diff options
author | Maryana Rozhankivska <mariroz@mr.lviv.ua> | 2014-03-10 16:28:47 +0200 |
---|---|---|
committer | Maryana Rozhankivska <mariroz@mr.lviv.ua> | 2014-03-10 16:28:47 +0200 |
commit | fb26cc9375ce9ef8df748eb473eb6e58884421c6 (patch) | |
tree | 3b1ac9bf4b1eb95c4ca91c02b447350516b8ad84 /inc/poche/Database.class.php | |
parent | 17b2afefad1947042cc9fbbb841c3a023d00d96d (diff) | |
download | wallabag-fb26cc9375ce9ef8df748eb473eb6e58884421c6.tar.gz wallabag-fb26cc9375ce9ef8df748eb473eb6e58884421c6.tar.zst wallabag-fb26cc9375ce9ef8df748eb473eb6e58884421c6.zip |
a lot of enhancements related to tags: tags list is now sorted, shows number of articles, autocomplete added according to #477, #542
Diffstat (limited to 'inc/poche/Database.class.php')
-rwxr-xr-x | inc/poche/Database.class.php | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index edc775f5..5b51b507 100755 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php | |||
@@ -389,12 +389,15 @@ class Database { | |||
389 | return $this->getHandle()->lastInsertId($column); | 389 | return $this->getHandle()->lastInsertId($column); |
390 | } | 390 | } |
391 | 391 | ||
392 | public function retrieveAllTags($user_id) { | 392 | public function retrieveAllTags($user_id, $term = null) { |
393 | $sql = "SELECT DISTINCT tags.* FROM tags | 393 | $sql = "SELECT DISTINCT tags.*, count(entries.id) AS entriescount FROM tags |
394 | LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id | 394 | LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id |
395 | LEFT JOIN entries ON tags_entries.entry_id=entries.id | 395 | LEFT JOIN entries ON tags_entries.entry_id=entries.id |
396 | WHERE entries.content <> '' AND entries.user_id=?"; | 396 | WHERE entries.content <> '' AND entries.user_id=? |
397 | $query = $this->executeQuery($sql, array($user_id)); | 397 | ". (($term) ? "AND lower(tags.value) LIKE ?" : '') ." |
398 | GROUP BY tags.id, tags.value | ||
399 | ORDER BY tags.value"; | ||
400 | $query = $this->executeQuery($sql, (($term)? array($user_id, strtolower('%'.$term.'%')) : array($user_id) )); | ||
398 | $tags = $query->fetchAll(); | 401 | $tags = $query->fetchAll(); |
399 | 402 | ||
400 | return $tags; | 403 | return $tags; |