2016-02-26 00:20:09 +00:00
< ? php
2018-05-18 06:28:27 +00:00
/**
* @ package Joomla . Component . Builder
*
* @ created 30 th April , 2015
2021-12-21 14:44:50 +00:00
* @ author Llewellyn van der Merwe < https :// dev . vdm . io >
* @ gitea Joomla Component Builder < https :// git . vdm . dev / joomla / Component - Builder >
2018-05-18 06:28:27 +00:00
* @ github Joomla Component Builder < https :// github . com / vdm - io / Joomla - Component - Builder >
2021-01-03 16:49:35 +00:00
* @ copyright Copyright ( C ) 2015 Vast Development Method . All rights reserved .
2018-05-18 06:28:27 +00:00
* @ license GNU General Public License version 2 or later ; see LICENSE . txt
*/
2016-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-03-09 23:46:45 +00:00
use VDM\Joomla\Utilities\StringHelper ;
use VDM\Joomla\Utilities\ArrayHelper ;
use VDM\Joomla\Utilities\ObjectHelper ;
2022-04-04 15:35:08 +00:00
use VDM\Joomla\Utilities\GetHelper ;
use VDM\Joomla\Utilities\FileHelper ;
2022-08-30 15:28:41 +00:00
use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory ;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix ;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent ;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line ;
2022-03-09 23:46:45 +00:00
2021-03-07 21:40:55 +00:00
2016-02-26 00:20:09 +00:00
/**
* Structure class
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2016-02-26 00:20:09 +00:00
*/
class Structure extends Get
2017-12-14 23:10:47 +00:00
{
2016-03-04 00:01:43 +00:00
/**
2019-06-29 21:11:37 +00:00
* The folder counter
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Counter' ) -> folder ;
2016-02-26 00:20:09 +00:00
*/
public $folderCount = 0 ;
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2019-06-29 21:11:37 +00:00
* The file counter
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Counter' ) -> file ;
2016-02-26 00:20:09 +00:00
*/
public $fileCount = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The page counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $pageCount = 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 line counter
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
* @ deprecated 3.3 Use CFactory :: _ ( 'Counter' ) -> line ;
2016-02-26 00:20:09 +00:00
*/
public $lineCount = 0 ;
2017-12-14 23:10:47 +00:00
2017-12-14 13:30:21 +00:00
/**
* The field counter
2020-03-28 13:34:14 +00:00
*
2017-12-14 13:30:21 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-12-14 13:30:21 +00:00
*/
public $fieldCount = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The seconds counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $seconds = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The actual seconds counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $actualSeconds = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The folder seconds counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $folderSeconds = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The file seconds counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $fileSeconds = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The line seconds counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $lineSeconds = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The seconds debugging counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $secondsDebugging = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The seconds planning counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $secondsPlanning = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The seconds mapping counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $secondsMapping = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The seconds office counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $secondsOffice = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The total hours counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $totalHours = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The debugging hours counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $debuggingHours = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The planning hours counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $planningHours = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The mapping hours counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $mappingHours = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The office hours counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $officeHours = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The actual Total Hours counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $actualTotalHours = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The actual hours spent counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $actualHoursSpent = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The actual days spent counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $actualDaysSpent = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The total days counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $totalDays = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The actual Total Days counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $actualTotalDays = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The project week time counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $projectWeekTime = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The project month time counter
2020-03-28 13:34:14 +00:00
*
2017-03-03 21:53:18 +00:00
* @ var int
2023-01-22 00:38:21 +00:00
* @ deprecated 3.3
2017-03-03 21:53:18 +00:00
*/
public $projectMonthTime = 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 template path
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var string
*/
public $templatePath ;
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 template path
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var string
*/
public $templatePathCustom ;
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 Joomla Version Data
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var object
*/
public $joomlaVersionData ;
2017-12-14 23:10:47 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* Static File Content
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
2022-12-04 09:23:43 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Content' ) -> active
2016-02-26 00:20:09 +00:00
*/
public $fileContentStatic = array ();
2017-12-14 23:10:47 +00:00
2020-01-25 22:24:42 +00:00
/**
* Extention Custom Fields
*
* @ var array
*/
public $extentionCustomfields = array ();
2020-02-13 12:24:13 +00:00
/**
* Extention Tracking Files Moved
*
* @ var array
*/
public $extentionTrackingFilesMoved = array ();
2018-09-25 20:02:48 +00:00
/**
* The standard folders
2020-03-28 13:34:14 +00:00
*
2018-09-25 20:02:48 +00:00
* @ var array
*/
public $stdFolders = array ( 'site' , 'admin' , 'media' );
2019-08-08 15:35:58 +00:00
/**
* The standard root files
2020-03-28 13:34:14 +00:00
*
2019-08-08 15:35:58 +00:00
* @ var array
*/
2020-03-28 13:34:14 +00:00
public $stdRootFiles
= array ( 'access.xml' , 'config.xml' , 'controller.php' , 'index.html' ,
2021-12-21 14:44:50 +00:00
'README.txt' );
2019-08-08 15:35:58 +00:00
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* Dynamic File Content
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
2022-12-04 09:23:43 +00:00
* @ deprecated 3.3 Use CFactory :: _ ( 'Content' ) -> _active
2016-02-26 00:20:09 +00:00
*/
public $fileContentDynamic = 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 Component Sales name
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var string
*/
public $componentSalesName ;
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 Backup name
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var string
*/
public $componentBackupName ;
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 Folder name
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var string
*/
public $componentFolderName ;
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 path
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var string
*/
public $componentPath ;
2017-12-14 23:10:47 +00:00
2019-08-04 22:38:53 +00:00
/**
* The Dynamic paths
2020-03-28 13:34:14 +00:00
*
2019-08-04 22:38:53 +00:00
* @ var array
*/
public $dynamicPaths = array ();
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The not new static items
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
*/
public $notNew = array ();
2017-12-14 23:10:47 +00:00
2018-09-25 20:02:48 +00:00
/**
* Update the file content
2020-03-28 13:34:14 +00:00
*
2018-09-25 20:02:48 +00:00
* @ var array
*/
public $updateFileContent = array ();
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The new files
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var array
*/
public $newFiles = 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 Checkin Switch
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ var boolean
*/
public $addCheckin = false ;
2017-12-14 23:10:47 +00:00
2018-02-28 02:27:03 +00:00
/**
* The Move Folders Switch
2020-03-28 13:34:14 +00:00
*
2018-02-28 02:27:03 +00:00
* @ var boolean
*/
public $setMoveFolders = false ;
2017-02-01 13:17:04 +00:00
/**
* The array of last modified dates
2020-03-28 13:34:14 +00:00
*
2017-02-01 13:17:04 +00:00
* @ var array
*/
protected $lastModifiedDate = array ();
2017-12-14 23:10:47 +00:00
2018-03-09 03:26:44 +00:00
/**
* The default view switch
2020-03-28 13:34:14 +00:00
*
2018-03-09 03:26:44 +00:00
* @ var bool / string
*/
public $dynamicDashboard = false ;
2020-04-23 21:15:07 +00:00
/**
* The default view type
*
* @ var string
*/
public $dynamicDashboardType ;
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
{
2023-01-22 00:38:21 +00:00
// first we run the parent constructor
2022-08-30 15:28:41 +00:00
if ( parent :: __construct ())
2017-10-12 00:50:14 +00:00
{
2019-08-08 15:35:58 +00:00
// set the standard admin file
2023-01-22 00:38:21 +00:00
$this -> stdRootFiles [] = CFactory :: _ ( 'Component' ) -> get ( 'name_code' ) . '.php' ;
2018-09-25 20:02:48 +00:00
// set incase no extra admin folder are loaded
2022-12-04 09:23:43 +00:00
CFactory :: _ ( 'Content' ) -> set ( 'EXSTRA_ADMIN_FOLDERS' , '' );
2018-09-25 20:02:48 +00:00
// set incase no extra site folder are loaded
2022-12-04 09:23:43 +00:00
CFactory :: _ ( 'Content' ) -> set ( 'EXSTRA_SITE_FOLDERS' , '' );
2018-09-25 20:02:48 +00:00
// set incase no extra media folder are loaded
2022-12-04 09:23:43 +00:00
CFactory :: _ ( 'Content' ) -> set ( 'EXSTRA_MEDIA_FOLDERS' , '' );
2018-09-25 20:02:48 +00:00
// set incase no extra admin files are loaded
2022-12-04 09:23:43 +00:00
CFactory :: _ ( 'Content' ) -> set ( 'EXSTRA_ADMIN_FILES' , '' );
2018-09-25 20:02:48 +00:00
// set incase no extra site files are loaded
2022-12-04 09:23:43 +00:00
CFactory :: _ ( 'Content' ) -> set ( 'EXSTRA_SITE_FILES' , '' );
2018-09-25 20:02:48 +00:00
// set incase no extra media files are loaded
2022-12-04 09:23:43 +00:00
CFactory :: _ ( 'Content' ) -> set ( 'EXSTRA_MEDIA_FILES' , '' );
2016-02-26 00:20:09 +00:00
// set the template path
2022-08-30 15:28:41 +00:00
$this -> templatePath = CFactory :: _ ( 'Config' ) -> get ( 'compiler_path' , JPATH_COMPONENT_ADMINISTRATOR . '/compiler' ) . '/joomla_'
2023-01-22 00:38:21 +00:00
. CFactory :: _ ( 'Config' ) -> joomla_versions [ CFactory :: _ ( 'Config' ) -> joomla_version ][ 'folder_key' ];
2016-02-26 00:20:09 +00:00
// set some default names
2020-03-28 13:34:14 +00:00
$this -> componentSalesName = 'com_'
2023-01-22 00:38:21 +00:00
. CFactory :: _ ( 'Component' ) -> get ( 'sales_name' ) . '__J'
2022-08-30 15:28:41 +00:00
. CFactory :: _ ( 'Config' ) -> joomla_version ;
2020-03-28 13:34:14 +00:00
$this -> componentBackupName = 'com_'
2023-01-22 00:38:21 +00:00
. CFactory :: _ ( 'Component' ) -> get ( 'sales_name' ) . '_v' . str_replace (
'.' , '_' , ( string ) CFactory :: _ ( 'Component' ) -> get ( 'component_version' )
2022-08-30 15:28:41 +00:00
) . '__J' . CFactory :: _ ( 'Config' ) -> joomla_version ;
2020-03-28 13:34:14 +00:00
$this -> componentFolderName = 'com_'
2023-01-22 00:38:21 +00:00
. CFactory :: _ ( 'Component' ) -> get ( 'name_code' ) . '_v' . str_replace (
'.' , '_' , ( string ) CFactory :: _ ( 'Component' ) -> get ( 'component_version' )
2022-08-30 15:28:41 +00:00
) . '__J' . CFactory :: _ ( 'Config' ) -> joomla_version ;
2016-02-26 00:20:09 +00:00
// set component folder path
2022-08-30 15:28:41 +00:00
$this -> componentPath = CFactory :: _ ( 'Config' ) -> get ( 'compiler_path' , JPATH_COMPONENT_ADMINISTRATOR . '/compiler' ) . '/'
2020-03-28 13:34:14 +00:00
. $this -> componentFolderName ;
2016-02-26 00:20:09 +00:00
// set the template path for custom
2020-03-28 13:34:14 +00:00
$this -> templatePathCustom = $this -> params -> get (
'custom_folder_path' , JPATH_COMPONENT_ADMINISTRATOR . '/custom'
);
2016-02-26 00:20:09 +00:00
// make sure there is no old build
$this -> removeFolder ( $this -> componentPath );
2017-12-12 00:28:35 +00:00
// load the libraries files/folders and url's
2019-08-04 22:38:53 +00:00
$this -> setLibraries ();
2021-12-21 14:44:50 +00:00
// load the powers files/folders
$this -> buildPowers ();
2019-12-06 05:31:32 +00:00
// load the module files/folders and url's
$this -> buildModules ();
2019-08-04 22:38:53 +00:00
// load the plugin files/folders and url's
2019-08-22 01:54:47 +00:00
$this -> buildPlugins ();
2017-12-12 00:28:35 +00:00
// set the Joomla Version Data
2017-12-14 23:10:47 +00:00
$this -> joomlaVersionData = $this -> setJoomlaVersionData ();
2023-01-15 08:42:19 +00:00
// for plugin event TODO change event api signatures
$component_context = CFactory :: _ ( 'Config' ) -> component_context ;
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onAfterSetJoomlaVersionData
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2020-03-28 13:34:14 +00:00
'jcb_ce_onAfterSetJoomlaVersionData' ,
2023-01-15 08:42:19 +00:00
array ( & $component_context , & $this -> joomlaVersionData )
2020-03-28 13:34:14 +00:00
);
2018-03-09 03:26:44 +00:00
// set the dashboard
$this -> setDynamicDashboard ();
2016-02-26 00:20:09 +00:00
// set the new folders
if ( ! $this -> setFolders ())
{
return false ;
}
// set all static folders and files
if ( ! $this -> setStatic ())
{
return false ;
}
// set all the dynamic folders and files
if ( ! $this -> setDynamique ())
{
return false ;
}
2020-03-28 13:34:14 +00:00
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
2021-12-21 14:44:50 +00:00
/**
* Build the Powers files , folders
*
* @ return void
*
*/
private function buildPowers ()
{
2022-08-30 15:28:41 +00:00
if ( ArrayHelper :: check ( CFactory :: _ ( 'Power' ) -> active ))
2021-12-21 14:44:50 +00:00
{
2022-08-30 15:28:41 +00:00
// for plugin event TODO change event api signatures
$this -> powers = CFactory :: _ ( 'Power' ) -> active ;
2023-01-15 08:42:19 +00:00
$component_context = CFactory :: _ ( 'Config' ) -> component_context ;
2021-12-21 14:44:50 +00:00
// Trigger Event: jcb_ce_onBeforeSetModules
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2021-12-21 14:44:50 +00:00
'jcb_ce_onBeforeBuildPowers' ,
2023-01-15 08:42:19 +00:00
array ( & $component_context , & $this -> powers )
2021-12-21 14:44:50 +00:00
);
2022-08-30 15:28:41 +00:00
// for plugin event TODO change event api signatures
CFactory :: _ ( 'Power' ) -> active = $this -> powers ;
2021-12-21 14:44:50 +00:00
// we track the creation of htaccess files
$htaccess = array ();
2022-08-30 15:28:41 +00:00
foreach ( CFactory :: _ ( 'Power' ) -> active as $power )
2021-12-21 14:44:50 +00:00
{
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check ( $power )
2021-12-21 14:44:50 +00:00
&& isset ( $power -> path )
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2021-12-21 14:44:50 +00:00
$power -> path
))
{
2022-06-02 12:05:34 +00:00
// activate dynamic folders
$this -> setDynamicFolders ();
2021-12-21 14:44:50 +00:00
// power path
$power -> full_path = $this -> componentPath . '/'
. $power -> path ;
$power -> full_path_jcb = $this -> componentPath . '/'
. $power -> path_jcb ;
$power -> full_path_parent = $this -> componentPath . '/'
. $power -> path_parent ;
// set the power paths
$this -> dynamicPaths [ $power -> key ] = $power -> full_path_parent ;
// create the power folder if it does not exist
// we do it like this to add html files to each part
$this -> createFolder ( $power -> full_path_jcb );
$this -> createFolder ( $power -> full_path_parent );
$this -> createFolder ( $power -> full_path );
// set power file
$fileDetails = array ( 'path' => $power -> full_path . '/'
. $power -> file_name . '.php' ,
'name' => $power -> file_name . '.php' ,
'zip' => $power -> file_name . '.php' );
2022-09-20 11:06:03 +00:00
$bom = '<?php' . PHP_EOL . '// A POWER FILE' .
PHP_EOL . Placefix :: _h ( 'BOM' ) . PHP_EOL ;
// add custom override if found
if ( $power -> add_licensing_template == 2 )
{
$bom = '<?php' . PHP_EOL . $power -> licensing_template ;
}
2021-12-21 14:44:50 +00:00
$this -> writeFile (
$fileDetails [ 'path' ],
2022-09-20 11:06:03 +00:00
$bom . PHP_EOL . Placefix :: _h ( 'POWERCODE' )
2021-12-21 14:44:50 +00:00
);
$this -> newFiles [ $power -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2021-12-21 14:44:50 +00:00
if ( ! isset ( $htaccess [ $power -> path_jcb ]))
{
// set the htaccess data
$data = '# Apache 2.4+' . PHP_EOL .
'<IfModule mod_authz_core.c>' . PHP_EOL .
' Require all denied' . PHP_EOL .
'</IfModule>' . PHP_EOL . PHP_EOL .
'# Apache 2.0-2.2' . PHP_EOL .
'<IfModule !mod_authz_core.c>' . PHP_EOL .
' Deny from all' . PHP_EOL .
'</IfModule>' . PHP_EOL ;
// now we must add the .htaccess file
$fileDetails = array ( 'path' => $power -> full_path_jcb . '/.htaccess' ,
'name' => '.htaccess' ,
'zip' => '.htaccess' );
$this -> writeFile (
$fileDetails [ 'path' ], $data
);
$this -> newFiles [ $power -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2021-12-21 14:44:50 +00:00
// now we must add the htaccess.txt file where the zip package my not get the [.] files
$fileDetails = array ( 'path' => $power -> full_path_jcb . '/htaccess.txt' ,
'name' => 'htaccess.txt' ,
'zip' => 'htaccess.txt' );
$this -> writeFile (
$fileDetails [ 'path' ], $data
);
$this -> newFiles [ $power -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2021-12-21 14:44:50 +00:00
// now we must add the web.config file
$fileDetails = array ( 'path' => $power -> full_path_jcb . '/web.config' ,
'name' => 'web.config' ,
'zip' => 'web.config' );
$this -> writeFile (
$fileDetails [ 'path' ],
'<?xml version="1.0"?>' . PHP_EOL .
' <system.web>' . PHP_EOL .
' <authorization>' . PHP_EOL .
' <deny users="*" />' . PHP_EOL .
' </authorization>' . PHP_EOL .
' </system.web>' . PHP_EOL .
'</configuration>' . PHP_EOL
);
$this -> newFiles [ $power -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2021-12-21 14:44:50 +00:00
// we set these files only once
$htaccess [ $power -> path_jcb ] = true ;
}
}
}
}
}
2019-12-06 05:31:32 +00:00
/**
* Build the Modules files , folders , url ' s and config
*
* @ return void
*
*/
private function buildModules ()
{
2023-01-22 00:38:21 +00:00
if ( CFactory :: _ ( 'Joomlamodule.Data' ) -> exists ())
2019-12-06 05:31:32 +00:00
{
2023-01-15 08:42:19 +00:00
// for plugin event TODO change event api signatures
$component_context = CFactory :: _ ( 'Config' ) -> component_context ;
2023-01-22 00:38:21 +00:00
$modules = CFactory :: _ ( 'Joomlamodule.Data' ) -> get ();
2019-12-06 05:31:32 +00:00
// Trigger Event: jcb_ce_onBeforeSetModules
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2020-03-28 13:34:14 +00:00
'jcb_ce_onBeforeBuildModules' ,
2023-01-22 00:38:21 +00:00
array ( & $component_context , & $modules )
2020-03-28 13:34:14 +00:00
);
2023-01-22 00:38:21 +00:00
foreach ( $modules as $module )
2019-12-06 05:31:32 +00:00
{
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check ( $module )
2020-03-28 13:34:14 +00:00
&& isset ( $module -> folder_name )
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$module -> folder_name
))
2019-12-06 05:31:32 +00:00
{
// module path
2022-08-30 15:28:41 +00:00
$module -> folder_path = CFactory :: _ ( 'Config' ) -> get ( 'compiler_path' , JPATH_COMPONENT_ADMINISTRATOR . '/compiler' ) . '/'
2020-03-28 13:34:14 +00:00
. $module -> folder_name ;
2019-12-06 05:31:32 +00:00
// set the module paths
$this -> dynamicPaths [ $module -> key ] = $module -> folder_path ;
// make sure there is no old build
$this -> removeFolder ( $module -> folder_path );
2020-12-05 06:17:54 +00:00
// creat the main module folder
$this -> createFolder ( $module -> folder_path );
2019-12-06 05:31:32 +00:00
// set main mod file
2020-03-28 13:34:14 +00:00
$fileDetails = array ( 'path' => $module -> folder_path . '/'
. $module -> file_name . '.php' ,
'name' => $module -> file_name . '.php' ,
'zip' => $module -> file_name . '.php' );
$this -> writeFile (
$fileDetails [ 'path' ],
2019-12-06 05:31:32 +00:00
'<?php' . PHP_EOL . '// main modfile' .
2022-08-30 15:28:41 +00:00
PHP_EOL . Placefix :: _h ( 'BOM' ) . PHP_EOL .
2019-12-06 05:31:32 +00:00
PHP_EOL . '// No direct access to this file' . PHP_EOL .
2020-03-28 13:34:14 +00:00
" defined('_JEXEC') or die('Restricted access'); "
. PHP_EOL .
2022-08-30 15:28:41 +00:00
Placefix :: _h ( 'MODCODE' )
2020-03-28 13:34:14 +00:00
);
2019-12-06 05:31:32 +00:00
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-12-06 05:31:32 +00:00
// set custom_get
if ( $module -> custom_get )
{
2020-03-28 13:34:14 +00:00
$fileDetails = array ( 'path' => $module -> folder_path
. '/data.php' ,
'name' => 'data.php' ,
'zip' => 'data.php' );
$this -> writeFile (
$fileDetails [ 'path' ],
2019-12-06 05:31:32 +00:00
'<?php' . PHP_EOL . '// get data file' .
2022-08-30 15:28:41 +00:00
PHP_EOL . Placefix :: _h ( 'BOM' ) . PHP_EOL
2020-03-28 13:34:14 +00:00
.
PHP_EOL . '// No direct access to this file'
. PHP_EOL .
" defined('_JEXEC') or die('Restricted access'); "
. PHP_EOL . PHP_EOL .
2019-12-06 05:31:32 +00:00
'/**' . PHP_EOL .
2020-03-28 13:34:14 +00:00
' * Module ' . $module -> official_name . ' Data'
. PHP_EOL .
2019-12-06 05:31:32 +00:00
' */' . PHP_EOL .
2020-03-28 13:34:14 +00:00
" class " . $module -> class_data_name
. ' extends \JObject' . PHP_EOL .
2022-08-30 15:28:41 +00:00
" { " . Placefix :: _h ( 'DYNAMICGETS' ) . " } "
2020-03-28 13:34:14 +00:00
. PHP_EOL
);
2019-12-06 05:31:32 +00:00
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-12-06 05:31:32 +00:00
}
// set helper file
if ( $module -> add_class_helper >= 1 )
{
2020-03-28 13:34:14 +00:00
$fileDetails = array ( 'path' => $module -> folder_path
. '/helper.php' ,
'name' => 'helper.php' ,
'zip' => 'helper.php' );
$this -> writeFile (
$fileDetails [ 'path' ],
2019-12-06 05:31:32 +00:00
'<?php' . PHP_EOL . '// helper file' .
2022-08-30 15:28:41 +00:00
PHP_EOL . Placefix :: _h ( 'BOM' ) . PHP_EOL
2020-03-28 13:34:14 +00:00
.
PHP_EOL . '// No direct access to this file'
. PHP_EOL .
" defined('_JEXEC') or die('Restricted access'); "
. PHP_EOL .
2022-08-30 15:28:41 +00:00
Placefix :: _h ( 'HELPERCODE' )
2020-03-28 13:34:14 +00:00
);
2019-12-06 05:31:32 +00:00
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-12-06 05:31:32 +00:00
}
// set main xml file
2020-03-28 13:34:14 +00:00
$fileDetails = array ( 'path' => $module -> folder_path . '/'
. $module -> file_name . '.xml' ,
'name' => $module -> file_name . '.xml' ,
'zip' => $module -> file_name . '.xml' );
$this -> writeFile (
$fileDetails [ 'path' ],
$this -> getModuleXMLTemplate ( $module )
);
2019-12-06 05:31:32 +00:00
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-12-06 05:31:32 +00:00
// set tmpl folder
2020-12-05 06:17:54 +00:00
$this -> createFolder ( $module -> folder_path . '/tmpl' );
2019-12-06 05:31:32 +00:00
// set default file
2020-03-28 13:34:14 +00:00
$fileDetails = array ( 'path' => $module -> folder_path
. '/tmpl/default.php' ,
'name' => 'default.php' ,
'zip' => 'tmpl/default.php' );
$this -> writeFile (
$fileDetails [ 'path' ],
2019-12-06 05:31:32 +00:00
'<?php' . PHP_EOL . '// default tmpl' .
2022-08-30 15:28:41 +00:00
PHP_EOL . Placefix :: _h ( 'BOM' ) . PHP_EOL .
2019-12-06 05:31:32 +00:00
PHP_EOL . '// No direct access to this file' . PHP_EOL .
2020-03-28 13:34:14 +00:00
" defined('_JEXEC') or die('Restricted access'); "
. PHP_EOL .
2022-08-30 15:28:41 +00:00
Placefix :: _h ( 'MODDEFAULT' )
2020-03-28 13:34:14 +00:00
);
2019-12-06 05:31:32 +00:00
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-12-06 05:31:32 +00:00
// set install script if needed
if ( $module -> add_install_script )
{
2020-03-28 13:34:14 +00:00
$fileDetails = array ( 'path' => $module -> folder_path
. '/script.php' ,
'name' => 'script.php' ,
'zip' => 'script.php' );
$this -> writeFile (
$fileDetails [ 'path' ],
2019-12-06 05:31:32 +00:00
'<?php' . PHP_EOL . '// Script template' .
2022-08-30 15:28:41 +00:00
PHP_EOL . Placefix :: _h ( 'BOM' ) . PHP_EOL
2020-03-28 13:34:14 +00:00
.
PHP_EOL . '// No direct access to this file'
. PHP_EOL .
" defined('_JEXEC') or die('Restricted access'); "
. PHP_EOL .
2022-08-30 15:28:41 +00:00
Placefix :: _h ( 'INSTALLCLASS' )
2020-03-28 13:34:14 +00:00
);
2019-12-06 05:31:32 +00:00
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-12-06 05:31:32 +00:00
}
// set readme if found
if ( $module -> addreadme )
{
2020-03-28 13:34:14 +00:00
$fileDetails = array ( 'path' => $module -> folder_path
. '/README.md' ,
'name' => 'README.md' ,
'zip' => 'README.md' );
2019-12-06 05:31:32 +00:00
$this -> writeFile ( $fileDetails [ 'path' ], $module -> readme );
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-12-06 05:31:32 +00:00
}
2020-12-05 06:17:54 +00:00
// set the folders target path
$target_path = '' ;
if ( $module -> target_client === 'administrator' )
2019-12-06 05:31:32 +00:00
{
2020-12-05 06:17:54 +00:00
$target_path = '/administrator' ;
}
// check if we have custom fields needed for scripts
$module -> add_scripts_field = false ;
$field_script_bucket = array ();
// add any css from the fields
2022-08-31 11:49:01 +00:00
if (( $css = CFactory :: _ ( 'Customcode.Dispenser' ) -> get (
2020-12-05 06:17:54 +00:00
'css_view' , $module -> key
)) !== null
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $css ))
2020-12-05 06:17:54 +00:00
{
// make sure this script does not have PHP
2023-01-01 02:11:34 +00:00
if ( strpos (( string ) $css , '<?php' ) === false )
2019-12-06 05:31:32 +00:00
{
2020-12-05 06:17:54 +00:00
// make sure the field is added
$module -> add_scripts_field = true ;
// create the css folder
$this -> createFolder ( $module -> folder_path . '/css' );
// add the CSS file
$fileDetails = array ( 'path' => $module -> folder_path
. '/css/mod_admin.css' ,
'name' => 'mod_admin.css' ,
'zip' => 'mod_admin.css' );
$this -> writeFile (
$fileDetails [ 'path' ],
2022-08-30 15:28:41 +00:00
Placefix :: _h ( 'BOM' ) . PHP_EOL
2020-12-05 06:17:54 +00:00
. PHP_EOL . $css
2020-03-28 13:34:14 +00:00
);
2020-12-05 06:17:54 +00:00
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2020-12-05 06:17:54 +00:00
// add the field script
2022-08-30 15:28:41 +00:00
$field_script_bucket [] = Indent :: _ ( 2 ) . " // "
. Line :: _ ( __Line__ , __Class__ ) . " Custom CSS " ;
$field_script_bucket [] = Indent :: _ ( 2 )
2020-12-05 06:17:54 +00:00
. " \$ document->addStyleSheet(' " . $target_path
. " /modules/ " . $module -> folder_name
. " /css/mod_admin.css', ['version' => 'auto', 'relative' => true]); " ;
2019-12-06 05:31:32 +00:00
}
2020-12-05 06:17:54 +00:00
}
// add any JavaScript from the fields
2022-08-31 11:49:01 +00:00
if (( $javascript = CFactory :: _ ( 'Customcode.Dispenser' ) -> get (
2020-12-05 06:17:54 +00:00
'view_footer' , $module -> key
)) !== null
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $javascript ))
2020-12-05 06:17:54 +00:00
{
// make sure this script does not have PHP
2023-01-01 02:11:34 +00:00
if ( strpos (( string ) $javascript , '<?php' ) === false )
2019-12-06 05:31:32 +00:00
{
2020-12-05 06:17:54 +00:00
// make sure the field is added
$module -> add_scripts_field = true ;
// add the JavaScript file
$this -> createFolder ( $module -> folder_path . '/js' );
// add the CSS file
$fileDetails = array ( 'path' => $module -> folder_path
. '/js/mod_admin.js' ,
'name' => 'mod_admin.js' ,
'zip' => 'mod_admin.js' );
$this -> writeFile (
$fileDetails [ 'path' ],
2022-08-30 15:28:41 +00:00
Placefix :: _h ( 'BOM' ) . PHP_EOL
2020-12-05 06:17:54 +00:00
. PHP_EOL . $javascript
2020-03-28 13:34:14 +00:00
);
2020-12-05 06:17:54 +00:00
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2020-12-05 06:17:54 +00:00
// add the field script
2022-08-30 15:28:41 +00:00
$field_script_bucket [] = Indent :: _ ( 2 ) . " // "
. Line :: _ ( __Line__ , __Class__ ) . " Custom JS " ;
$field_script_bucket [] = Indent :: _ ( 2 )
2020-12-05 06:17:54 +00:00
. " \$ document->addScript(' " . $target_path
. " /modules/ " . $module -> folder_name
. " /js/mod_admin.js', ['version' => 'auto', 'relative' => true]); " ;
2019-12-06 05:31:32 +00:00
}
}
2020-12-05 06:17:54 +00:00
// set fields folders if needed
if ( $module -> add_scripts_field
|| ( isset ( $module -> fields_rules_paths )
&& $module -> fields_rules_paths == 2 ))
{
// create fields folder
$this -> createFolder ( $module -> folder_path . '/fields' );
// add the custom script field
if ( $module -> add_scripts_field )
{
$fileDetails = array ( 'path' => $module -> folder_path
. '/fields/modadminvvvvvvvdm.php' ,
'name' => 'modadminvvvvvvvdm.php' ,
'zip' => 'modadminvvvvvvvdm.php' );
$this -> writeFile (
$fileDetails [ 'path' ],
$this -> getModAdminVvvvvvvdm (
$field_script_bucket
)
);
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2020-12-05 06:17:54 +00:00
}
}
// set rules folders if needed
if ( isset ( $module -> fields_rules_paths )
&& $module -> fields_rules_paths == 2 )
{
// create rules folder
$this -> createFolder ( $module -> folder_path . '/rules' );
}
2019-12-06 05:31:32 +00:00
// set forms folder if needed
2020-03-28 13:34:14 +00:00
if ( isset ( $module -> form_files )
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$module -> form_files
))
2019-12-06 05:31:32 +00:00
{
// create forms folder
2020-12-05 06:17:54 +00:00
$this -> createFolder ( $module -> folder_path . '/forms' );
2019-12-06 05:31:32 +00:00
// set the template files
2020-03-28 13:34:14 +00:00
foreach ( $module -> form_files as $file => $fields )
2019-12-06 05:31:32 +00:00
{
// set file details
2020-03-28 13:34:14 +00:00
$fileDetails = array ( 'path' => $module -> folder_path
. '/forms/' . $file . '.xml' ,
'name' => $file . '.xml' ,
'zip' => 'forms/' . $file
. '.xml' );
2020-12-05 06:17:54 +00:00
// build basic XML
2019-12-06 05:31:32 +00:00
$xml = '<?xml version="1.0" encoding="utf-8"?>' ;
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . '<!--' . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. ' default paths of ' . $file
2023-01-15 08:42:19 +00:00
. ' form points to ' . CFactory :: _ ( 'Config' ) -> component_code_name
2020-03-28 13:34:14 +00:00
. ' -->' ;
2019-12-06 05:31:32 +00:00
// search if we must add the component path
$add_component_path = false ;
foreach ( $fields as $field_name => $fieldsets )
{
if ( ! $add_component_path )
{
foreach ( $fieldsets as $fieldset => $field )
{
2020-03-28 13:34:14 +00:00
if ( ! $add_component_path
&& isset (
$module -> fieldsets_paths [ $file
. $field_name . $fieldset ]
)
&& $module -> fieldsets_paths [ $file
. $field_name . $fieldset ] == 1 )
2019-12-06 05:31:32 +00:00
{
$add_component_path = true ;
}
}
}
}
// only add if part of the component field types path is required
if ( $add_component_path )
{
$xml .= PHP_EOL . '<form' ;
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. 'addrulepath="/administrator/components/com_'
2022-08-30 15:28:41 +00:00
. CFactory :: _ ( 'Config' ) -> component_code_name
2020-03-28 13:34:14 +00:00
. '/models/rules"' ;
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. 'addfieldpath="/administrator/components/com_'
2022-08-30 15:28:41 +00:00
. CFactory :: _ ( 'Config' ) -> component_code_name
2020-03-28 13:34:14 +00:00
. '/models/fields"' ;
2019-12-06 05:31:32 +00:00
$xml .= PHP_EOL . '>' ;
}
else
{
$xml .= PHP_EOL . '<form>' ;
}
// add the fields
foreach ( $fields as $field_name => $fieldsets )
{
// check if we have an double fields naming set
$field_name_inner = '' ;
$field_name_outer = $field_name ;
2023-01-01 02:11:34 +00:00
if ( strpos (( string ) $field_name , '.' ) !== false )
2019-12-06 05:31:32 +00:00
{
2023-01-01 02:11:34 +00:00
$field_names = explode ( '.' , ( string ) $field_name );
2019-12-06 05:31:32 +00:00
if ( count (( array ) $field_names ) == 2 )
{
$field_name_outer = $field_names [ 0 ];
$field_name_inner = $field_names [ 1 ];
}
}
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. '<fields name="' . $field_name_outer
. '">' ;
2019-12-06 05:31:32 +00:00
foreach ( $fieldsets as $fieldset => $field )
{
// default to the field set name
$label = $fieldset ;
2022-02-04 17:21:10 +00:00
if ( isset ( $module -> fieldsets_label [ $file . $field_name . $fieldset ]))
2019-12-06 05:31:32 +00:00
{
2022-02-04 17:21:10 +00:00
$label = $module -> fieldsets_label [ $file . $field_name . $fieldset ];
}
// add path to module rules and custom fields
if ( isset ( $module -> fieldsets_paths [ $file . $field_name . $fieldset ])
&& ( $module -> fieldsets_paths [ $file . $field_name . $fieldset ] == 2
|| $module -> fieldsets_paths [ $file . $field_name . $fieldset ] == 3 ))
{
if ( $module -> target == 2 )
{
if ( ! isset ( $module -> add_rule_path [ $file . $field_name . $fieldset ]))
{
$module -> add_rule_path [ $file . $field_name . $fieldset ] =
'/administrator/modules/'
. $module -> file_name . '/rules' ;
}
if ( ! isset ( $module -> add_field_path [ $file . $field_name . $fieldset ]))
{
$module -> add_field_path [ $file . $field_name . $fieldset ] =
'/administrator/modules/'
. $module -> file_name . '/fields' ;
}
}
else
{
if ( ! isset ( $module -> add_rule_path [ $file . $field_name . $fieldset ]))
{
$module -> add_rule_path [ $file . $field_name . $fieldset ] =
'/modules/' . $module -> file_name
. '/rules' ;
}
if ( ! isset ( $module -> add_field_path [ $file . $field_name . $fieldset ]))
{
$module -> add_field_path [ $file . $field_name . $fieldset ] =
'/modules/' . $module -> file_name
. '/fields' ;
}
}
2019-12-06 05:31:32 +00:00
}
// add path to module rules and custom fields
2022-02-04 17:21:10 +00:00
if ( isset ( $module -> add_rule_path [ $file . $field_name . $fieldset ])
|| isset ( $module -> add_field_path [ $file . $field_name . $fieldset ]))
2019-12-06 05:31:32 +00:00
{
2022-02-04 17:21:10 +00:00
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<!--'
. Line :: _ ( __Line__ , __Class__ ) . ' default paths of '
2022-02-04 17:21:10 +00:00
. $fieldset . ' fieldset points to the module -->' ;
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<fieldset name="'
2022-02-04 17:21:10 +00:00
. $fieldset . '" label="' . $label . '"' ;
if ( isset ( $module -> add_rule_path [ $file . $field_name . $fieldset ]))
{
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 2 )
2022-02-04 17:21:10 +00:00
. 'addrulepath="' . $module -> add_rule_path [ $file . $field_name . $fieldset ] . '"' ;
}
if ( isset ( $module -> add_field_path [ $file . $field_name . $fieldset ]))
{
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 2 )
2022-02-04 17:21:10 +00:00
. 'addfieldpath="' . $module -> add_field_path [ $file . $field_name . $fieldset ] . '"' ;
}
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '>' ;
2019-12-06 05:31:32 +00:00
}
else
{
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<fieldset name="'
2022-02-04 17:21:10 +00:00
. $fieldset . '" label="' . $label . '">' ;
2019-12-06 05:31:32 +00:00
}
// check if we have an inner field set
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check (
2020-03-28 13:34:14 +00:00
$field_name_inner
))
2019-12-06 05:31:32 +00:00
{
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. '<fields name="'
. $field_name_inner . '">' ;
2019-12-06 05:31:32 +00:00
}
// add the placeholder of the fields
2022-08-30 15:28:41 +00:00
$xml .= Placefix :: _h ( 'FIELDSET_' . $file
. $field_name . $fieldset );
2019-12-06 05:31:32 +00:00
// check if we have an inner field set
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check (
2020-03-28 13:34:14 +00:00
$field_name_inner
))
2019-12-06 05:31:32 +00:00
{
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. '</fields>' ;
2019-12-06 05:31:32 +00:00
}
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. '</fieldset>' ;
2019-12-06 05:31:32 +00:00
}
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '</fields>' ;
2019-12-06 05:31:32 +00:00
}
$xml .= PHP_EOL . '</form>' ;
// add xml to file
$this -> writeFile ( $fileDetails [ 'path' ], $xml );
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-12-06 05:31:32 +00:00
}
}
// set SQL stuff if needed
if ( $module -> add_sql || $module -> add_sql_uninstall )
{
// create SQL folder
2020-12-05 06:17:54 +00:00
$this -> createFolder ( $module -> folder_path . '/sql' );
2019-12-06 05:31:32 +00:00
// create mysql folder
2020-12-05 06:17:54 +00:00
$this -> createFolder (
2020-03-28 13:34:14 +00:00
$module -> folder_path . '/sql/mysql'
2020-12-05 06:17:54 +00:00
);
2019-12-06 05:31:32 +00:00
// now set the install file
if ( $module -> add_sql )
{
2020-03-28 13:34:14 +00:00
$this -> writeFile (
$module -> folder_path . '/sql/mysql/install.sql' ,
$module -> sql
);
2019-12-06 05:31:32 +00:00
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-12-06 05:31:32 +00:00
}
// now set the uninstall file
if ( $module -> add_sql_uninstall )
{
2020-03-28 13:34:14 +00:00
$this -> writeFile (
$module -> folder_path
. '/sql/mysql/uninstall.sql' ,
$module -> sql_uninstall
);
2019-12-06 05:31:32 +00:00
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-12-06 05:31:32 +00:00
}
}
// creat the language folder
2020-12-05 06:17:54 +00:00
$this -> createFolder ( $module -> folder_path . '/language' );
// also create the lang tag folder
$this -> createFolder (
2022-08-30 15:28:41 +00:00
$module -> folder_path . '/language/' . CFactory :: _ ( 'Config' ) -> get ( 'lang_tag' , 'en-GB' )
2020-12-05 06:17:54 +00:00
);
2019-12-06 05:31:32 +00:00
// check if this lib has files
2020-03-28 13:34:14 +00:00
if ( isset ( $module -> files )
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check ( $module -> files ))
2019-12-06 05:31:32 +00:00
{
// add to component files
foreach ( $module -> files as $file )
{
2023-01-22 00:38:21 +00:00
// set the pathfinder
2020-03-28 13:34:14 +00:00
$file [ 'target_type' ] = $module -> target_type ;
$file [ 'target_id' ] = $module -> id ;
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Component' ) -> appendArray ( 'files' , $file );
2019-12-06 05:31:32 +00:00
}
}
// check if this lib has folders
2020-03-28 13:34:14 +00:00
if ( isset ( $module -> folders )
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check ( $module -> folders ))
2019-12-06 05:31:32 +00:00
{
// add to component folders
foreach ( $module -> folders as $folder )
{
2023-01-22 00:38:21 +00:00
// set the pathfinder
2020-03-28 13:34:14 +00:00
$folder [ 'target_type' ] = $module -> target_type ;
$folder [ 'target_id' ] = $module -> id ;
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Component' ) -> appendArray ( 'folders' , $folder );
2019-12-06 05:31:32 +00:00
}
}
// check if this module has urls
2020-03-28 13:34:14 +00:00
if ( isset ( $module -> urls )
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check ( $module -> urls ))
2019-12-06 05:31:32 +00:00
{
// add to component urls
foreach ( $module -> urls as $n => & $url )
{
// should we add the local folder
2020-03-28 13:34:14 +00:00
if ( isset ( $url [ 'type' ]) && $url [ 'type' ] > 1
&& isset ( $url [ 'url' ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$url [ 'url' ]
))
2019-12-06 05:31:32 +00:00
{
// set file name
2023-01-01 02:11:34 +00:00
$fileName = basename (( string ) $url [ 'url' ]);
2019-12-06 05:31:32 +00:00
// get the file contents
2022-04-04 15:35:08 +00:00
$data = FileHelper :: getContent (
2020-03-28 13:34:14 +00:00
$url [ 'url' ]
);
2019-12-06 05:31:32 +00:00
// build sub path
if ( strpos ( $fileName , '.js' ) !== false )
{
$path = '/js' ;
}
elseif ( strpos ( $fileName , '.css' ) !== false )
{
$path = '/css' ;
}
else
{
$path = '' ;
}
// create sub media path if not set
2020-12-05 06:17:54 +00:00
$this -> createFolder (
2020-03-28 13:34:14 +00:00
$module -> folder_path . $path
2020-12-05 06:17:54 +00:00
);
2019-12-06 05:31:32 +00:00
// set the path to module file
2020-03-28 13:34:14 +00:00
$url [ 'path' ] = $module -> folder_path . $path
. '/' . $fileName ; // we need this for later
2019-12-06 05:31:32 +00:00
// write data to path
$this -> writeFile ( $url [ 'path' ], $data );
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-12-06 05:31:32 +00:00
}
}
}
}
}
}
}
2019-08-04 22:38:53 +00:00
/**
* Build the Plugins files , folders , url ' s and config
2020-03-28 13:34:14 +00:00
*
2019-08-04 22:38:53 +00:00
* @ return void
2020-03-28 13:34:14 +00:00
*
2019-08-04 22:38:53 +00:00
*/
2019-08-22 01:54:47 +00:00
private function buildPlugins ()
2019-08-04 22:38:53 +00:00
{
2023-01-22 00:38:21 +00:00
if ( CFactory :: _ ( 'Joomlaplugin.Data' ) -> exists ())
2019-08-04 22:38:53 +00:00
{
2023-01-15 08:42:19 +00:00
// for plugin event TODO change event api signatures
$component_context = CFactory :: _ ( 'Config' ) -> component_context ;
2023-01-22 00:38:21 +00:00
$plugins = CFactory :: _ ( 'Joomlaplugin.Data' ) -> get ();
2019-08-04 22:38:53 +00:00
// Trigger Event: jcb_ce_onBeforeSetPlugins
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2020-03-28 13:34:14 +00:00
'jcb_ce_onBeforeBuildPlugins' ,
2023-01-22 00:38:21 +00:00
array ( & $component_context , & $plugins )
2020-03-28 13:34:14 +00:00
);
2023-01-22 00:38:21 +00:00
foreach ( $plugins as $plugin )
2019-08-04 22:38:53 +00:00
{
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check ( $plugin )
2020-03-28 13:34:14 +00:00
&& isset ( $plugin -> folder_name )
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$plugin -> folder_name
))
2019-08-04 22:38:53 +00:00
{
// plugin path
2022-08-30 15:28:41 +00:00
$plugin -> folder_path = CFactory :: _ ( 'Config' ) -> get ( 'compiler_path' , JPATH_COMPONENT_ADMINISTRATOR . '/compiler' ) . '/'
2020-03-28 13:34:14 +00:00
. $plugin -> folder_name ;
2019-08-04 22:38:53 +00:00
// set the plugin paths
$this -> dynamicPaths [ $plugin -> key ] = $plugin -> folder_path ;
// make sure there is no old build
$this -> removeFolder ( $plugin -> folder_path );
// creat the main component folder
2020-12-05 06:17:54 +00:00
$this -> createFolder ( $plugin -> folder_path );
2019-08-04 22:38:53 +00:00
// set main class file
2020-03-28 13:34:14 +00:00
$fileDetails = array ( 'path' => $plugin -> folder_path . '/'
. $plugin -> file_name . '.php' ,
'name' => $plugin -> file_name . '.php' ,
'zip' => $plugin -> file_name . '.php' );
$this -> writeFile (
$fileDetails [ 'path' ],
2019-08-08 15:35:58 +00:00
'<?php' . PHP_EOL . '// Plugin main class template' .
2022-08-30 15:28:41 +00:00
PHP_EOL . Placefix :: _h ( 'BOM' ) . PHP_EOL .
2019-08-08 15:35:58 +00:00
PHP_EOL . '// No direct access to this file' . PHP_EOL .
2020-03-28 13:34:14 +00:00
" defined('_JEXEC') or die('Restricted access'); "
. PHP_EOL .
2022-08-30 15:28:41 +00:00
Placefix :: _h ( 'MAINCLASS' )
2020-03-28 13:34:14 +00:00
);
2019-08-04 22:38:53 +00:00
$this -> newFiles [ $plugin -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-08-04 22:38:53 +00:00
// set main xml file
2020-03-28 13:34:14 +00:00
$fileDetails = array ( 'path' => $plugin -> folder_path . '/'
. $plugin -> file_name . '.xml' ,
'name' => $plugin -> file_name . '.xml' ,
'zip' => $plugin -> file_name . '.xml' );
$this -> writeFile (
$fileDetails [ 'path' ],
$this -> getPluginXMLTemplate ( $plugin )
);
2019-08-04 22:38:53 +00:00
$this -> newFiles [ $plugin -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-08-04 22:38:53 +00:00
// set install script if needed
if ( $plugin -> add_install_script )
{
2020-03-28 13:34:14 +00:00
$fileDetails = array ( 'path' => $plugin -> folder_path
. '/script.php' ,
'name' => 'script.php' ,
'zip' => 'script.php' );
$this -> writeFile (
$fileDetails [ 'path' ],
2019-08-08 15:35:58 +00:00
'<?php' . PHP_EOL . '// Script template' .
2022-08-30 15:28:41 +00:00
PHP_EOL . Placefix :: _h ( 'BOM' ) . PHP_EOL
2020-03-28 13:34:14 +00:00
.
PHP_EOL . '// No direct access to this file'
. PHP_EOL .
" defined('_JEXEC') or die('Restricted access'); "
. PHP_EOL .
2022-08-30 15:28:41 +00:00
Placefix :: _h ( 'INSTALLCLASS' )
2020-03-28 13:34:14 +00:00
);
2019-08-04 22:38:53 +00:00
$this -> newFiles [ $plugin -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-08-04 22:38:53 +00:00
}
// set readme if found
if ( $plugin -> addreadme )
{
2020-03-28 13:34:14 +00:00
$fileDetails = array ( 'path' => $plugin -> folder_path
. '/README.md' ,
'name' => 'README.md' ,
'zip' => 'README.md' );
2019-08-04 22:38:53 +00:00
$this -> writeFile ( $fileDetails [ 'path' ], $plugin -> readme );
$this -> newFiles [ $plugin -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-08-04 22:38:53 +00:00
}
2019-08-22 01:54:47 +00:00
// set fields & rules folders if needed
2020-03-28 13:34:14 +00:00
if ( isset ( $plugin -> fields_rules_paths )
&& $plugin -> fields_rules_paths == 2 )
2019-08-22 01:54:47 +00:00
{
// create fields folder
2020-12-05 06:17:54 +00:00
$this -> createFolder ( $plugin -> folder_path . '/fields' );
2019-08-22 01:54:47 +00:00
// create rules folder
2020-12-05 06:17:54 +00:00
$this -> createFolder ( $plugin -> folder_path . '/rules' );
2019-08-22 01:54:47 +00:00
}
// set forms folder if needed
2020-03-28 13:34:14 +00:00
if ( isset ( $plugin -> form_files )
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$plugin -> form_files
))
2019-08-22 01:54:47 +00:00
{
// create forms folder
2020-12-05 06:17:54 +00:00
$this -> createFolder ( $plugin -> folder_path . '/forms' );
2019-08-22 01:54:47 +00:00
// set the template files
2020-03-28 13:34:14 +00:00
foreach ( $plugin -> form_files as $file => $fields )
2019-08-22 01:54:47 +00:00
{
// set file details
2020-03-28 13:34:14 +00:00
$fileDetails = array ( 'path' => $plugin -> folder_path
. '/forms/' . $file . '.xml' ,
'name' => $file . '.xml' ,
'zip' => 'forms/' . $file
. '.xml' );
2019-08-22 01:54:47 +00:00
// biuld basic XML
$xml = '<?xml version="1.0" encoding="utf-8"?>' ;
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . '<!--' . Line :: _ ( __Line__ , __Class__ )
2020-03-28 13:34:14 +00:00
. ' default paths of ' . $file
2022-08-30 15:28:41 +00:00
. ' form points to ' . CFactory :: _ ( 'Config' ) -> component_code_name
2020-03-28 13:34:14 +00:00
. ' -->' ;
2019-12-03 02:17:35 +00:00
// search if we must add the component path
$add_component_path = false ;
foreach ( $fields as $field_name => $fieldsets )
{
if ( ! $add_component_path )
{
foreach ( $fieldsets as $fieldset => $field )
{
2020-03-28 13:34:14 +00:00
if ( ! $add_component_path
&& isset (
$plugin -> fieldsets_paths [ $file
. $field_name . $fieldset ]
)
&& $plugin -> fieldsets_paths [ $file
. $field_name . $fieldset ] == 1 )
2019-12-03 02:17:35 +00:00
{
$add_component_path = true ;
}
}
}
}
// only add if part of the component field types path is required
if ( $add_component_path )
{
$xml .= PHP_EOL . '<form' ;
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. 'addrulepath="/administrator/components/com_'
2022-08-30 15:28:41 +00:00
. CFactory :: _ ( 'Config' ) -> component_code_name
2020-03-28 13:34:14 +00:00
. '/models/rules"' ;
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. 'addfieldpath="/administrator/components/com_'
2022-08-30 15:28:41 +00:00
. CFactory :: _ ( 'Config' ) -> component_code_name
2020-03-28 13:34:14 +00:00
. '/models/fields"' ;
2019-12-03 02:17:35 +00:00
$xml .= PHP_EOL . '>' ;
}
else
{
$xml .= PHP_EOL . '<form>' ;
}
// add the fields
2019-08-22 01:54:47 +00:00
foreach ( $fields as $field_name => $fieldsets )
{
2019-10-11 13:41:00 +00:00
// check if we have an double fields naming set
$field_name_inner = '' ;
$field_name_outer = $field_name ;
2023-01-01 02:11:34 +00:00
if ( strpos (( string ) $field_name , '.' ) !== false )
2019-10-11 13:41:00 +00:00
{
2023-01-01 02:11:34 +00:00
$field_names = explode ( '.' , ( string ) $field_name );
2019-10-11 13:41:00 +00:00
if ( count (( array ) $field_names ) == 2 )
{
$field_name_outer = $field_names [ 0 ];
$field_name_inner = $field_names [ 1 ];
}
}
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. '<fields name="' . $field_name_outer
. '">' ;
2019-08-22 01:54:47 +00:00
foreach ( $fieldsets as $fieldset => $field )
{
// default to the field set name
$label = $fieldset ;
2022-02-04 17:21:10 +00:00
if ( isset ( $plugin -> fieldsets_label [ $file . $field_name . $fieldset ]))
{
$label = $plugin -> fieldsets_label [ $file . $field_name . $fieldset ];
}
// add path to plugin rules and custom fields
if ( isset ( $plugin -> fieldsets_paths [ $file . $field_name . $fieldset ])
&& ( $plugin -> fieldsets_paths [ $file . $field_name . $fieldset ] == 2
|| $plugin -> fieldsets_paths [ $file . $field_name . $fieldset ] == 3 ))
2019-08-22 01:54:47 +00:00
{
2022-02-04 17:21:10 +00:00
if ( ! isset ( $plugin -> add_rule_path [ $file . $field_name . $fieldset ]))
{
$plugin -> add_rule_path [ $file . $field_name . $fieldset ] =
2023-01-01 02:11:34 +00:00
'/plugins/' . strtolower (( string ) $plugin -> group
) . '/' . strtolower (( string ) $plugin -> code_name )
2022-02-04 17:21:10 +00:00
. '/rules' ;
}
if ( ! isset ( $plugin -> add_field_path [ $file . $field_name . $fieldset ]))
{
$plugin -> add_field_path [ $file . $field_name . $fieldset ] =
2023-01-01 02:11:34 +00:00
'/plugins/' . strtolower (( string ) $plugin -> group
) . '/' . strtolower (( string ) $plugin -> code_name )
2022-02-04 17:21:10 +00:00
. '/fields' ;
}
2019-08-22 01:54:47 +00:00
}
// add path to plugin rules and custom fields
2022-02-04 17:21:10 +00:00
if ( isset ( $plugin -> add_rule_path [ $file . $field_name . $fieldset ])
|| isset ( $plugin -> add_field_path [ $file . $field_name . $fieldset ]))
2019-08-22 01:54:47 +00:00
{
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<!--'
. Line :: _ ( __Line__ , __Class__ ) . ' default paths of '
2022-02-04 17:21:10 +00:00
. $fieldset . ' fieldset points to the plugin -->' ;
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<fieldset name="'
2022-02-04 17:21:10 +00:00
. $fieldset . '" label="' . $label . '"' ;
if ( isset ( $plugin -> add_rule_path [ $file . $field_name . $fieldset ]))
{
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 2 )
2022-02-04 17:21:10 +00:00
. 'addrulepath="' . $plugin -> add_rule_path [ $file . $field_name . $fieldset ] . '"' ;
}
if ( isset ( $plugin -> add_field_path [ $file . $field_name . $fieldset ]))
{
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 2 )
2022-02-04 17:21:10 +00:00
. 'addfieldpath="' . $plugin -> add_field_path [ $file . $field_name . $fieldset ] . '"' ;
}
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '>' ;
2019-08-22 01:54:47 +00:00
}
else
{
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '<fieldset name="'
2022-02-04 17:21:10 +00:00
. $fieldset . '" label="' . $label . '">' ;
2019-08-22 01:54:47 +00:00
}
2019-10-11 13:41:00 +00:00
// check if we have an inner field set
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check (
2020-03-28 13:34:14 +00:00
$field_name_inner
))
2019-10-11 13:41:00 +00:00
{
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. '<fields name="'
. $field_name_inner . '">' ;
2019-10-11 13:41:00 +00:00
}
2019-08-22 01:54:47 +00:00
// add the placeholder of the fields
2022-08-30 15:28:41 +00:00
$xml .= Placefix :: _h ( 'FIELDSET_' . $file
. $field_name . $fieldset );
2019-10-11 13:41:00 +00:00
// check if we have an inner field set
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check (
2020-03-28 13:34:14 +00:00
$field_name_inner
))
2019-10-11 13:41:00 +00:00
{
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. '</fields>' ;
2019-10-11 13:41:00 +00:00
}
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 )
2020-03-28 13:34:14 +00:00
. '</fieldset>' ;
2019-08-22 01:54:47 +00:00
}
2022-08-30 15:28:41 +00:00
$xml .= PHP_EOL . Indent :: _ ( 1 ) . '</fields>' ;
2019-08-22 01:54:47 +00:00
}
$xml .= PHP_EOL . '</form>' ;
// add xml to file
$this -> writeFile ( $fileDetails [ 'path' ], $xml );
$this -> newFiles [ $plugin -> key ][] = $fileDetails ;
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-08-22 01:54:47 +00:00
}
}
2019-08-04 22:38:53 +00:00
// set SQL stuff if needed
if ( $plugin -> add_sql || $plugin -> add_sql_uninstall )
{
// create SQL folder
2020-12-05 06:17:54 +00:00
$this -> createFolder ( $plugin -> folder_path . '/sql' );
2019-08-04 22:38:53 +00:00
// create mysql folder
2020-12-05 06:17:54 +00:00
$this -> createFolder (
2020-03-28 13:34:14 +00:00
$plugin -> folder_path . '/sql/mysql'
2020-12-05 06:17:54 +00:00
);
2019-08-04 22:38:53 +00:00
// now set the install file
if ( $plugin -> add_sql )
{
2020-03-28 13:34:14 +00:00
$this -> writeFile (
$plugin -> folder_path . '/sql/mysql/install.sql' ,
$plugin -> sql
);
2019-08-04 22:38:53 +00:00
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-08-04 22:38:53 +00:00
}
// now set the uninstall file
if ( $plugin -> add_sql_uninstall )
{
2020-03-28 13:34:14 +00:00
$this -> writeFile (
$plugin -> folder_path
. '/sql/mysql/uninstall.sql' ,
$plugin -> sql_uninstall
);
2019-08-04 22:38:53 +00:00
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-08-04 22:38:53 +00:00
}
}
2020-12-05 06:17:54 +00:00
// creat the language folder path
$this -> createFolder ( $plugin -> folder_path . '/language' );
// also creat the lang tag folder path
$this -> createFolder (
2022-08-30 15:28:41 +00:00
$plugin -> folder_path . '/language/' . CFactory :: _ ( 'Config' ) -> get ( 'lang_tag' , 'en-GB' )
2020-12-05 06:17:54 +00:00
);
2019-08-04 22:38:53 +00:00
// check if this lib has files
2020-03-28 13:34:14 +00:00
if ( isset ( $plugin -> files )
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check ( $plugin -> files ))
2019-08-04 22:38:53 +00:00
{
// add to component files
foreach ( $plugin -> files as $file )
{
// set the path finder
2020-03-28 13:34:14 +00:00
$file [ 'target_type' ] = $plugin -> target_type ;
$file [ 'target_id' ] = $plugin -> id ;
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Component' ) -> appendArray ( 'files' , $file );
2019-08-04 22:38:53 +00:00
}
}
// check if this lib has folders
2020-03-28 13:34:14 +00:00
if ( isset ( $plugin -> folders )
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check ( $plugin -> folders ))
2019-08-04 22:38:53 +00:00
{
// add to component folders
foreach ( $plugin -> folders as $folder )
{
// set the path finder
2020-03-28 13:34:14 +00:00
$folder [ 'target_type' ] = $plugin -> target_type ;
$folder [ 'target_id' ] = $plugin -> id ;
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Component' ) -> appendArray ( 'folders' , $folder );
2019-08-04 22:38:53 +00:00
}
}
// check if this plugin has urls
2020-03-28 13:34:14 +00:00
if ( isset ( $plugin -> urls )
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check ( $plugin -> urls ))
2019-08-04 22:38:53 +00:00
{
// add to component urls
foreach ( $plugin -> urls as $n => & $url )
{
// should we add the local folder
2020-03-28 13:34:14 +00:00
if ( isset ( $url [ 'type' ]) && $url [ 'type' ] > 1
&& isset ( $url [ 'url' ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$url [ 'url' ]
))
2019-08-04 22:38:53 +00:00
{
// set file name
2023-01-01 02:11:34 +00:00
$fileName = basename (( string ) $url [ 'url' ]);
2019-08-04 22:38:53 +00:00
// get the file contents
2022-04-04 15:35:08 +00:00
$data = FileHelper :: getContent (
2020-03-28 13:34:14 +00:00
$url [ 'url' ]
);
2019-08-04 22:38:53 +00:00
// build sub path
if ( strpos ( $fileName , '.js' ) !== false )
{
$path = '/js' ;
}
elseif ( strpos ( $fileName , '.css' ) !== false )
{
$path = '/css' ;
}
else
{
$path = '' ;
}
2020-12-05 06:17:54 +00:00
// create sub media media folder path if not set
$this -> createFolder (
2020-03-28 13:34:14 +00:00
$plugin -> folder_path . $path
2020-12-05 06:17:54 +00:00
);
2019-08-04 22:38:53 +00:00
// set the path to plugin file
2020-03-28 13:34:14 +00:00
$url [ 'path' ] = $plugin -> folder_path . $path
. '/' . $fileName ; // we need this for later
2019-08-04 22:38:53 +00:00
// write data to path
$this -> writeFile ( $url [ 'path' ], $data );
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2019-08-04 22:38:53 +00:00
}
}
}
}
}
}
}
2020-12-05 06:17:54 +00:00
/**
* Create Path if not exist
*
* @ return void
*/
private function createFolder ( $path )
{
// check if the path exist
2021-03-07 21:40:55 +00:00
if ( ! Folder :: exists (
2020-12-05 06:17:54 +00:00
$path
))
{
// create the path
2021-03-07 21:40:55 +00:00
Folder :: create (
2020-12-05 06:17:54 +00:00
$path
);
// count the folder created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> folder ++ ;
2020-12-05 06:17:54 +00:00
// add index.html (boring I know)
$this -> indexHTML (
$path , ''
);
}
}
2017-12-10 19:17:26 +00:00
/**
* Build the Libraries files , folders , url ' s and config
2020-03-28 13:34:14 +00:00
*
2017-12-10 19:17:26 +00:00
* @ return void
2020-03-28 13:34:14 +00:00
*
2017-12-10 19:17:26 +00:00
*/
2019-08-04 22:38:53 +00:00
private function setLibraries ()
2017-12-10 19:17:26 +00:00
{
2023-01-22 00:38:21 +00:00
if (( $libraries_ = CFactory :: _ ( 'Registry' ) -> get ( 'builder.libraries' )) !== null )
2017-12-10 19:17:26 +00:00
{
2023-01-15 08:42:19 +00:00
// for plugin event TODO change event api signatures
$component_context = CFactory :: _ ( 'Config' ) -> component_context ;
2019-08-04 22:38:53 +00:00
// Trigger Event: jcb_ce_onBeforeSetLibraries
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Event' ) -> trigger (
2020-03-28 13:34:14 +00:00
'jcb_ce_onBeforeSetLibraries' ,
2023-01-15 08:42:19 +00:00
array ( & $component_context , & $libraries_ )
2020-03-28 13:34:14 +00:00
);
2017-12-12 00:28:35 +00:00
// creat the main component folder
2021-03-07 21:40:55 +00:00
if ( ! Folder :: exists ( $this -> componentPath ))
2017-12-12 00:28:35 +00:00
{
2021-03-07 21:40:55 +00:00
Folder :: create ( $this -> componentPath );
2017-12-12 00:28:35 +00:00
// count the folder created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> folder ++ ;
2017-12-12 00:28:35 +00:00
$this -> indexHTML ( '' );
}
// create media path if not set
2020-12-05 06:17:54 +00:00
$this -> createFolder ( $this -> componentPath . '/media' );
2023-01-15 08:42:19 +00:00
foreach ( $libraries_ as $id => & $library )
2017-12-10 19:17:26 +00:00
{
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check ( $library ))
2017-12-10 19:17:26 +00:00
{
// check if this lib has files
2020-03-28 13:34:14 +00:00
if ( isset ( $library -> files )
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check ( $library -> files ))
2017-12-10 19:17:26 +00:00
{
// add to component files
foreach ( $library -> files as $file )
{
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Component' ) -> appendArray ( 'files' , $file );
2017-12-10 19:17:26 +00:00
}
}
// check if this lib has folders
2020-03-28 13:34:14 +00:00
if ( isset ( $library -> folders )
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$library -> folders
))
2017-12-10 19:17:26 +00:00
{
// add to component folders
foreach ( $library -> folders as $folder )
{
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Component' ) -> appendArray ( 'folders' , $folder );
2017-12-10 19:17:26 +00:00
}
}
// check if this lib has urls
2020-03-28 13:34:14 +00:00
if ( isset ( $library -> urls )
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check ( $library -> urls ))
2017-12-10 19:17:26 +00:00
{
// build media folder path
2020-03-28 13:34:14 +00:00
$libFolder = strtolower (
preg_replace (
'/\s+/' , '-' ,
2023-01-01 02:11:34 +00:00
( string ) StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$library -> name , 'filename' , ' ' , false
)
)
);
2017-12-12 00:28:35 +00:00
$mediaPath = '/media/' . $libFolder ;
// should we add the local folder
$addLocalFolder = false ;
2017-12-10 19:17:26 +00:00
// add to component urls
foreach ( $library -> urls as $n => & $url )
{
2020-03-28 13:34:14 +00:00
if ( isset ( $url [ 'type' ]) && $url [ 'type' ] > 1
&& isset ( $url [ 'url' ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$url [ 'url' ]
))
2017-12-10 19:17:26 +00:00
{
2017-12-12 00:28:35 +00:00
// create media/lib path if not set
2020-12-05 06:17:54 +00:00
$this -> createFolder (
2020-03-28 13:34:14 +00:00
$this -> componentPath . $mediaPath
2020-12-05 06:17:54 +00:00
);
2017-12-12 00:28:35 +00:00
// add local folder
$addLocalFolder = true ;
// set file name
2023-01-01 02:11:34 +00:00
$fileName = basename (( string ) $url [ 'url' ]);
2017-12-10 19:17:26 +00:00
// get the file contents
2022-04-04 15:35:08 +00:00
$data = FileHelper :: getContent (
2020-03-28 13:34:14 +00:00
$url [ 'url' ]
);
2017-12-10 19:17:26 +00:00
// build sub path
if ( strpos ( $fileName , '.js' ) !== false )
{
$path = '/js' ;
}
elseif ( strpos ( $fileName , '.css' ) !== false )
{
$path = '/css' ;
}
else
{
$path = '' ;
}
// create sub media path if not set
2020-12-05 06:17:54 +00:00
$this -> createFolder (
2020-03-28 13:34:14 +00:00
$this -> componentPath . $mediaPath . $path
2020-12-05 06:17:54 +00:00
);
2017-12-10 19:17:26 +00:00
// set the path to library file
2020-03-28 13:34:14 +00:00
$url [ 'path' ] = $mediaPath . $path . '/'
. $fileName ; // we need this for later
2017-12-10 19:17:26 +00:00
// set full path
$path = $this -> componentPath . $url [ 'path' ];
// write data to path
$this -> writeFile ( $path , $data );
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2017-12-10 19:17:26 +00:00
}
}
2017-12-12 00:28:35 +00:00
// only add if local
if ( $addLocalFolder )
{
2019-08-04 22:38:53 +00:00
// add folder to xml of media folders
2022-12-04 09:23:43 +00:00
CFactory :: _ ( 'Content' ) -> add ( 'EXSTRA_MEDIA_FOLDERS' ,
PHP_EOL . Indent :: _ ( 2 ) . " <folder> "
. $libFolder . " </folder> " );
2017-12-12 00:28:35 +00:00
}
2017-12-10 19:17:26 +00:00
}
2021-12-21 14:44:50 +00:00
// if config fields are found load into component config (avoiding duplicates)
2020-03-28 13:34:14 +00:00
if ( isset ( $library -> how ) && $library -> how > 1
&& isset ( $library -> config )
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check ( $library -> config ))
2017-12-10 19:17:26 +00:00
{
foreach ( $library -> config as $cofig )
{
2020-03-28 13:34:14 +00:00
$found = array_filter (
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Component' ) -> get ( 'config' ),
fn ( $item ) => $item [ 'field' ] == $cofig [ 'field' ]
2020-03-28 13:34:14 +00:00
);
2017-12-10 19:17:26 +00:00
// set the config data if not found
2022-03-09 23:46:45 +00:00
if ( ! ArrayHelper :: check ( $found ))
2017-12-10 19:17:26 +00:00
{
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Component' ) -> appendArray ( 'config' , $cofig );
2017-12-10 19:17:26 +00:00
}
}
}
2023-01-15 08:42:19 +00:00
// update the global value just in case for now
CFactory :: _ ( 'Registry' ) -> set ( " builder.libraries. $id " , $library );
2017-12-10 19:17:26 +00:00
}
}
}
}
2017-12-14 23:10:47 +00:00
2018-03-09 03:26:44 +00:00
/**
* set the dynamic dashboard if set
2020-03-28 13:34:14 +00:00
*
2018-03-09 03:26:44 +00:00
* @ return void
2020-03-28 13:34:14 +00:00
*
2018-03-09 03:26:44 +00:00
*/
private function setDynamicDashboard ()
{
2018-03-10 01:50:09 +00:00
// only add the dynamic dashboard if all checks out
2023-01-22 00:38:21 +00:00
if ( CFactory :: _ ( 'Component' ) -> get ( 'dashboard_type' , 0 ) == 2
&& ( $dashboard_ = CFactory :: _ ( 'Component' ) -> get ( 'dashboard' )) !== null
&& StringHelper :: check ( $dashboard_ )
&& strpos (( string ) $dashboard_ , '_' ) !== false )
2018-03-09 03:26:44 +00:00
{
// set the default view
2023-01-22 00:38:21 +00:00
$getter = explode ( '_' , ( string ) $dashboard_ );
2019-09-05 21:12:56 +00:00
if ( count (( array ) $getter ) == 2 && is_numeric ( $getter [ 1 ]))
2018-03-09 03:26:44 +00:00
{
2018-03-10 01:50:09 +00:00
// the pointers
2022-03-09 23:46:45 +00:00
$t = StringHelper :: safe ( $getter [ 0 ], 'U' );
2018-03-11 02:44:43 +00:00
$id = ( int ) $getter [ 1 ];
2018-03-10 01:50:09 +00:00
// the dynamic stuff
2020-03-28 13:34:14 +00:00
$targets = array ( 'A' => 'admin_views' ,
'C' => 'custom_admin_views' );
$names = array ( 'A' => 'admin view' ,
'C' => 'custom admin view' );
$types = array ( 'A' => 'adminview' , 'C' => 'customadminview' );
$keys = array ( 'A' => 'name_list' , 'C' => 'code' );
2018-03-10 01:50:09 +00:00
// check the target values
if ( isset ( $targets [ $t ]) && $id > 0 )
2018-03-09 03:26:44 +00:00
{
2018-03-11 02:44:43 +00:00
// set the type name
2022-03-09 23:46:45 +00:00
$type_names = StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$targets [ $t ], 'w'
);
2018-03-10 01:50:09 +00:00
// set the dynamic dash
2023-01-22 00:38:21 +00:00
if (( $target_ = CFactory :: _ ( 'Component' ) -> get ( $targets [ $t ])) !== null
&& ArrayHelper :: check ( $target_ ))
2018-03-10 01:50:09 +00:00
{
// search the target views
2020-03-28 13:34:14 +00:00
$dashboard = ( array ) array_filter (
2023-01-22 00:38:21 +00:00
$target_ ,
2020-03-28 13:34:14 +00:00
function ( $view ) use ( $id , $t , $types ) {
if ( isset ( $view [ $types [ $t ]])
&& $id == $view [ $types [ $t ]])
2018-03-18 04:52:07 +00:00
{
return true ;
}
2020-03-28 13:34:14 +00:00
2018-03-18 04:52:07 +00:00
return false ;
2020-03-28 13:34:14 +00:00
}
);
2018-05-17 01:02:11 +00:00
// set dashboard
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $dashboard ))
2018-05-17 01:02:11 +00:00
{
$dashboard = array_values ( $dashboard )[ 0 ];
}
2018-03-10 01:50:09 +00:00
// check if view was found (this should be true)
2020-03-28 13:34:14 +00:00
if ( isset ( $dashboard [ 'settings' ])
&& isset ( $dashboard [ 'settings' ] -> { $keys [ $t ]}))
2018-03-09 03:26:44 +00:00
{
2020-03-28 13:34:14 +00:00
$this -> dynamicDashboard
2022-03-09 23:46:45 +00:00
= StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$dashboard [ 'settings' ] -> { $keys [ $t ]}
);
2020-04-23 21:15:07 +00:00
$this -> dynamicDashboardType
= $targets [ $t ];
2018-03-09 03:26:44 +00:00
}
2018-03-10 01:50:09 +00:00
else
2018-03-09 03:26:44 +00:00
{
2018-03-10 01:50:09 +00:00
// set massage that something is wrong
2020-03-28 13:34:14 +00:00
$this -> app -> enqueueMessage (
JText :: _ ( '<hr /><h3>Dashboard Error</h3>' ),
'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'The <b>%s</b> (<b>%s</b>) is not available in your component! Please insure to only used %s, for a dynamic dashboard, that are still linked to your component.' ,
2023-01-22 00:38:21 +00:00
$names [ $t ], $dashboard_ ,
2020-03-28 13:34:14 +00:00
$type_names
), 'Error'
);
2018-03-09 03:26:44 +00:00
}
2018-03-10 01:50:09 +00:00
}
else
2018-03-09 03:26:44 +00:00
{
2018-03-10 01:50:09 +00:00
// set massage that something is wrong
2020-03-28 13:34:14 +00:00
$this -> app -> enqueueMessage (
JText :: _ ( '<hr /><h3>Dashboard Error</h3>' ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'The <b>%s</b> (<b>%s</b>) is not available in your component! Please insure to only used %s, for a dynamic dashboard, that are still linked to your component.' ,
2023-01-22 00:38:21 +00:00
$names [ $t ], $dashboard_ ,
2020-03-28 13:34:14 +00:00
$type_names
), 'Error'
);
2018-03-09 03:26:44 +00:00
}
}
2018-03-10 01:50:09 +00:00
else
{
// the target value is wrong
2020-03-28 13:34:14 +00:00
$this -> app -> enqueueMessage (
JText :: _ ( '<hr /><h3>Dashboard Error</h3>' ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'The <b>%s</b> value for the dynamic dashboard is invalid.' ,
2023-01-22 00:38:21 +00:00
$dashboard_
2020-03-28 13:34:14 +00:00
), 'Error'
);
2018-03-10 01:50:09 +00:00
}
}
else
{
// the target value is wrong
2020-03-28 13:34:14 +00:00
$this -> app -> enqueueMessage (
JText :: _ ( '<hr /><h3>Dashboard Error</h3>' ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'The <b>%s</b> value for the dynamic dashboard is invalid.' ,
2023-01-22 00:38:21 +00:00
$dashboard_
2020-03-28 13:34:14 +00:00
), 'Error'
);
2018-03-09 03:26:44 +00:00
}
// if default was changed to dynamic dashboard the remove default tab and methods
2022-03-09 23:46:45 +00:00
if ( StringHelper :: check ( $this -> dynamicDashboard ))
2018-03-09 03:26:44 +00:00
{
// dynamic dashboard is used
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Component' ) -> remove ( 'dashboard_tab' );
CFactory :: _ ( 'Component' ) -> remove ( 'php_dashboard_methods' );
2018-03-09 03:26:44 +00:00
}
}
}
2017-12-10 19:17:26 +00:00
/**
* Write data to file
2020-03-28 13:34:14 +00:00
*
2017-12-10 19:17:26 +00:00
* @ return bool true on success
2020-03-28 13:34:14 +00:00
*
2017-12-10 19:17:26 +00:00
*/
public function writeFile ( $path , $data )
{
2022-04-04 15:35:08 +00:00
return FileHelper :: write ( $path , $data );
2017-12-10 19:17:26 +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 Initial Folders
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ return void
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
*/
private function setFolders ()
{
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check (
2020-03-28 13:34:14 +00:00
$this -> joomlaVersionData -> create
))
2016-02-26 00:20:09 +00:00
{
2017-12-12 00:28:35 +00:00
// creat the main component folder
2021-03-07 21:40:55 +00:00
if ( ! Folder :: exists ( $this -> componentPath ))
2016-02-26 00:20:09 +00:00
{
2021-03-07 21:40:55 +00:00
Folder :: create ( $this -> componentPath );
2016-02-26 00:20:09 +00:00
// count the folder created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> folder ++ ;
2016-02-26 00:20:09 +00:00
$this -> indexHTML ( '' );
}
// now build all folders needed for this component
foreach ( $this -> joomlaVersionData -> create as $main => $folders )
{
2020-12-05 06:17:54 +00:00
$this -> createFolder ( $this -> componentPath . '/' . $main );
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check ( $folders ))
2016-02-26 00:20:09 +00:00
{
foreach ( $folders as $sub => $subFolders )
{
2020-12-05 06:17:54 +00:00
$this -> createFolder (
2020-03-28 13:34:14 +00:00
$this -> componentPath . '/' . $main . '/' . $sub
2020-12-05 06:17:54 +00:00
);
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check ( $subFolders ))
2016-02-26 00:20:09 +00:00
{
foreach ( $subFolders as $sub_2 => $subFolders_2 )
{
2020-12-05 06:17:54 +00:00
$this -> createFolder (
2020-03-28 13:34:14 +00:00
$this -> componentPath . '/' . $main . '/'
. $sub . '/' . $sub_2
2020-12-05 06:17:54 +00:00
);
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check (
2020-03-28 13:34:14 +00:00
$subFolders_2
))
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
foreach (
$subFolders_2 as $sub_3 => $subFolders_3
)
2016-02-26 00:20:09 +00:00
{
2020-12-05 06:17:54 +00:00
$this -> createFolder (
2020-03-28 13:34:14 +00:00
$this -> componentPath . '/' . $main
. '/' . $sub . '/' . $sub_2 . '/'
. $sub_3
2020-12-05 06:17:54 +00:00
);
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check (
2020-03-28 13:34:14 +00:00
$subFolders_3
))
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
foreach (
$subFolders_3 as $sub_4 =>
$subFolders_4
)
2016-02-26 00:20:09 +00:00
{
2020-12-05 06:17:54 +00:00
$this -> createFolder (
2020-03-28 13:34:14 +00:00
$this -> componentPath . '/'
. $main . '/' . $sub . '/'
. $sub_2 . '/' . $sub_3
. '/' . $sub_4
2020-12-05 06:17:54 +00:00
);
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check (
2020-03-28 13:34:14 +00:00
$subFolders_4
))
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
foreach (
$subFolders_4 as $sub_5
=> $subFolders_5
)
2016-02-26 00:20:09 +00:00
{
2020-12-05 06:17:54 +00:00
$this -> createFolder (
2020-03-28 13:34:14 +00:00
$this -> componentPath
. '/' . $main . '/'
. $sub . '/'
. $sub_2 . '/'
. $sub_3 . '/'
. $sub_4 . '/'
. $sub_5
2020-12-05 06:17:54 +00:00
);
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check (
2020-03-28 13:34:14 +00:00
$subFolders_5
))
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
foreach (
$subFolders_5 as
$sub_6 =>
$subFolders_6
)
2016-02-26 00:20:09 +00:00
{
2020-12-05 06:17:54 +00:00
$this -> createFolder (
2020-03-28 13:34:14 +00:00
$this -> componentPath
. '/'
. $main
2020-12-05 06:17:54 +00:00
. '/'
. $sub
2020-03-28 13:34:14 +00:00
. '/'
. $sub_2
. '/'
. $sub_3
. '/'
. $sub_4
. '/'
. $sub_5
. '/'
. $sub_6
2020-12-05 06:17:54 +00:00
);
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check (
2020-03-28 13:34:14 +00:00
$subFolders_6
))
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
foreach (
$subFolders_6
as
$sub_7
=>
$subFolders_7
)
2016-02-26 00:20:09 +00:00
{
2020-12-05 06:17:54 +00:00
$this -> createFolder (
2020-03-28 13:34:14 +00:00
$this -> componentPath
. '/'
. $main
. '/'
. $sub
. '/'
. $sub_2
. '/'
. $sub_3
. '/'
. $sub_4
. '/'
. $sub_5
. '/'
. $sub_6
. '/'
. $sub_7
2020-12-05 06:17:54 +00:00
);
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 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
* Set the Static File & Folder
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ return boolean
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
*/
private function setStatic ()
{
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check (
2020-03-28 13:34:14 +00:00
$this -> joomlaVersionData -> move -> static
))
2016-02-26 00:20:09 +00:00
{
2022-08-30 15:28:41 +00:00
$codeName = CFactory :: _ ( 'Config' ) -> component_code_name ;
2020-04-19 00:48:23 +00:00
// TODO needs more looking at this must be dynamic actually
2016-02-26 00:20:09 +00:00
$this -> notNew [] = 'LICENSE.txt' ;
// do license check
2020-03-28 13:34:14 +00:00
$LICENSE = false ;
2023-01-22 00:38:21 +00:00
$licenseChecker = strtolower (( string ) CFactory :: _ ( 'Component' ) -> get ( 'license' , '' ));
2020-03-28 13:34:14 +00:00
if ( strpos ( $licenseChecker , 'gnu' ) !== false
&& strpos (
$licenseChecker , '2'
) !== false
&& ( strpos ( $licenseChecker , 'gpl' ) !== false
|| strpos (
$licenseChecker , 'general public license'
) !== false ))
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
$LICENSE
= true ; // we only add version 2 auto at this time (TODO)
2016-02-26 00:20:09 +00:00
}
// do README check
2017-12-14 23:10:47 +00:00
$README = false ;
2016-02-26 00:20:09 +00:00
// add the README file if needed
2023-01-22 00:38:21 +00:00
if ( CFactory :: _ ( 'Component' ) -> get ( 'addreadme' , false ))
2016-02-26 00:20:09 +00:00
{
$README = true ;
}
// start moving
2020-03-28 13:34:14 +00:00
foreach (
$this -> joomlaVersionData -> move -> static as $ftem => $details
)
2016-02-26 00:20:09 +00:00
{
// set item
$item = $details -> naam ;
// do the file renaming
if ( $details -> rename )
{
2017-02-01 13:17:04 +00:00
if ( $details -> rename === 'new' )
2016-02-26 00:20:09 +00:00
{
$new = $details -> newName ;
}
else
{
2023-01-01 02:11:34 +00:00
$new = str_replace ( $details -> rename , $codeName , ( string ) $item );
2016-02-26 00:20:09 +00:00
}
}
else
{
$new = $item ;
}
// if not gnu/gpl license dont add the LICENSE.txt file
2017-02-01 13:17:04 +00:00
if ( $item === 'LICENSE.txt' && ! $LICENSE )
2016-02-26 00:20:09 +00:00
{
continue ;
}
// if not needed do not add
2020-03-28 13:34:14 +00:00
if (( $item === 'README.md' || $item === 'README.txt' )
&& ! $README )
2016-02-26 00:20:09 +00:00
{
continue ;
}
2019-08-08 15:35:58 +00:00
// check if we have a target value
2019-08-04 22:38:53 +00:00
if ( isset ( $details -> _target ))
{
// set destination path
2020-03-28 13:34:14 +00:00
$zipPath = str_replace (
2023-01-01 02:11:34 +00:00
$details -> _target [ 'type' ] . '/' , '' , ( string ) $details -> path
2020-03-28 13:34:14 +00:00
);
$path = str_replace (
$details -> _target [ 'type' ] . '/' ,
$this -> dynamicPaths [ $details -> _target [ 'key' ]] . '/' ,
2023-01-01 02:11:34 +00:00
( string ) $details -> path
2020-03-28 13:34:14 +00:00
);
2019-08-04 22:38:53 +00:00
}
else
{
// set destination path
2023-01-01 02:11:34 +00:00
$zipPath = str_replace ( 'c0mp0n3nt/' , '' , ( string ) $details -> path );
2020-03-28 13:34:14 +00:00
$path = str_replace (
2023-01-01 02:11:34 +00:00
'c0mp0n3nt/' , $this -> componentPath . '/' , ( string ) $details -> path
2020-03-28 13:34:14 +00:00
);
2019-08-04 22:38:53 +00:00
}
2016-02-26 00:20:09 +00:00
// set the template folder path
2020-03-28 13:34:14 +00:00
$templatePath = ( isset ( $details -> custom ) && $details -> custom )
? (( $details -> custom !== 'full' ) ? $this -> templatePathCustom
. '/' : '' ) : $this -> templatePath . '/' ;
2018-02-28 02:27:03 +00:00
// set the final paths
2023-01-01 02:11:34 +00:00
$currentFullPath = ( preg_match ( '/^[a-z]:/i' , ( string ) $item )) ? $item
2020-03-28 13:34:14 +00:00
: $templatePath . '/' . $item ;
2023-01-01 02:11:34 +00:00
$currentFullPath = str_replace ( '//' , '/' , ( string ) $currentFullPath );
2018-03-18 04:52:07 +00:00
$packageFullPath = str_replace ( '//' , '/' , $path . '/' . $new );
2020-03-28 13:34:14 +00:00
$zipFullPath = str_replace (
'//' , '/' , $zipPath . '/' . $new
);
2018-02-28 02:27:03 +00:00
// now move the file
2017-02-01 13:17:04 +00:00
if ( $details -> type === 'file' )
2016-02-26 00:20:09 +00:00
{
2021-03-07 21:40:55 +00:00
if ( ! File :: exists ( $currentFullPath ))
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
$this -> app -> enqueueMessage (
JText :: _ ( '<hr /><h3>File Path Error</h3>' ), 'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'The file path: <b>%s</b> does not exist, and was not added!' ,
$currentFullPath
), 'Error'
);
2018-02-16 21:53:43 +00:00
}
else
{
2018-09-11 11:15:39 +00:00
// get base name && get the path only
2020-03-28 13:34:14 +00:00
$packageFullPath0nly = str_replace (
basename ( $packageFullPath ), '' , $packageFullPath
);
2018-09-11 11:15:39 +00:00
// check if path exist, if not creat it
2021-03-07 21:40:55 +00:00
if ( ! Folder :: exists ( $packageFullPath0nly ))
2018-09-11 11:15:39 +00:00
{
2021-03-07 21:40:55 +00:00
Folder :: create ( $packageFullPath0nly );
2018-09-11 11:15:39 +00:00
}
2018-02-16 21:53:43 +00:00
// move the file to its place
2021-03-07 21:40:55 +00:00
File :: copy ( $currentFullPath , $packageFullPath );
2018-02-16 21:53:43 +00:00
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2018-02-16 21:53:43 +00:00
// store the new files
if ( ! in_array ( $ftem , $this -> notNew ))
{
2019-08-04 22:38:53 +00:00
if ( isset ( $details -> _target ))
{
2020-03-28 13:34:14 +00:00
$this -> newFiles [ $details -> _target [ 'key' ]][]
= array ( 'path' => $packageFullPath ,
'name' => $new ,
'zip' => $zipFullPath );
2019-08-04 22:38:53 +00:00
}
else
{
2020-03-28 13:34:14 +00:00
$this -> newFiles [ 'static' ][]
= array ( 'path' => $packageFullPath ,
'name' => $new ,
'zip' => $zipFullPath );
2019-08-04 22:38:53 +00:00
}
2018-02-16 21:53:43 +00:00
}
2018-09-25 20:02:48 +00:00
// ensure we update this file if needed
2020-03-28 13:34:14 +00:00
if ( isset ( $this -> updateFileContent [ $ftem ])
&& $this -> updateFileContent [ $ftem ])
2018-09-25 20:02:48 +00:00
{
// remove the pointer
unset ( $this -> updateFileContent [ $ftem ]);
// set the full path
2020-03-28 13:34:14 +00:00
$this -> updateFileContent [ $packageFullPath ]
= $packageFullPath ;
2018-09-25 20:02:48 +00:00
}
2016-02-26 00:20:09 +00:00
}
}
2017-02-01 13:17:04 +00:00
elseif ( $details -> type === 'folder' )
2016-02-26 00:20:09 +00:00
{
2021-03-07 21:40:55 +00:00
if ( ! Folder :: exists ( $currentFullPath ))
2018-02-16 21:53:43 +00:00
{
2020-03-28 13:34:14 +00:00
$this -> app -> enqueueMessage (
JText :: _ ( '<hr /><h3>Folder Path Error</h3>' ),
'Error'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'The folder path: <b>%s</b> does not exist, and was not added!' ,
$currentFullPath
), 'Error'
);
2018-02-16 21:53:43 +00:00
}
else
{
// move the folder to its place
2021-03-07 21:40:55 +00:00
Folder :: copy (
2020-03-28 13:34:14 +00:00
$currentFullPath , $packageFullPath , '' , true
);
2018-02-16 21:53:43 +00:00
// count the folder created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> folder ++ ;
2018-02-16 21:53:43 +00:00
}
2016-02-26 00:20:09 +00:00
}
2019-08-08 15:35:58 +00:00
// only add if no target found since those belong to plugins and modules
2019-08-04 22:38:53 +00:00
if ( ! isset ( $details -> _target ))
2018-02-28 02:27:03 +00:00
{
2018-09-25 20:02:48 +00:00
// check if we should add the dynamic folder moving script to the installer script
2019-08-04 22:38:53 +00:00
$checker = array_values (( array ) explode ( '/' , $zipFullPath ));
// TODO <-- this may not be the best way, will keep an eye on this.
// We basicly only want to check if a folder is added that is not in the stdFolders array
2020-03-28 13:34:14 +00:00
if ( isset ( $checker [ 0 ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $checker [ 0 ])
2019-08-08 15:35:58 +00:00
&& ! in_array ( $checker [ 0 ], $this -> stdFolders ))
2018-09-25 20:02:48 +00:00
{
2022-06-02 12:05:34 +00:00
// activate dynamic folders
$this -> setDynamicFolders ();
2018-09-25 20:02:48 +00:00
}
2020-03-28 13:34:14 +00:00
elseif ( count (( array ) $checker ) == 2
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $checker [ 0 ]))
2018-09-25 20:02:48 +00:00
{
2019-08-08 15:35:58 +00:00
$add_to_extra = false ;
2019-08-04 22:38:53 +00:00
// set the target
$eNAME = 'FILES' ;
$ename = 'filename' ;
2019-08-08 15:35:58 +00:00
// this should not happen and must have been caught by the above if statment
2019-08-04 22:38:53 +00:00
if ( $details -> type === 'folder' )
{
2019-08-08 15:35:58 +00:00
// only folders outside the standard folder are added
2020-03-28 13:34:14 +00:00
$eNAME = 'FOLDERS' ;
$ename = 'folder' ;
2019-08-12 21:30:31 +00:00
$add_to_extra = true ;
2019-08-08 15:35:58 +00:00
}
// if this is a file, it can only be added to the admin/site/media folders
// all other folders are moved as a whole so their files do not need to be declared
2020-03-28 13:34:14 +00:00
elseif ( in_array ( $checker [ 0 ], $this -> stdFolders )
&& ! in_array ( $checker [ 1 ], $this -> stdRootFiles ))
2019-08-08 15:35:58 +00:00
{
$add_to_extra = true ;
2019-08-04 22:38:53 +00:00
}
2019-08-08 15:35:58 +00:00
// add if valid folder/file
if ( $add_to_extra )
2019-08-04 22:38:53 +00:00
{
2019-08-08 15:35:58 +00:00
// set the tab
2022-08-30 15:28:41 +00:00
$eTab = Indent :: _ ( 2 );
2019-08-08 15:35:58 +00:00
if ( 'admin' === $checker [ 0 ])
{
2022-08-30 15:28:41 +00:00
$eTab = Indent :: _ ( 3 );
2019-08-08 15:35:58 +00:00
}
// set the xml file
2022-12-04 09:23:43 +00:00
$key_ = 'EXSTRA_'
. StringHelper :: safe (
$checker [ 0 ], 'U'
) . '_' . $eNAME ;
CFactory :: _ ( 'Content' ) -> add ( $key_ ,
PHP_EOL . $eTab . " < " . $ename . " > "
. $checker [ 1 ] . " </ " . $ename . " > " );
2019-08-04 22:38:53 +00:00
}
2018-02-28 02:27:03 +00:00
}
}
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 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
* Set the Dynamic File & Folder
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
* @ return boolean
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
*/
private function setDynamique ()
{
2020-03-28 13:34:14 +00:00
$back = false ;
2016-02-26 00:20:09 +00:00
$front = false ;
2020-03-28 13:34:14 +00:00
if (( isset ( $this -> joomlaVersionData -> move -> dynamic )
2022-03-09 23:46:45 +00:00
&& ObjectHelper :: check (
2020-03-28 13:34:14 +00:00
$this -> joomlaVersionData -> move -> dynamic
))
2023-01-22 00:38:21 +00:00
&& CFactory :: _ ( 'Component' ) -> isArray ( 'admin_views' ))
2016-02-26 00:20:09 +00:00
{
2022-03-09 23:46:45 +00:00
if ( ! StringHelper :: check ( $this -> dynamicDashboard ))
2018-03-09 03:26:44 +00:00
{
// setup dashboard
2023-01-22 00:38:21 +00:00
$target = array ( 'admin' => CFactory :: _ ( 'Component' ) -> get ( 'name_code' ));
2018-03-09 03:26:44 +00:00
$this -> buildDynamique ( $target , 'dashboard' );
}
2016-02-26 00:20:09 +00:00
// now the rest of the views
2023-01-22 00:38:21 +00:00
foreach ( CFactory :: _ ( 'Component' ) -> get ( 'admin_views' ) as $nr => $view )
2016-02-26 00:20:09 +00:00
{
2022-03-09 23:46:45 +00:00
if ( ObjectHelper :: check ( $view [ 'settings' ]))
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
$created = $this -> getCreatedDate ( $view );
2017-02-01 13:17:04 +00:00
$modified = $this -> getLastModifiedDate ( $view );
2016-02-26 00:20:09 +00:00
if ( $view [ 'settings' ] -> name_list != 'null' )
{
2020-03-28 13:34:14 +00:00
$target
= array ( 'admin' => $view [ 'settings' ] -> name_list );
2022-08-30 15:28:41 +00:00
$config = array ( Placefix :: _h ( 'CREATIONDATE' ) => $created ,
Placefix :: _h ( 'BUILDDATE' ) => $modified ,
Placefix :: _h ( 'VERSION' ) => $view [ 'settings' ] -> version );
2017-12-14 23:10:47 +00:00
$this -> buildDynamique ( $target , 'list' , false , $config );
2016-02-26 00:20:09 +00:00
}
if ( $view [ 'settings' ] -> name_single != 'null' )
{
2020-03-28 13:34:14 +00:00
$target
= array ( 'admin' => $view [ 'settings' ] -> name_single );
2022-08-30 15:28:41 +00:00
$config = array ( Placefix :: _h ( 'CREATIONDATE' ) => $created ,
Placefix :: _h ( 'BUILDDATE' ) => $modified ,
Placefix :: _h ( 'VERSION' ) => $view [ 'settings' ] -> version );
2020-03-28 13:34:14 +00:00
$this -> buildDynamique (
$target , 'single' , false , $config
);
2016-02-26 00:20:09 +00:00
}
2020-03-28 13:34:14 +00:00
if ( isset ( $view [ 'edit_create_site_view' ])
&& is_numeric (
$view [ 'edit_create_site_view' ]
)
&& $view [ 'edit_create_site_view' ] > 0 )
2016-02-26 00:20:09 +00:00
{
// setup the front site edit-view files
2020-03-28 13:34:14 +00:00
$target
= array ( 'site' => $view [ 'settings' ] -> name_single );
2022-08-30 15:28:41 +00:00
$config = array ( Placefix :: _h ( 'CREATIONDATE' ) => $created ,
Placefix :: _h ( 'BUILDDATE' ) => $modified ,
Placefix :: _h ( 'VERSION' ) => $view [ 'settings' ] -> version );
2017-12-14 23:10:47 +00:00
$this -> buildDynamique ( $target , 'edit' , false , $config );
2016-02-26 00:20:09 +00:00
}
}
// quick set of checkin once
2020-03-28 13:34:14 +00:00
if ( isset ( $view [ 'checkin' ]) && $view [ 'checkin' ] == 1
&& ! $this -> addCheckin )
2016-02-26 00:20:09 +00:00
{
// switch to add checking to config
$this -> addCheckin = true ;
}
}
$back = true ;
}
2020-03-28 13:34:14 +00:00
if (( isset ( $this -> joomlaVersionData -> move -> dynamic )
2022-03-09 23:46:45 +00:00
&& ObjectHelper :: check (
2020-03-28 13:34:14 +00:00
$this -> joomlaVersionData -> move -> dynamic
))
2023-01-22 00:38:21 +00:00
&& CFactory :: _ ( 'Component' ) -> isArray ( 'site_views' ))
2016-02-26 00:20:09 +00:00
{
2023-01-22 00:38:21 +00:00
foreach ( CFactory :: _ ( 'Component' ) -> get ( 'site_views' ) as $nr => $view )
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
$created = $this -> getCreatedDate ( $view );
2017-02-01 13:17:04 +00:00
$modified = $this -> getLastModifiedDate ( $view );
2016-02-26 00:20:09 +00:00
if ( $view [ 'settings' ] -> main_get -> gettype == 2 )
{
// set list view
$target = array ( 'site' => $view [ 'settings' ] -> code );
2022-08-30 15:28:41 +00:00
$config = array ( Placefix :: _h ( 'CREATIONDATE' ) => $created ,
Placefix :: _h ( 'BUILDDATE' ) => $modified ,
Placefix :: _h ( 'VERSION' ) => $view [ 'settings' ] -> version );
2017-12-14 23:10:47 +00:00
$this -> buildDynamique ( $target , 'list' , false , $config );
2016-02-26 00:20:09 +00:00
}
elseif ( $view [ 'settings' ] -> main_get -> gettype == 1 )
{
// set single view
$target = array ( 'site' => $view [ 'settings' ] -> code );
2022-08-30 15:28:41 +00:00
$config = array ( Placefix :: _h ( 'CREATIONDATE' ) => $created ,
Placefix :: _h ( 'BUILDDATE' ) => $modified ,
Placefix :: _h ( 'VERSION' ) => $view [ 'settings' ] -> version );
2017-12-14 23:10:47 +00:00
$this -> buildDynamique ( $target , 'single' , false , $config );
2016-02-26 00:20:09 +00:00
}
}
$front = true ;
}
2020-03-28 13:34:14 +00:00
if (( isset ( $this -> joomlaVersionData -> move -> dynamic )
2022-03-09 23:46:45 +00:00
&& ObjectHelper :: check (
2020-03-28 13:34:14 +00:00
$this -> joomlaVersionData -> move -> dynamic
))
2023-01-22 00:38:21 +00:00
&& CFactory :: _ ( 'Component' ) -> isArray ( 'custom_admin_views' ))
2016-02-26 00:20:09 +00:00
{
2023-01-22 00:38:21 +00:00
foreach ( CFactory :: _ ( 'Component' ) -> get ( 'custom_admin_views' ) as $nr => $view )
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
$created = $this -> getCreatedDate ( $view );
2017-02-01 13:17:04 +00:00
$modified = $this -> getLastModifiedDate ( $view );
2016-02-26 00:20:09 +00:00
if ( $view [ 'settings' ] -> main_get -> gettype == 2 )
{
2017-02-02 11:54:07 +00:00
// set list view$view
2016-02-26 00:20:09 +00:00
$target = array ( 'custom_admin' => $view [ 'settings' ] -> code );
2022-08-30 15:28:41 +00:00
$config = array ( Placefix :: _h ( 'CREATIONDATE' ) => $created ,
Placefix :: _h ( 'BUILDDATE' ) => $modified ,
Placefix :: _h ( 'VERSION' ) => $view [ 'settings' ] -> version );
2017-12-14 23:10:47 +00:00
$this -> buildDynamique ( $target , 'list' , false , $config );
2016-02-26 00:20:09 +00:00
}
elseif ( $view [ 'settings' ] -> main_get -> gettype == 1 )
{
// set single view
$target = array ( 'custom_admin' => $view [ 'settings' ] -> code );
2022-08-30 15:28:41 +00:00
$config = array ( Placefix :: _h ( 'CREATIONDATE' ) => $created ,
Placefix :: _h ( 'BUILDDATE' ) => $modified ,
Placefix :: _h ( 'VERSION' ) => $view [ 'settings' ] -> version );
2017-02-01 13:17:04 +00:00
$this -> buildDynamique ( $target , 'single' , false , $config );
2016-02-26 00:20:09 +00:00
}
}
$back = true ;
}
2018-09-10 11:04:52 +00:00
// check if we had success
2016-02-26 00:20:09 +00:00
if ( $back || $front )
{
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
2019-08-22 01:54:47 +00:00
/**
* move the fields and Rules
*
* @ param array $field The field data
* @ param string $path The path to move to
*
* @ return void
*
*/
public function moveFieldsRules ( $field , $path )
{
2020-05-21 23:38:20 +00:00
// check if we have a subform or repeatable field
2020-06-25 19:22:30 +00:00
if ( $field [ 'type_name' ] === 'subform'
|| $field [ 'type_name' ] === 'repeatable' )
2019-08-22 01:54:47 +00:00
{
2020-05-21 23:38:20 +00:00
// since we could have a custom field or rule inside
$this -> moveMultiFieldsRules ( $field , $path );
}
else
{
// check if this is a custom field that should be moved
if ( isset ( $this -> extentionCustomfields [ $field [ 'type_name' ]]))
2019-08-22 01:54:47 +00:00
{
2020-05-21 23:38:20 +00:00
$check = md5 ( $path . 'type' . $field [ 'type_name' ]);
// lets check if we already moved this
if ( ! isset ( $this -> extentionTrackingFilesMoved [ $check ]))
2020-02-13 12:24:13 +00:00
{
2020-05-21 23:38:20 +00:00
// check files exist
2021-03-07 21:40:55 +00:00
if ( File :: exists (
2020-03-28 13:34:14 +00:00
$this -> componentPath . '/admin/models/fields/'
2020-05-21 23:38:20 +00:00
. $field [ 'type_name' ] . '.php'
))
{
// copy the custom field
2021-03-07 21:40:55 +00:00
File :: copy (
2020-05-21 23:38:20 +00:00
$this -> componentPath . '/admin/models/fields/'
. $field [ 'type_name' ] . '.php' ,
$path . '/fields/' . $field [ 'type_name' ] . '.php'
);
}
// stop from doing this again.
$this -> extentionTrackingFilesMoved [ $check ] = true ;
2020-02-13 12:24:13 +00:00
}
2019-08-22 01:54:47 +00:00
}
2020-05-21 23:38:20 +00:00
// check if this has validation that should be moved
2022-09-10 08:16:44 +00:00
if ( CFactory :: _ ( 'Registry' ) -> get ( 'validation.linked.' . $field [ 'field' ]) !== null )
2019-08-22 01:54:47 +00:00
{
2020-05-21 23:38:20 +00:00
$check = md5 (
$path . 'rule'
2022-09-10 08:16:44 +00:00
. CFactory :: _ ( 'Registry' ) -> get ( 'validation.linked.' . $field [ 'field' ])
2020-05-21 23:38:20 +00:00
);
// lets check if we already moved this
if ( ! isset ( $this -> extentionTrackingFilesMoved [ $check ]))
2020-02-13 12:24:13 +00:00
{
2020-05-21 23:38:20 +00:00
// check files exist
2021-03-07 21:40:55 +00:00
if ( File :: exists (
2020-03-28 13:34:14 +00:00
$this -> componentPath . '/admin/models/rules/'
2022-09-10 08:16:44 +00:00
. CFactory :: _ ( 'Registry' ) -> get ( 'validation.linked.' . $field [ 'field' ])
2020-03-28 13:34:14 +00:00
. '.php'
2020-05-21 23:38:20 +00:00
))
{
// copy the custom field
2021-03-07 21:40:55 +00:00
File :: copy (
2020-05-21 23:38:20 +00:00
$this -> componentPath . '/admin/models/rules/'
2022-09-10 08:16:44 +00:00
. CFactory :: _ ( 'Registry' ) -> get ( 'validation.linked.' . $field [ 'field' ])
2020-05-21 23:38:20 +00:00
. '.php' , $path . '/rules/'
2022-09-10 08:16:44 +00:00
. CFactory :: _ ( 'Registry' ) -> get ( 'validation.linked.' . $field [ 'field' ])
2020-05-21 23:38:20 +00:00
. '.php'
);
}
// stop from doing this again.
$this -> extentionTrackingFilesMoved [ $check ] = true ;
2020-02-13 12:24:13 +00:00
}
2020-05-21 23:38:20 +00:00
}
}
}
/**
* move the fields and Rules of multi fields
*
* @ param array $multi_field The field data
2020-06-25 19:22:30 +00:00
* @ param string $path The path to move to
2020-05-21 23:38:20 +00:00
*
* @ return void
*
*/
protected function moveMultiFieldsRules ( $multi_field , $path )
{
// get the fields ids
2020-06-25 19:22:30 +00:00
$ids = array_map (
2020-11-29 00:00:20 +00:00
'trim' ,
explode (
',' ,
2023-01-01 02:11:34 +00:00
( string ) GetHelper :: between (
2020-11-29 00:00:20 +00:00
$multi_field [ 'settings' ] -> xml , 'fields="' , '"'
)
)
2020-06-25 19:22:30 +00:00
);
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $ids ))
2020-05-21 23:38:20 +00:00
{
foreach ( $ids as $id )
{
// setup the field
2020-06-25 19:22:30 +00:00
$field = array ();
2020-05-21 23:38:20 +00:00
$field [ 'field' ] = $id ;
2022-09-10 08:16:44 +00:00
CFactory :: _ ( 'Field' ) -> set ( $field );
2020-05-21 23:38:20 +00:00
// move field and rules if needed
$this -> moveFieldsRules ( $field , $path );
2019-08-22 01:54:47 +00:00
}
}
}
2017-02-02 11:54:07 +00:00
/**
* get the created date of the ( view )
2019-08-22 01:54:47 +00:00
*
2020-03-28 13:34:14 +00:00
* @ param array $view The view values
2019-08-22 01:54:47 +00:00
*
2017-02-02 11:54:07 +00:00
* @ return string Last Modified Date
2019-08-22 01:54:47 +00:00
*
2017-02-02 11:54:07 +00:00
*/
public function getCreatedDate ( $view )
2017-12-14 23:10:47 +00:00
{
2020-03-28 13:34:14 +00:00
if ( isset ( $view [ 'settings' ] -> created )
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $view [ 'settings' ] -> created ))
2017-02-02 11:54:07 +00:00
{
// first set the main date
2023-01-01 02:11:34 +00:00
$date = strtotime (( string ) $view [ 'settings' ] -> created );
2017-02-02 11:54:07 +00:00
}
else
{
// first set the main date
$date = strtotime ( " now " );
}
2020-03-28 13:34:14 +00:00
2017-02-02 11:54:07 +00:00
return JFactory :: getDate ( $date ) -> format ( 'jS F, Y' );
}
2017-12-14 23:10:47 +00:00
2017-02-01 13:17:04 +00:00
/**
* get the last modified date of a MVC ( view )
2019-08-22 01:54:47 +00:00
*
2020-03-28 13:34:14 +00:00
* @ param array $view The view values
2019-08-22 01:54:47 +00:00
*
2017-02-01 13:17:04 +00:00
* @ return string Last Modified Date
2019-08-22 01:54:47 +00:00
*
2017-02-01 13:17:04 +00:00
*/
public function getLastModifiedDate ( $view )
{
2017-05-04 22:34:28 +00:00
// first set the main date
2020-03-28 13:34:14 +00:00
if ( isset ( $view [ 'settings' ] -> modified )
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $view [ 'settings' ] -> modified )
2020-03-28 13:34:14 +00:00
&& '0000-00-00 00:00:00' !== $view [ 'settings' ] -> modified )
2017-02-02 11:54:07 +00:00
{
2023-01-01 02:11:34 +00:00
$date = strtotime (( string ) $view [ 'settings' ] -> modified );
2017-02-02 11:54:07 +00:00
}
else
{
2017-05-04 22:34:28 +00:00
// use todays date
2017-02-02 11:54:07 +00:00
$date = strtotime ( " now " );
}
2017-05-04 22:34:28 +00:00
// search for the last modified date
2017-02-01 13:17:04 +00:00
if ( isset ( $view [ 'adminview' ]))
{
2017-12-14 23:10:47 +00:00
$id = $view [ 'adminview' ] . 'admin' ;
2017-02-01 13:17:04 +00:00
// now check if value has been set
if ( ! isset ( $this -> lastModifiedDate [ $id ]))
{
2020-03-28 13:34:14 +00:00
if ( isset ( $view [ 'settings' ] -> fields )
2022-03-09 23:46:45 +00:00
&& ArrayHelper :: check (
2020-03-28 13:34:14 +00:00
$view [ 'settings' ] -> fields
))
2017-02-01 13:17:04 +00:00
{
foreach ( $view [ 'settings' ] -> fields as $field )
{
2020-03-28 13:34:14 +00:00
if ( isset ( $field [ 'settings' ])
2022-03-09 23:46:45 +00:00
&& ObjectHelper :: check (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ]
)
&& isset ( $field [ 'settings' ] -> modified )
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$field [ 'settings' ] -> modified
)
&& '0000-00-00 00:00:00'
!== $field [ 'settings' ] -> modified )
2017-02-01 13:17:04 +00:00
{
2020-03-28 13:34:14 +00:00
$anotherDate = strtotime (
2023-01-01 02:11:34 +00:00
( string ) $field [ 'settings' ] -> modified
2020-03-28 13:34:14 +00:00
);
2017-02-01 13:17:04 +00:00
if ( $anotherDate > $date )
{
$date = $anotherDate ;
}
}
}
}
}
}
elseif ( isset ( $view [ 'siteview' ]))
2017-12-14 23:10:47 +00:00
{
$id = $view [ 'siteview' ] . 'site' ;
2017-02-01 13:17:04 +00:00
// now check if value has been set
if ( ! isset ( $this -> lastModifiedDate [ $id ]))
{
2020-03-28 13:34:14 +00:00
if ( isset ( $view [ 'settings' ] -> main_get -> modified )
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$view [ 'settings' ] -> main_get -> modified
)
&& '0000-00-00 00:00:00'
!== $view [ 'settings' ] -> main_get -> modified )
2017-02-01 13:17:04 +00:00
{
2020-03-28 13:34:14 +00:00
$anotherDate = strtotime (
2023-01-01 02:11:34 +00:00
( string ) $view [ 'settings' ] -> main_get -> modified
2020-03-28 13:34:14 +00:00
);
2017-02-01 13:17:04 +00:00
if ( $anotherDate > $date )
{
$date = $anotherDate ;
}
}
}
}
elseif ( isset ( $view [ 'customadminview' ]))
2017-12-14 23:10:47 +00:00
{
$id = $view [ 'customadminview' ] . 'customadmin' ;
2017-02-01 13:17:04 +00:00
// now check if value has been set
if ( ! isset ( $this -> lastModifiedDate [ $id ]))
{
2020-03-28 13:34:14 +00:00
if ( isset ( $view [ 'settings' ] -> main_get -> modified )
2022-03-09 23:46:45 +00:00
&& StringHelper :: check (
2020-03-28 13:34:14 +00:00
$view [ 'settings' ] -> main_get -> modified
)
&& '0000-00-00 00:00:00'
!== $view [ 'settings' ] -> main_get -> modified )
2017-02-01 13:17:04 +00:00
{
2020-03-28 13:34:14 +00:00
$anotherDate = strtotime (
2023-01-01 02:11:34 +00:00
( string ) $view [ 'settings' ] -> main_get -> modified
2020-03-28 13:34:14 +00:00
);
2017-02-01 13:17:04 +00:00
if ( $anotherDate > $date )
{
$date = $anotherDate ;
}
}
}
}
// check if ID was found
if ( ! isset ( $id ))
{
$id = md5 ( $date );
}
// now load the date
if ( ! isset ( $this -> lastModifiedDate [ $id ]))
{
$this -> lastModifiedDate [ $id ] = $date ;
}
2017-12-14 23:10:47 +00:00
2020-03-28 13:34:14 +00:00
return JFactory :: getDate ( $this -> lastModifiedDate [ $id ]) -> format (
'jS F, Y'
);
2017-02-01 13:17:04 +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 the Static File & Folder
2017-09-18 00:18:23 +00:00
*
2020-03-28 13:34:14 +00:00
* @ param array $target The main target and name
* @ param string $type The type in the target
* @ param string $fileName The custom file name
* @ param array $cofig to add more data to the files info
2017-09-18 00:18:23 +00:00
*
2016-02-26 00:20:09 +00:00
* @ return boolean
2017-09-18 00:18:23 +00:00
*
2016-02-26 00:20:09 +00:00
*/
2020-03-28 13:34:14 +00:00
public function buildDynamique ( $target , $type , $fileName = false ,
2021-12-21 14:44:50 +00:00
$config = false
)
{
2019-04-14 20:20:01 +00:00
// did we build the files (any number)
$build_status = false ;
// check that we have the target values
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $target ))
2016-02-26 00:20:09 +00:00
{
2019-04-14 20:20:01 +00:00
// search the target
2017-12-14 23:10:47 +00:00
foreach ( $target as $main => $name )
2016-02-26 00:20:09 +00:00
{
// make sure it is lower case
2022-03-09 23:46:45 +00:00
$name = StringHelper :: safe ( $name );
2016-02-26 00:20:09 +00:00
// setup the files
2020-03-28 13:34:14 +00:00
foreach (
$this -> joomlaVersionData -> move -> dynamic -> { $main } as $item =>
$details
)
2016-02-26 00:20:09 +00:00
{
2019-04-14 20:20:01 +00:00
if ( $details -> type === $type )
2016-02-26 00:20:09 +00:00
{
// set destination path
2017-12-14 23:10:47 +00:00
$path = '' ;
2023-01-01 02:11:34 +00:00
if ( strpos (( string ) $details -> path , 'VIEW' ) !== false )
2016-02-26 00:20:09 +00:00
{
2023-01-01 02:11:34 +00:00
$path = str_replace ( 'VIEW' , $name , ( string ) $details -> path );
2016-02-26 00:20:09 +00:00
}
else
{
$path = $details -> path ;
}
2020-06-25 19:22:30 +00:00
// make sure we have component to replace
2023-01-01 02:11:34 +00:00
if ( strpos (( string ) $path , 'c0mp0n3nt' ) !== false )
2020-06-25 19:22:30 +00:00
{
2023-01-01 02:11:34 +00:00
$zipPath = str_replace ( 'c0mp0n3nt/' , '' , ( string ) $path );
2020-06-25 19:22:30 +00:00
$path = str_replace (
2023-01-01 02:11:34 +00:00
'c0mp0n3nt/' , $this -> componentPath . '/' , ( string ) $path
2020-06-25 19:22:30 +00:00
);
}
else
{
$this -> app -> enqueueMessage (
JText :: sprintf (
'<hr /><h3>c0mp0n3nt issue found</h3><p>The path (%s) could not be used.</p>' ,
$path
), 'Error'
);
continue ;
}
2016-02-26 00:20:09 +00:00
// setup the folder
2021-03-07 21:40:55 +00:00
if ( ! Folder :: exists ( $path ))
2016-02-26 00:20:09 +00:00
{
2021-03-07 21:40:55 +00:00
Folder :: create ( $path );
2016-02-26 00:20:09 +00:00
$this -> indexHTML ( $zipPath );
// count the folder created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> folder ++ ;
2016-02-26 00:20:09 +00:00
}
// do the file renaming
if ( $details -> rename )
{
if ( $fileName )
{
2020-03-28 13:34:14 +00:00
$new = str_replace (
2023-01-01 02:11:34 +00:00
$details -> rename , $fileName , ( string ) $item
2020-03-28 13:34:14 +00:00
);
2017-12-14 23:10:47 +00:00
$name = $name . '_' . $fileName ;
2016-02-26 00:20:09 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $details -> rename === 'new' )
2016-02-26 00:20:09 +00:00
{
$new = $details -> newName ;
}
else
{
2020-03-28 13:34:14 +00:00
$new = str_replace (
2023-01-01 02:11:34 +00:00
$details -> rename , $name , ( string ) $item
2020-03-28 13:34:14 +00:00
);
2016-02-26 00:20:09 +00:00
}
}
else
{
$new = $item ;
}
2021-03-07 21:40:55 +00:00
if ( ! File :: exists ( $path . '/' . $new ))
2016-02-26 00:20:09 +00:00
{
// move the file to its place
2021-03-07 21:40:55 +00:00
File :: copy (
2020-03-28 13:34:14 +00:00
$this -> templatePath . '/' . $item ,
2020-06-25 19:22:30 +00:00
$path . '/' . $new
2020-03-28 13:34:14 +00:00
);
2016-02-26 00:20:09 +00:00
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2016-02-26 00:20:09 +00:00
}
2017-02-01 13:17:04 +00:00
// setup array for new file
2020-03-28 13:34:14 +00:00
$newFIle = array ( 'path' => $path . '/' . $new ,
'name' => $new , 'view' => $name ,
'zip' => $zipPath . '/' . $new );
2022-03-09 23:46:45 +00:00
if ( ArrayHelper :: check ( $config ))
2017-02-01 13:17:04 +00:00
{
$newFIle [ 'config' ] = $config ;
}
2016-02-26 00:20:09 +00:00
// store the new files
2017-02-01 13:17:04 +00:00
$this -> newFiles [ 'dynamic' ][ $name ][] = $newFIle ;
2019-04-14 20:20:01 +00:00
// we have build atleast one
$build_status = true ;
2016-02-26 00:20:09 +00:00
}
}
}
}
2020-03-28 13:34:14 +00:00
2019-04-14 20:20:01 +00:00
return $build_status ;
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
* set the Joomla Version Data
*
2020-12-03 00:13:49 +00:00
* @ return object The version data
2019-08-22 01:54:47 +00:00
*
2016-02-26 00:20:09 +00:00
*/
private function setJoomlaVersionData ()
{
2022-03-09 23:46:45 +00:00
// option to load other settings
2022-08-30 15:28:41 +00:00
$custom_settings = $this -> templatePath . '/settings_' . CFactory :: _ ( 'Config' ) -> component_code_name . '.json' ;
2016-02-26 00:20:09 +00:00
// set the version data
2022-03-09 23:46:45 +00:00
if ( File :: exists ( $custom_settings ))
{
$version_data = json_decode (
2023-01-01 02:11:34 +00:00
( string ) FileHelper :: getContent (
2022-03-09 23:46:45 +00:00
$custom_settings
)
);
}
else
{
$version_data = json_decode (
2023-01-01 02:11:34 +00:00
( string ) FileHelper :: getContent (
2022-03-09 23:46:45 +00:00
$this -> templatePath . '/settings.json'
)
);
}
2023-01-15 08:42:19 +00:00
// set some defaults
$uikit = CFactory :: _ ( 'Config' ) -> get ( 'uikit' , 0 );
$footable = CFactory :: _ ( 'Config' ) -> get ( 'footable' , false );
$add_eximport = CFactory :: _ ( 'Config' ) -> get ( 'add_eximport' , false );
2016-02-26 00:20:09 +00:00
// add custom folders
2023-01-22 00:38:21 +00:00
if ( CFactory :: _ ( 'Component' ) -> isArray ( 'folders' )
|| $add_eximport || $uikit || $footable )
2016-02-26 00:20:09 +00:00
{
2023-01-15 08:42:19 +00:00
if ( $add_eximport )
2016-02-26 00:20:09 +00:00
{
// move the import view folder in place
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Component' ) -> appendArray ( 'folders' , array ( 'folder' => 'importViews' ,
2020-03-28 13:34:14 +00:00
'path' => 'admin/views/import' ,
2023-01-22 00:38:21 +00:00
'rename' => 1 ));
2020-04-19 00:48:23 +00:00
// move the phpspreadsheet Folder (TODO we must move this to a library package)
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Component' ) -> appendArray ( 'folders' , array ( 'folderpath' => 'JPATH_LIBRARIES/phpspreadsheet/vendor' ,
2020-06-25 19:22:30 +00:00
'path' => '/libraries/phpspreadsheet/' ,
2023-01-22 00:38:21 +00:00
'rename' => 0 ));
2016-02-26 00:20:09 +00:00
}
2023-01-15 08:42:19 +00:00
// set uikit
if ( 2 == $uikit || 1 == $uikit )
2016-02-26 00:20:09 +00:00
{
// move the UIKIT Folder into place
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Component' ) -> appendArray ( 'folders' , array ( 'folder' => 'uikit-v2' ,
2020-03-28 13:34:14 +00:00
'path' => 'media' ,
2023-01-22 00:38:21 +00:00
'rename' => 0 ));
2017-12-14 23:10:47 +00:00
}
2023-01-15 08:42:19 +00:00
if ( 2 == $uikit || 3 == $uikit )
2017-11-11 04:33:51 +00:00
{
// move the UIKIT-3 Folder into place
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Component' ) -> appendArray ( 'folders' , array ( 'folder' => 'uikit-v3' ,
2020-03-28 13:34:14 +00:00
'path' => 'media' ,
2023-01-22 00:38:21 +00:00
'rename' => 0 ));
2016-02-26 00:20:09 +00:00
}
2023-01-15 08:42:19 +00:00
// set footable
$footable_version = CFactory :: _ ( 'Config' ) -> get ( 'footable_version' , 2 );
if ( $footable && 2 == $footable_version )
2016-02-26 00:20:09 +00:00
{
// move the footable folder into place
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Component' ) -> appendArray ( 'folders' , array ( 'folder' => 'footable-v2' ,
2020-03-28 13:34:14 +00:00
'path' => 'media' ,
2023-01-22 00:38:21 +00:00
'rename' => 0 ));
2016-04-22 12:03:43 +00:00
}
2023-01-15 08:42:19 +00:00
elseif ( $footable && 3 == $footable_version )
2016-04-22 12:03:43 +00:00
{
// move the footable folder into place
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Component' ) -> appendArray ( 'folders' , array ( 'folder' => 'footable-v3' ,
2020-03-28 13:34:14 +00:00
'path' => 'media' ,
2023-01-22 00:38:21 +00:00
'rename' => 0 ));
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
// pointer tracker
$pointer_tracker = 'h' ;
2023-01-22 00:38:21 +00:00
foreach ( CFactory :: _ ( 'Component' ) -> get ( 'folders' ) as $custom )
2016-02-26 00:20:09 +00:00
{
2019-08-04 22:38:53 +00:00
// check type of target type
$_target_type = 'c0mp0n3nt' ;
if ( isset ( $custom [ 'target_type' ]))
{
$_target_type = $custom [ 'target_type' ];
}
2019-03-13 12:20:51 +00:00
// for good practice
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: fixPath (
$custom , array ( 'path' , 'folder' , 'folderpath' )
);
2018-02-16 21:53:43 +00:00
// fix custom path
2020-03-28 13:34:14 +00:00
if ( isset ( $custom [ 'path' ])
2022-03-09 23:46:45 +00:00
&& StringHelper :: check ( $custom [ 'path' ]))
2018-02-16 21:53:43 +00:00
{
2023-01-01 02:11:34 +00:00
$custom [ 'path' ] = trim (( string ) $custom [ 'path' ], '/' );
2018-02-16 21:53:43 +00:00
}
2019-03-13 12:20:51 +00:00
// by default custom path is true
$customPath = 'custom' ;
2018-02-16 21:53:43 +00:00
// set full path if this is a full path folder
2018-03-18 04:52:07 +00:00
if ( ! isset ( $custom [ 'folder' ]) && isset ( $custom [ 'folderpath' ]))
2018-02-16 21:53:43 +00:00
{
2019-03-13 21:07:41 +00:00
// update the dynamic path
2020-03-28 13:34:14 +00:00
$custom [ 'folderpath' ] = $this -> updateDynamicPath (
$custom [ 'folderpath' ]
);
2019-03-13 12:20:51 +00:00
// set the folder path with / if does not have a drive/windows full path
2020-03-28 13:34:14 +00:00
$custom [ 'folder' ] = ( preg_match (
'/^[a-z]:/i' , $custom [ 'folderpath' ]
))
2019-03-13 12:20:51 +00:00
? trim ( $custom [ 'folderpath' ], '/' )
: '/' . trim ( $custom [ 'folderpath' ], '/' );
2018-02-16 21:53:43 +00:00
// remove the file path
unset ( $custom [ 'folderpath' ]);
// triget fullpath
$customPath = 'full' ;
}
2016-02-26 00:20:09 +00:00
// make sure we use the correct name
2023-01-01 02:11:34 +00:00
$pathArray = ( array ) explode ( '/' , ( string ) $custom [ 'path' ]);
2016-02-26 00:20:09 +00:00
$firstFolder = array_values ( $pathArray )[ 0 ];
2020-03-28 13:34:14 +00:00
$lastFolder = end ( $pathArray );
2016-02-26 00:20:09 +00:00
// only rename folder if last has folder name
2017-11-11 04:33:51 +00:00
if ( isset ( $custom [ 'rename' ]) && $custom [ 'rename' ] == 1 )
2016-02-26 00:20:09 +00:00
{
2020-03-28 13:34:14 +00:00
$custom [ 'path' ] = str_replace (
2023-01-01 02:11:34 +00:00
'/' . $lastFolder , '' , ( string ) $custom [ 'path' ]
2020-03-28 13:34:14 +00:00
);
$rename = 'new' ;
$newname = $lastFolder ;
2016-02-26 00:20:09 +00:00
}
2018-02-16 21:53:43 +00:00
elseif ( 'full' === $customPath )
{
// make sure we use the correct name
2023-01-01 02:11:34 +00:00
$folderArray = ( array ) explode ( '/' , ( string ) $custom [ 'folder' ]);
2020-03-28 13:34:14 +00:00
$lastFolder = end ( $folderArray );
$rename = 'new' ;
$newname = $lastFolder ;
2018-02-16 21:53:43 +00:00
}
2016-02-26 00:20:09 +00:00
else
{
$lastFolder = $custom [ 'folder' ];
2020-03-28 13:34:14 +00:00
$rename = false ;
$newname = '' ;
2016-02-26 00:20:09 +00:00
}
2018-09-25 20:02:48 +00:00
// insure we have no duplicates
2022-03-09 23:46:45 +00:00
$key_pointer = StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$custom [ 'folder' ]
) . '_f' . $pointer_tracker ;
2016-02-26 00:20:09 +00:00
$pointer_tracker ++ ;
2018-09-10 11:04:52 +00:00
// fix custom path
2023-01-01 02:11:34 +00:00
$custom [ 'path' ] = ltrim (( string ) $custom [ 'path' ], '/' );
2016-02-26 00:20:09 +00:00
// set new folder to object
2022-03-09 23:46:45 +00:00
$version_data -> move -> static -> { $key_pointer } = new stdClass ();
$version_data -> move -> static -> { $key_pointer } -> naam
2020-03-28 13:34:14 +00:00
= str_replace (
2023-01-01 02:11:34 +00:00
'//' , '/' , ( string ) $custom [ 'folder' ]
2020-03-28 13:34:14 +00:00
);
2022-03-09 23:46:45 +00:00
$version_data -> move -> static -> { $key_pointer } -> path
2020-03-28 13:34:14 +00:00
= $_target_type
. '/' . $custom [ 'path' ];
2022-03-09 23:46:45 +00:00
$version_data -> move -> static -> { $key_pointer } -> rename = $rename ;
$version_data -> move -> static -> { $key_pointer } -> newName = $newname ;
$version_data -> move -> static -> { $key_pointer } -> type = 'folder' ;
$version_data -> move -> static -> { $key_pointer } -> custom
2020-03-28 13:34:14 +00:00
= $customPath ;
2019-08-04 22:38:53 +00:00
// set the target if type and id is found
2020-03-28 13:34:14 +00:00
if ( isset ( $custom [ 'target_id' ])
&& isset ( $custom [ 'target_type' ]))
2019-08-04 22:38:53 +00:00
{
2022-03-09 23:46:45 +00:00
$version_data -> move -> static -> { $key_pointer } -> _target
2020-03-28 13:34:14 +00:00
= array ( 'key' => $custom [ 'target_id' ] . '_'
. $custom [ 'target_type' ],
'type' => $custom [ 'target_type' ]);
2019-08-04 22:38:53 +00:00
}
2016-02-26 00:20:09 +00:00
}
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Component' ) -> remove ( 'folders' );
2016-02-26 00:20:09 +00:00
unset ( $custom );
}
2023-01-15 08:42:19 +00:00
// get the google chart switch
$google_chart = CFactory :: _ ( 'Config' ) -> get ( 'google_chart' , false );
2016-02-26 00:20:09 +00:00
// add custom files
2023-01-22 00:38:21 +00:00
if ( CFactory :: _ ( 'Component' ) -> isArray ( 'files' )
|| $google_chart )
2016-02-26 00:20:09 +00:00
{
2023-01-15 08:42:19 +00:00
if ( $google_chart )
2016-02-26 00:20:09 +00:00
{
// move the google chart files
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Component' ) -> appendArray ( 'files' , array ( 'file' => 'google.jsapi.js' ,
2020-03-28 13:34:14 +00:00
'path' => 'media/js' ,
2023-01-22 00:38:21 +00:00
'rename' => 0 ));
CFactory :: _ ( 'Component' ) -> appendArray ( 'files' , array ( 'file' => 'chartbuilder.php' ,
2020-03-28 13:34:14 +00:00
'path' => 'admin/helpers' ,
2023-01-22 00:38:21 +00:00
'rename' => 0 ));
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
// pointer tracker
$pointer_tracker = 'h' ;
2023-01-22 00:38:21 +00:00
foreach ( CFactory :: _ ( 'Component' ) -> get ( 'files' ) as $custom )
2016-02-26 00:20:09 +00:00
{
2019-08-04 22:38:53 +00:00
// check type of target type
$_target_type = 'c0mp0n3nt' ;
if ( isset ( $custom [ 'target_type' ]))
{
$_target_type = $custom [ 'target_type' ];
}
2019-03-13 12:20:51 +00:00
// for good practice
2020-03-28 13:34:14 +00:00
ComponentbuilderHelper :: fixPath (
$custom , array ( 'path' , 'file' , 'filepath' )
);
2019-03-13 12:20:51 +00:00
// by default custom path is true
2018-02-16 21:53:43 +00:00
$customPath = 'custom' ;
// set full path if this is a full path file
2018-03-18 04:52:07 +00:00
if ( ! isset ( $custom [ 'file' ]) && isset ( $custom [ 'filepath' ]))
2018-02-16 21:53:43 +00:00
{
2019-03-13 21:07:41 +00:00
// update the dynamic path
2020-03-28 13:34:14 +00:00
$custom [ 'filepath' ] = $this -> updateDynamicPath (
$custom [ 'filepath' ]
);
2019-03-13 12:20:51 +00:00
// set the file path with / if does not have a drive/windows full path
2020-03-28 13:34:14 +00:00
$custom [ 'file' ] = ( preg_match (
'/^[a-z]:/i' , $custom [ 'filepath' ]
))
2019-03-13 12:20:51 +00:00
? trim ( $custom [ 'filepath' ], '/' )
: '/' . trim ( $custom [ 'filepath' ], '/' );
2018-02-16 21:53:43 +00:00
// remove the file path
unset ( $custom [ 'filepath' ]);
// triget fullpath
$customPath = 'full' ;
}
2019-08-04 22:38:53 +00:00
// make sure we have not duplicates
2022-03-09 23:46:45 +00:00
$key_pointer = StringHelper :: safe (
2020-03-28 13:34:14 +00:00
$custom [ 'file' ]
) . '_g' . $pointer_tracker ;
2016-02-26 00:20:09 +00:00
$pointer_tracker ++ ;
// set new file to object
2022-03-09 23:46:45 +00:00
$version_data -> move -> static -> { $key_pointer } = new stdClass ();
$version_data -> move -> static -> { $key_pointer } -> naam = str_replace (
2023-01-01 02:11:34 +00:00
'//' , '/' , ( string ) $custom [ 'file' ]
2020-03-28 13:34:14 +00:00
);
2018-04-08 06:12:18 +00:00
// update the dynamic component name placholders in file names
2022-12-11 15:06:13 +00:00
$custom [ 'path' ] = CFactory :: _ ( 'Placeholder' ) -> update_ (
$custom [ 'path' ]
2020-03-28 13:34:14 +00:00
);
2016-02-26 00:20:09 +00:00
// get the path info
2023-01-01 02:11:34 +00:00
$pathInfo = pathinfo (( string ) $custom [ 'path' ]);
2016-02-26 00:20:09 +00:00
if ( isset ( $pathInfo [ 'extension' ]) && $pathInfo [ 'extension' ])
{
2018-02-16 21:53:43 +00:00
$pathInfo [ 'dirname' ] = trim ( $pathInfo [ 'dirname' ], '/' );
// set the info
2022-03-09 23:46:45 +00:00
$version_data -> move -> static -> { $key_pointer } -> path
2020-03-28 13:34:14 +00:00
= $_target_type
. '/' . $pathInfo [ 'dirname' ];
2022-03-09 23:46:45 +00:00
$version_data -> move -> static -> { $key_pointer } -> rename = 'new' ;
$version_data -> move -> static -> { $key_pointer } -> newName
2020-03-28 13:34:14 +00:00
= $pathInfo [ 'basename' ];
2018-02-16 21:53:43 +00:00
}
elseif ( 'full' === $customPath )
{
2018-09-10 11:04:52 +00:00
// fix custom path
2023-01-01 02:11:34 +00:00
$custom [ 'path' ] = ltrim (( string ) $custom [ 'path' ], '/' );
2018-09-10 11:04:52 +00:00
// get file array
2023-01-01 02:11:34 +00:00
$fileArray = ( array ) explode ( '/' , ( string ) $custom [ 'file' ]);
2018-02-16 21:53:43 +00:00
// set the info
2022-03-09 23:46:45 +00:00
$version_data -> move -> static -> { $key_pointer } -> path
2020-03-28 13:34:14 +00:00
= $_target_type
. '/' . $custom [ 'path' ];
2022-03-09 23:46:45 +00:00
$version_data -> move -> static -> { $key_pointer } -> rename = 'new' ;
$version_data -> move -> static -> { $key_pointer } -> newName = end (
2020-03-28 13:34:14 +00:00
$fileArray
);
2016-02-26 00:20:09 +00:00
}
else
{
2018-02-16 21:53:43 +00:00
// fix custom path
2023-01-01 02:11:34 +00:00
$custom [ 'path' ] = ltrim (( string ) $custom [ 'path' ], '/' );
2018-02-16 21:53:43 +00:00
// set the info
2022-03-09 23:46:45 +00:00
$version_data -> move -> static -> { $key_pointer } -> path
2020-03-28 13:34:14 +00:00
= $_target_type
. '/' . $custom [ 'path' ];
2022-03-09 23:46:45 +00:00
$version_data -> move -> static -> { $key_pointer } -> rename = false ;
2016-02-26 00:20:09 +00:00
}
2022-03-09 23:46:45 +00:00
$version_data -> move -> static -> { $key_pointer } -> type = 'file' ;
$version_data -> move -> static -> { $key_pointer } -> custom
2020-03-28 13:34:14 +00:00
= $customPath ;
2019-08-04 22:38:53 +00:00
// set the target if type and id is found
2020-03-28 13:34:14 +00:00
if ( isset ( $custom [ 'target_id' ])
&& isset ( $custom [ 'target_type' ]))
2019-08-04 22:38:53 +00:00
{
2022-03-09 23:46:45 +00:00
$version_data -> move -> static -> { $key_pointer } -> _target
2020-03-28 13:34:14 +00:00
= array ( 'key' => $custom [ 'target_id' ] . '_'
. $custom [ 'target_type' ],
'type' => $custom [ 'target_type' ]);
2019-08-04 22:38:53 +00:00
}
2016-02-26 00:20:09 +00:00
// check if file should be updated
2020-03-28 13:34:14 +00:00
if ( ! isset ( $custom [ 'notnew' ]) || $custom [ 'notnew' ] == 0
|| $custom [ 'notnew' ] != 1 )
2016-02-26 00:20:09 +00:00
{
$this -> notNew [] = $key_pointer ;
}
2018-09-25 20:02:48 +00:00
else
{
// update the file content
$this -> updateFileContent [ $key_pointer ] = true ;
}
2016-02-26 00:20:09 +00:00
}
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Component' ) -> remove ( 'files' );
2016-02-26 00:20:09 +00:00
unset ( $custom );
}
2020-03-28 13:34:14 +00:00
2022-03-09 23:46:45 +00:00
return $version_data ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
2022-06-02 12:05:34 +00:00
/**
* Add the dynamic folders
*/
protected function setDynamicFolders ()
{
// check if we should add the dynamic folder moving script to the installer script
if ( ! $this -> setMoveFolders )
{
// add the setDynamicF0ld3rs() method to the install scipt.php file
$this -> setMoveFolders = true ;
// set message that this was done (will still add a tutorial link later)
$this -> app -> enqueueMessage (
JText :: _ (
'<hr /><h3>Dynamic folder(s) were detected.</h3>'
), 'Notice'
);
$this -> app -> enqueueMessage (
JText :: sprintf (
'A method (setDynamicF0ld3rs) was added to the install <b>script.php</b> of this package to insure that the folder(s) are copied into the correct place when this component is installed!'
), 'Notice'
);
}
}
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* set the index . html file in a folder path
2019-08-22 01:54:47 +00:00
*
2020-03-28 13:34:14 +00:00
* @ param string $path The path to place the index . html file in
2016-02-26 00:20:09 +00:00
*
* @ return void
2019-08-22 01:54:47 +00:00
*
2016-02-26 00:20:09 +00:00
*/
2019-08-04 22:38:53 +00:00
private function indexHTML ( $path , $root = 'component' )
2016-02-26 00:20:09 +00:00
{
2019-08-04 22:38:53 +00:00
if ( 'component' === $root )
{
2020-12-05 06:17:54 +00:00
$root = $this -> componentPath . '/' ;
2019-08-04 22:38:53 +00:00
}
// use path if exist
2016-02-26 00:20:09 +00:00
if ( strlen ( $path ) > 0 )
{
2021-03-07 21:40:55 +00:00
File :: copy (
2020-03-28 13:34:14 +00:00
$this -> templatePath . '/index.html' ,
2020-12-05 06:17:54 +00:00
$root . $path . '/index.html'
2020-03-28 13:34:14 +00:00
);
2016-02-26 00:20:09 +00:00
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2016-02-26 00:20:09 +00:00
}
else
{
2021-03-07 21:40:55 +00:00
File :: copy (
2020-03-28 13:34:14 +00:00
$this -> templatePath . '/index.html' , $root . '/index.html'
);
2016-02-26 00:20:09 +00:00
// count the file created
2023-01-22 00:38:21 +00:00
CFactory :: _ ( 'Counter' ) -> file ++ ;
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
2018-02-28 02:27:03 +00:00
/**
* Update paths with real value
2020-03-28 13:34:14 +00:00
*
* @ param string $path The full path
2018-02-28 02:27:03 +00:00
*
* @ return string The updated path
2020-03-28 13:34:14 +00:00
*
2018-02-28 02:27:03 +00:00
*/
protected function updateDynamicPath ( $path )
{
2022-12-11 15:06:13 +00:00
return CFactory :: _ ( 'Placeholder' ) -> update_ (
2022-08-30 15:28:41 +00:00
CFactory :: _ ( 'Placeholder' ) -> update (
2020-03-28 13:34:14 +00:00
$path , ComponentbuilderHelper :: $constantPaths
2022-12-11 15:06:13 +00:00
)
2020-03-28 13:34:14 +00:00
);
2018-02-28 02:27:03 +00:00
}
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* Remove folders with files
2020-03-28 13:34:14 +00:00
*
2017-09-18 00:18:23 +00:00
* @ param string $dir The path to folder to remove
* @ param boolean $ignore The files and folders to ignore
2016-02-26 00:20:09 +00:00
*
2017-03-20 22:07:14 +00:00
* @ return boolean True if all is removed
2020-03-28 13:34:14 +00:00
*
2016-02-26 00:20:09 +00:00
*/
2017-09-18 00:18:23 +00:00
protected function removeFolder ( $dir , $ignore = false )
2016-02-26 00:20:09 +00:00
{
2017-09-18 00:18:23 +00:00
return ComponentbuilderHelper :: removeFolder ( $dir , $ignore );
2016-02-26 00:20:09 +00:00
}
2018-03-18 04:52:07 +00:00
2016-02-26 00:20:09 +00:00
}