]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/GNUsocialPhotos/actions/photo.php
Conversation IDs (again) no longer based on Notice ID
[quix0rs-gnu-social.git] / plugins / GNUsocialPhotos / actions / photo.php
1 <?php
2 /**
3  * GNU Social
4  * Copyright (C) 2010, Free Software Foundation, Inc.
5  *
6  * PHP version 5
7  *
8  * LICENCE:
9  * 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  Widget
23  * @package   GNU Social
24  * @author    Ian Denhardt <ian@zenhack.net>
25  * @author    Sean Corbett <sean@gnu.org>
26  * @author    Max Shinn    <trombonechamp@gmail.com>
27  * @copyright 2010 Free Software Foundation, Inc.
28  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
29  */
30
31 if (!defined('GNUSOCIAL')) { exit(1); }
32
33 class PhotoAction extends ManagedAction
34 {
35     var $user = null;
36     var $conv = null;   // Conversation dataobject
37
38     protected function prepare(array $args=array())
39     {
40         parent::prepare($args);
41
42         $args = $this->returnToArgs();
43         $this->photoid = $args[1]['photoid'];
44         $this->photo = GNUsocialPhoto::getKV('id', $this->photoid);
45         $this->notice = Notice::getKV('id', $this->photo->notice_id);
46
47         $this->user = Profile::getKV('id', $this->notice->profile_id);
48         $this->conv = $this->notice->getConversation();
49
50         return true;
51     }
52
53     function title()
54     {
55         if (empty($this->user)) {
56             return _m('No such user.');
57         } else if (empty($this->photo)) {
58             return _m('No such photo.');
59         } else if (!empty($this->photo->title)) {
60             return $this->photo->title;
61         } else {
62             return sprintf(_m("%s's Photo."), $this->user->nickname);
63         }
64     }
65
66     function showLocalNav()
67     {
68         $nav = new GNUsocialPhotoNav($this, $this->user->nickname);
69         $nav->show();
70     }
71
72     function showContent()
73     {
74         if(empty($this->user)) {
75             return;
76         }
77
78         $this->elementStart('a', array('href' => $this->photo->uri));
79         $this->element('img', array('src' => $this->photo->uri));
80         $this->elementEnd('a');
81
82         //Image "toolbar"
83         $cur = common_current_user();
84         if($this->photo->profile_id == $cur->profile_id) {
85             $this->elementStart('div', array('id' => 'image_toolbar'));
86             $this->element('a', array('href' => '/editphoto/' . $this->photo->id), 'Edit');
87             $this->elementEnd('div');
88         }
89
90         $this->element('p', array('class' => 'photodescription'), $this->photo->photo_description);
91         //This is a hack to hide the top-level comment
92         $this->element('style', array(), "#notice-{$this->photo->notice_id} div { display: none } #notice-{$this->photo->notice_id} ol li div { display: inline }");
93
94         if (Event::handle('StartShowConversation', array($this, $this->conv, $this->scoped))) {
95             $notices = $this->conv->getNotices($this->scoped);
96             $nl = new FullThreadedNoticeList($notices, $this, $this->scoped);
97             $cnt = $nl->show();
98         }
99         Event::handle('EndShowConversation', array($this, $this->conv, $this->scoped));
100     }
101 }