Minahito
minah****@users*****
2006年 10月 13日 (金) 18:21:40 JST
Index: xoops2jp/html/modules/base/kernel/Legacy_PublicControllerStrategy.class.php diff -u xoops2jp/html/modules/base/kernel/Legacy_PublicControllerStrategy.class.php:1.1.2.6 xoops2jp/html/modules/base/kernel/Legacy_PublicControllerStrategy.class.php:1.1.2.7 --- xoops2jp/html/modules/base/kernel/Legacy_PublicControllerStrategy.class.php:1.1.2.6 Thu Oct 12 20:03:56 2006 +++ xoops2jp/html/modules/base/kernel/Legacy_PublicControllerStrategy.class.php Fri Oct 13 18:21:40 2006 @@ -1,7 +1,7 @@ <?php /** * @package Legacy - * @version $Id: Legacy_PublicControllerStrategy.class.php,v 1.1.2.6 2006/10/12 11:03:56 minahito Exp $ + * @version $Id: Legacy_PublicControllerStrategy.class.php,v 1.1.2.7 2006/10/13 09:21:40 minahito Exp $ */ if (!defined('XOOPS_ROOT_PATH')) exit(); @@ -21,63 +21,6 @@ } } - function setupModuleContext(&$context, $dirname) - { - $handler =& xoops_gethandler('module'); - $module =& $handler->getByDirname($dirname); - - if (!is_object($module)) { - return; - } - - $context->mModule =& $this->_createModule($module); - $context->mXoopsModule =& $context->mModule->getXoopsModule(); - - if ($context->mXoopsModule->get('hasconfig') == 1 || $context->mXoopsModule->get('hascomments') == 1) { - $handler =& xoops_gethandler('config'); - - $context->mModule->setModuleConfig($handler->getConfigsByCat(0, $context->mXoopsModule->get('mid'))); - $context->mModuleConfig = $context->mModule->getModuleConfig(); - } - - // - // Load Roles - // - Legacy_RoleManager::loadRolesByMid($context->mXoopsModule->get('mid')); - } - - /** - * Creates a instance of the module with the generating convention. And, - * returns it. - * @static - * @return Legacy_Module - */ - function &_createModule($module) - { - $instance = null; - $dirname = $module->get('dirname'); - - // - // IMPORTANT CONVENTION - // - $className = ucfirst($dirname) . "_Module"; - if (!class_exists($className)) { - $filePath = XOOPS_ROOT_PATH . "/modules/${dirname}/class/Module.class.php"; - if (file_exists($filePath)) { - require_once $filePath; - } - } - - if (class_exists($className)) { - $instance =& new $className($module); - } - else { - $instance =& new Legacy_ModuleAdapter($module); - } - - return $instance; - } - function setupBlock() { $showFlag =0; Index: xoops2jp/html/modules/base/kernel/Legacy_AdminControllerStrategy.class.php diff -u xoops2jp/html/modules/base/kernel/Legacy_AdminControllerStrategy.class.php:1.1.2.4 xoops2jp/html/modules/base/kernel/Legacy_AdminControllerStrategy.class.php:1.1.2.5 --- xoops2jp/html/modules/base/kernel/Legacy_AdminControllerStrategy.class.php:1.1.2.4 Thu Oct 12 20:03:56 2006 +++ xoops2jp/html/modules/base/kernel/Legacy_AdminControllerStrategy.class.php Fri Oct 13 18:21:40 2006 @@ -1,7 +1,7 @@ <?php /** * @package Legacy - * @version $Id: Legacy_AdminControllerStrategy.class.php,v 1.1.2.4 2006/10/12 11:03:56 minahito Exp $ + * @version $Id: Legacy_AdminControllerStrategy.class.php,v 1.1.2.5 2006/10/13 09:21:40 minahito Exp $ */ if (!defined('XOOPS_ROOT_PATH')) exit(); @@ -68,39 +68,7 @@ $dirname = 'base'; } - Legacy_PublicControllerStrategy::setupModuleContext($context, $dirname); - } - - /** - * Creates a instance of the module with the generating convention. And, - * returns it. - * @static - * @return Legacy_Module - */ - function &_createModule($module) - { - $instance = null; - $dirname = $module->get('dirname'); - - // - // IMPORTANT CONVENTION - // - $className = ucfirst($dirname) . "_AdminModule"; - if (!class_exists($className)) { - $filePath = XOOPS_ROOT_PATH . "/modules/${dirname}/admin/class/Module.class.php"; - if (file_exists($filePath)) { - require_once $filePath; - } - } - - if (class_exists($className)) { - $instance =& new $className($module); - } - else { - $instance =& new Legacy_ModuleAdapter($module); - } - - return $instance; + parent::setupModuleContext(&$context, $dirname); } function setupBlock() Index: xoops2jp/html/modules/base/kernel/Legacy_Module.class.php diff -u xoops2jp/html/modules/base/kernel/Legacy_Module.class.php:1.1.2.5 xoops2jp/html/modules/base/kernel/Legacy_Module.class.php:1.1.2.6 --- xoops2jp/html/modules/base/kernel/Legacy_Module.class.php:1.1.2.5 Thu Oct 12 20:03:56 2006 +++ xoops2jp/html/modules/base/kernel/Legacy_Module.class.php Fri Oct 13 18:21:40 2006 @@ -1,7 +1,7 @@ <?php /** * @package Legacy - * @version $Id: Legacy_Module.class.php,v 1.1.2.5 2006/10/12 11:03:56 minahito Exp $ + * @version $Id: Legacy_Module.class.php,v 1.1.2.6 2006/10/13 09:21:40 minahito Exp $ */ class Legacy_AbstractModule @@ -190,6 +190,14 @@ return $this->mCacheInfo; } + + /** + * This method is called by the controller strategy, if this module is the + * current module. + */ + function startup() + { + } function searchAction(&$searchArgs) { Index: xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php diff -u xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php:1.1.2.79.2.13 xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php:1.1.2.79.2.14 --- xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php:1.1.2.79.2.13 Thu Oct 12 20:03:56 2006 +++ xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php Fri Oct 13 18:21:40 2006 @@ -1,7 +1,7 @@ <?php /** * @package Legacy - * @version $Id: Legacy_Controller.class.php,v 1.1.2.79.2.13 2006/10/12 11:03:56 minahito Exp $ + * @version $Id: Legacy_Controller.class.php,v 1.1.2.79.2.14 2006/10/13 09:21:40 minahito Exp $ */ if (!defined('XOOPS_ROOT_PATH')) exit(); @@ -377,7 +377,8 @@ function _processModuleController() { if ($this->mRoot->mContext->mModule != null) { - if (!$this->mRoot->mContext->mModule->isActive()) { + $module =& $this->mRoot->mContext->mModule; + if (!$module->isActive()) { /** * Notify that the current user accesses none-activate module * controller. @@ -392,9 +393,10 @@ } $this->_mStrategy->setupModuleLanguage(); + $module->startup(); - $GLOBALS['xoopsModule'] =& $this->mRoot->mContext->mXoopsModule; - $GLOBALS['xoopsModuleConfig'] =& $this->mRoot->mContext->mModuleConfig; + $GLOBALS['xoopsModule'] =& $module->mXoopsModule; + $GLOBALS['xoopsModuleConfig'] =& $module->mModuleConfig; } } @@ -1254,17 +1256,67 @@ /** * Create some instances for the module process. * @param Legacy_HttpContext $context + * @param string $dirname */ - function setupModuleContext(&$context) + function setupModuleContext(&$context, $dirname) { + $handler =& xoops_gethandler('module'); + $module =& $handler->getByDirname($dirname); + + if (!is_object($module)) { + return; + } + + $context->mModule =& $this->_createModule($module); + $context->mXoopsModule =& $context->mModule->getXoopsModule(); + + if ($context->mXoopsModule->get('hasconfig') == 1 || $context->mXoopsModule->get('hascomments') == 1) { + $handler =& xoops_gethandler('config'); + + $context->mModule->setModuleConfig($handler->getConfigsByCat(0, $context->mXoopsModule->get('mid'))); + $context->mModuleConfig = $context->mModule->getModuleConfig(); + } + + // + // Load Roles + // + Legacy_RoleManager::loadRolesByMid($context->mXoopsModule->get('mid')); } /** * Gets the module object. * @return Legacy_Module */ - function &_createModule() + /** + * Creates a instance of the module with the generating convention. And, + * returns it. + * @param XoopsModule $module + * @return Legacy_Module + */ + function &_createModule($module) { + $instance = null; + $dirname = $module->get('dirname'); + + // + // IMPORTANT CONVENTION + // + $className = ucfirst($dirname) . "_Module"; + if (!class_exists($className)) { + $filePath = XOOPS_ROOT_PATH . "/modules/${dirname}/class/Module.class.php"; + if (file_exists($filePath)) { + require_once $filePath; + } + } + + if (class_exists($className)) { + $instance =& new $className($module); + } + else { + $instance =& new Legacy_ModuleAdapter($module); + } + + return $instance; } function setupBlock()