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);
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->user_id = $this->user->id;
93 if (!$album->find()) {
94 $cur = common_current_user();
95 GNUsocialPhotoAlbum::newAlbum($cur->profile_id, 'Default');
98 $this->elementStart('div', array('class' => 'galleryheader'));
99 //$this->element('a', array('href' => '#',
100 // 'onclick' => 'return increasePhotoSize()'), '+');
102 //$this->element('a', array('href' => '#',
103 // 'onclick' => 'return decreasePhotoSize()'), '-');
105 $this->showResizeImagesBox();
106 $this->elementEnd('div');
110 while ($album->fetch()) {
111 $this->elementStart('div', array('class' => 'photocontainer'));
112 $this->elementStart('a', array('href' => $album->getPageLink()));
113 $this->element('img', array('src' => $album->getThumbUri(),
114 'class' => 'albumingallery'));
115 $this->elementEnd('a');
116 $this->element('h3', array(), $album->album_name);
117 $this->elementEnd('div');
122 function showAlbum($album_id)
124 $album = GNUSocialPhotoAlbum::staticGet('album_id', $album_id);
129 $page = $_GET['pageid'];
130 if (!filter_var($page, FILTER_VALIDATE_INT)){
134 $photos = GNUsocialPhoto::getGalleryPage($page, $album->album_id, 9);
135 $this->elementStart('div', array('class' => 'galleryheader'));
137 $this->element('a', array('href' => $album->getPageLink() . '?pageid=' . ($page-1)), 'Previous page');
140 if (GNUsocialPhoto::getGalleryPage($page+1, $album->album_id, 9)) {
141 $this->element('a', array('href' => $album->getPageLink() . '?pageid=' . ($page+1) ), 'Next page');
145 //$this->element('a', array('href' => '#',
146 // 'onclick' => 'return increasePhotoSize()'), '+');
148 //$this->element('a', array('href' => '#',
149 // 'onclick' => 'return decreasePhotoSize()'), '-');
152 $this->showResizeImagesBox();
153 $this->elementEnd('div');
155 foreach ($photos as $photo) {
156 $this->elementStart('a', array('href' => $photo->getPageLink()));
157 $this->elementStart('div', array('class' => 'photocontainer'));
158 $this->element('img', array('src' => $photo->thumb_uri,
159 'class' => 'photoingallery'));
160 $this->element('div', array('class' => 'phototitle'), $photo->title);
161 $this->elementEnd('div');
162 $this->elementEnd('a');
168 function showContent()
170 if (!empty($this->albumid))
171 $this->showAlbum($this->albumid);