diff --git a/componentbuilderlanguagepackaging.php b/componentbuilderlanguagepackaging.php index 56bfcd4..ba93dc7 100644 --- a/componentbuilderlanguagepackaging.php +++ b/componentbuilderlanguagepackaging.php @@ -16,7 +16,8 @@ use Joomla\CMS\Application\CMSApplication; use Joomla\CMS\Plugin\CMSPlugin; use VDM\Joomla\Utilities\JsonHelper; use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\GetHelper; JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'); @@ -28,7 +29,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; * Extension - Componentbuilder Language Packaging plugin. * * @package ComponentbuilderLanguagePackaging - * @since 1.1.5 + * @since 1.2.0 */ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin { @@ -78,7 +79,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin * @var array * @since 1.0.0 */ - protected $languageNames = array(); + protected $languageNames = []; /** * The language building tracker @@ -86,23 +87,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin * @var array * @since 1.0.0 */ - protected $languageTracker = array(); - - /** - * The languages not added that should be added - * - * @var array - * @since 1.0.0 - */ - protected $langNot; - - /** - * The languages added - * - * @var array - * @since 1.0.0 - */ - protected $langSet; + protected $languageTracker = []; /** * The should the site folder be removed @@ -190,7 +175,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin * @var array * @since 1.0.0 */ - protected $activeComponents = array(); + protected $activeComponents = []; /** * The Active Components Names @@ -198,7 +183,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin * @var array * @since 1.0.0 */ - protected $activeComponentsNames = array(); + protected $activeComponentsNames = []; /** * The Languages @@ -206,7 +191,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin * @var array * @since 1.0.0 */ - protected $languages = array(); + protected $languages = []; /** * The Language build details @@ -214,7 +199,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin * @var array * @since 1.0.0 */ - protected $buildDetails = array(); + protected $buildDetails = []; /** * The Excluded Languages @@ -222,7 +207,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin * @var array * @since 1.0.0 */ - protected $excludedLang = array(); + protected $excludedLang = []; /** * The Active Language @@ -239,7 +224,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin * * @since 1.0 */ - public function jcb_ce_onBeforeModelComponentData(&$context, &$component) + public function jcb_ce_onBeforeModelComponentData(&$component) { // add the privacy $component->params = (isset($component->params) && JsonHelper::check($component->params)) ? json_decode($component->params, true) : $component->params; @@ -247,7 +232,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin isset($component->params['language_options']['activate']) && $component->params['language_options']['activate'] == 1) { // load the admin component details - $this->activeComponents[$component->id] = $context; + $this->activeComponents[$component->id] = CFactory::_('Config')->component_context; $this->activeComponentsNames[$component->id] = StringHelper::safe($component->name_code); $this->activeComponentsRealNames[$component->id] = $component->name; // add excluded list of languages @@ -274,16 +259,15 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin * * @since 1.0 */ - public function jcb_ce_onAfterGet(&$context, $compiler) + public function jcb_ce_onAfterGet() { // get component id - $id = (int) filter_var($context, FILTER_SANITIZE_NUMBER_INT); + $id = (int) CFactory::_('Config')->component_id; // check if there is active if (ArrayHelper::check($this->activeComponents) - && isset($this->activeComponents[$id]) - && $this->percentageLanguageAddOveride != 200) + && isset($this->activeComponents[$id]) && $this->percentageLanguageAddOveride != 200) { - $compiler->percentageLanguageAdd = $this->percentageLanguageAddOveride; + CFactory::_('Config')->set('percentage_language_add', $this->percentageLanguageAddOveride); } } @@ -294,7 +278,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin * * @since 1.0 */ - public function jcb_ce_onBeforeSetLangFileData(&$context, $compiler) + public function jcb_ce_onBeforeSetLangFileData() { // lets map some arrays to the plugin for later use $this->compilerPath = CFactory::_('Config')->compiler_path; @@ -303,9 +287,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin $this->debugLinenr = CFactory::_('Config')->get('debug_line_nr', false); $this->component_version = CFactory::_('Config')->get('component_version', '1.0.0'); $this->joomlaVersion = CFactory::_('Config')->joomla_version; - $this->percentageLanguageAdd = $compiler->percentageLanguageAdd; - $this->langNot = &$compiler->langNot; - $this->langSet = &$compiler->langSet; + $this->percentageLanguageAdd = CFactory::_('Config')->percentage_language_add; $this->removeSiteFolder = CFactory::_('Config')->remove_site_folder; $this->removeSiteEditFolder = CFactory::_('Config')->remove_site_edit_folder; $this->componentPath = CFactory::_('Utilities.Paths')->component_path; @@ -319,17 +301,17 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin * * @since 1.0 */ - public function jcb_ce_onBeforeBuildPluginLangFiles(&$context, &$plugin, &$languages, &$langTag) + public function jcb_ce_onBeforeBuildPluginLangFiles(&$plugin, &$languages) { // get component id - $id = (int) filter_var($context, FILTER_SANITIZE_NUMBER_INT); + $id = (int) CFactory::_('Config')->component_id; // check if there is active if (ArrayHelper::check($this->activeComponents) && isset($this->activeComponents[$id])) { // set file name $file_name = 'plg_' . strtolower($plugin->group) . '_' . strtolower($plugin->code_name); // extrude the languages that should not remain in the plugin - $this->extrudeLanguages($id, $languages, $langTag, $file_name, 'admin'); + $this->extrudeLanguages($id, $languages, CFactory::_('Config')->lang_tag, $file_name, 'admin'); } } @@ -340,15 +322,15 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin * * @since 1.0 */ - public function jcb_ce_onBeforeBuildModuleLangFiles(&$context, &$module, &$languages, &$langTag) + public function jcb_ce_onBeforeBuildModuleLangFiles(&$module, &$languages) { // get component id - $id = (int) filter_var($context, FILTER_SANITIZE_NUMBER_INT); + $id = (int) CFactory::_('Config')->component_id; // check if there is active if (ArrayHelper::check($this->activeComponents) && isset($this->activeComponents[$id])) { // extrude the languages that should not remain in the module - $this->extrudeLanguages($id, $languages, $langTag, $module->file_name, $module->target_client); + $this->extrudeLanguages($id, $languages, CFactory::_('Config')->lang_tag, $module->file_name, $module->target_client); } } @@ -359,20 +341,20 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin * * @since 1.0 */ - public function jcb_ce_onBeforeBuildAllLangFiles(&$context, &$languages, &$langTag) + public function jcb_ce_onBeforeBuildAllLangFiles(&$languages) { // get component id - $id = (int) filter_var($context, FILTER_SANITIZE_NUMBER_INT); + $id = (int) CFactory::_('Config')->component_id; // check if there is active if (ArrayHelper::check($this->activeComponents) && isset($this->activeComponents[$id])) { // set file name $file_name = 'com_' . $this->activeComponentsNames[$id]; // extrude the languages that should not remain in the module - $this->extrudeLanguages($id, $languages, $langTag, $file_name); + $this->extrudeLanguages($id, $languages, CFactory::_('Config')->lang_tag, $file_name); } // build the language packages - $this->buildLanguages($id, $langTag); + $this->buildLanguages($id, CFactory::_('Config')->lang_tag); } /** @@ -382,19 +364,19 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin * * @since 1.0 */ - protected function extrudeLanguages(&$id, &$languages, &$langTag, &$file_name, $target_client = 'both') + protected function extrudeLanguages(&$id, &$languages, $langTag, &$file_name, $target_client = 'both') { - $mainLangLoader = array(); + $mainLangLoader = []; // check if this id was set before if (!isset($this->languages[$id])) { - $this->languages[$id] = array(); - $this->buildDetails[$id] = array(); + $this->languages[$id] = []; + $this->buildDetails[$id] = []; } // check if this file name was set before if (!isset($this->languages[$id][$file_name])) { - $this->languages[$id][$file_name] = array(); + $this->languages[$id][$file_name] = []; } // set all the extra languages not excluded foreach ($languages as $key => $language) @@ -416,7 +398,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin } } // store details for build - $this->buildDetails[$id][$file_name] = array($langTag => $mainLangLoader, 'target_client' => $target_client); + $this->buildDetails[$id][$file_name] = [$langTag => $mainLangLoader, 'target_client' => $target_client]; } /** @@ -425,16 +407,16 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin * @return void * */ - protected function buildLanguages(&$id, &$langTag) + protected function buildLanguages(&$id, $langTag) { if (isset($this->languages[$id]) && ArrayHelper::check($this->languages[$id])) { // rest xml array - $langXML = array(); - $langNames = array(); - $langPackages = array(); - $langZIPNames = array(); - $langXMLNames = array(); + $langXML = []; + $langNames = []; + $langPackages = []; + $langZIPNames = []; + $langXMLNames = []; $versionName = $this->activeComponentsNames[$id] . '_v' . str_replace('.', '_', $this->component_version . '__J' . $this->joomlaVersion); foreach ($this->languages[$id] as $file_name => $languages) { @@ -610,7 +592,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin { if (!isset($this->languageNames[$tag])) { - if (($name = ComponentbuilderHelper::getVar('language', $tag, 'langtag', 'name')) !== false) + if (($name = GetHelper::var('language', $tag, 'langtag', 'name')) !== false) { $this->languageNames[$tag] = $name; } @@ -713,6 +695,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin $stringNAme = ($langStringNr == 1) ? '(string ' . $tag . ' translated)' : '(strings ' . $tag . ' translated)'; + // force load if debug lines are added if (!$this->debugLinenr) { @@ -720,21 +703,24 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin if ($percentage < $this->percentageLanguageAdd) { // dont add - $this->langNot[$file_name] = '' - . $total . '(total ' + CFactory::_('Compiler.Builder.Language.Messages')->set("exclude.$file_name", + '' . $total . '(total ' . $this->langTag . ' strings) only ' . $langStringNr . '' . $stringNAme - . ' = ' . $percentage; + . ' = ' . $percentage + ); return false; } } + // show if it was added as well - $this->langSet[$file_name] = '' - . $total . '(total ' + CFactory::_('Compiler.Builder.Language.Messages')->set("include.$file_name", + '' . $total . '(total ' . $this->langTag . ' strings) and ' . $langStringNr . '' . $stringNAme . ' = ' - . $percentage; + . $percentage + ); } return true; diff --git a/componentbuilderlanguagepackaging.xml b/componentbuilderlanguagepackaging.xml index 516498a..d971cc9 100644 --- a/componentbuilderlanguagepackaging.xml +++ b/componentbuilderlanguagepackaging.xml @@ -1,13 +1,13 @@ - + PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING - 24th October, 2023 + 2nd March, 2024 Llewellyn van der Merwe joomla@vdm.io https://dev.vdm.io Copyright (C) 2015 Vast Development Method. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt - 1.1.5 + 1.2.0 PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING_XML_DESCRIPTION diff --git a/language/en-GB/en-GB.plg_extension_componentbuilderlanguagepackaging.ini b/language/en-GB/en-GB.plg_extension_componentbuilderlanguagepackaging.ini index e73d132..6f37179 100644 --- a/language/en-GB/en-GB.plg_extension_componentbuilderlanguagepackaging.ini +++ b/language/en-GB/en-GB.plg_extension_componentbuilderlanguagepackaging.ini @@ -1,3 +1,3 @@ PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING="Extension - Componentbuilder Language Packaging" PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING_DESCRIPTION="This plugin is used to add language packaging to JCB. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field." -PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING_XML_DESCRIPTION="

Extension - Componentbuilder Language Packaging (v.1.1.5)

This plugin is used to add language packaging to JCB. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.

Created by Llewellyn van der Merwe
Development started 12th October, 2019

" \ No newline at end of file +PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING_XML_DESCRIPTION="

Extension - Componentbuilder Language Packaging (v.1.2.0)

This plugin is used to add language packaging to JCB. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.

Created by Llewellyn van der Merwe
Development started 12th October, 2019

" \ No newline at end of file diff --git a/language/en-GB/en-GB.plg_extension_componentbuilderlanguagepackaging.sys.ini b/language/en-GB/en-GB.plg_extension_componentbuilderlanguagepackaging.sys.ini index e73d132..6f37179 100644 --- a/language/en-GB/en-GB.plg_extension_componentbuilderlanguagepackaging.sys.ini +++ b/language/en-GB/en-GB.plg_extension_componentbuilderlanguagepackaging.sys.ini @@ -1,3 +1,3 @@ PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING="Extension - Componentbuilder Language Packaging" PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING_DESCRIPTION="This plugin is used to add language packaging to JCB. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field." -PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING_XML_DESCRIPTION="

Extension - Componentbuilder Language Packaging (v.1.1.5)

This plugin is used to add language packaging to JCB. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.

Created by Llewellyn van der Merwe
Development started 12th October, 2019

" \ No newline at end of file +PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING_XML_DESCRIPTION="

Extension - Componentbuilder Language Packaging (v.1.2.0)

This plugin is used to add language packaging to JCB. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.

Created by Llewellyn van der Merwe
Development started 12th October, 2019

" \ No newline at end of file diff --git a/script.php b/script.php index de9b9f3..f98dec4 100644 --- a/script.php +++ b/script.php @@ -12,6 +12,11 @@ // No direct access to this file defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Filesystem\Folder; + /** * Extension - Componentbuilder Language Packaging script file. * @@ -31,7 +36,7 @@ class plgExtensionComponentbuilderLanguagePackagingInstallerScript public function preflight($route, $adapter) { // get application - $app = JFactory::getApplication(); + $app = Factory::getApplication(); // the default for both install and update $jversion = new JVersion();