123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <?php
- defined('GNUSOCIAL') || die();
- class SelftagAction extends Action
- {
- public $tag = null;
- public $page = null;
-
- public function prepare(array $args = [])
- {
- parent::prepare($args);
- $this->tag = $this->trimmed('tag');
- if (!common_valid_profile_tag($this->tag)) {
-
-
- $this->clientError(sprintf(
- _('Not a valid list: %s.'),
- $this->tag
- ));
- return null;
- }
- $this->page = ($this->arg('page')) ? $this->arg('page') : 1;
- common_set_returnto($this->selfUrl());
- return true;
- }
-
- public function handle()
- {
- parent::handle();
- $this->showPage();
- }
-
- public function showContent()
- {
- $profile = new Profile();
- $profile->joinAdd(['id', 'profile_list:tagger']);
- $profile->joinAdd(['id', 'profile_role:profile_id'], 'LEFT');
- $profile->whereAdd(sprintf(
- "profile_list.tag = '%s'",
- $profile->escape($this->tag)
- ));
- $profile->whereAdd("COALESCE(profile_role.role, '') <> 'silenced'");
- $user = common_current_user();
- if (!empty($user)) {
- $profile->whereAdd(sprintf(
- 'profile_list.tagger = %d OR profile_list.private IS NOT TRUE',
- $user->getID()
- ));
- } else {
- $profile->whereAdd('profile_list.private IS NOT TRUE');
- }
- $profile->orderBy('profile_list.modified DESC, profile_list.id DESC');
- $offset = ($this->page - 1) * PROFILES_PER_PAGE;
- $limit = PROFILES_PER_PAGE + 1;
- $profile->limit($offset, $limit);
- $profile->find();
- $ptl = new SelfTagProfileList($profile, $this);
- $cnt = $ptl->show();
- $this->pagination(
- $this->page > 1,
- $cnt > PROFILES_PER_PAGE,
- $this->page,
- 'selftag',
- ['tag' => $this->tag]
- );
- }
-
- public function title()
- {
-
-
- return sprintf(
- _('Users self-tagged with %1$s, page %2$d'),
- $this->tag,
- $this->page
- );
- }
- }
- class SelfTagProfileList extends ProfileList
- {
- public function newListItem(Profile $target)
- {
- return new SelfTagProfileListItem($target, $this->action);
- }
- }
- class SelfTagProfileListItem extends ProfileListItem
- {
- public function linkAttributes()
- {
- $aAttrs = parent::linkAttributes();
- if (common_config('nofollow', 'selftag')) {
- $aAttrs['rel'] .= ' nofollow';
- }
- return $aAttrs;
- }
- public function homepageAttributes()
- {
- $aAttrs = parent::linkAttributes();
- if (common_config('nofollow', 'selftag')) {
- $aAttrs['rel'] = 'nofollow';
- }
- return $aAttrs;
- }
- public function showTags()
- {
- $selftags = new SelfTagsWidget($this->out, $this->profile, $this->profile);
- $selftags->show();
- $user = common_current_user();
- if (!empty($user) && $user->id != $this->profile->getID() &&
- $user->getProfile()->canTag($this->profile)) {
- $yourtags = new PeopleTagsWidget($this->out, $user, $this->profile);
- $yourtags->show();
- }
- }
- }
|