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         $sUrl = null;
00925         $blAdmin = isset($blAdmin) ? $blAdmin : $this->isAdmin();
00926 
00927         if (!$blAdmin) {
00928             $sUrl = $this->getShopUrlByLanguage($iLang);
00929             if (!$sUrl) {
00930                 $sUrl = $this->getMallShopUrl();
00931             }
00932         }
00933 
00934         if (!$sUrl) {
00935             $sUrl = $this->getConfigParam('sShopURL');
00936         }
00937 
00938         return $sUrl;
00939     }
00940 
00948     public function getSslShopUrl($iLang = null)
00949     {
00950         $sUrl = null;
00951 
00952         if(!$sUrl) {
00953             $sUrl = $this->getShopUrlByLanguage($iLang, true);
00954         }
00955 
00956         if(!$sUrl) {
00957             $sUrl = $this->getMallShopUrl(true);
00958         }
00959 
00960         if(!$sUrl) {
00961             $sUrl = $this->getMallShopUrl();
00962         }
00963 
00964         //normal section
00965         if (!$sUrl) {
00966             $sUrl = $this->getConfigParam('sSSLShopURL');
00967         }
00968 
00969         if (!$sUrl) {
00970             $sUrl = $this->getShopUrl($iLang);
00971         }
00972 
00973         return $sUrl;
00974     }
00975 
00981     public function getCoreUtilsUrl()
00982     {
00983         return $this->getCurrentShopUrl().'core/utils/';
00984     }
00985 
00994     public function getCurrentShopUrl($blAdmin = null)
00995     {
00996         if ($blAdmin===null) {
00997             $blAdmin = $this->isAdmin();
00998         }
00999         if ($blAdmin) {
01000             if ($this->isSsl()) {
01001 
01002                 $sUrl = $this->getConfigParam( 'sAdminSSLURL' );
01003                 if ( !$sUrl ) {
01004                     return $this->getSslShopUrl() . $this->getConfigParam( 'sAdminDir' ) . '/';
01005                 }
01006                 return $sUrl;
01007             } else {
01008                 return $this->getShopUrl() . $this->getConfigParam( 'sAdminDir' ) . '/';
01009             }
01010         } else {
01011             return $this->isSsl() ? $this->getSslShopUrl() : $this->getShopUrl();
01012         }
01013     }
01014 
01022     public function getShopCurrentUrl( $iLang = null )
01023     {
01024         if ( $this->isSsl() ) {
01025             $sURL = $this->getSSLShopURL( $iLang );
01026         } else {
01027             $sURL = $this->getShopURL( $iLang );
01028         }
01029 
01030         return oxRegistry::get("oxUtilsUrl")->processUrl( $sURL.'index.php', false );
01031     }
01032 
01041     public function getShopHomeUrl( $iLang = null, $blAdmin = null )
01042     {
01043         return oxRegistry::get("oxUtilsUrl")->processUrl($this->getShopUrl( $iLang, $blAdmin).'index.php', false );
01044     }
01045 
01054     public function getWidgetUrl( $iLang = null, $blAdmin = null )
01055     {
01056         $sUrl = $this->isSsl() ? $this->getSslShopUrl($iLang) : $this->getShopUrl($iLang, $blAdmin);
01057 
01058         return oxRegistry::get('oxUtilsUrl')->processUrl($sUrl.'widget.php', false);
01059     }
01060 
01066     public function getShopSecureHomeUrl()
01067     {
01068         return  oxRegistry::get("oxUtilsUrl")->processUrl( $this->getSslShopUrl().'index.php', false );
01069     }
01070 
01076     public function getShopCurrency()
01077     {
01078         $iCurr = null;
01079         if ( ( null === ( $iCurr = $this->getRequestParameter( 'cur' ) ) ) ) {
01080             if ( null === ( $iCurr = $this->getRequestParameter( 'currency' ) ) ) {
01081                 $iCurr = $this->getSession()->getVariable( 'currency' );
01082             }
01083         }
01084         return (int) $iCurr;
01085     }
01086 
01092     public function getActShopCurrencyObject()
01093     {
01094         //caching currency as it does not change through the script
01095         //but not for unit tests as ther it changes always
01096         if ( !defined( 'OXID_PHP_UNIT' ) ) {
01097             if (!is_null($this->_oActCurrencyObject)) {
01098                 return $this->_oActCurrencyObject;
01099             }
01100         }
01101 
01102         $iCur = $this->getShopCurrency();
01103         $aCurrencies = $this->getCurrencyArray();
01104         if ( !isset( $aCurrencies[$iCur] ) ) {
01105             return $this->_oActCurrencyObject = reset( $aCurrencies ); // reset() returns the first element
01106         }
01107 
01108         return $this->_oActCurrencyObject = $aCurrencies[$iCur];
01109     }
01110 
01118     public function setActShopCurrency( $iCur )
01119     {
01120         $aCurrencies = $this->getCurrencyArray();
01121         if ( isset( $aCurrencies[$iCur] ) ) {
01122             $this->getSession()->setVariable( 'currency', $iCur );
01123             $this->_oActCurrencyObject = null;
01124         }
01125     }
01126 
01134     public function getOutDir( $blAbsolute = true)
01135     {
01136         if ($blAbsolute) {
01137             return $this->getConfigParam('sShopDir').$this->_sOutDir.'/';
01138         } else {
01139             return $this->_sOutDir.'/';
01140         }
01141     }
01142 
01150     public function getViewsDir( $blAbsolute = true )
01151     {
01152         if ($blAbsolute) {
01153             return $this->getConfigParam('sShopDir'). 'application/views/';
01154         } else {
01155             return 'application/views/';
01156         }
01157     }
01158 
01168     public function getTranslationsDir( $sFile, $sDir, $blAbsolute = true )
01169     {
01170         $sPath = $blAbsolute ? $this->getConfigParam( 'sShopDir' ) : '';
01171         $sPath .= 'application/translations/';
01172         if ( is_readable( $sPath. $sDir. '/'. $sFile ) ) {
01173             return $sPath. $sDir. '/'. $sFile;
01174         }
01175         return false;
01176     }
01177 
01185     public function getAppDir( $blAbsolute = true )
01186     {
01187         if ($blAbsolute) {
01188             return $this->getConfigParam('sShopDir'). 'application/';
01189         } else {
01190             return 'application/';
01191         }
01192     }
01193 
01203     public function getOutUrl( $blSSL = null , $blAdmin = null, $blNativeImg = false )
01204     {
01205         $blSSL    = is_null($blSSL)?$this->isSsl():$blSSL;
01206         $blAdmin  = is_null($blAdmin)?$this->isAdmin():$blAdmin;
01207 
01208         if ( $blSSL ) {
01209             if ($blNativeImg && !$blAdmin) {
01210                 $sUrl = $this->getSslShopUrl();
01211             } else {
01212                 $sUrl = $this->getConfigParam('sSSLShopURL');
01213                 if (!$sUrl && $blAdmin) {
01214                     $sUrl = $this->getConfigParam('sAdminSSLURL').'../';
01215                 }
01216             }
01217         } else {
01218             $sUrl = ($blNativeImg && !$blAdmin )?$this->getShopUrl():$this->getConfigParam( 'sShopURL' );
01219         }
01220 
01221         return $sUrl.$this->_sOutDir.'/';
01222     }
01223 
01238     public function getDir($sFile, $sDir, $blAdmin, $iLang = null, $iShop = null, $sTheme = null, $blAbsolute = true, $blIgnoreCust = false  )
01239     {
01240         if ( is_null($sTheme) ) {
01241             $sTheme = $this->getConfigParam( 'sTheme' );
01242         }
01243 
01244         if ( $blAdmin ) {
01245             $sTheme = 'admin';
01246         }
01247 
01248         if ( $sDir != $this->_sTemplateDir ) {
01249             $sBase    = $this->getOutDir( $blAbsolute );
01250             $sAbsBase = $this->getOutDir();
01251         } else {
01252             $sBase    = $this->getViewsDir( $blAbsolute );
01253             $sAbsBase = $this->getViewsDir();
01254         }
01255 
01256         $sLang = '-';
01257         // FALSE means skip language folder check
01258         if ( $iLang !== false ) {
01259             $oLang = oxRegistry::getLang();
01260 
01261             if ( is_null( $iLang ) ) {
01262                 $iLang = $oLang->getEditLanguage();
01263             }
01264 
01265             $sLang = $oLang->getLanguageAbbr( $iLang );
01266         }
01267 
01268         if ( is_null($iShop) ) {
01269             $iShop = $this->getShopId();
01270         }
01271 
01272         //Load from
01273         $sPath = "{$sTheme}/{$iShop}/{$sLang}/{$sDir}/{$sFile}";
01274         $sCacheKey = $sPath . "_{$blIgnoreCust}{$blAbsolute}";
01275 
01276         if ( ( $sReturn = oxRegistry::getUtils()->fromStaticCache( $sCacheKey ) ) !== null ) {
01277             return $sReturn;
01278         }
01279 
01280         $sReturn = false;
01281 
01282         // Check for custom template
01283         $sCustomTheme = $this->getConfigParam( 'sCustomTheme' );
01284         if ( !$blAdmin && !$blIgnoreCust && $sCustomTheme && $sCustomTheme != $sTheme) {
01285             $sReturn = $this->getDir( $sFile, $sDir, $blAdmin, $iLang, $iShop, $sCustomTheme, $blAbsolute );
01286         }
01287 
01288         //test lang level ..
01289         if ( !$sReturn && !$blAdmin && is_readable( $sAbsBase.$sPath ) ) {
01290             $sReturn = $sBase . $sPath;
01291         }
01292 
01293         //test shop level ..
01294         $sPath = "$sTheme/$iShop/$sDir/$sFile";
01295         if ( !$sReturn && !$blAdmin && is_readable( $sAbsBase.$sPath ) ) {
01296             $sReturn = $sBase . $sPath;
01297         }
01298 
01299 
01300         //test theme language level ..
01301         $sPath = "$sTheme/$sLang/$sDir/$sFile";
01302         if ( !$sReturn && $iLang !== false && is_readable( $sAbsBase.$sPath ) ) {
01303             $sReturn = $sBase . $sPath;
01304         }
01305 
01306         //test theme level ..
01307         $sPath = "$sTheme/$sDir/$sFile";
01308         if ( !$sReturn && is_readable( $sAbsBase.$sPath ) ) {
01309             $sReturn = $sBase . $sPath;
01310         }
01311 
01312         //test out language level ..
01313         $sPath = "$sLang/$sDir/$sFile";
01314         if ( !$sReturn &&  $iLang !== false && is_readable( $sAbsBase.$sPath ) ) {
01315             $sReturn = $sBase . $sPath;
01316         }
01317 
01318         //test out level ..
01319         $sPath = "$sDir/$sFile";
01320         if ( !$sReturn && is_readable( $sAbsBase.$sPath ) ) {
01321             $sReturn = $sBase . $sPath;
01322         }
01323 
01324         if ( !$sReturn ) {
01325             // TODO: implement logic to log missing paths
01326         }
01327 
01328         // to cache
01329         oxRegistry::getUtils()->toStaticCache( $sCacheKey, $sReturn );
01330 
01331         return $sReturn;
01332     }
01333 
01348     public function getUrl($sFile, $sDir , $blAdmin = null, $blSSL = null, $blNativeImg = false, $iLang = null , $iShop = null , $sTheme = null )
01349     {
01350         $sUrl = str_replace(
01351                                 $this->getOutDir(),
01352                                 $this->getOutUrl($blSSL, $blAdmin, $blNativeImg),
01353                                 $this->getDir( $sFile, $sDir, $blAdmin, $iLang, $iShop, $sTheme )
01354                             );
01355 
01356         return $sUrl;
01357     }
01358 
01367     public function getImagePath( $sFile, $blAdmin = false )
01368     {
01369         return $this->getDir( $sFile, $this->_sImageDir, $blAdmin );
01370     }
01371 
01382     public function getImageUrl( $blAdmin = false, $blSSL = null, $blNativeImg = null, $sFile = null )
01383     {
01384         $blNativeImg = is_null($blNativeImg)?$this->getConfigParam( 'blNativeImages' ):$blNativeImg;
01385         return $this->getUrl( $sFile, $this->_sImageDir, $blAdmin, $blSSL, $blNativeImg );
01386     }
01387 
01395     public function getImageDir( $blAdmin = false )
01396     {
01397         return $this->getDir( null, $this->_sImageDir, $blAdmin );
01398     }
01399 
01411     public function getPicturePath($sFile, $blAdmin = false, $iLang = null , $iShop = null , $sTheme = null)
01412     {
01413         return $this->getDir( $sFile, $this->_sPictureDir, $blAdmin, $iLang, $iShop, $sTheme );
01414     }
01415 
01423     public function getMasterPictureDir( $blAdmin = false )
01424     {
01425         return $this->getDir( null, $this->_sPictureDir . "/" . $this->_sMasterPictureDir, $blAdmin );
01426     }
01427 
01436     public function getMasterPicturePath( $sFile, $blAdmin = false )
01437     {
01438         return $this->getDir( $sFile, $this->_sPictureDir . "/" . $this->_sMasterPictureDir, $blAdmin );
01439     }
01440 
01453     public function getPictureUrl( $sFile, $blAdmin = false, $blSSL = null, $iLang = null, $iShopId = null, $sDefPic = "master/nopic.jpg" )
01454     {
01455         if ( $sAltUrl = oxRegistry::get("oxPictureHandler")->getAltImageUrl('/', $sFile, $blSSL) ) {
01456             return $sAltUrl;
01457         }
01458 
01459         $blNativeImg = $this->getConfigParam( 'blNativeImages' );
01460         $sUrl = $this->getUrl( $sFile, $this->_sPictureDir, $blAdmin, $blSSL, $blNativeImg, $iLang, $iShopId );
01461 
01462         //anything is better than empty name, because <img src=""> calls shop once more = x2 SLOW.
01463         if ( !$sUrl && $sDefPic ) {
01464             $sUrl = $this->getUrl( $sDefPic, $this->_sPictureDir, $blAdmin, $blSSL, $blNativeImg, $iLang, $iShopId );
01465         }
01466         return $sUrl;
01467     }
01468 
01476     public function getPictureDir( $blAdmin )
01477     {
01478         return $this->getDir( null, $this->_sPictureDir, $blAdmin );
01479     }
01480 
01489     public function getTemplatePath( $sFile, $blAdmin )
01490     {
01491         $sTemplatePath = $this->getDir( $sFile, $this->_sTemplateDir, $blAdmin );
01492 
01493         if (!$sTemplatePath) {
01494             $sBasePath        = getShopBasePath();
01495             $aModuleTemplates = $this->getConfigParam('aModuleTemplates');
01496 
01497             $oModulelist = oxNew('oxmodulelist');
01498             $aActiveModuleInfo = $oModulelist->getActiveModuleInfo();
01499             if (is_array($aModuleTemplates) && is_array($aActiveModuleInfo)) {
01500                 foreach ($aModuleTemplates as $sModuleId => $aTemplates) {
01501                     if (isset($aTemplates[$sFile]) && isset($aActiveModuleInfo[$sModuleId])) {
01502                         $sPath = $aTemplates[$sFile];
01503                         $sPath = $sBasePath. 'modules/'.  $sPath;
01504                         if (is_file($sPath) && is_readable($sPath)) {
01505                             $sTemplatePath =  $sPath;
01506                         }
01507                     }
01508                 }
01509             }
01510         }
01511 
01512         return $sTemplatePath;
01513     }
01514 
01522     public function getTemplateDir( $blAdmin = false )
01523     {
01524         return $this->getDir( null, $this->_sTemplateDir, $blAdmin );
01525     }
01526 
01537     public function getTemplateUrl( $sFile = null, $blAdmin = false, $blSSL = null , $iLang = null )
01538     {
01539         return $this->getShopMainUrl() . $this->getDir( $sFile, $this->_sTemplateDir, $blAdmin, $iLang, null, null, false );
01540     }
01541 
01549     public function getTemplateBase( $blAdmin = false )
01550     {
01551         // Base template dir is the parent dir of template dir
01552         return str_replace( $this->_sTemplateDir.'/', '', $this->getDir( null, $this->_sTemplateDir, $blAdmin, null, null, null, false ));
01553     }
01554 
01563     public function getResourcePath($sFile = '', $blAdmin = false )
01564     {
01565         return $this->getDir( $sFile, $this->_sResourceDir, $blAdmin );
01566     }
01567 
01575     public function getModulesDir( $blAbsolute = true )
01576     {
01577         if ($blAbsolute) {
01578             return $this->getConfigParam('sShopDir') . $this->_sModulesDir . '/';
01579         } else {
01580             return $this->_sModulesDir . '/';
01581         }
01582     }
01583 
01594     public function getResourceUrl( $sFile = '', $blAdmin = false , $blSSL = null , $iLang = null )
01595     {
01596         $blNativeImg = $this->getConfigParam( 'blNativeImages' );
01597         return $this->getUrl( $sFile, $this->_sResourceDir, $blAdmin, $blSSL, $blNativeImg, $iLang );
01598     }
01599 
01607     public function getResourceDir( $blAdmin )
01608     {
01609         return $this->getDir( null, $this->_sResourceDir, $blAdmin );
01610     }
01611 
01619     public function getCurrencyArray( $iCurrency = null )
01620     {
01621         $aConfCurrencies = $this->getConfigParam( 'aCurrencies' );
01622         if ( !is_array( $aConfCurrencies ) ) {
01623             return array();
01624         }
01625 
01626         if ( defined( 'OXID_PHP_UNIT' ) ) {
01627             if ( isset( modConfig::$unitMOD ) && is_object( modConfig::$unitMOD ) ) {
01628                 try{
01629                     $aAltCurrencies = modConfig::getInstance()->getConfigParam( 'modaCurrencies' );
01630                     if ( isset( $aAltCurrencies ) ) {
01631                         $aConfCurrencies = $aAltCurrencies;
01632                     }
01633                 } catch( Exception $e ) {
01634                     // if exception is thrown, use default
01635                 }
01636             }
01637         }
01638 
01639         // processing currency configuration data
01640         $aCurrencies = array();
01641         reset( $aConfCurrencies );
01642         while ( list( $key, $val ) = each( $aConfCurrencies ) ) {
01643             if ( $val ) {
01644                 $oCur = new stdClass();
01645                 $oCur->id      = $key;
01646                 $sCur = explode( '@', $val);
01647                 $oCur->name     = trim( $sCur[0] );
01648                 $oCur->rate     = trim( $sCur[1] );
01649                 $oCur->dec      = trim( $sCur[2] );
01650                 $oCur->thousand = trim( $sCur[3] );
01651                 $oCur->sign     = trim( $sCur[4] );
01652                 $oCur->decimal  = trim( $sCur[5] );
01653 
01654                 // change for US version
01655                 if ( isset( $sCur[6] ) ) {
01656                     $oCur->side = trim($sCur[6]);
01657                 }
01658 
01659                 if ( isset( $iCurrency) && $key == $iCurrency ) {
01660                     $oCur->selected = 1;
01661                 } else {
01662                     $oCur->selected = 0;
01663                 }
01664                 $aCurrencies[$key]= $oCur;
01665             }
01666 
01667             // #861C -  performance, do not load other currencies
01668             if ( !$this->getConfigParam( 'bl_perfLoadCurrency' ) ) {
01669                 break;
01670             }
01671         }
01672         return $aCurrencies;
01673     }
01674 
01682     public function getCurrencyObject( $sName )
01683     {
01684         $aSearch = $this->getCurrencyArray();
01685         foreach ( $aSearch as $oCur ) {
01686             if ( $oCur->name == $sName ) {
01687                 return $oCur;
01688             }
01689         }
01690     }
01691 
01697     public function isDemoShop()
01698     {
01699         return $this->getConfigParam('blDemoShop');
01700     }
01701 
01702 
01703 
01709     public function getEdition()
01710     {
01711             return "CE";
01712 
01713 
01714     }
01715 
01721     public function getFullEdition()
01722     {
01723         $sEdition = $this->getEdition();
01724 
01725             if ($sEdition == "CE") {
01726                 return "Community Edition";
01727             }
01728 
01729 
01730 
01731         return $sEdition;
01732     }
01733 
01739     public function getVersion()
01740     {
01741         $sVersion = $this->getActiveShop()->oxshops__oxversion->value;
01742         return $sVersion;
01743     }
01744 
01750     public function getRevision()
01751     {
01752         $sFileName = $this->getConfigParam( 'sShopDir' ) . "/pkg.rev";
01753         $sRev = trim(@file_get_contents($sFileName));
01754 
01755         if (!$sRev) {
01756             return false;
01757         }
01758 
01759         return $sRev;
01760     }
01761 
01767     public function getPackageInfo()
01768     {
01769         $sFileName = $this->getConfigParam( 'sShopDir' ) . "/pkg.info";
01770         $sRev = @file_get_contents($sFileName);
01771         $sRev = str_replace("\n", "<br>", $sRev);
01772 
01773         if (!$sRev) {
01774             return false;
01775         }
01776 
01777         return $sRev;
01778     }
01779 
01780 
01786     public function isMall()
01787     {
01788 
01789             return false;
01790     }
01791 
01801     public function detectVersion()
01802     {
01803     }
01804 
01805 
01806 
01819     public function saveShopConfVar( $sVarType, $sVarName, $sVarVal, $sShopId = null, $sModule = '' )
01820     {
01821         switch ( $sVarType ) {
01822             case 'arr':
01823             case 'aarr':
01824                 $sValue = serialize( $sVarVal );
01825                 break;
01826             case 'bool':
01827                 //config param
01828                 $sVarVal = (( $sVarVal == 'true' || $sVarVal) && $sVarVal && strcasecmp($sVarVal, "false"));
01829                 //db value
01830                 $sValue  = $sVarVal?"1":"";
01831                 break;
01832             case 'num':
01833                 //config param
01834                 $sVarVal = $sVarVal != ''? oxRegistry::getUtils()->string2Float( $sVarVal ) : '';
01835                 $sValue = $sVarVal;
01836                 break;
01837             default:
01838                 $sValue  = $sVarVal;
01839                 break;
01840         }
01841 
01842         if ( !$sShopId ) {
01843             $sShopId = $this->getShopId();
01844         }
01845 
01846         // Update value only for current shop
01847         if ($sShopId == $this->getShopId()) {
01848             $this->setConfigParam( $sVarName, $sVarVal );
01849         }
01850 
01851         $oDb = oxDb::getDb();
01852 
01853         $sShopIdQuoted     = $oDb->quote($sShopId);
01854         $sModuleQuoted     = $oDb->quote($sModule);
01855         $sVarNameQuoted    = $oDb->quote($sVarName);
01856         $sVarTypeQuoted    = $oDb->quote($sVarType);
01857         $sVarValueQuoted   = $oDb->quote($sValue);
01858         $sConfigKeyQuoted  = $oDb->quote($this->getConfigParam('sConfigKey'));
01859         $sNewOXIDdQuoted   = $oDb->quote(oxUtilsObject::getInstance()->generateUID());
01860 
01861         $sQ = "delete from oxconfig where oxshopid = $sShopIdQuoted and oxvarname = $sVarNameQuoted and oxmodule = $sModuleQuoted";
01862         $oDb->execute( $sQ );
01863 
01864         $sQ = "insert into oxconfig (oxid, oxshopid, oxmodule, oxvarname, oxvartype, oxvarvalue)
01865                values($sNewOXIDdQuoted, $sShopIdQuoted, $sModuleQuoted, $sVarNameQuoted, $sVarTypeQuoted, ENCODE( $sVarValueQuoted, $sConfigKeyQuoted) )";
01866         $oDb->execute( $sQ );
01867 
01868 
01869 
01870     }
01871 
01872 
01882     public function getShopConfVar( $sVarName, $sShopId = null, $sModule = '' )
01883     {
01884         if ( !$sShopId ) {
01885             $sShopId = $this->getShopId();
01886         }
01887 
01888         if ( $sShopId === $this->getShopId() && ( !$sModule || $sModule == oxConfig::OXMODULE_THEME_PREFIX . $this->getConfigParam('sTheme') ) ) {
01889             $sVarValue = $this->getConfigParam( $sVarName );
01890             if ( $sVarValue !== null ) {
01891                 return $sVarValue;
01892             }
01893         }
01894 
01895         $oDb = oxDb::getDb( oxDb::FETCH_MODE_ASSOC );
01896 
01897         $sQ  = "select oxvartype, ".$this->getDecodeValueQuery()." as oxvarvalue from oxconfig where oxshopid = '{$sShopId}' and oxmodule = '{$sModule}' and oxvarname = ".$oDb->quote($sVarName);
01898         $oRs = $oDb->select( $sQ );
01899 
01900         $sValue = null;
01901         if ( $oRs != false && $oRs->recordCount() > 0 ) {
01902             $sValue = $this->decodeValue( $oRs->fields['oxvartype'], $oRs->fields['oxvarvalue'] );
01903         }
01904         return $sValue;
01905     }
01906 
01915     public function decodeValue( $sType, $mOrigValue )
01916     {
01917         $sValue = $mOrigValue;
01918         switch ( $sType ) {
01919             case 'arr':
01920             case 'aarr':
01921                 $sValue = unserialize( $mOrigValue );
01922                 break;
01923             case 'bool':
01924                 $sValue = ( $mOrigValue == 'true' || $mOrigValue == '1' );
01925                 break;
01926         }
01927 
01928         return $sValue;
01929     }
01930 
01938     public function getDecodeValueQuery( $sFieldName = "oxvarvalue" )
01939     {
01940         return " DECODE( {$sFieldName}, '".$this->getConfigParam( 'sConfigKey' )."') ";
01941     }
01942 
01948     public function isProductiveMode()
01949     {
01950         $blProductive = false;
01951 
01952         $blProductive = $this->getConfigParam( 'blProductive' );
01953         if ( !isset( $blProductive ) ) {
01954             $sQ = 'select oxproductive from oxshops where oxid = "'.$this->getShopId().'"';
01955             $blProductive = ( bool ) oxDb::getDb()->getOne( $sQ );
01956             $this->setConfigParam( 'blProductive', $blProductive );
01957         }
01958 
01959         return $blProductive;
01960     }
01961 
01962 
01963 
01969     public function getBaseShopId()
01970     {
01971 
01972             return 'oxbaseshop';
01973     }
01974 
01980     public function getActiveShop()
01981     {
01982         if ( $this->_oActShop && $this->_iShopId == $this->_oActShop->getId() &&
01983              $this->_oActShop->getLanguage() == oxRegistry::getLang()->getBaseLanguage() ) {
01984             return $this->_oActShop;
01985         }
01986 
01987         $this->_oActShop = oxNew( 'oxshop' );
01988         $this->_oActShop->load( $this->getShopId() );
01989         return $this->_oActShop;
01990     }
01991 
01997     public function getActiveView()
01998     {
01999         if ( count( $this->_aActiveViews ) ) {
02000             $oActView = end( $this->_aActiveViews );
02001         }
02002         if ( $oActView == null ) {
02003             $oActView = oxNew( 'oxubase' );
02004             $this->_aActiveViews[] = $oActView;
02005         }
02006 
02007         return $oActView;
02008     }
02009 
02015     public function getTopActiveView()
02016     {
02017         if ( count( $this->_aActiveViews ) ) {
02018             return reset( $this->_aActiveViews );
02019         } else {
02020             return $this->getActiveView();
02021         }
02022     }
02023 
02029     public function getActiveViewsList()
02030     {
02031         return $this->_aActiveViews;
02032     }
02033 
02041     public function setActiveView( $oView )
02042     {
02043         $this->_aActiveViews[] = $oView;
02044     }
02045 
02051     public function dropLastActiveView()
02052     {
02053         array_pop( $this->_aActiveViews );
02054     }
02055 
02061     public function hasActiveViewsChain()
02062     {
02063         return ( count( $this->_aActiveViews ) > 1 );
02064     }
02065 
02071     public function getActiveViewsNames()
02072     {
02073         $aNames = array();
02074 
02075         if ( is_array( $this->getActiveViewsList() ) ) {
02076             foreach ($this->getActiveViewsList() as $oView ) {
02077                 $aNames[] = $oView->getClassName();
02078             }
02079         }
02080 
02081         return $aNames;
02082     }
02083 
02089     public function isUtf()
02090     {
02091         return ( bool ) $this->getConfigParam( 'iUtfMode' );
02092     }
02093 
02099     public function getLogsDir()
02100     {
02101         return $this->getConfigParam( 'sShopDir' ).'log/';
02102     }
02103 
02111     public function isThemeOption( $sName )
02112     {
02113         return (bool) isset( $this->_aThemeConfigParams[$sName] );
02114     }
02115 
02121     public function getShopMainUrl()
02122     {
02123         return $this->_blIsSsl ? $this->getConfigParam( 'sSSLShopURL' ) : $this->getConfigParam( 'sShopURL' );
02124     }
02125 
02131     public function getAllModules()
02132     {
02133         return $this->parseModuleChains($this->getConfigParam('aModules'));
02134     }
02135 
02143     public function parseModuleChains($aModules)
02144     {
02145         $aModuleArray = array();
02146 
02147         if (is_array($aModules)) {
02148             foreach ($aModules as $sClass => $sModuleChain) {
02149                 if (strstr($sModuleChain, '&')) {
02150                     $aModuleChain = explode('&', $sModuleChain);
02151                 } else {
02152                     $aModuleChain = array($sModuleChain);
02153                 }
02154                 $aModuleArray[$sClass] = $aModuleChain;
02155             }
02156         }
02157 
02158         return $aModuleArray;
02159     }
02160 
02166     public function getShopIds()
02167     {
02168         return oxDb::getDb()->getCol( "SELECT `oxid` FROM `oxshops`" );
02169     }
02170 
02180     public function getShopUrlByLanguage($iLang, $blSSL = false)
02181     {
02182         $sLanguageUrl = null;
02183         $sConfigParameter = $blSSL ? 'aLanguageSSLURLs' : 'aLanguageURLs';
02184         $iLang = isset($iLang) ? $iLang : oxRegistry::getLang()->getBaseLanguage();
02185         $aLanguageURLs = $this->getConfigParam($sConfigParameter);
02186         if (isset($iLang) && isset($aLanguageURLs[$iLang]) && !empty($aLanguageURLs[$iLang])) {
02187             $aLanguageURLs[$iLang] = oxRegistry::getUtils()->checkUrlEndingSlash($aLanguageURLs[$iLang]);
02188             $sLanguageUrl = $aLanguageURLs[$iLang];
02189         }
02190 
02191         return $sLanguageUrl;
02192     }
02193 
02201     public function getMallShopUrl($blSSL = false)
02202     {
02203         $sUrl = null;
02204         $sConfigParameter = $blSSL ? 'sMallSSLShopURL' : 'sMallShopURL';
02205         $sMallShopURL = $this->getConfigParam($sConfigParameter);
02206         if ($sMallShopURL) {
02207             $sMallShopURL = oxRegistry::getUtils()->checkUrlEndingSlash($sMallShopURL);
02208             $sUrl = $sMallShopURL;
02209         }
02210 
02211         return $sUrl;
02212     }
02213 
02220     protected function _handleDbConnectionException( $oEx )
02221     {
02222         $oEx->debugOut();
02223         if ( defined( 'OXID_PHP_UNIT' ) ) {
02224             return false;
02225         } elseif ( 0 != $this->iDebug ) {
02226             oxRegistry::getUtils()->showMessageAndExit( $oEx->getString() );
02227         } else {
02228             header( "HTTP/1.1 500 Internal Server Error");
02229             header( "Location: offline.html");
02230             header( "Connection: close");
02231         }
02232     }
02233 
02240     protected function _handleCookieException( $oEx )
02241     {
02242         $this->_processSeoCall();
02243 
02244         //starting up the session
02245         $this->getSession()->start();
02246 
02247         // redirect to start page and display the error
02248         oxRegistry::get("oxUtilsView")->addErrorToDisplay( $oEx );
02249         oxRegistry::getUtils()->redirect( $this->getShopHomeURL() .'cl=start', true, 302 );
02250     }
02251 }