mirror of
https://github.com/wallabag/wallabag.git
synced 2025-01-07 07:25:25 +00:00
fix for #1153, a couple of improvements and fixed bugs
This commit is contained in:
parent
ab87a7fe69
commit
f76dab12c9
3 changed files with 55 additions and 12 deletions
|
@ -411,10 +411,22 @@ class Database {
|
||||||
|
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
public function getRandomId($user_id) {
|
public function getRandomId($user_id, $view) {
|
||||||
$random = (STORAGE == 'mysql') ? 'RAND()' : 'RANDOM()';
|
$random = (STORAGE == 'mysql') ? 'RAND()' : 'RANDOM()';
|
||||||
$sql = "SELECT id FROM entries WHERE user_id=? ORDER BY ". $random . " LIMIT 1";
|
switch ($view) {
|
||||||
$params = array($user_id);
|
case 'archive':
|
||||||
|
$sql = "SELECT id FROM entries WHERE user_id=? AND is_read=? ORDER BY ". $random . " LIMIT 1";
|
||||||
|
$params = array($user_id,1);
|
||||||
|
break;
|
||||||
|
case 'fav':
|
||||||
|
$sql = "SELECT id FROM entries WHERE user_id=? AND is_fav=? ORDER BY ". $random . " LIMIT 1";
|
||||||
|
$params = array($user_id,1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$sql = "SELECT id FROM entries WHERE user_id=? AND is_read=? ORDER BY ". $random . " LIMIT 1";
|
||||||
|
$params = array($user_id,0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
$query = $this->executeQuery($sql, $params);
|
$query = $this->executeQuery($sql, $params);
|
||||||
$id = $query->fetchAll();
|
$id = $query->fetchAll();
|
||||||
|
|
||||||
|
|
|
@ -406,8 +406,9 @@ class Poche
|
||||||
/* For some unknown reason I can't get displayView() to work here (it redirects to home view afterwards). So here's a dirty fix which redirects directly to URL */
|
/* For some unknown reason I can't get displayView() to work here (it redirects to home view afterwards). So here's a dirty fix which redirects directly to URL */
|
||||||
case 'random':
|
case 'random':
|
||||||
Tools::logm('get a random article');
|
Tools::logm('get a random article');
|
||||||
if ($this->store->getRandomId($this->user->getId())) {
|
$view = $_GET['view'];
|
||||||
$id_array = $this->store->getRandomId($this->user->getId());
|
if ($this->store->getRandomId($this->user->getId(),$view)) {
|
||||||
|
$id_array = $this->store->getRandomId($this->user->getId(),$view);
|
||||||
$id = $id_array[0];
|
$id = $id_array[0];
|
||||||
Tools::redirect('?view=view&id=' . $id[0]);
|
Tools::redirect('?view=view&id=' . $id[0]);
|
||||||
Tools::logm('got the article with id ' . $id[0]);
|
Tools::logm('got the article with id ' . $id[0]);
|
||||||
|
@ -522,7 +523,7 @@ class Poche
|
||||||
$this->pagination->page_links('?view=' . $view . '?search=' . $search . '&sort=' . $_SESSION['sort'] . '&' ));
|
$this->pagination->page_links('?view=' . $view . '?search=' . $search . '&sort=' . $_SESSION['sort'] . '&' ));
|
||||||
$tpl_vars['page_links'] = $page_links;
|
$tpl_vars['page_links'] = $page_links;
|
||||||
$tpl_vars['nb_results'] = $count;
|
$tpl_vars['nb_results'] = $count;
|
||||||
$tpl_vars['searchterm'] = $search;
|
$tpl_vars['search_term'] = $search;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'view':
|
case 'view':
|
||||||
|
@ -578,6 +579,7 @@ class Poche
|
||||||
'page_links' => '',
|
'page_links' => '',
|
||||||
'nb_results' => '',
|
'nb_results' => '',
|
||||||
'listmode' => (isset($_COOKIE['listmode']) ? true : false),
|
'listmode' => (isset($_COOKIE['listmode']) ? true : false),
|
||||||
|
'view' => $view,
|
||||||
);
|
);
|
||||||
|
|
||||||
//if id is given - we retrieve entries by tag: id is tag id
|
//if id is given - we retrieve entries by tag: id is tag id
|
||||||
|
|
|
@ -15,8 +15,15 @@
|
||||||
{% if tag %}
|
{% if tag %}
|
||||||
<h3>{% trans "Tag" %}: <b>{{ tag.value }}</b></h3>
|
<h3>{% trans "Tag" %}: <b>{{ tag.value }}</b></h3>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if entries is empty %}
|
{% if entries is empty%}
|
||||||
<div class="messages warning"><p>{% trans "No articles found." %}</p></div>
|
<div class="messages warning"><p>
|
||||||
|
{% if view == 'home' %}{% trans "No articles unread. Good job !" %}
|
||||||
|
{% elseif view == 'fav' %}{% trans "No articles favourited" %}
|
||||||
|
{% elseif view == 'archive' %}{% trans "No articles marked as read" %}
|
||||||
|
{% elseif view == 'tags' %}{% trans "No articles with this tag found" %}
|
||||||
|
{% elseif search_term is defined %} {% trans %}No articles found for « {{ search_term }} »{% endtrans %}
|
||||||
|
{% else %}{% trans "No articles found" %}{% endif %}
|
||||||
|
</p></div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div>
|
<div>
|
||||||
{% include '_display-mode.twig' %}
|
{% include '_display-mode.twig' %}
|
||||||
|
@ -25,15 +32,35 @@
|
||||||
{% block pager %}
|
{% block pager %}
|
||||||
{% if nb_results > 1 %}
|
{% if nb_results > 1 %}
|
||||||
<div class="results">
|
<div class="results">
|
||||||
<div class="nb-results">{{ nb_results }} {% trans "results" %}{% if search_term is defined %} {% trans %}found for « {{ search_term }} »{% endtrans %}{% endif %} <a href="?action=random" class="icon icon-random"><span> {% trans "random" %}</span></a></div>
|
<div class="nb-results">
|
||||||
|
{% if view == 'home' %}
|
||||||
|
{{ nb_results }} {% trans "articles unread" %}
|
||||||
|
{% elseif view == 'fav' %}
|
||||||
|
{{ nb_results }} {% trans "articles favourited" %}
|
||||||
|
{% elseif view == 'archive' %}
|
||||||
|
{{ nb_results }} {% trans "articles marked as read" %}
|
||||||
|
{% elseif view == 'tag' %}
|
||||||
|
{{ nb_results }} {% trans "articles with this tag" %}
|
||||||
|
{% elseif search_term is defined %}{{ nb_results }}
|
||||||
|
{% trans %}articles found for « {{ search_term }} »{% endtrans %}
|
||||||
|
{% else %}
|
||||||
|
{{ nb_results }} {% trans "articles" %}
|
||||||
|
{% endif %}
|
||||||
|
{% if view == 'home' or view == 'fav' or view == 'archive' %}
|
||||||
|
<a href="?action=random&view={{ view }}" class="icon icon-random"><span> {% trans "random" %}</span></a>{% endif %}
|
||||||
|
</div>
|
||||||
{{ page_links | raw }}
|
{{ page_links | raw }}
|
||||||
</div>
|
</div>
|
||||||
{% elseif nb_results == 1 %}
|
{% elseif nb_results == 1 %}
|
||||||
{% if search_term is defined %}
|
|
||||||
<div class="results">
|
<div class="results">
|
||||||
<div class="nb-results">{% trans "Only one result found for " %} « {{ search_term }} »</div>
|
<div class="nb-results">
|
||||||
|
{% if view == 'home' %}{% trans "Only one article unread. Way to go !" %}
|
||||||
|
{% elseif view == 'fav' %}{% trans "Just one article favourited" %}
|
||||||
|
{% elseif view == 'archive' %}{% trans "One article marked as read" %}
|
||||||
|
{% elseif view == 'tag' %}{% trans "One article with this tag" %}
|
||||||
|
{% elseif search_term is defined %}{% trans %}Only one result found for « {{ search_term }} »{% endtrans %}
|
||||||
|
{% else %}{% trans "One article found" %}{% endif %}</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
<div id="list-entries" class="list-entries">
|
<div id="list-entries" class="list-entries">
|
||||||
|
@ -64,6 +91,7 @@
|
||||||
|
|
||||||
{% if tag %}<a title="{% trans "Mark all articles from this tag as read" %}" href="./?action=toggle_archive&tag_id={{ tag.id }}">{% trans "Mark all articles from this tag as read" %}</a><br />{% endif %}
|
{% if tag %}<a title="{% trans "Mark all articles from this tag as read" %}" href="./?action=toggle_archive&tag_id={{ tag.id }}">{% trans "Mark all articles from this tag as read" %}</a><br />{% endif %}
|
||||||
|
|
||||||
|
{% if entries is not empty %}
|
||||||
{% if tag %}
|
{% if tag %}
|
||||||
{% if constant('EPUB') == 1 %}<a title="{% trans "Download the articles from this tag in an epub file" %}" href="./?epub&method=tag&value={{ tag.value }}">{% trans "Download as ePub3" %}</a>{% endif %}
|
{% if constant('EPUB') == 1 %}<a title="{% trans "Download the articles from this tag in an epub file" %}" href="./?epub&method=tag&value={{ tag.value }}">{% trans "Download as ePub3" %}</a>{% endif %}
|
||||||
{% if constant('MOBI') == 1 %}<a title="{% trans "Download the articles from this tag in a mobi file" %}" href="./?mobi&method=tag&value={{ tag.value }}">{% trans "Download as Mobi" %}</a>{% endif %}
|
{% if constant('MOBI') == 1 %}<a title="{% trans "Download the articles from this tag in a mobi file" %}" href="./?mobi&method=tag&value={{ tag.value }}">{% trans "Download as Mobi" %}</a>{% endif %}
|
||||||
|
@ -77,5 +105,6 @@
|
||||||
{% if constant('MOBI') == 1 %}<a title="{% trans "Download the articles from this category in a mobi file" %}" href="./?mobi&method=category&value={{ view }}">{% trans "Download as Mobi" %}</a>{% endif %}
|
{% if constant('MOBI') == 1 %}<a title="{% trans "Download the articles from this category in a mobi file" %}" href="./?mobi&method=category&value={{ view }}">{% trans "Download as Mobi" %}</a>{% endif %}
|
||||||
{% if constant('PDF') == 1 %}<a title="{% trans "Download the articles from this category in a pdf file" %}" href="./?pdf&method=category&value={{ view }}">{% trans "Download as PDF" %}</a>{% endif %}
|
{% if constant('PDF') == 1 %}<a title="{% trans "Download the articles from this category in a pdf file" %}" href="./?pdf&method=category&value={{ view }}">{% trans "Download as PDF" %}</a>{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue