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