123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- require_once INSTALLDIR.'/lib/widget.php';
- class PeopletagsWidget extends Widget
- {
-
- 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 _m('LABEL','Your lists');
- }
- 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);
-
- $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('div', '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, _m('LEGEND','Edit lists'));
- $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', _m('BUTTON','Save'));
- $this->out->elementEnd('fieldset');
- $this->out->elementEnd('form');
- $this->out->elementEnd('div');
- }
- 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)
- {
-
- return common_local_url('selftag', array('tag' => $tag));
- }
- function label()
- {
-
- return _m('LABEL','Tags');
- }
- }
|