Minahito
minah****@users*****
2006年 6月 22日 (木) 14:36:29 JST
Index: xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php diff -u xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php:1.1.2.39 xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php:1.1.2.40 --- xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php:1.1.2.39 Mon May 29 16:33:36 2006 +++ xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php Thu Jun 22 14:36:29 2006 @@ -26,8 +26,24 @@ var $mDialogMode=false; + /** + * @todo Rename this with "mModule" + */ + var $mModuleController = null; + + /** + * @var XCube_Deleagate + */ + var $mSiteLogin = null; + function Legacy_Controller() { + // + // Setup member properties as member delegates. + // + $this->mSiteLogin =& new XCube_NewDelegate(); + $this->mSiteLogin->register("Site.Login"); + set_magic_quotes_runtime(0); // ^^; // @@ -62,9 +78,6 @@ $this->_setupFilterChain(); $this->_processFilter(); - $this->mRoot->setEventManager($this->_createEventManager()); - $this->mRoot->setServiceManager($this->_createServiceManager()); - // ^^; $this->_setupErrorHandler(); @@ -148,42 +161,23 @@ */ function _setupFilterChain() { - require_once XOOPS_ROOT_PATH."/modules/base/preload/protectorLE/protectorLE.class.php"; - $protector=new protectorLE_Filter($this); - $this->addActionFilter($protector); - - require_once XOOPS_ROOT_PATH."/modules/base/preload/IPbanning/IPbanning.class.php"; - $ipban=new IPbanning_Filter($this); - $this->addActionFilter($ipban); - - require_once XOOPS_ROOT_PATH."/modules/base/preload/SiteClose/SiteClose.class.php"; - $siteclose = new SiteClose_Filter($this); - $this->addActionFilter($siteclose); - - require_once XOOPS_ROOT_PATH."/modules/base/preload/ThemeSelect/ThemeSelect.class.php"; - $themeselect = new ThemeSelect_Filter($this); - $this->addActionFilter($themeselect); + $primaryPreloads = $this->mRoot->getSiteConfig('Legacy.PrimaryPreloads'); + foreach ($primaryPreloads as $className => $classPath) { + if (file_exists(XOOPS_ROOT_PATH . $classPath)) { + require_once XOOPS_ROOT_PATH . $classPath; + if (class_exists($className)) { + $filter =& new $className($this); + $this->addActionFilter($filter); + unset($filter); + } + } + } // // Auto pre-loading. // - if($this->mRoot->getSiteConfig('Legacy','AutoPreload')==1) { - $dir=XOOPS_ROOT_PATH."/preload/"; - if(is_dir($dir)) { - if($handler=opendir($dir)) { - while(($file=readdir($handler))!==false) { - if(preg_match("/(\w+)\.class\.php$/",$file,$matches)) { - require_once $dir.$file; - $className=$matches[1]; - if(class_exists($className)) { - $instance =& new $className($this); - $this->addActionFilter($instance); - } - } - } - closedir($handler); - } - } + if($this->mRoot->getSiteConfig('Legacy', 'AutoPreload')==1) { + $this->_executePreload(XOOPS_ROOT_PATH . "/preload"); } } @@ -314,18 +308,13 @@ function _setupUser() { - $eventManager=&$this->mRoot->getEventManager(); - if($eventManager!=null) { - $eventArgs= new LoginEventArgs(); - $eventManager->raiseEvent("Site.Login",$this,$eventArgs); - - if($eventArgs->hasXoopsUser()) - $this->mXoopsUser=&$eventArgs->getXoopsUser(); - } - + $xoopsUser = null; + $this->mSiteLogin->call(new XCube_Ref($xoopsUser)); + // Set instance to global variable for compatiblity with XOOPS 2.0.x - $GLOBALS['xoopsUser']=&$this->mXoopsUser; - $GLOBALS['xoopsUserIsAdmin'] = is_object($this->mXoopsUser) ? $this->mXoopsUser->isAdmin(1) : false; //@todo Remove '1' + $this->mXoopsUser =& $xoopsUser; + $GLOBALS['xoopsUser'] =& $xoopsUser; + $GLOBALS['xoopsUserIsAdmin'] = is_object($xoopsUser) ? $xoopsUser->isAdmin(1) : false; //@todo Remove '1' // // Set member handler to global variables for compatibility with XOOPS 2.0.x. @@ -418,21 +407,24 @@ // // Auto pre-loading for Module. // - if($this->mRoot->getSiteConfig('Legacy','AutoPreload')==1) { + if ($this->mRoot->getSiteConfig('Legacy', 'AutoPreload') == 1) { $moduleHandler =& xoops_gethandler('module'); $moduleObjects =& $moduleHandler->getObjects(); - foreach($moduleObjects as $moduleObject) { + foreach ($moduleObjects as $moduleObject) { $mod_dir = $moduleObject->getVar('dirname'); - $dir = XOOPS_ROOT_PATH.'/modules/'.$mod_dir.'/class/'; + $dir = XOOPS_ROOT_PATH . '/modules/' . $mod_dir . '/preload/'; if(is_dir($dir)) { - $files = glob($dir.'modulePreload*.class.php'); + $files = glob($dir.'*.class.php'); if (is_array($files)) { foreach($files as $file) { require_once $file; - $className=preg_replace('/^modulePreload(\w*)\.class\.php/', $mod_dir.'ModulePreload\1', basename($file)); - if(class_exists($className)) { - $instance =& new $className($this); - $this->addActionFilter($instance); + if (preg_match("/(\w+)\.class\.php/", $file, $matches)) { + $className = ucfirst($mod_dir) . "_" . $matches[1]; + + if (class_exists($className)) { + $instance =& new $className($this); + $this->addActionFilter($instance); + } } } } @@ -485,6 +477,16 @@ 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); + parent::executeHeader(); // @@ -626,17 +628,6 @@ { $manager=&parent::_createEventManager(); - // - // TODO We should stop hard-cording in the following lines. - // - - require_once XOOPS_ROOT_PATH."/modules/user/kernel/UserEventProxyRegister.class.php"; - $manager->addProxyRegister(new UserEventProxyRegister()); - $manager->add("Site.Login",new XCube_Delegate("UserCommonEventFunction","Login")); // TODO - - require_once XOOPS_ROOT_PATH."/modules/pm/kernel/PmEventProxyRegister.class.php"; - $manager->addProxyRegister(new PmEventProxyRegister()); - require_once XOOPS_ROOT_PATH."/modules/base/kernel/MiscEventFunctions.class.php"; $manager->setAnchorDelegate("Legacypage.Misc.Access", new XCube_Delegate("Legacy_MiscEventFunction","AccessToMisc")); @@ -645,33 +636,27 @@ $manager->setAnchorDelegate("Legacypage.Backend.Access", new XCube_Delegate("Legacy_EventFunction", "AccessToBackend")); $manager->setAnchorDelegate("Legacypage.Search.Access", new XCube_Delegate("Legacy_EventFunction", "AccessToSearch")); - // - // We write the following lines for test here. - // -// require_once XOOPS_ROOT_PATH."/modules/comment/event/CommentEventProxyRegister.class.php"; -// $manager->addProxyRegister(new CommentEventProxyRegister()); - - $manager->setAnchorDelegate("Site.CheckLogin",new XCube_InstanceDelegate($this,"eventCheckLogin")); - $manager->setAnchorDelegate("Site.Logout",new XCube_InstanceDelegate($this,"eventLogout")); + $manager->setAnchorDelegate("Site.CheckLogin", new XCube_InstanceDelegate($this, "eventCheckLogin")); + $manager->setAnchorDelegate("Site.Logout", new XCube_InstanceDelegate($this, "eventLogout")); return $manager; } + + function &_createDelegateManager() + { + $manager =& parent::_createDelegateManager(); + $manager->add("Site.Login", "UserCommonEventFunction::NewLogin"); + + return $manager; + } function &_createServiceManager() { - $manager=&parent::_createServiceManager(); + $manager =& parent::_createServiceManager(); - // - // TODO : Now, we register services we specified. However, this process should be customized by user. - // - require_once XOOPS_ROOT_PATH."/modules/pm/service/LegacyPmService.class.php"; - $service=new LegacyPmService(); - $manager->addXCubeService("PrivateMessage",$service); - unset($service); - - require_once XOOPS_ROOT_PATH."/modules/base/service/LegacySearchService.class.php"; - $service=new LegacySearchService(); - $manager->addXCubeService("LegacySearch",$service); + require_once XOOPS_ROOT_PATH . "/modules/base/service/LegacySearchService.class.php"; + $service =& new LegacySearchService(); + $manager->addXCubeService("LegacySearch", $service); unset($service); return $manager;