aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xinc/poche/Poche.class.php69
-rwxr-xr-xinc/poche/Routing.class.php3
-rwxr-xr-xthemes/baggy/home.twig6
-rwxr-xr-xthemes/default/home.twig8
4 files changed, 67 insertions, 19 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 75766919..8b0d3a19 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -180,6 +180,13 @@ class Poche
180 } 180 }
181 } 181 }
182 182
183 // if there are tags, add them to the new article
184 if (isset($_GET['tags'])) {
185 $_POST['value'] = $_GET['tags'];
186 $_POST['entry_id'] = $last_id;
187 $this->action('add_tag', $url);
188 }
189
183 $this->messages->add('s', _('the link has been added successfully')); 190 $this->messages->add('s', _('the link has been added successfully'));
184 } 191 }
185 else { 192 else {
@@ -194,18 +201,31 @@ class Poche
194 } 201 }
195 break; 202 break;
196 case 'delete': 203 case 'delete':
197 $msg = 'delete link #' . $id; 204 if (isset($_GET['search'])) {
198 if ($this->store->deleteById($id, $this->user->getId())) { 205 //when we want to apply a delete to a search
199 if (DOWNLOAD_PICTURES) { 206 $tags = array($_GET['search']);
200 Picture::removeDirectory(ABS_PATH . $id); 207 $allentry_ids = $this->store->search($tags[0], $this->user->getId());
208 $entry_ids = array();
209 foreach ($allentry_ids as $eachentry) {
210 $entry_ids[] = $eachentry[0];
201 } 211 }
202 $this->messages->add('s', _('the link has been deleted successfully')); 212 } else { // delete a single article
213 $entry_ids = array($id);
203 } 214 }
204 else { 215 foreach($entry_ids as $id) {
205 $this->messages->add('e', _('the link wasn\'t deleted')); 216 $msg = 'delete link #' . $id;
206 $msg = 'error : can\'t delete link #' . $id; 217 if ($this->store->deleteById($id, $this->user->getId())) {
218 if (DOWNLOAD_PICTURES) {
219 Picture::removeDirectory(ABS_PATH . $id);
220 }
221 $this->messages->add('s', _('the link has been deleted successfully'));
222 }
223 else {
224 $this->messages->add('e', _('the link wasn\'t deleted'));
225 $msg = 'error : can\'t delete link #' . $id;
226 }
227 Tools::logm($msg);
207 } 228 }
208 Tools::logm($msg);
209 Tools::redirect('?'); 229 Tools::redirect('?');
210 break; 230 break;
211 case 'toggle_fav' : 231 case 'toggle_fav' :
@@ -220,8 +240,21 @@ class Poche
220 } 240 }
221 break; 241 break;
222 case 'toggle_archive' : 242 case 'toggle_archive' :
223 $this->store->archiveById($id, $this->user->getId()); 243 if (isset($_GET['tag_id'])) {
224 Tools::logm('archive link #' . $id); 244 //when we want to archive a whole tag
245 $tag_id = $_GET['tag_id'];
246 $allentry_ids = $this->store->retrieveEntriesByTag($tag_id, $this->user->getId());
247 $entry_ids = array();
248 foreach ($allentry_ids as $eachentry) {
249 $entry_ids[] = $eachentry[0];
250 }
251 } else { //archive a single article
252 $entry_ids = array($id);
253 }
254 foreach($entry_ids as $id) {
255 $this->store->archiveById($id, $this->user->getId());
256 Tools::logm('archive link #' . $id);
257 }
225 if ( Tools::isAjaxRequest() ) { 258 if ( Tools::isAjaxRequest() ) {
226 echo 1; 259 echo 1;
227 exit; 260 exit;
@@ -753,10 +786,11 @@ class Poche
753 * 786 *
754 * @param $token 787 * @param $token
755 * @param $user_id 788 * @param $user_id
756 * @param $tag_id 789 * @param $tag_id if $type is 'tag', the id of the tag to generate feed for
757 * @param string $type 790 * @param string $type the type of feed to generate
791 * @param int $limit the maximum number of items (0 means all)
758 */ 792 */
759 public function generateFeeds($token, $user_id, $tag_id, $type = 'home') 793 public function generateFeeds($token, $user_id, $tag_id, $type = 'home', $limit = 0)
760 { 794 {
761 $allowed_types = array('home', 'fav', 'archive', 'tag'); 795 $allowed_types = array('home', 'fav', 'archive', 'tag');
762 $config = $this->store->getConfigUser($user_id); 796 $config = $this->store->getConfigUser($user_id);
@@ -783,8 +817,13 @@ class Poche
783 $entries = $this->store->getEntriesByView($type, $user_id); 817 $entries = $this->store->getEntriesByView($type, $user_id);
784 } 818 }
785 819
820 // if $limit is set to zero, use all entries
821 if (0 == $limit) {
822 $limit = count($entries);
823 }
786 if (count($entries) > 0) { 824 if (count($entries) > 0) {
787 foreach ($entries as $entry) { 825 for ($i = 0; $i < min(count($entries), $limit); $i++) {
826 $entry = $entries[$i];
788 $newItem = $feed->createNewItem(); 827 $newItem = $feed->createNewItem();
789 $newItem->setTitle($entry['title']); 828 $newItem->setTitle($entry['title']);
790 $newItem->setSource(Tools::getPocheUrl() . '?view=view&amp;id=' . $entry['id']); 829 $newItem->setSource(Tools::getPocheUrl() . '?view=view&amp;id=' . $entry['id']);
diff --git a/inc/poche/Routing.class.php b/inc/poche/Routing.class.php
index 5acd08ba..be06a433 100755
--- a/inc/poche/Routing.class.php
+++ b/inc/poche/Routing.class.php
@@ -102,7 +102,8 @@ class Routing
102 $this->wallabag->login($this->referer); 102 $this->wallabag->login($this->referer);
103 } elseif (isset($_GET['feed']) && isset($_GET['user_id'])) { 103 } elseif (isset($_GET['feed']) && isset($_GET['user_id'])) {
104 $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0); 104 $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0);
105 $this->wallabag->generateFeeds($_GET['token'], filter_var($_GET['user_id'],FILTER_SANITIZE_NUMBER_INT), $tag_id, $_GET['type']); 105 $limit = (isset($_GET['limit']) ? intval($_GET['limit']) : 0);
106 $this->wallabag->generateFeeds($_GET['token'], filter_var($_GET['user_id'],FILTER_SANITIZE_NUMBER_INT), $tag_id, $_GET['type'], $limit);
106 } 107 }
107 108
108 //allowed ONLY to logged in user 109 //allowed ONLY to logged in user
diff --git a/themes/baggy/home.twig b/themes/baggy/home.twig
index abebe455..93515080 100755
--- a/themes/baggy/home.twig
+++ b/themes/baggy/home.twig
@@ -59,7 +59,11 @@
59 {{ block('pager') }} 59 {{ block('pager') }}
60 {% if view == 'home' %}{% if nb_results > 1 %}<p><a title="{% trans "Mark all the entries as read" %}" href="./?action=archive_all">{% trans "Mark all the entries as read" %}</a></p>{% endif %}{% endif %} 60 {% if view == 'home' %}{% if nb_results > 1 %}<p><a title="{% trans "Mark all the entries as read" %}" href="./?action=archive_all">{% trans "Mark all the entries as read" %}</a></p>{% endif %}{% endif %}
61 {% if searchterm is defined %}<a title="{% trans "Tag these results as" %} {{ searchterm }}" href="./?action=add_tag&search={{ searchterm }}">{% trans "Tag these results as" %} {{ searchterm }}</a>{% endif %}<br /> 61 {% if searchterm is defined %}<a title="{% trans "Tag these results as" %} {{ searchterm }}" href="./?action=add_tag&search={{ searchterm }}">{% trans "Tag these results as" %} {{ searchterm }}</a>{% endif %}<br />
62 62
63 {% if searchterm is defined %}<a title="{% trans "Delete results matching" %} {{ searchterm }}" href="./?action=delete&search={{ searchterm }}">{% trans "Delete results matching" %} {{ searchterm }}</a>{% endif %}<br />
64
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 %}
66
63 {% if tag %} 67 {% if tag %}
64 {% 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 %} 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 %}
65 {% 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 %} 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 %}
diff --git a/themes/default/home.twig b/themes/default/home.twig
index c5db5802..b9000559 100755
--- a/themes/default/home.twig
+++ b/themes/default/home.twig
@@ -59,7 +59,11 @@
59 {{ block('pager') }} 59 {{ block('pager') }}
60 {% if view == 'home' %}{% if nb_results > 1 %}<p><a title="{% trans "Mark all the entries as read" %}" href="./?action=archive_all">{% trans "Mark all the entries as read" %}</a></p>{% endif %}{% endif %} 60 {% if view == 'home' %}{% if nb_results > 1 %}<p><a title="{% trans "Mark all the entries as read" %}" href="./?action=archive_all">{% trans "Mark all the entries as read" %}</a></p>{% endif %}{% endif %}
61 {% if searchterm is defined %}<a title="{% trans "Tag these results as" %} {{ searchterm }}" href="./?action=add_tag&search={{ searchterm }}">{% trans "Tag these results as" %} {{ searchterm }}</a>{% endif %}<br /> 61 {% if searchterm is defined %}<a title="{% trans "Tag these results as" %} {{ searchterm }}" href="./?action=add_tag&search={{ searchterm }}">{% trans "Tag these results as" %} {{ searchterm }}</a>{% endif %}<br />
62 62
63 {% if searchterm is defined %}<a title="{% trans "Delete results matching" %} {{ searchterm }}" href="./?action=delete&search={{ searchterm }}">{% trans "Delete results matching" %} {{ searchterm }}</a>{% endif %}<br />
64
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 %}
66
63 {% if tag %} 67 {% if tag %}
64 {% 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 %} 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 %}
65 {% 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 %} 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 %}
@@ -73,6 +77,6 @@
73 {% 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 %} 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 %}
74 {% 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 %} 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 %}
75 {% endif %} 79 {% endif %}
76 80
77 {% endif %} 81 {% endif %}
78{% endblock %} 82{% endblock %}