From f778e47283c9691d2992045e0fbcdfc6685f157f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 6 Dec 2013 14:37:42 +0100 Subject: [PATCH] [add] rss for tag --- inc/poche/Poche.class.php | 15 ++++++++++++--- index.php | 3 ++- themes/default/img/default/rss.png | Bin 0 -> 288 bytes themes/default/tags.twig | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 themes/default/img/default/rss.png diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index fefbb02d..68f56d62 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -446,8 +446,11 @@ class Poche ); break; case 'tags': + $token = $this->user->getConfigValue('token'); $tags = $this->store->retrieveAllTags(); $tpl_vars = array( + 'token' => $token, + 'user_id' => $this->user->getId(), 'tags' => $tags, ); break; @@ -884,9 +887,9 @@ class Poche $_SESSION['poche_user']->setConfig($currentConfig); } - public function generateFeeds($token, $user_id, $type = 'home') + public function generateFeeds($token, $user_id, $tag_id, $type = 'home') { - $allowed_types = array('home', 'fav', 'archive'); + $allowed_types = array('home', 'fav', 'archive', 'tag'); $config = $this->store->getConfigUser($user_id); if (!in_array($type, $allowed_types) || @@ -901,7 +904,13 @@ class Poche $feed->setChannelElement('updated', date(DATE_RSS , time())); $feed->setChannelElement('author', 'poche'); - $entries = $this->store->getEntriesByView($type, $user_id); + if ($type == 'tag') { + $entries = $this->store->retrieveEntriesByTag($tag_id); + } + else { + $entries = $this->store->getEntriesByView($type, $user_id); + } + if (count($entries) > 0) { foreach ($entries as $entry) { $newItem = $feed->createNewItem(); diff --git a/index.php b/index.php index 96f28a72..836730bf 100644 --- a/index.php +++ b/index.php @@ -75,7 +75,8 @@ if (isset($_GET['login'])) { $poche->generateToken(); } else { - $poche->generateFeeds($_GET['token'], $_GET['user_id'], $_GET['type']); + $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0); + $poche->generateFeeds($_GET['token'], $_GET['user_id'], $tag_id, $_GET['type']); } } diff --git a/themes/default/img/default/rss.png b/themes/default/img/default/rss.png new file mode 100644 index 0000000000000000000000000000000000000000..21bad1a174bf152563552aff0e1a397fee05a82b GIT binary patch literal 288 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt^vJzX3_ zEPBsgF!XW`6li_u-9N+;K)*BZpl-y?R7O3=4IFw-8+chZalBq4=(BL@)Ega1 zyC$q?{eJL+$D_?g%m)&8-vX5;);}d*q9%;X1w!LziDT>u$o#d_? zI?N{v+PLqCI{Y=7z@xq*iFtVi|Af<_r$4e4^9Zfz^?c>OaX-(77i|7FoYlYN)pZy2 z6-G$>IQehFAMI_^8T$%bWbd?FgvPLDD93k%=O%Ut@)gLY&8pzpy!B6Dq~LS2zij6# iG=H>CRh{}ZJK+9#5j$t+{{ tag.value }} {% endfor %} +{% for tag in tags %}{{ tag.value }} {% if token != '' %}{% endif %} {% endfor %} {% endblock %} \ No newline at end of file -- 2.41.0