Update old block t data to match new block t class type Test if we can load plugin parts, this is a side test for if we want to not add them to the main Smarty load class Remove old test source code, no longer needed
139 lines
3.6 KiB
PHP
139 lines
3.6 KiB
PHP
<?php // phpcs:ignore PSR1.Files.SideEffects
|
|
|
|
/**
|
|
* AUTOR: Clemens Schwaighofer
|
|
* CREATED: 2024/7/22
|
|
* DESCRIPTION:
|
|
* Smarty 5 Test: Just base call
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
require "../vendor/autoload.php";
|
|
|
|
define('BASE', str_replace('/configs', '', __DIR__) . DIRECTORY_SEPARATOR);
|
|
|
|
# public \CoreLibs\Language\L10n $l10n;
|
|
|
|
$locale = 'ja_JP.UTF-8';
|
|
$domain = 'frontend';
|
|
$locale_path = 'includes/locale/';
|
|
$encoding = 'UTF-8';
|
|
|
|
$l10n = new \CoreLibs\Language\L10n(
|
|
$locale,
|
|
$domain,
|
|
$locale_path,
|
|
$encoding
|
|
);
|
|
|
|
// $smarty_ml = new \CoreLibs\Template\SmartyExtend($l10n, 'Smarty5TestCache', 'Smarty5TestCompile');
|
|
// $smarty_ml->setTemplateDir('includes/templates/frontend');
|
|
// $smarty_ml->setConfigDir('configs');
|
|
// $smarty_ml->setCompileDir('templates_c');
|
|
// $smarty_ml->setCacheDir('cache');
|
|
// $smarty_ml->setSmartyPaths();
|
|
// $smarty_ml->setSmartyVarsFrontend();
|
|
// $smarty_ml->renderSmarty();
|
|
|
|
$locale = $l10n->getLocaleAsArray();
|
|
\CoreLibs\Language\L10n::loadFunctions();
|
|
_setlocale(LC_MESSAGES, $locale['locale']);
|
|
_textdomain($locale['domain']);
|
|
_bindtextdomain($locale['domain'], $locale['path']);
|
|
_bind_textdomain_codeset($locale['domain'], $locale['encoding']);
|
|
|
|
$template_name = "test.full.tpl";
|
|
// $template_name = "test.simple.tpl";
|
|
|
|
$CACHE_ID = 'SmartyV5Test';
|
|
$COMPILE_ID = 'SmartyV5Test';
|
|
|
|
// $smarty = \Smarty::__construct();
|
|
$smarty = new \Smarty\Smarty();
|
|
$smarty->setTemplateDir('includes/templates/frontend');
|
|
$smarty->setConfigDir('configs');
|
|
$smarty->setCompileDir('templates_c');
|
|
$smarty->setCacheDir('cache');
|
|
|
|
$smarty->setEscapeHtml(true);
|
|
$smarty->registerPlugin(\Smarty\Smarty::PLUGIN_MODIFIER, 'getvar', [&$smarty, 'getTemplateVars']);
|
|
|
|
require 'plugins/block.t.php';
|
|
$smarty->registerPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'tp', 'smarty_block_t');
|
|
require 'plugins/function.popup_init.php';
|
|
require 'plugins/function.popup.php';
|
|
$smarty->registerPlugin(\Smarty\Smarty::PLUGIN_FUNCTION, 'popinit', 'smarty_function_popup_init');
|
|
$smarty->registerPlugin(\Smarty\Smarty::PLUGIN_FUNCTION, 'pop', 'smarty_function_popup');
|
|
|
|
// $smarty->testInstall();
|
|
|
|
$CONTENT_DATA = [
|
|
'BASE' => BASE,
|
|
// 'TEST_INSTALL' => $smarty->testInstall(),
|
|
'HTML_TITLE' => 'Smarty v5 tst',
|
|
// smarty test
|
|
'SMARTY_TEST' => 'Test Data',
|
|
'TRANSLATE_TEST' => $l10n->__('Are we translated?'),
|
|
'TRANSLATE_TEST_FUNCTION' => _gettext('Are we translated?'),
|
|
'TRANSLATE_TEST_SMARTY' => $l10n->__('Are we translated?'),
|
|
'replace' => 'Replaced',
|
|
// variable variables
|
|
'test' => 'foo',
|
|
'foo' => 'bar',
|
|
// loop
|
|
'loop_start' => 5,
|
|
// drop down test with optgroups
|
|
'drop_down_test' => [
|
|
'foo' => 'Foo',
|
|
'bar' => 'Bar',
|
|
'foobar' => 'Foo Bar',
|
|
],
|
|
'drop_down_test_selected' => 'bar',
|
|
'drop_down_test_nested' => [
|
|
'' => '選択してください',
|
|
'4/25(木)' => [
|
|
'4/25(木) 11:00-11:50' => '4/25(木) 11:00-11:50',
|
|
'4/25(木) 12:20-13:00' => '4/25(木) 12:20-13:00'
|
|
],
|
|
'4/26(金)' => [
|
|
'4/26(金) 11:00-11:50' => '4/26(金) 11:00-11:50',
|
|
'4/26(金) 12:20-13:00' => '4/26(金) 12:20-13:00'
|
|
],
|
|
'4/27(土)' => [
|
|
'4/27(土) 11:00-11:50' => '4/27(土) 11:00-11:50',
|
|
'4/27(土) 12:20-13:00' => '4/27(土) 12:20-13:00'
|
|
],
|
|
],
|
|
'drop_down_test_nested_selected' => '',
|
|
'radio_test' => [
|
|
'0' => 'On',
|
|
'1' => 'Off',
|
|
'-1' => 'Undefined'
|
|
],
|
|
'radio_test_selected' => -1,
|
|
'checkbox_test' => [
|
|
'0' => 'On',
|
|
'1' => 'Off',
|
|
'-1' => 'Undefined'
|
|
],
|
|
'checkbox_test_pos' => [
|
|
'0' => 'A',
|
|
'1' => 'B'
|
|
],
|
|
'checkbox_test_selected' => ['1', '-1'],
|
|
'checkbox_test_pos_selected' => ['0', '-1'],
|
|
];
|
|
|
|
foreach ($CONTENT_DATA as $key => $value) {
|
|
$smarty->assign($key, $value);
|
|
}
|
|
|
|
$smarty->display(
|
|
$template_name,
|
|
$CACHE_ID,
|
|
$COMPILE_ID
|
|
);
|
|
|
|
// __END__
|