webmaster@1
|
1 <?php |
webmaster@1
|
2 // $Id: chameleon.theme,v 1.76 2008/01/24 09:42:53 goba Exp $ |
webmaster@1
|
3 |
webmaster@1
|
4 /** |
webmaster@1
|
5 * @file |
webmaster@1
|
6 * A slim, CSS-driven theme which does not depend on a template engine like phptemplate |
webmaster@1
|
7 */ |
webmaster@1
|
8 |
webmaster@1
|
9 /** |
webmaster@1
|
10 * Implementation of hook_theme. Auto-discover theme functions. |
webmaster@1
|
11 */ |
webmaster@1
|
12 function chameleon_theme($existing, $type, $theme, $path) { |
webmaster@1
|
13 return drupal_find_theme_functions($existing, array($theme)); |
webmaster@1
|
14 } |
webmaster@1
|
15 |
webmaster@1
|
16 function chameleon_page($content, $show_blocks = TRUE, $show_messages = TRUE) { |
webmaster@1
|
17 $language = $GLOBALS['language']->language; |
webmaster@1
|
18 $direction = $GLOBALS['language']->direction ? 'rtl' : 'ltr'; |
webmaster@1
|
19 |
webmaster@1
|
20 if (theme_get_setting('toggle_favicon')) { |
webmaster@1
|
21 drupal_set_html_head('<link rel="shortcut icon" href="'. check_url(theme_get_setting('favicon')) .'" type="image/x-icon" />'); |
webmaster@1
|
22 } |
webmaster@1
|
23 |
webmaster@1
|
24 $title = drupal_get_title(); |
webmaster@1
|
25 |
webmaster@1
|
26 // Get blocks before so that they can alter the header (JavaScript, Stylesheets etc.) |
webmaster@1
|
27 $blocks_left = theme_blocks('left'); |
webmaster@1
|
28 $blocks_right = theme_blocks('right'); |
webmaster@1
|
29 |
webmaster@1
|
30 $output = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"; |
webmaster@1
|
31 $output .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"$language\" xml:lang=\"$language\" dir=\"$direction\">\n"; |
webmaster@1
|
32 $output .= "<head>\n"; |
webmaster@1
|
33 $output .= " <title>". ($title ? strip_tags($title) ." | ". variable_get("site_name", "Drupal") : variable_get("site_name", "Drupal") ." | ". variable_get("site_slogan", "")) ."</title>\n"; |
webmaster@1
|
34 $output .= drupal_get_html_head(); |
webmaster@1
|
35 $output .= drupal_get_css(); |
webmaster@1
|
36 $output .= drupal_get_js(); |
webmaster@1
|
37 $output .= "</head>"; |
webmaster@1
|
38 $output .= "<body>\n"; |
webmaster@1
|
39 $output .= " <div id=\"header\">"; |
webmaster@1
|
40 |
webmaster@1
|
41 if ($logo = theme_get_setting('logo')) { |
webmaster@1
|
42 $output .= " <a href=\"". url() ."\" title=\"". t('Home') ."\"><img src=\"$logo\" alt=\"". t('Home') ."\" /></a>"; |
webmaster@1
|
43 } |
webmaster@1
|
44 if (theme_get_setting('toggle_name')) { |
webmaster@1
|
45 $output .= " <h1 class=\"site-name title\">". l(variable_get('site_name', 'drupal'), "") ."</h1>"; |
webmaster@1
|
46 } |
webmaster@1
|
47 if (theme_get_setting('toggle_slogan')) { |
webmaster@1
|
48 $output .= " <div class=\"site-slogan\">". variable_get('site_slogan', '') ."</div>"; |
webmaster@1
|
49 } |
webmaster@1
|
50 |
webmaster@1
|
51 $output .= "</div>\n"; |
webmaster@1
|
52 |
webmaster@1
|
53 $primary_links = theme('links', menu_primary_links(), array('class' => 'links', 'id' => 'navlist')); |
webmaster@1
|
54 $secondary_links = theme('links', menu_secondary_links(), array('class' => 'links', 'id' => 'subnavlist')); |
webmaster@1
|
55 if (isset($primary_links) || isset($secondary_links)) { |
webmaster@1
|
56 $output .= ' <div class="navlinks">'; |
webmaster@1
|
57 if (isset($primary_links)) { |
webmaster@1
|
58 $output .= $primary_links; |
webmaster@1
|
59 } |
webmaster@1
|
60 if (isset($secondary_links)) { |
webmaster@1
|
61 $output .= $secondary_links; |
webmaster@1
|
62 } |
webmaster@1
|
63 $output .= " </div>\n"; |
webmaster@1
|
64 } |
webmaster@1
|
65 |
webmaster@1
|
66 $output .= " <table id=\"content\">\n"; |
webmaster@1
|
67 $output .= " <tr>\n"; |
webmaster@1
|
68 |
webmaster@1
|
69 if ($show_blocks && !empty($blocks_left)) { |
webmaster@1
|
70 $output .= " <td id=\"sidebar-left\">$blocks_left</td>\n"; |
webmaster@1
|
71 } |
webmaster@1
|
72 |
webmaster@1
|
73 $output .= " <td id=\"main\">\n"; |
webmaster@1
|
74 |
webmaster@1
|
75 if ($title) { |
webmaster@1
|
76 $output .= theme("breadcrumb", drupal_get_breadcrumb()); |
webmaster@1
|
77 $output .= "<h2>$title</h2>"; |
webmaster@1
|
78 } |
webmaster@1
|
79 |
webmaster@1
|
80 if ($tabs = theme('menu_local_tasks')) { |
webmaster@1
|
81 $output .= $tabs; |
webmaster@1
|
82 } |
webmaster@1
|
83 |
webmaster@1
|
84 if ($show_messages) { |
webmaster@1
|
85 $output .= theme('status_messages'); |
webmaster@1
|
86 } |
webmaster@1
|
87 |
webmaster@1
|
88 $output .= theme('help'); |
webmaster@1
|
89 |
webmaster@1
|
90 $output .= "\n<!-- begin content -->\n"; |
webmaster@1
|
91 $output .= $content; |
webmaster@1
|
92 $output .= drupal_get_feeds(); |
webmaster@1
|
93 $output .= "\n<!-- end content -->\n"; |
webmaster@1
|
94 |
webmaster@1
|
95 if ($footer = variable_get('site_footer', '')) { |
webmaster@1
|
96 $output .= " <div id=\"footer\">$footer</div>\n"; |
webmaster@1
|
97 } |
webmaster@1
|
98 |
webmaster@1
|
99 $output .= " </td>\n"; |
webmaster@1
|
100 |
webmaster@1
|
101 if ($show_blocks && !empty($blocks_right)) { |
webmaster@1
|
102 $output .= " <td id=\"sidebar-right\">$blocks_right</td>\n"; |
webmaster@1
|
103 } |
webmaster@1
|
104 |
webmaster@1
|
105 $output .= " </tr>\n"; |
webmaster@1
|
106 $output .= " </table>\n"; |
webmaster@1
|
107 |
webmaster@1
|
108 $output .= theme_closure(); |
webmaster@1
|
109 $output .= " </body>\n"; |
webmaster@1
|
110 $output .= "</html>\n"; |
webmaster@1
|
111 |
webmaster@1
|
112 return $output; |
webmaster@1
|
113 } |
webmaster@1
|
114 |
webmaster@1
|
115 function chameleon_node($node, $teaser = 0, $page = 0) { |
webmaster@1
|
116 |
webmaster@1
|
117 $output = "<div class=\"node". ((!$node->status) ? ' node-unpublished' : '') . (($node->sticky) ? ' sticky' : '') ."\">\n"; |
webmaster@1
|
118 |
webmaster@1
|
119 if (!$page) { |
webmaster@1
|
120 $output .= " <h2 class=\"title\">". ($teaser ? l($node->title, "node/$node->nid") : check_plain($node->title)) ."</h2>\n"; |
webmaster@1
|
121 } |
webmaster@1
|
122 |
webmaster@1
|
123 $output .= " <div class=\"content\">\n"; |
webmaster@1
|
124 |
webmaster@1
|
125 if ($teaser && $node->teaser) { |
webmaster@1
|
126 $output .= $node->teaser; |
webmaster@1
|
127 } |
webmaster@1
|
128 elseif (isset($node->body)) { |
webmaster@1
|
129 $output .= $node->body; |
webmaster@1
|
130 } |
webmaster@1
|
131 |
webmaster@1
|
132 $output .= " </div>\n"; |
webmaster@1
|
133 |
webmaster@1
|
134 $submitted['node_submitted'] = theme_get_setting("toggle_node_info_$node->type") ? array( |
webmaster@1
|
135 'title' => t("By !author at @date", array('!author' => theme('username', $node), '@date' => format_date($node->created, 'small'))), |
webmaster@1
|
136 'html' => TRUE) : array(); |
webmaster@1
|
137 |
webmaster@1
|
138 $terms = array(); |
webmaster@1
|
139 if (module_exists('taxonomy')) { |
webmaster@1
|
140 $terms = taxonomy_link("taxonomy terms", $node); |
webmaster@1
|
141 } |
webmaster@1
|
142 |
webmaster@1
|
143 $links = array_merge($submitted, $terms); |
webmaster@1
|
144 if (isset($node->links)) { |
webmaster@1
|
145 $links = array_merge($links, $node->links); |
webmaster@1
|
146 } |
webmaster@1
|
147 if (count($links)) { |
webmaster@1
|
148 $output .= '<div class="links">'. theme('links', $links, array('class' => 'links inline')) ."</div>\n"; |
webmaster@1
|
149 } |
webmaster@1
|
150 |
webmaster@1
|
151 $output .= "</div>\n"; |
webmaster@1
|
152 |
webmaster@1
|
153 return $output; |
webmaster@1
|
154 } |
webmaster@1
|
155 |
webmaster@1
|
156 function chameleon_comment($comment, $node, $links = array()) { |
webmaster@1
|
157 $submitted['comment_submitted'] = array( |
webmaster@1
|
158 'title' => t('By !author at @date', array('!author' => theme('username', $comment), '@date' => format_date($comment->timestamp, 'small'))), |
webmaster@1
|
159 'html' => TRUE); |
webmaster@1
|
160 |
webmaster@1
|
161 $output = "<div class=\"comment". ' '. $status ."\">\n"; |
webmaster@1
|
162 $output .= " <h3 class=\"title\">". l($comment->subject, $_GET['q'], array('fragment' => "comment-$comment->cid")) ."</h3>\n"; |
webmaster@1
|
163 $output .= " <div class=\"content\">". $comment->comment; |
webmaster@1
|
164 if (!empty($signature)) { |
webmaster@1
|
165 $output .= " <div class=\"clear-block\">"; |
webmaster@1
|
166 $output .= "<div>—</div>\n"; |
webmaster@1
|
167 $output .= $signature ."\n"; |
webmaster@1
|
168 $output .= " </div>\n"; |
webmaster@1
|
169 } |
webmaster@1
|
170 $output .= " </div>\n"; |
webmaster@1
|
171 $output .= " <div class=\"links\">". theme('links', array_merge($submitted, $links)) ."</div>\n"; |
webmaster@1
|
172 $output .= "</div>\n"; |
webmaster@1
|
173 |
webmaster@1
|
174 return $output; |
webmaster@1
|
175 } |
webmaster@1
|
176 |
webmaster@1
|
177 function chameleon_help() { |
webmaster@1
|
178 if ($help = menu_get_active_help()) { |
webmaster@1
|
179 return '<div class="help">'. $help .'</div><hr />'; |
webmaster@1
|
180 } |
webmaster@1
|
181 } |
webmaster@1
|
182 |