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

Back to archive index

Minahito minah****@users*****
2005年 12月 24日 (土) 15:46:05 JST


Index: xoops2jp/html/modules/base/class/Legacy_AdminRenderSystem.class.php
diff -u xoops2jp/html/modules/base/class/Legacy_AdminRenderSystem.class.php:1.1.2.9 xoops2jp/html/modules/base/class/Legacy_AdminRenderSystem.class.php:1.1.2.10
--- xoops2jp/html/modules/base/class/Legacy_AdminRenderSystem.class.php:1.1.2.9	Thu Dec 22 20:23:15 2005
+++ xoops2jp/html/modules/base/class/Legacy_AdminRenderSystem.class.php	Sat Dec 24 15:46:05 2005
@@ -1,184 +1,222 @@
-<?php
-
-//
-// TODO
-//
-require_once XOOPS_ROOT_PATH."/modules/legacyRender/kernel/Legacy_RenderSystem.class.php";
-
-define("LEGACY_ADMIN_RENDER_TEMPLATE_DIRNAME","templates");
-
-require_once XOOPS_ROOT_PATH."/class/smarty/Smarty.class.php";
-
-/**
- * This class extends Smarty to mediate the collision compiled file name.
- */
-class Legacy_AdminSmarty extends Smarty
-{
-	var $mModulePrefix = null;
-	
-	function Legacy_AdminSmarty()
-	{
-		parent::Smarty();
-
-		$this->compile_dir = XOOPS_COMPILE_PATH;
-		$this->left_delimiter = "<{";
-		$this->right_delimiter = "}>";
-
-		$this->register_modifier("theme", "Legacy_modifier_theme");
-	}
-	
-	function setModulePrefix($prefix)
-	{
-		$this->mModulePrefix = $prefix;
-	}
-	
-	function _get_auto_filename($autoBase, $autoSource = null, $auotId = null)
-	{
-		$autoSource = $this->mModulePrefix . "_admin_" . $autoSource;
-		return parent::_get_auto_filename($autoBase, $autoSource, $auotId);
-	}
-}
-
-/**
- * [TODO]
- * We depends on Legacy_RenderSystem that a add-in module defines. We must stop
- * this situation.
- */
-class Legacy_AdminRenderSystem extends Legacy_RenderSystem
-{
-	var $mSmarty;
-	
-	function prepare()
-	{
-		$this->mSmarty=new Legacy_AdminSmarty();
-
-		$this->mSmarty->assign(array("xoops_url"=>XOOPS_URL,
-		                              "xoops_rootpath"=>XOOPS_ROOT_PATH,
-		                              "xoops_langcode"=>_LANGCODE,
-		                              "xoops_charset"=>_CHARSET,
-		                              "xoops_version"=>XOOPS_VERSION,
-		                              "xoops_upload_url"=>XOOPS_UPLOAD_URL));
-
-	}
-	
-	function renderBlock(&$target)
-	{
-		$this->mSmarty->template_dir=XOOPS_ROOT_PATH."/modules/base/admin/templates/blocks";
-
-		foreach($target->getAttributes() as $key=>$value) {
-			$this->mSmarty->assign($key,$value);
-		}
-		
-		$this->mSmarty->setModulePrefix("base");
-		$result=&$this->mSmarty->fetch($target->getTemplateName());
-		$target->setResult($result);
-		
-		//
-		// Reset
-		//
-		foreach($target->getAttributes() as $key=>$value) {
-			$this->mSmarty->clear_assign($key);
-		}
-	}
-	
-	function renderTheme(&$target)
-	{
-		$this->mController->mDebugger->displayLog();
-
-		//
-		// Assign from attributes of the render-target.
-		//
-		foreach($target->getAttributes() as $key=>$value) {
-			$this->mSmarty->assign($key,$value);
-		}
-
-		$this->mSmarty->assign("currentModule",$this->mController->mModuleController->mModuleObject);
-
-		//
-		// Theme rendering
-		//
-		foreach($this->mBlockContents[0] as $result) {
-			$this->mSmarty->append('xoops_lblocks',$result);
-		}
-
-		$this->mSmarty->template_dir=XOOPS_ROOT_PATH."/themes/admin/";
-		$this->mSmarty->setModulePrefix("");
-		$result=$this->mSmarty->fetch("file:admin_theme.html");
-
-		$target->setResult($result);
-	}
-
-	function renderMain(&$target)
-	{
-		//
-		// Assign from attributes of the render-target.
-		//
-		foreach($target->getAttributes() as $key=>$value) {
-			$this->mSmarty->assign($key,$value);
-		}
-
-		$result=null;
-		if($target->getTemplateName()) {
-			$this->mSmarty->template_dir=$this->mController->mModuleController->getModuleDir() . "/". LEGACY_ADMIN_RENDER_TEMPLATE_DIRNAME;
-			$this->mSmarty->setModulePrefix($this->mController->mModuleController->getModuleDir());
-			$result=$this->mSmarty->fetch("file:".$this->mTemplateName);
-		}
-		else {
-			$result=$target->getAttribute("stdout_buffer");
-		}
-		
-		$target->setResult($result);
-	}
-}
-
-/**
- * Return URL string by "overriding" rule.
- * (Now, test implement)
- * 1) Search file in specified theme directory.
- * 2) Search file in current module template directory.
- * 3) Search file in fallback theme directory.
- */
-function Legacy_modifier_theme($string)
-{
-	$root =& XCube_Root::getSingleton();
-	$modController =& $root->mController->getModuleController();
-	$moduleObject =& $modController->getXoopsModule();
-
-	if (!is_object($moduleObject)) {
-		// TODO We must remove Hard-Coding
-		$themePath = XOOPS_THEME_PATH . "/admin/" . $string;
-		if (file_exists($themePath)) {
-			return XOOPS_THEME_URL . "/admin/" . $string;
-		}
-
-		// TEMP
-		// TODO We must return FALLBACK_URL here.
-		return "hoge";
-	}
-	else {
-		$dirname = $moduleObject->getVar('dirname');
-
-		// TODO We must remove Hard-Coding
-		$themePath = XOOPS_THEME_PATH . "/admin/modules/" . $dirname . "/" . $string;
-		if (file_exists($themePath)) {
-			return XOOPS_THEME_URL . "/admin/modules/" . $dirname . "/" . $string;
-		}
-
-		$themePath = XOOPS_THEME_PATH . "/admin/" . $string;
-		if (file_exists($themePath)) {
-			return XOOPS_THEME_URL . "/admin/" . $string;
-		}
-
-		$modulePath = XOOPS_MODULE_PATH . "/" . $moduleObject->getVar('dirname') . "/admin/templates/" . $string;
-
-		if (file_exists($modulePath)) {
-			return XOOPS_MODULE_URL . "/" . $moduleObject->getVar('dirname') . "/admin/templates/" . $string;
-		}
-
-		// TEMP
-		// TODO We must return FALLBACK_URL here.
-		return "fallback";
-	}
-}
-
+<?php
+
+//
+// TODO
+//
+require_once XOOPS_ROOT_PATH."/modules/legacyRender/kernel/Legacy_RenderSystem.class.php";
+
+define('LEGACY_ADMIN_RENDER_TEMPLATE_DIRNAME', "templates");
+define('_TMP_THEME_NAME', "admin");
+
+require_once XOOPS_ROOT_PATH."/class/smarty/Smarty.class.php";
+
+/**
+ * This class extends Smarty to mediate the collision compiled file name.
+ */
+class Legacy_AdminSmarty extends Smarty
+{
+	var $mModulePrefix = null;
+
+	//
+	// If you don't hope to override for theme, set false.
+	//
+	var $overrideMode = true;
+	
+	function Legacy_AdminSmarty()
+	{
+		parent::Smarty();
+
+		$this->compile_id = null;
+		$this->_canUpdateFromFile = true;
+		$this->compile_check = true;
+		$this->compile_dir = XOOPS_COMPILE_PATH;
+		$this->left_delimiter = "<{";
+		$this->right_delimiter = "}>";
+
+		$this->register_modifier("theme", "Legacy_modifier_theme");
+	}
+	
+	function setModulePrefix($prefix)
+	{
+		$this->mModulePrefix = $prefix;
+	}
+	
+	function _get_auto_filename($autoBase, $autoSource = null, $auotId = null)
+	{
+		$autoSource = $this->mModulePrefix . "_admin_" . $autoSource;
+		return parent::_get_auto_filename($autoBase, $autoSource, $auotId);
+	}
+
+	function _fetch_resource_info(&$params)
+	{
+		//
+		// Get dirname from root object.
+		//
+		$root =& XCube_Root::getSingleton();
+		$modController =& $root->mController->getModuleController();
+		$moduleObject =& $modController->getXoopsModule();
+		$dirname = $moduleObject->getVar('dirname');
+
+		$overridePath = XOOPS_THEME_PATH . "/" . _TMP_THEME_NAME . "/modules/" . $dirname;
+
+		$params['resource_base_path'] = $overridePath;
+		$params['quiet'] = true;
+
+		$_return = parent::_fetch_resource_info($params);
+
+		if (!$_return) {
+			unset ($params['resource_base_path']);
+			$params['quiet'] = false;
+
+			$_return = parent::_fetch_resource_info($params);
+		}
+
+		return $_return;
+	}
+	
+}
+
+/**
+ * [TODO]
+ * We depends on Legacy_RenderSystem that a add-in module defines. We must stop
+ * this situation.
+ */
+class Legacy_AdminRenderSystem extends Legacy_RenderSystem
+{
+	var $mSmarty;
+	
+	function prepare()
+	{
+		$this->mSmarty=new Legacy_AdminSmarty();
+
+		$this->mSmarty->assign(array("xoops_url"=>XOOPS_URL,
+		                              "xoops_rootpath"=>XOOPS_ROOT_PATH,
+		                              "xoops_langcode"=>_LANGCODE,
+		                              "xoops_charset"=>_CHARSET,
+		                              "xoops_version"=>XOOPS_VERSION,
+		                              "xoops_upload_url"=>XOOPS_UPLOAD_URL));
+
+	}
+	
+	function renderBlock(&$target)
+	{
+		$this->mSmarty->template_dir=XOOPS_ROOT_PATH."/modules/base/admin/templates";
+
+		foreach($target->getAttributes() as $key=>$value) {
+			$this->mSmarty->assign($key,$value);
+		}
+		
+		$this->mSmarty->setModulePrefix("base");
+		$result=&$this->mSmarty->fetch("blocks/".$target->getTemplateName());
+		$target->setResult($result);
+		
+		//
+		// Reset
+		//
+		foreach($target->getAttributes() as $key=>$value) {
+			$this->mSmarty->clear_assign($key);
+		}
+	}
+	
+	function renderTheme(&$target)
+	{
+		$this->mController->mDebugger->displayLog();
+
+		//
+		// Assign from attributes of the render-target.
+		//
+		foreach($target->getAttributes() as $key=>$value) {
+			$this->mSmarty->assign($key,$value);
+		}
+
+		$this->mSmarty->assign("currentModule",$this->mController->mModuleController->mModuleObject);
+
+		//
+		// Theme rendering
+		//
+		foreach($this->mBlockContents[0] as $result) {
+			$this->mSmarty->append('xoops_lblocks',$result);
+		}
+
+		$this->mSmarty->template_dir=XOOPS_ROOT_PATH."/themes/admin/";
+		$this->mSmarty->setModulePrefix("");
+		$result=$this->mSmarty->fetch("file:admin_theme.html");
+
+		$target->setResult($result);
+	}
+
+	function renderMain(&$target)
+	{
+		//
+		// Assign from attributes of the render-target.
+		//
+		foreach($target->getAttributes() as $key=>$value) {
+			$this->mSmarty->assign($key,$value);
+		}
+
+		$result=null;
+		if($target->getTemplateName()) {
+			$this->mSmarty->template_dir=$this->mController->mModuleController->getModuleDir() . "/". LEGACY_ADMIN_RENDER_TEMPLATE_DIRNAME;
+			$this->mSmarty->setModulePrefix($this->mController->mModuleController->getModuleDir());
+			$result=$this->mSmarty->fetch("file:".$this->mTemplateName);
+		}
+		else {
+			$result=$target->getAttribute("stdout_buffer");
+		}
+		
+		$target->setResult($result);
+	}
+}
+
+/**
+ * Return URL string by "overriding" rule.
+ * (Now, test implement)
+ * 1) Search file in specified theme directory.
+ * 2) Search file in current module template directory.
+ * 3) Search file in fallback theme directory.
+ */
+function Legacy_modifier_theme($string)
+{
+	$root =& XCube_Root::getSingleton();
+	$modController =& $root->mController->getModuleController();
+	$moduleObject =& $modController->getXoopsModule();
+
+	if (!is_object($moduleObject)) {
+		// TODO We must remove Hard-Coding
+		$themePath = XOOPS_THEME_PATH . "/" . _TMP_THEME_NAME . "/" . $string;
+		if (file_exists($themePath)) {
+			return XOOPS_THEME_URL . "/" . _TMP_THEME_NAME . "/" . $string;
+		}
+
+		// TEMP
+		// TODO We must return FALLBACK_URL here.
+		return "hoge";
+	}
+	else {
+		$dirname = $moduleObject->getVar('dirname');
+
+		// TODO We must remove Hard-Coding
+		$themePath = XOOPS_THEME_PATH . "/" . _TMP_THEME_NAME . "/modules/" . $dirname . "/" . $string;
+		if (file_exists($themePath)) {
+			return XOOPS_THEME_URL . "/" . _TMP_THEME_NAME . "/modules/" . $dirname . "/" . $string;
+		}
+
+		$themePath = XOOPS_THEME_PATH . "/" . _TMP_THEME_NAME . "/" . $string;
+		if (file_exists($themePath)) {
+			return XOOPS_THEME_URL . "/" . _TMP_THEME_NAME . "/" . $string;
+		}
+
+		$modulePath = XOOPS_MODULE_PATH . "/" . $dirname . "/admin/templates/" . $string;
+
+		if (file_exists($modulePath)) {
+			return XOOPS_MODULE_URL . "/" . $dirname . "/admin/templates/" . $string;
+		}
+
+		// TEMP
+		// TODO We must return FALLBACK_URL here.
+		return "fallback";
+	}
+}
+
+
 ?>
\ No newline at end of file


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