From 891739afadddad56b517b7d565458296eeb58c0b Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 11 Feb 2011 22:51:08 +0000 Subject: some clean up of the categories plugin - html/css polish needed git-svn-id: http://code.elgg.org/elgg/trunk@8122 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/categories/actions/save.php | 4 +- mod/categories/languages/en.php | 5 +- mod/categories/listing.php | 8 +-- mod/categories/readme.txt | 9 ++-- mod/categories/start.php | 11 ++-- mod/categories/views/default/categories.php | 46 ++-------------- mod/categories/views/default/categories/list.php | 62 ---------------------- mod/categories/views/default/categories/view.php | 24 ++------- mod/categories/views/default/input/categories.php | 45 ++++++++++++++++ mod/categories/views/default/output/categories.php | 27 ++++++++++ .../views/default/settings/categories/edit.php | 17 +++--- 11 files changed, 107 insertions(+), 151 deletions(-) delete mode 100644 mod/categories/views/default/categories/list.php create mode 100644 mod/categories/views/default/input/categories.php create mode 100644 mod/categories/views/default/output/categories.php (limited to 'mod/categories') diff --git a/mod/categories/actions/save.php b/mod/categories/actions/save.php index 3aa8b3261..26222a030 100644 --- a/mod/categories/actions/save.php +++ b/mod/categories/actions/save.php @@ -1,6 +1,8 @@ 'Categories', @@ -9,4 +12,4 @@ $english = array( 'categories:on_enable_reminder' => "You haven't added any categories yet! Add categories now.", ); -add_translation("en",$english); \ No newline at end of file +add_translation("en", $english); \ No newline at end of file diff --git a/mod/categories/listing.php b/mod/categories/listing.php index 19fb65069..abbcf6785 100644 --- a/mod/categories/listing.php +++ b/mod/categories/listing.php @@ -1,16 +1,14 @@ FALSE, 'metadata_case_sensitive' => FALSE, ); -elgg_push_context('search'); $objects = elgg_list_entities_from_metadata($params); -elgg_pop_context(); $title = elgg_echo('categories:results', array($category)); diff --git a/mod/categories/readme.txt b/mod/categories/readme.txt index 49241b2f4..48d07fe8f 100644 --- a/mod/categories/readme.txt +++ b/mod/categories/readme.txt @@ -1,7 +1,7 @@ Site-wide categories -------------------- -NOTES FOR PROGRAMMERS: +NOTES FOR DEVELOPERS: 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 @@ -15,12 +15,11 @@ This is a two-line addition to any plugin. In your edit/create form: - echo elgg_view('categories', $vars); + echo elgg_view('input/categories', $vars); In your object view: - echo elgg_view('categories/view', $vars); + echo elgg_view('output/categories', $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 +the entity the categories apply to, if it exists. \ No newline at end of file diff --git a/mod/categories/start.php b/mod/categories/start.php index aa460677a..5590c0089 100644 --- a/mod/categories/start.php +++ b/mod/categories/start.php @@ -1,11 +1,12 @@ universal_categories; -} -$categories = elgg_get_site_entity()->categories; -if (empty($categories)) { - $categories = array(); -} -if (empty($selected_categories)) { - $selected_categories = array(); -} - -if (!empty($categories)) { - if (!is_array($categories)) { - $categories = array($categories); - } - - ?> - -

-
-

- - $categories, - 'value' => $selected_categories, - 'internalname' => 'universal_categories_list' - )); - - ?> - -

-
- - '; -} +echo elgg_view('input/categories', $vars); diff --git a/mod/categories/views/default/categories/list.php b/mod/categories/views/default/categories/list.php deleted file mode 100644 index 7a6dadff4..000000000 --- a/mod/categories/views/default/categories/list.php +++ /dev/null @@ -1,62 +0,0 @@ -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']; - } - - elgg_register_tag_metadata_name('universal_categories'); - $params = array( - 'threshold' => 1, - 'limit' => 999, - 'tag_names' => array('universal_categories'), - 'types' => 'object', - 'subtypes' => $vars['subtype'], - 'owner_guid' => $owner_guid, - ); - $cats = elgg_get_tags($params); - if ($cats) { - foreach($cats as $cat) { - $flag[] = $cat->tag; - } - } - - } else { - $flag = null; - } - - if (is_null($flag) || !empty($flag)) { - - ?> - -

-
- '. $category .''; - } - } - } - if (!empty($catstring)) { - echo ""; - } - - ?> -
- universal_categories; - if (!empty($categories)) { - if (!is_array($categories)) { - $categories = array($categories); - } - foreach($categories as $category) { - $link = elgg_get_site_url() . 'pg/categories/list/?category=' . urlencode($category); - if (!empty($linkstr)) { - $linkstr .= ', '; - } - $linkstr .= '' . $category . ''; - } - } - -} - -echo $linkstr; +echo elgg_view('output/categories', $vars); diff --git a/mod/categories/views/default/input/categories.php b/mod/categories/views/default/input/categories.php new file mode 100644 index 000000000..6f57a0c29 --- /dev/null +++ b/mod/categories/views/default/input/categories.php @@ -0,0 +1,45 @@ +universal_categories; +} +$categories = elgg_get_site_entity()->categories; +if (empty($categories)) { + $categories = array(); +} +if (empty($selected_categories)) { + $selected_categories = array(); +} + +if (!empty($categories)) { + if (!is_array($categories)) { + $categories = array($categories); + } + + ?> + +

+
+ $categories, + 'value' => $selected_categories, + 'internalname' => 'universal_categories_list' + )); + + ?> + +

+ + '; +} diff --git a/mod/categories/views/default/output/categories.php b/mod/categories/views/default/output/categories.php new file mode 100644 index 000000000..724c46037 --- /dev/null +++ b/mod/categories/views/default/output/categories.php @@ -0,0 +1,27 @@ +universal_categories; + if (!empty($categories)) { + if (!is_array($categories)) { + $categories = array($categories); + } + foreach($categories as $category) { + $link = elgg_get_site_url() . 'pg/categories/list/?category=' . urlencode($category); + if (!empty($linkstr)) { + $linkstr .= ', '; + } + $linkstr .= '' . $category . ''; + } + } + +} + +echo $linkstr; diff --git a/mod/categories/views/default/settings/categories/edit.php b/mod/categories/views/default/settings/categories/edit.php index 9e0af0e48..e4750f02f 100644 --- a/mod/categories/views/default/settings/categories/edit.php +++ b/mod/categories/views/default/settings/categories/edit.php @@ -1,11 +1,11 @@ categories; @@ -14,11 +14,8 @@ if (empty($categories)) { } ?> -
-

- -

- $categories, 'internalname' => 'categories')); - ?> -
\ No newline at end of file +

+ +

+ $categories, 'internalname' => 'categories')); -- cgit v1.2.3