]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Directory/lib/sortablegrouplist.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / plugins / Directory / lib / sortablegrouplist.php
index 4f34a8a897722be45c7f8584ee197157ffe40a5d..fe0e1bcf676d041d8b8e52c4abf571ed1479dec8 100644 (file)
  * @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
@@ -44,16 +40,6 @@ require_once INSTALLDIR . '/lib/subscriptionlist.php';
  */
 class SortableGroupList extends SortableSubscriptionList
 {
-    /** 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'));
@@ -119,67 +105,53 @@ class SortableGroupList extends SortableSubscriptionList
         $this->out->elementStart('tbody');
     }
 
-    function newListItem($profile, $odd)
+    function newListItem($profile)
     {
-        return new SortableGroupListItem($profile, $this->owner, $this->action, $odd);
+        return new SortableGroupListItem($profile, $this->owner, $this->action);
     }
 }
 
 class SortableGroupListItem extends SortableSubscriptionListItem
 {
-    /** Owner of this list */
-    var $owner = null;
-
-    function __construct($profile, $owner, $action, $alt)
-    {
-        parent::__construct($profile, $owner, $action, $alt);
-
-        $this->alt   = $alt; // is this row alternate?
-        $this->owner = $owner;
-    }
-
     function showHomepage()
     {
         if (!empty($this->profile->homepage)) {
             $this->out->text(' ');
             $aAttrs = $this->homepageAttributes();
             $this->out->elementStart('a', $aAttrs);
-            $this->out->raw($this->highlight($this->profile->homeUrl()));
+            $this->out->raw($this->highlight($this->profile->homepage));
             $this->out->elementEnd('a');
         }
     }
 
-    function showAvatar()
+    function showDescription()
     {
-        $logo = ($this->profile->stream_logo) ?
-        $this->profile->stream_logo : User_group::defaultLogo(AVATAR_STREAM_SIZE);
-
-        $this->out->elementStart(
-            'a',
-            array(
-                'href'  => $this->profile->homeUrl(),
-                'class' => 'url entry-title',
-                'rel'   => 'contact group'
-            )
-        );
-        $this->out->element(
-            'img',
-            array(
-                'src'    => $logo,
-                'class'  => 'photo avatar',
-                'width'  => AVATAR_STREAM_SIZE,
-                'height' => AVATAR_STREAM_SIZE,
-                'alt'    => ($this->profile->fullname)
-                    ? $this->profile->fullname : $this->profile->nickname
-            )
-        );
+        if (!empty($this->profile->description)) {
+            $cutoff      = 140; // XXX Should this be configurable?
+            $description = htmlspecialchars($this->profile->description);
+
+            if (mb_strlen($description) > $cutoff) {
+                $description = mb_substr($description, 0, $cutoff - 1)
+                    .'<a href="' . $this->profile->homeUrl() .'">…</a>';
+            }
 
-        $this->out->text(' ');
-        $hasFN = ($this->profile->fullname) ? 'nickname' : 'fn org nickname';
-        $this->out->elementStart('span', $hasFN);
-        $this->out->raw($this->highlight($this->profile->nickname));
-        $this->out->elementEnd('span');
-        $this->out->elementEnd('a');
+            $this->out->elementStart('p', 'note');
+            $this->out->raw($description);
+            $this->out->elementEnd('p');
+        }
+
+    }
+
+    // TODO: Make sure we can do ->getAvatar() for group profiles too!
+    function showAvatar(Profile $profile, $size=null)
+    {
+        $logo = $profile->getGroup()->stream_logo ?: User_group::defaultLogo($size ?: $this->avatarSize());
+
+        $this->out->element('img', array('src'    => $logo,
+                                         'class'  => 'avatar u-photo',
+                                         'width'  => AVATAR_STREAM_SIZE,
+                                         'height' => AVATAR_STREAM_SIZE,
+                                         'alt'    => $profile->getBestName()));
     }
 
     function show()
@@ -205,6 +177,42 @@ class SortableGroupListItem extends SortableSubscriptionListItem
         }
     }
 
+    function showProfile()
+    {
+        $this->startProfile();
+
+        $this->showAvatar($this->profile->getProfile());
+        $this->out->element('a', array('href'  => $this->profile->homeUrl(),
+                                            'class' => 'p-org p-nickname',
+                                            'rel'   => 'contact group'),
+                                 $this->profile->getNickname());
+
+        $this->showFullName();
+        $this->showLocation();
+        $this->showHomepage();
+        $this->showDescription(); // groups have this instead of bios
+        // Relevant portion!
+        $this->showTags();
+        $this->endProfile();
+    }
+
+    function endActions()
+    {
+        // delete button
+        $cur = common_current_user();
+        list($action, $r2args) = $this->out->returnToArgs();
+        $r2args['action'] = $action;
+        if ($cur instanceof User && $cur->hasRight(Right::DELETEGROUP)) {
+            $this->out->elementStart('li', 'entity_delete');
+            $df = new DeleteGroupForm($this->out, $this->profile, $r2args);
+            $df->show();
+            $this->out->elementEnd('li');
+        }
+
+        $this->out->elementEnd('ul');
+        $this->out->elementEnd('td');
+    }
+
     function showActions()
     {
         $this->startActions();
@@ -218,8 +226,8 @@ class SortableGroupListItem extends SortableSubscriptionListItem
     function showJoinButton()
     {
         $user = $this->owner;
-        if ($user) {
 
+        if ($user instanceof User) {
             $this->out->elementStart('li', 'entity_subscribe');
             // XXX: special-case for user looking at own
             // subscriptions page