]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Directory/lib/sortablegrouplist.php
Added more checked type-hints.
[quix0rs-gnu-social.git] / plugins / Directory / lib / sortablegrouplist.php
index 709547ae0f4ee0c9629ed9e02b115d7c4df2e771..756b078416f87ee40e2e03f40ffe6a137f0e7046 100644 (file)
@@ -119,7 +119,7 @@ class SortableGroupList extends SortableSubscriptionList
         $this->out->elementStart('tbody');
     }
 
-    function newListItem($profile, $odd)
+    function newListItem(Profile $profile, $odd)
     {
         return new SortableGroupListItem($profile, $this->owner, $this->action, $odd);
     }
@@ -144,7 +144,7 @@ class SortableGroupListItem extends SortableSubscriptionListItem
             $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');
         }
     }
@@ -167,37 +167,16 @@ class SortableGroupListItem extends SortableSubscriptionListItem
 
     }
 
-    function showAvatar()
+    // TODO: Make sure we can do ->getAvatar() for group profiles too!
+    function showAvatar(Profile $profile, $size=null)
     {
-        $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
-            )
-        );
+        $logo = $profile->getGroup()->stream_logo ?: User_group::defaultLogo($size ?: $this->avatarSize());
 
-        $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->element('img', array('src'    => $logo,
+                                         'class'  => 'avatar u-photo',
+                                         'width'  => AVATAR_STREAM_SIZE,
+                                         'height' => AVATAR_STREAM_SIZE,
+                                         'alt'    => $profile->getBestName()));
     }
 
     function show()
@@ -226,7 +205,13 @@ class SortableGroupListItem extends SortableSubscriptionListItem
     function showProfile()
     {
         $this->startProfile();
-        $this->showAvatar();
+
+        $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();
@@ -236,6 +221,23 @@ class SortableGroupListItem extends SortableSubscriptionListItem
         $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();
@@ -249,8 +251,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