gnu-social/_darcs/tentative_pristine
Evan Prodromou 5d76234a60 reformat for phpcs
darcs-hash:20081221005837-84dde-07cd6bb27d5f601360a686538dd76f1dca9af3c4.gz
2008-12-20 19:58:37 -05:00

563 lines
19 KiB
Plaintext

hunk ./lib/gallery.php 2
-
-/*
+/**
hunk ./lib/gallery.php 20
-if (!defined('LACONICA')) { exit(1); }
+if (!defined('LACONICA')) {
+ exit(1);
+}
hunk ./lib/gallery.php 24
-require_once(INSTALLDIR.'/lib/profilelist.php');
+require_once INSTALLDIR.'/lib/profilelist.php';
hunk ./lib/gallery.php 26
-# 10x8
+// 10x8
hunk ./lib/gallery.php 30
-class GalleryAction extends Action {
+class GalleryAction extends Action
+{
+ function is_readonly()
+ {
+ return true;
+ }
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ // Post from the tag dropdown; redirect to a GET
+
+ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+ common_redirect($this->self_url(), 307);
+ }
+
+ $nickname = common_canonical_nickname($this->arg('nickname'));
hunk ./lib/gallery.php 49
- function is_readonly() {
- return true;
- }
+ $user = User::staticGet('nickname', $nickname);
hunk ./lib/gallery.php 51
- function handle($args) {
- parent::handle($args);
+ if (!$user) {
+ $this->no_such_user();
+ return;
+ }
hunk ./lib/gallery.php 56
- # Post from the tag dropdown; redirect to a GET
+ $profile = $user->getProfile();
hunk ./lib/gallery.php 58
- if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- common_redirect($this->self_url(), 307);
- }
+ if (!$profile) {
+ $this->server_error(_('User without matching profile in system.'));
+ return;
+ }
hunk ./lib/gallery.php 63
- $nickname = common_canonical_nickname($this->arg('nickname'));
- $user = User::staticGet('nickname', $nickname);
+ $page = $this->arg('page');
hunk ./lib/gallery.php 65
- if (!$user) {
- $this->no_such_user();
- return;
- }
+ if (!$page) {
+ $page = 1;
+ }
hunk ./lib/gallery.php 69
- $profile = $user->getProfile();
+ $display = $this->arg('display');
hunk ./lib/gallery.php 71
- if (!$profile) {
- $this->server_error(_('User without matching profile in system.'));
- return;
- }
+ if (!$display) {
+ $display = 'list';
+ }
hunk ./lib/gallery.php 75
- $page = $this->arg('page');
+ $tag = $this->arg('tag');
hunk ./lib/gallery.php 77
- if (!$page) {
- $page = 1;
- }
+ common_show_header($profile->nickname . ": " . $this->gallery_type(),
+ null, $profile,
+ array($this, 'show_top'));
hunk ./lib/gallery.php 81
- $display = $this->arg('display');
+ $this->display_links($profile, $page, $display);
+ $this->show_tags_dropdown($profile);
hunk ./lib/gallery.php 84
- if (!$display) {
- $display = 'list';
- }
+ $this->show_gallery($profile, $page, $display, $tag);
+ common_show_footer();
+ }
hunk ./lib/gallery.php 88
- $tag = $this->arg('tag');
+ function no_such_user()
+ {
+ $this->client_error(_('No such user.'));
+ }
hunk ./lib/gallery.php 93
- common_show_header($profile->nickname . ": " . $this->gallery_type(),
- NULL, $profile,
- array($this, 'show_top'));
+ function show_tags_dropdown($profile)
+ {
+ $tag = $this->trimmed('tag');
hunk ./lib/gallery.php 97
- $this->display_links($profile, $page, $display);
- $this->show_tags_dropdown($profile);
+ list($lst, $usr) = $this->fields();
hunk ./lib/gallery.php 99
- $this->show_gallery($profile, $page, $display, $tag);
- common_show_footer();
- }
+ $tags = $this->get_all_tags($profile, $lst, $usr);
hunk ./lib/gallery.php 101
- function no_such_user() {
- $this->client_error(_('No such user.'));
- }
+ $content = array();
hunk ./lib/gallery.php 103
- function show_tags_dropdown($profile) {
- $tag = $this->trimmed('tag');
- list($lst, $usr) = $this->fields();
- $tags = $this->get_all_tags($profile, $lst, $usr);
- $content = array();
- foreach ($tags as $t) {
- $content[$t] = $t;
- }
- if ($tags) {
- common_element_start('dl', array('id'=>'filter_tags'));
- common_element('dt', null, _('Filter tags'));
- common_element_start('dd');
- common_element_start('ul');
- common_element_start('li', array('id'=>'filter_tags_all', 'class'=>'child_1'));
- common_element('a', array('href' => common_local_url($this->trimmed('action'),
- array('nickname' => $profile->nickname))),
- _('All'));
- common_element_end('li');
- common_element_start('li', array('id'=>'filter_tags_item'));
- common_element_start('form', array('name' => 'bytag', 'id' => 'bytag', 'method' => 'post'));
- common_dropdown('tag', _('Tag'), $content,
- _('Choose a tag to narrow list'), FALSE, $tag);
- common_submit('go', _('Go'));
- common_element_end('form');
- common_element_end('li');
- common_element_end('ul');
- common_element_end('dd');
- common_element_end('dl');
- }
- }
+ foreach ($tags as $t) {
+ $content[$t] = $t;
+ }
+ if ($tags) {
+ common_element_start('dl', array('id'=>'filter_tags'));
+ common_element('dt', null, _('Filter tags'));
+ common_element_start('dd');
+ common_element_start('ul');
+ common_element_start('li', array('id' => 'filter_tags_all',
+ 'class' => 'child_1'));
+ common_element('a',
+ array('href' =>
+ common_local_url($this->trimmed('action'),
+ array('nickname' =>
+ $profile->nickname))),
+ _('All'));
+ common_element_end('li');
+ common_element_start('li', array('id'=>'filter_tags_item'));
+ common_element_start('form', array('name' => 'bytag',
+ 'id' => 'bytag',
+ 'method' => 'post'));
+ common_dropdown('tag', _('Tag'), $content,
+ _('Choose a tag to narrow list'), false, $tag);
+ common_submit('go', _('Go'));
+ common_element_end('form');
+ common_element_end('li');
+ common_element_end('ul');
+ common_element_end('dd');
+ common_element_end('dl');
+ }
+ }
hunk ./lib/gallery.php 135
- function show_top($profile) {
- common_element('div', 'instructions',
- $this->get_instructions($profile));
+ function show_top($profile)
+ {
+ common_element('div', 'instructions',
+ $this->get_instructions($profile));
hunk ./lib/gallery.php 140
- }
+ }
hunk ./lib/gallery.php 142
- function show_menu() {
- # action => array('prompt', 'title', $args)
- $action = $this->trimmed('action');
- $nickname = $this->trimmed('nickname');
- $menu =
- array('subscriptions' =>
- array( _('Subscriptions'),
- _('Subscriptions'),
- array('nickname' => $nickname)),
- 'subscribers' =>
- array(
- _('Subscribers'),
- _('Subscribers'),
- array('nickname' => $nickname)),
- );
- $this->nav_menu($menu);
- }
+ function show_menu()
+ {
+ // action => array('prompt', 'title', $args)
+ $action = $this->trimmed('action');
+ $nickname = $this->trimmed('nickname');
hunk ./lib/gallery.php 148
- function show_gallery($profile, $page, $display='list', $tag=NULL) {
+ $menu =
+ array('subscriptions' =>
+ array( _('Subscriptions'),
+ _('Subscriptions'),
+ array('nickname' => $nickname)),
+ 'subscribers' =>
+ array(
+ _('Subscribers'),
+ _('Subscribers'),
+ array('nickname' => $nickname)),
+ );
+ $this->nav_menu($menu);
+ }
hunk ./lib/gallery.php 162
- $other = new Profile();
+ function show_gallery($profile, $page, $display='list', $tag=null)
+ {
+ $other = new Profile();
hunk ./lib/gallery.php 166
- list($lst, $usr) = $this->fields();
+ list($lst, $usr) = $this->fields();
hunk ./lib/gallery.php 168
- $per_page = ($display == 'list') ? PROFILES_PER_PAGE : AVATARS_PER_PAGE;
+ $per_page = ($display == 'list') ? PROFILES_PER_PAGE : AVATARS_PER_PAGE;
hunk ./lib/gallery.php 170
- $offset = ($page-1)*$per_page;
- $limit = $per_page + 1;
+ $offset = ($page-1)*$per_page;
+ $limit = $per_page + 1;
hunk ./lib/gallery.php 173
- if (common_config('db','type') == 'pgsql') {
- $lim = ' LIMIT ' . $limit . ' OFFSET ' . $offset;
- } else {
- $lim = ' LIMIT ' . $offset . ', ' . $limit;
- }
+ if (common_config('db', 'type') == 'pgsql') {
+ $lim = ' LIMIT ' . $limit . ' OFFSET ' . $offset;
+ } else {
+ $lim = ' LIMIT ' . $offset . ', ' . $limit;
+ }
hunk ./lib/gallery.php 179
- # XXX: memcached results
- # FIXME: SQL injection on $tag
+ // XXX: memcached results
+ // FIXME: SQL injection on $tag
hunk ./lib/gallery.php 182
- $other->query('SELECT profile.* ' .
- 'FROM profile JOIN subscription ' .
- 'ON profile.id = subscription.' . $lst . ' ' .
- (($tag) ? 'JOIN profile_tag ON (profile.id = profile_tag.tagged AND subscription.'.$usr.'= profile_tag.tagger) ' : '') .
- 'WHERE ' . $usr . ' = ' . $profile->id . ' ' .
- 'AND subscriber != subscribed ' .
- (($tag) ? 'AND profile_tag.tag= "' . $tag . '" ': '') .
- 'ORDER BY subscription.created DESC, profile.id DESC ' .
- $lim);
+ $other->query('SELECT profile.* ' .
+ 'FROM profile JOIN subscription ' .
+ 'ON profile.id = subscription.' . $lst . ' ' .
+ (($tag) ? 'JOIN profile_tag ON (profile.id = profile_tag.tagged AND subscription.'.$usr.'= profile_tag.tagger) ' : '') .
+ 'WHERE ' . $usr . ' = ' . $profile->id . ' ' .
+ 'AND subscriber != subscribed ' .
+ (($tag) ? 'AND profile_tag.tag= "' . $tag . '" ': '') .
+ 'ORDER BY subscription.created DESC, profile.id DESC ' .
+ $lim);
hunk ./lib/gallery.php 192
- if ($display == 'list') {
+ if ($display == 'list') {
hunk ./lib/gallery.php 194
- $profile_list = new $cls($other, $profile, $this->trimmed('action'));
- $cnt = $profile_list->show_list();
- } else {
- $cnt = $this->icon_list($other);
- }
+ $profile_list = new $cls($other, $profile, $this->trimmed('action'));
+ $cnt = $profile_list->show_list();
+ } else {
+ $cnt = $this->icon_list($other);
+ }
hunk ./lib/gallery.php 200
- # For building the pagination URLs
+ // For building the pagination URLs
hunk ./lib/gallery.php 202
- $args = array('nickname' => $profile->nickname);
+ $args = array('nickname' => $profile->nickname);
hunk ./lib/gallery.php 204
- if ($display != 'list') {
- $args['display'] = $display;
- }
+ if ($display != 'list') {
+ $args['display'] = $display;
+ }
hunk ./lib/gallery.php 208
- common_pagination($page > 1,
- $cnt > $per_page,
- $page,
- $this->trimmed('action'),
- $args);
- }
+ common_pagination($page > 1,
+ $cnt > $per_page,
+ $page,
+ $this->trimmed('action'),
+ $args);
+ }
hunk ./lib/gallery.php 215
- function profile_list_class() {
+ function profile_list_class()
+ {
hunk ./lib/gallery.php 220
- function icon_list($other) {
+ function icon_list($other)
+ {
+ common_element_start('ul', $this->div_class());
hunk ./lib/gallery.php 224
- common_element_start('ul', $this->div_class());
+ $cnt = 0;
hunk ./lib/gallery.php 226
- $cnt = 0;
+ while ($other->fetch()) {
hunk ./lib/gallery.php 228
- while ($other->fetch()) {
+ $cnt++;
hunk ./lib/gallery.php 230
- $cnt++;
+ if ($cnt > AVATARS_PER_PAGE) {
+ break;
+ }
hunk ./lib/gallery.php 234
- if ($cnt > AVATARS_PER_PAGE) {
- break;
- }
+ common_element_start('li');
hunk ./lib/gallery.php 236
- common_element_start('li');
+ 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) ? common_avatar_display_url($avatar) :
+ common_default_avatar(AVATAR_STREAM_SIZE)),
+ 'width' => AVATAR_STREAM_SIZE,
+ 'height' => AVATAR_STREAM_SIZE,
+ 'class' => 'avatar stream',
+ 'alt' => ($other->fullname) ?
+ $other->fullname :
+ $other->nickname));
+ common_element_end('a');
hunk ./lib/gallery.php 254
- 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) ? common_avatar_display_url($avatar) :
- common_default_avatar(AVATAR_STREAM_SIZE)),
- 'width' => AVATAR_STREAM_SIZE,
- 'height' => AVATAR_STREAM_SIZE,
- 'class' => 'avatar stream',
- 'alt' => ($other->fullname) ?
- $other->fullname :
- $other->nickname));
- common_element_end('a');
+ // XXX: subscribe form here
hunk ./lib/gallery.php 256
- # XXX: subscribe form here
+ common_element_end('li');
+ }
hunk ./lib/gallery.php 259
- common_element_end('li');
- }
+ common_element_end('ul');
hunk ./lib/gallery.php 261
- common_element_end('ul');
-
- return $cnt;
- }
+ return $cnt;
+ }
hunk ./lib/gallery.php 264
- function gallery_type() {
- return NULL;
- }
+ function gallery_type()
+ {
+ return null;
+ }
hunk ./lib/gallery.php 269
- function get_instructions(&$profile) {
- return NULL;
- }
+ function get_instructions(&$profile)
+ {
+ return null;
+ }
hunk ./lib/gallery.php 274
- function fields() {
- return NULL;
- }
+ function fields()
+ {
+ return null;
+ }
hunk ./lib/gallery.php 279
- function div_class() {
- return '';
- }
+ function div_class()
+ {
+ return '';
+ }
hunk ./lib/gallery.php 284
- function display_links($profile, $page, $display) {
- $tag = $this->trimmed('tag');
+ function display_links($profile, $page, $display)
+ {
+ $tag = $this->trimmed('tag');
hunk ./lib/gallery.php 288
- common_element_start('dl', array('id'=>'subscriptions_nav'));
- common_element('dt', null, _('Subscriptions navigation'));
- common_element_start('dd');
- common_element_start('ul', array('class'=>'nav'));
+ common_element_start('dl', array('id'=>'subscriptions_nav'));
+ common_element('dt', null, _('Subscriptions navigation'));
+ common_element_start('dd');
+ common_element_start('ul', array('class'=>'nav'));
hunk ./lib/gallery.php 293
- switch ($display) {
- case 'list':
- common_element('li', array('class'=>'child_1'), _('List'));
- common_element_start('li');
- $url_args = array('display' => 'icons',
- 'nickname' => $profile->nickname,
- 'page' => 1 + floor((($page - 1) * PROFILES_PER_PAGE) / AVATARS_PER_PAGE));
- if ($tag) {
- $url_args['tag'] = $tag;
- }
- $url = common_local_url($this->trimmed('action'), $url_args);
- common_element('a', array('href' => $url),
- _('Icons'));
- common_element_end('li');
- break;
- default:
- common_element_start('li', array('class'=>'child_1'));
- $url_args = array('nickname' => $profile->nickname,
- 'page' => 1 + floor((($page - 1) * AVATARS_PER_PAGE) / PROFILES_PER_PAGE));
- if ($tag) {
- $url_args['tag'] = $tag;
- }
- $url = common_local_url($this->trimmed('action'), $url_args);
- common_element('a', array('href' => $url),
- _('List'));
- common_element_end('li');
- common_element('li', NULL, _('Icons'));
- break;
- }
+ switch ($display) {
+ case 'list':
+ common_element('li', array('class'=>'child_1'), _('List'));
+ common_element_start('li');
+ $url_args = array('display' => 'icons',
+ 'nickname' => $profile->nickname,
+ 'page' => 1 + floor((($page - 1) * PROFILES_PER_PAGE) / AVATARS_PER_PAGE));
+ if ($tag) {
+ $url_args['tag'] = $tag;
+ }
+ $url = common_local_url($this->trimmed('action'), $url_args);
+ common_element('a', array('href' => $url),
+ _('Icons'));
+ common_element_end('li');
+ break;
+ default:
+ common_element_start('li', array('class'=>'child_1'));
+ $url_args = array('nickname' => $profile->nickname,
+ 'page' => 1 + floor((($page - 1) * AVATARS_PER_PAGE) / PROFILES_PER_PAGE));
+ if ($tag) {
+ $url_args['tag'] = $tag;
+ }
+ $url = common_local_url($this->trimmed('action'), $url_args);
+ common_element('a', array('href' => $url),
+ _('List'));
+ common_element_end('li');
+ common_element('li', null, _('Icons'));
+ break;
+ }
hunk ./lib/gallery.php 323
- common_element_end('ul');
- common_element_end('dd');
- common_element_end('dl');
- }
+ common_element_end('ul');
+ common_element_end('dd');
+ common_element_end('dl');
+ }
hunk ./lib/gallery.php 328
- # Get list of tags we tagged other users with
+ // Get list of tags we tagged other users with
hunk ./lib/gallery.php 330
- function get_all_tags($profile, $lst, $usr) {
- $profile_tag = new Notice_tag();
- $profile_tag->query('SELECT DISTINCT(tag) ' .
- 'FROM profile_tag, subscription ' .
- 'WHERE tagger = ' . $profile->id . ' ' .
- 'AND ' . $usr . ' = ' . $profile->id . ' ' .
- 'AND ' . $lst . ' = tagged ' .
- 'AND tagger != tagged');
- $tags = array();
- while ($profile_tag->fetch()) {
- $tags[] = $profile_tag->tag;
- }
- $profile_tag->free();
- return $tags;
- }
+ function get_all_tags($profile, $lst, $usr)
+ {
+ $profile_tag = new Notice_tag();
+ $profile_tag->query('SELECT DISTINCT(tag) ' .
+ 'FROM profile_tag, subscription ' .
+ 'WHERE tagger = ' . $profile->id . ' ' .
+ 'AND ' . $usr . ' = ' . $profile->id . ' ' .
+ 'AND ' . $lst . ' = tagged ' .
+ 'AND tagger != tagged');
+ $tags = array();
+ while ($profile_tag->fetch()) {
+ $tags[] = $profile_tag->tag;
+ }
+ $profile_tag->free();
+ return $tags;
+ }