aboutsummaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-18 16:37:16 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-18 16:37:16 +0000
commit8ec093ecc1bf28c09f5d2dbe3c7bc8e6a2485ac6 (patch)
tree2b0c0454d9305cd61b92f57d02be06deccaf5d9b /actions
parentfc0fb6ec66aca4e439f434ce0d97df6d09388ef4 (diff)
downloadelgg-8ec093ecc1bf28c09f5d2dbe3c7bc8e6a2485ac6.tar.gz
elgg-8ec093ecc1bf28c09f5d2dbe3c7bc8e6a2485ac6.tar.bz2
site nav menu now uses new menu code (and finished the implementation of custom menu items while I was at it - not backward compatible with the previous half finished version)
git-svn-id: http://code.elgg.org/elgg/trunk@7668 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'actions')
-rw-r--r--actions/admin/menu/save.php35
-rw-r--r--actions/admin/menu_items.php50
2 files changed, 35 insertions, 50 deletions
diff --git a/actions/admin/menu/save.php b/actions/admin/menu/save.php
new file mode 100644
index 000000000..3fdce8c45
--- /dev/null
+++ b/actions/admin/menu/save.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Save menu items.
+ *
+ * @package Elgg
+ * @subpackage Core
+ */
+
+// featured menu items
+$featured_names = get_input('featured_menu_names', array());
+$featured_names = array_unique($featured_names);
+if (in_array('', $featured_names)) {
+ unset($featured_names[array_search('', $featured_names)]);
+}
+elgg_save_config('site_featured_menu_names', $featured_names);
+
+
+// custom menu items
+$custom_menu_titles = get_input('custom_menu_titles', array());
+$custom_menu_urls = get_input('custom_menu_urls', array());
+$num_menu_items = count($custom_menu_titles);
+$custom_menu_items = array();
+for ($i = 0; $i < $num_menu_items; $i++) {
+ if (trim($custom_menu_urls[$i]) && trim($custom_menu_titles[$i])) {
+ $url = $custom_menu_urls[$i];
+ $title = $custom_menu_titles[$i];
+ $custom_menu_items[$title] = $url;
+ }
+}
+elgg_save_config('site_custom_menu_items', $custom_menu_items);
+
+
+system_message(elgg_echo('admin:menu_items:saved'));
+
+forward(REFERER);
diff --git a/actions/admin/menu_items.php b/actions/admin/menu_items.php
deleted file mode 100644
index c9efb8bee..000000000
--- a/actions/admin/menu_items.php
+++ /dev/null
@@ -1,50 +0,0 @@
-<?php
-/**
- * Save menu items.
- *
- * @package Elgg
- * @subpackage Core
- */
-
-$featured_urls = get_input('featured_urls', 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;
-}
-
-foreach ($featured_urls as $url) {
- if (array_key_exists($url, $menu_urls)) {
- $featured_url_info[] = $menu_urls[$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_custom_items', $custom_items);
-
-system_message(elgg_echo('admin:menu_items:saved'));
-
-forward(REFERER);