Move "Notify::getTab()" to notification module since it's presentation layer logic
This commit is contained in:
parent
4f29e4c4a7
commit
26d6afd27f
2 changed files with 54 additions and 53 deletions
|
@ -13,8 +13,36 @@ use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
use Friendica\Model\Notify;
|
||||||
use Friendica\Module\Security\Login;
|
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)
|
function notifications_post(App $a)
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
|
@ -61,7 +89,7 @@ function notifications_content(App $a)
|
||||||
|
|
||||||
$o = '';
|
$o = '';
|
||||||
// Get the nav tabs for the notification pages
|
// Get the nav tabs for the notification pages
|
||||||
$tabs = $nm->getTabs();
|
$tabs = getTabs($this->args->get(1, ''));
|
||||||
$notif_content = [];
|
$notif_content = [];
|
||||||
$notif_nocontent = '';
|
$notif_nocontent = '';
|
||||||
|
|
||||||
|
@ -320,3 +348,28 @@ function notifications_content(App $a)
|
||||||
|
|
||||||
return $o;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -36,33 +36,6 @@ final class Notify
|
||||||
const HOME = 'home';
|
const HOME = 'home';
|
||||||
const INTRO = 'intro';
|
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 */
|
/** @var Database */
|
||||||
private $dba;
|
private $dba;
|
||||||
/** @var L10n */
|
/** @var L10n */
|
||||||
|
@ -196,31 +169,6 @@ final class Notify
|
||||||
return $this->dba->update('notify', ['seen' => $seen], ['uid' => local_user()]);
|
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
|
* Format the notification query in an usable array
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue