/[drupal]/contributions/theme-engines/phptemplate/phptemplate.engine
ViewVC logotype

Diff of /contributions/theme-engines/phptemplate/phptemplate.engine

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.25, Thu Mar 31 19:53:47 2005 UTC revision 1.26, Mon Apr 11 00:07:54 2005 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: phptemplate.engine,v 1.24 2005/03/26 18:20:09 adrian Exp $  // $Id: phptemplate.engine,v 1.25 2005/03/31 19:53:47 tdobes Exp $
3    
4    function phptemplate_init($template) {
5      require_once(realpath('themes/engines/phptemplate/template.php'));
6      $engine_code = variable_get('phptemplate_extra_logic', array());
7      $file = dirname($template->filename) . '/template.php';
8      if (file_exists($file)) {
9        include_once($file);
10      }
11    }
12    
13    function phptemplate_templates($directory = 'themes') {
14      return system_listing('^page\.tpl\.php$', $directory, 'filename');
15    }
16    
17    
18  /**  /**
19   * Execute a template engine call.   * Execute a template engine call.
# Line 20  Line 34 
34   *  The HTML generated by the template system.   *  The HTML generated by the template system.
35   */   */
36  function _phptemplate_callback($hook, $vars = array(), $file = null) {  function _phptemplate_callback($hook, $vars = array(), $file = null) {
   /**  
    * Counts how many times certain hooks have been called  
    *  
    * Sidebar left / right are special cases.  
    */  
   static $count = array();  
   $count[$hook] = is_int($count[$hook]) ? $count[$hook] : 1;  
   $vars['zebra'] = ($count[$hook] % 2) ? 'odd' : 'even';  
   $vars['seqid'] = $count[$hook]++;  
37    
38    global $sidebar_indicator;    $vars = array_merge($vars, _phptemplate_default_variables($hook, $vars));
   if ($hook == 'block') {  
     $count['block_counter'][$sidebar_indicator] = is_int($count['block_counter'][$sidebar_indicator]) ? $count['block_counter'][$sidebar_indicator] : 1;  
     $vars['block_zebra'] = ($count['block_counter'][$sidebar_indicator] % 2) ? 'odd' : 'even';  
     $vars['block_seqid'] = $count['block_counter'][$sidebar_indicator]++;  
   }  
39    
40    // Allow specified variables to be overridden    // Allow specified variables to be overridden
41    if (function_exists('_phptemplate_variables')) {    if (function_exists('_phptemplate_variables')) {
# Line 55  function _phptemplate_callback($hook, $v Line 55  function _phptemplate_callback($hook, $v
55    
56  }  }
57    
58  function phptemplate_init($template) {  /**
59    require_once(realpath('themes/engines/phptemplate/template.php'));   * Counts how many times certain hooks have been called
60    $engine_code = variable_get('phptemplate_extra_logic', array());   *
61    $file = dirname($template->filename) . '/template.php';   * Sidebar left / right are special cases.
62    if (file_exists($file)) {   */
63      include_once($file);  function _phptemplate_default_variables($hook, $vars) {
64      static $count = array();
65      $count[$hook] = is_int($count[$hook]) ? $count[$hook] : 1;
66      $vars['zebra'] = ($count[$hook] % 2) ? 'odd' : 'even';
67      $vars['seqid'] = $count[$hook]++;
68    
69      global $sidebar_indicator;
70      if ($hook == 'block') {
71        $count['block_counter'][$sidebar_indicator] = is_int($count['block_counter'][$sidebar_indicator]) ? $count['block_counter'][$sidebar_indicator] : 1;
72        $vars['block_zebra'] = ($count['block_counter'][$sidebar_indicator] % 2) ? 'odd' : 'even';
73        $vars['block_seqid'] = $count['block_counter'][$sidebar_indicator]++;
74    }    }
 }  
75    
76  function phptemplate_templates($directory = 'themes') {    // Tell all templates where they are located.
77    return system_listing('^page\.tpl\.php$', $directory, 'filename');    $vars['directory'] = path_to_theme();
78    
79      if (drupal_get_path_alias($_GET['q']) == variable_get('site_frontpage', 'node')) {
80        $vars['is_front'] = true;
81      }
82    
83      return $vars;
84  }  }
85    
86  function phptemplate_features() {  function phptemplate_features() {
# Line 106  function phptemplate_settings() { Line 121  function phptemplate_settings() {
121      }      }
122    
123      //Get the data to populate the textfields, if the variable is not an array .. try to parse the old-style link format.      //Get the data to populate the textfields, if the variable is not an array .. try to parse the old-style link format.
124      $value = variable_get('phptemplate_' . $type . '_links', '');      $value = variable_get('phptemplate_' . $type . '_links', array());
125    
126      //Get the amount of links to show, possibly expanding if there are more links defined than the count specifies.      //Get the amount of links to show, possibly expanding if there are more links defined than the count specifies.
127      $count = variable_get('phptemplate_' . $type . '_link_count', 5);      $count = variable_get('phptemplate_' . $type . '_link_count', 5);
# Line 151  function phptemplate_page($content) { Line 166  function phptemplate_page($content) {
166    
167    foreach (array('primary', 'secondary') as $type) {    foreach (array('primary', 'secondary') as $type) {
168      //Get the data to populate the textfields, if the variable is not an array .. try to parse the old-style link format.      //Get the data to populate the textfields, if the variable is not an array .. try to parse the old-style link format.
169      $value = variable_get('phptemplate_' . $type . '_links', '');      $value = variable_get('phptemplate_' . $type . '_links', array());
170    
171      //Get the amount of links to show, possibly expanding if there are more links defined than the count specifies.      //Get the amount of links to show, possibly expanding if there are more links defined than the count specifies.
172      $count = variable_get('phptemplate_' . $type . '_link_count', 5);      $count = variable_get('phptemplate_' . $type . '_link_count', 5);
# Line 203  function phptemplate_page($content) { Line 218  function phptemplate_page($content) {
218      'language'            => $GLOBALS['locale'],      'language'            => $GLOBALS['locale'],
219      'site'                => variable_get('site_name', 'drupal'),      'site'                => variable_get('site_name', 'drupal'),
220      'head'                => drupal_get_html_head(),      'head'                => drupal_get_html_head(),
221      'onload_attributes'   => theme_onload_attribute(),      'onload_attributes'   => theme('onload_attribute'),
     'directory'           => path_to_theme(),  
222      'logo'                => theme_get_setting('logo'),      'logo'                => theme_get_setting('logo'),
223      'site_name'           => (theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : ''),      'site_name'           => (theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : ''),
224      'site_slogan'         => (theme_get_setting('toggle_slogan') ? variable_get('site_slogan', '') : ''),      'site_slogan'         => (theme_get_setting('toggle_slogan') ? variable_get('site_slogan', '') : ''),
# Line 217  function phptemplate_page($content) { Line 231  function phptemplate_page($content) {
231      'secondary_links'     => $links['secondary'],      'secondary_links'     => $links['secondary'],
232      'breadcrumb'          => theme('breadcrumb', drupal_get_breadcrumb()),      'breadcrumb'          => theme('breadcrumb', drupal_get_breadcrumb()),
233      'tabs'                => theme('menu_local_tasks'),      'tabs'                => theme('menu_local_tasks'),
234      'messages'            => theme_status_messages(),      'messages'            => theme('status_messages'),
235      'layout'              => $layout,      'layout'              => $layout,
236      'help'                => menu_get_active_help(),      'help'                => menu_get_active_help(),
237      'styles'              => theme_get_styles(),      'styles'              => theme_get_styles(),
238      'mission'             => $mission,      'mission'             => $mission,
     'is_front'            => $frontpage,  
239      'sidebar_left'        => $sidebar_left,      'sidebar_left'        => $sidebar_left,
240      'content'             => '<!-- begin content -->' . $content . '<!-- end content -->',      'content'             => '<!-- begin content -->' . $content . '<!-- end content -->',
241      'sidebar_right'       => $sidebar_right,      'sidebar_right'       => $sidebar_right,

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

  ViewVC Help
Powered by ViewVC 1.1.2