]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Added ability to make arbitrary links for the menu items.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 24 Mar 2010 22:20:03 +0000 (22:20 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Wed, 24 Mar 2010 22:20:03 +0000 (22:20 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@5498 36083f99-b078-4883-b0ff-0f9b5a30f544

actions/admin/menu_items.php
engine/lib/elgglib.php
languages/en.php
views/default/admin/menu_items.php

index b271e1c2b001860f684d4208e86d63b91f0d4456..8e502bea2d2ef2250b5e94c6f4285a8186caf059 100644 (file)
 
 $featured_urls = get_input('featured_urls', array());
 $hide_toolbar_entries = get_input('menu_items_hide_toolbar_entries', 'yes');
-$featured_url_info = array();
+$custom_item_names = get_input('custom_item_names', array());
+$custom_item_urls = get_input('custom_item_urls', array());
 
 // save the full information from the menu item into the config table
 // this will be checked upon display that it is still valid (based upon url)
 $menu_items = get_register('menu');
 $menu_urls = array();
+$featured_url_info = array();
 
 foreach ($menu_items as $name => $info) {
        $menu_urls[$info->value->url] = $info;
@@ -27,9 +29,25 @@ foreach ($featured_urls as $url) {
        }
 }
 
+// save the custom items
+$custom_count = count($custom_item_names);
+$custom_items = array();
+for ($i=0; $i<$custom_count; $i++) {
+       if (isset($custom_item_names[$i]) && isset($custom_item_names[$i])) {
+               $name = $custom_item_names[$i];
+               $url = $custom_item_urls[$i];
+
+               if ($name && $url) {
+                       $custom_items[$url] = $name;
+               }
+       }
+}
+
+
 // set_config() always returns 0 so can't check for failures
 set_config('menu_items_featured_urls', $featured_url_info);
 set_config('menu_items_hide_toolbar_entries', $hide_toolbar_entries);
+set_config('menu_items_custom_items', $custom_items);
 
 system_message(elgg_echo('admin:menu_items:saved'));
 
index ad245ab79bdd8b3337de0d057b630398d62ddbc7..e33fdab6f346d3b252c844bf86d0b1f2df578a8e 100644 (file)
@@ -3005,6 +3005,17 @@ function elgg_get_nav_items() {
        );
 }
 
+/**
+ * Hook that registers the custom menu items.
+ */
+function add_custom_menu_items() {
+       if ($custom_items = get_config('menu_items_custom_items')) {
+               foreach ($custom_items as $url => $name) {
+                       add_menu($name, $url);
+               }
+       }
+}
+
 /**
  * Some useful constant definitions
  */
@@ -3021,4 +3032,4 @@ register_elgg_event_handler('init', 'system', 'elgg_init');
 register_elgg_event_handler('boot', 'system', 'elgg_boot', 1000);
 register_plugin_hook('unit_test', 'system', 'elgg_api_test');
 
-//register_elgg_event_handler('pagesetup', 'system', 'ui_page_setup', 1000);
\ No newline at end of file
+register_elgg_event_handler('init', 'system', 'add_custom_menu_items', 1000);
\ No newline at end of file
index a74c8ea90f6efadf124a01662300cd6d040395d3..b50501e5e9cf10351cf6eaebe4b830ccfc20811e 100644 (file)
@@ -514,6 +514,8 @@ To remove a widget drag it back to the <b>Widget gallery</b>.",
        'admin:menu_items:description' => 'Select which menu items you want to show as featured links.  Unused items will be added as "More" at the end of the list.',
        'admin:menu_items:hide_toolbar_entries' => 'Remove links from tool bar menu?',
        'admin:menu_items:saved' => 'Menu items saved.',
+       'admin:add_menu_item' => 'Add a custom menu item',
+       'admin:add_menu_item:description' => 'Fill out the Display name and URL to add custom items to your navigation menu.',
 
 /**
  * User settings
@@ -825,21 +827,21 @@ If you requested this click on the link below, otherwise ignore this email.
  * XML-RPC
  */
        'xmlrpc:noinputdata'    =>      "Input data missing",
-       
+
 /**
  * Likes
  **/
-       'likes:this' => 'liked this',
-       'likes:deleted' => 'Your like has been removed',
-       'likes:notdeleted' => 'There was a problem removing your like',
-       'likes:likes' => 'You now like this item',
-       'likes:failure' => 'There was a problem liking this item',
-       'likes:alreadyliked' => 'You have already liked this item',
-       'likes:notfound' => 'The item you are trying to like cannot be found',
-       'likes:likethis' => 'Like this',
-       'likes:userlikedthis' => 'user liked this',
-       'likes:userslikethis' => 'users liked this',
-       'likes:river:annotate' => 'likes',
+       'likes:this' => 'liked this',
+       'likes:deleted' => 'Your like has been removed',
+       'likes:notdeleted' => 'There was a problem removing your like',
+       'likes:likes' => 'You now like this item',
+       'likes:failure' => 'There was a problem liking this item',
+       'likes:alreadyliked' => 'You have already liked this item',
+       'likes:notfound' => 'The item you are trying to like cannot be found',
+       'likes:likethis' => 'Like this',
+       'likes:userlikedthis' => 'user liked this',
+       'likes:userslikethis' => 'users liked this',
+       'likes:river:annotate' => 'likes',
 
 /**
  * Comments
index c9bdc5bca91c86650de29c4eb7433e116382feb0..1233eeb1b5fe9bcaaaaf302b20ab60435338e785 100644 (file)
@@ -41,6 +41,46 @@ for ($i=0; $i<6; $i++) {
        ));
 }
 
+$form_body .= '<br /><br />';
+// add arbitrary links
+$form_body .= elgg_view_title(elgg_echo('admin:add_menu_item'));
+$form_body .= elgg_view('output/longtext', array('value' => elgg_echo("admin:add_menu_item:description")));
+
+$custom_items = get_config('menu_items_custom_items');
+
+$name_str = elgg_echo('name');
+$url_str = elgg_echo('admin:plugins:label:website');
+
+$form_body .= '<ul>';
+
+if (is_array($custom_items)) {
+       foreach ($custom_items as $url => $name) {
+               $name_input = elgg_view('input/text', array(
+                       'internalname' => 'custom_item_names[]',
+                       'value' => $name
+               ));
+
+               $url_input = elgg_view('input/text', array(
+                       'internalname' => 'custom_item_urls[]',
+                       'value' => $url
+               ));
+
+               $form_body .= "<li>$name_str: $name_input $url_str: $url_input $delete</li>";
+       }
+}
+
+$new = elgg_echo('new');
+$name_input = elgg_view('input/text', array(
+       'internalname' => 'custom_item_names[]',
+));
+
+$url_input = elgg_view('input/text', array(
+       'internalname' => 'custom_item_urls[]',
+));
+
+$form_body .= "<li>$name_str: $name_input $url_str: $url_input</li>
+</ul>";
+
 $form_body .= '<br /><br />';
 $form_body .= elgg_view('input/submit', array('value' => elgg_echo('save')));