]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Directory/lib/sortablesubscriptionlist.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / plugins / Directory / lib / sortablesubscriptionlist.php
index 2a412a628d6f3ab95e15405369bb1dfa0fc67939..719834bc917d3aa9c5e17a74c0e63e9470646725 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * StatusNet, the distributed open-source microblogging tool
  *
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET')) {
-    exit(1);
-}
-
-require_once INSTALLDIR . '/lib/subscriptionlist.php';
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Widget to show a sortable list of subscriptions
@@ -43,19 +38,8 @@ require_once INSTALLDIR . '/lib/subscriptionlist.php';
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://status.net/
  */
-
 class SortableSubscriptionList extends SubscriptionList
 {
-    /** Owner of this list */
-    var $owner = null;
-
-    function __construct($profile, $owner=null, $action=null)
-    {
-        parent::__construct($profile, $owner, $action);
-
-        $this->owner = $owner;
-    }
-
     function startList()
     {
         $this->out->elementStart('table', array('class' => 'profile_list xoxo'));
@@ -63,21 +47,23 @@ class SortableSubscriptionList extends SubscriptionList
         $this->out->elementStart('tr');
 
         $tableHeaders = array(
+            // TRANS: Column header in table for user nickname.
             'nickname'    => _m('Nickname'),
+            // TRANS: Column header in table for timestamp when user was created.
             'created'     => _m('Created')
         );
 
         foreach ($tableHeaders as $id => $label) {
-            $attrs = array('id' => $id);
 
+            $attrs   = array('id' => $id);
             $current = (!empty($this->action->sort) && $this->action->sort == $id);
 
             if ($current || empty($this->action->sort) && $id == 'nickname') {
                 $attrs['class'] = 'current';
             }
 
-            if ($current && !$this->action->boolean('asc')) {
-                $attrs['class'] .= ' asc';
+            if ($current && $this->action->reverse) {
+                $attrs['class'] .= ' reverse';
                 $attrs['class'] = trim($attrs['class']);
             }
 
@@ -86,8 +72,12 @@ class SortableSubscriptionList extends SubscriptionList
             $linkAttrs = array();
             $params    = array('sort' => $id);
 
-            if ($current && !$this->action->boolean('asc')) {
-                $params['asc'] = "true";
+            if (!empty($this->action->q)) {
+                $params['q'] = $this->action->q;
+            }
+
+            if ($current && !$this->action->reverse) {
+                $params['reverse'] = 'true';
             }
 
             $args = array();
@@ -106,9 +96,11 @@ class SortableSubscriptionList extends SubscriptionList
             $this->out->elementEnd('th');
         }
 
-        $this->out->element('th', array('id' => 'subscriptions'), 'Subscriptions');
-        $this->out->element('th', array('id' => 'notices'), 'Notices');
-        //$this->out->element('th', array('id' => 'controls'), 'Controls');
+        // TRANS: Column header for number of subscriptions.
+        $this->out->element('th', array('id' => 'subscriptions'), _m('Subscriptions'));
+        // TRANS: Column header for number of notices.
+        $this->out->element('th', array('id' => 'notices'), _m('Notices'));
+        $this->out->element('th', array('id' => 'controls'), null);
 
         $this->out->elementEnd('tr');
         $this->out->elementEnd('thead');
@@ -122,44 +114,14 @@ class SortableSubscriptionList extends SubscriptionList
         $this->out->elementEnd('table');
     }
 
-    function showProfiles()
-    {
-        $cnt = 0;
-
-        while ($this->profile->fetch()) {
-            $cnt++;
-            if($cnt > PROFILES_PER_PAGE) {
-                break;
-            }
-
-            $odd = ($cnt % 2 == 0); // for zebra striping
-
-            $pli = $this->newListItem($this->profile, $odd);
-            $pli->show();
-        }
-
-        return $cnt;
-    }
-
-    function newListItem($profile, $odd)
+    function newListItem($profile)
     {
-        return new SortableSubscriptionListItem($profile, $this->owner, $this->action, $odd);
+        return new SortableSubscriptionListItem($profile, $this->owner, $this->action);
     }
 }
 
 class SortableSubscriptionListItem extends SubscriptionListItem
 {
-    /** Owner of this list */
-    var $owner = null;
-
-    function __construct($profile, $owner, $action, $alt)
-    {
-        parent::__construct($profile, $owner, $action);
-
-        $this->alt   = $alt; // is this row alternate?
-        $this->owner = $owner;
-    }
-
     function startItem()
     {
         $attr = array(
@@ -167,10 +129,6 @@ class SortableSubscriptionListItem extends SubscriptionListItem
             'id'    => 'profile-' . $this->profile->id
         );
 
-        if ($this->alt) {
-            $attr['class'] .= ' alt';
-        }
-
         $this->out->elementStart('tr', $attr);
     }
 
@@ -181,7 +139,7 @@ class SortableSubscriptionListItem extends SubscriptionListItem
 
     function startProfile()
     {
-        $this->out->elementStart('td', 'entity_profile vcard entry-content');
+        $this->out->elementStart('td', 'entity_profile h-card');
     }
 
     function endProfile()
@@ -197,6 +155,18 @@ class SortableSubscriptionListItem extends SubscriptionListItem
 
     function endActions()
     {
+               
+               // delete button
+               $cur = common_current_user();
+        list($action, $r2args) = $this->out->returnToArgs();
+        $r2args['action'] = $action;        
+               if ($cur instanceof User && $cur->hasRight(Right::DELETEUSER)) {
+                       $this->out->elementStart('li', 'entity_delete');
+                       $df = new DeleteUserForm($this->out, $this->profile, $r2args);
+                       $df->show();            
+                       $this->out->elementEnd('li');
+               }
+                       
         $this->out->elementEnd('ul');
         $this->out->elementEnd('td');
     }
@@ -245,4 +215,35 @@ class SortableSubscriptionListItem extends SubscriptionListItem
         $this->out->elementEnd('td');
     }
 
+    /**
+     * Overrided to truncate the bio if it's real long, because it
+     * looks better that way in the SortableSubscriptionList's table
+     */
+    function showBio()
+    {
+        if (!empty($this->profile->bio)) {
+            $cutoff = 140; // XXX Should this be configurable?
+            $bio    = htmlspecialchars($this->profile->bio);
+
+            if (mb_strlen($bio) > $cutoff) {
+                $bio = mb_substr($bio, 0, $cutoff - 1)
+                    .'<a href="' . $this->profile->profileurl .'">…</a>';
+            }
+
+            $this->out->elementStart('p', 'note');
+            $this->out->raw($bio);
+            $this->out->elementEnd('p');
+        }
+    }
+
+    /**
+     * Only show the tags if we're logged in
+     */
+    function showTags()
+    {
+         if (common_logged_in()) {
+            parent::showTags();
+        }
+
+    }
 }