]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/showstream.php
Merge branch 'backupaccount-xml' into 'nightly'
[quix0rs-gnu-social.git] / actions / showstream.php
index 8e8b055b4b4749b3a51ad7248963386bb4aecccc..79a3706d77fbe688f8044be64cf706fe91d24f70 100644 (file)
@@ -45,51 +45,9 @@ if (!defined('GNUSOCIAL')) { exit(1); }
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://status.net/
  */
-class ShowstreamAction extends ProfileAction
+class ShowstreamAction extends NoticestreamAction
 {
-    var $notice;
-
-    protected function doPreparation()
-    {
-        // showstream requires a nickname
-        $nickname_arg = $this->arg('nickname');
-        $nickname     = common_canonical_nickname($nickname_arg);
-
-        // Permanent redirect on non-canonical nickname
-
-        if ($nickname_arg != $nickname) {
-            $args = array('nickname' => $nickname);
-            if ($this->arg('page') && $this->arg('page') != 1) {
-                $args['page'] = $this->arg['page'];
-            }
-            common_redirect(common_local_url($this->getActionName(), $args), 301);
-        }
-        $this->user = User::getKV('nickname', $nickname);
-
-        if (!$this->user) {
-            $group = Local_group::getKV('nickname', $nickname);
-            if ($group instanceof Local_group) {
-                common_redirect($group->getProfile()->getUrl());
-            }
-            // TRANS: Client error displayed when calling a profile action without specifying a user.
-            $this->clientError(_('No such user.'), 404);
-        }
-
-        $this->target = $this->user->getProfile();
-    }
-
-    protected function profileActionPreparation()
-    {
-        $stream = $this->getStream();
-        $this->notice = $stream->getNotices(($this->page-1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
-
-        if ($this->page > 1 && $this->notice->N == 0) {
-            // TRANS: Client error when page not found (404).
-            $this->clientError(_('No such page.'), 404);
-        }
-    }
-
-    protected function getStream()
+    public function getStream()
     {
         if (empty($this->tag)) {
             $stream = new ProfileNoticeStream($this->target, $this->scoped);
@@ -100,7 +58,6 @@ class ShowstreamAction extends ProfileAction
         return $stream;
     }
 
-
     function title()
     {
         $base = $this->target->getFancyName();
@@ -116,7 +73,7 @@ class ShowstreamAction extends ProfileAction
             }
         } else {
             if ($this->page == 1) {
-                return $base;
+                return sprintf(_('Notices by %s'), $base);
             } else {
                 // TRANS: Extended page title showing tagged notices in one user's timeline.
                 // TRANS: %1$s is the username, %2$d is the page number.
@@ -127,7 +84,7 @@ class ShowstreamAction extends ProfileAction
         }
     }
 
-    function showContent()
+    protected function showContent()
     {
         $this->showNotices();
     }
@@ -156,6 +113,18 @@ class ShowstreamAction extends ProfileAction
                                           $this->target->getNickname(), $this->tag)));
         }
 
+        if (!$this->target->isLocal()) {
+            // remote profiles at least have Atom, but we can't guarantee anything else
+            return array(
+                     new Feed(Feed::ATOM,
+                              $this->target->getAtomFeed(),
+                              // TRANS: Title for link to notice feed.
+                              // TRANS: %s is a user nickname.
+                              sprintf(_('Notice feed for %s (Atom)'),
+                                      $this->target->getNickname()))
+                     );
+        }
+
         return array(new Feed(Feed::JSON,
                               common_local_url('ApiTimelineUser',
                                                array(
@@ -182,10 +151,7 @@ class ShowstreamAction extends ProfileAction
                               sprintf(_('Notice feed for %s (RSS 2.0)'),
                                       $this->target->getNickname())),
                      new Feed(Feed::ATOM,
-                              common_local_url('ApiTimelineUser',
-                                               array(
-                                                    'id' => $this->target->getID(),
-                                                    'format' => 'atom')),
+                              $this->target->getAtomFeed(),
                               // TRANS: Title for link to notice feed.
                               // TRANS: %s is a user nickname.
                               sprintf(_('Notice feed for %s (Atom)'),
@@ -198,6 +164,17 @@ class ShowstreamAction extends ProfileAction
                               sprintf(_('FOAF for %s'), $this->target->getNickname())));
     }
 
+    public function extraHeaders()
+    {
+        parent::extraHeaders();
+        // Publish all the rel="me" in the HTTP headers on our main profile page
+        if (get_class($this) == 'ShowstreamAction') {
+            foreach ($this->target->getRelMes() as $relMe) {
+                header('Link: <'.htmlspecialchars($relMe['href']).'>; rel="me"', false);
+            }
+        }
+    }
+
     function extraHead()
     {
         if ($this->target->bio) {
@@ -205,19 +182,6 @@ class ShowstreamAction extends ProfileAction
                                          'content' => $this->target->getDescription()));
         }
 
-        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()));
-        }
-
-        // See https://wiki.mozilla.org/Microsummaries
-
-        $this->element('link', array('rel' => 'microsummary',
-                                     'href' => common_local_url('microsummary',
-                                                                array('nickname' => $this->target->getNickname()))));
-
         $rsd = common_local_url('rsd',
                                 array('nickname' => $this->target->getNickname()));
 
@@ -260,19 +224,20 @@ class ShowstreamAction extends ProfileAction
 
     function showNotices()
     {
-        $pnl = new NoticeList($this->notice, $this);
+        $pnl = new PrimaryNoticeList($this->notice, $this);
         $cnt = $pnl->show();
         if (0 == $cnt) {
             $this->showEmptyListMessage();
         }
 
-        $args = array('nickname' => $this->target->getNickname());
+        // either nickname or id will be used, depending on which action (showstream, userbyid...)
+        $args = array('nickname' => $this->target->getNickname(), 'id' => $this->target->getID());
         if (!empty($this->tag))
         {
             $args['tag'] = $this->tag;
         }
         $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
-                          'showstream', $args);
+                          $this->getActionName(), $args);
     }
 
     function showAnonymousMessage()
@@ -296,20 +261,11 @@ class ShowstreamAction extends ProfileAction
         $this->elementEnd('div');
     }
 
-    function showSections()
-    {
-        parent::showSections();
-        if (!common_config('performance', 'high')) {
-            $cloud = new PersonalTagCloudSection($this, $this->user);
-            $cloud->show();
-        }
-    }
-
     function noticeFormOptions()
     {
         $options = parent::noticeFormOptions();
 
-        if (!$this->scoped instanceof Profile || $this->scoped->id != $this->target->id) {
+        if (!$this->scoped instanceof Profile || !$this->scoped->sameAs($this->target)) {
             $options['to_profile'] =  $this->target;
         }