From 26d6afd27fe29cbd0ecba0f1683a9eef03631363 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Sun, 19 Jan 2020 23:17:52 +0100 Subject: [PATCH] Move "Notify::getTab()" to notification module since it's presentation layer logic --- mod/notifications.php | 55 ++++++++++++++++++++++++++++++++++++++++++- src/Model/Notify.php | 52 ---------------------------------------- 2 files changed, 54 insertions(+), 53 deletions(-) diff --git a/mod/notifications.php b/mod/notifications.php index 43d3f7871a..33ff910236 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -13,8 +13,36 @@ use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; +use Friendica\Model\Notify; use Friendica\Module\Security\Login; +/** @var array Array of URL parameters */ +const URL_TYPES = [ + Notify::NETWORK => 'network', + Notify::SYSTEM => 'system', + Notify::HOME => 'home', + Notify::PERSONAL => 'personal', + Notify::INTRO => 'intros', +]; + +/** @var array Array of the allowed notifies and their printable name */ +const PRINT_TYPES = [ + Notify::NETWORK => 'Network', + Notify::SYSTEM => 'System', + Notify::HOME => 'Home', + Notify::PERSONAL => 'Personal', + Notify::INTRO => 'Introductions', +]; + +/** @var array The array of access keys for notify pages */ +const ACCESS_KEYS = [ + Notify::NETWORK => 'w', + Notify::SYSTEM => 'y', + Notify::HOME => 'h', + Notify::PERSONAL => 'r', + Notify::INTRO => 'i', +]; + function notifications_post(App $a) { if (!local_user()) { @@ -61,7 +89,7 @@ function notifications_content(App $a) $o = ''; // Get the nav tabs for the notification pages - $tabs = $nm->getTabs(); + $tabs = getTabs($this->args->get(1, '')); $notif_content = []; $notif_nocontent = ''; @@ -320,3 +348,28 @@ function notifications_content(App $a) return $o; } + +/** + * List of pages for the Notifications TabBar + * + * @param string $selected The selected notification tab + * + * @return array with with notifications TabBar data + * @throws Exception + */ +function getTabs(string $selected = '') +{ + $tabs = []; + + foreach (URL_TYPES as $type => $url) { + $tabs[] = [ + 'label' => $this->l10n->t(PRINT_TYPES[$type]), + 'url' => 'notifications/' . $url, + 'sel' => (($selected == $url) ? 'active' : ''), + 'id' => $type . '-tab', + 'accesskey' => ACCESS_KEYS[$type], + ]; + } + + return $tabs; +} diff --git a/src/Model/Notify.php b/src/Model/Notify.php index a27635a07e..7e8a71c165 100644 --- a/src/Model/Notify.php +++ b/src/Model/Notify.php @@ -36,33 +36,6 @@ final class Notify const HOME = 'home'; const INTRO = 'intro'; - /** @var array Array of URL parameters */ - const URL_TYPES = [ - self::NETWORK => 'network', - self::SYSTEM => 'system', - self::HOME => 'home', - self::PERSONAL => 'personal', - self::INTRO => 'intros', - ]; - - /** @var array Array of the allowed notifies and their printable name */ - const PRINT_TYPES = [ - self::NETWORK => 'Network', - self::SYSTEM => 'System', - self::HOME => 'Home', - self::PERSONAL => 'Personal', - self::INTRO => 'Introductions', - ]; - - /** @var array The array of access keys for notify pages */ - const ACCESS_KEYS = [ - self::NETWORK => 'w', - self::SYSTEM => 'y', - self::HOME => 'h', - self::PERSONAL => 'r', - self::INTRO => 'i', - ]; - /** @var Database */ private $dba; /** @var L10n */ @@ -196,31 +169,6 @@ final class Notify return $this->dba->update('notify', ['seen' => $seen], ['uid' => local_user()]); } - /** - * List of pages for the Notifications TabBar - * - * @return array with with notifications TabBar data - * @throws Exception - */ - public function getTabs() - { - $selected = $this->args->get(1, ''); - - $tabs = []; - - foreach (self::URL_TYPES as $type => $url) { - $tabs[] = [ - 'label' => $this->l10n->t(self::PRINT_TYPES[$type]), - 'url' => 'notifications/' . $url, - 'sel' => (($selected == $url) ? 'active' : ''), - 'id' => $type . '-tab', - 'accesskey' => self::ACCESS_KEYS[$type], - ]; - } - - return $tabs; - } - /** * Format the notification query in an usable array *