52
0

update - v1.1.4

This commit is contained in:
Llewellyn van der Merwe 2023-02-05 23:57:58 +02:00
parent da4f0aeedd
commit eab8f3fc29
Signed by: Llewellyn
GPG Key ID: A9201372263741E7
4 changed files with 41 additions and 94 deletions

View File

@ -16,11 +16,16 @@ use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Plugin\CMSPlugin; 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. * Extension - Componentbuilder Language Packaging plugin.
* *
* @package ComponentbuilderLanguagePackaging * @package ComponentbuilderLanguagePackaging
* @since 1.0.2 * @since 1.1.4
*/ */
class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
{ {
@ -160,30 +165,6 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
*/ */
protected $componentCodeName; 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 * The file content static values
* *
@ -313,23 +294,19 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
public function jcb_ce_onBeforeSetLangFileData(&$context, $compiler) public function jcb_ce_onBeforeSetLangFileData(&$context, $compiler)
{ {
// lets map some arrays to the plugin for later use // lets map some arrays to the plugin for later use
$this->compilerPath = $compiler->compilerPath; $this->compilerPath = CFactory::_('Config')->compiler_path;
$this->tempPath = $compiler->tempPath; $this->tempPath = CFactory::_('Config')->tmp_path;
$this->langTag = $compiler->langTag; $this->langTag = CFactory::_('Config')->lang_tag;
$this->debugLinenr = $compiler->debugLinenr; $this->debugLinenr = CFactory::_('Config')->get('debug_line_nr', false);
$this->component_version = $compiler->componentData->component_version; $this->component_version = CFactory::_('Config')->get('component_version', '1.0.0');
$this->joomlaVersion = $compiler->joomlaVersion; $this->joomlaVersion = CFactory::_('Config')->joomla_version;
$this->percentageLanguageAdd = $compiler->percentageLanguageAdd; $this->percentageLanguageAdd = $compiler->percentageLanguageAdd;
$this->langNot = &$compiler->langNot; $this->langNot = &$compiler->langNot;
$this->langSet = &$compiler->langSet; $this->langSet = &$compiler->langSet;
$this->removeSiteFolder = $compiler->removeSiteFolder; $this->removeSiteFolder = CFactory::_('Config')->remove_site_folder;
$this->removeSiteEditFolder = $compiler->removeSiteEditFolder; $this->removeSiteEditFolder = CFactory::_('Config')->remove_site_edit_folder;
$this->componentPath = $compiler->componentPath; $this->componentPath = CFactory::_('Utilities.Paths')->component_path;
$this->componentCodeName = $compiler->componentCodeName; $this->componentCodeName = CFactory::_('Config')->component_code_name;
$this->fileCount = &$compiler->fileCount;
$this->lineCount = &$compiler->lineCount;
$this->fileContentStatic = &$compiler->fileContentStatic;
$this->hhh = $compiler->hhh;
} }
/** /**
@ -494,7 +471,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
{ {
JFolder::create($main_path); JFolder::create($main_path);
// count the folder created // count the folder created
$this->folderCount++; CFactory::_('Utilities.Counter')->folder++;
} }
foreach ($areas as $area => $languageStrings) foreach ($areas as $area => $languageStrings)
{ {
@ -511,7 +488,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
array_keys($languageStrings) array_keys($languageStrings)
); );
// set the line counter // set the line counter
$this->lineCount = $this->lineCount + count( CFactory::_('Utilities.Counter')->line += count(
(array) $lang (array) $lang
); );
// check that the main folder exist // check that the main folder exist
@ -530,7 +507,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
$client_path . $act['file_name'], implode(PHP_EOL, $lang) $client_path . $act['file_name'], implode(PHP_EOL, $lang)
); );
// count the file created // count the file created
$this->fileCount++; CFactory::_('Utilities.Counter')->line++;
// build xml strings // build xml strings
if (!isset($langXML[$main_path])) if (!isset($langXML[$main_path]))
{ {
@ -560,8 +537,8 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
{ {
// get the XML // get the XML
$xml = str_replace( $xml = str_replace(
array_keys($this->fileContentStatic), array_keys(CFactory::_('Content')->active),
array_values($this->fileContentStatic), array_values(CFactory::_('Content')->active),
$this->getLanguageXML($target_clients, $langPackages[$main_path], $langNames[$main_path]) $this->getLanguageXML($target_clients, $langPackages[$main_path], $langNames[$main_path])
); );
// get the XML File Name // get the XML File Name
@ -595,26 +572,26 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
{ {
$xml = '<?xml version="1.0" encoding="utf-8"?>'; $xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= PHP_EOL . '<extension type="file" version="3.2" method="upgrade">'; $xml .= PHP_EOL . '<extension type="file" version="3.2" method="upgrade">';
$xml .= PHP_EOL . $this->_t(1) . '<name>' . $this->hhh . 'Component' . $this->hhh . ' - ' . $language . ' Language Pack</name>'; $xml .= PHP_EOL . Indent::_(1) . '<name>' . Placefix::_h('Component') . ' - ' . $language . ' Language Pack</name>';
$xml .= PHP_EOL . $this->_t(1) . '<creationDate>' . $this->hhh . 'BUILDDATE' . $this->hhh . '</creationDate>'; $xml .= PHP_EOL . Indent::_(1) . '<creationDate>' . Placefix::_h('BUILDDATE') . '</creationDate>';
$xml .= PHP_EOL . $this->_t(1) . '<author>' . $this->hhh . 'AUTHOR' . $this->hhh . '</author>'; $xml .= PHP_EOL . Indent::_(1) . '<author>' . Placefix::_h('AUTHOR') . '</author>';
$xml .= PHP_EOL . $this->_t(1) . '<authorEmail>' . $this->hhh . 'AUTHOREMAIL' . $this->hhh . '</authorEmail>'; $xml .= PHP_EOL . Indent::_(1) . '<authorEmail>' . Placefix::_h('AUTHOREMAIL') . '</authorEmail>';
$xml .= PHP_EOL . $this->_t(1) . '<authorUrl>' . $this->hhh . 'AUTHORWEBSITE' . $this->hhh . '</authorUrl>'; $xml .= PHP_EOL . Indent::_(1) . '<authorUrl>' . Placefix::_h('AUTHORWEBSITE') . '</authorUrl>';
$xml .= PHP_EOL . $this->_t(1) . '<copyright>' . $this->hhh . 'COPYRIGHT' . $this->hhh . '</copyright>'; $xml .= PHP_EOL . Indent::_(1) . '<copyright>' . Placefix::_h('COPYRIGHT') . '</copyright>';
$xml .= PHP_EOL . $this->_t(1) . '<license>' . $this->hhh . 'LICENSE' . $this->hhh . '</license>'; $xml .= PHP_EOL . Indent::_(1) . '<license>' . Placefix::_h('LICENSE') . '</license>';
$xml .= PHP_EOL . $this->_t(1) . '<version>' . $this->hhh . 'ACTUALVERSION' . $this->hhh . '</version>'; $xml .= PHP_EOL . Indent::_(1) . '<version>' . Placefix::_h('ACTUALVERSION') . '</version>';
$xml .= PHP_EOL . $this->_t(1) . '<description>' . $language . ' Language Pack - ' . $this->hhh . 'SHORT_DESCRIPTION' . $this->hhh . '</description>'; $xml .= PHP_EOL . Indent::_(1) . '<description>' . $language . ' Language Pack - ' . Placefix::_h('SHORT_DESCRIPTION') . '</description>';
$xml .= PHP_EOL . $this->_t(1) . '<fileset>'; $xml .= PHP_EOL . Indent::_(1) . '<fileset>';
foreach ($target_clients as $target_client => $files) foreach ($target_clients as $target_client => $files)
{ {
$xml .= PHP_EOL . $this->_t(2) . '<files folder="' . $target_client . '" target="' . $targets[$target_client] . '">'; $xml .= PHP_EOL . Indent::_(2) . '<files folder="' . $target_client . '" target="' . $targets[$target_client] . '">';
foreach ($files as $file) foreach ($files as $file)
{ {
$xml .= PHP_EOL . $this->_t(3) . '<filename>' . $file . '</filename>'; $xml .= PHP_EOL . Indent::_(3) . '<filename>' . $file . '</filename>';
} }
$xml .= PHP_EOL . $this->_t(2) . '</files>'; $xml .= PHP_EOL . Indent::_(2) . '</files>';
} }
$xml .= PHP_EOL . $this->_t(1) . '</fileset>'; $xml .= PHP_EOL . Indent::_(1) . '</fileset>';
$xml .= PHP_EOL . '</extension>'; $xml .= PHP_EOL . '</extension>';
return $xml; return $xml;
@ -760,34 +737,4 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
return true; 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);
}
} }

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" version="4" group="extension" method="upgrade"> <extension type="plugin" version="4" group="extension" method="upgrade">
<name>PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING</name> <name>PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING</name>
<creationDate>13th November, 2022</creationDate> <creationDate>5th February, 2023</creationDate>
<author>Llewellyn van der Merwe</author> <author>Llewellyn van der Merwe</author>
<authorEmail>joomla@vdm.io</authorEmail> <authorEmail>joomla@vdm.io</authorEmail>
<authorUrl>https://dev.vdm.io</authorUrl> <authorUrl>https://dev.vdm.io</authorUrl>
<copyright>Copyright (C) 2015 Vast Development Method. All rights reserved.</copyright> <copyright>Copyright (C) 2015 Vast Development Method. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license> <license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<version>1.0.2</version> <version>1.1.4</version>
<description>PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING_XML_DESCRIPTION</description> <description>PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING_XML_DESCRIPTION</description>
<!-- Scripts to run on installation --> <!-- Scripts to run on installation -->

View File

@ -1,3 +1,3 @@
PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING="Extension - Componentbuilder Language Packaging" 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_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="<h1>Extension - Componentbuilder Language Packaging (v.1.0.2)</h1> <div style='clear: both;'></div><p>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.</p><p>Created by <a href='https://dev.vdm.io' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 12th October, 2019</small></p>" PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING_XML_DESCRIPTION="<h1>Extension - Componentbuilder Language Packaging (v.1.1.4)</h1> <div style='clear: both;'></div><p>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.</p><p>Created by <a href='https://dev.vdm.io' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 12th October, 2019</small></p>"

View File

@ -1,3 +1,3 @@
PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING="Extension - Componentbuilder Language Packaging" 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_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="<h1>Extension - Componentbuilder Language Packaging (v.1.0.2)</h1> <div style='clear: both;'></div><p>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.</p><p>Created by <a href='https://dev.vdm.io' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 12th October, 2019</small></p>" PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING_XML_DESCRIPTION="<h1>Extension - Componentbuilder Language Packaging (v.1.1.4)</h1> <div style='clear: both;'></div><p>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.</p><p>Created by <a href='https://dev.vdm.io' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 12th October, 2019</small></p>"