aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/admin/menu_items.php20
-rw-r--r--engine/lib/elgglib.php13
-rw-r--r--languages/en.php26
-rw-r--r--views/default/admin/menu_items.php40
4 files changed, 85 insertions, 14 deletions
diff --git a/actions/admin/menu_items.php b/actions/admin/menu_items.php
index b271e1c2b..8e502bea2 100644
--- a/actions/admin/menu_items.php
+++ b/actions/admin/menu_items.php
@@ -10,12 +10,14 @@
$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'));
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index ad245ab79..e33fdab6f 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -3006,6 +3006,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
*/
define('ACCESS_DEFAULT', -1);
@@ -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
diff --git a/languages/en.php b/languages/en.php
index a74c8ea90..b50501e5e 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -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
diff --git a/views/default/admin/menu_items.php b/views/default/admin/menu_items.php
index c9bdc5bca..1233eeb1b 100644
--- a/views/default/admin/menu_items.php
+++ b/views/default/admin/menu_items.php
@@ -42,6 +42,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')));
echo elgg_view('input/form', array(