Minahito
minah****@users*****
2006年 6月 22日 (木) 14:31:29 JST
Index: xoops2jp/html/kernel/XCube_Controller.class.php diff -u xoops2jp/html/kernel/XCube_Controller.class.php:1.1.2.9 xoops2jp/html/kernel/XCube_Controller.class.php:1.1.2.10 --- xoops2jp/html/kernel/XCube_Controller.class.php:1.1.2.9 Tue May 16 21:59:36 2006 +++ xoops2jp/html/kernel/XCube_Controller.class.php Thu Jun 22 14:31:29 2006 @@ -2,11 +2,12 @@ if (!defined('XOOPS_ROOT_PATH')) exit(); -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"; +require_once XOOPS_ROOT_PATH . "/class/XCube_ActionFilter.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"; + +require_once XOOPS_ROOT_PATH . "/kernel/XCube_Delegate.class.php"; /** * Virtual front controller class @@ -53,8 +54,6 @@ */ var $mLanguage; - var $mModuleController; - var $mRenderSystem; /** @@ -72,9 +71,16 @@ function prepare(&$root) { $this->mRoot=&$root; + + $this->mRoot->setEventManager($this->_createEventManager()); + $this->mRoot->setDelegateManager($this->_createDelegateManager()); + $this->mRoot->setServiceManager($this->_createServiceManager()); } /** + * This member function is actual initialize process of web application. + * Some Nuke-like bases call this function at any timing. + * * @access public */ function executeCommon() @@ -85,9 +91,6 @@ $this->_setupFilterChain(); $this->_processFilter(); - $this->mRoot->setEventManager($this->_createEventManager()); - $this->mRoot->setServiceManager($this->_createServiceManager()); - // ^^; $this->_setupErrorHandler(); @@ -220,7 +223,6 @@ function _setupModuleController() { - $this->mModuleController=new XCube_ModuleController($this); } /** @@ -276,20 +278,15 @@ /** - * This method create RenderSystem and set it to own property. + * Usually this member function is called after executeCommon(). But, some + * cases don't call this. Therefore, the page controller type base should + * not write the indispensable code here. For example, this is good to call + * blocks. + * + * @return void */ function executeHeader() { - // - // TODO Now, I done for working admin panel. - // - $renderSystem =& $this->mRoot->getRenderSystem($this->mModuleController->getDependRenderSystem()); - - // TODO - $this->mRenderSystem =& $renderSystem; - - $this->mRenderSystem->prepare($this); - $this->_setupBlock(); $this->_processBlock(); } @@ -351,6 +348,17 @@ $eventManager=new XCube_EventManager(); return $eventManager; } + + /** + * Create an instance of delegate manager and return it. + * + * @return XCube_DelegateManager + */ + function &_createDelegateManager() + { + $delegateManager =& new XCube_DelegateManager(); + return $delegateManager; + } function &_createServiceManager() { @@ -421,6 +429,36 @@ { // TODO } + + /** + * This is utility member function for the sub-class controller. Load files + * with the rule from $path, and add the instance of the sub-class to the + * chain. + * + * @access protected + * @param $path string Absolute path. + */ + function _executePreload($path) + { + $path = $path . "/"; + + if (is_dir($path)) { + if ($handler = opendir($path)) { + while (($file = readdir($handler)) !== false) { + if (preg_match("/(\w+)\.class\.php/", $file, $matches)) { + require_once $path . $file; + $className = $matches[1]; + + if (class_exists($className)) { + $instance =& new $className($this); + $this->addActionFilter($instance); + } + } + } + closedir($handler); + } + } + } } ?> \ No newline at end of file