-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathextension.php
More file actions
76 lines (62 loc) · 2.37 KB
/
extension.php
File metadata and controls
76 lines (62 loc) · 2.37 KB
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
66
67
68
69
70
71
72
73
74
75
76
<?php
class WallabagButtonExtension extends Minz_Extension
{
#[\Override]
public function init(): void
{
$this->registerTranslates();
Minz_View::appendScript($this->getFileUrl('script.js'), false, false, false);
Minz_View::appendStyle($this->getFileUrl('style.css'));
Minz_View::appendScript(strval(_url('wallabagButton', 'jsVars')), false, true, false);
$this->registerController('wallabagButton');
$this->registerViews();
}
#[\Override]
public function handleConfigureAction(): void
{
$this->registerTranslates();
if (!Minz_Request::isPost()) {
return;
}
$keyboard_shortcut = Minz_Request::paramString('wallabag_keyboard_shortcut');
FreshRSS_Context::userConf()->_attribute('wallabag_keyboard_shortcut', $keyboard_shortcut);
$cainfo_path = Minz_Request::paramString('wallabag_cainfo_path');
FreshRSS_Context::userConf()->_attribute('wallabag_cainfo_path', $cainfo_path);
FreshRSS_Context::userConf()->save();
$button_location = Minz_Request::paramString('wallabag_button_location');
$url_redirect = array('c' => 'extension', 'a' => 'configure', 'params' => array('e' => 'Wallabag Button'));
switch ($button_location) {
case "header_bottom":
case "header":
case "bottom":
case "hidden":
FreshRSS_Context::userConf()->_attribute('wallabag_button_location', $button_location);
FreshRSS_Context::userConf()->save();
Minz_Request::good(_t('ext.wallabagButton.notifications.changes_saved_sucessfully'), $url_redirect);
return;
default:
Minz_Request::bad(_t('ext.wallabagButton.notifications.changes_failed', $button_location), $url_redirect);
}
}
public function isConfigured(): bool
{
return FreshRSS_Context::userConf()->attributeString('wallabag_access_token') != '';
}
public function shouldBeShown(string $entryName): bool
{
$location = FreshRSS_Context::userConf()->attributeString('wallabag_button_location');
// TO BE REMOVED:
// Update missing entry after update
if ($location == "") {
FreshRSS_Context::userConf()->_attribute('wallabag_button_location', "header_bottom");
FreshRSS_Context::userConf()->save();
return true;
}
if ($location == "hidden") {
return false;
} else if ($location == "header_bottom") {
return true;
}
return $entryName == $location;
}
}