示例#1
3
文件: Rss.php 项目: hisaboh/w2t
 /**
  * xmlをRssに変換する
  *
  * @param string $src
  * @return Rss
  */
 public static function parse($src)
 {
     if (Tag::setof($rss, $src, "rss")) {
         $result = new self();
         $result->version($rss->inParam("version", "2.0"));
         if (Tag::setof($channel, $rss->value(), "channel")) {
             $result->title($channel->f("title.value()"));
             $result->link($channel->f("link.value()"));
             $result->description($channel->f("description.value()"));
             $result->language($channel->f("language.value()"));
             $result->copyright($channel->f("copyright.value()"));
             $result->docs($channel->f("docs.value()"));
             $result->managingEditor($channel->f("managingEditor.value()"));
             $result->webMaster($channel->f("webMaster.value()"));
             $result->lastBuildDate($channel->f("lastBuildDate.value()"));
             $result->pubDate($channel->f("pubDate.value()"));
             $value = $channel->value();
             $result->item = RssItem::parse($value);
             return $result;
         }
     }
     throw new Exception("no rss");
     /***
     			 $src = text('
     						<rss version="2.0">
     							<channel>
     								<title>rhaco</title>
     								<link>http://rhaco.org</link>
     								<description>php</description>
     								<language>ja</language>
     								<copyright>rhaco.org</copyright>
     								<docs>hogehoge</docs>
     								<lastBuildDate>2007-10-10T10:10:10+09:00</lastBuildDate>
     								<managingEditor>tokushima</managingEditor>
     								<pubDate>2007-10-10T10:10:10+09:00</pubDate>
     								<webMaster>kazutaka</webMaster>
     								<item>
     									<title>rhaco</title>
     									<link>http://rhaco.org</link>
     									<description>rhaco desc</description>
     								</item>
     								<item>
     									<title>everes</title>
     									<link>http://www.everes.net</link>
     									<description>everes desc</description>
     								</item>
     							</channel>
     						</rss>
     					');
     					$xml = Rss::parse($src);
     					eq("2.0",$xml->version());
     					eq("rhaco",$xml->title());
     					eq("http://rhaco.org",$xml->link());
     					eq("php",$xml->description());
     					eq("ja",$xml->language());
     					eq("rhaco.org",$xml->copyright());
     					eq("hogehoge",$xml->docs());
     					eq(1191978610,$xml->lastBuildDate());
     					eq("Wed, 10 Oct 2007 10:10:10 +0900",$xml->fmLastBuildDate());
     					eq("tokushima",$xml->managingEditor());
     					eq(1191978610,$xml->pubDate());
     					eq("Wed, 10 Oct 2007 10:10:10 +0900",$xml->fmPubDate());
     					eq("kazutaka",$xml->webMaster());
     					eq(2,sizeof($xml->item()));
     			*/
 }
示例#2
0
 public function revision($from, $to)
 {
     $src = Command::out(sprintf("%s log %s --xml --verbose %s", $this->cmd, sprintf("-r %d:%d ", $from, $to), $this->url));
     $result = array();
     if (Tag::setof($tag, $src, "log")) {
         foreach ($tag->in("logentry") as $log) {
             $revision = $log->inParam("revision");
             $result[$revision] = new SvnRevision($revision, $log->f("author.value()"), $log->f("msg.value()"), $log->f("date.value()"));
             foreach ($log->in("paths") as $paths) {
                 foreach ($paths->in("path") as $path) {
                     $result[$revision]->path($path->inParam("action"), $path->value());
                 }
             }
         }
     }
     if ($to - $from != sizeof($result) - 1) {
         $last = $this->_lastShell();
         if ($to > $last) {
             $to = $last;
         }
         for ($i = $from; $i <= $to; $i++) {
             if (!isset($result[$i])) {
                 $result[$i] = new SvnRevision($i, null, null, null);
             }
         }
     }
     return $result;
 }
示例#3
0
 public static function parse($response)
 {
     if (!is_array($response)) {
         Tag::setof($response, $response, "hash");
     }
     $obj = new self();
     return $obj->cp($response);
 }
示例#4
0
文件: Feed.php 项目: hisaboh/w2t
 /**
  * URLからフィードを取得
  *
  * @param string $url
  * @return Atom
  */
 public function do_read($url)
 {
     $urls = func_get_args();
     $feed = null;
     if (!self::$CACHE || File::isExpiry($urls, self::$CACHE_TIME)) {
         foreach ($urls as $url) {
             if (is_string($url) && ($url = trim($url)) && !empty($url)) {
                 if (!self::$CACHE || File::isExpiry($url, self::$CACHE_TIME)) {
                     $src = Tag::xhtmlnize($this->do_get($url)->body(), "link");
                     if (Tag::setof($tag, $src, "head")) {
                         foreach ($tag->in("link") as $link) {
                             if ("alternate" == strtolower($link->inParam("rel")) && strpos(strtolower($link->inParam("type")), "application") === 0 && $url != ($link = File::absolute($url, $link->inParam("href")))) {
                                 $src = $this->do_get($link)->body();
                                 break;
                             }
                         }
                     }
                     $tmp = self::parse($src);
                     if (self::$CACHE) {
                         File::cwrite($url, $tmp);
                     }
                 } else {
                     $tmp = File::cread($url);
                 }
                 if ($feed === null) {
                     if ($this->title !== null) {
                         $tmp->title($this->title());
                     }
                     if ($this->subtitle !== null) {
                         $tmp->subtitle($this->subtitle());
                     }
                     if ($this->id !== null) {
                         $tmp->id($this->id());
                     }
                     if ($this->generator !== null) {
                         $tmp->generator($this->generator());
                     }
                     if ($this->updated !== null) {
                         $tmp->updated($this->updated());
                     }
                     $feed = $tmp;
                 } else {
                     $feed->add($tmp);
                 }
             }
         }
         if (!$feed instanceof Atom) {
             $feed = new Atom();
         }
         $feed->sort();
         if (self::$CACHE) {
             File::cwrite($urls, $feed);
         }
     } else {
         $feed = File::cread($urls);
     }
     return $feed;
 }
示例#5
0
文件: Mixi.php 项目: hisaboh/w2t
 public function updates()
 {
     $results = array();
     if (Tag::setof($feed, $this->do_get("http://mixi.jp/atom/updates/r=1/member_id=" . $this->member_id)->body(), "feed")) {
         foreach ($feed->in("entry") as $entry) {
             $results[] = MixiContent::parse($entry);
         }
     }
     return $results;
 }
示例#6
0
 protected function __after_exec__(&$ret)
 {
     if (Tag::setof($tag, $ret->stdout(), 'info')) {
         foreach ($tag->in('entry') as $entry) {
             $ret = $entry->hash();
             return;
         }
     }
     throw new SubversionInfoException();
 }
示例#7
0
 public function diff($path, $revA, $revB)
 {
     $url = sprintf("http://%s.svn.sourceforge.net/viewvc/%s/%s?r1=%d&r2=%d&diff_format=u", $this->project, $this->project, $path, $revA, $revB);
     if (Tag::setof($tag, $this->do_get($url)->body(), "body")) {
         $result = Text::htmldecode(preg_replace("/^\\+{3} .+\n/", "", preg_replace("/^-{3} .+\n/", "", trim($tag->f("pre.value()")))));
         if ($result !== "400 Bad Request") {
             return $result;
         }
     }
     throw new Exception("undef");
 }
 private function m_not_mobile(&$src, Template $template)
 {
     while (Tag::setof($tag, $src, 'm:not_mobile')) {
         if (!Mobile::is_mobile()) {
             $src = str_replace($tag->plain(), $tag->value(), $src);
         } else {
             $src = str_replace($tag->plain(), '', $src);
         }
     }
     $src = $template->parse_vars($src);
 }
示例#9
0
 public static function parse($response)
 {
     if (Tag::setof($tag, $response, "err")) {
         throw new Exception($tag->inParam("msg"));
     }
     if (Tag::setof($tag, $response, "rsp")) {
         $obj = new self();
         return $obj->cp($tag->hash());
     }
     throw new InvalidArgumentException();
 }
示例#10
0
 /**
  * Templateのモジュール
  * @param string $src
  * @param Tempalte $template
  */
 public function before_template(&$src, Template $template)
 {
     if (Tag::setof($tag, $src, "body")) {
         foreach ($tag->in("form") as $f) {
             if (strtolower($f->in_param("method")) == "post") {
                 $f->value("<input type=\"hidden\" name=\"_onetimeticket\" value=\"{\$_onetimeticket}\" />" . $f->value());
                 $src = str_replace($f->plain(), $f->get(), $src);
             }
         }
     }
 }
示例#11
0
 public function parse(&$src, &$result)
 {
     if (Tag::setof($tag, $src, "media:group")) {
         $media = new self();
         $media->keyword($tag->f("media:keywords.value()"));
         $media->duration($tag->f("yt:duration.param(seconds)"));
         $media->player($tag->f("media:player.value()"));
         $media->category($tag->f("media:category.value()"));
         $media->thumbnail($tag->f("media:thumbnail.param(url)"));
         $result = $media;
     }
 }
示例#12
0
 public static function parse($response)
 {
     if (!is_array($response)) {
         if (Tag::setof($tag, $response, "error")) {
             throw new Exception($tag->value());
         }
         Tag::setof($tag, $response, "user");
         $response = $tag->hash();
     }
     $obj = new self();
     return $obj->cp($response);
 }
示例#13
0
 protected function __exec__()
 {
     $this->options('xml');
     if (Tag::setof($tag, parent::__exec__()->stdout(), 'list')) {
         $result = array();
         foreach ($tag->in('entry') as $t) {
             $result[] = $t->hash();
         }
         return $result;
     }
     throw new SubversionListException();
 }
示例#14
0
文件: Installer.php 项目: hisaboh/w2t
 private static function read_server($http, $server, $uri, $tgz, $package_path)
 {
     if ($http->do_get($server . "__repository__.php" . "/state/" . $uri)->status() === 200) {
         if (Tag::setof($tag, $http->body(), "rest") && $tag->f("status.value()") == "success") {
             $http->do_download($server . "__repository__.php" . "/download/" . $uri, $tgz);
             File::untgz($tgz, getcwd());
             File::rm($tgz);
             return true;
         }
     }
     return false;
 }
示例#15
0
 public static function parse(&$src)
 {
     $result = null;
     if (Tag::setof($tag, $src, "summary")) {
         $result = new self();
         $result->type($tag->inParam("type", "text"));
         $result->lang($tag->inParam("xml:lang"));
         $result->value($tag->value());
         $src = str_replace($tag->plain(), "", $src);
     }
     return $result;
 }
示例#16
0
 public static function parse_list($response)
 {
     $result = array();
     if (Tag::setof($tag, $response, "info")) {
         foreach ($tag->in("photo") as $photo) {
             $obj = new self();
             $result[] = $obj->cp($photo->hash());
         }
     } else {
         throw new Exception("Invalid data");
     }
     return $result;
 }
示例#17
0
文件: Lou.php 项目: hisaboh/w2t
 private static function trans($message, $mode)
 {
     $http = new Http();
     $http->vars("v", $mode);
     $http->vars("text", $message);
     if (Tag::setof($tag, $http->do_post("http://lou5.jp/")->body(), "body")) {
         foreach ($tag->in('p') as $p) {
             if ($p->inParam("class") == "large align-left box") {
                 $message = $p->value();
             }
         }
     }
     return $message;
 }
示例#18
0
 public static function parse_list($response)
 {
     $result = array();
     if (Tag::setof($tag, $response, "error")) {
         throw new Exception($tag->f("message.value()"));
     }
     if (Tag::setof($tag, $response, "programs")) {
         foreach ($tag->in("program") as $program) {
             $obj = new self();
             $result[] = $obj->cp($program->hash());
         }
     }
     return $result;
 }
示例#19
0
 public static function parse($response)
 {
     if (Tag::setof($tag, $response, "error")) {
         throw new Exception($tag->value());
     }
     if (Tag::setof($tag, $response, "status")) {
         $hash = $tag->hash();
         $obj = new self();
         $obj->user(TwitterUser::parse($hash["user"]));
         unset($hash["user"]);
         return $obj->cp($hash);
     }
     throw new Exception("invalid data");
 }
示例#20
0
 public static function parse($response)
 {
     if (Tag::setof($tag, $response, "Error")) {
         throw new Exception($tag->f("Message.value()"));
     }
     $obj = new self();
     if (Tag::setof($tag, $response, "ResultSet")) {
         $ma_result = $tag->f("ma_result");
         $obj->total_count($ma_result->f("total_count.value()"));
         $obj->filtered_count($ma_result->f("filtered_count.value()"));
         $obj->ma(YahooMAWord::parse($ma_result->f("word_list")));
         $obj->uniq(YahooMAWord::parse($tag->f("uniq_result")->f("word_list")));
     }
     return $obj;
 }
示例#21
0
 protected function __exec__()
 {
     if ($this->is_raw()) {
         return parent::__exec__();
     }
     $this->options('xml');
     $result = array();
     if (Tag::setof($tag, parent::__exec__()->stdout(), 'log')) {
         foreach ($tag->in('logentry') as $logentry) {
             $result[] = $logentry->hash();
         }
         return $result;
     }
     throw new SubversionLogException();
 }
示例#22
0
 public static function parse_list($response)
 {
     $result = array();
     if (Tag::setof($tag, $response, "photos")) {
         foreach ($tag->in("photo") as $photo) {
             $obj = new self();
             $params = array();
             foreach ($photo->arParam() as $param) {
                 $params[$param[0]] = $param[1];
             }
             $result[] = $obj->cp($params);
         }
     }
     return $result;
 }
示例#23
0
 /**
  * linktitleHandler
  */
 public static function linktitleHandler($url)
 {
     if (module_const('is_cache', false)) {
         $store_key = array('__hatenaformat_linktitlehandler', $url);
         if (Store::has($store_key)) {
             return Store::get($store_key);
         }
     }
     if (Tag::setof($title, Http::read($url), 'title')) {
         $url = $title->value();
         if (module_const('is_cache', false)) {
             Store::set($store_key, $url, self::CACHE_EXPIRE);
         }
     }
     return $url;
 }
示例#24
0
 public static function parse($response)
 {
     if (Tag::setof($tag, $response, "error")) {
         throw new Exception($tag->value());
     }
     $result = array();
     if (Tag::setof($tag, $response, "direct_message")) {
         $re = $status->hash();
         $obj = new self();
         $obj->sender(TwitterUser::parse($re["sender"]));
         $obj->recipient(TwitterUser::parse($re["recipient"]));
         unset($re["recipient"], $re["sender"]);
         return $obj->cp($re);
     }
     throw new Exception("invalid data");
 }
示例#25
0
 /**
  * @see Iterator
  */
 public function valid()
 {
     if ($this->length > 0 && $this->offset + $this->length <= $this->count) {
         return false;
     }
     if (is_array($this->name)) {
         $tags = array();
         foreach ($this->name as $name) {
             if (Tag::setof($get_tag, $this->plain, $name)) {
                 $tags[$get_tag->pos()] = $get_tag;
             }
         }
         if (empty($tags)) {
             return false;
         }
         ksort($tags, SORT_NUMERIC);
         foreach ($tags as $this->tag) {
             return true;
         }
     }
     return Tag::setof($this->tag, $this->plain, $this->name);
 }
示例#26
0
 public function diff($path, $revA, $revB)
 {
     $url = sprintf("http://code.google.com/p/%s/source/diff?old=%d&r=%d&format=unidiff&path=%s", $this->project, $revA, $revB, $path);
     $src = $this->do_get($url)->body();
     if (Tag::setof($tag, $src, "body")) {
         $lines = "";
         $block = "";
         $fs = $ts = $fl = $tl = 0;
         $blocks = $tag->f("table[5].in(tr)");
         foreach ($blocks as $tr) {
             $from = $tr->f("th[0].value()");
             if ($from == "...") {
                 if (!empty($block)) {
                     $lines .= sprintf("@@ -%d,%d +%d,%d @@\n%s", $fs, $fl, $ts, $tl, $block);
                 }
                 $block = "";
                 $fs = $ts = $fl = $tl = 0;
             } else {
                 $to = $tr->f("th[1].value()");
                 if ($fs == 0 && !empty($from)) {
                     $fs = $from;
                 }
                 if ($ts == 0 && !empty($to)) {
                     $ts = $to;
                 }
                 if (!empty($from)) {
                     $fl++;
                 }
                 if (!empty($to)) {
                     $tl++;
                 }
                 $block .= Text::htmldecode(strip_tags($tr->f("th[2].value()") . $tr->f("td.value()")) . "\n");
             }
         }
         return $lines;
     }
     throw new Exception("undef");
 }
示例#27
0
    public function before_template(&$src)
    {
        if (Tag::setof($tag, $src, "body")) {
            foreach ($tag->in("form") as $f) {
                if (strtolower($f->inParam("method")) == "post") {
                    $func = uniqid("f") . mt_rand();
                    foreach ($f->in("input") as $i) {
                        if (strtolower($i->inParam("type")) === "submit") {
                            $i->param("onclick", $func . "(this.form)");
                            $f->value(str_replace($i->plain(), $i->get(), $f->value()));
                        }
                    }
                    $f->value("<input type=\"hidden\" name=\"_onetimeticket\" rt:ref=\"false\" />" . $f->value());
                    $src = str_replace($f->plain(), sprintf('
													<script type="text/javascript"><!--
														function %s(frm){
															frm._onetimeticket.value = "{$_onetimeticket}";
														}
													-->
													</script>', $func) . $f->get(), $src);
                }
            }
        }
    }
示例#28
0
 /**
  * application アプリケーションXMLをパースする
  * 
  * 基本情報
  * ========================================================================
  * <app name="アプリケーションの名前" summary="アプリケーションのサマリ">
  * 	<description>
  * 		アプリケーションの説明
  * 	</description>
  * </app>
  * ========================================================================
  * 
  * アプリケーションの順次処理を行う場合	
  * ========================================================================
  * <app>
  * 	<invoke class="org.rhaco.net.xml.Feed" method="do_read">
  * 		<arg value="http://ameblo.jp/nakagawa-shoko/" />
  * 		<arg value="http://ameblo.jp/kurori1985/" />
  * 	</invoke>
  * 	<invoke class="org.rhaco.net.xml.FeedConverter" method="strip_tags" />
  * 	<invoke method="output" />
  * </app>
  * ========================================================================
  * 
  * URLマッピングでアプリケーションを作成する
  * ========================================================================
  * <app>
  * 	<handler>
  * 		<map url="/hello" class="FlowSampleHello" method="hello" template="display.html" summary="ハローワールド" name="hello_world" />
  * 	</handler>
  * </app>
  * ========================================================================
  * 
  * @param string $file アプリケーションXMLのファイルパス
  * @param boolean $get_meta 詳細な情報を取得する
  * @return string{}
  */
 public static function parse_app($file, $get_meta = true)
 {
     $apps = array();
     $handler_multiple = false;
     $app_nomatch_redirect = $app_nomatch_template = null;
     if (Tag::setof($tag, Tag::uncomment(File::read($file)), 'app')) {
         $app_ns = $tag->in_param('ns');
         $app_nomatch_redirect = File::path_slash($tag->in_param('nomatch_redirect'), false, null);
         $app_nomatch_template = File::path_slash($tag->in_param('nomatch_template'), false, null);
         $handler_multiple = $tag->in_param('multiple', false) === "true";
         $handler_count = 0;
         $invoke_count = 0;
         foreach ($tag->in(array('invoke', 'handler')) as $handler) {
             switch (strtolower($handler->name())) {
                 case 'handler':
                     if ($handler->in_param(App::mode(), "true") === "true") {
                         if ($handler->is_param('class')) {
                             $class = Lib::import($handler->in_param('class'));
                             $maps = new Tag('maps');
                             $maps->add('class', $handler->in_param('class'));
                             $ref = new ReflectionClass($class);
                             $url = File::path_slash($handler->in_param('url', strtolower(substr($ref->getName(), 0, 1)) . substr($ref->getName(), 1)), false, false);
                             $handler->param('url', $url);
                             $var = new Tag('var');
                             $handler->add($var->add('name', 'module_url')->add('value', $url));
                             foreach ($ref->getMethods() as $method) {
                                 if ($method->isPublic() && is_subclass_of($method->getDeclaringClass()->getName(), __CLASS__)) {
                                     if (!$method->isStatic()) {
                                         $url = $method->getName() == 'index' && $method->getNumberOfParameters() == 0 ? '' : $method->getName() . str_repeat("/(.+)", $method->getNumberOfRequiredParameters());
                                         for ($i = 0; $i <= $method->getNumberOfParameters() - $method->getNumberOfRequiredParameters(); $i++) {
                                             $map = new Tag('map');
                                             $map->add('url', $url);
                                             $map->add('method', $method->getName());
                                             $maps->add($map);
                                             $url .= '/(.+)';
                                         }
                                     }
                                 }
                             }
                             $handler->add($maps);
                         }
                         $handler_name = empty($app_ns) ? str_replace(App::path(), '', $file) . $handler_count++ : $app_ns;
                         $maps = $modules = $vars = array();
                         $handler_url = File::path_slash(App::branch(), false, true) . File::path_slash($handler->in_param('url'), false, true);
                         $map_index = 0;
                         $base_path = File::path_slash($handler->in_param("template_path"), false, false);
                         foreach ($handler->in(array('maps', 'map', 'var', 'module')) as $tag) {
                             switch (strtolower($tag->name())) {
                                 case 'map':
                                     $url = File::path_slash($handler_url . File::path_slash($tag->in_param('url'), false, false), false, false);
                                     $maps[$url] = self::parse_map($tag, $url, $base_path, $handler_name, null, null, null, $map_index++, $get_meta);
                                     break;
                                 case 'maps':
                                     $maps_map = $maps_module = array();
                                     $maps_base_path = File::path_slash($base_path, false, true) . File::path_slash($tag->in_param('template_path'), false, false);
                                     foreach ($tag->in(array('map', 'module')) as $m) {
                                         if ($m->name() == 'map') {
                                             $url = File::path_slash($handler_url . File::path_slash($tag->in_param('url'), false, true) . File::path_slash($m->in_param('url'), false, false), false, false);
                                             $map = self::parse_map($m, $url, $maps_base_path, $handler_name, $tag->in_param('class'), $tag->in_param('secure'), $tag->in_param('update'), $map_index++, $get_meta);
                                             $maps_map[$url] = $map;
                                         } else {
                                             $maps_module[] = self::parse_module($m);
                                         }
                                     }
                                     if (!empty($maps_module)) {
                                         foreach ($maps_map as $k => $v) {
                                             $maps_map[$k]['modules'] = array_merge($maps_map[$k]['modules'], $maps_module);
                                         }
                                     }
                                     $maps = array_merge($maps, $maps_map);
                                     break;
                                 case 'var':
                                     $vars[] = self::parse_var($tag);
                                     break;
                                 case 'module':
                                     $modules[] = self::parse_module($tag);
                                     break;
                             }
                         }
                         $verify_maps = array();
                         foreach ($maps as $m) {
                             if (!empty($m['name'])) {
                                 if (isset($verify_maps[$m['name']])) {
                                     Exceptions::add(new RuntimeException("name `" . $m['name'] . "` with this map already exists."));
                                 }
                                 $verify_maps[$m['name']] = true;
                             }
                         }
                         Exceptions::validation();
                         $urls = $maps;
                         krsort($urls);
                         $sort_maps = $surls = array();
                         foreach (array_keys($urls) as $url) {
                             $surls[$url] = strlen(preg_replace("/[\\W]/", "", $url));
                         }
                         arsort($surls);
                         krsort($surls);
                         foreach (array_keys($surls) as $url) {
                             $sort_maps[$url] = $maps[$url];
                         }
                         $apps[] = array('type' => 'handle', 'maps' => $sort_maps, 'modules' => $modules, 'vars' => $vars, 'on_error' => array('status' => $handler->in_param('error_status', 403), 'template' => $handler->in_param('error_template'), 'redirect' => $handler->in_param('error_redirect')));
                     }
                     break;
                 case 'invoke':
                     $targets = $methods = $args = $modules = array();
                     if ($handler->is_param('method')) {
                         $targets[] = $handler->add('name', $handler->in_param('method'));
                     } else {
                         $targets = $handler->in_all('method');
                     }
                     foreach ($targets as $method_tag) {
                         foreach ($method_tag->in(array('arg', 'result')) as $arg) {
                             $args[] = array('type' => $arg->name(), 'value' => $arg->in_param('value', Text::plain($arg->value())));
                         }
                         $methods[] = array('method' => $method_tag->in_param('name'), 'args' => empty($args) && $handler->is_param('class') && $invoke_count > 0 ? array(array('type' => 'result', 'value' => null)) : $args);
                     }
                     foreach ($handler->in('module') as $m) {
                         $modules[] = self::parse_module($m);
                     }
                     $apps[] = array('type' => 'invoke', 'class' => $handler->in_param('class'), 'methods' => $methods, 'modules' => $modules);
                     $invoke_count++;
                     break;
             }
         }
     }
     return array("nomatch_redirect" => $app_nomatch_redirect, "nomatch_template" => $app_nomatch_template, "handler_multiple" => $handler_multiple, "apps" => $apps);
 }
示例#29
0
文件: Opml.php 项目: hisaboh/w2t
 /**
  * 文字列からOpmlをセットする
  *
  * @param string $src
  */
 public static function parse($src)
 {
     if (Tag::setof($tag, $src, "opml")) {
         $result = new self();
         $result->title($tag->f("title.value()"));
         $result->dateCreated($tag->f("dateCreated.value()"));
         $result->dateModified($tag->f("dateModified.value()"));
         $result->ownerName($tag->f("ownerName.value()"));
         $result->ownerEmail($tag->f("ownerEmail.value()"));
         $result->expansionState($tag->f("expansionState.value()"));
         $result->vertScrollState($tag->f("vertScrollState.value()"));
         $result->windowTop($tag->f("windowTop.value()"));
         $result->windowLeft($tag->f("windowLeft.value()"));
         $result->windowBottom($tag->f("windowBottom.value()"));
         $result->windowRight($tag->f("windowRight.value()"));
         foreach ($tag->in("outline") as $intag) {
             $opmloutline = new OpmlOutline();
             $result->outline($opmloutline->parse($intag->plain()));
         }
         return $result;
     }
     throw new Exception("no opml");
     /***
     			$text = text('
     						<?xml version="1.0" encoding="utf-8"?>
     						<opml version="1.0">
     						<head>
     							<title>Subscriptions</title>
     							<dateCreated>Mon, 19 May 2008 04:51:05 UTC</dateCreated>
     							<ownerName>rhaco</ownerName>
     						</head>
     						<body>
     						<outline title="Subscriptions">
     							  <outline title="スパムとか" htmlUrl="http://www.everes.net/" type="rss" xmlUrl="http://www.everes.net/blog/atom/" />
     							  <outline title="tokushimakazutaka.com" htmlUrl="http://tokushimakazutaka.com" type="rss" xmlUrl="tokushimakazutaka.com/rss" />
     							<outline title="rhaco">
     							</outline>
     							<outline title="php">
     							  <outline title="riaf-ja blog" htmlUrl="http://blog.riaf.jp/" type="rss" xmlUrl="http://blog.riaf.jp/rss" />
     							</outline>
     							<outline title="お知らせ">
     							</outline>
     						</outline>
     						</body></opml>
     					');
     
     			$feed = Opml::parse($text);
     			eq("Subscriptions",$feed->title());
     			eq("1.0",$feed->version());
     			eq(1211172665,$feed->dateCreated());
     			eq("rhaco",$feed->ownerName());
     			eq(null,$feed->ownerEmail());
     			
     			eq(1,sizeof($feed->outline()));
     			$opml = $feed->outline();
     			eq("Subscriptions",$opml[0]->title());
     	
     			eq(3,sizeof($opml[0]->xml()));
     			eq(3,sizeof($opml[0]->html()));
     		*/
 }
示例#30
0
文件: Atom.php 项目: hisaboh/w2t
 public static function parse($src)
 {
     $args = func_get_args();
     array_shift($args);
     if (Tag::setof($tag, $src, "feed") && $tag->inParam("xmlns") == self::$XMLNS) {
         $result = new self();
         $value = $tag->value();
         $tag = Tag::anyhow($value);
         $result->id($tag->f("id.value()"));
         $result->title($tag->f("title.value()"));
         $result->subtitle($tag->f("subtitle.value()"));
         $result->updated($tag->f("updated.value()"));
         $result->generator($tag->f("generator.value()"));
         $value = $tag->value();
         $result->entry = call_user_func_array(array("AtomEntry", "parse"), array_merge(array(&$value), $args));
         $result->link = AtomLink::parse($value);
         $result->author = AtomAuthor::parse($value);
         return $result;
     }
     throw new Exception("no atom");
     /***
     			$src = text('
     						<feed xmlns="http://www.w3.org/2005/Atom">
     							<title>atom10 feed</title>
     							<subtitle>atom10 sub title</subtitle>
     							<updated>2007-07-18T16:16:31+00:00</updated>
     							<generator>tokushima</generator>
     							<link href="http://tokushimakazutaka.com" rel="abc" type="xyz" />
     
     							<author>
     								<url>http://tokushimakazutaka.com</url>
     								<name>tokushima</name>
     								<email>tokushima@hoge.hoge</email>
     							</author>
     
     							<entry>
     								<title>rhaco</title>
     								<summary type="xml" xml:lang="ja">summary test</summary>
     								<content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content>
     								<link href="http://rhaco.org" rel="abc" type="xyz" />
     								<link href="http://conveyor.rhaco.org" rel="abc" type="conveyor" />
     								<link href="http://lib.rhaco.org" rel="abc" type="lib" />
     
     							 <updated>2007-07-18T16:16:31+00:00</updated>
     							 <issued>2007-07-18T16:16:31+00:00</issued>
     							 <published>2007-07-18T16:16:31+00:00</published>
     							 <id>rhaco</id>
     							<author>
     								<url>http://rhaco.org</url>
     								<name>rhaco</name>
     								<email>rhaco@rhaco.org</email>
     							</author>
     							</entry>
     
     							<entry>
     								<title>django</title>
     								<summary type="xml" xml:lang="ja">summary test</summary>
     								<content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content>
     								<link href="http://djangoproject.jp" rel="abc" type="xyz" />
     
     							 <updated>2007-07-18T16:16:31+00:00</updated>
     							 <issued>2007-07-18T16:16:31+00:00</issued>
     							 <published>2007-07-18T16:16:31+00:00</published>
     							 <id>django</id>
     							<author>
     								<url>http://www.everes.net</url>
     								<name>everes</name>
     								<email>everes@hoge.hoge</email>
     							</author>
     							</entry>
     						</feed>
     					');
     
     			$xml = Atom::parse($src);
     			eq("atom10 feed",$xml->title());
     			eq("atom10 sub title",$xml->subtitle());
     			eq(1184775391,$xml->updated());
     			eq("2007-07-18T16:16:31Z",$xml->fmUpdated());
     			eq("tokushima",$xml->generator());
     			eq(2,sizeof($xml->entry()));
     		*/
 }