NobuNobu
nobun****@users*****
2007年 4月 30日 (月) 16:35:55 JST
Index: xoops2jp/html/modules/legacyRender/kernel/DelegateFunctions.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/kernel/DelegateFunctions.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:55 2007 +++ xoops2jp/html/modules/legacyRender/kernel/DelegateFunctions.class.php Mon Apr 30 16:35:55 2007 @@ -0,0 +1,51 @@ +<?php +/** + * @package legacyRender + * @version $Id: DelegateFunctions.class.php,v 1.1.4.1 2007/04/30 07:35:55 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_ROOT_PATH . "/core/XCube_Theme.class.php"; + +class LegacyRender_DelegateFunctions +{ + /** + * Search themes that Legacy_RenderSystem can render in file system. + */ + function getInstalledThemes(&$results) + { + if ($handler = opendir(XOOPS_THEME_PATH)) { + while (($dirname = readdir($handler)) !== false) { + if ($dirname == "." || $dirname == "..") { + continue; + } + + $themeDir = XOOPS_THEME_PATH . "/" . $dirname; + if (is_dir($themeDir)) { + $theme =& new XCube_Theme(); + $theme->mDirname = $dirname; + + if ($theme->loadManifesto($themeDir . "/manifesto.ini.php")) { + if ($theme->mRenderSystemName == 'Legacy_RenderSystem') { + $results[] =& $theme; + } + } + else { + if (file_exists($themeDir . "/theme.html")) { + $theme->mName = $dirname; + $theme->mRenderSystemName = 'Legacy_RenderSystem'; + $theme->mFormat = "XOOPS2 Legacy Style"; + $results[] =& $theme; + } + } + + unset($theme); + } + } + closedir($handler); + } + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/legacyRender/kernel/Legacy_AdminRenderSystem.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/kernel/Legacy_AdminRenderSystem.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:55 2007 +++ xoops2jp/html/modules/legacyRender/kernel/Legacy_AdminRenderSystem.class.php Mon Apr 30 16:35:55 2007 @@ -0,0 +1,360 @@ +<?php +/** + * @package Legacy + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +// +// TODO +// +require_once XOOPS_ROOT_PATH . "/modules/legacyRender/kernel/Legacy_RenderSystem.class.php"; + +define('LEGACY_ADMIN_RENDER_TEMPLATE_DIRNAME', "templates"); + +define('LEGACY_ADMIN_RENDER_FALLBACK_PATH', XOOPS_MODULE_PATH . "/legacy/admin/theme"); +define('LEGACY_ADMIN_RENDER_FALLBACK_URL', XOOPS_MODULE_URL . "/legacy/admin/theme"); + +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 = "}>"; + + // + // [TODO] + // If we don't set true to the following flag, a user can not recover + // with deleting additional theme. But, a user should to select true or + // false by site_custom.ini.php. + // + $this->force_compile = false; + } + + 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) + { + $_return = false; + + $root =& XCube_Root::getSingleton(); + $theme = $root->mSiteConfig['Legacy']['Theme']; + $dirname = $this->mModulePrefix; + + if ($dirname != null) { + $params['resource_base_path'] = XOOPS_THEME_PATH . "/" . $theme . "/modules/" . $dirname; + $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 $mController; + var $mSmarty; + + /** + * This is the buffer which stores standard output when the render-target + * in renderMain() doesn't use a template. + * + * @access private + * @var string + */ + var $_mStdoutBuffer = null; + + function prepare(&$controller) + { + $this->mController =& $controller; + + $this->mSmarty =& new Legacy_AdminSmarty(); + $this->mSmarty->register_modifier("theme", "Legacy_modifier_theme"); + $this->mSmarty->register_function("stylesheet", "Legacy_function_stylesheet"); + + $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) + ); + + if ($controller->mRoot->mSiteConfig['Legacy_AdminRenderSystem']['ThemeDevelopmentMode'] == true) { + $this->mSmarty->force_compile = true; + } + } + + function renderBlock(&$target) + { + $this->mSmarty->template_dir = XOOPS_ROOT_PATH . "/modules/legacy/admin/templates"; + + foreach ($target->getAttributes() as $key => $value) { + $this->mSmarty->assign($key, $value); + } + + $this->mSmarty->setModulePrefix($target->getAttribute('legacy_module')); + $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) + { + // + // Assign from attributes of the render-target. + // + foreach($target->getAttributes() as $key=>$value) { + $this->mSmarty->assign($key,$value); + } + + $this->mSmarty->assign('stdout_buffer', $this->_mStdoutBuffer); + + // + // Get a virtual current module object from the controller and assign it. + // + $moduleObject =& $this->mController->getVirtualCurrentModule(); + $this->mSmarty->assign("currentModule", $moduleObject); + + // + // Other attributes + // + $this->mSmarty->assign('legacy_sitename', $this->mController->mRoot->mContext->getAttribute('legacy_sitename')); + $this->mSmarty->assign('legacy_pagetitle', $this->mController->mRoot->mContext->getAttribute('legacy_pagetitle')); + $this->mSmarty->assign('legacy_slogan', $this->mController->mRoot->mContext->getAttribute('legacy_slogan')); + + // + // Theme rendering + // + $blocks = array(); + foreach($this->mController->mRoot->mContext->mAttributes['legacy_BlockContents'][0] as $key => $result) { + // $this->mSmarty->append('xoops_lblocks', $result); + $blocks[$result['name']] = $result; + } + $this->mSmarty->assign('xoops_lblocks', $blocks); + + // + // Check Theme or Fallback + // + $root =& XCube_Root::getSingleton(); + $theme = $root->mSiteConfig['Legacy']['Theme']; + + if (file_exists(XOOPS_ROOT_PATH."/themes/".$theme."/admin_theme.html")) { + $this->mSmarty->template_dir=XOOPS_THEME_PATH."/".$theme; + } + else { + $this->mSmarty->template_dir=LEGACY_ADMIN_RENDER_FALLBACK_PATH; + } + + $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()) { + if ($target->getAttribute('legacy_module') != null) { + $this->mSmarty->setModulePrefix($target->getAttribute('legacy_module')); + $this->mSmarty->template_dir = XOOPS_MODULE_PATH . "/" . $target->getAttribute('legacy_module') . "/admin/". LEGACY_ADMIN_RENDER_TEMPLATE_DIRNAME; + } + + $result=$this->mSmarty->fetch("file:".$target->getTemplateName()); + $buffer = $target->getAttribute("stdout_buffer"); + + $this->_mStdoutBuffer .= $buffer; + } + else { + $result=$target->getAttribute("stdout_buffer"); + } + + $target->setResult($result); + + // + // Clear assign. + // + foreach ($target->getAttributes() as $key=>$value) { + $this->mSmarty->clear_assign($key); + } + } +} + +/** + * 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) +{ + $infoArr = Legacy_get_ovveride_file($string); + + if ($infoArr['theme'] != null && $infoArr['dirname'] != null) { + return XOOPS_THEME_URL . "/" . $infoArr['theme'] . "/modules/" . $infoArr['dirname'] . "/" . $string; + } + elseif ($infoArr['theme'] != null) { + return XOOPS_THEME_URL . "/" . $infoArr['theme'] . "/" . $string; + } + elseif ($infoArr['dirname'] != null) { + return XOOPS_MODULE_URL . "/" . $infoArr['dirname'] . "/admin/templates/" . $string; + } + + return LEGACY_ADMIN_RENDER_FALLBACK_URL . "/" . $string; +} + +function Legacy_function_stylesheet($params, &$smarty) +{ + if (!isset($params['file'])) { + $smarty->trigger_error("stylesheet: missing file parameter."); + return; + } + + $file = $params['file']; + + if (strstr($file, "..") !== false) { + $smarty->trigger_error("stylesheet: missing file parameter."); + return; + } + + $media = (isset($params['media'])) ? $params['media'] : "all"; + + $infoArr = Legacy_get_ovveride_file($file, "stylesheets/"); + + // TEMP + // TODO We must return FALLBACK_URL here. + if ($infoArr['file'] != null) { + $request = array(); + foreach ($infoArr as $key => $value) { + if ($value != null) { + $request[] = "${key}=${value}"; + } + } + $url = XOOPS_MODULE_URL . "/legacyRender/admin/css.php?" . implode("&", $request); + print '<link rel="stylesheet" type="text/css" media="'. $media .'" href="' . $url . '" />'; + } +} + +function Legacy_get_ovveride_file($file, $prefix = null, $isSpDirname = false) +{ + $root =& XCube_Root::getSingleton(); + $moduleObject =& $root->mContext->mXoopsModule; + + if ($isSpDirname && is_object($moduleObject) && $moduleObject->get('dirname') == 'legacy' && isset($_REQUEST['dirname'])) { + if (preg_match("/^[a-z0-9_]+$/i", xoops_getrequest('dirname'))) { + $handler =& xoops_gethandler('module'); + $moduleObject =& $handler->getByDirname(xoops_getrequest('dirname')); + } + } + + $theme = $root->mSiteConfig['Legacy']['Theme']; + + $ret = array(); + $ret['theme'] = $theme; + $ret['file'] = $file; + + $file = $prefix . $file; + + if (!is_object($moduleObject)) { + $themePath = XOOPS_THEME_PATH . "/" . $theme . "/" . $file; + if (file_exists($themePath)) { + return $ret; + } + + $ret['theme'] = null; + return $ret; + } + else { + $dirname = $moduleObject->get('dirname'); + + $ret['dirname'] = $dirname; + + $themePath = XOOPS_THEME_PATH . "/" . $theme . "/modules/" . $dirname . "/" . $file; + if (file_exists($themePath)) { + return $ret; + } + + $themePath = XOOPS_THEME_PATH . "/" . $theme . "/" . $file; + if (file_exists($themePath)) { + $ret['dirname'] = null; + return $ret; + } + + $ret['theme'] = null; + + $modulePath = XOOPS_MODULE_PATH . "/" . $dirname . "/admin/templates/" . $file; + if (file_exists($modulePath)) { + return $ret; + } + + $ret['dirname'] = null; + + if (file_exists(LEGACY_ADMIN_RENDER_FALLBACK_PATH . "/" . $file)) { + return $ret; + } + + $ret['file'] =null; + return $ret; + } +} + +?> \ No newline at end of file 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.4.1 --- /dev/null Mon Apr 30 16:35:55 2007 +++ xoops2jp/html/modules/legacyRender/kernel/Legacy_RenderSystem.class.php Mon Apr 30 16:35:55 2007 @@ -0,0 +1,547 @@ +<?php +/** + * @version $Id: Legacy_RenderSystem.class.php,v 1.1.4.1 2007/04/30 07:35:55 nobunobu 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) + { + $root =& XCube_Root::getSingleton(); + if (!isset($name)) { + foreach ($this->_mContextReserve as $t_key => $t_value) { + if (isset($this->_mContextReserve[$t_value])) { + $this->_tpl_vars[$t_key] = htmlspecialchars($root->mContext->getAttribute($this->_mContextReserve[$t_value]), ENT_QUOTES); + } + } + $value =& parent::get_template_vars($name); + } + elseif (isset($this->_mContextReserve[$name])) { + $value = htmlspecialchars($root->mContext->getAttribute($this->_mContextReserve[$name]), ENT_QUOTES); + } + else { + $value =& parent::get_template_vars($name); + } + return $value; + } +} + +/** + * Compatible render system with XOOPS 2 Themes & Templates. + * + * This manages theme and main render-target directly. And, this realizes + * variable-sharing-mechanism with using smarty. + */ +class Legacy_RenderSystem extends XCube_RenderSystem +{ + var $mXoopsTpl; + + /** + * Temporary + */ + var $mThemeRenderTarget; + + /** + * Temporary + */ + var $mMainRenderTarget; + + var $_mContentsData = null; + + /** + * @type XCube_Delegate + */ + var $mSetupXoopsTpl = null; + + function Legacy_RenderSystem() + { + parent::XCube_RenderSystem(); + $this->mSetupXoopsTpl =& new XCube_Delegate(); + $this->mSetupXoopsTpl->register('Legacy_RenderSystem.SetupXoopsTpl'); + } + + function prepare(&$controller) + { + parent::prepare($controller); + + $root =& $this->mController->mRoot; + $context =& $root->getContext(); + $textFilter =& $root->getTextFilter(); + + // XoopsTpl default setup + $this->mXoopsTpl =& new Legacy_XoopsTpl(); + $this->mXoopsTpl->register_function("legacy_notifications_select", "LegacyRender_smartyfunction_notifications_select"); + $this->mSetupXoopsTpl->call(new XCube_Ref($this->mXoopsTpl)); + + // compatible + $GLOBALS['xoopsTpl'] =& $this->mXoopsTpl; + + $this->mXoopsTpl->xoops_setCaching(0); + + // If debugger request debugging to me, send debug mode signal by any methods. + if ($controller->mDebugger->isDebugRenderSystem()) { + $this->mXoopsTpl->xoops_setDebugging(true); + } + + $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"><!--' + )); + $this->mXoopsTpl->assign('xoops_sitename', $textFilter->toShow($context->getAttribute('legacy_sitename'))); + $this->mXoopsTpl->assign('xoops_pagetitle', $textFilter->toShow($context->getAttribute('legacy_pagetitle'))); + $this->mXoopsTpl->assign('xoops_slogan', $textFilter->toShow($context->getAttribute('legacy_slogan'))); + + // -------------------------------------- + // Meta tags + // -------------------------------------- + $moduleHandler =& xoops_gethandler('module'); + $legacyRender =& $moduleHandler->getByDirname('legacyRender'); + + if (is_object($legacyRender)) { + $configHandler =& xoops_gethandler('config'); + $configs =& $configHandler->getConfigsByCat(0, $legacyRender->get('mid')); + + $this->mXoopsTpl->assign('xoops_meta_keywords', $textFilter->toShow($configs['meta_keywords'])); + $this->mXoopsTpl->assign('xoops_meta_description', $textFilter->toShow($configs['meta_description'])); + $this->mXoopsTpl->assign('xoops_meta_robots', $textFilter->toShow($configs['meta_robots'])); + $this->mXoopsTpl->assign('xoops_meta_rating', $textFilter->toShow($configs['meta_rating'])); + $this->mXoopsTpl->assign('xoops_meta_author', $textFilter->toShow($configs['meta_author'])); + $this->mXoopsTpl->assign('xoops_meta_copyright', $textFilter->toShow($configs['meta_copyright'])); + $this->mXoopsTpl->assign('xoops_footer', $configs['footer']); // footer may be raw HTML text. + + // + // If this site has the setting of banner. + // TODO this process depends on XOOPS 2.0.x. + // + if ($configs['banners'] == 1) { + $this->mXoopsTpl->assign('xoops_banner',xoops_getbanner()); + } + else { + $this->mXoopsTpl->assign('xoops_banner',' '); + } + } + else { + $this->mXoopsTpl->assign('xoops_banner',' '); + } + + // -------------------------------------- + // Add User + // -------------------------------------- + $arr = null; + if (is_object($context->mXoopsUser)) { + $arr = array( + 'xoops_isuser' => true, + 'xoops_userid' => $context->mXoopsUser->getShow('uid'), + 'xoops_uname' => $context->mXoopsUser->getShow('uname') + ); + } + else { + $arr = array( + 'xoops_isuser' => false + ); + } + + $this->mXoopsTpl->assign($arr); + } + + function setAttribute($key,$value) + { + $this->mRenderTarget->setAttribute($key,$value); + } + + function getAttribute($key) + { + $this->mRenderTarget->getAttribute($key); + } + + /** + * @protected + * Assign common variables for the compatibility with X2. + */ + function _commonPrepareRender() + { + $root =& $this->mController->mRoot; + $context =& $root->getContext(); + $textFilter =& $root->getTextFilter(); + + $themeName = $context->getThemeName(); + $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', $textFilter->toShow($context->getAttribute('legacy_sitename'))); + $this->mXoopsTpl->assign('xoops_pagetitle', $textFilter->toShow($context->getAttribute('legacy_pagetitle'))); + $this->mXoopsTpl->assign('xoops_slogan', $textFilter->toShow($context->getAttribute('legacy_slogan'))); + + // + // Assign module informations. + // + if($context->mModule != null) { // The process of module + $xoopsModule =& $context->mXoopsModule; + $this->mXoopsTpl->assign(array('xoops_modulename' => $xoopsModule->getShow('name'), + 'xoops_dirname' => $xoopsModule->getShow('dirname'))); + } + + if (isset($GLOBALS['xoopsUserIsAdmin'])) { + $this->mXoopsTpl->assign('xoops_isadmin', $GLOBALS['xoopsUserIsAdmin']); + } + } + + function renderBlock(&$target) + { + $this->_commonPrepareRender(); + + if (isset($GLOBALS['xoopsUserIsAdmin'])) { + $this->mXoopsTpl->assign('xoops_isadmin', $GLOBALS['xoopsUserIsAdmin']); + } + + // + // Temporary + // + $this->mXoopsTpl->xoops_setCaching(0); + + foreach($target->getAttributes() as $key=>$value) { + $this->mXoopsTpl->assign($key,$value); + } + + $result=&$this->mXoopsTpl->fetchBlock($target->getTemplateName(),$target->getAttribute("bid")); + $target->setResult($result); + + // + // Reset + // + foreach($target->getAttributes() as $key=>$value) { + $this->mXoopsTpl->clear_assign($key); + } + } + + 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 ($target->getAttributes() as $key => $value) { + $this->mXoopsTpl->clear_assign($key); + } + } + + function render(&$target) + { + // + // The following lines are temporary until we will finish changing the style! + // + switch ($target->getAttribute('legacy_buffertype')) { + case XCUBE_RENDER_TARGET_TYPE_BLOCK: + $this->renderBlock($target); + break; + + case XCUBE_RENDER_TARGET_TYPE_MAIN: + $this->renderMain($target); + break; + + case XCUBE_RENDER_TARGET_TYPE_THEME: + $this->renderTheme($target); + break; + + case XCUBE_RENDER_TARGET_TYPE_BUFFER: + default: + break; + } + } + + function renderMain(&$target) + { + $this->_commonPrepareRender(); + + if (isset($GLOBALS['xoopsUserIsAdmin'])) { + $this->mXoopsTpl->assign('xoops_isadmin', $GLOBALS['xoopsUserIsAdmin']); + } + + $cachedTemplateId = isset($GLOBLAS['xoopsCachedTemplateId']) ? $GLOBLAS['xoopsCachedTemplateId'] : null; + + foreach($target->getAttributes() as $key=>$value) { + $this->mXoopsTpl->assign($key,$value); + } + + if ($target->getTemplateName()) { + if ($cachedTemplateId!==null) { + $contents=$this->mXoopsTpl->fetch('db:'.$target->getTemplateName(), $xoopsCachedTemplateId); + } else { + $contents=$this->mXoopsTpl->fetch('db:'.$target->getTemplateName()); + } + } else { + if ($cachedTemplateId!==null) { + $this->mXoopsTpl->assign('dummy_content', $target->getAttribute("stdout_buffer")); + $contents=$this->mXoopsTpl->fetch($GLOBALS['xoopsCachedTemplate'], $xoopsCachedTemplateId); + } else { + $contents=$target->getAttribute("stdout_buffer"); + } + } + + $target->setResult($contents); + } + + function renderTheme(&$target) + { + $this->_commonPrepareRender(); + + // + // 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(); + + // assing + /// @todo I must move these to somewhere. + $assignNameMap = array( + XOOPS_SIDEBLOCK_LEFT=>array('showflag'=>'xoops_showlblock','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'],$this->_getBlockShowFlag($val['showflag'])); + if(isset($this->mController->mRoot->mContext->mAttributes['legacy_BlockContents'][$key])) { + foreach($this->mController->mRoot->mContext->mAttributes['legacy_BlockContents'][$key] as $result) { + $this->mXoopsTpl->append($val['block'], $result); + } + } + } + + // + // Render result, and set it to the RenderBuffer of the $target. + // + $result=null; + if($target->getAttribute("isFileTheme")) { + $result=$this->mXoopsTpl->fetch($target->getTemplateName()."/theme.html"); + } + else { + $result=$this->mXoopsTpl->fetch("db:".$target->getTemplateName()); + } + + $result .= $this->mXoopsTpl->fetchDebugConsole(); + + $target->setResult($result); + } + + function _getBlockShowFlag($area) { + switch($area) { + case 'xoops_showrblock' : + if (isset($GLOBALS['show_rblock']) && empty($GLOBALS['show_rblock'])) return 0; + return (!empty($this->mController->mRoot->mContext->mAttributes['legacy_BlockShowFlags'][XOOPS_SIDEBLOCK_RIGHT])) ? 1 : 0; + break; + case 'xoops_showlblock' : + if (isset($GLOBALS['show_lblock']) && empty($GLOBALS['show_lblock'])) return 0; + return (!empty($this->mController->mRoot->mContext->mAttributes['legacy_BlockShowFlags'][XOOPS_SIDEBLOCK_LEFT])) ? 1 : 0; + break; + case 'xoops_showcblock' : + if (isset($GLOBALS['show_cblock']) && empty($GLOBALS['show_cblock'])) return 0; + return (!empty($this->mController->mRoot->mContext->mAttributes['legacy_BlockShowFlags'][XOOPS_CENTERBLOCK_LEFT])|| + !empty($this->mController->mRoot->mContext->mAttributes['legacy_BlockShowFlags'][XOOPS_CENTERBLOCK_RIGHT])|| + !empty($this->mController->mRoot->mContext->mAttributes['legacy_BlockShowFlags'][XOOPS_CENTERBLOCK_CENTER])) ? 1 : 0; + break; + default : + return 0; + } + } + // + // There must not be the following functions here! + // + // + + /** + * @deprecated + */ + 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'); + } + + /** + * @deprecated + */ + function showXoopsHeader($closeHead=true) + { + global $xoopsConfig; + $myts =& MyTextSanitizer::getInstance(); + if ($xoopsConfig['gzip_compression'] == 1) { + ob_start("ob_gzhandler"); + } else { + ob_start(); + } + + $this->sendHeader(); + $this->_renderHeader($closeHead); + } + + // TODO never direct putput + /** + * @deprecated + */ + function _renderHeader($closehead=true) + { + global $xoopsConfig, $xoopsTheme, $xoopsConfigMetaFooter; + + echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>"; + + echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'._LANGCODE.'" lang="'._LANGCODE.'"> + <head> + <meta http-equiv="content-type" content="text/html; charset='._CHARSET.'" /> + <meta http-equiv="content-language" content="'._LANGCODE.'" /> + <meta name="robots" content="'.htmlspecialchars($xoopsConfigMetaFooter['meta_robots']).'" /> + <meta name="keywords" content="'.htmlspecialchars($xoopsConfigMetaFooter['meta_keywords']).'" /> + <meta name="description" content="'.htmlspecialchars($xoopsConfigMetaFooter['meta_desc']).'" /> + <meta name="rating" content="'.htmlspecialchars($xoopsConfigMetaFooter['meta_rating']).'" /> + <meta name="author" content="'.htmlspecialchars($xoopsConfigMetaFooter['meta_author']).'" /> + <meta name="copyright" content="'.htmlspecialchars($xoopsConfigMetaFooter['meta_copyright']).'" /> + <meta name="generator" content="XOOPS" /> + <title>'.htmlspecialchars($xoopsConfig['sitename']).'</title> + <script type="text/javascript" src="'.XOOPS_URL.'/include/xoops.js"></script> + '; + $themecss = getcss($xoopsConfig['theme_set']); + echo '<link rel="stylesheet" type="text/css" media="all" href="'.XOOPS_URL.'/xoops.css" />'; + if ($themecss) { + echo '<link rel="stylesheet" type="text/css" media="all" href="'.$themecss.'" />'; + //echo '<style type="text/css" media="all"><!-- @import url('.$themecss.'); --></style>'; + } + if ($closehead) { + echo '</head><body>'; + } + } + + /** + * @deprecated + */ + function _renderFooter() + { + echo '</body></html>'; + ob_end_flush(); + } + + /** + * @deprecated + */ + function showXoopsFooter() + { + $this->_renderFooter(); + } + + function &createRenderTarget($type = LEGACY_RENDER_TARGET_TYPE_MAIN, $option = null) + { + $renderTarget = null; + switch ($type) { + case XCUBE_RENDER_TARGET_TYPE_MAIN: + $renderTarget =& new Legacy_RenderTargetMain(); + break; + + case LEGACY_RENDER_TARGET_TYPE_BLOCK: + $renderTarget =& new XCube_RenderTarget(); + $renderTarget->setAttribute('legacy_buffertype', LEGACY_RENDER_TARGET_TYPE_BLOCK); + break; + + default: + $renderTarget =& new XCube_RenderTarget(); + break; + } + + return $renderTarget; + } + + /** + * @TODO This function is not cool! + */ + function &getThemeRenderTarget($isDialog = false) + { + $screenTarget = $isDialog ? new Legacy_DialogRenderTarget() : new Legacy_ThemeRenderTarget(); + return $screenTarget; + } +} + +function LegacyRender_smartyfunction_notifications_select($params, &$smarty) +{ + $root =& XCube_Root::getSingleton(); + $renderSystem =& $root->getRenderSystem('Legacy_RenderSystem'); + + $renderTarget =& $renderSystem->createRenderTarget('main'); + $renderTarget->setTemplateName("legacy_notification_select_form.html"); + + XCube_DelegateUtils::call('Legacyfunction.Notifications.Select', new XCube_Ref($renderTarget)); + + $renderSystem->render($renderTarget); + + return $renderTarget->getResult(); +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/legacyRender/kernel/Legacy_RenderTarget.class.php diff -u /dev/null xoops2jp/html/modules/legacyRender/kernel/Legacy_RenderTarget.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:35:55 2007 +++ xoops2jp/html/modules/legacyRender/kernel/Legacy_RenderTarget.class.php Mon Apr 30 16:35:55 2007 @@ -0,0 +1,78 @@ +<?php +/** + * @version $Id: Legacy_RenderTarget.class.php,v 1.1.4.1 2007/04/30 07:35:55 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +define("LEGACY_RENDER_TARGET_TYPE_BUFFER", null); +define("LEGACY_RENDER_TARGET_TYPE_THEME", 'theme'); +define("LEGACY_RENDER_TARGET_TYPE_BLOCK", 'block'); +define("LEGACY_RENDER_TARGET_TYPE_MAIN", 'main'); + +class Legacy_AbstractThemeRenderTarget extends XCube_RenderTarget +{ + var $mSendHeaderFlag=false; + + function Legacy_AbstractThemeRenderTarget() + { + parent::XCube_RenderTarget(); + $this->setAttribute('legacy_buffertype', LEGACY_RENDER_TARGET_TYPE_THEME); + } + + 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 setResult($result) + { + parent::setResult($result); + if(!$this->mSendHeaderFlag) { + $this->sendHeader(); + $this->mSendHeaderFlag=true; + } + + print $result; + } +} + +class Legacy_ThemeRenderTarget extends Legacy_AbstractThemeRenderTarget +{ + function Legacy_ThemeRenderTarget() + { + parent::Legacy_AbstractThemeRenderTarget(); + $this->setAttribute("isFileTheme",true); + } +} + +class Legacy_DialogRenderTarget extends Legacy_AbstractThemeRenderTarget +{ + function Legacy_DialogRenderTarget() + { + parent::Legacy_AbstractThemeRenderTarget(); + $this->setAttribute("isFileTheme",false); + } + + function getTemplateName() + { + return "legacy_render_dialog.html"; + } + +} + +class Legacy_RenderTargetMain extends XCube_RenderTarget +{ + function Legacy_RenderTargetMain() + { + parent::XCube_RenderTarget(); + $this->setAttribute('legacy_buffertype', LEGACY_RENDER_TARGET_TYPE_MAIN); + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/legacyRender/kernel/index.html diff -u /dev/null xoops2jp/html/modules/legacyRender/kernel/index.html:1.1.4.1 --- /dev/null Mon Apr 30 16:35:55 2007 +++ xoops2jp/html/modules/legacyRender/kernel/index.html Mon Apr 30 16:35:55 2007 @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file