]> git.wh0rd.org Git - tt-rss.git/commitdiff
add option to force display attachments in feeds (implementation)
authorAndrew Dolgov <fox@bah.org.ru>
Tue, 6 Oct 2009 10:15:29 +0000 (14:15 +0400)
committerAndrew Dolgov <fox@bah.org.ru>
Tue, 6 Oct 2009 10:15:29 +0000 (14:15 +0400)
functions.php
modules/pref-feeds.php
sanity_check.php

index b67ff95703ac833dff333a68206d6f80fe754769..effd20005869c0b2e67bbdff3a81ecb30fcf2070 100644 (file)
 
                if (!$zoom_mode) { print "<article id='$id'><![CDATA["; };
 
-               $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds
+               $result = db_query($link, "SELECT rtl_content, always_display_enclosures FROM ttrss_feeds
                        WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
 
                if (db_num_rows($result) == 1) {
                        $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
+                       $always_display_enclosures = sql_bool_to_bool(db_fetch_result($result, 0, "always_display_enclosures"));
                } else {
                        $rtl_content = false;
+                       $always_display_enclosures = false;
                }
 
                if ($rtl_content) {
 
                                print "<div class=\"postEnclosures\">";
 
-                               if (!preg_match("/<img/i", $article_content)) {
+                               if ($always_display_enclosures || !preg_match("/<img/i", $article_content)) {
                                        foreach ($entries as $entry) {
                                                if (preg_match("/image/", $entry["type"])) {
                                                        print "<p><img 
 
 //                                     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>";
 
+                                       print sanitize_rss($link, $line["content_preview"]);
+
                                        $article_content = $line["content_preview"];
 
                                        $e_result = db_query($link, "SELECT * FROM ttrss_enclosures WHERE
                                        array_push($entries, $entry);
                                }
 
-                               if (!preg_match("/img/i", $article_content)) {
+                               $tmp_result = db_query($link, "SELECT always_display_enclosures FROM
+                                       ttrss_feeds WHERE id = ".$line['feed_id']." AND owner_uid = ".$_SESSION["uid"]);
+
+                               $always_display_enclosures = db_fetch_result($tmp_result, 0, "always_display_enclosures");
+
+                               if ($always_display_enclosures || !preg_match("/img/i", $article_content)) {
                                        foreach ($entries as $entry) {
                                                if (preg_match("/image/", $entry["type"])) {
                                                        print "<p><img 
index 6aec173361e51dbd3c7f8801adeb1827115d9a8c..b30b6db6f45cf96ff41a932003d3c5e4f4391dc5 100644 (file)
                                name=\"include_in_digest\"
                                $checked>&nbsp;<label for=\"include_in_digest\">".__('Include in e-mail digest')."</label>";
 
+
+                       $always_display_enclosures = sql_bool_to_bool(db_fetch_result($result, 0, "always_display_enclosures"));
+
+                       if ($always_display_enclosures) {
+                               $checked = "checked";
+                       } else {
+                               $checked = "";
+                       }
+
+                       print "<br/><input type=\"checkbox\" id=\"always_display_enclosures\" 
+                               name=\"always_display_enclosures\"
+                               $checked>&nbsp;<label for=\"always_display_enclosures\">".__('Always display image attachments')."</label>";
+
+
                        $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
 
                        if ($cache_images) {
                                db_escape_string($_POST["cache_images"]));
                        $update_method = (int) db_escape_string($_POST["update_method"]);
 
+                       $always_display_enclosures = checkbox_to_sql_bool(
+                               db_escape_string($_POST["always_display_enclosures"]));
+
                        if (get_pref($link, 'ENABLE_FEED_CATS')) {                      
                                if ($cat_id && $cat_id != 0) {
                                        $category_qpart = "cat_id = '$cat_id',";
                                        hidden = $hidden,
                                        $cache_images_qpart
                                        include_in_digest = $include_in_digest,
+                                       always_display_enclosures = $always_display_enclosures,
                                        update_method = '$update_method'
                                        WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
 
index ab4e29b3aa21647a2be4f57bebb3c6d90363c9a6..600f8d9f40fdf2ade4bac298c45341f8a7785c5b 100644 (file)
@@ -2,7 +2,7 @@
        require_once "functions.php";
 
        define('EXPECTED_CONFIG_VERSION', 18);
-       define('SCHEMA_VERSION', 56);
+       define('SCHEMA_VERSION', 57);
 
        if (!file_exists("config.php")) {
                print "<b>Fatal Error</b>: You forgot to copy