rhaco.org
PHP library & setup framework
rhaco version: 1.6.0
File
ファイルモデル
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
FileUtil
ファイル操作を行うクラス
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
fgets [ # ]
ファイルから取得する
トランザクションを利用する事ができる
@param string $filename
@param string $enc
@return string
トランザクションを利用する事ができる
@param string $filename
@param string $enc
@return string
unit("io.FileUtilTest");
fputs [ # ]
ファイルに追記する
トランザクションを利用する事ができる
@param string $filename
@param string $src
@param string $enc
@return boolean
トランザクションを利用する事ができる
@param string $filename
@param string $src
@param string $enc
@return boolean
unit("io.FileUtilTest");
fwrite [ # ]
ファイルを上書きする
トランザクションが利用できる
@param string $filename
@param string $src
@param string $enc
@return boolean
トランザクションが利用できる
@param string $filename
@param string $src
@param string $enc
@return boolean
unit("io.FileUtilTest");
read [ # ]
ファイルから読み込む
@static
@param string $filename
@param string $enc
@return string
@static
@param string $filename
@param string $enc
@return string
unit("io.FileUtilTest");
write [ # ]
ファイルに書き込む
@static
@param string $filename
@param string $src
@param string $enc
@return string
@static
@param string $filename
@param string $src
@param string $enc
@return string
unit("io.FileUtilTest");
append [ # ]
ファイルに追記する
@static
@param string $filename
@param string $src
@param string $enc
@return string
@static
@param string $filename
@param string $src
@param string $enc
@return string
unit("io.FileUtilTest");
path [ # ]
ファイルパスを生成する
@static
@param string $base
@param string $path
@return string
@static
@param string $base
@param string $path
@return string
$null
eq("/abc/def/hig.php",FileUtil::path("/abc/def","hig.php"));
eq("/xyz/abc/hig.php",FileUtil::path("/xyz/","/abc/hig.php"));
eq("/xyz/abc/hig.php",FileUtil::path("/xyz/","/abc/hig.php"));
parseFilename [ # ]
ファイル名をそれっぽくする
@static
@param string $filename
@return string
@static
@param string $filename
@return string
eq("/Users/kaz/Sites/rhacotest/test/io/FileUtilTest.php",FileUtil::parseFilename("/Users/kaz/Sites/rhacotest/test/io/FileUtilTest.php"));
eq("/Users/kaz/Sites/rhacotest/test/io",FileUtil::parseFilename("/Users/kaz/Sites/rhacotest/test/io"));
eq("/Users/kaz/Sites/rhacotest/test/io",FileUtil::parseFilename("/Users/kaz/Sites/rhacotest/test/io/"));
eq("/Users/kaz/Sites/rhacotest/test/io",FileUtil::parseFilename("\\Users\\kaz\\Sites\\rhacotest\\test\\io"));
eq("C:/Users/kaz/Sites/rhacotest/test/io",FileUtil::parseFilename("C:\\Users\\kaz\\Sites\\rhacotest\\test\\io"));
eq("/Users/kaz/Sites/rhacotest/test/io",FileUtil::parseFilename("/Users/kaz/Sites/rhacotest/test/io"));
eq("/Users/kaz/Sites/rhacotest/test/io",FileUtil::parseFilename("/Users/kaz/Sites/rhacotest/test/io/"));
eq("/Users/kaz/Sites/rhacotest/test/io",FileUtil::parseFilename("\\Users\\kaz\\Sites\\rhacotest\\test\\io"));
eq("C:/Users/kaz/Sites/rhacotest/test/io",FileUtil::parseFilename("C:\\Users\\kaz\\Sites\\rhacotest\\test\\io"));
ls [ # ]
指定された$directory内のファイル情報をio.model.Fileとして配列で取得
@static
@param string $directory
@param boolean $recursive 階層を潜って取得するか
@return array(File)
@static
@param string $directory
@param boolean $recursive 階層を潜って取得するか
@return array(File)
unit("io.FileUtilTest");
dirs [ # ]
フォルダ名の配列を取得
@static
@param string $directory
@param boolean $recursive 階層を潜って取得するか
@static
@param string $directory
@param boolean $recursive 階層を潜って取得するか
unit("io.FileUtilTest");
find [ # ]
ファイルを検索する
@static
@param string $pattern 正規表現パターン
@param string $directory
@param boolean $recursive 階層を潜って取得するか
@static
@param string $pattern 正規表現パターン
@param string $directory
@param boolean $recursive 階層を潜って取得するか
unit("io.FileUtilTest");
cp [ # ]
コピー
$sourceがフォルダの場合はそれ以下もコピーする
@static
@param string $source
@param string $dest
@param int $parmission
@return boolean
$sourceがフォルダの場合はそれ以下もコピーする
@static
@param string $source
@param string $dest
@param int $parmission
@return boolean
$parmission
unit("io.FileUtilTest");
rm [ # ]
削除
$sourceが削除の場合はそれ以下も全て削除します
@static
@param string $source
@return boolean
$sourceが削除の場合はそれ以下も全て削除します
@static
@param string $source
@return boolean
unit("io.FileUtilTest");
mkdir [ # ]
フォルダを作成する
@static
@param string $source
@param int $permission
@return boolean
@static
@param string $source
@param int $permission
@return boolean
unit("io.FileUtilTest");
mv [ # ]
移動
@static
@param string $source
@param string $dest
@return boolean
@static
@param string $source
@param string $dest
@return boolean
unit("io.FileUtilTest");
size [ # ]
ファイルサイズを取得する
@static
@param string $filename
@param string $format
@return int
@static
@param string $filename
@param string $format
@return int
$size
#viewing
pack [ # ]
複数のファイルから単一のソースを作成する
@static
@param unknown_type $paths
@return unknown
@static
@param unknown_type $paths
@return unknown
$path = FileUtil::path(Rhaco::rhacopath(),"/io/FileUtil.php");
$paths = array("FileUtil.php"=>$path,"io/FileUtil.php"=>$path);
$src = FileUtil::pack($paths);
preg_match_all("/\[\[(.+)?\]\]/",$src,$match);
eq(2,sizeof($match[1]));
$paths = array("FileUtil.php"=>$path,"io/FileUtil.php"=>$path);
$src = FileUtil::pack($paths);
preg_match_all("/\[\[(.+)?\]\]/",$src,$match);
eq(2,sizeof($match[1]));
unpack [ # ]
packされたソースから展開する
@static
@param unknown_type $src
@param unknown_type $outputdir
@static
@param unknown_type $src
@param unknown_type $outputdir
#viewing
Stream
ストリームを操作するクラス
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
Cache
キャッシュを操作するクラス
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
isExpiry [ # ]
$urlsが生存期間を超えているか
@param array / string $urls
@param 生存時間 $expiryTime
@return boolean
@param array / string $urls
@param 生存時間 $expiryTime
@return boolean
#viewing
execute [ # ]
キャッシュの内容をPHPとして実行する
@param array / string $urls
@param array $variables
@return string / false
@param array / string $urls
@param array $variables
@return string / false
#viewing
path [ # ]
キャッシュのパスを取得する
@param array / string $urls
@return string
@param array / string $urls
@return string
eq("2ccfea6a1c6fb5cfa92ab9dd763e86f1",Cache::path("/var/rhaco/templates/hoge.html"));
eq("682493e7ae5aa9f55a4d4b2017724f1a",Cache::path("/var/rhaco/templates/hoge.html?hoge=abc&def=geko"));
eq("e6f85c0f789c9758c051b011db6fa91a",Cache::path(array("/var/rhaco/templates/hoge.html?hoge=abc&def=geko","http://rhaco.org/hoge/abc")));
eq("682493e7ae5aa9f55a4d4b2017724f1a",Cache::path("/var/rhaco/templates/hoge.html?hoge=abc&def=geko"));
eq("e6f85c0f789c9758c051b011db6fa91a",Cache::path(array("/var/rhaco/templates/hoge.html?hoge=abc&def=geko","http://rhaco.org/hoge/abc")));
Snapshot
スナップショットを操作するクラス
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
exist [ # ]
保存されたスナップショットが存在するか
@static
@param string $url
@param array $variables
@param int $expiryTime
@return boolean
@static
@param string $url
@param array $variables
@param int $expiryTime
@return boolean
unit("io.SnapshotTest");
save [ # ]
スナップショットを保存する
@static
@param string $url
@param array $variables
@return string
@static
@param string $url
@param array $variables
@return string
unit("io.SnapshotTest");
load [ # ]
保存されたスナップショットを取得
@static
@param string $url
@param array $variables
@return string
@static
@param string $url
@param array $variables
@return string
unit("io.SnapshotTest");
write [ # ]
保存されたスナップショットをPHPとして出力する
@static
@param string $url
@param array $variables
@static
@param string $url
@param array $variables
unit("io.SnapshotTest");
clear [ # ]
保存されたスナップショット削除する
@static
@param string $url
@param array $variables
@return boolean
@static
@param string $url
@param array $variables
@return boolean
unit("io.SnapshotTest");
path [ # ]
スナップショットのパスを取得
@static
@param string $url
@param array $variables
@return string
@static
@param string $url
@param array $variables
@return string
$path = Snapshot::path("http://rhaco.org/hoge/test.php",array("hoge"=>"abc"));
eq(FileUtil::path(Rhaco::path("work/snapshot/"),"aHR0cDovL3JoYWNvLm9yZy9ob2dlL3Rlc3QucGhwaG9nZT1hYmM="),$path);
eq(FileUtil::path(Rhaco::path("work/snapshot/"),"aHR0cDovL3JoYWNvLm9yZy9ob2dlL3Rlc3QucGhwaG9nZT1hYmM="),$path);
NetscapeBookmark
NETSCAPE-Bookmark-file-1 MODEL
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
AtomLink
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
RssChannel09
<RssChannel>
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
RssChannel10
<RssChannel>
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
RssChannel20
<RssChannel09>
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
AtomEntry
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
RssSource
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
AtomSummary
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
NetscapeBookmarkItem
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
RssTextinput
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
RssItem
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
AtomContent
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
RssEnclosure
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
RssItem10
<RssItem>
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
RssItem20
<RssItem>
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
NetscapeBookmarkBlock
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
RssChannel
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
OpmlOutline
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
RssImage
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
AtomAuthor
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
RssTextinput10
<RssTextinput>
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
RssCloud
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
AtomEntry03
<AtomEntry>
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
AtomEntry10
<AtomEntry>
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
RssImage09
<RssImage>
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
RssImage10
<RssImage>
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
Opml
Opml Model
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
Atom03
<Atom>
Atom03 Model
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
set [ # ]
文字列からAtom03をセットする
@param string $src
@param string $src
$src = <<< __XML__
<feed version="0.3">
<title>atom03 feed</title>
<modified>2007-07-18T16:16:31+00:00</modified>
<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" />
<modified>2007-07-18T16:16:31+00:00</modified>
<issued>2007-07-18T16:16:31+00:00</issued>
<created>2007-07-18T16:16:31+00:00</created>
<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" />
<modified>2007-07-18T16:16:31+00:00</modified>
<issued>2007-07-18T16:16:31+00:00</issued>
<created>2007-07-18T16:16:31+00:00</created>
<id>django</id>
<author>
<url>http://www.everes.net</url>
<name>everes</name>
<email>everes@hoge.hoge</email>
</author>
</entry>
</feed>
__XML__;
$xml = new Atom03();
assert($xml->set($src));
eq("atom03 feed",$xml->getTitle());
eq("http://tokushimakazutaka.com",$xml->getLinkHref());
eq("2007-07-19T01:16:31+09:00",$xml->getModified());
$author = $xml->getAuthor();
eq("http://tokushimakazutaka.com",$author->getUrl());
eq("tokushima",$author->getName());
eq("tokushima@hoge.hoge",$author->getEmail());
eq(2,sizeof($xml->getEntry()));
foreach($xml->getEntry() as $entry){
assert(Variable::istype("AtomEntry03",$entry));
}
<feed version="0.3">
<title>atom03 feed</title>
<modified>2007-07-18T16:16:31+00:00</modified>
<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" />
<modified>2007-07-18T16:16:31+00:00</modified>
<issued>2007-07-18T16:16:31+00:00</issued>
<created>2007-07-18T16:16:31+00:00</created>
<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" />
<modified>2007-07-18T16:16:31+00:00</modified>
<issued>2007-07-18T16:16:31+00:00</issued>
<created>2007-07-18T16:16:31+00:00</created>
<id>django</id>
<author>
<url>http://www.everes.net</url>
<name>everes</name>
<email>everes@hoge.hoge</email>
</author>
</entry>
</feed>
__XML__;
$xml = new Atom03();
assert($xml->set($src));
eq("atom03 feed",$xml->getTitle());
eq("http://tokushimakazutaka.com",$xml->getLinkHref());
eq("2007-07-19T01:16:31+09:00",$xml->getModified());
$author = $xml->getAuthor();
eq("http://tokushimakazutaka.com",$author->getUrl());
eq("tokushima",$author->getName());
eq("tokushima@hoge.hoge",$author->getEmail());
eq(2,sizeof($xml->getEntry()));
foreach($xml->getEntry() as $entry){
assert(Variable::istype("AtomEntry03",$entry));
}
get [ # ]
フォーマットされた文字列を取得
@return string
@return string
$src = <<< __XML__
<feed version="0.3">
<title>atom03 feed</title>
<modified>2007-07-18T16:16:31+00:00</modified>
<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" />
<modified>2007-07-18T16:16:31+00:00</modified>
<issued>2007-07-18T16:16:31+00:00</issued>
<created>2007-07-18T16:16:31+00:00</created>
<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" />
<modified>2007-07-18T16:16:31+00:00</modified>
<issued>2007-07-18T16:16:31+00:00</issued>
<created>2007-07-18T16:16:31+00:00</created>
<id>django</id>
<author>
<url>http://www.everes.net</url>
<name>everes</name>
<email>everes@hoge.hoge</email>
</author>
</entry>
</feed>
__XML__;
$xml = new Atom03();
assert($xml->set($src));
$result = <<< __XML__
<feed version="0.3" xmlns="http://purl.org/atom/ns#">
<title>atom03 feed</title>
<modified>2007-07-19T01:16:31+09:00</modified>
<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" />
<id>rhaco</id>
<author><url>http://rhaco.org</url><name>rhaco</name><email>rhaco@rhaco.org</email></author>
<created>2007-07-19T01:16:31Z</created>
<modified>2007-07-19T01:16:31Z</modified>
<issued>2007-07-19T01:16:31+09:00</issued>
</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" />
<id>django</id>
<author><url>http://www.everes.net</url><name>everes</name><email>everes@hoge.hoge</email></author>
<created>2007-07-19T01:16:31Z</created>
<modified>2007-07-19T01:16:31Z</modified>
<issued>2007-07-19T01:16:31+09:00</issued>
</entry>
</feed>
__XML__;
$result = str_replace("\n","",$result);
eq($result,$xml->get());
<feed version="0.3">
<title>atom03 feed</title>
<modified>2007-07-18T16:16:31+00:00</modified>
<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" />
<modified>2007-07-18T16:16:31+00:00</modified>
<issued>2007-07-18T16:16:31+00:00</issued>
<created>2007-07-18T16:16:31+00:00</created>
<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" />
<modified>2007-07-18T16:16:31+00:00</modified>
<issued>2007-07-18T16:16:31+00:00</issued>
<created>2007-07-18T16:16:31+00:00</created>
<id>django</id>
<author>
<url>http://www.everes.net</url>
<name>everes</name>
<email>everes@hoge.hoge</email>
</author>
</entry>
</feed>
__XML__;
$xml = new Atom03();
assert($xml->set($src));
$result = <<< __XML__
<feed version="0.3" xmlns="http://purl.org/atom/ns#">
<title>atom03 feed</title>
<modified>2007-07-19T01:16:31+09:00</modified>
<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" />
<id>rhaco</id>
<author><url>http://rhaco.org</url><name>rhaco</name><email>rhaco@rhaco.org</email></author>
<created>2007-07-19T01:16:31Z</created>
<modified>2007-07-19T01:16:31Z</modified>
<issued>2007-07-19T01:16:31+09:00</issued>
</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" />
<id>django</id>
<author><url>http://www.everes.net</url><name>everes</name><email>everes@hoge.hoge</email></author>
<created>2007-07-19T01:16:31Z</created>
<modified>2007-07-19T01:16:31Z</modified>
<issued>2007-07-19T01:16:31+09:00</issued>
</entry>
</feed>
__XML__;
$result = str_replace("\n","",$result);
eq($result,$xml->get());
Atom10
<Atom>
Atom10 Model
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
set [ # ]
文字列からAtom10をセットする
@param string $src
@param string $src
unit("tag.feed.Atom10Test");
$src = <<< __XML__
<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__;
$xml = new Atom10();
assert($xml->set($src));
eq("atom10 feed",$xml->getTitle());
eq("atom10 sub title",$xml->getSubTitle());
eq("http://tokushimakazutaka.com",$xml->getLinkHref());
eq("2007-07-19T01:16:31Z",$xml->getUpdated());
eq("tokushima",$xml->getGenerator());
$author = $xml->getAuthor();
eq("http://tokushimakazutaka.com",$author->getUrl());
eq("tokushima",$author->getName());
eq("tokushima@hoge.hoge",$author->getEmail());
eq(2,sizeof($xml->getEntry()));
foreach($xml->getEntry() as $entry){
assert(Variable::istype("AtomEntry10",$entry));
}
$src = <<< __XML__
<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__;
$xml = new Atom10();
assert($xml->set($src));
eq("atom10 feed",$xml->getTitle());
eq("atom10 sub title",$xml->getSubTitle());
eq("http://tokushimakazutaka.com",$xml->getLinkHref());
eq("2007-07-19T01:16:31Z",$xml->getUpdated());
eq("tokushima",$xml->getGenerator());
$author = $xml->getAuthor();
eq("http://tokushimakazutaka.com",$author->getUrl());
eq("tokushima",$author->getName());
eq("tokushima@hoge.hoge",$author->getEmail());
eq(2,sizeof($xml->getEntry()));
foreach($xml->getEntry() as $entry){
assert(Variable::istype("AtomEntry10",$entry));
}
get [ # ]
フォーマットされた文字列を取得
@return string
@return string
unit("tag.feed.Atom10Test");
$src = <<< __XML__
<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__;
$xml = new Atom10();
assert($xml->set($src));
$result = <<< __XML__
<feed xmlns="http://www.w3.org/2005/Atom">
<title>atom10 feed</title>
<subtitle>atom10 sub title</subtitle>
<updated>2007-07-19T01:16:31Z</updated>
<link href="http://tokushimakazutaka.com" rel="abc" type="xyz" />
<generator>tokushima</generator>
<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" />
<id>rhaco</id>
<author><url>http://rhaco.org</url><name>rhaco</name><email>rhaco@rhaco.org</email></author>
<published>2007-07-19T01:16:31Z</published>
<updated>2007-07-19T01:16:31Z</updated>
<issued>2007-07-19T01:16:31Z</issued>
</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" />
<id>django</id>
<author><url>http://www.everes.net</url><name>everes</name><email>everes@hoge.hoge</email></author>
<published>2007-07-19T01:16:31Z</published>
<updated>2007-07-19T01:16:31Z</updated>
<issued>2007-07-19T01:16:31Z</issued>
</entry>
</feed>
__XML__;
$result = str_replace("\n","",$result);
eq($result,$xml->get());
$src = <<< __XML__
<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__;
$xml = new Atom10();
assert($xml->set($src));
$result = <<< __XML__
<feed xmlns="http://www.w3.org/2005/Atom">
<title>atom10 feed</title>
<subtitle>atom10 sub title</subtitle>
<updated>2007-07-19T01:16:31Z</updated>
<link href="http://tokushimakazutaka.com" rel="abc" type="xyz" />
<generator>tokushima</generator>
<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" />
<id>rhaco</id>
<author><url>http://rhaco.org</url><name>rhaco</name><email>rhaco@rhaco.org</email></author>
<published>2007-07-19T01:16:31Z</published>
<updated>2007-07-19T01:16:31Z</updated>
<issued>2007-07-19T01:16:31Z</issued>
</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" />
<id>django</id>
<author><url>http://www.everes.net</url><name>everes</name><email>everes@hoge.hoge</email></author>
<published>2007-07-19T01:16:31Z</published>
<updated>2007-07-19T01:16:31Z</updated>
<issued>2007-07-19T01:16:31Z</issued>
</entry>
</feed>
__XML__;
$result = str_replace("\n","",$result);
eq($result,$xml->get());
Rss
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
FeedParser
Feed解析クラス
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2006- rhaco project. All rights reserved.
read [ # ]
URLからFeedを取得しRSS20として取得
@static
@param string $url
@param int $time 現在時間-$time秒以内の更新を取得
@return tag.feed.Rss20
@static
@param string $url
@param int $time 現在時間-$time秒以内の更新を取得
@return tag.feed.Rss20
unit("tag.feed.FeedParserTest");
getItem [ # ]
URLからFeedを取得しRssItemをまとめたものを取得
@static
@param string/array $urls
@param int $time 現在時間-$time秒以内の更新を取得
@return array(tag.feed.model.RssItem20)
@static
@param string/array $urls
@param int $time 現在時間-$time秒以内の更新を取得
@return array(tag.feed.model.RssItem20)
unit("tag.feed.FeedParserTest");
parse [ # ]
文字列からtag.feed.Rss20にセットする
@static
@param string $src
@return tag.feed.Rss20
@static
@param string $src
@return tag.feed.Rss20
unit("tag.feed.FeedParserTest");
alternateUrl [ # ]
URLまたは文字列からFeed URLを取得する
@static
@param string $baseurl
@param string $src
@return string
@static
@param string $baseurl
@param string $src
@return string
$html = <<< __HTML__
<html>
<head>
<link rel="alternate" type="application/rss+xml" href="rss" />
<link rel="alternate" type="application/rss+xml" href="http://rhaco.org/rss.rdf" />
<link rel="alternate" type="application/atom+xml" href="http://rhaco.org/atom" />
</head>
<body>
</body>
</html>
__HTML__;
eq("http://rhaco.org/rss",FeedParser::alternateUrl("http://rhaco.org/",$html));
<html>
<head>
<link rel="alternate" type="application/rss+xml" href="rss" />
<link rel="alternate" type="application/rss+xml" href="http://rhaco.org/rss.rdf" />
<link rel="alternate" type="application/atom+xml" href="http://rhaco.org/atom" />
</head>
<body>
</body>
</html>
__HTML__;
eq("http://rhaco.org/rss",FeedParser::alternateUrl("http://rhaco.org/",$html));
Atom
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
Rss09
<Rss>
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
set [ # ]
文字列からRss09をセットする
@param string $src
@param string $src
$src = <<< __XML__
<rss version="0.91">
<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>
<skipDays>
<day>1</day>
<day>20</day>
</skipDays>
<skipHours>
<hour>2</hour>
<hour>10</hour>
</skipHours>
<image><title>rhaco</title><link>http://rhaco.org</link><url>http://rhaco.org</url><width>100</width><height>200</height></image>
<image><title>everes</title><link>http://www.everes.net</link><url>http://everes.net</url><width>100</width><height>200</height></image>
<textinput><title>rhaco</title><name>tokushima</name><link>http://rhaco.org</link><description>rhaco desc</description></textinput>
<textinput><title>everes</title><name>tsuyuki</name><link>http://www.everes.net</link><description>everes desc</description></textinput>
<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__;
$feed = new Rss09();
assert($feed->set($src));
$xml = $feed->getChannel();
eq("rhaco",$xml->getTitle());
eq("http://rhaco.org",$xml->getLink());
eq("php",$xml->getDescription());
eq("ja",$xml->getLanguage());
eq("rhaco.org",$xml->getCopyright());
eq("hogehoge",$xml->getDocs());
eq("2007-10-10T10:10:10+09:00",$xml->getLastBuildDate());
eq("tokushima",$xml->getManagingEditor());
eq("2007-10-10T10:10:10+09:00",$xml->getPubDate());
eq("kazutaka",$xml->getWebMaster());
eq(2,sizeof($xml->getImage()));
foreach($xml->getImage() as $data){
assert(Variable::istype("RssImage09",$data));
}
eq(2,sizeof($xml->getTextInput()));
foreach($xml->getTextInput() as $data){
assert(Variable::istype("RssTextinput",$data));
}
eq(2,sizeof($xml->getItem()));
foreach($xml->getItem() as $data){
assert(Variable::istype("RssItem",$data));
}
eq(2,sizeof($xml->getSkipDays()));
eq(2,sizeof($xml->getSkipHours()));
<rss version="0.91">
<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>
<skipDays>
<day>1</day>
<day>20</day>
</skipDays>
<skipHours>
<hour>2</hour>
<hour>10</hour>
</skipHours>
<image><title>rhaco</title><link>http://rhaco.org</link><url>http://rhaco.org</url><width>100</width><height>200</height></image>
<image><title>everes</title><link>http://www.everes.net</link><url>http://everes.net</url><width>100</width><height>200</height></image>
<textinput><title>rhaco</title><name>tokushima</name><link>http://rhaco.org</link><description>rhaco desc</description></textinput>
<textinput><title>everes</title><name>tsuyuki</name><link>http://www.everes.net</link><description>everes desc</description></textinput>
<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__;
$feed = new Rss09();
assert($feed->set($src));
$xml = $feed->getChannel();
eq("rhaco",$xml->getTitle());
eq("http://rhaco.org",$xml->getLink());
eq("php",$xml->getDescription());
eq("ja",$xml->getLanguage());
eq("rhaco.org",$xml->getCopyright());
eq("hogehoge",$xml->getDocs());
eq("2007-10-10T10:10:10+09:00",$xml->getLastBuildDate());
eq("tokushima",$xml->getManagingEditor());
eq("2007-10-10T10:10:10+09:00",$xml->getPubDate());
eq("kazutaka",$xml->getWebMaster());
eq(2,sizeof($xml->getImage()));
foreach($xml->getImage() as $data){
assert(Variable::istype("RssImage09",$data));
}
eq(2,sizeof($xml->getTextInput()));
foreach($xml->getTextInput() as $data){
assert(Variable::istype("RssTextinput",$data));
}
eq(2,sizeof($xml->getItem()));
foreach($xml->getItem() as $data){
assert(Variable::istype("RssItem",$data));
}
eq(2,sizeof($xml->getSkipDays()));
eq(2,sizeof($xml->getSkipHours()));
get [ # ]
フォーマットされた文字列を取得
@return string
@return string
$src = <<< __XML__
<rss version="0.91">
<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>
<skipDays>
<day>1</day>
<day>20</day>
</skipDays>
<skipHours>
<hour>2</hour>
<hour>10</hour>
</skipHours>
<image><title>rhaco</title><link>http://rhaco.org</link><url>http://rhaco.org</url><width>100</width><height>200</height></image>
<image><title>everes</title><link>http://www.everes.net</link><url>http://everes.net</url><width>100</width><height>200</height></image>
<textinput><title>rhaco</title><name>tokushima</name><link>http://rhaco.org</link><description>rhaco desc</description></textinput>
<textinput><title>everes</title><name>tsuyuki</name><link>http://www.everes.net</link><description>everes desc</description></textinput>
<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__;
$xml = new Rss09();
assert($xml->set($src));
$doc = "<!DOCTYPE rss PUBLIC __DQUOTE__-//Netscape Communications//DTD RSS 0.91//EN__DQUOTE__ __DQUOTE__http://my.netscape.com/publish/formats/rss-0.91.dtd__DQUOTE__>";
eq($doc."\n".str_replace("\n","",$src),$xml->get());
<rss version="0.91">
<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>
<skipDays>
<day>1</day>
<day>20</day>
</skipDays>
<skipHours>
<hour>2</hour>
<hour>10</hour>
</skipHours>
<image><title>rhaco</title><link>http://rhaco.org</link><url>http://rhaco.org</url><width>100</width><height>200</height></image>
<image><title>everes</title><link>http://www.everes.net</link><url>http://everes.net</url><width>100</width><height>200</height></image>
<textinput><title>rhaco</title><name>tokushima</name><link>http://rhaco.org</link><description>rhaco desc</description></textinput>
<textinput><title>everes</title><name>tsuyuki</name><link>http://www.everes.net</link><description>everes desc</description></textinput>
<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__;
$xml = new Rss09();
assert($xml->set($src));
$doc = "<!DOCTYPE rss PUBLIC __DQUOTE__-//Netscape Communications//DTD RSS 0.91//EN__DQUOTE__ __DQUOTE__http://my.netscape.com/publish/formats/rss-0.91.dtd__DQUOTE__>";
eq($doc."\n".str_replace("\n","",$src),$xml->get());
Rss10
<Rss>
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
get [ # ]
フォーマットされた文字列を取得
@return string
@return string
$src = <<< __XML__
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/">
<channel rdf:about="http://rhacoorg">
<title>rhaco</title>
<link>http://rhaco.org</link>
<description>php</description>
<image rdf:resource="hogeimage1" />
<image rdf:resource="hogeimage2" />
<textinput rdf:resource="text1" />
<textinput rdf:resource="text2" />
<items>
<rdf:Seq>
<rdf:li rdf:resource="http://rhaco.org" />
<rdf:li rdf:resource="http://everes.net" />
</rdf:Seq>
</items>
</channel>
<image rdf:about="hogeimage1"><title>rhaco</title><link>http://rhaco.org</link><url>http://rhaco.org</url></image>
<image rdf:about="hogeimage2"><title>rhaco</title><link>http://rhaco.org</link><url>http://rhaco.org</url></image>
<textinput rdf:about="text1"><title>rhaco</title><name>tokushima</name><link>http://rhaco.org</link><description>rhaco desc</description></textinput>
<textinput rdf:about="text2"><title>rhaco</title><name>tokushima</name><link>http://rhaco.org</link><description>rhaco desc</description></textinput>
<item rdf:about="http://rhaco.org">
<title>rhaco</title><link>http://rhaco.org</link><description>rhaco desc</description>
<dc:subject>rhaco</dc:subject>
<dc:creator>tokushima</dc:creator>
<dc:date>2007-07-19T01:16:31+09:00</dc:date>
</item>
<item rdf:about="http://everes.net">
<title>rhaco</title><link>http://rhaco.org</link><description>rhaco desc</description>
<dc:subject>rhaco</dc:subject>
<dc:creator>tokushima</dc:creator>
<dc:date>2007-07-19T01:16:31+09:00</dc:date>
</item>
</rdf:RDF>
__XML__;
$feed = new Rss10();
assert($feed->set($src));
eq(str_replace(array("\t","\n"),array("",""),$src),$feed->get(),"src");
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/">
<channel rdf:about="http://rhacoorg">
<title>rhaco</title>
<link>http://rhaco.org</link>
<description>php</description>
<image rdf:resource="hogeimage1" />
<image rdf:resource="hogeimage2" />
<textinput rdf:resource="text1" />
<textinput rdf:resource="text2" />
<items>
<rdf:Seq>
<rdf:li rdf:resource="http://rhaco.org" />
<rdf:li rdf:resource="http://everes.net" />
</rdf:Seq>
</items>
</channel>
<image rdf:about="hogeimage1"><title>rhaco</title><link>http://rhaco.org</link><url>http://rhaco.org</url></image>
<image rdf:about="hogeimage2"><title>rhaco</title><link>http://rhaco.org</link><url>http://rhaco.org</url></image>
<textinput rdf:about="text1"><title>rhaco</title><name>tokushima</name><link>http://rhaco.org</link><description>rhaco desc</description></textinput>
<textinput rdf:about="text2"><title>rhaco</title><name>tokushima</name><link>http://rhaco.org</link><description>rhaco desc</description></textinput>
<item rdf:about="http://rhaco.org">
<title>rhaco</title><link>http://rhaco.org</link><description>rhaco desc</description>
<dc:subject>rhaco</dc:subject>
<dc:creator>tokushima</dc:creator>
<dc:date>2007-07-19T01:16:31+09:00</dc:date>
</item>
<item rdf:about="http://everes.net">
<title>rhaco</title><link>http://rhaco.org</link><description>rhaco desc</description>
<dc:subject>rhaco</dc:subject>
<dc:creator>tokushima</dc:creator>
<dc:date>2007-07-19T01:16:31+09:00</dc:date>
</item>
</rdf:RDF>
__XML__;
$feed = new Rss10();
assert($feed->set($src));
eq(str_replace(array("\t","\n"),array("",""),$src),$feed->get(),"src");
Rss20
<Rss>
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
set [ # ]
文字列からRss20をセットする
@param string $src
@param string $src
unit("tag.feed.Rss20Test");
$src = <<< __XML__
<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>
<skipDays>
<day>1</day>
<day>20</day>
</skipDays>
<skipHours>
<hour>2</hour>
<hour>10</hour>
</skipHours>
<image><title>rhaco</title><link>http://rhaco.org</link><url>http://rhaco.org</url><width>100</width><height>200</height></image>
<image><title>everes</title><link>http://www.everes.net</link><url>http://everes.net</url><width>100</width><height>200</height></image>
<textinput><title>rhaco</title><name>tokushima</name><link>http://rhaco.org</link><description>rhaco desc</description></textinput>
<textinput><title>everes</title><name>tsuyuki</name><link>http://www.everes.net</link><description>everes desc</description></textinput>
<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>
<cloud domain="http://rhaco.org" port="80" protocol="http" path="/" />
</channel>
</rss>
__XML__;
$feed = new Rss20();
assert($feed->set($src));
eq("2.0",$feed->getVersion());
$xml = $feed->getChannel();
eq("rhaco",$xml->getTitle());
eq("http://rhaco.org",$xml->getLink());
eq("php",$xml->getDescription());
eq("ja",$xml->getLanguage());
eq("rhaco.org",$xml->getCopyright());
eq("hogehoge",$xml->getDocs());
eq("2007-10-10T10:10:10+09:00",$xml->getLastBuildDate());
eq("tokushima",$xml->getManagingEditor());
eq("2007-10-10T10:10:10+09:00",$xml->getPubDate());
eq("kazutaka",$xml->getWebMaster());
eq(2,sizeof($xml->getImage()));
foreach($xml->getImage() as $data){
assert(Variable::istype("RssImage09",$data));
}
eq(2,sizeof($xml->getTextInput()));
foreach($xml->getTextInput() as $data){
assert(Variable::istype("RssTextinput",$data));
}
eq(2,sizeof($xml->getItem()));
foreach($xml->getItem() as $data){
assert(Variable::istype("RssItem20",$data));
}
eq(2,sizeof($xml->getSkipDays()));
eq(2,sizeof($xml->getSkipHours()));
assert(Variable::istype("RssCloud",$xml->getCloud()));
$src = <<< __XML__
<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>
<skipDays>
<day>1</day>
<day>20</day>
</skipDays>
<skipHours>
<hour>2</hour>
<hour>10</hour>
</skipHours>
<image><title>rhaco</title><link>http://rhaco.org</link><url>http://rhaco.org</url><width>100</width><height>200</height></image>
<image><title>everes</title><link>http://www.everes.net</link><url>http://everes.net</url><width>100</width><height>200</height></image>
<textinput><title>rhaco</title><name>tokushima</name><link>http://rhaco.org</link><description>rhaco desc</description></textinput>
<textinput><title>everes</title><name>tsuyuki</name><link>http://www.everes.net</link><description>everes desc</description></textinput>
<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>
<cloud domain="http://rhaco.org" port="80" protocol="http" path="/" />
</channel>
</rss>
__XML__;
$feed = new Rss20();
assert($feed->set($src));
eq("2.0",$feed->getVersion());
$xml = $feed->getChannel();
eq("rhaco",$xml->getTitle());
eq("http://rhaco.org",$xml->getLink());
eq("php",$xml->getDescription());
eq("ja",$xml->getLanguage());
eq("rhaco.org",$xml->getCopyright());
eq("hogehoge",$xml->getDocs());
eq("2007-10-10T10:10:10+09:00",$xml->getLastBuildDate());
eq("tokushima",$xml->getManagingEditor());
eq("2007-10-10T10:10:10+09:00",$xml->getPubDate());
eq("kazutaka",$xml->getWebMaster());
eq(2,sizeof($xml->getImage()));
foreach($xml->getImage() as $data){
assert(Variable::istype("RssImage09",$data));
}
eq(2,sizeof($xml->getTextInput()));
foreach($xml->getTextInput() as $data){
assert(Variable::istype("RssTextinput",$data));
}
eq(2,sizeof($xml->getItem()));
foreach($xml->getItem() as $data){
assert(Variable::istype("RssItem20",$data));
}
eq(2,sizeof($xml->getSkipDays()));
eq(2,sizeof($xml->getSkipHours()));
assert(Variable::istype("RssCloud",$xml->getCloud()));
get [ # ]
フォーマットされた文字列を取得
@return string
@return string
unit("tag.feed.Rss20Test");
$src = <<< __XML__
<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>
<skipDays>
<day>1</day>
<day>20</day>
</skipDays>
<skipHours>
<hour>2</hour>
<hour>10</hour>
</skipHours>
<image><title>rhaco</title><link>http://rhaco.org</link><url>http://rhaco.org</url><width>100</width><height>200</height></image>
<image><title>everes</title><link>http://www.everes.net</link><url>http://everes.net</url><width>100</width><height>200</height></image>
<textinput><title>rhaco</title><name>tokushima</name><link>http://rhaco.org</link><description>rhaco desc</description></textinput>
<textinput><title>everes</title><name>tsuyuki</name><link>http://www.everes.net</link><description>everes desc</description></textinput>
<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>
<cloud domain="http://rhaco.org" port="80" protocol="http" path="/" />
</channel>
</rss>
__XML__;
$xml = new Rss20();
assert($xml->set($src));
eq(str_replace("\n","",$src),$xml->get());
$src = <<< __XML__
<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>
<skipDays>
<day>1</day>
<day>20</day>
</skipDays>
<skipHours>
<hour>2</hour>
<hour>10</hour>
</skipHours>
<image><title>rhaco</title><link>http://rhaco.org</link><url>http://rhaco.org</url><width>100</width><height>200</height></image>
<image><title>everes</title><link>http://www.everes.net</link><url>http://everes.net</url><width>100</width><height>200</height></image>
<textinput><title>rhaco</title><name>tokushima</name><link>http://rhaco.org</link><description>rhaco desc</description></textinput>
<textinput><title>everes</title><name>tsuyuki</name><link>http://www.everes.net</link><description>everes desc</description></textinput>
<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>
<cloud domain="http://rhaco.org" port="80" protocol="http" path="/" />
</channel>
</rss>
__XML__;
$xml = new Rss20();
assert($xml->set($src));
eq(str_replace("\n","",$src),$xml->get());
SimpleTagParameter
tag.model.SimpleTagで利用するパラメータクラス
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
SimpleTag
タグ Model
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
@author Kazutaka Tokushima
@license New BSD License
@copyright Copyright 2005- rhaco project. All rights reserved.
set [ # ]
文字列からSimpleTagをセットする
$normalizationは対象の構成によっては著しくパフォーマンスがおちます。
@param string $plain
@param string $name
@param boolean $normalization
@return boolean
$normalizationは対象の構成によっては著しくパフォーマンスがおちます。
@param string $plain
@param string $name
@param boolean $normalization
@return boolean
$tag = new SimpleTag();
assert($tag->set("<hoge />","hoge"));
assert($tag->set("<hoge /><hoge />","hoge"));
eq("<hoge />",$tag->getPlain());
assert($tag->set("<xyz /><hoge><abc /><bbc>news</bbc></hoge>","hoge"));
eq("<hoge><abc /><bbc>news</bbc></hoge>",$tag->getPlain());
assert($tag->set("<hoge><hoge></hoge></hoge>","hoge"));
assert($tag->set("<hoge><hoge /></hoge>","hoge"));
assert($tag->set("<outline><outline xmlUrl=__DQUOTE__hoge__DQUOTE__ /></outline>","outline"));
assert($tag->set("<outline xmlUrl=__DQUOTE__hoge__DQUOTE__ /></outline>","outline"));
assert($tag->set("<outline xmlUrl=__DQUOTE__ho/ge__DQUOTE__>aa</outline>","outline"));
eq("ho/ge",$tag->getParameter("xmlUrl"));
assert($tag->set("<outline xmlUrl=__DQUOTE__ho/ge__DQUOTE__ /></outline>","outline"));
eq("ho/ge",$tag->getParameter("xmlUrl"));
// <outline xmlUrl=__DQUOTE__ho/>
assert($tag->set("<outline xmlUrl=__DQUOTE__ho/>ge__DQUOTE__>aa</outline>","outline"));
eq("xmlUrl",$tag->getAttribute("xmlUrl"));
eq("ho",$tag->getAttribute("ho"));
assert($tag->set("<outline xmlUrl=__DQUOTE__ho/>ge__DQUOTE__>aa</outline>","outline",true));
eq("ho/>ge",$tag->getParameter("xmlUrl"),"normalization");
assert($tag->set("<outline xmlUrl=__DQUOTE__ho__QUOTE__ge__DQUOTE__>aa</outline>","outline",true));
eq("ho__QUOTE__ge",$tag->getParameter("xmlUrl"));
assert($tag->set("<outline xmlUrl=__DQUOTE__ho\\__DQUOTE__ge__DQUOTE__>aa</outline>","outline",true));
eq("ho\\__DQUOTE__ge",$tag->getParameter("xmlUrl"));
assert($tag->set("<opml hoge=__DQUOTE__<outline __DQUOTE__><outline xmlUrl=__DQUOTE__ho<ge__DQUOTE__>aa</outline>","outline",true));
eq("ho<ge",$tag->getParameter("xmlUrl"));
assert($tag->set("<hoge />","hoge"));
assert($tag->set("<hoge /><hoge />","hoge"));
eq("<hoge />",$tag->getPlain());
assert($tag->set("<xyz /><hoge><abc /><bbc>news</bbc></hoge>","hoge"));
eq("<hoge><abc /><bbc>news</bbc></hoge>",$tag->getPlain());
assert($tag->set("<hoge><hoge></hoge></hoge>","hoge"));
assert($tag->set("<hoge><hoge /></hoge>","hoge"));
assert($tag->set("<outline><outline xmlUrl=__DQUOTE__hoge__DQUOTE__ /></outline>","outline"));
assert($tag->set("<outline xmlUrl=__DQUOTE__hoge__DQUOTE__ /></outline>","outline"));
assert($tag->set("<outline xmlUrl=__DQUOTE__ho/ge__DQUOTE__>aa</outline>","outline"));
eq("ho/ge",$tag->getParameter("xmlUrl"));
assert($tag->set("<outline xmlUrl=__DQUOTE__ho/ge__DQUOTE__ /></outline>","outline"));
eq("ho/ge",$tag->getParameter("xmlUrl"));
// <outline xmlUrl=__DQUOTE__ho/>
assert($tag->set("<outline xmlUrl=__DQUOTE__ho/>ge__DQUOTE__>aa</outline>","outline"));
eq("xmlUrl",$tag->getAttribute("xmlUrl"));
eq("ho",$tag->getAttribute("ho"));
assert($tag->set("<outline xmlUrl=__DQUOTE__ho/>ge__DQUOTE__>aa</outline>","outline",true));
eq("ho/>ge",$tag->getParameter("xmlUrl"),"normalization");
assert($tag->set("<outline xmlUrl=__DQUOTE__ho__QUOTE__ge__DQUOTE__>aa</outline>","outline",true));
eq("ho__QUOTE__ge",$tag->getParameter("xmlUrl"));
assert($tag->set("<outline xmlUrl=__DQUOTE__ho\\__DQUOTE__ge__DQUOTE__>aa</outline>","outline",true));
eq("ho\\__DQUOTE__ge",$tag->getParameter("xmlUrl"));
assert($tag->set("<opml hoge=__DQUOTE__<outline __DQUOTE__><outline xmlUrl=__DQUOTE__ho<ge__DQUOTE__>aa</outline>","outline",true));
eq("ho<ge",$tag->getParameter("xmlUrl"));
setof [ # ]
staticにSimpleTag::setを行う
$varにsetされたSimpleTagインスタンスが入ります。
$normalizationはparameterがクオートされてない等を補正する
$normalizationは対象の構成によっては著しくパフォーマンスがおちます。
@static
@param unknown_type $var
@param string $plain
@param string $name
@param boolea $normalization
@return boolean
$varにsetされたSimpleTagインスタンスが入ります。
$normalizationはparameterがクオートされてない等を補正する
$normalizationは対象の構成によっては著しくパフォーマンスがおちます。
@static
@param unknown_type $var
@param string $plain
@param string $name
@param boolea $normalization
@return boolean
$xml = "<tag><xyz /><hoge><abc /><bbc>news</bbc></hoge></tag>";
$result = SimpleTag::setof($tag,$xml,"tag");
eq(true,$result);
assert(Variable::istype("SimpleTag",$tag));
$xml = "<tag><xyz /><hoge><abc /><bbc>news</bbc></hoge></tag>";
$result = SimpleTag::setof($tag,$xml,"gen");
eq(false,$result);
eq(null,$tag);
$result = SimpleTag::setof($tag,$xml,"tag");
eq(true,$result);
assert(Variable::istype("SimpleTag",$tag));
$xml = "<tag><xyz /><hoge><abc /><bbc>news</bbc></hoge></tag>";
$result = SimpleTag::setof($tag,$xml,"gen");
eq(false,$result);
eq(null,$tag);
anyhow [ # ]
適当な名前でとにかくSimpleTagにする
@param unknown_type $var
@param anyhow $plain
@param unknown_type $var
@param anyhow $plain
$xml = "<abc>hoge1</abc><abc>hoge2</abc><abc>hoge3</abc>";
$tag = SimpleTag::anyhow($xml);
assert(Variable::istype("SimpleTag",$tag));
eq(3,sizeof($tag->getIn("abc")));
$tag = SimpleTag::anyhow($xml);
assert(Variable::istype("SimpleTag",$tag));
eq(3,sizeof($tag->getIn("abc")));
get [ # ]
フォーマットされた文字列を取得
@param booelan $isDec XML宣言を追加する
@return string
@param booelan $isDec XML宣言を追加する
@return string
$tag = new SimpleTag("data","hogehoge",array("abc"=>123,"def"=>"xyz"));
eq('<data abc="123" def=__REP__43__>hogehoge</data>',$tag->get());
$tag = new SimpleTag("data",null,array("abc"=>123,"def"=>"xyz"));
eq('<data abc="123" def=__REP__43__ />',$tag->get());
eq('<data abc="123" def=__REP__43__>hogehoge</data>',$tag->get());
$tag = new SimpleTag("data",null,array("abc"=>123,"def"=>"xyz"));
eq('<data abc="123" def=__REP__43__ />',$tag->get());
removeParameter [ # ]
パラメータを削除する
@param string $name
@param string $name
$xml = "<tag frog='guwa'><abc>123</abc></tag>";
SimpleTag::setof($tag,$xml,"tag");
$tag->removeParameter("frog");
eq("<tag><abc>123</abc></tag>",$tag->get());
SimpleTag::setof($tag,$xml,"tag");
$tag->removeParameter("frog");
eq("<tag><abc>123</abc></tag>",$tag->get());
removeAttribute [ # ]
アトリビュートを削除する
@param string $name
@param string $name
$tag = new SimpleTag("tag");
$tag->setAttribute("default");
eq('<tag default />',$tag->get());
$tag->removeAttribute("default");
eq('<tag />',$tag->get());
$tag->setAttribute("default");
eq('<tag default />',$tag->get());
$tag->removeAttribute("default");
eq('<tag />',$tag->get());
getIn [ # ]
value内のarray(tag.model.SimpleTag)を取得する
@param string $tagName
@param boolean $extraction 取得したtag.model.SimpleTagをvalueから削除するか
@return array(tag.model.SimpleTag)
@param string $tagName
@param boolean $extraction 取得したtag.model.SimpleTagをvalueから削除するか
@return array(tag.model.SimpleTag)
$src = "<tag><a b='1' /><a>abc</a><b>0</b><a b='1' /><a /></tag>";
$list = array();
if(SimpleTag::setof($tag,$src,"tag")){
foreach($tag->getIn("a") as $a){
eq("a",$a->getName());
$list[] = $a;
}
}
eq(4,sizeof($list));
SimpleTag::setof($tag,"<opml><outline><outline xmlUrl=__DQUOTE__hoge__DQUOTE__ /></outline></opml>","opml");
eq(1,sizeof($tag->getIn("outline")),"opml outline");
SimpleTag::setof($tag,"<tag><data1 /><data2 /><data1 /><data3 /><data3 /><data2 /><data4 /></tag>","tag");
$result = $tag->getIn("data2",true);
eq("<data1 /><data1 /><data3 /><data3 /><data4 />",$tag->getValue());
eq("<tag><data1 /><data1 /><data3 /><data3 /><data4 /></tag>",$tag->getPlain());
eq(2,sizeof($result));
SimpleTag::setof($tag,"<tag><data1 /><data2 /><data1 /><data3 /><data3 /><data2 /><data4 /></tag>","tag");
$result = $tag->getIn(array("data2","data3"));
eq("data2",$result[0]->getName());
eq("data3",$result[1]->getName());
eq("data3",$result[2]->getName());
eq("data2",$result[3]->getName());
SimpleTag::setof($tag,"<tag><data1 /><data2 /><data1 /><data3 /><data3 /><data2 /><data4 /></tag>","tag");
$result = $tag->getIn(array("data2","data3"),true);
eq("<tag><data1 /><data1 /><data4 /></tag>",$tag->getPlain());
eq("<data1 /><data1 /><data4 />",$tag->getValue());
$src = "<tag><abc><def var='123'><ghi>aaa</ghi><ghi>bbb</ghi><ghi>ccc</ghi></def></abc></tag>";
SimpleTag::setof($tag,$src,"tag");
$tags = $tag->getIn("ghi",true,1,1);
if(assert(isset($tags[0]))){
eq("<ghi>bbb</ghi>",$tags[0]->getPlain());
eq("<tag><abc><def var='123'><ghi>aaa</ghi><ghi>ccc</ghi></def></abc></tag>",$tag->getPlain());
}
$html = '<html><input type="hidden" value="test > hogehoge" /><input type="hidden" value="test < hogehoge" /><input type="hidden" value="test > __DQUOTE__hogehoge__DQUOTE__" /></html>';
if(SimpleTag::setof($tag,$html,"html",true)){
$inputs = $tag->getIn("input");
eq(3,sizeof($inputs));
eq("test > hogehoge",$inputs[0]->getParameter("value"));
eq("test < hogehoge",$inputs[1]->getParameter("value"));
eq("test > \\__DQUOTE__hogehoge\\__DQUOTE__",$inputs[2]->getParameter("value"));
}
$html = <<< __HDOC__
<div>aaaa</div>
<div style="background: url(http://example.jp/example.png);">bbbb</div>
<div>cccc</div>
__HDOC__;
SimpleTag::setof($tag, '<div>'.$html.'</div>', 'div');
$divs = $tag->getIn('div');
eq(3, count($divs),"DIV SLASH");
SimpleTag::setof($tag, '<body>'.$html.'</body>', 'body');
$divs = $tag->getIn('div');
eq(3, count($divs));
$html = <<< __HDOC__
<div>aaaa</div>
<div>bbbb</div>
<div>cccc</div>
__HDOC__;
SimpleTag::setof($tag, '<div>'.$html.'</div>', 'div');
$divs = $tag->getIn('div');
eq(3, count($divs),"DIV simple");
$list = array();
if(SimpleTag::setof($tag,$src,"tag")){
foreach($tag->getIn("a") as $a){
eq("a",$a->getName());
$list[] = $a;
}
}
eq(4,sizeof($list));
SimpleTag::setof($tag,"<opml><outline><outline xmlUrl=__DQUOTE__hoge__DQUOTE__ /></outline></opml>","opml");
eq(1,sizeof($tag->getIn("outline")),"opml outline");
SimpleTag::setof($tag,"<tag><data1 /><data2 /><data1 /><data3 /><data3 /><data2 /><data4 /></tag>","tag");
$result = $tag->getIn("data2",true);
eq("<data1 /><data1 /><data3 /><data3 /><data4 />",$tag->getValue());
eq("<tag><data1 /><data1 /><data3 /><data3 /><data4 /></tag>",$tag->getPlain());
eq(2,sizeof($result));
SimpleTag::setof($tag,"<tag><data1 /><data2 /><data1 /><data3 /><data3 /><data2 /><data4 /></tag>","tag");
$result = $tag->getIn(array("data2","data3"));
eq("data2",$result[0]->getName());
eq("data3",$result[1]->getName());
eq("data3",$result[2]->getName());
eq("data2",$result[3]->getName());
SimpleTag::setof($tag,"<tag><data1 /><data2 /><data1 /><data3 /><data3 /><data2 /><data4 /></tag>","tag");
$result = $tag->getIn(array("data2","data3"),true);
eq("<tag><data1 /><data1 /><data4 /></tag>",$tag->getPlain());
eq("<data1 /><data1 /><data4 />",$tag->getValue());
$src = "<tag><abc><def var='123'><ghi>aaa</ghi><ghi>bbb</ghi><ghi>ccc</ghi></def></abc></tag>";
SimpleTag::setof($tag,$src,"tag");
$tags = $tag->getIn("ghi",true,1,1);
if(assert(isset($tags[0]))){
eq("<ghi>bbb</ghi>",$tags[0]->getPlain());
eq("<tag><abc><def var='123'><ghi>aaa</ghi><ghi>ccc</ghi></def></abc></tag>",$tag->getPlain());
}
$html = '<html><input type="hidden" value="test > hogehoge" /><input type="hidden" value="test < hogehoge" /><input type="hidden" value="test > __DQUOTE__hogehoge__DQUOTE__" /></html>';
if(SimpleTag::setof($tag,$html,"html",true)){
$inputs = $tag->getIn("input");
eq(3,sizeof($inputs));
eq("test > hogehoge",$inputs[0]->getParameter("value"));
eq("test < hogehoge",$inputs[1]->getParameter("value"));
eq("test > \\__DQUOTE__hogehoge\\__DQUOTE__",$inputs[2]->getParameter("value"));
}
$html = <<< __HDOC__
<div>aaaa</div>
<div style="background: url(http://example.jp/example.png);">bbbb</div>
<div>cccc</div>
__HDOC__;
SimpleTag::setof($tag, '<div>'.$html.'</div>', 'div');
$divs = $tag->getIn('div');
eq(3, count($divs),"DIV SLASH");
SimpleTag::setof($tag, '<body>'.$html.'</body>', 'body');
$divs = $tag->getIn('div');
eq(3, count($divs));
$html = <<< __HDOC__
<div>aaaa</div>
<div>bbbb</div>
<div>cccc</div>
__HDOC__;
SimpleTag::setof($tag, '<div>'.$html.'</div>', 'div');
$divs = $tag->getIn('div');
eq(3, count($divs),"DIV simple");
getInValue [ # ]
value内のarray(tag.model.SimpleTag)をフォーマットした文字列を取得
@param string $tagName
@param string $default
@return string
@param string $tagName
@param string $default
@return string
$tag = new SimpleTag("hoge","<hogehoge>rhaco</hogehoge><hogehoge>django</hogehoge>");
eq("rhaco",$tag->getInValue("hogehoge"));
eq(null,$tag->getInValue("ruru"));
eq("aid",$tag->getInValue("ruru","aid"));
eq("rhaco",$tag->getInValue("hogehoge"));
eq(null,$tag->getInValue("ruru"));
eq("aid",$tag->getInValue("ruru","aid"));
f [ # ]
文字列により取得する
@param string $path
@param unknown_type $default
@return unknown
@param string $path
@param unknown_type $default
@return unknown
$tmp
$src = "<tag><abc><def var='123'><ghi selected>hoge</ghi></def></abc></tag>";
SimpleTag::setof($tag,$src,"tag");
eq("hoge",$tag->f("abc.def.ghi.value()"));
eq("123",$tag->f("abc.def.param('var')"));
eq("selected",$tag->f("abc.def.ghi.attr('selected')"));
eq("<def var='123'><ghi selected>hoge</ghi></def>",$tag->f("abc.def.plain()"));
eq("",$tag->f("abc.def.xyz"));
eq("rhaco",$tag->f("abc.def.xyz","rhaco"));
$src = "<tag><abc><def var='123'>".
"<ghi selected>hoge</ghi>".
"<ghi>".
"<jkl>rails</jkl>".
"</ghi>".
"<ghi>django</ghi>".
"</def></abc></tag>";
SimpleTag::setof($tag,$src,"tag");
eq("django",$tag->f("abc.def.ghi[2].value()"));
eq("rails",$tag->f("abc.def.ghi[1].jkl.value()"));
eq("",$tag->f("abc.def.ghi.jkl.value()"));
$src = "<tag><abc><def var='123'>".
"<def><ghi selected>DRY</ghi></def>".
"<def><def>".
"<ghi>setup framework</ghi>".
"</def></def>".
"<ghi>and library</ghi>".
"</def></abc></tag>";
SimpleTag::setof($tag,$src,"tag");
eq("setup framework",$tag->f("abc.def.def[1].def.ghi.value()"));
eq("setup framework",$tag->f("abc.def.def[1].ghi.value()"));
eq("setup framework",$tag->f("def.def[1].ghi.value()"));
eq("",$tag->f("def[1].ghi.value()"));
eq("",$tag->f("abc.def.def.def.ghi.value()"));
eq(1,count($tag->f("in(def)")));
eq(2,count($tag->f("def.in(def)")));
eq(3,count($tag->f("in(ghi)")));
$src = <<< __XML__
<tag>
<abc>
<def type='unknown' selected>hoge</def>
<def><jkl>is</jkl></def>
<ghi>hentai++</ghi>
</abc>
</tag>
__XML__;
SimpleTag::setof($tag,$src,"tag");
$def = $tag->f("abc.in(def)");
eq(2,count($def));
eq($tag->f("abc.def"),$def[0]);
$ghi = $tag->f("abc.in(ghi)");
assert(V::istype("SimpleTag",$ghi[0]));
eq("hentai++",$ghi[0]->getValue());
eq("",$tag->f("abc.mno"));
neq($tag->f("abc.def[1].jkl"),$tag->f("jkl")); //posだけ違う
eq($tag->f("abc.def[1].jkl.value()"),$tag->f("jkl.value()"));
neq($tag->f("abc.jkl"),$tag->f("jkl")); //posだけ違う
eq($tag->f("abc.jkl.value()"),$tag->f("jkl.value()"));
neq($tag->f("abc.def[1].in(jkl)"),$tag->f("in(jkl)"));//posだけ違う
$tag->f("def.save()","rhaco");
eq("rhaco",$tag->f("abc.def.value()"));
eq("<jkl>is</jkl>",$tag->f("abc.def[1].value()"));
$tag->f("abc.def.saveParam(type)","author");
eq("author",$tag->f("abc.def.param(type)"));
$tag->f("abc.saveParam(type)","other");
eq("other",$tag->f("abc.param(type)"));
$tag->f("abc.def.saveAttr(human)");
eq("human",$tag->f("abc.def.attr(human)"));
SimpleTag::setof($tag,$src,"tag");
eq("hoge",$tag->f("abc.def.ghi.value()"));
eq("123",$tag->f("abc.def.param('var')"));
eq("selected",$tag->f("abc.def.ghi.attr('selected')"));
eq("<def var='123'><ghi selected>hoge</ghi></def>",$tag->f("abc.def.plain()"));
eq("",$tag->f("abc.def.xyz"));
eq("rhaco",$tag->f("abc.def.xyz","rhaco"));
$src = "<tag><abc><def var='123'>".
"<ghi selected>hoge</ghi>".
"<ghi>".
"<jkl>rails</jkl>".
"</ghi>".
"<ghi>django</ghi>".
"</def></abc></tag>";
SimpleTag::setof($tag,$src,"tag");
eq("django",$tag->f("abc.def.ghi[2].value()"));
eq("rails",$tag->f("abc.def.ghi[1].jkl.value()"));
eq("",$tag->f("abc.def.ghi.jkl.value()"));
$src = "<tag><abc><def var='123'>".
"<def><ghi selected>DRY</ghi></def>".
"<def><def>".
"<ghi>setup framework</ghi>".
"</def></def>".
"<ghi>and library</ghi>".
"</def></abc></tag>";
SimpleTag::setof($tag,$src,"tag");
eq("setup framework",$tag->f("abc.def.def[1].def.ghi.value()"));
eq("setup framework",$tag->f("abc.def.def[1].ghi.value()"));
eq("setup framework",$tag->f("def.def[1].ghi.value()"));
eq("",$tag->f("def[1].ghi.value()"));
eq("",$tag->f("abc.def.def.def.ghi.value()"));
eq(1,count($tag->f("in(def)")));
eq(2,count($tag->f("def.in(def)")));
eq(3,count($tag->f("in(ghi)")));
$src = <<< __XML__
<tag>
<abc>
<def type='unknown' selected>hoge</def>
<def><jkl>is</jkl></def>
<ghi>hentai++</ghi>
</abc>
</tag>
__XML__;
SimpleTag::setof($tag,$src,"tag");
$def = $tag->f("abc.in(def)");
eq(2,count($def));
eq($tag->f("abc.def"),$def[0]);
$ghi = $tag->f("abc.in(ghi)");
assert(V::istype("SimpleTag",$ghi[0]));
eq("hentai++",$ghi[0]->getValue());
eq("",$tag->f("abc.mno"));
neq($tag->f("abc.def[1].jkl"),$tag->f("jkl")); //posだけ違う
eq($tag->f("abc.def[1].jkl.value()"),$tag->f("jkl.value()"));
neq($tag->f("abc.jkl"),$tag->f("jkl")); //posだけ違う
eq($tag->f("abc.jkl.value()"),$tag->f("jkl.value()"));
neq($tag->f("abc.def[1].in(jkl)"),$tag->f("in(jkl)"));//posだけ違う
$tag->f("def.save()","rhaco");
eq("rhaco",$tag->f("abc.def.value()"));
eq("<jkl>is</jkl>",$tag->f("abc.def[1].value()"));
$tag->f("abc.def.saveParam(type)","author");
eq("author",$tag->f("abc.def.param(type)"));
$tag->f("abc.saveParam(type)","other");
eq("other",$tag->f("abc.param(type)"));
$tag->f("abc.def.saveAttr(human)");
eq("human",$tag->f("abc.def.attr(human)"));
toHash [ # ]
value内のtag.model.SimpleTagをハッシュにして取得
@param tag.model.SimpleTag $tag
@return array
@param tag.model.SimpleTag $tag
@return array
$tag = new SimpleTag("input","",array("type"=>"password"));
eq(array("type__REP__174__password"),$tag->toHash());
$tag = new SimpleTag("input","",array("type"=>"password","name"=>"hoge"));
eq(array("type__REP__174__password","name"=>"hoge"),$tag->toHash());
$tag = new SimpleTag("input",new SimpleTag("user__REP__176__dummy"),array("type__REP__174__password"));
eq(array("type__REP__174__password","user__REP__174__dummy"),$tag->toHash());
$tag = new SimpleTag("input",array(new SimpleTag("user__REP__176__dummy"),new SimpleTag("status",1)),array("type__REP__174__password"));
eq(array("type__REP__174__password","user__REP__174__dummy__REP__176__status"=>1),$tag->toHash());
$tag = new SimpleTag("input",array(new SimpleTag("user__REP__176__dummy"),new SimpleTag("status",new SimpleTag("default",123))),array("type__REP__174__password"));
eq(array("type__REP__174__password","user__REP__174__dummy__REP__176__status"=>array("default"=>123)),$tag->toHash());
$tag = new SimpleTag("tag",<<< _XML_
<word_list>
<word>
<abc>1</abc>
<def>2</def>
</word>
<word>
<abc>3</abc>
<def>4</def>
</word>
</word_list>
_XML_
);
eq(array(
"word_list"=>array(
"word"=>array(
0=>array("abc"=>1,"def"=>2),
1=>array("abc"=>3,"def"=>4)
)
)),$tag->toHash());
$tag = new SimpleTag("tag","<hoge><data>1.23</data></hoge>");
eq(array("hoge"=>array("data"=>1.23)),$tag->toHash());
$tag = new SimpleTag("tag","<hoge><data>1</data><data>2</data><data>3</data></hoge>");
eq(array("hoge"=>array("data"=>array(1,2,3))),$tag->toHash());
$tag = new SimpleTag("tag","hogehoge");
eq("hogehoge",$tag->toHash());
$tag = new SimpleTag("tag","<hoge name='fuga' class='funyo'>1.23</hoge>");
eq(array(
"_rawvalue___REP__174__<hoge name='fuga' class='funyo'>1.23</hoge>",
"hoge"=>array(
"name__REP__174__fuga",
"class__REP__174__funyo",
"_rawvalue_"=>1.23,
)
),$tag->toHash(true));
$xml = <<< __XML__
<chat anonymity="1" date="1201934892" mail="184" no="30" thread="1201801480" user_id="BGqtOSY_nL_zF30qi9rBWduKB9A" vpos="12453">オナニーズ★プレイ</chat>
__XML__;
$tag = new SimpleTag("tag",$xml);
eq(array(
"_rawvalue_"=>$xml,
"chat"=>array("anonymity"=>1,
"date"=>1201934892,
"mail"=>184,
"no"=>30,
"thread"=>1201801480,
"user_id__REP__174__BGqtOSY_nL_zF30qi9rBWduKB9A",
"vpos"=>12453,
"_rawvalue___REP__174__オナニーズ★プレイ")),
$tag->toHash(true));
$xml = <<<XML
<sample>
<tags>
<tag>tag 1</tag>
<tag>tag 2</tag>
<tag>tag 3</tag>
<tag>tag 4</tag>
</tags>
</sample>
XML;
if(SimpleTag::setof($tag,$xml,"sample")){
eq(array("tags"=>array("tag"=>array("tag 1__REP__176__tag 2__REP__176__tag 3__REP__176__tag 4"))),$tag->toHash());
}
$xml = <<<XML
<sample>
<tags>
<group>
<tag>tag 1</tag>
<tag>tag 2</tag>
</group>
<group>
<tag>tag 3</tag>
<tag>tag 4</tag>
</group>
</tags>
</sample>
XML;
if(SimpleTag::setof($tag,$xml,"sample")){
eq(array("tags"=>array(
"group"=>array(
0=>array("tag"=>array("tag 1__REP__176__tag 2")),
1=>array("tag"=>array("tag 3__REP__176__tag 4")),
))
),$tag->toHash());
}
eq(array("type__REP__174__password"),$tag->toHash());
$tag = new SimpleTag("input","",array("type"=>"password","name"=>"hoge"));
eq(array("type__REP__174__password","name"=>"hoge"),$tag->toHash());
$tag = new SimpleTag("input",new SimpleTag("user__REP__176__dummy"),array("type__REP__174__password"));
eq(array("type__REP__174__password","user__REP__174__dummy"),$tag->toHash());
$tag = new SimpleTag("input",array(new SimpleTag("user__REP__176__dummy"),new SimpleTag("status",1)),array("type__REP__174__password"));
eq(array("type__REP__174__password","user__REP__174__dummy__REP__176__status"=>1),$tag->toHash());
$tag = new SimpleTag("input",array(new SimpleTag("user__REP__176__dummy"),new SimpleTag("status",new SimpleTag("default",123))),array("type__REP__174__password"));
eq(array("type__REP__174__password","user__REP__174__dummy__REP__176__status"=>array("default"=>123)),$tag->toHash());
$tag = new SimpleTag("tag",<<< _XML_
<word_list>
<word>
<abc>1</abc>
<def>2</def>
</word>
<word>
<abc>3</abc>
<def>4</def>
</word>
</word_list>
_XML_
);
eq(array(
"word_list"=>array(
"word"=>array(
0=>array("abc"=>1,"def"=>2),
1=>array("abc"=>3,"def"=>4)
)
)),$tag->toHash());
$tag = new SimpleTag("tag","<hoge><data>1.23</data></hoge>");
eq(array("hoge"=>array("data"=>1.23)),$tag->toHash());
$tag = new SimpleTag("tag","<hoge><data>1</data><data>2</data><data>3</data></hoge>");
eq(array("hoge"=>array("data"=>array(1,2,3))),$tag->toHash());
$tag = new SimpleTag("tag","hogehoge");
eq("hogehoge",$tag->toHash());
$tag = new SimpleTag("tag","<hoge name='fuga' class='funyo'>1.23</hoge>");
eq(array(
"_rawvalue___REP__174__<hoge name='fuga' class='funyo'>1.23</hoge>",
"hoge"=>array(
"name__REP__174__fuga",
"class__REP__174__funyo",
"_rawvalue_"=>1.23,
)
),$tag->toHash(true));
$xml = <<< __XML__
<chat anonymity="1" date="1201934892" mail="184" no="30" thread="1201801480" user_id="BGqtOSY_nL_zF30qi9rBWduKB9A" vpos="12453">オナニーズ★プレイ</chat>
__XML__;
$tag = new SimpleTag("tag",$xml);
eq(array(
"_rawvalue_"=>$xml,
"chat"=>array("anonymity"=>1,
"date"=>1201934892,
"mail"=>184,
"no"=>30,
"thread"=>1201801480,
"user_id__REP__174__BGqtOSY_nL_zF30qi9rBWduKB9A",
"vpos"=>12453,
"_rawvalue___REP__174__オナニーズ★プレイ")),
$tag->toHash(true));
$xml = <<<XML
<sample>
<tags>
<tag>tag 1</tag>
<tag>tag 2</tag>
<tag>tag 3</tag>
<tag>tag 4</tag>
</tags>
</sample>
XML;
if(SimpleTag::setof($tag,$xml,"sample")){
eq(array("tags"=>array("tag"=>array("tag 1__REP__176__tag 2__REP__176__tag 3__REP__176__tag 4"))),$tag->toHash());
}
$xml = <<<XML
<sample>
<tags>
<group>
<tag>tag 1</tag>
<tag>tag 2</tag>
</group>
<group>
<tag>tag 3</tag>
<tag>tag 4</tag>
</group>
</tags>
</sample>
XML;
if(SimpleTag::setof($tag,$xml,"sample")){
eq(array("tags"=>array(
"group"=>array(
0=>array("tag"=>array("tag 1__REP__176__tag 2")),
1=>array("tag"=>array("tag 3__REP__176__tag 4")),
))
),$tag->toHash());
}
xmltext [ # ]
XMLテキストとして返す
@static
@param string $value
@return string
@static
@param string $value
@return string
eq("\n<hoge>&1234;abc</hoge>\n",SimpleTag::xmltext("<hoge>&1234;abc</hoge>"