]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/attachment.php
Merge branch '0.8.x' of git@gitorious.org:+laconica-developers/laconica/dev into...
[quix0rs-gnu-social.git] / actions / attachment.php
1 <?php
2 /**
3  * Laconica, the distributed open-source microblogging tool
4  *
5  * Show notice attachments
6  *
7  * PHP version 5
8  *
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.
13  *
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.
18  *
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/>.
21  *
22  * @category  Personal
23  * @package   Laconica
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/
28  */
29
30 if (!defined('LACONICA')) {
31     exit(1);
32 }
33
34 require_once INSTALLDIR.'/lib/attachmentlist.php';
35
36 /**
37  * Show notice attachments
38  *
39  * @category Personal
40  * @package  Laconica
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/
44  */
45
46 class AttachmentAction extends Action
47 {
48     /**
49      * Attachment object to show
50      */
51
52     var $attachment = null;
53
54     /**
55      * Load attributes based on database arguments
56      *
57      * Loads all the DB stuff
58      *
59      * @param array $args $_REQUEST array
60      *
61      * @return success flag
62      */
63
64     function prepare($args)
65     {
66         parent::prepare($args);
67
68         if ($id = $this->trimmed('attachment')) {
69             $this->attachment = File::staticGet($id);
70         }
71
72         if (empty($this->attachment)) {
73             $this->clientError(_('No such attachment.'), 404);
74             return false;
75         }
76         return true;
77     }
78
79     /**
80      * Is this action read-only?
81      *
82      * @return boolean true
83      */
84
85     function isReadOnly($args)
86     {
87         return true;
88     }
89
90     /**
91      * Title of the page
92      *
93      * @return string title of the page
94      */
95     function title()
96     {
97         $a = new Attachment($this->attachment);
98         return $a->title();
99     }
100
101     /**
102      * Last-modified date for page
103      *
104      * When was the content of this page last modified? Based on notice,
105      * profile, avatar.
106      *
107      * @return int last-modified date as unix timestamp
108      */
109 /*
110     function lastModified()
111     {
112         return max(strtotime($this->notice->created),
113                    strtotime($this->profile->modified),
114                    ($this->avatar) ? strtotime($this->avatar->modified) : 0);
115     }
116 */
117
118     /**
119      * An entity tag for this page
120      *
121      * Shows the ETag for the page, based on the notice ID and timestamps
122      * for the notice, profile, and avatar. It's weak, since we change
123      * the date text "one hour ago", etc.
124      *
125      * @return string etag
126      */
127 /*
128     function etag()
129     {
130         $avtime = ($this->avatar) ?
131           strtotime($this->avatar->modified) : 0;
132
133         return 'W/"' . implode(':', array($this->arg('action'),
134                                           common_language(),
135                                           $this->notice->id,
136                                           strtotime($this->notice->created),
137                                           strtotime($this->profile->modified),
138                                           $avtime)) . '"';
139     }
140 */
141
142
143     /**
144      * Handle input
145      *
146      * Only handles get, so just show the page.
147      *
148      * @param array $args $_REQUEST data (unused)
149      *
150      * @return void
151      */
152
153     function handle($args)
154     {
155         parent::handle($args);
156         $this->showPage();
157     }
158
159     /**
160      * Don't show local navigation
161      *
162      * @return void
163      */
164
165     function showLocalNavBlock()
166     {
167     }
168
169     /**
170      * Fill the content area of the page
171      *
172      * Shows a single notice list item.
173      *
174      * @return void
175      */
176
177     function showContent()
178     {
179         $ali = new Attachment($this->attachment, $this);
180         $cnt = $ali->show();
181     }
182
183     /**
184      * Don't show page notice
185      *
186      * @return void
187      */
188
189     function showPageNoticeBlock()
190     {
191     }
192
193     /**
194      * Show aside: this attachments appears in what notices
195      *
196      * @return void
197      */
198     function showSections() {
199         $ns = new AttachmentNoticeSection($this);
200         $ns->show();
201         $atcs = new AttachmentTagCloudSection($this);
202         $atcs->show();
203     }
204 }
205