forked from wallabag/wallabag
Implemented rudimental search engine
This commit is contained in:
@ -388,6 +388,14 @@ 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 ?");
|
||||
$query->execute(array($search));
|
||||
$entries = $query->fetchAll();
|
||||
return $entries;
|
||||
}
|
||||
|
||||
public function retrieveAllTags($user_id, $term = null) {
|
||||
$sql = "SELECT DISTINCT tags.*, count(entries.id) AS entriescount FROM tags
|
||||
|
||||
@ -603,6 +603,14 @@ class Poche
|
||||
'tags' => $tags,
|
||||
);
|
||||
break;
|
||||
|
||||
case 'search':
|
||||
if (isset($_POST['search'])){
|
||||
$search = $_POST['search'];
|
||||
$tpl_vars['entries'] = $this->store->search($search);
|
||||
$tpl_vars['nb_results'] = count($tpl_vars['entries']);
|
||||
}
|
||||
break;
|
||||
case 'view':
|
||||
$entry = $this->store->retrieveOneById($id, $this->user->getId());
|
||||
if ($entry != NULL) {
|
||||
@ -772,8 +780,7 @@ class Poche
|
||||
$this->emptyCache();
|
||||
|
||||
Tools::redirect('?view=config');
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* get credentials from differents sources
|
||||
* it redirects the user to the $referer link
|
||||
|
||||
@ -38,7 +38,7 @@ if (! file_exists(ROOT . '/vendor/autoload.php')) {
|
||||
require_once ROOT . '/vendor/autoload.php';
|
||||
}
|
||||
|
||||
# system configuration; database credentials et cetera
|
||||
# system configuration; database credentials et caetera
|
||||
if (! file_exists(INCLUDES . '/poche/config.inc.php')) {
|
||||
Poche::$configFileAvailable = false;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user