protected function __str__() { if ($this->none()) { return ""; } $result = new Tag("content"); foreach ($this->access_members() as $name => $value) { if (!empty($value)) { switch ($name) { case "type": case "mode": $result->param($name, $value); break; case "lang": case "base": $result->param("xml:" . $name, $value); break; case "value": $result->value($value); break; } } } return $result->get(); }
public function post_diary($title, $summary) { $tag = new Tag("entry"); $tag->param("xmlns", "http://www.w3.org/2007/app"); $tag->add(new Tag("title", $title)); $tag->add(new Tag("summary", $summary)); $this->raw($tag->get("utf-8")); $this->do_post("http://mixi.jp/atom/diary/member_id=" . $this->member_id); }
protected function __str__() { $result = new Tag("source"); foreach ($this->access_members() as $name => $value) { if (!empty($value)) { switch ($name) { case "url": case "value": $result->param($name, $value); break; } } } return $result->get(); }
protected function __str__() { /*** * $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($src,(string)$xml); */ $outTag = new Tag("outline"); if ($this->isTitle()) { $outTag->param("title", $this->title()); } if ($this->isHtmlUrl()) { $outTag->param("htmlUrl", $this->htmlUrl()); } if ($this->isType()) { $outTag->param("type", $this->type()); } if ($this->isXmlUrl()) { $outTag->param("xmlUrl", $this->xmlUrl()); } if ($this->isComment()) { $outTag->param("isComment", $this->isComment()); } if ($this->isBreakpoint()) { $outTag->param("isBreakpoint", $this->isBreakpoint()); } if ($this->isText()) { $outTag->param("text", $this->text()); } if ($this->isDescription()) { $outTag->param("description", $this->description()); } if ($this->isTags()) { $outTag->param("tags", $this->tags()); } $outTag->add($this->value()); foreach ($this->arOutline() as $outline) { $outTag->add($outline); } return $outTag->get(); }
protected function __str__() { $out = new Tag("opml"); $out->param("version", $this->version()); $head = new Tag("head"); if ($this->isTitle()) { $head->add(new Tag("title", $this->title())); } if ($this->isDateCreated()) { $head->add(new Tag("dateCreated", $this->formatDate($this->dateCreated()))); } if ($this->isDateModified()) { $head->add(new Tag("dateModified", $this->formatDate($this->dateModified()))); } if ($this->isOwnerName()) { $head->add(new Tag("ownerName", $this->ownerName())); } if ($this->isOwnerEmail()) { $head->add(new Tag("ownerEmail", $this->ownerEmail())); } if ($this->isExpansionState()) { $head->add(new Tag("expansionState", $this->expansionState())); } if ($this->isVertScrollState()) { $head->add(new Tag("vertScrollState", $this->vertScrollState())); } if ($this->isWindowTop()) { $head->add(new Tag("windowTop", $this->windowTop())); } if ($this->isWindowLeft()) { $head->add(new Tag("windowLeft", $this->windowLeft())); } if ($this->isWindowBottom()) { $head->add(new Tag("windowBottom", $this->windowBottom())); } if ($this->isWindowRight()) { $head->add(new Tag("windowRight", $this->windowRight())); } $out->adde($head); $body = new Tag("body"); foreach ($this->arOutline() as $outline) { $body->add($outline->get()); } $out->add($body->get()); return $out(); }
protected function __str__() { if ($this->none()) { return ""; } $result = new Tag("link"); foreach ($this->access_members() as $name => $value) { if (!empty($value)) { switch ($name) { case "href": case "rel": case "type": $result->param($name, $value); break; } } } return $result->get(); }
protected function __str__() { if ($this->none()) { return ""; } $result = new Tag("entry"); foreach ($this->access_members() as $name => $value) { if (!empty($value)) { switch ($name) { case "xmlns": $result->param("xmlns", $value); break; case "id": case "title": $result->add(new Tag($name, $value)); break; case "published": case "updated": case "issued": $result->add(new Tag($name, Date::format_atom($value))); break; default: if (is_array($this->{$name})) { foreach ($this->{$name} as $o) { $result->add($o); } break; } else { if (is_object($this->{$name})) { $result->add($value); break; } else { $result->add(new Tag($name, $value)); break; } } } } } return $result->get(); }
private static function parse_map(Tag $map_tag, $url, $path, $scope, $base_class, $secure, $update, $map_index, $get_meta) { $params = $args = $vars = $modules = $meta = array(); if (!$map_tag->is_param('class')) { $map_tag->param('class', $base_class); } $params['url'] = $url; $params['scope'] = $scope; $params['map_index'] = $map_index; $params['redirect'] = File::path_slash($map_tag->in_param('redirect'), false, false); $params['template'] = File::path_slash($map_tag->in_param('template'), false, false); $params['secure'] = $map_tag->in_param('secure', $secure) === 'true'; $params['update'] = $map_tag->in_param('update', $update) === 'true'; if (!empty($params['template']) && !empty($path)) { $params['template'] = $path . '/' . $params['template']; } foreach (array('class', 'method', 'name') as $c) { $params[$c] = $map_tag->in_param($c); } foreach ($map_tag->in('module') as $t) { $modules[] = self::parse_module($t); } foreach ($map_tag->in('var') as $t) { $vars[] = self::parse_var($t); } foreach ($map_tag->in('arg') as $a) { $args[$a->in_param('name')] = $a->in_param('value', $a->value()); } if ($get_meta) { $meta['summary'] = $map_tag->in_param('summary'); } list($params['vars'], $params['modules'], $params['args'], $params['meta']) = array($vars, $modules, $args, $meta); if (!empty($params['class']) && empty($params['method'])) { Exceptions::add(new InvalidArgumentException('map `' . $map_tag->plain() . '` method not found')); } if (!empty($params['method']) && empty($params['class'])) { Exceptions::add(new InvalidArgumentException('map `' . $map_tag->plain() . '` class not found')); } return $params; }
protected function __str__() { $result = new Tag("rss"); $channel = new Tag("channel"); foreach ($this->access_members() as $name => $value) { if (!empty($value)) { switch ($name) { case "version": $result->param("version", $value); break; case "title": case "link": case "description": case "language": case "copyright": case "docs": case "managingEditor": case "webMaster": $channel->add(new Tag($name, $value)); break; case "lastBuildDate": case "pubDate": $channel->add(new Tag($name, $this->formatDate($value))); break; default: if (is_array($this->{$name})) { foreach ($this->{$name} as $o) { $channel->add($o); } break; } else { if (is_object($this->{$name})) { $channel->add($value); break; } else { $channel->add(new Tag($name, $value)); break; } } } } } $result->add($channel); return $result->get(); /*** $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(str_replace(array("\n","\t"),"",$src),(string)$xml); */ }
protected function __str__() { $result = new Tag("feed"); $result->param("xmlns", self::$XMLNS); foreach ($this->access_members() as $name => $value) { if (!empty($value)) { switch ($name) { case "title": case "subtitle": case "id": case "generator": $result->add(new Tag($name, $value)); break; case "author": foreach ($this->{$name} as $o) { $result->add($o); } break; case "updated": $result->add(new Tag($name, Date::format_atom($value))); break; default: if (is_array($this->{$name})) { foreach ($this->{$name} as $o) { $result->add($o); } break; } else { if (is_object($this->{$name})) { $result->add($value); break; } else { $result->add(new Tag($name, $value)); break; } } } } } return $result->get(); /*** $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); $result = text(' <feed xmlns="http://www.w3.org/2005/Atom"> <title>atom10 feed</title> <subtitle>atom10 sub title</subtitle> <id>rhaco</id> <generator>tokushima</generator> <updated>2007-07-18T16:16:31Z</updated> <link rel="abc" type="xyz" href="http://tokushimakazutaka.com" /> <entry> <id>rhaco</id> <title>rhaco</title> <published>2007-07-18T16:16:31Z</published> <updated>2007-07-18T16:16:31Z</updated> <issued>2007-07-18T16:16:31Z</issued> <content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content> <summary type="xml" xml:lang="ja">summary test</summary> <link rel="abc" type="xyz" href="http://rhaco.org" /> <link rel="abc" type="conveyor" href="http://conveyor.rhaco.org" /> <link rel="abc" type="lib" href="http://lib.rhaco.org" /> <author> <name>rhaco</name> <url>http://rhaco.org</url> <email>rhaco@rhaco.org</email> </author> </entry> <entry> <id>django</id> <title>django</title> <published>2007-07-18T16:16:31Z</published> <updated>2007-07-18T16:16:31Z</updated> <issued>2007-07-18T16:16:31Z</issued> <content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content> <summary type="xml" xml:lang="ja">summary test</summary> <link rel="abc" type="xyz" href="http://djangoproject.jp" /> <author> <name>everes</name> <url>http://www.everes.net</url> <email>everes@hoge.hoge</email> </author> </entry> <author> <name>tokushima</name> <url>http://tokushimakazutaka.com</url> <email>tokushima@hoge.hoge</email> </author> </feed> '); $result = str_replace(array("\n","\t"),"",$result); eq($result,(string)$xml); */ }