コード例 #1
0
 public static function fetchCachedFeed($url, $interval = 300)
 {
     $cacheClass = sfConfig::get('app_a_feed_cache_class', 'sfFileCache');
     $cache = new $cacheClass(sfConfig::get('app_a_feed_cache_options', array('cache_dir' => aFiles::getWritableDataFolder(array('a_feed_cache')))));
     $key = 'apostrophe:feed:' . $url;
     $feed = $cache->get($key, false);
     if ($feed === 'invalid') {
         return false;
     } else {
         if ($feed !== false) {
             // sfFeed is designed to serialize well
             $feed = unserialize($feed);
         }
     }
     if (!$feed) {
         try {
             $feed = sfFeedPeer::createFromWeb($url);
             $cache->set($key, serialize($feed), $interval);
         } catch (Exception $e) {
             // Cache the fact that the feed is invalid for 60 seconds so we don't
             // beat the daylights out of a dead feed
             $cache->set($key, 'invalid', 60);
             return false;
         }
     }
     return $feed;
 }
コード例 #2
0
ファイル: aFeed.class.php プロジェクト: hashir/UoA
 /**
  * Rock the Symfony cache to avoid fetching the same external URL over and over
  * These defaults are safe and boring and way faster than bashing on other servers.
  * But here's a tip. If you don't have APC enabled your site is probably running very,
  * very slowly, so fix that. And then do this for even better speed:
  * 
  * a:
  * feed:
  * cache_class: sfAPCCache
  * cache_options: { }
  * @param mixed $url
  * @param mixed $interval
  * @return mixed
  */
 public static function fetchCachedFeed($url, $interval = 300)
 {
     $cacheClass = sfConfig::get('app_a_feed_cache_class', 'sfFileCache');
     $cache = new $cacheClass(sfConfig::get('app_a_feed_cache_options', array('cache_dir' => aFiles::getWritableDataFolder(array('a_feed_cache')))));
     $key = 'apostrophe:feed:' . $url;
     $feed = $cache->get($key, false);
     if ($feed === 'invalid') {
         return false;
     } else {
         if ($feed !== false) {
             // sfFeed is designed to serialize well
             $feed = unserialize($feed);
         }
     }
     if (!$feed) {
         try {
             // We now always use the fopen adapter and specify a time limit, which is configurable.
             // Francois' comments about fopen being slow are probably dated, the stream wrappers are
             // quite good in modern PHP and in any case Apostrophe uses them consistently elsewhere
             $options = array('adapter' => 'sfFopenAdapter', 'adapter_options' => array('timeout' => sfConfig::get('app_a_feed_timeout', 30)));
             $feed = sfFeedPeer::createFromWeb($url, $options);
             $cache->set($key, serialize($feed), $interval);
         } catch (Exception $e) {
             // Cache the fact that the feed is invalid for 60 seconds so we don't
             // beat the daylights out of a dead feed
             $cache->set($key, 'invalid', 60);
             return false;
         }
     }
     return $feed;
 }
コード例 #3
0
 public function executeHudsonBox()
 {
     $cache = $this->context->get('cache_manager')->getCache('feed');
     if ($cache->has('hudson-last')) {
         $this->items = $cache->get('hudson-last');
     } elseif (!sfConfig::get('dm_search_populating')) {
         $url = 'http://ci.diem-project.org/rssAll';
         $this->items = sfFeedPeer::createFromWeb($url)->getItems();
         $cache->set('hudson-last', $this->items, 10800);
     }
 }
コード例 #4
0
	<div class="sevencol">
           <!-- Banner Camere Aperte 2013 -->
           <div style="margin-bottom:20px;">
              <?php 
echo link_to(image_tag('ca2014_banner.png', array('alt' => 'Indice  2014')), 'http://blog.openpolis.it/2014/11/03/pubblicato-il-minidossier-indice-di-produttivita-parlamentare/');
?>
</div>        

	    <!-- in evidenza dal blog -->
	     <div class="section-box"  style="padding-bottom:20px;">
	       <?php 
echo link_to(image_tag('ico-rss.png', array('alt' => 'rss')), 'http://feeds.feedburner.com/openpolis?format=xml', array('class' => 'section-box-rss'));
?>
	       <h3>in evidenza dal blog di openpolis</h3>
	       <?php 
include_partial('sfSimpleBlog/inevidenza', array('feed' => sfFeedPeer::createFromWeb('http://blog.openpolis.it/categorie/inparlamento/feed/'), 'limit' => 3));
?>
	 		   <p align=right><strong><a href="http://blog.openpolis.it/">vai al blog di openpolis</a></strong></p>
	 	  </div>

	    <!-- box keyvotes -->
	   	<?php 
include_component('votazione', 'keyvotes', array('limit' => '5', 'pagina' => 'homepage', 'type' => 'key'));
?>

	    <div class="clear-both"></div>

	    <!-- Box attivita' utenti -->
	     <div class="section-box" style="margin-top: 2em;">   
	       <h3 class="section-box-no-rss">ultime dalla comunit&agrave;</h3>
	       <?php 
コード例 #5
0
 /**
  * Displays the latest changes to the registry
  *
  */
 public function getChangeFeed()
 {
     try {
         $feed1 = sfFeedPeer::createFromWeb($this->getRequest()->getUriPrefix() . "/schemahistory/feed.atom");
         $feed2 = sfFeedPeer::createFromWeb($this->getRequest()->getUriPrefix() . "/history/feed.atom");
         if ($feed1 && $feed2) {
             $image = new sfFeedImage();
             $image->setFavicon($this->getRequest()->getUriPrefix() . "/favicon.ico");
             $image->setFeed($this->getRequest()->getUriPrefix() . "/allhistoryfeeds.atom");
             $image->setLink($image->getFeed());
             $image->setTitle("Metadata Registry Change History");
             $this->feed = sfFeedPeer::aggregate(array($feed1, $feed2), array('limit' => 100, 'format' => 'atom1', 'link' => $image->getLink(), 'title' => $image->getTitle(), 'feedUrl' => $image->getFeed(), 'image' => $image, 'description' => 'A statement-level list of all of the recent changes to the vocabularies and element sets maintained in the Metadata registry.'));
             $this->changeFeedItems = $this->feed->getItems();
         }
     } catch (Exception $e) {
     }
 }
コード例 #6
0
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
sfContext::getInstance();
$cache = new sfArrayCache(sfConfig::get('sf_cache_dir'));
$cache->setLifeTime(86400);
// convert to seconds
$pages = $cache->get('pages', 'my_cache_dir');
// test for empty or timed out cache
if ($pages === null) {
    $pages = array();
    /*        $feeds = array(
                'http://www.fbi.gov/rss/topten.xml',
                'http://www.fbi.gov/rss/terrorists.xml'
            );*/
    $feeds = array('http://www.fbi.gov/rss/topten.xml', 'http://www.fbi.gov/rss/terrorists.xml', 'http://www.fbi.gov/rss/murder.xml', 'http://www.fbi.gov/rss/violent.xml', 'http://www.fbi.gov/rss/cyber.xml', 'http://www.fbi.gov/rss/cac.xml', 'http://www.fbi.gov/rss/criment.xml', 'http://www.fbi.gov/rss/white.xml');
    foreach ($feeds as $feedurl) {
        $feed = sfFeedPeer::createFromWeb($feedurl);
        $items = $feed->getItems();
        foreach ($items as $item) {
            $pages[] = $item->getLink();
        }
    }
    $cache->set('pages', 'my_cache_dir', $pages);
}
$images = $cache->get('images', 'my_cache_dir');
if ($images === null) {
    $images = array();
    $numofpages = count($pages);
    foreach ($pages as $pageindex => $url) {
        $path = substr($url, 0, strrpos($url, '/') + 1);
        $b = new sfWebBrowser();
        $b->get($url);
コード例 #7
0
ファイル: components.class.php プロジェクト: silky/littlesis
 public function executeNameWire()
 {
     $feed = sfFeedPeer::createFromWeb('http://blog.littlesis.org/category/namewire/feed');
     $this->posts = $feed->getItems();
     if (count($this->posts) > 3) {
         $this->posts = array_slice($this->posts, 0, 3);
     }
 }