Added the php field properties to a textarea outside of the subform for easier editing
This commit is contained in:
parent
81e5038bb2
commit
4e7d4af1d3
@ -130,7 +130,7 @@ Component Builder is mapped as a component in itself on my local development env
|
||||
+ *Version*: 2.7.5
|
||||
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
|
||||
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
||||
+ *Line count*: **182312**
|
||||
+ *Line count*: **182437**
|
||||
+ *Field count*: **1012**
|
||||
+ *File count*: **1199**
|
||||
+ *Folder count*: **193**
|
||||
|
@ -130,7 +130,7 @@ Component Builder is mapped as a component in itself on my local development env
|
||||
+ *Version*: 2.7.5
|
||||
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
|
||||
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
||||
+ *Line count*: **182312**
|
||||
+ *Line count*: **182437**
|
||||
+ *Field count*: **1012**
|
||||
+ *File count*: **1199**
|
||||
+ *Folder count*: **193**
|
||||
|
@ -1600,6 +1600,7 @@ abstract class ComponentbuilderHelper
|
||||
$field = array(
|
||||
'subform' => array(),
|
||||
'nameListOptions' => array(),
|
||||
'php' => array(),
|
||||
'values' => "<field ",
|
||||
'values_description' => '<table class="uk-table uk-table-hover uk-table-striped uk-table-condensed">',
|
||||
'short_description' => $result->short_description,
|
||||
@ -1612,32 +1613,62 @@ abstract class ComponentbuilderHelper
|
||||
$field['values_description'] .= '<thead><tr><th class="uk-text-right">'.JText::_('COM_COMPONENTBUILDER_PROPERTY').'</th><th>'.JText::_('COM_COMPONENTBUILDER_EXAMPLE').'</th><th>'.JText::_('COM_COMPONENTBUILDER_DESCRIPTION').'</th></thead><tbody>';
|
||||
foreach ($properties as $property)
|
||||
{
|
||||
$example = (isset($property['example']) && self::checkString($property['example'])) ? self::shorten($property['example'], 30) : '';
|
||||
$example = (isset($property['example']) && self::checkString($property['example'])) ? $property['example'] : '';
|
||||
$field['values_description'] .= '<tr><td class="uk-text-right"><code>'.$property['name'].'</code></td><td>'.$example.'</td><td>'.$property['description'].'</td></tr>';
|
||||
// check if we should load the value
|
||||
$value = self::getValueFromXMLstring($xml, $property['name'], $confirmation);
|
||||
// check if this is a php field
|
||||
$addPHP = false;
|
||||
if (strpos($property['name'], 'type_php') !== false)
|
||||
{
|
||||
$addPHP = true;
|
||||
$phpKey = trim(preg_replace('/[0-9]+/', '', $property['name']), '_');
|
||||
// start array if not already set
|
||||
if (!isset($field['php'][$phpKey]))
|
||||
{
|
||||
$field['php'][$phpKey] = array();
|
||||
$field['php'][$phpKey]['value'] = array();
|
||||
$field['php'][$phpKey]['desc'] = $property['description'];
|
||||
}
|
||||
}
|
||||
// was the settings for the property passed
|
||||
if(self::checkArray($settings) && isset($settings[$property['name']]))
|
||||
{
|
||||
// add the xml values
|
||||
$field['values'] .= "\n\t".$property['name'].'="'.$settings[$property['name']].'" ';
|
||||
$field['values'] .= PHP_EOL."\t".$property['name'].'="'.$settings[$property['name']].'" ';
|
||||
// add the json values
|
||||
$field['subform']['properties'.$nr] = array('name' => $property['name'], 'value' => $settings[$property['name']]);
|
||||
// add the name List Options as set
|
||||
$field['nameListOptionsSet'][$property['name']] = $property['name'];
|
||||
if ($addPHP)
|
||||
{
|
||||
$field['php'][$phpKey]['value'][] = $settings[$property['name']];
|
||||
}
|
||||
else
|
||||
{
|
||||
$field['subform']['properties'.$nr] = array('name' => $property['name'], 'value' => $settings[$property['name']], 'desc' => $property['description']);
|
||||
}
|
||||
}
|
||||
elseif (!$xml || $confirmation !== $value)
|
||||
{
|
||||
// add the xml values
|
||||
$field['values'] .= "\n\t" . $property['name'] . '="'. ($confirmation !== $value) ? $value : $property['example'] .'" ';
|
||||
$field['values'] .= PHP_EOL."\t" . $property['name'] . '="'. ($confirmation !== $value) ? $value : $example .'" ';
|
||||
// add the json values
|
||||
$field['subform']['properties' . $nr] = array('name' => $property['name'], 'value' => ($confirmation !== $value) ? $value : $property['example'], 'desc' => $property['description']);
|
||||
if ($addPHP)
|
||||
{
|
||||
$field['php'][$phpKey]['value'][] = ($confirmation !== $value) ? $value : $example;
|
||||
}
|
||||
else
|
||||
{
|
||||
$field['subform']['properties' . $nr] = array('name' => $property['name'], 'value' => ($confirmation !== $value) ? $value : $example, 'desc' => $property['description']);
|
||||
}
|
||||
}
|
||||
// add the name List Options
|
||||
$field['nameListOptions'][$property['name']] = $property['name'];
|
||||
if (!$addPHP)
|
||||
{
|
||||
$field['nameListOptions'][$property['name']] = $property['name'];
|
||||
}
|
||||
// increment the number
|
||||
$nr++;
|
||||
}
|
||||
$field['values'] .= "\n/>";
|
||||
$field['values'] .= PHP_EOL."/>";
|
||||
$field['values_description'] .= '</tbody></table>';
|
||||
// return found field options
|
||||
return $field;
|
||||
|
@ -6577,6 +6577,7 @@ COM_COMPONENTBUILDER_YOU_SHOULD_ADD_THE_CORRECT_OWNER_DETAILS="You should add th
|
||||
COM_COMPONENTBUILDER_YOU_SHOULD_ONLY_CONTINUE_THIS_IMPORT_IF_YOU_HAVE_BACKUP_YOUR_COMPONENTS_AND_INSURED_THAT_THE_PACKAGE_OWNER_IS_REPUTABLE="You should only continue this import if you have backup your components, and insured that the package owner is reputable."
|
||||
COM_COMPONENTBUILDER_YOU_WILL_NEED_TO_KNOW_HOW_S_WORKS_BASIC_YOU_WILL_ALSO_NEED_A_S_ACCOUNT_AND_KNOW_HOW_TO_MAKE_A_PULL_REQUEST_ON_GITHUB="you will need to know how %s works (basic). You will also need a %s account and know how to make a pull request on github."
|
||||
COM_COMPONENTBUILDER_ZIPPED_FILE_LOCATION="Zipped File Location"
|
||||
COM_COMPONENTBUILDER__ADD_YOUR_PHP_SCRIPT_HERE="// Add your php script here"
|
||||
COM_COMPONENTBUILDER__SELECT_COMPONENT_="- Select Component -"
|
||||
COM_COMPONENTBUILDER__SELECT_PACKAGE_="- Select Package -"
|
||||
COM_COMPONENTBUILDER__SINCE_YOU_DONT_HAVE_PERMISSION_TO_CREATE_S=", since you don't have permission to create %s!"
|
||||
|
@ -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
|
||||
|
@ -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."/>";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
File diff suppressed because one or more lines are too long
@ -612,6 +612,7 @@ abstract class ComponentbuilderHelper
|
||||
$field = array(
|
||||
'subform' => array(),
|
||||
'nameListOptions' => array(),
|
||||
'php' => array(),
|
||||
'values' => "<field ",
|
||||
'values_description' => '<table class="uk-table uk-table-hover uk-table-striped uk-table-condensed">',
|
||||
'short_description' => $result->short_description,
|
||||
@ -624,32 +625,62 @@ abstract class ComponentbuilderHelper
|
||||
$field['values_description'] .= '<thead><tr><th class="uk-text-right">'.JText::_('COM_COMPONENTBUILDER_PROPERTY').'</th><th>'.JText::_('COM_COMPONENTBUILDER_EXAMPLE').'</th><th>'.JText::_('COM_COMPONENTBUILDER_DESCRIPTION').'</th></thead><tbody>';
|
||||
foreach ($properties as $property)
|
||||
{
|
||||
$example = (isset($property['example']) && self::checkString($property['example'])) ? self::shorten($property['example'], 30) : '';
|
||||
$example = (isset($property['example']) && self::checkString($property['example'])) ? $property['example'] : '';
|
||||
$field['values_description'] .= '<tr><td class="uk-text-right"><code>'.$property['name'].'</code></td><td>'.$example.'</td><td>'.$property['description'].'</td></tr>';
|
||||
// check if we should load the value
|
||||
$value = self::getValueFromXMLstring($xml, $property['name'], $confirmation);
|
||||
// check if this is a php field
|
||||
$addPHP = false;
|
||||
if (strpos($property['name'], 'type_php') !== false)
|
||||
{
|
||||
$addPHP = true;
|
||||
$phpKey = trim(preg_replace('/[0-9]+/', '', $property['name']), '_');
|
||||
// start array if not already set
|
||||
if (!isset($field['php'][$phpKey]))
|
||||
{
|
||||
$field['php'][$phpKey] = array();
|
||||
$field['php'][$phpKey]['value'] = array();
|
||||
$field['php'][$phpKey]['desc'] = $property['description'];
|
||||
}
|
||||
}
|
||||
// was the settings for the property passed
|
||||
if(self::checkArray($settings) && isset($settings[$property['name']]))
|
||||
{
|
||||
// add the xml values
|
||||
$field['values'] .= "\n\t".$property['name'].'="'.$settings[$property['name']].'" ';
|
||||
$field['values'] .= PHP_EOL."\t".$property['name'].'="'.$settings[$property['name']].'" ';
|
||||
// add the json values
|
||||
$field['subform']['properties'.$nr] = array('name' => $property['name'], 'value' => $settings[$property['name']]);
|
||||
// add the name List Options as set
|
||||
$field['nameListOptionsSet'][$property['name']] = $property['name'];
|
||||
if ($addPHP)
|
||||
{
|
||||
$field['php'][$phpKey]['value'][] = $settings[$property['name']];
|
||||
}
|
||||
else
|
||||
{
|
||||
$field['subform']['properties'.$nr] = array('name' => $property['name'], 'value' => $settings[$property['name']], 'desc' => $property['description']);
|
||||
}
|
||||
}
|
||||
elseif (!$xml || $confirmation !== $value)
|
||||
{
|
||||
// add the xml values
|
||||
$field['values'] .= "\n\t" . $property['name'] . '="'. ($confirmation !== $value) ? $value : $property['example'] .'" ';
|
||||
$field['values'] .= PHP_EOL."\t" . $property['name'] . '="'. ($confirmation !== $value) ? $value : $example .'" ';
|
||||
// add the json values
|
||||
$field['subform']['properties' . $nr] = array('name' => $property['name'], 'value' => ($confirmation !== $value) ? $value : $property['example'], 'desc' => $property['description']);
|
||||
if ($addPHP)
|
||||
{
|
||||
$field['php'][$phpKey]['value'][] = ($confirmation !== $value) ? $value : $example;
|
||||
}
|
||||
else
|
||||
{
|
||||
$field['subform']['properties' . $nr] = array('name' => $property['name'], 'value' => ($confirmation !== $value) ? $value : $example, 'desc' => $property['description']);
|
||||
}
|
||||
}
|
||||
// add the name List Options
|
||||
$field['nameListOptions'][$property['name']] = $property['name'];
|
||||
if (!$addPHP)
|
||||
{
|
||||
$field['nameListOptions'][$property['name']] = $property['name'];
|
||||
}
|
||||
// increment the number
|
||||
$nr++;
|
||||
}
|
||||
$field['values'] .= "\n/>";
|
||||
$field['values'] .= PHP_EOL."/>";
|
||||
$field['values_description'] .= '</tbody></table>';
|
||||
// return found field options
|
||||
return $field;
|
||||
|
Loading…
Reference in New Issue
Block a user