Update master #1

Merged
root merged 49 commits from joomla/Component-Builder:master into master 2024-02-06 12:33:45 +00:00
11 changed files with 739 additions and 330 deletions
Showing only changes of commit abe9b5d227 - Show all commits

View File

@ -140,13 +140,13 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder) + *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 30th August, 2022 + *Last Build*: 31st August, 2022
+ *Version*: 3.1.5 + *Version*: 3.1.5
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **319334** + *Line count*: **319873**
+ *Field count*: **2002** + *Field count*: **2002**
+ *File count*: **2087** + *File count*: **2090**
+ *Folder count*: **359** + *Folder count*: **359**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com). > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).

View File

@ -140,13 +140,13 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder) + *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 30th August, 2022 + *Last Build*: 31st August, 2022
+ *Version*: 3.1.5 + *Version*: 3.1.5
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **319334** + *Line count*: **319873**
+ *Field count*: **2002** + *Field count*: **2002**
+ *File count*: **2087** + *File count*: **2090**
+ *Folder count*: **359** + *Folder count*: **359**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com). > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).

View File

@ -648,6 +648,7 @@ class Get
* The Custom Script Builder * The Custom Script Builder
* *
* @var array * @var array
* @deprecated 3.3 Use CFactory::_('Customcode.Dispenser')->hub;
*/ */
public $customScriptBuilder = array(); public $customScriptBuilder = array();
@ -1716,17 +1717,17 @@ class Get
// add_javascript // add_javascript
if ($component->add_javascript == 1) if ($component->add_javascript == 1)
{ {
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$component->javascript, $component->javascript,
'component_js', 'component_js',
false, null,
false, null,
$guiMapper $guiMapper
); );
} }
else else
{ {
$this->customScriptBuilder['component_js'] = ''; CFactory::_('Customcode.Dispenser')->hub['component_js'] = '';
} }
unset($component->javascript); unset($component->javascript);
@ -1742,14 +1743,14 @@ class Get
$component->{'css_' . $area} $component->{'css_' . $area}
)) ))
{ {
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$component->{'css_' . $area}, $component->{'css_' . $area},
'component_css_' . $area 'component_css_' . $area
); );
} }
else else
{ {
$this->customScriptBuilder['component_css_' . $area] = ''; CFactory::_('Customcode.Dispenser')->hub['component_css_' . $area] = '';
} }
unset($component->{'css_' . $area}); unset($component->{'css_' . $area});
} }
@ -1776,17 +1777,17 @@ class Get
{ {
// set GUI mapper field // set GUI mapper field
$guiMapper['field'] = $scriptMethod . '_' . $scriptType; $guiMapper['field'] = $scriptMethod . '_' . $scriptType;
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$component->{$scriptMethod . '_' . $scriptType}, $component->{$scriptMethod . '_' . $scriptType},
$scriptMethod, $scriptMethod,
$scriptType, $scriptType,
false, null,
$guiMapper $guiMapper
); );
} }
else else
{ {
$this->customScriptBuilder[$scriptMethod][$scriptType] = ''; CFactory::_('Customcode.Dispenser')->hub[$scriptMethod][$scriptType] = '';
} }
unset($component->{$scriptMethod . '_' . $scriptType}); unset($component->{$scriptMethod . '_' . $scriptType});
} }
@ -1801,18 +1802,18 @@ class Get
// update GUI mapper // update GUI mapper
$guiMapper['field'] = 'php_helper_admin'; $guiMapper['field'] = 'php_helper_admin';
$guiMapper['prefix'] = PHP_EOL . PHP_EOL; $guiMapper['prefix'] = PHP_EOL . PHP_EOL;
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$component->php_helper_admin, $component->php_helper_admin,
'component_php_helper_admin', 'component_php_helper_admin',
false, null,
false, null,
$guiMapper $guiMapper
); );
unset($guiMapper['prefix']); unset($guiMapper['prefix']);
} }
else else
{ {
$this->customScriptBuilder['component_php_helper_admin'] = ''; CFactory::_('Customcode.Dispenser')->hub['component_php_helper_admin'] = '';
} }
unset($component->php_helper); unset($component->php_helper);
// add_admin_event // add_admin_event
@ -1822,17 +1823,17 @@ class Get
CFactory::_('Config')->lang_target = 'admin'; CFactory::_('Config')->lang_target = 'admin';
// update GUI mapper field // update GUI mapper field
$guiMapper['field'] = 'php_admin_event'; $guiMapper['field'] = 'php_admin_event';
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$component->php_admin_event, $component->php_admin_event,
'component_php_admin_event', 'component_php_admin_event',
false, null,
false, null,
$guiMapper $guiMapper
); );
} }
else else
{ {
$this->customScriptBuilder['component_php_admin_event'] = ''; CFactory::_('Customcode.Dispenser')->hub['component_php_admin_event'] = '';
} }
unset($component->php_admin_event); unset($component->php_admin_event);
// add_php_helper_both // add_php_helper_both
@ -1843,18 +1844,18 @@ class Get
// update GUI mapper field // update GUI mapper field
$guiMapper['field'] = 'php_helper_both'; $guiMapper['field'] = 'php_helper_both';
$guiMapper['prefix'] = PHP_EOL . PHP_EOL; $guiMapper['prefix'] = PHP_EOL . PHP_EOL;
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$component->php_helper_both, $component->php_helper_both,
'component_php_helper_both', 'component_php_helper_both',
false, null,
false, null,
$guiMapper $guiMapper
); );
unset($guiMapper['prefix']); unset($guiMapper['prefix']);
} }
else else
{ {
$this->customScriptBuilder['component_php_helper_both'] = ''; CFactory::_('Customcode.Dispenser')->hub['component_php_helper_both'] = '';
} }
// add_php_helper_site // add_php_helper_site
if ($component->add_php_helper_site == 1 if ($component->add_php_helper_site == 1
@ -1864,18 +1865,18 @@ class Get
// update GUI mapper field // update GUI mapper field
$guiMapper['field'] = 'php_helper_site'; $guiMapper['field'] = 'php_helper_site';
$guiMapper['prefix'] = PHP_EOL . PHP_EOL; $guiMapper['prefix'] = PHP_EOL . PHP_EOL;
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$component->php_helper_site, $component->php_helper_site,
'component_php_helper_site', 'component_php_helper_site',
false, null,
false, null,
$guiMapper $guiMapper
); );
unset($guiMapper['prefix']); unset($guiMapper['prefix']);
} }
else else
{ {
$this->customScriptBuilder['component_php_helper_site'] = ''; CFactory::_('Customcode.Dispenser')->hub['component_php_helper_site'] = '';
} }
unset($component->php_helper); unset($component->php_helper);
// add_site_event // add_site_event
@ -1885,23 +1886,23 @@ class Get
CFactory::_('Config')->lang_target = 'site'; CFactory::_('Config')->lang_target = 'site';
// update GUI mapper field // update GUI mapper field
$guiMapper['field'] = 'php_site_event'; $guiMapper['field'] = 'php_site_event';
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$component->php_site_event, $component->php_site_event,
'component_php_site_event', 'component_php_site_event',
false, null,
false, null,
$guiMapper $guiMapper
); );
} }
else else
{ {
$this->customScriptBuilder['component_php_site_event'] = ''; CFactory::_('Customcode.Dispenser')->hub['component_php_site_event'] = '';
} }
unset($component->php_site_event); unset($component->php_site_event);
// add_sql // add_sql
if ($component->add_sql == 1) if ($component->add_sql == 1)
{ {
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$component->sql, $component->sql,
'sql', 'sql',
'component_sql' 'component_sql'
@ -1911,7 +1912,7 @@ class Get
// add_sql_uninstall // add_sql_uninstall
if ($component->add_sql_uninstall == 1) if ($component->add_sql_uninstall == 1)
{ {
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$component->sql_uninstall, $component->sql_uninstall,
'sql_uninstall' 'sql_uninstall'
); );
@ -2259,13 +2260,13 @@ class Get
); );
// setup token check // setup token check
if (!isset($this->customScriptBuilder['token'])) if (!isset(CFactory::_('Customcode.Dispenser')->hub['token']))
{ {
$this->customScriptBuilder['token'] = array(); CFactory::_('Customcode.Dispenser')->hub['token'] = [];
} }
$this->customScriptBuilder['token'][$view->name_single_code] CFactory::_('Customcode.Dispenser')->hub['token'][$view->name_single_code]
= false; = false;
$this->customScriptBuilder['token'][$view->name_list_code] = false; CFactory::_('Customcode.Dispenser')->hub['token'][$view->name_list_code] = false;
// set some placeholders // set some placeholders
CFactory::_('Placeholder')->active[Placefix::_h('view')] CFactory::_('Placeholder')->active[Placefix::_h('view')]
= $view->name_single_code; = $view->name_single_code;
@ -2940,11 +2941,11 @@ class Get
); );
// update GUI mapper field // update GUI mapper field
$guiMapper['field'] = $scripter; $guiMapper['field'] = $scripter;
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$view->{$scripter}, $view->{$scripter},
$scripter_target, $scripter_target,
$view->name_single_code, $view->name_single_code,
false, null,
$guiMapper, $guiMapper,
true, true,
true, true,
@ -2956,9 +2957,9 @@ class Get
$view->$scripter, "task=ajax" $view->$scripter, "task=ajax"
) !== false) ) !== false)
{ {
if (!$this->customScriptBuilder['token'][$view->name_single_code]) if (!CFactory::_('Customcode.Dispenser')->hub['token'][$view->name_single_code])
{ {
$this->customScriptBuilder['token'][$view->name_single_code] CFactory::_('Customcode.Dispenser')->hub['token'][$view->name_single_code]
= true; = true;
} }
} }
@ -2974,11 +2975,11 @@ class Get
&& $view->{'add_' . $scripter} == 1 && $view->{'add_' . $scripter} == 1
&& StringHelper::check($view->{$scripter})) && StringHelper::check($view->{$scripter}))
{ {
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$view->{$scripter}, $view->{$scripter},
$scripter, $scripter,
$view->name_single_code, $view->name_single_code,
false, null,
array('prefix' => PHP_EOL), array('prefix' => PHP_EOL),
true, true,
true, true,
@ -3006,11 +3007,11 @@ class Get
{ {
// update GUI mapper field // update GUI mapper field
$guiMapper['field'] = $scripter; $guiMapper['field'] = $scripter;
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$view->{$scripter}, $view->{$scripter},
$scripter, $scripter,
$view->name_single_code, $view->name_single_code,
false, null,
$guiMapper $guiMapper
); );
@ -3089,11 +3090,11 @@ class Get
{ {
$guiMapper['type'] = 'html'; $guiMapper['type'] = 'html';
} }
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$view->$importScripter, $view->$importScripter,
$importScripter, $importScripter,
'import_' . $view->name_list_code, 'import_' . $view->name_list_code,
false, null,
$guiMapper $guiMapper
); );
unset($view->$importScripter); unset($view->$importScripter);
@ -3101,7 +3102,7 @@ class Get
else else
{ {
// load the default // load the default
$this->customScriptBuilder[$importScripter]['import_' CFactory::_('Customcode.Dispenser')->hub[$importScripter]['import_'
. $view->name_list_code] . $view->name_list_code]
= ComponentbuilderHelper::getDynamicScripts( = ComponentbuilderHelper::getDynamicScripts(
$importScripter, true $importScripter, true
@ -3113,7 +3114,7 @@ class Get
if (isset($view->add_php_ajax) && $view->add_php_ajax == 1) if (isset($view->add_php_ajax) && $view->add_php_ajax == 1)
{ {
// insure the token is added to edit view atleast // insure the token is added to edit view atleast
$this->customScriptBuilder['token'][$view->name_single_code] CFactory::_('Customcode.Dispenser')->hub['token'][$view->name_single_code]
= true; = true;
$addAjaxSite = false; $addAjaxSite = false;
if (isset($this->siteEditView[$id]) && $this->siteEditView[$id]) if (isset($this->siteEditView[$id]) && $this->siteEditView[$id])
@ -3133,10 +3134,10 @@ class Get
{ {
if ($addAjaxSite) if ($addAjaxSite)
{ {
$this->customScriptBuilder['site']['ajax_controller'][$view->name_single_code] CFactory::_('Customcode.Dispenser')->hub['site']['ajax_controller'][$view->name_single_code]
= array_values($view->ajax_input); = array_values($view->ajax_input);
} }
$this->customScriptBuilder['admin']['ajax_controller'][$view->name_single_code] CFactory::_('Customcode.Dispenser')->hub['admin']['ajax_controller'][$view->name_single_code]
= array_values($view->ajax_input); = array_values($view->ajax_input);
$this->addAjax = true; $this->addAjax = true;
unset($view->ajax_input); unset($view->ajax_input);
@ -3147,7 +3148,7 @@ class Get
$guiMapper['type'] = 'php'; $guiMapper['type'] = 'php';
// update GUI mapper field // update GUI mapper field
$guiMapper['field'] = 'php_ajaxmethod'; $guiMapper['field'] = 'php_ajaxmethod';
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$view->php_ajaxmethod, $view->php_ajaxmethod,
'admin', 'admin',
'ajax_model', 'ajax_model',
@ -3157,7 +3158,7 @@ class Get
if ($addAjaxSite) if ($addAjaxSite)
{ {
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$view->php_ajaxmethod, $view->php_ajaxmethod,
'site', 'site',
'ajax_model', 'ajax_model',
@ -3215,7 +3216,7 @@ class Get
if ($view->source == 1 && isset($view->tables)) if ($view->source == 1 && isset($view->tables))
{ {
// build and add the SQL dump // build and add the SQL dump
$this->customScriptBuilder['sql'][$view->name_single_code] CFactory::_('Customcode.Dispenser')->hub['sql'][$view->name_single_code]
= $this->buildSqlDump( = $this->buildSqlDump(
$view->tables, $view->name_single_code, $id $view->tables, $view->name_single_code, $id
); );
@ -3224,7 +3225,7 @@ class Get
elseif ($view->source == 2 && isset($view->sql)) elseif ($view->source == 2 && isset($view->sql))
{ {
// add the SQL dump string // add the SQL dump string
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$view->sql, $view->sql,
'sql', 'sql',
$view->name_single_code $view->name_single_code
@ -3577,7 +3578,7 @@ class Get
? json_decode($view->ajax_input, true) : null; ? json_decode($view->ajax_input, true) : null;
if (ArrayHelper::check($view->ajax_input)) if (ArrayHelper::check($view->ajax_input))
{ {
$this->customScriptBuilder[$target]['ajax_controller'][$view->code] CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller'][$view->code]
= array_values($view->ajax_input); = array_values($view->ajax_input);
$setAjax = true; $setAjax = true;
} }
@ -3587,7 +3588,7 @@ class Get
{ {
// set field // set field
$guiMapper['field'] = 'php_ajaxmethod'; $guiMapper['field'] = 'php_ajaxmethod';
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$view->php_ajaxmethod, $view->php_ajaxmethod,
$target, $target,
'ajax_model', 'ajax_model',
@ -3931,11 +3932,11 @@ class Get
{ {
$convert__ = false; $convert__ = false;
} }
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$this->_fieldData[$id]->javascript_view_footer, $this->_fieldData[$id]->javascript_view_footer,
'view_footer', 'view_footer',
$name_single, $name_single,
false, null,
array( array(
'table' => 'field', 'table' => 'field',
'id' => (int) $id, 'id' => (int) $id,
@ -3960,14 +3961,14 @@ class Get
"task=ajax" "task=ajax"
) !== false) ) !== false)
{ {
if (!isset($this->customScriptBuilder['token'])) if (!isset(CFactory::_('Customcode.Dispenser')->hub['token']))
{ {
$this->customScriptBuilder['token'] = array(); CFactory::_('Customcode.Dispenser')->hub['token'] = [];
} }
if (!isset($this->customScriptBuilder['token'][$name_single]) if (!isset(CFactory::_('Customcode.Dispenser')->hub['token'][$name_single])
|| !$this->customScriptBuilder['token'][$name_single]) || !CFactory::_('Customcode.Dispenser')->hub['token'][$name_single])
{ {
$this->customScriptBuilder['token'][$name_single] CFactory::_('Customcode.Dispenser')->hub['token'][$name_single]
= true; = true;
} }
} }
@ -3982,11 +3983,11 @@ class Get
{ {
$convert__ = false; $convert__ = false;
} }
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$this->_fieldData[$id]->css_view, $this->_fieldData[$id]->css_view,
'css_view', 'css_view',
$name_single, $name_single,
false, null,
array('prefix' => PHP_EOL), array('prefix' => PHP_EOL),
$convert__, $convert__,
$convert__, $convert__,
@ -4014,11 +4015,11 @@ class Get
{ {
$convert__ = false; $convert__ = false;
} }
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$this->_fieldData[$id]->javascript_views_footer, $this->_fieldData[$id]->javascript_views_footer,
'views_footer', 'views_footer',
$name_single, $name_single,
false, null,
array( array(
'table' => 'field', 'table' => 'field',
'id' => (int) $id, 'id' => (int) $id,
@ -4043,14 +4044,14 @@ class Get
"task=ajax" "task=ajax"
) !== false) ) !== false)
{ {
if (!isset($this->customScriptBuilder['token'])) if (!isset(CFactory::_('Customcode.Dispenser')->hub['token']))
{ {
$this->customScriptBuilder['token'] = array(); CFactory::_('Customcode.Dispenser')->hub['token'] = [];
} }
if (!isset($this->customScriptBuilder['token'][$name_list]) if (!isset(CFactory::_('Customcode.Dispenser')->hub['token'][$name_list])
|| !$this->customScriptBuilder['token'][$name_list]) || !CFactory::_('Customcode.Dispenser')->hub['token'][$name_list])
{ {
$this->customScriptBuilder['token'][$name_list] CFactory::_('Customcode.Dispenser')->hub['token'][$name_list]
= true; = true;
} }
} }
@ -4064,11 +4065,11 @@ class Get
{ {
$convert__ = false; $convert__ = false;
} }
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$this->_fieldData[$id]->css_views, $this->_fieldData[$id]->css_views,
'css_views', 'css_views',
$name_single, $name_single,
false, null,
array('prefix' => PHP_EOL), array('prefix' => PHP_EOL),
$convert__, $convert__,
$convert__, $convert__,
@ -4668,11 +4669,11 @@ class Get
// set GUI mapper field // set GUI mapper field
$guiMapper['field'] = $script; $guiMapper['field'] = $script;
$guiMapper['prefix'] = PHP_EOL . PHP_EOL; $guiMapper['prefix'] = PHP_EOL . PHP_EOL;
$this->setCustomScriptBuilder( CFactory::_('Customcode.Dispenser')->set(
$result->{$script}, $result->{$script},
CFactory::_('Config')->build_target . '_' . $script, CFactory::_('Config')->build_target . '_' . $script,
$view_code, $view_code,
false, null,
$guiMapper, $guiMapper,
true, true,
true, true,
@ -5131,135 +5132,35 @@ class Get
} }
/** /**
* set the script for the custom script builder * Set the script for the customcode dispenser
* *
* @param string $script The script * @param string $script The script
* @param string $first The first key * @param string $first The first key
* @param string $second The second key (if not set we use only first key) * @param string|null $second The second key (if not set we use only first key)
* @param string $third The third key (if not set we use only first and second key) * @param string|null $third The third key (if not set we use only first and second key)
* @param array $config The config options * @param array $config The config options
* @param bool $base64 The switch to decode base64 the script * @param bool $base64 The switch to decode base64 the script
* default: true * default: true
* @param bool $dynamic The switch to dynamic update the script * @param bool $dynamic The switch to dynamic update the script
* default: true * default: true
* @param bool $add The switch to add to exiting instead of replace * @param bool $add The switch to add to exiting instead of replace
* default: false * default: false
*
* @return boolean true on success
* *
* @return bool true on success
* @deprecated 3.3 Use CFactory::_('Customcode.Dispenser')->set($script, $first, $second, $third, $config, $base64, $dynamic, $add);
*/ */
public function setCustomScriptBuilder(&$script, $first, $second = false, public function setCustomScriptBuilder(
$third = false, $config = array(), $base64 = true, $dynamic = true, &$script,
$add = false string $first,
) ?string $second = null,
?string $third = null,
array $config = array(),
bool $base64 = true,
bool $dynamic = true,
bool $add = false
): bool
{ {
// only load if we have a string return CFactory::_('Customcode.Dispenser')->set($script, $first, $second, $third, $config, $base64, $dynamic, $add);
if (!StringHelper::check($script))
{
return false;
}
// this needs refactoring (TODO)
if (!isset($this->customScriptBuilder[$first])
|| ($second
&& !isset($this->customScriptBuilder[$first][$second])))
{
// check if the script first key is set
if ($second && !isset($this->customScriptBuilder[$first]))
{
$this->customScriptBuilder[$first] = array();
}
elseif ($add && !$second
&& !isset($this->customScriptBuilder[$first]))
{
$this->customScriptBuilder[$first] = '';
}
// check if the script second key is set
if ($second && $third
&& !isset($this->customScriptBuilder[$first][$second]))
{
$this->customScriptBuilder[$first][$second] = array();
}
elseif ($add && $second && !$third
&& !isset($this->customScriptBuilder[$first][$second]))
{
$this->customScriptBuilder[$first][$second] = '';
}
// check if the script third key is set
if ($add && $second && $third
&& !isset($this->customScriptBuilder[$first][$second][$third]))
{
$this->customScriptBuilder[$first][$second][$third] = '';
}
}
// prep the script string
if ($base64 && $dynamic)
{
$script = CFactory::_('Customcode')->add(base64_decode($script));
}
elseif ($base64)
{
$script = base64_decode($script);
}
elseif ($dynamic) // this does not happen (just incase)
{
$script = CFactory::_('Customcode')->add($script);
}
// check if we still have a string
if (StringHelper::check($script))
{
// now load the placeholder snippet if needed
if ($base64 || $dynamic)
{
$script = CFactory::_('Customcode.Gui')->set($script, $config);
}
// add Dynamic HASHING option of a file/string
$script = $this->setDynamicHASHING($script);
// add base64 locking option of a string
$script = $this->setBase64LOCK($script);
// load the script
if ($first && $second && $third)
{
// now act on loading option
if ($add)
{
$this->customScriptBuilder[$first][$second][$third]
.= $script;
}
else
{
$this->customScriptBuilder[$first][$second][$third]
= $script;
}
}
elseif ($first && $second)
{
// now act on loading option
if ($add)
{
$this->customScriptBuilder[$first][$second] .= $script;
}
else
{
$this->customScriptBuilder[$first][$second] = $script;
}
}
else
{
// now act on loading option
if ($add)
{
$this->customScriptBuilder[$first] .= $script;
}
else
{
$this->customScriptBuilder[$first] = $script;
}
}
return true;
}
return false;
} }
/** /**
@ -5274,44 +5175,13 @@ class Get
* @param string $sufix The sufix to add after the script if found * @param string $sufix The sufix to add after the script if found
* *
* @return mix The string/script if found or the default value if not found * @return mix The string/script if found or the default value if not found
* * @deprecated 3.3 Use CFactory::_('Customcode.Dispenser')->get($first, $second, $prefix, $note, $unset, $default, $sufix);
*/ */
public function getCustomScriptBuilder($first, $second, $prefix = '', public function getCustomScriptBuilder($first, $second, $prefix = '',
$note = null, $unset = null, $default = null, $sufix = '' $note = null, $unset = null, $default = null, $sufix = ''
) )
{ {
// default is to return an empty string return CFactory::_('Customcode.Dispenser')->get($first, $second, $prefix, $note, $unset, $default, $sufix);
$script = '';
// check if there is any custom script
if (isset($this->customScriptBuilder[$first][$second])
&& StringHelper::check(
$this->customScriptBuilder[$first][$second]
))
{
// add not if set
if ($note)
{
$script .= $note;
}
// load the actual script
$script .= $prefix . str_replace(
array_keys(CFactory::_('Placeholder')->active),
array_values(CFactory::_('Placeholder')->active),
$this->customScriptBuilder[$first][$second]
) . $sufix;
// clear some memory
if ($unset)
{
unset($this->customScriptBuilder[$first][$second]);
}
}
// if not found return default
if (!StringHelper::check($script) && $default)
{
return $default;
}
return $script;
} }
/** /**
@ -10198,7 +10068,7 @@ class Get
* @param string $string The code string * @param string $string The code string
* *
* @return string * @return string
* * @deprecated 3.3 Use CFactory::_('Customcode.Hash')->set($script);
*/ */
protected function setDynamicHASHING($script) protected function setDynamicHASHING($script)
{ {
@ -10259,7 +10129,7 @@ class Get
* @param string $string The code string * @param string $string The code string
* *
* @return string * @return string
* * @deprecated 3.3 Use CFactory::_('Customcode.LockBase')->set($script);
*/ */
protected function setBase64LOCK($script) protected function setBase64LOCK($script)
{ {

View File

@ -754,7 +754,7 @@ class Structure extends Get
$module->add_scripts_field = false; $module->add_scripts_field = false;
$field_script_bucket = array(); $field_script_bucket = array();
// add any css from the fields // add any css from the fields
if (($css = $this->getCustomScriptBuilder( if (($css = CFactory::_('Customcode.Dispenser')->get(
'css_view', $module->key 'css_view', $module->key
)) !== null )) !== null
&& StringHelper::check($css)) && StringHelper::check($css))
@ -789,7 +789,7 @@ class Structure extends Get
} }
} }
// add any JavaScript from the fields // add any JavaScript from the fields
if (($javascript = $this->getCustomScriptBuilder( if (($javascript = CFactory::_('Customcode.Dispenser')->get(
'view_footer', $module->key 'view_footer', $module->key
)) !== null )) !== null
&& StringHelper::check($javascript)) && StringHelper::check($javascript))

View File

@ -4784,7 +4784,7 @@ class Interpretation extends Fields
// set main get query // set main get query
$getItem .= $this->setCustomViewQuery($get->main_get, $code); $getItem .= $this->setCustomViewQuery($get->main_get, $code);
// check if there is any custom script // check if there is any custom script
$getItem .= $this->getCustomScriptBuilder( $getItem .= CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target . '_php_getlistquery', $code, '', CFactory::_('Config')->build_target . '_php_getlistquery', $code, '',
PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_( PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__ __LINE__,__CLASS__
@ -7403,7 +7403,7 @@ class Interpretation extends Fields
$script .= PHP_EOL . Indent::_(3) . "}"; $script .= PHP_EOL . Indent::_(3) . "}";
} }
// add custom php to getitem method // add custom php to getitem method
$script .= $this->getCustomScriptBuilder( $script .= CFactory::_('Customcode.Dispenser')->get(
'php_getitem', $view, PHP_EOL . PHP_EOL 'php_getitem', $view, PHP_EOL . PHP_EOL
); );
@ -7442,7 +7442,7 @@ class Interpretation extends Fields
$Component = $this->fileContentStatic[Placefix::_h('Component')]; $Component = $this->fileContentStatic[Placefix::_h('Component')];
$component = CFactory::_('Config')->component_code_name; $component = CFactory::_('Config')->component_code_name;
// check if there was script added before modeling of data // check if there was script added before modeling of data
$script .= $this->getCustomScriptBuilder( $script .= CFactory::_('Customcode.Dispenser')->get(
'php_before_save', $view, PHP_EOL . PHP_EOL 'php_before_save', $view, PHP_EOL . PHP_EOL
); );
// turn array into JSON string // turn array into JSON string
@ -7627,7 +7627,7 @@ class Interpretation extends Fields
} }
} }
// add custom PHP to the save method // add custom PHP to the save method
$script .= $this->getCustomScriptBuilder( $script .= CFactory::_('Customcode.Dispenser')->get(
'php_save', $view, PHP_EOL . PHP_EOL 'php_save', $view, PHP_EOL . PHP_EOL
); );
@ -7901,7 +7901,7 @@ class Interpretation extends Fields
. PHP_EOL; . PHP_EOL;
} }
// add the custom script // add the custom script
$script .= $this->getCustomScriptBuilder( $script .= CFactory::_('Customcode.Dispenser')->get(
'php_postflight', 'install', PHP_EOL . PHP_EOL, null, true 'php_postflight', 'install', PHP_EOL . PHP_EOL, null, true
); );
// add the Intelligent Fix script if needed // add the Intelligent Fix script if needed
@ -7930,7 +7930,7 @@ class Interpretation extends Fields
// reset script // reset script
$script = $this->setComponentToContentTypes('update'); $script = $this->setComponentToContentTypes('update');
// add the custom script // add the custom script
$script .= $this->getCustomScriptBuilder( $script .= CFactory::_('Customcode.Dispenser')->get(
'php_postflight', 'update', PHP_EOL . PHP_EOL, null, true 'php_postflight', 'update', PHP_EOL . PHP_EOL, null, true
); );
if (isset($this->componentData->admin_views) if (isset($this->componentData->admin_views)
@ -8427,7 +8427,7 @@ class Interpretation extends Fields
// add the Intelligent Reversal script if needed // add the Intelligent Reversal script if needed
$script .= $this->getAssetsTableIntelligentUninstall(); $script .= $this->getAssetsTableIntelligentUninstall();
// add the custom uninstall script // add the custom uninstall script
$script .= $this->getCustomScriptBuilder( $script .= CFactory::_('Customcode.Dispenser')->get(
'php_method', 'uninstall', "", null, true, null, PHP_EOL 'php_method', 'uninstall', "", null, true, null, PHP_EOL
); );
@ -9104,7 +9104,7 @@ class Interpretation extends Fields
$category = $this->catCodeBuilder[$nameSingleCode]['code']; $category = $this->catCodeBuilder[$nameSingleCode]['code'];
} }
// prepare custom script // prepare custom script
$customScript = $this->getCustomScriptBuilder( $customScript = CFactory::_('Customcode.Dispenser')->get(
'php_batchmove', $nameSingleCode, PHP_EOL . PHP_EOL, null, true 'php_batchmove', $nameSingleCode, PHP_EOL . PHP_EOL, null, true
); );
@ -9381,7 +9381,7 @@ class Interpretation extends Fields
} }
} }
// prepare custom script // prepare custom script
$customScript = $this->getCustomScriptBuilder( $customScript = CFactory::_('Customcode.Dispenser')->get(
'php_batchcopy', $nameSingleCode, PHP_EOL . PHP_EOL, null, true 'php_batchcopy', $nameSingleCode, PHP_EOL . PHP_EOL, null, true
); );
@ -10528,13 +10528,13 @@ class Interpretation extends Fields
$db .= $db_ . PHP_EOL . PHP_EOL; $db .= $db_ . PHP_EOL . PHP_EOL;
} }
// add custom sql dump to the file // add custom sql dump to the file
if (isset($this->customScriptBuilder['sql']) if (isset(CFactory::_('Customcode.Dispenser')->hub['sql'])
&& ArrayHelper::check( && ArrayHelper::check(
$this->customScriptBuilder['sql'] CFactory::_('Customcode.Dispenser')->hub['sql']
)) ))
{ {
foreach ( foreach (
$this->customScriptBuilder['sql'] as $for => $customSql CFactory::_('Customcode.Dispenser')->hub['sql'] as $for => $customSql
) )
{ {
$placeholders = array(Placefix::_('component') => $component, $placeholders = array(Placefix::_('component') => $component,
@ -10543,7 +10543,7 @@ class Interpretation extends Fields
$customSql, $placeholders $customSql, $placeholders
) . PHP_EOL . PHP_EOL; ) . PHP_EOL . PHP_EOL;
} }
unset($this->customScriptBuilder['sql']); unset(CFactory::_('Customcode.Dispenser')->hub['sql']);
} }
// WHY DO WE NEED AN ASSET TABLE FIX? // WHY DO WE NEED AN ASSET TABLE FIX?
@ -10640,16 +10640,16 @@ class Interpretation extends Fields
} }
} }
// add custom sql uninstall dump to the file // add custom sql uninstall dump to the file
if (isset($this->customScriptBuilder['sql_uninstall']) if (isset(CFactory::_('Customcode.Dispenser')->hub['sql_uninstall'])
&& StringHelper::check( && StringHelper::check(
$this->customScriptBuilder['sql_uninstall'] CFactory::_('Customcode.Dispenser')->hub['sql_uninstall']
)) ))
{ {
$db .= CFactory::_('Placeholder')->update( $db .= CFactory::_('Placeholder')->update(
$this->customScriptBuilder['sql_uninstall'], CFactory::_('Customcode.Dispenser')->hub['sql_uninstall'],
$this->placeholders $this->placeholders
) . PHP_EOL; ) . PHP_EOL;
unset($this->customScriptBuilder['sql_uninstall']); unset(CFactory::_('Customcode.Dispenser')->hub['sql_uninstall']);
} }
// check if this component used larger rules // check if this component used larger rules
@ -14528,7 +14528,7 @@ class Interpretation extends Fields
. "') . ' = ' . \$db->quoteName('c.id') . ')');"; . "') . ' = ' . \$db->quoteName('c.id') . ')');";
} }
// add custom filtering php // add custom filtering php
$query .= $this->getCustomScriptBuilder( $query .= CFactory::_('Customcode.Dispenser')->get(
'php_getlistquery', $nameSingleCode, PHP_EOL . PHP_EOL 'php_getlistquery', $nameSingleCode, PHP_EOL . PHP_EOL
); );
// add the custom fields query // add the custom fields query
@ -14949,7 +14949,7 @@ class Interpretation extends Fields
$query .= PHP_EOL . Indent::_(3) . "}"; $query .= PHP_EOL . Indent::_(3) . "}";
} }
// add custom php to getitems method after all // add custom php to getitems method after all
$query .= $this->getCustomScriptBuilder( $query .= CFactory::_('Customcode.Dispenser')->get(
'php_getitems_after_all', $nameSingleCode, 'php_getitems_after_all', $nameSingleCode,
PHP_EOL . PHP_EOL . Indent::_(1) PHP_EOL . PHP_EOL . Indent::_(1)
); );
@ -15213,7 +15213,7 @@ class Interpretation extends Fields
$query .= PHP_EOL . Indent::_(3) $query .= PHP_EOL . Indent::_(3)
. "}"; . "}";
// add custom filtering php // add custom filtering php
$query .= $this->getCustomScriptBuilder( $query .= CFactory::_('Customcode.Dispenser')->get(
'php_getlistquery', $nameSingleCode, 'php_getlistquery', $nameSingleCode,
PHP_EOL . PHP_EOL . Indent::_(1) PHP_EOL . PHP_EOL . Indent::_(1)
); );
@ -15337,7 +15337,7 @@ class Interpretation extends Fields
$query .= PHP_EOL . Indent::_(3) . "}"; $query .= PHP_EOL . Indent::_(3) . "}";
} }
// add custom php to getItems method after all // add custom php to getItems method after all
$query .= $this->getCustomScriptBuilder( $query .= CFactory::_('Customcode.Dispenser')->get(
'php_getitems_after_all', $nameSingleCode, 'php_getitems_after_all', $nameSingleCode,
PHP_EOL . PHP_EOL . Indent::_(2) PHP_EOL . PHP_EOL . Indent::_(2)
); );
@ -15361,7 +15361,7 @@ class Interpretation extends Fields
$header = ComponentbuilderHelper::getDynamicScripts('headers'); $header = ComponentbuilderHelper::getDynamicScripts('headers');
// add getExImPortHeaders // add getExImPortHeaders
$query .= $this->getCustomScriptBuilder( $query .= CFactory::_('Customcode.Dispenser')->get(
'php_import_headers', 'import_' . $nameListCode, 'php_import_headers', 'import_' . $nameListCode,
PHP_EOL . PHP_EOL, null, true, PHP_EOL . PHP_EOL, null, true,
// set a default script for those with no custom script // set a default script for those with no custom script
@ -15597,40 +15597,40 @@ class Interpretation extends Fields
// load the custom script to the files // load the custom script to the files
// IMPORT_EXT_METHOD <<<DYNAMIC>>> // IMPORT_EXT_METHOD <<<DYNAMIC>>>
$this->fileContentDynamic['import_' . $nameListCode][Placefix::_h('IMPORT_EXT_METHOD')] $this->fileContentDynamic['import_' . $nameListCode][Placefix::_h('IMPORT_EXT_METHOD')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
'php_import_ext', 'import_' . $nameListCode, PHP_EOL, null, 'php_import_ext', 'import_' . $nameListCode, PHP_EOL, null,
true true
); );
// IMPORT_DISPLAY_METHOD_CUSTOM <<<DYNAMIC>>> // IMPORT_DISPLAY_METHOD_CUSTOM <<<DYNAMIC>>>
$this->fileContentDynamic['import_' . $nameListCode][Placefix::_h('IMPORT_DISPLAY_METHOD_CUSTOM')] $this->fileContentDynamic['import_' . $nameListCode][Placefix::_h('IMPORT_DISPLAY_METHOD_CUSTOM')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
'php_import_display', 'import_' . $nameListCode, PHP_EOL, 'php_import_display', 'import_' . $nameListCode, PHP_EOL,
null, null,
true true
); );
// IMPORT_SETDATA_METHOD <<<DYNAMIC>>> // IMPORT_SETDATA_METHOD <<<DYNAMIC>>>
$this->fileContentDynamic['import_' . $nameListCode][Placefix::_h('IMPORT_SETDATA_METHOD')] $this->fileContentDynamic['import_' . $nameListCode][Placefix::_h('IMPORT_SETDATA_METHOD')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
'php_import_setdata', 'import_' . $nameListCode, PHP_EOL, 'php_import_setdata', 'import_' . $nameListCode, PHP_EOL,
null, null,
true true
); );
// IMPORT_METHOD_CUSTOM <<<DYNAMIC>>> // IMPORT_METHOD_CUSTOM <<<DYNAMIC>>>
$this->fileContentDynamic['import_' . $nameListCode][Placefix::_h('IMPORT_METHOD_CUSTOM')] $this->fileContentDynamic['import_' . $nameListCode][Placefix::_h('IMPORT_METHOD_CUSTOM')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
'php_import', 'import_' . $nameListCode, PHP_EOL, null, 'php_import', 'import_' . $nameListCode, PHP_EOL, null,
true true
); );
// IMPORT_SAVE_METHOD <<<DYNAMIC>>> // IMPORT_SAVE_METHOD <<<DYNAMIC>>>
$this->fileContentDynamic['import_' . $nameListCode][Placefix::_h('IMPORT_SAVE_METHOD')] $this->fileContentDynamic['import_' . $nameListCode][Placefix::_h('IMPORT_SAVE_METHOD')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
'php_import_save', 'import_' . $nameListCode, PHP_EOL, 'php_import_save', 'import_' . $nameListCode, PHP_EOL,
null, null,
true true
); );
// IMPORT_DEFAULT_VIEW_CUSTOM <<<DYNAMIC>>> // IMPORT_DEFAULT_VIEW_CUSTOM <<<DYNAMIC>>>
$this->fileContentDynamic['import_' . $nameListCode][Placefix::_h('IMPORT_DEFAULT_VIEW_CUSTOM')] $this->fileContentDynamic['import_' . $nameListCode][Placefix::_h('IMPORT_DEFAULT_VIEW_CUSTOM')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
'html_import_view', 'import_' . $nameListCode, PHP_EOL, 'html_import_view', 'import_' . $nameListCode, PHP_EOL,
null, null,
true true
@ -15700,7 +15700,7 @@ class Interpretation extends Fields
. "') . ' = ' . \$db->quoteName('c.id') . ')');"; . "') . ' = ' . \$db->quoteName('c.id') . ')');";
} }
// add custom filtering php // add custom filtering php
$query .= $this->getCustomScriptBuilder( $query .= CFactory::_('Customcode.Dispenser')->get(
'php_getlistquery', $nameSingleCode, PHP_EOL . PHP_EOL 'php_getlistquery', $nameSingleCode, PHP_EOL . PHP_EOL
); );
// add the custom fields query // add the custom fields query
@ -16734,17 +16734,17 @@ class Interpretation extends Fields
{ {
$fileScript = ''; $fileScript = '';
} }
$fileScript .= $this->getCustomScriptBuilder( $fileScript .= CFactory::_('Customcode.Dispenser')->get(
'view_file', $nameSingleCode, PHP_EOL . PHP_EOL, null, true, '' 'view_file', $nameSingleCode, PHP_EOL . PHP_EOL, null, true, ''
); );
// add custom script to footer // add custom script to footer
if (isset($this->customScriptBuilder['view_footer'][$nameSingleCode]) if (isset(CFactory::_('Customcode.Dispenser')->hub['view_footer'][$nameSingleCode])
&& StringHelper::check( && StringHelper::check(
$this->customScriptBuilder['view_footer'][$nameSingleCode] CFactory::_('Customcode.Dispenser')->hub['view_footer'][$nameSingleCode]
)) ))
{ {
$customFooterScript = PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update( $customFooterScript = PHP_EOL . PHP_EOL . CFactory::_('Placeholder')->update(
$this->customScriptBuilder['view_footer'][$nameSingleCode], CFactory::_('Customcode.Dispenser')->hub['view_footer'][$nameSingleCode],
$this->placeholders $this->placeholders
); );
if (strpos($customFooterScript, '<?php') === false) if (strpos($customFooterScript, '<?php') === false)
@ -16761,7 +16761,7 @@ class Interpretation extends Fields
// set view listname // set view listname
$nameListCode = $viewArray['settings']->name_list_code; $nameListCode = $viewArray['settings']->name_list_code;
// add custom script to list view JS file // add custom script to list view JS file
if (($list_fileScript = $this->getCustomScriptBuilder( if (($list_fileScript = CFactory::_('Customcode.Dispenser')->get(
'views_file', $nameSingleCode, PHP_EOL . PHP_EOL, null, true, 'views_file', $nameSingleCode, PHP_EOL . PHP_EOL, null, true,
false false
)) !== false )) !== false
@ -17733,8 +17733,8 @@ class Interpretation extends Fields
public function setAjaxToke(&$view) public function setAjaxToke(&$view)
{ {
$fix = ''; $fix = '';
if (isset($this->customScriptBuilder['token'][$view]) if (isset(CFactory::_('Customcode.Dispenser')->hub['token'][$view])
&& $this->customScriptBuilder['token'][$view]) && CFactory::_('Customcode.Dispenser')->hub['token'][$view])
{ {
$fix .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) $fix .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Add Ajax Token"; . " Add Ajax Token";
@ -17748,14 +17748,14 @@ class Interpretation extends Fields
public function setRegisterAjaxTask($target) public function setRegisterAjaxTask($target)
{ {
$tasks = ''; $tasks = '';
if (isset($this->customScriptBuilder[$target]['ajax_controller']) if (isset(CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller'])
&& ArrayHelper::check( && ArrayHelper::check(
$this->customScriptBuilder[$target]['ajax_controller'] CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller']
)) ))
{ {
$taskArray = array(); $taskArray = array();
foreach ( foreach (
$this->customScriptBuilder[$target]['ajax_controller'] as $view CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller'] as $view
) )
{ {
foreach ($view as $task) foreach ($view as $task)
@ -17779,9 +17779,9 @@ class Interpretation extends Fields
public function setAjaxInputReturn($target) public function setAjaxInputReturn($target)
{ {
$cases = ''; $cases = '';
if (isset($this->customScriptBuilder[$target]['ajax_controller']) if (isset(CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller'])
&& ArrayHelper::check( && ArrayHelper::check(
$this->customScriptBuilder[$target]['ajax_controller'] CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller']
)) ))
{ {
$input = array(); $input = array();
@ -17790,7 +17790,7 @@ class Interpretation extends Fields
$getModel = array(); $getModel = array();
$userCheck = array(); $userCheck = array();
foreach ( foreach (
$this->customScriptBuilder[$target]['ajax_controller'] as $view CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_controller'] as $view
) )
{ {
foreach ($view as $task) foreach ($view as $task)
@ -17911,13 +17911,13 @@ class Interpretation extends Fields
public function setAjaxModelMethods($target) public function setAjaxModelMethods($target)
{ {
$methods = ''; $methods = '';
if (isset($this->customScriptBuilder[$target]['ajax_model']) if (isset(CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_model'])
&& ArrayHelper::check( && ArrayHelper::check(
$this->customScriptBuilder[$target]['ajax_model'] CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_model']
)) ))
{ {
foreach ( foreach (
$this->customScriptBuilder[$target]['ajax_model'] as $view => CFactory::_('Customcode.Dispenser')->hub[$target]['ajax_model'] as $view =>
$method $method
) )
{ {
@ -19005,7 +19005,7 @@ class Interpretation extends Fields
// set component name // set component name
$component = $this->componentCodeName; $component = $this->componentCodeName;
// prepare custom permission script // prepare custom permission script
$customAllow = $this->getCustomScriptBuilder( $customAllow = CFactory::_('Customcode.Dispenser')->get(
'php_allowadd', $nameSingleCode, '', null, true 'php_allowadd', $nameSingleCode, '', null, true
); );
// setup correct core target // setup correct core target
@ -19162,7 +19162,7 @@ class Interpretation extends Fields
// set component name // set component name
$component = $this->componentCodeName; $component = $this->componentCodeName;
// prepare custom permission script // prepare custom permission script
$customAllow = $this->getCustomScriptBuilder( $customAllow = CFactory::_('Customcode.Dispenser')->get(
'php_allowedit', $nameSingleCode, '', null, true 'php_allowedit', $nameSingleCode, '', null, true
); );
// setup correct core target // setup correct core target
@ -19953,7 +19953,7 @@ class Interpretation extends Fields
. "\$form->setValue(\$redirectedField, null, \$redirectedValue);"; . "\$form->setValue(\$redirectedField, null, \$redirectedValue);";
$getForm[] = Indent::_(3) . "}"; $getForm[] = Indent::_(3) . "}";
// load custom script if found // load custom script if found
$getForm[] = Indent::_(2) . "}" . $this->getCustomScriptBuilder( $getForm[] = Indent::_(2) . "}" . CFactory::_('Customcode.Dispenser')->get(
'php_getform', $nameSingleCode, PHP_EOL 'php_getform', $nameSingleCode, PHP_EOL
); );
// setup the default script // setup the default script
@ -20117,7 +20117,7 @@ class Interpretation extends Fields
// set component name // set component name
$component = $this->componentCodeName; $component = $this->componentCodeName;
// prepare custom permission script // prepare custom permission script
$customAllow = $this->getCustomScriptBuilder( $customAllow = CFactory::_('Customcode.Dispenser')->get(
'php_allowedit', $nameSingleCode, Indent::_(2) 'php_allowedit', $nameSingleCode, Indent::_(2)
. "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;" . "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;"
. PHP_EOL . PHP_EOL
@ -22268,7 +22268,7 @@ class Interpretation extends Fields
} }
// add custom php to getitems method // add custom php to getitems method
$fix .= $this->getCustomScriptBuilder( $fix .= CFactory::_('Customcode.Dispenser')->get(
'php_getitems', $nameSingleCode, PHP_EOL . PHP_EOL . $tab 'php_getitems', $nameSingleCode, PHP_EOL . PHP_EOL . $tab
); );
@ -28029,14 +28029,14 @@ function vdm_dkim() {
// first add the header // first add the header
$default = PHP_EOL . $module->default_header . PHP_EOL . '?>'; $default = PHP_EOL . $module->default_header . PHP_EOL . '?>';
// add any css from the fields // add any css from the fields
$default .= $this->getCustomScriptBuilder( $default .= CFactory::_('Customcode.Dispenser')->get(
'css_views', $key, PHP_EOL . '<style>', '', true, null, 'css_views', $key, PHP_EOL . '<style>', '', true, null,
PHP_EOL . '</style>' . PHP_EOL PHP_EOL . '</style>' . PHP_EOL
); );
// now add the body // now add the body
$default .= PHP_EOL . $module->default . PHP_EOL; $default .= PHP_EOL . $module->default . PHP_EOL;
// add any JavaScript from the fields // add any JavaScript from the fields
$default .= $this->getCustomScriptBuilder( $default .= CFactory::_('Customcode.Dispenser')->get(
'views_footer', $key, 'views_footer', $key,
PHP_EOL . '<script type="text/javascript">', '', true, PHP_EOL . '<script type="text/javascript">', '', true,
null, PHP_EOL . '</script>' . PHP_EOL null, PHP_EOL . '</script>' . PHP_EOL

View File

@ -216,38 +216,38 @@ class Infusion extends Interpretation
// ADMINJS // ADMINJS
$this->fileContentStatic[Placefix::_h('ADMINJS')] $this->fileContentStatic[Placefix::_h('ADMINJS')]
= CFactory::_('Placeholder')->update( = CFactory::_('Placeholder')->update(
$this->customScriptBuilder['component_js'], CFactory::_('Placeholder')->active CFactory::_('Customcode.Dispenser')->hub['component_js'], CFactory::_('Placeholder')->active
); );
// SITEJS // SITEJS
$this->fileContentStatic[Placefix::_h('SITEJS')] $this->fileContentStatic[Placefix::_h('SITEJS')]
= CFactory::_('Placeholder')->update( = CFactory::_('Placeholder')->update(
$this->customScriptBuilder['component_js'], CFactory::_('Placeholder')->active CFactory::_('Customcode.Dispenser')->hub['component_js'], CFactory::_('Placeholder')->active
); );
// ADMINCSS // ADMINCSS
$this->fileContentStatic[Placefix::_h('ADMINCSS')] $this->fileContentStatic[Placefix::_h('ADMINCSS')]
= CFactory::_('Placeholder')->update( = CFactory::_('Placeholder')->update(
$this->customScriptBuilder['component_css_admin'], CFactory::_('Customcode.Dispenser')->hub['component_css_admin'],
CFactory::_('Placeholder')->active CFactory::_('Placeholder')->active
); );
// SITECSS // SITECSS
$this->fileContentStatic[Placefix::_h('SITECSS')] $this->fileContentStatic[Placefix::_h('SITECSS')]
= CFactory::_('Placeholder')->update( = CFactory::_('Placeholder')->update(
$this->customScriptBuilder['component_css_site'], CFactory::_('Customcode.Dispenser')->hub['component_css_site'],
CFactory::_('Placeholder')->active CFactory::_('Placeholder')->active
); );
// CUSTOM_HELPER_SCRIPT // CUSTOM_HELPER_SCRIPT
$this->fileContentStatic[Placefix::_h('CUSTOM_HELPER_SCRIPT')] $this->fileContentStatic[Placefix::_h('CUSTOM_HELPER_SCRIPT')]
= CFactory::_('Placeholder')->update( = CFactory::_('Placeholder')->update(
$this->customScriptBuilder['component_php_helper_admin'], CFactory::_('Customcode.Dispenser')->hub['component_php_helper_admin'],
CFactory::_('Placeholder')->active CFactory::_('Placeholder')->active
); );
// BOTH_CUSTOM_HELPER_SCRIPT // BOTH_CUSTOM_HELPER_SCRIPT
$this->fileContentStatic[Placefix::_h('BOTH_CUSTOM_HELPER_SCRIPT')] $this->fileContentStatic[Placefix::_h('BOTH_CUSTOM_HELPER_SCRIPT')]
= CFactory::_('Placeholder')->update( = CFactory::_('Placeholder')->update(
$this->customScriptBuilder['component_php_helper_both'], CFactory::_('Customcode.Dispenser')->hub['component_php_helper_both'],
CFactory::_('Placeholder')->active CFactory::_('Placeholder')->active
); );
@ -284,7 +284,7 @@ class Infusion extends Interpretation
.= PHP_EOL . Indent::_(1) . '{'; .= PHP_EOL . Indent::_(1) . '{';
$this->fileContentStatic[Placefix::_h('ADMIN_GLOBAL_EVENT_HELPER')] $this->fileContentStatic[Placefix::_h('ADMIN_GLOBAL_EVENT_HELPER')]
.= PHP_EOL . CFactory::_('Placeholder')->update( .= PHP_EOL . CFactory::_('Placeholder')->update(
$this->customScriptBuilder['component_php_admin_event'], CFactory::_('Customcode.Dispenser')->hub['component_php_admin_event'],
CFactory::_('Placeholder')->active CFactory::_('Placeholder')->active
); );
$this->fileContentStatic[Placefix::_h('ADMIN_GLOBAL_EVENT_HELPER')] $this->fileContentStatic[Placefix::_h('ADMIN_GLOBAL_EVENT_HELPER')]
@ -447,7 +447,7 @@ class Infusion extends Interpretation
); );
// DOCUMENT_CUSTOM_PHP <<<DYNAMIC>>> // DOCUMENT_CUSTOM_PHP <<<DYNAMIC>>>
if ($phpDocument = $this->getCustomScriptBuilder( if ($phpDocument = CFactory::_('Customcode.Dispenser')->get(
'php_document', $nameSingleCode, 'php_document', $nameSingleCode,
PHP_EOL, null, true, PHP_EOL, null, true,
false false
@ -512,28 +512,28 @@ class Infusion extends Interpretation
// JMODELADMIN_BEFORE_DELETE <<<DYNAMIC>>> // JMODELADMIN_BEFORE_DELETE <<<DYNAMIC>>>
$this->fileContentDynamic[$nameSingleCode][Placefix::_h('JMODELADMIN_BEFORE_DELETE')] $this->fileContentDynamic[$nameSingleCode][Placefix::_h('JMODELADMIN_BEFORE_DELETE')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
'php_before_delete', 'php_before_delete',
$nameSingleCode, PHP_EOL $nameSingleCode, PHP_EOL
); );
// JMODELADMIN_AFTER_DELETE <<<DYNAMIC>>> // JMODELADMIN_AFTER_DELETE <<<DYNAMIC>>>
$this->fileContentDynamic[$nameSingleCode][Placefix::_h('JMODELADMIN_AFTER_DELETE')] $this->fileContentDynamic[$nameSingleCode][Placefix::_h('JMODELADMIN_AFTER_DELETE')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
'php_after_delete', $nameSingleCode, 'php_after_delete', $nameSingleCode,
PHP_EOL . PHP_EOL PHP_EOL . PHP_EOL
); );
// JMODELADMIN_BEFORE_DELETE <<<DYNAMIC>>> // JMODELADMIN_BEFORE_DELETE <<<DYNAMIC>>>
$this->fileContentDynamic[$nameSingleCode][Placefix::_h('JMODELADMIN_BEFORE_PUBLISH')] $this->fileContentDynamic[$nameSingleCode][Placefix::_h('JMODELADMIN_BEFORE_PUBLISH')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
'php_before_publish', 'php_before_publish',
$nameSingleCode, PHP_EOL $nameSingleCode, PHP_EOL
); );
// JMODELADMIN_AFTER_DELETE <<<DYNAMIC>>> // JMODELADMIN_AFTER_DELETE <<<DYNAMIC>>>
$this->fileContentDynamic[$nameSingleCode][Placefix::_h('JMODELADMIN_AFTER_PUBLISH')] $this->fileContentDynamic[$nameSingleCode][Placefix::_h('JMODELADMIN_AFTER_PUBLISH')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
'php_after_publish', 'php_after_publish',
$nameSingleCode, PHP_EOL . PHP_EOL $nameSingleCode, PHP_EOL . PHP_EOL
); );
@ -552,7 +552,7 @@ class Infusion extends Interpretation
// POSTSAVEHOOK <<<DYNAMIC>>> // POSTSAVEHOOK <<<DYNAMIC>>>
$this->fileContentDynamic[$nameSingleCode][Placefix::_h('POSTSAVEHOOK')] $this->fileContentDynamic[$nameSingleCode][Placefix::_h('POSTSAVEHOOK')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
'php_postsavehook', $nameSingleCode, 'php_postsavehook', $nameSingleCode,
PHP_EOL, null, PHP_EOL, null,
true, PHP_EOL . Indent::_(2) . "return;", true, PHP_EOL . Indent::_(2) . "return;",
@ -561,7 +561,7 @@ class Infusion extends Interpretation
// VIEWCSS <<<DYNAMIC>>> // VIEWCSS <<<DYNAMIC>>>
$this->fileContentDynamic[$nameSingleCode][Placefix::_h('VIEWCSS')] $this->fileContentDynamic[$nameSingleCode][Placefix::_h('VIEWCSS')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
'css_view', $nameSingleCode, '', 'css_view', $nameSingleCode, '',
null, true null, true
); );
@ -746,7 +746,7 @@ class Infusion extends Interpretation
// GET_ITEMS_METHOD_AFTER_ALL <<<DYNAMIC>>> // GET_ITEMS_METHOD_AFTER_ALL <<<DYNAMIC>>>
$this->fileContentDynamic[$nameListCode][Placefix::_h('GET_ITEMS_METHOD_AFTER_ALL')] $this->fileContentDynamic[$nameListCode][Placefix::_h('GET_ITEMS_METHOD_AFTER_ALL')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
'php_getitems_after_all', 'php_getitems_after_all',
$nameSingleCode, PHP_EOL $nameSingleCode, PHP_EOL
); );
@ -912,7 +912,7 @@ class Infusion extends Interpretation
// VIEWSCSS <<<DYNAMIC>>> // VIEWSCSS <<<DYNAMIC>>>
$this->fileContentDynamic[$nameListCode][Placefix::_h('VIEWSCSS')] $this->fileContentDynamic[$nameListCode][Placefix::_h('VIEWSCSS')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
'css_views', $nameSingleCode, '', 'css_views', $nameSingleCode, '',
null, true null, true
); );
@ -927,7 +927,7 @@ class Infusion extends Interpretation
$scriptNote = PHP_EOL . '//' . Line::_(__Line__, __Class__) $scriptNote = PHP_EOL . '//' . Line::_(__Line__, __Class__)
. ' ' . $nameListCode . ' ' . $nameListCode
. ' footer script'; . ' footer script';
if (($footerScript = $this->getCustomScriptBuilder( if (($footerScript = CFactory::_('Customcode.Dispenser')->get(
'views_footer', $nameSingleCode, '', 'views_footer', $nameSingleCode, '',
$scriptNote, true, $scriptNote, true,
false, PHP_EOL false, PHP_EOL
@ -1040,17 +1040,17 @@ class Infusion extends Interpretation
// JCONTROLLERFORM_BEFORECANCEL <<<DYNAMIC>>> // JCONTROLLERFORM_BEFORECANCEL <<<DYNAMIC>>>
$this->fileContentDynamic[$nameSingleCode][Placefix::_h('JCONTROLLERFORM_BEFORECANCEL')] $this->fileContentDynamic[$nameSingleCode][Placefix::_h('JCONTROLLERFORM_BEFORECANCEL')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
'php_before_cancel', $nameSingleCode, 'php_before_cancel', $nameSingleCode,
PHP_EOL, null, null, PHP_EOL, null, false,
'' ''
); );
// JCONTROLLERFORM_AFTERCANCEL <<<DYNAMIC>>> // JCONTROLLERFORM_AFTERCANCEL <<<DYNAMIC>>>
$this->fileContentDynamic[$nameSingleCode][Placefix::_h('JCONTROLLERFORM_AFTERCANCEL')] $this->fileContentDynamic[$nameSingleCode][Placefix::_h('JCONTROLLERFORM_AFTERCANCEL')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
'php_after_cancel', $nameSingleCode, 'php_after_cancel', $nameSingleCode,
PHP_EOL, null, null, PHP_EOL, null, false,
'' ''
); );
@ -1280,7 +1280,7 @@ class Infusion extends Interpretation
{ {
// CUSTOM_ADMIN_BEFORE_GET_ITEM <<<DYNAMIC>>> // CUSTOM_ADMIN_BEFORE_GET_ITEM <<<DYNAMIC>>>
$this->fileContentDynamic[$view['settings']->code][Placefix::_h('CUSTOM_ADMIN_BEFORE_GET_ITEM')] $this->fileContentDynamic[$view['settings']->code][Placefix::_h('CUSTOM_ADMIN_BEFORE_GET_ITEM')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target . '_php_before_getitem', CFactory::_('Config')->build_target . '_php_before_getitem',
$view['settings']->code, '', null, true $view['settings']->code, '', null, true
); );
@ -1294,7 +1294,7 @@ class Infusion extends Interpretation
// CUSTOM_ADMIN_AFTER_GET_ITEM <<<DYNAMIC>>> // CUSTOM_ADMIN_AFTER_GET_ITEM <<<DYNAMIC>>>
$this->fileContentDynamic[$view['settings']->code][Placefix::_h('CUSTOM_ADMIN_AFTER_GET_ITEM')] $this->fileContentDynamic[$view['settings']->code][Placefix::_h('CUSTOM_ADMIN_AFTER_GET_ITEM')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target . '_php_after_getitem', CFactory::_('Config')->build_target . '_php_after_getitem',
$view['settings']->code, '', null, true $view['settings']->code, '', null, true
); );
@ -1309,14 +1309,14 @@ class Infusion extends Interpretation
// CUSTOM_ADMIN_CUSTOM_BEFORE_LIST_QUERY <<<DYNAMIC>>> // CUSTOM_ADMIN_CUSTOM_BEFORE_LIST_QUERY <<<DYNAMIC>>>
$this->fileContentDynamic[$view['settings']->code][Placefix::_h('CUSTOM_ADMIN_CUSTOM_BEFORE_LIST_QUERY')] $this->fileContentDynamic[$view['settings']->code][Placefix::_h('CUSTOM_ADMIN_CUSTOM_BEFORE_LIST_QUERY')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target . '_php_getlistquery', CFactory::_('Config')->build_target . '_php_getlistquery',
$view['settings']->code, PHP_EOL, null, true $view['settings']->code, PHP_EOL, null, true
); );
// CUSTOM_ADMIN_BEFORE_GET_ITEMS <<<DYNAMIC>>> // CUSTOM_ADMIN_BEFORE_GET_ITEMS <<<DYNAMIC>>>
$this->fileContentDynamic[$view['settings']->code][Placefix::_h('CUSTOM_ADMIN_BEFORE_GET_ITEMS')] $this->fileContentDynamic[$view['settings']->code][Placefix::_h('CUSTOM_ADMIN_BEFORE_GET_ITEMS')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target . '_php_before_getitems', CFactory::_('Config')->build_target . '_php_before_getitems',
$view['settings']->code, PHP_EOL, null, true $view['settings']->code, PHP_EOL, null, true
); );
@ -1329,7 +1329,7 @@ class Infusion extends Interpretation
// CUSTOM_ADMIN_AFTER_GET_ITEMS <<<DYNAMIC>>> // CUSTOM_ADMIN_AFTER_GET_ITEMS <<<DYNAMIC>>>
$this->fileContentDynamic[$view['settings']->code][Placefix::_h('CUSTOM_ADMIN_AFTER_GET_ITEMS')] $this->fileContentDynamic[$view['settings']->code][Placefix::_h('CUSTOM_ADMIN_AFTER_GET_ITEMS')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target . '_php_after_getitems', CFactory::_('Config')->build_target . '_php_after_getitems',
$view['settings']->code, PHP_EOL, null, true $view['settings']->code, PHP_EOL, null, true
); );
@ -1768,7 +1768,7 @@ class Infusion extends Interpretation
// SITE_BEFORE_GET_ITEM <<<DYNAMIC>>> // SITE_BEFORE_GET_ITEM <<<DYNAMIC>>>
$this->fileContentDynamic[$view['settings']->code][Placefix::_h('SITE_BEFORE_GET_ITEM')] $this->fileContentDynamic[$view['settings']->code][Placefix::_h('SITE_BEFORE_GET_ITEM')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target . '_php_before_getitem', CFactory::_('Config')->build_target . '_php_before_getitem',
$view['settings']->code, '', null, true $view['settings']->code, '', null, true
); );
@ -1782,7 +1782,7 @@ class Infusion extends Interpretation
// SITE_AFTER_GET_ITEM <<<DYNAMIC>>> // SITE_AFTER_GET_ITEM <<<DYNAMIC>>>
$this->fileContentDynamic[$view['settings']->code][Placefix::_h('SITE_AFTER_GET_ITEM')] $this->fileContentDynamic[$view['settings']->code][Placefix::_h('SITE_AFTER_GET_ITEM')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target . '_php_after_getitem', CFactory::_('Config')->build_target . '_php_after_getitem',
$view['settings']->code, '', null, true $view['settings']->code, '', null, true
); );
@ -1800,7 +1800,7 @@ class Infusion extends Interpretation
// SITE_BEFORE_GET_ITEMS <<<DYNAMIC>>> // SITE_BEFORE_GET_ITEMS <<<DYNAMIC>>>
$this->fileContentDynamic[$view['settings']->code][Placefix::_h('SITE_BEFORE_GET_ITEMS')] $this->fileContentDynamic[$view['settings']->code][Placefix::_h('SITE_BEFORE_GET_ITEMS')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target . '_php_before_getitems', CFactory::_('Config')->build_target . '_php_before_getitems',
$view['settings']->code, PHP_EOL, null, true $view['settings']->code, PHP_EOL, null, true
); );
@ -1813,7 +1813,7 @@ class Infusion extends Interpretation
// SITE_AFTER_GET_ITEMS <<<DYNAMIC>>> // SITE_AFTER_GET_ITEMS <<<DYNAMIC>>>
$this->fileContentDynamic[$view['settings']->code][Placefix::_h('SITE_AFTER_GET_ITEMS')] $this->fileContentDynamic[$view['settings']->code][Placefix::_h('SITE_AFTER_GET_ITEMS')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
CFactory::_('Config')->build_target . '_php_after_getitems', CFactory::_('Config')->build_target . '_php_after_getitems',
$view['settings']->code, PHP_EOL, null, true $view['settings']->code, PHP_EOL, null, true
); );
@ -1969,7 +1969,7 @@ class Infusion extends Interpretation
// SITE_CUSTOM_HELPER_SCRIPT // SITE_CUSTOM_HELPER_SCRIPT
$this->fileContentStatic[Placefix::_h('SITE_CUSTOM_HELPER_SCRIPT')] $this->fileContentStatic[Placefix::_h('SITE_CUSTOM_HELPER_SCRIPT')]
= CFactory::_('Placeholder')->update( = CFactory::_('Placeholder')->update(
$this->customScriptBuilder['component_php_helper_site'], CFactory::_('Customcode.Dispenser')->hub['component_php_helper_site'],
CFactory::_('Placeholder')->active CFactory::_('Placeholder')->active
); );
// SITE_GLOBAL_EVENT_HELPER // SITE_GLOBAL_EVENT_HELPER
@ -2004,7 +2004,7 @@ class Infusion extends Interpretation
.= PHP_EOL . Indent::_(1) . '{'; .= PHP_EOL . Indent::_(1) . '{';
$this->fileContentStatic[Placefix::_h('SITE_GLOBAL_EVENT_HELPER')] $this->fileContentStatic[Placefix::_h('SITE_GLOBAL_EVENT_HELPER')]
.= PHP_EOL . CFactory::_('Placeholder')->update( .= PHP_EOL . CFactory::_('Placeholder')->update(
$this->customScriptBuilder['component_php_site_event'], CFactory::_('Customcode.Dispenser')->hub['component_php_site_event'],
CFactory::_('Placeholder')->active CFactory::_('Placeholder')->active
); );
$this->fileContentStatic[Placefix::_h('SITE_GLOBAL_EVENT_HELPER')] $this->fileContentStatic[Placefix::_h('SITE_GLOBAL_EVENT_HELPER')]
@ -2014,13 +2014,13 @@ class Infusion extends Interpretation
// PREINSTALLSCRIPT // PREINSTALLSCRIPT
$this->fileContentStatic[Placefix::_h('PREINSTALLSCRIPT')] $this->fileContentStatic[Placefix::_h('PREINSTALLSCRIPT')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
'php_preflight', 'install', PHP_EOL, null, true 'php_preflight', 'install', PHP_EOL, null, true
); );
// PREUPDATESCRIPT // PREUPDATESCRIPT
$this->fileContentStatic[Placefix::_h('PREUPDATESCRIPT')] $this->fileContentStatic[Placefix::_h('PREUPDATESCRIPT')]
= $this->getCustomScriptBuilder( = CFactory::_('Customcode.Dispenser')->get(
'php_preflight', 'update', PHP_EOL, null, true 'php_preflight', 'update', PHP_EOL, null, true
); );

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="4" method="upgrade"> <extension type="component" version="4" method="upgrade">
<name>COM_COMPONENTBUILDER</name> <name>COM_COMPONENTBUILDER</name>
<creationDate>30th August, 2022</creationDate> <creationDate>31st August, 2022</creationDate>
<author>Llewellyn van der Merwe</author> <author>Llewellyn van der Merwe</author>
<authorEmail>joomla@vdm.io</authorEmail> <authorEmail>joomla@vdm.io</authorEmail>
<authorUrl>https://dev.vdm.io</authorUrl> <authorUrl>https://dev.vdm.io</authorUrl>

View File

@ -0,0 +1,283 @@
<?php
/**
* @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>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Hash;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\LockBase;
/**
* Compiler Custom Code Dispenser
*
* @since 3.2.0
*/
class Dispenser
{
/**
* Customcode Dispenser Hub
*
* @var array
* @since 3.2.0
**/
public array $hub;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
**/
protected Customcode $customcode;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Customcode to Hash
*
* @var Hash
* @since 3.2.0
**/
protected Hash $hash;
/**
* Compiler Customcode to LockBase
*
* @var LockBase
* @since 3.2.0
**/
protected LockBase $base64;
/**
* Constructor.
*
* @param Customcode|null $customcode The compiler customcode object.
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param Gui|null $gui The compiler customcode gui object.
* @param Hash|null $hash The compiler customcode hash object.
* @param LockBase|null $base64 The compiler customcode lock base64 object.
*
* @since 3.2.0
*/
public function __construct(?Placeholder $placeholder = null, ?Customcode $customcode = null,
?Gui $gui = null, ?Hash $hash = null, ?LockBase $base64 = null)
{
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->hash = $hash ?: Compiler::_('Customcode.Hash');
$this->base64 = $base64 ?: Compiler::_('Customcode.LockBase');
}
/**
* Set the script for the customcode dispenser
*
* @param string $script The script
* @param string $first The first key
* @param string|null $second The second key (if not set we use only first key)
* @param string|null $third The third key (if not set we use only first and second key)
* @param array $config The config options
* @param bool $base64 The switch to decode base64 the script
* default: true
* @param bool $dynamic The switch to dynamic update the script
* default: true
* @param bool $add The switch to add to exiting instead of replace
* default: false
*
* @return bool true on success
* @since 3.2.0
*/
public function set(&$script, string $first, ?string $second = null, ?string $third = null,
array $config = array(), bool $base64 = true, bool $dynamic = true, bool $add = false): bool
{
// only load if we have a string
if (!StringHelper::check($script))
{
return false;
}
// this needs refactoring (TODO)
if (!isset($this->hub[$first])
|| ($second
&& !isset($this->hub[$first][$second])))
{
// check if the script first key is set
if ($second && !isset($this->hub[$first]))
{
$this->hub[$first] = array();
}
elseif ($add && !$second
&& !isset($this->hub[$first]))
{
$this->hub[$first] = '';
}
// check if the script second key is set
if ($second && $third
&& !isset($this->hub[$first][$second]))
{
$this->hub[$first][$second] = array();
}
elseif ($add && $second && !$third
&& !isset($this->hub[$first][$second]))
{
$this->hub[$first][$second] = '';
}
// check if the script third key is set
if ($add && $second && $third
&& !isset($this->hub[$first][$second][$third]))
{
$this->hub[$first][$second][$third] = '';
}
}
// prep the script string
if ($base64 && $dynamic)
{
$script = $this->customcode->add(base64_decode($script));
}
elseif ($base64)
{
$script = base64_decode($script);
}
elseif ($dynamic) // this does not happen (just incase)
{
$script = $this->customcode->add($script);
}
// check if we still have a string
if (StringHelper::check($script))
{
// now load the placeholder snippet if needed
if ($base64 || $dynamic)
{
$script = $this->gui->set($script, $config);
}
// add Dynamic HASHING option of a file/string
$script = $this->hash->set($script);
// add base64 locking option of a string
$script = $this->base64->set($script);
// load the script
if ($first && $second && $third)
{
// now act on loading option
if ($add)
{
$this->hub[$first][$second][$third]
.= $script;
}
else
{
$this->hub[$first][$second][$third]
= $script;
}
}
elseif ($first && $second)
{
// now act on loading option
if ($add)
{
$this->hub[$first][$second] .= $script;
}
else
{
$this->hub[$first][$second] = $script;
}
}
else
{
// now act on loading option
if ($add)
{
$this->hub[$first] .= $script;
}
else
{
$this->hub[$first] = $script;
}
}
return true;
}
return false;
}
/**
* Get the script from the customcode dispenser
*
* @param string $first The first key
* @param string $second The second key
* @param string $prefix The prefix to add in front of the script if found
* @param string|null $note The switch/note to add to the script
* @param bool $unset The switch to unset the value if found
* @param mixed|null $default The switch/string to use as default return if script not found
* @param string $suffix The suffix to add after the script if found
*
* @return mixed The string/script if found or the default value if not found
*
* @since 3.2.0
*/
public function get(string $first, string $second, string $prefix = '', ?string $note = null,
bool $unset = false, $default = null, string $suffix = '')
{
// default is to return an empty string
$script = '';
// check if there is any custom script
if (isset($this->hub[$first][$second])
&& StringHelper::check(
$this->hub[$first][$second]
))
{
// add not if set
if ($note)
{
$script .= $note;
}
// load the actual script
$script .= $prefix . str_replace(
array_keys($this->placeholder->active),
array_values($this->placeholder->active),
$this->hub[$first][$second]
) . $suffix;
// clear some memory
if ($unset)
{
unset($this->hub[$first][$second]);
}
}
// if not found return default
if (!StringHelper::check($script) && $default)
{
return $default;
}
return $script;
}
}

View File

@ -0,0 +1,110 @@
<?php
/**
* @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>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
/**
* Compiler Custom Code MD5
*
* @since 3.2.0
*/
class Hash
{
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Constructor.
*
* @param Placeholder|null $placeholder The compiler placeholder object.
*
* @since 3.2.0
*/
public function __construct(?Placeholder $placeholder = null)
{
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
}
/**
* Set the the MD5 hashed string or file or string
*
* @param string $script The code string
*
* @return string
* @since 3.2.0
*/
public function set(string $script): string
{
// check if we should hash a string
if (\strpos($script, 'HASH' . 'STRING((((') !== false)
{
// get the strings
$values = GetHelper::allBetween(
$script, 'HASH' . 'STRING((((', '))))'
);
$locker = array();
// convert them
foreach ($values as $value)
{
$locker['HASH' . 'STRING((((' . $value . '))))']
= \md5($value);
}
// update the script
return $this->placeholder->update($script, $locker);
}
// check if we should hash a file
if (\strpos($script, 'HASH' . 'FILE((((') !== false)
{
// get the strings
$values = GetHelper::allBetween(
$script, 'HASH' . 'FILE((((', '))))'
);
$locker = array();
// convert them
foreach ($values as $path)
{
// we first get the file if it exist
if ($value = FileHelper::getContent($path))
{
// now we hash the file content
$locker['HASH' . 'FILE((((' . $path . '))))']
= \md5($value);
}
else
{
// could not retrieve the file so we show error
$locker['HASH' . 'FILE((((' . $path . '))))']
= 'ERROR';
}
}
// update the script
return $this->placeholder->update($script, $locker);
}
return $script;
}
}

View File

@ -0,0 +1,85 @@
<?php
/**
* @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>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
/**
* Compiler Custom Code Base64
*
* @since 3.2.0
*/
class LockBase
{
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Constructor.
*
* @param Placeholder|null $placeholder The compiler placeholder object.
*
* @since 3.2.0
*/
public function __construct(?Placeholder $placeholder = null)
{
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
}
/**
* Set a string as bsae64 (basic)
*
* @param string $script The code string
*
* @return string
* @since 3.2.0
*/
public function set(string $script): string
{
if (\strpos($script, 'LOCK'.'BASE64((((') !== false)
{
// get the strings
$values = GetHelper::allBetween(
$script, 'LOCK'.'BASE64((((', '))))'
);
$locker = array();
// convert them
foreach ($values as $value)
{
$locker['LOCK'.'BASE64((((' . $value . '))))']
= "base64_decode( preg_replace('/\s+/', ''," .
PHP_EOL . Indent::_(2) . "'" .
\wordwrap(
\base64_encode($value), 64, PHP_EOL . Indent::_(2), true
) .
"'))";
}
// update the script
return $this->placeholder->update($script, $locker);
}
return $script;
}
}

View File

@ -17,6 +17,9 @@ use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Customcode as CompilerCustomcode; use VDM\Joomla\Componentbuilder\Compiler\Customcode as CompilerCustomcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\External; use VDM\Joomla\Componentbuilder\Compiler\Customcode\External;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui; use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Hash;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\LockBase;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
/** /**
@ -44,6 +47,15 @@ class Customcode implements ServiceProviderInterface
$container->alias(Gui::class, 'Customcode.Gui') $container->alias(Gui::class, 'Customcode.Gui')
->share('Customcode.Gui', [$this, 'getGui'], true); ->share('Customcode.Gui', [$this, 'getGui'], true);
$container->alias(Hash::class, 'Customcode.Hash')
->share('Customcode.Hash', [$this, 'getHash'], true);
$container->alias(LockBase::class, 'Customcode.LockBase')
->share('Customcode.LockBase', [$this, 'getLockBase'], true);
$container->alias(Dispenser::class, 'Customcode.Dispenser')
->share('Customcode.Dispenser', [$this, 'getDispenser'], true);
} }
/** /**
@ -94,6 +106,55 @@ class Customcode implements ServiceProviderInterface
$container->get('Placeholder.Reverse') $container->get('Placeholder.Reverse')
); );
} }
/**
* Get the Customcode Hash
*
* @param Container $container The DI container.
*
* @return Hash
* @since 3.2.0
*/
public function getHash(Container $container): Hash
{
return new Hash(
$container->get('Placeholder')
);
}
/**
* Get the Customcode LockBase64
*
* @param Container $container The DI container.
*
* @return LockBase
* @since 3.2.0
*/
public function getLockBase(Container $container): LockBase
{
return new LockBase(
$container->get('Placeholder')
);
}
/**
* Get the Customcode Dispenser
*
* @param Container $container The DI container.
*
* @return Dispenser
* @since 3.2.0
*/
public function getDispenser(Container $container): Dispenser
{
return new Dispenser(
$container->get('Placeholder'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Customcode.Hash'),
$container->get('Customcode.LockBase')
);
}
} }