/** * Show discovered feeds * * @return nothin **/ function showDiscoveredFeeds() { $feed = new SimplePie(); $feed->set_cache_location(GLPI_RSS_DIR); $feed->enable_cache(false); $feed->set_feed_url($this->fields['url']); $feed->init(); $feed->handle_content_type(); if ($feed->error()) { return false; } foreach ($feed->get_all_discovered_feeds() as $f) { $newurl = $f->url; $newfeed = self::getRSSFeed($newurl); if ($newfeed && !$newfeed->error()) { $link = $newfeed->get_permalink(); if (!empty($link)) { echo "<a href='{$newurl}'>" . $newfeed->get_title() . "</a> "; Html::showSimpleForm($this->getFormURL(), 'update', _x('button', 'Use'), array('id' => $this->getID(), 'url' => $newurl)); echo "<br>"; } } } }
break; case "feed_from_site": if (isset($_GET['site'])) { $url = trim($_GET["site"]); } else { $url = trim($_POST["site"]); } $site_url = check_field('site', urldecode($url), 'url'); $feeds = array(); if ($site_url['success']) { require_once dirname(__FILE__) . '/../../inc/lib/simplepie_1.3.compiled.php'; $simplepie = new SimplePie(); $simplepie->set_feed_url($site_url['value']); $simplepie->init(); $simplepie->handle_content_type(); foreach ($simplepie->get_all_discovered_feeds() as $ob) { $feeds[] = $ob->url; } } header('Content-type: application/json; charset=utf-8'); print json_encode($feeds); break; ########################################################## # DEFAULT RETURN ########################################################## ########################################################## # DEFAULT RETURN ########################################################## default: print '<div class="flash_error">' . T_('User bad call') . '</div>'; break;