X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=classes%2Fhandler%2Fpublic.php;h=1e96bef0034585e7bdfb90a0e45d92e44f7e33d9;hb=6322ac79a020ab584d412d782d62b2ee77d7c6cf;hp=dc1e100498827cf9c64c9dd133af51765d5bfc49;hpb=5b0aec17e9359818e6a9d3161d8539d6ed7a4f70;p=tt-rss.git
diff --git a/classes/handler/public.php b/classes/handler/public.php
index dc1e1004..1e96bef0 100644
--- a/classes/handler/public.php
+++ b/classes/handler/public.php
@@ -12,22 +12,41 @@ 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;
- if (get_pref($this->link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {
- $date_sort_field = "updated";
- } else {
- $date_sort_field = "date_entered";
- }
+ $date_sort_field = "date_entered DESC, updated DESC";
if ($feed == -2)
- $date_sort_field = "last_read";
+ $date_sort_field = "last_published DESC";
+ else if ($feed == -1)
+ $date_sort_field = "last_marked DESC";
+
+ $qfh_ret = queryFeedHeadlines( $feed,
+ 1, $view_mode, $is_cat, $search, $search_mode,
+ $date_sort_field, $offset, $owner_uid,
+ false, 0, false, true);
+
+ $result = $qfh_ret[0];
+
+ if (db_num_rows($result) != 0) {
+ $ts = strtotime(db_fetch_result($result, 0, "date_entered"));
+
+ if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
+ strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $ts) {
+ header('HTTP/1.0 304 Not Modified');
+ return;
+ }
- $qfh_ret = queryFeedHeadlines($this->link, $feed,
+ $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 DESC", $offset, $owner_uid,
+ $date_sort_field, $offset, $owner_uid,
false, 0, false, true);
+
$result = $qfh_ret[0];
$feed_title = htmlspecialchars($qfh_ret[1]);
$feed_site_url = $qfh_ret[2];
@@ -35,7 +54,7 @@ class Handler_Public extends Handler {
$feed_self_url = get_self_url_prefix() .
"/public.php?op=rss&id=-2&key=" .
- get_feed_access_key($this->link, -2, false, $owner_uid);
+ get_feed_access_key( -2, false, $owner_uid);
if (!$feed_site_url) $feed_site_url = get_self_url_prefix();
@@ -55,19 +74,21 @@ class Handler_Public extends Handler {
$tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
- while ($line = db_fetch_assoc($result)) {
+ while ($line = db_fetch_assoc($result)) {
+
$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, '...'), true);
- $content = sanitize($this->link, $line["content_preview"], false, $owner_uid);
+ $content = sanitize( $line["content_preview"], false, $owner_uid);
if ($line['note']) {
$content = "
Article note: " . $line['note'] . "
" .
$content;
-}
+ $tpl->setVariable('ARTICLE_NOTE', htmlspecialchars($line['note']), true);
+ }
$tpl->setVariable('ARTICLE_CONTENT', $content, true);
@@ -78,14 +99,14 @@ class Handler_Public extends Handler {
$tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
- $tags = get_article_tags($this->link, $line["id"], $owner_uid);
+ $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']);
@@ -137,13 +158,13 @@ class Handler_Public extends Handler {
$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['content'] = sanitize( $line["content_preview"], 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();
@@ -153,7 +174,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();
@@ -180,19 +201,19 @@ class Handler_Public extends Handler {
}
function getUnread() {
- $login = db_escape_string($_REQUEST["login"]);
+ $login = db_escape_string( $_REQUEST["login"]);
$fresh = $_REQUEST["fresh"] == "1";
- $result = db_query($this->link, "SELECT id FROM ttrss_users WHERE login = '$login'");
+ $result = db_query( "SELECT id FROM ttrss_users WHERE login = '$login'");
if (db_num_rows($result) == 1) {
$uid = db_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 {
@@ -202,9 +223,9 @@ class Handler_Public extends Handler {
}
function getProfiles() {
- $login = db_escape_string($_REQUEST["login"]);
+ $login = db_escape_string( $_REQUEST["login"]);
- $result = db_query($this->link, "SELECT * FROM ttrss_settings_profiles,ttrss_users
+ $result = db_query( "SELECT * FROM ttrss_settings_profiles,ttrss_users
WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = '$login' ORDER BY title");
print "