From 4b22b0c42a11f3e5d853a422fe289a2d9b56fc60 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Wed, 6 Jan 2016 01:36:46 +0100 Subject: [PATCH] More listitems and lists into separate files + stronger typing --- actions/subscribers.php | 61 ------------------------------------- lib/subscriberslist.php | 11 +++++++ lib/subscriberslistitem.php | 56 ++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 61 deletions(-) create mode 100644 lib/subscriberslist.php create mode 100644 lib/subscriberslistitem.php diff --git a/actions/subscribers.php b/actions/subscribers.php index 2724927878..81ab70e21e 100644 --- a/actions/subscribers.php +++ b/actions/subscribers.php @@ -132,64 +132,3 @@ class SubscribersAction extends GalleryAction 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; - } -} diff --git a/lib/subscriberslist.php b/lib/subscriberslist.php new file mode 100644 index 0000000000..420456f1e4 --- /dev/null +++ b/lib/subscriberslist.php @@ -0,0 +1,11 @@ +owner, $this->action); + } +} diff --git a/lib/subscriberslistitem.php b/lib/subscriberslistitem.php new file mode 100644 index 0000000000..556a352ceb --- /dev/null +++ b/lib/subscriberslistitem.php @@ -0,0 +1,56 @@ +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; + } +} -- 2.39.5