mirror of
https://github.com/moparisthebest/wallabag
synced 2024-11-27 11:22:17 -05:00
Implemented rudimental search engine
This commit is contained in:
parent
028e34b6c4
commit
a33a3d2afb
@ -389,6 +389,14 @@ class Database {
|
|||||||
return $this->getHandle()->lastInsertId($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) {
|
public function retrieveAllTags($user_id, $term = null) {
|
||||||
$sql = "SELECT DISTINCT tags.*, count(entries.id) AS entriescount FROM tags
|
$sql = "SELECT DISTINCT tags.*, count(entries.id) AS entriescount FROM tags
|
||||||
LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id
|
LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id
|
||||||
|
@ -603,6 +603,14 @@ class Poche
|
|||||||
'tags' => $tags,
|
'tags' => $tags,
|
||||||
);
|
);
|
||||||
break;
|
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':
|
case 'view':
|
||||||
$entry = $this->store->retrieveOneById($id, $this->user->getId());
|
$entry = $this->store->retrieveOneById($id, $this->user->getId());
|
||||||
if ($entry != NULL) {
|
if ($entry != NULL) {
|
||||||
@ -773,7 +781,6 @@ class Poche
|
|||||||
|
|
||||||
Tools::redirect('?view=config');
|
Tools::redirect('?view=config');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get credentials from differents sources
|
* get credentials from differents sources
|
||||||
* it redirects the user to the $referer link
|
* 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';
|
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')) {
|
if (! file_exists(INCLUDES . '/poche/config.inc.php')) {
|
||||||
Poche::$configFileAvailable = false;
|
Poche::$configFileAvailable = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
<li><a href="./?view=archive" {% if view == 'archive' %}class="current"{% endif %}>{% trans "archive" %}</a></li>
|
<li><a href="./?view=archive" {% if view == 'archive' %}class="current"{% endif %}>{% trans "archive" %}</a></li>
|
||||||
<li><a href="./?view=tags" {% if view == 'tags' %}class="current"{% endif %}>{% trans "tags" %}</a></li>
|
<li><a href="./?view=tags" {% if view == 'tags' %}class="current"{% endif %}>{% trans "tags" %}</a></li>
|
||||||
<li><a href="javascript: void(null);" id="pocheit">{% trans "save a link" %}</a><span id="pocheit-arrow"></span></li>
|
<li><a href="javascript: void(null);" id="pocheit">{% trans "save a link" %}</a><span id="pocheit-arrow"></span></li>
|
||||||
|
<li><a href="javascript: void(null);" id="search">{% trans "search" %}</a><span id="search-arrow"></span></li>
|
||||||
<li><a href="./?view=config" {% if view == 'config' %}class="current"{% endif %}>{% trans "config" %}</a></li>
|
<li><a href="./?view=config" {% if view == 'config' %}class="current"{% endif %}>{% trans "config" %}</a></li>
|
||||||
<li><a href="./?logout" title="{% trans "logout" %}">{% trans "logout" %}</a></li>
|
<li><a href="./?logout" title="{% trans "logout" %}">{% trans "logout" %}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -12,6 +12,28 @@
|
|||||||
{% include '_menu.twig' %}
|
{% include '_menu.twig' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block precontent %}
|
{% block precontent %}
|
||||||
|
<div id="search-form" class="messages info">
|
||||||
|
<form method="post" action="index.php?view=search">
|
||||||
|
<p>
|
||||||
|
<label>{% trans "Search" %}</label> : <input type="text" placeholder="{% trans "Enter your search here" %}" name="search" />
|
||||||
|
<input type="submit" value="{% trans "Search" %} !"></input>
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
$("#search-form").hide();
|
||||||
|
|
||||||
|
$("#search").click(function(){
|
||||||
|
$("#search-form").toggle();
|
||||||
|
$("#search").toggleClass("current");
|
||||||
|
$("#search-arrow").toggleClass("arrow-down");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
{% include '_sorting.twig' %}
|
{% include '_sorting.twig' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
Loading…
Reference in New Issue
Block a user