summaryrefslogtreecommitdiff
path: root/themes/chameleon/chameleon.theme
blob: 8f3a519047e89c751f165a7684b07cf7dcf4f537 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php
// $Id$

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

/**
 * Implementation of hook_theme. Auto-discover theme functions.
 */
function chameleon_theme($existing, $type, $theme, $path) {
  return drupal_find_theme_functions($existing, array($theme));
}

function chameleon_page($content, $show_blocks = TRUE, $show_messages = TRUE) {
  $language = $GLOBALS['language']->language;
  $direction = $GLOBALS['language']->direction ? 'rtl' : 'ltr';

  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" />');
  }

  $title = drupal_get_title();

  // Get blocks before so that they can alter the header (JavaScript, Stylesheets etc.)
  $blocks_left = theme_blocks('left');
  $blocks_right = theme_blocks('right');

  $output  = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
  $output .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"$language\" xml:lang=\"$language\" dir=\"$direction\">\n";
  $output .= "<head>\n";
  $output .= " <title>". ($title ? strip_tags($title) ." | ". variable_get("site_name", "Drupal") : variable_get("site_name", "Drupal") ." | ". variable_get("site_slogan", "")) ."</title>\n";
  $output .= drupal_get_html_head();
  $output .= drupal_get_css();
  $output .= drupal_get_js();
  $output .= "</head>";
  $output .= "<body>\n";
  $output .= " <div id=\"header\">";

  if ($logo = theme_get_setting('logo')) {
    $output .= "  <a href=\"". url() ."\" title=\"". t('Home') ."\"><img src=\"$logo\" alt=\"". t('Home') ."\" /></a>";
  }
  if (theme_get_setting('toggle_name')) {
    $output .= "  <h1 class=\"site-name title\">". l(variable_get('site_name', 'drupal'), "") ."</h1>";
  }
  if (theme_get_setting('toggle_slogan')) {
    $output .= "  <div class=\"site-slogan\">". variable_get('site_slogan', '') ."</div>";
  }

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

  $primary_links = theme('links', menu_primary_links(), array('class' => 'links', 'id' => 'navlist'));
  $secondary_links = theme('links', menu_secondary_links(), array('class' => 'links', 'id' => 'subnavlist'));
  if (isset($primary_links) || isset($secondary_links)) {
    $output .= ' <div class="navlinks">';
    if (isset($primary_links)) {
      $output .= $primary_links;
    }
    if (isset($secondary_links)) {
      $output .= $secondary_links;
    }
    $output .= " </div>\n";
  }

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

  if ($show_blocks && !empty($blocks_left)) {
    $output .= "   <td id=\"sidebar-left\">$blocks_left</td>\n";
  }

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

  if ($title) {
    $output .= theme("breadcrumb", drupal_get_breadcrumb());
    $output .= "<h2>$title</h2>";
  }

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

  if ($show_messages) {
    $output .= theme('status_messages');
  }

  $output .= theme('help');

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

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

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

  if ($show_blocks && !empty($blocks_right)) {
    $output .= "   <td id=\"sidebar-right\">$blocks_right</td>\n";
  }

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

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

  return $output;
}

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

  $output  = "<div class=\"node". ((!$node->status) ? ' node-unpublished' : '') . (($node->sticky) ? ' sticky' : '') ."\">\n";

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

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

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

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

  $submitted['node_submitted'] = theme_get_setting("toggle_node_info_$node->type") ? array(
    'title' => t("By !author at @date", array('!author' => theme('username', $node), '@date' => format_date($node->created, 'small'))),
    'html' => TRUE) : array();

  $terms = array();
  if (module_exists('taxonomy')) {
    $terms = taxonomy_link("taxonomy terms", $node);
  }

  $links = array_merge($submitted, $terms);
  if (isset($node->links)) {
    $links = array_merge($links, $node->links);
  }
  if (count($links)) {
    $output .= '<div class="links">'. theme('links', $links, array('class' => 'links inline')) ."</div>\n";
  }

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

  return $output;
}

function chameleon_comment($comment, $node, $links = array()) {
  $submitted['comment_submitted'] = array(
    'title' => t('By !author at @date', array('!author' => theme('username', $comment), '@date' => format_date($comment->timestamp, 'small'))),
    'html' => TRUE);

  $output  = "<div class=\"comment". ' '. $status ."\">\n";
  $output .= " <h3 class=\"title\">". l($comment->subject, $_GET['q'], array('fragment' => "comment-$comment->cid")) ."</h3>\n";
  $output .= " <div class=\"content\">". $comment->comment;
  if (!empty($signature)) {
    $output .= "  <div class=\"clear-block\">";
    $output .= "<div>—</div>\n";
    $output .= $signature ."\n";
    $output .= "  </div>\n";
  }
  $output .= " </div>\n";
  $output .= " <div class=\"links\">". theme('links', array_merge($submitted, $links)) ."</div>\n";
  $output .= "</div>\n";

  return $output;
}

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