Sample template.php

  1. <?php
  2. // $Id: template.php,v 1.16 2007/10/11 09:51:29 goba Exp $
  3. drupal_add_js(path_to_theme().'/jscrollerx.js', 'theme');
  4. /*drupal_add_js(path_to_theme().'/jscroller2-1.5.js', 'theme');*/
  5.  
  6.  
  7. drupal_add_css(path_to_theme().'/jscroller2-1.0.css', 'theme', 'all', TRUE);
  8. $styles = drupal_get_css();
  9. /**
  10.  * Sets the body-tag class attribute.
  11.  *
  12.  * Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
  13.  */
  14. function phptemplate_body_class($left, $right) {
  15.   if ($left != '' && $right != '') {
  16.     $class = 'sidebars';
  17.   }
  18.   else {
  19.     if ($left != '') {
  20.       $class = 'sidebar-left';
  21.     }
  22.     if ($right != '') {
  23.       $class = 'sidebar-right';
  24.     }
  25.   }
  26.  
  27.   if (isset($class)) {
  28.     print ' class="'. $class .'"';
  29.   }
  30. }
  31.  
  32. /**
  33.  * Return a themed breadcrumb trail.
  34.  *
  35.  * @param $breadcrumb
  36.  *   An array containing the breadcrumb links.
  37.  * @return a string containing the breadcrumb output.
  38.  */
  39. function phptemplate_breadcrumb($breadcrumb) {
  40.   if (!empty($breadcrumb)) {
  41.     return '<div class="breadcrumb">'. implode(' › ', $breadcrumb) .'</div>';
  42.   }
  43. }
  44.  
  45. /**
  46.  * Allow themable wrapping of all comments.
  47.  */
  48. function phptemplate_comment_wrapper($content, $node) {
  49.   if (!$content || $node->type == 'forum') {
  50.     return '<div id="comments">'. $content .'</div>';
  51.   }
  52.   else {
  53.     return '<div id="comments"><h2 class="comments">'. t('Comments') .'</h2>'. $content .'</div>';
  54.   }
  55. }
  56.  
  57. /**
  58.  * Override or insert PHPTemplate variables into the templates.
  59.  */
  60. function phptemplate_preprocess_page(&$vars) {
  61.   $vars['tabs2'] = menu_secondary_local_tasks();
  62.  
  63.   // Hook into color.module
  64.   if (module_exists('color')) {
  65.     _color_page_alter($vars);
  66.   }
  67. }
  68.  
  69. /**
  70.  * Returns the rendered local tasks. The default implementation renders
  71.  * them as tabs. Overridden to split the secondary tasks.
  72.  *
  73.  * @ingroup themeable
  74.  */
  75. function phptemplate_menu_local_tasks() {
  76. }
  77.  
  78. function phptemplate_comment_submitted($comment) {
  79.   return t('!datetime — !username',
  80.     array(
  81.       '!username' => theme('username', $comment),
  82.       '!datetime' => format_date($comment->timestamp)
  83.     ));
  84. }
  85.  
  86. function phptemplate_node_submitted($node) {
  87.   return t('!datetime — !username',
  88.     array(
  89.       '!username' => theme('username', $node),
  90.       '!datetime' => format_date($node->created),
  91.     ));
  92. }
  93.  
  94. /**
  95.  * Generates IE CSS links for LTR and RTL languages.
  96.  */
  97. function phptemplate_get_ie_styles() {
  98.   global $language;
  99.  
  100.   $iecss = '<link type="text/css" rel="stylesheet" media="all" href="'. base_path() . path_to_theme() .'/fix-ie.css" />';
  101.   if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) {
  102.     $iecss .= '<style type="text/css" media="all">@import "'. base_path() . path_to_theme() .'/fix-ie-rtl.css";</style>';
  103.   }
  104.  
  105.   return $iecss;
  106. }