Library manager implementation #195
@ -362,7 +362,8 @@ class Fields extends Structure {
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
private function setLine($nr) {
|
||||
private function setLine($nr)
|
||||
{
|
||||
if ($this->debugLinenr)
|
||||
{
|
||||
return ' [Fields '.$nr.']';
|
||||
@ -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))
|
||||
{
|
||||
@ -538,7 +540,8 @@ class Fields extends Structure {
|
||||
$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) {
|
||||
foreach (array('JPUBLISHED' => 1, 'JUNPUBLISHED' => 0, 'JARCHIVED' => 2, 'JTRASHED' => -2) as $text => $value)
|
||||
{
|
||||
$optionXML = $fieldXML->addChild('option');
|
||||
$optionXML->addAttribute('value', $value);
|
||||
$optionXML[] = $text;
|
||||
@ -656,7 +659,8 @@ class Fields extends Structure {
|
||||
if (count($dynamicFieldsXML))
|
||||
{
|
||||
$this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Dynamic Fields.");
|
||||
foreach($dynamicFieldsXML as $dynamicfield) {
|
||||
foreach ($dynamicFieldsXML as $dynamicfield)
|
||||
{
|
||||
$this->xmlAppend($fieldSetXML, $dynamicfield);
|
||||
}
|
||||
}
|
||||
@ -687,7 +691,8 @@ class Fields extends Structure {
|
||||
'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[] = $text;
|
||||
@ -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
|
||||
@ -772,12 +779,12 @@ class Fields extends Structure {
|
||||
{
|
||||
// set the array of field names
|
||||
$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')
|
||||
{
|
||||
@ -953,7 +959,8 @@ class Fields extends Structure {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!$r->fieldXML->count()) {
|
||||
if (!$r->fieldXML->count())
|
||||
{
|
||||
$this->xmlComment($r->fieldXML, $this->setLine(__LINE__) . " No Manual Options Were Added In Field Settings.");
|
||||
}
|
||||
}
|
||||
@ -1175,7 +1182,6 @@ 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')
|
||||
@ -1183,7 +1189,6 @@ class Fields extends Structure {
|
||||
$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,7 +1302,8 @@ class Fields extends Structure {
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function buildSiteFieldData($view, $field, $set, $type) {
|
||||
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]))
|
||||
@ -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();
|
||||
@ -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,7 +2116,8 @@ 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']]))
|
||||
{
|
||||
@ -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,7 +2286,8 @@ 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);
|
||||
@ -2279,22 +2295,29 @@ class Fields extends Structure {
|
||||
$xml = simplexml_import_dom($domXML);
|
||||
}
|
||||
|
||||
public function xmlAddAttributes(&$xml,$attributes=array()) {
|
||||
foreach($attributes as $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')) {
|
||||
if (property_exists($node, 'comment'))
|
||||
{
|
||||
$this->xmlComment($xml, $node->comment);
|
||||
}
|
||||
if(property_exists($node,'fieldXML')) {
|
||||
if (property_exists($node, 'fieldXML'))
|
||||
{
|
||||
$this->xmlAppend($xml, $node->fieldXML);
|
||||
}
|
||||
break;
|
||||
@ -2307,9 +2330,11 @@ class Fields extends Structure {
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user