]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/tagcloudsection.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / lib / tagcloudsection.php
index 178dd88ca7399fb9ff0fc330455d35383e0e9eef..9f7320f2de41d750c96da518299e5ab843e4efac 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Laconica, the distributed open-source microblogging tool
+ * StatusNet, the distributed open-source microblogging tool
  *
  * Base class for sections showing tag clouds
  *
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  * @category  Widget
- * @package   Laconica
- * @author    Evan Prodromou <evan@controlyourself.ca>
- * @copyright 2009 Control Yourself, Inc.
+ * @package   StatusNet
+ * @author    Evan Prodromou <evan@status.net>
+ * @copyright 2009 StatusNet, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link      http://laconi.ca/
+ * @link      http://status.net/
  */
 
-if (!defined('LACONICA')) {
+if (!defined('STATUSNET') && !defined('LACONICA')) {
     exit(1);
 }
 
-define('TAGS_PER_SECTION', 20);
+define('TAGS_PER_SECTION', 10);
 
 /**
  * Base class for sections
@@ -40,20 +40,21 @@ define('TAGS_PER_SECTION', 20);
  * group, or site.
  *
  * @category Widget
- * @package  Laconica
- * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @package  StatusNet
+ * @author   Evan Prodromou <evan@status.net>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link     http://laconi.ca/
+ * @link     http://status.net/
  */
-
 class TagCloudSection extends Section
 {
     function showContent()
     {
         $tags = $this->getTags();
+        //* NOISY-DEBUG: */ common_debug('[' . __METHOD__ . ':' . __LINE__ . '] tags[]=' . gettype($tags));
 
         if (!$tags) {
-            $this->out->element('p', null, _('None'));
+            // TRANS: Content displayed in a tag cloud section if there are no tags.
+            $this->out->element('p', null, _m('NOTAGS','None'));
             return false;
         }
 
@@ -63,12 +64,16 @@ class TagCloudSection extends Section
         $sum = 0;
 
         while ($tags->fetch() && ++$cnt <= TAGS_PER_SECTION) {
-            $tw[$tags->tag] = $tags->weight;
-            $sum += $tags->weight;
+            // Check scope of tag to current profile (including guests)
+            if ($tags->isCurrentProfileInScope()) {
+                $tw[$tags->tag] = $tags->weight;
+                $sum += $tags->weight;
+            }
         }
 
         if ($cnt == 0) {
-            $this->out->element('p', null, _('(None)'));
+            // TRANS: Content displayed in a tag cloud section if there are no tags.
+            $this->out->element('p', null, _m('NOTAGS','None'));
             return false;
         }
 
@@ -76,7 +81,7 @@ class TagCloudSection extends Section
 
         $this->out->elementStart('ul', 'tags xoxo tag-cloud');
         foreach ($tw as $tag => $weight) {
-            $this->showTag($tag, $weight, $weight/$sum);
+            $this->showTag($tag, $weight, ($sum == 0) ? 0 : $weight/$sum);
         }
         $this->out->elementEnd('ul');
 
@@ -114,6 +119,9 @@ class TagCloudSection extends Section
 
     function tagUrl($tag)
     {
+        if ($this->out instanceof ShowstreamAction) {
+            return common_local_url('showstream', array('nickname' => $this->out->getTarget()->getNickname(), 'tag' => $tag));
+        }
         return common_local_url('tag', array('tag' => $tag));
     }