]> git.wh0rd.org Git - tt-rss.git/commitdiff
simplepie: fix check_for_update()
authorAndrew Dolgov <fox@madoka.spb.ru>
Thu, 23 Aug 2007 12:46:53 +0000 (13:46 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Thu, 23 Aug 2007 12:46:53 +0000 (13:46 +0100)
functions.php

index e86fc03100ded9f45ebd13853e896be0ddceba0c..364024ba03d4fc0be8984f179e27be49bc307a76 100644 (file)
                }
 
                error_reporting(0);
-               $rss = fetch_rss($releases_feed);
+               if (ENABLE_SIMPLEPIE) {
+                       $rss = new SimplePie();
+                       $rss->set_useragent(SIMPLEPIE_USERAGENT . MAGPIE_USER_AGENT_EXT);
+                       $rss->set_timeout(MAGPIE_FETCH_TIME_OUT);
+                       $rss->set_feed_url($fetch_url);
+                       $rss->set_output_encoding('UTF-8');
+                       $rss->init();
+               } else {
+                       $rss = fetch_rss($releases_feed);
+               }
                error_reporting (DEFAULT_ERROR_LEVEL);
 
                if ($rss) {
 
-                       $items = $rss->items;
+                       if (ENABLE_SIMPLEPIE) {
+                               $items = $rss->get_items();
+                       } else {
+                               $items = $rss->items;
 
-                       if (!$items || !is_array($items)) $items = $rss->entries;
-                       if (!$items || !is_array($items)) $items = $rss;
+                               if (!$items || !is_array($items)) $items = $rss->entries;
+                               if (!$items || !is_array($items)) $items = $rss;
+                       }
 
                        if (!is_array($items) || count($items) == 0) {
                                return;
 
                        $latest_item = $items[0];
 
-                       $latest_version = trim(preg_replace("/(Milestone)|(completed)/", "", $latest_item["title"]));
+                       if (ENABLE_SIMPLEPIE) {
+                               $last_title = $latest_item->get_title();
+                       } else {
+                               $last_title = $latest_item["title"];
+                       }
 
-                       $release_url = sanitize_rss($link, $latest_item["link"]);
-                       $content = sanitize_rss($link, $latest_item["description"]);
+                       $latest_version = trim(preg_replace("/(Milestone)|(completed)/", "", $last_title));
+
+                       if (ENABLE_SIMPLEPIE) {
+                               $release_url = sanitize_rss($latest_item->get_link());
+                               $content = sanitize_rss($latest_item->get_description());
+                       } else {
+                               $release_url = sanitize_rss($link, $latest_item["link"]);
+                               $content = sanitize_rss($link, $latest_item["description"]);
+                       }
 
                        if (version_compare(VERSION, $latest_version) == -1) {
                                if ($brief_fmt) {