]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fix some ProfileAction stuff, add function profileActionPreparation
authorMikael Nordfeldth <mmn@hethane.se>
Wed, 22 Apr 2015 19:22:02 +0000 (21:22 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Wed, 22 Apr 2015 19:22:38 +0000 (21:22 +0200)
Split up files with multiple classes to multiple files for autoload, sorry
for baking this into this commit.

12 files changed:
actions/all.php
actions/showstream.php
actions/tagprofile.php
lib/accountprofileblock.php
lib/peopletags.php [deleted file]
lib/peopletagswidget.php [new file with mode: 0644]
lib/profileaction.php
lib/profilelist.php
lib/profilelistitem.php [new file with mode: 0644]
lib/profileminilist.php
lib/profileminilistitem.php [new file with mode: 0644]
lib/selftagswidget.php [new file with mode: 0644]

index fb0b63577afbb17377f4cb4ebd4dc0a163ec4551..9cab91264f00bd2337127dbaba6cdb27f3116db3 100644 (file)
@@ -41,13 +41,9 @@ class AllAction extends ProfileAction
 {
     var $notice;
 
-    protected function prepare(array $args=array())
+    protected function profileActionPreparation()
     {
-        parent::prepare($args);
-
-        $user = common_current_user();
-
-        if (!empty($user) && $user->streamModeOnly()) {
+        if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
             $stream = new InboxNoticeStream($this->target, $this->scoped);
         } else {
             $stream = new ThreadingInboxNoticeStream($this->target, $this->scoped);
@@ -60,8 +56,6 @@ class AllAction extends ProfileAction
             // TRANS: Client error when page not found (404).
             $this->clientError(_('No such page.'), 404);
         }
-
-        return true;
     }
 
     function title()
index 7c38eca14a7637e99248f0d1f1844c338cc1f2d5..b1271dea5465f0ca886ff99acf747dbae935767a 100644 (file)
@@ -57,14 +57,12 @@ class ShowstreamAction extends ProfileAction
 {
     var $notice;
 
-    protected function prepare(array $args=array())
+    protected function profileActionPreparation()
     {
-        parent::prepare($args);
-
         if (empty($this->tag)) {
-            $stream = new ProfileNoticeStream($this->profile, $this->scoped);
+            $stream = new ProfileNoticeStream($this->target, $this->scoped);
         } else {
-            $stream = new TaggedProfileNoticeStream($this->profile, $this->tag, $this->scoped);
+            $stream = new TaggedProfileNoticeStream($this->target, $this->tag, $this->scoped);
         }
 
         $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
@@ -75,7 +73,7 @@ class ShowstreamAction extends ProfileAction
 
     function title()
     {
-        $base = $this->profile->getFancyName();
+        $base = $this->target->getFancyName();
         if (!empty($this->tag)) {
             if ($this->page == 1) {
                 // TRANS: Page title showing tagged notices in one user's timeline.
@@ -106,7 +104,7 @@ class ShowstreamAction extends ProfileAction
 
     function showProfileBlock()
     {
-        $block = new AccountProfileBlock($this, $this->profile);
+        $block = new AccountProfileBlock($this, $this->target);
         $block->show();
     }
 
@@ -120,12 +118,12 @@ class ShowstreamAction extends ProfileAction
         if (!empty($this->tag)) {
             return array(new Feed(Feed::RSS1,
                                   common_local_url('userrss',
-                                                   array('nickname' => $this->target->nickname,
+                                                   array('nickname' => $this->target->getNickname(),
                                                          'tag' => $this->tag)),
                                   // TRANS: Title for link to notice feed.
                                   // TRANS: %1$s is a user nickname, %2$s is a hashtag.
                                   sprintf(_('Notice feed for %1$s tagged %2$s (RSS 1.0)'),
-                                          $this->target->nickname, $this->tag)));
+                                          $this->target->getNickname(), $this->tag)));
         }
 
         return array(new Feed(Feed::JSON,
@@ -136,14 +134,14 @@ class ShowstreamAction extends ProfileAction
                               // TRANS: Title for link to notice feed.
                               // TRANS: %s is a user nickname.
                               sprintf(_('Notice feed for %s (Activity Streams JSON)'),
-                                      $this->target->nickname)),
+                                      $this->target->getNickname())),
                      new Feed(Feed::RSS1,
                               common_local_url('userrss',
-                                               array('nickname' => $this->target->nickname)),
+                                               array('nickname' => $this->target->getNickname())),
                               // TRANS: Title for link to notice feed.
                               // TRANS: %s is a user nickname.
                               sprintf(_('Notice feed for %s (RSS 1.0)'),
-                                      $this->target->nickname)),
+                                      $this->target->getNickname())),
                      new Feed(Feed::RSS2,
                               common_local_url('ApiTimelineUser',
                                                array(
@@ -152,7 +150,7 @@ class ShowstreamAction extends ProfileAction
                               // TRANS: Title for link to notice feed.
                               // TRANS: %s is a user nickname.
                               sprintf(_('Notice feed for %s (RSS 2.0)'),
-                                      $this->target->nickname)),
+                                      $this->target->getNickname())),
                      new Feed(Feed::ATOM,
                               common_local_url('ApiTimelineUser',
                                                array(
@@ -161,24 +159,24 @@ class ShowstreamAction extends ProfileAction
                               // TRANS: Title for link to notice feed.
                               // TRANS: %s is a user nickname.
                               sprintf(_('Notice feed for %s (Atom)'),
-                                      $this->target->nickname)),
+                                      $this->target->getNickname())),
                      new Feed(Feed::FOAF,
                               common_local_url('foaf', array('nickname' =>
-                                                             $this->target->nickname)),
+                                                             $this->target->getNickname())),
                               // TRANS: Title for link to notice feed. FOAF stands for Friend of a Friend.
                               // TRANS: More information at http://www.foaf-project.org. %s is a user nickname.
-                              sprintf(_('FOAF for %s'), $this->target->nickname)));
+                              sprintf(_('FOAF for %s'), $this->target->getNickname())));
     }
 
     function extraHead()
     {
-        if ($this->profile->bio) {
+        if ($this->target->bio) {
             $this->element('meta', array('name' => 'description',
-                                         'content' => $this->profile->bio));
+                                         'content' => $this->target->getDescription()));
         }
 
-        if ($this->user->emailmicroid && $this->user->email && $this->profile->profileurl) {
-            $id = new Microid('mailto:'.$this->user->email,
+        if ($this->target->isLocal() && $this->target->getUser()->emailmicroid && $this->target->getUser()->email && $this->target->getUrl()) {
+            $id = new Microid('mailto:'.$this->target->getUser()->email,
                               $this->selfUrl());
             $this->element('meta', array('name' => 'microid',
                                          'content' => $id->toString()));
@@ -188,10 +186,10 @@ class ShowstreamAction extends ProfileAction
 
         $this->element('link', array('rel' => 'microsummary',
                                      'href' => common_local_url('microsummary',
-                                                                array('nickname' => $this->profile->nickname))));
+                                                                array('nickname' => $this->target->getNickname()))));
 
         $rsd = common_local_url('rsd',
-                                array('nickname' => $this->profile->nickname));
+                                array('nickname' => $this->target->getNickname()));
 
         // RSD, http://tales.phrasewise.com/rfc/rsd
         $this->element('link', array('rel' => 'EditURI',
@@ -200,7 +198,7 @@ class ShowstreamAction extends ProfileAction
 
         if ($this->page != 1) {
             $this->element('link', array('rel' => 'canonical',
-                                         'href' => $this->profile->profileurl));
+                                         'href' => $this->target->getUrl()));
         }
     }
 
@@ -284,10 +282,9 @@ class ShowstreamAction extends ProfileAction
     function noticeFormOptions()
     {
         $options = parent::noticeFormOptions();
-        $cur = common_current_user();
 
-        if (empty($cur) || $cur->id != $this->profile->id) {
-            $options['to_profile'] =  $this->profile;
+        if (!$this->scoped instanceof Profile || $this->scoped->id != $this->target->id) {
+            $options['to_profile'] =  $this->target;
         }
 
         return $options;
@@ -329,20 +326,23 @@ class ProfileNoticeListItem extends DoFollowListItem
 
             // FIXME: this code is almost identical to default; need to refactor
 
-            $attrs = array('href' => $this->profile->profileurl,
-                           'class' => 'url');
+            $attrs = array();
+            if (!empty($this->target->fullname)) {
+                $attrs['title'] = $this->target->getFullname();
+            }
 
-            if (!empty($this->profile->fullname)) {
-                $attrs['title'] = $this->profile->getFancyName();
+            try {
+                $attrs = array('href' => $this->target->getUrl(),
+                               'class' => 'url');
+                $text_tag = 'a';
+            } catch (InvalidUrlException $e) {
+                $text_tag = 'abbr';
             }
 
             $this->out->elementStart('span', 'repeat');
-
-            $text_link = XMLStringer::estring('a', $attrs, $this->profile->nickname);
-
+            $text_link = XMLStringer::estring($text_tag, $attrs, $this->target->getNickname());
             // TRANS: Link to the author of a repeated notice. %s is a linked nickname.
             $this->out->raw(sprintf(_('Repeat of %s'), $text_link));
-
             $this->out->elementEnd('span');
         }
     }
index 79a401c6a93dccfb7d584ddb088d4cb33f1fdd7d..47a66d0be47b718832f99142e3f007bc27f70708 100644 (file)
@@ -19,8 +19,6 @@
 
 if (!defined('GNUSOCIAL')) { exit(1); }
 
-require_once INSTALLDIR . '/lib/peopletags.php';
-
 class TagprofileAction extends FormAction
 {
     var $error = null;
index fe11a0fc1571c3658fa38253c4073a18aa543127..875acbb59c30ea500b38ff27b85fe660f70dd21a 100644 (file)
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET')) {
-    // This check helps protect against security problems;
-    // your code file can't be executed directly from the web.
-    exit(1);
-}
-
-require_once INSTALLDIR.'/lib/peopletags.php';
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Profile block to show for an account
diff --git a/lib/peopletags.php b/lib/peopletags.php
deleted file mode 100644 (file)
index 40f07c0..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-<?php
-/**
- * StatusNet, the distributed open-source microblogging tool
- *
- * Tags for a profile
- *
- * 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  Action
- * @package   StatusNet
- * @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);
-}
-
-require_once INSTALLDIR.'/lib/widget.php';
-
-/*
- * Show a bunch of peopletags
- * provide ajax editing if the current user owns the tags
- *
- * @category Action
- * @pacage   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
- */
-class PeopletagsWidget extends Widget
-{
-    /*
-     * the query, current peopletag.
-     * or an array of strings (tags)
-     */
-
-    var $tag=null;
-
-    var $user=null;
-    var $tagger=null;
-    var $tagged=null;
-
-    function __construct($out, $tagger, $tagged)
-    {
-        parent::__construct($out);
-
-        $this->user   = common_current_user();
-        $this->tag = Profile_tag::getTags($tagger->id, $tagged->id, $this->user);
-        $this->tagger = $tagger;
-        $this->tagged = $tagged;
-    }
-
-    function show()
-    {
-        if (Event::handle('StartShowPeopletags', array($this, $this->tagger, $this->tagged))) {
-            if ($this->tag->N > 0) {
-                $this->showTags();
-            }
-            else {
-                $this->showEmptyList();
-            }
-            Event::handle('EndShowPeopletags', array($this, $this->tagger, $this->tagged));
-        }
-    }
-
-    function url()
-    {
-        return $this->tag->homeUrl();
-    }
-
-    function label()
-    {
-        // TRANS: Label in lists widget.
-        return _m('LABEL','Your lists');
-    }
-
-    function showTags()
-    {
-        $this->out->elementStart('dl', 'entity_tags user_profile_tags');
-        $this->out->element('dt', null, $this->label());
-        $this->out->elementStart('dd');
-
-        $class = 'tags xoxo';
-        if ($this->isEditable()) {
-            $class .= ' editable';
-        }
-
-        $tags = array();
-        $this->out->elementStart('ul', $class);
-        while ($this->tag->fetch()) {
-            $mode = $this->tag->private ? 'private' : 'public';
-            $tags[] = $this->tag->tag;
-
-            $this->out->elementStart('li', 'hashptag mode-' . $mode);
-            // Avoid space by using raw output.
-            $pt = '<span class="mark_hash">#</span><a rel="tag" href="' .
-              $this->url($this->tag->tag) .
-              '">' . $this->tag->tag . '</a>';
-            $this->out->raw($pt);
-            $this->out->elementEnd('li');
-        }
-        $this->out->elementEnd('ul');
-
-        if ($this->isEditable()) {
-            $this->showEditTagForm($tags);
-        }
-
-        $this->out->elementEnd('dd');
-        $this->out->elementEnd('dl');
-    }
-
-    function showEditTagForm($tags=null)
-    {
-        $this->out->elementStart('div', 'form_tag_user_wrap');
-        $this->out->elementStart('form', array('method' => 'post',
-                                           'class' => 'form_tag_user',
-                                           'name' => 'tagprofile',
-                                           'action' => common_local_url('tagprofile', array('id' => $this->tagged->id))));
-
-        $this->out->elementStart('fieldset');
-        // TRANS: Fieldset legend in lists widget.
-        $this->out->element('legend', null, _m('LEGEND','Edit lists'));
-        $this->out->hidden('token', common_session_token());
-        $this->out->hidden('id', $this->tagged->id);
-
-        if (!$tags) {
-            $tags = array();
-        }
-
-        $this->out->input('tags', $this->label(),
-                     ($this->out->arg('tags')) ? $this->out->arg('tags') : implode(' ', $tags));
-        // TRANS: Button text to save tags for a profile.
-        $this->out->submit('save', _m('BUTTON','Save'));
-
-        $this->out->elementEnd('fieldset');
-        $this->out->elementEnd('form');
-        $this->out->elementEnd('div');
-    }
-
-    function showEmptyList()
-    {
-        $this->out->elementStart('dl', 'entity_tags user_profile_tags');
-        $this->out->element('dt', null, $this->label());
-        $this->out->elementStart('dd');
-
-        $class = 'tags';
-        if ($this->isEditable()) {
-            $class .= ' editable';
-        }
-
-        $this->out->elementStart('ul', $class);
-        // TRANS: Empty list message for tags.
-        $this->out->element('li', null, _('(None)'));
-        $this->out->elementEnd('ul');
-
-        if ($this->isEditable()) {
-            $this->showEditTagForm();
-        }
-        $this->out->elementEnd('dd');
-        $this->out->elementEnd('dl');
-    }
-
-    function isEditable()
-    {
-        return !empty($this->user) && $this->tagger->id == $this->user->id;
-    }
-}
-
-class SelftagsWidget extends PeopletagsWidget
-{
-    function url($tag)
-    {
-        // link to self tag page
-        return common_local_url('selftag', array('tag' => $tag));
-    }
-
-    function label()
-    {
-        // TRANS: Label in self tags widget.
-        return _m('LABEL','Tags');
-    }
-}
diff --git a/lib/peopletagswidget.php b/lib/peopletagswidget.php
new file mode 100644 (file)
index 0000000..1da153c
--- /dev/null
@@ -0,0 +1,176 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Tags for a profile
+ *
+ * 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  Action
+ * @package   StatusNet
+ * @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('GNUSOCIAL')) { exit(1); }
+
+/*
+ * Show a bunch of peopletags
+ * provide ajax editing if the current user owns the tags
+ *
+ * @category Action
+ * @pacage   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
+ */
+class PeopletagsWidget extends Widget
+{
+    /*
+     * the query, current peopletag.
+     * or an array of strings (tags)
+     */
+
+    var $tag=null;
+
+    var $user=null;
+    var $tagger=null;
+    var $tagged=null;
+
+    function __construct($out, $tagger, $tagged)
+    {
+        parent::__construct($out);
+
+        $this->user   = common_current_user();
+        $this->tag = Profile_tag::getTags($tagger->id, $tagged->id, $this->user);
+        $this->tagger = $tagger;
+        $this->tagged = $tagged;
+    }
+
+    function show()
+    {
+        if (Event::handle('StartShowPeopletags', array($this, $this->tagger, $this->tagged))) {
+            if ($this->tag->N > 0) {
+                $this->showTags();
+            }
+            else {
+                $this->showEmptyList();
+            }
+            Event::handle('EndShowPeopletags', array($this, $this->tagger, $this->tagged));
+        }
+    }
+
+    function url()
+    {
+        return $this->tag->homeUrl();
+    }
+
+    function label()
+    {
+        // TRANS: Label in lists widget.
+        return _m('LABEL','Your lists');
+    }
+
+    function showTags()
+    {
+        $this->out->elementStart('dl', 'entity_tags user_profile_tags');
+        $this->out->element('dt', null, $this->label());
+        $this->out->elementStart('dd');
+
+        $class = 'tags xoxo';
+        if ($this->isEditable()) {
+            $class .= ' editable';
+        }
+
+        $tags = array();
+        $this->out->elementStart('ul', $class);
+        while ($this->tag->fetch()) {
+            $mode = $this->tag->private ? 'private' : 'public';
+            $tags[] = $this->tag->tag;
+
+            $this->out->elementStart('li', 'hashptag mode-' . $mode);
+            // Avoid space by using raw output.
+            $pt = '<span class="mark_hash">#</span><a rel="tag" href="' .
+              $this->url($this->tag->tag) .
+              '">' . $this->tag->tag . '</a>';
+            $this->out->raw($pt);
+            $this->out->elementEnd('li');
+        }
+        $this->out->elementEnd('ul');
+
+        if ($this->isEditable()) {
+            $this->showEditTagForm($tags);
+        }
+
+        $this->out->elementEnd('dd');
+        $this->out->elementEnd('dl');
+    }
+
+    function showEditTagForm($tags=null)
+    {
+        $this->out->elementStart('div', 'form_tag_user_wrap');
+        $this->out->elementStart('form', array('method' => 'post',
+                                           'class' => 'form_tag_user',
+                                           'name' => 'tagprofile',
+                                           'action' => common_local_url('tagprofile', array('id' => $this->tagged->id))));
+
+        $this->out->elementStart('fieldset');
+        // TRANS: Fieldset legend in lists widget.
+        $this->out->element('legend', null, _m('LEGEND','Edit lists'));
+        $this->out->hidden('token', common_session_token());
+        $this->out->hidden('id', $this->tagged->id);
+
+        if (!$tags) {
+            $tags = array();
+        }
+
+        $this->out->input('tags', $this->label(),
+                     ($this->out->arg('tags')) ? $this->out->arg('tags') : implode(' ', $tags));
+        // TRANS: Button text to save tags for a profile.
+        $this->out->submit('save', _m('BUTTON','Save'));
+
+        $this->out->elementEnd('fieldset');
+        $this->out->elementEnd('form');
+        $this->out->elementEnd('div');
+    }
+
+    function showEmptyList()
+    {
+        $this->out->elementStart('dl', 'entity_tags user_profile_tags');
+        $this->out->element('dt', null, $this->label());
+        $this->out->elementStart('dd');
+
+        $class = 'tags';
+        if ($this->isEditable()) {
+            $class .= ' editable';
+        }
+
+        $this->out->elementStart('ul', $class);
+        // TRANS: Empty list message for tags.
+        $this->out->element('li', null, _('(None)'));
+        $this->out->elementEnd('ul');
+
+        if ($this->isEditable()) {
+            $this->showEditTagForm();
+        }
+        $this->out->elementEnd('dd');
+        $this->out->elementEnd('dl');
+    }
+
+    function isEditable()
+    {
+        return !empty($this->user) && $this->tagger->id == $this->user->id;
+    }
+}
index 83b3170bed170c48e2d907908565c978346c9ba5..592364009781a73ecc3c5e83cd3e1fcfa7e3c1a6 100644 (file)
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
-    exit(1);
-}
-
-require_once INSTALLDIR.'/lib/profileminilist.php';
-require_once INSTALLDIR.'/lib/groupminilist.php';
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Profile action common superclass
@@ -46,17 +41,15 @@ require_once INSTALLDIR.'/lib/groupminilist.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 ProfileAction extends ManagedAction
+abstract class ProfileAction extends ManagedAction
 {
     var $page    = null;
     var $tag     = null;
 
     protected $target  = null;    // Profile that we're showing
 
-    protected function prepare(array $args=array())
+    protected function doPreparation()
     {
-        parent::prepare($args);
-
         try {
             $nickname_arg = $this->arg('nickname');
             $nickname     = common_canonical_nickname($nickname_arg);
@@ -106,7 +99,13 @@ class ProfileAction extends ManagedAction
         $this->tag = $this->trimmed('tag');
         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
         common_set_returnto($this->selfUrl());
-        return true;
+
+        return $this->profileActionPreparation();
+    }
+
+    protected function profileActionPreparation()
+    {
+        // No-op by default.
     }
 
     function isReadOnly($args)
index 767e12bc25a7dbc2360bd65d1bddd270fd919989..177560cdf568844ef7f2a070d463c343684a4f7b 100644 (file)
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
-    exit(1);
-}
-
-require_once INSTALLDIR.'/lib/peopletags.php';
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Widget to show a list of profiles
@@ -107,215 +103,3 @@ class ProfileList extends Widget
         return PROFILES_PER_PAGE;
     }
 }
-
-class ProfileListItem extends Widget
-{
-    /** Current profile. */
-    var $profile = null;
-    /** Action object using us. */
-    var $action = null;
-
-    function __construct($profile, $action)
-    {
-        parent::__construct($action);
-
-        $this->profile = $profile;
-        $this->action  = $action;
-    }
-
-    function show()
-    {
-        if (Event::handle('StartProfileListItem', array($this))) {
-            $this->startItem();
-            if (Event::handle('StartProfileListItemProfile', array($this))) {
-                $this->showProfile();
-                Event::handle('EndProfileListItemProfile', array($this));
-            }
-            if (Event::handle('StartProfileListItemActions', array($this))) {
-                $this->showActions();
-                Event::handle('EndProfileListItemActions', array($this));
-            }
-            $this->endItem();
-            Event::handle('EndProfileListItem', array($this));
-        }
-    }
-
-    function startItem()
-    {
-        $this->out->elementStart('li', array('class' => 'profile',
-                                             'id' => 'profile-' . $this->profile->id));
-    }
-
-    function showProfile()
-    {
-        $this->startProfile();
-        if (Event::handle('StartProfileListItemProfileElements', array($this))) {
-            if (Event::handle('StartProfileListItemAvatar', array($this))) {
-                $aAttrs = $this->linkAttributes();
-                $this->out->elementStart('a', $aAttrs);
-                $this->showAvatar($this->profile);
-                $this->out->elementEnd('a');
-                Event::handle('EndProfileListItemAvatar', array($this));
-            }
-            if (Event::handle('StartProfileListItemNickname', array($this))) {
-                $this->showNickname();
-                Event::handle('EndProfileListItemNickname', array($this));
-            }
-            if (Event::handle('StartProfileListItemFullName', array($this))) {
-                $this->showFullName();
-                Event::handle('EndProfileListItemFullName', array($this));
-            }
-            if (Event::handle('StartProfileListItemLocation', array($this))) {
-                $this->showLocation();
-                Event::handle('EndProfileListItemLocation', array($this));
-            }
-            if (Event::handle('StartProfileListItemHomepage', array($this))) {
-                $this->showHomepage();
-                Event::handle('EndProfileListItemHomepage', array($this));
-            }
-            if (Event::handle('StartProfileListItemBio', array($this))) {
-                $this->showBio();
-                Event::handle('EndProfileListItemBio', array($this));
-            }
-            if (Event::handle('StartProfileListItemTags', array($this))) {
-                $this->showTags();
-                Event::handle('EndProfileListItemTags', array($this));
-            }
-            Event::handle('EndProfileListItemProfileElements', array($this));
-        }
-        $this->endProfile();
-    }
-
-    function startProfile()
-    {
-        $this->out->elementStart('div', 'entity_profile h-card');
-    }
-
-    function showNickname()
-    {
-        $this->out->element('a', array('href'=>$this->profile->getUrl(),
-                                       'class'=>'p-nickname'),
-                            $this->profile->getNickname());
-    }
-
-    function showFullName()
-    {
-        if (!empty($this->profile->fullname)) {
-            $this->out->element('span', 'p-name', $this->profile->fullname);
-        }
-    }
-
-    function showLocation()
-    {
-        if (!empty($this->profile->location)) {
-            $this->out->element('span', 'label p-locality', $this->profile->location);
-        }
-    }
-
-    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->homepage));
-            $this->out->elementEnd('a');
-        }
-    }
-
-    function showBio()
-    {
-        if (!empty($this->profile->bio)) {
-            $this->out->elementStart('p', 'note');
-            $this->out->raw($this->highlight($this->profile->bio));
-            $this->out->elementEnd('p');
-        }
-    }
-
-    function showTags()
-    {
-        $user = common_current_user();
-        if (!empty($user)) {
-            if ($user->id == $this->profile->id) {
-                $tags = new SelftagsWidget($this->out, $user, $this->profile);
-                $tags->show();
-            } else if ($user->getProfile()->canTag($this->profile)) {
-                $tags = new PeopletagsWidget($this->out, $user, $this->profile);
-                $tags->show();
-            }
-        }
-    }
-
-    function endProfile()
-    {
-        $this->out->elementEnd('div');
-    }
-
-    function showActions()
-    {
-        $this->startActions();
-        if (Event::handle('StartProfileListItemActionElements', array($this))) {
-            $this->showSubscribeButton();
-            Event::handle('EndProfileListItemActionElements', array($this));
-        }
-        $this->endActions();
-    }
-
-    function startActions()
-    {
-        $this->out->elementStart('div', 'entity_actions');
-        $this->out->elementStart('ul');
-    }
-
-    function showSubscribeButton()
-    {
-        // Is this a logged-in user, looking at someone else's
-        // profile?
-
-        $user = common_current_user();
-
-        if (!empty($user) && $this->profile->id != $user->id) {
-            $this->out->elementStart('li', 'entity_subscribe');
-            if ($user->isSubscribed($this->profile)) {
-                $usf = new UnsubscribeForm($this->out, $this->profile);
-                $usf->show();
-            } else {
-                if (Event::handle('StartShowProfileListSubscribeButton', array($this))) {
-                    $sf = new SubscribeForm($this->out, $this->profile);
-                    $sf->show();
-                    Event::handle('EndShowProfileListSubscribeButton', array($this));
-                }
-            }
-            $this->out->elementEnd('li');
-        }
-    }
-
-    function endActions()
-    {
-        $this->out->elementEnd('ul');
-        $this->out->elementEnd('div');
-    }
-
-    function endItem()
-    {
-        $this->out->elementEnd('li');
-    }
-
-    function highlight($text)
-    {
-        return htmlspecialchars($text);
-    }
-
-    function linkAttributes()
-    {
-        return array('href' => $this->profile->profileurl,
-                     'class' => 'u-url',
-                     'rel' => 'contact');
-    }
-
-    function homepageAttributes()
-    {
-        return array('href' => $this->profile->homepage,
-                     'class' => 'u-url');
-    }
-}
diff --git a/lib/profilelistitem.php b/lib/profilelistitem.php
new file mode 100644 (file)
index 0000000..e0b94ac
--- /dev/null
@@ -0,0 +1,242 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Widget to show a list of profiles
+ *
+ * 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  Public
+ * @package   StatusNet
+ * @author    Evan Prodromou <evan@status.net>
+ * @copyright 2008-2009 StatusNet, Inc.
+ * @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('GNUSOCIAL')) { exit(1); }
+
+class ProfileListItem extends Widget
+{
+    /** Current profile. */
+    var $profile = null;
+    /** Action object using us. */
+    var $action = null;
+
+    function __construct($profile, $action)
+    {
+        parent::__construct($action);
+
+        $this->profile = $profile;
+        $this->action  = $action;
+    }
+
+    function show()
+    {
+        if (Event::handle('StartProfileListItem', array($this))) {
+            $this->startItem();
+            if (Event::handle('StartProfileListItemProfile', array($this))) {
+                $this->showProfile();
+                Event::handle('EndProfileListItemProfile', array($this));
+            }
+            if (Event::handle('StartProfileListItemActions', array($this))) {
+                $this->showActions();
+                Event::handle('EndProfileListItemActions', array($this));
+            }
+            $this->endItem();
+            Event::handle('EndProfileListItem', array($this));
+        }
+    }
+
+    function startItem()
+    {
+        $this->out->elementStart('li', array('class' => 'profile',
+                                             'id' => 'profile-' . $this->profile->id));
+    }
+
+    function showProfile()
+    {
+        $this->startProfile();
+        if (Event::handle('StartProfileListItemProfileElements', array($this))) {
+            if (Event::handle('StartProfileListItemAvatar', array($this))) {
+                $aAttrs = $this->linkAttributes();
+                $this->out->elementStart('a', $aAttrs);
+                $this->showAvatar($this->profile);
+                $this->out->elementEnd('a');
+                Event::handle('EndProfileListItemAvatar', array($this));
+            }
+            if (Event::handle('StartProfileListItemNickname', array($this))) {
+                $this->showNickname();
+                Event::handle('EndProfileListItemNickname', array($this));
+            }
+            if (Event::handle('StartProfileListItemFullName', array($this))) {
+                $this->showFullName();
+                Event::handle('EndProfileListItemFullName', array($this));
+            }
+            if (Event::handle('StartProfileListItemLocation', array($this))) {
+                $this->showLocation();
+                Event::handle('EndProfileListItemLocation', array($this));
+            }
+            if (Event::handle('StartProfileListItemHomepage', array($this))) {
+                $this->showHomepage();
+                Event::handle('EndProfileListItemHomepage', array($this));
+            }
+            if (Event::handle('StartProfileListItemBio', array($this))) {
+                $this->showBio();
+                Event::handle('EndProfileListItemBio', array($this));
+            }
+            if (Event::handle('StartProfileListItemTags', array($this))) {
+                $this->showTags();
+                Event::handle('EndProfileListItemTags', array($this));
+            }
+            Event::handle('EndProfileListItemProfileElements', array($this));
+        }
+        $this->endProfile();
+    }
+
+    function startProfile()
+    {
+        $this->out->elementStart('div', 'entity_profile h-card');
+    }
+
+    function showNickname()
+    {
+        $this->out->element('a', array('href'=>$this->profile->getUrl(),
+                                       'class'=>'p-nickname'),
+                            $this->profile->getNickname());
+    }
+
+    function showFullName()
+    {
+        if (!empty($this->profile->fullname)) {
+            $this->out->element('span', 'p-name', $this->profile->fullname);
+        }
+    }
+
+    function showLocation()
+    {
+        if (!empty($this->profile->location)) {
+            $this->out->element('span', 'label p-locality', $this->profile->location);
+        }
+    }
+
+    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->homepage));
+            $this->out->elementEnd('a');
+        }
+    }
+
+    function showBio()
+    {
+        if (!empty($this->profile->bio)) {
+            $this->out->elementStart('p', 'note');
+            $this->out->raw($this->highlight($this->profile->bio));
+            $this->out->elementEnd('p');
+        }
+    }
+
+    function showTags()
+    {
+        $user = common_current_user();
+        if (!empty($user)) {
+            if ($user->id == $this->profile->id) {
+                $tags = new SelftagsWidget($this->out, $user, $this->profile);
+                $tags->show();
+            } else if ($user->getProfile()->canTag($this->profile)) {
+                $tags = new PeopletagsWidget($this->out, $user, $this->profile);
+                $tags->show();
+            }
+        }
+    }
+
+    function endProfile()
+    {
+        $this->out->elementEnd('div');
+    }
+
+    function showActions()
+    {
+        $this->startActions();
+        if (Event::handle('StartProfileListItemActionElements', array($this))) {
+            $this->showSubscribeButton();
+            Event::handle('EndProfileListItemActionElements', array($this));
+        }
+        $this->endActions();
+    }
+
+    function startActions()
+    {
+        $this->out->elementStart('div', 'entity_actions');
+        $this->out->elementStart('ul');
+    }
+
+    function showSubscribeButton()
+    {
+        // Is this a logged-in user, looking at someone else's
+        // profile?
+
+        $user = common_current_user();
+
+        if (!empty($user) && $this->profile->id != $user->id) {
+            $this->out->elementStart('li', 'entity_subscribe');
+            if ($user->isSubscribed($this->profile)) {
+                $usf = new UnsubscribeForm($this->out, $this->profile);
+                $usf->show();
+            } else {
+                if (Event::handle('StartShowProfileListSubscribeButton', array($this))) {
+                    $sf = new SubscribeForm($this->out, $this->profile);
+                    $sf->show();
+                    Event::handle('EndShowProfileListSubscribeButton', array($this));
+                }
+            }
+            $this->out->elementEnd('li');
+        }
+    }
+
+    function endActions()
+    {
+        $this->out->elementEnd('ul');
+        $this->out->elementEnd('div');
+    }
+
+    function endItem()
+    {
+        $this->out->elementEnd('li');
+    }
+
+    function highlight($text)
+    {
+        return htmlspecialchars($text);
+    }
+
+    function linkAttributes()
+    {
+        return array('href' => $this->profile->profileurl,
+                     'class' => 'u-url',
+                     'rel' => 'contact');
+    }
+
+    function homepageAttributes()
+    {
+        return array('href' => $this->profile->homepage,
+                     'class' => 'u-url');
+    }
+}
index 33624a3c7059440298a23e3e829b13c5b59b5f5d..4f4748722055aca1ebb555f60e601f7d0b23c634 100644 (file)
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
-    exit(1);
-}
-
-require_once INSTALLDIR.'/lib/profilelist.php';
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 define('PROFILES_PER_MINILIST', 8);
 
@@ -69,39 +65,3 @@ class ProfileMiniList extends ProfileList
         return AVATAR_MINI_SIZE;
     }
 }
-
-class ProfileMiniListItem extends ProfileListItem
-{
-    function show()
-    {
-        $this->out->elementStart('li', 'h-card');
-        if (Event::handle('StartProfileListItemProfileElements', array($this))) {
-            if (Event::handle('StartProfileListItemAvatar', array($this))) {
-                $aAttrs = $this->linkAttributes();
-                $this->out->elementStart('a', $aAttrs);
-                $avatarUrl = $this->profile->avatarUrl(AVATAR_MINI_SIZE);
-                $this->out->element('img', array('src' => $avatarUrl,
-                                                 'width' => AVATAR_MINI_SIZE,
-                                                 'height' => AVATAR_MINI_SIZE,
-                                                 'class' => 'avatar u-photo',
-                                                 'alt' =>  $this->profile->getBestName()));
-                $this->out->elementEnd('a');
-                Event::handle('EndProfileListItemAvatar', array($this));
-            }
-            $this->out->elementEnd('li');
-        }
-    }
-
-    // default; overridden for nofollow lists
-
-    function linkAttributes()
-    {
-        $aAttrs = parent::linkAttributes();
-
-        $aAttrs['title'] = $this->profile->getBestName();
-        $aAttrs['rel']   = 'contact member'; // @todo: member? always?
-        $aAttrs['class'] = 'u-url p-name';
-
-        return $aAttrs;
-    }
-}
diff --git a/lib/profileminilistitem.php b/lib/profileminilistitem.php
new file mode 100644 (file)
index 0000000..c012126
--- /dev/null
@@ -0,0 +1,76 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Widget to show a list of profiles
+ *
+ * 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  Public
+ * @package   StatusNet
+ * @author    Evan Prodromou <evan@status.net>
+ * @copyright 2008-2009 StatusNet, Inc.
+ * @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('GNUSOCIAL')) { exit(1); }
+
+/**
+ * Widget to show a list of profiles, good for sidebar
+ *
+ * @category Public
+ * @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://status.net/
+ */
+
+class ProfileMiniListItem extends ProfileListItem
+{
+    function show()
+    {
+        $this->out->elementStart('li', 'h-card');
+        if (Event::handle('StartProfileListItemProfileElements', array($this))) {
+            if (Event::handle('StartProfileListItemAvatar', array($this))) {
+                $aAttrs = $this->linkAttributes();
+                $this->out->elementStart('a', $aAttrs);
+                $avatarUrl = $this->profile->avatarUrl(AVATAR_MINI_SIZE);
+                $this->out->element('img', array('src' => $avatarUrl,
+                                                 'width' => AVATAR_MINI_SIZE,
+                                                 'height' => AVATAR_MINI_SIZE,
+                                                 'class' => 'avatar u-photo',
+                                                 'alt' =>  $this->profile->getBestName()));
+                $this->out->elementEnd('a');
+                Event::handle('EndProfileListItemAvatar', array($this));
+            }
+            $this->out->elementEnd('li');
+        }
+    }
+
+    // default; overridden for nofollow lists
+
+    function linkAttributes()
+    {
+        $aAttrs = parent::linkAttributes();
+
+        $aAttrs['title'] = $this->profile->getBestName();
+        $aAttrs['rel']   = 'contact member'; // @todo: member? always?
+        $aAttrs['class'] = 'u-url p-name';
+
+        return $aAttrs;
+    }
+}
diff --git a/lib/selftagswidget.php b/lib/selftagswidget.php
new file mode 100644 (file)
index 0000000..e253076
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Tags for a profile
+ *
+ * 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  Action
+ * @package   StatusNet
+ * @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('GNUSOCIAL')) { exit(1); }
+
+class SelftagsWidget extends PeopletagsWidget
+{
+    function url($tag)
+    {
+        // link to self tag page
+        return common_local_url('selftag', array('tag' => $tag));
+    }
+
+    function label()
+    {
+        // TRANS: Label in self tags widget.
+        return _m('LABEL','Tags');
+    }
+}