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 require_once INSTALLDIR.'/lib/personalgroupnav.php';
37 class PhotosAction extends Action
41 function prepare($args)
43 parent::prepare($args);
45 $args = $this->returnToArgs();
46 $username = $args[1]['nickname'];
47 $this->albumid = $args[1]['albumid'];
48 if (common_valid_profile_tag($username) == 0) {
51 $this->user = Profile::staticGet('nickname', $username);
56 function handle($args)
58 parent::handle($args);
64 if (empty($this->user)) {
65 return _m('No such user.');
67 return sprintf(_m("%s's Photos."), $this->user->nickname);
71 function showLocalNav()
73 $nav = new PersonalGroupNav($this);
79 $album = new GNUsocialPhotoAlbum();
80 $album->user_id = $this->user->id;
83 if (!$album->find()) {
84 GNUsocialPhotoAlbum::newAlbum($cur->id, 'Default');
86 while ($album->fetch()) {
87 $this->elementStart('div', array('class' => 'photocontainer'));
88 $this->elementStart('a', array('href' => $album->getPageLink()));
89 $this->element('img', array('src' => $album->getThumbUri()));
90 $this->elementEnd('a');
91 $this->element('h3', array(), $album->album_name);
92 $this->elementEnd('div');
97 function showAlbum($album_id)
99 $album = GNUSocialPhotoAlbum::staticGet('album_id', $album_id);
104 $page = $_GET['pageid'];
105 if (!filter_var($page, FILTER_VALIDATE_INT)){
109 $photos = GNUsocialPhoto::getGalleryPage($page, $album->album_id, 9);
111 $this->element('a', array('href' => $album->getPageLink() . '?pageid=' . ($page-1)), 'Previous page');
113 if (GNUsocialPhoto::getGalleryPage($page+1, $album->album_id, 9)) {
114 $this->element('a', array('href' => $album->getPageLink() . '?pageid=' . ($page+1) ), 'Next page');
117 foreach ($photos as $photo) {
118 $this->elementStart('a', array('href' => $photo->getPageLink()));
119 $this->elementStart('div', array('class' => 'photocontainer'));
120 $this->element('img', array('src' => $photo->thumb_uri));
121 $this->element('div', array('class' => 'phototitle'), $photo->title);
122 $this->elementEnd('div');
123 $this->elementEnd('a');
129 function showContent()
131 if (!empty($this->albumid))
132 $this->showAlbum($this->albumid);