We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

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');
}
}
<?php
/**
* StatusNet, the distributed open-source microblogging tool
*
* Widget to show a list 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 Public
* @package StatusNet
* @author Shashi Gowda <connect2shashi@gmail.com>
* @copyright 2008-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);
}
require_once INSTALLDIR.'/lib/widget.php';
define('PEOPLETAGS_PER_PAGE', 20);
/**
* Widget to show a list of peopletags
*
* @category Public
* @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/
*/
class PeopletagList extends Widget
{
/** Current peopletag, peopletag query. */
var $peopletag = null;
/** current user **/
var $user = null;
function __construct($peopletag, $action=null)
{
parent::__construct($action);
$this->peopletag = $peopletag;
if (!empty($owner)) {
$this->user = $owner;
} else {
$this->user = common_current_user();
}
}
function show()
{
$this->out->elementStart('ul', 'peopletags xoxo hfeed');
$cnt = 0;
while ($this->peopletag->fetch()) {
$cnt++;
if($cnt > PEOPLETAGS_PER_PAGE) {
break;
}
$this->showPeopletag();
}
$this->out->elementEnd('ul');
return $cnt;
}
function showPeopletag()
{
$ptag = new PeopletagListItem($this->peopletag, $this->user, $this->out);
$ptag->show();
}
}
class PeopletagListItem extends Widget
{
var $peopletag = null;
var $current = null;
var $profile = null;
/**
* constructor
*
* Also initializes the owner attribute.
*
* @param Notice $notice The notice we'll display
*/
function __construct($peopletag, $current, $out=null)
{
parent::__construct($out);
$this->peopletag = $peopletag;
$this->current = $current;
$this->profile = Profile::staticGet('id', $this->peopletag->tagger);
}
/**
* recipe function for displaying a single peopletag.
*
* This uses all the other methods to correctly display a notice. Override
* it or one of the others to fine-tune the output.
*
* @return void
*/
function url()
{
return $this->peopletag->homeUrl();
}
function show()
{
if (empty($this->peopletag)) {
common_log(LOG_WARNING, "Trying to show missing peopletag; skipping.");
return;
}
if (Event::handle('StartShowPeopletagItem', array($this))) {
$this->showStart();
$this->showPeopletag();
$this->showStats();
$this->showEnd();
Event::handle('EndShowPeopletagItem', array($this));
}
}
function showStart()
{
$mode = ($this->peopletag->private) ? 'private' : 'public';
$this->out->elementStart('li', array('class' => 'hentry peopletag mode-' . $mode,
'id' => 'peopletag-' . $this->peopletag->id));
}
function showEnd()
{
$this->out->elementEnd('li');
}
function showPeopletag()
{
$this->showCreator();
$this->showTag();
$this->showPrivacy();
$this->showUpdated();
$this->showActions();
$this->showDescription();
}
function showStats()
{
$this->out->elementStart('div', 'entry-summary entity_statistics');
$this->out->elementStart('span', 'tagged-count');
$this->out->element('a',
array('href' => common_local_url('peopletagged',
array('tagger' => $this->profile->nickname,
'tag' => $this->peopletag->tag))),
_('Tagged'));
$this->out->raw($this->peopletag->taggedCount());
$this->out->elementEnd('span');
$this->out->elementStart('span', 'subscriber-count');
$this->out->element('a',
array('href' => common_local_url('peopletagsubscribers',
array('tagger' => $this->profile->nickname,
'tag' => $this->peopletag->tag))),
_('Subscribers'));
$this->out->raw($this->peopletag->subscriberCount());
$this->out->elementEnd('span');
$this->out->elementEnd('div');
}
function showOwnerOptions()
{
$this->out->elementStart('li', 'entity_edit');
$this->out->element('a', array('href' =>
common_local_url('editpeopletag', array('tagger' => $this->profile->nickname,
'tag' => $this->peopletag->tag)),
'title' => _('Edit peopletag settings')),
_('Edit'));
$this->out->elementEnd('li');
}
function showSubscribeForm()
{
$this->out->elementStart('li');
if (Event::handle('StartSubscribePeopletagForm', array($this->out, $this->peopletag))) {
if ($this->current) {
if ($this->peopletag->hasSubscriber($this->current->id)) {
$form = new UnsubscribePeopletagForm($this->out, $this->peopletag);
$form->show();
} else {
$form = new SubscribePeopletagForm($this->out, $this->peopletag);
$form->show();
}
}
Event::handle('EndSubscribePeopletagForm', array($this->out, $this->peopletag));
}
$this->out->elementEnd('li');
}
function showCreator()
{
$this->out->elementStart('span', 'author vcard');
$attrs = array();
$attrs['href'] = $this->profile->profileurl;
$attrs['class'] = 'url';
$attrs['rel'] = 'contact';
if (!empty($this->profile->fullname)) {
$attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ')';
}
$this->out->elementStart('a', $attrs);
$this->showAvatar();
$this->out->text(' ');
$this->out->element('span', 'nickname fn',
htmlspecialchars($this->profile->nickname));
$this->out->elementEnd('a');
$this->out->elementEnd('span');
}
function showUpdated()
{
if (!empty($this->peopletag->modified)) {
$this->out->element('abbr',
array('title' => common_date_w3dtf($this->peopletag->modified),
'class' => 'updated'),
common_date_string($this->peopletag->modified));
}
}
function showPrivacy()
{
if ($this->peopletag->private) {
$this->out->elementStart('a',
array('href' => common_local_url('peopletagsbyuser',
array('nickname' => $this->profile->nickname, 'private' => 1))));
$this->out->element('span', 'privacy_mode', _('Private'));
$this->out->elementEnd('a');
}
}
function showTag()
{
$this->out->elementStart('span', 'entry-title tag');
$this->out->element('a',
array('rel' => 'bookmark',
'href' => $this->url()),
htmlspecialchars($this->peopletag->tag));
$this->out->elementEnd('span');