]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
some clean up of the categories plugin - html/css polish needed
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 11 Feb 2011 22:51:08 +0000 (22:51 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 11 Feb 2011 22:51:08 +0000 (22:51 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8122 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/categories/actions/save.php
mod/categories/languages/en.php
mod/categories/listing.php
mod/categories/readme.txt
mod/categories/start.php
mod/categories/views/default/categories.php
mod/categories/views/default/categories/list.php [deleted file]
mod/categories/views/default/categories/view.php
mod/categories/views/default/input/categories.php [new file with mode: 0644]
mod/categories/views/default/output/categories.php [new file with mode: 0644]
mod/categories/views/default/settings/categories/edit.php

index 3aa8b3261688f4abeee5f973107757362f0e29ce..26222a0302fa350bd256bda0a6dd60dbf32fb755 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 /**
- * Elgg categories plugin category saver
+ * Saves the available categories for the site
+ *
+ * @note The categories for an object are saved through an event handler: categories_save()
  *
  * @package ElggCategories
  */
index cbe5a608f2491fa35c7dc00a62b6771661022f35..1954ba8d97ffb06df93c4e20b7d525a75f89b1da 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+/**
+ * Categories English language file
+ */
 
 $english = array(
        'categories' => 'Categories',
@@ -9,4 +12,4 @@ $english = array(
        'categories:on_enable_reminder' => "You haven't added any categories yet!  <a href=\"%s\">Add categories now.</a>",
 );
 
-add_translation("en",$english);
\ No newline at end of file
+add_translation("en", $english);
\ No newline at end of file
index 19fb65069a31835deff165035f320f3a016c8fd8..abbcf67851c5424798ea4ae39666fc9aa3922247 100644 (file)
@@ -1,16 +1,14 @@
 <?php
 /**
- * Elgg categories listing page
+ * List entities by category
  *
  * @package ElggCategories
  */
 
-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);
+$owner_guid = get_input("owner_guid", ELGG_ENTITIES_ANY_VALUE);
 $subtype = get_input("subtype", ELGG_ENTITIES_ANY_VALUE);
 $type = get_input("type", 'object');
 
@@ -24,9 +22,7 @@ $params = array(
        'full_view' => 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));
 
index 49241b2f43e9b253a8de737f15756d7f854f1416..48d07fe8f0ab437cfdd3842d91a4715e6f194fc2 100644 (file)
@@ -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
index aa460677ada480894a427565fd2ae3e7eadabd6e..5590c008924af130c3c6c38b427e30f9e5391274 100644 (file)
@@ -1,11 +1,12 @@
 <?php
-
 /**
  * Elgg categories plugin
  *
  * @package ElggCategories
  */
 
+elgg_register_event_handler('init', 'system', 'categories_init');
+
 /**
  * Initialise categories plugin
  *
@@ -19,8 +20,8 @@ function categories_init() {
 
        register_page_handler('categories', 'categories_page_handler');
 
-       elgg_register_event_handler('update','all','categories_save');
-       elgg_register_event_handler('create','all','categories_save');
+       elgg_register_event_handler('update', 'all', 'categories_save');
+       elgg_register_event_handler('create', 'all', 'categories_save');
 }
 
 
@@ -34,7 +35,7 @@ function categories_page_handler() {
 }
 
 /**
- * Save site categories to and object upon save / edit
+ * Save categories to object upon save / edit
  *
  */
 function categories_save($event, $object_type, $object) {
@@ -72,5 +73,3 @@ function categories_on_enable() {
 function categories_on_disable() {
        elgg_delete_admin_notice('categories_admin_notice_no_categories');
 }
-
-elgg_register_event_handler('init','system','categories_init');
\ No newline at end of file
index f69283e9ffe4baebae6ae1e404819f2e864fe47f..8577ef01b968d8aa4b40e0fb28a3635a30287945 100644 (file)
@@ -1,48 +1,12 @@
 <?php
-
 /**
- * Elgg categories plugin
+ * Categories input view
  *
  * @package ElggCategories
+ *
+ * @deprecated 1.8
  */
 
-if (isset($vars['entity']) && $vars['entity'] instanceof ElggEntity) {
-       $selected_categories = $vars['entity']->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);
-       }
-
-       ?>
-
-<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
+elgg_deprecated_notice("Use input/categories instead of categories", 1.8);
 
-} else {
-       echo '<input type="hidden" name="universal_category_marker" value="on" />';
-}
+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 (file)
index 7a6dadf..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-
-$categories = elgg_get_site_entity()->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)) {
-
-               ?>
-
-<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
-       }
-
-}
index 043b1d78e502cb95fddedadaba3d6250cad91c3b..6d1f7c1bbf5a3c56c5e51edaf57b08e711b7402d 100644 (file)
@@ -1,22 +1,8 @@
 <?php
+/**
+ * @deprecated 1.8
+ */
 
-$linkstr = '';
-if (isset($vars['entity']) && $vars['entity'] instanceof ElggEntity) {
+elgg_deprecated_notice("Use output/categories instead of categories/view", 1.8);
 
-       $categories = $vars['entity']->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 .= '<a href="'.$link.'">' . $category . '</a>';
-               }
-       }
-
-}
-
-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 (file)
index 0000000..6f57a0c
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Categories input view
+ *
+ * @package ElggCategories
+ *
+ * @uses $vars['entity'] The entity being edited or created
+ */
+
+if (isset($vars['entity']) && $vars['entity'] instanceof ElggEntity) {
+       $selected_categories = $vars['entity']->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);
+       }
+
+       ?>
+
+<p class="categories">
+       <label><?php echo elgg_echo('categories'); ?></label><br />
+       <?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>
+
+       <?php
+
+} else {
+       echo '<input type="hidden" name="universal_category_marker" value="on" />';
+}
diff --git a/mod/categories/views/default/output/categories.php b/mod/categories/views/default/output/categories.php
new file mode 100644 (file)
index 0000000..724c460
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+/**
+ * View categories on an entity
+ *
+ * @uses $vars['entity']
+ */
+
+$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 = elgg_get_site_url() . 'pg/categories/list/?category=' . urlencode($category);
+                       if (!empty($linkstr)) {
+                               $linkstr .= ', ';
+                       }
+                       $linkstr .= '<a href="'.$link.'">' . $category . '</a>';
+               }
+       }
+
+}
+
+echo $linkstr;
index 9e0af0e48abb7d1f133a761bf1d671e532064b1b..e4750f02f7ae5d0e5e7aad4edcf32e14a3dcbb30 100644 (file)
@@ -1,11 +1,11 @@
 <?php
 /**
- * Elgg categories plugin settings page
+ * Administrator sets the categories for the site
  *
  * @package ElggCategories
  */
 
-// Get site and categories
+// Get site categories
 $site = elgg_get_site_entity();
 $categories = $site->categories;
 
@@ -14,11 +14,8 @@ if (empty($categories)) {
 }
 
 ?>
-<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
+<p>
+       <?php echo elgg_echo('categories:explanation'); ?>
+</p>
+<?php
+echo elgg_view('input/tags', array('value' => $categories, 'internalname' => 'categories'));