Exemplo n.º 1
0
 /**
  * Converts a SimpleXMLElement object representing a response from the service
  * into a SlideShow object
  *
  * @param SimpleXMLElement $node The input XML from the slideshare.net service
  * @throws Exception\RuntimeException
  * @return SlideShow The resulting object
  */
 protected function slideShowNodeToObject(SimpleXMLElement $node)
 {
     if ($node->getName() != 'Slideshow') {
         throw new Exception\RuntimeException("Was not provided the expected XML Node for processing");
     }
     $ss = new SlideShow();
     $ss->setId((string) $node->ID);
     $ss->setDescription((string) $node->Description);
     $ss->setEmbedCode((string) $node->Embed);
     $ss->setNumViews((string) $node->NumViews);
     $ss->setNumDownloads((string) $node->NumDownloads);
     $ss->setNumComments((string) $node->NumComments);
     $ss->setNumFavorites((string) $node->NumFavorites);
     $ss->setNumSlides((string) $node->NumSlides);
     $ss->setPermaLink((string) $node->URL);
     $ss->setStatus((string) $node->Status);
     $ss->setStatusDescription((string) $node->StatusDescription);
     foreach ($node->Tags->Tag as $tag) {
         if (!in_array($tag, $ss->getTags())) {
             $ss->addTag($tag);
         }
     }
     $ss->setThumbnailUrl((string) $node->ThumbnailURL);
     $ss->setThumbnailSmallUrl((string) $node->ThumbnailSmallURL);
     $ss->setTitle((string) $node->Title);
     $ss->setLocation((string) $node->PPTLocation);
     $ss->setUsername((string) $node->Username);
     $ss->setCreated((string) $node->Created);
     $ss->setUpdated((string) $node->Updated);
     $ss->setLanguage((string) $node->Language);
     $ss->setFormat((string) $node->Format);
     $ss->setDownload((string) $node->Download);
     $ss->setDownloadUrl((string) $node->DownloadUrl);
     foreach ($node->RelatedSlideshows->RelatedSlideshowID as $id) {
         if (!in_array($id, $ss->getRelatedSlideshowIds())) {
             $ss->addRelatedSlideshowId($id);
         }
     }
     return $ss;
 }
Exemplo n.º 2
0
    /**
     * @group   ZF-3247
     */
	public function testSlideShareObjectHandlesUnicodeCharactersWell()
	{
        $slideShow = new SlideShare\SlideShow();
		
		$slideShow->setTitle('Unicode test: ஸ்றீனிவாஸ ராமானுஜன் ஐயங்கார்');

		if (!extension_loaded('mbstring')) {
		    $this->markTestSkipped('Extension "mbstring" not loaded');
		}
        $this->assertEquals('UTF-8', mb_detect_encoding($slideShow->getTitle()));
	}
Exemplo n.º 3
0
    /**
     * Converts a SimpleXMLElement object representing a response from the service
     * into a Zend\Service\SlideShare\SlideShow object
     *
     * @param SimpleXMLElement $node The input XML from the slideshare.net service
     * @throws \Zend\Service\SlideShare\Exception
     * @return Zend\Service\SlideShare\SlideShow The resulting object
     */
    protected function _slideShowNodeToObject(\SimpleXMLElement $node)
    {

        if($node->getName() == 'Slideshow') {

            $ss = new SlideShow();

            $ss->setId((string)$node->ID);
            $ss->setDescription((string)$node->Description);
            $ss->setEmbedCode((string)$node->EmbedCode);
            $ss->setNumViews((string)$node->Views);
            $ss->setPermaLink((string)$node->Permalink);
            $ss->setStatus((string)$node->Status);
            $ss->setStatusDescription((string)$node->StatusDescription);

            foreach(explode(",", (string)$node->Tags) as $tag) {

                if(!in_array($tag, $ss->getTags())) {
                    $ss->addTag($tag);
                }
            }

            $ss->setThumbnailUrl((string)$node->Thumbnail);
            $ss->setTitle((string)$node->Title);
            $ss->setLocation((string)$node->Location);
            $ss->setTranscript((string)$node->Transcript);

            return $ss;

        }

        throw new Exception\RuntimeException("Was not provided the expected XML Node for processing");
    }
Exemplo n.º 4
0
 public function testSlideShowObj()
 {
     $ss = new SlideShare\SlideShow();
     $ss->setDescription("Foo");
     $ss->setEmbedCode("Bar");
     $ss->setFilename("Baz");
     $ss->setId(123);
     $ss->setLocation("Somewhere");
     $ss->setNumViews(4432);
     $ss->setPermaLink("nowhere");
     $ss->setStatus(124);
     $ss->setStatusDescription("Boo");
     $ss->setTags(array('bar', 'baz'));
     $ss->addTag('fon');
     $ss->setThumbnailUrl('asdf');
     $ss->setTitle('title');
     $ss->setTranscript('none');
     $this->assertEquals($ss->getDescription(), "Foo");
     $this->assertEquals($ss->getEmbedCode(), "Bar");
     $this->assertEquals($ss->getFilename(), "Baz");
     $this->assertEquals($ss->getId(), 123);
     $this->assertEquals($ss->getLocation(), "Somewhere");
     $this->assertEquals($ss->getNumViews(), 4432);
     $this->assertEquals($ss->getPermaLink(), "nowhere");
     $this->assertEquals($ss->getStatus(), 124);
     $this->assertEquals($ss->getStatusDescription(), "Boo");
     $this->assertEquals($ss->getTags(), array('bar', 'baz', 'fon'));
     $this->assertEquals($ss->getThumbnailUrl(), "asdf");
     $this->assertEquals($ss->getTitle(), "title");
     $this->assertEquals($ss->getTranscript(), "none");
 }