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 
00120     //protected $iMaxArticles = 6000;
00121 
00131     protected $blNativeImages = true;
00132 
00138     protected $aMultiShopTables = array( 'oxarticles', 'oxdiscount', 'oxcategories', 'oxattribute',
00139                                          'oxlinks', 'oxvoucherseries', 'oxmanufacturers',
00140                                          'oxnews', 'oxselectlist', 'oxwrapping',
00141                                          'oxdeliveryset', 'oxdelivery', 'oxvendor', 'oxobject2category');
00142 
00148     private static $_instance = null;
00149 
00155     private $_oStart = null;
00156 
00157 
00163     protected $_oActShop       = null;
00164 
00172     protected $_aActiveViews   = array();
00173 
00179     protected $_aGlobalParams = array();
00180 
00186     protected $_aConfigParams = array();
00187 
00193     protected $_aThemeConfigParams = array();
00194 
00200     protected $_iLanguageId = null;
00201 
00207     protected $_iShopId = null;
00208 
00209 
00215     protected $_sOutDir = 'out';
00216 
00222     protected $_sImageDir = 'img';
00223 
00229     protected $_sPictureDir = 'pictures';
00230 
00236     protected $_sMasterPictureDir = 'master';
00237 
00243     protected $_sTemplateDir = 'tpl';
00244 
00250     protected $_sResourceDir = 'src';
00251 
00257     protected $_sModulesDir = 'modules';
00258 
00264     protected $_blIsSsl = null;
00265 
00271     protected $_aAbsDynImageDir = array();
00272 
00278     protected $_oActCurrencyObject = null;
00279 
00287     protected $_blInit = false;
00288 
00294     const OXMODULE_THEME_PREFIX = 'theme:';
00295 
00301     const OXMODULE_MODULE_PREFIX = 'module:';
00302 
00308     const OXMAX_SHOP_COUNT = 256;
00309 
00317     public function getConfigParam( $sName )
00318     {
00319 
00320         if ( defined( 'OXID_PHP_UNIT' ) ) {
00321             if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
00322                 $sValue = modConfig::$unitMOD->getModConfigParam( $sName );
00323                 if ( $sValue !== null ) {
00324                     return $sValue;
00325                 }
00326             }
00327         }
00328 
00329         $this->init();
00330 
00331         if ( isset ( $this->_aConfigParams[$sName] ) ) {
00332             return $this->_aConfigParams[$sName];
00333         }
00334 
00335         if ( isset( $this->$sName ) ) {
00336             return $this->$sName;
00337         }
00338 
00339     }
00340 
00349     public function setConfigParam( $sName, $sValue )
00350     {
00351         if ( isset( $this->$sName ) ) {
00352             $this->$sName = $sValue;
00353         } else {
00354             $this->_aConfigParams[$sName] = $sValue;
00355         }
00356     }
00357 
00363     protected function _processSeoCall()
00364     {
00365         // TODO: refactor shop bootstrap and parse url params as soon as possible
00366         if (isSearchEngineUrl()) {
00367             oxNew('oxSeoDecoder')->processSeoCall();
00368         }
00369     }
00370 
00378     public function init()
00379     {
00380         // Duplicated init protection
00381         if ($this->_blInit) {
00382            return;
00383         }
00384         $this->_blInit = true;
00385 
00386         $this->_loadVarsFromFile();
00387 
00388         include getShopBasePath().'core/oxconfk.php';
00389 
00390         // setting ADODB timeout
00391         global  $ADODB_SESS_LIFE;
00392         $ADODB_SESS_LIFE  = 1;
00393 
00394         // some important defaults
00395         $this->_setDefaults();
00396 
00397         try {
00398             $sShopID = $this->getShopId();
00399             $blConfigLoaded = $this->_loadVarsFromDb( $sShopID );
00400 
00401             // loading shop config
00402             if ( empty($sShopID) || !$blConfigLoaded ) {
00403                 // if no config values where loaded (some problems with DB), throwing an exception
00404                 $oEx = oxNew( "oxConnectionException" );
00405                 $oEx->setMessage( "Unable to load shop config values from database" );
00406                 throw $oEx;
00407             }
00408 
00409             // loading theme config options
00410             $this->_loadVarsFromDb( $sShopID, null, oxConfig::OXMODULE_THEME_PREFIX . $this->getConfigParam('sTheme') );
00411 
00412             // checking if custom theme (which has defined parent theme) config options should be loaded over parent theme (#3362)
00413             if ( $this->getConfigParam('sCustomTheme') ) {
00414                 $this->_loadVarsFromDb( $sShopID, null, oxConfig::OXMODULE_THEME_PREFIX . $this->getConfigParam('sCustomTheme') );
00415             }
00416 
00417             // loading modules config
00418             $this->_loadVarsFromDb( $sShopID, null, oxConfig::OXMODULE_MODULE_PREFIX );
00419 
00420 
00421             $this->_processSeoCall();
00422 
00423             //starting up the session
00424             $this->getSession()->start();
00425 
00426         } catch ( oxConnectionException $oEx ) {
00427 
00428             $oEx->debugOut();
00429             if ( defined( 'OXID_PHP_UNIT' ) ) {
00430                 return false;
00431             } elseif ( 0 != $this->iDebug ) {
00432                 oxRegistry::getUtils()->showMessageAndExit( $oEx->getString() );
00433             } else {
00434                 header( "HTTP/1.1 500 Internal Server Error");
00435                 header( "Location: offline.html");
00436                 header( "Connection: close");
00437             }
00438         } catch ( oxCookieException $oEx ) {
00439 
00440             $this->_processSeoCall();
00441 
00442             //starting up the session
00443             $this->getSession()->start();
00444 
00445             // redirect to start page and display the error
00446             oxRegistry::get("oxUtilsView")->addErrorToDisplay( $oEx );
00447             oxRegistry::getUtils()->redirect( $this->getShopHomeURL() .'cl=start', true, 302 );
00448         }
00449 
00450 
00451         // Admin handling
00452         $this->setConfigParam( 'blAdmin', isAdmin() );
00453 
00454         if ( defined('OX_ADMIN_DIR') ) {
00455             $this->setConfigParam( 'sAdminDir', OX_ADMIN_DIR );
00456         }
00457 
00458         $this->_loadVarsFromFile();
00459 
00460         //application initialization
00461         $this->_oStart = new oxStart();
00462         $this->_oStart->appInit();
00463     }
00464 
00472     public static function getInstance()
00473     {
00474         return oxRegistry::getConfig();
00475     }
00476 
00482     protected function _loadVarsFromFile()
00483     {
00484         //config variables from config.inc.php takes priority over the ones loaded from db
00485         include getShopBasePath().'/config.inc.php';
00486 
00487         //adding trailing slashes
00488         $oFileUtils = oxRegistry::get("oxUtilsFile");
00489         $this->sShopDir     = $oFileUtils->normalizeDir($this->sShopDir);
00490         $this->sCompileDir  = $oFileUtils->normalizeDir($this->sCompileDir);
00491         $this->sShopURL     = $oFileUtils->normalizeDir($this->sShopURL);
00492         $this->sSSLShopURL  = $oFileUtils->normalizeDir($this->sSSLShopURL);
00493         $this->sAdminSSLURL = $oFileUtils->normalizeDir($this->sAdminSSLURL);
00494 
00495         $this->_loadCustomConfig();
00496     }
00497 
00503     protected function _setDefaults()
00504     {
00505 
00506         // some important defaults
00507         if( !$this->getConfigParam( 'sDefaultLang' ) )
00508             $this->setConfigParam( 'sDefaultLang', 0 );
00509 
00510 
00511         $this->setConfigParam( 'sTheme', 'azure' );
00512 
00513 
00514         $blLogChangesInAdmin = $this->getConfigParam( 'blLogChangesInAdmin' );
00515         if( !isset( $blLogChangesInAdmin ) )
00516             $this->setConfigParam( 'blLogChangesInAdmin', false );
00517 
00518         $blCheckTemplates = $this->getConfigParam( 'blCheckTemplates' );
00519         if( !isset( $blCheckTemplates ) )
00520             $this->setConfigParam( 'blCheckTemplates', false );
00521 
00522         $blAllowArticlesubclass = $this->getConfigParam( 'blAllowArticlesubclass' );
00523         if( !isset( $blAllowArticlesubclass ) )
00524             $this->setConfigParam( 'blAllowArticlesubclass', false );
00525 
00526         $iAdminListSize = $this->getConfigParam( 'iAdminListSize' );
00527         if( !isset( $iAdminListSize ) )
00528             $this->setConfigParam( 'iAdminListSize', 9 );
00529 
00530         // #1173M  for EE - not all pic are deleted
00531         $iPicCount = $this->getConfigParam( 'iPicCount' );
00532         if ( !isset( $iPicCount ) )
00533             $this->setConfigParam( 'iPicCount', 7 );
00534 
00535         $iZoomPicCount = $this->getConfigParam( 'iZoomPicCount' );
00536         if ( !isset( $iZoomPicCount ) )
00537             $this->setConfigParam( 'iZoomPicCount', 4 );
00538 
00539         //max shop id default value
00540         $iMaxShopId = $this->getConfigParam( 'iMaxShopId' );
00541         if ( !isset( $iMaxShopId ) ) {
00542             $this->setConfigParam( 'iMaxShopId', 128 );
00543         } elseif ( $iMaxShopId > self::OXMAX_SHOP_COUNT ) {
00544             $this->setConfigParam( 'iMaxShopId', self::OXMAX_SHOP_COUNT );
00545         }
00546 
00547         // ADODB cache life time
00548         $iDBCacheLifeTime = $this->getConfigParam( 'iDBCacheLifeTime' );
00549         if ( !isset( $iDBCacheLifeTime ) )
00550             $this->setConfigParam( 'iDBCacheLifeTime', 3600 ); // 1 hour
00551 
00552         $sCoreDir = $this->getConfigParam( 'sShopDir' );
00553         $this->setConfigParam( 'sCoreDir', $sCoreDir.'/core/' );
00554     }
00555 
00561     protected function _loadCustomConfig()
00562     {
00563         $sCustConfig = getShopBasePath().'/cust_config.inc.php';
00564         if ( is_readable( $sCustConfig ) ) {
00565             include $sCustConfig;
00566         }
00567     }
00568 
00578     protected function _loadVarsFromDb( $sShopID, $aOnlyVars = null, $sModule = '' )
00579     {
00580         $oDb = oxDb::getDb();
00581 
00582         if ( !empty($sModule) ) {
00583             $sModuleSql = " oxmodule LIKE " . $oDb->quote($sModule."%");
00584         } else {
00585             $sModuleSql = " oxmodule='' ";
00586         }
00587 
00588         $sQ = "select oxvarname, oxvartype, ".$this->getDecodeValueQuery()." as oxvarvalue from oxconfig where oxshopid = '$sShopID' and " . $sModuleSql;
00589         // dodger, allow loading from some vars only from baseshop
00590         if ( $aOnlyVars !== null ) {
00591             $blSep = false;
00592             $sIn  = '';
00593             foreach ( $aOnlyVars as $sField ) {
00594                 if ( $blSep ) {
00595                     $sIn .= ', ';
00596                 }
00597                 $sIn .= '"'.$sField.'"';
00598                 $blSep = true;
00599             }
00600             $sQ .= ' and oxvarname in ( '.$sIn.' ) ';
00601         }
00602         $oRs = $oDb->select( $sQ );
00603 
00604         if ( $oRs != false && $oRs->recordCount() > 0 ) {
00605             while ( !$oRs->EOF ) {
00606                 $sVarName = $oRs->fields[0];
00607                 $sVarType = $oRs->fields[1];
00608                 $sVarVal  = $oRs->fields[2];
00609 
00610                 //in sShopURL and sSSLShopURL cases we skip (for admin or when URL values are not set)
00611                 if ( ( $sVarName == 'sShopURL' || $sVarName == 'sSSLShopURL' ) &&
00612                     ( !$sVarVal || $this->isAdmin() === true ) ) {
00613                     $oRs->moveNext();
00614                     continue;
00615                 }
00616 
00617                 $this->_setConfVarFromDb($sVarName, $sVarType, $sVarVal);
00618 
00619                 //setting theme options array
00620                 if ( $sModule != '' ) {
00621                     $this->_aThemeConfigParams[$sVarName] = $sModule;
00622                 }
00623 
00624                 $oRs->moveNext();
00625             }
00626 
00627             return true;
00628         } else {
00629             return false;
00630         }
00631     }
00632 
00642     protected function _setConfVarFromDb($sVarName, $sVarType, $sVarVal)
00643     {
00644         switch ( $sVarType ) {
00645             case 'arr':
00646             case 'aarr':
00647                 $this->setConfigParam( $sVarName, unserialize( $sVarVal ) );
00648                 break;
00649             case 'bool':
00650                 $this->setConfigParam( $sVarName, ( $sVarVal == 'true' || $sVarVal == '1' ) );
00651                 break;
00652             default:
00653                 $this->setConfigParam( $sVarName, $sVarVal );
00654                 break;
00655         }
00656     }
00657 
00663     public function pageClose()
00664     {
00665         if ( $this->hasActiveViewsChain() ) {
00666             // do not commit session until active views chain exists
00667             return;
00668         }
00669 
00670         return $this->_oStart->pageClose();
00671     }
00672 
00685     public static function getParameter( $sName, $blRaw = false )
00686     {
00687         return oxRegistry::getConfig()->getRequestParameter( $sName, $blRaw );
00688     }
00689 
00701     public function getRequestParameter( $sName, $blRaw = false )
00702     {
00703         if ( defined( 'OXID_PHP_UNIT' ) ) {
00704             if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
00705                 try{
00706                     $sValue = modConfig::getParameter(  $sName, $blRaw );
00707 
00708                     // TODO: remove this after special chars concept implementation
00709                     $blIsAdmin = modConfig::getInstance()->isAdmin() || modSession::getInstance()->getVariable(  "blIsAdmin" );
00710                     if ( $sValue !== null && !$blIsAdmin && (!$blRaw || is_array($blRaw))) {
00711                         $this->checkParamSpecialChars( $sValue, $blRaw );
00712                     }
00713 
00714                     return $sValue;
00715                 } catch( Exception $e ) {
00716                     // if exception is thrown, use default
00717                 }
00718             }
00719         }
00720 
00721         $sValue = null;
00722 
00723         if ( isset( $_POST[$sName] ) ) {
00724             $sValue = $_POST[$sName];
00725         } elseif ( isset( $_GET[$sName] ) ) {
00726             $sValue = $_GET[$sName];
00727         }
00728 
00729         // TODO: remove this after special chars concept implementation
00730         $blIsAdmin = $this->isAdmin() && $this->getSession()->getVariable( "blIsAdmin" );
00731         if ( $sValue !== null && !$blIsAdmin && (!$blRaw || is_array($blRaw))) {
00732             $this->checkParamSpecialChars( $sValue, $blRaw );
00733         }
00734 
00735         return $sValue;
00736     }
00737 
00745     public function getUploadedFile($sParamName)
00746     {
00747         return $_FILES[$sParamName];
00748     }
00749 
00758     public function setGlobalParameter( $sName, $sValue )
00759     {
00760         $this->_aGlobalParams[$sName] = $sValue;
00761     }
00762 
00770     public function getGlobalParameter( $sName )
00771     {
00772         if ( isset( $this->_aGlobalParams[$sName] ) ) {
00773             return $this->_aGlobalParams[$sName];
00774         } else {
00775             return null;
00776         }
00777     }
00778 
00790     public static function checkSpecialChars( & $sValue, $aRaw = null )
00791     {
00792         return oxRegistry::getConfig()->checkParamSpecialChars( $sValue, $aRaw );
00793     }
00794 
00804     public function checkParamSpecialChars( & $sValue, $aRaw = null )
00805     {
00806         if ( is_object( $sValue ) ) {
00807             return $sValue;
00808         }
00809 
00810         if ( is_array( $sValue ) ) {
00811             $newValue = array();
00812             foreach ( $sValue as $sKey => $sVal ) {
00813                 $sValidKey = $sKey;
00814                 if ( !$aRaw || !in_array($sKey, $aRaw) ) {
00815                     $this->checkParamSpecialChars( $sValidKey );
00816                     $this->checkParamSpecialChars( $sVal );
00817                     if ($sValidKey != $sKey) {
00818                         unset ($sValue[$sKey]);
00819                     }
00820                 }
00821                 $newValue[$sValidKey] = $sVal;
00822             }
00823             $sValue = $newValue;
00824         } elseif ( is_string( $sValue ) ) {
00825             $sValue = str_replace( array( '&',     '<',    '>',    '"',      "'",      chr(0), '\\' ),
00826                                    array( '&amp;', '&lt;', '&gt;', '&quot;', '&#039;', '',     '&#092;' ),
00827                                    $sValue );
00828         }
00829         return $sValue;
00830     }
00831 
00837     public function getShopId()
00838     {
00839         if ( $this->_iShopId !== null )
00840             return $this->_iShopId;
00841 
00842             $this->_iShopId = $this->getBaseShopId();
00843 
00844 
00845         $this->getSession()->setVariable( 'actshop', $this->_iShopId );
00846         return $this->_iShopId;
00847     }
00848 
00849 
00857     public function setShopId( $sShopId )
00858     {
00859         $this->getSession()->setVariable( 'actshop', $sShopId );
00860         $this->_iShopId = $sShopId;
00861     }
00862 
00863 
00864 
00872     public function setIsSsl( $blIsSsl = false )
00873     {
00874         $this->_blIsSsl = $blIsSsl;
00875     }
00876 
00882     protected function _checkSsl()
00883     {
00884             $myUtilsServer   = oxRegistry::get("oxUtilsServer");
00885             $aServerVars     = $myUtilsServer->getServerVar();
00886             $aHttpsServerVar = $myUtilsServer->getServerVar( 'HTTPS' );
00887 
00888             $this->setIsSsl();
00889             if (isset( $aHttpsServerVar ) && ($aHttpsServerVar === 'on' || $aHttpsServerVar === 'ON' || $aHttpsServerVar == '1' )) {
00890                 // "1&1" hoster provides "1"
00891                 $this->setIsSsl($this->getConfigParam('sSSLShopURL') || $this->getConfigParam('sMallSSLShopURL')) ;
00892                 if ($this->isAdmin() && !$this->_blIsSsl) {
00893                     //#4026
00894                      $this->setIsSsl( !is_null($this->getConfigParam('sAdminSSLURL')) );
00895                 }
00896             }
00897 
00898             //additional special handling for profihost customers
00899             if ( isset( $aServerVars['HTTP_X_FORWARDED_SERVER'] ) &&
00900                  ( strpos( $aServerVars['HTTP_X_FORWARDED_SERVER'], 'ssl' ) !== false ||
00901                  strpos( $aServerVars['HTTP_X_FORWARDED_SERVER'], 'secure-online-shopping.de' ) !== false ) ) {
00902                  $this->setIsSsl( true );
00903             }
00904 
00905     }
00906 
00907 
00913     public function isSsl()
00914     {
00915         if ( is_null( $this->_blIsSsl ) ) {
00916             $this->_checkSsl();
00917         }
00918         return $this->_blIsSsl;
00919     }
00920 
00928     public function isCurrentUrl( $sURL )
00929     {
00930         // Missing protocol, cannot proceed, assuming true.
00931         if ( !$sURL || (strpos( $sURL, "http" ) !== 0)) {
00932             return true;
00933         }
00934 
00935         return oxRegistry::get("oxUtilsServer")->isCurrentUrl($sURL);
00936     }
00937 
00945     public function isCurrentProtocol( $sURL )
00946     {
00947         // Missing protocol, cannot proceed, assuming true.
00948         if ( !$sURL || (strpos( $sURL, "http" ) !== 0)) {
00949             return true;
00950         }
00951 
00952         return (strpos( $sURL, "https:" ) === 0) == $this->isSsl();
00953     }
00954 
00963     public function getShopUrl( $iLang = null, $blAdmin = null )
00964     {
00965         $blAdmin = isset( $blAdmin ) ? $blAdmin : $this->isAdmin();
00966         if ( $blAdmin ) {
00967             return $this->getConfigParam( 'sShopURL' );
00968         }
00969 
00970         // #680 per language another URL
00971         $iLang = isset( $iLang ) ? $iLang : oxRegistry::getLang()->getBaseLanguage();
00972         $aLanguageURLs = $this->getConfigParam( 'aLanguageURLs' );
00973         if ( isset( $iLang ) && isset( $aLanguageURLs[$iLang] ) && !empty( $aLanguageURLs[$iLang] ) ) {
00974             $aLanguageURLs[$iLang] = oxRegistry::getUtils()->checkUrlEndingSlash( $aLanguageURLs[$iLang] );
00975             return $aLanguageURLs[$iLang];
00976         }
00977 
00978         //normal section
00979         $sMallShopURL = $this->getConfigParam( 'sMallShopURL' );
00980         if ( $sMallShopURL ) {
00981             $sMallShopURL = oxRegistry::getUtils()->checkUrlEndingSlash( $sMallShopURL );
00982             return $sMallShopURL;
00983         }
00984 
00985         return $this->getConfigParam( 'sShopURL' );
00986     }
00987 
00995     public function getSslShopUrl( $iLang = null )
00996     {
00997         // #680 per language another URL
00998         $iLang = isset( $iLang ) ? $iLang : oxRegistry::getLang()->getBaseLanguage();
00999         $aLanguageSSLURLs = $this->getConfigParam( 'aLanguageSSLURLs' );
01000         if ( isset( $iLang ) && isset( $aLanguageSSLURLs[$iLang] ) && !empty( $aLanguageSSLURLs[$iLang] ) ) {
01001             $aLanguageSSLURLs[$iLang] = oxRegistry::getUtils()->checkUrlEndingSlash( $aLanguageSSLURLs[$iLang] );
01002             return $aLanguageSSLURLs[$iLang];
01003         }
01004 
01005         //mall mode
01006         if ( ( $sMallSSLShopURL = $this->getConfigParam( 'sMallSSLShopURL' ) ) ) {
01007             $sMallSSLShopURL = oxRegistry::getUtils()->checkUrlEndingSlash( $sMallSSLShopURL );
01008             return $sMallSSLShopURL;
01009         }
01010 
01011         if ( ( $sMallShopURL = $this->getConfigParam( 'sMallShopURL' ) ) ) {
01012             $sMallShopURL = oxRegistry::getUtils()->checkUrlEndingSlash( $sMallShopURL );
01013             return $sMallShopURL;
01014         }
01015 
01016         //normal section
01017         if ( ( $sSSLShopURL = $this->getConfigParam( 'sSSLShopURL' ) ) ) {
01018             return $sSSLShopURL;
01019         }
01020 
01021         return $this->getShopUrl( $iLang );
01022     }
01023 
01029     public function getCoreUtilsUrl()
01030     {
01031         return $this->getCurrentShopUrl().'core/utils/';
01032     }
01033 
01042     public function getCurrentShopUrl($blAdmin = null)
01043     {
01044         if ($blAdmin===null) {
01045             $blAdmin = $this->isAdmin();
01046         }
01047         if ($blAdmin) {
01048             if ($this->isSsl()) {
01049 
01050                 $sUrl = $this->getConfigParam( 'sAdminSSLURL' );
01051                 if ( !$sUrl ) {
01052                     return $this->getSslShopUrl() . $this->getConfigParam( 'sAdminDir' ) . '/';
01053                 }
01054                 return $sUrl;
01055             } else {
01056                 return $this->getShopUrl() . $this->getConfigParam( 'sAdminDir' ) . '/';
01057             }
01058         } else {
01059             return $this->isSsl() ? $this->getSslShopUrl() : $this->getShopUrl();
01060         }
01061     }
01062 
01070     public function getShopCurrentUrl( $iLang = null )
01071     {
01072         if ( $this->isSsl() ) {
01073             $sURL = $this->getSSLShopURL( $iLang );
01074         } else {
01075             $sURL = $this->getShopURL( $iLang );
01076         }
01077 
01078         return oxRegistry::get("oxUtilsUrl")->processUrl( $sURL.'index.php', false );
01079     }
01080 
01089     public function getShopHomeUrl( $iLang = null, $blAdmin = null )
01090     {
01091         return oxRegistry::get("oxUtilsUrl")->processUrl($this->getShopUrl( $iLang, $blAdmin).'index.php', false );
01092     }
01093 
01102     public function getWidgetUrl( $iLang = null, $blAdmin = null )
01103     {
01104         return oxRegistry::get("oxUtilsUrl")->processUrl($this->getShopUrl( $iLang, $blAdmin).'widget.php', false );
01105     }
01106 
01112     public function getShopSecureHomeUrl()
01113     {
01114         return  oxRegistry::get("oxUtilsUrl")->processUrl( $this->getSslShopUrl().'index.php', false );
01115     }
01116 
01122     public function getShopCurrency()
01123     {
01124         $iCurr = null;
01125         if ( ( null === ( $iCurr = $this->getRequestParameter( 'cur' ) ) ) ) {
01126             if ( null === ( $iCurr = $this->getRequestParameter( 'currency' ) ) ) {
01127                 $iCurr = $this->getSession()->getVariable( 'currency' );
01128             }
01129         }
01130         return (int) $iCurr;
01131     }
01132 
01138     public function getActShopCurrencyObject()
01139     {
01140         //caching currency as it does not change through the script
01141         //but not for unit tests as ther it changes always
01142         if ( !defined( 'OXID_PHP_UNIT' ) ) {
01143             if (!is_null($this->_oActCurrencyObject)) {
01144                 return $this->_oActCurrencyObject;
01145             }
01146         }
01147 
01148         $iCur = $this->getShopCurrency();
01149         $aCurrencies = $this->getCurrencyArray();
01150         if ( !isset( $aCurrencies[$iCur] ) ) {
01151             return $this->_oActCurrencyObject = reset( $aCurrencies ); // reset() returns the first element
01152         }
01153 
01154         return $this->_oActCurrencyObject = $aCurrencies[$iCur];
01155     }
01156 
01164     public function setActShopCurrency( $iCur )
01165     {
01166         $aCurrencies = $this->getCurrencyArray();
01167         if ( isset( $aCurrencies[$iCur] ) ) {
01168             $this->getSession()->setVariable( 'currency', $iCur );
01169             $this->_oActCurrencyObject = null;
01170         }
01171     }
01172 
01180     public function getOutDir( $blAbsolute = true)
01181     {
01182         if ($blAbsolute) {
01183             return $this->getConfigParam('sShopDir').$this->_sOutDir.'/';
01184         } else {
01185             return $this->_sOutDir.'/';
01186         }
01187     }
01188 
01196     public function getViewsDir( $blAbsolute = true )
01197     {
01198         if ($blAbsolute) {
01199             return $this->getConfigParam('sShopDir'). 'application/views/';
01200         } else {
01201             return 'application/views/';
01202         }
01203     }
01204 
01214     public function getTranslationsDir( $sFile, $sDir, $blAbsolute = true )
01215     {
01216         $sPath = $blAbsolute ? $this->getConfigParam( 'sShopDir' ) : '';
01217         $sPath .= 'application/translations/';
01218         if ( is_readable( $sPath. $sDir. '/'. $sFile ) ) {
01219             return $sPath. $sDir. '/'. $sFile;
01220         }
01221         return false;
01222     }
01223 
01231     public function getAppDir( $blAbsolute = true )
01232     {
01233         if ($blAbsolute) {
01234             return $this->getConfigParam('sShopDir'). 'application/';
01235         } else {
01236             return 'application/';
01237         }
01238     }
01239 
01249     public function getOutUrl( $blSSL = null , $blAdmin = null, $blNativeImg = false )
01250     {
01251         $blSSL    = is_null($blSSL)?$this->isSsl():$blSSL;
01252         $blAdmin  = is_null($blAdmin)?$this->isAdmin():$blAdmin;
01253 
01254         if ( $blSSL ) {
01255             if ($blNativeImg && !$blAdmin) {
01256                 $sUrl = $this->getSslShopUrl();
01257             } else {
01258                 $sUrl = $this->getConfigParam('sSSLShopURL');
01259                 if (!$sUrl && $blAdmin) {
01260                     $sUrl = $this->getConfigParam('sAdminSSLURL').'../';
01261                 }
01262             }
01263         } else {
01264             $sUrl = ($blNativeImg && !$blAdmin )?$this->getShopUrl():$this->getConfigParam( 'sShopURL' );
01265         }
01266 
01267         return $sUrl.$this->_sOutDir.'/';
01268     }
01269 
01284     public function getDir($sFile, $sDir, $blAdmin, $iLang = null, $iShop = null, $sTheme = null, $blAbsolute = true, $blIgnoreCust = false  )
01285     {
01286         if ( is_null($sTheme) ) {
01287             $sTheme = $this->getConfigParam( 'sTheme' );
01288         }
01289 
01290         if ( $blAdmin ) {
01291             $sTheme = 'admin';
01292         }
01293 
01294         if ( $sDir != $this->_sTemplateDir ) {
01295             $sBase    = $this->getOutDir( $blAbsolute );
01296             $sAbsBase = $this->getOutDir();
01297         } else {
01298             $sBase    = $this->getViewsDir( $blAbsolute );
01299             $sAbsBase = $this->getViewsDir();
01300         }
01301 
01302         $sLang = '-';
01303         // FALSE means skip language folder check
01304         if ( $iLang !== false ) {
01305             $oLang = oxRegistry::getLang();
01306 
01307             if ( is_null( $iLang ) ) {
01308                 $iLang = $oLang->getEditLanguage();
01309             }
01310 
01311             $sLang = $oLang->getLanguageAbbr( $iLang );
01312         }
01313 
01314         if ( is_null($iShop) ) {
01315             $iShop = $this->getShopId();
01316         }
01317 
01318         //Load from
01319         $sPath = "{$sTheme}/{$iShop}/{$sLang}/{$sDir}/{$sFile}";
01320         $sCacheKey = $sPath . "_{$blIgnoreCust}{$blAbsolute}";
01321 
01322         if ( ( $sReturn = oxRegistry::getUtils()->fromStaticCache( $sCacheKey ) ) !== null ) {
01323             return $sReturn;
01324         }
01325 
01326         $sReturn = false;
01327 
01328         // Check for custom template
01329         $sCustomTheme = $this->getConfigParam( 'sCustomTheme' );
01330         if ( !$blAdmin && !$blIgnoreCust && $sCustomTheme && $sCustomTheme != $sTheme) {
01331             $sReturn = $this->getDir( $sFile, $sDir, $blAdmin, $iLang, $iShop, $sCustomTheme, $blAbsolute );
01332         }
01333 
01334         //test lang level ..
01335         if ( !$sReturn && !$blAdmin && is_readable( $sAbsBase.$sPath ) ) {
01336             $sReturn = $sBase . $sPath;
01337         }
01338 
01339         //test shop level ..
01340         $sPath = "$sTheme/$iShop/$sDir/$sFile";
01341         if ( !$sReturn && !$blAdmin && is_readable( $sAbsBase.$sPath ) ) {
01342             $sReturn = $sBase . $sPath;
01343         }
01344 
01345 
01346         //test theme language level ..
01347         $sPath = "$sTheme/$sLang/$sDir/$sFile";
01348         if ( !$sReturn && $iLang !== false && is_readable( $sAbsBase.$sPath ) ) {
01349             $sReturn = $sBase . $sPath;
01350         }
01351 
01352         //test theme level ..
01353         $sPath = "$sTheme/$sDir/$sFile";
01354         if ( !$sReturn && is_readable( $sAbsBase.$sPath ) ) {
01355             $sReturn = $sBase . $sPath;
01356         }
01357 
01358         //test out language level ..
01359         $sPath = "$sLang/$sDir/$sFile";
01360         if ( !$sReturn &&  $iLang !== false && is_readable( $sAbsBase.$sPath ) ) {
01361             $sReturn = $sBase . $sPath;
01362         }
01363 
01364         //test out level ..
01365         $sPath = "$sDir/$sFile";
01366         if ( !$sReturn && is_readable( $sAbsBase.$sPath ) ) {
01367             $sReturn = $sBase . $sPath;
01368         }
01369 
01370         if ( !$sReturn ) {
01371             // TODO: implement logic to log missing paths
01372         }
01373 
01374         // to cache
01375         oxRegistry::getUtils()->toStaticCache( $sCacheKey, $sReturn );
01376 
01377         return $sReturn;
01378     }
01379 
01394     public function getUrl($sFile, $sDir , $blAdmin = null, $blSSL = null, $blNativeImg = false, $iLang = null , $iShop = null , $sTheme = null )
01395     {
01396         $sUrl = str_replace(
01397                                 $this->getOutDir(),
01398                                 $this->getOutUrl($blSSL, $blAdmin, $blNativeImg),
01399                                 $this->getDir( $sFile, $sDir, $blAdmin, $iLang, $iShop, $sTheme )
01400                             );
01401 
01402         return $sUrl;
01403     }
01404 
01413     public function getImagePath( $sFile, $blAdmin = false )
01414     {
01415         return $this->getDir( $sFile, $this->_sImageDir, $blAdmin );
01416     }
01417 
01428     public function getImageUrl( $blAdmin = false, $blSSL = null, $blNativeImg = null, $sFile = null )
01429     {
01430         $blNativeImg = is_null($blNativeImg)?$this->getConfigParam( 'blNativeImages' ):$blNativeImg;
01431         return $this->getUrl( $sFile, $this->_sImageDir, $blAdmin, $blSSL, $blNativeImg );
01432     }
01433 
01441     public function getImageDir( $blAdmin = false )
01442     {
01443         return $this->getDir( null, $this->_sImageDir, $blAdmin );
01444     }
01445 
01457     public function getPicturePath($sFile, $blAdmin = false, $iLang = null , $iShop = null , $sTheme = null)
01458     {
01459         return $this->getDir( $sFile, $this->_sPictureDir, $blAdmin, $iLang, $iShop, $sTheme );
01460     }
01461 
01469     public function getMasterPictureDir( $blAdmin = false )
01470     {
01471         return $this->getDir( null, $this->_sPictureDir . "/" . $this->_sMasterPictureDir, $blAdmin );
01472     }
01473 
01482     public function getMasterPicturePath( $sFile, $blAdmin = false )
01483     {
01484         return $this->getDir( $sFile, $this->_sPictureDir . "/" . $this->_sMasterPictureDir, $blAdmin );
01485     }
01486 
01499     public function getPictureUrl( $sFile, $blAdmin = false, $blSSL = null, $iLang = null, $iShopId = null, $sDefPic = "master/nopic.jpg" )
01500     {
01501         if ( $sAltUrl = oxRegistry::get("oxPictureHandler")->getAltImageUrl('/', $sFile, $blSSL) ) {
01502             return $sAltUrl;
01503         }
01504 
01505         $blNativeImg = $this->getConfigParam( 'blNativeImages' );
01506         $sUrl = $this->getUrl( $sFile, $this->_sPictureDir, $blAdmin, $blSSL, $blNativeImg, $iLang, $iShopId );
01507 
01508         //anything is better than empty name, because <img src=""> calls shop once more = x2 SLOW.
01509         if ( !$sUrl && $sDefPic ) {
01510             $sUrl = $this->getUrl( $sDefPic, $this->_sPictureDir, $blAdmin, $blSSL, $blNativeImg, $iLang, $iShopId );
01511         }
01512         return $sUrl;
01513     }
01514 
01522     public function getPictureDir( $blAdmin )
01523     {
01524         return $this->getDir( null, $this->_sPictureDir, $blAdmin );
01525     }
01526 
01535     public function getTemplatePath( $sFile, $blAdmin )
01536     {
01537         $sTemplatePath = $this->getDir( $sFile, $this->_sTemplateDir, $blAdmin );
01538 
01539         if (!$sTemplatePath) {
01540             $sBasePath        = getShopBasePath();
01541             $aModuleTemplates = $this->getConfigParam('aModuleTemplates');
01542 
01543             $oModulelist = oxNew('oxmodulelist');
01544             $aActiveModuleInfo = $oModulelist->getActiveModuleInfo();
01545             if (is_array($aModuleTemplates) && is_array($aActiveModuleInfo)) {
01546                 foreach ($aModuleTemplates as $sModuleId => $aTemplates) {
01547                     if (isset($aTemplates[$sFile]) && isset($aActiveModuleInfo[$sModuleId])) {
01548                         $sPath = $aTemplates[$sFile];
01549                         $sPath = $sBasePath. 'modules/'.  $sPath;
01550                         if (is_file($sPath) && is_readable($sPath)) {
01551                             $sTemplatePath =  $sPath;
01552                         }
01553                     }
01554                 }
01555             }
01556         }
01557 
01558         return $sTemplatePath;
01559     }
01560 
01568     public function getTemplateDir( $blAdmin = false )
01569     {
01570         return $this->getDir( null, $this->_sTemplateDir, $blAdmin );
01571     }
01572 
01583     public function getTemplateUrl( $sFile = null, $blAdmin = false, $blSSL = null , $iLang = null )
01584     {
01585         return $this->getShopMainUrl() . $this->getDir( $sFile, $this->_sTemplateDir, $blAdmin, $iLang, null, null, false );
01586     }
01587 
01595     public function getTemplateBase( $blAdmin = false )
01596     {
01597         // Base template dir is the parent dir of template dir
01598         return str_replace( $this->_sTemplateDir.'/', '', $this->getDir( null, $this->_sTemplateDir, $blAdmin, null, null, null, false ));
01599     }
01600 
01609     public function getResourcePath($sFile = '', $blAdmin = false )
01610     {
01611         return $this->getDir( $sFile, $this->_sResourceDir, $blAdmin );
01612     }
01613 
01621     public function getModulesDir( $blAbsolute = true )
01622     {
01623         if ($blAbsolute) {
01624             return $this->getConfigParam('sShopDir') . $this->_sModulesDir . '/';
01625         } else {
01626             return $this->_sModulesDir . '/';
01627         }
01628     }
01629 
01640     public function getResourceUrl( $sFile = '', $blAdmin = false , $blSSL = null , $iLang = null )
01641     {
01642         $blNativeImg = $this->getConfigParam( 'blNativeImages' );
01643         return $this->getUrl( $sFile, $this->_sResourceDir, $blAdmin, $blSSL, $blNativeImg, $iLang );
01644     }
01645 
01653     public function getResourceDir( $blAdmin )
01654     {
01655         return $this->getDir( null, $this->_sResourceDir, $blAdmin );
01656     }
01657 
01665     public function getCurrencyArray( $iCurrency = null )
01666     {
01667         $aConfCurrencies = $this->getConfigParam( 'aCurrencies' );
01668         if ( !is_array( $aConfCurrencies ) ) {
01669             return array();
01670         }
01671 
01672         if ( defined( 'OXID_PHP_UNIT' ) ) {
01673             if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
01674                 try{
01675                     $aAltCurrencies = modConfig::getInstance()->getConfigParam( 'modaCurrencies' );
01676                     if ( isset( $aAltCurrencies ) ) {
01677                         $aConfCurrencies = $aAltCurrencies;
01678                     }
01679                 } catch( Exception $e ) {
01680                     // if exception is thrown, use default
01681                 }
01682             }
01683         }
01684 
01685         // processing currency configuration data
01686         $aCurrencies = array();
01687         reset( $aConfCurrencies );
01688         while ( list( $key, $val ) = each( $aConfCurrencies ) ) {
01689             if ( $val ) {
01690                 $oCur = new stdClass();
01691                 $oCur->id      = $key;
01692                 $sCur = explode( '@', $val);
01693                 $oCur->name     = trim( $sCur[0] );
01694                 $oCur->rate     = trim( $sCur[1] );
01695                 $oCur->dec      = trim( $sCur[2] );
01696                 $oCur->thousand = trim( $sCur[3] );
01697                 $oCur->sign     = trim( $sCur[4] );
01698                 $oCur->decimal  = trim( $sCur[5] );
01699 
01700                 // change for US version
01701                 if ( isset( $sCur[6] ) ) {
01702                     $oCur->side = trim($sCur[6]);
01703                 }
01704 
01705                 if ( isset( $iCurrency) && $key == $iCurrency ) {
01706                     $oCur->selected = 1;
01707                 } else {
01708                     $oCur->selected = 0;
01709                 }
01710                 $aCurrencies[$key]= $oCur;
01711             }
01712 
01713             // #861C -  performance, do not load other currencies
01714             if ( !$this->getConfigParam( 'bl_perfLoadCurrency' ) ) {
01715                 break;
01716             }
01717         }
01718         return $aCurrencies;
01719     }
01720 
01728     public function getCurrencyObject( $sName )
01729     {
01730         $aSearch = $this->getCurrencyArray();
01731         foreach ( $aSearch as $oCur ) {
01732             if ( $oCur->name == $sName ) {
01733                 return $oCur;
01734             }
01735         }
01736     }
01737 
01743     public function isDemoShop()
01744     {
01745         return $this->getConfigParam('blDemoShop');
01746     }
01747 
01748 
01749 
01755     public function getEdition()
01756     {
01757             return "CE";
01758 
01759 
01760     }
01761 
01767     public function getFullEdition()
01768     {
01769         $sEdition = $this->getEdition();
01770 
01771             if ($sEdition == "CE") {
01772                 return "Community Edition";
01773             }
01774 
01775 
01776 
01777         return $sEdition;
01778     }
01779 
01785     public function getVersion()
01786     {
01787         $sVersion = $this->getActiveShop()->oxshops__oxversion->value;
01788         return $sVersion;
01789     }
01790 
01796     public function getRevision()
01797     {
01798         try {
01799             $sFileName = getShopBasePath() . "/pkg.rev";
01800             $iRev = (int) trim(@file_get_contents($sFileName));
01801         } catch (Exception $e) {
01802             return false;
01803         }
01804 
01805         if (!$iRev) {
01806             return false;
01807         }
01808 
01809         return $iRev;
01810     }
01811 
01812 
01818     public function isMall()
01819     {
01820 
01821             return false;
01822     }
01823 
01833     public function detectVersion()
01834     {
01835     }
01836 
01837 
01838 
01851     public function saveShopConfVar( $sVarType, $sVarName, $sVarVal, $sShopId = null, $sModule = '' )
01852     {
01853         switch ( $sVarType ) {
01854             case 'arr':
01855             case 'aarr':
01856                 $sValue = serialize( $sVarVal );
01857                 break;
01858             case 'bool':
01859                 //config param
01860                 $sVarVal = (( $sVarVal == 'true' || $sVarVal) && $sVarVal && strcasecmp($sVarVal, "false"));
01861                 //db value
01862                 $sValue  = $sVarVal?"1":"";
01863                 break;
01864             case 'num':
01865                 //config param
01866                 $sVarVal = $sVarVal != ''? oxRegistry::getUtils()->string2Float( $sVarVal ) : '';
01867                 $sValue = $sVarVal;
01868                 break;
01869             default:
01870                 $sValue  = $sVarVal;
01871                 break;
01872         }
01873 
01874         if ( !$sShopId ) {
01875             $sShopId = $this->getShopId();
01876         }
01877 
01878         // Update value only for current shop
01879         if ($sShopId == $this->getShopId()) {
01880             $this->setConfigParam( $sVarName, $sVarVal );
01881         }
01882 
01883         $oDb = oxDb::getDb();
01884 
01885         $sShopIdQuoted     = $oDb->quote($sShopId);
01886         $sModuleQuoted     = $oDb->quote($sModule);
01887         $sVarNameQuoted    = $oDb->quote($sVarName);
01888         $sVarTypeQuoted    = $oDb->quote($sVarType);
01889         $sVarValueQuoted   = $oDb->quote($sValue);
01890         $sConfigKeyQuoted  = $oDb->quote($this->getConfigParam('sConfigKey'));
01891         $sNewOXIDdQuoted   = $oDb->quote(oxUtilsObject::getInstance()->generateUID());
01892 
01893         $sQ = "delete from oxconfig where oxshopid = $sShopIdQuoted and oxvarname = $sVarNameQuoted and oxmodule = $sModuleQuoted";
01894         $oDb->execute( $sQ );
01895 
01896         $sQ = "insert into oxconfig (oxid, oxshopid, oxmodule, oxvarname, oxvartype, oxvarvalue)
01897                values($sNewOXIDdQuoted, $sShopIdQuoted, $sModuleQuoted, $sVarNameQuoted, $sVarTypeQuoted, ENCODE( $sVarValueQuoted, $sConfigKeyQuoted) )";
01898 
01899         $oDb->execute( $sQ );
01900 
01901 
01902 
01903     }
01904 
01905 
01915     public function getShopConfVar( $sVarName, $sShopId = null, $sModule = '' )
01916     {
01917         if ( !$sShopId ) {
01918             $sShopId = $this->getShopId();
01919         }
01920 
01921         if ( $sShopId === $this->getShopId() && ( !$sModule || $sModule == oxConfig::OXMODULE_THEME_PREFIX . $this->getConfigParam('sTheme') ) ) {
01922             $sVarValue = $this->getConfigParam( $sVarName );
01923             if ( $sVarValue !== null ) {
01924                 return $sVarValue;
01925             }
01926         }
01927 
01928         $oDb = oxDb::getDb( oxDb::FETCH_MODE_ASSOC );
01929 
01930         $sQ  = "select oxvartype, ".$this->getDecodeValueQuery()." as oxvarvalue from oxconfig where oxshopid = '{$sShopId}' and oxmodule = '{$sModule}' and oxvarname = ".$oDb->quote($sVarName);
01931         $oRs = $oDb->select( $sQ );
01932 
01933         $sValue = null;
01934         if ( $oRs != false && $oRs->recordCount() > 0 ) {
01935             $sValue = $this->decodeValue( $oRs->fields['oxvartype'], $oRs->fields['oxvarvalue'] );
01936         }
01937         return $sValue;
01938     }
01939 
01948     public function decodeValue( $sType, $mOrigValue )
01949     {
01950         $sValue = $mOrigValue;
01951         switch ( $sType ) {
01952             case 'arr':
01953             case 'aarr':
01954                 $sValue = unserialize( $mOrigValue );
01955                 break;
01956             case 'bool':
01957                 $sValue = ( $mOrigValue == 'true' || $mOrigValue == '1' );
01958                 break;
01959         }
01960 
01961         return $sValue;
01962     }
01963 
01971     public function getDecodeValueQuery( $sFieldName = "oxvarvalue" )
01972     {
01973         return " DECODE( {$sFieldName}, '".$this->getConfigParam( 'sConfigKey' )."') ";
01974     }
01975 
01981     public function isProductiveMode()
01982     {
01983         $blProductive = false;
01984 
01985         $blProductive = $this->getConfigParam( 'blProductive' );
01986         if ( !isset( $blProductive ) ) {
01987             $sQ = 'select oxproductive from oxshops where oxid = "'.$this->getShopId().'"';
01988             $blProductive = ( bool ) oxDb::getDb()->getOne( $sQ );
01989             $this->setConfigParam( 'blProductive', $blProductive );
01990         }
01991 
01992         return $blProductive;
01993     }
01994 
01995 
01996 
02002     public function getBaseShopId()
02003     {
02004 
02005             return 'oxbaseshop';
02006     }
02007 
02013     public function getActiveShop()
02014     {
02015         if ( $this->_oActShop && $this->_iShopId == $this->_oActShop->getId() &&
02016              $this->_oActShop->getLanguage() == oxRegistry::getLang()->getBaseLanguage() ) {
02017             return $this->_oActShop;
02018         }
02019 
02020         $this->_oActShop = oxNew( 'oxshop' );
02021         $this->_oActShop->load( $this->getShopId() );
02022         return $this->_oActShop;
02023     }
02024 
02030     public function getActiveView()
02031     {
02032         if ( count( $this->_aActiveViews ) ) {
02033             $oActView = end( $this->_aActiveViews );
02034         }
02035         if ( $oActView == null ) {
02036             $oActView = oxNew( 'oxubase' );
02037             $this->_aActiveViews[] = $oActView;
02038         }
02039 
02040         return $oActView;
02041     }
02042 
02048     public function getTopActiveView()
02049     {
02050         if ( count( $this->_aActiveViews ) ) {
02051             return reset( $this->_aActiveViews );
02052         } else {
02053             return $this->getActiveView();
02054         }
02055     }
02056 
02062     public function getActiveViewsList()
02063     {
02064         return $this->_aActiveViews;
02065     }
02066 
02074     public function setActiveView( $oView )
02075     {
02076         $this->_aActiveViews[] = $oView;
02077     }
02078 
02084     public function dropLastActiveView()
02085     {
02086         array_pop( $this->_aActiveViews );
02087     }
02088 
02094     public function hasActiveViewsChain()
02095     {
02096         return ( count( $this->_aActiveViews ) > 1 );
02097     }
02098 
02104     public function getActiveViewsNames()
02105     {
02106         $aNames = array();
02107 
02108         if ( is_array( $this->getActiveViewsList() ) ) {
02109             foreach ($this->getActiveViewsList() as $oView ) {
02110                 $aNames[] = $oView->getClassName();
02111             }
02112         }
02113 
02114         return $aNames;
02115     }
02116 
02122     public function isUtf()
02123     {
02124         return ( bool ) $this->getConfigParam( 'iUtfMode' );
02125     }
02126 
02132     public function getLogsDir()
02133     {
02134         return $this->getConfigParam( 'sShopDir' ).'log/';
02135     }
02136 
02144     public function isThemeOption( $sName )
02145     {
02146         return (bool) isset( $this->_aThemeConfigParams[$sName] );
02147     }
02148 
02154     public function getShopMainUrl()
02155     {
02156         return $this->_blIsSsl ? $this->getConfigParam( 'sSSLShopURL' ) : $this->getConfigParam( 'sShopURL' );
02157     }
02158 
02164     public function getAllModules()
02165     {
02166         return $this->parseModuleChains($this->getConfigParam('aModules'));
02167     }
02168 
02176     public function parseModuleChains($aModules)
02177     {
02178         $aModuleArray = array();
02179 
02180         if (is_array($aModules)) {
02181             foreach ($aModules as $sClass => $sModuleChain) {
02182                 if (strstr($sModuleChain, '&')) {
02183                     $aModuleChain = explode('&', $sModuleChain);
02184                 } else {
02185                     $aModuleChain = array($sModuleChain);
02186                 }
02187                 $aModuleArray[$sClass] = $aModuleChain;
02188             }
02189         }
02190 
02191         return $aModuleArray;
02192     }
02193 
02199     public function getShopIds()
02200     {
02201         return oxDb::getDb()->getCol( "SELECT `oxid` FROM `oxshops`" );
02202     }
02203 
02204 }