]> git.wh0rd.org Git - tt-rss.git/commitdiff
allow per-feed update method selection
authorAndrew Dolgov <fox@bah.spb.su>
Fri, 25 Jan 2008 17:46:01 +0000 (18:46 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Fri, 25 Jan 2008 17:46:01 +0000 (18:46 +0100)
backend.php
functions.php
modules/pref-feeds.php

index 8af861fdc15096070d686e6881821a31fc7ef81a..c8271f4f975396a05a10d9c712a0ef380995f196 100644 (file)
                1440 => __("Daily"),
                10080 => __("Weekly"));
 
-       $update_method = array(
+       $update_methods = array(
                0   => __("Use default"),
                1   => __("Magpie"),
                2   => __("SimplePie"));
-               
+
+       if (ENABLE_SIMPLEPIE) {
+               $update_methods[0] .= ' (SimplePie)';
+       } else {
+               $update_methods[0] .= ' (Magpie)';
+       }
+
        $access_level_names = array(
                0 => __("User"), 
                10 => __("Administrator"));
index 4e4e8ef0e5e2c5f47411d5af21189d53bd6cc9f6..6cc3b6785f898ee3011f21c1dfcc04174c05f819 100644 (file)
        define('MAGPIE_USER_AGENT_EXT', ' (Tiny Tiny RSS/' . VERSION . ')');
        define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
 
-       if (ENABLE_SIMPLEPIE) {
-               require_once "simplepie/simplepie.inc";
-       } else {
-               require_once "magpierss/rss_fetch.inc";
-               require_once 'magpierss/rss_utils.inc';
-       }
+       require_once "simplepie/simplepie.inc";
+       require_once "magpierss/rss_fetch.inc";
+       require_once 'magpierss/rss_utils.inc';
 
        function _debug($msg) {
                $ts = strftime("%H:%M:%S", time());
                                }                       
        
                        $result = db_query($link, "SELECT id,update_interval,auth_login,
-                               auth_pass,cache_images
+                               auth_pass,cache_images,update_method
                                FROM ttrss_feeds WHERE id = '$feed' AND $updstart_thresh_qpart");
 
                } else {
 
                        $result = db_query($link, "SELECT id,update_interval,auth_login,
-                               auth_pass,cache_images
+                               auth_pass,cache_images,update_method
                                FROM ttrss_feeds WHERE id = '$feed'");
 
                }
                        return;
                }
 
+               $update_method = db_fetch_result($result, 0, "update_method");
+
                db_query($link, "UPDATE ttrss_feeds SET last_update_started = NOW()
                        WHERE id = '$feed'");
 
                $auth_login = db_fetch_result($result, 0, "auth_login");
                $auth_pass = db_fetch_result($result, 0, "auth_pass");
 
-               if (!ENABLE_SIMPLEPIE) {
+               if (ENABLE_SIMPLEPIE) {
+                       $use_simplepie = $update_method != 1;
+               } else {
+                       $use_simplepie = $update_method == 2;
+               }
+
+               if (defined('DAEMON_EXTENDED_DEBUG') || $_GET['xdebug']) {
+                       _debug("use simplepie: $use_simplepie (feed setting: $update_method)\n");
+               }
+
+               if (!$use_simplepie) {
                        $auth_login = urlencode($auth_login);
                        $auth_pass = urlencode($auth_pass);
                }
                        error_reporting(0);
                }
 
-               if (!ENABLE_SIMPLEPIE) {
+               if (!$use_simplepie) {
                        $rss = fetch_rss($fetch_url);
                } else {
                        if (!is_dir(SIMPLEPIE_CACHE_DIR)) {
 
                        $rss = new SimplePie();
                        $rss->set_useragent(SIMPLEPIE_USERAGENT . MAGPIE_USER_AGENT_EXT);
-                       $rss->set_timeout(10);
+#                      $rss->set_timeout(10);
                        $rss->set_feed_url($fetch_url);
                        $rss->set_output_encoding('UTF-8');
 
 
                $feed = db_escape_string($feed);
 
-               if (ENABLE_SIMPLEPIE) {
+               if ($use_simplepie) {
                        $fetch_ok = !$rss->error();
                } else {
                        $fetch_ok = !!$rss;
 
                        $owner_uid = db_fetch_result($result, 0, "owner_uid");
 
-                       if (ENABLE_SIMPLEPIE) {
+                       if ($use_simplepie) {
                                $site_url = $rss->get_link();
                        } else {
                                $site_url = $rss->channel["link"];
 
                        if (!$registered_title || $registered_title == "[Unknown]") {
 
-                               if (ENABLE_SIMPLEPIE) {
+                               if ($use_simplepie) {
                                        $feed_title = db_escape_string($rss->get_title());
                                } else {
                                        $feed_title = db_escape_string($rss->channel["title"]);
                        }
 
                        // weird, weird Magpie
-                       if (!ENABLE_SIMPLEPIE) {
+                       if (!$use_simplepie) {
                                if (!$site_url) $site_url = db_escape_string($rss->channel["link_"]);
                        }
 
 
 //                     print "I: " . $rss->channel["image"]["url"];
 
-                       if (!ENABLE_SIMPLEPIE) {
+                       if (!$use_simplepie) {
                                $icon_url = $rss->image["url"];
                        } else {
                                $icon_url = $rss->get_image_url();
                                array_push($filters[$line["name"]], $filter);
                        }
 
-                       if (ENABLE_SIMPLEPIE) {
+                       if ($use_simplepie) {
                                $iterator = $rss->get_items();
                        } else {
                                $iterator = $rss->items;
 
                                }
 
-                               if (ENABLE_SIMPLEPIE) {
+                               if ($use_simplepie) {
                                        $entry_guid = $item->get_id();
                                        if (!$entry_guid) $entry_guid = $item->get_link();
                                        if (!$entry_guid) $entry_guid = make_guid_from_title($item->get_title());
 
                                $entry_timestamp = "";
 
-                               if (ENABLE_SIMPLEPIE) {
+                               if ($use_simplepie) {
                                        $entry_timestamp = strtotime($item->get_date());
                                } else {
                                        $rss_2_date = $item['pubdate'];
 
                                $entry_timestamp_fmt = strftime("%Y/%m/%d %H:%M:%S", $entry_timestamp);
 
-                               if (ENABLE_SIMPLEPIE) {
+                               if ($use_simplepie) {
                                        $entry_title = $item->get_title();
                                } else {
                                        $entry_title = trim(strip_tags($item["title"]));
                                }
 
-                               if (ENABLE_SIMPLEPIE) {
+                               if ($use_simplepie) {
                                        $entry_link = $item->get_link();
                                } else {
                                        // strange Magpie workaround
 
                                $entry_link = strip_tags($entry_link);
 
-                               if (ENABLE_SIMPLEPIE) {
+                               if ($use_simplepie) {
                                        $entry_content = $item->get_description();
                                } else {
                                        $entry_content = $item["content:escaped"];
 
                                $entry_content_unescaped = $entry_content;
 
-                               if (ENABLE_SIMPLEPIE) {
+                               if ($use_simplepie) {
                                        $entry_comments = strip_tags($item->data["comments"]);
                                        if ($item->get_author()) {
                                                $entry_author_item = $item->get_author();
                                $entry_comments = mb_substr(db_escape_string($entry_comments), 0, 250);
                                $entry_author = mb_substr($entry_author, 0, 250);
 
-                               if (ENABLE_SIMPLEPIE) {
+                               if ($use_simplepie) {
                                        $num_comments = 0; #FIXME#
                                } else {
                                        $num_comments = db_escape_string($item["slash"]["comments"]);
 
                                // parse <category> entries into tags
 
-                               if (ENABLE_SIMPLEPIE) {
+                               if ($use_simplepie) {
 
                                        $additional_tags = array();
                                        $additional_tags_src = $item->get_categories();
 
                                $enclosures = array();
 
-                               if (ENABLE_SIMPLEPIE) {
+                               if ($use_simplepie) {
                                        $encs = $item->get_enclosures();
 
                                        if (is_array($encs)) {
 
                } else {
 
-                       if (ENABLE_SIMPLEPIE) {
+                       if ($use_simplepie) {
                                $error_msg = mb_substr($rss->error(), 0, 250);
                        } else {
                                $error_msg = mb_substr(magpie_error(), 0, 250);
                                        last_updated = NOW() WHERE id = '$feed'");
                }
 
-               if (ENABLE_SIMPLEPIE) {
+               if ($use_simplepie) {
                        unset($rss);
                }
 
index c3197716496bbece8d8f1c0e50ed9905b3d2895a..749f4dc045dfdf80ac9ad4781ef71a7c3ae2ead3 100644 (file)
@@ -4,6 +4,7 @@
 
                global $update_intervals;
                global $purge_intervals;
+               global $update_methods;
 
                $subop = $_REQUEST["subop"];
                $quiet = $_REQUEST["quiet"];
                        
                        print "</td>";
 
+                       $update_method = db_fetch_result($result, 0, "update_method");
+
+                       print "<tr><td>".__('Update using:')."</td>";
+
+                       print "<td>";
+
+                       print_select_hash("update_method", $update_method, $update_methods, 
+                               "class=\"iedit\"");
+                       
+                       print "</td>";
+
                        $auth_login = htmlspecialchars(db_fetch_result($result, 0, "auth_login"));
 
                        print "<tr><td>".__('Login:')."</td>";
                                db_escape_string($_POST["include_in_digest"]));
                        $cache_images = checkbox_to_sql_bool(
                                db_escape_string($_POST["cache_images"]));
+                       $update_method = (int) db_escape_string($_POST["update_method"]);
 
                        if (get_pref($link, 'ENABLE_FEED_CATS')) {                      
                                if ($cat_id && $cat_id != 0) {
                                rtl_content = $rtl_content,
                                hidden = $hidden,
                                $cache_images_qpart
-                               include_in_digest = $include_in_digest
+                               include_in_digest = $include_in_digest,
+                               update_method = '$update_method'
                                WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
 
                        if (get_pref($link, 'ENABLE_FEED_CATS')) {