3 * Laconica, the distributed open-source microblogging tool
5 * Show notice attachments
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/feedlist.php';
36 require_once INSTALLDIR.'/lib/attachmentlist.php';
39 * Show notice attachments
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 AttachmentAction extends Action
51 * Attachment object to show
54 var $attachment = null;
57 * Load attributes based on database arguments
59 * Loads all the DB stuff
61 * @param array $args $_REQUEST array
63 * @return success flag
66 function prepare($args)
68 parent::prepare($args);
70 $id = $this->arg('attachment');
72 $this->attachment = File::staticGet($id);
74 if (!$this->attachment) {
75 $this->clientError(_('No such attachment.'), 404);
82 * Is this action read-only?
84 * @return boolean true
87 function isReadOnly($args)
95 * @return string title of the page
99 $a = new Attachment($this->attachment);
104 * Last-modified date for page
106 * When was the content of this page last modified? Based on notice,
109 * @return int last-modified date as unix timestamp
112 function lastModified()
114 return max(strtotime($this->notice->created),
115 strtotime($this->profile->modified),
116 ($this->avatar) ? strtotime($this->avatar->modified) : 0);
121 * An entity tag for this page
123 * Shows the ETag for the page, based on the notice ID and timestamps
124 * for the notice, profile, and avatar. It's weak, since we change
125 * the date text "one hour ago", etc.
127 * @return string etag
132 $avtime = ($this->avatar) ?
133 strtotime($this->avatar->modified) : 0;
135 return 'W/"' . implode(':', array($this->arg('action'),
138 strtotime($this->notice->created),
139 strtotime($this->profile->modified),
148 * Only handles get, so just show the page.
150 * @param array $args $_REQUEST data (unused)
155 function handle($args)
157 parent::handle($args);
162 * Don't show local navigation
167 function showLocalNavBlock()
172 * Fill the content area of the page
174 * Shows a single notice list item.
179 function showContent()
181 $this->elementStart('ul', array('class' => 'attachments'));
182 $ali = new Attachment($this->attachment, $this);
184 $this->elementEnd('ul');
188 * Don't show page notice
193 function showPageNoticeBlock()
198 * Show aside: this attachments appears in what notices
202 function showSections() {
203 $ns = new AttachmentNoticeSection($this);
205 $atcs = new AttachmentTagCloudSection($this);