]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/favorited.php
Merge branch 'link-rel-paginate' of git://gitorious.org/laconica/meitar. Fixed wrong...
[quix0rs-gnu-social.git] / actions / favorited.php
index 74920ca7e4073a7a4f68b0911ce971b55fa2d5b5..8cf1528b2aa98f0812e45d390f5913700a296e2e 100644 (file)
@@ -104,9 +104,9 @@ class FavoritedAction extends Action
     {
         parent::prepare($args);
         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
-        
+
         common_set_returnto($this->selfUrl());
-        
+
         return true;
     }
 
@@ -145,6 +145,22 @@ class FavoritedAction extends Action
         $this->elementEnd('div');
     }
 
+    function showEmptyList()
+    {
+        $message = _('Favorite notices appear on this page but no one has favorited one yet.') . ' ';
+
+        if (common_logged_in()) {
+            $message .= _('Be the first to add a notice to your favorites by clicking the fave button next to any notice you like.');
+        }
+        else {
+            $message .= _('Why not [register an account](%%action.register%%) and be the first to add a notice to your favorites!');
+        }
+
+        $this->elementStart('div', 'guide');
+        $this->raw(common_markup_to_html($message));
+        $this->elementEnd('div');
+    }
+
     /**
      * Local navigation
      *
@@ -169,10 +185,16 @@ class FavoritedAction extends Action
 
     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.*, '.
-          'sum(exp(-(now() - fave.modified) / %s)) as weight ' .
+          $weightexpr . ' as weight ' .
           'FROM notice JOIN fave ON notice.id = fave.notice_id ' .
-          'GROUP BY 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;
@@ -192,6 +214,10 @@ class FavoritedAction extends Action
 
         $cnt = $nl->show();
 
+        if ($cnt == 0) {
+            $this->showEmptyList();
+        }
+
         $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
                           $this->page, 'favorited');
     }