Fixed gh-629 to add a hidden title field when a view does not have a title field.

This commit is contained in:
2020-12-24 15:39:33 +02:00
parent 664c2d5f2a
commit 3bd2158b83
100 changed files with 557 additions and 68 deletions

View File

@ -863,6 +863,40 @@ class Fields extends Structure
$this->fieldCount++;
}
}
// fix the permissions field "title" issue gh-629
// check if the the title is not already set
if (!isset($this->fieldsNames[$nameSingleCode]['title']))
{
// set the field/tab name
$field_name = "title";
$tab_name = "publishing";
$fieldSet[] = $this->_t(2) . "<!--" . $this->setLine(__LINE__)
. " Was added due to Permissions JS needing a Title field -->";
$fieldSet[] = $this->_t(2) . "<!--" . $this->setLine(__LINE__)
. " Let us know at gh-629 should this change -->";
$fieldSet[] = $this->_t(2) . "<!--" . $this->setLine(__LINE__)
. " https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235 -->";
// at this point we know that we must add a hidden title field
// and make sure it does not get stored to the database
$fieldSet[] = $this->_t(2) . "<field";
$fieldSet[] = $this->_t(3) . "name=" . '"' . $field_name . '"';
$fieldSet[] = $this->_t(3)
. 'type="hidden"';
$fieldSet[] = $this->_t(3) . 'default="' . $component . ' '
. $nameSingleCode . '"';
$fieldSet[] = $this->_t(2) . "/>";
// count the static field created
$this->fieldCount++;
// setup needed field values for layout
$field_array = array();
$field_array['order_edit'] = 0;
$field_array['tab'] = 15;
$field_array['alignment'] = 1;
// make sure it gets added to view
$this->setLayoutBuilder(
$nameSingleCode, $tab_name, $field_name, $field_array
);
}
// load the dynamic fields now
if (ComponentbuilderHelper::checkString($dynamicFields))
{
@ -1263,6 +1297,45 @@ class Fields extends Structure
$this->fieldCount++;
}
}
// fix the permissions field "title" issue gh-629
// check if the the title is not already set
if (!isset($this->fieldsNames[$nameSingleCode]['title']))
{
// set the field/tab name
$field_name = "title";
$tab_name = "publishing";
$attributes = array(
'name' => $field_name,
'type' => 'hidden',
'default' => $component . ' ' . $nameSingleCode
);
ComponentbuilderHelper::xmlComment(
$fieldSetXML,
$this->setLine(__LINE__) . " Was added due to Permissions JS needing a Title field"
);
ComponentbuilderHelper::xmlComment(
$fieldSetXML,
$this->setLine(__LINE__) . " Let us know at gh-629 should this change"
);
ComponentbuilderHelper::xmlComment(
$fieldSetXML,
$this->setLine(__LINE__) . " https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235"
);
$fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created
$this->fieldCount++;
// setup needed field values for layout
$field_array = array();
$field_array['order_edit'] = 0;
$field_array['tab'] = 15;
$field_array['alignment'] = 1;
// make sure it gets added to view
$this->setLayoutBuilder(
$nameSingleCode, $tab_name, $field_name, $field_array
);
}
// load the dynamic fields now
if (count((array) $dynamicFieldsXML))
{
@ -4652,7 +4725,7 @@ class Fields extends Structure
}
}
// set the hidden field of this view
if ($typeName === 'hidden')
if ($dbSwitch && $typeName === 'hidden')
{
if (!isset($this->hiddenFieldsBuilder[$nameSingleCode]))
{
@ -4673,7 +4746,7 @@ class Fields extends Structure
$this->intFieldsBuilder[$nameSingleCode] .= ',"' . $name . '"';
}
// set all dynamic field of this view
if ($typeName != 'category' && $typeName != 'repeatable'
if ($dbSwitch && $typeName != 'category' && $typeName != 'repeatable'
&& $typeName != 'subform'
&& !in_array($name, $this->defaultFields))
{

View File

@ -1983,7 +1983,8 @@ abstract class ComponentbuilderHelper
'<a href="https://vdm.bz/joomla-volunteers" target="_blank" title="Joomla! Volunteers Portal"><img src="https://cdn.joomla.org/volunteers/joomla-heart-wide.gif" alt="Joomla! Volunteers Portal" width="728" height="90" border="0"></a>',
'<a href="https://vdm.bz/joomla-magazine" target="_blank" title="Joomla! Community Magazine | Because community matters..."><img alt="Joomla! Community Magazine | Because community matters..." src="https://magazine.joomla.org/images/banners/JCM_2010_728x90.png" width="728" height="90" border="0" /></a>',
'<a href="https://vdm.bz/jcb-sponsor-tlwebdesign" target="_blank" title="tlwebdesign a JCB sponsor | Because community matters..."><img alt="tlwebdesign a JCB sponsor | Because community matters..." src="https://www.joomlacomponentbuilder.com/images/banners/tlwebdesign_jcb_sponsor_728_90.png" width="728" height="90" border="0" /></a>',
'<a href="https://vdm.bz/jcb-sponsor-vdm" target="_blank" title="VDM a JCB sponsor | Because community matters..."><img alt="VDM a JCB sponsor | Because community matters..." src="https://www.joomlacomponentbuilder.com/images/banners/vdm_jcb_sponsor_728_90.gif" width="728" height="90" border="0" /></a>'
'<a href="https://vdm.bz/jcb-sponsor-vdm" target="_blank" title="VDM a JCB sponsor | Because community matters..."><img alt="VDM a JCB sponsor | Because community matters..." src="https://www.joomlacomponentbuilder.com/images/banners/vdm_jcb_sponsor_728_90.gif" width="728" height="90" border="0" /></a>',
'<a href="https://vdm.bz/jcb-sponsor-agerix" target="_blank" title="Agerix a JCB sponsor | Because community matters..."><img alt="Agerix a JCB sponsor | Because community matters..." src="https://allmycms.com/images/banners/agerix/agerix-loves-jcb-728-90.gif" width="728" height="90" border="0" /></a>'
),
'160-600' => array(
'<a href="https://vdm.bz/joomla-volunteers" target="_blank" title="Joomla! Volunteers Portal"><img src="https://cdn.joomla.org/volunteers/joomla-heart-tall.gif" alt="Joomla! Volunteers Portal" width="160" height="600" border="0"></a>',