forked from wallabag/wallabag
import without cron
This commit is contained in:
@ -407,14 +407,15 @@ class Database {
|
||||
public function getLastId($column = '') {
|
||||
return $this->getHandle()->lastInsertId($column);
|
||||
}
|
||||
|
||||
public function search($term){
|
||||
$search = '%'.$term.'%';
|
||||
$query = $this->getHandle()->prepare("SELECT * FROM entries WHERE content LIKE ? OR title LIKE ? OR url LIKE ?"); //searches in content, title and URL
|
||||
$query->execute(array($search,$search,$search));
|
||||
$entries = $query->fetchAll();
|
||||
return $entries;
|
||||
}
|
||||
|
||||
public function search($term, $user_id, $limit = '') {
|
||||
$search = '%'.$term.'%';
|
||||
$sql_action = "SELECT * FROM entries WHERE user_id=? AND (content LIKE ? OR title LIKE ? OR url LIKE ?) "; //searches in content, title and URL
|
||||
$sql_action .= $this->getEntriesOrder().' ' . $limit;
|
||||
$params_action = array($user_id, $search, $search, $search);
|
||||
$query = $this->executeQuery($sql_action, $params_action);
|
||||
return $query->fetchAll();
|
||||
}
|
||||
|
||||
public function retrieveAllTags($user_id, $term = null) {
|
||||
$sql = "SELECT DISTINCT tags.*, count(entries.id) AS entriescount FROM tags
|
||||
|
||||
@ -597,14 +597,19 @@ class Poche
|
||||
'tags' => $tags,
|
||||
);
|
||||
break;
|
||||
|
||||
case 'search':
|
||||
if (isset($_GET['search'])){
|
||||
$search = $_GET['search'];
|
||||
$tpl_vars['entries'] = $this->store->search($search);
|
||||
$tpl_vars['nb_results'] = count($tpl_vars['entries']);
|
||||
}
|
||||
break;
|
||||
case 'search':
|
||||
if (isset($_GET['search'])) {
|
||||
$search = filter_var($_GET['search'], FILTER_SANITIZE_STRING);
|
||||
$tpl_vars['entries'] = $this->store->search($search, $this->user->getId());
|
||||
$count = count($tpl_vars['entries']);
|
||||
$this->pagination->set_total($count);
|
||||
$page_links = str_replace(array('previous', 'next'), array(_('previous'), _('next')),
|
||||
$this->pagination->page_links('?view=' . $view . '?search=' . $search . '&sort=' . $_SESSION['sort'] . '&' ));
|
||||
$tpl_vars['page_links'] = $page_links;
|
||||
$tpl_vars['nb_results'] = $count;
|
||||
$tpl_vars['search_term'] = $search;
|
||||
}
|
||||
break;
|
||||
case 'view':
|
||||
$entry = $this->store->retrieveOneById($id, $this->user->getId());
|
||||
if ($entry != NULL) {
|
||||
|
||||
Reference in New Issue
Block a user