X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=classes%2Fhandler%2Fpublic.php;h=46c74041c85c33a6de6b1036552ce2a8bac5ee80;hb=27f7b59353a076120407d8873ea86f5eea7d1dcf;hp=6822faa771832f295232d10b73b3a22fc69e4716;hpb=e216d3025f486cee0398410a7842484f268b8c9d;p=tt-rss.git
diff --git a/classes/handler/public.php b/classes/handler/public.php
index 6822faa7..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";
@@ -12,28 +12,68 @@ class Handler_Public extends Handler {
"padding : 5px; border-style : dashed; border-color : #e7d796;".
"margin-bottom : 1em; color : #9a8c59;";
- if (!$limit) $limit = 100;
+ 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, true, true, false, false, $start_ts);
+
+ $result = $qfh_ret[0];
- $qfh_ret = queryFeedHeadlines($this->link, $feed,
+ if ($this->dbh->num_rows($result) != 0) {
+
+ $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) {
+ header('HTTP/1.0 304 Not Modified');
+ return;
+ }
+
+ $last_modified = gmdate("D, d M Y H:i:s", $ts) . " GMT";
+ header("Last-Modified: $last_modified", true);
+ }
+
+ $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($this->link, -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();
@@ -52,20 +92,28 @@ 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);
+ }
- while ($line = db_fetch_assoc($result)) {
- $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($this->link, $line["content_preview"], false, $owner_uid);
+ $content = sanitize($line["content"], false, $owner_uid,
+ $feed_site_url);
if ($line['note']) {
$content = "
Article note: " . $line['note'] . "
" .
$content;
-}
+ $tpl->setVariable('ARTICLE_NOTE', htmlspecialchars($line['note']), true);
+ }
$tpl->setVariable('ARTICLE_CONTENT', $content, true);
@@ -76,19 +124,22 @@ class Handler_Public extends Handler {
$tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
- $tags = get_article_tags($this->link, $line["id"], $owner_uid);
+ $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) {
$tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true);
$tpl->addBlock('category');
}
- $enclosures = get_article_enclosures($this->link, $line["id"]);
+ $enclosures = get_article_enclosures($line["id"]);
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);
@@ -128,20 +179,24 @@ class Handler_Public extends Handler {
$feed['articles'] = array();
- while ($line = db_fetch_assoc($result)) {
+ 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($this->link, $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'];
if ($article['author']) $article['author'] = $line['author'];
- $tags = get_article_tags($this->link, $line["id"], $owner_uid);
+ $tags = get_article_tags($line["id"], $owner_uid);
if (count($tags) > 0) {
$article['tags'] = array();
@@ -151,7 +206,7 @@ class Handler_Public extends Handler {
}
}
- $enclosures = get_article_enclosures($this->link, $line["id"]);
+ $enclosures = get_article_enclosures($line["id"]);
if (count($enclosures) > 0) {
$article['enclosures'] = array();
@@ -178,19 +233,19 @@ class Handler_Public extends Handler {
}
function getUnread() {
- $login = db_escape_string($this->link, $_REQUEST["login"]);
+ $login = $this->dbh->escape_string($_REQUEST["login"]);
$fresh = $_REQUEST["fresh"] == "1";
- $result = db_query($this->link, "SELECT id FROM ttrss_users WHERE login = '$login'");
+ $result = $this->dbh->query("SELECT id FROM ttrss_users WHERE login = '$login'");
- if (db_num_rows($result) == 1) {
- $uid = db_fetch_result($result, 0, "id");
+ if ($this->dbh->num_rows($result) == 1) {
+ $uid = $this->dbh->fetch_result($result, 0, "id");
- print getGlobalUnread($this->link, $uid);
+ print getGlobalUnread($uid);
if ($fresh) {
print ";";
- print getFeedArticles($this->link, -3, false, true, $uid);
+ print getFeedArticles(-3, false, true, $uid);
}
} else {
@@ -200,16 +255,16 @@ class Handler_Public extends Handler {
}
function getProfiles() {
- $login = db_escape_string($this->link, $_REQUEST["login"]);
+ $login = $this->dbh->escape_string($_REQUEST["login"]);
- $result = db_query($this->link, "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 "