[xoops-cvslog 1191] CVS update: xoops2jp/html/modules/legacyRender/kernel

Back to archive index

Minahito minah****@users*****
2005年 11月 25日 (金) 13:18:45 JST


Index: xoops2jp/html/modules/legacyRender/kernel/Legacy_RenderSystem.class.php
diff -u /dev/null xoops2jp/html/modules/legacyRender/kernel/Legacy_RenderSystem.class.php:1.1.2.1
--- /dev/null	Fri Nov 25 13:18:45 2005
+++ xoops2jp/html/modules/legacyRender/kernel/Legacy_RenderSystem.class.php	Fri Nov 25 13:18:45 2005
@@ -0,0 +1,386 @@
+<?php
+/**
+ * @version $Id: Legacy_RenderSystem.class.php,v 1.1.2.1 2005/11/25 04:18:45 minahito Exp $
+ */
+
+class Legacy_DialogRenderTarget extends XCube_RenderTarget
+{
+	function sendHeader()
+	{
+		header('Content-Type:text/html; charset='._CHARSET);
+		header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+		header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
+		header('Cache-Control: no-store, no-cache, must-revalidate');
+		header('Cache-Control: post-check=0, pre-check=0', false);
+		header('Pragma: no-cache');
+	}
+	
+	function isGlobal()
+	{
+		return true;
+	}
+	
+	function isTheme()
+	{
+		return false;
+	}
+	
+	function getTemplateName()
+	{
+		return "legacy_render_dialog.html";
+	}
+
+	function display(&$renderSystem)
+	{
+		$this->sendHeader();
+		print $this->getResult();
+	}
+}
+
+class Legacy_ScreenRenderTarget extends XCube_RenderTarget
+{
+	function sendHeader()
+	{
+		header('Content-Type:text/html; charset='._CHARSET);
+		header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+		header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
+		header('Cache-Control: no-store, no-cache, must-revalidate');
+		header('Cache-Control: post-check=0, pre-check=0', false);
+		header('Pragma: no-cache');
+	}
+
+	function isGlobal()
+	{
+		return true;
+	}
+	
+	function isTheme()
+	{
+		return true;
+	}
+
+	function display(&$renderSystem)
+	{
+		$this->sendHeader();
+		print $this->getResult();
+	}
+}
+
+
+/**
+ * Compatible render system with XOOPS 2 Themes & Templates.
+ */
+class Legacy_RenderSystem extends XCube_RenderSystem
+{
+	var $mController;
+	var $mXoopsTpl;
+
+	var $mBlockShowFlags;
+	var $mBlockContents;
+	
+	var $_mContentsData=null;
+
+	function Legacy_RenderSystem(&$controller)
+	{
+		parent::XCube_RenderSystem($controller);
+		$this->mBlockContents=array();
+		$this->mRenderTarget=new Legacy_ScreenRenderTarget();
+	}
+	
+	function setDialogRenderMode()
+	{
+		$this->mRenderTarget=new Legacy_DialogRenderTarget();
+	}
+	
+	/**
+	 * @return bool
+	 */
+	function isDialogRenderMode()
+	{
+	}
+
+	function prepare()
+	{
+		require_once XOOPS_ROOT_PATH."/class/template.php";
+
+		// XoopsTpl default setup
+		$this->mXoopsTpl=new XoopsTpl();
+		
+		// compatible
+		$GLOBALS['xoopsTpl']=&$this->mXoopsTpl;
+		
+		$this->mXoopsTpl->xoops_setCaching(2);
+
+		$this->mXoopsTpl->assign(array('xoops_requesturi' => htmlspecialchars($GLOBALS['xoopsRequestUri'], ENT_QUOTES),	//@todo ?????????????
+									// set JavaScript /Weird, but need extra <script> tags for 2.0.x themes
+									'xoops_js' => '//--></script><script type="text/javascript" src="'.XOOPS_URL.'/include/xoops.js"></script><script type="text/javascript"><!--'
+								));
+
+		// If debugger request debugging to me, send debug mode signal by any methods.
+		if($this->mController->mDebugger->isDebugRenderSystem())
+			$this->mXoopsTpl->xoops_setDebugging(true);
+		
+   		$this->mXoopsTpl->assign(array('xoops_theme' => $this->mController->mConfig['theme_set'],
+							'xoops_imageurl' => XOOPS_THEME_URL.'/'.$this->mController->mConfig['theme_set'].'/',
+							'xoops_themecss'=> xoops_getcss($this->mController->mConfig['theme_set']),
+							'xoops_requesturi' => htmlspecialchars($GLOBALS['xoopsRequestUri'], ENT_QUOTES),	//@todo ?????????????
+							'xoops_sitename' => htmlspecialchars($this->mController->mConfig['sitename'], ENT_QUOTES),
+							'xoops_slogan' => htmlspecialchars($this->mController->mConfig['slogan'], ENT_QUOTES),
+							// set JavaScript/Weird, but need extra <script> tags for 2.0.x themes
+							'xoops_js' => '//--></script><script type="text/javascript" src="'.XOOPS_URL.'/include/xoops.js"></script><script type="text/javascript"><!--'
+						));
+
+		//
+		// If this site has the setting of banner.
+		// TODO this process depends on XOOPS 2.0.x.
+		//
+		if($this->mController->mConfig['banners']==1)
+			$this->mXoopsTpl->assign('xoops_banner',xoops_getbanner());
+		else
+			$this->mXoopsTpl->assign('xoops_banner','&nbsp;');
+
+		// --------------------------------------
+		// Meta tags
+		// --------------------------------------
+		$configHandler=&xoops_gethandler('config');
+		$configs =& $configHandler->getConfigsByCat(0,XOOPS_CONF_METAFOOTER);
+		foreach ($configs as $config) {
+		    // prefix each tag with 'xoops_'
+			if(is_object($config))
+				$this->mXoopsTpl->assign('xoops_'.$config->getVar('conf_name'),	$config->getConfValueForOutput());
+	    }
+
+		// --------------------------------------
+		// Add User
+		// --------------------------------------
+		$arr=null;
+		if(is_object($this->mController->mXoopsUser)) {
+			$arr = array(
+				'xoops_isuser' => true,
+				'xoops_userid' => $this->mController->mXoopsUser->getVar('uid'),
+				'xoops_uname' => $this->mController->mXoopsUser->getVar('uname'),
+				'xoops_isadmin' => $this->mController->mXoopsUser->isAdmin());
+		}
+		else {
+			$arr = array(
+				'xoops_isuser' => false,
+				'xoops_isadmin' => false);
+		}
+
+		$this->mXoopsTpl->assign($arr);
+	}
+	
+	function setAttribute($key,$value)
+	{
+		$this->mRenderTarget->setAttribute($key,$value);
+	}
+	
+	function getAttribute($key)
+	{
+		$this->mRenderTarget->getAttribute($key);
+	}
+	
+	function renderBlock(&$blockProcedure)
+	{
+		$cacheTime = $blockProcedure->getCacheTime();
+		if(!$cacheTime) {
+			$this->mXoopsTpl->xoops_setCaching(0);
+		}
+		else {
+            $this->mXoopsTpl->xoops_setCaching(2);
+            $this->mXoopsTpl->xoops_setCacheTime($bcachetime);
+		}
+
+		$templateName=$blockProcedure->getTemplateName();
+	
+		$this->mXoopsTpl->assign_by_ref("block",$blockProcedure->getResult());
+
+		$renderResult=&$this->mXoopsTpl->fetchBlock($templateName,$blockProcedure->getId());
+		
+		$this->mXoopsTpl->clear_assign('block');
+
+		$this->mBlockShowFlags[$blockProcedure->getEntryIndex()] = true;
+		$this->mBlockContents[$blockProcedure->getEntryIndex()][] = array(
+								'title'=>$blockProcedure->getTitle(),
+								'content'=>$renderResult,
+								'weight'=>$blockProcedure->getWeight());
+	}
+	
+	function _render(&$target)
+	{
+		foreach($target->getAttributes() as $key=>$value) {
+			$this->mXoopsTpl->assign($key,$value);
+		}
+
+		$result=$this->mXoopsTpl->fetch("db:".$target->getTemplateName());
+		$target->setResult($result);
+
+		foreach($keys as $key) {
+			$this->mXoopsTpl->clear_assign($key);
+		}
+	}
+	
+	function _renderTheme(&$target)
+	{
+		//
+		// Assign from attributes of the render-target.
+		//
+		foreach($target->getAttributes() as $key=>$value) {
+			$this->mXoopsTpl->assign($key,$value);
+		}
+
+		//
+		// [TODO]
+		// We must implement with a render-target.
+		//
+		$this->_processLegacyTemplate();
+
+		//
+		// Assign module informations.
+		//
+		if($this->mController->mModuleController->isModuleProcess()) {	// The process of module
+			$xoopsModule=&$this->mController->mModuleController->mModuleObject;
+			$this->mXoopsTpl->assign(array('xoops_pagetitle' => $xoopsModule->getVar('name'),
+			                               'xoops_modulename' => $xoopsModule->getVar('name'),
+			                               'xoops_dirname' => $xoopsModule->getVar('dirname')));
+		}
+		else {
+			$this->mXoopsTpl->assign('xoops_pagetitle', htmlspecialchars($this->mController->mConfig['slogan'], ENT_QUOTES));
+		}
+
+
+		// assing
+		/// @todo I must move these to somewhere.
+		$assignNameMap = array(
+				XOOPS_SIDEBLOCK_LEFT=>array('showflag'=>'xoops_showllock','block'=>'xoops_lblocks'),
+				XOOPS_CENTERBLOCK_LEFT=>array('showflag'=>'xoops_showcblock','block'=>'xoops_clblocks'),
+				XOOPS_CENTERBLOCK_RIGHT=>array('showflag'=>'xoops_showcblock','block'=>'xoops_crblocks'),
+				XOOPS_CENTERBLOCK_CENTER=>array('showflag'=>'xoops_showcblock','block'=>'xoops_ccblocks'),
+				XOOPS_SIDEBLOCK_RIGHT=>array('showflag'=>'xoops_showrblock','block'=>'xoops_rblocks')
+			);
+
+		foreach($assignNameMap as $key=>$val) {
+			$this->mXoopsTpl->assign($val['showflag'],(isset($this->mBlockShowFlags[$key])&&$this->mBlockShowFlags[$key]) ? 1 : 0);
+			if(isset($this->mBlockContents[$key])) {
+				foreach($this->mBlockContents[$key] as $result) {
+					$this->mXoopsTpl->append($val['block'],$result);
+				}
+			}
+		}
+
+		if($target->isTheme()) {
+			$this->mXoopsTpl->xoops_setCaching(0);
+		
+			$themeSet = $this->mController->mConfig['theme_set'];
+
+			//< test
+			$this->mRenderTarget->setResult($this->mXoopsTpl->fetch($themeSet."/theme.html"));
+		}
+		else {
+			$result=$this->mXoopsTpl->fetch("db:".$target->getTemplateName());
+			$target->setResult($result);
+		}
+	}
+	
+	function display()
+	{
+		$this->render();
+		$this->mRenderTarget->display();
+
+		$this->mController->mDebugger->displayLog();
+	}
+	
+	/**
+	 *
+	 */
+	function _processStartPage()
+	{
+		$this->mTemplateName = isset($GLOBALS['xoopsOption']['template_main']) ? $GLOBALS['xoopsOption']['template_main'] : null;
+
+		if(!$this->mTemplateName) {
+			require_once XOOPS_ROOT_PATH.'/include/old_theme_functions.php';
+			$GLOBALS['xoopsTheme']['thename'] = $GLOBALS['xoopsConfig']['theme_set'];
+			ob_start();
+		}
+    }
+
+	function _processLegacyTemplate()
+	{
+		if(!$this->mTemplateName)
+			$this->mTemplateName = isset($GLOBALS['xoopsOption']['template_main']) ? $GLOBALS['xoopsOption']['template_main'] : null;
+		
+		$contents=null;
+
+		$cachedTemplateId = isset($GLOBLAS['xoopsCachedTemplateId']) ? $GLOBLAS['xoopsCachedTemplateId'] : null;
+
+		if ($this->mTemplateName) {
+		    if ($cachedTemplateId!==null) {
+		        $contents=$this->mXoopsTpl->fetch('db:'.$this->mTemplateName, $xoopsCachedTemplateId);
+		    } else {
+		        $contents=$this->mXoopsTpl->fetch('db:'.$this->mTemplateName);
+		    }
+		} else {
+		    if ($cachedTemplateId!==null) {
+		        $this->mXoopsTpl->assign('dummy_content', ob_get_contents());
+		        $contents=$this->mXoopsTpl->fetch($GLOBALS['xoopsCachedTemplate'], $xoopsCachedTemplateId);
+		    } else {
+		        $contents=ob_get_contents();
+		    }
+		    ob_end_clean();
+		}
+
+		$this->mXoopsTpl->assign('xoops_contents',$contents);
+	}
+
+	function renderMessageBox(&$messageBox)
+	{
+		$ret="";
+		$class = ($messageBox->getType()==XCUBE_MESSAGEBOX_RESULT) ? "resultMsg" : "errorMsg";
+		$ret ="<div class='$class'>";
+		if($messageBox->getTitle()!=null)
+			$ret.=@sprintf("<h4>%s</h4>",htmlspecialchars($messageBox->getTitle()));
+			
+		if(is_array($messageBox->getMessage())) {
+			foreach($messageBox->getMessage() as $msg) {
+				$ret.=htmlspecialchars($msg)."<br/>";
+			}
+		}
+		else {
+			$ret.=htmlspecialchars($messageBox->getMessage());
+		}
+		
+		$ret.="</div>";
+
+		return $ret;
+	}
+
+	function renderConfirmMessageBox(&$messageBox)
+	{
+		$ret=@sprintf("<div class='confirmMsg'><h4>%s</h4>",$messageBox->getTitle());
+		$ret.=@sprintf("<form method='post' action='%s'>",$messageBox->getAction());
+
+		foreach($messageBox->getAttributes() as $key=>$value) {
+			if(is_array($value))
+				foreach($value as $radioName=>$radioValue) {
+				$ret.=@sprintf("<input type='radio' name='%s' value='%s' /> %s<br />",$key,htmlspecialchars($radioValue),htmlspecialchars($radioName));
+			}
+			else {
+				$ret.=@sprintf("<input type='hidden' name='%s' value='%s' />",$key,htmlspecialchars($value));
+			}
+		}
+		
+		$submitText=$messageBox->getSubmitText();
+		if($submitText==null)
+			$submitText=_SUBMIT;
+
+		$ret.=@sprintf("<input type='submit' name='confirm_submit' value='%s' /><input type='button' name='confirm_back' value='%s'  onclick='javascript:history.go(-1);' />",
+		                htmlspecialchars($submitText),_CANCEL);
+
+		$ret.="</form></div>";
+
+		return $ret;
+	}
+}
+
+
+?>
\ No newline at end of file


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