public function getBlock($blockname = '') { $_currentNameSpace = \fec\helpers\CModule::param("_currentNameSpace"); if (empty($_currentNameSpace)) { $message = "Modules Param '_currentNameSpace' is not set , you can set like fecadmin\\Module"; throw new \yii\web\HttpException(406, $message); } $modulesDir = "\\" . $_currentNameSpace . "\\block\\"; $url_key = \fec\helpers\CUrl::getUrlKey(); $url_key = trim($url_key, "/"); $url_key = substr($url_key, strpos($url_key, "/") + 1); $url_key_arr = explode("/", $url_key); if (!isset($url_key_arr[1])) { $url_key_arr[1] = 'index'; } if ($blockname) { $url_key_arr[count($url_key_arr) - 1] = ucfirst($blockname); } else { $url_key_arr[count($url_key_arr) - 1] = ucfirst($url_key_arr[count($url_key_arr) - 1]); } $block_space = implode("\\", $url_key_arr); $blockFile = $modulesDir . $block_space; //echo $blockFile;exit; return new $blockFile(); }
public function getCurrentControllerRoleKey() { # 进行权限验证 如果不满足权限,则停止执行。 $url_key = CUrl::getUrlKey(); $url_key = trim($url_key, "/"); $controller_role_key = ''; if ($url_key) { $url_key_arr = explode("/", $url_key); $action = $this->action->id; if ($url_key_arr[count($url_key_arr) - 1] == $action) { unset($url_key_arr[count($url_key_arr) - 1]); } $controller_role_key = "/" . implode("/", $url_key_arr); } return $controller_role_key; }