Commit f104d3cc authored by Dries's avatar Dries

- Committed the admin menu integration patch.  Thanks Adrian, Stefan and others.
parent 645d026e
...@@ -46,6 +46,17 @@ function menu_item($in_path) { ...@@ -46,6 +46,17 @@ function menu_item($in_path) {
return "<a href=\"". url($in_path) ."\"$css>". t($_gmenu[$in_path]["title"]) ."</a>"; return "<a href=\"". url($in_path) ."\"$css>". t($_gmenu[$in_path]["title"]) ."</a>";
} }
function menu_title($in_path = null) {
global $_gmenu;
if ($in_path == null) {
$trail = menu_trail();
$in_path = array_pop($trail);
}
return ucfirst($_gmenu[$in_path]["title"]);
}
function menu_trail() { function menu_trail() {
global $_gmenu; global $_gmenu;
static $trail; // cache static $trail; // cache
...@@ -72,13 +83,13 @@ function menu_path() { ...@@ -72,13 +83,13 @@ function menu_path() {
$trail = menu_trail(); $trail = menu_trail();
$links = array(); $links[] = l(t("Home"), "");
foreach ($trail as $item) { foreach ($trail as $item) {
$links[] = menu_item($item); $links[] = menu_item($item);
} }
return implode(" &raquo; ", $links); return $links;
} }
function menu_help() { function menu_help() {
......
/* $Id */
body {
font-size: 90%;
margin: 0;
background-color: #fff;
}
body, th, td, h1, h2, h3, h4, #menu, #main {
font-family: helvetica, arial;
}
a:link {
color: #059;
}
a:visited {
color: #049;
}
h1 {
font-size: 1.3em;
font-weight: bold;
color: #006;
}
h2 {
font-size: 1.2em;
font-weight: bold;
color: #006;
margin: 0;
padding: 0.5em 0 0 0;
}
h3 {
font-size: 1.2em;
font-weight: bold;
color: #006;
margin: 0;
padding: 1em 0 0 0;
}
table {
border-collapse: collapse;
}
th {
text-align: left;
padding-right: 1em;
color: #006;
border-bottom: 1px solid #ccc;
}
td {
padding: 5px;
font-size: 0.9em;
}
hr {
clear: both;
margin: .5em 0;
height: 1px;
color: #ccc;
}
dt {
font-weight: bold;
}
dd {
margin-bottom: 0.5em;
}
#menu {
position: absolute;
left: 0px;
top: 0px;
margin: 0 0 0 0;
padding: 0 0 .85em 0;
width: 14em;
z-index: 1;
overflow: hidden;
background-color: #69c;
border-right: 1px solid #999;
border-bottom: 1px solid #999;
}
#menu h1 {
background-color: #369;
display: block;
margin: 0 0 .85em 0;
padding: 1em 0 .2em .6em;
border-top: 1px solid #69c;
border-bottom: 1px solid #90bade;
}
#menu h1 a {
color: #fff;
text-decoration: none;
}
#menu ul {
list-style: none;
margin: 0;
padding: 0 0 0.25em 1.5em;
border: none;
}
#menu li {
margin: 0;
padding: 0.2em 0.5em 0 0;
}
#menu li a {
display: block;
width: 100%;
color: #fff;
text-decoration: none;
}
#menu li a.current {
color: #000;
}
#menu li a:hover {
color: #009;
}
#menu li.expanded {
list-style-image: url(menu-expanded.gif);
}
#menu li.collapsed {
list-style-image: url(menu-collapsed.gif);
}
#menu li.leaf {
list-style-image: url(menu-leaf.gif);
}
#main {
margin: 0 0 0 16em;
padding: 1em 1em 1em 0;
z-index: 2;
}
#logo {
padding: 1em 1em 0 1em;
float: right;
}
#logo img {
border: 0;
}
#update {
padding: 1em 1em 1em 1em;
}
...@@ -258,3 +258,13 @@ pre, code { ...@@ -258,3 +258,13 @@ pre, code {
.queue-user-numeral { .queue-user-numeral {
color: red; color: red;
} }
#menu { padding: 0 0 0 0.5em; }
#menu ul { list-style: none; margin: 0; padding: 0 0 0.25em 1em; border: none; text-align:left;}
#menu li { margin: 0; padding: 0.2em 0.5em 0 0; }
#menu li a { display: block; width: 100%; text-decoration: none; }
#menu li a.current { color: #000; }
#menu li a:hover { color: #009; }
#menu li.expanded { list-style-image: url(menu-expanded.gif); }
#menu li.collapsed { list-style-image: url(menu-collapsed.gif); }
#menu li.leaf { list-style-image: url(menu-leaf.gif); }
misc/menu-collapsed.gif

53 Bytes | W: | H:

misc/menu-collapsed.gif

53 Bytes | W: | H:

misc/menu-collapsed.gif
misc/menu-collapsed.gif
misc/menu-collapsed.gif
misc/menu-collapsed.gif
  • 2-up
  • Swipe
  • Onion skin
misc/menu-expanded.gif

52 Bytes | W: | H:

misc/menu-expanded.gif

826 Bytes | W: | H:

misc/menu-expanded.gif
misc/menu-expanded.gif
misc/menu-expanded.gif
misc/menu-expanded.gif
  • 2-up
  • Swipe
  • Onion skin
misc/menu-leaf.gif

54 Bytes | W: | H:

misc/menu-leaf.gif

829 Bytes | W: | H:

misc/menu-leaf.gif
misc/menu-leaf.gif
misc/menu-leaf.gif
misc/menu-leaf.gif
  • 2-up
  • Swipe
  • Onion skin
...@@ -13,112 +13,73 @@ function admin_help($section) { ...@@ -13,112 +13,73 @@ function admin_help($section) {
$output = ""; $output = "";
switch ($section) { switch ($section) {
case 'admin/system/modules': case "admin/system/modules":
$output .= "Handles the administration pages."; $output .= "Handles the administration pages.";
break; break;
case 'admin': case "admin":
$output .= "Welcome to the administration section. Below are the most recent system events. To get started please choose an item in the left column. If there is an arrow it will expand into a submenu. To jump up a level use the link,bread crumbs, above this block of text. To return to the home page click on the site name, and to go to Drupal's home page click on Druplicon, the drop on to the right."; $output .= "Welcome to the administration section. Below are the most recent system events. To get started please choose an item in the left column. If there is an arrow it will expand into a submenu. To jump up a level use the link,bread crumbs, above this block of text. To return to the home page click on the site name, and to go to Drupal's home page click on Druplicon, the drop on to the right.";
break; break;
case 'admin': case "admin":
$output = "This is a complete overview of the site administration page."; $output = "This is a complete overview of the site administration page.";
break; break;
} }
return t($output); return t($output);
} }
function admin_system($field){ function admin_system($field){
$output = ""; $output = "";
if ($field == "description") {
if ($field == "description") { $output = admin_help("admin/system/modules"); } $output = admin_help("admin/system/modules");
}
return $output; return $output;
} }
function admin_link($type) { function admin_link($type) {
if ($type == "admin") { if ($type == "system") {
menu("admin", "Administration", NULL, admin_help("admin")); menu("admin", t("administer %a", array("%a" => variable_get("site_name", "drupal"))) , NULL, NULL, 9);
menu("admin/overview", "sitemap", "overview_callback", admin_help("admin/overview"), 8); menu("admin/overview", "sitemap", "overview_callback", admin_help("admin/overview"), 8);
} }
} }
function overview_callback() { function overview_callback() {
return menu_map("admin"); return menu_map();
} }
function admin_admin() { function admin_admin() {
print menu_map(); return menu_map();
} }
function admin_page() {
global $base_url;
function admin_page() {
if (user_access("access administration pages")) { if (user_access("access administration pages")) {
?> if (!isset($GLOBALS["_gmenu"])) {
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> menu_build("system");
<html> }
<head> if ($help = menu_help()) {
<title><?php echo t("%sitename administration pages", array("%sitename" => variable_get("site_name", "drupal"))); ?></title> $contents = "<small>$help</small><hr />";
<?php print theme_head(); ?> }
<link rel="shortcut icon" type="image/ico" href="favicon.ico" /> if (arg(1)) {
<link rel="stylesheet" type="text/css" media="print" href="misc/print.css" /> $contents .= menu_execute_action();
<style type="text/css" title="layout" media="Screen"> }
@import url("misc/admin.css"); else {
</style> $contents.= watchdog_overview("actions");
</head> $title = t("System messages");
<body<?php print theme_onload_attribute(); ?>> }
<?php
// NOTE: we include a dummy "print.css" to remove the "flash of unstyled content" (FUOC) problems in IE. $breadcrumb = menu_path();
array_pop($breadcrumb);
menu_build("admin"); $title = menu_title();
/* theme("header");
** Body: theme("breadcrumb", $breadcrumb);
*/ theme("box", $title, $contents);
theme("footer");
print "<div id=\"logo\"><a href=\"http://drupal.org/\"><img src=\"misc/druplicon-small.gif\" alt=\"Druplicon - Drupal logo\" title=\"Druplicon - Drupal logo\" /></a></div>";
print "<div id=\"main\">";
if ($path = menu_path()) {
print "<h2>$path</h2>";
}
if ($help = menu_help()) {
print "<small>$help</small>";
}
print "<hr />";
if (arg(1)) {
//print module_invoke(arg(1), "admin");
print menu_execute_action();
}
else {
print "<h2>". t("System messages") ."</h2>";
print watchdog_overview("actions");
}
print "</div>";
/*
** Menu:
** We rebuild the admin menu once more because one might have
** enabled/disabled themes or modules, changed permissions, etc.
*/
menu_build("admin");
print "<div id=\"menu\">";
echo "<h1><a href=\"$base_url/\">". variable_get("site_name", "drupal") ."</a></h1>";
print menu_tree("admin") ;
print "</div>";
print theme_footer();
?>
</body>
</html>
<?php
} }
else { else {
print message_access(); theme("header");
theme("box", t("Access denied"), message_access());
theme("footer");
} }
} }
......
...@@ -105,14 +105,16 @@ function import_link($type) { ...@@ -105,14 +105,16 @@ function import_link($type) {
$links[] = l(t("news feeds"), "import", array("title" => t("Read the latest news from syndicated web sites."))); $links[] = l(t("news feeds"), "import", array("title" => t("Read the latest news from syndicated web sites.")));
} }
if ($type == "admin" && user_access("administer news feeds")) { if ($type == "system") {
if (user_access("administer news feeds")) {
menu("admin/syndication", "content syndication", NULL, NULL, 5);
menu("admin/syndication/news", "news aggregation", "import_admin", import_help("admin/syndication/news") ); menu("admin/syndication", "content syndication", NULL, NULL, 5);
menu("admin/syndication/news/add/feed", "add new feed", "import_admin", import_help("admin/syndication/news/add/feed"), 2); menu("admin/syndication/news", "news aggregation", "import_admin", import_help("admin/syndication/news") );
menu("admin/syndication/news/add/bundle", "add new bundle", "import_admin", import_help("admin/syndication/news/add/bundle"), 3); menu("admin/syndication/news/add/feed", "add new feed", "import_admin", import_help("admin/syndication/news/add/feed"), 2);
menu("admin/syndication/news/tag", "tag news items", "import_admin", import_help("admin/syndication/news/tag"), 4); menu("admin/syndication/news/add/bundle", "add new bundle", "import_admin", import_help("admin/syndication/news/add/bundle"), 3);
menu("admin/syndication/news/help", "help", "import_help", NULL, 9); menu("admin/syndication/news/tag", "tag news items", "import_admin", import_help("admin/syndication/news/tag"), 4);
menu("admin/syndication/news/help", "help", "import_help", NULL, 9);
}
} }
return $links; return $links;
......
...@@ -105,14 +105,16 @@ function import_link($type) { ...@@ -105,14 +105,16 @@ function import_link($type) {
$links[] = l(t("news feeds"), "import", array("title" => t("Read the latest news from syndicated web sites."))); $links[] = l(t("news feeds"), "import", array("title" => t("Read the latest news from syndicated web sites.")));
} }
if ($type == "admin" && user_access("administer news feeds")) { if ($type == "system") {
if (user_access("administer news feeds")) {
menu("admin/syndication", "content syndication", NULL, NULL, 5);
menu("admin/syndication/news", "news aggregation", "import_admin", import_help("admin/syndication/news") ); menu("admin/syndication", "content syndication", NULL, NULL, 5);
menu("admin/syndication/news/add/feed", "add new feed", "import_admin", import_help("admin/syndication/news/add/feed"), 2); menu("admin/syndication/news", "news aggregation", "import_admin", import_help("admin/syndication/news") );
menu("admin/syndication/news/add/bundle", "add new bundle", "import_admin", import_help("admin/syndication/news/add/bundle"), 3); menu("admin/syndication/news/add/feed", "add new feed", "import_admin", import_help("admin/syndication/news/add/feed"), 2);
menu("admin/syndication/news/tag", "tag news items", "import_admin", import_help("admin/syndication/news/tag"), 4); menu("admin/syndication/news/add/bundle", "add new bundle", "import_admin", import_help("admin/syndication/news/add/bundle"), 3);
menu("admin/syndication/news/help", "help", "import_help", NULL, 9); menu("admin/syndication/news/tag", "tag news items", "import_admin", import_help("admin/syndication/news/tag"), 4);
menu("admin/syndication/news/help", "help", "import_help", NULL, 9);
}
} }
return $links; return $links;
......
...@@ -66,7 +66,7 @@ function block_perm() { ...@@ -66,7 +66,7 @@ function block_perm() {
} }
function block_link($type) { function block_link($type) {
if ($type == "admin" && user_access("administer blocks")) { if ($type == "system" && user_access("administer blocks")) {
menu("admin/block", "block management", "block_admin", block_help("admin/block"), 3); menu("admin/block", "block management", "block_admin", block_help("admin/block"), 3);
menu("admin/block/add", "create new block", "block_admin", block_help("admin/block/add"), 2); menu("admin/block/add", "create new block", "block_admin", block_help("admin/block/add"), 2);
...@@ -169,10 +169,7 @@ function block_admin_display() { ...@@ -169,10 +169,7 @@ function block_admin_display() {
$delete = ""; $delete = "";
} }
$status = form_checkbox(NULL, $block["module"]."][".$block["delta"]."][status", 1, $block["status"]); $rows[] = array($block["info"], array("data" => form_checkbox(NULL, $block["module"]."][".$block["delta"]."][status", 1, $block["status"]), "align" => "center"), array("data" => form_checkbox(NULL, $block["module"]."][".$block["delta"]."][custom", 1, $block["custom"]), "align" => "center"), form_weight(NULL, $block["module"]."][".$block["delta"]."][weight", $block["weight"]), form_select(NULL, $block["module"]."][".$block["delta"]."][region", $block["region"], array(t("left"), t("right"))), form_textfield(NULL, $block["module"]."][".$block["delta"]."][path", $block["path"], 10, 255), $edit, $delete);
$custom = form_checkbox(NULL, $block["module"]."][".$block["delta"]."][custom", 1, $block["custom"]);
$rows[] = array($block["info"], array("data" => $status, "align" => "center"), array("data" => $custom, "align" => "center"), form_weight(NULL, $block["module"]."][".$block["delta"]."][weight", $block["weight"]), form_select(NULL, $block["module"]."][".$block["delta"]."][region", $block["region"], array(t("left"), t("right"))), form_textfield(NULL, $block["module"]."][".$block["delta"]."][path", $block["path"], 10, 255), $edit, $delete);
} }
$output = table($header, $rows); $output = table($header, $rows);
......
...@@ -66,7 +66,7 @@ function block_perm() { ...@@ -66,7 +66,7 @@ function block_perm() {
} }
function block_link($type) { function block_link($type) {
if ($type == "admin" && user_access("administer blocks")) { if ($type == "system" && user_access("administer blocks")) {
menu("admin/block", "block management", "block_admin", block_help("admin/block"), 3); menu("admin/block", "block management", "block_admin", block_help("admin/block"), 3);
menu("admin/block/add", "create new block", "block_admin", block_help("admin/block/add"), 2); menu("admin/block/add", "create new block", "block_admin", block_help("admin/block/add"), 2);
...@@ -169,10 +169,7 @@ function block_admin_display() { ...@@ -169,10 +169,7 @@ function block_admin_display() {
$delete = ""; $delete = "";
} }
$status = form_checkbox(NULL, $block["module"]."][".$block["delta"]."][status", 1, $block["status"]); $rows[] = array($block["info"], array("data" => form_checkbox(NULL, $block["module"]."][".$block["delta"]."][status", 1, $block["status"]), "align" => "center"), array("data" => form_checkbox(NULL, $block["module"]."][".$block["delta"]."][custom", 1, $block["custom"]), "align" => "center"), form_weight(NULL, $block["module"]."][".$block["delta"]."][weight", $block["weight"]), form_select(NULL, $block["module"]."][".$block["delta"]."][region", $block["region"], array(t("left"), t("right"))), form_textfield(NULL, $block["module"]."][".$block["delta"]."][path", $block["path"], 10, 255), $edit, $delete);
$custom = form_checkbox(NULL, $block["module"]."][".$block["delta"]."][custom", 1, $block["custom"]);
$rows[] = array($block["info"], array("data" => $status, "align" => "center"), array("data" => $custom, "align" => "center"), form_weight(NULL, $block["module"]."][".$block["delta"]."][weight", $block["weight"]), form_select(NULL, $block["module"]."][".$block["delta"]."][region", $block["region"], array(t("left"), t("right"))), form_textfield(NULL, $block["module"]."][".$block["delta"]."][path", $block["path"], 10, 255), $edit, $delete);
} }
$output = table($header, $rows); $output = table($header, $rows);
......
...@@ -259,16 +259,17 @@ function blog_link($type, $node = 0, $main) { ...@@ -259,16 +259,17 @@ function blog_link($type, $node = 0, $main) {
$links = array(); $links = array();
if ($type == "page" && user_access("access content")) { if ($type == "system") {
$links[] = l(t("blogs"), "blog", array("title" => t("Read the latest blog entries."))); if (user_access("maintain personal blog")) {
} menu("node/add/blog", t("create blog entry"), NULL, NULL, 0);
}
if ($type == "menu.create" && user_access("maintain personal blog")) { if (user_access("maintain personal blog")) {
$links[] = l(t("create blog entry"), "node/add/blog", array("title" => t("Add a new personal blog entry."))); menu("blog/" . $user->uid,t("view personal blog"), NULL, NULL, 1);
}
} }
if ($type == "menu.view" && user_access("maintain personal blog")) { if ($type == "page" && user_access("access content")) {
$links[] = l(t("view personal blog"), "blog/$user->uid", array("title" => t("Read your latest blog entries."))); $links[] = l(t("blogs"), "blog", array("title" => t("Read the latest blog entries.")));
} }
if ($type == "node" && $node->type == "blog") { if ($type == "node" && $node->type == "blog") {
......
...@@ -259,16 +259,17 @@ function blog_link($type, $node = 0, $main) { ...@@ -259,16 +259,17 @@ function blog_link($type, $node = 0, $main) {
$links = array(); $links = array();
if ($type == "page" && user_access("access content")) { if ($type == "system") {
$links[] = l(t("blogs"), "blog", array("title" => t("Read the latest blog entries."))); if (user_access("maintain personal blog")) {
} menu("node/add/blog", t("create blog entry"), NULL, NULL, 0);
}
if ($type == "menu.create" && user_access("maintain personal blog")) { if (user_access("maintain personal blog")) {
$links[] = l(t("create blog entry"), "node/add/blog", array("title" => t("Add a new personal blog entry."))); menu("blog/" . $user->uid,t("view personal blog"), NULL, NULL, 1);
}
} }
if ($type == "menu.view" && user_access("maintain personal blog")) { if ($type == "page" && user_access("access content")) {
$links[] = l(t("view personal blog"), "blog/$user->uid", array("title" => t("Read your latest blog entries."))); $links[] = l(t("blogs"), "blog", array("title" => t("Read the latest blog entries.")));
} }
if ($type == "node" && $node->type == "blog") { if ($type == "node" && $node->type == "blog") {
......
...@@ -68,10 +68,6 @@ function book_link($type, $node = 0, $main = 0) { ...@@ -68,10 +68,6 @@ function book_link($type, $node = 0, $main = 0) {
$links[] = l(t("books"), "book", array("title" => t("Read and contribute to the collaborative books."))); $links[] = l(t("books"), "book", array("title" => t("Read and contribute to the collaborative books.")));
} }
if ($type == "menu.create" && user_access("maintain books")) {
$links[] = l(t("create book page"), "node/add/book", array("title" => t("Add a new book page.")));
}
if ($type == "node" && $node->type == "book") { if ($type == "node" && $node->type == "book") {
if (book_access("update", $node)) { if (book_access("update", $node)) {
$links[] = l(t("edit this page"), "node/edit/$node->nid", array("title" => t("Suggest an update for this book page."))); $links[] = l(t("edit this page"), "node/edit/$node->nid", array("title" => t("Suggest an update for this book page.")));
...@@ -81,15 +77,20 @@ function book_link($type, $node = 0, $main = 0) { ...@@ -81,15 +77,20 @@ function book_link($type, $node = 0, $main = 0) {
} }
} }
if ($type == "admin" && user_access("maintain books")) { if ($type == "system") {
menu("admin/node/book", "books", "book_admin", book_help("admin/node/book"), 4); if (user_access("maintain books")) {
menu("admin/node/book/orphan", "orphan pages", "book_admin", book_help("admin/node/book/orphan"), 8); menu("node/add/book",t("create book page"),NULL, NULL,0);
menu("admin/node/book/help", "help", "book_help", NULL, 9);
menu("admin/node/book", "books", NULL, NULL, 4);
menu("admin/node/book/orphan", "orphan pages", NULL, NULL, 8);
menu("admin/node/book/help", "help", NULL, NULL, 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"); $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)) { while ($book = db_fetch_object($result)) {
menu("admin/node/book/$book->nid", "'$book->title' book", "book_admin"); menu("admin/node/book/$book->nid", "'$book->title' book", "book_admin");
}
} }
} }
return $links; return $links;
......
...@@ -68,10 +68,6 @@ function book_link($type, $node = 0, $main = 0) { ...@@ -68,10 +68,6 @@ function book_link($type, $node = 0, $main = 0) {
$links[] = l(t("books"), "book", array("title" => t("Read and contribute to the collaborative books."))); $links[] = l(t("books"), "book", array("title" => t("Read and contribute to the collaborative books.")));
}