Commit c0494c0a authored by Dries's avatar Dries

- Committed phase 4 of JonBob's menu system changes.
parent 2df7214a
......@@ -10,7 +10,7 @@ function drupal_set_title($title = NULL) {
static $stored_title;
if (isset($title)) {
$stored_title = $title;
$stored_title = ucfirst($title);
}
return $stored_title;
}
......
......@@ -16,17 +16,15 @@
/**
Returns the theme header.
@param $title (optional) override the page title.
@return a string containing the \a header output.
**/
function theme_header($title = "") {
function theme_header() {
global $base_url;
$output = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
$output .= "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
$output .= "<head>";
$output .= " <title>". $title ? $title : variable_get(site_name, "drupal") ."</title>";
$output .= " <title>". drupal_get_title() ? drupal_get_title() : variable_get(site_name, "drupal") ."</title>";
$output .= theme_head($main);
$output .= " <style type=\"text/css\" media=\"all\">";
$output .= " @import url(misc/drupal.css);";
......@@ -49,6 +47,27 @@ function theme_header($title = "") {
return $output;
}
/**
Returns an entire Drupal page displaying the supplied content.
@param $content a string containing the content to display.
@return a string containing the \a page output.
**/
function theme_page($content, $title = NULL, $breadcrumb = NULL) {
if (isset($title)) {
drupal_set_title($title);
}
if (isset($breadcrumb)) {
drupal_set_breadcrumb($breadcrumb);
}
$output = theme("header");
$output .= $content;
$output .= theme("footer");
return $output;
}
/**
Returns themed set of links.
......@@ -98,16 +117,22 @@ function theme_breadcrumb($breadcrumb) {
\li \c $node->username the username of the poster.
@param $node the \a node to be themed.
@param $main
@param $main Display teaser only, as on main page?
@param $page Display node as standalone page (no title)?
@return a string containing the \a node output.
**/
function theme_node($node, $main) {
function theme_node($node, $main = 0, $page = 0) {
if (module_exist("taxonomy")) {
$terms = taxonomy_link("taxonomy terms", $node);
}
$output = "<h2>$node->title</h2> by ". format_name($node);
if ($page == 0) {
$output = "<h2>$node->title</h2> by ". format_name($node);
}
else {
$output = "by ". format_name($node);
}
if (count($terms)) {
$output .= " <small>(". print theme("links", $terms) .")</small><br />";
......
......@@ -13,8 +13,7 @@
menu_execute_active_handler();
}
else {
print theme("header");
print theme("footer");
print theme("page", "");
}
drupal_page_footer();
......
......@@ -26,14 +26,10 @@ function admin_link($type) {
function admin_admin() {
if (user_access("access administration pages")) {
print theme("header");
print watchdog_overview("actions");
print theme("footer");
print theme("page", watchdog_overview("actions"));
}
else {
print theme("header");
print message_access();
print theme("footer");
print theme("page", message_access());
}
}
......
......@@ -76,9 +76,7 @@ function import_help($section = "admin/help#import") {
}
function import_help_page() {
print theme("header");
print import_help();
print theme("footer");
print theme("page", import_help());
}
function import_settings() {
......@@ -618,14 +616,10 @@ function import_admin() {
default:
$output .= import_view();
}
print theme("header");
print $output;
print theme("footer");
print theme("page", $output);
}
else {
print theme("header");
print message_access();
print theme("footer");
print theme("page", message_access());
}
}
......
......@@ -76,9 +76,7 @@ function import_help($section = "admin/help#import") {
}
function import_help_page() {
print theme("header");
print import_help();
print theme("footer");
print theme("page", import_help());
}
function import_settings() {
......@@ -618,14 +616,10 @@ function import_admin() {
default:
$output .= import_view();
}
print theme("header");
print $output;
print theme("footer");
print theme("page", $output);
}
else {
print theme("header");
print message_access();
print theme("footer");
print theme("page", message_access());
}
}
......
......@@ -200,6 +200,12 @@ function archive_link($type) {
}
}
if ($type == "system") {
if (user_access("access content")) {
menu("archive", t("archives"), "archive_page", 0, 1);
}
}
return $links;
}
......@@ -209,7 +215,7 @@ function archive_page() {
$op = $_POST["op"];
$edit = $_POST["edit"];
print theme("header");
$output = "";
if (user_access("access content")) {
if ($op == t("Show")) {
......@@ -236,7 +242,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 form($start);
$output .= form($start);
/*
** Fetch nodes for the selected date, or current date if none
......@@ -247,15 +253,14 @@ function archive_page() {
$result = db_query_range("SELECT nid FROM {node} WHERE status = '1' AND created > %d ORDER BY created", $date, 0, 20);
while ($nid = db_fetch_object($result)) {
node_view(node_load(array("nid" => $nid->nid)), 1);
$output .= node_view(node_load(array("nid" => $nid->nid)), 1);
}
}
print theme("page", $output);
}
else {
message_access();
print theme("page", message_access());
}
print theme("footer");
}
function archive_settings() {
......
......@@ -200,6 +200,12 @@ function archive_link($type) {
}
}
if ($type == "system") {
if (user_access("access content")) {
menu("archive", t("archives"), "archive_page", 0, 1);
}
}
return $links;
}
......@@ -209,7 +215,7 @@ function archive_page() {
$op = $_POST["op"];
$edit = $_POST["edit"];
print theme("header");
$output = "";
if (user_access("access content")) {
if ($op == t("Show")) {
......@@ -236,7 +242,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 form($start);
$output .= form($start);
/*
** Fetch nodes for the selected date, or current date if none
......@@ -247,15 +253,14 @@ function archive_page() {
$result = db_query_range("SELECT nid FROM {node} WHERE status = '1' AND created > %d ORDER BY created", $date, 0, 20);
while ($nid = db_fetch_object($result)) {
node_view(node_load(array("nid" => $nid->nid)), 1);
$output .= node_view(node_load(array("nid" => $nid->nid)), 1);
}
}
print theme("page", $output);
}
else {
message_access();
print theme("page", message_access());
}
print theme("footer");
}
function archive_settings() {
......
......@@ -54,9 +54,7 @@ function block_help($section = "admin/help#block") {
}
function block_help_page() {
print theme("header");
print block_help();
print theme("footer");
print theme("page", block_help());
}
function block_perm() {
......@@ -312,14 +310,10 @@ function block_admin() {
$output .= block_admin_display();
}
print theme("header");
print $output;
print theme("footer");
print theme("page", $output);
}
else {
print theme("header");
print message_access();
print theme("footer");
print theme("page", message_access());
}
}
......
......@@ -54,9 +54,7 @@ function block_help($section = "admin/help#block") {
}
function block_help_page() {
print theme("header");
print block_help();
print theme("footer");
print theme("page", block_help());
}
function block_perm() {
......@@ -312,14 +310,10 @@ function block_admin() {
$output .= block_admin_display();
}
print theme("header");
print $output;
print theme("footer");
print theme("page", $output);
}
else {
print theme("header");
print message_access();
print theme("footer");
print theme("page", message_access());
}
}
......
......@@ -116,34 +116,36 @@ function blog_page_user($uid) {
$account = user_load(array((is_numeric($uid) ? "uid" : "name") => $uid, "status" => 1));
// Breadcrumb navigation:
$breadcrumb[] = l(t("Home"), NULL);
$breadcrumb[] = l(t("Blogs"), "blog");
$breadcrumb[] = t("%name's blog", array("%name" => $account->name));
print theme("breadcrumb", $breadcrumb);
$breadcrumb[] = l(t("Home"), "");
$breadcrumb[] = t("blogs");
$title = t("%name's blog", array("%name" => $account->name));
$output = "";
$result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY nid DESC", variable_get("default_nodes_main", 10));
while ($node = db_fetch_object($result)) {
node_view(node_load(array("nid" => $node->nid)), 1);
$output .= node_view(node_load(array("nid" => $node->nid)), 1);
}
print pager_display(NULL, variable_get("default_nodes_main", 10));
print "<div class=\"xml-icon\">" . l("<img src=\"". theme("image", "xml.gif") ."\" width=\"36\" height=\"14\" style=\"border: 0px;\" alt=\"\" title=\"\" />", "blog/feed/$account->uid", array("title" => t("View the XML version of %username's blog", array("%username" => $account->name)))) . "</div>";
$output .= pager_display(NULL, variable_get("default_nodes_main", 10));
$output .= "<div class=\"xml-icon\">" . l("<img src=\"". theme("image", "xml.gif") ."\" width=\"36\" height=\"14\" style=\"border: 0px;\" alt=\"\" title=\"\" />", "blog/feed/$account->uid", array("title" => t("View the XML version of %username's blog", array("%username" => $account->name)))) . "</div>";
print theme("page", $output, $title);
}
function blog_page_last() {
global $user;
// Breadcrumb navigation:
$breadcrumb[] = l(t("Home"), NULL);
$breadcrumb[] = t("Blogs");
print theme("breadcrumb", $breadcrumb);
$output = "";
$result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND status = 1 ORDER BY nid DESC", variable_get("default_nodes_main", 10));
while ($node = db_fetch_object($result)) {
node_view(node_load(array("nid" => $node->nid)), 1);
$output .= node_view(node_load(array("nid" => $node->nid)), 1);
}
print pager_display(NULL, variable_get("default_nodes_main", 10));
print "<div class=\"xml-icon\">". l("<img src=\"". theme("image", "xml.gif") ."\" width=\"36\" height=\"14\" style=\"border: 0px;\" alt=\"\" title=\"\" />", "blog/feed", array("title" => t("Read the XML version of all blogs."))) ."</div>";
$output .= pager_display(NULL, variable_get("default_nodes_main", 10));
$output .= "<div class=\"xml-icon\">". l("<img src=\"". theme("image", "xml.gif") ."\" width=\"36\" height=\"14\" style=\"border: 0px;\" alt=\"\" title=\"\" />", "blog/feed", array("title" => t("Read the XML version of all blogs."))) ."</div>";
print theme("page", $output);
}
function blog_validate(&$node) {
......@@ -207,20 +209,16 @@ function blog_page() {
}
break;
default:
print theme("header");
if (arg(1)) {
blog_page_user(arg(1));
}
else {
blog_page_last();
}
print theme("footer");
}
}
else {
print theme("header");
print theme("box", t("Access denied"), message_access());
print theme("footer");
print theme("page", message_access());
}
}
......@@ -231,18 +229,19 @@ function blog_content($node) {
return $node;
}
function blog_view($node, $main = 0) {
if ($main == 0) {
function blog_view($node, $main = 0, $page = 0) {
if ($page) {
// Breadcrumb navigation
$breadcrumb[] = l(t("Home"), NULL);
$breadcrumb[] = l(t("Home"), "");
$breadcrumb[] = l(t("blogs"), "blog");
$breadcrumb[] = l(t("%name's blog", array("%name" => $node->name)), "blog/$node->uid");
// print the breadcrumb
print theme("breadcrumb", $breadcrumb);
// set the breadcrumb
drupal_set_breadcrumb($breadcrumb);
}
// prepair the node content
// prepare the node content
$node = blog_content($node);
// print the node
print theme("node", $node, $main);
return theme("node", $node, $main, $page);
}
function blog_link($type, $node = 0, $main) {
......@@ -258,7 +257,7 @@ function blog_link($type, $node = 0, $main) {
menu("blog/" . $user->uid, t("my blog"), "blog_page", 1);
}
if (user_access("access content")) {
menu("blog", t("blog"), "blog_page", 0, 1);
menu("blog", t("blogs"), "blog_page", 0, 1);
}
}
......
......@@ -116,34 +116,36 @@ function blog_page_user($uid) {
$account = user_load(array((is_numeric($uid) ? "uid" : "name") => $uid, "status" => 1));
// Breadcrumb navigation:
$breadcrumb[] = l(t("Home"), NULL);
$breadcrumb[] = l(t("Blogs"), "blog");
$breadcrumb[] = t("%name's blog", array("%name" => $account->name));
print theme("breadcrumb", $breadcrumb);
$breadcrumb[] = l(t("Home"), "");
$breadcrumb[] = t("blogs");
$title = t("%name's blog", array("%name" => $account->name));
$output = "";
$result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY nid DESC", variable_get("default_nodes_main", 10));
while ($node = db_fetch_object($result)) {
node_view(node_load(array("nid" => $node->nid)), 1);
$output .= node_view(node_load(array("nid" => $node->nid)), 1);
}
print pager_display(NULL, variable_get("default_nodes_main", 10));
print "<div class=\"xml-icon\">" . l("<img src=\"". theme("image", "xml.gif") ."\" width=\"36\" height=\"14\" style=\"border: 0px;\" alt=\"\" title=\"\" />", "blog/feed/$account->uid", array("title" => t("View the XML version of %username's blog", array("%username" => $account->name)))) . "</div>";
$output .= pager_display(NULL, variable_get("default_nodes_main", 10));
$output .= "<div class=\"xml-icon\">" . l("<img src=\"". theme("image", "xml.gif") ."\" width=\"36\" height=\"14\" style=\"border: 0px;\" alt=\"\" title=\"\" />", "blog/feed/$account->uid", array("title" => t("View the XML version of %username's blog", array("%username" => $account->name)))) . "</div>";
print theme("page", $output, $title);
}
function blog_page_last() {
global $user;
// Breadcrumb navigation:
$breadcrumb[] = l(t("Home"), NULL);
$breadcrumb[] = t("Blogs");
print theme("breadcrumb", $breadcrumb);
$output = "";
$result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND status = 1 ORDER BY nid DESC", variable_get("default_nodes_main", 10));
while ($node = db_fetch_object($result)) {
node_view(node_load(array("nid" => $node->nid)), 1);
$output .= node_view(node_load(array("nid" => $node->nid)), 1);
}
print pager_display(NULL, variable_get("default_nodes_main", 10));
print "<div class=\"xml-icon\">". l("<img src=\"". theme("image", "xml.gif") ."\" width=\"36\" height=\"14\" style=\"border: 0px;\" alt=\"\" title=\"\" />", "blog/feed", array("title" => t("Read the XML version of all blogs."))) ."</div>";
$output .= pager_display(NULL, variable_get("default_nodes_main", 10));
$output .= "<div class=\"xml-icon\">". l("<img src=\"". theme("image", "xml.gif") ."\" width=\"36\" height=\"14\" style=\"border: 0px;\" alt=\"\" title=\"\" />", "blog/feed", array("title" => t("Read the XML version of all blogs."))) ."</div>";
print theme("page", $output);
}
function blog_validate(&$node) {
......@@ -207,20 +209,16 @@ function blog_page() {
}
break;
default:
print theme("header");
if (arg(1)) {
blog_page_user(arg(1));
}
else {
blog_page_last();
}
print theme("footer");
}
}
else {
print theme("header");
print theme("box", t("Access denied"), message_access());
print theme("footer");
print theme("page", message_access());
}
}
......@@ -231,18 +229,19 @@ function blog_content($node) {
return $node;
}
function blog_view($node, $main = 0) {
if ($main == 0) {
function blog_view($node, $main = 0, $page = 0) {
if ($page) {
// Breadcrumb navigation
$breadcrumb[] = l(t("Home"), NULL);
$breadcrumb[] = l(t("Home"), "");
$breadcrumb[] = l(t("blogs"), "blog");
$breadcrumb[] = l(t("%name's blog", array("%name" => $node->name)), "blog/$node->uid");
// print the breadcrumb
print theme("breadcrumb", $breadcrumb);
// set the breadcrumb
drupal_set_breadcrumb($breadcrumb);
}
// prepair the node content
// prepare the node content
$node = blog_content($node);
// print the node
print theme("node", $node, $main);
return theme("node", $node, $main, $page);
}
function blog_link($type, $node = 0, $main) {
......@@ -258,7 +257,7 @@ function blog_link($type, $node = 0, $main) {
menu("blog/" . $user->uid, t("my blog"), "blog_page", 1);
}
if (user_access("access content")) {
menu("blog", t("blog"), "blog_page", 0, 1);
menu("blog", t("blogs"), "blog_page", 0, 1);
}
}
......
......@@ -383,7 +383,7 @@ function book_content($node) {
return $node;
}
function book_view($node, $main = 0) {
function book_view($node, $main = 0, $page = 0) {
$node = book_content($node);
/*
** Display the node. If not displayed on the main page, we render
......@@ -391,30 +391,35 @@ function book_view($node, $main = 0) {
** and the next page.
*/
$output = "";
if ($main) {
print theme("node", $node, $main);
$output .= theme("node", $node, $main, $page);
}
else {
if ($node->moderate) {
$node->body = $node->body . "<div class=\"log\"><div class=\"title\">". t("Log") .":</div>$node->log</div>";
}
// Add the navigation and the breadcrumb if we view a page
if (arg(1) == "view") {
if ($page) {
$node = book_navigation($node);
// Print the breadcrumb
print theme("breadcrumb", $node->breadcrumb);
drupal_set_breadcrumb($node->breadcrumb);
}
// Print the node
print theme("node", $node, $main);
$output .= theme("node", $node, $main, $page);
}
return $output;
}
function book_show($node, $cid) {
$output = "";
if (node_access("view", $node)) {
if ($node->type == "book") {
book_view($node, 0);
$output .= book_view($node, 0, 1);
}
else {
......@@ -443,8 +448,8 @@ function book_show($node, $cid) {
/*
** View the node
*/
print theme("breadcrumb", $node->breadcrumb);
print theme("node", $node, 0);
drupal_set_breadcrumb($node->breadcrumb);
$output .= theme("node", $node, 0, 1);
}
else {
......@@ -452,11 +457,11 @@ function book_show($node, $cid) {
** We can't get the content of the node and just view the node.
** We don't add breadcrums or links.
*/
node_view($node, 0);
$output .= node_view($node, 0, 1);
}
}
if (function_exists("comment_render") && $node->comment) {
comment_render($node, $cid);
$output .= comment_render($node, $cid);
}
/*
......@@ -464,6 +469,10 @@ function book_show($node, $cid) {
*/
node_tag_new($node->nid);
}
else {
$output .= message_access();
}
return $output;
}
function book_navigation($node) {
......@@ -476,7 +485,7 @@ function book_navigation($node) {
$node->breadcrumb = ""; // Overwrite the trail with a book trail.
$node->breadcrumb[] = l(t("Home"), "");
$node->breadcrumb[] = l(t("Books"), "book");
$node->breadcrumb[] = l(t("books"), "book");
foreach ($path as $level) {
$node->breadcrumb[] = l($level->title, "book/view/$level->nid");
}
......@@ -625,9 +634,7 @@ function book_render() {
}
drupal_set_title(t("Books"));
print theme("header");
print $output;
print theme("footer");
print theme("page", $output);
}
function book_page() {
......@@ -636,9 +643,8 @@ function book_page() {
switch (arg(1)) {
case "view":
$node = node_load(array("nid" => arg(2)));
print theme("header");
book_show($node, arg(3));
print theme("footer");
$output = book_show($node, arg(3));
print theme("page", $output, $node->title);
break;
case "print":
print book_print(arg(2), $depth = 1);
......@@ -648,10 +654,7 @@ function book_page() {
}
}
else {
drupal_set_title(t("Access denied"));
print theme("header");
print message_access();
print theme("footer");
print theme("page", message_access());