Library manager implementation #195

Merged
Llewellyn merged 24 commits from staging into master 2017-12-12 13:31:16 +00:00
2 changed files with 489 additions and 307 deletions
Showing only changes of commit b60d208d9e - Show all commits

View File

@ -1,5 +1,4 @@
<?php
/**--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
__ __ _ _____ _ _ __ __ _ _ _
\ \ / / | | | __ \ | | | | | \/ | | | | | | |
@ -413,10 +412,11 @@ class Fields extends Structure
$this->accessBuilder[$viewName] = $viewName;
}
// set the read only
$readOnly = "";
$readOnlyXML = array();
if ($view['settings']->type == 2)
{
$readOnly = "\t\t\t" . 'readonly="true"' . PHP_EOL."\t\t\t" . 'disabled="true"';
$readOnlyXML['readonly'] = true;
$readOnlyXML['disabled'] = true;
}
// main lang prefix
$langView = $this->langPrefix . '_' . $this->placeholders['###VIEW###'];
@ -468,209 +468,266 @@ class Fields extends Structure
$this->setUniqueNameKeeper($field, $view['settings']->type, $name, $viewName);
}
// start adding dynamc fields
$dynamcfields = '';
$dynamicFieldsXML = array();
$spacerCounter = 'a';
// set the custom table key
$dbkey = 'g';
// TODO we should add the global and local view switch if field for front end
foreach ($view['settings']->fields as $field)
{
$dynamcfields .= $this->setDynamicField($field, $view, $view['settings']->type, $langView, $viewName, $listViewName, $spacerCounter, $this->placeholders, $dbkey, true);
$dynamicFieldsXML[] = $this->setDynamicField($field, $view, $view['settings']->type, $langView, $viewName, $listViewName, $spacerCounter, $this->placeholders, $dbkey, true);
}
// set the defautl fields
$fieldSet = array();
$fieldSet[] = '<fieldset name="details">';
$fieldSet[] = "\t\t<!--" . $this->setLine(__LINE__) . " Default Fields. -->";
$fieldSet[] = "\t\t<!--" . $this->setLine(__LINE__) . " Id Field. Type: Text (joomla) -->";
// 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)");
// if id is not set
if (!isset($this->fieldsNames[$viewName]['id']))
{
$fieldSet[] = "\t\t<field";
$fieldSet[] = "\t\t\tname=" . '"id"';
$fieldSet[] = "\t\t\t" . 'type="text" class="readonly" label="JGLOBAL_FIELD_ID_LABEL"';
$fieldSet[] = "\t\t\t" . 'description ="JGLOBAL_FIELD_ID_DESC" size="10" default="0"';
$fieldSet[] = "\t\t\t" . 'readonly="true"';
$fieldSet[] = "\t\t/>";
$attributes = array(
'name' => 'id',
'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);
}
// if created is not set
if (!isset($this->fieldsNames[$viewName]['created']))
{
$fieldSet[] = "\t\t<!--" . $this->setLine(__LINE__) . " Date Created Field. Type: Calendar (joomla) -->";
$fieldSet[] = "\t\t<field";
$fieldSet[] = "\t\t\tname=" . '"created"';
$fieldSet[] = "\t\t\ttype=" . '"calendar"';
$fieldSet[] = "\t\t\tlabel=" . '"' . $langView . '_CREATED_DATE_LABEL"';
$fieldSet[] = "\t\t\tdescription=" . '"' . $langView . '_CREATED_DATE_DESC"';
$fieldSet[] = "\t\t\tsize=" . '"22"';
$fieldSet[] = $readOnly;
$fieldSet[] = "\t\t\tformat=" . '"%Y-%m-%d %H:%M:%S"';
$fieldSet[] = "\t\t\tfilter=" . '"user_utc"';
$fieldSet[] = "\t\t/>";
$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'
);
$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);
}
// if created_by is not set
if (!isset($this->fieldsNames[$viewName]['created_by']))
{
$fieldSet[] = "\t\t<!--" . $this->setLine(__LINE__) . " User Created Field. Type: User (joomla) -->";
$fieldSet[] = "\t\t<field";
$fieldSet[] = "\t\t\tname=" . '"created_by"';
$fieldSet[] = "\t\t\ttype=" . '"user"';
$fieldSet[] = "\t\t\tlabel=" . '"' . $langView . '_CREATED_BY_LABEL"';
$fieldSet[] = $readOnly;
$fieldSet[] = "\t\t\tdescription=" . '"' . $langView . '_CREATED_BY_DESC"';
$fieldSet[] = "\t\t/>";
$attributes = array(
'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)");
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML, $attributes);
}
// if published is not set
if (!isset($this->fieldsNames[$viewName]['published']))
{
$fieldSet[] = "\t\t<!--" . $this->setLine(__LINE__) . " Published Field. Type: List (joomla) -->";
$fieldSet[] = "\t\t<field name=" . '"published" type="list" label="JSTATUS"';
$fieldSet[] = "\t\t\tdescription=" . '"JFIELD_PUBLISHED_DESC" class="chzn-color-state"';
$fieldSet[] = $readOnly;
$fieldSet[] = "\t\t\tfilter=" . '"intval" size="1" default="1" >';
$fieldSet[] = "\t\t\t<option value=" . '"1">';
$fieldSet[] = "\t\t\t\tJPUBLISHED</option>";
$fieldSet[] = "\t\t\t<option value=" . '"0">';
$fieldSet[] = "\t\t\t\tJUNPUBLISHED</option>";
$fieldSet[] = "\t\t\t<option value=" . '"2">';
$fieldSet[] = "\t\t\t\tJARCHIVED</option>";
$fieldSet[] = "\t\t\t<option value=" . '"-2">';
$fieldSet[] = "\t\t\t\tJTRASHED</option>";
$fieldSet[] = "\t\t</field>";
$attributes = array(
'name' => 'published',
'type' => 'list',
'label' => 'JSTATUS'
);
$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)
{
$optionXML = $fieldXML->addChild('option');
$optionXML->addAttribute('value', $value);
$optionXML[] = $text;
}
}
// if modified is not set
if (!isset($this->fieldsNames[$viewName]['modified']))
{
$fieldSet[] = "\t\t<!--" . $this->setLine(__LINE__) . " Date Modified Field. Type: Calendar (joomla) -->";
$fieldSet[] = "\t\t" . '<field name="modified" type="calendar" class="readonly"';
$fieldSet[] = "\t\t\t" . 'label="' . $langView . '_MODIFIED_DATE_LABEL" description="' . $langView . '_MODIFIED_DATE_DESC"';
$fieldSet[] = "\t\t\t" . 'size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />';
$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'
);
$this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Date Modified Field. Type: Calendar (joomla)");
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML, $attributes);
}
// if modified_by is not set
if (!isset($this->fieldsNames[$viewName]['modified_by']))
{
$fieldSet[] = "\t\t<!--" . $this->setLine(__LINE__) . " User Modified Field. Type: User (joomla) -->";
$fieldSet[] = "\t\t" . '<field name="modified_by" type="user"';
$fieldSet[] = "\t\t\t" . 'label="' . $langView . '_MODIFIED_BY_LABEL"';
$fieldSet[] = "\t\t\tdescription=" . '"' . $langView . '_MODIFIED_BY_DESC"';
$fieldSet[] = "\t\t\t" . 'class="readonly"';
$fieldSet[] = "\t\t\t" . 'readonly="true"';
$fieldSet[] = "\t\t\t" . 'filter="unset"';
$fieldSet[] = "\t\t/>";
$attributes = array(
'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)");
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML, $attributes);
}
// check if view has access
if (isset($this->accessBuilder[$viewName]) && ComponentbuilderHelper::checkString($this->accessBuilder[$viewName]) && !isset($this->fieldsNames[$viewName]['access']))
{
$fieldSet[] = "\t\t<!--" . $this->setLine(__LINE__) . " Access Field. Type: Accesslevel (joomla) -->";
$fieldSet[] = "\t\t" . '<field name="access"';
$fieldSet[] = "\t\t\t" . 'type="accesslevel"';
$fieldSet[] = "\t\t\t" . 'label="JFIELD_ACCESS_LABEL"';
$fieldSet[] = "\t\t\t" . 'description="JFIELD_ACCESS_DESC"';
$fieldSet[] = "\t\t\t" . 'default="1"';
$fieldSet[] = $readOnly;
$fieldSet[] = "\t\t\t" . 'required="false"';
$fieldSet[] = "\t\t/>";
$attributes = array(
'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)");
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML, $attributes);
}
// if ordering is not set
if (!isset($this->fieldsNames[$viewName]['ordering']))
{
$fieldSet[] = "\t\t<!--" . $this->setLine(__LINE__) . " Ordering Field. Type: Numbers (joomla) -->";
$fieldSet[] = "\t\t<field";
$fieldSet[] = "\t\t\t" . 'name="ordering"';
$fieldSet[] = "\t\t\t" . 'type="number"';
$fieldSet[] = "\t\t\t" . 'class="inputbox validate-ordering"';
$fieldSet[] = "\t\t\t" . 'label="' . $langView . '_ORDERING_LABEL' . '"';
$fieldSet[] = "\t\t\t" . 'description=""';
$fieldSet[] = "\t\t\t" . 'default="0"';
$fieldSet[] = "\t\t\t" . 'size="6"';
$fieldSet[] = $readOnly;
$fieldSet[] = "\t\t\t" . 'required="false"';
$fieldSet[] = "\t\t/>";
$attributes = array(
'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)");
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML, $attributes);
}
// if version is not set
if (!isset($this->fieldsNames[$viewName]['version']))
{
$fieldSet[] = "\t\t<!--" . $this->setLine(__LINE__) . " Version Field. Type: Text (joomla) -->";
$fieldSet[] = "\t\t<field";
$fieldSet[] = "\t\t\t" . 'name="version"';
$fieldSet[] = "\t\t\t" . 'type="text"';
$fieldSet[] = "\t\t\t" . 'class="readonly"';
$fieldSet[] = "\t\t\t" . 'label="' . $langView . '_VERSION_LABEL"';
$fieldSet[] = "\t\t\t" . 'description="' . $langView . '_VERSION_DESC"';
$fieldSet[] = "\t\t\t" . 'size="6"';
$fieldSet[] = "\t\t\t" . 'readonly="true"';
$fieldSet[] = "\t\t\t" . 'filter="unset"';
$fieldSet[] = "\t\t/>";
$attributes = array(
'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)");
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML, $attributes);
}
// check if metadata is added to this view
if (isset($this->metadataBuilder[$viewName]) && ComponentbuilderHelper::checkString($this->metadataBuilder[$viewName]))
{
// metakey
$fieldSet[] = "\t\t<!--" . $this->setLine(__LINE__) . " Metakey Field. Type: Textarea (joomla) -->";
$fieldSet[] = "\t\t<field";
$fieldSet[] = "\t\t\t" . 'name="metakey"';
$fieldSet[] = "\t\t\t" . 'type="textarea"';
$fieldSet[] = "\t\t\t" . 'label="JFIELD_META_KEYWORDS_LABEL"';
$fieldSet[] = "\t\t\t" . 'description="JFIELD_META_KEYWORDS_DESC"';
$fieldSet[] = "\t\t\t" . 'rows="3"';
$fieldSet[] = "\t\t\t" . 'cols="30"';
$fieldSet[] = "\t\t/>";
$attributes = array(
'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)");
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML, $attributes);
// metadesc
$fieldSet[] = "\t\t<!--" . $this->setLine(__LINE__) . " Metadesc Field. Type: Textarea (joomla) -->";
$fieldSet[] = "\t\t<field";
$fieldSet[] = "\t\t\t" . 'name="metadesc"';
$fieldSet[] = "\t\t\t" . 'type="textarea"';
$fieldSet[] = "\t\t\t" . 'label="JFIELD_META_DESCRIPTION_LABEL"';
$fieldSet[] = "\t\t\t" . 'description="JFIELD_META_DESCRIPTION_DESC"';
$fieldSet[] = "\t\t\t" . 'rows="3"';
$fieldSet[] = "\t\t\t" . 'cols="30"';
$fieldSet[] = "\t\t/>";
$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)");
$fieldXML = $fieldSetXML->addChild('field');
$this->xmlAddAttributes($fieldXML, $attributes);
}
// load the dynamic fields now
if (ComponentbuilderHelper::checkString($dynamcfields))
if (count($dynamicFieldsXML))
{
$fieldSet[] = "\t\t<!--" . $this->setLine(__LINE__) . " Dynamic Fields. -->" . $dynamcfields;
$this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Dynamic Fields.");
foreach ($dynamicFieldsXML as $dynamicfield)
{
$this->xmlAppend($fieldSetXML, $dynamicfield);
}
}
// close fieldset
$fieldSet[] = "\t</fieldset>";
// check if metadata is added to this view
if (isset($this->metadataBuilder[$viewName]) && ComponentbuilderHelper::checkString($this->metadataBuilder[$viewName]))
{
$fieldSet[] = PHP_EOL."\t<!--" . $this->setLine(__LINE__) . " Metadata Fields. -->";
$fieldSet[] = "\t<fields" . ' name="metadata" label="JGLOBAL_FIELDSET_METADATA_OPTIONS">';
$fieldSet[] = "\t\t" . '<fieldset name="vdmmetadata"';
$fieldSet[] = "\t\t\t" . 'label="JGLOBAL_FIELDSET_METADATA_OPTIONS">';
$this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Metadata Fields");
$fieldsXML = $fieldSetXML->addChild('fields');
$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');
// robots
$fieldSet[] = "\t\t\t<!--" . $this->setLine(__LINE__) . " Robots Field. Type: List (joomla) -->";
$fieldSet[] = "\t\t\t" . '<field name="robots"';
$fieldSet[] = "\t\t\t\t" . 'type="list"';
$fieldSet[] = "\t\t\t\t" . 'label="JFIELD_METADATA_ROBOTS_LABEL"';
$fieldSet[] = "\t\t\t\t" . 'description="JFIELD_METADATA_ROBOTS_DESC" >';
$fieldSet[] = "\t\t\t\t" . '<option value="">JGLOBAL_USE_GLOBAL</option>';
$fieldSet[] = "\t\t\t\t" . '<option value="index, follow">JGLOBAL_INDEX_FOLLOW</option>';
$fieldSet[] = "\t\t\t\t" . '<option value="noindex, follow">JGLOBAL_NOINDEX_FOLLOW</option>';
$fieldSet[] = "\t\t\t\t" . '<option value="index, nofollow">JGLOBAL_INDEX_NOFOLLOW</option>';
$fieldSet[] = "\t\t\t\t" . '<option value="noindex, nofollow">JGLOBAL_NOINDEX_NOFOLLOW</option>';
$fieldSet[] = "\t\t\t" . '</field>';
$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'
);
$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',
);
foreach ($options as $text => $value)
{
$option = $robots->addChild('option');
$option->addAttribute('value', $value);
$option[] = $text;
}
// author
$fieldSet[] = "\t\t\t<!--" . $this->setLine(__LINE__) . " Author Field. Type: Text (joomla) -->";
$fieldSet[] = "\t\t\t" . '<field name="author"';
$fieldSet[] = "\t\t\t\t" . 'type="text"';
$fieldSet[] = "\t\t\t\t" . 'label="JAUTHOR" description="JFIELD_METADATA_AUTHOR_DESC"';
$fieldSet[] = "\t\t\t\t" . 'size="20"';
$fieldSet[] = "\t\t\t/>";
$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
);
$this->xmlAddAttributes($author, $attributes);
// rights
$fieldSet[] = "\t\t\t<!--" . $this->setLine(__LINE__) . " Rights Field. Type: Textarea (joomla) -->";
$fieldSet[] = "\t\t\t" . '<field name="rights" type="textarea" label="JFIELD_META_RIGHTS_LABEL"';
$fieldSet[] = "\t\t\t\t" . 'description="JFIELD_META_RIGHTS_DESC" required="false" filter="string"';
$fieldSet[] = "\t\t\t\t" . 'cols="30" rows="2"';
$fieldSet[] = "\t\t\t/>";
$fieldSet[] = "\t\t</fieldset>";
$fieldSet[] = "\t</fields>";
$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
);
$this->xmlAddAttributes($rights, $attributes);
}
// just to be safe, lets clear the view placeholders
$this->clearFromPlaceHolders('view');
// retunr the set
return implode(PHP_EOL, $fieldSet);
// return the set
return $this->xmlPrettyPrint($XML, 'fieldset');
}
return '';
}
@ -702,7 +759,7 @@ 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)
@ -714,7 +771,6 @@ class Fields extends Structure
$typeName = ComponentbuilderHelper::safeString($field['settings']->type_name);
$multiple = false;
$langLabel = '';
$taber = '';
$fieldSet = '';
$fieldAttributes = array();
// set field attributes
@ -730,7 +786,7 @@ class Fields extends Structure
//reset options array
$optionArray = array();
// now add to the field set
$fieldSet .= $this->setField('option', $taber, $fieldAttributes, $name, $typeName, $langView, $viewName, $listViewName, $placeholders, $optionArray);
$xmlElement = $this->setField('option', $fieldAttributes, $name, $typeName, $langView, $viewName, $listViewName, $placeholders, $optionArray);
if ($build)
{
// set builders
@ -745,7 +801,7 @@ class Fields extends Structure
$this->setBuilders($langLabel, $langView, $viewName, $listViewName, $name, $view, $field, $typeName, $multiple);
}
// now add to the field set
$fieldSet .= $this->setField('plain', $taber, $fieldAttributes, $name, $typeName, $langView, $viewName, $listViewName, $placeholders, $optionArray);
$xmlElement = $this->setField('plain', $fieldAttributes, $name, $typeName, $langView, $viewName, $listViewName, $placeholders, $optionArray);
}
elseif ($this->defaultField($typeName, 'spacer'))
{
@ -765,7 +821,7 @@ class Fields extends Structure
$this->setLayoutBuilder($viewName, $tabName, $name, $field);
}
// now add to the field set
$fieldSet .= $this->setField('spacer', $taber, $fieldAttributes, $name, $typeName, $langView, $viewName, $listViewName, $placeholders, $optionArray);
$xmlElement = $this->setField('spacer', $fieldAttributes, $name, $typeName, $langView, $viewName, $listViewName, $placeholders, $optionArray);
// increment spacer counter
if ($typeName === 'spacer')
{
@ -783,7 +839,7 @@ class Fields extends Structure
$this->setBuilders($langLabel, $langView, $viewName, $listViewName, $name, $view, $field, $typeName, $multiple, false);
}
// now add to the field set
$fieldSet .= $this->setField('special', $taber, $fieldAttributes, $name, $typeName, $langView, $viewName, $listViewName, $placeholders, $optionArray);
$xmlElement = $this->setField('special', $fieldAttributes, $name, $typeName, $langView, $viewName, $listViewName, $placeholders, $optionArray);
}
}
elseif (ComponentbuilderHelper::checkArray($fieldAttributes['custom']))
@ -801,56 +857,56 @@ class Fields extends Structure
$this->setBuilders($langLabel, $langView, $viewName, $listViewName, $name, $view, $field, $typeName, $multiple, $custom);
}
// now add to the field set
$fieldSet .= $this->setField('custom', $taber, $fieldAttributes, $name, $typeName, $langView, $viewName, $listViewName, $placeholders, $optionArray, $custom);
$xmlElement = $this->setField('custom', $fieldAttributes, $name, $typeName, $langView, $viewName, $listViewName, $placeholders, $optionArray, $custom);
}
}
return $fieldSet;
return $xmlElement;
}
return '';
return false;
}
/**
* set a field
*
* @param string $setType The set of fields type
* @param string $taber The tabs to add in layout
* @param array $fieldAttributes The field values
* @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 string The field in xml
* @return SimpleXMLElement The field in xml
*
*/
private function setField($setType, $taber, &$fieldAttributes, &$name, &$typeName, &$langView, &$viewName, &$listViewName, $placeholders, &$optionArray, $custom = null)
private function setField($setType, &$fieldAttributes, &$name, &$typeName, &$langView, &$viewName, &$listViewName, $placeholders, &$optionArray, $custom = null)
{
$fieldSet = '';
$field = new stdClass();
if ($setType === 'option')
{
// now add to the field set
$fieldSet .= PHP_EOL."\t" . $taber . "\t<!--" . $this->setLine(__LINE__) . " " . ComponentbuilderHelper::safeString($name, 'F') . " Field. Type: " . ComponentbuilderHelper::safeString($typeName, 'F') . ". (joomla) -->";
$fieldSet .= PHP_EOL."\t" . $taber . "\t<field";
$optionSet = '';
$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')
{
$fieldSet .= PHP_EOL."\t\t" . $taber . "\t" . $property . '="' . $value . '"';
$field->fieldXML->addAttribute($property, $value);
}
elseif ($property === 'option')
{
$optionSet = '';
$this->xmlComment($field->fieldXML, $this->setLine(__LINE__) . " Option Set.");
if (strpos($value, ',') !== false)
{
// mulitpal options
$options = explode(',', $value);
foreach ($options as $option)
{
$optionXML = $field->fieldXML->addChild('option');
if (strpos($option, '|') !== false)
{
// has other value then text
@ -859,7 +915,7 @@ class Fields extends Structure
// add to lang array
$this->langContent[$this->lang][$langValue] = $t;
// no add to option set
$optionSet .= PHP_EOL."\t" . $taber . "\t\t" . '<option value="' . $v . '">' . PHP_EOL."\t" . $taber . "\t\t\t" . $langValue . '</option>';
$optionXML->addAttribute('value', $v);
$optionArray[$v] = $langValue;
}
else
@ -869,14 +925,16 @@ class Fields extends Structure
// add to lang array
$this->langContent[$this->lang][$langValue] = $option;
// no add to option set
$optionSet .= PHP_EOL."\t\t" . $taber . "\t" . '<option value="' . $option . '">' . PHP_EOL."\t\t" . $taber . "\t\t" . $langValue . '</option>';
$optionXML->addAttribute('value', $option);
$optionArray[$option] = $langValue;
}
$optionXML[] = $langValue;
}
}
else
{
// one option
$optionXML = $field->fieldXML->addChild('option');
if (strpos($value, '|') !== false)
{
// has other value then text
@ -885,7 +943,7 @@ class Fields extends Structure
// add to lang array
$this->langContent[$this->lang][$langValue] = $t;
// no add to option set
$optionSet .= PHP_EOL."\t\t" . $taber . "\t" . '<option value="' . $v . '">' . PHP_EOL."\t\t" . $taber . "\t\t" . $langValue . '</option>';
$optionXML->addAttribute('value', $v);
$optionArray[$v] = $langValue;
}
else
@ -895,58 +953,45 @@ class Fields extends Structure
// add to lang array
$this->langContent[$this->lang][$langValue] = $value;
// no add to option set
$optionSet .= PHP_EOL."\t\t" . $taber . "\t" . '<option value="' . $value . '">' . PHP_EOL."\t\t" . $taber . "\t\t" . $langValue . '</option>';
$optionXML->addAttribute('value', $value);
$optionArray[$value] = $langValue;
}
$optionXML[] = $langValue;
}
}
}
if (ComponentbuilderHelper::checkString($optionSet))
if (!$field->fieldXML->count())
{
$fieldSet .= '>';
$fieldSet .= PHP_EOL."\t\t\t" . $taber . "<!--" . $this->setLine(__LINE__) . " Option Set. -->";
$fieldSet .= $optionSet;
$fieldSet .= PHP_EOL."\t\t" . $taber . "</field>";
}
elseif ($typeName === 'sql')
{
$optionArray = false;
$fieldSet .= PHP_EOL."\t\t" . $taber . "/>";
}
else
{
$optionArray = false;
$fieldSet .= PHP_EOL."\t\t\t" . $taber . "<!--" . $this->setLine(__LINE__) . " No Manual Options Were Added In Field Settings. -->";
$fieldSet .= PHP_EOL."\t\t" . $taber . "/>";
$this->xmlComment($field->fieldXML, $this->setLine(__LINE__) . " No Manual Options Were Added In Field Settings.");
}
}
elseif ($setType === 'plain')
{
// now add to the field set
$fieldSet .= PHP_EOL."\t\t" . $taber . "<!--" . $this->setLine(__LINE__) . " " . ComponentbuilderHelper::safeString($name, 'F') . " Field. Type: " . ComponentbuilderHelper::safeString($typeName, 'F') . ". (joomla) -->";
$fieldSet .= PHP_EOL."\t\t" . $taber . "<field";
$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')
{
$fieldSet .= PHP_EOL."\t\t" . $taber . "\t" . $property . '="' . $value . '"';
$field->fieldXML->addAttribute($property, $value);
}
}
$fieldSet .= PHP_EOL."\t\t" . $taber . "/>";
}
elseif ($setType === 'spacer')
{
// now add to the field set
$fieldSet .= PHP_EOL."\t\t<!--" . $this->setLine(__LINE__) . " " . ComponentbuilderHelper::safeString($name, 'F') . " Field. Type: " . ComponentbuilderHelper::safeString($typeName, 'F') . ". A None Database Field. (joomla) -->";
$fieldSet .= PHP_EOL."\t\t<field";
$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')
{
$fieldSet .= " " . $property . '="' . $value . '"';
$field->fieldXML->addAttribute($property, $value);
}
}
$fieldSet .= " />";
}
elseif ($setType === 'special')
{
@ -954,19 +999,24 @@ class Fields extends Structure
if ($typeName === 'repeatable')
{
// now add to the field set
$fieldSet .= PHP_EOL."\t\t<!--" . $this->setLine(__LINE__) . " " . ComponentbuilderHelper::safeString($name, 'F') . " Field. Type: " . ComponentbuilderHelper::safeString($typeName, 'F') . ". (joomla) -->";
$fieldSet .= PHP_EOL."\t\t<field";
$fieldsSet = array();
$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')
{
$fieldSet .= PHP_EOL."\t\t\t" . $property . '="' . $value . '"';
$field->fieldXML->addAttribute($property, $value);
}
}
$fieldSet .= ">";
$fieldSet .= PHP_EOL."\t\t\t" . '<fields name="' . $fieldAttributes['name'] . '_fields" label="">';
$fieldSet .= PHP_EOL."\t\t\t\t" . '<fieldset hidden="true" name="' . $fieldAttributes['name'] . '_modal" repeat="true">';
$fieldsXML = $field->fieldXML->addChild('fields');
$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');
if (strpos($fieldAttributes['fields'], ',') !== false)
{
// mulitpal fields
@ -991,8 +1041,6 @@ class Fields extends Structure
$r_typeName = ComponentbuilderHelper::safeString($fieldData['settings']->type_name);
$r_multiple = false;
$r_langLabel = '';
// add the tabs needed
$taber = "\t\t\t";
// get field values
$r_fieldValues = $this->setFieldAttributes($fieldData, $view, $r_name, $r_typeName, $r_multiple, $r_langLabel, $langView, $spacerCounter, $listViewName, $viewName, $placeholders, true);
// check if values were set
@ -1003,12 +1051,12 @@ class Fields extends Structure
if ($this->defaultField($r_typeName, 'option'))
{
// now add to the field set
$fieldSet .= $this->setField('option', $taber, $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
$fieldSet .= $this->setField('plain', $taber, $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']))
{
@ -1016,7 +1064,7 @@ class Fields extends Structure
$custom = $r_fieldValues['custom'];
unset($r_fieldValues['custom']);
// now add to the field set
$fieldSet .= $this->setField('custom', $taber, $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
@ -1035,37 +1083,40 @@ class Fields extends Structure
}
}
}
$fieldSet .= PHP_EOL."\t\t\t\t</fieldset>";
$fieldSet .= PHP_EOL."\t\t\t</fields>";
$fieldSet .= PHP_EOL."\t\t</field>";
}
// set the subform fields (it is a repeatable without the modal)
elseif ($typeName === 'subform')
{
// now add to the field set
$fieldSet .= PHP_EOL."\t\t<!--" . $this->setLine(__LINE__) . " " . ComponentbuilderHelper::safeString($name, 'F') . " Field. Type: " . ComponentbuilderHelper::safeString($typeName, 'F') . ". (joomla) -->";
$fieldSet .= PHP_EOL."\t\t<field";
$fieldsSet = array();
$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' && $property != 'formsource')
{
$fieldSet .= PHP_EOL."\t\t\t" . $property . '="' . $value . '"';
$field->fieldXML->addAttribute($property, $value);
}
}
// if we detect formsource we do not add the form
if (isset($fieldAttributes['formsource']) && ComponentbuilderHelper::checkString($fieldAttributes['formsource']))
{
$fieldSet .= PHP_EOL."\t\t\tformsource". '="' . $fieldAttributes['formsource'] . '"';
$fieldSet .= PHP_EOL."\t\t />";
$field->fieldXML->addAttribute('formsource', $fieldAttributes['formsource']);
}
// add the form
else
{
$fieldSet .= ">";
$fieldSet .= PHP_EOL."\t\t\t" . '<form hidden="true" name="list_' . $fieldAttributes['name'] . '_modal" repeat="true">';
$form = $field->fieldXML->addChild('form');
$attributes = array(
'hidden' => 'true',
'name' => 'list_' . $fieldAttributes['name'] . '_modal',
'repeat' => 'true'
);
$this->xmlAddAttributes($form, $attributes);
if (strpos($fieldAttributes['fields'], ',') !== false)
{
// mulitpal fields
// multiple fields
$fieldsSets = (array) explode(',', $fieldAttributes['fields']);
}
elseif (is_numeric($fieldAttributes['fields']))
@ -1087,8 +1138,6 @@ class Fields extends Structure
$r_typeName = ComponentbuilderHelper::safeString($fieldData['settings']->type_name);
$r_multiple = false;
$r_langLabel = '';
// add the tabs needed
$taber = "\t\t";
// get field values
$r_fieldValues = $this->setFieldAttributes($fieldData, $view, $r_name, $r_typeName, $r_multiple, $r_langLabel, $langView, $spacerCounter, $listViewName, $viewName, $placeholders, true);
// check if values were set
@ -1099,12 +1148,12 @@ class Fields extends Structure
if ($this->defaultField($r_typeName, 'option'))
{
// now add to the field set
$fieldSet .= $this->setField('option', $taber, $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
$fieldSet .= $this->setField('plain', $taber, $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']))
{
@ -1112,7 +1161,7 @@ class Fields extends Structure
$custom = $r_fieldValues['custom'];
unset($r_fieldValues['custom']);
// now add to the field set
$fieldSet .= $this->setField('custom', $taber, $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
@ -1131,24 +1180,21 @@ class Fields extends Structure
}
}
}
$fieldSet .= PHP_EOL."\t\t\t</form>";
$fieldSet .= PHP_EOL."\t\t</field>";
}
}
}
elseif ($setType === 'custom')
{
// now add to the field set
$fieldSet .= PHP_EOL."\t\t" . $taber . "<!--" . $this->setLine(__LINE__) . " " . ComponentbuilderHelper::safeString($name, 'F') . " Field. Type: " . ComponentbuilderHelper::safeString($typeName, 'F') . ". (custom) -->";
$fieldSet .= PHP_EOL."\t\t" . $taber . "<field";
$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')
{
$fieldSet .= PHP_EOL."\t\t" . $taber . "\t" . $property . '="' . $value . '"';
$field->fieldXML->addAttribute($property, $value);
}
}
$fieldSet .= PHP_EOL."\t\t" . $taber . "/>";
// incase the field is in the config and has not been set
if ('config' === $viewName && 'configs' === $listViewName)
{
@ -1160,7 +1206,7 @@ class Fields extends Structure
$this->setCustomFieldTypeFile($data, $listViewName, $viewName);
}
}
return $fieldSet;
return $field;
}
/**
@ -1305,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
@ -1537,7 +1583,7 @@ class Fields extends Structure
// check if translatable
if (ComponentbuilderHelper::checkString($xmlValue) && isset($property['translatable']) && $property['translatable'] == 1)
{
// update lable if field use multiple times
// update label if field use multiple times
if ($property['name'] === 'label')
{
if (isset($fieldAttributes['name']) && isset($this->uniqueNames[$viewName]['names'][$fieldAttributes['name']]))
@ -2244,4 +2290,121 @@ class Fields extends Structure
return false;
}
/**
* xmlComment
*
* @param SimpleXMLElement $xml The XML element reference in which to inject a comment
* @param string $comment The comment to inject
*
* @return null
*
*/
public function xmlComment(&$xml, $comment)
{
$domXML = dom_import_simplexml($xml);
$domComment = new DOMComment($comment);
$nodeTarget = $domXML->ownerDocument->importNode($domComment, true);
$domXML->appendChild($nodeTarget);
$xml = simplexml_import_dom($domXML);
}
/**
* xmlAddAttributes
*
* @param SimpleXMLElement $xml The XML element reference in which to inject a comment
* @param array $attributes The attributes to apply to the XML element
*
* @return null
*
*/
public function xmlAddAttributes(&$xml, $attributes = array())
{
foreach ($attributes as $key => $value)
{
$xml->addAttribute($key, $value);
}
}
/**
* xmlAppend
*
* @param SimpleXMLElement $xml The XML element reference in which to inject a comment
* @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement
*
* @return null
*
*/
public function xmlAppend(&$xml, $node)
{
if (!$node)
{ // element was not returned
return;
}
switch (get_class($node))
{
case 'stdClass':
if (property_exists($node, 'comment'))
{
$this->xmlComment($xml, $node->comment);
}
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));
$xml = simplexml_import_dom($domXML);
break;
}
}
/**
* xmlPrettyPrint
*
* @param SimpleXMLElement $xml The XML element containing a node to be output
* @param string $nodename node name of the input xml element to print out. this is done to omit the <?xml... tag
*
* @return string XML output
*
*/
public function xmlPrettyPrint($xml, $nodename)
{
$dom = dom_import_simplexml($xml)->ownerDocument;
$dom->formatOutput = true;
$xmlString = $dom->saveXML($dom->getElementsByTagName($nodename)->item(0));
$tidy = new Tidy();
$tidy->parseString($xmlString,array('indent'=>true,'indent-spaces'=>8,'input-xml'=>true,'output-xml'=>true,'indent-attributes'=>true,'wrap-attributes'=>true,'wrap'=>false));
$tidy->cleanRepair();
return $this->xmlIndent((string)$tidy,' ',8,true,false);
}
/**
* xmlIndent
*
* @param string $string The XML input
* @param string $char Character or characters to use as the repeated indent
* @param integer $depth number of times to repeat the indent character
* @param boolean $skipfirst Skip the first line of the input.
* @param boolean $skiplast Skip the last line of the input;
*
* @return string XML output
*
*/
public function xmlIndent($string,$char=' ',$depth=0,$skipfirst=false,$skiplast=false)
{
$output = array();
$lines = explode("\n",$string);
$first = true;
$last = count($lines)-1;
foreach($lines as $i=>$line)
{
$output[] = (($first&&$skipfirst)||$i===$last&&$skiplast)?$line:str_repeat($char,$depth).$line;
$first = false;
}
return implode("\n",$output);
}
}

View File

@ -1653,13 +1653,19 @@ class Interpretation extends Fields
public function setCustomViewFieldUikitChecker(&$get, $checker, $string, $code, $tab = '')
{
$fieldUikit = '';
$runplugins = false;
foreach ($checker as $field => $array)
{
if (strpos($get['selection']['select'], $field) !== false)
{
// build decoder string
$fieldUikit .= PHP_EOL."\t".$tab."\t//".$this->setLine(__LINE__)." Make sure the content prepare plugins fire on ".$field." (TODO)";
$fieldUikit .= PHP_EOL."\t".$tab."\t".$string."->".$field." = JHtml::_('content.prepare',".$string."->".$field.");";
if(!$runplugins) {
$runplugins = PHP_EOL.$tab."\t//".$this->setLine(__LINE__)." Load the JEvent Dispatcher";
$runplugins .= PHP_EOL.$tab."\tJPluginHelper::importPlugin('content');";
$runplugins .= PHP_EOL.$tab."\t".'$this->_dispatcher = JEventDispatcher::getInstance();';
}
$fieldUikit .= PHP_EOL."\t".$tab."\t//".$this->setLine(__LINE__)." Make sure the content prepare plugins fire on ".$field;
$fieldUikit .= PHP_EOL."\t".$tab."\t".'$this->_dispatcher->trigger("onContentPrepare",array($this->_context,&'.$string.'->'.$field.',$item->params));';
// only load for uikit version 2 (TODO) we may need to add another check here
if (2 == $this->uikit || 1 == $this->uikit)
{
@ -1668,6 +1674,9 @@ class Interpretation extends Fields
}
}
}
// load dispatcher
$this->JEventDispatcher = array('###DISPATCHER###' => ($runplugins?:''));
// return UIKIT fix
return $fieldUikit;
}
@ -2123,6 +2132,8 @@ class Interpretation extends Fields
$getItem .= PHP_EOL."\t".$tab."\t\treturn false;";
}
$getItem .= PHP_EOL."\t".$tab."\t}";
// dispatcher placholder
$getItem .= "###DISPATCHER###";
if (ComponentbuilderHelper::checkArray($get->main_get))
{
$asBucket = array();
@ -2203,7 +2214,8 @@ class Interpretation extends Fields
$getItem .= PHP_EOL.PHP_EOL."\t".$tab."\t//".$this->setLine(__LINE__)." set data object to item.";
$getItem .= PHP_EOL."\t".$tab."\t\$this->_item[\$pk] = \$data;";
}
return $getItem;
// check if the dispather should be added
return str_replace(array_keys($this->JEventDispatcher), array_values($this->JEventDispatcher), $getItem);
}
return PHP_EOL."\t".$tab."\t//".$this->setLine(__LINE__)."add your custom code here.";
}
@ -2526,6 +2538,8 @@ class Interpretation extends Fields
$methods .= PHP_EOL.PHP_EOL."\t\t//".$this->setLine(__LINE__)." check if there was data returned";
$methods .= PHP_EOL."\t\tif (\$db->getNumRows())";
$methods .= PHP_EOL."\t\t{";
// set dispatcher placeholder
$methods .= "###DISPATCHER###";
// set decoding of needed fields
if (isset($this->siteFieldData['decode'][$default['code']][$get['key']][$default['as']]))
{
@ -2632,10 +2646,12 @@ class Interpretation extends Fields
$methods = str_replace('###CRYPT###', $script, $methods);
}
}
// insure the crypt placeholder is removed
$methods = str_replace('###CRYPT###','',$methods);
}
}
return $methods.PHP_EOL;
// check if the dispatcher must be set
return str_replace(array_keys($this->JEventDispatcher), array_values($this->JEventDispatcher), $methods).PHP_EOL;
}
public function setCustomViewMethodDefaults($get,$code)
@ -2734,6 +2750,7 @@ class Interpretation extends Fields
$getItem .= PHP_EOL.PHP_EOL."\t\t//".$this->setLine(__LINE__)." Convert the parameter fields into objects.";
$getItem .= PHP_EOL."\t\tif (".$Component."Helper::checkArray(\$items))";
$getItem .= PHP_EOL."\t\t{";
$getItem .= "###DISPATCHER###";
$getItem .= PHP_EOL."\t\t\tforeach (\$items as \$nr => &\$item)";
$getItem .= PHP_EOL."\t\t\t{";
$getItem .= PHP_EOL."\t\t\t\t//".$this->setLine(__LINE__)." Always create a slug for sef URL's";
@ -2773,6 +2790,8 @@ class Interpretation extends Fields
$asBucket[] = $main_get['as'];
}
}
// check if we should load the dispatcher
$getItem = str_replace(array_keys($this->JEventDispatcher), array_values($this->JEventDispatcher), $getItem);
// setup Globals
$getItem .= $this->setCustomViewGlobals($get->global,'$item',$asBucket,"\t\t");
// setup the custom gets that returns multipal values