From 2b840e0cfb63a453bea67a98541f3df9c273c5f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 3 Aug 2013 08:57:35 +0200 Subject: [PATCH] twig implementation --- inc/poche/pocheCore.php | 46 +++++++++++++++++++------------- index.php | 6 ++--- tpl/{config.html => config.twig} | 16 ++++++++++- tpl/footer.html | 7 ----- tpl/head.html | 42 ----------------------------- tpl/home.twig | 45 ++++++++++++++++++++++--------- tpl/install.twig | 2 +- tpl/js.html | 22 --------------- tpl/login.twig | 2 +- 9 files changed, 80 insertions(+), 108 deletions(-) rename tpl/{config.html => config.twig} (72%) delete mode 100644 tpl/footer.html delete mode 100644 tpl/head.html delete mode 100644 tpl/js.html diff --git a/inc/poche/pocheCore.php b/inc/poche/pocheCore.php index 3e32c4a8..9cbcc077 100644 --- a/inc/poche/pocheCore.php +++ b/inc/poche/pocheCore.php @@ -134,9 +134,35 @@ function fetch_url_content($url) return FALSE; } +function get_tpl_file($view) +{ + $tpl_file = 'home.twig'; + switch ($view) + { + case 'install': + $tpl_file = 'install.twig'; + break; + case 'import'; + $tpl_file = 'import.twig'; + break; + case 'export': + $tpl_file = 'export.twig'; + break; + case 'config': + $tpl_file = 'config.twig'; + break; + case 'view': + $tpl_file = 'view.twig'; + break; + default: + break; + } + return $tpl_file; +} + function display_view($view, $id = 0) { - global $tpl, $store; + global $store; $tpl_vars = array(); @@ -155,12 +181,6 @@ function display_view($view, $id = 0) pocheTools::logm('export view'); break; case 'config': - $tpl->assign('load_all_js', 0); - $tpl->draw('head'); - $tpl->draw('home'); - $tpl->draw('config'); - $tpl->draw('js'); - $tpl->draw('footer'); pocheTools::logm('config view'); break; case 'view': @@ -191,18 +211,6 @@ function display_view($view, $id = 0) $tpl_vars = array( 'entries' => $entries, ); - - // if ($full_head == 'yes') { - // $tpl->assign('load_all_js', 1); - // $tpl->draw('head'); - // $tpl->draw('home'); - // } - - // $tpl->draw('entries'); - // if ($full_head == 'yes') { - // $tpl->draw('js'); - // $tpl->draw('footer'); - // } break; } diff --git a/index.php b/index.php index f0a8aef4..81bd0174 100644 --- a/index.php +++ b/index.php @@ -15,7 +15,8 @@ $errors = array(); # XSRF protection with token if (!empty($_POST)) { if (!Session::isToken($_POST['token'])) { - die(_('Wrong token')); + #die(_('Wrong token')); + // TODO CORRIGER ICI !!! } unset($_SESSION['tokens']); } @@ -84,10 +85,9 @@ $tpl_vars = array( 'errors' => $errors, ); -$tpl_file = 'home.twig'; - if (Session::isLogged()) { action_to_do($action, $url, $id); + $tpl_file = get_tpl_file($view); $tpl_vars = array_merge($tpl_vars, display_view($view, $id)); } else { diff --git a/tpl/config.html b/tpl/config.twig similarity index 72% rename from tpl/config.html rename to tpl/config.twig index 2c7df4f7..10c481de 100644 --- a/tpl/config.html +++ b/tpl/config.twig @@ -1,3 +1,16 @@ +{% extends "layout.twig" %} + +{% block title %}{% trans "config" %}{% endblock %} +{% block menu %} + +{% endblock %} +{% block content %}

Bookmarklet

Thanks to the bookmarklet, you will be able to easily add a link to your poche. If you don't know how use a bookmarklet, have a look here.

@@ -24,4 +37,5 @@

Export

Click here to export your poche datas.

-
\ No newline at end of file + +{% endblock %} \ No newline at end of file diff --git a/tpl/footer.html b/tpl/footer.html deleted file mode 100644 index b8bd755c..00000000 --- a/tpl/footer.html +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/tpl/head.html b/tpl/head.html deleted file mode 100644 index dfb12788..00000000 --- a/tpl/head.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - {$title} - - - - - - - - - - - - \ No newline at end of file diff --git a/tpl/home.twig b/tpl/home.twig index 7b5b88a2..c79d4276 100644 --- a/tpl/home.twig +++ b/tpl/home.twig @@ -1,19 +1,18 @@ {% extends "layout.twig" %} - -{% block title %}Home{% endblock %} +{% block title %}{% trans "home" %}{% endblock %} {% block menu %} {% endblock %} {% block precontent %} {% endblock %} {% block content %} @@ -27,9 +26,9 @@
@@ -38,4 +37,26 @@ {% endfor %} +{% endblock %} + +{% block js %} + + + + {% endblock %} \ No newline at end of file diff --git a/tpl/install.twig b/tpl/install.twig index 4342df2e..8bcede0d 100644 --- a/tpl/install.twig +++ b/tpl/install.twig @@ -1,5 +1,5 @@ {% extends "layout.twig" %} -{% block title %}Installation{% endblock %} +{% block title %}{% trans "installation" %}{% endblock %} {% block content %}
diff --git a/tpl/js.html b/tpl/js.html deleted file mode 100644 index 3a51af6e..00000000 --- a/tpl/js.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - {if="$load_all_js == '1'"} - - - {/if} \ No newline at end of file diff --git a/tpl/login.twig b/tpl/login.twig index c95a5f02..d1080530 100644 --- a/tpl/login.twig +++ b/tpl/login.twig @@ -1,6 +1,6 @@ {% extends "layout.twig" %} -{% block title %}Login{% endblock %} +{% block title %}{% trans "login to your poche" %}{% endblock %} {% block messages %}
    -- 2.41.0