コード例 #1
0
    public function testBuildMediaEntry()
    {
        $feed = new AtomFeedAdapter(null);
        $feed->addNamespace('m', MediaNS::NS);
        $entry = $feed->addEntry();
        $mediaEntry = $entry->getExtension(MediaNS::NS);
        $mediaEntry->description = 'this is the media description';
        $link = $entry->addLink();
        $mediaLink = $link->getExtension(MediaNS::NS);
        $mediaLink->rel = 'this is the media link rel';
        $mediaLink->href = 'this is the media link href';
        $mediaLink->type = 'this is the media link type';
        $mediaLink->width = 'this is the media link width';
        $mediaLink->width = 'this is the media link width';
        $mediaLink->height = 'this is the media link height';
        $mediaLink->duration = 'this is the media link duration';
        $expectedResult = '<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://purl.org/syndication/atommedia"><entry><m:description>this is the media description</m:description><link rel="this is the media link rel" href="this is the media link href" type="this is the media link type" m:width="this is the media link width" m:height="this is the media link height" m:duration="this is the media link duration"/></entry></feed>';
        $this->assertEquals(trim($feed->getXml()), trim($expectedResult));
        return $feed;
    }
コード例 #2
0
 /**
  * Returns a feed of comment of an item
  * 
  * @param array $comments
  * @param mixed $item
  * @return AtomFeedAdapter
  */
 public function buildCommentsFeed($comments, $item)
 {
     $application = Stuffpress_Application::getInstance();
     $feed = new AtomFeedAdapter(null);
     $feed->addNamespace(ActivityNS::PREFIX, ActivityNS::NS);
     $feed->title = "Comments of " . $this->_getObjectId($item);
     $feed->id = "http://" . $this->_domain . "/api/comments";
     //
     $feed->updated = toAtomDate(time());
     $feedLink = $feed->addLink();
     $feedLink->rel = 'self';
     $feedLink->href = 'http://' . $this->_domain . "/api/comments/" . $this->_getObjectId($item);
     foreach ($comments as $comment) {
         $this->buildCommentEntry(new Comment($comment), $item, $feed->addEntry());
     }
     return $feed;
 }
コード例 #3
0
    public function testBuildFeed()
    {
        $new = new AtomFeedAdapter(null);
        $new->title = 'New Title';
        $new->title->type = 'New Title Type';
        $new->id = 'New Id';
        $new->updated = 'New Updated';
        $new->generator = 'New Generator';
        $new->generator->uri = 'New Generator Uri';
        $new->generator->version = 'New Generator Version';
        $newAuthor = $new->addAuthor();
        $newAuthor->name = 'New Author Name';
        $newAuthor->uri = 'New Author Uri';
        $newAuthor->email = 'New Author Email';
        $newLink = $new->addLink();
        $newLink->href = 'New Link Href';
        $newLink->type = 'New Link Type';
        $newLink->rel = 'New Link Rel';
        $newLink->title = 'New Link Title';
        $newLink->hreflang = 'New Link Hreflang';
        $newLink->length = 'New Link Length';
        $newCategory = $new->addCategory();
        $newCategory->term = 'New Category Term';
        $newCategory->scheme = 'New Category Scheme';
        $newCategory->label = 'New Category Label';
        $newEntry = $new->addEntry();
        $newEntry->title = 'New Entry Title';
        $newEntry->title->type = 'New Entry Title Type';
        $newEntry->id = 'New Entry Id';
        $newEntry->updated = 'New Entry Updated';
        $newEntry->published = 'New Entry Published';
        $newEntry->summary = 'New Entry Summary';
        $newEntry->summary->type = 'New Entry Summary Type';
        $newEntry->content = 'New Entry Content';
        $newEntry->content->type = 'New Entry Content Type';
        $newEntry->content->src = 'New Entry Content Src';
        $newEntryAuthor = $newEntry->addAuthor();
        $newEntryAuthor->name = 'New Entry Author Name';
        $newEntryAuthor->uri = 'New Entry Author Uri';
        $newEntryAuthor->email = 'New Entry Author Email';
        $newEntryLink = $newEntry->addLink();
        $newEntryLink->href = 'New Entry Link Href';
        $newEntryLink->type = 'New Entry Link Type';
        $newEntryLink->rel = 'New Entry Link Rel';
        $newEntryLink->title = 'New Entry Link Title';
        $newEntryLink->hreflang = 'New Entry Link Hreflang';
        $newEntryLink->length = 'New Entry Link Length';
        $newEntryCategory = $newEntry->addCategory();
        $newEntryCategory->term = 'New Entry Category Term';
        $newEntryCategory->scheme = 'New Entry Category Scheme';
        $newEntryCategory->label = 'New Entry Category Label';
        $expectedResult = '<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title type="New Title Type">New Title</title><id>New Id</id><updated>New Updated</updated><generator uri="New Generator Uri" version="New Generator Version">New Generator</generator><author><name>New Author Name</name><uri>New Author Uri</uri><email>New Author Email</email></author><link href="New Link Href" type="New Link Type" rel="New Link Rel" title="New Link Title" hreflang="New Link Hreflang" length="New Link Length"/><category term="New Category Term" scheme="New Category Scheme" label="New Category Label"/><entry><title type="New Entry Title Type">New Entry Title</title><id>New Entry Id</id><updated>New Entry Updated</updated><published>New Entry Published</published><summary type="New Entry Summary Type">New Entry Summary</summary><content type="New Entry Content Type" src="New Entry Content Src">New Entry Content</content><author><name>New Entry Author Name</name><uri>New Entry Author Uri</uri><email>New Entry Author Email</email></author><link href="New Entry Link Href" type="New Entry Link Type" rel="New Entry Link Rel" title="New Entry Link Title" hreflang="New Entry Link Hreflang" length="New Entry Link Length"/><category term="New Entry Category Term" scheme="New Entry Category Scheme" label="New Entry Category Label"/></entry></feed>';
        $this->assertEquals(trim($new->getXml()), trim($expectedResult));
        return $new;
    }