Commit 4bdac433 authored by Dries's avatar Dries

- Patch by JonBob:

  Phase 2 of the menu system integration project. This unifies the interface
  used by admin and non-admin pages, and deprecates the _page hook in favor of
  explicit callbacks from menu(). Breadcrumbs, titles, and help text go away
  as a result of this patch; they will return in the phase 3 patch, printed
  by the theme.
parent 9000f825
......@@ -10,29 +10,11 @@
menu_build("system");
if (menu_active_handler_exists()) {
$breadcrumb = menu_get_active_breadcrumb();
array_pop($breadcrumb);
$title = menu_get_active_title();
print theme("header");
print theme("breadcrumb", $breadcrumb);
if ($help = menu_get_active_help()) {
$contents = "<small>$help</small><hr />";
}
$contents .= menu_execute_active_handler();
print theme("box", $title, $contents);
print theme("footer");
menu_execute_active_handler();
}
else {
$mod = arg(0);
if (isset($mod) && module_hook($mod, "page")) {
module_invoke($mod, "page");
}
else {
print theme("header");
print theme("footer");
}
print theme("header");
print theme("footer");
}
drupal_page_footer();
......
......@@ -26,7 +26,14 @@ function admin_link($type) {
function admin_admin() {
if (user_access("access administration pages")) {
return watchdog_overview("actions");
print theme("header");
print watchdog_overview("actions");
print theme("footer");
}
else {
print theme("header");
print message_access();
print theme("footer");
}
}
......
......@@ -75,6 +75,12 @@ function import_help($section = "admin/help#import") {
return $output;
}
function import_help_page() {
print theme("header");
print import_help();
print theme("footer");
}
function import_settings() {
$number = array(5 => 5, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 55 => 55, 60 => 60, 65 => 65, 70 => 70, 75 => 75, 80 => 80, 85 => 85, 90 => 90, 95 => 95, 100 => 100);
$output .= form_select(t("Items per block"), "import_block_limit", variable_get("import_block_limit", 15), $number, t("The maximum number of news items displayed in one block."));
......@@ -103,7 +109,10 @@ function import_link($type) {
menu("admin/node/syndication/news/add/feed", t("new feed"), "import_admin", 2);
menu("admin/node/syndication/news/add/bundle", t("new bundle"), "import_admin", 3);
menu("admin/node/syndication/news/tag", t("tag items"), "import_admin", 4);
menu("admin/node/syndication/news/help", t("help"), "import_help", 9);
menu("admin/node/syndication/news/help", t("help"), "import_help_page", 9);
}
if (user_access("access news feeds")) {
menu("import", t("news feeds"), "import_page", 0, 1);
}
}
......@@ -609,11 +618,14 @@ function import_admin() {
default:
$output .= import_view();
}
return $output;
print theme("header");
print $output;
print theme("footer");
}
else {
return message_access();
print theme("header");
print message_access();
print theme("footer");
}
}
......
......@@ -75,6 +75,12 @@ function import_help($section = "admin/help#import") {
return $output;
}
function import_help_page() {
print theme("header");
print import_help();
print theme("footer");
}
function import_settings() {
$number = array(5 => 5, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 55 => 55, 60 => 60, 65 => 65, 70 => 70, 75 => 75, 80 => 80, 85 => 85, 90 => 90, 95 => 95, 100 => 100);
$output .= form_select(t("Items per block"), "import_block_limit", variable_get("import_block_limit", 15), $number, t("The maximum number of news items displayed in one block."));
......@@ -103,7 +109,10 @@ function import_link($type) {
menu("admin/node/syndication/news/add/feed", t("new feed"), "import_admin", 2);
menu("admin/node/syndication/news/add/bundle", t("new bundle"), "import_admin", 3);
menu("admin/node/syndication/news/tag", t("tag items"), "import_admin", 4);
menu("admin/node/syndication/news/help", t("help"), "import_help", 9);
menu("admin/node/syndication/news/help", t("help"), "import_help_page", 9);
}
if (user_access("access news feeds")) {
menu("import", t("news feeds"), "import_page", 0, 1);
}
}
......@@ -609,11 +618,14 @@ function import_admin() {
default:
$output .= import_view();
}
return $output;
print theme("header");
print $output;
print theme("footer");
}
else {
return message_access();
print theme("header");
print message_access();
print theme("footer");
}
}
......
......@@ -188,6 +188,12 @@ function archive_link($type) {
$links[] = l(t("archives"), "archive", array("title" => t("Read the older content in our archive.")));
}
if ($type == "system") {
if (user_access("access content")) {
menu("archive", t("archives"), "archive_page", 0, 1);
}
}
return $links;
}
......
......@@ -188,6 +188,12 @@ function archive_link($type) {
$links[] = l(t("archives"), "archive", array("title" => t("Read the older content in our archive.")));
}
if ($type == "system") {
if (user_access("access content")) {
menu("archive", t("archives"), "archive_page", 0, 1);
}
}
return $links;
}
......
......@@ -53,6 +53,12 @@ function block_help($section = "admin/help#block") {
return $output;
}
function block_help_page() {
print theme("header");
print block_help();
print theme("footer");
}
function block_perm() {
return array("administer blocks");
}
......@@ -63,7 +69,7 @@ function block_link($type) {
menu("admin/system/block", t("blocks"), "block_admin", 3);
menu("admin/system/block/add", t("new block"), "block_admin", 2);
menu("admin/system/block/preview", t("preview placement"), "block_admin", 3);
menu("admin/system/block/help", t("help"), "block_help", 9);
menu("admin/system/block/help", t("help"), "block_help_page", 9);
}
}
......@@ -306,10 +312,14 @@ function block_admin() {
$output .= block_admin_display();
}
return $output;
print theme("header");
print $output;
print theme("footer");
}
else {
return message_access();
print theme("header");
print message_access();
print theme("footer");
}
}
......
......@@ -53,6 +53,12 @@ function block_help($section = "admin/help#block") {
return $output;
}
function block_help_page() {
print theme("header");
print block_help();
print theme("footer");
}
function block_perm() {
return array("administer blocks");
}
......@@ -63,7 +69,7 @@ function block_link($type) {
menu("admin/system/block", t("blocks"), "block_admin", 3);
menu("admin/system/block/add", t("new block"), "block_admin", 2);
menu("admin/system/block/preview", t("preview placement"), "block_admin", 3);
menu("admin/system/block/help", t("help"), "block_help", 9);
menu("admin/system/block/help", t("help"), "block_help_page", 9);
}
}
......@@ -306,10 +312,14 @@ function block_admin() {
$output .= block_admin_display();
}
return $output;
print theme("header");
print $output;
print theme("footer");
}
else {
return message_access();
print theme("header");
print message_access();
print theme("footer");
}
}
......
......@@ -252,10 +252,13 @@ function blog_link($type, $node = 0, $main) {
if ($type == "system") {
if (user_access("maintain personal blog")) {
menu("node/add/blog", t("blog entry"), "page", 0);
menu("node/add/blog", t("blog entry"), "node_page", 0);
}
if (user_access("maintain personal blog")) {
menu("blog/" . $user->uid, t("my blog"), "page", 1);
menu("blog/" . $user->uid, t("my blog"), "blog_page", 1);
}
if (user_access("access content")) {
menu("blog", t("blog"), "blog_page", 0, 1);
}
}
......
......@@ -252,10 +252,13 @@ function blog_link($type, $node = 0, $main) {
if ($type == "system") {
if (user_access("maintain personal blog")) {
menu("node/add/blog", t("blog entry"), "page", 0);
menu("node/add/blog", t("blog entry"), "node_page", 0);
}
if (user_access("maintain personal blog")) {
menu("blog/" . $user->uid, t("my blog"), "page", 1);
menu("blog/" . $user->uid, t("my blog"), "blog_page", 1);
}
if (user_access("access content")) {
menu("blog", t("blog"), "blog_page", 0, 1);
}
}
......
......@@ -76,14 +76,16 @@ function book_link($type, $node = 0, $main = 0) {
if (user_access("administer nodes")) {
menu("admin/node/book", t("books"), "book_admin", 4);
menu("admin/node/book/orphan", t("orphan pages"), "book_admin_orphan", 8);
menu("admin/node/book/help", t("help"), "book_help", 9);
menu("admin/node/book/help", t("help"), "book_help_page", 9);
$result = db_query("SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = 0 ORDER BY b.weight, n.title");
while ($book = db_fetch_object($result)) {
menu("admin/node/book/$book->nid", t("'%title' book", array("%title" => $book->title)), "book_admin");
}
}
if (user_access("access content")) {
menu("book", t("books"), "book_page", 0, 1);
}
}
return $links;
......@@ -800,7 +802,9 @@ function book_admin_orphan() {
$output .= theme("table", $header, $rows);
}
return $output;
print theme("header");
print $output;
print theme("footer");
}
function book_admin_links() {
......@@ -832,7 +836,14 @@ function book_admin() {
$output .= book_admin_view(arg(3));
break;
}
return $output;
print theme("header");
print $output;
print theme("footer");
}
else {
print theme("header");
print message_access();
print theme("footer");
}
}
......@@ -867,4 +878,10 @@ function book_help($section = "admin/help#book") {
return $output;
}
function book_help_page() {
print theme("header");
print book_help();
print theme("footer");
}
?>
......@@ -76,14 +76,16 @@ function book_link($type, $node = 0, $main = 0) {
if (user_access("administer nodes")) {
menu("admin/node/book", t("books"), "book_admin", 4);
menu("admin/node/book/orphan", t("orphan pages"), "book_admin_orphan", 8);
menu("admin/node/book/help", t("help"), "book_help", 9);
menu("admin/node/book/help", t("help"), "book_help_page", 9);
$result = db_query("SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = 0 ORDER BY b.weight, n.title");
while ($book = db_fetch_object($result)) {
menu("admin/node/book/$book->nid", t("'%title' book", array("%title" => $book->title)), "book_admin");
}
}
if (user_access("access content")) {
menu("book", t("books"), "book_page", 0, 1);
}
}
return $links;
......@@ -800,7 +802,9 @@ function book_admin_orphan() {
$output .= theme("table", $header, $rows);
}
return $output;
print theme("header");
print $output;
print theme("footer");
}
function book_admin_links() {
......@@ -832,7 +836,14 @@ function book_admin() {
$output .= book_admin_view(arg(3));
break;
}
return $output;
print theme("header");
print $output;
print theme("footer");
}
else {
print theme("header");
print message_access();
print theme("footer");
}
}
......@@ -867,4 +878,10 @@ function book_help($section = "admin/help#book") {
return $output;
}
function book_help_page() {
print theme("header");
print book_help();
print theme("footer");
}
?>
......@@ -109,6 +109,12 @@ function comment_help($section = "admin/help#comment") {
return $output;
}
function comment_help_page() {
print theme("header");
print comment_help();
print theme("footer");
}
function comment_settings() {
$output .= form_radios(t("Default display mode"), "comment_default_mode", variable_get("comment_default_mode", 4), _comment_get_modes(), t("The default view for comments. Expanded views display the body of the comment. Threaded views keep replies together."));
......@@ -827,7 +833,7 @@ function comment_link($type, $node = 0, $main = 0) {
menu("admin/comment/comments/0", t("new/updated"), "comment_admin", 1);
menu("admin/comment/comments/1", t("approval queue"), "comment_admin", 2);
menu("admin/comment/search", t("search"), "comment_admin", 8);
menu("admin/comment/help", t("help"), "comment_help", 9);
menu("admin/comment/help", t("help"), "comment_help_page", 9);
menu("admin/comment/edit", t("edit comment"), "comment_admin", 0, 1);
// comment settings:
......@@ -839,6 +845,7 @@ function comment_link($type, $node = 0, $main = 0) {
menu("admin/comment/moderation/roles", t("initial scores"), "comment_admin", 6);
}
}
menu("comment", t("comments"), "comment_page", 0, 1);
}
return $links ? $links : array();
......@@ -1231,10 +1238,14 @@ function comment_admin() {
$output = comment_admin_overview(0);
}
}
return $output;
print theme("header");
print $output;
print theme("footer");
}
else {
return message_access();
print theme("header");
print message_access();
print theme("footer");
}
}
......
......@@ -109,6 +109,12 @@ function comment_help($section = "admin/help#comment") {
return $output;
}
function comment_help_page() {
print theme("header");
print comment_help();
print theme("footer");
}
function comment_settings() {
$output .= form_radios(t("Default display mode"), "comment_default_mode", variable_get("comment_default_mode", 4), _comment_get_modes(), t("The default view for comments. Expanded views display the body of the comment. Threaded views keep replies together."));
......@@ -827,7 +833,7 @@ function comment_link($type, $node = 0, $main = 0) {
menu("admin/comment/comments/0", t("new/updated"), "comment_admin", 1);
menu("admin/comment/comments/1", t("approval queue"), "comment_admin", 2);
menu("admin/comment/search", t("search"), "comment_admin", 8);
menu("admin/comment/help", t("help"), "comment_help", 9);
menu("admin/comment/help", t("help"), "comment_help_page", 9);
menu("admin/comment/edit", t("edit comment"), "comment_admin", 0, 1);
// comment settings:
......@@ -839,6 +845,7 @@ function comment_link($type, $node = 0, $main = 0) {
menu("admin/comment/moderation/roles", t("initial scores"), "comment_admin", 6);
}
}
menu("comment", t("comments"), "comment_page", 0, 1);
}
return $links ? $links : array();
......@@ -1231,10 +1238,14 @@ function comment_admin() {
$output = comment_admin_overview(0);
}
}
return $output;
print theme("header");
print $output;
print theme("footer");
}
else {
return message_access();
print theme("header");
print message_access();
print theme("footer");
}
}
......
......@@ -155,6 +155,12 @@ function drupal_auth($username, $password, $server) {
return $login;
}
function drupal_link($type) {
if ($type == "system") {
menu("drupal", "Drupal", "drupal_page", 0, 1);
}
}
function drupal_page() {
print theme("header");
......
......@@ -155,6 +155,12 @@ function drupal_auth($username, $password, $server) {
return $login;
}
function drupal_link($type) {
if ($type == "system") {
menu("drupal", "Drupal", "drupal_page", 0, 1);
}
}
function drupal_page() {
print theme("header");
......
......@@ -93,8 +93,13 @@ function forum_link($type, $node = 0, $main = 0) {
$links[] = l(t("forums"), "forum");
}
if ($type == "system" && user_access("create forum topics")) {
menu("node/add/forum",t("forum topic"), "page");
if ($type == "system") {
if (user_access("create forum topics")) {
menu("node/add/forum", t("forum topic"), "node_page");
}
if (user_access("access content")) {
menu("forum", t("forums"), "forum_page", 0, 1);
}
}
if (!$main && $type == "node" && $node->type == "forum") {
......
......@@ -93,8 +93,13 @@ function forum_link($type, $node = 0, $main = 0) {
$links[] = l(t("forums"), "forum");
}
if ($type == "system" && user_access("create forum topics")) {
menu("node/add/forum",t("forum topic"), "page");
if ($type == "system") {
if (user_access("create forum topics")) {
menu("node/add/forum", t("forum topic"), "node_page");
}
if (user_access("access content")) {
menu("forum", t("forums"), "forum_page", 0, 1);
}
}
if (!$main && $type == "node" && $node->type == "forum") {
......
......@@ -4,7 +4,7 @@
function help_link($type) {
if ($type == "system" && user_access("access administration pages")) {
menu("admin/help/glossary", t("glossary"), "help_glossary", 8);
menu("admin/help", t("help"), "help_help", 9);
menu("admin/help", t("help"), "help_help_page", 9);
}
}
......@@ -28,7 +28,9 @@ function help_glossary() {
$output .= "</dl>";
$output = t($output, array("%taxonomy" => l(t("taxonomy help"), "admin/taxonomy/help")));
return $output;
print theme("header");
print $output;
print theme("footer");
}
function help_help($section = "admin/help#help") {
......@@ -59,4 +61,10 @@ function help_help($section = "admin/help#help") {
return $output;
}
function help_help_page() {
print theme("header");
print help_help();
print theme("footer");
}
?>
......@@ -4,7 +4,7 @@
function help_link($type) {
if ($type == "system" && user_access("access administration pages")) {
menu("admin/help/glossary", t("glossary"), "help_glossary", 8);
menu("admin/help", t("help"), "help_help", 9);
menu("admin/help", t("help"), "help_help_page", 9);
}
}
......@@ -28,7 +28,9 @@ function help_glossary() {
$output .= "</dl>";
$output = t($output, array("%taxonomy" => l(t("taxonomy help"), "admin/taxonomy/help")));
return $output;
print theme("header");
print $output;
print theme("footer");
}
function help_help($section = "admin/help#help") {
......@@ -59,4 +61,10 @@ function help_help($section = "admin/help#help") {
return $output;
}
function help_help_page() {
print theme("header");
print help_help();
print theme("footer");
}
?>
......@@ -75,6 +75,12 @@ function import_help($section = "admin/help#import") {
return $output;
}
function import_help_page() {
print theme("header");
print import_help();
print theme("footer");
}
function import_settings() {
$number = array(5 => 5, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 55 => 55, 60 => 60, 65 => 65, 70 => 70, 75 => 75, 80 => 80, 85 => 85, 90 => 90, 95 => 95, 100 => 100);
$output .= form_select(t("Items per block"), "import_block_limit", variable_get("import_block_limit", 15), $number, t("The maximum number of news items displayed in one block."));
......@@ -103,7 +109,10 @@ function import_link($type) {
menu("admin/node/syndication/news/add/feed", t("new feed"), "import_admin", 2);
menu("admin/node/syndication/news/add/bundle", t("new bundle"), "import_admin", 3);
menu("admin/node/syndication/news/tag", t("tag items"), "import_admin", 4);
menu("admin/node/syndication/news/help", t("help"), "import_help", 9);
menu("admin/node/syndication/news/help", t("help"), "import_help_page", 9);
}
if (user_access("access news feeds")) {
menu("import", t("news feeds"), "import_page", 0, 1);
}
}
......@@ -609,11 +618,14 @@ function import_admin() {
default:
$output .= import_view();