1
0
mirror of https://github.com/moparisthebest/wallabag synced 2024-12-25 00:38:51 -05:00

implemented ?random url

This commit is contained in:
Thomas Citharel 2014-12-22 16:19:29 +01:00
parent f3917b1ee4
commit e51487f932
2 changed files with 9 additions and 2 deletions

View File

@ -303,6 +303,14 @@ class Poche
$this->messages->add('s', _('The tag has been successfully deleted'));
Tools::redirect();
break;
/* 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':
$count = $this->store->getEntriesByViewCount($view, $this->user->getId());
$id = rand(1,$count);
Tools::logm('get a random article');
Tools::redirect('?view=view&id=' . $id);
//$this->displayView('view', $id);
break;
default:
break;
}
@ -445,7 +453,6 @@ class Poche
$tpl_vars['entries'] = $this->store->getEntriesByView($view, $this->user->getId(), $this->pagination->get_limit(), $id);
$tpl_vars['page_links'] = $page_links;
$tpl_vars['nb_results'] = $count;
$tpl_vars['random'] = rand(1,$count);
}
Tools::logm('display ' . $view . ' view');
break;

View File

@ -25,7 +25,7 @@
{% block pager %}
{% if nb_results > 1 %}
<div class="results">
<div class="nb-results">{{ nb_results }} {% trans "results" %}{% if search_term is defined %} {% trans %}found for « {{ search_term }} »{% endtrans %}{% endif %} <span class="icon icon-random"><a href="?view=view&id={{ random }}"> {% trans "random" %}</span></div>
<div class="nb-results">{{ nb_results }} {% trans "results" %}{% if search_term is defined %} {% trans %}found for « {{ search_term }} »{% endtrans %}{% endif %} <span class="icon icon-random"><a href="?action=random"> {% trans "random" %}</span></div>
{{ page_links | raw }}
</div>
{% elseif nb_results == 1 %}