Esempio n. 1
0
File: Atom.php Progetto: hisaboh/w2t
 public static function parse($src)
 {
     $args = func_get_args();
     array_shift($args);
     if (Tag::setof($tag, $src, "feed") && $tag->inParam("xmlns") == self::$XMLNS) {
         $result = new self();
         $value = $tag->value();
         $tag = Tag::anyhow($value);
         $result->id($tag->f("id.value()"));
         $result->title($tag->f("title.value()"));
         $result->subtitle($tag->f("subtitle.value()"));
         $result->updated($tag->f("updated.value()"));
         $result->generator($tag->f("generator.value()"));
         $value = $tag->value();
         $result->entry = call_user_func_array(array("AtomEntry", "parse"), array_merge(array(&$value), $args));
         $result->link = AtomLink::parse($value);
         $result->author = AtomAuthor::parse($value);
         return $result;
     }
     throw new Exception("no atom");
     /***
     			$src = text('
     						<feed xmlns="http://www.w3.org/2005/Atom">
     							<title>atom10 feed</title>
     							<subtitle>atom10 sub title</subtitle>
     							<updated>2007-07-18T16:16:31+00:00</updated>
     							<generator>tokushima</generator>
     							<link href="http://tokushimakazutaka.com" rel="abc" type="xyz" />
     
     							<author>
     								<url>http://tokushimakazutaka.com</url>
     								<name>tokushima</name>
     								<email>tokushima@hoge.hoge</email>
     							</author>
     
     							<entry>
     								<title>rhaco</title>
     								<summary type="xml" xml:lang="ja">summary test</summary>
     								<content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content>
     								<link href="http://rhaco.org" rel="abc" type="xyz" />
     								<link href="http://conveyor.rhaco.org" rel="abc" type="conveyor" />
     								<link href="http://lib.rhaco.org" rel="abc" type="lib" />
     
     							 <updated>2007-07-18T16:16:31+00:00</updated>
     							 <issued>2007-07-18T16:16:31+00:00</issued>
     							 <published>2007-07-18T16:16:31+00:00</published>
     							 <id>rhaco</id>
     							<author>
     								<url>http://rhaco.org</url>
     								<name>rhaco</name>
     								<email>rhaco@rhaco.org</email>
     							</author>
     							</entry>
     
     							<entry>
     								<title>django</title>
     								<summary type="xml" xml:lang="ja">summary test</summary>
     								<content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content>
     								<link href="http://djangoproject.jp" rel="abc" type="xyz" />
     
     							 <updated>2007-07-18T16:16:31+00:00</updated>
     							 <issued>2007-07-18T16:16:31+00:00</issued>
     							 <published>2007-07-18T16:16:31+00:00</published>
     							 <id>django</id>
     							<author>
     								<url>http://www.everes.net</url>
     								<name>everes</name>
     								<email>everes@hoge.hoge</email>
     							</author>
     							</entry>
     						</feed>
     					');
     
     			$xml = Atom::parse($src);
     			eq("atom10 feed",$xml->title());
     			eq("atom10 sub title",$xml->subtitle());
     			eq(1184775391,$xml->updated());
     			eq("2007-07-18T16:16:31Z",$xml->fmUpdated());
     			eq("tokushima",$xml->generator());
     			eq(2,sizeof($xml->entry()));
     		*/
 }
Esempio n. 2
0
 public static function parse(&$src)
 {
     $args = func_get_args();
     array_shift($args);
     $result = array();
     foreach (Tag::anyhow($src)->in("entry") as $in) {
         $o = new self();
         foreach ($args as $module) {
             $o->add_modules($module);
         }
         $o->id($in->f("id.value()"));
         $o->title($in->f("title.value()"));
         $o->published($in->f("published.value()"));
         $o->updated($in->f("updated.value()"));
         $o->issued($in->f("issued.value()"));
         $value = $in->value();
         $o->content = AtomContent::parse($value);
         $o->summary = AtomSummary::parse($value);
         $o->link = AtomLink::parse($value);
         $o->author = AtomAuthor::parse($value);
         $o->parse_extra($value);
         $result[] = $o;
         $src = str_replace($in->plain(), "", $src);
     }
     return $result;
 }