]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/favorited.php
Merge remote branch 'gitorious/1.0.x' into 1.0.x
[quix0rs-gnu-social.git] / actions / favorited.php
index 7e31303e3b87ea11fa71e8046cab24ea3a729d53..17c2a58c946145181526d47e2c94f62b47218e0a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Laconica, the distributed open-source microblogging tool
+ * StatusNet, the distributed open-source microblogging tool
  *
  * List of popular notices
  *
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  * @category  Public
- * @package   Laconica
- * @author    Zach Copley <zach@controlyourself.ca>
- * @author    Evan Prodromou <evan@controlyourself.ca>
- * @copyright 2008-2009 Control Yourself, Inc.
+ * @package   StatusNet
+ * @author    Zach Copley <zach@status.net>
+ * @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://laconi.ca/
+ * @link      http://status.net/
  */
 
-if (!defined('LACONICA')) {
+if (!defined('STATUSNET') && !defined('LACONICA')) {
     exit(1);
 }
 
@@ -42,13 +42,12 @@ require_once INSTALLDIR.'/lib/noticelist.php';
  * is measured by
  *
  * @category Personal
- * @package  Laconica
- * @author   Zach Copley <zach@controlyourself.ca>
- * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @package  StatusNet
+ * @author   Zach Copley <zach@status.net>
+ * @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://laconi.ca/
+ * @link     http://status.net/
  */
-
 class FavoritedAction extends Action
 {
     var $page = null;
@@ -62,8 +61,11 @@ class FavoritedAction extends Action
     function title()
     {
         if ($this->page == 1) {
+            // TRANS: Page title for first page of favorited notices.
             return _('Popular notices');
         } else {
+            // TRANS: Page title for all but first page of favorited notices.
+            // TRANS: %d is the page number being displayed.
             return sprintf(_('Popular notices, page %d'), $this->page);
         }
     }
@@ -73,9 +75,9 @@ class FavoritedAction extends Action
      *
      * @return instructions for use
      */
-
     function getInstructions()
     {
+        // TRANS: Description on page displaying favorited notices.
         return _('The most popular notices on the site right now.');
     }
 
@@ -84,7 +86,6 @@ class FavoritedAction extends Action
      *
      * @return boolean true
      */
-
     function isReadOnly($args)
     {
         return true;
@@ -99,7 +100,6 @@ class FavoritedAction extends Action
      *
      * @todo move queries from showContent() to here
      */
-
     function prepare($args)
     {
         parent::prepare($args);
@@ -119,7 +119,6 @@ class FavoritedAction extends Action
      *
      * @return void
      */
-
     function handle($args)
     {
         parent::handle($args);
@@ -134,7 +133,6 @@ class FavoritedAction extends Action
      *
      * @return void
      */
-
     function showPageNotice()
     {
         $instr  = $this->getInstructions();
@@ -147,12 +145,16 @@ class FavoritedAction extends Action
 
     function showEmptyList()
     {
+        // TRANS: Text displayed instead of a list when a site does not yet have any favourited notices.
         $message = _('Favorite notices appear on this page but no one has favorited one yet.') . ' ';
 
         if (common_logged_in()) {
+            // TRANS: Additional text displayed instead of a list when a site does not yet have any favourited notices for logged in users.
             $message .= _('Be the first to add a notice to your favorites by clicking the fave button next to any notice you like.');
         }
         else {
+            // TRANS: Additional text displayed instead of a list when a site does not yet have any favourited notices for not logged in users.
+            // TRANS: %%action.register%% is a registration link. "[link text](link)" is Mark Down. Do not change the formatting.
             $message .= _('Why not [register an account](%%action.register%%) and be the first to add a notice to your favorites!');
         }
 
@@ -161,20 +163,6 @@ class FavoritedAction extends Action
         $this->elementEnd('div');
     }
 
-    /**
-     * Local navigation
-     *
-     * This page is part of the public group, so show that.
-     *
-     * @return void
-     */
-
-    function showLocalNav()
-    {
-        $nav = new PublicGroupNav($this);
-        $nav->show();
-    }
-
     /**
      * Content area
      *
@@ -182,33 +170,13 @@ class FavoritedAction extends Action
      *
      * @return void
      */
-
     function showContent()
     {
-        if (common_config('db', 'type') == 'pgsql') {
-            $weightexpr='sum(exp(-extract(epoch from (now() - fave.modified)) / %s))';
-        } else {
-            $weightexpr='sum(exp(-(now() - fave.modified) / %s))';
-        }
-
-        $qry = 'SELECT notice.*, '.
-          $weightexpr . ' as weight ' .
-          'FROM notice JOIN fave ON notice.id = fave.notice_id ' .
-          'GROUP BY id,profile_id,uri,content,rendered,url,created,notice.modified,reply_to,is_local,source ' .
-          'ORDER BY weight DESC';
-
-        $offset = ($this->page - 1) * NOTICES_PER_PAGE;
-        $limit  = NOTICES_PER_PAGE + 1;
-
-        if (common_config('db', 'type') == 'pgsql') {
-            $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
-        } else {
-            $qry .= ' LIMIT ' . $offset . ', ' . $limit;
-        }
-
-        $notice = Memcached_DataObject::cachedQuery('Notice',
-                                                    sprintf($qry, common_config('popular', 'dropoff')),
-                                                    600);
+        $pop = new Popularity();
+        $pop->offset = ($this->page - 1) * NOTICES_PER_PAGE;
+        $pop->limit  = NOTICES_PER_PAGE;
+        $pop->expiry = 600;
+        $notice = $pop->getNotices();
 
         $nl = new NoticeList($notice, $this);
 
@@ -221,15 +189,4 @@ class FavoritedAction extends Action
         $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
                           $this->page, 'favorited');
     }
-
-    /**
-     * Output document relationship links
-     *
-     * @return void
-     */
-    function showRelationshipLinks()
-    {
-        $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
-                                     $this->page, 'favorited');
-    }
 }