52
0
Fork 0

update - v2.1.0

This commit is contained in:
Llewellyn van der Merwe 2022-05-18 13:08:14 +02:00
parent 46e7de3285
commit 76fead933e
Signed by: Llewellyn
GPG Key ID: A9201372263741E7
5 changed files with 54 additions and 24 deletions

View File

@ -22,7 +22,7 @@ JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/c
* Extension - Componentbuilder Headers Compiler plugin.
*
* @package ComponentbuilderHeadersCompiler
* @since 2.0.1
* @since 2.1.0
*/
class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
{
@ -581,9 +581,9 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
}
// load the headers if power
if (isset($params['power_' . $get['field']]) && ComponentbuilderHelper::checkArray($params['power_' . $get['field']], true)
&& ($use = $this->getPowers($params['power_' . $get['field']])) !== false)
&& ($powers = $this->getPowers($params['power_' . $get['field']])) !== false)
{
$headers[] = 'use ' . implode(';' . PHP_EOL . 'use ', $use) . ';';
$headers[] = $powers;
}
// check if we found some header values
if (ComponentbuilderHelper::checkArray($headers, true))
@ -637,30 +637,60 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
*
* @since 1.0.6
*/
protected function getPowers($guids)
protected function getPowers($rows)
{
// if none are found
$namspaces = false;
// add to active powers
if (($namspaces = ComponentbuilderHelper::getVars('power', $guids, 'guid', 'namespace', 'IN_STRINGS')) !== false)
{
foreach ($guids as $guid)
{
$this->linkedPowers[$guid] = $guid;
// load the active powers
$powers = array_filter(
// get the power namespace
array_map(function ($row) {
if (($power = ComponentbuilderHelper::getGUID($row['power'], 'power', ['a.guid', 'a.namespace'])) !== false)
{
$power->build = (int) $row['build'];
$power->as = (string) $row['as'];
return $power;
}
return false;
}, $rows),
// check that we have valid powers
function ($row) {
return is_object($row) && isset($row->guid);
}
);
// add to active powers
if (ComponentbuilderHelper::checkArray($powers))
{
// convert the dots to namespace
$namspaces = array_map(function ($namespace) {
return ComponentbuilderHelper::safeNamespace(
$powers = array_map(function ($power) {
// add to compiler (to build)
if ($power->build != 6)
{
// secure that always will remain always even if only set that way once
if (empty($this->linkedPowers[$power->guid]) || $power->build == 1)
{
$this->linkedPowers[$power->guid] = $power->build;
}
}
// build the namespace
$namespace = ComponentbuilderHelper::safeNamespace(
str_replace(
array_keys($this->placeholders),
array_values($this->placeholders),
str_replace('.', '\\', $namespace)
str_replace('.', '\\', $power->namespace)
)
);
}, $namspaces);
// check if it has an AS option
if (ComponentbuilderHelper::checkString($power->as) && $power->as !== 'default')
{
return 'use ' . $namespace . ' as ' . $power->as . ';';
}
return 'use ' . $namespace . ';';
}, $powers);
// return the found powers
return implode(PHP_EOL, $powers);
}
return $namspaces;
return false;
}
}

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" version="4" group="extension" method="upgrade">
<name>PLG_EXTENSION_COMPONENTBUILDERHEADERSCOMPILER</name>
<creationDate>9th May, 2022</creationDate>
<creationDate>18th May, 2022</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>2.0.1</version>
<version>2.1.0</version>
<description>PLG_EXTENSION_COMPONENTBUILDERHEADERSCOMPILER_XML_DESCRIPTION</description>
<!-- Scripts to run on installation -->

View File

@ -2,6 +2,6 @@ PLG_EXTENSION_COMPONENTBUILDERHEADERSCOMPILER="Extension - Componentbuilder Head
PLG_EXTENSION_COMPONENTBUILDERHEADERSCOMPILER_DESCRIPTION="This plugin is used to set the custom headers for your classes during compilation. 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.
Also be sure to set your code where you would like to set Custom Headers."
PLG_EXTENSION_COMPONENTBUILDERHEADERSCOMPILER_XML_DESCRIPTION="<h1>Extension - Componentbuilder Headers Compiler (v.2.0.1)</h1> <div style='clear: both;'></div><p>This plugin is used to set the custom headers for your classes during compilation. 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_COMPONENTBUILDERHEADERSCOMPILER_XML_DESCRIPTION="<h1>Extension - Componentbuilder Headers Compiler (v.2.1.0)</h1> <div style='clear: both;'></div><p>This plugin is used to set the custom headers for your classes during compilation. 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.
Also be sure to set your code where you would like to set Custom Headers.</p><p>Created by <a href='https://dev.vdm.io' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 24th May, 2020</small></p>"

View File

@ -2,6 +2,6 @@ PLG_EXTENSION_COMPONENTBUILDERHEADERSCOMPILER="Extension - Componentbuilder Head
PLG_EXTENSION_COMPONENTBUILDERHEADERSCOMPILER_DESCRIPTION="This plugin is used to set the custom headers for your classes during compilation. 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.
Also be sure to set your code where you would like to set Custom Headers."
PLG_EXTENSION_COMPONENTBUILDERHEADERSCOMPILER_XML_DESCRIPTION="<h1>Extension - Componentbuilder Headers Compiler (v.2.0.1)</h1> <div style='clear: both;'></div><p>This plugin is used to set the custom headers for your classes during compilation. 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_COMPONENTBUILDERHEADERSCOMPILER_XML_DESCRIPTION="<h1>Extension - Componentbuilder Headers Compiler (v.2.1.0)</h1> <div style='clear: both;'></div><p>This plugin is used to set the custom headers for your classes during compilation. 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.
Also be sure to set your code where you would like to set Custom Headers.</p><p>Created by <a href='https://dev.vdm.io' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 24th May, 2020</small></p>"

View File

@ -61,10 +61,10 @@ class plgExtensionComponentbuilderHeadersCompilerInstallerScript
{
// get the version
$jcbVersion = explode('.', $manifest->version);
// check that we have JCB 3.0.11 or higher installed
// check that we have JCB 3.0.14 or higher installed
if (count($jcbVersion) == 3 && $jcbVersion[0] >= 3 &&
(
($jcbVersion[0] == 3 && $jcbVersion[1] == 0 && $jcbVersion[2] >= 11) ||
($jcbVersion[0] == 3 && $jcbVersion[1] == 0 && $jcbVersion[2] >= 14) ||
($jcbVersion[0] == 3 && $jcbVersion[1] > 0) ||
$jcbVersion[0] > 3)
)
@ -75,7 +75,7 @@ class plgExtensionComponentbuilderHeadersCompilerInstallerScript
// allow install if all conditions are met
if ($blockInstall)
{
$app->enqueueMessage('Please upgrade to JCB-Pro v3.0.11 or higher before installing this plugin.', 'error');
$app->enqueueMessage('Please upgrade to JCB-Pro v3.0.14 or higher before installing this plugin.', 'error');
return false;
}
}