Library manager implementation #195

Merged
Llewellyn merged 24 commits from staging into master 2017-12-12 13:31:16 +00:00
Showing only changes of commit 87ba078dc8 - Show all commits

View File

@ -1,5 +1,4 @@
<?php
/**--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
__ __ _ _____ _ _ __ __ _ _ _
\ \ / / | | | __ \ | | | | | \/ | | | | | | |
@ -37,6 +36,7 @@ class Fields extends Structure
*
* @var array
*/
public $metadataBuilder = array();
/**
@ -873,40 +873,40 @@ class Fields extends Structure
* @param string $name The field name
* @param string $typeName The field type
* @param string $langView The language string of the view
* @param string $viewName The singel view name
* @param string $viewName The single view name
* @param string $listViewName The list view name
* @param array $placeholders The place holder and replace values
* @param string $optionArray The option bucket array used to set the field options if needed.
* @param arra $custom Used when field is from config
* @param array $custom Used when field is from config
*
* @return SimpleXMLElement The field in xml
*
*/
private function setField($setType, &$fieldAttributes, &$name, &$typeName, &$langView, &$viewName, &$listViewName, $placeholders, &$optionArray, $custom = null)
{
$r = new stdClass();
$field = new stdClass();
if ($setType === 'option')
{
// 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') . ". (joomla)";
$field->fieldXML = new SimpleXMLElement('<field/>');
$field->comment = $this->setLine(__LINE__) . " " . ComponentbuilderHelper::safeString($name, 'F') . " Field. Type: " . ComponentbuilderHelper::safeString($typeName, 'F') . ". (joomla)";
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'option')
{
$r->fieldXML->addAttribute($property, $value);
$field->fieldXML->addAttribute($property, $value);
}
elseif ($property === 'option')
{
$this->xmlComment($r->fieldXML, $this->setLine(__LINE__) . " Option Set.");
$this->xmlComment($field->fieldXML, $this->setLine(__LINE__) . " Option Set.");
if (strpos($value, ',') !== false)
{
// mulitpal options
$options = explode(',', $value);
foreach ($options as $option)
{
$optionXML = $r->fieldXML->addChild('option');
$optionXML = $field->fieldXML->addChild('option');
if (strpos($option, '|') !== false)
{
// has other value then text
@ -934,7 +934,7 @@ class Fields extends Structure
else
{
// one option
$optionXML = $r->fieldXML->addChild('option');
$optionXML = $field->fieldXML->addChild('option');
if (strpos($value, '|') !== false)
{
// has other value then text
@ -960,36 +960,36 @@ class Fields extends Structure
}
}
}
if (!$r->fieldXML->count())
if (!$field->fieldXML->count())
{
$this->xmlComment($r->fieldXML, $this->setLine(__LINE__) . " No Manual Options Were Added In Field Settings.");
$this->xmlComment($field->fieldXML, $this->setLine(__LINE__) . " No Manual Options Were Added In Field Settings.");
}
}
elseif ($setType === 'plain')
{
// 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') . ". (joomla)";
$field->fieldXML = new SimpleXMLElement('<field/>');
$field->comment = $this->setLine(__LINE__) . " " . ComponentbuilderHelper::safeString($name, 'F') . " Field. Type: " . ComponentbuilderHelper::safeString($typeName, 'F') . ". (joomla)";
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'option')
{
$r->fieldXML->addAttribute($property, $value);
$field->fieldXML->addAttribute($property, $value);
}
}
}
elseif ($setType === 'spacer')
{
// 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') . ". A None Database Field. (joomla)";
$field->fieldXML = new SimpleXMLElement('<field/>');
$field->comment = $this->setLine(__LINE__) . " " . ComponentbuilderHelper::safeString($name, 'F') . " Field. Type: " . ComponentbuilderHelper::safeString($typeName, 'F') . ". A None Database Field. (joomla)";
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'option')
{
$r->fieldXML->addAttribute($property, $value);
$field->fieldXML->addAttribute($property, $value);
}
}
}
@ -999,17 +999,17 @@ class Fields extends Structure
if ($typeName === 'repeatable')
{
// 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') . ". (joomla)";
$field->fieldXML = new SimpleXMLElement('<field/>');
$field->comment = $this->setLine(__LINE__) . " " . ComponentbuilderHelper::safeString($name, 'F') . " Field. Type: " . ComponentbuilderHelper::safeString($typeName, 'F') . ". (depreciated)";
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'fields')
{
$r->fieldXML->addAttribute($property, $value);
$field->fieldXML->addAttribute($property, $value);
}
}
$fieldsXML = $r->fieldXML->addChild('fields');
$fieldsXML = $field->fieldXML->addChild('fields');
$fieldsXML->addAttribute('name', $fieldAttributes['name'] . '_fields');
$fieldsXML->addAttribute('label', '');
$fieldSetXML = $fieldsXML->addChild('fieldset');
@ -1088,20 +1088,25 @@ class Fields extends Structure
elseif ($typeName === 'subform')
{
// 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') . ". (joomla)";
$field->fieldXML = new SimpleXMLElement('<field/>');
$field->comment = $this->setLine(__LINE__) . " " . ComponentbuilderHelper::safeString($name, 'F') . " Field. Type: " . ComponentbuilderHelper::safeString($typeName, 'F') . ". (joomla)";
// add all properties
foreach ($fieldAttributes as $property => $value)
{
if ($property != 'fields')
if ($property != 'fields' && $property != 'formsource')
{
$r->fieldXML->addAttribute($property, $value);
$field->fieldXML->addAttribute($property, $value);
}
}
// if we do not detect formsource we add the form
if (!isset($fieldAttributes['formsource']))
// if we detect formsource we do not add the form
if (isset($fieldAttributes['formsource']) && ComponentbuilderHelper::checkString($fieldAttributes['formsource']))
{
$form = $r->fieldXML->addChild('form');
$field->fieldXML->addAttribute('formsource', $fieldAttributes['formsource']);
}
// add the form
else
{
$form = $field->fieldXML->addChild('form');
$attributes = array(
'hidden' => 'true',
'name' => 'list_' . $fieldAttributes['name'] . '_modal',
@ -1181,13 +1186,13 @@ class Fields extends Structure
elseif ($setType === 'custom')
{
// 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)";
$field->fieldXML = new SimpleXMLElement('<field/>');
$field->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);
$field->fieldXML->addAttribute($property, $value);
}
}
// incase the field is in the config and has not been set
@ -1201,7 +1206,7 @@ class Fields extends Structure
$this->setCustomFieldTypeFile($data, $listViewName, $viewName);
}
}
return $r;
return $field;
}
/**
@ -1346,7 +1351,7 @@ class Fields extends Structure
*/
private function setFieldAttributes(&$field, &$viewType, &$name, &$typeName, &$multiple, &$langLabel, $langView, &$spacerCounter, $listViewName, $viewName, $placeholders, $repeatable = false)
{
// reset array`
// reset array
$fieldAttributes = array();
$setCustom = false;
// setup joomla default fields
@ -1469,7 +1474,7 @@ class Fields extends Structure
$name = $this->setPlaceholders($xmlValue, $placeholders);
}
}
elseif ($property['name'] === 'extension' || $property['name'] === 'directory')
elseif ($property['name'] === 'extension' || $property['name'] === 'directory' || $property['name'] === 'formsource')
{
$xmlValue = ComponentbuilderHelper::getBetween($field['settings']->xml, $property['name'] . '="', '"');
// replace the placeholders
@ -1487,7 +1492,7 @@ class Fields extends Structure
// set the line number
$phpLine = (int) str_replace('type_phpx_', '', $property['name']);
// load the php for the custom field file
$fieldAttributes['custom']['php'][$phpLine] = ComponentbuilderHelper::getBetween($field['settings']->xml, $property['name'] . '="', '"');
$fieldAttributes['custom']['phpx'][$phpLine] = ComponentbuilderHelper::getBetween($field['settings']->xml, $property['name'] . '="', '"');
}
elseif ($property['name'] === 'extends' && $setCustom)
{
@ -1684,7 +1689,6 @@ class Fields extends Structure
protected function setUniqueNameKeeper(&$field, &$typeName, &$name, $viewName)
{
// setup a default field
$xml = new SimpleXMLElement($field['settings']->xml);
if (ComponentbuilderHelper::checkArray($field['settings']->properties))
{
foreach ($field['settings']->properties as $property)