/** * 重定向 * 特别: 如果 $this->redirect("http://www.sina.com"); 如果只有一个参数 并且 第二个参数没有 则直接重定向 */ public function redirect($arg0 = null, $arg1 = null, $arg2 = null, $arg3 = null) { if (is_string($arg0) && $arg1 === null) { $url = $arg0; } else { $url = WF_Application_Router::Instance()->urlWithDomain($arg0, $arg1, $arg2, $arg3); } header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $url); die; }
private static function _Dispath() { // 获取HTTP 请求体和返回体 $request = WF_Application_Request::Instance(); $response = WF_Application_Response::Instance(); // 路由管理器初始化 $router = WF_Application_Router::Instance(); // 进行路由 $router->router($request); // 请求分发器 try { WF_Application_Dispather::dispath($request, $response); } catch (Exception $ex) { self::$DispathError = $ex; // error controller show the error self::_dispathError(); //log error self::_errorLog($ex->getMessage()); } /** * 进行输出 */ $response->send(); }
private function _rewrite($data, $anchor) { if (self::$_htaccess === null) { $ht = file_get_contents(PUBLIC_PATH . '/.htaccess'); if (preg_match_all('/^\\s*RewriteRule\\s+(\\S*)\\s+\\S*\\s+\\[NC=(\\w*)\\]$/Um', $ht, $out)) { $tmp = array(); foreach ($out[1] as $v) { $tmp[] = str_replace(array('\\', '^', '$'), array('', '', ''), $v); } self::$_htaccess = array_combine($out[2], $tmp); } } $url = self::$_htaccess[$anchor]; foreach ($data as $d) { $url = preg_replace('/\\(.*\\)/U', $d, $url, 1); } return $url; //$tmp = explode('@', $map->$anchor); //$n = count($tmp)-1; //$uri = array(); //for($i = 0;$i < $n;$i++) { // $uri[] = $tmp[$i]; // $uri[] = $data[$i]; // if ($i + 1 === $n) $uri[] = $tmp[$n]; //} //return implode('', $uri); }
/** * url 生成器 * @param unknown_type $data * @param unknown_type $anchor */ public function url($arg0 = null, $arg1 = null, $arg2 = null, $arg3 = null) { return WF_Application_Router::Instance()->url($arg0, $arg1, $arg2, $arg3); }