aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche
diff options
context:
space:
mode:
Diffstat (limited to 'inc/poche')
-rwxr-xr-xinc/poche/Database.class.php17
-rwxr-xr-xinc/poche/Poche.class.php21
2 files changed, 22 insertions, 16 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php
index 9adb1644..6244df88 100755
--- a/inc/poche/Database.class.php
+++ b/inc/poche/Database.class.php
@@ -407,14 +407,15 @@ class Database {
407 public function getLastId($column = '') { 407 public function getLastId($column = '') {
408 return $this->getHandle()->lastInsertId($column); 408 return $this->getHandle()->lastInsertId($column);
409 } 409 }
410 410
411 public function search($term){ 411 public function search($term, $user_id, $limit = '') {
412 $search = '%'.$term.'%'; 412 $search = '%'.$term.'%';
413 $query = $this->getHandle()->prepare("SELECT * FROM entries WHERE content LIKE ? OR title LIKE ? OR url LIKE ?"); //searches in content, title and URL 413 $sql_action = "SELECT * FROM entries WHERE user_id=? AND (content LIKE ? OR title LIKE ? OR url LIKE ?) "; //searches in content, title and URL
414 $query->execute(array($search,$search,$search)); 414 $sql_action .= $this->getEntriesOrder().' ' . $limit;
415 $entries = $query->fetchAll(); 415 $params_action = array($user_id, $search, $search, $search);
416 return $entries; 416 $query = $this->executeQuery($sql_action, $params_action);
417 } 417 return $query->fetchAll();
418 }
418 419
419 public function retrieveAllTags($user_id, $term = null) { 420 public function retrieveAllTags($user_id, $term = null) {
420 $sql = "SELECT DISTINCT tags.*, count(entries.id) AS entriescount FROM tags 421 $sql = "SELECT DISTINCT tags.*, count(entries.id) AS entriescount FROM tags
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index d1b0c945..ee3b2ac2 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -597,14 +597,19 @@ class Poche
597 'tags' => $tags, 597 'tags' => $tags,
598 ); 598 );
599 break; 599 break;
600 600 case 'search':
601 case 'search': 601 if (isset($_GET['search'])) {
602 if (isset($_GET['search'])){ 602 $search = filter_var($_GET['search'], FILTER_SANITIZE_STRING);
603 $search = $_GET['search']; 603 $tpl_vars['entries'] = $this->store->search($search, $this->user->getId());
604 $tpl_vars['entries'] = $this->store->search($search); 604 $count = count($tpl_vars['entries']);
605 $tpl_vars['nb_results'] = count($tpl_vars['entries']); 605 $this->pagination->set_total($count);
606 } 606 $page_links = str_replace(array('previous', 'next'), array(_('previous'), _('next')),
607 break; 607 $this->pagination->page_links('?view=' . $view . '?search=' . $search . '&sort=' . $_SESSION['sort'] . '&' ));
608 $tpl_vars['page_links'] = $page_links;
609 $tpl_vars['nb_results'] = $count;
610 $tpl_vars['search_term'] = $search;
611 }
612 break;
608 case 'view': 613 case 'view':
609 $entry = $this->store->retrieveOneById($id, $this->user->getId()); 614 $entry = $this->store->retrieveOneById($id, $this->user->getId());
610 if ($entry != NULL) { 615 if ($entry != NULL) {