Ejemplo n.º 1
0
 public function updateData()
 {
     $feed_url = $this->getProperty('feed_url');
     Zend_Feed::registerNamespace('gr', 'http://www.google.com/schemas/reader/atom/');
     if (!($feed = new Zend_Feed_Atom($feed_url))) {
         return 0;
     }
     $result = $this->processItems($feed);
     // Clear up to free memory
     unset($feed);
     // Mark as updated (could have been with errors)
     $this->markUpdated();
     return $result;
 }
 public function __construct($xml = null)
 {
     if ($xml) {
         // first, lets find the cmis namespace to use
         $sx = new SimpleXMLElement($xml);
         $namespaces = $sx->getDocNamespaces();
         $ns = isset($namespaces['cmis']) ? $namespaces['cmis'] : 'http://docs.oasis-open.org/ns/cmis/core/200901';
         // go through the XML and pull out the things we're interested in
         Zend_Feed::registerNamespace('cmis', $ns);
         // 'http://www.cmis.org/2008/05');
         $this->rawXml = $xml;
         $feed = Zend_Feed::importString($this->rawXml);
         foreach ($feed as $item) {
             $this->loadFromFeed($item);
         }
     }
 }
 function __construct($xml)
 {
     parent::__construct();
     if ($xml) {
         // first, lets find the cmis namespace to use
         $sx = new SimpleXMLElement($xml);
         $namespaces = $sx->getDocNamespaces();
         $ns = isset($namespaces['cmis']) ? $namespaces['cmis'] : 'http://docs.oasis-open.org/ns/cmis/core/200901';
         // go through the entries and create some objects
         Zend_Feed::registerNamespace('cmis', $ns);
         // 'http://www.cmis.org/2008/05');
         $this->rawXml = $xml;
         $feed = Zend_Feed::importString($this->rawXml);
         foreach ($feed as $entry) {
             $obj = new SeaMistObject();
             $obj->loadFromFeed($entry);
             $this[] = $obj;
         }
     }
 }
Ejemplo n.º 4
0
Archivo: Rss.php Proyecto: Kliwer/lms
 /**
  * Generate the entries of the feed when working in write mode
  *
  * The following nodes are constructed for each feed entry
  * <item>
  *    <title>entry title</title>
  *    <link>url to feed entry</link>
  *    <guid>url to feed entry</guid>
  *    <description>short text</description>
  *    <content:encoded>long version, can contain html</content:encoded>
  * </item>
  *
  * @param  DOMElement $root the root node to use
  * @param  array $array the data to use
  * @return void
  */
 protected function _mapFeedEntries(DOMElement $root, $array)
 {
     Zend_Feed::registerNamespace('content', 'http://purl.org/rss/1.0/modules/content/');
     foreach ($array as $dataentry) {
         $item = $this->_element->createElement('item');
         $title = $this->_element->createElement('title');
         $title->appendChild($this->_element->createCDATASection($dataentry->title));
         $item->appendChild($title);
         if (isset($dataentry->author)) {
             $author = $this->_element->createElement('author', $dataentry->author);
             $item->appendChild($author);
         }
         $link = $this->_element->createElement('link', $dataentry->link);
         $item->appendChild($link);
         if (isset($dataentry->guid)) {
             $guid = $this->_element->createElement('guid', $dataentry->guid);
             if (!Zend_Uri::check($dataentry->guid)) {
                 $guid->setAttribute('isPermaLink', 'false');
             }
             $item->appendChild($guid);
         }
         $description = $this->_element->createElement('description');
         $description->appendChild($this->_element->createCDATASection($dataentry->description));
         $item->appendChild($description);
         if (isset($dataentry->content)) {
             $content = $this->_element->createElement('content:encoded');
             $content->appendChild($this->_element->createCDATASection($dataentry->content));
             $item->appendChild($content);
         }
         $pubdate = isset($dataentry->lastUpdate) ? $dataentry->lastUpdate : time();
         $pubdate = $this->_element->createElement('pubDate', date(DATE_RSS, $pubdate));
         $item->appendChild($pubdate);
         if (isset($dataentry->category)) {
             foreach ($dataentry->category as $category) {
                 $node = $this->_element->createElement('category', $category['term']);
                 if (isset($category['scheme'])) {
                     $node->setAttribute('domain', $category['scheme']);
                 }
                 $item->appendChild($node);
             }
         }
         if (isset($dataentry->source)) {
             $source = $this->_element->createElement('source', $dataentry->source['title']);
             $source->setAttribute('url', $dataentry->source['url']);
             $item->appendChild($source);
         }
         if (isset($dataentry->comments)) {
             $comments = $this->_element->createElement('comments', $dataentry->comments);
             $item->appendChild($comments);
         }
         if (isset($dataentry->commentRss)) {
             $comments = $this->_element->createElementNS('http://wellformedweb.org/CommentAPI/', 'wfw:commentRss', $dataentry->commentRss);
             $item->appendChild($comments);
         }
         if (isset($dataentry->enclosure)) {
             foreach ($dataentry->enclosure as $enclosure) {
                 $node = $this->_element->createElement('enclosure');
                 $node->setAttribute('url', $enclosure['url']);
                 if (isset($enclosure['type'])) {
                     $node->setAttribute('type', $enclosure['type']);
                 }
                 if (isset($enclosure['length'])) {
                     $node->setAttribute('length', $enclosure['length']);
                 }
                 $item->appendChild($node);
             }
         }
         $root->appendChild($item);
     }
 }
Ejemplo n.º 5
0
/**
 * Creates an event on the authenticated user's default calendar with the
 * specified event details.
 *
 * @param Zend_Http_Client $client The authenticated client object
 * @param string $title The event title
 * @param string $desc The detailed description of the event
 * @param string $startDate The start date of the event in YYYY-MM-DD format
 * @param string $startTime The start time of the event in HH:MM 24hr format
 * @param string $endTime The end time of the event in HH:MM 24hr format
 * @param string $tzOffset The offset from GMT/UTC in [+-]DD format (eg -08)
 * @return void
 */
function createEvent($client, $title = 'Tennis with Beth', $desc = 'Meet for a quick lesson', $where = 'On the courts', $startDate = '2008-01-20', $startTime = '10:00', $endDate = '2008-01-20', $endTime = '11:00', $tzOffset = '-08')
{
    $gdataCal = new Zend_Gdata_Calendar($client);
    Zend_Feed::registerNamespace('gd', 'http://schemas.google.com/g/2005');
    $newEntry = new Zend_Feed_EntryAtom();
    $newEntry->title = trim($title);
    $newEntry->{'gd:where'}['valueString'] = $where;
    $newEntry->content = $desc;
    $newEntry->content['type'] = 'text';
    $when = $newEntry->{'gd:when'};
    $when['startTime'] = "{$startDate}T{$startTime}:00.000{$tzOffset}:00";
    $when['endTime'] = "{$endDate}T{$endTime}:00.000{$tzOffset}:00";
    $gdataCal->post($newEntry->saveXML());
}