Changeset 847 in ExiteCMS


Ignore:
Timestamp:
09/28/07 21:08:59 (4 years ago)
Author:
hverton
Message:

Reorganized the directory structure. All directories to which the webserver needs write access are now in /files (cache and tplcache directories). Smarty now supports multiple websites and multiple themes writing to the same cache directories)

Location:
trunk
Files:
2 added
83 deleted
5 edited
16 copied
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/includes/Smarty-2.6.18/Smarty.class.php

    r843 r847  
    7373     * @var string 
    7474     */ 
    75     var $template_dir    =  array('templates'); 
     75    var $template_dir    =  'templates'; 
    7676 
    7777    /** 
     
    11201120    { 
    11211121        static $_cache_info = array(); 
    1122  
     1122         
    11231123        $_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting) 
    11241124               ? $this->error_reporting : error_reporting() & ~E_NOTICE); 
     
    17521752            // make source name safe for filename 
    17531753            $_filename = urlencode(basename($auto_source)); 
    1754  
    1755             // WANWIZARD: if the filename contains illegal characters, use the MD5-hash 
    1756             if (preg_match("%[\\\/:;*?\"\[\]\%]%", $_filename)) { 
    1757                 $_filename = md5($_filename); 
    1758             } 
    1759             // WANWIZARD: end-of-mod 
    1760  
    17611754            $_crc32 = sprintf('%08X', crc32($auto_source)); 
    17621755            // prepend %% to avoid name conflicts with 
     
    17641757            $_crc32 = substr($_crc32, 0, 2) . $_compile_dir_sep . 
    17651758                      substr($_crc32, 0, 3) . $_compile_dir_sep . $_crc32; 
    1766             $_return .= $_filename . '.%%' . $_crc32 . '%%'; 
    1767         } 
     1759            $_return .= '%%' . $_crc32 . '%%' . $_filename; 
     1760        } 
     1761 
    17681762        return $_return; 
    17691763    } 
  • trunk/includes/font2image.php

    r834 r847  
    2929    $f2i_array['cache_folder'] = "";                   // Directory to store the cached images in. 
    3030                                                       // If not defined or not valid, cache_images will be set to false. 
     31    $f2i_array['cache_prefix'] = false;                // If defined, this will be prepended to the filename of the cached file     
    3132    $f2i_array['cache_hash'] = false;                  // Boolean. If false, the text will be used as filename, otherwise a hash is calculated     
    3233 
     
    9293    if (!isset($font2image['cache_folder'])) $font2image['cache_images'] = false; 
    9394    if ($font2image['cache_folder'] !="" && !is_dir($font2image['cache_folder'])) fatal_error('Cache folder does not exist.'); 
     95    if (!isset($font2image['cache_prefix']) || $font2image['cache_prefix'] == false) $font2image['cache_prefix'] = ""; 
    9496    if (!isset($font2image['cache_hash'])) $font2image['cache_hash'] = false; 
    9597 
     
    129131            $hash = str_replace(' ', '_', $font2image['font_text']); 
    130132        } 
    131         $cache_filename = $font2image['cache_folder'] . '/' . $hash . '.png' ; 
     133        $cache_filename = $font2image['cache_folder'] . '/' . $font2image['cache_prefix'] . $hash . '.png' ; 
    132134        if($font2image['cache_images'] && is_readable($cache_filename)) { 
    133135            // convert the file to a resource 
  • trunk/includes/theme_functions.php

    r843 r847  
    1515if (eregi("theme_functions.php", $_SERVER['PHP_SELF']) || !defined('ExiteCMS_INIT')) die(); 
    1616 
     17// load the Smarty template engine 
     18require_once PATH_INCLUDES."Smarty-2.6.18/Smarty.class.php"; 
     19 
     20// extend Smarty with the ExiteCMS custom bits 
     21class ExiteCMS_Smarty extends Smarty { 
     22 
     23    /**#@+ 
     24     * ExiteCMS Smarty Configuration Section 
     25     */ 
     26 
     27    /** 
     28     * Array with names of directories where templates can be located. 
     29     * 
     30     * @var string 
     31     */ 
     32    var $template_dir = array('templates'); 
     33 
     34    /**#@-*/ 
     35    /** 
     36     * The class constructor. 
     37     */ 
     38    function ExiteCMS_Smarty() { 
     39        global $settings; 
     40         
     41        $this->Smarty(); 
     42 
     43        // debugging needed? 
     44        $this->debugging = false; 
     45         
     46        // on-the-fly compilation needed? 
     47        $this->compile_check = true; 
     48         
     49        // set the compile ID for this website/theme (themes can have different templates!) 
     50        $this->compile_id = $_SERVER['SERVER_NAME'].".".$settings['theme']; 
     51         
     52        // caching required? 
     53        $this->caching = 0; 
     54         
     55        // path definitions 
     56        $this->config_dir = PATH_THEME.'templates/configs'; 
     57        $this->compile_dir = PATH_ROOT.'files/tplcache'; 
     58        $this->cache_dir = PATH_ROOT.'files/cache'; 
     59     
     60        // PHP in Templates? Don't think so! 
     61        $this->php_handling = SMARTY_PHP_REMOVE; 
     62         
     63        // Template security settings: allow PHP functions 
     64        $this->security = false; 
     65    } 
     66 
     67    /** 
     68     * get a concrete filename for automagically created content 
     69     * 
     70     * @param string $auto_base 
     71     * @param string $auto_source 
     72     * @param string $auto_id 
     73     * @return string 
     74     * @staticvar string|null 
     75     * @staticvar string|null 
     76     */ 
     77    function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null) 
     78    { 
     79        $_compile_dir_sep =  $this->use_sub_dirs ? DIRECTORY_SEPARATOR : '^'; 
     80        $_return = $auto_base . DIRECTORY_SEPARATOR; 
     81 
     82        if(isset($auto_id)) { 
     83            // make auto_id safe for directory names 
     84            $auto_id = str_replace('%7C',$_compile_dir_sep,(urlencode($auto_id))); 
     85        } 
     86 
     87        if(isset($auto_source)) { 
     88            // make source name safe for filename 
     89            $auto_source = urlencode(basename($auto_source)); 
     90            if (preg_match("%[\\\/:;*?\"\[\]\%]%", $auto_source)) { 
     91                $auto_source = md5($auto_source); 
     92            } 
     93            $_crc32 = sprintf('%08X', crc32($auto_source)); 
     94            // prepend %% to avoid name conflicts with 
     95            // with $params['auto_id'] names 
     96            $_crc32 = substr($_crc32, 0, 2) . $_compile_dir_sep . 
     97                      substr($_crc32, 0, 3) . $_compile_dir_sep . $_crc32; 
     98        } 
     99        return $_return.(isset($auto_source)?($auto_source."."):"").(isset($auto_id)?($auto_id."."):"").(isset($_crc32)?$_crc32:""); 
     100    } 
     101 
     102    /** 
     103     * Returns the last modified timestamp of a template, or false if not found. 
     104     * 
     105     * @param string $tpl_file 
     106     * @return mixed 
     107     */ 
     108    function template_timestamp($tpl_file) 
     109    { 
     110        $_params = array('resource_name' => $tpl_file, 'quiet'=>true, 'get_source'=>false); 
     111        if ($this->_fetch_resource_info($_params)) { 
     112            return $_params['resource_timestamp']; 
     113        } else { 
     114            return false; 
     115        } 
     116    } 
     117} 
     118 
    17119// Smarty template engine definitions and initialisation 
    18 require_once PATH_INCLUDES."Smarty-2.6.18/Smarty.class.php"; 
    19  
    20 // initialize the class 
    21 $template = & new Smarty(); 
    22  
    23 // debugging needed? 
    24 $template->debugging = false; 
    25  
    26 // on-the-fly compilation needed? 
    27 $template->compile_check = true; 
    28  
    29 // set the compile ID for this website 
    30 $template->compile_id = $_SERVER['SERVER_NAME']; 
    31  
    32 // caching required? 
    33 $template->caching = 0; 
    34  
    35 // path definitions 
    36 $template->template_dir = PATH_THEME.'templates/source'; 
    37 $template->compile_dir = PATH_THEME.'templates/templates'; 
    38 $template->config_dir = PATH_THEME.'templates/configs'; 
    39 $template->cache_dir = PATH_THEME.'cache'; 
     120 
     121// initialize the template engine 
     122$template = & new ExiteCMS_Smarty(); 
    40123 
    41124// plugin's, where to find them? 
     
    43126// first check if there's one defined in the current theme 
    44127if (is_dir(PATH_THEME."template/plugins")) $plugins_dir[] = PATH_THEME."template/plugins"; 
    45 // next, check the CMS custom plugins 
    46 $plugins_dir[] = 'custom-plugins'; 
     128// next, check the ExiteCMS custom plugins 
     129$plugins_dir[] = PATH_INCLUDES.'template-plugins'; 
    47130// and finaly, use the default Smarty plugins 
    48131$plugins_dir[] = 'smarty-plugins'; 
     
    53136$template_dir = array(); 
    54137// first check if there's one defined in the current theme 
    55 if (is_dir(PATH_THEME."templates/source")) $template_dir[] = PATH_THEME."templates/source"; 
     138if (is_dir(PATH_THEME."templates/templates")) $template_dir[] = PATH_THEME."templates/templates"; 
    56139// next, check the CMS template directory 
    57140$template_dir[] = PATH_INCLUDES.'templates'; 
    58141 
    59142$template->template_dir = $template_dir; 
    60  
    61 // PHP in Templates? Don't think so! 
    62 $template->php_handling = SMARTY_PHP_REMOVE; 
    63  
    64 // Template security settings: allow PHP functions 
    65 $template->security = false; 
    66143 
    67144// Register the panel template resource 
     
    83160    global $settings, $userdata, $db_prefix, $aidlink, 
    84161            $template, $template_panels, $template_variables,  
    85             $_loadstats, $_headparms, $_bodyparms; 
     162            $_loadstats, $_headparms, $_bodyparms, $_last_updated; 
    86163 
    87164    // reset all assigned template variables 
     
    181258            } 
    182259         
    183             // if a template is defined, load the template,  
    184             if (isset($panel['template'])) $template->display($panel['template']); 
     260            // if a template is defined, get the last modified date, and load the template 
     261            if (isset($panel['template'])) { 
     262                // get the timestamp of the template, and update the last update timestamp if newer 
     263                $ts = $template->template_timestamp($panel['template']); 
     264                $_last_updated = isset($_last_updated) ? ($ts > $_last_updated ? $ts : $_last_updated ) : $ts; 
     265                $template->assign("_last_updated", $_last_updated); 
     266                // and load the template 
     267                $template->display($panel['template']); 
     268            } 
    185269             
    186270            // restore the template direcory if needed 
  • trunk/locale/English/global.php

    r843 r847  
    167167$locale['195'] = "This account has not been activated."; 
    168168$locale['196'] = "Invalid username or password."; 
    169 $locale['197'] = "OBSOLETE! REPLACED BY 183/184!"; 
     169$locale['197'] = "Page last updated"; 
    170170$locale['198'] = "<font color='red'><b>Warning:</b></font> setup.php detected, please delete it immediately"; 
    171171$locale['199'] = "wrote"; 
  • trunk/themes/PLiTheme/bartext.php

    r735 r847  
    2525$font2png['shadow_width'] = 0; 
    2626$font2png['cache_images'] = (isset($_GET['cache']) && $_GET['cache'] == "yes") ? true : false; 
    27 $font2png['cache_folder'] = PATH_THEME."cache"; 
     27$font2png['cache_folder'] = PATH_ROOT."files/cache/"; 
     28$font2png['cache_prefix'] = $_SERVER['SERVER_NAME'].".".$settings['theme']."."; 
    2829$font2png['cache_hash'] = false; 
    2930 
Note: See TracChangeset for help on using the changeset viewer.