Commit 32e8d77c authored by Dries's avatar Dries

- Associate a callback with the menu links!  (This callback is not yet being
  called but will be as soon the remaining links have been transformed to use
  the menu system.)

- Made sure the menu does not render links with no callback and no children.
  Like this, the 'create content' link is not being shown when the user has
  no permission to add any content.
parent b8416f61
......@@ -133,7 +133,12 @@ function menu_tree($parent = "") {
$output = "\n<ul>\n";
usort($_list[$parent]["children"], "_menu_sort");
foreach ($_list[$parent]["children"] as $item) {
if ($_list[$item]["hidden"] == 0) {
/*
** Don't render the menu when it is hidden, or when it has no call-back
** nor children. The latter check avoids that useless links are being
** rendered.
*/
if ($_list[$item]["hidden"] == 0 && ($_list[$item]["callback"] || $_list[$item]["children"])) {
$style = ($_list[$item]["children"] ? (menu_in_active_trail($item) ? "expanded" : "collapsed") : "leaf");
$output .= "<li class=\"$style\">";
$output .= _render_item($item);
......
......@@ -261,10 +261,10 @@ function blog_link($type, $node = 0, $main) {
if ($type == "system") {
if (user_access("maintain personal blog")) {
menu("node/add/blog", t("blog entry"), NULL, NULL, 0);
menu("node/add/blog", t("blog entry"), "blog_page", NULL, 0);
}
if (user_access("maintain personal blog")) {
menu("blog/" . $user->uid,t("view my blog"), NULL, NULL, 1);
menu("blog/" . $user->uid,t("view my blog"), "user_page", NULL, 1);
}
}
......
......@@ -261,10 +261,10 @@ function blog_link($type, $node = 0, $main) {
if ($type == "system") {
if (user_access("maintain personal blog")) {
menu("node/add/blog", t("blog entry"), NULL, NULL, 0);
menu("node/add/blog", t("blog entry"), "blog_page", NULL, 0);
}
if (user_access("maintain personal blog")) {
menu("blog/" . $user->uid,t("view my blog"), NULL, NULL, 1);
menu("blog/" . $user->uid,t("view my blog"), "user_page", NULL, 1);
}
}
......
......@@ -79,7 +79,7 @@ function book_link($type, $node = 0, $main = 0) {
if ($type == "system") {
if (user_access("maintain books")) {
menu("node/add/book", t("book page"), NULL, NULL,0);
menu("node/add/book", t("book page"), "book_page", NULL,0);
menu("admin/node/book", t("books"), NULL, NULL, 4);
menu("admin/node/book/orphan", t("orphan pages"), NULL, NULL, 8);
menu("admin/node/book/help", t("help"), NULL, NULL, 9);
......
......@@ -79,7 +79,7 @@ function book_link($type, $node = 0, $main = 0) {
if ($type == "system") {
if (user_access("maintain books")) {
menu("node/add/book", t("book page"), NULL, NULL,0);
menu("node/add/book", t("book page"), "book_page", NULL,0);
menu("admin/node/book", t("books"), NULL, NULL, 4);
menu("admin/node/book/orphan", t("orphan pages"), NULL, NULL, 8);
menu("admin/node/book/help", t("help"), NULL, NULL, 9);
......
......@@ -551,17 +551,12 @@ function node_link($type, $node = 0, $main = 0) {
$links = array();
if ($type == "page") {
$links[] = l(t("submit"), "node/add", array("title" => t("Submit or suggest new content.")));
}
if ($type == "node") {
if ($node->links) {
$links = $node->links;
}
if ($main == 1 && $node->teaser && strlen($node->teaser) != strlen($node->body))
{
if ($main == 1 && $node->teaser && strlen($node->teaser) != strlen($node->body)) {
$links[] = l(t("read more"), "node/view/$node->nid", array("title" => t("Read the rest of this posting."), "class" => "read-more"));
}
......@@ -572,6 +567,7 @@ function node_link($type, $node = 0, $main = 0) {
if ($type == "system") {
menu("node/add", t("create content"), NULL, NULL, 1);
if (user_access("administer nodes")) {
menu("admin/node", t("content"), "node_admin", node_help("admin/node"));
menu("admin/node/search", t("search"), "node_admin", node_help("admin/node/search"), 8);
......
......@@ -551,17 +551,12 @@ function node_link($type, $node = 0, $main = 0) {
$links = array();
if ($type == "page") {
$links[] = l(t("submit"), "node/add", array("title" => t("Submit or suggest new content.")));
}
if ($type == "node") {
if ($node->links) {
$links = $node->links;
}
if ($main == 1 && $node->teaser && strlen($node->teaser) != strlen($node->body))
{
if ($main == 1 && $node->teaser && strlen($node->teaser) != strlen($node->body)) {
$links[] = l(t("read more"), "node/view/$node->nid", array("title" => t("Read the rest of this posting."), "class" => "read-more"));
}
......@@ -572,6 +567,7 @@ function node_link($type, $node = 0, $main = 0) {
if ($type == "system") {
menu("node/add", t("create content"), NULL, NULL, 1);
if (user_access("administer nodes")) {
menu("admin/node", t("content"), "node_admin", node_help("admin/node"));
menu("admin/node/search", t("search"), "node_admin", node_help("admin/node/search"), 8);
......
......@@ -97,7 +97,7 @@ function page_link($type) {
if ($type == "system") {
if (user_access("maintain static pages")) {
menu("node/add/page", t("static page"), NULL, NULL, 0);
menu("node/add/page", t("static page"), "page_page", NULL, 0);
}
}
......
......@@ -97,7 +97,7 @@ function page_link($type) {
if ($type == "system") {
if (user_access("maintain static pages")) {
menu("node/add/page", t("static page"), NULL, NULL, 0);
menu("node/add/page", t("static page"), "page_page", NULL, 0);
}
}
......
......@@ -163,7 +163,7 @@ function poll_link($type, $node = 0, $main) {
if ($type == "system") {
if (user_access("create polls")) {
menu("node/add/poll",t("poll"), NULL, NULL, 0);
menu("node/add/poll",t("poll"), "poll_page", NULL, 0);
}
}
else if ($type == "page" && user_access("access content")) {
......
......@@ -163,7 +163,7 @@ function poll_link($type, $node = 0, $main) {
if ($type == "system") {
if (user_access("create polls")) {
menu("node/add/poll",t("poll"), NULL, NULL, 0);
menu("node/add/poll",t("poll"), "poll_page", NULL, 0);
}
}
else if ($type == "page" && user_access("access content")) {
......
......@@ -56,7 +56,7 @@ function story_link($type) {
if ($type == "system") {
if (user_access("create stories")) {
menu("node/add/story", t("story"), NULL, NULL, 0);
menu("node/add/story", t("story"), "story_page", NULL, 0);
}
}
......
......@@ -56,7 +56,7 @@ function story_link($type) {
if ($type == "system") {
if (user_access("create stories")) {
menu("node/add/story", t("story"), NULL, NULL, 0);
menu("node/add/story", t("story"), "story_page", NULL, 0);
}
}
......
......@@ -20,7 +20,7 @@ function tracker_link($type) {
if ($type == "system") {
if (user_access("access content")) {
menu("tracker", t("recent posts"), NULL, NULL, 1);
menu("tracker", t("recent posts"), "tracker_page", NULL, 1);
}
}
......
......@@ -20,7 +20,7 @@ function tracker_link($type) {
if ($type == "system") {
if (user_access("access content")) {
menu("tracker", t("recent posts"), NULL, NULL, 1);
menu("tracker", t("recent posts"), "tracker_page", NULL, 1);
}
}
......
......@@ -466,8 +466,8 @@ function user_link($type) {
if ($type == "system") {
global $user;
if ($user->uid) {
menu("user/edit", t("edit my account"), NULL, NULL, 8);
menu("user/logout", t("log out"), NULL, NULL, 10);
menu("user/edit", t("edit my account"), "user_page", NULL, 8);
menu("user/logout", t("log out"), "user_page", NULL, 10);
}
if (user_access("administer users")) {
menu("admin/user", t("accounts"), "user_admin", user_help("admin/user"), 2);
......
......@@ -466,8 +466,8 @@ function user_link($type) {
if ($type == "system") {
global $user;
if ($user->uid) {
menu("user/edit", t("edit my account"), NULL, NULL, 8);
menu("user/logout", t("log out"), NULL, NULL, 10);
menu("user/edit", t("edit my account"), "user_page", NULL, 8);
menu("user/logout", t("log out"), "user_page", NULL, 10);
}
if (user_access("administer users")) {
menu("admin/user", t("accounts"), "user_admin", user_help("admin/user"), 2);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment