2008-05-09 11:16:04 +09:00
|
|
|
<?php
|
2009-01-19 03:35:11 +09:00
|
|
|
/**
|
|
|
|
* Laconica, the distributed open-source microblogging tool
|
2008-05-21 04:14:12 +09:00
|
|
|
*
|
2009-01-19 03:35:11 +09:00
|
|
|
* Show a single notice
|
|
|
|
*
|
|
|
|
* PHP version 5
|
|
|
|
*
|
|
|
|
* LICENCE: This program is free software: you can redistribute it and/or modify
|
2008-05-15 04:26:48 +09: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.
|
2008-05-21 04:14:12 +09:00
|
|
|
*
|
2008-05-15 04:26:48 +09:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
2008-05-21 04:14:12 +09:00
|
|
|
*
|
2008-05-15 04:26:48 +09:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-01-19 03:35:11 +09:00
|
|
|
*
|
|
|
|
* @category Personal
|
|
|
|
* @package Laconica
|
|
|
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
|
|
|
* @copyright 2008-2009 Control Yourself, Inc.
|
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
|
|
* @link http://laconi.ca/
|
2008-05-15 04:26:48 +09:00
|
|
|
*/
|
|
|
|
|
2009-01-19 03:35:11 +09:00
|
|
|
if (!defined('LACONICA')) {
|
|
|
|
exit(1);
|
|
|
|
}
|
2008-05-09 11:16:04 +09:00
|
|
|
|
2009-01-19 03:35:11 +09:00
|
|
|
require_once INSTALLDIR.'/lib/personalgroupnav.php';
|
|
|
|
require_once INSTALLDIR.'/lib/noticelist.php';
|
|
|
|
require_once INSTALLDIR.'/lib/feedlist.php';
|
2008-06-11 07:19:10 +09:00
|
|
|
|
2009-01-19 03:35:11 +09:00
|
|
|
/**
|
|
|
|
* Show a single notice
|
|
|
|
*
|
|
|
|
* @category Personal
|
|
|
|
* @package Laconica
|
|
|
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
|
|
* @link http://laconi.ca/
|
|
|
|
*/
|
|
|
|
|
|
|
|
class ShownoticeAction extends Action
|
2008-12-24 04:49:23 +09:00
|
|
|
{
|
2009-01-19 03:35:11 +09:00
|
|
|
/**
|
|
|
|
* Notice object to show
|
|
|
|
*/
|
2008-05-09 11:16:04 +09:00
|
|
|
|
2008-12-24 04:21:29 +09:00
|
|
|
var $notice = null;
|
2009-01-19 03:35:11 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Profile of the notice object
|
|
|
|
*/
|
|
|
|
|
2008-12-24 04:21:29 +09:00
|
|
|
var $profile = null;
|
2009-01-19 03:35:11 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Avatar of the profile of the notice object
|
|
|
|
*/
|
|
|
|
|
2008-12-24 04:21:29 +09:00
|
|
|
var $avatar = null;
|
2008-12-02 14:02:00 +09:00
|
|
|
|
2009-01-19 03:35:11 +09:00
|
|
|
/**
|
|
|
|
* Load attributes based on database arguments
|
|
|
|
*
|
|
|
|
* Loads all the DB stuff
|
|
|
|
*
|
|
|
|
* @param array $args $_REQUEST array
|
|
|
|
*
|
|
|
|
* @return success flag
|
|
|
|
*/
|
|
|
|
|
2008-12-24 04:33:23 +09:00
|
|
|
function prepare($args)
|
|
|
|
{
|
2008-12-24 04:19:07 +09:00
|
|
|
parent::prepare($args);
|
2008-12-02 13:12:43 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
$id = $this->arg('notice');
|
2009-01-19 03:35:11 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
$this->notice = Notice::staticGet($id);
|
2008-05-09 11:16:04 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
if (!$this->notice) {
|
2009-01-16 08:03:38 +09:00
|
|
|
$this->clientError(_('No such notice.'), 404);
|
2008-12-24 04:19:07 +09:00
|
|
|
return false;
|
|
|
|
}
|
2008-05-09 11:16:04 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
$this->profile = $this->notice->getProfile();
|
2008-06-28 07:29:30 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
if (!$this->profile) {
|
2009-01-16 08:03:38 +09:00
|
|
|
$this->serverError(_('Notice has no profile'), 500);
|
2008-12-24 04:19:07 +09:00
|
|
|
return false;
|
|
|
|
}
|
2008-05-21 04:14:12 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
$this->avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
|
2008-12-02 13:50:21 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
return true;
|
|
|
|
}
|
2008-12-02 13:12:43 +09:00
|
|
|
|
2009-01-19 03:35:11 +09:00
|
|
|
/**
|
|
|
|
* Is this action read-only?
|
|
|
|
*
|
|
|
|
* @return boolean true
|
|
|
|
*/
|
|
|
|
|
|
|
|
function isReadOnly()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Last-modified date for page
|
|
|
|
*
|
|
|
|
* When was the content of this page last modified? Based on notice,
|
|
|
|
* profile, avatar.
|
|
|
|
*
|
|
|
|
* @return int last-modified date as unix timestamp
|
|
|
|
*/
|
|
|
|
|
|
|
|
function lastModified()
|
2008-12-24 04:33:23 +09:00
|
|
|
{
|
2008-12-24 04:19:07 +09:00
|
|
|
return max(strtotime($this->notice->created),
|
|
|
|
strtotime($this->profile->modified),
|
|
|
|
($this->avatar) ? strtotime($this->avatar->modified) : 0);
|
|
|
|
}
|
2008-12-02 13:50:21 +09:00
|
|
|
|
2009-01-19 03:35:11 +09:00
|
|
|
/**
|
|
|
|
* An entity tag for this page
|
|
|
|
*
|
|
|
|
* Shows the ETag for the page, based on the notice ID and timestamps
|
|
|
|
* for the notice, profile, and avatar. It's weak, since we change
|
|
|
|
* the date text "one hour ago", etc.
|
|
|
|
*
|
|
|
|
* @return string etag
|
|
|
|
*/
|
|
|
|
|
2008-12-24 04:33:23 +09:00
|
|
|
function etag()
|
|
|
|
{
|
2009-01-19 03:35:11 +09:00
|
|
|
$avtime = ($this->avatar) ?
|
|
|
|
strtotime($this->avatar->modified) : 0;
|
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
return 'W/"' . implode(':', array($this->arg('action'),
|
|
|
|
common_language(),
|
|
|
|
$this->notice->id,
|
|
|
|
strtotime($this->notice->created),
|
|
|
|
strtotime($this->profile->modified),
|
2009-01-19 03:35:11 +09:00
|
|
|
$avtime)) . '"';
|
2008-12-24 04:19:07 +09:00
|
|
|
}
|
2008-12-02 13:12:43 +09:00
|
|
|
|
2009-01-19 03:35:11 +09:00
|
|
|
/**
|
|
|
|
* Title of the page
|
|
|
|
*
|
|
|
|
* @return string title of the page
|
|
|
|
*/
|
|
|
|
|
|
|
|
function title()
|
2008-12-24 04:33:23 +09:00
|
|
|
{
|
2009-01-19 03:35:11 +09:00
|
|
|
return sprintf(_('%1$s\'s status on %2$s'),
|
|
|
|
$this->profile->nickname,
|
|
|
|
common_exact_date($this->notice->created));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle input
|
|
|
|
*
|
|
|
|
* Only handles get, so just show the page.
|
|
|
|
*
|
|
|
|
* @param array $args $_REQUEST data (unused)
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-21 04:14:12 +09:00
|
|
|
|
2009-01-19 03:35:11 +09:00
|
|
|
function handle($args)
|
|
|
|
{
|
2008-12-24 04:19:07 +09:00
|
|
|
parent::handle($args);
|
2008-12-02 13:12:43 +09:00
|
|
|
|
2009-01-19 03:35:11 +09:00
|
|
|
$this->showPage();
|
|
|
|
}
|
2008-05-21 04:14:12 +09:00
|
|
|
|
2009-01-20 02:12:35 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Don't show local navigation
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
|
|
|
|
function showLocalNavBlock()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-19 03:35:11 +09:00
|
|
|
/**
|
|
|
|
* Fill the content area of the page
|
|
|
|
*
|
|
|
|
* Shows a single notice list item.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
|
|
|
|
function showContent()
|
|
|
|
{
|
2009-01-20 01:50:22 +09:00
|
|
|
$this->elementStart('ul', array('class' => 'notices'));
|
2009-01-19 03:35:11 +09:00
|
|
|
$nli = new NoticeListItem($this->notice, $this);
|
2008-12-12 08:12:52 +09:00
|
|
|
$nli->show();
|
2009-01-16 07:57:15 +09:00
|
|
|
$this->elementEnd('ul');
|
2008-12-24 04:19:07 +09:00
|
|
|
}
|
2008-05-21 04:14:12 +09:00
|
|
|
|
2009-01-20 02:12:35 +09:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Don't show page notice
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
|
|
|
|
function showPageNoticeBlock()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Don't show aside
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
|
|
|
|
function showAside() {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-19 03:35:11 +09:00
|
|
|
/**
|
|
|
|
* Extra <head> content
|
|
|
|
*
|
|
|
|
* We show the microid(s) for the author, if any.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-12-02 13:12:43 +09:00
|
|
|
|
2009-01-19 03:35:11 +09:00
|
|
|
function extraHead()
|
|
|
|
{
|
2008-12-24 04:19:07 +09:00
|
|
|
$user = User::staticGet($this->profile->id);
|
2008-12-02 13:12:43 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
if (!$user) {
|
|
|
|
return;
|
|
|
|
}
|
2008-12-02 13:12:43 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
if ($user->emailmicroid && $user->email && $this->notice->uri) {
|
2009-01-19 03:35:11 +09:00
|
|
|
$id = new Microid('mailto:'. $user->email,
|
|
|
|
$this->notice->uri);
|
2009-01-16 07:57:15 +09:00
|
|
|
$this->element('meta', array('name' => 'microid',
|
2009-01-19 03:35:11 +09:00
|
|
|
'content' => $id->toString()));
|
2008-12-24 04:19:07 +09:00
|
|
|
}
|
2008-12-02 13:12:43 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
if ($user->jabbermicroid && $user->jabber && $this->notice->uri) {
|
2009-01-19 03:35:11 +09:00
|
|
|
$id = new Microid('xmpp:', $user->jabber,
|
|
|
|
$this->notice->uri);
|
2009-01-16 07:57:15 +09:00
|
|
|
$this->element('meta', array('name' => 'microid',
|
2009-01-19 03:35:11 +09:00
|
|
|
'content' => $id->toString()));
|
2008-12-24 04:19:07 +09:00
|
|
|
}
|
|
|
|
}
|
2008-05-09 11:16:04 +09:00
|
|
|
}
|