Browse Source

#34 - LESS vars reorganization

Alex Trofimov 13 years ago
parent
commit
d5fba1595d

+ 7 - 0
inc/classes/BxDolTemplate.php

@@ -179,6 +179,8 @@ class BxDolTemplate extends BxDol implements iBxDolSingleton {
     protected $aPage;
     protected $aPageContent;
 
+    protected $_oConfigTemplate;
+
     /**
      * Constructor
      */
@@ -358,6 +360,9 @@ class BxDolTemplate extends BxDol implements iBxDolSingleton {
             $oCache->setData ($oDb->genDbCacheKey($this->_sInjectionsCache), $aInjections);
         }
         $this->aPage['injections'] = $aInjections;
+
+        bx_import('BxTemplConfig');
+        $this->_oConfigTemplate = BxTemplConfig::getInstance();
     }
 
     /**
@@ -1295,6 +1300,8 @@ class BxDolTemplate extends BxDol implements iBxDolSingleton {
     function _lessCss($mixed) {
     	require_once(BX_DIRECTORY_PATH_PLUGINS . 'lessphp/lessc.inc.php');
         $oLess = new lessc();
+        
+        $oLess->setVariables($this->_oConfigTemplate->aLessConfig);
 
     	if(is_array($mixed) && isset($mixed['url']) && isset($mixed['path'])) {
     		$sPathFile = realpath($mixed['path']);

+ 13 - 8
modules/boonex/uni/data/template/system/scripts/BxTemplConfig.php

@@ -1,16 +1,19 @@
-<?php
+<?php defined('BX_DOL') or die('hack attempt');
 /**
- * @package     Dolphin Core
- * @copyright   Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
- * @license     CC-BY - http://creativecommons.org/licenses/by/3.0/
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    DolphinCore Dolphin Core
+ * @{
  */
-defined('BX_DOL') or die('hack attempt');
 
 bx_import('BxBaseConfig');
 
-class BxTemplConfig extends BxBaseConfig {
-    function BxTemplConfig() {
-        parent::BxBaseConfig();
+class BxTemplConfig extends BxBaseConfig 
+{
+    function __construct() 
+    {
+        parent::__construct();
 
         bx_import('BxDolTemplate');
         $sCode = BxDolTemplate::getInstance()->getCode();
@@ -24,3 +27,5 @@ class BxTemplConfig extends BxBaseConfig {
         $oSysConfig->set('path_static', 'css', BX_DIRECTORY_PATH_ROOT . 'templates/tmpl_' . $sCode . '/css/');
     }
 }
+
+/** @} */

+ 0 - 1
template/css/_mixins.less

@@ -1,5 +1,4 @@
 
-@import "_vars.less";
 @import "_remixins.less";
 
 .radius(@val) {

+ 0 - 39
template/css/_vars.less

@@ -1,39 +0,0 @@
-
-@bx-margin: 20px;
-@bx-margin-sec: 10px;
-@bx-margin-thd: 5px;
-
-@bx-padding: 20px;
-@bx-padding-sec: 10px;
-@bx-padding-thd: 5px;
-
-@bx-font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
-
-@bx-size-avatar: 96px;
-@bx-size-thumb: 48px;
-@bx-size-icon: 32px;
-
-@bx-color-page: #fff;
-@bx-color-block: #fff;
-@bx-color-box: #fff;
-@bx-color-sec: #f2f2f2;
-@bx-color-hl: rgba(196, 248, 156, 0.2);
-@bx-color-active: rgba(196, 248, 156, 0.4);
-
-@bx-border-width: 1px;
-@bx-border-type: solid;
-@bx-border-color: #d0d0d0;
-
-@bx-font-size-default: 16px;
-@bx-font-size-small: 12px;
-@bx-font-size-middle: 14px;
-@bx-font-size-large: 18px;
-@bx-font-size-h1: 24px;
-@bx-font-size-h2: 20px;
-@bx-font-size-h3: 16px;
-
-@bx-font-color-default: #333;
-@bx-font-color-grayed: #999;
-@bx-font-color-contrasted: #fff;
-
-@bx-round-corners-radius: 3px;

+ 65 - 6
template/scripts/BxBaseConfig.php

@@ -9,21 +9,80 @@
 
 class BxBaseConfig extends BxDol implements iBxDolSingleton {
 
-    var $iTagsMinFontSize = 10;  // minimal font size of tag
-    var $iTagsMaxFontSize = 30; // maximal font size of tag
+    protected $_aConfig = array (
+        'iTagsMinFontSize' => 10, // minimal font size of tag
+        'iTagsMaxFontSize' => 30, // maximal font size of tag
+        'bAllowUnicodeInPreg' => false, // allow unicode in regular expressions
+        'aLessConfig' => array (
+			'bx-margin' => '20px',
+			'bx-margin-sec' => '10px',
+			'bx-margin-thd' => '5px',
 
-    var $bAllowUnicodeInPreg = false; // allow unicode in regular expressions
+			'bx-padding' => '20px',
+			'bx-padding-sec' => '10px',
+			'bx-padding-thd' => '5px',
 
-    function BxBaseConfig() {
-        parent::BxDol();
+			'bx-font-family' => '"Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif',
+
+			'bx-size-avatar' => '96px',
+			'bx-size-thumb' => '48px',
+			'bx-size-icon' => '32px',
+
+			'bx-color-page' => '#fff',
+			'bx-color-block' => '#fff',
+			'bx-color-box' => '#fff',
+			'bx-color-sec' => '#f2f2f2',
+			'bx-color-hl' => 'rgba(196, 248, 156, 0.2)',
+			'bx-color-active' => 'rgba(196, 248, 156, 0.4)',
+
+			'bx-border-width' => '1px',
+			'bx-border-type' => 'solid',
+			'bx-border-color' => '#d0d0d0',
+
+			'bx-font-size-default' => '16px',
+			'bx-font-size-small' => '12px',
+			'bx-font-size-middle' => '14px',
+			'bx-font-size-large' => '18px',
+			'bx-font-size-h1' => '24px',
+			'bx-font-size-h2' => '20px',
+			'bx-font-size-h3' => '16px',
+
+			'bx-font-color-default' => '#333',
+			'bx-font-color-grayed' => '#999',
+			'bx-font-color-contrasted' => '#fff',
+
+			'bx-round-corners-radius' => '3px',
+        ),
+    );
+
+    function __construct() 
+    {
+        parent::__construct();
     }
 
-    public static function getInstance() {
+    public static function getInstance() 
+    {
         if(!isset($GLOBALS['bxDolClasses'][__CLASS__]))
             $GLOBALS['bxDolClasses'][__CLASS__] = new BxTemplConfig();
 
         return $GLOBALS['bxDolClasses'][__CLASS__];
     }
+
+    public function __get($sName)
+    {
+        if (array_key_exists($sName, $this->_aConfig))
+            return $this->_aConfig[$sName];
+
+        trigger_error('Undefined property "' . $aName . '" in ' . get_class($this), E_USER_ERROR);
+
+        return null;
+    }
+
+    public function __isset($sName)
+    {
+        return isset($this->_aConfig[$sName]);
+    }
+
 }
 
 /** @} */