chameleon.theme

A slim, CSS-driven theme which does not depend on a template engine like phptemplate

File

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