diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2014-03-10 18:14:43 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2014-03-10 18:14:43 +0100 |
commit | 1acd18510a8fc5b843bf793322ed79b249b195dc (patch) | |
tree | 8218a340193e2827e1c4b0a6117adf81344e7b43 /inc/poche/Database.class.php | |
parent | d47a05a9a5185e835d51341febc8257f5262ce03 (diff) | |
parent | fb26cc9375ce9ef8df748eb473eb6e58884421c6 (diff) | |
download | wallabag-1acd18510a8fc5b843bf793322ed79b249b195dc.tar.gz wallabag-1acd18510a8fc5b843bf793322ed79b249b195dc.tar.zst wallabag-1acd18510a8fc5b843bf793322ed79b249b195dc.zip |
Merge pull request #544 from mariroz/feature-tags-autocomplete
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; |