]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Sidebar sections to show peopletags and tag subscriptions.
authorShashi Gowda <connect2shashi@gmail.com>
Fri, 8 Apr 2011 10:52:27 +0000 (16:22 +0530)
committerShashi Gowda <connect2shashi@gmail.com>
Fri, 8 Apr 2011 10:52:51 +0000 (16:22 +0530)
FIXME: currently you can see the subscriptions section only on *your* profileaction pages, is this OK?

lib/peopletagsection.php
lib/peopletagsforusersection.php [new file with mode: 0644]
lib/peopletagsubscriptionssection.php [new file with mode: 0644]
lib/profileaction.php
lib/section.php

index 6722f3a149599fff414beb270fe5e53568e3622a..a96863c04b276c75aca9e2e31d261b745450880b 100644 (file)
@@ -112,7 +112,7 @@ class PeopletagSectionItem extends PeopletagListItem
         $this->showPeopletag();
         $this->out->elementEnd('td');
 
-        if ($this->peopletag->value) {
+        if (isset($this->peopletag->value)) {
             $this->out->element('td', 'value', $this->peopletag->value);
         }
         $this->out->elementEnd('tr');
diff --git a/lib/peopletagsforusersection.php b/lib/peopletagsforusersection.php
new file mode 100644 (file)
index 0000000..f074248
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * People tags a user has been tagged with
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category  Widget
+ * @package   StatusNet
+ * @author    Shashi Gowda <connect2shashi@gmail.com>
+ * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link      http://status.net/
+ */
+
+if (!defined('STATUSNET') && !defined('LACONICA')) {
+    exit(1);
+}
+
+/**
+ * People tags a user has been tagged with
+ *
+ * @category Widget
+ * @package  StatusNet
+ * @author   Shashi Gowda <connect2shashi@gmail.com>
+ * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link     http://status.net/
+ */
+
+class PeopletagsForUserSection extends PeopletagSection
+{
+    var $profile=null;
+
+    function __construct($out, Profile $profile)
+    {
+        parent::__construct($out);
+        $this->profile = $profile;
+    }
+
+    function getPeopletags()
+    {
+        $limit = PEOPLETAGS_PER_SECTION+1;
+        $offset = 0;
+
+        $auth_user = common_current_user();
+        $ptags = $this->profile->getOtherTags($auth_user, $offset, $limit);
+
+        return $ptags;
+    }
+
+    function title()
+    {
+        $name = $this->profile->getBestName();
+        if ($this->profile->id == common_current_user()->id) {
+            $name = 'you';
+        }
+        return sprintf(_('People tags for %s'), $name);
+    }
+
+
+    function link()
+    {
+        return common_local_url('peopletagsforuser',
+                array('nickname' => $this->profile->nickname));
+    }
+
+    function moreUrl()
+    {
+        return $this->link();
+    }
+
+    function divId()
+    {
+        return 'peopletag_subscriptions';
+    }
+}
diff --git a/lib/peopletagsubscriptionssection.php b/lib/peopletagsubscriptionssection.php
new file mode 100644 (file)
index 0000000..63a0d13
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Peopletags a user has subscribed to
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category  Widget
+ * @package   StatusNet
+ * @author    Shashi Gowda <connect2shashi@gmail.com>
+ * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link      http://status.net/
+ */
+
+if (!defined('STATUSNET') && !defined('LACONICA')) {
+    exit(1);
+}
+
+/**
+ * Peopletags a user has subscribed to
+ *
+ * @category Widget
+ * @package  StatusNet
+ * @author   Shashi Gowda <connect2shashi@gmail.com>
+ * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link     http://status.net/
+ */
+
+class PeopletagSubscriptionsSection extends PeopletagSection
+{
+    var $profile=null;
+
+    function __construct($out, Profile $profile)
+    {
+        parent::__construct($out);
+        $this->profile = $profile;
+    }
+
+    function getPeopletags()
+    {
+        $limit = PEOPLETAGS_PER_SECTION+1;
+        $offset = 0;
+
+        $ptags = $this->profile->getTagSubscriptions($offset, $limit);
+
+        return $ptags;
+    }
+
+    function title()
+    {
+        return _('People tag subscriptions');
+    }
+
+    function link()
+    {
+        return common_local_url('peopletagsubscriptions',
+                array('nickname' => $this->profile->nickname));
+    }
+
+    function moreUrl()
+    {
+        return $this->link();
+    }
+
+    function divId()
+    {
+        return 'peopletag_subscriptions';
+    }
+}
index f777edd31955d0f20d734604cd700cff97503a18..cd3f5bcde5b94b2bf6b3fc86bb0f60998685da1b 100644 (file)
@@ -97,6 +97,8 @@ class ProfileAction extends OwnerDesignAction
         $this->showSubscriptions();
         $this->showSubscribers();
         $this->showGroups();
+        $this->showPeopletagSubs();
+        $this->showPeopletags();
         $this->showStatistics();
     }
 
@@ -188,6 +190,32 @@ class ProfileAction extends OwnerDesignAction
         $this->elementEnd('div');
     }
 
+    function showPeopletagSubs()
+    {
+        $user = common_current_user();
+        if (!empty($user) && $this->profile->id == $user->id) {
+            if (Event::handle('StartShowPeopletagSubscriptionsSection', array($this))) {
+
+                $profile = $user->getProfile();
+                $section = new PeopletagSubscriptionsSection($this, $profile);
+                $section->show();
+
+                Event::handle('EndShowPeopletagSubscriptionsSection', array($this));
+            }
+        }
+    }
+
+    function showPeopletags()
+    {
+        if (Event::handle('StartShowPeopletagsSection', array($this))) {
+
+            $section = new PeopletagsForUserSection($this, $this->profile);
+            $section->show();
+
+            Event::handle('EndShowPeopletagsSection', array($this));
+        }
+    }
+
     function showStatistics()
     {
         $notice_count = $this->profile->noticeCount();
index 753a37efa424dc52c4f7da187aff869f464aade0..d77673898a7d5ab7119bcd6afc4dc7e477f7b2d8 100644 (file)
@@ -61,8 +61,15 @@ class Section extends Widget
                                  array('id' => $this->divId(),
                                        'class' => 'section'));
 
-        $this->out->element('h2', null,
-                            $this->title());
+        $link = $this->link();
+        if (!empty($link)) {
+            $this->out->elementStart('h2');
+            $this->out->element('a', array('href' => $link), $this->title());
+            $this->out->elementEnd('h2');
+        } else {
+            $this->out->element('h2', null,
+                                $this->title());
+        }
 
         $have_more = $this->showContent();
 
@@ -88,6 +95,11 @@ class Section extends Widget
         return _('Untitled section');
     }
 
+    function link()
+    {
+        return null;
+    }
+
     function showContent()
     {
         $this->out->element('p', null,