Release of v5.1.1-alpha2

Adds the ModalSelect fieldtype to Joomla Component Builder - J5. Adds the Data Import Function to the Demo Component. Adds new country related tables and fields to the Demo Component. Resolves the Database Updating issue in the compiler. #1212,#1209. Adds the Component Commands Plugin to the CLI for Import of spreadsheet data-sets.
This commit is contained in:
2025-03-28 13:15:25 +00:00
parent 06185f8c3a
commit 8342c5bb9f
536 changed files with 16369 additions and 2067 deletions

View File

@@ -315,6 +315,11 @@ class Data
*/
public function get($view): ?object
{
if (empty($view))
{
return null;
}
if (isset($this->index[$view]))
{
$id = $this->index[$view];
@@ -478,6 +483,13 @@ class Data
'jcb_ce_onBeforeModelViewData', [&$view]
);
// should we add sql?
if ($view->add_sql !== 1)
{
unset($view->addtables);
unset($view->sql);
}
// add the tables
$view->addtables = (isset($view->addtables) && JsonHelper::check($view->addtables))
? json_decode((string) $view->addtables, true)

View File

@@ -397,7 +397,7 @@ final class Structuresingle
return false;
}
// take action based on type
elseif ($details->type === 'file' && !File::exists($this->currentFullPath))
elseif ($details->type === 'file' && !is_file($this->currentFullPath))
{
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEFILE_PATH_ERRORHTHREE'), 'Error'

View File

@@ -689,6 +689,8 @@ final class Builders
// to identify the field
$this->databasetables->set($nameSingleCode . '.' . $name . '.ID',
$field['settings']->id);
$this->databasetables->set($nameSingleCode . '.' . $name . '.GUID',
$field['settings']->guid);
$this->databasetables->set($nameSingleCode . '.' . $name . '.null_switch',
$field['settings']->null_switch);
// set index types
@@ -912,6 +914,7 @@ final class Builders
&& $typeName != 'repeatable'
&& $typeName != 'subform')
{
// do not add if extends is empty
$this->customfield->add($nameListCode, [
'type' => $typeName,
'code' => $name,

View File

@@ -15,6 +15,7 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Creator;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name;
use VDM\Joomla\Componentbuilder\Compiler\Field\TypeName;
use VDM\Joomla\Componentbuilder\Compiler\Field\Attributes;
use VDM\Joomla\Componentbuilder\Compiler\Field\ModalSelect;
use VDM\Joomla\Componentbuilder\Compiler\Field\Groups;
use VDM\Joomla\Componentbuilder\Compiler\Builder\FieldNames;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Creator\Fieldtypeinterface as Field;
@@ -56,6 +57,14 @@ final class FieldDynamic implements Fielddynamicinterface
*/
protected Attributes $attributes;
/**
* The ModalSelect Class.
*
* @var ModalSelect
* @since 5.2.1
*/
protected ModalSelect $modalselect;
/**
* The Groups Class.
*
@@ -102,6 +111,7 @@ final class FieldDynamic implements Fielddynamicinterface
* @param Name $name The Name Class.
* @param TypeName $typename The TypeName Class.
* @param Attributes $attributes The Attributes Class.
* @param ModalSelect $modalselect The ModalSelect Class.
* @param Groups $groups The Groups Class.
* @param FieldNames $fieldnames The FieldNames Class.
* @param Field $field The Fieldtypeinterface Class.
@@ -111,12 +121,14 @@ final class FieldDynamic implements Fielddynamicinterface
* @since 3.2.0
*/
public function __construct(Name $name, TypeName $typename,
Attributes $attributes, Groups $groups, FieldNames $fieldnames,
Attributes $attributes, ModalSelect $modalselect,
Groups $groups, FieldNames $fieldnames,
Field $field, Builders $builders, Layout $layout)
{
$this->name = $name;
$this->typename = $typename;
$this->attributes = $attributes;
$this->modalselect = $modalselect;
$this->groups = $groups;
$this->fieldnames = $fieldnames;
$this->field = $field;
@@ -172,6 +184,12 @@ final class FieldDynamic implements Fielddynamicinterface
// set options as null
$optionArray = null;
// special treatment for Modal Select
if ($typeName === 'ModalSelect')
{
$fieldAttributes['custom'] = $this->modalselect->extract($fieldAttributes);
}
if ($this->groups->check($typeName, 'option'))
{
// set options array
@@ -253,6 +271,7 @@ final class FieldDynamic implements Fielddynamicinterface
// set the custom array
$custom = $fieldAttributes['custom'];
unset($fieldAttributes['custom']);
// set db key
$custom['db'] = $dbkey;
// increment the db key

View File

@@ -19,6 +19,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Field\Groups;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name;
use VDM\Joomla\Componentbuilder\Compiler\Field\TypeName;
use VDM\Joomla\Componentbuilder\Compiler\Field\Attributes;
use VDM\Joomla\Componentbuilder\Compiler\Field\ModalSelect;
use VDM\Joomla\Componentbuilder\Compiler\Creator\CustomFieldTypeFile;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
use VDM\Joomla\Utilities\ArrayHelper;
@@ -94,6 +95,14 @@ final class FieldString implements Fieldtypeinterface
*/
protected Attributes $attributes;
/**
* The ModalSelect Class.
*
* @var ModalSelect
* @since 5.2.1
*/
protected ModalSelect $modalselect;
/**
* The CustomFieldTypeFile Class.
*
@@ -120,6 +129,7 @@ final class FieldString implements Fieldtypeinterface
* @param Name $name The Name Class.
* @param TypeName $typename The TypeName Class.
* @param Attributes $attributes The Attributes Class.
* @param ModalSelect $modalselect The ModalSelect Class.
* @param CustomFieldTypeFile $customfieldtypefile The CustomFieldTypeFile Class.
* @param Counter $counter The Counter Class.
*
@@ -127,7 +137,7 @@ final class FieldString implements Fieldtypeinterface
*/
public function __construct(Config $config, Language $language, Field $field,
Groups $groups, Name $name, TypeName $typename,
Attributes $attributes,
Attributes $attributes, ModalSelect $modalselect,
CustomFieldTypeFile $customfieldtypefile,
Counter $counter)
{
@@ -138,6 +148,7 @@ final class FieldString implements Fieldtypeinterface
$this->name = $name;
$this->typename = $typename;
$this->attributes = $attributes;
$this->modalselect = $modalselect;
$this->customfieldtypefile = $customfieldtypefile;
$this->counter = $counter;
}
@@ -591,6 +602,13 @@ final class FieldString implements Fieldtypeinterface
{
//reset options array
$r_optionArray = array();
// special treatment for Modal Select
if ($r_typeName === 'ModalSelect')
{
$r_fieldValues['custom'] = $this->modalselect->extract($r_fieldValues);
}
if ($this->groups->check(
$r_typeName, 'option'
))
@@ -740,7 +758,7 @@ final class FieldString implements Fieldtypeinterface
$fieldData['settings']
))
{
$r_name = $this->name->get(
$r_name = $this->name->get(
$fieldData, $nameListCode, $_resolverKey
);
$r_typeName = $this->typename->get($fieldData);
@@ -763,6 +781,13 @@ final class FieldString implements Fieldtypeinterface
{
//reset options array
$r_optionArray = array();
// special treatment for Modal Select
if ($r_typeName === 'ModalSelect')
{
$r_fieldValues['custom'] = $this->modalselect->extract($r_fieldValues);
}
if ($this->groups->check(
$r_typeName, 'option'
))

View File

@@ -19,6 +19,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Field\Groups;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name;
use VDM\Joomla\Componentbuilder\Compiler\Field\TypeName;
use VDM\Joomla\Componentbuilder\Compiler\Field\Attributes;
use VDM\Joomla\Componentbuilder\Compiler\Field\ModalSelect;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Xml;
use VDM\Joomla\Componentbuilder\Compiler\Creator\CustomFieldTypeFile;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
@@ -93,6 +94,14 @@ final class FieldXML implements Fieldtypeinterface
*/
protected Attributes $attributes;
/**
* The ModalSelect Class.
*
* @var ModalSelect
* @since 5.2.1
*/
protected ModalSelect $modalselect;
/**
* The Xml Class.
*
@@ -127,6 +136,7 @@ final class FieldXML implements Fieldtypeinterface
* @param Name $name The Name Class.
* @param TypeName $typename The TypeName Class.
* @param Attributes $attributes The Attributes Class.
* @param ModalSelect $modalselect The ModalSelect Class.
* @param Xml $xml The Xml Class.
* @param CustomFieldTypeFile $customfieldtypefile The CustomFieldTypeFile Class.
* @param Counter $counter The Counter Class.
@@ -135,8 +145,8 @@ final class FieldXML implements Fieldtypeinterface
*/
public function __construct(Config $config, Language $language, Field $field,
Groups $groups, Name $name, TypeName $typename,
Attributes $attributes, Xml $xml,
CustomFieldTypeFile $customfieldtypefile,
Attributes $attributes, ModalSelect $modalselect,
Xml $xml, CustomFieldTypeFile $customfieldtypefile,
Counter $counter)
{
$this->config = $config;
@@ -146,6 +156,7 @@ final class FieldXML implements Fieldtypeinterface
$this->name = $name;
$this->typename = $typename;
$this->attributes = $attributes;
$this->modalselect = $modalselect;
$this->xml = $xml;
$this->customfieldtypefile = $customfieldtypefile;
$this->counter = $counter;
@@ -571,6 +582,13 @@ final class FieldXML implements Fieldtypeinterface
{
//reset options array
$r_optionArray = array();
// special treatment for Modal Select
if ($r_typeName === 'ModalSelect')
{
$r_fieldValues['custom'] = $this->modalselect->extract($r_fieldValues);
}
if ($this->groups->check(
$r_typeName, 'option'
))
@@ -735,7 +753,7 @@ final class FieldXML implements Fieldtypeinterface
$fieldData['settings']
))
{
$r_name = $this->name->get(
$r_name = $this->name->get(
$fieldData, $nameListCode, $_resolverKey
);
$r_typeName = $this->typename->get($fieldData);
@@ -756,6 +774,13 @@ final class FieldXML implements Fieldtypeinterface
{
//reset options array
$r_optionArray = array();
// special treatment for Modal Select
if ($r_typeName === 'ModalSelect')
{
$r_fieldValues['custom'] = $this->modalselect->extract($r_fieldValues);
}
if ($this->groups->check(
$r_typeName, 'option'
))
@@ -763,11 +788,11 @@ final class FieldXML implements Fieldtypeinterface
// now add to the field set
$this->xml->append(
$form, $this->get(
'option', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray
)
'option', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray
)
);
}
elseif ($r_typeName === 'subform')
@@ -789,12 +814,12 @@ final class FieldXML implements Fieldtypeinterface
// now add to the field set
$this->xml->append(
$form, $this->get(
'special', $r_fieldValues,
$r_name, $r_typeName, $langView,
$nameSingleCode,
$nameListCode, $placeholders,
$r_optionArray
)
'special', $r_fieldValues,
$r_name, $r_typeName, $langView,
$nameSingleCode,
$nameListCode, $placeholders,
$r_optionArray
)
);
}
@@ -810,11 +835,11 @@ final class FieldXML implements Fieldtypeinterface
// now add to the field set
$this->xml->append(
$form, $this->get(
'custom', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray
)
'custom', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray
)
);
// set lang (just incase)
$r_listLangName = $langView . '_'
@@ -851,11 +876,11 @@ final class FieldXML implements Fieldtypeinterface
// now add to the field set
$this->xml->append(
$form, $this->get(
'plain', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray
)
'plain', $r_fieldValues, $r_name,
$r_typeName, $langView,
$nameSingleCode, $nameListCode,
$placeholders, $r_optionArray
)
);
}
}

View File

@@ -151,6 +151,11 @@ class Data
*/
public function get($field, ?string $singleViewName = null, ?string $listViewName = null): ?object
{
if (empty($field))
{
return null;
}
if (isset($this->index[$field]))
{
$id = $this->index[$field];

View File

@@ -0,0 +1,150 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @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\Field;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Structure;
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentMulti;
/**
* Compiler Field Modal Select
*
* @since 5.2.1
*/
final class ModalSelect
{
/**
* The Structure Class.
*
* @var Structure
* @since 5.2.1
*/
protected Structure $structure;
/**
* The ContentMulti Class.
*
* @var ContentMulti
* @since 5.2.1
*/
protected ContentMulti $contentmulti;
/**
* The switch to ensure the fix is just added once
*
* @var bool
* @since 5.2.1
*/
protected bool $addedFix = false;
/**
* Constructor.
*
* @param Structure $structure The Structure Class.
* @param ContentMulti $contentmulti The ContentMulti Class.
*
* @since 5.2.1
*/
public function __construct(Structure $structure, ContentMulti $contentmulti)
{
$this->structure = $structure;
$this->contentmulti = $contentmulti;
}
/**
* Extracts component and view details from field attributes for a Modal Select field.
*
* @param array $fieldAttributes The field attributes containing URLs and SQL table details.
*
* @return array An associative array with extracted component, view, views, table, id, and text.
* @since 5.1.2
*/
public function extract(array $fieldAttributes): array
{
$component = null;
$views = null;
$view = null;
// Extract parameters from the given URL
$extractParams = function ($url) {
if (empty($url)) {
return ['option' => null, 'view' => null];
}
$query = parse_url($url, PHP_URL_QUERY);
parse_str($query, $params);
return [
'option' => $params['option'] ?? $params['amp;option'] ?? null,
'view' => $params['view'] ?? $params['amp;view'] ?? null,
];
};
// Process URL attributes
foreach (['urlSelect', 'urlEdit', 'urlNew'] as $urlKey)
{
$params = $extractParams($fieldAttributes[$urlKey] ?? '');
$component ??= $params['option'];
if ($urlKey === 'urlSelect')
{
$views ??= $params['view'];
}
else
{
$view ??= $params['view'];
}
}
// Determine the target table and extract the view name
$field_target_table = $fieldAttributes['sql_title_table'] ?? '';
if (!$view && !empty($field_target_table))
{
$clean_table = str_replace('__', '', $field_target_table);
$view = substr($clean_table, strpos($clean_table, '_') + 1);
}
$sql_title_key = $fieldAttributes['sql_title_key'] ?? 'id';
// if one field is not id, we add an override to the ModalSelectField as a FIX
if (!$this->addedFix && $sql_title_key !== 'id')
{
$this->structure->build(
['admin' => 'fieldmodalselect_override'],
'fieldmodalselect_override'
);
$this->structure->build(
['site' => 'fieldmodalselect_override'],
'fieldmodalselect_override'
);
// to make sure the file is updated TODO
$this->contentmulti->set('fieldmodalselect_override|BLABLA', 'blabla');
$this->addedFix = true;
}
return [
'modal_select' => true,
'urlSelect' => $fieldAttributes['urlSelect'] ?? '',
'hint' => $fieldAttributes['hint'] ?? '',
'titleSelect' => $fieldAttributes['titleSelect'] ?? '',
'iconSelect' => $fieldAttributes['iconSelect'] ?? '',
'table' => $field_target_table,
'id' => $sql_title_key,
'text' => $fieldAttributes['sql_title_column'] ?? '',
'component' => $component ?? 'error',
'view' => $view ?? 'error',
'views' => $views ?? 'error',
'button' => false,
'extends' => ''
];
}
}

View File

@@ -418,7 +418,7 @@ class Compiler extends Infusion
// first we do the static files
foreach (CFactory::_('Utilities.Files')->get('static') as $static)
{
if (File::exists($static['path']))
if (is_file($static['path']))
{
$this->setFileContent(
$static['name'], $static['path'], $bom
@@ -434,7 +434,7 @@ class Compiler extends Infusion
{
if ($file['view'] == $view)
{
if (File::exists($file['path']))
if (is_file($file['path']))
{
$this->setFileContent(
$file['name'], $file['path'], $bom,
@@ -513,7 +513,7 @@ class Compiler extends Infusion
// update the module files
foreach (CFactory::_('Utilities.Files')->get($module->key) as $module_file)
{
if (File::exists($module_file['path']))
if (is_file($module_file['path']))
{
$this->setFileContent(
$module_file['name'], $module_file['path'],
@@ -591,7 +591,7 @@ class Compiler extends Infusion
// update the plugin files
foreach (CFactory::_('Utilities.Files')->get($plugin->key) as $plugin_file)
{
if (File::exists($plugin_file['path']))
if (is_file($plugin_file['path']))
{
$this->setFileContent(
$plugin_file['name'], $plugin_file['path'],
@@ -625,7 +625,7 @@ class Compiler extends Infusion
// update the power files
foreach (CFactory::_('Utilities.Files')->get($power->key) as $power_file)
{
if (File::exists($power_file['path']))
if (is_file($power_file['path']))
{
$this->setFileContent(
$power_file['name'], $power_file['path'],
@@ -650,7 +650,7 @@ class Compiler extends Infusion
// update the power files
foreach (CFactory::_('Utilities.Files')->get($key) as $power_file)
{
if (File::exists($power_file['path']))
if (is_file($power_file['path']))
{
$this->setFileContent(
$power_file['name'], $power_file['path'],
@@ -775,7 +775,7 @@ class Compiler extends Infusion
$update_server_xml_path = CFactory::_('Utilities.Paths')->component_path . '/'
. $this->updateServerFileName . '.xml';
// make sure we have the correct file
if (File::exists($update_server_xml_path)
if (is_file($update_server_xml_path)
&& ($update_server = CFactory::_('Component')->get('update_server')) !== null)
{
// move to server
@@ -811,7 +811,7 @@ class Compiler extends Infusion
&& is_numeric($module->update_server)
&& $module->update_server > 0
&& isset($module->update_server_xml_path)
&& File::exists($module->update_server_xml_path)
&& is_file($module->update_server_xml_path)
&& isset($module->update_server_xml_file_name)
&& StringHelper::check(
$module->update_server_xml_file_name
@@ -852,7 +852,7 @@ class Compiler extends Infusion
&& is_numeric($plugin->update_server)
&& $plugin->update_server > 0
&& isset($plugin->update_server_xml_path)
&& File::exists($plugin->update_server_xml_path)
&& is_file($plugin->update_server_xml_path)
&& isset($plugin->update_server_xml_file_name)
&& StringHelper::check(
$plugin->update_server_xml_file_name
@@ -952,7 +952,7 @@ class Compiler extends Infusion
if (('README.md' === $static['name']
|| 'README.txt' === $static['name'])
&& CFactory::_('Component')->get('addreadme')
&& File::exists($static['path']))
&& is_file($static['path']))
{
$this->setReadMe($static['path']);
$two++;
@@ -1467,7 +1467,7 @@ class Compiler extends Infusion
}
$counter = 0;
// check if file exist
if (File::exists($file))
if (is_file($file))
{
foreach (
new \SplFileObject($file) as $lineNumber => $lineContent

View File

@@ -1326,6 +1326,30 @@ class Fields extends Structure
. $filter['type'] . '"';
// set css classname of this field
$filter_class = ucfirst((string) $filter['type']);
// if this is a modal_select field
$modal_select = $filter['custom']['modal_select'] ?? null;
if ($modal_select)
{
$field_filter_sets[] = Indent::_(3) . 'sql_title_table="'
. $filter['custom']['table'] . '"';
$field_filter_sets[] = Indent::_(3) . 'sql_title_column="'
. $filter['custom']['text'] . '"';
$field_filter_sets[] = Indent::_(3) . 'sql_title_key="'
. $filter['custom']['id'] . '"';
$field_filter_sets[] = Indent::_(3) . 'urlSelect="'
. $filter['custom']['urlSelect'] . '"';
$field_filter_sets[] = Indent::_(3) . 'hint="'
. $filter['custom']['hint'] . '"';
$field_filter_sets[] = Indent::_(3) . 'titleSelect="'
. $filter['custom']['titleSelect'] . '"';
$field_filter_sets[] = Indent::_(3) . 'iconSelect="'
. $filter['custom']['iconSelect'] . '"';
$field_filter_sets[] = Indent::_(3) . 'select="true"';
$field_filter_sets[] = Indent::_(3) . 'edit="false"';
$field_filter_sets[] = Indent::_(3) . 'clear="true"';
$field_filter_sets[] = Indent::_(3) . 'onchange="form.submit()"';
}
}
else
{

View File

@@ -445,6 +445,11 @@ class Infusion extends Interpretation
$this->setAddToolBar($view)
);
// ADDMODALTOOLBAR <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|ADDMODALTOOLBAR',
$this->setAddModalToolBar($view)
);
// set the script for this view
$this->buildTheViewScript($view);
@@ -945,6 +950,14 @@ class Infusion extends Interpretation
)
);
// VIEWS_MODAL_BODY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|VIEWS_MODAL_BODY',
$this->setModalViewsBody(
$nameSingleCode,
$nameListCode
)
);
// LISTHEAD <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|LISTHEAD',
$this->setListHead(
@@ -1046,6 +1059,13 @@ class Infusion extends Interpretation
)
);
// ADMIN_VIEWS_MODAL_HEADER <<<DYNAMIC>>> add the header details for the views
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|ADMIN_VIEWS_MODAL_HEADER',
CFactory::_('Header')->get(
'admin.views.modal', $nameListCode
)
);
// API_VIEWS_CONTROLLER_HEADER <<<DYNAMIC>>> add the header details for the controller
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|API_VIEWS_CONTROLLER_HEADER',
CFactory::_('Header')->get(

View File

@@ -679,7 +679,7 @@ class Structure extends Get
!isset($this->extentionTrackingFilesMoved[$check]))
{
// check files exist
if (File::exists(
if (is_file(
CFactory::_('Utilities.Paths')->component_path . '/admin/models/fields/'
. $field['type_name'] . '.php'
))
@@ -707,7 +707,7 @@ class Structure extends Get
!isset($this->extentionTrackingFilesMoved[$check]))
{
// check files exist
if (File::exists(
if (is_file(
CFactory::_('Utilities.Paths')->component_path . '/admin/models/rules/'
. CFactory::_('Registry')->get('validation.linked.' . $field['field'])
. '.php'

View File

@@ -426,6 +426,8 @@ final class Header implements HeaderInterface
$headers[] = 'use Joomla\Input\Input;';
break;
case 'admin.views.modal':
$headers[] = 'use Joomla\CMS\Session\Session;';
case 'admin.views':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';

View File

@@ -426,6 +426,8 @@ final class Header implements HeaderInterface
$headers[] = 'use Joomla\Input\Input;';
break;
case 'admin.views.modal':
$headers[] = 'use Joomla\CMS\Session\Session;';
case 'admin.views':
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
$headers[] = 'use Joomla\CMS\Layout\LayoutHelper;';

View File

@@ -63,9 +63,9 @@ class Sql
*/
public function set(object &$item)
{
if (isset($item->add_sql) && $item->add_sql == 1 && isset($item->source))
if (isset($item->add_sql) && (int) $item->add_sql === 1 && isset($item->source))
{
if ($item->source == 1 && isset($item->tables) &&
if ((int) $item->source === 1 && isset($item->tables) &&
($string = $this->dump->get(
$item->tables, $item->name_single_code, $item->guid
)) !== null)
@@ -77,7 +77,7 @@ class Sql
$this->dispenser->hub['sql'][$item->name_single_code]
= $string;
}
elseif ($item->source == 2 && isset($item->sql))
elseif ((int) $item->source === 2 && isset($item->sql))
{
// add the SQL dump string
$this->dispenser->set(

View File

@@ -199,82 +199,88 @@ class Sqldump
else
{
// see where
// var_dump($view);
// jexit();
// var_dump($view, $view_guid);
// exit;
}
}
// check if we should run query
if ($run_query)
{
// now get the data
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// get the data
$data = $this->db->loadObjectList();
// start building the MySql dump
$dump = "--";
$dump .= PHP_EOL . "-- Dumping data for table `#__"
. Placefix::_("component") . "_" . $view
. "`";
$dump .= PHP_EOL . "--";
$dump .= PHP_EOL . PHP_EOL . "INSERT INTO `#__" . Placefix::_("component") . "_" . $view . "` (";
foreach ($data as $line)
try{
// now get the data
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
$comaSet = 0;
foreach ($line as $fieldName => $fieldValue)
// get the data
$data = $this->db->loadObjectList();
// start building the MySql dump
$dump = "--";
$dump .= PHP_EOL . "-- Dumping data for table `#__"
. Placefix::_("component") . "_" . $view
. "`";
$dump .= PHP_EOL . "--";
$dump .= PHP_EOL . PHP_EOL . "INSERT INTO `#__" . Placefix::_("component") . "_" . $view . "` (";
foreach ($data as $line)
{
if ($comaSet == 0)
$comaSet = 0;
foreach ($line as $fieldName => $fieldValue)
{
$dump .= $this->db->quoteName($fieldName);
if ($comaSet == 0)
{
$dump .= $this->db->quoteName($fieldName);
}
else
{
$dump .= ", " . $this->db->quoteName(
$fieldName
);
}
$comaSet++;
}
break;
}
$dump .= ") VALUES";
$coma = 0;
foreach ($data as $line)
{
if ($coma == 0)
{
$dump .= PHP_EOL . "(";
}
else
{
$dump .= ", " . $this->db->quoteName(
$fieldName
);
$dump .= "," . PHP_EOL . "(";
}
$comaSet++;
}
break;
}
$dump .= ") VALUES";
$coma = 0;
foreach ($data as $line)
{
if ($coma == 0)
{
$dump .= PHP_EOL . "(";
}
else
{
$dump .= "," . PHP_EOL . "(";
}
$comaSet = 0;
foreach ($line as $fieldName => $fieldValue)
{
if ($comaSet == 0)
$comaSet = 0;
foreach ($line as $fieldName => $fieldValue)
{
$dump .= $this->escape($fieldValue);
if ($comaSet == 0)
{
$dump .= $this->escape($fieldValue);
}
else
{
$dump .= ", " . $this->escape(
$fieldValue
);
}
$comaSet++;
}
else
{
$dump .= ", " . $this->escape(
$fieldValue
);
}
$comaSet++;
$dump .= ")";
$coma++;
}
$dump .= ")";
$coma++;
}
$dump .= ";";
$dump .= ";";
// return build dump query
return $dump;
// return build dump query
return $dump;
}
} catch (\Throwable $e) {
// see where
// var_dump($view, $view_guid);
// exit;
}
}
}

View File

@@ -78,13 +78,13 @@ class Updatesql
{
$newItem = true;
// check if this is an id to ignore
// check if this is an id/guid to ignore
if (ArrayHelper::check($ignore)
&& in_array(
$item, $ignore
))
{
// don't add ignored ids
// don't add ignored ids/guids
$newItem = false;
}
// check if this is old repeatable field
@@ -142,11 +142,11 @@ class Updatesql
// search to see if this is a new value
$newItem = true;
// check if this is an id to ignore
// check if this is an id/guid to ignore
if (ArrayHelper::check($ignore)
&& in_array($item[$type], $ignore))
{
// don't add ignored ids
// don't add ignored ids/guids
$newItem = false;
}
// check if this is old repeatable field

View File

@@ -773,6 +773,7 @@ class Creator implements ServiceProviderInterface
$container->get('Field.Name'),
$container->get('Field.Type.Name'),
$container->get('Field.Attributes'),
$container->get('Field.ModalSelect'),
$container->get('Utilities.Xml'),
$container->get('Compiler.Creator.Custom.Field.Type.File'),
$container->get('Utilities.Counter')
@@ -797,6 +798,7 @@ class Creator implements ServiceProviderInterface
$container->get('Field.Name'),
$container->get('Field.Type.Name'),
$container->get('Field.Attributes'),
$container->get('Field.ModalSelect'),
$container->get('Compiler.Creator.Custom.Field.Type.File'),
$container->get('Utilities.Counter')
);
@@ -816,6 +818,7 @@ class Creator implements ServiceProviderInterface
$container->get('Field.Name'),
$container->get('Field.Type.Name'),
$container->get('Field.Attributes'),
$container->get('Field.ModalSelect'),
$container->get('Field.Groups'),
$container->get('Compiler.Builder.Field.Names'),
$container->get('Compiler.Creator.Field.Type'),

View File

@@ -20,6 +20,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Field\Data;
use VDM\Joomla\Componentbuilder\Compiler\Field\Groups;
use VDM\Joomla\Componentbuilder\Compiler\Field\Attributes;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name;
use VDM\Joomla\Componentbuilder\Compiler\Field\ModalSelect;
use VDM\Joomla\Componentbuilder\Compiler\Field\TypeName;
use VDM\Joomla\Componentbuilder\Compiler\Field\UniqueName;
use VDM\Joomla\Componentbuilder\Compiler\Field\Rule;
@@ -83,6 +84,9 @@ class Field implements ServiceProviderInterface
$container->alias(Name::class, 'Field.Name')
->share('Field.Name', [$this, 'getName'], true);
$container->alias(ModalSelect::class, 'Field.ModalSelect')
->share('Field.ModalSelect', [$this, 'getModalSelect'], true);
$container->alias(TypeName::class, 'Field.Type.Name')
->share('Field.Type.Name', [$this, 'getTypeName'], true);
@@ -214,6 +218,22 @@ class Field implements ServiceProviderInterface
);
}
/**
* Get The ModalSelect Class.
*
* @param Container $container The DI container.
*
* @return ModalSelect
* @since 5.2.1
*/
public function getModalSelect(Container $container): ModalSelect
{
return new ModalSelect(
$container->get('Utilities.Structure'),
$container->get('Compiler.Builder.Content.Multi')
);
}
/**
* Get The TypeName Class.
*

View File

@@ -50,7 +50,7 @@ final class RowDataArray implements RowDataProcessorInterface
foreach ($cellIterator as $cell)
{
$rowData['values'][$cell->getColumn()] = $cell->getValueString();
$rowData['values'][$cell->getColumn()] = (string) $cell->getValue();
}
return $rowData;