initial import from onelab svn codebase
[plewww.git] / themes / chameleon / chameleon.theme
1 <?php
2 // $Id: chameleon.theme 144 2007-03-28 07:52:20Z thierry $
3
4 /**
5  * @file
6  * A slim, CSS-driven theme.
7  */
8
9 function chameleon_features() {
10   return array(
11        'toggle_logo',
12        'toggle_favicon',
13        'toggle_name',
14        'toggle_slogan');
15 }
16
17 function chameleon_regions() {
18   return array(
19        'left' => t('left sidebar'),
20        'right' => t('right sidebar')
21   );
22 }
23
24 function chameleon_page($content) {
25   $language = $GLOBALS['locale'];
26
27   if (theme_get_setting('toggle_favicon')) {
28     drupal_set_html_head('<link rel="shortcut icon" href="'. check_url(theme_get_setting('favicon')) .'" type="image/x-icon" />');
29   }
30
31   $title = drupal_get_title();
32
33   $output  = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
34   $output .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"$language\" xml:lang=\"$language\">\n";
35   $output .= "<head>\n";
36   $output .= " <title>". ($title ? strip_tags($title) ." | ". variable_get("site_name", "drupal") : variable_get("site_name", "drupal") ." | ". variable_get("site_slogan", "")) ."</title>\n";
37   $output .= drupal_get_html_head();
38   $output .= theme('stylesheet_import', base_path() . path_to_theme() ."/common.css");
39   $output .= theme_get_styles();
40   $output .= "</head>";
41   $output .= "<body>\n";
42   $output .= " <div id=\"header\">";
43
44   if ($logo = theme_get_setting('logo')) {
45     $output .= "  <a href=\"". base_path() ."\" title=\"". t('Home') ."\"><img src=\"$logo\" alt=\"". t('Home') ."\" /></a>";
46   }
47   if (theme_get_setting('toggle_name')) {
48     $output .= "  <h1 class=\"site-name title\">". l(variable_get('site_name', 'drupal'), ""). "</h1>";
49   }
50   if (theme_get_setting('toggle_slogan')) {
51     $output .= "  <div class=\"site-slogan\">". variable_get('site_slogan', '') ."</div>";
52   }
53
54   $output .= "</div>\n";
55
56   $primary_links = theme('links', menu_primary_links());
57   $secondary_links = theme('links', menu_secondary_links());
58   if (isset($primary_links) || isset($secondary_links)) {
59     $output .= ' <div class="navlinks">';
60     if (isset($primary_links)) {
61       $output .= '<div class="primary">'. $primary_links .'</div>';
62     }
63     if (isset($secondary_links)) {
64       $output .= '<div class="secondary">'. $secondary_links .'</div>';
65     }
66     $output .= " </div>\n";
67   }
68
69   $output .= " <table id=\"content\">\n";
70   $output .= "  <tr>\n";
71
72   if ($blocks = theme_blocks("left")) {
73     $output .= "   <td id=\"sidebar-left\">$blocks</td>\n";
74   }
75
76   $output .= "   <td id=\"main\">\n";
77
78   if ($title) {
79     $output .= theme("breadcrumb", drupal_get_breadcrumb());
80     $output .= "<h2>$title</h2>";
81   }
82
83   if ($tabs = theme('menu_local_tasks')) {
84     $output .= $tabs;
85   }
86
87   $output .= theme('help');
88
89   $output .= theme('status_messages');
90
91   $output .= "\n<!-- begin content -->\n";
92   $output .= $content;
93   $output .= "\n<!-- end content -->\n";
94
95   if ($footer = variable_get('site_footer', '')) {
96     $output .= " <div id=\"footer\">$footer</div>\n";
97   }
98
99   $output  .= "   </td>\n";
100
101   if ($blocks = theme_blocks("right")) {
102     $output .= "   <td id=\"sidebar-right\">$blocks</td>\n";
103   }
104
105   $output .= "  </tr>\n";
106   $output .= " </table>\n";
107
108   $output .=  theme_closure();
109   $output .= " </body>\n";
110   $output .= "</html>\n";
111
112   return $output;
113 }
114
115 function chameleon_node($node, $teaser = 0, $page = 0) {
116
117   $output  = "<div class=\"node". ((!$node->status) ? ' node-unpublished' : '') ."\">\n";
118
119   if (!$page) {
120     $output .= " <h2 class=\"title\">". ($teaser ? l($node->title, "node/$node->nid") : check_plain($node->title)) ."</h2>\n";
121   }
122
123   $output .= " <div class=\"content\">\n";
124
125   if ($teaser && $node->teaser) {
126     $output .= $node->teaser;
127   }
128   else {
129     $output .= $node->body;
130   }
131
132   $output .= " </div>\n";
133
134   $submitted = theme_get_setting("toggle_node_info_$node->type") ? array(t("By %author at %date", array('%author' => theme('username', $node), '%date' => format_date($node->created, 'small')))) : array();
135
136   $terms = array();
137   if (module_exist('taxonomy')) {
138     $terms = taxonomy_link("taxonomy terms", $node);
139   }
140
141   $links = array_merge($submitted, $terms);
142   if ($node->links) {
143     $links = array_merge($links, $node->links);
144   }
145   if (count($links)) {
146     $output .= " <div class=\"links\">". theme('links', $links) ."</div>\n";
147   }
148
149   $output .= "</div>\n";
150
151   return $output;
152 }
153
154 function chameleon_comment($comment, $links = "") {
155   $submitted = array(t('By %author at %date', array('%author' => theme('username', $comment), '%date' => format_date($comment->timestamp. 'small'))));
156
157   $output  = "<div class=\"comment". ($comment->status == COMMENT_NOT_PUBLISHED ? ' comment-unpublished' : '') ."\">\n";
158   $output .= " <h3 class=\"title\">". l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid") ."</h3>\n";
159   $output .= " <div class=\"content\">". $comment->comment ."</div>\n";
160   $output .= " <div class=\"links\">". theme('links', array_merge($submitted, $links)) ."</div>\n";
161   $output .= "</div>\n";
162
163   return $output;
164 }
165
166 function chameleon_help() {
167   if ($help = menu_get_active_help()) {
168     return '<div class="help">'. $help .'</div><hr />';
169   }
170 }
171
172 ?>