| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* A slim, CSS-driven theme which does not depend on a template engine like phptemplate
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_theme. Auto-discover theme functions.
|
| 11 |
*/
|
| 12 |
function chameleon_theme($existing, $type, $theme, $path) {
|
| 13 |
return drupal_find_theme_functions($existing, array($theme));
|
| 14 |
}
|
| 15 |
|
| 16 |
function chameleon_page($content) {
|
| 17 |
$show_blocks = $content['#show_blocks'];
|
| 18 |
$language = $GLOBALS['language']->language;
|
| 19 |
$direction = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
|
| 20 |
|
| 21 |
if (theme_get_setting('toggle_favicon')) {
|
| 22 |
drupal_set_html_head('<link rel="shortcut icon" href="' . check_url(theme_get_setting('favicon')) . '" type="image/x-icon" />');
|
| 23 |
}
|
| 24 |
|
| 25 |
$title = drupal_get_title();
|
| 26 |
$rdf_namespaces = drupal_get_rdf_namespaces();
|
| 27 |
|
| 28 |
// Get blocks before so that they can alter the header (JavaScript, Stylesheets etc.)
|
| 29 |
$blocks_left = drupal_render($content['left']);
|
| 30 |
$blocks_right = drupal_render($content['right']);
|
| 31 |
|
| 32 |
$output = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML+RDFa 1.0//EN\" \"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd\">\n";
|
| 33 |
$output .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"$language\" dir=\"$direction\"\n";
|
| 34 |
$output .= " $rdf_namespaces>\n";
|
| 35 |
$output .= "<head profile=\"http://ns.inria.fr/grddl/rdfa/\">\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 .= drupal_get_css();
|
| 39 |
$output .= drupal_get_js();
|
| 40 |
$output .= "</head>";
|
| 41 |
$output .= "<body>\n";
|
| 42 |
$output .= " <div id=\"header\">";
|
| 43 |
|
| 44 |
if ($logo = theme_get_setting('logo')) {
|
| 45 |
$output .= " <a href=\"" . url() . "\" 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 |
$main_menu = theme('links', menu_main_menu(), array('class' => 'links', 'id' => 'navlist'));
|
| 57 |
$secondary_menu = theme('links', menu_secondary_menu(), array('class' => 'links', 'id' => 'subnavlist'));
|
| 58 |
if (isset($main_menu) || isset($secondary_menu)) {
|
| 59 |
$output .= ' <div class="navlinks">';
|
| 60 |
if (isset($main_menu)) {
|
| 61 |
$output .= $main_menu;
|
| 62 |
}
|
| 63 |
if (isset($secondary_menu)) {
|
| 64 |
$output .= $secondary_menu;
|
| 65 |
}
|
| 66 |
$output .= " </div>\n";
|
| 67 |
}
|
| 68 |
|
| 69 |
$output .= " <table id=\"content\">\n";
|
| 70 |
$output .= " <tr>\n";
|
| 71 |
|
| 72 |
if ($show_blocks && !empty($blocks_left)) {
|
| 73 |
$output .= " <td id=\"sidebar-left\">$blocks_left</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 |
if ($content['#show_messages']) {
|
| 88 |
$output .= theme('status_messages');
|
| 89 |
}
|
| 90 |
|
| 91 |
$output .= theme('help');
|
| 92 |
|
| 93 |
$output .= "\n<!-- begin content -->\n";
|
| 94 |
$output .= drupal_render($content['content']);
|
| 95 |
$output .= drupal_get_feeds();
|
| 96 |
$output .= "\n<!-- end content -->\n";
|
| 97 |
|
| 98 |
if ($footer = variable_get('site_footer', '')) {
|
| 99 |
$output .= " <div id=\"footer\">$footer</div>\n";
|
| 100 |
}
|
| 101 |
|
| 102 |
$output .= " </td>\n";
|
| 103 |
|
| 104 |
if ($show_blocks && !empty($blocks_right)) {
|
| 105 |
$output .= " <td id=\"sidebar-right\">$blocks_right</td>\n";
|
| 106 |
}
|
| 107 |
|
| 108 |
$output .= " </tr>\n";
|
| 109 |
$output .= " </table>\n";
|
| 110 |
|
| 111 |
$output .= theme_closure();
|
| 112 |
$output .= " </body>\n";
|
| 113 |
$output .= "</html>\n";
|
| 114 |
|
| 115 |
return $output;
|
| 116 |
}
|
| 117 |
|
| 118 |
function chameleon_node($node, $teaser = 0) {
|
| 119 |
$teaser = $node['#teaser'];
|
| 120 |
$node = $node['#node'];
|
| 121 |
|
| 122 |
$output = "<div class=\"node" . ((!$node->status) ? ' node-unpublished' : '') . (($node->sticky) ? ' sticky' : '') . "\">\n";
|
| 123 |
|
| 124 |
// Check if we're on a node page.
|
| 125 |
if (!menu_get_object()) {
|
| 126 |
$output .= " <h2 class=\"title\">" . ($teaser ? l($node->title, "node/$node->nid") : check_plain($node->title)) . "</h2>\n";
|
| 127 |
}
|
| 128 |
|
| 129 |
$output .= " <div class=\"content\">\n";
|
| 130 |
|
| 131 |
// Render the node body (or teaser).
|
| 132 |
$output .= drupal_render($node->content['body']);
|
| 133 |
|
| 134 |
$output .= " </div>\n";
|
| 135 |
|
| 136 |
$submitted = '';
|
| 137 |
if (variable_get('node_submitted_' . $node->type, TRUE)) {
|
| 138 |
$submitted = t("By !author at @date", array('!author' => theme('username', $node), '@date' => format_date($node->created, 'small')));
|
| 139 |
}
|
| 140 |
|
| 141 |
$terms = '';
|
| 142 |
if (!empty($node->content['links']['terms'])) {
|
| 143 |
$terms = drupal_render($node->content['links']['terms']);
|
| 144 |
}
|
| 145 |
|
| 146 |
$links = '';
|
| 147 |
if (!empty($node->content['links'])) {
|
| 148 |
$links = drupal_render($node->content['links']);
|
| 149 |
}
|
| 150 |
|
| 151 |
if (!empty($terms) || !empty($links)) {
|
| 152 |
$output .= '<div class="links">' . $terms . $links . $submitted . "</div>\n";
|
| 153 |
}
|
| 154 |
|
| 155 |
// Render comments.
|
| 156 |
if (!empty($node->content['comments'])) {
|
| 157 |
$comments = drupal_render($node->content['comments']);
|
| 158 |
}
|
| 159 |
else {
|
| 160 |
$comments = '';
|
| 161 |
}
|
| 162 |
|
| 163 |
// Render remaining parts of the node content.
|
| 164 |
$output .= drupal_render($node->content);
|
| 165 |
|
| 166 |
$output .= "</div>\n";
|
| 167 |
|
| 168 |
$output .= $comments;
|
| 169 |
|
| 170 |
return $output;
|
| 171 |
}
|
| 172 |
|
| 173 |
function chameleon_comment($comment, $node, $links = array()) {
|
| 174 |
$submitted['comment_submitted'] = array(
|
| 175 |
'title' => t('By !author at @date', array('!author' => theme('username', $comment), '@date' => format_date($comment->timestamp, 'small'))),
|
| 176 |
'html' => TRUE);
|
| 177 |
|
| 178 |
$output = "<div class=\"comment\">\n";
|
| 179 |
$output .= " <h3 class=\"title\">" . l($comment->subject, $_GET['q'], array('fragment' => "comment-$comment->cid")) . "</h3>\n";
|
| 180 |
$output .= " <div class=\"content\">" . $comment->comment;
|
| 181 |
if (!empty($comment->signature)) {
|
| 182 |
$output .= " <div class=\"clearfix\">";
|
| 183 |
$output .= "<div>—</div>\n";
|
| 184 |
$output .= $comment->signature . "\n";
|
| 185 |
$output .= " </div>\n";
|
| 186 |
}
|
| 187 |
$output .= " </div>\n";
|
| 188 |
$output .= " <div class=\"links\">" . theme('links', array_merge($submitted, $links)) . "</div>\n";
|
| 189 |
$output .= "</div>\n";
|
| 190 |
|
| 191 |
return $output;
|
| 192 |
}
|
| 193 |
|
| 194 |
function chameleon_help() {
|
| 195 |
if ($help = menu_get_active_help()) {
|
| 196 |
return '<div class="help">' . $help . '</div><hr />';
|
| 197 |
}
|
| 198 |
}
|
| 199 |
|