Compare commits
37 Commits
Author | SHA1 | Date | |
---|---|---|---|
acad771807 | |||
616824c352 | |||
47ebc5c0fb | |||
332b11d644 | |||
368ec6139a | |||
1801eb5977 | |||
cd57598f50 | |||
c152276605 | |||
1f92d9d44b | |||
b26f64f4c3 | |||
622421c531 | |||
2f566e06fd | |||
d5c0fca707 | |||
9268eb5e5f | |||
0770cf5511 | |||
d932a2f9e0 | |||
eea6b5d1f0 | |||
4c0877e7aa | |||
d63e4a6ea2 | |||
8ed3b60d95 | |||
22e92e9064 | |||
d480b023e6 | |||
c3f73a893f | |||
550f34cd31 | |||
bf70d406ab | |||
4f9d794de0 | |||
c1ebe7ce34 | |||
8fa464000d | |||
dfdf245004 | |||
620d9225d8 | |||
eb10fd630f | |||
73750896ae | |||
bae1c71653 | |||
c0c3445e97 | |||
3019950beb | |||
2cd4de00ca | |||
b39c9c5355 |
@ -12,24 +12,23 @@
|
|||||||
// No direct access to this file
|
// No direct access to this file
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php');
|
||||||
|
|
||||||
use Joomla\CMS\Application\CMSApplication;
|
use Joomla\CMS\Application\CMSApplication;
|
||||||
use Joomla\CMS\Plugin\CMSPlugin;
|
use Joomla\CMS\Plugin\CMSPlugin;
|
||||||
|
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\JsonHelper;
|
use VDM\Joomla\Utilities\JsonHelper;
|
||||||
use VDM\Joomla\Utilities\ArrayHelper;
|
use VDM\Joomla\Utilities\ArrayHelper;
|
||||||
use VDM\Joomla\Utilities\StringHelper;
|
use VDM\Joomla\Utilities\StringHelper;
|
||||||
use VDM\Joomla\Utilities\GetHelper;
|
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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension - Componentbuilder Language Packaging plugin.
|
* Extension - Componentbuilder Language Packaging plugin.
|
||||||
*
|
*
|
||||||
* @package ComponentbuilderLanguagePackaging
|
* @package ComponentbuilderLanguagePackaging
|
||||||
* @since 1.2.0
|
* @since 1.2.1
|
||||||
*/
|
*/
|
||||||
class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
||||||
{
|
{
|
||||||
@ -301,7 +300,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
|||||||
*
|
*
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
public function jcb_ce_onBeforeBuildPluginLangFiles(&$plugin, &$languages)
|
public function jcb_ce_onBeforeBuildPluginLangFiles(&$plugin)
|
||||||
{
|
{
|
||||||
// get component id
|
// get component id
|
||||||
$id = (int) CFactory::_('Config')->component_id;
|
$id = (int) CFactory::_('Config')->component_id;
|
||||||
@ -311,7 +310,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
|||||||
// set file name
|
// set file name
|
||||||
$file_name = 'plg_' . strtolower($plugin->group) . '_' . strtolower($plugin->code_name);
|
$file_name = 'plg_' . strtolower($plugin->group) . '_' . strtolower($plugin->code_name);
|
||||||
// extrude the languages that should not remain in the plugin
|
// extrude the languages that should not remain in the plugin
|
||||||
$this->extrudeLanguages($id, $languages, CFactory::_('Config')->lang_tag, $file_name, 'admin');
|
$this->extrudeLanguages($id, 'plugins', CFactory::_('Config')->lang_tag, $file_name, 'admin');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,7 +321,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
|||||||
*
|
*
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
public function jcb_ce_onBeforeBuildModuleLangFiles(&$module, &$languages)
|
public function jcb_ce_onBeforeBuildModuleLangFiles(&$module)
|
||||||
{
|
{
|
||||||
// get component id
|
// get component id
|
||||||
$id = (int) CFactory::_('Config')->component_id;
|
$id = (int) CFactory::_('Config')->component_id;
|
||||||
@ -330,7 +329,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
|||||||
if (ArrayHelper::check($this->activeComponents) && isset($this->activeComponents[$id]))
|
if (ArrayHelper::check($this->activeComponents) && isset($this->activeComponents[$id]))
|
||||||
{
|
{
|
||||||
// extrude the languages that should not remain in the module
|
// 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, 'modules', CFactory::_('Config')->lang_tag, $module->file_name, $module->target_client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,7 +340,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
|||||||
*
|
*
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
public function jcb_ce_onBeforeBuildAllLangFiles(&$languages)
|
public function jcb_ce_onBeforeBuildAllLangFiles($targetArea)
|
||||||
{
|
{
|
||||||
// get component id
|
// get component id
|
||||||
$id = (int) CFactory::_('Config')->component_id;
|
$id = (int) CFactory::_('Config')->component_id;
|
||||||
@ -351,7 +350,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
|||||||
// set file name
|
// set file name
|
||||||
$file_name = 'com_' . $this->activeComponentsNames[$id];
|
$file_name = 'com_' . $this->activeComponentsNames[$id];
|
||||||
// extrude the languages that should not remain in the module
|
// extrude the languages that should not remain in the module
|
||||||
$this->extrudeLanguages($id, $languages, CFactory::_('Config')->lang_tag, $file_name);
|
$this->extrudeLanguages($id, $targetArea, CFactory::_('Config')->lang_tag, $file_name);
|
||||||
}
|
}
|
||||||
// build the language packages
|
// build the language packages
|
||||||
$this->buildLanguages($id, CFactory::_('Config')->lang_tag);
|
$this->buildLanguages($id, CFactory::_('Config')->lang_tag);
|
||||||
@ -364,7 +363,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
|||||||
*
|
*
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
protected function extrudeLanguages(&$id, &$languages, $langTag, &$file_name, $target_client = 'both')
|
protected function extrudeLanguages(&$id, $targetArea, $langTag, &$file_name, $target_client = 'both')
|
||||||
{
|
{
|
||||||
$mainLangLoader = [];
|
$mainLangLoader = [];
|
||||||
// check if this id was set before
|
// check if this id was set before
|
||||||
@ -379,14 +378,14 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
|||||||
$this->languages[$id][$file_name] = [];
|
$this->languages[$id][$file_name] = [];
|
||||||
}
|
}
|
||||||
// set all the extra languages not excluded
|
// set all the extra languages not excluded
|
||||||
foreach ($languages as $key => $language)
|
foreach (CFactory::_('Compiler.Builder.Languages')->get($targetArea) as $key => $language)
|
||||||
{
|
{
|
||||||
if ($key !== $langTag && ArrayHelper::check($language) && (!isset($this->excludedLang[$id]) || !in_array($key, $this->excludedLang[$id])))
|
if ($key !== $langTag && ArrayHelper::check($language) && (!isset($this->excludedLang[$id]) || !in_array($key, $this->excludedLang[$id])))
|
||||||
{
|
{
|
||||||
// add to our bucket
|
// add to our bucket
|
||||||
$this->languages[$id][$file_name][$key] = $language;
|
$this->languages[$id][$file_name][$key] = $language;
|
||||||
// remove from the JCB build
|
// remove from the JCB build
|
||||||
unset($languages[$key]);
|
CFactory::_('Compiler.Builder.Languages')->remove("{$targetArea}.{$key}");
|
||||||
}
|
}
|
||||||
// count the area strings
|
// count the area strings
|
||||||
if ($langTag === $key)
|
if ($langTag === $key)
|
||||||
@ -463,7 +462,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
|||||||
// get the file name
|
// get the file name
|
||||||
$fileName = $this->getLanguageFileName($file_name, $tag, $area);
|
$fileName = $this->getLanguageFileName($file_name, $tag, $area);
|
||||||
// check if language should be added
|
// check if language should be added
|
||||||
if ($this->shouldLanguageBeAdded($tag, $languageStrings, $mainLangLoader[$area], $fileName) && ($actions = $this->getLangActions($file_name, $tag, $area, $target_client)) !== false)
|
if (CFactory::_('Language.Translation')->check($tag, $languageStrings, $mainLangLoader[$area], $fileName) && ($actions = $this->getLangActions($file_name, $tag, $area, $target_client)) !== false)
|
||||||
{
|
{
|
||||||
// set the language data
|
// set the language data
|
||||||
$lang = array_map(
|
$lang = array_map(
|
||||||
@ -677,53 +676,13 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
|||||||
* check if a translation should be added
|
* check if a translation should be added
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
* @deprecated 3.4 Use CFactory::_('Language.Translation')->check(...);
|
||||||
*/
|
*/
|
||||||
protected function shouldLanguageBeAdded(&$tag, &$languageStrings, &$total,
|
protected function shouldLanguageBeAdded(&$tag, &$languageStrings, &$total, &$file_name) {
|
||||||
&$file_name
|
|
||||||
) {
|
|
||||||
// only log messages for none $this->langTag translations
|
// only log messages for none $this->langTag translations
|
||||||
if ($this->langTag !== $tag)
|
CFactory::_('Language.Translation')->check(
|
||||||
{
|
$tag, $languageStrings, $total, $file_name
|
||||||
$langStringNr = count($languageStrings);
|
);
|
||||||
$langStringSum = ComponentbuilderHelper::bcmath(
|
|
||||||
'mul', $langStringNr, 100
|
|
||||||
);
|
|
||||||
$percentage = ComponentbuilderHelper::bcmath(
|
|
||||||
'div', $langStringSum, $total
|
|
||||||
);
|
|
||||||
$stringNAme = ($langStringNr == 1) ? '(string '
|
|
||||||
. $tag . ' translated)'
|
|
||||||
: '(strings ' . $tag . ' translated)';
|
|
||||||
|
|
||||||
// force load if debug lines are added
|
|
||||||
if (!$this->debugLinenr)
|
|
||||||
{
|
|
||||||
// check if we should install this translation
|
|
||||||
if ($percentage < $this->percentageLanguageAdd)
|
|
||||||
{
|
|
||||||
// dont add
|
|
||||||
CFactory::_('Compiler.Builder.Language.Messages')->set("exclude.$file_name",
|
|
||||||
'<b>' . $total . '</b>(total '
|
|
||||||
. $this->langTag . ' strings) only <b>'
|
|
||||||
. $langStringNr . '</b>' . $stringNAme
|
|
||||||
. ' = ' . $percentage
|
|
||||||
);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// show if it was added as well
|
|
||||||
CFactory::_('Compiler.Builder.Language.Messages')->set("include.$file_name",
|
|
||||||
'<b>' . $total . '</b>(total '
|
|
||||||
. $this->langTag . ' strings) and <b>'
|
|
||||||
. $langStringNr . '</b>' . $stringNAme . ' = '
|
|
||||||
. $percentage
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<extension type="plugin" version="3.10" group="extension" method="upgrade">
|
<extension type="plugin" version="3.10" group="extension" method="upgrade">
|
||||||
<name>PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING</name>
|
<name>PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING</name>
|
||||||
<creationDate>9th March, 2024</creationDate>
|
<creationDate>18th September, 2024</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.2.0</version>
|
<version>1.2.1</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 -->
|
||||||
@ -17,6 +17,8 @@
|
|||||||
<languages folder="language">
|
<languages folder="language">
|
||||||
<language tag="en-GB">en-GB/en-GB.plg_extension_componentbuilderlanguagepackaging.ini</language>
|
<language tag="en-GB">en-GB/en-GB.plg_extension_componentbuilderlanguagepackaging.ini</language>
|
||||||
<language tag="en-GB">en-GB/en-GB.plg_extension_componentbuilderlanguagepackaging.sys.ini</language>
|
<language tag="en-GB">en-GB/en-GB.plg_extension_componentbuilderlanguagepackaging.sys.ini</language>
|
||||||
|
<language tag="af-ZA">af-ZA/af-ZA.plg_extension_componentbuilderlanguagepackaging.ini</language>
|
||||||
|
<language tag="af-ZA">af-ZA/af-ZA.plg_extension_componentbuilderlanguagepackaging.sys.ini</language>
|
||||||
</languages>
|
</languages>
|
||||||
|
|
||||||
<!-- Plugin files -->
|
<!-- Plugin files -->
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
PLG_CONTENT_COMPONENTBUILDERLANGUAGETABS_YES="Ja"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERLANGUAGETABS_NO="Nee"
|
@ -0,0 +1,2 @@
|
|||||||
|
PLG_CONTENT_COMPONENTBUILDERLANGUAGETABS_YES="Ja"
|
||||||
|
PLG_CONTENT_COMPONENTBUILDERLANGUAGETABS_NO="Nee"
|
@ -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.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.1.2.1)</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>"
|
@ -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.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.1.2.1)</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>"
|
43
script.php
43
script.php
@ -48,49 +48,6 @@ class plgExtensionComponentbuilderLanguagePackagingInstallerScript
|
|||||||
|
|
||||||
if ('install' === $route)
|
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
|
// check that componentbuilder is installed
|
||||||
$pathToCore = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php';
|
$pathToCore = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php';
|
||||||
if (!JFile::exists($pathToCore))
|
if (!JFile::exists($pathToCore))
|
||||||
|
Loading…
Reference in New Issue
Block a user