Commit 26735ac5 authored by Dries's avatar Dries

- Committed phase 3 of JonBob's menu changes.  Adds an API for modules to
  define titles and breadcrumbs for their pages, and updates the theme
  system to display them.
parent e4d791fe
<?php
// $Id$
/**
* Functions to get and set the title of the current page.
*/
function drupal_set_title($title = NULL) {
static $stored_title;
if (isset($title)) {
$stored_title = $title;
}
return $stored_title;
}
function drupal_get_title() {
$title = drupal_set_title();
if (!isset($title)) {
$title = menu_get_active_title();
}
return $title;
}
/**
* Functions to get and set the breadcrumb trail of the current page. The
* breadcrumb trail is represented as an array of links, starting with
* "home" and proceeding up to but not including the current page.
*/
function drupal_set_breadcrumb($breadcrumb = NULL) {
static $stored_breadcrumb;
if (isset($breadcrumb)) {
$stored_breadcrumb = $breadcrumb;
}
return $stored_breadcrumb;
}
function drupal_get_breadcrumb() {
$breadcrumb = drupal_set_breadcrumb();
if (!isset($breadcrumb)) {
$breadcrumb = menu_get_active_breadcrumb();
array_pop($breadcrumb);
}
return $breadcrumb;
}
/**
* Build the alias/path array
*/
......
......@@ -40,6 +40,12 @@ function theme_header($title = "") {
$output .= theme("blocks", "all");
$output .= "</td><td style=\"vertical-align: top;\">";
$output .= theme("breadcrumb", drupal_get_breadcrumb());
$output .= "<h1>" . drupal_get_title() . "</h1>";
if ($help = menu_get_active_help()) {
$output .= "<small>$help</small><hr />";
}
return $output;
}
......
......@@ -194,6 +194,12 @@ function archive_link($type) {
}
}
if ($type == "system") {
if (user_access("access content")) {
menu("archive", t("archives"), "archive_page", 0, 1);
}
}
return $links;
}
......@@ -230,7 +236,7 @@ function archive_page() {
$start = "<div class=\"container-inline\">";
$start .= form_select("", "year", ($year ? $year : date("Y")), $years). form_select("", "month", ($month ? $month : date("m")), $months) . form_select("", "day", ($day ? $day : date("d")), $days) . form_submit(t("Show"));
$start .= "</div>";
print theme("box", t("Archives"), form($start));
print form($start);
/*
** Fetch nodes for the selected date, or current date if none
......
......@@ -194,6 +194,12 @@ function archive_link($type) {
}
}
if ($type == "system") {
if (user_access("access content")) {
menu("archive", t("archives"), "archive_page", 0, 1);
}
}
return $links;
}
......@@ -230,7 +236,7 @@ function archive_page() {
$start = "<div class=\"container-inline\">";
$start .= form_select("", "year", ($year ? $year : date("Y")), $years). form_select("", "month", ($month ? $month : date("m")), $months) . form_select("", "day", ($day ? $day : date("d")), $days) . form_submit(t("Show"));
$start .= "</div>";
print theme("box", t("Archives"), form($start));
print form($start);
/*
** Fetch nodes for the selected date, or current date if none
......
......@@ -71,7 +71,7 @@ function book_link($type, $node = 0, $main = 0) {
if ($type == "system") {
if (user_access("maintain books")) {
menu("node/add/book", t("book page"), "page", 0);
menu("node/add/book", t("book page"), "node_page", 0);
}
if (user_access("administer nodes")) {
menu("admin/node/book", t("books"), "book_admin", 4);
......@@ -623,8 +623,9 @@ function book_render() {
}
}
drupal_set_title(t("Books"));
print theme("header");
print theme("box", t("Books"), "$output");
print $output;
print theme("footer");
}
......@@ -646,8 +647,9 @@ function book_page() {
}
}
else {
drupal_set_title(t("Access denied"));
print theme("header");
print theme("box", t("Access denied"), message_access());
print message_access();
print theme("footer");
}
}
......
......@@ -71,7 +71,7 @@ function book_link($type, $node = 0, $main = 0) {
if ($type == "system") {
if (user_access("maintain books")) {
menu("node/add/book", t("book page"), "page", 0);
menu("node/add/book", t("book page"), "node_page", 0);
}
if (user_access("administer nodes")) {
menu("admin/node/book", t("books"), "book_admin", 4);
......@@ -623,8 +623,9 @@ function book_render() {
}
}
drupal_set_title(t("Books"));
print theme("header");
print theme("box", t("Books"), "$output");
print $output;
print theme("footer");
}
......@@ -646,8 +647,9 @@ function book_page() {
}
}
else {
drupal_set_title(t("Access denied"));
print theme("header");
print theme("box", t("Access denied"), message_access());
print message_access();
print theme("footer");
}
}
......
......@@ -883,8 +883,9 @@ function comment_page() {
case t("Post comment"):
list($error_title, $error_body) = comment_post($edit);
if ($error_body) {
drupal_set_title($error_title);
print theme("header");
print theme("box", $error_title, $error_body);
print $error_body;
print theme("footer");
}
else {
......
......@@ -883,8 +883,9 @@ function comment_page() {
case t("Post comment"):
list($error_title, $error_body) = comment_post($edit);
if ($error_body) {
drupal_set_title($error_title);
print theme("header");
print theme("box", $error_title, $error_body);
print $error_body;
print theme("footer");
}
else {
......
......@@ -162,9 +162,9 @@ function drupal_link($type) {
}
function drupal_page() {
drupal_set_title("Drupal");
print theme("header");
print theme("box", "Drupal", drupal_help("user/help#drupal"));
print drupal_help("user/help#drupal");
print theme("footer");
}
......
......@@ -162,9 +162,9 @@ function drupal_link($type) {
}
function drupal_page() {
drupal_set_title("Drupal");
print theme("header");
print theme("box", "Drupal", drupal_help("user/help#drupal"));
print drupal_help("user/help#drupal");
print theme("footer");
}
......
......@@ -442,16 +442,16 @@ function forum_page() {
print theme("forum_display", $forums, $topics, $parents, $tid, $sortby, $forum_per_page, $offset);
}
else {
$message = t("Warning");
print theme("header", $message);
print theme("box", $message, _forum_message_taxonomy());
drupal_set_title(t("Warning"));
print theme("header");
print _forum_message_taxonomy();
print theme("footer");
}
}
else {
$message = t("Access denied");
print theme("header", $message);
print theme("box", $message, message_access());
drupal_set_title(t("Access denied"));
print theme("header");
print message_access();
print theme("footer");
}
}
......@@ -513,9 +513,10 @@ function theme_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_p
$output = '';
}
print theme("header", $title);
print theme("breadcrumb", $breadcrumb);
print theme("box", $title, $output);
drupal_set_title($title);
drupal_set_breadcrumb($breadcrumb);
print theme("header");
print $output;
print theme("footer");
}
......
......@@ -442,16 +442,16 @@ function forum_page() {
print theme("forum_display", $forums, $topics, $parents, $tid, $sortby, $forum_per_page, $offset);
}
else {
$message = t("Warning");
print theme("header", $message);
print theme("box", $message, _forum_message_taxonomy());
drupal_set_title(t("Warning"));
print theme("header");
print _forum_message_taxonomy();
print theme("footer");
}
}
else {
$message = t("Access denied");
print theme("header", $message);
print theme("box", $message, message_access());
drupal_set_title(t("Access denied"));
print theme("header");
print message_access();
print theme("footer");
}
}
......@@ -513,9 +513,10 @@ function theme_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_p
$output = '';
}
print theme("header", $title);
print theme("breadcrumb", $breadcrumb);
print theme("box", $title, $output);
drupal_set_title($title);
drupal_set_breadcrumb($breadcrumb);
print theme("header");
print $output;
print theme("footer");
}
......
......@@ -1505,57 +1505,84 @@ function node_page() {
$node = node_load(array("nid" => arg(2), "status" => 1), $_GET["revision"]);
}
print theme("header", $node->title);
$name = module_invoke(arg(2), "node", "name");
switch ($op) {
case "add":
print theme("box", t("Submit %name", array("%name" => $name)), node_add(arg(2)));
drupal_set_title(t("Submit %name", array("%name" => $name)));
print theme("header");
print node_add(arg(2));
print theme("footer");
break;
case "edit":
print theme("box", t("Edit %name", array("%name" => $name)), node_edit(arg(2)));
drupal_set_title(t("Edit %name", array("%name" => $name)));
print theme("header");
print node_edit(arg(2));
print theme("footer");
break;
case "view":
drupal_set_title($node->title);
print theme("header");
print node_show($node, arg(3));
print theme("footer");
break;
case "revisions":
theme("box", t("Revisions"), node_revision_overview((arg(2))));
drupal_set_title(t("Revisions"));
print theme("header");
print node_revision_overview(arg(2));
print theme("footer");
break;
case "rollback-revision":
$output = node_revision_rollback(arg(2), arg(3));
$output .= node_revision_overview(arg(2));
theme("box", t("Revisions"), $output);
drupal_set_title(t("Revisions"));
print theme("header");
print $output;
print theme("footer");
break;
case "delete-revision":
$output = node_revision_delete(arg(2), arg(3));
$output .= node_revision_overview(arg(2));
theme("box", t("Revisions"), $output);
drupal_set_title(t("Revisions"));
print theme("header");
print $output;
print theme("footer");
break;
case t("Preview"):
$edit = node_validate($edit, $error);
print theme("box", t("Preview %name", array("%name" => $name)), node_preview($edit, $error));
drupal_set_title(t("Preview %name", array("%name" => $name)));
print theme("header");
print node_preview($edit, $error);
print theme("footer");
break;
case t("Submit"):
print theme("box", t("Submit %name", array("%name" => $name)), node_submit($edit));
drupal_set_title(t("Submit %name", array("%name" => $name)));
print theme("header");
print node_submit($edit);
print theme("footer");
break;
case t("Delete"):
print theme("box", t("Delete %name", array("%name" => $name)), node_delete($edit));
drupal_set_title(t("Delete %name", array("%name" => $name)));
print theme("header");
print node_delete($edit);
print theme("footer");
break;
default:
drupal_set_title("");
print theme("header");
$result = pager_query("SELECT nid, type FROM {node} WHERE promote = '1' AND status = '1' ORDER BY static DESC, created DESC", variable_get("default_nodes_main", 10));
while ($node = db_fetch_object($result)) {
node_view(node_load(array("nid" => $node->nid, "type" => $node->type)), 1);
}
print pager_display(NULL, variable_get("default_nodes_main", 10));
print theme("footer");
}
print theme("footer");
}
else {
drupal_set_title(t("Access denied"));
print theme("header");
print theme("box", t("Access denied"), message_access());
print message_access();
print theme("footer");
}
......
......@@ -1505,57 +1505,84 @@ function node_page() {
$node = node_load(array("nid" => arg(2), "status" => 1), $_GET["revision"]);
}
print theme("header", $node->title);
$name = module_invoke(arg(2), "node", "name");
switch ($op) {
case "add":
print theme("box", t("Submit %name", array("%name" => $name)), node_add(arg(2)));
drupal_set_title(t("Submit %name", array("%name" => $name)));
print theme("header");
print node_add(arg(2));
print theme("footer");
break;
case "edit":
print theme("box", t("Edit %name", array("%name" => $name)), node_edit(arg(2)));
drupal_set_title(t("Edit %name", array("%name" => $name)));
print theme("header");
print node_edit(arg(2));
print theme("footer");
break;
case "view":
drupal_set_title($node->title);
print theme("header");
print node_show($node, arg(3));
print theme("footer");
break;
case "revisions":
theme("box", t("Revisions"), node_revision_overview((arg(2))));
drupal_set_title(t("Revisions"));
print theme("header");
print node_revision_overview(arg(2));
print theme("footer");
break;
case "rollback-revision":
$output = node_revision_rollback(arg(2), arg(3));
$output .= node_revision_overview(arg(2));
theme("box", t("Revisions"), $output);
drupal_set_title(t("Revisions"));
print theme("header");
print $output;
print theme("footer");
break;
case "delete-revision":
$output = node_revision_delete(arg(2), arg(3));
$output .= node_revision_overview(arg(2));
theme("box", t("Revisions"), $output);
drupal_set_title(t("Revisions"));
print theme("header");
print $output;
print theme("footer");
break;
case t("Preview"):
$edit = node_validate($edit, $error);
print theme("box", t("Preview %name", array("%name" => $name)), node_preview($edit, $error));
drupal_set_title(t("Preview %name", array("%name" => $name)));
print theme("header");
print node_preview($edit, $error);
print theme("footer");
break;
case t("Submit"):
print theme("box", t("Submit %name", array("%name" => $name)), node_submit($edit));
drupal_set_title(t("Submit %name", array("%name" => $name)));
print theme("header");
print node_submit($edit);
print theme("footer");
break;
case t("Delete"):
print theme("box", t("Delete %name", array("%name" => $name)), node_delete($edit));
drupal_set_title(t("Delete %name", array("%name" => $name)));
print theme("header");
print node_delete($edit);
print theme("footer");
break;
default:
drupal_set_title("");
print theme("header");
$result = pager_query("SELECT nid, type FROM {node} WHERE promote = '1' AND status = '1' ORDER BY static DESC, created DESC", variable_get("default_nodes_main", 10));
while ($node = db_fetch_object($result)) {
node_view(node_load(array("nid" => $node->nid, "type" => $node->type)), 1);
}
print pager_display(NULL, variable_get("default_nodes_main", 10));
print theme("footer");
}
print theme("footer");
}
else {
drupal_set_title(t("Access denied"));
print theme("header");
print theme("box", t("Access denied"), message_access());
print message_access();
print theme("footer");
}
......
......@@ -257,7 +257,7 @@ function poll_page() {
$output .= "<li>".l($node->title, "node/view/$node->nid") ." - ". format_plural($node->votes, "1 vote", "%count votes") ." - ". ($node->active ? t("open") : t("closed")) ."</li>";
}
$output .= "</ul>";
print theme("box", t("Polls"), $output);
print $output;
print theme("footer");
}
......
......@@ -257,7 +257,7 @@ function poll_page() {
$output .= "<li>".l($node->title, "node/view/$node->nid") ." - ". format_plural($node->votes, "1 vote", "%count votes") ." - ". ($node->active ? t("open") : t("closed")) ."</li>";
}
$output .= "</ul>";
print theme("box", t("Polls"), $output);
print $output;
print theme("footer");
}
......
......@@ -116,8 +116,9 @@ function queue_overview() {
}
$output .= "</table>";
drupal_set_title(t("Moderation queue"));
print theme("header");
print theme("box", t("Moderation queue"), $output);
print $output;
print theme("footer");
}
......@@ -192,7 +193,7 @@ function queue_page() {
}
else {
print theme("header");
print theme("box", t("Moderation queue"), message_access());
print message_access();
print theme("footer");
}
}
......
......@@ -46,6 +46,10 @@ function search_link($type) {
menu("search", t("search"), "search_page", 0, 1);
}
if ($type == "system" && user_access("search content")) {
menu("search", t("search"), "search_page", 0, 1);
}
return $links;
}
......@@ -361,23 +365,22 @@ function search_view($keys) {
$help_link = l(t("search help"), "search/help");
switch (variable_get("help_pos", 1)) {
case "1":
$form = search_help(). $form;
$form = search_help(). $form ."<br />";
break;
case "2":
$form .= search_help();
$form .= search_help() ."<br />";
break;
case "3":
$form = $help_link. "<br />". $form;
$form = $help_link. "<br />". $form ."<br />";
break;
case "4":
$form .= "<br />". $help_link;
$form .= "<br />". $help_link ."<br />";
}
print theme("header", t("Search"));
drupal_set_title(t("Search"));
print theme("header");
if ($form) {
print theme("box", t("Search"), $form);
}
print $form;
if ($keys) {
if ($output) {
......@@ -391,8 +394,9 @@ function search_view($keys) {
print theme("footer");
}
else {
print theme("header", t("Access denied"));
print theme("box", t("Access denied"), message_access());
drupal_set_title(t("Access denied"));
print theme("header");
print message_access();
print theme("footer");
}
......@@ -403,8 +407,9 @@ function search_page() {
switch (arg(1)) {
case "help":
drupal_set_title(t("Search Help"));
print theme("header");
print theme("box", t("Search Help"), search_help());
print search_help();
print theme("footer");
break;
default:
......
......@@ -46,6 +46,10 @@ function search_link($type) {
menu("search", t("search"), "search_page", 0, 1);
}
if ($type == "system" && user_access("search content")) {
menu("search", t("search"), "search_page", 0, 1);
}
return $links;
}
......@@ -361,23 +365,22 @@ function search_view($keys) {
$help_link = l(t("search help"), "search/help");
switch (variable_get("help_pos", 1)) {
case "1":
$form = search_help(). $form;
$form = search_help(). $form ."<br />";
break;
case "2":
$form .= search_help();
$form .= search_help() ."<br />";
break;
case "3":
$form = $help_link. "<br />". $form;
$form = $help_link. "<br />". $form ."<br />";
break;
case "4":
$form .= "<br />". $help_link;
$form .= "<br />". $help_link ."<br />";