X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fgallery.php;h=4f3c18ff91466135384f86e0b8a7a30df2c339fa;hb=f50bc7044552955af29b2a7426bdd72bfdf9ca8f;hp=6d21b8310f49c2c53d0a4ba2124a2510f9378171;hpb=aeaf75138cf8be42d2e3935b708e1d24a97bd0a0;p=quix0rs-gnu-social.git diff --git a/lib/gallery.php b/lib/gallery.php index 6d21b8310f..4f3c18ff91 100644 --- a/lib/gallery.php +++ b/lib/gallery.php @@ -19,7 +19,8 @@ if (!defined('LACONICA')) { exit(1); } -define('AVATARS_PER_ROW', 8); +# 10x8 + define('AVATARS_PER_PAGE', 80); class GalleryAction extends Action { @@ -37,7 +38,10 @@ class GalleryAction extends Action { $this->no_such_user(); return; } - $page = $this->arg('page') || 1; + $page = $this->arg('page'); + if (!$page) { + $page = 1; + } common_show_header($profile->nickname . ": " . $this->gallery_type(), NULL, $profile, array($this, 'show_top')); @@ -46,20 +50,20 @@ class GalleryAction extends Action { } function no_such_user() { - $this->client_error(_t('No such user.')); + $this->client_error(_('No such user.')); } - + function show_top($profile) { - common_element('p', 'instructions', + common_element('div', 'instructions', $this->get_instructions($profile)); } - + function show_gallery($profile, $page) { $subs = new Subscription(); - + $this->define_subs($subs, $profile); - + $subs->orderBy('created DESC'); # We ask for an extra one to know if we need to do another page @@ -68,25 +72,35 @@ class GalleryAction extends Action { $subs_count = $subs->find(); - common_element_start('div', $this->div_class()); + if ($subs_count == 0) { + common_element('p', _('Nobody to show!')); + return; + } + + common_element_start('ul', $this->div_class()); + + for ($idx = 0; $idx < min($subs_count, AVATARS_PER_PAGE); $idx++) { + + $result = $subs->fetch(); - $idx = 0; + if (!$result) { + common_debug('Ran out of subscribers too early.', __FILE__); + break; + } + + $other = Profile::staticGet($this->get_other($subs)); - while ($subs->fetch()) { - - $idx++; + common_element_start('li'); - $other = Profile::staticGet($subs->subscribed); - common_element_start('a', array('title' => ($other->fullname) ? $other->fullname : $other->nickname, 'href' => $other->profileurl, 'class' => 'subscription')); $avatar = $other->getAvatar(AVATAR_STREAM_SIZE); - common_element('img', - array('src' => - (($avatar) ? $avatar->url : + common_element('img', + array('src' => + (($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE)), 'width' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE, @@ -98,20 +112,18 @@ class GalleryAction extends Action { # XXX: subscribe form here - if ($idx == AVATARS_PER_PAGE) { - break; - } + common_element_end('li'); } - common_element_end('div'); - - common_pagination($page > 1, + common_element_end('ul'); + + common_pagination($page > 1, $subs_count > AVATARS_PER_PAGE, - $page, - $this->trimmed('action'), + $page, + $this->trimmed('action'), array('nickname' => $profile->nickname)); } - + function gallery_type() { return NULL; } @@ -123,7 +135,11 @@ class GalleryAction extends Action { function define_subs(&$subs, &$profile) { return; } - + + function get_other(&$subs) { + return NULL; + } + function div_class() { return ''; }