Stable release of v3.2.0-beta5

Add custom file file mapping for Joomla 4 and 5.
This commit is contained in:
2024-03-09 21:41:29 +02:00
parent 5675f186cd
commit 91e922b993
28 changed files with 207 additions and 93 deletions

View File

@ -645,21 +645,48 @@ final class CustomFieldTypeFile
$core_fields = $this->corefield->get();
$extends = $this->extends;
$found = null;
foreach ($core_fields as $core_field)
{
$field = strtolower((string) $core_field);
if ($extends === $field)
{
$this->fieldmap[$extends] = $core_field;
return $core_field;
$found = $core_field;
break;
}
}
$this->fieldmap[$extends] = StringHelper::safe($extends, 'F');
$extends = $found ?? StringHelper::safe($extends, 'F');
return $this->fieldmap[$extends];
if ($this->config->get('joomla_version', 3) != 3)
{
$fix = strtolower($extends);
if ('checkboxes' === $fix)
{
$extends = 'CheckboxesField';
}
elseif ('list' === $fix)
{
$extends = 'FormField';
}
elseif ('radio' === $fix)
{
$extends = 'RadioField';
}
elseif ('combo' === $fix)
{
$extends = 'ComboField';
}
elseif (strpos($extends, 'Field') === false)
{
$extends = StringHelper::safe($extends, 'F') . 'Field';
}
}
$this->fieldmap[$this->extends] = $extends;
return $extends;
}
/**

View File

@ -600,6 +600,13 @@ class Infusion extends Interpretation
)
);
// AJAXTOKE <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|AJAXTOKE',
$this->setAjaxToke(
$nameSingleCode
)
);
// add css to front end
if (isset($view['edit_create_site_view'])
&& is_numeric($view['edit_create_site_view'])
@ -681,6 +688,13 @@ class Infusion extends Interpretation
)
);
// JQUERY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameSingleCode . '|JQUERY',
$this->setJquery(
$nameSingleCode
)
);
// Trigger Event: jcb_ce_onAfterBuildAdminEditViewContent
CFactory::_('Event')->trigger(
'jcb_ce_onAfterBuildAdminEditViewContent',[&$view, &$nameSingleCode, &$nameListCode]
@ -1015,6 +1029,13 @@ class Infusion extends Interpretation
)
);
// JQUERY <<<DYNAMIC>>>
CFactory::_('Compiler.Builder.Content.Multi')->set($nameListCode . '|JQUERY',
$this->setJquery(
$nameSingleCode
)
);
// Trigger Event: jcb_ce_onAfterBuildAdminListViewContent
CFactory::_('Event')->trigger(
'jcb_ce_onAfterBuildAdminListViewContent', [&$view, &$nameSingleCode, &$nameListCode]

View File

@ -5654,7 +5654,7 @@ class Interpretation extends Fields
. " Add the needed Javascript to insure that the buttons work.";
$script[] = Indent::_(2) . "Html::_('behavior.framework', true);";
$script[] = Indent::_(2)
. "\$this->document->addScriptDeclaration(\"Joomla.submitbutton = function(task){if (task == ''){ return false; } else { Joomla.submitform(task); return true; }}\");";
. "\$this->getDocument()->addScriptDeclaration(\"Joomla.submitbutton = function(task){if (task == ''){ return false; } else { Joomla.submitform(task); return true; }}\");";
// return the script
return PHP_EOL . implode(PHP_EOL, $script);
@ -5780,7 +5780,7 @@ class Interpretation extends Fields
$script = PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " Set the Custom JS script to view" . PHP_EOL
. Indent::_(2) . '$this->document->addScriptDeclaration("';
. Indent::_(2) . '$this->getDocument()->addScriptDeclaration("';
$jsDocument = PHP_EOL . Indent::_(3) . str_replace(
'"', '\"', implode(
PHP_EOL . Indent::_(3),
@ -17760,6 +17760,19 @@ class Interpretation extends Fields
return $methods;
}
public function setJquery(&$view)
{
$addJQuery = '';
if (true) // TODO we just add it everywhere for now.
{
$addJQuery .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__)
. " Load jQuery";
$addJQuery .= PHP_EOL . Indent::_(2) . "Html::_('jquery.framework');";
}
return $addJQuery;
}
/**
* build filter functions
*

View File

@ -73,7 +73,7 @@ final class Load
{
return $this->model->value(
$this->load->value(
["a.${field}" => $field],
["a.{$field}" => $field],
['a' => 'power'],
$this->prefix($keys)
),

View File

@ -55,10 +55,9 @@ class Insert implements InsertInterface
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
protected $db;
/**
* Constructor
@ -66,17 +65,16 @@ class Insert implements InsertInterface
* @param Config|null $config The search config object.
* @param Table|null $table The search table object.
* @param Model|null $model The search get model object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Table $table = null,
?Model $model = null, ?\JDatabaseDriver $db = null)
?Model $model = null)
{
$this->config = $config ?: Factory::_('Config');
$this->table = $table ?: Factory::_('Table');
$this->model = $model ?: Factory::_('Insert.Model');
$this->db = $db ?: JoomlaFactory::getDbo();
$this->db = JoomlaFactory::getDbo();
}
/**

View File

@ -119,13 +119,35 @@ class Load extends Model implements ModelInterface
*/
protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool
{
// Start note to self
// Yes we don't search in the field->xml (field) PHP because the xml is messy
// first of all we need to change that storage method :((( seriously
// and the actual PHP is stored in the xml as base64 with a [__.o0=base64=Oo.__] key in front of it
// if I can go back and drag you around by your ear... I will, but okay you did not know better.
// Listen you have tried to fix this a few times already (I lost count) and by the time you realize how it works
// two hours have been wasted, and you usually only then realize why it's not fixed in the first place... o boy... just walk now!
// since unless you have three days don't even look further, this is a huge issue/mess
// and while I agree it needs fixing, it will not take a few hours... but days
// End note to self
// check values
if (StringHelper::check($value) || ArrayHelper::check($value, true))
{
return true;
}
// remove empty values
return false;
// Start another note to self
// If you're still here
// the problem is not opening the PHP in the xml,
// it is storing it with the updated changes... if any are made via the search-update methods
// so the only way to fix this is to change the whole way the xml values in the field table is stored.
// Yes, that is right... all the way back to the field view... and then to update all places you open that xml values
// and get the values out of the xml string and use them, and if you've forgotten, that is nearly everywhere,
// and so let the refactoring of the foundation begin... there I saved you another 3 hours.
// End another note to self
}
/**

View File

@ -75,24 +75,24 @@ abstract class FormHelper
// element was not returned
return;
}
switch (get_class($node))
if ($node instanceof \stdClass)
{
case 'stdClass':
if (property_exists($node, 'comment'))
{
self::comment($xml, $node->comment);
}
if (property_exists($node, 'fieldXML'))
{
self::append($xml, $node->fieldXML);
}
break;
case 'SimpleXMLElement':
$domXML = \dom_import_simplexml($xml);
$domNode = \dom_import_simplexml($node);
$domXML->appendChild($domXML->ownerDocument->importNode($domNode, true));
$xml = \simplexml_import_dom($domXML);
break;
if (property_exists($node, 'comment'))
{
self::comment($xml, $node->comment);
}
if (property_exists($node, 'fieldXML'))
{
self::append($xml, $node->fieldXML);
}
}
elseif ($node instanceof \SimpleXMLElement)
{
$domXML = \dom_import_simplexml($xml);
$domNode = \dom_import_simplexml($node);
$domXML->appendChild($domXML->ownerDocument->importNode($domNode, true));
$xml = \simplexml_import_dom($domXML);
}
}
@ -127,7 +127,7 @@ abstract class FormHelper
{
foreach ($attributes as $key => $value)
{
$xml->addAttribute($key, $value);
$xml->addAttribute($key, $value ?? '');
}
}
@ -145,7 +145,7 @@ abstract class FormHelper
foreach ($options as $key => $value)
{
$addOption = $xml->addChild('option');
$addOption->addAttribute('value', $key);
$addOption->addAttribute('value', $key ?? '');
$addOption[] = $value;
}
}