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); }
22 define('AVATARS_PER_ROW', 8);
23 define('AVATARS_PER_PAGE', 80);
25 class GalleryAction extends Action {
27 function handle($args) {
28 parent::handle($args);
29 $nickname = $this->arg('nickname');
30 $profile = Profile::staticGet('nickname', $nickname);
32 $this->no_such_user();
35 $user = User::staticGet($profile->id);
37 $this->no_such_user();
40 $page = $this->arg('page') || 1;
41 common_show_header($profile->nickname . ": " . $this->gallery_type(),
43 array($this, 'show_top'));
44 $this->show_gallery($profile, $page);
48 function no_such_user() {
49 $this->client_error(_t('No such user.'));
52 function show_top($profile) {
53 common_element('p', 'instructions',
54 $this->get_instructions($profile));
57 function show_gallery($profile, $page) {
59 $subs = new Subscription();
61 $this->define_subs($subs, $profile);
63 $subs->orderBy('created DESC');
65 # We ask for an extra one to know if we need to do another page
67 $subs->limit((($page-1)*AVATARS_PER_PAGE), AVATARS_PER_PAGE + 1);
69 $subs_count = $subs->find();
71 if ($subs_count == 0) {
72 common_element('p', _t('Nobody to show!'));
76 common_element_start('ul', $this->div_class());
78 for ($idx = 0; $idx < min($subs_count, AVATARS_PER_PAGE); $idx++) {
80 $result = $subs->fetch();
83 common_debug('Ran out of subscribers too early.', __FILE__);
87 $other = Profile::staticGet($this->get_other($subs));
89 common_element_start('li');
91 common_element_start('a', array('title' => ($other->fullname) ?
94 'href' => $other->profileurl,
95 'class' => 'subscription'));
96 $avatar = $other->getAvatar(AVATAR_STREAM_SIZE);
99 (($avatar) ? $avatar->url :
100 common_default_avatar(AVATAR_STREAM_SIZE)),
101 'width' => AVATAR_STREAM_SIZE,
102 'height' => AVATAR_STREAM_SIZE,
103 'class' => 'avatar stream',
104 'alt' => ($other->fullname) ?
107 common_element_end('a');
109 # XXX: subscribe form here
111 common_element_end('li');
114 common_element_end('ul');
116 common_pagination($page > 1,
117 $subs_count > AVATARS_PER_PAGE,
119 $this->trimmed('action'),
120 array('nickname' => $profile->nickname));
123 function gallery_type() {
127 function get_instructions(&$profile) {
131 function define_subs(&$subs, &$profile) {
135 function get_other(&$subs) {
139 function div_class() {