4 * Copyright (C) 2010, Free Software Foundation, Inc.
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.
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 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
31 if (!defined('GNUSOCIAL')) { exit(1); }
33 class PhotoAction extends ManagedAction
36 var $conv = null; // Conversation dataobject
38 protected function prepare(array $args=array())
40 parent::prepare($args);
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);
47 $this->user = Profile::getKV('id', $this->notice->profile_id);
48 $this->conv = $this->notice->getConversation();
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;
62 return sprintf(_m("%s's Photo."), $this->user->nickname);
66 function showLocalNav()
68 $nav = new GNUsocialPhotoNav($this, $this->user->nickname);
72 function showContent()
74 if(empty($this->user)) {
78 $this->elementStart('a', array('href' => $this->photo->uri));
79 $this->element('img', array('src' => $this->photo->uri));
80 $this->elementEnd('a');
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');
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 }");
94 if (Event::handle('StartShowConversation', array($this, $this->conv, $this->scoped))) {
95 $notices = $this->conv->getNotices();
96 $nl = new FullThreadedNoticeList($notices, $this, $this->scoped);
99 Event::handle('EndShowConversation', array($this, $this->conv, $this->scoped));