From 2e2ebe5ec767dcbee90394d12b03298592c87805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 13:15:06 +0100 Subject: [PATCH] [add] create tags page --- inc/poche/Database.class.php | 14 +++++++++++--- inc/poche/Poche.class.php | 6 ++++++ inc/poche/Tools.class.php | 5 +++-- themes/default/_menu.twig | 1 + themes/default/tags.twig | 8 ++++++++ 5 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 themes/default/tags.twig diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index 86907e5..8e9ee0b 100644 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php @@ -250,13 +250,21 @@ class Database { return $this->getHandle()->lastInsertId($column); } + public function retrieveAllTags() { + $sql = "SELECT * FROM tags"; + $query = $this->executeQuery($sql, array()); + $tags = $query->fetchAll(); + + return $tags; + } + public function retrieveTagsByEntry($entry_id) { - $sql = + $sql = "SELECT * FROM tags LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id WHERE tags_entries.entry_id = ?"; - $query = $this->executeQuery($sql, array($entry_id)); - $tags = $query->fetchAll(); + $query = $this->executeQuery($sql, array($entry_id)); + $tags = $query->fetchAll(); return $tags; } diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index c9fb638..802ec54 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -430,6 +430,12 @@ class Poche ); Tools::logm('config view'); break; + case 'tags': + $tags = $this->store->retrieveAllTags(); + $tpl_vars = array( + 'tags' => $tags, + ); + break; case 'view': $entry = $this->store->retrieveOneById($id, $this->user->getId()); if ($entry != NULL) { diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 750553f..5bb65fe 100644 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php @@ -103,14 +103,15 @@ class Tools case 'config': $tpl_file = 'config.twig'; break; + case 'tags': + $tpl_file = 'tags.twig'; + break; case 'view': $tpl_file = 'view.twig'; break; - case 'login': $tpl_file = 'login.twig'; break; - case 'error': $tpl_file = 'error.twig'; break; diff --git a/themes/default/_menu.twig b/themes/default/_menu.twig index 699d6a0..02bec1d 100644 --- a/themes/default/_menu.twig +++ b/themes/default/_menu.twig @@ -2,6 +2,7 @@
  • {% trans "home" %}
  • {% trans "favorites" %}
  • {% trans "archive" %}
  • +
  • {% trans "tags" %}
  • {% trans "config" %}
  • {% trans "logout" %}
  • \ No newline at end of file diff --git a/themes/default/tags.twig b/themes/default/tags.twig new file mode 100644 index 0000000..9421fe3 --- /dev/null +++ b/themes/default/tags.twig @@ -0,0 +1,8 @@ +{% extends "layout.twig" %} +{% block title %}tags{% endblock %} +{% block menu %} +{% include '_menu.twig' %} +{% endblock %} +{% block content %} +{% for tag in tags %}{{ tag.value }} {% endfor %} +{% endblock %} \ No newline at end of file