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 is_readonly() {
32 function handle($args) {
33 parent::handle($args);
34 $nickname = $this->arg('nickname');
35 $profile = Profile::staticGet('nickname', $nickname);
37 $this->no_such_user();
40 $user = User::staticGet($profile->id);
42 $this->no_such_user();
45 $page = $this->arg('page');
49 common_show_header($profile->nickname . ": " . $this->gallery_type(),
51 array($this, 'show_top'));
52 $this->show_gallery($profile, $page);
56 function no_such_user() {
57 $this->client_error(_('No such user.'));
60 function show_top($profile) {
61 common_element('div', 'instructions',
62 $this->get_instructions($profile));
65 function show_gallery($profile, $page) {
67 $subs = new Subscription();
69 $this->define_subs($subs, $profile);
71 $subs->orderBy('created DESC');
73 # We ask for an extra one to know if we need to do another page
75 $subs->limit((($page-1)*AVATARS_PER_PAGE), AVATARS_PER_PAGE + 1);
77 $subs_count = $subs->find();
79 if ($subs_count == 0) {
80 common_element('p', _('Nobody to show!'));
84 common_element_start('ul', $this->div_class());
86 for ($idx = 0; $idx < min($subs_count, AVATARS_PER_PAGE); $idx++) {
88 $result = $subs->fetch();
91 common_debug('Ran out of subscribers too early.', __FILE__);
95 $other = Profile::staticGet($this->get_other($subs));
97 common_element_start('li');
99 common_element_start('a', array('title' => ($other->fullname) ?
102 'href' => $other->profileurl,
103 'class' => 'subscription'));
104 $avatar = $other->getAvatar(AVATAR_STREAM_SIZE);
105 common_element('img',
107 (($avatar) ? common_avatar_display_url($avatar) :
108 common_default_avatar(AVATAR_STREAM_SIZE)),
109 'width' => AVATAR_STREAM_SIZE,
110 'height' => AVATAR_STREAM_SIZE,
111 'class' => 'avatar stream',
112 'alt' => ($other->fullname) ?
115 common_element_end('a');
117 # XXX: subscribe form here
119 common_element_end('li');
122 common_element_end('ul');
124 common_pagination($page > 1,
125 $subs_count > AVATARS_PER_PAGE,
127 $this->trimmed('action'),
128 array('nickname' => $profile->nickname));
131 function gallery_type() {
135 function get_instructions(&$profile) {
139 function define_subs(&$subs, &$profile) {
143 function get_other(&$subs) {
147 function div_class() {