2016-03-01 18:44:13 +00:00
< ? php
2018-05-18 06:28:27 +00:00
/**
* @ package Joomla . Component . Builder
*
* @ created 30 th April , 2015
2021-12-21 14:44:50 +00:00
* @ author Llewellyn van der Merwe < https :// dev . vdm . io >
* @ gitea Joomla Component Builder < https :// git . vdm . dev / joomla / Component - Builder >
2018-05-18 06:28:27 +00:00
* @ github Joomla Component Builder < https :// github . com / vdm - io / Joomla - Component - Builder >
2021-01-03 16:49:35 +00:00
* @ copyright Copyright ( C ) 2015 Vast Development Method . All rights reserved .
2018-05-18 06:28:27 +00:00
* @ license GNU General Public License version 2 or later ; see LICENSE . txt
*/
2016-03-01 18:44:13 +00:00
// No direct access to this file
defined ( '_JEXEC' ) or die ( 'Restricted access' );
2022-03-09 23:46:45 +00:00
use VDM\Joomla\Utilities\StringHelper ;
use VDM\Joomla\Utilities\ArrayHelper ;
use VDM\Joomla\Utilities\ObjectHelper ;
2022-04-04 15:35:08 +00:00
use VDM\Joomla\Utilities\GetHelper ;
2022-03-09 23:46:45 +00:00
use VDM\Joomla\Utilities\String\FieldHelper ;
2022-08-30 15:28:41 +00:00
use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory ;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix ;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent ;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line ;
2022-03-09 23:46:45 +00:00
2016-03-01 18:44:13 +00:00
/**
* Compiler class
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2016-03-01 18:44:13 +00:00
*/
class Fields extends Structure
{
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Metadate Switch
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.meta_data' );
2016-03-01 18:44:13 +00:00
*/
public $metadataBuilder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* View access Switch
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.access_switch' );
2016-03-01 18:44:13 +00:00
*/
public $accessBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* edit view tabs counter
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.tab_counter' );
2016-03-01 18:44:13 +00:00
*/
public $tabCounter = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* layout builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.layout' );
2016-03-01 18:44:13 +00:00
*/
public $layoutBuilder = array ();
2017-12-14 23:10:47 +00:00
2020-12-24 16:28:07 +00:00
/**
* permissions builder
*
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.has_permissions' );
2020-12-24 16:28:07 +00:00
*/
public $hasPermissions = array ();
2017-08-12 11:47:25 +00:00
/**
* used to fix the zero order
2019-10-16 20:34:36 +00:00
*
2017-08-12 11:47:25 +00:00
* @ var array
*/
private $zeroOrderFix = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Site field data
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
*/
public $siteFieldData = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* list of fields that are not being escaped
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.do_not_escape' );
2016-03-01 18:44:13 +00:00
*/
public $doNotEscape = array ();
2017-12-14 23:10:47 +00:00
2018-02-27 12:17:38 +00:00
/**
* list of classes used in the list view for the fields
2019-10-16 20:34:36 +00:00
*
2018-02-27 12:17:38 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> set ( 'builder.list_field_class' );
2018-02-27 12:17:38 +00:00
*/
public $listFieldClass = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* tags builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.tags' );
2016-03-01 18:44:13 +00:00
*/
public $tagsBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* query builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.database_tables' );
2016-03-01 18:44:13 +00:00
*/
public $queryBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* unique keys for database field
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.database_unique_keys' );
2016-03-01 18:44:13 +00:00
*/
public $dbUniqueKeys = array ();
2017-12-14 23:10:47 +00:00
2020-05-25 00:38:16 +00:00
/**
* unique guid swtich
*
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.database_unique_guid' );
2020-05-25 00:38:16 +00:00
*/
public $dbUniqueGuid = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* keys for database field
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.database_keys' );
2016-03-01 18:44:13 +00:00
*/
public $dbKeys = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* history builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.history' );
2016-03-01 18:44:13 +00:00
*/
public $historyBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* alias builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 CFactory :: _ ( 'Registry' ) -> get ( 'builder.alias' );
2016-03-01 18:44:13 +00:00
*/
public $aliasBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* title builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 CFactory :: _ ( 'Registry' ) -> get ( 'builder.title' );
2016-03-01 18:44:13 +00:00
*/
public $titleBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* list builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2022-09-10 08:16:44 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.list' );
2016-03-01 18:44:13 +00:00
*/
public $listBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* custom Builder List
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.custom_list' );
2016-03-01 18:44:13 +00:00
*/
public $customBuilderList = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Hidden Fields Builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.hidden_fields' );
2016-03-01 18:44:13 +00:00
*/
public $hiddenFieldsBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* INT Field Builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.integer_fields' );
2016-03-01 18:44:13 +00:00
*/
public $intFieldsBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Dynamic Fields Builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.dynamic_fields' );
2016-03-01 18:44:13 +00:00
*/
public $dynamicfieldsBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Main text Builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.main_text_field' );
2016-03-01 18:44:13 +00:00
*/
public $maintextBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Custom Builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
*/
public $customBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Custom Field Links Builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.custom_field_links' );
2016-03-01 18:44:13 +00:00
*/
public $customFieldLinksBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Set Script for User Switch
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
*/
public $setScriptUserSwitch = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Set Script for Media Switch
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
*/
public $setScriptMediaSwitch = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Category builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
*/
public $categoryBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Category Code builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
*/
public $catCodeBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Check Box builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
*/
public $checkboxBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Json String Builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
*/
public $jsonStringBuilder = array ();
2017-12-14 23:10:47 +00:00
2017-06-18 07:37:48 +00:00
/**
* Json String Builder for return values to array
2019-10-16 20:34:36 +00:00
*
2017-06-18 07:37:48 +00:00
* @ var array
*/
public $jsonItemBuilderArray = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Json Item Builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
*/
public $jsonItemBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Base 64 Builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
*/
public $base64Builder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2019-10-16 20:34:36 +00:00
* Basic Encryption Field Modeling
*
2016-03-01 18:44:13 +00:00
* @ var array
*/
2019-10-16 20:34:36 +00:00
public $basicFieldModeling = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2019-10-16 20:34:36 +00:00
* WHMCS Encryption Field Modeling
*
2016-03-01 18:44:13 +00:00
* @ var array
*/
2019-10-16 20:34:36 +00:00
public $whmcsFieldModeling = array ();
2018-03-06 02:28:44 +00:00
/**
2019-10-16 20:34:36 +00:00
* Medium Encryption Field Modeling
*
* @ var array
*/
public $mediumFieldModeling = array ();
/**
* Expert Field Modeling
*
* @ var array
*/
public $expertFieldModeling = array ();
/**
* Expert Mode Initiator
*
2018-03-06 02:28:44 +00:00
* @ var array
*/
2019-10-16 20:34:36 +00:00
public $expertFieldModelInitiator = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Get Items Method List String Fix Builder
2019-10-16 20:34:36 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
*/
public $getItemsMethodListStringFixBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Get Items Method Eximport String Fix Builder
2020-03-28 13:34:14 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
*/
public $getItemsMethodEximportStringFixBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Selection Translation Fix Builder
2020-03-28 13:34:14 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
*/
2017-12-14 23:10:47 +00:00
public $selectionTranslationFixBuilder = array ();
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Sort Builder
2020-03-28 13:34:14 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
*/
public $sortBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Search Builder
2020-03-28 13:34:14 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
*/
public $searchBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Filter Builder
2020-03-28 13:34:14 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
*/
public $filterBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* Set Group Control
2020-03-28 13:34:14 +00:00
*
2016-03-01 18:44:13 +00:00
* @ var array
2016-03-04 00:01:43 +00:00
*/
public $setGroupControl = array ();
2017-12-14 23:10:47 +00:00
2016-06-02 16:18:49 +00:00
/**
* Set Field Names
2020-03-28 13:34:14 +00:00
*
2016-06-02 16:18:49 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.field_names' );
2016-06-02 16:18:49 +00:00
*/
2017-12-14 23:10:47 +00:00
public $fieldsNames = array ();
2016-06-02 16:18:49 +00:00
/**
* Default Fields set to publishing
2020-03-28 13:34:14 +00:00
*
2016-06-02 16:18:49 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> set ( 'builder.new_publishing_fields' );
2016-06-02 16:18:49 +00:00
*/
public $newPublishingFields = array ();
2017-12-14 23:10:47 +00:00
2016-06-02 16:18:49 +00:00
/**
* Default Fields set to publishing
2020-03-28 13:34:14 +00:00
*
2016-06-02 16:18:49 +00:00
* @ var array
2023-05-02 00:10:55 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.moved_publishing_fields' );
2016-06-02 16:18:49 +00:00
*/
public $movedPublishingFields = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* set the Field set of a view
2020-03-28 13:34:14 +00:00
*
2020-11-26 17:33:39 +00:00
* @ param array $view The view data
* @ param string $component The component name
* @ param string $nameSingleCode The single view name
* @ param string $nameListCode The list view name
2016-03-01 18:44:13 +00:00
*
* @ return string The fields set in xml
2020-03-28 13:34:14 +00:00
*
2016-03-01 18:44:13 +00:00
*/
2020-11-26 17:33:39 +00:00
public function setFieldSet ( $view , $component , $nameSingleCode ,
2023-05-02 00:10:55 +00:00
$nameListCode
2020-03-28 13:34:14 +00:00
) {
2016-03-01 18:44:13 +00:00
// setup the fieldset of this view
2020-03-28 13:34:14 +00:00
if ( isset ( $view [ 'settings' ] -> fields )
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check ( $view [ 'settings' ] -> fields ))
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
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.meta_data.' . $nameSingleCode , $nameListCode );
2016-03-01 18:44:13 +00:00
}
// add access to the view
2017-10-30 13:08:02 +00:00
if ( isset ( $view [ 'access' ]) && $view [ 'access' ])
2016-03-01 18:44:13 +00:00
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.access_switch.' . $nameSingleCode , true );
CFactory :: _ ( 'Registry' ) -> set ( 'builder.access_switch_list.' . $nameListCode , true );
2016-03-01 18:44:13 +00:00
}
// main lang prefix
2022-08-30 15:28:41 +00:00
$langView = CFactory :: _ ( 'Config' ) -> lang_prefix . '_'
2022-12-11 15:06:13 +00:00
. CFactory :: _ ( 'Placeholder' ) -> get ( 'VIEW' );
2022-08-30 15:28:41 +00:00
$langViews = CFactory :: _ ( 'Config' ) -> lang_prefix . '_'
2022-12-11 15:06:13 +00:00
. CFactory :: _ ( 'Placeholder' ) -> get ( 'VIEWS' );
2016-03-01 18:44:13 +00:00
// set default lang
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langView , $view [ 'settings' ] -> name_single
2020-03-28 13:34:14 +00:00
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews , $view [ 'settings' ] -> name_list
2020-03-28 13:34:14 +00:00
);
2016-03-01 18:44:13 +00:00
// set global item strings
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_ARCHIVED' ,
2020-03-28 13:34:14 +00:00
" %s " . $view [ 'settings' ] -> name_list . " archived. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_ARCHIVED_1' ,
2020-03-28 13:34:14 +00:00
" %s " . $view [ 'settings' ] -> name_single . " archived. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_CHECKED_IN_0' ,
2020-03-28 13:34:14 +00:00
" No " . $view [ 'settings' ] -> name_single
. " successfully checked in. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_CHECKED_IN_1' ,
2020-03-28 13:34:14 +00:00
" %d " . $view [ 'settings' ] -> name_single
. " successfully checked in. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_CHECKED_IN_MORE' ,
2020-03-28 13:34:14 +00:00
" %d " . $view [ 'settings' ] -> name_list
. " successfully checked in. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_DELETED' ,
2020-03-28 13:34:14 +00:00
" %s " . $view [ 'settings' ] -> name_list . " deleted. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_DELETED_1' ,
2020-03-28 13:34:14 +00:00
" %s " . $view [ 'settings' ] -> name_single . " deleted. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_FEATURED' ,
2020-03-28 13:34:14 +00:00
" %s " . $view [ 'settings' ] -> name_list . " featured. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_FEATURED_1' ,
2020-03-28 13:34:14 +00:00
" %s " . $view [ 'settings' ] -> name_single . " featured. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_PUBLISHED' ,
2020-03-28 13:34:14 +00:00
" %s " . $view [ 'settings' ] -> name_list . " published. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_PUBLISHED_1' ,
2020-03-28 13:34:14 +00:00
" %s " . $view [ 'settings' ] -> name_single . " published. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_TRASHED' ,
2020-03-28 13:34:14 +00:00
" %s " . $view [ 'settings' ] -> name_list . " trashed. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_TRASHED_1' ,
2020-03-28 13:34:14 +00:00
" %s " . $view [ 'settings' ] -> name_single . " trashed. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_UNFEATURED' ,
2020-03-28 13:34:14 +00:00
" %s " . $view [ 'settings' ] -> name_list . " unfeatured. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_UNFEATURED_1' ,
2020-03-28 13:34:14 +00:00
" %s " . $view [ 'settings' ] -> name_single . " unfeatured. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_UNPUBLISHED' ,
2020-03-28 13:34:14 +00:00
" %s " . $view [ 'settings' ] -> name_list . " unpublished. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_UNPUBLISHED_1' ,
2020-03-28 13:34:14 +00:00
" %s " . $view [ 'settings' ] -> name_single . " unpublished. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_FAILED_PUBLISHING' ,
2020-09-15 17:14:53 +00:00
" %s " . $view [ 'settings' ] -> name_list . " failed publishing. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_N_ITEMS_FAILED_PUBLISHING_1' ,
2020-09-15 17:14:53 +00:00
" %s " . $view [ 'settings' ] -> name_single . " failed publishing. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_BATCH_OPTIONS' ,
2020-03-28 13:34:14 +00:00
" Batch process the selected " . $view [ 'settings' ] -> name_list
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langViews . '_BATCH_TIP' ,
2020-03-28 13:34:14 +00:00
" All changes will be applied to all selected "
. $view [ 'settings' ] -> name_list
);
2016-03-01 18:44:13 +00:00
// set some basic defaults
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langView . '_ERROR_UNIQUE_ALIAS' ,
2020-03-28 13:34:14 +00:00
" Another " . $view [ 'settings' ] -> name_single
. " has the same alias. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langView . '_CREATED_DATE_LABEL' , " Created Date "
2020-03-28 13:34:14 +00:00
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langView . '_CREATED_DATE_DESC' ,
2020-03-28 13:34:14 +00:00
" The date this " . $view [ 'settings' ] -> name_single
. " was created. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langView . '_MODIFIED_DATE_LABEL' , " Modified Date "
2020-03-28 13:34:14 +00:00
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langView . '_MODIFIED_DATE_DESC' ,
2020-03-28 13:34:14 +00:00
" The date this " . $view [ 'settings' ] -> name_single
. " was modified. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langView . '_CREATED_BY_LABEL' , " Created By "
2020-03-28 13:34:14 +00:00
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langView . '_CREATED_BY_DESC' ,
2020-03-28 13:34:14 +00:00
" The user that created this " . $view [ 'settings' ] -> name_single
. " . "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langView . '_MODIFIED_BY_LABEL' , " Modified By "
2020-03-28 13:34:14 +00:00
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langView . '_MODIFIED_BY_DESC' ,
2020-03-28 13:34:14 +00:00
" The last user that modified this "
. $view [ 'settings' ] -> name_single . " . "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langView . '_ORDERING_LABEL' , " Ordering "
2020-03-28 13:34:14 +00:00
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langView . '_VERSION_LABEL' , " Version "
2020-03-28 13:34:14 +00:00
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langView . '_VERSION_DESC' ,
2020-03-28 13:34:14 +00:00
" A count of the number of times this "
. $view [ 'settings' ] -> name_single . " has been revised. "
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langView . '_SAVE_WARNING' ,
2020-03-28 13:34:14 +00:00
" Alias already existed so a number was added at the end. You can re-edit the "
. $view [ 'settings' ] -> name_single . " to customise the alias. "
);
2018-03-18 04:28:54 +00:00
// check what type of field builder to use
2022-08-30 15:28:41 +00:00
if ( CFactory :: _ ( 'Config' ) -> get ( 'field_builder_type' , 2 ) == 1 )
2018-03-18 04:28:54 +00:00
{
// build field set using string manipulation
2020-03-28 13:34:14 +00:00
return $this -> stringFieldSet (
2020-11-26 17:33:39 +00:00
$view , $component , $nameSingleCode , $nameListCode ,
2020-03-28 13:34:14 +00:00
$langView , $langViews
);
2018-03-18 04:28:54 +00:00
}
else
{
// build field set with simpleXMLElement class
2020-03-28 13:34:14 +00:00
return $this -> simpleXMLFieldSet (
2020-11-26 17:33:39 +00:00
$view , $component , $nameSingleCode , $nameListCode ,
2020-03-28 13:34:14 +00:00
$langView , $langViews
);
2018-03-18 04:28:54 +00:00
}
2016-03-01 18:44:13 +00:00
}
2020-03-28 13:34:14 +00:00
2016-03-01 18:44:13 +00:00
return '' ;
}
2017-12-03 17:08:01 +00:00
2018-03-18 04:28:54 +00:00
/**
* build field set using string manipulation
*
2020-11-26 17:33:39 +00:00
* @ param array $view The view data
* @ param string $component The component name
* @ param string $nameSingleCode The single view name
* @ param string $nameListCode The list view name
* @ param string $langView The language string of the view
* @ param string $langViews The language string of the views
2018-03-18 04:28:54 +00:00
*
* @ return string The fields set in xml
*
*/
2020-11-26 17:33:39 +00:00
protected function stringFieldSet ( $view , $component , $nameSingleCode ,
2023-05-02 00:10:55 +00:00
$nameListCode , $langView , $langViews
2020-03-28 13:34:14 +00:00
) {
2018-03-18 04:28:54 +00:00
// set the read only
$readOnly = false ;
if ( $view [ 'settings' ] -> type == 2 )
{
2022-08-30 15:28:41 +00:00
$readOnly = Indent :: _ ( 3 ) . 'readonly="true"' . PHP_EOL . Indent :: _ (
2020-03-28 13:34:14 +00:00
3
) . 'disabled="true"' ;
2018-03-18 04:28:54 +00:00
}
// start adding dynamc fields
$dynamicFields = '' ;
// set the custom table key
$dbkey = 'g' ;
2022-08-30 15:28:41 +00:00
// for plugin event TODO change event api signatures
2022-12-11 15:06:13 +00:00
$placeholders = CFactory :: _ ( 'Placeholder' ) -> active ;
2023-01-15 08:42:19 +00:00
$component_context = CFactory :: _ ( 'Config' ) -> component_context ;
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onBeforeBuildFields
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2020-03-28 13:34:14 +00:00
'jcb_ce_onBeforeBuildFields' ,
2023-01-15 08:42:19 +00:00
array ( & $component_context , & $dynamicFields , & $readOnly ,
2023-05-02 00:10:55 +00:00
& $dbkey , & $view , & $component , & $nameSingleCode ,
& $nameListCode , & $placeholders , & $langView ,
& $langViews )
2020-03-28 13:34:14 +00:00
);
2022-12-11 15:06:13 +00:00
unset ( $placeholders );
2018-03-18 04:28:54 +00:00
// TODO we should add the global and local view switch if field for front end
foreach ( $view [ 'settings' ] -> fields as $field )
{
2020-03-28 13:34:14 +00:00
$dynamicFields .= $this -> setDynamicField (
$field , $view , $view [ 'settings' ] -> type , $langView ,
2022-08-30 15:28:41 +00:00
$nameSingleCode , $nameListCode , CFactory :: _ ( 'Placeholder' ) -> active , $dbkey ,
2020-03-28 13:34:14 +00:00
true
);
2018-03-18 04:28:54 +00:00
}
2022-08-30 15:28:41 +00:00
// for plugin event TODO change event api signatures
2022-12-11 15:06:13 +00:00
$placeholders = CFactory :: _ ( 'Placeholder' ) -> active ;
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onAfterBuildFields
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2020-03-28 13:34:14 +00:00
'jcb_ce_onAfterBuildFields' ,
2023-01-15 08:42:19 +00:00
array ( & $component_context , & $dynamicFields , & $readOnly ,
2023-05-02 00:10:55 +00:00
& $dbkey , & $view , & $component , & $nameSingleCode ,
& $nameListCode , & $placeholders , & $langView ,
& $langViews )
2020-03-28 13:34:14 +00:00
);
2022-12-11 15:06:13 +00:00
unset ( $placeholders );
2018-03-18 04:28:54 +00:00
// set the default fields
2020-03-28 13:34:14 +00:00
$fieldSet = array ();
2018-03-18 04:28:54 +00:00
$fieldSet [] = '<fieldset name="details">' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <!-- " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Default Fields. --> " ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <!-- " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Id Field. Type: Text (joomla) --> " ;
2018-03-18 04:28:54 +00:00
// if id is not set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.id' ))
2018-03-18 04:28:54 +00:00
{
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <field " ;
$fieldSet [] = Indent :: _ ( 3 ) . " name= " . '"id"' ;
$fieldSet [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. 'type="text" class="readonly" label="JGLOBAL_FIELD_ID_LABEL"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. 'description ="JGLOBAL_FIELD_ID_DESC" size="10" default="0"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . 'readonly="true"' ;
$fieldSet [] = Indent :: _ ( 2 ) . " /> " ;
2018-03-18 04:28:54 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2018-03-18 04:28:54 +00:00
}
// if created is not set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.created' ))
2018-03-18 04:28:54 +00:00
{
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <!-- " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Date Created Field. Type: Calendar (joomla) --> " ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <field " ;
$fieldSet [] = Indent :: _ ( 3 ) . " name= " . '"created"' ;
$fieldSet [] = Indent :: _ ( 3 ) . " type= " . '"calendar"' ;
$fieldSet [] = Indent :: _ ( 3 ) . " label= " . '"' . $langView
2020-03-28 13:34:14 +00:00
. '_CREATED_DATE_LABEL"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . " description= " . '"' . $langView
2020-03-28 13:34:14 +00:00
. '_CREATED_DATE_DESC"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . " size= " . '"22"' ;
2018-03-18 04:28:54 +00:00
if ( $readOnly )
{
$fieldSet [] = $readOnly ;
}
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . " format= " . '"%Y-%m-%d %H:%M:%S"' ;
$fieldSet [] = Indent :: _ ( 3 ) . " filter= " . '"user_utc"' ;
$fieldSet [] = Indent :: _ ( 2 ) . " /> " ;
2018-03-18 04:28:54 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2018-03-18 04:28:54 +00:00
}
// if created_by is not set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.created_by' ))
2018-03-18 04:28:54 +00:00
{
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <!-- " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " User Created Field. Type: User (joomla) --> " ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <field " ;
$fieldSet [] = Indent :: _ ( 3 ) . " name= " . '"created_by"' ;
$fieldSet [] = Indent :: _ ( 3 ) . " type= " . '"user"' ;
$fieldSet [] = Indent :: _ ( 3 ) . " label= " . '"' . $langView
2020-03-28 13:34:14 +00:00
. '_CREATED_BY_LABEL"' ;
2018-03-18 04:28:54 +00:00
if ( $readOnly )
{
$fieldSet [] = $readOnly ;
}
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . " description= " . '"' . $langView
2020-03-28 13:34:14 +00:00
. '_CREATED_BY_DESC"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " /> " ;
2018-03-18 04:28:54 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2018-03-18 04:28:54 +00:00
}
// if published is not set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.published' ))
2018-03-18 04:28:54 +00:00
{
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <!-- " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Published Field. Type: List (joomla) --> " ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <field name= "
2020-03-28 13:34:14 +00:00
. '"published" type="list" label="JSTATUS"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . " description= "
2020-03-28 13:34:14 +00:00
. '"JFIELD_PUBLISHED_DESC" class="chzn-color-state"' ;
2018-03-18 04:28:54 +00:00
if ( $readOnly )
{
$fieldSet [] = $readOnly ;
}
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . " filter= "
2020-03-28 13:34:14 +00:00
. '"intval" size="1" default="1" >' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . " <option value= " . '"1">' ;
$fieldSet [] = Indent :: _ ( 4 ) . " JPUBLISHED</option> " ;
$fieldSet [] = Indent :: _ ( 3 ) . " <option value= " . '"0">' ;
$fieldSet [] = Indent :: _ ( 4 ) . " JUNPUBLISHED</option> " ;
$fieldSet [] = Indent :: _ ( 3 ) . " <option value= " . '"2">' ;
$fieldSet [] = Indent :: _ ( 4 ) . " JARCHIVED</option> " ;
$fieldSet [] = Indent :: _ ( 3 ) . " <option value= " . '"-2">' ;
$fieldSet [] = Indent :: _ ( 4 ) . " JTRASHED</option> " ;
$fieldSet [] = Indent :: _ ( 2 ) . " </field> " ;
2018-03-18 04:28:54 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2018-03-18 04:28:54 +00:00
}
// if modified is not set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.modified' ))
2018-03-18 04:28:54 +00:00
{
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <!-- " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Date Modified Field. Type: Calendar (joomla) --> " ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 )
2020-03-28 13:34:14 +00:00
. '<field name="modified" type="calendar" class="readonly"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . 'label="' . $langView
2020-03-28 13:34:14 +00:00
. '_MODIFIED_DATE_LABEL" description="' . $langView
. '_MODIFIED_DATE_DESC"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. 'size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />' ;
2018-03-18 04:28:54 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2018-03-18 04:28:54 +00:00
}
// if modified_by is not set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.modified_by' ))
2018-03-18 04:28:54 +00:00
{
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <!-- " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " User Modified Field. Type: User (joomla) --> " ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 )
2020-03-28 13:34:14 +00:00
. '<field name="modified_by" type="user"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . 'label="' . $langView
2020-03-28 13:34:14 +00:00
. '_MODIFIED_BY_LABEL"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . " description= " . '"' . $langView
2020-03-28 13:34:14 +00:00
. '_MODIFIED_BY_DESC"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . 'class="readonly"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'readonly="true"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'filter="unset"' ;
$fieldSet [] = Indent :: _ ( 2 ) . " /> " ;
2018-03-18 04:28:54 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2018-03-18 04:28:54 +00:00
}
// check if view has access
2023-05-02 00:10:55 +00:00
if ( CFactory :: _ ( 'Registry' ) -> exists ( 'builder.access_switch.' . $nameSingleCode )
&& ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.access' ))
2018-03-18 04:28:54 +00:00
{
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <!-- " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Access Field. Type: Accesslevel (joomla) --> " ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . '<field name="access"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'type="accesslevel"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'label="JFIELD_ACCESS_LABEL"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'description="JFIELD_ACCESS_DESC"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'default="1"' ;
2018-03-18 04:28:54 +00:00
if ( $readOnly )
{
$fieldSet [] = $readOnly ;
}
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . 'required="false"' ;
$fieldSet [] = Indent :: _ ( 2 ) . " /> " ;
2018-03-18 04:28:54 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2018-03-18 04:28:54 +00:00
}
// if ordering is not set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.ordering' ))
2018-03-18 04:28:54 +00:00
{
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <!-- " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Ordering Field. Type: Numbers (joomla) --> " ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <field " ;
$fieldSet [] = Indent :: _ ( 3 ) . 'name="ordering"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'type="number"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'class="inputbox validate-ordering"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'label="' . $langView
2020-03-28 13:34:14 +00:00
. '_ORDERING_LABEL' . '"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . 'description=""' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'default="0"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'size="6"' ;
2018-03-18 04:28:54 +00:00
if ( $readOnly )
{
$fieldSet [] = $readOnly ;
}
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . 'required="false"' ;
$fieldSet [] = Indent :: _ ( 2 ) . " /> " ;
2018-03-18 04:28:54 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2018-03-18 04:28:54 +00:00
}
// if version is not set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.version' ))
2018-03-18 04:28:54 +00:00
{
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <!-- " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Version Field. Type: Text (joomla) --> " ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <field " ;
$fieldSet [] = Indent :: _ ( 3 ) . 'name="version"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'type="text"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'class="readonly"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'label="' . $langView
2020-03-28 13:34:14 +00:00
. '_VERSION_LABEL"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . 'description="' . $langView
2020-03-28 13:34:14 +00:00
. '_VERSION_DESC"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . 'size="6"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'readonly="true"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'filter="unset"' ;
$fieldSet [] = Indent :: _ ( 2 ) . " /> " ;
2018-03-18 04:28:54 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2018-03-18 04:28:54 +00:00
}
// check if metadata is added to this view
2023-05-02 00:10:55 +00:00
if ( CFactory :: _ ( 'Registry' ) -> isString ( 'builder.meta_data.' . $nameSingleCode ))
2018-03-18 04:28:54 +00:00
{
// metakey
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.metakey' ))
2019-10-11 13:41:00 +00:00
{
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <!-- " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Metakey Field. Type: Textarea (joomla) --> " ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <field " ;
$fieldSet [] = Indent :: _ ( 3 ) . 'name="metakey"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'type="textarea"' ;
$fieldSet [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. 'label="JFIELD_META_KEYWORDS_LABEL"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. 'description="JFIELD_META_KEYWORDS_DESC"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . 'rows="3"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'cols="30"' ;
$fieldSet [] = Indent :: _ ( 2 ) . " /> " ;
2019-10-11 13:41:00 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2019-10-11 13:41:00 +00:00
}
2018-03-18 04:28:54 +00:00
// metadesc
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.metadesc' ))
2019-10-11 13:41:00 +00:00
{
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <!-- " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Metadesc Field. Type: Textarea (joomla) --> " ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <field " ;
$fieldSet [] = Indent :: _ ( 3 ) . 'name="metadesc"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'type="textarea"' ;
$fieldSet [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. 'label="JFIELD_META_DESCRIPTION_LABEL"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. 'description="JFIELD_META_DESCRIPTION_DESC"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . 'rows="3"' ;
$fieldSet [] = Indent :: _ ( 3 ) . 'cols="30"' ;
$fieldSet [] = Indent :: _ ( 2 ) . " /> " ;
2019-10-11 13:41:00 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2019-10-11 13:41:00 +00:00
}
2018-03-18 04:28:54 +00:00
}
2020-12-24 13:39:33 +00:00
// fix the permissions field "title" issue gh-629
// check if the the title is not already set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.title' )
2020-12-24 16:28:07 +00:00
&& $this -> hasPermissionsSet ( $view , $nameSingleCode ))
2020-12-24 13:39:33 +00:00
{
// set the field/tab name
$field_name = " title " ;
$tab_name = " publishing " ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <!-- " . Line :: _ ( __Line__ , __Class__ )
2020-12-24 13:39:33 +00:00
. " Was added due to Permissions JS needing a Title field --> " ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <!-- " . Line :: _ ( __Line__ , __Class__ )
2020-12-24 13:39:33 +00:00
. " Let us know at gh-629 should this change --> " ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <!-- " . Line :: _ ( __Line__ , __Class__ )
2020-12-24 13:39:33 +00:00
. " https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235 --> " ;
// at this point we know that we must add a hidden title field
// and make sure it does not get stored to the database
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <field " ;
$fieldSet [] = Indent :: _ ( 3 ) . " name= " . '"' . $field_name . '"' ;
$fieldSet [] = Indent :: _ ( 3 )
2020-12-24 13:39:33 +00:00
. 'type="hidden"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . 'default="' . $component . ' '
2020-12-24 13:39:33 +00:00
. $nameSingleCode . '"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " /> " ;
2020-12-24 13:39:33 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2020-12-24 13:39:33 +00:00
// setup needed field values for layout
$field_array = array ();
$field_array [ 'order_edit' ] = 0 ;
$field_array [ 'tab' ] = 15 ;
$field_array [ 'alignment' ] = 1 ;
// make sure it gets added to view
$this -> setLayoutBuilder (
$nameSingleCode , $tab_name , $field_name , $field_array
);
}
2018-03-18 04:28:54 +00:00
// load the dynamic fields now
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $dynamicFields ))
2018-03-18 04:28:54 +00:00
{
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " <!-- " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Dynamic Fields. --> " . $dynamicFields ;
2018-03-18 04:28:54 +00:00
}
// close fieldset
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 1 ) . " </fieldset> " ;
2018-03-18 04:28:54 +00:00
// check if metadata is added to this view
2023-05-02 00:10:55 +00:00
if ( CFactory :: _ ( 'Registry' ) -> isString ( 'builder.meta_data.' . $nameSingleCode ))
2018-03-18 04:28:54 +00:00
{
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.robots' )
|| ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.rights' )
|| ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.author' ))
2019-10-11 13:41:00 +00:00
{
2022-08-30 15:28:41 +00:00
$fieldSet [] = PHP_EOL . Indent :: _ ( 1 ) . " <!-- " . Line :: _ (
__LINE__ , __CLASS__
2020-03-28 13:34:14 +00:00
) . " Metadata Fields. --> " ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 1 ) . " <fields "
2020-03-28 13:34:14 +00:00
. ' name="metadata" label="JGLOBAL_FIELDSET_METADATA_OPTIONS">' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . '<fieldset name="vdmmetadata"' ;
$fieldSet [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. 'label="JGLOBAL_FIELDSET_METADATA_OPTIONS">' ;
2019-10-11 13:41:00 +00:00
// robots
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.robots' ))
2019-10-11 13:41:00 +00:00
{
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . " <!-- " . Line :: _ (
__LINE__ , __CLASS__
2020-03-28 13:34:14 +00:00
) . " Robots Field. Type: List (joomla) --> " ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . '<field name="robots"' ;
$fieldSet [] = Indent :: _ ( 4 ) . 'type="list"' ;
$fieldSet [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. 'label="JFIELD_METADATA_ROBOTS_LABEL"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. 'description="JFIELD_METADATA_ROBOTS_DESC" >' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. '<option value="">JGLOBAL_USE_GLOBAL</option>' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. '<option value="index, follow">JGLOBAL_INDEX_FOLLOW</option>' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. '<option value="noindex, follow">JGLOBAL_NOINDEX_FOLLOW</option>' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. '<option value="index, nofollow">JGLOBAL_INDEX_NOFOLLOW</option>' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. '<option value="noindex, nofollow">JGLOBAL_NOINDEX_NOFOLLOW</option>' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . '</field>' ;
2019-10-11 13:41:00 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2019-10-11 13:41:00 +00:00
}
// author
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.author' ))
2019-10-11 13:41:00 +00:00
{
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . " <!-- " . Line :: _ (
__LINE__ , __CLASS__
2020-03-28 13:34:14 +00:00
) . " Author Field. Type: Text (joomla) --> " ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . '<field name="author"' ;
$fieldSet [] = Indent :: _ ( 4 ) . 'type="text"' ;
$fieldSet [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. 'label="JAUTHOR" description="JFIELD_METADATA_AUTHOR_DESC"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 4 ) . 'size="20"' ;
$fieldSet [] = Indent :: _ ( 3 ) . " /> " ;
2019-10-11 13:41:00 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2019-10-11 13:41:00 +00:00
}
// rights
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.rights' ))
2019-10-11 13:41:00 +00:00
{
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 ) . " <!-- " . Line :: _ (
__LINE__ , __CLASS__
2020-03-28 13:34:14 +00:00
) . " Rights Field. Type: Textarea (joomla) --> " ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. '<field name="rights" type="textarea" label="JFIELD_META_RIGHTS_LABEL"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. 'description="JFIELD_META_RIGHTS_DESC" required="false" filter="string"' ;
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 4 ) . 'cols="30" rows="2"' ;
$fieldSet [] = Indent :: _ ( 3 ) . " /> " ;
2019-10-11 13:41:00 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2019-10-11 13:41:00 +00:00
}
2022-08-30 15:28:41 +00:00
$fieldSet [] = Indent :: _ ( 2 ) . " </fieldset> " ;
$fieldSet [] = Indent :: _ ( 1 ) . " </fields> " ;
2019-10-11 13:41:00 +00:00
}
2018-03-18 04:28:54 +00:00
}
2020-03-28 13:34:14 +00:00
2020-11-26 17:33:39 +00:00
// return the set
2018-03-18 04:28:54 +00:00
return implode ( PHP_EOL , $fieldSet );
}
/**
* build field set with simpleXMLElement class
*
2020-11-26 17:33:39 +00:00
* @ param array $view The view data
* @ param string $component The component name
* @ param string $nameSingleCode The single view name
* @ param string $nameListCode The list view name
* @ param string $langView The language string of the view
* @ param string $langViews The language string of the views
2018-03-18 04:28:54 +00:00
*
* @ return string The fields set in xml
*
*/
2020-11-26 17:33:39 +00:00
protected function simpleXMLFieldSet ( $view , $component , $nameSingleCode ,
2023-05-02 00:10:55 +00:00
$nameListCode , $langView , $langViews
2020-03-28 13:34:14 +00:00
) {
2018-03-18 04:28:54 +00:00
// set the read only
$readOnlyXML = array ();
if ( $view [ 'settings' ] -> type == 2 )
{
$readOnlyXML [ 'readonly' ] = true ;
$readOnlyXML [ 'disabled' ] = true ;
}
// start adding dynamc fields
$dynamicFieldsXML = array ();
// set the custom table key
$dbkey = 'g' ;
2022-08-30 15:28:41 +00:00
// for plugin event TODO change event api signatures
2022-12-11 15:06:13 +00:00
$placeholders = CFactory :: _ ( 'Placeholder' ) -> active ;
2023-01-15 08:42:19 +00:00
$component_context = CFactory :: _ ( 'Config' ) -> component_context ;
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onBeforeBuildFields
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2020-03-28 13:34:14 +00:00
'jcb_ce_onBeforeBuildFields' ,
2023-01-15 08:42:19 +00:00
array ( & $component_context , & $dynamicFieldsXML , & $readOnlyXML ,
2023-05-02 00:10:55 +00:00
& $dbkey , & $view , & $component , & $nameSingleCode ,
& $nameListCode , & $placeholders , & $langView ,
& $langViews )
2020-03-28 13:34:14 +00:00
);
2022-12-11 15:06:13 +00:00
unset ( $placeholders );
2018-03-18 04:28:54 +00:00
// TODO we should add the global and local view switch if field for front end
foreach ( $view [ 'settings' ] -> fields as $field )
{
2020-03-28 13:34:14 +00:00
$dynamicFieldsXML [] = $this -> setDynamicField (
$field , $view , $view [ 'settings' ] -> type , $langView ,
2022-08-30 15:28:41 +00:00
$nameSingleCode , $nameListCode , CFactory :: _ ( 'Placeholder' ) -> active , $dbkey ,
2020-03-28 13:34:14 +00:00
true
);
2018-03-18 04:28:54 +00:00
}
2022-08-30 15:28:41 +00:00
// for plugin event TODO change event api signatures
2022-12-11 15:06:13 +00:00
$placeholders = CFactory :: _ ( 'Placeholder' ) -> active ;
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onAfterBuildFields
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2020-03-28 13:34:14 +00:00
'jcb_ce_onAfterBuildFields' ,
2023-01-15 08:42:19 +00:00
array ( & $component_context , & $dynamicFieldsXML , & $readOnlyXML ,
2023-05-02 00:10:55 +00:00
& $dbkey , & $view , & $component , & $nameSingleCode ,
& $nameListCode , & $placeholders , & $langView ,
& $langViews )
2020-03-28 13:34:14 +00:00
);
2022-12-11 15:06:13 +00:00
unset ( $placeholders );
2018-03-18 04:28:54 +00:00
// set the default fields
2020-03-28 13:34:14 +00:00
$XML = new simpleXMLElement ( '<a/>' );
2018-03-18 04:28:54 +00:00
$fieldSetXML = $XML -> addChild ( 'fieldset' );
$fieldSetXML -> addAttribute ( 'name' , 'details' );
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: xmlComment (
2022-08-30 15:28:41 +00:00
$fieldSetXML , Line :: _ ( __Line__ , __Class__ ) . " Default Fields. "
2020-03-28 13:34:14 +00:00
);
ComponentbuilderHelper :: xmlComment (
$fieldSetXML ,
2022-08-30 15:28:41 +00:00
Line :: _ ( __Line__ , __Class__ ) . " Id Field. Type: Text (joomla) "
2020-03-28 13:34:14 +00:00
);
2018-03-18 04:28:54 +00:00
// if id is not set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.id' ))
2018-03-18 04:28:54 +00:00
{
$attributes = array (
2020-03-28 13:34:14 +00:00
'name' => 'id' ,
'type' => 'text' ,
'class' => 'readonly' ,
'readonly' => " true " ,
'label' => 'JGLOBAL_FIELD_ID_LABEL' ,
2018-03-18 04:28:54 +00:00
'description' => 'JGLOBAL_FIELD_ID_DESC' ,
2020-03-28 13:34:14 +00:00
'size' => 10 ,
'default' => 0
2018-03-18 04:28:54 +00:00
);
2020-03-28 13:34:14 +00:00
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2018-03-18 04:28:54 +00:00
}
// if created is not set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.created' ))
2018-03-18 04:28:54 +00:00
{
$attributes = array (
2020-03-28 13:34:14 +00:00
'name' => 'created' ,
'type' => 'calendar' ,
'label' => $langView . '_CREATED_DATE_LABEL' ,
2018-03-18 04:28:54 +00:00
'description' => $langView . '_CREATED_DATE_DESC' ,
2020-03-28 13:34:14 +00:00
'size' => 22 ,
'format' => '%Y-%m-%d %H:%M:%S' ,
'filter' => 'user_utc'
2018-03-18 04:28:54 +00:00
);
$attributes = array_merge ( $attributes , $readOnlyXML );
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: xmlComment (
2022-08-30 15:28:41 +00:00
$fieldSetXML , Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Date Created Field. Type: Calendar (joomla) "
);
2018-03-18 04:28:54 +00:00
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2018-03-18 04:28:54 +00:00
}
// if created_by is not set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.created_by' ))
2018-03-18 04:28:54 +00:00
{
$attributes = array (
2020-03-28 13:34:14 +00:00
'name' => 'created_by' ,
'type' => 'user' ,
'label' => $langView . '_CREATED_BY_LABEL' ,
2018-03-18 04:28:54 +00:00
'description' => $langView . '_CREATED_BY_DESC' ,
);
$attributes = array_merge ( $attributes , $readOnlyXML );
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: xmlComment (
2022-08-30 15:28:41 +00:00
$fieldSetXML , Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " User Created Field. Type: User (joomla) "
);
2018-03-18 04:28:54 +00:00
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2018-03-18 04:28:54 +00:00
}
// if published is not set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.published' ))
2018-03-18 04:28:54 +00:00
{
$attributes = array (
2020-03-28 13:34:14 +00:00
'name' => 'published' ,
'type' => 'list' ,
2018-03-18 04:28:54 +00:00
'label' => 'JSTATUS'
);
$attributes = array_merge ( $attributes , $readOnlyXML );
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: xmlComment (
2022-08-30 15:28:41 +00:00
$fieldSetXML , Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Published Field. Type: List (joomla) "
);
2018-03-18 04:28:54 +00:00
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2020-03-28 13:34:14 +00:00
foreach (
array ( 'JPUBLISHED' => 1 , 'JUNPUBLISHED' => 0 , 'JARCHIVED' => 2 ,
2023-05-02 00:10:55 +00:00
'JTRASHED' => - 2 ) as $text => $value
2020-03-28 13:34:14 +00:00
)
2018-03-18 04:28:54 +00:00
{
$optionXML = $fieldXML -> addChild ( 'option' );
$optionXML -> addAttribute ( 'value' , $value );
$optionXML [] = $text ;
}
}
// if modified is not set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.modified' ))
2018-03-18 04:28:54 +00:00
{
$attributes = array (
2020-03-28 13:34:14 +00:00
'name' => 'modified' ,
'type' => 'calendar' ,
'class' => 'readonly' ,
'label' => $langView . '_MODIFIED_DATE_LABEL' ,
2018-03-18 04:28:54 +00:00
'description' => $langView . '_MODIFIED_DATE_DESC' ,
2020-03-28 13:34:14 +00:00
'size' => 22 ,
'readonly' => " true " ,
'format' => '%Y-%m-%d %H:%M:%S' ,
'filter' => 'user_utc'
);
ComponentbuilderHelper :: xmlComment (
2022-08-30 15:28:41 +00:00
$fieldSetXML , Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Date Modified Field. Type: Calendar (joomla) "
2018-03-18 04:28:54 +00:00
);
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2018-03-18 04:28:54 +00:00
}
// if modified_by is not set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.modified_by' ))
2018-03-18 04:28:54 +00:00
{
$attributes = array (
2020-03-28 13:34:14 +00:00
'name' => 'modified_by' ,
'type' => 'user' ,
'label' => $langView . '_MODIFIED_BY_LABEL' ,
2018-03-18 04:28:54 +00:00
'description' => $langView . '_MODIFIED_BY_DESC' ,
2020-03-28 13:34:14 +00:00
'class' => 'readonly' ,
'readonly' => 'true' ,
'filter' => 'unset'
);
ComponentbuilderHelper :: xmlComment (
2022-08-30 15:28:41 +00:00
$fieldSetXML , Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " User Modified Field. Type: User (joomla) "
2018-03-18 04:28:54 +00:00
);
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2018-03-18 04:28:54 +00:00
}
// check if view has access
2023-05-02 00:10:55 +00:00
if ( CFactory :: _ ( 'Registry' ) -> exists ( 'builder.access_switch.' . $nameSingleCode )
&& ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.access' ))
2018-03-18 04:28:54 +00:00
{
$attributes = array (
2020-03-28 13:34:14 +00:00
'name' => 'access' ,
'type' => 'accesslevel' ,
'label' => 'JFIELD_ACCESS_LABEL' ,
2018-03-18 04:28:54 +00:00
'description' => 'JFIELD_ACCESS_DESC' ,
2020-03-28 13:34:14 +00:00
'default' => 1 ,
'required' => " false "
2018-03-18 04:28:54 +00:00
);
$attributes = array_merge ( $attributes , $readOnlyXML );
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: xmlComment (
2022-08-30 15:28:41 +00:00
$fieldSetXML , Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Access Field. Type: Accesslevel (joomla) "
);
2018-03-18 04:28:54 +00:00
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2018-03-18 04:28:54 +00:00
}
// if ordering is not set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.ordering' ))
2018-03-18 04:28:54 +00:00
{
$attributes = array (
2020-03-28 13:34:14 +00:00
'name' => 'ordering' ,
'type' => 'number' ,
'class' => 'inputbox validate-ordering' ,
'label' => $langView . '_ORDERING_LABEL' ,
2018-03-18 04:28:54 +00:00
'description' => '' ,
2020-03-28 13:34:14 +00:00
'default' => 0 ,
'size' => 6 ,
'required' => " false "
2018-03-18 04:28:54 +00:00
);
$attributes = array_merge ( $attributes , $readOnlyXML );
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: xmlComment (
2022-08-30 15:28:41 +00:00
$fieldSetXML , Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Ordering Field. Type: Numbers (joomla) "
);
2018-03-18 04:28:54 +00:00
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2018-03-18 04:28:54 +00:00
}
// if version is not set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.version' ))
2018-03-18 04:28:54 +00:00
{
$attributes = array (
2020-03-28 13:34:14 +00:00
'name' => 'version' ,
'type' => 'text' ,
'class' => 'readonly' ,
'label' => $langView . '_VERSION_LABEL' ,
2018-03-18 04:28:54 +00:00
'description' => $langView . '_VERSION_DESC' ,
2020-03-28 13:34:14 +00:00
'size' => 6 ,
'readonly' => " true " ,
'filter' => 'unset'
);
ComponentbuilderHelper :: xmlComment (
$fieldSetXML ,
2022-08-30 15:28:41 +00:00
Line :: _ ( __Line__ , __Class__ ) . " Version Field. Type: Text (joomla) "
2018-03-18 04:28:54 +00:00
);
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
2018-03-18 04:28:54 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2018-03-18 04:28:54 +00:00
}
// check if metadata is added to this view
2023-05-02 00:10:55 +00:00
if ( CFactory :: _ ( 'Registry' ) -> isString ( 'builder.meta_data.' . $nameSingleCode ))
2018-03-18 04:28:54 +00:00
{
// metakey
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.metakey' ))
2019-10-11 13:41:00 +00:00
{
$attributes = array (
2020-03-28 13:34:14 +00:00
'name' => 'metakey' ,
'type' => 'textarea' ,
'label' => 'JFIELD_META_KEYWORDS_LABEL' ,
2019-10-11 13:41:00 +00:00
'description' => 'JFIELD_META_KEYWORDS_DESC' ,
2020-03-28 13:34:14 +00:00
'rows' => 3 ,
'cols' => 30
);
ComponentbuilderHelper :: xmlComment (
2022-08-30 15:28:41 +00:00
$fieldSetXML , Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Metakey Field. Type: Textarea (joomla) "
2019-10-11 13:41:00 +00:00
);
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: xmlAddAttributes (
$fieldXML , $attributes
);
2019-10-11 13:41:00 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2019-10-11 13:41:00 +00:00
}
2018-03-18 04:28:54 +00:00
// metadesc
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.metadesc' ))
2019-10-11 13:41:00 +00:00
{
2020-03-28 13:34:14 +00:00
$attributes [ 'name' ] = 'metadesc' ;
$attributes [ 'label' ] = 'JFIELD_META_DESCRIPTION_LABEL' ;
2019-10-11 13:41:00 +00:00
$attributes [ 'description' ] = 'JFIELD_META_DESCRIPTION_DESC' ;
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: xmlComment (
2022-08-30 15:28:41 +00:00
$fieldSetXML , Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Metadesc Field. Type: Textarea (joomla) "
);
2019-10-11 13:41:00 +00:00
$fieldXML = $fieldSetXML -> addChild ( 'field' );
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: xmlAddAttributes (
$fieldXML , $attributes
);
2019-10-11 13:41:00 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2019-10-11 13:41:00 +00:00
}
2018-03-18 04:28:54 +00:00
}
2020-12-24 13:39:33 +00:00
// fix the permissions field "title" issue gh-629
2023-05-16 22:20:41 +00:00
// check if the title is not already set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.title' )
2020-12-24 16:28:07 +00:00
&& $this -> hasPermissionsSet ( $view , $nameSingleCode ))
2020-12-24 13:39:33 +00:00
{
// set the field/tab name
$field_name = " title " ;
$tab_name = " publishing " ;
$attributes = array (
2021-03-04 06:13:05 +00:00
'name' => $field_name ,
'type' => 'hidden' ,
'default' => $component . ' ' . $nameSingleCode
2020-12-24 13:39:33 +00:00
);
ComponentbuilderHelper :: xmlComment (
$fieldSetXML ,
2022-08-30 15:28:41 +00:00
Line :: _ ( __Line__ , __Class__ )
2021-03-04 06:13:05 +00:00
. " Was added due to Permissions JS needing a Title field "
2020-12-24 13:39:33 +00:00
);
ComponentbuilderHelper :: xmlComment (
$fieldSetXML ,
2022-08-30 15:28:41 +00:00
Line :: _ ( __Line__ , __Class__ )
2021-03-04 06:13:05 +00:00
. " Let us know at gh-629 should this change "
2020-12-24 13:39:33 +00:00
);
ComponentbuilderHelper :: xmlComment (
$fieldSetXML ,
2022-08-30 15:28:41 +00:00
Line :: _ ( __Line__ , __Class__ )
2021-03-04 06:13:05 +00:00
. " https://github.com/vdm-io/Joomla-Component-Builder/issues/629#issuecomment-750117235 "
2020-12-24 13:39:33 +00:00
);
$fieldXML = $fieldSetXML -> addChild ( 'field' );
ComponentbuilderHelper :: xmlAddAttributes ( $fieldXML , $attributes );
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2020-12-24 13:39:33 +00:00
// setup needed field values for layout
$field_array = array ();
$field_array [ 'order_edit' ] = 0 ;
$field_array [ 'tab' ] = 15 ;
$field_array [ 'alignment' ] = 1 ;
// make sure it gets added to view
$this -> setLayoutBuilder (
$nameSingleCode , $tab_name , $field_name , $field_array
);
}
2018-03-18 04:28:54 +00:00
// load the dynamic fields now
2019-09-05 21:12:56 +00:00
if ( count (( array ) $dynamicFieldsXML ))
2018-03-18 04:28:54 +00:00
{
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: xmlComment (
2022-08-30 15:28:41 +00:00
$fieldSetXML , Line :: _ ( __Line__ , __Class__ ) . " Dynamic Fields. "
2020-03-28 13:34:14 +00:00
);
2018-03-18 04:28:54 +00:00
foreach ( $dynamicFieldsXML as $dynamicfield )
{
2018-04-08 06:12:18 +00:00
ComponentbuilderHelper :: xmlAppend ( $fieldSetXML , $dynamicfield );
2018-03-18 04:28:54 +00:00
}
}
// check if metadata is added to this view
2023-05-02 00:10:55 +00:00
if ( CFactory :: _ ( 'Registry' ) -> isString ( 'builder.meta_data.' . $nameSingleCode ))
2018-03-18 04:28:54 +00:00
{
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.robots' )
|| ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.author' )
|| ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.rights' ))
2018-03-18 04:28:54 +00:00
{
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: xmlComment (
2022-08-30 15:28:41 +00:00
$fieldSetXML , Line :: _ ( __Line__ , __Class__ ) . " Metadata Fields "
2020-03-28 13:34:14 +00:00
);
2019-10-11 13:41:00 +00:00
$fieldsXML = $fieldSetXML -> addChild ( 'fields' );
$fieldsXML -> addAttribute ( 'name' , 'metadata' );
2020-03-28 13:34:14 +00:00
$fieldsXML -> addAttribute (
'label' , 'JGLOBAL_FIELDSET_METADATA_OPTIONS'
);
2019-10-11 13:41:00 +00:00
$fieldsFieldSetXML = $fieldsXML -> addChild ( 'fieldset' );
$fieldsFieldSetXML -> addAttribute ( 'name' , 'vdmmetadata' );
2020-03-28 13:34:14 +00:00
$fieldsFieldSetXML -> addAttribute (
'label' , 'JGLOBAL_FIELDSET_METADATA_OPTIONS'
);
2019-10-11 13:41:00 +00:00
// robots
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.robots' ))
2019-10-11 13:41:00 +00:00
{
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: xmlComment (
2022-08-30 15:28:41 +00:00
$fieldsFieldSetXML , Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Robots Field. Type: List (joomla) "
);
$robots = $fieldsFieldSetXML -> addChild ( 'field' );
2019-10-11 13:41:00 +00:00
$attributes = array (
2020-03-28 13:34:14 +00:00
'name' => 'robots' ,
'type' => 'list' ,
'label' => 'JFIELD_METADATA_ROBOTS_LABEL' ,
2019-10-11 13:41:00 +00:00
'description' => 'JFIELD_METADATA_ROBOTS_DESC'
);
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: xmlAddAttributes (
$robots , $attributes
);
2019-10-11 13:41:00 +00:00
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2019-10-11 13:41:00 +00:00
$options = array (
2020-03-28 13:34:14 +00:00
'JGLOBAL_USE_GLOBAL' => '' ,
'JGLOBAL_INDEX_FOLLOW' => 'index, follow' ,
'JGLOBAL_NOINDEX_FOLLOW' => 'noindex, follow' ,
'JGLOBAL_INDEX_NOFOLLOW' => 'index, nofollow' ,
2019-10-11 13:41:00 +00:00
'JGLOBAL_NOINDEX_NOFOLLOW' => 'noindex, nofollow' ,
);
foreach ( $options as $text => $value )
{
$option = $robots -> addChild ( 'option' );
$option -> addAttribute ( 'value' , $value );
$option [] = $text ;
}
}
// author
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.author' ))
2019-10-11 13:41:00 +00:00
{
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: xmlComment (
2022-08-30 15:28:41 +00:00
$fieldsFieldSetXML , Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Author Field. Type: Text (joomla) "
);
$author = $fieldsFieldSetXML -> addChild ( 'field' );
2019-10-11 13:41:00 +00:00
$attributes = array (
2020-03-28 13:34:14 +00:00
'name' => 'author' ,
'type' => 'text' ,
'label' => 'JAUTHOR' ,
2019-10-11 13:41:00 +00:00
'description' => 'JFIELD_METADATA_AUTHOR_DESC' ,
2020-03-28 13:34:14 +00:00
'size' => 20
);
ComponentbuilderHelper :: xmlAddAttributes (
$author , $attributes
2019-10-11 13:41:00 +00:00
);
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2019-10-11 13:41:00 +00:00
}
// rights
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.rights' ))
2019-10-11 13:41:00 +00:00
{
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: xmlComment (
2022-08-30 15:28:41 +00:00
$fieldsFieldSetXML , Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Rights Field. Type: Textarea (joomla) "
);
$rights = $fieldsFieldSetXML -> addChild ( 'field' );
2019-10-11 13:41:00 +00:00
$attributes = array (
2020-03-28 13:34:14 +00:00
'name' => 'rights' ,
'type' => 'textarea' ,
'label' => 'JFIELD_META_RIGHTS_LABEL' ,
2019-10-11 13:41:00 +00:00
'description' => 'JFIELD_META_RIGHTS_DESC' ,
2020-03-28 13:34:14 +00:00
'required' => 'false' ,
'filter' => 'string' ,
'cols' => 30 ,
'rows' => 2
);
ComponentbuilderHelper :: xmlAddAttributes (
$rights , $attributes
2019-10-11 13:41:00 +00:00
);
// count the static field created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2019-10-11 13:41:00 +00:00
}
2018-03-18 04:28:54 +00:00
}
}
2020-03-28 13:34:14 +00:00
2018-03-18 04:28:54 +00:00
// return the set
return $this -> xmlPrettyPrint ( $XML , 'fieldset' );
}
2020-12-24 16:28:07 +00:00
/**
* Check to see if a view has permissions
*
* @ param array $view View details
* @ param string $nameSingleCode View Single Code Name
*
* @ return boolean true if it has permisssions
*
*/
protected function hasPermissionsSet ( & $view , & $nameSingleCode )
{
// first check if we have checked this already
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> exists ( 'builder.has_permissions.' . $nameSingleCode ))
2020-12-24 16:28:07 +00:00
{
// when a view has history, it has permissions
// since it tracks the version access
if ( isset ( $view [ 'history' ]) && $view [ 'history' ] == 1 )
{
// set the permission for later
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.has_permissions.' . $nameSingleCode , true );
2021-03-04 06:13:05 +00:00
2020-12-24 16:28:07 +00:00
// break out here
return true ;
}
// check if the view has permissions
if ( isset ( $view [ 'settings' ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-12-25 21:16:34 +00:00
$view [ 'settings' ] -> permissions , true
2020-12-24 16:28:07 +00:00
))
{
foreach ( $view [ 'settings' ] -> permissions as $per )
{
// check if the permission targets the view
// 1 = view
// 3 = both view & component
if ( isset ( $per [ 'implementation' ])
&& (
$per [ 'implementation' ] == 1
|| $per [ 'implementation' ] == 3
))
{
// set the permission for later
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.has_permissions.' . $nameSingleCode , true );
2021-03-04 06:13:05 +00:00
2020-12-24 16:28:07 +00:00
// break out here
return true ;
}
}
}
// check if the fields has permissions
if ( isset ( $view [ 'settings' ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-12-25 21:16:34 +00:00
$view [ 'settings' ] -> fields , true
2020-12-24 16:28:07 +00:00
))
{
foreach ( $view [ 'settings' ] -> fields as $field )
{
// if a field has any permissions
// the a view has permissions
if ( isset ( $field [ 'permission' ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-12-25 21:16:34 +00:00
$field [ 'permission' ], true
2020-12-24 16:28:07 +00:00
))
{
// set the permission for later
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.has_permissions.' . $nameSingleCode , true );
2021-03-04 06:13:05 +00:00
2020-12-24 16:28:07 +00:00
// break out here
return true ;
}
}
}
}
2021-03-04 06:13:05 +00:00
2023-05-02 00:10:55 +00:00
return CFactory :: _ ( 'Registry' ) -> exists ( 'builder.has_permissions.' . $nameSingleCode );
2020-12-24 16:28:07 +00:00
}
2016-06-02 16:18:49 +00:00
/**
* set Field Names
2017-12-03 17:08:01 +00:00
*
2020-03-28 13:34:14 +00:00
* @ param string $view View the field belongs to
* @ param string $name The name of the field
2016-06-02 16:18:49 +00:00
*
2017-12-03 17:08:01 +00:00
*
2016-06-02 16:18:49 +00:00
*/
public function setFieldsNames ( & $view , & $name )
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.field_names.' . $view . '.' . $name , $name );
2016-06-02 16:18:49 +00:00
}
2016-03-01 18:44:13 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* set Dynamic field
2017-12-03 17:08:01 +00:00
*
2020-11-26 17:33:39 +00:00
* @ param array $field The field data
* @ param array $view The view data
* @ param int $viewType The view type
* @ param string $langView The language string of the view
* @ param string $nameSingleCode The single view name
* @ param string $nameListCode The list view name
* @ param array $placeholders The place holder and replace values
* @ param string $dbkey The the custom table key
* @ param boolean $build The switch to set the build option
2016-03-01 18:44:13 +00:00
*
2017-12-03 17:08:01 +00:00
* @ return SimpleXMLElement The complete field in xml
*
2016-03-01 18:44:13 +00:00
*/
2020-03-28 13:34:14 +00:00
public function setDynamicField ( & $field , & $view , & $viewType , & $langView ,
2023-05-02 00:10:55 +00:00
& $nameSingleCode , & $nameListCode , & $placeholders , & $dbkey , $build
2020-03-28 13:34:14 +00:00
) {
2018-03-18 04:28:54 +00:00
// set default return
2022-08-30 15:28:41 +00:00
if ( CFactory :: _ ( 'Config' ) -> get ( 'field_builder_type' , 2 ) == 1 )
2018-03-18 04:28:54 +00:00
{
// string manipulation
$dynamicField = '' ;
}
else
{
// simpleXMLElement class
$dynamicField = false ;
}
// make sure we have settings
2020-03-28 13:34:14 +00:00
if ( isset ( $field [ 'settings' ])
2022-03-09 23:46:45 +00:00
&& ObjectHelper :: check (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ]
))
2016-03-01 18:44:13 +00:00
{
2017-12-03 17:08:01 +00:00
// reset some values
2022-09-10 08:16:44 +00:00
$name = CFactory :: _ ( 'Field.Name' ) -> get ( $field , $nameListCode );
$typeName = CFactory :: _ ( 'Field.Type.Name' ) -> get ( $field );
2020-03-28 13:34:14 +00:00
$multiple = false ;
$langLabel = '' ;
$fieldSet = '' ;
2017-12-03 17:08:01 +00:00
$fieldAttributes = array ();
2016-06-23 15:05:37 +00:00
// set field attributes
2020-03-28 13:34:14 +00:00
$fieldAttributes = $this -> setFieldAttributes (
$field , $viewType , $name , $typeName , $multiple , $langLabel ,
2020-11-26 17:33:39 +00:00
$langView , $nameListCode , $nameSingleCode , $placeholders
2020-03-28 13:34:14 +00:00
);
2016-06-23 15:05:37 +00:00
// check if values were set
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $fieldAttributes ))
2016-03-01 18:44:13 +00:00
{
2016-06-23 15:05:37 +00:00
// set the array of field names
2020-03-28 13:34:14 +00:00
$this -> setFieldsNames (
2020-11-26 17:33:39 +00:00
$nameSingleCode , $fieldAttributes [ 'name' ]
2020-03-28 13:34:14 +00:00
);
2017-12-14 23:10:47 +00:00
2018-05-24 13:56:56 +00:00
if ( ComponentbuilderHelper :: fieldCheck ( $typeName , 'option' ))
2016-03-01 18:44:13 +00:00
{
2016-06-23 15:05:37 +00:00
//reset options array
$optionArray = array ();
// now add to the field set
2020-03-28 13:34:14 +00:00
$dynamicField = $this -> setField (
'option' , $fieldAttributes , $name , $typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode , $placeholders ,
2020-03-28 13:34:14 +00:00
$optionArray
);
2016-06-23 15:05:37 +00:00
if ( $build )
{
// set builders
2020-03-28 13:34:14 +00:00
$this -> setBuilders (
2020-11-26 17:33:39 +00:00
$langLabel , $langView , $nameSingleCode ,
$nameListCode , $name , $view , $field , $typeName ,
2020-03-28 13:34:14 +00:00
$multiple , false , $optionArray
);
2016-06-23 15:05:37 +00:00
}
2016-03-01 18:44:13 +00:00
}
2018-05-24 13:56:56 +00:00
elseif ( ComponentbuilderHelper :: fieldCheck ( $typeName , 'spacer' ))
2016-03-01 18:44:13 +00:00
{
2016-06-23 15:05:37 +00:00
if ( $build )
2016-03-01 18:44:13 +00:00
{
2016-06-23 15:05:37 +00:00
// make sure spacers gets loaded to layout
$tabName = '' ;
2020-03-28 13:34:14 +00:00
if ( isset ( $view [ 'settings' ] -> tabs )
&& isset ( $view [ 'settings' ] -> tabs [( int ) $field [ 'tab' ]]))
2016-06-23 15:05:37 +00:00
{
2020-03-28 13:34:14 +00:00
$tabName
= $view [ 'settings' ] -> tabs [( int ) $field [ 'tab' ]];
2016-06-23 15:05:37 +00:00
}
elseif (( int ) $field [ 'tab' ] == 15 )
{
// set to publishing tab
$tabName = 'publishing' ;
}
2020-03-28 13:34:14 +00:00
$this -> setLayoutBuilder (
2020-11-26 17:33:39 +00:00
$nameSingleCode , $tabName , $name , $field
2020-03-28 13:34:14 +00:00
);
2016-03-01 18:44:13 +00:00
}
2016-06-23 15:05:37 +00:00
// now add to the field set
2020-03-28 13:34:14 +00:00
$dynamicField = $this -> setField (
'spacer' , $fieldAttributes , $name , $typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode , $placeholders ,
2020-03-28 13:34:14 +00:00
$optionArray
);
2016-03-01 18:44:13 +00:00
}
2020-03-28 13:34:14 +00:00
elseif ( ComponentbuilderHelper :: fieldCheck (
$typeName , 'special'
))
2016-03-01 18:44:13 +00:00
{
2017-06-18 07:37:48 +00:00
// set the repeatable field or subform field
if ( $typeName === 'repeatable' || $typeName === 'subform' )
2016-06-23 15:05:37 +00:00
{
if ( $build )
{
// set builders
2020-03-28 13:34:14 +00:00
$this -> setBuilders (
2020-11-26 17:33:39 +00:00
$langLabel , $langView , $nameSingleCode ,
$nameListCode , $name , $view , $field ,
2020-03-28 13:34:14 +00:00
$typeName , $multiple , false
);
2016-06-23 15:05:37 +00:00
}
// now add to the field set
2020-03-28 13:34:14 +00:00
$dynamicField = $this -> setField (
'special' , $fieldAttributes , $name , $typeName ,
2020-11-26 17:33:39 +00:00
$langView , $nameSingleCode , $nameListCode ,
2020-03-28 13:34:14 +00:00
$placeholders , $optionArray
);
2016-06-23 15:05:37 +00:00
}
2016-03-01 18:44:13 +00:00
}
2020-03-28 13:34:14 +00:00
elseif ( isset ( $fieldAttributes [ 'custom' ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$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
2020-03-28 13:34:14 +00:00
$this -> setBuilders (
2020-11-26 17:33:39 +00:00
$langLabel , $langView , $nameSingleCode ,
$nameListCode , $name , $view , $field , $typeName ,
2020-03-28 13:34:14 +00:00
$multiple , $custom
);
2016-03-01 18:44:13 +00:00
}
// now add to the field set
2020-03-28 13:34:14 +00:00
$dynamicField = $this -> setField (
'custom' , $fieldAttributes , $name , $typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode , $placeholders ,
2020-03-28 13:34:14 +00:00
$optionArray , $custom
);
2016-03-01 18:44:13 +00:00
}
2019-07-15 20:03:57 +00:00
else
{
if ( $build )
{
// set builders
2020-03-28 13:34:14 +00:00
$this -> setBuilders (
2020-11-26 17:33:39 +00:00
$langLabel , $langView , $nameSingleCode ,
$nameListCode , $name , $view , $field , $typeName ,
2020-03-28 13:34:14 +00:00
$multiple
);
2019-07-15 20:03:57 +00:00
}
// now add to the field set
2020-03-28 13:34:14 +00:00
$dynamicField = $this -> setField (
'plain' , $fieldAttributes , $name , $typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode , $placeholders ,
2020-03-28 13:34:14 +00:00
$optionArray
);
2019-07-15 20:03:57 +00:00
}
2016-03-01 18:44:13 +00:00
}
}
2020-03-28 13:34:14 +00:00
2018-03-18 04:28:54 +00:00
return $dynamicField ;
2016-03-01 18:44:13 +00:00
}
2020-11-26 17:33:39 +00:00
/**
* build field set
*
* @ param array $fields The fields data
* @ param string $langView The language string of the view
* @ param string $nameSingleCode The single view name
* @ param string $nameListCode The list view name
* @ param array $placeholders The place holder and replace values
* @ param string $dbkey The the custom table key
* @ param boolean $build The switch to set the build option
* @ param int $return_type The return type 1 = string , 2 = array
*
* @ return mix The complete field in xml
*
*/
public function getFieldsetXML ( & $fields , & $langView , & $nameSingleCode ,
2023-05-02 00:10:55 +00:00
& $nameListCode , & $placeholders , & $dbkey , $build = false ,
$return_type = 1
2020-11-26 17:33:39 +00:00
) {
// set some defaults
$view = '' ;
$viewType = 0 ;
// build the fieldset
if ( $return_type == 1 )
{
$fieldset = '' ;
}
else
{
$fieldset = array ();
}
// loop over the fields to build
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $fields ))
2020-11-26 17:33:39 +00:00
{
foreach ( $fields as $field )
{
// get the field
$xmlField = $this -> getFieldXMLString (
$field , $view , $viewType , $langView ,
$nameSingleCode , $nameListCode ,
$placeholders , $dbkey , $build
);
// make sure the xml is set and a string
if ( isset ( $xmlField )
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-11-26 17:33:39 +00:00
$xmlField
))
{
if ( $return_type == 1 )
{
$fieldset .= $xmlField ;
}
else
{
$fieldset [] = $xmlField ;
}
}
}
}
return $fieldset ;
}
/**
* build field string
*
* @ 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 $nameSingleCode The single view name
* @ param string $nameListCode The list view name
* @ param array $placeholders The place holder and replace values
* @ param string $dbkey The the custom table key
* @ param boolean $build The switch to set the build option
*
* @ return string The complete field in xml - string
*
*/
public function getFieldXMLString ( & $field , & $view , & $viewType , & $langView ,
2023-05-02 00:10:55 +00:00
& $nameSingleCode , & $nameListCode , & $placeholders , & $dbkey ,
$build = false
2020-11-26 17:33:39 +00:00
) {
// check the field builder type
$xmlField = '' ;
2022-08-30 15:28:41 +00:00
if ( CFactory :: _ ( 'Config' ) -> get ( 'field_builder_type' , 2 ) == 1 )
2020-11-26 17:33:39 +00:00
{
// string manipulation
$xmlField = $this -> setDynamicField (
$field , $view , $viewType , $langView ,
$nameSingleCode , $nameListCode ,
$placeholders , $dbkey , $build
);
}
else
{
// simpleXMLElement class
$newxmlField = $this -> setDynamicField (
$field , $view , $viewType , $langView ,
$nameSingleCode , $nameListCode ,
$placeholders , $dbkey , $build
);
if ( isset ( $newxmlField -> fieldXML ))
{
$xmlField = dom_import_simplexml (
$newxmlField -> fieldXML
);
2022-08-30 15:28:41 +00:00
$xmlField = PHP_EOL . Indent :: _ ( 2 ) . " <!-- "
. Line :: _ ( __Line__ , __Class__ ) . " "
2020-11-26 17:33:39 +00:00
. $newxmlField -> comment . ' -->' . PHP_EOL
2022-08-30 15:28:41 +00:00
. Indent :: _ ( 1 ) . $this -> xmlPrettyPrint (
2020-11-26 17:33:39 +00:00
$xmlField , 'field'
);
}
}
// return the string
return $xmlField ;
}
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* set a field
*
2020-11-26 17:33:39 +00:00
* @ param string $setType The set of fields type
* @ param array $fieldAttributes The field values
* @ param string $name The field name
* @ param string $typeName The field type
* @ param string $langView The language string of the view
* @ param string $nameSingleCode The single view name
* @ param string $nameListCode The list view name
* @ param array $placeholders The place holder and replace values
* @ param string $optionArray The option bucket array used to set the field options if needed .
* @ param array $custom Used when field is from config
* @ param string $taber The tabs to add in layout ( only in string manipulation )
2018-03-18 04:28:54 +00:00
*
* @ return SimpleXMLElement The field in xml
*
*/
2020-03-28 13:34:14 +00:00
private function setField ( $setType , & $fieldAttributes , & $name , & $typeName ,
2023-05-02 00:10:55 +00:00
& $langView , & $nameSingleCode , & $nameListCode , $placeholders ,
& $optionArray , $custom = null , $taber = ''
2020-03-28 13:34:14 +00:00
) {
2018-03-18 04:52:07 +00:00
// count the dynamic fields created
2023-01-29 20:12:42 +00:00
CFactory :: _ ( 'Utilities.Counter' ) -> field ++ ;
2018-03-18 04:28:54 +00:00
// check what type of field builder to use
2022-08-30 15:28:41 +00:00
if ( CFactory :: _ ( 'Config' ) -> get ( 'field_builder_type' , 2 ) == 1 )
2018-03-18 04:28:54 +00:00
{
// build field set using string manipulation
2020-03-28 13:34:14 +00:00
return $this -> stringSetField (
$setType , $fieldAttributes , $name , $typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode , $placeholders , $optionArray ,
2020-03-28 13:34:14 +00:00
$custom , $taber
);
2018-03-18 04:28:54 +00:00
}
else
{
// build field set with simpleXMLElement class
2020-03-28 13:34:14 +00:00
return $this -> simpleXMLSetField (
$setType , $fieldAttributes , $name , $typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode , $placeholders , $optionArray ,
2020-03-28 13:34:14 +00:00
$custom
);
2018-03-18 04:28:54 +00:00
}
}
/**
* set a field using string manipulation
*
2020-11-26 17:33:39 +00:00
* @ param string $setType The set of fields type
* @ param array $fieldAttributes The field values
* @ param string $name The field name
* @ param string $typeName The field type
* @ param string $langView The language string of the view
* @ param string $nameSingleCode The single view name
* @ param string $nameListCode The list view name
* @ param array $placeholders The place holder and replace values
* @ param string $optionArray The option bucket array used to set the field options if needed .
* @ param array $custom Used when field is from config
* @ param string $taber The tabs to add in layout
2018-03-18 04:28:54 +00:00
*
* @ return SimpleXMLElement The field in xml
*
*/
2020-03-28 13:34:14 +00:00
protected function stringSetField ( $setType , & $fieldAttributes , & $name ,
2023-05-02 00:10:55 +00:00
& $typeName , & $langView , & $nameSingleCode , & $nameListCode ,
$placeholders , & $optionArray , $custom = null , $taber = ''
2020-03-28 13:34:14 +00:00
) {
2018-03-18 04:28:54 +00:00
$field = '' ;
if ( $setType === 'option' )
{
// now add to the field set
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 1 ) . $taber . Indent :: _ ( 1 )
. " <!-- " . Line :: _ ( __Line__ , __Class__ ) . " " . ucfirst ( $name )
2022-03-09 23:46:45 +00:00
. " Field. Type: " . StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$typeName , 'F'
) . " . (joomla) --> " ;
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 1 ) . $taber . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. " <field " ;
2018-03-18 04:28:54 +00:00
$optionSet = '' ;
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. $property . '="' . $value . '"' ;
2018-03-18 04:28:54 +00:00
}
elseif ( $property === 'option' )
{
$optionSet = '' ;
2020-03-28 13:34:14 +00:00
if ( strtolower ( $typeName ) === 'groupedlist'
&& strpos (
2023-01-01 02:11:34 +00:00
( string ) $value , ','
2020-03-28 13:34:14 +00:00
) !== false
2023-01-01 02:11:34 +00:00
&& strpos (( string ) $value , '@@' ) !== false )
2019-07-29 11:30:13 +00:00
{
// reset the group temp arrays
2020-03-28 13:34:14 +00:00
$groups_ = array ();
$grouped_ = array ( 'group' => array (),
2023-05-02 00:10:55 +00:00
'option' => array ());
2020-03-28 13:34:14 +00:00
$order_ = array ();
2019-07-29 11:30:13 +00:00
// mulitpal options
2023-01-01 02:11:34 +00:00
$options = explode ( ',' , ( string ) $value );
2019-07-29 11:30:13 +00:00
foreach ( $options as $option )
{
if ( strpos ( $option , '@@' ) !== false )
{
// set the group label
$valueKeyArray = explode ( '@@' , $option );
if ( count (( array ) $valueKeyArray ) == 2 )
{
2020-03-28 13:34:14 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$valueKeyArray [ 0 ], true
);
2019-07-29 11:30:13 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue ,
2020-03-28 13:34:14 +00:00
$valueKeyArray [ 0 ]
);
2019-07-29 11:30:13 +00:00
// now add group label
2020-03-28 13:34:14 +00:00
$groups_ [ $valueKeyArray [ 1 ]] = PHP_EOL
2022-08-30 15:28:41 +00:00
. Indent :: _ ( 1 ) . $taber . Indent :: _ ( 2 )
2020-03-28 13:34:14 +00:00
. '<group label="' . $langValue . '">' ;
2019-07-29 11:30:13 +00:00
// set order
2020-03-28 13:34:14 +00:00
$order_ [ 'group' . $valueKeyArray [ 1 ]]
= $valueKeyArray [ 1 ];
2019-07-29 11:30:13 +00:00
}
}
elseif ( strpos ( $option , '|' ) !== false )
{
// has other value then text
$valueKeyArray = explode ( '|' , $option );
if ( count (( array ) $valueKeyArray ) == 3 )
{
2020-03-28 13:34:14 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$valueKeyArray [ 1 ], true
);
2019-07-29 11:30:13 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue ,
2020-03-28 13:34:14 +00:00
$valueKeyArray [ 1 ]
);
2019-07-29 11:30:13 +00:00
// now add to option set
2020-03-28 13:34:14 +00:00
$grouped_ [ 'group' ][ $valueKeyArray [ 2 ]][]
2022-08-30 15:28:41 +00:00
= PHP_EOL . Indent :: _ ( 1 ) . $taber
. Indent :: _ ( 3 ) . '<option value="'
2020-03-28 13:34:14 +00:00
. $valueKeyArray [ 0 ] . '">' . PHP_EOL
2022-08-30 15:28:41 +00:00
. Indent :: _ ( 1 ) . $taber . Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. $langValue . '</option>' ;
$optionArray [ $valueKeyArray [ 0 ]]
= $langValue ;
2019-07-29 11:30:13 +00:00
// set order
2020-03-28 13:34:14 +00:00
$order_ [ 'group' . $valueKeyArray [ 2 ]]
= $valueKeyArray [ 2 ];
2019-07-29 11:30:13 +00:00
}
else
{
2020-03-28 13:34:14 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$valueKeyArray [ 1 ], true
);
2019-07-29 11:30:13 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue ,
2020-03-28 13:34:14 +00:00
$valueKeyArray [ 1 ]
);
2019-07-29 11:30:13 +00:00
// now add to option set
2020-03-28 13:34:14 +00:00
$grouped_ [ 'option' ][ $valueKeyArray [ 0 ]]
2022-08-30 15:28:41 +00:00
= PHP_EOL . Indent :: _ ( 1 ) . $taber
. Indent :: _ ( 2 ) . '<option value="'
2020-03-28 13:34:14 +00:00
. $valueKeyArray [ 0 ] . '">' . PHP_EOL
2022-08-30 15:28:41 +00:00
. Indent :: _ ( 1 ) . $taber . Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. $langValue . '</option>' ;
$optionArray [ $valueKeyArray [ 0 ]]
= $langValue ;
2019-07-29 11:30:13 +00:00
// set order
2020-03-28 13:34:14 +00:00
$order_ [ 'option' . $valueKeyArray [ 0 ]]
= $valueKeyArray [ 0 ];
2019-07-29 11:30:13 +00:00
}
}
else
{
// text is also the value
2020-03-28 13:34:14 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$option , true
);
2019-07-29 11:30:13 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $option
2020-03-28 13:34:14 +00:00
);
2019-07-29 11:30:13 +00:00
// now add to option set
2020-03-28 13:34:14 +00:00
$grouped_ [ 'option' ][ $option ] = PHP_EOL
2022-08-30 15:28:41 +00:00
. Indent :: _ ( 1 ) . $taber . Indent :: _ ( 2 )
2020-03-28 13:34:14 +00:00
. '<option value="' . $option . '">'
2022-08-30 15:28:41 +00:00
. PHP_EOL . Indent :: _ ( 1 ) . $taber
. Indent :: _ ( 3 ) . $langValue . '</option>' ;
2020-03-28 13:34:14 +00:00
$optionArray [ $option ] = $langValue ;
2019-07-29 11:30:13 +00:00
// set order
$order_ [ 'option' . $option ] = $option ;
}
}
// now build the groups
foreach ( $order_ as $pointer_ => $_id )
{
// load the default key
$key_ = 'group' ;
if ( strpos ( $pointer_ , 'option' ) !== false )
{
// load the option field
$key_ = 'option' ;
}
// check if this is a group loader
2020-03-28 13:34:14 +00:00
if ( 'group' === $key_ && isset ( $groups_ [ $_id ])
&& isset ( $grouped_ [ $key_ ][ $_id ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$grouped_ [ $key_ ][ $_id ]
))
2019-07-29 11:30:13 +00:00
{
// set group label
$optionSet .= $groups_ [ $_id ];
foreach ( $grouped_ [ $key_ ][ $_id ] as $option_ )
{
$optionSet .= $option_ ;
}
unset ( $groups_ [ $_id ]);
unset ( $grouped_ [ $key_ ][ $_id ]);
// close the group
2022-08-30 15:28:41 +00:00
$optionSet .= PHP_EOL . Indent :: _ ( 1 ) . $taber
. Indent :: _ ( 2 ) . '</group>' ;
2019-07-29 11:30:13 +00:00
}
2020-03-28 13:34:14 +00:00
elseif ( isset ( $grouped_ [ $key_ ][ $_id ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$grouped_ [ $key_ ][ $_id ]
))
2019-07-29 11:30:13 +00:00
{
$optionSet .= $grouped_ [ $key_ ][ $_id ];
}
}
}
2023-01-01 02:11:34 +00:00
elseif ( strpos (( string ) $value , ',' ) !== false )
2018-03-18 04:28:54 +00:00
{
// mulitpal options
2023-01-01 02:11:34 +00:00
$options = explode ( ',' , ( string ) $value );
2018-03-18 04:28:54 +00:00
foreach ( $options as $option )
{
if ( strpos ( $option , '|' ) !== false )
{
// has other value then text
list ( $v , $t ) = explode ( '|' , $option );
2020-03-28 13:34:14 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$t , true
);
2018-03-18 04:28:54 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $t
2020-03-28 13:34:14 +00:00
);
2019-07-29 11:30:13 +00:00
// now add to option set
2022-08-30 15:28:41 +00:00
$optionSet .= PHP_EOL . Indent :: _ ( 1 )
. $taber . Indent :: _ ( 2 ) . '<option value="'
. $v . '">' . PHP_EOL . Indent :: _ ( 1 )
. $taber . Indent :: _ ( 3 ) . $langValue
2020-03-28 13:34:14 +00:00
. '</option>' ;
2018-03-18 04:28:54 +00:00
$optionArray [ $v ] = $langValue ;
}
else
{
// text is also the value
2020-03-28 13:34:14 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$option , true
);
2018-03-18 04:28:54 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $option
2020-03-28 13:34:14 +00:00
);
2019-07-29 11:30:13 +00:00
// now add to option set
2022-08-30 15:28:41 +00:00
$optionSet .= PHP_EOL . Indent :: _ ( 2 )
. $taber . Indent :: _ ( 1 ) . '<option value="'
. $option . '">' . PHP_EOL . Indent :: _ ( 2 )
. $taber . Indent :: _ ( 2 ) . $langValue
2020-03-28 13:34:14 +00:00
. '</option>' ;
2018-03-18 04:28:54 +00:00
$optionArray [ $option ] = $langValue ;
}
}
}
else
{
// one option
2023-01-01 02:11:34 +00:00
if ( strpos (( string ) $value , '|' ) !== false )
2018-03-18 04:28:54 +00:00
{
// has other value then text
2023-01-01 02:11:34 +00:00
list ( $v , $t ) = explode ( '|' , ( string ) $value );
2020-03-28 13:34:14 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$t , true
);
2018-03-18 04:28:54 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set ( CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $t );
2019-07-29 11:30:13 +00:00
// now add to option set
2022-08-30 15:28:41 +00:00
$optionSet .= PHP_EOL . Indent :: _ ( 2 ) . $taber
. Indent :: _ ( 1 ) . '<option value="' . $v . '">'
. PHP_EOL . Indent :: _ ( 2 ) . $taber . Indent :: _ ( 2 )
2020-03-28 13:34:14 +00:00
. $langValue . '</option>' ;
2018-03-18 04:28:54 +00:00
$optionArray [ $v ] = $langValue ;
}
else
{
// text is also the value
2020-03-28 13:34:14 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$value , true
);
2018-03-18 04:28:54 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $value
2020-03-28 13:34:14 +00:00
);
2019-07-29 11:30:13 +00:00
// now add to option set
2022-08-30 15:28:41 +00:00
$optionSet .= PHP_EOL . Indent :: _ ( 2 )
. $taber . Indent :: _ ( 1 ) . '<option value="'
. $value . '">' . PHP_EOL . Indent :: _ ( 2 )
. $taber . Indent :: _ ( 2 ) . $langValue
2020-03-28 13:34:14 +00:00
. '</option>' ;
2018-03-18 04:28:54 +00:00
$optionArray [ $value ] = $langValue ;
}
}
}
}
2019-03-05 07:51:52 +00:00
// if options were found
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $optionSet ))
2018-03-18 04:28:54 +00:00
{
$field .= '>' ;
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 3 ) . $taber . " <!-- "
. Line :: _ ( __Line__ , __Class__ ) . " Option Set. --> " ;
2018-03-18 04:28:54 +00:00
$field .= $optionSet ;
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . " </field> " ;
2018-03-18 04:28:54 +00:00
}
2019-03-05 07:51:52 +00:00
// if no options found and must have a list of options
elseif ( ComponentbuilderHelper :: fieldCheck ( $typeName , 'list' ))
2018-03-18 04:28:54 +00:00
{
$optionArray = false ;
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . " /> " ;
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . " <!-- "
. Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " No Manual Options Were Added In Field Settings. --> "
. PHP_EOL ;
2018-03-18 04:28:54 +00:00
}
else
{
$optionArray = false ;
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . " /> " ;
2018-03-18 04:28:54 +00:00
}
}
elseif ( $setType === 'plain' )
{
// now add to the field set
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . " <!-- " . Line :: _ (
__LINE__ , __CLASS__
2020-03-28 13:34:14 +00:00
) . " " . ucfirst ( $name ) . " Field. Type: "
2022-03-09 23:46:45 +00:00
. StringHelper :: safe ( $typeName , 'F' )
2020-03-28 13:34:14 +00:00
. " . (joomla) --> " ;
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . " <field " ;
2018-03-18 04:28:54 +00:00
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. $property . '="' . $value . '"' ;
2018-03-18 04:28:54 +00:00
}
}
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . " /> " ;
2018-03-18 04:28:54 +00:00
}
elseif ( $setType === 'spacer' )
{
// now add to the field set
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . " <!-- " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " " . ucfirst ( $name ) . " Field. Type: "
2022-03-09 23:46:45 +00:00
. StringHelper :: safe ( $typeName , 'F' )
2020-03-28 13:34:14 +00:00
. " . A None Database Field. (joomla) --> " ;
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . " <field " ;
2018-03-18 04:28:54 +00:00
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
$field .= " " . $property . '="' . $value . '"' ;
}
}
$field .= " /> " ;
}
elseif ( $setType === 'special' )
{
// set the repeatable field
if ( $typeName === 'repeatable' )
{
// now add to the field set
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . " <!-- " . Line :: _ (
__LINE__ , __CLASS__
2020-03-28 13:34:14 +00:00
) . " " . ucfirst ( $name ) . " Field. Type: "
2022-03-09 23:46:45 +00:00
. StringHelper :: safe ( $typeName , 'F' )
2020-03-28 13:34:14 +00:00
. " . (joomla) --> " ;
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . " <field " ;
2018-03-18 04:28:54 +00:00
$fieldsSet = array ();
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'fields' )
{
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 3 ) . $property . '="'
2020-03-28 13:34:14 +00:00
. $value . '"' ;
2018-03-18 04:28:54 +00:00
}
}
$field .= " > " ;
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 3 ) . '<fields name="'
2020-03-28 13:34:14 +00:00
. $fieldAttributes [ 'name' ] . '_fields" label="">' ;
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. '<fieldset hidden="true" name="'
. $fieldAttributes [ 'name' ] . '_modal" repeat="true">' ;
2023-01-01 02:11:34 +00:00
if ( strpos (( string ) $fieldAttributes [ 'fields' ], ',' ) !== false )
2018-03-18 04:28:54 +00:00
{
// mulitpal fields
2020-03-28 13:34:14 +00:00
$fieldsSets = ( array ) explode (
2023-01-01 02:11:34 +00:00
',' , ( string ) $fieldAttributes [ 'fields' ]
2020-03-28 13:34:14 +00:00
);
2018-03-18 04:28:54 +00:00
}
elseif ( is_numeric ( $fieldAttributes [ 'fields' ]))
{
// single field
$fieldsSets [] = ( int ) $fieldAttributes [ 'fields' ];
}
// only continue if we have a field set
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $fieldsSets ))
2018-03-18 04:28:54 +00:00
{
2018-10-01 02:16:24 +00:00
// set the resolver
$_resolverKey = $fieldAttributes [ 'name' ];
// load the field data
2020-03-28 13:34:14 +00:00
$fieldsSets = array_map (
function ( $id ) use (
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode , $_resolverKey
2020-03-28 13:34:14 +00:00
) {
// start field
$field = array ();
$field [ 'field' ] = $id ;
// set the field details
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Field' ) -> set (
2020-11-26 17:33:39 +00:00
$field , $nameSingleCode , $nameListCode ,
2020-03-28 13:34:14 +00:00
$_resolverKey
);
// return field
return $field ;
}, array_values ( $fieldsSets )
);
2018-10-01 02:16:24 +00:00
// start the build
foreach ( $fieldsSets as $fieldData )
2018-03-18 04:28:54 +00:00
{
2018-10-01 02:16:24 +00:00
// if we have settings continue
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check (
2020-03-28 13:34:14 +00:00
$fieldData [ 'settings' ]
))
2018-03-18 04:28:54 +00:00
{
2022-09-10 08:16:44 +00:00
$r_name = CFactory :: _ ( 'Field.Name' ) -> get (
2020-11-26 17:33:39 +00:00
$fieldData , $nameListCode , $_resolverKey
2020-03-28 13:34:14 +00:00
);
2022-09-10 08:16:44 +00:00
$r_typeName = CFactory :: _ ( 'Field.Type.Name' ) -> get ( $fieldData );
2020-03-28 13:34:14 +00:00
$r_multiple = false ;
2018-03-18 04:28:54 +00:00
$r_langLabel = '' ;
// add the tabs needed
2022-08-30 15:28:41 +00:00
$r_taber = Indent :: _ ( 3 );
2018-03-18 04:28:54 +00:00
// get field values
2020-03-28 13:34:14 +00:00
$r_fieldValues = $this -> setFieldAttributes (
$fieldData , $view , $r_name , $r_typeName ,
$r_multiple , $r_langLabel , $langView ,
2020-11-26 17:33:39 +00:00
$nameListCode , $nameSingleCode ,
2020-03-28 13:34:14 +00:00
$placeholders , true
);
2018-03-18 04:28:54 +00:00
// check if values were set
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$r_fieldValues
))
2018-03-18 04:28:54 +00:00
{
//reset options array
$r_optionArray = array ();
2020-03-28 13:34:14 +00:00
if ( ComponentbuilderHelper :: fieldCheck (
$r_typeName , 'option'
))
2018-03-18 04:28:54 +00:00
{
// now add to the field set
2020-03-28 13:34:14 +00:00
$field .= $this -> setField (
'option' , $r_fieldValues , $r_name ,
$r_typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode ,
2020-03-28 13:34:14 +00:00
$placeholders , $r_optionArray , null ,
$r_taber
);
2018-03-18 04:28:54 +00:00
}
2020-03-28 13:34:14 +00:00
elseif ( isset ( $r_fieldValues [ 'custom' ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$r_fieldValues [ 'custom' ]
))
2018-03-18 04:28:54 +00:00
{
// add to custom
$custom = $r_fieldValues [ 'custom' ];
unset ( $r_fieldValues [ 'custom' ]);
// now add to the field set
2020-03-28 13:34:14 +00:00
$field .= $this -> setField (
'custom' , $r_fieldValues , $r_name ,
$r_typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode ,
2020-03-28 13:34:14 +00:00
$placeholders , $r_optionArray , null ,
$r_taber
);
2018-03-18 04:28:54 +00:00
// set lang (just incase)
2020-03-28 13:34:14 +00:00
$r_listLangName = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$r_name , true
);
2018-03-18 04:28:54 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $r_listLangName ,
2022-03-09 23:46:45 +00:00
StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$r_name , 'W'
)
);
2018-03-18 04:28:54 +00:00
// if label was set use instead
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check (
2020-03-28 13:34:14 +00:00
$r_langLabel
))
2018-03-18 04:28:54 +00:00
{
$r_listLangName = $r_langLabel ;
}
// set the custom array
2020-03-28 13:34:14 +00:00
$data = array ( 'type' => $r_typeName ,
2023-05-02 00:10:55 +00:00
'code' => $r_name ,
'lang' => $r_listLangName ,
'custom' => $custom );
2018-03-18 04:28:54 +00:00
// set the custom field file
2020-03-28 13:34:14 +00:00
$this -> setCustomFieldTypeFile (
2020-11-26 17:33:39 +00:00
$data , $nameListCode ,
$nameSingleCode
2020-03-28 13:34:14 +00:00
);
2018-03-18 04:28:54 +00:00
}
2019-07-19 02:17:15 +00:00
else
{
// now add to the field set
2020-03-28 13:34:14 +00:00
$field .= $this -> setField (
'plain' , $r_fieldValues , $r_name ,
$r_typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode ,
2020-03-28 13:34:14 +00:00
$placeholders , $r_optionArray , null ,
$r_taber
);
2019-07-19 02:17:15 +00:00
}
2018-03-18 04:28:54 +00:00
}
}
}
}
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 4 ) . " </fieldset> " ;
$field .= PHP_EOL . Indent :: _ ( 3 ) . " </fields> " ;
$field .= PHP_EOL . Indent :: _ ( 2 ) . " </field> " ;
2018-03-18 04:28:54 +00:00
}
// set the subform fields (it is a repeatable without the modal)
elseif ( $typeName === 'subform' )
{
// now add to the field set
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . " <!-- "
. Line :: _ ( __Line__ , __Class__ ) . " " . ucfirst ( $name )
2022-03-09 23:46:45 +00:00
. " Field. Type: " . StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$typeName , 'F'
) . " . (joomla) --> " ;
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . " <field " ;
2018-03-18 04:28:54 +00:00
$fieldsSet = array ();
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'fields' )
{
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 3 ) . $taber . $property
2020-03-28 13:34:14 +00:00
. '="' . $value . '"' ;
2018-03-18 04:28:54 +00:00
}
}
$field .= " > " ;
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 3 ) . $taber
2020-03-28 13:34:14 +00:00
. '<form hidden="true" name="list_'
. $fieldAttributes [ 'name' ] . '_modal" repeat="true">' ;
2023-01-01 02:11:34 +00:00
if ( strpos (( string ) $fieldAttributes [ 'fields' ], ',' ) !== false )
2018-03-18 04:28:54 +00:00
{
// mulitpal fields
2020-03-28 13:34:14 +00:00
$fieldsSets = ( array ) explode (
2023-01-01 02:11:34 +00:00
',' , ( string ) $fieldAttributes [ 'fields' ]
2020-03-28 13:34:14 +00:00
);
2018-03-18 04:28:54 +00:00
}
elseif ( is_numeric ( $fieldAttributes [ 'fields' ]))
{
// single field
$fieldsSets [] = ( int ) $fieldAttributes [ 'fields' ];
}
// only continue if we have a field set
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $fieldsSets ))
2018-03-18 04:28:54 +00:00
{
2018-10-01 02:16:24 +00:00
// set the resolver
$_resolverKey = $fieldAttributes [ 'name' ];
// load the field data
2020-03-28 13:34:14 +00:00
$fieldsSets = array_map (
function ( $id ) use (
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode , $_resolverKey
2020-03-28 13:34:14 +00:00
) {
// start field
$field = array ();
$field [ 'field' ] = $id ;
// set the field details
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Field' ) -> set (
2020-11-26 17:33:39 +00:00
$field , $nameSingleCode , $nameListCode ,
2020-03-28 13:34:14 +00:00
$_resolverKey
);
// return field
return $field ;
}, array_values ( $fieldsSets )
);
2018-10-01 02:16:24 +00:00
// start the build
foreach ( $fieldsSets as $fieldData )
2018-03-18 04:28:54 +00:00
{
2018-10-01 02:16:24 +00:00
// if we have settings continue
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check (
2020-03-28 13:34:14 +00:00
$fieldData [ 'settings' ]
))
2018-03-18 04:28:54 +00:00
{
2022-09-10 08:16:44 +00:00
$r_name = CFactory :: _ ( 'Field.Name' ) -> get (
2020-11-26 17:33:39 +00:00
$fieldData , $nameListCode , $_resolverKey
2020-03-28 13:34:14 +00:00
);
2022-09-10 08:16:44 +00:00
$r_typeName = CFactory :: _ ( 'Field.Type.Name' ) -> get ( $fieldData );
2020-03-28 13:34:14 +00:00
$r_multiple = false ;
2018-03-18 04:28:54 +00:00
$r_langLabel = '' ;
// add the tabs needed
2022-08-30 15:28:41 +00:00
$r_taber = Indent :: _ ( 2 ) . $taber ;
2018-03-18 04:28:54 +00:00
// get field values
2020-03-28 13:34:14 +00:00
$r_fieldValues = $this -> setFieldAttributes (
$fieldData , $view , $r_name , $r_typeName ,
$r_multiple , $r_langLabel , $langView ,
2020-11-26 17:33:39 +00:00
$nameListCode , $nameSingleCode ,
2020-03-28 13:34:14 +00:00
$placeholders , true
);
2018-03-18 04:28:54 +00:00
// check if values were set
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$r_fieldValues
))
2018-03-18 04:28:54 +00:00
{
//reset options array
$r_optionArray = array ();
2020-03-28 13:34:14 +00:00
if ( ComponentbuilderHelper :: fieldCheck (
$r_typeName , 'option'
))
2018-03-18 04:28:54 +00:00
{
// now add to the field set
2020-03-28 13:34:14 +00:00
$field .= $this -> setField (
'option' , $r_fieldValues , $r_name ,
$r_typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode ,
2020-03-28 13:34:14 +00:00
$placeholders , $r_optionArray , null ,
$r_taber
);
2018-03-18 04:28:54 +00:00
}
2019-01-14 15:32:23 +00:00
elseif ( $r_typeName === 'subform' )
{
// set nested depth
if ( isset ( $fieldAttributes [ 'nested_depth' ]))
{
2020-03-28 13:34:14 +00:00
$r_fieldValues [ 'nested_depth' ]
= ++ $fieldAttributes [ 'nested_depth' ];
2019-01-14 15:32:23 +00:00
}
else
{
$r_fieldValues [ 'nested_depth' ] = 1 ;
}
// only continue if nest is bellow 20 (this should be a safe limit)
if ( $r_fieldValues [ 'nested_depth' ] <= 20 )
{
// now add to the field set
2020-03-28 13:34:14 +00:00
$field .= $this -> setField (
'special' , $r_fieldValues , $r_name ,
$r_typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode ,
2020-03-28 13:34:14 +00:00
$placeholders , $r_optionArray , null ,
$r_taber
);
2019-01-14 15:32:23 +00:00
}
}
2020-03-28 13:34:14 +00:00
elseif ( isset ( $r_fieldValues [ 'custom' ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$r_fieldValues [ 'custom' ]
))
2018-03-18 04:28:54 +00:00
{
// add to custom
$custom = $r_fieldValues [ 'custom' ];
unset ( $r_fieldValues [ 'custom' ]);
// now add to the field set
2020-03-28 13:34:14 +00:00
$field .= $this -> setField (
'custom' , $r_fieldValues , $r_name ,
$r_typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode ,
2020-03-28 13:34:14 +00:00
$placeholders , $r_optionArray , null ,
$r_taber
);
2018-03-18 04:28:54 +00:00
// set lang (just incase)
2020-03-28 13:34:14 +00:00
$r_listLangName = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$r_name , true
);
2018-03-18 04:28:54 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $r_listLangName ,
2022-03-09 23:46:45 +00:00
StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$r_name , 'W'
)
);
2018-03-18 04:28:54 +00:00
// if label was set use instead
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check (
2020-03-28 13:34:14 +00:00
$r_langLabel
))
2018-03-18 04:28:54 +00:00
{
$r_listLangName = $r_langLabel ;
}
// set the custom array
2020-03-28 13:34:14 +00:00
$data = array ( 'type' => $r_typeName ,
2023-05-02 00:10:55 +00:00
'code' => $r_name ,
'lang' => $r_listLangName ,
'custom' => $custom );
2018-03-18 04:28:54 +00:00
// set the custom field file
2020-03-28 13:34:14 +00:00
$this -> setCustomFieldTypeFile (
2020-11-26 17:33:39 +00:00
$data , $nameListCode ,
$nameSingleCode
2020-03-28 13:34:14 +00:00
);
2018-03-18 04:28:54 +00:00
}
2019-07-19 02:17:15 +00:00
else
{
// now add to the field set
2020-03-28 13:34:14 +00:00
$field .= $this -> setField (
'plain' , $r_fieldValues , $r_name ,
$r_typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode ,
2020-03-28 13:34:14 +00:00
$placeholders , $r_optionArray , null ,
$r_taber
);
2019-07-19 02:17:15 +00:00
}
2018-03-18 04:28:54 +00:00
}
}
}
}
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 3 ) . $taber . " </form> " ;
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . " </field> " ;
2018-03-18 04:28:54 +00:00
}
}
elseif ( $setType === 'custom' )
{
// now add to the field set
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . " <!-- "
. Line :: _ (
__LINE__ , __CLASS__
2020-03-28 13:34:14 +00:00
) . " " . ucfirst ( $name ) . " Field. Type: "
2022-03-09 23:46:45 +00:00
. StringHelper :: safe ( $typeName , 'F' )
2020-03-28 13:34:14 +00:00
. " . (custom) --> " ;
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . " <field " ;
2020-07-07 15:13:04 +00:00
$optionSet = '' ;
2018-03-18 04:28:54 +00:00
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. $property . '="' . $value . '"' ;
2018-03-18 04:28:54 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $property === 'option' )
2016-03-01 18:44:13 +00:00
{
2020-07-07 15:13:04 +00:00
$optionSet = '' ;
2020-03-28 13:34:14 +00:00
if ( strtolower ( $typeName ) === 'groupedlist'
&& strpos (
2023-01-01 02:11:34 +00:00
( string ) $value , ','
2020-03-28 13:34:14 +00:00
) !== false
2023-01-01 02:11:34 +00:00
&& strpos (( string ) $value , '@@' ) !== false )
2019-07-29 11:30:13 +00:00
{
// reset the group temp arrays
2020-03-28 13:34:14 +00:00
$groups_ = array ();
$grouped_ = array ( 'group' => array (),
2023-05-02 00:10:55 +00:00
'option' => array ());
2020-03-28 13:34:14 +00:00
$order_ = array ();
2019-07-29 11:30:13 +00:00
// mulitpal options
2023-01-01 02:11:34 +00:00
$options = explode ( ',' , ( string ) $value );
2019-07-29 11:30:13 +00:00
foreach ( $options as $option )
{
if ( strpos ( $option , '@@' ) !== false )
{
// set the group label
$valueKeyArray = explode ( '@@' , $option );
if ( count (( array ) $valueKeyArray ) == 2 )
{
2020-03-28 13:34:14 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$valueKeyArray [ 0 ], true
);
2019-07-29 11:30:13 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue ,
2020-03-28 13:34:14 +00:00
$valueKeyArray [ 0 ]
);
2019-07-29 11:30:13 +00:00
// now add group label
2020-07-07 15:13:04 +00:00
$groups_ [ $valueKeyArray [ 1 ]] = PHP_EOL
2022-08-30 15:28:41 +00:00
. Indent :: _ ( 1 ) . $taber . Indent :: _ ( 2 )
2020-07-07 15:13:04 +00:00
. '<group label="' . $langValue . '">' ;
2019-07-29 11:30:13 +00:00
// set order
2020-03-28 13:34:14 +00:00
$order_ [ 'group' . $valueKeyArray [ 1 ]]
= $valueKeyArray [ 1 ];
2019-07-29 11:30:13 +00:00
}
}
elseif ( strpos ( $option , '|' ) !== false )
{
// has other value then text
$valueKeyArray = explode ( '|' , $option );
if ( count (( array ) $valueKeyArray ) == 3 )
{
2020-03-28 13:34:14 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$valueKeyArray [ 1 ], true
);
2019-07-29 11:30:13 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue ,
2020-03-28 13:34:14 +00:00
$valueKeyArray [ 1 ]
);
2019-07-29 11:30:13 +00:00
// now add to option set
2020-03-28 13:34:14 +00:00
$grouped_ [ 'group' ][ $valueKeyArray [ 2 ]][]
2022-08-30 15:28:41 +00:00
= PHP_EOL . Indent :: _ ( 1 ) . $taber
. Indent :: _ ( 3 ) . '<option value="'
2020-07-07 15:13:04 +00:00
. $valueKeyArray [ 0 ] . '">' . PHP_EOL
2022-08-30 15:28:41 +00:00
. Indent :: _ ( 1 ) . $taber . Indent :: _ ( 4 )
2020-07-07 15:13:04 +00:00
. $langValue . '</option>' ;
2020-03-28 13:34:14 +00:00
$optionArray [ $valueKeyArray [ 0 ]]
= $langValue ;
2019-07-29 11:30:13 +00:00
// set order
2020-03-28 13:34:14 +00:00
$order_ [ 'group' . $valueKeyArray [ 2 ]]
= $valueKeyArray [ 2 ];
2019-07-29 11:30:13 +00:00
}
else
{
2020-03-28 13:34:14 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$valueKeyArray [ 1 ], true
);
2019-07-29 11:30:13 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue ,
2020-03-28 13:34:14 +00:00
$valueKeyArray [ 1 ]
);
2019-07-29 11:30:13 +00:00
// now add to option set
2020-03-28 13:34:14 +00:00
$grouped_ [ 'option' ][ $valueKeyArray [ 0 ]]
2022-08-30 15:28:41 +00:00
= PHP_EOL . Indent :: _ ( 1 ) . $taber
. Indent :: _ ( 2 ) . '<option value="'
2020-07-07 15:13:04 +00:00
. $valueKeyArray [ 0 ] . '">' . PHP_EOL
2022-08-30 15:28:41 +00:00
. Indent :: _ ( 1 ) . $taber . Indent :: _ ( 3 )
2020-07-07 15:13:04 +00:00
. $langValue . '</option>' ;
2020-03-28 13:34:14 +00:00
$optionArray [ $valueKeyArray [ 0 ]]
= $langValue ;
2019-07-29 11:30:13 +00:00
// set order
2020-03-28 13:34:14 +00:00
$order_ [ 'option' . $valueKeyArray [ 0 ]]
= $valueKeyArray [ 0 ];
2019-07-29 11:30:13 +00:00
}
}
else
{
// text is also the value
2020-03-28 13:34:14 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$option , true
);
2019-07-29 11:30:13 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $option
2020-03-28 13:34:14 +00:00
);
2019-07-29 11:30:13 +00:00
// now add to option set
2020-07-07 15:13:04 +00:00
$grouped_ [ 'option' ][ $option ] = PHP_EOL
2022-08-30 15:28:41 +00:00
. Indent :: _ ( 1 ) . $taber . Indent :: _ ( 2 )
2020-07-07 15:13:04 +00:00
. '<option value="' . $option . '">'
2022-08-30 15:28:41 +00:00
. PHP_EOL . Indent :: _ ( 1 ) . $taber
. Indent :: _ ( 3 ) . $langValue . '</option>' ;
2020-07-07 15:13:04 +00:00
$optionArray [ $option ] = $langValue ;
2019-07-29 11:30:13 +00:00
// set order
$order_ [ 'option' . $option ] = $option ;
}
}
// now build the groups
foreach ( $order_ as $pointer_ => $_id )
{
// load the default key
$key_ = 'group' ;
if ( strpos ( $pointer_ , 'option' ) !== false )
{
// load the option field
$key_ = 'option' ;
}
// check if this is a group loader
2020-03-28 13:34:14 +00:00
if ( 'group' === $key_ && isset ( $groups_ [ $_id ])
&& isset ( $grouped_ [ $key_ ][ $_id ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$grouped_ [ $key_ ][ $_id ]
))
2019-07-29 11:30:13 +00:00
{
// set group label
2020-07-07 15:13:04 +00:00
$optionSet .= $groups_ [ $_id ];
2019-07-29 11:30:13 +00:00
foreach ( $grouped_ [ $key_ ][ $_id ] as $option_ )
{
2020-07-07 15:13:04 +00:00
$optionSet .= $option_ ;
2019-07-29 11:30:13 +00:00
}
unset ( $groups_ [ $_id ]);
unset ( $grouped_ [ $key_ ][ $_id ]);
2020-07-07 15:13:04 +00:00
// close the group
2022-08-30 15:28:41 +00:00
$optionSet .= PHP_EOL . Indent :: _ ( 1 ) . $taber
. Indent :: _ ( 2 ) . '</group>' ;
2019-07-29 11:30:13 +00:00
}
2020-03-28 13:34:14 +00:00
elseif ( isset ( $grouped_ [ $key_ ][ $_id ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$grouped_ [ $key_ ][ $_id ]
))
2019-07-29 11:30:13 +00:00
{
2020-07-07 15:13:04 +00:00
$optionSet .= $grouped_ [ $key_ ][ $_id ];
2019-07-29 11:30:13 +00:00
}
}
}
2023-01-01 02:11:34 +00:00
elseif ( strpos (( string ) $value , ',' ) !== false )
2016-03-01 18:44:13 +00:00
{
// mulitpal options
2023-01-01 02:11:34 +00:00
$options = explode ( ',' , ( string ) $value );
2016-03-01 18:44:13 +00:00
foreach ( $options as $option )
{
if ( strpos ( $option , '|' ) !== false )
{
// has other value then text
list ( $v , $t ) = explode ( '|' , $option );
2020-03-28 13:34:14 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$t , true
);
2016-03-01 18:44:13 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $t
2020-03-28 13:34:14 +00:00
);
2019-07-29 11:30:13 +00:00
// now add to option set
2022-08-30 15:28:41 +00:00
$optionSet .= PHP_EOL . Indent :: _ ( 1 )
. $taber . Indent :: _ ( 2 ) . '<option value="'
. $v . '">' . PHP_EOL . Indent :: _ ( 1 )
. $taber . Indent :: _ ( 3 ) . $langValue
2020-07-07 15:13:04 +00:00
. '</option>' ;
2016-03-01 18:44:13 +00:00
$optionArray [ $v ] = $langValue ;
}
else
{
// text is also the value
2020-03-28 13:34:14 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$option , true
);
2016-03-01 18:44:13 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $option
2020-03-28 13:34:14 +00:00
);
2019-07-29 11:30:13 +00:00
// now add to option set
2022-08-30 15:28:41 +00:00
$optionSet .= PHP_EOL . Indent :: _ ( 2 )
. $taber . Indent :: _ ( 1 ) . '<option value="'
. $option . '">' . PHP_EOL . Indent :: _ ( 2 )
. $taber . Indent :: _ ( 2 ) . $langValue
2020-07-07 15:13:04 +00:00
. '</option>' ;
2016-03-01 18:44:13 +00:00
$optionArray [ $option ] = $langValue ;
}
}
}
else
{
// one option
2023-01-01 02:11:34 +00:00
if ( strpos (( string ) $value , '|' ) !== false )
2016-03-01 18:44:13 +00:00
{
// has other value then text
2023-01-01 02:11:34 +00:00
list ( $v , $t ) = explode ( '|' , ( string ) $value );
2020-03-28 13:34:14 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$t , true
);
2016-03-01 18:44:13 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set ( CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $t );
2019-07-29 11:30:13 +00:00
// now add to option set
2022-08-30 15:28:41 +00:00
$optionSet .= PHP_EOL . Indent :: _ ( 2 ) . $taber
. Indent :: _ ( 1 ) . '<option value="' . $v . '">'
. PHP_EOL . Indent :: _ ( 2 ) . $taber . Indent :: _ ( 2 )
2020-07-07 15:13:04 +00:00
. $langValue . '</option>' ;
2016-03-01 18:44:13 +00:00
$optionArray [ $v ] = $langValue ;
}
else
{
// text is also the value
2020-03-28 13:34:14 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$value , true
);
2016-03-01 18:44:13 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $value
2020-03-28 13:34:14 +00:00
);
2019-07-29 11:30:13 +00:00
// now add to option set
2022-08-30 15:28:41 +00:00
$optionSet .= PHP_EOL . Indent :: _ ( 2 )
. $taber . Indent :: _ ( 1 ) . '<option value="'
. $value . '">' . PHP_EOL . Indent :: _ ( 2 )
. $taber . Indent :: _ ( 2 ) . $langValue
2020-07-07 15:13:04 +00:00
. '</option>' ;
2016-03-01 18:44:13 +00:00
$optionArray [ $value ] = $langValue ;
}
}
}
}
2020-07-07 15:13:04 +00:00
// if options were found
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $optionSet ))
2020-07-07 15:13:04 +00:00
{
$field .= '>' ;
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 3 ) . $taber . " <!-- "
. Line :: _ ( __Line__ , __Class__ ) . " Option Set. --> " ;
2020-07-07 15:13:04 +00:00
$field .= $optionSet ;
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . " </field> " ;
2020-07-07 15:13:04 +00:00
}
2019-03-05 07:51:52 +00:00
// if no options found and must have a list of options
2020-07-07 15:13:04 +00:00
elseif ( ComponentbuilderHelper :: fieldCheck ( $typeName , 'list' ))
2016-03-01 18:44:13 +00:00
{
2020-07-07 15:13:04 +00:00
$optionArray = false ;
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . " /> " ;
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . " <!-- "
. Line :: _ ( __Line__ , __Class__ )
2020-07-07 15:13:04 +00:00
. " No Manual Options Were Added In Field Settings. --> "
. PHP_EOL ;
2016-03-01 18:44:13 +00:00
}
2020-07-07 15:13:04 +00:00
else
2016-03-01 18:44:13 +00:00
{
2020-07-07 15:13:04 +00:00
$optionArray = false ;
2022-08-30 15:28:41 +00:00
$field .= PHP_EOL . Indent :: _ ( 2 ) . $taber . " /> " ;
2020-07-07 15:13:04 +00:00
}
// incase the field is in the config and has not been set
2020-11-26 17:33:39 +00:00
if ( 'config' === $nameSingleCode && 'configs' === $nameListCode
|| ( strpos ( $nameSingleCode , 'P|uG!n' ) !== false
2020-07-07 15:13:04 +00:00
|| strpos (
2020-11-26 17:33:39 +00:00
$nameSingleCode , 'M0dU|3'
2020-07-07 15:13:04 +00:00
) !== false ))
{
// set lang (just incase)
$listLangName = $langView . '_'
2022-03-09 23:46:45 +00:00
. StringHelper :: safe ( $name , 'U' );
2020-07-07 15:13:04 +00:00
// set the custom array
$data = array ( 'type' => $typeName , 'code' => $name ,
2023-05-02 00:10:55 +00:00
'lang' => $listLangName , 'custom' => $custom );
2020-07-07 15:13:04 +00:00
// set the custom field file
$this -> setCustomFieldTypeFile (
2020-11-26 17:33:39 +00:00
$data , $nameListCode , $nameSingleCode
2020-07-07 15:13:04 +00:00
);
2016-03-01 18:44:13 +00:00
}
}
2020-07-07 15:13:04 +00:00
// return field
return $field ;
}
/**
* set a field with simpleXMLElement class
*
2020-11-26 17:33:39 +00:00
* @ param string $setType The set of fields type
* @ param array $fieldAttributes The field values
* @ param string $name The field name
* @ param string $typeName The field type
* @ param string $langView The language string of the view
* @ param string $nameSingleCode The single view name
* @ param string $nameListCode The list view name
* @ param array $placeholders The place holder and replace values
* @ param string $optionArray The option bucket array used to set the field options if needed .
* @ param array $custom Used when field is from config
2020-07-07 15:13:04 +00:00
*
* @ return SimpleXMLElement The field in xml
*
*/
protected function simpleXMLSetField ( $setType , & $fieldAttributes , & $name ,
2023-05-02 00:10:55 +00:00
& $typeName , & $langView , & $nameSingleCode , & $nameListCode ,
$placeholders , & $optionArray , $custom = null
2020-07-07 15:13:04 +00:00
) {
$field = new stdClass ();
if ( $setType === 'option' )
2016-03-01 18:44:13 +00:00
{
// now add to the field set
2017-12-04 14:56:18 +00:00
$field -> fieldXML = new SimpleXMLElement ( '<field/>' );
2022-08-30 15:28:41 +00:00
$field -> comment = Line :: _ ( __Line__ , __Class__ ) . " " . ucfirst ( $name )
2022-03-09 23:46:45 +00:00
. " Field. Type: " . StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$typeName , 'F'
2020-07-07 15:13:04 +00:00
) . " . (joomla) " ;
2017-12-03 17:08:01 +00:00
2016-03-01 18:44:13 +00:00
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
2017-12-04 14:56:18 +00:00
$field -> fieldXML -> addAttribute ( $property , $value );
2016-03-01 18:44:13 +00:00
}
2020-07-07 15:13:04 +00:00
elseif ( $property === 'option' )
2016-03-01 18:44:13 +00:00
{
2020-07-07 15:13:04 +00:00
ComponentbuilderHelper :: xmlComment (
$field -> fieldXML ,
2022-08-30 15:28:41 +00:00
Line :: _ ( __Line__ , __Class__ ) . " Option Set. "
2020-03-28 13:34:14 +00:00
);
2020-07-07 15:13:04 +00:00
if ( strtolower ( $typeName ) === 'groupedlist'
&& strpos (
2023-01-01 02:11:34 +00:00
( string ) $value , ','
2020-07-07 15:13:04 +00:00
) !== false
2023-01-01 02:11:34 +00:00
&& strpos (( string ) $value , '@@' ) !== false )
2016-03-01 18:44:13 +00:00
{
2020-07-07 15:13:04 +00:00
// reset the group temp arrays
$groups_ = array ();
$grouped_ = array ( 'group' => array (),
2023-05-02 00:10:55 +00:00
'option' => array ());
2020-07-07 15:13:04 +00:00
$order_ = array ();
// mulitpal options
2023-01-01 02:11:34 +00:00
$options = explode ( ',' , ( string ) $value );
2020-07-07 15:13:04 +00:00
foreach ( $options as $option )
2016-03-01 18:44:13 +00:00
{
2020-07-07 15:13:04 +00:00
if ( strpos ( $option , '@@' ) !== false )
2016-03-01 18:44:13 +00:00
{
2020-07-07 15:13:04 +00:00
// set the group label
$valueKeyArray = explode ( '@@' , $option );
if ( count (( array ) $valueKeyArray ) == 2 )
2016-03-01 18:44:13 +00:00
{
2020-07-07 15:13:04 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-07-07 15:13:04 +00:00
$valueKeyArray [ 0 ], true
);
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue ,
2020-07-07 15:13:04 +00:00
$valueKeyArray [ 0 ]
2020-03-28 13:34:14 +00:00
);
2020-07-07 15:13:04 +00:00
// now add group label
$groups_ [ $valueKeyArray [ 1 ]] = $langValue ;
// set order
$order_ [ 'group' . $valueKeyArray [ 1 ]]
= $valueKeyArray [ 1 ];
2016-03-01 18:44:13 +00:00
}
2020-07-07 15:13:04 +00:00
}
elseif ( strpos ( $option , '|' ) !== false )
{
// has other value then text
$valueKeyArray = explode ( '|' , $option );
if ( count (( array ) $valueKeyArray ) == 3 )
2016-03-01 18:44:13 +00:00
{
2020-07-07 15:13:04 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-07-07 15:13:04 +00:00
$valueKeyArray [ 1 ], true
2020-03-28 13:34:14 +00:00
);
2016-03-01 18:44:13 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue ,
2020-07-07 15:13:04 +00:00
$valueKeyArray [ 1 ]
2020-03-28 13:34:14 +00:00
);
2020-07-07 15:13:04 +00:00
// now add to option set
$grouped_ [ 'group' ][ $valueKeyArray [ 2 ]][]
= array ( 'value' => $valueKeyArray [ 0 ],
2023-05-02 00:10:55 +00:00
'text' => $langValue );
2020-07-07 15:13:04 +00:00
$optionArray [ $valueKeyArray [ 0 ]]
= $langValue ;
// set order
$order_ [ 'group' . $valueKeyArray [ 2 ]]
= $valueKeyArray [ 2 ];
2016-03-01 18:44:13 +00:00
}
2019-07-28 21:48:42 +00:00
else
{
2020-07-07 15:13:04 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-07-07 15:13:04 +00:00
$valueKeyArray [ 1 ], true
);
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue ,
2020-07-07 15:13:04 +00:00
$valueKeyArray [ 1 ]
2020-03-28 13:34:14 +00:00
);
2020-07-07 15:13:04 +00:00
// now add to option set
$grouped_ [ 'option' ][ $valueKeyArray [ 0 ]]
= array ( 'value' => $valueKeyArray [ 0 ],
2023-05-02 00:10:55 +00:00
'text' => $langValue );
2020-07-07 15:13:04 +00:00
$optionArray [ $valueKeyArray [ 0 ]]
= $langValue ;
// set order
$order_ [ 'option' . $valueKeyArray [ 0 ]]
= $valueKeyArray [ 0 ];
2019-07-28 21:48:42 +00:00
}
2016-03-01 18:44:13 +00:00
}
2020-07-07 15:13:04 +00:00
else
{
// text is also the value
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-07-07 15:13:04 +00:00
$option , true
);
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $option
2020-07-07 15:13:04 +00:00
);
// now add to option set
$grouped_ [ 'option' ][ $option ]
2023-05-02 00:10:55 +00:00
= array ( 'value' => $option ,
'text' => $langValue );
2020-07-07 15:13:04 +00:00
$optionArray [ $option ] = $langValue ;
// set order
$order_ [ 'option' . $option ] = $option ;
}
2016-03-01 18:44:13 +00:00
}
2020-07-07 15:13:04 +00:00
// now build the groups
foreach ( $order_ as $pointer_ => $_id )
{
// load the default key
$key_ = 'group' ;
if ( strpos ( $pointer_ , 'option' ) !== false )
{
// load the option field
$key_ = 'option' ;
}
// check if this is a group loader
if ( 'group' === $key_ && isset ( $groups_ [ $_id ])
&& isset ( $grouped_ [ $key_ ][ $_id ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-07-07 15:13:04 +00:00
$grouped_ [ $key_ ][ $_id ]
))
{
// set group label
$groupXML = $field -> fieldXML -> addChild ( 'group' );
$groupXML -> addAttribute (
'label' , $groups_ [ $_id ]
);
2017-12-03 17:08:01 +00:00
2020-07-07 15:13:04 +00:00
foreach ( $grouped_ [ $key_ ][ $_id ] as $option_ )
{
$groupOptionXML = $groupXML -> addChild (
'option'
);
$groupOptionXML -> addAttribute (
'value' , $option_ [ 'value' ]
);
$groupOptionXML [] = $option_ [ 'text' ];
}
unset ( $groups_ [ $_id ]);
unset ( $grouped_ [ $key_ ][ $_id ]);
}
elseif ( isset ( $grouped_ [ $key_ ][ $_id ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-07-07 15:13:04 +00:00
$grouped_ [ $key_ ][ $_id ]
))
{
$optionXML = $field -> fieldXML -> addChild (
'option'
);
$optionXML -> addAttribute (
'value' , $grouped_ [ $key_ ][ $_id ][ 'value' ]
);
$optionXML [] = $grouped_ [ $key_ ][ $_id ][ 'text' ];
}
}
}
2023-01-01 02:11:34 +00:00
elseif ( strpos (( string ) $value , ',' ) !== false )
2017-06-18 07:37:48 +00:00
{
2020-07-07 15:13:04 +00:00
// mulitpal options
2023-01-01 02:11:34 +00:00
$options = explode ( ',' , ( string ) $value );
2020-07-07 15:13:04 +00:00
foreach ( $options as $option )
{
$optionXML = $field -> fieldXML -> addChild ( 'option' );
if ( strpos ( $option , '|' ) !== false )
{
// has other value then text
list ( $v , $t ) = explode ( '|' , $option );
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-07-07 15:13:04 +00:00
$t , true
);
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $t
2020-07-07 15:13:04 +00:00
);
// now add to option set
$optionXML -> addAttribute ( 'value' , $v );
$optionArray [ $v ] = $langValue ;
}
else
{
// text is also the value
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-07-07 15:13:04 +00:00
$option , true
);
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $option
2020-07-07 15:13:04 +00:00
);
// now add to option set
$optionXML -> addAttribute ( 'value' , $option );
$optionArray [ $option ] = $langValue ;
}
$optionXML [] = $langValue ;
}
2017-12-03 18:09:04 +00:00
}
2020-07-07 15:13:04 +00:00
else
2017-12-03 18:09:04 +00:00
{
2020-07-07 15:13:04 +00:00
// one option
$optionXML = $field -> fieldXML -> addChild ( 'option' );
2023-01-01 02:11:34 +00:00
if ( strpos (( string ) $value , '|' ) !== false )
2020-07-07 15:13:04 +00:00
{
// has other value then text
2023-01-01 02:11:34 +00:00
list ( $v , $t ) = explode ( '|' , ( string ) $value );
2020-07-07 15:13:04 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-07-07 15:13:04 +00:00
$t , true
);
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set ( CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $t );
2020-07-07 15:13:04 +00:00
// now add to option set
$optionXML -> addAttribute ( 'value' , $v );
$optionArray [ $v ] = $langValue ;
}
else
{
// text is also the value
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-07-07 15:13:04 +00:00
$value , true
);
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $value
2020-07-07 15:13:04 +00:00
);
// now add to option set
$optionXML -> addAttribute ( 'value' , $value );
$optionArray [ $value ] = $langValue ;
}
$optionXML [] = $langValue ;
}
}
}
// if no options found and must have a list of options
if ( ! $field -> fieldXML -> count ()
&& ComponentbuilderHelper :: fieldCheck ( $typeName , 'list' ))
{
ComponentbuilderHelper :: xmlComment (
2022-08-30 15:28:41 +00:00
$field -> fieldXML , Line :: _ ( __Line__ , __Class__ )
2020-07-07 15:13:04 +00:00
. " No Manual Options Were Added In Field Settings. "
);
}
}
elseif ( $setType === 'plain' )
{
// now add to the field set
$field -> fieldXML = new SimpleXMLElement ( '<field/>' );
2022-08-30 15:28:41 +00:00
$field -> comment = Line :: _ ( __Line__ , __Class__ ) . " " . ucfirst ( $name )
2022-03-09 23:46:45 +00:00
. " Field. Type: " . StringHelper :: safe (
2020-07-07 15:13:04 +00:00
$typeName , 'F'
) . " . (joomla) " ;
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
$field -> fieldXML -> addAttribute ( $property , $value );
}
}
}
elseif ( $setType === 'spacer' )
{
// now add to the field set
$field -> fieldXML = new SimpleXMLElement ( '<field/>' );
2022-08-30 15:28:41 +00:00
$field -> comment = Line :: _ ( __Line__ , __Class__ ) . " " . ucfirst ( $name )
2022-03-09 23:46:45 +00:00
. " Field. Type: " . StringHelper :: safe (
2020-07-07 15:13:04 +00:00
$typeName , 'F'
) . " . A None Database Field. (joomla) " ;
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
$field -> fieldXML -> addAttribute ( $property , $value );
}
}
}
elseif ( $setType === 'special' )
{
// set the repeatable field
if ( $typeName === 'repeatable' )
{
// now add to the field set
$field -> fieldXML = new SimpleXMLElement ( '<field/>' );
2022-08-30 15:28:41 +00:00
$field -> comment = Line :: _ ( __Line__ , __Class__ ) . " " . ucfirst (
2020-07-07 15:13:04 +00:00
$name
2022-03-09 23:46:45 +00:00
) . " Field. Type: " . StringHelper :: safe (
2020-07-07 15:13:04 +00:00
$typeName , 'F'
) . " . (depreciated) " ;
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'fields' )
{
$field -> fieldXML -> addAttribute ( $property , $value );
}
}
$fieldsXML = $field -> fieldXML -> addChild ( 'fields' );
$fieldsXML -> addAttribute (
'name' , $fieldAttributes [ 'name' ] . '_fields'
);
$fieldsXML -> addAttribute ( 'label' , '' );
$fieldSetXML = $fieldsXML -> addChild ( 'fieldset' );
$fieldSetXML -> addAttribute ( 'hidden' , 'true' );
$fieldSetXML -> addAttribute (
'name' , $fieldAttributes [ 'name' ] . '_modal'
);
$fieldSetXML -> addAttribute ( 'repeat' , 'true' );
2023-01-01 02:11:34 +00:00
if ( strpos (( string ) $fieldAttributes [ 'fields' ], ',' ) !== false )
2020-07-07 15:13:04 +00:00
{
// mulitpal fields
$fieldsSets = ( array ) explode (
2023-01-01 02:11:34 +00:00
',' , ( string ) $fieldAttributes [ 'fields' ]
2020-07-07 15:13:04 +00:00
);
}
elseif ( is_numeric ( $fieldAttributes [ 'fields' ]))
{
// single field
$fieldsSets [] = ( int ) $fieldAttributes [ 'fields' ];
}
// only continue if we have a field set
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $fieldsSets ))
2020-07-07 15:13:04 +00:00
{
// set the resolver
$_resolverKey = $fieldAttributes [ 'name' ];
// load the field data
$fieldsSets = array_map (
function ( $id ) use (
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode , $_resolverKey
2020-07-07 15:13:04 +00:00
) {
// start field
$field = array ();
$field [ 'field' ] = $id ;
// set the field details
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Field' ) -> set (
2020-11-26 17:33:39 +00:00
$field , $nameSingleCode , $nameListCode ,
2020-07-07 15:13:04 +00:00
$_resolverKey
);
// return field
return $field ;
}, array_values ( $fieldsSets )
);
// start the build
foreach ( $fieldsSets as $fieldData )
{
// if we have settings continue
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check (
2020-07-07 15:13:04 +00:00
$fieldData [ 'settings' ]
))
{
2022-09-10 08:16:44 +00:00
$r_name = CFactory :: _ ( 'Field.Name' ) -> get (
2020-11-26 17:33:39 +00:00
$fieldData , $nameListCode , $_resolverKey
2020-07-07 15:13:04 +00:00
);
2022-09-10 08:16:44 +00:00
$r_typeName = CFactory :: _ ( 'Field.Type.Name' ) -> get ( $fieldData );
2020-07-07 15:13:04 +00:00
$r_multiple = false ;
$r_langLabel = '' ;
// get field values
$r_fieldValues = $this -> setFieldAttributes (
$fieldData , $view , $r_name , $r_typeName ,
$r_multiple , $r_langLabel , $langView ,
2020-11-26 17:33:39 +00:00
$nameListCode , $nameSingleCode ,
2020-07-07 15:13:04 +00:00
$placeholders , true
);
// check if values were set
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-07-07 15:13:04 +00:00
$r_fieldValues
))
{
//reset options array
$r_optionArray = array ();
if ( ComponentbuilderHelper :: fieldCheck (
$r_typeName , 'option'
))
{
// now add to the field set
ComponentbuilderHelper :: xmlAppend (
$fieldSetXML , $this -> setField (
'option' , $r_fieldValues , $r_name ,
$r_typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode ,
2020-07-07 15:13:04 +00:00
$placeholders , $r_optionArray
)
);
}
elseif ( isset ( $r_fieldValues [ 'custom' ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-07-07 15:13:04 +00:00
$r_fieldValues [ 'custom' ]
))
{
// add to custom
$custom = $r_fieldValues [ 'custom' ];
unset ( $r_fieldValues [ 'custom' ]);
// now add to the field set
ComponentbuilderHelper :: xmlAppend (
$fieldSetXML , $this -> setField (
'custom' , $r_fieldValues , $r_name ,
$r_typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode ,
2020-07-07 15:13:04 +00:00
$placeholders , $r_optionArray
)
);
// set lang (just incase)
$r_listLangName = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-07-07 15:13:04 +00:00
$r_name , true
);
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $r_listLangName ,
2022-03-09 23:46:45 +00:00
StringHelper :: safe (
2020-07-07 15:13:04 +00:00
$r_name , 'W'
)
);
// if label was set use instead
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check (
2020-07-07 15:13:04 +00:00
$r_langLabel
))
{
$r_listLangName = $r_langLabel ;
}
// set the custom array
$data = array ( 'type' => $r_typeName ,
2023-05-02 00:10:55 +00:00
'code' => $r_name ,
'lang' => $r_listLangName ,
'custom' => $custom );
2020-07-07 15:13:04 +00:00
// set the custom field file
$this -> setCustomFieldTypeFile (
2020-11-26 17:33:39 +00:00
$data , $nameListCode ,
$nameSingleCode
2020-07-07 15:13:04 +00:00
);
}
else
{
// now add to the field set
ComponentbuilderHelper :: xmlAppend (
$fieldSetXML , $this -> setField (
'plain' , $r_fieldValues , $r_name ,
$r_typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode ,
2020-07-07 15:13:04 +00:00
$placeholders , $r_optionArray
)
);
}
}
}
}
}
}
// set the subform fields (it is a repeatable without the modal)
elseif ( $typeName === 'subform' )
{
// now add to the field set
$field -> fieldXML = new SimpleXMLElement ( '<field/>' );
2022-08-30 15:28:41 +00:00
$field -> comment = Line :: _ ( __Line__ , __Class__ ) . " " . ucfirst (
2020-07-07 15:13:04 +00:00
$name
2022-03-09 23:46:45 +00:00
) . " Field. Type: " . StringHelper :: safe (
2020-07-07 15:13:04 +00:00
$typeName , 'F'
) . " . (joomla) " ;
// add all properties
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'fields' && $property != 'formsource' )
{
$field -> fieldXML -> addAttribute ( $property , $value );
}
}
// if we detect formsource we do not add the form
if ( isset ( $fieldAttributes [ 'formsource' ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-07-07 15:13:04 +00:00
$fieldAttributes [ 'formsource' ]
))
{
$field -> fieldXML -> addAttribute (
'formsource' , $fieldAttributes [ 'formsource' ]
);
}
// add the form
else
{
$form = $field -> fieldXML -> addChild ( 'form' );
$attributes = array (
'hidden' => 'true' ,
'name' => 'list_' . $fieldAttributes [ 'name' ]
. '_modal' ,
'repeat' => 'true'
);
ComponentbuilderHelper :: xmlAddAttributes (
$form , $attributes
);
2023-01-01 02:11:34 +00:00
if ( strpos (( string ) $fieldAttributes [ 'fields' ], ',' ) !== false )
2020-07-07 15:13:04 +00:00
{
// multiple fields
$fieldsSets = ( array ) explode (
2023-01-01 02:11:34 +00:00
',' , ( string ) $fieldAttributes [ 'fields' ]
2020-07-07 15:13:04 +00:00
);
}
elseif ( is_numeric ( $fieldAttributes [ 'fields' ]))
{
// single field
$fieldsSets [] = ( int ) $fieldAttributes [ 'fields' ];
}
// only continue if we have a field set
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $fieldsSets ))
2020-07-07 15:13:04 +00:00
{
// set the resolver
$_resolverKey = $fieldAttributes [ 'name' ];
// load the field data
$fieldsSets = array_map (
function ( $id ) use (
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode ,
2020-07-07 15:13:04 +00:00
$_resolverKey
) {
// start field
$field = array ();
$field [ 'field' ] = $id ;
// set the field details
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Field' ) -> set (
2020-11-26 17:33:39 +00:00
$field , $nameSingleCode , $nameListCode ,
2020-07-07 15:13:04 +00:00
$_resolverKey
);
// return field
return $field ;
}, array_values ( $fieldsSets )
);
// start the build
foreach ( $fieldsSets as $fieldData )
{
// if we have settings continue
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check (
2020-07-07 15:13:04 +00:00
$fieldData [ 'settings' ]
))
{
2022-09-10 08:16:44 +00:00
$r_name = CFactory :: _ ( 'Field.Name' ) -> get (
2020-11-26 17:33:39 +00:00
$fieldData , $nameListCode , $_resolverKey
2020-07-07 15:13:04 +00:00
);
2022-09-10 08:16:44 +00:00
$r_typeName = CFactory :: _ ( 'Field.Type.Name' ) -> get ( $fieldData );
2020-07-07 15:13:04 +00:00
$r_multiple = false ;
$r_langLabel = '' ;
// get field values
$r_fieldValues = $this -> setFieldAttributes (
$fieldData , $view , $r_name , $r_typeName ,
$r_multiple , $r_langLabel , $langView ,
2020-11-26 17:33:39 +00:00
$nameListCode , $nameSingleCode ,
2020-07-07 15:13:04 +00:00
$placeholders , true
);
// check if values were set
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-07-07 15:13:04 +00:00
$r_fieldValues
))
{
//reset options array
$r_optionArray = array ();
if ( ComponentbuilderHelper :: fieldCheck (
$r_typeName , 'option'
))
{
// now add to the field set
ComponentbuilderHelper :: xmlAppend (
$form , $this -> setField (
'option' , $r_fieldValues , $r_name ,
$r_typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode ,
2020-07-07 15:13:04 +00:00
$placeholders , $r_optionArray
)
);
}
elseif ( $r_typeName === 'subform' )
{
// set nested depth
if ( isset ( $fieldAttributes [ 'nested_depth' ]))
{
$r_fieldValues [ 'nested_depth' ]
= ++ $fieldAttributes [ 'nested_depth' ];
}
else
{
$r_fieldValues [ 'nested_depth' ] = 1 ;
}
// only continue if nest is bellow 20 (this should be a safe limit)
if ( $r_fieldValues [ 'nested_depth' ]
<= 20 )
{
// now add to the field set
ComponentbuilderHelper :: xmlAppend (
$form , $this -> setField (
'special' , $r_fieldValues ,
$r_name , $r_typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode ,
$nameListCode , $placeholders ,
2020-07-07 15:13:04 +00:00
$r_optionArray
)
);
}
}
elseif ( isset ( $r_fieldValues [ 'custom' ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-07-07 15:13:04 +00:00
$r_fieldValues [ 'custom' ]
))
{
// add to custom
$custom = $r_fieldValues [ 'custom' ];
unset ( $r_fieldValues [ 'custom' ]);
// now add to the field set
ComponentbuilderHelper :: xmlAppend (
$form , $this -> setField (
'custom' , $r_fieldValues , $r_name ,
$r_typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode ,
2020-07-07 15:13:04 +00:00
$placeholders , $r_optionArray
)
);
// set lang (just incase)
$r_listLangName = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-07-07 15:13:04 +00:00
$r_name , true
);
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $r_listLangName ,
2022-03-09 23:46:45 +00:00
StringHelper :: safe (
2020-07-07 15:13:04 +00:00
$r_name , 'W'
)
);
// if label was set use instead
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check (
2020-07-07 15:13:04 +00:00
$r_langLabel
))
{
$r_listLangName = $r_langLabel ;
}
// set the custom array
$data = array ( 'type' => $r_typeName ,
2023-05-02 00:10:55 +00:00
'code' => $r_name ,
'lang' => $r_listLangName ,
'custom' => $custom );
2020-07-07 15:13:04 +00:00
// set the custom field file
$this -> setCustomFieldTypeFile (
2020-11-26 17:33:39 +00:00
$data , $nameListCode ,
$nameSingleCode
2020-07-07 15:13:04 +00:00
);
}
else
{
// now add to the field set
ComponentbuilderHelper :: xmlAppend (
$form , $this -> setField (
'plain' , $r_fieldValues , $r_name ,
$r_typeName , $langView ,
2020-11-26 17:33:39 +00:00
$nameSingleCode , $nameListCode ,
2020-07-07 15:13:04 +00:00
$placeholders , $r_optionArray
)
);
}
}
}
}
}
}
}
}
elseif ( $setType === 'custom' )
{
// now add to the field set
$field -> fieldXML = new SimpleXMLElement ( '<field/>' );
2022-08-30 15:28:41 +00:00
$field -> comment = Line :: _ ( __Line__ , __Class__ ) . " " . ucfirst ( $name )
2022-03-09 23:46:45 +00:00
. " Field. Type: " . StringHelper :: safe (
2020-07-07 15:13:04 +00:00
$typeName , 'F'
) . " . (custom) " ;
foreach ( $fieldAttributes as $property => $value )
{
if ( $property != 'option' )
{
$field -> fieldXML -> addAttribute ( $property , $value );
}
elseif ( $property === 'option' )
{
ComponentbuilderHelper :: xmlComment (
$field -> fieldXML ,
2022-08-30 15:28:41 +00:00
Line :: _ ( __Line__ , __Class__ ) . " Option Set. "
2020-07-07 15:13:04 +00:00
);
if ( strtolower ( $typeName ) === 'groupedlist'
&& strpos (
2023-01-01 02:11:34 +00:00
( string ) $value , ','
2020-07-07 15:13:04 +00:00
) !== false
2023-01-01 02:11:34 +00:00
&& strpos (( string ) $value , '@@' ) !== false )
2020-07-07 15:13:04 +00:00
{
// reset the group temp arrays
$groups_ = array ();
$grouped_ = array ( 'group' => array (),
2023-05-02 00:10:55 +00:00
'option' => array ());
2020-07-07 15:13:04 +00:00
$order_ = array ();
// mulitpal options
2023-01-01 02:11:34 +00:00
$options = explode ( ',' , ( string ) $value );
2020-07-07 15:13:04 +00:00
foreach ( $options as $option )
{
if ( strpos ( $option , '@@' ) !== false )
{
// set the group label
$valueKeyArray = explode ( '@@' , $option );
if ( count (( array ) $valueKeyArray ) == 2 )
{
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-07-07 15:13:04 +00:00
$valueKeyArray [ 0 ], true
);
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue ,
2020-07-07 15:13:04 +00:00
$valueKeyArray [ 0 ]
);
// now add group label
$groups_ [ $valueKeyArray [ 1 ]] = $langValue ;
// set order
$order_ [ 'group' . $valueKeyArray [ 1 ]]
= $valueKeyArray [ 1 ];
}
}
elseif ( strpos ( $option , '|' ) !== false )
{
// has other value then text
$valueKeyArray = explode ( '|' , $option );
if ( count (( array ) $valueKeyArray ) == 3 )
{
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-07-07 15:13:04 +00:00
$valueKeyArray [ 1 ], true
);
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue ,
2020-07-07 15:13:04 +00:00
$valueKeyArray [ 1 ]
);
// now add to option set
$grouped_ [ 'group' ][ $valueKeyArray [ 2 ]][]
= array ( 'value' => $valueKeyArray [ 0 ],
2023-05-02 00:10:55 +00:00
'text' => $langValue );
2020-07-07 15:13:04 +00:00
$optionArray [ $valueKeyArray [ 0 ]]
= $langValue ;
// set order
$order_ [ 'group' . $valueKeyArray [ 2 ]]
= $valueKeyArray [ 2 ];
}
else
{
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-07-07 15:13:04 +00:00
$valueKeyArray [ 1 ], true
);
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue ,
2020-07-07 15:13:04 +00:00
$valueKeyArray [ 1 ]
);
// now add to option set
$grouped_ [ 'option' ][ $valueKeyArray [ 0 ]]
= array ( 'value' => $valueKeyArray [ 0 ],
2023-05-02 00:10:55 +00:00
'text' => $langValue );
2020-07-07 15:13:04 +00:00
$optionArray [ $valueKeyArray [ 0 ]]
= $langValue ;
// set order
$order_ [ 'option' . $valueKeyArray [ 0 ]]
= $valueKeyArray [ 0 ];
}
}
else
{
// text is also the value
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-07-07 15:13:04 +00:00
$option , true
);
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $option
2020-07-07 15:13:04 +00:00
);
// now add to option set
$grouped_ [ 'option' ][ $option ]
2023-05-02 00:10:55 +00:00
= array ( 'value' => $option ,
'text' => $langValue );
2020-07-07 15:13:04 +00:00
$optionArray [ $option ] = $langValue ;
// set order
$order_ [ 'option' . $option ] = $option ;
}
}
// now build the groups
foreach ( $order_ as $pointer_ => $_id )
{
// load the default key
$key_ = 'group' ;
if ( strpos ( $pointer_ , 'option' ) !== false )
{
// load the option field
$key_ = 'option' ;
}
// check if this is a group loader
if ( 'group' === $key_ && isset ( $groups_ [ $_id ])
&& isset ( $grouped_ [ $key_ ][ $_id ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-07-07 15:13:04 +00:00
$grouped_ [ $key_ ][ $_id ]
))
{
// set group label
$groupXML = $field -> fieldXML -> addChild ( 'group' );
$groupXML -> addAttribute (
'label' , $groups_ [ $_id ]
);
foreach ( $grouped_ [ $key_ ][ $_id ] as $option_ )
{
$groupOptionXML = $groupXML -> addChild (
'option'
);
$groupOptionXML -> addAttribute (
'value' , $option_ [ 'value' ]
);
$groupOptionXML [] = $option_ [ 'text' ];
}
unset ( $groups_ [ $_id ]);
unset ( $grouped_ [ $key_ ][ $_id ]);
}
elseif ( isset ( $grouped_ [ $key_ ][ $_id ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-07-07 15:13:04 +00:00
$grouped_ [ $key_ ][ $_id ]
))
{
$optionXML = $field -> fieldXML -> addChild (
'option'
);
$optionXML -> addAttribute (
'value' , $grouped_ [ $key_ ][ $_id ][ 'value' ]
);
$optionXML [] = $grouped_ [ $key_ ][ $_id ][ 'text' ];
}
}
2017-12-03 18:09:04 +00:00
}
2023-01-01 02:11:34 +00:00
elseif ( strpos (( string ) $value , ',' ) !== false )
2017-12-03 18:09:04 +00:00
{
2022-03-09 23:46:45 +00:00
// municipal options
2023-01-01 02:11:34 +00:00
$options = explode ( ',' , ( string ) $value );
2020-07-07 15:13:04 +00:00
foreach ( $options as $option )
2017-06-18 07:37:48 +00:00
{
2020-07-07 15:13:04 +00:00
$optionXML = $field -> fieldXML -> addChild ( 'option' );
if ( strpos ( $option , '|' ) !== false )
2017-06-18 07:37:48 +00:00
{
2020-07-07 15:13:04 +00:00
// has other value then text
list ( $v , $t ) = explode ( '|' , $option );
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-07-07 15:13:04 +00:00
$t , true
);
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $t
2020-03-28 13:34:14 +00:00
);
2020-07-07 15:13:04 +00:00
// now add to option set
$optionXML -> addAttribute ( 'value' , $v );
$optionArray [ $v ] = $langValue ;
}
else
{
// text is also the value
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-07-07 15:13:04 +00:00
$option , true
);
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $option
2020-03-28 13:34:14 +00:00
);
2020-07-07 15:13:04 +00:00
// now add to option set
$optionXML -> addAttribute ( 'value' , $option );
$optionArray [ $option ] = $langValue ;
2017-06-18 07:37:48 +00:00
}
2020-07-07 15:13:04 +00:00
$optionXML [] = $langValue ;
2017-06-18 07:37:48 +00:00
}
}
2020-07-07 15:13:04 +00:00
else
{
// one option
$optionXML = $field -> fieldXML -> addChild ( 'option' );
2023-01-01 02:11:34 +00:00
if ( strpos (( string ) $value , '|' ) !== false )
2020-07-07 15:13:04 +00:00
{
// has other value then text
2023-01-01 02:11:34 +00:00
list ( $v , $t ) = explode ( '|' , ( string ) $value );
2020-07-07 15:13:04 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-07-07 15:13:04 +00:00
$t , true
);
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set ( CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $t );
2020-07-07 15:13:04 +00:00
// now add to option set
$optionXML -> addAttribute ( 'value' , $v );
$optionArray [ $v ] = $langValue ;
}
else
{
// text is also the value
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-07-07 15:13:04 +00:00
$value , true
);
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $value
2020-07-07 15:13:04 +00:00
);
// now add to option set
$optionXML -> addAttribute ( 'value' , $value );
$optionArray [ $value ] = $langValue ;
}
$optionXML [] = $langValue ;
}
2016-03-01 18:44:13 +00:00
}
}
2019-08-22 01:54:47 +00:00
// incase the field is in the config and has not been set (or is part of a plugin or module)
2020-11-26 17:33:39 +00:00
if (( 'config' === $nameSingleCode
&& 'configs' === $nameListCode )
|| ( strpos ( $nameSingleCode , 'P|uG!n' ) !== false
2020-03-28 13:34:14 +00:00
|| strpos (
2020-11-26 17:33:39 +00:00
$nameSingleCode , 'M0dU|3'
2020-03-28 13:34:14 +00:00
) !== false ))
2016-10-23 22:48:26 +00:00
{
// set lang (just incase)
2020-03-28 13:34:14 +00:00
$listLangName = $langView . '_'
2022-03-09 23:46:45 +00:00
. StringHelper :: safe ( $name , 'U' );
2016-10-23 22:48:26 +00:00
// set the custom array
2020-03-28 13:34:14 +00:00
$data = array ( 'type' => $typeName , 'code' => $name ,
2023-05-02 00:10:55 +00:00
'lang' => $listLangName , 'custom' => $custom );
2016-10-23 22:48:26 +00:00
// set the custom field file
2020-03-28 13:34:14 +00:00
$this -> setCustomFieldTypeFile (
2020-11-26 17:33:39 +00:00
$data , $nameListCode , $nameSingleCode
2020-03-28 13:34:14 +00:00
);
2016-10-23 22:48:26 +00:00
}
2016-03-01 18:44:13 +00:00
}
2020-03-28 13:34:14 +00:00
2017-12-04 14:56:18 +00:00
return $field ;
2016-03-01 18:44:13 +00:00
}
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* set the layout builder
2017-12-03 17:08:01 +00:00
*
2020-11-26 17:33:39 +00:00
* @ param string $nameSingleCode The single edit view code name
* @ param string $tabName The tab code name
* @ param string $name The field code name
* @ param array $field The field details
2016-03-01 18:44:13 +00:00
*
* @ return void
2017-12-03 17:08:01 +00:00
*
2016-03-01 18:44:13 +00:00
*/
2020-11-26 17:33:39 +00:00
public function setLayoutBuilder ( & $nameSingleCode , & $tabName , & $name ,
2023-05-02 00:10:55 +00:00
& $field
2020-03-28 13:34:14 +00:00
) {
2017-08-12 11:47:25 +00:00
// first fix the zero order
// to insure it lands before all the other fields
// as zero is expected to behave
if ( $field [ 'order_edit' ] == 0 )
{
2023-05-02 00:10:55 +00:00
// get the value
$zero_counter = CFactory :: _ ( 'Registry' ) -> get ( 'builder.zero_order_fix.' . $nameSingleCode . '.' . $field [ 'tab' ], - 999 );
if ( $zero_counter != - 999 )
2017-08-12 11:47:25 +00:00
{
2023-05-02 00:10:55 +00:00
$zero_counter ++ ;
2017-08-12 11:47:25 +00:00
}
2023-05-02 00:10:55 +00:00
$field [ 'order_edit' ] = $zero_counter ;
// set the value
CFactory :: _ ( 'Registry' ) -> set ( 'builder.zero_order_fix.' . $nameSingleCode . '.' . $field [ 'tab' ], $zero_counter );
2017-08-12 11:47:25 +00:00
}
2023-01-15 08:42:19 +00:00
// get the default fields
$default_fields = CFactory :: _ ( 'Config' ) -> default_fields ;
2017-08-12 11:47:25 +00:00
// now build the layout
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $tabName )
2022-09-14 15:40:02 +00:00
&& strtolower ( $tabName ) != 'publishing' )
2016-03-01 18:44:13 +00:00
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.tab_counter.' . $nameSingleCode . '.' . $field [ 'tab' ], $tabName );
if ( CFactory :: _ ( 'Registry' ) -> exists ( 'builder.layout.' . $nameSingleCode . '.' . $tabName . '.'
. $field [ 'alignment' ] . '.' . $field [ 'order_edit' ]))
2016-03-01 18:44:13 +00:00
{
2020-03-28 13:34:14 +00:00
$size = ( int ) count (
2023-05-02 00:10:55 +00:00
( array ) CFactory :: _ ( 'Registry' ) -> get ( 'builder.layout.' . $nameSingleCode . '.' . $tabName . '.'
. $field [ 'alignment' ])
2020-03-28 13:34:14 +00:00
) + 1 ;
2023-05-02 00:10:55 +00:00
while ( CFactory :: _ ( 'Registry' ) -> exists ( 'builder.layout.' . $nameSingleCode . '.' . $tabName . '.'
. $field [ 'alignment' ] . '.' . $size ))
2018-03-11 22:36:14 +00:00
{
$size ++ ;
}
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.layout.'
. $nameSingleCode . '.'
. $tabName . '.'
. $field [ 'alignment' ] . '.'
. $size , $name );
2016-03-01 18:44:13 +00:00
}
else
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.layout.'
. $nameSingleCode . '.'
. $tabName . '.'
. $field [ 'alignment' ] . '.'
. $field [ 'order_edit' ], $name );
2016-03-01 18:44:13 +00:00
}
2023-05-16 22:20:41 +00:00
// check if default fields were overwritten
2023-01-15 08:42:19 +00:00
if ( in_array ( $name , $default_fields ))
2016-06-02 16:18:49 +00:00
{
// just to eliminate
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.moved_publishing_fields.' . $nameSingleCode . '.' . $name , true );
2016-06-02 16:18:49 +00:00
}
}
2017-12-03 17:08:01 +00:00
elseif ( $tabName === 'publishing' || $tabName === 'Publishing' )
2016-06-02 16:18:49 +00:00
{
2023-01-15 08:42:19 +00:00
if ( ! in_array ( $name , $default_fields ))
2016-06-02 16:18:49 +00:00
{
2023-05-02 00:10:55 +00:00
if ( CFactory :: _ ( 'Registry' ) -> exists ( 'builder.new_publishing_fields.' . $nameSingleCode . '.' .
$field [ 'alignment' ] . '.' . $field [ 'order_edit' ]))
2016-06-02 16:18:49 +00:00
{
2020-03-28 13:34:14 +00:00
$size = ( int ) count (
2023-05-02 00:10:55 +00:00
( array ) CFactory :: _ ( 'Registry' ) -> get ( 'builder.new_publishing_fields.' . $nameSingleCode . '.' .
$field [ 'alignment' ])
2020-03-28 13:34:14 +00:00
) + 1 ;
2023-05-02 00:10:55 +00:00
while ( CFactory :: _ ( 'Registry' ) -> exists ( 'builder.new_publishing_fields.' . $nameSingleCode . '.' .
$field [ 'alignment' ] . '.' . $size ))
2018-03-11 22:36:14 +00:00
{
$size ++ ;
}
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.new_publishing_fields.' . $nameSingleCode . '.' .
$field [ 'alignment' ] . '.' . $size , $name );
2016-06-02 16:18:49 +00:00
}
else
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.new_publishing_fields.' . $nameSingleCode . '.' .
$field [ 'alignment' ] . '.' . $field [ 'order_edit' ], $name );
2016-06-02 16:18:49 +00:00
}
}
2016-03-01 18:44:13 +00:00
}
else
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.tab_counter.' . $nameSingleCode . '.1' , 'Details' );
if ( CFactory :: _ ( 'Registry' ) -> exists ( 'builder.layout.' . $nameSingleCode . '.Details.'
. $field [ 'alignment' ] . '.' . $field [ 'order_edit' ]))
2016-03-01 18:44:13 +00:00
{
2020-03-28 13:34:14 +00:00
$size = ( int ) count (
2023-05-02 00:10:55 +00:00
( array ) CFactory :: _ ( 'Registry' ) -> get ( 'builder.layout.' . $nameSingleCode . '.Details.'
. $field [ 'alignment' ])
) + 1 ;
while ( CFactory :: _ ( 'Registry' ) -> exists ( 'builder.layout.' . $nameSingleCode . '.Details.'
. $field [ 'alignment' ] . '.' . $size ))
2018-03-11 22:36:14 +00:00
{
$size ++ ;
}
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.layout.'
. $nameSingleCode . '.Details.'
. $field [ 'alignment' ] . '.'
. $size , $name );
2016-03-01 18:44:13 +00:00
}
else
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.layout.'
. $nameSingleCode . '.Details.'
. $field [ 'alignment' ] . '.'
. $field [ 'order_edit' ], $name );
2016-03-01 18:44:13 +00:00
}
2023-05-02 00:10:55 +00:00
// check if default fields were overwritten
2023-01-15 08:42:19 +00:00
if ( in_array ( $name , $default_fields ))
2016-06-02 16:18:49 +00:00
{
// just to eliminate
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.moved_publishing_fields.' . $nameSingleCode . '.' . $name , true );
2016-06-02 16:18:49 +00:00
}
2016-03-01 18:44:13 +00:00
}
}
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* build the site field data needed
2017-12-03 17:08:01 +00:00
*
2020-03-28 13:34:14 +00:00
* @ param string $view The single edit view code name
* @ param string $field The field name
* @ param string $set The decoding set this field belongs to
* @ param string $type The field type
2016-03-01 18:44:13 +00:00
*
* @ return void
2017-12-03 17:08:01 +00:00
*
2016-03-01 18:44:13 +00:00
*/
2017-11-11 04:33:51 +00:00
public function buildSiteFieldData ( $view , $field , $set , $type )
2016-03-01 18:44:13 +00:00
{
2020-03-28 13:34:14 +00:00
$decode = array ( 'json' , 'base64' , 'basic_encryption' ,
2023-05-02 00:10:55 +00:00
'whmcs_encryption' , 'medium_encryption' , 'expert_mode' );
2017-12-14 23:10:47 +00:00
$textareas = array ( 'textarea' , 'editor' );
2023-01-15 08:42:19 +00:00
if (( $site_fields = CFactory :: _ ( 'Registry' ) ->
extract ( 'builder.site_fields.' . $view . '.' . $field )) !== null )
2016-03-01 18:44:13 +00:00
{
2023-01-15 08:42:19 +00:00
foreach ( $site_fields as $codeString => $site_field )
2016-03-01 18:44:13 +00:00
{
2018-07-21 07:10:37 +00:00
// get the code array
2023-01-01 02:11:34 +00:00
$codeArray = explode ( '___' , ( string ) $codeString );
2018-07-21 07:10:37 +00:00
// set the code
$code = trim ( $codeArray [ 0 ]);
2016-03-01 18:44:13 +00:00
// set the decoding methods
2017-12-14 23:10:47 +00:00
if ( in_array ( $set , $decode ))
2016-03-01 18:44:13 +00:00
{
2023-01-15 08:42:19 +00:00
if ( isset ( $this -> siteFieldData [ 'decode' ][ $site_field -> site ][ $code ][ $site_field -> as ][ $site_field -> key ])
&& isset ( $this -> siteFieldData [ 'decode' ][ $site_field -> site ][ $code ][ $site_field -> as ][ $site_field -> key ][ 'decode' ]))
2018-04-30 12:06:05 +00:00
{
2020-03-28 13:34:14 +00:00
if ( ! in_array (
$set ,
2023-01-15 08:42:19 +00:00
$this -> siteFieldData [ 'decode' ][ $site_field -> site ][ $code ][ $site_field -> as ][ $site_field -> key ][ 'decode' ]
2020-03-28 13:34:14 +00:00
))
2018-04-30 12:06:05 +00:00
{
2023-01-15 08:42:19 +00:00
$this -> siteFieldData [ 'decode' ][ $site_field -> site ][ $code ][ $site_field -> as ][ $site_field -> key ][ 'decode' ][]
2020-03-28 13:34:14 +00:00
= $set ;
2018-04-30 12:06:05 +00:00
}
}
else
{
2023-01-15 08:42:19 +00:00
$this -> siteFieldData [ 'decode' ][ $site_field -> site ][ $code ][ $site_field -> as ][ $site_field -> key ]
= array ( 'decode' => [ $set ],
2023-05-02 00:10:55 +00:00
'type' => $type ,
'admin_view' => $view );
2018-04-30 12:06:05 +00:00
}
2016-03-01 18:44:13 +00:00
}
// set the uikit checker
2023-01-15 08:42:19 +00:00
if (( 2 == CFactory :: _ ( 'Config' ) -> uikit || 1 == CFactory :: _ ( 'Config' ) -> uikit )
2020-03-28 13:34:14 +00:00
&& in_array (
$type , $textareas
))
2016-03-01 18:44:13 +00:00
{
2023-01-15 08:42:19 +00:00
$this -> siteFieldData [ 'uikit' ][ $site_field -> site ][ $code ][ $site_field -> as ][ $site_field -> key ]
= ( array ) $site_field ;
2016-03-01 18:44:13 +00:00
}
2017-12-10 19:17:26 +00:00
// set the textareas checker
if ( in_array ( $type , $textareas ))
{
2023-01-15 08:42:19 +00:00
$this -> siteFieldData [ 'textareas' ][ $site_field -> site ][ $code ][ $site_field -> as ][ $site_field -> key ]
= ( array ) $site_field ;
2017-12-10 19:17:26 +00:00
}
2016-03-01 18:44:13 +00:00
}
}
}
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* set field attributes
2017-12-03 17:08:01 +00:00
*
2020-11-26 17:33:39 +00:00
* @ param array $field The field data
* @ param int $viewType The view type
* @ param string $name The field name
* @ param string $typeName The field type
* @ param boolean $multiple The switch to set multiple selection option
* @ param string $langLabel The language string for field label
* @ param string $langView The language string of the view
* @ param string $nameListCode The list view name
* @ param string $nameSingleCode The single view name
* @ param array $placeholders The place holder and replace values
* @ param boolean $repeatable The repeatable field switch
2016-03-01 18:44:13 +00:00
*
* @ return array The field attributes
2017-12-03 17:08:01 +00:00
*
2016-03-01 18:44:13 +00:00
*/
2020-03-28 13:34:14 +00:00
private function setFieldAttributes ( & $field , & $viewType , & $name , & $typeName ,
2023-05-02 00:10:55 +00:00
& $multiple , & $langLabel , $langView , $nameListCode , $nameSingleCode ,
$placeholders , $repeatable = false
2020-03-28 13:34:14 +00:00
) {
2017-12-04 14:56:18 +00:00
// reset array
2016-03-01 18:44:13 +00:00
$fieldAttributes = array ();
2020-03-28 13:34:14 +00:00
$setCustom = false ;
$setReadonly = false ;
2016-03-01 18:44:13 +00:00
// setup joomla default fields
2018-05-24 13:56:56 +00:00
if ( ! ComponentbuilderHelper :: fieldCheck ( $typeName ))
2016-03-01 18:44:13 +00:00
{
$fieldAttributes [ 'custom' ] = array ();
2018-09-24 14:37:51 +00:00
// is this an own custom field
2018-10-01 02:16:24 +00:00
if ( isset ( $field [ 'settings' ] -> own_custom ))
2018-09-24 14:37:51 +00:00
{
2020-03-28 13:34:14 +00:00
$fieldAttributes [ 'custom' ][ 'own_custom' ]
= $field [ 'settings' ] -> own_custom ;
2018-09-24 14:37:51 +00:00
}
2016-03-01 18:44:13 +00:00
$setCustom = true ;
}
// setup a default field
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $field [ 'settings' ] -> properties ))
2016-03-01 18:44:13 +00:00
{
2018-10-29 16:38:00 +00:00
// we need a deeper php code search tracker
$phpTracker = array ();
2016-03-01 18:44:13 +00:00
foreach ( $field [ 'settings' ] -> properties as $property )
{
// reset
2020-03-28 13:34:14 +00:00
$xmlValue = '' ;
2016-03-01 18:44:13 +00:00
$langValue = '' ;
2017-02-01 13:17:04 +00:00
if ( $property [ 'name' ] === 'type' )
2016-03-01 18:44:13 +00:00
{
2018-03-11 02:44:43 +00:00
// get type name
$xmlValue = $typeName ;
2016-03-01 18:44:13 +00:00
// add to custom if it is custom
if ( $setCustom )
{
// set the type just to make sure.
$fieldAttributes [ 'custom' ][ 'type' ] = $typeName ;
}
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'name' )
2016-03-01 18:44:13 +00:00
{
2018-03-11 02:44:43 +00:00
// get the actual field name
2022-08-30 15:28:41 +00:00
$xmlValue = CFactory :: _ ( 'Placeholder' ) -> update ( $name , $placeholders );
2016-03-01 18:44:13 +00:00
}
2018-03-27 09:57:16 +00:00
elseif ( $property [ 'name' ] === 'validate' )
{
// check if we have validate (validation rule set)
2022-04-04 15:35:08 +00:00
$xmlValue = GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , 'validate="' , '"'
);
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $xmlValue ))
2018-03-27 09:57:16 +00:00
{
2022-03-09 23:46:45 +00:00
$xmlValue = StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$xmlValue
);
2018-03-27 09:57:16 +00:00
}
}
2020-03-28 13:34:14 +00:00
elseif ( $property [ 'name' ] === 'extension'
|| $property [ 'name' ] === 'directory'
|| $property [ 'name' ] === 'formsource' )
2016-03-01 18:44:13 +00:00
{
2018-09-25 20:51:14 +00:00
// get value & replace the placeholders
2022-08-30 15:28:41 +00:00
$xmlValue = CFactory :: _ ( 'Placeholder' ) -> update (
2022-04-04 15:35:08 +00:00
GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , $property [ 'name' ] . '="' ,
'"'
), $placeholders
);
2016-03-01 18:44:13 +00:00
}
2018-09-24 14:37:51 +00:00
// catch all PHP here
2023-01-01 02:11:34 +00:00
elseif ( strpos (( string ) $property [ 'name' ], 'type_php' ) !== false
2020-03-28 13:34:14 +00:00
&& $setCustom )
2016-03-01 18:44:13 +00:00
{
// set the line number
2020-03-28 13:34:14 +00:00
$phpLine = ( int ) preg_replace (
2023-01-01 02:11:34 +00:00
'/[^0-9]/' , '' , ( string ) $property [ 'name' ]
2020-03-28 13:34:14 +00:00
);
2018-09-24 14:37:51 +00:00
// set the type key
2020-03-28 13:34:14 +00:00
$phpKey = ( string ) trim (
str_replace (
'type_' , '' ,
2023-01-01 02:11:34 +00:00
preg_replace ( '/[0-9]+/' , '' , ( string ) $property [ 'name' ])
2020-03-28 13:34:14 +00:00
), '_'
);
2016-03-01 18:44:13 +00:00
// load the php for the custom field file
2020-03-28 13:34:14 +00:00
$fieldAttributes [ 'custom' ][ $phpKey ][ $phpLine ]
2022-09-03 10:48:53 +00:00
= CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: openValidBase64 (
2022-04-04 15:35:08 +00:00
GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml ,
$property [ 'name' ] . '="' , '"'
)
)
);
2018-10-29 16:38:00 +00:00
// load tracker
$phpTracker [ 'type_' . $phpKey ] = $phpKey ;
2016-03-01 18:44:13 +00:00
}
2018-02-20 21:23:35 +00:00
elseif ( $property [ 'name' ] === 'prime_php' && $setCustom )
{
// load the php for the custom field file
2020-03-28 13:34:14 +00:00
$fieldAttributes [ 'custom' ][ 'prime_php' ]
2022-04-04 15:35:08 +00:00
= ( int ) GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , $property [ 'name' ] . '="' , '"'
);
2018-02-20 21:23:35 +00:00
}
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
2020-03-28 13:34:14 +00:00
$fieldAttributes [ 'custom' ][ 'extends' ]
2022-04-04 15:35:08 +00:00
= GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , 'extends="' , '"'
);
2016-03-01 18:44:13 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'view' && $setCustom )
2016-03-01 18:44:13 +00:00
{
2018-09-25 20:51:14 +00:00
// load the view name & replace the placeholders
2020-03-28 13:34:14 +00:00
$fieldAttributes [ 'custom' ][ 'view' ]
2022-03-09 23:46:45 +00:00
= StringHelper :: safe (
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> update (
2022-04-04 15:35:08 +00:00
GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , 'view="' , '"'
), $placeholders
)
);
2016-03-01 18:44:13 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'views' && $setCustom )
2016-03-01 18:44:13 +00:00
{
2018-09-25 20:51:14 +00:00
// load the views name & replace the placeholders
2020-03-28 13:34:14 +00:00
$fieldAttributes [ 'custom' ][ 'views' ]
2022-03-09 23:46:45 +00:00
= StringHelper :: safe (
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> update (
2022-04-04 15:35:08 +00:00
GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , 'views="' , '"'
), $placeholders
)
);
2016-03-01 18:44:13 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'component' && $setCustom )
2016-03-01 18:44:13 +00:00
{
2018-09-25 20:51:14 +00:00
// load the component name & replace the placeholders
2020-03-28 13:34:14 +00:00
$fieldAttributes [ 'custom' ][ 'component' ]
2022-08-30 15:28:41 +00:00
= CFactory :: _ ( 'Placeholder' ) -> update (
2022-04-04 15:35:08 +00:00
GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , 'component="' , '"'
), $placeholders
);
2016-03-01 18:44:13 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'table' && $setCustom )
2016-03-01 18:44:13 +00:00
{
2018-09-25 20:51:14 +00:00
// load the main table that is queried & replace the placeholders
2020-03-28 13:34:14 +00:00
$fieldAttributes [ 'custom' ][ 'table' ]
2022-08-30 15:28:41 +00:00
= CFactory :: _ ( 'Placeholder' ) -> update (
2022-04-04 15:35:08 +00:00
GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , 'table="' , '"'
), $placeholders
);
2016-03-01 18:44:13 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'value_field' && $setCustom )
2016-03-01 18:44:13 +00:00
{
// load the text key
2020-03-28 13:34:14 +00:00
$fieldAttributes [ 'custom' ][ 'text' ]
2022-03-09 23:46:45 +00:00
= StringHelper :: safe (
2022-04-04 15:35:08 +00:00
GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , 'value_field="' , '"'
)
);
2016-03-01 18:44:13 +00:00
}
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
2020-03-28 13:34:14 +00:00
$fieldAttributes [ 'custom' ][ 'id' ]
2022-03-09 23:46:45 +00:00
= StringHelper :: safe (
2022-04-04 15:35:08 +00:00
GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , 'key_field="' , '"'
)
);
2016-03-01 18:44:13 +00:00
}
2020-03-28 13:34:14 +00:00
elseif ( $property [ 'name' ] === 'button' && $repeatable
&& $setCustom )
2016-03-01 18:44:13 +00:00
{
// dont load the button to repeatable
$xmlValue = 'false' ;
2018-03-30 07:58:24 +00:00
// do not add button
$fieldAttributes [ 'custom' ][ 'add_button' ] = 'false' ;
}
elseif ( $property [ 'name' ] === 'button' && $setCustom )
{
2019-05-25 20:20:12 +00:00
// load the button string value if found
2022-03-09 23:46:45 +00:00
$xmlValue = ( string ) StringHelper :: safe (
2022-04-04 15:35:08 +00:00
GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , 'button="' , '"'
)
);
2018-03-30 07:58:24 +00:00
// add to custom values
2020-03-28 13:34:14 +00:00
$fieldAttributes [ 'custom' ][ 'add_button' ]
2022-03-09 23:46:45 +00:00
= ( StringHelper :: check ( $xmlValue )
2020-03-28 13:34:14 +00:00
|| 1 == $xmlValue ) ? $xmlValue : 'false' ;
2016-03-01 18:44:13 +00:00
}
2020-03-28 13:34:14 +00:00
elseif ( $property [ 'name' ] === 'required'
&& 'repeatable' === $typeName )
2016-09-03 21:44:47 +00:00
{
2019-05-25 20:20:12 +00:00
// dont load the required to repeatable field type
2016-09-03 21:44:47 +00:00
$xmlValue = 'false' ;
}
2020-03-28 13:34:14 +00:00
elseif ( $viewType == 2
&& ( $property [ 'name' ] === 'readonly'
|| $property [ 'name' ] === 'disabled' ))
2016-03-01 18:44:13 +00:00
{
// set read only
$xmlValue = 'true' ;
2018-07-21 07:10:37 +00:00
// trip the switch for readonly
if ( $property [ 'name' ] === 'readonly' )
{
$setReadonly = true ;
}
2016-03-01 18:44:13 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $property [ 'name' ] === 'multiple' )
2016-03-01 18:44:13 +00:00
{
2022-04-04 15:35:08 +00:00
$xmlValue = ( string ) GetHelper :: between (
2020-03-28 13:34:14 +00:00
$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
2020-03-28 13:34:14 +00:00
elseif ( $property [ 'name' ] === 'class'
&& ( $typeName === 'note'
|| $typeName === 'spacer' ))
2016-03-01 18:44:13 +00:00
{
2022-04-04 15:35:08 +00:00
$xmlValue = GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , 'class="' , '"'
);
2016-03-01 18:44:13 +00:00
// add the type class
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $xmlValue ))
2016-03-01 18:44:13 +00:00
{
if ( strpos ( $xmlValue , $name ) === false )
{
$xmlValue = $xmlValue . ' ' . $name ;
}
}
else
{
$xmlValue = $name ;
}
}
else
{
// set the rest of the fields
2022-08-30 15:28:41 +00:00
$xmlValue = ( string ) CFactory :: _ ( 'Placeholder' ) -> update (
2022-04-04 15:35:08 +00:00
GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , $property [ 'name' ] . '="' ,
'"'
), $placeholders
);
2016-03-01 18:44:13 +00:00
}
// check if translatable
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $xmlValue )
2020-03-28 13:34:14 +00:00
&& isset ( $property [ 'translatable' ])
&& $property [ 'translatable' ] == 1 )
2016-03-01 18:44:13 +00:00
{
2017-12-03 17:08:01 +00:00
// update label if field use multiple times
2017-03-06 12:06:51 +00:00
if ( $property [ 'name' ] === 'label' )
{
2020-03-28 13:34:14 +00:00
if ( isset ( $fieldAttributes [ 'name' ])
2022-09-10 08:16:44 +00:00
&& CFactory :: _ ( 'Registry' ) -> get ( " unique.names. $nameListCode .names. " . $fieldAttributes [ 'name' ]) !== null )
2017-03-06 12:06:51 +00:00
{
2020-03-28 13:34:14 +00:00
$xmlValue .= ' ('
2022-03-09 23:46:45 +00:00
. StringHelper :: safe (
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Registry' ) -> get ( " unique.names. $nameListCode .names. " . $fieldAttributes [ 'name' ])
2020-03-28 13:34:14 +00:00
) . ')' ;
2017-03-06 12:06:51 +00:00
}
}
2016-03-01 18:44:13 +00:00
// replace placeholders
2022-08-30 15:28:41 +00:00
$xmlValue = CFactory :: _ ( 'Placeholder' ) -> update (
2020-03-28 13:34:14 +00:00
$xmlValue , $placeholders
);
2016-03-01 18:44:13 +00:00
// insure custom lables dont get messed up
if ( $setCustom )
{
$customLabel = $xmlValue ;
}
// set lang key
2020-03-28 13:34:14 +00:00
$langValue = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$name . ' ' . $property [ 'name' ], true
);
2016-03-01 18:44:13 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set ( CFactory :: _ ( 'Config' ) -> lang_target , $langValue , $xmlValue );
2016-03-01 18:44:13 +00:00
// use lang value
$xmlValue = $langValue ;
}
2020-03-28 13:34: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' ;
}
}
2020-03-28 13:34: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' ;
}
}
// only load value if found or is mandatory
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $xmlValue )
2020-03-28 13:34:14 +00:00
|| ( isset ( $property [ 'mandatory' ])
&& $property [ 'mandatory' ] == 1
&& ! $setCustom ))
2016-03-01 18:44:13 +00:00
{
// make sure mantory fields are added
2022-03-09 23:46:45 +00:00
if ( ! StringHelper :: check ( $xmlValue ))
2016-03-01 18:44:13 +00:00
{
2020-03-28 13:34:14 +00:00
if ( isset ( $property [ 'example' ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$property [ 'example' ]
))
2016-03-01 18:44:13 +00:00
{
$xmlValue = $property [ 'example' ];
}
}
// load to langBuilder down the line
2017-02-01 13:17:04 +00:00
if ( $property [ 'name' ] === 'label' )
2016-03-01 18:44:13 +00:00
{
if ( $setCustom )
{
$fieldAttributes [ 'custom' ][ 'label' ] = $customLabel ;
}
2017-03-06 12:06:51 +00:00
$langLabel = $xmlValue ;
2016-03-01 18:44:13 +00:00
}
2017-03-06 12:06:51 +00:00
// now set the value
$fieldAttributes [ $property [ 'name' ]] = $xmlValue ;
2016-03-01 18:44:13 +00:00
}
2018-09-24 14:37:51 +00:00
// validate that the default field is set
2020-03-28 13:34:14 +00:00
elseif ( $property [ 'name' ] === 'default'
&& ( $xmlValidateValue
2022-04-04 15:35:08 +00:00
= GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , 'default="' , '"' , 'none-set'
)) !== 'none-set' )
2018-09-24 14:37:51 +00:00
{
// we must allow empty defaults
$fieldAttributes [ 'default' ] = $xmlValue ;
}
2016-03-01 18:44:13 +00:00
}
2018-10-29 16:38:00 +00:00
// check if all php is loaded using the tracker
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $phpTracker ))
2018-10-29 16:38:00 +00:00
{
// litle search validation
2020-03-28 13:34:14 +00:00
$confirmation
= '8qvZHoyuFYQqpj0YQbc6F3o5DhBlmS-_-a8pmCZfOVSfANjkmV5LG8pCdAY2JNYu6cB' ;
2018-10-29 16:38:00 +00:00
foreach ( $phpTracker as $searchKey => $phpKey )
{
2020-07-13 02:52:06 +00:00
// we must search for more code in the xml just encase
2020-03-28 13:34:14 +00:00
foreach ( range ( 2 , 30 ) as $phpLine )
2018-10-29 16:38:00 +00:00
{
$get_ = $searchKey . '_' . $phpLine ;
2020-03-28 13:34:14 +00:00
if ( ! isset ( $fieldAttributes [ 'custom' ][ $phpKey ][ $phpLine ])
&& ( $value
= ComponentbuilderHelper :: getValueFromXMLstring (
$field [ 'settings' ] -> xml , $get_ , $confirmation
)) !== $confirmation )
2018-10-29 16:38:00 +00:00
{
2020-03-28 13:34:14 +00:00
$fieldAttributes [ 'custom' ][ $phpKey ][ $phpLine ]
2022-09-03 10:48:53 +00:00
= CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: openValidBase64 ( $value )
);
2018-10-29 16:38:00 +00:00
}
}
}
}
2016-03-01 18:44:13 +00:00
// do some nice twigs beyond the default
if ( isset ( $fieldAttributes [ 'name' ]))
{
2018-02-27 12:17:38 +00:00
// check if we have class value for the list view of this field
2022-04-04 15:35:08 +00:00
$listclass = GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , 'listclass="' , '"'
);
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $listclass ))
2018-02-27 12:17:38 +00:00
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.list_field_class.' . $nameListCode . '.' . $fieldAttributes [ 'name' ], $listclass );
2018-02-27 12:17:38 +00:00
}
2016-03-01 18:44:13 +00:00
// check if we find reason to remove this field from being escaped
2022-04-04 15:35:08 +00:00
$escaped = GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , 'escape="' , '"'
);
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $escaped ))
2016-03-01 18:44:13 +00:00
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.do_not_escape.' .
$nameListCode . '.' . $fieldAttributes [ 'name' ], true );
2016-03-01 18:44:13 +00:00
}
2022-03-09 23:46:45 +00:00
// check if we have display switch for dynamic placement
2022-04-04 15:35:08 +00:00
$display = GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , 'display="' , '"'
);
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $display ))
2017-07-20 23:26:48 +00:00
{
$fieldAttributes [ 'display' ] = $display ;
}
2018-03-27 09:57:16 +00:00
// make sure validation is set if found (even it not part of field properties)
if ( ! isset ( $fieldAttributes [ 'validate' ]))
{
// check if we have validate (validation rule set)
2022-04-04 15:35:08 +00:00
$validationRule = GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , 'validate="' , '"'
);
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $validationRule ))
2018-03-27 09:57:16 +00:00
{
2020-03-28 13:34:14 +00:00
$fieldAttributes [ 'validate' ]
2022-03-09 23:46:45 +00:00
= StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$validationRule
);
2018-03-27 09:57:16 +00:00
}
}
2018-07-21 07:10:37 +00:00
// make sure ID is always readonly
if ( $fieldAttributes [ 'name' ] === 'id' && ! $setReadonly )
{
$fieldAttributes [ 'readonly' ] = 'true' ;
}
2016-03-01 18:44:13 +00:00
}
}
2020-03-28 13:34:14 +00:00
2016-03-01 18:44:13 +00:00
return $fieldAttributes ;
}
2016-03-04 00:01:43 +00:00
/**
2016-03-01 18:44:13 +00:00
* set Builders
2017-12-03 17:08:01 +00:00
*
2020-11-26 17:33:39 +00:00
* @ param string $langLabel The language string for field label
* @ param string $langView The language string of the view
* @ param string $nameSingleCode The single view name
* @ param string $nameListCode The list view name
* @ param string $name The field name
* @ param array $view The view data
* @ param array $field The field data
* @ param string $typeName The field type
* @ param boolean $multiple The switch to set multiple selection option
* @ param boolean $custom The custom field switch
* @ param boolean $options The options switch
2016-03-01 18:44:13 +00:00
*
* @ return void
2017-12-03 17:08:01 +00:00
*
2016-03-01 18:44:13 +00:00
*/
2020-11-26 17:33:39 +00:00
public function setBuilders ( $langLabel , $langView , $nameSingleCode ,
2023-05-02 00:10:55 +00:00
$nameListCode , $name , $view , $field , $typeName , $multiple ,
$custom = false , $options = false
2020-03-28 13:34:14 +00:00
) {
2021-05-19 15:44:14 +00:00
// check if this is a tag field
if ( $typeName === 'tag' )
{
// set tags for this view but don't load to DB
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.tags.' . $nameSingleCode , true );
2021-05-19 15:44:14 +00:00
}
2018-04-13 15:24:06 +00:00
// dbSwitch
$dbSwitch = true ;
if ( isset ( $field [ 'list' ]) && $field [ 'list' ] == 2 )
{
// do not add this field to the database
$dbSwitch = false ;
}
2018-04-23 00:42:41 +00:00
elseif ( isset ( $field [ 'settings' ] -> datatype ))
2016-03-01 18:44:13 +00:00
{
// insure default not none if number type
2020-03-28 13:34:14 +00:00
$numberKeys = array ( 'INT' , 'TINYINT' , 'BIGINT' , 'FLOAT' , 'DECIMAL' ,
2023-05-02 00:10:55 +00:00
'DOUBLE' );
2020-02-09 11:13:42 +00:00
// don't use these as index or uniqe keys
2020-03-28 13:34:14 +00:00
$textKeys = array ( 'TEXT' , 'TINYTEXT' , 'MEDIUMTEXT' , 'LONGTEXT' ,
2023-05-02 00:10:55 +00:00
'BLOB' , 'TINYBLOB' , 'MEDIUMBLOB' , 'LONGBLOB' );
2020-02-09 11:13:42 +00:00
// build the query values
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.database_tables.' . $nameSingleCode . '.' . $name . '.type' ,
$field [ 'settings' ] -> datatype );
2020-02-09 11:13:42 +00:00
// check if this is a number
if ( in_array ( $field [ 'settings' ] -> datatype , $numberKeys ))
2016-03-01 18:44:13 +00:00
{
2017-02-01 13:17:04 +00:00
if ( $field [ 'settings' ] -> datadefault === 'Other' )
2016-03-01 18:44:13 +00:00
{
2020-02-09 11:13:42 +00:00
// setup the checking
$number_check = $field [ 'settings' ] -> datadefault_other ;
// Decimals in SQL needs some help
2020-03-28 13:34:14 +00:00
if ( 'DECIMAL' === $field [ 'settings' ] -> datatype
&& ! is_numeric ( $number_check ))
2020-02-09 11:13:42 +00:00
{
2020-03-28 13:34:14 +00:00
$number_check = str_replace (
2023-01-01 02:11:34 +00:00
',' , '.' , ( string ) $field [ 'settings' ] -> datadefault_other
2020-03-28 13:34:14 +00:00
);
2020-02-09 11:13:42 +00:00
}
// check if we have a valid number value
if ( ! is_numeric ( $number_check ))
2016-03-01 18:44:13 +00:00
{
$field [ 'settings' ] -> datadefault_other = '0' ;
}
}
elseif ( ! is_numeric ( $field [ 'settings' ] -> datadefault ))
{
$field [ 'settings' ] -> datadefault = '0' ;
}
}
2020-02-09 11:13:42 +00:00
// check if this is not text
2017-12-03 17:08:01 +00:00
if ( ! in_array ( $field [ 'settings' ] -> datatype , $textKeys ))
2016-09-03 21:44:47 +00:00
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.database_tables.' . $nameSingleCode . '.' . $name . '.lenght' ,
$field [ 'settings' ] -> datalenght );
CFactory :: _ ( 'Registry' ) -> set ( 'builder.database_tables.' . $nameSingleCode . '.' . $name . '.lenght_other' ,
$field [ 'settings' ] -> datalenght_other );
CFactory :: _ ( 'Registry' ) -> set ( 'builder.database_tables.' . $nameSingleCode . '.' . $name . '.default' ,
$field [ 'settings' ] -> datadefault );
CFactory :: _ ( 'Registry' ) -> set ( 'builder.database_tables.' . $nameSingleCode . '.' . $name . '.other' ,
$field [ 'settings' ] -> datadefault_other );
2016-03-01 18:44:13 +00:00
}
2020-02-09 11:13:42 +00:00
// fall back unto EMPTY for text
2017-12-03 08:02:11 +00:00
else
2016-03-01 18:44:13 +00:00
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.database_tables.' . $nameSingleCode . '.' . $name . '.default' ,
'EMPTY' );
2017-12-03 17:08:01 +00:00
}
2017-06-29 21:03:53 +00:00
// to identify the field
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.database_tables.' . $nameSingleCode . '.' . $name . '.ID' ,
$field [ 'settings' ] -> id );
CFactory :: _ ( 'Registry' ) -> set ( 'builder.database_tables.' . $nameSingleCode . '.' . $name . '.null_switch' ,
$field [ 'settings' ] -> null_switch );
2016-03-01 18:44:13 +00:00
// set index types
2020-05-25 00:38:16 +00:00
$_guid = true ;
2020-03-28 13:34:14 +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
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> appendArray ( 'builder.database_unique_keys.' . $nameSingleCode , $name );
2020-05-25 00:38:16 +00:00
// prevent guid from being added twice
if ( 'guid' === $name )
{
$_guid = false ;
}
2016-03-01 18:44:13 +00:00
}
2020-03-28 13:34:14 +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
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> appendArray ( 'builder.database_keys.' . $nameSingleCode , $name );
2016-03-01 18:44:13 +00:00
}
2020-05-25 00:38:16 +00:00
// special treatment for GUID
if ( 'guid' === $name && $_guid )
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.database_unique_guid.' . $nameSingleCode , true );
2020-05-25 00:38:16 +00:00
}
2016-03-01 18:44:13 +00:00
}
2018-05-24 13:56:56 +00:00
// set list switch
2020-03-28 13:34:14 +00:00
$listSwitch = ( isset ( $field [ 'list' ])
&& ( $field [ 'list' ] == 1
|| $field [ 'list' ] == 3
|| $field [ 'list' ] == 4 ));
2018-05-24 13:56:56 +00:00
// set list join
2020-03-28 13:34:14 +00:00
$listJoin
2022-09-10 08:16:44 +00:00
= CFactory :: _ ( 'Registry' ) -> exists ( 'builder.list_join.' . $nameListCode . '.' . ( int ) $field [ 'field' ]);
2016-03-01 18:44:13 +00:00
// add history to this view
2017-10-30 13:08:02 +00:00
if ( isset ( $view [ 'history' ]) && $view [ 'history' ])
2016-03-01 18:44:13 +00:00
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.history.' . $nameSingleCode , true );
2016-03-01 18:44:13 +00:00
}
// set Alias (only one title per view)
2020-03-28 13:34:14 +00:00
if ( $dbSwitch && isset ( $field [ 'alias' ]) && $field [ 'alias' ]
2023-05-02 00:10:55 +00:00
&& ! CFactory :: _ ( 'Registry' ) -> get ( 'builder.alias.' . $nameSingleCode ))
2016-03-01 18:44:13 +00:00
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.alias.' . $nameSingleCode , $name );
2016-03-01 18:44:13 +00:00
}
// set Titles (only one title per view)
2020-03-28 13:34:14 +00:00
if ( $dbSwitch && isset ( $field [ 'title' ]) && $field [ 'title' ]
2023-05-02 00:10:55 +00:00
&& ! CFactory :: _ ( 'Registry' ) -> get ( 'builder.title.' . $nameSingleCode ))
2016-03-01 18:44:13 +00:00
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.title.' . $nameSingleCode , $name );
2016-03-01 18:44:13 +00:00
}
// category name fix
2017-02-01 13:17:04 +00:00
if ( $typeName === 'category' )
2016-03-01 18:44:13 +00:00
{
2022-09-10 08:16:44 +00:00
if ( CFactory :: _ ( 'Registry' ) -> get ( 'category.other.name.' . $nameListCode . '.name' ))
2016-03-01 18:44:13 +00:00
{
2022-09-10 08:16:44 +00:00
$tempName = CFactory :: _ ( 'Registry' ) -> get ( 'category.other.name.' . $nameListCode . '.name' );
2016-03-01 18:44:13 +00:00
}
else
{
2020-11-26 17:33:39 +00:00
$tempName = $nameListCode . ' categories' ;
2016-03-01 18:44:13 +00:00
}
// set lang
2020-03-28 13:34:14 +00:00
$listLangName = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe ( $tempName , true );
2020-11-30 03:59:45 +00:00
// set field name
2022-03-09 23:46:45 +00:00
$listFieldName = StringHelper :: safe ( $tempName , 'W' );
2016-03-01 18:44:13 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $listLangName , $listFieldName
2020-03-28 13:34:14 +00:00
);
2016-03-01 18:44:13 +00:00
}
else
{
// if label was set use instead
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $langLabel ))
2016-03-01 18:44:13 +00:00
{
$listLangName = $langLabel ;
2021-01-30 13:36:03 +00:00
// get field label from the lang label
2022-08-30 15:28:41 +00:00
if ( CFactory :: _ ( 'Language' ) -> exist ( CFactory :: _ ( 'Config' ) -> lang_target , $langLabel ))
2021-01-30 13:36:03 +00:00
{
$listFieldName
2022-08-30 15:28:41 +00:00
= CFactory :: _ ( 'Language' ) -> get ( CFactory :: _ ( 'Config' ) -> lang_target , $langLabel );
2021-01-30 13:36:03 +00:00
}
else
{
// get it from the field xml string
2022-12-11 15:06:13 +00:00
$listFieldName = ( string ) CFactory :: _ ( 'Placeholder' ) -> update_ (
2022-04-04 15:35:08 +00:00
GetHelper :: between (
2021-01-30 13:36:03 +00:00
$field [ 'settings' ] -> xml , 'label="' ,
'"'
2022-12-11 15:06:13 +00:00
)
2021-01-30 13:36:03 +00:00
);
}
// make sure there is no html in the list field name
$listFieldName = strip_tags ( $listFieldName );
}
else
{
// set lang (just in case)
$listLangName = $langView . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe ( $name , true );
2021-01-30 13:36:03 +00:00
// set field name
2022-03-09 23:46:45 +00:00
$listFieldName = StringHelper :: safe ( $name , 'W' );
2021-01-30 13:36:03 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $listLangName , $listFieldName
2021-01-30 13:36:03 +00:00
);
2016-03-01 18:44:13 +00:00
}
}
// build the list values
2020-03-28 13:34:14 +00:00
if (( $listSwitch || $listJoin ) && $typeName != 'repeatable'
&& $typeName != 'subform' )
2016-03-01 18:44:13 +00:00
{
// load to list builder
2018-05-24 13:56:56 +00:00
if ( $listSwitch )
{
2022-09-10 08:16:44 +00:00
// append values
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Registry' ) -> appendArray ( 'builder.list.' . $nameListCode , [
2020-03-28 13:34:14 +00:00
'id' => ( int ) $field [ 'field' ],
'type' => $typeName ,
'code' => $name ,
'lang' => $listLangName ,
'title' => ( isset ( $field [ 'title' ]) && $field [ 'title' ])
? true : false ,
'alias' => ( isset ( $field [ 'alias' ]) && $field [ 'alias' ])
? true : false ,
'link' => ( isset ( $field [ 'link' ]) && $field [ 'link' ])
? true : false ,
'sort' => ( isset ( $field [ 'sort' ]) && $field [ 'sort' ])
? true : false ,
'custom' => $custom ,
2018-05-24 13:56:56 +00:00
'multiple' => $multiple ,
2020-03-28 13:34:14 +00:00
'options' => $options ,
2022-09-10 08:16:44 +00:00
'target' => ( int ) $field [ 'list' ]
]);
2018-05-24 13:56:56 +00:00
}
// build custom builder list
if ( $listSwitch || $listJoin )
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.custom_list.' . $nameSingleCode . '.' . $name , true );
2018-05-24 13:56:56 +00:00
}
2016-03-01 18:44:13 +00:00
}
2018-05-26 10:03:08 +00:00
// load the list join builder
if ( $listJoin )
{
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.list_join.' . $nameListCode . '.' . ( int ) $field [ 'field' ], [
2020-03-28 13:34:14 +00:00
'type' => $typeName ,
'code' => $name ,
'lang' => $listLangName ,
'title' => ( isset ( $field [ 'title' ]) && $field [ 'title' ]) ? true
: false ,
'alias' => ( isset ( $field [ 'alias' ]) && $field [ 'alias' ]) ? true
: false ,
'link' => ( isset ( $field [ 'link' ]) && $field [ 'link' ]) ? true
: false ,
'sort' => ( isset ( $field [ 'sort' ]) && $field [ 'sort' ]) ? true
: false ,
'custom' => $custom ,
2018-05-26 10:03:08 +00:00
'multiple' => $multiple ,
2022-09-10 08:16:44 +00:00
'options' => $options
]);
2018-05-26 10:03:08 +00:00
}
// update the field relations
2022-09-10 08:16:44 +00:00
if (( $field_relations =
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> get ( 'builder.field_relations.' . $nameListCode . '.' . ( int ) $field [ 'field' ])) !== null )
2018-05-26 10:03:08 +00:00
{
2022-09-10 08:16:44 +00:00
$field_relations = ( array ) $field_relations ;
foreach ( $field_relations as $area => & $field_values )
2018-07-21 07:10:37 +00:00
{
2020-03-28 13:34:14 +00:00
$field_values [ 'type' ] = $typeName ;
$field_values [ 'code' ] = $name ;
2018-07-21 07:10:37 +00:00
$field_values [ 'custom' ] = $custom ;
}
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.field_relations.' . $nameListCode . '.' . ( int ) $field [ 'field' ], $field_relations );
2018-05-26 10:03:08 +00:00
}
2016-03-01 18:44:13 +00:00
// set the hidden field of this view
2020-12-24 13:39:33 +00:00
if ( $dbSwitch && $typeName === 'hidden' )
2016-03-01 18:44:13 +00:00
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> appendArray ( 'builder.hidden_fields.' . $nameSingleCode , ',"' . $name . '"' );
2016-03-01 18:44:13 +00:00
}
// set all int fields of this view
2020-03-28 13:34:14 +00:00
if ( $dbSwitch && isset ( $field [ 'settings' ] -> datatype )
&& ( $field [ 'settings' ] -> datatype === 'INT'
|| $field [ 'settings' ] -> datatype === 'TINYINT'
|| $field [ 'settings' ] -> datatype === 'BIGINT' ))
2016-03-01 18:44:13 +00:00
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> appendArray ( 'builder.integer_fields.' . $nameSingleCode , ',"' . $name . '"' );
2016-03-01 18:44:13 +00:00
}
2023-01-15 08:42:19 +00:00
// Get the default fields
$default_fields = CFactory :: _ ( 'Config' ) -> default_fields ;
2016-03-01 18:44:13 +00:00
// set all dynamic field of this view
2020-12-24 13:39:33 +00:00
if ( $dbSwitch && $typeName != 'category' && $typeName != 'repeatable'
2023-05-02 00:10:55 +00:00
&& $typeName != 'subform' && ! in_array ( $name , $default_fields ))
2016-03-01 18:44:13 +00:00
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> appendArray ( 'builder.dynamic_fields.' . $nameSingleCode , '"' . $name . '":"' . $name . '"' );
2016-03-01 18:44:13 +00:00
}
// TODO we may need to add a switch instead (since now it uses the first editor field)
// set the main(biggest) text field of this view
2018-04-13 15:24:06 +00:00
if ( $dbSwitch && $typeName === 'editor' )
2016-03-01 18:44:13 +00:00
{
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> exists ( 'builder.main_text_field.' . $nameSingleCode ))
2016-03-01 18:44:13 +00:00
{
2023-05-02 00:10:55 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.main_text_field.' . $nameSingleCode , $name );
2016-03-01 18:44:13 +00:00
}
}
// set the custom builder
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $custom )
2020-03-28 13:34:14 +00:00
&& $typeName != 'category'
&& $typeName != 'repeatable'
&& $typeName != 'subform' )
2016-03-01 18:44:13 +00:00
{
2020-11-26 17:33:39 +00:00
$this -> customBuilder [ $nameListCode ][] = array ( 'type' => $typeName ,
2023-05-02 00:10:55 +00:00
'code' => $name ,
'lang' => $listLangName ,
'custom' => $custom ,
'method' => $field [ 'settings' ] -> store );
2016-10-23 22:48:26 +00:00
// only load this if table is set
2020-03-28 13:34:14 +00:00
if ( isset ( $custom [ 'table' ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$custom [ 'table' ]
))
2016-10-23 22:48:26 +00:00
{
2023-05-02 00:10:55 +00:00
// set the custom fields needed in content type data
CFactory :: _ ( 'Registry' ) -> appendArray ( 'builder.custom_field_links.' . $nameSingleCode , ',{"sourceColumn": "'
. $name . '","targetTable": "' . $custom [ 'table' ] . '","targetColumn": "' . $custom [ 'id' ]
. '","displayColumn": "' . $custom [ 'text' ] . '"}' );
2016-10-23 22:48:26 +00:00
}
2016-03-01 18:44:13 +00:00
// build script switch for user
2017-02-01 13:17:04 +00:00
if ( $custom [ 'extends' ] === 'user' )
2016-03-01 18:44:13 +00:00
{
$this -> setScriptUserSwitch [ $typeName ] = $typeName ;
}
}
2017-02-01 13:17:04 +00:00
if ( $typeName === 'media' )
2016-03-01 18:44:13 +00:00
{
$this -> setScriptMediaSwitch [ $typeName ] = $typeName ;
}
2020-05-30 18:49:13 +00:00
// setup category for this view
2018-04-13 15:24:06 +00:00
if ( $dbSwitch && $typeName === 'category' )
2016-03-01 18:44:13 +00:00
{
2022-09-10 08:16:44 +00:00
if ( CFactory :: _ ( 'Registry' ) -> get ( 'category.other.name.' . $nameListCode . '.view' )
&& CFactory :: _ ( 'Registry' ) -> get ( 'category.other.name.' . $nameListCode . '.views' ))
2016-03-01 18:44:13 +00:00
{
2022-09-10 08:16:44 +00:00
$otherViews = CFactory :: _ ( 'Registry' ) -> get ( 'category.other.name.' . $nameListCode . '.views' );
$otherView = CFactory :: _ ( 'Registry' ) -> get ( 'category.other.name.' . $nameListCode . '.view' );
2016-03-01 18:44:13 +00:00
}
else
{
2020-11-26 17:33:39 +00:00
$otherViews = $nameListCode ;
$otherView = $nameSingleCode ;
2016-03-01 18:44:13 +00:00
}
2019-05-06 01:05:15 +00:00
// get the xml extension name
2022-12-11 15:06:13 +00:00
$_extension = CFactory :: _ ( 'Placeholder' ) -> update_ (
2022-04-04 15:35:08 +00:00
GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml , 'extension="' , '"'
2022-12-11 15:06:13 +00:00
)
2020-03-28 13:34:14 +00:00
);
2020-05-30 18:49:13 +00:00
// if they left out the extension for some reason
2022-03-09 23:46:45 +00:00
if ( ! StringHelper :: check ( $_extension ))
2019-06-09 21:19:34 +00:00
{
2022-08-30 15:28:41 +00:00
$_extension = 'com_' . CFactory :: _ ( 'Config' ) -> component_code_name . '.'
2020-03-28 13:34:14 +00:00
. $otherView ;
2019-06-09 21:19:34 +00:00
}
2020-05-30 18:49:13 +00:00
// check the context (does our target match)
2023-01-01 02:11:34 +00:00
if ( strpos (( string ) $_extension , '.' ) !== false )
2020-05-30 18:49:13 +00:00
{
2023-01-01 02:11:34 +00:00
$target_view = trim ( explode ( '.' , ( string ) $_extension )[ 1 ]);
2020-05-30 18:49:13 +00:00
// from my understanding the target extension view and the otherView must align
// so I will here check that it does, and if not raise an error message to fix this
if ( $target_view !== $otherView )
{
2023-01-01 02:11:34 +00:00
$target_extension = trim ( explode ( '.' , ( string ) $_extension )[ 0 ]);
2020-07-07 15:13:04 +00:00
$correction = $target_extension . '.' . $otherView ;
2020-05-30 18:49:13 +00:00
$this -> app -> enqueueMessage (
2020-07-07 15:13:04 +00:00
JText :: sprintf (
' < hr />< h3 > Category targeting view mismatch </ h3 >
2020-08-13 01:03:56 +00:00
< p > The < a href = " index.php?option=com_componentbuilder&view=fields&task=field.edit&id=%s " target = " _blank " title = " open field " >
2020-05-30 18:49:13 +00:00
category field </ a > in < b > ( % s ) admin view </ b > has a mismatching target view .
< br /> To correct the mismatch , the < b > extension </ b > value < code >% s </ code > in the < a href = " index.php?option=com_componentbuilder&view=fields&task=field.edit&id=%s " target = " _blank " title = " open category field " >
field </ a > must be changed to < code >% s </ code >
for < a href = " https://github.com/vdm-io/Joomla-Component-Builder/issues/561 " target = " _blank " title = " view issue on gitHub " >
best category integration with Joomla </ a >.
< br />< b > Please watch < a href = " https://youtu.be/R4WQgcu6Xns " target = " _blank " title = " very important info on the topic " >
this tutorial </ a > before proceeding !!!</ b > ,
2020-07-07 15:13:04 +00:00
< a href = " https://gist.github.com/Llewellynvdm/e053dc39ae3b2bf769c76a3e62c75b95 " target = " _blank " title = " first watch the tutorial to understand how to use this code " > code fix </ a ></ p > ' ,
2020-11-26 17:33:39 +00:00
$field [ 'field' ], $nameSingleCode , $_extension ,
2020-07-07 15:13:04 +00:00
$field [ 'field' ], $correction
), 'Error'
2020-05-30 18:49:13 +00:00
);
}
}
// load the category builder - TODO must move all to single view
2020-11-26 17:33:39 +00:00
$this -> categoryBuilder [ $nameListCode ] = array ( 'code' => $name ,
2023-05-02 00:10:55 +00:00
'name' => $listLangName ,
'extension' => $_extension ,
'filter' => $field [ 'filter' ]);
2016-03-01 18:44:13 +00:00
// also set code name for title alias fix
2020-11-26 17:33:39 +00:00
$this -> catCodeBuilder [ $nameSingleCode ] = array ( 'code' => $name ,
2023-05-02 00:10:55 +00:00
'views' => $otherViews ,
'view' => $otherView );
2016-03-01 18:44:13 +00:00
}
// setup checkbox for this view
2020-03-28 13:34:14 +00:00
if ( $dbSwitch
&& ( $typeName === 'checkbox'
2022-03-09 23:46:45 +00:00
|| ( ArrayHelper :: check ( $custom )
2020-03-28 13:34:14 +00:00
&& isset ( $custom [ 'extends' ])
&& $custom [ 'extends' ] === 'checkboxes' )))
2016-03-01 18:44:13 +00:00
{
2020-11-26 17:33:39 +00:00
$this -> checkboxBuilder [ $nameSingleCode ][] = $name ;
2016-03-01 18:44:13 +00:00
}
// setup checkboxes and other json items for this view
2020-03-28 13:34:14 +00:00
// if we have advance field modeling and the field is not being set in the DB
// this could mean that field is modeled manually (so we add it)
if (( $dbSwitch || $field [ 'settings' ] -> store == 6 )
&& (( $typeName === 'subform' || $typeName === 'checkboxes'
|| $multiple
|| $field [ 'settings' ] -> store != 0 )
&& $typeName != 'tag' ))
2016-03-01 18:44:13 +00:00
{
2018-04-30 12:06:05 +00:00
$subformJsonSwitch = true ;
2016-03-01 18:44:13 +00:00
switch ( $field [ 'settings' ] -> store )
{
case 1 :
// JSON_STRING_ENCODE
2020-11-26 17:33:39 +00:00
$this -> jsonStringBuilder [ $nameSingleCode ][] = $name ;
2016-03-01 18:44:13 +00:00
// Site settings of each field if needed
2020-03-28 13:34:14 +00:00
$this -> buildSiteFieldData (
2020-11-26 17:33:39 +00:00
$nameSingleCode , $name , 'json' , $typeName
2020-03-28 13:34:14 +00:00
);
2022-09-14 15:40:02 +00:00
// add open close method to field data
$field [ 'store' ] = 'json' ;
2016-03-01 18:44:13 +00:00
break ;
case 2 :
// BASE_SIXTY_FOUR
2020-11-26 17:33:39 +00:00
$this -> base64Builder [ $nameSingleCode ][] = $name ;
2016-03-01 18:44:13 +00:00
// Site settings of each field if needed
2020-03-28 13:34:14 +00:00
$this -> buildSiteFieldData (
2020-11-26 17:33:39 +00:00
$nameSingleCode , $name , 'base64' , $typeName
2020-03-28 13:34:14 +00:00
);
2022-09-14 15:40:02 +00:00
// add open close method to field data
$field [ 'store' ] = 'base64' ;
2016-03-01 18:44:13 +00:00
break ;
case 3 :
// BASIC_ENCRYPTION_LOCALKEY
2020-11-26 17:33:39 +00:00
$this -> basicFieldModeling [ $nameSingleCode ][] = $name ;
2016-03-01 18:44:13 +00:00
// Site settings of each field if needed
2020-03-28 13:34:14 +00:00
$this -> buildSiteFieldData (
2020-11-26 17:33:39 +00:00
$nameSingleCode , $name , 'basic_encryption' , $typeName
2020-03-28 13:34:14 +00:00
);
2022-09-14 15:40:02 +00:00
// add open close method to field data
$field [ 'store' ] = 'basic_encryption' ;
2016-03-01 18:44:13 +00:00
break ;
case 4 :
2021-08-11 12:15:35 +00:00
// WHMCS_ENCRYPTION_VDMKEY (DUE REMOVAL)
2020-11-26 17:33:39 +00:00
$this -> whmcsFieldModeling [ $nameSingleCode ][] = $name ;
2018-03-06 02:28:44 +00:00
// Site settings of each field if needed
2020-03-28 13:34:14 +00:00
$this -> buildSiteFieldData (
2020-11-26 17:33:39 +00:00
$nameSingleCode , $name , 'whmcs_encryption' , $typeName
2020-03-28 13:34:14 +00:00
);
2022-09-14 15:40:02 +00:00
// add open close method to field data
$field [ 'store' ] = 'whmcs_encryption' ;
2018-03-06 02:28:44 +00:00
break ;
case 5 :
// MEDIUM_ENCRYPTION_LOCALFILE
2020-11-26 17:33:39 +00:00
$this -> mediumFieldModeling [ $nameSingleCode ][] = $name ;
2016-03-01 18:44:13 +00:00
// Site settings of each field if needed
2020-03-28 13:34:14 +00:00
$this -> buildSiteFieldData (
2020-11-26 17:33:39 +00:00
$nameSingleCode , $name , 'medium_encryption' , $typeName
2020-03-28 13:34:14 +00:00
);
2022-09-14 15:40:02 +00:00
// add open close method to field data
$field [ 'store' ] = 'medium_encryption' ;
2016-03-01 18:44:13 +00:00
break ;
2019-10-16 20:34:36 +00:00
case 6 :
// EXPERT_MODE
2020-03-28 13:34:14 +00:00
if ( isset ( $field [ 'settings' ] -> model_field ))
2019-10-16 20:34:36 +00:00
{
if ( isset ( $field [ 'settings' ] -> initiator_save_key ))
{
2020-11-26 17:33:39 +00:00
$this -> expertFieldModelInitiator [ $nameSingleCode ][ 'save' ][ $field [ 'settings' ] -> initiator_save_key ]
2019-10-16 20:34:36 +00:00
= $field [ 'settings' ] -> initiator_save ;
}
if ( isset ( $field [ 'settings' ] -> initiator_get_key ))
{
2020-11-26 17:33:39 +00:00
$this -> expertFieldModelInitiator [ $nameSingleCode ][ 'get' ][ $field [ 'settings' ] -> initiator_get_key ]
2019-10-16 20:34:36 +00:00
= $field [ 'settings' ] -> initiator_get ;
}
2020-11-26 17:33:39 +00:00
$this -> expertFieldModeling [ $nameSingleCode ][ $name ]
2020-03-28 13:34:14 +00:00
= $field [ 'settings' ] -> model_field ;
2019-10-16 20:34:36 +00:00
// Site settings of each field if needed
2020-03-28 13:34:14 +00:00
$this -> buildSiteFieldData (
2020-11-26 17:33:39 +00:00
$nameSingleCode , $name , 'expert_mode' , $typeName
2020-03-28 13:34:14 +00:00
);
2019-10-16 20:34:36 +00:00
}
break ;
2016-03-01 18:44:13 +00:00
default :
// JSON_ARRAY_ENCODE
2020-11-26 17:33:39 +00:00
$this -> jsonItemBuilder [ $nameSingleCode ][] = $name ;
2016-03-01 18:44:13 +00:00
// Site settings of each field if needed
2020-03-28 13:34:14 +00:00
$this -> buildSiteFieldData (
2020-11-26 17:33:39 +00:00
$nameSingleCode , $name , 'json' , $typeName
2020-03-28 13:34:14 +00:00
);
2018-04-30 12:06:05 +00:00
// no londer add the json again (already added)
$subformJsonSwitch = false ;
2022-09-14 15:40:02 +00:00
// add open close method to field data
$field [ 'store' ] = 'json' ;
2016-03-01 18:44:13 +00:00
break ;
}
// just a heads-up for usergroups set to multiple
2017-02-01 13:17:04 +00:00
if ( $typeName === 'usergroup' )
2016-03-01 18:44:13 +00:00
{
2020-03-28 13:34:14 +00:00
$this -> buildSiteFieldData (
2020-11-26 17:33:39 +00:00
$nameSingleCode , $name , 'json' , $typeName
2020-03-28 13:34:14 +00:00
);
2016-03-01 18:44:13 +00:00
}
2019-11-08 16:07:08 +00:00
// load the model list display fix
2020-03-28 13:34:14 +00:00
if (( $listSwitch || $listJoin )
&& (( $typeName != 'repeatable'
&& $typeName != 'subform' )
|| $field [ 'settings' ] -> store == 6 ))
2016-03-01 18:44:13 +00:00
{
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $options ))
2016-03-01 18:44:13 +00:00
{
2020-11-26 17:33:39 +00:00
$this -> getItemsMethodListStringFixBuilder [ $nameSingleCode ][]
2020-03-28 13:34:14 +00:00
= array ( 'name' => $name , 'type' => $typeName ,
2023-05-02 00:10:55 +00:00
'translation' => true , 'custom' => $custom ,
'method' => $field [ 'settings' ] -> store );
2016-03-01 18:44:13 +00:00
}
else
{
2020-11-26 17:33:39 +00:00
$this -> getItemsMethodListStringFixBuilder [ $nameSingleCode ][]
2020-03-28 13:34:14 +00:00
= array ( 'name' => $name , 'type' => $typeName ,
2023-05-02 00:10:55 +00:00
'translation' => false , 'custom' => $custom ,
'method' => $field [ 'settings' ] -> store );
2016-03-01 18:44:13 +00:00
}
}
2017-12-03 17:08:01 +00:00
2020-02-27 21:05:28 +00:00
// subform house keeping (only if not advance modeling)
if ( 'subform' === $typeName && $field [ 'settings' ] -> store != 6 )
2017-06-18 07:37:48 +00:00
{
2018-04-30 12:06:05 +00:00
// the values must revert to array
2020-11-26 17:33:39 +00:00
$this -> jsonItemBuilderArray [ $nameSingleCode ][] = $name ;
2018-04-30 12:06:05 +00:00
// should the json builder still be added
if ( $subformJsonSwitch )
{
// and insure the if is converted to json
2020-11-26 17:33:39 +00:00
$this -> jsonItemBuilder [ $nameSingleCode ][] = $name ;
2018-04-30 12:06:05 +00:00
// Site settings of each field if needed
2020-03-28 13:34:14 +00:00
$this -> buildSiteFieldData (
2020-11-26 17:33:39 +00:00
$nameSingleCode , $name , 'json' , $typeName
2020-03-28 13:34:14 +00:00
);
2018-04-30 12:06:05 +00:00
}
2017-06-18 07:37:48 +00:00
}
2016-03-01 18:44:13 +00:00
}
2017-02-01 13:17:04 +00:00
// build the data for the export & import methods $typeName === 'repeatable' ||
2020-03-28 13:34:14 +00:00
if ( $dbSwitch
&& (( $typeName === 'checkboxes' || $multiple
|| $field [ 'settings' ] -> store != 0 )
2022-03-09 23:46:45 +00:00
&& ! ArrayHelper :: check ( $options )))
2016-03-01 18:44:13 +00:00
{
2020-11-26 17:33:39 +00:00
$this -> getItemsMethodEximportStringFixBuilder [ $nameSingleCode ][]
2020-03-28 13:34:14 +00:00
= array ( 'name' => $name , 'type' => $typeName ,
2023-05-02 00:10:55 +00:00
'translation' => false , 'custom' => $custom ,
'method' => $field [ 'settings' ] -> store );
2016-03-01 18:44:13 +00:00
}
// check if field should be added to uikit
2020-11-26 17:33:39 +00:00
$this -> buildSiteFieldData ( $nameSingleCode , $name , 'uikit' , $typeName );
2016-03-01 18:44:13 +00:00
// load the selection translation fix
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $options )
2020-03-28 13:34:14 +00:00
&& ( $listSwitch
|| $listJoin )
&& $typeName != 'repeatable'
&& $typeName != 'subform' )
2016-03-01 18:44:13 +00:00
{
2020-11-26 17:33:39 +00:00
$this -> selectionTranslationFixBuilder [ $nameListCode ][ $name ]
2020-03-28 13:34:14 +00:00
= $options ;
2016-03-01 18:44:13 +00:00
}
2020-11-30 03:59:45 +00:00
// main lang filter prefix
2022-08-30 15:28:41 +00:00
$lang_filter_ = CFactory :: _ ( 'Config' ) -> lang_prefix . '_FILTER_' ;
2016-03-01 18:44:13 +00:00
// build the sort values
2020-03-28 13:34:14 +00:00
if ( $dbSwitch && ( isset ( $field [ 'sort' ]) && $field [ 'sort' ] == 1 )
&& ( $listSwitch || $listJoin )
&& ( ! $multiple && $typeName != 'checkbox'
&& $typeName != 'checkboxes'
&& $typeName != 'repeatable'
&& $typeName != 'subform' ))
2016-03-01 18:44:13 +00:00
{
2020-11-30 03:59:45 +00:00
// add the language only for new filter option
2020-11-30 15:30:10 +00:00
$filter_name_asc_lang = '' ;
2020-11-30 03:59:45 +00:00
$filter_name_desc_lang = '' ;
2023-01-15 08:42:19 +00:00
if ( CFactory :: _ ( 'Registry' ) ->
get ( 'builder.admin_filter_type.' . $nameListCode , 1 ) == 2 )
2020-11-30 03:59:45 +00:00
{
// set the language strings for ascending
$filter_name_asc = $listFieldName . ' ascending' ;
$filter_name_asc_lang = $lang_filter_
2022-03-09 23:46:45 +00:00
. StringHelper :: safe (
2020-11-30 03:59:45 +00:00
$filter_name_asc , 'U'
);
// and to translation
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $filter_name_asc_lang , $filter_name_asc
2020-11-30 03:59:45 +00:00
);
// set the language strings for descending
$filter_name_desc = $listFieldName . ' descending' ;
$filter_name_desc_lang = $lang_filter_
2022-03-09 23:46:45 +00:00
. StringHelper :: safe (
2020-11-30 03:59:45 +00:00
$filter_name_desc , 'U'
);
// and to translation
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $filter_name_desc_lang , $filter_name_desc
2020-11-30 03:59:45 +00:00
);
}
$this -> sortBuilder [ $nameListCode ][] = array ( 'type' => $typeName ,
2023-05-02 00:10:55 +00:00
'code' => $name ,
'lang' => $listLangName ,
'lang_asc' => $filter_name_asc_lang ,
'lang_desc' => $filter_name_desc_lang ,
'custom' => $custom ,
'options' => $options );
2016-03-01 18:44:13 +00:00
}
// build the search values
2018-04-13 15:24:06 +00:00
if ( $dbSwitch && isset ( $field [ 'search' ]) && $field [ 'search' ] == 1 )
2016-03-01 18:44:13 +00:00
{
2020-11-26 17:33:39 +00:00
$_list = ( isset ( $field [ 'list' ]))
2020-03-28 13:34:14 +00:00
? $field [ 'list' ] : 0 ;
2020-11-26 17:33:39 +00:00
$this -> searchBuilder [ $nameListCode ][] = array ( 'type' => $typeName ,
2023-05-02 00:10:55 +00:00
'code' => $name ,
'custom' => $custom ,
'list' => $_list );
2016-03-01 18:44:13 +00:00
}
// build the filter values
2020-11-17 04:06:34 +00:00
if ( $dbSwitch && ( isset ( $field [ 'filter' ]) && $field [ 'filter' ] >= 1 )
2020-03-28 13:34:14 +00:00
&& ( $listSwitch || $listJoin )
&& ( ! $multiple && $typeName != 'checkbox'
&& $typeName != 'checkboxes'
&& $typeName != 'repeatable'
&& $typeName != 'subform' ))
2016-03-01 18:44:13 +00:00
{
2020-11-29 00:00:20 +00:00
// this pains me... but to avoid collusion
2022-03-09 23:46:45 +00:00
$filter_type_code = StringHelper :: safe (
2020-12-05 06:17:54 +00:00
$nameListCode . 'filter' . $name
2020-11-29 00:00:20 +00:00
);
2023-01-01 02:11:34 +00:00
$filter_type_code = preg_replace ( '/_+/' , '' , ( string ) $filter_type_code );
2022-03-09 23:46:45 +00:00
$filter_function_name = StringHelper :: safe (
2020-11-29 00:00:20 +00:00
$name , 'F'
);
2020-11-30 03:59:45 +00:00
// add the language only for new filter option
$filter_name_select_lang = '' ;
2023-01-15 08:42:19 +00:00
if ( CFactory :: _ ( 'Registry' ) ->
get ( 'builder.admin_filter_type.' . $nameListCode , 1 ) == 2 )
2020-11-30 03:59:45 +00:00
{
// set the language strings for selection
$filter_name_select = 'Select ' . $listFieldName ;
$filter_name_select_lang = $lang_filter_
2022-03-09 23:46:45 +00:00
. StringHelper :: safe (
2020-11-30 03:59:45 +00:00
$filter_name_select , 'U'
);
// and to translation
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $filter_name_select_lang , $filter_name_select
2020-11-30 03:59:45 +00:00
);
}
2020-11-29 00:00:20 +00:00
// add the filter details
$this -> filterBuilder [ $nameListCode ][] = array (
'id' => ( int ) $field [ 'field' ],
'type' => $typeName ,
'multi' => $field [ 'filter' ],
'code' => $name ,
'label' => $langLabel ,
'lang' => $listLangName ,
2020-11-30 03:59:45 +00:00
'lang_select' => $filter_name_select_lang ,
2020-11-29 00:00:20 +00:00
'database' => $nameSingleCode ,
'function' => $filter_function_name ,
'custom' => $custom ,
'options' => $options ,
'filter_type' => $filter_type_code
);
2016-03-01 18:44:13 +00:00
}
// build the layout
$tabName = '' ;
2020-03-28 13:34:14 +00:00
if ( isset ( $view [ 'settings' ] -> tabs )
&& isset ( $view [ 'settings' ] -> tabs [( int ) $field [ 'tab' ]]))
2016-03-01 18:44:13 +00:00
{
$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' ;
}
2020-11-26 17:33:39 +00:00
$this -> setLayoutBuilder ( $nameSingleCode , $tabName , $name , $field );
2022-09-14 15:40:02 +00:00
2022-12-29 06:12:03 +00:00
// load all fields that are in the database
if ( $dbSwitch )
2022-09-14 15:40:02 +00:00
{
2022-12-29 06:12:03 +00:00
// load array of view, field, and [encryption, type, tab]
2023-05-02 00:10:55 +00:00
$title_ = CFactory :: _ ( 'Registry' ) -> get ( 'builder.title.' . $nameSingleCode );
2022-12-29 06:12:03 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'all_component_fields.' . $nameSingleCode . '.' . $name ,
2022-09-14 15:40:02 +00:00
[
'name' => $name ,
2022-12-29 06:12:03 +00:00
'label' => $langLabel ,
2022-09-14 15:40:02 +00:00
'type' => $typeName ,
2023-05-02 00:10:55 +00:00
'title' => ( is_string ( $title_ ) && $name === $title_ ) ? true : false ,
2022-09-14 15:40:02 +00:00
'list' => $nameListCode ,
'store' => ( isset ( $field [ 'store' ])) ? $field [ 'store' ] : null ,
'tab_name' => $tabName
]
);
}
2016-03-01 18:44:13 +00:00
}
2017-12-03 08:02:11 +00:00
2018-03-30 04:41:33 +00:00
/**
* set Custom Field Type File
*
2020-11-26 17:33:39 +00:00
* @ param array $data The field complete data set
* @ param string $nameListCode The list view code name
* @ param string $nameSingleCode The single view code name
2018-03-30 04:41:33 +00:00
*
* @ return void
*
*/
2020-11-26 17:33:39 +00:00
public function setCustomFieldTypeFile ( $data , $nameListCode ,
2023-05-02 00:10:55 +00:00
$nameSingleCode
2020-03-28 13:34:14 +00:00
) {
2018-02-20 21:23:35 +00:00
// make sure it is not already been build or if it is prime
2020-02-12 14:27:32 +00:00
if ( isset ( $data [ 'custom' ]) && isset ( $data [ 'custom' ][ 'extends' ])
2020-03-28 13:34:14 +00:00
&& (( isset ( $data [ 'custom' ][ 'prime_php' ])
&& $data [ 'custom' ][ 'prime_php' ] == 1 )
2022-12-11 15:06:13 +00:00
|| ! CFactory :: _ ( 'Content' ) -> exist_ ( 'customfield_' . $data [ 'type' ])
2022-03-09 23:46:45 +00:00
|| ! ArrayHelper :: check (
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> get_ ( 'customfield_' . $data [ 'type' ])
)
))
2016-03-01 18:44:13 +00:00
{
2019-07-19 02:17:15 +00:00
// set J prefix
$jprefix = 'J' ;
// check if this field has a dot in field type name
2023-01-01 02:11:34 +00:00
if ( strpos (( string ) $data [ 'type' ], '.' ) !== false )
2019-07-19 02:17:15 +00:00
{
// so we have name spacing in custom field type name
2023-01-01 02:11:34 +00:00
$dotTypeArray = explode ( '.' , ( string ) $data [ 'type' ]);
2019-07-19 02:17:15 +00:00
// set the J prefix
2019-09-05 21:12:56 +00:00
if ( count (( array ) $dotTypeArray ) > 1 )
2019-07-19 02:17:15 +00:00
{
$jprefix = strtoupper ( array_shift ( $dotTypeArray ));
}
// update the type name now
2020-03-28 13:34:14 +00:00
$data [ 'type' ] = implode ( '' , $dotTypeArray );
2019-07-19 02:17:15 +00:00
$data [ 'custom' ][ 'type' ] = $data [ 'type' ];
}
2016-03-01 18:44:13 +00:00
// set tab and break replacements
$tabBreak = array (
2022-08-30 15:28:41 +00:00
'\t' => Indent :: _ ( 1 ),
2017-12-14 23:10:47 +00:00
'\n' => PHP_EOL
2016-03-01 18:44:13 +00:00
);
2018-09-24 14:37:51 +00:00
// set the [[[PLACEHOLDER]]] options
2016-03-01 18:44:13 +00:00
$replace = array (
2022-08-30 15:28:41 +00:00
Placefix :: _ ( 'JPREFIX' ) => $jprefix ,
Placefix :: _ ( 'TABLE' ) => ( isset ( $data [ 'custom' ][ 'table' ]))
2020-09-15 17:14:53 +00:00
? $data [ 'custom' ][ 'table' ] : '' ,
2022-08-30 15:28:41 +00:00
Placefix :: _ ( 'ID' ) => ( isset ( $data [ 'custom' ][ 'id' ]))
2020-09-15 17:14:53 +00:00
? $data [ 'custom' ][ 'id' ] : '' ,
2022-08-30 15:28:41 +00:00
Placefix :: _ ( 'TEXT' ) => ( isset ( $data [ 'custom' ][ 'text' ]))
2020-09-15 17:14:53 +00:00
? $data [ 'custom' ][ 'text' ] : '' ,
2022-08-30 15:28:41 +00:00
Placefix :: _ ( 'CODE_TEXT' ) => ( isset ( $data [ 'code' ], $data [ 'custom' ][ 'text' ]))
2020-09-15 17:14:53 +00:00
? $data [ 'code' ] . '_' . $data [ 'custom' ][ 'text' ] : '' ,
2022-08-30 15:28:41 +00:00
Placefix :: _ ( 'CODE' ) => ( isset ( $data [ 'code' ]))
2020-09-15 17:14:53 +00:00
? $data [ 'code' ] : '' ,
2022-08-30 15:28:41 +00:00
Placefix :: _ ( 'view_type' ) => $nameSingleCode
2020-03-28 13:34:14 +00:00
. '_' . $data [ 'type' ],
2022-08-30 15:28:41 +00:00
Placefix :: _ ( 'type' ) => ( isset ( $data [ 'type' ]))
2020-09-15 17:14:53 +00:00
? $data [ 'type' ] : '' ,
2022-08-30 15:28:41 +00:00
Placefix :: _ ( 'com_component' ) => ( isset ( $data [ 'custom' ][ 'component' ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$data [ 'custom' ][ 'component' ]
2022-03-09 23:46:45 +00:00
)) ? StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$data [ 'custom' ][ 'component' ]
2022-08-30 15:28:41 +00:00
) : 'com_' . CFactory :: _ ( 'Config' ) -> component_code_name ,
2018-09-24 14:37:51 +00:00
// set the generic values
2022-08-30 15:28:41 +00:00
Placefix :: _ ( 'component' ) => CFactory :: _ ( 'Config' ) -> component_code_name ,
2022-12-04 09:23:43 +00:00
Placefix :: _ ( 'Component' ) => CFactory :: _ ( 'Content' ) -> get ( 'Component' ),
2022-08-30 15:28:41 +00:00
Placefix :: _ ( 'view' ) => ( isset ( $data [ 'custom' ][ 'view' ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$data [ 'custom' ][ 'view' ]
2022-03-09 23:46:45 +00:00
)) ? StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$data [ 'custom' ][ 'view' ]
2020-11-26 17:33:39 +00:00
) : $nameSingleCode ,
2022-08-30 15:28:41 +00:00
Placefix :: _ ( 'views' ) => ( isset ( $data [ 'custom' ][ 'views' ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$data [ 'custom' ][ 'views' ]
2022-03-09 23:46:45 +00:00
)) ? StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$data [ 'custom' ][ 'views' ]
2020-11-26 17:33:39 +00:00
) : $nameListCode
2016-03-01 18:44:13 +00:00
);
2018-09-24 14:37:51 +00:00
// now set the ###PLACEHOLDER### options
foreach ( $replace as $replacekey => $replacevalue )
2016-03-01 18:44:13 +00:00
{
2018-09-24 14:37:51 +00:00
// update the key value
2020-03-28 13:34:14 +00:00
$replacekey = str_replace (
2022-08-30 15:28:41 +00:00
array ( Placefix :: b (), Placefix :: d ()),
array ( Placefix :: h (), Placefix :: h ()), $replacekey
2020-03-28 13:34:14 +00:00
);
2018-09-24 14:37:51 +00:00
// now set the value
$replace [ $replacekey ] = $replacevalue ;
}
2019-02-15 22:03:21 +00:00
// load the global placeholders
2022-09-14 15:40:02 +00:00
foreach ( CFactory :: _ ( 'Component.Placeholder' ) -> get () as $globalPlaceholder => $gloabalValue )
2019-02-15 22:03:21 +00:00
{
2022-09-14 15:40:02 +00:00
$replace [ $globalPlaceholder ] = $gloabalValue ;
2019-02-15 22:03:21 +00:00
}
2018-09-24 14:37:51 +00:00
// start loading the field type
2022-12-11 15:06:13 +00:00
// $this->fileContentDynamic['customfield_' . $data['type']] = array();
2020-11-29 00:00:20 +00:00
// JPREFIX <<<DYNAMIC>>>
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> set_ ( 'customfield_' . $data [ 'type' ], 'JPREFIX' , $jprefix );
2018-09-24 14:37:51 +00:00
// Type <<<DYNAMIC>>>
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> set_ ( 'customfield_' . $data [ 'type' ], 'Type' ,
StringHelper :: safe (
$data [ 'custom' ][ 'type' ], 'F'
)
2020-03-28 13:34:14 +00:00
);
2018-09-24 14:37:51 +00:00
// type <<<DYNAMIC>>>
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> set_ ( 'customfield_' . $data [ 'type' ], 'type' , StringHelper :: safe ( $data [ 'custom' ][ 'type' ]));
2018-09-24 14:37:51 +00:00
// is this a own custom field
if ( isset ( $data [ 'custom' ][ 'own_custom' ]))
{
// make sure the button option notice is set to notify the developer that the button option is not available in own custom field types
2020-03-28 13:34:14 +00:00
if ( isset ( $data [ 'custom' ][ 'add_button' ])
&& ( $data [ 'custom' ][ 'add_button' ] === 'true'
|| 1 == $data [ 'custom' ][ 'add_button' ]))
2018-09-24 14:37:51 +00:00
{
2018-09-25 20:02:48 +00:00
// set error
2020-03-28 13:34:14 +00:00
$this -> app -> enqueueMessage (
JText :: _ ( '<hr /><h3>Dynamic Button Error</h3>' ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: _ (
'The option to add a dynamic button is not available in <b>own custom field types</b>, you will have to custom code it.'
), 'Error'
);
2018-09-24 14:37:51 +00:00
}
// load another file
$target = array ( 'admin' => 'customfield' );
2023-02-12 19:15:41 +00:00
CFactory :: _ ( 'Utilities.Structure' ) -> build (
2020-03-28 13:34:14 +00:00
$target , 'fieldcustom' , $data [ 'custom' ][ 'type' ]
);
2020-07-07 15:13:04 +00:00
// get the extends name
2022-03-09 23:46:45 +00:00
$JFORM_extends = StringHelper :: safe (
2020-07-07 15:13:04 +00:00
$data [ 'custom' ][ 'extends' ]
);
// JFORM_TYPE_HEADER <<<DYNAMIC>>>
$add_default_header = true ;
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> set_ ( 'customfield_' . $data [ 'type' ], 'JFORM_TYPE_HEADER' ,
" // " . Line :: _ (
2022-08-30 15:28:41 +00:00
__LINE__ , __CLASS__
2020-09-15 17:14:53 +00:00
) . " Import the " . $JFORM_extends
2022-12-11 15:06:13 +00:00
. " field type classes needed "
);
2018-09-24 14:37:51 +00:00
// JFORM_extens <<<DYNAMIC>>>
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> set_ ( 'customfield_' . $data [ 'type' ],
'JFORM_extends' , $JFORM_extends
);
2018-09-24 14:37:51 +00:00
// JFORM_EXTENDS <<<DYNAMIC>>>
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> set_ ( 'customfield_' . $data [ 'type' ], 'JFORM_EXTENDS' ,
StringHelper :: safe (
$data [ 'custom' ][ 'extends' ], 'F'
)
2020-03-28 13:34:14 +00:00
);
2018-09-24 14:37:51 +00:00
// JFORM_TYPE_PHP <<<DYNAMIC>>>
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> set_ ( 'customfield_' . $data [ 'type' ], 'JFORM_TYPE_PHP' ,
PHP_EOL . PHP_EOL . Indent :: _ ( 1 ) . " // " . Line :: _ (
2022-08-30 15:28:41 +00:00
__LINE__ , __CLASS__
2022-12-11 15:06:13 +00:00
) . " A " . $data [ 'custom' ][ 'own_custom' ] . " Field "
);
2018-09-24 14:37:51 +00:00
// load the other PHP options
foreach ( ComponentbuilderHelper :: $phpFieldArray as $x )
{
// reset the php bucket
$phpBucket = '' ;
2020-08-13 01:03:56 +00:00
// only set if available
2020-03-28 13:34:14 +00:00
if ( isset ( $data [ 'custom' ][ 'php' . $x ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$data [ 'custom' ][ 'php' . $x ]
))
2016-03-01 18:44:13 +00:00
{
2018-09-24 14:37:51 +00:00
foreach ( $data [ 'custom' ][ 'php' . $x ] as $line => $code )
2016-03-01 18:44:13 +00:00
{
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $code ))
2018-09-24 14:37:51 +00:00
{
2022-08-30 15:28:41 +00:00
$phpBucket .= PHP_EOL . CFactory :: _ ( 'Placeholder' ) -> update (
2020-03-28 13:34:14 +00:00
$code , $tabBreak
);
2018-09-24 14:37:51 +00:00
}
2016-03-01 18:44:13 +00:00
}
2020-07-07 15:13:04 +00:00
// check if this is header text
2020-09-15 17:14:53 +00:00
if ( 'HEADER' === $x )
2020-07-07 15:13:04 +00:00
{
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> add_ ( 'customfield_' . $data [ 'type' ], 'JFORM_TYPE_HEADER' ,
PHP_EOL . CFactory :: _ ( 'Placeholder' ) -> update (
2020-07-07 15:13:04 +00:00
$phpBucket , $replace
2022-12-11 15:06:13 +00:00
)
);
2020-07-07 15:13:04 +00:00
// stop default headers from loading
$add_default_header = false ;
}
else
{
// JFORM_TYPE_PHP <<<DYNAMIC>>>
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> add_ ( 'customfield_' . $data [ 'type' ], 'JFORM_TYPE_PHP' ,
PHP_EOL . CFactory :: _ ( 'Placeholder' ) -> update (
2020-07-07 15:13:04 +00:00
$phpBucket , $replace
2022-12-11 15:06:13 +00:00
)
);
2020-07-07 15:13:04 +00:00
}
2016-03-01 18:44:13 +00:00
}
}
2020-07-07 15:13:04 +00:00
// check if we should add default header
if ( $add_default_header )
{
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> add_ ( 'customfield_' . $data [ 'type' ], 'JFORM_TYPE_HEADER' ,
PHP_EOL . " jimport('joomla.form.helper'); "
);
CFactory :: _ ( 'Content' ) -> add_ ( 'customfield_' . $data [ 'type' ], 'JFORM_TYPE_HEADER' ,
PHP_EOL . " JFormHelper::loadFieldClass(' " . $JFORM_extends . " '); "
);
2020-07-07 15:13:04 +00:00
}
// check the the JFormHelper::loadFieldClass(..) was set
2023-01-01 02:11:34 +00:00
elseif ( strpos (( string ) CFactory :: _ ( 'Content' ) -> get_ ( 'customfield_' . $data [ 'type' ], 'JFORM_TYPE_HEADER' ),
2022-12-11 15:06:13 +00:00
'JFormHelper::loadFieldClass(' ) === false )
2020-07-07 15:13:04 +00:00
{
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> add_ ( 'customfield_' . $data [ 'type' ], 'JFORM_TYPE_HEADER' ,
PHP_EOL . " JFormHelper::loadFieldClass(' "
. $JFORM_extends . " '); "
);
2020-07-07 15:13:04 +00:00
}
2016-03-01 18:44:13 +00:00
}
else
{
2018-09-24 14:37:51 +00:00
// first build the custom field type file
$target = array ( 'admin' => 'customfield' );
2023-02-12 19:15:41 +00:00
CFactory :: _ ( 'Utilities.Structure' ) -> build (
2020-03-28 13:34:14 +00:00
$target , 'field' . $data [ 'custom' ][ 'extends' ],
$data [ 'custom' ][ 'type' ]
);
2018-09-24 14:37:51 +00:00
// make sure the value is reset
$phpCode = '' ;
// now load the php script
2020-03-28 13:34:14 +00:00
if ( isset ( $data [ 'custom' ][ 'php' ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$data [ 'custom' ][ 'php' ]
))
2016-03-01 18:44:13 +00:00
{
2018-09-24 14:37:51 +00:00
foreach ( $data [ 'custom' ][ 'php' ] as $line => $code )
2016-03-01 18:44:13 +00:00
{
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $code ))
2016-03-01 18:44:13 +00:00
{
if ( $line == 1 )
{
2022-08-30 15:28:41 +00:00
$phpCode .= CFactory :: _ ( 'Placeholder' ) -> update (
2020-03-28 13:34:14 +00:00
$code , $tabBreak
);
2016-03-01 18:44:13 +00:00
}
else
{
2022-08-30 15:28:41 +00:00
$phpCode .= PHP_EOL . Indent :: _ ( 2 )
. CFactory :: _ ( 'Placeholder' ) -> update ( $code , $tabBreak );
2016-03-01 18:44:13 +00:00
}
}
}
// replace the placholders
2022-08-30 15:28:41 +00:00
$phpCode = CFactory :: _ ( 'Placeholder' ) -> update ( $phpCode , $replace );
2016-03-01 18:44:13 +00:00
}
2018-09-24 14:37:51 +00:00
// catch empty stuff
2022-03-09 23:46:45 +00:00
if ( ! StringHelper :: check ( $phpCode ))
2016-03-01 18:44:13 +00:00
{
2018-09-24 14:37:51 +00:00
$phpCode = 'return null;' ;
2016-03-01 18:44:13 +00:00
}
2018-09-24 14:37:51 +00:00
// some house cleaning for users
if ( $data [ 'custom' ][ 'extends' ] === 'user' )
2016-03-01 18:44:13 +00:00
{
2018-09-24 14:37:51 +00:00
// make sure the value is reset
$phpxCode = '' ;
// now load the php xclude script
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$data [ 'custom' ][ 'phpx' ]
))
2018-09-24 14:37:51 +00:00
{
foreach ( $data [ 'custom' ][ 'phpx' ] as $line => $code )
{
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $code ))
2018-09-24 14:37:51 +00:00
{
if ( $line == 1 )
{
2022-08-30 15:28:41 +00:00
$phpxCode .= CFactory :: _ ( 'Placeholder' ) -> update (
2020-03-28 13:34:14 +00:00
$code , $tabBreak
);
2018-09-24 14:37:51 +00:00
}
else
{
2022-08-30 15:28:41 +00:00
$phpxCode .= PHP_EOL . Indent :: _ ( 2 )
. CFactory :: _ ( 'Placeholder' ) -> update (
2020-03-28 13:34:14 +00:00
$code , $tabBreak
);
2018-09-24 14:37:51 +00:00
}
}
}
// replace the placholders
2022-08-30 15:28:41 +00:00
$phpxCode = CFactory :: _ ( 'Placeholder' ) -> update ( $phpxCode , $replace );
2018-09-24 14:37:51 +00:00
}
// catch empty stuff
2022-03-09 23:46:45 +00:00
if ( ! StringHelper :: check ( $phpxCode ))
2018-09-24 14:37:51 +00:00
{
$phpxCode = 'return null;' ;
}
// temp holder for name
$tempName = $data [ 'custom' ][ 'label' ] . ' Group' ;
// set lang
2022-08-30 15:28:41 +00:00
$groupLangName = CFactory :: _ ( 'Config' ) -> lang_prefix . '_'
2022-03-09 23:46:45 +00:00
. FieldHelper :: safe (
2020-03-28 13:34:14 +00:00
$tempName , true
);
2018-09-24 14:37:51 +00:00
// add to lang array
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $groupLangName ,
2022-03-09 23:46:45 +00:00
StringHelper :: safe ( $tempName , 'W' )
2020-03-28 13:34:14 +00:00
);
2018-09-24 14:37:51 +00:00
// build the Group Control
$this -> setGroupControl [ $data [ 'type' ]] = $groupLangName ;
// JFORM_GETGROUPS_PHP <<<DYNAMIC>>>
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> set_ ( 'customfield_' . $data [ 'type' ], 'JFORM_GETGROUPS_PHP' ,
$phpCode
);
2018-09-24 14:37:51 +00:00
// JFORM_GETEXCLUDED_PHP <<<DYNAMIC>>>
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> set_ ( 'customfield_' . $data [ 'type' ], 'JFORM_GETEXCLUDED_PHP' ,
$phpxCode
);
2016-03-01 18:44:13 +00:00
}
2018-09-24 14:37:51 +00:00
else
{
// JFORM_GETOPTIONS_PHP <<<DYNAMIC>>>
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> set_ ( 'customfield_' . $data [ 'type' ], 'JFORM_GETOPTIONS_PHP' ,
$phpCode
);
2018-09-24 14:37:51 +00:00
}
// type <<<DYNAMIC>>>
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> set_ ( 'customfield_' . $data [ 'type' ], 'ADD_BUTTON' ,
$this -> setAddButtonToListField ( $data [ 'custom' ])
);
2016-03-01 18:44:13 +00:00
}
2018-03-30 04:41:33 +00:00
}
2019-08-22 01:54:47 +00:00
// if this field gets used in plugin or module we should track it so if needed we can copy it over
2020-11-26 17:33:39 +00:00
if (( strpos ( $nameSingleCode , 'P|uG!n' ) !== false
2020-03-28 13:34:14 +00:00
|| strpos (
2020-11-26 17:33:39 +00:00
$nameSingleCode , 'M0dU|3'
2020-03-28 13:34:14 +00:00
) !== false )
&& isset ( $data [ 'custom' ])
&& isset ( $data [ 'custom' ][ 'type' ]))
2019-08-22 01:54:47 +00:00
{
2020-03-28 13:34:14 +00:00
$this -> extentionCustomfields [ $data [ 'type' ]]
= $data [ 'custom' ][ 'type' ];
2019-08-22 01:54:47 +00:00
}
2018-03-30 04:41:33 +00:00
}
2020-11-29 00:00:20 +00:00
/**
* This is just to get the code .
* Don ' t use this to build the field
*
* @ param array $custom The field complete data set
*
* @ return array with the code
*
*/
public function getCustomFieldCode ( $custom )
{
// the code bucket
$code_bucket = array (
'JFORM_TYPE_HEADER' => '' ,
'JFORM_TYPE_PHP' => ''
);
// set tab and break replacements
$tabBreak = array (
2022-08-30 15:28:41 +00:00
'\t' => Indent :: _ ( 1 ),
2020-11-29 00:00:20 +00:00
'\n' => PHP_EOL
);
// load the other PHP options
foreach ( ComponentbuilderHelper :: $phpFieldArray as $x )
{
// reset the php bucket
$phpBucket = '' ;
// only set if available
if ( isset ( $custom [ 'php' . $x ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-11-29 00:00:20 +00:00
$custom [ 'php' . $x ]
))
{
foreach ( $custom [ 'php' . $x ] as $line => $code )
{
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $code ))
2020-11-29 00:00:20 +00:00
{
2022-08-30 15:28:41 +00:00
$phpBucket .= PHP_EOL . CFactory :: _ ( 'Placeholder' ) -> update (
2020-11-29 00:00:20 +00:00
$code , $tabBreak
);
}
}
// check if this is header text
if ( 'HEADER' === $x )
{
$code_bucket [ 'JFORM_TYPE_HEADER' ]
.= PHP_EOL . $phpBucket ;
}
else
{
// JFORM_TYPE_PHP <<<DYNAMIC>>>
$code_bucket [ 'JFORM_TYPE_PHP' ]
.= PHP_EOL . $phpBucket ;
}
}
}
return $code_bucket ;
}
/**
* set the Filter Field set of a view
*
* @ param string $nameSingleCode The single view name
* @ param string $nameListCode The list view name
*
* @ return string The fields set in xml
*
*/
public function setFieldFilterSet ( & $nameSingleCode , & $nameListCode )
{
// check if this is the above/new filter option
2023-01-15 08:42:19 +00:00
if ( CFactory :: _ ( 'Registry' ) ->
get ( 'builder.admin_filter_type.' . $nameListCode , 1 ) == 2 )
2020-11-29 00:00:20 +00:00
{
// we first create the file
$target = array ( 'admin' => 'filter_' . $nameListCode );
2023-02-12 19:15:41 +00:00
CFactory :: _ ( 'Utilities.Structure' ) -> build (
2020-11-29 00:00:20 +00:00
$target , 'filter'
);
2020-11-30 03:59:45 +00:00
// the search language string
2022-08-30 15:28:41 +00:00
$lang_search = CFactory :: _ ( 'Config' ) -> lang_prefix . '_FILTER_SEARCH' ;
2020-11-30 03:59:45 +00:00
// and to translation
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $lang_search , 'Search'
2022-03-09 23:46:45 +00:00
. StringHelper :: safe ( $nameListCode , 'w' )
2020-11-30 03:59:45 +00:00
);
// the search description language string
2022-08-30 15:28:41 +00:00
$lang_search_desc = CFactory :: _ ( 'Config' ) -> lang_prefix . '_FILTER_SEARCH_'
2020-11-30 03:59:45 +00:00
. strtoupper ( $nameListCode );
// and to translation
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $lang_search_desc , 'Search the '
2022-03-09 23:46:45 +00:00
. StringHelper :: safe ( $nameSingleCode , 'w' )
2020-11-30 03:59:45 +00:00
. ' items. Prefix with ID: to search for an item by ID.'
);
2020-11-29 00:00:20 +00:00
// now build the XML
$field_filter_sets = array ();
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 1 ) . '<fields name="filter">' ;
2020-11-29 00:00:20 +00:00
// we first add the search
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 2 ) . '<field' ;
$field_filter_sets [] = Indent :: _ ( 3 ) . 'type="text"' ;
$field_filter_sets [] = Indent :: _ ( 3 ) . 'name="search"' ;
$field_filter_sets [] = Indent :: _ ( 3 ) . 'inputmode="search"' ;
$field_filter_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. 'label="' . $lang_search . '"' ;
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. 'description="' . $lang_search_desc . '"' ;
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 ) . 'hint="JSEARCH_FILTER"' ;
$field_filter_sets [] = Indent :: _ ( 2 ) . '/>' ;
2020-11-29 00:00:20 +00:00
// add the published filter if published is not set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.published' ))
2020-11-29 00:00:20 +00:00
{
2020-11-30 03:59:45 +00:00
// the published language string
2022-08-30 15:28:41 +00:00
$lang_published = CFactory :: _ ( 'Config' ) -> lang_prefix . '_FILTER_PUBLISHED' ;
2020-11-30 03:59:45 +00:00
// and to translation
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $lang_published , 'Status'
2020-11-30 03:59:45 +00:00
);
// the published description language string
2022-08-30 15:28:41 +00:00
$lang_published_desc = CFactory :: _ ( 'Config' ) -> lang_prefix . '_FILTER_PUBLISHED_'
2020-11-30 03:59:45 +00:00
. strtoupper ( $nameListCode );
// and to translation
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
CFactory :: _ ( 'Config' ) -> lang_target , $lang_published_desc , 'Status options for '
2022-03-09 23:46:45 +00:00
. StringHelper :: safe ( $nameListCode , 'w' )
2020-11-30 03:59:45 +00:00
);
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 2 ) . '<field' ;
$field_filter_sets [] = Indent :: _ ( 3 ) . 'type="status"' ;
$field_filter_sets [] = Indent :: _ ( 3 ) . 'name="published"' ;
$field_filter_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. 'label="' . $lang_published . '"' ;
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. 'description="' . $lang_published_desc . '"' ;
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 )
2020-11-29 00:00:20 +00:00
. 'onchange="this.form.submit();"' ;
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 2 ) . '>' ;
$field_filter_sets [] = Indent :: _ ( 3 )
2020-11-29 00:00:20 +00:00
. '<option value="">JOPTION_SELECT_PUBLISHED</option>' ;
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 2 ) . '</field>' ;
2020-11-29 00:00:20 +00:00
}
2020-11-30 15:30:10 +00:00
// add the category if found
if ( isset ( $this -> categoryBuilder [ $nameListCode ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-11-30 15:30:10 +00:00
$this -> categoryBuilder [ $nameListCode ]
)
2021-03-04 06:13:05 +00:00
&& isset ( $this -> categoryBuilder [ $nameListCode ][ 'extension' ])
&& isset ( $this -> categoryBuilder [ $nameListCode ][ 'filter' ])
&& $this -> categoryBuilder [ $nameListCode ][ 'filter' ] >= 1 )
2020-11-30 15:30:10 +00:00
{
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 2 ) . '<field' ;
$field_filter_sets [] = Indent :: _ ( 3 ) . 'type="category"' ;
$field_filter_sets [] = Indent :: _ ( 3 ) . 'name="category_id"' ;
$field_filter_sets [] = Indent :: _ ( 3 )
2020-12-05 06:17:54 +00:00
. 'label="' . $this -> categoryBuilder [ $nameListCode ][ 'name' ]
. '"' ;
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 )
2020-11-30 15:30:10 +00:00
. 'description="JOPTION_FILTER_CATEGORY_DESC"' ;
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 ) . 'multiple="true"' ;
$field_filter_sets [] = Indent :: _ ( 3 )
2020-11-30 15:30:10 +00:00
. 'class="multipleCategories"' ;
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 ) . 'extension="'
2020-11-30 15:30:10 +00:00
. $this -> categoryBuilder [ $nameListCode ][ 'extension' ] . '"' ;
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 )
2020-11-30 15:30:10 +00:00
. 'onchange="this.form.submit();"' ;
// TODO NOT SURE IF THIS SHOULD BE STATIC
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 ) . 'published="0,1,2"' ;
$field_filter_sets [] = Indent :: _ ( 2 ) . '/>' ;
2020-11-30 15:30:10 +00:00
}
2020-11-29 00:00:20 +00:00
// add the access filter if this view has access
// and if access manually is not set
2023-05-02 00:10:55 +00:00
if ( CFactory :: _ ( 'Registry' ) -> exists ( 'builder.access_switch.' . $nameSingleCode )
&& ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.access' ))
2020-11-29 00:00:20 +00:00
{
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 2 ) . '<field' ;
$field_filter_sets [] = Indent :: _ ( 3 ) . 'type="accesslevel"' ;
$field_filter_sets [] = Indent :: _ ( 3 ) . 'name="access"' ;
$field_filter_sets [] = Indent :: _ ( 3 )
2020-12-03 00:13:49 +00:00
. 'label="JFIELD_ACCESS_LABEL"' ;
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 )
2020-12-03 00:13:49 +00:00
. 'description="JFIELD_ACCESS_DESC"' ;
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 ) . 'multiple="true"' ;
$field_filter_sets [] = Indent :: _ ( 3 )
2020-11-29 00:00:20 +00:00
. 'class="multipleAccessLevels"' ;
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 )
2020-11-29 00:00:20 +00:00
. 'onchange="this.form.submit();"' ;
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 2 ) . '/>' ;
2020-11-29 00:00:20 +00:00
}
// now add the dynamic fields
2020-11-30 03:59:45 +00:00
if ( isset ( $this -> filterBuilder [ $nameListCode ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-11-30 03:59:45 +00:00
$this -> filterBuilder [ $nameListCode ]
))
2020-11-29 00:00:20 +00:00
{
2020-11-30 03:59:45 +00:00
foreach ( $this -> filterBuilder [ $nameListCode ] as $r => & $filter )
2020-11-29 00:00:20 +00:00
{
2020-11-30 03:59:45 +00:00
if ( $filter [ 'type' ] != 'category' )
2020-11-29 00:00:20 +00:00
{
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 2 ) . '<field' ;
2020-11-30 03:59:45 +00:00
// if this is a custom field
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-11-30 03:59:45 +00:00
$filter [ 'custom' ]
))
{
// we use the field type from the custom field
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 ) . 'type="'
2020-11-30 03:59:45 +00:00
. $filter [ 'type' ] . '"' ;
// set css classname of this field
2023-01-01 02:11:34 +00:00
$filter [ 'class' ] = ucfirst (( string ) $filter [ 'type' ]);
2020-11-30 03:59:45 +00:00
}
else
{
// we use the filter field type that was build
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 ) . 'type="'
2020-11-30 03:59:45 +00:00
. $filter [ 'filter_type' ] . '"' ;
// set css classname of this field
2023-01-01 02:11:34 +00:00
$filter [ 'class' ] = ucfirst (( string ) $filter [ 'filter_type' ]);
2020-11-30 03:59:45 +00:00
}
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 ) . 'name="'
2020-11-30 03:59:45 +00:00
. $filter [ 'code' ] . '"' ;
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 ) . 'label="'
2020-11-30 03:59:45 +00:00
. $filter [ 'label' ] . '"' ;
// if this is a multi field
if ( $filter [ 'multi' ] == 2 )
{
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. 'class="multiple'
. $filter [ 'class' ] . '"' ;
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. 'multiple="true"' ;
}
else
{
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. 'multiple="false"' ;
}
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. 'onchange="this.form.submit();"' ;
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 2 ) . '/>' ;
2020-11-29 00:00:20 +00:00
}
}
}
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 2 )
2020-11-29 00:00:20 +00:00
. '<input type="hidden" name="form_submited" value="1"/>' ;
2022-08-30 15:28:41 +00:00
$field_filter_sets [] = Indent :: _ ( 1 ) . '</fields>' ;
2020-11-29 00:00:20 +00:00
// now update the file
return implode ( PHP_EOL , $field_filter_sets );
}
return '' ;
}
/**
* set the Filter List set of a view
*
* @ param string $nameSingleCode The single view name
* @ param string $nameListCode The list view name
*
* @ return string The fields set in xml
*
*/
public function setFieldFilterListSet ( & $nameSingleCode , & $nameListCode )
{
2020-11-30 03:59:45 +00:00
// check if this is the above/new filter option
2023-01-15 08:42:19 +00:00
if ( CFactory :: _ ( 'Registry' ) ->
get ( 'builder.admin_filter_type.' . $nameListCode , 1 ) == 2 )
2020-11-30 03:59:45 +00:00
{
// keep track of all fields already added
$donelist = array ( 'ordering' => true , 'id' => true );
// now build the XML
$list_sets = array ();
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 1 ) . '<fields name="list">' ;
$list_sets [] = Indent :: _ ( 2 ) . '<field' ;
$list_sets [] = Indent :: _ ( 3 ) . 'name="fullordering"' ;
$list_sets [] = Indent :: _ ( 3 ) . 'type="list"' ;
$list_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. 'label="COM_CONTENT_LIST_FULL_ORDERING"' ;
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. 'description="COM_CONTENT_LIST_FULL_ORDERING_DESC"' ;
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 3 ) . 'onchange="this.form.submit();"' ;
2020-11-30 03:59:45 +00:00
// add dynamic ordering (Admin view)
$default_ordering = $this -> getListViewDefaultOrdering (
$nameListCode
);
// set the default ordering
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 3 ) . 'default="'
2020-11-30 03:59:45 +00:00
. $default_ordering [ 'name' ] . ' '
. $default_ordering [ 'direction' ] . '"' ;
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 3 ) . 'validate="options"' ;
$list_sets [] = Indent :: _ ( 2 ) . '>' ;
$list_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. '<option value="">JGLOBAL_SORT_BY</option>' ;
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. '<option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>' ;
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. '<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>' ;
// add the published filter if published is not set
2023-05-02 00:10:55 +00:00
if ( ! CFactory :: _ ( 'Registry' ) -> isString ( 'builder.field_names.' . $nameSingleCode . '.published' ))
2020-11-30 03:59:45 +00:00
{
// add to done list
$donelist [ 'published' ] = true ;
// add to xml :)
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. '<option value="a.published ASC">JSTATUS_ASC</option>' ;
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. '<option value="a.published DESC">JSTATUS_DESC</option>' ;
}
// add the rest of the set filters
if ( isset ( $this -> sortBuilder [ $nameListCode ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-11-30 03:59:45 +00:00
$this -> sortBuilder [ $nameListCode ]
))
{
foreach ( $this -> sortBuilder [ $nameListCode ] as $filter )
{
if ( ! isset ( $donelist [ $filter [ 'code' ]]))
{
if ( $filter [ 'type' ] === 'category' )
{
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. '<option value="category_title ASC">'
. $filter [ 'lang_asc' ] . '</option>' ;
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. '<option value="category_title DESC">'
. $filter [ 'lang_desc' ] . '</option>' ;
}
2022-03-09 23:46:45 +00:00
elseif ( ArrayHelper :: check (
2020-11-30 03:59:45 +00:00
$filter [ 'custom' ]
))
{
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 3 ) . '<option value="'
2020-11-30 03:59:45 +00:00
. $filter [ 'custom' ][ 'db' ] . '.'
. $filter [ 'custom' ][ 'text' ] . ' ASC">'
. $filter [ 'lang_asc' ] . '</option>' ;
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 3 ) . '<option value="'
2020-11-30 03:59:45 +00:00
. $filter [ 'custom' ][ 'db' ] . '.'
. $filter [ 'custom' ][ 'text' ] . ' DESC">'
. $filter [ 'lang_desc' ] . '</option>' ;
}
else
{
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 3 ) . '<option value="a.'
2020-11-30 03:59:45 +00:00
. $filter [ 'code' ] . ' ASC">'
. $filter [ 'lang_asc' ] . '</option>' ;
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 3 ) . '<option value="a.'
2020-11-30 03:59:45 +00:00
. $filter [ 'code' ] . ' DESC">'
. $filter [ 'lang_desc' ] . '</option>' ;
}
// do not add again
$donelist [ $filter [ 'code' ]] = true ;
}
}
}
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. '<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>' ;
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. '<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>' ;
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 2 ) . '</field>' . PHP_EOL ;
2020-11-30 03:59:45 +00:00
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 2 ) . '<field' ;
$list_sets [] = Indent :: _ ( 3 ) . 'name="limit"' ;
$list_sets [] = Indent :: _ ( 3 ) . 'type="limitbox"' ;
$list_sets [] = Indent :: _ ( 3 ) . 'label="COM_CONTENT_LIST_LIMIT"' ;
$list_sets [] = Indent :: _ ( 3 )
2020-11-30 03:59:45 +00:00
. 'description="COM_CONTENT_LIST_LIMIT_DESC"' ;
2022-08-30 15:28:41 +00:00
$list_sets [] = Indent :: _ ( 3 ) . 'class="input-mini"' ;
$list_sets [] = Indent :: _ ( 3 ) . 'default="25"' ;
$list_sets [] = Indent :: _ ( 3 ) . 'onchange="this.form.submit();"' ;
$list_sets [] = Indent :: _ ( 2 ) . '/>' ;
$list_sets [] = Indent :: _ ( 1 ) . '</fields>' ;
2020-11-30 03:59:45 +00:00
return implode ( PHP_EOL , $list_sets );
}
2020-11-29 00:00:20 +00:00
return '' ;
}
/**
* set Custom Field for Filter
*
* @ param string $getOptions The get options php string / code
* @ param array $filter The filter details
*
* @ return void
*
*/
public function setFilterFieldFile ( $getOptions , $filter )
{
// make sure it is not already been build
2022-12-11 15:06:13 +00:00
if ( ! CFactory :: _ ( 'Content' ) -> exist_ ( 'customfilterfield_' . $filter [ 'filter_type' ])
2022-03-09 23:46:45 +00:00
|| ! ArrayHelper :: check (
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> get_ ( 'customfilterfield_' . $filter [ 'filter_type' ])
2020-11-29 00:00:20 +00:00
)
)
{
// start loading the field type
2022-12-11 15:06:13 +00:00
// $this->fileContentDynamic['customfilterfield_'
// . $filter['filter_type']]
// = array();
2020-11-29 00:00:20 +00:00
// JPREFIX <<DYNAMIC>>>
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> set_ ( 'customfilterfield_' . $filter [ 'filter_type' ], 'JPREFIX' , 'J' );
2020-11-29 00:00:20 +00:00
// Type <<<DYNAMIC>>>
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> set_ ( 'customfilterfield_' . $filter [ 'filter_type' ], 'Type' ,
StringHelper :: safe (
$filter [ 'filter_type' ], 'F'
)
2020-11-29 00:00:20 +00:00
);
// type <<<DYNAMIC>>>
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> set_ ( 'customfilterfield_' . $filter [ 'filter_type' ], 'type' ,
StringHelper :: safe ( $filter [ 'filter_type' ])
);
2020-11-29 00:00:20 +00:00
// JFORM_GETOPTIONS_PHP <<<DYNAMIC>>>
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> set_ ( 'customfilterfield_' . $filter [ 'filter_type' ], 'JFORM_GETOPTIONS_PHP' ,
$getOptions
);
2020-11-29 00:00:20 +00:00
// ADD_BUTTON <<<DYNAMIC>>>
2022-12-11 15:06:13 +00:00
CFactory :: _ ( 'Content' ) -> set_ ( 'customfilterfield_' . $filter [ 'filter_type' ], 'ADD_BUTTON' , '' );
2020-11-29 00:00:20 +00:00
// now build the custom filter field type file
$target = array ( 'admin' => 'customfilterfield' );
2023-02-12 19:15:41 +00:00
CFactory :: _ ( 'Utilities.Structure' ) -> build (
2020-11-29 00:00:20 +00:00
$target , 'fieldlist' ,
$filter [ 'filter_type' ]
);
}
}
2018-03-30 04:41:33 +00:00
/**
* set Add Button To List Field ( getInput tweak )
*
2020-03-28 13:34:14 +00:00
* @ param array $fieldData The field custom data
2018-03-30 04:41:33 +00:00
*
* @ return string of getInput class on success empty string otherwise
*
*/
protected function setAddButtonToListField ( $fieldData )
{
// make sure hte view values are set
2020-03-28 13:34:14 +00:00
if ( isset ( $fieldData [ 'add_button' ])
&& ( $fieldData [ 'add_button' ] === 'true'
|| 1 == $fieldData [ 'add_button' ])
&& isset ( $fieldData [ 'view' ])
&& isset ( $fieldData [ 'views' ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $fieldData [ 'view' ])
&& StringHelper :: check ( $fieldData [ 'views' ]))
2018-05-11 04:08:14 +00:00
{
2018-08-19 20:15:43 +00:00
// set local component
2022-08-30 15:28:41 +00:00
$local_component = " com_ " . CFactory :: _ ( 'Config' ) -> component_code_name ;
2018-04-02 19:45:52 +00:00
// check that the component value is set
2020-03-28 13:34:14 +00:00
if ( ! isset ( $fieldData [ 'component' ])
2022-03-09 23:46:45 +00:00
|| ! StringHelper :: check (
2020-03-28 13:34:14 +00:00
$fieldData [ 'component' ]
))
2018-04-02 19:45:52 +00:00
{
2018-08-19 20:15:43 +00:00
$fieldData [ 'component' ] = $local_component ;
2018-04-02 19:45:52 +00:00
}
2021-05-04 20:34:23 +00:00
// check that the component has the com_ value in it
2023-01-01 02:11:34 +00:00
if ( strpos (( string ) $fieldData [ 'component' ], 'com_' ) === false
2020-03-28 13:34:14 +00:00
|| strpos (
2023-01-01 02:11:34 +00:00
( string ) $fieldData [ 'component' ], '='
2020-03-28 13:34:14 +00:00
) !== false )
2018-04-02 19:45:52 +00:00
{
$fieldData [ 'component' ] = " com_ " . $fieldData [ 'component' ];
}
2018-05-22 19:01:36 +00:00
// make sure the component is update if # # # or [ [ [ component placeholder is used
2023-01-01 02:11:34 +00:00
if ( strpos (( string ) $fieldData [ 'component' ], ( string ) Placefix :: h ()) !== false
2020-03-28 13:34:14 +00:00
|| strpos (
2023-01-01 02:11:34 +00:00
( string ) $fieldData [ 'component' ], ( string ) Placefix :: b ()
2020-03-28 13:34:14 +00:00
) !== false ) // should not be needed... but
2018-04-02 19:45:52 +00:00
{
2022-12-11 15:06:13 +00:00
$fieldData [ 'component' ] = CFactory :: _ ( 'Placeholder' ) -> update_ (
$fieldData [ 'component' ]
2020-03-28 13:34:14 +00:00
);
2018-04-02 19:45:52 +00:00
}
2019-06-13 21:12:16 +00:00
// get core permissions
$coreLoad = false ;
// add ref tags
$refLoad = true ;
2018-08-19 20:15:43 +00:00
// fall back on the field component
$component = $fieldData [ 'component' ];
// check if we should add ref tags (since it only works well on local views)
if ( $local_component !== $component )
{
// do not add ref tags
$refLoad = false ;
}
2019-06-13 21:12:16 +00:00
// get core permisssions
2018-04-02 19:45:52 +00:00
if ( isset ( $this -> permissionCore [ $fieldData [ 'view' ]]))
{
// get the core permission naming array
$core = $this -> permissionCore [ $fieldData [ 'view' ]];
// set switch to activate easy update
$coreLoad = true ;
}
// start building the add buttons/s
2020-03-28 13:34:14 +00:00
$addButton = array ();
2022-08-30 15:28:41 +00:00
$addButton [] = PHP_EOL . PHP_EOL . Indent :: _ ( 1 ) . " /** " ;
$addButton [] = Indent :: _ ( 1 ) . " * Override to add new button " ;
$addButton [] = Indent :: _ ( 1 ) . " * " ;
$addButton [] = Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. " * @return string The field input markup. " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 1 ) . " * " ;
$addButton [] = Indent :: _ ( 1 ) . " * @since 3.2 " ;
$addButton [] = Indent :: _ ( 1 ) . " */ " ;
$addButton [] = Indent :: _ ( 1 ) . " protected function getInput() " ;
$addButton [] = Indent :: _ ( 1 ) . " { " ;
$addButton [] = Indent :: _ ( 2 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " see if we should add buttons " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 2 )
2020-03-28 13:34:14 +00:00
. " \$ set_button = \$ this->getAttribute('button'); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 2 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " get html " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 2 ) . " \$ html = parent::getInput(); " ;
$addButton [] = Indent :: _ ( 2 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " if true set button " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 2 ) . " if ( \$ set_button === 'true') " ;
$addButton [] = Indent :: _ ( 2 ) . " { " ;
$addButton [] = Indent :: _ ( 3 ) . " \$ button = array(); " ;
$addButton [] = Indent :: _ ( 3 ) . " \$ script = array(); " ;
$addButton [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. " \$ button_code_name = \$ this->getAttribute('name'); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " get the input from url " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 ) . " \$ app = JFactory::getApplication(); " ;
$addButton [] = Indent :: _ ( 3 ) . " \$ jinput = \$ app->input; " ;
$addButton [] = Indent :: _ ( 3 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " get the view name & id " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. " \$ values = \$ jinput->getArray(array( " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 ) . " 'id' => 'int', " ;
$addButton [] = Indent :: _ ( 4 ) . " 'view' => 'word' " ;
$addButton [] = Indent :: _ ( 3 ) . " )); " ;
$addButton [] = Indent :: _ ( 3 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " check if new item " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 ) . " \$ ref = ''; " ;
$addButton [] = Indent :: _ ( 3 ) . " \$ refJ = ''; " ;
2018-04-02 19:45:52 +00:00
if ( $refLoad )
2018-03-30 04:41:33 +00:00
{
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. " if (!is_null( \$ values['id']) && strlen( \$ values['view'])) " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 ) . " { " ;
$addButton [] = Indent :: _ ( 4 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " only load referral if not new item. " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. " \$ ref = '&ref=' . \$ values['view'] . '&refid=' . \$ values['id']; " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. " \$ refJ = '&ref=' . \$ values['view'] . '&refid=' . \$ values['id']; " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " get the return value. " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. " \$ _uri = (string) JUri::getInstance(); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. " \$ _return = urlencode(base64_encode( \$ _uri)); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " load return value. " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. " \$ ref .= '&return=' . \$ _return; " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. " \$ refJ .= '&return=' . \$ _return; " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 ) . " } " ;
2018-03-30 04:41:33 +00:00
}
else
{
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. " if (!is_null( \$ values['id']) && strlen( \$ values['view'])) " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 ) . " { " ;
$addButton [] = Indent :: _ ( 4 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " only load field details if not new item. " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. " \$ ref = '&field=' . \$ values['view'] . '&field_id=' . \$ values['id']; " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. " \$ refJ = '&field=' . \$ values['view'] . '&field_id=' . \$ values['id']; " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " get the return value. " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. " \$ _uri = (string) JUri::getInstance(); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. " \$ _return = urlencode(base64_encode( \$ _uri)); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " load return value. " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. " \$ ref = '&return=' . \$ _return; " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. " \$ refJ = '&return=' . \$ _return; " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 ) . " } " ;
2018-05-26 10:03:08 +00:00
}
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " get button label " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. " \$ button_label = trim( \$ button_code_name); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. " \$ button_label = preg_replace('/_+/', ' ', \$ button_label); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. " \$ button_label = preg_replace('/ \ s+/', ' ', \$ button_label); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. " \$ button_label = preg_replace( \" /[^A-Za-z ]/ \" , '', \$ button_label); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. " \$ button_label = ucfirst(strtolower( \$ button_label)); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " get user object " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 ) . " \$ user = JFactory::getUser(); " ;
$addButton [] = Indent :: _ ( 3 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " only add if user allowed to create " . $fieldData [ 'view' ];
2018-03-30 04:41:33 +00:00
// check if the item has permissions.
2020-03-28 13:34:14 +00:00
if ( $coreLoad && isset ( $core [ 'core.create' ])
&& isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]
)
&& in_array (
$fieldData [ 'view' ],
$this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]
))
2018-03-30 04:41:33 +00:00
{
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 ) . " if ( \$ user->authorise(' "
2020-03-28 13:34:14 +00:00
. $core [ 'core.create' ] . " ', ' " . $component
. " ') && \$ app->isAdmin()) // TODO for now only in admin area. " ;
2018-03-30 04:41:33 +00:00
}
else
{
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. " if ( \$ user->authorise('core.create', ' " . $component
. " ') && \$ app->isAdmin()) // TODO for now only in admin area. " ;
2018-05-26 10:03:08 +00:00
}
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 ) . " { " ;
$addButton [] = Indent :: _ ( 4 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " build Create button " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. " \$ button[] = '<a id= \" '. \$ button_code_name.'Create \" class= \" btn btn-small btn-success hasTooltip \" title= \" '.JText: "
2022-08-30 15:28:41 +00:00
. " :sprintf(' " . CFactory :: _ ( 'Config' ) -> lang_prefix
2020-03-28 13:34:14 +00:00
. " _CREATE_NEW_S', \$ button_label).' \" style= \" border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px; \" " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 5 ) . " href= \" index.php?option= "
2020-03-28 13:34:14 +00:00
. $fieldData [ 'component' ] . " &view= " . $fieldData [ 'view' ]
. " &layout=edit'. \$ ref.' \" > " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 5 )
2020-03-28 13:34:14 +00:00
. " <span class= \" icon-new icon-white \" ></span></a>'; " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 ) . " } " ;
$addButton [] = Indent :: _ ( 3 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " only add if user allowed to edit " . $fieldData [ 'view' ];
2018-03-30 04:41:33 +00:00
// check if the item has permissions.
2020-03-28 13:34:14 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit' ])
&& isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]
)
&& in_array (
$fieldData [ 'view' ],
$this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]
))
2018-03-30 04:41:33 +00:00
{
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 ) . " if ( \$ user->authorise(' "
2020-03-28 13:34:14 +00:00
. $core [ 'core.edit' ] . " ', ' " . $component
. " ') && \$ app->isAdmin()) // TODO for now only in admin area. " ;
2018-03-30 04:41:33 +00:00
}
else
{
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. " if ( \$ user->authorise('core.edit', ' " . $component
. " ') && \$ app->isAdmin()) // TODO for now only in admin area. " ;
2018-05-26 10:03:08 +00:00
}
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 ) . " { " ;
$addButton [] = Indent :: _ ( 4 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " build edit button " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. " \$ button[] = '<a id= \" '. \$ button_code_name.'Edit \" class= \" btn btn-small hasTooltip \" title= \" '.JText: "
2022-08-30 15:28:41 +00:00
. " :sprintf(' " . CFactory :: _ ( 'Config' ) -> lang_prefix
2020-03-28 13:34:14 +00:00
. " _EDIT_S', \$ button_label).' \" style= \" display: none; padding: 4px 4px 4px 7px; \" href= \" # \" > " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 5 )
2020-03-28 13:34:14 +00:00
. " <span class= \" icon-edit \" ></span></a>'; " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " build script " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 ) . " \$ script[] = \" " ;
$addButton [] = Indent :: _ ( 5 ) . " jQuery(document).ready(function() { " ;
$addButton [] = Indent :: _ ( 6 )
2020-03-28 13:34:14 +00:00
. " jQuery('#adminForm').on('change', '#jform_ \" . \$ button_code_name. \" ',function (e) { " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 7 ) . " e.preventDefault(); " ;
$addButton [] = Indent :: _ ( 7 )
2020-03-28 13:34:14 +00:00
. " var \" . \$ button_code_name. \" Value = jQuery('#jform_ \" . \$ button_code_name. \" ').val(); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 7 )
2020-03-28 13:34:14 +00:00
. " \" . \$ button_code_name. \" Button( \" . \$ button_code_name. \" Value); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 6 ) . " }); " ;
$addButton [] = Indent :: _ ( 6 )
2020-03-28 13:34:14 +00:00
. " var \" . \$ button_code_name. \" Value = jQuery('#jform_ \" . \$ button_code_name. \" ').val(); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 6 )
2020-03-28 13:34:14 +00:00
. " \" . \$ button_code_name. \" Button( \" . \$ button_code_name. \" Value); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 5 ) . " }); " ;
$addButton [] = Indent :: _ ( 5 )
2020-03-28 13:34:14 +00:00
. " function \" . \$ button_code_name. \" Button(value) { " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 6 )
2020-03-28 13:34:14 +00:00
. " if (value > 0) { " ; // TODO not ideal since value may not be an (int)
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 7 ) . " // hide the create button " ;
$addButton [] = Indent :: _ ( 7 )
2020-03-28 13:34:14 +00:00
. " jQuery('# \" . \$ button_code_name. \" Create').hide(); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 7 ) . " // show edit button " ;
$addButton [] = Indent :: _ ( 7 )
2020-03-28 13:34:14 +00:00
. " jQuery('# \" . \$ button_code_name. \" Edit').show(); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 7 ) . " var url = 'index.php?option= "
2020-03-28 13:34:14 +00:00
. $fieldData [ 'component' ] . " &view= " . $fieldData [ 'views' ]
. " &task= " . $fieldData [ 'view' ]
. " .edit&id='+value+' \" . \$ refJ. \" '; " ; // TODO this value may not be the ID
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 7 )
2020-03-28 13:34:14 +00:00
. " jQuery('# \" . \$ button_code_name. \" Edit').attr('href', url); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 6 ) . " } else { " ;
$addButton [] = Indent :: _ ( 7 ) . " // show the create button " ;
$addButton [] = Indent :: _ ( 7 )
2020-03-28 13:34:14 +00:00
. " jQuery('# \" . \$ button_code_name. \" Create').show(); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 7 ) . " // hide edit button " ;
$addButton [] = Indent :: _ ( 7 )
2020-03-28 13:34:14 +00:00
. " jQuery('# \" . \$ button_code_name. \" Edit').hide(); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 6 ) . " } " ;
$addButton [] = Indent :: _ ( 5 ) . " } \" ; " ;
$addButton [] = Indent :: _ ( 3 ) . " } " ;
$addButton [] = Indent :: _ ( 3 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " check if button was created for " . $fieldData [ 'view' ]
. " field. " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. " if (is_array( \$ button) && count( \$ button) > 0) " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 ) . " { " ;
$addButton [] = Indent :: _ ( 4 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " Load the needed script. " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. " \$ document = JFactory::getDocument(); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. " \$ document->addScriptDeclaration(implode(' ', \$ script)); " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. " return the button attached to input field. " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 4 )
2020-03-28 13:34:14 +00:00
. " return '<div class= \" input-append \" >' . \$ html . implode('', \$ button).'</div>'; " ;
2022-08-30 15:28:41 +00:00
$addButton [] = Indent :: _ ( 3 ) . " } " ;
$addButton [] = Indent :: _ ( 2 ) . " } " ;
$addButton [] = Indent :: _ ( 2 ) . " return \$ html; " ;
$addButton [] = Indent :: _ ( 1 ) . " } " ;
2018-03-30 04:41:33 +00:00
return implode ( PHP_EOL , $addButton );
2016-03-01 18:44:13 +00:00
}
2020-03-28 13:34:14 +00:00
2018-03-30 04:41:33 +00:00
return '' ;
2016-03-01 18:44:13 +00:00
}
2017-12-03 19:12:56 +00:00
/**
* xmlPrettyPrint
*
2020-03-28 13:34:14 +00:00
* @ param SimpleXMLElement $xml The XML element containing a node to be output
* @ param string $nodename node name of the input xml element to print out . this is done to omit the < ? xml ... tag
2017-12-03 19:12:56 +00:00
*
* @ return string XML output
*
*/
2017-12-03 17:08:01 +00:00
public function xmlPrettyPrint ( $xml , $nodename )
{
2020-03-28 13:34:14 +00:00
$dom = dom_import_simplexml ( $xml ) -> ownerDocument ;
2017-12-03 17:08:01 +00:00
$dom -> formatOutput = true ;
2020-03-28 13:34:14 +00:00
$xmlString = $dom -> saveXML (
$dom -> getElementsByTagName ( $nodename ) -> item ( 0 )
);
2017-12-12 22:17:02 +00:00
// make sure Tidy is enabled
2022-08-30 15:28:41 +00:00
if ( CFactory :: _ ( 'Config' ) -> get ( 'tidy' , false ))
2017-12-12 22:17:02 +00:00
{
$tidy = new Tidy ();
2020-03-28 13:34:14 +00:00
$tidy -> parseString (
$xmlString , array ( 'indent' => true ,
2023-05-02 00:10:55 +00:00
'indent-spaces' => 8 , 'input-xml' => true ,
'output-xml' => true ,
'indent-attributes' => true ,
'wrap-attributes' => true , 'wrap' => false )
2020-03-28 13:34:14 +00:00
);
2017-12-12 22:17:02 +00:00
$tidy -> cleanRepair ();
2020-03-28 13:34:14 +00:00
2017-12-14 23:10:47 +00:00
return $this -> xmlIndent (( string ) $tidy , ' ' , 8 , true , false );
2017-12-12 22:17:02 +00:00
}
2023-01-15 08:42:19 +00:00
// set tidy waring only once
elseif ( CFactory :: _ ( 'Config' ) -> set_tidy_warning )
2017-12-12 22:17:02 +00:00
{
// set the warning only once
2023-01-15 08:42:19 +00:00
CFactory :: _ ( 'Config' ) -> set ( 'set_tidy_warning' , false );
2017-12-12 22:17:02 +00:00
// now set the warning
2020-03-28 13:34:14 +00:00
$this -> app -> enqueueMessage (
JText :: _ ( '<hr /><h3>Tidy Error</h3>' ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: _ (
'You must enable the <b>Tidy</b> extension in your php.ini file so we can tidy up your xml! If you need help please <a href="https://github.com/vdm-io/Joomla-Component-Builder/issues/197#issuecomment-351181754" target="_blank">start here</a>!'
), 'Error'
);
2017-12-12 22:17:02 +00:00
}
2020-03-28 13:34:14 +00:00
2017-12-12 22:17:02 +00:00
return $xmlString ;
2017-12-03 19:12:56 +00:00
}
2017-12-14 23:10:47 +00:00
2017-12-03 19:12:56 +00:00
/**
* xmlIndent
*
2020-03-28 13:34:14 +00:00
* @ param string $string The XML input
* @ param string $char Character or characters to use as the repeated indent
* @ param integer $depth number of times to repeat the indent character
* @ param boolean $skipfirst Skip the first line of the input .
* @ param boolean $skiplast Skip the last line of the input ;
2017-12-03 19:12:56 +00:00
*
* @ return string XML output
*
*/
2020-03-28 13:34:14 +00:00
public function xmlIndent ( $string , $char = ' ' , $depth = 0 ,
2023-05-02 00:10:55 +00:00
$skipfirst = false , $skiplast = false
2020-03-28 13:34:14 +00:00
) {
2017-12-03 19:12:56 +00:00
$output = array ();
2020-03-28 13:34:14 +00:00
$lines = explode ( " \n " , $string );
$first = true ;
$last = count ( $lines ) - 1 ;
2017-12-14 23:10:47 +00:00
foreach ( $lines as $i => $line )
2017-12-03 19:12:56 +00:00
{
2020-03-28 13:34:14 +00:00
$output [] = (( $first && $skipfirst ) || $i === $last && $skiplast )
? $line : str_repeat ( $char , $depth ) . $line ;
$first = false ;
2017-12-03 19:12:56 +00:00
}
2020-03-28 13:34:14 +00:00
2017-12-14 23:10:47 +00:00
return implode ( " \n " , $output );
2017-12-03 17:08:01 +00:00
}
2016-03-01 18:44:13 +00:00
}