/** * @param Zend_Feed_Rss $rss */ private function processRss($rss) { $this->addField(Zend_Search_Lucene_Field::UnIndexed('id', $this->id)); $this->addField(Zend_Search_Lucene_Field::UnIndexed('url', $this->url)); $this->addField(Zend_Search_Lucene_Field::Text('title', $rss->title())); $this->addField(Zend_Search_Lucene_Field::Text('description', $rss->description())); // Loop over each channel item and store relevant data $text = ''; foreach ($rss as $item) { $text .= $item->title(); $text .= ' '; $text .= $item->description(); } $this->addField(Zend_Search_Lucene_Field::Text('body', $text)); }
function retrieveFirstItem($uri, $idcontact_website = null) { $do_contact_website = new ContactWebsite(); $do_contact_website->getId($idcontact_website); $website_type = $do_contact_website->website_type; if ($website_type == "RSS Feed") { try { $feed = new Zend_Feed_Rss($uri); $entry = $feed->current(); if (trim($entry->title()) == trim($entry->description())) { $str_item .= $entry->description() . "<br />"; } else { $str_item = "<B>" . $entry->title() . "</B><br />"; $str_item .= $entry->description() . "<br />"; } $str_item .= " " . date("D, j M Y H:i:s", strtotime($entry->pubDate())) . "<br />"; $arr_item[0] = $str_item; $arr_item[1] = strtotime($entry->pubDate()); return $arr_item; } catch (Exception $ex) { $this->turnFeedOff($idcontact_website); } } else { try { $obj_arr_feeds = Zend_Feed::findFeeds($uri); foreach ($obj_arr_feeds as $channel) { if ($channel->item) { //fetches the first (current) updated item $item = $channel->current(); if (trim($item->title()) == trim($item->description())) { $str_item .= $item->description() . "<br />"; } else { $str_item = "<B>" . $item->title() . "</B><br />"; $str_item .= $item->description() . "<br />"; } $str_item .= " " . date("D, j M Y H:i:s", strtotime($item->pubDate())) . "<br />"; $arr_item[0] = $str_item; $arr_item[1] = strtotime($item->pubDate()); break; } } return $arr_item; } catch (Exception $ex) { $this->turnFeedOff($idcontact_website); } } }
public function __construct($feed, $id) { $cache_f = array('lifetime' => 60 * 60, 'automatic_serialization' => true); $cache_b = array('cache_dir' => '/tmp'); $cache = Zend_Cache::factory('Core', 'File', $cache_f, $cache_b); if ($c = $cache->load($id . '_FM')) { parent::__construct(null, $c->saveXML()); $this->_base = $c; } else { try { parent::__construct($feed); $this->_base = new Zend_Feed_Rss($feed); $cache->save($this->_base, $id . '_FM'); $this->_base->__wakeup(); } catch (Zend_Feed_Exception $e) { } } }
function saveJobfeeds($criteria) { if ($criteria['feed_url'] != '') { $link = $criteria['feed_url']; $linkbits = parse_url($link); $host = $linkbits['host']; //******************************************** //So now $host = www.url.com //All I have to do is remove the 'www.': //******************************************** // find pos of first dot if (stristr($host, 'www.') == true) { $dot_pos = strpos($host, '.', 0) + 1; // make a new substring $domain = substr($host, $dot_pos); } else { $domain = $host; } $criteria['feed_domain'] = $domain; } if (stristr($criteria['feed_url'], 'http') == true) { require_once 'Zend/Feed.php'; require_once 'Zend/Feed/Rss.php'; $channel = new Zend_Feed_Rss($criteria['feed_url']); $criteria['feed_title'] = $channel->title(); foreach ($channel as $item) { //echo $item->title() . "\n"; } } if (strval($criteria['group_id_new']) != '') { //check if group is there $data = array(); $data['group_to_table'] = 'cacaomail_mailing_lists'; $data['group_name'] = strtolower($criteria['group_id_new']); $data = $this->input->xss_clean($data); $results = CI::model('core')->groupsGet($data); if (empty($results)) { $save = CI::model('core')->groupsSave($data); $criteria['group_id'] = $save; } else { $results = $results[0]; $id = $results['id']; $criteria['group_id'] = $id; //var_dump($results); } } else { } $table = TABLE_PREFIX . 'cacaomail_mailing_lists'; $criteria = $this->input->xss_clean($criteria); //var_dump($criteria); //exit; $save = CI::model('core')->saveData($table, $criteria); $cleanup_groups = CI::model('core')->groupsCleanup('cacaomail_mailing_lists'); return $save; }