Exemplo n.º 1
0
 public function testCanAddIndividualEntries()
 {
     $this->feed->transferFromXML($this->feedText);
     $this->assertEquals(1, count($this->feed->entry));
     $oldTitle = $this->feed->entry[0]->title->text;
     $newEntry = new Zend_Gdata_App_Entry();
     $newEntry->setTitle(new Zend_Gdata_App_Extension_Title("Foo"));
     $this->feed->addEntry($newEntry);
     $this->assertEquals(2, count($this->feed->entry));
     $this->assertEquals($oldTitle, $this->feed->entry[0]->title->text);
     $this->assertEquals("Foo", $this->feed->entry[1]->title->text);
 }
Exemplo n.º 2
0
 public function __construct($element = null)
 {
     foreach (Zend_Gdata::$namespaces as $nsPrefix => $nsUri) {
         $this->registerNamespace($nsPrefix, $nsUri);
     }
     parent::__construct($element);
 }
Exemplo n.º 3
0
 public function testConvertEntryToAndFromString()
 {
     $this->enry->transferFromXML($this->enryText);
     $enryXml = $this->enry->saveXML();
     $newEntry = new Zend_Gdata_App_Entry();
     $newEntry->transferFromXML($enryXml);
     /*
             $this->assertEquals(1, count($newEntry->entry));
             $this->assertEquals('dive into mark', $newEntry->title->text);
             $this->assertEquals('text', $newEntry->title->type);
             $this->assertEquals('2005-07-31T12:29:29Z', $newEntry->updated->text);
             $this->assertEquals('tag:example.org,2003:3', $newEntry->id->text);
             $this->assertEquals(2, count($newEntry->link));
             $this->assertEquals('http://example.org/',
                     $newEntry->getAlternateLink()->href);
             $this->assertEquals('en',
                     $newEntry->getAlternateLink()->hrefLang);
             $this->assertEquals('text/html',
                     $newEntry->getAlternateLink()->type);
             $this->assertEquals('http://example.org/enry.atom',
                     $newEntry->getSelfLink()->href);
             $this->assertEquals('application/atom+xml',
                     $newEntry->getSelfLink()->type);
             $this->assertEquals('Copyright (c) 2003, Mark Pilgrim',
                     $newEntry->rights->text);
             $entry = $newEntry->entry[0];
             $this->assertEquals('Atom draft-07 snapshot', $entry->title->text);
             $this->assertEquals('tag:example.org,2003:3.2397',
                     $entry->id->text);
             $this->assertEquals('2005-07-31T12:29:29Z', $entry->updated->text);
             $this->assertEquals('2003-12-13T08:29:29-04:00',
                     $entry->published->text);
             $this->assertEquals('Mark Pilgrim',
                     $entry->author[0]->name->text);
             $this->assertEquals('http://example.org/',
                     $entry->author[0]->uri->text);
             $this->assertEquals(2, count($entry->contributor));
             $this->assertEquals('Sam Ruby',
                     $entry->contributor[0]->name->text);
             $this->assertEquals('Joe Gregorio',
                     $entry->contributor[1]->name->text);
             $this->assertEquals('xhtml', $entry->content->type);
     */
 }
Exemplo n.º 4
0
 protected function takeChildFromDOM($child)
 {
     $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
     switch ($absoluteNodeName) {
         case $this->lookupNamespace('gphoto') . ':' . 'user':
             $user = new Zend_Gdata_Photos_Extension_User();
             $user->transferFromDOM($child);
             $this->_gphotoUser = $user;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'nickname':
             $nickname = new Zend_Gdata_Photos_Extension_Nickname();
             $nickname->transferFromDOM($child);
             $this->_gphotoNickname = $nickname;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'thumbnail':
             $thumbnail = new Zend_Gdata_Photos_Extension_Thumbnail();
             $thumbnail->transferFromDOM($child);
             $this->_gphotoThumbnail = $thumbnail;
             break;
         case $this->lookupNamespace('atom') . ':' . 'entry':
             $entryClassName = $this->_entryClassName;
             $tmpEntry = new Zend_Gdata_App_Entry($child);
             $categories = $tmpEntry->getCategory();
             foreach ($categories as $category) {
                 if ($category->scheme == Zend_Gdata_Photos::KIND_PATH && $this->_entryKindClassMapping[$category->term] != "") {
                     $entryClassName = $this->_entryKindClassMapping[$category->term];
                     break;
                 } else {
                     require_once 'Zend/Gdata/App/Exception.php';
                     throw new Zend_Gdata_App_Exception('Entry is missing kind declaration.');
                 }
             }
             $newEntry = new $entryClassName($child);
             $newEntry->setHttpClient($this->getHttpClient());
             $this->_entry[] = $newEntry;
             break;
         default:
             parent::takeChildFromDOM($child);
             break;
     }
 }
Exemplo n.º 5
0
 protected function takeChildFromDOM($child)
 {
     $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
     switch ($absoluteNodeName) {
         case $this->lookupNamespace('gphoto') . ':' . 'id':
             $id = new Zend_Gdata_Photos_Extension_Id();
             $id->transferFromDOM($child);
             $this->_gphotoId = $id;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'user':
             $user = new Zend_Gdata_Photos_Extension_User();
             $user->transferFromDOM($child);
             $this->_gphotoUser = $user;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'nickname':
             $nickname = new Zend_Gdata_Photos_Extension_Nickname();
             $nickname->transferFromDOM($child);
             $this->_gphotoNickname = $nickname;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'name':
             $name = new Zend_Gdata_Photos_Extension_Name();
             $name->transferFromDOM($child);
             $this->_gphotoName = $name;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'location':
             $location = new Zend_Gdata_Photos_Extension_Location();
             $location->transferFromDOM($child);
             $this->_gphotoLocation = $location;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'access':
             $access = new Zend_Gdata_Photos_Extension_Access();
             $access->transferFromDOM($child);
             $this->_gphotoAccess = $access;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'timestamp':
             $timestamp = new Zend_Gdata_Photos_Extension_Timestamp();
             $timestamp->transferFromDOM($child);
             $this->_gphotoTimestamp = $timestamp;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'numphotos':
             $numphotos = new Zend_Gdata_Photos_Extension_NumPhotos();
             $numphotos->transferFromDOM($child);
             $this->_gphotoNumPhotos = $numphotos;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'commentingEnabled':
             $commentingEnabled = new Zend_Gdata_Photos_Extension_CommentingEnabled();
             $commentingEnabled->transferFromDOM($child);
             $this->_gphotoCommentingEnabled = $commentingEnabled;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'commentCount':
             $commentCount = new Zend_Gdata_Photos_Extension_CommentCount();
             $commentCount->transferFromDOM($child);
             $this->_gphotoCommentCount = $commentCount;
             break;
         case $this->lookupNamespace('atom') . ':' . 'entry':
             $entryClassName = $this->_entryClassName;
             $tmpEntry = new Zend_Gdata_App_Entry($child);
             $categories = $tmpEntry->getCategory();
             foreach ($categories as $category) {
                 if ($category->scheme == Zend_Gdata_Photos::KIND_PATH && $this->_entryKindClassMapping[$category->term] != "") {
                     $entryClassName = $this->_entryKindClassMapping[$category->term];
                     break;
                 } else {
                     // require_once 'Zend/Gdata/App/Exception.php';
                     throw new Zend_Gdata_App_Exception('Entry is missing kind declaration.');
                 }
             }
             $newEntry = new $entryClassName($child);
             $newEntry->setHttpClient($this->getHttpClient());
             $this->_entry[] = $newEntry;
             break;
         default:
             parent::takeChildFromDOM($child);
             break;
     }
 }
Exemplo n.º 6
0
 protected function takeChildFromDOM($child)
 {
     $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
     switch ($absoluteNodeName) {
         case $this->lookupNamespace('gphoto') . ':' . 'id':
             $id = new Zend_Gdata_Photos_Extension_Id();
             $id->transferFromDOM($child);
             $this->_gphotoId = $id;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'version':
             $version = new Zend_Gdata_Photos_Extension_Version();
             $version->transferFromDOM($child);
             $this->_gphotoVersion = $version;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'albumid':
             $albumid = new Zend_Gdata_Photos_Extension_AlbumId();
             $albumid->transferFromDOM($child);
             $this->_gphotoAlbumId = $albumid;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'width':
             $width = new Zend_Gdata_Photos_Extension_Width();
             $width->transferFromDOM($child);
             $this->_gphotoWidth = $width;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'height':
             $height = new Zend_Gdata_Photos_Extension_Height();
             $height->transferFromDOM($child);
             $this->_gphotoHeight = $height;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'size':
             $size = new Zend_Gdata_Photos_Extension_Size();
             $size->transferFromDOM($child);
             $this->_gphotoSize = $size;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'client':
             $client = new Zend_Gdata_Photos_Extension_Client();
             $client->transferFromDOM($child);
             $this->_gphotoClient = $client;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'checksum':
             $checksum = new Zend_Gdata_Photos_Extension_Checksum();
             $checksum->transferFromDOM($child);
             $this->_gphotoChecksum = $checksum;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'timestamp':
             $timestamp = new Zend_Gdata_Photos_Extension_Timestamp();
             $timestamp->transferFromDOM($child);
             $this->_gphotoTimestamp = $timestamp;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'commentingEnabled':
             $commentingEnabled = new Zend_Gdata_Photos_Extension_CommentingEnabled();
             $commentingEnabled->transferFromDOM($child);
             $this->_gphotoCommentingEnabled = $commentingEnabled;
             break;
         case $this->lookupNamespace('gphoto') . ':' . 'commentCount':
             $commentCount = new Zend_Gdata_Photos_Extension_CommentCount();
             $commentCount->transferFromDOM($child);
             $this->_gphotoCommentCount = $commentCount;
             break;
         case $this->lookupNamespace('media') . ':' . 'group':
             $mediaGroup = new Zend_Gdata_Media_Extension_MediaGroup();
             $mediaGroup->transferFromDOM($child);
             $this->_mediaGroup = $mediaGroup;
             break;
         case $this->lookupNamespace('atom') . ':' . 'entry':
             $entryClassName = $this->_entryClassName;
             $tmpEntry = new Zend_Gdata_App_Entry($child);
             $categories = $tmpEntry->getCategory();
             foreach ($categories as $category) {
                 if ($category->scheme == Zend_Gdata_Photos::KIND_PATH && $this->_entryKindClassMapping[$category->term] != "") {
                     $entryClassName = $this->_entryKindClassMapping[$category->term];
                     break;
                 } else {
                     // require_once 'Zend/Gdata/App/Exception.php';
                     throw new Zend_Gdata_App_Exception('Entry is missing kind declaration.');
                 }
             }
             $newEntry = new $entryClassName($child);
             $newEntry->setHttpClient($this->getHttpClient());
             $this->_entry[] = $newEntry;
             break;
         default:
             parent::takeChildFromDOM($child);
             break;
     }
 }
Exemplo n.º 7
0
 /**
  * Constructs a new MediaEntry, representing XML data and optional
  * file to upload
  *
  * @param DOMElement $element (optional) DOMElement from which this
  *          object should be constructed.
  */
 public function __construct($element = null, $mediaSource = null)
 {
     parent::__construct($element);
     $this->_mediaSource = $mediaSource;
 }
Exemplo n.º 8
0
 public function testGenerateIfMatchHeaderDataReturnsEtagIfNotWeakAndFlagSet()
 {
     $etag = 'ABCD1234';
     $this->service->setMajorProtocolVersion(2);
     $entry = new Zend_Gdata_App_Entry();
     $entry->setEtag($etag);
     $result = $this->service->generateIfMatchHeaderData($entry, true);
     $this->assertEquals($etag, $result);
 }
Exemplo n.º 9
0
 public function get_tags()
 {
     return implode(",", $this->entry->getVideoTags());
 }
Exemplo n.º 10
0
 /**
  *
  * @var DateTime
  */
 public function get_created_on()
 {
     return new DateTime($this->entry->getPublished()->getText());
 }
Exemplo n.º 11
0
 /**
  * Put an entry
  *
  * TODO Determine if App should call Entry to Update or the opposite.  
  * Suspecect opposite would mkae more sense.  Also, this possibly should
  * take an optional URL to override URL used in the entry, or if an
  * edit URI/ID is not present in the entry
  *
  * @param mixed $data Zend_Gdata_App_Entry or XML (w/ID and link rel='edit')
  * @return Zend_Gdata_App_Entry The entry returned from the server
  * @throws Zend_Gdata_App_Exception
  */
 public function put($data)
 {
     if (is_string($data)) {
         $entry = new Zend_Gdata_App_Entry($data);
         $entry->setHttpClient($this->_httpClient);
         return $entry->save();
     } elseif ($data instanceof Zend_Gdata_App_Entry) {
         return $data->save();
     } else {
         require_once 'Zend/Gdata/App/InvalidArgumentException.php';
         throw new Zend_Gdata_App_InvalidArgumentException('You must specify the data to post as either a XML string or a child of Zend_Gdata_App_Entry');
     }
 }