diff options
author | Maryana Rozhankivska <mariroz@mr.lviv.ua> | 2014-04-02 22:33:06 +0300 |
---|---|---|
committer | Maryana Rozhankivska <mariroz@mr.lviv.ua> | 2014-04-02 22:33:06 +0300 |
commit | a4585f7eaa74d5f705c1622ac2419ea1198a7aba (patch) | |
tree | e379b18cbd353a361e27696e222f178dfe257fa6 /inc/poche | |
parent | 182faf2696b38502d4784efc3f84f2f00290343f (diff) | |
parent | d967a1fa14237648fc63c44f6a28c9c077b3e1bc (diff) | |
download | wallabag-a4585f7eaa74d5f705c1622ac2419ea1198a7aba.tar.gz wallabag-a4585f7eaa74d5f705c1622ac2419ea1198a7aba.tar.zst wallabag-a4585f7eaa74d5f705c1622ac2419ea1198a7aba.zip |
import without cron
Diffstat (limited to 'inc/poche')
-rwxr-xr-x | inc/poche/Database.class.php | 17 | ||||
-rwxr-xr-x | inc/poche/Poche.class.php | 21 |
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) { |