2008-11-20 07:19:30 +00:00
|
|
|
<?php
|
2009-01-19 13:22:22 +00:00
|
|
|
/**
|
2009-08-25 23:12:20 +01:00
|
|
|
* StatusNet, the distributed open-source microblogging tool
|
2008-11-20 07:19:30 +00:00
|
|
|
*
|
2009-01-19 13:22:22 +00:00
|
|
|
* List of popular notices
|
|
|
|
*
|
|
|
|
* PHP version 5
|
|
|
|
*
|
|
|
|
* LICENCE: This program is free software: you can redistribute it and/or modify
|
2008-11-20 07:19:30 +00:00
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2009-01-19 13:22:22 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2008-11-20 07:19:30 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
2009-01-19 13:22:22 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* @category Public
|
2009-08-25 23:12:20 +01:00
|
|
|
* @package StatusNet
|
2009-08-25 23:19:04 +01:00
|
|
|
* @author Zach Copley <zach@status.net>
|
|
|
|
* @author Evan Prodromou <evan@status.net>
|
2009-08-25 23:12:20 +01:00
|
|
|
* @copyright 2008-2009 StatusNet, Inc.
|
2009-01-19 13:22:22 +00:00
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
2009-08-25 23:16:46 +01:00
|
|
|
* @link http://status.net/
|
2008-11-20 07:19:30 +00:00
|
|
|
*/
|
|
|
|
|
2014-06-28 15:09:46 +01:00
|
|
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
2008-11-20 07:19:30 +00:00
|
|
|
|
2009-01-19 13:22:22 +00:00
|
|
|
/**
|
|
|
|
* List of popular notices
|
|
|
|
*
|
|
|
|
* We provide a list of the most popular notices. Popularity
|
|
|
|
* is measured by
|
|
|
|
*
|
|
|
|
* @category Personal
|
2009-08-25 23:12:20 +01:00
|
|
|
* @package StatusNet
|
2009-08-25 23:19:04 +01:00
|
|
|
* @author Zach Copley <zach@status.net>
|
|
|
|
* @author Evan Prodromou <evan@status.net>
|
2009-01-19 13:22:22 +00:00
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
2009-08-25 23:16:46 +01:00
|
|
|
* @link http://status.net/
|
2009-01-19 13:22:22 +00:00
|
|
|
*/
|
|
|
|
class FavoritedAction extends Action
|
2008-12-23 19:49:23 +00:00
|
|
|
{
|
2009-01-19 13:22:22 +00:00
|
|
|
var $page = null;
|
2008-11-20 07:19:30 +00:00
|
|
|
|
2009-01-19 13:22:22 +00:00
|
|
|
/**
|
|
|
|
* Title of the page
|
|
|
|
*
|
|
|
|
* @return string Title of the page
|
|
|
|
*/
|
|
|
|
|
|
|
|
function title()
|
2008-12-23 19:33:23 +00:00
|
|
|
{
|
2009-01-19 13:22:22 +00:00
|
|
|
if ($this->page == 1) {
|
2011-01-30 18:01:55 +00:00
|
|
|
// TRANS: Page title for first page of favorited notices.
|
2009-01-19 13:22:22 +00:00
|
|
|
return _('Popular notices');
|
|
|
|
} else {
|
2011-01-30 18:01:55 +00:00
|
|
|
// TRANS: Page title for all but first page of favorited notices.
|
|
|
|
// TRANS: %d is the page number being displayed.
|
2009-01-19 13:22:22 +00:00
|
|
|
return sprintf(_('Popular notices, page %d'), $this->page);
|
|
|
|
}
|
|
|
|
}
|
2008-11-20 07:19:30 +00:00
|
|
|
|
2009-01-19 13:22:22 +00:00
|
|
|
/**
|
|
|
|
* Instructions for use
|
|
|
|
*
|
|
|
|
* @return instructions for use
|
|
|
|
*/
|
|
|
|
function getInstructions()
|
|
|
|
{
|
2011-01-30 18:01:55 +00:00
|
|
|
// TRANS: Description on page displaying favorited notices.
|
2009-01-19 13:22:22 +00:00
|
|
|
return _('The most popular notices on the site right now.');
|
|
|
|
}
|
2008-11-20 07:19:30 +00:00
|
|
|
|
2009-01-19 13:22:22 +00:00
|
|
|
/**
|
|
|
|
* Is this page read-only?
|
|
|
|
*
|
|
|
|
* @return boolean true
|
|
|
|
*/
|
2009-04-13 20:49:26 +01:00
|
|
|
function isReadOnly($args)
|
2009-01-19 13:22:22 +00:00
|
|
|
{
|
|
|
|
return true;
|
2008-12-23 19:19:07 +00:00
|
|
|
}
|
2008-11-20 07:19:30 +00:00
|
|
|
|
2009-01-19 13:22:22 +00:00
|
|
|
/**
|
|
|
|
* Take arguments for running
|
|
|
|
*
|
|
|
|
* @param array $args $_REQUEST args
|
|
|
|
*
|
|
|
|
* @return boolean success flag
|
|
|
|
*
|
|
|
|
* @todo move queries from showContent() to here
|
|
|
|
*/
|
|
|
|
function prepare($args)
|
2008-12-23 19:33:23 +00:00
|
|
|
{
|
2009-01-19 13:22:22 +00:00
|
|
|
parent::prepare($args);
|
|
|
|
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
2009-04-08 04:57:45 +01:00
|
|
|
|
2009-02-06 00:16:10 +00:00
|
|
|
common_set_returnto($this->selfUrl());
|
2009-04-08 04:57:45 +01:00
|
|
|
|
2009-01-19 13:22:22 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle request
|
|
|
|
*
|
|
|
|
* Shows a page with list of favorite notices
|
|
|
|
*
|
|
|
|
* @param array $args $_REQUEST args; handled in prepare()
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function handle($args)
|
|
|
|
{
|
|
|
|
parent::handle($args);
|
|
|
|
|
|
|
|
$this->showPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the page notice
|
|
|
|
*
|
|
|
|
* Shows instructions for the page
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function showPageNotice()
|
|
|
|
{
|
|
|
|
$instr = $this->getInstructions();
|
2008-12-23 19:19:07 +00:00
|
|
|
$output = common_markup_to_html($instr);
|
2009-01-19 13:22:22 +00:00
|
|
|
|
2009-01-15 22:57:15 +00:00
|
|
|
$this->elementStart('div', 'instructions');
|
|
|
|
$this->raw($output);
|
|
|
|
$this->elementEnd('div');
|
2009-04-08 04:57:45 +01:00
|
|
|
}
|
2009-04-03 21:35:18 +01:00
|
|
|
|
2009-04-08 04:57:45 +01:00
|
|
|
function showEmptyList()
|
|
|
|
{
|
2011-01-30 18:01:55 +00:00
|
|
|
// TRANS: Text displayed instead of a list when a site does not yet have any favourited notices.
|
2009-04-07 22:12:11 +01:00
|
|
|
$message = _('Favorite notices appear on this page but no one has favorited one yet.') . ' ';
|
2009-04-03 21:35:18 +01:00
|
|
|
|
|
|
|
if (common_logged_in()) {
|
2011-01-30 18:01:55 +00:00
|
|
|
// TRANS: Additional text displayed instead of a list when a site does not yet have any favourited notices for logged in users.
|
2009-04-03 21:35:18 +01:00
|
|
|
$message .= _('Be the first to add a notice to your favorites by clicking the fave button next to any notice you like.');
|
|
|
|
}
|
|
|
|
else {
|
2011-01-30 18:01:55 +00:00
|
|
|
// 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.
|
2009-08-21 21:45:42 +01:00
|
|
|
$message .= _('Why not [register an account](%%action.register%%) and be the first to add a notice to your favorites!');
|
2009-04-03 21:35:18 +01:00
|
|
|
}
|
|
|
|
|
2009-04-07 22:09:27 +01:00
|
|
|
$this->elementStart('div', 'guide');
|
2009-04-03 21:35:18 +01:00
|
|
|
$this->raw(common_markup_to_html($message));
|
|
|
|
$this->elementEnd('div');
|
2008-12-23 19:19:07 +00:00
|
|
|
}
|
2008-11-20 07:19:30 +00:00
|
|
|
|
2009-01-19 13:22:22 +00:00
|
|
|
/**
|
|
|
|
* Content area
|
|
|
|
*
|
|
|
|
* Shows the list of popular notices
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function showContent()
|
|
|
|
{
|
2016-03-01 13:51:47 +00:00
|
|
|
$stream = new PopularNoticeStream($this->scoped);
|
2011-10-20 15:40:39 +01:00
|
|
|
$notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE+1);
|
2008-11-20 07:19:30 +00:00
|
|
|
|
2009-01-19 13:22:22 +00:00
|
|
|
$nl = new NoticeList($notice, $this);
|
2008-11-20 07:19:30 +00:00
|
|
|
|
2009-01-19 13:22:22 +00:00
|
|
|
$cnt = $nl->show();
|
2008-11-20 07:19:30 +00:00
|
|
|
|
2009-04-08 04:57:45 +01:00
|
|
|
if ($cnt == 0) {
|
|
|
|
$this->showEmptyList();
|
|
|
|
}
|
|
|
|
|
2009-01-19 13:22:22 +00:00
|
|
|
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
|
|
|
|
$this->page, 'favorited');
|
2008-12-23 19:19:07 +00:00
|
|
|
}
|
2008-12-05 22:14:02 +00:00
|
|
|
}
|