Changeset 484

Show
Ignore:
Timestamp:
02/28/08 19:36:03 (10 months ago)
Author:
padams
Message:

added ability to override templates based on files being present wit the same name in a 'local' folder within the templates directory. Also
added check for upcomming themes directory.

- refactored environment path constants to begin using OWA_DIR to describe the root folder path for OWA.
- added template function that will cinlude other templates respecting overrides.
- refactored wrapper templates to use new include function
- added in new OWA logo.

Location:
trunk
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/base/templates/css.tpl

    r418 r484  
    206206#keywords{width:400px;} 
    207207#login_box {width:390px;} 
    208 #header {background-color: #B0C4DE; padding:4px; font-weight:bold; clear: both;} 
     208#owa_header {background-color:#FFFFFF; padding:4px; font-weight:bold; clear: both;} 
    209209#report_top_level_nav {margin: 5px 0 0 0;} 
    210210#side_bar {width:auto; color: ; border-right: 0px solid #000000; padding: 5px; background-color: ; font-size: 12px;} 
  • trunk/modules/base/templates/wrapper_default.tpl

    r250 r484  
    11<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     2 
    23<html xmlns="http://www.w3.org/1999/xhtml"> 
    34 
     
    56                <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> 
    67                <title>Open Web Analytics - <?=$page_title;?></title> 
    7                 <? include('css.tpl');?> 
     8                <?php $this->includeTemplate('css.tpl');?> 
    89        </head> 
    910         
    1011        <body> 
    1112         
    12                 <DIV id="header"><?include ('header.tpl');?></DIV> 
     13                <?php $this->includeTemplate('header.tpl');?> 
    1314                 
    14                 <? include('msgs.tpl');?> 
     15                <?php $this->includeTemplate('msgs.tpl');?> 
    1516                         
    1617                <?=$body;?> 
    1718         
    1819        </body> 
     20         
    1921</html> 
  • trunk/modules/base/templates/wrapper_gallery2.tpl

    r438 r484  
    1 <? include('css.tpl');?>         
     1<?php $this->includeTemplate('css.tpl');?>       
    22         
    3 <DIV id="header"><?include ('header.tpl');?></DIV> 
     3<?php $this->includeTemplate('header.tpl');?> 
    44 
    5 <? include('msgs.tpl');?> 
     5<?php $this->includeTemplate('msgs.tpl');?> 
    66 
    77<?=$body;?> 
  • trunk/modules/base/templates/wrapper_mediawiki.tpl

    r418 r484  
    55                <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> 
    66                <title>Open Web Analytics - <?=$page_title;?></title> 
    7                 <? include('css.tpl');?> 
     7                <?php $this->includeTemplate('css.tpl');?> 
    88        </head> 
    99         
     
    1111                <div class="host_app_nav"><img src="<?=$this->makeImageLink('mediawiki_icon_50h.jpg');?>" align="absmiddle"> <a href="/index.php?title=Special:SpecialPages">Return to your MediaWiki >></a></div> 
    1212                <div id="header"><?include ('header.tpl');?></div> 
    13                 <? include('msgs.tpl');?> 
     13                <?php $this->includeTemplate('msgs.tpl');?> 
    1414                <?=$body;?> 
    1515                <div class="host_app_nav"><img src="<?=$this->makeImageLink('mediawiki_icon_50h.jpg');?>" align="absmiddle"> <a href="/index.php?title=Special:SpecialPages">Return to your MediaWiki >></a></div> 
  • trunk/modules/base/templates/wrapper_public.tpl

    r293 r484  
    99        <body> 
    1010         
    11         <? include('css.tpl');?> 
     11        <?php $this->includeTemplate('css.tpl');?> 
    1212         
    1313        <DIV id="header"> 
    1414                <table width="100%"> 
    1515                        <TR> 
     16                                <TD class="owa_logo"><img src="<?=$this->makeImageLink('owa_logo_150w.jpg'); ?>" alt="Open Web Analytics"></TD> 
    1617                                <TD> 
    17                                         <span class="inline_h1">Open Web Analytics - <?=OWA_VERSION;?></span>            
     18                                        <span class="inline_h1">Version: <?=OWA_VERSION;?></span>                
    1819                                </TD> 
    1920                         
     
    3031                 
    3132                 
    32                 <? include('msgs.tpl');?> 
     33                <?php $this->includeTemplate('msgs.tpl');?> 
    3334        <BR> 
    3435                <?=$content;?> 
  • trunk/modules/base/templates/wrapper_wordpress.tpl

    r250 r484  
    1 <? include('css.tpl');?>         
     1<?php $this->includeTemplate('css.tpl');?>       
    22         
    3 <DIV id="header"><?include ('header.tpl');?></DIV> 
     3<?php $this->includeTemplate('header.tpl');?> 
    44 
    5 <? include('msgs.tpl');?> 
     5<?php $this->includeTemplate('msgs.tpl');?> 
    66 
    77<?=$body;?> 
  • trunk/owa_env.php

    r454 r484  
    2929 */ 
    3030 
    31 define('OWA_BASE_DIR', dirname(__FILE__)); 
    32 define('OWA_BASE_CLASSES_DIR', dirname(__FILE__). DIRECTORY_SEPARATOR); 
    33 define('OWA_BASE_CLASS_DIR', OWA_BASE_DIR.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR); 
    34 define('OWA_BASE_MODULE_DIR', OWA_BASE_DIR.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR); 
    35 define('OWA_INCLUDE_DIR', OWA_BASE_DIR.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR); 
    36 define('OWA_PEARLOG_DIR', OWA_BASE_DIR.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR.'Log-1.9.13'); 
    37 define('OWA_PHPMAILER_DIR', OWA_BASE_DIR.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR.'phpmailer-1.73'.DIRECTORY_SEPARATOR); 
    38 define('OWA_JPGRAPH_DIR', OWA_BASE_DIR.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR.'jpgraph-1.20.3'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR); 
    39 define('OWA_PLUGINS_DIR', OWA_BASE_DIR.DIRECTORY_SEPARATOR.'plugins'); 
    40 define('OWA_METRICS_DIR', OWA_BASE_DIR.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'metrics'.DIRECTORY_SEPARATOR); 
    41 define('OWA_GRAPHS_DIR', OWA_BASE_DIR.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'graphs'.DIRECTORY_SEPARATOR); 
    42 define('OWA_CONF_DIR', OWA_BASE_DIR.DIRECTORY_SEPARATOR.'conf'.DIRECTORY_SEPARATOR); 
    43 define('OWA_DATA_DIR', OWA_BASE_DIR.DIRECTORY_SEPARATOR.'owa-data'.DIRECTORY_SEPARATOR); 
     31define('OWA_DIR', dirname(__FILE__). DIRECTORY_SEPARATOR); 
     32define('OWA_BASE_DIR', dirname(__FILE__)); // depricated 
     33define('OWA_BASE_CLASSES_DIR', dirname(__FILE__). DIRECTORY_SEPARATOR); //depricated 
     34define('OWA_BASE_MODULE_DIR', OWA_DIR.'modules'.DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR); 
     35define('OWA_BASE_CLASS_DIR', OWA_BASE_MODULE_DIR.'classes'.DIRECTORY_SEPARATOR); 
     36define('OWA_INCLUDE_DIR', OWA_DIR.'includes'.DIRECTORY_SEPARATOR); 
     37define('OWA_PEARLOG_DIR', OWA_INCLUDE_DIR.'Log-1.9.13'); 
     38define('OWA_PHPMAILER_DIR', OWA_INCLUDE_DIR.'phpmailer-1.73'.DIRECTORY_SEPARATOR); 
     39define('OWA_JPGRAPH_DIR', OWA_INCLUDE_DIR.'jpgraph-1.20.3'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR); 
     40define('OWA_PLUGINS_DIR', OWA_DIR.'plugins'); //depricated 
     41define('OWA_METRICS_DIR', OWA_DIR.'plugins'.DIRECTORY_SEPARATOR.'metrics'.DIRECTORY_SEPARATOR); //depricated 
     42define('OWA_GRAPHS_DIR', OWA_DIR.'plugins'.DIRECTORY_SEPARATOR.'graphs'.DIRECTORY_SEPARATOR); //depricated 
     43define('OWA_PLUGIN_DIR', OWA_DIR.'plugins'.DIRECTORY_SEPARATOR); 
     44define('OWA_CONF_DIR', OWA_DIR.'conf'.DIRECTORY_SEPARATOR); 
     45define('OWA_DATA_DIR', OWA_DIR.'owa-data'.DIRECTORY_SEPARATOR); 
    4446define('OWA_CACHE_DIR', OWA_DATA_DIR.'caches'.DIRECTORY_SEPARATOR); 
    45 define('OWA_VERSION', '$Keyword:owa_version$'); 
     47define('OWA_THEMES_DIR', OWA_DIR.'themes'.DIRECTORY_SEPARATOR); 
     48define('OWA_VERSION', 'SVN-TRUNK'); 
    4649?> 
  • trunk/owa_template.php

    r393 r484  
    1717// 
    1818 
    19 require_once(OWA_INCLUDE_DIR.'/template_class.php'); 
     19require_once(OWA_INCLUDE_DIR.'template_class.php'); 
    2020require_once(OWA_BASE_DIR.'/owa_lib.php'); 
    21 require_once(OWA_BASE_CLASS_DIR.'settings.php'); 
    2221require_once(OWA_BASE_DIR.'/owa_auth.php'); 
    2322 
     
    4342        var $config; 
    4443         
     44        var $theme_template_dir; 
     45         
     46        var $module_local_template_dir; 
     47         
     48        var $module_template_dir; 
     49         
     50        var $e; 
     51         
    4552        /** 
    4653         * Params passed by calling caller 
     
    5663                $c = &owa_coreAPI::configSingleton(); 
    5764                $this->config = $c->fetch('base'); 
    58                 // set template dir 
    59                  
     65                 
     66                $this->e = &owa_coreAPI::errorSingleton(); 
     67                 
     68                // set template dirs 
    6069                if(!empty($caller_params['module'])): 
    6170                        $this->_setTemplateDir($module); 
     
    7079         
    7180        function _setTemplateDir($module) { 
    72                  
    73                 $this->template_dir = OWA_BASE_DIR . '/modules/' . $module . '/templates/'; 
     81         
     82                // set module template dir 
     83                $this->module_template_dir = OWA_DIR.'modules'.DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR; 
     84                 
     85                // set module local template override dir 
     86                $this->module_local_template_dir = $this->module_template_dir.'local'.DIRECTORY_SEPARATOR; 
     87                 
     88                // set theme template dir 
     89                $this->theme_template_dir = OWA_THEMES_DIR.$this->config['theme'].DIRECTORY_SEPARATOR; 
    7490                 
    7591                return; 
    7692        } 
     93         
     94        /** 
     95     * Set the template file 
     96     * 
     97     * @param string $file 
     98     */ 
     99        function set_template($file = null) { 
     100         
     101                if ($file == null): 
     102                        $this->e->error('No template file was specified.'); 
     103                        return false; 
     104                else: 
     105                        // check module's local modification template Directory 
     106                        if (file_exists($this->module_local_template_dir.$file)): 
     107                                $this->file = $this->module_local_template_dir.$file; 
     108                                 
     109                        // check theme's template Directory 
     110                        elseif(file_exists($this->theme_template_dir.$file)): 
     111                                $this->file = $this->theme_template_dir.$file; 
     112                                 
     113                        // check module's template directory 
     114                        elseif(file_exists($this->module_template_dir.$file)): 
     115                                $this->file = $this->module_template_dir.$file; 
     116                         
     117                        // throw error 
     118                        else: 
     119                                $this->e->error(sprintf('%s was not found in any template directory.', $file)); 
     120                                return false; 
     121                        endif; 
     122         
     123                return true; 
     124        endif; 
     125    } 
    77126         
    78127        /** 
     
    417466        } 
    418467         
     468        function includeTemplate($file) { 
     469         
     470                $this->set_template($file); 
     471                include($this->file); 
     472                return; 
     473         
     474        } 
    419475         
    420476