summaryrefslogtreecommitdiff
path: root/app/models/Entry.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-03-16 20:29:24 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-03-16 20:29:24 +0100
commit9daa4c14636ca6b70031344f812ac99947b3a2b0 (patch)
tree7a0ec97e6e3e99c0af588bda39e69207b511cff4 /app/models/Entry.php
parentc164e0b456a0642a7ef8e2c044b0f591b25c9d64 (diff)
Ajout champs de recherche + désactivation des raccourcis quand un input a le focus -> fix bugs #18 et #29
Diffstat (limited to 'app/models/Entry.php')
-rwxr-xr-xapp/models/Entry.php47
1 files changed, 36 insertions, 11 deletions
diff --git a/app/models/Entry.php b/app/models/Entry.php
index 8a1ee1449..b1d7b8880 100755
--- a/app/models/Entry.php
+++ b/app/models/Entry.php
@@ -229,12 +229,22 @@ class EntryDAO extends Model_pdo {
}
}
- public function listEntries ($mode, $order = 'high_to_low') {
+ public function listEntries ($mode, $search = false, $order = 'high_to_low') {
$where = '';
if ($mode == 'not_read') {
$where = ' WHERE is_read=0';
}
+ $values = array();
+ if ($search) {
+ $values[] = '%'.$search.'%';
+ if ($mode == 'not_read') {
+ $where = ' AND title LIKE ?';
+ } else {
+ $where = ' WHERE title LIKE ?';
+ }
+ }
+
if ($order == 'low_to_high') {
$order = ' DESC';
} else {
@@ -243,7 +253,7 @@ class EntryDAO extends Model_pdo {
$sql = 'SELECT COUNT(*) AS count FROM entry' . $where;
$stm = $this->bd->prepare ($sql);
- $stm->execute ();
+ $stm->execute ($values);
$res = $stm->fetchAll (PDO::FETCH_ASSOC);
$this->nbItems = $res[0]['count'];
@@ -254,17 +264,23 @@ class EntryDAO extends Model_pdo {
. ' ORDER BY date' . $order
. ' LIMIT ' . $deb . ', ' . $fin;
$stm = $this->bd->prepare ($sql);
- $stm->execute ();
+ $stm->execute ($values);
return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC));
}
- public function listFavorites ($mode, $order = 'high_to_low') {
+ public function listFavorites ($mode, $search = false, $order = 'high_to_low') {
$where = ' WHERE is_favorite=1';
if ($mode == 'not_read') {
$where .= ' AND is_read=0';
}
+ $values = array();
+ if ($search) {
+ $values[] = '%'.$search.'%';
+ $where = ' AND title LIKE ?';
+ }
+
if ($order == 'low_to_high') {
$order = ' DESC';
} else {
@@ -273,7 +289,7 @@ class EntryDAO extends Model_pdo {
$sql = 'SELECT COUNT(*) AS count FROM entry' . $where;
$stm = $this->bd->prepare ($sql);
- $stm->execute ();
+ $stm->execute ($values);
$res = $stm->fetchAll (PDO::FETCH_ASSOC);
$this->nbItems = $res[0]['count'];
@@ -290,17 +306,23 @@ class EntryDAO extends Model_pdo {
}
$stm = $this->bd->prepare ($sql);
- $stm->execute ();
+ $stm->execute ($values);
return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC));
}
- public function listByCategory ($cat, $mode, $order = 'high_to_low') {
+ public function listByCategory ($cat, $mode, $search = false, $order = 'high_to_low') {
$where = ' WHERE category=?';
if ($mode == 'not_read') {
$where .= ' AND is_read=0';
}
+ $values = array ($cat);
+ if ($search) {
+ $values[] = '%'.$search.'%';
+ $where = ' AND title LIKE ?';
+ }
+
if ($order == 'low_to_high') {
$order = ' DESC';
} else {
@@ -309,7 +331,6 @@ class EntryDAO extends Model_pdo {
$sql = 'SELECT COUNT(*) AS count FROM entry e INNER JOIN feed f ON e.id_feed = f.id' . $where;
$stm = $this->bd->prepare ($sql);
- $values = array ($cat);
$stm->execute ($values);
$res = $stm->fetchAll (PDO::FETCH_ASSOC);
$this->nbItems = $res[0]['count'];
@@ -322,19 +343,23 @@ class EntryDAO extends Model_pdo {
$stm = $this->bd->prepare ($sql);
- $values = array ($cat);
-
$stm->execute ($values);
return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC));
}
- public function listByFeed ($feed, $mode, $order = 'high_to_low') {
+ public function listByFeed ($feed, $mode, $search = false, $order = 'high_to_low') {
$where = ' WHERE id_feed=?';
if ($mode == 'not_read') {
$where .= ' AND is_read=0';
}
+ $values = array();
+ if ($search) {
+ $values[] = '%'.$search.'%';
+ $where = ' AND title LIKE ?';
+ }
+
if ($order == 'low_to_high') {
$order = ' DESC';
} else {