diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-09-20 10:21:39 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-09-20 10:21:39 +0200 |
commit | 00dbaf90bc44ef3ed0abaebb15307756e054a027 (patch) | |
tree | b3391178b65147d025a8ae01e2c97044c9298189 /index.php | |
parent | 705250b93dc71ae91d3c305b51e7a20611873805 (diff) | |
download | wallabag-00dbaf90bc44ef3ed0abaebb15307756e054a027.tar.gz wallabag-00dbaf90bc44ef3ed0abaebb15307756e054a027.tar.zst wallabag-00dbaf90bc44ef3ed0abaebb15307756e054a027.zip |
merge #224
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 62 |
1 files changed, 35 insertions, 27 deletions
@@ -8,13 +8,11 @@ | |||
8 | * @license http://www.wtfpl.net/ see COPYING file | 8 | * @license http://www.wtfpl.net/ see COPYING file |
9 | */ | 9 | */ |
10 | 10 | ||
11 | if (file_exists(__DIR__ . '/inc/poche/myconfig.inc.php')) { | 11 | require_once 'inc/poche/global.inc.php'; |
12 | require_once __DIR__ . '/inc/poche/myconfig.inc.php'; | ||
13 | } | ||
14 | require_once './inc/poche/Tools.class.php'; | ||
15 | Tools::createMyConfig(); | ||
16 | 12 | ||
17 | include dirname(__FILE__).'/inc/poche/config.inc.php'; | 13 | # Start Poche |
14 | $poche = new Poche(); | ||
15 | $notInstalledMessage = $poche -> getNotInstalledMessage(); | ||
18 | 16 | ||
19 | # Parse GET & REFERER vars | 17 | # Parse GET & REFERER vars |
20 | $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; | 18 | $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; |
@@ -24,47 +22,57 @@ $id = Tools::checkVar('id'); | |||
24 | $_SESSION['sort'] = Tools::checkVar('sort', 'id'); | 22 | $_SESSION['sort'] = Tools::checkVar('sort', 'id'); |
25 | $url = new Url((isset ($_GET['url'])) ? $_GET['url'] : ''); | 23 | $url = new Url((isset ($_GET['url'])) ? $_GET['url'] : ''); |
26 | 24 | ||
25 | # vars to _always_ send to templates | ||
26 | $tpl_vars = array( | ||
27 | 'referer' => $referer, | ||
28 | 'view' => $view, | ||
29 | 'poche_url' => Tools::getPocheUrl(), | ||
30 | 'title' => _('poche, a read it later open source system'), | ||
31 | 'token' => Session::getToken(), | ||
32 | 'theme' => $poche->getTheme() | ||
33 | ); | ||
34 | |||
35 | if (! empty($notInstalledMessage)) { | ||
36 | if (! Poche::$canRenderTemplates || ! Poche::$configFileAvailable) { | ||
37 | # We cannot use Twig to display the error message | ||
38 | die($notInstalledMessage); | ||
39 | } else { | ||
40 | # Twig is installed, put the error message in the template | ||
41 | $tpl_file = Tools::getTplFile('error'); | ||
42 | $tpl_vars = array_merge($tpl_vars, array('msg' => $poche->getNotInstalledMessage())); | ||
43 | echo $poche->tpl->render($tpl_file, $tpl_vars); | ||
44 | exit; | ||
45 | } | ||
46 | } | ||
47 | |||
27 | # poche actions | 48 | # poche actions |
28 | if (isset($_GET['login'])) { | 49 | if (isset($_GET['login'])) { |
29 | # hello you | 50 | # hello you |
30 | $poche->login($referer); | 51 | $poche->login($referer); |
31 | } | 52 | } elseif (isset($_GET['logout'])) { |
32 | elseif (isset($_GET['logout'])) { | ||
33 | # see you soon ! | 53 | # see you soon ! |
34 | $poche->logout(); | 54 | $poche->logout(); |
35 | } | 55 | } elseif (isset($_GET['config'])) { |
36 | elseif (isset($_GET['config'])) { | ||
37 | # Update password | 56 | # Update password |
38 | $poche->updatePassword(); | 57 | $poche->updatePassword(); |
39 | } | 58 | } elseif (isset($_GET['import'])) { |
40 | elseif (isset($_GET['import'])) { | ||
41 | $import = $poche->import($_GET['from']); | 59 | $import = $poche->import($_GET['from']); |
42 | } | 60 | } elseif (isset($_GET['export'])) { |
43 | elseif (isset($_GET['export'])) { | ||
44 | $poche->export(); | 61 | $poche->export(); |
62 | } elseif (isset($_GET['updatetheme'])) { | ||
63 | $poche->updateTheme(); | ||
45 | } | 64 | } |
46 | elseif (isset($_GET['plainurl']) && !empty($_GET['plainurl'])) { | 65 | elseif (isset($_GET['plainurl']) && !empty($_GET['plainurl'])) { |
47 | $plain_url = new Url(base64_encode($_GET['plainurl'])); | 66 | $plain_url = new Url(base64_encode($_GET['plainurl'])); |
48 | $poche->action('add', $plain_url); | 67 | $poche->action('add', $plain_url); |
49 | } | 68 | } |
50 | 69 | ||
51 | # vars to send to templates | ||
52 | $tpl_vars = array( | ||
53 | 'lang' => Tools::getDocLanguage($poche->user->getConfigValue('language')), | ||
54 | 'referer' => $referer, | ||
55 | 'view' => $view, | ||
56 | 'poche_url' => Tools::getPocheUrl(), | ||
57 | 'title' => _('poche, a read it later open source system'), | ||
58 | 'token' => Session::getToken(), | ||
59 | ); | ||
60 | |||
61 | if (Session::isLogged()) { | 70 | if (Session::isLogged()) { |
62 | $poche->action($action, $url, $id); | 71 | $poche->action($action, $url, $id); |
63 | $tpl_file = Tools::getTplFile($view); | 72 | $tpl_file = Tools::getTplFile($view); |
64 | $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id)); | 73 | $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id)); |
65 | } | 74 | } else { |
66 | else { | 75 | $tpl_file = Tools::getTplFile('login'); |
67 | $tpl_file = 'login.twig'; | ||
68 | } | 76 | } |
69 | 77 | ||
70 | # because messages can be added in $poche->action(), we have to add this entry now (we can add it before) | 78 | # because messages can be added in $poche->action(), we have to add this entry now (we can add it before) |