chameleon.theme 4.85 KB
Newer Older
1 2 3
<?php
// $Id$

Dries's avatar
 
Dries committed
4 5 6 7 8
/**
 * @file
 * A slim, CSS-driven theme.
 */

9 10 11
function chameleon_features() {
  return array(
       'logo',
12
       'toggle_favicon',
13
       'toggle_name',
14
       'toggle_slogan');
15 16
}

17 18 19 20 21 22 23
function chameleon_regions() {
  return array(
       'left' => t('left sidebar'),
       'right' => t('right sidebar')
  );
}

24
function chameleon_page($content) {
25 26
  $language = $GLOBALS['locale'];

27 28 29 30
  if (theme_get_setting('toggle_favicon')) {
    drupal_set_html_head('<link rel="shortcut icon" href="'. check_url(theme_get_setting('favicon')) .'" type="image/x-icon" />');
  }

31 32
  $title = drupal_get_title();

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 38
  $output .= drupal_get_html_head();
  $output .= " <link rel=\"stylesheet\" type=\"text/css\" href=\"themes/chameleon/common.css\" />\n";
39
  $output .= theme_get_styles();
40
  $output .= "</head>";
41
  $output .= "<body>\n";
42 43
  $output .= " <div id=\"header\">";

44
  if ($logo = theme_get_setting('logo')) {
45 46
    $output .= "  <a href=\"./\" title=\"Home\"><img src=\"$logo\" alt=\"Home\" /></a>";
  }
47
  if (theme_get_setting('toggle_name')) {
48 49
    $output .= "  <h1 class=\"site-name title\">". l(variable_get('site_name', 'drupal'), ""). "</h1>";
  }
50
  if (theme_get_setting('toggle_slogan')) {
51 52 53 54 55
    $output .= "  <div class=\"site-slogan\">". variable_get('site_slogan', '') ."</div>";
  }

  $output .= "</div>\n";

56 57
  $primary_links = theme('links', menu_primary_links());
  $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 62
      $output .= '<div class="primary">'. $primary_links .'</div>';
    }
63
    if (isset($secondary_links)) {
64 65 66 67 68
      $output .= '<div class="secondary">'. $secondary_links .'</div>';
    }
    $output .= " </div>\n";
  }

69
  $output .= " <table id=\"content\">\n";
70 71 72 73 74 75 76 77
  $output .= "  <tr>\n";

  if ($blocks = theme_blocks("left")) {
    $output .= "   <td id=\"sidebar-left\">$blocks</td>\n";
  }

  $output .= "   <td id=\"main\">\n";

78
  if ($title) {
79 80 81 82 83 84 85 86
    $output .= theme("breadcrumb", drupal_get_breadcrumb());
    $output .= "<h2>$title</h2>";
  }

  if ($tabs = theme('menu_local_tasks')) {
    $output .= $tabs;
  }

87
  $output .= theme('help');
88

89
  $output .= theme('status_messages');
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

  $output .= "\n<!-- begin content -->\n";
  $output .= $content;
  $output .= "\n<!-- end content -->\n";

  if ($footer = variable_get('site_footer', '')) {
    $output .= " <div id=\"footer\">$footer</div>\n";
  }

  $output  .= "   </td>\n";

  if ($blocks = theme_blocks("right")) {
    $output .= "   <td id=\"sidebar-right\">$blocks</td>\n";
  }

  $output .= "  </tr>\n";
  $output .= " </table>\n";

  $output .=  theme_closure();
  $output .= " </body>\n";
  $output .= "</html>\n";

  return $output;
}

115
function chameleon_node($node, $teaser = 0, $page = 0) {
116 117 118 119

  $output  = "<div class=\"node\">\n";

  if (!$page) {
120
    $output .= " <h2 class=\"title\">". ($teaser ? l($node->title, "node/$node->nid") : check_plain($node->title)) ."</h2>\n";
121 122 123 124
  }

  $output .= " <div class=\"content\">\n";

125
  if ($teaser && $node->teaser) {
126 127 128 129 130 131 132 133
    $output .= $node->teaser;
  }
  else {
    $output .= $node->body;
  }

  $output .= " </div>\n";

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 138 139 140
  if (module_exist('taxonomy')) {
    $terms = taxonomy_link("taxonomy terms", $node);
  }

141
  $links = array_merge($submitted, $terms);
142
  if ($node->links) {
143 144 145
    $links = array_merge($links, $node->links);
  }
  if (count($links)) {
Dries's avatar
Dries committed
146
    $output .= " <div class=\"links\">". theme('links', $links) ."</div>\n";
147 148 149 150 151 152 153
  }

  $output .= "</div>\n";

  return $output;
}

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 158 159 160 161 162 163 164

  $output  = "<div class=\"comment\">\n";
  $output .= " <h3 class=\"title\">". l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid") ."</h3>\n";
  $output .= " <div class=\"content\">". $comment->comment ."</div>\n";
  $output .= " <div class=\"links\">". theme('links', array_merge($submitted, $links)) ."</div>\n";
  $output .= "</div>\n";

  return $output;
}
165 166 167 168 169 170 171

function chameleon_help() {
  if ($help = menu_get_active_help()) {
    return '<div class="help">'. $help .'</div><hr />';
  }
}

172
?>