Added events to the new module and plugin translation areas. Updated the fieldtypes to have more info on the showon property.

This commit is contained in:
2020-04-03 20:45:48 +02:00
parent 230834057a
commit ad8717a47d
10 changed files with 270 additions and 203 deletions

View File

@ -1249,6 +1249,11 @@ class Get
$component->system_name
);
// set the component name_code
$component->name_code = ComponentbuilderHelper::safeString(
$component->name_code
);
// ensure version naming is correct
$this->component_version = preg_replace(
'/[^0-9.]+/', '', $component->component_version
@ -1447,7 +1452,7 @@ class Get
{
$this->setJoomlaFields = true;
}
// has become a lacacy issue, can't remove this
// has become a legacy issue, can't remove this
$array['view'] = $array['adminview'];
// get the admin settings/data
$array['settings'] = $this->getAdminViewData(

View File

@ -25835,14 +25835,17 @@ function vdm_dkim() {
// Trigger Event: jcb_ce_onBeforeBuildModuleLang
$this->triggerEvent(
'jcb_ce_onBeforeBuildModuleLang',
array(&$module->context, &$this->langContent[$module->key],
array(&$this->componentContext, &$module,
&$this->langContent[$module->key],
&$module->lang_prefix, &$module->official_name)
);
// get other languages
$values = array_unique($this->langContent[$module->key]);
// get the other lang strings if there is any
$this->multiLangString = $this->getMultiLangStrings($values);
// start the modules language bucket
// start the modules language bucket (must rest every time)
$this->languages['modules'] = array();
$this->languages['modules'][$this->langTag] = array();
$this->languages['modules'][$this->langTag]['all']
= $this->langContent[$module->key];
unset($this->langContent[$module->key]);
@ -25855,7 +25858,8 @@ function vdm_dkim() {
// Trigger Event: jcb_ce_onBeforeBuildModuleLangFiles
$this->triggerEvent(
'jcb_ce_onBeforeBuildModuleLangFiles',
array(&$module->context, &$this->languages['modules'],
array(&$this->componentContext, &$module,
&$this->languages['modules'],
&$this->langTag)
);
// now we insert the values into the files
@ -25867,46 +25871,48 @@ function vdm_dkim() {
$tag = trim($tag);
foreach ($areas as $area => $languageStrings)
{
$file_name = $tag . '.' . $module->file_name . '.ini';
// check if language should be added
if (!$this->shouldLanguageBeAdded(
$tag, $languageStrings, $total
if ($this->shouldLanguageBeAdded(
$tag, $languageStrings, $total,
$file_name
))
{
continue;
}
$lang = array_map(
function ($langstring, $placeholder) {
return $placeholder . '="' . $langstring . '"';
}, array_values($languageStrings),
array_keys($languageStrings)
);
// set path
$path = $module->folder_path . '/language/' . $tag;
// create path if not exist
if (!JFolder::exists($path))
{
JFolder::create($path);
// count the folder created
$this->folderCount++;
}
// add to language files (for now we add all to both TODO)
$this->writeFile(
$path . '/' . $tag . '.' . $module->file_name
. '.ini',
implode(PHP_EOL, $lang)
);
$this->writeFile(
$path . '/' . $tag . '.' . $module->file_name
. '.sys.ini',
implode(PHP_EOL, $lang)
);
// set the line counter
$this->lineCount = $this->lineCount + count(
(array) $lang
$lang = array_map(
function ($langstring, $placeholder) {
return $placeholder . '="' . $langstring
. '"';
}, array_values($languageStrings),
array_keys($languageStrings)
);
unset($lang);
// trigger to add language
$addLang[$tag] = $tag;
// set path
$path = $module->folder_path . '/language/' . $tag
. '/';
// create path if not exist
if (!JFolder::exists($path))
{
JFolder::create($path);
// count the folder created
$this->folderCount++;
}
// add to language files (for now we add all to both TODO)
$this->writeFile(
$path . $file_name,
implode(PHP_EOL, $lang)
);
$this->writeFile(
$path . $tag . '.' . $module->file_name
. '.sys.ini',
implode(PHP_EOL, $lang)
);
// set the line counter
$this->lineCount = $this->lineCount + count(
(array) $lang
);
unset($lang);
// trigger to add language
$addLang[$tag] = $tag;
}
}
}
}
@ -25995,7 +26001,7 @@ function vdm_dkim() {
}
}
// add language folder
if ($addLang)
if (ComponentbuilderHelper::checkArray($addLang))
{
$xml .= PHP_EOL . $this->_t(2) . '<folder>language</folder>';
}
@ -26122,9 +26128,6 @@ function vdm_dkim() {
public function getPluginMainXML(&$plugin)
{
// set some defaults
$view = '';
$viewType = 0;
// set the custom table key
$dbkey = 'yy';
// build the xml
@ -26174,14 +26177,17 @@ function vdm_dkim() {
// Trigger Event: jcb_ce_onBeforeBuildPluginLang
$this->triggerEvent(
'jcb_ce_onBeforeBuildPluginLang',
array(&$plugin->context, &$this->langContent[$plugin->key],
array(&$this->componentContext, &$plugin,
&$this->langContent[$plugin->key],
&$plugin->lang_prefix, &$plugin->official_name)
);
// get other languages
$values = array_unique($this->langContent[$plugin->key]);
// get the other lang strings if there is any
$this->multiLangString = $this->getMultiLangStrings($values);
// start the plugins language bucket
// start the plugins language bucket (must rest every time)
$this->languages['plugins'] = array();
$this->languages['plugins'][$this->langTag] = array();
$this->languages['plugins'][$this->langTag]['all']
= $this->langContent[$plugin->key];
unset($this->langContent[$plugin->key]);
@ -26194,7 +26200,8 @@ function vdm_dkim() {
// Trigger Event: jcb_ce_onBeforeBuildPluginLangFiles
$this->triggerEvent(
'jcb_ce_onBeforeBuildPluginLangFiles',
array(&$plugin->context, &$this->languages['plugins'],
array(&$this->componentContext, &$plugin,
&$this->languages['plugins'],
&$this->langTag)
);
// now we insert the values into the files
@ -26206,47 +26213,53 @@ function vdm_dkim() {
$tag = trim($tag);
foreach ($areas as $area => $languageStrings)
{
$file_name = $tag . '.plg_' . strtolower($plugin->group)
. '_'
. strtolower($plugin->code_name) . '.ini';
// check if language should be added
if (!$this->shouldLanguageBeAdded(
$tag, $languageStrings, $total
if ($this->shouldLanguageBeAdded(
$tag, $languageStrings, $total,
$file_name
))
{
continue;
}
$lang = array_map(
function ($langstring, $placeholder) {
return $placeholder . '="' . $langstring . '"';
}, array_values($languageStrings),
array_keys($languageStrings)
);
// set path
$path = $plugin->folder_path . '/language/' . $tag . '/'
. $tag;
// create path if not exist
if (!JFolder::exists($path))
{
JFolder::create($path);
// count the folder created
$this->folderCount++;
}
// add to language file
$this->writeFile(
$path . '.plg_' . strtolower($plugin->group) . '_'
. strtolower($plugin->code_name) . '.ini',
implode(PHP_EOL, $lang)
);
$this->writeFile(
$path . '.plg_' . strtolower($plugin->group) . '_'
. strtolower($plugin->code_name) . '.sys.ini',
implode(PHP_EOL, $lang)
);
// set the line counter
$this->lineCount = $this->lineCount + count(
(array) $lang
$lang = array_map(
function ($langstring, $placeholder) {
return $placeholder . '="' . $langstring
. '"';
}, array_values($languageStrings),
array_keys($languageStrings)
);
unset($lang);
// trigger to add language
$addLang[$tag] = $tag;
// set path
$path = $plugin->folder_path . '/language/' . $tag
. '/';
// create path if not exist
if (!JFolder::exists($path))
{
JFolder::create($path);
// count the folder created
$this->folderCount++;
}
// add to language file
$this->writeFile(
$path . $file_name,
implode(PHP_EOL, $lang)
);
$this->writeFile(
$path . $tag . '.plg_' . strtolower(
$plugin->group
)
. '_'
. strtolower($plugin->code_name) . '.sys.ini',
implode(PHP_EOL, $lang)
);
// set the line counter
$this->lineCount = $this->lineCount + count(
(array) $lang
);
unset($lang);
// trigger to add language
$addLang[$tag] = $tag;
}
}
}
}
@ -26338,7 +26351,7 @@ function vdm_dkim() {
}
}
// add language folder
if ($addLang)
if (ComponentbuilderHelper::checkArray($addLang))
{
$xml .= PHP_EOL . $this->_t(2) . '<folder>language</folder>';
}
@ -26734,8 +26747,15 @@ function vdm_dkim() {
return $script;
}
public function shouldLanguageBeAdded(&$tag, &$languageStrings, &$total)
{
/**
* check if a translation should be added
*
* @return bool
*
*/
public function shouldLanguageBeAdded(&$tag, &$languageStrings, &$total,
&$file_name
) {
// only log messages for none $this->langTag translations
if ($this->langTag !== $tag)
{
@ -26756,7 +26776,7 @@ function vdm_dkim() {
if ($percentage < $this->percentageLanguageAdd)
{
// dont add
$this->langNot[$area . ' ' . $tag] = '<b>'
$this->langNot[$file_name] = '<b>'
. $total . '</b>(total '
. $this->langTag . ' strings) only <b>'
. $langStringNr . '</b>' . $stringNAme
@ -26766,7 +26786,7 @@ function vdm_dkim() {
}
}
// show if it was added as well
$this->langSet[$area . ' ' . $tag] = '<b>'
$this->langSet[$file_name] = '<b>'
. $total . '</b>(total '
. $this->langTag . ' strings) and <b>'
. $langStringNr . '</b>' . $stringNAme . ' = '

View File

@ -1875,6 +1875,11 @@ class Infusion extends Interpretation
{
if (ComponentbuilderHelper::checkObject($module))
{
// Trigger Event: jcb_ce_onBeforeInfuseModuleData
$this->triggerEvent(
'jcb_ce_onBeforeInfuseModuleData',
array(&$this->componentContext, &$module, $this)
);
$this->target = $module->key;
$this->lang = $module->key;
$this->langPrefix = $module->lang_prefix;
@ -1934,6 +1939,11 @@ class Infusion extends Interpretation
$this->fileContentDynamic[$module->key][$this->hhh
. 'MAINXML' . $this->hhh]
= $this->getModuleMainXML($module);
// Trigger Event: jcb_ce_onAfterInfuseModuleData
$this->triggerEvent(
'jcb_ce_onAfterInfuseModuleData',
array(&$this->componentContext, &$module, $this)
);
}
}
}
@ -1944,6 +1954,11 @@ class Infusion extends Interpretation
{
if (ComponentbuilderHelper::checkObject($plugin))
{
// Trigger Event: jcb_ce_onBeforeInfusePluginData
$this->triggerEvent(
'jcb_ce_onBeforeInfusePluginData',
array(&$this->componentContext, &$plugin, $this)
);
$this->target = $plugin->key;
$this->lang = $plugin->key;
$this->langPrefix = $plugin->lang_prefix;
@ -1986,6 +2001,11 @@ class Infusion extends Interpretation
$this->fileContentDynamic[$plugin->key][$this->hhh
. 'MAINXML' . $this->hhh]
= $this->getPluginMainXML($plugin);
// Trigger Event: jcb_ce_onAfterInfusePluginData
$this->triggerEvent(
'jcb_ce_onAfterInfusePluginData',
array(&$this->componentContext, &$plugin, $this)
);
}
}
}
@ -2206,11 +2226,6 @@ class Infusion extends Interpretation
$tag = trim($tag);
foreach ($areas as $area => $languageStrings)
{
// check if language should be added
if (!$this->shouldLanguageBeAdded($tag, $languageStrings, $mainLangLoader[$area]))
{
continue;
}
// set naming convention
$p = 'admin';
$t = '';
@ -2227,41 +2242,53 @@ class Infusion extends Interpretation
{
$t = '.sys';
}
// build the path to place the lang file
$path = $this->componentPath . '/' . $p . '/language/'
. $tag;
if (!JFolder::exists($path))
{
JFolder::create($path);
// count the folder created
$this->folderCount++;
}
// build the file name
$fileName = $tag . '.com_' . $this->componentCodeName . $t
$file_name = $tag . '.com_' . $this->componentCodeName . $t
. '.ini';
// move the file to its place
JFile::copy($getPAth, $path . '/' . $fileName);
// count the file created
$this->fileCount++;
// add content to it
$lang = array_map(
function ($langstring, $placeholder) {
return $placeholder . '="' . $langstring . '"';
}, $languageStrings, array_keys($languageStrings)
);
// add to language file
$this->writeFile(
$path . '/' . $fileName, implode(PHP_EOL, $lang)
);
// set the line counter
$this->lineCount = $this->lineCount + count((array) $lang);
// build xml strings
if (!isset($langXML[$p]))
// check if language should be added
if ($this->shouldLanguageBeAdded(
$tag, $languageStrings, $mainLangLoader[$area],
$file_name
))
{
$langXML[$p] = array();
// build the path to place the lang file
$path = $this->componentPath . '/' . $p . '/language/'
. $tag . '/';
if (!JFolder::exists($path))
{
JFolder::create($path);
// count the folder created
$this->folderCount++;
}
// move the file to its place
JFile::copy($getPAth, $path . $file_name);
// count the file created
$this->fileCount++;
// add content to it
$lang = array_map(
function ($langstring, $placeholder) {
return $placeholder . '="' . $langstring . '"';
}, array_values($languageStrings),
array_keys($languageStrings)
);
// add to language file
$this->writeFile(
$path . $file_name, implode(PHP_EOL, $lang)
);
// set the line counter
$this->lineCount = $this->lineCount + count(
(array) $lang
);
unset($lang);
// build xml strings
if (!isset($langXML[$p]))
{
$langXML[$p] = array();
}
$langXML[$p][] = '<language tag="' . $tag
. '">language/'
. $tag . '/' . $file_name . '</language>';
}
$langXML[$p][] = '<language tag="' . $tag . '">language/'
. $tag . '/' . $fileName . '</language>';
}
}
// load the lang xml