Minahito
minah****@users*****
2006年 10月 12日 (木) 20:03:56 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.5 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.5 Tue Oct 10 19:55:36 2006 +++ xoops2jp/html/modules/base/kernel/Legacy_PublicControllerStrategy.class.php Thu Oct 12 20:03:56 2006 @@ -1,7 +1,7 @@ <?php /** * @package Legacy - * @version $Id: Legacy_PublicControllerStrategy.class.php,v 1.1.2.5 2006/10/10 10:55:36 minahito Exp $ + * @version $Id: Legacy_PublicControllerStrategy.class.php,v 1.1.2.6 2006/10/12 11:03:56 minahito Exp $ */ if (!defined('XOOPS_ROOT_PATH')) exit(); @@ -24,18 +24,20 @@ function setupModuleContext(&$context, $dirname) { $handler =& xoops_gethandler('module'); - $context->mModule =& $this->_createModule(); - $context->mModule->mXoopsModule =& $handler->getByDirname($dirname); - $context->mXoopsModule =& $context->mModule->mXoopsModule; - - if ($context->mXoopsModule == null) { + $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->mModuleConfig =& $handler->getConfigsByCat(0, $context->mXoopsModule->get('mid')); - $context->mModuleConfig =& $context->mModule->mModuleConfig; + + $context->mModule->setModuleConfig($handler->getConfigsByCat(0, $context->mXoopsModule->get('mid'))); + $context->mModuleConfig = $context->mModule->getModuleConfig(); } // @@ -44,10 +46,36 @@ Legacy_RoleManager::loadRolesByMid($context->mXoopsModule->get('mid')); } - function &_createModule() + /** + * Creates a instance of the module with the generating convention. And, + * returns it. + * @static + * @return Legacy_Module + */ + function &_createModule($module) { - $module =& new Legacy_Module(); - return $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() @@ -111,6 +139,12 @@ return true; } + + function setupModuleLanguage() + { + $root =& XCube_Root::getSingleton(); + $root->mLanguageManager->loadModuleMessageCatalog($root->mContext->mXoopsModule->get('dirname')); + } } ?> \ No newline at end of file Index: xoops2jp/html/modules/base/kernel/Legacy_AdminControllerStrategy.class.php diff -u xoops2jp/html/modules/base/kernel/Legacy_AdminControllerStrategy.class.php:1.1.2.3 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.3 Fri Oct 6 18:47:36 2006 +++ xoops2jp/html/modules/base/kernel/Legacy_AdminControllerStrategy.class.php Thu Oct 12 20:03:56 2006 @@ -1,7 +1,7 @@ <?php /** * @package Legacy - * @version $Id: Legacy_AdminControllerStrategy.class.php,v 1.1.2.3 2006/10/06 09:47:36 minahito Exp $ + * @version $Id: Legacy_AdminControllerStrategy.class.php,v 1.1.2.4 2006/10/12 11:03:56 minahito Exp $ */ if (!defined('XOOPS_ROOT_PATH')) exit(); @@ -71,10 +71,36 @@ Legacy_PublicControllerStrategy::setupModuleContext($context, $dirname); } - function &_createModule() + /** + * Creates a instance of the module with the generating convention. And, + * returns it. + * @static + * @return Legacy_Module + */ + function &_createModule($module) { - $module =& new Legacy_AdminModule(); - return $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; } function setupBlock() @@ -157,6 +183,19 @@ return false; } + + function setupModuleLanguage() + { + $root =& XCube_Root::getSingleton(); + + $root->mContext->mXoopsModule->loadInfo($root->mContext->mXoopsModule->get('dirname')); + + if (isset($root->mContext->mXoopsModule->modinfo['cube_style']) && $root->mContext->mXoopsModule->modinfo['cube_style'] != false) { + $root->mLanguageManager->loadModuleMessageCatalog($root->mContext->mXoopsModule->get('dirname')); + } + $root->mLanguageManager->loadModuleAdminMessageCatalog($root->mContext->mXoopsModule->get('dirname')); + $root->mLanguageManager->loadModinfoMessageCatalog($root->mContext->mXoopsModule->get('dirname')); + } } ?> \ No newline at end of file Index: xoops2jp/html/modules/base/kernel/Legacy_Module.class.php diff -u xoops2jp/html/modules/base/kernel/Legacy_Module.class.php:1.1.2.4 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.4 Wed Oct 11 17:13:17 2006 +++ xoops2jp/html/modules/base/kernel/Legacy_Module.class.php Thu Oct 12 20:03:56 2006 @@ -1,10 +1,10 @@ <?php /** * @package Legacy - * @version $Id: Legacy_Module.class.php,v 1.1.2.4 2006/10/11 08:13:17 minahito Exp $ + * @version $Id: Legacy_Module.class.php,v 1.1.2.5 2006/10/12 11:03:56 minahito Exp $ */ -class Legacy_Module +class Legacy_AbstractModule { /** * Hash used free for this module. @@ -28,8 +28,9 @@ var $mRender = null; - function Legacy_Module() + function Legacy_AbstractModule(&$module) { + $this->setXoopsModule($module); } /** @@ -67,6 +68,48 @@ { return isset($this->mAttributes[$key]) ? $this->mAttributes[$key] : null; } + + /** + * Sets a instance of XoopsModule to the property. + * @param XoopsModule $xoopsModule + */ + function setXoopsModule(&$xoopsModule) + { + $this->mXoopsModule =& $xoopsModule; + } + + /** + * Gets a instance of XoopsModule. + * @return XoopsModule + */ + function &getXoopsModule() + { + return $this->mXoopsModule; + } + + /** + * Sets array of xoops module config to the property. + * @param Array $config + */ + function setModuleConfig($config) + { + $this->mModuleConfig = $config; + } + + /** + * Gets a value form xoops module config with $key. If $key is specified + * null, returns array. + * @param string $key + * @return mixed + */ + function getModuleConfig($key = null) + { + if ($key == null) { + return $this->mModuleConfig; + } + + return isset($this->mModuleConfig[$key]) ? $this->mModuleConfig[$key] : null; + } function &getCacheInfo() { @@ -119,12 +162,6 @@ return $this->mXoopsModule->get('isactive') ? true : false; } - function setupLanguage() - { - $root =& XCube_Root::getSingleton(); - $root->mLanguageManager->loadModuleMessageCatalog($this->mXoopsModule->getVar('dirname')); - } - /** * Gets a value indicating whether the current module has a option of * configurations to use the cache system. @@ -153,26 +190,119 @@ return $this->mCacheInfo; } + + function searchAction(&$searchArgs) + { + } } -class Legacy_AdminModule extends Legacy_Module +class Legacy_ModuleAdapter extends Legacy_AbstractModule { - function setupLanguage() + function searchAction(&$searchArgs) { - $root =& XCube_Root::getSingleton(); + if(!is_object($searchArgs)) { + return; + } + + $this->mXoopsModule->loadAdminMenu(); + if(count($this->mXoopsModule->adminmenu) == 0 && !isset($this->mXoopsModule->modinfo['config']) ) { + return; + } + + // + // Search preference + // + if(isset($this->mXoopsModule->modinfo['config'])&&count($this->mXoopsModule->modinfo['config'])>0) { + $configInfos=array(); + foreach($this->mXoopsModule->modinfo['config'] as $config) { + if(isset($config['title'])) + $configInfos[]=@constant($config['title']); + if(isset($config['description'])) + $configInfos[]=@constant($config['description']); + if(isset($config['options'])&&count($config['options'])>0) { + foreach($config['options'] as $key=>$val) { + $configInfos[]=$key; + } + } + } + + $findFlag=true; + foreach($searchArgs->getKeywords() as $word) { + $findFlag&=(stristr(implode(" ",$configInfos),$word)!==false); + } + + if($findFlag) { + $searchArgs->addRecord($this->mXoopsModule->getVar('name'), + XOOPS_URL.'/modules/base/admin/index.php?action=PreferenceEdit&confmod_id='.$this->mXoopsModule->getVar('mid'), + _PREFERENCES ); + } + } - $this->mXoopsModule->loadInfo($this->mXoopsModule->get('dirname')); + // + // Search AdminMenu + // + if(count($this->mXoopsModule->adminmenu)>0) { + foreach($this->mXoopsModule->adminmenu as $menu) { + $findFlag=true; + foreach($searchArgs->getKeywords() as $word) { + $tmpFlag=false; + $tmpFlag|=(stristr($menu['title'],$word)!==false); + + // Search keyword + if(isset($menu['keywords'])) { + $keyword=is_array($menu['keywords']) ? implode(" ",$menu['keywords']) : $menu['keywords']; + $tmpFlag|=(stristr($keyword,$word)!==false); + } + + $findFlag&=$tmpFlag; + } + + if($findFlag) { + // + // Create url string with absolute information. + // + $url=""; + if(isset($menu['absolute'])&&$menu['absolute']) { + $url=$menu['link']; + } + else { + $url=XOOPS_URL."/modules/".$this->mXoopsModule->getVar('dirname')."/".$menu['link']; + } + + // + // Add record + // + $searchArgs->addRecord($this->mXoopsModule->getVar('name'),$url,$menu['title']); + } + } + } - if (isset($this->mXoopsModule->modinfo['cube_style']) && $this->mXoopsModule->modinfo['cube_style'] != false) { - $root->mLanguageManager->loadModuleMessageCatalog($this->mXoopsModule->get('dirname')); + // + // Search help + // + if ($this->mXoopsModule->hasHelp()) { + $root =& XCube_Root::getSingleton(); + $language = $root->mContext->getXoopsConfig('language'); + $helpfile = $this->mXoopsModule->getHelp(); + $dir = XOOPS_MODULE_PATH . "/" . $this->mXoopsModule->getVar('dirname') . "/language/" . $language; + + if (!file_exists($dir . "/" . $helpfile)) { + $dir = XOOPS_MODULE_PATH . "/" . $this->mXoopsModule->getVar('dirname') . "/language/" . $language; + if (!file_exists($dir . "/" . $helpfile)) { + return; + } + } + $lines = file($dir . "/" . $helpfile); + foreach ($lines as $line) { + foreach($searchArgs->getKeywords() as $word) { + if (stristr($line, $word) !== false) { + $url = XOOPS_MODULE_URL . "/base/admin/index.php?action=Help&dirname=" . $this->mXoopsModule->getVar('dirname'); + $searchArgs->addRecord($this->mXoopsModule->getVar('name'), $url, _HELP); + return; + } + } + } } - $root->mLanguageManager->loadModuleAdminMessageCatalog($this->mXoopsModule->get('dirname')); - $root->mLanguageManager->loadModinfoMessageCatalog($this->mXoopsModule->get('dirname')); - } - - function hasCacheConfig() - { - return false; } } 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.12 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.12 Wed Oct 11 17:13:40 2006 +++ xoops2jp/html/modules/base/kernel/Legacy_Controller.class.php Thu Oct 12 20:03:56 2006 @@ -1,7 +1,7 @@ <?php /** * @package Legacy - * @version $Id: Legacy_Controller.class.php,v 1.1.2.79.2.12 2006/10/11 08:13:40 minahito Exp $ + * @version $Id: Legacy_Controller.class.php,v 1.1.2.79.2.13 2006/10/12 11:03:56 minahito Exp $ */ if (!defined('XOOPS_ROOT_PATH')) exit(); @@ -391,7 +391,7 @@ $this->executeRedirect(XOOPS_URL . '/',1,_NOPERM); // TODO Depens on const message catalog. } - $this->mRoot->mContext->mModule->setupLanguage(); + $this->_mStrategy->setupModuleLanguage(); $GLOBALS['xoopsModule'] =& $this->mRoot->mContext->mXoopsModule; $GLOBALS['xoopsModuleConfig'] =& $this->mRoot->mContext->mModuleConfig; @@ -1304,6 +1304,10 @@ function enableAccess() { } + + function setupModuleLanguage() + { + } } ?> \ No newline at end of file