]>
Commit | Line | Data |
---|---|---|
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 | include dirname(__FILE__).'/inc/poche/config.inc.php'; | |
12 | ||
13 | # Parse GET & REFERER vars | |
14 | $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; | |
15 | $view = Tools::checkVar('view', 'home'); | |
16 | $action = Tools::checkVar('action'); | |
17 | $id = Tools::checkVar('id'); | |
18 | $_SESSION['sort'] = Tools::checkVar('sort', 'id'); | |
19 | $url = new Url((isset ($_GET['url'])) ? $_GET['url'] : ''); | |
20 | ||
21 | # poche actions | |
22 | if (isset($_GET['login'])) { | |
23 | # hello you | |
24 | $poche->login($referer); | |
25 | } | |
26 | elseif (isset($_GET['logout'])) { | |
27 | # see you soon ! | |
28 | $poche->logout(); | |
29 | } | |
30 | elseif (isset($_GET['config'])) { | |
31 | # Update password | |
32 | $poche->updatePassword(); | |
33 | } | |
34 | elseif (isset($_GET['import'])) { | |
35 | $import = $poche->import($_GET['from']); | |
36 | } | |
37 | elseif (isset($_GET['export'])) { | |
38 | $poche->export(); | |
39 | } | |
40 | ||
41 | # vars to send to templates | |
42 | $tpl_vars = array( | |
43 | 'referer' => $referer, | |
44 | 'view' => $view, | |
45 | 'poche_url' => Tools::getPocheUrl(), | |
46 | 'title' => _('poche, a read it later open source system'), | |
47 | 'token' => Session::getToken(), | |
48 | ); | |
49 | ||
50 | if (Session::isLogged()) { | |
51 | $poche->action($action, $url, $id); | |
52 | $tpl_file = Tools::getTplFile($view); | |
53 | $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id)); | |
54 | } | |
55 | else { | |
56 | $tpl_file = 'login.twig'; | |
57 | } | |
58 | ||
59 | # because messages can be added in $poche->action(), we have to add this entry now (we can add it before) | |
60 | $messages = $poche->messages->display('all', FALSE); | |
61 | $tpl_vars = array_merge($tpl_vars, array('messages' => $messages)); | |
62 | ||
63 | # display poche | |
64 | echo $poche->tpl->render($tpl_file, $tpl_vars); |