Subversion Repositories Sites.obs-saisons.fr

Rev

Rev 94 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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