/** * Sets up SimplePie object. * * @param integer $iCacheDuration // 60 seconds * 60 = 1 hour, 1800 = 30 minutes */ protected function getFeedObj($aUrls, $iItem = 10, $iCacheDuration = 36000) { // Reuse the object that already exists. This conserves the memory usage. // $this->oFeed = isset( $this->oFeed ) ? $this->oFeed : new AmazonAutoLinks_SimplePie; // $oFeed = $this->oFeed; // // For excluding sub categories, new instances need to be instantiated per set of uls as SimplePie somehow does not // property output newly fetched items. $_oFeed = new AmazonAutoLinks_SimplePie(); // Set sort type. $_oFeed->set_sortorder($this->oUnitOption->get('sort')); $_oFeed->set_charset_for_sort($this->sCharEncoding); $_oFeed->set_keeprawtitle($this->oUnitOption->get('keep_raw_title')); // Set urls $_oFeed->set_feed_url($aUrls); $_oFeed->set_item_limit($iItem); // This should be set after defining $urls $_oFeed->set_cache_duration($iCacheDuration); $_oFeed->set_stupidly_fast(true); // If the cache lifetime is explicitly set to 0, do not trigger the background renewal cache event if (0 == $iCacheDuration) { // setting it true will be considered the background process; thus, it won't trigger the renewal event. $_oFeed->setBackground(true); } // set_stupidly_fast() disables this internally so turn it on manually because it will trigger the custom sort method $_oFeed->enable_order_by_date(true); // $_oFeed->file_class = 'AmazonAutoLinks_SimplePie_File'; // this is assigned in the class definition already $_oFeed->init(); // will perform fetching the feeds. return $_oFeed; }