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(array $args=array())
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::getKV('nickname', $username);
56 function handle(array $args=array())
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);
77 function showResizeImagesBox()
79 $this->elementStart('select', array('onchange' => 'return scalePhotosToSize(this.value)'));
80 $this->element('option', array('value' => ''), "");
81 $this->element('option', array('value' => '60'), _("Thumbnail"));
82 $this->element('option', array('value' => '120'), _("Medium"));
83 $this->element('option', array('value' => '400'), _("Normal"));
84 $this->elementEnd('select');
89 $album = new GNUsocialPhotoAlbum();
90 $album->profile_id = $this->user->id;
93 if (!$album->find()) {
94 GNUsocialPhotoAlbum::newAlbum($this->user->id, 'Default');
97 $this->elementStart('div', array('class' => 'galleryheader'));
98 //$this->element('a', array('href' => '#',
99 // 'onclick' => 'return increasePhotoSize()'), '+');
101 //$this->element('a', array('href' => '#',
102 // 'onclick' => 'return decreasePhotoSize()'), '-');
104 $this->showResizeImagesBox();
105 $this->elementEnd('div');
109 while ($album->fetch()) {
110 $this->elementStart('div', array('class' => 'photocontainer'));
111 $this->elementStart('a', array('href' => $album->getPageLink()));
112 $this->element('img', array('src' => $album->getThumbUri(),
113 'class' => 'albumingallery'));
114 $this->elementEnd('a');
115 $this->element('h3', array(), $album->album_name);
116 $this->elementEnd('div');
121 function showAlbum($album_id)
123 $album = GNUsocialPhotoAlbum::getKV('album_id', $album_id);
128 $page = $_GET['pageid'];
129 if (!filter_var($page, FILTER_VALIDATE_INT)){
133 $photos = GNUsocialPhoto::getGalleryPage($page, $album->album_id, 9);
134 $this->elementStart('div', array('class' => 'galleryheader'));
136 $this->element('a', array('href' => $album->getPageLink() . '?pageid=' . ($page-1)), 'Previous page');
139 if (GNUsocialPhoto::getGalleryPage($page+1, $album->album_id, 9)) {
140 $this->element('a', array('href' => $album->getPageLink() . '?pageid=' . ($page+1) ), 'Next page');
144 //$this->element('a', array('href' => '#',
145 // 'onclick' => 'return increasePhotoSize()'), '+');
147 //$this->element('a', array('href' => '#',
148 // 'onclick' => 'return decreasePhotoSize()'), '-');
151 $this->showResizeImagesBox();
152 $this->elementEnd('div');
154 foreach ($photos as $photo) {
155 $this->elementStart('a', array('href' => $photo->getPageLink()));
156 $this->elementStart('div', array('class' => 'photocontainer'));
157 $this->element('img', array('src' => $photo->thumb_uri,
158 'class' => 'photoingallery'));
159 $this->element('div', array('class' => 'phototitle'), $photo->title);
160 $this->elementEnd('div');
161 $this->elementEnd('a');
167 function showContent()
169 if (!empty($this->albumid))
170 $this->showAlbum($this->albumid);