]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
reformat for phpcs
authorEvan Prodromou <evan@prodromou.name>
Sun, 21 Dec 2008 00:58:37 +0000 (19:58 -0500)
committerEvan Prodromou <evan@prodromou.name>
Sun, 21 Dec 2008 00:58:37 +0000 (19:58 -0500)
darcs-hash:20081221005837-84dde-07cd6bb27d5f601360a686538dd76f1dca9af3c4.gz

_darcs/inventory
_darcs/patches/20081221005837-84dde-07cd6bb27d5f601360a686538dd76f1dca9af3c4.gz [new file with mode: 0644]
_darcs/pristine/lib/gallery.php
_darcs/tentative_pristine
lib/gallery.php

index 0ee79eeaa284fed9eae7ba78c40d04a744b15c2b..3fba388223097d0814fe1e029256e9ee7f4dacee 100644 (file)
@@ -27,4 +27,6 @@ Evan Prodromou <evan@prodromou.name>**20081221003016]
 [some modifications to assuage phpcs
 Evan Prodromou <evan@prodromou.name>**20081221003955] 
 [reformat lib/daemon.php for phpcs
-Evan Prodromou <evan@prodromou.name>**20081221004607] 
\ No newline at end of file
+Evan Prodromou <evan@prodromou.name>**20081221004607] 
+[reformat for phpcs
+Evan Prodromou <evan@prodromou.name>**20081221005837] 
\ No newline at end of file
diff --git a/_darcs/patches/20081221005837-84dde-07cd6bb27d5f601360a686538dd76f1dca9af3c4.gz b/_darcs/patches/20081221005837-84dde-07cd6bb27d5f601360a686538dd76f1dca9af3c4.gz
new file mode 100644 (file)
index 0000000..34fd52d
Binary files /dev/null and b/_darcs/patches/20081221005837-84dde-07cd6bb27d5f601360a686538dd76f1dca9af3c4.gz differ
index 0dd351bab5b788d9f15e044ae506f4de04dc67a8..34b58518c63e1815cf9f8db6c79fadd0bd07c441 100644 (file)
@@ -1,6 +1,5 @@
 <?php
-
-/*
+/**
  * Laconica - a distributed open-source microblogging tool
  * Copyright (C) 2008, Controlez-Vous, Inc.
  *
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('LACONICA')) { exit(1); }
+if (!defined('LACONICA')) {
+    exit(1);
+}
 
-require_once(INSTALLDIR.'/lib/profilelist.php');
+require_once INSTALLDIR.'/lib/profilelist.php';
 
-# 10x8
+// 10x8
 
 define('AVATARS_PER_PAGE', 80);
 
-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'));
-               $user = User::staticGet('nickname', $nickname);
-
-               if (!$user) {
-                       $this->no_such_user();
-                       return;
-               }
-
-               $profile = $user->getProfile();
-
-               if (!$profile) {
-                       $this->server_error(_('User without matching profile in system.'));
-                       return;
-               }
-
-               $page = $this->arg('page');
-
-               if (!$page) {
-                       $page = 1;
-               }
-
-               $display = $this->arg('display');
-
-               if (!$display) {
-                       $display = 'list';
-               }
-
-               $tag = $this->arg('tag');
-
-               common_show_header($profile->nickname . ": " . $this->gallery_type(),
-                                                  NULL, $profile,
-                                                  array($this, 'show_top'));
-
-               $this->display_links($profile, $page, $display);
-               $this->show_tags_dropdown($profile);
-
-               $this->show_gallery($profile, $page, $display, $tag);
-               common_show_footer();
-       }
-
-       function no_such_user() {
-               $this->client_error(_('No such user.'));
-       }
-
-       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');
-               }
-       }
-
-       function show_top($profile) {
-               common_element('div', 'instructions',
-                                          $this->get_instructions($profile));
+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'));
+
+        $user = User::staticGet('nickname', $nickname);
+
+        if (!$user) {
+            $this->no_such_user();
+            return;
+        }
+
+        $profile = $user->getProfile();
+
+        if (!$profile) {
+            $this->server_error(_('User without matching profile in system.'));
+            return;
+        }
+
+        $page = $this->arg('page');
+
+        if (!$page) {
+            $page = 1;
+        }
+
+        $display = $this->arg('display');
+
+        if (!$display) {
+            $display = 'list';
+        }
+
+        $tag = $this->arg('tag');
+
+        common_show_header($profile->nickname . ": " . $this->gallery_type(),
+                           null, $profile,
+                           array($this, 'show_top'));
+
+        $this->display_links($profile, $page, $display);
+        $this->show_tags_dropdown($profile);
+
+        $this->show_gallery($profile, $page, $display, $tag);
+        common_show_footer();
+    }
+
+    function no_such_user()
+    {
+        $this->client_error(_('No such user.'));
+    }
+
+    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');
+        }
+    }
+
+    function show_top($profile)
+    {
+        common_element('div', 'instructions',
+                       $this->get_instructions($profile));
         $this->show_menu();
-       }
-
-    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_gallery($profile, $page, $display='list', $tag=NULL) {
+    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);
+    }
 
-               $other = new Profile();
+    function show_gallery($profile, $page, $display='list', $tag=null)
+    {
+        $other = new Profile();
 
-               list($lst, $usr) = $this->fields();
+        list($lst, $usr) = $this->fields();
 
-               $per_page = ($display == 'list') ? PROFILES_PER_PAGE : AVATARS_PER_PAGE;
+        $per_page = ($display == 'list') ? PROFILES_PER_PAGE : AVATARS_PER_PAGE;
 
-               $offset = ($page-1)*$per_page;
-               $limit = $per_page + 1;
+        $offset = ($page-1)*$per_page;
+        $limit = $per_page + 1;
 
-               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;
+        }
 
-               # XXX: memcached results
-               # FIXME: SQL injection on $tag
+        // XXX: memcached results
+        // FIXME: SQL injection on $tag
 
-               $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);
 
-               if ($display == 'list') {
+        if ($display == 'list') {
             $cls = $this->profile_list_class();
-                       $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);
+        }
 
-               # For building the pagination URLs
+        // For building the pagination URLs
 
-               $args = array('nickname' => $profile->nickname);
+        $args = array('nickname' => $profile->nickname);
 
-               if ($display != 'list') {
-                       $args['display'] = $display;
-               }
+        if ($display != 'list') {
+            $args['display'] = $display;
+        }
 
-               common_pagination($page > 1,
-                                                 $cnt > $per_page,
-                                                 $page,
-                                                 $this->trimmed('action'),
-                                                 $args);
-       }
+        common_pagination($page > 1,
+                          $cnt > $per_page,
+                          $page,
+                          $this->trimmed('action'),
+                          $args);
+    }
 
-    function profile_list_class() {
+    function profile_list_class()
+    {
         return 'ProfileList';
     }
 
-       function icon_list($other) {
-
-               common_element_start('ul', $this->div_class());
-
-               $cnt = 0;
-
-               while ($other->fetch()) {
-
-                       $cnt++;
-
-                       if ($cnt > AVATARS_PER_PAGE) {
-                               break;
-                       }
-
-                       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');
-
-                       # XXX: subscribe form here
-
-                       common_element_end('li');
-               }
-
-               common_element_end('ul');
-
-               return $cnt;
-       }
-
-       function gallery_type() {
-               return NULL;
-       }
-
-       function get_instructions(&$profile) {
-               return NULL;
-       }
-
-       function fields() {
-               return NULL;
-       }
-
-       function div_class() {
-               return '';
-       }
-
-       function display_links($profile, $page, $display) {
-               $tag = $this->trimmed('tag');
-
-               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'));
-
-               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;
-               }
-
-               common_element_end('ul');
-               common_element_end('dd');
-               common_element_end('dl');
-       }
-
-       # Get list of tags we tagged other users with
-
-       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 icon_list($other)
+    {
+        common_element_start('ul', $this->div_class());
+
+        $cnt = 0;
+
+        while ($other->fetch()) {
+
+            $cnt++;
+
+            if ($cnt > AVATARS_PER_PAGE) {
+                break;
+            }
+
+            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');
+
+            // XXX: subscribe form here
+
+            common_element_end('li');
+        }
+
+        common_element_end('ul');
+
+        return $cnt;
+    }
+
+    function gallery_type()
+    {
+        return null;
+    }
+
+    function get_instructions(&$profile)
+    {
+        return null;
+    }
+
+    function fields()
+    {
+        return null;
+    }
+
+    function div_class()
+    {
+        return '';
+    }
+
+    function display_links($profile, $page, $display)
+    {
+        $tag = $this->trimmed('tag');
+
+        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'));
+
+        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;
+        }
+
+        common_element_end('ul');
+        common_element_end('dd');
+        common_element_end('dl');
+    }
+
+    // Get list of tags we tagged other users with
+
+    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;
+    }
 }
\ No newline at end of file
index 73c44f1dc6d87ecb6536e66bc7fec0f91afc2687..4e6b1fca93ade0987af12af9c9c5669c4034f14f 100644 (file)
-hunk ./lib/daemon.php 2
+hunk ./lib/gallery.php 2
+-
 -/*
 +/**
-hunk ./lib/daemon.php 20
+hunk ./lib/gallery.php 20
 -if (!defined('LACONICA')) { exit(1); }
 +if (!defined('LACONICA')) {
 +    exit(1);
 +}
-hunk ./lib/daemon.php 24
--class Daemon {
-+class Daemon
+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 name()
++    function is_readonly()
 +    {
-+        return null;
++        return true;
 +    }
-hunk ./lib/daemon.php 31
--      function name() {
--              return NULL;
++
++    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;
 -      }
--      
--      function background() {
--              $pid = pcntl_fork();
--              if ($pid < 0) { # error
--                      common_log(LOG_ERR, "Could not fork.");
--                      return false;
--              } else if ($pid > 0) { # parent
--                      common_log(LOG_INFO, "Successfully forked.");
--                      exit(0);
--              } else { # child
--                      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);
 -              }
--      }
-+    function background()
-+    {
-+        $pid = pcntl_fork();
-+        if ($pid < 0) { // error
-+            common_log(LOG_ERR, "Could not fork.");
-+            return false;
-+        } else if ($pid > 0) { // parent
-+            common_log(LOG_INFO, "Successfully forked.");
-+            exit(0);
-+        } else { // child
-+            return true;
++        if (!$profile) {
++            $this->server_error(_('User without matching profile in system.'));
++            return;
 +        }
-+    }
-hunk ./lib/daemon.php 45
--      function alreadyRunning() {
-+    function alreadyRunning()
-+    {
-+        $pidfilename = $this->pidFilename();
-hunk ./lib/daemon.php 49
--              $pidfilename = $this->pidFilename();
-+        if (!$pidfilename) {
-+            return false;
+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/daemon.php 53
--              if (!$pidfilename) {
--                      return false;
+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 (!file_exists($pidfilename)) {
--                      return false;
++        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;
 -              }
--              $contents = file_get_contents($pidfilename);
--              if (posix_kill(trim($contents),0)) {
--                      return true;
--              } else {
--                      return false;
++        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.'));
 -      }
--      
--      function writePidFile() {
--              $pidfilename = $this->pidFilename();
--              
--              if (!$pidfilename) {
--                      return false;
++        $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');
 -              }
--              
--          return file_put_contents($pidfilename, posix_getpid() . "\n");
 -      }
-+        if (!file_exists($pidfilename)) {
-+            return false;
++        foreach ($tags as $t) {
++            $content[$t] = $t;
 +        }
-+        $contents = file_get_contents($pidfilename);
-+        if (posix_kill(trim($contents), 0)) {
-+            return true;
-+        } else {
-+            return false;
++        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/daemon.php 64
--      function clearPidFile() {
--              $pidfilename = $this->pidFilename();
--              if (!$pidfilename) {
--                  return false;
--              }
--              return unlink($pidfilename);
+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
 -      }
--      
--      function pidFilename() {
--              $piddir = common_config('daemon', 'piddir');
--              if (!$piddir) {
--                      return NULL;
--              }
--              $name = $this->name();
--              if (!$name) {
--                      return NULL;
--              }
--              return $piddir . '/' . $name . '.pid';
++    }
+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 writePidFile()
++    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)
 +    {
-+        $pidfilename = $this->pidFilename();
-hunk ./lib/daemon.php 68
--      function changeUser() {
-+        if (!$pidfilename) {
-+            return false;
++        $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/daemon.php 72
--              $username = common_config('daemon', 'user');
--              
--              if ($username) {
--                      $user_info = posix_getpwnam($username);
--                      if (!$user_info) {
--                              common_log(LOG_WARNING, 'Ignoring unknown user for daemon: ' . $username);
--                      } else {
--                              common_log(LOG_INFO, "Setting user to " . $username);
--                              posix_setuid($user_info['uid']);
--                      }
+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);
 -              }
-+        return file_put_contents($pidfilename, posix_getpid() . "\n");
++            $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/daemon.php 75
--              $groupname = common_config('daemon', 'group');
--              
--              if ($groupname) {
--                      $group_info = posix_getgrnam($groupname);
--                      if (!$group_info) {
--                              common_log(LOG_WARNING, 'Ignoring unknown group for daemon: ' . $groupname);
--                      } else {
--                              common_log(LOG_INFO, "Setting group to " . $groupname);
--                              posix_setgid($group_info['gid']);
+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;
 -      }
--      
--      function runOnce() {
--              if ($this->alreadyRunning()) {
--                      common_log(LOG_INFO, $this->name() . ' already running. Exiting.');
--                      exit(0);
--              }
--              if ($this->background()) {
--                      $this->writePidFile();
--                      $this->changeUser();
--                      $this->run();
--                      $this->clearPidFile();
--              }
++        return $cnt;
++    }
+hunk ./lib/gallery.php 264
+-      function gallery_type() {
+-              return NULL;
 -      }
--      
--      function run() {
--              return true;
++    function gallery_type()
++    {
++        return null;
++    }
+hunk ./lib/gallery.php 269
+-      function get_instructions(&$profile) {
+-              return NULL;
 -      }
-+    function clearPidFile()
++    function get_instructions(&$profile)
 +    {
-+        $pidfilename = $this->pidFilename();
-+        if (!$pidfilename) {
-+            return false;
-+        }
-+        return unlink($pidfilename);
++        return null;
 +    }
-+
-+    function pidFilename()
+hunk ./lib/gallery.php 274
+-      function fields() {
+-              return NULL;
+-      }
++    function fields()
 +    {
-+        $piddir = common_config('daemon', 'piddir');
-+        if (!$piddir) {
-+            return null;
-+        }
-+        $name = $this->name();
-+        if (!$name) {
-+            return null;
-+        }
-+        return $piddir . '/' . $name . '.pid';
++        return null;
 +    }
-+
-+    function changeUser()
+hunk ./lib/gallery.php 279
+-      function div_class() {
+-              return '';
+-      }
++    function div_class()
 +    {
-+        $username = common_config('daemon', 'user');
-+
-+        if ($username) {
-+            $user_info = posix_getpwnam($username);
-+            if (!$user_info) {
-+                common_log(LOG_WARNING,
-+                           'Ignoring unknown user for daemon: ' . $username);
-+            } else {
-+                common_log(LOG_INFO, "Setting user to " . $username);
-+                posix_setuid($user_info['uid']);
++        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;
 +            }
-+        }
-+
-+        $groupname = common_config('daemon', 'group');
-+
-+        if ($groupname) {
-+            $group_info = posix_getgrnam($groupname);
-+            if (!$group_info) {
-+                common_log(LOG_WARNING,
-+                           'Ignoring unknown group for daemon: ' . $groupname);
-+            } else {
-+                common_log(LOG_INFO, "Setting group to " . $groupname);
-+                posix_setgid($group_info['gid']);
++            $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');
 +    }
-+
-+    function runOnce()
+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)
 +    {
-+        if ($this->alreadyRunning()) {
-+            common_log(LOG_INFO, $this->name() . ' already running. Exiting.');
-+            exit(0);
++        $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;
 +        }
-+        if ($this->background()) {
-+            $this->writePidFile();
-+            $this->changeUser();
-+            $this->run();
-+            $this->clearPidFile();
-+        }
-+    }
-+
-+    function run()
-+    {
-+        return true;
++        $profile_tag->free();
++        return $tags;
 +    }
index 0dd351bab5b788d9f15e044ae506f4de04dc67a8..34b58518c63e1815cf9f8db6c79fadd0bd07c441 100644 (file)
@@ -1,6 +1,5 @@
 <?php
-
-/*
+/**
  * Laconica - a distributed open-source microblogging tool
  * Copyright (C) 2008, Controlez-Vous, Inc.
  *
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('LACONICA')) { exit(1); }
+if (!defined('LACONICA')) {
+    exit(1);
+}
 
-require_once(INSTALLDIR.'/lib/profilelist.php');
+require_once INSTALLDIR.'/lib/profilelist.php';
 
-# 10x8
+// 10x8
 
 define('AVATARS_PER_PAGE', 80);
 
-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'));
-               $user = User::staticGet('nickname', $nickname);
-
-               if (!$user) {
-                       $this->no_such_user();
-                       return;
-               }
-
-               $profile = $user->getProfile();
-
-               if (!$profile) {
-                       $this->server_error(_('User without matching profile in system.'));
-                       return;
-               }
-
-               $page = $this->arg('page');
-
-               if (!$page) {
-                       $page = 1;
-               }
-
-               $display = $this->arg('display');
-
-               if (!$display) {
-                       $display = 'list';
-               }
-
-               $tag = $this->arg('tag');
-
-               common_show_header($profile->nickname . ": " . $this->gallery_type(),
-                                                  NULL, $profile,
-                                                  array($this, 'show_top'));
-
-               $this->display_links($profile, $page, $display);
-               $this->show_tags_dropdown($profile);
-
-               $this->show_gallery($profile, $page, $display, $tag);
-               common_show_footer();
-       }
-
-       function no_such_user() {
-               $this->client_error(_('No such user.'));
-       }
-
-       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');
-               }
-       }
-
-       function show_top($profile) {
-               common_element('div', 'instructions',
-                                          $this->get_instructions($profile));
+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'));
+
+        $user = User::staticGet('nickname', $nickname);
+
+        if (!$user) {
+            $this->no_such_user();
+            return;
+        }
+
+        $profile = $user->getProfile();
+
+        if (!$profile) {
+            $this->server_error(_('User without matching profile in system.'));
+            return;
+        }
+
+        $page = $this->arg('page');
+
+        if (!$page) {
+            $page = 1;
+        }
+
+        $display = $this->arg('display');
+
+        if (!$display) {
+            $display = 'list';
+        }
+
+        $tag = $this->arg('tag');
+
+        common_show_header($profile->nickname . ": " . $this->gallery_type(),
+                           null, $profile,
+                           array($this, 'show_top'));
+
+        $this->display_links($profile, $page, $display);
+        $this->show_tags_dropdown($profile);
+
+        $this->show_gallery($profile, $page, $display, $tag);
+        common_show_footer();
+    }
+
+    function no_such_user()
+    {
+        $this->client_error(_('No such user.'));
+    }
+
+    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');
+        }
+    }
+
+    function show_top($profile)
+    {
+        common_element('div', 'instructions',
+                       $this->get_instructions($profile));
         $this->show_menu();
-       }
-
-    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_gallery($profile, $page, $display='list', $tag=NULL) {
+    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);
+    }
 
-               $other = new Profile();
+    function show_gallery($profile, $page, $display='list', $tag=null)
+    {
+        $other = new Profile();
 
-               list($lst, $usr) = $this->fields();
+        list($lst, $usr) = $this->fields();
 
-               $per_page = ($display == 'list') ? PROFILES_PER_PAGE : AVATARS_PER_PAGE;
+        $per_page = ($display == 'list') ? PROFILES_PER_PAGE : AVATARS_PER_PAGE;
 
-               $offset = ($page-1)*$per_page;
-               $limit = $per_page + 1;
+        $offset = ($page-1)*$per_page;
+        $limit = $per_page + 1;
 
-               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;
+        }
 
-               # XXX: memcached results
-               # FIXME: SQL injection on $tag
+        // XXX: memcached results
+        // FIXME: SQL injection on $tag
 
-               $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);
 
-               if ($display == 'list') {
+        if ($display == 'list') {
             $cls = $this->profile_list_class();
-                       $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);
+        }
 
-               # For building the pagination URLs
+        // For building the pagination URLs
 
-               $args = array('nickname' => $profile->nickname);
+        $args = array('nickname' => $profile->nickname);
 
-               if ($display != 'list') {
-                       $args['display'] = $display;
-               }
+        if ($display != 'list') {
+            $args['display'] = $display;
+        }
 
-               common_pagination($page > 1,
-                                                 $cnt > $per_page,
-                                                 $page,
-                                                 $this->trimmed('action'),
-                                                 $args);
-       }
+        common_pagination($page > 1,
+                          $cnt > $per_page,
+                          $page,
+                          $this->trimmed('action'),
+                          $args);
+    }
 
-    function profile_list_class() {
+    function profile_list_class()
+    {
         return 'ProfileList';
     }
 
-       function icon_list($other) {
-
-               common_element_start('ul', $this->div_class());
-
-               $cnt = 0;
-
-               while ($other->fetch()) {
-
-                       $cnt++;
-
-                       if ($cnt > AVATARS_PER_PAGE) {
-                               break;
-                       }
-
-                       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');
-
-                       # XXX: subscribe form here
-
-                       common_element_end('li');
-               }
-
-               common_element_end('ul');
-
-               return $cnt;
-       }
-
-       function gallery_type() {
-               return NULL;
-       }
-
-       function get_instructions(&$profile) {
-               return NULL;
-       }
-
-       function fields() {
-               return NULL;
-       }
-
-       function div_class() {
-               return '';
-       }
-
-       function display_links($profile, $page, $display) {
-               $tag = $this->trimmed('tag');
-
-               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'));
-
-               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;
-               }
-
-               common_element_end('ul');
-               common_element_end('dd');
-               common_element_end('dl');
-       }
-
-       # Get list of tags we tagged other users with
-
-       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 icon_list($other)
+    {
+        common_element_start('ul', $this->div_class());
+
+        $cnt = 0;
+
+        while ($other->fetch()) {
+
+            $cnt++;
+
+            if ($cnt > AVATARS_PER_PAGE) {
+                break;
+            }
+
+            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');
+
+            // XXX: subscribe form here
+
+            common_element_end('li');
+        }
+
+        common_element_end('ul');
+
+        return $cnt;
+    }
+
+    function gallery_type()
+    {
+        return null;
+    }
+
+    function get_instructions(&$profile)
+    {
+        return null;
+    }
+
+    function fields()
+    {
+        return null;
+    }
+
+    function div_class()
+    {
+        return '';
+    }
+
+    function display_links($profile, $page, $display)
+    {
+        $tag = $this->trimmed('tag');
+
+        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'));
+
+        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;
+        }
+
+        common_element_end('ul');
+        common_element_end('dd');
+        common_element_end('dl');
+    }
+
+    // Get list of tags we tagged other users with
+
+    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;
+    }
 }
\ No newline at end of file