From eab8f3fc29dcbf4bb81b92023127353b27170285 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Sun, 5 Feb 2023 23:57:58 +0200 Subject: [PATCH] update - v1.1.4 --- componentbuilderlanguagepackaging.php | 127 +++++------------- componentbuilderlanguagepackaging.xml | 4 +- ...sion_componentbuilderlanguagepackaging.ini | 2 +- ..._componentbuilderlanguagepackaging.sys.ini | 2 +- 4 files changed, 41 insertions(+), 94 deletions(-) diff --git a/componentbuilderlanguagepackaging.php b/componentbuilderlanguagepackaging.php index 1eed2a1..87d7440 100644 --- a/componentbuilderlanguagepackaging.php +++ b/componentbuilderlanguagepackaging.php @@ -15,12 +15,17 @@ defined('_JEXEC') or die('Restricted access'); use Joomla\CMS\Application\CMSApplication; use Joomla\CMS\Plugin\CMSPlugin; -JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'); +JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'); + +use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; + /** * Extension - Componentbuilder Language Packaging plugin. * * @package ComponentbuilderLanguagePackaging - * @since 1.0.2 + * @since 1.1.4 */ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin { @@ -160,30 +165,6 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin */ protected $componentCodeName; - /** - * The number of files - * - * @var int - * @since 1.0.0 - */ - protected $fileCount; - - /** - * The number of lines - * - * @var bool - * @since 1.0.0 - */ - protected $lineCount; - - /** - * The hash placeholder - * - * @var string - * @since 1.0.0 - */ - protected $hhh = '#' . '#' . '#'; - /** * The file content static values * @@ -313,23 +294,19 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin public function jcb_ce_onBeforeSetLangFileData(&$context, $compiler) { // lets map some arrays to the plugin for later use - $this->compilerPath = $compiler->compilerPath; - $this->tempPath = $compiler->tempPath; - $this->langTag = $compiler->langTag; - $this->debugLinenr = $compiler->debugLinenr; - $this->component_version = $compiler->componentData->component_version; - $this->joomlaVersion = $compiler->joomlaVersion; + $this->compilerPath = CFactory::_('Config')->compiler_path; + $this->tempPath = CFactory::_('Config')->tmp_path; + $this->langTag = CFactory::_('Config')->lang_tag; + $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->removeSiteFolder = $compiler->removeSiteFolder; - $this->removeSiteEditFolder = $compiler->removeSiteEditFolder; - $this->componentPath = $compiler->componentPath; - $this->componentCodeName = $compiler->componentCodeName; - $this->fileCount = &$compiler->fileCount; - $this->lineCount = &$compiler->lineCount; - $this->fileContentStatic = &$compiler->fileContentStatic; - $this->hhh = $compiler->hhh; + $this->removeSiteFolder = CFactory::_('Config')->remove_site_folder; + $this->removeSiteEditFolder = CFactory::_('Config')->remove_site_edit_folder; + $this->componentPath = CFactory::_('Utilities.Paths')->component_path; + $this->componentCodeName = CFactory::_('Config')->component_code_name; } /** @@ -494,7 +471,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin { JFolder::create($main_path); // count the folder created - $this->folderCount++; + CFactory::_('Utilities.Counter')->folder++; } foreach ($areas as $area => $languageStrings) { @@ -511,7 +488,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin array_keys($languageStrings) ); // set the line counter - $this->lineCount = $this->lineCount + count( + CFactory::_('Utilities.Counter')->line += count( (array) $lang ); // check that the main folder exist @@ -530,7 +507,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin $client_path . $act['file_name'], implode(PHP_EOL, $lang) ); // count the file created - $this->fileCount++; + CFactory::_('Utilities.Counter')->line++; // build xml strings if (!isset($langXML[$main_path])) { @@ -560,8 +537,8 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin { // get the XML $xml = str_replace( - array_keys($this->fileContentStatic), - array_values($this->fileContentStatic), + array_keys(CFactory::_('Content')->active), + array_values(CFactory::_('Content')->active), $this->getLanguageXML($target_clients, $langPackages[$main_path], $langNames[$main_path]) ); // get the XML File Name @@ -595,26 +572,26 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin { $xml = ''; $xml .= PHP_EOL . ''; - $xml .= PHP_EOL . $this->_t(1) . '' . $this->hhh . 'Component' . $this->hhh . ' - ' . $language . ' Language Pack'; - $xml .= PHP_EOL . $this->_t(1) . '' . $this->hhh . 'BUILDDATE' . $this->hhh . ''; - $xml .= PHP_EOL . $this->_t(1) . '' . $this->hhh . 'AUTHOR' . $this->hhh . ''; - $xml .= PHP_EOL . $this->_t(1) . '' . $this->hhh . 'AUTHOREMAIL' . $this->hhh . ''; - $xml .= PHP_EOL . $this->_t(1) . '' . $this->hhh . 'AUTHORWEBSITE' . $this->hhh . ''; - $xml .= PHP_EOL . $this->_t(1) . '' . $this->hhh . 'COPYRIGHT' . $this->hhh . ''; - $xml .= PHP_EOL . $this->_t(1) . '' . $this->hhh . 'LICENSE' . $this->hhh . ''; - $xml .= PHP_EOL . $this->_t(1) . '' . $this->hhh . 'ACTUALVERSION' . $this->hhh . ''; - $xml .= PHP_EOL . $this->_t(1) . '' . $language . ' Language Pack - ' . $this->hhh . 'SHORT_DESCRIPTION' . $this->hhh . ''; - $xml .= PHP_EOL . $this->_t(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('Component') . ' - ' . $language . ' Language Pack'; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('BUILDDATE') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHOR') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHOREMAIL') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('AUTHORWEBSITE') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('COPYRIGHT') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('LICENSE') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . Placefix::_h('ACTUALVERSION') . ''; + $xml .= PHP_EOL . Indent::_(1) . '' . $language . ' Language Pack - ' . Placefix::_h('SHORT_DESCRIPTION') . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; foreach ($target_clients as $target_client => $files) { - $xml .= PHP_EOL . $this->_t(2) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; foreach ($files as $file) { - $xml .= PHP_EOL . $this->_t(3) . '' . $file . ''; + $xml .= PHP_EOL . Indent::_(3) . '' . $file . ''; } - $xml .= PHP_EOL . $this->_t(2) . ''; + $xml .= PHP_EOL . Indent::_(2) . ''; } - $xml .= PHP_EOL . $this->_t(1) . ''; + $xml .= PHP_EOL . Indent::_(1) . ''; $xml .= PHP_EOL . ''; return $xml; @@ -759,35 +736,5 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin return true; } - - /** - * Set the line number in comments - * - * @param int $nr The line number - * - * @return void - * - */ - protected function setLine($nr) - { - if ($this->debugLinenr) - { - return ' [Plugin-Language-Packaging ' . $nr . ']'; - } - return ''; - } - - /** - * Set the tab/space - * - * @param int $nr The number of tag/space - * - * @return string - * - */ - protected function _t($nr) - { - // use global method for conformity - return ComponentbuilderHelper::_t($nr); - } + } diff --git a/componentbuilderlanguagepackaging.xml b/componentbuilderlanguagepackaging.xml index dba742c..dc0b1b9 100644 --- a/componentbuilderlanguagepackaging.xml +++ b/componentbuilderlanguagepackaging.xml @@ -1,13 +1,13 @@ PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING - 13th November, 2022 + 5th February, 2023 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.0.2 + 1.1.4 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 78d31bd..cffabfe 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.0.2)

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.1.4)

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 78d31bd..cffabfe 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.0.2)

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.1.4)

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