Code formatting

This commit is contained in:
Michael Richey 2017-12-03 11:08:01 -06:00 committed by GitHub
parent 55afca91a2
commit c1675dbd30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -362,10 +362,11 @@ class Fields extends Structure {
* @return void
*
*/
private function setLine($nr) {
private function setLine($nr)
{
if ($this->debugLinenr)
{
return ' [Fields ' . $nr . ']';
return ' [Fields '.$nr.']';
}
return '';
}
@ -379,7 +380,8 @@ class Fields extends Structure {
* @return string The fields set in xml
*
*/
public function setFieldSet($view, $component) {
public function setFieldSet($view, $component)
{
// setup the fieldset of this view
if (isset($view['settings']->fields) && ComponentbuilderHelper::checkArray($view['settings']->fields))
{
@ -478,69 +480,70 @@ class Fields extends Structure {
// set the default fields
$XML = new simpleXMLElement('<a/>');
$fieldSetXML = $XML->addChild('fieldset');
$fieldSetXML->addAttribute('name','details');
$this->xmlComment($fieldSetXML,$this->setLine(__LINE__) . " Default Fields.");
$this->xmlComment($fieldSetXML,$this->setLine(__LINE__) . " Id Field. Type: Text (joomla)");
$fieldSetXML->addAttribute('name', 'details');
$this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Default Fields.");
$this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Id Field. Type: Text (joomla)");
// if id is not set
if (!isset($this->fieldsNames[$viewName]['id']))
{
$attributes = array(
'type'=>'text',
'class'=>'readonly',
'label'=>'JGLOBAL_FIELD_ID_LABEL',
'description'=>'JGLOBAL_FIELD_ID_DESC',
'size'=>10,
'default'=>0
'type' => 'text',
'class' => 'readonly',
'label' => 'JGLOBAL_FIELD_ID_LABEL',
'description' => 'JGLOBAL_FIELD_ID_DESC',
'size' => 10,
'default' => 0
);
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML,$attributes);
$this->xmlAddAttributes($fieldXML, $attributes);
}
// if created is not set
if (!isset($this->fieldsNames[$viewName]['created']))
{
$attributes = array(
'name'=>'created',
'type'=>'calendar',
'label'=>$langView . '_CREATED_DATE_LABEL',
'description'=>$langView . '_CREATED_DATE_DESC',
'size'=>22,
'format'=>'%Y-%m-%d %H:%M:%S',
'filter'=>'user_utc'
'name' => 'created',
'type' => 'calendar',
'label' => $langView . '_CREATED_DATE_LABEL',
'description' => $langView . '_CREATED_DATE_DESC',
'size' => 22,
'format' => '%Y-%m-%d %H:%M:%S',
'filter' => 'user_utc'
);
$attributes = array_merge($attributes,$readOnlyXML);
$this->xmlComment($fieldSetXML,$this->setLine(__LINE__) . " Date Created Field. Type: Calendar (joomla)");
$attributes = array_merge($attributes, $readOnlyXML);
$this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Date Created Field. Type: Calendar (joomla)");
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML,$attributes);
$this->xmlAddAttributes($fieldXML, $attributes);
}
// if created_by is not set
if (!isset($this->fieldsNames[$viewName]['created_by']))
{
$attributes = array(
'name'=>'created_by',
'type'=>'user',
'label'=>$langView . '_CREATED_BY_LABEL',
'description'=>$langView . '_CREATED_BY_DESC',
'name' => 'created_by',
'type' => 'user',
'label' => $langView . '_CREATED_BY_LABEL',
'description' => $langView . '_CREATED_BY_DESC',
);
$attributes = array_merge($attributes,$readOnlyXML);
$this->xmlComment($fieldSetXML,$this->setLine(__LINE__) . " User Created Field. Type: User (joomla)");
$attributes = array_merge($attributes, $readOnlyXML);
$this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " User Created Field. Type: User (joomla)");
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML,$attributes);
$this->xmlAddAttributes($fieldXML, $attributes);
}
// if published is not set
if (!isset($this->fieldsNames[$viewName]['published']))
{
$attributes = array(
'name'=>'published',
'type'=>'list',
'label'=>'JSTATUS'
'name' => 'published',
'type' => 'list',
'label' => 'JSTATUS'
);
$attributes = array_merge($attributes,$readOnlyXML);
$this->xmlComment($fieldSetXML,$this->setLine(__LINE__) . " Published Field. Type: List (joomla)");
$attributes = array_merge($attributes, $readOnlyXML);
$this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Published Field. Type: List (joomla)");
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML,$attributes);
foreach(array('JPUBLISHED'=>1,'JUNPUBLISHED'=>0,'JARCHIVED'=>2,'JTRASHED'=>-2) as $text=>$value) {
$this->xmlAddAttributes($fieldXML, $attributes);
foreach (array('JPUBLISHED' => 1, 'JUNPUBLISHED' => 0, 'JARCHIVED' => 2, 'JTRASHED' => -2) as $text => $value)
{
$optionXML = $fieldXML->addChild('option');
$optionXML->addAttribute('value',$value);
$optionXML->addAttribute('value', $value);
$optionXML[] = $text;
}
}
@ -548,180 +551,182 @@ class Fields extends Structure {
if (!isset($this->fieldsNames[$viewName]['modified']))
{
$attributes = array(
'name'=>'modified',
'type'=>'calendar',
'class'=>'readonly',
'label'=>$langView . '_MODIFIED_DATE_LABEL',
'description'=>$langView . '_MODIFIED_DATE_DESC',
'size'=>22,
'readonly'=>"true",
'format'=>'%Y-%m-%d %H:%M:%S',
'filter'=>'user_utc'
'name' => 'modified',
'type' => 'calendar',
'class' => 'readonly',
'label' => $langView . '_MODIFIED_DATE_LABEL',
'description' => $langView . '_MODIFIED_DATE_DESC',
'size' => 22,
'readonly' => "true",
'format' => '%Y-%m-%d %H:%M:%S',
'filter' => 'user_utc'
);
$this->xmlComment($fieldSetXML,$this->setLine(__LINE__) . " Date Modified Field. Type: Calendar (joomla)");
$this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Date Modified Field. Type: Calendar (joomla)");
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML,$attributes);
$this->xmlAddAttributes($fieldXML, $attributes);
}
// if modified_by is not set
if (!isset($this->fieldsNames[$viewName]['modified_by']))
{
$attributes = array(
'name'=>'modified_by',
'type'=>'user',
'label'=>$langView . '_MODIFIED_BY_LABEL',
'description'=>$langView . '_MODIFIED_BY_DESC',
'class'=>'readonly',
'readonly'=>'true',
'filter'=>'unset'
'name' => 'modified_by',
'type' => 'user',
'label' => $langView . '_MODIFIED_BY_LABEL',
'description' => $langView . '_MODIFIED_BY_DESC',
'class' => 'readonly',
'readonly' => 'true',
'filter' => 'unset'
);
$this->xmlComment($fieldSetXML,$this->setLine(__LINE__) . " User Modified Field. Type: User (joomla)");
$this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " User Modified Field. Type: User (joomla)");
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML,$attributes);
$this->xmlAddAttributes($fieldXML, $attributes);
}
// check if view has access
if (isset($this->accessBuilder[$viewName]) && ComponentbuilderHelper::checkString($this->accessBuilder[$viewName]) && !isset($this->fieldsNames[$viewName]['access']))
{
$attributes = array(
'name'=>'access',
'type'=>'accesslevel',
'label'=>'JFIELD_ACCESS_LABEL',
'description'=>'JFIELD_ACCESS_DESC',
'default'=>1,
'required'=>"false"
'name' => 'access',
'type' => 'accesslevel',
'label' => 'JFIELD_ACCESS_LABEL',
'description' => 'JFIELD_ACCESS_DESC',
'default' => 1,
'required' => "false"
);
$attributes = array_merge($attributes,$readOnlyXML);
$this->xmlComment($fieldSetXML,$this->setLine(__LINE__) . " Access Field. Type: Accesslevel (joomla)");
$attributes = array_merge($attributes, $readOnlyXML);
$this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Access Field. Type: Accesslevel (joomla)");
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML,$attributes);
$this->xmlAddAttributes($fieldXML, $attributes);
}
// if ordering is not set
if (!isset($this->fieldsNames[$viewName]['ordering']))
{
$attributes = array(
'name'=>'ordering',
'type'=>'number',
'class'=>'inputbox validate-ordering',
'label'=>$langView . '_ORDERING_LABEL',
'description'=>'',
'default'=>0,
'size'=>6,
'required'=>"false"
'name' => 'ordering',
'type' => 'number',
'class' => 'inputbox validate-ordering',
'label' => $langView . '_ORDERING_LABEL',
'description' => '',
'default' => 0,
'size' => 6,
'required' => "false"
);
$attributes = array_merge($attributes,$readOnlyXML);
$this->xmlComment($fieldSetXML,$this->setLine(__LINE__) . " Ordering Field. Type: Numbers (joomla)");
$attributes = array_merge($attributes, $readOnlyXML);
$this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Ordering Field. Type: Numbers (joomla)");
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML,$attributes);
$this->xmlAddAttributes($fieldXML, $attributes);
}
// if version is not set
if (!isset($this->fieldsNames[$viewName]['version']))
{
$attributes = array(
'name'=>'version',
'type'=>'text',
'class'=>'readonly',
'label'=>$langView . '_VERSION_LABEL',
'description'=>$langView . '_VERSION_DESC',
'size'=>6,
'readonly'=>"true",
'filter'=>'unset'
'name' => 'version',
'type' => 'text',
'class' => 'readonly',
'label' => $langView . '_VERSION_LABEL',
'description' => $langView . '_VERSION_DESC',
'size' => 6,
'readonly' => "true",
'filter' => 'unset'
);
$this->xmlComment($fieldSetXML,$this->setLine(__LINE__) . " Version Field. Type: Text (joomla)");
$this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Version Field. Type: Text (joomla)");
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML,$attributes);
$this->xmlAddAttributes($fieldXML, $attributes);
}
// check if metadata is added to this view
if (isset($this->metadataBuilder[$viewName]) && ComponentbuilderHelper::checkString($this->metadataBuilder[$viewName]))
{
// metakey
$attributes = array(
'name'=>'metakey',
'type'=>'textarea',
'label'=>'JFIELD_META_KEYWORDS_LABEL',
'description'=>'JFIELD_META_KEYWORDS_DESC',
'rows'=>3,
'cols'=>30
'name' => 'metakey',
'type' => 'textarea',
'label' => 'JFIELD_META_KEYWORDS_LABEL',
'description' => 'JFIELD_META_KEYWORDS_DESC',
'rows' => 3,
'cols' => 30
);
$this->xmlComment($fieldSetXML,$this->setLine(__LINE__) . " Metakey Field. Type: Textarea (joomla)");
$this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Metakey Field. Type: Textarea (joomla)");
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML,$attributes);
$this->xmlAddAttributes($fieldXML, $attributes);
// metadesc
$attributes['name'] = 'metadesc';
$attributes['label'] = 'JFIELD_META_DESCRIPTION_LABEL';
$attributes['description'] = 'JFIELD_META_DESCRIPTION_DESC';
$this->xmlComment($fieldSetXML,$this->setLine(__LINE__) . " Metadesc Field. Type: Textarea (joomla)");
$this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Metadesc Field. Type: Textarea (joomla)");
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML,$attributes);
$this->xmlAddAttributes($fieldXML, $attributes);
}
// load the dynamic fields now
if (count($dynamicFieldsXML))
{
$this->xmlComment($fieldSetXML,$this->setLine(__LINE__) . " Dynamic Fields.");
foreach($dynamicFieldsXML as $dynamicfield) {
$this->xmlAppend($fieldSetXML,$dynamicfield);
$this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Dynamic Fields.");
foreach ($dynamicFieldsXML as $dynamicfield)
{
$this->xmlAppend($fieldSetXML, $dynamicfield);
}
}
// check if metadata is added to this view
if (isset($this->metadataBuilder[$viewName]) && ComponentbuilderHelper::checkString($this->metadataBuilder[$viewName]))
{
$this->xmlComment($fieldSetXML,$this->setLine(__LINE__) . " Metadata Fields");
$this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Metadata Fields");
$fieldsXML = $fieldSetXML->addChild('fields');
$fieldsXML->addAttribute('name','metadata');
$fieldsXML->addAttribute('label','JGLOBAL_FIELDSET_METADATA_OPTIONS');
$fieldsXML->addAttribute('name', 'metadata');
$fieldsXML->addAttribute('label', 'JGLOBAL_FIELDSET_METADATA_OPTIONS');
$fieldsFieldSetXML = $fieldsXML->addChild('fieldset');
$fieldsFieldSetXML->addAttribute('name','vdmmetadata');
$fieldsFieldSetXML->addAttribute('label','JGLOBAL_FIELDSET_METADATA_OPTIONS');
$fieldsFieldSetXML->addAttribute('name', 'vdmmetadata');
$fieldsFieldSetXML->addAttribute('label', 'JGLOBAL_FIELDSET_METADATA_OPTIONS');
// robots
$this->xmlComment($fieldsFieldSetXML,$this->setLine(__LINE__) . " Robots Field. Type: List (joomla)");
$this->xmlComment($fieldsFieldSetXML, $this->setLine(__LINE__) . " Robots Field. Type: List (joomla)");
$robots = $fieldsFieldSetXML->addChild('field');
$attributes = array(
'name'=>'robots',
'type'=>'list',
'label'=>'JFIELD_METADATA_ROBOTS_LABEL',
'description'=>'JFIELD_METADATA_ROBOTS_DESC'
'name' => 'robots',
'type' => 'list',
'label' => 'JFIELD_METADATA_ROBOTS_LABEL',
'description' => 'JFIELD_METADATA_ROBOTS_DESC'
);
$this->xmlAddAttributes($robots,$attributes);
$this->xmlAddAttributes($robots, $attributes);
$options = array(
'JGLOBAL_USE_GLOBAL'=>'',
'JGLOBAL_INDEX_FOLLOW'=>'index, follow',
'JGLOBAL_NOINDEX_FOLLOW'=>'noindex, follow',
'JGLOBAL_INDEX_NOFOLLOW'=>'index, nofollow',
'JGLOBAL_NOINDEX_NOFOLLOW'=>'noindex, nofollow',
'JGLOBAL_USE_GLOBAL' => '',
'JGLOBAL_INDEX_FOLLOW' => 'index, follow',
'JGLOBAL_NOINDEX_FOLLOW' => 'noindex, follow',
'JGLOBAL_INDEX_NOFOLLOW' => 'index, nofollow',
'JGLOBAL_NOINDEX_NOFOLLOW' => 'noindex, nofollow',
);
foreach($options as $text=>$value) {
foreach ($options as $text => $value)
{
$option = $robots->addChild('option');
$option->addAttribute('value',$value);
$option->addAttribute('value', $value);
$option[] = $text;
}
// author
$this->xmlComment($fieldsFieldSetXML,$this->setLine(__LINE__) . " Author Field. Type: Text (joomla)");
$this->xmlComment($fieldsFieldSetXML, $this->setLine(__LINE__) . " Author Field. Type: Text (joomla)");
$author = $fieldsFieldSetXML->addChild('field');
$attributes = array(
'name'=>'author',
'type'=>'text',
'label'=>'JAUTHOR',
'description'=>'JFIELD_METADATA_AUTHOR_DESC',
'size'=>20
'name' => 'author',
'type' => 'text',
'label' => 'JAUTHOR',
'description' => 'JFIELD_METADATA_AUTHOR_DESC',
'size' => 20
);
$this->xmlAddAttributes($author,$attributes);
$this->xmlAddAttributes($author, $attributes);
// rights
$this->xmlComment($fieldsFieldSetXML,$this->setLine(__LINE__) . " Rights Field. Type: Textarea (joomla)");
$this->xmlComment($fieldsFieldSetXML, $this->setLine(__LINE__) . " Rights Field. Type: Textarea (joomla)");
$rights = $fieldsFieldSetXML->addChild('field');
$attributes = array(
'name'=>'rights',
'type'=>'textarea',
'label'=>'JFIELD_META_RIGHTS_LABEL',
'description'=>'JFIELD_META_RIGHTS_DESC',
'required'=>'false',
'filter'=>'string',
'cols'=>30,
'rows'=>2
'name' => 'rights',
'type' => 'textarea',
'label' => 'JFIELD_META_RIGHTS_LABEL',
'description' => 'JFIELD_META_RIGHTS_DESC',
'required' => 'false',
'filter' => 'string',
'cols' => 30,
'rows' => 2
);
$this->xmlAddAttributes($rights,$attributes);
$this->xmlAddAttributes($rights, $attributes);
}
// just to be safe, lets clear the view placeholders
$this->clearFromPlaceHolders('view');
// return the set
return $this->xmlPrettyPrint($XML,'fieldset');
return $this->xmlPrettyPrint($XML, 'fieldset');
}
return '';
}
@ -734,7 +739,8 @@ class Fields extends Structure {
*
*
*/
public function setFieldsNames(&$view, &$name) {
public function setFieldsNames(&$view, &$name)
{
$this->fieldsNames[$view][$name] = $name;
}
@ -752,10 +758,11 @@ class Fields extends Structure {
* @param string $dbkey The the custom table key
* @param boolean $build The switch to set the build option
*
* @return string The complete field in xml
* @return SimpleXMLElement The complete field in xml
*
*/
public function setDynamicField(&$field, &$view, &$viewType, &$langView, &$viewName, &$listViewName, &$spacerCounter, &$placeholders, &$dbkey, $build) {
public function setDynamicField(&$field, &$view, &$viewType, &$langView, &$viewName, &$listViewName, &$spacerCounter, &$placeholders, &$dbkey, $build)
{
if (isset($field['settings']) && ComponentbuilderHelper::checkObject($field['settings']))
{
// reset some values
@ -771,13 +778,13 @@ class Fields extends Structure {
if (ComponentbuilderHelper::checkArray($fieldAttributes))
{
// set the array of field names
$this->setFieldsNames($viewName, $fieldAttributes['name']);
$this->setFieldsNames($viewName,$fieldAttributes['name']);
if ($this->defaultField($typeName, 'option'))
{
//reset options array
$optionArray = array();
// now add to the field set
$xmlElement = $this->setField('option', $fieldAttributes, $name, $typeName, $langView, $viewName, $listViewName, $placeholders, $optionArray);
if ($build)
{
@ -793,7 +800,6 @@ class Fields extends Structure {
$this->setBuilders($langLabel, $langView, $viewName, $listViewName, $name, $view, $field, $typeName, $multiple);
}
// now add to the field set
$xmlElement = $this->setField('plain', $fieldAttributes, $name, $typeName, $langView, $viewName, $listViewName, $placeholders, $optionArray);
}
elseif ($this->defaultField($typeName, 'spacer'))
@ -872,11 +878,11 @@ class Fields extends Structure {
* @param string $optionArray The option bucket array used to set the field options if needed.
* @param arra $custom Used when field is from config
*
* @return SimpleXMLElement The field as a SimpleXMLEflement
* @return string The field in xml
* @return SimpleXMLElement The field in xml
*
*/
private function setField($setType, &$fieldAttributes, &$name, &$typeName, &$langView, &$viewName, &$listViewName, $placeholders, &$optionArray, $custom = null) {
private function setField($setType, &$fieldAttributes, &$name, &$typeName, &$langView, &$viewName, &$listViewName, $placeholders, &$optionArray, $custom = null)
{
$r = new stdClass();
if ($setType === 'option')
{
@ -888,11 +894,11 @@ class Fields extends Structure {
{
if ($property != 'option')
{
$r->fieldXML->addAttribute($property,$value);
$r->fieldXML->addAttribute($property, $value);
}
elseif ($property === 'option')
{
$this->xmlComment($r->fieldXML,$this->setLine(__LINE__) . " Option Set.");
$this->xmlComment($r->fieldXML, $this->setLine(__LINE__) . " Option Set.");
if (strpos($value, ',') !== false)
{
// mulitpal options
@ -908,7 +914,7 @@ class Fields extends Structure {
// add to lang array
$this->langContent[$this->lang][$langValue] = $t;
// no add to option set
$optionXML->addAttribute('value',$v);
$optionXML->addAttribute('value', $v);
$optionArray[$v] = $langValue;
}
else
@ -918,7 +924,7 @@ class Fields extends Structure {
// add to lang array
$this->langContent[$this->lang][$langValue] = $option;
// no add to option set
$optionXML->addAttribute('value',$option);
$optionXML->addAttribute('value', $option);
$optionArray[$option] = $langValue;
}
$optionXML[] = $langValue;
@ -936,7 +942,7 @@ class Fields extends Structure {
// add to lang array
$this->langContent[$this->lang][$langValue] = $t;
// no add to option set
$optionXML->addAttribute('value',$v);
$optionXML->addAttribute('value', $v);
$optionArray[$v] = $langValue;
}
else
@ -946,15 +952,16 @@ class Fields extends Structure {
// add to lang array
$this->langContent[$this->lang][$langValue] = $value;
// no add to option set
$optionXML->addAttribute('value',$value);
$optionXML->addAttribute('value', $value);
$optionArray[$value] = $langValue;
}
$optionXML[] = $langValue;
}
}
}
if(!$r->fieldXML->count()) {
$this->xmlComment($r->fieldXML,$this->setLine(__LINE__) . " No Manual Options Were Added In Field Settings.");
if (!$r->fieldXML->count())
{
$this->xmlComment($r->fieldXML, $this->setLine(__LINE__) . " No Manual Options Were Added In Field Settings.");
}
}
elseif ($setType === 'plain')
@ -967,7 +974,7 @@ class Fields extends Structure {
{
if ($property != 'option')
{
$r->fieldXML->addAttribute($property,$value);
$r->fieldXML->addAttribute($property, $value);
}
}
}
@ -981,7 +988,7 @@ class Fields extends Structure {
{
if ($property != 'option')
{
$r->fieldXML->addAttribute($property,$value);
$r->fieldXML->addAttribute($property, $value);
}
}
}
@ -998,16 +1005,16 @@ class Fields extends Structure {
{
if ($property != 'fields')
{
$r->fieldXML->addAttribute($property,$value);
$r->fieldXML->addAttribute($property, $value);
}
}
$fieldsXML = $r->fieldXML->addChild('fields');
$fieldsXML->addAttribute('name',$fieldAttributes['name'].'_fields');
$fieldsXML->addAttribute('label','');
$fieldsXML->addAttribute('name', $fieldAttributes['name'] . '_fields');
$fieldsXML->addAttribute('label', '');
$fieldSetXML = $fieldsXML->addChild('fieldset');
$fieldSetXML->addAttribute('hidden','true');
$fieldSetXML->addAttribute('name',$fieldAttributes['name'] . '_modal');
$fieldSetXML->addAttribute('repeat','true');
$fieldSetXML->addAttribute('hidden', 'true');
$fieldSetXML->addAttribute('name', $fieldAttributes['name'] . '_modal');
$fieldSetXML->addAttribute('repeat', 'true');
if (strpos($fieldAttributes['fields'], ',') !== false)
{
@ -1043,12 +1050,12 @@ class Fields extends Structure {
if ($this->defaultField($r_typeName, 'option'))
{
// now add to the field set
$this->xmlAppend($fieldSetXML,$this->setField('option', $r_fieldValues, $r_name, $r_typeName, $langView, $viewName, $listViewName, $placeholders, $r_optionArray));
$this->xmlAppend($fieldSetXML, $this->setField('option', $r_fieldValues, $r_name, $r_typeName, $langView, $viewName, $listViewName, $placeholders, $r_optionArray));
}
elseif ($this->defaultField($r_typeName, 'plain'))
{
// now add to the field set
$this->xmlAppend($fieldSetXML,$this->setField('plain', $r_fieldValues, $r_name, $r_typeName, $langView, $viewName, $listViewName, $placeholders, $r_optionArray));
$this->xmlAppend($fieldSetXML, $this->setField('plain', $r_fieldValues, $r_name, $r_typeName, $langView, $viewName, $listViewName, $placeholders, $r_optionArray));
}
elseif (ComponentbuilderHelper::checkArray($r_fieldValues['custom']))
{
@ -1056,7 +1063,7 @@ class Fields extends Structure {
$custom = $r_fieldValues['custom'];
unset($r_fieldValues['custom']);
// now add to the field set
$this->xmlAppend($fieldSetXML,$this->setField('custom', $r_fieldValues, $r_name, $r_typeName, $langView, $viewName, $listViewName, $placeholders, $r_optionArray));
$this->xmlAppend($fieldSetXML, $this->setField('custom', $r_fieldValues, $r_name, $r_typeName, $langView, $viewName, $listViewName, $placeholders, $r_optionArray));
// set lang (just incase)
$r_listLangName = $langView . '_' . ComponentbuilderHelper::safeString($r_name, 'U');
// add to lang array
@ -1087,7 +1094,7 @@ class Fields extends Structure {
{
if ($property != 'fields')
{
$r->fieldXML->addAttribute($property,$value);
$r->fieldXML->addAttribute($property, $value);
}
}
// if we do not detect formsource we add the form
@ -1095,11 +1102,11 @@ class Fields extends Structure {
{
$form = $r->fieldXML->addChild('form');
$attributes = array(
'hidden'=>'true',
'name'=>'list_' . $fieldAttributes['name'] . '_modal',
'repeat'=>'true'
'hidden' => 'true',
'name' => 'list_' . $fieldAttributes['name'] . '_modal',
'repeat' => 'true'
);
$this->xmlAddAttributes($form,$attributes);
$this->xmlAddAttributes($form, $attributes);
if (strpos($fieldAttributes['fields'], ',') !== false)
{
@ -1135,12 +1142,12 @@ class Fields extends Structure {
if ($this->defaultField($r_typeName, 'option'))
{
// now add to the field set
$this->xmlAppend($form,$this->setField('option', $r_fieldValues, $r_name, $r_typeName, $langView, $viewName, $listViewName, $placeholders, $r_optionArray));
$this->xmlAppend($form, $this->setField('option', $r_fieldValues, $r_name, $r_typeName, $langView, $viewName, $listViewName, $placeholders, $r_optionArray));
}
elseif ($this->defaultField($r_typeName, 'plain'))
{
// now add to the field set
$this->xmlAppend($form,$this->setField('plain', $r_fieldValues, $r_name, $r_typeName, $langView, $viewName, $listViewName, $placeholders, $r_optionArray));
$this->xmlAppend($form, $this->setField('plain', $r_fieldValues, $r_name, $r_typeName, $langView, $viewName, $listViewName, $placeholders, $r_optionArray));
}
elseif (ComponentbuilderHelper::checkArray($r_fieldValues['custom']))
{
@ -1148,7 +1155,7 @@ class Fields extends Structure {
$custom = $r_fieldValues['custom'];
unset($r_fieldValues['custom']);
// now add to the field set
$this->xmlAppend($form,$this->setField('custom', $r_fieldValues, $r_name, $r_typeName, $langView, $viewName, $listViewName, $placeholders, $r_optionArray));
$this->xmlAppend($form, $this->setField('custom', $r_fieldValues, $r_name, $r_typeName, $langView, $viewName, $listViewName, $placeholders, $r_optionArray));
// set lang (just incase)
$r_listLangName = $langView . '_' . ComponentbuilderHelper::safeString($r_name, 'U');
// add to lang array
@ -1175,15 +1182,13 @@ class Fields extends Structure {
// now add to the field set
$r->fieldXML = new SimpleXMLElement('<field/>');
$r->comment = $this->setLine(__LINE__) . " " . ComponentbuilderHelper::safeString($name, 'F') . " Field. Type: " . ComponentbuilderHelper::safeString($typeName, 'F') . ". (custom)";
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'option')
{
$r->fieldXML->addAttribute($property,$value);
$r->fieldXML->addAttribute($property, $value);
}
}
// incase the field is in the config and has not been set
if ('config' === $viewName && 'configs' === $listViewName)
{
@ -1209,7 +1214,8 @@ class Fields extends Structure {
* @return void
*
*/
public function setLayoutBuilder(&$viewName, &$tabName, &$name, &$field) {
public function setLayoutBuilder(&$viewName,&$tabName,&$name,&$field)
{
// first fix the zero order
// to insure it lands before all the other fields
// as zero is expected to behave
@ -1296,15 +1302,16 @@ class Fields extends Structure {
* @return void
*
*/
public function buildSiteFieldData($view, $field, $set, $type) {
$decode = array('json', 'base64', 'basic_encryption', 'advance_encryption');
$uikit = array('textarea', 'editor');
public function buildSiteFieldData($view, $field, $set, $type)
{
$decode = array('json','base64','basic_encryption','advance_encryption');
$uikit = array('textarea','editor');
if (isset($this->siteFields[$view][$field]) && ComponentbuilderHelper::checkArray($this->siteFields[$view][$field]))
{
foreach ($this->siteFields[$view][$field] as $code => $array)
{
// set the decoding methods
if (in_array($set, $decode))
if (in_array($set,$decode))
{
$this->siteFieldData['decode'][$array['site']][$code][$array['as']][$array['key']] = array('decode' => $set, 'type' => $type);
}
@ -1336,7 +1343,8 @@ class Fields extends Structure {
* @return array The field attributes
*
*/
private function setFieldAttributes(&$field, &$viewType, &$name, &$typeName, &$multiple, &$langLabel, $langView, &$spacerCounter, $listViewName, $viewName, $placeholders, $repeatable = false) {
private function setFieldAttributes(&$field, &$viewType, &$name, &$typeName, &$multiple, &$langLabel, $langView, &$spacerCounter, $listViewName, $viewName, $placeholders, $repeatable = false)
{
// reset array`
$fieldAttributes = array();
$setCustom = false;
@ -1673,7 +1681,8 @@ class Fields extends Structure {
* @return void
*
*/
protected function setUniqueNameKeeper(&$field, &$typeName, &$name, $viewName) {
protected function setUniqueNameKeeper(&$field, &$typeName, &$name, $viewName)
{
// setup a default field
$xml = new SimpleXMLElement($field['settings']->xml);
if (ComponentbuilderHelper::checkArray($field['settings']->properties))
@ -1733,7 +1742,8 @@ class Fields extends Structure {
* @return void
*
*/
protected function setUniqueNameCounter($name, $view) {
protected function setUniqueNameCounter($name, $view)
{
if (!isset($this->uniqueNames[$view]))
{
$this->uniqueNames[$view] = array();
@ -1746,7 +1756,7 @@ class Fields extends Structure {
return;
}
// count how many times the field is used
$this->uniqueNames[$view]['counter'][$name] ++;
$this->uniqueNames[$view]['counter'][$name]++;
return;
}
@ -1759,7 +1769,8 @@ class Fields extends Structure {
* @return string the name
*
*/
protected function uniqueName($name, $view) {
protected function uniqueName($name, $view)
{
// only increment if the field name is used multiple times
if (isset($this->uniqueNames[$view]['counter'][$name]) && $this->uniqueNames[$view]['counter'][$name] > 1)
{
@ -1777,6 +1788,7 @@ class Fields extends Structure {
return $name;
}
/**
* set Builders
*
@ -1795,7 +1807,8 @@ class Fields extends Structure {
* @return void
*
*/
public function setBuilders($langLabel, $langView, $viewName, $listViewName, $name, $view, $field, $typeName, $multiple, $custom = false, $options = false) {
public function setBuilders($langLabel, $langView, $viewName, $listViewName, $name, $view, $field, $typeName, $multiple, $custom = false, $options = false)
{
if ($typeName === 'tag')
{
// set tags for this view but don't load to DB
@ -2103,13 +2116,14 @@ class Fields extends Structure {
$this->setLayoutBuilder($viewName, $tabName, $name, $field);
}
public function setCustomFieldTypeFile($data, $viewName_list, $viewName_single) {
public function setCustomFieldTypeFile($data, $viewName_list, $viewName_single)
{
// make sure it is not already been build
if (!isset($this->fileContentDynamic['customfield_' . $data['type']]) || !ComponentbuilderHelper::checkArray($this->fileContentDynamic['customfield_' . $data['type']]))
if (!isset($this->fileContentDynamic['customfield_'.$data['type']]) || !ComponentbuilderHelper::checkArray($this->fileContentDynamic['customfield_'.$data['type']]))
{
// first build the custom field type file
$target = array('admin' => 'customfield');
$this->buildDynamique($target, 'field' . $data['custom']['extends'], $data['custom']['type']);
$this->buildDynamique($target,'field'.$data['custom']['extends'], $data['custom']['type']);
// set tab and break replacements
$tabBreak = array(
'\t' => "\t",
@ -2120,11 +2134,11 @@ class Fields extends Structure {
'###TABLE###' => $data['custom']['table'],
'###ID###' => $data['custom']['id'],
'###TEXT###' => $data['custom']['text'],
'###CODE_TEXT###' => $data['code'] . '_' . $data['custom']['text'],
'###CODE_TEXT###' => $data['code'].'_'.$data['custom']['text'],
'###CODE###' => $data['code'],
'###component###' => $this->fileContentStatic['###component###'],
'###Component###' => $this->fileContentStatic['###Component###'],
'###view_type###' => $viewName_single . '_' . $data['type'],
'###view_type###' => $viewName_single.'_'.$data['type'],
'###type###' => $data['type'],
'###view###' => $viewName_single,
'###views###' => $viewName_list
@ -2144,7 +2158,7 @@ class Fields extends Structure {
}
else
{
$phpCode .= PHP_EOL . "\t\t" . $this->setPlaceholders($code, $tabBreak);
$phpCode .= PHP_EOL."\t\t".$this->setPlaceholders($code, $tabBreak);
}
}
}
@ -2193,30 +2207,30 @@ class Fields extends Structure {
$phpxCode = 'return null;';
}
// temp holder for name
$tempName = $data['custom']['label'] . ' Group';
$tempName = $data['custom']['label'].' Group';
// set lang
$groupLangName = $this->langPrefix . '_' . ComponentbuilderHelper::safeString($tempName, 'U');
$groupLangName = $this->langPrefix.'_'.ComponentbuilderHelper::safeString($tempName,'U');
// add to lang array
$this->langContent[$this->lang][$groupLangName] = ComponentbuilderHelper::safeString($tempName, 'W');
$this->langContent[$this->lang][$groupLangName] = ComponentbuilderHelper::safeString($tempName,'W');
// build the Group Control
$this->setGroupControl[$data['type']] = $groupLangName;
// ###JFORM_GETGROUPS_PHP### <<<DYNAMIC>>>
$this->fileContentDynamic['customfield_' . $data['type']]['###JFORM_GETGROUPS_PHP###'] = $phpCode;
$this->fileContentDynamic['customfield_'.$data['type']]['###JFORM_GETGROUPS_PHP###'] = $phpCode;
// ###JFORM_GETEXCLUDED_PHP### <<<DYNAMIC>>>
$this->fileContentDynamic['customfield_' . $data['type']]['###JFORM_GETEXCLUDED_PHP###'] = $phpxCode;
$this->fileContentDynamic['customfield_'.$data['type']]['###JFORM_GETEXCLUDED_PHP###'] = $phpxCode;
}
else
{
// ###JFORM_GETOPTIONS_PHP### <<<DYNAMIC>>>
$this->fileContentDynamic['customfield_' . $data['type']]['###JFORM_GETOPTIONS_PHP###'] = $phpCode;
$this->fileContentDynamic['customfield_'.$data['type']]['###JFORM_GETOPTIONS_PHP###'] = $phpCode;
}
// ###Type### <<<DYNAMIC>>>
$this->fileContentDynamic['customfield_' . $data['type']]['###Type###'] = ComponentbuilderHelper::safeString($data['custom']['type'], 'F');
$this->fileContentDynamic['customfield_'.$data['type']]['###Type###'] = ComponentbuilderHelper::safeString($data['custom']['type'],'F');
// ###type### <<<DYNAMIC>>>
$this->fileContentDynamic['customfield_' . $data['type']]['###type###'] = $data['custom']['type'];
$this->fileContentDynamic['customfield_'.$data['type']]['###type###'] = $data['custom']['type'];
// ###type### <<<DYNAMIC>>>
$this->fileContentDynamic['customfield_' . $data['type']]['###ADD_BUTTON###'] = $this->setAddButttonToListField($data['custom']['view'], $data['custom']['views']);
$this->fileContentDynamic['customfield_'.$data['type']]['###ADD_BUTTON###'] = $this->setAddButttonToListField($data['custom']['view'],$data['custom']['views']);
}
}
@ -2229,7 +2243,8 @@ class Fields extends Structure {
* @return boolean if the field was found
*
*/
public function defaultField($type, $option = 'default') {
public function defaultField($type, $option = 'default')
{
// list of default fields
// https://docs.joomla.org/Form_field
$defaults = array(
@ -2271,45 +2286,55 @@ class Fields extends Structure {
return false;
}
public function xmlComment(&$xml,$comment) {
public function xmlComment(&$xml, $comment)
{
$domXML = dom_import_simplexml($xml);
$domComment = new DOMComment($comment);
$nodeTarget = $domXML->ownerDocument->importNode($domComment,true);
$nodeTarget = $domXML->ownerDocument->importNode($domComment, true);
$domXML->appendChild($nodeTarget);
$xml = simplexml_import_dom($domXML);
}
public function xmlAddAttributes(&$xml,$attributes=array()) {
foreach($attributes as $key=>$value) {
$xml->addAttribute($key,$value);
public function xmlAddAttributes(&$xml, $attributes = array())
{
foreach ($attributes as $key => $value)
{
$xml->addAttribute($key, $value);
}
}
public function xmlAppend(&$xml,$node) {
if(!$node) { // element was not returned
public function xmlAppend(&$xml, $node)
{
if (!$node)
{ // element was not returned
return;
}
switch(get_class($node)) {
switch (get_class($node))
{
case 'stdClass':
if(property_exists($node,'comment')) {
$this->xmlComment($xml,$node->comment);
if (property_exists($node, 'comment'))
{
$this->xmlComment($xml, $node->comment);
}
if(property_exists($node,'fieldXML')) {
$this->xmlAppend($xml,$node->fieldXML);
if (property_exists($node, 'fieldXML'))
{
$this->xmlAppend($xml, $node->fieldXML);
}
break;
case 'SimpleXMLElement':
$domXML = dom_import_simplexml($xml);
$domNode = dom_import_simplexml($node);
$domXML->appendChild($domXML->ownerDocument->importNode($domNode,true));
$domXML->appendChild($domXML->ownerDocument->importNode($domNode, true));
$xml = simplexml_import_dom($domXML);
break;
}
}
public function xmlPrettyPrint($xml,$nodename) {
public function xmlPrettyPrint($xml, $nodename)
{
$dom = dom_import_simplexml($xml)->ownerDocument;
$dom->formatOutput = true;
return $dom->saveXML($dom->getElementsByTagName($nodename)->item(0));
}
}