if (ENABLE_TRANSLATIONS == true) { // If translations are enabled.
require_once "accept-to-gettext.php";
- require_once "gettext/gettext.inc";
+ require_once "lib/gettext/gettext.inc";
function startup_gettext() {
require_once 'errors.php';
require_once 'version.php';
- require_once 'phpmailer/class.phpmailer.php';
+ require_once 'lib/phpmailer/class.phpmailer.php';
define('MAGPIE_USER_AGENT_EXT', ' (Tiny Tiny RSS/' . VERSION . ')');
define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
define('MAGPIE_CACHE_AGE', 60*15); // 15 minutes
- require_once "simplepie/simplepie.inc";
- require_once "magpierss/rss_fetch.inc";
- require_once 'magpierss/rss_utils.inc';
+ require_once "lib/simplepie/simplepie.inc";
+ require_once "lib/magpierss/rss_fetch.inc";
+ require_once 'lib/magpierss/rss_utils.inc';
/**
* Print a timestamped debug message.
}
}
- function update_all_feeds($link, $fetch, $user_id = false, $force_daemon = false) {
-
- if (WEB_DEMO_MODE) return;
-
- if (!$user_id) {
- $user_id = $_SESSION["uid"];
- purge_old_posts($link);
- }
-
-// db_query($link, "BEGIN");
-
- if (MAX_UPDATE_TIME > 0) {
- if (DB_TYPE == "mysql") {
- $q_order = "RAND()";
- } else {
- $q_order = "RANDOM()";
- }
- } else {
- $q_order = "last_updated DESC";
- }
-
- $result = db_query($link, "SELECT feed_url,id,
- ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated,
- update_interval FROM ttrss_feeds WHERE owner_uid = '$user_id'
- ORDER BY $q_order");
-
- $upd_start = time();
-
- while ($line = db_fetch_assoc($result)) {
- $upd_intl = $line["update_interval"];
-
- if (!$upd_intl || $upd_intl == 0) {
- $upd_intl = get_pref($link, 'DEFAULT_UPDATE_INTERVAL', $user_id, false);
- }
-
- if ($upd_intl < 0) {
- // Updates for this feed are disabled
- continue;
- }
-
- if ($fetch || (!$line["last_updated"] ||
- time() - strtotime($line["last_updated"]) > ($upd_intl * 60))) {
-
-// print "<!-- feed: ".$line["feed_url"]." -->";
-
- update_rss_feed($link, $line["feed_url"], $line["id"], $force_daemon);
-
- $upd_elapsed = time() - $upd_start;
-
- if (MAX_UPDATE_TIME > 0 && $upd_elapsed > MAX_UPDATE_TIME) {
- return;
- }
- }
- }
-
-// db_query($link, "COMMIT");
-
- }
-
function fetch_file_contents($url) {
if (USE_CURL_FOR_ICONS) {
$tmpfile = tempnam(TMP_DIRECTORY, "ttrss-tmp");
$faviconURL = $urlParts['scheme'].'://'.$urlParts['host'].$linkUrl;
} else if (substr($linkUrl, 0, 7) == 'http://') {
$faviconURL = $linkUrl;
- } else if (substr($url, -1, 1) == '/') {
- $faviconURL = $url.$linkUrl;
} else {
- $faviconURL = $url.'/'.$linkUrl;
+ $pos = strrpos($url, "/");
+ // no "/" in url or "/" is part of "://"
+ if ($pos === false || $pos == (strpos($url, "://")+2)) {
+ $faviconURL = $url.'/'.$linkUrl;
+ } else {
+ $faviconURL = substr($url, 0, $pos+1).$linkUrl;
+ }
}
} else {
$http_response = fgets( $socket, 22 );
- $responses = "/(200 OK)|(30[0-9] Moved)/";
+ $responses = "/(200 OK)|(30[123])/";
if ( preg_match($responses, $http_response) ) {
fclose($socket);
return true;
} else {
$result = db_query($link, "SELECT id,update_interval,auth_login,
- auth_pass,cache_images,update_method,hidden
+ auth_pass,cache_images,update_method,hidden,last_updated
FROM ttrss_feeds WHERE id = '$feed'");
}
$hidden = sql_bool_to_bool(db_fetch_result($result, 0, "hidden"));
$update_method = db_fetch_result($result, 0, "update_method");
+ $last_updated = db_fetch_result($result, 0, "last_updated");
db_query($link, "UPDATE ttrss_feeds SET last_update_started = NOW()
WHERE id = '$feed'");
}
}
+ if (!$last_updated) {
+ if (defined('DAEMON_EXTENDED_DEBUG') || $_GET['xdebug']) {
+ _debug("update_rss_feed: new feed, catching it up...");
+ }
+ catchup_feed($link, $feed, false, $owner_uid);
+ }
+
if (!$hidden) {
if (defined('DAEMON_EXTENDED_DEBUG') || $_GET['xdebug']) {
_debug("update_rss_feed: updating counters cache...");
}
function printFeedEntry($feed_id, $class, $feed_title, $unread, $icon_file, $link,
- $rtl_content = false, $last_updated = false, $last_error = false) {
+ $rtl_content = false, $last_updated = false, $last_error = false,
+ $fg_content = false, $bg_content = false) {
if (file_exists($icon_file) && filesize($icon_file) > 0) {
$feed_icon = "<img id=\"FIMG-$feed_id\" src=\"$icon_file\">";
$feed = "<a title=\"$link_title\" id=\"FEEDL-$feed_id\"
href=\"javascript:viewfeed('$feed_id', '', false, '', false, 0);\">$feed_title</a>";
+/* if ($feed_id < -10) {
+ $bg_color = "#00ccff";
+ $fg_color = "white";
+ }
+
+ if ($fg_color || $bg_color) {
+ $color_str = "<div class='labelColorIndicator'
+ style='color : $fg_color; background-color : $bg_color'>l</div>";
+ }
+
+ print $color_str; */
+
print "<li id=\"FEEDR-$feed_id\" class=\"$class\">";
if (get_pref($link, 'ENABLE_FEED_ICONS')) {
print "$feed_icon";
print "<div class=\"feedExtInfo\">
<span id=\"FLUPD-$feed_id\">$last_updated ($total total) $error_notify_msg</span></div>";
}
-
+
print "</li>";
}
if (!$_SESSION["uid"] || !validate_session($link)) {
render_login_form($link, $mobile);
+ //header("Location: login.php");
exit;
} else {
/* bump login timestamp */
}
}
+ function bool_to_sql_bool($s) {
+ if ($s) {
+ return "true";
+ } else {
+ return "false";
+ }
+ }
function toggleEvenOdd($a) {
if ($a == "even")
}
}
- function catchup_feed($link, $feed, $cat_view) {
+ function catchup_feed($link, $feed, $cat_view, $owner_uid) {
+
+ if (!$owner_uid) $owner_uid = $_SESSION['uid'];
if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) {
if ($cat_view) {
- if ($feed > 0) {
- $cat_qpart = "cat_id = '$feed'";
- } else {
- $cat_qpart = "cat_id IS NULL";
- }
+ if ($feed >= 0) {
+
+ if ($feed > 0) {
+ $cat_qpart = "cat_id = '$feed'";
+ } else {
+ $cat_qpart = "cat_id IS NULL";
+ }
- $tmp_result = db_query($link, "SELECT id
- FROM ttrss_feeds WHERE $cat_qpart AND owner_uid = " .
- $_SESSION["uid"]);
+ $tmp_result = db_query($link, "SELECT id
+ FROM ttrss_feeds WHERE $cat_qpart AND owner_uid = $owner_uid");
+
+ while ($tmp_line = db_fetch_assoc($tmp_result)) {
- while ($tmp_line = db_fetch_assoc($tmp_result)) {
+ $tmp_feed = $tmp_line["id"];
+
+ db_query($link, "UPDATE ttrss_user_entries
+ SET unread = false,last_read = NOW()
+ WHERE feed_id = '$tmp_feed' AND owner_uid = $owner_uid");
+ }
+ } else if ($feed == -2) {
- $tmp_feed = $tmp_line["id"];
db_query($link, "UPDATE ttrss_user_entries
- SET unread = false,last_read = NOW()
- WHERE feed_id = '$tmp_feed' AND owner_uid = " . $_SESSION["uid"]);
+ SET unread = false,last_read = NOW() WHERE (SELECT COUNT(*)
+ FROM ttrss_user_labels2 WHERE article_id = ref_id) > 0
+ AND unread = true AND owner_uid = $owner_uid");
}
} else if ($feed > 0) {
db_query($link, "UPDATE ttrss_user_entries
SET unread = false,last_read = NOW()
WHERE (feed_id = '$feed' OR $children_qpart)
- AND owner_uid = " . $_SESSION["uid"]);
+ AND owner_uid = $owner_uid");
} else {
db_query($link, "UPDATE ttrss_user_entries
SET unread = false,last_read = NOW()
- WHERE feed_id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
+ WHERE feed_id = '$feed' AND owner_uid = $owner_uid");
}
} else if ($feed < 0 && $feed > -10) { // special, like starred
if ($feed == -1) {
db_query($link, "UPDATE ttrss_user_entries
SET unread = false,last_read = NOW()
- WHERE marked = true AND owner_uid = ".$_SESSION["uid"]);
+ WHERE marked = true AND owner_uid = $owner_uid");
}
if ($feed == -2) {
db_query($link, "UPDATE ttrss_user_entries
SET unread = false,last_read = NOW()
- WHERE published = true AND owner_uid = ".$_SESSION["uid"]);
+ WHERE published = true AND owner_uid = $owner_uid");
}
if ($feed == -3) {
ttrss_user_entries WHERE $match_part AND
unread = true AND
ttrss_user_entries.ref_id = ttrss_entries.id AND
- owner_uid = ".$_SESSION["uid"]);
+ owner_uid = $owner_uid");
$affected_ids = array();
if ($feed == -4) {
db_query($link, "UPDATE ttrss_user_entries
SET unread = false,last_read = NOW()
- WHERE owner_uid = ".$_SESSION["uid"]);
+ WHERE owner_uid = $owner_uid");
}
} else if ($feed < -10) { // label
$label_id = -$feed - 11;
db_query($link, "UPDATE ttrss_user_entries, ttrss_user_labels2
- SET unread = false WHERE label_id = '$label_id' AND unread = true
- AND owner_uid = '".$_SESSION["uid"]."' AND ref_id = article_id");
+ SET unread = false, last_read = NOW()
+ WHERE label_id = '$label_id' AND unread = true
+ AND owner_uid = '$owner_uid' AND ref_id = article_id");
}
- ccache_update($link, $feed, $_SESSION["uid"], $cat_view);
+ ccache_update($link, $feed, $owner_uid, $cat_view);
} else { // tag
db_query($link, "BEGIN");
$tag_name = db_escape_string($feed);
$result = db_query($link, "SELECT post_int_id FROM ttrss_tags
- WHERE tag_name = '$tag_name' AND owner_uid = " . $_SESSION["uid"]);
+ WHERE tag_name = '$tag_name' AND owner_uid = $owner_uid");
while ($line = db_fetch_assoc($result)) {
db_query($link, "UPDATE ttrss_user_entries SET
}
function get_script_dt_add() {
- if (strpos(VERSION, ".99") === false) {
+/* if (strpos(VERSION, ".99") === false) {
return VERSION;
} else {
return time();
- }
+ } */
+ return time();
}
function get_pgsql_version($link) {
print "<param key=\"hide_read_feeds\" value=\"" .
(int) get_pref($link, "HIDE_READ_FEEDS") . "\"/>";
+ print "<param key=\"enable_feed_cats\" value=\"" .
+ (int) get_pref($link, "ENABLE_FEED_CATS") . "\"/>";
+
print "<param key=\"feeds_sort_by_unread\" value=\"" .
(int) get_pref($link, "FEEDS_SORT_BY_UNREAD") . "\"/>";
print "<param key=\"sync_counters\" value=\"1\"/>";
+ print "<param key=\"offline_enabled\" value=\"".
+ (int) get_pref($link, "ENABLE_OFFLINE_READING") . "\"/>";
+
+ $result = db_query($link, "SELECT COUNT(*) AS cf FROM
+ ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
+
+ $num_feeds = db_fetch_result($result, 0, "cf");
+
+ print "<param key=\"num_feeds\" value=\"".
+ (int)$num_feeds. "\"/>";
+
print "</init-params>";
}
function print_runtime_info($link) {
print "<runtime-info>";
+ $result = db_query($link, "SELECT COUNT(*) AS cf FROM
+ ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
+
+ $num_feeds = db_fetch_result($result, 0, "cf");
+
+ print "<param key=\"num_feeds\" value=\"".
+ (int)$num_feeds. "\"/>";
+
if (ENABLE_UPDATE_DAEMON) {
print "<param key=\"daemon_is_running\" value=\"".
sprintf("%d", file_is_locked("update_daemon.lock")) . "\"/>";
if (CHECK_FOR_NEW_VERSION && $_SESSION["access_level"] >= 10) {
- if ($_SESSION["last_version_check"] + 86400 < time()) {
+ if ($_SESSION["last_version_check"] + 86400 + rand(-1000, 1000) < time()) {
$new_version_details = check_for_update($link);
print "<param key=\"new_version_available\" value=\"".
$feed_title = "?";
}
- if ($feed < -10) error_reporting (0);
-
$content_query_part = "content as content_preview,";
if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) {
guid,
ttrss_entries.id,ttrss_entries.title,
updated,
+ note,
unread,feed_id,marked,published,link,last_read,
".SUBSTRING_FOR_DATE."(last_read,1,19) as last_read_noms,
$vfeed_query_part
$result = db_query($link, "SELECT
guid,
+ note,
ttrss_entries.id as id,title,
updated,
unread,feed_id,
function generate_syndicated_feed($link, $owner_uid, $feed, $is_cat,
$limit, $search, $search_mode, $match_on) {
+ $note_style = "background-color : #fff7d5; border-width : 1px; ".
+ "padding : 5px; border-style : dashed; border-color : #e7d796;".
+ "margin-top : 5px; color : #9a8c59;";
+
if (!$limit) $limit = 30;
$qfh_ret = queryFeedHeadlines($link, $feed,
print "<title>" .
htmlspecialchars($line["title"]) . "</title>";
- print "<description><![CDATA[" .
- $line["content_preview"] . "]]></description>";
+ print "<description><![CDATA[";
+ print $line["content_preview"];
+ if ($line["note"]) {
+ print "<div style='$note_style'>";
+ print $line["note"];
+ print "</div>";
+ }
+ print "]]></description>";
print "</item>";
}
$mail = new PHPMailer();
- $mail->PluginDir = "phpmailer/";
- $mail->SetLanguage("en", "phpmailer/language/");
+ $mail->PluginDir = "lib/phpmailer/";
+ $mail->SetLanguage("en", "lib/phpmailer/language/");
$mail->CharSet = "UTF-8";
function prepare_headlines_digest($link, $user_id, $days = 1, $limit = 100) {
- require_once "MiniTemplator.class.php";
+ require_once "lib/MiniTemplator.class.php";
$tpl = new MiniTemplator;
$tpl_t = new MiniTemplator;
return array($tmp, $headlines_count, $affected_ids, $tmp_t);
}
- function check_for_update($link, $brief_fmt = true) {
+ function check_for_update($link) {
$releases_feed = "http://tt-rss.org/releases.rss";
if (!CHECK_FOR_NEW_VERSION || $_SESSION["access_level"] < 10) {
}
if (version_compare(VERSION, $latest_version) == -1) {
- if ($brief_fmt) {
- return format_notice("<a href=\"javascript:showBlockElement('milestoneDetails')\">
- New version of Tiny-Tiny RSS ($latest_version) is available (click for details)</a>
- <div id=\"milestoneDetails\">$content</div>");
- } else {
- return "New version of Tiny-Tiny RSS ($latest_version) is available:
- <div class='milestoneDetails'>$content</div>
- Visit <a target=\"_blank\" href=\"http://tt-rss.org/\">official site</a> for
- download and update information.";
- }
-
- }
+ return sprintf("New version of Tiny-Tiny RSS (%s) is available:",
+ $latest_version)."<div class='milestoneDetails'>$content</div>";
+ } else {
+ return false;
+ }
}
}
}
function print_headline_subtoolbar($link, $feed_site_url, $feed_title,
- $bottom = false, $rtl_content = false, $feed_id = 0,
- $is_cat = false, $search = false, $match_on = false,
- $search_mode = false, $offset = 0, $limit = 0,
- $dashboard_menu = 0, $disable_feed = 0, $feed_small_icon = 0) {
-
- $user_page_offset = $offset + 1;
-
- if (!$bottom) {
- $class = "headlinesSubToolbar";
- $tid = "headlineActionsTop";
- } else {
- $class = "headlinesSubToolbar";
- $tid = "headlineActionsBottom";
- }
+ $feed_id, $is_cat, $search, $match_on,
+ $search_mode) {
- print "<nobr><table class=\"$class\" id=\"$tid\"
- width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
-
- if ($rtl_content) {
- $rtl_cpart = "RTL";
- } else {
- $rtl_cpart = "";
- }
+ print "<div class=\"headlinesSubToolbar\">";
$page_prev_link = "javascript:viewFeedGoPage(-1)";
$page_next_link = "javascript:viewFeedGoPage(1)";
}
- print "<td class=\"headlineActions$rtl_cpart\">";
+ print "<div id=\"subtoolbar_ftitle\">";
+
+ if ($feed_site_url) {
+ if (!$bottom) {
+ $target = "target=\"_blank\"";
+ }
+ print "<a $target href=\"$feed_site_url\">".
+ truncate_string($feed_title,30)."</a>";
+ } else {
+ print $feed_title;
+ }
+
+ if ($search) {
+ $search_q = "&q=$search&m=$match_on&smode=$search_mode";
+ }
+
+ print "
+ <a target=\"_blank\"
+ href=\"backend.php?op=rss&id=$feed_id&is_cat=$is_cat$search_q\">
+ <img class=\"noborder\"
+ alt=\"".__('Generated feed')."\" src=\"images/feed-icon-12x12.png\">
+ </a>";
+ print "</div>";
print __('Select:')."
<a href=\"$sel_all_link\">".__('All')."</a>,
//print "<li><span class=\"insensitive\">--------</span></li>";
print "<li class=\"insensitive\">".__('Assign label:')."</li>";
- print "<li onclick=\"javascript:addLabel()\">
- ".__("Create label...")."</li>";
-
- $result = db_query($link, "SELECT id, caption FROM ttrss_labels2 WHERE
- owner_uid = '".$_SESSION["uid"]."' ORDER BY caption");
-
- while ($line = db_fetch_assoc($result)) {
-
- $label_id = $line["id"];
- $label_caption = $line["caption"];
-
- if ($feed_id < -10 && $feed_id == -11-$label_id) {
- print "<li onclick=\"javascript:selectionRemoveLabel($label_id)\">
- $label_caption ".__('(remove)')."</li>";
- } else {
- print "<li onclick=\"javascript:selectionAssignLabel($label_id)\">
- $label_caption</li>";
- }
- }
+ print_labels_headlines_dropdown($link, $feed_id);
print "</ul>";
- print "</td>";
-
- print "<td class=\"headlineTitle$rtl_cpart\">";
-
- print "<span id=\"subtoolbar_ftitle\">";
-
- if ($feed_site_url) {
- if (!$bottom) {
- $target = "target=\"_blank\"";
- }
- print "<a $target href=\"$feed_site_url\">".
- truncate_string($feed_title,30)."</a>";
- } else {
- print $feed_title;
- }
-
- if ($search) {
- $search_q = "&q=$search&m=$match_on&smode=$search_mode";
- }
-
- if ($user_page_offset > 1) {
- print " [$user_page_offset] ";
- }
-
- if (!$bottom && !$disable_feed) {
- print "
- <a target=\"_blank\"
- href=\"backend.php?op=rss&id=$feed_id&is_cat=$is_cat$search_q\">
- <img class=\"noborder\"
- alt=\"".__('Generated feed')."\" src=\"images/feed-icon-12x12.png\">
- </a>";
- } else if ($feed_small_icon) {
- print "<img class=\"noborder\" alt=\"\" src=\"images/$feed_small_icon\">";
- }
-
- print "</span>";
-
- print "</td>";
- print "</tr></table></nobr>";
+ print "</div>";
}
function printCategoryHeader($link, $cat_id, $hidden = false, $can_browse = true) {
if (!$tags) {
- $result = db_query($link, "SELECT id,caption FROM
+ $result = db_query($link, "SELECT * FROM
ttrss_labels2 WHERE owner_uid = '$owner_uid' ORDER by caption");
if (db_num_rows($result) > 0) {
printFeedEntry($label_id,
$class, $line["caption"],
- $count, "images/label.png", $link);
+ $count, "images/label.png", $link,
+ false, false, false,
+ $line['fg_color'], $line['bg_color']);
}
".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
(SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url,
num_comments,
- author
+ author,
+ note
FROM ttrss_entries,ttrss_user_entries
WHERE id = '$id' AND ref_id = id AND owner_uid = " . $_SESSION["uid"]);
print "<div clear='both'>" . $line["title"] . "$entry_author</div>";
}
- $tags = get_article_tags($link, $id);
-
- $tags_str = "";
- $tags_nolinks_str = "";
- $f_tags_str = "";
-
- $num_tags = 0;
-
- if ($_SESSION["theme"] == "3pane") {
- $tag_limit = 3;
- } else {
- $tag_limit = 6;
- }
-
- foreach ($tags as $tag) {
- $num_tags++;
- $tag_escaped = str_replace("'", "\\'", $tag);
-
- $tag_str = "<a href=\"javascript:viewfeed('$tag_escaped')\">$tag</a>, ";
-
- if ($num_tags == $tag_limit) {
- $tags_str .= "…";
- $tags_nolinks_str .= "…";
-
- } else if ($num_tags < $tag_limit) {
- $tags_str .= $tag_str;
- $tags_nolinks_str .= "$tag, ";
- }
- $f_tags_str .= $tag_str;
- }
-
- $tags_str = preg_replace("/, $/", "", $tags_str);
- $tags_nolinks_str = preg_replace("/, $/", "", $tags_nolinks_str);
- $f_tags_str = preg_replace("/, $/", "", $f_tags_str);
-
- $all_tags_div = "<span class='cdmAllTagsCtr'>…<div class='cdmAllTags'>All Tags: $f_tags_str</div></span>";
- $tags_str = preg_replace("/\.\.\.$/", "$all_tags_div", $tags_str);
+ $tags_str = format_tags_string(get_article_tags($link, $id), $id);
if (!$entry_comments) $entry_comments = " "; # placeholder
- if (!$tags_str) $tags_str = '<span class="tagList">'.__('no tags').'</span>';
- if (!$tags_nolinks_str) $tags_nolinks_str = '<span class="tagList">'.__('no tags').'</span>';
-
print "<div style='float : right'>
- <img src='images/tag.png' class='tagsPic' alt='Tags' title='Tags'>";
+ <img src='images/tag.png' class='tagsPic' alt='Tags' title='Tags'> ";
if (!$zoom_mode) {
- print "$tags_str
+ print "<span id=\"ATSTR-$id\">$tags_str</span>
<a title=\"".__('Edit tags for this article')."\"
href=\"javascript:editArticleTags($id, $feed_id)\">(+)</a>";
style=\"cursor : pointer\" style=\"cursor : pointer\"
onclick=\"zoomToArticle($id)\"
alt='Zoom' title='".__('Show article summary in new window')."'>";
- } else {
- print "$tags_nolinks_str";
+
+ $note_escaped = htmlspecialchars($line['note'], ENT_QUOTES);
+
+ print "<img src=\"images/art-pub-note.png\" class='tagsPic'
+ style=\"cursor : pointer\" style=\"cursor : pointer\"
+ onclick=\"publishWithNote($id, '$note_escaped')\"
+ alt='PubNote' title='".__('Publish article with a note')."'>";
+
}
print "</div>";
print "<div clear='both'>$entry_comments</div>";
print "<div class=\"postContent\">";
- #print "<div id=\"allEntryTags\">".__('Tags:')." $f_tags_str</div>";
-
$article_content = sanitize_rss($link, $line["content"]);
if (get_pref($link, 'OPEN_LINKS_IN_NEW_WINDOW')) {
print $article_content;
+ print "<div id=\"POSTNOTE-$id\">";
+ if ($line['note']) {
+ print format_article_note($id, $line['note']);
+ }
+ print "</div>";
+
$result = db_query($link, "SELECT * FROM ttrss_enclosures WHERE
post_id = '$id' AND content_url != ''");
return;
}
- print_headline_subtoolbar($link, $feed_site_url, $feed_title, false,
- $rtl_content, $feed, $cat_view, $search, $match_on, $search_mode,
- $offset, $limit);
+ print_headline_subtoolbar($link, $feed_site_url, $feed_title,
+ $feed, $cat_view, $search, $match_on, $search_mode);
print "<div id=\"headlinesInnerContainer\" onscroll=\"headlines_scroll_handler()\">";
}
$feed_id = $line["feed_id"];
$labels = get_article_labels($link, $id);
- $labels_str = "<span id=\"HLLCTR-$id\">";
-
- foreach ($labels as $l) {
- $labels_str .= "<span
- class='hlLabelRef'>".
- $l[1]."</span>";
- }
+ $labels_str = "<span id=\"HLLCTR-$id\">";
+ $labels_str .= format_article_labels($labels, $id);
$labels_str .= "</span>";
-
+
if (count($topmost_article_ids) < 5) {
array_push($topmost_article_ids, $id);
}
// print "<div class=\"cdmInnerContent\" id=\"CICD-$id\" $cdm_cstyle>";
print sanitize_rss($link, $line["content_preview"]);
+
+ print "<div id=\"POSTNOTE-$id\">";
+ if ($line['note']) {
+ print format_article_note($id, $line['note']);
+ }
+ print "</div>";
+
$article_content = $line["content_preview"];
$e_result = db_query($link, "SELECT * FROM ttrss_enclosures WHERE
" <input type=\"checkbox\" onclick=\"toggleSelectRowById(this,
'RROW-$id')\" class=\"feedCheckBox\" id=\"RCHK-$id\">";
- print "</span><span class='s1'>$marked_pic</span> ";
- print "<span class='s1'>$published_pic</span> ";
- print "<span class='s1'><img src=\"images/art-zoom.png\" class='tagsPic'
+ print "</span><span class='s1'>$marked_pic ";
+ print "$published_pic ";
+ print "<img src=\"images/art-zoom.png\" class='tagsPic'
onclick=\"zoomToArticle($id)\"
style=\"cursor : pointer\"
alt='Zoom'
- title='".__('Show article summary in new window')."'></span>";
-
- $tags = get_article_tags($link, $id);
-
- $tags_str = "";
- $full_tags_str = "";
- $num_tags = 0;
+ title='".__('Show article summary in new window')."'> ";
- foreach ($tags as $tag) {
- $num_tags++;
- $full_tags_str .= "<a href=\"javascript:viewfeed('$tag')\">$tag</a>, ";
- if ($num_tags < 5) {
- $tags_str .= "<a href=\"javascript:viewfeed('$tag')\">$tag</a>, ";
- } else if ($num_tags == 5) {
- $tags_str .= "…";
- }
- }
-
- $tags_str = preg_replace("/, $/", "", $tags_str);
- $full_tags_str = preg_replace("/, $/", "", $full_tags_str);
-
- $all_tags_div = "<span class='cdmAllTagsCtr'>…<div class='cdmAllTags'>All Tags: $full_tags_str</div></span>";
+ $note_escaped = htmlspecialchars($line['note'], ENT_QUOTES);
- $tags_str = preg_replace("/\.\.\.$/", "$all_tags_div", $tags_str);
+ print "<img src=\"images/art-pub-note.png\" class='tagsPic'
+ style=\"cursor : pointer\" style=\"cursor : pointer\"
+ onclick=\"publishWithNote($id, '$note_escaped')\"
+ alt='PubNote' title='".__('Publish article with a note')."'>";
+ print "</span>";
- if ($tags_str == "") $tags_str = "no tags";
+ $tags_str = format_tags_string(get_article_tags($link, $id), $id);
// print "<img src='images/tag.png' class='markedPic'>";
print "<span class='s1'>
- <img class='tagsPic' src='images/tag.png' alt='Tags'
- title='Tags'> $tags_str <a title=\"Edit tags for this article\"
- href=\"javascript:editArticleTags($id, $feed_id, true)\">(+)</a>";
+ <img class='tagsPic' src='images/tag.png' alt='Tags' title='Tags'>
+ <span id=\"ATSTR-$id\">$tags_str</span>
+ <a title=\"".__('Edit tags for this article')."\"
+ href=\"javascript:editArticleTags($id, $feed_id, true)\">(+)</a>";
print "</span>";
- print "<span class='s2'>Toggle: <a class=\"cdmToggleLink\"
+ print "<span class='s2'><a class=\"cdmToggleLink\"
href=\"javascript:toggleUnread($id)\">
- Unread</a></span>";
+ ".__('toggle unread')."</a></span>";
print "</div>";
print "</div>";
value = 0 WHERE owner_uid = '$owner_uid'");
}
+ function ccache_remove($link, $feed_id, $owner_uid, $is_cat = false) {
+
+ if (!$is_cat) {
+ $table = "ttrss_counters_cache";
+ } else {
+ $table = "ttrss_cat_counters_cache";
+ }
+
+ db_query($link, "DELETE FROM $table WHERE
+ feed_id = '$feed_id' AND owner_uid = '$owner_uid'");
+
+ }
+
function ccache_update_all($link, $owner_uid) {
if (get_pref($link, 'ENABLE_FEED_CATS', $owner_uid)) {
function ccache_find($link, $feed_id, $owner_uid, $is_cat = false,
$no_update = false) {
+ if (!is_numeric($feed_id)) return;
+
if (!$is_cat) {
$table = "ttrss_counters_cache";
} else {
function ccache_update($link, $feed_id, $owner_uid, $is_cat = false,
$update_pcat = true) {
+ if (!is_numeric($feed_id)) return;
+
$prev_unread = ccache_find($link, $feed_id, $owner_uid, $is_cat, true);
/* When updating a label, all we need to do is recalculate feed counters
$unread = (int) getFeedArticles($link, $feed_id, $is_cat, true, $owner_uid);
}
+ db_query($link, "BEGIN");
+
$result = db_query($link, "SELECT feed_id FROM $table
WHERE owner_uid = '$owner_uid' AND feed_id = '$feed_id' LIMIT 1");
($feed_id, $unread, $owner_uid, NOW())");
}
+ db_query($link, "COMMIT");
+
if ($feed_id > 0 && $prev_unread != $unread) {
if (!$is_cat) {
function get_article_labels($link, $id) {
$result = db_query($link,
- "SELECT DISTINCT label_id,caption
+ "SELECT DISTINCT label_id,caption,fg_color,bg_color
FROM ttrss_labels2, ttrss_user_labels2
WHERE id = label_id
AND article_id = '$id'
$rv = array();
while ($line = db_fetch_assoc($result)) {
- $rk = array($line["label_id"], $line["caption"]);
+ $rk = array($line["label_id"], $line["caption"], $line["fg_color"],
+ $line["bg_color"]);
array_push($rv, $rk);
}
db_query($link, "COMMIT");
}
+
+ function label_create($link, $caption) {
+
+ db_query($link, "BEGIN");
+
+ $result = false;
+
+ $result = db_query($link, "SELECT id FROM ttrss_labels2
+ WHERE caption = '$caption' AND owner_uid = ". $_SESSION["uid"]);
+
+ if (db_num_rows($result) == 0) {
+ $result = db_query($link,
+ "INSERT INTO ttrss_labels2 (caption,owner_uid)
+ VALUES ('$caption', '".$_SESSION["uid"]."')");
+
+ $result = db_affected_rows($link, $result) != 0;
+ }
+
+ db_query($link, "COMMIT");
+
+ return $result;
+ }
+
+ function print_labels_headlines_dropdown($link, $feed_id) {
+ print "<li onclick=\"javascript:addLabel()\">
+ ".__("Create label...")."</li>";
+
+ $result = db_query($link, "SELECT id, caption FROM ttrss_labels2 WHERE
+ owner_uid = '".$_SESSION["uid"]."' ORDER BY caption");
+
+ while ($line = db_fetch_assoc($result)) {
+
+ $label_id = $line["id"];
+ $label_caption = $line["caption"];
+
+ if ($feed_id < -10 && $feed_id == -11-$label_id) {
+ print "<li id=\"LHDL-$id\"
+ onclick=\"javascript:selectionRemoveLabel($label_id)\">
+ $label_caption ".__('(remove)')."</li>";
+ } else {
+ print "<li id=\"LHDL-$id\"
+ onclick=\"javascript:selectionAssignLabel($label_id)\">
+ $label_caption</li>";
+ }
+ }
+ }
+
+ function format_tags_string($tags, $id) {
+
+ $tags_str = "";
+ $tags_nolinks_str = "";
+
+ $num_tags = 0;
+
+ if ($_SESSION["theme"] == "3pane") {
+ $tag_limit = 3;
+ } else {
+ $tag_limit = 6;
+ }
+
+ $formatted_tags = array();
+
+ foreach ($tags as $tag) {
+ $num_tags++;
+ $tag_escaped = str_replace("'", "\\'", $tag);
+
+ $tag_str = "<a href=\"javascript:viewfeed('$tag_escaped')\">$tag</a>";
+
+ array_push($formatted_tags, $tag_str);
+
+ if ($num_tags == $tag_limit) {
+ break;
+ }
+ }
+
+ $tags_str = implode(", ", $formatted_tags);
+
+ if ($num_tags < count($tags)) {
+ $tags_str .= ", …";
+ }
+
+ if ($num_tags == 0) {
+ $tags_str = __("no tags");
+ }
+
+ return $tags_str;
+
+ }
+
+ function format_article_labels($labels, $id) {
+
+ $labels_str = "";
+
+ foreach ($labels as $l) {
+ $labels_str .= sprintf("<span class='hlLabelRef'
+ style='color : %s; background-color : %s'>%s</span>",
+ $l[2], $l[3], $l[1]);
+ }
+
+ return $labels_str;
+
+ }
+
+ function format_article_note($id, $note) {
+
+ $note_escaped = htmlspecialchars($note, ENT_QUOTES);
+
+ $str = "<div class='articleNote'>";
+ $str .= "<div class='articleNoteOps'>";
+ $str .= "<a href=\"javascript:publishWithNote($id, '$note_escaped')\">".
+ __('edit note')."</a>";
+ $str .= "</div>";
+ $str .= $note;
+ $str .= "</div>";
+
+ return $str;
+ }
?>