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/attachmentlist.php';
37 * Show notice attachments
41 * @author Evan Prodromou <evan@controlyourself.ca>
42 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
43 * @link http://laconi.ca/
46 class AttachmentAction extends Action
49 * Attachment object to show
52 var $attachment = null;
55 * Load attributes based on database arguments
57 * Loads all the DB stuff
59 * @param array $args $_REQUEST array
61 * @return success flag
64 function prepare($args)
66 parent::prepare($args);
68 if ($id = $this->trimmed('attachment')) {
69 $this->attachment = File::staticGet($id);
72 if (empty($this->attachment)) {
73 $this->clientError(_('No such attachment.'), 404);
80 * Is this action read-only?
82 * @return boolean true
85 function isReadOnly($args)
93 * @return string title of the page
97 $a = new Attachment($this->attachment);
103 $this->element('link',array('rel'=>'alternate',
104 'type'=>'application/json+oembed',
105 'href'=>common_local_url(
107 array('apiaction'=>'oembed','method'=>'oembed.json'),
109 common_local_url('attachment',
110 array('attachment' => $this->attachment->id)))),
111 'title'=>'oEmbed'),null);
112 $this->element('link',array('rel'=>'alternate',
113 'type'=>'text/xml+oembed',
114 'href'=>common_local_url(
116 array('apiaction'=>'oembed','method'=>'oembed.xml'),
118 common_local_url('attachment',
119 array('attachment' => $this->attachment->id)))),
120 'title'=>'oEmbed'),null);
126 * Only handles get, so just show the page.
128 * @param array $args $_REQUEST data (unused)
133 function handle($args)
135 parent::handle($args);
137 if (empty($this->attachment->filename)) {
139 // if it's not a local file, gtfo
141 common_redirect($this->attachment->url, 303);
149 * Don't show local navigation
154 function showLocalNavBlock()
159 * Fill the content area of the page
161 * Shows a single notice list item.
166 function showContent()
168 $ali = new Attachment($this->attachment, $this);
173 * Don't show page notice
178 function showPageNoticeBlock()
183 * Show aside: this attachments appears in what notices
187 function showSections() {
188 $ns = new AttachmentNoticeSection($this);
190 $atcs = new AttachmentTagCloudSection($this);