update - v1.0.4
This commit is contained in:
parent
c37702781e
commit
5fd3eb8a72
@ -5,7 +5,7 @@
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||
* @copyright Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved.
|
||||
* @copyright Copyright (C) 2015 - 2021 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
@ -22,31 +22,31 @@ JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/c
|
||||
* Extension - Componentbuilder Headers Compiler plugin.
|
||||
*
|
||||
* @package ComponentbuilderHeadersCompiler
|
||||
* @since 1.0.3
|
||||
* @since 1.0.4
|
||||
*/
|
||||
class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
|
||||
{
|
||||
/**
|
||||
* Global switch to see if component have need class headers.
|
||||
* Global switch to see if a file has custom headers.
|
||||
*
|
||||
* @var boolean
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $loadClassHeaders = false;
|
||||
protected $loadHeaders = false;
|
||||
|
||||
/**
|
||||
* The Views active with default ordering options
|
||||
* The files active with headers
|
||||
*
|
||||
* @var array
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $activeViews = array();
|
||||
protected $activeFiles = array();
|
||||
|
||||
/**
|
||||
* The Targets
|
||||
*
|
||||
* @var array
|
||||
* @since 1.0.3
|
||||
* @since 1.0.4
|
||||
*/
|
||||
protected $targets = array(
|
||||
'admin_view_headers' =>
|
||||
@ -117,6 +117,29 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
|
||||
'context' => 'custom.admin.views.model',
|
||||
'view' => 'code'
|
||||
)
|
||||
),
|
||||
'joomla_component_headers' =>
|
||||
array(
|
||||
'add_admin_component' => array(
|
||||
'field' => 'admin_component',
|
||||
'context' => 'admin.component',
|
||||
'view' => 'admin'
|
||||
),
|
||||
'add_site_component' => array(
|
||||
'field' => 'site_component',
|
||||
'context' => 'site.component',
|
||||
'view' => 'site'
|
||||
),
|
||||
'add_admin_helper' => array(
|
||||
'field' => 'admin_helper',
|
||||
'context' => 'admin.helper',
|
||||
'view' => 'admin'
|
||||
),
|
||||
'add_site_helper' => array(
|
||||
'field' => 'site_helper',
|
||||
'context' => 'site.helper',
|
||||
'view' => 'site'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@ -147,13 +170,13 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
|
||||
&& $view->params['admin_view_headers'][$target] == 1)
|
||||
{
|
||||
// activate the load of the privacy plugin
|
||||
$this->loadClassHeaders = true;
|
||||
$this->loadHeaders = true;
|
||||
// setup the view key name
|
||||
$view_name = ComponentbuilderHelper::safeString(
|
||||
$view->{$event['view']}
|
||||
);
|
||||
// load the admin view details
|
||||
$this->activeViews[$view_name][$event['context']]
|
||||
// load the headers
|
||||
$this->activeFiles[$view_name][$event['context']]
|
||||
= $view->params['admin_view_headers'][$event['field']];
|
||||
}
|
||||
}
|
||||
@ -165,7 +188,7 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0
|
||||
* @since 1.2
|
||||
*/
|
||||
public function jcb_ce_onBeforeModelCustomViewData(&$context, &$view,
|
||||
&$id, &$table
|
||||
@ -188,18 +211,18 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
|
||||
&& $view->params['site_view_headers'][$target] == 1)
|
||||
{
|
||||
// activate the load of the privacy plugin
|
||||
$this->loadClassHeaders = true;
|
||||
$this->loadHeaders = true;
|
||||
// setup the view key name
|
||||
$view_name = ComponentbuilderHelper::safeString(
|
||||
$view->{$event['view']}
|
||||
);
|
||||
// load the admin view details
|
||||
$this->activeViews[$view_name][$event['context']]
|
||||
// load the headers
|
||||
$this->activeFiles[$view_name][$event['context']]
|
||||
= $view->params['site_view_headers'][$event['field']];
|
||||
}
|
||||
}
|
||||
}
|
||||
// target custom admin veiws
|
||||
// target custom admin views
|
||||
if (ComponentbuilderHelper::checkArray($view->params)
|
||||
&& isset($view->params['custom_admin_view_headers'])
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
@ -212,13 +235,13 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
|
||||
&& $view->params['custom_admin_view_headers'][$target] == 1)
|
||||
{
|
||||
// activate the load of the privacy plugin
|
||||
$this->loadClassHeaders = true;
|
||||
$this->loadHeaders = true;
|
||||
// setup the view key name
|
||||
$view_name = ComponentbuilderHelper::safeString(
|
||||
$view->{$event['view']}
|
||||
);
|
||||
// load the admin view details
|
||||
$this->activeViews[$view_name][$event['context']]
|
||||
// load the headers
|
||||
$this->activeFiles[$view_name][$event['context']]
|
||||
= $view->params['custom_admin_view_headers'][$event['field']];
|
||||
}
|
||||
}
|
||||
@ -226,7 +249,42 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
|
||||
}
|
||||
|
||||
/**
|
||||
* Event Triggered in the compiler [on set ClassHeader]
|
||||
* Event Triggered in the compiler [on Before Model Component Data]
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
public function jcb_ce_onBeforeModelComponentData(&$context, &$component)
|
||||
{
|
||||
// add the privacy
|
||||
$component->params = (isset($component->params)
|
||||
&& ComponentbuilderHelper::checkJson($component->params)) ? json_decode(
|
||||
$component->params, true
|
||||
) : $component->params;
|
||||
if (ComponentbuilderHelper::checkArray($component->params)
|
||||
&& isset($component->params['joomla_component_headers'])
|
||||
&& ComponentbuilderHelper::checkArray(
|
||||
$component->params['joomla_component_headers']
|
||||
))
|
||||
{
|
||||
foreach ($this->targets['joomla_component_headers'] as $target => $event)
|
||||
{
|
||||
if (isset($component->params['joomla_component_headers'][$target])
|
||||
&& $component->params['joomla_component_headers'][$target] == 1)
|
||||
{
|
||||
// activate the load of the privacy plugin
|
||||
$this->loadHeaders = true;
|
||||
// load the headers
|
||||
$this->activeFiles[$event['view']][$event['context']]
|
||||
= $component->params['joomla_component_headers'][$event['field']];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event Triggered in the compiler [on set Class Header]
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@ -236,15 +294,15 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
|
||||
&$view_name,
|
||||
&$headers
|
||||
) {
|
||||
if ($this->loadClassHeaders && isset($this->activeViews[$view_name])
|
||||
&& isset($this->activeViews[$view_name][$event_context]))
|
||||
if ($this->loadHeaders && isset($this->activeFiles[$view_name])
|
||||
&& isset($this->activeFiles[$view_name][$event_context]))
|
||||
{
|
||||
// we have default headers we actually need
|
||||
foreach ($headers as $n => $header)
|
||||
{
|
||||
// we check if this header is also set from the user
|
||||
if (strpos(
|
||||
$this->activeViews[$view_name][$event_context], $header
|
||||
$this->activeFiles[$view_name][$event_context], $header
|
||||
) !== false)
|
||||
{
|
||||
// since it is set, remove it here
|
||||
@ -252,8 +310,8 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
|
||||
}
|
||||
}
|
||||
// now add the custom headers
|
||||
// yes they are below the defaults, unless overridden and remove above
|
||||
$headers[] = $this->activeViews[$view_name][$event_context];
|
||||
// yes they are below the defaults, unless overridden and removed above
|
||||
$headers[] = $this->activeFiles[$view_name][$event_context];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="plugin" version="3.8" group="extension" method="upgrade">
|
||||
<name>PLG_EXTENSION_COMPONENTBUILDERHEADERSCOMPILER</name>
|
||||
<creationDate>8th December, 2020</creationDate>
|
||||
<creationDate>26th December, 2020</creationDate>
|
||||
<author>Llewellyn van der Merwe</author>
|
||||
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
|
||||
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>
|
||||
<copyright>Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved.</copyright>
|
||||
<copyright>Copyright (C) 2015 - 2021 Vast Development Method. All rights reserved.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<version>1.0.3</version>
|
||||
<version>1.0.4</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.1.0.3)</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.1.0.4)</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='http://www.joomlacomponentbuilder.com' 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.1.0.3)</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.1.0.4)</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='http://www.joomlacomponentbuilder.com' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 24th May, 2020</small></p>"
|
@ -5,7 +5,7 @@
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||
* @copyright Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved.
|
||||
* @copyright Copyright (C) 2015 - 2021 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
@ -60,8 +60,8 @@ class plgExtensionComponentbuilderHeadersCompilerInstallerScript
|
||||
{
|
||||
// get the version
|
||||
$jcbVersion = explode('.', $manifest->version);
|
||||
// check that we have JCB 2.12.1 or higher installed
|
||||
if (count($jcbVersion) == 3 && $jcbVersion[0] >= 2 && $jcbVersion[1] > 11)
|
||||
// check that we have JCB 2.12.4 or higher installed
|
||||
if (count($jcbVersion) == 3 && $jcbVersion[0] >= 2 && (($jcbVersion[1] == 12 && $jcbVersion[2] >= 4) || $jcbVersion[1] > 12))
|
||||
{
|
||||
$blockInstall = false;
|
||||
}
|
||||
@ -69,7 +69,7 @@ class plgExtensionComponentbuilderHeadersCompilerInstallerScript
|
||||
// allow install if all conditions are met
|
||||
if ($blockInstall)
|
||||
{
|
||||
$app->enqueueMessage('Please upgrade to JCB 2.12.1 or higher before installing this plugin.', 'error');
|
||||
$app->enqueueMessage('Please upgrade to JCB 2.12.4 or higher before installing this plugin.', 'error');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user