public static function parse_list($response) { $result = array(); try { $atom = Atom::parse($response, new YouTubeDataMedia()); } catch (Exception $e) { throw new Exception($response); } foreach ($atom->arEntry() as $entry) { $obj = new self(); $links = $entry->link(); if (isset($links[0])) { $obj->url($links[0]->href()); } if (isset($links[3])) { $obj->mobile_url($links[3]->href()); } if ($entry->content() instanceof AtomContent) { $obj->content($entry->content()->value()); } $obj->title($entry->title()); $obj->published($entry->published()); $obj->updated($entry->updated()); $obj->keyword($entry->extra()->keyword()); $obj->duration($entry->extra()->duration()); $obj->player($entry->extra()->player()); $obj->category($entry->extra()->category()); $obj->thumbnail($entry->extra()->thumbnail()); $result[] = $obj; } return $result; }
public static function parse(Tag $entry) { $self = new self(); $self->term($entry->f("category.param(term)")); $self->link($entry->f("link.param(href)")); $self->content($entry->f("content.value()")); $self->updated($entry->f("updated.value()")); $user = new MixiUser(); $user->name($entry->f("author.name.value()")); $user->link($entry->f("author.uri.value()")); $self->author($user); return $self; }
public static function parse(Tag $entry) { $self = new self(); $author = $entry->f("author"); if ($author !== null) { $self->name($author->f("name.value()")); $self->image($author->f("tracks:image.value()")); $self->relation($author->f("tracks:relation.value()")); } else { $self->name($entry->f("title.value()")); $self->image($entry->f("icon.value()")); $self->relation("friends"); } $self->updated($entry->f("updated.value()")); $self->link($entry->f("link.param(href)")); return $self; }
public static function parse_list($response, $paginator) { $result = array(); $res = Text::parse_json($response); if (isset($res["error"])) { throw new Exception($res["error"]); } if (!empty($res["pager"])) { $paginator = new Paginator($res["pager"]["clips_in_page"], $res["pager"]["current_page"], $res["pager"]["total_entries"]); } if (!empty($res["entries"])) { foreach ($res["entries"] as $re) { $obj = new self(); $obj->id($re["id"]); $obj->title($re["title"]); $obj->url($re["permalink"]); $obj->author(new FlipClipAuthor($re["author"]["id"], $re["author"]["name"], $re["author"]["uri"])); $obj->summary($re["summary"]); $obj->updated($re["updated"]); if (isset($re["category"])) { $obj->category(new FlipClipCategory($re["category"]["term"], $re["category"]["scheme"], $re["category"]["label"])); } if (isset($re["subcategory"])) { $obj->category(new FlipClipCategory($re["subcategory"]["term"], $re["subcategory"]["scheme"], $re["subcategory"]["label"])); } if (isset($re["tags"])) { foreach ($re["tags"] as $tag) { $obj->tags(new FlipClipTag($tag["term"], $tag["scheme"], $tag["label"])); } } $obj->embed_script($re["embed_script"]); $obj->latitude($re["latitude"]); $obj->longitude($re["longitude"]); $obj->privacy($re["privacy"]); $obj->duration($re["duration"]); $obj->image($re["image"]); $obj->image_medium($re["imageMedium"]); $obj->image_small($re["imageSmall"]); $obj->thumbnail($re["thumbnail"]); $result[] = $obj; } } return $result; }
/** * 文字列からAtomフィードを取得する * @param string $src * @return self */ public static function parse($src) { $args = func_get_args(); array_shift($args); if (\org\rhaco\Xml::set($tag, $src, 'feed') && $tag->in_attr('xmlns') == self::XMLNS) { $result = new self(); $value = $tag->value(); \org\rhaco\Xml::set($tag, '<:>' . $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 = \org\rhaco\net\xml\atom\Entry::parse($value); $result->link = \org\rhaco\net\xml\atom\Link::parse($value); $result->author = \org\rhaco\net\xml\atom\Author::parse($value); return $result; } throw new \InvalidArgumentException('no atom'); }
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())); */ }
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; }
public static function parse(&$src) { $args = func_get_args(); array_shift($args); $result = array(); \org\rhaco\Xml::set($x, '<:>' . $src . '</:>'); foreach ($x->in('entry') as $in) { $o = new self(); $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 = Content::parse($value); $o->summary = Summary::parse($value); $o->link = Link::parse($value); $o->author = Author::parse($value); $result[] = $o; $src = str_replace($in->plain(), '', $src); } return $result; }