Subversion Repositories Sites.obs-saisons.fr

Rev

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

Rev 93 Rev 94
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.
-
 
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
 */
-
 
37
function ods_links($links, $attributes = array('class' => 'links')) {
-
 
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
            	
-
 
63
      $class .= ' lien_primaire_'.$i;
-
 
64
      
-
 
65
      $output .= '<li'. drupal_attributes(array('class' => $class)) .'>';
-
 
66
 
-
 
67
      if (isset($link['href'])) {
-
 
68
      	
-
 
69
      	if($i == 1) {
-
 
70
      		$link['html'] = true;
-
 
71
      		$link['title'] = '<img class="icone_acceuil" alt="'.$link['title'].'" src="'.base_path().path_to_theme().'/images/accueil.png" />';
-
 
72
      	}
-
 
73
      	
-
 
74
        // Pass in $link as $options, they share the same keys.
-
 
75
        $output .= l($link['title'], $link['href'], $link);
-
 
76
      }
-
 
77
      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
        if (empty($link['html'])) {
-
 
80
          $link['title'] = check_plain($link['title']);
-
 
81
        }
-
 
82
        $span_attributes = '';
-
 
83
        if (isset($link['attributes'])) {
-
 
84
          $span_attributes = drupal_attributes($link['attributes']);
-
 
85
        }
-
 
86
        $output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
-
 
87
      }
-
 
88
 
-
 
89
      $i++;
-
 
90
      $output .= "</li>\n";
-
 
91
    }
-
 
92
 
-
 
93
    $output .= '</ul>';
-
 
94
  }
-
 
95
 
-
 
96
  return $output;
-
 
97
}
-
 
98
 
-
 
99
/**
28
 * Return a themed breadcrumb trail.
100
 * Return a themed breadcrumb trail.
29
 *
101
 *
30
 * @param $breadcrumb
102
 * @param $breadcrumb
31
 *   An array containing the breadcrumb links.
103
 *   An array containing the breadcrumb links.
32
 * @return a string containing the breadcrumb output.
104
 * @return a string containing the breadcrumb output.
33
 */
105
 */
34
function phptemplate_breadcrumb($breadcrumb) {
106
function phptemplate_breadcrumb($breadcrumb) {
35
  if (!empty($breadcrumb)) {
107
  if (!empty($breadcrumb)) {
36
    return '<div class="breadcrumb">'. implode(' › ', $breadcrumb) .'</div>';
108
    return '<div class="breadcrumb">'. implode(' › ', $breadcrumb) .'</div>';
37
  }
109
  }
38
}
110
}
39
 
111
 
40
/**
112
/**
41
 * Override or insert PHPTemplate variables into the templates.
113
 * Override or insert PHPTemplate variables into the templates.
42
 */
114
 */
43
function phptemplate_preprocess_page(&$vars) {
115
function phptemplate_preprocess_page(&$vars) {
44
  $vars['tabs2'] = menu_secondary_local_tasks();
116
  $vars['tabs2'] = menu_secondary_local_tasks();
45
 
117
 
46
  // Hook into color.module
118
  // Hook into color.module
47
  if (module_exists('color')) {
119
  if (module_exists('color')) {
48
    _color_page_alter($vars);
120
    _color_page_alter($vars);
49
  }
121
  }
50
}
122
}
51
 
123
 
52
/**
124
/**
53
 * Add a "Comments" heading above comments except on forum pages.
125
 * Add a "Comments" heading above comments except on forum pages.
54
 */
126
 */
55
function garland_preprocess_comment_wrapper(&$vars) {
127
function ods_preprocess_comment_wrapper(&$vars) {
56
  if ($vars['content'] && $vars['node']->type != 'forum') {
128
  if ($vars['content'] && $vars['node']->type != 'forum') {
57
    $vars['content'] = '<h2 class="comments">'. t('Comments') .'</h2>'.  $vars['content'];
129
    $vars['content'] = '<h2 class="comments">'. t('Comments') .'</h2>'.  $vars['content'];
58
  }
130
  }
59
}
131
}
60
 
132
 
61
/**
133
/**
62
 * Returns the rendered local tasks. The default implementation renders
134
 * Returns the rendered local tasks. The default implementation renders
63
 * them as tabs. Overridden to split the secondary tasks.
135
 * them as tabs. Overridden to split the secondary tasks.
64
 *
136
 *
65
 * @ingroup themeable
137
 * @ingroup themeable
66
 */
138
 */
67
function phptemplate_menu_local_tasks() {
139
function phptemplate_menu_local_tasks() {
68
  return menu_primary_local_tasks();
140
  return menu_primary_local_tasks();
69
}
141
}
70
 
142
 
71
/**
143
/**
72
 * Returns the themed submitted-by string for the comment.
144
 * Returns the themed submitted-by string for the comment.
73
 */
145
 */
74
function phptemplate_comment_submitted($comment) {
146
function phptemplate_comment_submitted($comment) {
75
  return t('!datetime — !username',
147
  return t('!datetime — !username',
76
    array(
148
    array(
77
      '!username' => theme('username', $comment),
149
      '!username' => theme('username', $comment),
78
      '!datetime' => format_date($comment->timestamp)
150
      '!datetime' => format_date($comment->timestamp)
79
    ));
151
    ));
80
}
152
}
81
 
153
 
82
/**
154
/**
83
 * Returns the themed submitted-by string for the node.
155
 * Returns the themed submitted-by string for the node.
84
 */
156
 */
85
function phptemplate_node_submitted($node) {
157
function phptemplate_node_submitted($node) {
86
  return t('!datetime — !username',
158
  return t('!datetime — !username',
87
    array(
159
    array(
88
      '!username' => theme('username', $node),
160
      '!username' => theme('username', $node),
89
      '!datetime' => format_date($node->created),
161
      '!datetime' => format_date($node->created),
90
    ));
162
    ));
91
}
163
}
92
 
164
 
93
/**
165
/**
94
 * Generates IE CSS links for LTR and RTL languages.
166
 * Generates IE CSS links for LTR and RTL languages.
95
 */
167
 */
96
function phptemplate_get_ie_styles() {
168
function phptemplate_get_ie_styles() {
97
  global $language;
169
  global $language;
98
 
170
 
99
  $iecss = '<link type="text/css" rel="stylesheet" media="all" href="'. base_path() . path_to_theme() .'/fix-ie.css" />';
171
  $iecss = '<link type="text/css" rel="stylesheet" media="all" href="'. base_path() . path_to_theme() .'/fix-ie.css" />';
100
  if ($language->direction == LANGUAGE_RTL) {
172
  if ($language->direction == LANGUAGE_RTL) {
101
    $iecss .= '<style type="text/css" media="all">@import "'. base_path() . path_to_theme() .'/fix-ie-rtl.css";</style>';
173
    $iecss .= '<style type="text/css" media="all">@import "'. base_path() . path_to_theme() .'/fix-ie-rtl.css";</style>';
102
  }
174
  }
103
 
175
 
104
  return $iecss;
176
  return $iecss;
105
}
177
}