]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #2091 added a tagcloud block that accepts subtype
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 22 Mar 2011 10:55:51 +0000 (10:55 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 22 Mar 2011 10:55:51 +0000 (10:55 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8814 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/tags.php
mod/blog/views/default/blog/sidebar.php
mod/blog/views/default/blog/sidebar/tagcloud.php [deleted file]
views/default/output/tagcloud.php
views/default/page/elements/tagcloud_block.php [new file with mode: 0644]

index 32d48eff2bdbc7808dbbd11337ee247b348c53f3..1116d63f38a98e0d1ba34780b66f7117b2424b96 100644 (file)
@@ -269,10 +269,11 @@ function elgg_view_tagcloud(array $options = array()) {
        }
 
        $tag_data = elgg_get_tags($options);
-       return elgg_view("output/tagcloud", array('value' => $tag_data,
-                                                                                       'type' => $type,
-                                                                                       'subtype' => $subtype));
-
+       return elgg_view("output/tagcloud", array(
+               'value' => $tag_data,
+               'type' => $type,
+               'subtype' => $subtype,
+       ));
 }
 
 /**
index 4eb5cf4434333f0cba2ae3d427719284c2474850..b7dfaa2e195b81efde7b97ba4d3194739b84b9db 100644 (file)
@@ -19,4 +19,9 @@ if ($vars['page'] == 'all') {
 
 echo elgg_view('blog/sidebar/archives', $vars);
 
-echo elgg_view('blog/sidebar/tagcloud', $vars);
+if ($vars['page'] != 'friends') {
+       echo elgg_view('page/elements/tagcloud_block', array(
+               'subtypes' => 'blog',
+               'owner_guid' => elgg_get_page_owner_guid(),
+       ));
+}
diff --git a/mod/blog/views/default/blog/sidebar/tagcloud.php b/mod/blog/views/default/blog/sidebar/tagcloud.php
deleted file mode 100644 (file)
index 70c4543..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/**
- * Blog tag cloud
- */
-
-$loggedin_user = elgg_get_logged_in_user_entity();
-$page_owner = elgg_get_page_owner_entity();
-
-if ($page_owner && $vars['page'] != 'friends') {
-
-       // friends page lists all tags; mine lists owner's
-       $owner_guid = ($vars['page'] == 'friends') ? '' : $page_owner->getGUID();
-       $options = array(
-               'type' => 'object',
-               'subtype' => 'blog',
-               'owner_guid' => $owner_guid,
-               'threshold' => 0,
-               'limit' => 50,
-               'tag_name' => 'tags',
-       );
-       echo elgg_view_tagcloud($options);
-} else {
-       $options = array(
-               'type' => 'object',
-               'subtype' => 'blog',
-               'threshold' => 0,
-               'limit' => 50,
-               'tag_name' => 'tags',
-       );
-       echo elgg_view_tagcloud($options);
-}
index 3bc04a3fb479c7a1dc0042a84c035652d62d1332..22b6cf49d7ee1ec113564268052553b0f46c31fa 100644 (file)
@@ -12,8 +12,6 @@
  * @uses $vars['subtype'] Entity subtype
  */
 
-$context = elgg_get_context();
-
 if (!empty($vars['subtype'])) {
        $subtype = "&entity_subtype=" . urlencode($vars['subtype']);
 } else {
@@ -53,22 +51,8 @@ if (!empty($vars['tagcloud']) && is_array($vars['tagcloud'])) {
                $url = elgg_format_url($url);
                $cloud .= "<a href=\"$url\" style=\"font-size: $size%\" title=\"".addslashes($tag->tag)." ($tag->total)\">" . htmlspecialchars($tag->tag, ENT_QUOTES, 'UTF-8') . "</a>";
        }
-               
-       if ($context != 'tags') {
-               $cloud .= '<p class="small">';
-               $cloud .= elgg_view_icon('tag');
-               $cloud .= elgg_view('output/url', array(
-                       'href' => 'tags', 
-                       'text' => elgg_echo('tagcloud:allsitetags'),
-               ));
-               $cloud .= '</p>';
-       }
        
        $cloud .= elgg_view('tagcloud/extend');
 
-       if ($context != 'tags') {
-               echo elgg_view_module('aside', elgg_echo('tagcloud'), $cloud, array('class' => 'elgg-tagcloud'));
-       } else {
-               echo "<div class=\"elgg-tagcloud\">$cloud</div>";
-       }
+       echo "<div class=\"elgg-tagcloud\">$cloud</div>";
 }
diff --git a/views/default/page/elements/tagcloud_block.php b/views/default/page/elements/tagcloud_block.php
new file mode 100644 (file)
index 0000000..8b67c9e
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+/**
+ * Display content-based tags
+ *
+ * Generally used in a sidebar. Does not work with groups currently.
+ *
+ * @uses $vars['subtypes']   Object subtype string or array of subtypes
+ * @uses $vars['owner_guid'] The owner of the content being tagged
+ * @uses $vars['limit']      The maxinum number of tags to display
+ */
+
+$owner_guid = elgg_extract('owner_guid', $vars, ELGG_ENTITIES_ANY_VALUE);
+if (!$owner_guid) {
+       $owner_guid = ELGG_ENTITIES_ANY_VALUE;
+}
+
+$owner_entity = get_entity($owner_guid);
+if ($owner_entity && elgg_instanceof($owner_entity, 'group')) {
+       // not supporting groups so return
+       return true;
+}
+
+$options = array(
+       'type' => 'object',
+       'subtype' => elgg_extract('subtypes', $vars, ELGG_ENTITIES_ANY_VALUE),
+       'owner_guid' => $owner_guid,
+       'threshold' => 0,
+       'limit' => elgg_extract('limit', $vars, 50),
+       'tag_name' => 'tags',
+);
+
+$title = elgg_echo('tagcloud');
+if (is_array($options['subtype']) && count($options['subtype']) > 1) {
+       // we cannot provide links to tagged objects with multiple types
+       $tag_data = elgg_get_tags($options);
+       $cloud = elgg_view("output/tagcloud", array(
+               'value' => $tag_data,
+               'type' => $type,
+       ));
+} else {
+       $cloud = elgg_view_tagcloud($options);
+}
+if (!$cloud) {
+       return true;
+}
+
+// add a link to all site tags
+$cloud .= '<p class="small">';
+$cloud .= elgg_view_icon('tag');
+$cloud .= elgg_view('output/url', array(
+       'href' => 'tags',
+       'text' => elgg_echo('tagcloud:allsitetags'),
+));
+$cloud .= '</p>';
+
+
+echo elgg_view_module('aside', $title, $cloud);