]> git.immae.eu Git - github/wallabag/wallabag.git/blame - index.php
Fix #255 : increase article toolbar height if necessary
[github/wallabag/wallabag.git] / index.php
CommitLineData
1a268ba7
NL
1<?php
2/**
3 * poche, a read it later open source system
4 *
5 * @category poche
421b65eb 6 * @author Nicolas Lœuillet <support@inthepoche.com>
1a268ba7
NL
7 * @copyright 2013
8 * @license http://www.wtfpl.net/ see COPYING file
9 */
10
00dbaf90 11require_once 'inc/poche/global.inc.php';
bb5a7d9e 12
00dbaf90
NL
13# Start Poche
14$poche = new Poche();
15$notInstalledMessage = $poche -> getNotInstalledMessage();
1a268ba7 16
ed06f040 17# Parse GET & REFERER vars
a4565e88 18$referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
7f959169 19$view = Tools::checkVar('view', 'home');
63c35580
NL
20$action = Tools::checkVar('action');
21$id = Tools::checkVar('id');
f6df40db 22$_SESSION['sort'] = Tools::checkVar('sort', 'id');
63c35580 23$url = new Url((isset ($_GET['url'])) ? $_GET['url'] : '');
8c72b98d 24
00dbaf90
NL
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
35if (! 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
ed06f040 48# poche actions
a1953dff 49if (isset($_GET['login'])) {
4f5b44bd 50 # hello you
c765c367 51 $poche->login($referer);
00dbaf90 52} elseif (isset($_GET['logout'])) {
4f5b44bd 53 # see you soon !
c765c367 54 $poche->logout();
00dbaf90 55} elseif (isset($_GET['config'])) {
4f5b44bd 56 # Update password
c765c367 57 $poche->updatePassword();
00dbaf90 58} elseif (isset($_GET['import'])) {
07ee09f4 59 $import = $poche->import($_GET['from']);
00dbaf90 60} elseif (isset($_GET['export'])) {
63c35580 61 $poche->export();
00dbaf90
NL
62} elseif (isset($_GET['updatetheme'])) {
63 $poche->updateTheme();
63c35580 64}
ce4a1dcc
NL
65elseif (isset($_GET['plainurl']) && !empty($_GET['plainurl'])) {
66 $plain_url = new Url(base64_encode($_GET['plainurl']));
67 $poche->action('add', $plain_url);
68}
693b3f86 69
e4d2565e 70if (Session::isLogged()) {
eb1af592
NL
71 $poche->action($action, $url, $id);
72 $tpl_file = Tools::getTplFile($view);
73 $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id));
00dbaf90
NL
74} else {
75 $tpl_file = Tools::getTplFile('login');
8c72b98d 76}
a4565e88 77
55821e04 78# because messages can be added in $poche->action(), we have to add this entry now (we can add it before)
6a361945
NL
79$messages = $poche->messages->display('all', FALSE);
80$tpl_vars = array_merge($tpl_vars, array('messages' => $messages));
55821e04 81
ed06f040 82# display poche
eb1af592 83echo $poche->tpl->render($tpl_file, $tpl_vars);