X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Ffavorited.php;h=5ba508cdf5e592bfb95ecd16444c0c180fd92cbe;hb=03022c6e601f223c92216af9748c764786cf46c2;hp=fd5ff413cbbfd9cc8f0ac478c7aa084a7c0d43ca;hpb=a6cf3a2fb3b150cba06143f6a744a49a0cf91e83;p=quix0rs-gnu-social.git diff --git a/actions/favorited.php b/actions/favorited.php index fd5ff413cb..5ba508cdf5 100644 --- a/actions/favorited.php +++ b/actions/favorited.php @@ -1,6 +1,6 @@ . * * @category Public - * @package Laconica - * @author Zach Copley - * @author Evan Prodromou - * @copyright 2008-2009 Control Yourself, Inc. + * @package StatusNet + * @author Zach Copley + * @author Evan Prodromou + * @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,11 +42,11 @@ require_once INSTALLDIR.'/lib/noticelist.php'; * is measured by * * @category Personal - * @package Laconica - * @author Zach Copley - * @author Evan Prodromou + * @package StatusNet + * @author Zach Copley + * @author Evan Prodromou * @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 @@ -85,7 +85,7 @@ class FavoritedAction extends Action * @return boolean true */ - function isReadOnly() + function isReadOnly($args) { return true; } @@ -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,23 @@ 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 .= sprintf(_('Why not [register an account](%%%%action.%s%%%%) and be the first to add a notice to your favorites!'), + (!common_config('site','openidonly')) ? 'register' : 'openidlogin'); + } + + $this->elementStart('div', 'guide'); + $this->raw(common_markup_to_html($message)); + $this->elementEnd('div'); + } + /** * Local navigation * @@ -169,10 +186,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,notice.conversation ' . 'ORDER BY weight DESC'; $offset = ($this->page - 1) * NOTICES_PER_PAGE; @@ -192,6 +215,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'); }