update - v2.1.2
This commit is contained in:
parent
b69e3f953d
commit
eac2ad4e47
@ -22,7 +22,7 @@ JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/c
|
||||
* Extension - Componentbuilder Headers Compiler plugin.
|
||||
*
|
||||
* @package ComponentbuilderHeadersCompiler
|
||||
* @since 2.1.1
|
||||
* @since 2.1.2
|
||||
*/
|
||||
class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
|
||||
{
|
||||
@ -441,28 +441,26 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
|
||||
public function jcb_ce_setClassHeader(&$context, &$event_context, &$view_name, &$headers)
|
||||
{
|
||||
if ($this->loadHeaders && isset($this->activeHeaders[$view_name])
|
||||
&& isset($this->activeHeaders[$view_name][$event_context]))
|
||||
&& isset($this->activeHeaders[$view_name][$event_context])
|
||||
&& is_array($this->activeHeaders[$view_name][$event_context]))
|
||||
{
|
||||
// we have default headers we actually need
|
||||
foreach ($headers as $n => $header)
|
||||
// work with the header values as keys
|
||||
$_headers = array_flip($headers);
|
||||
|
||||
// new headers
|
||||
$new = $this->activeHeaders[$view_name][$event_context];
|
||||
|
||||
// now add the new headers
|
||||
foreach ($new as $n => $header)
|
||||
{
|
||||
// if an empty line is found just skip it
|
||||
if (empty($header))
|
||||
// if an empty line is found just skip it
|
||||
// we check if this header is already set
|
||||
if (empty($header) || isset($_headers[$header]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// we check if this header is also set from the user
|
||||
if (isset($this->activeHeaders[$view_name][$event_context]) && strpos(
|
||||
$this->activeHeaders[$view_name][$event_context], $header
|
||||
) !== false)
|
||||
{
|
||||
// since it is set, remove it here
|
||||
unset($headers[$n]);
|
||||
}
|
||||
$headers[] = $header;
|
||||
}
|
||||
// now add the custom headers
|
||||
// yes they are below the defaults, unless overridden and removed above
|
||||
$headers[] = $this->activeHeaders[$view_name][$event_context];
|
||||
}
|
||||
}
|
||||
|
||||
@ -577,13 +575,28 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
|
||||
// load the headers if text
|
||||
if (isset($params[$get['field']]) && ComponentbuilderHelper::checkString($params[$get['field']]))
|
||||
{
|
||||
$headers[] = $params[$get['field']];
|
||||
if (($_headers = explode(PHP_EOL, $params[$get['field']])) !== false)
|
||||
{
|
||||
foreach ($_headers as $header)
|
||||
{
|
||||
$header = trim($header);
|
||||
if (empty($header))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$headers[$header] = $header;
|
||||
}
|
||||
}
|
||||
}
|
||||
// load the headers if power
|
||||
if (isset($params['power_' . $get['field']]) && ComponentbuilderHelper::checkArray($params['power_' . $get['field']], true)
|
||||
&& ($powers = $this->getPowers($params['power_' . $get['field']])) !== false)
|
||||
{
|
||||
$headers[] = $powers;
|
||||
foreach ($powers as $power)
|
||||
{
|
||||
$power = trim($power);
|
||||
$headers[$power] = $power;
|
||||
}
|
||||
}
|
||||
// check if we found some header values
|
||||
if (ComponentbuilderHelper::checkArray($headers, true))
|
||||
@ -594,15 +607,14 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
|
||||
if (!isset($this->activeHeaders[$view_name][$get['context']]))
|
||||
{
|
||||
// start the active header
|
||||
$this->activeHeaders[$view_name][$get['context']] = '';
|
||||
$this->activeHeaders[$view_name][$get['context']] = [];
|
||||
}
|
||||
else
|
||||
// load the found headers and avoid adding the same header twice
|
||||
foreach ($headers as $header)
|
||||
{
|
||||
// each addition we add a new line
|
||||
$this->activeHeaders[$view_name][$get['context']] .= PHP_EOL;
|
||||
$header = trim($header);
|
||||
$this->activeHeaders[$view_name][$get['context']][$header] = $header;
|
||||
}
|
||||
// load the found headers
|
||||
$this->activeHeaders[$view_name][$get['context']] .= implode(PHP_EOL, $headers);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -633,11 +645,11 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
|
||||
/**
|
||||
* get the powers header use strings
|
||||
*
|
||||
* @return mixed
|
||||
* @return array|null
|
||||
*
|
||||
* @since 1.0.6
|
||||
*/
|
||||
protected function getPowers($rows)
|
||||
protected function getPowers($rows): ?array
|
||||
{
|
||||
// load the active powers
|
||||
$powers = array_filter(
|
||||
@ -660,7 +672,7 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
|
||||
if (ComponentbuilderHelper::checkArray($powers))
|
||||
{
|
||||
// convert the dots to namespace
|
||||
$powers = array_map(function ($power) {
|
||||
return array_map(function ($power) {
|
||||
// add to compiler (to build)
|
||||
if ($power->build != 6)
|
||||
{
|
||||
@ -685,12 +697,9 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
|
||||
}
|
||||
return 'use ' . $namespace . ';';
|
||||
}, $powers);
|
||||
|
||||
// return the found powers
|
||||
return implode(PHP_EOL, $powers);
|
||||
}
|
||||
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<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.1.1</version>
|
||||
<version>2.1.2</version>
|
||||
<description>PLG_EXTENSION_COMPONENTBUILDERHEADERSCOMPILER_XML_DESCRIPTION</description>
|
||||
|
||||
<!-- Scripts to run on installation -->
|
||||
|
@ -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.1.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.2)</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>"
|
@ -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.1.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.2)</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>"
|
Loading…
Reference in New Issue
Block a user