Theme system * @see themeable */ /** * Hook Help - returns theme specific help and information. * * @param section defines the @a section of the help to be returned. * * @return a string containing the help output. */ function theme_help($section) { $ouptout = ""; switch ($section) { case 'admin/system/themes#description': $output = t("The base theme"); break; } return $output; } /** * Initialized the theme system. * * @return the name of the currently selected theme. */ function init_theme() { global $user; $themes = list_themes(); $name = $user->theme ? $user->theme : variable_get("theme_default", 0); $theme->path = ""; $theme->name = ""; if (is_object($themes[$name])) { include_once($themes[$name]->filename); $theme->path = dirname($themes[$name]->filename); $theme->name = $name; } return $theme; } /** * Provides a list of currently available themes. * * @param $refresh * * @return an array of the currently available themes. */ function list_themes($refresh = 0) { static $list; if ($refresh) { unset($list); } if (!$list) { $list = array(); $result = db_query("SELECT * FROM {system} where type = 'theme' AND status = '1' ORDER BY name"); while ($theme = db_fetch_object($result)) { if (file_exists($theme->filename)) { $list[$theme->name] = $theme; } } } return $list; } /** * External interface of the theme system to all other modules, and core files. * * All requests for themed functions must go through this function. It examines * the request and routes it to the appropriate theme function. If the current * theme does not implement the requested function, then the base theme function * is called. Example: @verbatim $header_text = theme("header"); @endverbatim * * @return themed output. */ function theme() { global $theme; $args = func_get_args(); $function = array_shift($args); if (($theme->name != "") && (function_exists($theme->name ."_". $function))) { return call_user_func_array($theme->name ."_". $function, $args); } elseif (function_exists("theme_". $function)){ return call_user_func_array("theme_". $function, $args); } } /** * Returns the path to the currently selected theme. * * @return the path to the the currently selected theme. */ function path_to_theme() { global $theme; return $theme->path; } /** * @defgroup themeable Themeable functions * @{ * * Themeable functions - functions that can be styled differently in themes. * * @see theme * @see theme.inc */ /** * Returns the theme header. * * @return a string containing the @a header output. */ function theme_header() { global $base_url; $output = "\n"; $output .= ""; $output .= "
"; $output .= "";
$output .= theme("box", t("Navigation"), @implode(" ", link_page())); $output .= theme("blocks", "all"); $output .= " | ";
$output .= theme("breadcrumb", drupal_get_breadcrumb());
$output .= "" . drupal_get_title() . ""; if ($help = menu_get_active_help()) { $output .= "$help"; } return $output; } /** * Returns an entire Drupal page displaying the supplied content. * * @param $content a string containing the content to display * @param $title (optional) page title (\\ $node->titleby ". format_name($node); } else { $output = "by ". format_name($node); } if (count($terms)) { $output .= " (". print theme("links", $terms) .")"; } if ($main && $node->teaser) { $output .= $node->teaser; } else { $output .= $node->body; } if ($links = link_node($node, $main)) { $output .= " [ ". print theme("links", $links) ." ]"; } $output .= " "; return $output; } /** * Returns themed form element. * * @param $title the form element's title * @param $value the form element's data * @param $description the form element's description or explanation * * @return a string containing the @a node output. */ function theme_form_element($title, $value, $description = 0) { return " ". ($title ? " \n";
}
/**
* Returns themed table.
*
* @param $header
* @param $rows
*
* @return a string containing the @a node output.
*/
function theme_table($header, $rows) {
$output = "" : "") . $value . ($description ? " $description " : "") ."$subject$content "; return $output; } /** * Returns a themed block. * * You can style your blocks by defining .block (all blocks), * .block-module (all blocks of module module), and * \#block-module-delta (specific block of module module * with delta delta) in your theme's CSS. * * @param $block object "indexed with" fields from database table 'blocks' * ($block->module, $block->delta, $block->region, ...) and fields returned by * module_block("view") ($block->subject, $block->content, ...). * * @return a string containing the @a box output. */ function theme_block($block) { $output = "module\" id=\"block-$block->module-$block->delta\">";
$output .= " ";
return $output;
}
/**
* Returns themed page footer.
*
* @return a string containing the @a footer output.
*/
function theme_footer() {
$output = "$block->subject"; $output .= "$block->content ";
$output .= " |