diff options
Diffstat (limited to 'mod/categories')
-rw-r--r-- | mod/categories/actions/save.php | 37 | ||||
-rw-r--r-- | mod/categories/languages/en.php | 1 | ||||
-rw-r--r-- | mod/categories/listing.php | 40 | ||||
-rw-r--r-- | mod/categories/settings.php | 74 | ||||
-rw-r--r-- | mod/categories/start.php | 135 | ||||
-rw-r--r-- | mod/categories/views/default/categories.php | 90 | ||||
-rw-r--r-- | mod/categories/views/default/categories/list.php | 54 | ||||
-rw-r--r-- | mod/categories/views/default/categories/settings.php | 22 | ||||
-rw-r--r-- | mod/categories/views/default/categories/view.php | 29 |
9 files changed, 269 insertions, 213 deletions
diff --git a/mod/categories/actions/save.php b/mod/categories/actions/save.php index c8d8bd051..21602f659 100644 --- a/mod/categories/actions/save.php +++ b/mod/categories/actions/save.php @@ -1,23 +1,22 @@ <?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/ - */ +/** + * 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']); +$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 index ecd01a9df..588c194e4 100644 --- a/mod/categories/languages/en.php +++ b/mod/categories/languages/en.php @@ -6,6 +6,7 @@ '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", ); diff --git a/mod/categories/listing.php b/mod/categories/listing.php new file mode 100644 index 000000000..ecc1bede5 --- /dev/null +++ b/mod/categories/listing.php @@ -0,0 +1,40 @@ +<?php +/** + * Elgg categories listing page + * + * @package ElggCategories + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + +require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +$limit = get_input("limit", 10); +$offset = get_input("offset", 0); +$category = get_input("category"); +$owner_guid = get_input("owner_guid", 0); +$subtype = get_input("subtype", ELGG_ENTITIES_ANY_VALUE); +$type = get_input("type", 'object'); + +$objects = list_entities_from_metadata('universal_categories', + $category, + $type, + $subtype, + $owner_guid, + $limit, + false, + false, + true, + false); + + +$title = sprintf(elgg_echo('categories:results'), $category); + +$content = elgg_view_title($title); +$content .= $objects; + +$body = elgg_view_layout('two_column_left_sidebar', '', $content); + +page_draw($title, $body); diff --git a/mod/categories/settings.php b/mod/categories/settings.php index 85696730a..260b057c3 100644 --- a/mod/categories/settings.php +++ b/mod/categories/settings.php @@ -1,43 +1,35 @@ <?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 +/** + * 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)); + + +$body = elgg_view_layout('two_column_left_sidebar', '', $body); + +page_draw(elgg_echo('categories:settings'), $body); diff --git a/mod/categories/start.php b/mod/categories/start.php index 1a8e686fe..dd6da16d5 100644 --- a/mod/categories/start.php +++ b/mod/categories/start.php @@ -1,70 +1,79 @@ <?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) { +/** + * 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 plugin + * + */ +function categories_init() { + + global $CONFIG; + + elgg_extend_view('css', 'categories/css'); + + register_action('categories/save',false,$CONFIG->pluginspath . 'categories/actions/save.php',true); + + register_page_handler('categories', 'categories_page_handler'); + +} + +/** + * 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; +} + +/** + * Save site 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 ($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; - - } - + if (empty($categories)) { + $categories = array(); } - return true; - + + $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 +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'); diff --git a/mod/categories/views/default/categories.php b/mod/categories/views/default/categories.php index f5a41cfa1..98e87a05f 100644 --- a/mod/categories/views/default/categories.php +++ b/mod/categories/views/default/categories.php @@ -1,48 +1,52 @@ <?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 +/** + * 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); + } - 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" />'; - } +<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 -?>
\ No newline at end of file +} else { + echo '<input type="hidden" name="universal_category_marker" value="on" />'; +} diff --git a/mod/categories/views/default/categories/list.php b/mod/categories/views/default/categories/list.php index b6f9f4302..161a21655 100644 --- a/mod/categories/views/default/categories/list.php +++ b/mod/categories/views/default/categories/list.php @@ -1,41 +1,51 @@ <?php - $categories = $vars['config']->site->categories; - - if ($categories) { - if (!is_array($categories)) $categories = array($categories); - +$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) + 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 + ?> + +<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))) + 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 } + 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 index 6c55d88f9..7f38b6579 100644 --- a/mod/categories/views/default/categories/settings.php +++ b/mod/categories/views/default/categories/settings.php @@ -1,26 +1,24 @@ <?php - echo elgg_view_title(elgg_echo('categories:settings')); +echo elgg_view_title(elgg_echo('categories:settings')); ?> - <div class="contentWrapper"> - <p> - <?php echo elgg_echo('categories:explanation'); ?> - </p> - +<div class="contentWrapper"> + <p> + <?php echo elgg_echo('categories:explanation'); ?> + </p> -<?php - echo elgg_view( - 'input/form', - array( + <?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/view.php b/mod/categories/views/default/categories/view.php index ef092ce84..7ee0170d9 100644 --- a/mod/categories/views/default/categories/view.php +++ b/mod/categories/views/default/categories/view.php @@ -1,19 +1,22 @@ <?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>'; +$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'] . 'pg/categories/list/?category=' . urlencode($category); + if (!empty($linkstr)) { + $linkstr .= ', '; } + $linkstr .= '<a href="'.$link.'">' . $category . '</a>'; } - } - echo $linkstr; -?>
\ No newline at end of file +} + +echo $linkstr; |