2003-01-20 21:00:31 +00:00
<?php
2003-08-28 05:35:26 +00:00
// $Id$
2003-01-20 21:00:31 +00:00
2003-02-17 22:33:31 +00:00
function xtemplate_settings() {
2003-05-18 13:22:00 +00:00
$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.");
2003-02-17 22:33:31 +00:00
$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.");
2003-05-18 13:22:00 +00:00
return $output;
2003-02-17 22:33:31 +00:00
}
2003-01-20 21:00:31 +00:00
class Theme_xtemplate extends BaseTheme {
function system($field) {
$system["name"] = "xtemplate";
2003-02-01 19:54:19 +00:00
$system["description"] = "a template driven theme";
2003-01-20 21:00:31 +00:00
return $system[$field];
}
function Theme_xtemplate() {
2003-04-13 16:06:24 +00:00
if (!class_exists("XTemplate")) {
include_once("themes/xtemplate/xtemplate.inc");
}
2003-01-20 21:00:31 +00:00
2003-05-18 13:22:00 +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!
}
2003-03-06 19:38:22 +00:00
function node($node, $main = 0) {
2003-01-20 21:00:31 +00:00
2003-07-09 18:39:46 +00:00
$this->template->assign(array(
2003-08-16 06:31:49 +00:00
"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),
2003-05-26 19:50:39 +00:00
"content" => ($main && $node->teaser) ? $node->teaser : $node->body));
2003-01-20 21:00:31 +00:00
2003-06-06 17:24:24 +00:00
if (module_exist("taxonomy") && ($taxonomy = taxonomy_link("taxonomy terms", $node))) {
2003-02-09 17:39:40 +00:00
$this->template->assign("taxonomy", $this->links($taxonomy));
}
2003-02-01 19:54:19 +00:00
if ($links = link_node($node, $main)) {
$this->template->assign("links", $this->links($links));
}
2003-01-20 21:00:31 +00:00
2003-02-01 19:54:19 +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),
2003-05-26 19:50:39 +00:00
"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");
}
}
2003-02-01 19:54:19 +00:00
function header($title = "") {
2003-01-20 21:00:31 +00:00
$this->template->assign(array(
2003-02-01 19:54:19 +00:00
"title" => ($title ? $title." | ". variable_get("site_name", "drupal") : variable_get("site_name", "drupal") ." | ". variable_get("site_slogan", "")),
"head" => theme_head(),
2003-04-21 14:03:57 +00:00
"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"))
2003-02-01 19:54:19 +00:00
));
2003-05-18 13:22:00 +00:00
2003-02-17 22:33:31 +00:00
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");
}
2003-02-01 19:54:19 +00:00
2003-08-28 05:35:26 +00:00
// 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);
2003-02-01 19:54:19 +00:00
$this->template->parse("header.message");
}
2003-01-20 21:00:31 +00:00
2003-05-18 13:22:00 +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-02-01 19:54:19 +00:00
}
2003-01-20 21:00:31 +00:00
2003-02-01 19:54:19 +00:00
function block($title, $content, $region = "main") {
2003-01-20 21:00:31 +00:00
$this->template->assign(array(
2003-02-01 19:54:19 +00:00
"subject" => $title,
"content" => $content
));
2003-01-20 21:00:31 +00:00
2003-02-01 19:54:19 +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") {
2003-06-03 18:04:47 +00:00
$this->template->assign(array(
"subject" => $title,
"content" => $content));
2003-01-20 21:00:31 +00:00
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() {
2003-05-18 13:22:00 +00:00
2003-02-01 19:54:19 +00:00
ob_start();
2003-05-18 13:22:00 +00:00
if ($this->sidebar == "right") {
theme_blocks("all");
}
else if ($this->sidebar == "both") {
theme_blocks("right");
}
2003-05-15 18:09:19 +00:00
if ($blocks = ob_get_contents()) {
$this->template->assign("blocks", $blocks);
$this->template->parse("footer.blocks");
}
2003-05-18 13:22:00 +00:00
2003-05-15 18:09:19 +00:00
ob_end_clean();
2003-05-18 13:22:00 +00:00
2003-08-28 05:35:26 +00:00
// 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
2003-08-28 05:35:26 +00:00
$this->template->assign("footer", theme_footer());
2003-01-20 21:00:31 +00:00
$this->template->parse("footer");
2003-08-28 05:35:26 +00:00
2003-01-20 21:00:31 +00:00
print $this->template->text("footer");
}
}
?>