reformat for phpcs
darcs-hash:20081221005837-84dde-07cd6bb27d5f601360a686538dd76f1dca9af3c4.gz
This commit is contained in:
parent
f3c0d31688
commit
5d76234a60
@ -28,3 +28,5 @@ Evan Prodromou <evan@prodromou.name>**20081221003016]
|
||||
Evan Prodromou <evan@prodromou.name>**20081221003955]
|
||||
[reformat lib/daemon.php for phpcs
|
||||
Evan Prodromou <evan@prodromou.name>**20081221004607]
|
||||
[reformat for phpcs
|
||||
Evan Prodromou <evan@prodromou.name>**20081221005837]
|
Binary file not shown.
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
*
|
||||
@ -18,30 +17,35 @@
|
||||
* 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() {
|
||||
class GalleryAction extends Action
|
||||
{
|
||||
function is_readonly()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
function handle($args) {
|
||||
function handle($args)
|
||||
{
|
||||
parent::handle($args);
|
||||
|
||||
# Post from the tag dropdown; redirect to a GET
|
||||
// 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) {
|
||||
@ -71,7 +75,7 @@ class GalleryAction extends Action {
|
||||
$tag = $this->arg('tag');
|
||||
|
||||
common_show_header($profile->nickname . ": " . $this->gallery_type(),
|
||||
NULL, $profile,
|
||||
null, $profile,
|
||||
array($this, 'show_top'));
|
||||
|
||||
$this->display_links($profile, $page, $display);
|
||||
@ -81,15 +85,21 @@ class GalleryAction extends Action {
|
||||
common_show_footer();
|
||||
}
|
||||
|
||||
function no_such_user() {
|
||||
function no_such_user()
|
||||
{
|
||||
$this->client_error(_('No such user.'));
|
||||
}
|
||||
|
||||
function show_tags_dropdown($profile) {
|
||||
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;
|
||||
}
|
||||
@ -98,15 +108,21 @@ class GalleryAction extends Action {
|
||||
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))),
|
||||
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_element_start('form', array('name' => 'bytag',
|
||||
'id' => 'bytag',
|
||||
'method' => 'post'));
|
||||
common_dropdown('tag', _('Tag'), $content,
|
||||
_('Choose a tag to narrow list'), FALSE, $tag);
|
||||
_('Choose a tag to narrow list'), false, $tag);
|
||||
common_submit('go', _('Go'));
|
||||
common_element_end('form');
|
||||
common_element_end('li');
|
||||
@ -116,16 +132,19 @@ class GalleryAction extends Action {
|
||||
}
|
||||
}
|
||||
|
||||
function show_top($profile) {
|
||||
function show_top($profile)
|
||||
{
|
||||
common_element('div', 'instructions',
|
||||
$this->get_instructions($profile));
|
||||
$this->show_menu();
|
||||
}
|
||||
|
||||
function show_menu() {
|
||||
# action => array('prompt', 'title', $args)
|
||||
function show_menu()
|
||||
{
|
||||
// action => array('prompt', 'title', $args)
|
||||
$action = $this->trimmed('action');
|
||||
$nickname = $this->trimmed('nickname');
|
||||
|
||||
$menu =
|
||||
array('subscriptions' =>
|
||||
array( _('Subscriptions'),
|
||||
@ -140,8 +159,8 @@ class GalleryAction extends Action {
|
||||
$this->nav_menu($menu);
|
||||
}
|
||||
|
||||
function show_gallery($profile, $page, $display='list', $tag=NULL) {
|
||||
|
||||
function show_gallery($profile, $page, $display='list', $tag=null)
|
||||
{
|
||||
$other = new Profile();
|
||||
|
||||
list($lst, $usr) = $this->fields();
|
||||
@ -151,14 +170,14 @@ class GalleryAction extends Action {
|
||||
$offset = ($page-1)*$per_page;
|
||||
$limit = $per_page + 1;
|
||||
|
||||
if (common_config('db','type') == 'pgsql') {
|
||||
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 ' .
|
||||
@ -178,7 +197,7 @@ class GalleryAction extends Action {
|
||||
$cnt = $this->icon_list($other);
|
||||
}
|
||||
|
||||
# For building the pagination URLs
|
||||
// For building the pagination URLs
|
||||
|
||||
$args = array('nickname' => $profile->nickname);
|
||||
|
||||
@ -193,12 +212,13 @@ class GalleryAction extends Action {
|
||||
$args);
|
||||
}
|
||||
|
||||
function profile_list_class() {
|
||||
function profile_list_class()
|
||||
{
|
||||
return 'ProfileList';
|
||||
}
|
||||
|
||||
function icon_list($other) {
|
||||
|
||||
function icon_list($other)
|
||||
{
|
||||
common_element_start('ul', $this->div_class());
|
||||
|
||||
$cnt = 0;
|
||||
@ -231,7 +251,7 @@ class GalleryAction extends Action {
|
||||
$other->nickname));
|
||||
common_element_end('a');
|
||||
|
||||
# XXX: subscribe form here
|
||||
// XXX: subscribe form here
|
||||
|
||||
common_element_end('li');
|
||||
}
|
||||
@ -241,23 +261,28 @@ class GalleryAction extends Action {
|
||||
return $cnt;
|
||||
}
|
||||
|
||||
function gallery_type() {
|
||||
return NULL;
|
||||
function gallery_type()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
function get_instructions(&$profile) {
|
||||
return NULL;
|
||||
function get_instructions(&$profile)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
function fields() {
|
||||
return NULL;
|
||||
function fields()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
function div_class() {
|
||||
function div_class()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
function display_links($profile, $page, $display) {
|
||||
function display_links($profile, $page, $display)
|
||||
{
|
||||
$tag = $this->trimmed('tag');
|
||||
|
||||
common_element_start('dl', array('id'=>'subscriptions_nav'));
|
||||
@ -291,7 +316,7 @@ class GalleryAction extends Action {
|
||||
common_element('a', array('href' => $url),
|
||||
_('List'));
|
||||
common_element_end('li');
|
||||
common_element('li', NULL, _('Icons'));
|
||||
common_element('li', null, _('Icons'));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -300,9 +325,10 @@ class GalleryAction extends Action {
|
||||
common_element_end('dl');
|
||||
}
|
||||
|
||||
# Get list of tags we tagged other users with
|
||||
// Get list of tags we tagged other users with
|
||||
|
||||
function get_all_tags($profile, $lst, $usr) {
|
||||
function get_all_tags($profile, $lst, $usr)
|
||||
{
|
||||
$profile_tag = new Notice_tag();
|
||||
$profile_tag->query('SELECT DISTINCT(tag) ' .
|
||||
'FROM profile_tag, subscription ' .
|
||||
|
@ -1,232 +1,562 @@
|
||||
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()
|
||||
+ {
|
||||
+ return null;
|
||||
+ }
|
||||
hunk ./lib/daemon.php 31
|
||||
- function name() {
|
||||
- return NULL;
|
||||
- }
|
||||
-
|
||||
- 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;
|
||||
- }
|
||||
- }
|
||||
+ 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;
|
||||
+ }
|
||||
+ }
|
||||
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/daemon.php 53
|
||||
- if (!$pidfilename) {
|
||||
- return false;
|
||||
- }
|
||||
-
|
||||
- if (!file_exists($pidfilename)) {
|
||||
- return false;
|
||||
- }
|
||||
- $contents = file_get_contents($pidfilename);
|
||||
- if (posix_kill(trim($contents),0)) {
|
||||
- return true;
|
||||
- } else {
|
||||
- return false;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- function writePidFile() {
|
||||
- $pidfilename = $this->pidFilename();
|
||||
-
|
||||
- if (!$pidfilename) {
|
||||
- return false;
|
||||
- }
|
||||
-
|
||||
- return file_put_contents($pidfilename, posix_getpid() . "\n");
|
||||
- }
|
||||
+ if (!file_exists($pidfilename)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ $contents = file_get_contents($pidfilename);
|
||||
+ if (posix_kill(trim($contents), 0)) {
|
||||
+ return true;
|
||||
+ } else {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
hunk ./lib/daemon.php 64
|
||||
- function clearPidFile() {
|
||||
- $pidfilename = $this->pidFilename();
|
||||
- if (!$pidfilename) {
|
||||
- return false;
|
||||
- }
|
||||
- return unlink($pidfilename);
|
||||
- }
|
||||
-
|
||||
- function pidFilename() {
|
||||
- $piddir = common_config('daemon', 'piddir');
|
||||
- if (!$piddir) {
|
||||
- return NULL;
|
||||
- }
|
||||
- $name = $this->name();
|
||||
- if (!$name) {
|
||||
- return NULL;
|
||||
- }
|
||||
- return $piddir . '/' . $name . '.pid';
|
||||
- }
|
||||
+ function writePidFile()
|
||||
+ {
|
||||
+ $pidfilename = $this->pidFilename();
|
||||
hunk ./lib/daemon.php 68
|
||||
- function changeUser() {
|
||||
+ if (!$pidfilename) {
|
||||
+ return false;
|
||||
+ }
|
||||
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']);
|
||||
- }
|
||||
- }
|
||||
+ return file_put_contents($pidfilename, posix_getpid() . "\n");
|
||||
+ }
|
||||
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']);
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- 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();
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- function run() {
|
||||
- return true;
|
||||
- }
|
||||
+ function clearPidFile()
|
||||
+ {
|
||||
+ $pidfilename = $this->pidFilename();
|
||||
+ if (!$pidfilename) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ return unlink($pidfilename);
|
||||
+ }
|
||||
+
|
||||
+ function pidFilename()
|
||||
+ {
|
||||
+ $piddir = common_config('daemon', 'piddir');
|
||||
+ if (!$piddir) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ $name = $this->name();
|
||||
+ if (!$name) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ return $piddir . '/' . $name . '.pid';
|
||||
+ }
|
||||
+
|
||||
+ function changeUser()
|
||||
+ {
|
||||
+ $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']);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ $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']);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ 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();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ function run()
|
||||
+ 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;
|
||||
+ }
|
||||
|
110
lib/gallery.php
110
lib/gallery.php
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Laconica - a distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, Controlez-Vous, Inc.
|
||||
*
|
||||
@ -18,30 +17,35 @@
|
||||
* 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() {
|
||||
class GalleryAction extends Action
|
||||
{
|
||||
function is_readonly()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
function handle($args) {
|
||||
function handle($args)
|
||||
{
|
||||
parent::handle($args);
|
||||
|
||||
# Post from the tag dropdown; redirect to a GET
|
||||
// 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) {
|
||||
@ -71,7 +75,7 @@ class GalleryAction extends Action {
|
||||
$tag = $this->arg('tag');
|
||||
|
||||
common_show_header($profile->nickname . ": " . $this->gallery_type(),
|
||||
NULL, $profile,
|
||||
null, $profile,
|
||||
array($this, 'show_top'));
|
||||
|
||||
$this->display_links($profile, $page, $display);
|
||||
@ -81,15 +85,21 @@ class GalleryAction extends Action {
|
||||
common_show_footer();
|
||||
}
|
||||
|
||||
function no_such_user() {
|
||||
function no_such_user()
|
||||
{
|
||||
$this->client_error(_('No such user.'));
|
||||
}
|
||||
|
||||
function show_tags_dropdown($profile) {
|
||||
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;
|
||||
}
|
||||
@ -98,15 +108,21 @@ class GalleryAction extends Action {
|
||||
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))),
|
||||
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_element_start('form', array('name' => 'bytag',
|
||||
'id' => 'bytag',
|
||||
'method' => 'post'));
|
||||
common_dropdown('tag', _('Tag'), $content,
|
||||
_('Choose a tag to narrow list'), FALSE, $tag);
|
||||
_('Choose a tag to narrow list'), false, $tag);
|
||||
common_submit('go', _('Go'));
|
||||
common_element_end('form');
|
||||
common_element_end('li');
|
||||
@ -116,16 +132,19 @@ class GalleryAction extends Action {
|
||||
}
|
||||
}
|
||||
|
||||
function show_top($profile) {
|
||||
function show_top($profile)
|
||||
{
|
||||
common_element('div', 'instructions',
|
||||
$this->get_instructions($profile));
|
||||
$this->show_menu();
|
||||
}
|
||||
|
||||
function show_menu() {
|
||||
# action => array('prompt', 'title', $args)
|
||||
function show_menu()
|
||||
{
|
||||
// action => array('prompt', 'title', $args)
|
||||
$action = $this->trimmed('action');
|
||||
$nickname = $this->trimmed('nickname');
|
||||
|
||||
$menu =
|
||||
array('subscriptions' =>
|
||||
array( _('Subscriptions'),
|
||||
@ -140,8 +159,8 @@ class GalleryAction extends Action {
|
||||
$this->nav_menu($menu);
|
||||
}
|
||||
|
||||
function show_gallery($profile, $page, $display='list', $tag=NULL) {
|
||||
|
||||
function show_gallery($profile, $page, $display='list', $tag=null)
|
||||
{
|
||||
$other = new Profile();
|
||||
|
||||
list($lst, $usr) = $this->fields();
|
||||
@ -151,14 +170,14 @@ class GalleryAction extends Action {
|
||||
$offset = ($page-1)*$per_page;
|
||||
$limit = $per_page + 1;
|
||||
|
||||
if (common_config('db','type') == 'pgsql') {
|
||||
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 ' .
|
||||
@ -178,7 +197,7 @@ class GalleryAction extends Action {
|
||||
$cnt = $this->icon_list($other);
|
||||
}
|
||||
|
||||
# For building the pagination URLs
|
||||
// For building the pagination URLs
|
||||
|
||||
$args = array('nickname' => $profile->nickname);
|
||||
|
||||
@ -193,12 +212,13 @@ class GalleryAction extends Action {
|
||||
$args);
|
||||
}
|
||||
|
||||
function profile_list_class() {
|
||||
function profile_list_class()
|
||||
{
|
||||
return 'ProfileList';
|
||||
}
|
||||
|
||||
function icon_list($other) {
|
||||
|
||||
function icon_list($other)
|
||||
{
|
||||
common_element_start('ul', $this->div_class());
|
||||
|
||||
$cnt = 0;
|
||||
@ -231,7 +251,7 @@ class GalleryAction extends Action {
|
||||
$other->nickname));
|
||||
common_element_end('a');
|
||||
|
||||
# XXX: subscribe form here
|
||||
// XXX: subscribe form here
|
||||
|
||||
common_element_end('li');
|
||||
}
|
||||
@ -241,23 +261,28 @@ class GalleryAction extends Action {
|
||||
return $cnt;
|
||||
}
|
||||
|
||||
function gallery_type() {
|
||||
return NULL;
|
||||
function gallery_type()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
function get_instructions(&$profile) {
|
||||
return NULL;
|
||||
function get_instructions(&$profile)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
function fields() {
|
||||
return NULL;
|
||||
function fields()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
function div_class() {
|
||||
function div_class()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
function display_links($profile, $page, $display) {
|
||||
function display_links($profile, $page, $display)
|
||||
{
|
||||
$tag = $this->trimmed('tag');
|
||||
|
||||
common_element_start('dl', array('id'=>'subscriptions_nav'));
|
||||
@ -291,7 +316,7 @@ class GalleryAction extends Action {
|
||||
common_element('a', array('href' => $url),
|
||||
_('List'));
|
||||
common_element_end('li');
|
||||
common_element('li', NULL, _('Icons'));
|
||||
common_element('li', null, _('Icons'));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -300,9 +325,10 @@ class GalleryAction extends Action {
|
||||
common_element_end('dl');
|
||||
}
|
||||
|
||||
# Get list of tags we tagged other users with
|
||||
// Get list of tags we tagged other users with
|
||||
|
||||
function get_all_tags($profile, $lst, $usr) {
|
||||
function get_all_tags($profile, $lst, $usr)
|
||||
{
|
||||
$profile_tag = new Notice_tag();
|
||||
$profile_tag->query('SELECT DISTINCT(tag) ' .
|
||||
'FROM profile_tag, subscription ' .
|
||||
|
Loading…
Reference in New Issue
Block a user