diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-03-03 17:53:05 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-03-03 17:53:05 +0000 |
commit | 4766f36a4d74924f21ff329c4318ce4e069ffa04 (patch) | |
tree | 969b84632f2a8b0db79788a8a6db8e41d63e5cb4 /mod/categories | |
parent | 57a217fd6b708844407486046a1faa23b46cac08 (diff) | |
download | elgg-4766f36a4d74924f21ff329c4318ce4e069ffa04.tar.gz elgg-4766f36a4d74924f21ff329c4318ce4e069ffa04.tar.bz2 |
Pulled in the interface changes.
git-svn-id: http://code.elgg.org/elgg/trunk@5257 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/categories')
-rw-r--r-- | mod/categories/actions/save.php | 23 | ||||
-rw-r--r-- | mod/categories/languages/en.php | 14 | ||||
-rw-r--r-- | mod/categories/manifest.xml | 10 | ||||
-rw-r--r-- | mod/categories/readme.txt | 26 | ||||
-rw-r--r-- | mod/categories/settings.php | 43 | ||||
-rw-r--r-- | mod/categories/start.php | 70 | ||||
-rw-r--r-- | mod/categories/views/default/categories.php | 48 | ||||
-rw-r--r-- | mod/categories/views/default/categories/css.php | 61 | ||||
-rw-r--r-- | mod/categories/views/default/categories/list.php | 41 | ||||
-rw-r--r-- | mod/categories/views/default/categories/settings.php | 26 | ||||
-rw-r--r-- | mod/categories/views/default/categories/settingsform.php | 7 | ||||
-rw-r--r-- | mod/categories/views/default/categories/view.php | 19 |
12 files changed, 388 insertions, 0 deletions
diff --git a/mod/categories/actions/save.php b/mod/categories/actions/save.php new file mode 100644 index 000000000..c8d8bd051 --- /dev/null +++ b/mod/categories/actions/save.php @@ -0,0 +1,23 @@ +<?php + + /** + * Elgg categories plugin category saver + * + * @package ElggCategories + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd <info@elgg.com> + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + + $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']); + +?> diff --git a/mod/categories/languages/en.php b/mod/categories/languages/en.php new file mode 100644 index 000000000..ecd01a9df --- /dev/null +++ b/mod/categories/languages/en.php @@ -0,0 +1,14 @@ +<?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.', + + ); + + add_translation("en",$english); + +?>
\ No newline at end of file diff --git a/mod/categories/manifest.xml b/mod/categories/manifest.xml new file mode 100644 index 000000000..443872e57 --- /dev/null +++ b/mod/categories/manifest.xml @@ -0,0 +1,10 @@ +<?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" /> +</plugin_manifest> diff --git a/mod/categories/readme.txt b/mod/categories/readme.txt new file mode 100644 index 000000000..49241b2f4 --- /dev/null +++ b/mod/categories/readme.txt @@ -0,0 +1,26 @@ +Site-wide categories +-------------------- + +NOTES FOR PROGRAMMERS: + +If you're not a programmer, don't worry! All the main Elgg tools +are already adapted to use categories, and a growing number of +third party Elgg tools use it too. + + +This plugin uses views and events hooks to allow you to easily add +site-wide categories across Elgg tools. + +This is a two-line addition to any plugin. + +In your edit/create form: + + echo elgg_view('categories', $vars); + +In your object view: + + echo elgg_view('categories/view', $vars); + +Note that in both cases, $vars['entity'] MUST be populated with +the entity the categories apply to, if it exists. (i.e., there's +no need for this on a create form.)
\ No newline at end of file diff --git a/mod/categories/settings.php b/mod/categories/settings.php new file mode 100644 index 000000000..85696730a --- /dev/null +++ b/mod/categories/settings.php @@ -0,0 +1,43 @@ +<?php + + /** + * Elgg categories plugin settings page + * + * @package ElggCategories + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd <info@elgg.com> + * @copyright Curverider Ltd 2008-2010 + * @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; + + if (empty($categories)) $categories = array(); + + // Load category save view + + $body = elgg_view('categories/settings',array( + 'categories' => $categories, + )); + + // Layout + + $body = elgg_view_layout('two_column_left_sidebar','', $body); + + // View page + page_draw(elgg_echo('categories:settings'),$body); + +?>
\ No newline at end of file diff --git a/mod/categories/start.php b/mod/categories/start.php new file mode 100644 index 000000000..1a8e686fe --- /dev/null +++ b/mod/categories/start.php @@ -0,0 +1,70 @@ +<?php + + /** + * Elgg categories plugin + * + * @package ElggCategories + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd <info@elgg.com> + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + + /** + * Initialise categories actions etc + * + */ + function categories_init() { + + // Get config + global $CONFIG; + + elgg_extend_view('css', 'categories/css'); + + // Register action + register_action('categories/save',false,$CONFIG->pluginspath . 'categories/actions/save.php',true); + + } + + /** + * Set up menu items + * + */ + function categories_pagesetup() + { + if (get_context() == 'admin' && isadminloggedin()) { + global $CONFIG; + add_submenu_item(elgg_echo('categories:settings'), $CONFIG->wwwroot . 'mod/categories/settings.php'); + } + } + + /** + * Save categories + * + */ + 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(); + + $object->universal_categories = $categories; + + } + + } + return true; + + } + + + 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'); + +?>
\ No newline at end of file diff --git a/mod/categories/views/default/categories.php b/mod/categories/views/default/categories.php new file mode 100644 index 000000000..f5a41cfa1 --- /dev/null +++ b/mod/categories/views/default/categories.php @@ -0,0 +1,48 @@ +<?php + + /** + * Elgg categories plugin + * + * @package ElggCategories + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd <info@elgg.com> + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + + if (isset($vars['entity']) && $vars['entity'] instanceof ElggEntity) { + $selected_categories = $vars['entity']->universal_categories; + } + $categories = $vars['config']->site->categories; + if (empty($categories)) $categories = array(); + if (empty($selected_categories)) $selected_categories = array(); + + if (!empty($categories)) { + if (!is_array($categories)) $categories = array($categories); + +?> + + <div id="content_area_user_title"><h2 class="categoriestitle"><?php echo elgg_echo('categories'); ?></h2></div> + <div class="categories"> + <p> + +<?php + + echo elgg_view('input/checkboxes',array( + 'options' => $categories, + 'value' => $selected_categories, + 'internalname' => 'universal_categories_list' + )); + +?> + <input type="hidden" name="universal_category_marker" value="on" /> + </p> + </div> + +<?php + + } else { + echo '<input type="hidden" name="universal_category_marker" value="on" />'; + } + +?>
\ No newline at end of file diff --git a/mod/categories/views/default/categories/css.php b/mod/categories/views/default/categories/css.php new file mode 100644 index 000000000..d2cf5a8a8 --- /dev/null +++ b/mod/categories/views/default/categories/css.php @@ -0,0 +1,61 @@ +<?php + /** + * Categories CSS extender + * + * @package Elgg File Repository + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ +?> + +.categories .input-checkboxes { + padding:0; + margin:2px 5px 0 0; +} +.categories label { + font-size: 100%; + line-height:1.2em; +} + +#two_column_left_sidebar_maincontent .contentWrapper h2.categoriestitle { + padding: 0 0 3px 0; + margin:0; + font-size:120%; + color:#333333; +} +#two_column_left_sidebar_maincontent .contentWrapper .categories { + border:1px solid #CCCCCC; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + padding:5px; + margin:0 0 15px 0; +} +#two_column_left_sidebar_maincontent .contentWrapper .categories p { + margin:0; +} +#two_column_left_sidebar_maincontent .contentWrapper .blog_post .categories { + border:none; + margin:0; + padding:0; +} + +#two_column_left_sidebar .blog_categories { + background:white; + -webkit-border-radius: 8px; + -moz-border-radius: 8px; + padding:10px; + margin:0 10px 10px 10px; +} +#two_column_left_sidebar .blog_categories h2 { + background:none; + border-top:none; + margin:0; + padding:0 0 5px 0; + font-size:1.25em; + line-height:1.2em; + color:#0054A7; +} +#two_column_left_sidebar .blog_categories ul { + color:#0054A7; + margin:5px 0 0 0; +}
\ No newline at end of file diff --git a/mod/categories/views/default/categories/list.php b/mod/categories/views/default/categories/list.php new file mode 100644 index 000000000..b6f9f4302 --- /dev/null +++ b/mod/categories/views/default/categories/list.php @@ -0,0 +1,41 @@ +<?php + + $categories = $vars['config']->site->categories; + + if ($categories) { + if (!is_array($categories)) $categories = array($categories); + + if (!empty($vars['subtype'])) { + $flag = array(); + $owner_guid = ''; + if (isset($vars['owner_guid'])) $owner_guid = (int) $vars['owner_guid']; + if ($cats = get_tags(0,999,'universal_categories','object',$vars['subtype'],$owner_guid)) + foreach($cats as $cat) + $flag[] = $cat->tag; + + } else { + $flag = null; + } + + if (is_null($flag) || !empty($flag)) { + +?> + + <h2><?php echo elgg_echo('categories'); ?></h2> + <div class="categories"> + <?php + + $catstring = ''; + if (!empty($categories)) { + foreach($categories as $category) { + if (is_null($flag) || (is_array($flag) && in_array($category,$flag))) + $catstring .= '<li><a href="'.$vars['baseurl'].urlencode($category).'">'. $category .'</a></li>'; + } + } + if (!empty($catstring)) echo "<ul>{$catstring}</ul>"; + + ?> + </div> +<?php } + +}?>
\ No newline at end of file diff --git a/mod/categories/views/default/categories/settings.php b/mod/categories/views/default/categories/settings.php new file mode 100644 index 000000000..6c55d88f9 --- /dev/null +++ b/mod/categories/views/default/categories/settings.php @@ -0,0 +1,26 @@ +<?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 new file mode 100644 index 000000000..044f01dcd --- /dev/null +++ b/mod/categories/views/default/categories/settingsform.php @@ -0,0 +1,7 @@ +<?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/views/default/categories/view.php b/mod/categories/views/default/categories/view.php new file mode 100644 index 000000000..ef092ce84 --- /dev/null +++ b/mod/categories/views/default/categories/view.php @@ -0,0 +1,19 @@ +<?php + + $linkstr = ''; + if (isset($vars['entity']) && $vars['entity'] instanceof ElggEntity) { + + $categories = $vars['entity']->universal_categories; + if (!empty($categories)) { + if (!is_array($categories)) $categories = array($categories); + foreach($categories as $category) { + $link = $vars['url'] . 'search?tagtype=universal_categories&tag=' . urlencode($category); + if (!empty($linkstr)) $linkstr .= ', '; + $linkstr .= '<a href="'.$link.'">' . $category . '</a>'; + } + } + + } + echo $linkstr; + +?>
\ No newline at end of file |