52
0
Fork 0

Compare commits

...

18 Commits
5.x ... 4.x

Author SHA1 Message Date
Robot cd150dd7bf
Update on v2.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-05-16 16:06:17 +02:00
Robot d73cc389a9
Update on v2.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-05-13 12:22:56 +02:00
Robot b7eb6c2715
Update on v2.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-05-10 18:12:11 +02:00
Robot 2533095db0
Update on v2.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-05-06 07:43:47 +02:00
Robot 30553a4011
Update on v2.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-05-03 07:12:58 +02:00
Robot 68a84d2e14
Update on v2.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-04-30 10:42:14 +02:00
Robot 39d231ca53
Update on v2.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-04-27 15:51:57 +02:00
Robot 2004a81a84
Update on v2.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-04-24 21:31:12 +02:00
Robot a6e38a9ecb
Update on v2.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-04-22 01:07:22 +02:00
Robot e72ba64c83
Update on v2.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-04-16 20:03:38 +02:00
Robot 405b508c45
Update on v2.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-04-09 13:49:29 +02:00
Robot 2d13ca3268
Update on v2.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-04-07 11:54:20 +02:00
Robot 3867386ded
Update on v2.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-04-06 23:29:23 +02:00
Robot 198687109a
Update on v2.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-03-26 22:31:36 +02:00
Robot 556627f48a
Update on v2.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-03-20 14:20:20 +02:00
Robot 2c9a4d4529
Update on v2.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-03-15 12:12:09 +02:00
Robot 0afcd66311
Update on v2.0.0 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
2024-03-12 12:50:20 +02:00
Robot de4e6a0ed6
Release of v2.0.0 2024-03-11 16:14:23 +02:00
5 changed files with 57 additions and 160 deletions

View File

@ -13,23 +13,22 @@
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Filesystem\Folder;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
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;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\MathHelper;
/**
* Extension - Componentbuilder Language Packaging plugin.
*
* @package ComponentbuilderLanguagePackaging
* @since 1.2.0
* @since 2.0.0
*/
class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
{
@ -232,7 +231,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] = CFactory::_('Config')->component_context;
$this->activeComponents[$component->id] = Factory::_('Config')->component_context;
$this->activeComponentsNames[$component->id] = StringHelper::safe($component->name_code);
$this->activeComponentsRealNames[$component->id] = $component->name;
// add excluded list of languages
@ -262,12 +261,12 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
public function jcb_ce_onAfterGet()
{
// get component id
$id = (int) CFactory::_('Config')->component_id;
$id = (int) Factory::_('Config')->component_id;
// check if there is active
if (ArrayHelper::check($this->activeComponents)
&& isset($this->activeComponents[$id]) && $this->percentageLanguageAddOveride != 200)
{
CFactory::_('Config')->set('percentage_language_add', $this->percentageLanguageAddOveride);
Factory::_('Config')->set('percentage_language_add', $this->percentageLanguageAddOveride);
}
}
@ -281,17 +280,17 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
public function jcb_ce_onBeforeSetLangFileData()
{
// lets map some arrays to the plugin for later use
$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 = 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;
$this->componentCodeName = CFactory::_('Config')->component_code_name;
$this->compilerPath = Factory::_('Config')->compiler_path;
$this->tempPath = Factory::_('Config')->tmp_path;
$this->langTag = Factory::_('Config')->lang_tag;
$this->debugLinenr = Factory::_('Config')->get('debug_line_nr', false);
$this->component_version = Factory::_('Config')->get('component_version', '1.0.0');
$this->joomlaVersion = Factory::_('Config')->joomla_version;
$this->percentageLanguageAdd = Factory::_('Config')->percentage_language_add;
$this->removeSiteFolder = Factory::_('Config')->remove_site_folder;
$this->removeSiteEditFolder = Factory::_('Config')->remove_site_edit_folder;
$this->componentPath = Factory::_('Utilities.Paths')->component_path;
$this->componentCodeName = Factory::_('Config')->component_code_name;
}
/**
@ -304,14 +303,14 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
public function jcb_ce_onBeforeBuildPluginLangFiles(&$plugin, &$languages)
{
// get component id
$id = (int) CFactory::_('Config')->component_id;
$id = (int) Factory::_('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, CFactory::_('Config')->lang_tag, $file_name, 'admin');
$this->extrudeLanguages($id, $languages, Factory::_('Config')->lang_tag, $file_name, 'admin');
}
}
@ -325,12 +324,12 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
public function jcb_ce_onBeforeBuildModuleLangFiles(&$module, &$languages)
{
// get component id
$id = (int) CFactory::_('Config')->component_id;
$id = (int) Factory::_('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, CFactory::_('Config')->lang_tag, $module->file_name, $module->target_client);
$this->extrudeLanguages($id, $languages, Factory::_('Config')->lang_tag, $module->file_name, $module->target_client);
}
}
@ -344,17 +343,17 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
public function jcb_ce_onBeforeBuildAllLangFiles(&$languages)
{
// get component id
$id = (int) CFactory::_('Config')->component_id;
$id = (int) Factory::_('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, CFactory::_('Config')->lang_tag, $file_name);
$this->extrudeLanguages($id, $languages, Factory::_('Config')->lang_tag, $file_name);
}
// build the language packages
$this->buildLanguages($id, CFactory::_('Config')->lang_tag);
$this->buildLanguages($id, Factory::_('Config')->lang_tag);
}
/**
@ -444,19 +443,19 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
// set the lang xml name for later
$langXMLNames[$main_path] = $langCodeName . '_' . $this->activeComponentsNames[$id] ;
// we must check if old folder is found and remove it
if (!isset($this->languageTracker[$main_path]) && JFolder::exists($main_path))
if (!isset($this->languageTracker[$main_path]) && Folder::exists($main_path))
{
// remove the main folder
ComponentbuilderHelper::removeFolder($main_path);
Factory::_('Utilities.Folder')->remove($main_path);
// do not remove it again
$this->languageTracker[$main_path] = true;
}
// check if exist and create if not
if (!JFolder::exists($main_path))
if (!Folder::exists($main_path))
{
JFolder::create($main_path);
Folder::create($main_path);
// count the folder created
CFactory::_('Utilities.Counter')->folder++;
Factory::_('Utilities.Counter')->folder++;
}
foreach ($areas as $area => $languageStrings)
{
@ -473,7 +472,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
array_keys($languageStrings)
);
// set the line counter
CFactory::_('Utilities.Counter')->line += count(
Factory::_('Utilities.Counter')->line += count(
(array) $lang
);
// check that the main folder exist
@ -481,18 +480,18 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
{
$client_path = $main_path . $act['target_client'] . '/';
// check if exist and create if not
if (!JFolder::exists($client_path))
if (!Folder::exists($client_path))
{
JFolder::create($client_path);
Folder::create($client_path);
// count the folder created
$this->folderCount++;
}
// write the language data to a file
ComponentbuilderHelper::writeFile(
FileHelper::write(
$client_path . $act['file_name'], implode(PHP_EOL, $lang)
);
// count the file created
CFactory::_('Utilities.Counter')->line++;
Factory::_('Utilities.Counter')->line++;
// build xml strings
if (!isset($langXML[$main_path]))
{
@ -522,25 +521,25 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
{
// get the XML
$xml = str_replace(
array_keys(CFactory::_('Compiler.Builder.Content.One')->allActive()),
array_values(CFactory::_('Compiler.Builder.Content.One')->allActive()),
array_keys(Factory::_('Compiler.Builder.Content.One')->allActive()),
array_values(Factory::_('Compiler.Builder.Content.One')->allActive()),
$this->getLanguageXML($target_clients, $langPackages[$main_path], $langNames[$main_path])
);
// get the XML File Name
$xmlFileName = $langXMLNames[$main_path] . '.xml';
// write the language data to a file
ComponentbuilderHelper::writeFile(
FileHelper::write(
$main_path . $xmlFileName, $xml
);
// set the zip full path
$zipPath = $this->tempPath . '/' . $langZIPNames[$main_path] . '.zip';
// now zip the package
if (ComponentbuilderHelper::zip(
if (FileHelper::zip(
$main_path, $zipPath
))
{
// now remove the package
ComponentbuilderHelper::removeFolder($main_path);
Factory::_('Utilities.Folder')->remove($main_path);
}
}
}
@ -679,17 +678,16 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
* @return bool
*
*/
protected function shouldLanguageBeAdded(&$tag, &$languageStrings, &$total,
&$file_name
) {
protected function shouldLanguageBeAdded(&$tag, &$languageStrings, &$total, &$file_name)
{
// only log messages for none $this->langTag translations
if ($this->langTag !== $tag)
{
$langStringNr = count($languageStrings);
$langStringSum = ComponentbuilderHelper::bcmath(
$langStringSum = MathHelper::bc(
'mul', $langStringNr, 100
);
$percentage = ComponentbuilderHelper::bcmath(
$percentage = MathHelper::bc(
'div', $langStringSum, $total
);
$stringNAme = ($langStringNr == 1) ? '(string '
@ -703,7 +701,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
if ($percentage < $this->percentageLanguageAdd)
{
// dont add
CFactory::_('Compiler.Builder.Language.Messages')->set("exclude.$file_name",
Factory::_('Compiler.Builder.Language.Messages')->set("exclude.$file_name",
'<b>' . $total . '</b>(total '
. $this->langTag . ' strings) only <b>'
. $langStringNr . '</b>' . $stringNAme
@ -715,7 +713,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
}
// show if it was added as well
CFactory::_('Compiler.Builder.Language.Messages')->set("include.$file_name",
Factory::_('Compiler.Builder.Language.Messages')->set("include.$file_name",
'<b>' . $total . '</b>(total '
. $this->langTag . ' strings) and <b>'
. $langStringNr . '</b>' . $stringNAme . ' = '
@ -724,6 +722,5 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
}
return true;
}
}
}

View File

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

View File

@ -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="<h1>Extension - Componentbuilder Language Packaging (v.1.2.0)</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.2.0.0)</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 10th March, 2024</small></p>"

View File

@ -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="<h1>Extension - Componentbuilder Language Packaging (v.1.2.0)</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.2.0.0)</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 10th March, 2024</small></p>"

View File

@ -24,104 +24,4 @@ use Joomla\CMS\Filesystem\Folder;
*/
class plgExtensionComponentbuilderLanguagePackagingInstallerScript
{
/**
* Called before any type of action
*
* @param string $route Which action is happening (install|uninstall|discover_install|update)
* @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function preflight($route, $adapter)
{
// get application
$app = Factory::getApplication();
// the default for both install and update
$jversion = new JVersion();
if (!$jversion->isCompatible('3.8.0'))
{
$app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error');
return false;
}
if ('install' === $route)
{
// needs fix
// check that componentbuilder is installed
$pathToCore = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php';
if (!JFile::exists($pathToCore))
{
$app->enqueueMessage('Joomla Component Builder must first be installed from <a href="https://www.joomlacomponentbuilder.com/ " target="_blank">Joomla Component Builder</a>.', 'error');
return false;
}
// load the helper class
JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php');
// block install
$blockInstall = true;
// check the version of JCB
$manifest = ComponentbuilderHelper::manifest();
if (isset($manifest->version) && strpos($manifest->version, '.') !== false)
{
// get the version
$jcbVersion = explode('.', $manifest->version);
// check that we have JCB 3.0.0 or higher installed
if (count($jcbVersion) == 3 && $jcbVersion[0] >= 3 &&
(
($jcbVersion[0] == 3 && $jcbVersion[1] == 0 && $jcbVersion[2] >= 0) ||
($jcbVersion[0] == 3 && $jcbVersion[1] > 0) ||
$jcbVersion[0] > 3)
)
{
$blockInstall = false;
}
}
// allow install if all conditions are met
if ($blockInstall)
{
$app->enqueueMessage('Please upgrade to JCB v3.0.0 or higher before installing this plugin.', 'error');
return false;
}
// check that componentbuilder is installed
$pathToCore = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php';
if (!JFile::exists($pathToCore))
{
$app->enqueueMessage('Joomla Component Builder must first be installed from <a href="https://www.joomlacomponentbuilder.com/ " target="_blank">Joomla Component Builder</a>.', 'error');
return false;
}
// load the helper class
JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php');
// block install
$blockInstall = true;
// check the version of JCB
$manifest = ComponentbuilderHelper::manifest();
if (isset($manifest->version) && strpos($manifest->version, '.') !== false)
{
// get the version
$jcbVersion = explode('.', $manifest->version);
// check that we have JCB 2.10.13 or higher installed
if (count($jcbVersion) == 3 && (($jcbVersion[0] == 2 && $jcbVersion[1] >= 10 && (($jcbVersion[1] == 10 && $jcbVersion[2] >= 13) || ($jcbVersion[1] > 10))) || $jcbVersion[0] >= 3))
{
$blockInstall = false;
}
}
// allow install if all conditions are met
if ($blockInstall)
{
$app->enqueueMessage('Please upgrade to JCB 2.10.13 or higher before installing this plugin.', 'error');
return false;
}
}
return true;
}
}