?? controller.php
字號:
<?php/*秀影視頻點播系統(tǒng)框架2.0取消了PATHINFO支持*/class Easy_Controller{ private $_viewsuffix; private $_basedir; private $_control; private $_viewdir; private $_methodname; private $_Request; public $view; private $_indexname; private $_loadClass; public $allowcontl; public function __construct(){ $this->view = new Easy_Controller_View(); $this->setMethod(); } public function setIndex( $indexname = 'index'){ $this->_indexname = $indexname; } /* 設置默認模板文件路徑 */ public function setViewPath( $dirname = 'view'){ $this->_viewdir = $dirname; } /*設置默認控制器名稱*/ public function setDefaultControl( $control = 'index' ){ if (isset($_GET['mod']) === false ){ $this->_control = strtolower($control); $_GET['mod'] = strtolower($control); }else{ $this->_control = strtolower($_GET['mod']); } } /*獲取控制器名稱*/ public function getControl(){ return $this->_control; } /*設置默認方法名*/ public function setMethod($method = 'index'){ if (isset($_GET['action'])){ $this->_methodname = strtolower($method); }else{ $_GET['action'] = strtolower($method); $this->_methodname = strtolower($method); } } /*獲取方法名*/ public function getMethod(){ return $this->_methodname; } /*設置基本路徑*/ public function setBaseDir($basedir='/'){ $this->_basedir = $basedir; } /* 設置模板后綴名稱 */ public function setViewSuffix( $ext = '.tpl'){ $this->_viewsuffix = $ext; } /* 運行輸出內(nèi)容 */ public function run(){ $mod = isset($_GET['mod']) ? $_GET['mod'] : $this->getControl(); $method = isset($_GET['action']) ? $_GET['action'] : $this->getMethod(); $classfile = ucfirst(strtolower($mod)).'Controller'; $this->view->viewPath = $this->_viewdir; $this->view->basedir = $this->_basedir; $this->view->installdir = $this->_basedir.$this->_indexname; define('INSTALLDIR', $this->view->installdir); $this->view->ViewSuffix = $this->_viewsuffix; $this->view->viewFile = $mod.DIRECTORY_SEPARATOR.$mod.'_'.$method; if( is_array( $this->allowcontrl ) ) { if(in_array(strtolower($mod), $this->allowcontrl) === false) { $classfile = 'IndexController'; $method = 'index'; } }elseif (is_array($this->denycontrl)){ if(in_array(strtolower($classfile), $this->allowcontrl) === true) { $classfile = 'IndexController'; $method = 'index'; } } if (is_array($this->_loadClass)){ $object = new $classfile ( array_merge(array('_View'=> &$this->view), $this->_loadClass)); }else{ $object = new $classfile ( array('_View'=> &$this->view)); } $action = $method.'Action'; $object->_Request = new Easy_Controller_Request(); $object->_View->_Request = $object->_Request; if ($object->$action() != true ){ return $this->view->render($this->view->viewFile); } } public function register($class){ $this->_loadClass = $class; } /*設置訪問權限*/ public function deny( $list = null) { $this->denycontrl = $list; } /*設置允許訪問的控制器規(guī)則*/ public function allow( $list = null ) { $this->allowcontrl = $list; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -