2016-02-26 00:20:09 +00:00
< ? php
2021-12-21 14:44:50 +00:00
/**
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-02-26 00:20:09 +00:00
// No direct access to this file
defined ( '_JEXEC' ) or die ( 'Restricted access' );
2021-03-07 21:40:55 +00:00
use Joomla\CMS\Filesystem\File ;
use Joomla\CMS\Filesystem\Folder ;
2022-05-16 04:25:03 +00:00
use VDM\Joomla\Utilities\GuidHelper ;
2022-03-09 23:46:45 +00:00
use VDM\Joomla\Utilities\StringHelper ;
use VDM\Joomla\Utilities\JsonHelper ;
use VDM\Joomla\Utilities\ArrayHelper ;
use VDM\Joomla\Utilities\ObjectHelper ;
use VDM\Joomla\Utilities\GetHelper ;
2022-04-04 15:35:08 +00:00
use VDM\Joomla\Utilities\FileHelper ;
2022-03-09 23:46:45 +00:00
use VDM\Joomla\Utilities\String\FieldHelper ;
use VDM\Joomla\Utilities\String\TypeHelper ;
use VDM\Joomla\Utilities\String\ClassfunctionHelper ;
use VDM\Joomla\Utilities\String\NamespaceHelper ;
use VDM\Joomla\Utilities\String\PluginHelper ;
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 ;
2021-03-07 21:40:55 +00:00
2016-02-26 00:20:09 +00:00
/**
* Get class as the main compilers class
*/
class Get
{
2019-05-15 22:50:45 +00:00
2019-08-08 15:35:58 +00:00
/**
* The Joomla Version
2020-03-28 13:34:14 +00:00
*
2019-08-08 15:35:58 +00:00
* @ var string
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> joomla_version ;
2019-08-08 15:35:58 +00:00
*/
public $joomlaVersion ;
2021-12-21 14:44:50 +00:00
/**
* The Joomla Versions
*
* @ var array
*/
public $joomlaVersions = array (
3 => array ( 'folder_key' => 3 , 'xml_version' => 3.9 ), // only joomla 3
3.10 => array ( 'folder_key' => 3 , 'xml_version' => 4.0 ) // legacy joomla 4
);
2018-05-22 19:01:36 +00:00
/**
* The hash placeholder
2020-03-28 13:34:14 +00:00
*
2018-05-22 19:01:36 +00:00
* @ var string
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use Placefix :: h ();
2018-05-22 19:01:36 +00:00
*/
public $hhh = '#' . '#' . '#' ;
/**
* The open bracket placeholder
2020-03-28 13:34:14 +00:00
*
2018-05-22 19:01:36 +00:00
* @ var string
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use Placefix :: b ();
2018-05-22 19:01:36 +00:00
*/
public $bbb = '[' . '[' . '[' ;
/**
* The close bracket placeholder
2020-03-28 13:34:14 +00:00
*
2018-05-22 19:01:36 +00:00
* @ var string
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use Placefix :: d ();
2018-05-22 19:01:36 +00:00
*/
public $ddd = ']' . ']' . ']' ;
2017-10-26 16:43:51 +00:00
/**
* The app
2020-03-28 13:34:14 +00:00
*
2017-10-26 16:43:51 +00:00
* @ var object
*/
public $app ;
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Params
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var object
*/
public $params ;
2017-12-14 23:10:47 +00:00
2019-09-10 16:47:39 +00:00
/**
* Add strict field export permissions
2020-03-28 13:34:14 +00:00
*
2019-09-10 16:47:39 +00:00
* @ var boolean
*/
public $strictFieldExportPermissions = false ;
/**
* Add text only export options
2020-03-28 13:34:14 +00:00
*
2019-09-10 16:47:39 +00:00
* @ var boolean
*/
public $exportTextOnly = false ;
2019-02-15 22:03:21 +00:00
/**
* The global placeholders
2020-03-28 13:34:14 +00:00
*
2019-02-15 22:03:21 +00:00
* @ var array
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Component.Placeholder' ) -> get ();
2019-02-15 22:03:21 +00:00
*/
public $globalPlaceholders = array ();
2017-02-13 23:24:38 +00:00
/**
* The placeholders
2020-03-28 13:34:14 +00:00
*
2017-02-13 23:24:38 +00:00
* @ var array
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Placeholder' ) -> active [];
2017-02-13 23:24:38 +00:00
*/
public $placeholders = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Compiler Path
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var object
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> compiler_path ;
2016-02-26 00:20:09 +00:00
*/
public $compilerPath ;
2017-12-14 23:10:47 +00:00
2021-12-21 14:44:50 +00:00
/**
* The JCB Powers Path
*
* @ var object
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> jcb_powers_path ;
2021-12-21 14:44:50 +00:00
*/
public $jcbPowersPath ;
2020-12-10 01:24:29 +00:00
/**
* Switch to add assets table fix
*
* @ var int
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> add_assets_table_fix ;
2020-12-10 01:24:29 +00:00
*/
public $addAssetsTableFix = 1 ;
2020-12-12 06:24:57 +00:00
/**
* Assets table worse case
*
* @ var int
*/
public $accessWorseCase ;
2020-12-10 01:24:29 +00:00
/**
* Switch to add assets table name fix
*
* @ var bool
*/
public $addAssetsTableNameFix = false ;
2017-02-14 00:33:24 +00:00
/**
* Switch to add custom code placeholders
2020-03-28 13:34:14 +00:00
*
2017-02-14 00:33:24 +00:00
* @ var bool
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> add_placeholders ;
2017-02-14 00:33:24 +00:00
*/
public $addPlaceholders = false ;
2017-12-14 23:10:47 +00:00
2020-08-19 00:54:09 +00:00
/**
* Switch to remove line breaks from language strings
*
* @ var bool
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> remove_line_breaks ;
2020-08-19 00:54:09 +00:00
*/
public $removeLineBreaks = false ;
2018-08-02 05:36:47 +00:00
/**
* The placeholders for custom code keys
2020-03-28 13:34:14 +00:00
*
2018-08-02 05:36:47 +00:00
* @ var array
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3
2018-08-02 05:36:47 +00:00
*/
2020-03-28 13:34:14 +00:00
protected $customCodeKeyPlacholders
= array (
'[' => '[' ,
']' => ']' ,
',' => ',' ,
'+' => '+' ,
'=' => '='
2018-08-02 05:36:47 +00:00
);
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Component data
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var object
*/
public $componentData ;
2017-12-14 23:10:47 +00:00
2022-04-04 15:35:08 +00:00
/**
* The Switch to add Powers data
*
* @ var boolean
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> add_power ;
2022-04-04 15:35:08 +00:00
*/
2022-05-16 04:25:03 +00:00
public $addPower ;
2022-04-04 15:35:08 +00:00
2021-12-21 14:44:50 +00:00
/**
* The Powers data
*
* @ var array
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Power' ) -> active ;
2021-12-21 14:44:50 +00:00
*/
public $powers = array ();
/**
* The state of all Powers
*
* @ var array
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3
2021-12-21 14:44:50 +00:00
*/
public $statePowers = array ();
/**
* The linked Powers
*
* @ var array
*/
public $linkedPowers = array ();
2019-08-22 01:54:47 +00:00
/**
* The Plugins data
2020-03-28 13:34:14 +00:00
*
2019-08-22 01:54:47 +00:00
* @ var array
*/
public $joomlaPlugins = array ();
2019-12-06 05:31:32 +00:00
/**
* The Modules data
*
* @ var array
*/
public $joomlaModules = array ();
2019-08-15 14:26:46 +00:00
/**
2020-03-28 13:34:14 +00:00
* The custom script placeholders - we use the ( xxx ) to avoid detection it should be ( *** )
* ##################################---> PHP/JS <---####################################
*
* New Insert Code = / xxx [ INSERT <> $ $ $ $ ] xxx / / xxx [ / INSERT <> $ $ $ $ ] xxx /
* New Replace Code = / xxx [ REPLACE <> $ $ $ $ ] xxx / / xxx [ / REPLACE <> $ $ $ $ ] xxx /
*
* //////////////////////////////// when JCB adds it back //////////////////////////////////
2021-08-11 12:15:35 +00:00
* JCB Add Inserted Code = / xxx [ INSERTED $ $ $ $ ] xxx //xx23xx/ /xxx[/INSERTED$$$$]xxx/
* JCB Add Replaced Code = / xxx [ REPLACED $ $ $ $ ] xxx //xx25xx/ /xxx[/REPLACED$$$$]xxx/
2020-03-28 13:34:14 +00:00
*
* /////////////////////////////// changeing existing custom code /////////////////////////
2021-08-11 12:15:35 +00:00
* Update Inserted Code = / xxx [ INSERTED <> $ $ $ $ ] xxx //xx23xx/ /xxx[/INSERTED<>$$$$]xxx/
* Update Replaced Code = / xxx [ REPLACED <> $ $ $ $ ] xxx //xx25xx/ /xxx[/REPLACED<>$$$$]xxx/
2020-03-28 13:34:14 +00:00
*
* The custom script placeholders - we use the ( == ) to avoid detection it should be ( -- )
* ###################################---> HTML <---#####################################
*
* New Insert Code = <!== [ INSERT <> $ $ $ $ ] ==> <!== [ / INSERT <> $ $ $ $ ] ==>
* New Replace Code = <!== [ REPLACE <> $ $ $ $ ] ==> <!== [ / REPLACE <> $ $ $ $ ] ==>
*
* ///////////////////////////////// when JCB adds it back ///////////////////////////////
* JCB Add Inserted Code = <!== [ INSERTED $ $ $ $ ] ==><!== 23 ==> <!== [ / INSERTED $ $ $ $ ] ==>
* JCB Add Replaced Code = <!== [ REPLACED $ $ $ $ ] ==><!== 25 ==> <!== [ / REPLACED $ $ $ $ ] ==>
*
* //////////////////////////// changeing existing custom code ///////////////////////////
* Update Inserted Code = <!== [ INSERTED <> $ $ $ $ ] ==><!== 23 ==> <!== [ / INSERTED <> $ $ $ $ ] ==>
* Update Replaced Code = <!== [ REPLACED <> $ $ $ $ ] ==><!== 25 ==> <!== [ / REPLACED <> $ $ $ $ ] ==>
*
* ////////23 is the ID of the code in the system don't change it!!!!!!!!!!!!!!!!!!!!!!!!!!
*
* @ var array
2022-09-02 05:51:08 +00:00
*
* @ deprecated 3.3
2020-03-28 13:34:14 +00:00
*/
protected $customCodePlaceholders
= array (
1 => 'REPLACE<>$$$$]' ,
2 => 'INSERT<>$$$$]' ,
3 => 'REPLACED<>$$$$]' ,
4 => 'INSERTED<>$$$$]'
);
2017-12-14 23:10:47 +00:00
2017-02-01 13:17:04 +00:00
/**
* The custom code to be added
2020-03-28 13:34:14 +00:00
*
2017-02-01 13:17:04 +00:00
* @ var array
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Customcode' ) -> active
2017-02-01 13:17:04 +00:00
*/
public $customCode ;
2017-12-14 23:10:47 +00:00
2017-02-13 23:24:38 +00:00
/**
* The custom code to be added
2020-03-28 13:34:14 +00:00
*
2017-02-13 23:24:38 +00:00
* @ var array
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3
2017-02-13 23:24:38 +00:00
*/
protected $customCodeData = array ();
2017-12-14 23:10:47 +00:00
2017-02-13 23:24:38 +00:00
/**
* The function name memory ids
2020-03-28 13:34:14 +00:00
*
2017-02-13 23:24:38 +00:00
* @ var array
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Customcode' ) -> functionNameMemory
2017-02-13 23:24:38 +00:00
*/
public $functionNameMemory = array ();
2017-12-14 23:10:47 +00:00
2017-02-13 23:24:38 +00:00
/**
* The custom code for local memory
2020-03-28 13:34:14 +00:00
*
2017-02-13 23:24:38 +00:00
* @ var array
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Customcode' ) -> memory
2017-02-13 23:24:38 +00:00
*/
public $customCodeMemory = array ();
2017-12-14 23:10:47 +00:00
2017-02-01 13:17:04 +00:00
/**
2018-01-31 13:35:54 +00:00
* The custom code in local files that already exist in system
2020-03-28 13:34:14 +00:00
*
2017-02-01 13:17:04 +00:00
* @ var array
2022-09-02 05:51:08 +00:00
* @ deprecated 3.3
2017-02-01 13:17:04 +00:00
*/
protected $existingCustomCode = array ();
2017-12-14 23:10:47 +00:00
2017-02-01 13:17:04 +00:00
/**
* The custom code in local files this are new
2020-03-28 13:34:14 +00:00
*
2017-02-01 13:17:04 +00:00
* @ var array
2022-09-02 05:51:08 +00:00
* @ deprecated 3.3
2017-02-01 13:17:04 +00:00
*/
protected $newCustomCode = array ();
2017-12-14 23:10:47 +00:00
2017-02-09 16:11:10 +00:00
/**
* The index of code already loaded
2020-03-28 13:34:14 +00:00
*
2017-02-09 16:11:10 +00:00
* @ var array
2022-09-02 05:51:08 +00:00
* @ deprecated 3.3
2017-02-09 16:11:10 +00:00
*/
2017-12-14 23:10:47 +00:00
protected $codeAreadyDone = array ();
2018-01-31 13:35:54 +00:00
/**
2018-02-03 00:13:48 +00:00
* The external code / string to be added
2020-03-28 13:34:14 +00:00
*
2018-01-31 13:35:54 +00:00
* @ var array
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3
2018-01-31 13:35:54 +00:00
*/
2018-02-03 00:13:48 +00:00
protected $externalCodeString = array ();
2018-01-31 13:35:54 +00:00
2021-12-21 14:44:50 +00:00
/**
* The external code / string cutter
*
* @ var array
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3
2021-12-21 14:44:50 +00:00
*/
protected $externalCodeCutter = array ();
2017-02-13 23:24:38 +00:00
/*
* The line numbers Switch
2020-03-28 13:34:14 +00:00
*
2017-02-13 23:24:38 +00:00
* @ var boolean
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> debug_line_nr ;
2017-02-13 23:24:38 +00:00
*/
2017-12-14 23:10:47 +00:00
public $debugLinenr = false ;
2017-04-06 08:47:51 +00:00
/*
* The percentage when a language should be added
2020-03-28 13:34:14 +00:00
*
2017-04-06 08:47:51 +00:00
* @ var boolean
*/
public $percentageLanguageAdd = 0 ;
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2017-04-05 13:21:10 +00:00
* The Placholder Language prefix
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var string
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> lang_prefix ;
2016-02-26 00:20:09 +00:00
*/
2017-04-05 13:21:10 +00:00
public $langPrefix ;
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Language content
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3
2016-02-26 00:20:09 +00:00
*/
public $langContent = array ();
2017-12-14 23:10:47 +00:00
2017-04-05 13:21:10 +00:00
/**
* The Languages bucket
2020-03-28 13:34:14 +00:00
*
2017-04-05 13:21:10 +00:00
* @ var array
*/
2020-03-28 13:34:14 +00:00
public $languages
= array ( 'components' => array (), 'modules' => array (),
'plugins' => array ());
2018-04-19 23:36:21 +00:00
/**
* The Main Languages
2020-03-28 13:34:14 +00:00
*
2018-04-19 23:36:21 +00:00
* @ var string
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> lang_tag ;
2018-04-19 23:36:21 +00:00
*/
public $langTag = 'en-GB' ;
2017-12-14 23:10:47 +00:00
2017-04-05 13:21:10 +00:00
/**
* The Multi Languages bucket
2020-03-28 13:34:14 +00:00
*
2017-04-05 13:21:10 +00:00
* @ var array
*/
public $multiLangString = array ();
2017-12-14 23:10:47 +00:00
2017-04-05 13:21:10 +00:00
/**
* The new lang to add
2020-03-28 13:34:14 +00:00
*
2017-04-05 13:21:10 +00:00
* @ var array
*/
protected $newLangStrings = array ();
2017-12-14 23:10:47 +00:00
2017-04-05 13:21:10 +00:00
/**
* The existing lang to update
2020-03-28 13:34:14 +00:00
*
2017-04-05 13:21:10 +00:00
* @ var array
*/
protected $existingLangStrings = array ();
2017-12-14 23:10:47 +00:00
2017-12-14 13:30:21 +00:00
/**
* The Language JS matching check
2020-03-28 13:34:14 +00:00
*
2017-12-14 13:30:21 +00:00
* @ var array
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Language.Extractor' ) -> langMismatch ;
2017-12-14 13:30:21 +00:00
*/
public $langMismatch = array ();
2017-12-14 23:10:47 +00:00
2017-12-14 13:30:21 +00:00
/**
* The Language SC matching check
2020-03-28 13:34:14 +00:00
*
2017-12-14 13:30:21 +00:00
* @ var array
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Language.Extractor' ) -> langMatch ;
2017-12-14 13:30:21 +00:00
*/
public $langMatch = array ();
2017-12-14 23:10:47 +00:00
2017-12-14 13:30:21 +00:00
/**
* The Language string targets
2020-03-28 13:34:14 +00:00
*
2017-12-14 13:30:21 +00:00
* @ var array
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> lang_string_targets ;
2017-12-14 13:30:21 +00:00
*/
2020-03-28 13:34:14 +00:00
public $langStringTargets
= array (
'Joomla' . '.JText._(' ,
'JText:' . ':script(' ,
2020-07-07 15:13:04 +00:00
'Text:' . ':_(' , // namespace and J version will be found
'Text:' . ':sprintf(' , // namespace and J version will be found
2020-03-28 13:34:14 +00:00
'JustTEXT:' . ':_('
);
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Component Code Name
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var string
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> component_code_name ;
2016-02-26 00:20:09 +00:00
*/
public $componentCodeName ;
2017-12-14 23:10:47 +00:00
2022-08-21 17:21:03 +00:00
/**
* The Component Context
*
* @ var string
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> component_context ;
2022-08-21 17:21:03 +00:00
*/
public $componentContext ;
2020-12-10 01:24:29 +00:00
/**
* The Component Code Name Length
*
* @ var int
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> component_code_name_length ;
2020-12-10 01:24:29 +00:00
*/
public $componentCodeNameLength ;
2017-02-13 23:24:38 +00:00
/**
* The Component ID
2020-03-28 13:34:14 +00:00
*
2017-02-13 23:24:38 +00:00
* @ var int
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> component_id ;
2017-02-13 23:24:38 +00:00
*/
public $componentID ;
2017-12-14 23:10:47 +00:00
2017-02-13 23:24:38 +00:00
/**
* The current user
2020-03-28 13:34:14 +00:00
*
2017-02-13 23:24:38 +00:00
* @ var array
*/
public $user ;
2017-12-14 23:10:47 +00:00
2017-02-13 23:24:38 +00:00
/**
* The database object
2020-03-28 13:34:14 +00:00
*
2017-02-13 23:24:38 +00:00
* @ var array
*/
public $db ;
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Component version
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var string
*/
public $component_version ;
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The UIKIT Switch
2020-03-28 13:34:14 +00:00
*
* @ var boolean
2016-02-26 00:20:09 +00:00
*/
2017-11-11 04:33:51 +00:00
public $uikit = 0 ;
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The UIKIT component checker
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
*/
public $uikitComp = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The FOOTABLE Switch
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var boolean
*/
public $footable = false ;
2017-12-14 23:10:47 +00:00
2016-04-22 12:03:43 +00:00
/**
* The FOOTABLE Version
2020-03-28 13:34:14 +00:00
*
2016-04-22 12:03:43 +00:00
* @ var int
*/
public $footableVersion ;
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Google Chart Switch per view
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
*/
public $googleChart = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Google Chart Switch
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var boolean
*/
public $googlechart = false ;
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Import & Export Switch
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var boolean
*/
public $addEximport = false ;
2017-12-14 23:10:47 +00:00
2020-04-19 00:48:23 +00:00
/**
* The Import & Export View
*
* @ var array
*/
public $eximportView = array ();
/**
* The Import & Export Custom Script
*
* @ var array
*/
public $importCustomScripts = array ();
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Tag & History Switch
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var boolean
*/
public $setTagHistory = false ;
2017-12-14 23:10:47 +00:00
2018-08-23 01:37:42 +00:00
/**
* The Joomla Fields Switch
2020-03-28 13:34:14 +00:00
*
2018-08-23 01:37:42 +00:00
* @ var boolean
*/
public $setJoomlaFields = false ;
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The site edit views
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
*/
public $siteEditView = array ();
2017-12-14 23:10:47 +00:00
2020-11-17 04:06:34 +00:00
/**
* The admin list view filter type
*
* @ var array
*/
public $adminFilterType = array ();
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Language target
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var string
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> lang_target ;
2016-02-26 00:20:09 +00:00
*/
public $lang = 'admin' ;
2017-12-14 23:10:47 +00:00
2019-09-11 14:50:42 +00:00
/**
* The lang keys for extentions
2020-03-28 13:34:14 +00:00
*
2019-09-11 14:50:42 +00:00
* @ var array
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Language.Extractor' ) -> langKeys ;
2019-09-11 14:50:42 +00:00
*/
public $langKeys = array ();
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Build target Switch
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var string
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> build_target ;
2016-02-26 00:20:09 +00:00
*/
public $target ;
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The unique codes
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
*/
2016-02-26 13:57:30 +00:00
public $uniquecodes = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 13:57:30 +00:00
* The unique keys
2020-03-28 13:34:14 +00:00
*
2016-02-26 13:57:30 +00:00
* @ var array
*/
public $uniquekeys = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Ad contributors Switch
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var boolean
*/
public $addContributors = false ;
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Custom Script Builder
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
2022-08-31 11:49:01 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Customcode.Dispenser' ) -> hub ;
2016-02-26 00:20:09 +00:00
*/
public $customScriptBuilder = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Footable Script Builder
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
*/
public $footableScripts = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The pathe to the bom file to be used
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var string
*/
public $bomPath ;
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The SQL Tweak of admin views
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
*/
public $sqlTweak = array ();
2017-12-14 23:10:47 +00:00
2018-03-27 09:57:16 +00:00
/**
* The validation rules that should be added
2020-03-28 13:34:14 +00:00
*
2018-03-27 09:57:16 +00:00
* @ var array
2022-09-10 08:16:44 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'validation.rules' );
2018-03-27 09:57:16 +00:00
*/
public $validationRules = array ();
2019-08-22 01:54:47 +00:00
/**
* The validation linked to fields
2020-03-28 13:34:14 +00:00
*
2019-08-22 01:54:47 +00:00
* @ var array
2022-09-10 08:16:44 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'validation.linked' );
2019-08-22 01:54:47 +00:00
*/
public $validationLinkedFields = array ();
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The admin views data array
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
*/
private $_adminViewData = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The field data array
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
2022-09-10 08:16:44 +00:00
* @ deprecated 3.3
2016-02-26 00:20:09 +00:00
*/
private $_fieldData = array ();
2017-12-14 23:10:47 +00:00
2018-03-28 09:46:14 +00:00
/**
* The custom alias builder
2020-03-28 13:34:14 +00:00
*
2018-03-28 09:46:14 +00:00
* @ var array
*/
public $customAliasBuilder = array ();
2018-03-18 04:28:54 +00:00
/**
* The field builder type
2020-03-28 13:34:14 +00:00
*
2018-03-18 04:28:54 +00:00
* 1 = StringManipulation
* 2 = SimpleXMLElement
2020-03-28 13:34:14 +00:00
*
2018-03-18 04:28:54 +00:00
* @ var int
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> field_builder_type ;
2018-03-18 04:28:54 +00:00
*/
public $fieldBuilderType ;
2018-03-11 02:44:43 +00:00
/**
* Set unique Names
2020-03-28 13:34:14 +00:00
*
2018-03-11 02:44:43 +00:00
* @ var array
2022-09-10 08:16:44 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'unique.names' );
2018-03-11 02:44:43 +00:00
*/
public $uniqueNames = array ();
/**
* Set unique Names
2020-03-28 13:34:14 +00:00
*
2018-03-11 02:44:43 +00:00
* @ var array
2022-09-10 08:16:44 +00:00
* @ deprecated
2018-03-11 02:44:43 +00:00
*/
protected $uniqueFieldNames = array ();
/**
* Category other name bucket
2020-03-28 13:34:14 +00:00
*
2018-03-11 02:44:43 +00:00
* @ var array
2022-09-10 08:16:44 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Registry' ) -> get ( 'category.other.name' );
2018-03-11 02:44:43 +00:00
*/
public $catOtherName = array ();
2018-05-24 13:56:56 +00:00
/**
* The field relations values
2020-03-28 13:34:14 +00:00
*
2018-05-24 13:56:56 +00:00
* @ var array
2022-09-10 08:16:44 +00:00
* @ deprecate Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.field_relations' );
2018-05-24 13:56:56 +00:00
*/
public $fieldRelations = array ();
2020-05-21 23:38:20 +00:00
/**
* The views default ordering
*
* @ var array
*/
public $viewsDefaultOrdering = array ();
2018-07-12 16:35:38 +00:00
/**
* Default Fields
2020-03-28 13:34:14 +00:00
*
2018-07-12 16:35:38 +00:00
* @ var array
*/
2020-03-28 13:34:14 +00:00
public $defaultFields
= array ( 'created' , 'created_by' , 'modified' , 'modified_by' , 'published' ,
2021-12-21 14:44:50 +00:00
'ordering' , 'access' , 'version' , 'hits' , 'id' );
2018-07-12 16:35:38 +00:00
2018-05-24 13:56:56 +00:00
/**
* The list join fields
2020-03-28 13:34:14 +00:00
*
2018-05-24 13:56:56 +00:00
* @ var array
2022-09-10 08:16:44 +00:00
* @ deprecate Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.list_join' );
2018-05-24 13:56:56 +00:00
*/
public $listJoinBuilder = array ();
2018-05-29 03:45:16 +00:00
/**
* The list head over ride
2020-03-28 13:34:14 +00:00
*
2018-05-29 03:45:16 +00:00
* @ var array
2022-09-10 08:16:44 +00:00
* @ deprecate Use CFactory :: _ ( 'Registry' ) -> get ( 'builder.list_head_override' );
2018-05-29 03:45:16 +00:00
*/
public $listHeadOverRide = array ();
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The linked admin view tabs
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
*/
public $linkedAdminViews = array ();
2017-12-14 23:10:47 +00:00
2018-08-24 21:46:41 +00:00
/**
* The custom admin view tabs
2020-03-28 13:34:14 +00:00
*
2018-08-24 21:46:41 +00:00
* @ var array
*/
public $customTabs = array ();
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Add Ajax Switch
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var boolean
*/
public $addAjax = false ;
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Add Site Ajax Switch
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var boolean
*/
public $addSiteAjax = false ;
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The get Module Script Switch
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
*/
public $getModule = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The template data
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
*/
public $templateData = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The layout data
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
*/
public $layoutData = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2018-03-06 02:28:44 +00:00
* The Encryption Types
2020-03-28 13:34:14 +00:00
*
2018-03-06 02:28:44 +00:00
* @ var array
*/
2019-10-16 20:34:36 +00:00
public $cryptionTypes = array ( 'basic' , 'medium' , 'whmcs' , 'expert' );
2018-03-06 02:28:44 +00:00
/**
* The WHMCS Encryption Switch
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var boolean
2022-09-10 08:16:44 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> whmcs_encryption ;
2016-02-26 00:20:09 +00:00
*/
2018-03-06 02:28:44 +00:00
public $whmcsEncryption = false ;
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Basic Encryption Switch
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var boolean
2022-09-10 08:16:44 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> basic_encryption ;
2016-02-26 00:20:09 +00:00
*/
public $basicEncryption = false ;
2017-12-14 23:10:47 +00:00
2018-03-06 02:28:44 +00:00
/**
* The Medium Encryption Switch
2020-03-28 13:34:14 +00:00
*
2018-03-06 02:28:44 +00:00
* @ var boolean
2022-09-10 08:16:44 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> medium_encryption ;
2018-03-06 02:28:44 +00:00
*/
public $mediumEncryption = false ;
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The Custom field Switch per view
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
2022-09-10 08:16:44 +00:00
* @ deprecated 3.3
2016-02-26 00:20:09 +00:00
*/
public $customFieldScript = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The site main get
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
*/
public $siteMainGet = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The site dynamic get
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
*/
public $siteDynamicGet = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The get AS lookup
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
*/
public $getAsLookup = array ();
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The site fields
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
*/
public $siteFields = array ();
2017-12-14 23:10:47 +00:00
2017-06-16 12:38:06 +00:00
/**
* The add SQL
2020-03-28 13:34:14 +00:00
*
2017-06-16 12:38:06 +00:00
* @ var array
*/
public $addSQL = array ();
2017-12-14 23:10:47 +00:00
2017-06-16 12:38:06 +00:00
/**
* The update SQL
2020-03-28 13:34:14 +00:00
*
2017-06-16 12:38:06 +00:00
* @ var array
*/
public $updateSQL = array ();
2017-12-14 23:10:47 +00:00
2020-12-31 11:18:52 +00:00
/**
* The data by alias keys
*
* @ var array
*/
protected $dataWithAliasKeys = array ();
2017-12-03 18:09:04 +00:00
/**
* The Library Manager
2020-03-28 13:34:14 +00:00
*
2017-12-03 18:09:04 +00:00
* @ var array
*/
public $libManager = array ();
2017-12-14 23:10:47 +00:00
2017-12-03 18:09:04 +00:00
/**
* The Libraries
2020-03-28 13:34:14 +00:00
*
2017-12-03 18:09:04 +00:00
* @ var array
*/
public $libraries = array ();
2017-12-14 23:10:47 +00:00
2018-04-18 19:11:14 +00:00
/**
* Is minify Enabled
2020-03-28 13:34:14 +00:00
*
2018-04-18 19:11:14 +00:00
* @ var int
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> minify ;
2018-04-18 19:11:14 +00:00
*/
public $minify = 0 ;
2017-12-12 22:17:02 +00:00
/**
* Is Tidy Enabled
2020-03-28 13:34:14 +00:00
*
2017-12-12 22:17:02 +00:00
* @ var bool
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Config' ) -> tidy ;
2017-12-12 22:17:02 +00:00
*/
public $tidy = false ;
2017-12-14 23:10:47 +00:00
2017-12-12 22:17:02 +00:00
/**
* Set Tidy warning once switch
2020-03-28 13:34:14 +00:00
*
2017-12-12 22:17:02 +00:00
* @ var bool
*/
public $setTidyWarning = false ;
2016-02-26 00:20:09 +00:00
2018-09-25 20:02:48 +00:00
/**
* mysql table setting keys
2020-03-28 13:34:14 +00:00
*
2018-09-25 20:02:48 +00:00
* @ var array
*/
2020-03-28 13:34:14 +00:00
public $mysqlTableKeys
= array (
'engine' => array ( 'default' => 'MyISAM' ),
'charset' => array ( 'default' => 'utf8' ),
'collate' => array ( 'default' => 'utf8_general_ci' ),
'row_format' => array ( 'default' => '' )
2018-09-25 20:02:48 +00:00
);
/**
* mysql table settings
2020-03-28 13:34:14 +00:00
*
2018-09-25 20:02:48 +00:00
* @ var array
*/
public $mysqlTableSetting = array ();
2018-05-26 10:03:08 +00:00
/**
2016-02-26 00:20:09 +00:00
* Constructor
*/
2022-08-30 15:28:41 +00:00
public function __construct ()
2016-02-26 00:20:09 +00:00
{
2022-08-21 17:21:03 +00:00
// we do not yet have this set as an option
$config [ 'remove_line_breaks' ]
= 2 ; // 2 is global (use the components value)
// load application
$this -> app = JFactory :: getApplication ();
// Set the params
$this -> params = JComponentHelper :: getParams ( 'com_componentbuilder' );
// Trigger Event: jcb_ce_onBeforeGet
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger ( 'jcb_ce_onBeforeGet' , array ( & $config , & $this ));
2022-08-21 17:21:03 +00:00
// set the Joomla version @deprecated
2022-08-30 15:28:41 +00:00
$this -> joomlaVersion = CFactory :: _ ( 'Config' ) -> joomla_version ;
2022-08-21 17:21:03 +00:00
// set the minfy switch of the JavaScript @deprecated
2022-08-30 15:28:41 +00:00
$this -> minify = CFactory :: _ ( 'Config' ) -> get ( 'minify' , 0 );
2022-08-21 17:21:03 +00:00
// set the global language @deprecated @deprecated
2022-08-30 15:28:41 +00:00
$this -> langTag = CFactory :: _ ( 'Config' ) -> get ( 'lang_tag' , 'en-GB' );
2022-08-21 17:21:03 +00:00
// also set the helper class langTag (for safeStrings)
2022-08-30 15:28:41 +00:00
ComponentbuilderHelper :: $langTag = CFactory :: _ ( 'Config' ) -> get ( 'lang_tag' , 'en-GB' );
2022-08-21 17:21:03 +00:00
// setup the main language array
2022-08-30 15:28:41 +00:00
$this -> languages [ 'components' ][ CFactory :: _ ( 'Config' ) -> get ( 'lang_tag' , 'en-GB' )] = array ();
2022-08-21 17:21:03 +00:00
// check if we have Tidy enabled @deprecated
2022-08-30 15:28:41 +00:00
$this -> tidy = CFactory :: _ ( 'Config' ) -> get ( 'tidy' , false );
2022-08-21 17:21:03 +00:00
// set the field type builder @deprecated
2022-08-30 15:28:41 +00:00
$this -> fieldBuilderType = CFactory :: _ ( 'Config' ) -> get ( 'field_builder_type' , 2 );
2022-08-21 17:21:03 +00:00
// check the field builder type logic
2022-08-30 15:28:41 +00:00
if ( ! CFactory :: _ ( 'Config' ) -> get ( 'tidy' , false ) && CFactory :: _ ( 'Config' ) -> get ( 'field_builder_type' , 2 ) == 2 )
2022-08-21 17:21:03 +00:00
{
// we do not have the tidy extension set fall back to StringManipulation
$this -> fieldBuilderType = 1 ;
// load the sugestion to use string manipulation
$this -> app -> enqueueMessage (
JText :: _ ( '<hr /><h3>Field Notice</h3>' ), 'Notice'
2020-03-28 13:34:14 +00:00
);
2022-08-21 17:21:03 +00:00
$this -> app -> enqueueMessage (
JText :: _ (
'Since you do not have <b>Tidy</b> extentsion setup on your system, we could not use the SimpleXMLElement class. We instead used <b>string manipulation</b> to build all your fields, this is a faster method, you must inspect the xml files in your component package to see if you are satisfied with the result.<br />You can make this method your default by opening the global options of JCB and under the <b>Global</b> tab set the <b>Field Builder Type</b> to string manipulation.'
), 'Notice'
);
}
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> set ( 'field_builder_type' , $this -> fieldBuilderType );
2022-08-21 17:21:03 +00:00
// load the compiler path @deprecated
2022-08-30 15:28:41 +00:00
$this -> compilerPath = CFactory :: _ ( 'Config' ) -> get ( 'compiler_path' , JPATH_COMPONENT_ADMINISTRATOR . '/compiler' );
2022-08-21 17:21:03 +00:00
// load the jcb powers path @deprecated
2022-08-30 15:28:41 +00:00
$this -> jcbPowersPath = CFactory :: _ ( 'Config' ) -> get ( 'jcb_powers_path' , 'libraries/jcb_powers' );
2022-08-21 17:21:03 +00:00
// set the component ID @deprecated
2022-08-30 15:28:41 +00:00
$this -> componentID = CFactory :: _ ( 'Config' ) -> component_id ;
2022-08-21 17:21:03 +00:00
// set lang prefix @deprecated
2022-08-30 15:28:41 +00:00
$this -> langPrefix = CFactory :: _ ( 'Config' ) -> lang_prefix ;
2022-08-21 17:21:03 +00:00
// set component code name @deprecated
2022-08-30 15:28:41 +00:00
$this -> componentCodeName = CFactory :: _ ( 'Config' ) -> component_code_name ;
2022-08-21 17:21:03 +00:00
// set component context @deprecated
2022-08-30 15:28:41 +00:00
$this -> componentContext = CFactory :: _ ( 'Config' ) -> component_context ;
2022-08-21 17:21:03 +00:00
// set the component name length @deprecated
2022-08-30 15:28:41 +00:00
$this -> componentCodeNameLength = CFactory :: _ ( 'Config' ) -> component_code_name_length ;
2022-08-21 17:21:03 +00:00
// add assets table fix @deprecated
2022-08-30 15:28:41 +00:00
$this -> addAssetsTableFix = CFactory :: _ ( 'Config' ) -> add_assets_table_fix ;
2022-08-21 17:21:03 +00:00
// set if language strings line breaks should be removed @deprecated
2022-08-30 15:28:41 +00:00
$this -> removeLineBreaks = CFactory :: _ ( 'Config' ) -> remove_line_breaks ;
2022-08-21 17:21:03 +00:00
// set if placeholders should be added to customcode @deprecated
2022-08-30 15:28:41 +00:00
$this -> addPlaceholders = CFactory :: _ ( 'Config' ) -> get ( 'add_placeholders' , false );
2022-08-21 17:21:03 +00:00
// set if line numbers should be added to comments @deprecated
2022-08-30 15:28:41 +00:00
$this -> debugLinenr = CFactory :: _ ( 'Config' ) -> get ( 'debug_line_nr' , false );
2022-08-21 17:21:03 +00:00
// set if powers should be added to component (default is true) @deprecated
2022-08-30 15:28:41 +00:00
$this -> addPower = CFactory :: _ ( 'Config' ) -> get ( 'add_power' , true );
2022-08-21 17:21:03 +00:00
// set the current user
$this -> user = JFactory :: getUser ();
// Get a db connection.
$this -> db = JFactory :: getDbo ();
2022-08-30 15:28:41 +00:00
// get global placeholders @deprecated
$this -> globalPlaceholders = CFactory :: _ ( 'Component.Placeholder' ) -> get ();
2022-09-02 05:51:08 +00:00
// get the custom code from installed files
CFactory :: _ ( 'Customcode.Extractor' ) -> run ();
2022-08-21 17:21:03 +00:00
// Trigger Event: jcb_ce_onBeforeGetComponentData
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2022-08-21 17:21:03 +00:00
'jcb_ce_onBeforeGetComponentData' ,
array ( & $this -> componentContext , & $this )
);
// get the component data
$this -> componentData = $this -> getComponentData ();
// Trigger Event: jcb_ce_onAfterGetComponentData
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2022-08-21 17:21:03 +00:00
'jcb_ce_onAfterGetComponentData' ,
array ( & $this -> componentContext , & $this )
);
// make sure we have a version
if ( strpos ( $this -> componentData -> component_version , '.' )
=== false )
{
$this -> componentData -> component_version = '1.0.0' ;
}
// update the version
if ( ! isset ( $this -> componentData -> old_component_version )
&& ( ArrayHelper :: check ( $this -> addSQL )
|| ArrayHelper :: check (
$this -> updateSQL
)))
{
// set the new version
$version = ( array ) explode (
'.' , $this -> componentData -> component_version
);
// get last key
end ( $version );
$key = key ( $version );
// just increment the last
$version [ $key ] ++ ;
// set the old version
$this -> componentData -> old_component_version
= $this -> componentData -> component_version ;
// set the new version, and set update switch
$this -> componentData -> component_version = implode (
'.' , $version
2020-03-28 13:34:14 +00:00
);
2016-02-26 00:20:09 +00:00
}
2022-08-21 17:21:03 +00:00
// get powers *+*+*+*+*+*+*+*PRO
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Power' ) -> load ( $this -> linkedPowers );
2022-08-21 17:21:03 +00:00
// set the percentage when a language can be added
$this -> percentageLanguageAdd = ( int ) $this -> params -> get (
'percentagelanguageadd' , 50
);
2020-03-28 13:34:14 +00:00
2022-08-21 17:21:03 +00:00
// Trigger Event: jcb_ce_onBeforeGet
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2022-08-21 17:21:03 +00:00
'jcb_ce_onAfterGet' , array ( & $this -> componentContext , & $this )
);
return true ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
2018-05-26 10:03:08 +00:00
/**
* Set the tab / space
2020-03-28 13:34:14 +00:00
*
* @ param int $nr The number of tag / space
*
2018-05-26 10:03:08 +00:00
* @ return string
2022-09-10 08:16:44 +00:00
* @ deprecated 3.3 Use Indent :: _ ( $nr );
2018-05-26 10:03:08 +00:00
*/
public function _t ( $nr )
{
2019-09-04 11:52:31 +00:00
// use global method for conformity
2022-09-10 08:16:44 +00:00
return Indent :: _ ( $nr );
2018-05-26 10:03:08 +00:00
}
2019-06-22 10:43:26 +00:00
/**
* Trigger events
2020-03-28 13:34:14 +00:00
*
* @ param string $event The event to trigger
* @ param mix $data The values to pass to the event / plugin
*
2020-03-24 01:11:43 +00:00
* @ return void
2022-09-10 08:16:44 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Event' ) -> trigger ( $event , $data );
2019-06-22 10:43:26 +00:00
*/
public function triggerEvent ( $event , $data )
{
2022-09-10 08:16:44 +00:00
return CFactory :: _ ( 'Event' ) -> trigger ( $event , $data );
2019-06-22 10:43:26 +00:00
}
2019-02-15 22:03:21 +00:00
/**
* get all System Placeholders
*
* @ return array The global placeholders
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Component.Placeholder' ) -> get ();
2019-02-15 22:03:21 +00:00
*/
public function getGlobalPlaceholders ()
{
2022-08-30 15:28:41 +00:00
return CFactory :: _ ( 'Component.Placeholder' ) -> get ();
2019-02-15 22:03:21 +00:00
}
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* get all Component Data
2020-03-28 13:34:14 +00:00
*
* @ param int $id The component ID
2016-02-26 00:20:09 +00:00
*
* @ return oject The component data
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
*/
2017-02-13 23:24:38 +00:00
public function getComponentData ()
2016-02-26 00:20:09 +00:00
{
// Create a new query object.
2017-02-13 23:24:38 +00:00
$query = $this -> db -> getQuery ( true );
2019-07-28 21:48:42 +00:00
// selection
$selection = array (
2020-03-28 13:34:14 +00:00
'b.addadmin_views' => 'addadmin_views' ,
'b.id' => 'addadmin_views_id' ,
'h.addconfig' => 'addconfig' ,
2019-07-28 21:48:42 +00:00
'd.addcustom_admin_views' => 'addcustom_admin_views' ,
2020-03-28 13:34:14 +00:00
'g.addcustommenus' => 'addcustommenus' ,
'j.addfiles' => 'addfiles' ,
'j.addfolders' => 'addfolders' ,
'j.addfilesfullpath' => 'addfilesfullpath' ,
'j.addfoldersfullpath' => 'addfoldersfullpath' ,
'c.addsite_views' => 'addsite_views' ,
'l.addjoomla_plugins' => 'addjoomla_plugins' ,
'k.addjoomla_modules' => 'addjoomla_modules' ,
'i.dashboard_tab' => 'dashboard_tab' ,
2019-07-28 21:48:42 +00:00
'i.php_dashboard_methods' => 'php_dashboard_methods' ,
2021-12-21 14:44:50 +00:00
'i.params' => 'dashboard_params' ,
2020-03-28 13:34:14 +00:00
'i.id' => 'component_dashboard_id' ,
'f.sql_tweak' => 'sql_tweak' ,
'e.version_update' => 'version_update' ,
'e.id' => 'version_update_id'
);
2016-02-26 00:20:09 +00:00
$query -> select ( 'a.*' );
2017-10-29 11:03:06 +00:00
$query -> select (
$this -> db -> quoteName (
2019-07-28 21:48:42 +00:00
array_keys ( $selection ), array_values ( $selection )
2017-12-14 23:10:47 +00:00
)
);
2019-07-28 21:48:42 +00:00
// from this table
2017-02-16 14:02:23 +00:00
$query -> from ( '#__componentbuilder_joomla_component AS a' );
2019-07-28 21:48:42 +00:00
// jointer-map
$joiners = array (
'b' => 'component_admin_views' ,
'c' => 'component_site_views' ,
'd' => 'component_custom_admin_views' ,
'e' => 'component_updates' ,
'f' => 'component_mysql_tweaks' ,
'g' => 'component_custom_admin_menus' ,
'h' => 'component_config' ,
'i' => 'component_dashboard' ,
'j' => 'component_files_folders' ,
2019-12-06 05:31:32 +00:00
'l' => 'component_plugins' ,
'k' => 'component_modules'
2019-07-28 21:48:42 +00:00
);
// load the joins
2020-03-28 13:34:14 +00:00
foreach ( $joiners as $as => $join )
2019-07-28 21:48:42 +00:00
{
2020-03-28 13:34:14 +00:00
$query -> join (
'LEFT' ,
$this -> db -> quoteName ( '#__componentbuilder_' . $join , $as )
. ' ON (' . $this -> db -> quoteName ( 'a.id' ) . ' = '
. $this -> db -> quoteName ( $as . '.joomla_component' ) . ')'
);
2019-07-28 21:48:42 +00:00
}
2020-03-28 13:34:14 +00:00
$query -> where (
2022-08-30 15:28:41 +00:00
$this -> db -> quoteName ( 'a.id' ) . ' = ' . ( int ) CFactory :: _ ( 'Config' ) -> component_id
2020-03-28 13:34:14 +00:00
);
2016-02-26 00:20:09 +00:00
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onBeforeQueryComponentData
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2020-03-28 13:34:14 +00:00
'jcb_ce_onBeforeQueryComponentData' ,
array ( & $this -> componentContext , & $this -> componentID , & $query ,
2021-12-21 14:44:50 +00:00
& $this -> db )
2020-03-28 13:34:14 +00:00
);
2019-06-22 10:43:26 +00:00
2016-02-26 00:20:09 +00:00
// Reset the query using our newly populated query object.
2017-02-13 23:24:38 +00:00
$this -> db -> setQuery ( $query );
2016-02-26 00:20:09 +00:00
// Load the results as a list of stdClass objects
2017-02-13 23:24:38 +00:00
$component = $this -> db -> loadObject ();
2017-12-14 23:10:47 +00:00
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onBeforeModelComponentData
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2020-03-28 13:34:14 +00:00
'jcb_ce_onBeforeModelComponentData' ,
array ( & $this -> componentContext , & $component )
);
2019-06-22 10:43:26 +00:00
2020-07-07 15:13:04 +00:00
// set updater
2017-10-29 11:03:06 +00:00
$updater = array (
'unique' => array (
2020-03-28 13:34:14 +00:00
'addadmin_views' => array ( 'table' => 'component_admin_views' ,
'val' => ( int ) $component -> addadmin_views_id ,
'key' => 'id' ),
'addconfig' => array ( 'table' => 'component_config' ,
2022-08-30 15:28:41 +00:00
'val' => ( int ) CFactory :: _ ( 'Config' ) -> component_id ,
2020-03-28 13:34:14 +00:00
'key' => 'joomla_component' ),
'addcustom_admin_views' => array ( 'table' => 'component_custom_admin_views' ,
2022-08-30 15:28:41 +00:00
'val' => ( int ) CFactory :: _ ( 'Config' ) -> component_id ,
2020-03-28 13:34:14 +00:00
'key' => 'joomla_component' ),
'addcustommenus' => array ( 'table' => 'component_custom_admin_menus' ,
2022-08-30 15:28:41 +00:00
'val' => ( int ) CFactory :: _ ( 'Config' ) -> component_id ,
2020-03-28 13:34:14 +00:00
'key' => 'joomla_component' ),
'addfiles' => array ( 'table' => 'component_files_folders' ,
2022-08-30 15:28:41 +00:00
'val' => ( int ) CFactory :: _ ( 'Config' ) -> component_id ,
2020-03-28 13:34:14 +00:00
'key' => 'joomla_component' ),
'addfolders' => array ( 'table' => 'component_files_folders' ,
2022-08-30 15:28:41 +00:00
'val' => ( int ) CFactory :: _ ( 'Config' ) -> component_id ,
2020-03-28 13:34:14 +00:00
'key' => 'joomla_component' ),
'addsite_views' => array ( 'table' => 'component_site_views' ,
2022-08-30 15:28:41 +00:00
'val' => ( int ) CFactory :: _ ( 'Config' ) -> component_id ,
2020-03-28 13:34:14 +00:00
'key' => 'joomla_component' ),
'dashboard_tab' => array ( 'table' => 'component_dashboard' ,
2022-08-30 15:28:41 +00:00
'val' => ( int ) CFactory :: _ ( 'Config' ) -> component_id ,
2020-03-28 13:34:14 +00:00
'key' => 'joomla_component' ),
'sql_tweak' => array ( 'table' => 'component_mysql_tweaks' ,
2022-08-30 15:28:41 +00:00
'val' => ( int ) CFactory :: _ ( 'Config' ) -> component_id ,
2020-03-28 13:34:14 +00:00
'key' => 'joomla_component' ),
'version_update' => array ( 'table' => 'component_updates' ,
2022-08-30 15:28:41 +00:00
'val' => ( int ) CFactory :: _ ( 'Config' ) -> component_id ,
2020-03-28 13:34:14 +00:00
'key' => 'joomla_component' )
2017-10-29 11:03:06 +00:00
),
2020-03-28 13:34:14 +00:00
'table' => 'joomla_component' ,
'key' => 'id' ,
2022-08-30 15:28:41 +00:00
'val' => ( int ) CFactory :: _ ( 'Config' ) -> component_id
2017-10-29 11:03:06 +00:00
);
// repeatable fields to update
$searchRepeatables = array (
// repeatablefield => checker
2020-03-28 13:34:14 +00:00
'addadmin_views' => 'adminview' ,
'addconfig' => 'field' ,
'addcontributors' => 'name' ,
2017-10-29 11:03:06 +00:00
'addcustom_admin_views' => 'customadminview' ,
2020-03-28 13:34:14 +00:00
'addcustommenus' => 'name' ,
'addfiles' => 'file' ,
'addfolders' => 'folder' ,
'addsite_views' => 'siteview' ,
'dashboard_tab' => 'name' ,
'sql_tweak' => 'adminview' ,
'version_update' => 'version'
2017-10-29 11:03:06 +00:00
);
// update the repeatable fields
2020-03-28 13:34:14 +00:00
$component = ComponentbuilderHelper :: convertRepeatableFields (
$component , $searchRepeatables , $updater
);
2017-12-14 23:10:47 +00:00
2019-02-15 22:03:21 +00:00
// load the global placeholders
2022-09-14 15:40:02 +00:00
CFactory :: _ ( 'Placeholder' ) -> active = CFactory :: _ ( 'Component.Placeholder' ) -> get ();
2019-02-15 22:03:21 +00:00
2016-02-26 00:20:09 +00:00
// set component sales name
2022-03-09 23:46:45 +00:00
$component -> sales_name = StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$component -> system_name
);
2017-12-14 23:10:47 +00:00
2020-04-03 18:45:48 +00:00
// set the component name_code
2022-03-09 23:46:45 +00:00
$component -> name_code = StringHelper :: safe (
2020-04-03 18:45:48 +00:00
$component -> name_code
);
2016-02-26 00:20:09 +00:00
// ensure version naming is correct
2020-03-28 13:34:14 +00:00
$this -> component_version = preg_replace (
'/[^0-9.]+/' , '' , $component -> component_version
);
2017-12-14 23:10:47 +00:00
2018-02-16 21:53:43 +00:00
// set the add targets
2020-07-07 15:13:04 +00:00
$addArrayF = array ( 'files' => 'files' ,
'folders' => 'folders' ,
2020-03-28 13:34:14 +00:00
'filesfullpath' => 'files' ,
'foldersfullpath' => 'folders' );
2018-02-16 21:53:43 +00:00
foreach ( $addArrayF as $addTarget => $targetHere )
2016-02-26 00:20:09 +00:00
{
2018-02-16 21:53:43 +00:00
// set the add target data
2020-03-28 13:34:14 +00:00
$component -> { 'add' . $addTarget } = ( isset (
$component -> { 'add' . $addTarget }
)
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check (
2020-03-28 13:34:14 +00:00
$component -> { 'add' . $addTarget }
)) ? json_decode ( $component -> { 'add' . $addTarget }, true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$component -> { 'add' . $addTarget }
))
{
if ( isset ( $component -> { $targetHere })
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$component -> { $targetHere }
))
2018-02-16 21:53:43 +00:00
{
2018-03-18 04:52:07 +00:00
foreach ( $component -> { 'add' . $addTarget } as $taget )
2018-02-16 21:53:43 +00:00
{
$component -> { $targetHere }[] = $taget ;
}
}
else
{
2020-03-28 13:34:14 +00:00
$component -> { $targetHere } = array_values (
$component -> { 'add' . $addTarget }
);
2018-02-16 21:53:43 +00:00
}
}
2018-03-18 04:52:07 +00:00
unset ( $component -> { 'add' . $addTarget });
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
// set the uikit switch
2017-11-11 04:33:51 +00:00
$this -> uikit = $component -> adduikit ;
2017-12-14 23:10:47 +00:00
2018-07-08 20:18:32 +00:00
// set whmcs links if needed
2020-03-28 13:34:14 +00:00
if ( 1 == $component -> add_license
&& ( ! isset ( $component -> whmcs_buy_link )
2022-03-09 23:46:45 +00:00
|| ! StringHelper :: check (
2020-03-28 13:34:14 +00:00
$component -> whmcs_buy_link
)))
2018-07-08 20:18:32 +00:00
{
// update with the whmcs url
2020-03-28 13:34:14 +00:00
if ( isset ( $component -> whmcs_url )
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $component -> whmcs_url ))
2018-07-08 20:18:32 +00:00
{
$component -> whmcs_buy_link = $component -> whmcs_url ;
}
// use the company website
2020-03-28 13:34:14 +00:00
elseif ( isset ( $component -> website )
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $component -> website ))
2018-07-08 20:18:32 +00:00
{
$component -> whmcs_buy_link = $component -> website ;
2020-03-28 13:34:14 +00:00
$component -> whmcs_url = rtrim ( $component -> website , '/' )
. '/whmcs' ;
2018-07-08 20:18:32 +00:00
}
// none set
else
{
$component -> whmcs_buy_link = '#' ;
2020-03-28 13:34:14 +00:00
$component -> whmcs_url = '#' ;
2018-07-08 20:18:32 +00:00
}
}
2018-07-08 23:17:04 +00:00
// since the license details are not set clear
2018-07-10 15:09:21 +00:00
elseif ( 0 == $component -> add_license )
2018-07-08 23:17:04 +00:00
{
2020-03-28 13:34:14 +00:00
$component -> whmcs_key = '' ;
2018-07-08 23:17:04 +00:00
$component -> whmcs_buy_link = '' ;
2020-03-28 13:34:14 +00:00
$component -> whmcs_url = '' ;
2018-07-08 23:17:04 +00:00
}
2018-07-08 20:18:32 +00:00
2016-02-26 00:20:09 +00:00
// set the footable switch
if ( $component -> addfootable )
{
$this -> footable = true ;
2016-04-22 12:03:43 +00:00
// add the version
2020-03-28 13:34:14 +00:00
$this -> footableVersion = ( 1 == $component -> addfootable
|| 2 == $component -> addfootable ) ? 2 : $component -> addfootable ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
2017-10-29 11:03:06 +00:00
// set the addcustommenus data
2020-03-28 13:34:14 +00:00
$component -> addcustommenus = ( isset ( $component -> addcustommenus )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $component -> addcustommenus ))
2020-03-28 13:34:14 +00:00
? json_decode ( $component -> addcustommenus , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $component -> addcustommenus ))
2016-02-26 00:20:09 +00:00
{
2017-10-29 11:03:06 +00:00
$component -> custommenus = array_values ( $component -> addcustommenus );
2016-02-26 00:20:09 +00:00
}
2017-10-29 11:03:06 +00:00
unset ( $component -> addcustommenus );
2017-12-14 23:10:47 +00:00
2017-10-29 11:03:06 +00:00
// set the sql_tweak data
2020-03-28 13:34:14 +00:00
$component -> sql_tweak = ( isset ( $component -> sql_tweak )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $component -> sql_tweak ))
2020-03-28 13:34:14 +00:00
? json_decode ( $component -> sql_tweak , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $component -> sql_tweak ))
2016-02-26 00:20:09 +00:00
{
2017-10-29 11:03:06 +00:00
// build the tweak settings
2020-03-28 13:34:14 +00:00
$this -> setSqlTweaking (
array_map (
function ( $array ) {
return array_map (
function ( $value ) {
2022-03-09 23:46:45 +00:00
if ( ! ArrayHelper :: check ( $value )
&& ! ObjectHelper :: check (
2020-03-28 13:34:14 +00:00
$value
)
&& strval ( $value ) === strval (
intval ( $value )
))
{
return ( int ) $value ;
}
return $value ;
}, $array
);
}, array_values ( $component -> sql_tweak )
)
);
2016-02-26 00:20:09 +00:00
}
2017-10-29 11:03:06 +00:00
unset ( $component -> sql_tweak );
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
// set the admin_view data
2020-03-28 13:34:14 +00:00
$component -> addadmin_views = ( isset ( $component -> addadmin_views )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $component -> addadmin_views ))
2020-03-28 13:34:14 +00:00
? json_decode ( $component -> addadmin_views , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $component -> addadmin_views ))
2016-02-26 00:20:09 +00:00
{
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> lang_target = 'admin' ;
CFactory :: _ ( 'Config' ) -> build_target = 'admin' ;
2020-05-21 23:38:20 +00:00
// sort the views according to order
2020-03-28 13:34:14 +00:00
usort (
$component -> addadmin_views , function ( $a , $b ) {
2016-02-26 00:20:09 +00:00
if ( $a [ 'order' ] != 0 && $b [ 'order' ] != 0 )
{
return $a [ 'order' ] - $b [ 'order' ];
}
elseif ( $b [ 'order' ] != 0 && $a [ 'order' ] == 0 )
{
return 1 ;
}
elseif ( $a [ 'order' ] != 0 && $b [ 'order' ] == 0 )
{
return 0 ;
}
2020-03-28 13:34:14 +00:00
2016-02-26 00:20:09 +00:00
return 1 ;
2020-03-28 13:34:14 +00:00
}
);
2017-10-29 11:03:06 +00:00
// build the admin_views settings
2020-03-28 13:34:14 +00:00
$component -> admin_views = array_map (
function ( $array ) {
$array = array_map (
function ( $value ) {
2022-03-09 23:46:45 +00:00
if ( ! ArrayHelper :: check ( $value )
&& ! ObjectHelper :: check ( $value )
2020-03-28 13:34:14 +00:00
&& strval ( $value ) === strval ( intval ( $value )))
{
return ( int ) $value ;
}
return $value ;
}, $array
);
// check if we must add to site
if ( isset ( $array [ 'edit_create_site_view' ])
&& is_numeric (
$array [ 'edit_create_site_view' ]
)
&& $array [ 'edit_create_site_view' ] > 0 )
2017-10-29 11:03:06 +00:00
{
2020-03-28 13:34:14 +00:00
$this -> siteEditView [ $array [ 'adminview' ]] = true ;
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> lang_target = 'both' ;
2017-10-29 11:03:06 +00:00
}
2020-11-17 04:06:34 +00:00
// set the import/export option for this view
2020-03-28 13:34:14 +00:00
if ( isset ( $array [ 'port' ]) && $array [ 'port' ]
&& ! $this -> addEximport )
{
$this -> addEximport = true ;
}
2020-11-17 04:06:34 +00:00
// set the history tracking option for this view
2020-03-28 13:34:14 +00:00
if ( isset ( $array [ 'history' ]) && $array [ 'history' ]
&& ! $this -> setTagHistory )
{
$this -> setTagHistory = true ;
}
2020-11-17 04:06:34 +00:00
// set the custom field integration for this view
2020-03-28 13:34:14 +00:00
if ( isset ( $array [ 'joomla_fields' ])
&& $array [ 'joomla_fields' ]
&& ! $this -> setJoomlaFields )
{
$this -> setJoomlaFields = true ;
}
2020-04-03 18:45:48 +00:00
// has become a legacy issue, can't remove this
2020-03-28 13:34:14 +00:00
$array [ 'view' ] = $array [ 'adminview' ];
// get the admin settings/data
$array [ 'settings' ] = $this -> getAdminViewData (
$array [ 'view' ]
);
2020-11-17 04:06:34 +00:00
// set the filter option for this view
2020-11-29 00:00:20 +00:00
$this -> adminFilterType [ $array [ 'settings' ] -> name_list_code ]
= 1 ; // Side (old) [default for now]
2020-11-17 04:06:34 +00:00
if ( isset ( $array [ 'filter' ])
&& is_numeric (
$array [ 'filter' ]
)
&& $array [ 'filter' ] > 0 )
{
2020-11-29 00:00:20 +00:00
$this -> adminFilterType [ $array [ 'settings' ] -> name_list_code ]
= ( int ) $array [ 'filter' ];
2020-11-17 04:06:34 +00:00
}
2020-11-29 00:00:20 +00:00
2020-03-28 13:34:14 +00:00
return $array ;
}, array_values ( $component -> addadmin_views )
);
2016-02-26 00:20:09 +00:00
}
// set the site_view data
2020-03-28 13:34:14 +00:00
$component -> addsite_views = ( isset ( $component -> addsite_views )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $component -> addsite_views ))
2020-03-28 13:34:14 +00:00
? json_decode ( $component -> addsite_views , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $component -> addsite_views ))
2016-02-26 00:20:09 +00:00
{
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> lang_target = 'site' ;
CFactory :: _ ( 'Config' ) -> build_target = 'site' ;
2017-10-29 11:03:06 +00:00
// build the site_views settings
2020-03-28 13:34:14 +00:00
$component -> site_views = array_map (
function ( $array ) {
// has become a lacacy issue, can't remove this
$array [ 'view' ] = $array [ 'siteview' ];
$array [ 'settings' ] = $this -> getCustomViewData (
$array [ 'view' ]
);
return array_map (
function ( $value ) {
2022-03-09 23:46:45 +00:00
if ( ! ArrayHelper :: check ( $value )
&& ! ObjectHelper :: check ( $value )
2020-03-28 13:34:14 +00:00
&& strval ( $value ) === strval ( intval ( $value )))
{
return ( int ) $value ;
}
return $value ;
}, $array
);
}, array_values ( $component -> addsite_views )
);
2017-10-29 11:03:06 +00:00
// unset original value
2016-02-26 00:20:09 +00:00
unset ( $component -> addsite_views );
}
// set the custom_admin_views data
2020-03-28 13:34:14 +00:00
$component -> addcustom_admin_views
= ( isset ( $component -> addcustom_admin_views )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check (
2020-03-28 13:34:14 +00:00
$component -> addcustom_admin_views
)) ? json_decode ( $component -> addcustom_admin_views , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$component -> addcustom_admin_views
))
{
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> lang_target = 'admin' ;
CFactory :: _ ( 'Config' ) -> build_target = 'custom_admin' ;
2017-10-29 11:03:06 +00:00
// build the custom_admin_views settings
2020-03-28 13:34:14 +00:00
$component -> custom_admin_views = array_map (
function ( $array ) {
// has become a lacacy issue, can't remove this
$array [ 'view' ] = $array [ 'customadminview' ];
$array [ 'settings' ] = $this -> getCustomViewData (
$array [ 'view' ], 'custom_admin_view'
);
return array_map (
function ( $value ) {
2022-03-09 23:46:45 +00:00
if ( ! ArrayHelper :: check ( $value )
&& ! ObjectHelper :: check ( $value )
2020-03-28 13:34:14 +00:00
&& strval ( $value ) === strval ( intval ( $value )))
{
return ( int ) $value ;
}
return $value ;
}, $array
);
}, array_values ( $component -> addcustom_admin_views )
);
2017-10-29 11:03:06 +00:00
// unset original value
2016-02-26 00:20:09 +00:00
unset ( $component -> addcustom_admin_views );
}
2017-12-03 18:09:04 +00:00
// set the config data
2020-03-28 13:34:14 +00:00
$component -> addconfig = ( isset ( $component -> addconfig )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $component -> addconfig ))
2020-03-28 13:34:14 +00:00
? json_decode ( $component -> addconfig , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $component -> addconfig ))
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
$component -> config = array_map (
function ( $field ) {
// make sure the alias and title is 0
$field [ 'alias' ] = 0 ;
$field [ 'title' ] = 0 ;
// set the field details
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Field' ) -> set ( $field );
2020-03-28 13:34:14 +00:00
// set unique name counter
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Field.Unique.Name' ) -> set ( $field [ 'base_name' ], 'configs' );
2020-03-28 13:34:14 +00:00
// return field
return $field ;
}, array_values ( $component -> addconfig )
);
2018-03-11 02:44:43 +00:00
// do some house cleaning (for fields)
foreach ( $component -> config as $field )
{
// so first we lock the field name in
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Field.Name' ) -> get ( $field , 'configs' );
2018-03-11 02:44:43 +00:00
}
2017-10-29 11:03:06 +00:00
// unset original value
2016-02-26 00:20:09 +00:00
unset ( $component -> addconfig );
}
2017-12-14 23:10:47 +00:00
2017-10-29 11:03:06 +00:00
// set the addcustommenus data
2020-03-28 13:34:14 +00:00
$component -> addcontributors = ( isset ( $component -> addcontributors )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $component -> addcontributors ))
2020-03-28 13:34:14 +00:00
? json_decode ( $component -> addcontributors , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $component -> addcontributors ))
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
$this -> addContributors = true ;
$component -> contributors = array_values (
$component -> addcontributors
);
2016-02-26 00:20:09 +00:00
}
2017-10-29 11:03:06 +00:00
unset ( $component -> addcontributors );
2017-12-14 23:10:47 +00:00
2017-10-29 11:03:06 +00:00
// set the addcustommenus data
2020-03-28 13:34:14 +00:00
$component -> version_update = ( isset ( $component -> version_update )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $component -> version_update ))
2020-03-28 13:34:14 +00:00
? json_decode ( $component -> version_update , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $component -> version_update ))
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
$component -> version_update = array_values (
$component -> version_update
);
2017-10-29 11:03:06 +00:00
}
2017-12-14 23:10:47 +00:00
2017-06-16 12:38:06 +00:00
// build update SQL
2022-09-10 08:16:44 +00:00
$old_admin_views = CFactory :: _ ( 'History' ) -> get (
2020-03-28 13:34:14 +00:00
'component_admin_views' , $component -> addadmin_views_id
);
2022-09-10 08:16:44 +00:00
$old_component = CFactory :: _ ( 'History' ) -> get (
2022-08-30 15:28:41 +00:00
'joomla_component' , CFactory :: _ ( 'Config' ) -> component_id
2020-03-28 13:34:14 +00:00
);
2017-10-30 18:50:56 +00:00
if ( $old_component || $old_admin_views )
2017-06-16 12:38:06 +00:00
{
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check ( $old_admin_views ))
2017-06-16 12:38:06 +00:00
{
2017-10-30 13:08:02 +00:00
// add new views if found
2020-03-28 13:34:14 +00:00
if ( isset ( $old_admin_views -> addadmin_views )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check (
2020-03-28 13:34:14 +00:00
$old_admin_views -> addadmin_views
))
{
$this -> setUpdateSQL (
json_decode ( $old_admin_views -> addadmin_views , true ),
$component -> addadmin_views , 'adminview'
);
2017-10-30 13:08:02 +00:00
}
// check if a new version was manualy set
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check ( $old_component ))
2017-10-30 13:08:02 +00:00
{
2020-03-28 13:34:14 +00:00
$old_component_version = preg_replace (
'/[^0-9.]+/' , '' , $old_component -> component_version
);
2017-10-30 13:08:02 +00:00
if ( $old_component_version != $this -> component_version )
{
// yes, this is a new version, this mean there may be manual sql and must be checked and updated
2020-03-28 13:34:14 +00:00
$component -> old_component_version
= $old_component_version ;
2017-10-30 13:08:02 +00:00
}
// clear this data
unset ( $old_component );
}
// clear this data
unset ( $old_admin_views );
2017-06-16 12:38:06 +00:00
}
2016-02-26 00:20:09 +00:00
}
2017-10-29 11:03:06 +00:00
// unset original value
unset ( $component -> addadmin_views );
2016-02-26 00:20:09 +00:00
2019-07-28 21:48:42 +00:00
// set GUI mapper
2020-03-28 13:34:14 +00:00
$guiMapper = array ( 'table' => 'joomla_component' ,
2022-08-30 15:28:41 +00:00
'id' => ( int ) CFactory :: _ ( 'Config' ) -> component_id ,
2020-03-28 13:34:14 +00:00
'field' => 'javascript' , 'type' => 'js' );
2019-07-28 21:48:42 +00:00
2017-10-06 14:53:22 +00:00
// add_javascript
if ( $component -> add_javascript == 1 )
{
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$component -> javascript ,
'component_js' ,
2022-08-31 11:49:01 +00:00
null ,
null ,
2019-07-28 21:48:42 +00:00
$guiMapper
);
2017-10-06 14:53:22 +00:00
}
else
{
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ 'component_js' ] = '' ;
2017-10-06 14:53:22 +00:00
}
unset ( $component -> javascript );
2018-01-15 15:54:05 +00:00
// add global CSS
$addGlobalCss = array ( 'admin' , 'site' );
foreach ( $addGlobalCss as $area )
2016-02-26 00:20:09 +00:00
{
2018-01-15 15:54:05 +00:00
// add_css if found
2020-03-28 13:34:14 +00:00
if ( isset ( $component -> { 'add_css_' . $area })
&& $component -> { 'add_css_' . $area } == 1
&& isset ( $component -> { 'css_' . $area })
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$component -> { 'css_' . $area }
))
2018-01-15 15:54:05 +00:00
{
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$component -> { 'css_' . $area },
'component_css_' . $area
);
2018-01-15 15:54:05 +00:00
}
else
{
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ 'component_css_' . $area ] = '' ;
2018-01-15 15:54:05 +00:00
}
2018-03-18 04:52:07 +00:00
unset ( $component -> { 'css_' . $area });
2016-02-26 00:20:09 +00:00
}
2016-10-23 22:48:26 +00:00
// set the lang target
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> lang_target = 'admin' ;
2016-10-23 22:48:26 +00:00
// add PHP in ADMIN
2020-03-28 13:34:14 +00:00
$addScriptMethods = array ( 'php_preflight' , 'php_postflight' ,
2021-12-21 14:44:50 +00:00
'php_method' );
2020-03-28 13:34:14 +00:00
$addScriptTypes = array ( 'install' , 'update' , 'uninstall' );
2019-07-28 21:48:42 +00:00
// update GUI mapper
$guiMapper [ 'type' ] = 'php' ;
2016-10-23 22:48:26 +00:00
foreach ( $addScriptMethods as $scriptMethod )
2017-12-14 23:10:47 +00:00
{
2016-10-23 22:48:26 +00:00
foreach ( $addScriptTypes as $scriptType )
{
2020-03-28 13:34:14 +00:00
if ( isset (
$component -> { 'add_' . $scriptMethod . '_' . $scriptType }
)
&& $component -> { 'add_' . $scriptMethod . '_' . $scriptType }
== 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$component -> { $scriptMethod . '_' . $scriptType }
))
2016-10-23 22:48:26 +00:00
{
2019-07-28 21:48:42 +00:00
// set GUI mapper field
$guiMapper [ 'field' ] = $scriptMethod . '_' . $scriptType ;
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$component -> { $scriptMethod . '_' . $scriptType },
$scriptMethod ,
$scriptType ,
2022-08-31 11:49:01 +00:00
null ,
2019-07-28 21:48:42 +00:00
$guiMapper
);
2016-10-23 22:48:26 +00:00
}
else
{
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ $scriptMethod ][ $scriptType ] = '' ;
2016-10-23 22:48:26 +00:00
}
2017-12-14 23:10:47 +00:00
unset ( $component -> { $scriptMethod . '_' . $scriptType });
2016-10-23 22:48:26 +00:00
}
}
2016-02-26 00:20:09 +00:00
// add_php_helper
2020-03-28 13:34:14 +00:00
if ( $component -> add_php_helper_admin == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$component -> php_helper_admin
))
2016-02-26 00:20:09 +00:00
{
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> lang_target = 'admin' ;
2019-07-28 21:48:42 +00:00
// update GUI mapper
2020-03-28 13:34:14 +00:00
$guiMapper [ 'field' ] = 'php_helper_admin' ;
2019-07-28 21:48:42 +00:00
$guiMapper [ 'prefix' ] = PHP_EOL . PHP_EOL ;
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$component -> php_helper_admin ,
'component_php_helper_admin' ,
2022-08-31 11:49:01 +00:00
null ,
null ,
2019-07-28 21:48:42 +00:00
$guiMapper
);
unset ( $guiMapper [ 'prefix' ]);
2016-02-26 00:20:09 +00:00
}
else
{
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ 'component_php_helper_admin' ] = '' ;
2016-02-26 00:20:09 +00:00
}
2016-10-23 22:48:26 +00:00
unset ( $component -> php_helper );
2016-02-26 00:20:09 +00:00
// add_admin_event
2020-03-28 13:34:14 +00:00
if ( $component -> add_admin_event == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $component -> php_admin_event ))
2016-02-26 00:20:09 +00:00
{
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> lang_target = 'admin' ;
2019-07-28 21:48:42 +00:00
// update GUI mapper field
$guiMapper [ 'field' ] = 'php_admin_event' ;
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$component -> php_admin_event ,
'component_php_admin_event' ,
2022-08-31 11:49:01 +00:00
null ,
null ,
2019-07-28 21:48:42 +00:00
$guiMapper
);
2016-02-26 00:20:09 +00:00
}
else
{
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ 'component_php_admin_event' ] = '' ;
2016-02-26 00:20:09 +00:00
}
2016-10-23 22:48:26 +00:00
unset ( $component -> php_admin_event );
2016-11-25 02:56:16 +00:00
// add_php_helper_both
2020-03-28 13:34:14 +00:00
if ( $component -> add_php_helper_both == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $component -> php_helper_both ))
2016-11-25 02:56:16 +00:00
{
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> lang_target = 'both' ;
2019-07-28 21:48:42 +00:00
// update GUI mapper field
2020-03-28 13:34:14 +00:00
$guiMapper [ 'field' ] = 'php_helper_both' ;
2019-07-28 21:48:42 +00:00
$guiMapper [ 'prefix' ] = PHP_EOL . PHP_EOL ;
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$component -> php_helper_both ,
'component_php_helper_both' ,
2022-08-31 11:49:01 +00:00
null ,
null ,
2019-07-28 21:48:42 +00:00
$guiMapper
);
unset ( $guiMapper [ 'prefix' ]);
2016-11-25 02:56:16 +00:00
}
else
{
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ 'component_php_helper_both' ] = '' ;
2016-11-25 02:56:16 +00:00
}
2016-02-26 00:20:09 +00:00
// add_php_helper_site
2020-03-28 13:34:14 +00:00
if ( $component -> add_php_helper_site == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $component -> php_helper_site ))
2016-02-26 00:20:09 +00:00
{
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> lang_target = 'site' ;
2019-07-28 21:48:42 +00:00
// update GUI mapper field
2020-03-28 13:34:14 +00:00
$guiMapper [ 'field' ] = 'php_helper_site' ;
2019-07-28 21:48:42 +00:00
$guiMapper [ 'prefix' ] = PHP_EOL . PHP_EOL ;
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$component -> php_helper_site ,
'component_php_helper_site' ,
2022-08-31 11:49:01 +00:00
null ,
null ,
2019-07-28 21:48:42 +00:00
$guiMapper
);
unset ( $guiMapper [ 'prefix' ]);
2016-02-26 00:20:09 +00:00
}
else
{
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ 'component_php_helper_site' ] = '' ;
2016-02-26 00:20:09 +00:00
}
2016-10-23 22:48:26 +00:00
unset ( $component -> php_helper );
2016-02-26 00:20:09 +00:00
// add_site_event
2020-03-28 13:34:14 +00:00
if ( $component -> add_site_event == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $component -> php_site_event ))
2016-02-26 00:20:09 +00:00
{
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> lang_target = 'site' ;
2019-07-28 21:48:42 +00:00
// update GUI mapper field
$guiMapper [ 'field' ] = 'php_site_event' ;
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$component -> php_site_event ,
'component_php_site_event' ,
2022-08-31 11:49:01 +00:00
null ,
null ,
2019-07-28 21:48:42 +00:00
$guiMapper
);
2016-02-26 00:20:09 +00:00
}
else
{
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ 'component_php_site_event' ] = '' ;
2016-02-26 00:20:09 +00:00
}
2016-10-23 22:48:26 +00:00
unset ( $component -> php_site_event );
2016-02-26 00:20:09 +00:00
// add_sql
if ( $component -> add_sql == 1 )
{
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$component -> sql ,
'sql' ,
'component_sql'
);
2016-02-26 00:20:09 +00:00
}
2016-10-23 22:48:26 +00:00
unset ( $component -> sql );
2018-05-11 04:08:14 +00:00
// add_sql_uninstall
if ( $component -> add_sql_uninstall == 1 )
{
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$component -> sql_uninstall ,
'sql_uninstall'
);
2018-05-11 04:08:14 +00:00
}
unset ( $component -> sql_uninstall );
2016-02-26 00:20:09 +00:00
// bom
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $component -> bom ))
2016-02-26 00:20:09 +00:00
{
2022-08-30 15:28:41 +00:00
$this -> bomPath = CFactory :: _ ( 'Config' ) -> get ( 'compiler_path' , JPATH_COMPONENT_ADMINISTRATOR . '/compiler' ) . '/' . $component -> bom ;
2016-02-26 00:20:09 +00:00
}
else
{
2022-08-30 15:28:41 +00:00
$this -> bomPath = CFactory :: _ ( 'Config' ) -> get ( 'compiler_path' , JPATH_COMPONENT_ADMINISTRATOR . '/compiler' ) . '/default.txt' ;
2016-02-26 00:20:09 +00:00
}
2016-10-23 22:48:26 +00:00
unset ( $component -> bom );
2016-02-26 00:20:09 +00:00
// README
if ( $component -> addreadme )
{
2022-09-03 10:48:53 +00:00
$component -> readme = CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $component -> readme )
);
2016-02-26 00:20:09 +00:00
}
else
{
$component -> readme = '' ;
}
2018-03-18 04:52:07 +00:00
2017-12-10 19:17:26 +00:00
// set lang now
2022-08-30 15:28:41 +00:00
$nowLang = CFactory :: _ ( 'Config' ) -> lang_target ;
CFactory :: _ ( 'Config' ) -> lang_target = 'admin' ;
2016-02-26 00:20:09 +00:00
// dashboard methods
2020-03-28 13:34:14 +00:00
$component -> dashboard_tab = ( isset ( $component -> dashboard_tab )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $component -> dashboard_tab ))
2020-03-28 13:34:14 +00:00
? json_decode ( $component -> dashboard_tab , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $component -> dashboard_tab ))
2017-12-10 19:17:26 +00:00
{
2020-03-28 13:34:14 +00:00
$component -> dashboard_tab = array_map (
function ( $array ) {
2022-09-03 10:48:53 +00:00
$array [ 'html' ] = CFactory :: _ ( 'Customcode' ) -> update ( $array [ 'html' ]);
2020-03-28 13:34:14 +00:00
return $array ;
}, array_values ( $component -> dashboard_tab )
);
2017-10-29 11:03:06 +00:00
}
else
{
$component -> dashboard_tab = '' ;
}
// add the php of the dashboard if set
2020-03-28 13:34:14 +00:00
if ( isset ( $component -> php_dashboard_methods )
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$component -> php_dashboard_methods
))
2017-10-29 11:03:06 +00:00
{
2016-02-26 00:20:09 +00:00
// load the php for the dashboard model
2022-08-30 15:28:41 +00:00
$component -> php_dashboard_methods = CFactory :: _ ( 'Customcode.Gui' ) -> set (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $component -> php_dashboard_methods )
),
2019-07-28 21:48:42 +00:00
array (
'table' => 'component_dashboard' ,
'field' => 'php_dashboard_methods' ,
2020-03-28 13:34:14 +00:00
'id' => ( int ) $component -> component_dashboard_id ,
'type' => 'php' )
);
2016-02-26 00:20:09 +00:00
}
else
{
$component -> php_dashboard_methods = '' ;
}
2017-12-10 19:17:26 +00:00
// reset back to nowlang
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> lang_target = $nowLang ;
2017-12-14 23:10:47 +00:00
2018-02-17 22:47:01 +00:00
// add the update/sales server FTP details if that is the expected protocol
2018-03-18 04:52:07 +00:00
$serverArray = array ( 'update_server' , 'sales_server' );
foreach ( $serverArray as $server )
2017-08-25 01:46:12 +00:00
{
2020-03-28 13:34:14 +00:00
if ( $component -> { 'add_' . $server } == 1
&& is_numeric (
$component -> { $server }
)
&& $component -> { $server } > 0 )
2018-02-17 22:47:01 +00:00
{
// get the server protocol
2020-03-28 13:34:14 +00:00
$component -> { $server . '_protocol' }
2022-03-09 23:46:45 +00:00
= GetHelper :: var (
2020-03-28 13:34:14 +00:00
'server' , ( int ) $component -> { $server }, 'id' , 'protocol'
);
2018-02-17 22:47:01 +00:00
}
else
{
$component -> { $server } = 0 ;
2018-02-17 23:11:05 +00:00
// only change this for sales server (update server can be added loacaly to the zip file)
if ( 'sales_server' === $server )
{
2018-03-18 04:52:07 +00:00
$component -> { 'add_' . $server } = 0 ;
2018-02-17 23:11:05 +00:00
}
2018-03-18 04:52:07 +00:00
$component -> { $server . '_protocol' } = 0 ;
2018-02-17 22:47:01 +00:00
}
2017-08-25 01:46:12 +00:00
}
2017-09-18 00:18:23 +00:00
// set the ignore folders for repo if found
2020-03-28 13:34:14 +00:00
if ( isset ( $component -> toignore )
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$component -> toignore
))
2017-09-13 00:37:43 +00:00
{
if ( strpos ( $component -> toignore , ',' ) !== false )
{
2020-03-28 13:34:14 +00:00
$component -> toignore = array_map (
'trim' , ( array ) explode ( ',' , $component -> toignore )
);
2017-09-13 00:37:43 +00:00
}
else
{
$component -> toignore = array ( trim ( $component -> toignore ));
}
}
else
{
2017-09-18 00:18:23 +00:00
// the default is to ignore the repo folder
2017-09-13 00:37:43 +00:00
$component -> toignore = array ( '.git' );
}
2019-12-06 05:31:32 +00:00
// get all modules
2020-03-28 13:34:14 +00:00
$component -> addjoomla_modules = ( isset ( $component -> addjoomla_modules )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $component -> addjoomla_modules ))
2020-03-28 13:34:14 +00:00
? json_decode ( $component -> addjoomla_modules , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $component -> addjoomla_modules ))
2019-12-06 05:31:32 +00:00
{
2020-03-28 13:34:14 +00:00
$joomla_modules = array_map (
function ( $array ) use ( & $component ) {
// only load the modules whose target association calls for it
if ( ! isset ( $array [ 'target' ]) || $array [ 'target' ] != 2 )
{
return $this -> setJoomlaModule (
$array [ 'module' ], $component
);
}
return null ;
}, array_values ( $component -> addjoomla_modules )
);
2019-12-06 05:31:32 +00:00
}
unset ( $component -> addjoomla_modules );
2019-07-28 21:48:42 +00:00
// get all plugins
2020-03-28 13:34:14 +00:00
$component -> addjoomla_plugins = ( isset ( $component -> addjoomla_plugins )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $component -> addjoomla_plugins ))
2020-03-28 13:34:14 +00:00
? json_decode ( $component -> addjoomla_plugins , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $component -> addjoomla_plugins ))
2019-07-28 21:48:42 +00:00
{
2020-03-28 13:34:14 +00:00
$joomla_plugins = array_map (
function ( $array ) use ( & $component ) {
// only load the plugins whose target association calls for it
if ( ! isset ( $array [ 'target' ]) || $array [ 'target' ] != 2 )
{
return $this -> setJoomlaPlugin (
$array [ 'plugin' ], $component
);
}
return null ;
}, array_values ( $component -> addjoomla_plugins )
);
2019-07-28 21:48:42 +00:00
}
unset ( $component -> addjoomla_plugins );
2017-12-14 23:10:47 +00:00
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onAfterModelComponentData
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2020-03-28 13:34:14 +00:00
'jcb_ce_onAfterModelComponentData' ,
array ( & $this -> componentContext , & $component )
);
2019-06-22 10:43:26 +00:00
2016-02-26 00:20:09 +00:00
// return the found component data
return $component ;
}
2017-12-14 23:10:47 +00:00
2019-07-04 23:53:54 +00:00
/**
* set the language content values to language content array
2020-03-28 13:34:14 +00:00
*
* @ param string $target The target area for the language string
* @ param string $language The language key string
* @ param string $string The language string
* @ param boolean $addPrefix The switch to add langPrefix
2019-07-04 23:53:54 +00:00
*
* @ return void
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Language' ) -> set ( $target , $language , $string , $addPrefix );
2019-07-04 23:53:54 +00:00
*/
2020-03-28 13:34:14 +00:00
public function setLangContent ( $target , $language , $string ,
2021-12-21 14:44:50 +00:00
$addPrefix = false
)
{
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set ( $target , $language , $string , $addPrefix );
2020-08-19 00:54:09 +00:00
}
/**
* We need to remove all text breaks from all language strings
*
2020-11-29 00:00:20 +00:00
* @ param string $string The language string
2020-08-19 00:54:09 +00:00
*
* @ return string
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3
2020-08-19 00:54:09 +00:00
*/
public function fixLangString ( & $string )
{
2022-08-30 15:28:41 +00:00
if ( CFactory :: _ ( 'Config' ) -> remove_line_breaks )
2020-08-19 00:54:09 +00:00
{
return trim ( str_replace ( array ( PHP_EOL , " \r " , " \n " ), '' , $string ));
2019-07-04 23:53:54 +00:00
}
2020-11-29 00:00:20 +00:00
2020-08-19 00:54:09 +00:00
return trim ( $string );
2019-07-04 23:53:54 +00:00
}
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* Get all Admin View Data
2020-03-28 13:34:14 +00:00
*
* @ param int $id The view ID
2016-02-26 00:20:09 +00:00
*
* @ return oject The view data
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
*/
public function getAdminViewData ( $id )
{
if ( ! isset ( $this -> _adminViewData [ $id ]))
{
// Create a new query object.
2017-02-13 23:24:38 +00:00
$query = $this -> db -> getQuery ( true );
2016-02-26 00:20:09 +00:00
$query -> select ( 'a.*' );
2017-10-29 11:03:06 +00:00
$query -> select (
$this -> db -> quoteName (
array (
2020-03-28 13:34:14 +00:00
'b.addfields' ,
'b.id' ,
'c.addconditions' ,
'c.id' ,
'r.addrelations' ,
't.tabs'
2017-12-14 23:10:47 +00:00
), array (
2020-03-28 13:34:14 +00:00
'addfields' ,
'addfields_id' ,
'addconditions' ,
'addconditions_id' ,
'addrelations' ,
'customtabs'
2017-10-29 11:03:06 +00:00
)
2017-12-14 23:10:47 +00:00
)
);
2016-02-26 00:20:09 +00:00
$query -> from ( '#__componentbuilder_admin_view AS a' );
2020-03-28 13:34:14 +00:00
$query -> join (
'LEFT' ,
$this -> db -> quoteName ( '#__componentbuilder_admin_fields' , 'b' )
. ' ON (' . $this -> db -> quoteName ( 'a.id' ) . ' = '
. $this -> db -> quoteName ( 'b.admin_view' ) . ')'
);
$query -> join (
'LEFT' , $this -> db -> quoteName (
'#__componentbuilder_admin_fields_conditions' , 'c'
) . ' ON (' . $this -> db -> quoteName ( 'a.id' ) . ' = '
. $this -> db -> quoteName ( 'c.admin_view' ) . ')'
);
$query -> join (
'LEFT' , $this -> db -> quoteName (
'#__componentbuilder_admin_fields_relations' , 'r'
) . ' ON (' . $this -> db -> quoteName ( 'a.id' ) . ' = '
. $this -> db -> quoteName ( 'r.admin_view' ) . ')'
);
$query -> join (
'LEFT' , $this -> db -> quoteName (
'#__componentbuilder_admin_custom_tabs' , 't'
) . ' ON (' . $this -> db -> quoteName ( 'a.id' ) . ' = '
. $this -> db -> quoteName ( 't.admin_view' ) . ')'
);
2017-12-14 23:10:47 +00:00
$query -> where ( $this -> db -> quoteName ( 'a.id' ) . ' = ' . ( int ) $id );
2016-02-26 00:20:09 +00:00
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onBeforeQueryViewData
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2020-03-28 13:34:14 +00:00
'jcb_ce_onBeforeQueryViewData' ,
array ( & $this -> componentContext , & $id , & $query , & $this -> db )
);
2019-06-22 10:43:26 +00:00
2016-02-26 00:20:09 +00:00
// Reset the query using our newly populated query object.
2017-02-13 23:24:38 +00:00
$this -> db -> setQuery ( $query );
2016-02-26 00:20:09 +00:00
// Load the results as a list of stdClass objects (see later for more options on retrieving data).
2017-02-13 23:24:38 +00:00
$view = $this -> db -> loadObject ();
2018-01-15 15:54:05 +00:00
2020-11-17 04:06:34 +00:00
// setup single view code names to use in storing the data
$view -> name_single_code = 'oops_hmm_' . $id ;
if ( isset ( $view -> name_single ) && $view -> name_single != 'null' )
{
2022-03-09 23:46:45 +00:00
$view -> name_single_code = StringHelper :: safe (
2020-11-17 04:06:34 +00:00
$view -> name_single
);
}
2017-12-14 23:10:47 +00:00
2020-11-17 04:06:34 +00:00
// setup list view code name to use in storing the data
$view -> name_list_code = 'oops_hmmm_' . $id ;
if ( isset ( $view -> name_list ) && $view -> name_list != 'null' )
{
2022-03-09 23:46:45 +00:00
$view -> name_list_code = StringHelper :: safe (
2020-11-17 04:06:34 +00:00
$view -> name_list
);
}
2020-12-10 01:24:29 +00:00
// check the length of the view name (+5 for com_ and _)
2022-08-30 15:28:41 +00:00
$name_length = CFactory :: _ ( 'Config' ) -> component_code_name_length + strlen (
2020-12-10 01:24:29 +00:00
$view -> name_single_code
) + 5 ;
2022-09-10 08:16:44 +00:00
// when the name is larger than 49 we need to add the assets' table name fix
2020-12-10 01:24:29 +00:00
if ( $name_length > 49 )
{
$this -> addAssetsTableNameFix = true ;
}
2020-11-17 04:06:34 +00:00
// set updater
2017-10-29 11:03:06 +00:00
$updater = array (
'unique' => array (
2020-03-28 13:34:14 +00:00
'addfields' => array ( 'table' => 'admin_fields' ,
'val' => ( int ) $view -> addfields_id ,
'key' => 'id' ),
'addconditions' => array ( 'table' => 'admin_fields_conditions' ,
'val' => ( int ) $view -> addconditions_id ,
'key' => 'id' )
2017-10-29 11:03:06 +00:00
),
2020-03-28 13:34:14 +00:00
'table' => 'admin_view' ,
'key' => 'id' ,
'val' => ( int ) $id
2017-10-29 11:03:06 +00:00
);
// repeatable fields to update
$searchRepeatables = array (
// repeatablefield => checker
2020-03-28 13:34:14 +00:00
'addfields' => 'field' ,
'addconditions' => 'target_field' ,
'ajax_input' => 'value_name' ,
'custom_button' => 'name' ,
2017-12-14 23:10:47 +00:00
'addlinked_views' => 'adminview' ,
2020-03-28 13:34:14 +00:00
'addtables' => 'table' ,
'addtabs' => 'name' ,
'addpermissions' => 'action'
2017-10-29 11:03:06 +00:00
);
// update the repeatable fields
2020-03-28 13:34:14 +00:00
$view = ComponentbuilderHelper :: convertRepeatableFields (
$view , $searchRepeatables , $updater
);
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
// setup token check
2022-08-31 11:49:01 +00:00
if ( ! isset ( CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ 'token' ]))
2017-02-13 23:24:38 +00:00
{
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ 'token' ] = [];
2017-02-13 23:24:38 +00:00
}
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ 'token' ][ $view -> name_single_code ]
2020-11-29 00:00:20 +00:00
= false ;
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ 'token' ][ $view -> name_list_code ] = false ;
2017-10-06 14:53:22 +00:00
// set some placeholders
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'view' )]
2020-11-17 04:06:34 +00:00
= $view -> name_single_code ;
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'views' )]
2020-11-17 04:06:34 +00:00
= $view -> name_list_code ;
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'View' )]
2022-03-09 23:46:45 +00:00
= StringHelper :: safe (
2020-11-17 04:06:34 +00:00
$view -> name_single , 'F'
2020-03-28 13:34:14 +00:00
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'Views' )]
2022-03-09 23:46:45 +00:00
= StringHelper :: safe (
2020-11-17 04:06:34 +00:00
$view -> name_list , 'F'
2020-03-28 13:34:14 +00:00
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'VIEW' )]
2022-03-09 23:46:45 +00:00
= StringHelper :: safe (
2020-11-17 04:06:34 +00:00
$view -> name_single , 'U'
2020-03-28 13:34:14 +00:00
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'VIEWS' )]
2022-03-09 23:46:45 +00:00
= StringHelper :: safe (
2020-11-17 04:06:34 +00:00
$view -> name_list , 'U'
2020-03-28 13:34:14 +00:00
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'view' )]
= CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'view' )];
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'views' )]
= CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'views' )];
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'View' )]
= CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'View' )];
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'Views' )]
= CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'Views' )];
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'VIEW' )]
= CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'VIEW' )];
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'VIEWS' )]
= CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'VIEWS' )];
// for plugin event TODO change event api signatures
$this -> placeholders = CFactory :: _ ( 'Placeholder' ) -> active ;
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onBeforeModelViewData
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2020-03-28 13:34:14 +00:00
'jcb_ce_onBeforeModelViewData' ,
array ( & $this -> componentContext , & $view , & $this -> placeholders )
);
2022-08-30 15:28:41 +00:00
// for plugin event TODO change event api signatures
CFactory :: _ ( 'Placeholder' ) -> active = $this -> placeholders ;
2019-06-22 10:43:26 +00:00
2017-10-12 00:50:14 +00:00
// add the tables
2020-03-28 13:34:14 +00:00
$view -> addtables = ( isset ( $view -> addtables )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $view -> addtables ))
2020-03-28 13:34:14 +00:00
? json_decode ( $view -> addtables , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $view -> addtables ))
2017-10-12 00:50:14 +00:00
{
$view -> tables = array_values ( $view -> addtables );
}
unset ( $view -> addtables );
2018-08-24 21:46:41 +00:00
// set custom tabs
2020-11-17 04:06:34 +00:00
$this -> customTabs [ $view -> name_single_code ] = null ;
2020-11-29 00:00:20 +00:00
$view -> customtabs
= ( isset ( $view -> customtabs )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $view -> customtabs ))
2020-03-28 13:34:14 +00:00
? json_decode ( $view -> customtabs , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $view -> customtabs ))
2018-08-24 21:46:41 +00:00
{
// setup custom tabs to global data sets
2020-11-17 04:06:34 +00:00
$this -> customTabs [ $view -> name_single_code ] = array_map (
function ( $tab ) use ( & $view ) {
2020-03-28 13:34:14 +00:00
// set the view name
2020-11-17 04:06:34 +00:00
$tab [ 'view' ] = $view -> name_single_code ;
2020-03-28 13:34:14 +00:00
// load the dynamic data
2022-08-30 15:28:41 +00:00
$tab [ 'html' ] = CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update ( $tab [ 'html' ]),
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
);
// set the tab name
$tab [ 'name' ] = ( isset ( $tab [ 'name' ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$tab [ 'name' ]
)) ? $tab [ 'name' ] : 'Tab' ;
// set lang
2022-08-30 15:28:41 +00:00
$tab [ 'lang' ] = CFactory :: _ ( 'Config' ) -> lang_prefix . '_'
2022-03-09 23:46:45 +00:00
. StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$tab [ 'view' ], 'U'
2022-03-09 23:46:45 +00:00
) . '_' . StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$tab [ 'name' ], 'U'
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
2020-03-28 13:34:14 +00:00
'both' , $tab [ 'lang' ], $tab [ 'name' ]
);
// set code name
2022-03-09 23:46:45 +00:00
$tab [ 'code' ] = StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$tab [ 'name' ]
);
// check if the permissions for the tab should be added
$_tab = '' ;
if ( isset ( $tab [ 'permission' ])
&& $tab [ 'permission' ] == 1 )
{
2022-08-30 15:28:41 +00:00
$_tab = Indent :: _ ( 1 );
2020-03-28 13:34:14 +00:00
}
// check if the php of the tab is set, if not load it now
if ( strpos ( $tab [ 'html' ], 'bootstrap.addTab' ) === false
&& strpos ( $tab [ 'html' ], 'bootstrap.endTab' )
=== false )
{
// add the tab
2022-08-30 15:28:41 +00:00
$tmp = PHP_EOL . $_tab . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. " <?php echo JHtml::_('bootstrap.addTab', ' "
. $tab [ 'view' ] . " Tab', ' " . $tab [ 'code' ]
. " ', JText::_(' " . $tab [ 'lang' ]
. " ', true)); ?> " ;
2022-08-30 15:28:41 +00:00
$tmp .= PHP_EOL . $_tab . Indent :: _ ( 2 )
2020-03-28 13:34:14 +00:00
. '<div class="row-fluid form-horizontal-desktop">' ;
2022-08-30 15:28:41 +00:00
$tmp .= PHP_EOL . $_tab . Indent :: _ ( 3 )
2020-03-28 13:34:14 +00:00
. '<div class="span12">' ;
2022-08-30 15:28:41 +00:00
$tmp .= PHP_EOL . $_tab . Indent :: _ ( 4 ) . implode (
PHP_EOL . $_tab . Indent :: _ ( 4 ),
2020-03-28 13:34:14 +00:00
( array ) explode ( PHP_EOL , trim ( $tab [ 'html' ]))
);
2022-08-30 15:28:41 +00:00
$tmp .= PHP_EOL . $_tab . Indent :: _ ( 3 ) . '</div>' ;
$tmp .= PHP_EOL . $_tab . Indent :: _ ( 2 ) . '</div>' ;
$tmp .= PHP_EOL . $_tab . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. " <?php echo JHtml::_('bootstrap.endTab'); ?> " ;
// update html
$tab [ 'html' ] = $tmp ;
}
else
{
2022-08-30 15:28:41 +00:00
$tab [ 'html' ] = PHP_EOL . $_tab . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. implode (
2022-08-30 15:28:41 +00:00
PHP_EOL . $_tab . Indent :: _ ( 1 ),
2020-03-28 13:34:14 +00:00
( array ) explode ( PHP_EOL , trim ( $tab [ 'html' ]))
);
}
// add the permissions if needed
if ( isset ( $tab [ 'permission' ])
&& $tab [ 'permission' ] == 1 )
{
2022-08-30 15:28:41 +00:00
$tmp = PHP_EOL . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. " <?php if ( \$ this->canDo->get(' "
. $tab [ 'view' ] . " . " . $tab [ 'code' ]
. " .viewtab')) : ?> " ;
$tmp .= $tab [ 'html' ];
2022-08-30 15:28:41 +00:00
$tmp .= PHP_EOL . Indent :: _ ( 1 ) . " <?php endif; ?> " ;
2020-03-28 13:34:14 +00:00
// update html
$tab [ 'html' ] = $tmp ;
// set lang for permissions
$tab [ 'lang_permission' ] = $tab [ 'lang' ]
. '_TAB_PERMISSION' ;
$tab [ 'lang_permission_desc' ] = $tab [ 'lang' ]
. '_TAB_PERMISSION_DESC' ;
$tab [ 'lang_permission_title' ]
2022-08-30 15:28:41 +00:00
= CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'Views' )] . ' View '
2020-03-28 13:34:14 +00:00
. $tab [ 'name' ] . ' Tab' ;
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
2020-03-28 13:34:14 +00:00
'both' , $tab [ 'lang_permission' ],
$tab [ 'lang_permission_title' ]
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
2020-03-28 13:34:14 +00:00
'both' , $tab [ 'lang_permission_desc' ],
'Allow the users in this group to view '
. $tab [ 'name' ] . ' Tab of '
2022-08-30 15:28:41 +00:00
. CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'views' )]
2020-03-28 13:34:14 +00:00
);
// set the sort key
$tab [ 'sortKey' ]
2022-03-09 23:46:45 +00:00
= StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$tab [ 'lang_permission_title' ]
);
}
// return tab
return $tab ;
}, array_values ( $view -> customtabs )
);
2018-08-24 21:46:41 +00:00
}
unset ( $view -> customtabs );
// add the local tabs
2020-03-28 13:34:14 +00:00
$view -> addtabs = ( isset ( $view -> addtabs )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $view -> addtabs ))
2020-03-28 13:34:14 +00:00
? json_decode ( $view -> addtabs , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $view -> addtabs ))
2016-02-26 00:20:09 +00:00
{
2017-10-12 00:50:14 +00:00
$nr = 1 ;
foreach ( $view -> addtabs as $tab )
2016-02-26 00:20:09 +00:00
{
2017-10-26 16:43:51 +00:00
$view -> tabs [ $nr ] = trim ( $tab [ 'name' ]);
2017-10-12 00:50:14 +00:00
$nr ++ ;
2016-02-26 00:20:09 +00:00
}
}
2017-10-26 16:43:51 +00:00
// if Details tab is not set, then set it here
if ( ! isset ( $view -> tabs [ 1 ]))
{
2017-10-26 21:11:52 +00:00
$view -> tabs [ 1 ] = 'Details' ;
2017-10-26 16:43:51 +00:00
}
// always make sure that publishing is lowercase
2020-03-28 13:34:14 +00:00
if (( $removeKey = array_search (
'publishing' , array_map ( 'strtolower' , $view -> tabs )
)) !== false )
2017-10-26 16:43:51 +00:00
{
$view -> tabs [ $removeKey ] = 'publishing' ;
}
// make sure to set the publishing tab (just incase we need it)
$view -> tabs [ 15 ] = 'publishing' ;
2017-10-12 00:50:14 +00:00
unset ( $view -> addtabs );
// add permissions
2020-03-28 13:34:14 +00:00
$view -> addpermissions = ( isset ( $view -> addpermissions )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $view -> addpermissions ))
2020-03-28 13:34:14 +00:00
? json_decode ( $view -> addpermissions , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $view -> addpermissions ))
2017-10-12 00:50:14 +00:00
{
$view -> permissions = array_values ( $view -> addpermissions );
2016-02-26 00:20:09 +00:00
}
2017-10-12 00:50:14 +00:00
unset ( $view -> addpermissions );
// reset fields
$view -> fields = array ();
// set fields
2020-03-28 13:34:14 +00:00
$view -> addfields = ( isset ( $view -> addfields )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $view -> addfields ))
2020-03-28 13:34:14 +00:00
? json_decode ( $view -> addfields , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $view -> addfields ))
2016-02-26 00:20:09 +00:00
{
2018-07-12 16:35:38 +00:00
$ignoreFields = array ();
// load the field data
2020-03-28 13:34:14 +00:00
$view -> fields = array_map (
function ( $field ) use (
2020-11-17 04:06:34 +00:00
& $view , & $ignoreFields
2020-03-28 13:34:14 +00:00
) {
// set the field details
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Field' ) -> set (
2020-11-29 00:00:20 +00:00
$field , $view -> name_single_code ,
$view -> name_list_code
2020-03-28 13:34:14 +00:00
);
// check if this field is a default field OR
// check if this is none database related field
if ( in_array ( $field [ 'base_name' ], $this -> defaultFields )
|| ComponentbuilderHelper :: fieldCheck (
$field [ 'type_name' ], 'spacer'
)
|| ( isset ( $field [ 'list' ])
&& $field [ 'list' ] == 2 )) // 2 = none database
{
$ignoreFields [ $field [ 'field' ]] = $field [ 'field' ];
}
// return field
return $field ;
}, array_values ( $view -> addfields )
);
2017-10-12 23:14:17 +00:00
// build update SQL
2022-09-10 08:16:44 +00:00
if ( $old_view = CFactory :: _ ( 'History' ) -> get (
2020-03-28 13:34:14 +00:00
'admin_fields' , $view -> addfields_id
))
2017-10-12 23:14:17 +00:00
{
// add new fields were added
2020-03-28 13:34:14 +00:00
if ( isset ( $old_view -> addfields )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check (
2020-03-28 13:34:14 +00:00
$old_view -> addfields
))
{
$this -> setUpdateSQL (
json_decode ( $old_view -> addfields , true ),
2020-11-17 04:06:34 +00:00
$view -> addfields , 'field' , $view -> name_single_code ,
2020-03-28 13:34:14 +00:00
$ignoreFields
);
2017-12-14 23:10:47 +00:00
}
2017-10-12 23:14:17 +00:00
// clear this data
unset ( $old_view );
2016-02-26 00:20:09 +00:00
}
2020-05-21 23:38:20 +00:00
// sort the fields according to order
2020-03-28 13:34:14 +00:00
usort (
$view -> fields , function ( $a , $b ) {
2018-07-12 16:35:38 +00:00
if ( isset ( $a [ 'order_list' ]) && isset ( $b [ 'order_list' ]))
2017-10-12 23:14:17 +00:00
{
2018-07-12 16:35:38 +00:00
if ( $a [ 'order_list' ] != 0 && $b [ 'order_list' ] != 0 )
{
return $a [ 'order_list' ] - $b [ 'order_list' ];
}
elseif ( $b [ 'order_list' ] != 0 && $a [ 'order_list' ] == 0 )
2017-10-12 23:14:17 +00:00
{
return 1 ;
}
2018-07-12 16:35:38 +00:00
elseif ( $a [ 'order_list' ] != 0 && $b [ 'order_list' ] == 0 )
{
return 0 ;
}
2020-03-28 13:34:14 +00:00
2018-07-12 16:35:38 +00:00
return 1 ;
}
2020-03-28 13:34:14 +00:00
2018-07-12 16:35:38 +00:00
return 0 ;
2020-03-28 13:34:14 +00:00
}
);
2018-07-12 16:35:38 +00:00
// do some house cleaning (for fields)
foreach ( $view -> fields as $field )
{
// so first we lock the field name in
2022-09-10 08:16:44 +00:00
$field_name = CFactory :: _ ( 'Field.Name' ) -> get (
2020-11-29 00:00:20 +00:00
$field , $view -> name_list_code
);
2018-07-12 16:35:38 +00:00
// check if the field changed since the last compilation (default fields never change and are always added)
2020-03-28 13:34:14 +00:00
if ( ! isset ( $ignoreFields [ $field [ 'field' ]])
2022-03-09 23:46:45 +00:00
&& ObjectHelper :: check (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> history
))
2018-03-11 02:44:43 +00:00
{
2018-07-12 16:35:38 +00:00
// check if the datatype changed
if ( isset ( $field [ 'settings' ] -> history -> datatype ))
2018-03-11 02:44:43 +00:00
{
2020-03-28 13:34:14 +00:00
$this -> setUpdateSQL (
$field [ 'settings' ] -> history -> datatype ,
$field [ 'settings' ] -> datatype , 'field.datatype' ,
2020-11-17 04:06:34 +00:00
$view -> name_single_code . '.' . $field_name
2020-03-28 13:34:14 +00:00
);
2018-07-12 16:35:38 +00:00
}
// check if the datatype lenght changed
2020-03-28 13:34:14 +00:00
if ( isset ( $field [ 'settings' ] -> history -> datalenght )
&& isset ( $field [ 'settings' ] -> history -> datalenght_other ))
2018-07-12 16:35:38 +00:00
{
2020-03-28 13:34:14 +00:00
$this -> setUpdateSQL (
$field [ 'settings' ] -> history -> datalenght
. $field [ 'settings' ] -> history -> datalenght_other ,
$field [ 'settings' ] -> datalenght
. $field [ 'settings' ] -> datalenght_other ,
2020-11-29 00:00:20 +00:00
'field.lenght' ,
$view -> name_single_code . '.' . $field_name
2020-03-28 13:34:14 +00:00
);
2018-07-12 16:35:38 +00:00
}
// check if the name changed
2020-03-28 13:34:14 +00:00
if ( isset ( $field [ 'settings' ] -> history -> xml )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> history -> xml
))
2018-07-12 16:35:38 +00:00
{
// only run if this is not an alias or a tag
2020-03-28 13:34:14 +00:00
if (( ! isset ( $field [ 'alias' ]) || ! $field [ 'alias' ])
&& 'tag' !== $field [ 'settings' ] -> type_name )
2018-03-11 02:44:43 +00:00
{
2018-07-12 16:35:38 +00:00
// build temp field bucket
2020-03-28 13:34:14 +00:00
$tmpfield = array ();
2018-07-12 16:35:38 +00:00
$tmpfield [ 'settings' ] = new stdClass ();
// convert the xml json string to normal string
2020-03-28 13:34:14 +00:00
$tmpfield [ 'settings' ] -> xml
2022-09-03 10:48:53 +00:00
= CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
json_decode (
$field [ 'settings' ] -> history -> xml
)
);
2018-07-12 16:35:38 +00:00
// add properties from current field as it is generic
2020-03-28 13:34:14 +00:00
$tmpfield [ 'settings' ] -> properties
= $field [ 'settings' ] -> properties ;
2018-07-12 16:35:38 +00:00
// add the old name
2020-03-28 13:34:14 +00:00
$tmpfield [ 'settings' ] -> name
= $field [ 'settings' ] -> history -> name ;
2018-07-12 16:35:38 +00:00
// add the field type from current field since it is generic
2020-03-28 13:34:14 +00:00
$tmpfield [ 'settings' ] -> type_name
= $field [ 'settings' ] -> type_name ;
2018-07-12 16:35:38 +00:00
// get the old name
2022-09-10 08:16:44 +00:00
$old_field_name = CFactory :: _ ( 'Field.Name' ) -> get (
2020-03-28 13:34:14 +00:00
$tmpfield
);
2018-07-12 16:35:38 +00:00
// only run this if not a multi field
2022-09-10 08:16:44 +00:00
if ( CFactory :: _ ( 'Registry' ) -> get ( 'unique.names.' . $view -> name_list_code . '.names.' . $field_name ) === null )
2018-03-11 02:44:43 +00:00
{
2018-07-12 16:35:38 +00:00
// this only works when the field is not multiple of the same field
2020-03-28 13:34:14 +00:00
$this -> setUpdateSQL (
$old_field_name , $field_name ,
'field.name' ,
2020-11-29 00:00:20 +00:00
$view -> name_single_code . '.'
. $field_name
2020-03-28 13:34:14 +00:00
);
2018-07-12 16:35:38 +00:00
}
elseif ( $old_field_name !== $field_name )
{
// give a notice atleast that the multi fields could have changed and no DB update was done
2020-03-28 13:34:14 +00:00
$this -> app -> enqueueMessage (
JText :: _ ( '<hr /><h3>Field Notice</h3>' ),
'Notice'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'You have a field called <b>%s</b> that has been added multiple times to the <b>%s</b> view, the name of that field has changed to <b>%s</b>. Normaly we would automaticly add the update SQL to your component, but with multiple fields this does not work automaticly since it could be that noting changed and it just seems like it did. Therefore you will have to do this manualy if it actualy did change!' ,
2020-11-29 00:00:20 +00:00
$field_name ,
$view -> name_single_code ,
2020-03-28 13:34:14 +00:00
$old_field_name
), 'Notice'
);
2018-03-11 02:44:43 +00:00
}
2018-07-12 16:35:38 +00:00
// remove tmp
unset ( $tmpfield );
2018-03-11 02:44:43 +00:00
}
}
}
2017-10-12 23:14:17 +00:00
}
2017-10-29 11:03:06 +00:00
}
2017-12-14 23:10:47 +00:00
unset ( $view -> addfields );
2017-10-12 00:50:14 +00:00
// build update SQL
2022-09-10 08:16:44 +00:00
if ( $old_view = CFactory :: _ ( 'History' ) -> get ( 'admin_view' , $id ))
2017-10-12 00:50:14 +00:00
{
// check if the view name changed
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $old_view -> name_single ))
2017-10-12 00:50:14 +00:00
{
2020-03-28 13:34:14 +00:00
$this -> setUpdateSQL (
2022-03-09 23:46:45 +00:00
StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$old_view -> name_single
2020-11-29 00:00:20 +00:00
), $view -> name_single_code , 'table_name' ,
$view -> name_single_code
2020-03-28 13:34:14 +00:00
);
2017-12-14 23:10:47 +00:00
}
2018-09-25 20:02:48 +00:00
// loop the mysql table settings
2020-03-28 13:34:14 +00:00
foreach (
$this -> mysqlTableKeys as $_mysqlTableKey => $_mysqlTableVal
)
2018-09-25 20:02:48 +00:00
{
// check if the table engine changed
2020-03-28 13:34:14 +00:00
if ( isset ( $old_view -> { 'mysql_table_' . $_mysqlTableKey })
&& isset ( $view -> { 'mysql_table_' . $_mysqlTableKey }))
2018-09-25 20:02:48 +00:00
{
2020-03-28 13:34:14 +00:00
$this -> setUpdateSQL (
$old_view -> { 'mysql_table_' . $_mysqlTableKey },
$view -> { 'mysql_table_' . $_mysqlTableKey },
2020-11-17 04:06:34 +00:00
'table_' . $_mysqlTableKey , $view -> name_single_code
2020-03-28 13:34:14 +00:00
);
2018-09-25 20:02:48 +00:00
}
// check if there is no history on table engine, and it changed from the default/global
2020-03-28 13:34:14 +00:00
elseif ( isset ( $view -> { 'mysql_table_' . $_mysqlTableKey })
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$view -> { 'mysql_table_' . $_mysqlTableKey }
)
&& ! is_numeric (
$view -> { 'mysql_table_' . $_mysqlTableKey }
))
{
$this -> setUpdateSQL (
$_mysqlTableVal [ 'default' ],
$view -> { 'mysql_table_' . $_mysqlTableKey },
2020-11-17 04:06:34 +00:00
'table_' . $_mysqlTableKey , $view -> name_single_code
2020-03-28 13:34:14 +00:00
);
2018-09-25 20:02:48 +00:00
}
}
2017-10-12 00:50:14 +00:00
// clear this data
unset ( $old_view );
2017-12-14 23:10:47 +00:00
}
2017-10-12 23:14:17 +00:00
// set the conditions
2020-03-28 13:34:14 +00:00
$view -> addconditions = ( isset ( $view -> addconditions )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $view -> addconditions ))
2020-03-28 13:34:14 +00:00
? json_decode ( $view -> addconditions , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $view -> addconditions ))
2017-10-12 00:50:14 +00:00
{
2017-10-29 11:03:06 +00:00
$view -> conditions = array ();
2020-03-28 13:34:14 +00:00
$ne = 0 ;
2017-10-29 11:03:06 +00:00
foreach ( $view -> addconditions as $nr => $conditionValue )
2017-10-12 23:14:17 +00:00
{
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$conditionValue [ 'target_field' ]
)
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check ( $view -> fields ))
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
foreach (
$conditionValue [ 'target_field' ] as $fieldKey =>
$fieldId
)
2016-02-26 00:20:09 +00:00
{
2017-10-29 11:03:06 +00:00
foreach ( $view -> fields as $fieldValues )
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
if (( int ) $fieldValues [ 'field' ]
== ( int ) $fieldId )
2016-02-26 00:20:09 +00:00
{
2017-10-29 11:03:06 +00:00
// load the field details
2020-03-28 13:34:14 +00:00
$required
2022-04-04 15:35:08 +00:00
= GetHelper :: between (
2020-03-28 13:34:14 +00:00
$fieldValues [ 'settings' ] -> xml ,
'required="' , '"'
);
$required = ( $required === 'true'
|| $required === '1' ) ? 'yes' : 'no' ;
$filter
2022-04-04 15:35:08 +00:00
= GetHelper :: between (
2020-03-28 13:34:14 +00:00
$fieldValues [ 'settings' ] -> xml ,
'filter="' , '"'
);
$filter
2022-03-09 23:46:45 +00:00
= StringHelper :: check (
2020-03-28 13:34:14 +00:00
$filter
) ? $filter : 'none' ;
2017-10-29 11:03:06 +00:00
// set the field name
2020-03-28 13:34:14 +00:00
$conditionValue [ 'target_field' ][ $fieldKey ]
= array (
2022-09-10 08:16:44 +00:00
'name' => CFactory :: _ ( 'Field.Name' ) -> get (
2020-11-17 04:06:34 +00:00
$fieldValues , $view -> name_list_code
2020-03-28 13:34:14 +00:00
),
2022-09-10 08:16:44 +00:00
'type' => CFactory :: _ ( 'Field.Type.Name' ) -> get (
2020-03-28 13:34:14 +00:00
$fieldValues
),
2017-10-29 11:03:06 +00:00
'required' => $required ,
2020-03-28 13:34:14 +00:00
'filter' => $filter
2017-12-14 23:10:47 +00:00
);
2017-10-29 11:03:06 +00:00
break ;
2016-02-26 00:20:09 +00:00
}
}
}
2017-10-29 11:03:06 +00:00
}
2017-10-12 23:14:17 +00:00
2017-10-29 11:03:06 +00:00
// load match field
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $view -> fields )
2020-03-28 13:34:14 +00:00
&& isset ( $conditionValue [ 'match_field' ]))
2017-10-29 11:03:06 +00:00
{
foreach ( $view -> fields as $fieldValue )
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
if (( int ) $fieldValue [ 'field' ]
== ( int ) $conditionValue [ 'match_field' ])
2016-02-26 00:20:09 +00:00
{
2018-03-11 02:44:43 +00:00
// set the type
2022-09-10 08:16:44 +00:00
$type = CFactory :: _ ( 'Field.Type.Name' ) -> get ( $fieldValue );
2017-10-29 11:03:06 +00:00
// set the field details
2020-03-28 13:34:14 +00:00
$conditionValue [ 'match_name' ]
2022-09-10 08:16:44 +00:00
= CFactory :: _ ( 'Field.Name' ) -> get (
2020-11-17 04:06:34 +00:00
$fieldValue , $view -> name_list_code
2020-03-28 13:34:14 +00:00
);
2018-03-11 02:44:43 +00:00
$conditionValue [ 'match_type' ] = $type ;
2020-03-28 13:34:14 +00:00
$conditionValue [ 'match_xml' ]
= $fieldValue [ 'settings' ] -> xml ;
2017-10-29 11:03:06 +00:00
// if custom field load field being extended
2018-05-24 13:56:56 +00:00
if ( ! ComponentbuilderHelper :: fieldCheck ( $type ))
2017-10-12 00:50:14 +00:00
{
2020-03-28 13:34:14 +00:00
$conditionValue [ 'match_extends' ]
2022-04-04 15:35:08 +00:00
= GetHelper :: between (
2020-03-28 13:34:14 +00:00
$fieldValue [ 'settings' ] -> xml ,
'extends="' , '"'
);
2017-10-12 00:50:14 +00:00
}
2017-10-29 11:03:06 +00:00
else
{
$conditionValue [ 'match_extends' ] = '' ;
}
break ;
2016-02-26 00:20:09 +00:00
}
}
}
2017-10-29 11:03:06 +00:00
// set condition values
$view -> conditions [ $ne ] = $conditionValue ;
$ne ++ ;
2016-02-26 00:20:09 +00:00
}
}
2017-10-29 11:03:06 +00:00
unset ( $view -> addconditions );
2018-05-24 13:56:56 +00:00
// set the relations
2020-03-28 13:34:14 +00:00
$view -> addrelations = ( isset ( $view -> addrelations )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $view -> addrelations ))
2020-03-28 13:34:14 +00:00
? json_decode ( $view -> addrelations , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $view -> addrelations ))
2018-05-24 13:56:56 +00:00
{
foreach ( $view -> addrelations as $nr => $relationsValue )
{
2022-09-10 08:16:44 +00:00
// only add if list view field is selected and joined fields are set
2020-03-28 13:34:14 +00:00
if ( isset ( $relationsValue [ 'listfield' ])
&& is_numeric (
$relationsValue [ 'listfield' ]
)
&& $relationsValue [ 'listfield' ] > 0
&& isset ( $relationsValue [ 'area' ])
&& is_numeric ( $relationsValue [ 'area' ])
&& $relationsValue [ 'area' ] > 0 )
2018-05-24 13:56:56 +00:00
{
2018-05-26 10:03:08 +00:00
// do a dynamic update on the set values
2020-03-28 13:34:14 +00:00
if ( isset ( $relationsValue [ 'set' ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$relationsValue [ 'set' ]
))
2018-05-26 10:03:08 +00:00
{
2022-09-03 10:48:53 +00:00
$relationsValue [ 'set' ] = CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
$relationsValue [ 'set' ]
);
2018-05-26 10:03:08 +00:00
}
2022-09-10 08:16:44 +00:00
2018-05-24 13:56:56 +00:00
// load the field relations
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.field_relations.' . $view -> name_list_code . '.' . ( int ) $relationsValue [ 'listfield' ]
. '.' . ( int ) $relationsValue [ 'area' ], $relationsValue );
2018-05-24 13:56:56 +00:00
// load the list joints
2020-03-28 13:34:14 +00:00
if ( isset ( $relationsValue [ 'joinfields' ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$relationsValue [ 'joinfields' ]
))
2018-05-24 13:56:56 +00:00
{
2018-07-21 07:10:37 +00:00
foreach ( $relationsValue [ 'joinfields' ] as $join )
{
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.list_join.' . $view -> name_list_code . '.' . ( int ) $join , ( int ) $join );
2018-07-21 07:10:37 +00:00
}
2018-05-24 13:56:56 +00:00
}
2018-05-29 03:45:16 +00:00
// set header over-ride
2020-03-28 13:34:14 +00:00
if ( isset ( $relationsValue [ 'column_name' ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$relationsValue [ 'column_name' ]
))
2018-05-29 03:45:16 +00:00
{
2020-03-28 13:34:14 +00:00
$check_column_name = trim (
strtolower ( $relationsValue [ 'column_name' ])
);
2018-05-29 03:45:16 +00:00
// confirm it should really make the over ride
if ( 'default' !== $check_column_name )
{
2022-08-30 15:28:41 +00:00
$column_name_lang = CFactory :: _ ( 'Config' ) -> lang_prefix . '_'
2022-03-09 23:46:45 +00:00
. StringHelper :: safe (
2020-11-17 04:06:34 +00:00
$view -> name_list_code , 'U'
2020-03-28 13:34:14 +00:00
) . '_'
2022-03-09 23:46:45 +00:00
. StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$relationsValue [ 'column_name' ], 'U'
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
2020-03-28 13:34:14 +00:00
'admin' , $column_name_lang ,
$relationsValue [ 'column_name' ]
);
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Registry' ) -> set ( 'builder.list_head_override.' .
$view -> name_list_code . '.' . ( int ) $relationsValue [ 'listfield' ],
$column_name_lang
);
2018-05-29 03:45:16 +00:00
}
}
2018-05-24 13:56:56 +00:00
}
}
}
unset ( $view -> addrelations );
2016-02-26 00:20:09 +00:00
// set linked views
2020-11-17 04:06:34 +00:00
$this -> linkedAdminViews [ $view -> name_single_code ] = null ;
2020-03-28 13:34:14 +00:00
$view -> addlinked_views
2020-11-29 00:00:20 +00:00
= ( isset ( $view -> addlinked_views )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $view -> addlinked_views ))
2020-03-28 13:34:14 +00:00
? json_decode ( $view -> addlinked_views , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $view -> addlinked_views ))
2017-10-12 00:50:14 +00:00
{
// setup linked views to global data sets
2020-11-17 04:06:34 +00:00
$this -> linkedAdminViews [ $view -> name_single_code ] = array_values (
2020-03-28 13:34:14 +00:00
$view -> addlinked_views
);
2016-02-26 00:20:09 +00:00
}
2017-10-12 00:50:14 +00:00
unset ( $view -> addlinked_views );
2016-06-23 15:05:37 +00:00
// set the lang target
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> lang_target = 'admin' ;
2018-03-30 01:29:24 +00:00
if ( isset ( $this -> siteEditView [ $id ]))
{
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> lang_target = 'both' ;
2018-03-30 01:29:24 +00:00
}
2019-07-28 21:48:42 +00:00
// set GUI mapper
2020-03-28 13:34:14 +00:00
$guiMapper = array ( 'table' => 'admin_view' , 'id' => ( int ) $id ,
'type' => 'js' );
2016-06-23 15:05:37 +00:00
// add_javascript
2020-03-28 13:34:14 +00:00
$addArrayJ = array ( 'javascript_view_file' , 'javascript_view_footer' ,
2021-12-21 14:44:50 +00:00
'javascript_views_file' ,
'javascript_views_footer' );
2019-07-28 21:48:42 +00:00
// update GUI mapper
$guiMapper [ 'prefix' ] = PHP_EOL ;
2016-06-23 15:05:37 +00:00
foreach ( $addArrayJ as $scripter )
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
if ( isset ( $view -> { 'add_' . $scripter })
&& $view -> { 'add_' . $scripter } == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $view -> $scripter ))
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
$scripter_target = str_replace (
'javascript_' , '' , $scripter
);
2019-07-28 21:48:42 +00:00
// update GUI mapper field
$guiMapper [ 'field' ] = $scripter ;
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$view -> { $scripter },
$scripter_target ,
2020-11-17 04:06:34 +00:00
$view -> name_single_code ,
2022-08-31 11:49:01 +00:00
null ,
2019-07-28 21:48:42 +00:00
$guiMapper ,
true ,
true ,
true
);
2019-03-05 07:51:52 +00:00
// check if a token must be set
2020-03-28 13:34:14 +00:00
if ( strpos ( $view -> $scripter , " token " ) !== false
|| strpos (
$view -> $scripter , " task=ajax "
) !== false )
2016-02-26 00:20:09 +00:00
{
2022-08-31 11:49:01 +00:00
if ( ! CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ 'token' ][ $view -> name_single_code ])
2016-06-23 15:05:37 +00:00
{
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ 'token' ][ $view -> name_single_code ]
2020-03-28 13:34:14 +00:00
= true ;
2016-06-23 15:05:37 +00:00
}
2016-02-26 00:20:09 +00:00
}
2019-03-05 07:51:52 +00:00
unset ( $view -> { $scripter });
2016-02-26 00:20:09 +00:00
}
}
2019-07-28 21:48:42 +00:00
unset ( $guiMapper [ 'prefix' ]);
2016-06-23 15:05:37 +00:00
// add_css
$addArrayC = array ( 'css_view' , 'css_views' );
foreach ( $addArrayC as $scripter )
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
if ( isset ( $view -> { 'add_' . $scripter })
&& $view -> { 'add_' . $scripter } == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $view -> { $scripter }))
2016-02-26 00:20:09 +00:00
{
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$view -> { $scripter },
$scripter ,
2020-11-17 04:06:34 +00:00
$view -> name_single_code ,
2022-08-31 11:49:01 +00:00
null ,
2019-07-28 21:48:42 +00:00
array ( 'prefix' => PHP_EOL ),
true ,
true ,
true
);
2019-03-05 07:51:52 +00:00
unset ( $view -> { $scripter });
2016-02-26 00:20:09 +00:00
}
}
2019-07-28 21:48:42 +00:00
// update GUI mapper
$guiMapper [ 'type' ] = 'php' ;
2016-06-23 15:05:37 +00:00
// add_php
2020-03-28 13:34:14 +00:00
$addArrayP = array ( 'php_getitem' , 'php_before_save' , 'php_save' ,
2021-12-21 14:44:50 +00:00
'php_getform' , 'php_postsavehook' ,
'php_getitems' , 'php_getitems_after_all' ,
'php_getlistquery' , 'php_allowadd' ,
'php_allowedit' , 'php_before_cancel' ,
'php_after_cancel' , 'php_before_delete' ,
'php_after_delete' , 'php_before_publish' ,
'php_after_publish' , 'php_batchcopy' ,
'php_batchmove' , 'php_document' );
2016-06-23 15:05:37 +00:00
foreach ( $addArrayP as $scripter )
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
if ( isset ( $view -> { 'add_' . $scripter })
&& $view -> { 'add_' . $scripter } == 1 )
2016-02-26 00:20:09 +00:00
{
2019-07-28 21:48:42 +00:00
// update GUI mapper field
$guiMapper [ 'field' ] = $scripter ;
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$view -> { $scripter },
$scripter ,
2020-11-17 04:06:34 +00:00
$view -> name_single_code ,
2022-08-31 11:49:01 +00:00
null ,
2019-07-28 21:48:42 +00:00
$guiMapper
);
2020-06-25 19:22:30 +00:00
// check if we have template or layouts to load
2020-11-29 00:00:20 +00:00
$this -> setTemplateAndLayoutData (
$view -> { $scripter }, $view -> name_single_code
);
2020-06-25 19:22:30 +00:00
2019-07-28 21:48:42 +00:00
unset ( $view -> { $scripter });
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
// add the custom buttons
2020-03-28 13:34:14 +00:00
if ( isset ( $view -> add_custom_button )
&& $view -> add_custom_button == 1 )
2017-12-14 23:10:47 +00:00
{
2019-07-28 21:48:42 +00:00
$button_code_array = array (
'php_model' ,
'php_controller' ,
'php_model_list' ,
'php_controller_list'
);
// set for the code
foreach ( $button_code_array as $button_code_field )
2017-12-14 23:10:47 +00:00
{
2020-03-28 13:34:14 +00:00
if ( isset ( $view -> { $button_code_field })
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$view -> { $button_code_field }
))
2019-07-28 21:48:42 +00:00
{
// set field
$guiMapper [ 'field' ] = $button_code_field ;
2020-03-28 13:34:14 +00:00
$view -> { $button_code_field }
2022-08-30 15:28:41 +00:00
= CFactory :: _ ( 'Customcode.Gui' ) -> set (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $view -> { $button_code_field })
),
2019-07-28 21:48:42 +00:00
$guiMapper
2020-03-28 13:34:14 +00:00
);
2020-06-25 19:22:30 +00:00
// check if we have template or layouts to load
2020-11-29 00:00:20 +00:00
$this -> setTemplateAndLayoutData (
$view -> { $button_code_field }, $view -> name_single_code
);
2019-07-28 21:48:42 +00:00
}
2017-03-02 00:55:04 +00:00
}
2017-12-14 23:10:47 +00:00
// set the button array
2020-03-28 13:34:14 +00:00
$view -> custom_button = ( isset ( $view -> custom_button )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $view -> custom_button ))
2020-03-28 13:34:14 +00:00
? json_decode ( $view -> custom_button , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $view -> custom_button ))
2017-12-14 23:10:47 +00:00
{
$view -> custom_buttons = array_values ( $view -> custom_button );
}
unset ( $view -> custom_button );
}
2016-05-04 04:53:33 +00:00
// set custom import scripts
2020-03-28 13:34:14 +00:00
if ( isset ( $view -> add_custom_import )
&& $view -> add_custom_import == 1 )
2016-05-04 04:53:33 +00:00
{
2020-03-28 13:34:14 +00:00
$addImportArray = array ( 'php_import_ext' , 'php_import_display' ,
2021-12-21 14:44:50 +00:00
'php_import' , 'php_import_setdata' ,
'php_import_save' , 'php_import_headers' ,
'html_import_view' );
2016-05-04 04:53:33 +00:00
foreach ( $addImportArray as $importScripter )
{
2020-03-28 13:34:14 +00:00
if ( isset ( $view -> $importScripter )
&& strlen (
$view -> $importScripter
) > 0 )
2016-05-04 04:53:33 +00:00
{
2019-07-28 21:48:42 +00:00
// update GUI mapper field
$guiMapper [ 'field' ] = $importScripter ;
2020-11-29 00:00:20 +00:00
$guiMapper [ 'type' ] = 'php' ;
2020-10-06 22:54:33 +00:00
// Make sure html gets HTML comment for placeholder
if ( 'html_import_view' === $importScripter )
{
$guiMapper [ 'type' ] = 'html' ;
}
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$view -> $importScripter ,
$importScripter ,
2020-11-17 04:06:34 +00:00
'import_' . $view -> name_list_code ,
2022-08-31 11:49:01 +00:00
null ,
2019-07-28 21:48:42 +00:00
$guiMapper
);
2016-05-04 04:53:33 +00:00
unset ( $view -> $importScripter );
}
2017-03-27 12:38:51 +00:00
else
{
// load the default
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ $importScripter ][ 'import_'
2020-11-17 04:06:34 +00:00
. $view -> name_list_code ]
2020-03-28 13:34:14 +00:00
= ComponentbuilderHelper :: getDynamicScripts (
$importScripter , true
);
2017-03-27 12:38:51 +00:00
}
2016-05-04 04:53:33 +00:00
}
}
2016-02-26 00:20:09 +00:00
// add_Ajax for this view
2016-05-10 05:47:47 +00:00
if ( isset ( $view -> add_php_ajax ) && $view -> add_php_ajax == 1 )
2016-02-26 00:20:09 +00:00
{
2017-02-13 23:24:38 +00:00
// insure the token is added to edit view atleast
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ 'token' ][ $view -> name_single_code ]
2020-11-29 00:00:20 +00:00
= true ;
$addAjaxSite = false ;
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> siteEditView [ $id ]) && $this -> siteEditView [ $id ])
{
2017-02-13 23:24:38 +00:00
// we should add this site ajax to front ajax
2016-02-26 00:20:09 +00:00
$addAjaxSite = true ;
if ( ! isset ( $this -> addSiteAjax ) || ! $this -> addSiteAjax )
{
$this -> addSiteAjax = true ;
}
}
// check if controller input as been set
2020-03-28 13:34:14 +00:00
$view -> ajax_input = ( isset ( $view -> ajax_input )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $view -> ajax_input ))
2020-03-28 13:34:14 +00:00
? json_decode ( $view -> ajax_input , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $view -> ajax_input ))
2017-10-12 00:50:14 +00:00
{
if ( $addAjaxSite )
{
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ 'site' ][ 'ajax_controller' ][ $view -> name_single_code ]
2020-03-28 13:34:14 +00:00
= array_values ( $view -> ajax_input );
2017-10-12 00:50:14 +00:00
}
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ 'admin' ][ 'ajax_controller' ][ $view -> name_single_code ]
2020-03-28 13:34:14 +00:00
= array_values ( $view -> ajax_input );
2016-05-10 05:47:47 +00:00
$this -> addAjax = true ;
unset ( $view -> ajax_input );
}
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $view -> php_ajaxmethod ))
2016-05-10 05:47:47 +00:00
{
2020-10-06 22:54:33 +00:00
// make sure we are still in PHP
$guiMapper [ 'type' ] = 'php' ;
2019-07-28 21:48:42 +00:00
// update GUI mapper field
$guiMapper [ 'field' ] = 'php_ajaxmethod' ;
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$view -> php_ajaxmethod ,
'admin' ,
'ajax_model' ,
2020-11-17 04:06:34 +00:00
$view -> name_single_code ,
2019-07-28 21:48:42 +00:00
$guiMapper
);
2020-06-25 19:22:30 +00:00
2016-02-26 00:20:09 +00:00
if ( $addAjaxSite )
{
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$view -> php_ajaxmethod ,
'site' ,
'ajax_model' ,
2020-11-17 04:06:34 +00:00
$view -> name_single_code ,
2019-07-28 21:48:42 +00:00
$guiMapper ,
false ,
false
);
2016-02-26 00:20:09 +00:00
}
2016-05-10 05:47:47 +00:00
// unset anyway
unset ( $view -> php_ajaxmethod );
2016-02-26 00:20:09 +00:00
$this -> addAjax = true ;
}
}
2018-03-28 09:46:14 +00:00
// activate alias builder
2020-11-17 04:06:34 +00:00
if ( ! isset ( $this -> customAliasBuilder [ $view -> name_single_code ])
2020-03-28 13:34:14 +00:00
&& isset ( $view -> alias_builder_type )
&& 2 == $view -> alias_builder_type
&& isset ( $view -> alias_builder )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $view -> alias_builder ))
2018-03-28 09:46:14 +00:00
{
// get the aliasFields
$alias_fields = ( array ) json_decode ( $view -> alias_builder , true );
// get the active fields
2020-03-28 13:34:14 +00:00
$alias_fields = ( array ) array_filter (
$view -> fields , function ( $field ) use ( $alias_fields ) {
// check if field is in view fields
if ( in_array ( $field [ 'field' ], $alias_fields ))
2018-03-28 09:46:14 +00:00
{
2020-03-28 13:34:14 +00:00
return true ;
}
return false ;
}
);
2018-03-28 09:46:14 +00:00
// check if all is well
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $alias_fields ))
2018-03-28 09:46:14 +00:00
{
// load the field names
2020-11-29 00:00:20 +00:00
$this -> customAliasBuilder [ $view -> name_single_code ]
= ( array ) array_map (
2020-11-17 04:06:34 +00:00
function ( $field ) use ( & $view ) {
2022-09-10 08:16:44 +00:00
return CFactory :: _ ( 'Field.Name' ) -> get (
2020-11-29 00:00:20 +00:00
$field , $view -> name_list_code
);
2018-05-11 04:08:14 +00:00
}, $alias_fields
2018-03-28 09:46:14 +00:00
);
}
}
// unset
unset ( $view -> alias_builder );
2016-02-26 00:20:09 +00:00
// add_sql
if ( $view -> add_sql == 1 )
{
2017-08-22 22:17:19 +00:00
if ( $view -> source == 1 && isset ( $view -> tables ))
2016-02-26 00:20:09 +00:00
{
// build and add the SQL dump
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ 'sql' ][ $view -> name_single_code ]
2020-11-29 00:00:20 +00:00
= $this -> buildSqlDump (
$view -> tables , $view -> name_single_code , $id
);
2016-02-26 00:20:09 +00:00
unset ( $view -> tables );
}
2017-08-22 22:17:19 +00:00
elseif ( $view -> source == 2 && isset ( $view -> sql ))
2016-02-26 00:20:09 +00:00
{
// add the SQL dump string
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$view -> sql ,
'sql' ,
2020-11-17 04:06:34 +00:00
$view -> name_single_code
2019-07-28 21:48:42 +00:00
);
2016-02-26 00:20:09 +00:00
unset ( $view -> sql );
}
}
2018-09-25 20:02:48 +00:00
// load table settings
2020-11-17 04:06:34 +00:00
if ( ! isset ( $this -> mysqlTableSetting [ $view -> name_single_code ]))
2018-09-25 20:02:48 +00:00
{
2020-11-17 04:06:34 +00:00
$this -> mysqlTableSetting [ $view -> name_single_code ] = array ();
2018-09-25 20:02:48 +00:00
}
// set mySql Table Settings
2020-03-28 13:34:14 +00:00
foreach (
$this -> mysqlTableKeys as $_mysqlTableKey => $_mysqlTableVal
)
2018-09-25 20:02:48 +00:00
{
2020-03-28 13:34:14 +00:00
if ( isset ( $view -> { 'mysql_table_' . $_mysqlTableKey })
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$view -> { 'mysql_table_' . $_mysqlTableKey }
)
&& ! is_numeric ( $view -> { 'mysql_table_' . $_mysqlTableKey }))
2018-09-25 20:02:48 +00:00
{
2020-11-17 04:06:34 +00:00
$this -> mysqlTableSetting [ $view -> name_single_code ][ $_mysqlTableKey ]
2020-03-28 13:34:14 +00:00
= $view -> { 'mysql_table_' . $_mysqlTableKey };
2018-09-25 20:02:48 +00:00
}
else
{
2020-11-17 04:06:34 +00:00
$this -> mysqlTableSetting [ $view -> name_single_code ][ $_mysqlTableKey ]
2020-03-28 13:34:14 +00:00
= $_mysqlTableVal [ 'default' ];
2018-09-25 20:02:48 +00:00
}
// remove the table values since we moved to another object
unset ( $view -> { 'mysql_table_' . $_mysqlTableKey });
}
2019-06-22 10:43:26 +00:00
2022-08-30 15:28:41 +00:00
// for plugin event TODO change event api signatures
$this -> placeholders = CFactory :: _ ( 'Placeholder' ) -> active ;
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onAfterModelViewData
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2020-03-28 13:34:14 +00:00
'jcb_ce_onAfterModelViewData' ,
array ( & $this -> componentContext , & $view , & $this -> placeholders )
);
2022-08-30 15:28:41 +00:00
// for plugin event TODO change event api signatures
CFactory :: _ ( 'Placeholder' ) -> active = $this -> placeholders ;
2019-06-22 10:43:26 +00:00
2017-10-06 14:53:22 +00:00
// clear placeholders
2022-08-30 15:28:41 +00:00
unset ( CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'view' )]);
unset ( CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'views' )]);
unset ( CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'View' )]);
unset ( CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'Views' )]);
unset ( CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'VIEW' )]);
unset ( CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'VIEWS' )]);
unset ( CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'view' )]);
unset ( CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'views' )]);
unset ( CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'View' )]);
unset ( CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'Views' )]);
unset ( CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'VIEW' )]);
unset ( CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'VIEWS' )]);
2018-01-15 15:54:05 +00:00
2017-06-16 12:38:06 +00:00
// store this view to class object
2016-02-26 00:20:09 +00:00
$this -> _adminViewData [ $id ] = $view ;
}
2020-03-28 13:34:14 +00:00
2016-02-26 00:20:09 +00:00
// return the found view data
return $this -> _adminViewData [ $id ];
}
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* Get all Custom View Data
2020-03-28 13:34:14 +00:00
*
* @ param int $id The view ID
* @ param string $table The view table
*
2016-02-26 00:20:09 +00:00
* @ return oject The view data
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
*/
public function getCustomViewData ( $id , $table = 'site_view' )
{
// Create a new query object.
2017-02-13 23:24:38 +00:00
$query = $this -> db -> getQuery ( true );
2016-02-26 00:20:09 +00:00
$query -> select ( 'a.*' );
2017-12-14 23:10:47 +00:00
$query -> from ( '#__componentbuilder_' . $table . ' AS a' );
$query -> where ( $this -> db -> quoteName ( 'a.id' ) . ' = ' . ( int ) $id );
2016-02-26 00:20:09 +00:00
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onBeforeQueryCustomViewData
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2020-03-28 13:34:14 +00:00
'jcb_ce_onBeforeQueryCustomViewData' ,
array ( & $this -> componentContext , & $id , & $table , & $query , & $this -> db )
);
2019-06-22 10:43:26 +00:00
2016-02-26 00:20:09 +00:00
// Reset the query using our newly populated query object.
2017-02-13 23:24:38 +00:00
$this -> db -> setQuery ( $query );
2016-02-26 00:20:09 +00:00
// Load the results as a list of stdClass objects (see later for more options on retrieving data).
2017-02-13 23:24:38 +00:00
$view = $this -> db -> loadObject ();
2020-12-08 04:32:39 +00:00
// fix alias to use in code
$view -> code = $this -> uniqueCode (
2022-03-09 23:46:45 +00:00
StringHelper :: safe ( $view -> codename )
2020-12-08 04:32:39 +00:00
);
2022-03-09 23:46:45 +00:00
$view -> Code = StringHelper :: safe ( $view -> code , 'F' );
$view -> CODE = StringHelper :: safe ( $view -> code , 'U' );
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onBeforeModelCustomViewData
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2020-03-28 13:34:14 +00:00
'jcb_ce_onBeforeModelCustomViewData' ,
array ( & $this -> componentContext , & $view , & $id , & $table )
);
2019-06-22 10:43:26 +00:00
2017-02-01 13:17:04 +00:00
if ( $table === 'site_view' )
2016-02-26 00:20:09 +00:00
{
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> lang_target = 'site' ;
2017-10-29 11:03:06 +00:00
// repeatable fields to update
$searchRepeatables = array (
// repeatablefield => checker
2020-03-28 13:34:14 +00:00
'ajax_input' => 'value_name' ,
2017-10-29 11:03:06 +00:00
'custom_button' => 'name'
);
2016-02-26 00:20:09 +00:00
}
else
{
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> lang_target = 'admin' ;
2017-10-29 11:03:06 +00:00
// repeatable fields to update
$searchRepeatables = array (
// repeatablefield => checker
'custom_button' => 'name'
);
2016-02-26 00:20:09 +00:00
}
2017-10-29 11:03:06 +00:00
// set upater
$updater = array (
'table' => $table ,
2020-03-28 13:34:14 +00:00
'key' => 'id' ,
'val' => ( int ) $id
2017-12-14 23:10:47 +00:00
);
2017-10-29 11:03:06 +00:00
// update the repeatable fields
2020-03-28 13:34:14 +00:00
$view = ComponentbuilderHelper :: convertRepeatableFields (
$view , $searchRepeatables , $updater
);
2017-12-14 23:10:47 +00:00
2019-07-28 21:48:42 +00:00
// set GUI mapper
2020-03-28 13:34:14 +00:00
$guiMapper = array ( 'table' => $table , 'id' => ( int ) $id ,
'field' => 'default' , 'type' => 'html' );
2019-07-28 21:48:42 +00:00
2016-02-26 00:20:09 +00:00
// set the default data
2022-08-30 15:28:41 +00:00
$view -> default = CFactory :: _ ( 'Customcode.Gui' ) -> set (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update ( base64_decode ( $view -> default )),
2020-03-28 13:34:14 +00:00
$guiMapper
);
2018-08-23 21:51:09 +00:00
// load context if not set
2020-03-28 13:34:14 +00:00
if ( ! isset ( $view -> context )
2022-03-09 23:46:45 +00:00
|| ! StringHelper :: check (
2020-03-28 13:34:14 +00:00
$view -> context
))
2018-08-23 21:51:09 +00:00
{
$view -> context = $view -> code ;
}
else
{
// always make sure context is a safe string
2022-03-09 23:46:45 +00:00
$view -> context = StringHelper :: safe ( $view -> context );
2018-08-23 21:51:09 +00:00
}
2017-12-10 19:17:26 +00:00
// load the library
2022-08-30 15:28:41 +00:00
if ( ! isset ( $this -> libManager [ CFactory :: _ ( 'Config' ) -> build_target ]))
2017-12-10 19:17:26 +00:00
{
2022-08-30 15:28:41 +00:00
$this -> libManager [ CFactory :: _ ( 'Config' ) -> build_target ] = array ();
2017-12-10 19:17:26 +00:00
}
2022-08-30 15:28:41 +00:00
if ( ! isset ( $this -> libManager [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ]))
2017-12-10 19:17:26 +00:00
{
2022-08-30 15:28:41 +00:00
$this -> libManager [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ] = array ();
2017-12-10 19:17:26 +00:00
}
// make sure json become array
2022-03-09 23:46:45 +00:00
if ( JsonHelper :: check ( $view -> libraries ))
2017-12-10 19:17:26 +00:00
{
$view -> libraries = json_decode ( $view -> libraries , true );
}
// if we have an array add it
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $view -> libraries ))
2017-12-10 19:17:26 +00:00
{
foreach ( $view -> libraries as $library )
{
2022-08-30 15:28:41 +00:00
if ( ! isset ( $this -> libManager [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ][ $library ]))
2017-12-10 19:17:26 +00:00
{
2019-10-16 20:34:36 +00:00
if ( $this -> getMediaLibrary (( int ) $library ))
2017-12-10 19:17:26 +00:00
{
2022-08-30 15:28:41 +00:00
$this -> libManager [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ][( int ) $library ]
2020-03-28 13:34:14 +00:00
= true ;
2017-12-10 19:17:26 +00:00
}
}
}
}
2020-03-28 13:34:14 +00:00
elseif ( is_numeric ( $view -> libraries )
2022-08-30 15:28:41 +00:00
&& ! isset ( $this -> libManager [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ][( int ) $view -> libraries ]))
2017-12-10 19:17:26 +00:00
{
2019-10-16 20:34:36 +00:00
if ( $this -> getMediaLibrary (( int ) $view -> libraries ))
2017-12-10 19:17:26 +00:00
{
2022-08-30 15:28:41 +00:00
$this -> libManager [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ][( int ) $view -> libraries ]
2020-03-28 13:34:14 +00:00
= true ;
2017-12-10 19:17:26 +00:00
}
}
// setup template array
2022-08-30 15:28:41 +00:00
$this -> templateData [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ] = array ();
2017-12-10 19:17:26 +00:00
// setup template and layout data
2017-12-14 23:10:47 +00:00
$this -> setTemplateAndLayoutData ( $view -> default , $view -> code );
2016-02-26 00:20:09 +00:00
// insure the uikit components are loaded
2017-11-11 04:33:51 +00:00
if ( 2 == $this -> uikit || 1 == $this -> uikit )
2016-02-26 00:20:09 +00:00
{
2017-11-11 04:33:51 +00:00
if ( ! isset ( $this -> uikitComp [ $view -> code ]))
{
$this -> uikitComp [ $view -> code ] = array ();
}
2020-03-28 13:34:14 +00:00
$this -> uikitComp [ $view -> code ]
= ComponentbuilderHelper :: getUikitComp (
$view -> default , $this -> uikitComp [ $view -> code ]
);
2016-02-26 00:20:09 +00:00
}
// check for footable
2022-08-30 15:28:41 +00:00
if ( ! isset ( $this -> footableScripts [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ])
|| ! $this -> footableScripts [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ])
2016-02-26 00:20:09 +00:00
{
$foundFoo = $this -> getFootableScripts ( $view -> default );
if ( $foundFoo )
{
2022-08-30 15:28:41 +00:00
$this -> footableScripts [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ] = true ;
2016-02-26 00:20:09 +00:00
}
if ( $foundFoo && ! $this -> footableScripts )
{
$this -> footable = true ;
}
}
// check for get module
2022-08-30 15:28:41 +00:00
if ( ! isset ( $this -> getModule [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ])
|| ! $this -> getModule [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ])
2016-02-26 00:20:09 +00:00
{
$found = $this -> getGetModule ( $view -> default );
if ( $found )
{
2022-08-30 15:28:41 +00:00
$this -> getModule [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ] = true ;
2016-02-26 00:20:09 +00:00
}
}
// set the main get data
2020-03-28 13:34:14 +00:00
$main_get = $this -> setGetData (
array ( $view -> main_get ), $view -> code , $view -> context
);
2016-02-26 00:20:09 +00:00
$view -> main_get = $main_get [ 0 ];
// set the custom_get data
2020-03-28 13:34:14 +00:00
$view -> custom_get = $this -> setGetData (
json_decode ( $view -> custom_get , true ), $view -> code , $view -> context
);
2016-02-26 00:20:09 +00:00
// set array adding array of scripts
2020-03-28 13:34:14 +00:00
$addArray = array ( 'php_view' , 'php_jview' , 'php_jview_display' ,
2021-12-21 14:44:50 +00:00
'php_document' , 'javascript_file' , 'js_document' ,
'css_document' , 'css' );
2019-07-28 21:48:42 +00:00
// set GUI mapper
$guiMapper [ 'type' ] = 'php' ;
2016-02-26 00:20:09 +00:00
foreach ( $addArray as $scripter )
{
2020-03-28 13:34:14 +00:00
if ( isset ( $view -> { 'add_' . $scripter })
&& $view -> { 'add_' . $scripter } == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $view -> $scripter ))
2016-02-26 00:20:09 +00:00
{
2019-07-28 21:48:42 +00:00
// css does not get placholders yet
if ( strpos ( $scripter , 'css' ) === false )
{
// set field
$guiMapper [ 'field' ] = $scripter ;
2022-08-30 15:28:41 +00:00
$view -> $scripter = CFactory :: _ ( 'Customcode.Gui' ) -> set (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $view -> $scripter )
),
$guiMapper
);
2019-07-28 21:48:42 +00:00
}
else
{
2022-09-03 10:48:53 +00:00
$view -> $scripter = CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $view -> $scripter )
);
2019-07-28 21:48:42 +00:00
}
2017-11-11 04:33:51 +00:00
if ( 2 == $this -> uikit || 1 == $this -> uikit )
{
2017-12-12 22:17:02 +00:00
if ( ! isset ( $this -> uikitComp [ $view -> code ]))
{
$this -> uikitComp [ $view -> code ] = array ();
}
2017-11-11 04:33:51 +00:00
// set uikit to views
2020-03-28 13:34:14 +00:00
$this -> uikitComp [ $view -> code ]
= ComponentbuilderHelper :: getUikitComp (
$view -> $scripter , $this -> uikitComp [ $view -> code ]
);
2017-11-11 04:33:51 +00:00
}
2017-12-14 23:10:47 +00:00
$this -> setTemplateAndLayoutData ( $view -> $scripter , $view -> code );
2016-02-26 00:20:09 +00:00
// check for footable
2022-08-30 15:28:41 +00:00
if ( ! isset ( $this -> footableScripts [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ])
|| ! $this -> footableScripts [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ])
2016-02-26 00:20:09 +00:00
{
$foundFoo = $this -> getFootableScripts ( $view -> $scripter );
if ( $foundFoo )
{
2022-08-30 15:28:41 +00:00
$this -> footableScripts [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ]
2020-03-28 13:34:14 +00:00
= true ;
2016-02-26 00:20:09 +00:00
}
if ( $foundFoo && ! $this -> footable )
{
$this -> footable = true ;
}
}
// check for google chart
2022-08-30 15:28:41 +00:00
if ( ! isset ( $this -> googleChart [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ])
|| ! $this -> googleChart [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ])
2016-02-26 00:20:09 +00:00
{
$found = $this -> getGoogleChart ( $view -> $scripter );
if ( $found )
{
2022-08-30 15:28:41 +00:00
$this -> googleChart [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ] = true ;
2016-02-26 00:20:09 +00:00
}
if ( $found && ! $this -> googlechart )
{
$this -> googlechart = true ;
}
}
// check for get module
2022-08-30 15:28:41 +00:00
if ( ! isset ( $this -> getModule [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ])
|| ! $this -> getModule [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ])
2016-02-26 00:20:09 +00:00
{
$found = $this -> getGetModule ( $view -> $scripter );
if ( $found )
{
2022-08-30 15:28:41 +00:00
$this -> getModule [ CFactory :: _ ( 'Config' ) -> build_target ][ $view -> code ] = true ;
2016-02-26 00:20:09 +00:00
}
}
}
}
// add_Ajax for this view
if ( isset ( $view -> add_php_ajax ) && $view -> add_php_ajax == 1 )
{
2018-01-15 15:54:05 +00:00
// ajax target (since we only have two options really)
2022-08-30 15:28:41 +00:00
if ( 'site' === CFactory :: _ ( 'Config' ) -> build_target )
2018-01-15 15:54:05 +00:00
{
$target = 'site' ;
}
else
{
$target = 'admin' ;
}
$setAjax = false ;
2016-02-26 00:20:09 +00:00
// check if controller input as been set
2020-03-28 13:34:14 +00:00
$view -> ajax_input = ( isset ( $view -> ajax_input )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $view -> ajax_input ))
2020-03-28 13:34:14 +00:00
? json_decode ( $view -> ajax_input , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $view -> ajax_input ))
2017-10-12 00:50:14 +00:00
{
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> hub [ $target ][ 'ajax_controller' ][ $view -> code ]
2020-03-28 13:34:14 +00:00
= array_values ( $view -> ajax_input );
2018-01-15 15:54:05 +00:00
$setAjax = true ;
2016-02-26 00:20:09 +00:00
}
2017-10-29 11:03:06 +00:00
unset ( $view -> ajax_input );
// load the ajax class mathods (if set)
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $view -> php_ajaxmethod ))
2016-05-10 05:47:47 +00:00
{
2019-07-28 21:48:42 +00:00
// set field
$guiMapper [ 'field' ] = 'php_ajaxmethod' ;
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$view -> php_ajaxmethod ,
$target ,
'ajax_model' ,
$view -> code ,
$guiMapper
);
2018-01-15 15:54:05 +00:00
$setAjax = true ;
2016-05-10 05:47:47 +00:00
}
2016-02-26 00:20:09 +00:00
// unset anyway
unset ( $view -> php_ajaxmethod );
2018-01-15 15:54:05 +00:00
// should ajax be set
if ( $setAjax )
{
// turn on ajax area
2022-08-30 15:28:41 +00:00
if ( 'site' === CFactory :: _ ( 'Config' ) -> build_target )
2018-01-15 15:54:05 +00:00
{
$this -> addSiteAjax = true ;
}
else
{
$this -> addAjax = true ;
}
}
2016-02-26 00:20:09 +00:00
}
// add the custom buttons
if ( isset ( $view -> add_custom_button ) && $view -> add_custom_button == 1 )
{
2019-07-28 21:48:42 +00:00
$button_code_array = array (
'php_model' ,
'php_controller'
);
// set for the code
foreach ( $button_code_array as $button_code_field )
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
if ( isset ( $view -> { $button_code_field })
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$view -> { $button_code_field }
))
2019-07-28 21:48:42 +00:00
{
// set field
2020-03-28 13:34:14 +00:00
$guiMapper [ 'field' ] = $button_code_field ;
2022-08-30 15:28:41 +00:00
$view -> { $button_code_field } = CFactory :: _ ( 'Customcode.Gui' ) -> set (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $view -> { $button_code_field })
),
2019-07-28 21:48:42 +00:00
$guiMapper
2020-03-28 13:34:14 +00:00
);
2019-07-28 21:48:42 +00:00
}
2016-02-26 00:20:09 +00:00
}
// set the button array
2020-03-28 13:34:14 +00:00
$view -> custom_button = ( isset ( $view -> custom_button )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $view -> custom_button ))
2020-03-28 13:34:14 +00:00
? json_decode ( $view -> custom_button , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $view -> custom_button ))
2017-10-12 00:50:14 +00:00
{
$view -> custom_buttons = array_values ( $view -> custom_button );
2016-02-26 00:20:09 +00:00
}
2017-10-12 00:50:14 +00:00
unset ( $view -> custom_button );
}
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onAfterModelCustomViewData
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2020-03-28 13:34:14 +00:00
'jcb_ce_onAfterModelCustomViewData' ,
array ( & $this -> componentContext , & $view )
);
2019-06-22 10:43:26 +00:00
2016-02-26 00:20:09 +00:00
// return the found view data
return $view ;
}
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* Get all Field Data
2020-03-28 13:34:14 +00:00
*
* @ param int $id The field ID
* @ param string $name_single The view edit or single name
* @ param string $name_list The view list name
2016-02-26 00:20:09 +00:00
*
* @ return oject The field data
2022-09-10 08:16:44 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Field.Data' ) -> get ( $id , $name_single , $name_list );
2016-02-26 00:20:09 +00:00
*/
2017-10-12 00:50:14 +00:00
public function getFieldData ( $id , $name_single = null , $name_list = null )
2016-02-26 00:20:09 +00:00
{
2022-09-10 08:16:44 +00:00
return CFactory :: _ ( 'Field.Data' ) -> get ( $id , $name_single , $name_list );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
2018-10-01 02:16:24 +00:00
/**
* set Field details
2020-03-28 13:34:14 +00:00
*
* @ param object $field The field object
* @ param string $singleViewName The single view name
* @ param string $listViewName The list view name
* @ param string $amicably The peaceful resolve
*
2018-10-01 02:16:24 +00:00
* @ return void
2022-09-10 08:16:44 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Field' ) -> set ( $field , $singleViewName , $listViewName , $amicably );
2018-10-01 02:16:24 +00:00
*/
2022-09-10 08:16:44 +00:00
public function setFieldDetails ( & $field , $singleViewName = null , $listViewName = null , $amicably = '' )
2021-12-21 14:44:50 +00:00
{
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Field' ) -> set ( $field , $singleViewName , $listViewName , $amicably );
2018-10-01 02:16:24 +00:00
}
2020-11-30 03:59:45 +00:00
/**
* get the list default ordering values
*
* @ param string $nameListCode The list view name
*
* @ return array
*
*/
public function getListViewDefaultOrdering ( & $nameListCode )
{
if ( isset ( $this -> viewsDefaultOrdering [ $nameListCode ])
2020-12-10 01:24:29 +00:00
&& $this -> viewsDefaultOrdering [ $nameListCode ][ 'add_admin_ordering' ]
== 1 )
2020-11-30 03:59:45 +00:00
{
foreach (
$this -> viewsDefaultOrdering [ $nameListCode ][ 'admin_ordering_fields' ]
as $order_field
)
{
2022-09-10 08:16:44 +00:00
if (( $order_field_name = CFactory :: _ ( 'Field.Database.Name' ) -> get (
2020-11-30 03:59:45 +00:00
$nameListCode , $order_field [ 'field' ]
)) !== false )
{
// just the first field is the based ordering state
return array (
2020-12-10 01:24:29 +00:00
'name' => $order_field_name ,
2020-11-30 03:59:45 +00:00
'direction' => $order_field [ 'direction' ]
);
}
}
}
2020-12-10 01:24:29 +00:00
2020-11-30 03:59:45 +00:00
// the default
return array (
2020-12-10 01:24:29 +00:00
'name' => 'a.id' ,
2020-11-30 03:59:45 +00:00
'direction' => 'DESC'
);
}
/**
* get the field database name and AS prefix
*
* @ param string $nameListCode The list view name
* @ param int $fieldId The field ID
* @ param string $targetArea The area being targeted
*
* @ return string
2022-09-10 08:16:44 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Field.Database.Name' ) -> get ( $nameListCode , $fieldId , $targetArea );
2020-11-30 03:59:45 +00:00
*/
2022-09-10 08:16:44 +00:00
public function getFieldDatabaseName ( $nameListCode , int $fieldId , $targetArea = 'builder.list' )
2021-12-21 14:44:50 +00:00
{
2022-09-10 08:16:44 +00:00
return CFactory :: _ ( 'Field.Database.Name' ) -> get ( $nameListCode , $fieldId , $targetArea );
2020-11-30 03:59:45 +00:00
}
2018-03-11 02:44:43 +00:00
/**
* Get the field ' s actual type
2020-03-28 13:34:14 +00:00
*
* @ param object $field The field object
*
2018-03-11 02:44:43 +00:00
* @ return string Success returns field type
2022-09-10 08:16:44 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Field.Type.Name' ) -> get ( $field );
2018-03-11 02:44:43 +00:00
*/
public function getFieldType ( & $field )
{
2022-09-10 08:16:44 +00:00
return CFactory :: _ ( 'Field.Type.Name' ) -> get ( $field );
2018-03-11 02:44:43 +00:00
}
/**
* Get the field ' s actual name
2020-03-28 13:34:14 +00:00
*
* @ param object $field The field object
* @ param string $listViewName The list view name
* @ param string $amicably The peaceful resolve ( for fields in subforms in same view : )
*
2018-03-11 02:44:43 +00:00
* @ return string Success returns field name
2022-09-10 08:16:44 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Field.Name' ) -> get ( $field , $listViewName , $amicably );
2018-03-11 02:44:43 +00:00
*/
2018-10-01 02:16:24 +00:00
public function getFieldName ( & $field , $listViewName = null , $amicably = '' )
2018-03-11 02:44:43 +00:00
{
2022-09-10 08:16:44 +00:00
return CFactory :: _ ( 'Field.Name' ) -> get ( $field , $listViewName , $amicably );
2018-03-11 02:44:43 +00:00
}
/**
* Count how many times the same field is used per view
*
2020-03-28 13:34:14 +00:00
* @ param string $name The name of the field
* @ param string $view The name of the view
2018-03-11 02:44:43 +00:00
*
* @ return void
2022-09-10 08:16:44 +00:00
* @ deprecated Use CFactory :: _ ( 'Field.Unique.Name' ) -> set ( $name , $view );
2018-03-11 02:44:43 +00:00
*/
protected function setUniqueNameCounter ( $name , $view )
{
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Field.Unique.Name' ) -> set ( $name , $view );
2018-03-11 02:44:43 +00:00
}
/**
* Naming each field with an unique name
*
2020-03-28 13:34:14 +00:00
* @ param string $name The name of the field
* @ param string $view The name of the view
2018-03-11 02:44:43 +00:00
*
* @ return string the name
2022-09-10 08:16:44 +00:00
* @ deprecated
2018-03-11 02:44:43 +00:00
*/
protected function uniqueName ( $name , $view )
{
2022-09-10 08:16:44 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
), 'Error'
);
2018-03-11 02:44:43 +00:00
}
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* Set get Data
2020-03-28 13:34:14 +00:00
*
* @ param array $ids The ids of the dynamic get
* @ param string $view_code The view code name
* @ param string $context The context for events
2016-02-26 00:20:09 +00:00
*
* @ return oject the get dynamicGet data
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
*/
2018-08-23 21:51:09 +00:00
public function setGetData ( $ids , $view_code , $context )
2016-02-26 00:20:09 +00:00
{
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $ids ))
2016-02-26 00:20:09 +00:00
{
$ids = implode ( ',' , $ids );
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $ids ))
2016-02-26 00:20:09 +00:00
{
// Create a new query object.
2017-02-13 23:24:38 +00:00
$query = $this -> db -> getQuery ( true );
2016-02-26 00:20:09 +00:00
$query -> select ( 'a.*' );
$query -> from ( '#__componentbuilder_dynamic_get AS a' );
$query -> where ( 'a.id IN (' . $ids . ')' );
2017-02-13 23:24:38 +00:00
$this -> db -> setQuery ( $query );
$this -> db -> execute ();
if ( $this -> db -> getNumRows ())
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
$results = $this -> db -> loadObjectList ();
$typeArray = array ( 1 => 'LEFT' , 2 => 'LEFT OUTER' ,
3 => 'INNER' , 4 => 'RIGHT' ,
5 => 'RIGHT OUTER' );
$operatorArray = array ( 1 => '=' , 2 => '!=' , 3 => '<>' ,
4 => '>' , 5 => '<' , 6 => '>=' ,
7 => '<=' , 8 => '!<' , 9 => '!>' ,
10 => 'IN' , 11 => 'NOT IN' );
$guiMapper = array ( 'table' => 'dynamic_get' ,
'type' => 'php' );
2017-10-26 16:43:51 +00:00
foreach ( $results as $_nr => & $result )
2016-02-26 00:20:09 +00:00
{
2022-01-15 17:52:09 +00:00
// Trigger Event: jcb_ce_onBeforeModelDynamicGetData
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2022-01-15 17:52:09 +00:00
'jcb_ce_onBeforeModelDynamicGetData' ,
array ( & $this -> componentContext , & $result , & $result -> id , & $view_code , & $context )
);
2019-08-04 22:38:53 +00:00
// set GUI mapper id
$guiMapper [ 'id' ] = ( int ) $result -> id ;
2016-02-26 00:20:09 +00:00
// add calculations if set
2020-03-28 13:34:14 +00:00
if ( $result -> addcalculation == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$result -> php_calculation
))
2019-08-04 22:38:53 +00:00
{
2019-07-28 21:48:42 +00:00
// set GUI mapper field
$guiMapper [ 'field' ] = 'php_calculation' ;
2020-03-28 13:34:14 +00:00
$result -> php_calculation
2022-08-30 15:28:41 +00:00
= CFactory :: _ ( 'Customcode.Gui' ) -> set (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $result -> php_calculation )
),
2019-07-28 21:48:42 +00:00
$guiMapper
2020-03-28 13:34:14 +00:00
);
2019-07-28 21:48:42 +00:00
}
// setup the router parse
if ( isset ( $result -> add_php_router_parse )
&& $result -> add_php_router_parse == 1
&& isset ( $result -> php_router_parse )
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$result -> php_router_parse
))
2016-02-26 00:20:09 +00:00
{
2019-07-28 21:48:42 +00:00
// set GUI mapper field
$guiMapper [ 'field' ] = 'php_router_parse' ;
2020-03-28 13:34:14 +00:00
$result -> php_router_parse
2022-08-30 15:28:41 +00:00
= CFactory :: _ ( 'Customcode.Gui' ) -> set (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $result -> php_router_parse )
),
2019-07-28 21:48:42 +00:00
$guiMapper
2020-03-28 13:34:14 +00:00
);
2019-07-28 21:48:42 +00:00
}
else
{
$result -> add_php_router_parse = 0 ;
2016-02-26 00:20:09 +00:00
}
2018-03-11 17:03:31 +00:00
// The array of the php scripts that should be added to the script builder
2020-03-28 13:34:14 +00:00
$phpSripts = array ( 'php_before_getitem' ,
2021-12-21 14:44:50 +00:00
'php_after_getitem' ,
'php_before_getitems' ,
'php_after_getitems' ,
'php_getlistquery' );
2018-03-11 17:03:31 +00:00
// load the php scripts
foreach ( $phpSripts as $script )
2016-02-26 00:20:09 +00:00
{
2018-03-11 17:03:31 +00:00
// add php script to the script builder
2020-03-28 13:34:14 +00:00
if ( isset ( $result -> { 'add_' . $script })
&& $result -> { 'add_' . $script } == 1
&& isset ( $result -> { $script })
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$result -> { $script }
))
2016-02-26 00:20:09 +00:00
{
2018-03-11 17:03:31 +00:00
// move all main gets out to the customscript builder
if ( $result -> gettype <= 2 )
{
2019-07-28 21:48:42 +00:00
// set GUI mapper field
2020-03-28 13:34:14 +00:00
$guiMapper [ 'field' ] = $script ;
2019-07-28 21:48:42 +00:00
$guiMapper [ 'prefix' ] = PHP_EOL . PHP_EOL ;
2022-08-31 11:49:01 +00:00
CFactory :: _ ( 'Customcode.Dispenser' ) -> set (
2019-07-28 21:48:42 +00:00
$result -> { $script },
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> build_target . '_' . $script ,
2019-07-28 21:48:42 +00:00
$view_code ,
2022-08-31 11:49:01 +00:00
null ,
2019-07-28 21:48:42 +00:00
$guiMapper ,
true ,
true ,
true
);
unset ( $guiMapper [ 'prefix' ]);
2018-03-11 17:03:31 +00:00
// remove from local item
unset ( $result -> { $script });
2018-03-18 04:52:07 +00:00
unset ( $result -> { 'add_' . $script });
2018-03-11 17:03:31 +00:00
}
else
{
2019-07-28 21:48:42 +00:00
// set GUI mapper field
2020-03-28 13:34:14 +00:00
$guiMapper [ 'field' ] = $script ;
2019-07-28 21:48:42 +00:00
$guiMapper [ 'prefix' ] = PHP_EOL ;
2018-03-11 17:03:31 +00:00
// only for custom gets
2020-03-28 13:34:14 +00:00
$result -> { $script }
2022-08-30 15:28:41 +00:00
= CFactory :: _ ( 'Customcode.Gui' ) -> set (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $result -> { $script })
),
2019-07-28 21:48:42 +00:00
$guiMapper
);
unset ( $guiMapper [ 'prefix' ]);
2018-03-11 17:03:31 +00:00
}
2016-02-26 00:20:09 +00:00
}
2018-03-11 17:03:31 +00:00
else
2016-02-26 00:20:09 +00:00
{
2018-03-11 17:03:31 +00:00
// remove from local item
unset ( $result -> { $script });
2018-03-18 04:52:07 +00:00
unset ( $result -> { 'add_' . $script });
2016-02-26 00:20:09 +00:00
}
}
// set the getmethod code name
2022-03-09 23:46:45 +00:00
$result -> key = StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$view_code . ' ' . $result -> name . ' ' . $result -> id
);
2016-02-26 00:20:09 +00:00
// reset buckets
2020-03-28 13:34:14 +00:00
$result -> main_get = array ();
2016-02-26 00:20:09 +00:00
$result -> custom_get = array ();
2018-10-04 10:07:37 +00:00
// should joineds and other weaks be added
$addDynamicTweaksJoints = true ;
2016-02-26 00:20:09 +00:00
// set source data
switch ( $result -> main_source )
{
case 1 :
2019-01-29 14:43:27 +00:00
// check if auto sync is set
if ( $result -> select_all == 1 )
{
$result -> view_selection = '*' ;
}
2017-12-14 23:10:47 +00:00
// set the view data
2020-03-28 13:34:14 +00:00
$result -> main_get [ 0 ][ 'selection' ]
= $this -> setDataSelection (
$result -> key , $view_code ,
$result -> view_selection ,
$result -> view_table_main , 'a' , null , 'view'
);
$result -> main_get [ 0 ][ 'as' ] = 'a' ;
$result -> main_get [ 0 ][ 'key' ] = $result -> key ;
2018-08-23 21:51:09 +00:00
$result -> main_get [ 0 ][ 'context' ] = $context ;
2017-12-14 23:10:47 +00:00
unset ( $result -> view_selection );
break ;
2016-02-26 00:20:09 +00:00
case 2 :
2019-01-29 14:43:27 +00:00
// check if auto sync is set
if ( $result -> select_all == 1 )
{
$result -> db_selection = '*' ;
}
2017-12-14 23:10:47 +00:00
// set the database data
2020-03-28 13:34:14 +00:00
$result -> main_get [ 0 ][ 'selection' ]
= $this -> setDataSelection (
$result -> key , $view_code ,
$result -> db_selection ,
$result -> db_table_main , 'a' , null , 'db'
);
$result -> main_get [ 0 ][ 'as' ] = 'a' ;
$result -> main_get [ 0 ][ 'key' ] = $result -> key ;
2018-08-23 21:51:09 +00:00
$result -> main_get [ 0 ][ 'context' ] = $context ;
2017-12-14 23:10:47 +00:00
unset ( $result -> db_selection );
break ;
2016-02-26 00:20:09 +00:00
case 3 :
2019-07-28 21:48:42 +00:00
// set GUI mapper field
$guiMapper [ 'field' ] = 'php_custom_get' ;
2018-08-30 16:33:30 +00:00
// get the custom query
2020-03-28 13:34:14 +00:00
$customQueryString
2022-08-30 15:28:41 +00:00
= CFactory :: _ ( 'Customcode.Gui' ) -> set (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $result -> php_custom_get )
),
2019-07-28 21:48:42 +00:00
$guiMapper
2020-03-28 13:34:14 +00:00
);
2018-08-30 16:33:30 +00:00
// get the table name
2020-03-28 13:34:14 +00:00
$_searchQuery
2022-04-04 15:35:08 +00:00
= GetHelper :: between (
2020-03-28 13:34:14 +00:00
$customQueryString , '$query->from(' , ')'
);
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check (
2020-03-28 13:34:14 +00:00
$_searchQuery
)
&& strpos ( $_searchQuery , '#__' ) !== false )
2018-08-30 16:33:30 +00:00
{
2020-03-28 13:34:14 +00:00
$_queryName
2022-04-04 15:35:08 +00:00
= GetHelper :: between (
2020-03-28 13:34:14 +00:00
$_searchQuery , '#__' , " ' "
);
2022-03-09 23:46:45 +00:00
if ( ! StringHelper :: check (
2020-03-28 13:34:14 +00:00
$_queryName
))
2018-08-30 16:33:30 +00:00
{
2020-03-28 13:34:14 +00:00
$_queryName
2022-04-04 15:35:08 +00:00
= GetHelper :: between (
2020-03-28 13:34:14 +00:00
$_searchQuery , '#__' , '"'
);
2018-08-30 16:33:30 +00:00
}
}
// set to blank if not found
2020-03-28 13:34:14 +00:00
if ( ! isset ( $_queryName )
2022-03-09 23:46:45 +00:00
|| ! StringHelper :: check (
2020-03-28 13:34:14 +00:00
$_queryName
))
2018-08-30 16:33:30 +00:00
{
$_queryName = '' ;
}
2017-12-14 23:10:47 +00:00
// set custom script
$result -> main_get [ 0 ][ 'selection' ] = array (
2018-08-30 16:33:30 +00:00
'select' => $customQueryString ,
2020-03-28 13:34:14 +00:00
'from' => '' , 'table' => '' , 'type' => '' ,
'name' => $_queryName );
$result -> main_get [ 0 ][ 'as' ] = 'a' ;
$result -> main_get [ 0 ][ 'key' ]
= $result -> key ;
$result -> main_get [ 0 ][ 'context' ] = $context ;
2018-10-04 10:07:37 +00:00
// do not add
$addDynamicTweaksJoints = false ;
2017-12-14 23:10:47 +00:00
break ;
2016-02-26 00:20:09 +00:00
}
2018-10-04 10:07:37 +00:00
// only add if main source is not custom
if ( $addDynamicTweaksJoints )
2016-02-26 00:20:09 +00:00
{
2018-10-04 10:07:37 +00:00
// set join_view_table details
2020-03-28 13:34:14 +00:00
$result -> join_view_table = json_decode (
$result -> join_view_table , true
);
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$result -> join_view_table
))
2016-02-26 00:20:09 +00:00
{
2019-12-16 03:02:16 +00:00
// start the part of a table bucket
$_part_of_a = array ();
// build relationship
2020-03-28 13:34:14 +00:00
$_relationship = array_map (
function ( $op ) use ( & $_part_of_a ) {
$bucket = array ();
// array(on_field_as, on_field)
$bucket [ 'on_field' ] = array_map (
'trim' ,
explode ( '.' , $op [ 'on_field' ])
);
// array(join_field_as, join_field)
$bucket [ 'join_field' ] = array_map (
'trim' ,
explode ( '.' , $op [ 'join_field' ])
);
// triget filed that has table a relationship
if ( $op [ 'row_type' ] == 1
&& ( $bucket [ 'on_field' ][ 0 ] === 'a'
|| isset ( $_part_of_a [ $bucket [ 'on_field' ][ 0 ]])
|| isset ( $_part_of_a [ $bucket [ 'join_field' ][ 0 ]])))
{
$_part_of_a [ $op [ 'as' ]] = $op [ 'as' ];
}
return $bucket ;
}, $result -> join_view_table
);
2019-12-16 03:02:16 +00:00
// loop joints
2020-03-28 13:34:14 +00:00
foreach (
$result -> join_view_table as $nr => & $option
)
2016-02-26 00:20:09 +00:00
{
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check (
2020-03-28 13:34:14 +00:00
$option [ 'selection' ]
))
2016-02-26 00:20:09 +00:00
{
2018-10-04 10:07:37 +00:00
// convert the type
2020-03-28 13:34:14 +00:00
$option [ 'type' ]
= $typeArray [ $option [ 'type' ]];
2018-10-04 10:07:37 +00:00
// convert the operator
2020-03-28 13:34:14 +00:00
$option [ 'operator' ]
= $operatorArray [ $option [ 'operator' ]];
2018-10-04 10:07:37 +00:00
// get the on field values
2020-03-28 13:34:14 +00:00
$on_field
= $_relationship [ $nr ][ 'on_field' ];
2018-10-04 10:07:37 +00:00
// get the join field values
2020-03-28 13:34:14 +00:00
$join_field
= $_relationship [ $nr ][ 'join_field' ];
2019-12-16 03:02:16 +00:00
// set selection
2020-03-28 13:34:14 +00:00
$option [ 'selection' ]
= $this -> setDataSelection (
$result -> key , $view_code ,
$option [ 'selection' ],
$option [ 'view_table' ],
$option [ 'as' ], $option [ 'row_type' ],
'view'
);
$option [ 'key' ] = $result -> key ;
2018-10-04 10:07:37 +00:00
$option [ 'context' ] = $context ;
// load to the getters
if ( $option [ 'row_type' ] == 1 )
2016-02-26 00:20:09 +00:00
{
2018-10-04 10:07:37 +00:00
$result -> main_get [] = $option ;
2020-03-28 13:34:14 +00:00
if ( $on_field [ 0 ] === 'a'
|| isset ( $_part_of_a [ $join_field [ 0 ]])
|| isset ( $_part_of_a [ $on_field [ 0 ]]))
2018-10-04 10:07:37 +00:00
{
2022-08-30 15:28:41 +00:00
$this -> siteMainGet [ CFactory :: _ ( 'Config' ) -> build_target ][ $view_code ][ $option [ 'as' ]]
2020-03-28 13:34:14 +00:00
= $option [ 'as' ];
2018-10-04 10:07:37 +00:00
}
else
{
2022-08-30 15:28:41 +00:00
$this -> siteDynamicGet [ CFactory :: _ ( 'Config' ) -> build_target ][ $view_code ][ $option [ 'as' ]][ $join_field [ 1 ]]
2020-03-28 13:34:14 +00:00
= $on_field [ 0 ];
2018-10-04 10:07:37 +00:00
}
2016-02-26 00:20:09 +00:00
}
2018-10-04 10:07:37 +00:00
elseif ( $option [ 'row_type' ] == 2 )
2016-02-26 00:20:09 +00:00
{
2018-10-04 10:07:37 +00:00
$result -> custom_get [] = $option ;
if ( $on_field [ 0 ] != 'a' )
{
2022-08-30 15:28:41 +00:00
$this -> siteDynamicGet [ CFactory :: _ ( 'Config' ) -> build_target ][ $view_code ][ $option [ 'as' ]][ $join_field [ 1 ]]
2020-03-28 13:34:14 +00:00
= $on_field [ 0 ];
2018-10-04 10:07:37 +00:00
}
2016-02-26 00:20:09 +00:00
}
}
2018-10-04 10:07:37 +00:00
unset ( $result -> join_view_table [ $nr ]);
2016-02-26 00:20:09 +00:00
}
}
2018-10-04 10:07:37 +00:00
unset ( $result -> join_view_table );
// set join_db_table details
2020-03-28 13:34:14 +00:00
$result -> join_db_table = json_decode (
$result -> join_db_table , true
);
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$result -> join_db_table
))
2016-02-26 00:20:09 +00:00
{
2019-12-16 03:02:16 +00:00
// start the part of a table bucket
$_part_of_a = array ();
// build relationship
2020-03-28 13:34:14 +00:00
$_relationship = array_map (
function ( $op ) use ( & $_part_of_a ) {
$bucket = array ();
// array(on_field_as, on_field)
$bucket [ 'on_field' ] = array_map (
'trim' ,
explode ( '.' , $op [ 'on_field' ])
);
// array(join_field_as, join_field)
$bucket [ 'join_field' ] = array_map (
'trim' ,
explode ( '.' , $op [ 'join_field' ])
);
// triget filed that has table a relationship
if ( $op [ 'row_type' ] == 1
&& ( $bucket [ 'on_field' ][ 0 ] === 'a'
|| isset ( $_part_of_a [ $bucket [ 'on_field' ][ 0 ]])
|| isset ( $_part_of_a [ $bucket [ 'join_field' ][ 0 ]])))
{
$_part_of_a [ $op [ 'as' ]] = $op [ 'as' ];
}
return $bucket ;
}, $result -> join_db_table
);
2019-12-16 03:02:16 +00:00
// loop joints
2020-03-28 13:34:14 +00:00
foreach (
$result -> join_db_table as $nr => & $option1
)
2016-02-26 00:20:09 +00:00
{
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check (
2020-03-28 13:34:14 +00:00
$option1 [ 'selection' ]
))
2016-02-26 00:20:09 +00:00
{
2018-10-04 10:07:37 +00:00
// convert the type
2020-03-28 13:34:14 +00:00
$option1 [ 'type' ]
= $typeArray [ $option1 [ 'type' ]];
2018-10-04 10:07:37 +00:00
// convert the operator
2020-03-28 13:34:14 +00:00
$option1 [ 'operator' ]
= $operatorArray [ $option1 [ 'operator' ]];
2018-10-04 10:07:37 +00:00
// get the on field values
2020-03-28 13:34:14 +00:00
$on_field
= $_relationship [ $nr ][ 'on_field' ];
2018-10-04 10:07:37 +00:00
// get the join field values
2020-03-28 13:34:14 +00:00
$join_field
= $_relationship [ $nr ][ 'join_field' ];
2019-12-16 03:02:16 +00:00
// set selection
2020-03-28 13:34:14 +00:00
$option1 [ 'selection' ]
= $this -> setDataSelection (
$result -> key , $view_code ,
$option1 [ 'selection' ],
$option1 [ 'db_table' ],
$option1 [ 'as' ],
$option1 [ 'row_type' ], 'db'
);
$option1 [ 'key' ] = $result -> key ;
2018-10-04 10:07:37 +00:00
$option1 [ 'context' ] = $context ;
// load to the getters
if ( $option1 [ 'row_type' ] == 1 )
2016-02-26 00:20:09 +00:00
{
2018-10-04 10:07:37 +00:00
$result -> main_get [] = $option1 ;
2020-03-28 13:34:14 +00:00
if ( $on_field [ 0 ] === 'a'
|| isset ( $_part_of_a [ $join_field [ 0 ]])
|| isset ( $_part_of_a [ $on_field [ 0 ]]))
2018-10-04 10:07:37 +00:00
{
2022-08-30 15:28:41 +00:00
$this -> siteMainGet [ CFactory :: _ ( 'Config' ) -> build_target ][ $view_code ][ $option1 [ 'as' ]]
2020-03-28 13:34:14 +00:00
= $option1 [ 'as' ];
2018-10-04 10:07:37 +00:00
}
else
{
2022-08-30 15:28:41 +00:00
$this -> siteDynamicGet [ CFactory :: _ ( 'Config' ) -> build_target ][ $view_code ][ $option1 [ 'as' ]][ $join_field [ 1 ]]
2020-03-28 13:34:14 +00:00
= $on_field [ 0 ];
2018-10-04 10:07:37 +00:00
}
2016-02-26 00:20:09 +00:00
}
2018-10-04 10:07:37 +00:00
elseif ( $option1 [ 'row_type' ] == 2 )
2016-02-26 00:20:09 +00:00
{
2018-10-04 10:07:37 +00:00
$result -> custom_get [] = $option1 ;
if ( $on_field [ 0 ] != 'a' )
{
2022-08-30 15:28:41 +00:00
$this -> siteDynamicGet [ CFactory :: _ ( 'Config' ) -> build_target ][ $view_code ][ $option1 [ 'as' ]][ $join_field [ 1 ]]
2020-03-28 13:34:14 +00:00
= $on_field [ 0 ];
2018-10-04 10:07:37 +00:00
}
2016-02-26 00:20:09 +00:00
}
}
2018-10-04 10:07:37 +00:00
unset ( $result -> join_db_table [ $nr ]);
2016-02-26 00:20:09 +00:00
}
}
2018-10-04 10:07:37 +00:00
unset ( $result -> join_db_table );
// set filter details
2020-03-28 13:34:14 +00:00
$result -> filter = json_decode (
$result -> filter , true
);
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$result -> filter
))
2016-02-26 00:20:09 +00:00
{
2018-10-04 10:07:37 +00:00
foreach ( $result -> filter as $nr => & $option2 )
2016-02-26 00:20:09 +00:00
{
2018-10-04 10:07:37 +00:00
if ( isset ( $option2 [ 'operator' ]))
{
2020-03-28 13:34:14 +00:00
$option2 [ 'operator' ]
= $operatorArray [ $option2 [ 'operator' ]];
$option2 [ 'state_key' ]
2022-08-30 15:28:41 +00:00
= CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
$option2 [ 'state_key' ]
2022-08-30 15:28:41 +00:00
), CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
);
2018-10-04 10:07:37 +00:00
$option2 [ 'key' ] = $result -> key ;
}
else
{
unset ( $result -> filter [ $nr ]);
}
2016-02-26 00:20:09 +00:00
}
}
2018-10-04 10:07:37 +00:00
// set where details
$result -> where = json_decode ( $result -> where , true );
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$result -> where
))
2016-02-26 00:20:09 +00:00
{
2018-10-04 10:07:37 +00:00
foreach ( $result -> where as $nr => & $option3 )
2016-02-26 00:20:09 +00:00
{
2018-10-04 10:07:37 +00:00
if ( isset ( $option3 [ 'operator' ]))
{
2020-03-28 13:34:14 +00:00
$option3 [ 'operator' ]
= $operatorArray [ $option3 [ 'operator' ]];
2018-10-04 10:07:37 +00:00
}
else
{
unset ( $result -> where [ $nr ]);
}
2016-02-26 00:20:09 +00:00
}
}
2018-10-04 10:07:37 +00:00
else
{
unset ( $result -> where );
}
// set order details
$result -> order = json_decode ( $result -> order , true );
2022-03-09 23:46:45 +00:00
if ( ! ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$result -> order
))
2018-10-04 10:07:37 +00:00
{
unset ( $result -> order );
}
2019-04-09 20:42:19 +00:00
// set grouping
$result -> group = json_decode ( $result -> group , true );
2022-03-09 23:46:45 +00:00
if ( ! ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$result -> group
))
2019-04-09 20:42:19 +00:00
{
unset ( $result -> group );
}
2018-10-04 10:07:37 +00:00
// set global details
2020-03-28 13:34:14 +00:00
$result -> global = json_decode (
$result -> global , true
);
2022-03-09 23:46:45 +00:00
if ( ! ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$result -> global
))
2018-10-04 10:07:37 +00:00
{
unset ( $result -> global );
}
2016-02-26 00:20:09 +00:00
}
2017-10-06 14:53:22 +00:00
else
{
2018-10-04 10:07:37 +00:00
// when we have a custom query script we do not add the dynamic options
unset ( $result -> join_view_table );
unset ( $result -> join_db_table );
unset ( $result -> filter );
2017-10-06 14:53:22 +00:00
unset ( $result -> where );
unset ( $result -> order );
2019-04-09 20:42:19 +00:00
unset ( $result -> group );
2017-10-06 14:53:22 +00:00
unset ( $result -> global );
}
2018-08-23 01:37:42 +00:00
// load the events if any is set
2020-03-28 13:34:14 +00:00
if ( $result -> gettype == 1
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check (
2020-03-28 13:34:14 +00:00
$result -> plugin_events
))
2018-08-23 01:37:42 +00:00
{
2020-03-28 13:34:14 +00:00
$result -> plugin_events = json_decode (
$result -> plugin_events , true
);
2018-08-23 01:37:42 +00:00
}
else
{
$result -> plugin_events = '' ;
}
2022-01-15 17:52:09 +00:00
// Trigger Event: jcb_ce_onAfterModelDynamicGetData
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2022-01-15 17:52:09 +00:00
'jcb_ce_onAfterModelDynamicGetData' ,
array ( & $this -> componentContext , & $result , & $result -> id , & $view_code , & $context )
);
2016-02-26 00:20:09 +00:00
}
2020-03-28 13:34:14 +00:00
2016-02-26 00:20:09 +00:00
return $results ;
}
}
}
2020-03-28 13:34:14 +00:00
2016-02-26 00:20:09 +00:00
return false ;
}
2017-12-14 23:10:47 +00:00
2019-07-28 21:48:42 +00:00
/**
2022-08-31 11:49:01 +00:00
* Set the script for the customcode dispenser
2019-07-28 21:48:42 +00:00
*
2022-08-31 11:49:01 +00:00
* @ param string $script The script
* @ param string $first The first key
* @ param string | null $second The second key ( if not set we use only first key )
* @ param string | null $third The third key ( if not set we use only first and second key )
* @ param array $config The config options
* @ param bool $base64 The switch to decode base64 the script
* default : true
* @ param bool $dynamic The switch to dynamic update the script
* default : true
* @ param bool $add The switch to add to exiting instead of replace
* default : false
*
* @ return bool true on success
* @ deprecated 3.3 Use CFactory :: _ ( 'Customcode.Dispenser' ) -> set ( $script , $first , $second , $third , $config , $base64 , $dynamic , $add );
*/
public function setCustomScriptBuilder (
& $script ,
string $first ,
? string $second = null ,
? string $third = null ,
array $config = array (),
bool $base64 = true ,
bool $dynamic = true ,
bool $add = false
) : bool
2021-12-21 14:44:50 +00:00
{
2022-08-31 11:49:01 +00:00
return CFactory :: _ ( 'Customcode.Dispenser' ) -> set ( $script , $first , $second , $third , $config , $base64 , $dynamic , $add );
2019-07-28 21:48:42 +00:00
}
2020-12-05 06:17:54 +00:00
/**
* get the a script from the custom script builder
*
* @ param string $first The first key
* @ param string $second The second key
* @ param string $prefix The prefix to add in front of the script if found
* @ param string $note The switch / note to add to the script
* @ param bool $unset The switch to unset the value if found
* @ param string $default The switch / string to use as default return if script not found
* @ param string $sufix The sufix to add after the script if found
*
* @ return mix The string / script if found or the default value if not found
2022-08-31 11:49:01 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Customcode.Dispenser' ) -> get ( $first , $second , $prefix , $note , $unset , $default , $sufix );
2020-12-05 06:17:54 +00:00
*/
public function getCustomScriptBuilder ( $first , $second , $prefix = '' ,
2021-12-21 14:44:50 +00:00
$note = null , $unset = null , $default = null , $sufix = ''
)
{
2022-08-31 11:49:01 +00:00
return CFactory :: _ ( 'Customcode.Dispenser' ) -> get ( $first , $second , $prefix , $note , $unset , $default , $sufix );
2020-12-05 06:17:54 +00:00
}
2017-10-29 11:03:06 +00:00
/**
* To limit the SQL Demo date build in the views
2020-03-28 13:34:14 +00:00
*
* @ param array $settings Tweaking array .
2017-10-29 11:03:06 +00:00
*
* @ return void
2020-03-28 13:34:14 +00:00
*
2017-12-14 23:10:47 +00:00
*/
2017-10-29 11:03:06 +00:00
public function setSqlTweaking ( $settings )
{
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $settings ))
2017-10-29 11:03:06 +00:00
{
2017-12-14 23:10:47 +00:00
foreach ( $settings as $setting )
2017-10-29 11:03:06 +00:00
{
// should sql dump be added
if ( 1 == $setting [ 'add_sql' ])
{
// add sql (by option)
if ( 2 == $setting [ 'add_sql_options' ])
{
2020-03-28 13:34:14 +00:00
// rest always
2017-10-29 11:03:06 +00:00
$id_array = array ();
// by id (first remove backups)
$ids = $setting [ 'ids' ];
// now get the ids
if ( strpos ( $ids , ',' ) !== false )
{
2020-03-28 13:34:14 +00:00
$id_array = ( array ) array_map (
'trim' , explode ( ',' , $ids )
);
2017-10-29 11:03:06 +00:00
}
else
{
$id_array [] = trim ( $ids );
}
$id_array_new = array ();
// check for ranges
foreach ( $id_array as $key => $id )
{
if ( strpos ( $id , '=>' ) !== false )
{
2020-03-28 13:34:14 +00:00
$id_range = ( array ) array_map (
'trim' , explode ( '=>' , $id )
);
2017-10-29 11:03:06 +00:00
unset ( $id_array [ $key ]);
// build range
2019-09-05 21:12:56 +00:00
if ( count (( array ) $id_range ) == 2 )
2017-10-29 11:03:06 +00:00
{
2020-03-28 13:34:14 +00:00
$range = range (
$id_range [ 0 ], $id_range [ 1 ]
);
$id_array_new = array_merge (
$id_array_new , $range
);
2017-10-29 11:03:06 +00:00
}
}
}
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $id_array_new ))
2017-10-29 11:03:06 +00:00
{
$id_array = array_merge ( $id_array_new , $id_array );
}
// final fixing to array
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $id_array ))
2017-10-29 11:03:06 +00:00
{
// uniqe
$id_array = array_unique ( $id_array , SORT_NUMERIC );
// sort
sort ( $id_array , SORT_NUMERIC );
// now set it to global
2020-03-28 13:34:14 +00:00
$this -> sqlTweak [( int ) $setting [ 'adminview' ]][ 'where' ]
= implode ( ',' , $id_array );
2017-10-29 11:03:06 +00:00
}
}
}
else
{
// remove all sql dump options
2020-03-28 13:34:14 +00:00
$this -> sqlTweak [( int ) $setting [ 'adminview' ]][ 'remove' ]
= true ;
2017-10-29 11:03:06 +00:00
}
}
}
}
2017-12-14 23:10:47 +00:00
2017-06-16 12:38:06 +00:00
/**
* check if an update SQL is needed
2020-03-28 13:34:14 +00:00
*
* @ param mix $old The old values
* @ param mix $new The new values
* @ param string $type The type of values
* @ param int $key The id / key where values changed
* @ param array $ignore The ids to ignore
2017-06-16 12:38:06 +00:00
*
* @ return void
2020-03-28 13:34:14 +00:00
*
2017-06-16 12:38:06 +00:00
*/
2020-03-28 13:34:14 +00:00
protected function setUpdateSQL ( $old , $new , $type , $key = null ,
2021-12-21 14:44:50 +00:00
$ignore = null
)
{
2017-06-16 12:38:06 +00:00
// check if there were new items added
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $new )
&& ArrayHelper :: check ( $old ))
2017-06-16 12:38:06 +00:00
{
2017-10-12 23:14:17 +00:00
// check if this is old repeatable field
if ( isset ( $new [ $type ]))
2017-06-16 12:38:06 +00:00
{
2017-10-12 23:14:17 +00:00
foreach ( $new [ $type ] as $item )
2017-10-12 00:50:14 +00:00
{
2017-10-12 23:14:17 +00:00
$newItem = true ;
2018-07-12 16:35:38 +00:00
// check if this is an id to ignore
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $ignore )
2020-03-28 13:34:14 +00:00
&& in_array (
$item , $ignore
))
2018-07-12 16:35:38 +00:00
{
// don't add ignored ids
$newItem = false ;
}
2017-10-12 00:50:14 +00:00
// check if this is old repeatable field
2020-03-28 13:34:14 +00:00
elseif ( isset ( $old [ $type ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check ( $old [ $type ]))
2017-10-12 00:50:14 +00:00
{
2017-10-12 23:14:17 +00:00
if ( ! in_array ( $item , $old [ $type ]))
2017-10-12 00:50:14 +00:00
{
2017-10-12 23:14:17 +00:00
// we have a new item, lets add to SQL
$this -> setAddSQL ( $type , $item , $key );
2017-10-12 00:50:14 +00:00
}
2017-10-12 23:14:17 +00:00
// add only once
$newItem = false ;
2017-10-12 00:50:14 +00:00
}
elseif ( ! isset ( $old [ $type ]))
{
// we have new values
2017-12-14 23:10:47 +00:00
foreach ( $old as $oldItem )
2017-10-12 00:50:14 +00:00
{
if ( isset ( $oldItem [ $type ]))
{
if ( $oldItem [ $type ] == $item [ $type ])
{
$newItem = false ;
break ;
}
}
else
{
$newItem = false ;
break ;
}
}
}
else
{
$newItem = false ;
}
2017-10-12 23:14:17 +00:00
// add if new
if ( $newItem )
2017-06-16 12:38:06 +00:00
{
2017-10-12 23:14:17 +00:00
// we have a new item, lets add to SQL
$this -> setAddSQL ( $type , $item [ $type ], $key );
2017-06-16 12:38:06 +00:00
}
2017-10-12 23:14:17 +00:00
}
}
else
{
foreach ( $new as $item )
{
if ( isset ( $item [ $type ]))
2017-06-16 12:38:06 +00:00
{
2018-07-12 16:35:38 +00:00
// search to see if this is a new value
$newItem = true ;
// check if this is an id to ignore
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $ignore )
2020-03-28 13:34:14 +00:00
&& in_array ( $item [ $type ], $ignore ))
2018-07-12 16:35:38 +00:00
{
// don't add ignored ids
$newItem = false ;
}
2017-10-12 23:14:17 +00:00
// check if this is old repeatable field
2020-03-28 13:34:14 +00:00
elseif ( isset ( $old [ $type ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check ( $old [ $type ]))
2017-06-16 12:38:06 +00:00
{
2017-10-12 23:14:17 +00:00
if ( in_array ( $item [ $type ], $old [ $type ]))
{
$newItem = false ;
}
2017-06-16 12:38:06 +00:00
}
2017-10-12 23:14:17 +00:00
elseif ( ! isset ( $old [ $type ]))
2017-06-16 12:38:06 +00:00
{
2017-10-12 23:14:17 +00:00
// we have new values
2017-12-14 23:10:47 +00:00
foreach ( $old as $oldItem )
2017-10-12 23:14:17 +00:00
{
if ( isset ( $oldItem [ $type ]))
{
if ( $oldItem [ $type ] == $item [ $type ])
{
$newItem = false ;
break ;
}
}
else
{
$newItem = false ;
break ;
}
}
2017-06-16 12:38:06 +00:00
}
else
{
2017-10-12 23:14:17 +00:00
$newItem = false ;
2017-06-16 12:38:06 +00:00
}
2018-07-12 16:35:38 +00:00
// add if new
if ( $newItem )
{
// we have a new item, lets add to SQL
$this -> setAddSQL ( $type , $item [ $type ], $key );
}
2017-10-12 23:14:17 +00:00
}
2017-06-16 12:38:06 +00:00
}
}
}
2020-03-28 13:34:14 +00:00
elseif ( $key
2022-03-09 23:46:45 +00:00
&& (( StringHelper :: check ( $new )
&& StringHelper :: check ( $old ))
2020-03-28 13:34:14 +00:00
|| ( is_numeric ( $new ) && is_numeric ( $old )))
&& $new !== $old )
2017-06-16 12:38:06 +00:00
{
// the string changed, lets add to SQL update
2020-03-28 13:34:14 +00:00
if ( ! isset ( $this -> updateSQL [ $type ])
2022-03-09 23:46:45 +00:00
|| ! ArrayHelper :: check ( $this -> updateSQL [ $type ]))
2017-06-16 12:38:06 +00:00
{
$this -> updateSQL [ $type ] = array ();
}
// set at key
2017-12-14 23:10:47 +00:00
$this -> updateSQL [ $type ][ $key ] = array ( 'old' => $old , 'new' => $new );
2017-06-16 12:38:06 +00:00
}
}
2017-12-14 23:10:47 +00:00
2017-10-12 23:14:17 +00:00
/**
* Set the add sql
2020-03-28 13:34:14 +00:00
*
* @ param string $type The type of values
* @ param int $item The item id to add
* @ param int $key The id / key where values changed
*
2017-10-12 23:14:17 +00:00
* @ return void
*/
protected function setAddSQL ( $type , $item , $key )
{
// we have a new item, lets add to SQL
2020-03-28 13:34:14 +00:00
if ( ! isset ( $this -> addSQL [ $type ])
2022-03-09 23:46:45 +00:00
|| ! ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$this -> addSQL [ $type ]
))
2017-10-12 23:14:17 +00:00
{
$this -> addSQL [ $type ] = array ();
}
// add key if found
if ( $key )
{
2020-03-28 13:34:14 +00:00
if ( ! isset ( $this -> addSQL [ $type ][ $key ])
2022-03-09 23:46:45 +00:00
|| ! ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$this -> addSQL [ $type ][ $key ]
))
2017-10-12 23:14:17 +00:00
{
$this -> addSQL [ $type ][ $key ] = array ();
}
$this -> addSQL [ $type ][ $key ][] = ( int ) $item ;
}
else
{
// convert adminview id to name
if ( 'adminview' === $type )
{
2022-03-09 23:46:45 +00:00
$this -> addSQL [ $type ][] = StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$this -> getAdminViewData ( $item ) -> name_single
);
2017-10-12 23:14:17 +00:00
}
else
{
$this -> addSQL [ $type ][] = ( int ) $item ;
}
}
}
2017-12-14 23:10:47 +00:00
2017-06-16 12:38:06 +00:00
/**
* Get Item History values
2020-03-28 13:34:14 +00:00
*
* @ param string $type The type of item
* @ param int $id The item ID
2017-06-16 12:38:06 +00:00
*
2022-09-10 08:16:44 +00:00
* @ return object The history
* @ deprecated 3.3 Use CFactory :: _ ( 'History' ) -> get ( $type , $id );
2017-06-16 12:38:06 +00:00
*/
protected function getHistoryWatch ( $type , $id )
{
2022-09-10 08:16:44 +00:00
return CFactory :: _ ( 'History' ) -> get ( $type , $id );
2017-06-16 12:38:06 +00:00
}
2017-12-14 23:10:47 +00:00
2017-06-16 12:38:06 +00:00
/**
* Set Item History Watch
2020-03-28 13:34:14 +00:00
*
* @ param Object $object The history object
* @ param int $action The action to take
* 0 = remove watch
* 1 = add watch
* @ param string $type The type of item
2017-06-16 12:38:06 +00:00
*
* @ return bool
2022-09-10 08:16:44 +00:00
* @ deprecated 3.3
2017-06-16 12:38:06 +00:00
*/
protected function setHistoryWatch ( $object , $action )
{
2022-09-10 08:16:44 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
), 'Error'
);
2017-06-16 12:38:06 +00:00
}
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* Set Template and Layout Data
2020-03-28 13:34:14 +00:00
*
2020-12-31 11:18:52 +00:00
* @ param string $default The content to check
* @ param string $view The view code name
* @ param boolean $found The proof that something was found
* @ param array $templates The option to pass templates keys ( to avoid search )
* @ param array $layouts The option to pass layout keys ( to avoid search )
2016-02-26 00:20:09 +00:00
*
2020-12-27 11:54:51 +00:00
* @ return boolean if something was found true
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
*/
2020-12-31 11:18:52 +00:00
public function setTemplateAndLayoutData ( $default , $view , $found = false ,
2021-12-21 14:44:50 +00:00
$templates = array (), $layouts = array ()
)
{
2020-12-31 11:18:52 +00:00
// to check inside the templates
$again = array ();
// check if template keys were passed
2022-03-09 23:46:45 +00:00
if ( ! ArrayHelper :: check ( $templates ))
2016-02-26 00:20:09 +00:00
{
2020-12-31 11:18:52 +00:00
// set the Template data
2022-04-04 15:35:08 +00:00
$temp1 = GetHelper :: allBetween (
2020-12-31 11:18:52 +00:00
$default , " \$ this->loadTemplate(' " , " ') "
);
2022-04-04 15:35:08 +00:00
$temp2 = GetHelper :: allBetween (
2020-12-31 11:18:52 +00:00
$default , '$this->loadTemplate("' , '")'
);
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $temp1 )
&& ArrayHelper :: check ( $temp2 ))
2016-02-26 00:20:09 +00:00
{
2020-12-31 11:18:52 +00:00
$templates = array_merge ( $temp1 , $temp2 );
2016-02-26 00:20:09 +00:00
}
2020-12-31 11:18:52 +00:00
else
2016-02-26 00:20:09 +00:00
{
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $temp1 ))
2020-12-31 11:18:52 +00:00
{
$templates = $temp1 ;
}
2022-03-09 23:46:45 +00:00
elseif ( ArrayHelper :: check ( $temp2 ))
2020-12-31 11:18:52 +00:00
{
$templates = $temp2 ;
}
2016-02-26 00:20:09 +00:00
}
}
2020-12-31 11:18:52 +00:00
// check if we found templates
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $templates , true ))
2016-02-26 00:20:09 +00:00
{
foreach ( $templates as $template )
{
2022-08-30 15:28:41 +00:00
if ( ! isset ( $this -> templateData [ CFactory :: _ ( 'Config' ) -> build_target ][ $view ])
2020-03-28 13:34:14 +00:00
|| ! array_key_exists (
2022-08-30 15:28:41 +00:00
$template , $this -> templateData [ CFactory :: _ ( 'Config' ) -> build_target ][ $view ]
2020-03-28 13:34:14 +00:00
))
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
$data = $this -> getDataWithAlias (
$template , 'template' , $view
);
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $data ))
2016-02-26 00:20:09 +00:00
{
2020-12-27 11:54:51 +00:00
// load it to the template data array
2022-08-30 15:28:41 +00:00
$this -> templateData [ CFactory :: _ ( 'Config' ) -> build_target ][ $view ][ $template ]
2020-03-28 13:34:14 +00:00
= $data ;
2016-02-26 00:20:09 +00:00
// call self to get child data
2017-12-14 23:10:47 +00:00
$again [] = array ( $data [ 'html' ], $view );
$again [] = array ( $data [ 'php_view' ], $view );
2016-02-26 00:20:09 +00:00
}
}
2020-12-27 11:54:51 +00:00
// check if we have the template set (and nothing yet found)
2020-12-31 11:18:52 +00:00
if ( ! $found
2022-08-30 15:28:41 +00:00
&& isset ( $this -> templateData [ CFactory :: _ ( 'Config' ) -> build_target ][ $view ][ $template ]))
2020-12-27 11:54:51 +00:00
{
// something was found
$found = true ;
}
2016-02-26 00:20:09 +00:00
}
}
2020-12-31 11:18:52 +00:00
// check if layout keys were passed
2022-03-09 23:46:45 +00:00
if ( ! ArrayHelper :: check ( $layouts ))
2016-02-26 00:20:09 +00:00
{
2020-12-31 11:18:52 +00:00
// set the Layout data
2022-04-04 15:35:08 +00:00
$lay1 = GetHelper :: allBetween (
2020-12-31 11:18:52 +00:00
$default , " JLayoutHelper::render(' " , " ', "
);
2022-04-04 15:35:08 +00:00
$lay2 = GetHelper :: allBetween (
2020-12-31 11:18:52 +00:00
$default , 'JLayoutHelper::render("' , '",'
);
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $lay1 )
&& ArrayHelper :: check ( $lay2 ))
2016-02-26 00:20:09 +00:00
{
2020-12-31 11:18:52 +00:00
$layouts = array_merge ( $lay1 , $lay2 );
2016-02-26 00:20:09 +00:00
}
2020-12-31 11:18:52 +00:00
else
2016-02-26 00:20:09 +00:00
{
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $lay1 ))
2020-12-31 11:18:52 +00:00
{
$layouts = $lay1 ;
}
2022-03-09 23:46:45 +00:00
elseif ( ArrayHelper :: check ( $lay2 ))
2020-12-31 11:18:52 +00:00
{
$layouts = $lay2 ;
}
2016-02-26 00:20:09 +00:00
}
}
2020-12-31 11:18:52 +00:00
// check if we found layouts
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $layouts , true ))
2016-02-26 00:20:09 +00:00
{
2020-12-31 11:18:52 +00:00
// get the other target if both
$_target = null ;
2022-08-30 15:28:41 +00:00
if ( CFactory :: _ ( 'Config' ) -> lang_target === 'both' )
2020-12-31 11:18:52 +00:00
{
2022-08-30 15:28:41 +00:00
$_target = ( CFactory :: _ ( 'Config' ) -> build_target === 'admin' ) ? 'site' : 'admin' ;
2020-12-31 11:18:52 +00:00
}
2016-02-26 00:20:09 +00:00
foreach ( $layouts as $layout )
{
2022-08-30 15:28:41 +00:00
if ( ! isset ( $this -> layoutData [ CFactory :: _ ( 'Config' ) -> build_target ])
2022-03-09 23:46:45 +00:00
|| ! ArrayHelper :: check (
2022-08-30 15:28:41 +00:00
$this -> layoutData [ CFactory :: _ ( 'Config' ) -> build_target ]
2020-03-28 13:34:14 +00:00
)
|| ! array_key_exists (
2022-08-30 15:28:41 +00:00
$layout , $this -> layoutData [ CFactory :: _ ( 'Config' ) -> build_target ]
2020-03-28 13:34:14 +00:00
))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$data = $this -> getDataWithAlias ( $layout , 'layout' , $view );
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $data ))
2016-02-26 00:20:09 +00:00
{
2020-12-27 11:54:51 +00:00
// load it to the layout data array
2022-08-30 15:28:41 +00:00
$this -> layoutData [ CFactory :: _ ( 'Config' ) -> build_target ][ $layout ] = $data ;
2020-12-31 11:18:52 +00:00
// check if other target is set
2022-08-30 15:28:41 +00:00
if ( CFactory :: _ ( 'Config' ) -> lang_target === 'both' && $_target )
2020-12-31 11:18:52 +00:00
{
$this -> layoutData [ $_target ][ $layout ] = $data ;
}
2016-02-26 00:20:09 +00:00
// call self to get child data
2017-12-14 23:10:47 +00:00
$again [] = array ( $data [ 'html' ], $view );
$again [] = array ( $data [ 'php_view' ], $view );
2016-02-26 00:20:09 +00:00
}
}
2020-12-27 11:54:51 +00:00
// check if we have the layout set (and nothing yet found)
2022-08-30 15:28:41 +00:00
if ( ! $found && isset ( $this -> layoutData [ CFactory :: _ ( 'Config' ) -> build_target ][ $layout ]))
2020-12-27 11:54:51 +00:00
{
// something was found
$found = true ;
}
2016-02-26 00:20:09 +00:00
}
}
2020-12-31 11:18:52 +00:00
// check again
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $again ))
2016-02-26 00:20:09 +00:00
{
foreach ( $again as $go )
{
2020-12-31 11:18:52 +00:00
$found = $this -> setTemplateAndLayoutData (
$go [ 0 ], $go [ 1 ], $found
);
2016-02-26 00:20:09 +00:00
}
}
2020-12-31 11:18:52 +00:00
2020-12-27 11:54:51 +00:00
// return the proof that something was found
return $found ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* Get Data With Alias
2020-03-28 13:34:14 +00:00
*
* @ param string $n_ame The alias name
* @ param string $table The table where to find the alias
* @ param string $view The view code name
2016-02-26 00:20:09 +00:00
*
* @ return array The data found with the alias
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
*/
2020-12-27 11:54:51 +00:00
protected function getDataWithAlias ( $n_ame , $table , $view )
2016-02-26 00:20:09 +00:00
{
2020-12-31 11:18:52 +00:00
// if not set, get all keys in table and set by ID
$this -> setDataWithAliasKeys ( $table );
// now check if key is found
$name = preg_replace ( " /[^A-Za-z]/ " , '' , $n_ame );
if ( isset ( $this -> dataWithAliasKeys [ $table ][ $name ]))
{
$ID = $this -> dataWithAliasKeys [ $table ][ $name ];
}
elseif ( isset ( $this -> dataWithAliasKeys [ $table ][ $n_ame ]))
{
$ID = $this -> dataWithAliasKeys [ $table ][ $n_ame ];
}
else
{
return false ;
}
2016-02-26 00:20:09 +00:00
// Create a new query object.
2017-02-13 23:24:38 +00:00
$query = $this -> db -> getQuery ( true );
2016-02-26 00:20:09 +00:00
$query -> select ( 'a.*' );
2017-12-14 23:10:47 +00:00
$query -> from ( '#__componentbuilder_' . $table . ' AS a' );
2020-12-31 11:18:52 +00:00
$query -> where (
2021-12-21 14:44:50 +00:00
$this -> db -> quoteName ( 'a.id' ) . ' = ' . ( int ) $ID
2020-12-31 11:18:52 +00:00
);
// get the other target if both
2022-08-30 15:28:41 +00:00
$_targets = array ( CFactory :: _ ( 'Config' ) -> build_target );
if ( CFactory :: _ ( 'Config' ) -> lang_target === 'both' )
2020-12-31 11:18:52 +00:00
{
$_targets = array ( 'site' , 'admin' );
}
2017-02-13 23:24:38 +00:00
$this -> db -> setQuery ( $query );
2020-12-31 11:18:52 +00:00
// get the row
$row = $this -> db -> loadObject ();
// we load this layout
$php_view = '' ;
if ( $row -> add_php_view == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $row -> php_view ))
2016-02-26 00:20:09 +00:00
{
2022-08-30 15:28:41 +00:00
$php_view = CFactory :: _ ( 'Customcode.Gui' ) -> set (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update ( base64_decode ( $row -> php_view )),
2020-12-31 11:18:52 +00:00
array (
'table' => $table ,
'field' => 'php_view' ,
'id' => ( int ) $row -> id ,
'type' => 'php' )
);
}
2022-08-30 15:28:41 +00:00
$contnent = CFactory :: _ ( 'Customcode.Gui' ) -> set (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update ( base64_decode ( $row -> { $table })),
2020-12-31 11:18:52 +00:00
array (
'table' => $table ,
'field' => $table ,
'id' => ( int ) $row -> id ,
'type' => 'html' )
);
// load all targets
foreach ( $_targets as $_target )
{
// load the library
if ( ! isset ( $this -> libManager [ $_target ]))
2016-02-26 00:20:09 +00:00
{
2020-12-31 11:18:52 +00:00
$this -> libManager [ $_target ] = array ();
}
if ( ! isset ( $this -> libManager [ $_target ][ $view ]))
{
$this -> libManager [ $_target ][ $view ] = array ();
}
// make sure json become array
2022-03-09 23:46:45 +00:00
if ( JsonHelper :: check ( $row -> libraries ))
2020-12-31 11:18:52 +00:00
{
$row -> libraries = json_decode ( $row -> libraries , true );
}
// if we have an array add it
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $row -> libraries ))
2020-12-31 11:18:52 +00:00
{
foreach ( $row -> libraries as $library )
2017-12-10 19:17:26 +00:00
{
2020-12-31 11:18:52 +00:00
if ( ! isset ( $this -> libManager [ $_target ][ $view ][ $library ]))
2017-12-10 19:17:26 +00:00
{
2020-12-31 11:18:52 +00:00
if ( $this -> getMediaLibrary (( int ) $library ))
2017-12-10 19:17:26 +00:00
{
2020-12-31 11:18:52 +00:00
$this -> libManager [ $_target ][ $view ][( int ) $library ]
= true ;
2017-12-10 19:17:26 +00:00
}
}
}
2020-12-31 11:18:52 +00:00
}
elseif ( is_numeric ( $row -> libraries )
&& ! isset ( $this -> libManager [ $_target ][ $view ][( int ) $row -> libraries ]))
{
if ( $this -> getMediaLibrary (( int ) $row -> libraries ))
2017-12-10 19:17:26 +00:00
{
2020-12-31 11:18:52 +00:00
$this -> libManager [ $_target ][ $view ][( int ) $row -> libraries ]
= true ;
2017-12-10 19:17:26 +00:00
}
2020-12-31 11:18:52 +00:00
}
// set footable to views and turn it on
if ( ! isset ( $this -> footableScripts [ $_target ][ $view ])
|| ! $this -> footableScripts [ $_target ][ $view ])
{
$foundFoo = $this -> getFootableScripts ( $contnent );
if ( $foundFoo )
2017-11-11 04:33:51 +00:00
{
2020-12-31 11:18:52 +00:00
$this -> footableScripts [ $_target ][ $view ] = true ;
2017-11-11 04:33:51 +00:00
}
2020-12-31 11:18:52 +00:00
if ( $foundFoo && ! $this -> footable )
2016-02-26 00:20:09 +00:00
{
2020-12-31 11:18:52 +00:00
$this -> footable = true ;
2016-02-26 00:20:09 +00:00
}
2020-12-31 11:18:52 +00:00
}
// set google charts to views and turn it on
if ( ! isset ( $this -> googleChart [ $_target ][ $view ])
|| ! $this -> googleChart [ $_target ][ $view ])
{
$foundA = $this -> getGoogleChart ( $php_view );
$foundB = $this -> getGoogleChart ( $contnent );
if ( $foundA || $foundB )
2016-02-26 00:20:09 +00:00
{
2020-12-31 11:18:52 +00:00
$this -> googleChart [ $_target ][ $view ] = true ;
2016-02-26 00:20:09 +00:00
}
2020-12-31 11:18:52 +00:00
if ( $foundA || $foundB && ! $this -> googlechart )
2016-02-26 00:20:09 +00:00
{
2020-12-31 11:18:52 +00:00
$this -> googlechart = true ;
2016-02-26 00:20:09 +00:00
}
}
2020-12-31 11:18:52 +00:00
// check for get module
if ( ! isset ( $this -> getModule [ $_target ][ $view ])
|| ! $this -> getModule [ $_target ][ $view ])
{
$foundA = $this -> getGetModule ( $php_view );
$foundB = $this -> getGetModule ( $contnent );
if ( $foundA || $foundB )
{
$this -> getModule [ $_target ][ $view ] = true ;
}
}
}
// load UIKIT if needed
if ( 2 == $this -> uikit || 1 == $this -> uikit )
{
if ( ! isset ( $this -> uikitComp [ $view ]))
{
$this -> uikitComp [ $view ] = array ();
}
// set uikit to views
$this -> uikitComp [ $view ]
= ComponentbuilderHelper :: getUikitComp (
$contnent , $this -> uikitComp [ $view ]
);
2016-02-26 00:20:09 +00:00
}
2020-03-28 13:34:14 +00:00
2020-12-31 11:18:52 +00:00
return array (
'id' => $row -> id ,
2022-08-30 15:28:41 +00:00
'html' => CFactory :: _ ( 'Customcode.Gui' ) -> set (
2020-12-31 11:18:52 +00:00
$contnent ,
array (
'table' => $table ,
'field' => $table ,
'id' => $row -> id ,
'type' => 'html'
)
),
2022-08-30 15:28:41 +00:00
'php_view' => CFactory :: _ ( 'Customcode.Gui' ) -> set (
2020-12-31 11:18:52 +00:00
$php_view ,
array (
'table' => $table ,
'field' => 'php_view' ,
'id' => $row -> id ,
'type' => 'php'
)
)
);
}
/**
* set Data With Alias Keys
*
* @ param string $table The table where to find the alias
*
* @ return void
*
*/
protected function setDataWithAliasKeys ( $table )
{
// now check if key is found
if ( ! isset ( $this -> dataWithAliasKeys [ $table ]))
{
// load this table keys
$this -> dataWithAliasKeys [ $table ] = array ();
// Create a new query object.
$query = $this -> db -> getQuery ( true );
$query -> select ( array ( 'a.id' , 'a.alias' ));
$query -> from ( '#__componentbuilder_' . $table . ' AS a' );
$this -> db -> setQuery ( $query );
$rows = $this -> db -> loadObjectList ();
// check if we have an array
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $rows ))
2020-12-31 11:18:52 +00:00
{
foreach ( $rows as $row )
{
// build the key
2022-03-09 23:46:45 +00:00
$k_ey = StringHelper :: safe ( $row -> alias );
2020-12-31 11:18:52 +00:00
$key = preg_replace ( " /[^A-Za-z]/ " , '' , $k_ey );
// set the keys
$this -> dataWithAliasKeys [ $table ][ $row -> alias ] = $row -> id ;
2021-12-21 14:44:50 +00:00
$this -> dataWithAliasKeys [ $table ][ $k_ey ] = $row -> id ;
$this -> dataWithAliasKeys [ $table ][ $key ] = $row -> id ;
2020-12-31 11:18:52 +00:00
}
}
}
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
2017-12-03 18:09:04 +00:00
/**
2019-10-16 20:34:36 +00:00
* Get Media Library Data and store globally
2020-03-28 13:34:14 +00:00
*
* @ param string $id the library id
2017-12-03 18:09:04 +00:00
*
* @ return bool true on success
2020-03-28 13:34:14 +00:00
*
2017-12-03 18:09:04 +00:00
*/
2019-10-16 20:34:36 +00:00
protected function getMediaLibrary ( $id )
2017-12-03 18:09:04 +00:00
{
2017-12-10 19:17:26 +00:00
// check if the lib has already been set
if ( ! isset ( $this -> libraries [ $id ]))
{
2019-12-06 05:31:32 +00:00
// make sure we should continue and that the lib is not already being loaded
2017-12-10 19:17:26 +00:00
switch ( $id )
{
case 1 : // No Library
return false ;
2017-12-14 23:10:47 +00:00
break ;
2017-12-10 19:17:26 +00:00
case 3 : // Uikit v3
if ( 2 == $this -> uikit || 3 == $this -> uikit )
{
// already being loaded
$this -> libraries [ $id ] = false ;
}
2017-12-14 23:10:47 +00:00
break ;
2017-12-10 19:17:26 +00:00
case 4 : // Uikit v2
if ( 2 == $this -> uikit || 1 == $this -> uikit )
{
// already being loaded
$this -> libraries [ $id ] = false ;
}
2017-12-14 23:10:47 +00:00
break ;
2017-12-10 19:17:26 +00:00
case 5 : // FooTable v2
2020-03-28 13:34:14 +00:00
if ( ! isset ( $this -> footableVersion )
|| 2 == $this -> footableVersion )
2017-12-10 19:17:26 +00:00
{
// already being loaded
$this -> libraries [ $id ] = false ;
}
2017-12-14 23:10:47 +00:00
break ;
2017-12-10 19:17:26 +00:00
case 6 : // FooTable v3
if ( 3 == $this -> footableVersion )
{
// already being loaded
$this -> libraries [ $id ] = false ;
}
2017-12-14 23:10:47 +00:00
break ;
2017-12-10 19:17:26 +00:00
}
}
2017-12-03 18:09:04 +00:00
// check if the lib has already been set
if ( ! isset ( $this -> libraries [ $id ]))
{
$query = $this -> db -> getQuery ( true );
$query -> select ( 'a.*' );
$query -> select (
$this -> db -> quoteName (
array (
2020-03-28 13:34:14 +00:00
'a.id' ,
'a.name' ,
'a.how' ,
'a.type' ,
'a.addconditions' ,
'b.addconfig' ,
'c.addfiles' ,
'c.addfolders' ,
'c.addfilesfullpath' ,
'c.addfoldersfullpath' ,
'c.addurls' ,
'a.php_setdocument'
2017-12-14 23:10:47 +00:00
), array (
2020-03-28 13:34:14 +00:00
'id' ,
'name' ,
'how' ,
'type' ,
'addconditions' ,
'addconfig' ,
'addfiles' ,
'addfolders' ,
'addfilesfullpath' ,
'addfoldersfullpath' ,
'addurls' ,
'php_setdocument'
2017-12-03 18:09:04 +00:00
)
2017-12-14 23:10:47 +00:00
)
);
2017-12-03 18:09:04 +00:00
// from these tables
$query -> from ( '#__componentbuilder_library AS a' );
2020-03-28 13:34:14 +00:00
$query -> join (
'LEFT' ,
$this -> db -> quoteName ( '#__componentbuilder_library_config' , 'b' )
. ' ON (' . $this -> db -> quoteName ( 'a.id' ) . ' = '
. $this -> db -> quoteName ( 'b.library' ) . ')'
);
$query -> join (
'LEFT' , $this -> db -> quoteName (
'#__componentbuilder_library_files_folders_urls' , 'c'
) . ' ON (' . $this -> db -> quoteName ( 'a.id' ) . ' = '
. $this -> db -> quoteName ( 'c.library' ) . ')'
);
2017-12-14 23:10:47 +00:00
$query -> where ( $this -> db -> quoteName ( 'a.id' ) . ' = ' . ( int ) $id );
2019-10-16 20:34:36 +00:00
$query -> where ( $this -> db -> quoteName ( 'a.target' ) . ' = 1' );
2017-12-03 18:09:04 +00:00
// Reset the query using our newly populated query object.
$this -> db -> setQuery ( $query );
// Load the results as a list of stdClass objects
$library = $this -> db -> loadObject ();
2017-12-14 23:10:47 +00:00
2017-12-10 19:17:26 +00:00
// check if this lib uses build-in behaviour
if ( $library -> how == 4 )
{
// fall back on build-in features
2020-03-28 13:34:14 +00:00
$buildin = array ( 3 => array ( 'uikit' => 3 ),
4 => array ( 'uikit' => 1 ),
5 => array ( 'footableVersion' => 2 ,
'footable' => true ),
6 => array ( 'footableVersion' => 3 ,
'footable' => true ));
if ( isset ( $buildin [ $library -> id ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$buildin [ $library -> id ]
))
2017-12-10 19:17:26 +00:00
{
// set the lib switch
foreach ( $buildin [ $library -> id ] as $lib => $val )
{
$this -> { $lib } = $val ;
}
// since we are falling back on build-in feature
$library -> how = 0 ;
}
else
{
// since we did not find build in behaviour we must load always.
$library -> how = 1 ;
}
}
2017-12-03 18:09:04 +00:00
// check if this lib has dynamic behaviour
if ( $library -> how > 0 )
{
2018-02-16 21:53:43 +00:00
// set the add targets
2020-03-28 13:34:14 +00:00
$addArray = array ( 'files' => 'files' ,
'folders' => 'folders' ,
'urls' => 'urls' ,
'filesfullpath' => 'files' ,
'foldersfullpath' => 'folders' );
2018-02-16 21:53:43 +00:00
foreach ( $addArray as $addTarget => $targetHere )
2017-12-03 18:09:04 +00:00
{
2018-02-16 21:53:43 +00:00
// set the add target data
2020-03-28 13:34:14 +00:00
$library -> { 'add' . $addTarget } = ( isset (
$library -> { 'add' . $addTarget }
)
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check (
2020-03-28 13:34:14 +00:00
$library -> { 'add' . $addTarget }
)) ? json_decode ( $library -> { 'add' . $addTarget }, true )
: null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$library -> { 'add' . $addTarget }
))
{
if ( isset ( $library -> { $targetHere })
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$library -> { $targetHere }
))
2018-02-16 21:53:43 +00:00
{
2018-03-18 04:52:07 +00:00
foreach ( $library -> { 'add' . $addTarget } as $taget )
2018-02-16 21:53:43 +00:00
{
$library -> { $targetHere }[] = $taget ;
}
}
else
{
2020-03-28 13:34:14 +00:00
$library -> { $targetHere } = array_values (
$library -> { 'add' . $addTarget }
);
2018-02-16 21:53:43 +00:00
}
}
2018-03-18 04:52:07 +00:00
unset ( $library -> { 'add' . $addTarget });
2017-12-14 23:10:47 +00:00
}
2017-12-03 18:09:04 +00:00
// add config fields only if needed
if ( $library -> how > 1 )
{
// set the config data
2020-03-28 13:34:14 +00:00
$library -> addconfig = ( isset ( $library -> addconfig )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check (
2020-03-28 13:34:14 +00:00
$library -> addconfig
)) ? json_decode ( $library -> addconfig , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $library -> addconfig ))
2017-12-03 18:09:04 +00:00
{
2020-03-28 13:34:14 +00:00
$library -> config = array_map (
function ( $array ) {
$array [ 'alias' ] = 0 ;
$array [ 'title' ] = 0 ;
2022-09-10 08:16:44 +00:00
$array [ 'settings' ] = CFactory :: _ ( 'Field.Data' ) -> get (
2020-03-28 13:34:14 +00:00
$array [ 'field' ]
);
return $array ;
}, array_values ( $library -> addconfig )
);
2017-12-03 18:09:04 +00:00
}
}
// if this lib is controlled by custom script
if ( 3 == $library -> how )
{
// set Needed PHP
2020-03-28 13:34:14 +00:00
if ( isset ( $library -> php_setdocument )
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$library -> php_setdocument
))
2017-12-03 18:09:04 +00:00
{
2022-08-30 15:28:41 +00:00
$library -> document = CFactory :: _ ( 'Customcode.Gui' ) -> set (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $library -> php_setdocument )
),
2019-07-28 21:48:42 +00:00
array (
'table' => 'library' ,
'field' => 'php_setdocument' ,
2020-03-28 13:34:14 +00:00
'id' => ( int ) $id ,
'type' => 'php' )
);
2017-12-03 18:09:04 +00:00
}
}
// if this lib is controlled by conditions
elseif ( 2 == $library -> how )
{
// set the addconditions data
2020-03-28 13:34:14 +00:00
$library -> addconditions = ( isset ( $library -> addconditions )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check (
2020-03-28 13:34:14 +00:00
$library -> addconditions
)) ? json_decode ( $library -> addconditions , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$library -> addconditions
))
{
$library -> conditions = array_values (
$library -> addconditions
);
2017-12-03 18:09:04 +00:00
}
}
unset ( $library -> php_setdocument );
unset ( $library -> addconditions );
2017-12-10 19:17:26 +00:00
unset ( $library -> addconfig );
// load to global lib
$this -> libraries [ $id ] = $library ;
2017-12-03 18:09:04 +00:00
}
else
{
$this -> libraries [ $id ] = false ;
}
}
// if set return
if ( isset ( $this -> libraries [ $id ]))
{
return $this -> libraries [ $id ];
}
2020-03-28 13:34:14 +00:00
2017-12-03 18:09:04 +00:00
return false ;
}
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2017-02-13 23:24:38 +00:00
* Set Language Place Holders
2018-04-08 06:12:18 +00:00
*
2020-03-28 13:34:14 +00:00
* @ param string $content The content
2016-02-26 00:20:09 +00:00
*
* @ return string The content with the updated Language place holder
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Language.Extractor' ) -> engine ( $content )
2016-02-26 00:20:09 +00:00
*/
2017-02-13 23:24:38 +00:00
public function setLangStrings ( $content )
2016-02-26 00:20:09 +00:00
{
2022-08-30 15:28:41 +00:00
return CFactory :: _ ( 'Language.Extractor' ) -> engine ( $content );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
2018-04-08 06:12:18 +00:00
/**
* Set the language String
2020-03-28 13:34:14 +00:00
*
* @ param string $string The plan text string ( English )
2018-04-08 06:12:18 +00:00
*
* @ return string The key language string ( all uppercase )
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Language' ) -> key ( $string );
2018-04-08 06:12:18 +00:00
*/
public function setLang ( $string )
{
2022-08-30 15:28:41 +00:00
return CFactory :: _ ( 'Language' ) -> key ( $string );
2018-04-08 06:12:18 +00:00
}
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* Set Data Selection of the dynamic get
2020-03-28 13:34:14 +00:00
*
* @ param string $method_key The method unique key
* @ param string $view_code The code name of the view
* @ param string $string The data string
* @ param string $asset The asset in question
* @ param string $as The as string
* @ param int $row_type The row type
* @ param string $type The target type ( db || view )
2016-02-26 00:20:09 +00:00
*
* @ return array the select query
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
*/
2020-03-28 13:34:14 +00:00
public function setDataSelection ( $method_key , $view_code , $string , $asset ,
2021-12-21 14:44:50 +00:00
$as , $row_type , $type
)
{
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $string ))
2016-02-26 00:20:09 +00:00
{
2019-01-29 14:43:27 +00:00
if ( 'db' === $type )
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
$table = '#__' . $asset ;
2019-01-29 14:43:27 +00:00
$queryName = $asset ;
2020-03-28 13:34:14 +00:00
$view = '' ;
2019-01-29 14:43:27 +00:00
}
elseif ( 'view' === $type )
{
2020-03-28 13:34:14 +00:00
$view = $this -> getViewTableName ( $asset );
2022-08-30 15:28:41 +00:00
$table = '#__' . CFactory :: _ ( 'Config' ) -> component_code_name . '_' . $view ;
2019-01-29 14:43:27 +00:00
$queryName = $view ;
}
// just get all values from table if * is found
if ( $string === '*' || strpos ( $string , '*' ) !== false )
{
if ( $type == 'view' )
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
$_string = ComponentbuilderHelper :: getViewTableColumns (
$asset , $as , $row_type
);
2016-02-26 00:20:09 +00:00
}
2019-01-29 14:43:27 +00:00
else
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
$_string = ComponentbuilderHelper :: getDbTableColumns (
$asset , $as , $row_type
);
2016-02-26 00:20:09 +00:00
}
2019-01-29 14:43:27 +00:00
// get only selected values
$lines = explode ( PHP_EOL , $_string );
// make sure to set the string to *
$string = '*' ;
}
else
{
// get only selected values
$lines = explode ( PHP_EOL , $string );
}
// only continue if lines are available
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $lines ))
2019-01-29 14:43:27 +00:00
{
2016-02-26 00:20:09 +00:00
$gets = array ();
$keys = array ();
2017-11-16 04:37:32 +00:00
// first load all options
2016-02-26 00:20:09 +00:00
foreach ( $lines as $line )
{
2017-12-14 23:10:47 +00:00
if ( strpos ( $line , 'AS' ) !== false )
2016-02-26 00:20:09 +00:00
{
2018-07-21 07:10:37 +00:00
$lineArray = explode ( " AS " , $line );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
elseif ( strpos ( $line , 'as' ) !== false )
2016-02-26 00:20:09 +00:00
{
2018-07-21 07:10:37 +00:00
$lineArray = explode ( " as " , $line );
2016-02-26 00:20:09 +00:00
}
else
{
2018-07-21 07:10:37 +00:00
$lineArray = array ( $line , null );
2016-02-26 00:20:09 +00:00
}
2017-11-16 04:37:32 +00:00
// set the get and key
2018-07-21 07:10:37 +00:00
$get = trim ( $lineArray [ 0 ]);
$key = trim ( $lineArray [ 1 ]);
2017-11-16 04:37:32 +00:00
// only add the view (we must adapt this)
2020-03-28 13:34:14 +00:00
if ( isset ( $this -> getAsLookup [ $method_key ][ $get ])
&& 'a' != $as
&& 1 == $row_type
&& 'view' === $type
&& strpos ( '#' . $key , '#' . $view . '_' ) === false )
2016-02-26 00:20:09 +00:00
{
2017-11-16 04:37:32 +00:00
// this is a problem (TODO) since we may want to not add the view name.
2017-12-14 23:10:47 +00:00
$key = $view . '_' . trim ( $key );
2016-02-26 00:20:09 +00:00
}
2017-11-16 04:37:32 +00:00
// continue only if we have get
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $get ))
2016-02-26 00:20:09 +00:00
{
2017-02-13 23:24:38 +00:00
$gets [] = $this -> db -> quote ( $get );
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $key ))
2016-02-26 00:20:09 +00:00
{
$this -> getAsLookup [ $method_key ][ $get ] = $key ;
2020-03-28 13:34:14 +00:00
$keys []
= $this -> db -> quote (
$key
);
2016-02-26 00:20:09 +00:00
}
else
{
2020-03-28 13:34:14 +00:00
$key = str_replace (
$as . '.' , '' , $get
);
2016-02-26 00:20:09 +00:00
$this -> getAsLookup [ $method_key ][ $get ] = $key ;
2020-03-28 13:34:14 +00:00
$keys []
= $this -> db -> quote (
$key
);
2016-02-26 00:20:09 +00:00
}
2018-07-21 07:10:37 +00:00
// make sure we have the view name
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $view ))
2016-02-26 00:20:09 +00:00
{
2018-07-21 07:10:37 +00:00
// prep the field name
2017-12-14 23:10:47 +00:00
$field = str_replace ( $as . '.' , '' , $get );
2018-07-21 07:10:37 +00:00
// make sure the array is set
if ( ! isset ( $this -> siteFields [ $view ][ $field ]))
{
$this -> siteFields [ $view ][ $field ] = array ();
}
// load to the site fields memory bucket
2020-03-28 13:34:14 +00:00
$this -> siteFields [ $view ][ $field ][ $method_key . '___'
. $as ]
= array ( 'site' => $view_code , 'get' => $get ,
'as' => $as , 'key' => $key );
2016-02-26 00:20:09 +00:00
}
}
}
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $gets )
&& ArrayHelper :: check ( $keys ))
2016-02-26 00:20:09 +00:00
{
2019-01-29 14:43:27 +00:00
// single joined selection needs the prefix to the values to avoid conflict in the names
2019-12-16 03:02:16 +00:00
// so we must still add then AS
2019-01-29 14:43:27 +00:00
if ( $string == '*' && 1 != $row_type )
{
$querySelect = " \$ query->select(' " . $as . " .*'); " ;
}
else
{
2020-03-28 13:34:14 +00:00
$querySelect = '$query->select($db->quoteName('
2022-08-30 15:28:41 +00:00
. PHP_EOL . Indent :: _ ( 3 ) . 'array(' . implode (
2020-03-28 13:34:14 +00:00
',' , $gets
2022-08-30 15:28:41 +00:00
) . '),' . PHP_EOL . Indent :: _ ( 3 ) . 'array('
2020-03-28 13:34:14 +00:00
. implode ( ',' , $keys ) . ')));' ;
2019-01-29 14:43:27 +00:00
}
2020-03-28 13:34:14 +00:00
$queryFrom = '$db->quoteName(' . $this -> db -> quote ( $table )
. ', ' . $this -> db -> quote ( $as ) . ')' ;
2016-02-26 00:20:09 +00:00
// return the select query
2020-03-28 13:34:14 +00:00
return array ( 'select' => $querySelect ,
'from' => $queryFrom ,
2022-05-16 04:25:03 +00:00
'name' => $queryName ,
'table' => $table ,
'type' => $type ,
'select_gets' => $gets ,
2020-03-28 13:34:14 +00:00
'select_keys' => $keys );
2016-02-26 00:20:09 +00:00
}
}
}
2020-11-29 00:00:20 +00:00
2016-02-26 00:20:09 +00:00
return false ;
}
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* Get the View Table Name
2020-03-28 13:34:14 +00:00
*
* @ param int $id The admin view in
2016-02-26 00:20:09 +00:00
*
* @ return string view code name
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
*/
public function getViewTableName ( $id )
{
// Create a new query object.
2017-02-13 23:24:38 +00:00
$query = $this -> db -> getQuery ( true );
$query -> select ( $this -> db -> quoteName ( array ( 'a.name_single' )));
2020-03-28 13:34:14 +00:00
$query -> from (
$this -> db -> quoteName ( '#__componentbuilder_admin_view' , 'a' )
);
2017-12-14 23:10:47 +00:00
$query -> where ( $this -> db -> quoteName ( 'a.id' ) . ' = ' . ( int ) $id );
2017-02-13 23:24:38 +00:00
$this -> db -> setQuery ( $query );
2020-03-28 13:34:14 +00:00
2022-03-09 23:46:45 +00:00
return StringHelper :: safe ( $this -> db -> loadResult ());
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* Build the SQL dump String for a view
2020-03-28 13:34:14 +00:00
*
* @ param string $tables The tables to use in build
* @ param string $view The target view / table to dump in
* @ param int $view_id The id of the target view
2016-02-26 00:20:09 +00:00
*
* @ return string on success with the Dump SQL
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
*/
2017-10-12 00:50:14 +00:00
public function buildSqlDump ( $tables , $view , $view_id )
2016-02-26 00:20:09 +00:00
{
// first build a query statment to get all the data (insure it must be added - check the tweaking)
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $tables )
2020-03-28 13:34:14 +00:00
&& ( ! isset ( $this -> sqlTweak [ $view_id ][ 'remove' ])
|| ! $this -> sqlTweak [ $view_id ][ 'remove' ]))
2016-02-26 00:20:09 +00:00
{
$counter = 'a' ;
// Create a new query object.
2017-02-13 23:24:38 +00:00
$query = $this -> db -> getQuery ( true );
2018-10-29 16:38:00 +00:00
// switch to onlu trigger the run of the query if we have tables to query
$runQuery = false ;
2016-02-26 00:20:09 +00:00
foreach ( $tables as $table )
{
2018-10-29 16:38:00 +00:00
if ( isset ( $table [ 'table' ]))
2016-02-26 00:20:09 +00:00
{
2018-10-29 16:38:00 +00:00
if ( $counter === 'a' )
2016-02-26 00:20:09 +00:00
{
2018-10-29 16:38:00 +00:00
// the main table fields
if ( strpos ( $table [ 'sourcemap' ], PHP_EOL ) !== false )
2016-02-26 00:20:09 +00:00
{
2018-10-29 16:38:00 +00:00
$fields = explode ( PHP_EOL , $table [ 'sourcemap' ]);
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $fields ))
2016-02-26 00:20:09 +00:00
{
2018-10-29 16:38:00 +00:00
// reset array buckets
$sourceArray = array ();
$targetArray = array ();
foreach ( $fields as $field )
2016-02-26 00:20:09 +00:00
{
2018-10-29 16:38:00 +00:00
if ( strpos ( $field , " => " ) !== false )
{
2020-03-28 13:34:14 +00:00
list ( $source , $target ) = explode (
" => " , $field
);
$sourceArray [] = $counter . '.' . trim (
$source
);
2018-10-29 16:38:00 +00:00
$targetArray [] = trim ( $target );
}
}
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$sourceArray
)
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$targetArray
))
2018-10-29 16:38:00 +00:00
{
// add to query
2020-03-28 13:34:14 +00:00
$query -> select (
$this -> db -> quoteName (
$sourceArray , $targetArray
)
);
$query -> from (
'#__' . $table [ 'table' ] . ' AS a'
);
2018-10-29 16:38:00 +00:00
$runQuery = true ;
}
// we may need to filter the selection
if ( isset ( $this -> sqlTweak [ $view_id ][ 'where' ]))
{
// add to query the where filter
2020-03-28 13:34:14 +00:00
$query -> where (
'a.id IN ('
. $this -> sqlTweak [ $view_id ][ 'where' ]
. ')'
);
2016-02-26 00:20:09 +00:00
}
}
}
}
2018-10-29 16:38:00 +00:00
else
2016-02-26 00:20:09 +00:00
{
2018-10-29 16:38:00 +00:00
// the other tables
if ( strpos ( $table [ 'sourcemap' ], PHP_EOL ) !== false )
2016-02-26 00:20:09 +00:00
{
2018-10-29 16:38:00 +00:00
$fields = explode ( PHP_EOL , $table [ 'sourcemap' ]);
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $fields ))
2016-02-26 00:20:09 +00:00
{
2018-10-29 16:38:00 +00:00
// reset array buckets
$sourceArray = array ();
$targetArray = array ();
foreach ( $fields as $field )
2016-02-26 00:20:09 +00:00
{
2018-10-29 16:38:00 +00:00
if ( strpos ( $field , " => " ) !== false )
{
2020-03-28 13:34:14 +00:00
list ( $source , $target ) = explode (
" => " , $field
);
$sourceArray [] = $counter . '.' . trim (
$source
);
2018-10-29 16:38:00 +00:00
$targetArray [] = trim ( $target );
}
if ( strpos ( $field , " == " ) !== false )
{
2020-03-28 13:34:14 +00:00
list ( $aKey , $bKey ) = explode (
" == " , $field
);
2018-10-29 16:38:00 +00:00
// add to query
2020-03-28 13:34:14 +00:00
$query -> join (
'LEFT' , $this -> db -> quoteName (
'#__' . $table [ 'table' ],
$counter
) . ' ON (' . $this -> db -> quoteName (
'a.' . trim ( $aKey )
) . ' = ' . $this -> db -> quoteName (
$counter . '.' . trim ( $bKey )
) . ')'
);
2018-10-29 16:38:00 +00:00
}
2016-02-26 00:20:09 +00:00
}
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$sourceArray
)
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$targetArray
))
2016-02-26 00:20:09 +00:00
{
// add to query
2020-03-28 13:34:14 +00:00
$query -> select (
$this -> db -> quoteName (
$sourceArray , $targetArray
)
);
2016-02-26 00:20:09 +00:00
}
}
}
}
2018-10-29 16:38:00 +00:00
$counter ++ ;
}
else
{
// see where
// var_dump($view);
// jexit();
2016-02-26 00:20:09 +00:00
}
}
2018-10-29 16:38:00 +00:00
// check if we should run query
if ( $runQuery )
2016-02-26 00:20:09 +00:00
{
2018-10-29 16:38:00 +00:00
// now get the data
$this -> db -> setQuery ( $query );
$this -> db -> execute ();
if ( $this -> db -> getNumRows ())
2016-02-26 00:20:09 +00:00
{
2018-10-29 16:38:00 +00:00
// get the data
$data = $this -> db -> loadObjectList ();
// start building the MySql dump
$dump = " -- " ;
2020-03-28 13:34:14 +00:00
$dump .= PHP_EOL . " -- Dumping data for table `#__ "
2022-08-30 15:28:41 +00:00
. Placefix :: _ ( " component " ) . " _ " . $view
2020-03-28 13:34:14 +00:00
. " ` " ;
2018-10-29 16:38:00 +00:00
$dump .= PHP_EOL . " -- " ;
2022-08-30 15:28:41 +00:00
$dump .= PHP_EOL . PHP_EOL . " INSERT INTO `#__ " . Placefix :: _ ( " component " ) . " _ " . $view . " ` ( " ;
2018-10-29 16:38:00 +00:00
foreach ( $data as $line )
2016-02-26 00:20:09 +00:00
{
2018-10-29 16:38:00 +00:00
$comaSet = 0 ;
foreach ( $line as $fieldName => $fieldValue )
2016-02-26 00:20:09 +00:00
{
2018-10-29 16:38:00 +00:00
if ( $comaSet == 0 )
{
$dump .= $this -> db -> quoteName ( $fieldName );
}
else
{
2020-03-28 13:34:14 +00:00
$dump .= " , " . $this -> db -> quoteName (
$fieldName
);
2018-10-29 16:38:00 +00:00
}
$comaSet ++ ;
2016-02-26 00:20:09 +00:00
}
2018-10-29 16:38:00 +00:00
break ;
2016-02-26 00:20:09 +00:00
}
2018-10-29 16:38:00 +00:00
$dump .= " ) VALUES " ;
$coma = 0 ;
foreach ( $data as $line )
2016-02-26 00:20:09 +00:00
{
2018-10-29 16:38:00 +00:00
if ( $coma == 0 )
2016-02-26 00:20:09 +00:00
{
2018-10-29 16:38:00 +00:00
$dump .= PHP_EOL . " ( " ;
2016-02-26 00:20:09 +00:00
}
else
{
2018-10-29 16:38:00 +00:00
$dump .= " , " . PHP_EOL . " ( " ;
}
$comaSet = 0 ;
foreach ( $line as $fieldName => $fieldValue )
{
if ( $comaSet == 0 )
{
$dump .= $this -> mysql_escape ( $fieldValue );
}
else
{
2020-03-28 13:34:14 +00:00
$dump .= " , " . $this -> mysql_escape (
$fieldValue
);
2018-10-29 16:38:00 +00:00
}
$comaSet ++ ;
2016-02-26 00:20:09 +00:00
}
2018-10-29 16:38:00 +00:00
$dump .= " ) " ;
$coma ++ ;
2016-02-26 00:20:09 +00:00
}
2018-10-29 16:38:00 +00:00
$dump .= " ; " ;
2020-03-28 13:34:14 +00:00
2018-10-29 16:38:00 +00:00
// return build dump query
return $dump ;
2016-02-26 00:20:09 +00:00
}
}
}
2020-03-28 13:34:14 +00:00
2016-02-26 00:20:09 +00:00
return false ;
}
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* Escape the values for a SQL dump
2020-03-28 13:34:14 +00:00
*
* @ param string $value the value to escape
2016-02-26 00:20:09 +00:00
*
* @ return string on success with escaped string
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
*/
public function mysql_escape ( $value )
{
// if array then return maped
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $value ))
2016-02-26 00:20:09 +00:00
{
return array_map ( __METHOD__ , $value );
}
// if string make sure it is correctly escaped
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $value ) && ! is_numeric ( $value ))
2016-02-26 00:20:09 +00:00
{
2017-02-13 23:24:38 +00:00
return $this -> db -> quote ( $value );
2016-02-26 00:20:09 +00:00
}
// if empty value return place holder
2017-12-14 23:10:47 +00:00
if ( empty ( $value ))
2016-02-26 00:20:09 +00:00
{
return " '' " ;
}
2020-03-28 13:34:14 +00:00
2016-02-26 00:20:09 +00:00
// if not array or string then return number
return $value ;
}
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* Creating an uniqueCode
2020-03-28 13:34:14 +00:00
*
* @ param string $code The planed code
2016-02-26 00:20:09 +00:00
*
* @ return string The unique code
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
*/
public function uniqueCode ( $code )
{
2022-08-30 15:28:41 +00:00
if ( ! isset ( $this -> uniquecodes [ CFactory :: _ ( 'Config' ) -> build_target ])
2020-03-28 13:34:14 +00:00
|| ! in_array (
2022-08-30 15:28:41 +00:00
$code , $this -> uniquecodes [ CFactory :: _ ( 'Config' ) -> build_target ]
2020-03-28 13:34:14 +00:00
))
2016-02-26 00:20:09 +00:00
{
2022-08-30 15:28:41 +00:00
$this -> uniquecodes [ CFactory :: _ ( 'Config' ) -> build_target ][] = $code ;
2020-03-28 13:34:14 +00:00
2016-02-26 00:20:09 +00:00
return $code ;
}
2020-03-28 13:34:14 +00:00
2016-02-26 00:20:09 +00:00
// make sure it is unique
2017-12-14 23:10:47 +00:00
return $this -> uniqueCode ( $code . $this -> uniquekey ( 1 ));
2016-02-26 13:57:30 +00:00
}
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 13:57:30 +00:00
* Creating an unique local key
2020-03-28 13:34:14 +00:00
*
* @ param int $size The key size
2016-02-26 13:57:30 +00:00
*
* @ return string The unique localkey
2020-03-28 13:34:14 +00:00
*
2016-02-26 13:57:30 +00:00
*/
2020-03-28 13:34:14 +00:00
public function uniquekey ( $size , $random = false ,
2021-12-21 14:44:50 +00:00
$newBag = " vvvvvvvvvvvvvvvvvvv "
)
{
2016-02-26 13:57:30 +00:00
if ( $random )
{
2020-03-28 13:34:14 +00:00
$bag
= " abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ " ;
2016-02-26 13:57:30 +00:00
}
else
{
2016-11-22 17:08:17 +00:00
$bag = $newBag ;
2016-02-26 13:57:30 +00:00
}
2020-03-28 13:34:14 +00:00
$key = array ();
2016-02-26 13:57:30 +00:00
$bagsize = strlen ( $bag ) - 1 ;
for ( $i = 0 ; $i < $size ; $i ++ )
{
2020-03-28 13:34:14 +00:00
$get = rand ( 0 , $bagsize );
2016-02-26 13:57:30 +00:00
$key [] = $bag [ $get ];
}
$key = implode ( $key );
while ( in_array ( $key , $this -> uniquekeys ))
{
$key ++ ;
}
$this -> uniquekeys [] = $key ;
2020-03-28 13:34:14 +00:00
2016-02-26 13:57:30 +00:00
return $key ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* Check for footable scripts
2020-03-28 13:34:14 +00:00
*
* @ param string $content The content to check
2016-02-26 00:20:09 +00:00
*
* @ return boolean True if found
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
*/
public function getFootableScripts ( $content )
{
2017-12-14 23:10:47 +00:00
if ( strpos ( $content , 'footable' ) !== false )
2016-02-26 00:20:09 +00:00
{
return true ;
}
2020-03-28 13:34:14 +00:00
2016-02-26 00:20:09 +00:00
return false ;
}
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* Check for getModules script
2020-03-28 13:34:14 +00:00
*
* @ param string $content The content to check
2016-02-26 00:20:09 +00:00
*
* @ return boolean True if found
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
*/
public function getGetModule ( $content )
{
2017-12-14 23:10:47 +00:00
if ( strpos ( $content , 'this->getModules(' ) !== false )
2016-02-26 00:20:09 +00:00
{
return true ;
}
2020-03-28 13:34:14 +00:00
2016-02-26 00:20:09 +00:00
return false ;
}
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2017-12-03 18:09:04 +00:00
* Check for get Google Chart script
2020-03-28 13:34:14 +00:00
*
* @ param string $content The content to check
2016-02-26 00:20:09 +00:00
*
* @ return boolean True if found
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
*/
public function getGoogleChart ( $content )
{
2017-12-14 23:10:47 +00:00
if ( strpos ( $content , 'Chartbuilder(' ) !== false )
2016-02-26 00:20:09 +00:00
{
return true ;
}
2020-03-28 13:34:14 +00:00
2016-02-26 00:20:09 +00:00
return false ;
}
2017-12-14 23:10:47 +00:00
2017-02-13 23:24:38 +00:00
/**
* Set the dynamic values in strings here
2020-03-28 13:34:14 +00:00
*
* @ param string $string The content to check
* @ param int $debug The switch to debug the update
* We can now at any time debug the
* dynamic build values if it gets broken
2017-02-13 23:24:38 +00:00
*
* @ return string
2022-09-03 10:48:53 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Customcode' ) -> update ( $string , $debug );
2017-02-13 23:24:38 +00:00
*/
2018-08-02 05:36:47 +00:00
public function setDynamicValues ( $string , $debug = 0 )
2017-02-13 23:24:38 +00:00
{
2022-09-03 10:48:53 +00:00
return CFactory :: _ ( 'Customcode' ) -> update ( $string , $debug );
2017-02-13 23:24:38 +00:00
}
2018-03-18 04:52:07 +00:00
2018-01-31 13:35:54 +00:00
/**
2018-02-03 00:13:48 +00:00
* Set the external code string & load it in to string
2020-03-28 13:34:14 +00:00
*
* @ param string $string The content to check
* @ param int $debug The switch to debug the update
2018-01-31 13:35:54 +00:00
*
* @ return string
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Customcode.External' ) -> set ( $string , $debug );
2018-01-31 13:35:54 +00:00
*/
2018-08-02 05:36:47 +00:00
public function setExternalCodeString ( $string , $debug = 0 )
2018-01-31 13:35:54 +00:00
{
2022-08-30 15:28:41 +00:00
return CFactory :: _ ( 'Customcode.External' ) -> set ( $string , $debug );
2018-01-31 13:35:54 +00:00
}
2018-03-18 04:52:07 +00:00
2018-02-02 17:36:22 +00:00
/**
2018-02-03 00:13:48 +00:00
* Get the External Code / String
2020-03-28 13:34:14 +00:00
*
* @ param string $string The content to check
* @ param array $bucket The Placeholders bucket
2018-02-02 17:36:22 +00:00
*
* @ return void
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3
2018-02-02 17:36:22 +00:00
*/
2018-02-03 00:13:48 +00:00
protected function getExternalCodeString ( $target , & $bucket )
2018-02-02 17:36:22 +00:00
{
2022-08-30 15:28:41 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
2022-09-02 05:51:08 +00:00
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
2022-08-30 15:28:41 +00:00
);
$this -> app -> enqueueMessage (
2022-09-02 05:51:08 +00:00
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
2022-08-30 15:28:41 +00:00
), 'Error'
);
2018-02-02 17:36:22 +00:00
}
2018-03-18 04:52:07 +00:00
2021-12-21 14:44:50 +00:00
/**
* Cut the External Code / String
*
* @ param string $string The content to cut
* @ param string $sequence The cutting sequence
* @ param string $key The content key
*
* @ return string
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3
2021-12-21 14:44:50 +00:00
*/
protected function cutExternalCodeString ( $string , $sequence , $key )
{
2022-08-30 15:28:41 +00:00
// set notice that we could not get a valid string from the target
2021-12-21 14:44:50 +00:00
$this -> app -> enqueueMessage (
2022-09-02 05:51:08 +00:00
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
2021-12-21 14:44:50 +00:00
);
$this -> app -> enqueueMessage (
2022-09-02 05:51:08 +00:00
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
2021-12-21 14:44:50 +00:00
), 'Error'
);
return '' ;
}
2017-02-13 23:24:38 +00:00
/**
* We start set the custom code data & can load it in to string
2020-03-28 13:34:14 +00:00
*
* @ param string $string The content to check
* @ param int $debug The switch to debug the update
2017-02-13 23:24:38 +00:00
*
2018-01-31 13:35:54 +00:00
* @ return string
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Customcode' ) -> set ( $string , $debug , $not );
2017-02-13 23:24:38 +00:00
*/
2018-11-27 13:05:47 +00:00
public function setCustomCodeData ( $string , $debug = 0 , $not = null )
2017-02-13 23:24:38 +00:00
{
2022-08-30 15:28:41 +00:00
return CFactory :: _ ( 'Customcode' ) -> set ( $string , $debug , $not );
2017-02-13 23:24:38 +00:00
}
2017-12-14 23:10:47 +00:00
2017-02-13 23:24:38 +00:00
/**
* Insert the custom code into the string
2020-03-28 13:34:14 +00:00
*
* @ param string $string The content to check
* @ param int $debug The switch to debug the update
2017-02-13 23:24:38 +00:00
*
* @ return string on success
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3
2017-02-13 23:24:38 +00:00
*/
2019-01-21 22:58:22 +00:00
protected function insertCustomCode ( $ids , $string , $debug = 0 )
2017-02-13 23:24:38 +00:00
{
2022-08-30 15:28:41 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
2022-09-02 05:51:08 +00:00
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
2022-08-30 15:28:41 +00:00
);
$this -> app -> enqueueMessage (
2022-09-02 05:51:08 +00:00
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
2022-08-30 15:28:41 +00:00
), 'Error'
);
2020-03-28 13:34:14 +00:00
2022-08-30 15:28:41 +00:00
return '' ;
2017-02-13 23:24:38 +00:00
}
2017-12-14 23:10:47 +00:00
2017-02-13 23:24:38 +00:00
/**
* Insert the custom code into the string
2020-03-28 13:34:14 +00:00
*
* @ param string $string The content to check
* @ param int $debug The switch to debug the update
2017-02-13 23:24:38 +00:00
*
* @ return string on success
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3
2017-12-14 23:10:47 +00:00
*/
2018-08-02 05:36:47 +00:00
protected function buildCustomCodePlaceholders ( $item , & $code , $debug = 0 )
2017-02-13 23:24:38 +00:00
{
2022-08-30 15:28:41 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
2022-09-02 05:51:08 +00:00
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
2022-08-30 15:28:41 +00:00
);
$this -> app -> enqueueMessage (
2022-09-02 05:51:08 +00:00
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
2022-08-30 15:28:41 +00:00
), 'Error'
);
return '' ;
2017-02-13 23:24:38 +00:00
}
2017-12-14 23:10:47 +00:00
2017-02-13 23:24:38 +00:00
/**
* Set a type of placeholder with set of values
2020-03-28 13:34:14 +00:00
*
* @ param string $key The main string for placeholder key
* @ param array $values The values to add
2017-02-13 23:24:38 +00:00
*
* @ return void
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Placeholder' ) -> setType ( $key , $values );
2017-02-13 23:24:38 +00:00
*/
public function setThesePlaceHolders ( $key , $values )
{
2022-08-30 15:28:41 +00:00
// use the new container class
CFactory :: _ ( 'Placeholder' ) -> setType ( $key , $values );
2017-02-13 23:24:38 +00:00
}
2017-12-14 23:10:47 +00:00
2017-02-13 23:24:38 +00:00
/**
* Remove a type of placeholder by main string
2020-03-28 13:34:14 +00:00
*
* @ param string $like The main string for placeholder key
2017-02-13 23:24:38 +00:00
*
* @ return void
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Placeholder' ) -> clearType ( $key );
2017-02-13 23:24:38 +00:00
*/
public function clearFromPlaceHolders ( $like )
{
2022-08-30 15:28:41 +00:00
// use the new container class
CFactory :: _ ( 'Placeholder' ) -> clearType ( $like );
2017-02-13 23:24:38 +00:00
}
2017-12-14 23:10:47 +00:00
2017-02-01 13:17:04 +00:00
/**
* to unset stuff that are private or protected
2020-03-28 13:34:14 +00:00
*
2017-02-01 13:17:04 +00:00
*/
public function unsetNow ( $remove )
{
unset ( $this -> $remove );
}
2017-12-14 23:10:47 +00:00
2017-04-05 13:21:10 +00:00
/**
* Get the other languages
2020-03-28 13:34:14 +00:00
*
* @ param array $values The lang strings to get
*
2017-04-05 13:21:10 +00:00
*
* @ return void
2020-03-28 13:34:14 +00:00
*
2017-04-05 13:21:10 +00:00
*/
public function getMultiLangStrings ( $values )
{
// Create a new query object.
$query = $this -> db -> getQuery ( true );
2020-03-28 13:34:14 +00:00
$query -> from (
$this -> db -> quoteName (
'#__componentbuilder_language_translation' , 'a'
)
);
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $values ))
2017-04-05 13:21:10 +00:00
{
2020-03-28 13:34:14 +00:00
$query -> select (
$this -> db -> quoteName (
array ( 'a.id' , 'a.translation' , 'a.source' , 'a.components' ,
2021-12-21 14:44:50 +00:00
'a.modules' , 'a.plugins' , 'a.published' )
2020-03-28 13:34:14 +00:00
)
);
$query -> where (
$this -> db -> quoteName ( 'a.source' ) . ' IN (' . implode (
',' , array_map (
function ( $a ) {
return $this -> db -> quote ( $a );
}, $values
)
) . ')'
);
2017-04-05 13:21:10 +00:00
$this -> db -> setQuery ( $query );
$this -> db -> execute ();
if ( $this -> db -> getNumRows ())
{
2018-04-19 23:36:21 +00:00
return $this -> db -> loadAssocList ( 'source' );
2017-04-05 13:21:10 +00:00
}
}
2020-03-28 13:34:14 +00:00
2017-04-05 13:21:10 +00:00
return false ;
}
2017-12-14 23:10:47 +00:00
2017-04-05 13:21:10 +00:00
/**
* Set the Current language values to DB
2020-03-24 01:11:43 +00:00
*
2017-04-05 13:21:10 +00:00
*
* @ return void
2020-03-24 01:11:43 +00:00
*
2017-04-05 13:21:10 +00:00
*/
2020-03-28 13:34:14 +00:00
public function setLangPlaceholders ( $strings , int $target_id ,
2021-12-21 14:44:50 +00:00
$target = 'components'
)
{
2017-04-05 13:21:10 +00:00
$counterInsert = 0 ;
$counterUpdate = 0 ;
2020-03-28 13:34:14 +00:00
$today = JFactory :: getDate () -> toSql ();
foreach (
2022-08-30 15:28:41 +00:00
$this -> languages [ $target ][ CFactory :: _ ( 'Config' ) -> get ( 'lang_tag' , 'en-GB' )] as $area => $placeholders
2020-03-28 13:34:14 +00:00
)
2017-04-05 13:21:10 +00:00
{
foreach ( $placeholders as $placeholder => $string )
{
// to keep or remove
$remove = false ;
2020-03-24 01:11:43 +00:00
// build the translations
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $string )
2020-03-28 13:34:14 +00:00
&& isset ( $this -> multiLangString [ $string ]))
2017-04-05 13:21:10 +00:00
{
// make sure we have converted the string to array
2020-03-28 13:34:14 +00:00
if ( isset ( $this -> multiLangString [ $string ][ 'translation' ])
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check (
2020-03-28 13:34:14 +00:00
$this -> multiLangString [ $string ][ 'translation' ]
))
{
$this -> multiLangString [ $string ][ 'translation' ]
= json_decode (
$this -> multiLangString [ $string ][ 'translation' ], true
);
2017-04-05 13:21:10 +00:00
}
// if we have an array continue
2020-03-28 13:34:14 +00:00
if ( isset ( $this -> multiLangString [ $string ][ 'translation' ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$this -> multiLangString [ $string ][ 'translation' ]
))
2017-04-05 13:21:10 +00:00
{
// great lets build the multi languages strings
2020-03-28 13:34:14 +00:00
foreach (
$this -> multiLangString [ $string ][ 'translation' ] as
$translations
)
2017-04-05 13:21:10 +00:00
{
2020-03-28 13:34:14 +00:00
if ( isset ( $translations [ 'language' ])
&& isset ( $translations [ 'translation' ]))
2017-04-05 13:21:10 +00:00
{
2017-09-18 00:18:23 +00:00
// build arrays
2020-03-28 13:34:14 +00:00
if ( ! isset ( $this -> languages [ $target ][ $translations [ 'language' ]]))
2017-09-18 00:18:23 +00:00
{
2020-03-28 13:34:14 +00:00
$this -> languages [ $target ][ $translations [ 'language' ]]
= array ();
2017-09-18 00:18:23 +00:00
}
2020-03-28 13:34:14 +00:00
if ( ! isset ( $this -> languages [ $target ][ $translations [ 'language' ]][ $area ]))
2017-09-18 00:18:23 +00:00
{
2020-03-28 13:34:14 +00:00
$this -> languages [ $target ][ $translations [ 'language' ]][ $area ]
= array ();
2017-09-18 00:18:23 +00:00
}
2020-03-28 13:34:14 +00:00
$this -> languages [ $target ][ $translations [ 'language' ]][ $area ][ $placeholder ]
= $translations [ 'translation' ];
2017-04-05 13:21:10 +00:00
}
}
}
else
{
// remove this string not to be checked again
$remove = true ;
}
}
2020-03-24 01:11:43 +00:00
// do the database management
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $string )
2020-03-28 13:34:14 +00:00
&& ( $key = array_search ( $string , $strings )) !== false )
2017-04-05 13:21:10 +00:00
{
if ( isset ( $this -> multiLangString [ $string ]))
{
// update the existing placeholder in db
$id = $this -> multiLangString [ $string ][ 'id' ];
2022-03-09 23:46:45 +00:00
if ( JsonHelper :: check (
2020-03-28 13:34:14 +00:00
$this -> multiLangString [ $string ][ $target ]
))
2017-04-05 13:21:10 +00:00
{
2020-03-28 13:34:14 +00:00
$targets = ( array ) json_decode (
$this -> multiLangString [ $string ][ $target ], true
);
2020-03-24 01:11:43 +00:00
// check if we should add the target ID
if ( in_array ( $target_id , $targets ))
2017-04-05 13:21:10 +00:00
{
2020-03-28 13:34:14 +00:00
// only skip the update if the string is published and has the target ID
if ( $this -> multiLangString [ $string ][ 'published' ]
== 1 )
2017-04-07 20:33:35 +00:00
{
continue ;
}
2017-04-05 13:21:10 +00:00
}
else
{
2020-03-24 01:11:43 +00:00
$targets [] = $target_id ;
2017-04-05 13:21:10 +00:00
}
}
else
{
2020-03-24 01:11:43 +00:00
$targets = array ( $target_id );
2017-04-05 13:21:10 +00:00
}
// start the bucket for this lang
2020-03-28 13:34:14 +00:00
$this -> setUpdateExistingLangStrings (
$id , $target , $targets , 1 , $today , $counterUpdate
);
2017-04-05 13:21:10 +00:00
$counterUpdate ++ ;
2020-03-24 01:11:43 +00:00
// load to db
2017-04-05 13:21:10 +00:00
$this -> setExistingLangStrings ( 50 );
// remove string if needed
if ( $remove )
{
unset ( $this -> multiLangString [ $string ]);
}
}
else
{
// add the new lang placeholder to the db
2020-03-24 01:11:43 +00:00
if ( ! isset ( $this -> newLangStrings [ $target ]))
{
$this -> newLangStrings [ $target ] = array ();
}
2020-03-28 13:34:14 +00:00
$this -> newLangStrings [ $target ][ $counterInsert ]
= array ();
$this -> newLangStrings [ $target ][ $counterInsert ][]
= $this -> db -> quote (
json_encode ( array ( $target_id ))
); // 'target'
$this -> newLangStrings [ $target ][ $counterInsert ][]
= $this -> db -> quote (
$string
); // 'source'
$this -> newLangStrings [ $target ][ $counterInsert ][]
= $this -> db -> quote (
1
); // 'published'
$this -> newLangStrings [ $target ][ $counterInsert ][]
= $this -> db -> quote (
$today
); // 'created'
$this -> newLangStrings [ $target ][ $counterInsert ][]
= $this -> db -> quote (
( int ) $this -> user -> id
); // 'created_by'
$this -> newLangStrings [ $target ][ $counterInsert ][]
= $this -> db -> quote (
1
); // 'version'
$this -> newLangStrings [ $target ][ $counterInsert ][]
= $this -> db -> quote (
1
); // 'access'
2017-04-05 13:21:10 +00:00
$counterInsert ++ ;
2020-03-24 01:11:43 +00:00
// load to db
$this -> setNewLangStrings ( $target , 100 );
2017-04-05 13:21:10 +00:00
}
// only set the string once
unset ( $strings [ $key ]);
}
}
}
// just to make sure all is done
$this -> setExistingLangStrings ();
2020-03-24 01:11:43 +00:00
$this -> setNewLangStrings ( $target );
2017-04-05 13:21:10 +00:00
}
2017-12-14 23:10:47 +00:00
2017-04-05 13:21:10 +00:00
/**
* store the language placeholders
2020-03-24 01:11:43 +00:00
*
2020-03-28 13:34:14 +00:00
* @ param string $target The target extention type
* @ param int $when To set when to update
2017-04-05 13:21:10 +00:00
*
* @ return void
2020-03-28 13:34:14 +00:00
*
2017-04-05 13:21:10 +00:00
*/
2020-03-24 01:11:43 +00:00
protected function setNewLangStrings ( $target , $when = 1 )
2017-04-05 13:21:10 +00:00
{
2020-03-28 13:34:14 +00:00
if ( isset ( $this -> newLangStrings [ $target ])
&& count (
( array ) $this -> newLangStrings [ $target ]
) >= $when )
2017-04-05 13:21:10 +00:00
{
// Create a new query object.
2020-03-28 13:34:14 +00:00
$query = $this -> db -> getQuery ( true );
2017-04-05 13:21:10 +00:00
$continue = false ;
// Insert columns.
2020-03-28 13:34:14 +00:00
$columns = array ( $target , 'source' , 'published' , 'created' ,
2021-12-21 14:44:50 +00:00
'created_by' , 'version' , 'access' );
2017-04-05 13:21:10 +00:00
// Prepare the insert query.
2020-03-28 13:34:14 +00:00
$query -> insert (
$this -> db -> quoteName ( '#__componentbuilder_language_translation' )
);
2017-04-05 13:21:10 +00:00
$query -> columns ( $this -> db -> quoteName ( $columns ));
2020-03-24 01:11:43 +00:00
foreach ( $this -> newLangStrings [ $target ] as $values )
2017-04-05 13:21:10 +00:00
{
2019-09-05 21:12:56 +00:00
if ( count (( array ) $values ) == 7 )
2017-04-05 13:21:10 +00:00
{
$query -> values ( implode ( ',' , $values ));
$continue = true ;
}
else
{
// TODO line mismatch... should not happen
}
}
// clear the values array
2020-03-24 01:11:43 +00:00
$this -> newLangStrings [ $target ] = array ();
2017-04-05 13:21:10 +00:00
if ( ! $continue )
{
return false ; // insure we dont continue if no values were loaded
}
// Set the query using our newly populated query object and execute it.
$this -> db -> setQuery ( $query );
$this -> db -> execute ();
}
2017-12-14 23:10:47 +00:00
}
2017-04-05 13:21:10 +00:00
/**
* update the language placeholders
2020-03-28 13:34:14 +00:00
*
* @ param int $when To set when to update
2017-04-05 13:21:10 +00:00
*
* @ return void
2020-03-28 13:34:14 +00:00
*
2017-04-05 13:21:10 +00:00
*/
protected function setExistingLangStrings ( $when = 1 )
{
2019-09-05 21:12:56 +00:00
if ( count (( array ) $this -> existingLangStrings ) >= $when )
2017-04-05 13:21:10 +00:00
{
2017-12-14 23:10:47 +00:00
foreach ( $this -> existingLangStrings as $values )
2017-04-05 13:21:10 +00:00
{
// Create a new query object.
$query = $this -> db -> getQuery ( true );
// Prepare the update query.
2020-03-28 13:34:14 +00:00
$query -> update (
$this -> db -> quoteName (
'#__componentbuilder_language_translation'
)
) -> set ( $values [ 'fields' ]) -> where ( $values [ 'conditions' ]);
2017-04-05 13:21:10 +00:00
// Set the query using our newly populated query object and execute it.
$this -> db -> setQuery ( $query );
$this -> db -> execute ();
}
// clear the values array
2017-12-14 23:10:47 +00:00
$this -> existingLangStrings = array ();
2017-04-05 13:21:10 +00:00
}
2017-12-14 23:10:47 +00:00
}
2017-04-07 20:33:35 +00:00
/**
* Remove exiting language translation stings
2020-03-28 13:34:14 +00:00
*
* @ param int $id To string ID to remove
2017-04-07 20:33:35 +00:00
*
* @ return void
2020-03-28 13:34:14 +00:00
*
2017-04-07 20:33:35 +00:00
*/
protected function removeExitingLangString ( $id )
{
// Create a new query object.
$query = $this -> db -> getQuery ( true );
2017-12-14 23:10:47 +00:00
2017-04-07 20:33:35 +00:00
// delete all custom keys for user 1001.
$conditions = array (
2017-12-14 23:10:47 +00:00
$this -> db -> quoteName ( 'id' ) . ' = ' . ( int ) $id
2017-04-07 20:33:35 +00:00
);
2020-03-28 13:34:14 +00:00
$query -> delete (
$this -> db -> quoteName ( '#__componentbuilder_language_translation' )
);
2017-04-07 20:33:35 +00:00
$query -> where ( $conditions );
$this -> db -> setQuery ( $query );
$this -> db -> execute ();
}
2017-12-14 23:10:47 +00:00
2017-04-07 20:33:35 +00:00
/**
* Function to purge the unused languge strings
2020-03-28 13:34:14 +00:00
*
* @ param string $values the active strings
2017-04-07 20:33:35 +00:00
*
* @ return void
2020-03-28 13:34:14 +00:00
*
2017-04-07 20:33:35 +00:00
*/
2020-03-28 13:34:14 +00:00
public function purgeLanuageStrings ( $values , $target_id ,
2021-12-21 14:44:50 +00:00
$target = 'components'
)
{
2020-03-24 01:11:43 +00:00
// the target types are
2020-03-28 13:34:14 +00:00
$target_types = array ( 'components' => 'components' ,
'modules' => 'modules' ,
'plugins' => 'plugins' );
// make sure we only work with preset targets
if ( isset ( $target_types [ $target ]))
{
// remove the current target
unset ( $target_types [ $target ]);
// Create a new query object.
$query = $this -> db -> getQuery ( true );
$query -> from (
$this -> db -> quoteName (
'#__componentbuilder_language_translation' , 'a'
)
);
$query -> select (
$this -> db -> quoteName (
array ( 'a.id' , 'a.translation' , 'a.components' , 'a.modules' ,
2021-12-21 14:44:50 +00:00
'a.plugins' )
2020-03-28 13:34:14 +00:00
)
);
// get all string that are not linked to this component
$query -> where (
$this -> db -> quoteName ( 'a.source' ) . ' NOT IN (' . implode (
',' , array_map (
function ( $a ) {
return $this -> db -> quote ( $a );
}, $values
)
) . ')'
);
$query -> where ( $this -> db -> quoteName ( 'a.published' ) . ' = 1' );
$this -> db -> setQuery ( $query );
$this -> db -> execute ();
if ( $this -> db -> getNumRows ())
2017-04-07 20:33:35 +00:00
{
2020-03-28 13:34:14 +00:00
$counterUpdate = 0 ;
$otherStrings = $this -> db -> loadAssocList ();
$today = JFactory :: getDate () -> toSql ();
foreach ( $otherStrings as $item )
2017-04-07 20:33:35 +00:00
{
2022-03-09 23:46:45 +00:00
if ( JsonHelper :: check ( $item [ $target ]))
2017-04-07 20:33:35 +00:00
{
2020-03-28 13:34:14 +00:00
$targets = ( array ) json_decode ( $item [ $target ], true );
// if component is not found ignore this string, and do nothing
if (( $key = array_search ( $target_id , $targets ))
!== false )
2017-04-07 20:33:35 +00:00
{
2020-03-28 13:34:14 +00:00
// first remove the component from the string
unset ( $targets [ $key ]);
// check if there are more components
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $targets ))
2020-03-28 13:34:14 +00:00
{
// just update the string to unlink the current component
$this -> setUpdateExistingLangStrings (
$item [ 'id' ], $target , $targets , 1 , $today ,
$counterUpdate
);
2017-04-07 20:33:35 +00:00
2020-03-28 13:34:14 +00:00
$counterUpdate ++ ;
2017-04-07 20:33:35 +00:00
2020-03-28 13:34:14 +00:00
// load to db
$this -> setExistingLangStrings ( 50 );
}
// check if this string has been worked on or is linked to other extensions
else
2017-04-07 20:33:35 +00:00
{
2020-03-28 13:34:14 +00:00
// the action (1 = remove, 2 = archive, 0 = do nothing)
$action_with_string = 1 ;
// now check if it is linked to other extensions
foreach ( $target_types as $other_target )
2020-03-24 01:11:43 +00:00
{
2020-03-28 13:34:14 +00:00
// just one linked extension type is enough to stop the search
if ( $action_with_string
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check (
2020-03-28 13:34:14 +00:00
$item [ $other_target ]
))
2020-03-24 01:11:43 +00:00
{
2020-03-28 13:34:14 +00:00
$other_targets = ( array ) json_decode (
$item [ $other_target ], true
);
// check if linked to other extensions
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$other_targets
))
{
$action_with_string
= 0 ; // do nothing
}
2020-03-24 01:11:43 +00:00
}
}
2020-03-28 13:34:14 +00:00
// check we should just archive or remove string
if ( $action_with_string
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check (
2020-03-28 13:34:14 +00:00
$item [ 'translation' ]
))
2020-03-24 01:11:43 +00:00
{
2020-03-28 13:34:14 +00:00
$translation = json_decode (
$item [ 'translation' ], true
);
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$translation
))
{
// only archive the item and update the string to unlink the current component
$this -> setUpdateExistingLangStrings (
$item [ 'id' ], $target , $targets , 2 ,
$today , $counterUpdate
);
2017-04-07 20:33:35 +00:00
2020-03-28 13:34:14 +00:00
$counterUpdate ++ ;
2017-04-07 20:33:35 +00:00
2020-03-28 13:34:14 +00:00
// load to db
$this -> setExistingLangStrings ( 50 );
2020-03-24 01:11:43 +00:00
2020-03-28 13:34:14 +00:00
$action_with_string
= 2 ; // we archived it
}
}
// remove the string since no translation found and not linked to any other extensions
if ( $action_with_string == 1 )
{
$this -> removeExitingLangString ( $item [ 'id' ]);
2020-03-24 01:11:43 +00:00
}
2017-04-07 20:33:35 +00:00
}
}
}
}
2020-03-28 13:34:14 +00:00
// load to db
$this -> setExistingLangStrings ();
2017-04-07 20:33:35 +00:00
}
}
}
2017-12-14 23:10:47 +00:00
2017-04-07 20:33:35 +00:00
/**
* just to add lang string to the existing Lang Strings array
2020-03-28 13:34:14 +00:00
*
2017-04-07 20:33:35 +00:00
* @ return void
2020-03-28 13:34:14 +00:00
*
2017-04-07 20:33:35 +00:00
*/
2020-03-28 13:34:14 +00:00
protected function setUpdateExistingLangStrings ( $id , $target , $targets ,
2021-12-21 14:44:50 +00:00
$published , $today , $counterUpdate
)
{
2017-04-07 20:33:35 +00:00
// start the bucket for this lang
2020-03-28 13:34:14 +00:00
$this -> existingLangStrings [ $counterUpdate ] = array ();
$this -> existingLangStrings [ $counterUpdate ][ 'id' ] = ( int ) $id ;
2017-12-14 23:10:47 +00:00
$this -> existingLangStrings [ $counterUpdate ][ 'conditions' ] = array ();
2020-03-28 13:34:14 +00:00
$this -> existingLangStrings [ $counterUpdate ][ 'conditions' ][]
= $this -> db -> quoteName (
'id'
) . ' = ' . $this -> db -> quote ( $id );
$this -> existingLangStrings [ $counterUpdate ][ 'fields' ] = array ();
$this -> existingLangStrings [ $counterUpdate ][ 'fields' ][]
= $this -> db -> quoteName (
$target
) . ' = ' . $this -> db -> quote ( json_encode ( $targets ));
$this -> existingLangStrings [ $counterUpdate ][ 'fields' ][]
= $this -> db -> quoteName (
'published'
) . ' = ' . $this -> db -> quote ( $published );
$this -> existingLangStrings [ $counterUpdate ][ 'fields' ][]
= $this -> db -> quoteName (
'modified'
) . ' = ' . $this -> db -> quote ( $today );
$this -> existingLangStrings [ $counterUpdate ][ 'fields' ][]
= $this -> db -> quoteName (
'modified_by'
) . ' = ' . $this -> db -> quote (( int ) $this -> user -> id );
2017-04-05 13:21:10 +00:00
}
2017-12-14 23:10:47 +00:00
2017-02-01 13:17:04 +00:00
/**
* get the custom code from the system
2020-03-28 13:34:14 +00:00
*
2022-08-30 15:28:41 +00:00
* @ param array | null $ids The custom code ides if known
* @ param int | null $setLang The set lang switch
* @ param int $debug The switch to debug the update
*
2017-02-01 13:17:04 +00:00
* @ return void
2022-09-03 10:48:53 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Customcode' ) -> get ( $ids , $setLang , $debug );
2022-08-30 15:28:41 +00:00
*/
public function getCustomCode ( ? array $ids = null , bool $setLang = true , int $debug = 0 )
{
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> get ( $ids , $setLang , $debug );
2022-08-30 15:28:41 +00:00
}
/**
* check if we already have these ids in local memory
2020-03-28 13:34:14 +00:00
*
2022-08-30 15:28:41 +00:00
* @ return void
* @ deprecated 3.3
2017-02-01 13:17:04 +00:00
*/
2022-08-30 15:28:41 +00:00
protected function checkCustomCodeMemory ( $ids )
2017-02-01 13:17:04 +00:00
{
2022-09-02 05:51:08 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
), 'Error'
);
2017-02-01 13:17:04 +00:00
}
2017-12-14 23:10:47 +00:00
2021-12-21 14:44:50 +00:00
/**
* get all the powers linkd to this component
*
* @ return void
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Power' ) -> load ( $guids );
2021-12-21 14:44:50 +00:00
*/
2022-05-16 04:25:03 +00:00
protected function getPowers ( $guids )
2021-12-21 14:44:50 +00:00
{
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Power' ) -> load ( $guids );
2021-12-21 14:44:50 +00:00
}
/**
* get a power linkd to this component
*
* @ return mixed
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Power' ) -> get ( $guid , $build );
2021-12-21 14:44:50 +00:00
*/
2022-05-19 13:34:11 +00:00
public function getPower ( $guid , $build = 0 )
2021-12-21 14:44:50 +00:00
{
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Power' ) -> get ( $guid , $build );
2021-12-21 14:44:50 +00:00
}
/**
* set a power linkd to this component
*
* @ return bool
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3
2021-12-21 14:44:50 +00:00
*/
2022-05-16 04:25:03 +00:00
protected function setPower ( $guid )
2021-12-21 14:44:50 +00:00
{
2022-08-30 15:28:41 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
2022-09-02 05:51:08 +00:00
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
2022-08-30 15:28:41 +00:00
);
$this -> app -> enqueueMessage (
2022-09-02 05:51:08 +00:00
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
2022-08-30 15:28:41 +00:00
), 'Error'
);
2021-12-21 14:44:50 +00:00
2022-09-02 05:51:08 +00:00
return false ;
2021-12-21 14:44:50 +00:00
}
2020-03-13 02:45:08 +00:00
/**
* get the Joomla module path
*
2022-09-02 05:51:08 +00:00
* @ return string of module path and target site area on success
* @ deprecated 3.3
2020-03-13 02:45:08 +00:00
*/
protected function getModulePath ( $id )
{
2022-09-02 05:51:08 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
), 'Error'
);
2020-03-28 13:34:14 +00:00
2022-09-02 05:51:08 +00:00
return '' ;
2020-03-13 02:45:08 +00:00
}
2019-12-06 05:31:32 +00:00
/**
* get the Joomla Modules IDs
*
* @ return array of IDs on success
2022-09-02 05:51:08 +00:00
* @ deprecated 3.3
2019-12-06 05:31:32 +00:00
*/
protected function getModuleIDs ()
{
2022-09-02 05:51:08 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
), 'Error'
);
2020-03-28 13:34:14 +00:00
2022-09-02 05:51:08 +00:00
return [];
2019-12-06 05:31:32 +00:00
}
/**
* set the Joomla modules
*
* @ return true
*
*/
public function setJoomlaModule ( $id , & $component )
{
if ( isset ( $this -> joomlaModules [ $id ]))
{
return true ;
}
else
{
// Create a new query object.
$query = $this -> db -> getQuery ( true );
$query -> select ( 'a.*' );
$query -> select (
$this -> db -> quoteName (
array (
'f.addfiles' ,
'f.addfolders' ,
'f.addfilesfullpath' ,
'f.addfoldersfullpath' ,
'f.addurls' ,
'u.version_update' ,
'u.id'
), array (
'addfiles' ,
'addfolders' ,
'addfilesfullpath' ,
'addfoldersfullpath' ,
'addurls' ,
'version_update' ,
'version_update_id'
)
)
);
// from these tables
$query -> from ( '#__componentbuilder_joomla_module AS a' );
2020-03-28 13:34:14 +00:00
$query -> join (
'LEFT' , $this -> db -> quoteName (
'#__componentbuilder_joomla_module_updates' , 'u'
) . ' ON (' . $this -> db -> quoteName ( 'a.id' ) . ' = '
. $this -> db -> quoteName ( 'u.joomla_module' ) . ')'
);
$query -> join (
'LEFT' , $this -> db -> quoteName (
'#__componentbuilder_joomla_module_files_folders_urls' , 'f'
) . ' ON (' . $this -> db -> quoteName ( 'a.id' ) . ' = '
. $this -> db -> quoteName ( 'f.joomla_module' ) . ')'
);
2019-12-06 05:31:32 +00:00
$query -> where ( $this -> db -> quoteName ( 'a.id' ) . ' = ' . ( int ) $id );
$query -> where ( $this -> db -> quoteName ( 'a.published' ) . ' >= 1' );
$this -> db -> setQuery ( $query );
$this -> db -> execute ();
if ( $this -> db -> getNumRows ())
{
// get the module data
$module = $this -> db -> loadObject ();
// tweak system to set stuff to the module domain
2022-08-30 15:28:41 +00:00
$_backup_target = CFactory :: _ ( 'Config' ) -> build_target ;
$_backup_lang = CFactory :: _ ( 'Config' ) -> lang_target ;
$_backup_langPrefix = CFactory :: _ ( 'Config' ) -> lang_prefix ;
2019-12-06 05:31:32 +00:00
// set some keys
$module -> target_type = 'M0dU|3' ;
2020-03-28 13:34:14 +00:00
$module -> key = $module -> id . '_' . $module -> target_type ;
2019-12-06 05:31:32 +00:00
// update to point to module
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> build_target = $module -> key ;
CFactory :: _ ( 'Config' ) -> lang_target = $module -> key ;
2019-12-06 05:31:32 +00:00
// set version if not set
if ( empty ( $module -> module_version ))
{
$module -> module_version = '1.0.0' ;
}
2020-03-13 02:45:08 +00:00
// set target client
if ( $module -> target == 2 )
{
2020-04-23 21:19:14 +00:00
$module -> target_client = 'administrator' ;
2020-03-13 02:45:08 +00:00
}
else
{
// default is site area
$module -> target_client = 'site' ;
}
2019-12-06 05:31:32 +00:00
// set GUI mapper
2020-03-28 13:34:14 +00:00
$guiMapper = array ( 'table' => 'joomla_module' ,
'id' => ( int ) $id , 'type' => 'php' );
2019-12-06 05:31:32 +00:00
// update the name if it has dynamic values
2022-08-30 15:28:41 +00:00
$module -> name = CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update ( $module -> name ), CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
);
2020-03-13 02:45:08 +00:00
// set safe class function name
2020-03-28 13:34:14 +00:00
$module -> code_name
2022-03-09 23:46:45 +00:00
= ClassfunctionHelper :: safe (
2020-03-28 13:34:14 +00:00
$module -> name
);
2022-08-21 17:21:03 +00:00
// alias of code name
$module -> class_name = $module -> code_name ;
2019-12-06 05:31:32 +00:00
// set official name
2022-03-09 23:46:45 +00:00
$module -> official_name = StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$module -> name , 'W'
);
2019-12-06 05:31:32 +00:00
// set langPrefix
$this -> langPrefix = 'MOD_' . strtoupper ( $module -> code_name );
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> set ( 'lang_prefix' , $this -> langPrefix );
2019-12-06 05:31:32 +00:00
// set lang prefix
2022-08-30 15:28:41 +00:00
$module -> lang_prefix = CFactory :: _ ( 'Config' ) -> lang_prefix ;
2019-12-06 05:31:32 +00:00
// set module class name
2020-03-28 13:34:14 +00:00
$module -> class_helper_name = 'Mod' . ucfirst ( $module -> code_name )
. 'Helper' ;
$module -> class_data_name = 'Mod' . ucfirst ( $module -> code_name )
. 'Data' ;
// set module install class name
$module -> installer_class_name = 'mod_' . ucfirst (
$module -> code_name
) . 'InstallerScript' ;
2019-12-06 05:31:32 +00:00
// set module folder name
$module -> folder_name = 'mod_' . strtolower ( $module -> code_name );
// set the zip name
2020-03-28 13:34:14 +00:00
$module -> zip_name = $module -> folder_name . '_v' . str_replace (
'.' , '_' , $module -> module_version
2022-08-30 15:28:41 +00:00
) . '__J' . CFactory :: _ ( 'Config' ) -> joomla_version ;
2019-12-06 05:31:32 +00:00
// set module file name
$module -> file_name = $module -> folder_name ;
2020-03-28 13:34:14 +00:00
// set module context
$module -> context = $module -> file_name . '.' . $module -> id ;
2019-12-06 05:31:32 +00:00
// set official_name lang strings
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
$module -> key , CFactory :: _ ( 'Config' ) -> lang_prefix , $module -> official_name
2020-03-28 13:34:14 +00:00
);
2019-12-06 05:31:32 +00:00
// set some placeholder for this module
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'Module_name' )]
2020-03-28 13:34:14 +00:00
= $module -> official_name ;
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'Module' )]
2020-03-28 13:34:14 +00:00
= ucfirst (
$module -> code_name
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'module' )]
2020-03-28 13:34:14 +00:00
= strtolower (
$module -> code_name
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'module.version' )]
2020-03-28 13:34:14 +00:00
= $module -> module_version ;
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'module_version' )]
2020-03-28 13:34:14 +00:00
= str_replace (
'.' , '_' , $module -> module_version
);
2019-12-06 05:31:32 +00:00
// set description (TODO) add description field to module
2020-03-28 13:34:14 +00:00
if ( ! isset ( $module -> description )
2022-03-09 23:46:45 +00:00
|| ! StringHelper :: check (
2020-03-28 13:34:14 +00:00
$module -> description
))
2019-12-06 05:31:32 +00:00
{
$module -> description = '' ;
}
else
{
2022-08-30 15:28:41 +00:00
$module -> description = CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update ( $module -> description ),
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
2020-03-28 13:34:14 +00:00
$module -> key , $module -> lang_prefix . '_DESCRIPTION' ,
$module -> description
);
$module -> description = '<p>' . $module -> description
. '</p>' ;
}
$module -> xml_description = " <h1> " . $module -> official_name
. " (v. " . $module -> module_version
. " )</h1> <div style='clear: both;'></div> "
. $module -> description . " <p>Created by <a href=' " . trim (
$component -> website
) . " ' target='_blank'> " . trim (
JFilterOutput :: cleanText ( $component -> author )
) . " </a><br /><small>Development started "
. JFactory :: getDate ( $module -> created ) -> format ( " jS F, Y " )
. " </small></p> " ;
2019-12-06 05:31:32 +00:00
// set xml description
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
2020-03-28 13:34:14 +00:00
$module -> key , $module -> lang_prefix . '_XML_DESCRIPTION' ,
$module -> xml_description
);
2019-12-06 05:31:32 +00:00
// update the readme if set
if ( $module -> addreadme == 1 && ! empty ( $module -> readme ))
{
2022-08-30 15:28:41 +00:00
$module -> readme = CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update ( base64_decode ( $module -> readme )),
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
);
2019-12-06 05:31:32 +00:00
}
else
{
$module -> addreadme = 0 ;
unset ( $module -> readme );
}
// get the custom_get
2020-03-28 13:34:14 +00:00
$module -> custom_get = ( isset ( $module -> custom_get )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $module -> custom_get ))
2020-03-28 13:34:14 +00:00
? json_decode ( $module -> custom_get , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $module -> custom_get ))
2019-12-06 05:31:32 +00:00
{
2020-03-28 13:34:14 +00:00
$module -> custom_get = $this -> setGetData (
$module -> custom_get , $module -> key , $module -> key
);
2019-12-06 05:31:32 +00:00
}
else
{
$module -> custom_get = false ;
}
// set helper class details
2020-03-28 13:34:14 +00:00
if ( $module -> add_class_helper >= 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$module -> class_helper_code
))
2019-12-06 05:31:32 +00:00
{
2020-03-28 13:34:14 +00:00
if ( $module -> add_class_helper_header == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$module -> class_helper_header
))
2019-12-06 05:31:32 +00:00
{
// set GUI mapper field
$guiMapper [ 'field' ] = 'class_helper_header' ;
// base64 Decode code
2020-03-28 13:34:14 +00:00
$module -> class_helper_header = PHP_EOL
2022-08-30 15:28:41 +00:00
. CFactory :: _ ( 'Customcode.Gui' ) -> set (
CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode (
$module -> class_helper_header
)
2022-08-30 15:28:41 +00:00
), CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
),
$guiMapper
) . PHP_EOL ;
2019-12-06 05:31:32 +00:00
}
else
{
$module -> add_class_helper_header = 0 ;
2020-03-28 13:34:14 +00:00
$module -> class_helper_header = '' ;
2019-12-06 05:31:32 +00:00
}
// set GUI mapper field
$guiMapper [ 'field' ] = 'class_helper_code' ;
// base64 Decode code
2022-08-30 15:28:41 +00:00
$module -> class_helper_code = CFactory :: _ ( 'Customcode.Gui' ) -> set (
CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $module -> class_helper_code )
2022-08-30 15:28:41 +00:00
), CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
),
2019-12-06 05:31:32 +00:00
$guiMapper
);
// set class type
if ( $module -> add_class_helper == 2 )
{
$module -> class_helper_type = 'abstract class ' ;
}
else
{
$module -> class_helper_type = 'class ' ;
}
}
else
{
2020-03-28 13:34:14 +00:00
$module -> add_class_helper = 0 ;
$module -> class_helper_code = '' ;
2019-12-06 05:31:32 +00:00
$module -> class_helper_header = '' ;
}
// base64 Decode mod_code
2020-03-28 13:34:14 +00:00
if ( isset ( $module -> mod_code )
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $module -> mod_code ))
2019-12-06 05:31:32 +00:00
{
// set GUI mapper field
$guiMapper [ 'field' ] = 'mod_code' ;
2022-08-30 15:28:41 +00:00
$module -> mod_code = CFactory :: _ ( 'Customcode.Gui' ) -> set (
CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $module -> mod_code )
2022-08-30 15:28:41 +00:00
), CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
),
2019-12-06 05:31:32 +00:00
$guiMapper
);
}
else
{
$module -> mod_code = " // get the module class sfx " ;
2020-03-28 13:34:14 +00:00
$module -> mod_code .= PHP_EOL
. " \$ moduleclass_sfx = htmlspecialchars( \$ params->get('moduleclass_sfx'), ENT_COMPAT, 'UTF-8'); " ;
2019-12-06 05:31:32 +00:00
$module -> mod_code .= PHP_EOL . " // load the default Tmpl " ;
2020-03-28 13:34:14 +00:00
$module -> mod_code .= PHP_EOL
. " require JModuleHelper::getLayoutPath('mod_ "
. strtolower ( $module -> code_name )
. " ', \$ params->get('layout', 'default')); " ;
2019-12-06 05:31:32 +00:00
}
// base64 Decode default header
2020-03-28 13:34:14 +00:00
if ( isset ( $module -> default_header )
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$module -> default_header
))
2019-12-06 05:31:32 +00:00
{
// set GUI mapper field
2020-03-28 13:34:14 +00:00
$guiMapper [ 'field' ] = 'default_header' ;
2022-08-30 15:28:41 +00:00
$module -> default_header = CFactory :: _ ( 'Customcode.Gui' ) -> set (
CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $module -> default_header )
2022-08-30 15:28:41 +00:00
), CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
),
2019-12-06 05:31:32 +00:00
$guiMapper
);
}
else
{
$module -> default_header = '' ;
}
// base64 Decode default
2020-03-28 13:34:14 +00:00
if ( isset ( $module -> default )
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $module -> default ))
2019-12-06 05:31:32 +00:00
{
// set GUI mapper field
$guiMapper [ 'field' ] = 'default' ;
2020-03-28 13:34:14 +00:00
$guiMapper [ 'type' ] = 'html' ;
2022-08-30 15:28:41 +00:00
$module -> default = CFactory :: _ ( 'Customcode.Gui' ) -> set (
CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $module -> default )
2022-08-30 15:28:41 +00:00
), CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
),
2019-12-06 05:31:32 +00:00
$guiMapper
);
}
else
{
$module -> default = '<h1>No Tmpl set</h1>' ;
}
// start the config array
$module -> config_fields = array ();
// create the form arrays
2020-03-28 13:34:14 +00:00
$module -> form_files = array ();
2019-12-06 05:31:32 +00:00
$module -> fieldsets_label = array ();
$module -> fieldsets_paths = array ();
2022-02-04 10:50:24 +00:00
$module -> add_rule_path = array ();
$module -> add_field_path = array ();
2019-12-06 05:31:32 +00:00
// set global fields rule to default component path
$module -> fields_rules_paths = 1 ;
// set the fields data
2020-03-28 13:34:14 +00:00
$module -> fields = ( isset ( $module -> fields )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $module -> fields ))
2020-03-28 13:34:14 +00:00
? json_decode ( $module -> fields , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $module -> fields ))
2019-12-06 05:31:32 +00:00
{
// ket global key
2020-03-28 13:34:14 +00:00
$key = $module -> key ;
$dynamic_fields = array ( 'fieldset' => 'basic' ,
'fields_name' => 'params' ,
'file' => 'config' );
2019-12-06 05:31:32 +00:00
foreach ( $module -> fields as $n => & $form )
{
2020-03-28 13:34:14 +00:00
if ( isset ( $form [ 'fields' ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$form [ 'fields' ]
))
2019-12-06 05:31:32 +00:00
{
// make sure the dynamic_field is set to dynamic_value by default
2020-03-28 13:34:14 +00:00
foreach (
$dynamic_fields as $dynamic_field =>
$dynamic_value
)
2019-12-06 05:31:32 +00:00
{
2020-03-28 13:34:14 +00:00
if ( ! isset ( $form [ $dynamic_field ])
2022-03-09 23:46:45 +00:00
|| ! StringHelper :: check (
2020-03-28 13:34:14 +00:00
$form [ $dynamic_field ]
))
2019-12-06 05:31:32 +00:00
{
$form [ $dynamic_field ] = $dynamic_value ;
}
else
{
2020-03-28 13:34:14 +00:00
if ( 'fields_name' === $dynamic_field
&& strpos ( $form [ $dynamic_field ], '.' )
!== false )
2019-12-06 05:31:32 +00:00
{
2020-03-28 13:34:14 +00:00
$form [ $dynamic_field ]
= $form [ $dynamic_field ];
2019-12-06 05:31:32 +00:00
}
else
{
2020-03-28 13:34:14 +00:00
$form [ $dynamic_field ]
2022-03-09 23:46:45 +00:00
= StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$form [ $dynamic_field ]
);
2019-12-06 05:31:32 +00:00
}
}
}
// check if field is external form file
if ( ! isset ( $form [ 'module' ]) || $form [ 'module' ] != 1 )
{
// now build the form key
2020-03-28 13:34:14 +00:00
$unique = $form [ 'file' ] . $form [ 'fields_name' ]
. $form [ 'fieldset' ];
2019-12-06 05:31:32 +00:00
}
else
{
// now build the form key
2020-03-28 13:34:14 +00:00
$unique = $form [ 'fields_name' ]
. $form [ 'fieldset' ];
2019-12-06 05:31:32 +00:00
}
2020-12-05 06:17:54 +00:00
// set global fields rule path switches
2020-03-28 13:34:14 +00:00
if ( $module -> fields_rules_paths == 1
&& isset ( $form [ 'fields_rules_paths' ])
&& $form [ 'fields_rules_paths' ] == 2 )
2019-12-06 05:31:32 +00:00
{
$module -> fields_rules_paths = 2 ;
}
// set where to path is pointing
2020-03-28 13:34:14 +00:00
$module -> fieldsets_paths [ $unique ]
= $form [ 'fields_rules_paths' ];
2022-02-04 10:50:24 +00:00
// check for extra rule paths
if ( isset ( $form [ 'addrulepath' ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check ( $form [ 'addrulepath' ]))
2022-02-04 10:50:24 +00:00
{
foreach ( $form [ 'addrulepath' ] as $add_rule_path )
{
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $add_rule_path [ 'path' ]))
2022-02-04 10:50:24 +00:00
{
2022-02-04 17:21:10 +00:00
$module -> add_rule_path [ $unique ] = $add_rule_path [ 'path' ];
2022-02-04 10:50:24 +00:00
}
}
}
// check for extra field paths
if ( isset ( $form [ 'addfieldpath' ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check ( $form [ 'addfieldpath' ]))
2022-02-04 10:50:24 +00:00
{
foreach ( $form [ 'addfieldpath' ] as $add_field_path )
{
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $add_field_path [ 'path' ]))
2022-02-04 10:50:24 +00:00
{
2022-02-04 17:21:10 +00:00
$module -> add_field_path [ $unique ] = $add_field_path [ 'path' ];
2022-02-04 10:50:24 +00:00
}
}
}
2019-12-06 05:31:32 +00:00
// add the label if set to lang
2020-03-28 13:34:14 +00:00
if ( isset ( $form [ 'label' ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$form [ 'label' ]
))
2019-12-06 05:31:32 +00:00
{
2020-03-28 13:34:14 +00:00
$module -> fieldsets_label [ $unique ]
2022-08-30 15:28:41 +00:00
= CFactory :: _ ( 'Language' ) -> key ( $form [ 'label' ]);
2019-12-06 05:31:32 +00:00
}
// build the fields
2020-03-28 13:34:14 +00:00
$form [ 'fields' ] = array_map (
function ( $field ) use ( $key , $unique ) {
// make sure the alias and title is 0
$field [ 'alias' ] = 0 ;
$field [ 'title' ] = 0 ;
// set the field details
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Field' ) -> set (
2020-03-28 13:34:14 +00:00
$field , $key , $key , $unique
);
// update the default if set
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check (
2020-03-28 13:34:14 +00:00
$field [ 'custom_value' ]
)
&& isset ( $field [ 'settings' ]))
2019-12-06 05:31:32 +00:00
{
2020-03-28 13:34:14 +00:00
if (( $old_default
2022-04-04 15:35:08 +00:00
= GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml ,
'default="' , '"' , false
)) !== false )
{
// replace old default
$field [ 'settings' ] -> xml
= str_replace (
'default="' . $old_default
. '"' , 'default="'
. $field [ 'custom_value' ] . '"' ,
$field [ 'settings' ] -> xml
);
}
else
{
// add the default (hmmm not ideal but okay it should work)
$field [ 'settings' ] -> xml
= 'default="'
. $field [ 'custom_value' ] . '" '
. $field [ 'settings' ] -> xml ;
}
2019-12-06 05:31:32 +00:00
}
2020-03-28 13:34:14 +00:00
unset ( $field [ 'custom_value' ]);
// return field
return $field ;
}, array_values ( $form [ 'fields' ])
);
2019-12-06 05:31:32 +00:00
// check if field is external form file
if ( ! isset ( $form [ 'module' ]) || $form [ 'module' ] != 1 )
{
// load the form file
if ( ! isset ( $module -> form_files [ $form [ 'file' ]]))
{
2020-03-28 13:34:14 +00:00
$module -> form_files [ $form [ 'file' ]]
= array ();
2019-12-06 05:31:32 +00:00
}
if ( ! isset ( $module -> form_files [ $form [ 'file' ]][ $form [ 'fields_name' ]]))
{
2020-03-28 13:34:14 +00:00
$module -> form_files [ $form [ 'file' ]][ $form [ 'fields_name' ]]
= array ();
2019-12-06 05:31:32 +00:00
}
if ( ! isset ( $module -> form_files [ $form [ 'file' ]][ $form [ 'fields_name' ]][ $form [ 'fieldset' ]]))
{
2020-03-28 13:34:14 +00:00
$module -> form_files [ $form [ 'file' ]][ $form [ 'fields_name' ]][ $form [ 'fieldset' ]]
= array ();
2019-12-06 05:31:32 +00:00
}
// do some house cleaning (for fields)
foreach ( $form [ 'fields' ] as $field )
{
// so first we lock the field name in
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Field.Name' ) -> get (
2020-03-28 13:34:14 +00:00
$field , $module -> key , $unique
);
2019-12-06 05:31:32 +00:00
// add the fields to the global form file builder
2020-03-28 13:34:14 +00:00
$module -> form_files [ $form [ 'file' ]][ $form [ 'fields_name' ]][ $form [ 'fieldset' ]][]
= $field ;
2019-12-06 05:31:32 +00:00
}
// remove form
unset ( $module -> fields [ $n ]);
}
else
{
// load the config form
if ( ! isset ( $module -> config_fields [ $form [ 'fields_name' ]]))
{
2020-03-28 13:34:14 +00:00
$module -> config_fields [ $form [ 'fields_name' ]]
= array ();
2019-12-06 05:31:32 +00:00
}
if ( ! isset ( $module -> config_fields [ $form [ 'fields_name' ]][ $form [ 'fieldset' ]]))
{
2020-03-28 13:34:14 +00:00
$module -> config_fields [ $form [ 'fields_name' ]][ $form [ 'fieldset' ]]
= array ();
2019-12-06 05:31:32 +00:00
}
// do some house cleaning (for fields)
foreach ( $form [ 'fields' ] as $field )
{
// so first we lock the field name in
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Field.Name' ) -> get (
2020-03-28 13:34:14 +00:00
$field , $module -> key , $unique
);
2019-12-06 05:31:32 +00:00
// add the fields to the config builder
2020-03-28 13:34:14 +00:00
$module -> config_fields [ $form [ 'fields_name' ]][ $form [ 'fieldset' ]][]
= $field ;
2019-12-06 05:31:32 +00:00
}
// remove form
unset ( $module -> fields [ $n ]);
}
}
else
{
unset ( $module -> fields [ $n ]);
}
}
}
unset ( $module -> fields );
// set the add targets
2020-03-28 13:34:14 +00:00
$addArray = array ( 'files' => 'files' ,
'folders' => 'folders' ,
'urls' => 'urls' ,
'filesfullpath' => 'files' ,
'foldersfullpath' => 'folders' );
2019-12-06 05:31:32 +00:00
foreach ( $addArray as $addTarget => $targetHere )
{
// set the add target data
2020-03-28 13:34:14 +00:00
$module -> { 'add' . $addTarget } = ( isset (
$module -> { 'add' . $addTarget }
)
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check (
2020-03-28 13:34:14 +00:00
$module -> { 'add' . $addTarget }
)) ? json_decode ( $module -> { 'add' . $addTarget }, true )
: null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$module -> { 'add' . $addTarget }
))
{
if ( isset ( $module -> { $targetHere })
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$module -> { $targetHere }
))
2019-12-06 05:31:32 +00:00
{
foreach ( $module -> { 'add' . $addTarget } as $taget )
{
$module -> { $targetHere }[] = $taget ;
}
}
else
{
2020-03-28 13:34:14 +00:00
$module -> { $targetHere } = array_values (
$module -> { 'add' . $addTarget }
);
2019-12-06 05:31:32 +00:00
}
}
unset ( $module -> { 'add' . $addTarget });
}
// load the library
2022-08-30 15:28:41 +00:00
if ( ! isset ( $this -> libManager [ CFactory :: _ ( 'Config' ) -> build_target ]))
2019-12-06 05:31:32 +00:00
{
2022-08-30 15:28:41 +00:00
$this -> libManager [ CFactory :: _ ( 'Config' ) -> build_target ] = array ();
2019-12-06 05:31:32 +00:00
}
2022-08-30 15:28:41 +00:00
if ( ! isset ( $this -> libManager [ CFactory :: _ ( 'Config' ) -> build_target ][ $module -> code_name ]))
2019-12-06 05:31:32 +00:00
{
2022-08-30 15:28:41 +00:00
$this -> libManager [ CFactory :: _ ( 'Config' ) -> build_target ][ $module -> code_name ]
2020-03-28 13:34:14 +00:00
= array ();
2019-12-06 05:31:32 +00:00
}
// make sure json become array
2022-03-09 23:46:45 +00:00
if ( JsonHelper :: check ( $module -> libraries ))
2019-12-06 05:31:32 +00:00
{
$module -> libraries = json_decode ( $module -> libraries , true );
}
// if we have an array add it
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $module -> libraries ))
2019-12-06 05:31:32 +00:00
{
foreach ( $module -> libraries as $library )
{
2022-08-30 15:28:41 +00:00
if ( ! isset ( $this -> libManager [ CFactory :: _ ( 'Config' ) -> build_target ][ $module -> code_name ][ $library ]))
2019-12-06 05:31:32 +00:00
{
if ( $this -> getMediaLibrary (( int ) $library ))
{
2022-08-30 15:28:41 +00:00
$this -> libManager [ CFactory :: _ ( 'Config' ) -> build_target ][ $module -> code_name ][( int ) $library ]
2020-03-28 13:34:14 +00:00
= true ;
2019-12-06 05:31:32 +00:00
}
}
}
}
2020-03-28 13:34:14 +00:00
elseif ( is_numeric ( $module -> libraries )
2022-08-30 15:28:41 +00:00
&& ! isset ( $this -> libManager [ CFactory :: _ ( 'Config' ) -> build_target ][ $module -> code_name ][( int ) $module -> libraries ]))
2019-12-06 05:31:32 +00:00
{
if ( $this -> getMediaLibrary (( int ) $module -> libraries ))
{
2022-08-30 15:28:41 +00:00
$this -> libManager [ CFactory :: _ ( 'Config' ) -> build_target ][ $module -> code_name ][( int ) $module -> libraries ]
2020-03-28 13:34:14 +00:00
= true ;
2019-12-06 05:31:32 +00:00
}
}
// add PHP in module install
$module -> add_install_script = false ;
2020-03-28 13:34:14 +00:00
$addScriptMethods = array ( 'php_preflight' ,
2021-12-21 14:44:50 +00:00
'php_postflight' ,
'php_method' );
2020-03-28 13:34:14 +00:00
$addScriptTypes = array ( 'install' , 'update' ,
2021-12-21 14:44:50 +00:00
'uninstall' );
2020-07-07 19:42:43 +00:00
// the next are php placeholders
2020-11-29 00:00:20 +00:00
$guiMapper [ 'type' ] = 'php' ;
2019-12-06 05:31:32 +00:00
foreach ( $addScriptMethods as $scriptMethod )
{
foreach ( $addScriptTypes as $scriptType )
{
2020-03-28 13:34:14 +00:00
if ( isset (
$module -> { 'add_' . $scriptMethod . '_'
. $scriptType }
)
&& $module -> { 'add_' . $scriptMethod . '_'
. $scriptType } == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$module -> { $scriptMethod . '_' . $scriptType }
))
2019-12-06 05:31:32 +00:00
{
// set GUI mapper field
2020-03-28 13:34:14 +00:00
$guiMapper [ 'field' ] = $scriptMethod . '_'
. $scriptType ;
$module -> { $scriptMethod . '_' . $scriptType }
2022-08-30 15:28:41 +00:00
= CFactory :: _ ( 'Customcode.Gui' ) -> set (
CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode (
$module -> { $scriptMethod . '_'
. $scriptType }
)
2022-08-30 15:28:41 +00:00
), CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
),
2019-12-06 05:31:32 +00:00
$guiMapper
);
$module -> add_install_script = true ;
}
else
{
unset ( $module -> { $scriptMethod . '_' . $scriptType });
2020-03-28 13:34:14 +00:00
$module -> { 'add_' . $scriptMethod . '_'
. $scriptType }
= 0 ;
2019-12-06 05:31:32 +00:00
}
}
}
// add_sql
2020-03-28 13:34:14 +00:00
if ( $module -> add_sql == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $module -> sql ))
2019-12-06 05:31:32 +00:00
{
2022-08-30 15:28:41 +00:00
$module -> sql = CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update ( base64_decode ( $module -> sql )),
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
);
2019-12-06 05:31:32 +00:00
}
else
{
unset ( $module -> sql );
$module -> add_sql = 0 ;
}
// add_sql_uninstall
2020-03-28 13:34:14 +00:00
if ( $module -> add_sql_uninstall == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$module -> sql_uninstall
))
{
2022-08-30 15:28:41 +00:00
$module -> sql_uninstall = CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $module -> sql_uninstall )
2022-08-30 15:28:41 +00:00
), CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
);
2019-12-06 05:31:32 +00:00
}
else
{
unset ( $module -> sql_uninstall );
$module -> add_sql_uninstall = 0 ;
}
// update the URL of the update_server if set
2020-03-28 13:34:14 +00:00
if ( $module -> add_update_server == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$module -> update_server_url
))
{
2022-08-30 15:28:41 +00:00
$module -> update_server_url = CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update ( $module -> update_server_url ),
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
);
2019-12-06 05:31:32 +00:00
}
// add the update/sales server FTP details if that is the expected protocol
$serverArray = array ( 'update_server' , 'sales_server' );
foreach ( $serverArray as $server )
{
2020-03-28 13:34:14 +00:00
if ( $module -> { 'add_' . $server } == 1
&& is_numeric (
$module -> { $server }
)
&& $module -> { $server } > 0 )
2019-12-06 05:31:32 +00:00
{
// get the server protocol
2020-03-28 13:34:14 +00:00
$module -> { $server . '_protocol' }
2022-03-09 23:46:45 +00:00
= GetHelper :: var (
2020-03-28 13:34:14 +00:00
'server' , ( int ) $module -> { $server }, 'id' , 'protocol'
);
2019-12-06 05:31:32 +00:00
}
else
{
$module -> { $server } = 0 ;
// only change this for sales server (update server can be added loacaly to the zip file)
if ( 'sales_server' === $server )
{
$module -> { 'add_' . $server } = 0 ;
}
$module -> { $server . '_protocol' } = 0 ;
}
}
// set the update server stuff (TODO)
// update_server_xml_path
// update_server_xml_file_name
// rest globals
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> build_target = $_backup_target ;
CFactory :: _ ( 'Config' ) -> lang_target = $_backup_lang ;
2019-12-06 05:31:32 +00:00
$this -> langPrefix = $_backup_langPrefix ;
2022-09-14 15:40:02 +00:00
CFactory :: _ ( 'Config' ) -> lang_prefix = $_backup_langPrefix ;
2019-12-06 05:31:32 +00:00
2020-03-28 13:34:14 +00:00
unset (
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'Module_name' )]
2020-03-28 13:34:14 +00:00
);
2022-08-30 15:28:41 +00:00
unset ( CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'Module' )]);
unset ( CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'module' )]);
2020-03-28 13:34:14 +00:00
unset (
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'module.version' )]
2020-03-28 13:34:14 +00:00
);
unset (
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'module_version' )]
2020-03-28 13:34:14 +00:00
);
2019-12-06 05:31:32 +00:00
$this -> joomlaModules [ $id ] = $module ;
return true ;
}
}
2020-03-28 13:34:14 +00:00
2019-12-06 05:31:32 +00:00
return false ;
}
/**
* get the module xml template
*
* @ return string
*
*/
public function getModuleXMLTemplate ( & $module )
{
$xml = '<?xml version="1.0" encoding="utf-8"?>' ;
2021-12-21 14:44:50 +00:00
$xml .= PHP_EOL . '<extension type="module" version="'
2022-08-30 15:28:41 +00:00
. $this -> joomlaVersions [ CFactory :: _ ( 'Config' ) -> joomla_version ][ 'xml_version' ] . '" client="'
2020-03-28 13:34:14 +00:00
. $module -> target_client . '" method="upgrade">' ;
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<name>' . $module -> lang_prefix
2020-03-28 13:34:14 +00:00
. '</name>' ;
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<creationDate>' . Placefix :: _h ( 'BUILDDATE' ) . '</creationDate>' ;
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<author>' . Placefix :: _h ( 'AUTHOR' ) . '</author>' ;
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<authorEmail>' . Placefix :: _h ( 'AUTHOREMAIL' ) . '</authorEmail>' ;
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<authorUrl>' . Placefix :: _h ( 'AUTHORWEBSITE' ) . '</authorUrl>' ;
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<copyright>' . Placefix :: _h ( 'COPYRIGHT' ) . '</copyright>' ;
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<license>' . Placefix :: _h ( 'LICENSE' ) . '</license>' ;
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<version>' . $module -> module_version
2020-03-28 13:34:14 +00:00
. '</version>' ;
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<description>' . $module -> lang_prefix
2020-03-28 13:34:14 +00:00
. '_XML_DESCRIPTION</description>' ;
2022-08-30 15:28:41 +00:00
$xml .= Placefix :: _h ( 'MAINXML' );
2019-12-06 05:31:32 +00:00
$xml .= PHP_EOL . '</extension>' ;
return $xml ;
}
2020-12-05 06:17:54 +00:00
/**
* get the module admin custom script field
*
* @ return string
*
*/
public function getModAdminVvvvvvvdm ( $fieldScriptBucket )
{
2020-12-10 01:24:29 +00:00
$form_field_class = array ();
2022-08-30 15:28:41 +00:00
$form_field_class [] = Placefix :: _h ( 'BOM' ) . PHP_EOL ;
$form_field_class [] = " // " . Line :: _ ( __Line__ , __Class__ )
2020-12-10 01:24:29 +00:00
. " No direct access to this file " ;
2020-12-05 06:17:54 +00:00
$form_field_class [] = " defined('_JEXEC') or die('Restricted access'); " ;
$form_field_class [] = PHP_EOL . " use Joomla \ CMS \ Form \ FormField; " ;
$form_field_class [] = " use Joomla \ CMS \ Factory; " ;
2020-12-10 01:24:29 +00:00
$form_field_class [] = PHP_EOL
. " class JFormFieldModadminvvvvvvvdm extends FormField " ;
2020-12-05 06:17:54 +00:00
$form_field_class [] = " { " ;
2022-08-30 15:28:41 +00:00
$form_field_class [] = Indent :: _ ( 1 )
2020-12-10 01:24:29 +00:00
. " protected \$ type = 'modadminvvvvvvvdm'; " ;
2022-08-30 15:28:41 +00:00
$form_field_class [] = PHP_EOL . Indent :: _ ( 1 )
2020-12-10 01:24:29 +00:00
. " protected function getLabel() " ;
2022-08-30 15:28:41 +00:00
$form_field_class [] = Indent :: _ ( 1 ) . " { " ;
$form_field_class [] = Indent :: _ ( 2 ) . " return; " ;
$form_field_class [] = Indent :: _ ( 1 ) . " } " ;
$form_field_class [] = PHP_EOL . Indent :: _ ( 1 )
2020-12-10 01:24:29 +00:00
. " protected function getInput() " ;
2022-08-30 15:28:41 +00:00
$form_field_class [] = Indent :: _ ( 1 ) . " { " ;
$form_field_class [] = Indent :: _ ( 2 ) . " // " . Line :: _ ( __Line__ , __Class__ )
2020-12-10 01:24:29 +00:00
. " Get the document " ;
2022-08-30 15:28:41 +00:00
$form_field_class [] = Indent :: _ ( 2 )
2020-12-10 01:24:29 +00:00
. " \$ document = Factory::getDocument(); " ;
2020-12-05 06:17:54 +00:00
$form_field_class [] = implode ( PHP_EOL , $fieldScriptBucket );
2022-08-30 15:28:41 +00:00
$form_field_class [] = Indent :: _ ( 2 ) . " return; // noting for now :) " ;
$form_field_class [] = Indent :: _ ( 1 ) . " } " ;
2020-12-05 06:17:54 +00:00
$form_field_class [] = " } " ;
return implode ( PHP_EOL , $form_field_class );
}
2019-09-11 14:50:42 +00:00
/**
* get the Joomla plugins IDs
2020-03-28 13:34:14 +00:00
*
2019-09-11 14:50:42 +00:00
* @ return array of IDs on success
2022-09-02 05:51:08 +00:00
* @ deprecated 3.3
2019-09-11 14:50:42 +00:00
*/
protected function getPluginIDs ()
{
2022-09-02 05:51:08 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
), 'Error'
);
2020-03-28 13:34:14 +00:00
2022-09-02 05:51:08 +00:00
return [];
2019-09-11 14:50:42 +00:00
}
/**
* get the Joomla plugin path
2020-03-28 13:34:14 +00:00
*
2019-09-11 14:50:42 +00:00
* @ return string of plugin path on success
2022-09-02 05:51:08 +00:00
* @ deprecated 3.3
2019-09-11 14:50:42 +00:00
*/
protected function getPluginPath ( $id )
{
2022-09-02 05:51:08 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
), 'Error'
);
2020-03-28 13:34:14 +00:00
2022-09-02 05:51:08 +00:00
return '' ;
2019-09-11 14:50:42 +00:00
}
2019-07-28 21:48:42 +00:00
/**
2019-08-22 01:54:47 +00:00
* set the Joomla plugins
2020-03-28 13:34:14 +00:00
*
2019-08-22 01:54:47 +00:00
* @ return true
2020-03-28 13:34:14 +00:00
*
2019-07-28 21:48:42 +00:00
*/
2019-08-22 01:54:47 +00:00
public function setJoomlaPlugin ( $id , & $component )
2019-07-28 21:48:42 +00:00
{
2019-08-22 01:54:47 +00:00
if ( isset ( $this -> joomlaPlugins [ $id ]))
2019-07-28 21:48:42 +00:00
{
2019-08-22 01:54:47 +00:00
return true ;
}
else
{
// Create a new query object.
$query = $this -> db -> getQuery ( true );
$query -> select ( 'a.*' );
$query -> select (
$this -> db -> quoteName (
2019-07-28 21:48:42 +00:00
array (
2019-08-22 01:54:47 +00:00
'g.name' ,
'e.name' ,
'e.head' ,
'e.comment' ,
'e.id' ,
'f.addfiles' ,
'f.addfolders' ,
'f.addfilesfullpath' ,
'f.addfoldersfullpath' ,
'f.addurls' ,
'u.version_update' ,
'u.id'
), array (
'group' ,
'extends' ,
'class_head' ,
'comment' ,
'class_id' ,
'addfiles' ,
'addfolders' ,
'addfilesfullpath' ,
'addfoldersfullpath' ,
'addurls' ,
'version_update' ,
'version_update_id'
)
)
);
// from these tables
$query -> from ( '#__componentbuilder_joomla_plugin AS a' );
2020-03-28 13:34:14 +00:00
$query -> join (
'LEFT' , $this -> db -> quoteName (
'#__componentbuilder_joomla_plugin_group' , 'g'
) . ' ON (' . $this -> db -> quoteName ( 'a.joomla_plugin_group' )
. ' = ' . $this -> db -> quoteName ( 'g.id' ) . ')'
);
$query -> join (
'LEFT' ,
$this -> db -> quoteName ( '#__componentbuilder_class_extends' , 'e' )
. ' ON (' . $this -> db -> quoteName ( 'a.class_extends' ) . ' = '
. $this -> db -> quoteName ( 'e.id' ) . ')'
);
$query -> join (
'LEFT' , $this -> db -> quoteName (
'#__componentbuilder_joomla_plugin_updates' , 'u'
) . ' ON (' . $this -> db -> quoteName ( 'a.id' ) . ' = '
. $this -> db -> quoteName ( 'u.joomla_plugin' ) . ')'
);
$query -> join (
'LEFT' , $this -> db -> quoteName (
'#__componentbuilder_joomla_plugin_files_folders_urls' , 'f'
) . ' ON (' . $this -> db -> quoteName ( 'a.id' ) . ' = '
. $this -> db -> quoteName ( 'f.joomla_plugin' ) . ')'
);
2019-08-22 01:54:47 +00:00
$query -> where ( $this -> db -> quoteName ( 'a.id' ) . ' = ' . ( int ) $id );
$query -> where ( $this -> db -> quoteName ( 'a.published' ) . ' >= 1' );
$this -> db -> setQuery ( $query );
$this -> db -> execute ();
if ( $this -> db -> getNumRows ())
2019-07-28 21:48:42 +00:00
{
2019-08-22 01:54:47 +00:00
// get the plugin data
$plugin = $this -> db -> loadObject ();
// tweak system to set stuff to the plugin domain
2022-08-30 15:28:41 +00:00
$_backup_target = CFactory :: _ ( 'Config' ) -> build_target ;
$_backup_lang = CFactory :: _ ( 'Config' ) -> lang_target ;
$_backup_langPrefix = CFactory :: _ ( 'Config' ) -> lang_prefix ;
2019-08-22 01:54:47 +00:00
// set some keys
$plugin -> target_type = 'P|uG!n' ;
2020-03-28 13:34:14 +00:00
$plugin -> key = $plugin -> id . '_' . $plugin -> target_type ;
2019-08-22 01:54:47 +00:00
// update to point to plugin
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> build_target = $plugin -> key ;
CFactory :: _ ( 'Config' ) -> lang_target = $plugin -> key ;
2019-08-22 01:54:47 +00:00
// set version if not set
if ( empty ( $plugin -> plugin_version ))
{
$plugin -> plugin_version = '1.0.0' ;
}
// set GUI mapper
2020-03-28 13:34:14 +00:00
$guiMapper = array ( 'table' => 'joomla_plugin' ,
'id' => ( int ) $id , 'type' => 'php' );
2019-08-22 01:54:47 +00:00
// update the name if it has dynamic values
2022-08-30 15:28:41 +00:00
$plugin -> name = CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update ( $plugin -> name ), CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
);
2019-08-22 01:54:47 +00:00
// update the name if it has dynamic values
2020-03-28 13:34:14 +00:00
$plugin -> code_name
2022-03-09 23:46:45 +00:00
= ClassfunctionHelper :: safe (
2020-03-28 13:34:14 +00:00
$plugin -> name
);
2019-08-22 01:54:47 +00:00
// set official name
2020-03-28 13:34:14 +00:00
$plugin -> official_name = ucwords (
$plugin -> group . ' - ' . $plugin -> name
);
2019-08-22 01:54:47 +00:00
// set lang prefix
2022-09-14 15:40:02 +00:00
$plugin -> lang_prefix = PluginHelper :: safeLangPrefix (
$plugin -> code_name ,
$plugin -> group
);
// set langPrefix
CFactory :: _ ( 'Config' ) -> lang_prefix = $plugin -> lang_prefix ;
$this -> langPrefix = $plugin -> lang_prefix ;
2019-08-22 01:54:47 +00:00
// set plugin class name
2022-03-09 23:46:45 +00:00
$plugin -> class_name
= PluginHelper :: safeClassName (
$plugin -> code_name ,
$plugin -> group
);
2019-08-22 01:54:47 +00:00
// set plugin install class name
2022-03-09 23:46:45 +00:00
$plugin -> installer_class_name
= PluginHelper :: safeInstallClassName (
$plugin -> code_name ,
$plugin -> group
);
2019-08-22 01:54:47 +00:00
// set plugin folder name
2022-03-09 23:46:45 +00:00
$plugin -> folder_name
= PluginHelper :: safeFolderName (
$plugin -> code_name ,
$plugin -> group
);
2019-08-22 01:54:47 +00:00
// set the zip name
2020-03-28 13:34:14 +00:00
$plugin -> zip_name = $plugin -> folder_name . '_v' . str_replace (
'.' , '_' , $plugin -> plugin_version
2022-08-30 15:28:41 +00:00
) . '__J' . CFactory :: _ ( 'Config' ) -> joomla_version ;
2019-08-22 01:54:47 +00:00
// set plugin file name
$plugin -> file_name = strtolower ( $plugin -> code_name );
2020-03-28 13:34:14 +00:00
// set plugin context
$plugin -> context = $plugin -> folder_name . '.' . $plugin -> id ;
2019-08-22 01:54:47 +00:00
// set official_name lang strings
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
$plugin -> key , CFactory :: _ ( 'Config' ) -> lang_prefix , $plugin -> official_name
2020-03-28 13:34:14 +00:00
);
2019-08-26 06:54:16 +00:00
// set some placeholder for this plugin
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'Plugin_name' )]
2020-03-28 13:34:14 +00:00
= $plugin -> official_name ;
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'PLUGIN_NAME' )]
2020-05-25 00:38:16 +00:00
= $plugin -> official_name ;
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'Plugin' )]
2020-03-28 13:34:14 +00:00
= ucfirst (
$plugin -> code_name
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'plugin' )]
2020-03-28 13:34:14 +00:00
= strtolower (
$plugin -> code_name
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'Plugin_group' )]
2020-03-28 13:34:14 +00:00
= ucfirst (
$plugin -> group
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'plugin_group' )]
2020-03-28 13:34:14 +00:00
= strtolower (
$plugin -> group
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'plugin.version' )]
2020-03-28 13:34:14 +00:00
= $plugin -> plugin_version ;
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'VERSION' )]
2020-05-25 00:38:16 +00:00
= $plugin -> plugin_version ;
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'plugin_version' )]
2020-03-28 13:34:14 +00:00
= str_replace (
'.' , '_' , $plugin -> plugin_version
);
2020-05-25 00:38:16 +00:00
// set description
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'DESCRIPTION' )]
2020-05-25 00:38:16 +00:00
= '' ;
2020-03-28 13:34:14 +00:00
if ( ! isset ( $plugin -> description )
2022-03-09 23:46:45 +00:00
|| ! StringHelper :: check (
2020-03-28 13:34:14 +00:00
$plugin -> description
))
2019-08-22 01:54:47 +00:00
{
$plugin -> description = '' ;
}
else
2019-07-28 21:48:42 +00:00
{
2022-08-30 15:28:41 +00:00
$plugin -> description = CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update ( $plugin -> description ),
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
);
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
2020-03-28 13:34:14 +00:00
$plugin -> key , $plugin -> lang_prefix . '_DESCRIPTION' ,
$plugin -> description
);
2020-05-25 00:38:16 +00:00
// set description
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'DESCRIPTION' )]
2020-11-29 00:00:20 +00:00
= $plugin -> description ;
2020-03-28 13:34:14 +00:00
$plugin -> description = '<p>' . $plugin -> description
. '</p>' ;
}
$plugin -> xml_description = " <h1> " . $plugin -> official_name
. " (v. " . $plugin -> plugin_version
. " )</h1> <div style='clear: both;'></div> "
. $plugin -> description . " <p>Created by <a href=' " . trim (
$component -> website
) . " ' target='_blank'> " . trim (
JFilterOutput :: cleanText ( $component -> author )
) . " </a><br /><small>Development started "
. JFactory :: getDate ( $plugin -> created ) -> format ( " jS F, Y " )
. " </small></p> " ;
2019-08-22 01:54:47 +00:00
// set xml discription
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Language' ) -> set (
2020-03-28 13:34:14 +00:00
$plugin -> key , $plugin -> lang_prefix . '_XML_DESCRIPTION' ,
$plugin -> xml_description
);
2019-08-22 01:54:47 +00:00
// update the readme if set
if ( $plugin -> addreadme == 1 && ! empty ( $plugin -> readme ))
{
2022-08-30 15:28:41 +00:00
$plugin -> readme = CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update ( base64_decode ( $plugin -> readme )),
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
);
2019-08-22 01:54:47 +00:00
}
else
2019-07-28 21:48:42 +00:00
{
2019-08-22 01:54:47 +00:00
$plugin -> addreadme = 0 ;
unset ( $plugin -> readme );
}
// open some base64 strings
if ( ! empty ( $plugin -> main_class_code ))
{
// set GUI mapper field
$guiMapper [ 'field' ] = 'main_class_code' ;
// base64 Decode main_class_code.
2022-08-30 15:28:41 +00:00
$plugin -> main_class_code = CFactory :: _ ( 'Customcode.Gui' ) -> set (
CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $plugin -> main_class_code )
2022-08-30 15:28:41 +00:00
), CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
),
2019-08-22 01:54:47 +00:00
$guiMapper
2020-03-28 13:34:14 +00:00
);
2019-08-22 01:54:47 +00:00
}
// set the head :)
if ( $plugin -> add_head == 1 && ! empty ( $plugin -> head ))
{
// set GUI mapper field
$guiMapper [ 'field' ] = 'head' ;
// base64 Decode head.
2022-08-30 15:28:41 +00:00
$plugin -> head = CFactory :: _ ( 'Customcode.Gui' ) -> set (
CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $plugin -> head )
2022-08-30 15:28:41 +00:00
), CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
),
2019-08-22 01:54:47 +00:00
$guiMapper
2020-03-28 13:34:14 +00:00
);
2019-08-22 01:54:47 +00:00
}
elseif ( ! empty ( $plugin -> class_head ))
{
// base64 Decode head.
2022-08-30 15:28:41 +00:00
$plugin -> head = CFactory :: _ ( 'Customcode.Gui' ) -> set (
CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $plugin -> class_head )
2022-08-30 15:28:41 +00:00
), CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
),
2019-08-22 01:54:47 +00:00
array (
'table' => 'class_extends' ,
'field' => 'head' ,
2020-03-28 13:34:14 +00:00
'id' => ( int ) $plugin -> class_id ,
'type' => 'php' )
);
2019-08-22 01:54:47 +00:00
}
unset ( $plugin -> class_head );
// set the comment
if ( ! empty ( $plugin -> comment ))
{
// base64 Decode comment.
2022-08-30 15:28:41 +00:00
$plugin -> comment = CFactory :: _ ( 'Customcode.Gui' ) -> set (
CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $plugin -> comment )
2022-08-30 15:28:41 +00:00
), CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
),
2019-08-22 01:54:47 +00:00
array (
'table' => 'class_extends' ,
'field' => 'comment' ,
2020-03-28 13:34:14 +00:00
'id' => ( int ) $plugin -> class_id ,
'type' => 'php' )
);
2019-08-22 01:54:47 +00:00
}
// start the config array
$plugin -> config_fields = array ();
// create the form arrays
2020-03-28 13:34:14 +00:00
$plugin -> form_files = array ();
2019-08-22 01:54:47 +00:00
$plugin -> fieldsets_label = array ();
$plugin -> fieldsets_paths = array ();
2022-02-04 10:50:24 +00:00
$plugin -> add_rule_path = array ();
$plugin -> add_field_path = array ();
2019-08-22 01:54:47 +00:00
// set global fields rule to default component path
$plugin -> fields_rules_paths = 1 ;
// set the fields data
2020-03-28 13:34:14 +00:00
$plugin -> fields = ( isset ( $plugin -> fields )
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check ( $plugin -> fields ))
2020-03-28 13:34:14 +00:00
? json_decode ( $plugin -> fields , true ) : null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $plugin -> fields ))
2019-08-22 01:54:47 +00:00
{
// ket global key
2020-03-28 13:34:14 +00:00
$key = $plugin -> key ;
$dynamic_fields = array ( 'fieldset' => 'basic' ,
'fields_name' => 'params' ,
'file' => 'config' );
2019-08-22 01:54:47 +00:00
foreach ( $plugin -> fields as $n => & $form )
2019-07-28 21:48:42 +00:00
{
2020-03-28 13:34:14 +00:00
if ( isset ( $form [ 'fields' ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$form [ 'fields' ]
))
2019-07-28 21:48:42 +00:00
{
2019-08-22 01:54:47 +00:00
// make sure the dynamic_field is set to dynamic_value by default
2020-03-28 13:34:14 +00:00
foreach (
$dynamic_fields as $dynamic_field =>
$dynamic_value
)
2019-08-22 01:54:47 +00:00
{
2020-03-28 13:34:14 +00:00
if ( ! isset ( $form [ $dynamic_field ])
2022-03-09 23:46:45 +00:00
|| ! StringHelper :: check (
2020-03-28 13:34:14 +00:00
$form [ $dynamic_field ]
))
2019-08-22 01:54:47 +00:00
{
$form [ $dynamic_field ] = $dynamic_value ;
}
else
{
2020-03-28 13:34:14 +00:00
if ( 'fields_name' === $dynamic_field
&& strpos ( $form [ $dynamic_field ], '.' )
!== false )
2019-10-11 13:41:00 +00:00
{
2020-03-28 13:34:14 +00:00
$form [ $dynamic_field ]
= $form [ $dynamic_field ];
2019-10-11 13:41:00 +00:00
}
else
{
2020-03-28 13:34:14 +00:00
$form [ $dynamic_field ]
2022-03-09 23:46:45 +00:00
= StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$form [ $dynamic_field ]
);
2019-10-11 13:41:00 +00:00
}
2019-08-22 01:54:47 +00:00
}
}
// check if field is external form file
if ( ! isset ( $form [ 'plugin' ]) || $form [ 'plugin' ] != 1 )
{
// now build the form key
2020-03-28 13:34:14 +00:00
$unique = $form [ 'file' ] . $form [ 'fields_name' ]
. $form [ 'fieldset' ];
2019-08-22 01:54:47 +00:00
}
else
{
// now build the form key
2020-03-28 13:34:14 +00:00
$unique = $form [ 'fields_name' ]
. $form [ 'fieldset' ];
2019-08-22 01:54:47 +00:00
}
// set global fields rule path switchs
2020-03-28 13:34:14 +00:00
if ( $plugin -> fields_rules_paths == 1
&& isset ( $form [ 'fields_rules_paths' ])
&& $form [ 'fields_rules_paths' ] == 2 )
2019-08-22 01:54:47 +00:00
{
$plugin -> fields_rules_paths = 2 ;
}
// set where to path is pointing
2020-03-28 13:34:14 +00:00
$plugin -> fieldsets_paths [ $unique ]
= $form [ 'fields_rules_paths' ];
2019-08-22 01:54:47 +00:00
// add the label if set to lang
2020-03-28 13:34:14 +00:00
if ( isset ( $form [ 'label' ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$form [ 'label' ]
))
2019-08-22 01:54:47 +00:00
{
2020-03-28 13:34:14 +00:00
$plugin -> fieldsets_label [ $unique ]
2022-08-30 15:28:41 +00:00
= CFactory :: _ ( 'Language' ) -> key ( $form [ 'label' ]);
2019-08-22 01:54:47 +00:00
}
2022-02-04 10:50:24 +00:00
// check for extra rule paths
if ( isset ( $form [ 'addrulepath' ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check ( $form [ 'addrulepath' ]))
2022-02-04 10:50:24 +00:00
{
foreach ( $form [ 'addrulepath' ] as $add_rule_path )
{
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $add_rule_path [ 'path' ]))
2022-02-04 10:50:24 +00:00
{
2022-02-04 17:21:10 +00:00
$plugin -> add_rule_path [ $unique ] = $add_rule_path [ 'path' ];
2022-02-04 10:50:24 +00:00
}
}
}
// check for extra field paths
if ( isset ( $form [ 'addfieldpath' ])
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check ( $form [ 'addfieldpath' ]))
2022-02-04 10:50:24 +00:00
{
foreach ( $form [ 'addfieldpath' ] as $add_field_path )
{
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $add_field_path [ 'path' ]))
2022-02-04 10:50:24 +00:00
{
2022-02-04 17:21:10 +00:00
$plugin -> add_field_path [ $unique ] = $add_field_path [ 'path' ];
2022-02-04 10:50:24 +00:00
}
}
}
2019-08-22 01:54:47 +00:00
// build the fields
2020-03-28 13:34:14 +00:00
$form [ 'fields' ] = array_map (
function ( $field ) use ( $key , $unique ) {
// make sure the alias and title is 0
$field [ 'alias' ] = 0 ;
$field [ 'title' ] = 0 ;
// set the field details
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Field' ) -> set (
2020-03-28 13:34:14 +00:00
$field , $key , $key , $unique
);
// update the default if set
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check (
2020-03-28 13:34:14 +00:00
$field [ 'custom_value' ]
)
&& isset ( $field [ 'settings' ]))
2019-08-22 01:54:47 +00:00
{
2020-03-28 13:34:14 +00:00
if (( $old_default
2022-04-04 15:35:08 +00:00
= GetHelper :: between (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> xml ,
'default="' , '"' , false
)) !== false )
{
// replace old default
$field [ 'settings' ] -> xml
= str_replace (
'default="' . $old_default
. '"' , 'default="'
. $field [ 'custom_value' ] . '"' ,
$field [ 'settings' ] -> xml
);
}
else
{
// add the default (hmmm not ideal but okay it should work)
$field [ 'settings' ] -> xml
= 'default="'
. $field [ 'custom_value' ] . '" '
. $field [ 'settings' ] -> xml ;
}
2019-08-22 01:54:47 +00:00
}
2020-03-28 13:34:14 +00:00
unset ( $field [ 'custom_value' ]);
// return field
return $field ;
}, array_values ( $form [ 'fields' ])
);
2019-08-22 01:54:47 +00:00
// check if field is external form file
if ( ! isset ( $form [ 'plugin' ]) || $form [ 'plugin' ] != 1 )
{
// load the form file
if ( ! isset ( $plugin -> form_files [ $form [ 'file' ]]))
{
2020-03-28 13:34:14 +00:00
$plugin -> form_files [ $form [ 'file' ]]
= array ();
2019-08-22 01:54:47 +00:00
}
if ( ! isset ( $plugin -> form_files [ $form [ 'file' ]][ $form [ 'fields_name' ]]))
{
2020-03-28 13:34:14 +00:00
$plugin -> form_files [ $form [ 'file' ]][ $form [ 'fields_name' ]]
= array ();
2019-08-22 01:54:47 +00:00
}
if ( ! isset ( $plugin -> form_files [ $form [ 'file' ]][ $form [ 'fields_name' ]][ $form [ 'fieldset' ]]))
{
2020-03-28 13:34:14 +00:00
$plugin -> form_files [ $form [ 'file' ]][ $form [ 'fields_name' ]][ $form [ 'fieldset' ]]
= array ();
2019-08-22 01:54:47 +00:00
}
// do some house cleaning (for fields)
foreach ( $form [ 'fields' ] as $field )
{
// so first we lock the field name in
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Field.Name' ) -> get (
2020-03-28 13:34:14 +00:00
$field , $plugin -> key , $unique
);
2019-08-22 01:54:47 +00:00
// add the fields to the global form file builder
2020-03-28 13:34:14 +00:00
$plugin -> form_files [ $form [ 'file' ]][ $form [ 'fields_name' ]][ $form [ 'fieldset' ]][]
= $field ;
2019-08-22 01:54:47 +00:00
}
// remove form
unset ( $plugin -> fields [ $n ]);
}
else
{
2019-12-03 02:17:35 +00:00
// load the config form
2019-08-22 01:54:47 +00:00
if ( ! isset ( $plugin -> config_fields [ $form [ 'fields_name' ]]))
{
2020-03-28 13:34:14 +00:00
$plugin -> config_fields [ $form [ 'fields_name' ]]
= array ();
2019-08-22 01:54:47 +00:00
}
if ( ! isset ( $plugin -> config_fields [ $form [ 'fields_name' ]][ $form [ 'fieldset' ]]))
{
2020-03-28 13:34:14 +00:00
$plugin -> config_fields [ $form [ 'fields_name' ]][ $form [ 'fieldset' ]]
= array ();
2019-08-22 01:54:47 +00:00
}
// do some house cleaning (for fields)
foreach ( $form [ 'fields' ] as $field )
{
// so first we lock the field name in
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Field.Name' ) -> get (
2020-03-28 13:34:14 +00:00
$field , $plugin -> key , $unique
);
2019-08-22 01:54:47 +00:00
// add the fields to the config builder
2020-03-28 13:34:14 +00:00
$plugin -> config_fields [ $form [ 'fields_name' ]][ $form [ 'fieldset' ]][]
= $field ;
2019-08-22 01:54:47 +00:00
}
// remove form
unset ( $plugin -> fields [ $n ]);
}
}
else
{
unset ( $plugin -> fields [ $n ]);
2019-07-28 21:48:42 +00:00
}
}
}
2019-08-22 01:54:47 +00:00
unset ( $plugin -> fields );
// set the add targets
2020-03-28 13:34:14 +00:00
$addArray = array ( 'files' => 'files' ,
'folders' => 'folders' ,
'urls' => 'urls' ,
'filesfullpath' => 'files' ,
'foldersfullpath' => 'folders' );
2019-08-22 01:54:47 +00:00
foreach ( $addArray as $addTarget => $targetHere )
2019-08-04 22:38:53 +00:00
{
2019-08-22 01:54:47 +00:00
// set the add target data
2020-03-28 13:34:14 +00:00
$plugin -> { 'add' . $addTarget } = ( isset (
$plugin -> { 'add' . $addTarget }
)
2022-03-09 23:46:45 +00:00
&& JsonHelper :: check (
2020-03-28 13:34:14 +00:00
$plugin -> { 'add' . $addTarget }
)) ? json_decode ( $plugin -> { 'add' . $addTarget }, true )
: null ;
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$plugin -> { 'add' . $addTarget }
))
{
if ( isset ( $plugin -> { $targetHere })
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$plugin -> { $targetHere }
))
2019-08-22 01:54:47 +00:00
{
foreach ( $plugin -> { 'add' . $addTarget } as $taget )
{
$plugin -> { $targetHere }[] = $taget ;
}
}
else
{
2020-03-28 13:34:14 +00:00
$plugin -> { $targetHere } = array_values (
$plugin -> { 'add' . $addTarget }
);
2019-08-22 01:54:47 +00:00
}
2019-08-04 22:38:53 +00:00
}
2019-08-22 01:54:47 +00:00
unset ( $plugin -> { 'add' . $addTarget });
}
// add PHP in plugin install
$plugin -> add_install_script = false ;
2020-03-28 13:34:14 +00:00
$addScriptMethods = array ( 'php_preflight' ,
2021-12-21 14:44:50 +00:00
'php_postflight' ,
'php_method' );
2020-03-28 13:34:14 +00:00
$addScriptTypes = array ( 'install' , 'update' ,
2021-12-21 14:44:50 +00:00
'uninstall' );
2019-08-22 01:54:47 +00:00
foreach ( $addScriptMethods as $scriptMethod )
{
foreach ( $addScriptTypes as $scriptType )
2019-08-04 22:38:53 +00:00
{
2020-03-28 13:34:14 +00:00
if ( isset (
$plugin -> { 'add_' . $scriptMethod . '_'
. $scriptType }
)
&& $plugin -> { 'add_' . $scriptMethod . '_'
. $scriptType } == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$plugin -> { $scriptMethod . '_' . $scriptType }
))
2019-08-22 01:54:47 +00:00
{
// set GUI mapper field
2020-03-28 13:34:14 +00:00
$guiMapper [ 'field' ] = $scriptMethod . '_'
. $scriptType ;
$plugin -> { $scriptMethod . '_' . $scriptType }
2022-08-30 15:28:41 +00:00
= CFactory :: _ ( 'Customcode.Gui' ) -> set (
CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode (
$plugin -> { $scriptMethod . '_'
. $scriptType }
)
2022-08-30 15:28:41 +00:00
), CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
),
2019-08-22 01:54:47 +00:00
$guiMapper
);
$plugin -> add_install_script = true ;
}
else
{
unset ( $plugin -> { $scriptMethod . '_' . $scriptType });
2020-03-28 13:34:14 +00:00
$plugin -> { 'add_' . $scriptMethod . '_'
. $scriptType }
= 0 ;
2019-08-22 01:54:47 +00:00
}
2019-08-04 22:38:53 +00:00
}
}
2019-08-22 01:54:47 +00:00
// add_sql
2020-03-28 13:34:14 +00:00
if ( $plugin -> add_sql == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $plugin -> sql ))
2019-08-22 01:54:47 +00:00
{
2022-08-30 15:28:41 +00:00
$plugin -> sql = CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update ( base64_decode ( $plugin -> sql )),
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
);
2019-08-22 01:54:47 +00:00
}
else
2019-08-04 22:38:53 +00:00
{
2019-08-22 01:54:47 +00:00
unset ( $plugin -> sql );
$plugin -> add_sql = 0 ;
}
// add_sql_uninstall
2020-03-28 13:34:14 +00:00
if ( $plugin -> add_sql_uninstall == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$plugin -> sql_uninstall
))
{
2022-08-30 15:28:41 +00:00
$plugin -> sql_uninstall = CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update (
2020-03-28 13:34:14 +00:00
base64_decode ( $plugin -> sql_uninstall )
2022-08-30 15:28:41 +00:00
), CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
);
2019-08-04 22:38:53 +00:00
}
else
{
2019-08-22 01:54:47 +00:00
unset ( $plugin -> sql_uninstall );
$plugin -> add_sql_uninstall = 0 ;
}
// update the URL of the update_server if set
2020-03-28 13:34:14 +00:00
if ( $plugin -> add_update_server == 1
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$plugin -> update_server_url
))
{
2022-08-30 15:28:41 +00:00
$plugin -> update_server_url = CFactory :: _ ( 'Placeholder' ) -> update (
2022-09-03 10:48:53 +00:00
CFactory :: _ ( 'Customcode' ) -> update ( $plugin -> update_server_url ),
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active
2020-03-28 13:34:14 +00:00
);
2019-08-22 01:54:47 +00:00
}
// add the update/sales server FTP details if that is the expected protocol
$serverArray = array ( 'update_server' , 'sales_server' );
foreach ( $serverArray as $server )
{
2020-03-28 13:34:14 +00:00
if ( $plugin -> { 'add_' . $server } == 1
&& is_numeric (
$plugin -> { $server }
)
&& $plugin -> { $server } > 0 )
2019-08-22 01:54:47 +00:00
{
// get the server protocol
2020-03-28 13:34:14 +00:00
$plugin -> { $server . '_protocol' }
2022-03-09 23:46:45 +00:00
= GetHelper :: var (
2020-03-28 13:34:14 +00:00
'server' , ( int ) $plugin -> { $server }, 'id' , 'protocol'
);
2019-08-22 01:54:47 +00:00
}
else
2019-08-04 22:38:53 +00:00
{
2019-08-22 01:54:47 +00:00
$plugin -> { $server } = 0 ;
2021-10-18 20:12:19 +00:00
// only change this for sales server (update server can be added locally to the zip file)
2019-08-22 01:54:47 +00:00
if ( 'sales_server' === $server )
{
$plugin -> { 'add_' . $server } = 0 ;
}
$plugin -> { $server . '_protocol' } = 0 ;
2019-08-04 22:38:53 +00:00
}
}
2019-08-22 01:54:47 +00:00
// set the update server stuff (TODO)
// update_server_xml_path
// update_server_xml_file_name
2019-08-08 15:35:58 +00:00
2019-08-22 01:54:47 +00:00
// rest globals
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> build_target = $_backup_target ;
CFactory :: _ ( 'Config' ) -> lang_target = $_backup_lang ;
2019-08-22 01:54:47 +00:00
$this -> langPrefix = $_backup_langPrefix ;
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Config' ) -> set ( 'lang_prefix' , $_backup_langPrefix );
2019-08-04 22:38:53 +00:00
2020-03-28 13:34:14 +00:00
unset (
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'Plugin_name' )]
2020-03-28 13:34:14 +00:00
);
2022-08-30 15:28:41 +00:00
unset ( CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'Plugin' )]);
unset ( CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'plugin' )]);
2020-03-28 13:34:14 +00:00
unset (
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'Plugin_group' )]
2020-03-28 13:34:14 +00:00
);
unset (
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'plugin_group' )]
2020-03-28 13:34:14 +00:00
);
unset (
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'plugin.version' )]
2020-03-28 13:34:14 +00:00
);
unset (
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _ ( 'plugin_version' )]
2020-03-28 13:34:14 +00:00
);
2020-05-25 00:38:16 +00:00
unset (
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'VERSION' )]
2020-11-29 00:00:20 +00:00
);
2020-05-25 00:38:16 +00:00
unset (
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'DESCRIPTION' )]
2020-11-29 00:00:20 +00:00
);
2020-05-25 00:38:16 +00:00
unset (
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> active [ Placefix :: _h ( 'PLUGIN_NAME' )]
2020-11-29 00:00:20 +00:00
);
2019-08-26 06:54:16 +00:00
2019-08-22 01:54:47 +00:00
$this -> joomlaPlugins [ $id ] = $plugin ;
return true ;
}
2019-07-28 21:48:42 +00:00
}
2020-03-28 13:34:14 +00:00
2019-07-28 21:48:42 +00:00
return false ;
}
2019-08-04 22:38:53 +00:00
/**
* get the plugin xml template
2020-03-28 13:34:14 +00:00
*
2019-08-04 22:38:53 +00:00
* @ return string
2020-03-28 13:34:14 +00:00
*
2019-08-04 22:38:53 +00:00
*/
public function getPluginXMLTemplate ( & $plugin )
{
$xml = '<?xml version="1.0" encoding="utf-8"?>' ;
2021-12-21 14:44:50 +00:00
$xml .= PHP_EOL . '<extension type="plugin" version="'
2022-08-30 15:28:41 +00:00
. $this -> joomlaVersions [ CFactory :: _ ( 'Config' ) -> joomla_version ][ 'xml_version' ] . '" group="'
2020-03-28 13:34:14 +00:00
. strtolower ( $plugin -> group ) . '" method="upgrade">' ;
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<name>' . $plugin -> lang_prefix
2020-03-28 13:34:14 +00:00
. '</name>' ;
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<creationDate>' . Placefix :: _h ( 'BUILDDATE' ) . '</creationDate>' ;
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<author>' . Placefix :: _h ( 'AUTHOR' ) . '</author>' ;
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<authorEmail>' . Placefix :: _h ( 'AUTHOREMAIL' ) . '</authorEmail>' ;
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<authorUrl>' . Placefix :: _h ( 'AUTHORWEBSITE' ) . '</authorUrl>' ;
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<copyright>' . Placefix :: _h ( 'COPYRIGHT' ) . '</copyright>' ;
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<license>' . Placefix :: _h ( 'LICENSE' ) . '</license>' ;
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<version>' . $plugin -> plugin_version
2020-03-28 13:34:14 +00:00
. '</version>' ;
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<description>' . $plugin -> lang_prefix
2020-03-28 13:34:14 +00:00
. '_XML_DESCRIPTION</description>' ;
2022-08-30 15:28:41 +00:00
$xml .= Placefix :: _h ( 'MAINXML' );
2019-08-04 22:38:53 +00:00
$xml .= PHP_EOL . '</extension>' ;
return $xml ;
}
2017-02-01 13:17:04 +00:00
/**
* store the code
2020-03-28 13:34:14 +00:00
*
* @ param int $when To set when to update
2017-02-01 13:17:04 +00:00
*
* @ return void
2020-03-28 13:34:14 +00:00
*
2022-09-02 05:51:08 +00:00
* @ deprecated 3.3
2017-02-01 13:17:04 +00:00
*/
2017-02-13 23:24:38 +00:00
protected function setNewCustomCode ( $when = 1 )
2017-02-01 13:17:04 +00:00
{
2022-09-02 05:51:08 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
), 'Error'
);
2017-02-01 13:17:04 +00:00
}
2017-12-14 23:10:47 +00:00
2017-02-01 13:17:04 +00:00
/**
* store the code
2020-03-28 13:34:14 +00:00
*
* @ param int $when To set when to update
2017-02-01 13:17:04 +00:00
*
* @ return void
2020-03-28 13:34:14 +00:00
*
2022-09-02 05:51:08 +00:00
* @ deprecated 3.3
2017-02-01 13:17:04 +00:00
*/
2017-02-13 23:24:38 +00:00
protected function setExistingCustomCode ( $when = 1 )
2017-02-01 13:17:04 +00:00
{
2022-09-02 05:51:08 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
), 'Error'
);
2017-02-01 13:17:04 +00:00
}
2017-12-14 23:10:47 +00:00
2017-02-01 13:17:04 +00:00
/**
* get the custom code from the local files
2020-03-28 13:34:14 +00:00
*
2017-02-01 13:17:04 +00:00
* @ param array $paths The local paths to parse
* @ param string $today The date for today
*
* @ return void
2022-09-02 05:51:08 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Customcode.Extractor' ) -> run ();
2017-02-01 13:17:04 +00:00
*/
2017-02-13 23:24:38 +00:00
protected function customCodeFactory ( & $paths , & $today )
2017-02-01 13:17:04 +00:00
{
2022-09-02 05:51:08 +00:00
CFactory :: _ ( 'Customcode.Extractor' ) -> run ();
2017-02-01 13:17:04 +00:00
}
2017-12-14 23:10:47 +00:00
2017-02-01 13:17:04 +00:00
/**
* search a file for placeholders and store result
2020-03-28 13:34:14 +00:00
*
* @ param array $counter The counter for the arrays
* @ param string $file The file path to search
* @ param array $searchArray The values to search for
* @ param array $placeholders The values to replace in the code being stored
* @ param string $today The date for today
2017-02-01 13:17:04 +00:00
*
* @ return array on success
2020-03-28 13:34:14 +00:00
*
2022-09-02 05:51:08 +00:00
* @ deprecated 3.3
2017-02-01 13:17:04 +00:00
*/
2020-03-28 13:34:14 +00:00
protected function searchFileContent ( & $counter , & $file , & $target ,
2021-12-21 14:44:50 +00:00
& $searchArray , & $placeholders , & $today
)
{
2022-09-02 05:51:08 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
), 'Error'
);
return [];
2017-02-01 13:17:04 +00:00
}
2020-06-25 19:22:30 +00:00
2021-02-19 00:35:54 +00:00
/**
* Set a hash of a file and / or string
*
* @ param string $string The code string
*
* @ return string
2022-08-31 11:49:01 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Customcode.Hash' ) -> set ( $script );
2021-02-19 00:35:54 +00:00
*/
protected function setDynamicHASHING ( $script )
{
2022-09-02 05:51:08 +00:00
return CFactory :: _ ( 'Customcode.Hash' ) -> set ( $script );
2021-02-19 00:35:54 +00:00
}
2020-06-25 19:22:30 +00:00
/**
* Lock a string with bsae64 ( basic )
*
* @ param string $string The code string
*
* @ return string
2022-08-31 11:49:01 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Customcode.LockBase' ) -> set ( $script );
2020-06-25 19:22:30 +00:00
*/
protected function setBase64LOCK ( $script )
{
2022-09-02 05:51:08 +00:00
return CFactory :: _ ( 'Customcode.LockBase' ) -> set ( $script );
2020-06-25 19:22:30 +00:00
}
2017-12-14 23:10:47 +00:00
2019-07-28 21:48:42 +00:00
/**
* Set the JCB GUI code placeholder
2020-03-28 13:34:14 +00:00
*
* @ param string $string The code string
* @ param array $config The placeholder config values
2019-07-28 21:48:42 +00:00
*
2019-12-03 02:17:35 +00:00
* @ return string
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Customcode.Gui' ) -> set ( $string , $config );
2019-07-28 21:48:42 +00:00
*/
public function setGuiCodePlaceholder ( $string , $config )
{
2022-08-30 15:28:41 +00:00
return CFactory :: _ ( 'Customcode.Gui' ) -> set ( $string , $config );
2019-07-28 21:48:42 +00:00
}
/**
2020-03-28 13:34:14 +00:00
* search a code to see if there is already any custom
2019-07-28 21:48:42 +00:00
* code or other reasons not to add the GUI code placeholders
2020-03-28 13:34:14 +00:00
*
* @ param string $code The code to check
2019-07-28 21:48:42 +00:00
*
* @ return boolean true if GUI code placeholders can be added
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3
2019-07-28 21:48:42 +00:00
*/
protected function canAddGuiCodePlaceholder ( & $code )
{
2022-09-02 05:51:08 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
), 'Error'
);
2020-03-28 13:34:14 +00:00
2022-09-02 05:51:08 +00:00
return false ;
2019-07-28 21:48:42 +00:00
}
/**
* search a file for gui code blocks that were updated in the IDE
2020-03-28 13:34:14 +00:00
*
* @ param string $file The file path to search
* @ param array $placeholders The values to replace in the code being stored
* @ param string $today The date for today
* @ param string $target The target path type
2019-07-28 21:48:42 +00:00
*
* @ return void
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Customcode.Gui' ) -> search ( $file , $placeholders , $today , $target );
2019-07-28 21:48:42 +00:00
*/
2019-09-11 14:50:42 +00:00
protected function guiCodeSearch ( & $file , & $placeholders , & $today , & $target )
2019-07-28 21:48:42 +00:00
{
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Customcode.Gui' ) -> search ( $file , $placeholders , $today , $target );
2019-07-28 21:48:42 +00:00
}
2017-02-13 23:24:38 +00:00
/**
* Check if this line should be added
2020-03-28 13:34:14 +00:00
*
* @ param string $replaceKey The key to remove from line
* @ param int $type The line type
* @ param string $lineContent The line to check
2017-02-13 23:24:38 +00:00
*
* @ return bool true on success
2020-03-28 13:34:14 +00:00
*
2022-09-02 05:51:08 +00:00
* @ deprecated 3.3
2017-02-13 23:24:38 +00:00
*/
protected function addLineChecker ( $replaceKey , $type , $lineContent )
{
2022-09-02 05:51:08 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
), 'Error'
);
2020-03-28 13:34:14 +00:00
2017-02-13 23:24:38 +00:00
return false ;
}
2017-12-14 23:10:47 +00:00
2017-02-13 23:24:38 +00:00
/**
2018-04-19 15:52:47 +00:00
* set the start replace placeholder
2020-03-28 13:34:14 +00:00
*
* @ param int $id The comment id
* @ param int $commentType The comment type
* @ param string $startReplace The main replace string
2017-02-13 23:24:38 +00:00
*
* @ return array on success
2020-03-28 13:34:14 +00:00
*
2022-09-02 05:51:08 +00:00
* @ deprecated 3.3
2017-02-13 23:24:38 +00:00
*/
protected function setStartReplace ( $id , $commentType , $startReplace )
{
2022-09-02 05:51:08 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
), 'Error'
);
2020-03-28 13:34:14 +00:00
2022-09-02 05:51:08 +00:00
return [];
2017-02-13 23:24:38 +00:00
}
2017-12-14 23:10:47 +00:00
2017-02-01 13:17:04 +00:00
/**
* search for the system id in the line given
2020-03-28 13:34:14 +00:00
*
* @ param string $lineContent The file path to search
* @ param string $placeholders The values to search for
* @ param int $commentType The comment type
2017-02-01 13:17:04 +00:00
*
2022-09-02 05:51:08 +00:00
* @ return int on success
2020-03-28 13:34:14 +00:00
*
2022-09-02 05:51:08 +00:00
* @ deprecated 3.3
2017-02-01 13:17:04 +00:00
*/
2017-02-13 23:24:38 +00:00
protected function getSystemID ( & $lineContent , $placeholders , $commentType )
2017-02-01 13:17:04 +00:00
{
2022-09-02 05:51:08 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
), 'Error'
2020-03-28 13:34:14 +00:00
);
2022-09-02 05:51:08 +00:00
return null ;
2017-02-01 13:17:04 +00:00
}
2017-12-14 23:10:47 +00:00
2017-02-11 02:24:26 +00:00
/**
2018-04-19 15:52:47 +00:00
* Reverse Engineer the dynamic placeholders ( TODO hmmmm this is not ideal )
2020-03-28 13:34:14 +00:00
*
* @ param string $string The string to revers
* @ param array $placeholders The values to search for
* @ param string $target The target path type
* @ param int $id The custom code id
* @ param string $field The field name
* @ param string $table The table name
2017-02-11 02:24:26 +00:00
*
* @ return string
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Placeholder.Reverse' ) -> engine ( $string , $placeholders , $target , $id , $field , $table );
2017-02-11 02:24:26 +00:00
*/
2020-03-28 13:34:14 +00:00
protected function reversePlaceholders ( $string , & $placeholders , & $target ,
2021-12-21 14:44:50 +00:00
$id = null , $field = 'code' , $table = 'custom_code'
)
{
2022-08-30 15:28:41 +00:00
// use the new container class
CFactory :: _ ( 'Placeholder.Reverse' ) -> engine ( $string , $placeholders , $target , $id , $field , $table );
2017-02-13 23:24:38 +00:00
}
2017-12-14 23:10:47 +00:00
2017-02-13 23:24:38 +00:00
/**
2019-09-11 14:50:42 +00:00
* Set the langs strings for the reveres process
2020-03-28 13:34:14 +00:00
*
* @ param string $updateString The string to update
* @ param string $string The string to use lang update
* @ param string $target The target path type
2017-02-13 23:24:38 +00:00
*
2019-05-20 12:14:43 +00:00
* @ return string
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 See $this -> reversePlaceholders ();
2017-02-13 23:24:38 +00:00
*/
2020-03-28 13:34:14 +00:00
protected function setReverseLangPlaceholders ( $updateString , $string ,
2021-12-21 14:44:50 +00:00
& $target
)
{
2022-09-02 05:51:08 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
), 'Error'
2020-03-28 13:34:14 +00:00
);
2022-09-02 05:51:08 +00:00
return '' ;
2017-02-13 23:24:38 +00:00
}
2017-12-14 23:10:47 +00:00
2017-02-13 23:24:38 +00:00
/**
* Update the data with the placeholders
2020-03-28 13:34:14 +00:00
*
* @ param string $data The actual data
* @ param array $placeholder The placeholders
* @ param int $action The action to use
*
2017-02-13 23:24:38 +00:00
* THE ACTION OPTIONS ARE
* 1 -> Just replace ( default )
* 2 -> Check if data string has placeholders
* 3 -> Remove placeholders not in data string
*
* @ return string
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Placeholder' ) -> update ( $data , $placeholder , $action );
2017-02-13 23:24:38 +00:00
*/
2018-03-20 02:35:48 +00:00
public function setPlaceholders ( $data , & $placeholder , $action = 1 )
2017-02-13 23:24:38 +00:00
{
2022-08-30 15:28:41 +00:00
// use the new container class
CFactory :: _ ( 'Placeholder' ) -> update ( $data , $placeholder , $action );
2017-02-11 02:24:26 +00:00
}
2017-12-14 23:10:47 +00:00
2017-02-01 13:17:04 +00:00
/**
2018-04-19 15:52:47 +00:00
* return the placeholders for inserted and replaced code
2020-03-28 13:34:14 +00:00
*
* @ param int $type The type of placement
* @ param int $id The code id in the system
2017-02-01 13:17:04 +00:00
*
* @ return array on success
2022-08-30 15:28:41 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Placeholder' ) -> keys ( $type , $id );
2017-02-01 13:17:04 +00:00
*/
2017-02-11 02:24:26 +00:00
public function getPlaceHolder ( $type , $id )
2017-02-01 13:17:04 +00:00
{
2022-08-30 15:28:41 +00:00
return CFactory :: _ ( 'Placeholder' ) -> keys ( $type , $id );
2017-02-01 13:17:04 +00:00
}
2017-12-14 23:10:47 +00:00
2017-02-13 23:24:38 +00:00
/**
* get the local installed path of this component
*
* @ return array of paths on success
2022-09-02 05:51:08 +00:00
* @ deprecated 3.3
2017-02-13 23:24:38 +00:00
*/
protected function getLocalInstallPaths ()
{
2022-09-02 05:51:08 +00:00
// set notice that we could not get a valid string from the target
$this -> app -> enqueueMessage (
JText :: sprintf ( '<hr /><h3>%s Warning</h3>' , __CLASS__ ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'Use of a deprecated method (%s)!' , __METHOD__
), 'Error'
);
2020-03-28 13:34:14 +00:00
2022-09-02 05:51:08 +00:00
return [];
2017-02-13 23:24:38 +00:00
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
}