template = new XTemplate('xtemplate.xtmpl', 'themes/xtemplate/' . $template_directory); $GLOBALS["xtemplate"]->template->SetNullBlock(" "); // "" doesnt work! function xtemplate_settings() { /* ** Compile a list of the available style sheets: */ $fd = opendir('themes/xtemplate'); while ($file = readdir($fd)) { if (is_dir("themes/xtemplate/$file") && !in_array($file, array('.', '..', 'CVS'))) { $files[$file] = $file; } } closedir($fd); $template_directory = variable_get('xtemplate_template', 'default'); $group = form_select(t('Template'), 'xtemplate_template', variable_get('xtemplate_template', 'default'), $files, t('Selecting a different template will change the look and feel of your site. To create a new template, create a new directory under themes/xtemplate and copy the contents of an existing template (e.g. themes/xtemplate/default) into it. The new template will automatically become available in the selection menu and will be identified by its directory name.')); $output = form_group(t('Template selection'), $group); $group = form_textarea(t('Logo'), 'xtemplate_logo', variable_get('xtemplate_logo', "\"Logo\""), 70, 4, t('The HTML code for displaying the logo.')); $group .= form_textarea(t('Primary links'), 'xtemplate_primary_links', variable_get('xtemplate_primary_links', l('edit primary links', 'admin/system/themes/xtemplate')), 70, 8, t('The HTML code for the primary links.')); $group .= form_textarea(t('Secondary links'), 'xtemplate_secondary_links', variable_get('xtemplate_secondary_links', l('edit secondary links', 'admin/system/themes/xtemplate')), 70, 8, t('The HTML code for the secondary links.')); $group .= form_textarea(t('Message on front page'), 'xtemplate_mission', variable_get('xtemplate_mission', 'edit mission'), 70, 6, t('This text will be displayed on the front page. It can be used to display a mission statement, announcement or site description..')); $group .= form_radios(t('Search box'), 'xtemplate_search_box', variable_get('xtemplate_search_box', 0), array(t('Disabled'), t('Enabled')), t('Show a search box in the upper right corner.')); $output .= form_group(t('Header settings'), $group); $group = form_checkbox(t('Display pictures with posts'), 'xtemplate_picture_node', 1, variable_get('xtemplate_picture_node', 0), t('Display individualized pictures identifying users with posts they start.')); $group .= form_checkbox(t('Display pictures with comments'), 'xtemplate_picture_comment', 1, variable_get('xtemplate_picture_comment', 0), t('Display individualized pictures identifying users with their comments.')); $output .= form_group(t('Avatar settings'), $group); return $output; } function xtemplate_help($section) { $output = ''; switch ($section) { case 'admin/system/themes#description': $output = t('A template driven theme'); break; } return $output; } function xtemplate_node($node, $main = 0, $page = 0) { global $xtemplate; $xtemplate->template->assign(array( "submitted" => t("Submitted by %a on %b.", array("%a" => format_name($node), "%b" => format_date($node->created))), "link" => url("node/view/$node->nid"), "title" => $node->title, "author" => format_name($node), "date" => format_date($node->created), "static" => ($main && $node->static) ? 'static' : '', "content" => ($main && $node->teaser) ? $node->teaser : $node->body)); if ($page == 0) { $xtemplate->template->parse("node.title"); } if ($picture = theme('user_picture', $node)) { $xtemplate->template->assign("picture", $picture); $xtemplate->template->parse("node.picture"); } if (module_exist("taxonomy") && ($taxonomy = taxonomy_link("taxonomy terms", $node))) { $xtemplate->template->assign("taxonomy", theme_links($taxonomy)); $xtemplate->template->parse("node.taxonomy"); } if ($links = link_node($node, $main)) { $xtemplate->template->assign("links", theme_links($links)); $xtemplate->template->parse("node.links"); } $xtemplate->template->parse("node"); $output = $xtemplate->template->text("node"); $xtemplate->template->reset("node"); return $output; } function xtemplate_comment($comment, $links = 0) { global $xtemplate; $xtemplate->template->assign(array ( "new" => t("new"), "submitted" => t("Submitted by %a on %b.", array("%a" => format_name($comment), "%b" => format_date($comment->timestamp))), "title" => $comment->subject, "author" => format_name($comment), "date" => format_date($comment->timestamp), "content" => $comment->comment )); if ($comment->new) { $xtemplate->template->parse("comment.new"); } if ($picture = theme('user_picture', $comment)) { $xtemplate->template->assign("picture", $picture); $xtemplate->template->parse("comment.picture"); } if ($links) { $xtemplate->template->assign("links", $links); $xtemplate->template->parse("comment.links"); } $xtemplate->template->parse("comment"); $output = $xtemplate->template->text("comment"); $xtemplate->template->reset("comment"); return $output; } function xtemplate_page($content, $title = NULL, $breadcrumb = NULL) { if (isset($title)) { drupal_set_title($title); } if (isset($breadcrumb)) { drupal_set_breadcrumb($breadcrumb); } global $xtemplate; $template_directory = variable_get('xtemplate_template', 'default'); $xtemplate->template->assign(array( "head_title" => (drupal_get_title() ? drupal_get_title() ." | ". variable_get("site_name", "drupal") : variable_get("site_name", "drupal") ." | ". variable_get("site_slogan", "")), "site" => variable_get("site_name", "drupal"), "head" => drupal_get_html_head(), "directory" => "themes/xtemplate/$template_directory", "onload_attributes" => theme_onload_attribute(), "logo" => variable_get('xtemplate_logo', "\"Logo\""), "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 ($title = drupal_get_title()) { $xtemplate->template->assign("title", $title); $xtemplate->template->assign("breadcrumb", theme("breadcrumb", drupal_get_breadcrumb())); $xtemplate->template->parse("header.title"); } if ($help = menu_get_active_help()) { $xtemplate->template->assign("help", $help); $xtemplate->template->parse("header.help"); } foreach (drupal_get_messages() as $message) { list($message, $type) = $message; $xtemplate->template->assign("message", ucfirst($message)); $xtemplate->template->assign("type", $type); $xtemplate->template->parse("header.message"); } if (variable_get("xtemplate_search_box", 1)) { $xtemplate->template->assign(array( //"search" => search_form(), "search_url" => url("search"), "search_button_text" => t("Search"), "search_description" => t("Enter the terms you wish to search for.") )); $xtemplate->template->parse("header.search_box"); } // only parse the mission block if we are on the frontpage ... if ($_GET["q"] == variable_get("site_frontpage", "node") && ($mission = variable_get("xtemplate_mission", "edit mission"))) { $xtemplate->template->assign("mission", $mission); $xtemplate->template->parse("header.mission"); } if ($blocks = theme("blocks", "left")) { $xtemplate->template->assign("blocks", $blocks); $xtemplate->template->parse("header.blocks"); } $xtemplate->template->parse("header"); $output = $xtemplate->template->text("header"); $output .= "\n\n"; $output .= $content; $output .= "\n\n"; if ($blocks = theme("blocks", "right")) { $xtemplate->template->assign("blocks", $blocks); $xtemplate->template->parse("footer.blocks"); } // only parse the footer block if site_footer is set if ($footer_message = variable_get("site_footer", FALSE)) { $xtemplate->template->assign("footer_message", $footer_message); $xtemplate->template->parse("footer.message"); } $xtemplate->template->assign("footer", theme_closure()); $xtemplate->template->parse("footer"); $output .= $xtemplate->template->text("footer"); return $output; } function xtemplate_block(&$block) { global $xtemplate; // create template variables for all block variables (module, delta, region, subject, content, ...) foreach ($block as $key => $value) { $xtemplate->template->assign($key == "subject" ? "title" : $key, $value); // TODO: standardize on 'title' (ie. rename all $block["subject"] to "title") } $xtemplate->template->parse("block"); $output = $xtemplate->template->text("block"); $xtemplate->template->reset("block"); return $output; } function xtemplate_box($title, $content, $region = "main") { global $xtemplate; $xtemplate->template->assign(array( "title" => $title, "content" => $content)); $xtemplate->template->parse("box"); $output = $xtemplate->template->text("box"); $xtemplate->template->reset("box"); return $output; } ?>