oxconfig.php

Go to the documentation of this file.
00001 <?php
00002 
00003 //max integer
00004 define( 'MAX_64BIT_INTEGER', '18446744073709551615' );
00005 
00010 class oxConfig extends oxSuperCfg
00011 {
00012     // this column of params are defined in config.inc.php file,
00013     // so for backwards compatibility. names starts without underscore
00014 
00020     protected $dbHost = null;
00021 
00027     protected $dbName = null;
00028 
00034     protected $dbUser = null;
00035 
00041     protected $dbPwd  = null;
00042 
00048     protected $dbType = null;
00049 
00055     protected $sShopURL = null;
00056 
00062     protected $sSSLShopURL = null;
00063 
00069     protected $sAdminSSLURL = null;
00070 
00076     protected $sShopDir = null;
00077 
00083     protected $sCompileDir = null;
00084 
00099     protected $iDebug = 0;
00100 
00106     protected $sAdminEmail = null;
00107 
00113     protected $blSessionUseCookies = null;
00114 
00124     protected $blNativeImages = true;
00125 
00131     protected $aMultiShopTables = array( 'oxarticles', 'oxdiscount', 'oxcategories', 'oxattribute',
00132                                          'oxlinks', 'oxvoucherseries', 'oxmanufacturers',
00133                                          'oxnews', 'oxselectlist', 'oxwrapping',
00134                                          'oxdeliveryset', 'oxdelivery', 'oxvendor', 'oxobject2category');
00135 
00141     private static $_instance = null;
00142 
00148     private $_oStart = null;
00149 
00150 
00156     protected $_oActShop       = null;
00157 
00165     protected $_aActiveViews   = array();
00166 
00172     protected $_aGlobalParams = array();
00173 
00179     protected $_aConfigParams = array();
00180 
00186     protected $_aThemeConfigParams = array();
00187 
00193     protected $_iLanguageId = null;
00194 
00200     protected $_iShopId = null;
00201 
00202 
00208     protected $_sOutDir = 'out';
00209 
00215     protected $_sImageDir = 'img';
00216 
00222     protected $_sPictureDir = 'pictures';
00223 
00229     protected $_sMasterPictureDir = 'master';
00230 
00236     protected $_sTemplateDir = 'tpl';
00237 
00243     protected $_sResourceDir = 'src';
00244 
00250     protected $_sModulesDir = 'modules';
00251 
00257     protected $_blIsSsl = null;
00258 
00264     protected $_aAbsDynImageDir = array();
00265 
00271     protected $_oActCurrencyObject = null;
00272 
00280     protected $_blInit = false;
00281 
00287     const OXMODULE_THEME_PREFIX = 'theme:';
00288 
00294     const OXMODULE_MODULE_PREFIX = 'module:';
00295 
00303     public function getConfigParam( $sName )
00304     {
00305 
00306         if ( defined( 'OXID_PHP_UNIT' ) ) {
00307             if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
00308                 $sValue = modConfig::$unitMOD->getModConfigParam( $sName );
00309                 if ( $sValue !== null ) {
00310                     return $sValue;
00311                 }
00312             }
00313         }
00314 
00315         $this->init();
00316 
00317         if ( isset ( $this->_aConfigParams[$sName] ) ) {
00318             return $this->_aConfigParams[$sName];
00319         }
00320 
00321         if ( isset( $this->$sName ) ) {
00322             return $this->$sName;
00323         }
00324 
00325     }
00326 
00335     public function setConfigParam( $sName, $sValue )
00336     {
00337         if ( isset( $this->$sName ) ) {
00338             $this->$sName = $sValue;
00339         } else {
00340             $this->_aConfigParams[$sName] = $sValue;
00341         }
00342     }
00343 
00349     protected function _processSeoCall()
00350     {
00351         // TODO: refactor shop bootstrap and parse url params as soon as possible
00352         if (isSearchEngineUrl()) {
00353             oxNew('oxSeoDecoder')->processSeoCall();
00354         }
00355     }
00356 
00364     public function init()
00365     {
00366         // Duplicated init protection
00367         if ($this->_blInit) {
00368            return;
00369         }
00370         $this->_blInit = true;
00371 
00372         $this->_loadVarsFromFile();
00373 
00374         include getShopBasePath().'core/oxconfk.php';
00375 
00376         // setting ADODB timeout
00377         global  $ADODB_SESS_LIFE;
00378         $ADODB_SESS_LIFE  = 1;
00379 
00380         // some important defaults
00381         $this->_setDefaults();
00382 
00383         try {
00384             $sShopID = $this->getShopId();
00385             $blConfigLoaded = $this->_loadVarsFromDb( $sShopID );
00386 
00387             // loading shop config
00388             if ( empty($sShopID) || !$blConfigLoaded ) {
00389                 // if no config values where loaded (some problems with DB), throwing an exception
00390                 $oEx = oxNew( "oxConnectionException" );
00391                 $oEx->setMessage( "Unable to load shop config values from database" );
00392                 throw $oEx;
00393             }
00394 
00395             // loading theme config options
00396             $this->_loadVarsFromDb( $sShopID, null, oxConfig::OXMODULE_THEME_PREFIX . $this->getConfigParam('sTheme') );
00397 
00398             // checking if custom theme (which has defined parent theme) config options should be loaded over parent theme (#3362)
00399             if ( $this->getConfigParam('sCustomTheme') ) {
00400                 $this->_loadVarsFromDb( $sShopID, null, oxConfig::OXMODULE_THEME_PREFIX . $this->getConfigParam('sCustomTheme') );
00401             }
00402 
00403             // loading modules config
00404             $this->_loadVarsFromDb( $sShopID, null, oxConfig::OXMODULE_MODULE_PREFIX );
00405 
00406 
00407             $this->_processSeoCall();
00408 
00409             //starting up the session
00410             $this->getSession()->start();
00411 
00412 
00413             // Admin handling
00414             $this->setConfigParam( 'blAdmin', isAdmin() );
00415 
00416             if ( defined('OX_ADMIN_DIR') ) {
00417                 $this->setConfigParam( 'sAdminDir', OX_ADMIN_DIR );
00418             }
00419 
00420             $this->_loadVarsFromFile();
00421 
00422             //application initialization
00423             $this->_oStart = new oxStart();
00424             $this->_oStart->appInit();
00425         } catch ( oxConnectionException $oEx ) {
00426             return $this->_handleDbConnectionException( $oEx );
00427         } catch ( oxCookieException $oEx ) {
00428             return $this->_handleCookieException( $oEx );
00429         }    
00430     }
00431 
00439     public static function getInstance()
00440     {
00441         return oxRegistry::getConfig();
00442     }
00443 
00449     protected function _loadVarsFromFile()
00450     {
00451         //config variables from config.inc.php takes priority over the ones loaded from db
00452         include getShopBasePath().'/config.inc.php';
00453 
00454         //adding trailing slashes
00455         $oFileUtils = oxRegistry::get("oxUtilsFile");
00456         $this->sShopDir     = $oFileUtils->normalizeDir($this->sShopDir);
00457         $this->sCompileDir  = $oFileUtils->normalizeDir($this->sCompileDir);
00458         $this->sShopURL     = $oFileUtils->normalizeDir($this->sShopURL);
00459         $this->sSSLShopURL  = $oFileUtils->normalizeDir($this->sSSLShopURL);
00460         $this->sAdminSSLURL = $oFileUtils->normalizeDir($this->sAdminSSLURL);
00461 
00462         $this->_loadCustomConfig();
00463     }
00464 
00470     protected function _setDefaults()
00471     {
00472 
00473         // some important defaults
00474         if( !$this->getConfigParam( 'sDefaultLang' ) )
00475             $this->setConfigParam( 'sDefaultLang', 0 );
00476 
00477 
00478         $this->setConfigParam( 'sTheme', 'azure' );
00479 
00480 
00481         $blLogChangesInAdmin = $this->getConfigParam( 'blLogChangesInAdmin' );
00482         if( !isset( $blLogChangesInAdmin ) )
00483             $this->setConfigParam( 'blLogChangesInAdmin', false );
00484 
00485         $blCheckTemplates = $this->getConfigParam( 'blCheckTemplates' );
00486         if( !isset( $blCheckTemplates ) )
00487             $this->setConfigParam( 'blCheckTemplates', false );
00488 
00489         $blAllowArticlesubclass = $this->getConfigParam( 'blAllowArticlesubclass' );
00490         if( !isset( $blAllowArticlesubclass ) )
00491             $this->setConfigParam( 'blAllowArticlesubclass', false );
00492 
00493         $iAdminListSize = $this->getConfigParam( 'iAdminListSize' );
00494         if( !isset( $iAdminListSize ) )
00495             $this->setConfigParam( 'iAdminListSize', 9 );
00496 
00497         // #1173M  for EE - not all pic are deleted
00498         $iPicCount = $this->getConfigParam( 'iPicCount' );
00499         if ( !isset( $iPicCount ) )
00500             $this->setConfigParam( 'iPicCount', 7 );
00501 
00502         $iZoomPicCount = $this->getConfigParam( 'iZoomPicCount' );
00503         if ( !isset( $iZoomPicCount ) )
00504             $this->setConfigParam( 'iZoomPicCount', 4 );
00505 
00506         // ADODB cache life time
00507         $iDBCacheLifeTime = $this->getConfigParam( 'iDBCacheLifeTime' );
00508         if ( !isset( $iDBCacheLifeTime ) )
00509             $this->setConfigParam( 'iDBCacheLifeTime', 3600 ); // 1 hour
00510 
00511         $sCoreDir = $this->getConfigParam( 'sShopDir' );
00512         $this->setConfigParam( 'sCoreDir', $sCoreDir.'/core/' );
00513     }
00514 
00520     protected function _loadCustomConfig()
00521     {
00522         $sCustConfig = getShopBasePath().'/cust_config.inc.php';
00523         if ( is_readable( $sCustConfig ) ) {
00524             include $sCustConfig;
00525         }
00526     }
00527 
00537     protected function _loadVarsFromDb( $sShopID, $aOnlyVars = null, $sModule = '' )
00538     {
00539         $oDb = oxDb::getDb();
00540 
00541         if ( !empty($sModule) ) {
00542             $sModuleSql = " oxmodule LIKE " . $oDb->quote($sModule."%");
00543         } else {
00544             $sModuleSql = " oxmodule='' ";
00545         }
00546 
00547         $sQ = "select oxvarname, oxvartype, ".$this->getDecodeValueQuery()." as oxvarvalue from oxconfig where oxshopid = '$sShopID' and " . $sModuleSql;
00548         // dodger, allow loading from some vars only from baseshop
00549         if ( $aOnlyVars !== null ) {
00550             $blSep = false;
00551             $sIn  = '';
00552             foreach ( $aOnlyVars as $sField ) {
00553                 if ( $blSep ) {
00554                     $sIn .= ', ';
00555                 }
00556                 $sIn .= '"'.$sField.'"';
00557                 $blSep = true;
00558             }
00559             $sQ .= ' and oxvarname in ( '.$sIn.' ) ';
00560         }
00561         $oRs = $oDb->select( $sQ );
00562 
00563         if ( $oRs != false && $oRs->recordCount() > 0 ) {
00564             while ( !$oRs->EOF ) {
00565                 $sVarName = $oRs->fields[0];
00566                 $sVarType = $oRs->fields[1];
00567                 $sVarVal  = $oRs->fields[2];
00568 
00569                 //in sShopURL and sSSLShopURL cases we skip (for admin or when URL values are not set)
00570                 if ( ( $sVarName == 'sShopURL' || $sVarName == 'sSSLShopURL' ) &&
00571                     ( !$sVarVal || $this->isAdmin() === true ) ) {
00572                     $oRs->moveNext();
00573                     continue;
00574                 }
00575 
00576                 $this->_setConfVarFromDb($sVarName, $sVarType, $sVarVal);
00577 
00578                 //setting theme options array
00579                 if ( $sModule != '' ) {
00580                     $this->_aThemeConfigParams[$sVarName] = $sModule;
00581                 }
00582 
00583                 $oRs->moveNext();
00584             }
00585 
00586             return true;
00587         } else {
00588             return false;
00589         }
00590     }
00591 
00601     protected function _setConfVarFromDb($sVarName, $sVarType, $sVarVal)
00602     {
00603         switch ( $sVarType ) {
00604             case 'arr':
00605             case 'aarr':
00606                 $this->setConfigParam( $sVarName, unserialize( $sVarVal ) );
00607                 break;
00608             case 'bool':
00609                 $this->setConfigParam( $sVarName, ( $sVarVal == 'true' || $sVarVal == '1' ) );
00610                 break;
00611             default:
00612                 $this->setConfigParam( $sVarName, $sVarVal );
00613                 break;
00614         }
00615     }
00616 
00622     public function pageClose()
00623     {
00624         if ( $this->hasActiveViewsChain() ) {
00625             // do not commit session until active views chain exists
00626             return;
00627         }
00628 
00629         return $this->_oStart->pageClose();
00630     }
00631 
00644     public static function getParameter( $sName, $blRaw = false )
00645     {
00646         return oxRegistry::getConfig()->getRequestParameter( $sName, $blRaw );
00647     }
00648 
00660     public function getRequestParameter( $sName, $blRaw = false )
00661     {
00662         if ( defined( 'OXID_PHP_UNIT' ) ) {
00663             if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
00664                 try{
00665                     $sValue = modConfig::getParameter(  $sName, $blRaw );
00666 
00667                     // TODO: remove this after special chars concept implementation
00668                     $blIsAdmin = modConfig::getInstance()->isAdmin() || modSession::getInstance()->getVariable(  "blIsAdmin" );
00669                     if ( $sValue !== null && !$blIsAdmin && (!$blRaw || is_array($blRaw))) {
00670                         $this->checkParamSpecialChars( $sValue, $blRaw );
00671                     }
00672 
00673                     return $sValue;
00674                 } catch( Exception $e ) {
00675                     // if exception is thrown, use default
00676                 }
00677             }
00678         }
00679 
00680         $sValue = null;
00681 
00682         if ( isset( $_POST[$sName] ) ) {
00683             $sValue = $_POST[$sName];
00684         } elseif ( isset( $_GET[$sName] ) ) {
00685             $sValue = $_GET[$sName];
00686         }
00687 
00688         // TODO: remove this after special chars concept implementation
00689         $blIsAdmin = $this->isAdmin() && $this->getSession()->getVariable( "blIsAdmin" );
00690         if ( $sValue !== null && !$blIsAdmin && (!$blRaw || is_array($blRaw))) {
00691             $this->checkParamSpecialChars( $sValue, $blRaw );
00692         }
00693 
00694         return $sValue;
00695     }
00696 
00704     public function getUploadedFile($sParamName)
00705     {
00706         return $_FILES[$sParamName];
00707     }
00708 
00717     public function setGlobalParameter( $sName, $sValue )
00718     {
00719         $this->_aGlobalParams[$sName] = $sValue;
00720     }
00721 
00729     public function getGlobalParameter( $sName )
00730     {
00731         if ( isset( $this->_aGlobalParams[$sName] ) ) {
00732             return $this->_aGlobalParams[$sName];
00733         } else {
00734             return null;
00735         }
00736     }
00737 
00749     public static function checkSpecialChars( & $sValue, $aRaw = null )
00750     {
00751         return oxRegistry::getConfig()->checkParamSpecialChars( $sValue, $aRaw );
00752     }
00753 
00763     public function checkParamSpecialChars( & $sValue, $aRaw = null )
00764     {
00765         if ( is_object( $sValue ) ) {
00766             return $sValue;
00767         }
00768 
00769         if ( is_array( $sValue ) ) {
00770             $newValue = array();
00771             foreach ( $sValue as $sKey => $sVal ) {
00772                 $sValidKey = $sKey;
00773                 if ( !$aRaw || !in_array($sKey, $aRaw) ) {
00774                     $this->checkParamSpecialChars( $sValidKey );
00775                     $this->checkParamSpecialChars( $sVal );
00776                     if ($sValidKey != $sKey) {
00777                         unset ($sValue[$sKey]);
00778                     }
00779                 }
00780                 $newValue[$sValidKey] = $sVal;
00781             }
00782             $sValue = $newValue;
00783         } elseif ( is_string( $sValue ) ) {
00784             $sValue = str_replace( array( '&',     '<',    '>',    '"',      "'",      chr(0), '\\', "\n", "\r" ),
00785                                    array( '&amp;', '&lt;', '&gt;', '&quot;', '&#039;', '', '&#092;', '&#10;', '&#13;' ),
00786                                    $sValue );
00787         }
00788         return $sValue;
00789     }
00790 
00796     public function getShopId()
00797     {
00798         if ( $this->_iShopId !== null )
00799             return $this->_iShopId;
00800 
00801             $this->_iShopId = $this->getBaseShopId();
00802 
00803 
00804         $this->getSession()->setVariable( 'actshop', $this->_iShopId );
00805         return $this->_iShopId;
00806     }
00807 
00808 
00816     public function setShopId( $sShopId )
00817     {
00818         $this->getSession()->setVariable( 'actshop', $sShopId );
00819         $this->_iShopId = $sShopId;
00820     }
00821 
00822 
00823 
00831     public function setIsSsl( $blIsSsl = false )
00832     {
00833         $this->_blIsSsl = $blIsSsl;
00834     }
00835 
00841     protected function _checkSsl()
00842     {
00843             $myUtilsServer   = oxRegistry::get("oxUtilsServer");
00844             $aServerVars     = $myUtilsServer->getServerVar();
00845             $aHttpsServerVar = $myUtilsServer->getServerVar( 'HTTPS' );
00846 
00847             $this->setIsSsl();
00848             if (isset( $aHttpsServerVar ) && ($aHttpsServerVar === 'on' || $aHttpsServerVar === 'ON' || $aHttpsServerVar == '1' )) {
00849                 // "1&1" hoster provides "1"
00850                 $this->setIsSsl($this->getConfigParam('sSSLShopURL') || $this->getConfigParam('sMallSSLShopURL')) ;
00851                 if ($this->isAdmin() && !$this->_blIsSsl) {
00852                     //#4026
00853                      $this->setIsSsl( !is_null($this->getConfigParam('sAdminSSLURL')) );
00854                 }
00855             }
00856 
00857             //additional special handling for profihost customers
00858             if ( isset( $aServerVars['HTTP_X_FORWARDED_SERVER'] ) &&
00859                  ( strpos( $aServerVars['HTTP_X_FORWARDED_SERVER'], 'ssl' ) !== false ||
00860                  strpos( $aServerVars['HTTP_X_FORWARDED_SERVER'], 'secure-online-shopping.de' ) !== false ) ) {
00861                  $this->setIsSsl( true );
00862             }
00863 
00864     }
00865 
00866 
00872     public function isSsl()
00873     {
00874         if ( is_null( $this->_blIsSsl ) ) {
00875             $this->_checkSsl();
00876         }
00877         return $this->_blIsSsl;
00878     }
00879 
00887     public function isCurrentUrl( $sURL )
00888     {
00889         // Missing protocol, cannot proceed, assuming true.
00890         if ( !$sURL || (strpos( $sURL, "http" ) !== 0)) {
00891             return true;
00892         }
00893 
00894         return oxRegistry::get("oxUtilsServer")->isCurrentUrl($sURL);
00895     }
00896 
00904     public function isCurrentProtocol( $sURL )
00905     {
00906         // Missing protocol, cannot proceed, assuming true.
00907         if ( !$sURL || (strpos( $sURL, "http" ) !== 0)) {
00908             return true;
00909         }
00910 
00911         return (strpos( $sURL, "https:" ) === 0) == $this->isSsl();
00912     }
00913 
00922     public function getShopUrl( $iLang = null, $blAdmin = null )
00923     {
00924         $blAdmin = isset( $blAdmin ) ? $blAdmin : $this->isAdmin();
00925         if ( $blAdmin ) {
00926             return $this->getConfigParam( 'sShopURL' );
00927         }
00928 
00929         // #680 per language another URL
00930         $iLang = isset( $iLang ) ? $iLang : oxRegistry::getLang()->getBaseLanguage();
00931         $aLanguageURLs = $this->getConfigParam( 'aLanguageURLs' );
00932         if ( isset( $iLang ) && isset( $aLanguageURLs[$iLang] ) && !empty( $aLanguageURLs[$iLang] ) ) {
00933             $aLanguageURLs[$iLang] = oxRegistry::getUtils()->checkUrlEndingSlash( $aLanguageURLs[$iLang] );
00934             return $aLanguageURLs[$iLang];
00935         }
00936 
00937         //normal section
00938         $sMallShopURL = $this->getConfigParam( 'sMallShopURL' );
00939         if ( $sMallShopURL ) {
00940             $sMallShopURL = oxRegistry::getUtils()->checkUrlEndingSlash( $sMallShopURL );
00941             return $sMallShopURL;
00942         }
00943 
00944         return $this->getConfigParam( 'sShopURL' );
00945     }
00946 
00954     public function getSslShopUrl( $iLang = null )
00955     {
00956         // #680 per language another URL
00957         $iLang = isset( $iLang ) ? $iLang : oxRegistry::getLang()->getBaseLanguage();
00958         $aLanguageSSLURLs = $this->getConfigParam( 'aLanguageSSLURLs' );
00959         if ( isset( $iLang ) && isset( $aLanguageSSLURLs[$iLang] ) && !empty( $aLanguageSSLURLs[$iLang] ) ) {
00960             $aLanguageSSLURLs[$iLang] = oxRegistry::getUtils()->checkUrlEndingSlash( $aLanguageSSLURLs[$iLang] );
00961             return $aLanguageSSLURLs[$iLang];
00962         }
00963 
00964         //mall mode
00965         if ( ( $sMallSSLShopURL = $this->getConfigParam( 'sMallSSLShopURL' ) ) ) {
00966             $sMallSSLShopURL = oxRegistry::getUtils()->checkUrlEndingSlash( $sMallSSLShopURL );
00967             return $sMallSSLShopURL;
00968         }
00969 
00970         if ( ( $sMallShopURL = $this->getConfigParam( 'sMallShopURL' ) ) ) {
00971             $sMallShopURL = oxRegistry::getUtils()->checkUrlEndingSlash( $sMallShopURL );
00972             return $sMallShopURL;
00973         }
00974 
00975         //normal section
00976         if ( ( $sSSLShopURL = $this->getConfigParam( 'sSSLShopURL' ) ) ) {
00977             return $sSSLShopURL;
00978         }
00979 
00980         return $this->getShopUrl( $iLang );
00981     }
00982 
00988     public function getCoreUtilsUrl()
00989     {
00990         return $this->getCurrentShopUrl().'core/utils/';
00991     }
00992 
01001     public function getCurrentShopUrl($blAdmin = null)
01002     {
01003         if ($blAdmin===null) {
01004             $blAdmin = $this->isAdmin();
01005         }
01006         if ($blAdmin) {
01007             if ($this->isSsl()) {
01008 
01009                 $sUrl = $this->getConfigParam( 'sAdminSSLURL' );
01010                 if ( !$sUrl ) {
01011                     return $this->getSslShopUrl() . $this->getConfigParam( 'sAdminDir' ) . '/';
01012                 }
01013                 return $sUrl;
01014             } else {
01015                 return $this->getShopUrl() . $this->getConfigParam( 'sAdminDir' ) . '/';
01016             }
01017         } else {
01018             return $this->isSsl() ? $this->getSslShopUrl() : $this->getShopUrl();
01019         }
01020     }
01021 
01029     public function getShopCurrentUrl( $iLang = null )
01030     {
01031         if ( $this->isSsl() ) {
01032             $sURL = $this->getSSLShopURL( $iLang );
01033         } else {
01034             $sURL = $this->getShopURL( $iLang );
01035         }
01036 
01037         return oxRegistry::get("oxUtilsUrl")->processUrl( $sURL.'index.php', false );
01038     }
01039 
01048     public function getShopHomeUrl( $iLang = null, $blAdmin = null )
01049     {
01050         return oxRegistry::get("oxUtilsUrl")->processUrl($this->getShopUrl( $iLang, $blAdmin).'index.php', false );
01051     }
01052 
01061     public function getWidgetUrl( $iLang = null, $blAdmin = null )
01062     {
01063         return oxRegistry::get("oxUtilsUrl")->processUrl($this->getShopUrl( $iLang, $blAdmin).'widget.php', false );
01064     }
01065 
01071     public function getShopSecureHomeUrl()
01072     {
01073         return  oxRegistry::get("oxUtilsUrl")->processUrl( $this->getSslShopUrl().'index.php', false );
01074     }
01075 
01081     public function getShopCurrency()
01082     {
01083         $iCurr = null;
01084         if ( ( null === ( $iCurr = $this->getRequestParameter( 'cur' ) ) ) ) {
01085             if ( null === ( $iCurr = $this->getRequestParameter( 'currency' ) ) ) {
01086                 $iCurr = $this->getSession()->getVariable( 'currency' );
01087             }
01088         }
01089         return (int) $iCurr;
01090     }
01091 
01097     public function getActShopCurrencyObject()
01098     {
01099         //caching currency as it does not change through the script
01100         //but not for unit tests as ther it changes always
01101         if ( !defined( 'OXID_PHP_UNIT' ) ) {
01102             if (!is_null($this->_oActCurrencyObject)) {
01103                 return $this->_oActCurrencyObject;
01104             }
01105         }
01106 
01107         $iCur = $this->getShopCurrency();
01108         $aCurrencies = $this->getCurrencyArray();
01109         if ( !isset( $aCurrencies[$iCur] ) ) {
01110             return $this->_oActCurrencyObject = reset( $aCurrencies ); // reset() returns the first element
01111         }
01112 
01113         return $this->_oActCurrencyObject = $aCurrencies[$iCur];
01114     }
01115 
01123     public function setActShopCurrency( $iCur )
01124     {
01125         $aCurrencies = $this->getCurrencyArray();
01126         if ( isset( $aCurrencies[$iCur] ) ) {
01127             $this->getSession()->setVariable( 'currency', $iCur );
01128             $this->_oActCurrencyObject = null;
01129         }
01130     }
01131 
01139     public function getOutDir( $blAbsolute = true)
01140     {
01141         if ($blAbsolute) {
01142             return $this->getConfigParam('sShopDir').$this->_sOutDir.'/';
01143         } else {
01144             return $this->_sOutDir.'/';
01145         }
01146     }
01147 
01155     public function getViewsDir( $blAbsolute = true )
01156     {
01157         if ($blAbsolute) {
01158             return $this->getConfigParam('sShopDir'). 'application/views/';
01159         } else {
01160             return 'application/views/';
01161         }
01162     }
01163 
01173     public function getTranslationsDir( $sFile, $sDir, $blAbsolute = true )
01174     {
01175         $sPath = $blAbsolute ? $this->getConfigParam( 'sShopDir' ) : '';
01176         $sPath .= 'application/translations/';
01177         if ( is_readable( $sPath. $sDir. '/'. $sFile ) ) {
01178             return $sPath. $sDir. '/'. $sFile;
01179         }
01180         return false;
01181     }
01182 
01190     public function getAppDir( $blAbsolute = true )
01191     {
01192         if ($blAbsolute) {
01193             return $this->getConfigParam('sShopDir'). 'application/';
01194         } else {
01195             return 'application/';
01196         }
01197     }
01198 
01208     public function getOutUrl( $blSSL = null , $blAdmin = null, $blNativeImg = false )
01209     {
01210         $blSSL    = is_null($blSSL)?$this->isSsl():$blSSL;
01211         $blAdmin  = is_null($blAdmin)?$this->isAdmin():$blAdmin;
01212 
01213         if ( $blSSL ) {
01214             if ($blNativeImg && !$blAdmin) {
01215                 $sUrl = $this->getSslShopUrl();
01216             } else {
01217                 $sUrl = $this->getConfigParam('sSSLShopURL');
01218                 if (!$sUrl && $blAdmin) {
01219                     $sUrl = $this->getConfigParam('sAdminSSLURL').'../';
01220                 }
01221             }
01222         } else {
01223             $sUrl = ($blNativeImg && !$blAdmin )?$this->getShopUrl():$this->getConfigParam( 'sShopURL' );
01224         }
01225 
01226         return $sUrl.$this->_sOutDir.'/';
01227     }
01228 
01243     public function getDir($sFile, $sDir, $blAdmin, $iLang = null, $iShop = null, $sTheme = null, $blAbsolute = true, $blIgnoreCust = false  )
01244     {
01245         if ( is_null($sTheme) ) {
01246             $sTheme = $this->getConfigParam( 'sTheme' );
01247         }
01248 
01249         if ( $blAdmin ) {
01250             $sTheme = 'admin';
01251         }
01252 
01253         if ( $sDir != $this->_sTemplateDir ) {
01254             $sBase    = $this->getOutDir( $blAbsolute );
01255             $sAbsBase = $this->getOutDir();
01256         } else {
01257             $sBase    = $this->getViewsDir( $blAbsolute );
01258             $sAbsBase = $this->getViewsDir();
01259         }
01260 
01261         $sLang = '-';
01262         // FALSE means skip language folder check
01263         if ( $iLang !== false ) {
01264             $oLang = oxRegistry::getLang();
01265 
01266             if ( is_null( $iLang ) ) {
01267                 $iLang = $oLang->getEditLanguage();
01268             }
01269 
01270             $sLang = $oLang->getLanguageAbbr( $iLang );
01271         }
01272 
01273         if ( is_null($iShop) ) {
01274             $iShop = $this->getShopId();
01275         }
01276 
01277         //Load from
01278         $sPath = "{$sTheme}/{$iShop}/{$sLang}/{$sDir}/{$sFile}";
01279         $sCacheKey = $sPath . "_{$blIgnoreCust}{$blAbsolute}";
01280 
01281         if ( ( $sReturn = oxRegistry::getUtils()->fromStaticCache( $sCacheKey ) ) !== null ) {
01282             return $sReturn;
01283         }
01284 
01285         $sReturn = false;
01286 
01287         // Check for custom template
01288         $sCustomTheme = $this->getConfigParam( 'sCustomTheme' );
01289         if ( !$blAdmin && !$blIgnoreCust && $sCustomTheme && $sCustomTheme != $sTheme) {
01290             $sReturn = $this->getDir( $sFile, $sDir, $blAdmin, $iLang, $iShop, $sCustomTheme, $blAbsolute );
01291         }
01292 
01293         //test lang level ..
01294         if ( !$sReturn && !$blAdmin && is_readable( $sAbsBase.$sPath ) ) {
01295             $sReturn = $sBase . $sPath;
01296         }
01297 
01298         //test shop level ..
01299         $sPath = "$sTheme/$iShop/$sDir/$sFile";
01300         if ( !$sReturn && !$blAdmin && is_readable( $sAbsBase.$sPath ) ) {
01301             $sReturn = $sBase . $sPath;
01302         }
01303 
01304 
01305         //test theme language level ..
01306         $sPath = "$sTheme/$sLang/$sDir/$sFile";
01307         if ( !$sReturn && $iLang !== false && is_readable( $sAbsBase.$sPath ) ) {
01308             $sReturn = $sBase . $sPath;
01309         }
01310 
01311         //test theme level ..
01312         $sPath = "$sTheme/$sDir/$sFile";
01313         if ( !$sReturn && is_readable( $sAbsBase.$sPath ) ) {
01314             $sReturn = $sBase . $sPath;
01315         }
01316 
01317         //test out language level ..
01318         $sPath = "$sLang/$sDir/$sFile";
01319         if ( !$sReturn &&  $iLang !== false && is_readable( $sAbsBase.$sPath ) ) {
01320             $sReturn = $sBase . $sPath;
01321         }
01322 
01323         //test out level ..
01324         $sPath = "$sDir/$sFile";
01325         if ( !$sReturn && is_readable( $sAbsBase.$sPath ) ) {
01326             $sReturn = $sBase . $sPath;
01327         }
01328 
01329         if ( !$sReturn ) {
01330             // TODO: implement logic to log missing paths
01331         }
01332 
01333         // to cache
01334         oxRegistry::getUtils()->toStaticCache( $sCacheKey, $sReturn );
01335 
01336         return $sReturn;
01337     }
01338 
01353     public function getUrl($sFile, $sDir , $blAdmin = null, $blSSL = null, $blNativeImg = false, $iLang = null , $iShop = null , $sTheme = null )
01354     {
01355         $sUrl = str_replace(
01356                                 $this->getOutDir(),
01357                                 $this->getOutUrl($blSSL, $blAdmin, $blNativeImg),
01358                                 $this->getDir( $sFile, $sDir, $blAdmin, $iLang, $iShop, $sTheme )
01359                             );
01360 
01361         return $sUrl;
01362     }
01363 
01372     public function getImagePath( $sFile, $blAdmin = false )
01373     {
01374         return $this->getDir( $sFile, $this->_sImageDir, $blAdmin );
01375     }
01376 
01387     public function getImageUrl( $blAdmin = false, $blSSL = null, $blNativeImg = null, $sFile = null )
01388     {
01389         $blNativeImg = is_null($blNativeImg)?$this->getConfigParam( 'blNativeImages' ):$blNativeImg;
01390         return $this->getUrl( $sFile, $this->_sImageDir, $blAdmin, $blSSL, $blNativeImg );
01391     }
01392 
01400     public function getImageDir( $blAdmin = false )
01401     {
01402         return $this->getDir( null, $this->_sImageDir, $blAdmin );
01403     }
01404 
01416     public function getPicturePath($sFile, $blAdmin = false, $iLang = null , $iShop = null , $sTheme = null)
01417     {
01418         return $this->getDir( $sFile, $this->_sPictureDir, $blAdmin, $iLang, $iShop, $sTheme );
01419     }
01420 
01428     public function getMasterPictureDir( $blAdmin = false )
01429     {
01430         return $this->getDir( null, $this->_sPictureDir . "/" . $this->_sMasterPictureDir, $blAdmin );
01431     }
01432 
01441     public function getMasterPicturePath( $sFile, $blAdmin = false )
01442     {
01443         return $this->getDir( $sFile, $this->_sPictureDir . "/" . $this->_sMasterPictureDir, $blAdmin );
01444     }
01445 
01458     public function getPictureUrl( $sFile, $blAdmin = false, $blSSL = null, $iLang = null, $iShopId = null, $sDefPic = "master/nopic.jpg" )
01459     {
01460         if ( $sAltUrl = oxRegistry::get("oxPictureHandler")->getAltImageUrl('/', $sFile, $blSSL) ) {
01461             return $sAltUrl;
01462         }
01463 
01464         $blNativeImg = $this->getConfigParam( 'blNativeImages' );
01465         $sUrl = $this->getUrl( $sFile, $this->_sPictureDir, $blAdmin, $blSSL, $blNativeImg, $iLang, $iShopId );
01466 
01467         //anything is better than empty name, because <img src=""> calls shop once more = x2 SLOW.
01468         if ( !$sUrl && $sDefPic ) {
01469             $sUrl = $this->getUrl( $sDefPic, $this->_sPictureDir, $blAdmin, $blSSL, $blNativeImg, $iLang, $iShopId );
01470         }
01471         return $sUrl;
01472     }
01473 
01481     public function getPictureDir( $blAdmin )
01482     {
01483         return $this->getDir( null, $this->_sPictureDir, $blAdmin );
01484     }
01485 
01494     public function getTemplatePath( $sFile, $blAdmin )
01495     {
01496         $sTemplatePath = $this->getDir( $sFile, $this->_sTemplateDir, $blAdmin );
01497 
01498         if (!$sTemplatePath) {
01499             $sBasePath        = getShopBasePath();
01500             $aModuleTemplates = $this->getConfigParam('aModuleTemplates');
01501 
01502             $oModulelist = oxNew('oxmodulelist');
01503             $aActiveModuleInfo = $oModulelist->getActiveModuleInfo();
01504             if (is_array($aModuleTemplates) && is_array($aActiveModuleInfo)) {
01505                 foreach ($aModuleTemplates as $sModuleId => $aTemplates) {
01506                     if (isset($aTemplates[$sFile]) && isset($aActiveModuleInfo[$sModuleId])) {
01507                         $sPath = $aTemplates[$sFile];
01508                         $sPath = $sBasePath. 'modules/'.  $sPath;
01509                         if (is_file($sPath) && is_readable($sPath)) {
01510                             $sTemplatePath =  $sPath;
01511                         }
01512                     }
01513                 }
01514             }
01515         }
01516 
01517         return $sTemplatePath;
01518     }
01519 
01527     public function getTemplateDir( $blAdmin = false )
01528     {
01529         return $this->getDir( null, $this->_sTemplateDir, $blAdmin );
01530     }
01531 
01542     public function getTemplateUrl( $sFile = null, $blAdmin = false, $blSSL = null , $iLang = null )
01543     {
01544         return $this->getShopMainUrl() . $this->getDir( $sFile, $this->_sTemplateDir, $blAdmin, $iLang, null, null, false );
01545     }
01546 
01554     public function getTemplateBase( $blAdmin = false )
01555     {
01556         // Base template dir is the parent dir of template dir
01557         return str_replace( $this->_sTemplateDir.'/', '', $this->getDir( null, $this->_sTemplateDir, $blAdmin, null, null, null, false ));
01558     }
01559 
01568     public function getResourcePath($sFile = '', $blAdmin = false )
01569     {
01570         return $this->getDir( $sFile, $this->_sResourceDir, $blAdmin );
01571     }
01572 
01580     public function getModulesDir( $blAbsolute = true )
01581     {
01582         if ($blAbsolute) {
01583             return $this->getConfigParam('sShopDir') . $this->_sModulesDir . '/';
01584         } else {
01585             return $this->_sModulesDir . '/';
01586         }
01587     }
01588 
01599     public function getResourceUrl( $sFile = '', $blAdmin = false , $blSSL = null , $iLang = null )
01600     {
01601         $blNativeImg = $this->getConfigParam( 'blNativeImages' );
01602         return $this->getUrl( $sFile, $this->_sResourceDir, $blAdmin, $blSSL, $blNativeImg, $iLang );
01603     }
01604 
01612     public function getResourceDir( $blAdmin )
01613     {
01614         return $this->getDir( null, $this->_sResourceDir, $blAdmin );
01615     }
01616 
01624     public function getCurrencyArray( $iCurrency = null )
01625     {
01626         $aConfCurrencies = $this->getConfigParam( 'aCurrencies' );
01627         if ( !is_array( $aConfCurrencies ) ) {
01628             return array();
01629         }
01630 
01631         if ( defined( 'OXID_PHP_UNIT' ) ) {
01632             if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
01633                 try{
01634                     $aAltCurrencies = modConfig::getInstance()->getConfigParam( 'modaCurrencies' );
01635                     if ( isset( $aAltCurrencies ) ) {
01636                         $aConfCurrencies = $aAltCurrencies;
01637                     }
01638                 } catch( Exception $e ) {
01639                     // if exception is thrown, use default
01640                 }
01641             }
01642         }
01643 
01644         // processing currency configuration data
01645         $aCurrencies = array();
01646         reset( $aConfCurrencies );
01647         while ( list( $key, $val ) = each( $aConfCurrencies ) ) {
01648             if ( $val ) {
01649                 $oCur = new stdClass();
01650                 $oCur->id      = $key;
01651                 $sCur = explode( '@', $val);
01652                 $oCur->name     = trim( $sCur[0] );
01653                 $oCur->rate     = trim( $sCur[1] );
01654                 $oCur->dec      = trim( $sCur[2] );
01655                 $oCur->thousand = trim( $sCur[3] );
01656                 $oCur->sign     = trim( $sCur[4] );
01657                 $oCur->decimal  = trim( $sCur[5] );
01658 
01659                 // change for US version
01660                 if ( isset( $sCur[6] ) ) {
01661                     $oCur->side = trim($sCur[6]);
01662                 }
01663 
01664                 if ( isset( $iCurrency) && $key == $iCurrency ) {
01665                     $oCur->selected = 1;
01666                 } else {
01667                     $oCur->selected = 0;
01668                 }
01669                 $aCurrencies[$key]= $oCur;
01670             }
01671 
01672             // #861C -  performance, do not load other currencies
01673             if ( !$this->getConfigParam( 'bl_perfLoadCurrency' ) ) {
01674                 break;
01675             }
01676         }
01677         return $aCurrencies;
01678     }
01679 
01687     public function getCurrencyObject( $sName )
01688     {
01689         $aSearch = $this->getCurrencyArray();
01690         foreach ( $aSearch as $oCur ) {
01691             if ( $oCur->name == $sName ) {
01692                 return $oCur;
01693             }
01694         }
01695     }
01696 
01702     public function isDemoShop()
01703     {
01704         return $this->getConfigParam('blDemoShop');
01705     }
01706 
01707 
01708 
01714     public function getEdition()
01715     {
01716             return "CE";
01717 
01718 
01719     }
01720 
01726     public function getFullEdition()
01727     {
01728         $sEdition = $this->getEdition();
01729 
01730             if ($sEdition == "CE") {
01731                 return "Community Edition";
01732             }
01733 
01734 
01735 
01736         return $sEdition;
01737     }
01738 
01744     public function getVersion()
01745     {
01746         $sVersion = $this->getActiveShop()->oxshops__oxversion->value;
01747         return $sVersion;
01748     }
01749 
01755     public function getRevision()
01756     {
01757         $sFileName = $this->getConfigParam( 'sShopDir' ) . "/pkg.rev";
01758         $sRev = trim(@file_get_contents($sFileName));
01759 
01760         if (!$sRev) {
01761             return false;
01762         }
01763 
01764         return $sRev;
01765     }
01766 
01772     public function getPackageInfo()
01773     {
01774         $sFileName = $this->getConfigParam( 'sShopDir' ) . "/pkg.info";
01775         $sRev = @file_get_contents($sFileName);
01776         $sRev = str_replace("\n", "<br>", $sRev);
01777 
01778         if (!$sRev) {
01779             return false;
01780         }
01781 
01782         return $sRev;
01783     }
01784 
01785 
01791     public function isMall()
01792     {
01793 
01794             return false;
01795     }
01796 
01806     public function detectVersion()
01807     {
01808     }
01809 
01810 
01811 
01824     public function saveShopConfVar( $sVarType, $sVarName, $sVarVal, $sShopId = null, $sModule = '' )
01825     {
01826         switch ( $sVarType ) {
01827             case 'arr':
01828             case 'aarr':
01829                 $sValue = serialize( $sVarVal );
01830                 break;
01831             case 'bool':
01832                 //config param
01833                 $sVarVal = (( $sVarVal == 'true' || $sVarVal) && $sVarVal && strcasecmp($sVarVal, "false"));
01834                 //db value
01835                 $sValue  = $sVarVal?"1":"";
01836                 break;
01837             case 'num':
01838                 //config param
01839                 $sVarVal = $sVarVal != ''? oxRegistry::getUtils()->string2Float( $sVarVal ) : '';
01840                 $sValue = $sVarVal;
01841                 break;
01842             default:
01843                 $sValue  = $sVarVal;
01844                 break;
01845         }
01846 
01847         if ( !$sShopId ) {
01848             $sShopId = $this->getShopId();
01849         }
01850 
01851         // Update value only for current shop
01852         if ($sShopId == $this->getShopId()) {
01853             $this->setConfigParam( $sVarName, $sVarVal );
01854         }
01855 
01856         $oDb = oxDb::getDb();
01857 
01858         $sShopIdQuoted     = $oDb->quote($sShopId);
01859         $sModuleQuoted     = $oDb->quote($sModule);
01860         $sVarNameQuoted    = $oDb->quote($sVarName);
01861         $sVarTypeQuoted    = $oDb->quote($sVarType);
01862         $sVarValueQuoted   = $oDb->quote($sValue);
01863         $sConfigKeyQuoted  = $oDb->quote($this->getConfigParam('sConfigKey'));
01864         $sNewOXIDdQuoted   = $oDb->quote(oxUtilsObject::getInstance()->generateUID());
01865 
01866         $sQ = "delete from oxconfig where oxshopid = $sShopIdQuoted and oxvarname = $sVarNameQuoted and oxmodule = $sModuleQuoted";
01867         $oDb->execute( $sQ );
01868 
01869         $sQ = "insert into oxconfig (oxid, oxshopid, oxmodule, oxvarname, oxvartype, oxvarvalue)
01870                values($sNewOXIDdQuoted, $sShopIdQuoted, $sModuleQuoted, $sVarNameQuoted, $sVarTypeQuoted, ENCODE( $sVarValueQuoted, $sConfigKeyQuoted) )";
01871         $oDb->execute( $sQ );
01872 
01873 
01874 
01875     }
01876 
01877 
01887     public function getShopConfVar( $sVarName, $sShopId = null, $sModule = '' )
01888     {
01889         if ( !$sShopId ) {
01890             $sShopId = $this->getShopId();
01891         }
01892 
01893         if ( $sShopId === $this->getShopId() && ( !$sModule || $sModule == oxConfig::OXMODULE_THEME_PREFIX . $this->getConfigParam('sTheme') ) ) {
01894             $sVarValue = $this->getConfigParam( $sVarName );
01895             if ( $sVarValue !== null ) {
01896                 return $sVarValue;
01897             }
01898         }
01899 
01900         $oDb = oxDb::getDb( oxDb::FETCH_MODE_ASSOC );
01901 
01902         $sQ  = "select oxvartype, ".$this->getDecodeValueQuery()." as oxvarvalue from oxconfig where oxshopid = '{$sShopId}' and oxmodule = '{$sModule}' and oxvarname = ".$oDb->quote($sVarName);
01903         $oRs = $oDb->select( $sQ );
01904 
01905         $sValue = null;
01906         if ( $oRs != false && $oRs->recordCount() > 0 ) {
01907             $sValue = $this->decodeValue( $oRs->fields['oxvartype'], $oRs->fields['oxvarvalue'] );
01908         }
01909         return $sValue;
01910     }
01911 
01920     public function decodeValue( $sType, $mOrigValue )
01921     {
01922         $sValue = $mOrigValue;
01923         switch ( $sType ) {
01924             case 'arr':
01925             case 'aarr':
01926                 $sValue = unserialize( $mOrigValue );
01927                 break;
01928             case 'bool':
01929                 $sValue = ( $mOrigValue == 'true' || $mOrigValue == '1' );
01930                 break;
01931         }
01932 
01933         return $sValue;
01934     }
01935 
01943     public function getDecodeValueQuery( $sFieldName = "oxvarvalue" )
01944     {
01945         return " DECODE( {$sFieldName}, '".$this->getConfigParam( 'sConfigKey' )."') ";
01946     }
01947 
01953     public function isProductiveMode()
01954     {
01955         $blProductive = false;
01956 
01957         $blProductive = $this->getConfigParam( 'blProductive' );
01958         if ( !isset( $blProductive ) ) {
01959             $sQ = 'select oxproductive from oxshops where oxid = "'.$this->getShopId().'"';
01960             $blProductive = ( bool ) oxDb::getDb()->getOne( $sQ );
01961             $this->setConfigParam( 'blProductive', $blProductive );
01962         }
01963 
01964         return $blProductive;
01965     }
01966 
01967 
01968 
01974     public function getBaseShopId()
01975     {
01976 
01977             return 'oxbaseshop';
01978     }
01979 
01985     public function getActiveShop()
01986     {
01987         if ( $this->_oActShop && $this->_iShopId == $this->_oActShop->getId() &&
01988              $this->_oActShop->getLanguage() == oxRegistry::getLang()->getBaseLanguage() ) {
01989             return $this->_oActShop;
01990         }
01991 
01992         $this->_oActShop = oxNew( 'oxshop' );
01993         $this->_oActShop->load( $this->getShopId() );
01994         return $this->_oActShop;
01995     }
01996 
02002     public function getActiveView()
02003     {
02004         if ( count( $this->_aActiveViews ) ) {
02005             $oActView = end( $this->_aActiveViews );
02006         }
02007         if ( $oActView == null ) {
02008             $oActView = oxNew( 'oxubase' );
02009             $this->_aActiveViews[] = $oActView;
02010         }
02011 
02012         return $oActView;
02013     }
02014 
02020     public function getTopActiveView()
02021     {
02022         if ( count( $this->_aActiveViews ) ) {
02023             return reset( $this->_aActiveViews );
02024         } else {
02025             return $this->getActiveView();
02026         }
02027     }
02028 
02034     public function getActiveViewsList()
02035     {
02036         return $this->_aActiveViews;
02037     }
02038 
02046     public function setActiveView( $oView )
02047     {
02048         $this->_aActiveViews[] = $oView;
02049     }
02050 
02056     public function dropLastActiveView()
02057     {
02058         array_pop( $this->_aActiveViews );
02059     }
02060 
02066     public function hasActiveViewsChain()
02067     {
02068         return ( count( $this->_aActiveViews ) > 1 );
02069     }
02070 
02076     public function getActiveViewsNames()
02077     {
02078         $aNames = array();
02079 
02080         if ( is_array( $this->getActiveViewsList() ) ) {
02081             foreach ($this->getActiveViewsList() as $oView ) {
02082                 $aNames[] = $oView->getClassName();
02083             }
02084         }
02085 
02086         return $aNames;
02087     }
02088 
02094     public function isUtf()
02095     {
02096         return ( bool ) $this->getConfigParam( 'iUtfMode' );
02097     }
02098 
02104     public function getLogsDir()
02105     {
02106         return $this->getConfigParam( 'sShopDir' ).'log/';
02107     }
02108 
02116     public function isThemeOption( $sName )
02117     {
02118         return (bool) isset( $this->_aThemeConfigParams[$sName] );
02119     }
02120 
02126     public function getShopMainUrl()
02127     {
02128         return $this->_blIsSsl ? $this->getConfigParam( 'sSSLShopURL' ) : $this->getConfigParam( 'sShopURL' );
02129     }
02130 
02136     public function getAllModules()
02137     {
02138         return $this->parseModuleChains($this->getConfigParam('aModules'));
02139     }
02140 
02148     public function parseModuleChains($aModules)
02149     {
02150         $aModuleArray = array();
02151 
02152         if (is_array($aModules)) {
02153             foreach ($aModules as $sClass => $sModuleChain) {
02154                 if (strstr($sModuleChain, '&')) {
02155                     $aModuleChain = explode('&', $sModuleChain);
02156                 } else {
02157                     $aModuleChain = array($sModuleChain);
02158                 }
02159                 $aModuleArray[$sClass] = $aModuleChain;
02160             }
02161         }
02162 
02163         return $aModuleArray;
02164     }
02165 
02171     public function getShopIds()
02172     {
02173         return oxDb::getDb()->getCol( "SELECT `oxid` FROM `oxshops`" );
02174     }
02175 
02182     protected function _handleDbConnectionException( $oEx )
02183     {
02184         $oEx->debugOut();
02185         if ( defined( 'OXID_PHP_UNIT' ) ) {
02186             return false;
02187         } elseif ( 0 != $this->iDebug ) {
02188             oxRegistry::getUtils()->showMessageAndExit( $oEx->getString() );
02189         } else {
02190             header( "HTTP/1.1 500 Internal Server Error");
02191             header( "Location: offline.html");
02192             header( "Connection: close");
02193         }
02194     }
02195 
02202     protected function _handleCookieException( $oEx )
02203     {
02204         $this->_processSeoCall();
02205 
02206         //starting up the session
02207         $this->getSession()->start();
02208 
02209         // redirect to start page and display the error
02210         oxRegistry::get("oxUtilsView")->addErrorToDisplay( $oEx );
02211         oxRegistry::getUtils()->redirect( $this->getShopHomeURL() .'cl=start', true, 302 );
02212     }
02213 }