[xoops-cvslog 3920] CVS update: xoops2jp/html/modules/base/kernel

Back to archive index

Minahito minah****@users*****
2006年 8月 4日 (金) 13:35:25 JST


Index: xoops2jp/html/modules/base/kernel/Legacy_ModuleController.class.php
diff -u xoops2jp/html/modules/base/kernel/Legacy_ModuleController.class.php:1.1.2.8 xoops2jp/html/modules/base/kernel/Legacy_ModuleController.class.php:1.1.2.9
--- xoops2jp/html/modules/base/kernel/Legacy_ModuleController.class.php:1.1.2.8	Thu Aug  3 18:42:06 2006
+++ xoops2jp/html/modules/base/kernel/Legacy_ModuleController.class.php	Fri Aug  4 13:35:25 2006
@@ -1,7 +1,7 @@
 <?php
 /**
  * @package legacy
- * @version $Id: Legacy_ModuleController.class.php,v 1.1.2.8 2006/08/03 09:42:06 minahito Exp $
+ * @version $Id: Legacy_ModuleController.class.php,v 1.1.2.9 2006/08/04 04:35:25 minahito Exp $
  */
 
 if (!defined('XOOPS_ROOT_PATH')) exit();
@@ -58,30 +58,69 @@
 			return;
 		}
 
-		$this->_createModuleObject();
+		//
+		// Set up module object
+		//
+		$this->setupModuleObject($this->_getDirName());
 			
-		if (!$this->isActive() && $this->_isActiveCheck()) {
+		if ($this->_isActiveCheck() && !$this->isActive()) {
 			return;
 		}
 
 		//
-		// Set config values for this module
+		// Setup render buffer.
 		//
-		if($this->mModuleObject!=null) {
-			if($this->mModuleObject->getVar('hasconfig')==1 || $this->mModuleObject->getVar('hascomments')==1) {
-				$configHandler=&xoops_gethandler('config');
-				$this->mConfig=&$configHandler->getConfigsByCat(0,$this->mModuleObject->getVar('mid'));
+		$this->setupRenderTarget();
+	}
+
+	/**
+	 * Create an object of the specified module, and set it to member property
+	 * $mModuleObject. And load the config of the module, too.
+	 * 
+	 * This member function is useful in the case that active module and
+	 * current module are different.
+	 * 
+	 * @param string $dirname
+	 * @see prepare()
+	 * @see setupRenderTarget()
+	 */	
+	function setupModuleObject($dirname)
+	{
+		$handler =& xoops_gethandler('module');
+		$this->mModuleObject =& $handler->getByDirname($dirname);
+		
+		if ($this->mModuleObject != null) {
+			if ($this->mModuleObject->get('hasconfig') == 1 || $this->mModuleObject->get('hascomments') == 1) {
+				$configHandler =& xoops_gethandler('config');
+				$this->mConfig =& $configHandler->getConfigsByCat(0, $this->mModuleObject->get('mid'));
 			}
-			
-			define('__XC_DIRNAME__', $this->mModuleObject->getVar('dirname'));
 		}
-		
-		//
-		// Setup render buffer.
-		//
+	}
+	
+	/**
+	 * Create an object of the render-target, and set it to member property
+	 * $mRenderTarget. If $dirname is empty, fetch dirname from current module
+	 * object and use it.
+	 * 
+	 * This member function is useful to regenerate the render-target. For
+	 * example, if active module and current module are different, the active
+	 * module needs regenerating the render-target.
+	 * 
+	 * @param string $dirname
+	 * @see prepare()
+	 */	
+	function setupRenderTarget($dirname = null)
+	{
 		$renderSystem =& $this->mController->mRoot->getRenderSystem($this->getRenderSystemName());
 		$this->mRenderTarget =& $renderSystem->createRenderTarget(XCUBE_RENDER_TARGET_TYPE_MAIN);
-		$this->mRenderTarget->setModuleName($this->mModuleObject->get('dirname'));
+		if ($dirname == null) {
+			if (is_object($this->mModuleObject)) {
+				$this->mRenderTarget->setModuleName($this->mModuleObject->get('dirname'));
+			}
+		}
+		else {
+			$this->mRenderTarget->setModuleName($dirname);
+		}
 	}
 
 	/**
@@ -142,10 +181,15 @@
 	    return (isset($url_arr[2])) ? $url_arr[2] : null;
 	}
 	
-	function setupLanguage()
+	function setupLanguage($dirname = null)
 	{
-		$languageManager=&$this->mController->mRoot->getLanguageManager();
-		$languageManager->loadModuleMessageCatalog($this->mModuleObject->getVar('dirname'));
+		$languageManager =& $this->mController->mRoot->getLanguageManager();
+		if ($dirname == null) {
+			$languageManager->loadModuleMessageCatalog($this->mModuleObject->getVar('dirname'));
+		}
+		else {
+			$languageManager->loadModuleMessageCatalog($dirname);
+		}
 	}
 	
 	function _processErrorModuleNotExist()


xoops-cvslog メーリングリストの案内
Back to archive index