Added the php field properties to a textarea outside of the subform for easier editing

This commit is contained in:
2018-04-15 00:52:48 +02:00
parent 81e5038bb2
commit 4e7d4af1d3
9 changed files with 148 additions and 22 deletions

View File

@ -2244,6 +2244,20 @@ class ComponentbuilderModelAjax extends JModelList
// load the html
$field['subform'] = '<div class="control-label prop_removal">'. $properties->label . '</div><div class="controls prop_removal">' . $properties->input . '</div>';
$field['extra'] = '<div class="control-label prop_removal">'. $extras->label . '</div><div class="controls prop_removal">' . $extras->input . '</div>';
// check if we have PHP values
if (ComponentbuilderHelper::checkArray($field['php']))
{
$field['textarea'] = array();
foreach($field['php'] as $name => $values)
{
$value = implode(PHP_EOL, $values['value']);
$textarea = $this->buildFieldTexteara($name, $values['desc'], $value, substr_count( $value, PHP_EOL ));
// load the html
$field['textarea'][] = '<div class="control-label prop_removal">'. $textarea->label . '</div><div class="controls prop_removal">' . $textarea->input . '</div><br />';
}
}
// remove some unneeded values
unset($field['values']);
// return found field options
return $field;
}
@ -2277,6 +2291,32 @@ class ComponentbuilderModelAjax extends JModelList
return null;
}
protected function buildFieldTexteara($name, $desc, $default, $rows)
{
// get the textarea
$textarea = JFormHelper::loadFieldType('textarea', true);
// start building the name field XML
$textareaXML = new SimpleXMLElement('<field/>');
// textarea attributes
$textareaAttribute = array(
'type' => 'textarea',
'name' => 'property_'.$name,
'label' => $desc,
'rows' => (int) ($rows >= 3) ? $rows : $rows + 2,
'cols' => '15',
'class' => 'text_area span12',
'filter' => 'RAW',
'hint' => 'COM_COMPONENTBUILDER__ADD_YOUR_PHP_SCRIPT_HERE');
// load the textarea attributes
ComponentbuilderHelper::xmlAddAttributes($textareaXML, $textareaAttribute);
// setup subform with values
$textarea->setup($textareaXML, $default);
// return textarea object
return $textarea;
}
protected function buildFieldOptionsSubform($values, $nameListOptions = null, $name = 'properties', $label = 'COM_COMPONENTBUILDER_PROPERTIESBR_SMALLHERE_YOU_CAN_SET_THE_PROPERTIES_FOR_THIS_FIELDSMALL')
{
// get the subform

View File

@ -893,6 +893,10 @@ class ComponentbuilderModelField extends JModelAdmin
$properties = $input->get('properties', null, 'ARRAY');
// get the extra properties
$extraproperties = $input->get('extraproperties', null, 'ARRAY');
// get the type phpx property
$typephpx = $input->get('property_type_phpx', null, 'RAW');
// get the type php property
$typephp = $input->get('property_type_php', null, 'RAW');
// make sure we have an array
if (ComponentbuilderHelper::checkArray($properties))
{
@ -931,10 +935,22 @@ class ComponentbuilderModelField extends JModelAdmin
}
}
}
// make sure we have a string
if (ComponentbuilderHelper::checkString($typephp))
{
// load the type_php property
$bucket[] = "\t".'type_php_1="'. str_replace('"', "'", $typephp).'"';
}
// make sure we have a string
if (ComponentbuilderHelper::checkString($typephpx))
{
// load the type_phpx property
$bucket[] = "\t".'type_phpx_1="'. str_replace('"', "'", $typephp).'"';
}
// if the bucket has been loaded
if (ComponentbuilderHelper::checkArray($bucket))
{
$data['xml'] = "<field\n".implode("\n", $bucket)."\n/>";
$data['xml'] = "<field".PHP_EOL.implode(PHP_EOL, $bucket).PHP_EOL."/>";
}
}

View File

@ -601,6 +601,13 @@ function getFieldOptions(fieldtype){
// append to note_filter_information class
jQuery('.note_filter_information').closest('.control-group').prepend(result.extra);
// append to note_filter_information class
if(result.textarea){
jQuery.each( result.textarea, function( i, tField ) {
// append to note_filter_information class
jQuery('.note_filter_information').closest('.control-group').prepend(tField);
});
}
// append to note_filter_information class
jQuery('.note_filter_information').closest('.control-group').prepend(result.subform);
// add the watcher
rowWatcher();