當前位置: 首頁>>代碼示例>>PHP>>正文


PHP router::controller方法代碼示例

本文整理匯總了PHP中router::controller方法的典型用法代碼示例。如果您正苦於以下問題:PHP router::controller方法的具體用法?PHP router::controller怎麽用?PHP router::controller使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在router的用法示例。


在下文中一共展示了router::controller方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 public static function execute()
 {
     if ($uri = trim(router::$uri, '/')) {
         router::$arguments = explode('/', $uri);
         router::$module = array_shift(router::$arguments);
         router::$controller = array_shift(router::$arguments);
         router::$action = array_shift(router::$arguments);
     } else {
         //當$uri 為空,則嘗試Query_string模式
         router::$arguments = $_GET;
         router::$module = arr::take('module', router::$arguments);
         router::$controller = arr::take('controller', router::$arguments);
         router::$action = arr::take('action', router::$arguments);
     }
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:15,代碼來源:router.php

示例2: execute

 /**
  * 解析URI
  * 
  * URI 由模塊名/控製器/動作/參數組成,采用如下的格式:
  *
  * @code php
  * module/controller/action/param1/vlaue1/param2/value2
  * @endcode
  *
  */
 public static function execute()
 {
     if ($uri = trim(router::$uri, '/')) {
         router::$arguments = explode('/', $uri);
         //分配module、controller、action
         router::$module = array_shift(router::$arguments);
         router::$controller = array_shift(router::$arguments);
         router::$action = array_shift(router::$arguments);
         //處理參數
         $arguments = array();
         for ($i = 0, $cnt = count(router::$arguments); $i < $cnt; $i++) {
             $arguments[$i] = rawurldecode(router::$arguments[$i]);
         }
         router::$arguments = $arguments;
         //unset($_GET['zotop']);
         //$_GET = array_merge($_GET, array('module'=>router::$module,'controller'=>router::$controller,'action'=>router::$action), $arguments);
     } else {
         //當$uri 為空,則嘗試Query_string模式
         router::$arguments = $_GET;
         router::$module = arr::take('module', router::$arguments);
         router::$controller = arr::take('controller', router::$arguments);
         router::$action = arr::take('action', router::$arguments);
     }
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:34,代碼來源:router.php

示例3: controller

 /**
  * 返回當前URL路由的控製器名稱,如果未能獲取路由分發的控製器,則獲取當前應用的默認路由
  *
  * @return string
  */
 public static function controller()
 {
     $controller = router::controller();
     if (empty($controller)) {
         $controller = application::$controller;
     }
     return $controller;
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:13,代碼來源:application.php

示例4: controller

 /**
  * 獲取當前的控製器的相關信息
  *
  * @return string
  */
 public static function controller($type = 'name')
 {
     switch ($type) {
         case 'name':
         case 'filename':
             $return = empty(self::$controller) ? 'index' : self::$controller;
             break;
         case 'path':
         case 'filepath':
             $return = module::setting(Router::module(), 'root') . DS . router::application() . DS . router::controller('filename') . '.php';
             break;
         case 'class':
         case 'classname':
             $return = empty(self::$controller) ? 'IndexController' : ucfirst(self::$controller) . 'Controller';
             break;
     }
     return $return;
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:23,代碼來源:router.php

示例5: controllerPath

 public static function controllerPath()
 {
     $controller = router::controller();
     if ($controller) {
         return zotop::module(router::module(), 'root') . DS . router::application() . DS . router::controller() . '.php';
     }
     return '';
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:8,代碼來源:router.php

示例6: getController

 /**
  * 返回當前URL路由的控製器名稱,如果未能獲取路由分發的控製器,則獲取當前應用的默認路由
  *
  * @return string
  */
 public static function getController()
 {
     $controller = router::controller();
     if (empty($controller)) {
         $controller = zotop::application(APP_NAME, 'controller');
     }
     return empty($controller) ? 'index' : $controller;
 }
開發者ID:dalinhuang,項目名稱:zotop,代碼行數:13,代碼來源:application.php

示例7: render

 /**
  *	渲染視圖同make
  */
 function render($name, $par = [])
 {
     if (static::$par) {
         $par = $par + static::$par;
     }
     $name = str_replace('.', '/', $name);
     if (substr($name, 0, 1) == '/') {
         $this->view_dir = $this->view_dir;
         $this->theme_dir = $this->theme_dir;
         $name = substr($name, 1);
     }
     $this->__ex($name);
     $m = router::controller()['module'];
     unset($n2);
     if ($m) {
         if (strpos($name, '/') !== false) {
             $name = substr($name, strpos($name, '/') + 1);
         }
         $n2 = BASE . '/' . static::$modulePath . '/' . $m . '/views/' . $name . '.php';
     }
     $this->block['content'] = $this->find([$this->theme_file, $this->view_file, $n2]);
     if (!static::$keep_dir) {
         static::$keep_dir = $this->block['content'];
     }
     ob_start();
     extract($par, EXTR_OVERWRITE);
     include $this->block['content'];
     if (file_exists($this->block['layout'])) {
         include $this->block['layout'];
     }
     $data = trim(ob_get_contents());
     ob_end_clean();
     if (true === static::$minify) {
         $data = preg_replace(array('/ {2,}/', '/<!--.*?-->|\\t|(?:\\r?\\n[\\t]*)+/s'), array(' ', ''), $data);
     }
     if (static::$cache !== false && static::$cache >= 0) {
         $url = static::cacheHtml();
         file_put_contents($url, $data);
     }
     return $data;
 }
開發者ID:samplecms,項目名稱:package,代碼行數:44,代碼來源:view.php

示例8: callcontroller

 static function callcontroller($controller, $vars, $right = false)
 {
     list($folder, $controller, $function) = explode('/', $controller);
     router::$controller = $controller;
     if (!class_exists($controller)) {
         include _BUNDLES_ . '/' . $folder . '/controllers/' . $controller . 'Controller.php';
     }
     $class = new $controller();
     $class->loadkernel();
     if ($right !== false && !isset($class->session->datas->rights->{$right})) {
         if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
             echo json_encode(array('success' => false, 'message' => 'Vous ne disposez pas des droits necessaires'));
             exit;
         } else {
             router::redirect('login');
         }
     }
     router::$views_path = _BUNDLES_ . '/' . $folder . '/views';
     $class->set('_VIEW_', router::$views_path);
     $class->set('_URL_', _URL_);
     call_user_func_array(array($class, $function . 'Action'), $vars);
 }
開發者ID:sebastian37,項目名稱:eMvc,代碼行數:22,代碼來源:router.php

示例9: url_array

function url_array()
{
    return router::controller();
}
開發者ID:samplecms,項目名稱:package,代碼行數:4,代碼來源:_function.php


注:本文中的router::controller方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。