From 9c97041d55c7f3023617443977f7953311c7d677 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 27 Feb 2012 14:39:15 +0400 Subject: [PATCH] make generated_feed parameters optional, add specific date type for RSS feeds --- classes/public_handler.php | 36 ++++++++++++++++++++---------------- templates/generated_feed.txt | 4 ++-- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/classes/public_handler.php b/classes/public_handler.php index 0896e498..7db34145 100644 --- a/classes/public_handler.php +++ b/classes/public_handler.php @@ -38,23 +38,23 @@ class Public_Handler extends Handler { $tpl->readTemplateFromFile("templates/generated_feed.txt"); - $tpl->setVariable('FEED_TITLE', $feed_title); - $tpl->setVariable('VERSION', VERSION); - $tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url)); + $tpl->setVariable('FEED_TITLE', $feed_title, true); + $tpl->setVariable('VERSION', VERSION, true); + $tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true); if (PUBSUBHUBBUB_HUB && $feed == -2) { - $tpl->setVariable('HUB_URL', htmlspecialchars(PUBSUBHUBBUB_HUB)); + $tpl->setVariable('HUB_URL', htmlspecialchars(PUBSUBHUBBUB_HUB), true); $tpl->addBlock('feed_hub'); } - $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix())); + $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true); while ($line = db_fetch_assoc($result)) { - $tpl->setVariable('ARTICLE_ID', htmlspecialchars($line['link'])); - $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link'])); - $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title'])); + $tpl->setVariable('ARTICLE_ID', htmlspecialchars($line['link']), true); + $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true); + $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true); $tpl->setVariable('ARTICLE_EXCERPT', - truncate_string(strip_tags($line["content_preview"]), 100, '...')); + truncate_string(strip_tags($line["content_preview"]), 100, '...'), true); $content = sanitize($this->link, $line["content_preview"], false, $owner_uid); @@ -63,15 +63,19 @@ class Public_Handler extends Handler { $content; } - $tpl->setVariable('ARTICLE_CONTENT', $content); + $tpl->setVariable('ARTICLE_CONTENT', $content, true); - $tpl->setVariable('ARTICLE_UPDATED', date('c', strtotime($line["updated"]))); - $tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author'])); + $tpl->setVariable('ARTICLE_UPDATED_ATOM', + date('c', strtotime($line["updated"])), true); + $tpl->setVariable('ARTICLE_UPDATED_RFC822', + date(DATE_RFC822, strtotime($line["updated"])), true); + + $tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true); $tags = get_article_tags($this->link, $line["id"], $owner_uid); foreach ($tags as $tag) { - $tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag)); + $tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true); $tpl->addBlock('category'); } @@ -82,9 +86,9 @@ class Public_Handler extends Handler { $url = htmlspecialchars($e['content_url']); $length = $e['duration']; - $tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url); - $tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type); - $tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length); + $tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true); + $tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true); + $tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length, true); $tpl->addBlock('enclosure'); } diff --git a/templates/generated_feed.txt b/templates/generated_feed.txt index dff67cf7..6bfa50b1 100644 --- a/templates/generated_feed.txt +++ b/templates/generated_feed.txt @@ -4,7 +4,7 @@ ${FEED_TITLE} Tiny Tiny RSS/${VERSION} -${ARTICLE_UPDATED} +${ARTICLE_UPDATED_ATOM} ${FEED_URL} @@ -18,7 +18,7 @@ ${ARTICLE_TITLE} - ${ARTICLE_UPDATED} + ${ARTICLE_UPDATED_ATOM} ${ARTICLE_AUTHOR} -- 2.39.5