More listitems and lists into separate files + stronger typing

This commit is contained in:
Mikael Nordfeldth 2016-01-06 01:36:46 +01:00
parent 6d9f390ba8
commit 4b22b0c42a
3 changed files with 67 additions and 61 deletions

View File

@ -132,64 +132,3 @@ class SubscribersAction extends GalleryAction
parent::showSections(); parent::showSections();
} }
} }
class SubscribersList extends SubscriptionList
{
function newListItem($profile)
{
return new SubscribersListItem($profile, $this->owner, $this->action);
}
}
class SubscribersListItem extends SubscriptionListItem
{
function showActions()
{
$this->startActions();
if (Event::handle('StartProfileListItemActionElements', array($this))) {
$this->showSubscribeButton();
// Relevant code!
$this->showBlockForm();
Event::handle('EndProfileListItemActionElements', array($this));
}
$this->endActions();
}
function showBlockForm()
{
$user = common_current_user();
if (!empty($user) && $this->owner->id == $user->id) {
$returnto = array('action' => 'subscribers',
'nickname' => $this->owner->getNickname());
$page = $this->out->arg('page');
if ($page) {
$returnto['param-page'] = $page;
}
$bf = new BlockForm($this->out, $this->profile, $returnto);
$bf->show();
}
}
function linkAttributes()
{
$aAttrs = parent::linkAttributes();
if (common_config('nofollow', 'subscribers')) {
$aAttrs['rel'] .= ' nofollow';
}
return $aAttrs;
}
function homepageAttributes()
{
$aAttrs = parent::linkAttributes();
if (common_config('nofollow', 'subscribers')) {
$aAttrs['rel'] = 'nofollow';
}
return $aAttrs;
}
}

11
lib/subscriberslist.php Normal file
View File

@ -0,0 +1,11 @@
<?php
if (!defined('GNUSOCIAL')) { exit(1); }
class SubscribersList extends SubscriptionList
{
function newListItem(Profile $profile)
{
return new SubscribersListItem($profile, $this->owner, $this->action);
}
}

View File

@ -0,0 +1,56 @@
<?php
if (!defined('GNUSOCIAL')) { exit(1); }
class SubscribersListItem extends SubscriptionListItem
{
function showActions()
{
$this->startActions();
if (Event::handle('StartProfileListItemActionElements', array($this))) {
$this->showSubscribeButton();
// Relevant code!
$this->showBlockForm();
Event::handle('EndProfileListItemActionElements', array($this));
}
$this->endActions();
}
function showBlockForm()
{
$user = common_current_user();
if (!empty($user) && $this->owner->id == $user->id) {
$returnto = array('action' => 'subscribers',
'nickname' => $this->owner->getNickname());
$page = $this->out->arg('page');
if ($page) {
$returnto['param-page'] = $page;
}
$bf = new BlockForm($this->out, $this->profile, $returnto);
$bf->show();
}
}
function linkAttributes()
{
$aAttrs = parent::linkAttributes();
if (common_config('nofollow', 'subscribers')) {
$aAttrs['rel'] .= ' nofollow';
}
return $aAttrs;
}
function homepageAttributes()
{
$aAttrs = parent::linkAttributes();
if (common_config('nofollow', 'subscribers')) {
$aAttrs['rel'] = 'nofollow';
}
return $aAttrs;
}
}