本文整理汇总了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);
}
}
示例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);
}
}
示例3: controller
/**
* 返回当前URL路由的控制器名称,如果未能获取路由分发的控制器,则获取当前应用的默认路由
*
* @return string
*/
public static function controller()
{
$controller = router::controller();
if (empty($controller)) {
$controller = application::$controller;
}
return $controller;
}
示例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;
}
示例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 '';
}
示例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;
}
示例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;
}
示例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);
}
示例9: url_array
function url_array()
{
return router::controller();
}