当前位置: 首页>>代码示例>>PHP>>正文


PHP UrlHelper::uri方法代码示例

本文整理汇总了PHP中UrlHelper::uri方法的典型用法代码示例。如果您正苦于以下问题:PHP UrlHelper::uri方法的具体用法?PHP UrlHelper::uri怎么用?PHP UrlHelper::uri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UrlHelper的用法示例。


在下文中一共展示了UrlHelper::uri方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dispatch

 /**
  * Finds and loads a Controller for the given http request
  * @return boolean
  */
 public function dispatch()
 {
     include_once BOOTSTRAP_FILE;
     $this->_domain = $_SERVER['HTTP_HOST'];
     $this->_url = $_SERVER['REQUEST_URI'];
     $this->_args = $_GET;
     $route = $this->findCustomRoute();
     if ($route) {
         //handle custom route
         if ($route->isRedirect()) {
             RequestHelper::redirect($route->httpStatus, $route->redirectLocation);
         } else {
             include CONTROLLER_PATH . $route->controller . '/controller.php';
             $template = $route->controller . '/view';
             $controller = new page();
             $controller->set_view($template);
             $controller->set_args($route->pathVariables);
             $controller->get();
         }
     } else {
         //custom route not found, map url to filesystem
         //auto map subdomains to _subdomain_ folders
         $subdomain = str_replace(Config::get('NAKED_DOMAIN'), '', $this->_domain);
         $subdomainFolder = "";
         if (substr($subdomain, -1) == '.') {
             $subdomain = substr($subdomain, 0, -1);
         }
         if ($subdomain != Config::get('DEFAULT_SUBDOMAIN')) {
             //redirect naked domain to default subdomain, if necessary;
             if (empty($subdomain)) {
                 RequestHelper::redirect(UrlHelper::uri($this->_url));
                 die;
             } else {
                 $subdomainFolder = '_' . $subdomain . '_/';
                 if (!is_dir(CONTROLLER_PATH . $subdomainFolder)) {
                     if (is_dir(CONTROLLER_PATH . '_*_/')) {
                         include CONTROLLER_PATH . '_*_/controller.php';
                         $template = CONTROLLER_PATH . '_*_/view';
                         $controller = new page();
                         $controller->set_view($template);
                         $controller->set_args(array('subdomain' => $subdomain));
                         $controller->get();
                         die;
                     } else {
                         $this->throwError('404');
                     }
                 }
             }
         }
         //on default subdomain, so continue
         $path = UrlHelper::convertUrlToPath($this->_url);
         if (empty($path)) {
             if (is_dir(CONTROLLER_PATH . $subdomainFolder) && is_readable(CONTROLLER_PATH . $subdomainFolder . 'controller.php')) {
                 include CONTROLLER_PATH . $subdomainFolder . 'controller.php';
                 $template = $subdomainFolder . 'view';
             } else {
                 $this->throwError('404');
             }
         } elseif (is_dir(CONTROLLER_PATH . $subdomainFolder . $path) && is_readable(CONTROLLER_PATH . $subdomainFolder . $path . '/controller.php')) {
             include CONTROLLER_PATH . $subdomainFolder . $path . '/controller.php';
             $template = $subdomainFolder . $path . DS . 'view';
         } elseif (is_readable(CONTROLLER_PATH . $subdomainFolder . $path)) {
             $file = CONTROLLER_PATH . $subdomainFolder . $path;
             if (function_exists('finfo_open')) {
                 $finfo = finfo_open(FILEINFO_MIME_TYPE);
                 // return mime type ala mimetype extension
                 header("Content-type: " . finfo_file($finfo, $file));
                 finfo_close($finfo);
             } elseif (function_exists('mime_content_type')) {
                 header("Content-type: " . mime_content_type($file));
             } else {
                 header("Content-type: text/plain");
             }
             readfile($file);
             die;
         } else {
             $this->throwError('404');
             return false;
         }
         $controller = new page();
         $controller->set_view($template);
         $controller->get();
     }
     return true;
 }
开发者ID:robertgentel,项目名称:phpCornerstone,代码行数:89,代码来源:cs.php


注:本文中的UrlHelper::uri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。