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

Back to archive index

Minahito minah****@users*****
2006年 11月 8日 (水) 15:12:10 JST


Index: xoops2jp/html/modules/legacyRender/kernel/Legacy_RenderSystem.class.php
diff -u xoops2jp/html/modules/legacyRender/kernel/Legacy_RenderSystem.class.php:1.1.2.30.2.8 xoops2jp/html/modules/legacyRender/kernel/Legacy_RenderSystem.class.php:1.1.2.30.2.9
--- xoops2jp/html/modules/legacyRender/kernel/Legacy_RenderSystem.class.php:1.1.2.30.2.8	Tue Nov  7 18:56:04 2006
+++ xoops2jp/html/modules/legacyRender/kernel/Legacy_RenderSystem.class.php	Wed Nov  8 15:12:10 2006
@@ -1,11 +1,81 @@
 <?php
 /**
- * @version $Id: Legacy_RenderSystem.class.php,v 1.1.2.30.2.8 2006/11/07 09:56:04 minahito Exp $
+ * @version $Id: Legacy_RenderSystem.class.php,v 1.1.2.30.2.9 2006/11/08 06:12:10 minahito Exp $
  */
 
 if (!defined('XOOPS_ROOT_PATH')) exit();
 
 require_once XOOPS_ROOT_PATH."/modules/legacyRender/kernel/Legacy_RenderTarget.class.php";
+require_once XOOPS_ROOT_PATH . "/class/template.php";
+
+/**
+ * @brief The sub-class for Legacy_RenderSystem. 
+ * 
+ * Because XoopsTpl class may be used without Cube's boot, this is declared.
+ */
+class Legacy_XoopsTpl extends XoopsTpl
+{
+	/**
+	 * @private
+	 * If variables having the following key are assigned, converts value with
+	 * htmlspecialchars_decode, and set it to the context for compatibility.
+	 */
+	var $_mContextReserve = array();
+	
+	function Legacy_XoopsTpl()
+	{
+		$this->_mContextReserve = array ('xoops_pagetitle' => 'legacy_pagetitle');
+		parent::XoopsTpl();
+	}
+	
+    function assign($tpl_var, $value = null)
+    {
+		if (is_array($tpl_var)){
+			foreach ($tpl_var as $key => $val) {
+				if ($key != '') {
+					$this->assign($key, $val);
+				}
+			}
+		}
+		else {
+			if ($tpl_var != '') {
+				if (isset($this->_mContextReserve[$tpl_var])) {
+					$root =& XCube_Root::getSingleton();
+					$root->mContext->setAttribute($this->_mContextReserve[$tpl_var], htmlspecialchars_decode($value));
+				}
+				$this->_tpl_vars[$tpl_var] = $value;
+			}
+        }
+	}
+	
+	function assign_by_ref($tpl_var, &$value)
+	{
+		if ($tpl_var != '') {
+			if (isset($this->_mContextReserve[$tpl_var])) {
+				$root =& XCube_Root::getSingleton();
+				$root->mContext->setAttribute($this->_mContextReserve[$tpl_var], htmlspecialchars_decode($value));
+			}
+			$this->_tpl_vars[$tpl_var] =& $value;
+		}
+	}
+	
+	function &get_template_vars($name = null)
+	{
+		if (!isset($name)) {
+			foreach ($this->_mContextReserve as $t_key => $t_value) {
+				$this->_tpl_vars[$t_key] = htmlspecialchars($root->mContext->getAttribute($this->_mContextReserve[$t_value]), ENT_QUOTES);
+			}
+			return parent::get_template_vars($name);
+		}
+		elseif (isset($this->_mContextReserve[$name])) {
+			$root =& XCube_Root::getSingleton();
+			$value = htmlspecialchars($root->mContext->getAttribute($this->_mContextReserve[$name]), ENT_QUOTES);
+		}
+		else {
+			return parent::get_template_vars($name);
+		}
+	}
+}
 
 /**
  * Compatible render system with XOOPS 2 Themes & Templates.
@@ -45,10 +115,8 @@
 	{
 		parent::prepare($controller);
 		
-		require_once XOOPS_ROOT_PATH . "/class/template.php";
-
 		// XoopsTpl default setup
-		$this->mXoopsTpl =& new XoopsTpl();
+		$this->mXoopsTpl =& new Legacy_XoopsTpl();
 		$this->mXoopsTpl->register_function("legacy_notifications_select", "LegacyRender_smartyfunction_notifications_select");
 		$this->mSetupXoopsTpl->call(new XCube_Ref($this->mXoopsTpl));
 
@@ -68,12 +136,13 @@
 		}
 		
    		$this->mXoopsTpl->assign(array('xoops_requesturi' => htmlspecialchars($GLOBALS['xoopsRequestUri'], ENT_QUOTES),	//@todo ?????????????
-							'xoops_sitename' => htmlspecialchars($this->mController->mRoot->mContext->mXoopsConfig['sitename'], ENT_QUOTES),
-							'xoops_pagetitle' => htmlspecialchars($this->mController->mRoot->mContext->mXoopsConfig['slogan'], ENT_QUOTES),
-							'xoops_slogan' => htmlspecialchars($this->mController->mRoot->mContext->mXoopsConfig['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"><!--'
 						));
+						
+		$this->mXoopsTpl->assign('xoops_sitename', htmlspecialchars($this->mController->mRoot->mContext->getAttribute('legacy_sitename'), ENT_QUOTES));
+		$this->mXoopsTpl->assign('xoops_pagetitle', htmlspecialchars($this->mController->mRoot->mContext->getAttribute('legacy_pagetitle'), ENT_QUOTES));
+		$this->mXoopsTpl->assign('xoops_slogan', htmlspecialchars($this->mController->mRoot->mContext->getAttribute('legacy_slogan'), ENT_QUOTES));
 
 		// --------------------------------------
 		// Meta tags
@@ -144,6 +213,10 @@
    		$this->mXoopsTpl->assign('xoops_theme', $themeName);
    		$this->mXoopsTpl->assign('xoops_imageurl', XOOPS_THEME_URL . "/${themeName}/");
    		$this->mXoopsTpl->assign('xoops_themecss', xoops_getcss($themeName));
+
+		$this->mXoopsTpl->assign('xoops_sitename', htmlspecialchars($this->mController->mRoot->mContext->getAttribute('legacy_sitename'), ENT_QUOTES));
+		$this->mXoopsTpl->assign('xoops_pagetitle', htmlspecialchars($this->mController->mRoot->mContext->getAttribute('legacy_pagetitle'), ENT_QUOTES));
+		$this->mXoopsTpl->assign('xoops_slogan', htmlspecialchars($this->mController->mRoot->mContext->getAttribute('legacy_slogan'), ENT_QUOTES));
 		
 		if (isset($GLOBALS['xoopsUserIsAdmin'])) {
 			$this->mXoopsTpl->assign('xoops_isadmin', $GLOBALS['xoopsUserIsAdmin']);
@@ -214,6 +287,10 @@
    		$this->mXoopsTpl->assign('xoops_imageurl', XOOPS_THEME_URL . "/${themeName}/");
    		$this->mXoopsTpl->assign('xoops_themecss', xoops_getcss($themeName));
 		
+		$this->mXoopsTpl->assign('xoops_sitename', htmlspecialchars($this->mController->mRoot->mContext->getAttribute('legacy_sitename'), ENT_QUOTES));
+		$this->mXoopsTpl->assign('xoops_pagetitle', htmlspecialchars($this->mController->mRoot->mContext->getAttribute('legacy_pagetitle'), ENT_QUOTES));
+		$this->mXoopsTpl->assign('xoops_slogan', htmlspecialchars($this->mController->mRoot->mContext->getAttribute('legacy_slogan'), ENT_QUOTES));
+		
 		if (isset($GLOBALS['xoopsUserIsAdmin'])) {
 			$this->mXoopsTpl->assign('xoops_isadmin', $GLOBALS['xoopsUserIsAdmin']);
 		}
@@ -249,17 +326,17 @@
    		$this->mXoopsTpl->assign('xoops_imageurl', XOOPS_THEME_URL . "/${themeName}/");
    		$this->mXoopsTpl->assign('xoops_themecss', xoops_getcss($themeName));
 		
+		$this->mXoopsTpl->assign('xoops_sitename', htmlspecialchars($this->mController->mRoot->mContext->getAttribute('legacy_sitename'), ENT_QUOTES));
+		$this->mXoopsTpl->assign('xoops_pagetitle', htmlspecialchars($this->mController->mRoot->mContext->getAttribute('legacy_pagetitle'), ENT_QUOTES));
+		$this->mXoopsTpl->assign('xoops_slogan', htmlspecialchars($this->mController->mRoot->mContext->getAttribute('legacy_slogan'), ENT_QUOTES));
+		
 		//
 		// Assign module informations.
 		//
 		if($this->mController->mRoot->mContext->mModule != null) {	// The process of module
 			$xoopsModule =& $this->mController->mRoot->mContext->mXoopsModule;
 			$this->mXoopsTpl->assign(array('xoops_modulename' => $xoopsModule->getShow('name'),
-			                               'xoops_dirname' => $xoopsModule->getShow('dirname'),
-										   'xoops_pagetitle' => $xoopsModule->getShow('name')));
-		}
-		else {
-			$this->mXoopsTpl->assign('xoops_pagetitle', htmlspecialchars($this->mController->mRoot->mContext->mXoopsConfig['slogan'], ENT_QUOTES));
+			                               'xoops_dirname' => $xoopsModule->getShow('dirname')));
 		}
 		
 		if (isset($GLOBALS['xoopsUserIsAdmin'])) {


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