2016-03-01 18:44:13 +00:00
< ? php
2016-03-04 00:01:43 +00:00
/**--------------------------------------------------------------------------------------------------------| www . vdm . io |------/
__ __ _ _____ _ _ __ __ _ _ _
\ \ / / | | | __ \ | | | | | \ / | | | | | | |
\ \ / / _ _ ___ | | _ | | | | _____ _____ | | ___ _ __ _ __ ___ ___ _ __ | | _ | \ / | ___ | | _ | | __ ___ __ | |
\ \ / / _ ` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| ' _ \ / _ \ / _ ` |
\ / ( _ | \__ \ | _ | | __ | | __ / \ V / __ / | ( _ ) | | _ ) | | | | | | __ / | | | | _ | | | | __ / | _ | | | | ( _ ) | ( _ | |
\ / \__ , _ | ___ / \__ | | _____ / \___ | \_ / \___ | _ | \___ /| . __ /| _ | | _ | | _ | \___ | _ | | _ | \__ | | _ | | _ | \___ | \__ | _ | | _ | \___ / \__ , _ |
| |
| _ |
/-------------------------------------------------------------------------------------------------------------------------------/
2016-03-01 18:44:13 +00:00
2017-10-30 13:30:20 +00:00
@ version 2.6 . 0
2016-03-04 00:01:43 +00:00
@ created 30 th April , 2015
@ package Component Builder
@ subpackage compiler . php
@ author Llewellyn van der Merwe < http :// www . vdm . io >
@ my wife Roline van der Merwe < http :// www . vdm . io />
@ copyright Copyright ( C ) 2015. All Rights Reserved
@ license GNU / GPL Version 2 or later - http :// www . gnu . org / licenses / gpl - 2.0 . html
Builds Complex Joomla Components
/-----------------------------------------------------------------------------------------------------------------------------*/
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
{
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 ();
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 ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* layout builder
*
* @ var array
*/
public $layoutBuilder = array ();
2017-08-12 11:47:25 +00:00
/**
* used to fix the zero order
*
* @ var array
*/
private $zeroOrderFix = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Site field data
*
* @ var array
*/
public $siteFieldData = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Category other name bucket
*
* @ var array
*/
public $catOtherName = array ();
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 ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* tags builder
*
* @ var array
*/
public $tagsBuilder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* query builder
*
* @ var array
*/
public $queryBuilder = array ();
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 ();
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 ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* history builder
*
* @ var array
*/
public $historyBuilder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* alias builder
*
* @ var array
*/
public $aliasBuilder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* title builder
*
* @ var array
*/
public $titleBuilder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* list builder
*
* @ var array
*/
public $listBuilder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* custom Builder List
*
* @ var array
*/
public $customBuilderList = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Hidden Fields Builder
*
* @ var array
*/
public $hiddenFieldsBuilder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* INT Field Builder
*
* @ var array
*/
public $intFieldsBuilder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Dynamic Fields Builder
*
* @ var array
*/
public $dynamicfieldsBuilder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Main text Builder
*
* @ var array
*/
public $maintextBuilder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Custom Builder
*
* @ var array
*/
public $customBuilder = array ();
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 ();
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 ();
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 ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Category builder
*
* @ var array
*/
public $categoryBuilder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Category Code builder
*
* @ var array
*/
public $catCodeBuilder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Check Box builder
*
* @ var array
*/
public $checkboxBuilder = array ();
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-06-18 07:37:48 +00:00
/**
* Json String Builder for return values to array
*
* @ var array
*/
public $jsonItemBuilderArray = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Json Item Builder
*
* @ var array
*/
public $jsonItemBuilder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Base 64 Builder
*
* @ var array
*/
public $base64Builder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Basic Encryption Builder
*
* @ var array
*/
public $basicEncryptionBuilder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Advnaced Encryption Builder
*
* @ var array
*/
public $advancedEncryptionBuilder = array ();
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 ();
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 ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Selection Translation Fix Builder
*
* @ var array
*/
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 ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Search Builder
*
* @ var array
*/
public $searchBuilder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Filter Builder
*
* @ var array
*/
public $filterBuilder = array ();
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 ();
2016-06-02 16:18:49 +00:00
/**
* Set Field Names
*
* @ var array
*/
2017-03-06 12:06:51 +00:00
public $fieldsNames = array ();
/**
* Set unique Names
*
* @ var array
*/
public $uniqueNames = array ();
2016-06-02 16:18:49 +00:00
/**
* Default Fields
*
* @ var array
*/
public $defaultFields = array ( 'created' , 'created_by' , 'modified' , 'modified_by' , 'published' , 'ordering' , 'access' , 'version' , 'hits' , 'id' );
/**
* Default Fields set to publishing
*
* @ var array
*/
public $newPublishingFields = array ();
/**
* Default Fields set to publishing
*
* @ var array
*/
public $movedPublishingFields = array ();
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
{
return ' [Fields ' . $nr . ']' ;
}
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
*
* @ param array $view The view data
* @ param string $component The component name
*
* @ return string The fields set in xml
*
*/
public function setFieldSet ( $view , $component )
{
// setup the fieldset of this view
if ( isset ( $view [ 'settings' ] -> fields ) && ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> fields ))
{
// setup the list view and single view name
$listViewName = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_list );
$viewName = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_single );
2017-03-06 12:06:51 +00:00
// set some place holder for this view
$this -> placeholders [ '###view###' ] = $viewName ;
$this -> placeholders [ '###VIEW###' ] = strtoupper ( $viewName );
$this -> placeholders [ '###View###' ] = ucfirst ( $viewName );
$this -> placeholders [ '[[[view]]]' ] = $this -> placeholders [ '###view###' ];
$this -> placeholders [ '[[[VIEW]]]' ] = $this -> placeholders [ '###VIEW###' ];
$this -> placeholders [ '[[[View]]]' ] = $this -> placeholders [ '###View###' ];
$this -> placeholders [ '###views###' ] = $listViewName ;
$this -> placeholders [ '###VIEWS###' ] = strtoupper ( $listViewName );
$this -> placeholders [ '###Views###' ] = ucfirst ( $listViewName );
$this -> placeholders [ '[[[views]]]' ] = $this -> placeholders [ '###views###' ];
$this -> placeholders [ '[[[VIEWS]]]' ] = $this -> placeholders [ '###VIEWS###' ];
$this -> placeholders [ '[[[Views]]]' ] = $this -> placeholders [ '###Views###' ];
2016-03-01 18:44:13 +00:00
// 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
{
$this -> metadataBuilder [ $viewName ] = $viewName ;
}
// 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
{
$this -> accessBuilder [ $viewName ] = $viewName ;
}
// set the read only
$readOnly = " " ;
if ( $view [ 'settings' ] -> type == 2 )
{
2017-02-09 16:11:10 +00:00
$readOnly = " \t \t \t " . 'readonly="true"' . PHP_EOL . " \t \t \t " . 'disabled="true"' ;
2016-03-01 18:44:13 +00:00
}
// main lang prefix
2017-03-06 12:06:51 +00:00
$langView = $this -> langPrefix . '_' . $this -> placeholders [ '###VIEW###' ];
$langViews = $this -> langPrefix . '_' . $this -> placeholders [ '###VIEWS###' ];
2016-03-01 18:44:13 +00:00
// set default lang
$this -> langContent [ $this -> lang ][ $langView ] = $view [ 'settings' ] -> name_single ;
$this -> langContent [ $this -> lang ][ $langViews ] = $view [ 'settings' ] -> name_list ;
2017-03-06 12:06:51 +00:00
// set the single name
2016-03-01 18:44:13 +00:00
$viewSingleName = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_single , 'W' );
// set global item strings
$this -> langContent [ $this -> lang ][ $langViews . '_N_ITEMS_ARCHIVED' ] = " %s " . $view [ 'settings' ] -> name_list . " archived. " ;
$this -> langContent [ $this -> lang ][ $langViews . '_N_ITEMS_ARCHIVED_1' ] = " %s " . $view [ 'settings' ] -> name_single . " archived. " ;
$this -> langContent [ $this -> lang ][ $langViews . '_N_ITEMS_CHECKED_IN_0' ] = " No " . $view [ 'settings' ] -> name_single . " successfully checked in. " ;
$this -> langContent [ $this -> lang ][ $langViews . '_N_ITEMS_CHECKED_IN_1' ] = " %d " . $view [ 'settings' ] -> name_single . " successfully checked in. " ;
$this -> langContent [ $this -> lang ][ $langViews . '_N_ITEMS_CHECKED_IN_MORE' ] = " %d " . $view [ 'settings' ] -> name_list . " successfully checked in. " ;
$this -> langContent [ $this -> lang ][ $langViews . '_N_ITEMS_DELETED' ] = " %s " . $view [ 'settings' ] -> name_list . " deleted. " ;
$this -> langContent [ $this -> lang ][ $langViews . '_N_ITEMS_DELETED_1' ] = " %s " . $view [ 'settings' ] -> name_single . " deleted. " ;
$this -> langContent [ $this -> lang ][ $langViews . '_N_ITEMS_FEATURED' ] = " %s " . $view [ 'settings' ] -> name_list . " featured. " ;
$this -> langContent [ $this -> lang ][ $langViews . '_N_ITEMS_FEATURED_1' ] = " %s " . $view [ 'settings' ] -> name_single . " featured. " ;
$this -> langContent [ $this -> lang ][ $langViews . '_N_ITEMS_PUBLISHED' ] = " %s " . $view [ 'settings' ] -> name_list . " published. " ;
$this -> langContent [ $this -> lang ][ $langViews . '_N_ITEMS_PUBLISHED_1' ] = " %s " . $view [ 'settings' ] -> name_single . " published. " ;
$this -> langContent [ $this -> lang ][ $langViews . '_N_ITEMS_TRASHED' ] = " %s " . $view [ 'settings' ] -> name_list . " trashed. " ;
$this -> langContent [ $this -> lang ][ $langViews . '_N_ITEMS_TRASHED_1' ] = " %s " . $view [ 'settings' ] -> name_single . " trashed. " ;
$this -> langContent [ $this -> lang ][ $langViews . '_N_ITEMS_UNFEATURED' ] = " %s " . $view [ 'settings' ] -> name_list . " unfeatured. " ;
$this -> langContent [ $this -> lang ][ $langViews . '_N_ITEMS_UNFEATURED_1' ] = " %s " . $view [ 'settings' ] -> name_single . " unfeatured. " ;
$this -> langContent [ $this -> lang ][ $langViews . '_N_ITEMS_UNPUBLISHED' ] = " %s " . $view [ 'settings' ] -> name_list . " unpublished. " ;
$this -> langContent [ $this -> lang ][ $langViews . '_N_ITEMS_UNPUBLISHED_1' ] = " %s " . $view [ 'settings' ] -> name_single . " unpublished. " ;
$this -> langContent [ $this -> lang ][ $langViews . '_BATCH_OPTIONS' ] = " Batch process the selected " . $view [ 'settings' ] -> name_list ;
$this -> langContent [ $this -> lang ][ $langViews . '_BATCH_TIP' ] = " All changes will be applied to all selected " . $view [ 'settings' ] -> name_list ;
// set some basic defaults
$this -> langContent [ $this -> lang ][ $langView . '_ERROR_UNIQUE_ALIAS' ] = " Another " . $view [ 'settings' ] -> name_single . " has the same alias. " ;
2016-06-02 16:18:49 +00:00
$this -> langContent [ $this -> lang ][ $langView . '_CREATED_DATE_LABEL' ] = " Created Date " ;
$this -> langContent [ $this -> lang ][ $langView . '_CREATED_DATE_DESC' ] = " The date this " . $view [ 'settings' ] -> name_single . " was created. " ;
$this -> langContent [ $this -> lang ][ $langView . '_MODIFIED_DATE_LABEL' ] = " Modified Date " ;
$this -> langContent [ $this -> lang ][ $langView . '_MODIFIED_DATE_DESC' ] = " The date this " . $view [ 'settings' ] -> name_single . " was modified. " ;
$this -> langContent [ $this -> lang ][ $langView . '_CREATED_BY_LABEL' ] = " Created By " ;
$this -> langContent [ $this -> lang ][ $langView . '_CREATED_BY_DESC' ] = " The user that created this " . $view [ 'settings' ] -> name_single . " . " ;
$this -> langContent [ $this -> lang ][ $langView . '_MODIFIED_BY_LABEL' ] = " Modified By " ;
$this -> langContent [ $this -> lang ][ $langView . '_MODIFIED_BY_DESC' ] = " The last user that modified this " . $view [ 'settings' ] -> name_single . " . " ;
2016-03-01 18:44:13 +00:00
$this -> langContent [ $this -> lang ][ $langView . '_ORDERING_LABEL' ] = " Ordering " ;
$this -> langContent [ $this -> lang ][ $langView . '_VERSION_LABEL' ] = " Revision " ;
$this -> langContent [ $this -> lang ][ $langView . '_VERSION_DESC' ] = " A count of the number of times this " . $view [ 'settings' ] -> name_single . " has been revised. " ;
$this -> langContent [ $this -> lang ][ $langView . '_SAVE_WARNING' ] = " Alias already existed so a number was added at the end. You can re-edit the " . $view [ 'settings' ] -> name_single . " to customise the alias. " ;
2016-06-02 16:18:49 +00:00
2017-03-06 12:06:51 +00:00
// check if the same field is added multiple times
foreach ( $view [ 'settings' ] -> fields as $field )
{
$name = ComponentbuilderHelper :: safeString ( $field [ 'settings' ] -> name );
$this -> setUniqueNameKeeper ( $field , $view [ 'settings' ] -> type , $name , $viewName );
}
2016-03-01 18:44:13 +00:00
// start adding dynamc fields
2016-06-02 16:18:49 +00:00
$dynamcfields = '' ;
2016-03-01 18:44:13 +00:00
$spacerCounter = 'a' ;
// set the custom table key
$dbkey = 'g' ;
// TODO we should add the global and local view switch if field for front end
foreach ( $view [ 'settings' ] -> fields as $field )
{
2017-03-08 04:49:54 +00:00
$dynamcfields .= $this -> setDynamicField ( $field , $view , $view [ 'settings' ] -> type , $langView , $viewName , $listViewName , $spacerCounter , $this -> placeholders , $dbkey , true );
2016-06-02 16:18:49 +00:00
}
// set the defautl fields
$fieldSet = array ();
$fieldSet [] = '<fieldset name="details">' ;
$fieldSet [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Default Fields. --> " ;
$fieldSet [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Id Field. Type: Text (joomla) --> " ;
// if id is not set
if ( ! isset ( $this -> fieldsNames [ $viewName ][ 'id' ]))
{
$fieldSet [] = " \t \t <field " ;
$fieldSet [] = " \t \t \t name= " . '"id"' ;
$fieldSet [] = " \t \t \t " . 'type="text" class="readonly" label="JGLOBAL_FIELD_ID_LABEL"' ;
$fieldSet [] = " \t \t \t " . 'description ="JGLOBAL_FIELD_ID_DESC" size="10" default="0"' ;
$fieldSet [] = " \t \t \t " . 'readonly="true"' ;
$fieldSet [] = " \t \t /> " ;
}
// if created is not set
if ( ! isset ( $this -> fieldsNames [ $viewName ][ 'created' ]))
{
$fieldSet [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Date Created Field. Type: Calendar (joomla) --> " ;
$fieldSet [] = " \t \t <field " ;
$fieldSet [] = " \t \t \t name= " . '"created"' ;
$fieldSet [] = " \t \t \t type= " . '"calendar"' ;
$fieldSet [] = " \t \t \t label= " . '"' . $langView . '_CREATED_DATE_LABEL"' ;
$fieldSet [] = " \t \t \t description= " . '"' . $langView . '_CREATED_DATE_DESC"' ;
$fieldSet [] = " \t \t \t size= " . '"22"' ;
$fieldSet [] = $readOnly ;
$fieldSet [] = " \t \t \t format= " . '"%Y-%m-%d %H:%M:%S"' ;
$fieldSet [] = " \t \t \t filter= " . '"user_utc"' ;
$fieldSet [] = " \t \t /> " ;
}
// if created_by is not set
if ( ! isset ( $this -> fieldsNames [ $viewName ][ 'created_by' ]))
{
$fieldSet [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " User Created Field. Type: User (joomla) --> " ;
$fieldSet [] = " \t \t <field " ;
$fieldSet [] = " \t \t \t name= " . '"created_by"' ;
$fieldSet [] = " \t \t \t type= " . '"user"' ;
$fieldSet [] = " \t \t \t label= " . '"' . $langView . '_CREATED_BY_LABEL"' ;
$fieldSet [] = $readOnly ;
$fieldSet [] = " \t \t \t description= " . '"' . $langView . '_CREATED_BY_DESC"' ;
$fieldSet [] = " \t \t /> " ;
}
// if published is not set
if ( ! isset ( $this -> fieldsNames [ $viewName ][ 'published' ]))
{
$fieldSet [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Published Field. Type: List (joomla) --> " ;
$fieldSet [] = " \t \t <field name= " . '"published" type="list" label="JSTATUS"' ;
$fieldSet [] = " \t \t \t description= " . '"JFIELD_PUBLISHED_DESC" class="chzn-color-state"' ;
$fieldSet [] = $readOnly ;
$fieldSet [] = " \t \t \t filter= " . '"intval" size="1" default="1" >' ;
$fieldSet [] = " \t \t \t <option value= " . '"1">' ;
$fieldSet [] = " \t \t \t \t JPUBLISHED</option> " ;
$fieldSet [] = " \t \t \t <option value= " . '"0">' ;
$fieldSet [] = " \t \t \t \t JUNPUBLISHED</option> " ;
$fieldSet [] = " \t \t \t <option value= " . '"2">' ;
$fieldSet [] = " \t \t \t \t JARCHIVED</option> " ;
$fieldSet [] = " \t \t \t <option value= " . '"-2">' ;
$fieldSet [] = " \t \t \t \t JTRASHED</option> " ;
$fieldSet [] = " \t \t </field> " ;
}
// if modified is not set
if ( ! isset ( $this -> fieldsNames [ $viewName ][ 'modified' ]))
{
$fieldSet [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Date Modified Field. Type: Calendar (joomla) --> " ;
$fieldSet [] = " \t \t " . '<field name="modified" type="calendar" class="readonly"' ;
$fieldSet [] = " \t \t \t " . 'label="' . $langView . '_MODIFIED_DATE_LABEL" description="' . $langView . '_MODIFIED_DATE_DESC"' ;
$fieldSet [] = " \t \t \t " . 'size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />' ;
}
// if modified_by is not set
if ( ! isset ( $this -> fieldsNames [ $viewName ][ 'modified_by' ]))
{
$fieldSet [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " User Modified Field. Type: User (joomla) --> " ;
$fieldSet [] = " \t \t " . '<field name="modified_by" type="user"' ;
$fieldSet [] = " \t \t \t " . 'label="' . $langView . '_MODIFIED_BY_LABEL"' ;
$fieldSet [] = " \t \t \t description= " . '"' . $langView . '_MODIFIED_BY_DESC"' ;
$fieldSet [] = " \t \t \t " . 'class="readonly"' ;
$fieldSet [] = " \t \t \t " . 'readonly="true"' ;
$fieldSet [] = " \t \t \t " . 'filter="unset"' ;
$fieldSet [] = " \t \t /> " ;
}
// check if view has access
if ( isset ( $this -> accessBuilder [ $viewName ]) && ComponentbuilderHelper :: checkString ( $this -> accessBuilder [ $viewName ]) && ! isset ( $this -> fieldsNames [ $viewName ][ 'access' ]))
{
$fieldSet [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Access Field. Type: Accesslevel (joomla) --> " ;
$fieldSet [] = " \t \t " . '<field name="access"' ;
$fieldSet [] = " \t \t \t " . 'type="accesslevel"' ;
$fieldSet [] = " \t \t \t " . 'label="JFIELD_ACCESS_LABEL"' ;
$fieldSet [] = " \t \t \t " . 'description="JFIELD_ACCESS_DESC"' ;
$fieldSet [] = " \t \t \t " . 'default="1"' ;
$fieldSet [] = $readOnly ;
$fieldSet [] = " \t \t \t " . 'required="false"' ;
$fieldSet [] = " \t \t /> " ;
}
// if ordering is not set
if ( ! isset ( $this -> fieldsNames [ $viewName ][ 'ordering' ]))
{
$fieldSet [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Ordering Field. Type: Numbers (joomla) --> " ;
$fieldSet [] = " \t \t <field " ;
$fieldSet [] = " \t \t \t " . 'name="ordering"' ;
$fieldSet [] = " \t \t \t " . 'type="number"' ;
$fieldSet [] = " \t \t \t " . 'class="inputbox validate-ordering"' ;
$fieldSet [] = " \t \t \t " . 'label="' . $langView . '_ORDERING_LABEL' . '"' ;
$fieldSet [] = " \t \t \t " . 'description=""' ;
$fieldSet [] = " \t \t \t " . 'default="0"' ;
$fieldSet [] = " \t \t \t " . 'size="6"' ;
$fieldSet [] = $readOnly ;
$fieldSet [] = " \t \t \t " . 'required="false"' ;
$fieldSet [] = " \t \t /> " ;
}
// if version is not set
if ( ! isset ( $this -> fieldsNames [ $viewName ][ 'version' ]))
{
$fieldSet [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Version Field. Type: Text (joomla) --> " ;
$fieldSet [] = " \t \t <field " ;
$fieldSet [] = " \t \t \t " . 'name="version"' ;
$fieldSet [] = " \t \t \t " . 'type="text"' ;
$fieldSet [] = " \t \t \t " . 'class="readonly"' ;
$fieldSet [] = " \t \t \t " . 'label="' . $langView . '_VERSION_LABEL"' ;
$fieldSet [] = " \t \t \t " . 'description="' . $langView . '_VERSION_DESC"' ;
$fieldSet [] = " \t \t \t " . 'size="6"' ;
$fieldSet [] = " \t \t \t " . 'readonly="true"' ;
$fieldSet [] = " \t \t \t " . 'filter="unset"' ;
$fieldSet [] = " \t \t /> " ;
2016-03-01 18:44:13 +00:00
}
// check if metadata is added to this view
if ( isset ( $this -> metadataBuilder [ $viewName ]) && ComponentbuilderHelper :: checkString ( $this -> metadataBuilder [ $viewName ]))
{
2016-06-02 16:18:49 +00:00
// metakey
$fieldSet [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Metakey Field. Type: Textarea (joomla) --> " ;
$fieldSet [] = " \t \t <field " ;
$fieldSet [] = " \t \t \t " . 'name="metakey"' ;
$fieldSet [] = " \t \t \t " . 'type="textarea"' ;
$fieldSet [] = " \t \t \t " . 'label="JFIELD_META_KEYWORDS_LABEL"' ;
$fieldSet [] = " \t \t \t " . 'description="JFIELD_META_KEYWORDS_DESC"' ;
$fieldSet [] = " \t \t \t " . 'rows="3"' ;
$fieldSet [] = " \t \t \t " . 'cols="30"' ;
$fieldSet [] = " \t \t /> " ;
// metadesc
$fieldSet [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Metadesc Field. Type: Textarea (joomla) --> " ;
$fieldSet [] = " \t \t <field " ;
$fieldSet [] = " \t \t \t " . 'name="metadesc"' ;
$fieldSet [] = " \t \t \t " . 'type="textarea"' ;
$fieldSet [] = " \t \t \t " . 'label="JFIELD_META_DESCRIPTION_LABEL"' ;
$fieldSet [] = " \t \t \t " . 'description="JFIELD_META_DESCRIPTION_DESC"' ;
$fieldSet [] = " \t \t \t " . 'rows="3"' ;
$fieldSet [] = " \t \t \t " . 'cols="30"' ;
$fieldSet [] = " \t \t /> " ;
}
// load the dynamic fields now
if ( ComponentbuilderHelper :: checkString ( $dynamcfields ))
{
$fieldSet [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Dynamic Fields. --> " . $dynamcfields ;
}
// close fieldset
$fieldSet [] = " \t </fieldset> " ;
// check if metadata is added to this view
if ( isset ( $this -> metadataBuilder [ $viewName ]) && ComponentbuilderHelper :: checkString ( $this -> metadataBuilder [ $viewName ]))
{
2017-02-09 16:11:10 +00:00
$fieldSet [] = PHP_EOL . " \t <!-- " . $this -> setLine ( __LINE__ ) . " Metadata Fields. --> " ;
2016-06-02 16:18:49 +00:00
$fieldSet [] = " \t <fields " . ' name="metadata" label="JGLOBAL_FIELDSET_METADATA_OPTIONS">' ;
$fieldSet [] = " \t \t " . '<fieldset name="vdmmetadata"' ;
$fieldSet [] = " \t \t \t " . 'label="JGLOBAL_FIELDSET_METADATA_OPTIONS">' ;
// robots
$fieldSet [] = " \t \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Robots Field. Type: List (joomla) --> " ;
$fieldSet [] = " \t \t \t " . '<field name="robots"' ;
$fieldSet [] = " \t \t \t \t " . 'type="list"' ;
$fieldSet [] = " \t \t \t \t " . 'label="JFIELD_METADATA_ROBOTS_LABEL"' ;
$fieldSet [] = " \t \t \t \t " . 'description="JFIELD_METADATA_ROBOTS_DESC" >' ;
$fieldSet [] = " \t \t \t \t " . '<option value="">JGLOBAL_USE_GLOBAL</option>' ;
$fieldSet [] = " \t \t \t \t " . '<option value="index, follow">JGLOBAL_INDEX_FOLLOW</option>' ;
$fieldSet [] = " \t \t \t \t " . '<option value="noindex, follow">JGLOBAL_NOINDEX_FOLLOW</option>' ;
$fieldSet [] = " \t \t \t \t " . '<option value="index, nofollow">JGLOBAL_INDEX_NOFOLLOW</option>' ;
$fieldSet [] = " \t \t \t \t " . '<option value="noindex, nofollow">JGLOBAL_NOINDEX_NOFOLLOW</option>' ;
$fieldSet [] = " \t \t \t " . '</field>' ;
// author
$fieldSet [] = " \t \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Author Field. Type: Text (joomla) --> " ;
$fieldSet [] = " \t \t \t " . '<field name="author"' ;
$fieldSet [] = " \t \t \t \t " . 'type="text"' ;
$fieldSet [] = " \t \t \t \t " . 'label="JAUTHOR" description="JFIELD_METADATA_AUTHOR_DESC"' ;
$fieldSet [] = " \t \t \t \t " . 'size="20"' ;
$fieldSet [] = " \t \t \t /> " ;
// rights
$fieldSet [] = " \t \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Rights Field. Type: Textarea (joomla) --> " ;
$fieldSet [] = " \t \t \t " . '<field name="rights" type="textarea" label="JFIELD_META_RIGHTS_LABEL"' ;
$fieldSet [] = " \t \t \t \t " . 'description="JFIELD_META_RIGHTS_DESC" required="false" filter="string"' ;
$fieldSet [] = " \t \t \t \t " . 'cols="30" rows="2"' ;
$fieldSet [] = " \t \t \t /> " ;
$fieldSet [] = " \t \t </fieldset> " ;
$fieldSet [] = " \t </fields> " ;
2016-03-01 18:44:13 +00:00
}
2017-03-06 12:06:51 +00:00
// just to be safe, lets clear the view placeholders
$this -> clearFromPlaceHolders ( 'view' );
2016-03-01 18:44:13 +00:00
// retunr the set
2017-02-09 16:11:10 +00:00
return implode ( PHP_EOL , $fieldSet );
2016-03-01 18:44:13 +00:00
}
return '' ;
}
2016-06-02 16:18:49 +00:00
/**
* set Field Names
*
* @ param string $view View the field belongs to
* @ param string $name The name of the field
*
*
*/
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
*
* @ param array $field The field data
* @ param array $view The view data
* @ param int $viewType The view type
* @ param string $langView The language string of the view
* @ param string $viewName The singel view name
* @ param string $listViewName The list view name
* @ param string $spacerCounter The space counter value
* @ param array $placeholders The place holder and replace values
* @ param string $dbkey The the custom table key
* @ param boolean $build The switch to set the build option
*
* @ return string The complete field in xml
*
*/
public function setDynamicField ( & $field , & $view , & $viewType , & $langView , & $viewName , & $listViewName , & $spacerCounter , & $placeholders , & $dbkey , $build )
{
2016-06-23 15:05:37 +00:00
if ( isset ( $field [ 'settings' ]) && ComponentbuilderHelper :: checkObject ( $field [ 'settings' ]))
2016-03-01 18:44:13 +00:00
{
2016-09-03 21:44:47 +00:00
// reset some values
2016-06-23 15:05:37 +00:00
$name = ComponentbuilderHelper :: safeString ( $field [ 'settings' ] -> name );
$typeName = ComponentbuilderHelper :: safeString ( $field [ 'settings' ] -> type_name );
$multiple = false ;
$langLabel = '' ;
$taber = '' ;
$fieldSet = '' ;
2016-09-03 21:44:47 +00:00
$fieldAttributes = array ();
2016-06-23 15:05:37 +00:00
// set field attributes
$fieldAttributes = $this -> setFieldAttributes ( $field , $viewType , $name , $typeName , $multiple , $langLabel , $langView , $spacerCounter , $listViewName , $viewName , $placeholders );
// 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
$this -> setFieldsNames ( $viewName , $fieldAttributes [ 'name' ]);
if ( $this -> defaultField ( $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
$fieldSet .= $this -> setField ( 'option' , $taber , $fieldAttributes , $name , $typeName , $langView , $viewName , $listViewName , $placeholders , $optionArray );
if ( $build )
{
// set builders
$this -> setBuilders ( $langLabel , $langView , $viewName , $listViewName , $name , $view , $field , $typeName , $multiple , false , $optionArray );
}
2016-03-01 18:44:13 +00:00
}
2016-06-23 15:05:37 +00:00
elseif ( $this -> defaultField ( $typeName , 'plain' ))
2016-03-01 18:44:13 +00:00
{
2016-06-23 15:05:37 +00:00
if ( $build )
{
// set builders
$this -> setBuilders ( $langLabel , $langView , $viewName , $listViewName , $name , $view , $field , $typeName , $multiple );
}
// now add to the field set
$fieldSet .= $this -> setField ( 'plain' , $taber , $fieldAttributes , $name , $typeName , $langView , $viewName , $listViewName , $placeholders , $optionArray );
2016-03-01 18:44:13 +00:00
}
2016-06-23 15:05:37 +00:00
elseif ( $this -> defaultField ( $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' ;
}
$this -> setLayoutBuilder ( $viewName , $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
$fieldSet .= $this -> setField ( 'spacer' , $taber , $fieldAttributes , $name , $typeName , $langView , $viewName , $listViewName , $placeholders , $optionArray );
// increment spacer counter
2017-02-01 13:17:04 +00:00
if ( $typeName === 'spacer' )
2016-06-02 16:18:49 +00:00
{
2016-06-23 15:05:37 +00:00
$spacerCounter ++ ;
2016-06-02 16:18:49 +00:00
}
2016-03-01 18:44:13 +00:00
}
2016-06-23 15:05:37 +00:00
elseif ( $this -> defaultField ( $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
$this -> setBuilders ( $langLabel , $langView , $viewName , $listViewName , $name , $view , $field , $typeName , $multiple , false );
}
// now add to the field set
$fieldSet .= $this -> setField ( 'special' , $taber , $fieldAttributes , $name , $typeName , $langView , $viewName , $listViewName , $placeholders , $optionArray );
}
2016-03-01 18:44:13 +00:00
}
2016-06-23 15:05:37 +00:00
elseif ( 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
2016-06-23 15:05:37 +00:00
$this -> setBuilders ( $langLabel , $langView , $viewName , $listViewName , $name , $view , $field , $typeName , $multiple , $custom );
2016-03-01 18:44:13 +00:00
}
// now add to the field set
2016-10-23 22:48:26 +00:00
$fieldSet .= $this -> setField ( 'custom' , $taber , $fieldAttributes , $name , $typeName , $langView , $viewName , $listViewName , $placeholders , $optionArray , $custom );
2016-03-01 18:44:13 +00:00
}
}
2016-06-23 15:05:37 +00:00
return $fieldSet ;
2016-03-01 18:44:13 +00:00
}
2016-06-23 15:05:37 +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 a field
*
* @ param string $setType The set of fields type
* @ param string $taber The tabs to add in layout
* @ param array $fieldAttributes The field values
* @ param string $name The field name
* @ param string $typeName The field type
* @ param string $langView The language string of the view
* @ param string $viewName The singel view name
* @ param string $listViewName The list view name
* @ param array $placeholders The place holder and replace values
* @ param string $optionArray The option bucket array used to set the field options if needed .
2016-10-23 22:48:26 +00:00
* @ param arra $custom Used when field is from config
2016-03-01 18:44:13 +00:00
*
* @ return string The field in xml
*
*/
2016-10-23 22:48:26 +00:00
private function setField ( $setType , $taber , & $fieldAttributes , & $name , & $typeName , & $langView , & $viewName , & $listViewName , $placeholders , & $optionArray , $custom = null )
2016-03-01 18:44:13 +00:00
{
$fieldSet = '' ;
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-02-09 16:11:10 +00:00
$fieldSet .= PHP_EOL . " \t " . $taber . " \t <!-- " . $this -> setLine ( __LINE__ ) . " " . ComponentbuilderHelper :: safeString ( $name , 'F' ) . " Field. Type: " . ComponentbuilderHelper :: safeString ( $typeName , 'F' ) . " . (joomla) --> " ;
$fieldSet .= PHP_EOL . " \t " . $taber . " \t <field " ;
2016-03-01 18:44:13 +00:00
$optionSet = '' ;
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
2017-02-09 16:11:10 +00:00
$fieldSet .= PHP_EOL . " \t \t " . $taber . " \t " . $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
{
$optionSet = '' ;
if ( strpos ( $value , ',' ) !== false )
{
// mulitpal options
$options = explode ( ',' , $value );
foreach ( $options as $option )
{
if ( strpos ( $option , '|' ) !== false )
{
// has other value then text
list ( $v , $t ) = explode ( '|' , $option );
$langValue = $langView . '_' . ComponentbuilderHelper :: safeString ( $t , 'U' );
// add to lang array
$this -> langContent [ $this -> lang ][ $langValue ] = $t ;
// no add to option set
2017-02-09 16:11:10 +00:00
$optionSet .= PHP_EOL . " \t " . $taber . " \t \t " . '<option value="' . $v . '">' . PHP_EOL . " \t " . $taber . " \t \t \t " . $langValue . '</option>' ;
2016-03-01 18:44:13 +00:00
$optionArray [ $v ] = $langValue ;
}
else
{
// text is also the value
$langValue = $langView . '_' . ComponentbuilderHelper :: safeString ( $option , 'U' );
// add to lang array
$this -> langContent [ $this -> lang ][ $langValue ] = $option ;
// no add to option set
2017-02-09 16:11:10 +00:00
$optionSet .= PHP_EOL . " \t \t " . $taber . " \t " . '<option value="' . $option . '">' . PHP_EOL . " \t \t " . $taber . " \t \t " . $langValue . '</option>' ;
2016-03-01 18:44:13 +00:00
$optionArray [ $option ] = $langValue ;
}
}
}
else
{
// one option
if ( strpos ( $value , '|' ) !== false )
{
// has other value then text
list ( $v , $t ) = explode ( '|' , $value );
$langValue = $langView . '_' . ComponentbuilderHelper :: safeString ( $t , 'U' );
// add to lang array
$this -> langContent [ $this -> lang ][ $langValue ] = $t ;
// no add to option set
2017-02-09 16:11:10 +00:00
$optionSet .= PHP_EOL . " \t \t " . $taber . " \t " . '<option value="' . $v . '">' . PHP_EOL . " \t \t " . $taber . " \t \t " . $langValue . '</option>' ;
2016-03-01 18:44:13 +00:00
$optionArray [ $v ] = $langValue ;
}
else
{
// text is also the value
$langValue = $langView . '_' . ComponentbuilderHelper :: safeString ( $value , 'U' );
// add to lang array
$this -> langContent [ $this -> lang ][ $langValue ] = $value ;
// no add to option set
2017-02-09 16:11:10 +00:00
$optionSet .= PHP_EOL . " \t \t " . $taber . " \t " . '<option value="' . $value . '">' . PHP_EOL . " \t \t " . $taber . " \t \t " . $langValue . '</option>' ;
2016-03-01 18:44:13 +00:00
$optionArray [ $value ] = $langValue ;
}
}
}
}
if ( ComponentbuilderHelper :: checkString ( $optionSet ))
{
$fieldSet .= '>' ;
2017-02-09 16:11:10 +00:00
$fieldSet .= PHP_EOL . " \t \t \t " . $taber . " <!-- " . $this -> setLine ( __LINE__ ) . " Option Set. --> " ;
2016-03-01 18:44:13 +00:00
$fieldSet .= $optionSet ;
2017-02-09 16:11:10 +00:00
$fieldSet .= PHP_EOL . " \t \t " . $taber . " </field> " ;
2016-03-01 18:44:13 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $typeName === 'sql' )
2016-07-17 10:24:51 +00:00
{
$optionArray = false ;
2017-02-09 16:11:10 +00:00
$fieldSet .= PHP_EOL . " \t \t " . $taber . " /> " ;
2016-07-17 10:24:51 +00:00
}
2016-03-01 18:44:13 +00:00
else
{
$optionArray = false ;
2017-02-09 16:11:10 +00:00
$fieldSet .= PHP_EOL . " \t \t \t " . $taber . " <!-- " . $this -> setLine ( __LINE__ ) . " No Manual Options Were Added In Field Settings. --> " ;
$fieldSet .= PHP_EOL . " \t \t " . $taber . " /> " ;
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-02-09 16:11:10 +00:00
$fieldSet .= PHP_EOL . " \t \t " . $taber . " <!-- " . $this -> setLine ( __LINE__ ) . " " . ComponentbuilderHelper :: safeString ( $name , 'F' ) . " Field. Type: " . ComponentbuilderHelper :: safeString ( $typeName , 'F' ) . " . (joomla) --> " ;
$fieldSet .= PHP_EOL . " \t \t " . $taber . " <field " ;
2016-03-01 18:44:13 +00:00
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
2017-02-09 16:11:10 +00:00
$fieldSet .= PHP_EOL . " \t \t " . $taber . " \t " . $property . '="' . $value . '"' ;
2016-03-01 18:44:13 +00:00
}
}
2017-02-09 16:11:10 +00:00
$fieldSet .= PHP_EOL . " \t \t " . $taber . " /> " ;
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-02-09 16:11:10 +00:00
$fieldSet .= PHP_EOL . " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " " . ComponentbuilderHelper :: safeString ( $name , 'F' ) . " Field. Type: " . ComponentbuilderHelper :: safeString ( $typeName , 'F' ) . " . A None Database Field. (joomla) --> " ;
$fieldSet .= PHP_EOL . " \t \t <field " ;
2016-03-01 18:44:13 +00:00
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
$fieldSet .= " " . $property . '="' . $value . '"' ;
}
}
$fieldSet .= " /> " ;
}
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-02-09 16:11:10 +00:00
$fieldSet .= PHP_EOL . " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " " . ComponentbuilderHelper :: safeString ( $name , 'F' ) . " Field. Type: " . ComponentbuilderHelper :: safeString ( $typeName , 'F' ) . " . (joomla) --> " ;
$fieldSet .= PHP_EOL . " \t \t <field " ;
2016-03-01 18:44:13 +00:00
$fieldsSet = array ();
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'fields' )
{
2017-02-09 16:11:10 +00:00
$fieldSet .= PHP_EOL . " \t \t \t " . $property . '="' . $value . '"' ;
2016-03-01 18:44:13 +00:00
}
}
$fieldSet .= " > " ;
2017-02-09 16:11:10 +00:00
$fieldSet .= PHP_EOL . " \t \t \t " . '<fields name="' . $fieldAttributes [ 'name' ] . '_fields" label="">' ;
$fieldSet .= PHP_EOL . " \t \t \t \t " . '<fieldset hidden="true" name="' . $fieldAttributes [ 'name' ] . '_modal" repeat="true">' ;
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 ))
{
foreach ( $fieldsSets as $fieldId )
{
// get the field data
2016-09-03 21:44:47 +00:00
$fieldData = array ();
2016-03-01 18:44:13 +00:00
$fieldData [ 'settings' ] = $this -> getFieldData ( $fieldId , $viewName );
if ( ComponentbuilderHelper :: checkObject ( $fieldData [ 'settings' ]))
{
$r_name = ComponentbuilderHelper :: safeString ( $fieldData [ 'settings' ] -> name );
$r_typeName = ComponentbuilderHelper :: safeString ( $fieldData [ 'settings' ] -> type_name );
$r_multiple = false ;
$r_langLabel = '' ;
// add the tabs needed
$taber = " \t \t \t " ;
// get field values
$r_fieldValues = $this -> setFieldAttributes ( $fieldData , $view , $r_name , $r_typeName , $r_multiple , $r_langLabel , $langView , $spacerCounter , $listViewName , $viewName , $placeholders , true );
// check if values were set
if ( ComponentbuilderHelper :: checkArray ( $r_fieldValues ))
{
//reset options array
$r_optionArray = array ();
if ( $this -> defaultField ( $r_typeName , 'option' ))
{
// now add to the field set
$fieldSet .= $this -> setField ( 'option' , $taber , $r_fieldValues , $r_name , $r_typeName , $langView , $viewName , $listViewName , $placeholders , $r_optionArray );
}
elseif ( $this -> defaultField ( $r_typeName , 'plain' ))
{
// now add to the field set
$fieldSet .= $this -> setField ( 'plain' , $taber , $r_fieldValues , $r_name , $r_typeName , $langView , $viewName , $listViewName , $placeholders , $r_optionArray );
}
elseif ( ComponentbuilderHelper :: checkArray ( $r_fieldValues [ 'custom' ]))
{
// add to custom
$custom = $r_fieldValues [ 'custom' ];
unset ( $r_fieldValues [ 'custom' ]);
// now add to the field set
$fieldSet .= $this -> setField ( 'custom' , $taber , $r_fieldValues , $r_name , $r_typeName , $langView , $viewName , $listViewName , $placeholders , $r_optionArray );
// set lang (just incase)
$r_listLangName = $langView . '_' . ComponentbuilderHelper :: safeString ( $r_name , 'U' );
// add to lang array
$this -> langContent [ $this -> lang ][ $r_listLangName ] = ComponentbuilderHelper :: safeString ( $r_name , 'W' );
// 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 , $listViewName , $viewName );
}
}
}
}
}
2017-02-09 16:11:10 +00:00
$fieldSet .= PHP_EOL . " \t \t \t \t </fieldset> " ;
$fieldSet .= PHP_EOL . " \t \t \t </fields> " ;
$fieldSet .= PHP_EOL . " \t \t </field> " ;
2016-03-01 18:44:13 +00:00
}
2017-06-18 10:47:10 +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
$fieldSet .= PHP_EOL . " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " " . ComponentbuilderHelper :: safeString ( $name , 'F' ) . " Field. Type: " . ComponentbuilderHelper :: safeString ( $typeName , 'F' ) . " . (joomla) --> " ;
$fieldSet .= PHP_EOL . " \t \t <field " ;
$fieldsSet = array ();
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
{
$fieldSet .= PHP_EOL . " \t \t \t " . $property . '="' . $value . '"' ;
}
}
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-03 18:09:04 +00:00
$fieldSet .= PHP_EOL . " \t \t \t formsource " . '="' . $fieldAttributes [ 'formsource' ] . '"' ;
$fieldSet .= PHP_EOL . " \t \t /> " ;
2017-06-18 07:37:48 +00:00
}
2017-12-03 18:09:04 +00:00
else
2017-06-18 07:37:48 +00:00
{
2017-12-03 18:09:04 +00:00
$fieldSet .= " > " ;
$fieldSet .= PHP_EOL . " \t \t \t " . '<form hidden="true" name="list_' . $fieldAttributes [ 'name' ] . '_modal" repeat="true">' ;
if ( strpos ( $fieldAttributes [ 'fields' ], ',' ) !== false )
2017-06-18 07:37:48 +00:00
{
2017-12-03 18:09:04 +00:00
// 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 ))
{
foreach ( $fieldsSets as $fieldId )
2017-06-18 07:37:48 +00:00
{
2017-12-03 18:09:04 +00:00
// get the field data
$fieldData = array ();
$fieldData [ 'settings' ] = $this -> getFieldData ( $fieldId , $viewName );
if ( ComponentbuilderHelper :: checkObject ( $fieldData [ 'settings' ]))
2017-06-18 07:37:48 +00:00
{
2017-12-03 18:09:04 +00:00
$r_name = ComponentbuilderHelper :: safeString ( $fieldData [ 'settings' ] -> name );
$r_typeName = ComponentbuilderHelper :: safeString ( $fieldData [ 'settings' ] -> type_name );
$r_multiple = false ;
$r_langLabel = '' ;
// add the tabs needed
$taber = " \t \t " ;
// get field values
$r_fieldValues = $this -> setFieldAttributes ( $fieldData , $view , $r_name , $r_typeName , $r_multiple , $r_langLabel , $langView , $spacerCounter , $listViewName , $viewName , $placeholders , true );
// check if values were set
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 ();
if ( $this -> defaultField ( $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
$fieldSet .= $this -> setField ( 'option' , $taber , $r_fieldValues , $r_name , $r_typeName , $langView , $viewName , $listViewName , $placeholders , $r_optionArray );
}
elseif ( $this -> defaultField ( $r_typeName , 'plain' ))
{
// now add to the field set
$fieldSet .= $this -> setField ( 'plain' , $taber , $r_fieldValues , $r_name , $r_typeName , $langView , $viewName , $listViewName , $placeholders , $r_optionArray );
}
elseif ( ComponentbuilderHelper :: checkArray ( $r_fieldValues [ 'custom' ]))
{
// add to custom
$custom = $r_fieldValues [ 'custom' ];
unset ( $r_fieldValues [ 'custom' ]);
// now add to the field set
$fieldSet .= $this -> setField ( 'custom' , $taber , $r_fieldValues , $r_name , $r_typeName , $langView , $viewName , $listViewName , $placeholders , $r_optionArray );
// set lang (just incase)
$r_listLangName = $langView . '_' . ComponentbuilderHelper :: safeString ( $r_name , 'U' );
// add to lang array
$this -> langContent [ $this -> lang ][ $r_listLangName ] = ComponentbuilderHelper :: safeString ( $r_name , 'W' );
// 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 , $listViewName , $viewName );
2017-06-18 07:37:48 +00:00
}
}
}
}
}
2017-12-03 18:09:04 +00:00
$fieldSet .= PHP_EOL . " \t \t \t </form> " ;
$fieldSet .= PHP_EOL . " \t \t </field> " ;
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-02-09 16:11:10 +00:00
$fieldSet .= PHP_EOL . " \t \t " . $taber . " <!-- " . $this -> setLine ( __LINE__ ) . " " . ComponentbuilderHelper :: safeString ( $name , 'F' ) . " Field. Type: " . ComponentbuilderHelper :: safeString ( $typeName , 'F' ) . " . (custom) --> " ;
$fieldSet .= PHP_EOL . " \t \t " . $taber . " <field " ;
2016-03-01 18:44:13 +00:00
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
2017-02-09 16:11:10 +00:00
$fieldSet .= PHP_EOL . " \t \t " . $taber . " \t " . $property . '="' . $value . '"' ;
2016-03-01 18:44:13 +00:00
}
}
2017-02-09 16:11:10 +00:00
$fieldSet .= PHP_EOL . " \t \t " . $taber . " /> " ;
2016-10-23 22:48:26 +00:00
// incase the field is in the config and has not been set
2017-02-02 11:54:07 +00:00
if ( 'config' === $viewName && 'configs' === $listViewName )
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
$this -> setCustomFieldTypeFile ( $data , $listViewName , $viewName );
}
2016-03-01 18:44:13 +00:00
}
return $fieldSet ;
}
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* set the layout builder
*
* @ param string $viewName The single edit view code name
* @ param string $tabName The tab code name
* @ param string $name The field code name
* @ param array $field The field details
*
* @ return void
*
*/
public function setLayoutBuilder ( & $viewName , & $tabName , & $name , & $field )
{
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 )
{
if ( ! isset ( $this -> zeroOrderFix [ $viewName ]))
{
$this -> zeroOrderFix [ $viewName ] = array ();
}
if ( ! isset ( $this -> zeroOrderFix [ $viewName ][( int ) $field [ 'tab' ]]))
{
$this -> zeroOrderFix [ $viewName ][( int ) $field [ 'tab' ]] = - 999 ;
}
else
{
$this -> zeroOrderFix [ $viewName ][( int ) $field [ 'tab' ]] ++ ;
}
$field [ 'order_edit' ] = $this -> zeroOrderFix [ $viewName ][( int ) $field [ 'tab' ]];
}
// 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
{
$this -> tabCounter [ $viewName ][( int ) $field [ 'tab' ]] = $tabName ;
if ( isset ( $this -> layoutBuilder [ $viewName ][ $tabName ][( int ) $field [ 'alignment' ]][( int ) $field [ 'order_edit' ]]))
{
$size = count ( $this -> layoutBuilder [ $viewName ][ $tabName ][( int ) $field [ 'alignment' ]][( int ) $field [ 'order_edit' ]]) + 1 ;
$this -> layoutBuilder [ $viewName ][ $tabName ][( int ) $field [ 'alignment' ]][ $size ] = $name ;
}
else
{
$this -> layoutBuilder [ $viewName ][ $tabName ][( int ) $field [ 'alignment' ]][( int ) $field [ 'order_edit' ]] = $name ;
}
2016-06-02 16:18:49 +00:00
// check if publishing fields were over written
if ( in_array ( $name , $this -> defaultFields ))
{
// just to eliminate
$this -> movedPublishingFields [ $viewName ][ $name ] = $name ;
}
}
2017-10-26 16:43:51 +00:00
elseif ( $tabName === 'publishing' || $tabName === 'Publishing' )
2016-06-02 16:18:49 +00:00
{
if ( ! in_array ( $name , $this -> defaultFields ))
{
if ( isset ( $this -> newPublishingFields [ $viewName ][( int ) $field [ 'alignment' ]][( int ) $field [ 'order_edit' ]]))
{
$size = count ( $this -> newPublishingFields [ $viewName ][( int ) $field [ 'alignment' ]][( int ) $field [ 'order_edit' ]]) + 1 ;
$this -> newPublishingFields [ $viewName ][( int ) $field [ 'alignment' ]][ $size ] = $name ;
}
else
{
$this -> newPublishingFields [ $viewName ][( int ) $field [ 'alignment' ]][( int ) $field [ 'order_edit' ]] = $name ;
}
}
2016-03-01 18:44:13 +00:00
}
else
{
$this -> tabCounter [ $viewName ][ 1 ] = 'Details' ;
if ( isset ( $this -> layoutBuilder [ $viewName ][ 'Details' ][( int ) $field [ 'alignment' ]][( int ) $field [ 'order_edit' ]]))
{
$size = count ( $this -> layoutBuilder [ $viewName ][ 'Details' ][( int ) $field [ 'alignment' ]][( int ) $field [ 'order_edit' ]]) + 1 ;
$this -> layoutBuilder [ $viewName ][ 'Details' ][( int ) $field [ 'alignment' ]][ $size ] = $name ;
}
else
{
$this -> layoutBuilder [ $viewName ][ 'Details' ][( int ) $field [ 'alignment' ]][( int ) $field [ 'order_edit' ]] = $name ;
}
2016-06-02 16:18:49 +00:00
// check if publishing fields were over written
if ( in_array ( $name , $this -> defaultFields ))
{
// just to eliminate
$this -> movedPublishingFields [ $viewName ][ $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
* build the site field data needed
*
* @ 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
*
* @ return void
*
*/
2017-11-11 04:33:51 +00:00
public function buildSiteFieldData ( $view , $field , $set , $type )
2016-03-01 18:44:13 +00:00
{
$decode = array ( 'json' , 'base64' , 'basic_encryption' , 'advance_encryption' );
$uikit = array ( 'textarea' , 'editor' );
if ( isset ( $this -> siteFields [ $view ][ $field ]) && ComponentbuilderHelper :: checkArray ( $this -> siteFields [ $view ][ $field ]))
{
foreach ( $this -> siteFields [ $view ][ $field ] as $code => $array )
{
// set the decoding methods
if ( in_array ( $set , $decode ))
{
$this -> siteFieldData [ 'decode' ][ $array [ 'site' ]][ $code ][ $array [ 'as' ]][ $array [ 'key' ]] = array ( 'decode' => $set , 'type' => $type );
}
// set the uikit checker
2017-11-11 04:33:51 +00:00
if (( 2 == $this -> uikit || 1 == $this -> uikit ) && in_array ( $type , $uikit ))
2016-03-01 18:44:13 +00:00
{
$this -> siteFieldData [ 'uikit' ][ $array [ 'site' ]][ $code ][ $array [ 'as' ]][ $array [ 'key' ]] = $array ;
}
}
}
}
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* set field attributes
*
2017-03-06 12:06:51 +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
2016-03-01 18:44:13 +00:00
* @ param string $spacerCounter The space counter value
2017-03-06 12:06:51 +00:00
* @ param string $listViewName The list view name
* @ param string $viewName The singel view name
* @ param array $placeholders The place holder and replace values
* @ param boolean $repeatable The repeatable field switch
2016-03-01 18:44:13 +00:00
*
* @ return array The field attributes
*
*/
private function setFieldAttributes ( & $field , & $viewType , & $name , & $typeName , & $multiple , & $langLabel , $langView , & $spacerCounter , $listViewName , $viewName , $placeholders , $repeatable = false )
{
// reset array`
$fieldAttributes = array ();
$setCustom = false ;
// setup joomla default fields
if ( ! $this -> defaultField ( $typeName ))
{
$fieldAttributes [ 'custom' ] = array ();
$setCustom = true ;
}
// setup a default field
if ( ComponentbuilderHelper :: checkArray ( $field [ 'settings' ] -> properties ))
{
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
{
2017-02-01 13:17:04 +00:00
if ( $typeName === 'custom' || $typeName === 'customuser' )
2016-03-01 18:44:13 +00:00
{
$xmlValue = ComponentbuilderHelper :: safeString ( ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'type="' , '"' ));
}
// use field core type only if not found
elseif ( ComponentbuilderHelper :: checkString ( $typeName ))
{
$xmlValue = $typeName ;
}
// make sure none adjustable fields are set
elseif ( isset ( $property [ 'example' ]) && ComponentbuilderHelper :: checkString ( $property [ 'example' ]) && $property [ 'adjustable' ] == 0 )
{
$xmlValue = $property [ 'example' ];
}
// fall back on the xml settings
else
{
$xmlValue = ComponentbuilderHelper :: safeString ( ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'type="' , '"' ));
}
// check if the value is set
if ( ComponentbuilderHelper :: checkString ( $xmlValue ))
{
// add the value
$typeName = $xmlValue ;
}
else
{
// fall back to text
$xmlValue = 'text' ;
$typeName = $xmlValue ;
}
// 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
{
// if category then name must be catid (only one per view)
2017-02-01 13:17:04 +00:00
if ( $typeName === 'category' )
2016-03-01 18:44:13 +00:00
{
// quick check if this is a category linked to view page
$requeSt_id = ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'name="' , '"' );
2017-03-08 04:49:54 +00:00
if ( strpos ( $requeSt_id , '_request_id' ) !== false || strpos ( $requeSt_id , '_request_catid' ) !== false )
2016-03-01 18:44:13 +00:00
{
// keep it then, don't change
$xmlValue = $requeSt_id ;
}
else
{
$xmlValue = 'catid' ;
}
// check if we should use another Text Name as this views name
$otherName = ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'othername="' , '"' );
$otherViews = ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'views="' , '"' );
$otherView = ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'view="' , '"' );
if ( ComponentbuilderHelper :: checkString ( $otherName ) && ComponentbuilderHelper :: checkString ( $otherViews ) && ComponentbuilderHelper :: checkString ( $otherView ))
{
$this -> catOtherName [ $listViewName ] = array (
'name' => ComponentbuilderHelper :: safeString ( $otherName ),
'views' => ComponentbuilderHelper :: safeString ( $otherViews ),
'view' => ComponentbuilderHelper :: safeString ( $otherView )
);
}
}
// if tag is set then enable all tag options for this view (only one per view)
2017-02-01 13:17:04 +00:00
elseif ( $typeName === 'tag' )
2016-03-01 18:44:13 +00:00
{
$xmlValue = 'tags' ;
}
// if the field is set as alias it must be called alias
elseif ( isset ( $field [ 'alias' ]) && $field [ 'alias' ])
{
$xmlValue = 'alias' ;
}
2017-02-01 13:17:04 +00:00
elseif ( $typeName === 'spacer' )
2016-03-01 18:44:13 +00:00
{
// make sure the name is unique
$xmlValue = $name . '_' . $spacerCounter ;
}
else
{
$xmlValue = ComponentbuilderHelper :: safeString ( ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'name="' , '"' ));
}
// use field core name only if not found in xml
if ( ! ComponentbuilderHelper :: checkString ( $xmlValue ))
{
2017-03-06 12:06:51 +00:00
// make sure the XML name is uniqe, so we can add one field multiple times
$name = $this -> uniqueName ( $name , $viewName );
2016-03-01 18:44:13 +00:00
$xmlValue = $name ;
}
// set the name if found
else
{
2017-03-06 12:06:51 +00:00
// make sure the XML name is uniqe, so we can add one field multiple times
$xmlValue = $this -> uniqueName ( $xmlValue , $viewName );
2017-03-08 04:49:54 +00:00
$name = $this -> setPlaceholders ( $xmlValue , $placeholders );
2016-03-01 18:44:13 +00:00
}
}
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
{
$xmlValue = ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , $property [ 'name' ] . '="' , '"' );
// replace the placeholders
2017-02-11 02:24:26 +00:00
$xmlValue = $this -> setPlaceholders ( $xmlValue , $placeholders );
2016-03-01 18:44:13 +00:00
}
elseif ( strpos ( $property [ 'name' ], 'type_php_' ) !== false && $setCustom )
{
// set the line number
$phpLine = ( int ) str_replace ( 'type_php_' , '' , $property [ 'name' ]);
// load the php for the custom field file
$fieldAttributes [ 'custom' ][ 'php' ][ $phpLine ] = ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , $property [ 'name' ] . '="' , '"' );
}
elseif ( strpos ( $property [ 'name' ], 'type_phpx_' ) !== false && $setCustom )
{
// set the line number
$phpLine = ( int ) str_replace ( 'type_phpx_' , '' , $property [ 'name' ]);
// load the php for the custom field file
$fieldAttributes [ 'custom' ][ 'phpx' ][ $phpLine ] = 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
{
// load the view name
$fieldAttributes [ 'custom' ][ 'view' ] = ComponentbuilderHelper :: safeString ( ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'view="' , '"' ));
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'views' && $setCustom )
2016-03-01 18:44:13 +00:00
{
// load the views name
$fieldAttributes [ 'custom' ][ 'views' ] = ComponentbuilderHelper :: safeString ( ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'views="' , '"' ));
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'component' && $setCustom )
2016-03-01 18:44:13 +00:00
{
// load the component name
$fieldAttributes [ 'custom' ][ 'component' ] = ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'component="' , '"' );
// replace the placeholders
2017-02-11 02:24:26 +00:00
$fieldAttributes [ 'custom' ][ 'component' ] = $this -> setPlaceholders ( $fieldAttributes [ 'custom' ][ '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
{
// load the main table that is queried
$fieldAttributes [ 'custom' ][ 'table' ] = ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'table="' , '"' );
// replace the placeholders
2017-02-11 02:24:26 +00:00
$fieldAttributes [ 'custom' ][ 'table' ] = $this -> setPlaceholders ( $fieldAttributes [ 'custom' ][ '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' ;
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'required' && $repeatable )
2016-09-03 21:44:47 +00:00
{
// dont load the required to repeatable
$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' ;
}
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
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
}
// 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-03-06 12:06:51 +00:00
// update lable if field use multiple times
if ( $property [ 'name' ] === 'label' )
{
if ( isset ( $fieldAttributes [ 'name' ]) && isset ( $this -> uniqueNames [ $viewName ][ 'names' ][ $fieldAttributes [ 'name' ]]))
{
$xmlValue .= ' (' . ComponentbuilderHelper :: safeString ( $this -> uniqueNames [ $viewName ][ 'names' ][ $fieldAttributes [ 'name' ]]) . ')' ;
}
}
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
$langValue = $langView . '_' . ComponentbuilderHelper :: safeString ( $name . ' ' . $property [ 'name' ], 'U' );
// add to lang array
$this -> langContent [ $this -> lang ][ $langValue ] = $xmlValue ;
// 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
}
}
// do some nice twigs beyond the default
if ( isset ( $fieldAttributes [ 'name' ]))
{
// check if we find reason to remove this field from being escaped
$escaped = ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'escape="' , '"' );
if ( ComponentbuilderHelper :: checkString ( $escaped ))
{
$this -> doNotEscape [ $listViewName ][] = $fieldAttributes [ 'name' ];
}
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 ;
}
2016-03-01 18:44:13 +00:00
}
}
return $fieldAttributes ;
}
2017-03-06 12:06:51 +00:00
/**
* Keep track of the field names , to see if it used multiple times
*
* @ param array $field The field data
* @ param string $typeName The field type
* @ param string $name The field name
* @ param string $viewName The singel view name
*
* @ return void
*
*/
protected function setUniqueNameKeeper ( & $field , & $typeName , & $name , $viewName )
{
// setup a default field
if ( ComponentbuilderHelper :: checkArray ( $field [ 'settings' ] -> properties ))
{
foreach ( $field [ 'settings' ] -> properties as $property )
{
// reset
$xmlValue = '' ;
if ( $property [ 'name' ] === 'name' )
{
// if category then name must be catid (only one per view)
if ( $typeName === 'category' )
{
// only one allowed
return ;
}
// if tag is set then enable all tag options for this view (only one per view)
elseif ( $typeName === 'tag' )
{
// only one allowed
return ;
}
// if the field is set as alias it must be called alias
elseif ( isset ( $field [ 'alias' ]) && $field [ 'alias' ])
{
// only one allowed
return ;
}
elseif ( $typeName === 'spacer' )
{
// not needed here
return ;
}
else
{
$xmlValue = ComponentbuilderHelper :: safeString ( ComponentbuilderHelper :: getBetween ( $field [ 'settings' ] -> xml , 'name="' , '"' ));
}
// use field core name only if not found in xml
if ( ! ComponentbuilderHelper :: checkString ( $xmlValue ))
{
$xmlValue = $name ;
}
// make sure the XML name is uniqe, so we can add one field multiple times
return $this -> setUniqueNameCounter ( $xmlValue , $viewName );
}
}
}
}
/**
* Count how many times the same field is used per view
*
* @ param string $name The name of the field
* @ param string $view The name of the view
*
* @ return void
*
*/
protected function setUniqueNameCounter ( $name , $view )
{
if ( ! isset ( $this -> uniqueNames [ $view ]))
{
$this -> uniqueNames [ $view ] = array ();
$this -> uniqueNames [ $view ][ 'counter' ] = array ();
$this -> uniqueNames [ $view ][ 'names' ] = array ();
}
if ( ! isset ( $this -> uniqueNames [ $view ][ 'counter' ][ $name ]))
{
$this -> uniqueNames [ $view ][ 'counter' ][ $name ] = 1 ;
return ;
}
// count how many times the field is used
$this -> uniqueNames [ $view ][ 'counter' ][ $name ] ++ ;
return ;
}
/**
* Naming each field with an unique name
*
* @ param string $name The name of the field
* @ param string $view The name of the view
*
* @ return string the name
*
*/
protected function uniqueName ( $name , $view )
{
// only increment if the field name is used multiple times
if ( isset ( $this -> uniqueNames [ $view ][ 'counter' ][ $name ]) && $this -> uniqueNames [ $view ][ 'counter' ][ $name ] > 1 )
{
$counter = $this -> uniqueNames [ $view ][ 'counter' ][ $name ];
$uniqueName = ComponentbuilderHelper :: safeString ( $name . '_' . $counter );
while ( isset ( $this -> uniqueNames [ $view ][ 'names' ][ $uniqueName ]))
{
$counter -- ;
$uniqueName = ComponentbuilderHelper :: safeString ( $name . '_' . $counter );
}
// set the new name
$this -> uniqueNames [ $view ][ 'names' ][ $uniqueName ] = $counter ;
return $uniqueName ;
}
return $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 Builders
*
* @ param string $langLabel The language string for field label
* @ param string $langView The language string of the view
* @ param string $viewName The singel view name
* @ param string $listViewName The list view name
* @ param string $name The field name
* @ param array $view The view data
* @ param array $field The field data
* @ param string $typeName The field type
* @ param boolean $multiple The switch to set multiple selection option
* @ param boolean $custom The custom field switch
* @ param boolean $options The options switch
*
* @ return void
*
*/
public function setBuilders ( $langLabel , $langView , $viewName , $listViewName , $name , $view , $field , $typeName , $multiple , $custom = false , $options = false )
{
2017-02-01 13:17:04 +00:00
if ( $typeName === 'tag' )
2016-03-01 18:44:13 +00:00
{
// set tags for this view but don't load to DB
$this -> tagsBuilder [ $viewName ] = $viewName ;
}
else
{
// 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
$this -> queryBuilder [ $viewName ][ $name ][ 'type' ] = $field [ 'settings' ] -> datatype ;
if ( ! in_array ( $field [ 'settings' ] -> datatype , $textKeys ))
{
$this -> queryBuilder [ $viewName ][ $name ][ 'lenght' ] = $field [ 'settings' ] -> datalenght ;
$this -> queryBuilder [ $viewName ][ $name ][ 'lenght_other' ] = $field [ 'settings' ] -> datalenght_other ;
$this -> queryBuilder [ $viewName ][ $name ][ 'default' ] = $field [ 'settings' ] -> datadefault ;
$this -> queryBuilder [ $viewName ][ $name ][ 'other' ] = $field [ 'settings' ] -> datadefault_other ;
}
else
{
$this -> queryBuilder [ $viewName ][ $name ][ 'default' ] = 'EMPTY' ;
}
2017-06-29 21:03:53 +00:00
// to identify the field
$this -> queryBuilder [ $viewName ][ $name ][ 'ID' ] = $field [ 'settings' ] -> id ;
2016-09-03 21:44:47 +00:00
$this -> queryBuilder [ $viewName ][ $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
$this -> dbUniqueKeys [ $viewName ][] = $name ;
}
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
$this -> dbKeys [ $viewName ][] = $name ;
}
}
// 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
{
$this -> historyBuilder [ $viewName ] = $viewName ;
}
// set Alias (only one title per view)
2017-10-30 18:50:56 +00:00
if ( isset ( $field [ 'alias' ]) && $field [ 'alias' ])
2016-03-01 18:44:13 +00:00
{
$this -> aliasBuilder [ $viewName ] = $name ;
}
// set Titles (only one title per view)
2017-10-30 18:50:56 +00:00
if ( isset ( $field [ 'title' ]) && $field [ 'title' ])
2016-03-01 18:44:13 +00:00
{
$this -> titleBuilder [ $viewName ] = $name ;
}
// category name fix
2017-02-01 13:17:04 +00:00
if ( $typeName === 'category' )
2016-03-01 18:44:13 +00:00
{
if ( isset ( $this -> catOtherName [ $listViewName ]) && ComponentbuilderHelper :: checkArray ( $this -> catOtherName [ $listViewName ]))
{
$tempName = $this -> catOtherName [ $listViewName ][ 'name' ];
}
else
{
$tempName = $viewName . ' category' ;
}
// set lang
$listLangName = $langView . '_' . ComponentbuilderHelper :: safeString ( $tempName , 'U' );
// add to lang array
$this -> langContent [ $this -> lang ][ $listLangName ] = ComponentbuilderHelper :: safeString ( $tempName , 'W' );
}
else
{
// set lang (just incase)
$listLangName = $langView . '_' . ComponentbuilderHelper :: safeString ( $name , 'U' );
// add to lang array
$this -> langContent [ $this -> lang ][ $listLangName ] = ComponentbuilderHelper :: safeString ( $name , 'W' );
// if label was set use instead
if ( ComponentbuilderHelper :: checkString ( $langLabel ))
{
$listLangName = $langLabel ;
}
}
// build the list values
2017-10-30 18:50:56 +00:00
if (( isset ( $field [ 'list' ]) && $field [ 'list' ] == 1 ) && $typeName != 'repeatable' && $typeName != 'subform' )
2016-03-01 18:44:13 +00:00
{
// load to list builder
$this -> listBuilder [ $listViewName ][] = array (
'type' => $typeName ,
'code' => $name ,
'lang' => $listLangName ,
2017-10-30 18:50:56 +00:00
'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 ,
2016-03-01 18:44:13 +00:00
'custom' => $custom ,
2016-05-10 05:47:47 +00:00
'multiple' => $multiple ,
2016-03-01 18:44:13 +00:00
'options' => $options );
$this -> customBuilderList [ $listViewName ][] = $name ;
}
// 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
{
if ( ! isset ( $this -> hiddenFieldsBuilder [ $viewName ]))
{
$this -> hiddenFieldsBuilder [ $viewName ] = '' ;
}
$this -> hiddenFieldsBuilder [ $viewName ] .= ',"' . $name . '"' ;
}
// set all int fields of this view
2017-02-01 13:17:04 +00:00
if ( $field [ 'settings' ] -> datatype === 'INT' || $field [ 'settings' ] -> datatype === 'TINYINT' || $field [ 'settings' ] -> datatype === 'BIGINT' )
2016-03-01 18:44:13 +00:00
{
if ( ! isset ( $this -> intFieldsBuilder [ $viewName ]))
{
$this -> intFieldsBuilder [ $viewName ] = '' ;
}
$this -> intFieldsBuilder [ $viewName ] .= ',"' . $name . '"' ;
}
// 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
{
if ( ! isset ( $this -> dynamicfieldsBuilder [ $viewName ]))
{
$this -> dynamicfieldsBuilder [ $viewName ] = '' ;
}
if ( isset ( $this -> dynamicfieldsBuilder [ $viewName ]) && ComponentbuilderHelper :: checkString ( $this -> dynamicfieldsBuilder [ $viewName ]))
{
$this -> dynamicfieldsBuilder [ $viewName ] .= ',"' . $name . '":"' . $name . '"' ;
}
else
{
$this -> dynamicfieldsBuilder [ $viewName ] .= '"' . $name . '":"' . $name . '"' ;
}
}
// TODO we may need to add a switch instead (since now it uses the first editor field)
// set the main(biggest) text field of this view
2017-02-01 13:17:04 +00:00
if ( $typeName === 'editor' )
2016-03-01 18:44:13 +00:00
{
if ( ! isset ( $this -> maintextBuilder [ $viewName ]) || ! ComponentbuilderHelper :: checkString ( $this -> maintextBuilder [ $viewName ]))
{
$this -> maintextBuilder [ $viewName ] = $name ;
}
}
// 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
{
2017-04-05 13:21:10 +00:00
$this -> customBuilder [ $listViewName ][] = 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
if ( ! isset ( $this -> customFieldLinksBuilder [ $viewName ]))
{
$this -> customFieldLinksBuilder [ $viewName ] = '' ;
}
2016-10-23 22:48:26 +00:00
// only load this if table is set
if ( isset ( $custom [ 'table' ]) && ComponentbuilderHelper :: checkString ( $custom [ 'table' ]))
{
$this -> customFieldLinksBuilder [ $viewName ] .= ',{"sourceColumn": "' . $name . '","targetTable": "' . $custom [ 'table' ] . '","targetColumn": "' . $custom [ 'id' ] . '","displayColumn": "' . $custom [ 'text' ] . '"}' ;
}
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
2017-02-01 13:17:04 +00:00
if ( $typeName === 'category' )
2016-03-01 18:44:13 +00:00
{
if ( isset ( $this -> catOtherName [ $listViewName ]) && ComponentbuilderHelper :: checkArray ( $this -> catOtherName [ $listViewName ]))
{
$otherViews = $this -> catOtherName [ $listViewName ][ 'views' ];
$otherView = $this -> catOtherName [ $listViewName ][ 'view' ];
}
else
{
$otherViews = $listViewName ;
$otherView = $viewName ;
}
$this -> categoryBuilder [ $listViewName ] = array ( 'code' => $name , 'name' => $listLangName );
// also set code name for title alias fix
$this -> catCodeBuilder [ $viewName ] = array ( 'code' => $name , 'views' => $otherViews , 'view' => $otherView );
}
// setup checkbox for this view
2017-02-01 13:17:04 +00:00
if ( $typeName === 'checkbox' || ( ComponentbuilderHelper :: checkArray ( $custom ) && isset ( $custom [ 'extends' ]) && $custom [ 'extends' ] === 'checkboxes' ))
2016-03-01 18:44:13 +00:00
{
$this -> checkboxBuilder [ $viewName ][] = $name ;
}
// setup checkboxes and other json items for this view
2017-06-18 07:37:48 +00:00
if (( $typeName === 'subform' || $typeName === 'checkboxes' || $multiple || $field [ 'settings' ] -> store != 0 ) && $typeName != 'tag' )
2016-03-01 18:44:13 +00:00
{
switch ( $field [ 'settings' ] -> store )
{
case 1 :
// JSON_STRING_ENCODE
$this -> jsonStringBuilder [ $viewName ][] = $name ;
// Site settings of each field if needed
$this -> buildSiteFieldData ( $viewName , $name , 'json' , $typeName );
break ;
case 2 :
// BASE_SIXTY_FOUR
$this -> base64Builder [ $viewName ][] = $name ;
// Site settings of each field if needed
$this -> buildSiteFieldData ( $viewName , $name , 'base64' , $typeName );
break ;
case 3 :
// BASIC_ENCRYPTION_LOCALKEY
$this -> basicEncryptionBuilder [ $viewName ][] = $name ;
// Site settings of each field if needed
$this -> buildSiteFieldData ( $viewName , $name , 'basic_encryption' , $typeName );
break ;
case 4 :
// ADVANCE_ENCRYPTION_VDMKEY
$this -> advancedEncryptionBuilder [ $viewName ][] = $name ;
// Site settings of each field if needed
$this -> buildSiteFieldData ( $viewName , $name , 'advance_encryption' , $typeName );
break ;
default :
// JSON_ARRAY_ENCODE
$this -> jsonItemBuilder [ $viewName ][] = $name ;
// Site settings of each field if needed
$this -> buildSiteFieldData ( $viewName , $name , 'json' , $typeName );
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
{
$this -> buildSiteFieldData ( $viewName , $name , 'json' , $typeName );
}
// load the json list display fix
2017-10-30 18:50:56 +00:00
if (( isset ( $field [ 'list' ]) && $field [ 'list' ] == 1 ) && $typeName != 'repeatable' && $typeName != 'subform' )
2016-03-01 18:44:13 +00:00
{
if ( ComponentbuilderHelper :: checkArray ( $options ))
{
$this -> getItemsMethodListStringFixBuilder [ $viewName ][] = array ( 'name' => $name , 'type' => $typeName , 'translation' => true , 'custom' => $custom , 'method' => $field [ 'settings' ] -> store );
}
else
{
$this -> getItemsMethodListStringFixBuilder [ $viewName ][] = array ( 'name' => $name , 'type' => $typeName , 'translation' => false , 'custom' => $custom , 'method' => $field [ 'settings' ] -> store );
}
}
2017-06-18 07:37:48 +00:00
// if subform the values must revert to array
if ( 'subform' === $typeName )
{
$this -> jsonItemBuilderArray [ $viewName ][] = $name ;
}
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' ||
if (( $typeName === 'checkboxes' || $multiple || $field [ 'settings' ] -> store != 0 ) && ! ComponentbuilderHelper :: checkArray ( $options ))
2016-03-01 18:44:13 +00:00
{
$this -> getItemsMethodEximportStringFixBuilder [ $viewName ][] = array ( 'name' => $name , 'type' => $typeName , 'translation' => false , 'custom' => $custom , 'method' => $field [ 'settings' ] -> store );
}
// check if field should be added to uikit
2017-11-11 04:33:51 +00:00
$this -> buildSiteFieldData ( $viewName , $name , 'uikit' , $typeName );
2016-03-01 18:44:13 +00:00
// load the selection translation fix
2017-10-30 18:50:56 +00:00
if ( ComponentbuilderHelper :: checkArray ( $options ) && ( isset ( $field [ 'list' ]) && $field [ 'list' ] == 1 ) && $typeName != 'repeatable' && $typeName != 'subform' )
2016-03-01 18:44:13 +00:00
{
$this -> selectionTranslationFixBuilder [ $listViewName ][ $name ] = $options ;
}
// build the sort values
2017-10-30 18:50:56 +00:00
if (( isset ( $field [ 'sort' ]) && $field [ 'sort' ] == 1 ) && ( isset ( $field [ 'list' ]) && $field [ 'list' ] == 1 ) && ( ! $multiple && $typeName != 'checkbox' && $typeName != 'checkboxes' && $typeName != 'repeatable' && $typeName != 'subform' ))
2016-03-01 18:44:13 +00:00
{
$this -> sortBuilder [ $listViewName ][] = array ( 'type' => $typeName , 'code' => $name , 'lang' => $listLangName , 'custom' => $custom , 'options' => $options );
}
// build the search values
2017-10-30 18:50:56 +00:00
if ( isset ( $field [ 'search' ]) && $field [ 'search' ] == 1 )
2016-03-01 18:44:13 +00:00
{
2017-10-30 18:50:56 +00:00
$_list = ( ! isset ( $field [ 'list' ])) ? $field [ 'list' ] : 0 ;
$this -> searchBuilder [ $listViewName ][] = array ( 'type' => $typeName , 'code' => $name , 'custom' => $custom , 'list' => $_list );
2016-03-01 18:44:13 +00:00
}
// build the filter values
2017-10-30 18:50:56 +00:00
if (( isset ( $field [ 'filter' ]) && $field [ 'filter' ] == 1 ) && ( isset ( $field [ 'list' ]) && $field [ 'list' ] == 1 ) && ( ! $multiple && $typeName != 'checkbox' && $typeName != 'checkboxes' && $typeName != 'repeatable' && $typeName != 'subform' ))
2016-03-01 18:44:13 +00:00
{
$this -> filterBuilder [ $listViewName ][] = array ( 'type' => $typeName , 'code' => $name , 'lang' => $listLangName , 'database' => $viewName , 'function' => ComponentbuilderHelper :: safeString ( $name , 'F' ), 'custom' => $custom , 'options' => $options );
}
// 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' ;
}
2016-03-01 18:44:13 +00:00
$this -> setLayoutBuilder ( $viewName , $tabName , $name , $field );
}
public function setCustomFieldTypeFile ( $data , $viewName_list , $viewName_single )
{
// make sure it is not already been build
if ( ! isset ( $this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]]) || ! ComponentbuilderHelper :: checkArray ( $this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]]))
{
// first build the custom field type file
$target = array ( 'admin' => 'customfield' );
$this -> buildDynamique ( $target , 'field' . $data [ 'custom' ][ 'extends' ], $data [ 'custom' ][ 'type' ]);
// set tab and break replacements
$tabBreak = array (
'\t' => " \t " ,
2017-02-09 16:11:10 +00:00
'\n' => PHP_EOL
2016-03-01 18:44:13 +00:00
);
// make field dynamic
$replace = array (
'###TABLE###' => $data [ 'custom' ][ 'table' ],
'###ID###' => $data [ 'custom' ][ 'id' ],
'###TEXT###' => $data [ 'custom' ][ 'text' ],
'###CODE_TEXT###' => $data [ 'code' ] . '_' . $data [ 'custom' ][ 'text' ],
'###CODE###' => $data [ 'code' ],
'###component###' => $this -> fileContentStatic [ '###component###' ],
'###Component###' => $this -> fileContentStatic [ '###Component###' ],
'###view_type###' => $viewName_single . '_' . $data [ 'type' ],
'###type###' => $data [ 'type' ],
'###view###' => $viewName_single ,
'###views###' => $viewName_list
);
// now load the php script
if ( isset ( $data [ 'custom' ][ 'php' ]) && ComponentbuilderHelper :: checkArray ( $data [ 'custom' ][ 'php' ]))
{
// make sure the ar is reset
$phpCode = '' ;
foreach ( $data [ 'custom' ][ 'php' ] as $line => $code )
{
if ( ComponentbuilderHelper :: checkString ( $code ))
{
if ( $line == 1 )
{
2017-02-11 02:24:26 +00:00
$phpCode .= $this -> setPlaceholders ( $code , $tabBreak );
2016-03-01 18:44:13 +00:00
}
else
{
2017-02-11 02:24:26 +00:00
$phpCode .= PHP_EOL . " \t \t " . $this -> setPlaceholders ( $code , $tabBreak );
2016-03-01 18:44:13 +00:00
}
}
}
// replace the placholders
2017-02-11 02:24:26 +00:00
$phpCode = $this -> setPlaceholders ( $phpCode , $replace );
2016-03-01 18:44:13 +00:00
}
else
{
$phpCode = 'return null;' ;
}
if ( ! ComponentbuilderHelper :: checkString ( $phpCode ))
{
$phpCode = 'return null;' ;
}
2017-02-01 13:17:04 +00:00
if ( $data [ 'custom' ][ 'extends' ] === 'user' )
2016-03-01 18:44:13 +00:00
{
// now load the php xclude script
if ( ComponentbuilderHelper :: checkArray ( $data [ 'custom' ][ 'phpx' ]))
{
// make sure the ar is reset
$phpxCode = '' ;
foreach ( $data [ 'custom' ][ 'phpx' ] as $line => $code )
{
if ( ComponentbuilderHelper :: checkString ( $code ))
{
if ( $line == 1 )
{
2017-02-11 02:24:26 +00:00
$phpxCode .= $this -> setPlaceholders ( $code , $tabBreak );
2016-03-01 18:44:13 +00:00
}
else
{
2017-02-11 02:24:26 +00:00
$phpxCode .= PHP_EOL . " \t \t " . $this -> setPlaceholders ( $code , $tabBreak );
2016-03-01 18:44:13 +00:00
}
}
}
// replace the placholders
2017-02-11 02:24:26 +00:00
$phpxCode = $this -> setPlaceholders ( $phpxCode , $replace );
2016-03-01 18:44:13 +00:00
}
else
{
$phpxCode = 'return null;' ;
}
if ( ! ComponentbuilderHelper :: checkString ( $phpxCode ))
{
$phpxCode = 'return null;' ;
}
// temp holder for name
$tempName = $data [ 'custom' ][ 'label' ] . ' Group' ;
// set lang
$groupLangName = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( $tempName , 'U' );
// add to lang array
$this -> langContent [ $this -> lang ][ $groupLangName ] = ComponentbuilderHelper :: safeString ( $tempName , 'W' );
// build the Group Control
$this -> setGroupControl [ $data [ 'type' ]] = $groupLangName ;
// ###JFORM_GETGROUPS_PHP### <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]][ '###JFORM_GETGROUPS_PHP###' ] = $phpCode ;
// ###JFORM_GETEXCLUDED_PHP### <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]][ '###JFORM_GETEXCLUDED_PHP###' ] = $phpxCode ;
}
else
{
// ###JFORM_GETOPTIONS_PHP### <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]][ '###JFORM_GETOPTIONS_PHP###' ] = $phpCode ;
}
// ###Type### <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]][ '###Type###' ] = ComponentbuilderHelper :: safeString ( $data [ 'custom' ][ 'type' ], 'F' );
// ###type### <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]][ '###type###' ] = $data [ 'custom' ][ 'type' ];
// ###type### <<<DYNAMIC>>>
2016-05-06 23:41:41 +00:00
$this -> fileContentDynamic [ 'customfield_' . $data [ 'type' ]][ '###ADD_BUTTON###' ] = $this -> setAddButttonToListField ( $data [ 'custom' ][ 'view' ], $data [ 'custom' ][ 'views' ]);
2016-03-01 18:44:13 +00:00
}
}
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* default Fields
*
* @ param string $type The field type
* @ param boolean $option The field grouping
*
* @ return boolean if the field was found
*
*/
public function defaultField ( $type , $option = 'default' )
{
// list of default fields
// https://docs.joomla.org/Form_field
$defaults = array (
'default' => array (
'accesslevel' , 'cachehandler' , 'calendar' , 'captcha' , 'category' , 'checkbox' ,
'checkboxes' , 'color' , 'combo' , 'componentlayout' , 'contentlanguage' , 'editor' ,
'chromestyle' , 'contenttype' , 'databaseconnection' , 'editors' , 'email' , 'file' ,
'filelist' , 'folderlist' , 'groupedlist' , 'hidden' , 'file' , 'headertag' , 'helpsite' ,
'imagelist' , 'integer' , 'language' , 'list' , 'media' , 'menu' , 'note' , 'number' , 'password' ,
2017-06-18 07:37:48 +00:00
'plugins' , 'radio' , 'repeatable' , 'range' , 'rules' , 'subform' , 'sessionhandler' , 'spacer' , 'sql' , 'tag' ,
2016-03-01 18:44:13 +00:00
'tel' , 'menuitem' , 'meter' , 'modulelayout' , 'moduleorder' , 'moduleposition' , 'moduletag' ,
'templatestyle' , 'text' , 'textarea' , 'timezone' , 'url' , 'user' , 'usergroup'
),
'plain' => array (
'accesslevel' , 'checkbox' , 'cachehandler' , 'calendar' , 'category' , 'chromestyle' , 'color' ,
'contenttype' , 'combo' , 'componentlayout' , 'databaseconnection' , 'editor' , 'editors' ,
'email' , 'file' , 'filelist' , 'folderlist' , 'headertag' , 'helpsite' ,
'hidden' , 'imagelist' , 'integer' , 'language' , 'media' , 'menu' ,
'menuitem' , 'meter' , 'modulelayout' , 'moduleorder' , 'moduletag' , 'number' , 'password' , 'range' , 'rules' ,
'sessionhandler' , 'tag' , 'tel' , 'text' , 'textarea' ,
'timezone' , 'url' , 'user' , 'usergroup'
),
'spacer' => array (
'note' , 'spacer'
),
'option' => array (
'plugins' , 'checkboxes' , 'contentlanguage' , 'list' , 'radio' , 'sql'
),
'special' => array (
'contentlanguage' , 'groupedlist' , 'moduleposition' , 'plugin' ,
2017-06-18 07:37:48 +00:00
'repeatable' , 'templatestyle' , 'subform'
2016-03-01 18:44:13 +00:00
)
);
if ( in_array ( $type , $defaults [ $option ]))
{
return true ;
}
return false ;
}
}