Просмотр исходного кода

#57 - allow to turn-off cache completely

Alex Trofimov 12 лет назад
Родитель
Сommit
075f13ad5e

+ 1 - 1
inc/classes/BxDolAcl.php

@@ -201,7 +201,7 @@ class BxDolAcl extends BxDol implements iBxDolSingleton {
     	$aMembership = $this->getMemberMembershipInfo($iProfileId); // get current profile's membership information
     
     	$aLangFileParams[CHECK_ACTION_LANG_FILE_MEMBERSHIP] = _t($aMembership['name']);
-    	$aLangFileParams[CHECK_ACTION_LANG_FILE_SITE_EMAIL] = $this->oDb->getParam('site_email');
+    	$aLangFileParams[CHECK_ACTION_LANG_FILE_SITE_EMAIL] = getParam('site_email');
 
     	$aAction = $this->oDb->getAction($aMembership['id'], $iActionId);
     	if (!$aAction)

+ 1 - 1
inc/classes/BxDolAlerts.php

@@ -62,7 +62,7 @@ class BxDolAlerts extends BxDol {
 
             $oDb = BxDolDb::getInstance();
             $oCache = $oDb->getDbCacheObject();
-            $sCacheKey = $this->genDbCacheKey('sys_alerts');
+            $sCacheKey = $oDb->genDbCacheKey('sys_alerts');
             $aData = $oCache->getData($sCacheKey);
             if (null === $aData) {
                 $aData = $this->getAlertsData();

+ 0 - 5
inc/classes/BxDolCacheUtilities.php

@@ -88,11 +88,6 @@ class BxDolCacheUtilities extends BxDol
 
     function _clearCacheObject($oCache, $sPrefix)
     {
-        if ('db_' == $sPrefix)
-            $GLOBALS['MySQL']->oParams->clearCache();
-        elseif ($this->oMemberMenu->sMenuMemberKeysCache == $sPrefix)
-            $this->oMemberMenu->deleteMemberMenuCaches();
-
         if (!$oCache->removeAllByPrefix ($sPrefix))
             return array('code' => 1, 'message' => _t('_adm_txt_dashboard_cache_clean_failed'));
         else

+ 60 - 36
inc/classes/BxDolDb.php

@@ -15,6 +15,8 @@ class BxDolDb extends BxDol implements iBxDolSingleton
     protected $_rLink, $_rCurrentRes, $_iCurrentResType;
 
     protected $_oDbCacheObject = null;
+    protected $_aParams = null;
+    protected $_sParamsCacheName = 'sys_options';
 
     /**
      * set database parameters and connect to it
@@ -63,26 +65,6 @@ class BxDolDb extends BxDol implements iBxDolSingleton
             trigger_error('Clone is not allowed for the class: ' . get_class($this), E_USER_ERROR);
     }
 
-    public function __get($sName)
-    {
-        if ('oParams' == $sName) {
-            bx_import('BxDolParams');
-            return BxDolParams::getInstance($this);
-        }
-
-        $aTrace = debug_backtrace();
-        trigger_error('Undefined property via __get(): ' . $sName . ' in ' . $aTrace[0]['file'] . ' on line ' . $aTrace[0]['line'], E_USER_NOTICE);
-
-        return null;
-    }
-
-    public function __isset($sName)
-    {
-        if ('oParams' == $sName)
-            return true;
-        return false;
-    }
-
     /**
      * Get singleton instance of the class
      */
@@ -417,25 +399,67 @@ class BxDolDb extends BxDol implements iBxDolSingleton
             $this->log($text . ': ' . $this->getErrorMessage());
     }
 
-    function isParam($sName, $bCache = true) 
+    protected function isParamInCache($sKey) 
+    {
+        return isset($this->_aParams[$sKey]);
+    }
+
+    protected function cacheParams($bForceCacheInvalidate = false) 
+    {
+        if ($bForceCacheInvalidate)
+            $this->cacheParamsClear();
+
+        $this->_aParams = $this->fromCache($this->_sParamsCacheName, 'getPairs', "SELECT `name`, `value` FROM `sys_options`", "name", "value");
+        if (empty($this->_aParams)) {
+            $this->_aParams = array ();
+            return false;
+        }
+
+        return true;
+    }
+
+    public function cacheParamsClear() 
+    {
+        return $this->cleanCache($this->_sParamsCacheName);
+    }
+
+    public function isParam($sKey, $bFromCache = true) 
     {
-        return $this->oParams->exists($sName, $bCache);
+    	if ($bFromCache && $this->isParamInCache($sKey))
+    	   return true;
+
+        $sQuery = $this->prepare("SELECT `name` FROM `sys_options` WHERE `name` = ? LIMIT 1", $sKey);
+        return $this->getOne($sQuery) == $sKey;
     }
 
     function addParam($sName, $sValue, $iKateg, $sDesc, $sType) 
     {
-        return $this->oParams->add($sName, $sValue, $iKateg, $sDesc, $sType);
+        $sQuery = $this->prepare("INSERT INTO `sys_options` SET `category_id` = ?, `name` = ?, `caption` = ?, `value` = ?, `type` = ?", $iKateg, $sName, $sDesc, $sValue, $sType);
+        $this->query($sQuery);
+
+        // renew params cache
+        $this->cacheParams(true);
     }
 
-    function getParam($sName, $bCache = true) 
+    function getParam($sKey, $bFromCache = true) 
     {
-        return $this->oParams->get($sName, $bCache);
+        if (!$sKey)
+            return false;
+        if ($bFromCache && $this->isParamInCache($sKey)) {
+            return $this->_aParams[$sKey];
+        } else {
+            $sQuery = $this->prepare("SELECT `value` FROM `sys_options` WHERE `name` = ? LIMIT 1", $sKey);
+            return $this->getOne($sQuery);
+        }
     }
 
-    function setParam($sName, $sValue ) 
+    function setParam($sKey, $mixedValue) 
     {
-        $this->oParams->set($sName, $sValue);
-        return true;
+        $sQuery = $this->prepare("UPDATE `sys_options` SET `value` = ? WHERE `name` = ? LIMIT 1", $mixedValue, $sKey);
+        $this->query($sQuery);
+
+        // renew params cache
+        $this->cacheParams(true);
     }
 
     function listTables() 
@@ -487,10 +511,10 @@ class BxDolDb extends BxDol implements iBxDolSingleton
             {
 
                 // truncating global settings since it repeated many times and output it separately
-                if (isset($aCall['object']) && property_exists($aCall['object'], 'oParams') && property_exists($aCall['object']->oParams, '_aParams')) {
+                if (isset($aCall['object']) && property_exists($aCall['object'], '_aParams')) {
                     if (false === $sParamsOutput)
-                        $sParamsOutput = var_export($aCall['object']->oParams->_aParams, true);
-                    $aCall['object']->oParams->_aParams = '[truncated]';
+                        $sParamsOutput = var_export($aCall['object']->_aParams, true);
+                    $aCall['object']->_aParams = '[truncated]';
                 }
 
                 if (isset($aCall['args']) && is_array($aCall['args']))
@@ -561,7 +585,7 @@ EOJ;
             echo $out;
 
         if(BxDolConfig::getInstance()->get('db', 'error_remort_by_email')) {
-            $sSiteTitle = getParam('site_title');
+            $sSiteTitle = $this->getParam('site_title');
             $sMailBody = "Database error in " . $sSiteTitle . "<br /><br /> \n";
 
             if( strlen( $query ) )
@@ -584,7 +608,7 @@ EOJ;
             $sMailBody .= "<hr />Request parameters: <pre>" . print_r( $_REQUEST, true ) . " </pre>";
             $sMailBody .= "--\nAuto-report system\n";
 
-            sendMail(getParam('site_email_bug_report'), "Database error in " . $sSiteTitle, $sMailBody, 0, array(), BX_EMAIL_SYSTEM, 'html', true);
+            sendMail($this->getParam('site_email_bug_report'), "Database error in " . $sSiteTitle, $sMailBody, 0, array(), BX_EMAIL_SYSTEM, 'html', true);
         }
 
         exit;
@@ -600,7 +624,7 @@ EOJ;
         if ($this->_oDbCacheObject != null) {
             return $this->_oDbCacheObject;
         } else {
-            $sEngine = getParam('sys_db_cache_engine');
+            $sEngine = $this->getParam('sys_db_cache_engine');
             $this->_oDbCacheObject = bx_instance ('BxDolCache'.$sEngine);
             if (!$this->_oDbCacheObject->isAvailable())
                 $this->_oDbCacheObject = bx_instance ('BxDolCacheFile');
@@ -619,7 +643,7 @@ EOJ;
         array_shift ($aArgs); // shift $sName
         array_shift ($aArgs); // shift $sFunc
 
-        if (!getParam('sys_db_cache_enable'))
+        if (!$this->getParam('sys_db_cache_enable'))
             return call_user_func_array (array ($this, $sFunc), $aArgs); // pass other function parameters as database function parameters
 
         $oCache = $this->getDbCacheObject ();
@@ -644,7 +668,7 @@ EOJ;
 
     function cleanCache ($sName) 
     {
-        if (!getParam('sys_db_cache_enable'))
+        if (!$this->getParam('sys_db_cache_enable'))
             return true;
 
         $oCache = $this->getDbCacheObject ();

+ 3 - 4
inc/classes/BxDolForm.php

@@ -943,13 +943,12 @@ class BxDolForm extends BxDol implements iBxDolReplaceable
 
     // Static Methods related to CSRF Tocken
 	public static function genCsrfToken($bReturn = false) {
-        $oDb = BxDolDb::getInstance();
-        if ($oDb->getParam('sys_security_form_token_enable') != 'on')
+        if (getParam('sys_security_form_token_enable') != 'on')
             return false;
 
         $oSession = BxDolSession::getInstance();
 
-        $iCsrfTokenLifetime = (int)$oDb->getParam('sys_security_form_token_lifetime');
+        $iCsrfTokenLifetime = (int)getParam('sys_security_form_token_lifetime');
         if($oSession->getValue('csrf_token') === false || ($iCsrfTokenLifetime != 0 && time() - (int)$oSession->getValue('csrf_token_time') > $iCsrfTokenLifetime)) {
             $sToken = genRndPwd(20, true);
             $oSession->setValue('csrf_token', $sToken);
@@ -1090,7 +1089,7 @@ class BxDolFormChecker {
         $iErrors = 0;
 
         // check CSRF token if it's needed.
-        if (BxDolDb::getInstance()->getParam('sys_security_form_token_enable') == 'on' && $this->_bFormCsrfChecking === true && ($mixedCsrfTokenSys = BxDolForm::getCsrfToken()) !== false) {
+        if (getParam('sys_security_form_token_enable') == 'on' && $this->_bFormCsrfChecking === true && ($mixedCsrfTokenSys = BxDolForm::getCsrfToken()) !== false) {
             $mixedCsrfTokenUsr = BxDolForm::getSubmittedValue('csrf_token', $this->_sFormMethod, $this->_aSpecificValues);
             unset($aInputs['csrf_token']);
 

+ 0 - 1
inc/classes/BxDolImageTranscoder.php

@@ -614,7 +614,6 @@ class BxDolImageTranscoder extends BxDol implements iBxDolFactoryObject
     }
 
     protected function clearCacheDB() {
-        $this->_oDb->oParams->clearCache();
         $oCacheDb = $this->_oDb->getDbCacheObject();
         return $oCacheDb->removeAllByPrefix('db_');
     }

+ 1 - 1
inc/classes/BxDolLanguagesQuery.php

@@ -67,7 +67,7 @@ class BxDolLanguagesQuery extends BxDolDb implements iBxDolSingleton {
         		break;
             case 'default':
         	    $aMethod['name'] = 'getRow';
-        		$sWhereClause .= $this->prepare(" AND `tl`.`Name`=?", $this->getParam('lang_default'));
+        		$sWhereClause .= $this->prepare(" AND `tl`.`Name`=?", getParam('lang_default'));
         		break;
         	case 'active':
                 $sWhereClause = " AND `tl`.`Enabled`='1'";

+ 0 - 111
inc/classes/BxDolParams.php

@@ -1,111 +0,0 @@
-<?php defined('BX_DOL') or die('hack attempt');
-/**
- * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
- * CC-BY License - http://creativecommons.org/licenses/by/3.0/
- *
- * @defgroup    DolphinCore Dolphin Core
- * @{
- */
-
-bx_import('BxDolCacheFile');
-
-class BxDolParams extends BxDol {
-    protected $_oDb;
-    protected $_oCache;
-    protected $_sCacheFile;
-    protected $_aParams;
-
-    /**
-     * constructor
-     */
-    function __construct($oDb) {
-        if (isset($GLOBALS['bxDolClasses'][get_class($this)]))
-            trigger_error ('Multiple instances are not allowed for the class: ' . get_class($this), E_USER_ERROR);
-
-        parent::__construct();
-
-        $this->_oDb = $oDb;
-        $this->_oCache = new BxDolCacheFile(); // feel free to change to another cache system if you are sure that it is available
-
-        $this->_sCacheFile = 'sys_options_' . bx_site_hash('', true) . '.php';
-
-        $this->_aParams = $this->_oCache->getData($this->_sCacheFile);
-        if(empty($this->_aParams) && $this->_oDb != null)
-            $this->cache();
-    }
-
-    /**
-     * Prevent cloning the instance
-     */
-    public function __clone() {
-        if (isset($GLOBALS['bxDolClasses'][get_class($this)]))
-            trigger_error('Clone is not allowed for the class: ' . get_class($this), E_USER_ERROR);
-    }
-
-    /**
-     * Get singleton instance of the class
-     */
-    public static function getInstance($oDb) {
-        if(!isset($GLOBALS['bxDolClasses'][__CLASS__]))
-            $GLOBALS['bxDolClasses'][__CLASS__] = new BxDolParams($oDb);
-
-        return $GLOBALS['bxDolClasses'][__CLASS__];
-    }
-
-    function isInCache($sKey) {
-        return isset($this->_aParams[$sKey]);
-    }
-
-    function exists($sKey, $bFromCache = true) {
-    	if($bFromCache && $this->isInCache($sKey))
-    	   return true;
-
-        $sQuery = $this->_oDb->prepare("SELECT `name` FROM `sys_options` WHERE `name`=? LIMIT 1", $sKey);
-        return $this->_oDb->getOne($sQuery) == $sKey;
-    }
-
-    function add($sName, $sValue, $iKateg, $sDesc, $sType) {
-        //--- Update Database ---//
-        $sQuery = $this->_oDb->prepare("INSERT INTO `sys_options` SET `category_id`=?, `name`=?, `caption`=?, `value`=?, `type`=?", $iKateg, $sName, $sDesc, $sValue, $sType);
-        $this->_oDb->query($sQuery);
-
-        //--- Update Cache ---//
-        $this->cache();
-    }
-
-    function get($sKey, $bFromCache = true) {
-        if (!$sKey)
-            return false;
-        if ($bFromCache && $this->isInCache($sKey)) {
-            return $this->_aParams[$sKey];
-        } else {
-            $sQuery = $this->_oDb->prepare("SELECT `value` FROM `sys_options` WHERE `name`=? LIMIT 1", $sKey);
-            return $this->_oDb->getOne($sQuery);
-        }
-    }
-
-    function set($sKey, $mixedValue) {
-        //--- Update Database ---//
-        $sQuery = $this->_oDb->prepare("UPDATE `sys_options` SET `value`=? WHERE `name`=? LIMIT 1", $mixedValue, $sKey);
-        $this->_oDb->query($sQuery);
-
-        //--- Update Cache ---//
-        $this->cache();
-    }
-
-    function cache() {
-        $this->_aParams = $this->_oDb->getPairs("SELECT `name`, `value` FROM `sys_options`", "name", "value");
-        if (empty($this->_aParams)) {
-            $this->_aParams = array ();
-            return false;
-        }
-
-        return $this->_oCache->setData($this->_sCacheFile, $this->_aParams);
-    }
-
-    function clearCache() {
-        $this->_oCache->delData($this->_sCacheFile);
-    }
-}
-
-/** @} */

+ 1 - 1
inc/classes/BxDolPermalinks.php

@@ -121,7 +121,7 @@ class BxDolPermalinks extends BxDolDb implements iBxDolSingleton {
                 'permalink' => $aLink['permalink'],
                 'standard' => $aLink['standard'],
                 'check' => $aLink['check'],
-                'enabled' => $this->getParam($aLink['check']) == 'on',
+                'enabled' => getParam($aLink['check']) == 'on',
             );
             $aResult['standard'][$aLink['standard']] = $a;
             $aResult['permalink'][$aLink['permalink']] = $a;

+ 29 - 11
inc/classes/BxDolTemplate.php

@@ -198,7 +198,7 @@ class BxDolTemplate extends BxDol implements iBxDolSingleton {
 
         $this->_sCodeKey = 'skin';
 
-        $sCode = BxDolDb::getInstance()->getParam('template');
+        $sCode = getParam('template');
         if(empty($sCode))
             $sCode = BX_DOL_TEMPLATE_DEFAULT_CODE;
         $this->_checkCode($sCode, false);
@@ -349,22 +349,40 @@ class BxDolTemplate extends BxDol implements iBxDolSingleton {
         ));
 
         //--- Load injection's cache ---//
-        $oDb = BxDolDb::getInstance();
-        $oCache = $oDb->getDbCacheObject();
-        $aInjections = $oCache->getData($oDb->genDbCacheKey($this->_sInjectionsCache));
-        if($aInjections === null) {
-            $aInjections = $oDb->getAll("SELECT `page_index`, `name`, `key`, `type`, `data`, `replace` FROM `" . $this->_sInjectionsTable . "` WHERE `active`='1'");
-            foreach ($aInjections as $aInjection)
-                $aInjections['page_' . $aInjection['page_index']][$aInjection['key']][] = $aInjection;
-
-            $oCache->setData ($oDb->genDbCacheKey($this->_sInjectionsCache), $aInjections);
+        if (getParam('sys_db_cache_enable')) {
+            $oDb = BxDolDb::getInstance();
+            $oCache = $oDb->getDbCacheObject();
+            $sCacheKey = $oDb->genDbCacheKey($this->_sInjectionsCache);
+
+            $aInjections = $oCache->getData($sCacheKey);
+            if ($aInjections === null) {
+                $aInjections = $this->getInjectionsData();
+                $oCache->setData ($sCacheKey, $aInjections);
+            }
+        } else {
+            $aInjections = $this->getInjectionsData();
         }
+
         $this->aPage['injections'] = $aInjections;
 
+
         bx_import('BxTemplConfig');
         $this->_oConfigTemplate = BxTemplConfig::getInstance();
     }
 
+    protected function getInjectionsData () {
+        $oDb = BxDolDb::getInstance();
+
+        $aInjections = $oDb->getAll("SELECT `page_index`, `name`, `key`, `type`, `data`, `replace` FROM `" . $this->_sInjectionsTable . "` WHERE `active`='1'");
+        if (!$aInjections)
+            return array();
+
+        foreach ($aInjections as $aInjection)
+            $aInjections['page_' . $aInjection['page_index']][$aInjection['key']][] = $aInjection;
+
+        return $aInjections;
+    }
+
     /**
      * Set page name index
      * @param int $i name index
@@ -612,7 +630,7 @@ class BxDolTemplate extends BxDol implements iBxDolSingleton {
             $mixedName = array($mixedName);
 
         foreach($mixedName as $sName)
-            $this->aPage['js_options'][$sName] = BxDolDb::getInstance()->getParam($sName);
+            $this->aPage['js_options'][$sName] = getParam($sName);
     }
     /**
      * Add language translation for key in JS output.

+ 2 - 2
modules/boonex/contact/classes/BxContactConfig.php

@@ -36,9 +36,9 @@ class BxContactConfig extends BxDolModuleConfig
     {
         $this->_oDb = &$oDb;
 
-        $this->_sEmail = $this->_oDb->getParam('bx_contact_email');
+        $this->_sEmail = getParam('bx_contact_email');
         if(empty($this->_sEmail))
-        	$this->_sEmail = $this->_oDb->getParam('site_email');
+        	$this->_sEmail = getParam('site_email');
     }
 
 	public function getSystemName($sType)

+ 12 - 12
modules/boonex/sites/classes/BxSitesConfig.php

@@ -69,20 +69,20 @@ class BxSitesConfig extends BxDolModuleConfig
     {
     	$this->_oDb = $oDb;
 
-    	$this->iTrialMaxNumber = (int)$this->_oDb->getParam('bx_sites_payment_trial_max_number');
-    	$this->fTrialPrice = (float)$this->_oDb->getParam('bx_sites_payment_trial_price');
-    	$this->sTrialPeriod = $this->_oDb->getParam('bx_sites_payment_trial_period');
-    	$this->iTrialFrequency = (float)$this->_oDb->getParam('bx_sites_payment_trial_frequency');
+    	$this->iTrialMaxNumber = (int)getParam('bx_sites_payment_trial_max_number');
+    	$this->fTrialPrice = (float)getParam('bx_sites_payment_trial_price');
+    	$this->sTrialPeriod = getParam('bx_sites_payment_trial_period');
+    	$this->iTrialFrequency = (float)getParam('bx_sites_payment_trial_frequency');
     	$this->iTrialBillingCycles = 1;
-    	$this->fRegularPrice = (float)$this->_oDb->getParam('bx_sites_payment_regular_price');
-    	$this->sRegularPeriod = $this->_oDb->getParam('bx_sites_payment_regular_period');
-    	$this->iRegularFrequency = (float)$this->_oDb->getParam('bx_sites_payment_regular_frequency');
+    	$this->fRegularPrice = (float)getParam('bx_sites_payment_regular_price');
+    	$this->sRegularPeriod = getParam('bx_sites_payment_regular_period');
+    	$this->iRegularFrequency = (float)getParam('bx_sites_payment_regular_frequency');
     	$this->iRegularBillingCycles = 0;
-    	$this->sEmailBusiness = $this->_oDb->getParam('bx_sites_payment_email_business');
-    	$this->sEmailSandbox = $this->_oDb->getParam('bx_sites_payment_email_sandbox');
-    	$this->bDemoMode = $this->_oDb->getParam('bx_sites_payment_demo_mode') == 'on';
-    	$this->sCurrencyCode = $this->_oDb->getParam('bx_sites_payment_currency_code');
-    	$this->sCurrencySign = $this->_oDb->getParam('bx_sites_payment_currency_sign');
+    	$this->sEmailBusiness = getParam('bx_sites_payment_email_business');
+    	$this->sEmailSandbox = getParam('bx_sites_payment_email_sandbox');
+    	$this->bDemoMode = getParam('bx_sites_payment_demo_mode') == 'on';
+    	$this->sCurrencyCode = getParam('bx_sites_payment_currency_code');
+    	$this->sCurrencySign = getParam('bx_sites_payment_currency_sign');
     }
 
     function getDomainMask()

+ 6 - 6
modules/boonex/timeline/classes/BxTimelineConfig.php

@@ -137,13 +137,13 @@ class BxTimelineConfig extends BxDolModuleConfig
     {
         $this->_oDb = &$oDb;
 
-        $this->_bAllowDelete = $this->_oDb->getParam('bx_timeline_enable_delete') == 'on';
+        $this->_bAllowDelete = getParam('bx_timeline_enable_delete') == 'on';
 
-        $this->_iPerPageProfile = (int)$this->_oDb->getParam('bx_timeline_events_per_page_profile');
-        $this->_iPerPageAccount = (int)$this->_oDb->getParam('bx_timeline_events_per_page_account');
-        $this->_iRssLength = (int)$this->_oDb->getParam('bx_timeline_rss_length');
+        $this->_iPerPageProfile = (int)getParam('bx_timeline_events_per_page_profile');
+        $this->_iPerPageAccount = (int)getParam('bx_timeline_events_per_page_account');
+        $this->_iRssLength = (int)getParam('bx_timeline_rss_length');
 
-        $this->_iCharsDisplayMax = (int)$this->_oDb->getParam('bx_timeline_chars_display_max');        
+        $this->_iCharsDisplayMax = (int)getParam('bx_timeline_chars_display_max');        
 
 		$aHandlers = $this->_oDb->getHandlers();
         foreach($aHandlers as $aHandler) {
@@ -156,7 +156,7 @@ class BxTimelineConfig extends BxDolModuleConfig
            $this->_aHandlers[$aHandler['alert_unit'] . '_' . $aHandler['alert_action']] = $aHandler;
         }
 
-		$sHideTimeline = $this->_oDb->getParam('bx_timeline_events_hide');
+		$sHideTimeline = getParam('bx_timeline_events_hide');
         if(!empty($sHideTimeline))
             $this->_aHandlersHidden = explode(',', $sHideTimeline);
     }

+ 1 - 1
studio/classes/BxDolStudioDashboard.php

@@ -33,7 +33,7 @@ class BxDolStudioDashboard extends BxTemplStudioPage {
 	        			break;
 
 	        		$sVersionAvl = $aContent['value'];
-	        		$sVersionCur = BxDolDb::getInstance()->getParam('sys_version');
+	        		$sVersionCur = getParam('sys_version');
 	        		if(version_compare($sVersionCur, $sVersionAvl) == -1)
 			        	$aResult = array('version' => $sVersionAvl);
 			    	break;

+ 1 - 1
studio/classes/BxDolStudioDesign.php

@@ -79,7 +79,7 @@ class BxDolStudioDesign extends BxTemplStudioPage {
         if($iTemplates == 1 && $aTemplates[0]['name'] == $sTemplate)
             return array('code' => 1, 'message' => _t('_adm_dsg_err_last_active'));
 
-        $sTemplateDefault = $this->oDb->getParam('template');
+        $sTemplateDefault = getParam('template');
         if($aTemplate['uri'] == $sTemplateDefault)
             return array('code' => 2, 'message' => _t('_adm_dsg_err_deactivate_default'));
 

+ 2 - 2
studio/classes/BxDolStudioDesigner.php

@@ -102,7 +102,7 @@ class BxDolStudioDesigner extends BxTemplStudioPage {
         bx_import('BxDolStorage');
         $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
 
-        $iId = (int)$this->oDb->getParam('sys_site_logo');
+        $iId = (int)getParam('sys_site_logo');
         if($iId != 0 && !$oStorage->deleteFile($iId, $iProfileId))
             return false;
 
@@ -116,7 +116,7 @@ class BxDolStudioDesigner extends BxTemplStudioPage {
         bx_import('BxDolStorage');
         $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
 
-        $iId = (int)$this->oDb->getParam('sys_site_icon');
+        $iId = (int)getParam('sys_site_icon');
         if($iId != 0 && !$oStorage->deleteFile($iId, $iProfileId))
             return $this->getJsResult('_adm_dsg_err_remove_old_icon');
 

+ 2 - 2
studio/classes/BxDolStudioInstaller.php

@@ -687,7 +687,7 @@ class BxDolStudioInstaller extends BxDolInstallerUtils {
         return $bResult && $oLanguages->compileLanguage(0, true) ? BX_DOL_STUDIO_INSTALLER_SUCCESS : BX_DOL_STUDIO_INSTALLER_FAILED;
     }
     function actionRecompileGlobalParamaters($sOperation) {
-        $bResult = $this->oDb->oParams->cache();
+        $bResult = $this->oDb->cacheParamsClear();
         return $bResult ? BX_DOL_STUDIO_INSTALLER_SUCCESS : BX_DOL_STUDIO_INSTALLER_FAILED;
     }
     function actionRecompileMainMenu($sOperation) {
@@ -811,7 +811,7 @@ class BxDolStudioInstaller extends BxDolInstallerUtils {
 
         if($bUseFtp) {
         	bx_import('BxDolFtp');
-			$oFile = new BxDolFtp(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost', $this->oDb->getParam('sys_ftp_login'), $this->oDb->getParam('sys_ftp_password'), $this->oDb->getParam('sys_ftp_dir'));
+			$oFile = new BxDolFtp(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost', getParam('sys_ftp_login'), getParam('sys_ftp_password'), getParam('sys_ftp_dir'));
 
 			if(!$oFile->connect())
 				return null;

+ 1 - 1
studio/classes/BxDolStudioLanguage.php

@@ -78,7 +78,7 @@ class BxDolStudioLanguage extends BxTemplStudioPage {
         if($iLanguages == 1 && $aLanguages[0]['name'] == $sLanguage)
             return array('code' => 1, 'message' => _t('_adm_pgt_err_last_active'));
 
-        $sLanguageDefault = $this->oDb->getParam('lang_default');
+        $sLanguageDefault = getParam('lang_default');
         if($aLanguage['uri'] == $sLanguageDefault)
             return array('code' => 2, 'message' => _t('_adm_pgt_err_deactivate_default'));
 

+ 2 - 3
studio/template/scripts/BxBaseStudioDashboard.php

@@ -56,13 +56,12 @@ class BxBaseStudioDashboard extends BxDolStudioDashboard {
 
     protected function getBlockCodeVersions($sName, $aBlock)
     {
-    	$oDb = BxDolDb::getInstance();
     	$oTemplate = BxDolStudioTemplate::getInstance();
 
     	$oTemplate->addJsTranslation('_adm_dbd_txt_dolphin_n_available');
     	return $oTemplate->parseHtmlByName('dbd_versions.html', array(
-    		'domain' => $oDb->getParam('site_title'),
-    		'version' => $oDb->getParam('sys_version'),
+    		'domain' => getParam('site_title'),
+    		'version' => getParam('sys_version'),
     		'installed' => bx_time_js(getParam('sys_install_time')),
     	));
     }

+ 4 - 4
studio/template/scripts/BxBaseStudioDesigner.php

@@ -106,7 +106,7 @@ class BxBaseStudioDesigner extends BxDolStudioDesigner {
     protected function getLogo() {
         $oTemplate = BxDolStudioTemplate::getInstance();
 
-        $sAlt = $this->oDb->getParam('sys_site_logo_alt');
+        $sAlt = getParam('sys_site_logo_alt');
 
         $aForm = array(
             'form_attrs' => array(
@@ -138,7 +138,7 @@ class BxBaseStudioDesigner extends BxDolStudioDesigner {
                     'caption' => _t('_adm_dsg_txt_upload_image'),
                 	'caption_preview' => _t('_adm_dsg_txt_upload_image_preview'),
                     'ajax_action_delete' => $this->getPageJsObject() . '.deleteLogo()',  
-                    'value' => (int)$this->oDb->getParam('sys_site_logo')
+                    'value' => (int)getParam('sys_site_logo')
                 ),
                 'alt' => array(
                     'type' => 'text',
@@ -192,7 +192,7 @@ class BxBaseStudioDesigner extends BxDolStudioDesigner {
         $sPreview = "";
         $aTmplVars = array('bx_repeat:images' => array());
 
-        if(($iId = (int)$this->oDb->getParam('sys_site_icon')) != 0) {
+        if(($iId = (int)getParam('sys_site_icon')) != 0) {
             $aTranscoders = array(
                 BX_DOL_TRANSCODER_OBJ_ICON_APPLE => '_adm_dsg_txt_icon_apple',
                 BX_DOL_TRANSCODER_OBJ_ICON_FACEBOOK => '_adm_dsg_txt_icon_facebook',
@@ -205,7 +205,7 @@ class BxBaseStudioDesigner extends BxDolStudioDesigner {
 
                 $sImageUrl = $oTranscoder->getImageUrl($iId);
                 if($sImageUrl === false) {
-                    $this->oDb->setParam('sys_site_icon', 0);
+                    setParam('sys_site_icon', 0);
                     break;
                 }
 

+ 1 - 1
template/scripts/BxBaseFormView.php

@@ -149,7 +149,7 @@ BLAH;
     function genRows() {
 
         // add CSRF token if it's needed.
-        if (!(isset($this->aParams['view_mode']) && $this->aParams['view_mode']) && BxDolDb::getInstance()->getParam('sys_security_form_token_enable') == 'on' && (!isset($this->aParams['csrf']['disable']) || (isset($this->aParams['csrf']['disable']) && $this->aParams['csrf']['disable'] !== true)) && ($mixedCsrfToken = BxDolForm::getCsrfToken()) !== false) {
+        if (!(isset($this->aParams['view_mode']) && $this->aParams['view_mode']) && getParam('sys_security_form_token_enable') == 'on' && (!isset($this->aParams['csrf']['disable']) || (isset($this->aParams['csrf']['disable']) && $this->aParams['csrf']['disable'] !== true)) && ($mixedCsrfToken = BxDolForm::getCsrfToken()) !== false) {
             $this->aInputs['csrf_token'] = array(
                 'type' => 'hidden',
                 'name' => 'csrf_token',