Test plugins as loaded modifier, block t update
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
This commit is contained in:
@@ -21,6 +21,9 @@ BASE: {$BASE}<br>
|
||||
<div {popup width="250" caption="Info" text="Text block<br>Control"} style="border: 1px solid black; margin: 5px 0 5px 0; padding: 5px;">
|
||||
POPUP HERE (hover mouse)
|
||||
</div>
|
||||
<div {pop width="250" caption="Info" text="Text block<br>Control<br>Plugin"} style="border: 1px solid black; margin: 5px 0 5px 0; padding: 5px;">
|
||||
POPUP PLUGIN HERE (hover mouse)
|
||||
</div>
|
||||
<div>
|
||||
<b>Outside translation test</b><br>
|
||||
TRANSLATION CLASS (OUT): {$TRANSLATE_TEST}<br>
|
||||
|
||||
@@ -27,6 +27,15 @@ $l10n = new \CoreLibs\Language\L10n(
|
||||
$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']);
|
||||
@@ -52,10 +61,15 @@ $smarty->registerPlugin(\Smarty\Smarty::PLUGIN_MODIFIER, 'getvar', [&$smarty, 'g
|
||||
|
||||
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
|
||||
|
||||
@@ -47,6 +47,17 @@ function smarty_gettext_strarg($str/*, $varargs... */)
|
||||
return strtr($str, $tr);
|
||||
}
|
||||
|
||||
/**
|
||||
* raise a notice for missing callable, indicates L10n functions where not loaded
|
||||
*
|
||||
* @param string $function
|
||||
* @return void
|
||||
*/
|
||||
function reportL10nNotInitialized(string $function): void
|
||||
{
|
||||
trigger_error("Missing " . $function . ", L10n::loadFunctions() called?", E_NOTICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty block function, provides gettext support for smarty.
|
||||
*
|
||||
@@ -64,10 +75,10 @@ function smarty_gettext_strarg($str/*, $varargs... */)
|
||||
* - domain - Textdomain to be used, default if skipped (dgettext() instead of gettext())
|
||||
* - context - gettext context. reserved for future use.
|
||||
*
|
||||
* @param array<string,int|string> $params
|
||||
* @param string $text
|
||||
* @return string
|
||||
*/
|
||||
|
||||
// cs modified: __ calls instead of direct gettext calls
|
||||
|
||||
function smarty_block_t($params, $text)
|
||||
{
|
||||
if (!isset($text)) {
|
||||
@@ -110,52 +121,52 @@ function smarty_block_t($params, $text)
|
||||
if (isset($domain) && isset($context)) {
|
||||
if (is_callable('_dnpgettext')) {
|
||||
$text = _dnpgettext($domain, $context, $text, $plural, $count);
|
||||
}/* elseif (is_callable('dnpgettext')) {
|
||||
$text = dnpgettext($domain, $context, $text, $plural, $count);
|
||||
} */
|
||||
} else {
|
||||
reportL10nNotInitialized('_dnpgettext');
|
||||
}
|
||||
} elseif (isset($domain)) {
|
||||
if (is_callable('_dngettext')) {
|
||||
$text = _dngettext($domain, $text, $plural, $count);
|
||||
} elseif (is_callable('dngettext')) {
|
||||
$text = dngettext($domain, $text, $plural, $count);
|
||||
} else {
|
||||
reportL10nNotInitialized('_dngettext');
|
||||
}
|
||||
} elseif (isset($context)) {
|
||||
if (is_callable('_npgettext')) {
|
||||
$text = _npgettext($context, $text, $plural, $count);
|
||||
}/* elseif (is_callable('npgettext')) {
|
||||
$text = npgettext($context, $text, $plural, $count);
|
||||
} */
|
||||
} else {
|
||||
reportL10nNotInitialized('_npgettext');
|
||||
}
|
||||
} else {
|
||||
if (is_callable('_ngettext')) {
|
||||
$text = _ngettext($text, $plural, $count);
|
||||
} elseif (is_callable('ngettext')) {
|
||||
$text = ngettext($text, $plural, $count);
|
||||
} else {
|
||||
reportL10nNotInitialized('_ngettext');
|
||||
}
|
||||
}
|
||||
} else { // use normal
|
||||
if (isset($domain) && isset($context)) {
|
||||
if (is_callable('_dpgettext')) {
|
||||
$text = _dpgettext($domain, $context, $text);
|
||||
}/* elseif (is_callable('dpgettext')) {
|
||||
$text = dpgettext($domain, $context, $text);
|
||||
} */
|
||||
} else {
|
||||
reportL10nNotInitialized('_dpgettext');
|
||||
}
|
||||
} elseif (isset($domain)) {
|
||||
if (is_callable('_dgettext')) {
|
||||
$text = _dgettext($domain, $text);
|
||||
} elseif (is_callable('dpgettext')) {
|
||||
$text = dgettext($domain, $text);
|
||||
} else {
|
||||
reportL10nNotInitialized('_dgettext');
|
||||
}
|
||||
} elseif (isset($context)) {
|
||||
if (is_callable('_pgettext')) {
|
||||
$text = _pgettext($context, $text);
|
||||
}/* elseif (is_callable('pgettext')) {
|
||||
$text = pgettext($context, $text);
|
||||
} */
|
||||
} else {
|
||||
reportL10nNotInitialized('_pgettext');
|
||||
}
|
||||
} else {
|
||||
if (is_callable('_gettext')) {
|
||||
$text = _gettext($text);
|
||||
} elseif (is_callable('gettext')) {
|
||||
$text = gettext($text);
|
||||
} else {
|
||||
reportL10nNotInitialized('_gettext');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,136 +0,0 @@
|
||||
<?php // phpcs:ignore PSR1.Files.SideEffects
|
||||
|
||||
// v3 modified (used)
|
||||
define('DIR', __DIR__ . '/');
|
||||
define('BASE', str_replace('/src', '', __DIR__) . '/');
|
||||
define('ROOT', getcwd() . '/');
|
||||
define('INCLUDES', 'includes/');
|
||||
define('CONTENT_PATH', 'frontend/');
|
||||
define('LIB', 'lib/');
|
||||
define('LANG', 'lang/');
|
||||
define('LOCALE', 'locale/');
|
||||
define('LAYOUT', 'layout/');
|
||||
define('CSS', 'css/');
|
||||
define('JS', 'js/');
|
||||
define('FONT', 'font/');
|
||||
define('IMAGES', 'images/');
|
||||
define('CACHE', 'cache/');
|
||||
define('TEMPLATES', 'templates/');
|
||||
define('TEMPLATES_C', 'templates_c/');
|
||||
//
|
||||
define('ENCODING', 'UTF-8');
|
||||
define('DEFAULT_LANG', 'en_US');
|
||||
define('DEFAULT_LOCALE', 'en_US.UTF-8');
|
||||
define('DEFAULT_ENCODING', 'UTF-8');
|
||||
// enable to test translation
|
||||
// define('SITE_LOCALE', 'ja_JP.UTF-8');
|
||||
//
|
||||
define('G_TITLE', '');
|
||||
define('PAGE_WIDTH', '100%');
|
||||
define('ADMIN_STYLESHEET', 'edit.css');
|
||||
define('ADMIN_JAVASCRIPT', 'edit.js');
|
||||
define('STYLESHEET', '');
|
||||
define('JAVASCRIPT', '');
|
||||
define('MASTER_TEMPLATE_NAME', '');
|
||||
define('SITE_LANG', '');
|
||||
//
|
||||
define('USE_PROTOTYPE', false);
|
||||
define('USE_JQUERY', false);
|
||||
define('USE_SCRIPTACULOUS', false);
|
||||
//
|
||||
define('CACHE_ID', 'Smart4Test_Cache');
|
||||
define('COMPILE_ID', 'Smart4Test_Compile');
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
// require("Class.Smarty.Extend4.php");
|
||||
// require(LIBS . "Class.l10n.php");
|
||||
|
||||
$DATA['lang_ex'] = "Get Encoding: <pre>" . print_r(\CoreLibs\Language\GetLocale::setLocale(), true) . "</pre>";
|
||||
|
||||
$locale = \CoreLibs\Language\GetLocale::setLocale();
|
||||
$l10n = new \CoreLibs\Language\L10n(
|
||||
$locale['locale'],
|
||||
$locale['domain'],
|
||||
$locale['path'],
|
||||
);
|
||||
// we can pass $l10n to smarty here too
|
||||
$smarty_ml = new \CoreLibs\Template\SmartyExtend($l10n, $locale);
|
||||
$smarty_ml->template_dir = '../' . INCLUDES . TEMPLATES . CONTENT_PATH;
|
||||
|
||||
$language = DEFAULT_LOCALE;
|
||||
$encoding = DEFAULT_ENCODING;
|
||||
$domain = 'messages.' . $encoding;
|
||||
$locale_path = BASE . INCLUDES . LANG;
|
||||
// alternative l10n test
|
||||
$loader = new PhpMyAdmin\MoTranslator\Loader();
|
||||
// Set locale
|
||||
$loader->setlocale($language);
|
||||
// Set default text domain
|
||||
$loader->textdomain($domain);
|
||||
// Set path where to look for a domain
|
||||
$loader->bindtextdomain($domain, $locale_path);
|
||||
// Get translator
|
||||
$translator = $loader->getTranslator();
|
||||
// some translation
|
||||
$DATA['translation_test'] = $translator->gettext('Original');
|
||||
|
||||
$DATA['DEFAULT_ENCODING'] = DEFAULT_ENCODING;
|
||||
$DATA['HTML_TITLE'] = 'Smarty Test Template';
|
||||
$DATA['BASE'] = BASE;
|
||||
$DATA['translate'] = 'Original';
|
||||
$DATA['translate_out'] = $l10n->__($DATA['translate']);
|
||||
$DATA['test'] = 'foo';
|
||||
$DATA['foo'] = 'bar';
|
||||
$DATA['replace'] = 'Replaced';
|
||||
$DATA['loop_start'] = 5;
|
||||
$DATA['drop_down_test'] = [
|
||||
'foo' => 'Foo',
|
||||
'bar' => 'Bar',
|
||||
'foobar' => 'Foo Bar',
|
||||
];
|
||||
$DATA['drop_down_test_selected'] = 'bar';
|
||||
$DATA['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'
|
||||
],
|
||||
];
|
||||
$DATA['drop_down_test_nested_selected'] = '';
|
||||
$DATA['radio_test'] = [
|
||||
'0' => 'On',
|
||||
'1' => 'Off',
|
||||
'-1' => 'Undefined'
|
||||
];
|
||||
$DATA['radio_test_selected'] = -1;
|
||||
$DATA['checkbox_test'] = [
|
||||
'0' => 'On',
|
||||
'1' => 'Off',
|
||||
'-1' => 'Undefined'
|
||||
];
|
||||
$DATA['checkbox_test_pos'] = [
|
||||
'0' => 'A',
|
||||
'1' => 'B'
|
||||
];
|
||||
$DATA['checkbox_test_selected'] = '';
|
||||
|
||||
// smarty part
|
||||
$smarty_ml->setCompileDir(BASE . TEMPLATES_C);
|
||||
$smarty_ml->setCacheDir(BASE . CACHE);
|
||||
|
||||
foreach ($DATA as $key => $value) {
|
||||
$smarty_ml->assign($key, $value);
|
||||
}
|
||||
// content (text) is array in templates
|
||||
$smarty_ml->display('test.tpl');
|
||||
|
||||
// __END__
|
||||
1491
test/src/overlib.js
1491
test/src/overlib.js
File diff suppressed because it is too large
Load Diff
@@ -1,50 +0,0 @@
|
||||
<?php // phpcs:ignore PSR1.Files.SideEffects
|
||||
|
||||
define('DIR', __DIR__ . '/');
|
||||
define('BASE', str_replace('/src', '', __DIR__) . '/');
|
||||
define('ROOT', getcwd() . '/');
|
||||
define('CONTENT_PATH', 'frontend/');
|
||||
define('INCLUDES', 'includes/');
|
||||
define('LANG', 'lang/');
|
||||
define('LOCALE', 'locale/');
|
||||
//
|
||||
define('ENCODING', 'UTF-8');
|
||||
define('DEFAULT_LANG', 'en_US');
|
||||
define('DEFAULT_LOCALE', 'en_US.UTF-8');
|
||||
define('DEFAULT_ENCODING', 'UTF-8');
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
$locale = \CoreLibs\Language\GetLocale::setLocale();
|
||||
$l10n = new \CoreLibs\Language\L10n(
|
||||
$locale['locale'],
|
||||
$locale['domain'],
|
||||
$locale['path'],
|
||||
);
|
||||
|
||||
$language = DEFAULT_LOCALE;
|
||||
$encoding = DEFAULT_ENCODING;
|
||||
$domain = str_replace('/', '', CONTENT_PATH) . '.' . $encoding;
|
||||
$locale_path = BASE . INCLUDES . LOCALE;
|
||||
// PATH: ja_JP or JA / LC_MESSAGES / frontend . UTF-8 .mo
|
||||
// alternative l10n test
|
||||
$loader = new PhpMyAdmin\MoTranslator\Loader();
|
||||
// Set locale
|
||||
$set_locale = $loader->setlocale($language);
|
||||
print "LOCALE: " . $language . " => " . $set_locale . "<br>";
|
||||
// Set default text domain
|
||||
$loader->textdomain($domain);
|
||||
// Set path where to look for a domain
|
||||
$loader->bindtextdomain($domain, $locale_path);
|
||||
// Get translator ($domain override)
|
||||
$translator = $loader->getTranslator();
|
||||
// some translation
|
||||
$translate = 'Original';
|
||||
$translated_mot = $translator->gettext($translate);
|
||||
$translated_l10n = $l10n->__($translate);
|
||||
|
||||
echo "ORIGINAL: " . $translate . "<br>";
|
||||
echo "TRANSLATED (MOT): " . $translated_mot . "<br>";
|
||||
echo "TRANSLATED (L10N): " . $translated_l10n . "<br>";
|
||||
|
||||
// __END__
|
||||
Reference in New Issue
Block a user