/[drupal]/contributions/themes/garland-smarty/smartytemplate.php
ViewVC logotype

Contents of /contributions/themes/garland-smarty/smartytemplate.php

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


Revision 1.2 - (show annotations) (download) (as text)
Sun May 13 12:48:22 2007 UTC (2 years, 6 months ago) by yojoe
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5
Changes since 1.1: +2 -2 lines
File MIME type: text/x-php
$ was at wrong position in the file
1 <?php
2 // $Id: smartytemplate.php,v 1.1 2007/05/13 11:28:31 yojoe Exp $
3
4 /**
5 * Allow themable wrapping of all comments.
6 */
7 function smarty_comment_wrapper($content, $type = null) {
8 static $node_type;
9 if (isset($type)) $node_type = $type;
10
11 if (!$content || $node_type == 'forum') {
12 return '<div id="comments">'. $content . '</div>';
13 }
14 else {
15 return '<div id="comments"><h2 class="comments">'. t('Comments') .'</h2>'. $content .'</div>';
16 }
17 }
18
19 /**
20 * Override or insert Smarty variables into the templates.
21 */
22 function _smarty_variables($hook, $variables) {
23 switch($hook) {
24 case 'page' :
25 $variables['base_path'] = base_path();
26 $variables['path_to_theme'] = path_to_theme();
27
28 // Prepare header
29 $site_fields = array();
30 if ($variables['site_name']) {
31 $site_fields[] = check_plain($variables['site_name']);
32 }
33 if ($variables['site_slogan']) {
34 $site_fields[] = check_plain($variables['site_slogan']);
35 }
36 $variables['site_title'] = implode(' ', $site_fields);
37 $site_fields[0] = '<span>'. $site_fields[0] .'</span>';
38 $variables['site_html'] = implode(' ', $site_fields);
39
40 // Hook into color.module
41 if (module_exists('color')) {
42 _color_page_alter($variables);
43 }
44
45 break;
46
47 case 'node' :
48 $variables['node_type_name'] = node_get_types('name', $variables['node']);
49
50 default:
51 $variables['base_path'] = base_path();
52 $variables['path_to_theme'] = path_to_theme();
53 break;
54 }
55 return $variables;
56 }
57
58 function smarty_field(&$node, &$field, &$items, $teaser, $page) {
59 $field_empty = TRUE;
60 foreach ($items as $delta => $item) {
61 if (!empty($item['view']) || $item['view'] === "0") {
62 $field_empty = FALSE;
63 break;
64 }
65 }
66
67 $variables = array(
68 'node' => $node,
69 'field' => $field,
70 'field_type' => $field['type'],
71 'field_name' => $field['field_name'],
72 'field_type_css' => strtr($field['type'], '_', '-'),
73 'field_name_css' => strtr($field['field_name'], '_', '-'),
74 'label' => t($field['widget']['label']),
75 'label_display' => isset($field['display_settings']['label']['format']) ? $field['display_settings']['label']['format'] : 'above',
76 'field_empty' => $field_empty,
77 'items' => $items,
78 'teaser' => $teaser,
79 'page' => $page,
80 );
81
82 return _smarty_callback('field', $variables, array('field-'. $field['field_name']));
83 }
84
85 ?>

  ViewVC Help
Powered by ViewVC 1.1.2