import without cron

This commit is contained in:
Maryana Rozhankivska 2014-04-02 22:33:06 +03:00
commit a4585f7eaa
10 changed files with 61 additions and 48 deletions

View file

@ -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

View file

@ -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) {

View file

@ -24,7 +24,7 @@ if (isset($_GET['clean'])) {
if (isset($_POST['download'])) {
if (!file_put_contents("cache/vendor.zip", fopen("http://static.wallabag.org/files/vendor.zip", 'r'))) {
$errors[] = 'Impossible to download vendor.zip. Please <a href="http://wllbg.org/vendor">download it manually<∕a> and unzip it in your wallabag folder.';
$errors[] = 'Impossible to download vendor.zip. Please <a href="http://wllbg.org/vendor">download it manually</a> and unzip it in your wallabag folder.';
}
else {
if (extension_loaded('zip')) {
@ -165,7 +165,7 @@ else if (isset($_POST['install'])) {
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=10">
<![endif]-->
<title>wallabag — installation</title>
<title>wallabag - installation</title>
<link rel="shortcut icon" type="image/x-icon" href="themes/baggy/img/favicon.ico" />
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="themes/baggy/img/apple-touch-icon-144x144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="themes/baggy/img/apple-touch-icon-72x72-precomposed.png">
@ -176,7 +176,7 @@ else if (isset($_POST['install'])) {
<link rel="stylesheet" href="themes/baggy/css/main.css" media="all">
<link rel="stylesheet" href="themes/baggy/css/messages.css" media="all">
<link rel="stylesheet" href="themes/baggy/css/print.css" media="print">
<script src="themes/baggy/js/jquery-2.0.3.min.js"></script>
<script src="themes/default/js/jquery-2.0.3.min.js"></script>
<script src="themes/baggy/js/init.js"></script>
</head>
<body>

27
themes/baggy/config.twig Normal file → Executable file
View file

@ -105,37 +105,20 @@
{% endif %}
<h2>{% trans "Import" %}</h2>
<p>{% trans "Importing from other services can be quite long, and webservers default configuration often prevents long scripts execution time, so it must be done in multiple parts." %}</p>
<p>1. {% trans "First, select the export file on your computer and upload it." %}</p>
<form method="post" action="?uploadfile" name="uploadfile" enctype="multipart/form-data">
<p>{% trans "You can import your Pocket, Readability, Instapaper, Wallabag or any data in appropriate json or html format." %}</p>
<p>{% trans "Please select export file on your computer:" %}</p>
<form method="post" action="?import" name="uploadfile" enctype="multipart/form-data">
<fieldset class="w500p">
<div class="row">
<label class="col w150p" for="file">{% trans "File:" %}</label>
<input class="col" type="file" id="file" name="file" tabindex="4">
</div>
<div class="row mts txtcenter">
<button class="bouton" type="submit" tabindex="4">{% trans "Upload" %}</button>
<button class="bouton" type="submit" tabindex="4">{% trans "Import" %}</button>
</div>
</fieldset>
<input type="hidden" name="MAX_FILE_SIZE" value="1048576">
<input type="hidden" name="returnurl" value="{{ referer }}">
</form>
<p>2. {% trans "Then, click on the right link below." %}</p>
<ul>
<li><a href="./?import&amp;from=pocket">{% trans "Import from Pocket" %}</a> {{ '(after uploaded %s file)'|trans|format(constant('POCKET_FILE')) }}</li>
<li><a href="./?import&amp;from=readability">{% trans "Import from Readability" %}</a> {{ '(after uploaded %s file)'|trans|format(constant('READABILITY_FILE')) }}</li>
<li><a href="./?import&amp;from=instapaper">{% trans "Import from Instapaper" %}</a> {{ '(after uploaded %s file)'|trans|format(constant('INSTAPAPER_FILE')) }}</li>
<li><a href="./?import&amp;from=poche">{% trans "Import from wallabag" %}</a> {{ '(after uploaded %s file)'|trans|format(constant('POCHE_FILE')) }}</li>
</ul>
{% if token == '' %}
<p>{% trans "3. Your feed token is currently empty and must first be generated to fetch content. Click <a href='?feed&amp;action=generate'>here to generate it</a>." %}</p>
{% else %}
<p>3. {% trans "Finally, you have to fetch content for imported items." %} <a href="cron.php?limit=10&amp;user-id={{ user_id }}&amp;token={{token}}" target="_blank">{% trans "Click here" %}</a> {% trans "to fetch content for 10 articles" %}.</p>
<p>{% trans "If you have console access to your server, you can also create a cron task:" %}</p>
<pre><code>0 */4 * * * cd /path/to/wallabag && php cron.php --limit=10 --user-id={{user_id}} --token={{token}} >/dev/null 2>&1</code></pre>
{% endif %}
<h2>{% trans "Export your wallabag data" %}</h2>
{% if constant('STORAGE') == 'sqlite' %}
<p><a href="?download" target="_blank">{% trans "Click here" %}</a> {% trans "to download your database." %}</p>{% endif %}

View file

@ -777,7 +777,7 @@ margin-top:1em;
}
.warning {
font-size: 3em;
/* font-size: 3em;
color: #999;
font-style: italic;
position: absolute;
@ -786,7 +786,10 @@ margin-top:1em;
width: 100%;
text-align: center;
padding-right: 5%;
margin-top: -2em;
margin-top: -2em;*/
font-weight: bold;
display: block;
width: 100%;
}
/* ==========================================================================

View file

@ -25,9 +25,15 @@
{% block pager %}
{% if nb_results > 1 %}
<div class="results">
<div class="nb-results">{{ nb_results }} {% trans "results" %}</div>
<div class="nb-results">{{ nb_results }} {% trans "results" %}{% if search_term is defined %}{% trans " found for « " %} {{ search_term }} »{% endif %}</div>
{{ page_links | raw }}
</div>
{% elseif nb_results == 1 %}
{% if search_term is defined %}
<div class="results">
<div class="nb-results">{% trans "Only one result found for " %} « {{ search_term }} »</div>
</div>
{% endif %}
{% endif %}
{% endblock %}
<div id="list-entries" class="list-entries">

3
themes/baggy/layout.twig Normal file → Executable file
View file

@ -21,6 +21,9 @@
{% block precontent %}{% endblock %}
{% block messages %}
{% include '_messages.twig' %}
{% if includeImport %}
{% include '_import.twig' %}
{% endif %}
{% endblock %}
<div id="content" class="w600p center">
{% block content %}{% endblock %}

View file

@ -26,9 +26,15 @@
{% block pager %}
{% if nb_results > 1 %}
<div class="results">
<div class="nb-results">{{ nb_results }} {% trans "results" %}</div>
<div class="nb-results">{{ nb_results }} {% trans "results" %}{% if search_term is defined %}{% trans " found for « " %} {{ search_term }} »{% endif %}</div>
{{ page_links | raw }}
</div>
{% elseif nb_results == 1 %}
{% if search_term is defined %}
<div class="results">
<div class="nb-results">{% trans "Only one result found for " %} « {{ search_term }} »</div>
</div>
{% endif %}
{% endif %}
{% endblock %}
{% for entry in entries %}

View file

@ -1,6 +1,6 @@
{% if entries|length > 1 %}
<ul id="sort">
<li><a href="./?sort=ia&amp;view={{ view }}&amp;id={{ id }}"><img src="{{ poche_url }}themes/{{ theme }}/img/{{ theme }}/top.png" alt="{% trans "by date asc" %}" title="{% trans "by date asc" %}" /></a> {% trans "by date" %} <a href="./?sort=id&amp;view={{ view }}&amp;id={{ id }}"><img src="{{ poche_url }}themes/{{ theme }}/img/{{ theme }}/down.png" alt="{% trans "by date desc" %}" title="{% trans "by date desc" %}" /></a></li>
<li><a href="./?sort=ta&amp;view={{ view }}&amp;id={{ id }}"><img src="{{ poche_url }}themes/{{ theme }}/img/{{ theme }}/top.png" alt="{% trans "by title asc" %}" title="{% trans "by title asc" %}" /></a> {% trans "by title" %} <a href="./?sort=td&amp;view={{ view }}&amp;id={{ id }}"><img src="{{ poche_url }}themes/{{ theme }}/img/{{ theme }}/down.png" alt="{% trans "by title desc" %}" title="{% trans "by title desc" %}" /></a></li>
<li><a href="./?sort=ia&amp;view={{ view }}{% if search_term is defined %}&amp;search={{ search_term }}{% endif %}&amp;id={{ id }}"><img src="{{ poche_url }}themes/{{ theme }}/img/{{ theme }}/top.png" alt="{% trans "by date asc" %}" title="{% trans "by date asc" %}" /></a> {% trans "by date" %} <a href="./?sort=id&amp;view={{ view }}{% if search_term is defined %}&amp;search={{ search_term }}{% endif %}&amp;id={{ id }}"><img src="{{ poche_url }}themes/{{ theme }}/img/{{ theme }}/down.png" alt="{% trans "by date desc" %}" title="{% trans "by date desc" %}" /></a></li>
<li><a href="./?sort=ta&amp;view={{ view }}{% if search_term is defined %}&amp;search={{ search_term }}{% endif %}&amp;id={{ id }}"><img src="{{ poche_url }}themes/{{ theme }}/img/{{ theme }}/top.png" alt="{% trans "by title asc" %}" title="{% trans "by title asc" %}" /></a> {% trans "by title" %} <a href="./?sort=td&amp;view={{ view }}{% if search_term is defined %}&amp;search={{ search_term }}{% endif %}&amp;id={{ id }}"><img src="{{ poche_url }}themes/{{ theme }}/img/{{ theme }}/down.png" alt="{% trans "by title desc" %}" title="{% trans "by title desc" %}" /></a></li>
</ul>
{% endif %}

View file

@ -31,9 +31,15 @@
{% block pager %}
{% if nb_results > 1 %}
<div class="results">
<div class="nb-results">{{ nb_results }} {% trans "results" %}</div>
<div class="nb-results">{{ nb_results }} {% trans "results" %}{% if search_term is defined %}{% trans " found for « " %} {{ search_term }} »{% endif %}</div>
{{ page_links | raw }}
</div>
{% elseif nb_results == 1 %}
{% if search_term is defined %}
<div class="results">
<div class="nb-results">{% trans "Only one result found for " %} « {{ search_term }} »</div>
</div>
{% endif %}
{% endif %}
{% endblock %}
{% for entry in entries %}