aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xinc/poche/Database.class.php18
-rwxr-xr-xinc/poche/Poche.class.php8
-rwxr-xr-xthemes/baggy/home.twig41
3 files changed, 55 insertions, 12 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php
index 4f55a7fe..823f834c 100755
--- a/inc/poche/Database.class.php
+++ b/inc/poche/Database.class.php
@@ -411,10 +411,22 @@ class Database {
411 411
412 return $count; 412 return $count;
413 } 413 }
414 public function getRandomId($user_id) { 414 public function getRandomId($user_id, $view) {
415 $random = (STORAGE == 'mysql') ? 'RAND()' : 'RANDOM()'; 415 $random = (STORAGE == 'mysql') ? 'RAND()' : 'RANDOM()';
416 $sql = "SELECT id FROM entries WHERE user_id=? ORDER BY ". $random . " LIMIT 1"; 416 switch ($view) {
417 $params = array($user_id); 417 case 'archive':
418 $sql = "SELECT id FROM entries WHERE user_id=? AND is_read=? ORDER BY ". $random . " LIMIT 1";
419 $params = array($user_id,1);
420 break;
421 case 'fav':
422 $sql = "SELECT id FROM entries WHERE user_id=? AND is_fav=? ORDER BY ". $random . " LIMIT 1";
423 $params = array($user_id,1);
424 break;
425 default:
426 $sql = "SELECT id FROM entries WHERE user_id=? AND is_read=? ORDER BY ". $random . " LIMIT 1";
427 $params = array($user_id,0);
428 break;
429 }
418 $query = $this->executeQuery($sql, $params); 430 $query = $this->executeQuery($sql, $params);
419 $id = $query->fetchAll(); 431 $id = $query->fetchAll();
420 432
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 4ec724f9..1a5cbe6c 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -406,8 +406,9 @@ class Poche
406 /* 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 */ 406 /* 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 */
407 case 'random': 407 case 'random':
408 Tools::logm('get a random article'); 408 Tools::logm('get a random article');
409 if ($this->store->getRandomId($this->user->getId())) { 409 $view = $_GET['view'];
410 $id_array = $this->store->getRandomId($this->user->getId()); 410 if ($this->store->getRandomId($this->user->getId(),$view)) {
411 $id_array = $this->store->getRandomId($this->user->getId(),$view);
411 $id = $id_array[0]; 412 $id = $id_array[0];
412 Tools::redirect('?view=view&id=' . $id[0]); 413 Tools::redirect('?view=view&id=' . $id[0]);
413 Tools::logm('got the article with id ' . $id[0]); 414 Tools::logm('got the article with id ' . $id[0]);
@@ -522,7 +523,7 @@ class Poche
522 $this->pagination->page_links('?view=' . $view . '?search=' . $search . '&sort=' . $_SESSION['sort'] . '&' )); 523 $this->pagination->page_links('?view=' . $view . '?search=' . $search . '&sort=' . $_SESSION['sort'] . '&' ));
523 $tpl_vars['page_links'] = $page_links; 524 $tpl_vars['page_links'] = $page_links;
524 $tpl_vars['nb_results'] = $count; 525 $tpl_vars['nb_results'] = $count;
525 $tpl_vars['searchterm'] = $search; 526 $tpl_vars['search_term'] = $search;
526 } 527 }
527 break; 528 break;
528 case 'view': 529 case 'view':
@@ -578,6 +579,7 @@ class Poche
578 'page_links' => '', 579 'page_links' => '',
579 'nb_results' => '', 580 'nb_results' => '',
580 'listmode' => (isset($_COOKIE['listmode']) ? true : false), 581 'listmode' => (isset($_COOKIE['listmode']) ? true : false),
582 'view' => $view,
581 ); 583 );
582 584
583 //if id is given - we retrieve entries by tag: id is tag id 585 //if id is given - we retrieve entries by tag: id is tag id
diff --git a/themes/baggy/home.twig b/themes/baggy/home.twig
index 93d2815b..5f097f3f 100755
--- a/themes/baggy/home.twig
+++ b/themes/baggy/home.twig
@@ -15,8 +15,15 @@
15 {% if tag %} 15 {% if tag %}
16 <h3>{% trans "Tag" %}: <b>{{ tag.value }}</b></h3> 16 <h3>{% trans "Tag" %}: <b>{{ tag.value }}</b></h3>
17 {% endif %} 17 {% endif %}
18 {% if entries is empty %} 18 {% if entries is empty%}
19 <div class="messages warning"><p>{% trans "No articles found." %}</p></div> 19 <div class="messages warning"><p>
20 {% if view == 'home' %}{% trans "No articles unread. Good job !" %}
21 {% elseif view == 'fav' %}{% trans "No articles favourited" %}
22 {% elseif view == 'archive' %}{% trans "No articles marked as read" %}
23 {% elseif view == 'tags' %}{% trans "No articles with this tag found" %}
24 {% elseif search_term is defined %} {% trans %}No articles found for « {{ search_term }} »{% endtrans %}
25 {% else %}{% trans "No articles found" %}{% endif %}
26 </p></div>
20 {% else %} 27 {% else %}
21 <div> 28 <div>
22 {% include '_display-mode.twig' %} 29 {% include '_display-mode.twig' %}
@@ -25,15 +32,35 @@
25 {% block pager %} 32 {% block pager %}
26 {% if nb_results > 1 %} 33 {% if nb_results > 1 %}
27 <div class="results"> 34 <div class="results">
28 <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> 35 <div class="nb-results">
36 {% if view == 'home' %}
37 {{ nb_results }} {% trans "articles unread" %}
38 {% elseif view == 'fav' %}
39 {{ nb_results }} {% trans "articles favourited" %}
40 {% elseif view == 'archive' %}
41 {{ nb_results }} {% trans "articles marked as read" %}
42 {% elseif view == 'tag' %}
43 {{ nb_results }} {% trans "articles with this tag" %}
44 {% elseif search_term is defined %}{{ nb_results }}
45 {% trans %}articles found for « {{ search_term }} »{% endtrans %}
46 {% else %}
47 {{ nb_results }} {% trans "articles" %}
48 {% endif %}
49 {% if view == 'home' or view == 'fav' or view == 'archive' %}
50 <a href="?action=random&amp;view={{ view }}" class="icon icon-random"><span> {% trans "random" %}</span></a>{% endif %}
51 </div>
29 {{ page_links | raw }} 52 {{ page_links | raw }}
30 </div> 53 </div>
31 {% elseif nb_results == 1 %} 54 {% elseif nb_results == 1 %}
32 {% if search_term is defined %}
33 <div class="results"> 55 <div class="results">
34 <div class="nb-results">{% trans "Only one result found for " %} « {{ search_term }} »</div> 56 <div class="nb-results">
57 {% if view == 'home' %}{% trans "Only one article unread. Way to go !" %}
58 {% elseif view == 'fav' %}{% trans "Just one article favourited" %}
59 {% elseif view == 'archive' %}{% trans "One article marked as read" %}
60 {% elseif view == 'tag' %}{% trans "One article with this tag" %}
61 {% elseif search_term is defined %}{% trans %}Only one result found for « {{ search_term }} »{% endtrans %}
62 {% else %}{% trans "One article found" %}{% endif %}</div>
35 </div> 63 </div>
36 {% endif %}
37 {% endif %} 64 {% endif %}
38 {% endblock %} 65 {% endblock %}
39 <div id="list-entries" class="list-entries"> 66 <div id="list-entries" class="list-entries">
@@ -64,6 +91,7 @@
64 91
65 {% if tag %}<a title="{% trans "Mark all articles from this tag as read" %}" href="./?action=toggle_archive&amp;tag_id={{ tag.id }}">{% trans "Mark all articles from this tag as read" %}</a><br />{% endif %} 92 {% if tag %}<a title="{% trans "Mark all articles from this tag as read" %}" href="./?action=toggle_archive&amp;tag_id={{ tag.id }}">{% trans "Mark all articles from this tag as read" %}</a><br />{% endif %}
66 93
94 {% if entries is not empty %}
67 {% if tag %} 95 {% if tag %}
68 {% if constant('EPUB') == 1 %}<a title="{% trans "Download the articles from this tag in an epub file" %}" href="./?epub&amp;method=tag&amp;value={{ tag.value }}">{% trans "Download as ePub3" %}</a>{% endif %} 96 {% if constant('EPUB') == 1 %}<a title="{% trans "Download the articles from this tag in an epub file" %}" href="./?epub&amp;method=tag&amp;value={{ tag.value }}">{% trans "Download as ePub3" %}</a>{% endif %}
69 {% if constant('MOBI') == 1 %}<a title="{% trans "Download the articles from this tag in a mobi file" %}" href="./?mobi&amp;method=tag&amp;value={{ tag.value }}">{% trans "Download as Mobi" %}</a>{% endif %} 97 {% if constant('MOBI') == 1 %}<a title="{% trans "Download the articles from this tag in a mobi file" %}" href="./?mobi&amp;method=tag&amp;value={{ tag.value }}">{% trans "Download as Mobi" %}</a>{% endif %}
@@ -77,5 +105,6 @@
77 {% if constant('MOBI') == 1 %}<a title="{% trans "Download the articles from this category in a mobi file" %}" href="./?mobi&amp;method=category&amp;value={{ view }}">{% trans "Download as Mobi" %}</a>{% endif %} 105 {% if constant('MOBI') == 1 %}<a title="{% trans "Download the articles from this category in a mobi file" %}" href="./?mobi&amp;method=category&amp;value={{ view }}">{% trans "Download as Mobi" %}</a>{% endif %}
78 {% if constant('PDF') == 1 %}<a title="{% trans "Download the articles from this category in a pdf file" %}" href="./?pdf&amp;method=category&amp;value={{ view }}">{% trans "Download as PDF" %}</a>{% endif %} 106 {% if constant('PDF') == 1 %}<a title="{% trans "Download the articles from this category in a pdf file" %}" href="./?pdf&amp;method=category&amp;value={{ view }}">{% trans "Download as PDF" %}</a>{% endif %}
79 {% endif %} 107 {% endif %}
108 {% endif %}
80{% endif %} 109{% endif %}
81{% endblock %} 110{% endblock %}