⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 controller.php

📁 a short sketch about linux syntex lines.
💻 PHP
字号:
<?php/*秀影视频点播系统框架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;	}	/*	运行输出内容	*/	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;	}	/*设置允许访问的控制器规则*/	public function allow( $list = null ) {		$this->allowcontrl = $list;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -