Subversion Repositories Sites.obs-saisons.fr

Rev

Rev 94 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
93 aurelien 1
<?php
2
// $Id: template.php,v 1.16.2.3 2010/05/11 09:41:22 goba Exp $
3
 
4
/**
5
 * Sets the body-tag class attribute.
6
 *
7
 * Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
8
 */
9
function phptemplate_body_class($left, $right) {
10
  if ($left != '' && $right != '') {
11
    $class = 'sidebars';
12
  }
13
  else {
14
    if ($left != '') {
15
      $class = 'sidebar-left';
16
    }
17
    if ($right != '') {
18
      $class = 'sidebar-right';
19
    }
20
  }
21
 
22
  if (isset($class)) {
23
    print ' class="'. $class .'"';
24
  }
25
}
26
 
27
/**
94 aurelien 28
 * Return a themed set of links.
29
 *
30
 * @param $links
31
 *   A keyed array of links to be themed.
32
 * @param $attributes
33
 *   A keyed array of attributes
34
 * @return
35
 *   A string containing an unordered list of links.
36
 */
109 aurelien 37
function primary_links($links, $attributes = array('class' => 'links')) {
94 aurelien 38
 
39
  global $language;
40
  $output = '';
41
 
42
  if (count($links) > 0) {
43
    $output = '<ul'. drupal_attributes($attributes) .'>';
44
 
45
    $num_links = count($links);
46
    $i = 1;
47
 
48
    foreach ($links as $key => $link) {
49
      $class = $key;
50
 
51
      // Add first, last and active classes to the list of links to help out themers.
52
      if ($i == 1) {
53
        $class .= ' first';
54
      }
55
      if ($i == $num_links) {
56
        $class .= ' last';
57
      }
58
      if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))
59
          && (empty($link['language']) || $link['language']->language == $language->language)) {
60
        $class .= ' active';
61
      }
62
 
109 aurelien 63
       $id = 'lien_primaire_'.$i;
64
       $class .= ' lien_primaire';
94 aurelien 65
 
109 aurelien 66
      $output .= '<li'. drupal_attributes(array('id' => $id, 'class' => $class)) .'>';
94 aurelien 67
 
68
      if (isset($link['href'])) {
69
 
70
      	if($i == 1) {
71
      		$link['html'] = true;
72
      		$link['title'] = '<img class="icone_acceuil" alt="'.$link['title'].'" src="'.base_path().path_to_theme().'/images/accueil.png" />';
73
      	}
74
 
75
        // Pass in $link as $options, they share the same keys.
76
        $output .= l($link['title'], $link['href'], $link);
77
      }
78
      else if (!empty($link['title'])) {
79
        // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
80
        if (empty($link['html'])) {
81
          $link['title'] = check_plain($link['title']);
82
        }
83
        $span_attributes = '';
84
        if (isset($link['attributes'])) {
85
          $span_attributes = drupal_attributes($link['attributes']);
86
        }
87
        $output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
88
      }
89
 
90
      $i++;
91
      $output .= "</li>\n";
92
    }
93
 
94
    $output .= '</ul>';
95
  }
96
 
97
  return $output;
98
}
99
 
100
/**
109 aurelien 101
* Override or insert PHPTemplate variables into the search_theme_form template.
102
*
103
* @param $vars
104
*   A sequential array of variables to pass to the theme template.
105
* @param $hook
106
*   The name of the theme function being called (not used in this case.)
107
*/
108
function ods_preprocess_search_theme_form(&$vars, $hook) {
109
  // Remove the "Search this site" label from the form.
110
  $vars['form']['search_theme_form']['#title'] = t('');
111
 
112
  // Set a default value for text inside the search box field.
113
  $vars['form']['search_theme_form']['#value'] = t('');
114
 
115
  // Add a custom class and placeholder text to the search box.
116
  $vars['form']['search_theme_form']['#attributes'] = array('class' => 'NormalTextBox txtSearch',
117
                                                              'onfocus' => "if (this.value == '') {this.value = '';}",
118
                                                              'onblur' => "if (this.value == '') {this.value = '';}");
119
 
120
  // Change the text on the submit button
121
  //$vars['form']['submit']['#value'] = t('Go');
122
 
123
  // Rebuild the rendered version (search form only, rest remains unchanged)
124
  unset($vars['form']['search_theme_form']['#printed']);
125
  $vars['search']['search_theme_form'] = drupal_render($vars['form']['search_theme_form']);
126
 
127
  $vars['form']['submit']['#type'] = 'image_button';
128
  $vars['form']['submit']['#src'] = path_to_theme() . '/images/search.jpg';
129
 
130
  // Rebuild the rendered version (submit button, rest remains unchanged)
131
  unset($vars['form']['submit']['#printed']);
132
  $vars['search']['submit'] = drupal_render($vars['form']['submit']);
133
 
134
  // Collect all form elements to make it easier to print the whole form.
135
  $vars['search_form'] = implode($vars['search']);
136
 
137
}
138
 
139
/**
140
* Override or insert PHPTemplate variables into the search_block_form template.
141
*
142
* @param $vars
143
*   A sequential array of variables to pass to the theme template.
144
* @param $hook
145
*   The name of the theme function being called (not used in this case.)
146
*/
147
function ods_preprocess_search_block_form(&$vars, $hook) {
148
  // Remove the "Search this site" label from the form.
149
  $vars['form']['search_block_form']['#title'] = t('');
150
 
151
  // Set a default value for text inside the search box field.
152
  $vars['form']['search_block_form']['#value'] = t('Rechercher');
153
 
154
  // Add a custom class and placeholder text to the search box.
155
  $vars['form']['search_block_form']['#attributes'] = array('class' => 'NormalTextBox txtSearch',
156
                                                              'onfocus' => "if (this.value == 'Rechercher') {this.value = '';}",
157
                                                              'onblur' => "if (this.value == 'Rechercher') {this.value = '';}");
158
 
159
  // Change the text on the submit button
160
  //$vars['form']['submit']['#value'] = t('Go');
161
 
162
 
163
  $vars['form']['search_block_form']['#label'] = t('');
164
  // Rebuild the rendered version (search form only, rest remains unchanged)
165
  unset($vars['form']['search_block_form']['#printed']);
166
  $vars['search']['search_block_form'] = drupal_render($vars['form']['search_block_form']);
167
 
168
  $vars['form']['submit']['#type'] = 'image_button';
169
  $vars['form']['submit']['#src'] = path_to_theme() . '/images/search.jpg';
170
 
171
  // Rebuild the rendered version (submit button, rest remains unchanged)
172
  unset($vars['form']['submit']['#printed']);
173
  $vars['search']['submit'] = drupal_render($vars['form']['submit']);
174
 
175
  // Collect all form elements to make it easier to print the whole form.
176
  $vars['search_form'] = implode($vars['search']);
177
}
178
 
179
/**
93 aurelien 180
 * Return a themed breadcrumb trail.
181
 *
182
 * @param $breadcrumb
183
 *   An array containing the breadcrumb links.
184
 * @return a string containing the breadcrumb output.
185
 */
186
function phptemplate_breadcrumb($breadcrumb) {
187
  if (!empty($breadcrumb)) {
188
    return '<div class="breadcrumb">'. implode(' › ', $breadcrumb) .'</div>';
189
  }
190
}
191
 
192
/**
193
 * Override or insert PHPTemplate variables into the templates.
194
 */
195
function phptemplate_preprocess_page(&$vars) {
196
  $vars['tabs2'] = menu_secondary_local_tasks();
197
 
198
  // Hook into color.module
199
  if (module_exists('color')) {
200
    _color_page_alter($vars);
201
  }
202
}
203
 
204
/**
205
 * Add a "Comments" heading above comments except on forum pages.
206
 */
94 aurelien 207
function ods_preprocess_comment_wrapper(&$vars) {
93 aurelien 208
  if ($vars['content'] && $vars['node']->type != 'forum') {
209
    $vars['content'] = '<h2 class="comments">'. t('Comments') .'</h2>'.  $vars['content'];
210
  }
211
}
212
 
213
/**
214
 * Returns the rendered local tasks. The default implementation renders
215
 * them as tabs. Overridden to split the secondary tasks.
216
 *
217
 * @ingroup themeable
218
 */
219
function phptemplate_menu_local_tasks() {
220
  return menu_primary_local_tasks();
221
}
222
 
223
/**
224
 * Returns the themed submitted-by string for the comment.
225
 */
226
function phptemplate_comment_submitted($comment) {
227
  return t('!datetime — !username',
228
    array(
229
      '!username' => theme('username', $comment),
230
      '!datetime' => format_date($comment->timestamp)
231
    ));
232
}
233
 
234
/**
235
 * Returns the themed submitted-by string for the node.
236
 */
237
function phptemplate_node_submitted($node) {
238
  return t('!datetime — !username',
239
    array(
240
      '!username' => theme('username', $node),
241
      '!datetime' => format_date($node->created),
242
    ));
243
}
244
 
245
/**
246
 * Generates IE CSS links for LTR and RTL languages.
247
 */
248
function phptemplate_get_ie_styles() {
249
  global $language;
250
 
251
  $iecss = '<link type="text/css" rel="stylesheet" media="all" href="'. base_path() . path_to_theme() .'/fix-ie.css" />';
252
  if ($language->direction == LANGUAGE_RTL) {
253
    $iecss .= '<style type="text/css" media="all">@import "'. base_path() . path_to_theme() .'/fix-ie-rtl.css";</style>';
254
  }
255
 
256
  return $iecss;
257
}