summaryrefslogtreecommitdiff
path: root/includes/theme.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/theme.inc')
-rw-r--r--includes/theme.inc138
1 files changed, 121 insertions, 17 deletions
diff --git a/includes/theme.inc b/includes/theme.inc
index 8d6f84468..3e8af9546 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -128,6 +128,29 @@ function theme_node($node, $main) {
return $output;
}
+function _theme_table_cell($cell, $header = 0) {
+ if (is_array($cell)) {
+ $data = $cell["data"];
+ foreach ($cell as $key => $value) {
+ if ($key != "data") {
+ $attributes .= " $key=\"$value\"";
+ }
+ }
+ }
+ else {
+ $data = $cell;
+ }
+
+ if ($header) {
+ $output = "<th$attributes>$data</th>";
+ }
+ else {
+ $output = "<td$attributes>$data</td>";
+ }
+
+ return $output;
+}
+
/**
Returns themed table.
@@ -224,7 +247,7 @@ function theme_box($subject, $content, $region = "main") {
**/
function theme_block($block) {
$output = "<div class=\"block block-$block->module\" id=\"block-$block->module-$block->delta\">";
- $output .= " <h2>$block->subject</h2>";
+ $output .= " <h3>$block->subject</h3>";
$output .= " <div class=\"content\">$block->content</div>";
$output .= "</div>";
return $output;
@@ -308,7 +331,7 @@ function theme_head($main = 0) {
/**
Execute hook _footer() which is run at the end of the page right
- before the \</body> tag.
+ before the </body> tag.
@param $main (optional)
@@ -358,28 +381,109 @@ function theme_blocks($region) {
}
return $output;
}
-/** @} End of defgroup themeable **/
-function _theme_table_cell($cell, $header = 0) {
- if (is_array($cell)) {
- $data = $cell["data"];
- foreach ($cell as $key => $value) {
- if ($key != "data") {
- $attributes .= " $key=\"$value\"";
+/**
+ 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;
+}
+
+/**
+ 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;
}
}
}
- else {
- $data = $cell;
+
+ return $list;
+}
+
+/**
+ 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;
}
- if ($header) {
- $output = "<th$attributes>$data</th>";
+ return $theme;
+}
+
+/**
+ 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;
+}
+
+/**
+ 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 the path to the the currently selected theme.
+**/
+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);
}
- else {
- $output = "<td$attributes>$data</td>";
+ elseif (function_exists("theme_". $function)){
+ return call_user_func_array("theme_". $function, $args);
}
-
- return $output;
}
+
+/** @} End of defgroup theme_system **/
?>