1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<?php
declare(strict_types=1);
/**
* Represents a view mode option for the reading configuration
*/
final class FreshRSS_ViewMode {
private string $id;
private string $name;
private string $controller;
private string $action;
public function __construct(string $id, string $name, string $controller = 'index', string $action = '') {
$this->id = $id;
$this->name = $name;
$this->controller = $controller;
$this->action = $action ?: $id;
}
public function id(): string {
return $this->id;
}
public function name(): string {
return $this->name;
}
public function controller(): string {
return $this->controller;
}
public function action(): string {
return $this->action;
}
/**
* @return array<string,FreshRSS_ViewMode> Mode ID => FreshRSS_ViewMode
*/
public static function getDefaultModes(): array {
return [
'normal' => new self(id: 'normal', name: _t('conf.reading.view.normal'), controller: 'index', action: 'normal'),
'reader' => new self(id: 'reader', name: _t('conf.reading.view.reader'), controller: 'index', action: 'reader'),
'global' => new self(id: 'global', name: _t('conf.reading.view.global'), controller: 'index', action: 'global'),
];
}
/**
* @return array<string,FreshRSS_ViewMode> Mode ID => FreshRSS_ViewMode
*/
public static function getAllModes(): array {
$modes = self::getDefaultModes();
// Allow extensions to add their own view modes
$extensionModes = Minz_ExtensionManager::callHook(Minz_HookType::ViewModes, []);
if (is_array($extensionModes)) {
foreach ($extensionModes as $mode) {
if ($mode instanceof FreshRSS_ViewMode) {
$modes[$mode->id()] = $mode;
}
}
}
return $modes;
}
}
|