Beispiel #1
0
 protected function __add__($arg)
 {
     if ($arg instanceof AtomEntry) {
         $this->entry[] = $arg;
     } else {
         if ($arg instanceof self) {
             foreach ($arg->arEntry() as $entry) {
                 $this->entry[] = $entry;
             }
         } else {
             if (is_implements_of($arg, "AtomInterface")) {
                 $entry = new AtomEntry();
                 $entry->id($arg->atom_id());
                 $entry->title($arg->atom_title());
                 $entry->published($arg->atom_published());
                 $entry->updated($arg->atom_updated());
                 $entry->issued($arg->atom_issued());
                 $content = new AtomContent();
                 $content->value($arg->atom_content());
                 $entry->content($content);
                 $summary = new AtomSummary();
                 $summary->value($arg->atom_summary());
                 $entry->summary($summary);
                 $entry->link(new AtomLink("href=" . $arg->atom_href()));
                 $entry->author(new AtomAuthor("name=" . $arg->atom_author()));
                 $this->entry[] = $entry;
             }
         }
     }
 }
Beispiel #2
0
 public function atom()
 {
     Rhaco::import("net.feed.atom.Atom");
     $atom = new Atom();
     $atom->title($this->title());
     $atom->subtitle($this->description());
     $atom->generator($this->webMaster());
     $atom->updated($this->lastBuildDate());
     $link = new AtomLink();
     $link->href($this->link());
     $atom->link($link);
     foreach ($this->arItem() as $item) {
         $entry = new AtomEntry();
         $entry->title($item->title());
         $entry->published($item->pubDate());
         $author = new AtomAuthor();
         $author->name($item->author());
         $entry->author($author);
         $link = new AtomLink();
         $link->href($item->link());
         $entry->link($link);
         $content = new AtomContent();
         $content->value($item->description());
         $entry->content($content);
         $summary = new AtomSummary();
         $summary->value($item->comments());
         $entry->summary($summary);
         $atom->add($entry);
     }
     return $atom;
     /***
     			 $src = text('
     						<rss version="2.0">
     							<channel>
     								<title>rhaco</title>
     								<link>http://rhaco.org</link>
     								<description>php</description>
     								<language>ja</language>
     								<copyright>rhaco.org</copyright>
     								<docs>hogehoge</docs>
     								<lastBuildDate>2007-10-10T10:10:10+09:00</lastBuildDate>
     								<managingEditor>tokushima</managingEditor>
     								<pubDate>2007-10-10T10:10:10+09:00</pubDate>
     								<webMaster>kazutaka</webMaster>
     								<item>
     									<title>rhaco</title>
     									<link>http://rhaco.org</link>
     									<description>rhaco desc</description>
     								</item>
     								<item>
     									<title>everes</title>
     									<link>http://www.everes.net</link>
     									<description>everes desc</description>
     								</item>
     							</channel>
     						</rss>
     					');
     					$xml = Rss::parse($src);
     					eq("2.0",$xml->version());
     					eq("rhaco",$xml->title());
     					eq("http://rhaco.org",$xml->link());
     					eq("php",$xml->description());
     					eq("ja",$xml->language());
     					eq("rhaco.org",$xml->copyright());
     					eq("hogehoge",$xml->docs());
     					eq(1191978610,$xml->lastBuildDate());
     					eq("Wed, 10 Oct 2007 10:10:10 +0900",$xml->fmLastBuildDate());
     					eq("tokushima",$xml->managingEditor());
     					eq(1191978610,$xml->pubDate());
     					eq("Wed, 10 Oct 2007 10:10:10 +0900",$xml->fmPubDate());
     					eq("kazutaka",$xml->webMaster());
     					eq(2,sizeof($xml->item()));
     
     					$atom = $xml->atom();
     					eq(true,$atom instanceof Atom);
     					eq("rhaco",$atom->title());
     					eq("php",$atom->subtitle());
     					eq(1191978610,$atom->updated());
     					eq("kazutaka",$atom->generator());
     					eq(2,sizeof($atom->entry()));
     			*/
 }
Beispiel #3
0
 public function atom()
 {
     Rhaco::import("net.feed.atom.Atom");
     $atom = new Atom();
     $atom->title($this->title());
     foreach ($this->outlines() as $outline) {
         $entry = new AtomEntry();
         $entry->title($outline->title());
         $entry->published(time());
         if ($outline->isHtmlUrl()) {
             $entry->link(new AtomLink("type=html,href=" . $outline->htmlUrl()));
         }
         if ($outline->isXmlUrl()) {
             $entry->link(new AtomLink("type=xml,href=" . $outline->xmlUrl()));
         }
         $entry->content(new AtomContent("value=" . $outline->description()));
         $entry->summary(new AtomSummary("value=" . $outline->tags()));
         $atom->add($entry);
     }
     return $atom;
     /***
     			$text = text('
     						<?xml version="1.0" encoding="utf-8"?>
     						<opml version="1.0">
     						<head>
     							<title>Subscriptions</title>
     							<dateCreated>Mon, 19 May 2008 04:51:05 UTC</dateCreated>
     							<ownerName>rhaco</ownerName>
     						</head>
     						<body>
     						<outline title="Subscriptions">
     							  <outline title="スパムとか" htmlUrl="http://www.everes.net/" type="rss" xmlUrl="http://www.everes.net/blog/atom/" />
     							  <outline title="tokushimakazutaka.com" htmlUrl="http://tokushimakazutaka.com" type="rss" xmlUrl="tokushimakazutaka.com/rss" />
     							<outline title="rhaco">
     							</outline>
     							<outline title="php">
     							  <outline title="riaf-ja blog" htmlUrl="http://blog.riaf.jp/" type="rss" xmlUrl="http://blog.riaf.jp/rss" />
     							</outline>
     							<outline title="お知らせ">
     							</outline>
     						</outline>
     						</body></opml>
     					');
     
     			$feed = Opml::parse($text);
     			eq("Subscriptions",$feed->title());
     			eq("1.0",$feed->version());
     			eq(1211172665,$feed->dateCreated());
     			eq("rhaco",$feed->ownerName());
     			eq(null,$feed->ownerEmail());
     			
     			eq(1,sizeof($feed->outline()));
     			$opml = $feed->outline();
     			eq("Subscriptions",$opml[0]->title());
     	
     			eq(3,sizeof($opml[0]->xml()));
     			eq(3,sizeof($opml[0]->html()));
     
     			$atom = $feed->atom();
     			eq(true,$atom instanceof Atom);
     			eq("Subscriptions",$atom->title());
     			eq(null,$atom->subtitle());
     			eq(time(),$atom->updated());
     			eq(null,$atom->generator());
     			eq(5,sizeof($atom->entry()));
     		*/
 }