drupal/themes/xtemplate/xtemplate.theme

171 lines
5.8 KiB
Plaintext
Raw Normal View History

2003-01-20 21:00:31 +00:00
<?php
// $Id$
2003-01-20 21:00:31 +00:00
function xtemplate_settings() {
$output = form_select("Sidebar placement", "xtemplate_sidebar", variable_get("xtemplate_sidebar", "right"), array("none" => t("No sidebars"), "left" => t("Sidebar on the left"), "right" => t("Sidebar on the right"), "both" => t("Sidebar on the left and the right")));
$output .= form_textarea("Message on front page", "xtemplate_message", variable_get("xtemplate_message", "edit message"), 70, 6, "This text will be displayed on the front page. It can be used to display a mission statement, announcement or site description..");
2003-05-11 06:44:49 +00:00
$output .= form_textarea("Primary links", "xtemplate_primary_links", variable_get("xtemplate_primary_links", l("edit primary links", "admin/system/themes/xtemplate")), 70, 6, "The primary links.");
$output .= form_textarea("Secondary links", "xtemplate_secondary_links", variable_get("xtemplate_secondary_links", l("edit secondary links", "admin/system/themes/xtemplate")), 70, 6, "The secondary links.");
$output .= form_select("Search box", "xtemplate_search_box", variable_get("xtemplate_search_box", 0), array(t("Disabled"), t("Enabled")), "Show a search box in the upper right corner.");
return $output;
}
2003-01-20 21:00:31 +00:00
class Theme_xtemplate extends BaseTheme {
function system($field) {
$system["name"] = "xtemplate";
$system["description"] = "a template driven theme";
2003-01-20 21:00:31 +00:00
return $system[$field];
}
function Theme_xtemplate() {
if (!class_exists("XTemplate")) {
include_once("themes/xtemplate/xtemplate.inc");
}
2003-01-20 21:00:31 +00:00
$this->sidebar = variable_get("xtemplate_sidebar", "right");
2003-01-20 21:00:31 +00:00
$this->template = new XTemplate("themes/xtemplate/xtemplate.xtmpl");
$this->template->SetNullBlock(" "); // "" doesnt work!
}
function node($node, $main = 0) {
2003-01-20 21:00:31 +00:00
$this->template->assign(array(
"link" => node_url($node),
2003-01-20 21:00:31 +00:00
"title" => ucfirst($node->title),
"author" => format_name($node),
"date" => format_date($node->created),
"content" => ($main && $node->teaser) ? $node->teaser : $node->body));
2003-01-20 21:00:31 +00:00
if (module_exist("taxonomy") && ($taxonomy = taxonomy_link("taxonomy terms", $node))) {
$this->template->assign("taxonomy", $this->links($taxonomy));
}
if ($links = link_node($node, $main)) {
$this->template->assign("links", $this->links($links));
}
2003-01-20 21:00:31 +00:00
$this->template->parse("node");
print $this->template->text("node");
$this->template->reset("node");
2003-01-20 21:00:31 +00:00
}
function comment($comment, $link = 0) {
$this->template->assign(array (
"title" => ucfirst($comment->subject),
"author" => format_name($comment),
"date" => format_date($comment->timestamp),
"content" => $comment->comment,
2003-01-20 21:00:31 +00:00
"links" => $link));
if ($comment->new) {
$this->template->parse("comment_new");
print $this->template->text("comment_new");
$this->template->reset("comment_new");
}
else {
$this->template->parse("comment_old");
print $this->template->text("comment_old");
$this->template->reset("comment_old");
}
}
function header($title = "") {
2003-01-20 21:00:31 +00:00
$this->template->assign(array(
"title" => ($title ? $title." | ". variable_get("site_name", "drupal") : variable_get("site_name", "drupal") ." | ". variable_get("site_slogan", "")),
"head" => theme_head(),
"onload_attributes" => theme_onload_attribute(),
2003-05-11 06:44:49 +00:00
"primary_links" => variable_get("xtemplate_primary_links", l("edit primary links", "admin/system/themes/xtemplate")),
"secondary_links" => variable_get("xtemplate_secondary_links", l("edit secondary links", "admin/system/themes/xtemplate"))
));
if (variable_get("xtemplate_search_box", 1)) {
$this->template->assign(array(
//"search" => search_form(),
"search_url" => url("search"),
"search_button_text" => t("Search")
));
$this->template->parse("header.search_box");
}
// only parse the message block if we are on the frontpage ...
if ($_GET["q"] == variable_get("site_frontpage", "node") && ($message = variable_get("xtemplate_message", "edit message"))) {
$this->template->assign("header_message", $message);
$this->template->parse("header.message");
}
2003-01-20 21:00:31 +00:00
ob_start();
if ($this->sidebar == "left") {
theme_blocks("all");
}
else if ($this->sidebar == "both") {
theme_blocks("left");
}
if ($blocks = ob_get_contents()) {
$this->template->assign("blocks", $blocks);
$this->template->parse("header.blocks");
}
ob_end_clean();
2003-01-20 21:00:31 +00:00
$this->template->parse("header");
print $this->template->text("header");
}
2003-01-20 21:00:31 +00:00
function block($title, $content, $region = "main") {
2003-01-20 21:00:31 +00:00
$this->template->assign(array(
"subject" => $title,
"content" => $content
));
2003-01-20 21:00:31 +00:00
$this->template->parse("block");
print $this->template->text("block");
$this->template->reset("block");
2003-01-20 21:00:31 +00:00
}
function box($title, $content, $region = "main") {
- Bugfix: made request_uri() rewrite ( and ) with their entity equivalents to avoid XSS attacks! Patch by Al, Moshe, Marco, Kjartan and me. - Bugfix: the admin module does now import drupal.css prior to admin.css. Patch by me. - Bugfix: the admin module was still emitting a <base href=""> tag. I removed this as it is been taken care of by theme_head(); Patch by me. - Bugfix: made the tracker module's pager only consider published pages. Patch by Moshe. - Bugfix: cured some typos in the comment module's help function. Patch by Marco. - Bugfix: fixed a typo in the pager_display() that caused optional attributes to be discarded. - Bugfix: made the Xtemplate emit empty boxes like any other theme does. Patch by Al. - Bugfix: fixed broken link on the statistics module's log page. Reported by Kjartan. - CSS improvements: made the HTML output emitted by the tracker module look nicer. Patch by Moshe and Al. - CSS improvements: added CSS classes for form elements. Patch by Al. - CSS improvements: added a vertical gap between the last form item and the submit button. Patch by Al. Note that Opera 6 is not picking up this CSS but apparently others browsers such as Konqueror do. - Xtemplate improvements: changed the color of the selected day in the archive module's calendar. Patch by Al. - Usability improvements: made the "birthday" field of the profile module look nicer. Patch by Al. ------ - TODO: it might be a good idea to emit the following meta tag in the theme_head() function: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> Currently, some themes (and modules!) emit this while others don't. This would also make it possible to change the charset site-wide. - TODO: now we added support for td.dark and td.light to drupal.css, maybe it can be removed from admin.css as well as xtemplate.css?
2003-06-03 18:04:47 +00:00
$this->template->assign(array(
"subject" => $title,
"content" => $content));
2003-01-20 21:00:31 +00:00
- Bugfix: made request_uri() rewrite ( and ) with their entity equivalents to avoid XSS attacks! Patch by Al, Moshe, Marco, Kjartan and me. - Bugfix: the admin module does now import drupal.css prior to admin.css. Patch by me. - Bugfix: the admin module was still emitting a <base href=""> tag. I removed this as it is been taken care of by theme_head(); Patch by me. - Bugfix: made the tracker module's pager only consider published pages. Patch by Moshe. - Bugfix: cured some typos in the comment module's help function. Patch by Marco. - Bugfix: fixed a typo in the pager_display() that caused optional attributes to be discarded. - Bugfix: made the Xtemplate emit empty boxes like any other theme does. Patch by Al. - Bugfix: fixed broken link on the statistics module's log page. Reported by Kjartan. - CSS improvements: made the HTML output emitted by the tracker module look nicer. Patch by Moshe and Al. - CSS improvements: added CSS classes for form elements. Patch by Al. - CSS improvements: added a vertical gap between the last form item and the submit button. Patch by Al. Note that Opera 6 is not picking up this CSS but apparently others browsers such as Konqueror do. - Xtemplate improvements: changed the color of the selected day in the archive module's calendar. Patch by Al. - Usability improvements: made the "birthday" field of the profile module look nicer. Patch by Al. ------ - TODO: it might be a good idea to emit the following meta tag in the theme_head() function: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> Currently, some themes (and modules!) emit this while others don't. This would also make it possible to change the charset site-wide. - TODO: now we added support for td.dark and td.light to drupal.css, maybe it can be removed from admin.css as well as xtemplate.css?
2003-06-03 18:04:47 +00:00
$this->template->parse("box");
print $this->template->text("box");
$this->template->reset("box");
2003-01-20 21:00:31 +00:00
}
function footer() {
ob_start();
if ($this->sidebar == "right") {
theme_blocks("all");
}
else if ($this->sidebar == "both") {
theme_blocks("right");
}
if ($blocks = ob_get_contents()) {
$this->template->assign("blocks", $blocks);
$this->template->parse("footer.blocks");
}
ob_end_clean();
// only parse the footer block if site_footer is set
if ($footer_message = variable_get("site_footer", FALSE)) {
$this->template->assign("footer_message", $footer_message);
$this->template->parse("footer.message");
}
2003-01-20 21:00:31 +00:00
$this->template->assign("footer", theme_footer());
2003-01-20 21:00:31 +00:00
$this->template->parse("footer");
2003-01-20 21:00:31 +00:00
print $this->template->text("footer");
}
}
?>