Procházet zdrojové kódy

#53 - Code clean-up: remove BxDolConfig

AntonLV před 11 roky
rodič
revize
de7ec970e2

+ 0 - 118
inc/classes/BxDolConfig.php

@@ -1,118 +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    TridentCore Trident Core
- * @{
- */
-
-bx_import('BxDol');
-
-/**
- * System class for main configuration settings.
- */
-class BxDolConfig extends BxDol implements iBxDolSingleton
-{
-    protected $aUrlStatic;
-    protected $aUrlDynamic;
-
-    protected $aPathStatic;
-    protected $aPathDynamic;
-
-    protected $aDb;
-
-    /**
-     * constructor
-     */
-    protected function __construct()
-    {
-        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->aUrlStatic = array();
-        $this->aUrlDynamic = array();
-
-        $this->aPathStatic = array();
-        $this->aPathDynamic = array();
-
-        $this->aDb = array();
-    }
-
-    /**
-     * 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()
-    {
-        if(!isset($GLOBALS['bxDolClasses'][__CLASS__])) {
-            $GLOBALS['bxDolClasses'][__CLASS__] = new BxDolConfig();
-            $GLOBALS['bxDolClasses'][__CLASS__]->init();
-        }
-
-        return $GLOBALS['bxDolClasses'][__CLASS__];
-    }
-
-    function init()
-    {
-        $this->aUrlDynamic = array();
-
-        $this->aPathDynamic = array();
-    }
-
-    function get($sGroup, $sName)
-    {
-        return $this->{$this->getVarName($sGroup)}[$sName];
-    }
-
-    function getGroup($sGroup)
-    {
-        return $this->{$this->getVarName($sGroup)};
-    }
-
-    function set($sGroup, $sName, $sValue, $bDefine = false)
-    {
-        if($bDefine)
-            define($this->getDefineName($sGroup, $sName), $sValue);
-        else
-            $this->{$this->getVarName($sGroup)}[$sName] = $sValue;
-    }
-
-    function setGroup($sGroup, $aValue, $bDefine = false)
-    {
-        if($bDefine)
-            foreach($aValue as $sName => $sValue)
-                define($this->getDefineName($sGroup, $sName), $sValue);
-        else {
-            $sGroup = $this->getVarName($sGroup);
-
-            if(!empty($this->$sGroup) && is_array($this->$sGroup))
-                $this->$sGroup = array_merge($this->$sGroup, $aValue);
-            else
-                $this->$sGroup = $aValue;
-        }
-    }
-
-    private function getVarName($sVar)
-    {
-        return 'a' . bx_gen_method_name($sVar);
-    }
-
-    private function getDefineName()
-    {
-        $aArgs = func_get_args();
-        return 'BX_' . strtoupper(implode('_', $aArgs));
-    }
-}
-
-/** @} */

+ 1 - 2
inc/classes/BxDolDb.php

@@ -532,7 +532,6 @@ EOJ;
             }
             }
         }
         }
 
 
-        bx_import('BxDolConfig');
         if (defined('BX_DB_FULL_VISUAL_PROCESSING') && BX_DB_FULL_VISUAL_PROCESSING) {
         if (defined('BX_DB_FULL_VISUAL_PROCESSING') && BX_DB_FULL_VISUAL_PROCESSING) {
 
 
             ob_start();
             ob_start();
@@ -800,7 +799,7 @@ EOJ;
 
 
     function log ($s)
     function log ($s)
     {
     {
-        return file_put_contents(BX_DIRECTORY_PATH_ROOT . 'logs/db.err.log', date('Y-m-d H:i:s') . "\t" . $s . "\n", FILE_APPEND);
+        return file_put_contents(BX_DIRECTORY_PATH_LOGS . 'db.err.log', date('Y-m-d H:i:s') . "\t" . $s . "\n", FILE_APPEND);
     }
     }
 
 
     function executeSQL($sPath, $aReplace = array (), $isBreakOnError = true)
     function executeSQL($sPath, $aReplace = array (), $isBreakOnError = true)

+ 1 - 1
inc/params.inc.php

@@ -28,6 +28,7 @@ define('BX_DIRECTORY_PATH_PLUGINS', BX_DIRECTORY_PATH_ROOT . 'plugins/');
 define('BX_DIRECTORY_PATH_PLUGINS_PUBLIC', BX_DIRECTORY_PATH_ROOT . 'plugins_public/');
 define('BX_DIRECTORY_PATH_PLUGINS_PUBLIC', BX_DIRECTORY_PATH_ROOT . 'plugins_public/');
 define('BX_DIRECTORY_PATH_MODULES', BX_DIRECTORY_PATH_ROOT . 'modules/');
 define('BX_DIRECTORY_PATH_MODULES', BX_DIRECTORY_PATH_ROOT . 'modules/');
 define('BX_DIRECTORY_PATH_TMP', BX_DIRECTORY_PATH_ROOT . 'tmp/');
 define('BX_DIRECTORY_PATH_TMP', BX_DIRECTORY_PATH_ROOT . 'tmp/');
+define('BX_DIRECTORY_PATH_LOGS', BX_DIRECTORY_PATH_ROOT . 'logs/');
 define('BX_DIRECTORY_STORAGE', BX_DIRECTORY_PATH_ROOT . 'storage/');
 define('BX_DIRECTORY_STORAGE', BX_DIRECTORY_PATH_ROOT . 'storage/');
 
 
 //--- System settings ---//
 //--- System settings ---//
@@ -81,7 +82,6 @@ require_once(BX_DIRECTORY_PATH_CLASSES . 'BxDol.php');
 require_once(BX_DIRECTORY_PATH_INC . 'utils.inc.php');
 require_once(BX_DIRECTORY_PATH_INC . 'utils.inc.php');
 require_once(BX_DIRECTORY_PATH_INC . 'version.inc.php');
 require_once(BX_DIRECTORY_PATH_INC . 'version.inc.php');
 
 
-bx_import('BxDolConfig');
 bx_import('BxDolService');
 bx_import('BxDolService');
 bx_import('BxDolAlerts');
 bx_import('BxDolAlerts');
 bx_import('BxDolDb');
 bx_import('BxDolDb');

+ 1 - 1
inc/utils.inc.php

@@ -464,7 +464,7 @@ function echoDbgLog($mWhat, $sDesc = '', $sFileName = 'debug.log')
         $sDesc . "\n" .
         $sDesc . "\n" .
         print_r($mWhat, true) . "\n\n\n";
         print_r($mWhat, true) . "\n\n\n";
 
 
-    $rFile = fopen(BxDolConfig::getInstance()->get('path_dynamic', 'tmp') . $sFileName, 'a');
+    $rFile = fopen(BX_DIRECTORY_PATH_LOGS . $sFileName, 'a');
     fwrite($rFile, $sCont);
     fwrite($rFile, $sCont);
     fclose($rFile);
     fclose($rFile);
 }
 }

+ 0 - 2
template/scripts/BxBaseFunctions.php

@@ -304,8 +304,6 @@ class BxBaseFunctions extends BxDol implements iBxDolSingleton
      */
      */
     function getMainLogo()
     function getMainLogo()
     {
     {
-        bx_import('BxDolConfig');
-
         $sAlt = getParam('sys_site_logo_alt') ? getParam('sys_site_logo_alt') : getParam('site_title');
         $sAlt = getParam('sys_site_logo_alt') ? getParam('sys_site_logo_alt') : getParam('site_title');
         $sLogo = $sAlt;
         $sLogo = $sAlt;