You are here

chameleon.theme in Drupal 5

Same filename and directory in other branches
  1. 4 themes/chameleon/chameleon.theme
  2. 6 themes/chameleon/chameleon.theme

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

File

themes/chameleon/chameleon.theme
View source
<?php

/**
 * @file
 * A slim, CSS-driven theme which does not depend on a template engine like phptemplate
 */
function chameleon_features() {
  return array(
    'toggle_logo',
    'toggle_favicon',
    'toggle_name',
    'toggle_slogan',
  );
}
function chameleon_regions() {
  return array(
    'left' => t('left sidebar'),
    'right' => t('right sidebar'),
  );
}
function chameleon_page($content, $show_blocks = TRUE) {
  $language = $GLOBALS['locale'];
  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" />');
  }
  drupal_add_css(path_to_theme() . '/common.css', 'theme');
  $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}\">\n";
  $output .= "<head>\n";
  $output .= drupal_get_html_head();
  $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_css();
  $output .= drupal_get_js();
  $output .= "</head>";
  $output .= "<body>\n";
  $output .= " <div id=\"header\">";
  if ($logo = theme_get_setting('logo')) {
    $output .= "  <a href=\"" . base_path() . "\" 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;
  }
  $output .= theme('help');
  $output .= theme('status_messages');
  $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' : '') . "\">\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;
  }
  else {
    $output .= $node->body;
  }
  $output .= " </div>\n";
  if (theme_get_setting("toggle_node_info_{$node->type}")) {
    $submitted['node_submitted'] = array(
      'title' => t("By !author at @date", array(
        '!author' => theme('username', $node),
        '@date' => format_date($node->created, 'small'),
      )),
      'html' => TRUE,
    );
  }
  else {
    $submitted['node_submitted'] = array();
  }
  $terms = array();
  if (module_exists('taxonomy')) {
    $terms = taxonomy_link("taxonomy terms", $node);
  }
  $links = array_merge($submitted, $terms);
  if ($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, $links = "") {
  $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" . ($comment->status == COMMENT_NOT_PUBLISHED ? ' comment-unpublished' : '') . "\">\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;
}
function chameleon_help() {
  if ($help = menu_get_active_help()) {
    return '<div class="help">' . $help . '</div><hr />';
  }
}

Functions

Namesort descending Description
chameleon_comment
chameleon_features @file A slim, CSS-driven theme which does not depend on a template engine like phptemplate
chameleon_help
chameleon_node
chameleon_page
chameleon_regions