chameleon.theme 4.43 KB
Newer Older
Dries's avatar
   
Dries committed
1
2
3
4
5
6
7
8
<?php
// $Id$

function chameleon_help($section) {

  $output = '';

  switch ($section) {
Dries's avatar
   
Dries committed
9
    case 'admin/themes#description':
Dries's avatar
   
Dries committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
      $output = t('A fast PHP theme with different stylesheets.');
      break;
  }

  return $output;
}

function chameleon_settings() {

  /*
  ** Compile a list of the available style sheets:
  */

  $fd = opendir('themes/chameleon');
  while ($file = readdir($fd)) {
Dries's avatar
   
Dries committed
25
26
    if (is_dir("themes/chameleon/$file") && !in_array($file, array('.', '..', 'CVS'))) {
      $files["themes/chameleon/$file/chameleon.css"] = "themes/chameleon/$file/chameleon.css";
Dries's avatar
   
Dries committed
27
28
    }
  }
Dries's avatar
   
Dries committed
29
  closedir($fd);
Dries's avatar
   
Dries committed
30

Dries's avatar
   
Dries committed
31
  $output = form_select(t('CSS stylesheet'), 'chameleon_stylesheet', variable_get('chameleon_stylesheet', 'themes/chameleon/pure/chameleon.css'), $files, t('Selecting a different stylesheet will change the look and feel of your site.'));
Dries's avatar
   
Dries committed
32
33
34
35

  return $output;
}

Dries's avatar
   
Dries committed
36
37
38
39
function chameleon_page($content, $title = NULL, $breadcrumb = NULL) {
  if (isset($title)) {
    drupal_set_title($title);
  }
Dries's avatar
   
Dries committed
40

Dries's avatar
   
Dries committed
41
42
43
  if (isset($breadcrumb)) {
    drupal_set_breadcrumb($breadcrumb);
  }
Dries's avatar
   
Dries committed
44
45
46
47
48

  $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=\"en\" xml:lang=\"en\">\n";
  $output .= "<head>\n";
  $output .= " <title>". ($title ? $title ." | ". variable_get("site_name", "drupal") : variable_get("site_name", "drupal") ." | ". variable_get("site_slogan", "")) ."</title>\n";
Dries's avatar
Dries committed
49
  $output .= drupal_get_html_head();
Dries's avatar
   
Dries committed
50
51
  $output .= " <link rel=\"stylesheet\" type=\"text/css\" href=\"themes/chameleon/common.css\" />\n";
  $output .= " <link rel=\"stylesheet\" type=\"text/css\" href=\"". variable_get("chameleon_stylesheet", "themes/chameleon/pure/chameleon.css") ."\" />\n";
Dries's avatar
   
Dries committed
52
  $output .= "</head>";
53
  $output .= "<body". theme_onload_attribute() .">\n";
Dries's avatar
   
Dries committed
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
  $output .= " <div id=\"header\">";
  $output .= "  <h1 class=\"title\">". l(variable_get("site_name", "drupal"), ""). "</h1>";
  $output .= " </div>\n";

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

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

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

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

Dries's avatar
   
Dries committed
72
73
74
75
  if ($tabs = theme('menu_local_tasks')) {
    $output .= $tabs;
  }

Dries's avatar
   
Dries committed
76
  if ($help = menu_get_active_help()) {
Dries's avatar
   
Dries committed
77
    $output .= "<div id=\"help\">$help</div><hr />";
Dries's avatar
   
Dries committed
78
79
  }

Dries's avatar
   
Dries committed
80
  $output .= theme_status_messages();
Dries's avatar
   
Dries committed
81

Dries's avatar
   
Dries committed
82
83
84
85
  $output .= "\n<!-- begin content -->\n";
  $output .= $content;
  $output .= "\n<!-- end content -->\n";

Dries's avatar
   
Dries committed
86
87
88
89
  if ($footer = variable_get('site_footer', '')) {
    $output .= " <div id=\"footer\">$footer</div>\n";
  }

Dries's avatar
   
Dries committed
90
91
92
93
94
95
96
97
  $output  .= "   </td>\n";

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

  $output .= "  </tr>\n";
  $output .= " </table>\n";
Dries's avatar
   
Dries committed
98

Dries's avatar
   
Dries committed
99
100
101
102
  $output .=  theme_closure();
  $output .= " </body>\n";
  $output .= "</html>\n";

Dries's avatar
   
Dries committed
103
104
105
106
107
108
109
110
  return $output;
}

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

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

  if (!$page) {
Dries's avatar
   
Dries committed
111
    $output .= " <h2 class=\"title\">". ($main ? l($node->title, "node/$node->nid") : $node->title) ."</h2>\n";
Dries's avatar
   
Dries committed
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
  }

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

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

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

  $submitted = array(t("By %author at %date", array('%author' => format_name($node), '%date' => format_date($node->created, 'small'))));

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

  if ($links = link_node($node, $main)) {
    $output .= " <div class=\"links\">". theme('links', array_merge($submitted, $terms, $links)) ."</div>\n";
  }

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

  return $output;
}

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

Dries's avatar
   
Dries committed
142
  $submitted = array(t('By %author at %date', array('%author' => format_name($comment), '%date' => format_date($comment->timestamp. 'small'))));
Dries's avatar
   
Dries committed
143
144
145
  $links = array($link);

  $output  = "<div class=\"comment\">\n";
Dries's avatar
   
Dries committed
146
  $output .= " <h3 class=\"title\">". l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid") ."</h3>\n";
Dries's avatar
   
Dries committed
147
  $output .= " <div class=\"content\">". $comment->comment ."</div>\n";
Dries's avatar
   
Dries committed
148
  $output .= " <div class=\"links\">". theme('links', array_merge($submitted, $links)) ."</div>\n";
Dries's avatar
   
Dries committed
149
150
151
152
153
  $output .= "</div>\n";

  return $output;
}
?>