Resolved gh-441 to allow fieldtype name prefixing. Resolved gh-443 to allow Alphanumeric+dot in fieldtype name. Fixed gh-446 to insure that JFormRuleInt validates correctly in the admin field realtions. Improved the new plugin area to also have system name and option to add custom header code. gh-436
This commit is contained in:
@ -2926,11 +2926,11 @@ class Get
|
||||
$field['settings']->type_name = 'Custom';
|
||||
}
|
||||
// set the type name
|
||||
$type_name = ComponentbuilderHelper::safeString($field['settings']->type_name);
|
||||
$type_name = ComponentbuilderHelper::safeTypeName($field['settings']->type_name);
|
||||
// if custom (we must use the xml value)
|
||||
if ($type_name === 'custom' || $type_name === 'customuser')
|
||||
if (strtolower($type_name) === 'custom' || strtolower($type_name) === 'customuser')
|
||||
{
|
||||
$type = ComponentbuilderHelper::safeString(ComponentbuilderHelper::getBetween($field['settings']->xml, 'type="', '"'));
|
||||
$type = ComponentbuilderHelper::safeTypeName(ComponentbuilderHelper::getBetween($field['settings']->xml, 'type="', '"'));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2942,17 +2942,12 @@ class Get
|
||||
// force the default value
|
||||
if (isset($property['example']) && ComponentbuilderHelper::checkString($property['example']))
|
||||
{
|
||||
$type = ComponentbuilderHelper::safeString($property['example']);
|
||||
}
|
||||
// fallback on type name set in name field
|
||||
elseif (ComponentbuilderHelper::checkString($type_name))
|
||||
{
|
||||
$type = $type_name;
|
||||
$type = ComponentbuilderHelper::safeTypeName($property['example']);
|
||||
}
|
||||
// fall back on the xml settings (not ideal)
|
||||
else
|
||||
{
|
||||
$type = ComponentbuilderHelper::safeString(ComponentbuilderHelper::getBetween($xml, 'type="', '"'));
|
||||
$type = ComponentbuilderHelper::safeTypeName(ComponentbuilderHelper::getBetween($field['settings']->xml, 'type="', '"'));
|
||||
}
|
||||
// exit foreach loop
|
||||
break;
|
||||
@ -2960,11 +2955,15 @@ class Get
|
||||
}
|
||||
}
|
||||
// check if the value is set
|
||||
if (ComponentbuilderHelper::checkString($type))
|
||||
if (isset($type) && ComponentbuilderHelper::checkString($type))
|
||||
{
|
||||
// add the value
|
||||
return $type;
|
||||
}
|
||||
// fallback on type name set in name field (not ideal)
|
||||
else
|
||||
{
|
||||
return $type_name;
|
||||
}
|
||||
}
|
||||
// fall back to text
|
||||
return 'text';
|
||||
|
@ -1399,11 +1399,6 @@ class Fields extends Structure
|
||||
// now add to the field set
|
||||
$field .= $this->setField('option', $r_fieldValues, $r_name, $r_typeName, $langView, $view_name_single, $view_name_list, $placeholders, $r_optionArray, null, $r_taber);
|
||||
}
|
||||
elseif (ComponentbuilderHelper::fieldCheck($r_typeName, 'plain'))
|
||||
{
|
||||
// now add to the field set
|
||||
$field .= $this->setField('plain', $r_fieldValues, $r_name, $r_typeName, $langView, $view_name_single, $view_name_list, $placeholders, $r_optionArray, null, $r_taber);
|
||||
}
|
||||
elseif (ComponentbuilderHelper::checkArray($r_fieldValues['custom']))
|
||||
{
|
||||
// add to custom
|
||||
@ -1425,6 +1420,11 @@ class Fields extends Structure
|
||||
// set the custom field file
|
||||
$this->setCustomFieldTypeFile($data, $view_name_list, $view_name_single);
|
||||
}
|
||||
else
|
||||
{
|
||||
// now add to the field set
|
||||
$field .= $this->setField('plain', $r_fieldValues, $r_name, $r_typeName, $langView, $view_name_single, $view_name_list, $placeholders, $r_optionArray, null, $r_taber);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1498,11 +1498,6 @@ class Fields extends Structure
|
||||
// now add to the field set
|
||||
$field .= $this->setField('option', $r_fieldValues, $r_name, $r_typeName, $langView, $view_name_single, $view_name_list, $placeholders, $r_optionArray, null, $r_taber);
|
||||
}
|
||||
elseif (ComponentbuilderHelper::fieldCheck($r_typeName, 'plain'))
|
||||
{
|
||||
// now add to the field set
|
||||
$field .= $this->setField('plain', $r_fieldValues, $r_name, $r_typeName, $langView, $view_name_single, $view_name_list, $placeholders, $r_optionArray, null, $r_taber);
|
||||
}
|
||||
elseif ($r_typeName === 'subform')
|
||||
{
|
||||
// set nested depth
|
||||
@ -1542,6 +1537,11 @@ class Fields extends Structure
|
||||
// set the custom field file
|
||||
$this->setCustomFieldTypeFile($data, $view_name_list, $view_name_single);
|
||||
}
|
||||
else
|
||||
{
|
||||
// now add to the field set
|
||||
$field .= $this->setField('plain', $r_fieldValues, $r_name, $r_typeName, $langView, $view_name_single, $view_name_list, $placeholders, $r_optionArray, null, $r_taber);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2862,6 +2862,22 @@ class Fields extends Structure
|
||||
// make sure it is not already been build or if it is prime
|
||||
if (isset($data['custom']) && isset($data['custom']['extends']) && ((isset($data['custom']['prime_php']) && $data['custom']['prime_php'] == 1) || !isset($this->fileContentDynamic['customfield_' . $data['type']]) || !ComponentbuilderHelper::checkArray($this->fileContentDynamic['customfield_' . $data['type']])))
|
||||
{
|
||||
// set J prefix
|
||||
$jprefix = 'J';
|
||||
// check if this field has a dot in field type name
|
||||
if (strpos($data['type'], '.') !== false)
|
||||
{
|
||||
// so we have name spacing in custom field type name
|
||||
$dotTypeArray = explode('.', $data['type']);
|
||||
// set the J prefix
|
||||
if (count($dotTypeArray) > 1)
|
||||
{
|
||||
$jprefix = strtoupper(array_shift($dotTypeArray));
|
||||
}
|
||||
// update the type name now
|
||||
$data['type'] = implode('', $dotTypeArray);
|
||||
$data['custom']['type'] = $data['type'];
|
||||
}
|
||||
// set tab and break replacements
|
||||
$tabBreak = array(
|
||||
'\t' => $this->_t(1),
|
||||
@ -2869,6 +2885,7 @@ class Fields extends Structure
|
||||
);
|
||||
// set the [[[PLACEHOLDER]]] options
|
||||
$replace = array(
|
||||
$this->bbb . 'JPREFIX' . $this->ddd => $jprefix,
|
||||
$this->bbb . 'TABLE' . $this->ddd => $data['custom']['table'],
|
||||
$this->bbb . 'ID' . $this->ddd => $data['custom']['id'],
|
||||
$this->bbb . 'TEXT' . $this->ddd => $data['custom']['text'],
|
||||
@ -2901,6 +2918,8 @@ class Fields extends Structure
|
||||
}
|
||||
// start loading the field type
|
||||
$this->fileContentDynamic['customfield_' . $data['type']] = array();
|
||||
// JPREFIX <<DYNAMIC>>>
|
||||
$this->fileContentDynamic['customfield_' . $data['type']][$this->hhh . 'JPREFIX' . $this->hhh] = $jprefix;
|
||||
// Type <<<DYNAMIC>>>
|
||||
$this->fileContentDynamic['customfield_' . $data['type']][$this->hhh . 'Type' . $this->hhh] = ComponentbuilderHelper::safeString($data['custom']['type'], 'F');
|
||||
// type <<<DYNAMIC>>>
|
||||
|
@ -712,6 +712,48 @@ abstract class ComponentbuilderHelper
|
||||
return self::safeString($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* The type builder switch
|
||||
**/
|
||||
protected static $typeNameBuilder = false;
|
||||
|
||||
/**
|
||||
* Making field type name safe
|
||||
*
|
||||
* @input string The you would like to make safe
|
||||
*
|
||||
* @returns string on success
|
||||
**/
|
||||
public static function safeTypeName($string)
|
||||
{
|
||||
// get global value
|
||||
if (self::$typeNameBuilder === false)
|
||||
{
|
||||
self::$typeNameBuilder = JComponentHelper::getParams('com_componentbuilder')->get('type_name_builder', 1);
|
||||
}
|
||||
// use the new convention
|
||||
if (2 == self::$typeNameBuilder)
|
||||
{
|
||||
// 0nly continue if we have a string
|
||||
if (self::checkString($string))
|
||||
{
|
||||
// check that the first character is not a number
|
||||
if (is_numeric(substr($string, 0, 1)))
|
||||
{
|
||||
$string = self::replaceNumbers($string);
|
||||
}
|
||||
// remove all and keep only characters and numbers and point (TODO just one point)
|
||||
$string = trim(preg_replace("/[^A-Za-z0-9\.]/", '', $string));
|
||||
// best is to return lower (for all string equality in compiler)
|
||||
return strtolower($string);
|
||||
}
|
||||
// not a string
|
||||
return '';
|
||||
}
|
||||
// use the default (original behaviour/convention)
|
||||
return self::safeString($string);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the Array of Existing Validation Rule Names
|
||||
*
|
||||
|
Reference in New Issue
Block a user