aboutsummaryrefslogtreecommitdiff
path: root/mod/categories
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-05-05 19:14:48 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-05-05 19:14:48 +0000
commitff31226fdeb972aac2f37f0098240cb366a9bb26 (patch)
tree1f0caa75c9a340cf28ce9a81a4cbe3230d13abf3 /mod/categories
parent81ffac29fabc175eebdbf95578da046f4f00611b (diff)
downloadelgg-ff31226fdeb972aac2f37f0098240cb366a9bb26.tar.gz
elgg-ff31226fdeb972aac2f37f0098240cb366a9bb26.tar.bz2
Merged 18_new_admin branch to trunk.
git-svn-id: http://code.elgg.org/elgg/trunk@5977 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/categories')
-rw-r--r--mod/categories/actions/save.php5
-rw-r--r--mod/categories/languages/en.php21
-rw-r--r--mod/categories/manifest.xml18
-rw-r--r--mod/categories/start.php49
-rw-r--r--mod/categories/views/default/categories/css.php26
-rw-r--r--mod/categories/views/default/categories/settings.php24
-rw-r--r--mod/categories/views/default/categories/settingsform.php7
-rw-r--r--mod/categories/views/default/settings/categories/edit.php (renamed from mod/categories/settings.php)25
8 files changed, 69 insertions, 106 deletions
diff --git a/mod/categories/actions/save.php b/mod/categories/actions/save.php
index 21602f659..3e93b6325 100644
--- a/mod/categories/actions/save.php
+++ b/mod/categories/actions/save.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Elgg categories plugin category saver
*
@@ -13,10 +12,10 @@
$categories = get_input('categories');
$categories = string_to_tag_array($categories);
-global $CONFIG;
$site = $CONFIG->site;
$site->categories = $categories;
system_message(elgg_echo("categories:save:success"));
-forward($_SERVER['HTTP_REFERER']);
+elgg_delete_admin_notice('categories_admin_notice_no_categories');
+forward($_SERVER['HTTP_REFERER']); \ No newline at end of file
diff --git a/mod/categories/languages/en.php b/mod/categories/languages/en.php
index 588c194e4..cbe5a608f 100644
--- a/mod/categories/languages/en.php
+++ b/mod/categories/languages/en.php
@@ -1,15 +1,12 @@
<?php
- $english = array(
-
- 'categories' => 'Categories',
- 'categories:settings' => 'Set site categories',
- '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",
-
- );
-
- add_translation("en",$english);
+$english = array(
+ 'categories' => 'Categories',
+ 'categories:settings' => 'Set site categories',
+ '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>",
+);
-?> \ No newline at end of file
+add_translation("en",$english); \ No newline at end of file
diff --git a/mod/categories/manifest.xml b/mod/categories/manifest.xml
index 443872e57..635543ee3 100644
--- a/mod/categories/manifest.xml
+++ b/mod/categories/manifest.xml
@@ -1,10 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin_manifest>
- <field key="author" value="Curverider" />
- <field key="version" value="1.7" />
- <field key="description" value="Site wide categories" />
- <field key="website" value="http://www.elgg.org/" />
- <field key="copyright" value="(C) Curverider 2008-2010" />
- <field key="licence" value="GNU Public License version 2" />
- <field key="elgg_version" value="2010030101" />
+ <field key="name" value="Site-wide Categories" />
+ <field key="author" value="Curverider" />
+ <field key="version" value="1.7" />
+ <field key="description" value="Site-wide Categories lets administrators define categories that users across the site can add content to." />
+ <field key="website" value="http://www.elgg.org/" />
+ <field key="copyright" value="(C) Curverider 2008-2010" />
+ <field key="licence" value="GNU Public License version 2" />
+ <field key="elgg_version" value="2010030101" />
+ <field key="admin_interface" value="advanced" />
+ <field key="on_enable" value="categories_on_enable" />
+ <field key="on_disable" value="categories_on_disable" />
</plugin_manifest>
diff --git a/mod/categories/start.php b/mod/categories/start.php
index dd6da16d5..60ee01065 100644
--- a/mod/categories/start.php
+++ b/mod/categories/start.php
@@ -15,52 +15,39 @@
*
*/
function categories_init() {
-
global $CONFIG;
elgg_extend_view('css', 'categories/css');
- register_action('categories/save',false,$CONFIG->pluginspath . 'categories/actions/save.php',true);
+ register_action('settings/categories/save', FALSE, $CONFIG->pluginspath . 'categories/actions/save.php', TRUE);
register_page_handler('categories', 'categories_page_handler');
+ register_elgg_event_handler('update','all','categories_save');
+ register_elgg_event_handler('create','all','categories_save');
}
-/**
- * Set up admin menu item
- *
- */
-function categories_pagesetup() {
- if (get_context() == 'admin' && isadminloggedin()) {
- global $CONFIG;
- add_submenu_item(elgg_echo('categories:settings'), $CONFIG->wwwroot . 'mod/categories/settings.php');
- }
-}
/**
* Page handler
*
*/
function categories_page_handler() {
-
include(dirname(__FILE__) . "/listing.php");
- return true;
+ return TRUE;
}
/**
- * Save site categories
+ * Save site categories to and object upon save / edit
*
*/
function categories_save($event, $object_type, $object) {
-
if ($object instanceof ElggEntity) {
-
$marker = get_input('universal_category_marker');
if ($marker == 'on') {
-
$categories = get_input('universal_categories_list');
-
+
if (empty($categories)) {
$categories = array();
}
@@ -68,12 +55,26 @@ function categories_save($event, $object_type, $object) {
$object->universal_categories = $categories;
}
}
+ return TRUE;
+}
- return true;
+/**
+ * Add a reminder to set default categories.
+ */
+function categories_on_enable() {
+ if (!$site->categories) {
+ global $CONFIG;
+ $message = sprintf(elgg_echo('categories:on_enable_reminder'), "{$CONFIG->url}pg/admin/plugin_settings/categories");
+ elgg_add_admin_notice('categories_admin_notice_no_categories', $message);
+ }
+ return TRUE;
}
+/**
+ * Clean up admin notices on disable.
+ */
+function categories_on_disable() {
+ elgg_delete_admin_notice('categories_admin_notice_no_categories');
+}
-register_elgg_event_handler('init','system','categories_init');
-register_elgg_event_handler('pagesetup','system','categories_pagesetup');
-register_elgg_event_handler('update','all','categories_save');
-register_elgg_event_handler('create','all','categories_save');
+register_elgg_event_handler('init','system','categories_init'); \ No newline at end of file
diff --git a/mod/categories/views/default/categories/css.php b/mod/categories/views/default/categories/css.php
index d2cf5a8a8..6dfe60047 100644
--- a/mod/categories/views/default/categories/css.php
+++ b/mod/categories/views/default/categories/css.php
@@ -1,11 +1,11 @@
<?php
- /**
- * Categories CSS extender
- *
- * @package Elgg File Repository
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.com/
- */
+/**
+ * Categories CSS extender
+ *
+ * @package Categories
+ * @copyright Curverider Ltd 2008-2010
+ * @link http://elgg.com/
+ */
?>
.categories .input-checkboxes {
@@ -25,13 +25,13 @@
}
#two_column_left_sidebar_maincontent .contentWrapper .categories {
border:1px solid #CCCCCC;
- -webkit-border-radius: 4px;
+ -webkit-border-radius: 4px;
-moz-border-radius: 4px;
padding:5px;
- margin:0 0 15px 0;
+ margin:0 0 15px 0;
}
#two_column_left_sidebar_maincontent .contentWrapper .categories p {
- margin:0;
+ margin:0;
}
#two_column_left_sidebar_maincontent .contentWrapper .blog_post .categories {
border:none;
@@ -41,10 +41,10 @@
#two_column_left_sidebar .blog_categories {
background:white;
- -webkit-border-radius: 8px;
+ -webkit-border-radius: 8px;
-moz-border-radius: 8px;
- padding:10px;
- margin:0 10px 10px 10px;
+ padding:10px;
+ margin:0 10px 10px 10px;
}
#two_column_left_sidebar .blog_categories h2 {
background:none;
diff --git a/mod/categories/views/default/categories/settings.php b/mod/categories/views/default/categories/settings.php
deleted file mode 100644
index 7f38b6579..000000000
--- a/mod/categories/views/default/categories/settings.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-echo elgg_view_title(elgg_echo('categories:settings'));
-
-?>
-
-<div class="contentWrapper">
- <p>
- <?php echo elgg_echo('categories:explanation'); ?>
- </p>
-
-
- <?php
-
- echo elgg_view('input/form', array(
- 'action' => $vars['url'] . 'action/categories/save',
- 'method' => 'post',
- 'body' => elgg_view('categories/settingsform',$vars)
- )
- );
-
- ?>
-
-</div> \ No newline at end of file
diff --git a/mod/categories/views/default/categories/settingsform.php b/mod/categories/views/default/categories/settingsform.php
deleted file mode 100644
index 044f01dcd..000000000
--- a/mod/categories/views/default/categories/settingsform.php
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php
-
- echo elgg_view('input/tags',array('value' => $vars['categories'],
- 'internalname' => 'categories'));
-
-?>
- <input type="submit" value="<?php echo elgg_echo('save'); ?>" /> \ No newline at end of file
diff --git a/mod/categories/settings.php b/mod/categories/views/default/settings/categories/edit.php
index 260b057c3..3742fd1e6 100644
--- a/mod/categories/settings.php
+++ b/mod/categories/views/default/settings/categories/edit.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Elgg categories plugin settings page
*
@@ -10,15 +9,7 @@
* @link http://elgg.com/
*/
-// Load engine and restrict to admins
-require_once(dirname(dirname(dirname(__FILE__))) . '/engine/start.php');
-admin_gatekeeper();
-
-// Set context
-set_context('admin');
-
// Get site and categories
-global $CONFIG;
$site = $CONFIG->site;
$categories = $site->categories;
@@ -26,10 +17,12 @@ if (empty($categories)) {
$categories = array();
}
-// Load category save view
-$body = elgg_view('categories/settings',array('categories' => $categories));
-
-
-$body = elgg_view_layout('two_column_left_sidebar', '', $body);
-
-page_draw(elgg_echo('categories:settings'), $body);
+?>
+<div class="contentWrapper">
+ <p>
+ <?php echo elgg_echo('categories:explanation'); ?>
+ </p>
+ <?php
+ echo elgg_view('input/tags', array('value' => $categories, 'internalname' => 'categories'));
+ ?>
+</div> \ No newline at end of file