mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-27 11:31:05 +00:00
Added save search as tag functionality
This commit is contained in:
parent
21f29fe492
commit
decc23aaf2
2 changed files with 45 additions and 31 deletions
|
@ -511,8 +511,20 @@ class Poche
|
||||||
Tools::redirect();
|
Tools::redirect();
|
||||||
break;
|
break;
|
||||||
case 'add_tag' :
|
case 'add_tag' :
|
||||||
|
if (isset($_GET['search'])) {
|
||||||
|
//when we want to apply a tag to a search
|
||||||
|
$search = true;
|
||||||
|
$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 { //add a tag to a single article
|
||||||
$tags = explode(',', $_POST['value']);
|
$tags = explode(',', $_POST['value']);
|
||||||
$entry_id = $_POST['entry_id'];
|
$entry_ids = array($_POST['entry_id']);
|
||||||
|
}
|
||||||
|
foreach($entry_ids as $entry_id) {
|
||||||
$entry = $this->store->retrieveOneById($entry_id, $this->user->getId());
|
$entry = $this->store->retrieveOneById($entry_id, $this->user->getId());
|
||||||
if (!$entry) {
|
if (!$entry) {
|
||||||
$this->messages->add('e', _('Article not found!'));
|
$this->messages->add('e', _('Article not found!'));
|
||||||
|
@ -529,7 +541,6 @@ class Poche
|
||||||
$value = trim($tag_value);
|
$value = trim($tag_value);
|
||||||
if ($value && !in_array($value, $already_set_tags)) {
|
if ($value && !in_array($value, $already_set_tags)) {
|
||||||
$tag = $this->store->retrieveTagByValue($value);
|
$tag = $this->store->retrieveTagByValue($value);
|
||||||
|
|
||||||
if (is_null($tag)) {
|
if (is_null($tag)) {
|
||||||
# we create the tag
|
# we create the tag
|
||||||
$tag = $this->store->createTag($value);
|
$tag = $this->store->createTag($value);
|
||||||
|
@ -547,6 +558,8 @@ class Poche
|
||||||
$this->store->setTagToEntry($tag_id, $entry_id);
|
$this->store->setTagToEntry($tag_id, $entry_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
$this->messages->add('s', _('the tag has been applied successfully'));
|
||||||
Tools::redirect();
|
Tools::redirect();
|
||||||
break;
|
break;
|
||||||
case 'remove_tag' :
|
case 'remove_tag' :
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% if view == 'home' %}{% if nb_results > 1 %}<a title="{% trans "Mark all the entries as read" %}" href="./?action=archive_all">{{ "Mark all the entries as read" }}</a>{% endif %}{% endif %}
|
{% if view == 'home' %}{% if nb_results > 1 %}<a title="{% trans "Mark all the entries as read" %}" href="./?action=archive_all">{{ "Mark all the entries as read" }}</a>{% endif %}{% endif %}
|
||||||
|
{% if search_term is defined %}<a title="{% trans "Apply the tag" %} {{ search_term }} {% trans "to this search" %}" href="./?action=add_tag&search={{ search_term }}">{% trans "Apply the tag" %} {{ search_term }} {% trans "to this search" %}</a>{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ block('pager') }}
|
{{ block('pager') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue