]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
implemented ?random url
authorThomas Citharel <tcit@tcit.fr>
Mon, 22 Dec 2014 15:19:29 +0000 (16:19 +0100)
committerThomas Citharel <tcit@tcit.fr>
Mon, 22 Dec 2014 15:19:29 +0000 (16:19 +0100)
inc/poche/Poche.class.php
themes/baggy/home.twig

index 2a8037cc27c142fff3a1424b561fd38517ce02dc..3c7a2c5a0ee55855cc410551761f9e338c8beb07 100755 (executable)
@@ -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;
index 5068f755a8c33fc202a914b1b3d20d9120c9b3f9..27eea422fcb11ddba8acfc86723ee39630f00df9 100755 (executable)
@@ -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 %}