From dad14b513d3e9bab376d3691043c49a99d6db0a4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 9 Nov 2010 20:57:23 +0300 Subject: refactor combined mode, code cleanup --- functions.php | 399 +++++++++++++++++++++++----------------------------------- 1 file changed, 158 insertions(+), 241 deletions(-) (limited to 'functions.php') diff --git a/functions.php b/functions.php index bc3b28826..af5a5c828 100644 --- a/functions.php +++ b/functions.php @@ -4979,76 +4979,11 @@ print $article_content; -// $result = db_query($link, "SELECT * FROM ttrss_enclosures WHERE -// post_id = '$id' AND content_url != ''"); + print_article_enclosures($link, $id, $always_display_enclosures, + $article_content); - $result = get_article_enclosures($link, $id); - -// if (db_num_rows($result) > 0) { - - if (count($result) > 0) { - - $entries_html = array(); - $entries = array(); - - //while ($line = db_fetch_assoc($result)) { - foreach ($result as $line) { - - $url = $line["content_url"]; - $ctype = $line["content_type"]; - - if (!$ctype) $ctype = __("unknown type"); - - $filename = substr($url, strrpos($url, "/")+1); - - $entry = format_inline_player($link, $url, $ctype); - - $entry .= " " . - $filename . " (" . $ctype . ")" . ""; - - array_push($entries_html, $entry); - - $entry = array(); - - $entry["type"] = $ctype; - $entry["filename"] = $filename; - $entry["url"] = $url; - - array_push($entries, $entry); - } - - print "
"; - - if (!get_pref($link, "STRIP_IMAGES")) { - if ($always_display_enclosures || - !preg_match("/\"".htmlspecialchars($entry["filename"])."\"

"; - } - } - } - } - - if (db_num_rows($result) == 1) { - print __("Attachment:") . " "; - } else { - print __("Attachments:") . " "; - } - - print join(", ", $entries_html); - - print "
"; - } - print ""; - + print ""; } @@ -5453,102 +5388,85 @@ } $expand_cdm = get_pref($link, 'CDM_EXPANDED'); - $show_excerpt = false; - - if ($expand_cdm && $score >= -100) { - $cdm_cstyle = ""; - $show_excerpt = false; - } else { - $cdm_cstyle = "style=\"display : none\""; - $show_excerpt = true; - } $mouseover_attrs = "onmouseover='postMouseIn($id)' onmouseout='postMouseOut($id)'"; - print "
"; print "
"; - if (!get_pref($link, "VFEED_GROUP_BY_FEED") || !$line["feed_title"]) { - $cdm_feed_icon = "$feed_icon_img"; - } + print "
"; + print "$updated_fmt"; + print "$marked_pic"; + print "$published_pic"; + print "$score_pic"; - print "
$updated_fmt $score_pic $cdm_feed_icon -
"; + if (!get_pref($link, "VFEED_GROUP_BY_FEED") && $line["feed_title"]) { + print "$feed_icon_img"; + } + print "
"; + + print ""; - print " + ".$line["title"]." - "; - - print $entry_author; - -/* if (!$expand_cdm || $score < -100) { - print "  - (".__('Show article').")"; - } */ + "; print $labels_str; - if (!get_pref($link, 'VFEED_GROUP_BY_FEED')) { - if ($line["feed_title"]) { - print " (".$line["feed_title"].")"; - } - } + if ($expand_cdm) + $content_hidden = "style=\"display : none\""; + else + $excerpt_hidden = "style=\"display : none\""; - print "
"; + print " - $content_preview"; - if ($show_excerpt) { - print "
"; + print "
"; - $content_preview = trim(truncate_string(strip_tags($line["content_preview"]), 100)); + print "
"; - if (strlen($content_preview) != 0) { - print $content_preview; - } else { - print __('Click to expand article'); - } - print "
"; - } - - print "
"; + print "
"; - if ($line["orig_feed_id"]) { + if ($line["orig_feed_id"]) { - $tmp_result = db_query($link, "SELECT * FROM ttrss_archived_feeds - WHERE id = ".$line["orig_feed_id"]); + $tmp_result = db_query($link, "SELECT * FROM ttrss_archived_feeds + WHERE id = ".$line["orig_feed_id"]); if (db_num_rows($tmp_result) != 0) { - - print "
"; - print __("Originally from:"); - - print " "; - - $tmp_line = db_fetch_assoc($tmp_result); - - print "" . - $tmp_line['title'] . ""; - - print " "; - - print ""; - print ""; - - print "
"; + + print "
"; + print __("Originally from:"); + + print " "; + + $tmp_line = db_fetch_assoc($tmp_result); + + print "" . + $tmp_line['title'] . ""; + + print " "; + + print ""; + print ""; + + print "
"; + } } - } -// print "
"; + $article_content = sanitize_rss($link, $line["content_preview"]); print "
"; if ($line['note']) { @@ -5556,136 +5474,69 @@ } print "
"; - print sanitize_rss($link, $line["content_preview"]); - - $article_content = $line["content_preview"]; - - $e_result = db_query($link, "SELECT * FROM ttrss_enclosures WHERE - post_id = '$id' AND content_url != ''"); - - if (db_num_rows($e_result) > 0) { - - $entries_html = array(); - $entries = array(); - - while ($e_line = db_fetch_assoc($e_result)) { - - $url = $e_line["content_url"]; - $ctype = $e_line["content_type"]; - if (!$ctype) $ctype = __("unknown type"); - - $filename = substr($url, strrpos($url, "/")+1); - - $entry = format_inline_player($link, $url, $ctype); - - $entry .= " " . - $filename . " (" . $ctype . ")" . ""; - - array_push($entries_html, $entry); + print $article_content; - $entry = array(); - - $entry["type"] = $ctype; - $entry["filename"] = $filename; - $entry["url"] = $url; - - array_push($entries, $entry); - } - - $tmp_result = db_query($link, "SELECT always_display_enclosures FROM - ttrss_feeds WHERE id = ". + $tmp_result = db_query($link, "SELECT always_display_enclosures FROM + ttrss_feeds WHERE id = ". (($line['feed_id'] == null) ? $line['orig_feed_id'] : $line['feed_id'])." AND owner_uid = ".$_SESSION["uid"]); - $always_display_enclosures = db_fetch_result($tmp_result, 0, "always_display_enclosures"); - - if (!get_pref($link, "STRIP_IMAGES")) { - if ($always_display_enclosures || - !preg_match("/img/i", $article_content)) { - - foreach ($entries as $entry) { - if (preg_match("/image/", $entry["type"]) || - preg_match("/\.(jpg|png|gif|bmp)/i", $entry["filename"])) { - print "

\"".htmlspecialchars($entry["filename"])."\"

"; - } - } - } - } - - print "
"; - - if (db_num_rows($e_result) == 1) { - print __("Attachment:") . " "; - } else { - print __("Attachments:") . " "; - } - - print join(", ", $entries_html); - - print "
"; - } - - - print "
"; -// print "
"; + $always_display_enclosures = sql_bool_to_bool(db_fetch_result($tmp_result, + 0, "always_display_enclosures")); -/* if (!$expand_cdm) { - print " - Show article"; - } */ + print_article_enclosures($link, $id, $always_display_enclosures, + $article_content); print "
"; - print "
"; + print "
"; - /* print "
Star it: $marked_pic
"; */ + $tags_str = format_tags_string(get_article_tags($link, $id), $id); + + print "Tags + $tags_str + (+)"; - print __("Select:"). - " "; + print "
"; - print "$marked_pic "; - print "$published_pic "; - print "Zoom "; + title='".__('Show article summary in new window')."'>"; + + if (DIGEST_ENABLE) { + print "Zoom"; + } $note_escaped = htmlspecialchars($line['note'], ENT_QUOTES); - print "PubNote"; - print ""; - - $tags_str = format_tags_string(get_article_tags($link, $id), $id); - - print " - Tags - $tags_str - (+)"; + print "Dismiss"; - print ""; + print "
"; + print "
"; - print " - ".__('toggle unread').""; + print "
"; print "
"; - print "
"; - } + } ++$lnum; - } + } if (!get_pref($link, 'COMBINED_DISPLAY_MODE') && !$offset) { print ""; @@ -7110,4 +6961,70 @@ } + function print_article_enclosures($link, $id, $always_display_enclosures, + $article_content) { + + $result = get_article_enclosures($link, $id); + + if (count($result) > 0) { + + $entries_html = array(); + $entries = array(); + + foreach ($result as $line) { + + $url = $line["content_url"]; + $ctype = $line["content_type"]; + + if (!$ctype) $ctype = __("unknown type"); + + $filename = substr($url, strrpos($url, "/")+1); + + $entry = format_inline_player($link, $url, $ctype); + + $entry .= " " . + $filename . " (" . $ctype . ")" . ""; + + array_push($entries_html, $entry); + + $entry = array(); + + $entry["type"] = $ctype; + $entry["filename"] = $filename; + $entry["url"] = $url; + + array_push($entries, $entry); + } + + print "
"; + + if (!get_pref($link, "STRIP_IMAGES")) { + if ($always_display_enclosures || + !preg_match("/\"".htmlspecialchars($entry["filename"])."\"

"; + } + } + } + } + + if (db_num_rows($result) == 1) { + print __("Attachment:") . " "; + } else { + print __("Attachments:") . " "; + } + + print join(", ", $entries_html); + + print "
"; + } + } + ?> -- cgit v1.2.3