[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/themes/myzen/ -> template.php (source)

   1  <?php
   2  // $Id: template.php,v 1.17.2.1 2009/02/13 06:47:44 johnalbin Exp $
   3  
   4  /**
   5   * @file
   6   * Contains theme override functions and preprocess functions for the theme.
   7   *
   8   * ABOUT THE TEMPLATE.PHP FILE
   9   *
  10   *   The template.php file is one of the most useful files when creating or
  11   *   modifying Drupal themes. You can add new regions for block content, modify
  12   *   or override Drupal's theme functions, intercept or make additional
  13   *   variables available to your theme, and create custom PHP logic. For more
  14   *   information, please visit the Theme Developer's Guide on Drupal.org:
  15   *   http://drupal.org/theme-guide
  16   *
  17   * OVERRIDING THEME FUNCTIONS
  18   *
  19   *   The Drupal theme system uses special theme functions to generate HTML
  20   *   output automatically. Often we wish to customize this HTML output. To do
  21   *   this, we have to override the theme function. You have to first find the
  22   *   theme function that generates the output, and then "catch" it and modify it
  23   *   here. The easiest way to do it is to copy the original function in its
  24   *   entirety and paste it here, changing the prefix from theme_ to STARTERKIT_.
  25   *   For example:
  26   *
  27   *     original: theme_breadcrumb()
  28   *     theme override: STARTERKIT_breadcrumb()
  29   *
  30   *   where STARTERKIT is the name of your sub-theme. For example, the
  31   *   zen_classic theme would define a zen_classic_breadcrumb() function.
  32   *
  33   *   If you would like to override any of the theme functions used in Zen core,
  34   *   you should first look at how Zen core implements those functions:
  35   *     theme_breadcrumbs()      in zen/template.php
  36   *     theme_menu_item_link()   in zen/template.php
  37   *     theme_menu_local_tasks() in zen/template.php
  38   *
  39   *   For more information, please visit the Theme Developer's Guide on
  40   *   Drupal.org: http://drupal.org/node/173880
  41   *
  42   * CREATE OR MODIFY VARIABLES FOR YOUR THEME
  43   *
  44   *   Each tpl.php template file has several variables which hold various pieces
  45   *   of content. You can modify those variables (or add new ones) before they
  46   *   are used in the template files by using preprocess functions.
  47   *
  48   *   This makes THEME_preprocess_HOOK() functions the most powerful functions
  49   *   available to themers.
  50   *
  51   *   It works by having one preprocess function for each template file or its
  52   *   derivatives (called template suggestions). For example:
  53   *     THEME_preprocess_page    alters the variables for page.tpl.php
  54   *     THEME_preprocess_node    alters the variables for node.tpl.php or
  55   *                              for node-forum.tpl.php
  56   *     THEME_preprocess_comment alters the variables for comment.tpl.php
  57   *     THEME_preprocess_block   alters the variables for block.tpl.php
  58   *
  59   *   For more information on preprocess functions and template suggestions,
  60   *   please visit the Theme Developer's Guide on Drupal.org:
  61   *   http://drupal.org/node/223440
  62   *   and http://drupal.org/node/190815#template-suggestions
  63   */
  64  
  65  
  66  /*
  67   * Add any conditional stylesheets you will need for this sub-theme.
  68   *
  69   * To add stylesheets that ALWAYS need to be included, you should add them to
  70   * your .info file instead. Only use this section if you are including
  71   * stylesheets based on certain conditions.
  72   */
  73  /* -- Delete this line if you want to use and modify this code
  74  // Example: optionally add a fixed width CSS file.
  75  if (theme_get_setting('STARTERKIT_fixed')) {
  76    drupal_add_css(path_to_theme() . '/layout-fixed.css', 'theme', 'all');
  77  }
  78  // */
  79  
  80  
  81  /**
  82   * Implementation of HOOK_theme().
  83   */
  84  function myzen_theme(&$existing, $type, $theme, $path) {
  85    $hooks = zen_theme($existing, $type, $theme, $path);
  86    //watchdog("zen hook",dvr($hooks, $return=TRUE, NULL), NULL, WATCHDOG_NOTICE, NULL);
  87    //dpr($existing, $return=TRUE, NULL);
  88    
  89    $hooks['more_link'] = array( 'arguments' => array('url' => NULL, 'title' => NULL), );
  90    // @TODO: Needs detailed comments. Patches welcome!
  91    return $hooks;
  92  }
  93  /**
  94   * implementation of theme_more_link
  95   */
  96  
  97  
  98  function myzen_more_link($url, $title) {
  99    // watchdog("template.php","myzen_more_link");
 100    return '<div class="more-link">' . t('<a href="@link" title="@title">( more ... )</a>', array('@link' => check_url($url), '@title' => $title)) . '</div>';
 101  }
 102  
 103  /**
 104   * Override or insert variables into all templates.
 105   *
 106   * @param $vars
 107   *   An array of variables to pass to the theme template.
 108   * @param $hook
 109   *   The name of the template being rendered (name of the .tpl.php file.)
 110   */
 111  /* -- Delete this line if you want to use this function
 112  function myzen_preprocess(&$vars, $hook) {
 113    $vars['sample_variable'] = t('Lorem ipsum.');
 114  }
 115  // */
 116  
 117  /**
 118   * Override or insert variables into the page templates.
 119   *
 120   * @param $vars
 121   *   An array of variables to pass to the theme template.
 122   * @param $hook
 123   *   The name of the template being rendered ("page" in this case.)
 124   */
 125  
 126  
 127  function myzen_preprocess_page(&$variables) {
 128    if (module_exists('path')) {
 129      $path_alias = drupal_get_path_alias($_GET['q']);
 130      $alias_parts = explode('/', $path_alias);
 131      $last = array_reverse($alias_parts);
 132      $last_part = $last[0];
 133      if ($last_part != "edit") {
 134        $templates = array();
 135        $template_name = "page";
 136        
 137        foreach ($alias_parts as $part) {
 138          $template_name = $template_name . '-' . $part;
 139          $templates[] = $template_name;
 140        }
 141        $variables['template_files'] = $templates;
 142        if (arg(0) == "node" && is_numeric(arg(1))) {
 143          $node_type = $variables['node']->type;
 144          $variables['template_files'] = array("page-node-$node_type.tpl.php");
 145          //watchdog("zen preprocess",dvr($variables['template_files'], $return=TRUE, NULL), NULL, WATCHDOG_NOTICE, NULL);
 146        }
 147        
 148      }
 149      
 150    }
 151  }
 152  
 153  /**
 154   * Override or insert variables into the node templates.
 155   *
 156   * @param $vars
 157   *   An array of variables to pass to the theme template.
 158   * @param $hook
 159   *   The name of the template being rendered ("node" in this  */
 160  /* -- Delete this line if you want to use this function
 161  function myzen_preprocess_node(&$vars, $hook) {
 162    $vars['sample_variable'] = t('Lorem ipsum.');
 163  }
 164  // */
 165  
 166  /**
 167   * Override or insert variables into the comment templates.
 168   *
 169   * @param $vars
 170   *   An array of variables to pass to the theme template.
 171   * @param $hook
 172   *   The name of the template being rendered ("comment" in this case.)
 173   */
 174  /* -- Delete this line if you want to use this function
 175  function myzen_preprocess_comment(&$vars, $hook) {
 176    $vars['sample_variable'] = t('Lorem ipsum.');
 177  }
 178  // */
 179  
 180  /**
 181   * Override or insert variables into the block templates.
 182   *
 183   * @param $vars
 184   *   An array of variables to pass to the theme template.
 185   * @param $hook
 186   *   The name of the template being rendered ("block" in this case.)
 187   */
 188  /* -- Delete this line if you want to use this function
 189  function myzen_preprocess_block(&$vars, $hook) {
 190    $vars['sample_variable'] = t('Lorem ipsum.');
 191  }
 192  // */
 193  
 194  function myzen_get_clisp($lispprog) {
 195        $handle = popen('/usr/home/yi/lisp/'.$lispprog, 'r');
 196        while($read = fread($handle, 2096) ){
 197          print $read;
 198        }
 199        pclose($handle);
 200  }
 201  function myzen_get_clisp1() {
 202        $handle = popen('/usr/home/yi/lisp/dr-test2.cl', 'r');
 203        while($read = fread($handle, 2096) ){
 204          print $read;
 205        }
 206        pclose($handle);
 207  }
 208  
 209  function myzen_get_clisp2() {
 210        $handle = popen('/usr/home/yi/lisp/dr-hol.cl', 'r');
 211        while($read = fread($handle, 2096) ){
 212          print $read;
 213        }
 214        pclose($handle);
 215  }
 216  function myzen_get_prog($path) {
 217        $handle = popen($path, 'r');
 218        while($read = fread($handle, 2096) ){
 219          print $read;
 220        }
 221        pclose($handle);
 222  }
 223  


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7