Minahito
minah****@users*****
2005年 11月 29日 (火) 16:18:26 JST
Index: xoops2jp/html/class/XCube_Controller.class.php diff -u xoops2jp/html/class/XCube_Controller.class.php:1.1.2.17 xoops2jp/html/class/XCube_Controller.class.php:removed --- xoops2jp/html/class/XCube_Controller.class.php:1.1.2.17 Tue Nov 29 16:13:04 2005 +++ xoops2jp/html/class/XCube_Controller.class.php Tue Nov 29 16:18:26 2005 @@ -1,462 +0,0 @@ -<?php - -require_once XOOPS_ROOT_PATH."/class/XCube_ActionFilter.class.php"; -require_once XOOPS_ROOT_PATH."/class/XCube_ModuleController.class.php"; -require_once XOOPS_ROOT_PATH."/class/XCube_BlockProcedure.class.php"; -require_once XOOPS_ROOT_PATH."/class/XCube_RenderSystem.class.php"; -require_once XOOPS_ROOT_PATH."/class/XCube_EventArgs.class.php"; - -/** - * Virtual front controller class - */ -class XCube_Controller -{ - var $mRoot; - - var $mBlockChain; - var $mFilterChain; - - /** - * XoopsLogger Instance - * @access protected - */ - var $mLogger; - - /** - * XoopsErrorHandler instance - * @access protected - */ - var $mErrorHandler; - - - /** - * Database instance - * @access protected - */ - var $mDB; - - /** - * Array - * @access protected - */ - var $mConfig; - - var $mDebugger; - - var $mUser; - - - /** - * @access public - */ - var $mLanguage; - - var $mModuleController; - - var $mRenderSystem; - - /** - * Instance to implement the action process of this controller - * @access private - */ - var $mActionStrategy=null; - - function XCube_Controller(&$root) - { - $this->mRoot=&$root; - $this->mBlockChain=array(); - $this->mFilterChain=array(); - } - - /** - * @access public - */ - function executeCommon() - { - // - // Setup Filter chain and execute the process of these filters. - // - $this->_setupFilterChain(); - $this->_processFilter(); - - $this->mRoot->setEventManager($this->_createEventManager()); - $this->mRoot->setServiceManager($this->_createServiceManager()); - - // ^^; - $this->_setupErrorHandler(); - - $this->_setupEnvironment(); - - $this->_setupLogger(); - - $this->_setupDB(); - - $this->_setupConfig(); - - $this->_setupDebugger(); - - $this->_processPreBlockFilter(); // What's !? - - $this->mRoot->setLanguageManager($this->_createLanguageManager()); - - $this->_processHostAbstractLayer(); - - $this->_setupSession(); - - $this->_setupUser(); - - $this->_setupModuleController(); - - $this->_setupRenderSystem(); - - $this->_processModuleController(); - } - - /** - * Create filter chain. - * @access protected - */ - function _setupFilterChain() - { - } - - function addActionFilter(&$filter) - { - $this->mFilterChain[]=&$filter; - } - - /** - * Create the instance of XoopsErrorHandler class, and set it to member property. - * @access protected - */ - function _setupErrorHandler() - { - // - // TODO Depens on legacy. - // - require_once XOOPS_ROOT_PATH.'/class/errorhandler.php'; - $this->mErrorHandler=&XoopsErrorHandler::getInstance(); - $this->mErrorHandler->activate(true); - } - - function _setupEnvironment() - { - require_once XOOPS_ROOT_PATH."/include/version.php"; - } - - /** - * Create the instance of XoopsLogger class, and set it to member property. - * @access private - */ - function _setupLogger() - { - // - // TODO Depens on legacy. - // - require_once XOOPS_ROOT_PATH.'/class/logger.php'; - $this->mLogger=&XoopsLogger::instance(); - $this->mLogger->startTime(); - } - - /** - * Create the instance of DataBase class, and set it to member property. - * @access protected - */ - function _setupDB() - { - // - // TODO Depens on legacy. - // - if(!defined('XOOPS_XMLRPC')) - define('XOOPS_DB_CHKREF', 1); - else - define('XOOPS_DB_CHKREF', 0); - - require_once XOOPS_ROOT_PATH.'/class/database/databasefactory.php'; - - if ($_SERVER['REQUEST_METHOD'] != 'POST' || !xoops_refcheck(XOOPS_DB_CHKREF)) { - define('XOOPS_DB_PROXY', 1); - } - - $this->mDB =& XoopsDatabaseFactory::getDatabaseConnection(); - } - - /** - * @access public - */ - function &getDB() - { - return $this->mDB; - } - - function _setupConfig() - { - // - // TODO Depens on legacy. - // - $configHandler=&xoops_gethandler('config'); - $this->mConfig=&$configHandler->getConfigsByCat(XOOPS_CONF); - } - - /** - * Set debbuger object to member property. - * @return void - */ - function _setupDebugger() - { - error_reporting(0); - - // - // TODO Depens on base. - // - require_once XOOPS_BASE_PATH."/class/debug/XoopsDebugManager.class.php"; - - $debug_mode = $this->mConfig['debug_mode']; - if(defined("OH_MY_GOD_HELP_ME")) - $debug_mode = XOOPS_DEBUG_PHP; - - $this->mDebugger=&XoopsDebuggerManager::getInstance($this->mConfig['debug_mode']); - $this->mDebugger->setup(); - } - - function &_createLanguageManager() - { - require_once XOOPS_ROOT_PATH."/class/XCube_LanguageManager.class.php"; - $languageManager=new XCube_LanguageManager($this->mConfig['language']); - return $languageManager; - } - - /** - * We need this method really?? - */ - function _processHostAbstractLayer() - { - } - - /** - * Setup handler for session, then start session. - * @return void - */ - function _setupSession() - { - global $xoopsDB; - - $sessionHandler=&xoops_gethandler('session'); - - session_set_save_handler( - array(&$sessionHandler,"open"), - array(&$sessionHandler,"close"), - array(&$sessionHandler, 'read'), - array(&$sessionHandler, 'write'), - array(&$sessionHandler, 'destroy'), - array(&$sessionHandler, 'gc')); - - session_start(); - } - - function _setupUser() - { - $eventManager=&$this->mRoot->getEventManager(); - if($eventManager!=null) { - $eventArgs= new LoginEventArgs(); - $eventManager->raiseEvent("Site.Login",$this,$eventArgs); - - if($eventArgs->hasUser()) - $this->mUser=&$eventArgs->getUser(); - } - } - - function _setupModuleController() - { - $this->mModuleController=new XCube_ModuleController($this); - } - - /** - * Return module controller. - * @return XCube_ModuleController - */ - function &getModuleController() - { - return $this->mModuleController; - } - - /** - * @return bool We have to return boolean in this method really?? - * @todo move this method to Base_Controller - */ - function _processModuleController() - { - $this->mModuleController->prepare(); - - if($this->mModuleController->isModuleProcess()) { - if(!$this->mModuleController->isActive()) - exit(); ///< @todo - - if(!$this->mModuleController->isPermission()) - XCube_Utils::redirectHeader(XOOPS_URL,1,_NOPERM); // TODO Depens on const message catalog. - - $this->mModuleController->setupLanguage(); - - return true; - } - - return false; - } - - /** - * Return logger instance. - * @return Object - */ - function &getLogger() - { - return $this->mLogger; - } - - - /** - * Return logger instance. - * @return XoopsErrorHandler - */ - function &getErrorHandler() - { - return $this->mErrorHandler; - } - - - /** - * This method create RenderSystem and set it to own property. - */ - function executeHeader() - { - // - // TODO Now, I done for working admin panel. - // - $this->mRenderSystem->prepare(); - - - $this->_setupBlock(); - $this->_processBlock(); - } - - /** - * This method only show you the concept process of this system. - * @return void - */ - function execute() - { - // $this->executeCommon(); - // $this->executeHeader(); - } - - function getConfig($id=null) - { - if($id) { - return $this->mConfig[$id]; - } - else { - return $this->mConfig; - } - } - - - function _processFilter() - { - foreach($this->mFilterChain as $filter) { - $filter->preFilter($this); ///< @todo I must change to call method directly. - } - } - - function _setupBlock() - { - } - - function _processBlock() - { - $i=0; - foreach($this->mBlockChain as $blockProcedure) { - $blockProcedure->execute($this,$this->getUser()); - if($blockProcedure->hasResult()) { - $this->mRenderSystem->renderBlock($blockProcedure); - } - unset($blockProcedure); - } - } - - function _processPreBlockFilter() - { - foreach($this->mFilterChain as $filter) { - $filter->preBlockFilter($this); - } - } - - function &_createEventManager() - { - require_once XOOPS_ROOT_PATH."/class/XCube_EventManager.class.php"; - $eventManager=new XCube_EventManager(); - return $eventManager; - } - - function &_createServiceManager() - { - require_once XOOPS_ROOT_PATH."/class/XCube_ServiceManager.class.php"; - $serviceManager=new XCube_ServiceManager(); - return $serviceManager; - } - - function &getDebugger() - { - return $this->mDebugger; - } - - /** - * Create and setup RenderSystem. - */ - function _setupRenderSystem() - { - $this->mRenderSystem=new XCube_RenderSystem($this); - $this->mRenderSystem->setup(); - } - - /** - * Retern RenderSystem - * @return XCube_RenderSystem - */ - function &getRenderSystem() - { - return $this->mRenderSystem; - } - - function executeView() - { - $this->mRenderSystem->display(); - } - - function setActionStrategy(&$actionStrategy) - { - $this->mActionStrategy=&$actionStrategy; - $this->mActionStrategy->prepare($this); - } - - /** - * @access protected - */ - function _processAction() - { - if($this->mActionStrategy!==null) // is_object - $this->mActionStrategy->execute($this); - } - - function executeAction() - { - $this->_processAction(); - } - - function executeForward($url) - { - // check header output - header("location: ".$url); - exit(); - } -} - -?> \ No newline at end of file