aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche/Poche.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/poche/Poche.class.php')
-rw-r--r--inc/poche/Poche.class.php79
1 files changed, 72 insertions, 7 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index d45d0c40..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 }
@@ -430,6 +460,31 @@ class Poche
430 ); 460 );
431 Tools::logm('config view'); 461 Tools::logm('config view');
432 break; 462 break;
463 case 'edit-tags':
464 # tags
465 $tags = $this->store->retrieveTagsByEntry($id);
466 $tpl_vars = array(
467 'entry_id' => $id,
468 'tags' => $tags,
469 );
470 break;
471 case 'tag':
472 $entries = $this->store->retrieveEntriesByTag($id);
473 $tag = $this->store->retrieveTag($id);
474 $tpl_vars = array(
475 'tag' => $tag,
476 'entries' => $entries,
477 );
478 break;
479 case 'tags':
480 $token = $this->user->getConfigValue('token');
481 $tags = $this->store->retrieveAllTags();
482 $tpl_vars = array(
483 'token' => $token,
484 'user_id' => $this->user->getId(),
485 'tags' => $tags,
486 );
487 break;
433 case 'view': 488 case 'view':
434 $entry = $this->store->retrieveOneById($id, $this->user->getId()); 489 $entry = $this->store->retrieveOneById($id, $this->user->getId());
435 if ($entry != NULL) { 490 if ($entry != NULL) {
@@ -443,12 +498,16 @@ class Poche
443 498
444 # flattr checking 499 # flattr checking
445 $flattr = new FlattrItem(); 500 $flattr = new FlattrItem();
446 $flattr->checkItem($entry['url'],$entry['id']); 501 $flattr->checkItem($entry['url'], $entry['id']);
502
503 # tags
504 $tags = $this->store->retrieveTagsByEntry($entry['id']);
447 505
448 $tpl_vars = array( 506 $tpl_vars = array(
449 'entry' => $entry, 507 'entry' => $entry,
450 'content' => $content, 508 'content' => $content,
451 'flattr' => $flattr 509 'flattr' => $flattr,
510 'tags' => $tags
452 ); 511 );
453 } 512 }
454 else { 513 else {
@@ -859,9 +918,9 @@ class Poche
859 $_SESSION['poche_user']->setConfig($currentConfig); 918 $_SESSION['poche_user']->setConfig($currentConfig);
860 } 919 }
861 920
862 public function generateFeeds($token, $user_id, $type = 'home') 921 public function generateFeeds($token, $user_id, $tag_id, $type = 'home')
863 { 922 {
864 $allowed_types = array('home', 'fav', 'archive'); 923 $allowed_types = array('home', 'fav', 'archive', 'tag');
865 $config = $this->store->getConfigUser($user_id); 924 $config = $this->store->getConfigUser($user_id);
866 925
867 if (!in_array($type, $allowed_types) || 926 if (!in_array($type, $allowed_types) ||
@@ -876,7 +935,13 @@ class Poche
876 $feed->setChannelElement('updated', date(DATE_RSS , time())); 935 $feed->setChannelElement('updated', date(DATE_RSS , time()));
877 $feed->setChannelElement('author', 'poche'); 936 $feed->setChannelElement('author', 'poche');
878 937
879 $entries = $this->store->getEntriesByView($type, $user_id); 938 if ($type == 'tag') {
939 $entries = $this->store->retrieveEntriesByTag($tag_id);
940 }
941 else {
942 $entries = $this->store->getEntriesByView($type, $user_id);
943 }
944
880 if (count($entries) > 0) { 945 if (count($entries) > 0) {
881 foreach ($entries as $entry) { 946 foreach ($entries as $entry) {
882 $newItem = $feed->createNewItem(); 947 $newItem = $feed->createNewItem();