3 * Laconica, the distributed open-source microblogging tool
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Evan Prodromou <evan@controlyourself.ca>
25 * @copyright 2008-2009 Control Yourself, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://laconi.ca/
30 if (!defined('LACONICA')) {
34 require_once INSTALLDIR.'/lib/personalgroupnav.php';
35 require_once INSTALLDIR.'/lib/noticelist.php';
36 require_once INSTALLDIR.'/lib/feedlist.php';
39 * Show a single notice
43 * @author Evan Prodromou <evan@controlyourself.ca>
44 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
45 * @link http://laconi.ca/
48 class ShownoticeAction extends Action
51 * Notice object to show
57 * Profile of the notice object
63 * Avatar of the profile of the notice object
69 * Load attributes based on database arguments
71 * Loads all the DB stuff
73 * @param array $args $_REQUEST array
75 * @return success flag
78 function prepare($args)
80 parent::prepare($args);
82 $id = $this->arg('notice');
84 $this->notice = Notice::staticGet($id);
87 $this->clientError(_('No such notice.'), 404);
91 $this->profile = $this->notice->getProfile();
93 if (!$this->profile) {
94 $this->serverError(_('Notice has no profile'), 500);
98 $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
104 * Is this action read-only?
106 * @return boolean true
109 function isReadOnly($args)
115 * Last-modified date for page
117 * When was the content of this page last modified? Based on notice,
120 * @return int last-modified date as unix timestamp
123 function lastModified()
125 return max(strtotime($this->notice->created),
126 strtotime($this->profile->modified),
127 ($this->avatar) ? strtotime($this->avatar->modified) : 0);
131 * An entity tag for this page
133 * Shows the ETag for the page, based on the notice ID and timestamps
134 * for the notice, profile, and avatar. It's weak, since we change
135 * the date text "one hour ago", etc.
137 * @return string etag
142 $avtime = ($this->avatar) ?
143 strtotime($this->avatar->modified) : 0;
145 return 'W/"' . implode(':', array($this->arg('action'),
148 strtotime($this->notice->created),
149 strtotime($this->profile->modified),
156 * @return string title of the page
161 return sprintf(_('%1$s\'s status on %2$s'),
162 $this->profile->nickname,
163 common_exact_date($this->notice->created));
169 * Only handles get, so just show the page.
171 * @param array $args $_REQUEST data (unused)
176 function handle($args)
178 parent::handle($args);
180 if ($this->notice->is_local == 0) {
181 if (!empty($this->notice->url)) {
182 common_redirect($this->notice->url, 301);
183 } else if (!empty($this->notice->uri) && preg_match('/^https?:/', $this->notice->uri)) {
184 common_redirect($this->notice->uri, 301);
192 * Don't show local navigation
197 function showLocalNavBlock()
202 * Fill the content area of the page
204 * Shows a single notice list item.
209 function showContent()
211 $this->elementStart('ul', array('class' => 'notices'));
212 $nli = new NoticeListItem($this->notice, $this);
214 $this->elementEnd('ul');
218 * Don't show page notice
223 function showPageNoticeBlock()
233 function showAside() {
237 * Extra <head> content
239 * We show the microid(s) for the author, if any.
246 $user = User::staticGet($this->profile->id);
252 if ($user->emailmicroid && $user->email && $this->notice->uri) {
253 $id = new Microid('mailto:'. $user->email,
255 $this->element('meta', array('name' => 'microid',
256 'content' => $id->toString()));
259 if ($user->jabbermicroid && $user->jabber && $this->notice->uri) {
260 $id = new Microid('xmpp:', $user->jabber,
262 $this->element('meta', array('name' => 'microid',
263 'content' => $id->toString()));