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

Contents of /contributions/themes/ubiquity/template.php

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


Revision 1.2 - (show annotations) (download) (as text)
Tue Jul 24 21:02:16 2007 UTC (2 years, 4 months ago) by melon
Branch: MAIN
CVS Tags: DRUPAL-5--0-11, HEAD
Branch point for: DRUPAL-5
Changes since 1.1: +1 -1 lines
File MIME type: text/x-php
Small modifications
1 <?php
2 // $Id: $
3
4 /* This is the default
5
6 /* Regions */
7 function ubiquity_regions() {
8 return array(
9 'left' => t('left sidebar'),
10 'right' => t('right sidebar'),
11 'content_top' => t('content top'),
12 'content_bottom' => t('content bottom'),
13 'header' => t('header'),
14 'footer' => t('footer')
15 );
16 }
17
18
19 /* Breadcrumb override */
20 function ubiquity_breadcrumb($breadcrumb) {
21 if (!empty($breadcrumb)) {
22 return '<div class="breadcrumb">'. implode(' &raquo ', $breadcrumb) .'</div>';
23 }
24 }
25
26
27 /* Template variables */
28 function _phptemplate_variables($hook, $vars = array()) {
29 switch ($hook) {
30 case 'page':
31
32 // secondary tabs
33 if ($secondary = menu_secondary_local_tasks()) {
34 $output .= "<ul class=\"tabs secondary\">\n". $secondary ."</ul>\n";
35 $vars['tabs2'] = $output;
36 }
37
38 // current logged-in user
39 global $user;
40 if ($user->uid > 0) {
41 $vars['logged_in'] = TRUE;
42 }
43 else {
44 $vars['logged_in'] = FALSE;
45 }
46
47 // classes for body element
48 $body_classes = array();
49 $body_classes[] = ($vars['is_front']) ? 'front' : 'not-front';
50 $body_classes[] = ($vars['logged_in']) ? 'logged-in' : 'not-logged-in';
51 if ($vars['node']->type) {
52 $body_classes[] = 'ntype-'. ubiquity_id_safe($vars['node']->type);
53 }
54 switch (TRUE) {
55 case $vars['sidebar_left'] && $vars['sidebar_right'] :
56 $body_classes[] = 'both-sidebars';
57 break;
58 case $vars['sidebar_left'] :
59 $body_classes[] = 'sidebar-left';
60 break;
61 case $vars['sidebar_right'] :
62 $body_classes[] = 'sidebar-right';
63 break;
64 }
65 // implode with spaces
66 $vars['body_classes'] = implode(' ', $body_classes);
67
68 break;
69
70 case 'node':
71 // get the currently logged in user
72 global $user;
73
74 $node_classes = array('node');
75 if ($vars['sticky']) {
76 $node_classes[] = 'sticky';
77 }
78 if (!$vars['node']->status) {
79 $node_classes[] = 'node-unpublished';
80 }
81 $node_classes[] = 'ntype-'. ubiquity_id_safe($vars['node']->type);
82 // implode with spaces
83 $vars['node_classes'] = implode(' ', $node_classes);
84
85 break;
86
87 case 'comment':
88 // we load the node object that the current comment is attached to
89 $node = node_load($vars['comment']->nid);
90 // if the author of this comment is equal to the author of the node, we set a variable
91 // then in our theme we can theme this comment differently to stand out
92 $vars['author_comment'] = $vars['comment']->uid == $node->uid ? TRUE : FALSE;
93 break;
94 }
95
96 return $vars;
97 }
98
99
100 /* Converts a string to a suitable html ID attribute. */
101 function ubiquity_id_safe($string) {
102 if (is_numeric($string{0})) {
103 // if the first character is numeric, add 'n' in front
104 $string = 'n'. $string;
105 }
106 return strtolower(preg_replace('/[^a-zA-Z0-9-]+/', '-', $string));
107 }
108
109
110 /* Menu local task rendering */
111 function ubiquity_menu_local_tasks() {
112 $output = '';
113
114 if ($primary = menu_primary_local_tasks()) {
115 $output .= "<ul class=\"tabs primary\">\n". $primary ."</ul>\n";
116 }
117
118 return $output;
119 }
120
121 /* ugly hack for generating menu items suitable for sliding doors technique */
122 function ubiquity_menu_item_link($item, $link_item) {
123 return l("<span>".$item['title']."</span>", $link_item['path'], !empty($item['description']) ? array('title' => $item['description']) : array(), isset($item['query']) ? $item['query'] : NULL, isset($item['fragment']) ? $item['fragment'] : NULL, FALSE, TRUE);
124 }
125

  ViewVC Help
Powered by ViewVC 1.1.2