示例#1
0
文件: Path.php 项目: hovenko/Madcow
 /**
  * 
  * @param DF_Web_Path $sub
  * @return DF_Web_Path
  */
 public function append_path($sub)
 {
     if (!$sub instanceof DF_Web_Path) {
         throw new DF_Error_InvalidArgumentException('sub', $sub, DF_Web_Path);
     }
     $sub_str = "{$sub}";
     if ($sub->is_absolute()) {
         $sub_str = substr($sub_str, 1);
     }
     $base_str = "{$this}";
     if (!$this->has_trailing_slash()) {
         $base_str .= "/";
     }
     $new_path = "{$base_str}{$sub_str}";
     return DF_Web_Path::fromString($new_path);
 }
示例#2
0
文件: Action.php 项目: hovenko/Madcow
 protected function prepare_path()
 {
     $path = NULL;
     if ($this->has('path')) {
         $path = $this->get('path');
     } else {
         $path = $this->get_name();
     }
     return DF_Web_Path::fromString("{$path}");
 }
示例#3
0
文件: Web.php 项目: hovenko/Madcow
 public function log_execution_time()
 {
     $time = $this->get_execution_time();
     $time = round($time, 3);
     $request = $this->request;
     $path = DF_Web_Path::fromString($request->get_path());
     self::$LOGGER->debug("Page processing time: {$time} seconds ({$path})");
 }
示例#4
0
 /**
  * @return DF_Web_Path
  */
 protected function prepare_path()
 {
     $path = DF_Web_Path::fromString($this->namespace);
     return $path;
 }
示例#5
0
文件: Action.php 项目: hovenko/Madcow
 public function get_private_path()
 {
     $name = $this->get_name();
     $ctrlpath = $this->controller_path;
     $private_path = "{$name}";
     if (strlen($private_path)) {
         $private_path = "/{$private_path}";
     }
     if ("{$ctrlpath}") {
         $private_path = "/{$ctrlpath}{$private_path}";
     }
     return DF_Web_Path::fromString($private_path);
 }
示例#6
0
 /**
  * 
  * @param DF_Web_Routing_Config_Action $config
  * @return DF_Web_Path
  */
 protected function prepare_path($config)
 {
     $stars = array();
     $captures = $this->captures;
     for ($i = 0; $i < $captures->get_numargs(); $i++) {
         $stars[] = "*";
     }
     $argspath = join("/", $stars);
     $path = $config->get_path();
     #if (!$path->is_absolute()) {
     #    $controller = new DF_Web_Path("/".$this->controller->get_path());
     #    $path = $controller->append_path($path);
     #}
     if ($argspath) {
         $path = $path->append_path(DF_Web_Path::fromString($argspath));
     }
     return $path;
 }
示例#7
0
文件: Part.php 项目: hovenko/Madcow
 public static function fromString($string)
 {
     $path = DF_Web_Path::fromString($string);
     return new DF_Web_Path_Part($path);
 }
示例#8
0
 /**
  * 
  * 
  * @param DF_Web_Path $path
  * @param DF_Web_Routing_ActionChain $chain
  * @return integer
  */
 protected static function chained_match($path, $chain)
 {
     if (!$path instanceof DF_Web_Path) {
         throw new DF_Error_InvalidArgumentException("path", $path, "DF_Web_Path");
     }
     if (!$chain instanceof DF_Web_Routing_ActionChain) {
         throw new DF_Error_InvalidArgumentException("chain", $chain, "DF_Web_Routing_ActionChain");
     }
     $action = $chain->get_endpoint();
     $a_path = $action->get_path_match();
     $a_args = $action->get_args();
     $a_parts = $a_path->get_path_parts();
     $a_numparts = count($a_parts);
     $parts = $path->get_path_parts();
     $numparts = count($parts);
     if ($numparts < $a_numparts) {
         #    return -1;
     }
     $rest = $parts;
     # FIXME For chains, dont do this for normal path actions
     foreach ($tmp = $chain->get_chain_list() as $_a) {
         $rest = self::eat_path_parts($_a, $rest);
     }
     $count = count($rest);
     if ($a_args instanceof DF_Web_Routing_ActionArgs_Any) {
         $count += 1000;
     }
     return $count;
 }