52
0
Fork 0

update - v1.0.7

This commit is contained in:
Llewellyn van der Merwe 2021-12-03 04:46:17 +02:00
parent e144ab8c14
commit cbbe81168d
Signed by: Llewellyn
GPG Key ID: EFC0C720A240551C
5 changed files with 200 additions and 63 deletions

View File

@ -1,12 +1,12 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @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 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder-Pro>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
@ -22,11 +22,11 @@ JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/c
* Extension - Componentbuilder Headers Compiler plugin.
*
* @package ComponentbuilderHeadersCompiler
* @since 1.0.5
* @since 1.0.7
*/
class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
{
/**
/**
* Global switch to see if a file has custom headers.
*
* @var boolean
@ -42,6 +42,22 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
*/
protected $activeFiles = array();
/**
* The compiler placeholders values
*
* @var array
* @since 1.0.6
*/
protected $placeholders = array();
/**
* The powers to include in project
*
* @var array
* @since 1.0.6
*/
protected $linkedPowers = array();
/**
* The Targets
*
@ -61,6 +77,16 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
'context' => 'admin.view',
'view' => 'name_single'
),
'add_admin_view_html' => array(
'field' => 'admin_view_html',
'context' => 'admin.view.html',
'view' => 'name_single'
),
'add_site_admin_view_html' => array(
'field' => 'site_admin_view_html',
'context' => 'site.admin.view.html',
'view' => 'name_single'
),
'add_admin_view_controller' => array(
'field' => 'admin_view_controller',
'context' => 'admin.view.controller',
@ -76,6 +102,11 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
'context' => 'admin.views',
'view' => 'name_list'
),
'add_admin_views_html' => array(
'field' => 'admin_views_html',
'context' => 'admin.views.html',
'view' => 'name_list'
),
'add_admin_views_controller' => array(
'field' => 'admin_views_controller',
'context' => 'admin.views.controller',
@ -94,6 +125,11 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
'context' => 'site.view',
'view' => 'code'
),
'add_site_view_html' => array(
'field' => 'site_view_html',
'context' => 'site.view.html',
'view' => 'code'
),
'add_site_view_controller' => array(
'field' => 'site_view_controller',
'context' => 'site.view.controller',
@ -109,6 +145,11 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
'context' => 'site.views',
'view' => 'code'
),
'add_site_views_html' => array(
'field' => 'site_views_html',
'context' => 'site.views.html',
'view' => 'code'
),
'add_site_views_controller' => array(
'field' => 'site_views_controller',
'context' => 'site.views.controller',
@ -127,6 +168,11 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
'context' => 'custom.admin.view',
'view' => 'code'
),
'add_custom_admin_view_html' => array(
'field' => 'custom_admin_view_html',
'context' => 'custom.admin.view.html',
'view' => 'code'
),
'add_custom_admin_view_controller' => array(
'field' => 'custom_admin_view_controller',
'context' => 'custom.admin.view.controller',
@ -142,6 +188,11 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
'context' => 'custom.admin.views',
'view' => 'code'
),
'add_custom_admin_views_html' => array(
'field' => 'custom_admin_views_html',
'context' => 'custom.admin.views.html',
'view' => 'code'
),
'add_custom_admin_views_controller' => array(
'field' => 'custom_admin_views_controller',
'context' => 'custom.admin.views.controller',
@ -183,7 +234,7 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
public function jcb_ce_onBeforeModelViewData(&$context, &$view,
&$placeholders
) {
// add the privacy
// add the headers
$view->params = (isset($view->params)
&& ComponentbuilderHelper::checkJson($view->params)) ? json_decode(
$view->params, true
@ -199,15 +250,8 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
if (isset($view->params['admin_view_headers'][$target])
&& $view->params['admin_view_headers'][$target] == 1)
{
// activate the load of the privacy plugin
$this->loadHeaders = true;
// setup the view key name
$view_name = ComponentbuilderHelper::safeString(
$view->{$event['view']}
);
// load the headers
$this->activeFiles[$view_name][$event['context']]
= $view->params['admin_view_headers'][$event['field']];
// get the header string if set
$this->getHeaderString($view, $event, 'admin_view_headers');
}
}
}
@ -223,7 +267,7 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
public function jcb_ce_onBeforeModelCustomViewData(&$context, &$view,
&$id, &$table
) {
// add the privacy
// add the headers
$view->params = (isset($view->params)
&& ComponentbuilderHelper::checkJson($view->params)) ? json_decode(
$view->params, true
@ -240,15 +284,8 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
if (isset($view->params['site_view_headers'][$target])
&& $view->params['site_view_headers'][$target] == 1)
{
// activate the load of the privacy plugin
$this->loadHeaders = true;
// setup the view key name
$view_name = ComponentbuilderHelper::safeString(
$view->{$event['view']}
);
// load the headers
$this->activeFiles[$view_name][$event['context']]
= $view->params['site_view_headers'][$event['field']];
// get the header string if set
$this->getHeaderString($view, $event, 'site_view_headers');
}
}
}
@ -264,15 +301,8 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
if (isset($view->params['custom_admin_view_headers'][$target])
&& $view->params['custom_admin_view_headers'][$target] == 1)
{
// activate the load of the privacy plugin
$this->loadHeaders = true;
// setup the view key name
$view_name = ComponentbuilderHelper::safeString(
$view->{$event['view']}
);
// load the headers
$this->activeFiles[$view_name][$event['context']]
= $view->params['custom_admin_view_headers'][$event['field']];
// get the header string if set
$this->getHeaderString($view, $event, 'custom_admin_view_headers');
}
}
}
@ -303,7 +333,7 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
if (isset($component->params['joomla_component_headers'][$target])
&& $component->params['joomla_component_headers'][$target] == 1)
{
// activate the load of the privacy plugin
// activate the load of the headers
$this->loadHeaders = true;
// load the headers
$this->activeFiles[$event['view']][$event['context']]
@ -313,6 +343,85 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
}
}
/**
* get the header string
*
* @return void
*
* @since 1.0
*/
protected function getHeaderString(&$view, &$get, $key, $view_name = null)
{
// we first check if the value is set
if (isset($view->params[$key][$get['field']]) || isset($view->params[$key]['power_' . $get['field']]))
{
// activate the load of the headers
$this->loadHeaders = true;
// setup the view key name
if (!$view_name)
{
$view_name = ComponentbuilderHelper::safeString(
$view->{$get['view']}
);
}
// we start this field if not already
if (!isset($this->activeFiles[$view_name][$get['context']]))
{
$this->activeFiles[$view_name][$get['context']] = '';
}
// start little bucket
$bucket = array();
// load the headers if text
if (isset($view->params[$key][$get['field']]) && ComponentbuilderHelper::checkString($view->params[$key][$get['field']]))
{
$bucket[] = $view->params[$key][$get['field']];
}
// load the headers if power
if (isset($view->params[$key]['power_' . $get['field']]) && ComponentbuilderHelper::checkArray($view->params[$key]['power_' . $get['field']], true)
&& ($use = $this->getPowers($view->params[$key]['power_' . $get['field']])) !== false)
{
$bucket[] = 'use ' . implode(';' . PHP_EOL . 'use ', $use) . ';';
}
// we start this field if not already
if (ComponentbuilderHelper::checkArray($bucket, true))
{
$this->activeFiles[$view_name][$get['context']] .= implode(PHP_EOL, $bucket);
}
}
}
/**
* get the powers header use strings
*
* @return string
*
* @since 1.0.6
*/
protected function getPowers($ids)
{
// if none are found
$namspaces = false;
// add to active powers
if (($namspaces = ComponentbuilderHelper::getVars('power', $ids, 'id', 'namespace')) !== false)
{
foreach ($ids as $id)
{
$this->linkedPowers[$id] = $id;
}
// convert the dots to namespace
$namspaces = array_map( function($namespace) {
return ComponentbuilderHelper::safeNamespace(
str_replace(
array_keys($this->placeholders),
array_values($this->placeholders),
str_replace('.', '\\', $namespace)
)
);
}, $namspaces );
}
return $namspaces;
}
/**
* Event Triggered in the compiler [on set Class Header]
*
@ -331,9 +440,9 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
foreach ($headers as $n => $header)
{
// we check if this header is also set from the user
if (strpos(
if (empty($header) || (isset($this->activeFiles[$view_name][$event_context]) && strpos(
$this->activeFiles[$view_name][$event_context], $header
) !== false)
) !== false))
{
// since it is set, remove it here
unset($headers[$n]);
@ -344,5 +453,33 @@ class PlgExtensionComponentbuilderHeadersCompiler extends CMSPlugin
$headers[] = $this->activeFiles[$view_name][$event_context];
}
}
/**
* Event Triggered in the compiler [on Before Get Component Data]
*
* @return void
*
* @since 1.0.6
*/
public function jcb_ce_onBeforeGetComponentData(&$context, $compiler)
{
// get placeholders from the compiler
$this->placeholders = $compiler->globalPlaceholders;
}
/**
* Event Triggered in the compiler [on After Get Component Data]
*
* @return void
*
* @since 1.0.6
*/
public function jcb_ce_onAfterGetComponentData(&$context, $compiler)
{
// add the powers to the component
if (ComponentbuilderHelper::checkArray($this->linkedPowers, true))
{
$compiler->linkedPowers = $this->linkedPowers;
}
}
}

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" version="3.8" group="extension" method="upgrade">
<extension type="plugin" version="4" group="extension" method="upgrade">
<name>PLG_EXTENSION_COMPONENTBUILDERHEADERSCOMPILER</name>
<creationDate>20th February, 2021</creationDate>
<creationDate>3rd December, 2021</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>
<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.0.5</version>
<version>1.0.7</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.1.0.5)</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.7)</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>"
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.1.0.5)</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.7)</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>"
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

@ -1,12 +1,12 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @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 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder-Pro>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
@ -60,8 +60,8 @@ class plgExtensionComponentbuilderHeadersCompilerInstallerScript
{
// get the version
$jcbVersion = explode('.', $manifest->version);
// check that we have JCB 2.12.6 or higher installed
if (count($jcbVersion) == 3 && $jcbVersion[0] >= 2 && (($jcbVersion[1] == 12 && $jcbVersion[2] >= 6) || $jcbVersion[1] > 12))
// check that we have JCB 2.12.14 or higher installed
if (count($jcbVersion) == 3 && (($jcbVersion[0] == 2 && (($jcbVersion[1] == 12 && $jcbVersion[2] >= 14) || ($jcbVersion[1] > 12))) || $jcbVersion[0] >= 3))
{
$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.6 or higher before installing this plugin.', 'error');
$app->enqueueMessage('Please upgrade to JCB-PRO 2.12.14 or higher before installing this plugin.', 'error');
return false;
}
}