Source for file Ethna_UrlHandler.php
Documentation is available at Ethna_UrlHandler.php
// vim: foldmethod=marker tabstop=4 shiftwidth=4 autoindent
* @author Masaki Fujimoto <fujimoto@php.net>
* @author Masaki Fujimoto <fujimoto@php.net>
/** @var array アクションマッピング */
* 'path_regexp' => false,
* Ethna_UrlHandlerクラスのコンストラクタ
* Ethna_UrlHandlerクラスのインスタンスを取得する
* $name がクラス名 ('_'を含む) の場合はそのクラスを、
* そうでないときはプラグイン名とみなしてインスタンスを返す
static $instance =
array();
if (isset
($instance[$name])) {
if (strpos($name, '_') !==
false) {
$instance[$name] =
&new $name();
// get instance with plugin
$plugin =
&$ctl->getPlugin();
$instance[$name] =
&$plugin->getPlugin('Urlhandler', $name);
if (isset
($value[$action])) {
$action_value =
$value[$action];
// url_handler specific path
list
($path, $path_key) =
$this->$method($action, $param);
if ($action_value['path']) {
$path .=
"/" .
$action_value['path'];
// path_ext candidate list
if (is_array($action_value['path_regexp'])) {
$tmp =
array_map('count', $action_value['path_ext']);
$path_ext_list =
$action_value['path_ext'];
$path_ext_list_indices =
array(0);
$path_ext_list =
array(0 =>
$action_value['path_ext']);
foreach ($path_ext_list_indices as $index) {
if (is_array($path_ext_list[$index]) ===
false) {
$path_ext =
$path_ext_list[$index];
foreach ($path_ext_list[$index] as $key =>
$value) {
if (isset
($param[$key]) ===
false) {
$path_ext =
$path_ext_list[$index];
if (isset
($path_ext) ===
false) {
// append extra parameters to path.
foreach ($path_ext as $key =>
$value) {
$ext_param =
$param[$key];
if (isset
($value['output_filter']) &&
$value['output_filter'] !=
"") {
$method =
$value['output_filter'];
$ext_param =
$this->$method($ext_param);
// remove form (pre|suf)fix
if (isset
($value['form_prefix']) &&
$value['form_prefix'] !=
"") {
$s =
$value['form_prefix'];
if (isset
($value['form_suffix']) &&
$value['form_suffix'] !=
"") {
$s =
$value['form_suffix'];
// rawurlencode (url (pre|suf)fixes need not to be encoded.)
if (isset
($value['url_prefix']) &&
$value['url_prefix'] !=
"") {
$ext_param =
$value['url_prefix'] .
$ext_param;
if (isset
($value['url_suffix']) &&
$value['url_suffix'] !=
"") {
$ext_param =
$ext_param .
$value['url_suffix'];
$path .=
'/' .
$ext_param;
list
($path, $is_slash) =
$this->_normalizePath($path);
return array($path, $path_key);
if (isset
($http_vars['__url_handler__']) ==
false
|| isset
($this->action_map[$http_vars['__url_handler__']]) ==
false) {
$url_handler =
$http_vars['__url_handler__'];
$http_vars =
$this->$method($http_vars);
if (isset
($http_vars['__url_info__'])) {
$path =
$http_vars['__url_info__'];
list
($path, $is_slash) =
$this->_normalizePath($path);
$action_regexp_index =
null;
foreach ($action_map as $key =>
$value) {
$match_length =
strlen($value['path']);
if (strncmp($path, $value['path'], $match_length) !=
0) {
if ($path ==
$value['path']) {
// continue in case w/ incomplete match
if ($path !=
"" &&
$match_length >
0 &&
$path{$match_length} !=
"/") {
if ($is_slash &&
$path{strlen($path)-
1} ==
"/") {
if ($value['path_regexp']) {
foreach ($value['path_regexp'] as $index =>
$regexp) {
$action_regexp_index =
$index;
if (preg_match($value['path_regexp'], $path, $tmp)) {
$action_value =
$action_map[$action];
$path_ext =
is_null($action_regexp_index)
?
$action_value['path_ext']
:
$action_value['path_ext'][$action_regexp_index];
foreach ($path_ext as $key =>
$value) {
if (isset
($action_match[$n]) ==
false) {
// remove url (pre|suf)fix
if (isset
($value['url_prefix']) &&
$value['url_prefix'] !=
"") {
$s =
$value['url_prefix'];
if (isset
($value['url_suffix']) &&
$value['url_suffix'] !=
"") {
$s =
$value['url_suffix'];
$action_match[$n] =
substr($action_match[$n], 0, -
strlen($s));
if (isset
($value['form_prefix']) &&
$value['form_prefix'] !=
"") {
$action_match[$n] =
$value['form_prefix'] .
$action_match[$n];
if (isset
($value['form_suffix']) &&
$value['form_suffix'] !=
"") {
$action_match[$n] =
$action_match[$n] .
$value['form_suffix'];
if (isset
($value['input_filter']) &&
$value['input_filter'] !=
"") {
$method =
$value['input_filter'];
$action_match[$n] =
$this->$method($action_match[$n]);
$http_vars[$key] =
$action_match[$n];
function _normalizePath($path)
return array($path, false);
if ($path{strlen($path)-
1} ==
'/') {
return array($path, $is_slash);
$key =
sprintf('action_%s', $action);
$http_vars[$key] =
'true';
foreach ($query as $key =>
$value) {
foreach ($value as $k =>
$v) {
} else if (is_null($value) ==
false) {
Documentation generated on Fri, 11 Nov 2011 04:01:02 +0900 by phpDocumentor 1.4.3