[xoops-cvslog 5007] CVS update: xoops2jp/html/modules/base/class

Back to archive index

Minahito minah****@users*****
2006年 10月 14日 (土) 02:51:41 JST


Index: xoops2jp/html/modules/base/class/Legacy_Utils.class.php
diff -u xoops2jp/html/modules/base/class/Legacy_Utils.class.php:1.1.2.1 xoops2jp/html/modules/base/class/Legacy_Utils.class.php:1.1.2.2
--- xoops2jp/html/modules/base/class/Legacy_Utils.class.php:1.1.2.1	Thu Sep 28 14:02:05 2006
+++ xoops2jp/html/modules/base/class/Legacy_Utils.class.php	Sat Oct 14 02:51:41 2006
@@ -1,7 +1,7 @@
 <?php
 /**
  * @package Legacy
- * @version $Id: Legacy_Utils.class.php,v 1.1.2.1 2006/09/28 05:02:05 minahito Exp $
+ * @version $Id: Legacy_Utils.class.php,v 1.1.2.2 2006/10/13 17:51:41 minahito Exp $
  */
 
 /**
@@ -41,6 +41,75 @@
 			return array('uninstalled' =>$uninstalledModules, 'disabled'=>$disabledModules, 'recommended'=>$recommendedModules);
 		}
 	}
+	
+	/**
+	 * 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;
+	}
+	
+	/**
+	 * Creates a instance of the block procedure with the generating convention.
+	 * And, returns it.
+	 * @static
+	 * @return Legacy_BlockProcedure
+	 */
+	function createBlockProcedure(&$block)
+	{
+		//
+		// IMPORTANT CONVENTION
+		//
+		$retBlock = null;
+		$func = $block->get('show_func');
+		if (substr($func, 0, 4) == 'cl::') {
+			$className = ucfirst($block->get('dirname')) . '_' . substr($func, 4);
+			if (!class_exists($className)) {
+				$filePath = XOOPS_ROOT_PATH . '/modules/' . $block->get('dirname') . '/blocks/' . $block->get('func_file');
+				if (!file_exists($filePath)) {
+					continue;
+				}
+				
+				require_once $filePath;
+				
+				if (!class_exists($className)) {
+					continue;
+				}
+			}
+				
+			$retBlock =& new $className($block);
+		}
+		else {
+			$retBlock =& new Legacy_BlockProcedureAdapter($block);
+		}
+		
+		return $retBlock;
+	}
 }
 
 ?>
\ No newline at end of file


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