]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Less redundant code, please
authorMikael Nordfeldth <mmn@hethane.se>
Sat, 20 Jun 2015 23:37:29 +0000 (01:37 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sat, 20 Jun 2015 23:37:29 +0000 (01:37 +0200)
actions/apitimelinetag.php
actions/tag.php
actions/tagrss.php
classes/Notice_tag.php

index b3f17d0712019c9578f92f5fd8aa6dccbfe4b0f2..632714551f95e6dc63d42a0dec8cdb7f0f03c6b0 100644 (file)
@@ -172,21 +172,12 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction
      */
     function getNotices()
     {
-        $notices = array();
+        $notice = Notice_tag::getStream($this->tag)->getNotices(($this->page - 1) * $this->count,
+                                                                 $this->count + 1,
+                                                                 $this->since_id,
+                                                                 $this->max_id);
 
-        $notice = Notice_tag::getStream(
-            $this->tag,
-            ($this->page - 1) * $this->count,
-            $this->count + 1,
-            $this->since_id,
-            $this->max_id
-        );
-
-        while ($notice->fetch()) {
-            $notices[] = clone($notice);
-        }
-
-        return $notices;
+        return $notice->fetchAll();
     }
 
     /**
index 09de8b3c25638973434ced16539b2c5e78716c42..751e8dcec52e92ef65c5a5bdce6ba4ce1159109b 100644 (file)
@@ -46,7 +46,8 @@ class TagAction extends ManagedAction
 
         common_set_returnto($this->selfUrl());
 
-        $this->notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
+        $this->notice = Notice_tag::getStream($this->tag)->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).
index 468944d11f117a99c4819c693e99dc57bb367bec..8a1494f1317ad469519b741700299d4bb4619537 100644 (file)
@@ -47,12 +47,8 @@ class TagrssAction extends Rss10Action
             return null;
         }
 
-        $notice = Notice_tag::getStream($tag->tag, 0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
-        while ($notice->fetch()) {
-            $notices[] = clone($notice);
-        }
-
-        return $notices;
+        $notice = Notice_tag::getStream($tag->tag)->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
+        return $notice->fetchAll();
     }
 
     function getChannel()
index 3d7658a1acfe19ed64e08f2c0d6ee152f43c2e4c..b864de80092b31001b03a8048519b0ab97b6e5ee 100644 (file)
@@ -56,8 +56,7 @@ class Notice_tag extends Managed_DataObject
     static function getStream($tag, $offset=0, $limit=20, $sinceId=0, $maxId=0)
     {
         $stream = new TagNoticeStream($tag);
-        
-        return $stream->getNotices($offset, $limit, $sinceId, $maxId);
+        return $stream;
     }
 
     function blowCache($blowLast=false)