aboutsummaryrefslogtreecommitdiff
path: root/mod/categories
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2011-08-24 15:22:49 -0700
committerBrett Profitt <brett.profitt@gmail.com>2011-08-24 15:22:49 -0700
commit2dace654a99396ab674f50829046ed703d3a36be (patch)
tree57add762814a2156eac54a2d50658a805be60ff9 /mod/categories
parent9f13557c2e7422cb15ce109adbe5714d6d78fc9e (diff)
downloadelgg-2dace654a99396ab674f50829046ed703d3a36be.tar.gz
elgg-2dace654a99396ab674f50829046ed703d3a36be.tar.bz2
Refs #3746. Updated categories for 1.8. Still some deprecation notices, but functional.
Diffstat (limited to 'mod/categories')
-rw-r--r--mod/categories/actions/save.php19
-rw-r--r--mod/categories/activate.php11
-rw-r--r--mod/categories/languages/en.php2
-rw-r--r--mod/categories/start.php33
-rw-r--r--mod/categories/views/default/input/categories.php4
-rw-r--r--mod/categories/views/default/plugins/categories/settings.php (renamed from mod/categories/views/default/settings/categories/edit.php)0
6 files changed, 46 insertions, 23 deletions
diff --git a/mod/categories/actions/save.php b/mod/categories/actions/save.php
deleted file mode 100644
index 26222a030..000000000
--- a/mod/categories/actions/save.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-/**
- * Saves the available categories for the site
- *
- * @note The categories for an object are saved through an event handler: categories_save()
- *
- * @package ElggCategories
- */
-
-$categories = get_input('categories');
-$categories = string_to_tag_array($categories);
-
-$site = elgg_get_site_entity();
-$site->categories = $categories;
-system_message(elgg_echo("categories:save:success"));
-
-elgg_delete_admin_notice('categories_admin_notice_no_categories');
-
-forward(REFERER); \ No newline at end of file
diff --git a/mod/categories/activate.php b/mod/categories/activate.php
new file mode 100644
index 000000000..80159d089
--- /dev/null
+++ b/mod/categories/activate.php
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Prompt the user to add categories after activating
+ */
+
+//categories_admin_notice_no_categories
+$site = get_config('site');
+if (!$site->categories) {
+ $message = elgg_echo('categories:on_activate_reminder', array(elgg_normalize_url('admin/plugin_settings/categories')));
+ elgg_add_admin_notice('categories_admin_notice_no_categories', $message);
+} \ No newline at end of file
diff --git a/mod/categories/languages/en.php b/mod/categories/languages/en.php
index 1954ba8d9..eaa65b13e 100644
--- a/mod/categories/languages/en.php
+++ b/mod/categories/languages/en.php
@@ -9,7 +9,7 @@ $english = array(
'categories:explanation' => 'To set some predefined site-wide categories that will be used throughout your system, enter them below, separated with commas. Compatible tools will then display them when the user creates or edits content.',
'categories:save:success' => 'Site categories were successfully saved.',
'categories:results' => "Results for the site category: %s",
- 'categories:on_enable_reminder' => "You haven't added any categories yet! <a href=\"%s\">Add categories now.</a>",
+ 'categories:on_activate_reminder' => "Site-wide Cateogires won't work until you add categories. <a href=\"%s\">Add categories now.</a>",
);
add_translation("en", $english); \ No newline at end of file
diff --git a/mod/categories/start.php b/mod/categories/start.php
index ff5b01efc..2ccea0d70 100644
--- a/mod/categories/start.php
+++ b/mod/categories/start.php
@@ -15,13 +15,14 @@ function categories_init() {
elgg_extend_view('css/elgg', 'categories/css');
- $action_base = elgg_get_plugins_path() . 'categories/actions';
- elgg_register_action('settings/categories/save', "$action_base/save.php", 'admin');
-
elgg_register_page_handler('categories', 'categories_page_handler');
elgg_register_event_handler('update', 'all', 'categories_save');
elgg_register_event_handler('create', 'all', 'categories_save');
+
+ // To keep the category plugins in the settings area and because we have to do special stuff,
+ // handle saving ourself.
+ elgg_register_plugin_hook_handler('action', 'plugins/settings/save', 'categories_save_site_categories');
}
@@ -54,3 +55,29 @@ function categories_save($event, $object_type, $object) {
}
return TRUE;
}
+
+/**
+ * Saves the site categories.
+ *
+ * @param type $hook
+ * @param type $type
+ * @param type $value
+ * @param type $params
+ */
+function categories_save_site_categories($hook, $type, $value, $params) {
+ $plugin_id = get_input('plugin_id');
+ if ($plugin_id != 'categories') {
+ return $value;
+ }
+
+ $categories = get_input('categories');
+ $categories = string_to_tag_array($categories);
+
+ $site = elgg_get_site_entity();
+ $site->categories = $categories;
+ system_message(elgg_echo("categories:save:success"));
+
+ elgg_delete_admin_notice('categories_admin_notice_no_categories');
+
+ forward(REFERER);
+} \ No newline at end of file
diff --git a/mod/categories/views/default/input/categories.php b/mod/categories/views/default/input/categories.php
index 1f71dc0b4..75960d257 100644
--- a/mod/categories/views/default/input/categories.php
+++ b/mod/categories/views/default/input/categories.php
@@ -23,6 +23,10 @@ if (!empty($categories)) {
$categories = array($categories);
}
+ // checkboxes want Label => value, so in our case we need category => category
+ $categories = array_flip($categories);
+ array_walk($categories, create_function('&$v, $k', '$v = $k;'));
+
?>
<div class="categories">
diff --git a/mod/categories/views/default/settings/categories/edit.php b/mod/categories/views/default/plugins/categories/settings.php
index 3802da95a..3802da95a 100644
--- a/mod/categories/views/default/settings/categories/edit.php
+++ b/mod/categories/views/default/plugins/categories/settings.php