2016-03-01 18:44:13 +00:00
< ? php
2018-05-18 06:28:27 +00:00
/**
* @ package Joomla . Component . Builder
*
* @ created 30 th April , 2015
* @ author Llewellyn van der Merwe < http :// www . joomlacomponentbuilder . com >
* @ github Joomla Component Builder < https :// github . com / vdm - io / Joomla - Component - Builder >
2019-03-04 12:47:28 +00:00
* @ copyright Copyright ( C ) 2015 - 2019 Vast Development Method . All rights reserved .
2018-05-18 06:28:27 +00:00
* @ license GNU General Public License version 2 or later ; see LICENSE . txt
*/
2016-03-01 18:44:13 +00:00
// No direct access to this file
defined ( '_JEXEC' ) or die ( 'Restricted access' );
/**
* Compiler class
*/
class Fields extends Structure
{
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Metadate Switch
*
* @ var array
*/
public $metadataBuilder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* View access Switch
*
* @ var array
*/
public $accessBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* edit view tabs counter
*
* @ var array
*/
public $tabCounter = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* layout builder
*
* @ var array
*/
public $layoutBuilder = array ();
2017-12-14 23:10:47 +00:00
2017-08-12 11:47:25 +00:00
/**
* used to fix the zero order
*
* @ var array
*/
private $zeroOrderFix = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Site field data
*
* @ var array
*/
public $siteFieldData = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* list of fields that are not being escaped
*
* @ var array
*/
public $doNotEscape = array ();
2017-12-14 23:10:47 +00:00
2018-02-27 12:17:38 +00:00
/**
* list of classes used in the list view for the fields
*
* @ var array
*/
public $listFieldClass = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* tags builder
*
* @ var array
*/
public $tagsBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* query builder
*
* @ var array
*/
public $queryBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* unique keys for database field
*
* @ var array
*/
public $dbUniqueKeys = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* keys for database field
*
* @ var array
*/
public $dbKeys = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* history builder
*
* @ var array
*/
public $historyBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* alias builder
*
* @ var array
*/
public $aliasBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* title builder
*
* @ var array
*/
public $titleBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* list builder
*
* @ var array
*/
public $listBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* custom Builder List
*
* @ var array
*/
public $customBuilderList = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Hidden Fields Builder
*
* @ var array
*/
public $hiddenFieldsBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* INT Field Builder
*
* @ var array
*/
public $intFieldsBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Dynamic Fields Builder
*
* @ var array
*/
public $dynamicfieldsBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Main text Builder
*
* @ var array
*/
public $maintextBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Custom Builder
*
* @ var array
*/
public $customBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Custom Field Links Builder
*
* @ var array
*/
public $customFieldLinksBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Set Script for User Switch
*
* @ var array
*/
public $setScriptUserSwitch = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Set Script for Media Switch
*
* @ var array
*/
public $setScriptMediaSwitch = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Category builder
*
* @ var array
*/
public $categoryBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Category Code builder
*
* @ var array
*/
public $catCodeBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Check Box builder
*
* @ var array
*/
public $checkboxBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Json String Builder
*
* @ var array
*/
public $jsonStringBuilder = array ();
2017-12-14 23:10:47 +00:00
2017-06-18 07:37:48 +00:00
/**
* Json String Builder for return values to array
*
* @ var array
*/
public $jsonItemBuilderArray = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Json Item Builder
*
* @ var array
*/
public $jsonItemBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Base 64 Builder
*
* @ var array
*/
public $base64Builder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Basic Encryption Builder
*
* @ var array
*/
public $basicEncryptionBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2018-03-06 02:28:44 +00:00
* WHMCS Encryption Builder
2016-03-01 18:44:13 +00:00
*
* @ var array
*/
2018-03-06 02:28:44 +00:00
public $whmcsEncryptionBuilder = array ();
/**
* Medium Encryption Builder
*
* @ var array
*/
public $mediumEncryptionBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Get Items Method List String Fix Builder
*
* @ var array
*/
public $getItemsMethodListStringFixBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Get Items Method Eximport String Fix Builder
*
* @ var array
*/
public $getItemsMethodEximportStringFixBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Selection Translation Fix Builder
*
* @ var array
*/
2017-12-14 23:10:47 +00:00
public $selectionTranslationFixBuilder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Sort Builder
*
* @ var array
*/
public $sortBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Search Builder
*
* @ var array
*/
public $searchBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Filter Builder
*
* @ var array
*/
public $filterBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Set Group Control
*
* @ var array
2016-03-04 00:01:43 +00:00
*/
public $setGroupControl = array ();
2017-12-14 23:10:47 +00:00
2016-06-02 16:18:49 +00:00
/**
* Set Field Names
*
* @ var array
*/
2017-12-14 23:10:47 +00:00
public $fieldsNames = array ();
2016-06-02 16:18:49 +00:00
/**
* Default Fields set to publishing
*
* @ var array
*/
public $newPublishingFields = array ();
2017-12-14 23:10:47 +00:00
2016-06-02 16:18:49 +00:00
/**
* Default Fields set to publishing
*
* @ var array
*/
public $movedPublishingFields = array ();
2017-12-14 23:10:47 +00:00
2016-09-03 21:44:47 +00:00
/**
* Set the line number in comments
*
* @ param int $nr The line number
*
* @ return void
*
*/
private function setLine ( $nr )
{
2017-04-06 08:47:51 +00:00
if ( $this -> debugLinenr )
2016-09-03 21:44:47 +00:00
{
2017-12-14 23:10:47 +00:00
return ' [Fields ' . $nr . ']' ;
2016-09-03 21:44:47 +00:00
}
return '' ;
}
2016-03-01 18:44:13 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* set the Field set of a view
*
2018-03-18 04:28:54 +00:00
* @ 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
2016-03-01 18:44:13 +00:00
*
* @ return string The fields set in xml
*
*/
2018-03-18 04:28:54 +00:00
public function setFieldSet ( $view , $component , $view_name_single , $view_name_list )
2016-03-01 18:44:13 +00:00
{
// setup the fieldset of this view
if ( isset ( $view [ 'settings' ] -> fields ) && ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> fields ))
{
// add metadata to the view
2017-10-30 13:08:02 +00:00
if ( isset ( $view [ 'metadata' ]) && $view [ 'metadata' ])
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> metadataBuilder [ $view_name_single ] = $view_name_single ;
2016-03-01 18:44:13 +00:00
}
// add access to the view
2017-10-30 13:08:02 +00:00
if ( isset ( $view [ 'access' ]) && $view [ 'access' ])
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> accessBuilder [ $view_name_single ] = $view_name_single ;
2016-03-01 18:44:13 +00:00
}
// main lang prefix
2018-05-22 19:01:36 +00:00
$langView = $this -> langPrefix . '_' . $this -> placeholders [ $this -> hhh . 'VIEW' . $this -> hhh ];
$langViews = $this -> langPrefix . '_' . $this -> placeholders [ $this -> hhh . 'VIEWS' . $this -> hhh ];
2016-03-01 18:44:13 +00:00
// set default lang
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $langView , $view [ 'settings' ] -> name_single );
$this -> setLangContent ( $this -> lang , $langViews , $view [ 'settings' ] -> name_list );
2016-03-01 18:44:13 +00:00
// set global item strings
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $langViews . '_N_ITEMS_ARCHIVED' , " %s " . $view [ 'settings' ] -> name_list . " archived. " );
$this -> setLangContent ( $this -> lang , $langViews . '_N_ITEMS_ARCHIVED_1' , " %s " . $view [ 'settings' ] -> name_single . " archived. " );
$this -> setLangContent ( $this -> lang , $langViews . '_N_ITEMS_CHECKED_IN_0' , " No " . $view [ 'settings' ] -> name_single . " successfully checked in. " );
$this -> setLangContent ( $this -> lang , $langViews . '_N_ITEMS_CHECKED_IN_1' , " %d " . $view [ 'settings' ] -> name_single . " successfully checked in. " );
$this -> setLangContent ( $this -> lang , $langViews . '_N_ITEMS_CHECKED_IN_MORE' , " %d " . $view [ 'settings' ] -> name_list . " successfully checked in. " );
$this -> setLangContent ( $this -> lang , $langViews . '_N_ITEMS_DELETED' , " %s " . $view [ 'settings' ] -> name_list . " deleted. " );
$this -> setLangContent ( $this -> lang , $langViews . '_N_ITEMS_DELETED_1' , " %s " . $view [ 'settings' ] -> name_single . " deleted. " );
$this -> setLangContent ( $this -> lang , $langViews . '_N_ITEMS_FEATURED' , " %s " . $view [ 'settings' ] -> name_list . " featured. " );
$this -> setLangContent ( $this -> lang , $langViews . '_N_ITEMS_FEATURED_1' , " %s " . $view [ 'settings' ] -> name_single . " featured. " );
$this -> setLangContent ( $this -> lang , $langViews . '_N_ITEMS_PUBLISHED' , " %s " . $view [ 'settings' ] -> name_list . " published. " );
$this -> setLangContent ( $this -> lang , $langViews . '_N_ITEMS_PUBLISHED_1' , " %s " . $view [ 'settings' ] -> name_single . " published. " );
$this -> setLangContent ( $this -> lang , $langViews . '_N_ITEMS_TRASHED' , " %s " . $view [ 'settings' ] -> name_list . " trashed. " );
$this -> setLangContent ( $this -> lang , $langViews . '_N_ITEMS_TRASHED_1' , " %s " . $view [ 'settings' ] -> name_single . " trashed. " );
$this -> setLangContent ( $this -> lang , $langViews . '_N_ITEMS_UNFEATURED' , " %s " . $view [ 'settings' ] -> name_list . " unfeatured. " );
$this -> setLangContent ( $this -> lang , $langViews . '_N_ITEMS_UNFEATURED_1' , " %s " . $view [ 'settings' ] -> name_single . " unfeatured. " );
$this -> setLangContent ( $this -> lang , $langViews . '_N_ITEMS_UNPUBLISHED' , " %s " . $view [ 'settings' ] -> name_list . " unpublished. " );
$this -> setLangContent ( $this -> lang , $langViews . '_N_ITEMS_UNPUBLISHED_1' , " %s " . $view [ 'settings' ] -> name_single . " unpublished. " );
$this -> setLangContent ( $this -> lang , $langViews . '_BATCH_OPTIONS' , " Batch process the selected " . $view [ 'settings' ] -> name_list );
$this -> setLangContent ( $this -> lang , $langViews . '_BATCH_TIP' , " All changes will be applied to all selected " . $view [ 'settings' ] -> name_list );
2016-03-01 18:44:13 +00:00
// set some basic defaults
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $langView . '_ERROR_UNIQUE_ALIAS' , " Another " . $view [ 'settings' ] -> name_single . " has the same alias. " );
$this -> setLangContent ( $this -> lang , $langView . '_CREATED_DATE_LABEL' , " Created Date " );
$this -> setLangContent ( $this -> lang , $langView . '_CREATED_DATE_DESC' , " The date this " . $view [ 'settings' ] -> name_single . " was created. " );
$this -> setLangContent ( $this -> lang , $langView . '_MODIFIED_DATE_LABEL' , " Modified Date " );
$this -> setLangContent ( $this -> lang , $langView . '_MODIFIED_DATE_DESC' , " The date this " . $view [ 'settings' ] -> name_single . " was modified. " );
$this -> setLangContent ( $this -> lang , $langView . '_CREATED_BY_LABEL' , " Created By " );
$this -> setLangContent ( $this -> lang , $langView . '_CREATED_BY_DESC' , " The user that created this " . $view [ 'settings' ] -> name_single . " . " );
$this -> setLangContent ( $this -> lang , $langView . '_MODIFIED_BY_LABEL' , " Modified By " );
$this -> setLangContent ( $this -> lang , $langView . '_MODIFIED_BY_DESC' , " The last user that modified this " . $view [ 'settings' ] -> name_single . " . " );
$this -> setLangContent ( $this -> lang , $langView . '_ORDERING_LABEL' , " Ordering " );
$this -> setLangContent ( $this -> lang , $langView . '_VERSION_LABEL' , " Revision " );
$this -> setLangContent ( $this -> lang , $langView . '_VERSION_DESC' , " A count of the number of times this " . $view [ 'settings' ] -> name_single . " has been revised. " );
$this -> setLangContent ( $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. " );
2018-03-18 04:28:54 +00:00
// check what type of field builder to use
if ( $this -> fieldBuilderType == 1 )
{
// build field set using string manipulation
return $this -> stringFieldSet ( $view , $component , $view_name_single , $view_name_list , $langView , $langViews );
}
else
{
// build field set with simpleXMLElement class
return $this -> simpleXMLFieldSet ( $view , $component , $view_name_single , $view_name_list , $langView , $langViews );
}
2016-03-01 18:44:13 +00:00
}
return '' ;
}
2017-12-03 17:08:01 +00:00
2018-03-18 04:28:54 +00:00
/**
* 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 )
{
2018-05-26 10:03:08 +00:00
$readOnly = $this -> _t ( 3 ) . 'readonly="true"' . PHP_EOL . $this -> _t ( 3 ) . 'disabled="true"' ;
2018-03-18 04:28:54 +00:00
}
// start adding dynamc fields
$dynamicFields = '' ;
// set the custom table key
$dbkey = 'g' ;
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onBeforeBuildFields
2019-07-01 16:10:28 +00:00
$this -> triggerEvent ( 'jcb_ce_onBeforeBuildFields' , array ( & $this -> componentContext , & $dynamicFields , & $readOnly , & $dbkey , & $view , & $component , & $view_name_single , & $view_name_list , & $this -> placeholders , & $langView , & $langViews ));
2018-03-18 04:28:54 +00:00
// 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 );
}
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onAfterBuildFields
2019-07-01 16:10:28 +00:00
$this -> triggerEvent ( 'jcb_ce_onAfterBuildFields' , array ( & $this -> componentContext , & $dynamicFields , & $readOnly , & $dbkey , & $view , & $component , & $view_name_single , & $view_name_list , & $this -> placeholders , & $langView , & $langViews ));
2018-03-18 04:28:54 +00:00
// set the default fields
$fieldSet = array ();
$fieldSet [] = '<fieldset name="details">' ;
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 2 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " Default Fields. --> " ;
$fieldSet [] = $this -> _t ( 2 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " Id Field. Type: Text (joomla) --> " ;
2018-03-18 04:28:54 +00:00
// if id is not set
if ( ! isset ( $this -> fieldsNames [ $view_name_single ][ 'id' ]))
{
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 2 ) . " <field " ;
$fieldSet [] = $this -> _t ( 3 ) . " name= " . '"id"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'type="text" class="readonly" label="JGLOBAL_FIELD_ID_LABEL"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'description ="JGLOBAL_FIELD_ID_DESC" size="10" default="0"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'readonly="true"' ;
$fieldSet [] = $this -> _t ( 2 ) . " /> " ;
2018-03-18 04:28:54 +00:00
// count the static field created
$this -> fieldCount ++ ;
}
// if created is not set
if ( ! isset ( $this -> fieldsNames [ $view_name_single ][ 'created' ]))
{
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 2 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " Date Created Field. Type: Calendar (joomla) --> " ;
$fieldSet [] = $this -> _t ( 2 ) . " <field " ;
$fieldSet [] = $this -> _t ( 3 ) . " name= " . '"created"' ;
$fieldSet [] = $this -> _t ( 3 ) . " type= " . '"calendar"' ;
$fieldSet [] = $this -> _t ( 3 ) . " label= " . '"' . $langView . '_CREATED_DATE_LABEL"' ;
$fieldSet [] = $this -> _t ( 3 ) . " description= " . '"' . $langView . '_CREATED_DATE_DESC"' ;
$fieldSet [] = $this -> _t ( 3 ) . " size= " . '"22"' ;
2018-03-18 04:28:54 +00:00
if ( $readOnly )
{
$fieldSet [] = $readOnly ;
}
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 3 ) . " format= " . '"%Y-%m-%d %H:%M:%S"' ;
$fieldSet [] = $this -> _t ( 3 ) . " filter= " . '"user_utc"' ;
$fieldSet [] = $this -> _t ( 2 ) . " /> " ;
2018-03-18 04:28:54 +00:00
// count the static field created
$this -> fieldCount ++ ;
}
// if created_by is not set
if ( ! isset ( $this -> fieldsNames [ $view_name_single ][ 'created_by' ]))
{
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 2 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " User Created Field. Type: User (joomla) --> " ;
$fieldSet [] = $this -> _t ( 2 ) . " <field " ;
$fieldSet [] = $this -> _t ( 3 ) . " name= " . '"created_by"' ;
$fieldSet [] = $this -> _t ( 3 ) . " type= " . '"user"' ;
$fieldSet [] = $this -> _t ( 3 ) . " label= " . '"' . $langView . '_CREATED_BY_LABEL"' ;
2018-03-18 04:28:54 +00:00
if ( $readOnly )
{
$fieldSet [] = $readOnly ;
}
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 3 ) . " description= " . '"' . $langView . '_CREATED_BY_DESC"' ;
$fieldSet [] = $this -> _t ( 2 ) . " /> " ;
2018-03-18 04:28:54 +00:00
// count the static field created
$this -> fieldCount ++ ;
}
// if published is not set
if ( ! isset ( $this -> fieldsNames [ $view_name_single ][ 'published' ]))
{
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 2 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " Published Field. Type: List (joomla) --> " ;
$fieldSet [] = $this -> _t ( 2 ) . " <field name= " . '"published" type="list" label="JSTATUS"' ;
$fieldSet [] = $this -> _t ( 3 ) . " description= " . '"JFIELD_PUBLISHED_DESC" class="chzn-color-state"' ;
2018-03-18 04:28:54 +00:00
if ( $readOnly )
{
$fieldSet [] = $readOnly ;
}
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 3 ) . " filter= " . '"intval" size="1" default="1" >' ;
$fieldSet [] = $this -> _t ( 3 ) . " <option value= " . '"1">' ;
$fieldSet [] = $this -> _t ( 4 ) . " JPUBLISHED</option> " ;
$fieldSet [] = $this -> _t ( 3 ) . " <option value= " . '"0">' ;
$fieldSet [] = $this -> _t ( 4 ) . " JUNPUBLISHED</option> " ;
$fieldSet [] = $this -> _t ( 3 ) . " <option value= " . '"2">' ;
$fieldSet [] = $this -> _t ( 4 ) . " JARCHIVED</option> " ;
$fieldSet [] = $this -> _t ( 3 ) . " <option value= " . '"-2">' ;
$fieldSet [] = $this -> _t ( 4 ) . " JTRASHED</option> " ;
$fieldSet [] = $this -> _t ( 2 ) . " </field> " ;
2018-03-18 04:28:54 +00:00
// count the static field created
$this -> fieldCount ++ ;
}
// if modified is not set
if ( ! isset ( $this -> fieldsNames [ $view_name_single ][ 'modified' ]))
{
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 2 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " Date Modified Field. Type: Calendar (joomla) --> " ;
$fieldSet [] = $this -> _t ( 2 ) . '<field name="modified" type="calendar" class="readonly"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'label="' . $langView . '_MODIFIED_DATE_LABEL" description="' . $langView . '_MODIFIED_DATE_DESC"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />' ;
2018-03-18 04:28:54 +00:00
// count the static field created
$this -> fieldCount ++ ;
}
// if modified_by is not set
if ( ! isset ( $this -> fieldsNames [ $view_name_single ][ 'modified_by' ]))
{
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 2 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " User Modified Field. Type: User (joomla) --> " ;
$fieldSet [] = $this -> _t ( 2 ) . '<field name="modified_by" type="user"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'label="' . $langView . '_MODIFIED_BY_LABEL"' ;
$fieldSet [] = $this -> _t ( 3 ) . " description= " . '"' . $langView . '_MODIFIED_BY_DESC"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'class="readonly"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'readonly="true"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'filter="unset"' ;
$fieldSet [] = $this -> _t ( 2 ) . " /> " ;
2018-03-18 04:28:54 +00:00
// 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' ]))
{
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 2 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " Access Field. Type: Accesslevel (joomla) --> " ;
$fieldSet [] = $this -> _t ( 2 ) . '<field name="access"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'type="accesslevel"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'label="JFIELD_ACCESS_LABEL"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'description="JFIELD_ACCESS_DESC"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'default="1"' ;
2018-03-18 04:28:54 +00:00
if ( $readOnly )
{
$fieldSet [] = $readOnly ;
}
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 3 ) . 'required="false"' ;
$fieldSet [] = $this -> _t ( 2 ) . " /> " ;
2018-03-18 04:28:54 +00:00
// count the static field created
$this -> fieldCount ++ ;
}
// if ordering is not set
if ( ! isset ( $this -> fieldsNames [ $view_name_single ][ 'ordering' ]))
{
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 2 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " Ordering Field. Type: Numbers (joomla) --> " ;
$fieldSet [] = $this -> _t ( 2 ) . " <field " ;
$fieldSet [] = $this -> _t ( 3 ) . 'name="ordering"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'type="number"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'class="inputbox validate-ordering"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'label="' . $langView . '_ORDERING_LABEL' . '"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'description=""' ;
$fieldSet [] = $this -> _t ( 3 ) . 'default="0"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'size="6"' ;
2018-03-18 04:28:54 +00:00
if ( $readOnly )
{
$fieldSet [] = $readOnly ;
}
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 3 ) . 'required="false"' ;
$fieldSet [] = $this -> _t ( 2 ) . " /> " ;
2018-03-18 04:28:54 +00:00
// count the static field created
$this -> fieldCount ++ ;
}
// if version is not set
if ( ! isset ( $this -> fieldsNames [ $view_name_single ][ 'version' ]))
{
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 2 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " Version Field. Type: Text (joomla) --> " ;
$fieldSet [] = $this -> _t ( 2 ) . " <field " ;
$fieldSet [] = $this -> _t ( 3 ) . 'name="version"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'type="text"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'class="readonly"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'label="' . $langView . '_VERSION_LABEL"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'description="' . $langView . '_VERSION_DESC"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'size="6"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'readonly="true"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'filter="unset"' ;
$fieldSet [] = $this -> _t ( 2 ) . " /> " ;
2018-03-18 04:28:54 +00:00
// 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
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 2 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " Metakey Field. Type: Textarea (joomla) --> " ;
$fieldSet [] = $this -> _t ( 2 ) . " <field " ;
$fieldSet [] = $this -> _t ( 3 ) . 'name="metakey"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'type="textarea"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'label="JFIELD_META_KEYWORDS_LABEL"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'description="JFIELD_META_KEYWORDS_DESC"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'rows="3"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'cols="30"' ;
$fieldSet [] = $this -> _t ( 2 ) . " /> " ;
2018-03-18 04:28:54 +00:00
// count the static field created
$this -> fieldCount ++ ;
// metadesc
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 2 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " Metadesc Field. Type: Textarea (joomla) --> " ;
$fieldSet [] = $this -> _t ( 2 ) . " <field " ;
$fieldSet [] = $this -> _t ( 3 ) . 'name="metadesc"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'type="textarea"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'label="JFIELD_META_DESCRIPTION_LABEL"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'description="JFIELD_META_DESCRIPTION_DESC"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'rows="3"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'cols="30"' ;
$fieldSet [] = $this -> _t ( 2 ) . " /> " ;
2018-03-18 04:28:54 +00:00
// count the static field created
$this -> fieldCount ++ ;
}
// load the dynamic fields now
if ( ComponentbuilderHelper :: checkString ( $dynamicFields ))
{
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 2 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " Dynamic Fields. --> " . $dynamicFields ;
2018-03-18 04:28:54 +00:00
}
// close fieldset
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 1 ) . " </fieldset> " ;
2018-03-18 04:28:54 +00:00
// check if metadata is added to this view
if ( isset ( $this -> metadataBuilder [ $view_name_single ]) && ComponentbuilderHelper :: checkString ( $this -> metadataBuilder [ $view_name_single ]))
{
2018-05-26 10:03:08 +00:00
$fieldSet [] = PHP_EOL . $this -> _t ( 1 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " Metadata Fields. --> " ;
$fieldSet [] = $this -> _t ( 1 ) . " <fields " . ' name="metadata" label="JGLOBAL_FIELDSET_METADATA_OPTIONS">' ;
$fieldSet [] = $this -> _t ( 2 ) . '<fieldset name="vdmmetadata"' ;
$fieldSet [] = $this -> _t ( 3 ) . 'label="JGLOBAL_FIELDSET_METADATA_OPTIONS">' ;
2018-03-18 04:28:54 +00:00
// robots
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 3 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " Robots Field. Type: List (joomla) --> " ;
$fieldSet [] = $this -> _t ( 3 ) . '<field name="robots"' ;
$fieldSet [] = $this -> _t ( 4 ) . 'type="list"' ;
$fieldSet [] = $this -> _t ( 4 ) . 'label="JFIELD_METADATA_ROBOTS_LABEL"' ;
$fieldSet [] = $this -> _t ( 4 ) . 'description="JFIELD_METADATA_ROBOTS_DESC" >' ;
$fieldSet [] = $this -> _t ( 4 ) . '<option value="">JGLOBAL_USE_GLOBAL</option>' ;
$fieldSet [] = $this -> _t ( 4 ) . '<option value="index, follow">JGLOBAL_INDEX_FOLLOW</option>' ;
$fieldSet [] = $this -> _t ( 4 ) . '<option value="noindex, follow">JGLOBAL_NOINDEX_FOLLOW</option>' ;
$fieldSet [] = $this -> _t ( 4 ) . '<option value="index, nofollow">JGLOBAL_INDEX_NOFOLLOW</option>' ;
$fieldSet [] = $this -> _t ( 4 ) . '<option value="noindex, nofollow">JGLOBAL_NOINDEX_NOFOLLOW</option>' ;
$fieldSet [] = $this -> _t ( 3 ) . '</field>' ;
2018-03-18 04:28:54 +00:00
// count the static field created
$this -> fieldCount ++ ;
// author
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 3 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " Author Field. Type: Text (joomla) --> " ;
$fieldSet [] = $this -> _t ( 3 ) . '<field name="author"' ;
$fieldSet [] = $this -> _t ( 4 ) . 'type="text"' ;
$fieldSet [] = $this -> _t ( 4 ) . 'label="JAUTHOR" description="JFIELD_METADATA_AUTHOR_DESC"' ;
$fieldSet [] = $this -> _t ( 4 ) . 'size="20"' ;
$fieldSet [] = $this -> _t ( 3 ) . " /> " ;
2018-03-18 04:28:54 +00:00
// count the static field created
$this -> fieldCount ++ ;
// rights
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 3 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " Rights Field. Type: Textarea (joomla) --> " ;
$fieldSet [] = $this -> _t ( 3 ) . '<field name="rights" type="textarea" label="JFIELD_META_RIGHTS_LABEL"' ;
$fieldSet [] = $this -> _t ( 4 ) . 'description="JFIELD_META_RIGHTS_DESC" required="false" filter="string"' ;
$fieldSet [] = $this -> _t ( 4 ) . 'cols="30" rows="2"' ;
$fieldSet [] = $this -> _t ( 3 ) . " /> " ;
2018-03-18 04:28:54 +00:00
// count the static field created
$this -> fieldCount ++ ;
2018-05-26 10:03:08 +00:00
$fieldSet [] = $this -> _t ( 2 ) . " </fieldset> " ;
$fieldSet [] = $this -> _t ( 1 ) . " </fields> " ;
2018-03-18 04:28:54 +00:00
}
// 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' ;
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onBeforeBuildFields
2019-07-01 16:10:28 +00:00
$this -> triggerEvent ( 'jcb_ce_onBeforeBuildFields' , array ( & $this -> componentContext , & $dynamicFieldsXML , & $readOnlyXML , & $dbkey , & $view , & $component , & $view_name_single , & $view_name_list , & $this -> placeholders , & $langView , & $langViews ));
2018-03-18 04:28:54 +00:00
// 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 );
}
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onAfterBuildFields
2019-07-01 16:10:28 +00:00
$this -> triggerEvent ( 'jcb_ce_onAfterBuildFields' , array ( & $this -> componentContext , & $dynamicFieldsXML , & $readOnlyXML , & $dbkey , & $view , & $component , & $view_name_single , & $view_name_list , & $this -> placeholders , & $langView , & $langViews ));
2018-03-18 04:28:54 +00:00
// set the default fields
$XML = new simpleXMLElement ( '<a/>' );
$fieldSetXML = $XML -> addChild ( 'fieldset' );
$fieldSetXML -> addAttribute ( 'name' , 'details' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlComment ( $fieldSetXML , $this -> setLine ( __LINE__ ) . " Default Fields. " );
ComponentbuilderHelper :: xmlComment ( $fieldSetXML , $this -> setLine ( __LINE__ ) . " Id Field. Type: Text (joomla) " );
2018-03-18 04:28:54 +00:00
// if id is not set
if ( ! isset ( $this -> fieldsNames [ $view_name_single ][ 'id' ]))
{
$attributes = array (
'name' => 'id' ,
'type' => 'text' ,
'class' => 'readonly' ,
2018-07-21 07:10:37 +00:00
'readonly' => " true " ,
2018-03-18 04:28:54 +00:00
'label' => 'JGLOBAL_FIELD_ID_LABEL' ,
'description' => 'JGLOBAL_FIELD_ID_DESC' ,
'size' => 10 ,
'default' => 0
);
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// 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 );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlComment ( $fieldSetXML , $this -> setLine ( __LINE__ ) . " Date Created Field. Type: Calendar (joomla) " );
2018-03-18 04:28:54 +00:00
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// 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 );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlComment ( $fieldSetXML , $this -> setLine ( __LINE__ ) . " User Created Field. Type: User (joomla) " );
2018-03-18 04:28:54 +00:00
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// 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 );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlComment ( $fieldSetXML , $this -> setLine ( __LINE__ ) . " Published Field. Type: List (joomla) " );
2018-03-18 04:28:54 +00:00
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// 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'
);
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlComment ( $fieldSetXML , $this -> setLine ( __LINE__ ) . " Date Modified Field. Type: Calendar (joomla) " );
2018-03-18 04:28:54 +00:00
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// 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'
);
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlComment ( $fieldSetXML , $this -> setLine ( __LINE__ ) . " User Modified Field. Type: User (joomla) " );
2018-03-18 04:28:54 +00:00
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// 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 );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlComment ( $fieldSetXML , $this -> setLine ( __LINE__ ) . " Access Field. Type: Accesslevel (joomla) " );
2018-03-18 04:28:54 +00:00
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// 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 );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlComment ( $fieldSetXML , $this -> setLine ( __LINE__ ) . " Ordering Field. Type: Numbers (joomla) " );
2018-03-18 04:28:54 +00:00
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// 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'
);
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlComment ( $fieldSetXML , $this -> setLine ( __LINE__ ) . " Version Field. Type: Text (joomla) " );
2018-03-18 04:28:54 +00:00
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// 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
);
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlComment ( $fieldSetXML , $this -> setLine ( __LINE__ ) . " Metakey Field. Type: Textarea (joomla) " );
2018-03-18 04:28:54 +00:00
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// count the static field created
$this -> fieldCount ++ ;
// metadesc
$attributes [ 'name' ] = 'metadesc' ;
$attributes [ 'label' ] = 'JFIELD_META_DESCRIPTION_LABEL' ;
$attributes [ 'description' ] = 'JFIELD_META_DESCRIPTION_DESC' ;
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlComment ( $fieldSetXML , $this -> setLine ( __LINE__ ) . " Metadesc Field. Type: Textarea (joomla) " );
2018-03-18 04:28:54 +00:00
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// count the static field created
$this -> fieldCount ++ ;
}
// load the dynamic fields now
if ( count ( $dynamicFieldsXML ))
{
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlComment ( $fieldSetXML , $this -> setLine ( __LINE__ ) . " Dynamic Fields. " );
2018-03-18 04:28:54 +00:00
foreach ( $dynamicFieldsXML as $dynamicfield )
{
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAppend ( $fieldSetXML , $dynamicfield );
2018-03-18 04:28:54 +00:00
}
}
// check if metadata is added to this view
if ( isset ( $this -> metadataBuilder [ $view_name_single ]) && ComponentbuilderHelper :: checkString ( $this -> metadataBuilder [ $view_name_single ]))
{
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlComment ( $fieldSetXML , $this -> setLine ( __LINE__ ) . " Metadata Fields " );
2018-03-18 04:28:54 +00:00
$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
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlComment ( $fieldsFieldSetXML , $this -> setLine ( __LINE__ ) . " Robots Field. Type: List (joomla) " );
2018-03-18 04:28:54 +00:00
$robots = $fieldsFieldSetXML -> addChild ( 'field' );
$attributes = array (
'name' => 'robots' ,
'type' => 'list' ,
'label' => 'JFIELD_METADATA_ROBOTS_LABEL' ,
'description' => 'JFIELD_METADATA_ROBOTS_DESC'
);
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $robots , $attributes );
2018-03-18 04:28:54 +00:00
// 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
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlComment ( $fieldsFieldSetXML , $this -> setLine ( __LINE__ ) . " Author Field. Type: Text (joomla) " );
2018-03-18 04:28:54 +00:00
$author = $fieldsFieldSetXML -> addChild ( 'field' );
$attributes = array (
'name' => 'author' ,
'type' => 'text' ,
'label' => 'JAUTHOR' ,
'description' => 'JFIELD_METADATA_AUTHOR_DESC' ,
'size' => 20
);
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $author , $attributes );
2018-03-18 04:28:54 +00:00
// count the static field created
$this -> fieldCount ++ ;
// rights
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlComment ( $fieldsFieldSetXML , $this -> setLine ( __LINE__ ) . " Rights Field. Type: Textarea (joomla) " );
2018-03-18 04:28:54 +00:00
$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
);
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $rights , $attributes );
2018-03-18 04:28:54 +00:00
// count the static field created
$this -> fieldCount ++ ;
}
// return the set
return $this -> xmlPrettyPrint ( $XML , 'fieldset' );
}
2016-06-02 16:18:49 +00:00
/**
* set Field Names
2017-12-03 17:08:01 +00:00
*
2016-06-02 16:18:49 +00:00
* @ param string $view View the field belongs to
* @ param string $name The name of the field
*
2017-12-03 17:08:01 +00:00
*
2016-06-02 16:18:49 +00:00
*/
public function setFieldsNames ( & $view , & $name )
{
$this -> fieldsNames [ $view ][ $name ] = $name ;
}
2016-03-01 18:44:13 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* set Dynamic field
2017-12-03 17:08:01 +00:00
*
2018-03-18 04:28:54 +00:00
* @ 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
2016-03-01 18:44:13 +00:00
*
2017-12-03 17:08:01 +00:00
* @ return SimpleXMLElement The complete field in xml
*
2016-03-01 18:44:13 +00:00
*/
2018-03-18 04:28:54 +00:00
public function setDynamicField ( & $field , & $view , & $viewType , & $langView , & $view_name_single , & $view_name_list , & $placeholders , & $dbkey , $build )
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
// set default return
if ( $this -> fieldBuilderType == 1 )
{
// string manipulation
$dynamicField = '' ;
}
else
{
// simpleXMLElement class
$dynamicField = false ;
}
// make sure we have settings
2016-06-23 15:05:37 +00:00
if ( isset ( $field [ 'settings' ]) && ComponentbuilderHelper :: checkObject ( $field [ 'settings' ]))
2016-03-01 18:44:13 +00:00
{
2017-12-03 17:08:01 +00:00
// reset some values
2018-03-18 04:28:54 +00:00
$name = $this -> getFieldName ( $field , $view_name_list );
2018-03-11 02:44:43 +00:00
$typeName = $this -> getFieldType ( $field );
2016-06-23 15:05:37 +00:00
$multiple = false ;
$langLabel = '' ;
$fieldSet = '' ;
2017-12-03 17:08:01 +00:00
$fieldAttributes = array ();
2016-06-23 15:05:37 +00:00
// set field attributes
2018-03-18 04:28:54 +00:00
$fieldAttributes = $this -> setFieldAttributes ( $field , $viewType , $name , $typeName , $multiple , $langLabel , $langView , $view_name_list , $view_name_single , $placeholders );
2016-06-23 15:05:37 +00:00
// check if values were set
if ( ComponentbuilderHelper :: checkArray ( $fieldAttributes ))
2016-03-01 18:44:13 +00:00
{
2016-06-23 15:05:37 +00:00
// set the array of field names
2018-03-18 04:28:54 +00:00
$this -> setFieldsNames ( $view_name_single , $fieldAttributes [ 'name' ]);
2017-12-14 23:10:47 +00:00
2018-05-24 13:56:56 +00:00
if ( ComponentbuilderHelper :: fieldCheck ( $typeName , 'option' ))
2016-03-01 18:44:13 +00:00
{
2016-06-23 15:05:37 +00:00
//reset options array
$optionArray = array ();
// now add to the field set
2018-03-18 04:28:54 +00:00
$dynamicField = $this -> setField ( 'option' , $fieldAttributes , $name , $typeName , $langView , $view_name_single , $view_name_list , $placeholders , $optionArray );
2016-06-23 15:05:37 +00:00
if ( $build )
{
// set builders
2018-03-18 04:28:54 +00:00
$this -> setBuilders ( $langLabel , $langView , $view_name_single , $view_name_list , $name , $view , $field , $typeName , $multiple , false , $optionArray );
2016-06-23 15:05:37 +00:00
}
2016-03-01 18:44:13 +00:00
}
2018-05-24 13:56:56 +00:00
elseif ( ComponentbuilderHelper :: fieldCheck ( $typeName , 'spacer' ))
2016-03-01 18:44:13 +00:00
{
2016-06-23 15:05:37 +00:00
if ( $build )
2016-03-01 18:44:13 +00:00
{
2016-06-23 15:05:37 +00:00
// make sure spacers gets loaded to layout
$tabName = '' ;
if ( isset ( $view [ 'settings' ] -> tabs ) && isset ( $view [ 'settings' ] -> tabs [( int ) $field [ 'tab' ]]))
{
$tabName = $view [ 'settings' ] -> tabs [( int ) $field [ 'tab' ]];
}
elseif (( int ) $field [ 'tab' ] == 15 )
{
// set to publishing tab
$tabName = 'publishing' ;
}
2018-03-18 04:28:54 +00:00
$this -> setLayoutBuilder ( $view_name_single , $tabName , $name , $field );
2016-03-01 18:44:13 +00:00
}
2016-06-23 15:05:37 +00:00
// now add to the field set
2018-03-18 04:28:54 +00:00
$dynamicField = $this -> setField ( 'spacer' , $fieldAttributes , $name , $typeName , $langView , $view_name_single , $view_name_list , $placeholders , $optionArray );
2016-03-01 18:44:13 +00:00
}
2018-05-24 13:56:56 +00:00
elseif ( ComponentbuilderHelper :: fieldCheck ( $typeName , 'special' ))
2016-03-01 18:44:13 +00:00
{
2017-06-18 07:37:48 +00:00
// set the repeatable field or subform field
if ( $typeName === 'repeatable' || $typeName === 'subform' )
2016-06-23 15:05:37 +00:00
{
if ( $build )
{
// set builders
2018-03-18 04:28:54 +00:00
$this -> setBuilders ( $langLabel , $langView , $view_name_single , $view_name_list , $name , $view , $field , $typeName , $multiple , false );
2016-06-23 15:05:37 +00:00
}
// now add to the field set
2018-03-18 04:28:54 +00:00
$dynamicField = $this -> setField ( 'special' , $fieldAttributes , $name , $typeName , $langView , $view_name_single , $view_name_list , $placeholders , $optionArray );
2016-06-23 15:05:37 +00:00
}
2016-03-01 18:44:13 +00:00
}
2019-07-28 21:48:42 +00:00
elseif ( isset ( $fieldAttributes [ 'custom' ]) && ComponentbuilderHelper :: checkArray ( $fieldAttributes [ 'custom' ]))
2016-03-01 18:44:13 +00:00
{
2016-06-23 15:05:37 +00:00
// set the custom array
$custom = $fieldAttributes [ 'custom' ];
unset ( $fieldAttributes [ 'custom' ]);
// set db key
$custom [ 'db' ] = $dbkey ;
// increment the db key
$dbkey ++ ;
2016-03-01 18:44:13 +00:00
if ( $build )
{
// set builders
2018-03-18 04:28:54 +00:00
$this -> setBuilders ( $langLabel , $langView , $view_name_single , $view_name_list , $name , $view , $field , $typeName , $multiple , $custom );
2016-03-01 18:44:13 +00:00
}
// now add to the field set
2018-03-18 04:28:54 +00:00
$dynamicField = $this -> setField ( 'custom' , $fieldAttributes , $name , $typeName , $langView , $view_name_single , $view_name_list , $placeholders , $optionArray , $custom );
2016-03-01 18:44:13 +00:00
}
2019-07-15 20:03:57 +00:00
else
{
if ( $build )
{
// set builders
$this -> setBuilders ( $langLabel , $langView , $view_name_single , $view_name_list , $name , $view , $field , $typeName , $multiple );
}
// now add to the field set
$dynamicField = $this -> setField ( 'plain' , $fieldAttributes , $name , $typeName , $langView , $view_name_single , $view_name_list , $placeholders , $optionArray );
}
2016-03-01 18:44:13 +00:00
}
}
2018-03-18 04:28:54 +00:00
return $dynamicField ;
2016-03-01 18:44:13 +00:00
}
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* set a field
*
2018-03-18 04:28:54 +00:00
* @ 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 , & $view_name_single , & $view_name_list , $placeholders , & $optionArray , $custom = null , $taber = '' )
{
2018-03-18 04:52:07 +00:00
// count the dynamic fields created
$this -> fieldCount ++ ;
2018-03-18 04:28:54 +00:00
// 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
2019-07-04 23:53:54 +00:00
$field .= PHP_EOL . $this -> _t ( 1 ) . $taber . $this -> _t ( 1 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " " . ucfirst ( $name ) . " Field. Type: " . ComponentbuilderHelper :: safeString ( $typeName , 'F' ) . " . (joomla) --> " ;
2018-05-26 10:03:08 +00:00
$field .= PHP_EOL . $this -> _t ( 1 ) . $taber . $this -> _t ( 1 ) . " <field " ;
2018-03-18 04:28:54 +00:00
$optionSet = '' ;
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
2018-05-26 10:03:08 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . $taber . $this -> _t ( 1 ) . $property . '="' . $value . '"' ;
2018-03-18 04:28:54 +00:00
}
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 );
2019-07-04 23:53:54 +00:00
$langValue = $langView . '_' . ComponentbuilderHelper :: safeFieldName ( $t , true );
2018-03-18 04:28:54 +00:00
// add to lang array
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $langValue , $t );
2018-03-18 04:28:54 +00:00
// no add to option set
2018-05-26 10:03:08 +00:00
$optionSet .= PHP_EOL . $this -> _t ( 1 ) . $taber . $this -> _t ( 2 ) . '<option value="' . $v . '">' . PHP_EOL . $this -> _t ( 1 ) . $taber . $this -> _t ( 3 ) . $langValue . '</option>' ;
2018-03-18 04:28:54 +00:00
$optionArray [ $v ] = $langValue ;
}
else
{
// text is also the value
2019-07-04 23:53:54 +00:00
$langValue = $langView . '_' . ComponentbuilderHelper :: safeFieldName ( $option , true );
2018-03-18 04:28:54 +00:00
// add to lang array
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $langValue , $option );
2018-03-18 04:28:54 +00:00
// no add to option set
2018-05-26 10:03:08 +00:00
$optionSet .= PHP_EOL . $this -> _t ( 2 ) . $taber . $this -> _t ( 1 ) . '<option value="' . $option . '">' . PHP_EOL . $this -> _t ( 2 ) . $taber . $this -> _t ( 2 ) . $langValue . '</option>' ;
2018-03-18 04:28:54 +00:00
$optionArray [ $option ] = $langValue ;
}
}
}
else
{
// one option
if ( strpos ( $value , '|' ) !== false )
{
// has other value then text
list ( $v , $t ) = explode ( '|' , $value );
2019-07-04 23:53:54 +00:00
$langValue = $langView . '_' . ComponentbuilderHelper :: safeFieldName ( $t , true );
2018-03-18 04:28:54 +00:00
// add to lang array
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $langValue , $t );
2018-03-18 04:28:54 +00:00
// no add to option set
2018-05-26 10:03:08 +00:00
$optionSet .= PHP_EOL . $this -> _t ( 2 ) . $taber . $this -> _t ( 1 ) . '<option value="' . $v . '">' . PHP_EOL . $this -> _t ( 2 ) . $taber . $this -> _t ( 2 ) . $langValue . '</option>' ;
2018-03-18 04:28:54 +00:00
$optionArray [ $v ] = $langValue ;
}
else
{
// text is also the value
2019-07-04 23:53:54 +00:00
$langValue = $langView . '_' . ComponentbuilderHelper :: safeFieldName ( $value , true );
2018-03-18 04:28:54 +00:00
// add to lang array
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $langValue , $value );
2018-03-18 04:28:54 +00:00
// no add to option set
2018-05-26 10:03:08 +00:00
$optionSet .= PHP_EOL . $this -> _t ( 2 ) . $taber . $this -> _t ( 1 ) . '<option value="' . $value . '">' . PHP_EOL . $this -> _t ( 2 ) . $taber . $this -> _t ( 2 ) . $langValue . '</option>' ;
2018-03-18 04:28:54 +00:00
$optionArray [ $value ] = $langValue ;
}
}
}
}
2019-03-05 07:51:52 +00:00
// if options were found
2018-03-18 04:28:54 +00:00
if ( ComponentbuilderHelper :: checkString ( $optionSet ))
{
$field .= '>' ;
2018-05-26 10:03:08 +00:00
$field .= PHP_EOL . $this -> _t ( 3 ) . $taber . " <!-- " . $this -> setLine ( __LINE__ ) . " Option Set. --> " ;
2018-03-18 04:28:54 +00:00
$field .= $optionSet ;
2018-05-26 10:03:08 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . $taber . " </field> " ;
2018-03-18 04:28:54 +00:00
}
2019-03-05 07:51:52 +00:00
// if no options found and must have a list of options
elseif ( ComponentbuilderHelper :: fieldCheck ( $typeName , 'list' ))
2018-03-18 04:28:54 +00:00
{
$optionArray = false ;
2018-05-26 10:03:08 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . $taber . " /> " ;
2019-03-05 07:51:52 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . $taber . " <!-- " . $this -> setLine ( __LINE__ ) . " No Manual Options Were Added In Field Settings. --> " . PHP_EOL ;
2018-03-18 04:28:54 +00:00
}
else
{
$optionArray = false ;
2018-05-26 10:03:08 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . $taber . " /> " ;
2018-03-18 04:28:54 +00:00
}
}
elseif ( $setType === 'plain' )
{
// now add to the field set
2019-07-04 23:53:54 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . $taber . " <!-- " . $this -> setLine ( __LINE__ ) . " " . ucfirst ( $name ) . " Field. Type: " . ComponentbuilderHelper :: safeString ( $typeName , 'F' ) . " . (joomla) --> " ;
2018-05-26 10:03:08 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . $taber . " <field " ;
2018-03-18 04:28:54 +00:00
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
2018-05-26 10:03:08 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . $taber . $this -> _t ( 1 ) . $property . '="' . $value . '"' ;
2018-03-18 04:28:54 +00:00
}
}
2018-05-26 10:03:08 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . $taber . " /> " ;
2018-03-18 04:28:54 +00:00
}
elseif ( $setType === 'spacer' )
{
// now add to the field set
2019-07-04 23:53:54 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " " . ucfirst ( $name ) . " Field. Type: " . ComponentbuilderHelper :: safeString ( $typeName , 'F' ) . " . A None Database Field. (joomla) --> " ;
2018-05-26 10:03:08 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . " <field " ;
2018-03-18 04:28:54 +00:00
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
$field .= " " . $property . '="' . $value . '"' ;
}
}
$field .= " /> " ;
}
elseif ( $setType === 'special' )
{
// set the repeatable field
if ( $typeName === 'repeatable' )
{
// now add to the field set
2019-07-04 23:53:54 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . " <!-- " . $this -> setLine ( __LINE__ ) . " " . ucfirst ( $name ) . " Field. Type: " . ComponentbuilderHelper :: safeString ( $typeName , 'F' ) . " . (joomla) --> " ;
2018-05-26 10:03:08 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . " <field " ;
2018-03-18 04:28:54 +00:00
$fieldsSet = array ();
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'fields' )
{
2018-05-26 10:03:08 +00:00
$field .= PHP_EOL . $this -> _t ( 3 ) . $property . '="' . $value . '"' ;
2018-03-18 04:28:54 +00:00
}
}
$field .= " > " ;
2018-05-26 10:03:08 +00:00
$field .= PHP_EOL . $this -> _t ( 3 ) . '<fields name="' . $fieldAttributes [ 'name' ] . '_fields" label="">' ;
$field .= PHP_EOL . $this -> _t ( 4 ) . '<fieldset hidden="true" name="' . $fieldAttributes [ 'name' ] . '_modal" repeat="true">' ;
2018-03-18 04:28:54 +00:00
if ( strpos ( $fieldAttributes [ 'fields' ], ',' ) !== false )
{
// mulitpal fields
$fieldsSets = ( array ) explode ( ',' , $fieldAttributes [ 'fields' ]);
}
elseif ( is_numeric ( $fieldAttributes [ 'fields' ]))
{
// single field
$fieldsSets [] = ( int ) $fieldAttributes [ 'fields' ];
}
// only continue if we have a field set
if ( ComponentbuilderHelper :: checkArray ( $fieldsSets ))
{
2018-10-01 02:16:24 +00:00
// set the resolver
$_resolverKey = $fieldAttributes [ 'name' ];
// load the field data
$fieldsSets = array_map ( function ( $id ) use ( $view_name_single , $view_name_list , $_resolverKey ) {
// start field
$field = array ();
$field [ 'field' ] = $id ;
// set the field details
$this -> setFieldDetails ( $field , $view_name_single , $view_name_list , $_resolverKey );
// return field
return $field ;
}, array_values ( $fieldsSets ));
// start the build
foreach ( $fieldsSets as $fieldData )
2018-03-18 04:28:54 +00:00
{
2018-10-01 02:16:24 +00:00
// if we have settings continue
2018-03-18 04:28:54 +00:00
if ( ComponentbuilderHelper :: checkObject ( $fieldData [ 'settings' ]))
{
2018-10-01 02:16:24 +00:00
$r_name = $this -> getFieldName ( $fieldData , $view_name_list , $_resolverKey );
2018-03-18 04:28:54 +00:00
$r_typeName = $this -> getFieldType ( $fieldData );
$r_multiple = false ;
$r_langLabel = '' ;
// add the tabs needed
2018-05-26 10:03:08 +00:00
$r_taber = $this -> _t ( 3 );
2018-03-18 04:28:54 +00:00
// get field values
2018-03-18 21:07:18 +00:00
$r_fieldValues = $this -> setFieldAttributes ( $fieldData , $view , $r_name , $r_typeName , $r_multiple , $r_langLabel , $langView , $view_name_list , $view_name_single , $placeholders , true );
2018-03-18 04:28:54 +00:00
// check if values were set
if ( ComponentbuilderHelper :: checkArray ( $r_fieldValues ))
{
//reset options array
$r_optionArray = array ();
2018-05-24 13:56:56 +00:00
if ( ComponentbuilderHelper :: fieldCheck ( $r_typeName , 'option' ))
2018-03-18 04:28:54 +00:00
{
// now add to the field set
$field .= $this -> setField ( 'option' , $r_fieldValues , $r_name , $r_typeName , $langView , $view_name_single , $view_name_list , $placeholders , $r_optionArray , null , $r_taber );
}
2019-07-28 21:48:42 +00:00
elseif ( isset ( $r_fieldValues [ 'custom' ]) && ComponentbuilderHelper :: checkArray ( $r_fieldValues [ 'custom' ]))
2018-03-18 04:28:54 +00:00
{
// add to custom
$custom = $r_fieldValues [ 'custom' ];
unset ( $r_fieldValues [ 'custom' ]);
// now add to the field set
$field .= $this -> setField ( 'custom' , $r_fieldValues , $r_name , $r_typeName , $langView , $view_name_single , $view_name_list , $placeholders , $r_optionArray , null , $r_taber );
// set lang (just incase)
2019-07-04 23:53:54 +00:00
$r_listLangName = $langView . '_' . ComponentbuilderHelper :: safeFieldName ( $r_name , true );
2018-03-18 04:28:54 +00:00
// add to lang array
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $r_listLangName , ComponentbuilderHelper :: safeString ( $r_name , 'W' ));
2018-03-18 04:28:54 +00:00
// if label was set use instead
if ( ComponentbuilderHelper :: checkString ( $r_langLabel ))
{
$r_listLangName = $r_langLabel ;
}
// 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 , $view_name_list , $view_name_single );
}
2019-07-19 02:17:15 +00:00
else
{
// now add to the field set
$field .= $this -> setField ( 'plain' , $r_fieldValues , $r_name , $r_typeName , $langView , $view_name_single , $view_name_list , $placeholders , $r_optionArray , null , $r_taber );
}
2018-03-18 04:28:54 +00:00
}
}
}
}
2018-05-26 10:03:08 +00:00
$field .= PHP_EOL . $this -> _t ( 4 ) . " </fieldset> " ;
$field .= PHP_EOL . $this -> _t ( 3 ) . " </fields> " ;
$field .= PHP_EOL . $this -> _t ( 2 ) . " </field> " ;
2018-03-18 04:28:54 +00:00
}
// set the subform fields (it is a repeatable without the modal)
elseif ( $typeName === 'subform' )
{
// now add to the field set
2019-07-04 23:53:54 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . $taber . " <!-- " . $this -> setLine ( __LINE__ ) . " " . ucfirst ( $name ) . " Field. Type: " . ComponentbuilderHelper :: safeString ( $typeName , 'F' ) . " . (joomla) --> " ;
2019-01-14 15:32:23 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . $taber . " <field " ;
2018-03-18 04:28:54 +00:00
$fieldsSet = array ();
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'fields' )
{
2019-01-14 15:32:23 +00:00
$field .= PHP_EOL . $this -> _t ( 3 ) . $taber . $property . '="' . $value . '"' ;
2018-03-18 04:28:54 +00:00
}
}
$field .= " > " ;
2019-01-14 15:32:23 +00:00
$field .= PHP_EOL . $this -> _t ( 3 ) . $taber . '<form hidden="true" name="list_' . $fieldAttributes [ 'name' ] . '_modal" repeat="true">' ;
2018-03-18 04:28:54 +00:00
if ( strpos ( $fieldAttributes [ 'fields' ], ',' ) !== false )
{
// mulitpal fields
$fieldsSets = ( array ) explode ( ',' , $fieldAttributes [ 'fields' ]);
}
elseif ( is_numeric ( $fieldAttributes [ 'fields' ]))
{
// single field
$fieldsSets [] = ( int ) $fieldAttributes [ 'fields' ];
}
// only continue if we have a field set
if ( ComponentbuilderHelper :: checkArray ( $fieldsSets ))
{
2018-10-01 02:16:24 +00:00
// set the resolver
$_resolverKey = $fieldAttributes [ 'name' ];
// load the field data
$fieldsSets = array_map ( function ( $id ) use ( $view_name_single , $view_name_list , $_resolverKey ) {
// start field
$field = array ();
$field [ 'field' ] = $id ;
// set the field details
$this -> setFieldDetails ( $field , $view_name_single , $view_name_list , $_resolverKey );
// return field
return $field ;
}, array_values ( $fieldsSets ));
// start the build
foreach ( $fieldsSets as $fieldData )
2018-03-18 04:28:54 +00:00
{
2018-10-01 02:16:24 +00:00
// if we have settings continue
2018-03-18 04:28:54 +00:00
if ( ComponentbuilderHelper :: checkObject ( $fieldData [ 'settings' ]))
{
2018-10-01 02:16:24 +00:00
$r_name = $this -> getFieldName ( $fieldData , $view_name_list , $_resolverKey );
2018-03-18 04:28:54 +00:00
$r_typeName = $this -> getFieldType ( $fieldData );
$r_multiple = false ;
$r_langLabel = '' ;
// add the tabs needed
2019-01-14 15:32:23 +00:00
$r_taber = $this -> _t ( 2 ) . $taber ;
2018-03-18 04:28:54 +00:00
// get field values
2018-03-18 21:07:18 +00:00
$r_fieldValues = $this -> setFieldAttributes ( $fieldData , $view , $r_name , $r_typeName , $r_multiple , $r_langLabel , $langView , $view_name_list , $view_name_single , $placeholders , true );
2018-03-18 04:28:54 +00:00
// check if values were set
if ( ComponentbuilderHelper :: checkArray ( $r_fieldValues ))
{
//reset options array
$r_optionArray = array ();
2018-05-24 13:56:56 +00:00
if ( ComponentbuilderHelper :: fieldCheck ( $r_typeName , 'option' ))
2018-03-18 04:28:54 +00:00
{
// now add to the field set
$field .= $this -> setField ( 'option' , $r_fieldValues , $r_name , $r_typeName , $langView , $view_name_single , $view_name_list , $placeholders , $r_optionArray , null , $r_taber );
}
2019-01-14 15:32:23 +00:00
elseif ( $r_typeName === 'subform' )
{
// set nested depth
if ( isset ( $fieldAttributes [ 'nested_depth' ]))
{
$r_fieldValues [ 'nested_depth' ] = ++ $fieldAttributes [ 'nested_depth' ];
}
else
{
$r_fieldValues [ 'nested_depth' ] = 1 ;
}
// only continue if nest is bellow 20 (this should be a safe limit)
if ( $r_fieldValues [ 'nested_depth' ] <= 20 )
{
// now add to the field set
$field .= $this -> setField ( 'special' , $r_fieldValues , $r_name , $r_typeName , $langView , $view_name_single , $view_name_list , $placeholders , $r_optionArray , null , $r_taber );
}
}
2019-07-28 21:48:42 +00:00
elseif ( isset ( $r_fieldValues [ 'custom' ]) && ComponentbuilderHelper :: checkArray ( $r_fieldValues [ 'custom' ]))
2018-03-18 04:28:54 +00:00
{
// add to custom
$custom = $r_fieldValues [ 'custom' ];
unset ( $r_fieldValues [ 'custom' ]);
// now add to the field set
$field .= $this -> setField ( 'custom' , $r_fieldValues , $r_name , $r_typeName , $langView , $view_name_single , $view_name_list , $placeholders , $r_optionArray , null , $r_taber );
// set lang (just incase)
2019-07-04 23:53:54 +00:00
$r_listLangName = $langView . '_' . ComponentbuilderHelper :: safeFieldName ( $r_name , true );
2018-03-18 04:28:54 +00:00
// add to lang array
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $r_listLangName , ComponentbuilderHelper :: safeString ( $r_name , 'W' ));
2018-03-18 04:28:54 +00:00
// if label was set use instead
if ( ComponentbuilderHelper :: checkString ( $r_langLabel ))
{
$r_listLangName = $r_langLabel ;
}
// 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 , $view_name_list , $view_name_single );
}
2019-07-19 02:17:15 +00:00
else
{
// now add to the field set
$field .= $this -> setField ( 'plain' , $r_fieldValues , $r_name , $r_typeName , $langView , $view_name_single , $view_name_list , $placeholders , $r_optionArray , null , $r_taber );
}
2018-03-18 04:28:54 +00:00
}
}
}
}
2019-01-14 15:32:23 +00:00
$field .= PHP_EOL . $this -> _t ( 3 ) . $taber . " </form> " ;
$field .= PHP_EOL . $this -> _t ( 2 ) . $taber . " </field> " ;
2018-03-18 04:28:54 +00:00
}
}
elseif ( $setType === 'custom' )
{
// now add to the field set
2019-07-04 23:53:54 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . $taber . " <!-- " . $this -> setLine ( __LINE__ ) . " " . ucfirst ( $name ) . " Field. Type: " . ComponentbuilderHelper :: safeString ( $typeName , 'F' ) . " . (custom) --> " ;
2018-05-26 10:03:08 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . $taber . " <field " ;
2018-03-18 04:28:54 +00:00
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
2018-05-26 10:03:08 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . $taber . $this -> _t ( 1 ) . $property . '="' . $value . '"' ;
2018-03-18 04:28:54 +00:00
}
}
2018-05-26 10:03:08 +00:00
$field .= PHP_EOL . $this -> _t ( 2 ) . $taber . " /> " ;
2018-03-18 04:28:54 +00:00
// 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 );
}
}
// 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
2017-12-03 17:08:01 +00:00
*
* @ return SimpleXMLElement The field in xml
*
2016-03-01 18:44:13 +00:00
*/
2018-03-18 04:28:54 +00:00
protected function simpleXMLSetField ( $setType , & $fieldAttributes , & $name , & $typeName , & $langView , & $view_name_single , & $view_name_list , $placeholders , & $optionArray , $custom = null )
2016-03-01 18:44:13 +00:00
{
2017-12-04 14:56:18 +00:00
$field = new stdClass ();
2017-02-01 13:17:04 +00:00
if ( $setType === 'option' )
2016-03-01 18:44:13 +00:00
{
// now add to the field set
2017-12-04 14:56:18 +00:00
$field -> fieldXML = new SimpleXMLElement ( '<field/>' );
2019-07-04 23:53:54 +00:00
$field -> comment = $this -> setLine ( __LINE__ ) . " " . ucfirst ( $name ) . " Field. Type: " . ComponentbuilderHelper :: safeString ( $typeName , 'F' ) . " . (joomla) " ;
2017-12-03 17:08:01 +00:00
2016-03-01 18:44:13 +00:00
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
2017-12-04 14:56:18 +00:00
$field -> fieldXML -> addAttribute ( $property , $value );
2016-03-01 18:44:13 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $property === 'option' )
2016-03-01 18:44:13 +00:00
{
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlComment ( $field -> fieldXML , $this -> setLine ( __LINE__ ) . " Option Set. " );
2016-03-01 18:44:13 +00:00
if ( strpos ( $value , ',' ) !== false )
{
// mulitpal options
$options = explode ( ',' , $value );
foreach ( $options as $option )
{
2017-12-04 14:56:18 +00:00
$optionXML = $field -> fieldXML -> addChild ( 'option' );
2016-03-01 18:44:13 +00:00
if ( strpos ( $option , '|' ) !== false )
{
// has other value then text
list ( $v , $t ) = explode ( '|' , $option );
2019-07-04 23:53:54 +00:00
$langValue = $langView . '_' . ComponentbuilderHelper :: safeFieldName ( $t , true );
2016-03-01 18:44:13 +00:00
// add to lang array
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $langValue , $t );
2016-03-01 18:44:13 +00:00
// no add to option set
2017-12-03 17:08:01 +00:00
$optionXML -> addAttribute ( 'value' , $v );
2016-03-01 18:44:13 +00:00
$optionArray [ $v ] = $langValue ;
}
else
{
// text is also the value
2019-07-04 23:53:54 +00:00
$langValue = $langView . '_' . ComponentbuilderHelper :: safeFieldName ( $option , true );
2016-03-01 18:44:13 +00:00
// add to lang array
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $langValue , $option );
2016-03-01 18:44:13 +00:00
// no add to option set
2017-12-03 17:08:01 +00:00
$optionXML -> addAttribute ( 'value' , $option );
2016-03-01 18:44:13 +00:00
$optionArray [ $option ] = $langValue ;
}
2017-12-03 17:08:01 +00:00
$optionXML [] = $langValue ;
2016-03-01 18:44:13 +00:00
}
}
else
{
// one option
2017-12-04 14:56:18 +00:00
$optionXML = $field -> fieldXML -> addChild ( 'option' );
2016-03-01 18:44:13 +00:00
if ( strpos ( $value , '|' ) !== false )
{
// has other value then text
list ( $v , $t ) = explode ( '|' , $value );
2019-07-04 23:53:54 +00:00
$langValue = $langView . '_' . ComponentbuilderHelper :: safeFieldName ( $t , true );
2016-03-01 18:44:13 +00:00
// add to lang array
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $langValue , $t );
2016-03-01 18:44:13 +00:00
// no add to option set
2017-12-03 17:08:01 +00:00
$optionXML -> addAttribute ( 'value' , $v );
2016-03-01 18:44:13 +00:00
$optionArray [ $v ] = $langValue ;
}
else
{
// text is also the value
2019-07-04 23:53:54 +00:00
$langValue = $langView . '_' . ComponentbuilderHelper :: safeFieldName ( $value , true );
2016-03-01 18:44:13 +00:00
// add to lang array
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $langValue , $value );
2016-03-01 18:44:13 +00:00
// no add to option set
2017-12-03 17:08:01 +00:00
$optionXML -> addAttribute ( 'value' , $value );
2016-03-01 18:44:13 +00:00
$optionArray [ $value ] = $langValue ;
}
2017-12-03 17:08:01 +00:00
$optionXML [] = $langValue ;
2016-03-01 18:44:13 +00:00
}
}
}
2019-03-05 07:51:52 +00:00
// if no options found and must have a list of options
if ( ! $field -> fieldXML -> count () && ComponentbuilderHelper :: fieldCheck ( $typeName , 'list' ))
2016-03-01 18:44:13 +00:00
{
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlComment ( $field -> fieldXML , $this -> setLine ( __LINE__ ) . " No Manual Options Were Added In Field Settings. " );
2016-03-01 18:44:13 +00:00
}
}
2017-02-01 13:17:04 +00:00
elseif ( $setType === 'plain' )
2016-03-01 18:44:13 +00:00
{
// now add to the field set
2017-12-04 14:56:18 +00:00
$field -> fieldXML = new SimpleXMLElement ( '<field/>' );
2019-07-04 23:53:54 +00:00
$field -> comment = $this -> setLine ( __LINE__ ) . " " . ucfirst ( $name ) . " Field. Type: " . ComponentbuilderHelper :: safeString ( $typeName , 'F' ) . " . (joomla) " ;
2017-12-03 17:08:01 +00:00
2016-03-01 18:44:13 +00:00
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
2017-12-04 14:56:18 +00:00
$field -> fieldXML -> addAttribute ( $property , $value );
2016-03-01 18:44:13 +00:00
}
}
}
2017-02-01 13:17:04 +00:00
elseif ( $setType === 'spacer' )
2016-03-01 18:44:13 +00:00
{
// now add to the field set
2017-12-04 14:56:18 +00:00
$field -> fieldXML = new SimpleXMLElement ( '<field/>' );
2019-07-04 23:53:54 +00:00
$field -> comment = $this -> setLine ( __LINE__ ) . " " . ucfirst ( $name ) . " Field. Type: " . ComponentbuilderHelper :: safeString ( $typeName , 'F' ) . " . A None Database Field. (joomla) " ;
2017-12-03 17:08:01 +00:00
2016-03-01 18:44:13 +00:00
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
2017-12-04 14:56:18 +00:00
$field -> fieldXML -> addAttribute ( $property , $value );
2016-03-01 18:44:13 +00:00
}
}
}
2017-02-01 13:17:04 +00:00
elseif ( $setType === 'special' )
2016-03-01 18:44:13 +00:00
{
// set the repeatable field
2017-02-01 13:17:04 +00:00
if ( $typeName === 'repeatable' )
2016-03-01 18:44:13 +00:00
{
// now add to the field set
2017-12-04 14:56:18 +00:00
$field -> fieldXML = new SimpleXMLElement ( '<field/>' );
2019-07-04 23:53:54 +00:00
$field -> comment = $this -> setLine ( __LINE__ ) . " " . ucfirst ( $name ) . " Field. Type: " . ComponentbuilderHelper :: safeString ( $typeName , 'F' ) . " . (depreciated) " ;
2017-12-03 17:08:01 +00:00
2016-03-01 18:44:13 +00:00
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'fields' )
{
2017-12-04 14:56:18 +00:00
$field -> fieldXML -> addAttribute ( $property , $value );
2016-03-01 18:44:13 +00:00
}
}
2017-12-04 14:56:18 +00:00
$fieldsXML = $field -> fieldXML -> addChild ( 'fields' );
2017-12-03 17:08:01 +00:00
$fieldsXML -> addAttribute ( 'name' , $fieldAttributes [ 'name' ] . '_fields' );
$fieldsXML -> addAttribute ( 'label' , '' );
$fieldSetXML = $fieldsXML -> addChild ( 'fieldset' );
$fieldSetXML -> addAttribute ( 'hidden' , 'true' );
$fieldSetXML -> addAttribute ( 'name' , $fieldAttributes [ 'name' ] . '_modal' );
$fieldSetXML -> addAttribute ( 'repeat' , 'true' );
2016-03-01 18:44:13 +00:00
if ( strpos ( $fieldAttributes [ 'fields' ], ',' ) !== false )
{
// mulitpal fields
2017-03-31 21:28:16 +00:00
$fieldsSets = ( array ) explode ( ',' , $fieldAttributes [ 'fields' ]);
2016-03-01 18:44:13 +00:00
}
2017-03-31 21:28:16 +00:00
elseif ( is_numeric ( $fieldAttributes [ 'fields' ]))
2016-03-01 18:44:13 +00:00
{
// single field
2017-03-31 21:28:16 +00:00
$fieldsSets [] = ( int ) $fieldAttributes [ 'fields' ];
2016-03-01 18:44:13 +00:00
}
// only continue if we have a field set
if ( ComponentbuilderHelper :: checkArray ( $fieldsSets ))
{
2018-10-01 02:16:24 +00:00
// set the resolver
$_resolverKey = $fieldAttributes [ 'name' ];
// load the field data
$fieldsSets = array_map ( function ( $id ) use ( $view_name_single , $view_name_list , $_resolverKey ) {
// start field
$field = array ();
$field [ 'field' ] = $id ;
// set the field details
$this -> setFieldDetails ( $field , $view_name_single , $view_name_list , $_resolverKey );
// return field
return $field ;
}, array_values ( $fieldsSets ));
// start the build
foreach ( $fieldsSets as $fieldData )
2016-03-01 18:44:13 +00:00
{
2018-10-01 02:16:24 +00:00
// if we have settings continue
2016-03-01 18:44:13 +00:00
if ( ComponentbuilderHelper :: checkObject ( $fieldData [ 'settings' ]))
{
2018-10-01 02:16:24 +00:00
$r_name = $this -> getFieldName ( $fieldData , $view_name_list , $_resolverKey );
2018-03-11 02:44:43 +00:00
$r_typeName = $this -> getFieldType ( $fieldData );
2016-03-01 18:44:13 +00:00
$r_multiple = false ;
$r_langLabel = '' ;
// get field values
2018-03-18 04:28:54 +00:00
$r_fieldValues = $this -> setFieldAttributes ( $fieldData , $view , $r_name , $r_typeName , $r_multiple , $r_langLabel , $langView , $view_name_list , $view_name_single , $placeholders , true );
2016-03-01 18:44:13 +00:00
// check if values were set
if ( ComponentbuilderHelper :: checkArray ( $r_fieldValues ))
{
//reset options array
$r_optionArray = array ();
2018-05-24 13:56:56 +00:00
if ( ComponentbuilderHelper :: fieldCheck ( $r_typeName , 'option' ))
2016-03-01 18:44:13 +00:00
{
// now add to the field set
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAppend ( $fieldSetXML , $this -> setField ( 'option' , $r_fieldValues , $r_name , $r_typeName , $langView , $view_name_single , $view_name_list , $placeholders , $r_optionArray ));
2016-03-01 18:44:13 +00:00
}
2019-07-28 21:48:42 +00:00
elseif ( isset ( $r_fieldValues [ 'custom' ]) && ComponentbuilderHelper :: checkArray ( $r_fieldValues [ 'custom' ]))
2016-03-01 18:44:13 +00:00
{
// add to custom
$custom = $r_fieldValues [ 'custom' ];
unset ( $r_fieldValues [ 'custom' ]);
// now add to the field set
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAppend ( $fieldSetXML , $this -> setField ( 'custom' , $r_fieldValues , $r_name , $r_typeName , $langView , $view_name_single , $view_name_list , $placeholders , $r_optionArray ));
2016-03-01 18:44:13 +00:00
// set lang (just incase)
2019-07-04 23:53:54 +00:00
$r_listLangName = $langView . '_' . ComponentbuilderHelper :: safeFieldName ( $r_name , true );
2016-03-01 18:44:13 +00:00
// add to lang array
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $r_listLangName , ComponentbuilderHelper :: safeString ( $r_name , 'W' ));
2016-03-01 18:44:13 +00:00
// if label was set use instead
if ( ComponentbuilderHelper :: checkString ( $r_langLabel ))
{
$r_listLangName = $r_langLabel ;
}
// set the custom array
$data = array ( 'type' => $r_typeName , 'code' => $r_name , 'lang' => $r_listLangName , 'custom' => $custom );
// set the custom field file
2018-03-18 04:28:54 +00:00
$this -> setCustomFieldTypeFile ( $data , $view_name_list , $view_name_single );
2016-03-01 18:44:13 +00:00
}
2019-07-28 21:48:42 +00:00
else
{
// now add to the field set
ComponentbuilderHelper :: xmlAppend ( $fieldSetXML , $this -> setField ( 'plain' , $r_fieldValues , $r_name , $r_typeName , $langView , $view_name_single , $view_name_list , $placeholders , $r_optionArray ));
}
2016-03-01 18:44:13 +00:00
}
}
}
}
}
2017-12-03 17:08:01 +00:00
// set the subform fields (it is a repeatable without the modal)
2017-06-18 07:37:48 +00:00
elseif ( $typeName === 'subform' )
{
// now add to the field set
2017-12-04 14:56:18 +00:00
$field -> fieldXML = new SimpleXMLElement ( '<field/>' );
2019-07-04 23:53:54 +00:00
$field -> comment = $this -> setLine ( __LINE__ ) . " " . ucfirst ( $name ) . " Field. Type: " . ComponentbuilderHelper :: safeString ( $typeName , 'F' ) . " . (joomla) " ;
2017-12-04 14:56:18 +00:00
// add all properties
2017-06-18 07:37:48 +00:00
foreach ( $fieldAttributes as $property => $value )
{
2017-12-03 18:09:04 +00:00
if ( $property != 'fields' && $property != 'formsource' )
2017-06-18 07:37:48 +00:00
{
2017-12-04 14:56:18 +00:00
$field -> fieldXML -> addAttribute ( $property , $value );
2017-06-18 07:37:48 +00:00
}
}
2017-12-03 18:09:04 +00:00
// if we detect formsource we do not add the form
if ( isset ( $fieldAttributes [ 'formsource' ]) && ComponentbuilderHelper :: checkString ( $fieldAttributes [ 'formsource' ]))
2017-06-18 07:37:48 +00:00
{
2017-12-04 14:56:18 +00:00
$field -> fieldXML -> addAttribute ( 'formsource' , $fieldAttributes [ 'formsource' ]);
2017-06-18 07:37:48 +00:00
}
2017-12-04 14:56:18 +00:00
// add the form
2017-12-03 18:09:04 +00:00
else
2017-06-18 07:37:48 +00:00
{
2017-12-04 14:56:18 +00:00
$form = $field -> fieldXML -> addChild ( 'form' );
2017-12-03 17:08:01 +00:00
$attributes = array (
2017-12-14 23:10:47 +00:00
'hidden' => 'true' ,
'name' => 'list_' . $fieldAttributes [ 'name' ] . '_modal' ,
'repeat' => 'true'
2017-12-03 17:08:01 +00:00
);
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $form , $attributes );
2017-12-03 17:08:01 +00:00
2017-12-03 18:09:04 +00:00
if ( strpos ( $fieldAttributes [ 'fields' ], ',' ) !== false )
2017-06-18 07:37:48 +00:00
{
2017-12-03 17:08:01 +00:00
// multiple fields
2017-12-03 18:09:04 +00:00
$fieldsSets = ( array ) explode ( ',' , $fieldAttributes [ 'fields' ]);
}
elseif ( is_numeric ( $fieldAttributes [ 'fields' ]))
{
// single field
$fieldsSets [] = ( int ) $fieldAttributes [ 'fields' ];
}
// only continue if we have a field set
if ( ComponentbuilderHelper :: checkArray ( $fieldsSets ))
{
2018-10-01 02:16:24 +00:00
// set the resolver
$_resolverKey = $fieldAttributes [ 'name' ];
// load the field data
$fieldsSets = array_map ( function ( $id ) use ( $view_name_single , $view_name_list , $_resolverKey ) {
// start field
$field = array ();
$field [ 'field' ] = $id ;
// set the field details
$this -> setFieldDetails ( $field , $view_name_single , $view_name_list , $_resolverKey );
// return field
return $field ;
}, array_values ( $fieldsSets ));
// start the build
foreach ( $fieldsSets as $fieldData )
2017-06-18 07:37:48 +00:00
{
2018-10-01 02:16:24 +00:00
// if we have settings continue
2017-12-03 18:09:04 +00:00
if ( ComponentbuilderHelper :: checkObject ( $fieldData [ 'settings' ]))
2017-06-18 07:37:48 +00:00
{
2018-10-01 02:16:24 +00:00
$r_name = $this -> getFieldName ( $fieldData , $view_name_list , $_resolverKey );
2018-03-11 02:44:43 +00:00
$r_typeName = $this -> getFieldType ( $fieldData );
2017-12-03 18:09:04 +00:00
$r_multiple = false ;
$r_langLabel = '' ;
// get field values
2018-03-18 04:28:54 +00:00
$r_fieldValues = $this -> setFieldAttributes ( $fieldData , $view , $r_name , $r_typeName , $r_multiple , $r_langLabel , $langView , $view_name_list , $view_name_single , $placeholders , true );
2017-12-03 18:09:04 +00:00
// check if values were set
if ( ComponentbuilderHelper :: checkArray ( $r_fieldValues ))
2017-06-18 07:37:48 +00:00
{
2017-12-03 18:09:04 +00:00
//reset options array
$r_optionArray = array ();
2018-05-24 13:56:56 +00:00
if ( ComponentbuilderHelper :: fieldCheck ( $r_typeName , 'option' ))
2017-06-18 07:37:48 +00:00
{
2017-12-03 18:09:04 +00:00
// now add to the field set
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAppend ( $form , $this -> setField ( 'option' , $r_fieldValues , $r_name , $r_typeName , $langView , $view_name_single , $view_name_list , $placeholders , $r_optionArray ));
2017-12-03 18:09:04 +00:00
}
2019-01-14 15:32:23 +00:00
elseif ( $r_typeName === 'subform' )
{
// set nested depth
if ( isset ( $fieldAttributes [ 'nested_depth' ]))
{
$r_fieldValues [ 'nested_depth' ] = ++ $fieldAttributes [ 'nested_depth' ];
}
else
{
$r_fieldValues [ 'nested_depth' ] = 1 ;
}
// only continue if nest is bellow 20 (this should be a safe limit)
if ( $r_fieldValues [ 'nested_depth' ] <= 20 )
{
// now add to the field set
ComponentbuilderHelper :: xmlAppend ( $form , $this -> setField ( 'special' , $r_fieldValues , $r_name , $r_typeName , $langView , $view_name_single , $view_name_list , $placeholders , $r_optionArray ));
}
}
2019-07-28 21:48:42 +00:00
elseif ( isset ( $r_fieldValues [ 'custom' ]) && ComponentbuilderHelper :: checkArray ( $r_fieldValues [ 'custom' ]))
2017-12-03 18:09:04 +00:00
{
// add to custom
$custom = $r_fieldValues [ 'custom' ];
unset ( $r_fieldValues [ 'custom' ]);
// now add to the field set
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAppend ( $form , $this -> setField ( 'custom' , $r_fieldValues , $r_name , $r_typeName , $langView , $view_name_single , $view_name_list , $placeholders , $r_optionArray ));
2017-12-03 18:09:04 +00:00
// set lang (just incase)
2019-07-04 23:53:54 +00:00
$r_listLangName = $langView . '_' . ComponentbuilderHelper :: safeFieldName ( $r_name , true );
2017-12-03 18:09:04 +00:00
// add to lang array
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $r_listLangName , ComponentbuilderHelper :: safeString ( $r_name , 'W' ));
2017-12-03 18:09:04 +00:00
// if label was set use instead
if ( ComponentbuilderHelper :: checkString ( $r_langLabel ))
{
$r_listLangName = $r_langLabel ;
}
// set the custom array
$data = array ( 'type' => $r_typeName , 'code' => $r_name , 'lang' => $r_listLangName , 'custom' => $custom );
// set the custom field file
2018-03-18 04:28:54 +00:00
$this -> setCustomFieldTypeFile ( $data , $view_name_list , $view_name_single );
2017-06-18 07:37:48 +00:00
}
2019-07-28 21:48:42 +00:00
else
{
// now add to the field set
ComponentbuilderHelper :: xmlAppend ( $form , $this -> setField ( 'plain' , $r_fieldValues , $r_name , $r_typeName , $langView , $view_name_single , $view_name_list , $placeholders , $r_optionArray ));
}
2017-06-18 07:37:48 +00:00
}
}
}
}
}
}
2016-03-01 18:44:13 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $setType === 'custom' )
2016-03-01 18:44:13 +00:00
{
// now add to the field set
2017-12-04 14:56:18 +00:00
$field -> fieldXML = new SimpleXMLElement ( '<field/>' );
2019-07-04 23:53:54 +00:00
$field -> comment = $this -> setLine ( __LINE__ ) . " " . ucfirst ( $name ) . " Field. Type: " . ComponentbuilderHelper :: safeString ( $typeName , 'F' ) . " . (custom) " ;
2016-03-01 18:44:13 +00:00
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
2017-12-04 14:56:18 +00:00
$field -> fieldXML -> addAttribute ( $property , $value );
2016-03-01 18:44:13 +00:00
}
}
2016-10-23 22:48:26 +00:00
// incase the field is in the config and has not been set
2018-03-18 04:28:54 +00:00
if ( 'config' === $view_name_single && 'configs' === $view_name_list )
2016-10-23 22:48:26 +00:00
{
// 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
2018-03-18 04:28:54 +00:00
$this -> setCustomFieldTypeFile ( $data , $view_name_list , $view_name_single );
2016-10-23 22:48:26 +00:00
}
2016-03-01 18:44:13 +00:00
}
2017-12-04 14:56:18 +00:00
return $field ;
2016-03-01 18:44:13 +00:00
}
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* set the layout builder
2017-12-03 17:08:01 +00:00
*
2018-03-18 04:28:54 +00:00
* @ 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
2016-03-01 18:44:13 +00:00
*
* @ return void
2017-12-03 17:08:01 +00:00
*
2016-03-01 18:44:13 +00:00
*/
2018-03-18 04:28:54 +00:00
public function setLayoutBuilder ( & $view_name_single , & $tabName , & $name , & $field )
2016-03-01 18:44:13 +00:00
{
2017-08-12 11:47:25 +00:00
// 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 )
{
2018-03-18 04:28:54 +00:00
if ( ! isset ( $this -> zeroOrderFix [ $view_name_single ]))
2017-08-12 11:47:25 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> zeroOrderFix [ $view_name_single ] = array ();
2017-08-12 11:47:25 +00:00
}
2018-03-18 04:28:54 +00:00
if ( ! isset ( $this -> zeroOrderFix [ $view_name_single ][( int ) $field [ 'tab' ]]))
2017-08-12 11:47:25 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> zeroOrderFix [ $view_name_single ][( int ) $field [ 'tab' ]] = - 999 ;
2017-08-12 11:47:25 +00:00
}
else
{
2018-03-18 04:28:54 +00:00
$this -> zeroOrderFix [ $view_name_single ][( int ) $field [ 'tab' ]] ++ ;
2017-08-12 11:47:25 +00:00
}
2018-03-18 04:28:54 +00:00
$field [ 'order_edit' ] = $this -> zeroOrderFix [ $view_name_single ][( int ) $field [ 'tab' ]];
2017-08-12 11:47:25 +00:00
}
// now build the layout
2016-06-02 16:18:49 +00:00
if ( ComponentbuilderHelper :: checkString ( $tabName ) && $tabName != 'publishing' )
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> tabCounter [ $view_name_single ][( int ) $field [ 'tab' ]] = $tabName ;
if ( isset ( $this -> layoutBuilder [ $view_name_single ][ $tabName ][( int ) $field [ 'alignment' ]][( int ) $field [ 'order_edit' ]]))
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$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 ]))
2018-03-11 22:36:14 +00:00
{
$size ++ ;
}
2018-03-18 04:28:54 +00:00
$this -> layoutBuilder [ $view_name_single ][ $tabName ][( int ) $field [ 'alignment' ]][ $size ] = $name ;
2016-03-01 18:44:13 +00:00
}
else
{
2018-03-18 04:28:54 +00:00
$this -> layoutBuilder [ $view_name_single ][ $tabName ][( int ) $field [ 'alignment' ]][( int ) $field [ 'order_edit' ]] = $name ;
2016-03-01 18:44:13 +00:00
}
2019-07-01 16:10:28 +00:00
// check if default fields were over written
2016-06-02 16:18:49 +00:00
if ( in_array ( $name , $this -> defaultFields ))
{
// just to eliminate
2018-03-18 04:28:54 +00:00
$this -> movedPublishingFields [ $view_name_single ][ $name ] = $name ;
2016-06-02 16:18:49 +00:00
}
}
2017-12-03 17:08:01 +00:00
elseif ( $tabName === 'publishing' || $tabName === 'Publishing' )
2016-06-02 16:18:49 +00:00
{
if ( ! in_array ( $name , $this -> defaultFields ))
{
2018-03-18 04:28:54 +00:00
if ( isset ( $this -> newPublishingFields [ $view_name_single ][( int ) $field [ 'alignment' ]][( int ) $field [ 'order_edit' ]]))
2016-06-02 16:18:49 +00:00
{
2018-03-18 04:28:54 +00:00
$size = ( int ) count (( array ) $this -> newPublishingFields [ $view_name_single ][( int ) $field [ 'alignment' ]]) + 1 ;
while ( isset ( $this -> newPublishingFields [ $view_name_single ][( int ) $field [ 'alignment' ]][ $size ]))
2018-03-11 22:36:14 +00:00
{
$size ++ ;
}
2018-03-18 04:28:54 +00:00
$this -> newPublishingFields [ $view_name_single ][( int ) $field [ 'alignment' ]][ $size ] = $name ;
2016-06-02 16:18:49 +00:00
}
else
{
2018-03-18 04:28:54 +00:00
$this -> newPublishingFields [ $view_name_single ][( int ) $field [ 'alignment' ]][( int ) $field [ 'order_edit' ]] = $name ;
2016-06-02 16:18:49 +00:00
}
}
2016-03-01 18:44:13 +00:00
}
else
{
2018-03-18 04:28:54 +00:00
$this -> tabCounter [ $view_name_single ][ 1 ] = 'Details' ;
if ( isset ( $this -> layoutBuilder [ $view_name_single ][ 'Details' ][( int ) $field [ 'alignment' ]][( int ) $field [ 'order_edit' ]]))
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$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 ]))
2018-03-11 22:36:14 +00:00
{
$size ++ ;
}
2018-03-18 04:28:54 +00:00
$this -> layoutBuilder [ $view_name_single ][ 'Details' ][( int ) $field [ 'alignment' ]][ $size ] = $name ;
2016-03-01 18:44:13 +00:00
}
else
{
2018-03-18 04:28:54 +00:00
$this -> layoutBuilder [ $view_name_single ][ 'Details' ][( int ) $field [ 'alignment' ]][( int ) $field [ 'order_edit' ]] = $name ;
2016-03-01 18:44:13 +00:00
}
2019-07-01 16:10:28 +00:00
// check if default fields were over written
2016-06-02 16:18:49 +00:00
if ( in_array ( $name , $this -> defaultFields ))
{
// just to eliminate
2018-03-18 04:28:54 +00:00
$this -> movedPublishingFields [ $view_name_single ][ $name ] = $name ;
2016-06-02 16:18:49 +00:00
}
2016-03-01 18:44:13 +00:00
}
}
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* build the site field data needed
2017-12-03 17:08:01 +00:00
*
2017-12-04 14:56:18 +00:00
* @ param string $view The single edit view code name
* @ param string $field The field name
* @ param string $set The decoding set this field belongs to
* @ param string $type The field type
2016-03-01 18:44:13 +00:00
*
* @ return void
2017-12-03 17:08:01 +00:00
*
2016-03-01 18:44:13 +00:00
*/
2017-11-11 04:33:51 +00:00
public function buildSiteFieldData ( $view , $field , $set , $type )
2016-03-01 18:44:13 +00:00
{
2018-03-06 02:28:44 +00:00
$decode = array ( 'json' , 'base64' , 'basic_encryption' , 'whmcs_encryption' , 'medium_encryption' );
2017-12-14 23:10:47 +00:00
$textareas = array ( 'textarea' , 'editor' );
2016-03-01 18:44:13 +00:00
if ( isset ( $this -> siteFields [ $view ][ $field ]) && ComponentbuilderHelper :: checkArray ( $this -> siteFields [ $view ][ $field ]))
{
2018-07-21 07:10:37 +00:00
foreach ( $this -> siteFields [ $view ][ $field ] as $codeString => $array )
2016-03-01 18:44:13 +00:00
{
2018-07-21 07:10:37 +00:00
// get the code array
$codeArray = explode ( '___' , $codeString );
// set the code
$code = trim ( $codeArray [ 0 ]);
2016-03-01 18:44:13 +00:00
// set the decoding methods
2017-12-14 23:10:47 +00:00
if ( in_array ( $set , $decode ))
2016-03-01 18:44:13 +00:00
{
2018-04-30 12:06:05 +00:00
if ( isset ( $this -> siteFieldData [ 'decode' ][ $array [ 'site' ]][ $code ][ $array [ 'as' ]][ $array [ 'key' ]]) &&
isset ( $this -> siteFieldData [ 'decode' ][ $array [ 'site' ]][ $code ][ $array [ 'as' ]][ $array [ 'key' ]][ 'decode' ]))
{
if ( ! in_array ( $set , $this -> siteFieldData [ 'decode' ][ $array [ 'site' ]][ $code ][ $array [ 'as' ]][ $array [ 'key' ]][ 'decode' ]))
{
$this -> siteFieldData [ 'decode' ][ $array [ 'site' ]][ $code ][ $array [ 'as' ]][ $array [ 'key' ]][ 'decode' ][] = $set ;
}
}
else
{
$this -> siteFieldData [ 'decode' ][ $array [ 'site' ]][ $code ][ $array [ 'as' ]][ $array [ 'key' ]] = array ( 'decode' => array ( $set ), 'type' => $type );
}
2016-03-01 18:44:13 +00:00
}
// set the uikit checker
2017-12-10 19:17:26 +00:00
if (( 2 == $this -> uikit || 1 == $this -> uikit ) && in_array ( $type , $textareas ))
2016-03-01 18:44:13 +00:00
{
$this -> siteFieldData [ 'uikit' ][ $array [ 'site' ]][ $code ][ $array [ 'as' ]][ $array [ 'key' ]] = $array ;
}
2017-12-10 19:17:26 +00:00
// set the textareas checker
if ( in_array ( $type , $textareas ))
{
$this -> siteFieldData [ 'textareas' ][ $array [ 'site' ]][ $code ][ $array [ 'as' ]][ $array [ 'key' ]] = $array ;
}
2016-03-01 18:44:13 +00:00
}
}
}
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* set field attributes
2017-12-03 17:08:01 +00:00
*
2018-03-18 04:28:54 +00:00
* @ 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
2016-03-01 18:44:13 +00:00
*
* @ return array The field attributes
2017-12-03 17:08:01 +00:00
*
2016-03-01 18:44:13 +00:00
*/
2018-03-18 04:28:54 +00:00
private function setFieldAttributes ( & $field , & $viewType , & $name , & $typeName , & $multiple , & $langLabel , $langView , $view_name_list , $view_name_single , $placeholders , $repeatable = false )
2016-03-01 18:44:13 +00:00
{
2017-12-04 14:56:18 +00:00
// reset array
2016-03-01 18:44:13 +00:00
$fieldAttributes = array ();
$setCustom = false ;
2018-07-21 07:10:37 +00:00
$setReadonly = false ;
2016-03-01 18:44:13 +00:00
// setup joomla default fields
2018-05-24 13:56:56 +00:00
if ( ! ComponentbuilderHelper :: fieldCheck ( $typeName ))
2016-03-01 18:44:13 +00:00
{
$fieldAttributes [ 'custom' ] = array ();
2018-09-24 14:37:51 +00:00
// is this an own custom field
2018-10-01 02:16:24 +00:00
if ( isset ( $field [ 'settings' ] -> own_custom ))
2018-09-24 14:37:51 +00:00
{
2018-10-01 02:16:24 +00:00
$fieldAttributes [ 'custom' ][ 'own_custom' ] = $field [ 'settings' ] -> own_custom ;
2018-09-24 14:37:51 +00:00
}
2016-03-01 18:44:13 +00:00
$setCustom = true ;
}
// setup a default field
if ( ComponentbuilderHelper :: checkArray ( $field [ 'settings' ] -> properties ))
{
2018-10-29 16:38:00 +00:00
// we need a deeper php code search tracker
$phpTracker = array ();
2016-03-01 18:44:13 +00:00
foreach ( $field [ 'settings' ] -> properties as $property )
{
// reset
$xmlValue = '' ;
$langValue = '' ;
2017-02-01 13:17:04 +00:00
if ( $property [ 'name' ] === 'type' )
2016-03-01 18:44:13 +00:00
{
2018-03-11 02:44:43 +00:00
// get type name
$xmlValue = $typeName ;
2016-03-01 18:44:13 +00:00
// add to custom if it is custom
if ( $setCustom )
{
// set the type just to make sure.
$fieldAttributes [ 'custom' ][ 'type' ] = $typeName ;
}
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'name' )
2016-03-01 18:44:13 +00:00
{
2018-03-11 02:44:43 +00:00
// get the actual field name
$xmlValue = $this -> setPlaceholders ( $name , $placeholders );
2016-03-01 18:44:13 +00:00
}
2018-03-27 09:57:16 +00:00
elseif ( $property [ 'name' ] === 'validate' )
{
// check if we have validate (validation rule set)
$xmlValue = ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'validate="' , '"' );
if ( ComponentbuilderHelper :: checkString ( $xmlValue ))
{
$xmlValue = ComponentbuilderHelper :: safeString ( $xmlValue );
}
}
2017-12-03 18:09:04 +00:00
elseif ( $property [ 'name' ] === 'extension' || $property [ 'name' ] === 'directory' || $property [ 'name' ] === 'formsource' )
2016-03-01 18:44:13 +00:00
{
2018-09-25 20:51:14 +00:00
// get value & replace the placeholders
$xmlValue = $this -> setPlaceholders ( ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , $property [ 'name' ] . '="' , '"' ), $placeholders );
2016-03-01 18:44:13 +00:00
}
2018-09-24 14:37:51 +00:00
// catch all PHP here
elseif ( strpos ( $property [ 'name' ], 'type_php' ) !== false && $setCustom )
2016-03-01 18:44:13 +00:00
{
// set the line number
2018-09-24 14:37:51 +00:00
$phpLine = ( int ) preg_replace ( '/[^0-9]/' , '' , $property [ 'name' ]);
// set the type key
$phpKey = ( string ) trim ( str_replace ( 'type_' , '' , preg_replace ( '/[0-9]+/' , '' , $property [ 'name' ])), '_' );
2016-03-01 18:44:13 +00:00
// load the php for the custom field file
2018-09-24 14:37:51 +00:00
$fieldAttributes [ 'custom' ][ $phpKey ][ $phpLine ] =
$this -> setDynamicValues ( ComponentbuilderHelper :: openValidBase64 (
ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , $property [ 'name' ] . '="' , '"' )
));
2018-10-29 16:38:00 +00:00
// load tracker
$phpTracker [ 'type_' . $phpKey ] = $phpKey ;
2016-03-01 18:44:13 +00:00
}
2018-02-20 21:23:35 +00:00
elseif ( $property [ 'name' ] === 'prime_php' && $setCustom )
{
// load the php for the custom field file
$fieldAttributes [ 'custom' ][ 'prime_php' ] = ( int ) ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , $property [ 'name' ] . '="' , '"' );
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'extends' && $setCustom )
2016-03-01 18:44:13 +00:00
{
// load the class that is being extended
$fieldAttributes [ 'custom' ][ 'extends' ] = ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'extends="' , '"' );
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'view' && $setCustom )
2016-03-01 18:44:13 +00:00
{
2018-09-25 20:51:14 +00:00
// load the view name & replace the placeholders
$fieldAttributes [ 'custom' ][ 'view' ] = ComponentbuilderHelper :: safeString ( $this -> setPlaceholders ( ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'view="' , '"' ), $placeholders ));
2016-03-01 18:44:13 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'views' && $setCustom )
2016-03-01 18:44:13 +00:00
{
2018-09-25 20:51:14 +00:00
// load the views name & replace the placeholders
$fieldAttributes [ 'custom' ][ 'views' ] = ComponentbuilderHelper :: safeString ( $this -> setPlaceholders ( ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'views="' , '"' ), $placeholders ));
2016-03-01 18:44:13 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'component' && $setCustom )
2016-03-01 18:44:13 +00:00
{
2018-09-25 20:51:14 +00:00
// load the component name & replace the placeholders
$fieldAttributes [ 'custom' ][ 'component' ] = $this -> setPlaceholders ( ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'component="' , '"' ), $placeholders );
2016-03-01 18:44:13 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'table' && $setCustom )
2016-03-01 18:44:13 +00:00
{
2018-09-25 20:51:14 +00:00
// load the main table that is queried & replace the placeholders
$fieldAttributes [ 'custom' ][ 'table' ] = $this -> setPlaceholders ( ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'table="' , '"' ), $placeholders );
2016-03-01 18:44:13 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'value_field' && $setCustom )
2016-03-01 18:44:13 +00:00
{
// load the text key
$fieldAttributes [ 'custom' ][ 'text' ] = ComponentbuilderHelper :: safeString ( ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'value_field="' , '"' ));
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'key_field' && $setCustom )
2016-03-01 18:44:13 +00:00
{
// load the id key
$fieldAttributes [ 'custom' ][ 'id' ] = ComponentbuilderHelper :: safeString ( ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'key_field="' , '"' ));
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'button' && $repeatable && $setCustom )
2016-03-01 18:44:13 +00:00
{
// dont load the button to repeatable
$xmlValue = 'false' ;
2018-03-30 07:58:24 +00:00
// do not add button
$fieldAttributes [ 'custom' ][ 'add_button' ] = 'false' ;
}
elseif ( $property [ 'name' ] === 'button' && $setCustom )
{
2019-05-25 20:20:12 +00:00
// load the button string value if found
2018-03-30 07:58:24 +00:00
$xmlValue = ( string ) ComponentbuilderHelper :: safeString ( ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'button="' , '"' ));
// add to custom values
2018-05-11 04:08:14 +00:00
$fieldAttributes [ 'custom' ][ 'add_button' ] = ( ComponentbuilderHelper :: checkString ( $xmlValue ) || 1 == $xmlValue ) ? $xmlValue : 'false' ;
2016-03-01 18:44:13 +00:00
}
2019-05-25 20:20:12 +00:00
elseif ( $property [ 'name' ] === 'required' && 'repeatable' === $typeName )
2016-09-03 21:44:47 +00:00
{
2019-05-25 20:20:12 +00:00
// dont load the required to repeatable field type
2016-09-03 21:44:47 +00:00
$xmlValue = 'false' ;
}
2017-02-01 13:17:04 +00:00
elseif ( $viewType == 2 && ( $property [ 'name' ] === 'readonly' || $property [ 'name' ] === 'disabled' ))
2016-03-01 18:44:13 +00:00
{
// set read only
$xmlValue = 'true' ;
2018-07-21 07:10:37 +00:00
// trip the switch for readonly
if ( $property [ 'name' ] === 'readonly' )
{
$setReadonly = true ;
}
2016-03-01 18:44:13 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'multiple' )
2016-03-01 18:44:13 +00:00
{
2016-09-03 21:44:47 +00:00
$xmlValue = ( string ) ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , $property [ 'name' ] . '="' , '"' );
2016-03-01 18:44:13 +00:00
// add the multipal
2017-02-02 11:54:07 +00:00
if ( 'true' === $xmlValue )
2016-03-01 18:44:13 +00:00
{
$multiple = true ;
}
}
// make sure the name is added as a cless name for use in javascript
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'class' && ( $typeName === 'note' || $typeName === 'spacer' ))
2016-03-01 18:44:13 +00:00
{
$xmlValue = ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'class="' , '"' );
// add the type class
if ( ComponentbuilderHelper :: checkString ( $xmlValue ))
{
if ( strpos ( $xmlValue , $name ) === false )
{
$xmlValue = $xmlValue . ' ' . $name ;
}
}
else
{
$xmlValue = $name ;
}
}
else
{
// set the rest of the fields
2019-02-15 22:03:21 +00:00
$xmlValue = ( string ) $this -> setPlaceholders ( ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , $property [ 'name' ] . '="' , '"' ), $placeholders );
2016-03-01 18:44:13 +00:00
}
// check if translatable
2017-10-12 00:50:14 +00:00
if ( ComponentbuilderHelper :: checkString ( $xmlValue ) && isset ( $property [ 'translatable' ]) && $property [ 'translatable' ] == 1 )
2016-03-01 18:44:13 +00:00
{
2017-12-03 17:08:01 +00:00
// update label if field use multiple times
2017-03-06 12:06:51 +00:00
if ( $property [ 'name' ] === 'label' )
{
2018-03-18 04:28:54 +00:00
if ( isset ( $fieldAttributes [ 'name' ]) && isset ( $this -> uniqueNames [ $view_name_list ][ 'names' ][ $fieldAttributes [ 'name' ]]))
2017-03-06 12:06:51 +00:00
{
2018-03-18 04:28:54 +00:00
$xmlValue .= ' (' . ComponentbuilderHelper :: safeString ( $this -> uniqueNames [ $view_name_list ][ 'names' ][ $fieldAttributes [ 'name' ]]) . ')' ;
2017-03-06 12:06:51 +00:00
}
}
2016-03-01 18:44:13 +00:00
// replace placeholders
2017-02-11 02:24:26 +00:00
$xmlValue = $this -> setPlaceholders ( $xmlValue , $placeholders );
2016-03-01 18:44:13 +00:00
// insure custom lables dont get messed up
if ( $setCustom )
{
$customLabel = $xmlValue ;
}
// set lang key
2019-07-04 23:53:54 +00:00
$langValue = $langView . '_' . ComponentbuilderHelper :: safeFieldName ( $name . ' ' . $property [ 'name' ], true );
2016-03-01 18:44:13 +00:00
// add to lang array
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $langValue , $xmlValue );
2016-03-01 18:44:13 +00:00
// use lang value
$xmlValue = $langValue ;
}
2017-10-12 00:50:14 +00:00
elseif ( isset ( $field [ 'alias' ]) && $field [ 'alias' ] && isset ( $property [ 'translatable' ]) && $property [ 'translatable' ] == 1 )
2016-03-01 18:44:13 +00:00
{
2017-02-01 13:17:04 +00:00
if ( $property [ 'name' ] === 'label' )
2016-03-01 18:44:13 +00:00
{
$xmlValue = 'JFIELD_ALIAS_LABEL' ;
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'description' )
2016-03-01 18:44:13 +00:00
{
$xmlValue = 'JFIELD_ALIAS_DESC' ;
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'hint' )
2016-03-01 18:44:13 +00:00
{
$xmlValue = 'JFIELD_ALIAS_PLACEHOLDER' ;
}
}
2017-10-12 00:50:14 +00:00
elseif ( isset ( $field [ 'title' ]) && $field [ 'title' ] && isset ( $property [ 'translatable' ]) && $property [ 'translatable' ] == 1 )
2016-03-01 18:44:13 +00:00
{
2017-02-01 13:17:04 +00:00
if ( $property [ 'name' ] === 'label' )
2016-03-01 18:44:13 +00:00
{
$xmlValue = 'JGLOBAL_TITLE' ;
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'description' )
2016-03-01 18:44:13 +00:00
{
$xmlValue = 'JFIELD_TITLE_DESC' ;
}
}
// only load value if found or is mandatory
2017-10-12 00:50:14 +00:00
if ( ComponentbuilderHelper :: checkString ( $xmlValue ) || ( isset ( $property [ 'mandatory' ]) && $property [ 'mandatory' ] == 1 && ! $setCustom ))
2016-03-01 18:44:13 +00:00
{
// make sure mantory fields are added
if ( ! ComponentbuilderHelper :: checkString ( $xmlValue ))
{
if ( isset ( $property [ 'example' ]) && ComponentbuilderHelper :: checkString ( $property [ 'example' ]))
{
$xmlValue = $property [ 'example' ];
}
}
// load to langBuilder down the line
2017-02-01 13:17:04 +00:00
if ( $property [ 'name' ] === 'label' )
2016-03-01 18:44:13 +00:00
{
if ( $setCustom )
{
$fieldAttributes [ 'custom' ][ 'label' ] = $customLabel ;
}
2017-03-06 12:06:51 +00:00
$langLabel = $xmlValue ;
2016-03-01 18:44:13 +00:00
}
2017-03-06 12:06:51 +00:00
// now set the value
$fieldAttributes [ $property [ 'name' ]] = $xmlValue ;
2016-03-01 18:44:13 +00:00
}
2018-09-24 14:37:51 +00:00
// validate that the default field is set
elseif ( $property [ 'name' ] === 'default' && ( $xmlValidateValue = ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'default="' , '"' , 'none-set' )) !== 'none-set' )
{
// we must allow empty defaults
$fieldAttributes [ 'default' ] = $xmlValue ;
}
2016-03-01 18:44:13 +00:00
}
2018-10-29 16:38:00 +00:00
// check if all php is loaded using the tracker
if ( ComponentbuilderHelper :: checkArray ( $phpTracker ))
{
// litle search validation
$confirmation = '8qvZHoyuFYQqpj0YQbc6F3o5DhBlmS-_-a8pmCZfOVSfANjkmV5LG8pCdAY2JNYu6cB' ;
foreach ( $phpTracker as $searchKey => $phpKey )
{
// we must search for more code in the xml just incase
foreach ( range ( 2 , 30 ) as $phpLine )
{
$get_ = $searchKey . '_' . $phpLine ;
if ( ! isset ( $fieldAttributes [ 'custom' ][ $phpKey ][ $phpLine ]) && ( $value = ComponentbuilderHelper :: getValueFromXMLstring ( $field [ 'settings' ] -> xml , $get_ , $confirmation )) !== $confirmation )
{
$fieldAttributes [ 'custom' ][ $phpKey ][ $phpLine ] = $this -> setDynamicValues ( ComponentbuilderHelper :: openValidBase64 ( $value ));
}
}
}
}
2016-03-01 18:44:13 +00:00
// do some nice twigs beyond the default
if ( isset ( $fieldAttributes [ 'name' ]))
{
2018-02-27 12:17:38 +00:00
// check if we have class value for the list view of this field
$listclass = ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'listclass="' , '"' );
if ( ComponentbuilderHelper :: checkString ( $listclass ))
{
2018-03-18 04:28:54 +00:00
$this -> listFieldClass [ $view_name_list ][ $fieldAttributes [ 'name' ]] = $listclass ;
2018-02-27 12:17:38 +00:00
}
2016-03-01 18:44:13 +00:00
// check if we find reason to remove this field from being escaped
$escaped = ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'escape="' , '"' );
if ( ComponentbuilderHelper :: checkString ( $escaped ))
{
2018-03-18 04:28:54 +00:00
$this -> doNotEscape [ $view_name_list ][] = $fieldAttributes [ 'name' ];
2016-03-01 18:44:13 +00:00
}
2017-07-20 23:26:48 +00:00
// check if we have display switch for dynamic placment
$display = ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'display="' , '"' );
if ( ComponentbuilderHelper :: checkString ( $display ))
{
$fieldAttributes [ 'display' ] = $display ;
}
2018-03-27 09:57:16 +00:00
// make sure validation is set if found (even it not part of field properties)
if ( ! isset ( $fieldAttributes [ 'validate' ]))
{
// check if we have validate (validation rule set)
$validationRule = ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'validate="' , '"' );
if ( ComponentbuilderHelper :: checkString ( $validationRule ))
{
$fieldAttributes [ 'validate' ] = ComponentbuilderHelper :: safeString ( $validationRule );
}
}
2018-07-21 07:10:37 +00:00
// make sure ID is always readonly
if ( $fieldAttributes [ 'name' ] === 'id' && ! $setReadonly )
{
$fieldAttributes [ 'readonly' ] = 'true' ;
}
2016-03-01 18:44:13 +00:00
}
}
return $fieldAttributes ;
}
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* set Builders
2017-12-03 17:08:01 +00:00
*
2018-03-18 04:28:54 +00:00
* @ 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
2016-03-01 18:44:13 +00:00
*
* @ return void
2017-12-03 17:08:01 +00:00
*
2016-03-01 18:44:13 +00:00
*/
2018-03-18 04:28:54 +00:00
public function setBuilders ( $langLabel , $langView , $view_name_single , $view_name_list , $name , $view , $field , $typeName , $multiple , $custom = false , $options = false )
2016-03-01 18:44:13 +00:00
{
2018-04-13 15:24:06 +00:00
// dbSwitch
$dbSwitch = true ;
if ( isset ( $field [ 'list' ]) && $field [ 'list' ] == 2 )
{
// do not add this field to the database
$dbSwitch = false ;
}
elseif ( $typeName === 'tag' )
2016-03-01 18:44:13 +00:00
{
// set tags for this view but don't load to DB
2018-03-18 04:28:54 +00:00
$this -> tagsBuilder [ $view_name_single ] = $view_name_single ;
2016-03-01 18:44:13 +00:00
}
2018-04-23 00:42:41 +00:00
elseif ( isset ( $field [ 'settings' ] -> datatype ))
2016-03-01 18:44:13 +00:00
{
// insure default not none if number type
$intKeys = array ( 'INT' , 'TINYINT' , 'BIGINT' , 'FLOAT' , 'DECIMAL' , 'DOUBLE' );
if ( in_array ( $field [ 'settings' ] -> datatype , $intKeys ))
{
2017-02-01 13:17:04 +00:00
if ( $field [ 'settings' ] -> datadefault === 'Other' )
2016-03-01 18:44:13 +00:00
{
if ( ! is_numeric ( $field [ 'settings' ] -> datadefault_other ) || $field [ 'settings' ] -> datadefault_other !== '0000-00-00 00:00:00' )
{
$field [ 'settings' ] -> datadefault_other = '0' ;
}
}
elseif ( ! is_numeric ( $field [ 'settings' ] -> datadefault ))
{
$field [ 'settings' ] -> datadefault = '0' ;
}
}
// don't use these as index or uniqe keys
2016-09-03 21:44:47 +00:00
$textKeys = array ( 'TEXT' , 'TINYTEXT' , 'MEDIUMTEXT' , 'LONGTEXT' , 'BLOB' , 'TINYBLOB' , 'MEDIUMBLOB' , 'LONGBLOB' );
// build the query values
2018-03-18 04:28:54 +00:00
$this -> queryBuilder [ $view_name_single ][ $name ][ 'type' ] = $field [ 'settings' ] -> datatype ;
2017-12-03 17:08:01 +00:00
if ( ! in_array ( $field [ 'settings' ] -> datatype , $textKeys ))
2016-09-03 21:44:47 +00:00
{
2018-03-18 04:28:54 +00:00
$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 ;
2016-03-01 18:44:13 +00:00
}
2017-12-03 08:02:11 +00:00
else
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> queryBuilder [ $view_name_single ][ $name ][ 'default' ] = 'EMPTY' ;
2017-12-03 17:08:01 +00:00
}
2017-06-29 21:03:53 +00:00
// to identify the field
2018-03-18 04:28:54 +00:00
$this -> queryBuilder [ $view_name_single ][ $name ][ 'ID' ] = $field [ 'settings' ] -> id ;
$this -> queryBuilder [ $view_name_single ][ $name ][ 'null_switch' ] = $field [ 'settings' ] -> null_switch ;
2016-03-01 18:44:13 +00:00
// set index types
2016-09-03 21:44:47 +00:00
if ( $field [ 'settings' ] -> indexes == 1 && ! in_array ( $field [ 'settings' ] -> datatype , $textKeys ))
2016-03-01 18:44:13 +00:00
{
// build unique keys of this view for db
2018-03-18 04:28:54 +00:00
$this -> dbUniqueKeys [ $view_name_single ][] = $name ;
2016-03-01 18:44:13 +00:00
}
2017-10-30 18:50:56 +00:00
elseif (( $field [ 'settings' ] -> indexes == 2 || ( isset ( $field [ 'alias' ]) && $field [ 'alias' ]) || ( isset ( $field [ 'title' ]) && $field [ 'title' ]) || $typeName === 'category' ) && ! in_array ( $field [ 'settings' ] -> datatype , $textKeys ))
2016-03-01 18:44:13 +00:00
{
// build keys of this view for db
2018-03-18 04:28:54 +00:00
$this -> dbKeys [ $view_name_single ][] = $name ;
2016-03-01 18:44:13 +00:00
}
}
2018-05-24 13:56:56 +00:00
// set list switch
2018-10-29 16:38:00 +00:00
$listSwitch = ( isset ( $field [ 'list' ]) && ( $field [ 'list' ] == 1 || $field [ 'list' ] == 3 || $field [ 'list' ] == 4 ));
2018-05-24 13:56:56 +00:00
// set list join
$listJoin = ( isset ( $this -> listJoinBuilder [ $view_name_list ][( int ) $field [ 'field' ]]));
2016-03-01 18:44:13 +00:00
// add history to this view
2017-10-30 13:08:02 +00:00
if ( isset ( $view [ 'history' ]) && $view [ 'history' ])
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> historyBuilder [ $view_name_single ] = $view_name_single ;
2016-03-01 18:44:13 +00:00
}
// set Alias (only one title per view)
2018-04-13 15:24:06 +00:00
if ( $dbSwitch && isset ( $field [ 'alias' ]) && $field [ 'alias' ] && ! isset ( $this -> aliasBuilder [ $view_name_single ]))
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> aliasBuilder [ $view_name_single ] = $name ;
2016-03-01 18:44:13 +00:00
}
// set Titles (only one title per view)
2018-04-13 15:24:06 +00:00
if ( $dbSwitch && isset ( $field [ 'title' ]) && $field [ 'title' ] && ! isset ( $this -> titleBuilder [ $view_name_single ]))
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> titleBuilder [ $view_name_single ] = $name ;
2016-03-01 18:44:13 +00:00
}
// category name fix
2017-02-01 13:17:04 +00:00
if ( $typeName === 'category' )
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
if ( isset ( $this -> catOtherName [ $view_name_list ]) && ComponentbuilderHelper :: checkArray ( $this -> catOtherName [ $view_name_list ]))
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$tempName = $this -> catOtherName [ $view_name_list ][ 'name' ];
2016-03-01 18:44:13 +00:00
}
else
{
2018-03-18 04:28:54 +00:00
$tempName = $view_name_single . ' category' ;
2016-03-01 18:44:13 +00:00
}
// set lang
2019-07-04 23:53:54 +00:00
$listLangName = $langView . '_' . ComponentbuilderHelper :: safeFieldName ( $tempName , true );
2016-03-01 18:44:13 +00:00
// add to lang array
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $listLangName , ComponentbuilderHelper :: safeString ( $tempName , 'W' ));
2016-03-01 18:44:13 +00:00
}
else
{
// set lang (just incase)
2019-07-04 23:53:54 +00:00
$listLangName = $langView . '_' . ComponentbuilderHelper :: safeFieldName ( $name , true );
2016-03-01 18:44:13 +00:00
// add to lang array
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $listLangName , ComponentbuilderHelper :: safeString ( $name , 'W' ));
2016-03-01 18:44:13 +00:00
// if label was set use instead
if ( ComponentbuilderHelper :: checkString ( $langLabel ))
{
$listLangName = $langLabel ;
}
}
// build the list values
2018-05-24 13:56:56 +00:00
if (( $listSwitch || $listJoin ) && $typeName != 'repeatable' && $typeName != 'subform' )
2016-03-01 18:44:13 +00:00
{
// load to list builder
2018-05-24 13:56:56 +00:00
if ( $listSwitch )
{
$this -> listBuilder [ $view_name_list ][] = array (
'id' => ( int ) $field [ 'field' ],
'type' => $typeName ,
'code' => $name ,
'lang' => $listLangName ,
'title' => ( isset ( $field [ 'title' ]) && $field [ 'title' ]) ? true : false ,
'alias' => ( isset ( $field [ 'alias' ]) && $field [ 'alias' ]) ? true : false ,
'link' => ( isset ( $field [ 'link' ]) && $field [ 'link' ]) ? true : false ,
'sort' => ( isset ( $field [ 'sort' ]) && $field [ 'sort' ]) ? true : false ,
'custom' => $custom ,
'multiple' => $multiple ,
2018-10-29 16:38:00 +00:00
'options' => $options ,
'target' => ( int ) $field [ 'list' ]);
2018-05-24 13:56:56 +00:00
}
// build custom builder list
if ( $listSwitch || $listJoin )
{
$this -> customBuilderList [ $view_name_list ][] = $name ;
}
2016-03-01 18:44:13 +00:00
}
2018-05-26 10:03:08 +00:00
// load the list join builder
if ( $listJoin )
{
$this -> listJoinBuilder [ $view_name_list ][( int ) $field [ 'field' ]] = array (
'type' => $typeName ,
'code' => $name ,
'lang' => $listLangName ,
'title' => ( isset ( $field [ 'title' ]) && $field [ 'title' ]) ? true : false ,
'alias' => ( isset ( $field [ 'alias' ]) && $field [ 'alias' ]) ? true : false ,
'link' => ( isset ( $field [ 'link' ]) && $field [ 'link' ]) ? true : false ,
'sort' => ( isset ( $field [ 'sort' ]) && $field [ 'sort' ]) ? true : false ,
'custom' => $custom ,
'multiple' => $multiple ,
'options' => $options );
}
// update the field relations
2018-07-21 07:10:37 +00:00
if ( isset ( $this -> fieldRelations [ $view_name_list ]) && isset ( $this -> fieldRelations [ $view_name_list ][( int ) $field [ 'field' ]])
&& ComponentbuilderHelper :: checkArray ( $this -> fieldRelations [ $view_name_list ][( int ) $field [ 'field' ]]))
2018-05-26 10:03:08 +00:00
{
2018-07-21 07:10:37 +00:00
foreach ( $this -> fieldRelations [ $view_name_list ][( int ) $field [ 'field' ]] as $area => & $field_values )
{
$field_values [ 'type' ] = $typeName ;
$field_values [ 'code' ] = $name ;
$field_values [ 'custom' ] = $custom ;
}
2018-05-26 10:03:08 +00:00
}
2016-03-01 18:44:13 +00:00
// set the hidden field of this view
2017-02-01 13:17:04 +00:00
if ( $typeName === 'hidden' )
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
if ( ! isset ( $this -> hiddenFieldsBuilder [ $view_name_single ]))
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> hiddenFieldsBuilder [ $view_name_single ] = '' ;
2016-03-01 18:44:13 +00:00
}
2018-03-18 04:28:54 +00:00
$this -> hiddenFieldsBuilder [ $view_name_single ] .= ',"' . $name . '"' ;
2016-03-01 18:44:13 +00:00
}
// set all int fields of this view
2018-04-23 00:42:41 +00:00
if ( $dbSwitch && isset ( $field [ 'settings' ] -> datatype ) && ( $field [ 'settings' ] -> datatype === 'INT' || $field [ 'settings' ] -> datatype === 'TINYINT' || $field [ 'settings' ] -> datatype === 'BIGINT' ))
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
if ( ! isset ( $this -> intFieldsBuilder [ $view_name_single ]))
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> intFieldsBuilder [ $view_name_single ] = '' ;
2016-03-01 18:44:13 +00:00
}
2018-03-18 04:28:54 +00:00
$this -> intFieldsBuilder [ $view_name_single ] .= ',"' . $name . '"' ;
2016-03-01 18:44:13 +00:00
}
// set all dynamic field of this view
2017-06-18 07:37:48 +00:00
if ( $typeName != 'category' && $typeName != 'repeatable' && $typeName != 'subform' && ! in_array ( $name , $this -> defaultFields ))
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
if ( ! isset ( $this -> dynamicfieldsBuilder [ $view_name_single ]))
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> dynamicfieldsBuilder [ $view_name_single ] = '' ;
2016-03-01 18:44:13 +00:00
}
2018-03-18 04:28:54 +00:00
if ( isset ( $this -> dynamicfieldsBuilder [ $view_name_single ]) && ComponentbuilderHelper :: checkString ( $this -> dynamicfieldsBuilder [ $view_name_single ]))
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> dynamicfieldsBuilder [ $view_name_single ] .= ',"' . $name . '":"' . $name . '"' ;
2016-03-01 18:44:13 +00:00
}
else
{
2018-03-18 04:28:54 +00:00
$this -> dynamicfieldsBuilder [ $view_name_single ] .= '"' . $name . '":"' . $name . '"' ;
2016-03-01 18:44:13 +00:00
}
}
// 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
2018-04-13 15:24:06 +00:00
if ( $dbSwitch && $typeName === 'editor' )
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
if ( ! isset ( $this -> maintextBuilder [ $view_name_single ]) || ! ComponentbuilderHelper :: checkString ( $this -> maintextBuilder [ $view_name_single ]))
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> maintextBuilder [ $view_name_single ] = $name ;
2016-03-01 18:44:13 +00:00
}
}
// set the custom builder
2017-06-18 07:37:48 +00:00
if ( ComponentbuilderHelper :: checkArray ( $custom ) && $typeName != 'category' && $typeName != 'repeatable' && $typeName != 'subform' )
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> customBuilder [ $view_name_list ][] = array ( 'type' => $typeName , 'code' => $name , 'lang' => $listLangName , 'custom' => $custom , 'method' => $field [ 'settings' ] -> store );
2016-03-01 18:44:13 +00:00
// set the custom fields needed in content type data
2018-03-18 04:28:54 +00:00
if ( ! isset ( $this -> customFieldLinksBuilder [ $view_name_single ]))
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> customFieldLinksBuilder [ $view_name_single ] = '' ;
2016-03-01 18:44:13 +00:00
}
2016-10-23 22:48:26 +00:00
// only load this if table is set
if ( isset ( $custom [ 'table' ]) && ComponentbuilderHelper :: checkString ( $custom [ 'table' ]))
{
2018-03-18 04:28:54 +00:00
$this -> customFieldLinksBuilder [ $view_name_single ] .= ',{"sourceColumn": "' . $name . '","targetTable": "' . $custom [ 'table' ] . '","targetColumn": "' . $custom [ 'id' ] . '","displayColumn": "' . $custom [ 'text' ] . '"}' ;
2016-10-23 22:48:26 +00:00
}
2016-03-01 18:44:13 +00:00
// build script switch for user
2017-02-01 13:17:04 +00:00
if ( $custom [ 'extends' ] === 'user' )
2016-03-01 18:44:13 +00:00
{
$this -> setScriptUserSwitch [ $typeName ] = $typeName ;
}
}
2017-02-01 13:17:04 +00:00
if ( $typeName === 'media' )
2016-03-01 18:44:13 +00:00
{
$this -> setScriptMediaSwitch [ $typeName ] = $typeName ;
}
// setup gategory for this view
2018-04-13 15:24:06 +00:00
if ( $dbSwitch && $typeName === 'category' )
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
if ( isset ( $this -> catOtherName [ $view_name_list ]) && ComponentbuilderHelper :: checkArray ( $this -> catOtherName [ $view_name_list ]))
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$otherViews = $this -> catOtherName [ $view_name_list ][ 'views' ];
$otherView = $this -> catOtherName [ $view_name_list ][ 'view' ];
2016-03-01 18:44:13 +00:00
}
else
{
2018-03-18 04:28:54 +00:00
$otherViews = $view_name_list ;
$otherView = $view_name_single ;
2016-03-01 18:44:13 +00:00
}
2019-05-06 01:05:15 +00:00
// get the xml extension name
$_extension = $this -> setPlaceholders ( ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'extension="' , '"' ), $this -> placeholders );
2019-06-09 21:19:34 +00:00
// if they left out the extention for some reason
if ( ! ComponentbuilderHelper :: checkString ( $_extension ))
{
$_extension = 'com_' . $this -> componentCodeName . '.' . $otherView ;
}
2019-05-06 01:05:15 +00:00
// load the category builder
$this -> categoryBuilder [ $view_name_list ] = array ( 'code' => $name , 'name' => $listLangName , 'extension' => $_extension );
2016-03-01 18:44:13 +00:00
// also set code name for title alias fix
2018-03-18 04:28:54 +00:00
$this -> catCodeBuilder [ $view_name_single ] = array ( 'code' => $name , 'views' => $otherViews , 'view' => $otherView );
2016-03-01 18:44:13 +00:00
}
// setup checkbox for this view
2018-04-13 15:24:06 +00:00
if ( $dbSwitch && ( $typeName === 'checkbox' || ( ComponentbuilderHelper :: checkArray ( $custom ) && isset ( $custom [ 'extends' ]) && $custom [ 'extends' ] === 'checkboxes' )))
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> checkboxBuilder [ $view_name_single ][] = $name ;
2016-03-01 18:44:13 +00:00
}
// setup checkboxes and other json items for this view
2018-04-13 15:24:06 +00:00
if ( $dbSwitch && (( $typeName === 'subform' || $typeName === 'checkboxes' || $multiple || $field [ 'settings' ] -> store != 0 ) && $typeName != 'tag' ))
2016-03-01 18:44:13 +00:00
{
2018-04-30 12:06:05 +00:00
$subformJsonSwitch = true ;
2016-03-01 18:44:13 +00:00
switch ( $field [ 'settings' ] -> store )
{
case 1 :
// JSON_STRING_ENCODE
2018-03-18 04:28:54 +00:00
$this -> jsonStringBuilder [ $view_name_single ][] = $name ;
2016-03-01 18:44:13 +00:00
// Site settings of each field if needed
2018-03-18 04:28:54 +00:00
$this -> buildSiteFieldData ( $view_name_single , $name , 'json' , $typeName );
2016-03-01 18:44:13 +00:00
break ;
case 2 :
// BASE_SIXTY_FOUR
2018-03-18 04:28:54 +00:00
$this -> base64Builder [ $view_name_single ][] = $name ;
2016-03-01 18:44:13 +00:00
// Site settings of each field if needed
2018-03-18 04:28:54 +00:00
$this -> buildSiteFieldData ( $view_name_single , $name , 'base64' , $typeName );
2016-03-01 18:44:13 +00:00
break ;
case 3 :
// BASIC_ENCRYPTION_LOCALKEY
2018-03-18 04:28:54 +00:00
$this -> basicEncryptionBuilder [ $view_name_single ][] = $name ;
2016-03-01 18:44:13 +00:00
// Site settings of each field if needed
2018-03-18 04:28:54 +00:00
$this -> buildSiteFieldData ( $view_name_single , $name , 'basic_encryption' , $typeName );
2016-03-01 18:44:13 +00:00
break ;
case 4 :
2018-03-06 02:28:44 +00:00
// WHMCS_ENCRYPTION_VDMKEY
2018-03-18 04:28:54 +00:00
$this -> whmcsEncryptionBuilder [ $view_name_single ][] = $name ;
2018-03-06 02:28:44 +00:00
// Site settings of each field if needed
2018-03-18 04:28:54 +00:00
$this -> buildSiteFieldData ( $view_name_single , $name , 'whmcs_encryption' , $typeName );
2018-03-06 02:28:44 +00:00
break ;
case 5 :
// MEDIUM_ENCRYPTION_LOCALFILE
2018-03-18 04:28:54 +00:00
$this -> mediumEncryptionBuilder [ $view_name_single ][] = $name ;
2016-03-01 18:44:13 +00:00
// Site settings of each field if needed
2018-03-18 04:28:54 +00:00
$this -> buildSiteFieldData ( $view_name_single , $name , 'medium_encryption' , $typeName );
2016-03-01 18:44:13 +00:00
break ;
default :
// JSON_ARRAY_ENCODE
2018-03-18 04:28:54 +00:00
$this -> jsonItemBuilder [ $view_name_single ][] = $name ;
2016-03-01 18:44:13 +00:00
// Site settings of each field if needed
2018-03-18 04:28:54 +00:00
$this -> buildSiteFieldData ( $view_name_single , $name , 'json' , $typeName );
2018-04-30 12:06:05 +00:00
// no londer add the json again (already added)
$subformJsonSwitch = false ;
2016-03-01 18:44:13 +00:00
break ;
}
// just a heads-up for usergroups set to multiple
2017-02-01 13:17:04 +00:00
if ( $typeName === 'usergroup' )
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> buildSiteFieldData ( $view_name_single , $name , 'json' , $typeName );
2016-03-01 18:44:13 +00:00
}
// load the json list display fix
2018-05-24 13:56:56 +00:00
if (( $listSwitch || $listJoin ) && $typeName != 'repeatable' && $typeName != 'subform' )
2016-03-01 18:44:13 +00:00
{
if ( ComponentbuilderHelper :: checkArray ( $options ))
{
2018-03-18 04:28:54 +00:00
$this -> getItemsMethodListStringFixBuilder [ $view_name_single ][] = array ( 'name' => $name , 'type' => $typeName , 'translation' => true , 'custom' => $custom , 'method' => $field [ 'settings' ] -> store );
2016-03-01 18:44:13 +00:00
}
else
{
2018-03-18 04:28:54 +00:00
$this -> getItemsMethodListStringFixBuilder [ $view_name_single ][] = array ( 'name' => $name , 'type' => $typeName , 'translation' => false , 'custom' => $custom , 'method' => $field [ 'settings' ] -> store );
2016-03-01 18:44:13 +00:00
}
}
2017-12-03 17:08:01 +00:00
2018-04-30 12:06:05 +00:00
// subform house keeping
2017-06-18 07:37:48 +00:00
if ( 'subform' === $typeName )
{
2018-04-30 12:06:05 +00:00
// the values must revert to array
2018-03-18 04:28:54 +00:00
$this -> jsonItemBuilderArray [ $view_name_single ][] = $name ;
2018-04-30 12:06:05 +00:00
// should the json builder still be added
if ( $subformJsonSwitch )
{
// and insure the if is converted to json
$this -> jsonItemBuilder [ $view_name_single ][] = $name ;
// Site settings of each field if needed
$this -> buildSiteFieldData ( $view_name_single , $name , 'json' , $typeName );
}
2017-06-18 07:37:48 +00:00
}
2016-03-01 18:44:13 +00:00
}
2017-02-01 13:17:04 +00:00
// build the data for the export & import methods $typeName === 'repeatable' ||
2018-04-13 15:24:06 +00:00
if ( $dbSwitch && (( $typeName === 'checkboxes' || $multiple || $field [ 'settings' ] -> store != 0 ) && ! ComponentbuilderHelper :: checkArray ( $options )))
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> getItemsMethodEximportStringFixBuilder [ $view_name_single ][] = array ( 'name' => $name , 'type' => $typeName , 'translation' => false , 'custom' => $custom , 'method' => $field [ 'settings' ] -> store );
2016-03-01 18:44:13 +00:00
}
// check if field should be added to uikit
2018-03-18 04:28:54 +00:00
$this -> buildSiteFieldData ( $view_name_single , $name , 'uikit' , $typeName );
2016-03-01 18:44:13 +00:00
// load the selection translation fix
2018-05-24 13:56:56 +00:00
if ( ComponentbuilderHelper :: checkArray ( $options ) && ( $listSwitch || $listJoin ) && $typeName != 'repeatable' && $typeName != 'subform' )
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> selectionTranslationFixBuilder [ $view_name_list ][ $name ] = $options ;
2016-03-01 18:44:13 +00:00
}
// build the sort values
2018-05-24 13:56:56 +00:00
if ( $dbSwitch && ( isset ( $field [ 'sort' ]) && $field [ 'sort' ] == 1 ) && ( $listSwitch || $listJoin ) && ( ! $multiple && $typeName != 'checkbox' && $typeName != 'checkboxes' && $typeName != 'repeatable' && $typeName != 'subform' ))
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$this -> sortBuilder [ $view_name_list ][] = array ( 'type' => $typeName , 'code' => $name , 'lang' => $listLangName , 'custom' => $custom , 'options' => $options );
2016-03-01 18:44:13 +00:00
}
// build the search values
2018-04-13 15:24:06 +00:00
if ( $dbSwitch && isset ( $field [ 'search' ]) && $field [ 'search' ] == 1 )
2016-03-01 18:44:13 +00:00
{
2017-12-10 19:17:26 +00:00
$_list = ( isset ( $field [ 'list' ])) ? $field [ 'list' ] : 0 ;
2018-03-18 04:28:54 +00:00
$this -> searchBuilder [ $view_name_list ][] = array ( 'type' => $typeName , 'code' => $name , 'custom' => $custom , 'list' => $_list );
2016-03-01 18:44:13 +00:00
}
// build the filter values
2018-05-24 13:56:56 +00:00
if ( $dbSwitch && ( isset ( $field [ 'filter' ]) && $field [ 'filter' ] == 1 ) && ( $listSwitch || $listJoin ) && ( ! $multiple && $typeName != 'checkbox' && $typeName != 'checkboxes' && $typeName != 'repeatable' && $typeName != 'subform' ))
2016-03-01 18:44:13 +00:00
{
2018-03-18 04:28:54 +00:00
$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 );
2016-03-01 18:44:13 +00:00
}
// build the layout
$tabName = '' ;
if ( isset ( $view [ 'settings' ] -> tabs ) && isset ( $view [ 'settings' ] -> tabs [( int ) $field [ 'tab' ]]))
{
$tabName = $view [ 'settings' ] -> tabs [( int ) $field [ 'tab' ]];
}
2016-06-02 16:18:49 +00:00
elseif (( int ) $field [ 'tab' ] == 15 )
{
// set to publishing tab
$tabName = 'publishing' ;
}
2018-03-18 04:28:54 +00:00
$this -> setLayoutBuilder ( $view_name_single , $tabName , $name , $field );
2016-03-01 18:44:13 +00:00
}
2017-12-03 08:02:11 +00:00
2018-03-30 04:41:33 +00:00
/**
* set Custom Field Type File
*
* @ param array $data The field complete data set
* @ param string $view_name_list The list view code name
* @ param string $view_name_single The single view code name
*
* @ return void
*
*/
2018-03-18 04:28:54 +00:00
public function setCustomFieldTypeFile ( $data , $view_name_list , $view_name_single )
2016-03-01 18:44:13 +00:00
{
2018-02-20 21:23:35 +00:00
// make sure it is not already been build or if it is prime
2018-09-24 14:37:51 +00:00
if ( isset ( $data [ 'custom' ]) && isset ( $data [ 'custom' ][ 'extends' ]) && (( isset ( $data [ 'custom' ][ 'prime_php' ]) && $data [ 'custom' ][ 'prime_php' ] == 1 ) || ! isset ( $this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]]) || ! ComponentbuilderHelper :: checkArray ( $this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]])))
2016-03-01 18:44:13 +00:00
{
2019-07-19 02:17:15 +00:00
// set J prefix
$jprefix = 'J' ;
// check if this field has a dot in field type name
if ( strpos ( $data [ 'type' ], '.' ) !== false )
{
// so we have name spacing in custom field type name
$dotTypeArray = explode ( '.' , $data [ 'type' ]);
// set the J prefix
if ( count ( $dotTypeArray ) > 1 )
{
$jprefix = strtoupper ( array_shift ( $dotTypeArray ));
}
// update the type name now
$data [ 'type' ] = implode ( '' , $dotTypeArray );
$data [ 'custom' ][ 'type' ] = $data [ 'type' ];
}
2016-03-01 18:44:13 +00:00
// set tab and break replacements
$tabBreak = array (
2018-05-26 10:03:08 +00:00
'\t' => $this -> _t ( 1 ),
2017-12-14 23:10:47 +00:00
'\n' => PHP_EOL
2016-03-01 18:44:13 +00:00
);
2018-09-24 14:37:51 +00:00
// set the [[[PLACEHOLDER]]] options
2016-03-01 18:44:13 +00:00
$replace = array (
2019-07-19 02:17:15 +00:00
$this -> bbb . 'JPREFIX' . $this -> ddd => $jprefix ,
2018-09-24 14:37:51 +00:00
$this -> bbb . 'TABLE' . $this -> ddd => $data [ 'custom' ][ 'table' ],
$this -> bbb . 'ID' . $this -> ddd => $data [ 'custom' ][ 'id' ],
$this -> bbb . 'TEXT' . $this -> ddd => $data [ 'custom' ][ 'text' ],
$this -> bbb . 'CODE_TEXT' . $this -> ddd => $data [ 'code' ] . '_' . $data [ 'custom' ][ 'text' ],
$this -> bbb . 'CODE' . $this -> ddd => $data [ 'code' ],
$this -> bbb . 'view_type' . $this -> ddd => $view_name_single . '_' . $data [ 'type' ],
$this -> bbb . 'type' . $this -> ddd => $data [ 'type' ],
2019-06-13 21:12:16 +00:00
$this -> bbb . 'com_component' . $this -> ddd => ( isset ( $data [ 'custom' ][ 'component' ]) && ComponentbuilderHelper :: checkString ( $data [ 'custom' ][ 'component' ])) ? ComponentbuilderHelper :: safeString ( $data [ 'custom' ][ 'component' ]) : 'com_' . $this -> componentCodeName ,
2018-09-24 14:37:51 +00:00
// set the generic values
2019-06-13 21:12:16 +00:00
$this -> bbb . 'component' . $this -> ddd => $this -> componentCodeName ,
2018-09-24 14:37:51 +00:00
$this -> bbb . 'Component' . $this -> ddd => $this -> fileContentStatic [ $this -> hhh . 'Component' . $this -> hhh ],
$this -> bbb . 'view' . $this -> ddd => ( isset ( $data [ 'custom' ][ 'view' ]) && ComponentbuilderHelper :: checkString ( $data [ 'custom' ][ 'view' ])) ? ComponentbuilderHelper :: safeString ( $data [ 'custom' ][ 'view' ]) : $view_name_single ,
$this -> bbb . 'views' . $this -> ddd => ( isset ( $data [ 'custom' ][ 'views' ]) && ComponentbuilderHelper :: checkString ( $data [ 'custom' ][ 'views' ])) ? ComponentbuilderHelper :: safeString ( $data [ 'custom' ][ 'views' ]) : $view_name_list
2016-03-01 18:44:13 +00:00
);
2018-09-24 14:37:51 +00:00
// now set the ###PLACEHOLDER### options
foreach ( $replace as $replacekey => $replacevalue )
2016-03-01 18:44:13 +00:00
{
2018-09-24 14:37:51 +00:00
// update the key value
$replacekey = str_replace ( array ( $this -> bbb , $this -> ddd ), array ( $this -> hhh , $this -> hhh ), $replacekey );
// now set the value
$replace [ $replacekey ] = $replacevalue ;
}
2019-02-15 22:03:21 +00:00
// load the global placeholders
if ( ComponentbuilderHelper :: checkArray ( $this -> globalPlaceholders ))
{
foreach ( $this -> globalPlaceholders as $globalPlaceholder => $gloabalValue )
{
$replace [ $globalPlaceholder ] = $gloabalValue ;
}
}
2018-09-24 14:37:51 +00:00
// start loading the field type
$this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]] = array ();
2019-07-19 02:17:15 +00:00
// JPREFIX <<DYNAMIC>>>
$this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]][ $this -> hhh . 'JPREFIX' . $this -> hhh ] = $jprefix ;
2018-09-24 14:37:51 +00:00
// Type <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]][ $this -> hhh . 'Type' . $this -> hhh ] = ComponentbuilderHelper :: safeString ( $data [ 'custom' ][ 'type' ], 'F' );
// type <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]][ $this -> hhh . 'type' . $this -> hhh ] = ComponentbuilderHelper :: safeString ( $data [ 'custom' ][ 'type' ]);
// is this a own custom field
if ( isset ( $data [ 'custom' ][ 'own_custom' ]))
{
// make sure the button option notice is set to notify the developer that the button option is not available in own custom field types
if ( isset ( $data [ 'custom' ][ 'add_button' ]) && ( $data [ 'custom' ][ 'add_button' ] === 'true' || 1 == $data [ 'custom' ][ 'add_button' ]))
{
2018-09-25 20:02:48 +00:00
// set error
$this -> app -> enqueueMessage ( JText :: _ ( '<hr /><h3>Dynamic Button Error</h3>' ), 'Error' );
$this -> app -> enqueueMessage ( JText :: _ ( 'The option to add a dynamic button is not available in <b>own custom field types</b>, you will have to custom code it.' ), 'Error' );
2018-09-24 14:37:51 +00:00
}
// load another file
$target = array ( 'admin' => 'customfield' );
$this -> buildDynamique ( $target , 'fieldcustom' , $data [ 'custom' ][ 'type' ]);
// JFORM_extens <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]][ $this -> hhh . 'JFORM_extends' . $this -> hhh ] = ComponentbuilderHelper :: safeString ( $data [ 'custom' ][ 'extends' ]);
// JFORM_EXTENDS <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]][ $this -> hhh . 'JFORM_EXTENDS' . $this -> hhh ] = ComponentbuilderHelper :: safeString ( $data [ 'custom' ][ 'extends' ], 'F' );
// JFORM_TYPE_PHP <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]][ $this -> hhh . 'JFORM_TYPE_PHP' . $this -> hhh ] = PHP_EOL . PHP_EOL . $this -> _t ( 1 ) . " // " . $this -> setLine ( __LINE__ ) . " A " . $data [ 'custom' ][ 'own_custom' ] . " Field " ;
// load the other PHP options
foreach ( ComponentbuilderHelper :: $phpFieldArray as $x )
{
// reset the php bucket
$phpBucket = '' ;
// only set if avaliable
if ( isset ( $data [ 'custom' ][ 'php' . $x ]) && ComponentbuilderHelper :: checkArray ( $data [ 'custom' ][ 'php' . $x ]))
2016-03-01 18:44:13 +00:00
{
2018-09-24 14:37:51 +00:00
foreach ( $data [ 'custom' ][ 'php' . $x ] as $line => $code )
2016-03-01 18:44:13 +00:00
{
2018-09-24 14:37:51 +00:00
if ( ComponentbuilderHelper :: checkString ( $code ))
{
$phpBucket .= PHP_EOL . $this -> setPlaceholders ( $code , $tabBreak );
}
2016-03-01 18:44:13 +00:00
}
2018-09-24 14:37:51 +00:00
// JFORM_TYPE_PHP <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]][ $this -> hhh . 'JFORM_TYPE_PHP' . $this -> hhh ] .= PHP_EOL . $this -> setPlaceholders ( $phpBucket , $replace );
2016-03-01 18:44:13 +00:00
}
}
}
else
{
2018-09-24 14:37:51 +00:00
// first build the custom field type file
$target = array ( 'admin' => 'customfield' );
$this -> buildDynamique ( $target , 'field' . $data [ 'custom' ][ 'extends' ], $data [ 'custom' ][ 'type' ]);
// make sure the value is reset
$phpCode = '' ;
// now load the php script
if ( isset ( $data [ 'custom' ][ 'php' ]) && ComponentbuilderHelper :: checkArray ( $data [ 'custom' ][ 'php' ]))
2016-03-01 18:44:13 +00:00
{
2018-09-24 14:37:51 +00:00
foreach ( $data [ 'custom' ][ 'php' ] as $line => $code )
2016-03-01 18:44:13 +00:00
{
if ( ComponentbuilderHelper :: checkString ( $code ))
{
if ( $line == 1 )
{
2018-09-24 14:37:51 +00:00
$phpCode .= $this -> setPlaceholders ( $code , $tabBreak );
2016-03-01 18:44:13 +00:00
}
else
{
2018-09-24 14:37:51 +00:00
$phpCode .= PHP_EOL . $this -> _t ( 2 ) . $this -> setPlaceholders ( $code , $tabBreak );
2016-03-01 18:44:13 +00:00
}
}
}
// replace the placholders
2018-09-24 14:37:51 +00:00
$phpCode = $this -> setPlaceholders ( $phpCode , $replace );
2016-03-01 18:44:13 +00:00
}
2018-09-24 14:37:51 +00:00
// catch empty stuff
if ( ! ComponentbuilderHelper :: checkString ( $phpCode ))
2016-03-01 18:44:13 +00:00
{
2018-09-24 14:37:51 +00:00
$phpCode = 'return null;' ;
2016-03-01 18:44:13 +00:00
}
2018-09-24 14:37:51 +00:00
// some house cleaning for users
if ( $data [ 'custom' ][ 'extends' ] === 'user' )
2016-03-01 18:44:13 +00:00
{
2018-09-24 14:37:51 +00:00
// make sure the value is reset
$phpxCode = '' ;
// now load the php xclude script
if ( ComponentbuilderHelper :: checkArray ( $data [ 'custom' ][ 'phpx' ]))
{
foreach ( $data [ 'custom' ][ 'phpx' ] as $line => $code )
{
if ( ComponentbuilderHelper :: checkString ( $code ))
{
if ( $line == 1 )
{
$phpxCode .= $this -> setPlaceholders ( $code , $tabBreak );
}
else
{
$phpxCode .= PHP_EOL . $this -> _t ( 2 ) . $this -> setPlaceholders ( $code , $tabBreak );
}
}
}
// replace the placholders
$phpxCode = $this -> setPlaceholders ( $phpxCode , $replace );
}
// catch empty stuff
if ( ! ComponentbuilderHelper :: checkString ( $phpxCode ))
{
$phpxCode = 'return null;' ;
}
// temp holder for name
$tempName = $data [ 'custom' ][ 'label' ] . ' Group' ;
// set lang
2019-07-04 23:53:54 +00:00
$groupLangName = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeFieldName ( $tempName , true );
2018-09-24 14:37:51 +00:00
// add to lang array
2019-07-04 23:53:54 +00:00
$this -> setLangContent ( $this -> lang , $groupLangName , ComponentbuilderHelper :: safeString ( $tempName , 'W' ));
2018-09-24 14:37:51 +00:00
// build the Group Control
$this -> setGroupControl [ $data [ 'type' ]] = $groupLangName ;
// JFORM_GETGROUPS_PHP <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]][ $this -> hhh . 'JFORM_GETGROUPS_PHP' . $this -> hhh ] = $phpCode ;
// JFORM_GETEXCLUDED_PHP <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]][ $this -> hhh . 'JFORM_GETEXCLUDED_PHP' . $this -> hhh ] = $phpxCode ;
2016-03-01 18:44:13 +00:00
}
2018-09-24 14:37:51 +00:00
else
{
// JFORM_GETOPTIONS_PHP <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]][ $this -> hhh . 'JFORM_GETOPTIONS_PHP' . $this -> hhh ] = $phpCode ;
}
// type <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]][ $this -> hhh . 'ADD_BUTTON' . $this -> hhh ] = $this -> setAddButtonToListField ( $data [ 'custom' ]);
2016-03-01 18:44:13 +00:00
}
2018-03-30 04:41:33 +00:00
}
}
/**
* set Add Button To List Field ( getInput tweak )
*
* @ param array $fieldData The field custom data
*
* @ return string of getInput class on success empty string otherwise
*
*/
protected function setAddButtonToListField ( $fieldData )
{
// make sure hte view values are set
2018-03-30 07:58:24 +00:00
if ( isset ( $fieldData [ 'add_button' ]) && ( $fieldData [ 'add_button' ] === 'true' || 1 == $fieldData [ 'add_button' ]) &&
isset ( $fieldData [ 'view' ]) && isset ( $fieldData [ 'views' ]) &&
ComponentbuilderHelper :: checkString ( $fieldData [ 'view' ]) && ComponentbuilderHelper :: checkString ( $fieldData [ 'views' ]))
2018-05-11 04:08:14 +00:00
{
2018-08-19 20:15:43 +00:00
// set local component
2019-06-13 21:12:16 +00:00
$local_component = " com_ " . $this -> componentCodeName ;
2018-04-02 19:45:52 +00:00
// check that the component value is set
if ( ! isset ( $fieldData [ 'component' ]) || ! ComponentbuilderHelper :: checkString ( $fieldData [ 'component' ]))
{
2018-08-19 20:15:43 +00:00
$fieldData [ 'component' ] = $local_component ;
2018-04-02 19:45:52 +00:00
}
// check that the componet has the com_ value in it
if ( strpos ( $fieldData [ 'component' ], 'com_' ) === false || strpos ( $fieldData [ 'component' ], '=' ) !== false )
{
$fieldData [ 'component' ] = " com_ " . $fieldData [ 'component' ];
}
2018-05-22 19:01:36 +00:00
// make sure the component is update if # # # or [ [ [ component placeholder is used
if ( strpos ( $fieldData [ 'component' ], $this -> hhh ) !== false || strpos ( $fieldData [ 'component' ], $this -> bbb ) !== false ) // should not be needed... but
2018-04-02 19:45:52 +00:00
{
$fieldData [ 'component' ] = $this -> setPlaceholders ( $fieldData [ 'component' ], $this -> placeholders );
}
2019-06-13 21:12:16 +00:00
// get core permissions
$coreLoad = false ;
// add ref tags
$refLoad = true ;
2018-08-19 20:15:43 +00:00
// fall back on the field component
$component = $fieldData [ 'component' ];
// check if we should add ref tags (since it only works well on local views)
if ( $local_component !== $component )
{
// do not add ref tags
$refLoad = false ;
}
2019-06-13 21:12:16 +00:00
// get core permisssions
2018-04-02 19:45:52 +00:00
if ( isset ( $this -> permissionCore [ $fieldData [ 'view' ]]))
{
// get the core permission naming array
$core = $this -> permissionCore [ $fieldData [ 'view' ]];
// set switch to activate easy update
$coreLoad = true ;
}
// start building the add buttons/s
2018-03-30 04:41:33 +00:00
$addButton = array ();
2018-05-26 10:03:08 +00:00
$addButton [] = PHP_EOL . PHP_EOL . $this -> _t ( 1 ) . " /** " ;
$addButton [] = $this -> _t ( 1 ) . " * Override to add new button " ;
$addButton [] = $this -> _t ( 1 ) . " * " ;
$addButton [] = $this -> _t ( 1 ) . " * @return string The field input markup. " ;
$addButton [] = $this -> _t ( 1 ) . " * " ;
$addButton [] = $this -> _t ( 1 ) . " * @since 3.2 " ;
$addButton [] = $this -> _t ( 1 ) . " */ " ;
$addButton [] = $this -> _t ( 1 ) . " protected function getInput() " ;
$addButton [] = $this -> _t ( 1 ) . " { " ;
$addButton [] = $this -> _t ( 2 ) . " // " . $this -> setLine ( __LINE__ ) . " see if we should add buttons " ;
2019-06-13 21:12:16 +00:00
$addButton [] = $this -> _t ( 2 ) . " \$ set_button = \$ this->getAttribute('button'); " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 2 ) . " // " . $this -> setLine ( __LINE__ ) . " get html " ;
$addButton [] = $this -> _t ( 2 ) . " \$ html = parent::getInput(); " ;
$addButton [] = $this -> _t ( 2 ) . " // " . $this -> setLine ( __LINE__ ) . " if true set button " ;
2019-06-13 21:12:16 +00:00
$addButton [] = $this -> _t ( 2 ) . " if ( \$ set_button === 'true') " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 2 ) . " { " ;
$addButton [] = $this -> _t ( 3 ) . " \$ button = array(); " ;
$addButton [] = $this -> _t ( 3 ) . " \$ script = array(); " ;
2019-06-13 21:12:16 +00:00
$addButton [] = $this -> _t ( 3 ) . " \$ button_code_name = \$ this->getAttribute('name'); " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 3 ) . " // " . $this -> setLine ( __LINE__ ) . " get the input from url " ;
$addButton [] = $this -> _t ( 3 ) . " \$ app = JFactory::getApplication(); " ;
$addButton [] = $this -> _t ( 3 ) . " \$ jinput = \$ app->input; " ;
$addButton [] = $this -> _t ( 3 ) . " // " . $this -> setLine ( __LINE__ ) . " get the view name & id " ;
$addButton [] = $this -> _t ( 3 ) . " \$ values = \$ jinput->getArray(array( " ;
$addButton [] = $this -> _t ( 4 ) . " 'id' => 'int', " ;
2018-08-19 20:15:43 +00:00
$addButton [] = $this -> _t ( 4 ) . " 'view' => 'word' " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 3 ) . " )); " ;
$addButton [] = $this -> _t ( 3 ) . " // " . $this -> setLine ( __LINE__ ) . " check if new item " ;
$addButton [] = $this -> _t ( 3 ) . " \$ ref = ''; " ;
$addButton [] = $this -> _t ( 3 ) . " \$ refJ = ''; " ;
2018-04-02 19:45:52 +00:00
if ( $refLoad )
2018-03-30 04:41:33 +00:00
{
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 3 ) . " if (!is_null( \$ values['id']) && strlen( \$ values['view'])) " ;
$addButton [] = $this -> _t ( 3 ) . " { " ;
2018-08-19 20:15:43 +00:00
$addButton [] = $this -> _t ( 4 ) . " // " . $this -> setLine ( __LINE__ ) . " only load referral if not new item. " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 4 ) . " \$ ref = '&ref=' . \$ values['view'] . '&refid=' . \$ values['id']; " ;
$addButton [] = $this -> _t ( 4 ) . " \$ refJ = '&ref=' . \$ values['view'] . '&refid=' . \$ values['id']; " ;
2018-08-18 12:09:17 +00:00
$addButton [] = $this -> _t ( 4 ) . " // " . $this -> setLine ( __LINE__ ) . " get the return value. " ;
$addButton [] = $this -> _t ( 4 ) . " \$ _uri = (string) JUri::getInstance(); " ;
$addButton [] = $this -> _t ( 4 ) . " \$ _return = urlencode(base64_encode( \$ _uri)); " ;
$addButton [] = $this -> _t ( 4 ) . " // " . $this -> setLine ( __LINE__ ) . " load return value. " ;
$addButton [] = $this -> _t ( 4 ) . " \$ ref .= '&return=' . \$ _return; " ;
$addButton [] = $this -> _t ( 4 ) . " \$ refJ .= '&return=' . \$ _return; " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 3 ) . " } " ;
2018-03-30 04:41:33 +00:00
}
else
{
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 3 ) . " if (!is_null( \$ values['id']) && strlen( \$ values['view'])) " ;
$addButton [] = $this -> _t ( 3 ) . " { " ;
2018-08-19 20:15:43 +00:00
$addButton [] = $this -> _t ( 4 ) . " // " . $this -> setLine ( __LINE__ ) . " only load field details if not new item. " ;
$addButton [] = $this -> _t ( 4 ) . " \$ ref = '&field=' . \$ values['view'] . '&field_id=' . \$ values['id']; " ;
$addButton [] = $this -> _t ( 4 ) . " \$ refJ = '&field=' . \$ values['view'] . '&field_id=' . \$ values['id']; " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 4 ) . " // " . $this -> setLine ( __LINE__ ) . " get the return value. " ;
$addButton [] = $this -> _t ( 4 ) . " \$ _uri = (string) JUri::getInstance(); " ;
$addButton [] = $this -> _t ( 4 ) . " \$ _return = urlencode(base64_encode( \$ _uri)); " ;
$addButton [] = $this -> _t ( 4 ) . " // " . $this -> setLine ( __LINE__ ) . " load return value. " ;
$addButton [] = $this -> _t ( 4 ) . " \$ ref = '&return=' . \$ _return; " ;
$addButton [] = $this -> _t ( 4 ) . " \$ refJ = '&return=' . \$ _return; " ;
$addButton [] = $this -> _t ( 3 ) . " } " ;
}
2019-06-13 21:12:16 +00:00
$addButton [] = $this -> _t ( 3 ) . " // " . $this -> setLine ( __LINE__ ) . " get button label " ;
$addButton [] = $this -> _t ( 3 ) . " \$ button_label = trim( \$ button_code_name); " ;
$addButton [] = $this -> _t ( 3 ) . " \$ button_label = preg_replace('/_+/', ' ', \$ button_label); " ;
$addButton [] = $this -> _t ( 3 ) . " \$ button_label = preg_replace('/ \ s+/', ' ', \$ button_label); " ;
$addButton [] = $this -> _t ( 3 ) . " \$ button_label = preg_replace( \" /[^A-Za-z ]/ \" , '', \$ button_label); " ;
$addButton [] = $this -> _t ( 3 ) . " \$ button_label = ucfirst(strtolower( \$ button_label)); " ;
$addButton [] = $this -> _t ( 3 ) . " // " . $this -> setLine ( __LINE__ ) . " get user object " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 3 ) . " \$ user = JFactory::getUser(); " ;
$addButton [] = $this -> _t ( 3 ) . " // " . $this -> setLine ( __LINE__ ) . " only add if user allowed to create " . $fieldData [ 'view' ];
2018-03-30 04:41:33 +00:00
// check if the item has permissions.
if ( $coreLoad && isset ( $core [ 'core.create' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && in_array ( $fieldData [ 'view' ], $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]))
{
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 3 ) . " if ( \$ user->authorise(' " . $core [ 'core.create' ] . " ', ' " . $component . " ') && \$ app->isAdmin()) // TODO for now only in admin area. " ;
2018-03-30 04:41:33 +00:00
}
else
{
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 3 ) . " if ( \$ user->authorise('core.create', ' " . $component . " ') && \$ app->isAdmin()) // TODO for now only in admin area. " ;
}
$addButton [] = $this -> _t ( 3 ) . " { " ;
$addButton [] = $this -> _t ( 4 ) . " // " . $this -> setLine ( __LINE__ ) . " build Create button " ;
2019-06-13 21:12:16 +00:00
$addButton [] = $this -> _t ( 4 ) . " \$ button[] = '<a id= \" '. \$ button_code_name.'Create \" class= \" btn btn-small btn-success hasTooltip \" title= \" '.JText: " . " :sprintf(' " . $this -> langPrefix . " _CREATE_NEW_S', \$ button_label).' \" style= \" border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px; \" " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 5 ) . " href= \" index.php?option= " . $fieldData [ 'component' ] . " &view= " . $fieldData [ 'view' ] . " &layout=edit'. \$ ref.' \" > " ;
$addButton [] = $this -> _t ( 5 ) . " <span class= \" icon-new icon-white \" ></span></a>'; " ;
$addButton [] = $this -> _t ( 3 ) . " } " ;
$addButton [] = $this -> _t ( 3 ) . " // " . $this -> setLine ( __LINE__ ) . " only add if user allowed to edit " . $fieldData [ 'view' ];
2018-03-30 04:41:33 +00:00
// check if the item has permissions.
if ( $coreLoad && isset ( $core [ 'core.edit' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && in_array ( $fieldData [ 'view' ], $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]))
{
2019-06-13 21:12:16 +00:00
$addButton [] = $this -> _t ( 3 ) . " if ( \$ user->authorise(' " . $core [ 'core.edit' ] . " ', ' " . $component . " ') && \$ app->isAdmin()) // TODO for now only in admin area. " ;
2018-03-30 04:41:33 +00:00
}
else
{
2019-06-13 21:12:16 +00:00
$addButton [] = $this -> _t ( 3 ) . " if ( \$ user->authorise('core.edit', ' " . $component . " ') && \$ app->isAdmin()) // TODO for now only in admin area. " ;
2018-05-26 10:03:08 +00:00
}
$addButton [] = $this -> _t ( 3 ) . " { " ;
$addButton [] = $this -> _t ( 4 ) . " // " . $this -> setLine ( __LINE__ ) . " build edit button " ;
2019-06-13 21:12:16 +00:00
$addButton [] = $this -> _t ( 4 ) . " \$ button[] = '<a id= \" '. \$ button_code_name.'Edit \" class= \" btn btn-small hasTooltip \" title= \" '.JText: " . " :sprintf(' " . $this -> langPrefix . " _EDIT_S', \$ button_label).' \" style= \" display: none; padding: 4px 4px 4px 7px; \" href= \" # \" > " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 5 ) . " <span class= \" icon-edit \" ></span></a>'; " ;
$addButton [] = $this -> _t ( 4 ) . " // " . $this -> setLine ( __LINE__ ) . " build script " ;
$addButton [] = $this -> _t ( 4 ) . " \$ script[] = \" " ;
$addButton [] = $this -> _t ( 5 ) . " jQuery(document).ready(function() { " ;
2019-06-13 21:12:16 +00:00
$addButton [] = $this -> _t ( 6 ) . " jQuery('#adminForm').on('change', '#jform_ \" . \$ button_code_name. \" ',function (e) { " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 7 ) . " e.preventDefault(); " ;
2019-06-13 21:12:16 +00:00
$addButton [] = $this -> _t ( 7 ) . " var \" . \$ button_code_name. \" Value = jQuery('#jform_ \" . \$ button_code_name. \" ').val(); " ;
$addButton [] = $this -> _t ( 7 ) . " \" . \$ button_code_name. \" Button( \" . \$ button_code_name. \" Value); " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 6 ) . " }); " ;
2019-06-13 21:12:16 +00:00
$addButton [] = $this -> _t ( 6 ) . " var \" . \$ button_code_name. \" Value = jQuery('#jform_ \" . \$ button_code_name. \" ').val(); " ;
$addButton [] = $this -> _t ( 6 ) . " \" . \$ button_code_name. \" Button( \" . \$ button_code_name. \" Value); " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 5 ) . " }); " ;
2019-06-13 21:12:16 +00:00
$addButton [] = $this -> _t ( 5 ) . " function \" . \$ button_code_name. \" Button(value) { " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 6 ) . " if (value > 0) { " ; // TODO not ideal since value may not be an (int)
$addButton [] = $this -> _t ( 7 ) . " // hide the create button " ;
2019-06-13 21:12:16 +00:00
$addButton [] = $this -> _t ( 7 ) . " jQuery('# \" . \$ button_code_name. \" Create').hide(); " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 7 ) . " // show edit button " ;
2019-06-13 21:12:16 +00:00
$addButton [] = $this -> _t ( 7 ) . " jQuery('# \" . \$ button_code_name. \" Edit').show(); " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 7 ) . " var url = 'index.php?option= " . $fieldData [ 'component' ] . " &view= " . $fieldData [ 'views' ] . " &task= " . $fieldData [ 'view' ] . " .edit&id='+value+' \" . \$ refJ. \" '; " ; // TODO this value may not be the ID
2019-06-13 21:12:16 +00:00
$addButton [] = $this -> _t ( 7 ) . " jQuery('# \" . \$ button_code_name. \" Edit').attr('href', url); " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 6 ) . " } else { " ;
$addButton [] = $this -> _t ( 7 ) . " // show the create button " ;
2019-06-13 21:12:16 +00:00
$addButton [] = $this -> _t ( 7 ) . " jQuery('# \" . \$ button_code_name. \" Create').show(); " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 7 ) . " // hide edit button " ;
2019-06-13 21:12:16 +00:00
$addButton [] = $this -> _t ( 7 ) . " jQuery('# \" . \$ button_code_name. \" Edit').hide(); " ;
2018-05-26 10:03:08 +00:00
$addButton [] = $this -> _t ( 6 ) . " } " ;
$addButton [] = $this -> _t ( 5 ) . " } \" ; " ;
$addButton [] = $this -> _t ( 3 ) . " } " ;
$addButton [] = $this -> _t ( 3 ) . " // " . $this -> setLine ( __LINE__ ) . " check if button was created for " . $fieldData [ 'view' ] . " field. " ;
$addButton [] = $this -> _t ( 3 ) . " if (is_array( \$ button) && count( \$ button) > 0) " ;
$addButton [] = $this -> _t ( 3 ) . " { " ;
$addButton [] = $this -> _t ( 4 ) . " // " . $this -> setLine ( __LINE__ ) . " Load the needed script. " ;
$addButton [] = $this -> _t ( 4 ) . " \$ document = JFactory::getDocument(); " ;
$addButton [] = $this -> _t ( 4 ) . " \$ document->addScriptDeclaration(implode(' ', \$ script)); " ;
$addButton [] = $this -> _t ( 4 ) . " // " . $this -> setLine ( __LINE__ ) . " return the button attached to input field. " ;
$addButton [] = $this -> _t ( 4 ) . " return '<div class= \" input-append \" >' . \$ html . implode('', \$ button).'</div>'; " ;
$addButton [] = $this -> _t ( 3 ) . " } " ;
$addButton [] = $this -> _t ( 2 ) . " } " ;
$addButton [] = $this -> _t ( 2 ) . " return \$ html; " ;
$addButton [] = $this -> _t ( 1 ) . " } " ;
2018-03-30 04:41:33 +00:00
return implode ( PHP_EOL , $addButton );
2016-03-01 18:44:13 +00:00
}
2018-03-30 04:41:33 +00:00
return '' ;
2016-03-01 18:44:13 +00:00
}
2017-12-03 19:12:56 +00:00
/**
* xmlPrettyPrint
*
* @ param SimpleXMLElement $xml The XML element containing a node to be output
* @ param string $nodename node name of the input xml element to print out . this is done to omit the < ? xml ... tag
*
* @ return string XML output
*
*/
2017-12-03 17:08:01 +00:00
public function xmlPrettyPrint ( $xml , $nodename )
{
$dom = dom_import_simplexml ( $xml ) -> ownerDocument ;
$dom -> formatOutput = true ;
2017-12-03 17:47:48 +00:00
$xmlString = $dom -> saveXML ( $dom -> getElementsByTagName ( $nodename ) -> item ( 0 ));
2017-12-12 22:17:02 +00:00
// make sure Tidy is enabled
if ( $this -> tidy )
{
$tidy = new Tidy ();
2017-12-14 23:10:47 +00:00
$tidy -> parseString ( $xmlString , array ( 'indent' => true , 'indent-spaces' => 8 , 'input-xml' => true , 'output-xml' => true , 'indent-attributes' => true , 'wrap-attributes' => true , 'wrap' => false ));
2017-12-12 22:17:02 +00:00
$tidy -> cleanRepair ();
2017-12-14 23:10:47 +00:00
return $this -> xmlIndent (( string ) $tidy , ' ' , 8 , true , false );
2017-12-12 22:17:02 +00:00
}
// set tidy waring atleast once
elseif ( ! $this -> setTidyWarning )
{
// set the warning only once
$this -> setTidyWarning = true ;
// now set the warning
2018-09-25 20:02:48 +00:00
$this -> app -> enqueueMessage ( JText :: _ ( '<hr /><h3>Tidy Error</h3>' ), 'Error' );
$this -> app -> enqueueMessage ( JText :: _ ( 'You must enable the <b>Tidy</b> extension in your php.ini file so we can tidy up your xml! If you need help please <a href="https://github.com/vdm-io/Joomla-Component-Builder/issues/197#issuecomment-351181754" target="_blank">start here</a>!' ), 'Error' );
2017-12-12 22:17:02 +00:00
}
return $xmlString ;
2017-12-03 19:12:56 +00:00
}
2017-12-14 23:10:47 +00:00
2017-12-03 19:12:56 +00:00
/**
* xmlIndent
*
* @ param string $string The XML input
* @ param string $char Character or characters to use as the repeated indent
* @ param integer $depth number of times to repeat the indent character
* @ param boolean $skipfirst Skip the first line of the input .
* @ param boolean $skiplast Skip the last line of the input ;
*
* @ return string XML output
*
*/
2017-12-14 23:10:47 +00:00
public function xmlIndent ( $string , $char = ' ' , $depth = 0 , $skipfirst = false , $skiplast = false )
2017-12-05 11:25:43 +00:00
{
2017-12-03 19:12:56 +00:00
$output = array ();
2017-12-14 23:10:47 +00:00
$lines = explode ( " \n " , $string );
2017-12-03 19:12:56 +00:00
$first = true ;
2017-12-14 23:10:47 +00:00
$last = count ( $lines ) - 1 ;
foreach ( $lines as $i => $line )
2017-12-03 19:12:56 +00:00
{
2017-12-14 23:10:47 +00:00
$output [] = (( $first && $skipfirst ) || $i === $last && $skiplast ) ? $line : str_repeat ( $char , $depth ) . $line ;
2017-12-03 19:12:56 +00:00
$first = false ;
}
2017-12-14 23:10:47 +00:00
return implode ( " \n " , $output );
2017-12-03 17:08:01 +00:00
}
2016-03-01 18:44:13 +00:00
}