2008-12-11 23:12:52 +00:00
|
|
|
<?php
|
2008-12-23 19:08:51 +00:00
|
|
|
/**
|
2009-08-25 23:12:20 +01:00
|
|
|
* StatusNet, the distributed open-source microblogging tool
|
2008-12-11 23:12:52 +00:00
|
|
|
*
|
2008-12-23 19:14:30 +00:00
|
|
|
* widget for displaying a list of notices
|
2008-12-23 19:08:51 +00:00
|
|
|
*
|
|
|
|
* PHP version 5
|
|
|
|
*
|
|
|
|
* LICENCE: This program is free software: you can redistribute it and/or modify
|
2008-12-11 23:12:52 +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
|
2008-12-23 19:08:51 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2008-12-11 23:12:52 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
2008-12-23 19:08:51 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* @category UI
|
2009-08-25 23:12:20 +01:00
|
|
|
* @package StatusNet
|
2009-08-25 23:19:04 +01:00
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @author Sarven Capadisli <csarven@status.net>
|
2009-08-25 23:12:20 +01:00
|
|
|
* @copyright 2008 StatusNet, Inc.
|
2008-12-23 19:08:51 +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-12-11 23:12:52 +00:00
|
|
|
*/
|
|
|
|
|
2009-08-26 15:41:36 +01:00
|
|
|
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
2008-12-23 19:08:51 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2009-01-15 23:43:58 +00:00
|
|
|
require_once INSTALLDIR.'/lib/favorform.php';
|
|
|
|
require_once INSTALLDIR.'/lib/disfavorform.php';
|
2009-05-24 09:43:34 +01:00
|
|
|
require_once INSTALLDIR.'/lib/attachmentlist.php';
|
2009-01-15 23:43:58 +00:00
|
|
|
|
2008-12-23 19:08:51 +00:00
|
|
|
/**
|
|
|
|
* widget for displaying a list of notices
|
|
|
|
*
|
|
|
|
* There are a number of actions that display a list of notices, in
|
|
|
|
* reverse chronological order. This widget abstracts out most of the
|
|
|
|
* code for UI for notice lists. It's overridden to hide some
|
|
|
|
* data for e.g. the profile page.
|
|
|
|
*
|
|
|
|
* @category UI
|
2009-08-25 23:12:20 +01:00
|
|
|
* @package StatusNet
|
2009-08-25 23:19:04 +01:00
|
|
|
* @author Evan Prodromou <evan@status.net>
|
2008-12-23 19:08:51 +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-12-23 19:08:51 +00:00
|
|
|
* @see Notice
|
|
|
|
* @see NoticeListItem
|
|
|
|
* @see ProfileNoticeList
|
|
|
|
*/
|
2009-01-15 20:19:32 +00:00
|
|
|
class NoticeList extends Widget
|
2008-12-23 19:08:51 +00:00
|
|
|
{
|
|
|
|
/** the current stream of notices being displayed. */
|
2008-12-11 23:12:52 +00:00
|
|
|
|
2008-12-23 19:08:51 +00:00
|
|
|
var $notice = null;
|
2008-12-11 23:12:52 +00:00
|
|
|
|
2008-12-23 19:08:51 +00:00
|
|
|
/**
|
|
|
|
* constructor
|
|
|
|
*
|
|
|
|
* @param Notice $notice stream of notices from DB_DataObject
|
|
|
|
*/
|
2009-01-15 20:19:32 +00:00
|
|
|
function __construct($notice, $out=null)
|
2008-12-23 19:08:51 +00:00
|
|
|
{
|
2009-01-19 16:35:04 +00:00
|
|
|
parent::__construct($out);
|
2008-12-11 23:12:52 +00:00
|
|
|
$this->notice = $notice;
|
|
|
|
}
|
|
|
|
|
2008-12-23 19:08:51 +00:00
|
|
|
/**
|
|
|
|
* show the list of notices
|
|
|
|
*
|
2009-11-08 22:28:51 +00:00
|
|
|
* "Uses up" the stream by looping through it. So, probably can't
|
2008-12-23 19:08:51 +00:00
|
|
|
* be called twice on the same list.
|
|
|
|
*
|
|
|
|
* @return int count of notices listed.
|
|
|
|
*/
|
|
|
|
function show()
|
|
|
|
{
|
2009-01-15 22:31:32 +00:00
|
|
|
$this->out->elementStart('div', array('id' =>'notices_primary'));
|
2009-05-29 03:38:38 +01:00
|
|
|
$this->out->elementStart('ol', array('class' => 'notices xoxo'));
|
2008-12-11 23:12:52 +00:00
|
|
|
|
2008-12-23 19:08:51 +00:00
|
|
|
$cnt = 0;
|
2008-12-11 23:12:52 +00:00
|
|
|
|
2008-12-23 19:08:51 +00:00
|
|
|
while ($this->notice->fetch() && $cnt <= NOTICES_PER_PAGE) {
|
|
|
|
$cnt++;
|
2008-12-11 23:12:52 +00:00
|
|
|
|
2008-12-23 19:08:51 +00:00
|
|
|
if ($cnt > NOTICES_PER_PAGE) {
|
|
|
|
break;
|
|
|
|
}
|
2008-12-11 23:12:52 +00:00
|
|
|
|
2010-07-13 15:59:01 +01:00
|
|
|
try {
|
|
|
|
$item = $this->newListItem($this->notice);
|
|
|
|
$item->show();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
// we log exceptions and continue
|
|
|
|
common_log(LOG_ERR, $e->getMessage());
|
|
|
|
continue;
|
|
|
|
}
|
2008-12-23 19:08:51 +00:00
|
|
|
}
|
2008-12-11 23:12:52 +00:00
|
|
|
|
2009-05-29 03:38:38 +01:00
|
|
|
$this->out->elementEnd('ol');
|
2009-01-15 22:31:32 +00:00
|
|
|
$this->out->elementEnd('div');
|
2008-12-11 23:12:52 +00:00
|
|
|
|
|
|
|
return $cnt;
|
2008-12-23 19:08:51 +00:00
|
|
|
}
|
2008-12-11 23:12:52 +00:00
|
|
|
|
2008-12-23 19:08:51 +00:00
|
|
|
/**
|
|
|
|
* returns a new list item for the current notice
|
|
|
|
*
|
|
|
|
* Recipe (factory?) method; overridden by sub-classes to give
|
|
|
|
* a different list item class.
|
|
|
|
*
|
|
|
|
* @param Notice $notice the current notice
|
|
|
|
*
|
|
|
|
* @return NoticeListItem a list item for displaying the notice
|
|
|
|
*/
|
|
|
|
function newListItem($notice)
|
|
|
|
{
|
2009-01-15 20:19:32 +00:00
|
|
|
return new NoticeListItem($notice, $this->out);
|
2008-12-11 23:12:52 +00:00
|
|
|
}
|
|
|
|
}
|