Merge pull request #999 from moparisthebest/additions_dev

Miscellaneous additions
This commit is contained in:
Thomas Citharel 2015-01-13 22:45:33 +01:00
commit af5c371e95
3 changed files with 55 additions and 14 deletions

View File

@ -180,6 +180,13 @@ class Poche
} }
} }
// if there are tags, add them to the new article
if (isset($_GET['tags'])) {
$_POST['value'] = $_GET['tags'];
$_POST['entry_id'] = $last_id;
$this->action('add_tag', $url);
}
$this->messages->add('s', _('the link has been added successfully')); $this->messages->add('s', _('the link has been added successfully'));
} }
else { else {
@ -194,6 +201,18 @@ class Poche
} }
break; break;
case 'delete': case 'delete':
if (isset($_GET['search'])) {
//when we want to apply a delete to a search
$tags = array($_GET['search']);
$allentry_ids = $this->store->search($tags[0], $this->user->getId());
$entry_ids = array();
foreach ($allentry_ids as $eachentry) {
$entry_ids[] = $eachentry[0];
}
} else { // delete a single article
$entry_ids = array($id);
}
foreach($entry_ids as $id) {
$msg = 'delete link #' . $id; $msg = 'delete link #' . $id;
if ($this->store->deleteById($id, $this->user->getId())) { if ($this->store->deleteById($id, $this->user->getId())) {
if (DOWNLOAD_PICTURES) { if (DOWNLOAD_PICTURES) {
@ -206,6 +225,7 @@ class Poche
$msg = 'error : can\'t delete link #' . $id; $msg = 'error : can\'t delete link #' . $id;
} }
Tools::logm($msg); Tools::logm($msg);
}
Tools::redirect('?'); Tools::redirect('?');
break; break;
case 'toggle_fav' : case 'toggle_fav' :
@ -220,8 +240,21 @@ class Poche
} }
break; break;
case 'toggle_archive' : case 'toggle_archive' :
if (isset($_GET['tag_id'])) {
//when we want to archive a whole tag
$tag_id = $_GET['tag_id'];
$allentry_ids = $this->store->retrieveEntriesByTag($tag_id, $this->user->getId());
$entry_ids = array();
foreach ($allentry_ids as $eachentry) {
$entry_ids[] = $eachentry[0];
}
} else { //archive a single article
$entry_ids = array($id);
}
foreach($entry_ids as $id) {
$this->store->archiveById($id, $this->user->getId()); $this->store->archiveById($id, $this->user->getId());
Tools::logm('archive link #' . $id); Tools::logm('archive link #' . $id);
}
if ( Tools::isAjaxRequest() ) { if ( Tools::isAjaxRequest() ) {
echo 1; echo 1;
exit; exit;

View File

@ -60,6 +60,10 @@
{% 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 %} {% 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 %}
{% 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 /> {% 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 />
{% if searchterm is defined %}<a title="{% trans "Delete results matching" %} {{ searchterm }}" href="./?action=delete&search={{ searchterm }}">{% trans "Delete results matching" %} {{ searchterm }}</a>{% endif %}<br />
{% 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 %}
{% if tag %} {% if tag %}
{% 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 %} {% 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 %}
{% 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 %} {% 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 %}

View File

@ -60,6 +60,10 @@
{% 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 %} {% 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 %}
{% 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 /> {% 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 />
{% if searchterm is defined %}<a title="{% trans "Delete results matching" %} {{ searchterm }}" href="./?action=delete&search={{ searchterm }}">{% trans "Delete results matching" %} {{ searchterm }}</a>{% endif %}<br />
{% 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 %}
{% if tag %} {% if tag %}
{% 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 %} {% 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 %}
{% 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 %} {% 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 %}