HomeHelpTrac

Changeset 9759


Ignore:
Timestamp:
03/23/09 05:32:02 (3 years ago)
Author:
Anton Lesnikov
Message:

Improvements for BxDolTemplate?

  1. CSS cache
  2. methods to add CSS files into head section
  3. methods to modify page's info(title, description, etc)
  4. <bx_text:_language_key />
  5. Fix for template cache

Necessary changes in Wall, News, Feedback modules and some common files.

Location:
trunk
Files:
1 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/inc/classes/BxDolAdminTools.php

    r9391 r9759  
    5353            'backup', 
    5454            'cache', 
     55            'cache_public', 
    5556            'inc', 
    5657            'langs', 
  • trunk/inc/classes/BxDolTemplate.php

    r9757 r9759  
    3232 
    3333class BxDolTemplate extends BxDolMistake { 
    34     var $_sCode; 
    35     var $_sPageWidth; 
     34    /** 
     35     * Main fields 
     36     */ 
     37    var $_sCode;     
    3638    var $_sKeyWrapperHtml; 
    3739    var $_aLocations; 
     
    4143    var $_sFolderIcons; 
    4244    var $_aTemplates; 
     45     
     46    /** 
     47     * Cache related fields 
     48     */ 
    4349    var $_bCacheEnable; 
    44     var $_sCacheFolder; 
     50    var $_sCacheFolderUrl; 
     51    var $_sCacheFolderPath; 
     52    var $_sCachePublicFolderUrl; 
     53    var $_sCachePublicFolderPath; 
    4554    var $_sCacheFilePrefix; 
    46     var $_sCacheTable; 
    47      
     55    var $_bCssCollect; 
     56    var $_bCssArchive; 
     57    var $_sCssCachePrefix; 
     58 
    4859    /** 
    4960     * Constructor 
     
    5263        parent::BxDolMistake(); 
    5364         
    54         $this->_sCode = isset($_COOKIE['skin']) ? $_COOKIE['skin'] : BX_DOL_TEMPLATE_DEFAULT_CODE; 
    55         $this->_sPageWidth = getParam('main_div_width'); 
     65        $this->_sCode = isset($_COOKIE['skin']) ? $_COOKIE['skin'] : BX_DOL_TEMPLATE_DEFAULT_CODE;       
    5666        $this->_sKeyWrapperHtml = '__'; 
    5767        $this->_sFolderHtml = ''; 
     
    5969        $this->_sFolderImages = 'images/'; 
    6070        $this->_sFolderIcons = 'images/icons/'; 
    61          
     71        $this->_aTemplates = array(); 
     72 
    6273        $this->addLocation('system', BX_DIRECTORY_PATH_ROOT, BX_DOL_URL_ROOT); 
    6374         
    64         $this->_aTemplates = array(); 
     75        $this->_bCacheEnable = true; 
     76        $this->_sCacheFolderUrl = BX_DOL_URL_CACHE; 
     77        $this->_sCacheFolderPath = BX_DIRECTORY_PATH_CACHE; 
     78        $this->_sCachePublicFolderUrl = BX_DOL_URL_CACHE_PUBLIC; 
     79        $this->_sCachePublicFolderPath = BX_DIRECTORY_PATH_CACHE_PUBLIC; 
     80        $this->_sCacheFilePrefix = "bx_templ_"; 
    6581         
    66         $this->_bCacheEnable = false; 
    67         $this->_sCacheFolder = BX_DIRECTORY_PATH_CACHE; 
    68         $this->_sCacheFilePrefix = "bx_templ_"; 
    69         $this->_sCacheTable = "BxDolTemplateCache"; 
     82        $this->_bCssCache = true; 
     83        $this->_bCssArchive = $this->_bCssCollect && false; 
     84        $this->_sCssCachePrefix = $this->_sCacheFilePrefix . 'css_'; 
    7085    } 
    7186    /** 
     
    8196    /** 
    8297     * Initialize template engine. 
    83      * Note. The method is executed with the system, you shouldn't execute it in your subclass. 
     98     * Note. The method is executed with the system, you shouldn't execute it in your subclasses. 
    8499     */ 
    85100    function init() { 
     
    112127         
    113128        $GLOBALS['BxDolTemplateInjections'] = $aInjections; 
     129         
     130        //--- Load page elements related static variables ---//          
     131        $GLOBALS['oSysTemplatePageWidth'] = getParam('main_div_width'); 
     132        $GLOBALS['oSysTemplatePageTitle'] = '';              
     133        $GLOBALS['oSysTemplatePageKeywords'] = array(); 
     134        $GLOBALS['oSysTemplatePageDescription']  = ''; 
     135        $GLOBALS['oSysTemplatePageMainBoxTitle'] = ''; 
    114136    } 
    115137    /** 
     
    164186     */ 
    165187    function getPageWidth() { 
    166         return $this->_sPageWidth; 
     188        return $GLOBALS['oSysTemplatePageWidth']; 
    167189    } 
    168190    /** 
     
    172194     */ 
    173195    function setPageWidth($sWidth) { 
    174         $this->_sPageWidth = $sWidth; 
    175     } 
     196        $GLOBALS['oSysTemplatePageWidth'] = $sWidth; 
     197    } 
     198    function setPageTitle($sTitle) { 
     199        $GLOBALS['oSysTemplatePageTitle'] = $sTitle; 
     200    } 
     201    function setPageMainBoxTitle($sTitle) { 
     202        $GLOBALS['oSysTemplatePageMainBoxTitle'] = $sTitle; 
     203    } 
     204    function setPageDescription($sDescription) { 
     205        $GLOBALS['oSysTemplatePageDescription'] = $sDescription; 
     206    } 
     207    function addPageKeywords($mixedKeywords) { 
     208        if(is_string($mixedKeywords)) 
     209            $mixedKeywords = strpos($mixedKeywords, ',') !== false ? explode(',', $mixedKeywords) : array($mixedKeywords); 
     210 
     211        foreach($mixedKeywords as $iKey => $sValue) 
     212            $mixedKeywords[$iKey] = trim($sValue); 
     213 
     214        $GLOBALS['oSysTemplatePageKeywords'] = array_merge($GLOBALS['oSysTemplatePageKeywords'], $mixedKeywords); 
     215    }    
    176216    /** 
    177217     * Get template, which was loaded earlier.  
     
    190230     * @return string full URL. 
    191231     */ 
    192     function getIconUrl($sName) { 
    193         return $this->_getAbsoluteLocation('url', $this->_sFolderIcons, $sName); 
     232    function getIconUrl($sName, $sCheckIn = BX_DOL_TEMPLATE_CHECK_IN_BOTH) { 
     233        return $this->_getAbsoluteLocation('url', $this->_sFolderIcons, $sName, $sCheckIn); 
    194234    } 
    195235    /** 
     
    199239     * @return string absolute path. 
    200240     */ 
    201     function getIconPath($sName) { 
    202         return $this->_getAbsoluteLocation('path', $this->_sFolderIcons, $sName); 
     241    function getIconPath($sName, $sCheckIn = BX_DOL_TEMPLATE_CHECK_IN_BOTH) { 
     242        return $this->_getAbsoluteLocation('path', $this->_sFolderIcons, $sName, $sCheckIn); 
    203243    } 
    204244    /** 
     
    208248     * @return string full URL. 
    209249     */ 
    210     function getImageUrl($sName) { 
    211         return $this->_getAbsoluteLocation('url', $this->_sFolderImages, $sName); 
     250    function getImageUrl($sName, $sCheckIn = BX_DOL_TEMPLATE_CHECK_IN_BOTH) { 
     251        return $this->_getAbsoluteLocation('url', $this->_sFolderImages, $sName, $sCheckIn); 
    212252    } 
    213253    /** 
     
    217257     * @return string absolute path. 
    218258     */ 
    219     function getImagePath($sName) { 
    220         return $this->_getAbsoluteLocation('path', $this->_sFolderImages, $sName); 
     259    function getImagePath($sName, $sCheckIn = BX_DOL_TEMPLATE_CHECK_IN_BOTH) { 
     260        return $this->_getAbsoluteLocation('path', $this->_sFolderImages, $sName, $sCheckIn); 
    221261    } 
    222262    /** 
     
    226266     * @return string full URL. 
    227267     */ 
    228     function getCssUrl($sName) {         
    229         return $this->_getAbsoluteLocation('url', $this->_sFolderCss, $sName); 
     268    function getCssUrl($sName, $sCheckIn = BX_DOL_TEMPLATE_CHECK_IN_BOTH) {      
     269        return $this->_getAbsoluteLocation('url', $this->_sFolderCss, $sName, $sCheckIn); 
     270    } 
     271    /** 
     272     * Get full Path of CSS file. 
     273     * 
     274     * @param string $sName - CSS file name. 
     275     * @return string full URL. 
     276     */ 
     277    function getCssPath($sName, $sCheckIn = BX_DOL_TEMPLATE_CHECK_IN_BOTH) {         
     278        return $this->_getAbsoluteLocation('path', $this->_sFolderCss, $sName, $sCheckIn); 
    230279    } 
    231280    /** 
     
    314363     * @return string value associated with the key. 
    315364     */ 
    316     function parseSystemKey($sKey) { 
     365    function parseSystemKey($sKey, $mixedKeyWrapperHtml = null) { 
    317366        global $site;                
    318367        global $_page; 
    319368        global $oFunctions; 
    320         global $oTemplConfig;        
     369        global $oTemplConfig; 
     370         
     371        $aKeyWrappers = $this->_getKeyWrappers($mixedKeyWrapperHtml); 
    321372 
    322373        $sRet = ''; 
    323374        switch( $sKey ) { 
    324             case 'page_charset': 
     375            case 'include_css':              
     376                $this->addCss($_page['css_name']); 
     377                $sRet = $this->includeCss(); 
     378                break; 
     379            case 'page_charset': 
    325380                $sRet = 'UTF-8';  
    326381                break; 
     382            case 'page_keywords': 
     383                if(!empty($GLOBALS['oSysTemplatePageKeywords']) && is_array($GLOBALS['oSysTemplatePageKeywords'])) 
     384                    $sRet = '<meta name="keywords" content="' . process_line_output(implode(',', $GLOBALS['oSysTemplatePageKeywords'])) . '" />'; 
     385                break; 
     386            case 'page_description':                 
     387                if(!empty($GLOBALS['oSysTemplatePageDescription']) && is_string($GLOBALS['oSysTemplatePageDescription'])) 
     388                    $sRet = '<meta name="description" content="' . process_line_output($GLOBALS['oSysTemplatePageDescription']) . '" />'; 
     389                break; 
     390            case 'page_header':                 
     391                if(!empty($GLOBALS['oSysTemplatePageTitle'])) 
     392                    $sRet = process_line_output($GLOBALS['oSysTemplatePageTitle']); 
     393                break; 
     394            case 'page_header_text': 
     395                if(!empty($GLOBALS['oSysTemplatePageMainBoxTitle'])) 
     396                    $sRet = process_line_output($GLOBALS['oSysTemplatePageMainBoxTitle']); 
     397                break; 
     398            case 'main_div_width':                 
     399                if(!empty($GLOBALS['oSysTemplatePageWidth'])) 
     400                    $sRet = process_line_output($GLOBALS['oSysTemplatePageWidth']); 
     401                break; 
     402                 
     403 
     404                 
    327405            case 'site_url': 
    328406                $sRet = BX_DOL_URL_ROOT; 
     
    334412                $sRet = $site['images']; 
    335413                break; 
     414/* 
    336415            case 'css_dir': 
    337416                $sRet = $site['css_dir']; 
    338417                break; 
     418*/ 
    339419            case 'base_menu_dir': 
    340420                $sRet = "templates/base/menu/"; 
     
    348428            case 'zodiac': 
    349429                $sRet = $site['zodiac']; 
    350                 break; 
    351             case 'switch_lang_block':  
    352                 $sRet = getLangSwitcher(); 
    353                 break; 
     430                break;           
    354431            case 'main_logo': 
    355432                $sRet = getMainLogo(); 
     
    368445            case 'thumb_height': 
    369446                $sRet = getParam('max_thumb_height'); 
    370                 break; 
    371             case 'main_div_width': 
    372                 $sRet = $this->getPageWidth(); 
    373                 break; 
     447                break;           
     448            case 'switch_lang_block':  
     449                $sRet = getLangSwitcher(); 
     450                break; 
    374451            case 'switch_skin_block': 
    375452                $sRet = getParam("enable_template") ? templates_select_txt() : '';  
     
    381458                $sRet = getDolLangCode(); 
    382459                break; 
    383             case 'meta_keywords': 
    384                 $sMetaKeyWord = process_line_output( getParam("MetaKeyWords") ); 
    385                 if ($sMetaKeyWord != '' && strrchr($_SERVER['PHP_SELF'], '/') == '/index.php') 
    386                     $sRet = '<meta name="keywords" content="' . $sMetaKeyWord . '" />'; 
    387             break; 
    388             case 'meta_description': 
    389                 $sMetaDescription = process_line_output( getParam("MetaDescription") ); 
    390                 if ($sMetaDescription != '' && strrchr($_SERVER['PHP_SELF'], '/') == '/index.php') 
    391                     $sRet = '<meta name="description" content="'. $sMetaDescription . '" />'; 
    392             break;           
    393460            case 'top_menu': 
    394461                $sRet = $GLOBALS['oTopMenu'] -> getCode(); 
     
    396463            case 'extra_js':          
    397464                $sRet = $_page['extra_js']; 
    398                 break; 
     465                break;  
     466            /* 
    399467            case 'extra_css': 
    400468                $sRet = $_page['extra_css']; 
    401469                break; 
    402             case 'page_header': 
    403                 $sRet = $_page['header']; 
    404                 break; 
    405             case 'page_header_text': 
    406                 $sRet = $_page['header_text']; 
    407                 break; 
     470            case 'styles': 
     471                $sRet = $this->processStyles($_page['css_name']); 
     472                break; 
     473            */ 
     474             
    408475            case 'banner_top': 
    409476                $sRet = banner_put_nv(1); 
     
    424491                $sRet = _t( '_copyright',   date('Y') ) . getVersionComment();  
    425492                break; 
    426             case 'styles': 
    427                 $sRet = $this->processStyles($_page['css_name']); 
    428                 break; 
    429493            case 'java_script': 
    430494                if( strlen( $_page['js_name'] ) ) { 
     
    474538                break; 
    475539            default: 
    476                 $sRet = ($sTemplAdd = $oFunctions->TemplPageAddComponent($sKey)) !== false ? $sTemplAdd : '__' . $sKey . '__'; 
     540                $sRet = ($sTemplAdd = $oFunctions->TemplPageAddComponent($sKey)) !== false ? $sTemplAdd : $aKeyWrappers['left'] . $sKey . $aKeyWrappers['right']; 
    477541            } 
    478542 
     
    498562 
    499563        $sCacheVariableName = "a"; 
    500         $sCacheAbsolutePath = $this->_sCacheFolder . $this->_getCacheFileName($sAbsolutePath) . '.php'; 
     564        $sCacheAbsolutePath = $this->_sCacheFolderPath . $this->_getCacheFileName('html', $sAbsolutePath) . '.php'; 
    501565 
    502566        $mixedWriteResult = false; 
    503567        $bExists = file_exists($sCacheAbsolutePath); 
    504         if(!$bExists && ($rHandler = fopen($sCacheAbsolutePath, 'w')) && ($sContent = file_get_contents($sAbsolutePath))) { 
    505             $mixedWriteResult = fwrite($rHandler, $this->_compileContent($sContent, "\$" . $sCacheVariableName, 1, $aVariables, $mixedKeyWrapperHtml)); 
    506             fclose($rHandler); 
    507         } 
     568        if(!$bExists && ($sContent = file_get_contents($sAbsolutePath)) !== false && ($sContent = $this->_compileContent($sContent, "\$" . $sCacheVariableName, 1, $aVariables, $mixedKeyWrapperHtml)) !== false) 
     569            if(($rHandler = fopen($sCacheAbsolutePath, 'w')) !== false) { 
     570                $mixedWriteResult = fwrite($rHandler, $sContent); 
     571                fclose($rHandler); 
     572            } 
    508573 
    509574        if($bExists || (!$bExists && $mixedWriteResult !== false)) { 
     
    519584 
    520585        return false; 
    521     } 
    522      
    523     /** 
    524      * Conver incomming CSS file/s into HTML representation. 
    525      * 
    526      * @param mixed $mixedFiles - single file name or array of file names. 
    527      * @return string the result of operation. 
    528      */ 
    529     function processStyles($mixedFiles) { 
    530         if(empty($mixedFiles)) return ''; 
    531  
    532         if(is_array($mixedFiles)) { 
    533             $sReturn = ''; 
    534             foreach ($mixedFiles as $sFile) 
    535                 $sReturn .= $this->_wrapInCssTag($sFile); 
    536         } 
    537         else if(is_string($mixedFiles)) 
    538            $sReturn = $this->_wrapInCssTag($mixedFiles); 
    539  
    540         return $sReturn; 
    541     } 
    542     /** 
    543      * Include CSS file(s) in head section of current page. 
    544      * 
    545      * @param  mixed $mixedFiles - single file name or array of file names. 
    546      */ 
    547     function includeStyles($mixedFiles) { 
    548         $sCss = $this->processStyles($mixedFiles); 
    549  
    550         BxDolTemplate::addInjection('styles', 'text', $sCss, 0); 
     586    }     
     587    function addCss($mixedFiles){ 
     588        return $this->_processCss('add', $mixedFiles); 
     589    } 
     590    function deleteCss($mixedFiles){ 
     591        return $this->_processCss('delete', $mixedFiles); 
     592    } 
     593    /** 
     594     * Include CSS file(s) attached to the page in its head section. 
     595     * @see the method is system and would be called automatically. 
     596     *  
     597     * @return string the result CSS code. 
     598     */ 
     599    function includeCss() { 
     600        $aFiles = isset($GLOBALS['BxDolTemplateCss']) ? $GLOBALS['BxDolTemplateCss'] : array(); 
     601        if(empty($aFiles) || !is_array($aFiles)) 
     602            return ""; 
     603 
     604        if(!$this->_bCssCache)  
     605            return $this->_includeCss($aFiles); 
     606 
     607        //--- If cache already exists, return it ---// 
     608        ksort($aFiles); 
     609         
     610        $sName = ""; 
     611        foreach($aFiles as $aFile) 
     612            $sName .= $aFile['url']; 
     613        $sName = $this->_getCacheFileName('css', $sName); 
     614 
     615        $sCacheAbsoluteUrl = $this->_sCachePublicFolderUrl . $sName . '.css'; 
     616        $sCacheAbsolutePath = $this->_sCachePublicFolderPath . $sName . '.css';      
     617        if(file_exists($sCacheAbsolutePath)) 
     618           return $this->_wrapInCssTag($sCacheAbsoluteUrl); 
     619                 
     620        //--- Collect all attached CSS in one file ---// 
     621        $sResult = ""; 
     622        foreach($aFiles as $aFile) { 
     623            $aIncluded = array(); 
     624            $aFileInfo = pathinfo($aFile['path']); 
     625            if(($sContent = $this->_compileCss($aFileInfo['dirname'] . '/', $aFileInfo['basename'], $aIncluded)) !== false) 
     626                $sResult .= $sContent; 
     627        } 
     628         
     629        $mixedWriteResult = false; 
     630        if(!empty($sResult) && ($rHandler = fopen($sCacheAbsolutePath, 'w')) !== false) { 
     631            $mixedWriteResult = fwrite($rHandler, $sResult); 
     632            fclose($rHandler); 
     633        } 
     634         
     635        if($mixedWriteResult === false) 
     636            return $this->_includeCss($aFiles); 
     637 
     638        //--- Archive the file if it's needed ---// 
     639        if($this->_bCssArchive) { 
     640            //TODO: process archiving. 
     641        }    
     642 
     643        return $this->_wrapInCssTag($sCacheAbsoluteUrl); 
     644    } 
     645    /** 
     646     * Compile CSS files' structure(@see @import css_file_path) in one file. 
     647     * 
     648     * @param unknown_type $aFile 
     649     * @return unknown 
     650     */ 
     651    function _compileCss($sPath, $sName, &$aIncluded) { 
     652        if(isset($aIncluded[$sPath . '_' . $sName])) 
     653           return ''; 
     654 
     655        $sContent = file_get_contents($sPath . $sName); 
     656        if(empty($sContent)) 
     657            return ''; 
     658 
     659        $aIncluded[$sPath . '_' . $sName] = 1; 
     660         
     661        $aSearch = array( 
     662            "'@import\s+url\s*\(\s*([a-zA-Z0-9\.\/_-]+)\s*\)\s*;'e", 
     663            "'background-image\s*:\s*url\s*\(\s*([a-zA-Z0-9\.\/_-]+)\s*\)\s*;'e", 
     664        ); 
     665        $aReplace = array( 
     666            "\$this->_compileCss(realpath(\$sPath . dirname('\\1')) . '/', basename('\\1'), \$aIncluded)", 
     667            "'background-image:url(' . str_replace(BX_DIRECTORY_PATH_ROOT, BX_DOL_URL_ROOT, realpath(\$sPath . dirname('\\1')) . '/' . basename('\\1')) . ');'" 
     668        ); 
     669        $sContent = preg_replace($aSearch, $aReplace, $sContent); 
     670        return $sContent;         
     671    } 
     672    /** 
     673     * Include CSS files without caching. 
     674     * 
     675     * @param unknown_type $aFiles 
     676     * @return unknown 
     677     */ 
     678    function _includeCss(&$aFiles) { 
     679        $sResult = ""; 
     680        foreach($aFiles as $aFile) 
     681           $sResult .= $this->_wrapInCssTag($aFile['url']); 
     682 
     683        return $sResult; 
     684    } 
     685    /** 
     686     * Insert/Delete CSS file from output stack. 
     687     * 
     688     * @param unknown_type $sAction 
     689     * @param unknown_type $mixedFiles 
     690     * @return unknown 
     691     */ 
     692    function _processCss($sAction, $mixedFiles) { 
     693        if(empty($mixedFiles)) 
     694            return false; 
     695 
     696        if(is_string($mixedFiles)) 
     697            $mixedFiles = array($mixedFiles); 
     698 
     699        foreach($mixedFiles as $sFile) { 
     700            $sUrl = $this->getCssUrl($sFile); 
     701            $sPath = $this->getCssPath($sFile); 
     702 
     703            if($sAction == 'add') 
     704                $GLOBALS['BxDolTemplateCss'][] = array('url' => $sUrl, 'path' => $sPath); 
     705            else if($sAction == 'delete') 
     706                foreach($GLOBALS['BxDolTemplateCss']  as $iKey => $aValue) 
     707                    if($aValue['url'] == $sUrl) { 
     708                        unset($GLOBALS['BxDolTemplateCss'][$iKey]); 
     709                        break; 
     710                    } 
     711        } 
     712         
     713        return true; 
    551714    } 
    552715     
     
    605768            "'<bx_include_base:([^\s]+) \/>'se", 
    606769            "'<bx_image_url:([^\s]+) \/>'se", 
    607             "'<bx_icon_url:([^\s]+) \/>'se" 
     770            "'<bx_icon_url:([^\s]+) \/>'se", 
     771            "'<bx_text:([^\s]+) \/>'se" 
    608772        )); 
    609773        $aValues = array_merge($aValues, array( 
     
    611775            "\$this->parseHtmlByName('\\1', \$aVariables, \$mixedKeyWrapperHtml, BX_DOL_TEMPLATE_CHECK_IN_BASE)", 
    612776            "\$this->getImageUrl('\\1')", 
    613             "\$this->getIconUrl('\\1')" 
     777            "\$this->getIconUrl('\\1')", 
     778            "_t('\\1')" 
    614779        )); 
    615780 
     
    617782        $sContent = preg_replace($aKeys, $aValues, $sContent); 
    618783        //--- Parse System Keys ---// 
    619         $sContent = preg_replace( "'" . $aKeyWrappers['left'] . "([a-zA-Z0-9_-]+)" . $aKeyWrappers['right'] . "'e", "\$this->parseSystemKey('\\1')", $sContent); 
     784        $sContent = preg_replace( "'" . $aKeyWrappers['left'] . "([a-zA-Z0-9_-]+)" . $aKeyWrappers['right'] . "'e", "\$this->parseSystemKey('\\1', \$mixedKeyWrapperHtml)", $sContent); 
    620785 
    621786        return $sContent; 
     
    647812                $sValue = ''; 
    648813                if(isset($aMatches[1]) && !empty($aMatches[1])) { 
    649                     if(is_array($aValues[$i])) { 
    650                         $sIndex = "\$" . str_repeat("i", $iVarDepth); 
    651                         $sValue .= "<? for(" . $sIndex . "=0; " . $sIndex . "<count(" . $aVarName . "['" . $aKeys[$i] . "']); " . $sIndex . "++){ ?>"; 
    652                         $sValue .= $this->_compileContent($aMatches[1], $aVarName . "['" . $aKeys[$i] . "'][" . $sIndex . "]", ++$iVarDepth, current($aValues[$i]), $mixedKeyWrapperHtml); 
    653                         $sValue .= "<?}?>"; 
    654                     } 
    655                     else if(is_string($aValues[$i])) 
    656                         $sValue .= $aValues[$i]; 
     814                    if(empty($aValues[$i]) || !is_array($aValues[$i])) 
     815                        return false; 
     816 
     817                    $sIndex = "\$" . str_repeat("i", $iVarDepth);                     
     818                    $sValue .= "<? if(is_array(" . $aVarName . "['" . $aKeys[$i] . "'])) for(" . $sIndex . "=0; " . $sIndex . "<count(" . $aVarName . "['" . $aKeys[$i] . "']); " . $sIndex . "++){ ?>"; 
     819                    if(($sInnerValue = $this->_compileContent($aMatches[1], $aVarName . "['" . $aKeys[$i] . "'][" . $sIndex . "]", ++$iVarDepth, current($aValues[$i]), $mixedKeyWrapperHtml)) === false) 
     820                        return false; 
     821                    $sValue .= $sInnerValue; 
     822                    $sValue .= "<?} else if(is_string(" . $aVarName . "['" . $aKeys[$i] . "'])) echo " . $aVarName . "['" . $aKeys[$i] . "']; ?>"; 
    657823                } 
    658824            } 
     
    665831                $sValue = ''; 
    666832                if(isset($aMatches[1]) && !empty($aMatches[1]) && is_array($aValues[$i]) && isset($aValues[$i]['condition']) && isset($aValues[$i]['content'])) { 
     833                    if(empty($aValues[$i]['content']) || !is_array($aValues[$i]['content'])) 
     834                        return false; 
     835 
    667836                    $sValue .= "<? if(" . $aVarName . "['" . $aKeys[$i] . "']['condition']){ ?>"; 
    668                     $sValue .= $this->_compileContent($aMatches[1], $aVarName . "['" . $aKeys[$i] . "']['content']", $iVarDepth, $aValues[$i]['content'], $mixedKeyWrapperHtml); 
     837                    if(($sInnerValue = $this->_compileContent($aMatches[1], $aVarName . "['" . $aKeys[$i] . "']['content']", $iVarDepth, $aValues[$i]['content'], $mixedKeyWrapperHtml)) === false) 
     838                        return false; 
     839                    $sValue .= $sInnerValue; 
    669840                    $sValue .= "<?}?>"; 
    670841                } 
     
    683854            "'<bx_include_tmpl:([^\s]+) \/>'se",             
    684855            "'<bx_image_url:([^\s]+) \/>'se", 
    685             "'<bx_icon_url:([^\s]+) \/>'se" 
     856            "'<bx_icon_url:([^\s]+) \/>'se", 
     857            "'<bx_text:([^\s]+) \/>'se" 
    686858        )); 
    687859        $aValues = array_merge($aValues, array( 
     
    689861            "\$this->getCached('\\1', \$aVarValues, BX_DOL_TEMPLATE_CHECK_IN_TMPL, false)", 
    690862            "\$this->getImageUrl('\\1')", 
    691             "\$this->getIconUrl('\\1')" 
     863            "\$this->getIconUrl('\\1')", 
     864            "_t('\\1')" 
    692865        )); 
    693866 
     
    695868        $sContent = preg_replace($aKeys, $aValues, $sContent); 
    696869        //--- Parse System Keys ---// 
    697         $sContent = preg_replace( "'" . $aKeyWrappers['left'] . "([a-zA-Z0-9_-]+)" . $aKeyWrappers['right'] . "'", "<?=\$this->parseSystemKey('\\1');?>", $sContent); 
     870        $sContent = preg_replace( "'" . $aKeyWrappers['left'] . "([a-zA-Z0-9_-]+)" . $aKeyWrappers['right'] . "'", "<?=\$this->parseSystemKey('\\1', \$mixedKeyWrapperHtml);?>", $sContent); 
    698871 
    699872        return $sContent; 
     
    753926     */ 
    754927    function _wrapInCssTag($sFile) { 
    755         return '<link href="' . $this->getCssUrl($sFile) . '" rel="stylesheet" type="text/css" />'; 
     928        return '<link href="' . $sFile . '" rel="stylesheet" type="text/css" />'; 
    756929    } 
    757930    /** 
     
    771944     * @return string the result of operation. 
    772945     */ 
    773     function _getCacheFileName($sAbsolutePath) { 
    774         return  $this->_sCacheFilePrefix . str_replace(array(BX_DIRECTORY_PATH_ROOT, '/'), array('', '_'), $sAbsolutePath); 
     946    function _getCacheFileName($sType, $sAbsolutePath) { 
     947        $sResult = ""; 
     948        switch($sType) { 
     949            case 'html': 
     950                $sResult = $this->_sCacheFilePrefix . str_replace(array(BX_DIRECTORY_PATH_ROOT, '/'), array('', '_'), $sAbsolutePath); 
     951                break; 
     952            case 'css': 
     953                $sResult = $this->_sCssCachePrefix . md5($sAbsolutePath); 
     954                break; 
     955            case 'js': 
     956                $sResult = ""; 
     957                break; 
     958        } 
     959 
     960        return $sResult; 
    775961    } 
    776962     
  • trunk/inc/params.inc.php

    r9395 r9759  
    2626$oSysTemplate = new BxDolTemplate(); 
    2727$oSysTemplate->init(); 
     28$oSysTemplate->addCss(array('general.css', 'anchor.css')); 
    2829 
    2930/** 
  • trunk/index.php

    r9105 r9759  
    6161 
    6262$_page['name_index']    = 1; 
    63 $_page['header']        = $site['title']; 
    64 $_page['header_text']   = $site['title']; 
    65 $_page['css_name']      = 'index.css'; 
     63 
     64$oSysTemplate->setPageTitle($site['title']); 
     65$oSysTemplate->setPageDescription(getParam("MetaDescription")); 
     66$oSysTemplate->setPageMainBoxTitle($site['title']); 
     67$oSysTemplate->addPageKeywords(getParam("MetaKeyWords")); 
     68$oSysTemplate->addCss('index.css'); 
    6669 
    6770$oIPV = new BxTemplIndexPageView(); 
  • trunk/install/index.php

    r9593 r9759  
    121121define('BX_DOL_URL_PROFILE_BACKGROUNDS', \$site['profileBackground']); 
    122122define('BX_DOL_URL_MODULES', \$site['url'] . 'modules/' ); 
     123define('BX_DOL_URL_CACHE_PUBLIC', \$site['url'] . 'cache_public/'); 
    123124 
    124125define('BX_DIRECTORY_PATH_INC', \$dir['inc']); 
     
    130131define('BX_DIRECTORY_PATH_DBCACHE', \$dir['cache']); 
    131132define('BX_DIRECTORY_PATH_MODULES', \$dir['root'] . 'modules/' ); 
     133define('BX_DIRECTORY_PATH_CACHE_PUBLIC', \$dir['root'] . 'cache_public/' ); 
    132134 
    133135define('DATABASE_HOST', \$db['host']); 
  • trunk/modules/boonex/feedback/classes/BxFdbTemplate.php

    r9506 r9759  
    5959        ); 
    6060        $aResult = array( 
     61            'include_css' => $this->_processCss('add', array('view.css', 'cmts.css')), 
    6162            'filter' => $oSearchResult->showAdminFilterPanel($aParams['filter_value'], 'feedback-filter-txt', 'feedback-filter-chb', 'feedback-filter'), 
    6263            'content' => $this->displayList($aParams), 
     
    6465        ); 
    6566        $aResult = array_merge($aResult, $this->_getViewJs()); 
    66         $aResult = array_merge($aResult, $this->_getViewCss()); 
    6767                 
    6868        return $this->parseHtmlByName('admin.html', $aResult); 
     
    7373        ); 
    7474        $aResult = array_merge($aResult, $this->_getViewJs()); 
    75         $aResult = array_merge($aResult, $this->_getViewCss()); 
    76                  
     75 
     76        $this->addCss(array('view.css', 'cmts.css')); 
    7777        return $this->parseHtmlByName('view.html', $aResult); 
    7878    } 
     
    177177        ); 
    178178    } 
    179     /** 
    180      * Prepare CSS paramaters. 
    181      */ 
    182     function _getViewCss() { 
    183         return array( 
    184            'include_css' => $this->processStyles(array('view.css', 'cmts.css', 'forms_adv.css')) 
    185         ); 
    186     } 
    187179} 
    188180?> 
  • trunk/modules/boonex/news/classes/BxNewsTemplate.php

    r9408 r9759  
    6363        ); 
    6464        $aResult = array( 
     65            'include_css' => $this->_processCss('add', array('view.css', 'cmts.css')), 
    6566            'filter' => $oSearchResult->showAdminFilterPanel($aParams['filter_value'], 'news-filter-txt', 'news-filter-chb', 'news-filter'), 
    6667            'content' => $this->displayList($aParams), 
     
    6869        ); 
    6970        $aResult = array_merge($aResult, $this->_getViewJs()); 
    70         $aResult = array_merge($aResult, $this->_getViewCss()); 
    7171                 
    7272        return $this->parseHtmlByName('admin.html', $aResult); 
     
    7777        ); 
    7878        $aResult = array_merge($aResult, $this->_getViewJs()); 
    79         $aResult = array_merge($aResult, $this->_getViewCss()); 
    80                  
     79         
     80        $this->addCss(array('view.css', 'cmts.css')); 
    8181        return $this->parseHtmlByName('view.html', $aResult); 
    8282    } 
     
    177177        ); 
    178178    } 
    179     /** 
    180      * Prepare CSS paramaters. 
    181      */ 
    182     function _getViewCss() { 
    183         return array( 
    184            'include_css' => $this->processStyles(array('view.css', 'cmts.css')) 
    185         ); 
    186     } 
    187179} 
    188180?> 
  • trunk/modules/boonex/news/templates/base/view.html

    r9408 r9759  
    1 __include_css__ 
    21<div class="news-view"> 
    32    <script language="javascript" type="text/javascript" src="__include_js_url__"></script> 
  • trunk/modules/boonex/wall/classes/BxWallModule.php

    r9682 r9759  
    298298        );                 
    299299         
    300         $this->_oTemplate->includeStyles('post.css'); 
     300        $this->_oTemplate->addCss('post.css'); 
    301301        $sRes = array($this->_oTemplate->parseHtmlByName('post.html', $aVariables), $aTopMenu, array(), true, 'getBlockCaptionMenu'); 
    302302        return $sRes; 
     
    346346        ); 
    347347 
    348         $this->_oTemplate->includeStyles('view.css'); 
     348        $this->_oTemplate->addCss('view.css'); 
    349349        return array($this->_oTemplate->parseHtmlByName('view.html', $aVariables), $aTopMenu, array(), true, 'getBlockCaptionMenu'); 
    350350    } 
  • trunk/modules/boonex/wall/templates/base/css/post.css

    r9635 r9759  
    1 div.wall-post {     
     1div.wall-post { 
    22    position: relative; 
    33} 
  • trunk/profile.php

    r9642 r9759  
    6666$oProfile = new BxBaseProfileGenerator( $profileID ); 
    6767 
     68$oProfile->oCmtsView->getExtraCss(); 
     69 
    6870$_page['extra_js']  = 
    6971    $oTemplConfig -> sTinyMceEditorMiniJS . 
     
    7274    '<script type="text/javascript">urlIconLoading = "'.getTemplateIcon('loading.gif').'";</script>'; 
    7375 
    74 $_page['extra_css'] = $oProfile -> genProfileCSS( $profileID ) . $oProfile->oCmtsView->getExtraCss(); 
     76$_page['extra_css'] = $oProfile -> genProfileCSS( $profileID ); 
    7577$p_arr              = $oProfile -> _aProfile; 
    7678 
  • trunk/templates/base/_header.html

    r9757 r9759  
    55    <base href="__site_url__" /> 
    66    <meta http-equiv="Content-Type" content="text/html; charset=__page_charset__" /> 
    7  
    8     __meta_description__ 
    9     __meta_keywords__ 
    10  
     7    __page_description__ 
     8    __page_keywords__ 
    119    <meta http-equiv="Content-Style-Type" content="text/css" /> 
    1210    <style> 
     
    1513        } 
    1614    </style> 
    17      
    18     <link href="__css_dir__general.css" rel="stylesheet" type="text/css" /> 
    19     <link href="__css_dir__anchor.css" rel="stylesheet" type="text/css" /> 
     15    __include_css__ 
    2016 
    2117    __menu_css__ 
     18    <!-- 
    2219    __styles__ 
    2320    __extra_css__ 
    24  
     21    --> 
    2522    __java_script__ 
    2623    __dol_images__ 
  • trunk/templates/base/css/common.css

    r9744 r9759  
    255255    height: 28px; 
    256256    line-height: 28px; 
    257     /*position:relative;*/ 
     257    position:relative; 
    258258    font-weight: normal; 
    259259} 
  • trunk/templates/base/scripts/BxBaseCmtsView.php

    r9241 r9759  
    183183    function getExtraCss () 
    184184    { 
    185         global $site; 
    186         global $tmpl; 
    187         return '<link href="'.$site['url'].'templates/tmpl_'.$tmpl.'/css/cmts.css" rel="stylesheet" type="text/css" />'; 
     185        $GLOBALS['oSysTemplate']->addCss('cmts.css'); 
    188186    } 
    189187 
  • trunk/templates/base/scripts/BxBaseSearchResultSharedMedia.php

    r9714 r9759  
    368368            $sModulePart = $this->getModuleFolder() . '/'; 
    369369            $oSysTemplate->addLocation($this->aCurrent['name'], BX_DIRECTORY_PATH_MODULES . $sModulePart, BX_DOL_URL_MODULES . $sModulePart); 
    370             return $sCode = $oSysTemplate->processStyles(array('search.css')); 
     370            $oSysTemplate->addCss(array('search.css')); 
     371            return ''; 
    371372        } 
    372373    } 
  • trunk/templates/tmpl_uni/page_150.html

    r9015 r9759  
    44    <title>__page_header__</title> 
    55    <meta http-equiv="Content-Type" content="text/html; charset=__page_charset__" /> 
    6     <meta http-equiv="refresh" content="1;URL=__url_relocate__" /> 
    7      
     6    <meta http-equiv="refresh" content="1;URL=__url_relocate__" />   
    87    <meta http-equiv="Content-Style-Type" content="text/css" /> 
    9     <link href="__css_dir__general.css" rel="stylesheet" type="text/css" /> 
    10     <link href="__css_dir__anchor.css" rel="stylesheet" type="text/css" /> 
    11     __styles__ 
     8    __include_css__ 
    129    <script src="inc/js/functions.js" type="text/javascript" language="javascript"></script> 
    1310    <script src="plugins/jquery/jquery.js" type="text/javascript" language="javascript"></script> 
Note: See TracChangeset for help on using the changeset viewer.