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