Subversion Repositories Sites.obs-saisons.fr

Rev

Rev 93 | Rev 109 | 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
 */
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
/**
93 aurelien 100
 * Return a themed breadcrumb trail.
101
 *
102
 * @param $breadcrumb
103
 *   An array containing the breadcrumb links.
104
 * @return a string containing the breadcrumb output.
105
 */
106
function phptemplate_breadcrumb($breadcrumb) {
107
  if (!empty($breadcrumb)) {
108
    return '<div class="breadcrumb">'. implode(' › ', $breadcrumb) .'</div>';
109
  }
110
}
111
 
112
/**
113
 * Override or insert PHPTemplate variables into the templates.
114
 */
115
function phptemplate_preprocess_page(&$vars) {
116
  $vars['tabs2'] = menu_secondary_local_tasks();
117
 
118
  // Hook into color.module
119
  if (module_exists('color')) {
120
    _color_page_alter($vars);
121
  }
122
}
123
 
124
/**
125
 * Add a "Comments" heading above comments except on forum pages.
126
 */
94 aurelien 127
function ods_preprocess_comment_wrapper(&$vars) {
93 aurelien 128
  if ($vars['content'] && $vars['node']->type != 'forum') {
129
    $vars['content'] = '<h2 class="comments">'. t('Comments') .'</h2>'.  $vars['content'];
130
  }
131
}
132
 
133
/**
134
 * Returns the rendered local tasks. The default implementation renders
135
 * them as tabs. Overridden to split the secondary tasks.
136
 *
137
 * @ingroup themeable
138
 */
139
function phptemplate_menu_local_tasks() {
140
  return menu_primary_local_tasks();
141
}
142
 
143
/**
144
 * Returns the themed submitted-by string for the comment.
145
 */
146
function phptemplate_comment_submitted($comment) {
147
  return t('!datetime — !username',
148
    array(
149
      '!username' => theme('username', $comment),
150
      '!datetime' => format_date($comment->timestamp)
151
    ));
152
}
153
 
154
/**
155
 * Returns the themed submitted-by string for the node.
156
 */
157
function phptemplate_node_submitted($node) {
158
  return t('!datetime — !username',
159
    array(
160
      '!username' => theme('username', $node),
161
      '!datetime' => format_date($node->created),
162
    ));
163
}
164
 
165
/**
166
 * Generates IE CSS links for LTR and RTL languages.
167
 */
168
function phptemplate_get_ie_styles() {
169
  global $language;
170
 
171
  $iecss = '<link type="text/css" rel="stylesheet" media="all" href="'. base_path() . path_to_theme() .'/fix-ie.css" />';
172
  if ($language->direction == LANGUAGE_RTL) {
173
    $iecss .= '<style type="text/css" media="all">@import "'. base_path() . path_to_theme() .'/fix-ie-rtl.css";</style>';
174
  }
175
 
176
  return $iecss;
177
}