git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

Commit f446db8e authored by Shashi Gowda's avatar Shashi Gowda

people tag UI elements

parent 371e923c
<?php
/**
* StatusNet, the distributed open-source microblogging tool
*
* Form for editing a peopletag
*
* PHP version 5
*
* LICENCE: 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/>.
*
* @category Form
* @package StatusNet
* @author Shashi Gowda <connect2shashi@gmail.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/form.php';
require_once INSTALLDIR.'/lib/togglepeopletag.php';
/**
* Form for editing a peopletag
*
* @category Form
* @package StatusNet
* @author Shashi Gowda <connect2shashi@gmail.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*
* @see GroupEditForm
*/
class PeopletagEditForm extends Form
{
/**
* peopletag to edit
*/
var $peopletag = null;
var $tagger = null;
/**
* Constructor
*
* @param Action $out output channel
* @param User_group $group group to join
*/
function __construct($out=null, Profile_list $peopletag=null)
{
parent::__construct($out);
$this->peopletag = $peopletag;
$this->tagger = Profile::staticGet('id', $peopletag->tagger);
}
/**
* ID of the form
*
* @return string ID of the form
*/
function id()
{
return 'form_peopletag_edit-' . $this->peopletag->id;
}
/**
* class of the form
*
* @return string of the form class
*/
function formClass()
{
return 'form_settings';
}
/**
* Action of the form
*
* @return string URL of the action
*/
function action()
{
return common_local_url('editpeopletag',
array('tagger' => $this->tagger->nickname, 'tag' => $this->peopletag->tag));
}
/**
* Name of the form
*
* @return void
*/
function formLegend()
{
$this->out->element('legend', null, sprintf(_('Edit peopletag %s'), $this->peopletag->tag));
}
/**
* Data elements of the form
*
* @return void
*/
function formData()
{
$id = $this->peopletag->id;
$tag = $this->peopletag->tag;
$description = $this->peopletag->description;
$private = $this->peopletag->private;
$this->out->elementStart('ul', 'form_data');
$this->out->elementStart('li');
$this->out->hidden('id', $id);
$this->out->input('tag', _('Tag'),
($this->out->arg('tag')) ? $this->out->arg('tag') : $tag,
_('Change the tag (letters, numbers, -, ., and _ are allowed)'));
$this->out->elementEnd('li');
$this->out->elementStart('li');
$desclimit = Profile_list::maxDescription();
if ($desclimit == 0) {
$descinstr = _('Describe the people tag or topic');
} else {
$descinstr = sprintf(_('Describe the people tag or topic in %d characters'), $desclimit);
}
$this->out->textarea('description', _('Description'),
($this->out->arg('description')) ? $this->out->arg('description') : $description,
$descinstr);
$this->out->checkbox('private', _('Private'), $private);
$this->out->elementEnd('li');
$this->out->elementEnd('ul');
}
/**
* Action elements
*
* @return void
*/
function formActions()
{
$this->out->submit('submit', _('Save'));
$this->out->submit('form_action-yes',
_m('BUTTON','Delete'),
'submit',
'delete',
_('Delete this people tag'));
}
function showProfileList()
{
$tagged = $this->peopletag->getTagged();
$this->out->element('h2', null, 'Add or remove people');
$this->out->elementStart('div', 'profile_search_wrap');
$this->out->element('h3', null, 'Add user');
$search = new SearchProfileForm($this->out, $this->peopletag);
$search->show();
$this->out->element('ul', array('id' => 'profile_search_results', 'class' => 'empty'));
$this->out->elementEnd('div');
$this->out->elementStart('ul', 'profile-lister');
while ($tagged->fetch()) {
$this->out->elementStart('li', 'entity_removable_profile');
$this->showProfileItem($tagged);
$this->out->elementStart('span', 'entity_actions');
$untag = new UntagButton($this->out, $tagged, $this->peopletag);
$untag->show();
$this->out->elementEnd('span');
$this->out->elementEnd('li');
}
$this->out->elementEnd('ul');
}
function showProfileItem($profile)
{
$item = new TaggedProfileItem($this->out, $profile);
$item->show();
}
}
<?php
/**
* StatusNet, the distributed open-source microblogging tool
*
* Base class for all actions (~views)
*
* PHP version 5
*
* LICENCE: 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/>.
*
* @category Action
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @author Sarven Capadisli <csarven@status.net>
* @copyright 2008 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/widget.php';
/**
* Base class for all actions
*
* This is the base class for all actions in the package. An action is
* more or less a "view" in an MVC framework.
*
* Actions are responsible for extracting and validating parameters; using
* model classes to read and write to the database; and doing ouput.
*
* @category Output
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @author Sarven Capadisli <csarven@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*
* @see HTMLOutputter
*/
class PeopletagGroupNav extends Widget
{
var $action = null;
/**
* Construction
*
* @param Action $action current action, used for output
*/
function __construct($action=null)
{
parent::__construct($action);
$this->action = $action;
}
/**
* Show the menu
*
* @return void
*/
function show()
{
$user = null;
// FIXME: we should probably pass this in
$action = $this->action->trimmed('action');
$nickname = $this->action->trimmed('tagger');
$tag = $this->action->trimmed('tag');
if ($nickname) {
$user = User::staticGet('nickname', $nickname);
$user_profile = $user->getProfile();
if ($tag) {
$tag = Profile_list::pkeyGet(array('tagger' => $user->id,
'tag' => $tag));
} else {
$tag = false;
}
} else {
$user_profile = false;
}
$this->out->elementStart('ul', array('class' => 'nav'));
if (Event::handle('StartPeopletagGroupNav', array($this))) {
// People tag timeline
$this->out->menuItem(common_local_url('showprofiletag', array('tagger' => $user_profile->nickname,
'tag' => $tag->tag)),
_('People tag'),
sprintf(_('%s tag by %s'), $tag->tag,
(($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
$action == 'showprofiletag', 'nav_timeline_peopletag');
// Tagged
$this->out->menuItem(common_local_url('peopletagged', array('tagger' => $user->nickname,
'tag' => $tag->tag)),
_('Tagged'),
sprintf(_('%s tag by %s'), $tag->tag,
(($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
$action == 'peopletagged', 'nav_peopletag_tagged');
// Subscribers
$this->out->menuItem(common_local_url('peopletagsubscribers', array('tagger' => $user->nickname,
'tag' => $tag->tag)),
_('Subscribers'),
sprintf(_('Subscribers to %s tag by %s'), $tag->tag,
(($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
$action == 'peopletagsubscribers', 'nav_peopletag_subscribers');
$cur = common_current_user();
if (!empty($cur) && $user_profile->id == $cur->id) {
// Edit
$this->out->menuItem(common_local_url('editpeopletag', array('tagger' => $user->nickname,
'tag' => $tag->tag)),
_('Edit'),
sprintf(_('Edit %s tag by you'), $tag->tag,
(($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
$action == 'editpeopletag', 'nav_peopletag_edit');
}
Event::handle('EndPeopletagGroupNav', array($this));
}
$this->out->elementEnd('ul');
}
}
This diff is collapsed.
<?php
/**
* StatusNet, the distributed open-source microblogging tool
*
* Tags for a profile
*
* PHP version 5
*
* LICENCE: 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/>.
*
* @category Action
* @package StatusNet
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/widget.php';
/*
* Show a bunch of peopletags
* provide ajax editing if the current user owns the tags
*
* @category Action
* @pacage StatusNet
* @author Shashi Gowda <connect2shashi@gmail.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
*/
class PeopletagsWidget extends Widget
{
/*
* the query, current peopletag.
* or an array of strings (tags)
*/
var $tag=null;
var $user=null;
var $tagger=null;
var $tagged=null;
function __construct($out, $tagger, $tagged)
{
parent::__construct($out);
$this->user = common_current_user();
$this->tag = Profile_tag::getTags($tagger->id, $tagged->id, $this->user);
$this->tagger = $tagger;
$this->tagged = $tagged;
}
function show()
{
if (Event::handle('StartShowPeopletags', array($this, $this->tagger, $this->tagged))) {
if ($this->tag->N > 0) {
$this->showTags();
}
else {
$this->showEmptyList();
}
Event::handle('EndShowPeopletags', array($this, $this->tagger, $this->tagged));
}
}
function url()
{
return $this->tag->homeUrl();
}
function label()
{
return _('Tags by you');
}
function showTags()
{
$this->out->elementStart('dl', 'entity_tags user_profile_tags');
$this->out->element('dt', null, $this->label());
$this->out->elementStart('dd');
$class = 'tags xoxo';
if ($this->isEditable()) {
$class .= ' editable';
}
$tags = array();
$this->out->elementStart('ul', $class);
while ($this->tag->fetch()) {
$mode = $this->tag->private ? 'private' : 'public';
$tags[] = $this->tag->tag;
$this->out->elementStart('li', 'hashptag mode-' . $mode);
// Avoid space by using raw output.
$pt = '<span class="mark_hash">#</span><a rel="tag" href="' .
$this->url($this->tag->tag) .
'">' . $this->tag->tag . '</a>';
$this->out->raw($pt);
$this->out->elementEnd('li');
}
$this->out->elementEnd('ul');
if ($this->isEditable()) {
$this->showEditTagForm($tags);
}
$this->out->elementEnd('dd');
$this->out->elementEnd('dl');
}
function showEditTagForm($tags=null)
{
$this->out->elementStart('span', 'form_tag_user_wrap');
$this->out->elementStart('form', array('method' => 'post',
'class' => 'form_tag_user',
'name' => 'tagprofile',
'action' => common_local_url('tagprofile', array('id' => $this->tagged->id))));
$this->out->elementStart('fieldset');
$this->out->element('legend', null, _('Edit tags'));
$this->out->hidden('token', common_session_token());
$this->out->hidden('id', $this->tagged->id);
if (!$tags) {
$tags = array();
}
$this->out->input('tags', $this->label(),
($this->out->arg('tags')) ? $this->out->arg('tags') : implode(' ', $tags));
$this->out->submit('save', _('Save'));
$this->out->elementEnd('fieldset');
$this->out->elementEnd('form');
$this->out->elementEnd('span');
}
function showEmptyList()
{
$this->out->elementStart('dl', 'entity_tags user_profile_tags');
$this->out->element('dt', null, $this->label());
$this->out->elementStart('dd');
$class = 'tags';
if ($this->isEditable()) {
$class .= ' editable';
}
$this->out->elementStart('ul', $class);
$this->out->element('li', null, _('(None)'));
$this->out->elementEnd('ul');
if ($this->isEditable()) {
$this->showEditTagForm();
}
$this->out->elementEnd('dd');
$this->out->elementEnd('dl');
}
function isEditable()
{
return !empty($this->user) && $this->tagger->id == $this->user->id;
}
}
class SelftagsWidget extends PeopletagsWidget
{
function url($tag)
{
// link to self tag page
return common_local_url('selftag', array('tag' => $tag));
}
function label()
{
return _('Tags');
}
}
<?php
/**
* StatusNet, the distributed open-source microblogging tool
*
* Peopletags with the most subscribers section
*
* PHP version 5
*
* LICENCE: 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/>.
*
* @category Widget
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @copyright 2009 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
/**
* Peopletags with the most subscribers section
*
* @category Widget
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
class PeopletagsBySubsSection extends PeopletagSection
{
function getPeopletags()
{
$qry = 'SELECT profile_list.*, subscriber_count as value ' .
'FROM profile_list WHERE profile_list.private = false ' .
'ORDER BY value DESC ';
$limit = PEOPLETAGS_PER_SECTION;
$offset = 0;
if (common_config('db','type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
$peopletag = Memcached_DataObject::cachedQuery('Profile_list',
$qry,
3600);
return $peopletag;
}
function title()
{
return _('People tags with most subscribers');
}
function divId()
{
return 'top_peopletags_by_subs';
}
}
<?php
/**
* StatusNet, the distributed open-source microblogging tool
*
* Base class for sections showing lists of peopletags
*
* PHP version 5
*
* LICENCE: 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/>.
*
* @category Widget
* @package StatusNet
* @author Shashi Gowda <connect2shashi@gmail.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR . '/lib/peopletaglist.php';
define('PEOPLETAGS_PER_SECTION', 6);
/**
* Base class for sections
*
* These are the widgets that show interesting data about a person
* peopletag, or site.
*
* @category Widget
* @package StatusNet
* @author Shashi Gowda <connect2shashi@gmail.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
class PeopletagSection extends Section
{
function showContent()
{
$tags = $this->getPeopletags();
if (!$tags) {
return false;
}
$cnt = 0;
$this->out->elementStart('table', 'peopletag_section');
while ($tags->fetch() && ++$cnt <= PEOPLETAGS_PER_SECTION) {
$this->showPeopletag($tags);
}
$this->out->elementEnd('table');
return ($cnt > PEOPLETAGS_PER_SECTION);
}
function getPeopletags()
{
return null;
}
function showPeopletag($peopletag)
{
$tag = new PeopletagSectionItem($peopletag, null, $this->out);
$tag->show();
}
}
class PeopletagSectionItem extends PeopletagListItem
{
function showStart()
{
}
function showEnd()
{
}
function showPeopletag()
{
$this->showCreator();
$this->showTag();
$this->showPrivacy();
}
function show()
{
if (empty($this->peopletag)) {
common_log(LOG_WARNING, "Trying to show missing peopletag; skipping.");
return;
}
$this->out->elementStart('tr');
$this->out->elementStart('td', 'peopletag');
$this->showPeopletag();
$this->out->elementEnd('td');
if ($this->peopletag->value) {
$this->out->element('td', 'value', $this->peopletag->value);
}
$this->out->elementEnd('tr');
}
function showTag()
{
$title = _('Tagged: ') . $this->peopletag->taggedCount() .