/[drupal]/contributions/themes/abarre/template.php
ViewVC logotype

Diff of /contributions/themes/abarre/template.php

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

revision 1.1.4.3 by couzinhub, Fri Aug 1 00:01:21 2008 UTC revision 1.1.4.4 by couzinhub, Sun Aug 3 20:08:43 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2    // $Id$
 /*  
  * Declare the available regions implemented by this engine.  
  *  
  * @return  
  *    An array of regions.  The first array element will be used as the default region for themes.  
  *    Each array element takes the format: variable_name => t('human readable name')  
  */  
3    
 function abarre_regions() {  
   return array(  
        'left' => t('left sidebar'),  
        'content_top' => t('content top'),  
        'content_bottom' => t('content bottom'),  
        'header' => t('header'),  
        'footer' => t('footer')  
   );  
 }  
   
   
4  /**  /**
5   * Intercept template variables  * Override or insert PHPTemplate variables into the templates.
  *  
  * @param $hook  
  *   The name of the theme function being executed  
  * @param $vars  
  *   A sequential array of variables passed to the theme function.  
  */  
   
 function _phptemplate_variables($hook, $vars = array()) {  
   switch ($hook) {  
     // Send a new variable, $logged_in, to page.tpl.php to tell us if the current user is logged in or out.  
     case 'page':  
       // get the currently logged in user  
       global $user;  
   
       // An anonymous user has a user id of zero.  
       if ($user->uid > 0) {  
         // The user is logged in.  
         $vars['logged_in'] = TRUE;  
       }  
       else {  
         // The user has logged out.  
         $vars['logged_in'] = FALSE;  
       }  
   
       $body_classes = array();  
       // classes for body element  
       // allows advanced theming based on context (home page, node of certain type, etc.)  
       $body_classes[] = ($vars['is_front']) ? 'front' : 'not-front';  
       $body_classes[] = ($vars['logged_in']) ? 'logged-in' : 'not-logged-in';  
       if ($vars['node']->type) {  
         $body_classes[] = 'ntype-'. abarre_id_safe($vars['node']->type);  
       }  
       // implode with spaces  
       $vars['body_classes'] = implode(' ', $body_classes);  
   
       break;  
   
     case 'node':  
       // get the currently logged in user  
       global $user;  
   
       // set a new $is_admin variable  
       // this is determined by looking at the currently logged in user and seeing if they are in the role 'admin'  
       $vars['is_admin'] = in_array('admin', $user->roles);  
   
       $node_classes = array('node');  
       if ($vars['sticky']) {  
         $node_classes[] = 'sticky';  
       }  
       if (!$vars['node']->status) {  
         $node_classes[] = 'node-unpublished';  
       }  
       $node_classes[] = 'ntype-'. abarre_id_safe($vars['node']->type);  
       // implode with spaces  
       $vars['node_classes'] = implode(' ', $node_classes);  
   
       break;  
   
     case 'comment':  
       // we load the node object that the current comment is attached to  
       $node = node_load($vars['comment']->nid);  
       // if the author of this comment is equal to the author of the node, we set a variable  
       // then in our theme we can theme this comment differently to stand out  
       $vars['author_comment'] = $vars['comment']->uid == $node->uid ? TRUE : FALSE;  
       break;  
   }  
   
   return $vars;  
 }  
   
 /**  
 * Converts a string to a suitable html ID attribute.  
 * - Preceeds initial numeric with 'n' character.  
 * - Replaces space and underscore with dash.  
 * - Converts entire string to lowercase.  
 * - Works for classes too!  
 *  
 * @param string $string  
 *  the string  
 * @return  
 *  the converted string  
6  */  */
7  function abarre_id_safe($string) {  
8    if (is_numeric($string{0})) {  function phptemplate_preprocess_page(&$vars) {
9      // if the first character is numeric, add 'n' in front    // Hook into color.module
10      $string = 'n'. $string;    if (module_exists('color')) {
11        _color_page_alter($vars);
12    }    }
   return strtolower(preg_replace('/[^a-zA-Z0-9-]+/', '-', $string));  
13  }  }

Legend:
Removed from v.1.1.4.3  
changed lines
  Added in v.1.1.4.4

  ViewVC Help
Powered by ViewVC 1.1.3