2008-11-21 07:42:07 +09:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Laconica - a distributed open-source microblogging tool
|
|
|
|
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!defined('LACONICA')) { exit(1); }
|
|
|
|
|
|
|
|
require_once(INSTALLDIR.'/lib/profilelist.php');
|
|
|
|
|
2008-12-24 04:49:23 +09:00
|
|
|
class PeopletagAction extends Action
|
|
|
|
{
|
2008-12-24 04:19:07 +09:00
|
|
|
|
2008-12-24 04:33:23 +09:00
|
|
|
function handle($args)
|
|
|
|
{
|
2008-11-21 07:42:07 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
parent::handle($args);
|
2008-11-21 07:42:07 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
$tag = $this->trimmed('tag');
|
|
|
|
|
|
|
|
if (!common_valid_profile_tag($tag)) {
|
2009-01-16 08:03:38 +09:00
|
|
|
$this->clientError(sprintf(_('Not a valid people tag: %s'), $tag));
|
2008-12-24 04:19:07 +09:00
|
|
|
return;
|
|
|
|
}
|
2008-11-21 07:42:07 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
$page = $this->trimmed('page');
|
|
|
|
|
|
|
|
if (!$page) {
|
|
|
|
$page = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Looks like we're good; show the header
|
2008-11-21 07:42:07 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
common_show_header(sprintf(_('Users self-tagged with %s - page %d'), $tag, $page),
|
2008-12-24 04:21:29 +09:00
|
|
|
null, $tag, array($this, 'show_top'));
|
2008-11-21 07:42:07 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
$this->show_people($tag, $page);
|
2008-11-21 07:42:07 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
common_show_footer();
|
|
|
|
}
|
2008-11-21 07:42:07 +09:00
|
|
|
|
2008-12-24 04:33:23 +09:00
|
|
|
function show_people($tag, $page)
|
|
|
|
{
|
2008-12-24 04:19:07 +09:00
|
|
|
|
|
|
|
$profile = new Profile();
|
2008-11-21 07:42:07 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
$offset = ($page-1)*PROFILES_PER_PAGE;
|
|
|
|
$limit = PROFILES_PER_PAGE + 1;
|
|
|
|
|
|
|
|
if (common_config('db','type') == 'pgsql') {
|
|
|
|
$lim = ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
|
|
|
} else {
|
|
|
|
$lim = ' LIMIT ' . $offset . ', ' . $limit;
|
|
|
|
}
|
2008-11-21 07:42:07 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
# XXX: memcached this
|
|
|
|
|
|
|
|
$profile->query(sprintf('SELECT profile.* ' .
|
|
|
|
'FROM profile JOIN profile_tag ' .
|
|
|
|
'ON profile.id = profile_tag.tagger ' .
|
|
|
|
'WHERE profile_tag.tagger = profile_tag.tagged ' .
|
|
|
|
'AND tag = "%s" ' .
|
|
|
|
'ORDER BY profile_tag.modified DESC ' .
|
|
|
|
$lim, $tag));
|
2008-11-21 07:42:07 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
$pl = new ProfileList($profile);
|
|
|
|
$cnt = $pl->show_list();
|
|
|
|
|
|
|
|
common_pagination($page > 1,
|
|
|
|
$cnt > PROFILES_PER_PAGE,
|
|
|
|
$page,
|
|
|
|
$this->trimmed('action'),
|
|
|
|
array('tag' => $tag));
|
|
|
|
}
|
|
|
|
|
2008-12-24 04:33:23 +09:00
|
|
|
function show_top($tag)
|
|
|
|
{
|
2008-12-24 04:19:07 +09:00
|
|
|
$instr = sprintf(_('These are users who have tagged themselves "%s" ' .
|
|
|
|
'to show a common interest, characteristic, hobby or job.'), $tag);
|
2009-01-16 07:57:15 +09:00
|
|
|
$this->elementStart('div', 'instructions');
|
|
|
|
$this->elementStart('p');
|
|
|
|
$this->text($instr);
|
|
|
|
$this->elementEnd('p');
|
|
|
|
$this->elementEnd('div');
|
2008-12-24 04:19:07 +09:00
|
|
|
}
|
2008-11-21 07:42:07 +09:00
|
|
|
|
2008-12-24 04:33:23 +09:00
|
|
|
function get_title()
|
|
|
|
{
|
2008-12-24 04:21:29 +09:00
|
|
|
return null;
|
2008-12-24 04:19:07 +09:00
|
|
|
}
|
2008-11-21 07:42:07 +09:00
|
|
|
|
2008-12-24 04:33:23 +09:00
|
|
|
function show_header($arr)
|
|
|
|
{
|
2008-12-24 04:19:07 +09:00
|
|
|
return;
|
|
|
|
}
|
2008-11-21 07:42:07 +09:00
|
|
|
}
|