chameleon.theme 4.45 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
12
13
14
15
16
17
function chameleon_features() {
  return array(
       'logo',
       'toggle_name',
       'toggle_slogan',
       'toggle_primary_links',
       'toggle_secondary_links');
}

18
function chameleon_page($content) {
19
20
  $language = $GLOBALS['locale'];

21
22
  $title = drupal_get_title();

23
  $output  = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
24
  $output .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"$language\" xml:lang=\"$language\">\n";
25
  $output .= "<head>\n";
26
  $output .= " <title>". ($title ? strip_tags($title) ." | ". variable_get("site_name", "drupal") : variable_get("site_name", "drupal") ." | ". variable_get("site_slogan", "")) ."</title>\n";
27
28
  $output .= drupal_get_html_head();
  $output .= " <link rel=\"stylesheet\" type=\"text/css\" href=\"themes/chameleon/common.css\" />\n";
29
  $output .= theme_get_styles();
30
31
32
33
  $output .= "</head>";
  $output .= "<body". theme_onload_attribute() .">\n";
  $output .= " <div id=\"header\">";

34
  if ($logo = theme_get_setting('logo')) {
35
36
    $output .= "  <a href=\"./\" title=\"Home\"><img src=\"$logo\" alt=\"Home\" /></a>";
  }
37
  if (theme_get_setting('toggle_name')) {
38
39
    $output .= "  <h1 class=\"site-name title\">". l(variable_get('site_name', 'drupal'), ""). "</h1>";
  }
40
  if (theme_get_setting('toggle_slogan')) {
41
42
43
44
45
    $output .= "  <div class=\"site-slogan\">". variable_get('site_slogan', '') ."</div>";
  }

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

46
47
  $primary_links = theme_get_setting('primary_links');
  $secondary_links = theme_get_setting('secondary_links');
48
49
50
51
52
53
54
55
56
57
58
  if ($primary_links || $secondary_links) {
    $output .= ' <div class="navlinks">';
    if ($primary_links) {
      $output .= '<div class="primary">'. $primary_links .'</div>';
    }
    if ($secondary_links) {
      $output .= '<div class="secondary">'. $secondary_links .'</div>';
    }
    $output .= " </div>\n";
  }

59
  $output .= " <table id=\"content\">\n";
60
61
62
63
64
65
66
67
  $output .= "  <tr>\n";

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

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

68
  if ($title) {
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
    $output .= theme("breadcrumb", drupal_get_breadcrumb());
    $output .= "<h2>$title</h2>";
  }

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

  if ($help = menu_get_active_help()) {
    $output .= "<div id=\"help\">$help</div><hr />";
  }

  $output .= theme_status_messages();

  $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;
}

function chameleon_node($node, $main = 0, $page = 0) {

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

  if (!$page) {
112
    $output .= " <h2 class=\"title\">". ($main ? l($node->title, "node/$node->nid") : check_plain($node->title)) ."</h2>\n";
113
114
115
116
117
118
119
120
121
122
123
124
125
  }

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

  if ($main && $node->teaser) {
    $output .= $node->teaser;
  }
  else {
    $output .= $node->body;
  }

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

126
  $submitted = theme_get_setting("toggle_node_info_$node->type") ? array(t("By %author at %date", array('%author' => format_name($node), '%date' => format_date($node->created, 'small')))) : array();
127

128
  $terms = array();
129
130
131
132
  if (module_exist('taxonomy')) {
    $terms = taxonomy_link("taxonomy terms", $node);
  }

133
134
  if ($node->links) {
    $output .= " <div class=\"links\">". theme('links', array_merge($submitted, $terms, $node->links)) ."</div>\n";
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
  }

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

  return $output;
}

function chameleon_comment($comment, $link = "") {

  $submitted = array(t('By %author at %date', array('%author' => format_name($comment), '%date' => format_date($comment->timestamp. 'small'))));
  $links = array($link);

  $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;
}
?>