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
* @ author Llewellyn van der Merwe < http :// www . joomlacomponentbuilder . com >
* @ github Joomla Component Builder < https :// github . com / vdm - io / Joomla - Component - Builder >
2019-03-04 12:47:28 +00:00
* @ copyright Copyright ( C ) 2015 - 2019 Vast Development Method . All rights reserved .
2018-05-18 06:28:27 +00:00
* @ license GNU General Public License version 2 or later ; see LICENSE . txt
*/
2016-02-26 00:20:09 +00:00
// No direct access to this file
defined ( '_JEXEC' ) or die ( 'Restricted access' );
/**
* Structure class
*/
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
2016-02-26 00:20:09 +00:00
*
* @ var int
*/
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
2016-02-26 00:20:09 +00:00
*
* @ var int
*/
public $fileCount = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The page counter
*
* @ var int
*/
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
*
* @ var int
*/
public $lineCount = 0 ;
2017-12-14 23:10:47 +00:00
2017-12-14 13:30:21 +00:00
/**
* The field counter
*
* @ var int
*/
public $fieldCount = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The seconds counter
*
* @ var int
*/
public $seconds = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The actual seconds counter
*
* @ var int
*/
public $actualSeconds = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The folder seconds counter
*
* @ var int
*/
public $folderSeconds = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The file seconds counter
*
* @ var int
*/
public $fileSeconds = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The line seconds counter
*
* @ var int
*/
public $lineSeconds = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The seconds debugging counter
*
* @ var int
*/
public $secondsDebugging = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The seconds planning counter
*
* @ var int
*/
public $secondsPlanning = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The seconds mapping counter
*
* @ var int
*/
public $secondsMapping = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The seconds office counter
*
* @ var int
*/
public $secondsOffice = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The total hours counter
*
* @ var int
*/
public $totalHours = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The debugging hours counter
*
* @ var int
*/
public $debuggingHours = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The planning hours counter
*
* @ var int
*/
public $planningHours = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The mapping hours counter
*
* @ var int
*/
public $mappingHours = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The office hours counter
*
* @ var int
*/
public $officeHours = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The actual Total Hours counter
*
* @ var int
*/
public $actualTotalHours = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The actual hours spent counter
*
* @ var int
*/
public $actualHoursSpent = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The actual days spent counter
*
* @ var int
*/
public $actualDaysSpent = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The total days counter
*
* @ var int
*/
public $totalDays = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The actual Total Days counter
*
* @ var int
*/
public $actualTotalDays = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The project week time counter
*
* @ var int
*/
public $projectWeekTime = 0 ;
2017-12-14 23:10:47 +00:00
2017-03-03 21:53:18 +00:00
/**
* The project month time counter
*
* @ var int
*/
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
*
* @ 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
*
* @ 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
*
* @ 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
*
* @ var array
*/
public $fileContentStatic = array ();
2017-12-14 23:10:47 +00:00
2018-09-25 20:02:48 +00:00
/**
* The standard folders
*
* @ var array
*/
public $stdFolders = array ( 'site' , 'admin' , 'media' );
2019-08-08 15:35:58 +00:00
/**
* The standard root files
*
* @ var array
*/
public $stdRootFiles = array ( 'access.xml' , 'config.xml' , 'controller.php' , 'index.html' , 'README.txt' );
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* Dynamic File Content
*
* @ var array
*/
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
*
* @ 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
*
* @ 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
*
* @ 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
*
* @ var string
*/
public $componentPath ;
2017-12-14 23:10:47 +00:00
2019-08-04 22:38:53 +00:00
/**
* The Dynamic paths
*
* @ 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
*
* @ 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
*
* @ var array
*/
public $updateFileContent = array ();
2016-03-04 00:01:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* The new files
*
* @ 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
*
* @ 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
*
* @ var boolean
*/
public $setMoveFolders = false ;
2017-02-01 13:17:04 +00:00
/**
* The array of last modified dates
*
* @ 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
*
* @ var bool / string
*/
public $dynamicDashboard = false ;
2016-02-26 00:20:09 +00:00
/**
* Constructor
*/
2017-12-14 23:10:47 +00:00
public function __construct ( $config = array ())
2016-02-26 00:20:09 +00:00
{
// first we run the perent constructor
if ( parent :: __construct ( $config ))
2017-10-12 00:50:14 +00:00
{
2019-08-08 15:35:58 +00:00
// set the standard admin file
$this -> stdRootFiles [] = $this -> componentData -> name_code . '.php' ;
2018-09-25 20:02:48 +00:00
// set incase no extra admin folder are loaded
$this -> fileContentStatic [ $this -> hhh . 'EXSTRA_ADMIN_FOLDERS' . $this -> hhh ] = '' ;
// set incase no extra site folder are loaded
$this -> fileContentStatic [ $this -> hhh . 'EXSTRA_SITE_FOLDERS' . $this -> hhh ] = '' ;
// set incase no extra media folder are loaded
$this -> fileContentStatic [ $this -> hhh . 'EXSTRA_MEDIA_FOLDERS' . $this -> hhh ] = '' ;
// set incase no extra admin files are loaded
$this -> fileContentStatic [ $this -> hhh . 'EXSTRA_ADMIN_FILES' . $this -> hhh ] = '' ;
// set incase no extra site files are loaded
$this -> fileContentStatic [ $this -> hhh . 'EXSTRA_SITE_FILES' . $this -> hhh ] = '' ;
// set incase no extra media files are loaded
$this -> fileContentStatic [ $this -> hhh . 'EXSTRA_MEDIA_FILES' . $this -> hhh ] = '' ;
2017-10-29 11:03:06 +00:00
// run global updater
ComponentbuilderHelper :: runGlobalUpdater ();
2016-02-26 00:20:09 +00:00
// set the template path
2018-04-24 22:36:05 +00:00
$this -> templatePath = $this -> compilerPath . '/joomla_' . $config [ 'version' ];
2016-02-26 00:20:09 +00:00
// set some default names
2017-12-14 23:10:47 +00:00
$this -> componentSalesName = 'com_' . $this -> componentData -> sales_name . '__J' . $this -> joomlaVersion ;
$this -> componentBackupName = 'com_' . $this -> componentData -> sales_name . '_v' . str_replace ( '.' , '_' , $this -> componentData -> component_version ) . '__J' . $this -> joomlaVersion ;
$this -> componentFolderName = 'com_' . $this -> componentData -> name_code . '_v' . str_replace ( '.' , '_' , $this -> componentData -> component_version ) . '__J' . $this -> joomlaVersion ;
2016-02-26 00:20:09 +00:00
// set component folder path
2017-12-14 23:10:47 +00:00
$this -> componentPath = $this -> compilerPath . '/' . $this -> componentFolderName ;
2016-02-26 00:20:09 +00:00
// set the template path for custom
2017-12-14 23:10:47 +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 ();
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 ();
2019-06-22 10:43:26 +00:00
// Trigger Event: jcb_ce_onAfterSetJoomlaVersionData
2019-07-01 16:10:28 +00:00
$this -> triggerEvent ( 'jcb_ce_onAfterSetJoomlaVersionData' , array ( & $this -> componentContext , & $this -> joomlaVersionData ));
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 ;
}
return true ;
}
return false ;
}
2017-12-14 23:10:47 +00:00
2016-09-03 21:44:47 +00:00
/**
* Set the line number in comments
*
* @ param int $nr The line number
*
2019-12-03 02:17:35 +00:00
* @ return string
2016-09-03 21:44:47 +00:00
*
*/
private function setLine ( $nr )
{
2017-04-06 08:47:51 +00:00
if ( $this -> debugLinenr )
2016-09-03 21:44:47 +00:00
{
2017-12-14 23:10:47 +00:00
return ' [Structure ' . $nr . ']' ;
2016-09-03 21:44:47 +00:00
}
return '' ;
}
2017-12-14 23:10:47 +00:00
2019-12-06 05:31:32 +00:00
/**
* Build the Modules files , folders , url ' s and config
*
* @ return void
*
*/
private function buildModules ()
{
if ( ComponentbuilderHelper :: checkArray ( $this -> joomlaModules ))
{
// Trigger Event: jcb_ce_onBeforeSetModules
$this -> triggerEvent ( 'jcb_ce_onBeforeBuildModules' , array ( & $this -> componentContext , & $this -> joomlaModules ));
foreach ( $this -> joomlaModules as $module )
{
if ( ComponentbuilderHelper :: checkObject ( $module ) && isset ( $module -> folder_name )
&& ComponentbuilderHelper :: checkString ( $module -> folder_name ))
{
// module path
$module -> folder_path = $this -> compilerPath . '/' . $module -> folder_name ;
// set the module paths
$this -> dynamicPaths [ $module -> key ] = $module -> folder_path ;
// make sure there is no old build
$this -> removeFolder ( $module -> folder_path );
// creat the main component folder
if ( ! JFolder :: exists ( $module -> folder_path ))
{
JFolder :: create ( $module -> folder_path );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( $module -> folder_name , $this -> compilerPath );
}
// set main mod file
$fileDetails = array ( 'path' => $module -> folder_path . '/' . $module -> file_name . '.php' ,
'name' => $module -> file_name . '.php' , 'zip' => $module -> file_name . '.php' );
$this -> writeFile ( $fileDetails [ 'path' ],
'<?php' . PHP_EOL . '// main modfile' .
PHP_EOL . $this -> hhh . 'BOM' . $this -> hhh . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
" defined('_JEXEC') or die('Restricted access'); " . PHP_EOL .
$this -> hhh . 'MODCODE' . $this -> hhh );
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
$this -> fileCount ++ ;
// set custom_get
if ( $module -> custom_get )
{
$fileDetails = array ( 'path' => $module -> folder_path . '/data.php' ,
'name' => 'data.php' , 'zip' => 'data.php' );
$this -> writeFile ( $fileDetails [ 'path' ],
'<?php' . PHP_EOL . '// get data file' .
PHP_EOL . $this -> hhh . 'BOM' . $this -> hhh . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
" defined('_JEXEC') or die('Restricted access'); " . PHP_EOL . PHP_EOL .
'/**' . PHP_EOL .
' * Module ' . $module -> official_name . ' Data' . PHP_EOL .
' */' . PHP_EOL .
" class " . $module -> class_data_name . ' extends \JObject' . PHP_EOL .
" { " . $this -> hhh . 'DYNAMICGETS' . $this -> hhh . " } " . PHP_EOL );
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
$this -> fileCount ++ ;
}
// set helper file
if ( $module -> add_class_helper >= 1 )
{
$fileDetails = array ( 'path' => $module -> folder_path . '/helper.php' ,
'name' => 'helper.php' , 'zip' => 'helper.php' );
$this -> writeFile ( $fileDetails [ 'path' ],
'<?php' . PHP_EOL . '// helper file' .
PHP_EOL . $this -> hhh . 'BOM' . $this -> hhh . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
" defined('_JEXEC') or die('Restricted access'); " . PHP_EOL .
$this -> hhh . 'HELPERCODE' . $this -> hhh );
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
$this -> fileCount ++ ;
}
// set main xml file
$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 ));
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
$this -> fileCount ++ ;
// set tmpl folder
if ( ! JFolder :: exists ( $module -> folder_path . '/tmpl' ))
{
JFolder :: create ( $module -> folder_path . '/tmpl' );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( $module -> folder_name . '/tmpl' , $this -> compilerPath );
}
// set default file
$fileDetails = array ( 'path' => $module -> folder_path . '/tmpl/default.php' ,
'name' => 'default.php' , 'zip' => 'tmpl/default.php' );
$this -> writeFile ( $fileDetails [ 'path' ],
'<?php' . PHP_EOL . '// default tmpl' .
PHP_EOL . $this -> hhh . 'BOM' . $this -> hhh . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
" defined('_JEXEC') or die('Restricted access'); " . PHP_EOL .
$this -> hhh . 'MODDEFAULT' . $this -> hhh );
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
$this -> fileCount ++ ;
// set install script if needed
if ( $module -> add_install_script )
{
$fileDetails = array ( 'path' => $module -> folder_path . '/script.php' ,
'name' => 'script.php' , 'zip' => 'script.php' );
$this -> writeFile ( $fileDetails [ 'path' ],
'<?php' . PHP_EOL . '// Script template' .
PHP_EOL . $this -> hhh . 'BOM' . $this -> hhh . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
" defined('_JEXEC') or die('Restricted access'); " . PHP_EOL .
$this -> hhh . 'INSTALLCLASS' . $this -> hhh );
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
$this -> fileCount ++ ;
}
// set readme if found
if ( $module -> addreadme )
{
$fileDetails = array ( 'path' => $module -> folder_path . '/README.md' ,
'name' => 'README.md' , 'zip' => 'README.md' );
$this -> writeFile ( $fileDetails [ 'path' ], $module -> readme );
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
$this -> fileCount ++ ;
}
// set fields & rules folders if needed
if ( isset ( $module -> fields_rules_paths ) && $module -> fields_rules_paths == 2 )
{
// create fields folder
if ( ! JFolder :: exists ( $module -> folder_path . '/fields' ))
{
JFolder :: create ( $module -> folder_path . '/fields' );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( $module -> folder_name . '/fields' , $this -> compilerPath );
}
// create rules folder
if ( ! JFolder :: exists ( $module -> folder_path . '/rules' ))
{
JFolder :: create ( $module -> folder_path . '/rules' );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( $module -> folder_name . '/rules' , $this -> compilerPath );
}
}
// set forms folder if needed
if ( isset ( $module -> form_files ) && ComponentbuilderHelper :: checkArray ( $module -> form_files ))
{
// create forms folder
if ( ! JFolder :: exists ( $module -> folder_path . '/forms' ))
{
JFolder :: create ( $module -> folder_path . '/forms' );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( $module -> folder_name . '/forms' , $this -> compilerPath );
}
// set the template files
foreach ( $module -> form_files as $file => $fields )
{
// set file details
$fileDetails = array ( 'path' => $module -> folder_path . '/forms/' . $file . '.xml' ,
'name' => $file . '.xml' , 'zip' => 'forms/' . $file . '.xml' );
// biuld basic XML
$xml = '<?xml version="1.0" encoding="utf-8"?>' ;
$xml .= PHP_EOL . '<!--' . $this -> setLine ( __LINE__ ) . ' default paths of ' . $file . ' form points to ' . $this -> componentCodeName . ' -->' ;
// 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 )
{
if ( ! $add_component_path && isset ( $module -> fieldsets_paths [ $file . $field_name . $fieldset ]) && $module -> fieldsets_paths [ $file . $field_name . $fieldset ] == 1 )
{
$add_component_path = true ;
}
}
}
}
// only add if part of the component field types path is required
if ( $add_component_path )
{
$xml .= PHP_EOL . '<form' ;
$xml .= PHP_EOL . $this -> _t ( 1 ) . 'addrulepath="/administrator/components/com_' . $this -> componentCodeName . '/models/rules"' ;
$xml .= PHP_EOL . $this -> _t ( 1 ) . 'addfieldpath="/administrator/components/com_' . $this -> componentCodeName . '/models/fields"' ;
$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 ;
if ( strpos ( $field_name , '.' ) !== false )
{
$field_names = explode ( '.' , $field_name );
if ( count (( array ) $field_names ) == 2 )
{
$field_name_outer = $field_names [ 0 ];
$field_name_inner = $field_names [ 1 ];
}
}
$xml .= PHP_EOL . $this -> _t ( 1 ) . '<fields name="' . $field_name_outer . '">' ;
foreach ( $fieldsets as $fieldset => $field )
{
// default to the field set name
$label = $fieldset ;
if ( isset ( $module -> fieldsets_label [ $file . $field_name . $fieldset ]))
{
$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 )
{
$xml .= PHP_EOL . $this -> _t ( 1 ) . '<!--' . $this -> setLine ( __LINE__ ) . ' default paths of ' . $fieldset . ' fieldset points to the module -->' ;
$xml .= PHP_EOL . $this -> _t ( 1 ) . '<fieldset name="' . $fieldset . '" label="' . $label . '"' ;
$xml .= PHP_EOL . $this -> _t ( 2 ) . 'addrulepath="/modules/' . strtolower ( $module -> code_name ) . '/rules"' ;
$xml .= PHP_EOL . $this -> _t ( 2 ) . 'addfieldpath="/modules/' . strtolower ( $module -> code_name ) . '/fields"' ;
$xml .= PHP_EOL . $this -> _t ( 1 ) . '>' ;
}
else
{
$xml .= PHP_EOL . $this -> _t ( 1 ) . '<fieldset name="' . $fieldset . '" label="' . $label . '">' ;
}
// check if we have an inner field set
if ( ComponentbuilderHelper :: checkString ( $field_name_inner ))
{
$xml .= PHP_EOL . $this -> _t ( 1 ) . '<fields name="' . $field_name_inner . '">' ;
}
// add the placeholder of the fields
$xml .= $this -> hhh . 'FIELDSET_' . $file . $field_name . $fieldset . $this -> hhh ;
// check if we have an inner field set
if ( ComponentbuilderHelper :: checkString ( $field_name_inner ))
{
$xml .= PHP_EOL . $this -> _t ( 1 ) . '</fields>' ;
}
$xml .= PHP_EOL . $this -> _t ( 1 ) . '</fieldset>' ;
}
$xml .= PHP_EOL . $this -> _t ( 1 ) . '</fields>' ;
}
$xml .= PHP_EOL . '</form>' ;
// add xml to file
$this -> writeFile ( $fileDetails [ 'path' ], $xml );
$this -> newFiles [ $module -> key ][] = $fileDetails ;
// count the file created
$this -> fileCount ++ ;
}
}
// set SQL stuff if needed
if ( $module -> add_sql || $module -> add_sql_uninstall )
{
// create SQL folder
if ( ! JFolder :: exists ( $module -> folder_path . '/sql' ))
{
JFolder :: create ( $module -> folder_path . '/sql' );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( $module -> folder_name . '/sql' , $this -> compilerPath );
}
// create mysql folder
if ( ! JFolder :: exists ( $module -> folder_path . '/sql/mysql' ))
{
JFolder :: create ( $module -> folder_path . '/sql/mysql' );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( $module -> folder_name . '/sql/mysql' , $this -> compilerPath );
}
// now set the install file
if ( $module -> add_sql )
{
$this -> writeFile ( $module -> folder_path . '/sql/mysql/install.sql' , $module -> sql );
// count the file created
$this -> fileCount ++ ;
}
// now set the uninstall file
if ( $module -> add_sql_uninstall )
{
$this -> writeFile ( $module -> folder_path . '/sql/mysql/uninstall.sql' , $module -> sql_uninstall );
// count the file created
$this -> fileCount ++ ;
}
}
// creat the language folder
if ( ! JFolder :: exists ( $module -> folder_path . '/language' ))
{
JFolder :: create ( $module -> folder_path . '/language' );
// count the folder created
$this -> folderCount ++ ;
// also the lang tag
if ( ! JFolder :: exists ( $module -> folder_path . '/language/' . $this -> langTag ))
{
JFolder :: create ( $module -> folder_path . '/language/' . $this -> langTag );
// count the folder created
$this -> folderCount ++ ;
}
}
// check if this lib has files
if ( isset ( $module -> files ) && ComponentbuilderHelper :: checkArray ( $module -> files ))
{
// add to component files
foreach ( $module -> files as $file )
{
// set the path finder
$file [ 'target_type' ] = $module -> target_type ;
$file [ 'target_id' ] = $module -> id ;
$this -> componentData -> files [] = $file ;
}
}
// check if this lib has folders
if ( isset ( $module -> folders ) && ComponentbuilderHelper :: checkArray ( $module -> folders ))
{
// add to component folders
foreach ( $module -> folders as $folder )
{
// set the path finder
$folder [ 'target_type' ] = $module -> target_type ;
$folder [ 'target_id' ] = $module -> id ;
$this -> componentData -> folders [] = $folder ;
}
}
// check if this module has urls
if ( isset ( $module -> urls ) && ComponentbuilderHelper :: checkArray ( $module -> urls ))
{
// add to component urls
foreach ( $module -> urls as $n => & $url )
{
// should we add the local folder
if ( isset ( $url [ 'type' ]) && $url [ 'type' ] > 1 && isset ( $url [ 'url' ])
&& ComponentbuilderHelper :: checkString ( $url [ 'url' ]))
{
// set file name
$fileName = basename ( $url [ 'url' ]);
// get the file contents
$data = ComponentbuilderHelper :: getFileContents ( $url [ 'url' ]);
// 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
if ( ! JFolder :: exists ( $module -> folder_path . $path ))
{
JFolder :: create ( $module -> folder_path . $path );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( $module -> folder_name . $path , $this -> compilerPath );
}
// set the path to module file
$url [ 'path' ] = $module -> folder_path . $path . '/' . $fileName ; // we need this for later
// write data to path
$this -> writeFile ( $url [ 'path' ], $data );
// count the file created
$this -> fileCount ++ ;
}
}
}
}
}
}
}
2019-08-04 22:38:53 +00:00
/**
* Build the Plugins files , folders , url ' s and config
*
* @ return void
*
*/
2019-08-22 01:54:47 +00:00
private function buildPlugins ()
2019-08-04 22:38:53 +00:00
{
2019-08-22 01:54:47 +00:00
if ( ComponentbuilderHelper :: checkArray ( $this -> joomlaPlugins ))
2019-08-04 22:38:53 +00:00
{
// Trigger Event: jcb_ce_onBeforeSetPlugins
2019-08-22 01:54:47 +00:00
$this -> triggerEvent ( 'jcb_ce_onBeforeBuildPlugins' , array ( & $this -> componentContext , & $this -> joomlaPlugins ));
foreach ( $this -> joomlaPlugins as $plugin )
2019-08-04 22:38:53 +00:00
{
2019-08-08 15:35:58 +00:00
if ( ComponentbuilderHelper :: checkObject ( $plugin ) && isset ( $plugin -> folder_name )
&& ComponentbuilderHelper :: checkString ( $plugin -> folder_name ))
2019-08-04 22:38:53 +00:00
{
// plugin path
$plugin -> folder_path = $this -> compilerPath . '/' . $plugin -> folder_name ;
// 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
if ( ! JFolder :: exists ( $plugin -> folder_path ))
{
JFolder :: create ( $plugin -> folder_path );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( $plugin -> folder_name , $this -> compilerPath );
}
// set main class file
2019-08-08 15:35:58 +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' ],
'<?php' . PHP_EOL . '// Plugin main class template' .
PHP_EOL . $this -> hhh . 'BOM' . $this -> hhh . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
" defined('_JEXEC') or die('Restricted access'); " . PHP_EOL .
$this -> hhh . 'MAINCLASS' . $this -> hhh );
2019-08-04 22:38:53 +00:00
$this -> newFiles [ $plugin -> key ][] = $fileDetails ;
// count the file created
$this -> fileCount ++ ;
// set main xml file
2019-08-08 15:35:58 +00:00
$fileDetails = array ( 'path' => $plugin -> folder_path . '/' . $plugin -> file_name . '.xml' ,
'name' => $plugin -> file_name . '.xml' , 'zip' => $plugin -> file_name . '.xml' );
2019-08-04 22:38:53 +00:00
$this -> writeFile ( $fileDetails [ 'path' ], $this -> getPluginXMLTemplate ( $plugin ));
$this -> newFiles [ $plugin -> key ][] = $fileDetails ;
// count the file created
$this -> fileCount ++ ;
// set install script if needed
if ( $plugin -> add_install_script )
{
2019-08-08 15:35:58 +00:00
$fileDetails = array ( 'path' => $plugin -> folder_path . '/script.php' ,
'name' => 'script.php' , 'zip' => 'script.php' );
$this -> writeFile ( $fileDetails [ 'path' ],
'<?php' . PHP_EOL . '// Script template' .
PHP_EOL . $this -> hhh . 'BOM' . $this -> hhh . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
" defined('_JEXEC') or die('Restricted access'); " . PHP_EOL .
$this -> hhh . 'INSTALLCLASS' . $this -> hhh );
2019-08-04 22:38:53 +00:00
$this -> newFiles [ $plugin -> key ][] = $fileDetails ;
// count the file created
$this -> fileCount ++ ;
}
// set readme if found
if ( $plugin -> addreadme )
{
2019-08-08 15:35:58 +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
$this -> fileCount ++ ;
}
2019-08-22 01:54:47 +00:00
// set fields & rules folders if needed
if ( isset ( $plugin -> fields_rules_paths ) && $plugin -> fields_rules_paths == 2 )
{
// create fields folder
if ( ! JFolder :: exists ( $plugin -> folder_path . '/fields' ))
{
JFolder :: create ( $plugin -> folder_path . '/fields' );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( $plugin -> folder_name . '/fields' , $this -> compilerPath );
}
// create rules folder
if ( ! JFolder :: exists ( $plugin -> folder_path . '/rules' ))
{
JFolder :: create ( $plugin -> folder_path . '/rules' );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( $plugin -> folder_name . '/rules' , $this -> compilerPath );
}
}
// set forms folder if needed
if ( isset ( $plugin -> form_files ) && ComponentbuilderHelper :: checkArray ( $plugin -> form_files ))
{
// create forms folder
if ( ! JFolder :: exists ( $plugin -> folder_path . '/forms' ))
{
JFolder :: create ( $plugin -> folder_path . '/forms' );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( $plugin -> folder_name . '/forms' , $this -> compilerPath );
}
// set the template files
foreach ( $plugin -> form_files as $file => $fields )
{
// set file details
$fileDetails = array ( 'path' => $plugin -> folder_path . '/forms/' . $file . '.xml' ,
'name' => $file . '.xml' , 'zip' => 'forms/' . $file . '.xml' );
// biuld basic XML
$xml = '<?xml version="1.0" encoding="utf-8"?>' ;
$xml .= PHP_EOL . '<!--' . $this -> setLine ( __LINE__ ) . ' default paths of ' . $file . ' form points to ' . $this -> componentCodeName . ' -->' ;
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 )
{
if ( ! $add_component_path && isset ( $plugin -> fieldsets_paths [ $file . $field_name . $fieldset ]) && $plugin -> fieldsets_paths [ $file . $field_name . $fieldset ] == 1 )
{
$add_component_path = true ;
}
}
}
}
// only add if part of the component field types path is required
if ( $add_component_path )
{
$xml .= PHP_EOL . '<form' ;
$xml .= PHP_EOL . $this -> _t ( 1 ) . 'addrulepath="/administrator/components/com_' . $this -> componentCodeName . '/models/rules"' ;
$xml .= PHP_EOL . $this -> _t ( 1 ) . 'addfieldpath="/administrator/components/com_' . $this -> componentCodeName . '/models/fields"' ;
$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 ;
if ( strpos ( $field_name , '.' ) !== false )
{
$field_names = explode ( '.' , $field_name );
if ( count (( array ) $field_names ) == 2 )
{
$field_name_outer = $field_names [ 0 ];
$field_name_inner = $field_names [ 1 ];
}
}
$xml .= PHP_EOL . $this -> _t ( 1 ) . '<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 ;
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 )
{
$xml .= PHP_EOL . $this -> _t ( 1 ) . '<!--' . $this -> setLine ( __LINE__ ) . ' default paths of ' . $fieldset . ' fieldset points to the plugin -->' ;
$xml .= PHP_EOL . $this -> _t ( 1 ) . '<fieldset name="' . $fieldset . '" label="' . $label . '"' ;
$xml .= PHP_EOL . $this -> _t ( 2 ) . 'addrulepath="/plugins/' . strtolower ( $plugin -> group ) . '/' . strtolower ( $plugin -> code_name ) . '/rules"' ;
$xml .= PHP_EOL . $this -> _t ( 2 ) . 'addfieldpath="/plugins/' . strtolower ( $plugin -> group ) . '/' . strtolower ( $plugin -> code_name ) . '/fields"' ;
$xml .= PHP_EOL . $this -> _t ( 1 ) . '>' ;
}
else
{
$xml .= PHP_EOL . $this -> _t ( 1 ) . '<fieldset name="' . $fieldset . '" label="' . $label . '">' ;
}
2019-10-11 13:41:00 +00:00
// check if we have an inner field set
if ( ComponentbuilderHelper :: checkString ( $field_name_inner ))
{
$xml .= PHP_EOL . $this -> _t ( 1 ) . '<fields name="' . $field_name_inner . '">' ;
}
2019-08-22 01:54:47 +00:00
// add the placeholder of the fields
$xml .= $this -> hhh . 'FIELDSET_' . $file . $field_name . $fieldset . $this -> hhh ;
2019-10-11 13:41:00 +00:00
// check if we have an inner field set
if ( ComponentbuilderHelper :: checkString ( $field_name_inner ))
{
$xml .= PHP_EOL . $this -> _t ( 1 ) . '</fields>' ;
}
2019-08-22 01:54:47 +00:00
$xml .= PHP_EOL . $this -> _t ( 1 ) . '</fieldset>' ;
}
$xml .= PHP_EOL . $this -> _t ( 1 ) . '</fields>' ;
}
$xml .= PHP_EOL . '</form>' ;
// add xml to file
$this -> writeFile ( $fileDetails [ 'path' ], $xml );
$this -> newFiles [ $plugin -> key ][] = $fileDetails ;
// count the file created
$this -> fileCount ++ ;
}
}
2019-08-04 22:38:53 +00:00
// set SQL stuff if needed
if ( $plugin -> add_sql || $plugin -> add_sql_uninstall )
{
// create SQL folder
if ( ! JFolder :: exists ( $plugin -> folder_path . '/sql' ))
{
JFolder :: create ( $plugin -> folder_path . '/sql' );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( $plugin -> folder_name . '/sql' , $this -> compilerPath );
}
// create mysql folder
if ( ! JFolder :: exists ( $plugin -> folder_path . '/sql/mysql' ))
{
JFolder :: create ( $plugin -> folder_path . '/sql/mysql' );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( $plugin -> folder_name . '/sql/mysql' , $this -> compilerPath );
}
// now set the install file
if ( $plugin -> add_sql )
{
$this -> writeFile ( $plugin -> folder_path . '/sql/mysql/install.sql' , $plugin -> sql );
// count the file created
$this -> fileCount ++ ;
}
// now set the uninstall file
if ( $plugin -> add_sql_uninstall )
{
$this -> writeFile ( $plugin -> folder_path . '/sql/mysql/uninstall.sql' , $plugin -> sql_uninstall );
// count the file created
$this -> fileCount ++ ;
}
}
// creat the language folder
if ( ! JFolder :: exists ( $plugin -> folder_path . '/language' ))
{
JFolder :: create ( $plugin -> folder_path . '/language' );
// count the folder created
$this -> folderCount ++ ;
// also the lang tag
if ( ! JFolder :: exists ( $plugin -> folder_path . '/language/' . $this -> langTag ))
{
JFolder :: create ( $plugin -> folder_path . '/language/' . $this -> langTag );
// count the folder created
$this -> folderCount ++ ;
}
}
// check if this lib has files
if ( isset ( $plugin -> files ) && ComponentbuilderHelper :: checkArray ( $plugin -> files ))
{
// add to component files
foreach ( $plugin -> files as $file )
{
// set the path finder
$file [ 'target_type' ] = $plugin -> target_type ;
$file [ 'target_id' ] = $plugin -> id ;
$this -> componentData -> files [] = $file ;
}
}
// check if this lib has folders
if ( isset ( $plugin -> folders ) && ComponentbuilderHelper :: checkArray ( $plugin -> folders ))
{
// add to component folders
foreach ( $plugin -> folders as $folder )
{
// set the path finder
$folder [ 'target_type' ] = $plugin -> target_type ;
$folder [ 'target_id' ] = $plugin -> id ;
$this -> componentData -> folders [] = $folder ;
}
}
// check if this plugin has urls
if ( isset ( $plugin -> urls ) && ComponentbuilderHelper :: checkArray ( $plugin -> urls ))
{
// add to component urls
foreach ( $plugin -> urls as $n => & $url )
{
// should we add the local folder
2019-08-08 15:35:58 +00:00
if ( isset ( $url [ 'type' ]) && $url [ 'type' ] > 1 && isset ( $url [ 'url' ])
&& ComponentbuilderHelper :: checkString ( $url [ 'url' ]))
2019-08-04 22:38:53 +00:00
{
// set file name
$fileName = basename ( $url [ 'url' ]);
// get the file contents
$data = ComponentbuilderHelper :: getFileContents ( $url [ 'url' ]);
// 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
if ( ! JFolder :: exists ( $plugin -> folder_path . $path ))
{
JFolder :: create ( $plugin -> folder_path . $path );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( $plugin -> folder_name . $path , $this -> compilerPath );
}
// set the path to plugin file
$url [ 'path' ] = $plugin -> folder_path . $path . '/' . $fileName ; // we need this for later
// write data to path
$this -> writeFile ( $url [ 'path' ], $data );
// count the file created
$this -> fileCount ++ ;
}
}
}
}
}
}
}
2017-12-10 19:17:26 +00:00
/**
* Build the Libraries files , folders , url ' s and config
*
* @ return void
*
*/
2019-08-04 22:38:53 +00:00
private function setLibraries ()
2017-12-10 19:17:26 +00:00
{
if ( ComponentbuilderHelper :: checkArray ( $this -> libraries ))
{
2019-08-04 22:38:53 +00:00
// Trigger Event: jcb_ce_onBeforeSetLibraries
$this -> triggerEvent ( 'jcb_ce_onBeforeSetLibraries' , array ( & $this -> componentContext , & $this -> libraries ));
2017-12-12 00:28:35 +00:00
// creat the main component folder
if ( ! JFolder :: exists ( $this -> componentPath ))
{
JFolder :: create ( $this -> componentPath );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( '' );
}
// create media path if not set
2017-12-14 23:10:47 +00:00
if ( ! JFolder :: exists ( $this -> componentPath . '/media' ))
2017-12-12 00:28:35 +00:00
{
JFolder :: create ( $this -> componentPath . '/media' );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( '/media' );
}
2017-12-14 23:10:47 +00:00
foreach ( $this -> libraries as $id => & $library )
2017-12-10 19:17:26 +00:00
{
if ( ComponentbuilderHelper :: checkObject ( $library ))
{
// check if this lib has files
if ( isset ( $library -> files ) && ComponentbuilderHelper :: checkArray ( $library -> files ))
{
// add to component files
foreach ( $library -> files as $file )
{
$this -> componentData -> files [] = $file ;
}
}
// check if this lib has folders
if ( isset ( $library -> folders ) && ComponentbuilderHelper :: checkArray ( $library -> folders ))
{
// add to component folders
foreach ( $library -> folders as $folder )
{
$this -> componentData -> folders [] = $folder ;
}
}
// check if this lib has urls
if ( isset ( $library -> urls ) && ComponentbuilderHelper :: checkArray ( $library -> urls ))
{
// build media folder path
2017-12-14 23:10:47 +00:00
$libFolder = strtolower ( preg_replace ( '/\s+/' , '-' , ComponentbuilderHelper :: safeString ( $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 )
{
if ( isset ( $url [ 'type' ]) && $url [ 'type' ] > 1 && isset ( $url [ 'url' ]) && ComponentbuilderHelper :: checkString ( $url [ 'url' ]))
{
2017-12-12 00:28:35 +00:00
// create media/lib path if not set
2017-12-14 23:10:47 +00:00
if ( ! JFolder :: exists ( $this -> componentPath . $mediaPath ))
2017-12-12 00:28:35 +00:00
{
JFolder :: create ( $this -> componentPath . $mediaPath );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( $mediaPath );
}
// add local folder
$addLocalFolder = true ;
// set file name
2017-12-10 19:17:26 +00:00
$fileName = basename ( $url [ 'url' ]);
// get the file contents
$data = ComponentbuilderHelper :: getFileContents ( $url [ 'url' ]);
// 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
if ( ! JFolder :: exists ( $this -> componentPath . $mediaPath . $path ))
{
JFolder :: create ( $this -> componentPath . $mediaPath . $path );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( $mediaPath . $path );
}
// set the path to library file
$url [ 'path' ] = $mediaPath . $path . '/' . $fileName ; // we need this for later
// set full path
$path = $this -> componentPath . $url [ 'path' ];
// write data to path
$this -> writeFile ( $path , $data );
// count the file created
$this -> fileCount ++ ;
}
}
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
2018-05-26 10:03:08 +00:00
$this -> fileContentStatic [ $this -> hhh . 'EXSTRA_MEDIA_FOLDERS' . $this -> hhh ] .= PHP_EOL . $this -> _t ( 2 ) . " <folder> " . $libFolder . " </folder> " ;
2017-12-12 00:28:35 +00:00
}
2017-12-10 19:17:26 +00:00
}
// if config fields are found load into component config (avoiding dublicates)
if ( isset ( $library -> how ) && $library -> how > 1 && isset ( $library -> config ) && ComponentbuilderHelper :: checkArray ( $library -> config ))
{
foreach ( $library -> config as $cofig )
{
2017-12-14 23:10:47 +00:00
$found = array_filter ( $this -> componentData -> config , function ( $item ) use ( $cofig )
{
2017-12-10 19:17:26 +00:00
return $item [ 'field' ] == $cofig [ 'field' ];
});
// set the config data if not found
if ( ! ComponentbuilderHelper :: checkArray ( $found ))
{
$this -> componentData -> config [] = $cofig ;
}
}
}
}
}
}
}
2017-12-14 23:10:47 +00:00
2018-03-09 03:26:44 +00:00
/**
* set the dynamic dashboard if set
*
* @ return void
*
*/
private function setDynamicDashboard ()
{
2018-03-10 01:50:09 +00:00
// only add the dynamic dashboard if all checks out
2018-03-18 04:52:07 +00:00
if ( isset ( $this -> componentData -> dashboard_type ) && 2 == $this -> componentData -> dashboard_type && isset ( $this -> componentData -> dashboard ) && ComponentbuilderHelper :: checkString ( $this -> componentData -> dashboard ) && strpos ( $this -> componentData -> dashboard , '_' ) !== false )
2018-03-09 03:26:44 +00:00
{
// set the default view
2018-03-18 04:52:07 +00:00
$getter = explode ( '_' , $this -> componentData -> 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
$t = ComponentbuilderHelper :: safeString ( $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
$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' );
// 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
$type_names = ComponentbuilderHelper :: safeString ( $targets [ $t ], 'w' );
2018-03-10 01:50:09 +00:00
// set the dynamic dash
if ( isset ( $this -> componentData -> { $targets [ $t ]}) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> { $targets [ $t ]}))
{
// search the target views
2018-03-18 04:52:07 +00:00
$dashboard = ( array ) array_filter ( $this -> componentData -> { $targets [ $t ]}, function ( $view ) use ( $id , $t , $types )
2018-03-10 01:50:09 +00:00
{
2018-03-18 04:52:07 +00:00
if ( isset ( $view [ $types [ $t ]]) && $id == $view [ $types [ $t ]])
{
return true ;
}
return false ;
});
2018-05-17 01:02:11 +00:00
// set dashboard
if ( ComponentbuilderHelper :: checkArray ( $dashboard ))
{
$dashboard = array_values ( $dashboard )[ 0 ];
}
2018-03-10 01:50:09 +00:00
// check if view was found (this should be true)
2018-05-17 01:02:11 +00:00
if ( isset ( $dashboard [ 'settings' ]) && isset ( $dashboard [ 'settings' ] -> { $keys [ $t ]}))
2018-03-09 03:26:44 +00:00
{
2018-05-17 01:02:11 +00:00
$this -> dynamicDashboard = ComponentbuilderHelper :: safeString ( $dashboard [ 'settings' ] -> { $keys [ $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
2018-09-25 20:02:48 +00:00
$this -> app -> enqueueMessage ( JText :: _ ( '<hr /><h3>Dashboard Error</h3>' ), 'Error' );
2018-03-10 01:50:09 +00:00
$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.' , $names [ $t ], $this -> componentData -> dashboard , $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
2018-09-25 20:02:48 +00:00
$this -> app -> enqueueMessage ( JText :: _ ( '<hr /><h3>Dashboard Error</h3>' ), 'Error' );
2018-03-10 01:50:09 +00:00
$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.' , $names [ $t ], $this -> componentData -> dashboard , $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
2018-09-25 20:02:48 +00:00
$this -> app -> enqueueMessage ( JText :: _ ( '<hr /><h3>Dashboard Error</h3>' ), 'Error' );
2018-03-10 01:50:09 +00:00
$this -> app -> enqueueMessage ( JText :: sprintf ( 'The <b>%s</b> value for the dynamic dashboard is invalid.' , $this -> componentData -> dashboard ), 'Error' );
}
}
else
{
// the target value is wrong
2018-09-25 20:02:48 +00:00
$this -> app -> enqueueMessage ( JText :: _ ( '<hr /><h3>Dashboard Error</h3>' ), 'Error' );
2018-03-18 04:52:07 +00:00
$this -> app -> enqueueMessage ( JText :: sprintf ( 'The <b>%s</b> value for the dynamic dashboard is invalid.' , $this -> componentData -> dashboard ), 'Error' );
2018-03-09 03:26:44 +00:00
}
// if default was changed to dynamic dashboard the remove default tab and methods
if ( ComponentbuilderHelper :: checkString ( $this -> dynamicDashboard ))
{
// dynamic dashboard is used
$this -> componentData -> dashboard_tab = '' ;
$this -> componentData -> php_dashboard_methods = '' ;
}
}
}
2017-12-10 19:17:26 +00:00
/**
* Write data to file
*
* @ return bool true on success
*
*/
public function writeFile ( $path , $data )
{
return ComponentbuilderHelper :: writeFile ( $path , $data );
}
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
*
* @ return void
*
*/
private function setFolders ()
{
if ( ComponentbuilderHelper :: checkObject ( $this -> joomlaVersionData -> create ))
{
2017-12-12 00:28:35 +00:00
// creat the main component folder
2016-02-26 00:20:09 +00:00
if ( ! JFolder :: exists ( $this -> componentPath ))
{
JFolder :: create ( $this -> componentPath );
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( '' );
}
// now build all folders needed for this component
foreach ( $this -> joomlaVersionData -> create as $main => $folders )
{
2017-12-14 23:10:47 +00:00
if ( ! JFolder :: exists ( $this -> componentPath . '/' . $main ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
JFolder :: create ( $this -> componentPath . '/' . $main );
2016-02-26 00:20:09 +00:00
// count the folder created
$this -> folderCount ++ ;
$this -> indexHTML ( $main );
}
if ( ComponentbuilderHelper :: checkObject ( $folders ))
{
foreach ( $folders as $sub => $subFolders )
{
2017-12-14 23:10:47 +00:00
if ( ! JFolder :: exists ( $this -> componentPath . '/' . $main . '/' . $sub ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
JFolder :: create ( $this -> componentPath . '/' . $main . '/' . $sub );
2016-02-26 00:20:09 +00:00
// count the folder created
$this -> folderCount ++ ;
2017-12-14 23:10:47 +00:00
$this -> indexHTML ( $main . '/' . $sub );
2016-02-26 00:20:09 +00:00
}
if ( ComponentbuilderHelper :: checkObject ( $subFolders ))
{
foreach ( $subFolders as $sub_2 => $subFolders_2 )
{
2017-12-14 23:10:47 +00:00
if ( ! JFolder :: exists ( $this -> componentPath . '/' . $main . '/' . $sub . '/' . $sub_2 ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
JFolder :: create ( $this -> componentPath . '/' . $main . '/' . $sub . '/' . $sub_2 );
2016-02-26 00:20:09 +00:00
// count the folder created
$this -> folderCount ++ ;
2017-12-14 23:10:47 +00:00
$this -> indexHTML ( $main . '/' . $sub . '/' . $sub_2 );
2016-02-26 00:20:09 +00:00
}
if ( ComponentbuilderHelper :: checkObject ( $subFolders_2 ))
{
foreach ( $subFolders_2 as $sub_3 => $subFolders_3 )
{
2017-12-14 23:10:47 +00:00
if ( ! JFolder :: exists ( $this -> componentPath . '/' . $main . '/' . $sub . '/' . $sub_2 . '/' . $sub_3 ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
JFolder :: create ( $this -> componentPath . '/' . $main . '/' . $sub . '/' . $sub_2 . '/' . $sub_3 );
2016-02-26 00:20:09 +00:00
// count the folder created
$this -> folderCount ++ ;
2017-12-14 23:10:47 +00:00
$this -> indexHTML ( $main . '/' . $sub . '/' . $sub_2 . '/' . $sub_3 );
2016-02-26 00:20:09 +00:00
}
if ( ComponentbuilderHelper :: checkObject ( $subFolders_3 ))
{
foreach ( $subFolders_3 as $sub_4 => $subFolders_4 )
{
2017-12-14 23:10:47 +00:00
if ( ! JFolder :: exists ( $this -> componentPath . '/' . $main . '/' . $sub . '/' . $sub_2 . '/' . $sub_3 . '/' . $sub_4 ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
JFolder :: create ( $this -> componentPath . '/' . $main . '/' . $sub . '/' . $sub_2 . '/' . $sub_3 . '/' . $sub_4 );
2016-02-26 00:20:09 +00:00
// count the folder created
$this -> folderCount ++ ;
2017-12-14 23:10:47 +00:00
$this -> indexHTML ( $main . '/' . $sub . '/' . $sub_2 . '/' . $sub_3 . '/' . $sub_4 );
2016-02-26 00:20:09 +00:00
}
if ( ComponentbuilderHelper :: checkObject ( $subFolders_4 ))
{
foreach ( $subFolders_4 as $sub_5 => $subFolders_5 )
{
2017-12-14 23:10:47 +00:00
if ( ! JFolder :: exists ( $this -> componentPath . '/' . $main . '/' . $sub . '/' . $sub_2 . '/' . $sub_3 . '/' . $sub_4 . '/' . $sub_5 ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
JFolder :: create ( $this -> componentPath . '/' . $main . '/' . $sub . '/' . $sub_2 . '/' . $sub_3 . '/' . $sub_4 . '/' . $sub_5 );
2016-02-26 00:20:09 +00:00
// count the folder created
$this -> folderCount ++ ;
2017-12-14 23:10:47 +00:00
$this -> indexHTML ( $main . '/' . $sub . '/' . $sub_2 . '/' . $sub_3 . '/' . $sub_4 . '/' . $sub_5 );
2016-02-26 00:20:09 +00:00
}
if ( ComponentbuilderHelper :: checkObject ( $subFolders_5 ))
{
foreach ( $subFolders_5 as $sub_6 => $subFolders_6 )
{
2017-12-14 23:10:47 +00:00
if ( ! JFolder :: exists ( $this -> componentPath . '/' . $main . '/' . $sub . '/' . $sub_2 . '/' . $sub_3 . '/' . $sub_4 . '/' . $sub_5 . '/' . $sub_6 ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
JFolder :: create ( $this -> componentPath . '/' . $main . '/' . $sub . '/' . $sub_2 . '/' . $sub_3 . '/' . $sub_4 . '/' . $sub_5 . '/' . $sub_6 );
2016-02-26 00:20:09 +00:00
// count the folder created
$this -> folderCount ++ ;
2017-12-14 23:10:47 +00:00
$this -> indexHTML ( $main . '/' . $sub . '/' . $sub_2 . '/' . $sub_3 . '/' . $sub_4 . '/' . $sub_5 . '/' . $sub_6 );
2016-02-26 00:20:09 +00:00
}
if ( ComponentbuilderHelper :: checkObject ( $subFolders_6 ))
{
foreach ( $subFolders_6 as $sub_7 => $subFolders_7 )
{
2017-12-14 23:10:47 +00:00
if ( ! JFolder :: exists ( $this -> componentPath . '/' . $main . '/' . $sub . '/' . $sub_2 . '/' . $sub_3 . '/' . $sub_4 . '/' . $sub_5 . '/' . $sub_6 . '/' . $sub_7 ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
JFolder :: create ( $this -> componentPath . '/' . $main . '/' . $sub . '/' . $sub_2 . '/' . $sub_3 . '/' . $sub_4 . '/' . $sub_5 . '/' . $sub_6 . '/' . $sub_7 );
2016-02-26 00:20:09 +00:00
// count the folder created
$this -> folderCount ++ ;
2017-12-14 23:10:47 +00:00
$this -> indexHTML ( $main . '/' . $sub . '/' . $sub_2 . '/' . $sub_3 . '/' . $sub_4 . '/' . $sub_5 . '/' . $sub_6 . '/' . $sub_7 );
2016-02-26 00:20:09 +00:00
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return true ;
}
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
*
* @ return boolean
*
*/
private function setStatic ()
{
if ( ComponentbuilderHelper :: checkObject ( $this -> joomlaVersionData -> move -> static ))
{
2019-06-09 21:19:34 +00:00
$codeName = $this -> componentCodeName ;
2016-02-26 00:20:09 +00:00
// TODO needs more looking at this must be dynamic actualy
$this -> notNew [] = 'PHPExcel.php' ;
$this -> notNew [] = 'LICENSE.txt' ;
// do license check
$LICENSE = false ;
$licenseChecker = strtolower ( $this -> componentData -> license );
2018-05-22 19:01:36 +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
{
2018-05-22 19:01:36 +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
if ( $this -> componentData -> addreadme )
{
$README = true ;
}
// start moving
foreach ( $this -> joomlaVersionData -> move -> static as $ftem => $details )
{
// 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
{
$new = str_replace ( $details -> rename , $codeName , $item );
}
}
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
2017-02-01 13:17:04 +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
$zipPath = str_replace ( $details -> _target [ 'type' ] . '/' , '' , $details -> path );
$path = str_replace ( $details -> _target [ 'type' ] . '/' , $this -> dynamicPaths [ $details -> _target [ 'key' ]] . '/' , $details -> path );
}
else
{
// set destination path
$zipPath = str_replace ( 'c0mp0n3nt/' , '' , $details -> path );
$path = str_replace ( 'c0mp0n3nt/' , $this -> componentPath . '/' , $details -> path );
}
2016-02-26 00:20:09 +00:00
// set the template folder path
2018-03-18 04:52:07 +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
2019-03-13 12:20:51 +00:00
$currentFullPath = ( preg_match ( '/^[a-z]:/i' , $item )) ? $item : $templatePath . '/' . $item ;
$currentFullPath = str_replace ( '//' , '/' , $currentFullPath );
2018-03-18 04:52:07 +00:00
$packageFullPath = str_replace ( '//' , '/' , $path . '/' . $new );
$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
{
2018-02-28 02:27:03 +00:00
if ( ! JFile :: exists ( $currentFullPath ))
2016-02-26 00:20:09 +00:00
{
2018-09-25 20:02:48 +00:00
$this -> app -> enqueueMessage ( JText :: _ ( '<hr /><h3>File Path Error</h3>' ), 'Error' );
2018-02-28 02:27:03 +00:00
$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
$packageFullPath0nly = str_replace ( basename ( $packageFullPath ), '' , $packageFullPath );
// check if path exist, if not creat it
if ( ! JFolder :: exists ( $packageFullPath0nly ))
{
JFolder :: create ( $packageFullPath0nly );
}
2018-02-16 21:53:43 +00:00
// move the file to its place
2018-02-28 02:27:03 +00:00
JFile :: copy ( $currentFullPath , $packageFullPath );
2018-02-16 21:53:43 +00:00
// count the file created
$this -> fileCount ++ ;
// store the new files
if ( ! in_array ( $ftem , $this -> notNew ))
{
2019-08-04 22:38:53 +00:00
if ( isset ( $details -> _target ))
{
$this -> newFiles [ $details -> _target [ 'key' ]][] = array ( 'path' => $packageFullPath , 'name' => $new , 'zip' => $zipFullPath );
}
else
{
$this -> newFiles [ 'static' ][] = array ( 'path' => $packageFullPath , 'name' => $new , 'zip' => $zipFullPath );
}
2018-02-16 21:53:43 +00:00
}
2018-09-25 20:02:48 +00:00
// ensure we update this file if needed
if ( isset ( $this -> updateFileContent [ $ftem ]) && $this -> updateFileContent [ $ftem ])
{
// remove the pointer
unset ( $this -> updateFileContent [ $ftem ]);
// set the full path
$this -> updateFileContent [ $packageFullPath ] = $packageFullPath ;
}
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
{
2018-02-28 02:27:03 +00:00
if ( ! JFolder :: exists ( $currentFullPath ))
2018-02-16 21:53:43 +00:00
{
2018-09-25 20:02:48 +00:00
$this -> app -> enqueueMessage ( JText :: _ ( '<hr /><h3>Folder Path Error</h3>' ), 'Error' );
2018-02-28 02:27:03 +00:00
$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
2018-09-11 11:15:39 +00:00
JFolder :: copy ( $currentFullPath , $packageFullPath , '' , true );
2018-02-16 21:53:43 +00:00
// count the folder created
$this -> folderCount ++ ;
}
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
2019-08-08 15:35:58 +00:00
if ( isset ( $checker [ 0 ]) && ComponentbuilderHelper :: checkString ( $checker [ 0 ])
&& ! in_array ( $checker [ 0 ], $this -> stdFolders ))
2018-09-25 20:02:48 +00:00
{
2019-08-04 22:38:53 +00:00
// 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 componet is installed!' ), 'Notice' );
}
2018-09-25 20:02:48 +00:00
}
2019-09-05 21:12:56 +00:00
elseif ( count (( array ) $checker ) == 2 && ComponentbuilderHelper :: checkString ( $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
2019-08-12 21:30:31 +00:00
$eNAME = 'FOLDERS' ;
$ename = 'folder' ;
$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
elseif ( in_array ( $checker [ 0 ], $this -> stdFolders ) && ! in_array ( $checker [ 1 ], $this -> stdRootFiles ))
{
$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
$eTab = $this -> _t ( 2 );
if ( 'admin' === $checker [ 0 ])
{
$eTab = $this -> _t ( 3 );
}
// set the xml file
$this -> fileContentStatic [ $this -> hhh . 'EXSTRA_' . ComponentbuilderHelper :: safeString ( $checker [ 0 ], 'U' ) . '_' . $eNAME . $this -> hhh ] .= 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
}
return true ;
}
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
*
* @ return boolean
*
*/
private function setDynamique ()
{
$back = false ;
$front = false ;
if (( isset ( $this -> joomlaVersionData -> move -> dynamic ) && ComponentbuilderHelper :: checkObject ( $this -> joomlaVersionData -> move -> dynamic )) && ( isset ( $this -> componentData -> admin_views ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> admin_views )))
{
2018-03-09 03:26:44 +00:00
if ( ! ComponentbuilderHelper :: checkString ( $this -> dynamicDashboard ))
{
// setup dashboard
$target = array ( 'admin' => $this -> componentData -> name_code );
$this -> buildDynamique ( $target , 'dashboard' );
}
2016-02-26 00:20:09 +00:00
// now the rest of the views
foreach ( $this -> componentData -> admin_views as $nr => $view )
{
if ( ComponentbuilderHelper :: checkObject ( $view [ 'settings' ]))
{
2017-02-02 11:54:07 +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' )
{
$target = array ( 'admin' => $view [ 'settings' ] -> name_list );
2018-05-22 19:01:36 +00:00
$config = array ( $this -> hhh . 'CREATIONDATE' . $this -> hhh => $created , $this -> hhh . 'BUILDDATE' . $this -> hhh => $modified , $this -> hhh . 'VERSION' . $this -> hhh => $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' )
{
$target = array ( 'admin' => $view [ 'settings' ] -> name_single );
2018-05-22 19:01:36 +00:00
$config = array ( $this -> hhh . 'CREATIONDATE' . $this -> hhh => $created , $this -> hhh . 'BUILDDATE' . $this -> hhh => $modified , $this -> hhh . 'VERSION' . $this -> hhh => $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
}
2019-04-09 21:54:54 +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
$target = array ( 'site' => $view [ 'settings' ] -> name_single );
2018-05-22 19:01:36 +00:00
$config = array ( $this -> hhh . 'CREATIONDATE' . $this -> hhh => $created , $this -> hhh . 'BUILDDATE' . $this -> hhh => $modified , $this -> hhh . 'VERSION' . $this -> hhh => $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
2017-10-30 13:08:02 +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 ;
}
if (( isset ( $this -> joomlaVersionData -> move -> dynamic ) && ComponentbuilderHelper :: checkObject ( $this -> joomlaVersionData -> move -> dynamic )) && ( isset ( $this -> componentData -> site_views ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> site_views )))
{
foreach ( $this -> componentData -> site_views as $nr => $view )
{
2017-02-02 11:54:07 +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 );
2018-05-22 19:01:36 +00:00
$config = array ( $this -> hhh . 'CREATIONDATE' . $this -> hhh => $created , $this -> hhh . 'BUILDDATE' . $this -> hhh => $modified , $this -> hhh . 'VERSION' . $this -> hhh => $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 );
2018-05-22 19:01:36 +00:00
$config = array ( $this -> hhh . 'CREATIONDATE' . $this -> hhh => $created , $this -> hhh . 'BUILDDATE' . $this -> hhh => $modified , $this -> hhh . 'VERSION' . $this -> hhh => $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 ;
}
if (( isset ( $this -> joomlaVersionData -> move -> dynamic ) && ComponentbuilderHelper :: checkObject ( $this -> joomlaVersionData -> move -> dynamic )) && ( isset ( $this -> componentData -> custom_admin_views ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> custom_admin_views )))
{
foreach ( $this -> componentData -> custom_admin_views as $nr => $view )
{
2017-02-02 11:54:07 +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 );
2018-05-22 19:01:36 +00:00
$config = array ( $this -> hhh . 'CREATIONDATE' . $this -> hhh => $created , $this -> hhh . 'BUILDDATE' . $this -> hhh => $modified , $this -> hhh . 'VERSION' . $this -> hhh => $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 );
2018-05-22 19:01:36 +00:00
$config = array ( $this -> hhh . 'CREATIONDATE' . $this -> hhh => $created , $this -> hhh . 'BUILDDATE' . $this -> hhh => $modified , $this -> hhh . 'VERSION' . $this -> hhh => $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 ;
}
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 )
{
// check if this is a custom field that should be moved
if ( isset ( $this -> extentionCustomfields [ $field [ 'type_name' ]]))
{
// check files exist
if ( JFile :: exists ( $this -> componentPath . '/admin/models/fields/' . $field [ 'type_name' ] . '.php' ))
{
// move the custom field
JFile :: copy ( $this -> componentPath . '/admin/models/fields/' . $field [ 'type_name' ] . '.php' , $path . '/fields/' . $field [ 'type_name' ] . '.php' );
}
// do this just once
unset ( $this -> extentionCustomfields [ $field [ 'type_name' ]]);
}
// check if this has validation that should be moved
if ( isset ( $this -> validationLinkedFields [ $field [ 'field' ]]))
{
// check files exist
if ( JFile :: exists ( $this -> componentPath . '/admin/models/rules/' . $this -> validationLinkedFields [ $field [ 'field' ]] . '.php' ))
{
// move the custom field
JFile :: copy ( $this -> componentPath . '/admin/models/rules/' . $this -> validationLinkedFields [ $field [ 'field' ]] . '.php' , $path . '/rules/' . $this -> validationLinkedFields [ $field [ 'field' ]] . '.php' );
}
// do this just once
unset ( $this -> validationLinkedFields [ $field [ 'field' ]]);
}
}
2017-02-02 11:54:07 +00:00
/**
* get the created date of the ( view )
2019-08-22 01:54:47 +00:00
*
2017-02-02 11:54:07 +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
{
2017-02-02 11:54:07 +00:00
if ( isset ( $view [ 'settings' ] -> created ) && ComponentbuilderHelper :: checkString ( $view [ 'settings' ] -> created ))
{
// first set the main date
$date = strtotime ( $view [ 'settings' ] -> created );
}
else
{
// first set the main date
$date = strtotime ( " now " );
}
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
*
2017-02-01 13:17:04 +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
2017-12-14 23:10:47 +00:00
if ( isset ( $view [ 'settings' ] -> modified ) && ComponentbuilderHelper :: checkString ( $view [ 'settings' ] -> modified ) && '0000-00-00 00:00:00' !== $view [ 'settings' ] -> modified )
2017-02-02 11:54:07 +00:00
{
$date = strtotime ( $view [ 'settings' ] -> modified );
}
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 ]))
{
if ( isset ( $view [ 'settings' ] -> fields ) && ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> fields ))
{
foreach ( $view [ 'settings' ] -> fields as $field )
{
2017-12-14 23:10:47 +00:00
if ( isset ( $field [ 'settings' ]) && ComponentbuilderHelper :: checkObject ( $field [ 'settings' ]) && isset ( $field [ 'settings' ] -> modified ) && ComponentbuilderHelper :: checkString ( $field [ 'settings' ] -> modified ) && '0000-00-00 00:00:00' !== $field [ 'settings' ] -> modified )
2017-02-01 13:17:04 +00:00
{
$anotherDate = strtotime ( $field [ 'settings' ] -> modified );
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 ]))
{
2017-12-14 23:10:47 +00:00
if ( isset ( $view [ 'settings' ] -> main_get -> modified ) && ComponentbuilderHelper :: checkString ( $view [ 'settings' ] -> main_get -> modified ) && '0000-00-00 00:00:00' !== $view [ 'settings' ] -> main_get -> modified )
2017-02-01 13:17:04 +00:00
{
$anotherDate = strtotime ( $view [ 'settings' ] -> main_get -> modified );
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 ]))
{
2017-12-14 23:10:47 +00:00
if ( isset ( $view [ 'settings' ] -> main_get -> modified ) && ComponentbuilderHelper :: checkString ( $view [ 'settings' ] -> main_get -> modified ) && '0000-00-00 00:00:00' !== $view [ 'settings' ] -> main_get -> modified )
2017-02-01 13:17:04 +00:00
{
$anotherDate = strtotime ( $view [ 'settings' ] -> main_get -> modified );
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
2017-02-01 13:17:04 +00:00
return JFactory :: getDate ( $this -> lastModifiedDate [ $id ]) -> format ( 'jS F, Y' );
}
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
*
* @ param array $target The main target and name
2016-02-26 00:20:09 +00:00
* @ param string $type The type in the target
* @ param string $fileName The custom file name
2017-09-18 00:18:23 +00:00
* @ param array $cofig to add more data to the files info
*
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
*/
2017-02-01 13:17:04 +00:00
public function buildDynamique ( $target , $type , $fileName = false , $config = false )
2016-02-26 00:20:09 +00:00
{
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
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkArray ( $target ))
{
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
$name = ComponentbuilderHelper :: safeString ( $name );
// setup the files
foreach ( $this -> joomlaVersionData -> move -> dynamic -> { $main } as $item => $details )
{
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 = '' ;
if ( strpos ( $details -> path , 'VIEW' ) !== false )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$path = str_replace ( 'VIEW' , $name , $details -> path );
2016-02-26 00:20:09 +00:00
}
else
{
$path = $details -> path ;
}
2017-12-14 23:10:47 +00:00
$zipPath = str_replace ( 'c0mp0n3nt/' , '' , $path );
$path = str_replace ( 'c0mp0n3nt/' , $this -> componentPath . '/' , $path );
2016-02-26 00:20:09 +00:00
// setup the folder
if ( ! JFolder :: exists ( $path ))
{
JFolder :: create ( $path );
$this -> indexHTML ( $zipPath );
// count the folder created
$this -> folderCount ++ ;
}
// do the file renaming
if ( $details -> rename )
{
if ( $fileName )
{
$new = str_replace ( $details -> rename , $fileName , $item );
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
{
$new = str_replace ( $details -> rename , $name , $item );
}
}
else
{
$new = $item ;
}
2017-12-14 23:10:47 +00:00
if ( ! JFile :: exists ( $path . '/' . $new ))
2016-02-26 00:20:09 +00:00
{
// move the file to its place
2017-12-14 23:10:47 +00:00
JFile :: copy ( $this -> templatePath . '/' . $item , $path . '/' . $new , '' , true );
2016-02-26 00:20:09 +00:00
// count the file created
$this -> fileCount ++ ;
}
2017-02-01 13:17:04 +00:00
// setup array for new file
2017-12-14 23:10:47 +00:00
$newFIle = array ( 'path' => $path . '/' . $new , 'name' => $new , 'view' => $name , 'zip' => $zipPath . '/' . $new );
2017-02-01 13:17:04 +00:00
if ( ComponentbuilderHelper :: checkArray ( $config ))
{
$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
}
}
}
}
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
*
* @ return oject The version data
2019-08-22 01:54:47 +00:00
*
2016-02-26 00:20:09 +00:00
*/
private function setJoomlaVersionData ()
{
// set the version data
2017-12-14 23:10:47 +00:00
$versionData = json_decode ( ComponentbuilderHelper :: getFileContents ( $this -> templatePath . '/settings.json' ));
2016-02-26 00:20:09 +00:00
// add custom folders
if (( isset ( $this -> componentData -> folders ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> folders )) || $this -> addEximport || $this -> uikit || $this -> footable )
{
if ( $this -> addEximport )
{
// move the import view folder in place
2017-12-14 23:10:47 +00:00
$importView = array ( 'folder' => 'importViews' , 'path' => 'admin/views/import' , 'rename' => 1 );
2016-02-26 00:20:09 +00:00
$this -> componentData -> folders [] = $importView ;
// move the PHPExel Folder
2017-12-14 23:10:47 +00:00
$PHPExcel = array ( 'folder' => 'PHPExcel' , 'path' => 'admin/helpers' , 'rename' => 0 );
2016-02-26 00:20:09 +00:00
$this -> componentData -> folders [] = $PHPExcel ;
}
2017-11-11 04:33:51 +00:00
if ( 2 == $this -> uikit || 1 == $this -> uikit )
2016-02-26 00:20:09 +00:00
{
// move the UIKIT Folder into place
2017-12-14 23:10:47 +00:00
$uikit = array ( 'folder' => 'uikit-v2' , 'path' => 'media' , 'rename' => 0 );
2016-02-26 00:20:09 +00:00
$this -> componentData -> folders [] = $uikit ;
2017-12-14 23:10:47 +00:00
}
2017-11-11 04:33:51 +00:00
if ( 2 == $this -> uikit || 3 == $this -> uikit )
{
// move the UIKIT-3 Folder into place
2017-12-14 23:10:47 +00:00
$uikit = array ( 'folder' => 'uikit-v3' , 'path' => 'media' , 'rename' => 0 );
2017-11-11 04:33:51 +00:00
$this -> componentData -> folders [] = $uikit ;
2016-02-26 00:20:09 +00:00
}
2016-04-22 12:03:43 +00:00
if ( $this -> footable && ( ! isset ( $this -> footableVersion ) || 2 == $this -> footableVersion ))
2016-02-26 00:20:09 +00:00
{
// move the footable folder into place
2017-12-14 23:10:47 +00:00
$footable = array ( 'folder' => 'footable-v2' , 'path' => 'media' , 'rename' => 0 );
2016-04-22 12:03:43 +00:00
$this -> componentData -> folders [] = $footable ;
}
elseif ( $this -> footable && 3 == $this -> footableVersion )
{
// move the footable folder into place
2017-12-14 23:10:47 +00:00
$footable = array ( 'folder' => 'footable-v3' , 'path' => 'media' , 'rename' => 0 );
2016-02-26 00:20:09 +00:00
$this -> componentData -> folders [] = $footable ;
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
// pointer tracker
$pointer_tracker = 'h' ;
foreach ( $this -> componentData -> folders as $custom )
{
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
ComponentbuilderHelper :: fixPath ( $custom , array ( 'path' , 'folder' , 'folderpath' ));
2018-02-16 21:53:43 +00:00
// fix custom path
if ( isset ( $custom [ 'path' ]) && ComponentbuilderHelper :: checkString ( $custom [ 'path' ]))
{
$custom [ 'path' ] = trim ( $custom [ 'path' ], '/' );
}
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
$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
$custom [ 'folder' ] = ( preg_match ( '/^[a-z]:/i' , $custom [ 'folderpath' ]))
? 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
2017-12-14 23:10:47 +00:00
$pathArray = ( array ) explode ( '/' , $custom [ 'path' ]);
2016-02-26 00:20:09 +00:00
$firstFolder = array_values ( $pathArray )[ 0 ];
$lastFolder = end ( $pathArray );
// 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
{
2017-12-14 23:10:47 +00:00
$custom [ 'path' ] = str_replace ( '/' . $lastFolder , '' , $custom [ 'path' ]);
2016-02-26 00:20:09 +00:00
$rename = 'new' ;
$newname = $lastFolder ;
}
2018-02-16 21:53:43 +00:00
elseif ( 'full' === $customPath )
{
// make sure we use the correct name
$folderArray = ( array ) explode ( '/' , $custom [ 'folder' ]);
$lastFolder = end ( $folderArray );
$rename = 'new' ;
$newname = $lastFolder ;
}
2016-02-26 00:20:09 +00:00
else
{
$lastFolder = $custom [ 'folder' ];
$rename = false ;
$newname = '' ;
}
2018-09-25 20:02:48 +00:00
// insure we have no duplicates
2017-12-14 23:10:47 +00:00
$key_pointer = ComponentbuilderHelper :: safeString ( $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
$custom [ 'path' ] = ltrim ( $custom [ 'path' ], '/' );
2016-02-26 00:20:09 +00:00
// set new folder to object
2018-09-25 20:02:48 +00:00
$versionData -> move -> static -> { $key_pointer } = new stdClass ();
$versionData -> move -> static -> { $key_pointer } -> naam = str_replace ( '//' , '/' , $custom [ 'folder' ]);
2019-08-04 22:38:53 +00:00
$versionData -> move -> static -> { $key_pointer } -> path = $_target_type . '/' . $custom [ 'path' ];
2018-09-25 20:02:48 +00:00
$versionData -> move -> static -> { $key_pointer } -> rename = $rename ;
$versionData -> move -> static -> { $key_pointer } -> newName = $newname ;
$versionData -> move -> static -> { $key_pointer } -> type = 'folder' ;
$versionData -> move -> static -> { $key_pointer } -> custom = $customPath ;
2019-08-04 22:38:53 +00:00
// set the target if type and id is found
if ( isset ( $custom [ 'target_id' ]) && isset ( $custom [ 'target_type' ]))
{
$versionData -> move -> static -> { $key_pointer } -> _target = array ( 'key' => $custom [ 'target_id' ] . '_' . $custom [ 'target_type' ], 'type' => $custom [ 'target_type' ]);
}
2016-02-26 00:20:09 +00:00
}
unset ( $this -> componentData -> folders );
unset ( $custom );
}
// add custom files
if (( isset ( $this -> componentData -> files ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> files )) || $this -> addEximport || $this -> googlechart )
{
if ( $this -> addEximport )
{
// move the PHPExel main file
2017-12-14 23:10:47 +00:00
$PHPExcel = array ( 'file' => 'PHPExcel.php' , 'path' => 'admin/helpers' , 'rename' => 0 );
2016-02-26 00:20:09 +00:00
$this -> componentData -> files [] = $PHPExcel ;
}
if ( $this -> googlechart )
{
// move the google chart files
2017-12-14 23:10:47 +00:00
$googleChart = array ( 'file' => 'google.jsapi.js' , 'path' => 'media/js' , 'rename' => 0 );
2016-02-26 00:20:09 +00:00
$this -> componentData -> files [] = $googleChart ;
2017-12-14 23:10:47 +00:00
$googleChart = array ( 'file' => 'chartbuilder.php' , 'path' => 'admin/helpers' , 'rename' => 0 );
2016-02-26 00:20:09 +00:00
$this -> componentData -> files [] = $googleChart ;
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
// pointer tracker
$pointer_tracker = 'h' ;
foreach ( $this -> componentData -> files as $custom )
{
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
ComponentbuilderHelper :: fixPath ( $custom , array ( 'path' , 'file' , 'filepath' ));
// 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
$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
$custom [ 'file' ] = ( preg_match ( '/^[a-z]:/i' , $custom [ 'filepath' ]))
? 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
2017-12-14 23:10:47 +00:00
$key_pointer = ComponentbuilderHelper :: safeString ( $custom [ 'file' ]) . '_g' . $pointer_tracker ;
2016-02-26 00:20:09 +00:00
$pointer_tracker ++ ;
// set new file to object
2018-09-25 20:02:48 +00:00
$versionData -> move -> static -> { $key_pointer } = new stdClass ();
$versionData -> move -> static -> { $key_pointer } -> naam = str_replace ( '//' , '/' , $custom [ 'file' ]);
2018-04-08 06:12:18 +00:00
// update the dynamic component name placholders in file names
$custom [ 'path' ] = $this -> setPlaceholders ( $custom [ 'path' ], $this -> placeholders );
2016-02-26 00:20:09 +00:00
// get the path info
$pathInfo = pathinfo ( $custom [ 'path' ]);
if ( isset ( $pathInfo [ 'extension' ]) && $pathInfo [ 'extension' ])
{
2018-02-16 21:53:43 +00:00
$pathInfo [ 'dirname' ] = trim ( $pathInfo [ 'dirname' ], '/' );
// set the info
2019-08-04 22:38:53 +00:00
$versionData -> move -> static -> { $key_pointer } -> path = $_target_type . '/' . $pathInfo [ 'dirname' ];
2018-09-25 20:02:48 +00:00
$versionData -> move -> static -> { $key_pointer } -> rename = 'new' ;
$versionData -> move -> static -> { $key_pointer } -> newName = $pathInfo [ 'basename' ];
2018-02-16 21:53:43 +00:00
}
elseif ( 'full' === $customPath )
{
2018-09-10 11:04:52 +00:00
// fix custom path
$custom [ 'path' ] = ltrim ( $custom [ 'path' ], '/' );
// get file array
2018-09-25 20:02:48 +00:00
$fileArray = ( array ) explode ( '/' , $custom [ 'file' ]);
2018-02-16 21:53:43 +00:00
// set the info
2019-08-04 22:38:53 +00:00
$versionData -> move -> static -> { $key_pointer } -> path = $_target_type . '/' . $custom [ 'path' ];
2018-09-25 20:02:48 +00:00
$versionData -> move -> static -> { $key_pointer } -> rename = 'new' ;
$versionData -> move -> static -> { $key_pointer } -> newName = end ( $fileArray );
2016-02-26 00:20:09 +00:00
}
else
{
2018-02-16 21:53:43 +00:00
// fix custom path
2018-09-10 11:04:52 +00:00
$custom [ 'path' ] = ltrim ( $custom [ 'path' ], '/' );
2018-02-16 21:53:43 +00:00
// set the info
2019-08-04 22:38:53 +00:00
$versionData -> move -> static -> { $key_pointer } -> path = $_target_type . '/' . $custom [ 'path' ];
2018-09-25 20:02:48 +00:00
$versionData -> move -> static -> { $key_pointer } -> rename = false ;
2016-02-26 00:20:09 +00:00
}
2018-09-25 20:02:48 +00:00
$versionData -> move -> static -> { $key_pointer } -> type = 'file' ;
$versionData -> move -> static -> { $key_pointer } -> custom = $customPath ;
2019-08-04 22:38:53 +00:00
// set the target if type and id is found
if ( isset ( $custom [ 'target_id' ]) && isset ( $custom [ 'target_type' ]))
{
$versionData -> move -> static -> { $key_pointer } -> _target = array ( 'key' => $custom [ 'target_id' ] . '_' . $custom [ 'target_type' ], 'type' => $custom [ 'target_type' ]);
}
2016-02-26 00:20:09 +00:00
// check if file should be updated
2017-11-11 04:33:51 +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
}
unset ( $this -> componentData -> files );
unset ( $custom );
}
return $versionData ;
}
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 index . html file in a folder path
2019-08-22 01:54:47 +00:00
*
2016-02-26 00:20:09 +00:00
* @ param string $path The path to place the index . html file in
*
* @ 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 )
{
$root = $this -> componentPath ;
}
// use path if exist
2016-02-26 00:20:09 +00:00
if ( strlen ( $path ) > 0 )
{
2019-08-04 22:38:53 +00:00
JFile :: copy ( $this -> templatePath . '/index.html' , $root . '/' . $path . '/index.html' );
2016-02-26 00:20:09 +00:00
// count the file created
$this -> fileCount ++ ;
}
else
{
2019-08-04 22:38:53 +00:00
JFile :: copy ( $this -> templatePath . '/index.html' , $root . '/index.html' );
2016-02-26 00:20:09 +00:00
// count the file created
$this -> fileCount ++ ;
}
}
2017-12-14 23:10:47 +00:00
2018-02-28 02:27:03 +00:00
/**
* Update paths with real value
*
* @ param string $path The full path
*
* @ return string The updated path
*
*/
protected function updateDynamicPath ( $path )
{
2019-03-20 01:05:33 +00:00
return $this -> setPlaceholders ( $this -> setPlaceholders ( $path , ComponentbuilderHelper :: $constantPaths ), $this -> placeholders );
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
*
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
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
}