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('STATUSNET')) {
35 include_once INSTALLDIR . '/actions/conversation.php';
36 include_once INSTALLDIR . '/classes/Notice.php';
38 class PhotoAction extends Action
42 function prepare($args)
44 parent::prepare($args);
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);
51 $this->user = Profile::staticGet('id', $this->notice->profile_id);
53 $notices = Notice::conversationStream((int)$this->notice->conversation, null, null); //Why do I have to do -1?
54 $this->conversation = new ConversationTree($notices, $this);
59 function handle($args)
61 parent::handle($args);
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;
74 return sprintf(_m("%s's Photo."), $this->user->nickname);
78 function showLocalNav()
80 $nav = new GNUsocialPhotoNav($this, $this->user->nickname);
84 function showContent()
86 if(empty($this->user)) {
90 $this->elementStart('a', array('href' => $this->photo->uri));
91 $this->element('img', array('src' => $this->photo->uri));
92 $this->elementEnd('a');
93 $this->element('p', array(), $this->photo->photo_description);
94 //This is a hack to hide the top-level comment
95 $this->element('style', array(), "#notice-{$this->photo->notice_id} div { display: none } #notice-{$this->photoid} ol li div { display: inline }");
96 $this->conversation->show();