-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathextension.php
43 lines (35 loc) · 1.36 KB
/
extension.php
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
<?php
class WallabagApiExtension extends Minz_Extension {
public function init() {
Minz_View::appendScript($this->getFileUrl('jquerymin.js', 'js'), false, false, false);
Minz_View::appendScript($this->getFileUrl('script.js', 'js'), false, false, false);
$this->registerTranslates();
$this->registerController('wallabag');
$this->registerViews();
}
private function removeTrailingSlash($url) {
$url = trim($url);
$urlLen = strlen($url);
$urlLastCharPos = $urlLen - 1;
$lastChar = $url[$urlLastCharPos];
if ($lastChar == '/') {
return substr($url, 0, $urlLastCharPos);
}
return $url;
}
public function handleConfigureAction() {
$this->registerTranslates();
if (Minz_Request::isPost()) {
FreshRSS_Context::$user_conf->wallabag_api_client_id = Minz_Request::param('api_client_id', '');
FreshRSS_Context::$user_conf->wallabag_api_client_secret = Minz_Request::param('api_client_secret', '');
$uri = $this->removeTrailingSlash(Minz_Request::param('uri', ''));
FreshRSS_Context::$user_conf->wallabag_api_uri = $uri;
FreshRSS_Context::$user_conf->wallabag_username = Minz_Request::param('username', '');
$password = Minz_Request::param('password', '');
if (!empty($password)) {
FreshRSS_Context::$user_conf->wallabag_password = $password;
}
FreshRSS_Context::$user_conf->save();
}
}
}