Smarty v5 update test, initial code setup
This commit is contained in:
124
test/index.php
Normal file
124
test/index.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?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
|
||||
);
|
||||
|
||||
$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');
|
||||
|
||||
// $smarty->testInstall();
|
||||
|
||||
$CONTENT_DATA = [
|
||||
// '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__
|
||||
Reference in New Issue
Block a user