]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/GNUsocialPhotos/actions/photo.php
f6ec06358638fbf294062afcdc6c323bfa9a59e8
[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('STATUSNET')) {
32     exit(1);
33 }
34
35 include_once INSTALLDIR . '/actions/conversation.php';
36 include_once INSTALLDIR . '/classes/Notice.php';
37
38 class PhotoAction extends Action
39 {
40     var $user = null;
41
42     function prepare($args)
43     {
44         parent::prepare($args);
45
46         $args = $this->returnToArgs();
47         $this->photoid = $args[1]['photoid'];
48         $this->photo = GNUsocialPhoto::staticGet('id', $this->photoid);
49         $this->notice = Notice::staticGet('id', $this->photo->notice_id);
50
51         $this->user = Profile::staticGet('id', $this->notice->profile_id);
52         
53         $notices = Notice::conversationStream((int)$this->notice->conversation, null, null); 
54         $this->conversation = new ConversationTree($notices, $this);
55         return true;
56
57     }
58
59     function handle($args)
60     {
61         parent::handle($args);
62         $this->showPage();
63     }
64
65     function title()
66     {
67         if (empty($this->user)) {
68             return _m('No such user.');
69         } else if (empty($this->photo)) {
70             return _m('No such photo.');
71         } else if (!empty($this->photo->title)) {
72             return $this->photo->title;
73         } else {
74             return sprintf(_m("%s's Photo."), $this->user->nickname);
75         }
76     }
77
78     function showLocalNav()
79     {
80         $nav = new GNUsocialPhotoNav($this, $this->user->nickname);
81         $nav->show();
82     }
83
84     function showContent()
85     {
86         if(empty($this->user)) {
87             return;
88         }
89
90         $this->elementStart('a', array('href' => $this->photo->uri));
91         $this->element('img', array('src' => $this->photo->uri));
92         $this->elementEnd('a');
93
94         //Image "toolbar"
95         $cur = common_current_user();
96         if($this->photo->profile_id == $cur->profile_id) {
97             $this->elementStart('div', array('id' => 'image_toolbar'));
98             $this->element('a', array('href' => '/editphoto/' . $this->photo->id), 'Edit');
99             $this->elementEnd('div');
100         }
101
102         $this->element('p', array(), $this->photo->photo_description);
103         //This is a hack to hide the top-level comment
104         $this->element('style', array(), "#notice-{$this->photo->notice_id} div { display: none } #notice-{$this->photo->notice_id} ol li div { display: inline }");
105         $this->conversation->show();
106     }
107 }