diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-12-06 15:07:51 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-12-06 15:07:51 +0100 |
commit | c432fa1674fbe2b190cf0d0bab2e90302a61e98f (patch) | |
tree | 731e876604ece7f35cebdb8a9e80f5b520f21b75 /inc/poche/Poche.class.php | |
parent | f778e47283c9691d2992045e0fbcdfc6685f157f (diff) | |
download | wallabag-c432fa1674fbe2b190cf0d0bab2e90302a61e98f.tar.gz wallabag-c432fa1674fbe2b190cf0d0bab2e90302a61e98f.tar.zst wallabag-c432fa1674fbe2b190cf0d0bab2e90302a61e98f.zip |
[add] assign and remove a tag to an entry
Diffstat (limited to 'inc/poche/Poche.class.php')
-rw-r--r-- | inc/poche/Poche.class.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 68f56d62..d415dd03 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -397,6 +397,36 @@ class Poche | |||
397 | Tools::redirect(); | 397 | Tools::redirect(); |
398 | } | 398 | } |
399 | break; | 399 | break; |
400 | case 'add_tag' : | ||
401 | $tags = explode(',', $_POST['value']); | ||
402 | $entry_id = $_POST['entry_id']; | ||
403 | foreach($tags as $key => $tag_value) { | ||
404 | $value = trim($tag_value); | ||
405 | $tag = $this->store->retrieveTagByValue($value); | ||
406 | |||
407 | if (is_null($tag)) { | ||
408 | # we create the tag | ||
409 | $tag = $this->store->createTag($value); | ||
410 | $sequence = ''; | ||
411 | if (STORAGE == 'postgres') { | ||
412 | $sequence = 'tags_id_seq'; | ||
413 | } | ||
414 | $tag_id = $this->store->getLastId($sequence); | ||
415 | } | ||
416 | else { | ||
417 | $tag_id = $tag['id']; | ||
418 | } | ||
419 | |||
420 | # we assign the tag to the article | ||
421 | $this->store->setTagToEntry($tag_id, $entry_id); | ||
422 | } | ||
423 | Tools::redirect(); | ||
424 | break; | ||
425 | case 'remove_tag' : | ||
426 | $tag_id = $_GET['tag_id']; | ||
427 | $this->store->removeTagForEntry($id, $tag_id); | ||
428 | Tools::redirect(); | ||
429 | break; | ||
400 | default: | 430 | default: |
401 | break; | 431 | break; |
402 | } | 432 | } |
@@ -434,6 +464,7 @@ class Poche | |||
434 | # tags | 464 | # tags |
435 | $tags = $this->store->retrieveTagsByEntry($id); | 465 | $tags = $this->store->retrieveTagsByEntry($id); |
436 | $tpl_vars = array( | 466 | $tpl_vars = array( |
467 | 'entry_id' => $id, | ||
437 | 'tags' => $tags, | 468 | 'tags' => $tags, |
438 | ); | 469 | ); |
439 | break; | 470 | break; |