aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/poche/Database.class.php21
-rw-r--r--inc/poche/Poche.class.php8
-rw-r--r--inc/poche/Tools.class.php2
3 files changed, 30 insertions, 1 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php
index 8e9ee0b7..a89bce41 100644
--- a/inc/poche/Database.class.php
+++ b/inc/poche/Database.class.php
@@ -258,6 +258,27 @@ class Database {
258 return $tags; 258 return $tags;
259 } 259 }
260 260
261 public function retrieveTag($id) {
262 $tag = NULL;
263 $sql = "SELECT * FROM tags WHERE id=?";
264 $params = array(intval($id));
265 $query = $this->executeQuery($sql, $params);
266 $tag = $query->fetchAll();
267
268 return isset($tag[0]) ? $tag[0] : null;
269 }
270
271 public function retrieveEntriesByTag($tag_id) {
272 $sql =
273 "SELECT * FROM entries
274 LEFT JOIN tags_entries ON tags_entries.entry_id=entries.id
275 WHERE tags_entries.tag_id = ?";
276 $query = $this->executeQuery($sql, array($tag_id));
277 $entries = $query->fetchAll();
278
279 return $entries;
280 }
281
261 public function retrieveTagsByEntry($entry_id) { 282 public function retrieveTagsByEntry($entry_id) {
262 $sql = 283 $sql =
263 "SELECT * FROM tags 284 "SELECT * FROM tags
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 5d368842..fefbb02d 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -437,6 +437,14 @@ class Poche
437 'tags' => $tags, 437 'tags' => $tags,
438 ); 438 );
439 break; 439 break;
440 case 'tag':
441 $entries = $this->store->retrieveEntriesByTag($id);
442 $tag = $this->store->retrieveTag($id);
443 $tpl_vars = array(
444 'tag' => $tag,
445 'entries' => $entries,
446 );
447 break;
440 case 'tags': 448 case 'tags':
441 $tags = $this->store->retrieveAllTags(); 449 $tags = $this->store->retrieveAllTags();
442 $tpl_vars = array( 450 $tpl_vars = array(
diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php
index b0ef55f5..6da53023 100644
--- a/inc/poche/Tools.class.php
+++ b/inc/poche/Tools.class.php
@@ -90,7 +90,7 @@ class Tools
90 { 90 {
91 $views = array( 91 $views = array(
92 'install', 'import', 'export', 'config', 'tags', 92 'install', 'import', 'export', 'config', 'tags',
93 'edit-tags', 'view', 'login', 'error' 93 'edit-tags', 'view', 'login', 'error', 'tag'
94 ); 94 );
95 95
96 if (in_array($view, $views)) { 96 if (in_array($view, $views)) {