3 * Laconica - a distributed open-source microblogging tool
4 * Copyright (C) 2008, Controlez-Vous, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('LACONICA')) { exit(1); }
24 define('AVATARS_PER_PAGE', 80);
26 class GalleryAction extends Action {
28 function handle($args) {
29 parent::handle($args);
30 $nickname = $this->arg('nickname');
31 $profile = Profile::staticGet('nickname', $nickname);
33 $this->no_such_user();
36 $user = User::staticGet($profile->id);
38 $this->no_such_user();
41 $page = $this->arg('page');
45 common_show_header($profile->nickname . ": " . $this->gallery_type(),
47 array($this, 'show_top'));
48 $this->show_gallery($profile, $page);
52 function no_such_user() {
53 $this->client_error(_t('No such user.'));
56 function show_top($profile) {
57 common_element('p', 'instructions',
58 $this->get_instructions($profile));
61 function show_gallery($profile, $page) {
63 $subs = new Subscription();
65 $this->define_subs($subs, $profile);
67 $subs->orderBy('created DESC');
69 # We ask for an extra one to know if we need to do another page
71 $subs->limit((($page-1)*AVATARS_PER_PAGE), AVATARS_PER_PAGE + 1);
73 $subs_count = $subs->find();
75 if ($subs_count == 0) {
76 common_element('p', _t('Nobody to show!'));
80 common_element_start('ul', $this->div_class());
82 for ($idx = 0; $idx < min($subs_count, AVATARS_PER_PAGE); $idx++) {
84 $result = $subs->fetch();
87 common_debug('Ran out of subscribers too early.', __FILE__);
91 $other = Profile::staticGet($this->get_other($subs));
93 common_element_start('li');
95 common_element_start('a', array('title' => ($other->fullname) ?
98 'href' => $other->profileurl,
99 'class' => 'subscription'));
100 $avatar = $other->getAvatar(AVATAR_STREAM_SIZE);
101 common_element('img',
103 (($avatar) ? common_avatar_display_url($avatar) :
104 common_default_avatar(AVATAR_STREAM_SIZE)),
105 'width' => AVATAR_STREAM_SIZE,
106 'height' => AVATAR_STREAM_SIZE,
107 'class' => 'avatar stream',
108 'alt' => ($other->fullname) ?
111 common_element_end('a');
113 # XXX: subscribe form here
115 common_element_end('li');
118 common_element_end('ul');
120 common_pagination($page > 1,
121 $subs_count > AVATARS_PER_PAGE,
123 $this->trimmed('action'),
124 array('nickname' => $profile->nickname));
127 function gallery_type() {
131 function get_instructions(&$profile) {
135 function define_subs(&$subs, &$profile) {
139 function get_other(&$subs) {
143 function div_class() {