Skip to content

Commit

Permalink
XCL v.2.4.0 Render compatibility with X2 and D3 modules
Browse files Browse the repository at this point in the history
  • Loading branch information
gigamaster committed May 5, 2024
1 parent 6634004 commit 9393023
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 101 deletions.
31 changes: 24 additions & 7 deletions html/class/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
* @license GPL 2.0
*/


if (!defined('SMARTY_DIR')) {
exit();
}
Expand Down Expand Up @@ -41,7 +40,8 @@ public function __construct()
if (1 == $xoopsConfig['theme_fromfile']) {
$this->_canUpdateFromFile = true;
$this->compile_check = false; /* This should be set to false on an active site*/
$this->force_compile = true;
$this->force_compile = true; /* This setting overrides $compile_check. By default this is FALSE.
This is handy for development and debugging. It should never be used in a production environment.*/
} else {
$this->_canUpdateFromFile = false;
$this->compile_check = false;
Expand All @@ -52,21 +52,38 @@ public function __construct()
$this->template_dir = XOOPS_THEME_PATH;
$this->cache_dir = XOOPS_CACHE_PATH;
$this->compile_dir = XOOPS_COMPILE_PATH;
//loading under root_path for compatibility with XCL2.1
//Loading under root_path for compatibility with XCL2.1
//$this->plugins_dir = [SMARTY_DIR . 'plugins', XOOPS_ROOT_PATH . '/class/smarty/plugins'];
$this->plugins_dir = [SMARTY_DIR . 'plugins'];

// Legacy_RenderSystem
// $this->default_template_handler_func = 'xoops_template_create';
$this->use_sub_dirs = false;


// Legacy compatility requirement for development and debugging of templates
// Because D3 modules can use XoopsTpl class without Cube's boot
if (isset($GLOBALS['xoopsUserIsAdmin'])) {
$isadmin['xoops_isadmin']=$GLOBALS['xoopsUserIsAdmin'];
}else{
$isadmin['xoops_isadmin']=false;
}
// Render System - get config preferences e.g. logotype, favicon
// for D3 modules who don't delegate XoopsTpl.New
$moduleHandler = xoops_gethandler('module');
$legacyRender =& $moduleHandler->getByDirname('legacyRender');
$configHandler = xoops_gethandler('config');
$configs =& $configHandler->getConfigsByCat(0, $legacyRender->get('mid'));

$this->assign(
[
'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
'xoops_upload_url' => XOOPS_UPLOAD_URL,
'xoops_isadmin' => $isadmin,
'logotype' => $configs['logotype'],
'favicon' => $configs['favicon']
]
);

Expand Down Expand Up @@ -191,7 +208,7 @@ public function xoops_fetchFromData(&$data)
}

/**
*
* _canUpdateFromFile
**/
public function xoops_canUpdateFromFile()
{
Expand Down
20 changes: 0 additions & 20 deletions html/modules/legacy/admin/theme/site.webmanifest

This file was deleted.

28 changes: 11 additions & 17 deletions html/modules/legacy/kernel/Legacy_Controller.class.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
/**
*
* @package Legacy
* @author Nobuhiro YASUTOMI, PHP8
* @version $Id: Legacy_Controller.class.php,v 1.22 2008/11/14 09:45:23 mumincacao Exp $
* @copyright (c) 2005-2024 The XOOPSCube Project
* @license GPL 2.0
* @package Legacy
* @author Nobuhiro YASUTOMI, PHP8
* @version $Id: Legacy_Controller.class.php,v 1.22 2008/11/14 09:45:23 mumincacao Exp $
* @copyright (c) 2005-2024 The XOOPSCube Project
* @license GPL 2.0
*
*/

Expand Down Expand Up @@ -408,7 +408,7 @@ public function _processBlock()
//
// If caching is enabled and the cache file exists, load and use it.
// Note : version 2.3.0
// @gigamaster added 'getTemplate' for block link in theme
// @gigamaster added 'getTemplate' to link block in front theme
if ($cacheInfo->isEnableCache() && $this->existActiveCacheFile($filepath, $blockProcedure->getCacheTime())) {
$content = $this->loadCache($filepath);
if ($blockProcedure->isDisplay() && !empty($content)) {
Expand All @@ -434,7 +434,7 @@ public function _processBlock()
if ($blockProcedure->isDisplay()) {
$renderBuffer =& $blockProcedure->getRenderTarget();
// Note : version 2.3.0
// @gigamaster added 'getTemplate' for block link in theme
// @gigamaster added 'getTemplate' to link block in front theme
$context->mAttributes['legacy_BlockShowFlags'][$blockProcedure->getEntryIndex()] = true;
$context->mAttributes['legacy_BlockContents'][$blockProcedure->getEntryIndex()][] = [
'name' => $blockProcedure->getName(),
Expand Down Expand Up @@ -1218,7 +1218,7 @@ public function executeRedirect($url, $time = 1, $message = null, $addRedirect =

// @TODO test XOOPS2 Compatibility $addredirect = true

// TODO uncomment line 1195
// TODO uncomment to test
// $addRedirect = $addredirect = true;

if ($addRedirect && strpos($url, 'user.php') !== false) {
Expand Down Expand Up @@ -1246,13 +1246,8 @@ public function executeRedirect($url, $time = 1, $message = null, $addRedirect =

/* XCL 2.3.x
* @gigamaster added theme_set, theme_url and theme_css (custom templates from theme)
* @gigamaster added logotype, use $configs for LegacyRender
* also Render configs for X2 and D3 compatibility, refer to /class/template.php
*/
$moduleHandler = xoops_gethandler('module');
$legacyRender =& $moduleHandler->getByDirname('legacyRender');
$configHandler = xoops_gethandler('config');
$configs =& $configHandler->getConfigsByCat(0, $legacyRender->get('mid'));

if (!defined('XOOPS_CPFUNC_LOADED')) {
require_once XOOPS_ROOT_PATH.'/class/template.php';
$xoopsTpl = new XoopsTpl();
Expand All @@ -1263,7 +1258,6 @@ public function executeRedirect($url, $time = 1, $message = null, $addRedirect =
'theme_set' =>htmlspecialchars($xoopsConfig['theme_set'], ENT_QUOTES),
'theme_url' =>XOOPS_THEME_URL . '/' . $xoopsConfig['theme_set'],
'theme_css' =>getcss(),
'logotype' =>$configs['logotype'],
'langcode' =>_LANGCODE,
'charset' =>_CHARSET,
'time' =>$time,
Expand All @@ -1274,7 +1268,7 @@ public function executeRedirect($url, $time = 1, $message = null, $addRedirect =
);
$GLOBALS['xoopsModuleUpdate'] = 1;

$xoopsTpl->display('db:system_redirect.html'); // TODO gigamaster
$xoopsTpl->display('db:system_redirect.html'); // Legacy compatibility

} else {

Expand Down Expand Up @@ -1501,7 +1495,7 @@ public function setupModuleContext(&$context, $dirname)

if (!is_object($module)) {
XCube_DelegateUtils::call('Legacy.Event.Exception.XoopsModuleNotFound', $dirname);
$this->mController->executeRedirect(XOOPS_URL . '/', 1, 'You can\'t access this URL.'); // TODO need message catalog.
$this->mController->executeRedirect(XOOPS_URL . '/', 1, 'You can\'t access this URL.'); // TODO need message catalog.
die();
}

Expand Down
4 changes: 4 additions & 0 deletions html/modules/legacy/preload/Primary/SiteClose.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public static function callbackSetupUser(&$principal, &$controller, &$context)
/* XCL 2.3.x
* @gigamaster added theme_set, theme_url and theme_css (custom templates from theme)
* @gigamaster added logotype, use $configs for LegacyRender
*
* Render System - get config preferences e.g. logotype, footer
* for D3 modules who don't delegate XoopsTpl.New
*/
$moduleHandler = xoops_gethandler('module');
$legacyRender =& $moduleHandler->getByDirname('legacyRender');
Expand All @@ -78,6 +81,7 @@ public static function callbackSetupUser(&$principal, &$controller, &$context)
'lang_password' => _PASSWORD,
'lang_siteclosemsg' => $xoopsConfig['closesite_text'],
'logotype' => $configs['logotype'],
'favicon' => $configs['favicon'],
'footer' => $configs['footer']
]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public function executeViewSuccess(&$controller, &$xoopsUser, &$render)
$xoopsConfig = $controller->mRoot->mContext->getXoopsConfig();
$mRoot = $controller->mRoot;
$mContext = $mRoot->mContext;


// Render System - get configurations categories
$moduleHandler = xoops_gethandler('module');
$legacyRender =& $moduleHandler->getByDirname('legacyRender');
$configHandler = xoops_gethandler('config');
Expand Down
Loading

0 comments on commit 9393023

Please sign in to comment.