diff --git a/README.md b/README.md index 470aee746..b89f98f4e 100644 --- a/README.md +++ b/README.md @@ -126,12 +126,12 @@ Component Builder is mapped as a component in itself on my local development env + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](http://joomlacomponentbuilder.com) + *First Build*: 30th April, 2015 -+ *Last Build*: 11th March, 2018 ++ *Last Build*: 18th March, 2018 + *Version*: 2.6.18 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **183732** -+ *Field count*: **1651** ++ *Line count*: **186136** ++ *Field count*: **994** + *File count*: **1171** + *Folder count*: **189** diff --git a/admin/README.txt b/admin/README.txt index 470aee746..b89f98f4e 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -126,12 +126,12 @@ Component Builder is mapped as a component in itself on my local development env + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](http://joomlacomponentbuilder.com) + *First Build*: 30th April, 2015 -+ *Last Build*: 11th March, 2018 ++ *Last Build*: 18th March, 2018 + *Version*: 2.6.18 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **183732** -+ *Field count*: **1651** ++ *Line count*: **186136** ++ *Field count*: **994** + *File count*: **1171** + *Folder count*: **189** diff --git a/admin/config.xml b/admin/config.xml index c373eab98..0f2763316 100644 --- a/admin/config.xml +++ b/admin/config.xml @@ -47,78 +47,113 @@ /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +
- - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + +
- - - - - - - - - - - - - - + + + + + + + + + + + + + +
tidy = extension_loaded('Tidy'); // Set the params $this->params = JComponentHelper::getParams('com_componentbuilder'); + // set the field type builder + $this->fieldBuilderType = $this->params->get('compiler_field_builder_type', 2); + // check the field builder type logic + if (!$this->tidy && $this->fieldBuilderType == 2) + { + // we do not have the tidy extention set fall back to StringManipulation + $this->fieldBuilderType = 1; + // load the sugestion to use string manipulation + $this->app->enqueueMessage(JText::_('Since you do not have Tidy extentsion setup on your system, we could not use the SimpleXMLElement class. We instead used string manipulation to build all your fields, this is a faster method, you must inspect the xml files in your component package to see if you are satisfied with the result.
You can make this method your default by opening the global options of JCB and under the Global tab set the Field Builder Type to string manipulation.
'), 'Notice'); + } // load the compiler path $this->compilerPath = $this->params->get('compiler_folder_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler'); // set the component ID diff --git a/admin/helpers/compiler/c_Fields.php b/admin/helpers/compiler/c_Fields.php index 7a731a8f6..c95d29c42 100644 --- a/admin/helpers/compiler/c_Fields.php +++ b/admin/helpers/compiler/c_Fields.php @@ -375,15 +375,15 @@ class Fields extends Structure /** * set the Field set of a view * - * @param array $view The view data - * @param string $component The component name - * @param string $viewName The single view name - * @param string $listViewName The list view name + * @param array $view The view data + * @param string $component The component name + * @param string $view_name_single The single view name + * @param string $view_name_list The list view name * * @return string The fields set in xml * */ - public function setFieldSet($view, $component, $viewName, $listViewName) + public function setFieldSet($view, $component, $view_name_single, $view_name_list) { // setup the fieldset of this view if (isset($view['settings']->fields) && ComponentbuilderHelper::checkArray($view['settings']->fields)) @@ -391,19 +391,12 @@ class Fields extends Structure // add metadata to the view if (isset($view['metadata']) && $view['metadata']) { - $this->metadataBuilder[$viewName] = $viewName; + $this->metadataBuilder[$view_name_single] = $view_name_single; } // add access to the view if (isset($view['access']) && $view['access']) { - $this->accessBuilder[$viewName] = $viewName; - } - // set the read only - $readOnlyXML = array(); - if ($view['settings']->type == 2) - { - $readOnlyXML['readonly'] = true; - $readOnlyXML['disabled'] = true; + $this->accessBuilder[$view_name_single] = $view_name_single; } // main lang prefix $langView = $this->langPrefix . '_' . $this->placeholders['###VIEW###']; @@ -411,8 +404,6 @@ class Fields extends Structure // set default lang $this->langContent[$this->lang][$langView] = $view['settings']->name_single; $this->langContent[$this->lang][$langViews] = $view['settings']->name_list; - // set the single name - $viewSingleName = ComponentbuilderHelper::safeString($view['settings']->name_single, 'W'); // set global item strings $this->langContent[$this->lang][$langViews . '_N_ITEMS_ARCHIVED'] = "%s " . $view['settings']->name_list . " archived."; $this->langContent[$this->lang][$langViews . '_N_ITEMS_ARCHIVED_1'] = "%s " . $view['settings']->name_single . " archived."; @@ -447,296 +438,598 @@ class Fields extends Structure $this->langContent[$this->lang][$langView . '_VERSION_LABEL'] = "Revision"; $this->langContent[$this->lang][$langView . '_VERSION_DESC'] = "A count of the number of times this " . $view['settings']->name_single . " has been revised."; $this->langContent[$this->lang][$langView . '_SAVE_WARNING'] = "Alias already existed so a number was added at the end. You can re-edit the " . $view['settings']->name_single . " to customise the alias."; - // start adding dynamc fields - $dynamicFieldsXML = array(); - // 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) + // check what type of field builder to use + if ($this->fieldBuilderType == 1) { - $dynamicFieldsXML[] = $this->setDynamicField($field, $view, $view['settings']->type, $langView, $viewName, $listViewName, $this->placeholders, $dbkey, true); + // build field set using string manipulation + return $this->stringFieldSet($view, $component, $view_name_single, $view_name_list, $langView, $langViews); } - // set the default fields - $XML = new simpleXMLElement(''); - $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'])) + else { - $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); - // count the static field created - $this->fieldCount++; + // build field set with simpleXMLElement class + return $this->simpleXMLFieldSet($view, $component, $view_name_single, $view_name_list, $langView, $langViews); } - // 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' - ); - $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); - // count the static field created - $this->fieldCount++; - } - // 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', - ); - $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); - // count the static field created - $this->fieldCount++; - } - // if published is not set - if (!isset($this->fieldsNames[$viewName]['published'])) - { - $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); - // count the static field created - $this->fieldCount++; - 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'])) - { - $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); - // count the static field created - $this->fieldCount++; - } - // 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' - ); - $this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " User Modified Field. Type: User (joomla)"); - $fieldXML = $fieldSetXML->addChild('field'); - $this->xmlAddAttributes($fieldXML, $attributes); - // count the static field created - $this->fieldCount++; - } - // 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" - ); - $attributes = array_merge($attributes, $readOnlyXML); - $this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Access Field. Type: Accesslevel (joomla)"); - $fieldXML = $fieldSetXML->addChild('field'); - $this->xmlAddAttributes($fieldXML, $attributes); - // count the static field created - $this->fieldCount++; - } - // 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" - ); - $attributes = array_merge($attributes, $readOnlyXML); - $this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Ordering Field. Type: Numbers (joomla)"); - $fieldXML = $fieldSetXML->addChild('field'); - $this->xmlAddAttributes($fieldXML, $attributes); - // count the static field created - $this->fieldCount++; - } - // 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' - ); - $this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Version Field. Type: Text (joomla)"); - $fieldXML = $fieldSetXML->addChild('field'); - $this->xmlAddAttributes($fieldXML, $attributes); - // count the static field created - $this->fieldCount++; - } - // 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 - ); - $this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Metakey Field. Type: Textarea (joomla)"); - $fieldXML = $fieldSetXML->addChild('field'); - $this->xmlAddAttributes($fieldXML, $attributes); - // count the static field created - $this->fieldCount++; - // 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)"); - $fieldXML = $fieldSetXML->addChild('field'); - $this->xmlAddAttributes($fieldXML, $attributes); - // count the static field created - $this->fieldCount++; - } - // load the dynamic fields now - if (count($dynamicFieldsXML)) - { - $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"); - $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 - $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); - // count the static field created - $this->fieldCount++; - $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 - $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); - // count the static field created - $this->fieldCount++; - // rights - $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); - // count the static field created - $this->fieldCount++; - } - // return the set - return $this->xmlPrettyPrint($XML, 'fieldset'); } return ''; } + /** + * build field set using string manipulation + * + * @param array $view The view data + * @param string $component The component name + * @param string $view_name_single The single view name + * @param string $view_name_list The list view name + * @param string $langView The language string of the view + * @param string $langViews The language string of the views + * + * @return string The fields set in xml + * + */ + protected function stringFieldSet($view, $component, $view_name_single, $view_name_list, $langView, $langViews) + { + // set the read only + $readOnly = false; + if ($view['settings']->type == 2) + { + $readOnly = "\t\t\t" . 'readonly="true"' . PHP_EOL . "\t\t\t" . 'disabled="true"'; + } + // start adding dynamc fields + $dynamicFields = ''; + // 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) + { + $dynamicFields .= $this->setDynamicField($field, $view, $view['settings']->type, $langView, $view_name_single, $view_name_list, $this->placeholders, $dbkey, true); + } + // set the default fields + $fieldSet = array(); + $fieldSet[] = '
'; + $fieldSet[] = "\t\t"; + $fieldSet[] = "\t\t"; + // if id is not set + if (!isset($this->fieldsNames[$view_name_single]['id'])) + { + $fieldSet[] = "\t\tfieldCount++; + } + // if created is not set + if (!isset($this->fieldsNames[$view_name_single]['created'])) + { + $fieldSet[] = "\t\t"; + $fieldSet[] = "\t\tfieldCount++; + } + // if created_by is not set + if (!isset($this->fieldsNames[$view_name_single]['created_by'])) + { + $fieldSet[] = "\t\t"; + $fieldSet[] = "\t\tfieldCount++; + } + // if published is not set + if (!isset($this->fieldsNames[$view_name_single]['published'])) + { + $fieldSet[] = "\t\t"; + $fieldSet[] = "\t\t'; + $fieldSet[] = "\t\t\t"; + $fieldSet[] = "\t\t\t"; + $fieldSet[] = "\t\t\t"; + $fieldSet[] = "\t\t\t"; + $fieldSet[] = "\t\t"; + // count the static field created + $this->fieldCount++; + } + // if modified is not set + if (!isset($this->fieldsNames[$view_name_single]['modified'])) + { + $fieldSet[] = "\t\t"; + $fieldSet[] = "\t\t" . ''; + // count the static field created + $this->fieldCount++; + } + // if modified_by is not set + if (!isset($this->fieldsNames[$view_name_single]['modified_by'])) + { + $fieldSet[] = "\t\t"; + $fieldSet[] = "\t\t" . 'fieldCount++; + } + // check if view has access + if (isset($this->accessBuilder[$view_name_single]) && ComponentbuilderHelper::checkString($this->accessBuilder[$view_name_single]) && !isset($this->fieldsNames[$view_name_single]['access'])) + { + $fieldSet[] = "\t\t"; + $fieldSet[] = "\t\t" . 'fieldCount++; + } + // if ordering is not set + if (!isset($this->fieldsNames[$view_name_single]['ordering'])) + { + $fieldSet[] = "\t\t"; + $fieldSet[] = "\t\tfieldCount++; + } + // if version is not set + if (!isset($this->fieldsNames[$view_name_single]['version'])) + { + $fieldSet[] = "\t\t"; + $fieldSet[] = "\t\tfieldCount++; + } + // check if metadata is added to this view + if (isset($this->metadataBuilder[$view_name_single]) && ComponentbuilderHelper::checkString($this->metadataBuilder[$view_name_single])) + { + // metakey + $fieldSet[] = "\t\t"; + $fieldSet[] = "\t\tfieldCount++; + // metadesc + $fieldSet[] = "\t\t"; + $fieldSet[] = "\t\tfieldCount++; + } + // load the dynamic fields now + if (ComponentbuilderHelper::checkString($dynamicFields)) + { + $fieldSet[] = "\t\t" . $dynamicFields; + } + // close fieldset + $fieldSet[] = "\t
"; + // check if metadata is added to this view + if (isset($this->metadataBuilder[$view_name_single]) && ComponentbuilderHelper::checkString($this->metadataBuilder[$view_name_single])) + { + $fieldSet[] = PHP_EOL . "\t"; + $fieldSet[] = "\t'; + $fieldSet[] = "\t\t" . '
'; + // robots + $fieldSet[] = "\t\t\t"; + $fieldSet[] = "\t\t\t" . ''; + $fieldSet[] = "\t\t\t\t" . ''; + $fieldSet[] = "\t\t\t\t" . ''; + $fieldSet[] = "\t\t\t\t" . ''; + $fieldSet[] = "\t\t\t\t" . ''; + $fieldSet[] = "\t\t\t\t" . ''; + $fieldSet[] = "\t\t\t" . ''; + // count the static field created + $this->fieldCount++; + // author + $fieldSet[] = "\t\t\t"; + $fieldSet[] = "\t\t\t" . 'fieldCount++; + // rights + $fieldSet[] = "\t\t\t"; + $fieldSet[] = "\t\t\t" . 'fieldCount++; + $fieldSet[] = "\t\t
"; + $fieldSet[] = "\t"; + } + // retunr the set + return implode(PHP_EOL, $fieldSet); + } + + /** + * build field set with simpleXMLElement class + * + * @param array $view The view data + * @param string $component The component name + * @param string $view_name_single The single view name + * @param string $view_name_list The list view name + * @param string $langView The language string of the view + * @param string $langViews The language string of the views + * + * @return string The fields set in xml + * + */ + protected function simpleXMLFieldSet($view, $component, $view_name_single, $view_name_list, $langView, $langViews) + { + // set the read only + $readOnlyXML = array(); + if ($view['settings']->type == 2) + { + $readOnlyXML['readonly'] = true; + $readOnlyXML['disabled'] = true; + } + // start adding dynamc fields + $dynamicFieldsXML = array(); + // 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) + { + $dynamicFieldsXML[] = $this->setDynamicField($field, $view, $view['settings']->type, $langView, $view_name_single, $view_name_list, $this->placeholders, $dbkey, true); + } + // set the default fields + $XML = new simpleXMLElement('
'); + $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[$view_name_single]['id'])) + { + $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); + // count the static field created + $this->fieldCount++; + } + // if created is not set + if (!isset($this->fieldsNames[$view_name_single]['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' + ); + $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); + // count the static field created + $this->fieldCount++; + } + // if created_by is not set + if (!isset($this->fieldsNames[$view_name_single]['created_by'])) + { + $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); + // count the static field created + $this->fieldCount++; + } + // if published is not set + if (!isset($this->fieldsNames[$view_name_single]['published'])) + { + $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); + // count the static field created + $this->fieldCount++; + 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[$view_name_single]['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' + ); + $this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Date Modified Field. Type: Calendar (joomla)"); + $fieldXML = $fieldSetXML->addChild('field'); + $this->xmlAddAttributes($fieldXML, $attributes); + // count the static field created + $this->fieldCount++; + } + // if modified_by is not set + if (!isset($this->fieldsNames[$view_name_single]['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' + ); + $this->xmlComment($fieldSetXML, $this->setLine(__LINE__) . " User Modified Field. Type: User (joomla)"); + $fieldXML = $fieldSetXML->addChild('field'); + $this->xmlAddAttributes($fieldXML, $attributes); + // count the static field created + $this->fieldCount++; + } + // check if view has access + if (isset($this->accessBuilder[$view_name_single]) && ComponentbuilderHelper::checkString($this->accessBuilder[$view_name_single]) && !isset($this->fieldsNames[$view_name_single]['access'])) + { + $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); + // count the static field created + $this->fieldCount++; + } + // if ordering is not set + if (!isset($this->fieldsNames[$view_name_single]['ordering'])) + { + $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); + // count the static field created + $this->fieldCount++; + } + // if version is not set + if (!isset($this->fieldsNames[$view_name_single]['version'])) + { + $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); + // count the static field created + $this->fieldCount++; + } + // check if metadata is added to this view + if (isset($this->metadataBuilder[$view_name_single]) && ComponentbuilderHelper::checkString($this->metadataBuilder[$view_name_single])) + { + // metakey + $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); + // count the static field created + $this->fieldCount++; + // 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)"); + $fieldXML = $fieldSetXML->addChild('field'); + $this->xmlAddAttributes($fieldXML, $attributes); + // count the static field created + $this->fieldCount++; + } + // load the dynamic fields now + if (count($dynamicFieldsXML)) + { + $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[$view_name_single]) && ComponentbuilderHelper::checkString($this->metadataBuilder[$view_name_single])) + { + $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 + $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); + // count the static field created + $this->fieldCount++; + $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 + $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); + // count the static field created + $this->fieldCount++; + // rights + $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); + // count the static field created + $this->fieldCount++; + } + // return the set + return $this->xmlPrettyPrint($XML, 'fieldset'); + } + /** * set Field Names * @@ -753,48 +1046,60 @@ class Fields extends Structure /** * set Dynamic field * - * @param array $field The field data - * @param array $view The view data - * @param int $viewType The view type - * @param string $langView The language string of the view - * @param string $viewName The singel view name - * @param string $listViewName The list view name - * @param array $placeholders The place holder and replace values - * @param string $dbkey The the custom table key - * @param boolean $build The switch to set the build option + * @param array $field The field data + * @param array $view The view data + * @param int $viewType The view type + * @param string $langView The language string of the view + * @param string $view_name_single The single view name + * @param string $view_name_list The list view name + * @param array $placeholders The place holder and replace values + * @param string $dbkey The the custom table key + * @param boolean $build The switch to set the build option * * @return SimpleXMLElement The complete field in xml * */ - public function setDynamicField(&$field, &$view, &$viewType, &$langView, &$viewName, &$listViewName, &$placeholders, &$dbkey, $build) + public function setDynamicField(&$field, &$view, &$viewType, &$langView, &$view_name_single, &$view_name_list, &$placeholders, &$dbkey, $build) { + // set default return + if ($this->fieldBuilderType == 1) + { + // string manipulation + $dynamicField = ''; + } + else + { + // simpleXMLElement class + $dynamicField = false; + } + // make sure we have settings if (isset($field['settings']) && ComponentbuilderHelper::checkObject($field['settings'])) { // reset some values - $name = $this->getFieldName($field, $listViewName); + $name = $this->getFieldName($field, $view_name_list); $typeName = $this->getFieldType($field); $multiple = false; $langLabel = ''; $fieldSet = ''; $fieldAttributes = array(); // set field attributes - $fieldAttributes = $this->setFieldAttributes($field, $viewType, $name, $typeName, $multiple, $langLabel, $langView, $listViewName, $viewName, $placeholders); + $fieldAttributes = $this->setFieldAttributes($field, $viewType, $name, $typeName, $multiple, $langLabel, $langView, $view_name_list, $view_name_single, $placeholders); // check if values were set if (ComponentbuilderHelper::checkArray($fieldAttributes)) { // set the array of field names - $this->setFieldsNames($viewName, $fieldAttributes['name']); + $this->setFieldsNames($view_name_single, $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); + $dynamicField = $this->setField('option', $fieldAttributes, $name, $typeName, $langView, $view_name_single, $view_name_list, $placeholders, $optionArray); if ($build) { // set builders - $this->setBuilders($langLabel, $langView, $viewName, $listViewName, $name, $view, $field, $typeName, $multiple, false, $optionArray); + $this->setBuilders($langLabel, $langView, $view_name_single, $view_name_list, $name, $view, $field, $typeName, $multiple, false, $optionArray); } } elseif ($this->defaultField($typeName, 'plain')) @@ -802,10 +1107,10 @@ class Fields extends Structure if ($build) { // set builders - $this->setBuilders($langLabel, $langView, $viewName, $listViewName, $name, $view, $field, $typeName, $multiple); + $this->setBuilders($langLabel, $langView, $view_name_single, $view_name_list, $name, $view, $field, $typeName, $multiple); } // now add to the field set - $xmlElement = $this->setField('plain', $fieldAttributes, $name, $typeName, $langView, $viewName, $listViewName, $placeholders, $optionArray); + $dynamicField = $this->setField('plain', $fieldAttributes, $name, $typeName, $langView, $view_name_single, $view_name_list, $placeholders, $optionArray); } elseif ($this->defaultField($typeName, 'spacer')) { @@ -822,10 +1127,10 @@ class Fields extends Structure // set to publishing tab $tabName = 'publishing'; } - $this->setLayoutBuilder($viewName, $tabName, $name, $field); + $this->setLayoutBuilder($view_name_single, $tabName, $name, $field); } // now add to the field set - $xmlElement = $this->setField('spacer', $fieldAttributes, $name, $typeName, $langView, $viewName, $listViewName, $placeholders, $optionArray); + $dynamicField = $this->setField('spacer', $fieldAttributes, $name, $typeName, $langView, $view_name_single, $view_name_list, $placeholders, $optionArray); } elseif ($this->defaultField($typeName, 'special')) { @@ -835,10 +1140,10 @@ class Fields extends Structure if ($build) { // set builders - $this->setBuilders($langLabel, $langView, $viewName, $listViewName, $name, $view, $field, $typeName, $multiple, false); + $this->setBuilders($langLabel, $langView, $view_name_single, $view_name_list, $name, $view, $field, $typeName, $multiple, false); } // now add to the field set - $xmlElement = $this->setField('special', $fieldAttributes, $name, $typeName, $langView, $viewName, $listViewName, $placeholders, $optionArray); + $dynamicField = $this->setField('special', $fieldAttributes, $name, $typeName, $langView, $view_name_single, $view_name_list, $placeholders, $optionArray); } } elseif (ComponentbuilderHelper::checkArray($fieldAttributes['custom'])) @@ -853,35 +1158,413 @@ class Fields extends Structure if ($build) { // set builders - $this->setBuilders($langLabel, $langView, $viewName, $listViewName, $name, $view, $field, $typeName, $multiple, $custom); + $this->setBuilders($langLabel, $langView, $view_name_single, $view_name_list, $name, $view, $field, $typeName, $multiple, $custom); } // now add to the field set - $xmlElement = $this->setField('custom', $fieldAttributes, $name, $typeName, $langView, $viewName, $listViewName, $placeholders, $optionArray, $custom); + $dynamicField = $this->setField('custom', $fieldAttributes, $name, $typeName, $langView, $view_name_single, $view_name_list, $placeholders, $optionArray, $custom); } } - return $xmlElement; } - return false; + return $dynamicField; } /** * set a field * - * @param string $setType The set of fields type - * @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 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 array $custom Used when field is from config + * @param string $setType The set of fields type + * @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 $view_name_single The single view name + * @param string $view_name_list 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 array $custom Used when field is from config + * @param string $taber The tabs to add in layout (only in string manipulation) * * @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, &$view_name_single, &$view_name_list, $placeholders, &$optionArray, $custom = null, $taber = '') + { + // check what type of field builder to use + if ($this->fieldBuilderType == 1) + { + // build field set using string manipulation + return $this->stringSetField($setType, $fieldAttributes, $name, $typeName, $langView, $view_name_single, $view_name_list, $placeholders, $optionArray, $custom, $taber); + } + else + { + // build field set with simpleXMLElement class + return $this->simpleXMLSetField($setType, $fieldAttributes, $name, $typeName, $langView, $view_name_single, $view_name_list, $placeholders, $optionArray, $custom); + } + } + + /** + * set a field using string manipulation + * + * @param string $setType The set of fields type + * @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 $view_name_single The single view name + * @param string $view_name_list 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 array $custom Used when field is from config + * @param string $taber The tabs to add in layout + * + * @return SimpleXMLElement The field in xml + * + */ + protected function stringSetField($setType, &$fieldAttributes, &$name, &$typeName, &$langView, &$view_name_single, &$view_name_list, $placeholders, &$optionArray, $custom = null, $taber = '') + { + $field = ''; + if ($setType === 'option') + { + // now add to the field set + $field .= PHP_EOL . "\t" . $taber . "\t"; + $field .= PHP_EOL . "\t" . $taber . "\t $value) + { + if ($property != 'option') + { + $field .= PHP_EOL . "\t\t" . $taber . "\t" . $property . '="' . $value . '"'; + } + elseif ($property === 'option') + { + $optionSet = ''; + if (strpos($value, ',') !== false) + { + // mulitpal options + $options = explode(',', $value); + foreach ($options as $option) + { + if (strpos($option, '|') !== false) + { + // has other value then text + list($v, $t) = explode('|', $option); + $langValue = $langView . '_' . ComponentbuilderHelper::safeString($t, 'U'); + // add to lang array + $this->langContent[$this->lang][$langValue] = $t; + // no add to option set + $optionSet .= PHP_EOL . "\t" . $taber . "\t\t" . ''; + $optionArray[$v] = $langValue; + } + else + { + // text is also the value + $langValue = $langView . '_' . ComponentbuilderHelper::safeString($option, 'U'); + // add to lang array + $this->langContent[$this->lang][$langValue] = $option; + // no add to option set + $optionSet .= PHP_EOL . "\t\t" . $taber . "\t" . ''; + $optionArray[$option] = $langValue; + } + } + } + else + { + // one option + if (strpos($value, '|') !== false) + { + // has other value then text + list($v, $t) = explode('|', $value); + $langValue = $langView . '_' . ComponentbuilderHelper::safeString($t, 'U'); + // add to lang array + $this->langContent[$this->lang][$langValue] = $t; + // no add to option set + $optionSet .= PHP_EOL . "\t\t" . $taber . "\t" . ''; + $optionArray[$v] = $langValue; + } + else + { + // text is also the value + $langValue = $langView . '_' . ComponentbuilderHelper::safeString($value, 'U'); + // add to lang array + $this->langContent[$this->lang][$langValue] = $value; + // no add to option set + $optionSet .= PHP_EOL . "\t\t" . $taber . "\t" . ''; + $optionArray[$value] = $langValue; + } + } + } + } + if (ComponentbuilderHelper::checkString($optionSet)) + { + $field .= '>'; + $field .= PHP_EOL . "\t\t\t" . $taber . ""; + $field .= $optionSet; + $field .= PHP_EOL . "\t\t" . $taber . ""; + } + elseif ($typeName === 'sql') + { + $optionArray = false; + $field .= PHP_EOL . "\t\t" . $taber . "/>"; + } + else + { + $optionArray = false; + $field .= PHP_EOL . "\t\t\t" . $taber . ""; + $field .= PHP_EOL . "\t\t" . $taber . "/>"; + } + } + elseif ($setType === 'plain') + { + // now add to the field set + $field .= PHP_EOL . "\t\t" . $taber . ""; + $field .= PHP_EOL . "\t\t" . $taber . " $value) + { + if ($property != 'option') + { + $field .= PHP_EOL . "\t\t" . $taber . "\t" . $property . '="' . $value . '"'; + } + } + $field .= PHP_EOL . "\t\t" . $taber . "/>"; + } + elseif ($setType === 'spacer') + { + // now add to the field set + $field .= PHP_EOL . "\t\t"; + $field .= PHP_EOL . "\t\t $value) + { + if ($property != 'option') + { + $field .= " " . $property . '="' . $value . '"'; + } + } + $field .= " />"; + } + elseif ($setType === 'special') + { + // set the repeatable field + if ($typeName === 'repeatable') + { + // now add to the field set + $field .= PHP_EOL . "\t\t"; + $field .= PHP_EOL . "\t\t $value) + { + if ($property != 'fields') + { + $field .= PHP_EOL . "\t\t\t" . $property . '="' . $value . '"'; + } + } + $field .= ">"; + $field .= PHP_EOL . "\t\t\t" . ''; + $field .= PHP_EOL . "\t\t\t\t" . '"; + $field .= PHP_EOL . "\t\t\t"; + $field .= PHP_EOL . "\t\t"; + } + // set the subform fields (it is a repeatable without the modal) + elseif ($typeName === 'subform') + { + // now add to the field set + $field .= PHP_EOL . "\t\t"; + $field .= PHP_EOL . "\t\t $value) + { + if ($property != 'fields') + { + $field .= PHP_EOL . "\t\t\t" . $property . '="' . $value . '"'; + } + } + $field .= ">"; + $field .= PHP_EOL . "\t\t\t" . '"; + $field .= PHP_EOL . "\t\t"; + } + } + elseif ($setType === 'custom') + { + // now add to the field set + $field .= PHP_EOL . "\t\t" . $taber . ""; + $field .= PHP_EOL . "\t\t" . $taber . " $value) + { + if ($property != 'option') + { + $field .= PHP_EOL . "\t\t" . $taber . "\t" . $property . '="' . $value . '"'; + } + } + $field .= PHP_EOL . "\t\t" . $taber . "/>"; + // incase the field is in the config and has not been set + if ('config' === $view_name_single && 'configs' === $view_name_list) + { + // set lang (just incase) + $listLangName = $langView . '_' . ComponentbuilderHelper::safeString($name, 'U'); + // set the custom array + $data = array('type' => $typeName, 'code' => $name, 'lang' => $listLangName, 'custom' => $custom); + // set the custom field file + $this->setCustomFieldTypeFile($data, $view_name_list, $view_name_single); + } + } + // count the dynamic fields created + $this->fieldCount++; + // return field + return $field; + } + + /** + * set a field with simpleXMLElement class + * + * @param string $setType The set of fields type + * @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 $view_name_single The single view name + * @param string $view_name_list 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 array $custom Used when field is from config + * + * @return SimpleXMLElement The field in xml + * + */ + protected function simpleXMLSetField($setType, &$fieldAttributes, &$name, &$typeName, &$langView, &$view_name_single, &$view_name_list, $placeholders, &$optionArray, $custom = null) { $field = new stdClass(); if ($setType === 'option') @@ -1033,7 +1716,7 @@ class Fields extends Structure { // get the field data $fieldData = array(); - $fieldData['settings'] = $this->getFieldData($fieldId, $viewName); + $fieldData['settings'] = $this->getFieldData($fieldId, $view_name_single); if (ComponentbuilderHelper::checkObject($fieldData['settings'])) { $r_name = $this->getFieldName($fieldData); @@ -1041,7 +1724,7 @@ class Fields extends Structure $r_multiple = false; $r_langLabel = ''; // get field values - $r_fieldValues = $this->setFieldAttributes($fieldData, $view, $r_name, $r_typeName, $r_multiple, $r_langLabel, $langView, $listViewName, $viewName, $placeholders, true); + $r_fieldValues = $this->setFieldAttributes($fieldData, $view, $r_name, $r_typeName, $r_multiple, $r_langLabel, $langView, $view_name_list, $view_name_single, $placeholders, true); // check if values were set if (ComponentbuilderHelper::checkArray($r_fieldValues)) { @@ -1050,12 +1733,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, $view_name_single, $view_name_list, $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, $view_name_single, $view_name_list, $placeholders, $r_optionArray)); } elseif (ComponentbuilderHelper::checkArray($r_fieldValues['custom'])) { @@ -1063,7 +1746,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, $view_name_single, $view_name_list, $placeholders, $r_optionArray)); // set lang (just incase) $r_listLangName = $langView . '_' . ComponentbuilderHelper::safeString($r_name, 'U'); // add to lang array @@ -1076,7 +1759,7 @@ class Fields extends Structure // set the custom array $data = array('type' => $r_typeName, 'code' => $r_name, 'lang' => $r_listLangName, 'custom' => $custom); // set the custom field file - $this->setCustomFieldTypeFile($data, $listViewName, $viewName); + $this->setCustomFieldTypeFile($data, $view_name_list, $view_name_single); } } } @@ -1130,7 +1813,7 @@ class Fields extends Structure { // get the field data $fieldData = array(); - $fieldData['settings'] = $this->getFieldData($fieldId, $viewName); + $fieldData['settings'] = $this->getFieldData($fieldId, $view_name_single); if (ComponentbuilderHelper::checkObject($fieldData['settings'])) { $r_name = $this->getFieldName($fieldData); @@ -1138,7 +1821,7 @@ class Fields extends Structure $r_multiple = false; $r_langLabel = ''; // get field values - $r_fieldValues = $this->setFieldAttributes($fieldData, $view, $r_name, $r_typeName, $r_multiple, $r_langLabel, $langView, $listViewName, $viewName, $placeholders, true); + $r_fieldValues = $this->setFieldAttributes($fieldData, $view, $r_name, $r_typeName, $r_multiple, $r_langLabel, $langView, $view_name_list, $view_name_single, $placeholders, true); // check if values were set if (ComponentbuilderHelper::checkArray($r_fieldValues)) { @@ -1147,12 +1830,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, $view_name_single, $view_name_list, $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, $view_name_single, $view_name_list, $placeholders, $r_optionArray)); } elseif (ComponentbuilderHelper::checkArray($r_fieldValues['custom'])) { @@ -1160,7 +1843,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, $view_name_single, $view_name_list, $placeholders, $r_optionArray)); // set lang (just incase) $r_listLangName = $langView . '_' . ComponentbuilderHelper::safeString($r_name, 'U'); // add to lang array @@ -1173,7 +1856,7 @@ class Fields extends Structure // set the custom array $data = array('type' => $r_typeName, 'code' => $r_name, 'lang' => $r_listLangName, 'custom' => $custom); // set the custom field file - $this->setCustomFieldTypeFile($data, $listViewName, $viewName); + $this->setCustomFieldTypeFile($data, $view_name_list, $view_name_single); } } } @@ -1195,14 +1878,14 @@ class Fields extends Structure } } // incase the field is in the config and has not been set - if ('config' === $viewName && 'configs' === $listViewName) + if ('config' === $view_name_single && 'configs' === $view_name_list) { // set lang (just incase) $listLangName = $langView . '_' . ComponentbuilderHelper::safeString($name, 'U'); // set the custom array $data = array('type' => $typeName, 'code' => $name, 'lang' => $listLangName, 'custom' => $custom); // set the custom field file - $this->setCustomFieldTypeFile($data, $listViewName, $viewName); + $this->setCustomFieldTypeFile($data, $view_name_list, $view_name_single); } } return $field; @@ -1211,99 +1894,99 @@ class Fields extends Structure /** * set the layout builder * - * @param string $viewName The single edit view code name - * @param string $tabName The tab code name - * @param string $name The field code name - * @param array $field The field details + * @param string $view_name_single The single edit view code name + * @param string $tabName The tab code name + * @param string $name The field code name + * @param array $field The field details * * @return void * */ - public function setLayoutBuilder(&$viewName, &$tabName, &$name, &$field) + public function setLayoutBuilder(&$view_name_single, &$tabName, &$name, &$field) { // first fix the zero order // to insure it lands before all the other fields // as zero is expected to behave if ($field['order_edit'] == 0) { - if (!isset($this->zeroOrderFix[$viewName])) + if (!isset($this->zeroOrderFix[$view_name_single])) { - $this->zeroOrderFix[$viewName] = array(); + $this->zeroOrderFix[$view_name_single] = array(); } - if (!isset($this->zeroOrderFix[$viewName][(int) $field['tab']])) + if (!isset($this->zeroOrderFix[$view_name_single][(int) $field['tab']])) { - $this->zeroOrderFix[$viewName][(int) $field['tab']] = -999; + $this->zeroOrderFix[$view_name_single][(int) $field['tab']] = -999; } else { - $this->zeroOrderFix[$viewName][(int) $field['tab']] ++; + $this->zeroOrderFix[$view_name_single][(int) $field['tab']] ++; } - $field['order_edit'] = $this->zeroOrderFix[$viewName][(int) $field['tab']]; + $field['order_edit'] = $this->zeroOrderFix[$view_name_single][(int) $field['tab']]; } // now build the layout if (ComponentbuilderHelper::checkString($tabName) && $tabName != 'publishing') { - $this->tabCounter[$viewName][(int) $field['tab']] = $tabName; - if (isset($this->layoutBuilder[$viewName][$tabName][(int) $field['alignment']][(int) $field['order_edit']])) + $this->tabCounter[$view_name_single][(int) $field['tab']] = $tabName; + if (isset($this->layoutBuilder[$view_name_single][$tabName][(int) $field['alignment']][(int) $field['order_edit']])) { - $size = (int) count((array) $this->layoutBuilder[$viewName][$tabName][(int) $field['alignment']]) + 1; - while(isset($this->layoutBuilder[$viewName][$tabName][(int) $field['alignment']][$size])) + $size = (int) count((array) $this->layoutBuilder[$view_name_single][$tabName][(int) $field['alignment']]) + 1; + while (isset($this->layoutBuilder[$view_name_single][$tabName][(int) $field['alignment']][$size])) { $size++; } - $this->layoutBuilder[$viewName][$tabName][(int) $field['alignment']][$size] = $name; + $this->layoutBuilder[$view_name_single][$tabName][(int) $field['alignment']][$size] = $name; } else { - $this->layoutBuilder[$viewName][$tabName][(int) $field['alignment']][(int) $field['order_edit']] = $name; + $this->layoutBuilder[$view_name_single][$tabName][(int) $field['alignment']][(int) $field['order_edit']] = $name; } // check if publishing fields were over written if (in_array($name, $this->defaultFields)) { // just to eliminate - $this->movedPublishingFields[$viewName][$name] = $name; + $this->movedPublishingFields[$view_name_single][$name] = $name; } } elseif ($tabName === 'publishing' || $tabName === 'Publishing') { if (!in_array($name, $this->defaultFields)) { - if (isset($this->newPublishingFields[$viewName][(int) $field['alignment']][(int) $field['order_edit']])) + if (isset($this->newPublishingFields[$view_name_single][(int) $field['alignment']][(int) $field['order_edit']])) { - $size = (int) count((array) $this->newPublishingFields[$viewName][(int) $field['alignment']]) + 1; - while(isset($this->newPublishingFields[$viewName][(int) $field['alignment']][$size])) + $size = (int) count((array) $this->newPublishingFields[$view_name_single][(int) $field['alignment']]) + 1; + while (isset($this->newPublishingFields[$view_name_single][(int) $field['alignment']][$size])) { $size++; } - $this->newPublishingFields[$viewName][(int) $field['alignment']][$size] = $name; + $this->newPublishingFields[$view_name_single][(int) $field['alignment']][$size] = $name; } else { - $this->newPublishingFields[$viewName][(int) $field['alignment']][(int) $field['order_edit']] = $name; + $this->newPublishingFields[$view_name_single][(int) $field['alignment']][(int) $field['order_edit']] = $name; } } } else { - $this->tabCounter[$viewName][1] = 'Details'; - if (isset($this->layoutBuilder[$viewName]['Details'][(int) $field['alignment']][(int) $field['order_edit']])) + $this->tabCounter[$view_name_single][1] = 'Details'; + if (isset($this->layoutBuilder[$view_name_single]['Details'][(int) $field['alignment']][(int) $field['order_edit']])) { - $size = (int) count((array) $this->layoutBuilder[$viewName]['Details'][(int) $field['alignment']]) + 1; - while(isset($this->layoutBuilder[$viewName]['Details'][(int) $field['alignment']][$size])) + $size = (int) count((array) $this->layoutBuilder[$view_name_single]['Details'][(int) $field['alignment']]) + 1; + while (isset($this->layoutBuilder[$view_name_single]['Details'][(int) $field['alignment']][$size])) { $size++; } - $this->layoutBuilder[$viewName]['Details'][(int) $field['alignment']][$size] = $name; + $this->layoutBuilder[$view_name_single]['Details'][(int) $field['alignment']][$size] = $name; } else { - $this->layoutBuilder[$viewName]['Details'][(int) $field['alignment']][(int) $field['order_edit']] = $name; + $this->layoutBuilder[$view_name_single]['Details'][(int) $field['alignment']][(int) $field['order_edit']] = $name; } // check if publishing fields were over written if (in_array($name, $this->defaultFields)) { // just to eliminate - $this->movedPublishingFields[$viewName][$name] = $name; + $this->movedPublishingFields[$view_name_single][$name] = $name; } } } @@ -1349,22 +2032,22 @@ class Fields extends Structure /** * set field attributes * - * @param array $field The field data - * @param int $viewType The view type - * @param string $name The field name - * @param string $typeName The field type - * @param boolean $multiple The switch to set multiple selection option - * @param string $langLabel The language string for field label - * @param string $langView The language string of the view - * @param string $listViewName The list view name - * @param string $viewName The singel view name - * @param array $placeholders The place holder and replace values - * @param boolean $repeatable The repeatable field switch + * @param array $field The field data + * @param int $viewType The view type + * @param string $name The field name + * @param string $typeName The field type + * @param boolean $multiple The switch to set multiple selection option + * @param string $langLabel The language string for field label + * @param string $langView The language string of the view + * @param string $view_name_list The list view name + * @param string $view_name_single The singel view name + * @param array $placeholders The place holder and replace values + * @param boolean $repeatable The repeatable field switch * * @return array The field attributes * */ - private function setFieldAttributes(&$field, &$viewType, &$name, &$typeName, &$multiple, &$langLabel, $langView, $listViewName, $viewName, $placeholders, $repeatable = false) + private function setFieldAttributes(&$field, &$viewType, &$name, &$typeName, &$multiple, &$langLabel, $langView, $view_name_list, $view_name_single, $placeholders, $repeatable = false) { // reset array $fieldAttributes = array(); @@ -1517,9 +2200,9 @@ class Fields extends Structure // update label if field use multiple times if ($property['name'] === 'label') { - if (isset($fieldAttributes['name']) && isset($this->uniqueNames[$listViewName]['names'][$fieldAttributes['name']])) + if (isset($fieldAttributes['name']) && isset($this->uniqueNames[$view_name_list]['names'][$fieldAttributes['name']])) { - $xmlValue .= ' (' . ComponentbuilderHelper::safeString($this->uniqueNames[$listViewName]['names'][$fieldAttributes['name']]) . ')'; + $xmlValue .= ' (' . ComponentbuilderHelper::safeString($this->uniqueNames[$view_name_list]['names'][$fieldAttributes['name']]) . ')'; } } // replace placeholders @@ -1593,13 +2276,13 @@ class Fields extends Structure $listclass = ComponentbuilderHelper::getBetween($field['settings']->xml, 'listclass="', '"'); if (ComponentbuilderHelper::checkString($listclass)) { - $this->listFieldClass[$listViewName][$fieldAttributes['name']] = $listclass; + $this->listFieldClass[$view_name_list][$fieldAttributes['name']] = $listclass; } // check if we find reason to remove this field from being escaped $escaped = ComponentbuilderHelper::getBetween($field['settings']->xml, 'escape="', '"'); if (ComponentbuilderHelper::checkString($escaped)) { - $this->doNotEscape[$listViewName][] = $fieldAttributes['name']; + $this->doNotEscape[$view_name_list][] = $fieldAttributes['name']; } // check if we have display switch for dynamic placment $display = ComponentbuilderHelper::getBetween($field['settings']->xml, 'display="', '"'); @@ -1615,27 +2298,27 @@ class Fields extends Structure /** * set Builders * - * @param string $langLabel The language string for field label - * @param string $langView The language string of the view - * @param string $viewName The singel view name - * @param string $listViewName The list view name - * @param string $name The field name - * @param array $view The view data - * @param array $field The field data - * @param string $typeName The field type - * @param boolean $multiple The switch to set multiple selection option - * @param boolean $custom The custom field switch - * @param boolean $options The options switch + * @param string $langLabel The language string for field label + * @param string $langView The language string of the view + * @param string $view_name_single The singel view name + * @param string $view_name_list The list view name + * @param string $name The field name + * @param array $view The view data + * @param array $field The field data + * @param string $typeName The field type + * @param boolean $multiple The switch to set multiple selection option + * @param boolean $custom The custom field switch + * @param boolean $options The options switch * * @return void * */ - public function setBuilders($langLabel, $langView, $viewName, $listViewName, $name, $view, $field, $typeName, $multiple, $custom = false, $options = false) + public function setBuilders($langLabel, $langView, $view_name_single, $view_name_list, $name, $view, $field, $typeName, $multiple, $custom = false, $options = false) { if ($typeName === 'tag') { // set tags for this view but don't load to DB - $this->tagsBuilder[$viewName] = $viewName; + $this->tagsBuilder[$view_name_single] = $view_name_single; } else { @@ -1658,58 +2341,58 @@ class Fields extends Structure // don't use these as index or uniqe keys $textKeys = array('TEXT', 'TINYTEXT', 'MEDIUMTEXT', 'LONGTEXT', 'BLOB', 'TINYBLOB', 'MEDIUMBLOB', 'LONGBLOB'); // build the query values - $this->queryBuilder[$viewName][$name]['type'] = $field['settings']->datatype; + $this->queryBuilder[$view_name_single][$name]['type'] = $field['settings']->datatype; if (!in_array($field['settings']->datatype, $textKeys)) { - $this->queryBuilder[$viewName][$name]['lenght'] = $field['settings']->datalenght; - $this->queryBuilder[$viewName][$name]['lenght_other'] = $field['settings']->datalenght_other; - $this->queryBuilder[$viewName][$name]['default'] = $field['settings']->datadefault; - $this->queryBuilder[$viewName][$name]['other'] = $field['settings']->datadefault_other; + $this->queryBuilder[$view_name_single][$name]['lenght'] = $field['settings']->datalenght; + $this->queryBuilder[$view_name_single][$name]['lenght_other'] = $field['settings']->datalenght_other; + $this->queryBuilder[$view_name_single][$name]['default'] = $field['settings']->datadefault; + $this->queryBuilder[$view_name_single][$name]['other'] = $field['settings']->datadefault_other; } else { - $this->queryBuilder[$viewName][$name]['default'] = 'EMPTY'; + $this->queryBuilder[$view_name_single][$name]['default'] = 'EMPTY'; } // to identify the field - $this->queryBuilder[$viewName][$name]['ID'] = $field['settings']->id; - $this->queryBuilder[$viewName][$name]['null_switch'] = $field['settings']->null_switch; + $this->queryBuilder[$view_name_single][$name]['ID'] = $field['settings']->id; + $this->queryBuilder[$view_name_single][$name]['null_switch'] = $field['settings']->null_switch; // set index types if ($field['settings']->indexes == 1 && !in_array($field['settings']->datatype, $textKeys)) { // build unique keys of this view for db - $this->dbUniqueKeys[$viewName][] = $name; + $this->dbUniqueKeys[$view_name_single][] = $name; } elseif (($field['settings']->indexes == 2 || (isset($field['alias']) && $field['alias']) || (isset($field['title']) && $field['title']) || $typeName === 'category') && !in_array($field['settings']->datatype, $textKeys)) { // build keys of this view for db - $this->dbKeys[$viewName][] = $name; + $this->dbKeys[$view_name_single][] = $name; } } // add history to this view if (isset($view['history']) && $view['history']) { - $this->historyBuilder[$viewName] = $viewName; + $this->historyBuilder[$view_name_single] = $view_name_single; } // set Alias (only one title per view) if (isset($field['alias']) && $field['alias']) { - $this->aliasBuilder[$viewName] = $name; + $this->aliasBuilder[$view_name_single] = $name; } // set Titles (only one title per view) if (isset($field['title']) && $field['title']) { - $this->titleBuilder[$viewName] = $name; + $this->titleBuilder[$view_name_single] = $name; } // category name fix if ($typeName === 'category') { - if (isset($this->catOtherName[$listViewName]) && ComponentbuilderHelper::checkArray($this->catOtherName[$listViewName])) + if (isset($this->catOtherName[$view_name_list]) && ComponentbuilderHelper::checkArray($this->catOtherName[$view_name_list])) { - $tempName = $this->catOtherName[$listViewName]['name']; + $tempName = $this->catOtherName[$view_name_list]['name']; } else { - $tempName = $viewName . ' category'; + $tempName = $view_name_single . ' category'; } // set lang $listLangName = $langView . '_' . ComponentbuilderHelper::safeString($tempName, 'U'); @@ -1732,7 +2415,7 @@ class Fields extends Structure if ((isset($field['list']) && $field['list'] == 1) && $typeName != 'repeatable' && $typeName != 'subform') { // load to list builder - $this->listBuilder[$listViewName][] = array( + $this->listBuilder[$view_name_list][] = array( 'type' => $typeName, 'code' => $name, 'lang' => $listLangName, @@ -1744,64 +2427,64 @@ class Fields extends Structure 'multiple' => $multiple, 'options' => $options); - $this->customBuilderList[$listViewName][] = $name; + $this->customBuilderList[$view_name_list][] = $name; } // set the hidden field of this view if ($typeName === 'hidden') { - if (!isset($this->hiddenFieldsBuilder[$viewName])) + if (!isset($this->hiddenFieldsBuilder[$view_name_single])) { - $this->hiddenFieldsBuilder[$viewName] = ''; + $this->hiddenFieldsBuilder[$view_name_single] = ''; } - $this->hiddenFieldsBuilder[$viewName] .= ',"' . $name . '"'; + $this->hiddenFieldsBuilder[$view_name_single] .= ',"' . $name . '"'; } // set all int fields of this view if ($field['settings']->datatype === 'INT' || $field['settings']->datatype === 'TINYINT' || $field['settings']->datatype === 'BIGINT') { - if (!isset($this->intFieldsBuilder[$viewName])) + if (!isset($this->intFieldsBuilder[$view_name_single])) { - $this->intFieldsBuilder[$viewName] = ''; + $this->intFieldsBuilder[$view_name_single] = ''; } - $this->intFieldsBuilder[$viewName] .= ',"' . $name . '"'; + $this->intFieldsBuilder[$view_name_single] .= ',"' . $name . '"'; } // set all dynamic field of this view if ($typeName != 'category' && $typeName != 'repeatable' && $typeName != 'subform' && !in_array($name, $this->defaultFields)) { - if (!isset($this->dynamicfieldsBuilder[$viewName])) + if (!isset($this->dynamicfieldsBuilder[$view_name_single])) { - $this->dynamicfieldsBuilder[$viewName] = ''; + $this->dynamicfieldsBuilder[$view_name_single] = ''; } - if (isset($this->dynamicfieldsBuilder[$viewName]) && ComponentbuilderHelper::checkString($this->dynamicfieldsBuilder[$viewName])) + if (isset($this->dynamicfieldsBuilder[$view_name_single]) && ComponentbuilderHelper::checkString($this->dynamicfieldsBuilder[$view_name_single])) { - $this->dynamicfieldsBuilder[$viewName] .= ',"' . $name . '":"' . $name . '"'; + $this->dynamicfieldsBuilder[$view_name_single] .= ',"' . $name . '":"' . $name . '"'; } else { - $this->dynamicfieldsBuilder[$viewName] .= '"' . $name . '":"' . $name . '"'; + $this->dynamicfieldsBuilder[$view_name_single] .= '"' . $name . '":"' . $name . '"'; } } // TODO we may need to add a switch instead (since now it uses the first editor field) // set the main(biggest) text field of this view if ($typeName === 'editor') { - if (!isset($this->maintextBuilder[$viewName]) || !ComponentbuilderHelper::checkString($this->maintextBuilder[$viewName])) + if (!isset($this->maintextBuilder[$view_name_single]) || !ComponentbuilderHelper::checkString($this->maintextBuilder[$view_name_single])) { - $this->maintextBuilder[$viewName] = $name; + $this->maintextBuilder[$view_name_single] = $name; } } // set the custom builder if (ComponentbuilderHelper::checkArray($custom) && $typeName != 'category' && $typeName != 'repeatable' && $typeName != 'subform') { - $this->customBuilder[$listViewName][] = array('type' => $typeName, 'code' => $name, 'lang' => $listLangName, 'custom' => $custom, 'method' => $field['settings']->store); + $this->customBuilder[$view_name_list][] = array('type' => $typeName, 'code' => $name, 'lang' => $listLangName, 'custom' => $custom, 'method' => $field['settings']->store); // set the custom fields needed in content type data - if (!isset($this->customFieldLinksBuilder[$viewName])) + if (!isset($this->customFieldLinksBuilder[$view_name_single])) { - $this->customFieldLinksBuilder[$viewName] = ''; + $this->customFieldLinksBuilder[$view_name_single] = ''; } // only load this if table is set if (isset($custom['table']) && ComponentbuilderHelper::checkString($custom['table'])) { - $this->customFieldLinksBuilder[$viewName] .= ',{"sourceColumn": "' . $name . '","targetTable": "' . $custom['table'] . '","targetColumn": "' . $custom['id'] . '","displayColumn": "' . $custom['text'] . '"}'; + $this->customFieldLinksBuilder[$view_name_single] .= ',{"sourceColumn": "' . $name . '","targetTable": "' . $custom['table'] . '","targetColumn": "' . $custom['id'] . '","displayColumn": "' . $custom['text'] . '"}'; } // build script switch for user if ($custom['extends'] === 'user') @@ -1816,24 +2499,24 @@ class Fields extends Structure // setup gategory for this view if ($typeName === 'category') { - if (isset($this->catOtherName[$listViewName]) && ComponentbuilderHelper::checkArray($this->catOtherName[$listViewName])) + if (isset($this->catOtherName[$view_name_list]) && ComponentbuilderHelper::checkArray($this->catOtherName[$view_name_list])) { - $otherViews = $this->catOtherName[$listViewName]['views']; - $otherView = $this->catOtherName[$listViewName]['view']; + $otherViews = $this->catOtherName[$view_name_list]['views']; + $otherView = $this->catOtherName[$view_name_list]['view']; } else { - $otherViews = $listViewName; - $otherView = $viewName; + $otherViews = $view_name_list; + $otherView = $view_name_single; } - $this->categoryBuilder[$listViewName] = array('code' => $name, 'name' => $listLangName); + $this->categoryBuilder[$view_name_list] = array('code' => $name, 'name' => $listLangName); // also set code name for title alias fix - $this->catCodeBuilder[$viewName] = array('code' => $name, 'views' => $otherViews, 'view' => $otherView); + $this->catCodeBuilder[$view_name_single] = array('code' => $name, 'views' => $otherViews, 'view' => $otherView); } // setup checkbox for this view if ($typeName === 'checkbox' || (ComponentbuilderHelper::checkArray($custom) && isset($custom['extends']) && $custom['extends'] === 'checkboxes')) { - $this->checkboxBuilder[$viewName][] = $name; + $this->checkboxBuilder[$view_name_single][] = $name; } // setup checkboxes and other json items for this view if (($typeName === 'subform' || $typeName === 'checkboxes' || $multiple || $field['settings']->store != 0) && $typeName != 'tag') @@ -1842,45 +2525,45 @@ class Fields extends Structure { case 1: // JSON_STRING_ENCODE - $this->jsonStringBuilder[$viewName][] = $name; + $this->jsonStringBuilder[$view_name_single][] = $name; // Site settings of each field if needed - $this->buildSiteFieldData($viewName, $name, 'json', $typeName); + $this->buildSiteFieldData($view_name_single, $name, 'json', $typeName); break; case 2: // BASE_SIXTY_FOUR - $this->base64Builder[$viewName][] = $name; + $this->base64Builder[$view_name_single][] = $name; // Site settings of each field if needed - $this->buildSiteFieldData($viewName, $name, 'base64', $typeName); + $this->buildSiteFieldData($view_name_single, $name, 'base64', $typeName); break; case 3: // BASIC_ENCRYPTION_LOCALKEY - $this->basicEncryptionBuilder[$viewName][] = $name; + $this->basicEncryptionBuilder[$view_name_single][] = $name; // Site settings of each field if needed - $this->buildSiteFieldData($viewName, $name, 'basic_encryption', $typeName); + $this->buildSiteFieldData($view_name_single, $name, 'basic_encryption', $typeName); break; case 4: // WHMCS_ENCRYPTION_VDMKEY - $this->whmcsEncryptionBuilder[$viewName][] = $name; + $this->whmcsEncryptionBuilder[$view_name_single][] = $name; // Site settings of each field if needed - $this->buildSiteFieldData($viewName, $name, 'whmcs_encryption', $typeName); + $this->buildSiteFieldData($view_name_single, $name, 'whmcs_encryption', $typeName); break; case 5: // MEDIUM_ENCRYPTION_LOCALFILE - $this->mediumEncryptionBuilder[$viewName][] = $name; + $this->mediumEncryptionBuilder[$view_name_single][] = $name; // Site settings of each field if needed - $this->buildSiteFieldData($viewName, $name, 'medium_encryption', $typeName); + $this->buildSiteFieldData($view_name_single, $name, 'medium_encryption', $typeName); break; default: // JSON_ARRAY_ENCODE - $this->jsonItemBuilder[$viewName][] = $name; + $this->jsonItemBuilder[$view_name_single][] = $name; // Site settings of each field if needed - $this->buildSiteFieldData($viewName, $name, 'json', $typeName); + $this->buildSiteFieldData($view_name_single, $name, 'json', $typeName); break; } // just a heads-up for usergroups set to multiple if ($typeName === 'usergroup') { - $this->buildSiteFieldData($viewName, $name, 'json', $typeName); + $this->buildSiteFieldData($view_name_single, $name, 'json', $typeName); } // load the json list display fix @@ -1888,47 +2571,47 @@ class Fields extends Structure { if (ComponentbuilderHelper::checkArray($options)) { - $this->getItemsMethodListStringFixBuilder[$viewName][] = array('name' => $name, 'type' => $typeName, 'translation' => true, 'custom' => $custom, 'method' => $field['settings']->store); + $this->getItemsMethodListStringFixBuilder[$view_name_single][] = array('name' => $name, 'type' => $typeName, 'translation' => true, 'custom' => $custom, 'method' => $field['settings']->store); } else { - $this->getItemsMethodListStringFixBuilder[$viewName][] = array('name' => $name, 'type' => $typeName, 'translation' => false, 'custom' => $custom, 'method' => $field['settings']->store); + $this->getItemsMethodListStringFixBuilder[$view_name_single][] = array('name' => $name, 'type' => $typeName, 'translation' => false, 'custom' => $custom, 'method' => $field['settings']->store); } } // if subform the values must revert to array if ('subform' === $typeName) { - $this->jsonItemBuilderArray[$viewName][] = $name; + $this->jsonItemBuilderArray[$view_name_single][] = $name; } } // build the data for the export & import methods $typeName === 'repeatable' || if (($typeName === 'checkboxes' || $multiple || $field['settings']->store != 0) && !ComponentbuilderHelper::checkArray($options)) { - $this->getItemsMethodEximportStringFixBuilder[$viewName][] = array('name' => $name, 'type' => $typeName, 'translation' => false, 'custom' => $custom, 'method' => $field['settings']->store); + $this->getItemsMethodEximportStringFixBuilder[$view_name_single][] = array('name' => $name, 'type' => $typeName, 'translation' => false, 'custom' => $custom, 'method' => $field['settings']->store); } // check if field should be added to uikit - $this->buildSiteFieldData($viewName, $name, 'uikit', $typeName); + $this->buildSiteFieldData($view_name_single, $name, 'uikit', $typeName); // load the selection translation fix if (ComponentbuilderHelper::checkArray($options) && (isset($field['list']) && $field['list'] == 1) && $typeName != 'repeatable' && $typeName != 'subform') { - $this->selectionTranslationFixBuilder[$listViewName][$name] = $options; + $this->selectionTranslationFixBuilder[$view_name_list][$name] = $options; } // build the sort values if ((isset($field['sort']) && $field['sort'] == 1) && (isset($field['list']) && $field['list'] == 1) && (!$multiple && $typeName != 'checkbox' && $typeName != 'checkboxes' && $typeName != 'repeatable' && $typeName != 'subform')) { - $this->sortBuilder[$listViewName][] = array('type' => $typeName, 'code' => $name, 'lang' => $listLangName, 'custom' => $custom, 'options' => $options); + $this->sortBuilder[$view_name_list][] = array('type' => $typeName, 'code' => $name, 'lang' => $listLangName, 'custom' => $custom, 'options' => $options); } // build the search values if (isset($field['search']) && $field['search'] == 1) { $_list = (isset($field['list'])) ? $field['list'] : 0; - $this->searchBuilder[$listViewName][] = array('type' => $typeName, 'code' => $name, 'custom' => $custom, 'list' => $_list); + $this->searchBuilder[$view_name_list][] = array('type' => $typeName, 'code' => $name, 'custom' => $custom, 'list' => $_list); } // build the filter values if ((isset($field['filter']) && $field['filter'] == 1) && (isset($field['list']) && $field['list'] == 1) && (!$multiple && $typeName != 'checkbox' && $typeName != 'checkboxes' && $typeName != 'repeatable' && $typeName != 'subform')) { - $this->filterBuilder[$listViewName][] = array('type' => $typeName, 'code' => $name, 'lang' => $listLangName, 'database' => $viewName, 'function' => ComponentbuilderHelper::safeString($name, 'F'), 'custom' => $custom, 'options' => $options); + $this->filterBuilder[$view_name_list][] = array('type' => $typeName, 'code' => $name, 'lang' => $listLangName, 'database' => $view_name_single, 'function' => ComponentbuilderHelper::safeString($name, 'F'), 'custom' => $custom, 'options' => $options); } // build the layout @@ -1942,10 +2625,10 @@ class Fields extends Structure // set to publishing tab $tabName = 'publishing'; } - $this->setLayoutBuilder($viewName, $tabName, $name, $field); + $this->setLayoutBuilder($view_name_single, $tabName, $name, $field); } - public function setCustomFieldTypeFile($data, $viewName_list, $viewName_single) + public function setCustomFieldTypeFile($data, $view_name_list, $view_name_single) { // make sure it is not already been build or if it is prime if ((isset($data['custom']['prime_php']) && $data['custom']['prime_php'] == 1) || !isset($this->fileContentDynamic['customfield_' . $data['type']]) || !ComponentbuilderHelper::checkArray($this->fileContentDynamic['customfield_' . $data['type']])) @@ -1967,10 +2650,10 @@ class Fields extends Structure '###CODE###' => $data['code'], '###component###' => $this->fileContentStatic['###component###'], '###Component###' => $this->fileContentStatic['###Component###'], - '###view_type###' => $viewName_single . '_' . $data['type'], + '###view_type###' => $view_name_single . '_' . $data['type'], '###type###' => $data['type'], - '###view###' => $viewName_single, - '###views###' => $viewName_list + '###view###' => $view_name_single, + '###views###' => $view_name_list ); // now load the php script if (isset($data['custom']['php']) && ComponentbuilderHelper::checkArray($data['custom']['php'])) diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index 637c38b19..a12f1d5d6 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -12902,13 +12902,23 @@ class Interpretation extends Fields $dbkey = 'g'; foreach ($this->componentData->config as $field) { - $newxmlField = $this->setDynamicField($field, $view, $viewType, $lang, $viewName, $listViewName, $placeholders, $dbkey, false); - // tmp hack untill this whole area is also done in xml (TODO) - if (isset($newxmlField->fieldXML)) + // check the field builder type + if ($this->fieldBuilderType == 1) { - $xmlField = dom_import_simplexml($newxmlField->fieldXML); - $xmlField = PHP_EOL . "\t' . PHP_EOL . "\t" . $this->xmlPrettyPrint($xmlField, 'field'); + // string manipulation + $xmlField = $this->setDynamicField($field, $view, $viewType, $lang, $viewName, $listViewName, $placeholders, $dbkey, false); } + else + { + // simpleXMLElement class + $newxmlField = $this->setDynamicField($field, $view, $viewType, $lang, $viewName, $listViewName, $placeholders, $dbkey, false); + if (isset($newxmlField->fieldXML)) + { + $xmlField = dom_import_simplexml($newxmlField->fieldXML); + $xmlField = PHP_EOL . "\t' . PHP_EOL . "\t" . $this->xmlPrettyPrint($xmlField, 'field'); + } + } + // make sure the xml is set and a string if (isset($xmlField) && ComponentbuilderHelper::checkString($xmlField)) { $this->configFieldSetsCustomField[$field['tabname']][] = $xmlField; @@ -13097,7 +13107,7 @@ class Interpretation extends Fields } } // set the fields - $this->configFieldSets[] = implode("\t\t", $bucket); + $this->configFieldSets[] = implode("", $bucket); // close field set $this->configFieldSets[] = "\t
"; // remove after loading @@ -13135,7 +13145,7 @@ class Interpretation extends Fields // add custom Target Groups fields if (isset($this->configFieldSetsCustomField['Target Groups']) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField['Target Groups'])) { - $this->configFieldSets[] = implode("\t\t", $this->configFieldSetsCustomField['Target Groups']); + $this->configFieldSets[] = implode("", $this->configFieldSetsCustomField['Target Groups']); unset($this->configFieldSetsCustomField['Target Groups']); } // close that fieldse @@ -13261,7 +13271,7 @@ class Interpretation extends Fields // add custom global fields if (isset($this->configFieldSetsCustomField['Global']) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField['Global'])) { - $this->configFieldSets[] = implode("\t\t", $this->configFieldSetsCustomField['Global']); + $this->configFieldSets[] = implode("", $this->configFieldSetsCustomField['Global']); unset($this->configFieldSetsCustomField['Global']); } // set the author details @@ -13619,7 +13629,7 @@ for developing fast and powerful web interfaces. For more info visit configFieldSetsCustomField['Uikit Settings']) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField['Uikit Settings'])) { - $this->configFieldSets[] = implode("\t\t", $this->configFieldSetsCustomField['Uikit Settings']); + $this->configFieldSets[] = implode("", $this->configFieldSetsCustomField['Uikit Settings']); unset($this->configFieldSetsCustomField['Uikit Settings']); } // close that fieldset @@ -13643,7 +13653,7 @@ for developing fast and powerful web interfaces. For more info visit configFieldSetsCustomField['Mail Configuration']) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField['Mail Configuration'])) { - $this->configFieldSets[] = implode("\t\t", $this->configFieldSetsCustomField['Mail Configuration']); + $this->configFieldSets[] = implode("", $this->configFieldSetsCustomField['Mail Configuration']); unset($this->configFieldSetsCustomField['Mail Configuration']); } else @@ -13905,7 +13915,7 @@ for developing fast and powerful web interfaces. For more info visit configFieldSetsCustomField['DKIM']) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField['DKIM'])) { - $this->configFieldSets[] = implode("\t\t", $this->configFieldSetsCustomField['DKIM']); + $this->configFieldSets[] = implode("", $this->configFieldSetsCustomField['DKIM']); unset($this->configFieldSetsCustomField['DKIM']); } else @@ -14339,7 +14349,7 @@ function vdm_dkim() { // add custom Encryption Settings fields if (isset($this->configFieldSetsCustomField['Chart Settings']) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField['Chart Settings'])) { - $this->configFieldSets[] = implode("\t\t", $this->configFieldSetsCustomField['Chart Settings']); + $this->configFieldSets[] = implode("", $this->configFieldSetsCustomField['Chart Settings']); unset($this->configFieldSetsCustomField['Chart Settings']); } @@ -14540,7 +14550,7 @@ function vdm_dkim() { // add custom Encryption Settings fields if (isset($this->configFieldSetsCustomField[$dynamicAddField]) && ComponentbuilderHelper::checkArray($this->configFieldSetsCustomField[$dynamicAddField])) { - $this->configFieldSets[] = implode("\t\t", $this->configFieldSetsCustomField[$dynamicAddField]); + $this->configFieldSets[] = implode("", $this->configFieldSetsCustomField[$dynamicAddField]); unset($this->configFieldSetsCustomField[$dynamicAddField]); } } diff --git a/admin/helpers/componentbuilder.php b/admin/helpers/componentbuilder.php index 99f458f71..13cfc4cdf 100644 --- a/admin/helpers/componentbuilder.php +++ b/admin/helpers/componentbuilder.php @@ -1554,16 +1554,19 @@ abstract class ComponentbuilderHelper } /** - * get the localkey + * the basic localkey **/ protected static $localkey = false; - + + /** + * get the localkey + **/ public static function getLocalKey() { if (!self::$localkey) { - // get the main key - self::$localkey = md5(JComponentHelper::getParams('com_componentbuilder')->get('basic_key', 'localKey34fdWEkl')); + // get the basic key + self::$localkey = md5(self::getCryptKey('basic', 'localKey34fdWEkl')); } return self::$localkey; } @@ -1636,8 +1639,18 @@ abstract class ComponentbuilderHelper } return false; } - - public static function getBetween($content,$start,$end) + + /** + * get between + * + * @param string $content The content to search + * @param string $start The starting value + * @param string $end The ending value + * + * @return string On success / empty string on failure + * + */ + public static function getBetween($content, $start, $end) { $r = explode($start, $content); if (isset($r[1])) @@ -1647,17 +1660,32 @@ abstract class ComponentbuilderHelper } return ''; } - - public static function getAllBetween($content,$start,$end) + + /** + * get all between + * + * @param string $content The content to search + * @param string $start The starting value + * @param string $end The ending value + * + * @return array On success + * + */ + public static function getAllBetween($content, $start, $end) { - $buket = array(); + // reset bucket + $bucket = array(); for ($i = 0; ; $i++) { + // search for string $found = self::getBetween($content,$start,$end); if (self::checkString($found)) { - $buket[] = $found; + // add to bucket + $bucket[] = $found; + // build removal string $remove = $start.$found.$end; + // remove from content $content = str_replace($remove,'',$content); } else @@ -1670,9 +1698,10 @@ abstract class ComponentbuilderHelper break; } } - return array_unique($buket); + // only return unique array of values + return array_unique($bucket); } - + public static function typeField($type,$option = 'default') { // list of default fields @@ -2494,6 +2523,7 @@ abstract class ComponentbuilderHelper // return the object return self::$CRYPT[$TYPE]; } + /** * Load the Component xml manifest. **/ diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.ini b/admin/language/en-GB/en-GB.com_componentbuilder.ini index 6a6303696..4b9338b4b 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.ini @@ -2270,6 +2270,8 @@ COM_COMPONENTBUILDER_CONFIG_CHECK_TIMER_OPTION_SIX="Never" COM_COMPONENTBUILDER_CONFIG_CHECK_TIMER_OPTION_THREE="Once a day" COM_COMPONENTBUILDER_CONFIG_CHECK_TIMER_OPTION_TWO="Every twelve hours" COM_COMPONENTBUILDER_CONFIG_COMPANY="Company" +COM_COMPONENTBUILDER_CONFIG_COMPILER_FIELD_BUILDER_TYPE_DESCRIPTION="Select the method to use when building the xml fields in the compiler. The SimpleXMLElement Class is best practice, and String Manipulation is faster and works without special extensions." +COM_COMPONENTBUILDER_CONFIG_COMPILER_FIELD_BUILDER_TYPE_LABEL="Field Builder Type
(in compiler)" COM_COMPONENTBUILDER_CONFIG_COMPILER_FOLDER_PATH_DESCRIPTION="Here you can set the path to the compiler folder" COM_COMPONENTBUILDER_CONFIG_COMPILER_FOLDER_PATH_HINT="/home/user/compiler" COM_COMPONENTBUILDER_CONFIG_COMPILER_FOLDER_PATH_LABEL="Compiler Folder Path" @@ -2437,6 +2439,7 @@ COM_COMPONENTBUILDER_CONFIG_SENDMAIL_HINT="/usr/sbin/sendmail" COM_COMPONENTBUILDER_CONFIG_SENDMAIL_LABEL="Sendmail Path" COM_COMPONENTBUILDER_CONFIG_SET_BROWSER_STORAGE_DESCRIPTION="Select if browser storage should be used to save on Ajax calls and speed up this components site pages." COM_COMPONENTBUILDER_CONFIG_SET_BROWSER_STORAGE_LABEL="Browser Storage" +COM_COMPONENTBUILDER_CONFIG_SIMPLEXMLELEMENT_CLASS="SimpleXMLElement Class" COM_COMPONENTBUILDER_CONFIG_SMTP="SMTP" COM_COMPONENTBUILDER_CONFIG_SMTPAUTH_DESCRIPTION="Select yes if your SMTP host requires SMTP Authentication." COM_COMPONENTBUILDER_CONFIG_SMTPAUTH_LABEL="SMTP Authentication" @@ -2456,6 +2459,7 @@ COM_COMPONENTBUILDER_CONFIG_SMTPUSER_LABEL="SMTP Username" COM_COMPONENTBUILDER_CONFIG_SSL="SSL" COM_COMPONENTBUILDER_CONFIG_STORAGE_TIME_TO_LIVE_DESCRIPTION="How long should the data that is stored in the browser memory remain unchanged before it is removed and updated." COM_COMPONENTBUILDER_CONFIG_STORAGE_TIME_TO_LIVE_LABEL="Update Cycle" +COM_COMPONENTBUILDER_CONFIG_STRING_MANIPULATION="String Manipulation" COM_COMPONENTBUILDER_CONFIG_TLS="TLS" COM_COMPONENTBUILDER_CONFIG_UIKIT_DESC="The Parameters for the uikit are set here.
Uikit is a lightweight and modular front-end framework for developing fast and powerful web interfaces. For more info visit
https://getuikit.com/v2/" diff --git a/admin/models/forms/admin_fields.xml b/admin/models/forms/admin_fields.xml index 57fb80c95..136769215 100644 --- a/admin/models/forms/admin_fields.xml +++ b/admin/models/forms/admin_fields.xml @@ -4,242 +4,277 @@ addfieldpath="/administrator/components/com_componentbuilder/models/fields" >
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +