X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=classes%2Fhandler%2Fpublic.php;h=46c74041c85c33a6de6b1036552ce2a8bac5ee80;hb=27f7b59353a076120407d8873ea86f5eea7d1dcf;hp=ca5952bca121b40338a4527fd7fb645ede6a1428;hpb=52d88392dad52ec4d5607fef7479d74dee8b8be4;p=tt-rss.git
diff --git a/classes/handler/public.php b/classes/handler/public.php
index ca5952bc..46c74041 100644
--- a/classes/handler/public.php
+++ b/classes/handler/public.php
@@ -3,7 +3,7 @@ class Handler_Public extends Handler {
private function generate_syndicated_feed($owner_uid, $feed, $is_cat,
$limit, $offset, $search, $search_mode,
- $view_mode = false, $format = 'atom') {
+ $view_mode = false, $format = 'atom', $order = false, $orig_guid = false, $start_ts = false) {
require_once "lib/MiniTemplator.class.php";
@@ -15,21 +15,40 @@ class Handler_Public extends Handler {
if (!$limit) $limit = 60;
$date_sort_field = "date_entered DESC, updated DESC";
+ $date_check_field = "date_entered";
- if ($feed == -2)
+ if ($feed == -2 && !$is_cat) {
$date_sort_field = "last_published DESC";
- else if ($feed == -1)
+ $date_check_field = "last_published";
+ } else if ($feed == -1 && !$is_cat) {
$date_sort_field = "last_marked DESC";
+ $date_check_field = "last_marked";
+ }
+
+ switch ($order) {
+ case "title":
+ $date_sort_field = "ttrss_entries.title";
+ break;
+ case "date_reverse":
+ $date_sort_field = "date_entered, updated";
+ break;
+ case "feed_dates":
+ $date_sort_field = "updated DESC";
+ break;
+ }
+
+ //function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false, $override_strategy = false, $override_vfeed = false, $start_ts = false) {
$qfh_ret = queryFeedHeadlines($feed,
1, $view_mode, $is_cat, $search, $search_mode,
$date_sort_field, $offset, $owner_uid,
- false, 0, false, true);
+ false, 0, true, true, false, false, $start_ts);
$result = $qfh_ret[0];
if ($this->dbh->num_rows($result) != 0) {
- $ts = strtotime($this->dbh->fetch_result($result, 0, "date_entered"));
+
+ $ts = strtotime($this->dbh->fetch_result($result, 0, $date_check_field));
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $ts) {
@@ -44,17 +63,17 @@ class Handler_Public extends Handler {
$qfh_ret = queryFeedHeadlines($feed,
$limit, $view_mode, $is_cat, $search, $search_mode,
$date_sort_field, $offset, $owner_uid,
- false, 0, false, true);
+ false, 0, true, true, false, false, $start_ts);
$result = $qfh_ret[0];
$feed_title = htmlspecialchars($qfh_ret[1]);
$feed_site_url = $qfh_ret[2];
- $last_error = $qfh_ret[3];
+ /* $last_error = $qfh_ret[3]; */
$feed_self_url = get_self_url_prefix() .
- "/public.php?op=rss&id=-2&key=" .
- get_feed_access_key(-2, false, $owner_uid);
+ "/public.php?op=rss&id=$feed&key=" .
+ get_feed_access_key($feed, false, $owner_uid);
if (!$feed_site_url) $feed_site_url = get_self_url_prefix();
@@ -73,16 +92,22 @@ class Handler_Public extends Handler {
}
$tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
-
while ($line = $this->dbh->fetch_assoc($result)) {
+ $line["content_preview"] = truncate_string(strip_tags($line["content"]), 100, '...');
+
+ foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
+ $line = $p->hook_query_headlines($line);
+ }
- $tpl->setVariable('ARTICLE_ID', htmlspecialchars($line['link']), true);
+ $tpl->setVariable('ARTICLE_ID',
+ htmlspecialchars($orig_guid ? $line['link'] :
+ $this->make_article_tag_uri($line['id'], $line['date_entered'])), 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, '...'), true);
+ $tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true);
- $content = sanitize($line["content_preview"], false, $owner_uid);
+ $content = sanitize($line["content"], false, $owner_uid,
+ $feed_site_url);
if ($line['note']) {
$content = "
Article note: " . $line['note'] . "
" .
@@ -99,6 +124,9 @@ class Handler_Public extends Handler {
$tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
+ $tpl->setVariable('ARTICLE_SOURCE_LINK', htmlspecialchars($line['site_url'] ? $line["site_url"] : get_self_url_prefix()), true);
+ $tpl->setVariable('ARTICLE_SOURCE_TITLE', htmlspecialchars($line['feed_title'] ? $line['feed_title'] : $feed_title), true);
+
$tags = get_article_tags($line["id"], $owner_uid);
foreach ($tags as $tag) {
@@ -111,7 +139,7 @@ class Handler_Public extends Handler {
foreach ($enclosures as $e) {
$type = htmlspecialchars($e['content_type']);
$url = htmlspecialchars($e['content_url']);
- $length = $e['duration'];
+ $length = $e['duration'] ? $e['duration'] : 1;
$tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true);
$tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true);
@@ -152,13 +180,17 @@ class Handler_Public extends Handler {
$feed['articles'] = array();
while ($line = $this->dbh->fetch_assoc($result)) {
+ $line["content_preview"] = truncate_string(strip_tags($line["content_preview"]), 100, '...');
+ foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
+ $line = $p->hook_query_headlines($line, 100);
+ }
$article = array();
$article['id'] = $line['link'];
$article['link'] = $line['link'];
$article['title'] = $line['title'];
- $article['excerpt'] = truncate_string(strip_tags($line["content_preview"]), 100, '...');
- $article['content'] = sanitize($line["content_preview"], false, $owner_uid);
+ $article['excerpt'] = $line["content_preview"];
+ $article['content'] = sanitize($line["content"], false, $owner_uid);
$article['updated'] = date('c', strtotime($line["updated"]));
if ($line['note']) $article['note'] = $line['note'];
@@ -225,7 +257,7 @@ class Handler_Public extends Handler {
function getProfiles() {
$login = $this->dbh->escape_string($_REQUEST["login"]);
- $result = $this->dbh->query("SELECT * FROM ttrss_settings_profiles,ttrss_users
+ $result = $this->dbh->query("SELECT ttrss_settings_profiles.* FROM ttrss_settings_profiles,ttrss_users
WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = '$login' ORDER BY title");
print "