Compare commits
43 Commits
Author | SHA1 | Date | |
---|---|---|---|
fe245fc90e | |||
45f788cbd8 | |||
4bae832fe1 | |||
818a4a9237 | |||
8909fde824 | |||
fb7edadb0c | |||
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,24 @@
|
||||
// No direct access to this file
|
||||
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\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\ArrayHelper;
|
||||
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\GetHelper;
|
||||
use Joomla\CMS\Filesystem\Folder;
|
||||
|
||||
/**
|
||||
* Extension - Componentbuilder Language Packaging plugin.
|
||||
*
|
||||
* @package ComponentbuilderLanguagePackaging
|
||||
* @since 1.2.0
|
||||
* @since 1.2.1
|
||||
*/
|
||||
class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
||||
{
|
||||
@ -301,7 +301,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function jcb_ce_onBeforeBuildPluginLangFiles(&$plugin, &$languages)
|
||||
public function jcb_ce_onBeforeBuildPluginLangFiles(&$plugin)
|
||||
{
|
||||
// get component id
|
||||
$id = (int) CFactory::_('Config')->component_id;
|
||||
@ -311,7 +311,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
||||
// 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, 'plugins', CFactory::_('Config')->lang_tag, $file_name, 'admin');
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,7 +322,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function jcb_ce_onBeforeBuildModuleLangFiles(&$module, &$languages)
|
||||
public function jcb_ce_onBeforeBuildModuleLangFiles(&$module)
|
||||
{
|
||||
// get component id
|
||||
$id = (int) CFactory::_('Config')->component_id;
|
||||
@ -330,7 +330,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
||||
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, 'modules', CFactory::_('Config')->lang_tag, $module->file_name, $module->target_client);
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,7 +341,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function jcb_ce_onBeforeBuildAllLangFiles(&$languages)
|
||||
public function jcb_ce_onBeforeBuildAllLangFiles($targetArea)
|
||||
{
|
||||
// get component id
|
||||
$id = (int) CFactory::_('Config')->component_id;
|
||||
@ -351,7 +351,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
||||
// 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, $targetArea, CFactory::_('Config')->lang_tag, $file_name);
|
||||
}
|
||||
// build the language packages
|
||||
$this->buildLanguages($id, CFactory::_('Config')->lang_tag);
|
||||
@ -364,7 +364,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
||||
*
|
||||
* @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 = [];
|
||||
// check if this id was set before
|
||||
@ -379,14 +379,14 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
||||
$this->languages[$id][$file_name] = [];
|
||||
}
|
||||
// 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])))
|
||||
{
|
||||
// add to our bucket
|
||||
$this->languages[$id][$file_name][$key] = $language;
|
||||
// remove from the JCB build
|
||||
unset($languages[$key]);
|
||||
CFactory::_('Compiler.Builder.Languages')->remove("{$targetArea}.{$key}");
|
||||
}
|
||||
// count the area strings
|
||||
if ($langTag === $key)
|
||||
@ -444,7 +444,7 @@ 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]) && is_dir($main_path))
|
||||
{
|
||||
// remove the main folder
|
||||
ComponentbuilderHelper::removeFolder($main_path);
|
||||
@ -452,9 +452,9 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
||||
$this->languageTracker[$main_path] = true;
|
||||
}
|
||||
// check if exist and create if not
|
||||
if (!JFolder::exists($main_path))
|
||||
if (!is_dir($main_path))
|
||||
{
|
||||
JFolder::create($main_path);
|
||||
Folder::create($main_path);
|
||||
// count the folder created
|
||||
CFactory::_('Utilities.Counter')->folder++;
|
||||
}
|
||||
@ -463,7 +463,7 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
||||
// get the file name
|
||||
$fileName = $this->getLanguageFileName($file_name, $tag, $area);
|
||||
// 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
|
||||
$lang = array_map(
|
||||
@ -481,9 +481,9 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
||||
{
|
||||
$client_path = $main_path . $act['target_client'] . '/';
|
||||
// check if exist and create if not
|
||||
if (!JFolder::exists($client_path))
|
||||
if (!is_dir($client_path))
|
||||
{
|
||||
JFolder::create($client_path);
|
||||
Folder::create($client_path);
|
||||
// count the folder created
|
||||
$this->folderCount++;
|
||||
}
|
||||
@ -677,53 +677,13 @@ class PlgExtensionComponentbuilderLanguagePackaging extends CMSPlugin
|
||||
* check if a translation should be added
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @deprecated 3.4 Use CFactory::_('Language.Translation')->check(...);
|
||||
*/
|
||||
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(
|
||||
'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;
|
||||
CFactory::_('Language.Translation')->check(
|
||||
$tag, $languageStrings, $total, $file_name
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="plugin" version="3.10" group="extension" method="upgrade">
|
||||
<name>PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING</name>
|
||||
<creationDate>9th March, 2024</creationDate>
|
||||
<creationDate>7th November, 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>1.2.1</version>
|
||||
<description>PLG_EXTENSION_COMPONENTBUILDERLANGUAGEPACKAGING_XML_DESCRIPTION</description>
|
||||
|
||||
<!-- Scripts to run on installation -->
|
||||
@ -17,6 +17,8 @@
|
||||
<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.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>
|
||||
|
||||
<!-- 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_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_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>"
|
45
script.php
45
script.php
@ -48,52 +48,9 @@ class plgExtensionComponentbuilderLanguagePackagingInstallerScript
|
||||
|
||||
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))
|
||||
if (!is_file($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;
|
||||
|
Loading…
Reference in New Issue
Block a user