/** * xmlをRssに変換する * * @param string $src * @return Rss */ public static function parse($src) { if (Tag::setof($rss, $src, "rss")) { $result = new self(); $result->version($rss->inParam("version", "2.0")); if (Tag::setof($channel, $rss->value(), "channel")) { $result->title($channel->f("title.value()")); $result->link($channel->f("link.value()")); $result->description($channel->f("description.value()")); $result->language($channel->f("language.value()")); $result->copyright($channel->f("copyright.value()")); $result->docs($channel->f("docs.value()")); $result->managingEditor($channel->f("managingEditor.value()")); $result->webMaster($channel->f("webMaster.value()")); $result->lastBuildDate($channel->f("lastBuildDate.value()")); $result->pubDate($channel->f("pubDate.value()")); $value = $channel->value(); $result->item = RssItem::parse($value); return $result; } } throw new Exception("no rss"); /*** $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())); */ }
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; }
/** * @return self */ public static function newPurgeTask() { global $wgCityId; $task = new self(); $task->call('purgeExpiredRows'); $task->wikiId($wgCityId); $task->title(\SpecialPage::getTitleFor('Recentchanges')); $task->queue(); return $task; }
public static function parse_list($response) { $result = array(); $res = Text::parse_json($response); if (!isset($res["responseData"]["results"])) { throw new Exception("Invalid data"); } foreach ($res["responseData"]["results"] as $re) { $obj = new self(); $obj->cache_url($re["cacheUrl"]); $obj->url($re["unescapedUrl"]); $obj->title($re["titleNoFormatting"]); $obj->content($re["content"]); $result[] = $obj; } return $result; }
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; }
public static function parse($src) { $result = array(); foreach (Tag::anyhow($src)->in("item") as $in) { $o = new self(); $o->title($in->f("title.value()")); $o->link($in->f("link.value()")); $o->description($in->f("description.value()")); $o->author($in->f("author.value()")); $o->category($in->f("category.value()")); $o->comments($in->f("comments.value()")); $o->pubDate($in->f("pubDate.value()")); $o->guid($in->f("guid.value()")); $value = $in->value(); $o->enclosure = RssEnclosure::parse($value); $o->source = RssSource::parse($src); $result[] = $o; } return $result; }
public function parse_list($response) { if ($response === "N;") { throw new Exception("Invalid data"); } $result = array(); foreach (unserialize($response) as $re) { $obj = new self(); $obj->language($re["language"]); $obj->id($re["id"]); $obj->url($re["url"]); $obj->title($re["title"]); $obj->body($re["body"]); $obj->length($re["length"]); $obj->redirect($re["redirect"]); $obj->strict($re["strict"]); $obj->datetime($re["datetime"]); $result[] = $obj; } return $result; }
/** * Atomに変換する * * @param string $title * @param string $link * @param iterator $entrys * @return Atom */ public static function convert($title, $link, $entrys) { $atom = new self(); $atom->title($title); $atom->link(new AtomLink("href=" . $link)); foreach ($entrys as $entry) { $atom->add($entry); } return $atom; }
/** * 文字列からOpmlをセットする * * @param string $src */ public static function parse($src) { if (Tag::setof($tag, $src, "opml")) { $result = new self(); $result->title($tag->f("title.value()")); $result->dateCreated($tag->f("dateCreated.value()")); $result->dateModified($tag->f("dateModified.value()")); $result->ownerName($tag->f("ownerName.value()")); $result->ownerEmail($tag->f("ownerEmail.value()")); $result->expansionState($tag->f("expansionState.value()")); $result->vertScrollState($tag->f("vertScrollState.value()")); $result->windowTop($tag->f("windowTop.value()")); $result->windowLeft($tag->f("windowLeft.value()")); $result->windowBottom($tag->f("windowBottom.value()")); $result->windowRight($tag->f("windowRight.value()")); foreach ($tag->in("outline") as $intag) { $opmloutline = new OpmlOutline(); $result->outline($opmloutline->parse($intag->plain())); } return $result; } throw new Exception("no opml"); /*** $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に変換する * * @param string $title * @param string $link * @param iterator $entrys * @return self */ public static function convert($title, $link, $entrys) { $atom = new self(); $atom->title($title); $atom->link(new \org\rhaco\net\xml\atom\Link('href=' . $link)); foreach ($entrys as $entry) { $atom->add($entry); } return $atom; }
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; }
public static function parse($src, $tags = "") { $result = null; if (Tag::setof($tag, $src, "outline")) { $result = new self(); $result->text($tag->inParam("text")); $result->type($tag->inParam("type")); $result->comment($tag->inParam("isComment", false)); $result->breakpoint($tag->inParam("isBreakpoint", false)); $result->htmlUrl($tag->inParam("htmlUrl")); $result->xmlUrl($tag->inParam("xmlUrl")); $result->title($tag->inParam("title")); $result->description($tag->inParam("description")); $result->tags($tags); foreach ($tag->in("outline") as $outlinetag) { $result->outline(self::parse($outlinetag->plain(), $tags)); } } return $result; /*** * $src = '<outline title="りあふ の にっき" htmlUrl="http://riaf.g.hatena.ne.jp/riaf/" type="rss" xmlUrl="http://riaf.g.hatena.ne.jp/riaf/rss2" />'; * $xml = OpmlOutline::parse($src); * eq("りあふ の にっき",$xml->title()); * eq("http://riaf.g.hatena.ne.jp/riaf/rss2",$xml->xmlUrl()); * eq("http://riaf.g.hatena.ne.jp/riaf/",$xml->htmlUrl()); * eq("rss",$xml->type()); * */ }