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(); }
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); */ }
/** * WSSE認証 * @param string $user * @param string $password */ public function wsse($user, $password) { $nonce = sha1(md5(time() . rand()), true); $created = Date::format_atom(time()); $this->header("X-WSSE", sprintf("UsernameToken Username=\"%s\", PasswordDigest=\"%s\", Nonce=\"%s\", Created=\"%s\"", $user, base64_encode(sha1($nonce . $created . $password, true)), base64_encode($nonce), $created)); }