2016-02-26 00:20:09 +00:00
< ? php
2017-12-14 23:10:47 +00:00
/* --------------------------------------------------------------------------------------------------------| www . vdm . io |------/
__ __ _ _____ _ _ __ __ _ _ _
\ \ / / | | | __ \ | | | | | \ / | | | | | | |
\ \ / / _ _ ___ | | _ | | | | _____ _____ | | ___ _ __ _ __ ___ ___ _ __ | | _ | \ / | ___ | | _ | | __ ___ __ | |
\ \ / / _ ` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| ' _ \ / _ \ / _ ` |
\ / ( _ | \__ \ | _ | | __ | | __ / \ V / __ / | ( _ ) | | _ ) | | | | | | __ / | | | | _ | | | | __ / | _ | | | | ( _ ) | ( _ | |
\ / \__ , _ | ___ / \__ | | _____ / \___ | \_ / \___ | _ | \___ /| . __ /| _ | | _ | | _ | \___ | _ | | _ | \__ | | _ | | _ | \___ | \__ | _ | | _ | \___ / \__ , _ |
| |
| _ |
/-------------------------------------------------------------------------------------------------------------------------------/
@ version 2.6 . x
@ created 30 th April , 2015
@ package Component Builder
@ subpackage compiler . php
@ author Llewellyn van der Merwe < http :// www . vdm . io >
@ my wife Roline van der Merwe < http :// www . vdm . io />
@ copyright Copyright ( C ) 2015. All Rights Reserved
@ license GNU / GPL Version 2 or later - http :// www . gnu . org / licenses / gpl - 2.0 . html
Builds Complex Joomla Components
/----------------------------------------------------------------------------------------------------------------------------- */
2016-02-26 00:20:09 +00:00
// No direct access to this file
defined ( '_JEXEC' ) or die ( 'Restricted access' );
/**
* Compiler class
*/
2016-03-01 18:44:13 +00:00
class Interpretation extends Fields
2017-12-14 23:10:47 +00:00
{
2017-08-22 22:17:19 +00:00
/**
* The contributors
*
* @ var string
*/
public $theContributors = '' ;
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The unistall builder
*
* @ var array
*/
public $uninstallBuilder = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The update SQL builder
*
* @ var array
*/
public $updateSQLBuilder = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The List Column Builder
*
* @ var array
*/
public $listColnrBuilder = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The permissions Builder
*
* @ var array
*/
public $permissionBuilder = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The dashboard permissions builder
*
* @ var array
*/
public $permissionDashboard = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The permissions core
*
* @ var array
*/
public $permissionCore = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The customs field builder
*
* @ var array
*/
public $customFieldBuilder = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The category builder
*
* @ var array
*/
public $buildCategories = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The icon builder
*
* @ var array
*/
public $iconBuilder = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The validation fix builder
*
* @ var array
*/
public $validationFixBuilder = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The edit body script builder
*
* @ var array
*/
public $editBodyViewScriptBuilder = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The target relation control
*
* @ var array
*/
public $targetRelationControl = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The target control script checker
*
* @ var array
*/
public $targetControlsScriptChecker = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The router helper
*
* @ var array
*/
public $setRouterHelpDone = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The other where
*
* @ var array
*/
public $otherWhere = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The dashboard get custom data
*
* @ var array
*/
public $DashboardGetCustomData = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The custom admin added
*
* @ var array
*/
public $customAdminAdded = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The extensions params
*
* @ var array
2017-12-14 23:10:47 +00:00
*/
2017-08-22 22:17:19 +00:00
protected $extensionsParams = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* The asset rules
*
* @ var array
*/
public $assetsRules = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* View Has Category Request
*
* @ var array
*/
protected $hasCatIdRequest = array ();
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
/**
* View Has Id Request
*
* @ var array
*/
protected $hasIdRequest = array ();
2017-12-10 19:17:26 +00:00
protected $libwarning = array ();
2016-04-22 12:03:43 +00:00
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 ))
{
return true ;
}
return false ;
}
2017-12-14 23:10:47 +00:00
2016-04-22 12:03:43 +00:00
/**
2016-02-26 00:20:09 +00:00
* Set the line number in comments
*
* @ param int $nr The line number
*
* @ return void
*
*/
2016-09-03 21:44:47 +00:00
private function setLine ( $nr )
2016-02-26 00:20:09 +00:00
{
2017-04-06 08:47:51 +00:00
if ( $this -> debugLinenr )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
return ' [Interpretation ' . $nr . ']' ;
2016-02-26 00:20:09 +00:00
}
return '' ;
}
2016-04-22 12:03:43 +00:00
/**
* add email helper
2017-12-14 23:10:47 +00:00
*/
2016-04-22 12:03:43 +00:00
public function addEmailHelper ()
{
if ( isset ( $this -> componentData -> add_email_helper ) && $this -> componentData -> add_email_helper )
{
// set email helper in place with component name
$component = $this -> fileContentStatic [ '###component###' ];
2017-08-20 17:52:35 +00:00
$Component = $this -> fileContentStatic [ '###Component###' ];
2016-04-22 12:03:43 +00:00
$target = array ( 'admin' => 'emailer' );
2017-12-14 23:10:47 +00:00
$done = $this -> buildDynamique ( $target , 'emailer' , $component );
2016-04-22 12:03:43 +00:00
if ( $done )
{
// the text for the file ###BAKING###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ 'emailer_' . $component ][ '###BAKING###' ] = '' ; // <<-- to insure it gets updated
2016-04-22 12:03:43 +00:00
// return the code need to load the abstract class
2017-12-14 23:10:47 +00:00
return PHP_EOL . " JLoader::register(' " . $Component . " Email', JPATH_COMPONENT_ADMINISTRATOR . '/helpers/ " . $component . " email.php'); " ;
2016-04-22 12:03:43 +00:00
}
}
return '' ;
}
/**
2017-08-22 22:17:19 +00:00
* set the lock license ( NOT OKAY )
2017-12-14 23:10:47 +00:00
*/
2016-02-26 00:20:09 +00:00
public function setLockLicense ()
{
if ( $this -> componentData -> add_license && $this -> componentData -> license_type == 3 )
{
2016-12-22 21:32:13 +00:00
if ( ! isset ( $this -> fileContentStatic [ '###HELPER_SITE_LICENSE_LOCK###' ]))
{
2017-12-14 23:10:47 +00:00
$_VDM = '_' . ComponentbuilderHelper :: safeString ( $this -> uniquekey ( 10 ), 'U' );
2016-12-22 21:32:13 +00:00
// add it to the system
2017-12-14 23:10:47 +00:00
$this -> fileContentStatic [ '###HELPER_SITE_LICENSE_LOCK###' ] = $this -> setHelperLicenseLock ( $_VDM , 'site' );
$this -> fileContentStatic [ '###HELPER_LICENSE_LOCK###' ] = $this -> setHelperLicenseLock ( $_VDM , 'admin' );
2017-12-11 11:18:33 +00:00
$this -> fileContentStatic [ '###LICENSE_LOCKED_INT###' ] = $this -> setInitLicenseLock ( $_VDM );
2017-12-14 23:10:47 +00:00
$this -> fileContentStatic [ '###LICENSE_LOCKED_DEFINED###' ] = PHP_EOL . PHP_EOL . 'defined(\'' . $_VDM . '\') or die(JText::_(\'NIE_REG_NIE\'));' ;
2016-12-22 21:32:13 +00:00
}
2016-02-26 00:20:09 +00:00
}
else
{
// don't add it to the system
$this -> fileContentStatic [ '###HELPER_SITE_LICENSE_LOCK###' ] = '' ;
$this -> fileContentStatic [ '###HELPER_LICENSE_LOCK###' ] = '' ;
$this -> fileContentStatic [ '###LICENSE_LOCKED_INT###' ] = '' ;
$this -> fileContentStatic [ '###LICENSE_LOCKED_DEFINED###' ] = '' ;
}
}
2016-04-22 12:03:43 +00:00
/**
* @ param $view
2017-12-14 23:10:47 +00:00
*/
2016-12-22 21:32:13 +00:00
public function setLockLicensePer ( & $view , $target )
2016-02-26 00:20:09 +00:00
{
if ( $this -> componentData -> add_license && $this -> componentData -> license_type == 3 )
{
2016-12-22 21:32:13 +00:00
if ( ! isset ( $this -> fileContentDynamic [ $view ][ '###BOOLMETHOD###' ]))
{
2017-12-14 23:10:47 +00:00
$boolMethod = 'get' . ComponentbuilderHelper :: safeString ( $this -> uniquekey ( 3 , false , 'ddd' ), 'W' );
$globalbool = 'set' . ComponentbuilderHelper :: safeString ( $this -> uniquekey ( 3 ), 'W' );
2016-12-22 21:32:13 +00:00
// add it to the system
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $view ][ '###LICENSE_LOCKED_SET_BOOL###' ] = $this -> setBoolLicenseLock ( $boolMethod , $globalbool );
$this -> fileContentDynamic [ $view ][ '###LICENSE_LOCKED_CHECK###' ] = $this -> checkStatmentLicenseLocked ( $boolMethod );
$this -> fileContentDynamic [ $view ][ '###LICENSE_TABLE_LOCKED_CHECK###' ] = $this -> checkStatmentLicenseLocked ( $boolMethod , '$table' );
$this -> fileContentDynamic [ $view ][ '###BOOLMETHOD###' ] = $boolMethod ;
2016-12-22 21:32:13 +00:00
}
2016-02-26 00:20:09 +00:00
}
else
{
// don't add it to the system
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $view ][ '###LICENSE_LOCKED_SET_BOOL###' ] = '' ;
$this -> fileContentDynamic [ $view ][ '###LICENSE_LOCKED_CHECK###' ] = '' ;
$this -> fileContentDynamic [ $view ][ '###LICENSE_TABLE_LOCKED_CHECK###' ] = '' ;
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
2016-11-22 17:08:17 +00:00
public function checkStatmentLicenseLocked ( $boolMethod , $thIIS = '$this' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$statment [] = PHP_EOL . " \t \t if (! " . $thIIS . " -> " . $boolMethod . " ()) " ;
2016-02-26 00:20:09 +00:00
$statment [] = " \t \t { " ;
2016-07-12 21:07:55 +00:00
$statment [] = " \t \t \t \$ app = JFactory::getApplication(); " ;
$statment [] = " \t \t \t \$ app->enqueueMessage(JText::_('NIE_REG_NIE'), 'error'); " ;
$statment [] = " \t \t \t \$ app->redirect('index.php'); " ;
2016-02-26 00:20:09 +00:00
$statment [] = " \t \t \t return false; " ;
$statment [] = " \t \t } " ;
// return the genuine mentod statement
2017-02-09 16:11:10 +00:00
return implode ( PHP_EOL , $statment );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
public function setBoolLicenseLock ( $boolMethod , $globalbool )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$bool [] = PHP_EOL . PHP_EOL . " \t /** " ;
2016-11-22 17:08:17 +00:00
$bool [] = " \t * The private bool. " ;
$bool [] = " \t **/ " ;
2017-12-14 23:10:47 +00:00
$bool [] = " \t private $ " . $globalbool . " ; " ;
$bool [] = PHP_EOL . " \t /** " ;
2016-02-26 00:20:09 +00:00
$bool [] = " \t * Check if this install has a license. " ;
$bool [] = " \t **/ " ;
2017-12-14 23:10:47 +00:00
$bool [] = " \t public function " . $boolMethod . " () " ;
2016-02-26 00:20:09 +00:00
$bool [] = " \t { " ;
2017-12-14 23:10:47 +00:00
$bool [] = " \t \t if(!empty( \$ this-> " . $globalbool . " )) " ;
2016-02-26 00:20:09 +00:00
$bool [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$bool [] = " \t \t \t return \$ this-> " . $globalbool . " ; " ;
2016-02-26 00:20:09 +00:00
$bool [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$bool [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the global params " ;
$bool [] = " \t \t \$ params = JComponentHelper::getParams('com_ " . $this -> fileContentStatic [ '###component###' ] . " ', true); " ;
2016-02-26 00:20:09 +00:00
$bool [] = " \t \t \$ license_key = \$ params->get('license_key', null); " ;
$bool [] = " \t \t if ( \$ license_key) " ;
$bool [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$bool [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " load the file " ;
$bool [] = " \t \t \t JLoader::import( 'vdm', JPATH_ADMINISTRATOR .'/components/com_ " . $this -> fileContentStatic [ '###component###' ] . " '); " ;
2016-02-26 00:20:09 +00:00
$bool [] = " \t \t \t \$ the = new VDM( \$ license_key); " ;
2017-12-14 23:10:47 +00:00
$bool [] = " \t \t \t \$ this-> " . $globalbool . " = \$ the->_is; " ;
$bool [] = " \t \t \t return \$ this-> " . $globalbool . " ; " ;
2016-02-26 00:20:09 +00:00
$bool [] = " \t \t } " ;
$bool [] = " \t \t return false; " ;
$bool [] = " \t } " ;
// return the genuine mentod statement
2017-02-09 16:11:10 +00:00
return implode ( PHP_EOL , $bool );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
public function setHelperLicenseLock ( $_VDM , $target )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$helper [] = PHP_EOL . PHP_EOL . " \t /** " ;
2016-02-26 00:20:09 +00:00
$helper [] = " \t * Check if this install has a license. " ;
$helper [] = " \t **/ " ;
$helper [] = " \t public static function isGenuine() " ;
$helper [] = " \t { " ;
2017-12-14 23:10:47 +00:00
$helper [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the global params " ;
$helper [] = " \t \t \$ params = JComponentHelper::getParams('com_ " . $this -> fileContentStatic [ '###component###' ] . " ', true); " ;
2016-02-26 00:20:09 +00:00
$helper [] = " \t \t \$ license_key = \$ params->get('license_key', null); " ;
$helper [] = " \t \t if ( \$ license_key) " ;
$helper [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$helper [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " load the file " ;
$helper [] = " \t \t \t JLoader::import( 'vdm', JPATH_ADMINISTRATOR .'/components/com_ " . $this -> fileContentStatic [ '###component###' ] . " '); " ;
2016-02-26 00:20:09 +00:00
$helper [] = " \t \t \t \$ the = new VDM( \$ license_key); " ;
$helper [] = " \t \t \t return \$ the->_is; " ;
$helper [] = " \t \t } " ;
$helper [] = " \t \t return false; " ;
$helper [] = " \t } " ;
// return the genuine mentod statement
2017-02-09 16:11:10 +00:00
return implode ( PHP_EOL , $helper );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
2017-12-11 11:18:33 +00:00
public function setInitLicenseLock ( $_VDM )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$init [] = PHP_EOL . " if (!defined(' " . $_VDM . " ')) " ;
2016-02-26 00:20:09 +00:00
$init [] = " { " ;
2017-12-14 23:10:47 +00:00
$init [] = " \t \$ allow = " . $this -> fileContentStatic [ '###Component###' ] . " Helper::isGenuine(); " ;
2016-02-26 00:20:09 +00:00
$init [] = " \t if ( \$ allow) " ;
$init [] = " \t { " ;
2017-12-14 23:10:47 +00:00
$init [] = " \t \t define(' " . $_VDM . " ', 1); " ;
2016-02-26 00:20:09 +00:00
$init [] = " \t } " ;
$init [] = " } " ;
// return the initializing statement
2017-02-09 16:11:10 +00:00
return implode ( PHP_EOL , $init );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
public function setVDMCryption ()
{
// make sure we have the correct file
if ( isset ( $this -> componentData -> whmcs_key ) && ComponentbuilderHelper :: checkString ( $this -> componentData -> whmcs_key ))
{
2017-09-13 00:37:43 +00:00
// Get the basic encryption.
2016-02-26 00:20:09 +00:00
$basickey = ComponentbuilderHelper :: getCryptKey ( 'basic' );
2017-09-13 00:37:43 +00:00
// Get the encryption object.
2016-02-26 00:20:09 +00:00
$basic = new FOFEncryptAes ( $basickey , 128 );
if ( ! empty ( $this -> componentData -> whmcs_key ) && $basickey && ! is_numeric ( $this -> componentData -> whmcs_key ) && $this -> componentData -> whmcs_key === base64_encode ( base64_decode ( $this -> componentData -> whmcs_key , true )))
{
2017-09-13 00:37:43 +00:00
// basic decrypt data whmcs_key.
2016-02-26 00:20:09 +00:00
$this -> componentData -> whmcs_key = rtrim ( $basic -> decryptString ( $this -> componentData -> whmcs_key ), " \0 " );
// set the needed string to connect to whmcs
$key [ " kasier " ] = $this -> componentData -> whmcs_url ;
$key [ " geheim " ] = $this -> componentData -> whmcs_key ;
$key [ " onthou " ] = 1 ;
// prep the call info
$theKey = base64_encode ( serialize ( $key ));
// set the script
$encrypt [] = " /** " ;
2017-12-14 23:10:47 +00:00
$encrypt [] = " * " . $this -> setLine ( __LINE__ ) . " VDM Class " ;
2016-02-26 00:20:09 +00:00
$encrypt [] = " **/ " ;
2017-12-14 23:10:47 +00:00
$encrypt [] = PHP_EOL . " class VDM " ;
2016-02-26 00:20:09 +00:00
$encrypt [] = " { " ;
$encrypt [] = " \t public \$ _key = false; " ;
$encrypt [] = " \t public \$ _is = false; " ;
$encrypt [] = " \t " ;
$encrypt [] = " \t public function __construct( \$ Vk5smi0wjnjb) " ;
$encrypt [] = " \t { " ;
$encrypt [] = " \t \t // get the session " ;
$encrypt [] = " \t \t \$ session = JFactory::getSession(); " ;
$encrypt [] = " \t \t \$ V2uekt2wcgwk = \$ session->get( \$ Vk5smi0wjnjb, null); " ;
$encrypt [] = " \t \t \$ h4sgrGsqq = \$ this->get( \$ Vk5smi0wjnjb, \$ V2uekt2wcgwk); " ;
2017-02-02 11:54:07 +00:00
$encrypt [] = " \t \t if (isset( \$ h4sgrGsqq['nuut']) && \$ h4sgrGsqq['nuut'] && (isset( \$ h4sgrGsqq['status']) && 'Active' === \$ h4sgrGsqq['status']) && isset( \$ h4sgrGsqq['eiegrendel']) && strlen( \$ h4sgrGsqq['eiegrendel']) > 300) " ;
2016-02-26 00:20:09 +00:00
$encrypt [] = " \t \t { " ;
$encrypt [] = " \t \t \t \$ session->set( \$ Vk5smi0wjnjb, \$ h4sgrGsqq['eiegrendel']); " ;
$encrypt [] = " \t \t } " ;
2017-02-02 11:54:07 +00:00
$encrypt [] = " \t \t if ((isset( \$ h4sgrGsqq['status']) && 'Active' === \$ h4sgrGsqq['status']) && isset( \$ h4sgrGsqq['md5hash']) && strlen( \$ h4sgrGsqq['md5hash']) == 32 && isset( \$ h4sgrGsqq['customfields']) && strlen( \$ h4sgrGsqq['customfields']) > 4) " ;
2016-02-26 00:20:09 +00:00
$encrypt [] = " \t \t { " ;
$encrypt [] = " \t \t \t \$ this->_key = md5( \$ h4sgrGsqq['customfields']); " ;
$encrypt [] = " \t \t } " ;
2017-02-02 11:54:07 +00:00
$encrypt [] = " \t \t if ((isset( \$ h4sgrGsqq['status']) && 'Active' === \$ h4sgrGsqq['status']) && isset( \$ h4sgrGsqq['md5hash']) && strlen( \$ h4sgrGsqq['md5hash']) == 32 ) " ;
2016-02-26 00:20:09 +00:00
$encrypt [] = " \t \t { " ;
$encrypt [] = " \t \t \t \$ this->_is = true; " ;
$encrypt [] = " \t \t } " ;
$encrypt [] = " \t } " ;
$encrypt [] = " \t " ;
2016-02-26 12:46:15 +00:00
$encrypt [] = " \t private function get( \$ Vk5smi0wjnjb, \$ V2uekt2wcgwk) " ;
2016-02-26 00:20:09 +00:00
$encrypt [] = " \t { " ;
2017-12-14 23:10:47 +00:00
$encrypt [] = " \t \t \$ Viioj50xuqu2 = unserialize(base64_decode(' " . $theKey . " ')); " ;
2016-02-26 00:20:09 +00:00
$encrypt [] = " \t \t \$ Visqfrd1caus = time() . md5(mt_rand(1000000000, 9999999999) . \$ Vk5smi0wjnjb); " ;
$encrypt [] = " \t \t \$ Vo4tezfgcf3e = date( \" Ymd \" ); " ;
$encrypt [] = " \t \t \$ Vozblwvfym2f = \$ _SERVER['SERVER_NAME']; " ;
$encrypt [] = " \t \t \$ Vozblwvfym2fdie = isset( \$ _SERVER['SERVER_ADDR']) ? \$ _SERVER['SERVER_ADDR'] : \$ _SERVER['LOCAL_ADDR']; " ;
$encrypt [] = " \t \t \$ V343jp03dxco = dirname(__FILE__); " ;
$encrypt [] = " \t \t \$ Vc2rayehw4f0 = unserialize(base64_decode('czozNjoibW9kdWxlcy9zZXJ2ZXJzL2xpY2Vuc2luZy92ZXJpZnkucGhwIjs=')); " ;
$encrypt [] = " \t \t \$ Vlpolphukogz = false; " ;
$encrypt [] = " \t \t if ( \$ V2uekt2wcgwk) { " ;
2017-12-14 23:10:47 +00:00
$encrypt [] = " \t \t \t \$ V2uekt2wcgwk = str_replace( \" " . '".PHP_EOL."' . " \" , '', \$ V2uekt2wcgwk); " ;
2016-02-26 00:20:09 +00:00
$encrypt [] = " \t \t \t \$ Vm5cxjdc43g4 = substr( \$ V2uekt2wcgwk, 0, strlen( \$ V2uekt2wcgwk) - 32); " ;
$encrypt [] = " \t \t \t \$ Vbgx0efeu2sy = substr( \$ V2uekt2wcgwk, strlen( \$ V2uekt2wcgwk) - 32); " ;
$encrypt [] = " \t \t \t if ( \$ Vbgx0efeu2sy == md5( \$ Vm5cxjdc43g4 . \$ Viioj50xuqu2['geheim'])) { " ;
$encrypt [] = " \t \t \t \t \$ Vm5cxjdc43g4 = strrev( \$ Vm5cxjdc43g4); " ;
$encrypt [] = " \t \t \t \t \$ Vbgx0efeu2sy = substr( \$ Vm5cxjdc43g4, 0, 32); " ;
$encrypt [] = " \t \t \t \t \$ Vm5cxjdc43g4 = substr( \$ Vm5cxjdc43g4, 32); " ;
$encrypt [] = " \t \t \t \t \$ Vm5cxjdc43g4 = base64_decode( \$ Vm5cxjdc43g4); " ;
$encrypt [] = " \t \t \t \t \$ Vm5cxjdc43g4finding = unserialize( \$ Vm5cxjdc43g4); " ;
$encrypt [] = " \t \t \t \t \$ V3qqz0p00fbq = \$ Vm5cxjdc43g4finding['dan']; " ;
$encrypt [] = " \t \t \t \t if ( \$ Vbgx0efeu2sy == md5( \$ V3qqz0p00fbq . \$ Viioj50xuqu2['geheim'])) { " ;
$encrypt [] = " \t \t \t \t \t \$ Vbfbwv2y4kre = date( \" Ymd \" , mktime(0, 0, 0, date( \" m \" ), date( \" d \" ) - \$ Viioj50xuqu2['onthou'], date( \" Y \" ))); " ;
$encrypt [] = " \t \t \t \t \t if ( \$ V3qqz0p00fbq > \$ Vbfbwv2y4kre) { " ;
$encrypt [] = " \t \t \t \t \t \t \$ Vlpolphukogz = true; " ;
$encrypt [] = " \t \t \t \t \t \t \$ Vwasqoybpyed = \$ Vm5cxjdc43g4finding; " ;
$encrypt [] = " \t \t \t \t \t \t \$ Vcixw3trerrt = explode(',', \$ Vwasqoybpyed['validdomain']); " ;
$encrypt [] = " \t \t \t \t \t \t if (!in_array( \$ _SERVER['SERVER_NAME'], \$ Vcixw3trerrt)) { " ;
$encrypt [] = " \t \t \t \t \t \t \t \$ Vlpolphukogz = false; " ;
$encrypt [] = " \t \t \t \t \t \t \t \$ Vm5cxjdc43g4finding['status'] = \" sleg \" ; " ;
$encrypt [] = " \t \t \t \t \t \t \t \$ Vwasqoybpyed = array(); " ;
$encrypt [] = " \t \t \t \t \t \t } " ;
$encrypt [] = " \t \t \t \t \t \t \$ Vkni3xyhkqzv = explode(',', \$ Vwasqoybpyed['validip']); " ;
$encrypt [] = " \t \t \t \t \t \t if (!in_array( \$ Vozblwvfym2fdie, \$ Vkni3xyhkqzv)) { " ;
$encrypt [] = " \t \t \t \t \t \t \t \$ Vlpolphukogz = false; " ;
$encrypt [] = " \t \t \t \t \t \t \t \$ Vm5cxjdc43g4finding['status'] = \" sleg \" ; " ;
$encrypt [] = " \t \t \t \t \t \t \t \$ Vwasqoybpyed = array(); " ;
$encrypt [] = " \t \t \t \t \t \t } " ;
$encrypt [] = " \t \t \t \t \t \t \$ Vckfvnepoaxj = explode(',', \$ Vwasqoybpyed['validdirectory']); " ;
$encrypt [] = " \t \t \t \t \t \t if (!in_array( \$ V343jp03dxco, \$ Vckfvnepoaxj)) { " ;
$encrypt [] = " \t \t \t \t \t \t \t \$ Vlpolphukogz = false; " ;
$encrypt [] = " \t \t \t \t \t \t \t \$ Vm5cxjdc43g4finding['status'] = \" sleg \" ; " ;
$encrypt [] = " \t \t \t \t \t \t \t \$ Vwasqoybpyed = array(); " ;
$encrypt [] = " \t \t \t \t \t \t } " ;
$encrypt [] = " \t \t \t \t \t } " ;
$encrypt [] = " \t \t \t \t } " ;
$encrypt [] = " \t \t \t } " ;
$encrypt [] = " \t \t } " ;
$encrypt [] = " \t \t if (! \$ Vlpolphukogz) { " ;
$encrypt [] = " \t \t \t \$ V1u0c4dl3ehp = array( " ;
$encrypt [] = " \t \t \t \t 'licensekey' => \$ Vk5smi0wjnjb, " ;
$encrypt [] = " \t \t \t \t 'domain' => \$ Vozblwvfym2f, " ;
$encrypt [] = " \t \t \t \t 'ip' => \$ Vozblwvfym2fdie, " ;
$encrypt [] = " \t \t \t \t 'dir' => \$ V343jp03dxco, " ;
$encrypt [] = " \t \t \t ); " ;
$encrypt [] = " \t \t \t if ( \$ Visqfrd1caus) \$ V1u0c4dl3ehp['check_token'] = \$ Visqfrd1caus; " ;
$encrypt [] = " \t \t \t \$ Vdsjeyjmpq2o = ''; " ;
$encrypt [] = " \t \t \t foreach ( \$ V1u0c4dl3ehp AS \$ V2sgyscukmgi=> \$ V1u00zkzmb1d) { " ;
$encrypt [] = " \t \t \t \t \$ Vdsjeyjmpq2o .= \$ V2sgyscukmgi.'='.urlencode( \$ V1u00zkzmb1d).'&'; " ;
$encrypt [] = " \t \t \t } " ;
$encrypt [] = " \t \t \t if (function_exists('curl_exec')) { " ;
$encrypt [] = " \t \t \t \t \$ Vdathuqgjyf0 = curl_init(); " ;
$encrypt [] = " \t \t \t \t curl_setopt( \$ Vdathuqgjyf0, CURLOPT_URL, \$ Viioj50xuqu2['kasier'] . \$ Vc2rayehw4f0); " ;
$encrypt [] = " \t \t \t \t curl_setopt( \$ Vdathuqgjyf0, CURLOPT_POST, 1); " ;
$encrypt [] = " \t \t \t \t curl_setopt( \$ Vdathuqgjyf0, CURLOPT_POSTFIELDS, \$ Vdsjeyjmpq2o); " ;
$encrypt [] = " \t \t \t \t curl_setopt( \$ Vdathuqgjyf0, CURLOPT_TIMEOUT, 30); " ;
$encrypt [] = " \t \t \t \t curl_setopt( \$ Vdathuqgjyf0, CURLOPT_RETURNTRANSFER, 1); " ;
$encrypt [] = " \t \t \t \t \$ Vqojefyeohg5 = curl_exec( \$ Vdathuqgjyf0); " ;
$encrypt [] = " \t \t \t \t curl_close( \$ Vdathuqgjyf0); " ;
$encrypt [] = " \t \t \t } else { " ;
$encrypt [] = " \t \t \t \t \$ Vrpmu4bvnmkp = fsockopen( \$ Viioj50xuqu2['kasier'], 80, \$ Vc0t5kmpwkwk, \$ Va3g41fnofhu, 5); " ;
$encrypt [] = " \t \t \t \t if ( \$ Vrpmu4bvnmkp) { " ;
2017-12-14 23:10:47 +00:00
$encrypt [] = " \t \t \t \t \t \$ Vznkm0a0me1y = \" \r " . PHP_EOL . " \" ; " ;
2016-02-26 00:20:09 +00:00
$encrypt [] = " \t \t \t \t \t \$ V2sgyscukmgiop = \" POST \" . \$ Viioj50xuqu2['kasier'] . \$ Vc2rayehw4f0 . \" HTTP/1.0 \" . \$ Vznkm0a0me1y; " ;
$encrypt [] = " \t \t \t \t \t \$ V2sgyscukmgiop .= \" Host: \" . \$ Viioj50xuqu2['kasier'] . \$ Vznkm0a0me1y; " ;
$encrypt [] = " \t \t \t \t \t \$ V2sgyscukmgiop .= \" Content-type: application/x-www-form-urlencoded \" . \$ Vznkm0a0me1y; " ;
$encrypt [] = " \t \t \t \t \t \$ V2sgyscukmgiop .= \" Content-length: \" .@strlen( \$ Vdsjeyjmpq2o) . \$ Vznkm0a0me1y; " ;
$encrypt [] = " \t \t \t \t \t \$ V2sgyscukmgiop .= \" Connection: close \" . \$ Vznkm0a0me1y . \$ Vznkm0a0me1y; " ;
$encrypt [] = " \t \t \t \t \t \$ V2sgyscukmgiop .= \$ Vdsjeyjmpq2o; " ;
$encrypt [] = " \t \t \t \t \t \$ Vqojefyeohg5 = ''; " ;
$encrypt [] = " \t \t \t \t \t @stream_set_timeout( \$ Vrpmu4bvnmkp, 20); " ;
$encrypt [] = " \t \t \t \t \t @fputs( \$ Vrpmu4bvnmkp, \$ V2sgyscukmgiop); " ;
$encrypt [] = " \t \t \t \t \t \$ V2czq24pjexf = @socket_get_status( \$ Vrpmu4bvnmkp); " ;
$encrypt [] = " \t \t \t \t \t while (!@feof( \$ Vrpmu4bvnmkp)&& \$ V2czq24pjexf) { " ;
$encrypt [] = " \t \t \t \t \t \t \$ Vqojefyeohg5 .= @fgets( \$ Vrpmu4bvnmkp, 1024); " ;
$encrypt [] = " \t \t \t \t \t \t \$ V2czq24pjexf = @socket_get_status( \$ Vrpmu4bvnmkp); " ;
$encrypt [] = " \t \t \t \t \t } " ;
$encrypt [] = " \t \t \t \t \t @fclose ( \$ Vqojefyeohg5); " ;
$encrypt [] = " \t \t \t \t } " ;
$encrypt [] = " \t \t \t } " ;
$encrypt [] = " \t \t \t if (! \$ Vqojefyeohg5) { " ;
$encrypt [] = " \t \t \t \t \$ Vbfbwv2y4kre = date( \" Ymd \" , mktime(0, 0, 0, date( \" m \" ), date( \" d \" ) - \$ Viioj50xuqu2['onthou'], date( \" Y \" ))); " ;
$encrypt [] = " \t \t \t \t if (isset( \$ V3qqz0p00fbq) && \$ V3qqz0p00fbq > \$ Vbfbwv2y4kre) { " ;
$encrypt [] = " \t \t \t \t \t \$ Vwasqoybpyed = \$ Vm5cxjdc43g4finding; " ;
$encrypt [] = " \t \t \t \t } else { " ;
$encrypt [] = " \t \t \t \t \t \$ Vwasqoybpyed = array(); " ;
$encrypt [] = " \t \t \t \t \t \$ Vwasqoybpyed['status'] = \" sleg \" ; " ;
$encrypt [] = " \t \t \t \t \t \$ Vwasqoybpyed['description'] = \" Remote Check Failed \" ; " ;
$encrypt [] = " \t \t \t \t \t return \$ Vwasqoybpyed; " ;
$encrypt [] = " \t \t \t \t } " ;
$encrypt [] = " \t \t \t } else { " ;
2017-12-14 23:10:47 +00:00
$encrypt [] = " \t \t \t \t preg_match_all(' " . '/<(.*?)>([^<]+)<\/\\1>/i' . " ', \$ Vqojefyeohg5, \$ V1ot20wob03f); " ;
2016-02-26 00:20:09 +00:00
$encrypt [] = " \t \t \t \t \$ Vwasqoybpyed = array(); " ;
$encrypt [] = " \t \t \t \t foreach ( \$ V1ot20wob03f[1] AS \$ V2sgyscukmgi=> \$ V1u00zkzmb1d) { " ;
$encrypt [] = " \t \t \t \t \t \$ Vwasqoybpyed[ \$ V1u00zkzmb1d] = \$ V1ot20wob03f[2][ \$ V2sgyscukmgi]; " ;
$encrypt [] = " \t \t \t \t } " ;
$encrypt [] = " \t \t \t } " ;
$encrypt [] = " \t \t \t if (!is_array( \$ Vwasqoybpyed)) { " ;
$encrypt [] = " \t \t \t \t die( \" Invalid License Server Response \" ); " ;
$encrypt [] = " \t \t \t } " ;
$encrypt [] = " \t \t \t if (isset( \$ Vwasqoybpyed['md5hash']) && \$ Vwasqoybpyed['md5hash']) { " ;
$encrypt [] = " \t \t \t \t if ( \$ Vwasqoybpyed['md5hash'] != md5( \$ Viioj50xuqu2['geheim'] . \$ Visqfrd1caus)) { " ;
$encrypt [] = " \t \t \t \t \t \$ Vwasqoybpyed['status'] = \" sleg \" ; " ;
$encrypt [] = " \t \t \t \t \t \$ Vwasqoybpyed['description'] = \" MD5 Checksum Verification Failed \" ; " ;
$encrypt [] = " \t \t \t \t \t return \$ Vwasqoybpyed; " ;
$encrypt [] = " \t \t \t \t } " ;
$encrypt [] = " \t \t \t } " ;
$encrypt [] = " \t \t \t if (isset( \$ Vwasqoybpyed['status']) && \$ Vwasqoybpyed['status'] == \" Active \" ) { " ;
$encrypt [] = " \t \t \t \t \$ Vwasqoybpyed['dan'] = \$ Vo4tezfgcf3e; " ;
$encrypt [] = " \t \t \t \t \$ Vqojefyeohg5ing = serialize( \$ Vwasqoybpyed); " ;
$encrypt [] = " \t \t \t \t \$ Vqojefyeohg5ing = base64_encode( \$ Vqojefyeohg5ing); " ;
$encrypt [] = " \t \t \t \t \$ Vqojefyeohg5ing = md5( \$ Vo4tezfgcf3e . \$ Viioj50xuqu2['geheim']) . \$ Vqojefyeohg5ing; " ;
$encrypt [] = " \t \t \t \t \$ Vqojefyeohg5ing = strrev( \$ Vqojefyeohg5ing); " ;
$encrypt [] = " \t \t \t \t \$ Vqojefyeohg5ing = \$ Vqojefyeohg5ing . md5( \$ Vqojefyeohg5ing . \$ Viioj50xuqu2['geheim']); " ;
2017-12-14 23:10:47 +00:00
$encrypt [] = " \t \t \t \t \$ Vqojefyeohg5ing = wordwrap( \$ Vqojefyeohg5ing, 80, \" " . '".PHP_EOL."' . " \" , true); " ;
2016-02-26 00:20:09 +00:00
$encrypt [] = " \t \t \t \t \$ Vwasqoybpyed['eiegrendel'] = \$ Vqojefyeohg5ing; " ;
$encrypt [] = " \t \t \t } " ;
$encrypt [] = " \t \t \t \$ Vwasqoybpyed['nuut'] = true; " ;
$encrypt [] = " \t \t } " ;
$encrypt [] = " \t \t unset( \$ V1u0c4dl3ehp, \$ Vqojefyeohg5, \$ V1ot20wob03f, \$ Viioj50xuqu2['kasier'], \$ Viioj50xuqu2['geheim'], \$ Vo4tezfgcf3e, \$ Vozblwvfym2fdie, \$ Viioj50xuqu2['onthou'], \$ Vbgx0efeu2sy); " ;
$encrypt [] = " \t \t return \$ Vwasqoybpyed; " ;
$encrypt [] = " \t } " ;
$encrypt [] = " } " ;
// return the help methods
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $encrypt );
2016-02-26 00:20:09 +00:00
}
}
return '' ;
}
public function setGetCryptKey ()
{
// ###ENCRYPT_FILE###
$this -> fileContentStatic [ '###ENCRYPT_FILE###' ] = '' ;
if (( isset ( $this -> basicEncryptionBuilder ) && ComponentbuilderHelper :: checkArray ( $this -> basicEncryptionBuilder )) || ( isset ( $this -> advancedEncryptionBuilder ) && ComponentbuilderHelper :: checkArray ( $this -> advancedEncryptionBuilder )) || $this -> componentData -> add_license )
{
if ( isset ( $this -> advancedEncryptionBuilder ) && ComponentbuilderHelper :: checkArray ( $this -> advancedEncryptionBuilder ) || $this -> componentData -> add_license )
{
// set advanced encrypt file into place
$target = array ( 'admin' => 'encrypt' );
2017-12-14 23:10:47 +00:00
$done = $this -> buildDynamique ( $target , 'encrypt' );
2016-02-26 00:20:09 +00:00
// the text for the file ###VDM_ENCRYPTION_BODY###
$this -> fileContentDynamic [ 'encrypt' ][ '###VDM_ENCRYPTION_BODY###' ] = $this -> setVDMCryption ();
// ###ENCRYPT_FILE###
2017-12-14 23:10:47 +00:00
$this -> fileContentStatic [ '###ENCRYPT_FILE###' ] = PHP_EOL . " \t \t \t <filename>vdm.php</filename> " ;
2016-02-26 00:20:09 +00:00
}
// get component name
2017-12-14 23:10:47 +00:00
$component = $this -> fileContentStatic [ '###component###' ];
2016-02-26 00:20:09 +00:00
// set the getCryptKey function to the helper class
$function = array ();
if ( isset ( $this -> basicEncryptionBuilder ) && ComponentbuilderHelper :: checkArray ( $this -> basicEncryptionBuilder ) && ComponentbuilderHelper :: checkArray ( $this -> advancedEncryptionBuilder ))
{
2017-12-14 23:10:47 +00:00
$function [] = PHP_EOL . PHP_EOL . " \t public static function getCryptKey( \$ type, \$ default = null) " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t { " ;
2017-12-14 23:10:47 +00:00
$function [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the global params " ;
$function [] = " \t \t \$ params = JComponentHelper::getParams('com_ " . $component . " ', true); " ;
2017-02-02 11:54:07 +00:00
$function [] = " \t \t if ('advanced' === \$ type) " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t { " ;
2016-11-22 05:48:55 +00:00
$function [] = " \t \t \t \$ advanced_key = \$ params->get('advanced_key', \$ default); " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t \t if ( \$ advanced_key) " ;
$function [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$function [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " load the file " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t \t \t JLoader::import( 'vdm', JPATH_COMPONENT_ADMINISTRATOR); " ;
2017-12-14 23:10:47 +00:00
$function [] = PHP_EOL . " \t \t \t \t \$ the = new VDM( \$ advanced_key); " ;
$function [] = PHP_EOL . " \t \t \t \t return \$ the->_key; " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t \t } " ;
$function [] = " \t \t } " ;
2017-02-02 11:54:07 +00:00
$function [] = " \t \t elseif ('basic' === \$ type) " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t { " ;
2016-11-22 05:48:55 +00:00
$function [] = " \t \t \t \$ basic_key = \$ params->get('basic_key', \$ default); " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t \t if ( \$ basic_key) " ;
$function [] = " \t \t \t { " ;
$function [] = " \t \t \t \t return \$ basic_key; " ;
$function [] = " \t \t \t } " ;
$function [] = " \t \t } " ;
$function [] = " \t \t return false; " ;
$function [] = " \t } " ;
}
elseif ( isset ( $this -> advancedEncryptionBuilder ) && ComponentbuilderHelper :: checkArray ( $this -> advancedEncryptionBuilder ))
{
2017-12-14 23:10:47 +00:00
$function [] = PHP_EOL . PHP_EOL . " \t public static function getCryptKey( \$ type, \$ default = null) " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t { " ;
2017-02-02 11:54:07 +00:00
$function [] = " \t \t if ('advanced' === \$ type) " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$function [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Get the global params " ;
$function [] = " \t \t \t \$ params = JComponentHelper::getParams('com_ " . $component . " ', true); " ;
2016-11-22 05:48:55 +00:00
$function [] = " \t \t \t \$ advanced_key = \$ params->get('advanced_key', \$ default); " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t \t if ( \$ advanced_key) " ;
$function [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$function [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " load the file " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t \t \t JLoader::import( 'vdm', JPATH_COMPONENT_ADMINISTRATOR); " ;
2017-12-14 23:10:47 +00:00
$function [] = PHP_EOL . " \t \t \t \t \$ the = new VDM( \$ advanced_key); " ;
$function [] = PHP_EOL . " \t \t \t \t return \$ the->_key; " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t \t } " ;
$function [] = " \t \t } " ;
$function [] = " \t \t return false; " ;
$function [] = " \t } " ;
}
elseif ( isset ( $this -> basicEncryptionBuilder ) && ComponentbuilderHelper :: checkArray ( $this -> basicEncryptionBuilder ))
{
2017-12-14 23:10:47 +00:00
$function [] = PHP_EOL . PHP_EOL . " \t public static function getCryptKey( \$ type, \$ default = null) " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t { " ;
2017-02-02 11:54:07 +00:00
$function [] = " \t \t if ('basic' === \$ type) " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$function [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Get the global params " ;
$function [] = " \t \t \t \$ params = JComponentHelper::getParams('com_ " . $component . " ', true); " ;
2016-11-22 05:48:55 +00:00
$function [] = " \t \t \t \$ basic_key = \$ params->get('basic_key', \$ default); " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t \t if ( \$ basic_key) " ;
$function [] = " \t \t \t { " ;
$function [] = " \t \t \t \t return \$ basic_key; " ;
$function [] = " \t \t \t } " ;
$function [] = " \t \t } " ;
$function [] = " \t \t return false; " ;
$function [] = " \t } " ;
}
// return the help methods
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $function );
2016-02-26 00:20:09 +00:00
}
return '' ;
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
public function setVersionController ()
{
2017-06-16 12:38:06 +00:00
if ( ComponentbuilderHelper :: checkArray ( $this -> componentData -> version_update ) || ComponentbuilderHelper :: checkArray ( $this -> updateSQLBuilder ))
2016-02-26 00:20:09 +00:00
{
$updateXML = array ();
// add the update server
2016-11-22 05:48:55 +00:00
if ( $this -> componentData -> add_update_server && $this -> componentData -> update_server_target != 3 )
2016-02-26 00:20:09 +00:00
{
$updateXML [] = '<updates>' ;
}
2017-12-14 23:10:47 +00:00
2017-06-16 12:38:06 +00:00
// add the dynamic sql switch
$addDynamicSQL = true ;
$addActive = true ;
if ( ComponentbuilderHelper :: checkArray ( $this -> componentData -> version_update ))
2016-02-26 00:20:09 +00:00
{
2017-06-16 12:38:06 +00:00
foreach ( $this -> componentData -> version_update as $nr => & $update )
2016-02-26 00:20:09 +00:00
{
2017-06-16 12:38:06 +00:00
$this -> setUpdateXMLSQL ( $update , $updateXML , $addDynamicSQL );
2017-12-14 23:10:47 +00:00
2017-06-16 12:38:06 +00:00
if ( $update [ 'version' ] == $this -> componentData -> component_version )
2016-02-26 00:20:09 +00:00
{
2017-06-16 12:38:06 +00:00
$addActive = false ;
2016-02-26 00:20:09 +00:00
}
}
}
2017-06-16 12:38:06 +00:00
// add the dynamic sql if not already added
if ( $addDynamicSQL && ComponentbuilderHelper :: checkArray ( $this -> updateSQLBuilder ))
{
// add the dynamic sql
$this -> setDynamicUpdateXMLSQL ( $updateXML );
}
// add the new active version if needed
if ( $addActive && ComponentbuilderHelper :: checkArray ( $this -> updateSQLBuilder ))
{
// add the dynamic sql
$this -> setDynamicUpdateXMLSQL ( $updateXML , $addActive );
}
2016-11-22 05:48:55 +00:00
// add the update server file
if ( $this -> componentData -> add_update_server && $this -> componentData -> update_server_target != 3 )
2016-02-26 00:20:09 +00:00
{
$updateXML [] = '</updates>' ;
// ###UPDATE_SERVER_XML###
$name = str_replace ( '.xml' , '' , substr ( $this -> componentData -> update_server , strrpos ( $this -> componentData -> update_server , '/' ) + 1 ));
$target = array ( 'admin' => $name );
2017-12-14 23:10:47 +00:00
$this -> buildDynamique ( $target , 'update_server' );
2017-02-09 16:11:10 +00:00
$this -> fileContentDynamic [ $name ][ '###UPDATE_SERVER_XML###' ] = implode ( PHP_EOL , $updateXML );
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
// set the Update server file name
$this -> updateServerFileName = $name ;
}
}
2016-11-22 05:48:55 +00:00
// add the update server link to component XML
if ( $this -> componentData -> add_update_server && isset ( $this -> componentData -> update_server ) && ComponentbuilderHelper :: checkString ( $this -> componentData -> update_server ))
{
// ###UPDATESERVER###
$updateServer = array ();
2017-12-14 23:10:47 +00:00
$updateServer [] = PHP_EOL . " \t <updateservers> " ;
$updateServer [] = " \t \t " . '<server type="extension" enabled="1" element="com_' . $this -> fileContentStatic [ '###component###' ] . '" name="' . $this -> fileContentStatic [ '###Component_name###' ] . '">' . $this -> componentData -> update_server . '</server>' ;
2016-11-22 05:48:55 +00:00
$updateServer [] = " \t </updateservers> " ;
// return the array to string
2017-02-09 16:11:10 +00:00
$updateServer = implode ( PHP_EOL , $updateServer );
2017-07-20 23:26:48 +00:00
// add update server details to component XML file
$this -> fileContentStatic [ '###UPDATESERVER###' ] = $updateServer ;
}
else
{
// add update server details to component XML file
$this -> fileContentStatic [ '###UPDATESERVER###' ] = '' ;
2016-11-22 05:48:55 +00:00
}
2017-06-16 12:38:06 +00:00
// ensure to update Component version data
if ( ComponentbuilderHelper :: checkArray ( $this -> updateSQLBuilder ))
{
$buket = array ();
2017-10-30 13:08:02 +00:00
$nr = 0 ;
2017-06-16 12:38:06 +00:00
foreach ( $this -> componentData -> version_update as $values )
{
2017-12-14 23:10:47 +00:00
$buket [ 'version_update' . $nr ] = $values ;
2017-10-30 13:08:02 +00:00
$nr ++ ;
2017-12-14 23:10:47 +00:00
}
2017-10-30 13:08:02 +00:00
// update the joomla component table
$newJ = array ();
$newJ [ 'id' ] = ( int ) $this -> componentID ;
$newJ [ 'component_version' ] = $this -> componentData -> component_version ;
2017-06-16 12:38:06 +00:00
// update the component with the new dynamic SQL
2017-10-30 13:08:02 +00:00
$modelJ = ComponentbuilderHelper :: getModel ( 'joomla_component' );
$modelJ -> save ( $newJ ); // <-- to insure the history is also updated
2017-06-16 12:38:06 +00:00
// reset the watch here
$this -> getHistoryWatch ( 'joomla_component' , $this -> componentID );
2017-10-30 13:08:02 +00:00
// update the component update table
$newU = array ();
2017-11-06 14:04:23 +00:00
if ( isset ( $this -> componentData -> version_update_id ) && $this -> componentData -> version_update_id > 0 )
{
$newU [ 'id' ] = ( int ) $this -> componentData -> version_update_id ;
}
else
{
$newU [ 'joomla_component' ] = ( int ) $this -> componentID ;
}
2017-10-30 13:08:02 +00:00
$newU [ 'version_update' ] = json_encode ( $buket );
// update the component with the new dynamic SQL
$modelU = ComponentbuilderHelper :: getModel ( 'component_updates' );
$modelU -> save ( $newU ); // <-- to insure the history is also updated
2017-06-16 12:38:06 +00:00
}
2017-12-14 23:10:47 +00:00
}
2017-06-16 12:38:06 +00:00
public function setDynamicUpdateXMLSQL ( & $updateXML , $current_version = false )
{
// start building the update
$update_ = array ();
if ( $current_version )
{
// setup new version
$update_ [ 'version' ] = $this -> componentData -> component_version ;
// setup SQL
$update_ [ 'mysql' ] = '' ;
// setup URL
$update_ [ 'url' ] = 'http://domain.com/demo.zip' ;
}
else
{
// setup new version
$update_ [ 'version' ] = $this -> componentData -> old_component_version ;
// setup SQL
2017-12-14 23:10:47 +00:00
$update_ [ 'mysql' ] = trim ( implode ( PHP_EOL . PHP_EOL , $this -> updateSQLBuilder ));
2017-06-16 12:38:06 +00:00
// setup URL
if ( isset ( $this -> lastupdateURL ))
{
$paceholders = array (
$this -> componentData -> component_version => $this -> componentData -> old_component_version ,
2017-12-14 23:10:47 +00:00
str_replace ( '.' , '-' , $this -> componentData -> component_version ) => str_replace ( '.' , '-' , $this -> componentData -> old_component_version ),
str_replace ( '.' , '_' , $this -> componentData -> component_version ) => str_replace ( '.' , '_' , $this -> componentData -> old_component_version ),
str_replace ( '.' , '' , $this -> componentData -> component_version ) => str_replace ( '.' , '' , $this -> componentData -> old_component_version )
2017-06-16 12:38:06 +00:00
);
$update_ [ 'url' ] = $this -> setPlaceholders ( $this -> lastupdateURL , $paceholders );
}
else
{
// setup URL
$update_ [ 'url' ] = 'http://domain.com/demo.zip' ;
}
}
// stop it from being added double
$addDynamicSQL = false ;
$this -> componentData -> version_update [] = $update_ ;
// add dynamic SQL
$this -> setUpdateXMLSQL ( $update_ , $updateXML , $addDynamicSQL );
}
2017-12-14 23:10:47 +00:00
2017-06-16 12:38:06 +00:00
public function setUpdateXMLSQL ( & $update , & $updateXML , & $addDynamicSQL )
{
// ensure version naming is correct
$update [ 'version' ] = preg_replace ( '/[^0-9.]+/' , '' , $update [ 'version' ]);
// setup SQL
if ( ComponentbuilderHelper :: checkString ( $update [ 'mysql' ]))
{
$update [ 'mysql' ] = $this -> setPlaceholders ( $update [ 'mysql' ], $this -> placeholders );
}
// add dynamic SQL
$force = false ;
2017-12-14 23:10:47 +00:00
if ( $addDynamicSQL && ComponentbuilderHelper :: checkArray ( $this -> updateSQLBuilder ) && ( isset ( $this -> componentData -> old_component_version ) && $this -> componentData -> old_component_version == $update [ 'version' ]))
2017-06-16 12:38:06 +00:00
{
$searchMySQL = preg_replace ( '/\s+/' , '' , $update [ 'mysql' ]);
// add the updates to the SQL only if not found
foreach ( $this -> updateSQLBuilder as $search => $query )
{
if ( strpos ( $searchMySQL , $search ) === FALSE )
{
2017-12-14 23:10:47 +00:00
$update [ 'mysql' ] .= PHP_EOL . PHP_EOL . $query ;
2017-06-16 12:38:06 +00:00
}
}
// make sure no unneeded white space is added
$update [ 'mysql' ] = trim ( $update [ 'mysql' ]);
// update has been added
$addDynamicSQL = false ;
}
// setup import files
if ( $update [ 'version' ] != $this -> componentData -> component_version )
{
$name = ComponentbuilderHelper :: safeString ( $update [ 'version' ]);
$target = array ( 'admin' => $name );
2017-12-14 23:10:47 +00:00
$this -> buildDynamique ( $target , 'sql_update' , $update [ 'version' ]);
$this -> fileContentDynamic [ $name . '_' . $update [ 'version' ]][ '###UPDATE_VERSION_MYSQL###' ] = $update [ 'mysql' ];
2017-06-16 12:38:06 +00:00
}
elseif ( isset ( $update [ 'url' ]) && ComponentbuilderHelper :: checkString ( $update [ 'url' ]))
{
$this -> lastupdateURL = $update [ 'url' ];
}
// add the update server
if ( $this -> componentData -> add_update_server && $this -> componentData -> update_server_target != 3 )
{
// build update xml
$updateXML [] = " \t <update> " ;
2017-12-14 23:10:47 +00:00
$updateXML [] = " \t \t <name> " . $this -> fileContentStatic [ '###Component_name###' ] . " </name> " ;
$updateXML [] = " \t \t <description> " . $this -> fileContentStatic [ '###SHORT_DESCRIPTION###' ] . " </description> " ;
$updateXML [] = " \t \t <element>com_ " . $this -> fileContentStatic [ '###component###' ] . " </element> " ;
2017-06-16 12:38:06 +00:00
$updateXML [] = " \t \t <type>component</type> " ;
2017-12-14 23:10:47 +00:00
$updateXML [] = " \t \t <version> " . $update [ 'version' ] . " </version> " ;
$updateXML [] = " \t \t " . '<infourl title="' . $this -> fileContentStatic [ '###Component_name###' ] . '!">' . $this -> fileContentStatic [ '###AUTHORWEBSITE###' ] . '</infourl>' ;
2017-06-16 12:38:06 +00:00
$updateXML [] = " \t \t <downloads> " ;
if ( ! isset ( $update [ 'url' ]) || ! ComponentbuilderHelper :: checkString ( $update [ 'url' ]))
{
$update [ 'url' ] = 'http://domain.com/demo.zip' ;
}
2017-12-14 23:10:47 +00:00
$updateXML [] = " \t \t \t " . '<downloadurl type="full" format="zip">' . $update [ 'url' ] . '</downloadurl>' ;
2017-06-16 12:38:06 +00:00
$updateXML [] = " \t \t </downloads> " ;
$updateXML [] = " \t \t <tags> " ;
$updateXML [] = " \t \t \t <tag>stable</tag> " ;
$updateXML [] = " \t \t </tags> " ;
2017-12-14 23:10:47 +00:00
$updateXML [] = " \t \t <maintainer> " . $this -> fileContentStatic [ '###AUTHOR###' ] . " </maintainer> " ;
$updateXML [] = " \t \t <maintainerurl> " . $this -> fileContentStatic [ '###AUTHORWEBSITE###' ] . " </maintainerurl> " ;
$updateXML [] = " \t \t " . '<targetplatform name="joomla" version="3.*"/>' ;
2017-06-16 12:38:06 +00:00
$updateXML [] = " \t </update> " ;
}
2016-02-26 00:20:09 +00:00
}
public function noHelp ()
{
$help = array ();
2017-12-14 23:10:47 +00:00
$help [] = PHP_EOL . PHP_EOL . " \t /** " ;
2016-02-26 00:20:09 +00:00
$help [] = " \t * Can be used to build help urls. " ;
$help [] = " \t **/ " ;
$help [] = " \t public static function getHelpUrl( \$ view) " ;
$help [] = " \t { " ;
$help [] = " \t \t return false; " ;
$help [] = " \t } " ;
// return the no help method
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $help );
2016-02-26 00:20:09 +00:00
}
public function checkHelp ( $viewName_single )
{
if ( $viewName_single == " help_document " )
{
// set help file into admin place
$target = array ( 'admin' => 'help' );
2017-12-14 23:10:47 +00:00
$admindone = $this -> buildDynamique ( $target , 'help' );
2016-02-26 00:20:09 +00:00
// set the help file into site place
$target = array ( 'site' => 'help' );
2017-12-14 23:10:47 +00:00
$sitedone = $this -> buildDynamique ( $target , 'help' );
2016-02-26 00:20:09 +00:00
if ( $admindone && $sitedone )
{
// ###HELP###
$this -> fileContentStatic [ '###HELP###' ] = $this -> setHelp ( 1 );
// ###HELP_SITE###
$this -> fileContentStatic [ '###HELP_SITE###' ] = $this -> setHelp ( 2 );
// to make sure the file is updated TODO
$this -> fileContentDynamic [ 'help' ][ '###BLABLA###' ] = 'blabla' ;
return true ;
}
}
return false ;
}
public function setHelp ( $location )
{
// set hte help function to the helper class
$target = 'admin_view' ;
if ( $location == 2 )
{
$target = 'site_view' ;
}
$help = array ();
2017-12-14 23:10:47 +00:00
$help [] = PHP_EOL . PHP_EOL . " \t /** " ;
2016-02-26 00:20:09 +00:00
$help [] = " \t * Load the Component Help URLs. " ;
$help [] = " \t **/ " ;
$help [] = " \t public static function getHelpUrl( \$ view) " ;
$help [] = " \t { " ;
$help [] = " \t \t \$ user = JFactory::getUser(); " ;
$help [] = " \t \t \$ groups = \$ user->get('groups'); " ;
$help [] = " \t \t \$ db = JFactory::getDbo(); " ;
$help [] = " \t \t \$ query = \$ db->getQuery(true); " ;
$help [] = " \t \t \$ query->select(array('a.id','a.groups','a.target','a.type','a.article','a.url')); " ;
2017-12-14 23:10:47 +00:00
$help [] = " \t \t \$ query->from('#__ " . $this -> fileContentStatic [ '###component###' ] . " _help_document AS a'); " ;
$help [] = " \t \t \$ query->where('a. " . $target . " = '. \$ db->quote( \$ view)); " ;
$help [] = " \t \t \$ query->where('a.location = " . ( int ) $location . " '); " ;
2016-02-26 00:20:09 +00:00
$help [] = " \t \t \$ query->where('a.published = 1'); " ;
$help [] = " \t \t \$ db->setQuery( \$ query); " ;
$help [] = " \t \t \$ db->execute(); " ;
$help [] = " \t \t if( \$ db->getNumRows()) " ;
$help [] = " \t \t { " ;
$help [] = " \t \t \t \$ helps = \$ db->loadObjectList(); " ;
$help [] = " \t \t \t if (self::checkArray( \$ helps)) " ;
$help [] = " \t \t \t { " ;
$help [] = " \t \t \t \t foreach ( \$ helps as \$ nr => \$ help) " ;
$help [] = " \t \t \t \t { " ;
$help [] = " \t \t \t \t \t if ( \$ help->target == 1) " ;
$help [] = " \t \t \t \t \t { " ;
$help [] = " \t \t \t \t \t \t \$ targetgroups = json_decode( \$ help->groups, true); " ;
$help [] = " \t \t \t \t \t \t if (!array_intersect( \$ targetgroups, \$ groups)) " ;
$help [] = " \t \t \t \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$help [] = " \t \t \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " if user not in those target groups then remove the item " ;
2016-02-26 00:20:09 +00:00
$help [] = " \t \t \t \t \t \t \t unset( \$ helps[ \$ nr]); " ;
$help [] = " \t \t \t \t \t \t \t continue; " ;
$help [] = " \t \t \t \t \t \t } " ;
$help [] = " \t \t \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$help [] = " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " set the return type " ;
2016-02-26 00:20:09 +00:00
$help [] = " \t \t \t \t \t switch ( \$ help->type) " ;
$help [] = " \t \t \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$help [] = " \t \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " set joomla article " ;
2016-02-26 00:20:09 +00:00
$help [] = " \t \t \t \t \t \t case 1: " ;
$help [] = " \t \t \t \t \t \t \t return self::loadArticleLink( \$ help->article); " ;
$help [] = " \t \t \t \t \t \t break; " ;
2017-12-14 23:10:47 +00:00
$help [] = " \t \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " set help text " ;
2016-02-26 00:20:09 +00:00
$help [] = " \t \t \t \t \t \t case 2: " ;
$help [] = " \t \t \t \t \t \t \t return self::loadHelpTextLink( \$ help->id); " ;
$help [] = " \t \t \t \t \t \t break; " ;
2017-12-14 23:10:47 +00:00
$help [] = " \t \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " set Link " ;
2016-02-26 00:20:09 +00:00
$help [] = " \t \t \t \t \t \t case 3: " ;
$help [] = " \t \t \t \t \t \t \t return \$ help->url; " ;
$help [] = " \t \t \t \t \t \t break; " ;
$help [] = " \t \t \t \t \t } " ;
$help [] = " \t \t \t \t } " ;
$help [] = " \t \t \t } " ;
$help [] = " \t \t } " ;
$help [] = " \t \t return false; " ;
$help [] = " \t } " ;
2017-12-14 23:10:47 +00:00
$help [] = PHP_EOL . " \t /** " ;
2016-02-26 00:20:09 +00:00
$help [] = " \t * Get the Article Link. " ;
$help [] = " \t **/ " ;
$help [] = " \t protected static function loadArticleLink( \$ id) " ;
$help [] = " \t { " ;
$help [] = " \t \t return JURI::root().'index.php?option=com_content&view=article&id='. \$ id.'&tmpl=component&layout=modal'; " ;
$help [] = " \t } " ;
2017-12-14 23:10:47 +00:00
$help [] = PHP_EOL . " \t /** " ;
2016-02-26 00:20:09 +00:00
$help [] = " \t * Get the Help Text Link. " ;
$help [] = " \t **/ " ;
$help [] = " \t protected static function loadHelpTextLink( \$ id) " ;
$help [] = " \t { " ;
$help [] = " \t \t \$ token = JSession::getFormToken(); " ;
2017-12-14 23:10:47 +00:00
$help [] = " \t \t return 'index.php?option=com_ " . $this -> fileContentStatic [ '###component###' ] . " &task=help.getText&id=' . (int) \$ id . '&token=' . \$ token; " ;
2016-02-26 00:20:09 +00:00
$help [] = " \t } " ;
// return the help methods
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $help );
2016-02-26 00:20:09 +00:00
}
public function setExelHelperMethods ()
{
if ( $this -> addEximport )
{
$exel = array ();
2017-12-14 23:10:47 +00:00
$exel [] = PHP_EOL . PHP_EOL . " \t /** " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t * Prepares the xml document " ;
$exel [] = " \t */ " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t public static function xls( \$ rows, \$ fileName = null, \$ title = null, \$ subjectTab = null, \$ creator = ' " . $this -> fileContentStatic [ '###COMPANYNAME###' ] . " ', \$ description = null, \$ category = null, \$ keywords = null, \$ modified = null) " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t { " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " set the user " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t \$ user = JFactory::getUser(); " ;
$exel [] = " \t \t " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " set fieldname if not set " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t if (! \$ fileName) " ;
$exel [] = " \t \t { " ;
$exel [] = " \t \t \t \$ fileName = 'exported_'.JFactory::getDate()->format('jS_F_Y'); " ;
$exel [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " set modiefied if not set " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t if (! \$ modified) " ;
$exel [] = " \t \t { " ;
$exel [] = " \t \t \t \$ modified = \$ user->name; " ;
$exel [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " set title if not set " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t if (! \$ title) " ;
$exel [] = " \t \t { " ;
$exel [] = " \t \t \t \$ title = 'Book1'; " ;
$exel [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " set tab name if not set " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t if (! \$ subjectTab) " ;
$exel [] = " \t \t { " ;
$exel [] = " \t \t \t \$ subjectTab = 'Sheet1'; " ;
$exel [] = " \t \t } " ;
$exel [] = " \t \t " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " make sure the file is loaded \t \t " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t JLoader::import('PHPExcel', JPATH_COMPONENT_ADMINISTRATOR . '/helpers'); " ;
$exel [] = " \t \t " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Create new PHPExcel object " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t \$ objPHPExcel = new PHPExcel(); " ;
$exel [] = " \t \t " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Set document properties " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t \$ objPHPExcel->getProperties()->setCreator( \$ creator) " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t \t \t \t \t \t \t \t ->setCompany(' " . $this -> fileContentStatic [ '###COMPANYNAME###' ] . " ') " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t \t \t \t \t \t \t \t ->setLastModifiedBy( \$ modified) " ;
$exel [] = " \t \t \t \t \t \t \t \t \t ->setTitle( \$ title) " ;
$exel [] = " \t \t \t \t \t \t \t \t \t ->setSubject( \$ subjectTab); " ;
$exel [] = " \t \t if (! \$ description) " ;
$exel [] = " \t \t { " ;
$exel [] = " \t \t \t \$ objPHPExcel->getProperties()->setDescription( \$ description); " ;
$exel [] = " \t \t } " ;
$exel [] = " \t \t if (! \$ keywords) " ;
$exel [] = " \t \t { " ;
$exel [] = " \t \t \t \$ objPHPExcel->getProperties()->setKeywords( \$ keywords); " ;
$exel [] = " \t \t } " ;
$exel [] = " \t \t if (! \$ category) " ;
$exel [] = " \t \t { " ;
$exel [] = " \t \t \t \$ objPHPExcel->getProperties()->setCategory( \$ category); " ;
$exel [] = " \t \t } " ;
$exel [] = " \t \t " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Some styles " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t \$ headerStyles = array( " ;
$exel [] = " \t \t \t 'font' => array( " ;
$exel [] = " \t \t \t \t 'bold' => true, " ;
$exel [] = " \t \t \t \t 'color' => array('rgb' => '1171A3'), " ;
$exel [] = " \t \t \t \t 'size' => 12, " ;
$exel [] = " \t \t \t \t 'name' => 'Verdana' " ;
$exel [] = " \t \t )); " ;
$exel [] = " \t \t \$ sideStyles = array( " ;
$exel [] = " \t \t \t 'font' => array( " ;
$exel [] = " \t \t \t \t 'bold' => true, " ;
$exel [] = " \t \t \t \t 'color' => array('rgb' => '444444'), " ;
$exel [] = " \t \t \t \t 'size' => 11, " ;
$exel [] = " \t \t \t \t 'name' => 'Verdana' " ;
$exel [] = " \t \t )); " ;
$exel [] = " \t \t \$ normalStyles = array( " ;
$exel [] = " \t \t \t 'font' => array( " ;
$exel [] = " \t \t \t \t 'color' => array('rgb' => '444444'), " ;
$exel [] = " \t \t \t \t 'size' => 11, " ;
$exel [] = " \t \t \t \t 'name' => 'Verdana' " ;
$exel [] = " \t \t )); " ;
$exel [] = " \t \t " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Add some data " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t if (self::checkArray( \$ rows)) " ;
$exel [] = " \t \t { " ;
$exel [] = " \t \t \t \$ i = 1; " ;
$exel [] = " \t \t \t foreach ( \$ rows as \$ array) { " ;
$exel [] = " \t \t \t \t \$ a = 'A'; " ;
$exel [] = " \t \t \t \t foreach ( \$ array as \$ value) { " ;
$exel [] = " \t \t \t \t \t \$ objPHPExcel->setActiveSheetIndex(0)->setCellValue( \$ a. \$ i, \$ value); " ;
$exel [] = " \t \t \t \t \t if ( \$ i == 1) { " ;
$exel [] = " \t \t \t \t \t \t \$ objPHPExcel->getActiveSheet()->getColumnDimension( \$ a)->setAutoSize(true); " ;
$exel [] = " \t \t \t \t \t \t \$ objPHPExcel->getActiveSheet()->getStyle( \$ a. \$ i)->applyFromArray( \$ headerStyles); " ;
$exel [] = " \t \t \t \t \t \t \$ objPHPExcel->getActiveSheet()->getStyle( \$ a. \$ i)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); " ;
2017-02-01 13:17:04 +00:00
$exel [] = " \t \t \t \t \t } elseif ( \$ a === 'A') { " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t \t \t \t \t \$ objPHPExcel->getActiveSheet()->getStyle( \$ a. \$ i)->applyFromArray( \$ sideStyles); " ;
$exel [] = " \t \t \t \t \t } else { " ;
$exel [] = " \t \t \t \t \t \t \$ objPHPExcel->getActiveSheet()->getStyle( \$ a. \$ i)->applyFromArray( \$ normalStyles); " ;
$exel [] = " \t \t \t \t \t } " ;
$exel [] = " \t \t \t \t \t \$ a++; " ;
$exel [] = " \t \t \t \t } " ;
$exel [] = " \t \t \t \t \$ i++; " ;
$exel [] = " \t \t \t } " ;
$exel [] = " \t \t } " ;
$exel [] = " \t \t else " ;
$exel [] = " \t \t { " ;
$exel [] = " \t \t \t return false; " ;
$exel [] = " \t \t } " ;
$exel [] = " \t \t " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Rename worksheet " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t \$ objPHPExcel->getActiveSheet()->setTitle( \$ subjectTab); " ;
$exel [] = " \t \t " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Set active sheet index to the first sheet, so Excel opens this as the first sheet " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t \$ objPHPExcel->setActiveSheetIndex(0); " ;
$exel [] = " \t \t " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Redirect output to a client's web browser (Excel5) " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t header('Content-Type: application/vnd.ms-excel'); " ;
$exel [] = " \t \t header('Content-Disposition: attachment;filename= \" '. \$ fileName.'.xls \" '); " ;
$exel [] = " \t \t header('Cache-Control: max-age=0'); " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " If you're serving to IE 9, then the following may be needed " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t header('Cache-Control: max-age=1'); " ;
$exel [] = " \t \t " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " If you're serving to IE over SSL, then the following may be needed " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past " ;
$exel [] = " \t \t header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified " ;
$exel [] = " \t \t header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1 " ;
$exel [] = " \t \t header ('Pragma: public'); // HTTP/1.0 " ;
$exel [] = " \t \t " ;
$exel [] = " \t \t \$ objWriter = PHPExcel_IOFactory::createWriter( \$ objPHPExcel, 'Excel5'); " ;
$exel [] = " \t \t \$ objWriter->save('php://output'); " ;
$exel [] = " \t \t jexit(); " ;
$exel [] = " \t } " ;
$exel [] = " \t " ;
$exel [] = " \t /** " ;
$exel [] = " \t * Get CSV Headers " ;
$exel [] = " \t */ " ;
$exel [] = " \t public static function getFileHeaders( \$ dataType) " ;
$exel [] = " \t { \t \t " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " make sure these files are loaded \t \t " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t JLoader::import('PHPExcel', JPATH_COMPONENT_ADMINISTRATOR . '/helpers'); " ;
2016-05-31 05:11:07 +00:00
$exel [] = " \t \t JLoader::import('ChunkReadFilter', JPATH_COMPONENT_ADMINISTRATOR . '/helpers/PHPExcel/Reader'); " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " get session object " ;
2016-05-31 05:11:07 +00:00
$exel [] = " \t \t \$ session \t = JFactory::getSession(); " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t \$ package \t = \$ session->get('package', null); " ;
$exel [] = " \t \t \$ package \t = json_decode( \$ package, true); " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " set the headers " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t if(isset( \$ package['dir'])) " ;
$exel [] = " \t \t { " ;
2016-05-31 05:11:07 +00:00
$exel [] = " \t \t \t \$ chunkFilter = new PHPExcel_Reader_chunkReadFilter(); " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " only load first three rows " ;
2016-05-31 05:11:07 +00:00
$exel [] = " \t \t \t \$ chunkFilter->setRows(2,1); " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " identify the file type " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t \t \$ inputFileType = PHPExcel_IOFactory::identify( \$ package['dir']); " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " create the reader for this file type " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t \t \$ excelReader = PHPExcel_IOFactory::createReader( \$ inputFileType); " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " load the limiting filter " ;
2016-05-31 05:11:07 +00:00
$exel [] = " \t \t \t \$ excelReader->setReadFilter( \$ chunkFilter); " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t \t \$ excelReader->setReadDataOnly(true); " ;
2017-12-14 23:10:47 +00:00
$exel [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " load the rows (only first three) " ;
2016-02-26 00:20:09 +00:00
$exel [] = " \t \t \t \$ excelObj = \$ excelReader->load( \$ package['dir']); " ;
$exel [] = " \t \t \t \$ headers = array(); " ;
$exel [] = " \t \t \t foreach ( \$ excelObj->getActiveSheet()->getRowIterator() as \$ row) " ;
$exel [] = " \t \t \t { " ;
$exel [] = " \t \t \t \t if( \$ row->getRowIndex() == 1) " ;
$exel [] = " \t \t \t \t { " ;
$exel [] = " \t \t \t \t \t \$ cellIterator = \$ row->getCellIterator(); " ;
$exel [] = " \t \t \t \t \t \$ cellIterator->setIterateOnlyExistingCells(false); " ;
$exel [] = " \t \t \t \t \t foreach ( \$ cellIterator as \$ cell) " ;
$exel [] = " \t \t \t \t \t { " ;
$exel [] = " \t \t \t \t \t \t if (!is_null( \$ cell)) " ;
$exel [] = " \t \t \t \t \t \t { " ;
$exel [] = " \t \t \t \t \t \t \t \$ headers[ \$ cell->getColumn()] = \$ cell->getValue(); " ;
$exel [] = " \t \t \t \t \t \t } " ;
$exel [] = " \t \t \t \t \t } " ;
$exel [] = " \t \t \t \t \t \$ excelObj->disconnectWorksheets(); " ;
$exel [] = " \t \t \t \t \t unset( \$ excelObj); " ;
$exel [] = " \t \t \t \t \t break; " ;
$exel [] = " \t \t \t \t } " ;
$exel [] = " \t \t \t } " ;
$exel [] = " \t \t \t return \$ headers; " ;
$exel [] = " \t \t } " ;
$exel [] = " \t \t return false; " ;
$exel [] = " \t } " ;
// return the help methods
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $exel );
2016-02-26 00:20:09 +00:00
}
return '' ;
}
public function setCreateUserHelperMethod ( $add )
{
if ( $add )
{
$method = array ();
2017-12-14 23:10:47 +00:00
$method [] = PHP_EOL . PHP_EOL . " \t /** " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t * Greate user and update given table " ;
$method [] = " \t */ " ;
$method [] = " \t public static function createUser( \$ new) " ;
$method [] = " \t { " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " load the user component language files if there is an error. " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \$ lang = JFactory::getLanguage(); " ;
$method [] = " \t \t \$ extension = 'com_users'; " ;
$method [] = " \t \t \$ base_dir = JPATH_SITE; " ;
$method [] = " \t \t \$ language_tag = 'en-GB'; " ;
$method [] = " \t \t \$ reload = true; " ;
$method [] = " \t \t \$ lang->load( \$ extension, \$ base_dir, \$ language_tag, \$ reload); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " load the user regestration model " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \$ model = self::getModel('registration', JPATH_ROOT. '/components/com_users', 'Users'); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " make sure no activation is needed " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \$ useractivation = self::setParams('com_users','useractivation',0); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " make sure password is send " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \$ sendpassword = self::setParams('com_users','sendpassword',1); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Check if password was set " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t if (isset( \$ new['password']) && isset( \$ new['password2']) && self::checkString( \$ new['password']) && self::checkString( \$ new['password2'])) " ;
$method [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Use the users passwords " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t \$ password = \$ new['password']; " ;
$method [] = " \t \t \t \$ password2 = \$ new['password2']; " ;
$method [] = " \t \t } " ;
$method [] = " \t \t else " ;
$method [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Set random password " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t \$ password = self::randomkey(8); " ;
$method [] = " \t \t \t \$ password2 = \$ password; " ;
$method [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " set username if not set " ;
2017-01-20 00:16:50 +00:00
$method [] = " \t \t if (!isset( \$ new['username']) || !self::checkString( \$ new['username'])) " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t { " ;
2017-01-20 00:16:50 +00:00
$method [] = " \t \t \t \$ new['username'] = self::safeString( \$ new['name']); " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " linup new user data " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \$ data = array( " ;
$method [] = " \t \t \t 'username' => \$ new['username'], " ;
$method [] = " \t \t \t 'name' => \$ new['name'], " ;
$method [] = " \t \t \t 'email1' => \$ new['email'], " ;
$method [] = " \t \t \t 'password1' => \$ password, // First password field " ;
$method [] = " \t \t \t 'password2' => \$ password2, // Confirm password field " ;
$method [] = " \t \t \t 'block' => 0 ); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " register the new user " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \$ userId = \$ model->register( \$ data); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " set activation back to default " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t self::setParams('com_users','useractivation', \$ useractivation); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " set send password back to default " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t self::setParams('com_users','sendpassword', \$ sendpassword); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " if user is created " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t if ( \$ userId > 0) " ;
$method [] = " \t \t { " ;
$method [] = " \t \t \t return \$ userId; " ;
$method [] = " \t \t } " ;
$method [] = " \t \t return \$ model->getError(); " ;
$method [] = " \t } " ;
2017-12-14 23:10:47 +00:00
$method [] = PHP_EOL . " \t protected static function setParams( \$ component, \$ target, \$ value) " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t { " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the params and set the new values " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \$ params = JComponentHelper::getParams( \$ component); " ;
$method [] = " \t \t \$ was = \$ params->get( \$ target, null); " ;
$method [] = " \t \t if ( \$ was != \$ value) " ;
$method [] = " \t \t { " ;
$method [] = " \t \t \t \$ params->set( \$ target, \$ value); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Get a new database query instance " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t \$ db = JFactory::getDBO(); " ;
$method [] = " \t \t \t \$ query = \$ db->getQuery(true); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Build the query " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t \$ query->update('#__extensions AS a'); " ;
$method [] = " \t \t \t \$ query->set('a.params = ' . \$ db->quote((string) \$ params)); " ;
$method [] = " \t \t \t \$ query->where('a.element = ' . \$ db->quote((string) \$ component)); " ;
$method [] = " \t \t \t " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Execute the query " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t \$ db->setQuery( \$ query); " ;
$method [] = " \t \t \t \$ db->query(); " ;
$method [] = " \t \t } " ;
$method [] = " \t \t return \$ was; " ;
$method [] = " \t } " ;
2017-12-14 23:10:47 +00:00
$method [] = PHP_EOL . " \t /** " ;
2016-04-22 12:03:43 +00:00
$method [] = " \t * Update user values " ;
$method [] = " \t */ " ;
$method [] = " \t public static function updateUser( \$ new) " ;
$method [] = " \t { " ;
$method [] = " \t \t // load the user component language files if there is an error. " ;
$method [] = " \t \t \$ lang = JFactory::getLanguage(); " ;
$method [] = " \t \t \$ extension = 'com_users'; " ;
$method [] = " \t \t \$ base_dir = JPATH_ADMINISTRATOR; " ;
$method [] = " \t \t \$ language_tag = 'en-GB'; " ;
$method [] = " \t \t \$ reload = true; " ;
$method [] = " \t \t \$ lang->load( \$ extension, \$ base_dir, \$ language_tag, \$ reload); " ;
$method [] = " \t \t // load the user model " ;
$method [] = " \t \t \$ model = self::getModel('user', JPATH_ADMINISTRATOR . '/components/com_users', 'Users'); " ;
$method [] = " \t \t // Check if password was set " ;
$method [] = " \t \t if (isset( \$ new['password']) && isset( \$ new['password2']) && self::checkString( \$ new['password']) && self::checkString( \$ new['password2'])) " ;
$method [] = " \t \t { " ;
$method [] = " \t \t \t // Use the users passwords " ;
$method [] = " \t \t \t \$ password = \$ new['password']; " ;
$method [] = " \t \t \t \$ password2 = \$ new['password2']; " ;
$method [] = " \t \t } " ;
$method [] = " \t \t // set username " ;
$method [] = " \t \t if (isset( \$ new['username']) && self::checkString( \$ new['username'])) " ;
$method [] = " \t \t { " ;
$method [] = " \t \t \t \$ new['username'] = self::safeString( \$ new['username']); " ;
$method [] = " \t \t } " ;
$method [] = " \t \t else " ;
$method [] = " \t \t { " ;
$method [] = " \t \t \t \$ new['username'] = self::safeString( \$ new['name']); \t \t \t " ;
$method [] = " \t \t } " ;
$method [] = " \t \t // linup update user data " ;
$method [] = " \t \t \$ data = array( " ;
$method [] = " \t \t \t 'id' => \$ new['id'], " ;
$method [] = " \t \t \t 'username' => \$ new['username'], " ;
$method [] = " \t \t \t 'name' => \$ new['name'], " ;
$method [] = " \t \t \t 'email' => \$ new['email'], " ;
$method [] = " \t \t \t 'password1' => \$ password, // First password field " ;
$method [] = " \t \t \t 'password2' => \$ password2, // Confirm password field " ;
$method [] = " \t \t \t 'block' => 0 ); " ;
$method [] = " \t \t // register the new user " ;
$method [] = " \t \t \$ done = \$ model->save( \$ data); " ;
$method [] = " \t \t // if user is updated " ;
$method [] = " \t \t if ( \$ done) " ;
$method [] = " \t \t { " ;
$method [] = " \t \t \t return \$ new['id']; " ;
$method [] = " \t \t } " ;
$method [] = " \t \t return \$ model->getError(); " ;
$method [] = " \t } " ;
2016-02-26 00:20:09 +00:00
// return the help method
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $method );
2016-02-26 00:20:09 +00:00
}
return '' ;
}
2016-09-11 15:27:04 +00:00
public function setCustomViewMenu ( & $view )
2016-02-26 00:20:09 +00:00
{
$xml = '' ;
// build the file
$target = array ( 'site' => $view [ 'settings' ] -> code );
2017-12-14 23:10:47 +00:00
$done = $this -> buildDynamique ( $target , 'menu' );
2016-02-26 00:20:09 +00:00
if ( $done )
{
// set the lang
2017-12-14 23:10:47 +00:00
$lang = ComponentbuilderHelper :: safeString ( 'com_' . $this -> fileContentStatic [ '###component###' ] . '_menu_' . $view [ 'settings' ] -> code , 'U' );
$this -> langContent [ 'adminsys' ][ $lang . '_TITLE' ] = $view [ 'settings' ] -> name ;
$this -> langContent [ 'adminsys' ][ $lang . '_OPTION' ] = $view [ 'settings' ] -> name ;
$this -> langContent [ 'adminsys' ][ $lang . '_DESC' ] = $view [ 'settings' ] -> description ;
2016-02-26 00:20:09 +00:00
//start loading xml
$xml = '<?xml version="1.0" encoding="utf-8" ?>' ;
2017-12-14 23:10:47 +00:00
$xml .= PHP_EOL . '<metadata>' ;
$xml .= PHP_EOL . " \t " . '<layout title="' . $lang . '_TITLE" option="' . $lang . '_OPTION">' ;
$xml .= PHP_EOL . " \t \t " . '<message>' ;
$xml .= PHP_EOL . " \t \t \t " . '<![CDATA[' . $lang . '_DESC]]>' ;
$xml .= PHP_EOL . " \t \t " . '</message>' ;
$xml .= PHP_EOL . " \t " . '</layout>' ;
2017-03-08 04:49:54 +00:00
if ( isset ( $this -> hasIdRequest [ $view [ 'settings' ] -> code ]) || isset ( $this -> hasCatIdRequest [ $view [ 'settings' ] -> code ]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$xml .= PHP_EOL . " \t " . '<!--' . $this -> setLine ( __LINE__ ) . ' Add fields to the request variables for the layout. -->' ;
$xml .= PHP_EOL . " \t " . '<fields name="request">' ;
$xml .= PHP_EOL . " \t \t " . '<fieldset name="request"' ;
$xml .= PHP_EOL . " \t \t \t " . 'addrulepath="/administrator/components/com_' . $this -> fileContentStatic [ '###component###' ] . '/models/rules"' ;
$xml .= PHP_EOL . " \t \t \t " . 'addfieldpath="/administrator/components/com_' . $this -> fileContentStatic [ '###component###' ] . '/models/fields">' ;
2017-03-08 04:49:54 +00:00
if ( isset ( $this -> hasIdRequest [ $view [ 'settings' ] -> code ]) && ComponentbuilderHelper :: checkArray ( $this -> hasIdRequest [ $view [ 'settings' ] -> code ]))
{
2017-12-14 23:10:47 +00:00
foreach ( $this -> hasIdRequest [ $view [ 'settings' ] -> code ] as $requestFieldXML )
2017-03-08 04:49:54 +00:00
{
2017-12-14 23:10:47 +00:00
$xml .= PHP_EOL . " \t \t \t " . $requestFieldXML ;
2017-03-08 04:49:54 +00:00
}
}
if ( isset ( $this -> hasCatIdRequest [ $view [ 'settings' ] -> code ]) && ComponentbuilderHelper :: checkArray ( $this -> hasCatIdRequest [ $view [ 'settings' ] -> code ]))
{
2017-12-14 23:10:47 +00:00
foreach ( $this -> hasCatIdRequest [ $view [ 'settings' ] -> code ] as $requestFieldXML )
2017-03-08 04:49:54 +00:00
{
2017-12-14 23:10:47 +00:00
$xml .= PHP_EOL . " \t \t \t " . $requestFieldXML ;
2017-03-08 04:49:54 +00:00
}
}
2017-12-14 23:10:47 +00:00
$xml .= PHP_EOL . " \t \t " . '</fieldset>' ;
$xml .= PHP_EOL . " \t " . '</fields>' ;
2016-02-26 00:20:09 +00:00
}
if ( isset ( $this -> frontEndParams ) && isset ( $this -> frontEndParams [ $view [ 'settings' ] -> name ]))
{
// first we must setup the fields for the page use
2017-12-14 23:10:47 +00:00
$params = $this -> setupFrontendParamFields ( $this -> frontEndParams [ $view [ 'settings' ] -> name ], $view [ 'settings' ] -> code );
2016-02-26 00:20:09 +00:00
// now load the fields
if ( ComponentbuilderHelper :: checkArray ( $params ))
{
2017-12-14 23:10:47 +00:00
$xml .= PHP_EOL . " \t " . '<!--' . $this -> setLine ( __LINE__ ) . ' Adding page parameters -->' ;
$xml .= PHP_EOL . " \t " . '<fields name="params">' ;
$xml .= PHP_EOL . " \t \t " . '<fieldset name="basic" label="COM_' . $this -> fileContentStatic [ '###COMPONENT###' ] . '"' ;
$xml .= PHP_EOL . " \t \t \t " . 'addrulepath="/administrator/components/com_' . $this -> fileContentStatic [ '###component###' ] . '/models/rules"' ;
$xml .= PHP_EOL . " \t \t \t " . 'addfieldpath="/administrator/components/com_' . $this -> fileContentStatic [ '###component###' ] . '/models/fields">' ;
$xml .= implode ( " \t \t \t " , $params );
$xml .= PHP_EOL . " \t \t " . '</fieldset>' ;
$xml .= PHP_EOL . " \t " . '</fields>' ;
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
$xml .= PHP_EOL . '</metadata>' ;
2016-02-26 00:20:09 +00:00
}
return $xml ;
}
2017-12-14 23:10:47 +00:00
public function setupFrontendParamFields ( $params , $view )
2016-02-26 00:20:09 +00:00
{
$keep = array ();
2017-12-14 23:10:47 +00:00
$menuSetter = $view . '_menu' ;
2016-02-26 00:20:09 +00:00
foreach ( $params as $field )
{
2017-07-20 23:26:48 +00:00
// some switch to see if it should be added to front end params
$target = ComponentbuilderHelper :: getBetween ( $field , 'display="' , '"' );
if ( ! ComponentbuilderHelper :: checkString ( $target ) || $target === 'menu' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
2017-07-20 23:26:48 +00:00
$field = str_replace ( 'display="menu"' , '' , $field );
// we load fields that have options
2017-12-14 23:10:47 +00:00
if ( strpos ( $field , 'Option Set. -->' ) !== false && strpos ( $field , $menuSetter ) === false && ! ComponentbuilderHelper :: checkString ( $target ))
2017-07-20 23:26:48 +00:00
{
// we add the global option
2017-12-14 23:10:47 +00:00
$field = str_replace ( 'Option Set. -->' , $this -> setLine ( __LINE__ ) . ' Global & Option Set. -->' . PHP_EOL . " \t \t \t " . '<option value="">' . PHP_EOL . " \t \t \t \t " . 'JGLOBAL_USE_GLOBAL</option>' , $field );
2017-07-20 23:26:48 +00:00
// update the default to be global
$field = preg_replace ( '/default=".+"/' , 'default=""' , $field );
// update the default to be filter
$field = preg_replace ( '/filter=".+"/' , 'filter="string"' , $field );
// update required
$field = str_replace ( 'required="true"' , 'required="false"' , $field );
// add to keeper array
$keep [] = $field ;
}
else
{
$keep [] = $field ;
}
2016-02-26 00:20:09 +00:00
}
}
return $keep ;
}
2017-12-14 23:10:47 +00:00
public function setCustomViewQuery ( & $gets , & $code , $tab = '' , $type = 'main' )
2016-02-26 00:20:09 +00:00
{
$query = '' ;
if ( ComponentbuilderHelper :: checkArray ( $gets ))
{
$mainAsArray = array ();
$check = 'zzz' ;
foreach ( $gets as $nr => $the_get )
{
// to insure that there be no double entries of a call
2017-12-14 23:10:47 +00:00
$checker = md5 ( serialize ( $the_get ) . $code );
if ( ! isset ( $this -> customViewQueryChecker [ $this -> target ]) || ! in_array ( $checker , $this -> customViewQueryChecker [ $this -> target ]))
2016-02-26 00:20:09 +00:00
{
// load this unuiqe key
$this -> customViewQueryChecker [ $this -> target ][] = $checker ;
if ( ComponentbuilderHelper :: checkString ( $the_get [ 'selection' ][ 'type' ]))
{
2017-12-14 23:10:47 +00:00
$getItem = PHP_EOL . PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " Get from " . $the_get [ 'selection' ][ 'table' ] . " as " . $the_get [ 'as' ];
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$getItem = PHP_EOL . PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " Get data " ;
2016-02-26 00:20:09 +00:00
}
// set the selection
2017-12-14 23:10:47 +00:00
$getItem .= PHP_EOL . " \t " . $tab . " \t " . $the_get [ 'selection' ][ 'select' ];
2016-02-26 00:20:09 +00:00
if (( $nr == 0 && ( ! isset ( $the_get [ 'join_field' ]) || ! ComponentbuilderHelper :: checkString ( $the_get [ 'join_field' ])) && ( isset ( $the_get [ 'selection' ][ 'type' ]) && ComponentbuilderHelper :: checkString ( $the_get [ 'selection' ][ 'type' ]))) ||
2017-02-01 13:17:04 +00:00
( $type === 'custom' && ( isset ( $the_get [ 'selection' ][ 'type' ]) && ComponentbuilderHelper :: checkString ( $the_get [ 'selection' ][ 'type' ]))))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$getItem .= PHP_EOL . " \t " . $tab . " \t " . '$query->from(' . $the_get [ 'selection' ][ 'from' ] . ');' ;
2016-02-26 00:20:09 +00:00
}
elseif ( isset ( $the_get [ 'join_field' ]) && ComponentbuilderHelper :: checkString ( $the_get [ 'join_field' ]) && isset ( $the_get [ 'selection' ][ 'type' ]) && ComponentbuilderHelper :: checkString ( $the_get [ 'selection' ][ 'type' ]))
{
2017-12-14 23:10:47 +00:00
$getItem .= PHP_EOL . " \t " . $tab . " \t \$ query->join(' " . $the_get [ 'type' ];
$getItem .= " ', ( " . $the_get [ 'selection' ][ 'from' ];
$getItem .= " ) . ' ON (' . \$ db->quoteName(' " . $the_get [ 'on_field' ];
$getItem .= " ') . ' " . $the_get [ 'operator' ];
$getItem .= " ' . \$ db->quoteName(' " . $the_get [ 'join_field' ] . " ') . ')'); " ;
2016-02-26 00:20:09 +00:00
$check = current ( explode ( " . " , $the_get [ 'on_field' ]));
}
// set the method defaults
2017-12-14 23:10:47 +00:00
$default = $this -> setCustomViewMethodDefaults ( $the_get , $code );
if ( isset ( $this -> siteDynamicGet [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]][ $default [ 'join_field' ]]) && ComponentbuilderHelper :: checkString ( $this -> siteDynamicGet [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]][ $default [ 'join_field' ]]) && ! in_array ( $check , $mainAsArray ))
2016-02-26 00:20:09 +00:00
{
// load to other query
if ( ! isset ( $this -> otherQuery [ $this -> target ][ $default [ 'code' ]][ $this -> siteDynamicGet [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]][ $default [ 'join_field' ]]][ $default [ 'valueName' ]]))
{
$this -> otherQuery [ $this -> target ][ $default [ 'code' ]][ $this -> siteDynamicGet [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]][ $default [ 'join_field' ]]][ $default [ 'valueName' ]] = '' ;
}
$this -> otherQuery [ $this -> target ][ $default [ 'code' ]][ $this -> siteDynamicGet [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]][ $default [ 'join_field' ]]][ $default [ 'valueName' ]] .= $getItem ;
}
else
{
$mainAsArray [] = $default [ 'as' ];
$query .= $getItem ;
}
}
}
}
return $query ;
}
2017-12-14 23:10:47 +00:00
public function setCustomViewFieldDecodeFilter ( & $get , & $filters , $string , $removeString , $code , $tab )
2016-02-26 00:20:09 +00:00
{
$filter = '' ;
// check if filter is set for this field
if ( ComponentbuilderHelper :: checkArray ( $filters ))
{
foreach ( $filters as $field => $ter )
{
if ( strpos ( $get [ 'selection' ][ 'select' ], $ter [ 'table_key' ]) !== false )
{
$as = '' ;
$felt = '' ;
2017-12-14 23:10:47 +00:00
list ( $as , $felt ) = array_map ( 'trim' , explode ( '.' , $ter [ 'table_key' ]));
2016-02-26 00:20:09 +00:00
if ( $get [ 'as' ] == $as )
{
switch ( $ter [ 'filter_type' ])
{
case 4 :
2017-12-14 23:10:47 +00:00
// COM_COMPONENTBUILDER_DYNAMIC_GET_USER_GROUPS
$filter .= PHP_EOL . PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " filter " . $as . " based on user groups " ;
$filter .= PHP_EOL . " \t " . $tab . " \t \$ remove = (count(array_intersect((array) \$ this->groups, (array) " . $string . " -> " . $field . " ))) ? false : true; " ;
$filter .= PHP_EOL . " \t " . $tab . " \t if ( \$ remove) " ;
$filter .= PHP_EOL . " \t " . $tab . " \t { " ;
if ( $removeString == $string )
{
$filter .= PHP_EOL . " \t " . $tab . " \t \t // " . $this -> setLine ( __LINE__ ) . " Remove " . $string . " if user not in groups " ;
$filter .= PHP_EOL . " \t " . $tab . " \t \t " . $string . " = null; " ;
$filter .= PHP_EOL . " \t " . $tab . " \t \t return false; " ;
}
else
{
$filter .= PHP_EOL . " \t " . $tab . " \t \t // " . $this -> setLine ( __LINE__ ) . " Unset " . $string . " if user not in groups " ;
$filter .= PHP_EOL . " \t " . $tab . " \t \t unset( " . $removeString . " ); " ;
$filter .= PHP_EOL . " \t " . $tab . " \t \t continue; " ;
}
$filter .= PHP_EOL . " \t " . $tab . " \t } " ;
break ;
2016-02-26 00:20:09 +00:00
case 9 :
2017-12-14 23:10:47 +00:00
// COM_COMPONENTBUILDER_DYNAMIC_GET_ARRAY_VALUE
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$filter .= PHP_EOL . PHP_EOL . " \t " . $tab . " \t if ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( " . $string . " -> " . $field . " )) " ;
$filter .= PHP_EOL . " \t " . $tab . " \t { " ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$filter .= PHP_EOL . " \t " . $tab . " \t \t // " . $this -> setLine ( __LINE__ ) . " do your thing here " ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$filter .= PHP_EOL . " \t " . $tab . " \t } " ;
$filter .= PHP_EOL . " \t " . $tab . " \t else " ;
$filter .= PHP_EOL . " \t " . $tab . " \t { " ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
if ( $removeString == $string )
{
$filter .= PHP_EOL . " \t " . $tab . " \t \t // " . $this -> setLine ( __LINE__ ) . " Remove " . $string . " if not array. " ;
$filter .= PHP_EOL . " \t " . $tab . " \t \t " . $string . " = null; " ;
}
else
{
$filter .= PHP_EOL . " \t " . $tab . " \t \t // " . $this -> setLine ( __LINE__ ) . " Unset " . $string . " if not array. " ;
$filter .= PHP_EOL . " \t " . $tab . " \t \t unset( " . $removeString . " ); " ;
$filter .= PHP_EOL . " \t " . $tab . " \t \t continue; " ;
}
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$filter .= PHP_EOL . " \t " . $tab . " \t } " ;
break ;
2016-02-26 00:20:09 +00:00
case 10 :
2017-12-14 23:10:47 +00:00
// COM_COMPONENTBUILDER_DYNAMIC_GET_REPEATABLE_VALUE
$filter .= PHP_EOL . PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " filter " . $as . " based on repeatable value " ;
$filter .= PHP_EOL . " \t " . $tab . " \t if ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkString( " . $string . " -> " . $field . " )) " ;
$filter .= PHP_EOL . " \t " . $tab . " \t { " ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$filter .= PHP_EOL . " \t \t " . $tab . " \t \$ array = json_decode( " . $string . " -> " . $field . " ,true); " ;
$filter .= PHP_EOL . " \t \t " . $tab . " \t if ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ array)) " ;
$filter .= PHP_EOL . " \t \t " . $tab . " \t { " ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$filter .= PHP_EOL . " \t \t " . $tab . " \t \t // " . $this -> setLine ( __LINE__ ) . " do your thing here " ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$filter .= PHP_EOL . " \t \t " . $tab . " \t } " ;
$filter .= PHP_EOL . " \t " . $tab . " \t \t else " ;
$filter .= PHP_EOL . " \t " . $tab . " \t \t { " ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
if ( $removeString == $string )
{
$filter .= PHP_EOL . " \t " . $tab . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Remove " . $string . " if not array. " ;
$filter .= PHP_EOL . " \t " . $tab . " \t \t \t " . $string . " = null; " ;
}
else
{
$filter .= PHP_EOL . " \t " . $tab . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Unset " . $string . " if not array. " ;
$filter .= PHP_EOL . " \t " . $tab . " \t \t \t unset( " . $removeString . " ); " ;
$filter .= PHP_EOL . " \t " . $tab . " \t \t \t continue; " ;
}
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$filter .= PHP_EOL . " \t " . $tab . " \t \t } " ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$filter .= PHP_EOL . " \t " . $tab . " \t } " ;
$filter .= PHP_EOL . " \t " . $tab . " \t else " ;
$filter .= PHP_EOL . " \t " . $tab . " \t { " ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
if ( $removeString == $string )
{
$filter .= PHP_EOL . " \t " . $tab . " \t \t // " . $this -> setLine ( __LINE__ ) . " Remove " . $string . " if not string. " ;
$filter .= PHP_EOL . " \t " . $tab . " \t \t " . $string . " = null; " ;
}
else
{
$filter .= PHP_EOL . " \t " . $tab . " \t \t // " . $this -> setLine ( __LINE__ ) . " Unset " . $string . " if not string. " ;
$filter .= PHP_EOL . " \t " . $tab . " \t \t unset( " . $removeString . " ); " ;
$filter .= PHP_EOL . " \t " . $tab . " \t \t continue; " ;
}
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$filter .= PHP_EOL . " \t " . $tab . " \t } " ;
break ;
2016-02-26 00:20:09 +00:00
}
}
}
}
}
return $filter ;
}
2017-12-14 23:10:47 +00:00
public function setCustomViewFieldDecode ( & $get , $checker , $string , $code , $tab = '' )
2016-02-26 00:20:09 +00:00
{
$fieldDecode = '' ;
foreach ( $checker as $field => $array )
{
if ( strpos ( $get [ 'selection' ][ 'select' ], $field ) !== false )
{
2017-02-01 13:17:04 +00:00
if ( $array [ 'decode' ] === 'json' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$if = PHP_EOL . " \t " . $tab . " \t if ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkJson( " . $string . " -> " . $field . " )) " . PHP_EOL . " \t " . $tab . " \t { " ;
2016-02-26 00:20:09 +00:00
// json_decode
2017-12-14 23:10:47 +00:00
$decoder = $string . " -> " . $field . " = json_decode( " . $string . " -> " . $field . " , true); " ;
2016-02-26 00:20:09 +00:00
// TODO Use the type of field to prepare it even more for use in the view
}
2017-02-01 13:17:04 +00:00
elseif ( $array [ 'decode' ] === 'base64' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$if = PHP_EOL . " \t " . $tab . " \t if (!empty( " . $string . " -> " . $field . " ) && " . $string . " -> " . $field . " === base64_encode(base64_decode( " . $string . " -> " . $field . " ))) " . PHP_EOL . " \t " . $tab . " \t { " ;
2016-02-26 00:20:09 +00:00
// base64_decode
2017-12-14 23:10:47 +00:00
$decoder = $string . " -> " . $field . " = base64_decode( " . $string . " -> " . $field . " ); " ;
2016-02-26 00:20:09 +00:00
// TODO Use the type of field to prepare it even more for use in the view
}
2017-02-01 13:17:04 +00:00
elseif ( $array [ 'decode' ] === 'basic_encryption' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$if = PHP_EOL . " \t " . $tab . " \t if (!empty( " . $string . " -> " . $field . " ) && \$ basickey && !is_numeric( " . $string . " -> " . $field . " ) && " . $string . " -> " . $field . " === base64_encode(base64_decode( " . $string . " -> " . $field . " , true))) " . PHP_EOL . " \t " . $tab . " \t { " ;
2016-02-26 00:20:09 +00:00
// basic decryption
2017-12-14 23:10:47 +00:00
$decoder = $string . " -> " . $field . " = rtrim( \$ basic->decryptString( " . $string . " -> " . $field . " ), " . '"\0"' . " ); " ;
2016-02-26 00:20:09 +00:00
$this -> siteDecrypt [ 'basic' ][ $code ] = true ;
}
2017-02-01 13:17:04 +00:00
elseif ( $array [ 'decode' ] === 'advance_encryption' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$if = PHP_EOL . " \t " . $tab . " \t if (!empty( " . $string . " -> " . $field . " ) && \$ advancedkey && !is_numeric( " . $string . " -> " . $field . " ) && " . $string . " -> " . $field . " === base64_encode(base64_decode( " . $string . " -> " . $field . " , true))) " . PHP_EOL . " \t " . $tab . " \t { " ;
2016-02-26 00:20:09 +00:00
// advanced decryption
2017-12-14 23:10:47 +00:00
$decoder = $string . " -> " . $field . " = rtrim( \$ advanced->decryptString( " . $string . " -> " . $field . " ), " . '"\0"' . " ); " ;
2016-02-26 00:20:09 +00:00
$this -> siteDecrypt [ 'advanced' ][ $code ] = true ;
}
// build decoder string
2017-12-14 23:10:47 +00:00
$fieldDecode .= $if . PHP_EOL . " \t " . $tab . " \t \t // " . $this -> setLine ( __LINE__ ) . " Decode " . $field ;
$fieldDecode .= PHP_EOL . " \t " . $tab . " \t \t " . $decoder . PHP_EOL . " \t " . $tab . " \t } " ;
2016-02-26 00:20:09 +00:00
}
}
return $fieldDecode ;
}
2017-12-10 19:17:26 +00:00
public function setCustomViewFieldonContentPrepareChecker ( & $get , $checker , $string , $code , $tab = '' )
2016-02-26 00:20:09 +00:00
{
2017-12-10 19:17:26 +00:00
$fieldPrepare = '' ;
2017-12-04 01:43:45 +00:00
$runplugins = false ;
2017-12-14 23:10:47 +00:00
$context = 'com_' . $this -> fileContentStatic [ '###component###' ] . '.' . $code ;
2016-02-26 00:20:09 +00:00
foreach ( $checker as $field => $array )
{
if ( strpos ( $get [ 'selection' ][ 'select' ], $field ) !== false )
{
// build decoder string
2017-12-14 23:10:47 +00:00
if ( ! $runplugins )
{
$runplugins = PHP_EOL . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " Load the JEvent Dispatcher " ;
$runplugins .= PHP_EOL . $tab . " \t JPluginHelper::importPlugin('content'); " ;
$runplugins .= PHP_EOL . $tab . " \t " . '$this->_dispatcher = JEventDispatcher::getInstance();' ;
2017-12-04 01:24:53 +00:00
}
2017-12-14 23:10:47 +00:00
$fieldPrepare .= PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " Make sure the content prepare plugins fire on " . $field ;
$fieldPrepare .= PHP_EOL . " \t " . $tab . " \t \$ _ " . $field . " = new stdClass(); " ;
$fieldPrepare .= PHP_EOL . " \t " . $tab . " \t \$ _ " . $field . '->text =& ' . $string . '->' . $field . '; //' . $this -> setLine ( __LINE__ ) . ' value must be in text' ;
$fieldPrepare .= PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " Since all values are now in text (Joomla Limitation), we also add the field name ( " . $field . " ) to context " ;
$fieldPrepare .= PHP_EOL . " \t " . $tab . " \t " . '$this->_dispatcher->trigger("onContentPrepare",array(\'' . $context . '.' . $field . '\',&$_' . $field . ',&$this->params));' ; // we can improve the params later (TODO)
2017-12-10 19:17:26 +00:00
}
}
// load dispatcher
2017-12-14 23:10:47 +00:00
$this -> JEventDispatcher = array ( '###DISPATCHER###' => ( $runplugins ? : '' ));
2017-12-10 19:17:26 +00:00
// return content prepare fix
return $fieldPrepare ;
}
public function setCustomViewFieldUikitChecker ( & $get , $checker , $string , $code , $tab = '' )
{
$fieldUikit = '' ;
foreach ( $checker as $field => $array )
{
if ( strpos ( $get [ 'selection' ][ 'select' ], $field ) !== false )
{
2017-11-11 04:33:51 +00:00
// only load for uikit version 2 (TODO) we may need to add another check here
if ( 2 == $this -> uikit || 1 == $this -> uikit )
{
2017-12-14 23:10:47 +00:00
$fieldUikit .= PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " Checking if " . $field . " has uikit components that must be loaded. " ;
$fieldUikit .= PHP_EOL . " \t " . $tab . " \t \$ this->uikitComp = " . $this -> fileContentStatic [ '###Component###' ] . " Helper::getUikitComp( " . $string . " -> " . $field . " , \$ this->uikitComp); " ;
2017-11-11 04:33:51 +00:00
}
2016-02-26 00:20:09 +00:00
}
}
2017-12-04 15:57:19 +00:00
// return UIKIT fix
return $fieldUikit ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
public function setCustomViewCustomJoin ( & $gets , $string , $code , & $asBucket , $tab = '' )
2016-02-26 00:20:09 +00:00
{
if ( ComponentbuilderHelper :: checkArray ( $gets ))
{
$customJoin = '' ;
foreach ( $gets as $get )
{
// set the value name $default
2017-12-14 23:10:47 +00:00
$default = $this -> setCustomViewMethodDefaults ( $get , $code );
if ( $this -> checkJoint ( $default , $get , $asBucket ))
2016-02-26 00:20:09 +00:00
{
// build custom join string
2017-12-14 23:10:47 +00:00
$otherJoin = PHP_EOL . " \t ###TAB### \t // " . $this -> setLine ( __LINE__ ) . " set " . $default [ 'valueName' ] . " to the ###STRING### object. " ;
$otherJoin .= PHP_EOL . " \t ###TAB### \t ###STRING###-> " . $default [ 'valueName' ] . " = \$ this->get " . $default [ 'methodName' ] . " (###STRING###-> " . $this -> getAsLookup [ $get [ 'key' ]][ $get [ 'on_field' ]] . " ); " ;
2016-02-26 00:20:09 +00:00
// load to other join
if ( ! isset ( $this -> otherJoin [ $this -> target ][ $default [ 'code' ]][ $this -> siteDynamicGet [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]][ $default [ 'join_field' ]]][ $default [ 'valueName' ]]))
{
$this -> otherJoin [ $this -> target ][ $default [ 'code' ]][ $this -> siteDynamicGet [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]][ $default [ 'join_field' ]]][ $default [ 'valueName' ]] = '' ;
}
$this -> otherJoin [ $this -> target ][ $default [ 'code' ]][ $this -> siteDynamicGet [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]][ $default [ 'join_field' ]]][ $default [ 'valueName' ]] .= $otherJoin ;
}
else
{
// build custom join string
2017-12-14 23:10:47 +00:00
$customJoin .= PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " set " . $default [ 'valueName' ] . " to the " . $string . " object. " ;
$customJoin .= PHP_EOL . " \t " . $tab . " \t " . $string . " -> " . $default [ 'valueName' ] . " = \$ this->get " . $default [ 'methodName' ] . " ( " . $string . " -> " . $this -> getAsLookup [ $get [ 'key' ]][ $get [ 'on_field' ]] . " ); " ;
2016-02-26 00:20:09 +00:00
}
}
return $customJoin ;
}
return '' ;
}
2017-12-14 23:10:47 +00:00
public function checkJoint ( & $default , & $get , & $asBucket )
2016-02-26 00:20:09 +00:00
{
// check if this function is not linked to the main call
2017-12-14 23:10:47 +00:00
list ( $aJoin ) = explode ( '.' , $get [ 'on_field' ]);
if ( ComponentbuilderHelper :: checkArray ( $asBucket ) && in_array ( $aJoin , $asBucket ))
2016-02-26 00:20:09 +00:00
{
return false ;
}
// default fallback
elseif ( isset ( $this -> siteDynamicGet [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]][ $default [ 'join_field' ]]) && ComponentbuilderHelper :: checkString ( $this -> siteDynamicGet [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]][ $default [ 'join_field' ]]))
{
return true ;
}
return false ;
}
2017-12-14 23:10:47 +00:00
public function setCustomViewFilter ( & $filter , & $code , $tab = '' )
2016-02-26 00:20:09 +00:00
{
$filters = '' ;
if ( ComponentbuilderHelper :: checkArray ( $filter ))
{
foreach ( $filter as $ter )
{
$as = '' ;
$field = '' ;
$string = '' ;
2017-12-14 23:10:47 +00:00
if ( strpos ( $ter [ 'table_key' ], '.' ) !== false )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
list ( $as , $field ) = array_map ( 'trim' , explode ( '.' , $ter [ 'table_key' ]));
2016-02-26 00:20:09 +00:00
}
switch ( $ter [ 'filter_type' ])
{
case 1 :
2017-12-14 23:10:47 +00:00
// COM_COMPONENTBUILDER_DYNAMIC_GET_ID
$string = PHP_EOL . " \t " . $tab . " \t \$ query->where(' " . $ter [ 'table_key' ] . " " . $ter [ 'operator' ] . " ' . (int) \$ pk); " ;
break ;
2016-02-26 00:20:09 +00:00
case 2 :
2017-12-14 23:10:47 +00:00
// COM_COMPONENTBUILDER_DYNAMIC_GET_USER
$string = PHP_EOL . " \t " . $tab . " \t \$ query->where(' " . $ter [ 'table_key' ] . " " . $ter [ 'operator' ] . " ' . (int) \$ this->userId); " ;
break ;
2016-02-26 00:20:09 +00:00
case 3 :
2017-12-14 23:10:47 +00:00
// COM_COMPONENTBUILDER_DYNAMIC_GET_ACCESS_LEVEL
$string = PHP_EOL . " \t " . $tab . " \t \$ query->where(' " . $ter [ 'table_key' ] . " " . $ter [ 'operator' ] . " (' . implode(',', \$ this->levels) . ')'); " ;
break ;
2016-02-26 00:20:09 +00:00
case 4 :
2017-12-14 23:10:47 +00:00
// COM_COMPONENTBUILDER_DYNAMIC_GET_USER_GROUPS
$decodeChecker = $this -> siteFieldData [ 'decode' ][ $code ][ $ter [ 'key' ]][ $as ][ $field ];
if ( ComponentbuilderHelper :: checkArray ( $decodeChecker ) || $ter [ 'state_key' ] === 'array' )
{
// set needed fields to filter after query
$this -> siteFieldDecodeFilter [ $this -> target ][ $code ][ $ter [ 'key' ]][ $as ][ $field ] = $ter ;
}
else
{
$string = PHP_EOL . " \t " . $tab . " \t \$ query->where(' " . $ter [ 'table_key' ] . " " . $ter [ 'operator' ] . " (' . implode(',', \$ this->groups) . ')'); " ;
}
break ;
2016-02-26 00:20:09 +00:00
case 5 :
2017-12-14 23:10:47 +00:00
// COM_COMPONENTBUILDER_DYNAMIC_GET_CATEGORIES
$string = PHP_EOL . " \t \t " . $tab . " // " . $this -> setLine ( __LINE__ ) . " (TODO) The dynamic category filter is not ready. " ;
break ;
2016-02-26 00:20:09 +00:00
case 6 :
2017-12-14 23:10:47 +00:00
// COM_COMPONENTBUILDER_DYNAMIC_GET_TAGS
$string = PHP_EOL . " \t \t " . $tab . " // " . $this -> setLine ( __LINE__ ) . " (TODO) The dynamic tags filter is not ready. " ;
break ;
2016-02-26 00:20:09 +00:00
case 7 :
2017-12-14 23:10:47 +00:00
// COM_COMPONENTBUILDER_DYNAMIC_GET_DATE
$string = PHP_EOL . " \t \t " . $tab . " // " . $this -> setLine ( __LINE__ ) . " (TODO) The dynamic date filter is not ready. " ;
break ;
2016-02-26 00:20:09 +00:00
case 8 :
2017-12-14 23:10:47 +00:00
// COM_COMPONENTBUILDER_DYNAMIC_GET_FUNCTIONVAR
if ( $ter [ 'operator' ] === 'IN' || $ter [ 'operator' ] === 'NOT IN' )
{
$string = PHP_EOL . " \t \t " . $tab . " // " . $this -> setLine ( __LINE__ ) . " Check if " . $ter [ 'state_key' ] . " is an array with values. " ;
$string .= PHP_EOL . " \t \t " . $tab . " \$ array = " . $ter [ 'state_key' ] . " ; " ;
$string .= PHP_EOL . " \t \t " . $tab . " if (isset( \$ array) && " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ array)) " ;
$string .= PHP_EOL . " \t \t " . $tab . " { " ;
$string .= PHP_EOL . " \t \t " . $tab . " \t \$ query->where(' " . $ter [ 'table_key' ] . " " . $ter [ 'operator' ] . " (' . implode(',', \$ array) . ')'); " ;
$string .= PHP_EOL . " \t \t " . $tab . " } " ;
$string .= PHP_EOL . " \t \t " . $tab . " else " ;
$string .= PHP_EOL . " \t \t " . $tab . " { " ;
$string .= PHP_EOL . " \t \t " . $tab . " \t return false; " ;
$string .= PHP_EOL . " \t \t " . $tab . " } " ;
}
else
{
$string = PHP_EOL . " \t \t " . $tab . " // " . $this -> setLine ( __LINE__ ) . " Check if " . $ter [ 'state_key' ] . " is a string or numeric value. " ;
$string .= PHP_EOL . " \t \t " . $tab . " \$ checkValue = " . $ter [ 'state_key' ] . " ; " ;
$string .= PHP_EOL . " \t \t " . $tab . " if (isset( \$ checkValue) && " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkString( \$ checkValue)) " ;
$string .= PHP_EOL . " \t \t " . $tab . " { " ;
$string .= PHP_EOL . " \t \t " . $tab . " \t \$ query->where(' " . $ter [ 'table_key' ] . " " . $ter [ 'operator' ] . " ' . \$ db->quote( \$ checkValue)); " ;
$string .= PHP_EOL . " \t \t " . $tab . " } " ;
$string .= PHP_EOL . " \t \t " . $tab . " elseif (is_numeric( \$ checkValue)) " ;
$string .= PHP_EOL . " \t \t " . $tab . " { " ;
$string .= PHP_EOL . " \t \t " . $tab . " \t \$ query->where(' " . $ter [ 'table_key' ] . " " . $ter [ 'operator' ] . " ' . \$ checkValue); " ;
$string .= PHP_EOL . " \t \t " . $tab . " } " ;
$string .= PHP_EOL . " \t \t " . $tab . " else " ;
$string .= PHP_EOL . " \t \t " . $tab . " { " ;
$string .= PHP_EOL . " \t \t " . $tab . " \t return false; " ;
$string .= PHP_EOL . " \t \t " . $tab . " } " ;
}
break ;
2016-02-26 00:20:09 +00:00
case 9 :
2017-12-14 23:10:47 +00:00
// COM_COMPONENTBUILDER_DYNAMIC_GET_ARRAY_VALUE
$string = " " ;
// set needed fields to filter after query
$this -> siteFieldDecodeFilter [ $this -> target ][ $code ][ $ter [ 'key' ]][ $as ][ $field ] = $ter ;
break ;
2016-02-26 00:20:09 +00:00
case 10 :
2017-12-14 23:10:47 +00:00
// COM_COMPONENTBUILDER_DYNAMIC_GET_REPEATABLE_VALUE
$string = " " ;
// set needed fields to filter after query
$this -> siteFieldDecodeFilter [ $this -> target ][ $code ][ $ter [ 'key' ]][ $as ][ $field ] = $ter ;
break ;
2016-02-26 00:20:09 +00:00
case 11 :
2017-12-14 23:10:47 +00:00
// COM_COMPONENTBUILDER_DYNAMIC_GET_OTHER
if ( strpos ( $as , '(' ) !== false )
{
// TODO (for now we only fix extra sql methods here)
list ( $dump , $as ) = array_map ( 'trim' , explode ( '(' , $as ));
$field = trim ( str_replace ( ')' , '' , $field ));
}
$string = PHP_EOL . " \t " . $tab . " \t \$ query->where(' " . $ter [ 'table_key' ] . " " . $ter [ 'operator' ] . " " . $ter [ 'state_key' ] . " '); " ;
break ;
2016-02-26 00:20:09 +00:00
}
// only add if the filter is set
if ( ComponentbuilderHelper :: checkString ( $string ))
{
// sort where
2017-02-01 13:17:04 +00:00
if ( $as === 'a' || ( isset ( $this -> siteMainGet [ $this -> target ][ $code ][ $as ]) && ComponentbuilderHelper :: checkString ( $this -> siteMainGet [ $this -> target ][ $code ][ $as ])))
2016-02-26 00:20:09 +00:00
{
$filters .= $string ;
}
2017-12-14 23:10:47 +00:00
elseif ( $as !== 'a' )
2016-02-26 00:20:09 +00:00
{
$this -> otherFilter [ $this -> target ][ $code ][ $as ][ $field ] = $string ;
}
}
}
}
return $filters ;
}
2017-12-14 23:10:47 +00:00
public function setCustomViewOrder ( & $order , & $code , $tab = '' )
2016-02-26 00:20:09 +00:00
{
$ordering = '' ;
if ( ComponentbuilderHelper :: checkArray ( $order ))
{
foreach ( $order as $or )
{
2017-12-14 23:10:47 +00:00
list ( $as , $field ) = array_map ( 'trim' , explode ( '.' , $or [ 'table_key' ]));
2016-02-26 00:20:09 +00:00
// set the string
2017-12-14 23:10:47 +00:00
$string = " \$ query->order(' " . $or [ 'table_key' ] . " " . $or [ 'direction' ] . " '); " ;
2016-02-26 00:20:09 +00:00
// sort where
2017-02-01 13:17:04 +00:00
if ( $as === 'a' || ( isset ( $this -> siteMainGet [ $this -> target ][ $code ][ $as ]) && ComponentbuilderHelper :: checkString ( $this -> siteMainGet [ $this -> target ][ $code ][ $as ])))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$ordering .= PHP_EOL . " \t " . $tab . " \t " . $string ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$this -> otherOrder [ $this -> target ][ $code ][ $as ][ $field ] = PHP_EOL . " \t \t " . $string ;
2016-02-26 00:20:09 +00:00
}
}
}
return $ordering ;
}
2017-12-14 23:10:47 +00:00
public function setCustomViewWhere ( & $where , & $code , $tab = '' )
2016-02-26 00:20:09 +00:00
{
$wheres = '' ;
if ( ComponentbuilderHelper :: checkArray ( $where ))
{
foreach ( $where as $whe )
{
$as = '' ;
$field = '' ;
$value = '' ;
2017-12-14 23:10:47 +00:00
list ( $as , $field ) = array_map ( 'trim' , explode ( '.' , $whe [ 'table_key' ]));
2016-02-26 00:20:09 +00:00
if ( is_numeric ( $whe [ 'value_key' ]))
{
2017-12-14 23:10:47 +00:00
$value = " " . $whe [ 'value_key' ] . " '); " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
elseif ( strpos ( $whe [ 'value_key' ], '$' ) !== false )
2016-02-26 00:20:09 +00:00
{
2017-02-01 13:17:04 +00:00
if ( $whe [ 'operator' ] === 'IN' || $whe [ 'operator' ] === 'NOT IN' )
2016-02-26 00:20:09 +00:00
{
$value = " (' . implode(',', " . $whe [ 'value_key' ] . " ) . ')'); " ;
}
else
{
2017-12-14 23:10:47 +00:00
$value = " ' . \$ db->quote( " . $whe [ 'value_key' ] . " )); " ;
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
elseif ( strpos ( $whe [ 'value_key' ], '.' ) !== false )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( strpos ( $whe [ 'value_key' ], " ' " ) !== false )
2017-04-26 08:55:02 +00:00
{
2017-12-14 23:10:47 +00:00
$value = " ' . \$ db->quote( " . $whe [ 'value_key' ] . " )); " ;
2017-04-26 08:55:02 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$value = " " . $whe [ 'value_key' ] . " '); " ;
2017-04-26 08:55:02 +00:00
}
2016-02-26 00:20:09 +00:00
}
2017-09-13 10:15:14 +00:00
elseif ( ComponentbuilderHelper :: checkString ( $whe [ 'value_key' ]))
{
2017-12-14 23:10:47 +00:00
$value = " " . $whe [ 'value_key' ] . " '); " ;
2017-09-13 10:15:14 +00:00
}
2016-02-26 00:20:09 +00:00
// only load if there is a value
if ( ComponentbuilderHelper :: checkString ( $value ))
{
2017-04-26 08:55:02 +00:00
$tabe = '' ;
if ( $as === 'a' )
{
$tabe = $tab ;
}
2016-02-26 00:20:09 +00:00
// set the string
2017-02-01 13:17:04 +00:00
if ( $whe [ 'operator' ] === 'IN' || $whe [ 'operator' ] === 'NOT IN' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$string = " if (isset( " . $whe [ 'value_key' ] . " ) && " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( " . $whe [ 'value_key' ] . " )) " ;
$string .= PHP_EOL . " \t " . $tabe . " \t { " ;
$string .= PHP_EOL . " \t " . $tabe . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get where " . $whe [ 'table_key' ] . " is " . $whe [ 'value_key' ];
$string .= PHP_EOL . " \t " . $tabe . " \t \t \$ query->where(' " . $whe [ 'table_key' ] . " " . $whe [ 'operator' ] . $value ;
$string .= PHP_EOL . " \t " . $tabe . " \t } " ;
$string .= PHP_EOL . " \t " . $tabe . " \t else " ;
$string .= PHP_EOL . " \t " . $tabe . " \t { " ;
$string .= PHP_EOL . " \t " . $tabe . " \t \t return false; " ;
$string .= PHP_EOL . " \t " . $tabe . " \t } " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$string = " // " . $this -> setLine ( __LINE__ ) . " Get where " . $whe [ 'table_key' ] . " is " . $whe [ 'value_key' ];
$string .= PHP_EOL . " \t " . $tabe . " \t \$ query->where(' " . $whe [ 'table_key' ] . " " . $whe [ 'operator' ] . $value ;
2016-02-26 00:20:09 +00:00
}
// sort where
2017-02-01 13:17:04 +00:00
if ( $as === 'a' || ( isset ( $this -> siteMainGet [ $this -> target ][ $code ][ $as ]) && ComponentbuilderHelper :: checkString ( $this -> siteMainGet [ $this -> target ][ $code ][ $as ])))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$wheres .= PHP_EOL . " \t " . $tab . " \t " . $string ;
2016-02-26 00:20:09 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $as !== 'a' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$this -> otherWhere [ $this -> target ][ $code ][ $as ][ $field ] = PHP_EOL . " \t \t " . $string ;
2016-02-26 00:20:09 +00:00
}
}
}
}
return $wheres ;
}
2017-12-14 23:10:47 +00:00
public function setCustomViewGlobals ( & $global , $string , $as , $tab = '' )
2016-02-26 00:20:09 +00:00
{
$globals = '' ;
if ( ComponentbuilderHelper :: checkArray ( $global ))
{
$as = array_unique ( $as );
foreach ( $global as $glo )
{
2017-12-14 23:10:47 +00:00
if ( in_array ( $glo [ 'as' ], $as ))
2016-02-26 00:20:09 +00:00
{
switch ( $glo [ 'type' ])
{
case 1 :
2017-12-14 23:10:47 +00:00
// SET STATE
$value = " \$ this->setState(' " . $glo [ 'as' ] . " . " . $glo [ 'name' ] . " ', " . $string . " -> " . $glo [ 'key' ] . " ); " ;
break ;
2016-02-26 00:20:09 +00:00
case 2 :
2017-12-14 23:10:47 +00:00
// SET THIS
$value = " \$ this-> " . $glo [ 'as' ] . " _ " . $glo [ 'name' ] . " = " . $string . " -> " . $glo [ 'key' ] . " ; " ;
break ;
2016-02-26 00:20:09 +00:00
}
// only add if the filter is set
if ( ComponentbuilderHelper :: checkString ( $value ))
{
2017-12-14 23:10:47 +00:00
$globals .= PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " set the global " . $glo [ 'name' ] . " value. " . PHP_EOL . " \t " . $tab . " \t " . $value ;
2016-02-26 00:20:09 +00:00
}
}
}
}
return $globals ;
}
2016-04-22 12:03:43 +00:00
/**
* @ param $string
* @ param string $type
* @ return mixed
2017-12-14 23:10:47 +00:00
*/
2016-04-22 12:03:43 +00:00
public function removeAsDot ( $string , $type = '' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( strpos ( $string , '.' ) !== false )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
list ( $dump , $field ) = array_map ( 'trim' , explode ( '.' , $string ));
2016-02-26 00:20:09 +00:00
}
else
{
$field = $string ;
}
return $field ;
}
2017-12-14 23:10:47 +00:00
2016-12-30 10:47:19 +00:00
/**
* @ param type $view
* @ param type $type
*/
public function setUserPermissionCheckAccess ( $view , $type )
{
if ( isset ( $view [ 'access' ]) && $view [ 'access' ] == 1 )
{
2017-12-14 23:10:47 +00:00
switch ( $type )
2016-12-30 10:47:19 +00:00
{
case 1 :
$userString = '$this->user' ;
break ;
default :
$userString = '$user' ;
break ;
}
// check that the default and the redirect page is not the same
2017-07-20 23:26:48 +00:00
if ( isset ( $this -> fileContentStatic [ '###SITE_DEFAULT_VIEW###' ]) && $this -> fileContentStatic [ '###SITE_DEFAULT_VIEW###' ] != $view [ 'settings' ] -> code )
2016-12-30 10:47:19 +00:00
{
2017-12-14 23:10:47 +00:00
$redirectMessage = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " redirect away to the default view if no access allowed. " ;
$redirectString = " JRoute::_('index.php?option=com_ " . $this -> fileContentStatic [ '###component###' ] . " &view= " . $this -> fileContentStatic [ '###SITE_DEFAULT_VIEW###' ] . " ') " ;
2016-12-30 10:47:19 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$redirectMessage = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " redirect away to the home page if no access allowed. " ;
2016-12-30 10:47:19 +00:00
$redirectString = 'JURI::root()' ;
}
2017-12-14 23:10:47 +00:00
$accessCheck [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " check if this user has permission to access item " ;
$accessCheck [] = " \t \t if (! " . $userString . " ->authorise('site. " . $view [ 'settings' ] -> code . " .access', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " ')) " ;
2016-12-30 10:47:19 +00:00
$accessCheck [] = " \t \t { " ;
$accessCheck [] = " \t \t \t \$ app = JFactory::getApplication(); " ;
// set lang
2017-12-14 23:10:47 +00:00
$langKeyWord = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( 'Not authorised to view ' . $view [ 'settings' ] -> code . '!' , 'U' );
2016-12-30 10:47:19 +00:00
if ( ! isset ( $this -> langContent [ 'site' ][ $langKeyWord ]))
{
2017-12-14 23:10:47 +00:00
$this -> langContent [ 'site' ][ $langKeyWord ] = 'Not authorised to view ' . $view [ 'settings' ] -> code . '!' ;
2016-12-30 10:47:19 +00:00
}
2017-12-14 23:10:47 +00:00
$accessCheck [] = " \t \t \t \$ app->enqueueMessage(JText::_(' " . $langKeyWord . " '), 'error'); " ;
2016-12-30 10:47:19 +00:00
$accessCheck [] = $redirectMessage ;
2017-12-14 23:10:47 +00:00
$accessCheck [] = " \t \t \t \$ app->redirect( " . $redirectString . " ); " ;
2016-12-30 10:47:19 +00:00
$accessCheck [] = " \t \t \t return false; " ;
$accessCheck [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
2016-12-30 10:47:19 +00:00
// return the access check
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $accessCheck );
2016-12-30 10:47:19 +00:00
}
return '' ;
}
2016-02-26 00:20:09 +00:00
2016-04-22 12:03:43 +00:00
/**
* @ param $get
* @ param $code
* @ param string $tab
* @ param string $type
* @ return string
2017-12-14 23:10:47 +00:00
*/
2016-04-22 12:03:43 +00:00
public function setCustomViewGetItem ( & $get , & $code , $tab = '' , $type = 'main' )
2016-02-26 00:20:09 +00:00
{
if ( ComponentbuilderHelper :: checkObject ( $get ))
{
$this -> siteDecrypt [ 'basic' ][ $code ] = false ;
$this -> siteDecrypt [ 'advanced' ][ $code ] = false ;
2017-12-14 23:10:47 +00:00
$getItem = PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " Get a db connection. " ;
$getItem .= PHP_EOL . " \t " . $tab . " \t \$ db = JFactory::getDbo(); " ;
$getItem .= PHP_EOL . PHP_EOL . $tab . " \t \t // " . $this -> setLine ( __LINE__ ) . " Create a new query object. " ;
$getItem .= PHP_EOL . " \t " . $tab . " \t \$ query = \$ db->getQuery(true); " ;
2016-02-26 00:20:09 +00:00
// set main get query
2017-12-14 23:10:47 +00:00
$getItem .= $this -> setCustomViewQuery ( $get -> main_get , $code , $tab );
2016-02-26 00:20:09 +00:00
// setup filters
2017-12-14 23:10:47 +00:00
$getItem .= $this -> setCustomViewFilter ( $get -> filter , $code , $tab );
2016-02-26 00:20:09 +00:00
// setup Where
2017-12-14 23:10:47 +00:00
$getItem .= $this -> setCustomViewWhere ( $get -> where , $code , $tab );
2016-02-26 00:20:09 +00:00
// setup ordering
2017-12-14 23:10:47 +00:00
$getItem .= $this -> setCustomViewOrder ( $get -> order , $code , $tab );
2016-02-26 00:20:09 +00:00
// get ready to get query
2017-12-14 23:10:47 +00:00
$getItem .= PHP_EOL . PHP_EOL . $tab . " \t \t // " . $this -> setLine ( __LINE__ ) . " Reset the query using our newly populated query object. " ;
$getItem .= PHP_EOL . " \t " . $tab . " \t \$ db->setQuery( \$ query); " ;
$getItem .= PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " Load the results as a stdClass object. " ;
$getItem .= PHP_EOL . " \t " . $tab . " \t \$ data = \$ db->loadObject(); " ;
$getItem .= PHP_EOL . PHP_EOL . $tab . " \t \t if (empty( \$ data)) " ;
$getItem .= PHP_EOL . " \t " . $tab . " \t { " ;
2017-02-01 13:17:04 +00:00
if ( $type === 'main' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$getItem .= PHP_EOL . " \t " . $tab . " \t \t \$ app = JFactory::getApplication(); " ;
$langKeyWoord = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( 'Not found or access denied' , 'U' );
2017-07-20 23:26:48 +00:00
if ( ! isset ( $this -> langContent [ $this -> lang ][ $langKeyWoord ]))
2016-02-26 00:20:09 +00:00
{
2017-07-20 23:26:48 +00:00
$this -> langContent [ $this -> lang ][ $langKeyWoord ] = 'Not found, or access denied.' ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$getItem .= PHP_EOL . " \t " . $tab . " \t \t // " . $this -> setLine ( __LINE__ ) . " If no data is found redirect to default page and show warning. " ;
$getItem .= PHP_EOL . " \t " . $tab . " \t \t \$ app->enqueueMessage(JText::_(' " . $langKeyWoord . " '), 'warning'); " ;
2017-02-02 11:54:07 +00:00
if ( 'site' === $this -> target )
2016-02-26 00:20:09 +00:00
{
2016-12-30 10:47:19 +00:00
// check that the default and the redirect page is not the same
2017-07-20 23:26:48 +00:00
if ( isset ( $this -> fileContentStatic [ '###SITE_DEFAULT_VIEW###' ]) && $this -> fileContentStatic [ '###SITE_DEFAULT_VIEW###' ] != $code )
2016-12-30 10:47:19 +00:00
{
2017-12-14 23:10:47 +00:00
$redirectString = " JRoute::_('index.php?option=com_ " . $this -> fileContentStatic [ '###component###' ] . " &view= " . $this -> fileContentStatic [ '###SITE_DEFAULT_VIEW###' ] . " ') " ;
2016-12-30 10:47:19 +00:00
}
else
{
$redirectString = 'JURI::root()' ;
}
2017-12-14 23:10:47 +00:00
$getItem .= PHP_EOL . " \t " . $tab . " \t \t \$ app->redirect( " . $redirectString . " ); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$getItem .= PHP_EOL . " \t " . $tab . " \t \t \$ app->redirect('index.php?option=com_ " . $this -> fileContentStatic [ '###component###' ] . " '); " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$getItem .= PHP_EOL . " \t " . $tab . " \t \t return false; " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$getItem .= PHP_EOL . " \t " . $tab . " \t \t return false; " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$getItem .= PHP_EOL . " \t " . $tab . " \t } " ;
2017-12-04 15:57:19 +00:00
// dispatcher placholder
$getItem .= " ###DISPATCHER### " ;
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkArray ( $get -> main_get ))
{
$asBucket = array ();
foreach ( $get -> main_get as $main_get )
{
if ( isset ( $this -> siteFieldData [ 'decode' ][ $code ][ $main_get [ 'key' ]][ $main_get [ 'as' ]]))
{
$decodeChecker = $this -> siteFieldData [ 'decode' ][ $code ][ $main_get [ 'key' ]][ $main_get [ 'as' ]];
if ( ComponentbuilderHelper :: checkArray ( $decodeChecker ))
{
// set decoding of needed fields
2017-12-14 23:10:47 +00:00
$getItem .= $this -> setCustomViewFieldDecode ( $main_get , $decodeChecker , '$data' , $code , $tab );
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> siteFieldDecodeFilter [ $this -> target ][ $code ][ $main_get [ 'key' ]][ $main_get [ 'as' ]]))
2016-02-26 00:20:09 +00:00
{
$decodeFilter = $this -> siteFieldDecodeFilter [ $this -> target ][ $code ][ $main_get [ 'key' ]][ $main_get [ 'as' ]];
if ( ComponentbuilderHelper :: checkArray ( $decodeFilter ))
{
// also filter fields if needed
2017-12-14 23:10:47 +00:00
$getItem .= $this -> setCustomViewFieldDecodeFilter ( $main_get , $decodeFilter , '$data' , '$data' , $code , $tab );
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
2017-12-10 19:17:26 +00:00
if ( isset ( $this -> siteFieldData [ 'textareas' ][ $code ][ $main_get [ 'key' ]][ $main_get [ 'as' ]]))
{
$contentprepareChecker = $this -> siteFieldData [ 'textareas' ][ $code ][ $main_get [ 'key' ]][ $main_get [ 'as' ]];
if ( ComponentbuilderHelper :: checkArray ( $contentprepareChecker ))
{
// set contentprepare checkers on needed fields
$getItem .= $this -> setCustomViewFieldonContentPrepareChecker ( $main_get , $contentprepareChecker , '$data' , $code , $tab );
}
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> siteFieldData [ 'uikit' ][ $code ][ $main_get [ 'key' ]][ $main_get [ 'as' ]]))
{
$uikitChecker = $this -> siteFieldData [ 'uikit' ][ $code ][ $main_get [ 'key' ]][ $main_get [ 'as' ]];
if ( ComponentbuilderHelper :: checkArray ( $uikitChecker ))
{
// set uikit checkers on needed fields
2017-11-11 04:33:51 +00:00
$getItem .= $this -> setCustomViewFieldUikitChecker ( $main_get , $uikitChecker , '$data' , $code , $tab );
2016-02-26 00:20:09 +00:00
}
}
$asBucket [] = $main_get [ 'as' ];
}
}
if (( isset ( $this -> siteDecrypt [ 'basic' ][ $code ]) && $this -> siteDecrypt [ 'basic' ][ $code ]) || ( isset ( $this -> siteDecrypt [ 'advanced' ][ $code ]) && $this -> siteDecrypt [ 'advanced' ][ $code ]))
{
2017-12-14 23:10:47 +00:00
$Component = $this -> fileContentStatic [ '###Component###' ];
2016-02-26 00:20:09 +00:00
$script = '' ;
if ( isset ( $this -> siteDecrypt [ 'basic' ][ $code ]) && $this -> siteDecrypt [ 'basic' ][ $code ])
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " Get the basic encryption. " ;
$script .= PHP_EOL . " \t " . $tab . " \t \$ basickey = " . $Component . " Helper::getCryptKey('basic'); " ;
$script .= PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " Get the encryption object. " ;
$script .= PHP_EOL . " \t " . $tab . " \t \$ basic = new FOFEncryptAes( \$ basickey, 128); " ;
2016-02-26 00:20:09 +00:00
}
if ( isset ( $this -> siteDecrypt [ 'advanced' ][ $code ]) && $this -> siteDecrypt [ 'advanced' ][ $code ])
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " Get the advanced encryption. " ;
$script .= PHP_EOL . " \t " . $tab . " \t \$ advancedkey = " . $Component . " Helper::getCryptKey('advanced'); " ;
$script .= PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " Get the encryption object. " ;
$script .= PHP_EOL . " \t " . $tab . " \t \$ advanced = new FOFEncryptAes( \$ advancedkey, 256); " ;
2016-02-26 00:20:09 +00:00
}
$getItem = $script . $getItem ;
}
// setup Globals
2017-12-14 23:10:47 +00:00
$getItem .= $this -> setCustomViewGlobals ( $get -> global , '$data' , $asBucket , $tab );
2016-02-26 00:20:09 +00:00
// setup the custom gets that returns multipal values
2017-12-14 23:10:47 +00:00
$getItem .= $this -> setCustomViewCustomJoin ( $get -> custom_get , '$data' , $code , $asBucket , $tab );
2016-02-26 00:20:09 +00:00
// set calculations
if ( $get -> addcalculation == 1 )
{
2017-12-14 23:10:47 +00:00
$get -> php_calculation = ( array ) explode ( PHP_EOL , $get -> php_calculation );
$getItem .= PHP_EOL . " \t " . $tab . " \t " . implode ( PHP_EOL . " \t " . $tab . " \t " , $get -> php_calculation );
2016-02-26 00:20:09 +00:00
}
2017-02-01 13:17:04 +00:00
if ( $type === 'custom' )
2016-02-26 00:20:09 +00:00
{
// return the object
2017-12-14 23:10:47 +00:00
$getItem .= PHP_EOL . PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " return data object. " ;
$getItem .= PHP_EOL . " \t " . $tab . " \t return \$ data; " ;
2016-02-26 00:20:09 +00:00
}
else
{
// set the object
2017-12-14 23:10:47 +00:00
$getItem .= PHP_EOL . PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " set data object to item. " ;
$getItem .= PHP_EOL . " \t " . $tab . " \t \$ this->_item[ \$ pk] = \$ data; " ;
2016-02-26 00:20:09 +00:00
}
2017-12-04 15:57:19 +00:00
// check if the dispather should be added
return str_replace ( array_keys ( $this -> JEventDispatcher ), array_values ( $this -> JEventDispatcher ), $getItem );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
return PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " add your custom code here. " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
public function setCustomViewCustomMethods ( $main_view , $code )
2016-02-26 00:20:09 +00:00
{
$methods = '' ;
// then set the needed custom methods
if ( ComponentbuilderHelper :: checkArray ( $main_view [ 'settings' ] -> custom_get ))
{
// start dynamic build
foreach ( $main_view [ 'settings' ] -> custom_get as $view )
{
// fix alias to use in code
$view -> code = ComponentbuilderHelper :: safeString ( $code );
$view -> Code = ComponentbuilderHelper :: safeString ( $view -> code , 'F' );
$view -> CODE = ComponentbuilderHelper :: safeString ( $view -> code , 'U' );
$main = '' ;
if ( $view -> gettype == 3 )
{
// ###SITE_GET_ITEM### <<<DYNAMIC>>>
2017-12-14 23:10:47 +00:00
$main .= PHP_EOL . PHP_EOL . " \t \t if (!isset( \$ this->initSet) || ! \$ this->initSet) " ;
$main .= PHP_EOL . " \t \t { " ;
$main .= PHP_EOL . " \t \t \t \$ this->user \t \t = JFactory::getUser(); " ;
$main .= PHP_EOL . " \t \t \t \$ this->userId \t \t = \$ this->user->get('id'); " ;
$main .= PHP_EOL . " \t \t \t \$ this->guest \t \t = \$ this->user->get('guest'); " ;
$main .= PHP_EOL . " \t \t \t \$ this->groups \t \t = \$ this->user->get('groups'); " ;
$main .= PHP_EOL . " \t \t \t \$ this->authorisedGroups \t = \$ this->user->getAuthorisedGroups(); " ;
$main .= PHP_EOL . " \t \t \t \$ this->levels \t \t = \$ this->user->getAuthorisedViewLevels(); " ;
$main .= PHP_EOL . " \t \t \t \$ this->initSet \t \t = true; " ;
$main .= PHP_EOL . " \t \t } " ;
$main .= $this -> setCustomViewGetItem ( $view , $view -> code , '' , 'custom' );
2016-02-26 00:20:09 +00:00
$type = 'mixed item data object on success, false on failure.' ;
}
elseif ( $view -> gettype == 4 )
{
2017-12-14 23:10:47 +00:00
$main .= PHP_EOL . PHP_EOL . " \t \t if (!isset( \$ this->initSet) || ! \$ this->initSet) " ;
$main .= PHP_EOL . " \t \t { " ;
$main .= PHP_EOL . " \t \t \t \$ this->user \t \t = JFactory::getUser(); " ;
$main .= PHP_EOL . " \t \t \t \$ this->userId \t \t = \$ this->user->get('id'); " ;
$main .= PHP_EOL . " \t \t \t \$ this->guest \t \t = \$ this->user->get('guest'); " ;
$main .= PHP_EOL . " \t \t \t \$ this->groups \t \t = \$ this->user->get('groups'); " ;
$main .= PHP_EOL . " \t \t \t \$ this->authorisedGroups \t = \$ this->user->getAuthorisedGroups(); " ;
$main .= PHP_EOL . " \t \t \t \$ this->levels \t \t = \$ this->user->getAuthorisedViewLevels(); " ;
$main .= PHP_EOL . " \t \t \t \$ this->initSet \t \t = true; " ;
$main .= PHP_EOL . " \t \t } " ;
$main .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the global params " ;
$main .= PHP_EOL . " \t \t \$ globalParams = JComponentHelper::getParams('com_ " . $this -> fileContentStatic [ '###component###' ] . " ', true); " ;
2016-02-26 00:20:09 +00:00
// ###SITE_GET_LIST_QUERY### <<<DYNAMIC>>>
$main .= $this -> setCustomViewListQuery ( $view , $view -> code , false );
// load the object list
2017-12-14 23:10:47 +00:00
$main .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Reset the query using our newly populated query object. " ;
$main .= PHP_EOL . " \t \t \$ db->setQuery( \$ query); " ;
$main .= PHP_EOL . " \t \t \$ items = \$ db->loadObjectList(); " ;
$main .= PHP_EOL . PHP_EOL . " \t \t if (empty( \$ items)) " ;
$main .= PHP_EOL . " \t \t { " ;
$main .= PHP_EOL . " \t \t \t return false; " ;
$main .= PHP_EOL . " \t \t } " ;
2016-02-26 00:20:09 +00:00
// ###SITE_GET_ITEMS### <<<DYNAMIC>>>
2017-12-14 23:10:47 +00:00
$main .= $this -> setCustomViewGetItems ( $view , $view -> code );
$main .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " return items " ;
$main .= PHP_EOL . " \t \t return \$ items; " ;
2016-02-26 00:20:09 +00:00
$type = 'mixed An array of objects on success, false on failure.' ;
}
// load the main mehtod
2017-12-14 23:10:47 +00:00
$methods .= $this -> setMainCustomMehtod ( $main , $view -> getcustom , $type );
2016-02-26 00:20:09 +00:00
// ###SITE_CUSTOM_METHODS### <<<DYNAMIC>>>
$methods .= $this -> setCustomViewCustomItemMethods ( $view , $view -> code );
}
}
// load uikit get method
$methods .= $this -> setUikitGetMethod ();
return $methods ;
}
public function setUikitHelperMethods ()
{
2017-11-11 04:33:51 +00:00
// only load for uikit version 2
if ( 2 == $this -> uikit || 1 == $this -> uikit )
2016-02-26 00:20:09 +00:00
{
// build uikit get method
$ukit = array ();
2017-12-14 23:10:47 +00:00
$ukit [] = PHP_EOL . PHP_EOL . " \t /** " ;
2016-02-26 00:20:09 +00:00
$ukit [] = " \t * \t UIKIT Component Classes " ;
$ukit [] = " \t **/ " ;
$ukit [] = " \t public static \$ uk_components = array( " ;
$ukit [] = " \t \t \t 'data-uk-grid' => array( " ;
$ukit [] = " \t \t \t \t 'grid' ), " ;
$ukit [] = " \t \t \t 'uk-accordion' => array( " ;
$ukit [] = " \t \t \t \t 'accordion' ), " ;
$ukit [] = " \t \t \t 'uk-autocomplete' => array( " ;
$ukit [] = " \t \t \t \t 'autocomplete' ), " ;
$ukit [] = " \t \t \t 'data-uk-datepicker' => array( " ;
$ukit [] = " \t \t \t \t 'datepicker' ), " ;
$ukit [] = " \t \t \t 'uk-form-password' => array( " ;
$ukit [] = " \t \t \t \t 'form-password' ), " ;
$ukit [] = " \t \t \t 'uk-form-select' => array( " ;
$ukit [] = " \t \t \t \t 'form-select' ), " ;
$ukit [] = " \t \t \t 'data-uk-htmleditor' => array( " ;
$ukit [] = " \t \t \t \t 'htmleditor' ), " ;
$ukit [] = " \t \t \t 'data-uk-lightbox' => array( " ;
$ukit [] = " \t \t \t \t 'lightbox' ), " ;
$ukit [] = " \t \t \t 'uk-nestable' => array( " ;
$ukit [] = " \t \t \t \t 'nestable' ), " ;
$ukit [] = " \t \t \t 'UIkit.notify' => array( " ;
$ukit [] = " \t \t \t \t 'notify' ), " ;
$ukit [] = " \t \t \t 'data-uk-parallax' => array( " ;
$ukit [] = " \t \t \t \t 'parallax' ), " ;
$ukit [] = " \t \t \t 'uk-search' => array( " ;
$ukit [] = " \t \t \t \t 'search' ), " ;
$ukit [] = " \t \t \t 'uk-slider' => array( " ;
$ukit [] = " \t \t \t \t 'slider' ), " ;
$ukit [] = " \t \t \t 'uk-slideset' => array( " ;
$ukit [] = " \t \t \t \t 'slideset' ), " ;
$ukit [] = " \t \t \t 'uk-slideshow' => array( " ;
$ukit [] = " \t \t \t \t 'slideshow', " ;
$ukit [] = " \t \t \t \t 'slideshow-fx' ), " ;
$ukit [] = " \t \t \t 'uk-sortable' => array( " ;
$ukit [] = " \t \t \t \t 'sortable' ), " ;
$ukit [] = " \t \t \t 'data-uk-sticky' => array( " ;
$ukit [] = " \t \t \t \t 'sticky' ), " ;
$ukit [] = " \t \t \t 'data-uk-timepicker' => array( " ;
$ukit [] = " \t \t \t \t 'timepicker' ), " ;
$ukit [] = " \t \t \t 'data-uk-tooltip' => array( " ;
$ukit [] = " \t \t \t \t 'tooltip' ), " ;
$ukit [] = " \t \t \t 'uk-placeholder' => array( " ;
$ukit [] = " \t \t \t \t 'placeholder' ), " ;
$ukit [] = " \t \t \t 'uk-dotnav' => array( " ;
$ukit [] = " \t \t \t \t 'dotnav' ), " ;
$ukit [] = " \t \t \t 'uk-slidenav' => array( " ;
$ukit [] = " \t \t \t \t 'slidenav' ), " ;
$ukit [] = " \t \t \t 'uk-form' => array( " ;
$ukit [] = " \t \t \t \t 'form-advanced' ), " ;
$ukit [] = " \t \t \t 'uk-progress' => array( " ;
$ukit [] = " \t \t \t \t 'progress' ), " ;
$ukit [] = " \t \t \t 'upload-drop' => array( " ;
$ukit [] = " \t \t \t \t 'upload', 'form-file' ) " ;
$ukit [] = " \t \t \t ); " ;
$ukit [] = " \t " ;
$ukit [] = " \t /** " ;
$ukit [] = " \t * \t Add UIKIT Components " ;
$ukit [] = " \t **/ " ;
$ukit [] = " \t public static \$ uikit = false; " ;
$ukit [] = " " ;
$ukit [] = " \t /** " ;
$ukit [] = " \t * \t Get UIKIT Components " ;
$ukit [] = " \t **/ " ;
$ukit [] = " \t public static function getUikitComp( \$ content, \$ classes = array()) " ;
$ukit [] = " \t { " ;
$ukit [] = " \t \t if (strpos( \$ content,'class= \" uk-') !== false) " ;
$ukit [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$ukit [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " reset " ;
2016-02-26 00:20:09 +00:00
$ukit [] = " \t \t \t \$ temp = array(); " ;
$ukit [] = " \t \t \t foreach (self:: \$ uk_components as \$ looking => \$ add) " ;
$ukit [] = " \t \t \t { " ;
$ukit [] = " \t \t \t \t if (strpos( \$ content, \$ looking) !== false) " ;
$ukit [] = " \t \t \t \t { " ;
$ukit [] = " \t \t \t \t \t \$ temp[] = \$ looking; " ;
$ukit [] = " \t \t \t \t } " ;
$ukit [] = " \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$ukit [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " make sure uikit is loaded to config " ;
2016-02-26 00:20:09 +00:00
$ukit [] = " \t \t \t if (strpos( \$ content,'class= \" uk-') !== false) " ;
$ukit [] = " \t \t \t { " ;
$ukit [] = " \t \t \t \t self:: \$ uikit = true; " ;
$ukit [] = " \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$ukit [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " sorter " ;
2016-02-26 00:20:09 +00:00
$ukit [] = " \t \t \t if (self::checkArray( \$ temp)) " ;
$ukit [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$ukit [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " merger " ;
2016-02-26 00:20:09 +00:00
$ukit [] = " \t \t \t \t if (self::checkArray( \$ classes)) " ;
$ukit [] = " \t \t \t \t { " ;
$ukit [] = " \t \t \t \t \t \$ newTemp = array_merge( \$ temp, \$ classes); " ;
$ukit [] = " \t \t \t \t \t \$ temp = array_unique( \$ newTemp); " ;
$ukit [] = " \t \t \t \t } " ;
$ukit [] = " \t \t \t \t return \$ temp; " ;
$ukit [] = " \t \t \t } " ;
$ukit [] = " \t \t } \t " ;
$ukit [] = " \t \t if (self::checkArray( \$ classes)) " ;
$ukit [] = " \t \t { " ;
$ukit [] = " \t \t \t return \$ classes; " ;
$ukit [] = " \t \t } " ;
$ukit [] = " \t \t return false; " ;
$ukit [] = " \t } " ;
// return the help methods
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $ukit );
2016-02-26 00:20:09 +00:00
}
return '' ;
}
public function setUikitGetMethod ()
{
$method = '' ;
2017-11-11 04:33:51 +00:00
// only load for uikit version 2
if ( 2 == $this -> uikit || 1 == $this -> uikit )
2016-02-26 00:20:09 +00:00
{
// build uikit get method
2017-12-14 23:10:47 +00:00
$method .= PHP_EOL . PHP_EOL . " \t /** " ;
$method .= PHP_EOL . " \t * Get the uikit needed components " ;
$method .= PHP_EOL . " \t * " ;
$method .= PHP_EOL . " \t * @return mixed An array of objects on success. " ;
$method .= PHP_EOL . " \t * " ;
$method .= PHP_EOL . " \t */ " ;
$method .= PHP_EOL . " \t public function getUikitComp() " ;
$method .= PHP_EOL . " \t { " ;
$method .= PHP_EOL . " \t \t if (isset( \$ this->uikitComp) && " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ this->uikitComp)) " ;
$method .= PHP_EOL . " \t \t { " ;
$method .= PHP_EOL . " \t \t \t return \$ this->uikitComp; " ;
$method .= PHP_EOL . " \t \t } " ;
$method .= PHP_EOL . " \t \t return false; " ;
$method .= PHP_EOL . " \t } " ;
2016-02-26 00:20:09 +00:00
}
return $method ;
}
2017-12-14 23:10:47 +00:00
public function setMainCustomMehtod ( & $body , $nAme , $type )
2016-02-26 00:20:09 +00:00
{
$method = '' ;
if ( ComponentbuilderHelper :: checkString ( $body ))
{
// build custom method
2017-12-14 23:10:47 +00:00
$method .= PHP_EOL . PHP_EOL . " \t /** " ;
$method .= PHP_EOL . " \t * Custom Method " ;
$method .= PHP_EOL . " \t * " ;
$method .= PHP_EOL . " \t * @return " . $type ;
$method .= PHP_EOL . " \t * " ;
$method .= PHP_EOL . " \t */ " ;
$method .= PHP_EOL . " \t public function " . $nAme . " () " ;
$method .= PHP_EOL . " \t { " . $body ;
$method .= PHP_EOL . " \t } " ;
2016-02-26 00:20:09 +00:00
}
return $method ;
}
2017-12-14 23:10:47 +00:00
public function setCustomViewCustomItemMethods ( & $main_get , $code )
2016-02-26 00:20:09 +00:00
{
$methods = '' ;
// first set the needed item/s methods
if ( ComponentbuilderHelper :: checkObject ( $main_get ))
{
if ( isset ( $main_get -> custom_get ) && ComponentbuilderHelper :: checkArray ( $main_get -> custom_get ))
{
foreach ( $main_get -> custom_get as $get )
{
$this -> siteDecrypt [ 'basic' ][ $code ] = false ;
$this -> siteDecrypt [ 'advanced' ][ $code ] = false ;
// set the method defaults
2017-12-14 23:10:47 +00:00
$default = $this -> setCustomViewMethodDefaults ( $get , $code );
2016-02-26 00:20:09 +00:00
// build custom method
2017-12-14 23:10:47 +00:00
$methods .= PHP_EOL . PHP_EOL . " \t /** " ;
$methods .= PHP_EOL . " \t * Method to get an array of " . $default [ 'name' ] . " Objects. " ;
$methods .= PHP_EOL . " \t * " ;
$methods .= PHP_EOL . " \t * @return mixed An array of " . $default [ 'name' ] . " Objects on success, false on failure. " ;
$methods .= PHP_EOL . " \t * " ;
$methods .= PHP_EOL . " \t */ " ;
$methods .= PHP_EOL . " \t public function get " . $default [ 'methodName' ] . " ( \$ " . $default [ 'on_field' ] . " ) " ;
$methods .= PHP_EOL . " \t { ###CRYPT### " ;
$methods .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get a db connection. " ;
$methods .= PHP_EOL . " \t \t \$ db = JFactory::getDbo(); " ;
$methods .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Create a new query object. " ;
$methods .= PHP_EOL . " \t \t \$ query = \$ db->getQuery(true); " ;
$methods .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get from " . $get [ 'selection' ][ 'table' ] . " as " . $default [ 'as' ];
$methods .= PHP_EOL . " \t \t " . $get [ 'selection' ][ 'select' ];
$methods .= PHP_EOL . " \t \t " . '$query->from(' . $get [ 'selection' ][ 'from' ] . ');' ;
2016-02-26 00:20:09 +00:00
// set the string
2017-02-01 13:17:04 +00:00
if ( $get [ 'operator' ] === 'IN' || $get [ 'operator' ] === 'NOT IN' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$methods .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Check if \$ " . $default [ 'on_field' ] . " is an array with values. " ;
$methods .= PHP_EOL . " \t \t \$ array = \$ " . $default [ 'on_field' ] . " ; " ;
$methods .= PHP_EOL . " \t \t if (isset( \$ array) && " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ array, true)) " ;
$methods .= PHP_EOL . " \t \t { " ;
$methods .= PHP_EOL . " \t \t \t \$ query->where(' " . $get [ 'join_field' ] . " " . $get [ 'operator' ] . " (' . implode(',', \$ array) . ')'); " ;
$methods .= PHP_EOL . " \t \t } " ;
$methods .= PHP_EOL . " \t \t else " ;
$methods .= PHP_EOL . " \t \t { " ;
$methods .= PHP_EOL . " \t \t \t return false; " ;
$methods .= PHP_EOL . " \t \t } " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$methods .= PHP_EOL . " \t \t \$ query->where(' " . $get [ 'join_field' ] . " " . $get [ 'operator' ] . " ' . \$ db->quote( \$ " . $default [ 'on_field' ] . " )); " ;
2016-02-26 00:20:09 +00:00
}
// check if other queries should be loaded
$queryChecker = ( isset ( $this -> otherQuery [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]]) && ComponentbuilderHelper :: checkArray ( $this -> otherQuery [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]])) ? $this -> otherQuery [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]] : '' ;
if ( ComponentbuilderHelper :: checkArray ( $queryChecker ))
{
foreach ( $queryChecker as $query )
{
$methods .= $query ;
}
}
// add any other filter that was set
if ( isset ( $this -> otherFilter [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]]) && ComponentbuilderHelper :: checkArray ( $this -> otherFilter [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]]))
{
foreach ( $this -> otherFilter [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]] as $field => $string )
{
$methods .= $string ;
}
}
// add any other where that was set
if ( isset ( $this -> otherWhere [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]]) && ComponentbuilderHelper :: checkArray ( $this -> otherWhere [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]]))
{
foreach ( $this -> otherWhere [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]] as $field => $string )
{
$methods .= $string ;
}
}
// add any other order that was set
if ( isset ( $this -> otherOrder [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]]) && ComponentbuilderHelper :: checkArray ( $this -> otherOrder [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]]))
{
foreach ( $this -> otherOrder [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]] as $field => $string )
{
$methods .= $string ;
}
}
2017-12-14 23:10:47 +00:00
$methods .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Reset the query using our newly populated query object. " ;
$methods .= PHP_EOL . " \t \t \$ db->setQuery( \$ query); " ;
$methods .= PHP_EOL . " \t \t \$ db->execute(); " ;
$methods .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " check if there was data returned " ;
$methods .= PHP_EOL . " \t \t if ( \$ db->getNumRows()) " ;
$methods .= PHP_EOL . " \t \t { " ;
2017-12-04 15:57:19 +00:00
// set dispatcher placeholder
$methods .= " ###DISPATCHER### " ;
2016-02-26 00:20:09 +00:00
// set decoding of needed fields
if ( isset ( $this -> siteFieldData [ 'decode' ][ $default [ 'code' ]][ $get [ 'key' ]][ $default [ 'as' ]]))
{
$decodeChecker = $this -> siteFieldData [ 'decode' ][ $default [ 'code' ]][ $get [ 'key' ]][ $default [ 'as' ]];
}
// also filter fields if needed
if ( isset ( $this -> siteFieldDecodeFilter [ $this -> target ][ $default [ 'code' ]][ $get [ 'key' ]][ $default [ 'as' ]]))
{
$decodeFilter = $this -> siteFieldDecodeFilter [ $this -> target ][ $default [ 'code' ]][ $get [ 'key' ]][ $default [ 'as' ]];
}
// set uikit checkers on needed fields
if ( isset ( $this -> siteFieldData [ 'uikit' ][ $default [ 'code' ]][ $get [ 'key' ]][ $default [ 'as' ]]))
{
$uikitChecker = $this -> siteFieldData [ 'uikit' ][ $default [ 'code' ]][ $get [ 'key' ]][ $default [ 'as' ]];
}
2017-12-10 19:17:26 +00:00
// set contnetprepare on needed fields
if ( isset ( $this -> siteFieldData [ 'textareas' ][ $default [ 'code' ]][ $get [ 'key' ]][ $default [ 'as' ]]))
{
$contentprepareChecker = $this -> siteFieldData [ 'textareas' ][ $default [ 'code' ]][ $get [ 'key' ]][ $default [ 'as' ]];
}
2016-02-26 00:20:09 +00:00
// set joined values
$placeholders = array ( '###TAB###' => " \t \t " , '###STRING###' => '$item' );
$joinedChecker = ( isset ( $this -> otherJoin [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]]) && ComponentbuilderHelper :: checkArray ( $this -> otherJoin [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]])) ? $this -> otherJoin [ $this -> target ][ $default [ 'code' ]][ $default [ 'as' ]] : '' ;
2017-12-14 23:10:47 +00:00
if (( isset ( $decodeChecker ) && ComponentbuilderHelper :: checkArray ( $decodeChecker )) ||
( isset ( $uikitChecker ) && ComponentbuilderHelper :: checkArray ( $uikitChecker )) ||
( isset ( $decodeFilter ) && ComponentbuilderHelper :: checkArray ( $decodeFilter )) ||
( isset ( $contentprepareChecker ) && ComponentbuilderHelper :: checkArray ( $contentprepareChecker )) ||
2016-02-26 00:20:09 +00:00
ComponentbuilderHelper :: checkArray ( $joinedChecker ))
{
$decoder = '' ;
if ( isset ( $decodeChecker ) && ComponentbuilderHelper :: checkArray ( $decodeChecker ))
{
// also filter fields if needed
2017-12-14 23:10:47 +00:00
$decoder = $this -> setCustomViewFieldDecode ( $get , $decodeChecker , '$item' , $default [ 'code' ], " \t \t " );
2016-02-26 00:20:09 +00:00
}
$decoder_filter = '' ;
if ( isset ( $decodeFilter ) && ComponentbuilderHelper :: checkArray ( $decodeFilter ))
{
2017-12-14 23:10:47 +00:00
$decoder_filter = $this -> setCustomViewFieldDecodeFilter ( $get , $decodeFilter , '$item' , '$items[$nr]' , $default [ 'code' ], " \t \t " );
2016-02-26 00:20:09 +00:00
}
2017-12-11 11:18:33 +00:00
$contentprepare = '' ;
2017-12-10 19:17:26 +00:00
if ( isset ( $contentprepareChecker ) && ComponentbuilderHelper :: checkArray ( $contentprepareChecker ))
{
2017-12-14 23:10:47 +00:00
$contentprepare = $this -> setCustomViewFieldonContentPrepareChecker ( $get , $contentprepareChecker , '$item' , $default [ 'code' ], " \t \t " );
2017-12-10 19:17:26 +00:00
}
2016-02-26 00:20:09 +00:00
$uikit = '' ;
if ( isset ( $uikitChecker ) && ComponentbuilderHelper :: checkArray ( $uikitChecker ))
{
2017-12-14 23:10:47 +00:00
$uikit = $this -> setCustomViewFieldUikitChecker ( $get , $uikitChecker , '$item' , $default [ 'code' ], " \t \t " );
2016-02-26 00:20:09 +00:00
}
$joine = '' ;
if ( ComponentbuilderHelper :: checkArray ( $joinedChecker ))
{
foreach ( $joinedChecker as $joinedString )
{
2017-02-11 02:24:26 +00:00
$joine .= $this -> setPlaceholders ( $joinedString , $placeholders );
2016-02-26 00:20:09 +00:00
}
}
2017-12-11 11:18:33 +00:00
if ( ComponentbuilderHelper :: checkString ( $decoder ) || ComponentbuilderHelper :: checkString ( $contentprepare ) || ComponentbuilderHelper :: checkString ( $uikit ) || ComponentbuilderHelper :: checkString ( $decoder_filter ) || ComponentbuilderHelper :: checkString ( $joine ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$methods .= PHP_EOL . " \t \t \t \$ items = \$ db->loadObjectList(); " ;
$methods .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Convert the parameter fields into objects. " ;
$methods .= PHP_EOL . " \t \t \t foreach ( \$ items as \$ nr => & \$ item) " ;
$methods .= PHP_EOL . " \t \t \t { " ;
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkString ( $decoder ))
{
$methods .= $decoder ;
}
if ( ComponentbuilderHelper :: checkString ( $decoder_filter ))
{
$methods .= $decoder_filter ;
}
2017-12-11 11:18:33 +00:00
if ( ComponentbuilderHelper :: checkString ( $contentprepare ))
2017-12-10 19:17:26 +00:00
{
2017-12-11 11:18:33 +00:00
$methods .= $contentprepare ;
2017-12-10 19:17:26 +00:00
}
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkString ( $uikit ))
{
$methods .= $uikit ;
}
if ( ComponentbuilderHelper :: checkString ( $joine ))
{
$methods .= $joine ;
}
2017-12-14 23:10:47 +00:00
$methods .= PHP_EOL . " \t \t \t } " ;
$methods .= PHP_EOL . " \t \t \t return \$ items; " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$methods .= PHP_EOL . " \t \t \t return \$ db->loadObjectList(); " ;
2016-02-26 00:20:09 +00:00
}
}
else
{
2017-12-14 23:10:47 +00:00
$methods .= PHP_EOL . " \t \t \t return \$ db->loadObjectList(); " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$methods .= PHP_EOL . " \t \t } " ;
$methods .= PHP_EOL . " \t \t return false; " ;
$methods .= PHP_EOL . " \t } " ;
2016-02-26 00:20:09 +00:00
if (( isset ( $this -> siteDecrypt [ 'basic' ][ $code ]) && $this -> siteDecrypt [ 'basic' ][ $code ]) || ( isset ( $this -> siteDecrypt [ 'advanced' ][ $code ]) && $this -> siteDecrypt [ 'advanced' ][ $code ]))
{
2017-12-14 23:10:47 +00:00
$Component = $this -> fileContentStatic [ '###Component###' ];
2016-02-26 00:20:09 +00:00
$script = '' ;
if ( $this -> siteDecrypt [ 'basic' ][ $code ])
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the basic encryption. " ;
$script .= PHP_EOL . " \t \t \$ basickey = " . $Component . " Helper::getCryptKey('basic'); " ;
$script .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the encryption object. " ;
$script .= PHP_EOL . " \t \t \$ basic = new FOFEncryptAes( \$ basickey, 128); " . PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
if ( $this -> siteDecrypt [ 'advanced' ][ $code ])
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the advanced encryption. " ;
$script .= PHP_EOL . " \t \t \$ advancedkey = " . $Component . " Helper::getCryptKey('advanced'); " ;
$script .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the encryption object. " ;
$script .= PHP_EOL . " \t \t \$ advanced = new FOFEncryptAes( \$ advancedkey, 256); " . PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
2017-12-04 15:57:19 +00:00
$methods = str_replace ( '###CRYPT###' , $script , $methods );
2016-02-26 00:20:09 +00:00
}
}
2017-12-04 15:57:19 +00:00
// insure the crypt placeholder is removed
2017-12-14 23:10:47 +00:00
$methods = str_replace ( '###CRYPT###' , '' , $methods );
2016-02-26 00:20:09 +00:00
}
}
2017-12-04 15:57:19 +00:00
// check if the dispatcher must be set
2017-12-14 23:10:47 +00:00
return str_replace ( array_keys ( $this -> JEventDispatcher ), array_values ( $this -> JEventDispatcher ), $methods ) . PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
public function setCustomViewMethodDefaults ( $get , $code )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$key = substr ( ComponentbuilderHelper :: safeString ( preg_replace ( '/[0-9]+/' , '' , md5 ( $get [ 'key' ])), 'F' ), 0 , 4 );
$method [ 'on_field' ] = ( isset ( $get [ 'on_field' ])) ? $this -> removeAsDot ( $get [ 'on_field' ]) : null ;
$method [ 'join_field' ] = ( isset ( $get [ 'join_field' ])) ? ComponentbuilderHelper :: safeString ( $this -> removeAsDot ( $get [ 'join_field' ])) : null ;
$method [ 'Join_field' ] = ( isset ( $method [ 'join_field' ])) ? ComponentbuilderHelper :: safeString ( $method [ 'join_field' ], 'F' ) : null ;
$method [ 'name' ] = ComponentbuilderHelper :: safeString ( $get [ 'selection' ][ 'name' ], 'F' );
2016-02-26 00:20:09 +00:00
$method [ 'code' ] = ComponentbuilderHelper :: safeString ( $code );
2017-12-14 23:10:47 +00:00
$method [ 'AS' ] = ComponentbuilderHelper :: safeString ( $get [ 'as' ], 'U' );
2016-02-26 00:20:09 +00:00
$method [ 'as' ] = ComponentbuilderHelper :: safeString ( $get [ 'as' ]);
$method [ 'valueName' ] = $method [ 'on_field' ] . $method [ 'Join_field' ] . $method [ 'name' ] . $method [ 'AS' ];
2017-12-14 23:10:47 +00:00
$method [ 'methodName' ] = ComponentbuilderHelper :: safeString ( $method [ 'on_field' ], 'F' ) . $method [ 'Join_field' ] . $method [ 'name' ] . $key . '_' . $method [ 'AS' ];
2016-02-26 00:20:09 +00:00
// return
return $method ;
}
2016-09-03 21:44:47 +00:00
public function getCustomScriptBuilder ( $first , $second , $prefix = '' , $note = null , $unset = null , $default = null , $sufix = '' )
{
2017-12-14 23:10:47 +00:00
// check if there is any custom script
$script = '' ;
2016-09-03 21:44:47 +00:00
if ( isset ( $this -> customScriptBuilder [ $first ][ $second ]) && ComponentbuilderHelper :: checkString ( $this -> customScriptBuilder [ $first ][ $second ]))
{
2017-12-14 23:10:47 +00:00
// add not if set
if ( $note )
{
$script .= $note ;
}
$script .= $prefix . str_replace ( array_keys ( $this -> placeholders ), array_values ( $this -> placeholders ), $this -> customScriptBuilder [ $first ][ $second ]) . $sufix ;
2016-09-03 21:44:47 +00:00
// clear some memory
2017-12-14 23:10:47 +00:00
if ( $unset )
{
unset ( $this -> customScriptBuilder [ $first ][ $second ]);
}
}
// if not found return default
if ( ! ComponentbuilderHelper :: checkString ( $script ) && $default )
{
return $default ;
}
return $script ;
}
2016-09-03 21:44:47 +00:00
2017-12-14 23:10:47 +00:00
public function setCustomViewListQuery ( & $get , $code , $return = true )
2016-02-26 00:20:09 +00:00
{
if ( ComponentbuilderHelper :: checkObject ( $get ))
{
if ( $get -> pagination == 1 )
{
2017-12-14 23:10:47 +00:00
$getItem = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get a db connection. " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$getItem = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Make sure all records load, since no pagination allowed. " ;
$getItem .= PHP_EOL . " \t \t \$ this->setState('list.limit', 0); " ;
$getItem .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get a db connection. " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$getItem .= PHP_EOL . " \t \t \$ db = JFactory::getDbo(); " ;
$getItem .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Create a new query object. " ;
$getItem .= PHP_EOL . " \t \t \$ query = \$ db->getQuery(true); " ;
2016-03-19 01:51:35 +00:00
// check if there is any custom script
2017-12-14 23:10:47 +00:00
$getItem .= $this -> getCustomScriptBuilder ( $this -> target . '_php_getlistquery' , $code , '' , PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Filtering. " , true );
2016-02-26 00:20:09 +00:00
// set main get query
2017-12-14 23:10:47 +00:00
$getItem .= $this -> setCustomViewQuery ( $get -> main_get , $code );
2016-02-26 00:20:09 +00:00
// setup filters
2017-12-14 23:10:47 +00:00
$getItem .= $this -> setCustomViewFilter ( $get -> filter , $code );
2016-02-26 00:20:09 +00:00
// setup where
2017-12-14 23:10:47 +00:00
$getItem .= $this -> setCustomViewWhere ( $get -> where , $code );
2016-02-26 00:20:09 +00:00
// setup ordering
2017-12-14 23:10:47 +00:00
$getItem .= $this -> setCustomViewOrder ( $get -> order , $code );
2016-02-26 00:20:09 +00:00
if ( $return )
{
// return the query object
2017-12-14 23:10:47 +00:00
$getItem .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " return the query object " . PHP_EOL . " \t \t return \$ query; " ;
2016-02-26 00:20:09 +00:00
}
return $getItem ;
}
2017-12-14 23:10:47 +00:00
return PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " add your custom code here. " ;
2016-02-26 00:20:09 +00:00
}
2016-04-22 12:03:43 +00:00
/**
* @ param $get
* @ param $code
* @ return string
2017-12-14 23:10:47 +00:00
*/
2016-04-22 12:03:43 +00:00
public function setCustomViewGetItems ( & $get , $code )
2016-02-26 00:20:09 +00:00
{
$getItem = '' ;
$this -> siteDecrypt [ 'basic' ][ $code ] = false ;
$this -> siteDecrypt [ 'advanced' ][ $code ] = false ;
2016-12-22 21:32:13 +00:00
$Component = $this -> fileContentStatic [ '###Component###' ];
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkObject ( $get ))
{
2017-12-14 23:10:47 +00:00
$getItem .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Insure all item fields are adapted where needed. " ;
$getItem .= PHP_EOL . " \t \t if ( " . $Component . " Helper::checkArray( \$ items)) " ;
$getItem .= PHP_EOL . " \t \t { " ;
2017-12-04 15:57:19 +00:00
$getItem .= " ###DISPATCHER### " ;
2017-12-14 23:10:47 +00:00
$getItem .= PHP_EOL . " \t \t \t foreach ( \$ items as \$ nr => & \$ item) " ;
$getItem .= PHP_EOL . " \t \t \t { " ;
$getItem .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Always create a slug for sef URL's " ;
$getItem .= PHP_EOL . " \t \t \t \t \$ item->slug = (isset( \$ item->alias) && isset( \$ item->id)) ? \$ item->id.':'. \$ item->alias : \$ item->id; " ;
2016-02-26 00:20:09 +00:00
if ( isset ( $get -> main_get ) && ComponentbuilderHelper :: checkArray ( $get -> main_get ))
{
$asBucket = array ();
foreach ( $get -> main_get as $main_get )
{
if ( isset ( $this -> siteFieldData [ 'decode' ][ $code ][ $main_get [ 'key' ]][ $main_get [ 'as' ]]))
{
$decodeChecker = $this -> siteFieldData [ 'decode' ][ $code ][ $main_get [ 'key' ]][ $main_get [ 'as' ]];
if ( ComponentbuilderHelper :: checkArray ( $decodeChecker ))
{
// set decoding of needed fields
2017-12-14 23:10:47 +00:00
$getItem .= $this -> setCustomViewFieldDecode ( $main_get , $decodeChecker , " \$ item " , $code , " \t \t " );
2016-02-26 00:20:09 +00:00
}
}
// also filter fields if needed
if ( isset ( $this -> siteFieldDecodeFilter [ $this -> target ][ $code ][ $main_get [ 'key' ]][ $main_get [ 'as' ]]))
{
$decodeFilter = $this -> siteFieldDecodeFilter [ $this -> target ][ $code ][ $main_get [ 'key' ]][ $main_get [ 'as' ]];
if ( ComponentbuilderHelper :: checkArray ( $decodeFilter ))
{
2017-12-14 23:10:47 +00:00
$getItem .= $this -> setCustomViewFieldDecodeFilter ( $main_get , $decodeFilter , " \$ item " , '$items[$nr]' , $code , " \t \t " );
2016-02-26 00:20:09 +00:00
}
}
2017-12-10 19:17:26 +00:00
if ( isset ( $this -> siteFieldData [ 'textareas' ][ $code ][ $main_get [ 'key' ]][ $main_get [ 'as' ]]))
{
$contentprepareChecker = $this -> siteFieldData [ 'textareas' ][ $code ][ $main_get [ 'key' ]][ $main_get [ 'as' ]];
if ( ComponentbuilderHelper :: checkArray ( $contentprepareChecker ))
{
// set contentprepare checkers on needed fields
2017-12-14 23:10:47 +00:00
$getItem .= $this -> setCustomViewFieldonContentPrepareChecker ( $main_get , $contentprepareChecker , " \$ item " , $code , " \t \t " );
2017-12-10 19:17:26 +00:00
}
}
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> siteFieldData [ 'uikit' ][ $code ][ $main_get [ 'key' ]][ $main_get [ 'as' ]]))
{
$uikitChecker = $this -> siteFieldData [ 'uikit' ][ $code ][ $main_get [ 'key' ]][ $main_get [ 'as' ]];
if ( ComponentbuilderHelper :: checkArray ( $uikitChecker ))
{
// set uikit checkers on needed fields
2017-12-14 23:10:47 +00:00
$getItem .= $this -> setCustomViewFieldUikitChecker ( $main_get , $uikitChecker , " \$ item " , $code , " \t \t " );
2016-02-26 00:20:09 +00:00
}
}
$asBucket [] = $main_get [ 'as' ];
}
}
2017-12-04 15:57:19 +00:00
// check if we should load the dispatcher
$getItem = str_replace ( array_keys ( $this -> JEventDispatcher ), array_values ( $this -> JEventDispatcher ), $getItem );
2016-02-26 00:20:09 +00:00
// setup Globals
2017-12-14 23:10:47 +00:00
$getItem .= $this -> setCustomViewGlobals ( $get -> global , '$item' , $asBucket , " \t \t " );
2016-02-26 00:20:09 +00:00
// setup the custom gets that returns multipal values
2017-12-14 23:10:47 +00:00
$getItem .= $this -> setCustomViewCustomJoin ( $get -> custom_get , " \$ item " , $code , $asBucket , " \t \t " );
2016-02-26 00:20:09 +00:00
// set calculations
if ( $get -> addcalculation == 1 )
{
2017-12-14 23:10:47 +00:00
$get -> php_calculation = ( array ) explode ( PHP_EOL , $get -> php_calculation );
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkArray ( $get -> php_calculation ))
{
2017-12-14 23:10:47 +00:00
$_tmp = PHP_EOL . " \t \t \t \t " . implode ( PHP_EOL . " \t \t \t \t " , $get -> php_calculation );
2017-02-11 02:24:26 +00:00
$getItem .= $this -> setPlaceholders ( $_tmp , $this -> placeholders );
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
$getItem .= PHP_EOL . " \t \t \t } " ;
$getItem .= PHP_EOL . " \t \t } " ;
2016-02-26 00:20:09 +00:00
// remove empty foreach
if ( strlen ( $getItem ) <= 100 )
{
2017-02-09 16:11:10 +00:00
$getItem = PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
}
if ( $this -> siteDecrypt [ 'basic' ][ $code ] || $this -> siteDecrypt [ 'advanced' ][ $code ])
{
$script = '' ;
if ( $this -> siteDecrypt [ 'basic' ][ $code ])
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the basic encryption. " ;
$script .= PHP_EOL . " \t \t \$ basickey = " . $Component . " Helper::getCryptKey('basic'); " ;
$script .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the encryption object. " ;
$script .= PHP_EOL . " \t \t \$ basic = new FOFEncryptAes( \$ basickey, 128); " ;
2016-02-26 00:20:09 +00:00
}
if ( $this -> siteDecrypt [ 'advanced' ][ $code ])
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the advanced encryption. " ;
$script .= PHP_EOL . " \t \t \$ advancedkey = " . $Component . " Helper::getCryptKey('advanced'); " ;
$script .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the encryption object. " ;
$script .= PHP_EOL . " \t \t \$ advanced = new FOFEncryptAes( \$ advancedkey, 256); " ;
2016-02-26 00:20:09 +00:00
}
$getItem = $script . $getItem ;
}
return $getItem ;
}
public function setCustomViewDisplayMethod ( & $view )
{
$method = '' ;
if ( isset ( $view [ 'settings' ] -> main_get ) && ComponentbuilderHelper :: checkObject ( $view [ 'settings' ] -> main_get ))
{
if ( $view [ 'settings' ] -> main_get -> gettype == 1 )
{
// for single views
2017-12-14 23:10:47 +00:00
$method .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Initialise variables. " ;
2017-12-15 01:10:10 +00:00
$method .= PHP_EOL . " \t \t \$ this->item = \$ this->get('Item'); " ;
2016-02-26 00:20:09 +00:00
}
elseif ( $view [ 'settings' ] -> main_get -> gettype == 2 )
{
// for list views
2017-12-14 23:10:47 +00:00
$method .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Initialise variables. " ;
2017-12-15 01:10:10 +00:00
$method .= PHP_EOL . " \t \t \$ this->items = \$ this->get('Items'); " ;
2016-02-26 00:20:09 +00:00
// only add if pagination is requered
if ( $view [ 'settings' ] -> main_get -> pagination == 1 )
{
2017-12-15 01:10:10 +00:00
$method .= PHP_EOL . " \t \t \$ this->pagination = \$ this->get('Pagination'); " ;
2016-02-26 00:20:09 +00:00
}
// add id to list view
if ( isset ( $this -> customAdminViewListId [ $view [ 'settings' ] -> code ]))
{
// ###HIDDEN_INPUT_VALUES###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $view [ 'settings' ] -> code ][ '###HIDDEN_INPUT_VALUES###' ] = PHP_EOL . " \t " . '<input type="hidden" name="id" value="<?php echo $this->app->input->getInt(\'id\', 0); ?>" />' ;
2016-02-26 00:20:09 +00:00
}
else
{
// also set the input value ###HIDDEN_INPUT_VALUES###
$this -> fileContentDynamic [ $view [ 'settings' ] -> code ][ '###HIDDEN_INPUT_VALUES###' ] = '' ;
}
}
// add the custom get methods
if ( isset ( $view [ 'settings' ] -> custom_get ) && ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> custom_get ))
{
foreach ( $view [ 'settings' ] -> custom_get as $custom_get )
{
2017-12-14 23:10:47 +00:00
$custom_get_name = str_replace ( 'get' , '' , $custom_get -> getcustom );
2017-12-15 01:10:10 +00:00
$method .= PHP_EOL . " \t \t \$ this-> " . ComponentbuilderHelper :: safeString ( $custom_get_name ) . " = \$ this->get(' " . $custom_get_name . " '); " ;
2016-02-26 00:20:09 +00:00
}
}
// add custom script
if ( $view [ 'settings' ] -> add_php_jview_display == 1 )
{
2017-12-14 23:10:47 +00:00
$view [ 'settings' ] -> php_jview_display = ( array ) explode ( PHP_EOL , $view [ 'settings' ] -> php_jview_display );
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> php_jview_display ))
{
2017-12-14 23:10:47 +00:00
$_tmp = PHP_EOL . " \t \t " . implode ( PHP_EOL . " \t \t " , $view [ 'settings' ] -> php_jview_display );
2017-02-11 02:24:26 +00:00
$method .= $this -> setPlaceholders ( $_tmp , $this -> placeholders );
2016-02-26 00:20:09 +00:00
}
}
2017-02-02 11:54:07 +00:00
if ( 'site' === $this -> target )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$method .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Set the toolbar " ;
$method .= PHP_EOL . " \t \t \$ this->addToolBar(); " ;
$method .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " set the document " ;
$method .= PHP_EOL . " \t \t \$ this->_prepareDocument(); " ;
2016-02-26 00:20:09 +00:00
}
2017-02-02 11:54:07 +00:00
elseif ( 'custom_admin' === $this -> target )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$method .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " We don't need toolbar in the modal window. " ;
$method .= PHP_EOL . " \t \t if ( \$ this->getLayout() !== 'modal') " ;
$method .= PHP_EOL . " \t \t { " ;
$method .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " add the tool bar " ;
$method .= PHP_EOL . " \t \t \t \$ this->addToolBar(); " ;
$method .= PHP_EOL . " \t \t } " ;
$method .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " set the document " ;
$method .= PHP_EOL . " \t \t \$ this->setDocument(); " ;
2016-02-26 00:20:09 +00:00
}
2017-10-14 17:18:29 +00:00
2017-12-14 23:10:47 +00:00
$method .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Check for errors. " ;
$method .= PHP_EOL . " \t \t if (count( \$ errors = \$ this->get('Errors'))) " ;
$method .= PHP_EOL . " \t \t { " ;
$method .= PHP_EOL . " \t \t \t throw new Exception(implode( " . '"\n", $errors), 500);' ;
$method .= PHP_EOL . " \t \t } " ;
$method .= PHP_EOL . PHP_EOL . " \t \t parent::display( \$ tpl); " ;
2016-02-26 00:20:09 +00:00
}
return $method ;
}
2016-09-11 15:27:04 +00:00
public function setPrepareDocument ( & $view )
2016-02-26 00:20:09 +00:00
{
// ensure correct target is set
2017-12-14 23:10:47 +00:00
$TARGET = ComponentbuilderHelper :: safeString ( $this -> target , 'U' );
2017-12-10 19:17:26 +00:00
// set libraries ###'.$TARGET.'_LIBRARIES_LOADER###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $view [ 'settings' ] -> code ][ '###' . $TARGET . '_LIBRARIES_LOADER###' ] = $this -> setLibrariesLoader ( $view );
2016-02-26 00:20:09 +00:00
// set uikit ###'.$TARGET.'_UIKIT_LOADER###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $view [ 'settings' ] -> code ][ '###' . $TARGET . '_UIKIT_LOADER###' ] = $this -> setUikitLoader ( $view );
2016-02-26 00:20:09 +00:00
2017-11-11 04:33:51 +00:00
// set Google Charts ###'.$TARGET.'_GOOGLECHART_LOADER###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $view [ 'settings' ] -> code ][ '###' . $TARGET . '_GOOGLECHART_LOADER###' ] = $this -> setGoogleChartLoader ( $view );
2016-02-26 00:20:09 +00:00
2017-11-11 04:33:51 +00:00
// set Footable ###FOOTABLE_LOADER###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $view [ 'settings' ] -> code ][ '###' . $TARGET . '_FOOTABLE_LOADER###' ] = $this -> setFootableScriptsLoader ( $view );
2016-02-26 00:20:09 +00:00
// set metadata ###DOCUMENT_METADATA###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $view [ 'settings' ] -> code ][ '###' . $TARGET . '_DOCUMENT_METADATA###' ] = $this -> setDocumentMetadata ( $view );
2016-02-26 00:20:09 +00:00
// set custom php scripting ###DOCUMENT_CUSTOM_PHP###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $view [ 'settings' ] -> code ][ '###' . $TARGET . '_DOCUMENT_CUSTOM_PHP###' ] = $this -> setDocumentCustomPHP ( $view );
2016-02-26 00:20:09 +00:00
// set custom css ###DOCUMENT_CUSTOM_CSS###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $view [ 'settings' ] -> code ][ '###' . $TARGET . '_DOCUMENT_CUSTOM_CSS###' ] = $this -> setDocumentCustomCSS ( $view );
2016-02-26 00:20:09 +00:00
// set custom javascript ###DOCUMENT_CUSTOM_JS###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $view [ 'settings' ] -> code ][ '###' . $TARGET . '_DOCUMENT_CUSTOM_JS###' ] = $this -> setDocumentCustomJS ( $view );
2016-02-26 00:20:09 +00:00
// set custom css file ###VIEWCSS###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $view [ 'settings' ] -> code ][ '###' . $TARGET . '_VIEWCSS###' ] = $this -> setCustomCSS ( $view );
2016-02-26 00:20:09 +00:00
// set the custom buttons ###CUSTOM_BUTTONS###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $view [ 'settings' ] -> code ][ '###' . $TARGET . '_CUSTOM_BUTTONS###' ] = $this -> setCustomButtons ( $view );
2016-02-26 00:20:09 +00:00
// only set the custom get form method if site target
2017-02-02 11:54:07 +00:00
if ( 'site' === $this -> target )
2016-02-26 00:20:09 +00:00
{
// set the custom get form method ###SITE_CUSTOM_GET_FORM_METHOD###
$this -> fileContentDynamic [ $view [ 'settings' ] -> code ][ '###SITE_CUSTOM_GET_FORM_METHOD###' ] = $this -> setCustomGetForm ( $view );
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
// see if we should add get modules to the view.html
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $view [ 'settings' ] -> code ][ '###' . $TARGET . '_GET_MODULE###' ] = $this -> setGetModules ( $view , $TARGET );
// set a JavaScript file if needed
$this -> fileContentDynamic [ $view [ 'settings' ] -> code ][ '###' . $TARGET . '_LIBRARIES_LOADER###' ] .= $this -> setJavaScriptFile ( $view , $TARGET );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
public function setGetModules ( $view , $TARGET )
2016-02-26 00:20:09 +00:00
{
if ( isset ( $this -> getModule [ $this -> target ][ $view [ 'settings' ] -> code ]) && $this -> getModule [ $this -> target ][ $view [ 'settings' ] -> code ])
{
$addModule = array ();
2017-12-14 23:10:47 +00:00
$addModule [] = PHP_EOL . PHP_EOL . " \t /** " ;
2016-02-26 00:20:09 +00:00
$addModule [] = " \t * Get the modules published in a position " ;
$addModule [] = " \t */ " ;
$addModule [] = " \t public function getModules( \$ position, \$ seperator = '', \$ class = '') " ;
$addModule [] = " \t { " ;
2017-12-14 23:10:47 +00:00
$addModule [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " set default " ;
2016-02-26 00:20:09 +00:00
$addModule [] = " \t \t \$ found = false; " ;
2017-12-14 23:10:47 +00:00
$addModule [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " check if we aleady have these modules loaded " ;
2016-02-26 00:20:09 +00:00
$addModule [] = " \t \t if (isset( \$ this->setModules[ \$ position])) " ;
$addModule [] = " \t \t { " ;
$addModule [] = " \t \t \t \$ found = true; " ;
$addModule [] = " \t \t } " ;
$addModule [] = " \t \t else " ;
$addModule [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$addModule [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " this is where you want to load your module position " ;
2016-02-26 00:20:09 +00:00
$addModule [] = " \t \t \t \$ modules = JModuleHelper::getModules( \$ position); " ;
$addModule [] = " \t \t \t if ( \$ modules) " ;
$addModule [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$addModule [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " set the place holder " ;
2016-02-26 00:20:09 +00:00
$addModule [] = " \t \t \t \t \$ this->setModules[ \$ position] = array(); " ;
$addModule [] = " \t \t \t \t foreach( \$ modules as \$ module) " ;
$addModule [] = " \t \t \t \t { " ;
$addModule [] = " \t \t \t \t \t \$ this->setModules[ \$ position][] = JModuleHelper::renderModule( \$ module); " ;
$addModule [] = " \t \t \t \t } " ;
$addModule [] = " \t \t \t \t \$ found = true; " ;
$addModule [] = " \t \t \t } " ;
$addModule [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$addModule [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " check if modules were found " ;
$addModule [] = " \t \t if ( \$ found && isset( \$ this->setModules[ \$ position]) && " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ this->setModules[ \$ position])) " ;
2016-02-26 00:20:09 +00:00
$addModule [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$addModule [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " set class " ;
$addModule [] = " \t \t \t if ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkString( \$ class)) " ;
2016-02-26 00:20:09 +00:00
$addModule [] = " \t \t \t { " ;
$addModule [] = " \t \t \t \t \$ class = ' class= \" '. \$ class.' \" '; " ;
$addModule [] = " \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$addModule [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " set seperating return values " ;
2016-02-26 00:20:09 +00:00
$addModule [] = " \t \t \t switch( \$ seperator) " ;
$addModule [] = " \t \t \t { " ;
$addModule [] = " \t \t \t \t case 'none': " ;
$addModule [] = " \t \t \t \t \t return implode('', \$ this->setModules[ \$ position]); " ;
$addModule [] = " \t \t \t \t \t break; " ;
$addModule [] = " \t \t \t \t case 'div': " ;
$addModule [] = " \t \t \t \t \t return '<div'. \$ class.'>'.implode('</div><div'. \$ class.'>', \$ this->setModules[ \$ position]).'</div>'; " ;
$addModule [] = " \t \t \t \t \t break; " ;
$addModule [] = " \t \t \t \t case 'list': " ;
$addModule [] = " \t \t \t \t \t return '<ul'. \$ class.'><li>'.implode('</li><li>', \$ this->setModules[ \$ position]).'</li></ul>'; " ;
$addModule [] = " \t \t \t \t \t break; " ;
$addModule [] = " \t \t \t \t case 'array': " ;
$addModule [] = " \t \t \t \t case 'Array': " ;
$addModule [] = " \t \t \t \t \t return \$ this->setModules[ \$ position]; " ;
$addModule [] = " \t \t \t \t \t break; " ;
$addModule [] = " \t \t \t \t default: " ;
$addModule [] = " \t \t \t \t \t return implode('<br />', \$ this->setModules[ \$ position]); " ;
$addModule [] = " \t \t \t \t \t break; " ;
$addModule [] = " \t \t \t \t " ;
$addModule [] = " \t \t \t } " ;
$addModule [] = " \t \t } " ;
$addModule [] = " \t \t return false; " ;
$addModule [] = " \t } " ;
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $view [ 'settings' ] -> code ][ '###' . $TARGET . '_GET_MODULE_JIMPORT###' ] = PHP_EOL . " jimport('joomla.application.module.helper'); " ;
return implode ( PHP_EOL , $addModule );
}
$this -> fileContentDynamic [ $view [ 'settings' ] -> code ][ '###' . $TARGET . '_GET_MODULE_JIMPORT###' ] = '' ;
2016-02-26 00:20:09 +00:00
return '' ;
}
2016-09-11 15:27:04 +00:00
public function setCustomGetForm ( & $view )
2016-02-26 00:20:09 +00:00
{
return '' ;
}
2016-09-11 15:27:04 +00:00
public function setDocumentCustomPHP ( & $view )
2016-02-26 00:20:09 +00:00
{
if ( $view [ 'settings' ] -> add_php_document == 1 )
{
2017-12-14 23:10:47 +00:00
$view [ 'settings' ] -> php_document = ( array ) explode ( PHP_EOL , $view [ 'settings' ] -> php_document );
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> php_document ))
{
2017-12-14 23:10:47 +00:00
$_tmp = PHP_EOL . " \t \t " . implode ( PHP_EOL . " \t \t " , $view [ 'settings' ] -> php_document );
2017-02-11 02:24:26 +00:00
return $this -> setPlaceholders ( $_tmp , $this -> placeholders );
2016-02-26 00:20:09 +00:00
}
}
return '' ;
}
2016-09-11 15:27:04 +00:00
public function setCustomButtons ( & $view , $type = 1 , $tab = '' )
2016-02-26 00:20:09 +00:00
{
// ensure correct target is set
2017-12-14 23:10:47 +00:00
$TARGET = ComponentbuilderHelper :: safeString ( $this -> target , 'U' );
2017-03-02 00:55:04 +00:00
if ( 1 == $type || 2 == $type )
{
if ( 1 == $type )
{
2017-12-14 23:10:47 +00:00
$viewName = $view [ 'settings' ] -> code ;
2017-03-02 00:55:04 +00:00
}
if ( 2 == $type )
{
2017-12-14 23:10:47 +00:00
$viewName = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_single );
2017-03-02 00:55:04 +00:00
}
// set the custom buttons ###CUSTOM_BUTTONS_CONTROLLER###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $viewName ][ '###' . $TARGET . '_CUSTOM_BUTTONS_CONTROLLER###' ] = '' ;
2017-03-02 00:55:04 +00:00
// set the custom buttons ###CUSTOM_BUTTONS_METHOD###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $viewName ][ '###' . $TARGET . '_CUSTOM_BUTTONS_METHOD###' ] = '' ;
2017-03-02 00:55:04 +00:00
}
elseif ( 3 == $type )
{
// set the names
$viewName = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_single );
$viewsName = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_list );
// set the custom buttons ###CUSTOM_BUTTONS_CONTROLLER_LIST###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $viewsName ][ '###' . $TARGET . '_CUSTOM_BUTTONS_CONTROLLER_LIST###' ] = '' ;
2017-03-02 00:55:04 +00:00
// set the custom buttons ###CUSTOM_BUTTONS_METHOD_LIST###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $viewsName ][ '###' . $TARGET . '_CUSTOM_BUTTONS_METHOD_LIST###' ] = '' ;
2017-03-02 00:55:04 +00:00
}
2016-02-26 00:20:09 +00:00
// if site add buttons to view
2017-02-01 13:17:04 +00:00
if ( $this -> target === 'site' )
2016-02-26 00:20:09 +00:00
{
// set the custom buttons ###SITE_TOP_BUTTON###
2016-09-11 15:27:04 +00:00
$this -> fileContentDynamic [ $viewName ][ '###SITE_TOP_BUTTON###' ] = '' ;
2016-02-26 00:20:09 +00:00
// set the custom buttons ###SITE_BOTTOM_BUTTON###
2016-09-11 15:27:04 +00:00
$this -> fileContentDynamic [ $viewName ][ '###SITE_BOTTOM_BUTTON###' ] = '' ;
2016-02-26 00:20:09 +00:00
// load into place
switch ( $view [ 'settings' ] -> button_position )
{
case 1 :
// set buttons to top right of the view
2016-09-11 15:27:04 +00:00
$this -> fileContentDynamic [ $viewName ][ '###SITE_TOP_BUTTON###' ] = '<div class="uk-clearfix"><div class="uk-float-right"><?php echo $this->toolbar->render(); ?></div></div>' ;
2016-02-26 00:20:09 +00:00
break ;
case 2 :
// set buttons to top left of the view
2016-09-11 15:27:04 +00:00
$this -> fileContentDynamic [ $viewName ][ '###SITE_TOP_BUTTON###' ] = '<?php echo $this->toolbar->render(); ?>' ;
2016-02-26 00:20:09 +00:00
break ;
case 3 :
// set buttons to buttom right of the view
2016-09-11 15:27:04 +00:00
$this -> fileContentDynamic [ $viewName ][ '###SITE_BOTTOM_BUTTON###' ] = '<div class="uk-clearfix"><div class="uk-float-right"><?php echo $this->toolbar->render(); ?></div></div>' ;
2016-02-26 00:20:09 +00:00
break ;
case 4 :
// set buttons to buttom left of the view
2016-09-11 15:27:04 +00:00
$this -> fileContentDynamic [ $viewName ][ '###SITE_BOTTOM_BUTTON###' ] = '<?php echo $this->toolbar->render(); ?>' ;
2016-02-26 00:20:09 +00:00
break ;
case 5 :
// set buttons to buttom left of the view
$this -> placeholders [ '[[[SITE_TOOLBAR]]]' ] = '<?php echo $this->toolbar->render(); ?>' ;
2017-12-14 23:10:47 +00:00
break ;
2016-02-26 00:20:09 +00:00
}
}
// check if custom button should be added
if ( isset ( $view [ 'settings' ] -> add_custom_button ) && $view [ 'settings' ] -> add_custom_button == 1 )
{
2017-03-02 00:55:04 +00:00
$buttons = array ();
2017-07-20 23:26:48 +00:00
$this -> onlyFunctionButton = array ();
2017-03-02 00:55:04 +00:00
$functionNames = array ();
2017-02-09 16:11:10 +00:00
if ( isset ( $view [ 'settings' ] -> custom_buttons ) && ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> custom_buttons ))
2016-02-26 00:20:09 +00:00
{
foreach ( $view [ 'settings' ] -> custom_buttons as $custom_button )
{
2017-08-12 11:47:25 +00:00
if ( 3 !== $type && ( $custom_button [ 'target' ] != 2 || $this -> target === 'site' ))
2016-02-26 00:20:09 +00:00
{
// Load to lang
2017-12-14 23:10:47 +00:00
$keyLang = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( $custom_button [ 'name' ], 'U' );
$keyCode = ComponentbuilderHelper :: safeString ( $custom_button [ 'name' ]);
2016-02-26 00:20:09 +00:00
$this -> langContent [ $this -> lang ][ $keyLang ] = trim ( $custom_button [ 'name' ]);
2016-10-23 22:48:26 +00:00
// add cpanel button TODO does not work well on site with permissions
2017-03-08 04:49:54 +00:00
if ( $custom_button [ 'target' ] == 2 )
{
2017-12-14 23:10:47 +00:00
$buttons [] = " \t " . $tab . " \t if ( \$ this->user->authorise(' " . $viewName . " . " . $keyCode . " ')) " ;
2017-03-08 04:49:54 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$buttons [] = " \t " . $tab . " \t if ( \$ this->canDo->get(' " . $viewName . " . " . $keyCode . " ')) " ;
2017-03-08 04:49:54 +00:00
}
2017-12-14 23:10:47 +00:00
$buttons [] = " \t " . $tab . " \t { " ;
$buttons [] = " \t " . $tab . " \t \t // " . $this -> setLine ( __LINE__ ) . " add " . $custom_button [ 'name' ] . " button. " ;
$buttons [] = " \t " . $tab . " \t \t JToolBarHelper::custom(' " . $viewName . " . " . $custom_button [ 'method' ] . " ', ' " . $custom_button [ 'icomoon' ] . " ', '', ' " . $keyLang . " ', false); " ;
$buttons [] = " \t " . $tab . " \t } " ;
2016-02-26 00:20:09 +00:00
}
2017-03-02 00:55:04 +00:00
// load the list button
2017-08-12 11:47:25 +00:00
elseif ( 3 == $type && $custom_button [ 'target' ] != 1 )
2017-03-02 00:55:04 +00:00
{
// Load to lang
2017-12-14 23:10:47 +00:00
$keyLang = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( $custom_button [ 'name' ], 'U' );
$keyCode = ComponentbuilderHelper :: safeString ( $custom_button [ 'name' ]);
2017-03-02 00:55:04 +00:00
$this -> langContent [ $this -> lang ][ $keyLang ] = trim ( $custom_button [ 'name' ]);
// add cpanel button TODO does not work well on site with permissions
2017-07-20 23:26:48 +00:00
if ( isset ( $custom_button [ 'type' ]) && $custom_button [ 'type' ] == 2 )
{
2017-08-22 22:44:53 +00:00
if ( ! isset ( $this -> onlyFunctionButton [ $viewsName ]))
{
$this -> onlyFunctionButton [ $viewsName ] = array ();
}
2017-12-14 23:10:47 +00:00
$this -> onlyFunctionButton [ $viewsName ][] = " \t " . $tab . " if ( \$ this->user->authorise(' " . $viewName . " . " . $keyCode . " ', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " ')) " ;
$this -> onlyFunctionButton [ $viewsName ][] = " \t " . $tab . " { " ;
$this -> onlyFunctionButton [ $viewsName ][] = " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " add " . $custom_button [ 'name' ] . " button. " ;
$this -> onlyFunctionButton [ $viewsName ][] = " \t " . $tab . " \t JToolBarHelper::custom(' " . $viewsName . " . " . $custom_button [ 'method' ] . " ', ' " . $custom_button [ 'icomoon' ] . " ', '', ' " . $keyLang . " ', false); " ;
$this -> onlyFunctionButton [ $viewsName ][] = " \t " . $tab . " } " ;
2017-07-20 23:26:48 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$buttons [] = " \t " . $tab . " \t if ( \$ this->user->authorise(' " . $viewName . " . " . $keyCode . " ', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " ')) " ;
$buttons [] = " \t " . $tab . " \t { " ;
$buttons [] = " \t " . $tab . " \t \t // " . $this -> setLine ( __LINE__ ) . " add " . $custom_button [ 'name' ] . " button. " ;
$buttons [] = " \t " . $tab . " \t \t JToolBarHelper::custom(' " . $viewsName . " . " . $custom_button [ 'method' ] . " ', ' " . $custom_button [ 'icomoon' ] . " ', '', ' " . $keyLang . " ', false); " ;
$buttons [] = " \t " . $tab . " \t } " ;
2017-07-20 23:26:48 +00:00
}
2017-03-02 00:55:04 +00:00
}
}
}
// load the model and controller
if ( 3 == $type )
{
// insure the controller and model strings are added
if ( isset ( $view [ 'settings' ] -> php_controller_list ) && ComponentbuilderHelper :: checkString ( $view [ 'settings' ] -> php_controller_list ) && $view [ 'settings' ] -> php_controller_list != '//' )
{
// set the custom buttons ###CUSTOM_BUTTONS_CONTROLLER###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $viewsName ][ '###' . $TARGET . '_CUSTOM_BUTTONS_CONTROLLER_LIST###' ] = PHP_EOL . PHP_EOL . $this -> setPlaceholders ( $view [ 'settings' ] -> php_controller_list , $this -> placeholders );
2016-02-26 00:20:09 +00:00
}
2017-03-02 00:55:04 +00:00
// load the model
if ( isset ( $view [ 'settings' ] -> php_model_list ) && ComponentbuilderHelper :: checkString ( $view [ 'settings' ] -> php_model_list ) && $view [ 'settings' ] -> php_model_list != '//' )
2016-02-26 00:20:09 +00:00
{
2017-03-02 00:55:04 +00:00
// set the custom buttons ###CUSTOM_BUTTONS_METHOD###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $viewsName ][ '###' . $TARGET . '_CUSTOM_BUTTONS_METHOD_LIST###' ] = PHP_EOL . PHP_EOL . $this -> setPlaceholders ( $view [ 'settings' ] -> php_model_list , $this -> placeholders );
2016-02-26 00:20:09 +00:00
}
}
2017-03-02 00:55:04 +00:00
else
{
// insure the controller and model strings are added
if ( ComponentbuilderHelper :: checkString ( $view [ 'settings' ] -> php_controller ) && $view [ 'settings' ] -> php_controller != '//' )
{
// set the custom buttons ###CUSTOM_BUTTONS_CONTROLLER###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $viewName ][ '###' . $TARGET . '_CUSTOM_BUTTONS_CONTROLLER###' ] = PHP_EOL . PHP_EOL . $this -> setPlaceholders ( $view [ 'settings' ] -> php_controller , $this -> placeholders );
2017-03-02 00:55:04 +00:00
if ( 'site' === $this -> target )
{
// add the controller for this view
// build the file
$target = array ( $this -> target => $viewName );
2017-12-14 23:10:47 +00:00
$this -> buildDynamique ( $target , 'custom_form' );
2017-03-02 00:55:04 +00:00
###GET_FORM_CUSTOM###
}
}
// load the model
if ( ComponentbuilderHelper :: checkString ( $view [ 'settings' ] -> php_model ) && $view [ 'settings' ] -> php_model != '//' )
{
// set the custom buttons ###CUSTOM_BUTTONS_METHOD###
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $viewName ][ '###' . $TARGET . '_CUSTOM_BUTTONS_METHOD###' ] = PHP_EOL . PHP_EOL . $this -> setPlaceholders ( $view [ 'settings' ] -> php_model , $this -> placeholders );
2017-03-02 00:55:04 +00:00
}
}
// return buttons if they were build
if ( ComponentbuilderHelper :: checkArray ( $buttons ))
{
2017-12-14 23:10:47 +00:00
return PHP_EOL . implode ( PHP_EOL , $buttons );
2017-03-02 00:55:04 +00:00
}
2016-02-26 00:20:09 +00:00
}
return '' ;
}
2017-08-22 22:44:53 +00:00
public function setFunctionOnlyButtons ( $viewName_list )
2017-07-20 23:26:48 +00:00
{
// return buttons if they were build
2017-08-22 22:44:53 +00:00
if ( isset ( $this -> onlyFunctionButton [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> onlyFunctionButton [ $viewName_list ]))
2017-07-20 23:26:48 +00:00
{
2017-12-14 23:10:47 +00:00
return PHP_EOL . implode ( PHP_EOL , $this -> onlyFunctionButton [ $viewName_list ]);
2017-07-20 23:26:48 +00:00
}
return '' ;
}
2016-09-11 15:27:04 +00:00
public function setCustomCSS ( & $view )
2016-02-26 00:20:09 +00:00
{
if ( $view [ 'settings' ] -> add_css == 1 )
{
if ( ComponentbuilderHelper :: checkString ( $view [ 'settings' ] -> css ))
{
2017-02-11 02:24:26 +00:00
return $this -> setPlaceholders ( $view [ 'settings' ] -> css , $this -> placeholders );
2016-02-26 00:20:09 +00:00
}
}
return '' ;
}
2016-09-11 15:27:04 +00:00
public function setDocumentCustomCSS ( & $view )
2016-02-26 00:20:09 +00:00
{
if ( $view [ 'settings' ] -> add_css_document == 1 )
{
2017-12-14 23:10:47 +00:00
$view [ 'settings' ] -> css_document = ( array ) explode ( PHP_EOL , $view [ 'settings' ] -> css_document );
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> css_document ))
{
2017-12-14 23:10:47 +00:00
$script = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Set the Custom CSS script to view " . PHP_EOL . " \t \t " . '$this->document->addStyleDeclaration("' ;
$cssDocument = PHP_EOL . " \t \t \t " . str_replace ( '"' , '\"' , implode ( PHP_EOL . " \t \t \t " , $view [ 'settings' ] -> css_document ));
return $script . $this -> setPlaceholders ( $cssDocument , $this -> placeholders ) . PHP_EOL . " \t \t " . '");' ;
}
}
return '' ;
}
public function setJavaScriptFile ( & $view , $TARGET )
{
if ( $view [ 'settings' ] -> add_javascript_file == 1 && ComponentbuilderHelper :: checkString ( $view [ 'settings' ] -> javascript_file ))
{
// get dates
$created = $this -> getCreatedDate ( $view );
$modified = $this -> getLastModifiedDate ( $view );
// add file to view
$target = array ( $this -> target => $view [ 'settings' ] -> code );
$config = array ( '###CREATIONDATE###' => $created , '###BUILDDATE###' => $modified , '###VERSION###' => $view [ 'settings' ] -> version );
$this -> buildDynamique ( $target , 'javascript_file' , false , $config );
// set path
if ( 'site' === $this -> target )
{
$path = '/components/com_' . $this -> fileContentStatic [ '###component###' ] . '/assets/js/' . $view [ 'settings' ] -> code . '.js' ;
}
else
{
$path = '/administrator/components/com_' . $this -> fileContentStatic [ '###component###' ] . '/assets/js/' . $view [ 'settings' ] -> code . '.js' ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
// add script to file
2017-12-29 11:20:14 +00:00
$this -> fileContentDynamic [ $view [ 'settings' ] -> code ][ '###' . $TARGET . '_JAVASCRIPT_FILE###' ]
= $this -> setPlaceholders ( $view [ 'settings' ] -> javascript_file , $this -> placeholders );
2017-12-14 23:10:47 +00:00
// add script to view
2017-12-17 09:07:51 +00:00
return PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Add View JavaScript File " . PHP_EOL . " \t \t " . $this -> setIncludeLibScript ( $path );
2016-02-26 00:20:09 +00:00
}
return '' ;
}
2016-09-11 15:27:04 +00:00
public function setDocumentCustomJS ( & $view )
2016-02-26 00:20:09 +00:00
{
if ( $view [ 'settings' ] -> add_js_document == 1 )
{
2017-12-14 23:10:47 +00:00
$view [ 'settings' ] -> js_document = ( array ) explode ( PHP_EOL , $view [ 'settings' ] -> js_document );
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> js_document ))
{
2017-12-14 23:10:47 +00:00
$script = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Set the Custom JS script to view " . PHP_EOL . " \t \t " . '$this->document->addScriptDeclaration("' ;
$jsDocument = PHP_EOL . " \t \t \t " . str_replace ( '"' , '\"' , implode ( PHP_EOL . " \t \t \t " , $view [ 'settings' ] -> js_document ));
return $script . $this -> setPlaceholders ( $jsDocument , $this -> placeholders ) . PHP_EOL . " \t \t " . '");' ;
2016-02-26 00:20:09 +00:00
}
}
return '' ;
}
2016-09-11 15:27:04 +00:00
public function setFootableScriptsLoader ( & $view )
2016-02-26 00:20:09 +00:00
{
if ( isset ( $this -> footableScripts [ $this -> target ][ $view [ 'settings' ] -> code ]) && $this -> footableScripts [ $this -> target ][ $view [ 'settings' ] -> code ])
{
2017-12-10 19:17:26 +00:00
return $this -> setFootableScripts ( false );
2016-02-26 00:20:09 +00:00
}
return '' ;
}
2016-09-11 15:27:04 +00:00
public function setDocumentMetadata ( & $view )
2016-02-26 00:20:09 +00:00
{
2017-10-30 13:08:02 +00:00
if ( $view [ 'settings' ] -> main_get -> gettype == 1 && isset ( $view [ 'metadata' ]) && $view [ 'metadata' ] == 1 )
2016-02-26 00:20:09 +00:00
{
return $this -> setMetadataItem ();
}
2017-10-30 13:08:02 +00:00
elseif ( isset ( $view [ 'metadata' ]) && $view [ 'metadata' ] == 1 )
2016-02-26 00:20:09 +00:00
{
// lets check if we have a custom get method that has the same name as the view
// if we do then it posibly can be that the metadata is loaded via that method
// and we can load the full metadata structure with its vars
if ( isset ( $view [ 'settings' ] -> custom_get ) && ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> custom_get ))
{
$found = false ;
2017-12-14 23:10:47 +00:00
$searchFor = 'get' . $view [ 'settings' ] -> Code ;
2016-02-26 00:20:09 +00:00
foreach ( $view [ 'settings' ] -> custom_get as $custom_get )
{
if ( $searchFor == $custom_get -> getcustom )
{
$found = true ;
break ;
}
}
// now lets see
if ( $found )
{
return $this -> setMetadataItem ( $view [ 'settings' ] -> code );
}
else
{
return $this -> setMetadataList ();
}
}
else
{
return $this -> setMetadataList ();
}
}
return '' ;
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
public function setMetadataItem ( $item = 'item' )
{
$meta = array ();
2017-12-14 23:10:47 +00:00
$meta [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " load the meta description " ;
$meta [] = " \t \t if (isset( \$ this-> " . $item . " ->metadesc) && \$ this-> " . $item . " ->metadesc) " ;
2016-02-26 00:20:09 +00:00
$meta [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$meta [] = " \t \t \t \$ this->document->setDescription( \$ this-> " . $item . " ->metadesc); " ;
2016-02-26 00:20:09 +00:00
$meta [] = " \t \t } " ;
$meta [] = " \t \t elseif ( \$ this->params->get('menu-meta_description')) " ;
$meta [] = " \t \t { " ;
$meta [] = " \t \t \t \$ this->document->setDescription( \$ this->params->get('menu-meta_description')); " ;
$meta [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$meta [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " load the key words if set " ;
$meta [] = " \t \t if (isset( \$ this-> " . $item . " ->metakey) && \$ this-> " . $item . " ->metakey) " ;
2016-02-26 00:20:09 +00:00
$meta [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$meta [] = " \t \t \t \$ this->document->setMetadata('keywords', \$ this-> " . $item . " ->metakey); " ;
2016-02-26 00:20:09 +00:00
$meta [] = " \t \t } " ;
$meta [] = " \t \t elseif ( \$ this->params->get('menu-meta_keywords')) " ;
$meta [] = " \t \t { " ;
$meta [] = " \t \t \t \$ this->document->setMetadata('keywords', \$ this->params->get('menu-meta_keywords')); " ;
$meta [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$meta [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " check the robot params " ;
$meta [] = " \t \t if (isset( \$ this-> " . $item . " ->robots) && \$ this-> " . $item . " ->robots) " ;
2016-02-26 00:20:09 +00:00
$meta [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$meta [] = " \t \t \t \$ this->document->setMetadata('robots', \$ this-> " . $item . " ->robots); " ;
2016-02-26 00:20:09 +00:00
$meta [] = " \t \t } " ;
$meta [] = " \t \t elseif ( \$ this->params->get('robots')) " ;
$meta [] = " \t \t { " ;
$meta [] = " \t \t \t \$ this->document->setMetadata('robots', \$ this->params->get('robots')); " ;
$meta [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$meta [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " check if autor is to be set " ;
$meta [] = " \t \t if (isset( \$ this-> " . $item . " ->created_by) && \$ this->params->get('MetaAuthor') == '1') " ;
2016-02-26 00:20:09 +00:00
$meta [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$meta [] = " \t \t \t \$ this->document->setMetaData('author', \$ this-> " . $item . " ->created_by); " ;
2016-02-26 00:20:09 +00:00
$meta [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$meta [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " check if metadata is available " ;
$meta [] = " \t \t if (isset( \$ this-> " . $item . " ->metadata) && \$ this-> " . $item . " ->metadata) " ;
2016-02-26 00:20:09 +00:00
$meta [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$meta [] = " \t \t \t \$ mdata = json_decode( \$ this-> " . $item . " ->metadata,true); " ;
2016-02-26 00:20:09 +00:00
$meta [] = " \t \t \t foreach ( \$ mdata as \$ k => \$ v) " ;
$meta [] = " \t \t \t { " ;
$meta [] = " \t \t \t \t if ( \$ v) " ;
$meta [] = " \t \t \t \t { " ;
$meta [] = " \t \t \t \t \t \$ this->document->setMetadata( \$ k, \$ v); " ;
$meta [] = " \t \t \t \t } " ;
$meta [] = " \t \t \t } " ;
$meta [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $meta );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
public function setMetadataList ()
{
$meta = array ();
2017-12-14 23:10:47 +00:00
$meta [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " load the meta description " ;
2016-02-26 00:20:09 +00:00
$meta [] = " \t \t if ( \$ this->params->get('menu-meta_description')) " ;
$meta [] = " \t \t { " ;
$meta [] = " \t \t \t \$ this->document->setDescription( \$ this->params->get('menu-meta_description')); " ;
$meta [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$meta [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " load the key words if set " ;
2016-02-26 00:20:09 +00:00
$meta [] = " \t \t if ( \$ this->params->get('menu-meta_keywords')) " ;
$meta [] = " \t \t { " ;
$meta [] = " \t \t \t \$ this->document->setMetadata('keywords', \$ this->params->get('menu-meta_keywords')); " ;
$meta [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$meta [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " check the robot params " ;
2016-02-26 00:20:09 +00:00
$meta [] = " \t \t if ( \$ this->params->get('robots')) " ;
$meta [] = " \t \t { " ;
$meta [] = " \t \t \t \$ this->document->setMetadata('robots', \$ this->params->get('robots')); " ;
$meta [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $meta );
2016-02-26 00:20:09 +00:00
}
2016-09-11 15:27:04 +00:00
public function setGoogleChartLoader ( & $view )
2016-02-26 00:20:09 +00:00
{
if ( isset ( $this -> googleChart [ $this -> target ][ $view [ 'settings' ] -> code ]) && $this -> googleChart [ $this -> target ][ $view [ 'settings' ] -> code ])
{
$chart = array ();
2017-12-14 23:10:47 +00:00
$chart [] = PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " add the google chart builder class. " ;
2016-02-26 00:20:09 +00:00
$chart [] = " \t \t require_once JPATH_COMPONENT_ADMINISTRATOR.'/helpers/chartbuilder.php'; " ;
2017-12-14 23:10:47 +00:00
$chart [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " load the google chart js. " ;
2017-12-22 19:46:03 +00:00
$chart [] = " \t \t \$ this->document->addScript(JURI::root(true) .'/media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /js/google.jsapi.js', array('version' => 'auto')); " ;
$chart [] = " \t \t \$ this->document->addScript('https://canvg.googlecode.com/svn/trunk/rgbcolor.js', array('version' => 'auto')); " ;
$chart [] = " \t \t \$ this->document->addScript('https://canvg.googlecode.com/svn/trunk/canvg.js', array('version' => 'auto')); " ;
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $chart );
2016-02-26 00:20:09 +00:00
}
return '' ;
}
2017-12-14 23:10:47 +00:00
2017-12-10 19:17:26 +00:00
public function setLibrariesLoader ( $view )
2016-02-26 00:20:09 +00:00
{
2017-12-10 19:17:26 +00:00
// reset bucket
2016-02-26 00:20:09 +00:00
$setter = '' ;
// allways load these in
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " always make sure jquery is loaded. " ;
$setter .= PHP_EOL . " \t \t JHtml::_('jquery.framework'); " ;
$setter .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Load the header checker class. " ;
2017-02-02 11:54:07 +00:00
if ( $this -> target === 'site' )
{
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . " \t \t require_once( JPATH_COMPONENT_SITE.'/helpers/headercheck.php' ); " ;
2017-02-02 11:54:07 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . " \t \t require_once( JPATH_COMPONENT_ADMINISTRATOR.'/helpers/headercheck.php' ); " ;
2017-02-02 11:54:07 +00:00
}
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Initialize the header checker. " ;
$setter .= PHP_EOL . " \t \t \$ HeaderCheck = new " . $this -> fileContentStatic [ '###component###' ] . " HeaderCheck; " ;
2017-12-10 19:17:26 +00:00
// check if this view should get libraries
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> libManager [ $this -> target ][ $view [ 'settings' ] -> code ]) && ComponentbuilderHelper :: checkArray ( $this -> libManager [ $this -> target ][ $view [ 'settings' ] -> code ]))
2017-12-10 19:17:26 +00:00
{
foreach ( $this -> libManager [ $this -> target ][ $view [ 'settings' ] -> code ] as $id => $true )
{
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> libraries [ $id ]) && ComponentbuilderHelper :: checkObject ( $this -> libraries [ $id ]) && isset ( $this -> libraries [ $id ] -> document ) && ComponentbuilderHelper :: checkString ( $this -> libraries [ $id ] -> document ))
2017-12-10 19:17:26 +00:00
{
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . PHP_EOL . $this -> setPlaceholders (
str_replace ( '$document->' , '$this->document->' , $this -> libraries [ $id ] -> document ), $this -> placeholders );
2017-12-10 19:17:26 +00:00
}
2017-12-14 23:10:47 +00:00
elseif ( isset ( $this -> libraries [ $id ]) && ComponentbuilderHelper :: checkObject ( $this -> libraries [ $id ]) && isset ( $this -> libraries [ $id ] -> how ))
2017-12-10 19:17:26 +00:00
{
$setter .= $this -> setLibraryDocument ( $id );
}
}
}
return $setter ;
}
protected function setLibraryDocument ( $id )
{
2017-12-14 23:10:47 +00:00
if ( 2 == $this -> libraries [ $id ] -> how && isset ( $this -> libraries [ $id ] -> conditions ) && ComponentbuilderHelper :: checkArray ( $this -> libraries [ $id ] -> conditions ))
2017-12-10 19:17:26 +00:00
{
// build document with the conditions values
$this -> setLibraryDocConditions ( $id , $this -> setLibraryScripts ( $id , false ));
}
elseif ( 1 == $this -> libraries [ $id ] -> how )
{
// build document to allways add all files and urls
$this -> setLibraryScripts ( $id );
}
// check if the document was build
if ( isset ( $this -> libraries [ $id ] -> document ) && ComponentbuilderHelper :: checkString ( $this -> libraries [ $id ] -> document ))
{
2017-12-14 23:10:47 +00:00
return PHP_EOL . PHP_EOL . $this -> libraries [ $id ] -> document ;
2017-12-10 19:17:26 +00:00
}
return '' ;
}
protected function setLibraryDocConditions ( $id , $scripts )
{
$document = '' ;
// Start script builder for library files
if ( ! isset ( $this -> libwarning [ $id ]))
{
2017-12-17 09:07:51 +00:00
$this -> app -> enqueueMessage ( JText :: sprintf ( 'The conditional script builder for <b>%s</b> is not ready, sorry!' , $this -> libraries [ $id ] -> name ), 'warning' );
2017-12-10 19:17:26 +00:00
// set the warning only once
$this -> libwarning [ $id ] = true ;
}
// if there was any code added to document then set globaly
if ( ComponentbuilderHelper :: checkString ( $document ))
{
$this -> libraries [ $id ] -> document = $document ;
}
}
protected function setLibraryScripts ( $id , $buildDoc = true )
{
$scripts = array ();
// load the urls if found
if ( isset ( $this -> libraries [ $id ] -> urls ) && ComponentbuilderHelper :: checkArray ( $this -> libraries [ $id ] -> urls ))
{
// set all the files
foreach ( $this -> libraries [ $id ] -> urls as $url )
{
// if local path is set, then use it first
if ( isset ( $url [ 'path' ]))
{
// update the root path
$path = $this -> getScriptRootPath ( $url [ 'path' ]);
// load document script
$scripts [ md5 ( $url [ 'path' ])] = $this -> setIncludeLibScript ( $path );
// load url also if not building document
if ( ! $buildDoc )
{
// load document script
$scripts [ md5 ( $url [ 'url' ])] = $this -> setIncludeLibScript ( $url [ 'url' ], false );
}
}
else
{
// load document script
$scripts [ md5 ( $url [ 'url' ])] = $this -> setIncludeLibScript ( $url [ 'url' ], false );
}
}
}
// load the local files if found
if ( isset ( $this -> libraries [ $id ] -> files ) && ComponentbuilderHelper :: checkArray ( $this -> libraries [ $id ] -> files ))
{
// set all the files
foreach ( $this -> libraries [ $id ] -> files as $file )
{
2017-12-14 23:10:47 +00:00
$path = '/' . trim ( $file [ 'path' ], '/' );
2017-12-10 19:17:26 +00:00
// check if path has new file name (has extetion)
$pathInfo = pathinfo ( $path );
// update the root path
$_path = $this -> getScriptRootPath ( $path );
if ( isset ( $pathInfo [ 'extension' ]) && $pathInfo [ 'extension' ])
{
// load document script
$scripts [ md5 ( $path )] = $this -> setIncludeLibScript ( $_path , false , $pathInfo );
}
else
{
// load document script
2017-12-14 23:10:47 +00:00
$scripts [ md5 ( $path . '/' . trim ( $file [ 'file' ], '/' ))] = $this -> setIncludeLibScript ( $_path . '/' . trim ( $file [ 'file' ], '/' ));
2017-12-10 19:17:26 +00:00
}
}
}
// load the local folders if found
if ( isset ( $this -> libraries [ $id ] -> folders ) && ComponentbuilderHelper :: checkArray ( $this -> libraries [ $id ] -> folders ))
{
// get all the file paths
foreach ( $this -> libraries [ $id ] -> folders as $folder )
{
if ( isset ( $folder [ 'path' ]) && isset ( $folder [ 'folder' ]))
{
2017-12-14 23:10:47 +00:00
$path = '/' . trim ( $folder [ 'path' ], '/' );
2017-12-10 19:17:26 +00:00
if ( isset ( $folder [ 'rename' ]) && 1 == $folder [ 'rename' ])
{
2017-12-14 23:10:47 +00:00
if ( $_paths = ComponentbuilderHelper :: getAllFilePaths ( $this -> componentPath . $path ))
2017-12-10 19:17:26 +00:00
{
$files [ $path ] = $_paths ;
}
}
else
{
2017-12-14 23:10:47 +00:00
$path = $path . '/' . trim ( $folder [ 'folder' ], '/' );
if ( $_paths = ComponentbuilderHelper :: getAllFilePaths ( $this -> componentPath . $path ))
2017-12-10 19:17:26 +00:00
{
$files [ $path ] = $_paths ;
}
}
}
}
// now load the script
foreach ( $files as $root => $paths )
{
// update the root path
$_root = $this -> getScriptRootPath ( $root );
// load per path
2017-12-14 23:10:47 +00:00
foreach ( $paths as $path )
2017-12-10 19:17:26 +00:00
{
2017-12-14 23:10:47 +00:00
$scripts [ md5 ( $root . '/' . trim ( $path , '/' ))] = $this -> setIncludeLibScript ( $_root . '/' . trim ( $path , '/' ));
2017-12-10 19:17:26 +00:00
}
}
}
// if there was any code added to document then set globaly
if ( $buildDoc && ComponentbuilderHelper :: checkArray ( $scripts ))
{
2017-12-14 23:10:47 +00:00
$this -> libraries [ $id ] -> document = " \t \t // " . $this -> setLine ( __LINE__ ) . " always load these files. " . PHP_EOL . " \t \t " . implode ( PHP_EOL . " \t \t " , $scripts );
2017-12-10 19:17:26 +00:00
// success
return true ;
}
elseif ( ComponentbuilderHelper :: checkArray ( $scripts ))
{
return $scripts ;
}
return false ;
}
protected function setIncludeLibScript ( $path , $local = true , $pathInfo = false )
{
// insure we have the path info
if ( ! $pathInfo )
{
$pathInfo = pathinfo ( $path );
}
// set the local string
$JURI = '' ;
if ( $local )
{
$JURI = 'JURI::root(true) . ' ;
}
// use the path info to build the script
if ( isset ( $pathInfo [ 'extension' ]) && $pathInfo [ 'extension' ])
{
2017-12-14 23:10:47 +00:00
switch ( $pathInfo [ 'extension' ])
2017-12-10 19:17:26 +00:00
{
case 'js' :
2017-12-22 19:46:03 +00:00
return '$this->document->addScript(' . $JURI . '"' . $path . '", array("version" => "auto"));' ;
2017-12-14 23:10:47 +00:00
break ;
2017-12-10 19:17:26 +00:00
case 'css' :
case 'less' :
2017-12-22 19:46:03 +00:00
return '$this->document->addStyleSheet(' . $JURI . '"' . $path . '", array("version" => "auto"));' ;
2017-12-14 23:10:47 +00:00
break ;
2017-12-10 19:17:26 +00:00
case 'php' :
if ( strpos ( $path , 'http' ) === false )
{
2017-12-14 23:10:47 +00:00
return 'require_once("' . $path . '");' ;
2017-12-10 19:17:26 +00:00
}
2017-12-14 23:10:47 +00:00
break ;
2017-12-10 19:17:26 +00:00
}
}
return '' ;
}
protected function getScriptRootPath ( $root )
{
if ( strpos ( $root , '/media/' ) !== false && strpos ( $root , '/admin/' ) === false && strpos ( $root , '/site/' ) === false )
{
2017-12-14 23:10:47 +00:00
return str_replace ( '/media/' , '/media/com_' . $this -> fileContentStatic [ '###component###' ] . '/' , $root );
2017-12-10 19:17:26 +00:00
}
elseif ( strpos ( $root , '/media/' ) === false && strpos ( $root , '/admin/' ) !== false && strpos ( $root , '/site/' ) === false )
{
2017-12-14 23:10:47 +00:00
return str_replace ( '/admin/' , '/administrator/components/com_' . $this -> fileContentStatic [ '###component###' ] . '/' , $root );
2017-12-10 19:17:26 +00:00
}
elseif ( strpos ( $root , '/media/' ) === false && strpos ( $root , '/admin/' ) === false && strpos ( $root , '/site/' ) !== false )
{
2017-12-14 23:10:47 +00:00
return str_replace ( '/site/' , '/components/com_' . $this -> fileContentStatic [ '###component###' ] . '/' , $root );
2017-12-10 19:17:26 +00:00
}
return $root ;
}
public function setUikitLoader ( & $view )
{
// reset setter
$setter = '' ;
2016-02-26 00:20:09 +00:00
// load the defaults needed
2017-11-11 04:33:51 +00:00
if ( $this -> uikit > 0 )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Load uikit options. " ;
$setter .= PHP_EOL . " \t \t \$ uikit = \$ this->params->get('uikit_load'); " ;
$setter .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Set script size. " ;
$setter .= PHP_EOL . " \t \t \$ size = \$ this->params->get('uikit_min'); " ;
2017-11-11 04:33:51 +00:00
$tabV = " " ;
// if both versions should be loaded then add some more logic
if ( 2 == $this -> uikit )
{
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Load uikit version. " ;
$setter .= PHP_EOL . " \t \t \$ uikitVersion = \$ this->params->get('uikit_version', 2); " ;
$setter .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Use Uikit Version 2 " ;
$setter .= PHP_EOL . " \t \t if (2 == \$ uikitVersion) " ;
$setter .= PHP_EOL . " \t \t { " ;
2017-11-11 04:33:51 +00:00
$tabV = " \t " ;
}
}
// load the defaults needed
if ( 2 == $this -> uikit || 1 == $this -> uikit )
{
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . $tabV . " \t \t // " . $this -> setLine ( __LINE__ ) . " Set css style. " ;
$setter .= PHP_EOL . $tabV . " \t \t \$ style = \$ this->params->get('uikit_style'); " ;
2017-11-11 04:33:51 +00:00
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . PHP_EOL . $tabV . " \t \t // " . $this -> setLine ( __LINE__ ) . " The uikit css. " ;
$setter .= PHP_EOL . $tabV . " \t \t if ((! \$ HeaderCheck->css_loaded('uikit.min') || \$ uikit == 1) && \$ uikit != 2 && \$ uikit != 3) " ;
$setter .= PHP_EOL . $tabV . " \t \t { " ;
2017-12-22 19:46:03 +00:00
$setter .= PHP_EOL . $tabV . " \t \t \t \$ this->document->addStyleSheet(JURI::root(true) .'/media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /uikit-v2/css/uikit'. \$ style. \$ size.'.css', array('version' => 'auto')); " ;
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . $tabV . " \t \t } " ;
$setter .= PHP_EOL . $tabV . " \t \t // " . $this -> setLine ( __LINE__ ) . " The uikit js. " ;
$setter .= PHP_EOL . $tabV . " \t \t if ((! \$ HeaderCheck->js_loaded('uikit.min') || \$ uikit == 1) && \$ uikit != 2 && \$ uikit != 3) " ;
$setter .= PHP_EOL . $tabV . " \t \t { " ;
2017-12-22 19:46:03 +00:00
$setter .= PHP_EOL . $tabV . " \t \t \t \$ this->document->addScript(JURI::root(true) .'/media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /uikit-v2/js/uikit'. \$ size.'.js', array('version' => 'auto')); " ;
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . $tabV . " \t \t } " ;
2016-02-26 00:20:09 +00:00
}
// load the components need
2017-11-11 04:33:51 +00:00
if (( 2 == $this -> uikit || 1 == $this -> uikit ) && isset ( $this -> uikitComp [ $view [ 'settings' ] -> code ]) && ComponentbuilderHelper :: checkArray ( $this -> uikitComp [ $view [ 'settings' ] -> code ]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . PHP_EOL . $tabV . " \t \t // " . $this -> setLine ( __LINE__ ) . " Load the script to find all uikit components needed. " ;
$setter .= PHP_EOL . $tabV . " \t \t if ( \$ uikit != 2) " ;
$setter .= PHP_EOL . $tabV . " \t \t { " ;
$setter .= PHP_EOL . $tabV . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Set the default uikit components in this view. " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \$ uikitComp = array(); " ;
2016-02-26 00:20:09 +00:00
foreach ( $this -> uikitComp [ $view [ 'settings' ] -> code ] as $class )
{
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . $tabV . " \t \t \t \$ uikitComp[] = ' " . $class . " '; " ;
2016-02-26 00:20:09 +00:00
}
// check content for more needed components
if ( isset ( $this -> siteFieldData [ 'uikit' ][ $view [ 'settings' ] -> code ]) && ComponentbuilderHelper :: checkArray ( $this -> siteFieldData [ 'uikit' ][ $view [ 'settings' ] -> code ]))
{
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . PHP_EOL . $tabV . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Get field uikit components needed in this view. " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \$ uikitFieldComp = \$ this->get('UikitComp'); " ;
$setter .= PHP_EOL . $tabV . " \t \t \t if (isset( \$ uikitFieldComp) && " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ uikitFieldComp)) " ;
$setter .= PHP_EOL . $tabV . " \t \t \t { " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t if (isset( \$ uikitComp) && " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ uikitComp)) " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t { " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t \$ uikitComp = array_merge( \$ uikitComp, \$ uikitFieldComp); " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t \$ uikitComp = array_unique( \$ uikitComp); " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t } " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t else " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t { " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t \$ uikitComp = \$ uikitFieldComp; " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t } " ;
$setter .= PHP_EOL . $tabV . " \t \t \t } " ;
}
$setter .= PHP_EOL . $tabV . " \t \t } " ;
$setter .= PHP_EOL . PHP_EOL . $tabV . " \t \t // " . $this -> setLine ( __LINE__ ) . " Load the needed uikit components in this view. " ;
$setter .= PHP_EOL . $tabV . " \t \t if ( \$ uikit != 2 && isset( \$ uikitComp) && " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ uikitComp)) " ;
$setter .= PHP_EOL . $tabV . " \t \t { " ;
$setter .= PHP_EOL . $tabV . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " load just in case. " ;
$setter .= PHP_EOL . $tabV . " \t \t \t jimport('joomla.filesystem.file'); " ;
$setter .= PHP_EOL . $tabV . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " loading... " ;
$setter .= PHP_EOL . $tabV . " \t \t \t foreach ( \$ uikitComp as \$ class) " ;
$setter .= PHP_EOL . $tabV . " \t \t \t { " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t foreach ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper:: \$ uk_components[ \$ class] as \$ name) " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t { " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " check if the CSS file exists. " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t if (JFile::exists(JPATH_ROOT.'/media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /uikit-v2/css/components/'. \$ name. \$ style. \$ size.'.css')) " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t { " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " load the css. " ;
2017-12-22 19:46:03 +00:00
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t \t \$ this->document->addStyleSheet(JURI::root(true) .'/media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /uikit-v2/css/components/'. \$ name. \$ style. \$ size.'.css', array('version' => 'auto')); " ;
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t } " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " check if the JavaScript file exists. " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t if (JFile::exists(JPATH_ROOT.'/media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /uikit-v2/js/components/'. \$ name. \$ size.'.js')) " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t { " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " load the js. " ;
2017-12-22 19:46:03 +00:00
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t \t \$ this->document->addScript(JURI::root(true) .'/media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /uikit-v2/js/components/'. \$ name. \$ size.'.js', array('version' => 'auto'), array('type' => 'text/javascript', 'async' => 'async')); " ;
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t } " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t } " ;
$setter .= PHP_EOL . $tabV . " \t \t \t } " ;
$setter .= PHP_EOL . $tabV . " \t \t } " ;
2017-11-11 04:33:51 +00:00
}
elseif (( 2 == $this -> uikit || 1 == $this -> uikit ) && isset ( $this -> siteFieldData [ 'uikit' ][ $view [ 'settings' ] -> code ]) && ComponentbuilderHelper :: checkArray ( $this -> siteFieldData [ 'uikit' ][ $view [ 'settings' ] -> code ]))
{
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . PHP_EOL . $tabV . " \t \t // " . $this -> setLine ( __LINE__ ) . " Load the needed uikit components in this view. " ;
$setter .= PHP_EOL . $tabV . " \t \t \$ uikitComp = \$ this->get('UikitComp'); " ;
$setter .= PHP_EOL . $tabV . " \t \t if ( \$ uikit != 2 && isset( \$ uikitComp) && " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ uikitComp)) " ;
$setter .= PHP_EOL . $tabV . " \t \t { " ;
$setter .= PHP_EOL . $tabV . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " load just in case. " ;
$setter .= PHP_EOL . $tabV . " \t \t \t jimport('joomla.filesystem.file'); " ;
$setter .= PHP_EOL . $tabV . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " loading... " ;
$setter .= PHP_EOL . $tabV . " \t \t \t foreach ( \$ uikitComp as \$ class) " ;
$setter .= PHP_EOL . $tabV . " \t \t \t { " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t foreach ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper:: \$ uk_components[ \$ class] as \$ name) " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t { " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " check if the CSS file exists. " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t if (JFile::exists(JPATH_ROOT.'/media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /uikit-v2/css/components/'. \$ name. \$ style. \$ size.'.css')) " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t { " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " load the css. " ;
2017-12-22 19:46:03 +00:00
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t \t \$ this->document->addStyleSheet(JURI::root(true) .'/media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /uikit-v2/css/components/'. \$ name. \$ style. \$ size.'.css', array('version' => 'auto')); " ;
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t } " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " check if the JavaScript file exists. " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t if (JFile::exists(JPATH_ROOT.'/media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /uikit-v2/js/components/'. \$ name. \$ size.'.js')) " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t { " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " load the js. " ;
2017-12-22 19:46:03 +00:00
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t \t \$ this->document->addScript(JURI::root(true) .'/media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /uikit-v2/js/components/'. \$ name. \$ size.'.js', array('version' => 'auto'), array('type' => 'text/javascript', 'async' => 'async')); " ;
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . $tabV . " \t \t \t \t \t } " ;
$setter .= PHP_EOL . $tabV . " \t \t \t \t } " ;
$setter .= PHP_EOL . $tabV . " \t \t \t } " ;
$setter .= PHP_EOL . $tabV . " \t \t } " ;
}
2017-11-11 04:33:51 +00:00
// now set the version 3
if ( 2 == $this -> uikit || 3 == $this -> uikit )
{
if ( 2 == $this -> uikit )
{
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . " \t \t } " ;
$setter .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Use Uikit Version 3 " ;
$setter .= PHP_EOL . " \t \t elseif (3 == \$ uikitVersion) " ;
$setter .= PHP_EOL . " \t \t { " ;
2017-11-11 04:33:51 +00:00
}
// add version 3 fiels to page
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . $tabV . " \t \t // " . $this -> setLine ( __LINE__ ) . " The uikit css. " ;
$setter .= PHP_EOL . $tabV . " \t \t if ((! \$ HeaderCheck->css_loaded('uikit.min') || \$ uikit == 1) && \$ uikit != 2 && \$ uikit != 3) " ;
$setter .= PHP_EOL . $tabV . " \t \t { " ;
2017-12-22 19:46:03 +00:00
$setter .= PHP_EOL . $tabV . " \t \t \t \$ this->document->addStyleSheet(JURI::root(true) .'/media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /uikit-v3/css/uikit'. \$ size.'.css', array('version' => 'auto')); " ;
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . $tabV . " \t \t } " ;
$setter .= PHP_EOL . $tabV . " \t \t // " . $this -> setLine ( __LINE__ ) . " The uikit js. " ;
$setter .= PHP_EOL . $tabV . " \t \t if ((! \$ HeaderCheck->js_loaded('uikit.min') || \$ uikit == 1) && \$ uikit != 2 && \$ uikit != 3) " ;
$setter .= PHP_EOL . $tabV . " \t \t { " ;
2017-12-22 19:46:03 +00:00
$setter .= PHP_EOL . $tabV . " \t \t \t \$ this->document->addScript(JURI::root(true) .'/media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /uikit-v3/js/uikit'. \$ size.'.js', array('version' => 'auto')); " ;
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . $tabV . " \t \t } " ;
2017-11-11 04:33:51 +00:00
if ( 2 == $this -> uikit )
{
2017-12-14 23:10:47 +00:00
$setter .= PHP_EOL . " \t \t } " ;
2017-11-11 04:33:51 +00:00
}
2016-02-26 00:20:09 +00:00
}
return $setter ;
}
public function setCustomViewExtraDisplayMethods ( & $view )
{
if ( $view [ 'settings' ] -> add_php_jview == 1 )
{
2017-12-14 23:10:47 +00:00
return PHP_EOL . PHP_EOL . $this -> setPlaceholders ( $view [ 'settings' ] -> php_jview , $this -> placeholders );
2016-02-26 00:20:09 +00:00
}
return '' ;
}
public function setCustomViewBody ( & $view )
{
if ( ComponentbuilderHelper :: checkString ( $view [ 'settings' ] -> default ))
{
if ( $view [ 'settings' ] -> main_get -> gettype == 2 && $view [ 'settings' ] -> main_get -> pagination == 1 )
{
// build body
$body = array ();
// add limit box
if ( strpos ( $view [ 'settings' ] -> default , '[[[LIMITBOX]]]' ) !== false )
{
$this -> placeholders [ '[[[LIMITBOX]]]' ] = '<?php echo $this->pagination->getLimitBox(); ?>' ;
}
2017-02-11 02:24:26 +00:00
$body [] = $this -> setPlaceholders ( $view [ 'settings' ] -> default , $this -> placeholders );
2017-12-14 23:10:47 +00:00
$body [] = PHP_EOL . '<?php if (isset($this->items) && isset($this->pagination) && isset($this->pagination->pagesTotal) && $this->pagination->pagesTotal > 1): ?>' ;
2016-02-26 00:20:09 +00:00
$body [] = '<form name="adminForm" method="post">' ;
2017-12-14 23:10:47 +00:00
$body [] = " \t " . '<div class="pagination">' ;
$body [] = " \t \t " . '<?php if ($this->params->def(\'show_pagination_results\', 1)) : ?>' ;
2016-02-26 00:20:09 +00:00
if ( strpos ( $view [ 'settings' ] -> default , '[[[LIMITBOX]]]' ) === false )
{
2017-12-14 23:10:47 +00:00
$body [] = " \t \t \t " . '<p class="counter pull-right"> <?php echo $this->pagination->getPagesCounter(); ?> <?php echo $this->pagination->getLimitBox(); ?></p>' ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$body [] = " \t \t \t " . '<p class="counter pull-right"> <?php echo $this->pagination->getPagesCounter(); ?> </p>' ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$body [] = " \t \t " . '<?php endif; ?>' ;
$body [] = " \t \t " . '<?php echo $this->pagination->getPagesLinks(); ?>' ;
$body [] = " \t " . '</div>' ;
2016-02-26 00:20:09 +00:00
$body [] = '</form>' ;
$body [] = '<?php endif; ?>' ;
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $body );
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
return PHP_EOL . $this -> setPlaceholders ( $view [ 'settings' ] -> default , $this -> placeholders );
2016-02-26 00:20:09 +00:00
}
}
return '' ;
}
2016-07-12 21:07:55 +00:00
public function setCustomViewSubmitButtonScript ( & $view )
{
if ( ComponentbuilderHelper :: checkString ( $view [ 'settings' ] -> default ))
{
// add the script only if there is none set
if ( strpos ( $view [ 'settings' ] -> default , 'Joomla.submitbutton = function(task)' ) === false )
{
$script = array ();
2017-12-14 23:10:47 +00:00
$script [] = PHP_EOL . " <script type= \" text/javascript \" > " ;
2016-07-12 21:07:55 +00:00
$script [] = " \t Joomla.submitbutton = function(task) { " ;
2017-12-14 23:10:47 +00:00
$script [] = " \t \t if (task === ' " . $view [ 'settings' ] -> code . " .back') { " ;
2016-07-12 21:07:55 +00:00
$script [] = " \t \t \t parent.history.back(); " ;
$script [] = " \t \t \t return false; " ;
$script [] = " \t \t } else { " ;
$script [] = " \t \t \t var form = document.getElementById('adminForm'); " ;
$script [] = " \t \t \t form.task.value = task; " ;
$script [] = " \t \t \t form.submit(); " ;
$script [] = " \t \t } " ;
$script [] = " \t } " ;
$script [] = " </script> " ;
2017-12-14 23:10:47 +00:00
2017-02-09 16:11:10 +00:00
return implode ( PHP_EOL , $script );
2016-07-12 21:07:55 +00:00
}
}
return '' ;
}
2016-02-26 00:20:09 +00:00
public function setCustomViewCodeBody ( & $view )
{
if ( $view [ 'settings' ] -> add_php_view == 1 )
{
2017-12-14 23:10:47 +00:00
$view [ 'settings' ] -> php_view = ( array ) explode ( PHP_EOL , $view [ 'settings' ] -> php_view );
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> php_view ))
{
2017-12-14 23:10:47 +00:00
$_tmp = PHP_EOL . PHP_EOL . implode ( PHP_EOL , $view [ 'settings' ] -> php_view );
2017-02-11 02:24:26 +00:00
return $this -> setPlaceholders ( $_tmp , $this -> placeholders );
2016-02-26 00:20:09 +00:00
}
}
return '' ;
}
public function setCustomViewTemplateBody ( & $view )
{
if ( isset ( $this -> templateData [ $this -> target ][ $view [ 'settings' ] -> code ]) && ComponentbuilderHelper :: checkArray ( $this -> templateData [ $this -> target ][ $view [ 'settings' ] -> code ]))
{
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
foreach ( $this -> templateData [ $this -> target ][ $view [ 'settings' ] -> code ] as $template => $data )
{
// build the file
$target = array ( $this -> target => $view [ 'settings' ] -> code );
2017-12-14 23:10:47 +00:00
$config = array ( '###CREATIONDATE###' => $created , '###BUILDDATE###' => $modified , '###VERSION###' => $view [ 'settings' ] -> version );
$this -> buildDynamique ( $target , 'template' , $template , $config );
2016-02-26 00:20:09 +00:00
// set the file data
2017-12-14 23:10:47 +00:00
$TARGET = ComponentbuilderHelper :: safeString ( $this -> target , 'U' );
2016-02-26 00:20:09 +00:00
// ###SITE_TEMPLATE_BODY### <<<DYNAMIC>>>
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $view [ 'settings' ] -> code . '_' . $template ][ '###' . $TARGET . '_TEMPLATE_BODY###' ] = PHP_EOL . $this -> setPlaceholders ( $data [ 'html' ], $this -> placeholders );
2016-02-26 00:20:09 +00:00
// ###SITE_TEMPLATE_CODE_BODY### <<<DYNAMIC>>>
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $view [ 'settings' ] -> code . '_' . $template ][ '###' . $TARGET . '_TEMPLATE_CODE_BODY###' ] = $this -> setCustomViewTemplateCode ( $data [ 'php_view' ]);
2016-02-26 00:20:09 +00:00
}
}
}
public function setCustomViewTemplateCode ( & $php )
{
if ( ComponentbuilderHelper :: checkString ( $php ))
{
2017-12-14 23:10:47 +00:00
$php_view = ( array ) explode ( PHP_EOL , $php );
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkArray ( $php_view ))
{
2017-12-14 23:10:47 +00:00
$php_view = PHP_EOL . PHP_EOL . implode ( PHP_EOL , $php_view );
2017-02-11 02:24:26 +00:00
return $this -> setPlaceholders ( $php_view , $this -> placeholders );
2016-02-26 00:20:09 +00:00
}
}
return '' ;
}
public function setCustomViewLayouts ()
{
if ( isset ( $this -> layoutData [ $this -> target ]) && ComponentbuilderHelper :: checkArray ( $this -> layoutData [ $this -> target ]))
{
foreach ( $this -> layoutData [ $this -> target ] as $layout => $data )
{
// build the file
$target = array ( $this -> target => $layout );
2017-12-14 23:10:47 +00:00
$this -> buildDynamique ( $target , 'layout' );
2016-02-26 00:20:09 +00:00
// set the file data
2017-12-14 23:10:47 +00:00
$TARGET = ComponentbuilderHelper :: safeString ( $this -> target , 'U' );
2016-02-26 00:20:09 +00:00
// ###SITE_LAYOUT_CODE### <<<DYNAMIC>>>
2017-12-14 23:10:47 +00:00
$php_view = ( array ) explode ( PHP_EOL , $data [ 'php_view' ]);
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkArray ( $php_view ))
{
2017-12-14 23:10:47 +00:00
$php_view = PHP_EOL . PHP_EOL . implode ( PHP_EOL , $php_view );
$this -> fileContentDynamic [ $layout ][ '###' . $TARGET . '_LAYOUT_CODE###' ] = $this -> setPlaceholders ( $php_view , $this -> placeholders );
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $layout ][ '###' . $TARGET . '_LAYOUT_CODE###' ] = '' ;
2016-02-26 00:20:09 +00:00
}
// ###SITE_LAYOUT_BODY### <<<DYNAMIC>>>
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $layout ][ '###' . $TARGET . '_LAYOUT_BODY###' ] = PHP_EOL . $this -> setPlaceholders ( $data [ 'html' ], $this -> placeholders );
2016-02-26 00:20:09 +00:00
}
}
}
public function getReplacementNames ()
{
foreach ( $this -> newFiles as $type => $files )
{
foreach ( $files as $view => $file )
{
if ( isset ( $file [ 'path' ]) && ComponentbuilderHelper :: checkArray ( $file ))
{
if ( JFile :: exists ( $file [ 'path' ]))
{
2017-11-16 04:37:32 +00:00
$string = ComponentbuilderHelper :: getFileContents ( $file [ 'path' ]);
2016-02-26 00:20:09 +00:00
$buket [ 'static' ][] = $this -> getInbetweenStrings ( $string );
}
}
elseif ( ComponentbuilderHelper :: checkArray ( $file ))
{
foreach ( $file as $nr => $doc )
{
if ( ComponentbuilderHelper :: checkArray ( $doc ))
{
if ( JFile :: exists ( $doc [ 'path' ]))
{
2017-11-16 04:37:32 +00:00
$string = ComponentbuilderHelper :: getFileContents ( $doc [ 'path' ]);
2016-02-26 00:20:09 +00:00
$buket [ $view ][] = $this -> getInbetweenStrings ( $string );
}
}
}
}
}
}
foreach ( $buket as $type => $array )
{
foreach ( $array as $replacments )
{
$replacments = array_unique ( $replacments );
foreach ( $replacments as $replacment )
{
2017-02-01 13:17:04 +00:00
if ( $type !== 'static' )
2016-02-26 00:20:09 +00:00
{
2017-02-09 16:11:10 +00:00
//var_dump($replacment); echo PHP_EOL;
2017-12-14 23:10:47 +00:00
$echos [ $replacment ] = " ### " . $replacment . " ###<br /> " ;
2016-02-26 00:20:09 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $type === 'static' )
2016-02-26 00:20:09 +00:00
{
2017-02-09 16:11:10 +00:00
//var_dump($replacment); echo PHP_EOL;
2017-12-14 23:10:47 +00:00
$echos [ $replacment ] = " ### " . $replacment . " ###<br /> " ;
2016-02-26 00:20:09 +00:00
}
}
}
}
foreach ( $echos as $echo )
{
2017-12-14 23:10:47 +00:00
echo $echo . '<br />' ;
2016-02-26 00:20:09 +00:00
}
}
2016-09-11 15:27:04 +00:00
public function setMethodGetItem ( & $view )
2016-02-26 00:20:09 +00:00
{
$script = '' ;
// go from json to array
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> jsonItemBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> jsonItemBuilder [ $view ]))
2016-02-26 00:20:09 +00:00
{
foreach ( $this -> jsonItemBuilder [ $view ] as $jsonItem )
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t \t if (!empty( \$ item-> " . $jsonItem . " )) " ;
$script .= PHP_EOL . " \t \t \t { " ;
$script .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Convert the " . $jsonItem . " field to an array. " ;
$script .= PHP_EOL . " \t \t \t \t \$ " . $jsonItem . " = new Registry; " ;
$script .= PHP_EOL . " \t \t \t \t \$ " . $jsonItem . " ->loadString( \$ item-> " . $jsonItem . " ); " ;
$script .= PHP_EOL . " \t \t \t \t \$ item-> " . $jsonItem . " = \$ " . $jsonItem . " ->toArray(); " ;
$script .= PHP_EOL . " \t \t \t } " ;
2016-02-26 00:20:09 +00:00
}
}
// go from json to string
if ( isset ( $this -> jsonStringBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> jsonStringBuilder [ $view ]))
{
$makeArray = '' ;
foreach ( $this -> jsonStringBuilder [ $view ] as $jsonString )
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t \t if (!empty( \$ item-> " . $jsonString . " )) " ;
$script .= PHP_EOL . " \t \t \t { " ;
$script .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " JSON Decode " . $jsonString . " . " ;
if ( isset ( $this -> jsonItemBuilderArray [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> jsonItemBuilderArray [ $view ]) && in_array ( $jsonString , $this -> jsonItemBuilderArray [ $view ]))
2017-06-18 07:37:48 +00:00
{
$makeArray = ',true' ;
}
elseif ( strpos ( $jsonString , 'group' ) !== false )
2016-02-26 00:20:09 +00:00
{
$makeArray = ',true' ;
}
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \t \t \$ item-> " . $jsonString . " = json_decode( \$ item-> " . $jsonString . $makeArray . " ); " ;
$script .= PHP_EOL . " \t \t \t } " ;
2016-02-26 00:20:09 +00:00
}
}
// go from base64 to string
if ( isset ( $this -> base64Builder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> base64Builder [ $view ]))
{
foreach ( $this -> base64Builder [ $view ] as $baseString )
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t \t if (!empty( \$ item-> " . $baseString . " )) " ; // TODO && base64_encode(base64_decode(\$item->".$baseString.", true)) === \$item->".$baseString.")";
$script .= PHP_EOL . " \t \t \t { " ;
$script .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " base64 Decode " . $baseString . " . " ;
$script .= PHP_EOL . " \t \t \t \t \$ item-> " . $baseString . " = base64_decode( \$ item-> " . $baseString . " ); " ;
$script .= PHP_EOL . " \t \t \t } " ;
2016-02-26 00:20:09 +00:00
}
}
// decryption
if (( isset ( $this -> basicEncryptionBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> basicEncryptionBuilder [ $view ])) || ( isset ( $this -> advancedEncryptionBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> advancedEncryptionBuilder [ $view ])))
{
2017-12-14 23:10:47 +00:00
$Component = $this -> fileContentStatic [ '###Component###' ];
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> basicEncryptionBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> basicEncryptionBuilder [ $view ]))
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Get the basic encryption. " ;
$script .= PHP_EOL . " \t \t \t \$ basickey = " . $Component . " Helper::getCryptKey('basic'); " ;
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Get the encryption object. " ;
$script .= PHP_EOL . " \t \t \t \$ basic = new FOFEncryptAes( \$ basickey, 128); " ;
2016-02-26 00:20:09 +00:00
foreach ( $this -> basicEncryptionBuilder [ $view ] as $baseString )
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t \t if (!empty( \$ item-> " . $baseString . " ) && \$ basickey && !is_numeric( \$ item-> " . $baseString . " ) && \$ item-> " . $baseString . " === base64_encode(base64_decode( \$ item-> " . $baseString . " , true))) " ;
$script .= PHP_EOL . " \t \t \t { " ;
$script .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " basic decrypt data " . $baseString . " . " ;
$script .= PHP_EOL . " \t \t \t \t \$ item-> " . $baseString . " = rtrim( \$ basic->decryptString( \$ item-> " . $baseString . " ), " . '"\0"' . " ); " ;
$script .= PHP_EOL . " \t \t \t } " ;
2016-02-26 00:20:09 +00:00
}
}
if ( isset ( $this -> advancedEncryptionBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> advancedEncryptionBuilder [ $view ]))
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Get the advanced encryption key. " ;
$script .= PHP_EOL . " \t \t \t \$ advancedkey = " . $Component . " Helper::getCryptKey('advanced'); " ;
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Get the encryption object. " ;
$script .= PHP_EOL . " \t \t \t \$ advanced = new FOFEncryptAes( \$ advancedkey, 256); " ;
2016-02-26 00:20:09 +00:00
foreach ( $this -> advancedEncryptionBuilder [ $view ] as $baseString )
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t \t if (!empty( \$ item-> " . $baseString . " ) && \$ advancedkey && !is_numeric( \$ item-> " . $baseString . " ) && \$ item-> " . $baseString . " === base64_encode(base64_decode( \$ item-> " . $baseString . " , true))) " ;
$script .= PHP_EOL . " \t \t \t { " ;
$script .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " advanced decrypt data " . $baseString . " . " ;
$script .= PHP_EOL . " \t \t \t \t \$ item-> " . $baseString . " = rtrim( \$ advanced->decryptString( \$ item-> " . $baseString . " ), " . '"\0"' . " ); " ;
$script .= PHP_EOL . " \t \t \t } " ;
2016-02-26 00:20:09 +00:00
}
}
}
// add custom php to getitem method
2017-12-14 23:10:47 +00:00
$script .= $this -> getCustomScriptBuilder ( 'php_getitem' , $view , PHP_EOL . PHP_EOL );
2016-02-26 00:20:09 +00:00
return $script ;
}
2016-09-11 15:27:04 +00:00
public function setCheckboxSave ( & $view )
2016-02-26 00:20:09 +00:00
{
$script = '' ;
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> checkboxBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> checkboxBuilder [ $view ]))
2016-02-26 00:20:09 +00:00
{
foreach ( $this -> checkboxBuilder [ $view ] as $checkbox )
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Set the empty " . $checkbox . " item to data " ;
$script .= PHP_EOL . " \t \t if (!isset( \$ data[' " . $checkbox . " '])) " ;
$script .= PHP_EOL . " \t \t { " ;
$script .= PHP_EOL . " \t \t \t \$ data[' " . $checkbox . " '] = ''; " ;
$script .= PHP_EOL . " \t \t } " ;
2016-02-26 00:20:09 +00:00
}
}
return $script ;
}
2016-09-11 15:27:04 +00:00
public function setMethodItemSave ( & $view )
2016-02-26 00:20:09 +00:00
{
$script = '' ;
2017-09-13 00:37:43 +00:00
// check if there was script added before modeling of data
2017-12-14 23:10:47 +00:00
$script .= $this -> getCustomScriptBuilder ( 'php_before_save' , $view , PHP_EOL . PHP_EOL );
2016-02-26 00:20:09 +00:00
// turn array into JSON string
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> jsonItemBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> jsonItemBuilder [ $view ]))
2016-02-26 00:20:09 +00:00
{
foreach ( $this -> jsonItemBuilder [ $view ] as $jsonItem )
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Set the " . $jsonItem . " items to data. " ;
$script .= PHP_EOL . " \t \t if (isset( \$ data[' " . $jsonItem . " ']) && is_array( \$ data[' " . $jsonItem . " '])) " ;
$script .= PHP_EOL . " \t \t { " ;
$script .= PHP_EOL . " \t \t \t \$ " . $jsonItem . " = new JRegistry; " ;
$script .= PHP_EOL . " \t \t \t \$ " . $jsonItem . " ->loadArray( \$ data[' " . $jsonItem . " ']); " ;
$script .= PHP_EOL . " \t \t \t \$ data[' " . $jsonItem . " '] = (string) \$ " . $jsonItem . " ; " ;
$script .= PHP_EOL . " \t \t } " ;
$script .= PHP_EOL . " \t \t elseif (!isset( \$ data[' " . $jsonItem . " '])) " ;
$script .= PHP_EOL . " \t \t { " ;
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Set the empty " . $jsonItem . " to data " ;
$script .= PHP_EOL . " \t \t \t \$ data[' " . $jsonItem . " '] = ''; " ;
$script .= PHP_EOL . " \t \t } " ;
2016-02-26 00:20:09 +00:00
}
}
// turn string into json string
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> jsonStringBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> jsonStringBuilder [ $view ]))
2016-02-26 00:20:09 +00:00
{
foreach ( $this -> jsonStringBuilder [ $view ] as $jsonString )
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Set the " . $jsonString . " string to JSON string. " ;
$script .= PHP_EOL . " \t \t if (isset( \$ data[' " . $jsonString . " '])) " ;
$script .= PHP_EOL . " \t \t { " ;
$script .= PHP_EOL . " \t \t \t \$ data[' " . $jsonString . " '] = (string) json_encode( \$ data[' " . $jsonString . " ']); " ;
$script .= PHP_EOL . " \t \t } " ;
2016-02-26 00:20:09 +00:00
}
}
// turn string into base 64 string
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> base64Builder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> base64Builder [ $view ]))
2016-02-26 00:20:09 +00:00
{
foreach ( $this -> base64Builder [ $view ] as $baseString )
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Set the " . $baseString . " string to base64 string. " ;
$script .= PHP_EOL . " \t \t if (isset( \$ data[' " . $baseString . " '])) " ;
$script .= PHP_EOL . " \t \t { " ;
$script .= PHP_EOL . " \t \t \t \$ data[' " . $baseString . " '] = base64_encode( \$ data[' " . $baseString . " ']); " ;
$script .= PHP_EOL . " \t \t } " ;
2016-02-26 00:20:09 +00:00
}
}
// turn string into encrypted string
2017-12-14 23:10:47 +00:00
if (( isset ( $this -> basicEncryptionBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> basicEncryptionBuilder [ $view ])) || ( isset ( $this -> advancedEncryptionBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> advancedEncryptionBuilder [ $view ])))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$Component = $this -> fileContentStatic [ '###Component###' ];
if ( isset ( $this -> basicEncryptionBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> basicEncryptionBuilder [ $view ]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the basic encryption key. " ;
$script .= PHP_EOL . " \t \t \$ basickey = " . $Component . " Helper::getCryptKey('basic'); " ;
$script .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the encryption object " ;
$script .= PHP_EOL . " \t \t \$ basic = new FOFEncryptAes( \$ basickey, 128); " ;
2016-02-26 00:20:09 +00:00
foreach ( $this -> basicEncryptionBuilder [ $view ] as $baseString )
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Encrypt data " . $baseString . " . " ;
$script .= PHP_EOL . " \t \t if (isset( \$ data[' " . $baseString . " ']) && \$ basickey) " ;
$script .= PHP_EOL . " \t \t { " ;
$script .= PHP_EOL . " \t \t \t \$ data[' " . $baseString . " '] = \$ basic->encryptString( \$ data[' " . $baseString . " ']); " ;
$script .= PHP_EOL . " \t \t } " ;
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> advancedEncryptionBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> advancedEncryptionBuilder [ $view ]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the advanced encryption key. " ;
$script .= PHP_EOL . " \t \t \$ advancedkey = " . $Component . " Helper::getCryptKey('advanced'); " ;
$script .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the encryption object " ;
$script .= PHP_EOL . " \t \t \$ advanced = new FOFEncryptAes( \$ advancedkey, 256); " ;
2016-02-26 00:20:09 +00:00
foreach ( $this -> advancedEncryptionBuilder [ $view ] as $baseString )
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Encrypt data " . $baseString . " . " ;
$script .= PHP_EOL . " \t \t if (isset( \$ data[' " . $baseString . " ']) && \$ advancedkey) " ;
$script .= PHP_EOL . " \t \t { " ;
$script .= PHP_EOL . " \t \t \t \$ data[' " . $baseString . " '] = \$ advanced->encryptString( \$ data[' " . $baseString . " ']); " ;
$script .= PHP_EOL . " \t \t } " ;
2016-02-26 00:20:09 +00:00
}
}
}
// add custom PHP to the save method
2017-12-14 23:10:47 +00:00
$script .= $this -> getCustomScriptBuilder ( 'php_save' , $view , PHP_EOL . PHP_EOL );
2016-02-26 00:20:09 +00:00
return $script ;
}
2016-09-11 15:27:04 +00:00
public function setJtableConstructor ( & $view )
2016-02-26 00:20:09 +00:00
{
// reset
$oserver = " " ;
// set component name
2017-12-14 23:10:47 +00:00
$component = $this -> fileContentStatic [ '###component###' ];
2016-02-26 00:20:09 +00:00
// add the tags observer
if ( isset ( $this -> tagsBuilder [ $view ]) && ComponentbuilderHelper :: checkString ( $this -> tagsBuilder [ $view ]))
{
2017-12-14 23:10:47 +00:00
$oserver .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Adding Tag Options " ;
$oserver .= PHP_EOL . " \t \t JTableObserverTags::createObserver( \$ this, array('typeAlias' => 'com_ " . $component . " . " . $view . " ')); " ;
2016-02-26 00:20:09 +00:00
}
// add the history/version observer
if ( isset ( $this -> historyBuilder [ $view ]) && ComponentbuilderHelper :: checkString ( $this -> historyBuilder [ $view ]))
{
2017-12-14 23:10:47 +00:00
$oserver .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Adding History Options " ;
$oserver .= PHP_EOL . " \t \t JTableObserverContenthistory::createObserver( \$ this, array('typeAlias' => 'com_ " . $component . " . " . $view . " ')); " ;
2016-02-26 00:20:09 +00:00
}
return $oserver ;
}
2016-09-11 15:27:04 +00:00
public function setJtableAliasCategory ( & $view )
2016-02-26 00:20:09 +00:00
{
// only add Observers if both title, alias and category is availabe in view
if ( array_key_exists ( $view , $this -> catCodeBuilder ))
{
$code = $this -> catCodeBuilder [ $view ][ 'code' ];
2017-12-14 23:10:47 +00:00
return " , ' " . $code . " ' => \$ this-> " . $code ;
2016-02-26 00:20:09 +00:00
}
return '' ;
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
public function setComponentToContentTypes ( $action )
{
$script = '' ;
if ( isset ( $this -> componentData -> admin_views ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> admin_views ))
{
// set component name
2017-12-14 23:10:47 +00:00
$component = $this -> fileContentStatic [ '###component###' ];
2016-02-26 00:20:09 +00:00
// reset
2017-12-14 23:10:47 +00:00
$dbStuff = array ();
2016-02-26 00:20:09 +00:00
// start loading the content type data
foreach ( $this -> componentData -> admin_views as $viewData )
{
// set main keys
$view = ComponentbuilderHelper :: safeString ( $viewData [ 'settings' ] -> name_single );
// set list view keys
$views = ComponentbuilderHelper :: safeString ( $viewData [ 'settings' ] -> name_list );
// get this views content type data
$dbStuff [ $view ] = $this -> getContentType ( $view , $component );
// get the correct views name
$checkViews = ( isset ( $this -> catCodeBuilder [ $view ][ 'views' ]) && ComponentbuilderHelper :: checkString ( $this -> catCodeBuilder [ $view ][ 'views' ])) ? $this -> catCodeBuilder [ $view ][ 'views' ] : $views ;
if ( ComponentbuilderHelper :: checkArray ( $dbStuff [ $view ]) && array_key_exists ( $view , $this -> catCodeBuilder ) && ( $checkViews == $views ))
{
2017-12-14 23:10:47 +00:00
$dbStuff [ $view . ' category' ] = $this -> getCategoryContentType ( $view , $views , $component );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
elseif ( ! isset ( $dbStuff [ $view ]) || ! ComponentbuilderHelper :: checkArray ( $dbStuff [ $view ]))
2016-02-26 00:20:09 +00:00
{
// remove if not array
unset ( $dbStuff [ $view ]);
}
}
// build the db insert query
if ( ComponentbuilderHelper :: checkArray ( $dbStuff ))
{
$taabb = '' ;
2017-02-01 13:17:04 +00:00
if ( $action === 'update' )
2016-02-26 00:20:09 +00:00
{
$taabb = " \t " ;
}
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Get The Database object " ;
$script .= PHP_EOL . " \t \t \t \$ db = JFactory::getDbo(); " ;
2016-02-26 00:20:09 +00:00
foreach ( $dbStuff as $name => $tables )
{
if ( ComponentbuilderHelper :: checkArray ( $tables ))
{
$code = ComponentbuilderHelper :: safeString ( $name );
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Create the " . $name . " content type object. " ;
$script .= PHP_EOL . " \t \t \t \$ " . $code . " = new stdClass(); " ;
2016-02-26 00:20:09 +00:00
foreach ( $tables as $table => $data )
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \t \$ " . $code . " -> " . $table . " = ' " . $data . " '; " ;
2016-02-26 00:20:09 +00:00
}
2017-02-01 13:17:04 +00:00
if ( $action === 'update' )
2016-02-26 00:20:09 +00:00
{
// we first load script to check if data exist
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Check if " . $name . " type is already in content_type DB. " ;
$script .= PHP_EOL . " \t \t \t \$ " . $code . " _id = null; " ;
$script .= PHP_EOL . " \t \t \t \$ query = \$ db->getQuery(true); " ;
$script .= PHP_EOL . " \t \t \t \$ query->select( \$ db->quoteName(array('type_id'))); " ;
$script .= PHP_EOL . " \t \t \t \$ query->from( \$ db->quoteName('#__content_types')); " ;
$script .= PHP_EOL . " \t \t \t \$ query->where( \$ db->quoteName('type_alias') . ' LIKE '. \$ db->quote( $ " . $code . " ->type_alias)); " ;
$script .= PHP_EOL . " \t \t \t \$ db->setQuery( \$ query); " ;
$script .= PHP_EOL . " \t \t \t \$ db->execute(); " ;
}
$script .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Set the object into the content types table. " ;
2017-02-01 13:17:04 +00:00
if ( $action === 'update' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \t if ( \$ db->getNumRows()) " ;
$script .= PHP_EOL . " \t \t \t { " ;
$script .= PHP_EOL . " \t \t \t \t \$ " . $code . " ->type_id = \$ db->loadResult(); " ;
$script .= PHP_EOL . " \t \t \t \t \$ " . $code . " _Updated = \$ db->updateObject('#__content_types', \$ " . $code . " , 'type_id'); " ;
$script .= PHP_EOL . " \t \t \t } " ;
$script .= PHP_EOL . " \t \t \t else " ;
$script .= PHP_EOL . " \t \t \t { " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \t " . $taabb . " \$ " . $code . " _Inserted = \$ db->insertObject('#__content_types', \$ " . $code . " ); " ;
2017-02-01 13:17:04 +00:00
if ( $action === 'update' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \t } " ;
2016-02-26 00:20:09 +00:00
}
}
}
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
}
return $script ;
}
2016-10-23 22:48:26 +00:00
public function setPostInstallScript ()
2016-02-26 00:20:09 +00:00
{
// reset script
$script = $this -> setComponentToContentTypes ( 'install' );
2017-12-14 23:10:47 +00:00
2016-03-04 17:26:18 +00:00
// set the component name
$component = $this -> fileContentStatic [ '###component###' ];
2017-12-14 23:10:47 +00:00
2017-08-22 22:17:19 +00:00
// add the assets table update for permissions rules
if ( isset ( $this -> assetsRules ) && ComponentbuilderHelper :: checkArray ( $this -> assetsRules ))
{
if ( ComponentbuilderHelper :: checkString ( $script ))
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Install the global extenstion assets permission. " ;
2017-08-22 22:17:19 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Install the global extenstion assets permission. " ;
$script .= PHP_EOL . " \t \t \t \$ db = JFactory::getDbo(); " ;
}
$script .= PHP_EOL . " \t \t \t \$ query = \$ db->getQuery(true); " ;
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Field to update. " ;
$script .= PHP_EOL . " \t \t \t \$ fields = array( " ;
$script .= PHP_EOL . " \t \t \t \t \$ db->quoteName('rules') . ' = ' . \$ db->quote(' { " . implode ( ',' , $this -> assetsRules ) . " }'), " ;
$script .= PHP_EOL . " \t \t \t ); " ;
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Condition. " ;
$script .= PHP_EOL . " \t \t \t \$ conditions = array( " ;
$script .= PHP_EOL . " \t \t \t \t \$ db->quoteName('name') . ' = ' . \$ db->quote('com_ " . $component . " ') " ;
$script .= PHP_EOL . " \t \t \t ); " ;
$script .= PHP_EOL . " \t \t \t \$ query->update( \$ db->quoteName('#__assets'))->set( \$ fields)->where( \$ conditions); " ;
$script .= PHP_EOL . " \t \t \t \$ db->setQuery( \$ query); " ;
$script .= PHP_EOL . " \t \t \t \$ allDone = \$ db->execute(); " . PHP_EOL ;
2017-08-22 22:17:19 +00:00
}
// add the global params for the component global settings
if ( isset ( $this -> extensionsParams ) && ComponentbuilderHelper :: checkArray ( $this -> extensionsParams ))
2016-02-26 00:20:09 +00:00
{
if ( ComponentbuilderHelper :: checkString ( $script ))
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Install the global extenstion params. " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Install the global extenstion params. " ;
$script .= PHP_EOL . " \t \t \t \$ db = JFactory::getDbo(); " ;
}
$script .= PHP_EOL . " \t \t \t \$ query = \$ db->getQuery(true); " ;
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Field to update. " ;
$script .= PHP_EOL . " \t \t \t \$ fields = array( " ;
$script .= PHP_EOL . " \t \t \t \t \$ db->quoteName('params') . ' = ' . \$ db->quote(' { " . implode ( ',' , $this -> extensionsParams ) . " }'), " ;
$script .= PHP_EOL . " \t \t \t ); " ;
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Condition. " ;
$script .= PHP_EOL . " \t \t \t \$ conditions = array( " ;
$script .= PHP_EOL . " \t \t \t \t \$ db->quoteName('element') . ' = ' . \$ db->quote('com_ " . $component . " ') " ;
$script .= PHP_EOL . " \t \t \t ); " ;
$script .= PHP_EOL . " \t \t \t \$ query->update( \$ db->quoteName('#__extensions'))->set( \$ fields)->where( \$ conditions); " ;
$script .= PHP_EOL . " \t \t \t \$ db->setQuery( \$ query); " ;
$script .= PHP_EOL . " \t \t \t \$ allDone = \$ db->execute(); " . PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
2016-10-23 22:48:26 +00:00
// add the custom script
2017-12-14 23:10:47 +00:00
$script .= $this -> getCustomScriptBuilder ( 'php_postflight' , 'install' , PHP_EOL . PHP_EOL , null , true );
2017-08-22 22:17:19 +00:00
// add the component install notice
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkString ( $script ))
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \t " . 'echo \'<a target="_blank" href="' . $this -> fileContentStatic [ '###AUTHORWEBSITE###' ] . '" title="' . $this -> fileContentStatic [ '###Component_name###' ] . '">' ;
$script .= PHP_EOL . " \t \t \t \t " . '<img src="components/com_' . $component . '/assets/images/vdm-component.' . $this -> componentImageType . '"/>' ;
$script .= PHP_EOL . " \t \t \t \t " . '</a>\';' ;
2016-02-26 00:20:09 +00:00
return $script ;
}
2017-12-14 23:10:47 +00:00
return PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " noting to install. " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
2016-10-23 22:48:26 +00:00
public function setPostUpdateScript ()
2016-02-26 00:20:09 +00:00
{
// reset script
$script = $this -> setComponentToContentTypes ( 'update' );
2016-10-23 22:48:26 +00:00
// add the custom script
2017-12-14 23:10:47 +00:00
$script .= $this -> getCustomScriptBuilder ( 'php_postflight' , 'update' , PHP_EOL . PHP_EOL , null , true );
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> componentData -> admin_views ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> admin_views ))
{
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \t " . 'echo \'<a target="_blank" href="' . $this -> fileContentStatic [ '###AUTHORWEBSITE###' ] . '" title="' . $this -> fileContentStatic [ '###Component_name###' ] . '">' ;
$script .= PHP_EOL . " \t \t \t \t " . '<img src="components/com_' . $this -> fileContentStatic [ '###component###' ] . '/assets/images/vdm-component.' . $this -> componentImageType . '"/>' ;
$script .= PHP_EOL . " \t \t \t \t " . '</a>' ;
$script .= PHP_EOL . " \t \t \t \t <h3>Upgrade to Version " . $this -> fileContentStatic [ '###ACTUALVERSION###' ] . " Was Successful! Let us know if anything is not working as expected.</h3>'; " ;
2016-02-26 00:20:09 +00:00
}
if ( ComponentbuilderHelper :: checkString ( $script ))
{
return $script ;
}
2017-12-14 23:10:47 +00:00
return PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " noting to update. " ;
2016-02-26 00:20:09 +00:00
}
2016-10-23 22:48:26 +00:00
public function setUninstallScript ()
{
// reset script
$script = '' ;
if ( isset ( $this -> uninstallScriptBuilder ) && ComponentbuilderHelper :: checkArray ( $this -> uninstallScriptBuilder ))
{
$component = $this -> fileContentStatic [ '###component###' ];
// start loading the data to delet
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get Application object " ;
$script .= PHP_EOL . " \t \t \$ app = JFactory::getApplication(); " ;
$script .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get The Database object " ;
$script .= PHP_EOL . " \t \t \$ db = JFactory::getDbo(); " ;
2016-10-23 22:48:26 +00:00
foreach ( $this -> uninstallScriptBuilder as $viewName => $typeAlias )
{
// set a var value
$view = ComponentbuilderHelper :: safeString ( $viewName );
// First check if data is till in table
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Create a new query object. " ;
$script .= PHP_EOL . " \t \t \$ query = \$ db->getQuery(true); " ;
$script .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Select id from content type table " ;
$script .= PHP_EOL . " \t \t \$ query->select( \$ db->quoteName('type_id')); " ;
$script .= PHP_EOL . " \t \t \$ query->from( \$ db->quoteName('#__content_types')); " ;
$script .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Where " . $viewName . " alias is found " ;
$script .= PHP_EOL . " \t \t \$ query->where( \$ db->quoteName('type_alias') . ' = '. \$ db->quote(' " . $typeAlias . " ') ); " ;
$script .= PHP_EOL . " \t \t \$ db->setQuery( \$ query); " ;
$script .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Execute query to see if alias is found " ;
$script .= PHP_EOL . " \t \t \$ db->execute(); " ;
$script .= PHP_EOL . " \t \t \$ " . $view . " _found = \$ db->getNumRows(); " ;
$script .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Now check if there were any rows " ;
$script .= PHP_EOL . " \t \t if ( \$ " . $view . " _found) " ;
$script .= PHP_EOL . " \t \t { " ;
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Since there are load the needed " . $view . " type ids " ;
$script .= PHP_EOL . " \t \t \t \$ " . $view . " _ids = \$ db->loadColumn(); " ;
2016-10-23 22:48:26 +00:00
// Now remove the actual type entry
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Remove " . $viewName . " from the content type table " ;
$script .= PHP_EOL . " \t \t \t \$ " . $view . " _condition = array( \$ db->quoteName('type_alias') . ' = '. \$ db->quote(' " . $typeAlias . " ') ); " ;
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Create a new query object. " ;
$script .= PHP_EOL . " \t \t \t \$ query = \$ db->getQuery(true); " ;
$script .= PHP_EOL . " \t \t \t \$ query->delete( \$ db->quoteName('#__content_types')); " ;
$script .= PHP_EOL . " \t \t \t \$ query->where( \$ " . $view . " _condition); " ;
$script .= PHP_EOL . " \t \t \t \$ db->setQuery( \$ query); " ;
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Execute the query to remove " . $viewName . " items " ;
$script .= PHP_EOL . " \t \t \t \$ " . $view . " _done = \$ db->execute(); " ;
$script .= PHP_EOL . " \t \t \t if ( \$ " . $view . " _done); " ;
$script .= PHP_EOL . " \t \t \t { " ;
$script .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " If succesfully remove " . $viewName . " add queued success message. " ;
2016-10-23 22:48:26 +00:00
// TODO lang is not translated
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \t \t \$ app->enqueueMessage(JText::_('The ( " . $typeAlias . " ) type alias was removed from the <b>#__content_type</b> table')); " ;
$script .= PHP_EOL . " \t \t \t } " ;
2016-10-23 22:48:26 +00:00
// Now remove the related items from contentitem tag map table
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Remove " . $viewName . " items from the contentitem tag map table " ;
$script .= PHP_EOL . " \t \t \t \$ " . $view . " _condition = array( \$ db->quoteName('type_alias') . ' = '. \$ db->quote(' " . $typeAlias . " ') ); " ;
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Create a new query object. " ;
$script .= PHP_EOL . " \t \t \t \$ query = \$ db->getQuery(true); " ;
$script .= PHP_EOL . " \t \t \t \$ query->delete( \$ db->quoteName('#__contentitem_tag_map')); " ;
$script .= PHP_EOL . " \t \t \t \$ query->where( \$ " . $view . " _condition); " ;
$script .= PHP_EOL . " \t \t \t \$ db->setQuery( \$ query); " ;
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Execute the query to remove " . $viewName . " items " ;
$script .= PHP_EOL . " \t \t \t \$ " . $view . " _done = \$ db->execute(); " ;
$script .= PHP_EOL . " \t \t \t if ( \$ " . $view . " _done); " ;
$script .= PHP_EOL . " \t \t \t { " ;
$script .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " If succesfully remove " . $viewName . " add queued success message. " ;
2016-10-23 22:48:26 +00:00
// TODO lang is not translated
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \t \t \$ app->enqueueMessage(JText::_('The ( " . $typeAlias . " ) type alias was removed from the <b>#__contentitem_tag_map</b> table')); " ;
$script .= PHP_EOL . " \t \t \t } " ;
2016-10-23 22:48:26 +00:00
// Now remove the related items from ucm content table
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Remove " . $viewName . " items from the ucm content table " ;
$script .= PHP_EOL . " \t \t \t \$ " . $view . " _condition = array( \$ db->quoteName('core_type_alias') . ' = ' . \$ db->quote(' " . $typeAlias . " ') ); " ;
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Create a new query object. " ;
$script .= PHP_EOL . " \t \t \t \$ query = \$ db->getQuery(true); " ;
$script .= PHP_EOL . " \t \t \t \$ query->delete( \$ db->quoteName('#__ucm_content')); " ;
$script .= PHP_EOL . " \t \t \t \$ query->where( \$ " . $view . " _condition); " ;
$script .= PHP_EOL . " \t \t \t \$ db->setQuery( \$ query); " ;
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Execute the query to remove " . $viewName . " items " ;
$script .= PHP_EOL . " \t \t \t \$ " . $view . " _done = \$ db->execute(); " ;
$script .= PHP_EOL . " \t \t \t if ( \$ " . $view . " _done); " ;
$script .= PHP_EOL . " \t \t \t { " ;
$script .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " If succesfully remove " . $viewName . " add queued success message. " ;
2016-10-23 22:48:26 +00:00
// TODO lang is not translated
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \t \t \$ app->enqueueMessage(JText::_('The ( " . $typeAlias . " ) type alias was removed from the <b>#__ucm_content</b> table')); " ;
$script .= PHP_EOL . " \t \t \t } " ;
2016-10-23 22:48:26 +00:00
// setup the foreach loop of ids
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Make sure that all the " . $viewName . " items are cleared from DB " ;
$script .= PHP_EOL . " \t \t \t foreach ( \$ " . $view . " _ids as \$ " . $view . " _id) " ;
$script .= PHP_EOL . " \t \t \t { " ;
2016-10-23 22:48:26 +00:00
// Now remove the related items from ucm base table
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Remove " . $viewName . " items from the ucm base table " ;
$script .= PHP_EOL . " \t \t \t \t \$ " . $view . " _condition = array( \$ db->quoteName('ucm_type_id') . ' = ' . \$ " . $view . " _id); " ;
$script .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Create a new query object. " ;
$script .= PHP_EOL . " \t \t \t \t \$ query = \$ db->getQuery(true); " ;
$script .= PHP_EOL . " \t \t \t \t \$ query->delete( \$ db->quoteName('#__ucm_base')); " ;
$script .= PHP_EOL . " \t \t \t \t \$ query->where( \$ " . $view . " _condition); " ;
$script .= PHP_EOL . " \t \t \t \t \$ db->setQuery( \$ query); " ;
$script .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Execute the query to remove " . $viewName . " items " ;
$script .= PHP_EOL . " \t \t \t \t \$ db->execute(); " ;
2016-10-23 22:48:26 +00:00
// Now remove the related items from ucm history table
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Remove " . $viewName . " items from the ucm history table " ;
$script .= PHP_EOL . " \t \t \t \t \$ " . $view . " _condition = array( \$ db->quoteName('ucm_type_id') . ' = ' . \$ " . $view . " _id); " ;
$script .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Create a new query object. " ;
$script .= PHP_EOL . " \t \t \t \t \$ query = \$ db->getQuery(true); " ;
$script .= PHP_EOL . " \t \t \t \t \$ query->delete( \$ db->quoteName('#__ucm_history')); " ;
$script .= PHP_EOL . " \t \t \t \t \$ query->where( \$ " . $view . " _condition); " ;
$script .= PHP_EOL . " \t \t \t \t \$ db->setQuery( \$ query); " ;
$script .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Execute the query to remove " . $viewName . " items " ;
$script .= PHP_EOL . " \t \t \t \t \$ db->execute(); " ;
2016-10-23 22:48:26 +00:00
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \t } " ;
2016-10-23 22:48:26 +00:00
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t } " ;
2016-10-23 22:48:26 +00:00
}
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " If All related items was removed queued success message. " ;
2016-10-23 22:48:26 +00:00
// TODO lang is not translated
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \$ app->enqueueMessage(JText::_('All related items was removed from the <b>#__ucm_base</b> table')); " ;
$script .= PHP_EOL . " \t \t \$ app->enqueueMessage(JText::_('All related items was removed from the <b>#__ucm_history</b> table')); " ;
2016-10-23 22:48:26 +00:00
// finaly remove the assets from the assets table
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Remove " . $component . " assets from the assets table " ;
$script .= PHP_EOL . " \t \t \$ " . $component . " _condition = array( \$ db->quoteName('name') . ' LIKE ' . \$ db->quote('com_ " . $component . " %') ); " ;
$script .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Create a new query object. " ;
$script .= PHP_EOL . " \t \t \$ query = \$ db->getQuery(true); " ;
$script .= PHP_EOL . " \t \t \$ query->delete( \$ db->quoteName('#__assets')); " ;
$script .= PHP_EOL . " \t \t \$ query->where( \$ " . $component . " _condition); " ;
$script .= PHP_EOL . " \t \t \$ db->setQuery( \$ query); " ;
$script .= PHP_EOL . " \t \t \$ " . $view . " _done = \$ db->execute(); " ;
$script .= PHP_EOL . " \t \t if ( \$ " . $view . " _done); " ;
$script .= PHP_EOL . " \t \t { " ;
$script .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " If succesfully remove " . $component . " add queued success message. " ;
2016-10-23 22:48:26 +00:00
// TODO lang is not translated
2017-12-14 23:10:47 +00:00
$script .= PHP_EOL . " \t \t \t \$ app->enqueueMessage(JText::_('All related items was removed from the <b>#__assets</b> table')); " ;
$script .= PHP_EOL . " \t \t } " ;
2016-10-23 22:48:26 +00:00
// done
2017-02-09 16:11:10 +00:00
$script .= PHP_EOL ;
2016-10-23 22:48:26 +00:00
}
// add the custom uninstall script
2017-02-09 16:11:10 +00:00
$script .= $this -> getCustomScriptBuilder ( 'php_method' , 'uninstall' , " " , null , true , null , PHP_EOL );
2016-10-23 22:48:26 +00:00
return $script ;
}
2016-02-26 00:20:09 +00:00
public function getContentType ( $view , $component )
{
// add if history is to be kept or if tags is added
if (( isset ( $this -> historyBuilder [ $view ]) && ComponentbuilderHelper :: checkString ( $this -> historyBuilder [ $view ])) || ( isset ( $this -> tagsBuilder [ $view ]) && ComponentbuilderHelper :: checkString ( $this -> tagsBuilder [ $view ])))
{
// reset array
$array = array ();
// set needed defaults
2017-12-14 23:10:47 +00:00
$alias = ( array_key_exists ( $view , $this -> aliasBuilder )) ? $this -> aliasBuilder [ $view ] : 'null' ;
$title = ( array_key_exists ( $view , $this -> titleBuilder )) ? $this -> titleBuilder [ $view ] : 'null' ;
$category = ( array_key_exists ( $view , $this -> catCodeBuilder )) ? $this -> catCodeBuilder [ $view ][ 'code' ] : 'null' ;
$categoryHistory = ( array_key_exists ( $view , $this -> catCodeBuilder )) ?
'{"sourceColumn": "' . $category . '","targetTable": "#__categories","targetColumn": "id","displayColumn": "title"},' : '' ;
$Component = ComponentbuilderHelper :: safeString ( $component , 'F' );
$View = ComponentbuilderHelper :: safeString ( $view , 'F' );
$maintext = ( isset ( $this -> maintextBuilder [ $view ]) && ComponentbuilderHelper :: checkString ( $this -> maintextBuilder [ $view ])) ? $this -> maintextBuilder [ $view ] : 'null' ;
$hiddenFields = ( isset ( $this -> hiddenFieldsBuilder [ $view ]) && ComponentbuilderHelper :: checkString ( $this -> hiddenFieldsBuilder [ $view ])) ? $this -> hiddenFieldsBuilder [ $view ] : '' ;
$dynamicfields = ( isset ( $this -> dynamicfieldsBuilder [ $view ]) && ComponentbuilderHelper :: checkString ( $this -> dynamicfieldsBuilder [ $view ])) ? $this -> dynamicfieldsBuilder [ $view ] : '' ;
$intFields = ( isset ( $this -> intFieldsBuilder [ $view ]) && ComponentbuilderHelper :: checkString ( $this -> intFieldsBuilder [ $view ])) ? $this -> intFieldsBuilder [ $view ] : '' ;
$customfieldlinks = ( isset ( $this -> customFieldLinksBuilder [ $view ]) && ComponentbuilderHelper :: checkString ( $this -> customFieldLinksBuilder [ $view ])) ? $this -> customFieldLinksBuilder [ $view ] : '' ;
2016-02-26 00:20:09 +00:00
// build uninstall script for content types
2017-12-14 23:10:47 +00:00
$this -> uninstallScriptBuilder [ $View ] = 'com_' . $component . '.' . $view ;
2016-02-26 00:20:09 +00:00
// check if this view has metadata
if ( isset ( $this -> metadataBuilder [ $view ]) && ComponentbuilderHelper :: checkString ( $this -> metadataBuilder [ $view ]))
{
$core_metadata = 'metadata' ;
$core_metakey = 'metakey' ;
$core_metadesc = 'metadesc' ;
}
else
{
$core_metadata = 'null' ;
$core_metakey = 'null' ;
$core_metadesc = 'null' ;
}
// check if view has access
if ( isset ( $this -> accessBuilder [ $view ]) && ComponentbuilderHelper :: checkString ( $this -> accessBuilder [ $view ]))
{
$core_access = 'access' ;
$accessHistory = ',{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"}' ;
}
else
{
$core_access = 'null' ;
$accessHistory = '' ;
}
// set the title
2017-12-14 23:10:47 +00:00
$array [ 'type_title' ] = $Component . ' ' . $View ;
2016-02-26 00:20:09 +00:00
// set the alias
2017-12-14 23:10:47 +00:00
$array [ 'type_alias' ] = 'com_' . $component . '.' . $view ;
2016-02-26 00:20:09 +00:00
// set the table
2017-12-14 23:10:47 +00:00
$array [ 'table' ] = '{"special": {"dbtable": "#__' . $component . '_' . $view . '","key": "id","type": "' . $View . '","prefix": "' . $component . 'Table","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}' ;
2016-02-26 00:20:09 +00:00
// set field map
2017-12-14 23:10:47 +00:00
$array [ 'field_mappings' ] = '{"common": {"core_content_item_id": "id","core_title": "' . $title . '","core_state": "published","core_alias": "' . $alias . '","core_created_time": "created","core_modified_time": "modified","core_body": "' . $maintext . '","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "' . $core_access . '","core_params": "params","core_featured": "null","core_metadata": "' . $core_metadata . '","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "' . $core_metakey . '","core_metadesc": "' . $core_metadesc . '","core_catid": "' . $category . '","core_xreference": "null","asset_id": "asset_id"},"special": {' . $dynamicfields . '}}' ;
2016-02-26 00:20:09 +00:00
// set the router class method
2017-12-14 23:10:47 +00:00
$array [ 'router' ] = $Component . 'HelperRoute::get' . $View . 'Route' ;
2016-02-26 00:20:09 +00:00
// set content history
2017-12-14 23:10:47 +00:00
$array [ 'content_history_options' ] = '{"formFile": "administrator/components/com_' . $component . '/models/forms/' . $view . '.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"' . $hiddenFields . '],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering"' . $intFields . '],"displayLookup": [' . $categoryHistory . '{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}' . $accessHistory . ',{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}' . $customfieldlinks . ']}' ;
2016-02-26 00:20:09 +00:00
return $array ;
}
return false ;
}
public function getCategoryContentType ( $view , $views , $component )
{
2017-12-14 23:10:47 +00:00
$category = $this -> catCodeBuilder [ $view ][ 'code' ];
$Component = ComponentbuilderHelper :: safeString ( $component , 'F' );
$View = ComponentbuilderHelper :: safeString ( $view , 'F' );
2016-02-26 00:20:09 +00:00
// build uninstall script for content types
2017-12-14 23:10:47 +00:00
$this -> uninstallScriptBuilder [ $View . ' ' . $category ] = 'com_' . $component . '.' . $views . '.category' ;
2016-02-26 00:20:09 +00:00
// set the title
2017-12-14 23:10:47 +00:00
$array [ 'type_title' ] = $Component . ' ' . $View . ' ' . ComponentbuilderHelper :: safeString ( $category , 'F' );
2016-02-26 00:20:09 +00:00
// set the alias
2017-12-14 23:10:47 +00:00
$array [ 'type_alias' ] = 'com_' . $component . '.' . $views . '.category' ;
2016-02-26 00:20:09 +00:00
// set the table
$array [ 'table' ] = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}' ;
// set field map
$array [ 'field_mappings' ] = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}' ;
// set the router class method
2017-12-14 23:10:47 +00:00
$array [ 'router' ] = $Component . 'HelperRoute::getCategoryRoute' ;
2016-02-26 00:20:09 +00:00
// set content history
$array [ 'content_history_options' ] = '{"formFile":"administrator\/components\/com_categories\/models\/forms\/category.xml", "hideFields":["asset_id","checked_out","checked_out_time","version","lft","rgt","level","path","extension"], "ignoreChanges":["modified_user_id", "modified_time", "checked_out", "checked_out_time", "version", "hits", "path"],"convertToInt":["publish_up", "publish_down"], "displayLookup":[{"sourceColumn":"created_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"}]}' ;
return $array ;
}
public function setRouterHelp ( $viewName_single , $viewName_list , $front = false )
{
// add if tags is added, also for all front item views
2017-12-14 23:10:47 +00:00
if ((( isset ( $this -> tagsBuilder [ $viewName_single ]) && ComponentbuilderHelper :: checkString ( $this -> tagsBuilder [ $viewName_single ])) || $front ) && ( ! in_array ( $viewName_single , $this -> setRouterHelpDone )))
2016-02-26 00:20:09 +00:00
{
// insure we load a view only once
$this -> setRouterHelpDone [] = $viewName_single ;
// build view route helper
$View = ComponentbuilderHelper :: safeString ( $viewName_single , 'F' );
$routeHelper = array ();
2017-12-14 23:10:47 +00:00
$routeHelper [] = PHP_EOL . PHP_EOL . " \t /** " ;
$routeHelper [] = " \t * @param int The route of the " . $View ;
2016-02-26 00:20:09 +00:00
$routeHelper [] = " \t */ " ;
2017-02-02 11:54:07 +00:00
if ( 'category' === $viewName_single || 'categories' === $viewName_single )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$routeHelper [] = " \t public static function get " . $View . " Route( \$ id = 0) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$routeHelper [] = " \t public static function get " . $View . " Route( \$ id = 0, \$ catid = 0) " ;
2016-02-26 00:20:09 +00:00
}
$routeHelper [] = " \t { " ;
$routeHelper [] = " \t \t if ( \$ id > 0) " ;
$routeHelper [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$routeHelper [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Initialize the needel array. " ;
2016-02-26 00:20:09 +00:00
$routeHelper [] = " \t \t \t \$ needles = array( " ;
2017-12-14 23:10:47 +00:00
$routeHelper [] = " \t \t \t \t ' " . $viewName_single . " ' => array((int) \$ id) " ;
2016-02-26 00:20:09 +00:00
$routeHelper [] = " \t \t \t ); " ;
2017-12-14 23:10:47 +00:00
$routeHelper [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Create the link " ;
$routeHelper [] = " \t \t \t \$ link = 'index.php?option=com_ " . $this -> fileContentStatic [ '###component###' ] . " &view= " . $viewName_single . " &id='. \$ id; " ;
2016-02-26 00:20:09 +00:00
$routeHelper [] = " \t \t } " ;
$routeHelper [] = " \t \t else " ;
$routeHelper [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$routeHelper [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Initialize the needel array. " ;
2016-02-26 00:20:09 +00:00
$routeHelper [] = " \t \t \t \$ needles = array(); " ;
2017-12-14 23:10:47 +00:00
$routeHelper [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Create the link but don't add the id. " ;
$routeHelper [] = " \t \t \t \$ link = 'index.php?option=com_ " . $this -> fileContentStatic [ '###component###' ] . " &view= " . $viewName_single . " '; " ;
$routeHelper [] = " \t \t } " ;
2016-02-26 00:20:09 +00:00
if ( 'category' != $viewName_single && 'categories' != $viewName_single )
{
$routeHelper [] = " \t \t if ( \$ catid > 1) " ;
$routeHelper [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$routeHelper [] = " \t \t \t \$ categories = JCategories::getInstance(' " . $this -> fileContentStatic [ '###component###' ] . " . " . $viewName_list . " '); " ;
2016-02-26 00:20:09 +00:00
$routeHelper [] = " \t \t \t \$ category = \$ categories->get( \$ catid); " ;
$routeHelper [] = " \t \t \t if ( \$ category) " ;
$routeHelper [] = " \t \t \t { " ;
$routeHelper [] = " \t \t \t \t \$ needles['category'] = array_reverse( \$ category->getPath()); " ;
$routeHelper [] = " \t \t \t \t \$ needles['categories'] = \$ needles['category']; " ;
$routeHelper [] = " \t \t \t \t \$ link .= '&catid='. \$ catid; " ;
$routeHelper [] = " \t \t \t } " ;
$routeHelper [] = " \t \t } " ;
}
if ( isset ( $this -> hasMenuGlobal [ $viewName_single ]))
{
2017-12-14 23:10:47 +00:00
$routeHelper [] = PHP_EOL . " \t \t if ( \$ item = self::_findItem( \$ needles, ' " . $viewName_single . " ')) " ;
2016-02-26 00:20:09 +00:00
}
else
2017-12-14 23:10:47 +00:00
{
$routeHelper [] = PHP_EOL . " \t \t if ( \$ item = self::_findItem( \$ needles)) " ;
2016-02-26 00:20:09 +00:00
}
$routeHelper [] = " \t \t { " ;
$routeHelper [] = " \t \t \t \$ link .= '&Itemid='. \$ item; " ;
$routeHelper [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$routeHelper [] = PHP_EOL . " \t \t return \$ link; " ;
2016-02-26 00:20:09 +00:00
$routeHelper [] = " \t } " ;
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $routeHelper );
2016-02-26 00:20:09 +00:00
}
return '' ;
}
2017-12-14 23:10:47 +00:00
2017-02-09 16:11:10 +00:00
public function routerParseSwitch ( & $view , $viewArray = null , $aliasView = true , $idView = true )
2016-02-26 00:20:09 +00:00
{
2016-12-22 21:32:13 +00:00
$isCategory = '' ;
2017-04-08 18:52:09 +00:00
$viewTable = false ;
2016-12-22 21:32:13 +00:00
if ( $viewArray && ComponentbuilderHelper :: checkArray ( $viewArray ))
{
2017-02-01 13:17:04 +00:00
if ( isset ( $viewArray [ 'settings' ] -> main_get -> db_table_main ) && $viewArray [ 'settings' ] -> main_get -> db_table_main === 'categories' )
2016-12-22 21:32:13 +00:00
{
$isCategory = ', true' ; // TODO we will keep an eye on this....
}
2017-02-09 16:11:10 +00:00
// elseif (isset($viewArray['settings']->main_get->gettype) && $viewArray['settings']->main_get->gettype == 2)
// {
// $idView = false; // TODO we will keep an eye on this....
// $aliasView = false;
// }
2017-04-08 18:52:09 +00:00
elseif ( isset ( $viewArray [ 'settings' ] -> main_get -> main_get ) && ComponentbuilderHelper :: checkArray ( $viewArray [ 'settings' ] -> main_get -> main_get ))
{
foreach ( $viewArray [ 'settings' ] -> main_get -> main_get as $get )
{
if ( $get [ 'as' ] === 'a' )
{
2017-12-14 23:10:47 +00:00
if ( isset ( $get [ 'selection' ]) && ComponentbuilderHelper :: checkArray ( $get [ 'selection' ]) && isset ( $get [ 'selection' ][ 'select_gets' ]) && ComponentbuilderHelper :: checkArray ( $get [ 'selection' ][ 'select_gets' ]))
2017-04-08 18:52:09 +00:00
{
if ( isset ( $get [ 'selection' ][ 'table' ]))
{
2017-12-14 23:10:47 +00:00
$viewTable = str_replace ( '#__' . $this -> fileContentStatic [ '###component###' ] . '_' , '' , $get [ 'selection' ][ 'table' ]);
2017-04-08 18:52:09 +00:00
}
}
}
}
}
2016-12-22 21:32:13 +00:00
}
2016-02-26 00:20:09 +00:00
// add if tags is added, also for all front item views
2017-02-09 16:11:10 +00:00
if ( $aliasView )
2016-02-26 00:20:09 +00:00
{
// build view route switch
$routerSwitch = array ();
2017-12-14 23:10:47 +00:00
$routerSwitch [] = PHP_EOL . " \t \t \t case ' " . $view . " ': " ;
$routerSwitch [] = " \t \t \t \t \$ vars['view'] = ' " . $view . " '; " ;
2016-02-26 00:20:09 +00:00
$routerSwitch [] = " \t \t \t \t if (is_numeric( \$ segments[ \$ count-1])) " ;
$routerSwitch [] = " \t \t \t \t { " ;
$routerSwitch [] = " \t \t \t \t \t \$ vars['id'] = (int) \$ segments[ \$ count-1]; " ;
$routerSwitch [] = " \t \t \t \t } " ;
2017-02-09 16:11:10 +00:00
$routerSwitch [] = " \t \t \t \t elseif ( \$ segments[ \$ count-1]) " ;
2016-02-26 00:20:09 +00:00
$routerSwitch [] = " \t \t \t \t { " ;
2017-04-08 18:52:09 +00:00
// we need to get from the table of this views main get the alias so we need the table name
if ( $viewTable )
{
2017-12-14 23:10:47 +00:00
$routerSwitch [] = " \t \t \t \t \t \$ id = \$ this->getVar(' " . $viewTable . " ', \$ segments[ \$ count-1], 'alias', 'id' " . $isCategory . " ); " ;
2017-04-08 18:52:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$routerSwitch [] = " \t \t \t \t \t \$ id = \$ this->getVar(' " . $view . " ', \$ segments[ \$ count-1], 'alias', 'id' " . $isCategory . " ); " ;
2017-04-08 18:52:09 +00:00
}
2016-02-26 00:20:09 +00:00
$routerSwitch [] = " \t \t \t \t \t if( \$ id) " ;
$routerSwitch [] = " \t \t \t \t \t { " ;
$routerSwitch [] = " \t \t \t \t \t \t \$ vars['id'] = \$ id; " ;
$routerSwitch [] = " \t \t \t \t \t } " ;
$routerSwitch [] = " \t \t \t \t } " ;
$routerSwitch [] = " \t \t \t \t break; " ;
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $routerSwitch );
2016-02-26 00:20:09 +00:00
}
2017-02-09 16:11:10 +00:00
elseif ( $idView )
2016-02-26 00:20:09 +00:00
{
// build view route switch
$routerSwitch = array ();
2017-12-14 23:10:47 +00:00
$routerSwitch [] = PHP_EOL . " \t \t \t case ' " . $view . " ': " ;
$routerSwitch [] = " \t \t \t \t \$ vars['view'] = ' " . $view . " '; " ;
2017-02-09 16:11:10 +00:00
$routerSwitch [] = " \t \t \t \t if (is_numeric( \$ segments[ \$ count-1])) " ;
$routerSwitch [] = " \t \t \t \t { " ;
$routerSwitch [] = " \t \t \t \t \t \$ vars['id'] = (int) \$ segments[ \$ count-1]; " ;
$routerSwitch [] = " \t \t \t \t } " ;
$routerSwitch [] = " \t \t \t \t break; " ;
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $routerSwitch );
2017-02-09 16:11:10 +00:00
}
else
{
// build view route switch
$routerSwitch = array ();
2017-12-14 23:10:47 +00:00
$routerSwitch [] = PHP_EOL . " \t \t \t case ' " . $view . " ': " ;
$routerSwitch [] = " \t \t \t \t \$ vars['view'] = ' " . $view . " '; " ;
2016-02-26 00:20:09 +00:00
$routerSwitch [] = " \t \t \t \t break; " ;
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $routerSwitch );
2016-02-26 00:20:09 +00:00
}
return '' ;
}
2017-12-14 23:10:47 +00:00
2016-09-11 15:27:04 +00:00
public function routerBuildViews ( & $view )
2016-02-26 00:20:09 +00:00
{
if ( isset ( $this -> fileContentStatic [ '###ROUTER_BUILD_VIEWS###' ]) && ComponentbuilderHelper :: checkString ( $this -> fileContentStatic [ '###ROUTER_BUILD_VIEWS###' ]))
{
2017-12-14 23:10:47 +00:00
return " || \$ view === ' " . $view . " ' " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
return " \$ view === ' " . $view . " ' " ;
2016-02-26 00:20:09 +00:00
}
}
public function setBatchMove ( $viewName_single )
{
// set needed defaults
2017-12-14 23:10:47 +00:00
$title = false ;
$alias = false ;
$category = false ;
$batchmove = array ();
$VIEW = ComponentbuilderHelper :: safeString ( $viewName_single , 'U' );
2016-02-26 00:20:09 +00:00
// component helper name
2017-12-14 23:10:47 +00:00
$Helper = $this -> fileContentStatic [ '###Component###' ] . 'Helper' ;
2016-02-26 00:20:09 +00:00
// setup correct core target
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $viewName_single ]))
{
$core = $this -> permissionCore [ $viewName_single ];
$coreLoad = true ;
}
// only load category if set in this view
if ( array_key_exists ( $viewName_single , $this -> catCodeBuilder ))
{
2017-12-14 23:10:47 +00:00
$category = $this -> catCodeBuilder [ $viewName_single ][ 'code' ];
2016-02-26 00:20:09 +00:00
}
// only load alias if set in this view
if ( array_key_exists ( $viewName_single , $this -> aliasBuilder ))
{
2017-12-14 23:10:47 +00:00
$alias = $this -> aliasBuilder [ $viewName_single ];
2016-02-26 00:20:09 +00:00
}
// only load title if set in this view
if ( array_key_exists ( $viewName_single , $this -> titleBuilder ))
{
2017-12-14 23:10:47 +00:00
$title = $this -> titleBuilder [ $viewName_single ];
2016-02-26 00:20:09 +00:00
}
// prepare custom script
2017-12-14 23:10:47 +00:00
$customScript = $this -> getCustomScriptBuilder ( 'php_batchmove' , $viewName_single , PHP_EOL . PHP_EOL , null , true );
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$batchmove [] = PHP_EOL . " \t /** " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t * Batch move items to a new category " ;
$batchmove [] = " \t * " ;
$batchmove [] = " \t * @param integer \$ value The new category ID. " ;
$batchmove [] = " \t * @param array \$ pks An array of row IDs. " ;
$batchmove [] = " \t * @param array \$ contexts An array of item contexts. " ;
$batchmove [] = " \t * " ;
$batchmove [] = " \t * @return boolean True if successful, false otherwise and internal error is set. " ;
$batchmove [] = " \t * " ;
$batchmove [] = " \t * @since \t 12.2 " ;
$batchmove [] = " \t */ " ;
2016-02-26 12:46:15 +00:00
$batchmove [] = " \t protected function batchMove( \$ values, \$ pks, \$ contexts) " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t { " ;
$batchmove [] = " \t \t if (empty( \$ this->batchSet)) " ;
$batchmove [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Set some needed variables. " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t \t \$ this->user = JFactory::getUser(); " ;
$batchmove [] = " \t \t \t \$ this->table = \$ this->getTable(); " ;
$batchmove [] = " \t \t \t \$ this->tableClassName = get_class( \$ this->table); " ;
$batchmove [] = " \t \t \t \$ this->contentType = new JUcmType; " ;
$batchmove [] = " \t \t \t \$ this->type = \$ this->contentType->getTypeByTable( \$ this->tableClassName); " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = " \t \t \t \$ this->canDo = " . $Helper . " ::getActions(' " . $viewName_single . " '); " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$batchmove [] = PHP_EOL . " \t \t if (! \$ this->canDo->get(' " . $core [ 'core.edit' ] . " ') && ! \$ this->canDo->get(' " . $core [ 'core.batch' ] . " ')) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$batchmove [] = PHP_EOL . " \t \t if (! \$ this->canDo->get('core.edit') && ! \$ this->canDo->get('core.batch')) " ;
2016-02-26 00:20:09 +00:00
}
$batchmove [] = " \t \t { " ;
$batchmove [] = " \t \t \t \$ this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); " ;
$batchmove [] = " \t \t \t return false; " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = " \t \t } " . $customScript ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$batchmove [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " make sure published only updates if user has the permission. " ;
if ( $coreLoad && isset ( $core [ 'core.edit.state' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.state' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.state' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.state' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$batchmove [] = " \t \t if (isset( \$ values['published']) && ! \$ this->canDo->get(' " . $core [ 'core.edit.state' ] . " ')) " ;
2016-02-26 00:20:09 +00:00
}
else
{
$batchmove [] = " \t \t if (isset( \$ values['published']) && ! \$ this->canDo->get('core.edit.state')) " ;
}
$batchmove [] = " \t \t { " ;
$batchmove [] = " \t \t \t unset( \$ values['published']); " ;
$batchmove [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " remove move_copy from array " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t unset( \$ values['move_copy']); " ;
if ( $category )
{
2017-12-14 23:10:47 +00:00
$batchmove [] = PHP_EOL . " \t \t if (isset( \$ values['category']) && (int) \$ values['category'] > 0 && !static::checkCategoryId( \$ values['category'])) " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t { " ;
$batchmove [] = " \t \t \t return false; " ;
$batchmove [] = " \t \t } " ;
$batchmove [] = " \t \t elseif (isset( \$ values['category']) && (int) \$ values['category'] > 0) " ;
$batchmove [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " move the category value to correct field name " ;
$batchmove [] = " \t \t \t \$ values[' " . $category . " '] = \$ values['category']; " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t \t unset( \$ values['category']); " ;
$batchmove [] = " \t \t } " ;
$batchmove [] = " \t \t elseif (isset( \$ values['category'])) " ;
$batchmove [] = " \t \t { " ;
$batchmove [] = " \t \t \t unset( \$ values['category']); " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = " \t \t } " . PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$batchmove [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Parent exists so we proceed " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t foreach ( \$ pks as \$ pk) " ;
$batchmove [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit' ]) && isset ( $this -> permissionBuilder [ $core [ 'core.edit' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $core [ 'core.edit' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ $core [ 'core.edit' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$batchmove [] = " \t \t \t if (! \$ this->user->authorise(' " . $core [ 'core.edit' ] . " ', \$ contexts[ \$ pk])) " ;
2016-02-26 00:20:09 +00:00
}
else
{
$batchmove [] = " \t \t \t if (! \$ this->user->authorise('core.edit', \$ contexts[ \$ pk])) " ;
}
$batchmove [] = " \t \t \t { " ;
$batchmove [] = " \t \t \t \t \$ this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = PHP_EOL . " \t \t \t \t return false; " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Check that the row actually exists " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t \t if (! \$ this->table->load( \$ pk)) " ;
$batchmove [] = " \t \t \t { " ;
$batchmove [] = " \t \t \t \t if ( \$ error = \$ this->table->getError()) " ;
$batchmove [] = " \t \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Fatal error " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t \t \t \t \$ this->setError( \$ error); " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = PHP_EOL . " \t \t \t \t \t return false; " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t \t \t } " ;
$batchmove [] = " \t \t \t \t else " ;
$batchmove [] = " \t \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Not fatal error " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t \t \t \t \$ this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', \$ pk)); " ;
$batchmove [] = " \t \t \t \t \t continue; " ;
$batchmove [] = " \t \t \t \t } " ;
$batchmove [] = " \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " insert all set values. " ;
$batchmove [] = " \t \t \t if ( " . $Helper . " ::checkArray( \$ values)) " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t \t { " ;
$batchmove [] = " \t \t \t \t foreach ( \$ values as \$ key => \$ value) " ;
$batchmove [] = " \t \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Do special action for access. " ;
2017-02-02 11:54:07 +00:00
$batchmove [] = " \t \t \t \t \t if ('access' === \$ key && strlen( \$ value) > 0) " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t \t \t \t { " ;
$batchmove [] = " \t \t \t \t \t \t \$ this->table-> \$ key = \$ value; " ;
$batchmove [] = " \t \t \t \t \t } " ;
$batchmove [] = " \t \t \t \t \t elseif (strlen( \$ value) > 0 && isset( \$ this->table-> \$ key)) " ;
$batchmove [] = " \t \t \t \t \t { " ;
$batchmove [] = " \t \t \t \t \t \t \$ this->table-> \$ key = \$ value; " ;
$batchmove [] = " \t \t \t \t \t } " ;
$batchmove [] = " \t \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = " \t \t \t } " . PHP_EOL ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$batchmove [] = PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Check the row. " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t \t if (! \$ this->table->check()) " ;
$batchmove [] = " \t \t \t { " ;
$batchmove [] = " \t \t \t \t \$ this->setError( \$ this->table->getError()); " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = PHP_EOL . " \t \t \t \t return false; " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = PHP_EOL . " \t \t \t if (!empty( \$ this->type)) " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t \t { " ;
$batchmove [] = " \t \t \t \t \$ this->createTagsHelper( \$ this->tagsObserver, \$ this->type, \$ pk, \$ this->typeAlias, \$ this->table); " ;
$batchmove [] = " \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Store the row. " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t \t if (! \$ this->table->store()) " ;
$batchmove [] = " \t \t \t { " ;
$batchmove [] = " \t \t \t \t \$ this->setError( \$ this->table->getError()); " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = PHP_EOL . " \t \t \t \t return false; " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t \t } " ;
$batchmove [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Clean the cache " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t \t \$ this->cleanCache(); " ;
2017-12-14 23:10:47 +00:00
$batchmove [] = PHP_EOL . " \t \t return true; " ;
2016-02-26 00:20:09 +00:00
$batchmove [] = " \t } " ;
2017-12-14 23:10:47 +00:00
return PHP_EOL . implode ( PHP_EOL , $batchmove );
2016-02-26 00:20:09 +00:00
}
public function setBatchCopy ( $viewName_single )
{
// set needed defaults
2017-12-14 23:10:47 +00:00
$title = false ;
$alias = false ;
$category = false ;
$batchcopy = array ();
$VIEW = ComponentbuilderHelper :: safeString ( $viewName_single , 'U' );
2016-02-26 00:20:09 +00:00
// component helper name
2017-12-14 23:10:47 +00:00
$Helper = $this -> fileContentStatic [ '###Component###' ] . 'Helper' ;
2016-02-26 00:20:09 +00:00
// setup correct core target
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $viewName_single ]))
{
$core = $this -> permissionCore [ $viewName_single ];
$coreLoad = true ;
}
// only load category if set in this view
if ( array_key_exists ( $viewName_single , $this -> catCodeBuilder ))
{
$category = $this -> catCodeBuilder [ $viewName_single ][ 'code' ];
}
// only load alias if set in this view
if ( array_key_exists ( $viewName_single , $this -> aliasBuilder ))
{
$alias = $this -> aliasBuilder [ $viewName_single ];
}
// only load title if set in this view
if ( array_key_exists ( $viewName_single , $this -> titleBuilder ))
{
$title = $this -> titleBuilder [ $viewName_single ];
}
// prepare custom script
2017-12-14 23:10:47 +00:00
$customScript = $this -> getCustomScriptBuilder ( 'php_batchcopy' , $viewName_single , PHP_EOL . PHP_EOL , null , true );
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t /** " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t * Batch copy items to a new category or current. " ;
$batchcopy [] = " \t * " ;
$batchcopy [] = " \t * @param integer \$ values The new values. " ;
$batchcopy [] = " \t * @param array \$ pks An array of row IDs. " ;
$batchcopy [] = " \t * @param array \$ contexts An array of item contexts. " ;
$batchcopy [] = " \t * " ;
$batchcopy [] = " \t * @return mixed An array of new IDs on success, boolean false on failure. " ;
$batchcopy [] = " \t * " ;
$batchcopy [] = " \t * @since \t 12.2 " ;
$batchcopy [] = " \t */ " ;
2016-02-26 12:46:15 +00:00
$batchcopy [] = " \t protected function batchCopy( \$ values, \$ pks, \$ contexts) " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t { " ;
$batchcopy [] = " \t \t if (empty( \$ this->batchSet)) " ;
$batchcopy [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Set some needed variables. " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t \$ this->user = JFactory::getUser(); " ;
$batchcopy [] = " \t \t \t \$ this->table = \$ this->getTable(); " ;
$batchcopy [] = " \t \t \t \$ this->tableClassName = get_class( \$ this->table); " ;
$batchcopy [] = " \t \t \t \$ this->contentType = new JUcmType; " ;
$batchcopy [] = " \t \t \t \$ this->type = \$ this->contentType->getTypeByTable( \$ this->tableClassName); " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = " \t \t \t \$ this->canDo = " . $Helper . " ::getActions(' " . $viewName_single . " '); " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.create' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t if (! \$ this->canDo->get(' " . $core [ 'core.create' ] . " ') && ! \$ this->canDo->get(' " . $core [ 'core.batch' ] . " ')) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t if (! \$ this->canDo->get('core.create') || ! \$ this->canDo->get('core.batch')) " ;
2016-02-26 00:20:09 +00:00
}
$batchcopy [] = " \t \t { " ;
$batchcopy [] = " \t \t \t return false; " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = " \t \t } " . $customScript ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " get list of uniqe fields " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \$ uniqeFields = \$ this->getUniqeFields(); " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " remove move_copy from array " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t unset( \$ values['move_copy']); " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " make sure published is set " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t if (!isset( \$ values['published'])) " ;
$batchcopy [] = " \t \t { " ;
$batchcopy [] = " \t \t \t \$ values['published'] = 0; " ;
$batchcopy [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit.state' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.state' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.state' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.state' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$batchcopy [] = " \t \t elseif (isset( \$ values['published']) && ! \$ this->canDo->get(' " . $core [ 'core.edit.state' ] . " ')) " ;
2016-02-26 00:20:09 +00:00
}
else
{
$batchcopy [] = " \t \t elseif (isset( \$ values['published']) && ! \$ this->canDo->get('core.edit.state')) " ;
}
$batchcopy [] = " \t \t { " ;
$batchcopy [] = " \t \t \t \t \$ values['published'] = 0; " ;
$batchcopy [] = " \t \t } " ;
if ( $category )
{
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t if (isset( \$ values['category']) && (int) \$ values['category'] > 0 && !static::checkCategoryId( \$ values['category'])) " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t { " ;
$batchcopy [] = " \t \t \t return false; " ;
$batchcopy [] = " \t \t } " ;
$batchcopy [] = " \t \t elseif (isset( \$ values['category']) && (int) \$ values['category'] > 0) " ;
$batchcopy [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " move the category value to correct field name " ;
$batchcopy [] = " \t \t \t \$ values[' " . $category . " '] = \$ values['category']; " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t unset( \$ values['category']); " ;
$batchcopy [] = " \t \t } " ;
$batchcopy [] = " \t \t elseif (isset( \$ values['category'])) " ;
$batchcopy [] = " \t \t { " ;
$batchcopy [] = " \t \t \t unset( \$ values['category']); " ;
$batchcopy [] = " \t \t } " ;
}
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \$ newIds = array(); " ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Parent exists so let's proceed " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t while (!empty( \$ pks)) " ;
$batchcopy [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Pop the first ID off the stack " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t \$ pk = array_shift( \$ pks); " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t \$ this->table->reset(); " ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " only allow copy if user may edit this item. " ;
if ( $coreLoad && isset ( $core [ 'core.edit' ]) && isset ( $this -> permissionBuilder [ $core [ 'core.edit' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $core [ 'core.edit' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ $core [ 'core.edit' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t if (! \$ this->user->authorise(' " . $core [ 'core.edit' ] . " ', \$ contexts[ \$ pk])) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t if (! \$ this->user->authorise('core.edit', \$ contexts[ \$ pk])) " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t { " ;
$batchcopy [] = PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Not fatal error " ;
$batchcopy [] = PHP_EOL . " \t \t \t \t \$ this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', \$ pk)); " ;
$batchcopy [] = PHP_EOL . " \t \t \t \t continue; " ;
$batchcopy [] = PHP_EOL . " \t \t \t } " ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Check that the row actually exists " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t if (! \$ this->table->load( \$ pk)) " ;
$batchcopy [] = " \t \t \t { " ;
$batchcopy [] = " \t \t \t \t if ( \$ error = \$ this->table->getError()) " ;
$batchcopy [] = " \t \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Fatal error " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t \t \t \$ this->setError( \$ error); " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t \t \t return false; " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t \t } " ;
$batchcopy [] = " \t \t \t \t else " ;
$batchcopy [] = " \t \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Not fatal error " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t \t \t \$ this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', \$ pk)); " ;
$batchcopy [] = " \t \t \t \t \t continue; " ;
$batchcopy [] = " \t \t \t \t } " ;
$batchcopy [] = " \t \t \t } " ;
2017-02-01 13:17:04 +00:00
if ( $category && $alias === 'alias' && $title === 'title' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t if (isset( \$ values[' " . $category . " '])) " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = " \t \t \t \t static::generateTitle((int) \$ values[' " . $category . " '], \$ this->table); " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t } " ;
$batchcopy [] = " \t \t \t else " ;
$batchcopy [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = " \t \t \t \t static::generateTitle((int) \$ this->table-> " . $category . " , \$ this->table); " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t } " ;
}
elseif ( $category && $alias && $title )
{
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t if (isset( \$ values[' " . $category . " '])) " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = " \t \t \t \t list( \$ this->table-> " . $title . " , \$ this->table-> " . $alias . " ) = \$ this->generateNewTitle( \$ values[' " . $category . " '], \$ this->table-> " . $alias . " , \$ this->table-> " . $title . " ); " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t } " ;
$batchcopy [] = " \t \t \t else " ;
$batchcopy [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = " \t \t \t \t list( \$ this->table-> " . $title . " , \$ this->table-> " . $alias . " ) = \$ this->generateNewTitle( \$ this->table-> " . $category . " , \$ this->table-> " . $alias . " , \$ this->table-> " . $title . " ); " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t } " ;
}
elseif ( ! $category && $alias && $title )
{
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t list( \$ this->table-> " . $title . " , \$ this->table-> " . $alias . " ) = \$ this->_generateNewTitle( \$ this->table-> " . $alias . " , \$ this->table-> " . $title . " ); " ;
2016-02-26 00:20:09 +00:00
}
2016-05-31 05:11:07 +00:00
elseif ( ! $category && ! $alias && $title && $title != 'user' && $title != 'jobnumber' ) // TODO [jobnumber] just for one project (not ideal)
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t \$ this->table-> " . $title . " = \$ this->generateUniqe(' " . $title . " ', \$ this->table-> " . $title . " ); " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " insert all set values " ;
$batchcopy [] = " \t \t \t if ( " . $Helper . " ::checkArray( \$ values)) " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t { " ;
$batchcopy [] = " \t \t \t \t foreach ( \$ values as \$ key => \$ value) " ;
$batchcopy [] = " \t \t \t \t { " ;
$batchcopy [] = " \t \t \t \t \t if (strlen( \$ value) > 0 && isset( \$ this->table-> \$ key)) " ;
$batchcopy [] = " \t \t \t \t \t { " ;
$batchcopy [] = " \t \t \t \t \t \t \$ this->table-> \$ key = \$ value; " ;
$batchcopy [] = " \t \t \t \t \t } " ;
$batchcopy [] = " \t \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = " \t \t \t } " . PHP_EOL ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$batchcopy [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " update all uniqe fields " ;
$batchcopy [] = " \t \t \t if ( " . $Helper . " ::checkArray( \$ uniqeFields)) " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t { " ;
$batchcopy [] = " \t \t \t \t foreach ( \$ uniqeFields as \$ uniqeField) " ;
$batchcopy [] = " \t \t \t \t { " ;
$batchcopy [] = " \t \t \t \t \t \$ this->table-> \$ uniqeField = \$ this->generateUniqe( \$ uniqeField, \$ this->table-> \$ uniqeField); " ;
$batchcopy [] = " \t \t \t \t } " ;
$batchcopy [] = " \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Reset the ID because we are making a copy " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t \$ this->table->id = 0; " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " TODO: Deal with ordering? " ;
$batchcopy [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " \$ this->table->ordering \t = 1; " ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Check the row. " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t if (! \$ this->table->check()) " ;
$batchcopy [] = " \t \t \t { " ;
$batchcopy [] = " \t \t \t \t \$ this->setError( \$ this->table->getError()); " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t \t return false; " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t if (!empty( \$ this->type)) " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t { " ;
$batchcopy [] = " \t \t \t \t \$ this->createTagsHelper( \$ this->tagsObserver, \$ this->type, \$ pk, \$ this->typeAlias, \$ this->table); " ;
$batchcopy [] = " \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Store the row. " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t if (! \$ this->table->store()) " ;
$batchcopy [] = " \t \t \t { " ;
$batchcopy [] = " \t \t \t \t \$ this->setError( \$ this->table->getError()); " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t \t return false; " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Get the new item ID " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t \$ newId = \$ this->table->get('id'); " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Add the new ID to the array " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \t \$ newIds[ \$ pk] = \$ newId; " ;
$batchcopy [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Clean the cache " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t \t \$ this->cleanCache(); " ;
2017-12-14 23:10:47 +00:00
$batchcopy [] = PHP_EOL . " \t \t return \$ newIds; " ;
2016-02-26 00:20:09 +00:00
$batchcopy [] = " \t } " ;
2017-12-14 23:10:47 +00:00
return PHP_EOL . implode ( PHP_EOL , $batchcopy );
2016-02-26 00:20:09 +00:00
}
public function setAliasTitleFix ( $viewName_single )
{
$fixUniqe = array ();
// only load this if these two items are set
if ( array_key_exists ( $viewName_single , $this -> aliasBuilder ) && array_key_exists ( $viewName_single , $this -> titleBuilder ))
{
// set needed defaults
2017-12-14 23:10:47 +00:00
$setCategory = false ;
$alias = $this -> aliasBuilder [ $viewName_single ];
$title = $this -> titleBuilder [ $viewName_single ];
$VIEW = ComponentbuilderHelper :: safeString ( $viewName_single , 'U' );
2016-02-26 00:20:09 +00:00
if ( array_key_exists ( $viewName_single , $this -> catCodeBuilder ))
{
2017-12-14 23:10:47 +00:00
$category = $this -> catCodeBuilder [ $viewName_single ][ 'code' ];
$setCategory = true ;
2016-02-26 00:20:09 +00:00
}
// start building the fix
2017-12-14 23:10:47 +00:00
$fixUniqe [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Alter the " . $title . " for save as copy " ;
2017-02-01 13:17:04 +00:00
$fixUniqe [] = " \t \t if ( \$ input->get('task') === 'save2copy') " ;
2016-02-26 00:20:09 +00:00
$fixUniqe [] = " \t \t { " ;
$fixUniqe [] = " \t \t \t \$ origTable = clone \$ this->getTable(); " ;
$fixUniqe [] = " \t \t \t \$ origTable->load( \$ input->getInt('id')); " ;
2017-12-14 23:10:47 +00:00
$fixUniqe [] = PHP_EOL . " \t \t \t if ( \$ data[' " . $title . " '] == \$ origTable-> " . $title . " ) " ;
2016-02-26 00:20:09 +00:00
$fixUniqe [] = " \t \t \t { " ;
if ( $setCategory )
{
2017-12-14 23:10:47 +00:00
$fixUniqe [] = " \t \t \t \t list( \$ " . $title . " , \$ " . $alias . " ) = \$ this->generateNewTitle( \$ data[' " . $category . " '], \$ data[' " . $alias . " '], \$ data[' " . $title . " ']); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$fixUniqe [] = " \t \t \t \t list( \$ " . $title . " , \$ " . $alias . " ) = \$ this->_generateNewTitle( \$ data[' " . $alias . " '], \$ data[' " . $title . " ']); " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$fixUniqe [] = " \t \t \t \t \$ data[' " . $title . " '] = \$ " . $title . " ; " ;
$fixUniqe [] = " \t \t \t \t \$ data[' " . $alias . " '] = \$ " . $alias . " ; " ;
2016-02-26 00:20:09 +00:00
$fixUniqe [] = " \t \t \t } " ;
$fixUniqe [] = " \t \t \t else " ;
$fixUniqe [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$fixUniqe [] = " \t \t \t \t if ( \$ data[' " . $alias . " '] == \$ origTable-> " . $alias . " ) " ;
2016-02-26 00:20:09 +00:00
$fixUniqe [] = " \t \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$fixUniqe [] = " \t \t \t \t \t \$ data[' " . $alias . " '] = ''; " ;
2016-02-26 00:20:09 +00:00
$fixUniqe [] = " \t \t \t \t } " ;
$fixUniqe [] = " \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$fixUniqe [] = PHP_EOL . " \t \t \t \$ data['published'] = 0; " ;
2016-02-26 00:20:09 +00:00
$fixUniqe [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$fixUniqe [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Automatic handling of " . $alias . " for empty fields " ;
2016-02-26 00:20:09 +00:00
$fixUniqe [] = " \t \t if (in_array( \$ input->get('task'), array('apply', 'save', 'save2new')) && (int) \$ input->get('id') == 0) " ;
$fixUniqe [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$fixUniqe [] = " \t \t \t if ( \$ data[' " . $alias . " '] == null) " ;
2016-02-26 00:20:09 +00:00
$fixUniqe [] = " \t \t \t { " ;
$fixUniqe [] = " \t \t \t \t if (JFactory::getConfig()->get('unicodeslugs') == 1) " ;
$fixUniqe [] = " \t \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$fixUniqe [] = " \t \t \t \t \t \$ data[' " . $alias . " '] = JFilterOutput::stringURLUnicodeSlug( \$ data[' " . $title . " ']); " ;
2016-02-26 00:20:09 +00:00
$fixUniqe [] = " \t \t \t \t } " ;
$fixUniqe [] = " \t \t \t \t else " ;
$fixUniqe [] = " \t \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$fixUniqe [] = " \t \t \t \t \t \$ data[' " . $alias . " '] = JFilterOutput::stringURLSafe( \$ data[' " . $title . " ']); " ;
2016-02-26 00:20:09 +00:00
$fixUniqe [] = " \t \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$fixUniqe [] = PHP_EOL . " \t \t \t \t \$ table = JTable::getInstance(' " . $viewName_single . " ', ' " . $this -> fileContentStatic [ '###component###' ] . " Table'); " ;
2016-02-26 00:20:09 +00:00
if ( $setCategory )
{
2017-12-14 23:10:47 +00:00
$fixUniqe [] = PHP_EOL . " \t \t \t \t if ( \$ table->load(array(' " . $alias . " ' => \$ data[' " . $alias . " '], ' " . $category . " ' => \$ data[' " . $category . " '])) && ( \$ table->id != \$ data['id'] || \$ data['id'] == 0)) " ;
2016-02-26 00:20:09 +00:00
$fixUniqe [] = " \t \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$fixUniqe [] = " \t \t \t \t \t \$ msg = JText::_('COM_ " . $this -> fileContentStatic [ '###COMPONENT###' ] . " _ " . $VIEW . " _SAVE_WARNING'); " ;
2016-02-26 00:20:09 +00:00
$fixUniqe [] = " \t \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$fixUniqe [] = PHP_EOL . " \t \t \t \t list( \$ " . $title . " , \$ " . $alias . " ) = \$ this->generateNewTitle( \$ data[' " . $category . " '], \$ data[' " . $alias . " '], \$ data[' " . $title . " ']); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$fixUniqe [] = PHP_EOL . " \t \t \t \t if ( \$ table->load(array(' " . $alias . " ' => \$ data[' " . $alias . " '])) && ( \$ table->id != \$ data['id'] || \$ data['id'] == 0)) " ;
2016-02-26 00:20:09 +00:00
$fixUniqe [] = " \t \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$fixUniqe [] = " \t \t \t \t \t \$ msg = JText::_('COM_ " . $this -> fileContentStatic [ '###COMPONENT###' ] . " _ " . $VIEW . " _SAVE_WARNING'); " ;
2016-02-26 00:20:09 +00:00
$fixUniqe [] = " \t \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$fixUniqe [] = PHP_EOL . " \t \t \t \t list( \$ " . $title . " , \$ " . $alias . " ) = \$ this->_generateNewTitle( \$ data[' " . $alias . " '], \$ data[' " . $title . " ']); " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$fixUniqe [] = " \t \t \t \t \$ data[' " . $alias . " '] = \$ " . $alias . " ; " ;
$fixUniqe [] = PHP_EOL . " \t \t \t \t if (isset( \$ msg)) " ;
2016-02-26 00:20:09 +00:00
$fixUniqe [] = " \t \t \t \t { " ;
$fixUniqe [] = " \t \t \t \t \t JFactory::getApplication()->enqueueMessage( \$ msg, 'warning'); " ;
$fixUniqe [] = " \t \t \t \t } " ;
$fixUniqe [] = " \t \t \t } " ;
$fixUniqe [] = " \t \t } " ;
}
// handel other uniqe fields
2017-12-14 23:10:47 +00:00
$fixUniqe [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Alter the uniqe field for save as copy " ;
2017-02-01 13:17:04 +00:00
$fixUniqe [] = " \t \t if ( \$ input->get('task') === 'save2copy') " ;
2016-02-26 00:20:09 +00:00
$fixUniqe [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$fixUniqe [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Automatic handling of other uniqe fields " ;
2016-02-26 00:20:09 +00:00
$fixUniqe [] = " \t \t \t \$ uniqeFields = \$ this->getUniqeFields(); " ;
2017-12-14 23:10:47 +00:00
$fixUniqe [] = " \t \t \t if ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ uniqeFields)) " ;
2016-02-26 00:20:09 +00:00
$fixUniqe [] = " \t \t \t { " ;
$fixUniqe [] = " \t \t \t \t foreach ( \$ uniqeFields as \$ uniqeField) " ;
$fixUniqe [] = " \t \t \t \t { " ;
$fixUniqe [] = " \t \t \t \t \t \$ data[ \$ uniqeField] = \$ this->generateUniqe( \$ uniqeField, \$ data[ \$ uniqeField]); " ;
$fixUniqe [] = " \t \t \t \t } " ;
$fixUniqe [] = " \t \t \t } " ;
$fixUniqe [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
return PHP_EOL . implode ( PHP_EOL , $fixUniqe );
2016-02-26 00:20:09 +00:00
}
public function setGenerateNewTitle ( $viewName_single )
{
// if category is added to this view then do nothing
if ( array_key_exists ( $viewName_single , $this -> aliasBuilder ) && array_key_exists ( $viewName_single , $this -> titleBuilder ))
{
$newFunction = array ();
2017-12-14 23:10:47 +00:00
$newFunction [] = PHP_EOL . PHP_EOL . " \t /** " ;
2016-02-26 00:20:09 +00:00
$newFunction [] = " \t * Method to change the title & alias. " ;
$newFunction [] = " \t * " ;
$newFunction [] = " \t * @param string \$ alias The alias. " ;
$newFunction [] = " \t * @param string \$ title The title. " ;
2017-12-14 23:10:47 +00:00
$newFunction [] = " \t * " ;
$newFunction [] = " \t * @return array Contains the modified title and alias. " ;
$newFunction [] = " \t * " ;
2016-02-26 00:20:09 +00:00
$newFunction [] = " \t */ " ;
2016-02-26 12:46:15 +00:00
$newFunction [] = " \t protected function _generateNewTitle( \$ alias, \$ title) " ;
2016-02-26 00:20:09 +00:00
$newFunction [] = " \t { " ;
2017-12-14 23:10:47 +00:00
$newFunction [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Alter the title & alias " ;
2016-02-26 00:20:09 +00:00
$newFunction [] = " \t \t \$ table = \$ this->getTable(); " ;
2017-12-14 23:10:47 +00:00
$newFunction [] = PHP_EOL . " \t \t while ( \$ table->load(array('alias' => \$ alias))) " ;
2016-02-26 00:20:09 +00:00
$newFunction [] = " \t \t { " ;
$newFunction [] = " \t \t \t \$ title = JString::increment( \$ title); " ;
$newFunction [] = " \t \t \t \$ alias = JString::increment( \$ alias, 'dash'); " ;
$newFunction [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$newFunction [] = PHP_EOL . " \t \t return array( \$ title, \$ alias); " ;
2016-02-26 00:20:09 +00:00
$newFunction [] = " \t } " ;
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $newFunction );
2016-02-26 00:20:09 +00:00
}
elseif ( array_key_exists ( $viewName_single , $this -> titleBuilder ))
{
$newFunction = array ();
2017-12-14 23:10:47 +00:00
$newFunction [] = PHP_EOL . PHP_EOL . " \t /** " ;
2016-02-26 00:20:09 +00:00
$newFunction [] = " \t * Method to change the title & alias. " ;
$newFunction [] = " \t * " ;
$newFunction [] = " \t * @param string \$ title The title. " ;
2017-12-14 23:10:47 +00:00
$newFunction [] = " \t * " ;
$newFunction [] = " \t * @return array Contains the modified title and alias. " ;
$newFunction [] = " \t * " ;
2016-02-26 00:20:09 +00:00
$newFunction [] = " \t */ " ;
2016-02-26 12:46:15 +00:00
$newFunction [] = " \t protected function _generateNewTitle( \$ title) " ;
2016-02-26 00:20:09 +00:00
$newFunction [] = " \t { " ;
2017-12-14 23:10:47 +00:00
$newFunction [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Alter the title " ;
2016-02-26 00:20:09 +00:00
$newFunction [] = " \t \t \$ table = \$ this->getTable(); " ;
2017-12-14 23:10:47 +00:00
$newFunction [] = PHP_EOL . " \t \t while ( \$ table->load(array('title' => \$ title))) " ;
2016-02-26 00:20:09 +00:00
$newFunction [] = " \t \t { " ;
$newFunction [] = " \t \t \t \$ title = JString::increment( \$ title); " ;
$newFunction [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$newFunction [] = PHP_EOL . " \t \t return \$ title; " ;
2016-02-26 00:20:09 +00:00
$newFunction [] = " \t } " ;
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $newFunction );
2016-02-26 00:20:09 +00:00
}
return '' ;
}
public function setInstall ()
{
if ( isset ( $this -> queryBuilder ) && ComponentbuilderHelper :: checkArray ( $this -> queryBuilder ))
{
// set the main db prefix
$component = $this -> fileContentStatic [ '###component###' ];
// start building the db
$db = '' ;
foreach ( $this -> queryBuilder as $view => $fields )
{
// build the uninstall array
2017-12-14 23:10:47 +00:00
$this -> uninstallBuilder [] = " DROP TABLE IF EXISTS `#__ " . $component . " _ " . $view . " `; " ;
2016-02-26 00:20:09 +00:00
2017-06-16 12:38:06 +00:00
// setup the table DB string
$db_ = '' ;
2017-12-14 23:10:47 +00:00
$db_ .= " CREATE TABLE IF NOT EXISTS `#__ " . $component . " _ " . $view . " ` ( " ;
2017-06-16 12:38:06 +00:00
// check if the table name has changed
if ( isset ( $this -> updateSQL [ 'table_name' ]) && isset ( $this -> updateSQL [ 'table_name' ][ $view ]))
{
$old_table_name = $this -> updateSQL [ 'table_name' ][ $view ][ 'old' ];
2017-12-14 23:10:47 +00:00
$this -> updateSQLBuilder [ " RENAMETABLE`#__ " . $component . " _ " . $old_table_name . " ` " ] = " RENAME TABLE `#__ " . $component . " _ " . $old_table_name . " ` to `#__ " . $component . " _ " . $view . " `; " ;
2017-06-16 12:38:06 +00:00
}
2016-06-02 16:18:49 +00:00
// check if default field was over written
if ( ! isset ( $this -> fieldsNames [ $view ][ 'id' ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= PHP_EOL . " \t `id` INT(11) NOT NULL AUTO_INCREMENT, " ;
2016-06-02 16:18:49 +00:00
}
2017-12-14 23:10:47 +00:00
$db_ .= PHP_EOL . " \t `asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.', " ;
2016-02-26 00:20:09 +00:00
ksort ( $fields );
2017-06-16 12:38:06 +00:00
$last_name = 'asset_id' ;
2016-02-26 00:20:09 +00:00
foreach ( $fields as $field => $data )
{
// set default
$default = $data [ 'default' ];
2017-12-14 23:10:47 +00:00
if ( $default === 'Other' )
2016-02-26 00:20:09 +00:00
{
$default = $data [ 'other' ];
}
2017-02-01 13:17:04 +00:00
if ( $default === 'EMPTY' )
2016-09-03 21:44:47 +00:00
{
$default = $data [ 'null_switch' ];
}
2017-02-01 13:17:04 +00:00
elseif ( $default === 'DATETIME' || $default === 'CURRENT_TIMESTAMP' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$default = $default . ' ' . $data [ 'null_switch' ];
2016-02-26 00:20:09 +00:00
}
elseif ( $default == 0 || $default )
{
2017-06-05 20:18:32 +00:00
if ( is_numeric ( $default ))
{
2017-12-14 23:10:47 +00:00
$default = $data [ 'null_switch' ] . " DEFAULT " . $default ;
2017-06-05 20:18:32 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$default = $data [ 'null_switch' ] . " DEFAULT ' " . $default . " ' " ;
2017-06-05 20:18:32 +00:00
}
2016-02-26 00:20:09 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $data [ 'null_switch' ] === 'NULL' )
2016-02-26 00:20:09 +00:00
{
$default = " DEFAULT NULL " ;
}
else
{
2017-12-14 23:10:47 +00:00
$default = $data [ 'null_switch' ] . " DEFAULT '' " ;
2016-02-26 00:20:09 +00:00
}
// set the lenght
$lenght = '' ;
2017-02-01 13:17:04 +00:00
if ( isset ( $data [ 'lenght' ]) && $data [ 'lenght' ] === 'Other' && isset ( $data [ 'lenght_other' ]) && $data [ 'lenght_other' ] > 0 )
2016-05-12 01:26:54 +00:00
{
2017-12-14 23:10:47 +00:00
$lenght = '(' . $data [ 'lenght_other' ] . ')' ;
2016-05-12 01:26:54 +00:00
}
elseif ( isset ( $data [ 'lenght' ]) && $data [ 'lenght' ] > 0 )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$lenght = '(' . $data [ 'lenght' ] . ')' ;
2016-02-26 00:20:09 +00:00
}
// set the field to db
2017-12-14 23:10:47 +00:00
$db_ .= PHP_EOL . " \t ` " . $field . " ` " . $data [ 'type' ] . $lenght . " " . $default . " , " ;
2017-06-16 12:38:06 +00:00
// check if this a new field that should be added via SQL update
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> addSQL [ 'field' ]) && isset ( $this -> addSQL [ 'field' ][ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> addSQL [ 'field' ][ $view ]) && in_array ( $data [ 'ID' ], $this -> addSQL [ 'field' ][ $view ]))
2017-06-16 12:38:06 +00:00
{
2017-12-14 23:10:47 +00:00
$this -> updateSQLBuilder [ " ALTERTABLE`#__ " . $component . " _ " . $view . " `ADD` " . $field . " ` " ] = " ALTER TABLE `#__ " . $component . " _ " . $view . " ` ADD ` " . $field . " ` " . $data [ 'type' ] . $lenght . " " . $default . " AFTER ` " . $last_name . " `; " ;
2017-06-16 12:38:06 +00:00
}
// check if the field has changed name and/or data type and lenght
elseif ( 0 )
{
// hmmm tough one
}
// be sure to track the last name used :)
$last_name = $field ;
2016-02-26 00:20:09 +00:00
}
2016-06-02 16:18:49 +00:00
// check if default field was over written
if ( ! isset ( $this -> fieldsNames [ $view ][ 'params' ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= PHP_EOL . " \t `params` text NOT NULL DEFAULT '', " ;
2016-06-02 16:18:49 +00:00
}
// check if default field was over written
if ( ! isset ( $this -> fieldsNames [ $view ][ 'published' ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= PHP_EOL . " \t `published` TINYINT(3) NOT NULL DEFAULT 1, " ;
2016-06-02 16:18:49 +00:00
}
// check if default field was over written
if ( ! isset ( $this -> fieldsNames [ $view ][ 'created_by' ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= PHP_EOL . " \t `created_by` INT(10) unsigned NOT NULL DEFAULT 0, " ;
2016-06-02 16:18:49 +00:00
}
// check if default field was over written
if ( ! isset ( $this -> fieldsNames [ $view ][ 'modified_by' ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= PHP_EOL . " \t `modified_by` INT(10) unsigned NOT NULL DEFAULT 0, " ;
2016-06-02 16:18:49 +00:00
}
// check if default field was over written
if ( ! isset ( $this -> fieldsNames [ $view ][ 'created' ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= PHP_EOL . " \t `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " ;
2016-06-02 16:18:49 +00:00
}
// check if default field was over written
if ( ! isset ( $this -> fieldsNames [ $view ][ 'modified' ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= PHP_EOL . " \t `modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " ;
2016-06-02 16:18:49 +00:00
}
// check if default field was over written
if ( ! isset ( $this -> fieldsNames [ $view ][ 'checked_out' ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= PHP_EOL . " \t `checked_out` int(11) unsigned NOT NULL DEFAULT 0, " ;
2016-06-02 16:18:49 +00:00
}
// check if default field was over written
if ( ! isset ( $this -> fieldsNames [ $view ][ 'checked_out_time' ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= PHP_EOL . " \t `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " ;
2016-06-02 16:18:49 +00:00
}
// check if default field was over written
if ( ! isset ( $this -> fieldsNames [ $view ][ 'version' ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= PHP_EOL . " \t `version` INT(10) unsigned NOT NULL DEFAULT 1, " ;
2016-06-02 16:18:49 +00:00
}
// check if default field was over written
if ( ! isset ( $this -> fieldsNames [ $view ][ 'hits' ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= PHP_EOL . " \t `hits` INT(10) unsigned NOT NULL DEFAULT 0, " ;
2016-06-02 16:18:49 +00:00
}
2016-02-26 00:20:09 +00:00
// check if view has access
if ( isset ( $this -> accessBuilder [ $view ]) && ComponentbuilderHelper :: checkString ( $this -> accessBuilder [ $view ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= PHP_EOL . " \t `access` INT(10) unsigned NOT NULL DEFAULT 0, " ;
2016-02-26 00:20:09 +00:00
}
2016-06-02 16:18:49 +00:00
// check if default field was over written
if ( ! isset ( $this -> fieldsNames [ $view ][ 'ordering' ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= PHP_EOL . " \t `ordering` INT(11) NOT NULL DEFAULT 0, " ;
2016-06-02 16:18:49 +00:00
}
2016-02-26 00:20:09 +00:00
// check if metadata is added to this view
if ( isset ( $this -> metadataBuilder [ $view ]) && ComponentbuilderHelper :: checkString ( $this -> metadataBuilder [ $view ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= PHP_EOL . " \t `metakey` TEXT NOT NULL DEFAULT '', " ;
$db_ .= PHP_EOL . " \t `metadesc` TEXT NOT NULL DEFAULT '', " ;
$db_ .= PHP_EOL . " \t `metadata` TEXT NOT NULL DEFAULT '', " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$db_ .= PHP_EOL . " \t PRIMARY KEY (`id`) " ;
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> dbUniqueKeys [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> dbUniqueKeys [ $view ]))
{
foreach ( $this -> dbUniqueKeys [ $view ] as $nr => $key )
{
2017-12-14 23:10:47 +00:00
$db_ .= " , " . PHP_EOL . " \t UNIQUE KEY `idx_ " . $key . " ` (` " . $key . " `) " ;
2016-02-26 00:20:09 +00:00
}
}
// check if view has access
if ( isset ( $this -> accessBuilder [ $view ]) && ComponentbuilderHelper :: checkString ( $this -> accessBuilder [ $view ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= " , " . PHP_EOL . " \t KEY `idx_access` (`access`) " ;
2016-02-26 00:20:09 +00:00
}
2016-06-02 16:18:49 +00:00
// check if default field was over written
if ( ! isset ( $this -> fieldsNames [ $view ][ 'checked_out' ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= " , " . PHP_EOL . " \t KEY `idx_checkout` (`checked_out`) " ;
2016-06-02 16:18:49 +00:00
}
// check if default field was over written
if ( ! isset ( $this -> fieldsNames [ $view ][ 'created_by' ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= " , " . PHP_EOL . " \t KEY `idx_createdby` (`created_by`) " ;
2016-06-02 16:18:49 +00:00
}
// check if default field was over written
if ( ! isset ( $this -> fieldsNames [ $view ][ 'modified_by' ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= " , " . PHP_EOL . " \t KEY `idx_modifiedby` (`modified_by`) " ;
2016-06-02 16:18:49 +00:00
}
// check if default field was over written
if ( ! isset ( $this -> fieldsNames [ $view ][ 'published' ]))
{
2017-12-14 23:10:47 +00:00
$db_ .= " , " . PHP_EOL . " \t KEY `idx_state` (`published`) " ;
2016-06-02 16:18:49 +00:00
}
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> dbKeys [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> dbKeys [ $view ]))
{
foreach ( $this -> dbKeys [ $view ] as $nr => $key )
{
2017-12-14 23:10:47 +00:00
$db_ .= " , " . PHP_EOL . " \t KEY `idx_ " . $key . " ` (` " . $key . " `) " ;
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
$db_ .= PHP_EOL . " ) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; " ;
2017-06-16 12:38:06 +00:00
// check if this is a new table that should be added via update SQL
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> addSQL [ 'adminview' ]) && ComponentbuilderHelper :: checkArray ( $this -> addSQL [ 'adminview' ]) && in_array ( $view , $this -> addSQL [ 'adminview' ]))
2017-06-16 12:38:06 +00:00
{
// build the update array
2017-12-14 23:10:47 +00:00
$this -> updateSQLBuilder [ " CREATETABLEIFNOTEXISTS`#__ " . $component . " _ " . $view . " ` " ] = $db_ ;
2017-06-16 12:38:06 +00:00
}
2017-12-14 23:10:47 +00:00
2017-06-16 12:38:06 +00:00
// add to main DB string
2017-12-14 23:10:47 +00:00
$db .= $db_ . PHP_EOL . PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
// add custom sql dump to the file
if ( isset ( $this -> customScriptBuilder [ 'sql' ]) && ComponentbuilderHelper :: checkArray ( $this -> customScriptBuilder [ 'sql' ]))
{
foreach ( $this -> customScriptBuilder [ 'sql' ] as $for => $customSql )
{
$placeholders = array ( '[[[component]]]' => $component , '[[[view]]]' => $for );
2017-12-14 23:10:47 +00:00
$db .= $this -> setPlaceholders ( $customSql , $placeholders ) . PHP_EOL . PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
}
return $db ;
}
return '' ;
}
public function setUninstall ()
{
if ( isset ( $this -> queryBuilder ) && ComponentbuilderHelper :: checkArray ( $this -> queryBuilder ))
{
$bd = '' ;
foreach ( $this -> uninstallBuilder as $line )
{
2017-12-14 23:10:47 +00:00
$bd .= $line . PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
return $bd ;
}
return '' ;
}
public function setLangAdmin ()
{
// add final list of needed lang strings
2016-04-22 12:03:43 +00:00
$componentName = JFilterOutput :: cleanText ( $this -> componentData -> name );
2017-12-14 23:10:47 +00:00
$this -> langContent [ 'adminsys' ][ $this -> langPrefix ] = $componentName ;
$this -> langContent [ 'adminsys' ][ $this -> langPrefix . '_CONFIGURATION' ] = $componentName . ' Configuration' ;
$this -> langContent [ $this -> lang ][ $this -> langPrefix ] = $componentName ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_BACK' ] = 'Back' ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_DASH' ] = 'Dashboard' ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_VERSION' ] = 'Version' ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_DATE' ] = 'Date' ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_AUTHOR' ] = 'Author' ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_WEBSITE' ] = 'Website' ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_LICENSE' ] = 'License' ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_CONTRIBUTORS' ] = 'Contributors' ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_CONTRIBUTOR' ] = 'Contributor' ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_DASHBOARD' ] = $componentName . ' Dashboard' ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_SAVE_SUCCESS' ] = " Great! Item successfully saved. " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_SAVE_WARNING' ] = " The value already existed so please select another. " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_HELP_MANAGER' ] = " Help " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_NEW' ] = " New " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_CLOSE_NEW' ] = " Close & New " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_CREATE_NEW_S' ] = " Create New %s " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_EDIT_S' ] = " Edit %s " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_KEEP_ORIGINAL_STATE' ] = " - Keep Original State - " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_KEEP_ORIGINAL_ACCESS' ] = " - Keep Original Access - " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_KEEP_ORIGINAL_CATEGORY' ] = " - Keep Original Category - " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_PUBLISHED' ] = 'Published' ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_INACTIVE' ] = 'Inactive' ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_ARCHIVED' ] = 'Archived' ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_TRASHED' ] = 'Trashed' ;
2016-02-26 00:20:09 +00:00
if ( $this -> componentData -> add_license && $this -> componentData -> license_type == 3 )
{
2017-12-14 23:10:47 +00:00
$this -> langContent [ 'admin' ][ 'NIE_REG_NIE' ] = " <br /><br /><center><h1>License not set for " . $componentName . " .</h1><p>Notify your administrator!<br />The license can be obtained from " . $this -> componentData -> companyname . " .</p></center> " ;
2016-02-26 00:20:09 +00:00
}
// add the langug files needed to import and export data
if ( $this -> addEximport )
{
2017-12-14 23:10:47 +00:00
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_EXPORT_FAILED' ] = " Export Failed " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_FAILED' ] = " Import Failed " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_TITLE' ] = " Data Importer " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_NO_IMPORT_TYPE_FOUND' ] = " Import type not found. " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE' ] = " Package to import not found. " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_ERROR' ] = " Import error. " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_SUCCESS' ] = " Great! Import successful. " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_MSG_WARNIMPORTFILE' ] = " Warning, import file error. " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_MSG_NO_FILE_SELECTED' ] = " No import file selected. " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_MSG_PLEASE_SELECT_A_FILE' ] = " Please select a file to import. " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_MSG_PLEASE_SELECT_ALL_COLUMNS' ] = " Please link all columns. " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_MSG_PLEASE_SELECT_A_DIRECTORY' ] = " Please enter the file directory. " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_MSG_WARNIMPORTUPLOADERROR' ] = " Warning, import upload error. " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_MSG_PLEASE_ENTER_A_PACKAGE_DIRECTORY' ] = " Please enter the file directory. " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_MSG_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE' ] = " Path does not have a valid file. " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_MSG_DOES_NOT_HAVE_A_VALID_FILE_TYPE' ] = " Does not have a valid file type. " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_MSG_ENTER_A_URL' ] = " Please enter a url. " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_MSG_INVALID_URL' ] = " Invalid url. " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_CONTINUE' ] = " Continue " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_FROM_UPLOAD' ] = " Upload " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_SELECT_FILE' ] = " Select File " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_UPLOAD_BOTTON' ] = " Upload File " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_FROM_DIRECTORY' ] = " Directory " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_SELECT_FILE_DIRECTORY' ] = " Set the path to file " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_GET_BOTTON' ] = " Get File " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_FROM_URL' ] = " URL " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_SELECT_FILE_URL' ] = " Enter file URL " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_UPDATE_DATA' ] = " Import Data " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_FORMATS_ACCEPTED' ] = " formats accepted " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_LINK_FILE_TO_TABLE_COLUMNS' ] = " Link File to Table Columns " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_TABLE_COLUMNS' ] = " Table Columns " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_FILE_COLUMNS' ] = " File Columns " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_PLEASE_SELECT_COLUMN' ] = " -- Please Select Column -- " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_IMPORT_IGNORE_COLUMN' ] = " -- Ignore This Column -- " ;
$this -> langContent [ 'admin' ][ $this -> langPrefix . '_NO_ACCESS_GRANTED' ] = " No Access Granted! " ;
2016-02-26 00:20:09 +00:00
}
// check if the both array is set
if ( isset ( $this -> langContent [ 'both' ]) && ComponentbuilderHelper :: checkArray ( $this -> langContent [ 'both' ]))
{
foreach ( $this -> langContent [ 'both' ] as $keylang => $langval )
{
$this -> langContent [ 'admin' ][ $keylang ] = $langval ;
}
}
2017-09-13 11:59:58 +00:00
// check if the both admin array is set
if ( isset ( $this -> langContent [ 'bothadmin' ]) && ComponentbuilderHelper :: checkArray ( $this -> langContent [ 'bothadmin' ]))
{
foreach ( $this -> langContent [ 'bothadmin' ] as $keylang => $langval )
{
$this -> langContent [ 'admin' ][ $keylang ] = $langval ;
}
}
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> langContent [ 'admin' ]) && ComponentbuilderHelper :: checkArray ( $this -> langContent [ 'admin' ]))
{
ksort ( $this -> langContent [ 'admin' ]);
2017-04-05 13:21:10 +00:00
// load to global languages
$this -> languages [ 'en-GB' ][ 'admin' ] = $this -> langContent [ 'admin' ];
// remove tmp array
unset ( $this -> langContent [ 'admin' ]);
2017-12-14 23:10:47 +00:00
2017-04-05 13:21:10 +00:00
return true ;
2016-02-26 00:20:09 +00:00
}
2017-04-05 13:21:10 +00:00
return false ;
2016-02-26 00:20:09 +00:00
}
public function setLangSite ()
{
// add final list of needed lang strings
2017-12-14 23:10:47 +00:00
$this -> langContent [ 'site' ][ $this -> langPrefix ] = ComponentbuilderHelper :: safeString ( $this -> componentData -> name , 'W' );
2016-02-26 00:20:09 +00:00
// some more defaults
2017-12-14 23:10:47 +00:00
$this -> langContent [ 'site' ][ 'JTOOLBAR_APPLY' ] = " Save " ;
$this -> langContent [ 'site' ][ 'JTOOLBAR_SAVE_AS_COPY' ] = " Save as Copy " ;
$this -> langContent [ 'site' ][ 'JTOOLBAR_SAVE' ] = " Save & Close " ;
$this -> langContent [ 'site' ][ 'JTOOLBAR_SAVE_AND_NEW' ] = " Save & New " ;
$this -> langContent [ 'site' ][ 'JTOOLBAR_CANCEL' ] = " Cancel " ;
$this -> langContent [ 'site' ][ 'JTOOLBAR_CLOSE' ] = " Close " ;
$this -> langContent [ 'site' ][ 'JTOOLBAR_HELP' ] = " Help " ;
$this -> langContent [ 'site' ][ 'JGLOBAL_FIELD_ID_LABEL' ] = " ID " ;
$this -> langContent [ 'site' ][ 'JGLOBAL_FIELD_ID_DESC' ] = " Record number in the database. " ;
$this -> langContent [ 'site' ][ 'JGLOBAL_FIELD_MODIFIED_LABEL' ] = " Modified Date " ;
$this -> langContent [ 'site' ][ 'COM_CONTENT_FIELD_MODIFIED_DESC' ] = " The last date this item was modified. " ;
$this -> langContent [ 'site' ][ 'JGLOBAL_FIELD_MODIFIED_BY_LABEL' ] = " Modified By " ;
$this -> langContent [ 'site' ][ 'JGLOBAL_FIELD_MODIFIED_BY_DESC' ] = " The user who did the last modification. " ;
$this -> langContent [ 'site' ][ $this -> langPrefix . '_NEW' ] = " New " ;
$this -> langContent [ 'site' ][ $this -> langPrefix . '_CREATE_NEW_S' ] = " Create New %s " ;
$this -> langContent [ 'site' ][ $this -> langPrefix . '_EDIT_S' ] = " Edit %s " ;
$this -> langContent [ 'site' ][ $this -> langPrefix . '_NO_ACCESS_GRANTED' ] = " No Access Granted! " ;
2016-02-26 00:20:09 +00:00
// check if the both array is set
if ( isset ( $this -> langContent [ 'both' ]) && ComponentbuilderHelper :: checkArray ( $this -> langContent [ 'both' ]))
{
2017-04-07 20:33:35 +00:00
foreach ( $this -> langContent [ 'both' ] as $keylang => $langval )
2016-02-26 00:20:09 +00:00
{
$this -> langContent [ 'site' ][ $keylang ] = $langval ;
}
}
2017-09-13 11:59:58 +00:00
// check if the both site array is set
if ( isset ( $this -> langContent [ 'bothsite' ]) && ComponentbuilderHelper :: checkArray ( $this -> langContent [ 'bothsite' ]))
{
foreach ( $this -> langContent [ 'bothsite' ] as $keylang => $langval )
{
$this -> langContent [ 'site' ][ $keylang ] = $langval ;
}
}
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> langContent [ 'site' ]) && ComponentbuilderHelper :: checkArray ( $this -> langContent [ 'site' ]))
{
ksort ( $this -> langContent [ 'site' ]);
2017-04-05 13:21:10 +00:00
// load to global languages
$this -> languages [ 'en-GB' ][ 'site' ] = $this -> langContent [ 'site' ];
// remove tmp array
unset ( $this -> langContent [ 'site' ]);
2017-12-14 23:10:47 +00:00
2017-04-05 13:21:10 +00:00
return true ;
2016-02-26 00:20:09 +00:00
}
2017-04-05 13:21:10 +00:00
return false ;
2016-02-26 00:20:09 +00:00
}
public function setLangSiteSys ()
{
// add final list of needed lang strings
2017-12-14 23:10:47 +00:00
$this -> langContent [ 'sitesys' ][ $this -> langPrefix ] = ComponentbuilderHelper :: safeString ( $this -> componentData -> name , 'W' );
$this -> langContent [ 'sitesys' ][ $this -> langPrefix . '_NO_ACCESS_GRANTED' ] = " No Access Granted! " ;
2016-02-26 00:20:09 +00:00
2017-09-13 11:59:58 +00:00
// check if the both site array is set
if ( isset ( $this -> langContent [ 'bothsite' ]) && ComponentbuilderHelper :: checkArray ( $this -> langContent [ 'bothsite' ]))
{
foreach ( $this -> langContent [ 'bothsite' ] as $keylang => $langval )
{
$this -> langContent [ 'sitesys' ][ $keylang ] = $langval ;
}
}
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> langContent [ 'sitesys' ]) && ComponentbuilderHelper :: checkArray ( $this -> langContent [ 'sitesys' ]))
{
ksort ( $this -> langContent [ 'sitesys' ]);
2017-04-05 13:21:10 +00:00
// load to global languages
$this -> languages [ 'en-GB' ][ 'sitesys' ] = $this -> langContent [ 'sitesys' ];
// remove tmp array
unset ( $this -> langContent [ 'sitesys' ]);
2017-12-14 23:10:47 +00:00
2017-04-05 13:21:10 +00:00
return true ;
2016-02-26 00:20:09 +00:00
}
2017-04-05 13:21:10 +00:00
return false ;
2016-02-26 00:20:09 +00:00
}
public function setLangAdminSys ()
{
2017-09-13 11:59:58 +00:00
// check if the both admin array is set
if ( isset ( $this -> langContent [ 'bothadmin' ]) && ComponentbuilderHelper :: checkArray ( $this -> langContent [ 'bothadmin' ]))
{
foreach ( $this -> langContent [ 'bothadmin' ] as $keylang => $langval )
{
$this -> langContent [ 'adminsys' ][ $keylang ] = $langval ;
}
}
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> langContent [ 'adminsys' ]) && ComponentbuilderHelper :: checkArray ( $this -> langContent [ 'adminsys' ]))
{
ksort ( $this -> langContent [ 'adminsys' ]);
2017-04-05 13:21:10 +00:00
// load to global languages
$this -> languages [ 'en-GB' ][ 'adminsys' ] = $this -> langContent [ 'adminsys' ];
// remove tmp array
unset ( $this -> langContent [ 'adminsys' ]);
2017-12-14 23:10:47 +00:00
2017-04-05 13:21:10 +00:00
return true ;
2016-02-26 00:20:09 +00:00
}
2017-04-05 13:21:10 +00:00
return false ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
public function setCustomAdminViewListLink ( $view , $viewName_list )
2016-02-26 00:20:09 +00:00
{
if ( isset ( $this -> componentData -> custom_admin_views ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> custom_admin_views ))
{
foreach ( $this -> componentData -> custom_admin_views as $custom_admin_view )
{
2017-12-10 19:17:26 +00:00
if ( isset ( $custom_admin_view [ 'adminviews' ]) && ComponentbuilderHelper :: checkArray ( $custom_admin_view [ 'adminviews' ]))
2016-02-26 00:20:09 +00:00
{
foreach ( $custom_admin_view [ 'adminviews' ] as $adminview )
{
2017-12-10 19:17:26 +00:00
if ( isset ( $view [ 'adminview' ]) && $view [ 'adminview' ] == $adminview )
2016-02-26 00:20:09 +00:00
{
// set the needed keys
$setId = false ;
if ( ComponentbuilderHelper :: checkArray ( $custom_admin_view [ 'settings' ] -> main_get -> filter ))
{
foreach ( $custom_admin_view [ 'settings' ] -> main_get -> filter as $filter )
{
if ( $filter [ 'filter_type' ] == 1 || '$id' == $filter [ 'state_key' ])
{
$setId = true ;
}
}
}
// set the needed array values
$set = array (
'icon' => $custom_admin_view [ 'icomoon' ],
'link' => $custom_admin_view [ 'settings' ] -> code ,
'NAME' => $custom_admin_view [ 'settings' ] -> CODE ,
'name' => $custom_admin_view [ 'settings' ] -> name );
// only load to list if it has id filter
if ( $setId )
{
// now load it to the global object for items list
$this -> customAdminViewListLink [ $viewName_list ][] = $set ;
// add to set id for list view if needed
$this -> customAdminViewListId [ $custom_admin_view [ 'settings' ] -> code ] = true ;
}
else
{
// now load it to the global object for tool bar
$this -> customAdminDynamicButtons [ $viewName_list ][] = $set ;
}
2016-04-22 12:03:43 +00:00
// log that it has been added already
$this -> customAdminAdded [ $custom_admin_view [ 'settings' ] -> code ] = $adminview ;
2016-02-26 00:20:09 +00:00
}
}
}
}
}
}
2017-12-14 23:10:47 +00:00
public function setListBody ( $viewName_single , $viewName_list )
2016-02-26 00:20:09 +00:00
{
if ( isset ( $this -> listBuilder [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> listBuilder [ $viewName_list ]))
{
// component helper name
2017-12-14 23:10:47 +00:00
$Helper = $this -> fileContentStatic [ '###Component###' ] . 'Helper' ;
2016-02-26 00:20:09 +00:00
// setup correct core target
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $viewName_single ]))
{
$core = $this -> permissionCore [ $viewName_single ];
$coreLoad = true ;
}
// make sure the custom links are only added once
$firstTimeBeingAdded = true ;
// add the default
$body = " <?php foreach ( \$ this->items as \$ i => \$ item): ?> " ;
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t <?php " ;
$body .= PHP_EOL . " \t \t \$ canCheckin = \$ this->user->authorise('core.manage', 'com_checkin') || \$ item->checked_out == \$ this->user->id || \$ item->checked_out == 0; " ;
$body .= PHP_EOL . " \t \t \$ userChkOut = JFactory::getUser( \$ item->checked_out); " ;
$body .= PHP_EOL . " \t \t \$ canDo = " . $Helper . " ::getActions(' " . $viewName_single . " ', \$ item,' " . $viewName_list . " '); " ;
$body .= PHP_EOL . " \t ?> " ;
$body .= PHP_EOL . " \t " . '<tr class="row<?php echo $i % 2; ?>">' ;
2016-06-02 16:18:49 +00:00
// only load if not over written
if ( ! isset ( $this -> fieldsNames [ $viewName_single ][ 'ordering' ]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t " . '<td class="order nowrap center hidden-phone">' ;
2016-06-02 16:18:49 +00:00
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit.state' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.state' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.state' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.state' ]]))
2016-06-02 16:18:49 +00:00
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <?php if ( \$ canDo->get(' " . $core [ 'core.edit.state' ] . " ')): ?> " ;
2016-06-02 16:18:49 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <?php if ( \$ canDo->get('core.edit.state')): ?> " ;
}
$body .= PHP_EOL . " \t \t \t <?php " ;
$body .= PHP_EOL . " \t \t \t \t if ( \$ this->saveOrder) " ;
$body .= PHP_EOL . " \t \t \t \t { " ;
$body .= PHP_EOL . " \t \t \t \t \t \$ iconClass = ' inactive'; " ;
$body .= PHP_EOL . " \t \t \t \t } " ;
$body .= PHP_EOL . " \t \t \t \t else " ;
$body .= PHP_EOL . " \t \t \t \t { " ;
$body .= PHP_EOL . " \t \t \t \t \t \$ iconClass = ' inactive tip-top " . '" hasTooltip" title="' . " ' . JHtml::tooltipText('JORDERINGDISABLED'); " ;
$body .= PHP_EOL . " \t \t \t \t } " ;
$body .= PHP_EOL . " \t \t \t ?> " ;
$body .= PHP_EOL . " \t \t \t " . '<span class="sortable-handler<?php echo $iconClass; ?>">' ;
$body .= PHP_EOL . " \t \t \t \t " . '<i class="icon-menu"></i>' ;
$body .= PHP_EOL . " \t \t \t </span> " ;
$body .= PHP_EOL . " \t \t \t <?php if ( \$ this->saveOrder) : ?> " ;
$body .= PHP_EOL . " \t \t \t \t " . '<input type="text" style="display:none" name="order[]" size="5"' ;
$body .= PHP_EOL . " \t \t \t \t " . 'value="<?php echo $item->ordering; ?>" class="width-20 text-area-order " />' ;
$body .= PHP_EOL . " \t \t \t <?php endif; ?> " ;
$body .= PHP_EOL . " \t \t <?php else: ?> " ;
$body .= PHP_EOL . " \t \t \t ⋮ " ;
$body .= PHP_EOL . " \t \t <?php endif; ?> " ;
$body .= PHP_EOL . " \t \t </td> " ;
}
$body .= PHP_EOL . " \t \t " . '<td class="nowrap center">' ;
2016-02-26 00:20:09 +00:00
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <?php if ( \$ canDo->get(' " . $core [ 'core.edit' ] . " ')): ?> " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <?php if ( \$ canDo->get('core.edit')): ?> " ;
}
$body .= PHP_EOL . " \t \t \t \t <?php if ( \$ item->checked_out) : ?> " ;
$body .= PHP_EOL . " \t \t \t \t \t <?php if ( \$ canCheckin) : ?> " ;
$body .= PHP_EOL . " \t \t \t \t \t \t <?php echo JHtml::_('grid.id', \$ i, \$ item->id); ?> " ;
$body .= PHP_EOL . " \t \t \t \t \t <?php else: ?> " ;
$body .= PHP_EOL . " \t \t \t \t \t \t □ " ;
$body .= PHP_EOL . " \t \t \t \t \t <?php endif; ?> " ;
$body .= PHP_EOL . " \t \t \t \t <?php else: ?> " ;
$body .= PHP_EOL . " \t \t \t \t \t <?php echo JHtml::_('grid.id', \$ i, \$ item->id); ?> " ;
$body .= PHP_EOL . " \t \t \t \t <?php endif; ?> " ;
$body .= PHP_EOL . " \t \t <?php else: ?> " ;
$body .= PHP_EOL . " \t \t \t □ " ;
$body .= PHP_EOL . " \t \t <?php endif; ?> " ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-02-26 00:20:09 +00:00
// check if this view has fields that should not be escaped
$doNotEscape = false ;
if ( isset ( $this -> doNotEscape [ $viewName_list ]))
{
$doNotEscape = true ;
}
// start adding the dynamic
foreach ( $this -> listBuilder [ $viewName_list ] as $item )
{
$checkoutTriger = false ;
2016-10-23 22:48:26 +00:00
if ( isset ( $item [ 'custom' ]) && ComponentbuilderHelper :: checkArray ( $item [ 'custom' ]) && isset ( $item [ 'custom' ][ 'table' ]) && ComponentbuilderHelper :: checkString ( $item [ 'custom' ][ 'table' ]))
2016-02-26 00:20:09 +00:00
{
$item [ 'id' ] = $item [ 'code' ];
2016-05-10 05:47:47 +00:00
if ( ! $item [ 'multiple' ])
{
2017-12-14 23:10:47 +00:00
$item [ 'code' ] = $item [ 'code' ] . '_' . $item [ 'custom' ][ 'text' ];
2016-05-10 05:47:47 +00:00
}
2016-02-26 00:20:09 +00:00
}
2016-10-23 22:48:26 +00:00
// check if translated value is used
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> selectionTranslationFixBuilder [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> selectionTranslationFixBuilder [ $viewName_list ]) && array_key_exists ( $item [ 'code' ], $this -> selectionTranslationFixBuilder [ $viewName_list ]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$itemCode = '<?php echo JText::_($item->' . $item [ 'code' ] . '); ?>' ;
2016-02-26 00:20:09 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( isset ( $item [ 'custom' ]) && ComponentbuilderHelper :: checkArray ( $item [ 'custom' ]) && $item [ 'custom' ][ 'text' ] === 'user' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$itemCode = '<?php echo JFactory::getUser((int)$item->' . $item [ 'code' ] . ')->name; ?>' ;
2016-02-26 00:20:09 +00:00
}
elseif ( $doNotEscape )
{
if ( in_array ( $item [ 'code' ], $this -> doNotEscape [ $viewName_list ]))
{
2017-12-14 23:10:47 +00:00
$itemCode = '<?php echo $item->' . $item [ 'code' ] . '; ?>' ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$itemCode = '<?php echo $this->escape($item->' . $item [ 'code' ] . '); ?>' ;
2016-02-26 00:20:09 +00:00
}
}
else
{
2017-12-14 23:10:47 +00:00
$itemCode = '<?php echo $this->escape($item->' . $item [ 'code' ] . '); ?>' ;
2016-02-26 00:20:09 +00:00
}
if ( $item [ 'link' ])
{
// allways rest custom links
$customAdminView = '' ;
// if to be linked
2017-02-01 13:17:04 +00:00
if ( $item [ 'type' ] === 'category' && ! $item [ 'title' ])
2016-02-26 00:20:09 +00:00
{
$otherViews = $this -> catCodeBuilder [ $viewName_single ][ 'views' ];
// category and linked
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t " . '<td class="nowrap">' ;
$body .= PHP_EOL . " \t \t \t <?php if ( \$ this->user->authorise('core.edit', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " . " . $otherViews . " .category.' . (int) \$ item-> " . $item [ 'code' ] . " )): ?> " ;
$body .= PHP_EOL . " \t \t \t \t " . '<a href="index.php?option=com_categories&task=category.edit&id=<?php echo (int)$item->' . $item [ 'code' ] . '; ?>&extension=com_' . $this -> fileContentStatic [ '###component###' ] . '.' . $otherViews . '"><?php echo $this->escape($item->category_title); ?></a>' ;
$body .= PHP_EOL . " \t \t \t <?php else: ?> " ;
$body .= PHP_EOL . " \t \t \t \t <?php echo \$ this->escape( \$ item->category_title); ?> " ;
$body .= PHP_EOL . " \t \t \t <?php endif; ?> " ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-02-26 00:20:09 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $item [ 'type' ] === 'user' && ! $item [ 'title' ])
2016-02-26 00:20:09 +00:00
{
// user and linked
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <?php \$ " . $item [ 'code' ] . " User = JFactory::getUser( \$ item-> " . $item [ 'code' ] . " ); ?> " ;
$body .= PHP_EOL . " \t \t " . '<td class="nowrap">' ;
$body .= PHP_EOL . " \t \t \t <?php if ( \$ this->user->authorise('core.edit', 'com_users')): ?> " ;
$body .= PHP_EOL . " \t \t \t \t " . '<a href="index.php?option=com_users&task=user.edit&id=<?php echo (int) $item->' . $item [ 'code' ] . ' ?>"><?php echo $' . $item [ 'code' ] . 'User->name; ?></a>' ;
$body .= PHP_EOL . " \t \t \t <?php else: ?> " ;
$body .= PHP_EOL . " \t \t \t \t <?php echo \$ " . $item [ 'code' ] . " User->name; ?> " ;
$body .= PHP_EOL . " \t \t \t <?php endif; ?> " ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-02-26 00:20:09 +00:00
}
else
{
$add = true ;
if ( isset ( $item [ 'custom' ]) && ComponentbuilderHelper :: checkArray ( $item [ 'custom' ]) && $item [ 'custom' ][ 'extends' ] != 'user' && ! $item [ 'title' ])
{
// link to that item instead
2017-12-14 23:10:47 +00:00
$link = 'index.php?option=' . $item [ 'custom' ][ 'component' ] . '&view=' . $item [ 'custom' ][ 'views' ] . '&task=' . $item [ 'custom' ][ 'view' ] . '.edit&id=<?php echo $item->' . $item [ 'id' ] . '; ?>&ref=' . $viewName_list ;
2016-02-26 00:20:09 +00:00
$coreLoadLink = false ;
if ( isset ( $this -> permissionCore [ $item [ 'custom' ][ 'view' ]]))
{
$coreLink = $this -> permissionCore [ $item [ 'custom' ][ 'view' ]];
$coreLoadLink = true ;
}
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoadLink && ( isset ( $coreLink [ 'core.edit' ]) && isset ( $this -> permissionBuilder [ $coreLink [ 'core.edit' ]])) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $coreLink [ 'core.edit' ]]) && in_array ( $item [ 'custom' ][ 'view' ], $this -> permissionBuilder [ $coreLink [ 'core.edit' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$accessCheck = " \$ this->user->authorise(' " . $coreLink [ 'core.edit' ] . " ', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " . " . $item [ 'custom' ][ 'view' ] . " .' . (int) \$ item-> " . $item [ 'id' ] . " ) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$accessCheck = " \$ this->user->authorise('core.edit', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " . " . $item [ 'custom' ][ 'view' ] . " .' . (int) \$ item-> " . $item [ 'id' ] . " ) " ;
2016-02-26 00:20:09 +00:00
}
}
2017-02-01 13:17:04 +00:00
elseif ( isset ( $item [ 'custom' ]) && ComponentbuilderHelper :: checkArray ( $item [ 'custom' ]) && $item [ 'custom' ][ 'extends' ] === 'user' && ! $item [ 'title' ])
2016-02-26 00:20:09 +00:00
{
// user and linked
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <?php \$ " . $item [ 'id' ] . " = JFactory::getUser( \$ item-> " . $item [ 'id' ] . " ); ?> " ;
$body .= PHP_EOL . " \t \t " . '<td class="nowrap">' ;
$body .= PHP_EOL . " \t \t \t <?php if ( \$ this->user->authorise('core.edit', 'com_users')): ?> " ;
$body .= PHP_EOL . " \t \t \t \t " . '<a href="index.php?option=com_users&task=user.edit&id=<?php echo (int) $item->' . $item [ 'id' ] . ' ?>"><?php echo $' . $item [ 'id' ] . '->name; ?></a>' ;
$body .= PHP_EOL . " \t \t \t <?php else: ?> " ;
$body .= PHP_EOL . " \t \t \t \t <?php echo \$ " . $item [ 'id' ] . " ->name; ?> " ;
$body .= PHP_EOL . " \t \t \t <?php endif; ?> " ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-02-26 00:20:09 +00:00
$add = false ;
}
else
{
2017-12-14 23:10:47 +00:00
// start building the links
2016-02-26 00:20:09 +00:00
$link = '<?php echo $edit; ?>&id=<?php echo $item->id; ?>' ;
2017-12-14 23:10:47 +00:00
// check if custom links should be added to this list views
if ( isset ( $this -> customAdminViewListLink [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> customAdminViewListLink [ $viewName_list ]) && $firstTimeBeingAdded )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
// make sure the custom links are only added once
$firstTimeBeingAdded = false ;
// start building the links
$customAdminView = PHP_EOL . " \t \t \t " . '<div class="btn-group">' ;
foreach ( $this -> customAdminViewListLink [ $viewName_list ] as $customLinkView )
{
$customAdminView .= PHP_EOL . " \t \t \t <?php if ( \$ canDo->get(' " . $customLinkView [ 'link' ] . " .access')): ?> " ;
$customAdminView .= PHP_EOL . " \t \t \t \t " . '<a class="hasTooltip btn btn-mini" href="index.php?option=com_' . $this -> fileContentStatic [ '###component###' ] . '&view=' . $customLinkView [ 'link' ] . '&id=<?php echo $item->id; ?>" title="<?php echo JText::_(' . " 'COM_ " . $this -> fileContentStatic [ '###COMPONENT###' ] . '_' . $customLinkView [ 'NAME' ] . " ' " . '); ?>" ><span class="icon-' . $customLinkView [ 'icon' ] . '"></span></a>' ;
$customAdminView .= PHP_EOL . " \t \t \t <?php else: ?> " ;
$customAdminView .= PHP_EOL . " \t \t \t \t " . '<a class="hasTooltip btn btn-mini disabled" href="#" title="<?php echo JText::_(' . " 'COM_ " . $this -> fileContentStatic [ '###COMPONENT###' ] . '_' . $customLinkView [ 'NAME' ] . " ' " . '); ?>"><span class="icon-' . $customLinkView [ 'icon' ] . '"></span></a>' ;
$customAdminView .= PHP_EOL . " \t \t \t <?php endif; ?> " ;
}
$customAdminView .= PHP_EOL . " \t \t \t " . '</div>' ;
}
// check if the item has permissions.
if ( $coreLoad && isset ( $core [ 'core.edit' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]))
{
// set permissions.
$accessCheck = " \$ canDo->get(' " . $core [ 'core.edit' ] . " ') " ;
}
else
2016-02-26 00:20:09 +00:00
{
// set permissions.
$accessCheck = " \$ canDo->get('core.edit') " ;
}
// triger the checked out script to be added
$checkoutTriger = true ;
}
if ( $add )
{
// set as linked
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t " . '<td class="nowrap">' ;
$body .= PHP_EOL . " \t \t \t <?php if ( " . $accessCheck . " ): ?> " ;
$body .= PHP_EOL . " \t \t \t \t " . '<div class="name">' . PHP_EOL . " \t \t \t \t \t " . '<a href="' . $link . '">' . $itemCode . '</a>' ;
2016-02-26 00:20:09 +00:00
if ( $checkoutTriger )
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t \t \t \t <?php if ( \$ item->checked_out): ?> " ;
$body .= PHP_EOL . " \t \t \t \t \t \t <?php echo JHtml::_('jgrid.checkedout', \$ i, \$ userChkOut->name, \$ item->checked_out_time, ' " . $viewName_list . " .', \$ canCheckin); ?> " ;
$body .= PHP_EOL . " \t \t \t \t \t <?php endif; ?> " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t \t \t " . '</div>' ;
$body .= PHP_EOL . " \t \t \t <?php else: ?> " ;
$body .= PHP_EOL . " \t \t \t \t " . '<div class="name">' . $itemCode . '</div>' ;
$body .= PHP_EOL . " \t \t \t <?php endif; ?> " ;
$body .= $customAdminView ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-02-26 00:20:09 +00:00
}
}
}
else
{
2017-02-01 13:17:04 +00:00
if ( $item [ 'type' ] === 'category' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <td class= \" hidden-phone \" > " ;
$body .= PHP_EOL . " \t \t \t <?php echo \$ this->escape( \$ item->category_title); ?> " ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-02-26 00:20:09 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( ComponentbuilderHelper :: checkArray ( $item [ 'custom' ]) && $item [ 'custom' ][ 'extends' ] === 'user' )
2016-02-26 00:20:09 +00:00
{
// custom user and linked
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <?php \$ " . $item [ 'code' ] . " = JFactory::getUser( \$ item-> " . $item [ 'id' ] . " ); ?> " ;
$body .= PHP_EOL . " \t \t " . '<td class="nowrap hidden-phone">' ;
$body .= PHP_EOL . " \t \t \t <?php if ( \$ this->user->authorise('core.edit', 'com_users')): ?> " ;
$body .= PHP_EOL . " \t \t \t \t " . '<a href="index.php?option=com_users&task=user.edit&id=<?php echo (int) $item->' . $item [ 'id' ] . ' ?>"><?php echo $' . $item [ 'code' ] . '->name; ?></a>' ;
$body .= PHP_EOL . " \t \t \t <?php else: ?> " ;
$body .= PHP_EOL . " \t \t \t \t <?php echo \$ " . $item [ 'code' ] . " ->name; ?> " ;
$body .= PHP_EOL . " \t \t \t <?php endif; ?> " ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-02-26 00:20:09 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $item [ 'type' ] === 'user' )
2016-06-02 16:18:49 +00:00
{
// user name only
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <?php \$ " . $item [ 'code' ] . " User = JFactory::getUser( \$ item-> " . $item [ 'code' ] . " ); ?> " ;
$body .= PHP_EOL . " \t \t " . '<td class="nowrap">' ;
$body .= PHP_EOL . " \t \t \t <?php echo \$ " . $item [ 'code' ] . " User->name; ?> " ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-06-02 16:18:49 +00:00
}
2016-02-26 00:20:09 +00:00
else
{
// normal not linked
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <td class= \" hidden-phone \" > " ;
$body .= PHP_EOL . " \t \t \t " . $itemCode ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-02-26 00:20:09 +00:00
}
}
}
// add the defaults
2016-06-02 16:18:49 +00:00
if ( ! isset ( $this -> fieldsNames [ $viewName_single ][ 'published' ]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t " . '<td class="center">' ;
2016-06-02 16:18:49 +00:00
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit.state' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.state' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.state' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.state' ]]))
2016-06-02 16:18:49 +00:00
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <?php if ( \$ canDo->get(' " . $core [ 'core.edit.state' ] . " ')) : ?> " ;
2016-06-02 16:18:49 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <?php if ( \$ canDo->get('core.edit.state')) : ?> " ;
}
$body .= PHP_EOL . " \t \t \t \t <?php if ( \$ item->checked_out) : ?> " ;
$body .= PHP_EOL . " \t \t \t \t \t <?php if ( \$ canCheckin) : ?> " ;
$body .= PHP_EOL . " \t \t \t \t \t \t <?php echo JHtml::_('jgrid.published', \$ item->published, \$ i, ' " . $viewName_list . " .', true, 'cb'); ?> " ;
$body .= PHP_EOL . " \t \t \t \t \t <?php else: ?> " ;
$body .= PHP_EOL . " \t \t \t \t \t \t <?php echo JHtml::_('jgrid.published', \$ item->published, \$ i, ' " . $viewName_list . " .', false, 'cb'); ?> " ;
$body .= PHP_EOL . " \t \t \t \t \t <?php endif; ?> " ;
$body .= PHP_EOL . " \t \t \t \t <?php else: ?> " ;
$body .= PHP_EOL . " \t \t \t \t \t <?php echo JHtml::_('jgrid.published', \$ item->published, \$ i, ' " . $viewName_list . " .', true, 'cb'); ?> " ;
$body .= PHP_EOL . " \t \t \t \t <?php endif; ?> " ;
$body .= PHP_EOL . " \t \t <?php else: ?> " ;
$body .= PHP_EOL . " \t \t \t <?php echo JHtml::_('jgrid.published', \$ item->published, \$ i, ' " . $viewName_list . " .', false, 'cb'); ?> " ;
$body .= PHP_EOL . " \t \t <?php endif; ?> " ;
$body .= PHP_EOL . " \t \t </td> " ;
}
2016-06-02 16:18:49 +00:00
if ( ! isset ( $this -> fieldsNames [ $viewName_single ][ 'id' ]))
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t " . '<td class="nowrap center hidden-phone">' ;
$body .= PHP_EOL . " \t \t \t <?php echo \$ item->id; ?> " ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t </tr> " ;
$body .= PHP_EOL . " <?php endforeach; ?> " ;
2016-02-26 00:20:09 +00:00
// return the build
return $body ;
}
return '' ;
}
2017-12-14 23:10:47 +00:00
public function setListHead ( $viewName_single , $viewName_list )
2016-02-26 00:20:09 +00:00
{
if ( isset ( $this -> listBuilder [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> listBuilder [ $viewName_list ]))
{
// main lang prefix
2017-12-14 23:10:47 +00:00
$langView = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( $viewName_single , 'U' );
2016-02-26 00:20:09 +00:00
// set status lang
2017-12-14 23:10:47 +00:00
$statusLangName = $langView . '_STATUS' ;
2016-02-26 00:20:09 +00:00
// set id lang
2017-12-14 23:10:47 +00:00
$idLangName = $langView . '_ID' ;
2016-02-26 00:20:09 +00:00
// add to lang array
if ( ! isset ( $this -> langContent [ $this -> lang ][ $statusLangName ]))
{
$this -> langContent [ $this -> lang ][ $statusLangName ] = 'Status' ;
}
// add to lang array
2017-12-14 23:10:47 +00:00
if ( ! isset ( $this -> langContent [ $this -> lang ][ $idLangName ]))
2016-02-26 00:20:09 +00:00
{
$this -> langContent [ $this -> lang ][ $idLangName ] = 'Id' ;
}
// set default
$head = '<tr>' ;
2017-12-14 23:10:47 +00:00
$head .= PHP_EOL . " \t <?php if ( \$ this->canEdit&& \$ this->canState): ?> " ;
2016-06-02 16:18:49 +00:00
if ( ! isset ( $this -> fieldsNames [ $viewName_single ][ 'ordering' ]))
{
2017-12-14 23:10:47 +00:00
$head .= PHP_EOL . " \t \t " . '<th width="1%" class="nowrap center hidden-phone">' ;
$head .= PHP_EOL . " \t \t \t <?php echo JHtml::_('grid.sort', ' " . '<i class="icon-menu-2"></i>' . " ', 'ordering', \$ this->listDirn, \$ this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?> " ;
$head .= PHP_EOL . " \t \t </th> " ;
}
$head .= PHP_EOL . " \t \t " . '<th width="20" class="nowrap center">' ;
$head .= PHP_EOL . " \t \t \t <?php echo JHtml::_('grid.checkall'); ?> " ;
$head .= PHP_EOL . " \t \t </th> " ;
$head .= PHP_EOL . " \t <?php else: ?> " ;
$head .= PHP_EOL . " \t \t " . '<th width="20" class="nowrap center hidden-phone">' ;
$head .= PHP_EOL . " \t \t \t ▾ " ;
$head .= PHP_EOL . " \t \t </th> " ;
$head .= PHP_EOL . " \t \t " . '<th width="20" class="nowrap center">' ;
$head .= PHP_EOL . " \t \t \t ■ " ;
$head .= PHP_EOL . " \t \t </th> " ;
$head .= PHP_EOL . " \t <?php endif; ?> " ;
2016-02-26 00:20:09 +00:00
// set footer Column number
$this -> listColnrBuilder [ $viewName_list ] = 4 ;
// build the dynamic fields
foreach ( $this -> listBuilder [ $viewName_list ] as $item )
{
if ( ComponentbuilderHelper :: checkArray ( $item [ 'custom' ]))
{
2017-12-14 23:10:47 +00:00
$item [ 'code' ] = $item [ 'code' ] . '_' . $item [ 'custom' ][ 'text' ];
2016-02-26 00:20:09 +00:00
}
$class = 'nowrap hidden-phone' ;
if ( $item [ 'link' ])
{
$class = 'nowrap' ;
}
2017-12-14 23:10:47 +00:00
$title = " <?php echo JText::_(' " . $item [ 'lang' ] . " '); ?> " ;
2016-02-26 00:20:09 +00:00
if ( $item [ 'sort' ])
{
2017-12-14 23:10:47 +00:00
$title = " <?php echo JHtml::_('grid.sort', ' " . $item [ 'lang' ] . " ', ' " . $item [ 'code' ] . " ', \$ this->listDirn, \$ this->listOrder); ?> " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$head .= PHP_EOL . " \t " . '<th class="' . $class . '" >' ;
$head .= PHP_EOL . " \t \t \t " . $title ;
$head .= PHP_EOL . " \t </th> " ;
$this -> listColnrBuilder [ $viewName_list ] ++ ;
2016-02-26 00:20:09 +00:00
}
// set default
2016-06-02 16:18:49 +00:00
if ( ! isset ( $this -> fieldsNames [ $viewName_single ][ 'published' ]))
{
2017-12-14 23:10:47 +00:00
$head .= PHP_EOL . " \t <?php if ( \$ this->canState): ?> " ;
$head .= PHP_EOL . " \t \t " . '<th width="10" class="nowrap center" >' ;
$head .= PHP_EOL . " \t \t \t <?php echo JHtml::_('grid.sort', ' " . $statusLangName . " ', 'published', \$ this->listDirn, \$ this->listOrder); ?> " ;
$head .= PHP_EOL . " \t \t </th> " ;
$head .= PHP_EOL . " \t <?php else: ?> " ;
$head .= PHP_EOL . " \t \t " . '<th width="10" class="nowrap center" >' ;
$head .= PHP_EOL . " \t \t \t <?php echo JText::_(' " . $statusLangName . " '); ?> " ;
$head .= PHP_EOL . " \t \t </th> " ;
$head .= PHP_EOL . " \t <?php endif; ?> " ;
2016-06-02 16:18:49 +00:00
}
if ( ! isset ( $this -> fieldsNames [ $viewName_single ][ 'id' ]))
{
2017-12-14 23:10:47 +00:00
$head .= PHP_EOL . " \t " . '<th width="5" class="nowrap center hidden-phone" >' ;
$head .= PHP_EOL . " \t \t \t <?php echo JHtml::_('grid.sort', ' " . $idLangName . " ', 'id', \$ this->listDirn, \$ this->listOrder); ?> " ;
$head .= PHP_EOL . " \t </th> " ;
2016-06-02 16:18:49 +00:00
}
2017-12-14 23:10:47 +00:00
$head .= PHP_EOL . " </tr> " ;
2016-02-26 00:20:09 +00:00
return $head ;
}
return '' ;
}
public function setListColnr ( $viewName_list )
{
if ( isset ( $this -> listColnrBuilder [ $viewName_list ]))
{
return $this -> listColnrBuilder [ $viewName_list ];
}
return '' ;
}
public function setEditBody ( & $view )
{
// set view name
$viewName_single = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_single );
// alignment
$alignmentNames = array ( 1 => 'left' , 2 => 'right' , 3 => 'fullwidth' , 4 => 'above' , 5 => 'under' , 6 => 'leftside' , 7 => 'rightside' );
// main lang prefix
2017-12-14 23:10:47 +00:00
$langView = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( $viewName_single , 'U' );
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> layoutBuilder [ $viewName_single ]) && ComponentbuilderHelper :: checkArray ( $this -> layoutBuilder [ $viewName_single ]))
{
// set the linked view tabs
$linkedTab = array ();
$keys = array ();
// setup correct core target
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $viewName_single ]))
{
$core = $this -> permissionCore [ $viewName_single ];
$coreLoad = true ;
}
if ( isset ( $this -> linkedAdminViews [ $viewName_single ]) && ComponentbuilderHelper :: checkArray ( $this -> linkedAdminViews [ $viewName_single ]))
{
foreach ( $this -> linkedAdminViews [ $viewName_single ] as $linkedView )
{
$tabName = $view [ 'settings' ] -> tabs [( int ) $linkedView [ 'tab' ]];
$this -> tabCounter [ $viewName_single ][ $linkedView [ 'tab' ]] = $tabName ;
$linkedTab [ $linkedView [ 'adminview' ]] = $linkedView [ 'tab' ];
if ( ComponentbuilderHelper :: checkString ( $linkedView [ 'key' ]) && ComponentbuilderHelper :: checkString ( $linkedView [ 'parentkey' ]))
{
2017-12-14 23:10:47 +00:00
$keys [ $linkedView [ 'adminview' ]] = array ( 'key' => $linkedView [ 'key' ], 'parentKey' => $linkedView [ 'parentkey' ]);
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$keys [ $linkedView [ 'adminview' ]] = array ( 'key' => null , 'parentKey' => null );
2016-02-26 00:20:09 +00:00
}
if ( isset ( $linkedView [ 'addnew' ]))
{
$keys [ $linkedView [ 'adminview' ]][ 'addNewButton' ] = ( int ) $linkedView [ 'addnew' ];
}
else
{
$keys [ $linkedView [ 'adminview' ]][ 'addNewButton' ] = 0 ;
}
}
}
// start tab set
$bucket = array ();
2017-10-26 16:43:51 +00:00
$leftside = '' ;
$rightside = '' ;
2016-02-26 00:20:09 +00:00
$footer = '' ;
$header = '' ;
$mainwidth = 12 ;
$sidewidth = 0 ;
ksort ( $this -> tabCounter [ $viewName_single ]);
foreach ( $this -> tabCounter [ $viewName_single ] as $tabNr => $tabName )
{
$tabWidth = 12 ;
$lrCounter = 0 ;
// set tab lang
2017-12-14 23:10:47 +00:00
$tabLangName = $langView . '_' . ComponentbuilderHelper :: safeString ( $tabName , 'U' );
2016-02-26 00:20:09 +00:00
// set tab code name
$tabCodeName = ComponentbuilderHelper :: safeString ( $tabName );
// add to lang array
if ( ! isset ( $this -> langContent [ $this -> lang ][ $tabLangName ]))
{
$this -> langContent [ $this -> lang ][ $tabLangName ] = $tabName ;
}
// check if linked view belongs to this tab
$buildLayout = true ;
$linkedViewId = '' ;
if ( ComponentbuilderHelper :: checkArray ( $linkedTab ))
{
2017-04-07 20:33:35 +00:00
if (( $linkedViewId = array_search ( $tabNr , $linkedTab )) !== false )
2016-02-26 00:20:09 +00:00
{
// don't build
$buildLayout = false ;
}
}
if ( $buildLayout )
{
// sort to make sure it loads left first
$alignments = $this -> layoutBuilder [ $viewName_single ][ $tabName ];
ksort ( $alignments );
foreach ( $alignments as $alignment => $names )
{
// set layout code name
2017-12-14 23:10:47 +00:00
$layoutCodeName = $tabCodeName . '_' . $alignmentNames [ $alignment ];
2016-02-26 00:20:09 +00:00
// reset each time
2017-12-14 23:10:47 +00:00
$items = '' ;
2016-02-26 00:20:09 +00:00
$itemCounter = 0 ;
ksort ( $names );
foreach ( $names as $nr => $name )
{
if ( $itemCounter == 0 )
{
2017-12-14 23:10:47 +00:00
$items .= " ' " . $name . " ' " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$items .= " , " . PHP_EOL . " \t ' " . $name . " ' " ;
2016-02-26 00:20:09 +00:00
}
$itemCounter ++ ;
}
2017-12-14 23:10:47 +00:00
switch ( $alignment )
2016-02-26 00:20:09 +00:00
{
case 1 : // left
case 2 : // right
// count
$lrCounter ++ ;
// set as items layout
2017-12-14 23:10:47 +00:00
$this -> setLayout ( $viewName_single , $layoutCodeName , $items , 'layoutitems' );
2016-02-26 00:20:09 +00:00
// set the lang to tab
$bucket [ $tabCodeName ][ 'lang' ] = $tabLangName ;
// load the body
if ( ! isset ( $bucket [ $tabCodeName ][( int ) $alignment ]))
{
$bucket [ $tabCodeName ][( int ) $alignment ] = '' ;
}
2017-12-14 23:10:47 +00:00
$bucket [ $tabCodeName ][( int ) $alignment ] .= " <?php echo JLayoutHelper::render(' " . $viewName_single . " . " . $layoutCodeName . " ', \$ this); ?> " ;
break ;
2016-02-26 00:20:09 +00:00
case 3 : // fullwidth
// set as items layout
2017-12-14 23:10:47 +00:00
$this -> setLayout ( $viewName_single , $layoutCodeName , $items , 'layoutfull' );
2016-02-26 00:20:09 +00:00
// set the lang to tab
$bucket [ $tabCodeName ][ 'lang' ] = $tabLangName ;
// load the body
if ( ! isset ( $bucket [ $tabCodeName ][( int ) $alignment ]))
{
$bucket [ $tabCodeName ][( int ) $alignment ] = '' ;
}
2017-12-14 23:10:47 +00:00
$bucket [ $tabCodeName ][( int ) $alignment ] .= " <?php echo JLayoutHelper::render(' " . $viewName_single . " . " . $layoutCodeName . " ', \$ this); ?> " ;
break ;
2016-02-26 00:20:09 +00:00
case 4 : // above
// set as title layout
$this -> setLayout ( $viewName_single , $layoutCodeName , $items , 'layouttitle' );
// load to header
2017-12-14 23:10:47 +00:00
$header .= PHP_EOL . " \t <?php echo JLayoutHelper::render(' " . $viewName_single . " . " . $layoutCodeName . " ', \$ this); ?> " ;
break ;
2016-02-26 00:20:09 +00:00
case 5 : // under
// set as title layout
$this -> setLayout ( $viewName_single , $layoutCodeName , $items , 'layouttitle' );
// load to footer
2017-12-14 23:10:47 +00:00
$footer .= PHP_EOL . PHP_EOL . " <div class= \" clearfix \" ></div> " . PHP_EOL . " <?php echo JLayoutHelper::render(' " . $viewName_single . " . " . $layoutCodeName . " ', \$ this); ?> " ;
break ;
2016-02-26 00:20:09 +00:00
case 6 : // left side
$tabWidth = $tabWidth - 2 ;
// set as items layout
$this -> setLayout ( $viewName_single , $layoutCodeName , $items , 'layoutitems' );
// load the body
2017-12-14 23:10:47 +00:00
$leftside .= PHP_EOL . " \t <?php echo JLayoutHelper::render(' " . $viewName_single . " . " . $layoutCodeName . " ', \$ this); ?> " ;
break ;
2016-02-26 00:20:09 +00:00
case 7 : // right side
$tabWidth = $tabWidth - 2 ;
// set as items layout
$this -> setLayout ( $viewName_single , $layoutCodeName , $items , 'layoutitems' );
// load the body
2017-12-14 23:10:47 +00:00
$rightside .= PHP_EOL . " \t <?php echo JLayoutHelper::render(' " . $viewName_single . " . " . $layoutCodeName . " ', \$ this); ?> " ;
break ;
2016-02-26 00:20:09 +00:00
}
}
}
else
{
// set layout code name
2017-12-14 23:10:47 +00:00
$layoutCodeName = $tabCodeName . '_fullwidth' ;
2016-02-26 00:20:09 +00:00
// set identifiers
$linkedViewIdentifier [ $linkedViewId ] = $tabCodeName ;
//set function name
2017-12-14 23:10:47 +00:00
$codeName = ComponentbuilderHelper :: safeString ( $this -> uniquekey ( 3 ) . $tabCodeName );
2016-02-26 00:20:09 +00:00
// set as items layout
2017-12-14 23:10:47 +00:00
$this -> setLayout ( $viewName_single , $layoutCodeName , $codeName , 'layoutlinkedview' );
2016-02-26 00:20:09 +00:00
// set the lang to tab
$bucket [ $tabCodeName ][ 'lang' ] = $tabLangName ;
// set all the linked view stuff
$this -> secondRunAdmin [ 'setLinkedView' ][] = array (
'viewId' => $linkedViewId ,
'viewName_single' => $viewName_single ,
'codeName' => $codeName ,
'layoutCodeName' => $layoutCodeName ,
'key' => $keys [ $linkedViewId ][ 'key' ],
'parentKey' => $keys [ $linkedViewId ][ 'parentKey' ],
'addNewButon' => $keys [ $linkedViewId ][ 'addNewButton' ]);
// load the body
if ( ! isset ( $bucket [ $tabCodeName ][ 3 ]))
{
$bucket [ $tabCodeName ][ 3 ] = '' ;
}
2017-12-14 23:10:47 +00:00
$bucket [ $tabCodeName ][ 3 ] .= " <?php echo JLayoutHelper::render(' " . $viewName_single . " . " . $layoutCodeName . " ', \$ this); ?> " ;
2016-02-26 00:20:09 +00:00
}
// width calculator :)
if ( $tabWidth == 8 )
{
$mainwidth = 8 ;
$sidewidth = 2 ;
}
elseif ( $tabWidth == 10 && $mainwidth != 8 )
{
$mainwidth = 9 ;
$sidewidth = 3 ;
}
$bucket [ $tabCodeName ][ 'lr' ] = $lrCounter ;
}
// tab counter
$tabCounter = 0 ;
// check if width is still 12
$span = '' ;
if ( $mainwidth != 12 )
{
2017-12-14 23:10:47 +00:00
$span = 'span' . $mainwidth ;
2016-02-26 00:20:09 +00:00
}
// start building body
2017-12-14 23:10:47 +00:00
$body = PHP_EOL . '<div class="form-horizontal">' ;
2017-04-26 08:55:02 +00:00
if ( ComponentbuilderHelper :: checkString ( $span ))
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t " . '<div class="' . $span . '">' ;
2017-04-26 08:55:02 +00:00
}
2016-02-26 00:20:09 +00:00
// now build the template
foreach ( $bucket as $tabCodeName => $posions )
{
// check main if both left and right is set
$lrCounter = $posions [ 'lr' ];
// get lang string
$tabLangName = $posions [ 'lang' ];
// build main center
2017-12-14 23:10:47 +00:00
$main = '' ;
2016-02-26 00:20:09 +00:00
$mainbottom = '' ;
foreach ( $posions as $posion => $string )
{
if ( $lrCounter == 2 )
{
2017-12-14 23:10:47 +00:00
switch ( $posion )
2016-02-26 00:20:09 +00:00
{
case 1 : // left
case 2 : // right
2017-12-14 23:10:47 +00:00
$main .= PHP_EOL . " \t \t \t " . '<div class="span6">' ;
$main .= PHP_EOL . " \t \t \t \t " . $string ;
$main .= PHP_EOL . " \t \t \t " . '</div>' ;
break ;
2016-02-26 00:20:09 +00:00
}
}
else
{
2017-12-14 23:10:47 +00:00
switch ( $posion )
2016-02-26 00:20:09 +00:00
{
case 1 : // left
case 2 : // right
2017-12-14 23:10:47 +00:00
$main .= PHP_EOL . " \t \t \t " . '<div class="span12">' ;
$main .= PHP_EOL . " \t \t \t \t " . $string ;
$main .= PHP_EOL . " \t \t \t " . '</div>' ;
break ;
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
switch ( $posion )
2016-02-26 00:20:09 +00:00
{
case 3 : // fullwidth
2017-12-14 23:10:47 +00:00
$mainbottom .= PHP_EOL . " \t \t \t " . '<div class="span12">' ;
$mainbottom .= PHP_EOL . " \t \t \t \t " . $string ;
$mainbottom .= PHP_EOL . " \t \t \t " . '</div>' ;
break ;
2016-02-26 00:20:09 +00:00
}
}
// set acctive tab
if ( $tabCounter == 0 )
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . PHP_EOL . " \t <?php echo JHtml::_('bootstrap.startTabSet', ' " . $viewName_single . " Tab', array('active' => ' " . $tabCodeName . " ')); ?> " ;
2016-02-26 00:20:09 +00:00
}
// if this is a linked view set permissions
$closeIT = false ;
2017-12-14 23:10:47 +00:00
if ( isset ( $linkedViewIdentifier ) && ComponentbuilderHelper :: checkArray ( $linkedViewIdentifier ) && in_array ( $tabCodeName , $linkedViewIdentifier ))
2016-02-26 00:20:09 +00:00
{
// get view name
2017-04-07 20:33:35 +00:00
$linkedViewId = array_search ( $tabCodeName , $linkedViewIdentifier );
2016-02-26 00:20:09 +00:00
$linkedViewData = $this -> getAdminViewData ( $linkedViewId );
$linkedCodeName = ComponentbuilderHelper :: safeString ( $linkedViewData -> name_single );
// setup correct core target
$coreLoadLinked = false ;
if ( isset ( $this -> permissionCore [ $linkedCodeName ]))
{
$coreLinked = $this -> permissionCore [ $linkedCodeName ];
$coreLoadLinked = true ;
}
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoadLinked && isset ( $coreLinked [ 'core.access' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $coreLinked [ 'core.access' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $coreLinked [ 'core.access' ]]) && in_array ( $linkedCodeName , $this -> permissionBuilder [ 'global' ][ $coreLinked [ 'core.access' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . PHP_EOL . " \t <?php if ( \$ this->canDo->get(' " . $coreLinked [ 'core.access' ] . " ')) : ?> " ;
2016-02-26 00:20:09 +00:00
$closeIT = true ;
}
else
{
2017-02-09 16:11:10 +00:00
$body .= PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
// insure clear
2017-12-14 23:10:47 +00:00
unset ( $coreLoadLinked , $coreLinked , $linkedViewData );
2016-02-26 00:20:09 +00:00
}
else
{
2017-02-09 16:11:10 +00:00
$body .= PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
// start tab
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t <?php echo JHtml::_('bootstrap.addTab', ' " . $viewName_single . " Tab', ' " . $tabCodeName . " ', JText::_(' " . $tabLangName . " ', true)); ?> " ;
2016-02-26 00:20:09 +00:00
// add the main
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t " . '<div class="row-fluid form-horizontal-desktop">' ;
2016-02-26 00:20:09 +00:00
$body .= $main ;
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t </div> " ;
2016-02-26 00:20:09 +00:00
if ( strlen ( $mainbottom ) > 0 )
{
// add the main bottom
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t " . '<div class="row-fluid form-horizontal-desktop">' ;
2016-02-26 00:20:09 +00:00
$body .= $mainbottom ;
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t </div> " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t <?php echo JHtml::_('bootstrap.endTab'); ?> " ;
if ( $closeIT )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t <?php endif; ?> " ;
2016-02-26 00:20:09 +00:00
}
// set counter
$tabCounter ++ ;
}
// set default publishing tab lang
2017-12-14 23:10:47 +00:00
$tabLangName = $langView . '_PUBLISHING' ;
2016-02-26 00:20:09 +00:00
// add to lang array
if ( ! isset ( $this -> langContent [ $this -> lang ][ $tabLangName ]))
{
$this -> langContent [ $this -> lang ][ $tabLangName ] = 'Publishing' ;
}
2016-06-02 16:18:49 +00:00
// the default publishing items
2017-10-26 16:43:51 +00:00
$items = array ( 'left' => array (), 'right' => array ());
// Setup the default (custom) fields
// only load (1 => 'left', 2 => 'right')
$fieldsAddedRight = false ;
if ( isset ( $this -> newPublishingFields [ $viewName_single ]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
foreach ( $this -> newPublishingFields [ $viewName_single ] as $df_alignment => $df_items )
2016-06-02 16:18:49 +00:00
{
2017-12-14 23:10:47 +00:00
foreach ( $df_items as $df_order => $df_name )
2016-06-02 16:18:49 +00:00
{
2017-10-26 16:43:51 +00:00
if ( $df_alignment == 2 || $df_alignment == 1 )
{
$items [ $alignmentNames [ $df_alignment ]][ $df_order ] = $df_name ;
}
else
{
$this -> app -> enqueueMessage ( JText :: sprintf ( 'Your <b>%s</b> field could not be added, since the <b>%s</b> alignment position is not available in the %s (publishing) tab. Please only target <b>Left or right</b> in the publishing tab.' , $df_name , $alignmentNames [ $df_alignment ], $viewName_single ), 'warning' );
}
2016-06-02 16:18:49 +00:00
}
2017-10-26 16:43:51 +00:00
}
// set switch to trigger notice if custom fields added to right
if ( ComponentbuilderHelper :: checkArray ( $items [ 'right' ]))
{
$fieldsAddedRight = true ;
}
}
// load all defaults
$loadDefaultFields = array (
'left' => array ( 'created' , 'created_by' , 'modified' , 'modified_by' ),
'right' => array ( 'published' , 'ordering' , 'access' , 'version' , 'hits' , 'id' )
2017-12-14 23:10:47 +00:00
);
2017-10-26 16:43:51 +00:00
foreach ( $loadDefaultFields as $d_alignment => $defaultFields )
{
2017-12-14 23:10:47 +00:00
foreach ( $defaultFields as $defaultField )
2017-10-26 16:43:51 +00:00
{
if ( ! isset ( $this -> movedPublishingFields [ $viewName_single ][ $defaultField ]))
2016-06-02 16:18:49 +00:00
{
2017-10-26 16:43:51 +00:00
if ( $defaultField != 'access' )
{
$items [ $d_alignment ][] = $defaultField ;
}
elseif ( $defaultField === 'access' && isset ( $this -> accessBuilder [ $viewName_single ]) && ComponentbuilderHelper :: checkString ( $this -> accessBuilder [ $viewName_single ]))
{
$items [ $d_alignment ][] = $defaultField ;
}
2016-06-02 16:18:49 +00:00
}
}
2016-02-26 00:20:09 +00:00
}
// check if metadata is added to this view
if ( isset ( $this -> metadataBuilder [ $viewName_single ]) && ComponentbuilderHelper :: checkString ( $this -> metadataBuilder [ $viewName_single ]))
{
// set default publishing tab code name
$tabCodeNameLeft = 'publishing' ;
$tabCodeNameRight = 'metadata' ;
// the default publishing tiems
2017-10-26 16:43:51 +00:00
if ( ComponentbuilderHelper :: checkArray ( $items [ 'left' ]) || ComponentbuilderHelper :: checkArray ( $items [ 'right' ]))
2016-06-02 16:18:49 +00:00
{
2017-10-26 16:43:51 +00:00
$items_one = '' ;
// load the items into one side
if ( ComponentbuilderHelper :: checkArray ( $items [ 'left' ]))
{
2017-12-14 23:10:47 +00:00
$items_one .= " ' " . implode ( " ', " . PHP_EOL . " \t ' " , $items [ 'left' ]) . " ' " ;
2017-10-26 16:43:51 +00:00
}
if ( ComponentbuilderHelper :: checkArray ( $items [ 'right' ]))
{
// there is already fields just add these
if ( strlen ( $items_one ) > 3 )
{
2017-12-14 23:10:47 +00:00
$items_one .= " , " . PHP_EOL . " \t ' " . implode ( " ', " . PHP_EOL . " \t ' " , $items [ 'right' ]) . " ' " ;
2017-10-26 16:43:51 +00:00
}
// no fields has been added yet
else
{
2017-12-14 23:10:47 +00:00
$items_one .= " ' " . implode ( " ', " . PHP_EOL . " \t ' " , $items [ 'right' ]) . " ' " ;
2017-10-26 16:43:51 +00:00
}
}
// only triger the info notice if there were custom fields targeted to the right alignment position.
if ( $fieldsAddedRight )
{
$this -> app -> enqueueMessage ( JText :: sprintf ( 'Your field/s added to the <b>right</b> alignment position in the %s (publishing) tab was added to the <b>left</b>. Since we have metadata fields on the right. Fields can only be loaded to the right of the publishing tab if there is no metadata fields.' , $viewName_single ), 'Notice' );
}
2016-06-02 16:18:49 +00:00
// set the publishing layout
$this -> setLayout ( $viewName_single , $tabCodeNameLeft , $items_one , 'layoutpublished' );
$items_one = true ;
}
else
{
2017-12-14 23:10:47 +00:00
$items_one = false ;
2016-06-02 16:18:49 +00:00
}
// set the metadata layout
2017-12-14 23:10:47 +00:00
$this -> setLayout ( $viewName_single , $tabCodeNameRight , false , 'layoutmetadata' );
2016-06-02 16:18:49 +00:00
$items_two = true ;
2016-02-26 00:20:09 +00:00
}
else
{
// set default publishing tab code name
$tabCodeNameLeft = 'publishing' ;
$tabCodeNameRight = 'publlshing' ;
// the default publishing tiems
2017-10-26 16:43:51 +00:00
if ( ComponentbuilderHelper :: checkArray ( $items [ 'left' ]) || ComponentbuilderHelper :: checkArray ( $items [ 'right' ]))
2016-06-02 16:18:49 +00:00
{
2017-10-26 16:43:51 +00:00
// load left items that remain
if ( ComponentbuilderHelper :: checkArray ( $items [ 'left' ]))
2016-06-02 16:18:49 +00:00
{
// load all items
2017-12-14 23:10:47 +00:00
$items_one = " ' " . implode ( " ', " . PHP_EOL . " \t ' " , $items [ 'left' ]) . " ' " ;
2016-06-02 16:18:49 +00:00
// set the publishing layout
$this -> setLayout ( $viewName_single , $tabCodeNameLeft , $items_one , 'layoutpublished' );
$items_one = true ;
}
2017-10-26 16:43:51 +00:00
// load right items that remain
if ( ComponentbuilderHelper :: checkArray ( $items [ 'right' ]))
2016-06-02 16:18:49 +00:00
{
// load all items
2017-12-14 23:10:47 +00:00
$items_two = " ' " . implode ( " ', " . PHP_EOL . " \t ' " , $items [ 'right' ]) . " ' " ;
2016-06-02 16:18:49 +00:00
// set the publishing layout
$this -> setLayout ( $viewName_single , $tabCodeNameRight , $items_two , 'layoutpublished' );
$items_two = true ;
}
}
else
{
$items_one = false ;
2017-12-14 23:10:47 +00:00
$items_two = false ;
2016-06-02 16:18:49 +00:00
}
2016-02-26 00:20:09 +00:00
}
2016-06-02 16:18:49 +00:00
if ( $items_one && $items_two )
2016-02-26 00:20:09 +00:00
{
2016-06-02 16:18:49 +00:00
$classs = " span6 " ;
}
elseif ( $items_one || $items_two )
{
$classs = " span12 " ;
}
// only load this if needed
if ( $items_one || $items_two )
{
// check if the item has permissions.
$publishingPer = array ();
2017-12-14 23:10:47 +00:00
$allToBeChekced = array ( 'core.delete' , 'core.edit.created_by' , 'core.edit.state' , 'core.edit.created' );
2016-06-02 16:18:49 +00:00
foreach ( $allToBeChekced as $core_permission )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ $core_permission ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ $core_permission ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ $core_permission ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ $core_permission ]]))
2016-06-02 16:18:49 +00:00
{
// set permissions.
2017-12-14 23:10:47 +00:00
$publishingPer [] = " \$ this->canDo->get(' " . $core [ $core_permission ] . " ') " ;
2016-06-02 16:18:49 +00:00
}
else
{
// set permissions.
2017-12-14 23:10:47 +00:00
$publishingPer [] = " \$ this->canDo->get(' " . $core_permission . " ') " ;
2016-06-02 16:18:49 +00:00
}
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . PHP_EOL . " \t <?php if ( " . implode ( ' || ' , $publishingPer ) . " ) : ?> " ;
2016-06-02 16:18:49 +00:00
// set the default publishing tab
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t <?php echo JHtml::_('bootstrap.addTab', ' " . $viewName_single . " Tab', ' " . $tabCodeNameLeft . " ', JText::_(' " . $tabLangName . " ', true)); ?> " ;
$body .= PHP_EOL . " \t \t " . '<div class="row-fluid form-horizontal-desktop">' ;
2016-06-02 16:18:49 +00:00
if ( $items_one )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t \t " . '<div class="' . $classs . '">' ;
$body .= PHP_EOL . " \t \t \t \t <?php echo JLayoutHelper::render(' " . $viewName_single . " . " . $tabCodeNameLeft . " ', \$ this); ?> " ;
$body .= PHP_EOL . " \t \t \t </div> " ;
2016-06-02 16:18:49 +00:00
}
if ( $items_two )
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t \t " . '<div class="' . $classs . '">' ;
$body .= PHP_EOL . " \t \t \t \t <?php echo JLayoutHelper::render(' " . $viewName_single . " . " . $tabCodeNameRight . " ', \$ this); ?> " ;
$body .= PHP_EOL . " \t \t \t </div> " ;
2016-06-02 16:18:49 +00:00
}
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t </div> " ;
$body .= PHP_EOL . " \t <?php echo JHtml::_('bootstrap.endTab'); ?> " ;
$body .= PHP_EOL . " \t <?php endif; ?> " ;
2016-06-02 16:18:49 +00:00
}
2016-02-26 00:20:09 +00:00
// make sure we dont load it to a view with the name component
if ( $viewName_single != 'component' )
{
// set permissions tab lang
2017-12-14 23:10:47 +00:00
$tabLangName = $langView . '_PERMISSION' ;
2016-02-26 00:20:09 +00:00
// set permissions tab code name
$tabCodeName = 'permissions' ;
// add to lang array
if ( ! isset ( $this -> langContent [ $this -> lang ][ $tabLangName ]))
{
$this -> langContent [ $this -> lang ][ $tabLangName ] = 'Permissions' ;
}
// set the permissions tab
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . PHP_EOL . " \t <?php if ( \$ this->canDo->get('core.admin')) : ?> " ;
$body .= PHP_EOL . " \t <?php echo JHtml::_('bootstrap.addTab', ' " . $viewName_single . " Tab', ' " . $tabCodeName . " ', JText::_(' " . $tabLangName . " ', true)); ?> " ;
$body .= PHP_EOL . " \t \t " . '<div class="row-fluid form-horizontal-desktop">' ;
$body .= PHP_EOL . " \t \t \t " . '<div class="span12">' ;
$body .= PHP_EOL . " \t \t \t \t " . '<fieldset class="adminform">' ;
$body .= PHP_EOL . " \t \t \t \t \t " . '<div class="adminformlist">' ;
$body .= PHP_EOL . " \t \t \t \t \t <?php foreach ( \$ this->form->getFieldset('accesscontrol') as \$ field): ?> " ;
$body .= PHP_EOL . " \t \t \t \t \t \t <div> " ;
$body .= PHP_EOL . " \t \t \t \t \t \t \t <?php echo \$ field->label; echo \$ field->input;?> " ;
$body .= PHP_EOL . " \t \t \t \t \t \t </div> " ;
$body .= PHP_EOL . " \t \t \t \t \t \t " . '<div class="clearfix"></div>' ;
$body .= PHP_EOL . " \t \t \t \t \t <?php endforeach; ?> " ;
$body .= PHP_EOL . " \t \t \t \t \t </div> " ;
$body .= PHP_EOL . " \t \t \t \t </fieldset> " ;
$body .= PHP_EOL . " \t \t \t </div> " ;
$body .= PHP_EOL . " \t \t </div> " ;
$body .= PHP_EOL . " \t <?php echo JHtml::_('bootstrap.endTab'); ?> " ;
$body .= PHP_EOL . " \t <?php endif; ?> " ;
2016-02-26 00:20:09 +00:00
}
// end the tab set
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . PHP_EOL . " \t <?php echo JHtml::_('bootstrap.endTabSet'); ?> " ;
$body .= PHP_EOL . PHP_EOL . " \t <div> " ;
$body .= PHP_EOL . " \t \t " . '<input type="hidden" name="task" value="' . $viewName_single . '.edit" />' ;
$body .= PHP_EOL . " \t \t <?php echo JHtml::_('form.token'); ?> " ;
$body .= PHP_EOL . " \t </div> " ;
$body .= PHP_EOL . " \t </div> " ;
$body .= PHP_EOL . " </div> " ;
2016-02-26 00:20:09 +00:00
// check if left has been set
2017-12-14 23:10:47 +00:00
if ( strlen ( $leftside ) > 0 )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$left = '<div class="span' . $sidewidth . '">' . $leftside . PHP_EOL . " </div> " ;
2016-02-26 00:20:09 +00:00
}
else
{
$left = '' ;
}
// check if right has been set
2017-12-14 23:10:47 +00:00
if ( strlen ( $rightside ) > 0 )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$right = '<div class="span' . $sidewidth . '">' . $rightside . PHP_EOL . " </div> " ;
2016-02-26 00:20:09 +00:00
}
else
{
$right = '' ;
}
// set active tab and return
2017-12-14 23:10:47 +00:00
return $header . $left . $body . $right . $footer ;
2016-02-26 00:20:09 +00:00
}
return '' ;
}
2017-12-14 23:10:47 +00:00
2016-05-31 05:11:07 +00:00
public function setFadeInEfect ( & $view )
{
2016-05-31 05:36:31 +00:00
// check if we should load the fade in affect
if ( $view [ 'settings' ] -> add_fadein == 1 )
2016-05-31 05:11:07 +00:00
{
// set view name
$fadein [] = " <script type= \" text/javascript \" > " ;
$fadein [] = " \t // waiting spinner " ;
$fadein [] = " \t var outerDiv = jQuery('body'); " ;
$fadein [] = " \t jQuery('<div id= \" loading \" ></div>') " ;
2017-12-14 23:10:47 +00:00
$fadein [] = " \t \t .css( \" background \" , \" rgba(255, 255, 255, .8) url('components/com_ " . $this -> fileContentStatic [ '###component###' ] . " /assets/images/import.gif') 50% 15% no-repeat \" ) " ;
2016-05-31 05:11:07 +00:00
$fadein [] = " \t \t .css( \" top \" , outerDiv.position().top - jQuery(window).scrollTop()) " ;
$fadein [] = " \t \t .css( \" left \" , outerDiv.position().left - jQuery(window).scrollLeft()) " ;
$fadein [] = " \t \t .css( \" width \" , outerDiv.width()) " ;
$fadein [] = " \t \t .css( \" height \" , outerDiv.height()) " ;
$fadein [] = " \t \t .css( \" position \" , \" fixed \" ) " ;
$fadein [] = " \t \t .css( \" opacity \" , \" 0.80 \" ) " ;
$fadein [] = " \t \t .css( \" -ms-filter \" , \" progid:DXImageTransform.Microsoft.Alpha(Opacity = 80) \" ) " ;
$fadein [] = " \t \t .css( \" filter \" , \" alpha(opacity = 80) \" ) " ;
$fadein [] = " \t \t .css( \" display \" , \" none \" ) " ;
$fadein [] = " \t \t .appendTo(outerDiv); " ;
$fadein [] = " \t jQuery('#loading').show(); " ;
$fadein [] = " \t // when page is ready remove and show " ;
$fadein [] = " \t jQuery(window).load(function() { " ;
2017-12-14 23:10:47 +00:00
$fadein [] = " \t \t jQuery('# " . $this -> fileContentStatic [ '###component###' ] . " _loader').fadeIn('fast'); " ;
2016-05-31 05:11:07 +00:00
$fadein [] = " \t \t jQuery('#loading').hide(); " ;
$fadein [] = " \t }); " ;
$fadein [] = " </script> " ;
2017-12-14 23:10:47 +00:00
$fadein [] = " <div id= \" " . $this -> fileContentStatic [ '###component###' ] . " _loader \" style= \" display: none; \" > " ;
2016-05-31 05:11:07 +00:00
2017-02-09 16:11:10 +00:00
return implode ( PHP_EOL , $fadein );
2016-05-31 05:11:07 +00:00
}
2017-12-14 23:10:47 +00:00
return " <div id= \" " . $this -> fileContentStatic [ '###component###' ] . " _loader \" > " ;
2016-05-31 05:11:07 +00:00
}
2016-02-26 00:20:09 +00:00
2016-04-22 12:03:43 +00:00
/**
* @ param $viewName_single
* @ param $layoutName
* @ param $items
* @ param $type
2017-12-14 23:10:47 +00:00
*/
2016-02-26 00:20:09 +00:00
public function setLayout ( $viewName_single , $layoutName , $items , $type )
{
// first build the layout file
$target = array ( 'admin' => $viewName_single );
2017-12-14 23:10:47 +00:00
$this -> buildDynamique ( $target , $type , $layoutName );
2016-02-26 00:20:09 +00:00
// add to front if needed
2017-02-01 13:17:04 +00:00
if ( $this -> lang === 'both' )
2016-02-26 00:20:09 +00:00
{
$target = array ( 'site' => $viewName_single );
2017-12-14 23:10:47 +00:00
$this -> buildDynamique ( $target , $type , $layoutName );
2016-02-26 00:20:09 +00:00
}
if ( ComponentbuilderHelper :: checkString ( $items ))
{
// ###LAYOUTITEMS### <<<DYNAMIC>>>
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $viewName_single . '_' . $layoutName ][ '###LAYOUTITEMS###' ] = $items ;
2016-02-26 00:20:09 +00:00
}
else
{
// ###LAYOUTITEMS### <<<DYNAMIC>>>
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $viewName_single . '_' . $layoutName ][ '###bogus###' ] = 'boom' ;
2016-02-26 00:20:09 +00:00
}
}
2016-04-22 12:03:43 +00:00
/**
* @ param $args
2017-12-14 23:10:47 +00:00
*/
2016-02-26 00:20:09 +00:00
public function setLinkedView ( $args )
{
2016-04-22 12:03:43 +00:00
/**
* @ var $viewId
* @ var $viewName_single
* @ var $codeName
* @ var $layoutCodeName
* @ var $key
* @ var $parentKey
* @ var $addNewButon
*/
2016-02-26 00:20:09 +00:00
extract ( $args , EXTR_PREFIX_SAME , " oops " );
$single = '' ;
2017-12-14 23:10:47 +00:00
$list = '' ;
2016-02-26 00:20:09 +00:00
foreach ( $this -> componentData -> admin_views as $array )
{
if ( $array [ 'adminview' ] == $viewId )
{
$single = ComponentbuilderHelper :: safeString ( $array [ 'settings' ] -> name_single );
$list = ComponentbuilderHelper :: safeString ( $array [ 'settings' ] -> name_list );
break ;
}
}
if ( ComponentbuilderHelper :: checkString ( $single ) && ComponentbuilderHelper :: checkString ( $list ))
{
2017-12-12 13:18:27 +00:00
$head = $this -> setListHeadLinked ( $single , $list , $addNewButon , $viewName_single );
$body = $this -> setListBodyLinked ( $single , $list , $viewName_single );
2017-12-14 23:10:47 +00:00
$functionName = ComponentbuilderHelper :: safeString ( $codeName , 'F' );
2016-02-26 00:20:09 +00:00
// ###LAYOUTITEMSTABLE### <<<DYNAMIC>>>
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $viewName_single . '_' . $layoutCodeName ][ '###LAYOUTITEMSTABLE###' ] = $head . $body ;
2016-02-26 00:20:09 +00:00
// ###LAYOUTITEMSHEADER### <<<DYNAMIC>>>
2017-12-14 23:10:47 +00:00
$headerscript = '$edit = "index.php?option=com_' . $this -> fileContentStatic [ '###component###' ] . '&view=' . $list . '&task=' . $single . '.edit";' ;
2017-12-12 13:18:27 +00:00
if ( $addNewButon > 0 )
2016-02-26 00:20:09 +00:00
{
2017-12-12 13:18:27 +00:00
// add the link for new
if ( $addNewButon == 1 || $addNewButon == 2 )
{
2017-12-14 23:10:47 +00:00
$headerscript .= PHP_EOL . '$ref = ($id) ? "&ref=' . $viewName_single . '&refid=".$id : "";' ;
$headerscript .= PHP_EOL . '$new = "index.php?option=com_' . $this -> fileContentStatic [ '###component###' ] . '&view=' . $single . '&layout=edit".$ref;' ;
2017-12-12 13:18:27 +00:00
}
// and the link for close and new
if ( $addNewButon == 2 || $addNewButon == 3 )
{
2017-12-14 23:10:47 +00:00
$headerscript .= PHP_EOL . '$close_new = "index.php?option=com_' . $this -> fileContentStatic [ '###component###' ] . '&view=' . $single . '&layout=edit";' ;
2017-12-12 13:18:27 +00:00
}
2017-12-14 23:10:47 +00:00
$headerscript .= PHP_EOL . '$can = ' . $this -> fileContentStatic [ '###Component###' ] . 'Helper::getActions(' . " ' " . $single . " ' " . ');' ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $viewName_single . '_' . $layoutCodeName ][ '###LAYOUTITEMSHEADER###' ] = $headerscript ;
2016-02-26 00:20:09 +00:00
// ###LINKEDVIEWITEMS### <<<DYNAMIC>>>
2017-12-15 01:10:10 +00:00
$this -> fileContentDynamic [ $viewName_single ][ '###LINKEDVIEWITEMS###' ] .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get Linked view data " . PHP_EOL . " \t \t \$ this-> " . $codeName . " = \$ this->get(' " . $functionName . " '); " ;
2016-02-26 00:20:09 +00:00
// ###LINKEDVIEWTABLESCRIPTS### <<<DYNAMIC>>>
$this -> fileContentDynamic [ $viewName_single ][ '###LINKEDVIEWTABLESCRIPTS###' ] = $this -> setFootableScripts ();
2017-12-14 23:10:47 +00:00
if ( strpos ( $parentKey , '-R>' ) !== false || strpos ( $parentKey , '-A>' ) !== false )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
list ( $parent_key ) = explode ( '-' , $parentKey );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
elseif ( strpos ( $parentKey , '-OR>' ) !== false )
2017-08-25 01:46:12 +00:00
{
// this is not good... (TODO)
2017-12-14 23:10:47 +00:00
$parent_keys = explode ( '-OR>' , $parentKey );
2017-08-25 01:46:12 +00:00
}
2016-02-26 00:20:09 +00:00
else
{
$parent_key = $parentKey ;
}
2017-12-14 23:10:47 +00:00
if ( strpos ( $key , '-R>' ) !== false || strpos ( $key , '-A>' ) !== false )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
list ( $_key ) = explode ( '-' , $key );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
elseif ( strpos ( $key , '-OR>' ) !== false )
2017-08-25 01:46:12 +00:00
{
2017-12-14 23:10:47 +00:00
$_key = str_replace ( '-OR>' , '' , $key );
2017-08-25 01:46:12 +00:00
}
2016-02-26 00:20:09 +00:00
else
{
$_key = $key ;
}
// ###LINKEDVIEWGLOBAL### <<<DYNAMIC>>>
2017-08-25 01:46:12 +00:00
if ( isset ( $parent_keys ) && ComponentbuilderHelper :: checkArray ( $parent_keys ))
{
$globalKey = array ();
foreach ( $parent_keys as $parent_key )
{
2017-12-14 23:10:47 +00:00
$globalKey [ $parent_key ] = ComponentbuilderHelper :: safeString ( $_key . $this -> uniquekey ( 4 ));
$this -> fileContentDynamic [ $viewName_single ][ '###LINKEDVIEWGLOBAL###' ] .= PHP_EOL . " \t \t \$ this-> " . $globalKey [ $parent_key ] . " = \$ item-> " . $parent_key . " ; " ;
2017-08-25 01:46:12 +00:00
}
}
else
{
// set the global key
2017-12-14 23:10:47 +00:00
$globalKey = ComponentbuilderHelper :: safeString ( $_key . $this -> uniquekey ( 4 ));
$this -> fileContentDynamic [ $viewName_single ][ '###LINKEDVIEWGLOBAL###' ] .= PHP_EOL . " \t \t \$ this-> " . $globalKey . " = \$ item-> " . $parent_key . " ; " ;
2017-08-25 01:46:12 +00:00
}
2016-02-26 00:20:09 +00:00
// ###LINKEDVIEWMETHODS### <<<DYNAMIC>>>
$this -> fileContentDynamic [ $viewName_single ][ '###LINKEDVIEWMETHODS###' ] .= $this -> setListQueryLinked ( $single , $list , $functionName , $key , $_key , $parentKey , $parent_key , $globalKey );
}
else
{
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $viewName_single . '_' . $layoutCodeName ][ '###LAYOUTITEMSTABLE###' ] = 'oops! error.....' ;
$this -> fileContentDynamic [ $viewName_single . '_' . $layoutCodeName ][ '###LAYOUTITEMSHEADER###' ] = '' ;
2016-02-26 00:20:09 +00:00
}
}
2016-04-22 12:03:43 +00:00
/**
* @ param bool $init
* @ return string
2017-12-10 19:17:26 +00:00
*/
public function setFootableScripts ( $init = true )
2016-02-26 00:20:09 +00:00
{
2016-04-22 12:03:43 +00:00
if ( ! isset ( $this -> footableVersion ) || 2 == $this -> footableVersion ) // loading version 2
{
2017-12-14 23:10:47 +00:00
$foo = PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Add the CSS for Footable. " ;
2017-12-22 19:46:03 +00:00
$foo .= PHP_EOL . " \t \t \$ this->document->addStyleSheet(JURI::root() .'media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /footable-v2/css/footable.core.min.css', array('version' => 'auto')); " ;
2017-12-14 23:10:47 +00:00
$foo .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Use the Metro Style " ;
$foo .= PHP_EOL . " \t \t if (!isset( \$ this->fooTableStyle) || 0 == \$ this->fooTableStyle) " ;
$foo .= PHP_EOL . " \t \t { " ;
2017-12-22 19:46:03 +00:00
$foo .= PHP_EOL . " \t \t \t \$ this->document->addStyleSheet(JURI::root() .'media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /footable-v2/css/footable.metro.min.css', array('version' => 'auto')); " ;
2017-12-14 23:10:47 +00:00
$foo .= PHP_EOL . " \t \t } " ;
$foo .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Use the Legacy Style. " ;
$foo .= PHP_EOL . " \t \t elseif (isset( \$ this->fooTableStyle) && 1 == \$ this->fooTableStyle) " ;
$foo .= PHP_EOL . " \t \t { " ;
2017-12-22 19:46:03 +00:00
$foo .= PHP_EOL . " \t \t \t \$ this->document->addStyleSheet(JURI::root() .'media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /footable-v2/css/footable.standalone.min.css', array('version' => 'auto')); " ;
2017-12-14 23:10:47 +00:00
$foo .= PHP_EOL . " \t \t } " ;
$foo .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Add the JavaScript for Footable " ;
2017-12-22 19:46:03 +00:00
$foo .= PHP_EOL . " \t \t \$ this->document->addScript(JURI::root() .'media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /footable-v2/js/footable.js', array('version' => 'auto')); " ;
$foo .= PHP_EOL . " \t \t \$ this->document->addScript(JURI::root() .'media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /footable-v2/js/footable.sort.js', array('version' => 'auto')); " ;
$foo .= PHP_EOL . " \t \t \$ this->document->addScript(JURI::root() .'media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /footable-v2/js/footable.filter.js', array('version' => 'auto')); " ;
$foo .= PHP_EOL . " \t \t \$ this->document->addScript(JURI::root() .'media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /footable-v2/js/footable.paginate.js', array('version' => 'auto')); " ;
2016-04-22 12:03:43 +00:00
if ( $init )
{
2017-12-14 23:10:47 +00:00
$foo .= PHP_EOL . PHP_EOL . " \t \t " . '$footable = "jQuery(document).ready(function() { jQuery(function () { jQuery(' . " '.footable' " . ').footable(); }); jQuery(' . " '.nav-tabs' " . ').on(' . " 'click' " . ', ' . " 'li' " . ', function() { setTimeout(tableFix, 10); }); }); function tableFix() { jQuery(' . " '.footable' " . ').trigger(' . " 'footable_resize' " . '); }";' ;
$foo .= PHP_EOL . " \t \t \$ this->document->addScriptDeclaration( \$ footable); " . PHP_EOL ;
2016-04-22 12:03:43 +00:00
}
}
elseif ( 3 == $this -> footableVersion ) // loading version 3
{
2017-12-14 23:10:47 +00:00
$foo = PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Add the CSS for Footable " ;
$foo .= PHP_EOL . " \t \t \$ this->document->addStyleSheet('https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css'); " ;
2017-12-22 19:46:03 +00:00
$foo .= PHP_EOL . " \t \t \$ this->document->addStyleSheet(JURI::root() .'media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /footable-v3/css/footable.standalone.min.css', array('version' => 'auto')); " ;
2017-12-14 23:10:47 +00:00
$foo .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Add the JavaScript for Footable (adding all funtions) " ;
2017-12-22 19:46:03 +00:00
$foo .= PHP_EOL . " \t \t \$ this->document->addScript(JURI::root() .'media/com_ " . $this -> fileContentStatic [ '###component###' ] . " /footable-v3/js/footable.min.js', array('version' => 'auto')); " ;
2016-04-22 12:03:43 +00:00
if ( $init )
{
2017-12-14 23:10:47 +00:00
$foo .= PHP_EOL . PHP_EOL . " \t \t " . '$footable = "jQuery(document).ready(function() { jQuery(function () { jQuery(' . " '.footable' " . ').footable();});});";' ;
$foo .= PHP_EOL . " \t \t \$ this->document->addScriptDeclaration( \$ footable); " . PHP_EOL ;
2016-04-22 12:03:43 +00:00
}
2016-02-26 00:20:09 +00:00
}
return $foo ;
}
2016-04-22 12:03:43 +00:00
/**
* @ param $viewName_single
* @ param $viewName_list
* @ param $refview
* @ return string
2017-12-14 23:10:47 +00:00
*/
2016-04-22 12:03:43 +00:00
public function setListBodyLinked ( $viewName_single , $viewName_list , $refview )
2016-02-26 00:20:09 +00:00
{
if ( isset ( $this -> listBuilder [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> listBuilder [ $viewName_list ]))
{
// component helper name
2017-12-14 23:10:47 +00:00
$Helper = $this -> fileContentStatic [ '###Component###' ] . 'Helper' ;
2016-02-26 00:20:09 +00:00
// make sure the custom links are only added once
$firstTimeBeingAdded = true ;
// setup correct core target
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $viewName_single ]))
{
$core = $this -> permissionCore [ $viewName_single ];
$coreLoad = true ;
}
$counter = 0 ;
// add the default
2017-12-14 23:10:47 +00:00
$body = PHP_EOL . " <tbody> " ;
$body .= PHP_EOL . " <?php foreach ( \$ items as \$ i => \$ item): ?> " ;
$body .= PHP_EOL . " \t <?php " ;
$body .= PHP_EOL . " \t \t \$ canCheckin = \$ user->authorise('core.manage', 'com_checkin') || \$ item->checked_out == \$ user->id || \$ item->checked_out == 0; " ;
$body .= PHP_EOL . " \t \t \$ userChkOut = JFactory::getUser( \$ item->checked_out); " ;
$body .= PHP_EOL . " \t \t \$ canDo = " . $Helper . " ::getActions(' " . $viewName_single . " ', \$ item,' " . $viewName_list . " '); " ;
$body .= PHP_EOL . " \t ?> " ;
$body .= PHP_EOL . " \t " . '<tr>' ;
2016-02-26 00:20:09 +00:00
// check if this view has fields that should not be escaped
$doNotEscape = false ;
if ( isset ( $this -> doNotEscape [ $viewName_list ]))
{
$doNotEscape = true ;
}
// start adding the dynamic
foreach ( $this -> listBuilder [ $viewName_list ] as $item )
{
$counter ++ ;
$checkoutTriger = false ;
2016-10-23 22:48:26 +00:00
if ( isset ( $item [ 'custom' ]) && ComponentbuilderHelper :: checkArray ( $item [ 'custom' ]) && isset ( $item [ 'custom' ][ 'table' ]) && ComponentbuilderHelper :: checkString ( $item [ 'custom' ][ 'table' ]))
2016-02-26 00:20:09 +00:00
{
$item [ 'id' ] = $item [ 'code' ];
2016-05-10 05:47:47 +00:00
if ( ! $item [ 'multiple' ])
{
2017-12-14 23:10:47 +00:00
$item [ 'code' ] = $item [ 'code' ] . '_' . $item [ 'custom' ][ 'text' ];
2016-05-10 05:47:47 +00:00
}
2016-02-26 00:20:09 +00:00
}
// check if translated vlaue is used
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> selectionTranslationFixBuilder [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> selectionTranslationFixBuilder [ $viewName_list ]) && array_key_exists ( $item [ 'code' ], $this -> selectionTranslationFixBuilder [ $viewName_list ]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$itemCode = '<?php echo JText::_($item->' . $item [ 'code' ] . '); ?>' ;
2016-02-26 00:20:09 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $item [ 'custom' ][ 'text' ] === 'user' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$itemCode = '<?php echo JFactory::getUser((int)$item->' . $item [ 'code' ] . ')->name; ?>' ;
2016-02-26 00:20:09 +00:00
}
elseif ( $doNotEscape )
{
if ( in_array ( $item [ 'code' ], $this -> doNotEscape [ $viewName_list ]))
{
2017-12-14 23:10:47 +00:00
$itemCode = '<?php echo $item->' . $item [ 'code' ] . '; ?>' ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$itemCode = '<?php echo $displayData->escape($item->' . $item [ 'code' ] . '); ?>' ;
2016-02-26 00:20:09 +00:00
}
}
else
{
2017-12-14 23:10:47 +00:00
$itemCode = '<?php echo $displayData->escape($item->' . $item [ 'code' ] . '); ?>' ;
2016-02-26 00:20:09 +00:00
}
if ( $item [ 'link' ])
{
// allways rest custom links
$customAdminView = '' ;
// if to be linked
2017-02-01 13:17:04 +00:00
if ( $item [ 'type' ] === 'category' && ! $item [ 'title' ])
2016-02-26 00:20:09 +00:00
{
$otherViews = $this -> catCodeBuilder [ $viewName_single ][ 'views' ];
// category and linked
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t " . '<td class="nowrap">' ;
$body .= PHP_EOL . " \t \t \t <?php if ( \$ user->authorise('core.edit', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " . " . $otherViews . " .category.' . (int) \$ item-> " . $item [ 'code' ] . " )): ?> " ;
$body .= PHP_EOL . " \t \t \t \t " . '<a href="index.php?option=com_categories&task=category.edit&id=<?php echo (int)$item->' . $item [ 'code' ] . '; ?>&extension=com_' . $this -> fileContentStatic [ '###component###' ] . '.' . $otherViews . '"><?php echo $displayData->escape($item->category_title); ?></a>' ;
$body .= PHP_EOL . " \t \t \t <?php else: ?> " ;
$body .= PHP_EOL . " \t \t \t \t <?php echo \$ displayData->escape( \$ item->category_title); ?> " ;
$body .= PHP_EOL . " \t \t \t <?php endif; ?> " ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-02-26 00:20:09 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $item [ 'type' ] === 'user' && ! $item [ 'title' ])
2016-02-26 00:20:09 +00:00
{
// user and linked
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <?php \$ " . $item [ 'code' ] . " User = JFactory::getUser( \$ item-> " . $item [ 'code' ] . " ); ?> " ;
$body .= PHP_EOL . " \t \t " . '<td class="nowrap">' ;
$body .= PHP_EOL . " \t \t \t <?php if ( \$ user->authorise('core.edit', 'com_users')): ?> " ;
$body .= PHP_EOL . " \t \t \t \t " . '<a href="index.php?option=com_users&task=user.edit&id=<?php echo (int) $item->' . $item [ 'code' ] . ' ?>"><?php echo $' . $item [ 'code' ] . 'User->name; ?></a>' ;
$body .= PHP_EOL . " \t \t \t <?php else: ?> " ;
$body .= PHP_EOL . " \t \t \t \t <?php echo \$ " . $item [ 'code' ] . " User->name; ?> " ;
$body .= PHP_EOL . " \t \t \t <?php endif; ?> " ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-02-26 00:20:09 +00:00
}
else
{
$add = true ;
if ( isset ( $item [ 'custom' ]) && ComponentbuilderHelper :: checkArray ( $item [ 'custom' ]) && $item [ 'custom' ][ 'extends' ] != 'user' && ! $item [ 'title' ])
{
2017-02-01 13:17:04 +00:00
if ( $refview === $item [ 'custom' ][ 'view' ])
2016-02-26 00:20:09 +00:00
{
// normal not linked
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <td> " ;
$body .= PHP_EOL . " \t \t \t " . $itemCode ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-02-26 00:20:09 +00:00
$add = false ;
}
else
{
// link to that item instead
2017-12-14 23:10:47 +00:00
$link = 'index.php?option=' . $item [ 'custom' ][ 'component' ] . '&view=' . $item [ 'custom' ][ 'views' ] . '&task=' . $item [ 'custom' ][ 'view' ] . '.edit&id=<?php echo $item->' . $item [ 'id' ] . '; ?>&ref=' . $refview . '&refid=<?php echo $id; ?>' ;
2016-02-26 00:20:09 +00:00
$coreLoadLink = false ;
if ( isset ( $this -> permissionCore [ $item [ 'custom' ][ 'view' ]]))
{
$coreLink = $this -> permissionCore [ $item [ 'custom' ][ 'view' ]];
$coreLoadLink = true ;
}
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoadLink && isset ( $this -> permissionBuilder [ $coreLink [ 'core.edit' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $coreLink [ 'core.edit' ]]) && in_array ( $item [ 'custom' ][ 'view' ], $this -> permissionBuilder [ $coreLink [ 'core.edit' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$accessCheck = " \$ user->authorise(' " . $coreLink [ 'core.edit' ] . " ', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " . " . $item [ 'custom' ][ 'view' ] . " .' . (int) \$ item-> " . $item [ 'id' ] . " ) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$accessCheck = " \$ user->authorise('core.edit', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " . " . $item [ 'custom' ][ 'view' ] . " .' . (int) \$ item-> " . $item [ 'id' ] . " ) " ;
2016-02-26 00:20:09 +00:00
}
}
}
2017-02-01 13:17:04 +00:00
elseif ( isset ( $item [ 'custom' ]) && ComponentbuilderHelper :: checkArray ( $item [ 'custom' ]) && $item [ 'custom' ][ 'extends' ] === 'user' && ! $item [ 'title' ])
2016-02-26 00:20:09 +00:00
{
// user and linked
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <?php \$ _ " . $item [ 'id' ] . " = JFactory::getUser( \$ item-> " . $item [ 'id' ] . " ); ?> " ;
$body .= PHP_EOL . " \t \t " . '<td class="nowrap">' ;
$body .= PHP_EOL . " \t \t \t <?php if ( \$ user->authorise('core.edit', 'com_users')): ?> " ;
$body .= PHP_EOL . " \t \t \t \t " . '<a href="index.php?option=com_users&task=user.edit&id=<?php echo (int) $item->' . $item [ 'id' ] . ' ?>"><?php echo $_' . $item [ 'id' ] . '->name; ?></a>' ;
$body .= PHP_EOL . " \t \t \t <?php else: ?> " ;
$body .= PHP_EOL . " \t \t \t \t <?php echo \$ _ " . $item [ 'id' ] . " ->name; ?> " ;
$body .= PHP_EOL . " \t \t \t <?php endif; ?> " ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-02-26 00:20:09 +00:00
$add = false ;
}
else
{
2017-12-14 23:10:47 +00:00
$link = '<?php echo $edit; ?>&id=<?php echo $item->id; ?>&ref=' . $refview . '&refid=<?php echo $id; ?>' ;
2016-02-26 00:20:09 +00:00
// check if custom links should be added to this list views
if ( isset ( $this -> customAdminViewListLink [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> customAdminViewListLink [ $viewName_list ]) && $firstTimeBeingAdded )
{
// make sure the custom links are only added once
$firstTimeBeingAdded = false ;
// start building the links
2017-12-14 23:10:47 +00:00
$customAdminView = PHP_EOL . " \t \t \t " . '<div class="btn-group">' ;
2016-02-26 00:20:09 +00:00
foreach ( $this -> customAdminViewListLink [ $viewName_list ] as $customLinkView )
{
2017-12-14 23:10:47 +00:00
$customAdminView .= PHP_EOL . " \t \t \t <?php if ( \$ canDo->get(' " . $customLinkView [ 'link' ] . " .access')): ?> " ;
$customAdminView .= PHP_EOL . " \t \t \t \t " . '<a class="hasTooltip btn btn-mini" href="index.php?option=com_' . $this -> fileContentStatic [ '###component###' ] . '&view=' . $customLinkView [ 'link' ] . '&id=<?php echo $item->id; ?>&ref=' . $refview . '&refid=<?php echo $id; ?>" title="<?php echo JText::_(' . " 'COM_ " . $this -> fileContentStatic [ '###COMPONENT###' ] . '_' . $customLinkView [ 'NAME' ] . " ' " . '); ?>" ><span class="icon-' . $customLinkView [ 'icon' ] . '"></span></a>' ;
$customAdminView .= PHP_EOL . " \t \t \t <?php else: ?> " ;
$customAdminView .= PHP_EOL . " \t \t \t \t " . '<a class="hasTooltip btn btn-mini disabled" href="#" title="<?php echo JText::_(' . " 'COM_ " . $this -> fileContentStatic [ '###COMPONENT###' ] . '_' . $customLinkView [ 'NAME' ] . " ' " . '); ?>"><span class="icon-' . $customLinkView [ 'icon' ] . '"></span></a>' ;
$customAdminView .= PHP_EOL . " \t \t \t <?php endif; ?> " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$customAdminView .= PHP_EOL . " \t \t \t " . '</div>' ;
2016-02-26 00:20:09 +00:00
}
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]))
2016-02-26 00:20:09 +00:00
{
// set permissions.
2017-12-14 23:10:47 +00:00
$accessCheck = " \$ canDo->get(' " . $core [ 'core.edit' ] . " ') " ;
2016-02-26 00:20:09 +00:00
}
else
{
// set permissions.
$accessCheck = " \$ canDo->get('core.edit') " ;
}
// triger the checked out script to be added
$checkoutTriger = true ;
}
if ( $add )
{
// set as linked
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t " . '<td class="nowrap">' ;
$body .= PHP_EOL . " \t \t \t <?php if ( " . $accessCheck . " ): ?> " ;
$body .= PHP_EOL . " \t \t \t \t " . '<a href="' . $link . '">' . $itemCode . '</a>' ;
2016-02-26 00:20:09 +00:00
if ( $checkoutTriger )
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t \t \t \t <?php if ( \$ item->checked_out): ?> " ;
$body .= PHP_EOL . " \t \t \t \t \t \t <?php echo JHtml::_('jgrid.checkedout', \$ i, \$ userChkOut->name, \$ item->checked_out_time, ' " . $viewName_list . " .', \$ canCheckin); ?> " ;
$body .= PHP_EOL . " \t \t \t \t \t <?php endif; ?> " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t \t <?php else: ?> " ;
$body .= PHP_EOL . " \t \t \t \t " . '<div class="name">' . $itemCode . '</div>' ;
$body .= PHP_EOL . " \t \t \t <?php endif; ?> " ;
$body .= $customAdminView ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-02-26 00:20:09 +00:00
}
}
}
else
{
2017-02-01 13:17:04 +00:00
if ( $item [ 'type' ] === 'category' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <td> " ;
$body .= PHP_EOL . " \t \t \t <?php echo \$ displayData->escape( \$ item->category_title); ?> " ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-02-26 00:20:09 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( ComponentbuilderHelper :: checkArray ( $item [ 'custom' ]) && $item [ 'custom' ][ 'extends' ] === 'user' )
2016-02-26 00:20:09 +00:00
{
// custom user and linked
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <?php \$ _ " . $item [ 'code' ] . " = JFactory::getUser( \$ item-> " . $item [ 'id' ] . " ); ?> " ;
$body .= PHP_EOL . " \t \t " . '<td>' ;
$body .= PHP_EOL . " \t \t \t <?php if ( \$ user->authorise('core.edit', 'com_users')): ?> " ;
$body .= PHP_EOL . " \t \t \t \t " . '<a href="index.php?option=com_users&task=user.edit&id=<?php echo (int) $item->' . $item [ 'id' ] . ' ?>"><?php echo $_' . $item [ 'code' ] . '->name; ?></a>' ;
$body .= PHP_EOL . " \t \t \t <?php else: ?> " ;
$body .= PHP_EOL . " \t \t \t \t <?php echo \$ _ " . $item [ 'code' ] . " ->name; ?> " ;
$body .= PHP_EOL . " \t \t \t <?php endif; ?> " ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-02-26 00:20:09 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $item [ 'type' ] === 'user' )
2016-06-02 16:18:49 +00:00
{
// user name only
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <?php \$ " . $item [ 'code' ] . " User = JFactory::getUser( \$ item-> " . $item [ 'code' ] . " ); ?> " ;
$body .= PHP_EOL . " \t \t " . '<td class="nowrap">' ;
$body .= PHP_EOL . " \t \t \t <?php echo \$ " . $item [ 'code' ] . " User->name; ?> " ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-06-02 16:18:49 +00:00
}
2016-02-26 00:20:09 +00:00
else
{
// normal not linked
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <td> " ;
$body .= PHP_EOL . " \t \t \t " . $itemCode ;
$body .= PHP_EOL . " \t \t </td> " ;
2016-02-26 00:20:09 +00:00
}
}
}
$counter = $counter + 2 ;
2017-12-14 23:10:47 +00:00
$data_value = ( 3 == $this -> footableVersion ) ? 'data-sort-value' : 'data-value' ;
2017-10-30 13:08:02 +00:00
// add the defaults
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . " \t \t <?php if ( \$ item->published == 1):?> " ;
$body .= PHP_EOL . " \t \t \t " . '<td class="center" ' . $data_value . '="1">' ;
$body .= PHP_EOL . " \t \t \t \t " . '<span class="status-metro status-published" title="<?php echo JText::_(' . " ' " . $this -> langPrefix . " _PUBLISHED' " . '); ?>">' ;
$body .= PHP_EOL . " \t \t \t \t \t " . '<?php echo JText::_(' . " ' " . $this -> langPrefix . " _PUBLISHED' " . '); ?>' ;
$body .= PHP_EOL . " \t \t \t \t " . '</span>' ;
$body .= PHP_EOL . " \t \t \t " . '</td>' ;
$body .= PHP_EOL . " \t \t <?php elseif ( \$ item->published == 0):?> " ;
$body .= PHP_EOL . " \t \t \t " . '<td class="center" ' . $data_value . '="2">' ;
$body .= PHP_EOL . " \t \t \t \t " . '<span class="status-metro status-inactive" title="<?php echo JText::_(' . " ' " . $this -> langPrefix . " _INACTIVE' " . '); ?>">' ;
$body .= PHP_EOL . " \t \t \t \t \t " . '<?php echo JText::_(' . " ' " . $this -> langPrefix . " _INACTIVE' " . '); ?>' ;
$body .= PHP_EOL . " \t \t \t \t " . '</span>' ;
$body .= PHP_EOL . " \t \t \t " . '</td>' ;
$body .= PHP_EOL . " \t \t <?php elseif ( \$ item->published == 2):?> " ;
$body .= PHP_EOL . " \t \t \t " . '<td class="center" ' . $data_value . '="3">' ;
$body .= PHP_EOL . " \t \t \t \t " . '<span class="status-metro status-archived" title="<?php echo JText::_(' . " ' " . $this -> langPrefix . " _ARCHIVED' " . '); ?>">' ;
$body .= PHP_EOL . " \t \t \t \t \t " . '<?php echo JText::_(' . " ' " . $this -> langPrefix . " _ARCHIVED' " . '); ?>' ;
$body .= PHP_EOL . " \t \t \t \t " . '</span>' ;
$body .= PHP_EOL . " \t \t \t " . '</td>' ;
$body .= PHP_EOL . " \t \t <?php elseif ( \$ item->published == -2):?> " ;
$body .= PHP_EOL . " \t \t \t " . '<td class="center" ' . $data_value . '="4">' ;
$body .= PHP_EOL . " \t \t \t \t " . '<span class="status-metro status-trashed" title="<?php echo JText::_(' . " ' " . $this -> langPrefix . " _TRASHED' " . '); ?>">' ;
$body .= PHP_EOL . " \t \t \t \t \t " . '<?php echo JText::_(' . " ' " . $this -> langPrefix . " _TRASHED' " . '); ?>' ;
$body .= PHP_EOL . " \t \t \t \t " . '</span>' ;
$body .= PHP_EOL . " \t \t \t " . '</td>' ;
$body .= PHP_EOL . " \t \t " . '<?php endif; ?>' ;
$body .= PHP_EOL . " \t \t " . '<td class="nowrap center hidden-phone">' ;
$body .= PHP_EOL . " \t \t \t <?php echo \$ item->id; ?> " ;
$body .= PHP_EOL . " \t \t </td> " ;
$body .= PHP_EOL . " \t </tr> " ;
$body .= PHP_EOL . " <?php endforeach; ?> " ;
$body .= PHP_EOL . " </tbody> " ;
2016-04-22 12:03:43 +00:00
if ( 2 == $this -> footableVersion )
{
2017-12-14 23:10:47 +00:00
$body .= PHP_EOL . '<tfoot class="hide-if-no-paging">' ;
$body .= PHP_EOL . " \t " . '<tr>' ;
$body .= PHP_EOL . " \t \t " . '<td colspan="' . $counter . '">' ;
$body .= PHP_EOL . " \t \t \t " . '<div class="pagination pagination-centered"></div>' ;
$body .= PHP_EOL . " \t \t " . '</td>' ;
$body .= PHP_EOL . " \t " . '</tr>' ;
$body .= PHP_EOL . '</tfoot>' ;
}
$body .= PHP_EOL . '</table>' ;
$body .= PHP_EOL . '<?php else: ?>' ;
$body .= PHP_EOL . " \t " . '<div class="alert alert-no-items">' ;
$body .= PHP_EOL . " \t \t " . '<?php echo JText::_(' . " 'JGLOBAL_NO_MATCHING_RESULTS' " . '); ?>' ;
$body .= PHP_EOL . " \t " . '</div>' ;
$body .= PHP_EOL . '<?php endif; ?>' ;
2016-02-26 00:20:09 +00:00
// return the build
return $body ;
}
return '' ;
}
2017-12-12 13:18:27 +00:00
public function setListHeadLinked ( $viewName_single , $viewName_list , $addNewButon , $refview )
2016-02-26 00:20:09 +00:00
{
if ( isset ( $this -> listBuilder [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> listBuilder [ $viewName_list ]))
{
// component helper name
2017-12-14 23:10:47 +00:00
$Helper = $this -> fileContentStatic [ '###Component###' ] . 'Helper' ;
2016-02-26 00:20:09 +00:00
$head = '' ;
// only add new button if set
2017-12-12 13:18:27 +00:00
if ( $addNewButon > 0 )
2016-02-26 00:20:09 +00:00
{
// setup correct core target
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $viewName_single ]))
{
$core = $this -> permissionCore [ $viewName_single ];
$coreLoad = true ;
}
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.create' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]))
2016-02-26 00:20:09 +00:00
{
// set permissions.
2017-12-14 23:10:47 +00:00
$accessCheck = " \$ can->get(' " . $core [ 'core.create' ] . " ') " ;
2016-02-26 00:20:09 +00:00
}
else
{
// set permissions.
$accessCheck = " \$ can->get('core.create') " ;
}
// add a button for new
2017-12-14 23:10:47 +00:00
$head = '<?php if (' . $accessCheck . '): ?>' ;
2017-12-12 13:18:27 +00:00
// make group button if needed
$tabB = " " ;
if ( $addNewButon == 2 )
{
2017-12-14 23:10:47 +00:00
$head .= PHP_EOL . " \t " . '<div class="btn-group">' ;
2017-12-12 13:18:27 +00:00
$tabB = " \t " ;
}
// add the new buttons
if ( $addNewButon == 1 || $addNewButon == 2 )
{
2017-12-14 23:10:47 +00:00
$head .= PHP_EOL . $tabB . " \t " . '<a class="btn btn-small btn-success" href="<?php echo $new; ?>"><span class="icon-new icon-white"></span> <?php echo JText::_(' . " ' " . $this -> langPrefix . " _NEW' " . '); ?></a>' ;
2017-12-12 13:18:27 +00:00
}
// add the close and new button
if ( $addNewButon == 2 || $addNewButon == 3 )
{
2017-12-14 23:10:47 +00:00
$head .= PHP_EOL . $tabB . " \t " . '<a class="btn btn-small" onclick="Joomla.submitbutton(\'' . $refview . '.cancel\');" href="<?php echo $close_new; ?>"><span class="icon-new"></span> <?php echo JText::_(' . " ' " . $this -> langPrefix . " _CLOSE_NEW' " . '); ?></a>' ;
2017-12-12 13:18:27 +00:00
}
// close group button if needed
if ( $addNewButon == 2 )
{
2017-12-14 23:10:47 +00:00
$head .= PHP_EOL . " \t " . '</div><br /><br />' ;
2017-12-12 13:18:27 +00:00
}
else
{
$head .= '<br /><br />' ;
}
2017-12-14 23:10:47 +00:00
$head .= PHP_EOL . '<?php endif; ?>' . PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$head .= '<?php if (' . $Helper . '::checkArray($items)): ?>' ;
2016-04-22 12:03:43 +00:00
// set the style for V2
2017-12-14 23:10:47 +00:00
$metro_blue = ( 2 == $this -> footableVersion ) ? ' metro-blue' : '' ;
2016-04-22 12:03:43 +00:00
// set the toggle for V3
2017-12-14 23:10:47 +00:00
$toggle = ( 3 == $this -> footableVersion ) ? ' data-show-toggle="true" data-toggle-column="first"' : '' ;
2016-04-22 12:03:43 +00:00
// set paging
2017-12-14 23:10:47 +00:00
$paging = ( 2 == $this -> footableVersion ) ? ' data-page-size="20" data-filter="#filter_' . $viewName_list . '"' : ' data-sorting="true" data-paging="true" data-paging-size="20" data-filtering="true"' ;
2016-04-22 12:03:43 +00:00
// add html fix for V3
2017-12-14 23:10:47 +00:00
$htmlFix = ( 3 == $this -> footableVersion ) ? ' data-type="html" data-sort-use="text"' : '' ;
$head .= PHP_EOL . '<table class="footable table data ' . $viewName_list . $metro_blue . '"' . $toggle . $paging . '>' ;
$head .= PHP_EOL . " <thead> " ;
2016-02-26 00:20:09 +00:00
// main lang prefix
2017-12-14 23:10:47 +00:00
$langView = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( $viewName_single , 'U' );
2016-02-26 00:20:09 +00:00
// set status lang
2017-12-14 23:10:47 +00:00
$statusLangName = $langView . '_STATUS' ;
2016-02-26 00:20:09 +00:00
// set id lang
2017-12-14 23:10:47 +00:00
$idLangName = $langView . '_ID' ;
2016-02-26 00:20:09 +00:00
// make sure only first link is used as togeler
$firstLink = true ;
// add to lang array
if ( ! isset ( $this -> langContent [ $this -> lang ][ $statusLangName ]))
{
$this -> langContent [ $this -> lang ][ $statusLangName ] = 'Status' ;
}
// add to lang array
2017-12-14 23:10:47 +00:00
if ( ! isset ( $this -> langContent [ $this -> lang ][ $idLangName ]))
2016-02-26 00:20:09 +00:00
{
$this -> langContent [ $this -> lang ][ $idLangName ] = 'Id' ;
}
2017-12-14 23:10:47 +00:00
$head .= PHP_EOL . " \t <tr> " ;
2016-02-26 00:20:09 +00:00
// set controller for data hiding options
$controller = 1 ;
// build the dynamic fields
foreach ( $this -> listBuilder [ $viewName_list ] as $item )
{
2017-12-14 23:10:47 +00:00
$setin = ( 2 == $this -> footableVersion ) ? ' data-hide="phone"' : ' data-breakpoints="xs sm"' ;
2016-02-26 00:20:09 +00:00
if ( $controller > 3 )
{
2016-04-22 12:03:43 +00:00
$setin = ( 2 == $this -> footableVersion ) ? ' data-hide="phone,tablet"' : ' data-breakpoints="xs sm md"' ;
2016-02-26 00:20:09 +00:00
}
if ( $controller > 6 )
{
2017-12-14 23:10:47 +00:00
$setin = ( 2 == $this -> footableVersion ) ? ' data-hide="all"' : ' data-breakpoints="all"' ;
2016-02-26 00:20:09 +00:00
}
if ( $item [ 'link' ] && $firstLink )
{
2017-12-14 23:10:47 +00:00
$setin = ( 2 == $this -> footableVersion ) ? ' data-toggle="true"' : '' ;
2016-02-26 00:20:09 +00:00
$firstLink = false ;
}
2017-12-14 23:10:47 +00:00
$head .= PHP_EOL . " \t \t <th " . $setin . $htmlFix . " > " ;
$head .= PHP_EOL . " \t \t \t <?php echo JText::_(' " . $item [ 'lang' ] . " '); ?> " ;
$head .= PHP_EOL . " \t \t </th> " ;
2016-02-26 00:20:09 +00:00
$controller ++ ;
}
2016-04-22 12:03:43 +00:00
// set some V3 attr
$data_hide = ( 2 == $this -> footableVersion ) ? 'data-hide="phone,tablet"' : 'data-breakpoints="xs sm md"' ;
2017-12-14 23:10:47 +00:00
$data_type = ( 2 == $this -> footableVersion ) ? 'data-type="numeric"' : 'data-type="number"' ;
2016-02-26 00:20:09 +00:00
// set default
2017-12-14 23:10:47 +00:00
$head .= PHP_EOL . " \t \t " . '<th width="10" ' . $data_hide . '>' ;
$head .= PHP_EOL . " \t \t \t <?php echo JText::_(' " . $statusLangName . " '); ?> " ;
$head .= PHP_EOL . " \t \t </th> " ;
$head .= PHP_EOL . " \t \t " . '<th width="5" ' . $data_type . ' ' . $data_hide . '>' ;
$head .= PHP_EOL . " \t \t \t <?php echo JText::_(' " . $idLangName . " '); ?> " ;
$head .= PHP_EOL . " \t \t </th> " ;
$head .= PHP_EOL . " \t </tr> " ;
$head .= PHP_EOL . " </thead> " ;
2016-02-26 00:20:09 +00:00
return $head ;
}
return '' ;
}
2016-04-22 12:03:43 +00:00
/**
* @ param $viewName_single
* @ param $viewName_list
* @ param $functionName
* @ param $key
* @ param $_key
* @ param $parentKey
* @ param $parent_key
* @ param $globalKey
2017-06-05 20:18:32 +00:00
* @ return string
*/
2016-02-26 00:20:09 +00:00
public function setListQueryLinked ( $viewName_single , $viewName_list , $functionName , $key , $_key , $parentKey , $parent_key , $globalKey )
{
// check if this view has category added
if ( isset ( $this -> categoryBuilder [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> categoryBuilder [ $viewName_list ]))
{
$categoryCodeName = $this -> categoryBuilder [ $viewName_list ][ 'code' ];
$addCategory = true ;
}
else
{
$addCategory = false ;
}
2017-12-14 23:10:47 +00:00
$query = PHP_EOL . PHP_EOL . " \t /** " ;
$query .= PHP_EOL . " \t * Method to get list data. " ;
$query .= PHP_EOL . " \t * " ;
$query .= PHP_EOL . " \t * @return mixed An array of data items on success, false on failure. " ;
$query .= PHP_EOL . " \t */ " ;
$query .= PHP_EOL . " \t public function get " . $functionName . " () " ;
$query .= PHP_EOL . " \t { " ;
2016-02-26 00:20:09 +00:00
// setup the query
2017-12-14 23:10:47 +00:00
$query .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the user object. " ;
$query .= PHP_EOL . " \t \t \$ user = JFactory::getUser(); " ;
$query .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Create a new query object. " ;
$query .= PHP_EOL . " \t \t \$ db = JFactory::getDBO(); " ;
$query .= PHP_EOL . " \t \t \$ query = \$ db->getQuery(true); " ;
$query .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Select some fields " ;
$query .= PHP_EOL . " \t \t \$ query->select('a.*'); " ;
2016-02-26 00:20:09 +00:00
// add the category
if ( $addCategory )
{
2017-12-14 23:10:47 +00:00
$query .= PHP_EOL . " \t \t \$ query->select( \$ db->quoteName('c.title','category_title')); " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$query .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " From the " . $this -> fileContentStatic [ '###component###' ] . " _ " . $viewName_single . " table " ;
$query .= PHP_EOL . " \t \t \$ query->from( \$ db->quoteName('#__ " . $this -> fileContentStatic [ '###component###' ] . " _ " . $viewName_single . " ', 'a')); " ;
2016-02-26 00:20:09 +00:00
// add the category
if ( $addCategory )
{
2017-12-14 23:10:47 +00:00
$query .= PHP_EOL . " \t \t \$ query->join('LEFT', \$ db->quoteName('#__categories', 'c') . ' ON (' . \$ db->quoteName('a. " . $categoryCodeName . " ') . ' = ' . \$ db->quoteName('c.id') . ')'); " ;
2016-02-26 00:20:09 +00:00
}
// add custom filtering php
2017-12-14 23:10:47 +00:00
$query .= $this -> getCustomScriptBuilder ( 'php_getlistquery' , $viewName_single , PHP_EOL . PHP_EOL );
2016-02-26 00:20:09 +00:00
// add the custom fields query
$query .= $this -> setCustomQuery ( $viewName_list , $viewName_single );
2017-08-25 01:46:12 +00:00
if ( ComponentbuilderHelper :: checkString ( $globalKey ) &&
2017-12-14 23:10:47 +00:00
$key && strpos ( $key , '-R>' ) === false && strpos ( $key , '-A>' ) === false && strpos ( $key , '-OR>' ) === false &&
$parentKey && strpos ( $parentKey , '-R>' ) === false && strpos ( $parentKey , '-A>' ) === false && strpos ( $parentKey , '-OR>' ) === false )
{
$query .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Filter by " . $globalKey . " global. " ;
$query .= PHP_EOL . " \t \t \$ " . $globalKey . " = \$ this-> " . $globalKey . " ; " ;
$query .= PHP_EOL . " \t \t if (is_numeric( \$ " . $globalKey . " )) " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t \$ query->where('a. " . $key . " = ' . (int) \$ " . $globalKey . " ); " ;
$query .= PHP_EOL . " \t \t } " ;
$query .= PHP_EOL . " \t \t elseif (is_string( \$ " . $globalKey . " )) " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t \$ query->where('a. " . $key . " = ' . \$ db->quote( \$ " . $globalKey . " )); " ;
$query .= PHP_EOL . " \t \t } " ;
$query .= PHP_EOL . " \t \t else " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t \$ query->where('a. " . $key . " = -5'); " ;
$query .= PHP_EOL . " \t \t } " ;
}
elseif ( strpos ( $parentKey , '-OR>' ) !== false || strpos ( $key , '-OR>' ) !== false )
2017-08-25 01:46:12 +00:00
{
// get both strings
2017-12-14 23:10:47 +00:00
if ( strpos ( $key , '-OR>' ) !== false )
2017-08-25 01:46:12 +00:00
{
$ORarray = explode ( '-OR>' , $key );
}
else
{
$ORarray = array ( $key );
}
// make sure we have an array
if ( ! ComponentbuilderHelper :: checkArray ( $globalKey ))
{
$globalKey = array ( $globalKey );
}
// now load the query (this may be to much... but hey let it write the code :)
foreach ( $globalKey as $_globalKey )
{
// now build the query
$ORquery = array ( 's' => array (), 'i' => array ());
foreach ( $ORarray as $ORkey )
{
2017-12-14 23:10:47 +00:00
$ORquery [ 'i' ][] = " a. " . $ORkey . " = ' . (int) \$ " . $_globalKey ;
$ORquery [ 's' ][] = " a. " . $ORkey . " = ' . \$ db->quote( \$ " . $_globalKey . " ) " ;
}
$query .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Filter by " . $_globalKey . " global. " ;
$query .= PHP_EOL . " \t \t \$ " . $_globalKey . " = \$ this-> " . $_globalKey . " ; " ;
$query .= PHP_EOL . " \t \t if (is_numeric( \$ " . $_globalKey . " )) " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t \$ query->where(' " . implode ( " . ' OR " , $ORquery [ 'i' ]) . " , ' OR'); " ;
$query .= PHP_EOL . " \t \t } " ;
$query .= PHP_EOL . " \t \t elseif (is_string( \$ " . $_globalKey . " )) " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t \$ query->where(' " . implode ( " . ' OR " , $ORquery [ 's' ]) . " , ' OR'); " ;
$query .= PHP_EOL . " \t \t } " ;
$query .= PHP_EOL . " \t \t else " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t \$ query->where('a. " . $ORkey . " = -5'); " ;
$query .= PHP_EOL . " \t \t } " ;
2017-08-25 01:46:12 +00:00
}
}
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> accessBuilder [ $viewName_single ]) && ComponentbuilderHelper :: checkString ( $this -> accessBuilder [ $viewName_single ]))
{
2017-12-14 23:10:47 +00:00
$query .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Join over the asset groups. " ;
$query .= PHP_EOL . " \t \t \$ query->select('ag.title AS access_level'); " ;
$query .= PHP_EOL . " \t \t \$ query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); " ;
$query .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Filter by access level. " ;
$query .= PHP_EOL . " \t \t if ( \$ access = \$ this->getState('filter.access')) " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t \$ query->where('a.access = ' . (int) \$ access); " ;
$query .= PHP_EOL . " \t \t } " ;
$query .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Implement View Level Access " ;
$query .= PHP_EOL . " \t \t if (! \$ user->authorise('core.options', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " ')) " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t \$ groups = implode(',', \$ user->getAuthorisedViewLevels()); " ;
$query .= PHP_EOL . " \t \t \t \$ query->where('a.access IN (' . \$ groups . ')'); " ;
$query .= PHP_EOL . " \t \t } " ;
}
$query .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Order the results by ordering " ;
$query .= PHP_EOL . " \t \t \$ query->order('a.published ASC'); " ;
$query .= PHP_EOL . " \t \t \$ query->order('a.ordering ASC'); " ;
$query .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Load the items " ;
$query .= PHP_EOL . " \t \t \$ db->setQuery( \$ query); " ;
$query .= PHP_EOL . " \t \t \$ db->execute(); " ;
$query .= PHP_EOL . " \t \t if ( \$ db->getNumRows()) " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t \$ items = \$ db->loadObjectList(); " ;
2016-02-26 00:20:09 +00:00
// ###STORE_METHOD_FIX### <<<DYNAMIC>>>
2017-12-14 23:10:47 +00:00
$query .= $this -> setGetItemsMethodStringFix ( $viewName_single , $this -> fileContentStatic [ '###Component###' ], " \t " );
2016-02-26 00:20:09 +00:00
// ###SELECTIONTRANSLATIONFIX### <<<DYNAMIC>>>
2017-12-14 23:10:47 +00:00
$query .= $this -> setSelectionTranslationFix ( $viewName_list , $this -> fileContentStatic [ '###Component###' ], " \t " );
2016-02-26 00:20:09 +00:00
// filter by child repetable field values
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkString ( $globalKey ) && $key && strpos ( $key , '-R>' ) !== false && strpos ( $key , '-A>' ) === false )
{
list ( $field , $target ) = explode ( '-R>' , $key );
$query .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Filter by " . $globalKey . " in this Repetable Field " ;
$query .= PHP_EOL . " \t \t \t if ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ items) && isset( \$ this-> " . $globalKey . " )) " ;
$query .= PHP_EOL . " \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t foreach ( \$ items as \$ nr => & \$ item) " ;
$query .= PHP_EOL . " \t \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \t if (isset( \$ item-> " . $field . " ) && " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkJson( \$ item-> " . $field . " )) " ;
$query .= PHP_EOL . " \t \t \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \t \t \$ tmpArray = json_decode( \$ item-> " . $field . " ,true); " ;
$query .= PHP_EOL . " \t \t \t \t \t \t if (!isset( \$ tmpArray[' " . $target . " ']) || ! " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ tmpArray[' " . $target . " ']) || !in_array( \$ this-> " . $globalKey . " , \$ tmpArray[' " . $target . " '])) " ;
$query .= PHP_EOL . " \t \t \t \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \t \t \t unset( \$ items[ \$ nr]); " ;
$query .= PHP_EOL . " \t \t \t \t \t \t \t continue; " ;
$query .= PHP_EOL . " \t \t \t \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t \t \t else " ;
$query .= PHP_EOL . " \t \t \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \t \t unset( \$ items[ \$ nr]); " ;
$query .= PHP_EOL . " \t \t \t \t \t \t continue; " ;
$query .= PHP_EOL . " \t \t \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t else " ;
$query .= PHP_EOL . " \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t return false; " ;
$query .= PHP_EOL . " \t \t \t } " ;
2016-02-26 00:20:09 +00:00
}
// filter by child array field values
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkString ( $globalKey ) && $key && strpos ( $key , '-R>' ) === false && strpos ( $key , '-A>' ) !== false )
{
$query .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Filter by " . $globalKey . " Array Field " ;
$query .= PHP_EOL . " \t \t \t \$ " . $globalKey . " = \$ this-> " . $globalKey . " ; " ;
$query .= PHP_EOL . " \t \t \t if ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ items) && \$ " . $globalKey . " ) " ;
$query .= PHP_EOL . " \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t foreach ( \$ items as \$ nr => & \$ item) " ;
$query .= PHP_EOL . " \t \t \t \t { " ;
list ( $bin , $target ) = explode ( '-A>' , $key );
2016-03-10 21:23:23 +00:00
if ( ComponentbuilderHelper :: checkString ( $target ))
2017-12-14 23:10:47 +00:00
{
$query .= PHP_EOL . " \t \t \t \t \t if ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkJson( \$ item-> " . $target . " )) " ;
$query .= PHP_EOL . " \t \t \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \t \t \$ item-> " . $target . " = json_decode( \$ item-> " . $target . " , true); " ;
$query .= PHP_EOL . " \t \t \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t \t \t elseif (!isset( \$ item-> " . $target . " ) || ! " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ item-> " . $target . " )) " ;
$query .= PHP_EOL . " \t \t \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \t \t unset( \$ items[ \$ nr]); " ;
$query .= PHP_EOL . " \t \t \t \t \t \t continue; " ;
$query .= PHP_EOL . " \t \t \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t \t \t if (!in_array( \$ " . $globalKey . " , \$ item-> " . $target . " )) " ;
2016-03-10 21:23:23 +00:00
}
else
2017-12-14 23:10:47 +00:00
{
$query .= PHP_EOL . " \t \t \t \t \t if ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkJson( \$ item-> " . $_key . " )) " ;
$query .= PHP_EOL . " \t \t \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \t \t \$ item-> " . $_key . " = json_decode( \$ item-> " . $_key . " , true); " ;
$query .= PHP_EOL . " \t \t \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t \t \t elseif (!isset( \$ item-> " . $_key . " ) || ! " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ item-> " . $_key . " )) " ;
$query .= PHP_EOL . " \t \t \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \t \t unset( \$ items[ \$ nr]); " ;
$query .= PHP_EOL . " \t \t \t \t \t \t continue; " ;
$query .= PHP_EOL . " \t \t \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t \t \t if (!in_array( \$ " . $globalKey . " , \$ item-> " . $_key . " )) " ;
}
$query .= PHP_EOL . " \t \t \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \t \t unset( \$ items[ \$ nr]); " ;
$query .= PHP_EOL . " \t \t \t \t \t \t continue; " ;
$query .= PHP_EOL . " \t \t \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t else " ;
$query .= PHP_EOL . " \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t return false; " ;
$query .= PHP_EOL . " \t \t \t } " ;
2016-02-26 00:20:09 +00:00
}
// filter by parent repetable field values
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkString ( $globalKey ) && $key && strpos ( $parentKey , '-R>' ) !== false && strpos ( $parentKey , '-A>' ) === false )
{
list ( $bin , $target ) = explode ( '-R>' , $parentKey );
$query .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Filter by " . $_key . " Repetable Field " ;
$query .= PHP_EOL . " \t \t \t \$ " . $globalKey . " = json_decode( \$ this-> " . $globalKey . " ,true); " ;
$query .= PHP_EOL . " \t \t \t if ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ items) && isset( \$ " . $globalKey . " ) && " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ " . $globalKey . " )) " ;
$query .= PHP_EOL . " \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t foreach ( \$ items as \$ nr => & \$ item) " ;
$query .= PHP_EOL . " \t \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \t if ( \$ item-> " . $_key . " && isset( \$ " . $globalKey . " [' " . $target . " ']) && " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ " . $globalKey . " [' " . $target . " '])) " ;
$query .= PHP_EOL . " \t \t \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \t \t if (!in_array( \$ item-> " . $_key . " , \$ " . $globalKey . " [' " . $target . " '])) " ;
$query .= PHP_EOL . " \t \t \t \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \t \t \t unset( \$ items[ \$ nr]); " ;
$query .= PHP_EOL . " \t \t \t \t \t \t \t continue; " ;
$query .= PHP_EOL . " \t \t \t \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t \t \t else " ;
$query .= PHP_EOL . " \t \t \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \t \t unset( \$ items[ \$ nr]); " ;
$query .= PHP_EOL . " \t \t \t \t \t \t continue; " ;
$query .= PHP_EOL . " \t \t \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t else " ;
$query .= PHP_EOL . " \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t return false; " ;
$query .= PHP_EOL . " \t \t \t } " ;
2016-02-26 00:20:09 +00:00
}
// filter by parent array field values
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkString ( $globalKey ) && $key && strpos ( $parentKey , '-R>' ) === false && strpos ( $parentKey , '-A>' ) !== false )
{
$query .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Filter by " . $globalKey . " Array Field " ;
$query .= PHP_EOL . " \t \t \t \$ " . $globalKey . " = \$ this-> " . $globalKey . " ; " ;
$query .= PHP_EOL . " \t \t \t if ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ items) && " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ " . $globalKey . " )) " ;
$query .= PHP_EOL . " \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t foreach ( \$ items as \$ nr => & \$ item) " ;
$query .= PHP_EOL . " \t \t \t \t { " ;
list ( $bin , $target ) = explode ( '-A>' , $parentKey );
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkString ( $target ))
{
2017-12-14 23:10:47 +00:00
$query .= PHP_EOL . " \t \t \t \t \t if ( \$ item-> " . $_key . " && " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ " . $globalKey . " [' " . $target . " '])) " ;
$query .= PHP_EOL . " \t \t \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \t \t if (!in_array( \$ item-> " . $_key . " , \$ " . $globalKey . " [' " . $target . " '])) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$query .= PHP_EOL . " \t \t \t \t \t if ( \$ item-> " . $_key . " ) " ;
$query .= PHP_EOL . " \t \t \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \t \t if (!in_array( \$ item-> " . $_key . " , \$ " . $globalKey . " )) " ;
}
$query .= PHP_EOL . " \t \t \t \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \t \t \t unset( \$ items[ \$ nr]); " ;
$query .= PHP_EOL . " \t \t \t \t \t \t \t continue; " ;
$query .= PHP_EOL . " \t \t \t \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t \t \t else " ;
$query .= PHP_EOL . " \t \t \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \t \t unset( \$ items[ \$ nr]); " ;
$query .= PHP_EOL . " \t \t \t \t \t \t continue; " ;
$query .= PHP_EOL . " \t \t \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t else " ;
$query .= PHP_EOL . " \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t return false; " ;
$query .= PHP_EOL . " \t \t \t } " ;
}
// add custom php to getitems method after all
$query .= $this -> getCustomScriptBuilder ( 'php_getitems_after_all' , $viewName_single , PHP_EOL . PHP_EOL . " \t " );
$query .= PHP_EOL . " \t \t \t return \$ items; " ;
$query .= PHP_EOL . " \t \t } " ;
$query .= PHP_EOL . " \t \t return false; " ;
$query .= PHP_EOL . " \t } " ;
2016-02-26 00:20:09 +00:00
// ###SELECTIONTRANSLATIONFIXFUNC###<<<DYNAMIC>>>
2017-12-14 23:10:47 +00:00
$query .= $this -> setSelectionTranslationFixFunc ( $viewName_list , $this -> fileContentStatic [ '###Component###' ]);
2016-02-26 00:20:09 +00:00
// fixe mothod name clash
2017-12-14 23:10:47 +00:00
$query = str_replace ( 'selectionTranslation(' , 'selectionTranslation' . $functionName . '(' , $query );
2016-02-26 00:20:09 +00:00
return $query ;
}
2016-04-22 12:03:43 +00:00
/**
* @ param $viewName_list
* @ return array | string
2017-07-20 23:26:48 +00:00
*/
2016-02-26 00:20:09 +00:00
public function setCustomAdminDynamicButton ( $viewName_list )
{
$buttons = '' ;
if ( isset ( $this -> customAdminDynamicButtons [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> customAdminDynamicButtons [ $viewName_list ]))
{
$buttons = array ();
foreach ( $this -> customAdminDynamicButtons [ $viewName_list ] as $custom_button )
{
// Load to lang
2017-12-14 23:10:47 +00:00
$keyLang = $this -> langPrefix . '_' . $custom_button [ 'NAME' ];
$this -> langContent [ $this -> lang ][ $keyLang ] = ComponentbuilderHelper :: safeString ( $custom_button [ 'name' ], 'Ww' );
2016-02-26 00:20:09 +00:00
// add cpanel button
2017-12-14 23:10:47 +00:00
$buttons [] = " \t \t if ( \$ this->canDo->get(' " . $custom_button [ 'link' ] . " .access')) " ;
2016-02-26 00:20:09 +00:00
$buttons [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$buttons [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " add " . $custom_button [ 'name' ] . " button. " ;
$buttons [] = " \t \t \t JToolBarHelper::custom(' " . $viewName_list . " .redirectTo " . ComponentbuilderHelper :: safeString ( $custom_button [ 'link' ], 'F' ) . " ', ' " . $custom_button [ 'icon' ] . " ', '', ' " . $keyLang . " ', true); " ;
2016-02-26 00:20:09 +00:00
$buttons [] = " \t \t } " ;
}
if ( ComponentbuilderHelper :: checkArray ( $buttons ))
{
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $buttons );
2016-02-26 00:20:09 +00:00
}
}
return $buttons ;
}
2016-04-22 12:03:43 +00:00
/**
* @ param $viewName_list
* @ return array | string
2017-07-20 23:26:48 +00:00
*/
2016-02-26 00:20:09 +00:00
public function setCustomAdminDynamicButtonController ( $viewName_list )
{
$method = '' ;
if ( isset ( $this -> customAdminDynamicButtons [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> customAdminDynamicButtons [ $viewName_list ]))
{
$method = array ();
foreach ( $this -> customAdminDynamicButtons [ $viewName_list ] as $custom_button )
{
// add the custom redirect method
2017-12-14 23:10:47 +00:00
$method [] = PHP_EOL . PHP_EOL . " \t public function redirectTo " . ComponentbuilderHelper :: safeString ( $custom_button [ 'link' ], 'F' ) . " () " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t { " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Check for request forgeries " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " check if export is allowed for this user. " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \$ user = JFactory::getUser(); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t if ( \$ user->authorise(' " . $custom_button [ 'link' ] . " .access', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " ')) " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Get the input " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t \$ input = JFactory::getApplication()->input; " ;
$method [] = " \t \t \t \$ pks = \$ input->post->get('cid', array(), 'array'); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Sanitize the input " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t JArrayHelper::toInteger( \$ pks); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " convert to string " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t \$ ids = implode('_', \$ pks); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t \$ this->setRedirect(JRoute::_('index.php?option=com_ " . $this -> fileContentStatic [ '###component###' ] . " &view= " . $custom_button [ 'link' ] . " &cid='. \$ ids, false)); " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t return; " ;
$method [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Redirect to the list screen with error. " ;
$method [] = " \t \t \$ message = JText::_(' " . $this -> langPrefix . " _ACCESS_TO_ " . $custom_button [ 'NAME' ] . " _FAILED'); " ;
$method [] = " \t \t \$ this->setRedirect(JRoute::_('index.php?option=com_ " . $this -> fileContentStatic [ '###component###' ] . " &view= " . $viewName_list . " ', false), \$ message, 'error'); " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t return; " ;
$method [] = " \t } " ;
// add to lang array
2017-12-14 23:10:47 +00:00
$lankey = $this -> langPrefix . " _ACCESS_TO_ " . $custom_button [ 'NAME' ] . " _FAILED " ;
2016-02-26 00:20:09 +00:00
if ( ! isset ( $this -> langContent [ $this -> lang ][ $lankey ]))
{
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lankey ] = 'Access to ' . $custom_button [ 'link' ] . ' was denied.' ;
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $method );
2016-02-26 00:20:09 +00:00
}
return $method ;
}
2016-04-22 12:03:43 +00:00
/**
* @ param $viewName_single
* @ param $viewName_list
* @ return string
2017-07-20 23:26:48 +00:00
*/
2016-02-26 00:20:09 +00:00
public function setModelExportMethod ( $viewName_single , $viewName_list )
{
$query = '' ;
if ( $this -> eximportView [ $viewName_list ])
{
2017-12-14 23:10:47 +00:00
$query = PHP_EOL . PHP_EOL . " \t /** " ;
$query .= PHP_EOL . " \t * Method to get list export data. " ;
$query .= PHP_EOL . " \t * " ;
$query .= PHP_EOL . " \t * @return mixed An array of data items on success, false on failure. " ;
$query .= PHP_EOL . " \t */ " ;
$query .= PHP_EOL . " \t public function getExportData( \$ pks) " ;
$query .= PHP_EOL . " \t { " ;
$query .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " setup the query " ;
$query .= PHP_EOL . " \t \t if ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ pks)) " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Set a value to know this is exporting method. " ;
$query .= PHP_EOL . " \t \t \t \$ _export = true; " ;
$query .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Get the user object. " ;
$query .= PHP_EOL . " \t \t \t \$ user = JFactory::getUser(); " ;
$query .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Create a new query object. " ;
$query .= PHP_EOL . " \t \t \t \$ db = JFactory::getDBO(); " ;
$query .= PHP_EOL . " \t \t \t \$ query = \$ db->getQuery(true); " ;
$query .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Select some fields " ;
$query .= PHP_EOL . " \t \t \t \$ query->select('a.*'); " ;
$query .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " From the " . $this -> fileContentStatic [ '###component###' ] . " _ " . $viewName_single . " table " ;
$query .= PHP_EOL . " \t \t \t \$ query->from( \$ db->quoteName('#__ " . $this -> fileContentStatic [ '###component###' ] . " _ " . $viewName_single . " ', 'a')); " ;
$query .= PHP_EOL . " \t \t \t \$ query->where('a.id IN (' . implode(',', \$ pks) . ')'); " ;
2016-02-26 00:20:09 +00:00
// add custom filtering php
2017-12-14 23:10:47 +00:00
$query .= $this -> getCustomScriptBuilder ( 'php_getlistquery' , $viewName_single , PHP_EOL . PHP_EOL . " \t " );
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> accessBuilder [ $viewName_single ]) && ComponentbuilderHelper :: checkString ( $this -> accessBuilder [ $viewName_single ]))
{
2017-12-14 23:10:47 +00:00
$query .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Implement View Level Access " ;
$query .= PHP_EOL . " \t \t \t if (! \$ user->authorise('core.options', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " ')) " ;
$query .= PHP_EOL . " \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \$ groups = implode(',', \$ user->getAuthorisedViewLevels()); " ;
$query .= PHP_EOL . " \t \t \t \t \$ query->where('a.access IN (' . \$ groups . ')'); " ;
$query .= PHP_EOL . " \t \t \t } " ;
}
$query .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Order the results by ordering " ;
$query .= PHP_EOL . " \t \t \t \$ query->order('a.ordering ASC'); " ;
$query .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Load the items " ;
$query .= PHP_EOL . " \t \t \t \$ db->setQuery( \$ query); " ;
$query .= PHP_EOL . " \t \t \t \$ db->execute(); " ;
$query .= PHP_EOL . " \t \t \t if ( \$ db->getNumRows()) " ;
$query .= PHP_EOL . " \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \$ items = \$ db->loadObjectList(); " ;
2017-04-05 13:21:10 +00:00
$query .= $this -> setGetItemsMethodStringFix ( $viewName_single , $this -> fileContentStatic [ '###Component###' ], " \t \t " , true );
2017-12-14 23:10:47 +00:00
// add custom php to getitems method after all
$query .= $this -> getCustomScriptBuilder ( 'php_getitems_after_all' , $viewName_single , PHP_EOL . PHP_EOL . " \t \t " );
$query .= PHP_EOL . " \t \t \t \t return \$ items; " ;
$query .= PHP_EOL . " \t \t \t } " ;
$query .= PHP_EOL . " \t \t } " ;
$query .= PHP_EOL . " \t \t return false; " ;
$query .= PHP_EOL . " \t } " ;
$query .= PHP_EOL . PHP_EOL . " \t /** " ;
$query .= PHP_EOL . " \t * Method to get header. " ;
$query .= PHP_EOL . " \t * " ;
$query .= PHP_EOL . " \t * @return mixed An array of data items on success, false on failure. " ;
$query .= PHP_EOL . " \t */ " ;
$query .= PHP_EOL . " \t public function getExImPortHeaders() " ;
$query .= PHP_EOL . " \t { " ;
$query .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get a db connection. " ;
$query .= PHP_EOL . " \t \t \$ db = JFactory::getDbo(); " ;
$query .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " get the columns " ;
$query .= PHP_EOL . " \t \t \$ columns = \$ db->getTableColumns( " . '"#__' . $this -> fileContentStatic [ '###component###' ] . '_' . $viewName_single . '");' ;
$query .= PHP_EOL . " \t \t if ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ columns)) " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " remove the headers you don't import/export. " ;
$query .= PHP_EOL . " \t \t \t unset( \$ columns['asset_id']); " ;
$query .= PHP_EOL . " \t \t \t unset( \$ columns['checked_out']); " ;
$query .= PHP_EOL . " \t \t \t unset( \$ columns['checked_out_time']); " ;
$query .= PHP_EOL . " \t \t \t \$ headers = new stdClass(); " ;
$query .= PHP_EOL . " \t \t \t foreach ( \$ columns as \$ column => \$ type) " ;
$query .= PHP_EOL . " \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \$ headers-> { \$ column} = \$ column; " ;
$query .= PHP_EOL . " \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t return \$ headers; " ;
$query .= PHP_EOL . " \t \t } " ;
$query .= PHP_EOL . " \t \t return false; " ;
$query .= PHP_EOL . " \t } " ;
2016-02-26 00:20:09 +00:00
}
return $query ;
}
public function setControllerEximportMethod ( $viewName_single , $viewName_list )
{
$method = '' ;
if ( isset ( $this -> eximportView [ $viewName_list ]) && $this -> eximportView [ $viewName_list ])
{
$method = array ();
// add the export method
2017-12-14 23:10:47 +00:00
$method [] = PHP_EOL . PHP_EOL . " \t public function exportData() " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t { " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Check for request forgeries " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " check if export is allowed for this user. " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \$ user = JFactory::getUser(); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t if ( \$ user->authorise(' " . $viewName_single . " .export', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " ') && \$ user->authorise('core.export', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " ')) " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Get the input " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t \$ input = JFactory::getApplication()->input; " ;
$method [] = " \t \t \t \$ pks = \$ input->post->get('cid', array(), 'array'); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Sanitize the input " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t JArrayHelper::toInteger( \$ pks); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Get the model " ;
$method [] = " \t \t \t \$ model = \$ this->getModel(' " . ComponentbuilderHelper :: safeString ( $viewName_list , 'F' ) . " '); " ;
$method [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " get the data to export " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t \$ data = \$ model->getExportData( \$ pks); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t if ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkArray( \$ data)) " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " now set the data to the spreadsheet " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t \t \$ date = JFactory::getDate(); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t \t " . $this -> fileContentStatic [ '###Component###' ] . " Helper::xls( \$ data,' " . ComponentbuilderHelper :: safeString ( $viewName_list , 'F' ) . " _'. \$ date->format('jS_F_Y'),' " . ComponentbuilderHelper :: safeString ( $viewName_list , 'Ww' ) . " exported ('. \$ date->format('jS F, Y').')',' " . ComponentbuilderHelper :: safeString ( $viewName_list , 'w' ) . " '); " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t } " ;
$method [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Redirect to the list screen with error. " ;
$method [] = " \t \t \$ message = JText::_(' " . $this -> langPrefix . " _EXPORT_FAILED'); " ;
$method [] = " \t \t \$ this->setRedirect(JRoute::_('index.php?option=com_ " . $this -> fileContentStatic [ '###component###' ] . " &view= " . $viewName_list . " ', false), \$ message, 'error'); " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t return; " ;
$method [] = " \t } " ;
// add the import method
2017-12-14 23:10:47 +00:00
$method [] = PHP_EOL . PHP_EOL . " \t public function importData() " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t { " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Check for request forgeries " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " check if import is allowed for this user. " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \$ user = JFactory::getUser(); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t if ( \$ user->authorise(' " . $viewName_single . " .import', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " ') && \$ user->authorise('core.import', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " ')) " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Get the import model " ;
$method [] = " \t \t \t \$ model = \$ this->getModel(' " . ComponentbuilderHelper :: safeString ( $viewName_list , 'F' ) . " '); " ;
$method [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " get the headers to import " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t \$ headers = \$ model->getExImPortHeaders(); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t if ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkObject( \$ headers)) " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Load headers to session. " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t \t \$ session = JFactory::getSession(); " ;
$method [] = " \t \t \t \t \$ headers = json_encode( \$ headers); " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t \t \$ session->set(' " . $viewName_single . " _VDM_IMPORTHEADERS', \$ headers); " ;
$method [] = " \t \t \t \t \$ session->set('backto_VDM_IMPORT', ' " . $viewName_list . " '); " ;
$method [] = " \t \t \t \t \$ session->set('dataType_VDM_IMPORTINTO', ' " . $viewName_single . " '); " ;
$method [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Redirect to import view. " ;
2016-02-26 00:20:09 +00:00
// add to lang array
2017-12-14 23:10:47 +00:00
$selectImportFileNote = $this -> langPrefix . " _IMPORT_SELECT_FILE_FOR_ " . ComponentbuilderHelper :: safeString ( $viewName_list , 'U' );
2016-02-26 00:20:09 +00:00
if ( ! isset ( $this -> langContent [ $this -> lang ][ $selectImportFileNote ]))
{
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $selectImportFileNote ] = 'Select the file to import data to ' . $viewName_list . '.' ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t \t \$ message = JText::_(' " . $selectImportFileNote . " '); " ;
2016-05-04 04:53:33 +00:00
// if this view has custom script it must have as custom import (model, veiw, controller)
if ( isset ( $this -> importCustomScripts [ $viewName_list ]) && $this -> importCustomScripts [ $viewName_list ])
{
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t \t \$ this->setRedirect(JRoute::_('index.php?option=com_ " . $this -> fileContentStatic [ '###component###' ] . " &view=import_ " . $viewName_list . " ', false), \$ message); " ;
2016-05-04 04:53:33 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$method [] = " \t \t \t \t \$ this->setRedirect(JRoute::_('index.php?option=com_ " . $this -> fileContentStatic [ '###component###' ] . " &view=import', false), \$ message); " ;
2016-05-04 04:53:33 +00:00
}
2016-02-26 00:20:09 +00:00
$method [] = " \t \t \t \t return; " ;
$method [] = " \t \t \t } " ;
$method [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$method [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Redirect to the list screen with error. " ;
$method [] = " \t \t \$ message = JText::_(' " . $this -> langPrefix . " _IMPORT_FAILED'); " ;
$method [] = " \t \t \$ this->setRedirect(JRoute::_('index.php?option=com_ " . $this -> fileContentStatic [ '###component###' ] . " &view= " . $viewName_list . " ', false), \$ message, 'error'); " ;
2016-02-26 00:20:09 +00:00
$method [] = " \t \t return; " ;
$method [] = " \t } " ;
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $method );
2016-02-26 00:20:09 +00:00
}
return $method ;
}
public function setExportButton ( $viewName_single , $viewName_list )
{
$button = '' ;
if ( isset ( $this -> eximportView [ $viewName_list ]) && $this -> eximportView [ $viewName_list ])
{
// main lang prefix
2017-12-14 23:10:47 +00:00
$langExport = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( 'Export Data' , 'U' );
2016-02-26 00:20:09 +00:00
// add to lang array
if ( ! isset ( $this -> langContent [ $this -> lang ][ $langExport ]))
{
$this -> langContent [ $this -> lang ][ $langExport ] = 'Export Data' ;
}
$button = array ();
2017-12-14 23:10:47 +00:00
$button [] = PHP_EOL . PHP_EOL . " \t \t \t if ( \$ this->canDo->get('core.export') && \$ this->canDo->get(' " . $viewName_single . " .export')) " ;
2016-02-26 00:20:09 +00:00
$button [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$button [] = " \t \t \t \t JToolBarHelper::custom(' " . $viewName_list . " .exportData', 'download', '', ' " . $langExport . " ', true); " ;
2016-02-26 00:20:09 +00:00
$button [] = " \t \t \t } " ;
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $button );
2016-02-26 00:20:09 +00:00
}
return $button ;
}
public function setImportButton ( $viewName_single , $viewName_list )
{
$button = '' ;
if ( isset ( $this -> eximportView [ $viewName_list ]) && $this -> eximportView [ $viewName_list ])
{
// main lang prefix
2017-12-14 23:10:47 +00:00
$langImport = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( 'Import Data' , 'U' );
2016-02-26 00:20:09 +00:00
// add to lang array
if ( ! isset ( $this -> langContent [ $this -> lang ][ $langImport ]))
{
$this -> langContent [ $this -> lang ][ $langImport ] = 'Import Data' ;
}
$button = array ();
2017-12-14 23:10:47 +00:00
$button [] = PHP_EOL . PHP_EOL . " \t \t if ( \$ this->canDo->get('core.import') && \$ this->canDo->get(' " . $viewName_single . " .import')) " ;
2016-02-26 00:20:09 +00:00
$button [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$button [] = " \t \t \t JToolBarHelper::custom(' " . $viewName_list . " .importData', 'upload', '', ' " . $langImport . " ', false); " ;
2016-02-26 00:20:09 +00:00
$button [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $button );
2016-02-26 00:20:09 +00:00
}
return $button ;
}
2016-05-04 04:53:33 +00:00
public function setImportCustomScripts ( $viewName_list )
{
// setup Ajax files
2017-12-14 23:10:47 +00:00
$target = array ( 'admin' => 'import_' . $viewName_list );
2017-03-27 12:38:51 +00:00
$this -> buildDynamique ( $target , 'customimport' );
2016-05-04 04:53:33 +00:00
// load the custom script to the files
2017-03-27 12:38:51 +00:00
// ###IMPORT_EXT_METHOD_CUSTOM### <<<DYNAMIC>>>
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ 'import_' . $viewName_list ][ '###IMPORT_EXT_METHOD_CUSTOM###' ] = $this -> getCustomScriptBuilder ( 'php_import_ext' , 'import_' . $viewName_list , PHP_EOL , null , true );
// ###IMPORT_DISPLAY_METHOD_CUSTOM### <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'import_' . $viewName_list ][ '###IMPORT_DISPLAY_METHOD_CUSTOM###' ] = $this -> getCustomScriptBuilder ( 'php_import_display' , 'import_' . $viewName_list , PHP_EOL , null , true );
// ###IMPORT_SETDATE_METHOD_CUSTOM### <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'import_' . $viewName_list ][ '###IMPORT_SETDATE_METHOD_CUSTOM###' ] = $this -> getCustomScriptBuilder ( 'php_import_setdata' , 'import_' . $viewName_list , PHP_EOL , null , true );
// ###IMPORT_METHOD_CUSTOM### <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'import_' . $viewName_list ][ '###IMPORT_METHOD_CUSTOM###' ] = $this -> getCustomScriptBuilder ( 'php_import' , 'import_' . $viewName_list , PHP_EOL , null , true );
// ###IMPORT_SAVE_METHOD_CUSTOM### <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'import_' . $viewName_list ][ '###IMPORT_SAVE_METHOD_CUSTOM###' ] = $this -> getCustomScriptBuilder ( 'php_import_save' , 'import_' . $viewName_list , PHP_EOL , null , true );
// ###IMPORT_DEFAULT_VIEW_CUSTOM### <<<DYNAMIC>>>
$this -> fileContentDynamic [ 'import_' . $viewName_list ][ '###IMPORT_DEFAULT_VIEW_CUSTOM###' ] = $this -> getCustomScriptBuilder ( 'html_import_view' , 'import_' . $viewName_list , PHP_EOL , null , true );
2016-05-04 04:53:33 +00:00
// insure we have the view placeholders setup
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ 'import_' . $viewName_list ][ '###VIEW###' ] = 'IMPORT_' . $this -> placeholders [ '###VIEWS###' ];
$this -> fileContentDynamic [ 'import_' . $viewName_list ][ '###View###' ] = 'Import_' . $this -> placeholders [ '###views###' ];
$this -> fileContentDynamic [ 'import_' . $viewName_list ][ '###view###' ] = 'import_' . $this -> placeholders [ '###views###' ];
$this -> fileContentDynamic [ 'import_' . $viewName_list ][ '###VIEWS###' ] = 'IMPORT_' . $this -> placeholders [ '###VIEWS###' ];
$this -> fileContentDynamic [ 'import_' . $viewName_list ][ '###Views###' ] = 'Import_' . $this -> placeholders [ '###views###' ];
$this -> fileContentDynamic [ 'import_' . $viewName_list ][ '###views###' ] = 'import_' . $this -> placeholders [ '###views###' ];
}
2016-02-26 00:20:09 +00:00
public function setListQuery ( $viewName_single , $viewName_list )
{
// check if this view has category added
if ( isset ( $this -> categoryBuilder [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> categoryBuilder [ $viewName_list ]))
{
$categoryCodeName = $this -> categoryBuilder [ $viewName_list ][ 'code' ];
$addCategory = true ;
}
else
{
$addCategory = false ;
}
// setup the query
2017-12-14 23:10:47 +00:00
$query = " // " . $this -> setLine ( __LINE__ ) . " Get the user object. " ;
$query .= PHP_EOL . " \t \t \$ user = JFactory::getUser(); " ;
$query .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Create a new query object. " ;
$query .= PHP_EOL . " \t \t \$ db = JFactory::getDBO(); " ;
$query .= PHP_EOL . " \t \t \$ query = \$ db->getQuery(true); " ;
$query .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Select some fields " ;
$query .= PHP_EOL . " \t \t \$ query->select('a.*'); " ;
2016-02-26 00:20:09 +00:00
// add the category
if ( $addCategory )
{
2017-12-14 23:10:47 +00:00
$query .= PHP_EOL . " \t \t \$ query->select( \$ db->quoteName('c.title','category_title')); " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$query .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " From the " . $this -> fileContentStatic [ '###component###' ] . " _item table " ;
$query .= PHP_EOL . " \t \t \$ query->from( \$ db->quoteName('#__ " . $this -> fileContentStatic [ '###component###' ] . " _ " . $viewName_single . " ', 'a')); " ;
2016-02-26 00:20:09 +00:00
// add the category
if ( $addCategory )
{
2017-12-14 23:10:47 +00:00
$query .= PHP_EOL . " \t \t \$ query->join('LEFT', \$ db->quoteName('#__categories', 'c') . ' ON (' . \$ db->quoteName('a. " . $categoryCodeName . " ') . ' = ' . \$ db->quoteName('c.id') . ')'); " ;
2016-02-26 00:20:09 +00:00
}
// add custom filtering php
2017-12-14 23:10:47 +00:00
$query .= $this -> getCustomScriptBuilder ( 'php_getlistquery' , $viewName_single , PHP_EOL . PHP_EOL );
2016-02-26 00:20:09 +00:00
// add the custom fields query
$query .= $this -> setCustomQuery ( $viewName_list , $viewName_single );
2017-12-14 23:10:47 +00:00
$query .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Filter by published state " ;
$query .= PHP_EOL . " \t \t \$ published = \$ this->getState('filter.published'); " ;
$query .= PHP_EOL . " \t \t if (is_numeric( \$ published)) " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t \$ query->where('a.published = ' . (int) \$ published); " ;
$query .= PHP_EOL . " \t \t } " ;
$query .= PHP_EOL . " \t \t elseif ( \$ published === '') " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t \$ query->where('(a.published = 0 OR a.published = 1)'); " ;
$query .= PHP_EOL . " \t \t } " ;
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> accessBuilder [ $viewName_single ]) && ComponentbuilderHelper :: checkString ( $this -> accessBuilder [ $viewName_single ]))
{
2017-12-14 23:10:47 +00:00
$query .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Join over the asset groups. " ;
$query .= PHP_EOL . " \t \t \$ query->select('ag.title AS access_level'); " ;
$query .= PHP_EOL . " \t \t \$ query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); " ;
$query .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Filter by access level. " ;
$query .= PHP_EOL . " \t \t if ( \$ access = \$ this->getState('filter.access')) " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t \$ query->where('a.access = ' . (int) \$ access); " ;
$query .= PHP_EOL . " \t \t } " ;
$query .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Implement View Level Access " ;
$query .= PHP_EOL . " \t \t if (! \$ user->authorise('core.options', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " ')) " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t \$ groups = implode(',', \$ user->getAuthorisedViewLevels()); " ;
$query .= PHP_EOL . " \t \t \t \$ query->where('a.access IN (' . \$ groups . ')'); " ;
$query .= PHP_EOL . " \t \t } " ;
2016-02-26 00:20:09 +00:00
}
// set the search query
$query .= $this -> setSearchQuery ( $viewName_list );
// set other filters
$query .= $this -> setFilterQuery ( $viewName_list );
// add the category
if ( $addCategory )
{
2017-12-14 23:10:47 +00:00
$query .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Filter by a single or group of categories. " ;
$query .= PHP_EOL . " \t \t \$ baselevel = 1; " ;
$query .= PHP_EOL . " \t \t \$ categoryId = \$ this->getState('filter.category_id'); " ;
2017-02-09 16:11:10 +00:00
$query .= PHP_EOL ;
2017-12-14 23:10:47 +00:00
$query .= PHP_EOL . " \t \t if (is_numeric( \$ categoryId)) " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t \$ cat_tbl = JTable::getInstance('Category', 'JTable'); " ;
$query .= PHP_EOL . " \t \t \t \$ cat_tbl->load( \$ categoryId); " ;
$query .= PHP_EOL . " \t \t \t \$ rgt = \$ cat_tbl->rgt; " ;
$query .= PHP_EOL . " \t \t \t \$ lft = \$ cat_tbl->lft; " ;
$query .= PHP_EOL . " \t \t \t \$ baselevel = (int) \$ cat_tbl->level; " ;
$query .= PHP_EOL . " \t \t \t \$ query->where('c.lft >= ' . (int) \$ lft) " ;
$query .= PHP_EOL . " \t \t \t \t ->where('c.rgt <= ' . (int) \$ rgt); " ;
$query .= PHP_EOL . " \t \t } " ;
$query .= PHP_EOL . " \t \t elseif (is_array( \$ categoryId)) " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t JArrayHelper::toInteger( \$ categoryId); " ;
$query .= PHP_EOL . " \t \t \t \$ categoryId = implode(',', \$ categoryId); " ;
$query .= PHP_EOL . " \t \t \t \$ query->where('a.category IN (' . \$ categoryId . ')'); " ;
$query .= PHP_EOL . " \t \t } " ;
2017-02-09 16:11:10 +00:00
$query .= PHP_EOL ;
}
2017-12-14 23:10:47 +00:00
$query .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Add the list ordering clause. " ;
$query .= PHP_EOL . " \t \t \$ orderCol = \$ this->state->get('list.ordering', 'a.id'); " ;
$query .= PHP_EOL . " \t \t \$ orderDirn = \$ this->state->get('list.direction', 'asc'); " ;
$query .= PHP_EOL . " \t \t if ( \$ orderCol != '') " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t \$ query->order( \$ db->escape( \$ orderCol . ' ' . \$ orderDirn)); " ;
$query .= PHP_EOL . " \t \t } " ;
2017-02-09 16:11:10 +00:00
$query .= PHP_EOL ;
2017-12-14 23:10:47 +00:00
$query .= PHP_EOL . " \t \t return \$ query; " ;
2016-02-26 00:20:09 +00:00
return $query ;
}
public function setSearchQuery ( $viewName_list )
{
if ( isset ( $this -> searchBuilder [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> searchBuilder [ $viewName_list ]))
{
// setup the searh options
$search = " '( " ;
foreach ( $this -> searchBuilder [ $viewName_list ] as $nr => $array )
{
// array( 'type' => $typeName, 'code' => $name, 'custom' => $custom, 'list' => $field['list']);
if ( $nr == 0 )
{
2017-12-14 23:10:47 +00:00
$search .= " a. " . $array [ 'code' ] . " LIKE '. \$ search.' " ;
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkArray ( $array [ 'custom' ]) && 1 == $array [ 'list' ])
{
2017-12-14 23:10:47 +00:00
$search .= " OR " . $array [ 'custom' ][ 'db' ] . " . " . $array [ 'custom' ][ 'text' ] . " LIKE '. \$ search.' " ;
2016-02-26 00:20:09 +00:00
}
}
else
{
2017-12-14 23:10:47 +00:00
$search .= " OR a. " . $array [ 'code' ] . " LIKE '. \$ search.' " ;
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkArray ( $array [ 'custom' ]) && 1 == $array [ 'list' ])
{
2017-12-14 23:10:47 +00:00
$search .= " OR " . $array [ 'custom' ][ 'db' ] . " . " . $array [ 'custom' ][ 'text' ] . " LIKE '. \$ search.' " ;
2016-02-26 00:20:09 +00:00
}
}
}
$search .= " )' " ;
// now setup query
2017-12-14 23:10:47 +00:00
$query = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Filter by search. " ;
$query .= PHP_EOL . " \t \t \$ search = \$ this->getState('filter.search'); " ;
$query .= PHP_EOL . " \t \t if (!empty( \$ search)) " ;
$query .= PHP_EOL . " \t \t { " ;
$query .= PHP_EOL . " \t \t \t if (stripos( \$ search, 'id:') === 0) " ;
$query .= PHP_EOL . " \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \$ query->where('a.id = ' . (int) substr( \$ search, 3)); " ;
$query .= PHP_EOL . " \t \t \t } " ;
$query .= PHP_EOL . " \t \t \t else " ;
$query .= PHP_EOL . " \t \t \t { " ;
$query .= PHP_EOL . " \t \t \t \t \$ search = \$ db->quote('%' . \$ db->escape( \$ search) . '%'); " ;
$query .= PHP_EOL . " \t \t \t \t \$ query->where( " . $search . " ); " ;
$query .= PHP_EOL . " \t \t \t } " ;
$query .= PHP_EOL . " \t \t } " ;
2017-02-09 16:11:10 +00:00
$query .= PHP_EOL ;
2016-02-26 00:20:09 +00:00
return $query ;
}
return '' ;
}
public function setCustomQuery ( $viewName_list , $viewName_single )
{
if ( isset ( $this -> customBuilder [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> customBuilder [ $viewName_list ]))
{
$query = " " ;
foreach ( $this -> customBuilder [ $viewName_list ] as $filter )
{
2016-10-23 22:48:26 +00:00
// only load this if table is set
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> customBuilderList [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> customBuilderList [ $viewName_list ]) && in_array ( $filter [ 'code' ], $this -> customBuilderList [ $viewName_list ]) && isset ( $filter [ 'custom' ][ 'table' ]) && ComponentbuilderHelper :: checkString ( $filter [ 'custom' ][ 'table' ]) && $filter [ 'method' ] == 0 )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$query .= PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " From the " . ComponentbuilderHelper :: safeString ( ComponentbuilderHelper :: safeString ( $filter [ 'custom' ][ 'table' ], 'w' )) . " table. " ;
$query .= PHP_EOL . " \t \t \$ query->select( \$ db->quoteName(' " . $filter [ 'custom' ][ 'db' ] . " . " . $filter [ 'custom' ][ 'text' ] . " ',' " . $filter [ 'code' ] . " _ " . $filter [ 'custom' ][ 'text' ] . " ')); " ;
$query .= PHP_EOL . " \t \t \$ query->join('LEFT', \$ db->quoteName(' " . $filter [ 'custom' ][ 'table' ] . " ', ' " . $filter [ 'custom' ][ 'db' ] . " ') . ' ON (' . \$ db->quoteName('a. " . $filter [ 'code' ] . " ') . ' = ' . \$ db->quoteName(' " . $filter [ 'custom' ][ 'db' ] . " . " . $filter [ 'custom' ][ 'id' ] . " ') . ')'); " ;
2016-02-26 00:20:09 +00:00
}
// build the field type file
$this -> setCustomFieldTypeFile ( $filter , $viewName_list , $viewName_single );
}
return $query ;
}
}
2017-12-14 23:10:47 +00:00
public function setAddButttonToListField ( $targetView , $targetViews )
2016-02-26 00:20:09 +00:00
{
$addButton = array ();
2017-12-14 23:10:47 +00:00
$addButton [] = PHP_EOL . " \t /** " ;
2016-02-26 00:20:09 +00:00
$addButton [] = " \t * Override to add new button " ;
$addButton [] = " \t * " ;
$addButton [] = " \t * @return string The field input markup. " ;
$addButton [] = " \t * " ;
$addButton [] = " \t * @since 3.2 " ;
$addButton [] = " \t */ " ;
2016-02-26 12:46:15 +00:00
$addButton [] = " \t protected function getInput() " ;
2016-02-26 00:20:09 +00:00
$addButton [] = " \t { " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " see if we should add buttons " ;
2016-02-26 00:20:09 +00:00
$addButton [] = " \t \t \$ setButton = \$ this->getAttribute('button'); " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " get html " ;
2016-02-26 00:20:09 +00:00
$addButton [] = " \t \t \$ html = parent::getInput(); " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " if true set button " ;
2016-02-26 00:20:09 +00:00
$addButton [] = " \t \t if ( \$ setButton === 'true') " ;
$addButton [] = " \t \t { " ;
2016-05-06 23:41:41 +00:00
$addButton [] = " \t \t \t \$ button = array(); " ;
$addButton [] = " \t \t \t \$ script = array(); " ;
$addButton [] = " \t \t \t \$ buttonName = \$ this->getAttribute('name'); " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " get the input from url " ;
2016-12-22 21:32:13 +00:00
$addButton [] = " \t \t \t \$ app = JFactory::getApplication(); " ;
$addButton [] = " \t \t \t \$ jinput = \$ app->input; " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " get the view name & id " ;
2016-05-06 23:41:41 +00:00
$addButton [] = " \t \t \t \$ values = \$ jinput->getArray(array( " ;
$addButton [] = " \t \t \t \t 'id' => 'int', " ;
$addButton [] = " \t \t \t \t 'view' => 'word' " ;
$addButton [] = " \t \t \t )); " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " check if new item " ;
2016-05-06 23:41:41 +00:00
$addButton [] = " \t \t \t \$ ref = ''; " ;
$addButton [] = " \t \t \t \$ refJ = ''; " ;
$addButton [] = " \t \t \t if (!is_null( \$ values['id']) && strlen( \$ values['view'])) " ;
$addButton [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " only load referal if not new item. " ;
2016-05-06 23:41:41 +00:00
$addButton [] = " \t \t \t \t \$ ref = '&ref=' . \$ values['view'] . '&refid=' . \$ values['id']; " ;
$addButton [] = " \t \t \t \t \$ refJ = '&ref=' . \$ values['view'] . '&refid=' . \$ values['id']; " ;
$addButton [] = " \t \t \t } " ;
2016-02-26 00:20:09 +00:00
$addButton [] = " \t \t \t \$ user = JFactory::getUser(); " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " only add if user allowed to create " . $targetView ;
2016-02-26 00:20:09 +00:00
// get core permissions
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $targetView ]))
{
$core = $this -> permissionCore [ $targetView ];
$coreLoad = true ;
}
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.create' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && in_array ( $targetView , $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t if ( \$ user->authorise(' " . $core [ 'core.create' ] . " ', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " ') && \$ app->isAdmin()) // TODO for now only in admin area. " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t if ( \$ user->authorise('core.create', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " ') && \$ app->isAdmin()) // TODO for now only in admin area. " ;
2016-02-26 00:20:09 +00:00
}
$addButton [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " build Create button " ;
2016-05-31 05:11:07 +00:00
$addButton [] = " \t \t \t \t \$ buttonNamee = trim( \$ buttonName); " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t \t \$ buttonNamee = preg_replace('/_+/', ' ', \$ buttonNamee); " ;
$addButton [] = " \t \t \t \t \$ buttonNamee = preg_replace('/ \ s+/', ' ', \$ buttonNamee); " ;
$addButton [] = " \t \t \t \t \$ buttonNamee = preg_replace( \" /[^A-Za-z ]/ \" , '', \$ buttonNamee); " ;
2016-05-31 05:11:07 +00:00
$addButton [] = " \t \t \t \t \$ buttonNamee = ucfirst(strtolower( \$ buttonNamee)); " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t \t \$ button[] = '<a id= \" '. \$ buttonName.'Create \" class= \" btn btn-small btn-success hasTooltip \" title= \" '.JText::sprintf(' " . $this -> langPrefix . " _CREATE_NEW_S', \$ buttonNamee).' \" style= \" border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px; \" " ;
2016-02-26 00:20:09 +00:00
$addButton [] = " \t \t \t \t \t href= \" index.php?option=com_ " . $this -> fileContentStatic [ '###component###' ] . " &view= " . $targetView . " &layout=edit'. \$ ref.' \" > " ;
2016-05-06 23:41:41 +00:00
$addButton [] = " \t \t \t \t \t <span class= \" icon-new icon-white \" ></span></a>'; " ;
$addButton [] = " \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " only add if user allowed to edit " . $targetView ;
2016-05-06 23:41:41 +00:00
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && in_array ( $targetView , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]))
2016-05-06 23:41:41 +00:00
{
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t if (( \$ buttonName === ' " . $targetView . " ' || \$ buttonName === ' " . $targetViews . " ') && \$ user->authorise(' " . $core [ 'core.edit' ] . " ', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " ') && \$ app->isAdmin()) // TODO for now only in admin area. " ;
2016-05-06 23:41:41 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t if (( \$ buttonName === ' " . $targetView . " ' || \$ buttonName === ' " . $targetViews . " ') && \$ user->authorise('core.edit', 'com_ " . $this -> fileContentStatic [ '###component###' ] . " ') && \$ app->isAdmin()) // TODO for now only in admin area. " ;
2016-05-06 23:41:41 +00:00
}
$addButton [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " build edit button " ;
2016-05-31 05:11:07 +00:00
$addButton [] = " \t \t \t \t \$ buttonNamee = trim( \$ buttonName); " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t \t \$ buttonNamee = preg_replace('/_+/', ' ', \$ buttonNamee); " ;
$addButton [] = " \t \t \t \t \$ buttonNamee = preg_replace('/ \ s+/', ' ', \$ buttonNamee); " ;
$addButton [] = " \t \t \t \t \$ buttonNamee = preg_replace( \" /[^A-Za-z ]/ \" , '', \$ buttonNamee); " ;
2016-05-31 05:11:07 +00:00
$addButton [] = " \t \t \t \t \$ buttonNamee = ucfirst(strtolower( \$ buttonNamee)); " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t \t \$ button[] = '<a id= \" '. \$ buttonName.'Edit \" class= \" btn btn-small hasTooltip \" title= \" '.JText::sprintf(' " . $this -> langPrefix . " _EDIT_S', \$ buttonNamee).' \" style= \" display: none; padding: 4px 4px 4px 7px; \" href= \" # \" > " ;
2016-05-06 23:41:41 +00:00
$addButton [] = " \t \t \t \t \t <span class= \" icon-edit \" ></span></a>'; " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " build script " ;
2016-05-06 23:41:41 +00:00
$addButton [] = " \t \t \t \t \$ script[] = \" " ;
$addButton [] = " \t \t \t \t \t jQuery(document).ready(function() { " ;
$addButton [] = " \t \t \t \t \t \t jQuery('#adminForm').on('change', '#jform_ \" . \$ buttonName. \" ',function (e) { " ;
$addButton [] = " \t \t \t \t \t \t \t e.preventDefault(); " ;
$addButton [] = " \t \t \t \t \t \t \t var \" . \$ buttonName. \" Value = jQuery('#jform_ \" . \$ buttonName. \" ').val(); " ;
$addButton [] = " \t \t \t \t \t \t \t \" . \$ buttonName. \" Button( \" . \$ buttonName. \" Value); " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t \t \t \t }); " ;
2016-05-06 23:41:41 +00:00
$addButton [] = " \t \t \t \t \t \t var \" . \$ buttonName. \" Value = jQuery('#jform_ \" . \$ buttonName. \" ').val(); " ;
$addButton [] = " \t \t \t \t \t \t \" . \$ buttonName. \" Button( \" . \$ buttonName. \" Value); " ;
$addButton [] = " \t \t \t \t \t }); " ;
$addButton [] = " \t \t \t \t \t function \" . \$ buttonName. \" Button(value) { " ;
$addButton [] = " \t \t \t \t \t \t if (value > 0) { " ; // TODO not ideal since value may not be an (int)
$addButton [] = " \t \t \t \t \t \t \t // hide the create button " ;
$addButton [] = " \t \t \t \t \t \t \t jQuery('# \" . \$ buttonName. \" Create').hide(); " ;
$addButton [] = " \t \t \t \t \t \t \t // show edit button " ;
$addButton [] = " \t \t \t \t \t \t \t jQuery('# \" . \$ buttonName. \" Edit').show(); " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t \t \t \t \t var url = 'index.php?option=com_ " . $this -> fileContentStatic [ '###component###' ] . " &view= " . $targetViews . " &task= " . $targetView . " .edit&id='+value+' \" . \$ refJ. \" '; " ; // TODO this value may not be the ID
2016-05-06 23:41:41 +00:00
$addButton [] = " \t \t \t \t \t \t \t jQuery('# \" . \$ buttonName. \" Edit').attr('href', url); " ;
$addButton [] = " \t \t \t \t \t \t } else { " ;
$addButton [] = " \t \t \t \t \t \t \t // show the create button " ;
$addButton [] = " \t \t \t \t \t \t \t jQuery('# \" . \$ buttonName. \" Create').show(); " ;
$addButton [] = " \t \t \t \t \t \t \t // hide edit button " ;
$addButton [] = " \t \t \t \t \t \t \t jQuery('# \" . \$ buttonName. \" Edit').hide(); " ;
$addButton [] = " \t \t \t \t \t \t } " ;
$addButton [] = " \t \t \t \t \t } \" ; " ;
$addButton [] = " \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " check if button was created for " . $targetView . " field. " ;
2016-05-31 05:11:07 +00:00
$addButton [] = " \t \t \t if (is_array( \$ button) && count( \$ button) > 0) " ;
2016-05-06 23:41:41 +00:00
$addButton [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Load the needed script. " ;
2016-05-06 23:41:41 +00:00
$addButton [] = " \t \t \t \t \$ document = JFactory::getDocument(); " ;
$addButton [] = " \t \t \t \t \$ document->addScriptDeclaration(implode(' ', \$ script)); " ;
2017-12-14 23:10:47 +00:00
$addButton [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " return the button attached to input field. " ;
2016-07-12 21:07:55 +00:00
$addButton [] = " \t \t \t \t return '<div class= \" input-append \" >' . \$ html . implode('', \$ button).'</div>'; " ;
2016-02-26 00:20:09 +00:00
$addButton [] = " \t \t \t } " ;
$addButton [] = " \t \t } " ;
$addButton [] = " \t \t return \$ html; " ;
$addButton [] = " \t } " ;
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $addButton );
2016-02-26 00:20:09 +00:00
}
public function setFilterQuery ( $viewName_list )
{
if ( isset ( $this -> filterBuilder [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> filterBuilder [ $viewName_list ]))
{
$filterQuery = " " ;
foreach ( $this -> filterBuilder [ $viewName_list ] as $filter )
{
if ( $filter [ 'type' ] != 'category' && ComponentbuilderHelper :: checkArray ( $filter [ 'custom' ]))
{
2017-12-14 23:10:47 +00:00
$filterQuery .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Filter by " . $filter [ 'code' ] . " . " ;
$filterQuery .= PHP_EOL . " \t \t if ( \$ " . $filter [ 'code' ] . " = \$ this->getState('filter. " . $filter [ 'code' ] . " ')) " ;
$filterQuery .= PHP_EOL . " \t \t { " ;
$filterQuery .= PHP_EOL . " \t \t \t \$ query->where('a. " . $filter [ 'code' ] . " = ' . \$ db->quote( \$ db->escape( \$ " . $filter [ 'code' ] . " ))); " ;
$filterQuery .= PHP_EOL . " \t \t } " ;
2016-02-26 00:20:09 +00:00
}
elseif ( $filter [ 'type' ] != 'category' )
{
2017-12-14 23:10:47 +00:00
$filterQuery .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Filter by " . ucwords ( $filter [ 'code' ]) . " . " ;
$filterQuery .= PHP_EOL . " \t \t if ( \$ " . $filter [ 'code' ] . " = \$ this->getState('filter. " . $filter [ 'code' ] . " ')) " ;
$filterQuery .= PHP_EOL . " \t \t { " ;
$filterQuery .= PHP_EOL . " \t \t \t \$ query->where('a. " . $filter [ 'code' ] . " = ' . \$ db->quote( \$ db->escape( \$ " . $filter [ 'code' ] . " ))); " ;
$filterQuery .= PHP_EOL . " \t \t } " ;
2016-02-26 00:20:09 +00:00
}
}
return $filterQuery ;
}
return '' ;
}
2016-06-23 15:05:37 +00:00
public function buildTheViewScript ( $viewArray )
2016-02-26 00:20:09 +00:00
{
// set the view name
$viewName = ComponentbuilderHelper :: safeString ( $viewArray [ 'settings' ] -> name_single );
// add conditions to this view
if ( isset ( $viewArray [ 'settings' ] -> conditions ) && ComponentbuilderHelper :: checkArray ( $viewArray [ 'settings' ] -> conditions ))
{
// reset defaults
2017-12-14 23:10:47 +00:00
$getValue = array ();
$ifValue = array ();
$targetControls = array ();
$functions = array ();
2016-02-26 00:20:09 +00:00
foreach ( $viewArray [ 'settings' ] -> conditions as $condition )
{
if ( isset ( $condition [ 'match_name' ]) && ComponentbuilderHelper :: checkString ( $condition [ 'match_name' ]))
{
2017-12-14 23:10:47 +00:00
$uniqueVar = $this -> uniquekey ( 7 );
$matchName = $condition [ 'match_name' ] . '_' . $uniqueVar ;
$targetBehavior = ( $condition [ 'target_behavior' ] == 1 ) ? 'show' : 'hide' ;
$targetDefault = ( $condition [ 'target_behavior' ] == 1 ) ? 'hide' : 'show' ;
2016-02-26 00:20:09 +00:00
// make sure only one relation is set
$firstTime = true ;
// set the realtation if any
if ( $condition [ 'target_relation' ] && $firstTime )
{
// chain to other items of the same target
2017-12-14 23:10:47 +00:00
$relations = $this -> getTargetRelationScript ( $viewArray [ 'settings' ] -> conditions , $condition , $viewName );
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkArray ( $relations ))
{
// set behavior and default array
2017-12-14 23:10:47 +00:00
$behaviors [ $matchName ] = $targetBehavior ;
$defaults [ $matchName ] = $targetDefault ;
2016-02-26 00:20:09 +00:00
// set the type buket
2017-12-14 23:10:47 +00:00
$typeBuket [ $matchName ] = $condition [ 'match_type' ];
2016-02-26 00:20:09 +00:00
// set function array
2017-12-14 23:10:47 +00:00
$functions [ $uniqueVar ][ 0 ] = $matchName ;
$matchNames [ $matchName ] = $condition [ 'match_name' ];
2016-02-26 00:20:09 +00:00
// get the select value
2017-12-14 23:10:47 +00:00
$getValue [ $matchName ] = $this -> getValueScript ( $condition [ 'match_type' ], $condition [ 'match_name' ], $condition [ 'match_extends' ], $uniqueVar );
2016-02-26 00:20:09 +00:00
// get the options
2017-12-14 23:10:47 +00:00
$options = $this -> getOptionsScript ( $condition [ 'match_type' ], $condition [ 'match_options' ]);
2016-02-26 00:20:09 +00:00
// set the if values
2017-12-14 23:10:47 +00:00
$ifValue [ $matchName ] = $this -> ifValueScript ( $matchName , $condition [ 'match_behavior' ], $condition [ 'match_type' ], $options );
2016-02-26 00:20:09 +00:00
// set the target controls
2017-12-14 23:10:47 +00:00
$targetControls [ $matchName ] = $this -> setTargetControlsScript ( $condition [ 'target_field' ], $targetBehavior , $targetDefault , $uniqueVar , $viewName );
2016-02-26 00:20:09 +00:00
$firstTime = false ;
2017-12-14 23:10:47 +00:00
foreach ( $relations as $relation )
2016-02-26 00:20:09 +00:00
{
if ( ComponentbuilderHelper :: checkString ( $relation [ 'match_name' ]))
{
2017-12-14 23:10:47 +00:00
$relationName = $relation [ 'match_name' ] . '_' . $uniqueVar ;
2016-02-26 00:20:09 +00:00
// set the type buket
2017-12-14 23:10:47 +00:00
$typeBuket [ $relationName ] = $relation [ 'match_type' ];
2016-02-26 00:20:09 +00:00
// set function array
2017-12-14 23:10:47 +00:00
$functions [ $uniqueVar ][] = $relationName ;
$matchNames [ $relationName ] = $relation [ 'match_name' ];
2016-02-26 00:20:09 +00:00
// get the relation option
2017-12-14 23:10:47 +00:00
$relationOptions = $this -> getOptionsScript ( $relation [ 'match_type' ], $relation [ 'match_options' ]);
$getValue [ $relationName ] = $this -> getValueScript ( $relation [ 'match_type' ], $relation [ 'match_name' ], $condition [ 'match_extends' ], $uniqueVar );
$ifValue [ $relationName ] = $this -> ifValueScript ( $relationName , $relation [ 'match_behavior' ], $relation [ 'match_type' ], $relationOptions );
2016-02-26 00:20:09 +00:00
}
}
}
}
else
{
// set behavior and default array
2017-12-14 23:10:47 +00:00
$behaviors [ $matchName ] = $targetBehavior ;
$defaults [ $matchName ] = $targetDefault ;
2016-02-26 00:20:09 +00:00
// set the type buket
2017-12-14 23:10:47 +00:00
$typeBuket [ $matchName ] = $condition [ 'match_type' ];
2016-02-26 00:20:09 +00:00
// set function array
2017-12-14 23:10:47 +00:00
$functions [ $uniqueVar ][ 0 ] = $matchName ;
$matchNames [ $matchName ] = $condition [ 'match_name' ];
2016-02-26 00:20:09 +00:00
// get the select value
2017-12-14 23:10:47 +00:00
$getValue [ $matchName ] = $this -> getValueScript ( $condition [ 'match_type' ], $condition [ 'match_name' ], $condition [ 'match_extends' ], $uniqueVar );
2016-02-26 00:20:09 +00:00
// get the options
2017-12-14 23:10:47 +00:00
$options = $this -> getOptionsScript ( $condition [ 'match_type' ], $condition [ 'match_options' ]);
2016-02-26 00:20:09 +00:00
// set the if values
2017-12-14 23:10:47 +00:00
$ifValue [ $matchName ] = $this -> ifValueScript ( $matchName , $condition [ 'match_behavior' ], $condition [ 'match_type' ], $options );
2016-02-26 00:20:09 +00:00
// set the target controls
2017-12-14 23:10:47 +00:00
$targetControls [ $matchName ] = $this -> setTargetControlsScript ( $condition [ 'target_field' ], $targetBehavior , $targetDefault , $uniqueVar , $viewName );
2016-02-26 00:20:09 +00:00
}
}
}
// reset buckets
$initial = '' ;
$func = '' ;
$validation = '' ;
$isSet = '' ;
$listener = '' ;
if ( ComponentbuilderHelper :: checkArray ( $functions ))
{
// now build the initial script
2017-12-14 23:10:47 +00:00
$initial .= " // Initial Script " . PHP_EOL . " jQuery(document).ready(function() " ;
$initial .= PHP_EOL . " { " ;
2016-02-26 00:20:09 +00:00
foreach ( $functions as $function => $matchKeys )
{
2017-12-14 23:10:47 +00:00
$func_call = $this -> buildFunctionCall ( $function , $matchKeys , $getValue );
2016-02-26 00:20:09 +00:00
$initial .= $func_call [ 'code' ];
}
2017-12-14 23:10:47 +00:00
$initial .= " }); " . PHP_EOL ;
2016-02-26 00:20:09 +00:00
// for modal fields
$modal = '' ;
// now build the listener scripts
foreach ( $functions as $l_function => $l_matchKeys )
{
$funcCall = '' ;
foreach ( $l_matchKeys as $l_matchKey )
{
2017-12-14 23:10:47 +00:00
$name = $matchNames [ $l_matchKey ];
$matchTypeKey = $typeBuket [ $l_matchKey ];
$funcCall = $this -> buildFunctionCall ( $l_function , $l_matchKeys , $getValue );
if ( isset ( $this -> setScriptMediaSwitch ) && ComponentbuilderHelper :: checkArray ( $this -> setScriptMediaSwitch ) && in_array ( $matchTypeKey , $this -> setScriptMediaSwitch ))
2016-02-26 00:20:09 +00:00
{
$modal .= $funcCall [ 'code' ];
}
else
{
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> setScriptUserSwitch ) && ComponentbuilderHelper :: checkArray ( $this -> setScriptUserSwitch ) && in_array ( $matchTypeKey , $this -> setScriptUserSwitch ))
2016-04-22 12:03:43 +00:00
{
2017-12-14 23:10:47 +00:00
$name = $name . '_id' ;
2016-04-22 12:03:43 +00:00
}
2017-12-14 23:10:47 +00:00
$listener .= PHP_EOL . " // #jform_ " . $name . " listeners for " . $l_matchKey . " function " ;
$listener .= PHP_EOL . " jQuery('#jform_ " . $name . " ').on('keyup',function() " ;
$listener .= PHP_EOL . " { " ;
2016-02-26 00:20:09 +00:00
$listener .= $funcCall [ 'code' ];
2017-12-14 23:10:47 +00:00
$listener .= PHP_EOL . " }); " ;
$listener .= PHP_EOL . " jQuery('#adminForm').on('change', '#jform_ " . $name . " ',function (e) " ;
$listener .= PHP_EOL . " { " ;
$listener .= PHP_EOL . " \t e.preventDefault(); " ;
2016-02-26 00:20:09 +00:00
$listener .= $funcCall [ 'code' ];
2017-12-14 23:10:47 +00:00
$listener .= PHP_EOL . " }); " . PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
}
}
if ( ComponentbuilderHelper :: checkString ( $modal ))
{
2017-12-14 23:10:47 +00:00
$listener .= PHP_EOL . " window.SqueezeBox.initialize( { " ;
$listener .= PHP_EOL . " \t onClose:function() { " ;
2016-02-26 00:20:09 +00:00
$listener .= $modal ;
2017-12-14 23:10:47 +00:00
$listener .= PHP_EOL . " \t } " ;
$listener .= PHP_EOL . " }); " . PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
// now build the function
$func = '' ;
$head = '' ;
foreach ( $functions as $f_function => $f_matchKeys )
{
$map = '' ;
// does this function require an array
$addArray = false ;
2017-12-14 23:10:47 +00:00
$func_ = $this -> buildFunctionCall ( $f_function , $f_matchKeys , $getValue );
2016-02-26 00:20:09 +00:00
// set array switch
if ( $func_ [ 'array' ])
{
$addArray = true ;
}
2017-12-14 23:10:47 +00:00
$func .= PHP_EOL . " // the " . $f_function . " function " ;
$func .= PHP_EOL . " function " . $f_function . " ( " ;
2016-02-26 00:20:09 +00:00
$fucounter = 0 ;
foreach ( $f_matchKeys as $fu_matchKey )
{
if ( ComponentbuilderHelper :: checkString ( $fu_matchKey ))
{
if ( $fucounter == 0 )
{
$func .= $fu_matchKey ;
}
else
{
2017-12-14 23:10:47 +00:00
$func .= ',' . $fu_matchKey ;
2016-02-26 00:20:09 +00:00
}
$fucounter ++ ;
}
}
$func .= " ) " ;
2017-12-14 23:10:47 +00:00
$func .= PHP_EOL . " { " ;
2016-02-26 00:20:09 +00:00
if ( $addArray )
{
foreach ( $f_matchKeys as $a_matchKey )
{
$name = $matchNames [ $a_matchKey ];
2017-12-14 23:10:47 +00:00
$func .= PHP_EOL . " \t if (isSet( " . $a_matchKey . " ) && " . $a_matchKey . " .constructor !== Array) " . PHP_EOL . " \t { " . PHP_EOL . " \t \t var temp_ " . $f_function . " = " . $a_matchKey . " ; " . PHP_EOL . " \t \t var " . $a_matchKey . " = []; " . PHP_EOL . " \t \t " . $a_matchKey . " .push(temp_ " . $f_function . " ); " . PHP_EOL . " \t } " ;
$func .= PHP_EOL . " \t else if (!isSet( " . $a_matchKey . " )) " . PHP_EOL . " \t { " ;
$func .= PHP_EOL . " \t \t var " . $a_matchKey . " = []; " ;
$func .= PHP_EOL . " \t } " ;
$func .= PHP_EOL . " \t var " . $name . " = " . $a_matchKey . " .some( " . $a_matchKey . " _SomeFunc); " . PHP_EOL ;
2016-02-26 00:20:09 +00:00
// setup the map function
2017-12-14 23:10:47 +00:00
$map .= PHP_EOL . " // the " . $f_function . " Some function " ;
$map .= PHP_EOL . " function " . $a_matchKey . " _SomeFunc( " . $a_matchKey . " ) " ;
$map .= PHP_EOL . " { " ;
$map .= PHP_EOL . " \t // " . $this -> setLine ( __LINE__ ) . " set the function logic " ;
$map .= PHP_EOL . " \t if ( " ;
2016-02-26 00:20:09 +00:00
$if = $ifValue [ $a_matchKey ];
if ( ComponentbuilderHelper :: checkString ( $if ))
{
$map .= $if ;
}
$map .= " ) " ;
2017-12-14 23:10:47 +00:00
$map .= PHP_EOL . " \t { " ;
$map .= PHP_EOL . " \t \t return true; " ;
$map .= PHP_EOL . " \t } " . PHP_EOL . " \t return false; " ;
$map .= PHP_EOL . " } " . PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$func .= PHP_EOL . PHP_EOL . " \t // " . $this -> setLine ( __LINE__ ) . " set this function logic " ;
$func .= PHP_EOL . " \t if ( " ;
2016-02-26 00:20:09 +00:00
// set if counter
$aifcounter = 0 ;
foreach ( $f_matchKeys as $af_matchKey )
{
$name = $matchNames [ $af_matchKey ];
if ( $aifcounter == 0 )
{
$func .= $name ;
}
else
{
2017-12-14 23:10:47 +00:00
$func .= ' && ' . $name ;
2016-02-26 00:20:09 +00:00
}
$aifcounter ++ ;
}
2017-12-14 23:10:47 +00:00
$func .= " ) " . PHP_EOL . " \t { " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$func .= PHP_EOL . " \t // " . $this -> setLine ( __LINE__ ) . " set the function logic " ;
$func .= PHP_EOL . " \t if ( " ;
2016-02-26 00:20:09 +00:00
// set if counter
$ifcounter = 0 ;
foreach ( $f_matchKeys as $f_matchKey )
{
$if = $ifValue [ $f_matchKey ];
if ( ComponentbuilderHelper :: checkString ( $if ))
{
if ( $ifcounter == 0 )
{
$func .= $if ;
}
else
{
2017-12-14 23:10:47 +00:00
$func .= ' && ' . $if ;
2016-02-26 00:20:09 +00:00
}
$ifcounter ++ ;
}
}
2017-12-14 23:10:47 +00:00
$func .= " ) " . PHP_EOL . " \t { " ;
2016-02-26 00:20:09 +00:00
}
// get the controles
$controls = $targetControls [ $f_matchKeys [ 0 ]];
// get target behavior and default
$targetBehavior = $behaviors [ $f_matchKeys [ 0 ]];
$targetDefault = $defaults [ $f_matchKeys [ 0 ]];
// load the target behavior
2017-12-14 23:10:47 +00:00
foreach ( $controls as $target => $action )
2016-02-26 00:20:09 +00:00
{
$func .= $action [ 'behavior' ];
if ( ComponentbuilderHelper :: checkString ( $action [ 'hide' ]))
{
$func .= $action [ $targetBehavior ];
$head .= $action [ 'requiredVar' ];
}
}
2017-12-14 23:10:47 +00:00
$func .= PHP_EOL . " \t } " . PHP_EOL . " \t else " . PHP_EOL . " \t { " ;
foreach ( $controls as $target => $action )
2016-02-26 00:20:09 +00:00
{
$func .= $action [ 'default' ];
if ( ComponentbuilderHelper :: checkString ( $action [ 'hide' ]))
{
$func .= $action [ $targetDefault ];
}
}
2017-12-14 23:10:47 +00:00
$func .= PHP_EOL . " \t } " . PHP_EOL . " } " . PHP_EOL . $map ;
2016-02-26 00:20:09 +00:00
}
// add the needed validation to file
if ( isset ( $this -> validationFixBuilder [ $viewName ]) && ComponentbuilderHelper :: checkArray ( $this -> validationFixBuilder [ $viewName ]))
{
2017-12-14 23:10:47 +00:00
$validation .= PHP_EOL . " // update required fields " ;
$validation .= PHP_EOL . " function updateFieldRequired(name,status) " ;
$validation .= PHP_EOL . " { " ;
$validation .= PHP_EOL . " \t var not_required = jQuery('#jform_not_required').val(); " ;
$validation .= PHP_EOL . PHP_EOL . " \t if(status == 1) " ;
$validation .= PHP_EOL . " \t { " ;
$validation .= PHP_EOL . " \t \t if (isSet(not_required) && not_required != 0) " ;
$validation .= PHP_EOL . " \t \t { " ;
$validation .= PHP_EOL . " \t \t \t not_required = not_required+','+name; " ;
$validation .= PHP_EOL . " \t \t } " ;
$validation .= PHP_EOL . " \t \t else " ;
$validation .= PHP_EOL . " \t \t { " ;
$validation .= PHP_EOL . " \t \t \t not_required = ','+name; " ;
$validation .= PHP_EOL . " \t \t } " ;
$validation .= PHP_EOL . " \t } " ;
$validation .= PHP_EOL . " \t else " ;
$validation .= PHP_EOL . " \t { " ;
$validation .= PHP_EOL . " \t \t if (isSet(not_required) && not_required != 0) " ;
$validation .= PHP_EOL . " \t \t { " ;
$validation .= PHP_EOL . " \t \t \t not_required = not_required.replace(','+name,''); " ;
$validation .= PHP_EOL . " \t \t } " ;
$validation .= PHP_EOL . " \t } " ;
$validation .= PHP_EOL . PHP_EOL . " \t jQuery('#jform_not_required').val(not_required); " ;
$validation .= PHP_EOL . " } " . PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
// set the isSet function
2017-12-14 23:10:47 +00:00
$isSet = PHP_EOL . " // the isSet function " ;
$isSet .= PHP_EOL . " function isSet(val) " ;
$isSet .= PHP_EOL . " { " ;
$isSet .= PHP_EOL . " \t if ((val != undefined) && (val != null) && 0 !== val.length) { " ;
$isSet .= PHP_EOL . " \t \t return true; " ;
$isSet .= PHP_EOL . " \t } " ;
$isSet .= PHP_EOL . " \t return false; " ;
$isSet .= PHP_EOL . " } " ;
2016-02-26 00:20:09 +00:00
}
// load to this buket
2017-12-14 23:10:47 +00:00
$fileScript = $initial . $func . $validation . $isSet ;
$footerScript = $listener ;
2016-02-26 00:20:09 +00:00
}
// add custom script to file
if ( isset ( $this -> customScriptBuilder [ 'view_file' ][ $viewName ]) && ComponentbuilderHelper :: checkString ( $this -> customScriptBuilder [ 'view_file' ][ $viewName ]))
{
if ( ! isset ( $fileScript ))
{
$fileScript = '' ;
}
2017-12-14 23:10:47 +00:00
$fileScript .= PHP_EOL . PHP_EOL . $this -> setPlaceholders ( $this -> customScriptBuilder [ 'view_file' ][ $viewName ], $this -> placeholders );
2016-02-26 00:20:09 +00:00
}
// add custom script to footer
if ( isset ( $this -> customScriptBuilder [ 'view_footer' ][ $viewName ]) && ComponentbuilderHelper :: checkString ( $this -> customScriptBuilder [ 'view_footer' ][ $viewName ]))
{
2017-12-14 23:10:47 +00:00
$customFooterScript = PHP_EOL . PHP_EOL . $this -> setPlaceholders ( $this -> customScriptBuilder [ 'view_footer' ][ $viewName ], $this -> placeholders );
if ( strpos ( $customFooterScript , '<?php' ) === false )
2016-02-26 00:20:09 +00:00
{
// only add now if no php is added to the footer script
if ( ! isset ( $footerScript ))
{
$footerScript = '' ;
}
$footerScript .= $customFooterScript ;
unset ( $customFooterScript );
}
}
// minfy the script
if ( $this -> params -> get ( 'minify' ) && isset ( $fileScript ) && ComponentbuilderHelper :: checkString ( $fileScript ))
{
// minify the fielScript javscript
$minifier = new JS ;
$minifier -> add ( $fileScript );
$fileScript = $minifier -> minify ();
}
// minfy the script
if ( $this -> params -> get ( 'minify' ) && isset ( $footerScript ) && ComponentbuilderHelper :: checkString ( $footerScript ))
{
// minify the footerScript javscript
$minifier = new JS ;
$minifier -> add ( $footerScript );
$footerScript = $minifier -> minify ();
}
// make sure there is script to add
if ( isset ( $fileScript ) && ComponentbuilderHelper :: checkString ( $fileScript ))
{
// add the head script if set
if ( isset ( $head ) && ComponentbuilderHelper :: checkString ( $head ))
{
2017-12-14 23:10:47 +00:00
$fileScript = " // Some Global Values " . PHP_EOL . $head . PHP_EOL . $fileScript ;
2016-02-26 00:20:09 +00:00
}
// load the script
$this -> editBodyViewScriptBuilder [ $viewName ][ 'fileScript' ] = $fileScript ;
}
// make sure to add custom footer script if php was found in it, since we canot minfy it with php
if ( isset ( $customFooterScript ) && ComponentbuilderHelper :: checkString ( $customFooterScript ))
{
if ( ! isset ( $footerScript ))
{
$footerScript = '' ;
}
$footerScript .= $customFooterScript ;
}
// make sure there is script to add
if ( isset ( $footerScript ) && ComponentbuilderHelper :: checkString ( $footerScript ))
{
// add the needed script tags
2017-12-14 23:10:47 +00:00
$footerScript = PHP_EOL . PHP_EOL . '<script type="text/javascript">' . PHP_EOL . $footerScript . PHP_EOL . " </script> " ;
2016-02-26 00:20:09 +00:00
$this -> editBodyViewScriptBuilder [ $viewName ][ 'footerScript' ] = $footerScript ;
}
}
2017-12-14 23:10:47 +00:00
public function buildFunctionCall ( $function , $matchKeys , $getValue )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$initial = '' ;
$funcsets = array ();
$array = false ;
2016-02-26 00:20:09 +00:00
foreach ( $matchKeys as $matchKey )
{
$value = $getValue [ $matchKey ];
if ( $value [ 'isArray' ])
{
2017-12-14 23:10:47 +00:00
$initial .= PHP_EOL . " \t " . $value [ 'get' ];
2016-02-26 00:20:09 +00:00
$funcsets [] = $matchKey ;
$array = true ;
}
else
{
2017-12-14 23:10:47 +00:00
$initial .= PHP_EOL . " \t " . $value [ 'get' ];
2016-02-26 00:20:09 +00:00
$funcsets [] = $matchKey ;
}
}
// make sure that the function is loaded only once
if ( ComponentbuilderHelper :: checkArray ( $funcsets ))
{
2017-12-14 23:10:47 +00:00
$initial .= PHP_EOL . " \t " . $function . " ( " ;
$initial .= implode ( ',' , $funcsets );
$initial .= " ); " . PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
return array ( 'code' => $initial , 'array' => $array );
}
2017-12-14 23:10:47 +00:00
public function getTargetRelationScript ( $relations , $condition , $view )
2016-02-26 00:20:09 +00:00
{
// reset the buket
$buket = array ();
// convert to name array
foreach ( $condition [ 'target_field' ] as $targetField )
{
if ( ComponentbuilderHelper :: checkArray ( $targetField ))
{
$currentTargets [] = $targetField [ 'name' ];
}
}
// start the search
2017-12-14 23:10:47 +00:00
foreach ( $relations as $relation )
2016-02-26 00:20:09 +00:00
{
// reset found
$found = false ;
if ( $relation [ 'match_field' ] != $condition [ 'match_field' ])
{
if ( ComponentbuilderHelper :: checkArray ( $relation [ 'target_field' ]))
{
2017-12-14 23:10:47 +00:00
foreach ( $relation [ 'target_field' ] as $target )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkArray ( $target ) && $this -> checkRelationControl ( $target [ 'name' ], $relation [ 'match_name' ], $condition [ 'match_name' ], $view ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( in_array ( $target [ 'name' ], $currentTargets ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$this -> targetRelationControl [ $view ][ $target [ 'name' ]] = array ( $relation [ 'match_name' ], $condition [ 'match_name' ]);
2016-02-26 00:20:09 +00:00
$found = true ;
break ;
}
}
}
if ( $found )
{
$buket [] = $relation ;
}
}
}
}
return $buket ;
}
2017-12-14 23:10:47 +00:00
public function checkRelationControl ( $targetName , $relationMatchName , $conditionMatchName , $view )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> targetRelationControl [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> targetRelationControl [ $view ]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> targetRelationControl [ $view ][ $targetName ]) && ComponentbuilderHelper :: checkArray ( $this -> targetRelationControl [ $view ][ $targetName ]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( ! in_array ( $relationMatchName , $this -> targetRelationControl [ $view ][ $targetName ]) || ! in_array ( $conditionMatchName , $this -> targetRelationControl [ $view ][ $targetName ]))
2016-02-26 00:20:09 +00:00
{
return true ;
}
}
else
{
return true ;
}
}
elseif ( ! isset ( $this -> targetRelationControl [ $view ]) || ! ComponentbuilderHelper :: checkArray ( $this -> targetRelationControl [ $view ]))
{
return true ;
}
return false ;
}
2017-12-14 23:10:47 +00:00
public function setTargetControlsScript ( $targets , $targetBehavior , $targetDefault , $uniqueVar , $viewName )
2016-02-26 00:20:09 +00:00
{
$bucket = array ();
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkArray ( $targets ) && ! in_array ( $uniqueVar , $this -> targetControlsScriptChecker ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
foreach ( $targets as $target )
2016-02-26 00:20:09 +00:00
{
if ( ComponentbuilderHelper :: checkArray ( $target ))
{
// set the required var
2017-12-14 23:10:47 +00:00
if ( $target [ 'required' ] === 'yes' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$unique = $uniqueVar . $this -> uniquekey ( 3 );
$bucket [ $target [ 'name' ]][ 'requiredVar' ] = " jform_ " . $unique . " _required = false; " . PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
else
{
$bucket [ $target [ 'name' ]][ 'requiredVar' ] = '' ;
}
// set target type
$targetTypeSufix = " " ;
if ( $this -> defaultField ( $target [ 'type' ], 'spacer' ))
{
// target a class if this is a note or spacer
$targetType = " . " ;
}
2017-07-20 23:26:48 +00:00
elseif ( $target [ 'type' ] === 'editor' || $target [ 'type' ] === 'subform' )
2016-02-26 00:20:09 +00:00
{
// target the label if editor field
$targetType = " #jform_ " ;
// since the id is not alway accessable we use the lable TODO (not best way)
$targetTypeSufix = " -lbl " ;
}
else
{
// target an id if this is a field
$targetType = " #jform_ " ;
}
// set the target behavior
2017-12-14 23:10:47 +00:00
$bucket [ $target [ 'name' ]][ 'behavior' ] = PHP_EOL . " \t \t jQuery(' " . $targetType . $target [ 'name' ] . $targetTypeSufix . " ').closest('.control-group'). " . $targetBehavior . " (); " ;
2016-02-26 00:20:09 +00:00
// set the target default
2017-12-14 23:10:47 +00:00
$bucket [ $target [ 'name' ]][ 'default' ] = PHP_EOL . " \t \t jQuery(' " . $targetType . $target [ 'name' ] . $targetTypeSufix . " ').closest('.control-group'). " . $targetDefault . " (); " ;
2016-02-26 00:20:09 +00:00
// the hide required function
2017-12-14 23:10:47 +00:00
if ( $target [ 'required' ] === 'yes' )
{
$hide = PHP_EOL . " \t \t if (!jform_ " . $unique . " _required) " ;
$hide .= PHP_EOL . " \t \t { " ;
$hide .= PHP_EOL . " \t \t \t updateFieldRequired(' " . $target [ 'name' ] . " ',1); " ;
$hide .= PHP_EOL . " \t \t \t jQuery('#jform_ " . $target [ 'name' ] . " ').removeAttr('required'); " ;
$hide .= PHP_EOL . " \t \t \t jQuery('#jform_ " . $target [ 'name' ] . " ').removeAttr('aria-required'); " ;
$hide .= PHP_EOL . " \t \t \t jQuery('#jform_ " . $target [ 'name' ] . " ').removeClass('required'); " ;
$hide .= PHP_EOL . " \t \t \t jform_ " . $unique . " _required = true; " ;
$hide .= PHP_EOL . " \t \t } " ;
2016-02-26 00:20:09 +00:00
$bucket [ $target [ 'name' ]][ 'hide' ] = $hide ;
// the show required function
2017-12-14 23:10:47 +00:00
$show = PHP_EOL . " \t \t if (jform_ " . $unique . " _required) " ;
$show .= PHP_EOL . " \t \t { " ;
$show .= PHP_EOL . " \t \t \t updateFieldRequired(' " . $target [ 'name' ] . " ',0); " ;
$show .= PHP_EOL . " \t \t \t jQuery('#jform_ " . $target [ 'name' ] . " ').prop('required','required'); " ;
$show .= PHP_EOL . " \t \t \t jQuery('#jform_ " . $target [ 'name' ] . " ').attr('aria-required',true); " ;
$show .= PHP_EOL . " \t \t \t jQuery('#jform_ " . $target [ 'name' ] . " ').addClass('required'); " ;
$show .= PHP_EOL . " \t \t \t jform_ " . $unique . " _required = false; " ;
$show .= PHP_EOL . " \t \t } " . PHP_EOL ;
2016-02-26 00:20:09 +00:00
$bucket [ $target [ 'name' ]][ 'show' ] = $show ;
// make sure that the axaj and other needed things for this view is loaded
$this -> validationFixBuilder [ $viewName ][] = $target [ 'name' ];
}
else
{
$bucket [ $target [ 'name' ]][ 'hide' ] = '' ;
$bucket [ $target [ 'name' ]][ 'show' ] = '' ;
}
}
}
$this -> targetControlsScriptChecker [] = $uniqueVar ;
}
return $bucket ;
}
2017-12-14 23:10:47 +00:00
public function ifValueScript ( $value , $behavior , $type , $options )
2016-02-26 00:20:09 +00:00
{
// reset string
$string = '' ;
switch ( $behavior )
{
case 1 : // Is
2017-12-14 23:10:47 +00:00
// only 4 list/radio/checkboxes
if ( ComponentbuilderHelper :: typeField ( $type , 'list' ) || ComponentbuilderHelper :: typeField ( $type , 'dynamic' ) || ! ComponentbuilderHelper :: typeField ( $type ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkArray ( $options ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
foreach ( $options as $option )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( ! is_numeric ( $option ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( $option != 'true' && $option != 'false' )
{
$option = " ' " . $option . " ' " ;
}
}
if ( ComponentbuilderHelper :: checkString ( $string ))
{
$string .= ' || ' . $value . ' == ' . $option ;
}
else
{
$string .= $value . ' == ' . $option ;
2016-02-26 00:20:09 +00:00
}
}
}
2017-12-14 23:10:47 +00:00
else
{
$string .= 'isSet(' . $value . ')' ;
}
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
break ;
2016-02-26 00:20:09 +00:00
case 2 : // Is Not
2017-12-14 23:10:47 +00:00
// only 4 list/radio/checkboxes
if ( ComponentbuilderHelper :: typeField ( $type , 'list' ) || ComponentbuilderHelper :: typeField ( $type , 'dynamic' ) || ! ComponentbuilderHelper :: typeField ( $type ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkArray ( $options ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
foreach ( $options as $option )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( ! is_numeric ( $option ))
{
if ( $option != 'true' && $option != 'false' )
{
$option = " ' " . $option . " ' " ;
}
}
if ( ComponentbuilderHelper :: checkString ( $string ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$string .= ' || ' . $value . ' != ' . $option ;
}
else
{
$string .= $value . ' != ' . $option ;
2016-02-26 00:20:09 +00:00
}
}
}
2017-12-14 23:10:47 +00:00
else
{
$string .= '!isSet(' . $value . ')' ;
}
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
break ;
2016-02-26 00:20:09 +00:00
case 3 : // Any Selection
2017-12-14 23:10:47 +00:00
// only 4 list/radio/checkboxes/dynamic_list
if ( ComponentbuilderHelper :: typeField ( $type , 'list' ) || ComponentbuilderHelper :: typeField ( $type , 'dynamic' ) || ! ComponentbuilderHelper :: typeField ( $type ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkArray ( $options ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
foreach ( $options as $option )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( ! is_numeric ( $option ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( $option != 'true' && $option != 'false' )
{
$option = " ' " . $option . " ' " ;
}
}
if ( ComponentbuilderHelper :: checkString ( $string ))
{
$string .= ' || ' . $value . ' == ' . $option ;
}
else
{
$string .= $value . ' == ' . $option ;
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
}
else
{
$userFix = '' ;
if ( isset ( $this -> setScriptUserSwitch ) && ComponentbuilderHelper :: checkArray ( $this -> setScriptUserSwitch ) && in_array ( $type , $this -> setScriptUserSwitch ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
// TODO this needs a closer look, a bit buggy
$userFix = " && " . $value . " != 0 " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
//echo '<pre>'; var_dump($type);exit;
$string .= 'isSet(' . $value . ')' . $userFix ;
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
break ;
case 4 : // Active (not empty)
// only 4 text_field
if ( ComponentbuilderHelper :: typeField ( $type , 'text' ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$string .= 'isSet(' . $value . ')' ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
break ;
2016-02-26 00:20:09 +00:00
case 5 : // Unactive (empty)
2017-12-14 23:10:47 +00:00
// only 4 text_field
if ( ComponentbuilderHelper :: typeField ( $type , 'text' ))
{
$string .= '!isSet(' . $value . ')' ;
}
break ;
2016-02-26 00:20:09 +00:00
case 6 : // Key Word All (case-sensitive)
2017-12-14 23:10:47 +00:00
// only 4 text_field
if ( ComponentbuilderHelper :: typeField ( $type , 'text' ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkArray ( $options [ 'keywords' ]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
foreach ( $options [ 'keywords' ] as $keyword )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkString ( $string ))
{
$string .= ' && ' . $value . '.indexOf("' . $keyword . '") >= 0' ;
}
else
{
$string .= $value . '.indexOf("' . $keyword . '") >= 0' ;
}
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
if ( ! ComponentbuilderHelper :: checkString ( $string ))
{
$string .= $value . ' == "error"' ;
}
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
break ;
2016-02-26 00:20:09 +00:00
case 7 : // Key Word Any (case-sensitive)
2017-12-14 23:10:47 +00:00
// only 4 text_field
if ( ComponentbuilderHelper :: typeField ( $type , 'text' ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkArray ( $options [ 'keywords' ]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
foreach ( $options [ 'keywords' ] as $keyword )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkString ( $string ))
{
$string .= ' || ' . $value . '.indexOf("' . $keyword . '") >= 0' ;
}
else
{
$string .= $value . '.indexOf("' . $keyword . '") >= 0' ;
}
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
if ( ! ComponentbuilderHelper :: checkString ( $string ))
{
$string .= $value . ' == "error"' ;
}
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
break ;
2016-02-26 00:20:09 +00:00
case 8 : // Key Word All (case-insensitive)
2017-12-14 23:10:47 +00:00
// only 4 text_field
if ( ComponentbuilderHelper :: typeField ( $type , 'text' ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkArray ( $options [ 'keywords' ]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
foreach ( $options [ 'keywords' ] as $keyword )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$keyword = ComponentbuilderHelper :: safeString ( $keyword , 'w' );
if ( ComponentbuilderHelper :: checkString ( $string ))
{
$string .= ' && ' . $value . '.toLowerCase().indexOf("' . $keyword . '") >= 0' ;
}
else
{
$string .= $value . '.toLowerCase().indexOf("' . $keyword . '") >= 0' ;
}
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
if ( ! ComponentbuilderHelper :: checkString ( $string ))
{
$string .= $value . ' == "error"' ;
}
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
break ;
2016-02-26 00:20:09 +00:00
case 9 : // Key Word Any (case-insensitive)
2017-12-14 23:10:47 +00:00
// only 4 text_field
if ( ComponentbuilderHelper :: typeField ( $type , 'text' ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkArray ( $options [ 'keywords' ]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
foreach ( $options [ 'keywords' ] as $keyword )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$keyword = ComponentbuilderHelper :: safeString ( $keyword , 'w' );
if ( ComponentbuilderHelper :: checkString ( $string ))
{
$string .= ' || ' . $value . '.toLowerCase().indexOf("' . $keyword . '") >= 0' ;
}
else
{
$string .= $value . '.toLowerCase().indexOf("' . $keyword . '") >= 0' ;
}
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
if ( ! ComponentbuilderHelper :: checkString ( $string ))
{
$string .= $value . ' == "error"' ;
}
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
break ;
2016-02-26 00:20:09 +00:00
case 10 : // Min Length
2017-12-14 23:10:47 +00:00
// only 4 text_field
if ( ComponentbuilderHelper :: typeField ( $type , 'text' ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkArray ( $options ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( $options [ 'length' ])
{
$string .= $value . '.length >= ' . ( int ) $options [ 'length' ];
}
}
if ( ! ComponentbuilderHelper :: checkString ( $string ))
{
$string .= $value . '.length >= 5' ;
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
break ;
2016-02-26 00:20:09 +00:00
case 11 : // Max Length
2017-12-14 23:10:47 +00:00
// only 4 text_field
if ( ComponentbuilderHelper :: typeField ( $type , 'text' ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkArray ( $options ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( $options [ 'length' ])
{
$string .= $value . '.length <= ' . ( int ) $options [ 'length' ];
}
}
if ( ! ComponentbuilderHelper :: checkString ( $string ))
{
$string .= $value . '.length <= 5' ;
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
break ;
2016-02-26 00:20:09 +00:00
case 12 : // Exact Length
2017-12-14 23:10:47 +00:00
// only 4 text_field
if ( ComponentbuilderHelper :: typeField ( $type , 'text' ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkArray ( $options ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( $options [ 'length' ])
{
$string .= $value . '.length == ' . ( int ) $options [ 'length' ];
}
}
if ( ! ComponentbuilderHelper :: checkString ( $string ))
{
$string .= $value . '.length == 5' ;
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
break ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
if ( ! ComponentbuilderHelper :: checkString ( $string ))
2016-02-26 00:20:09 +00:00
{
$string = 0 ;
}
return $string ;
}
2017-12-14 23:10:47 +00:00
public function getOptionsScript ( $type , $options )
2016-02-26 00:20:09 +00:00
{
$buket = array ();
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: checkString ( $options ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( ComponentbuilderHelper :: typeField ( $type , 'list' ) || ComponentbuilderHelper :: typeField ( $type , 'dynamic' ) || ! ComponentbuilderHelper :: typeField ( $type ))
2016-02-26 00:20:09 +00:00
{
$optionsArray = explode ( PHP_EOL , $options );
if ( ! ComponentbuilderHelper :: checkArray ( $optionsArray ))
{
$optionsArray [] = $optionsArray ;
}
2017-12-14 23:10:47 +00:00
foreach ( $optionsArray as $option )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( strpos ( $option , '|' ) !== false )
2016-02-26 00:20:09 +00:00
{
list ( $option ) = explode ( '|' , $option );
}
if ( $option != 'dynamic_list' )
{
// add option to return buket
$buket [] = $option ;
}
}
}
2017-12-14 23:10:47 +00:00
elseif ( ComponentbuilderHelper :: typeField ( $type , 'text' ))
2016-02-26 00:20:09 +00:00
{
// check to get the key words if set
2017-12-14 23:10:47 +00:00
$keywords = ComponentbuilderHelper :: getBetween ( $options , 'keywords="' , '"' );
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkString ( $keywords ))
{
2017-12-14 23:10:47 +00:00
if ( strpos ( $keywords , ',' ) !== false )
2016-02-26 00:20:09 +00:00
{
$keywords = explode ( ',' , $keywords );
2017-12-14 23:10:47 +00:00
foreach ( $keywords as $keyword )
2016-02-26 00:20:09 +00:00
{
$buket [ 'keywords' ][] = trim ( $keyword );
}
}
else
{
$buket [ 'keywords' ][] = trim ( $keywords );
}
}
// check to ket string length if set
2017-12-14 23:10:47 +00:00
$length = ComponentbuilderHelper :: getBetween ( $options , 'length="' , '"' );
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkString ( $length ))
{
$buket [ 'length' ] = $length ;
2017-12-14 23:10:47 +00:00
}
else
{
2016-02-26 00:20:09 +00:00
$buket [ 'length' ] = false ;
}
}
}
return $buket ;
}
2017-12-14 23:10:47 +00:00
public function getValueScript ( $type , $name , $extends , $unique )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$select = '' ;
$isArray = false ;
$keyName = $name . '_' . $unique ;
2017-02-01 13:17:04 +00:00
if ( $type === 'checkboxes' || $extends === 'checkboxes' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$select = " var " . $keyName . " = []; " . PHP_EOL . " \t jQuery('#jform_ " . $name . " input[type=checkbox]').each(function() " . PHP_EOL . " \t { " . PHP_EOL . " \t \t if (jQuery(this).is(':checked')) " . PHP_EOL . " \t \t { " . PHP_EOL . " \t \t \t " . $keyName . " .push(jQuery(this).prop('value')); " . PHP_EOL . " \t \t } " . PHP_EOL . " \t }); " ;
2016-02-26 00:20:09 +00:00
$isArray = true ;
}
2017-12-14 23:10:47 +00:00
elseif ( $type === 'checkbox' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$select = 'var ' . $keyName . ' = jQuery("#jform_' . $name . '").prop(\'checked\');' ;
2016-02-26 00:20:09 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $type === 'radio' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$select = 'var ' . $keyName . ' = jQuery("#jform_' . $name . ' input[type=\'radio\']:checked").val();' ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
elseif ( isset ( $this -> setScriptUserSwitch ) && ComponentbuilderHelper :: checkArray ( $this -> setScriptUserSwitch ) && in_array ( $type , $this -> setScriptUserSwitch ))
2016-04-22 12:03:43 +00:00
{
// this is only since 3.3.4
2017-12-14 23:10:47 +00:00
$select = 'var ' . $keyName . ' = jQuery("#jform_' . $name . '_id").val();' ;
2016-04-22 12:03:43 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $type === 'list' || ComponentbuilderHelper :: typeField ( $type , 'dynamic' ) || ! ComponentbuilderHelper :: typeField ( $type ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$select = 'var ' . $keyName . ' = jQuery("#jform_' . $name . '").val();' ;
2016-02-26 00:20:09 +00:00
$isArray = true ;
}
2017-12-14 23:10:47 +00:00
elseif ( ComponentbuilderHelper :: typeField ( $type , 'text' ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$select = 'var ' . $keyName . ' = jQuery("#jform_' . $name . '").val();' ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
return array ( 'get' => $select , 'isArray' => $isArray );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
public function clearValueScript ( $type , $name , $unique )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$clear = '' ;
$isArray = false ;
$keyName = $name . '_' . $unique ;
if ( $type === 'text' || $type === 'password' || $type === 'textarea' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$clear = " jQuery('#jform_ " . $name . " ').value = ''; " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
elseif ( $type === 'radio' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$clear = " jQuery('#jform_ " . $name . " ').checked = false; " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
elseif ( $type === 'checkboxes' || $type === 'checkbox' || $type === 'checkbox' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$clear = " jQuery('#jform_ " . $name . " ').selectedIndex = -1; " ;
2016-02-26 00:20:09 +00:00
}
return $clear ;
}
2016-09-11 15:27:04 +00:00
public function setViewScript ( & $view )
2016-02-26 00:20:09 +00:00
{
if ( isset ( $this -> editBodyViewScriptBuilder [ $view ]) && isset ( $this -> editBodyViewScriptBuilder [ $view ][ 'fileScript' ]))
{
return $this -> editBodyViewScriptBuilder [ $view ][ 'fileScript' ];
}
return '' ;
}
2016-09-11 15:27:04 +00:00
public function setEditBodyScript ( & $view )
2016-02-26 00:20:09 +00:00
{
if ( isset ( $this -> editBodyViewScriptBuilder [ $view ]) && isset ( $this -> editBodyViewScriptBuilder [ $view ][ 'footerScript' ]))
{
return $this -> editBodyViewScriptBuilder [ $view ][ 'footerScript' ];
}
return '' ;
}
2017-12-14 23:10:47 +00:00
public function setValidationFix ( $view , $Component )
2016-02-26 00:20:09 +00:00
{
$fix = '' ;
if ( isset ( $this -> validationFixBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> validationFixBuilder [ $view ]))
{
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . PHP_EOL . " \t /** " ;
$fix .= PHP_EOL . " \t * Method to validate the form data. " ;
$fix .= PHP_EOL . " \t * " ;
$fix .= PHP_EOL . " \t * @param JForm \$ form The form to validate against. " ;
$fix .= PHP_EOL . " \t * @param array \$ data The data to validate. " ;
$fix .= PHP_EOL . " \t * @param string \$ group The name of the field group to validate. " ;
$fix .= PHP_EOL . " \t * " ;
$fix .= PHP_EOL . " \t * @return mixed Array of filtered data if valid, false otherwise. " ;
$fix .= PHP_EOL . " \t * " ;
$fix .= PHP_EOL . " \t * @see JFormRule " ;
$fix .= PHP_EOL . " \t * @see JFilterInput " ;
$fix .= PHP_EOL . " \t * @since 12.2 " ;
$fix .= PHP_EOL . " \t */ " ;
$fix .= PHP_EOL . " \t public function validate( \$ form, \$ data, \$ group = null) " ;
$fix .= PHP_EOL . " \t { " ;
$fix .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " check if the not_required field is set " ;
$fix .= PHP_EOL . " \t \t if ( " . $Component . " Helper::checkString( \$ data['not_required'])) " ;
$fix .= PHP_EOL . " \t \t { " ;
$fix .= PHP_EOL . " \t \t \t \$ requiredFields = (array) explode(',',(string) \$ data['not_required']); " ;
$fix .= PHP_EOL . " \t \t \t \$ requiredFields = array_unique( \$ requiredFields); " ;
$fix .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " now change the required field attributes value " ;
$fix .= PHP_EOL . " \t \t \t foreach ( \$ requiredFields as \$ requiredField) " ;
$fix .= PHP_EOL . " \t \t \t { " ;
$fix .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " make sure there is a string value " ;
$fix .= PHP_EOL . " \t \t \t \t if ( " . $Component . " Helper::checkString( \$ requiredField)) " ;
$fix .= PHP_EOL . " \t \t \t \t { " ;
$fix .= PHP_EOL . " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " change to false " ;
$fix .= PHP_EOL . " \t \t \t \t \t \$ form->setFieldAttribute( \$ requiredField, 'required', 'false'); " ;
$fix .= PHP_EOL . " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " also clear the data set " ;
$fix .= PHP_EOL . " \t \t \t \t \t \$ data[ \$ requiredField] = ''; " ;
$fix .= PHP_EOL . " \t \t \t \t } " ;
$fix .= PHP_EOL . " \t \t \t } " ;
$fix .= PHP_EOL . " \t \t } " ;
$fix .= PHP_EOL . " \t \t return parent::validate( \$ form, \$ data, \$ group); " ;
$fix .= PHP_EOL . " \t } " ;
2016-02-26 00:20:09 +00:00
}
return $fix ;
}
2016-09-11 15:27:04 +00:00
public function setAjaxToke ( & $view )
2016-02-26 00:20:09 +00:00
{
$fix = '' ;
if ( isset ( $this -> customScriptBuilder [ 'token' ][ $view ]) && $this -> customScriptBuilder [ 'token' ][ $view ])
{
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Add Ajax Token " ;
$fix .= PHP_EOL . " \t \t \$ this->document->addScriptDeclaration( \" var token = ' \" .JSession::getFormToken(). \" '; \" ); " ;
2016-02-26 00:20:09 +00:00
}
return $fix ;
}
public function setRegisterAjaxTask ( $target )
{
$tasks = '' ;
if ( isset ( $this -> customScriptBuilder [ $target ][ 'ajax_controller' ]) && ComponentbuilderHelper :: checkArray ( $this -> customScriptBuilder [ $target ][ 'ajax_controller' ]))
{
$taskArray = array ();
foreach ( $this -> customScriptBuilder [ $target ][ 'ajax_controller' ] as $view )
{
foreach ( $view as $task )
{
$taskArray [ $task [ 'task_name' ]] = $task [ 'task_name' ];
}
}
if ( ComponentbuilderHelper :: checkArray ( $taskArray ))
{
foreach ( $taskArray as $name )
{
2017-12-14 23:10:47 +00:00
$tasks .= PHP_EOL . " \t \t \$ this->registerTask(' " . $name . " ', 'ajax'); " ;
2016-02-26 00:20:09 +00:00
}
}
}
return $tasks ;
}
public function setAjaxInputReturn ( $target )
{
$cases = '' ;
if ( isset ( $this -> customScriptBuilder [ $target ][ 'ajax_controller' ]) && ComponentbuilderHelper :: checkArray ( $this -> customScriptBuilder [ $target ][ 'ajax_controller' ]))
{
$input = array ();
$valueArray = array ();
$getModel = array ();
2017-11-01 03:16:21 +00:00
$userCheck = array ();
2016-02-26 00:20:09 +00:00
foreach ( $this -> customScriptBuilder [ $target ][ 'ajax_controller' ] as $view )
{
foreach ( $view as $task )
{
2017-12-14 23:10:47 +00:00
$input [ $task [ 'task_name' ]][] = PHP_EOL . " \t \t \t \t \t \t \$ " . $task [ 'value_name' ] . " Value = \$ jinput->get(' " . $task [ 'value_name' ] . " ', " . $task [ 'input_default' ] . " , ' " . $task [ 'input_filter' ] . " '); " ;
$valueArray [ $task [ 'task_name' ]][] = " \$ " . $task [ 'value_name' ] . " Value " ;
$getModel [ $task [ 'task_name' ]] = PHP_EOL . " \t \t \t \t \t \t \t \$ result = \$ this->getModel('ajax')-> " . $task [ 'method_name' ] . " ([[[valueArray]]]); " ;
2016-02-26 00:20:09 +00:00
// see user check is needed
2017-11-01 03:16:21 +00:00
if ( isset ( $task [ 'user_check' ]) && 1 == $task [ 'user_check' ])
2016-02-26 00:20:09 +00:00
{
// add it since this means it was not set, and in the old method we assumed it was inplace
// or it is set and 1 means we still want it inplace
$userCheck [ $task [ 'task_name' ]] = ' && $user->id != 0' ;
}
else
{
$userCheck [ $task [ 'task_name' ]] = '' ;
}
}
}
if ( ComponentbuilderHelper :: checkArray ( $getModel ))
{
foreach ( $getModel as $task => $getMethod )
{
2017-12-14 23:10:47 +00:00
$cases .= PHP_EOL . " \t \t \t \t case ' " . $task . " ': " ;
$cases .= PHP_EOL . " \t \t \t \t \t try " ;
$cases .= PHP_EOL . " \t \t \t \t \t { " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t \$ returnRaw = \$ jinput->get('raw', false, 'BOOLEAN'); " ;
2016-02-26 00:20:09 +00:00
foreach ( $input [ $task ] as $string )
{
$cases .= $string ;
}
// set the values
2017-12-14 23:10:47 +00:00
$values = implode ( ', ' , $valueArray [ $task ]);
$ifvalues = implode ( ' && ' , $valueArray [ $task ]);
2016-02-26 00:20:09 +00:00
// set the values to method
2017-12-14 23:10:47 +00:00
$getMethod = str_replace ( '[[[valueArray]]]' , $values , $getMethod );
$cases .= PHP_EOL . " \t \t \t \t \t \t if( " . $ifvalues . $userCheck [ $task ] . " ) " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t { " ;
2016-02-26 00:20:09 +00:00
$cases .= $getMethod ;
2017-12-14 23:10:47 +00:00
$cases .= PHP_EOL . " \t \t \t \t \t \t } " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t else " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t { " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t \t \$ result = false; " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t } " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t if( \$ callback = \$ jinput->get('callback', null, 'CMD')) " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t { " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t \t echo \$ callback . \" ( \" .json_encode( \$ result). \" ); \" ; " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t } " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t elseif( \$ returnRaw) " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t { " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t \t echo json_encode( \$ result); " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t } " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t else " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t { " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t \t echo \" ( \" .json_encode( \$ result). \" ); \" ; " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t } " ;
$cases .= PHP_EOL . " \t \t \t \t \t } " ;
$cases .= PHP_EOL . " \t \t \t \t \t catch(Exception \$ e) " ;
$cases .= PHP_EOL . " \t \t \t \t \t { " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t if( \$ callback = \$ jinput->get('callback', null, 'CMD')) " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t { " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t \t echo \$ callback. \" ( \" .json_encode( \$ e). \" ); \" ; " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t } " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t else " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t { " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t \t echo \" ( \" .json_encode( \$ e). \" ); \" ; " ;
$cases .= PHP_EOL . " \t \t \t \t \t \t } " ;
$cases .= PHP_EOL . " \t \t \t \t \t } " ;
$cases .= PHP_EOL . " \t \t \t \t break; " ;
2016-02-26 00:20:09 +00:00
}
}
}
return $cases ;
}
public function setAjaxModelMethods ( $target )
{
$methods = '' ;
if ( isset ( $this -> customScriptBuilder [ $target ][ 'ajax_model' ]) && ComponentbuilderHelper :: checkArray ( $this -> customScriptBuilder [ $target ][ 'ajax_model' ]))
{
foreach ( $this -> customScriptBuilder [ $target ][ 'ajax_model' ] as $view => $method )
{
2017-12-14 23:10:47 +00:00
$methods .= PHP_EOL . PHP_EOL . " \t // " . $this -> setLine ( __LINE__ ) . " Used in " . $view . PHP_EOL ;
2017-02-11 02:24:26 +00:00
$methods .= $this -> setPlaceholders ( $method , $this -> placeholders );
2016-02-26 00:20:09 +00:00
}
}
return $methods ;
}
2017-12-14 23:10:47 +00:00
public function setFilterFunctions ( $viewName_single , $viewName_list )
2016-02-26 00:20:09 +00:00
{
if ( isset ( $this -> filterBuilder [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> filterBuilder [ $viewName_list ]))
{
$function = array ();
// set component name
$component = ComponentbuilderHelper :: safeString ( $this -> componentData -> name_code );
foreach ( $this -> filterBuilder [ $viewName_list ] as $filter )
{
2017-02-01 13:17:04 +00:00
if ( $filter [ 'type' ] != 'category' && ComponentbuilderHelper :: checkArray ( $filter [ 'custom' ]) && $filter [ 'custom' ][ 'extends' ] === 'user' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$function [] = PHP_EOL . " \t protected function getThe " . $filter [ 'function' ] . ComponentbuilderHelper :: safeString ( $filter [ 'custom' ][ 'text' ], 'F' ) . " Selections() " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t { " ;
2017-12-14 23:10:47 +00:00
$function [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Get a db connection. " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t \$ db = JFactory::getDbo(); " ;
2017-12-14 23:10:47 +00:00
$function [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Create a new query object. " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t \$ query = \$ db->getQuery(true); " ;
2017-12-14 23:10:47 +00:00
$function [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Select the text. " ;
$function [] = " \t \t \$ query->select( \$ db->quoteName(array('a. " . $filter [ 'custom' ][ 'id' ] . " ','a. " . $filter [ 'custom' ][ 'text' ] . " '))); " ;
$function [] = " \t \t \$ query->from( \$ db->quoteName(' " . $filter [ 'custom' ][ 'table' ] . " ', 'a')); " ;
$function [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " get the targeted groups " ;
$function [] = " \t \t \$ groups= JComponentHelper::getParams('com_ " . $component . " ')->get(' " . $filter [ 'type' ] . " '); " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t if (count( \$ groups) > 0) " ;
$function [] = " \t \t { " ;
$function [] = " \t \t \t \$ query->join('LEFT', \$ db->quoteName('#__user_usergroup_map', 'group') . ' ON (' . \$ db->quoteName('group.user_id') . ' = ' . \$ db->quoteName('a.id') . ')'); " ;
$function [] = " \t \t \t \$ query->where('group.group_id IN (' . implode(',', \$ groups) . ')'); " ;
$function [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$function [] = " \t \t \$ query->order('a. " . $filter [ 'custom' ][ 'text' ] . " ASC'); " ;
$function [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Reset the query using our newly populated query object. " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t \$ db->setQuery( \$ query); " ;
2017-12-14 23:10:47 +00:00
$function [] = PHP_EOL . " \t \t \$ results = \$ db->loadObjectList(); " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t if ( \$ results) " ;
$function [] = " \t \t { " ;
$function [] = " \t \t \t \$ filter = array(); " ;
$function [] = " \t \t \t \$ batch = array(); " ;
$function [] = " \t \t \t foreach ( \$ results as \$ result) " ;
$function [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$function [] = " \t \t \t \t \$ filter[] = JHtml::_('select.option', \$ result-> " . $filter [ 'custom' ][ 'id' ] . " , \$ result-> " . $filter [ 'custom' ][ 'text' ] . " ); " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t \t } " ;
$function [] = " \t \t \t return \$ filter; " ;
$function [] = " \t \t } " ;
$function [] = " \t \t return false; " ;
$function [] = " \t } " ;
/* else
2017-12-14 23:10:47 +00:00
{
$function [] = PHP_EOL . " \t protected function getThe " . $filter [ 'function' ] . ComponentbuilderHelper :: safeString ( $filter [ 'custom' ][ 'text' ], 'F' ) . " Selections() " ;
$function [] = " \t { " ;
$function [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Get a db connection. " ;
$function [] = " \t \t \$ db = JFactory::getDbo(); " ;
$function [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Select the text. " ;
$function [] = " \t \t \$ query = \$ db->getQuery(true); " ;
$function [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Select the text. " ;
$function [] = " \t \t \$ query->select( \$ db->quoteName(array(' " . $filter [ 'custom' ][ 'id' ] . " ',' " . $filter [ 'custom' ][ 'text' ] . " '))); " ;
$function [] = " \t \t \$ query->from( \$ db->quoteName(' " . $filter [ 'custom' ][ 'table' ] . " ')); " ;
$function [] = " \t \t \$ query->where( \$ db->quoteName('published') . ' = 1'); " ;
$function [] = " \t \t \$ query->order( \$ db->quoteName(' " . $filter [ 'custom' ][ 'text' ] . " ') . ' ASC'); " ;
$function [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Reset the query using our newly populated query object. " ;
$function [] = " \t \t \$ db->setQuery( \$ query); " ;
$function [] = PHP_EOL . " \t \t \$ results = \$ db->loadObjectList(); " ;
$function [] = PHP_EOL . " \t \t if ( \$ results) " ;
$function [] = " \t \t { " ;
$function [] = " \t \t \t \$ filter = array(); " ;
$function [] = " \t \t \t \$ batch = array(); " ;
$function [] = " \t \t \t foreach ( \$ results as \$ result) " ;
$function [] = " \t \t \t { " ;
if ( $filter [ 'custom' ][ 'text' ] === 'user' )
{
$function [] = " \t \t \t \t \$ filter[] = JHtml::_('select.option', \$ result-> " . $filter [ 'custom' ][ 'text' ] . " , JFactory::getUser( \$ result-> " . $filter [ 'custom' ][ 'text' ] . " )->name); " ;
$function [] = " \t \t \t \t \$ batch[] = JHtml::_('select.option', \$ result-> " . $filter [ 'custom' ][ 'id' ] . " , JFactory::getUser( \$ result-> " . $filter [ 'custom' ][ 'text' ] . " )->name); " ;
}
else
{
$function [] = " \t \t \t \t \$ filter[] = JHtml::_('select.option', \$ result-> " . $filter [ 'custom' ][ 'text' ] . " , \$ result-> " . $filter [ 'custom' ][ 'text' ] . " ); " ;
$function [] = " \t \t \t \t \$ batch[] = JHtml::_('select.option', \$ result-> " . $filter [ 'custom' ][ 'id' ] . " , \$ result-> " . $filter [ 'custom' ][ 'text' ] . " ); " ;
}
$function [] = " \t \t \t } " ;
$function [] = " \t \t \t return array('filter' => \$ filter, 'batch' => \$ batch); " ;
$function [] = " \t \t } " ;
$function [] = " \t \t return false; " ;
$function [] = " \t } " ;
} */
2016-02-26 00:20:09 +00:00
}
elseif ( $filter [ 'type' ] != 'category' && ! ComponentbuilderHelper :: checkArray ( $filter [ 'custom' ]))
{
$translation = false ;
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> selectionTranslationFixBuilder [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> selectionTranslationFixBuilder [ $viewName_list ]) && array_key_exists ( $filter [ 'code' ], $this -> selectionTranslationFixBuilder [ $viewName_list ]))
2016-02-26 00:20:09 +00:00
{
$translation = true ;
}
2017-12-14 23:10:47 +00:00
$function [] = PHP_EOL . " \t protected function getThe " . $filter [ 'function' ] . " Selections() " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t { " ;
2017-12-14 23:10:47 +00:00
$function [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Get a db connection. " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t \$ db = JFactory::getDbo(); " ;
2017-12-14 23:10:47 +00:00
$function [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Create a new query object. " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t \$ query = \$ db->getQuery(true); " ;
2017-12-14 23:10:47 +00:00
$function [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Select the text. " ;
$function [] = " \t \t \$ query->select( \$ db->quoteName(' " . $filter [ 'code' ] . " ')); " ;
$function [] = " \t \t \$ query->from( \$ db->quoteName('#__ " . $component . " _ " . $filter [ 'database' ] . " ')); " ;
$function [] = " \t \t \$ query->order( \$ db->quoteName(' " . $filter [ 'code' ] . " ') . ' ASC'); " ;
$function [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Reset the query using our newly populated query object. " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t \$ db->setQuery( \$ query); " ;
2017-12-14 23:10:47 +00:00
$function [] = PHP_EOL . " \t \t \$ results = \$ db->loadColumn(); " ;
$function [] = PHP_EOL . " \t \t if ( \$ results) " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t { " ;
// check if translated vlaue is used
if ( $translation )
{
2017-12-14 23:10:47 +00:00
$function [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " get model " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t \t \$ model = \$ this->getModel(); " ;
}
$function [] = " \t \t \t \$ results = array_unique( \$ results); " ;
2017-02-11 02:24:26 +00:00
$function [] = " \t \t \t \$ _filter = array(); " ;
2017-12-14 23:10:47 +00:00
$function [] = " \t \t \t foreach ( \$ results as \$ " . $filter [ 'code' ] . " ) " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t \t { " ;
// check if translated vlaue is used
if ( $translation )
{
2017-12-14 23:10:47 +00:00
$function [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Translate the " . $filter [ 'code' ] . " selection " ;
$function [] = " \t \t \t \t \$ text = \$ model->selectionTranslation( \$ " . $filter [ 'code' ] . " ,' " . $filter [ 'code' ] . " '); " ;
$function [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Now add the " . $filter [ 'code' ] . " and its text to the options array " ;
$function [] = " \t \t \t \t \$ _filter[] = JHtml::_('select.option', \$ " . $filter [ 'code' ] . " , JText::_( \$ text)); " ;
2016-02-26 00:20:09 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $filter [ 'type' ] === 'user' )
2016-06-02 16:18:49 +00:00
{
2017-12-14 23:10:47 +00:00
$function [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Now add the " . $filter [ 'code' ] . " and its text to the options array " ;
$function [] = " \t \t \t \t \$ _filter[] = JHtml::_('select.option', \$ " . $filter [ 'code' ] . " , JFactory::getUser( \$ " . $filter [ 'code' ] . " )->name); " ;
2016-06-02 16:18:49 +00:00
}
2016-02-26 00:20:09 +00:00
else
{
2017-12-14 23:10:47 +00:00
$function [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Now add the " . $filter [ 'code' ] . " and its text to the options array " ;
$function [] = " \t \t \t \t \$ _filter[] = JHtml::_('select.option', \$ " . $filter [ 'code' ] . " , \$ " . $filter [ 'code' ] . " ); " ;
2016-02-26 00:20:09 +00:00
}
$function [] = " \t \t \t } " ;
2017-02-11 02:24:26 +00:00
$function [] = " \t \t \t return \$ _filter; " ;
2016-02-26 00:20:09 +00:00
$function [] = " \t \t } " ;
$function [] = " \t \t return false; " ;
$function [] = " \t } " ;
}
}
if ( ComponentbuilderHelper :: checkArray ( $function ))
{
// return the function
2017-12-14 23:10:47 +00:00
return PHP_EOL . implode ( PHP_EOL , $function );
2016-02-26 00:20:09 +00:00
}
}
return '' ;
}
2016-09-11 15:27:04 +00:00
public function setUniqueFields ( & $view )
2016-02-26 00:20:09 +00:00
{
$fields = array ();
2017-12-14 23:10:47 +00:00
$fields [] = PHP_EOL . PHP_EOL . " \t /** " ;
2016-02-26 00:20:09 +00:00
$fields [] = " \t * Method to get the unique fields of this table. " ;
$fields [] = " \t * " ;
$fields [] = " \t * @return mixed An array of field names, boolean false if none is set. " ;
$fields [] = " \t * " ;
$fields [] = " \t * @since 3.0 " ;
$fields [] = " \t */ " ;
2016-02-26 12:46:15 +00:00
$fields [] = " \t protected function getUniqeFields() " ;
2016-02-26 00:20:09 +00:00
$fields [] = " \t { " ;
if ( isset ( $this -> dbUniqueKeys [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> dbUniqueKeys [ $view ]))
{
2017-12-14 23:10:47 +00:00
$fields [] = " \t \t return array(' " . implode ( " ',' " , $this -> dbUniqueKeys [ $view ]) . " '); " ;
2016-02-26 00:20:09 +00:00
}
else
{
$fields [] = " \t \t return false; " ;
}
$fields [] = " \t } " ;
// return the unique fields
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $fields );
2016-02-26 00:20:09 +00:00
}
2016-09-11 15:27:04 +00:00
public function setOtherFilter ( & $view )
2016-02-26 00:20:09 +00:00
{
if ( isset ( $this -> filterBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> filterBuilder [ $view ]))
{
$otherFilter = array ();
foreach ( $this -> filterBuilder [ $view ] as $filter )
{
if ( $filter [ 'type' ] != 'category' && ComponentbuilderHelper :: checkArray ( $filter [ 'custom' ]) && $filter [ 'custom' ][ 'extends' ] !== 'user' )
{
2017-12-14 23:10:47 +00:00
$CodeName = ComponentbuilderHelper :: safeString ( $filter [ 'code' ] . ' ' . $filter [ 'custom' ][ 'text' ], 'W' );
$codeName = $filter [ 'code' ] . ComponentbuilderHelper :: safeString ( $filter [ 'custom' ][ 'text' ], 'F' );
$type = ComponentbuilderHelper :: safeString ( $filter [ 'custom' ][ 'type' ], 'F' );
$otherFilter [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Set " . $CodeName . " Selection " ;
$otherFilter [] = " \t \t \$ this-> " . $codeName . " Options = JFormHelper::loadFieldType(' " . $type . " ')->getOptions(); " ;
$otherFilter [] = " \t \t if ( \$ this-> " . $codeName . " Options) " ;
2016-02-26 00:20:09 +00:00
$otherFilter [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$otherFilter [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " " . $CodeName . " Filter " ;
2016-02-26 00:20:09 +00:00
$otherFilter [] = " \t \t \t JHtmlSidebar::addFilter( " ;
2017-12-14 23:10:47 +00:00
$otherFilter [] = " \t \t \t \t '- Select '.JText::_(' " . $filter [ 'lang' ] . " ').' -', " ;
$otherFilter [] = " \t \t \t \t 'filter_ " . $filter [ 'code' ] . " ', " ;
$otherFilter [] = " \t \t \t \t JHtml::_('select.options', \$ this-> " . $codeName . " Options, 'value', 'text', \$ this->state->get('filter. " . $filter [ 'code' ] . " ')) " ;
2016-02-26 00:20:09 +00:00
$otherFilter [] = " \t \t \t ); " ;
2017-12-14 23:10:47 +00:00
$otherFilter [] = PHP_EOL . " \t \t \t if ( \$ this->canBatch && \$ this->canCreate && \$ this->canEdit) " ;
2016-02-26 00:20:09 +00:00
$otherFilter [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$otherFilter [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " " . $CodeName . " Batch Selection " ;
2016-02-26 00:20:09 +00:00
$otherFilter [] = " \t \t \t \t JHtmlBatch_::addListSelection( " ;
2017-12-14 23:10:47 +00:00
$otherFilter [] = " \t \t \t \t \t '- Keep Original '.JText::_(' " . $filter [ 'lang' ] . " ').' -', " ;
$otherFilter [] = " \t \t \t \t \t 'batch[ " . $filter [ 'code' ] . " ]', " ;
$otherFilter [] = " \t \t \t \t \t JHtml::_('select.options', \$ this-> " . $codeName . " Options, 'value', 'text') " ;
2016-02-26 00:20:09 +00:00
$otherFilter [] = " \t \t \t \t ); " ;
$otherFilter [] = " \t \t \t } " ;
$otherFilter [] = " \t \t } " ;
}
elseif ( $filter [ 'type' ] != 'category' )
{
2017-12-14 23:10:47 +00:00
$Codename = ComponentbuilderHelper :: safeString ( $filter [ 'code' ], 'W' );
2016-02-26 00:20:09 +00:00
if ( isset ( $filter [ 'custom' ]) && ComponentbuilderHelper :: checkArray ( $filter [ 'custom' ]) && $filter [ 'custom' ][ 'extends' ] === 'user' )
{
2017-12-14 23:10:47 +00:00
$functionName = " \$ this->getThe " . $filter [ 'function' ] . ComponentbuilderHelper :: safeString ( $filter [ 'custom' ][ 'text' ], 'F' ) . " Selections(); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$functionName = " \$ this->getThe " . $filter [ 'function' ] . " Selections(); " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$otherFilter [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Set " . $Codename . " Selection " ;
$otherFilter [] = " \t \t \$ this-> " . $filter [ 'code' ] . " Options = " . $functionName ;
$otherFilter [] = " \t \t if ( \$ this-> " . $filter [ 'code' ] . " Options) " ;
2016-02-26 00:20:09 +00:00
$otherFilter [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$otherFilter [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " " . $Codename . " Filter " ;
2016-02-26 00:20:09 +00:00
$otherFilter [] = " \t \t \t JHtmlSidebar::addFilter( " ;
2017-12-14 23:10:47 +00:00
$otherFilter [] = " \t \t \t \t '- Select '.JText::_(' " . $filter [ 'lang' ] . " ').' -', " ;
$otherFilter [] = " \t \t \t \t 'filter_ " . $filter [ 'code' ] . " ', " ;
$otherFilter [] = " \t \t \t \t JHtml::_('select.options', \$ this-> " . $filter [ 'code' ] . " Options, 'value', 'text', \$ this->state->get('filter. " . $filter [ 'code' ] . " ')) " ;
2016-02-26 00:20:09 +00:00
$otherFilter [] = " \t \t \t ); " ;
2017-12-14 23:10:47 +00:00
$otherFilter [] = PHP_EOL . " \t \t \t if ( \$ this->canBatch && \$ this->canCreate && \$ this->canEdit) " ;
2016-02-26 00:20:09 +00:00
$otherFilter [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$otherFilter [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " " . $Codename . " Batch Selection " ;
2016-02-26 00:20:09 +00:00
$otherFilter [] = " \t \t \t \t JHtmlBatch_::addListSelection( " ;
2017-12-14 23:10:47 +00:00
$otherFilter [] = " \t \t \t \t \t '- Keep Original '.JText::_(' " . $filter [ 'lang' ] . " ').' -', " ;
$otherFilter [] = " \t \t \t \t \t 'batch[ " . $filter [ 'code' ] . " ]', " ;
$otherFilter [] = " \t \t \t \t \t JHtml::_('select.options', \$ this-> " . $filter [ 'code' ] . " Options, 'value', 'text') " ;
2016-02-26 00:20:09 +00:00
$otherFilter [] = " \t \t \t \t ); " ;
$otherFilter [] = " \t \t \t } " ;
$otherFilter [] = " \t \t } " ;
}
}
if ( ComponentbuilderHelper :: checkArray ( $otherFilter ))
{
// return the filter
2017-12-14 23:10:47 +00:00
return PHP_EOL . implode ( PHP_EOL , $otherFilter );
2016-02-26 00:20:09 +00:00
}
}
return '' ;
}
public function setCategoryFilter ( $viewName_list )
{
if ( isset ( $this -> categoryBuilder [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> categoryBuilder [ $viewName_list ]))
{
// check if category has another name
if ( isset ( $this -> catOtherName [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> catOtherName [ $viewName_list ]))
{
$otherViews = $this -> catOtherName [ $viewName_list ][ 'views' ];
}
else
{
$otherViews = $viewName_list ;
}
// set component name
$component = ComponentbuilderHelper :: safeString ( $this -> componentData -> name_code );
2017-12-14 23:10:47 +00:00
$COMONENT = ComponentbuilderHelper :: safeString ( $this -> componentData -> name_code , 'U' );
2016-02-26 00:20:09 +00:00
// set filter
$filter = array ();
2017-12-14 23:10:47 +00:00
$filter [] = PHP_EOL . PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Category Filter. " ;
2016-02-26 00:20:09 +00:00
$filter [] = " \t \t JHtmlSidebar::addFilter( " ;
$filter [] = " \t \t \t JText::_('JOPTION_SELECT_CATEGORY'), " ;
$filter [] = " \t \t \t 'filter_category_id', " ;
2017-12-14 23:10:47 +00:00
$filter [] = " \t \t \t JHtml::_('select.options', JHtml::_('category.options', 'com_ " . $component . " . " . $otherViews . " '), 'value', 'text', \$ this->state->get('filter.category_id')) " ;
2016-02-26 00:20:09 +00:00
$filter [] = " \t \t ); " ;
2017-12-14 23:10:47 +00:00
$filter [] = PHP_EOL . " \t \t if ( \$ this->canBatch && \$ this->canCreate && \$ this->canEdit) " ;
2016-02-26 00:20:09 +00:00
$filter [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$filter [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Category Batch selection. " ;
2016-02-26 00:20:09 +00:00
$filter [] = " \t \t \t JHtmlBatch_::addListSelection( " ;
2017-12-14 23:10:47 +00:00
$filter [] = " \t \t \t \t JText::_('COM_ " . $COMONENT . " _KEEP_ORIGINAL_CATEGORY'), " ;
2016-02-26 00:20:09 +00:00
$filter [] = " \t \t \t \t 'batch[category]', " ;
2017-12-14 23:10:47 +00:00
$filter [] = " \t \t \t \t JHtml::_('select.options', JHtml::_('category.options', 'com_ " . $component . " . " . $otherViews . " '), 'value', 'text') " ;
2016-02-26 00:20:09 +00:00
$filter [] = " \t \t \t ); " ;
$filter [] = " \t \t } " ;
// return the filter
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $filter );
2016-02-26 00:20:09 +00:00
}
return '' ;
}
2017-12-14 23:10:47 +00:00
public function setRouterCategoryViews ( $viewName_single , $viewName_list )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> categoryBuilder [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> categoryBuilder [ $viewName_list ]))
{
2016-02-26 00:20:09 +00:00
// set component name
$component = ComponentbuilderHelper :: safeString ( $this -> componentData -> name_code );
// check if category has another name
if ( isset ( $this -> catOtherName [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> catOtherName [ $viewName_list ]))
{
$otherViews = $this -> catOtherName [ $viewName_list ][ 'views' ];
$otherView = $this -> catOtherName [ $viewName_list ][ 'view' ];
}
else
{
$otherViews = $viewName_list ;
$otherView = $viewName_single ;
}
2017-03-06 12:06:51 +00:00
// load the category helper details in not already loaded
2017-12-14 23:10:47 +00:00
if ( ! isset ( $this -> fileContentDynamic [ 'category' . $otherViews ][ '###view###' ]))
2017-03-06 12:06:51 +00:00
{
// lets also set the category helper for this view
2017-12-14 23:10:47 +00:00
$target = array ( 'site' => 'category' . $viewName_list );
2017-03-06 12:06:51 +00:00
$this -> buildDynamique ( $target , 'category' );
// insure the file gets updated
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ 'category' . $otherViews ][ '###view###' ] = $otherView ;
$this -> fileContentDynamic [ 'category' . $otherViews ][ '###View###' ] = ucfirst ( $otherView );
$this -> fileContentDynamic [ 'category' . $otherViews ][ '###views###' ] = $otherViews ;
$this -> fileContentDynamic [ 'category' . $otherViews ][ '###Views###' ] = ucfirst ( $otherViews );
2017-03-06 12:06:51 +00:00
// set script to global helper file
$includeHelper = array ();
2017-12-14 23:10:47 +00:00
$includeHelper [] = " \n // " . $this -> setLine ( __LINE__ ) . " Insure this view category file is loaded. " ;
$includeHelper [] = " \$ classname = ' " . $this -> fileContentStatic [ '###component###' ] . ucfirst ( $viewName_list ) . " Categories'; " ;
2017-03-06 12:06:51 +00:00
$includeHelper [] = " if (!class_exists( \$ classname)) " ;
$includeHelper [] = " { " ;
2017-12-14 23:10:47 +00:00
$includeHelper [] = " \t \$ path = JPATH_SITE . '/components/com_ " . $this -> fileContentStatic [ '###component###' ] . " /helpers/category " . $viewName_list . " .php'; " ;
2017-03-06 12:06:51 +00:00
$includeHelper [] = " \t if (is_file( \$ path)) " ;
$includeHelper [] = " \t { " ;
$includeHelper [] = " \t \t include_once \$ path; " ;
$includeHelper [] = " \t } " ;
$includeHelper [] = " } " ;
2017-12-14 23:10:47 +00:00
$this -> fileContentStatic [ '###CATEGORY_CLASS_TREES###' ] .= implode ( " \n " , $includeHelper );
2017-03-06 12:06:51 +00:00
}
2016-02-26 00:20:09 +00:00
// return category view string
if ( isset ( $this -> fileContentStatic [ '###ROUTER_CATEGORY_VIEWS###' ]) && ComponentbuilderHelper :: checkString ( $this -> fileContentStatic [ '###ROUTER_CATEGORY_VIEWS###' ]))
{
2017-12-14 23:10:47 +00:00
return " , " . PHP_EOL . " \t \t \t " . '"com_' . $component . '.' . $otherViews . '" => "' . $otherView . '"' ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
return PHP_EOL . " \t \t \t " . '"com_' . $component . '.' . $otherViews . '" => "' . $otherView . '"' ;
2016-02-26 00:20:09 +00:00
}
}
return '' ;
}
2017-12-14 23:10:47 +00:00
public function setJcontrollerAllowAdd ( $viewName_single , $viewName_list )
2016-02-26 00:20:09 +00:00
{
$allow = array ();
// set component name
$component = ComponentbuilderHelper :: safeString ( $this -> componentData -> name_code );
// setup correct core target
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $viewName_single ]))
{
$core = $this -> permissionCore [ $viewName_single ];
$coreLoad = true ;
}
// check if item has category
2017-12-14 23:10:47 +00:00
if ( 0 ) //isset($this->categoryBuilder[$viewName_list]) && ComponentbuilderHelper::checkArray($this->categoryBuilder[$viewName_list])) <-- remove category from check
2017-02-09 16:11:10 +00:00
{
2016-02-26 00:20:09 +00:00
// check if category has another name
if ( $coreLoad && isset ( $this -> catOtherName [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> catOtherName [ $viewName_list ]))
{
$otherViews = $this -> catOtherName [ $viewName_list ][ 'views' ];
$otherView = $this -> catOtherName [ $viewName_list ][ 'view' ];
}
else
{
$otherViews = $viewName_list ;
$otherView = $viewName_single ;
}
// setup the category script
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " get the user object " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \$ user = JFactory::getUser(); " ;
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.access' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]) && in_array ( $otherView , $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Access check. " ;
$allow [] = " \t \t \$ access = \$ user->authorise(' " . $core [ 'core.access' ] . " ', 'com_ " . $component . " '); " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t if (! \$ access) " ;
$allow [] = " \t \t { " ;
$allow [] = " \t \t \t return false; " ;
$allow [] = " \t \t } " ;
}
$allow [] = " \t \t \$ categoryId = JArrayHelper::getValue( \$ data, 'catid', \$ this->input->getInt('filter_category_id'), 'int'); " ;
$allow [] = " \t \t \$ allow = null; " ;
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t if ( \$ categoryId) " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " If the category has been passed in the URL check it. " ;
$allow [] = " \t \t \t \$ allow = \$ user->authorise('core.create', \$ this->option . '. " . $otherViews . " .category.' . \$ categoryId); " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t if ( \$ allow === null) " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t { " ;
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.create' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]))
2016-02-26 00:20:09 +00:00
{
// setup the default script
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " In the absense of better information, revert to the component permissions. " ;
$allow [] = " \t \t \t return \$ user->authorise(' " . $core [ 'core.create' ] . " ', \$ this->option); " ;
2016-02-26 00:20:09 +00:00
}
else
{
// setup the default script
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " In the absense of better information, revert to the component permissions. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t return parent::allowAdd( \$ data); " ;
}
$allow [] = " \t \t } " ;
$allow [] = " \t \t else " ;
$allow [] = " \t \t { " ;
$allow [] = " \t \t \t return \$ allow; " ;
$allow [] = " \t \t } " ;
}
else
{
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.access' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Access check. " ;
$allow [] = " \t \t \$ access = JFactory::getUser()->authorise(' " . $core [ 'core.access' ] . " ', 'com_ " . $component . " '); " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t if (! \$ access) " ;
$allow [] = " \t \t { " ;
$allow [] = " \t \t \t return false; " ;
$allow [] = " \t \t } " ;
}
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.create' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]))
2016-02-26 00:20:09 +00:00
{
// setup the default script
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " In the absense of better information, revert to the component permissions. " ;
$allow [] = " \t \t return JFactory::getUser()->authorise(' " . $core [ 'core.create' ] . " ', \$ this->option); " ;
2016-02-26 00:20:09 +00:00
}
else
{
// setup the default script
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " In the absense of better information, revert to the component permissions. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t return parent::allowAdd( \$ data); " ;
}
}
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $allow );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
public function setJcontrollerAllowEdit ( $viewName_single , $viewName_list )
2016-02-26 00:20:09 +00:00
{
$allow = array ();
// set component name
$component = ComponentbuilderHelper :: safeString ( $this -> componentData -> name_code );
// prepare custom permission script
2017-12-14 23:10:47 +00:00
$customAllow = $this -> getCustomScriptBuilder ( 'php_allowedit' , $viewName_single , '' , null , true );
2016-02-26 00:20:09 +00:00
// setup correct core target
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $viewName_single ]))
{
$core = $this -> permissionCore [ $viewName_single ];
$coreLoad = true ;
}
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> categoryBuilder [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> categoryBuilder [ $viewName_list ]))
{
2016-02-26 00:20:09 +00:00
// check if category has another name
if ( $coreLoad && isset ( $this -> catOtherName [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> catOtherName [ $viewName_list ]))
{
$otherViews = $this -> catOtherName [ $viewName_list ][ 'views' ];
$otherView = $this -> catOtherName [ $viewName_list ][ 'view' ];
}
else
{
$otherViews = $viewName_list ;
$otherView = $viewName_single ;
}
// setup the category script
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " get user object. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \$ user \t \t = JFactory::getUser(); " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " get record id. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \$ recordId \t = (int) isset( \$ data[ \$ key]) ? \$ data[ \$ key] : 0; " ;
// load custom permission script
$allow [] = $customAllow ;
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.access' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]) && in_array ( $otherView , $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Access check. " ;
$allow [] = " \t \t \$ access = ( \$ user->authorise(' " . $core [ 'core.access' ] . " ', 'com_ " . $component . " . " . $otherView . " .' . (int) \$ recordId) && \$ user->authorise(' " . $core [ 'core.access' ] . " ', 'com_ " . $component . " ')); " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t if (! \$ access) " ;
$allow [] = " \t \t { " ;
$allow [] = " \t \t \t return false; " ;
$allow [] = " \t \t } " ;
}
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t if ( \$ recordId) " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " The record has been set. Check the record permissions. " ;
2016-02-26 00:20:09 +00:00
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit' ]) && isset ( $this -> permissionBuilder [ $core [ 'core.edit' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $core [ 'core.edit' ]]) && in_array ( $otherView , $this -> permissionBuilder [ $core [ 'core.edit' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \$ permission = \$ user->authorise(' " . $core [ 'core.edit' ] . " ', 'com_ " . $component . " . " . $otherView . " .' . (int) \$ recordId); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \$ permission = \$ user->authorise('core.edit', 'com_ " . $component . " . " . $otherView . " .' . (int) \$ recordId); " ;
2016-02-26 00:20:09 +00:00
}
2016-12-22 21:32:13 +00:00
$allow [] = " \t \t \t if (! \$ permission) " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t { " ;
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit.own' ]) && isset ( $this -> permissionBuilder [ $core [ 'core.edit.own' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $core [ 'core.edit.own' ]]) && in_array ( $otherView , $this -> permissionBuilder [ $core [ 'core.edit.own' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \t if ( \$ user->authorise(' " . $core [ 'core.edit.own' ] . " ', 'com_ " . $component . " . " . $otherView . " .' . \$ recordId)) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \t if ( \$ user->authorise('core.edit.own', 'com_ " . $component . " . " . $otherView . " .' . \$ recordId)) " ;
2016-02-26 00:20:09 +00:00
}
$allow [] = " \t \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Fallback on edit.own. Now test the owner is the user. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \t \t \$ ownerId = (int) isset( \$ data['created_by']) ? \$ data['created_by'] : 0; " ;
$allow [] = " \t \t \t \t \t if (empty( \$ ownerId)) " ;
$allow [] = " \t \t \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Need to do a lookup from the model. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \t \t \t \$ record = \$ this->getModel()->getItem( \$ recordId); " ;
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t \t \t \t \t if (empty( \$ record)) " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \t \t \t { " ;
$allow [] = " \t \t \t \t \t \t \t return false; " ;
$allow [] = " \t \t \t \t \t \t } " ;
$allow [] = " \t \t \t \t \t \t \$ ownerId = \$ record->created_by; " ;
$allow [] = " \t \t \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " If the owner matches 'me' then do the test. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \t \t if ( \$ ownerId == \$ user->id) " ;
$allow [] = " \t \t \t \t \t { " ;
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit.own' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.own' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.own' ]]) && in_array ( $otherView , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.own' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \t \t \t if ( \$ user->authorise(' " . $core [ 'core.edit.own' ] . " ', 'com_ " . $component . " ')) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \t \t \t if ( \$ user->authorise('core.edit.own', 'com_ " . $component . " ')) " ;
2016-02-26 00:20:09 +00:00
}
$allow [] = " \t \t \t \t \t \t { " ;
$allow [] = " \t \t \t \t \t \t \t return true; " ;
$allow [] = " \t \t \t \t \t \t } " ;
$allow [] = " \t \t \t \t \t } " ;
$allow [] = " \t \t \t \t } " ;
$allow [] = " \t \t \t \t return false; " ;
$allow [] = " \t \t \t } " ;
2017-02-09 16:11:10 +00:00
// $allow[] = PHP_EOL."\t\t\t\$categoryId = (int) isset(\$data['catid']) ? \$data['catid']: \$this->getModel()->getItem(\$recordId)->catid;"; <-- remove category from check
// $allow[] = PHP_EOL."\t\t\tif (\$categoryId)";
// $allow[] = "\t\t\t{";
// $allow[] = "\t\t\t\t//".$this->setLine(__LINE__)." The category has been set. Check the category permissions.";
// $allow[] = "\t\t\t\t\$catpermission = \$user->authorise('core.edit', \$this->option . '.".$otherView.".category.' . \$categoryId);";
// $allow[] = "\t\t\t\tif (!\$catpermission && !is_null(\$catpermission))";
// $allow[] = "\t\t\t\t{";
// $allow[] = "\t\t\t\t\treturn false;";
// $allow[] = "\t\t\t\t}";
// $allow[] = "\t\t\t}";
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && in_array ( $otherView , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Since there is no permission, revert to the component permissions. " ;
$allow [] = " \t \t return \$ user->authorise(' " . $core [ 'core.edit' ] . " ', \$ this->option); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Since there is no permission, revert to the component permissions. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t return parent::allowEdit( \$ data, \$ key); " ;
}
}
else
{
// setup the category script
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " get user object. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \$ user \t \t = JFactory::getUser(); " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " get record id. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \$ recordId \t = (int) isset( \$ data[ \$ key]) ? \$ data[ \$ key] : 0; " ;
// load custom permission script
$allow [] = $customAllow ;
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.access' ]) && isset ( $this -> permissionBuilder [ $core [ 'core.access' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $core [ 'core.access' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ $core [ 'core.access' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Access check. " ;
$allow [] = " \t \t \$ access = ( \$ user->authorise(' " . $core [ 'core.access' ] . " ', 'com_ " . $component . " . " . $viewName_single . " .' . (int) \$ recordId) && \$ user->authorise(' " . $core [ 'core.access' ] . " ', 'com_ " . $component . " ')); " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t if (! \$ access) " ;
$allow [] = " \t \t { " ;
$allow [] = " \t \t \t return false; " ;
$allow [] = " \t \t } " ;
}
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t if ( \$ recordId) " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " The record has been set. Check the record permissions. " ;
2016-02-26 00:20:09 +00:00
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit' ]) && isset ( $this -> permissionBuilder [ $core [ 'core.edit' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $core [ 'core.edit' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ $core [ 'core.edit' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \$ permission = \$ user->authorise(' " . $core [ 'core.edit' ] . " ', 'com_ " . $component . " . " . $viewName_single . " .' . (int) \$ recordId); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \$ permission = \$ user->authorise('core.edit', 'com_ " . $component . " . " . $viewName_single . " .' . (int) \$ recordId); " ;
2016-02-26 00:20:09 +00:00
}
2016-12-22 21:32:13 +00:00
$allow [] = " \t \t \t if (! \$ permission) " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t { " ;
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit.own' ]) && isset ( $this -> permissionBuilder [ $core [ 'core.edit.own' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $core [ 'core.edit.own' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ $core [ 'core.edit.own' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \t if ( \$ user->authorise(' " . $core [ 'core.edit.own' ] . " ', 'com_ " . $component . " . " . $viewName_single . " .' . \$ recordId)) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \t if ( \$ user->authorise('core.edit.own', 'com_ " . $component . " . " . $viewName_single . " .' . \$ recordId)) " ;
2016-02-26 00:20:09 +00:00
}
$allow [] = " \t \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Now test the owner is the user. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \t \t \$ ownerId = (int) isset( \$ data['created_by']) ? \$ data['created_by'] : 0; " ;
$allow [] = " \t \t \t \t \t if (empty( \$ ownerId)) " ;
$allow [] = " \t \t \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Need to do a lookup from the model. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \t \t \t \$ record = \$ this->getModel()->getItem( \$ recordId); " ;
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t \t \t \t \t if (empty( \$ record)) " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \t \t \t { " ;
$allow [] = " \t \t \t \t \t \t \t return false; " ;
$allow [] = " \t \t \t \t \t \t } " ;
$allow [] = " \t \t \t \t \t \t \$ ownerId = \$ record->created_by; " ;
$allow [] = " \t \t \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " If the owner matches 'me' then allow. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \t \t if ( \$ ownerId == \$ user->id) " ;
$allow [] = " \t \t \t \t \t { " ;
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit.own' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.own' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.own' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.own' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \t \t \t if ( \$ user->authorise(' " . $core [ 'core.edit.own' ] . " ', 'com_ " . $component . " ')) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \t \t \t if ( \$ user->authorise('core.edit.own', 'com_ " . $component . " ')) " ;
2016-02-26 00:20:09 +00:00
}
$allow [] = " \t \t \t \t \t \t { " ;
$allow [] = " \t \t \t \t \t \t \t return true; " ;
$allow [] = " \t \t \t \t \t \t } " ;
$allow [] = " \t \t \t \t \t } " ;
$allow [] = " \t \t \t \t } " ;
$allow [] = " \t \t \t \t return false; " ;
$allow [] = " \t \t \t } " ;
$allow [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Since there is no permission, revert to the component permissions. " ;
$allow [] = " \t \t return \$ user->authorise(' " . $core [ 'core.edit' ] . " ', \$ this->option); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Since there is no permission, revert to the component permissions. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t return parent::allowEdit( \$ data, \$ key); " ;
}
}
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $allow );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
public function setJmodelAdminGetForm ( $viewName_single , $viewName_list )
2016-02-26 00:20:09 +00:00
{
// set component name
$component = ComponentbuilderHelper :: safeString ( $this -> componentData -> name_code );
// allways load these
$allow = array ();
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get the form. " ;
$allow [] = " \t \t \$ form = \$ this->loadForm('com_ " . $component . " . " . $viewName_single . " ', ' " . $viewName_single . " ', array('control' => 'jform', 'load_data' => \$ loadData)); " ;
$allow [] = PHP_EOL . " \t \t if (empty( \$ form)) " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t { " ;
$allow [] = " \t \t \t return false; " ;
$allow [] = " \t \t } " ;
2016-11-22 17:08:17 +00:00
// load license locker
if ( $this -> componentData -> add_license && $this -> componentData -> license_type == 3 && isset ( $this -> fileContentDynamic [ $viewName_single ][ '###BOOLMETHOD###' ]))
{
$allow [] = $this -> checkStatmentLicenseLocked ( $this -> fileContentDynamic [ $viewName_single ][ '###BOOLMETHOD###' ]);
}
2016-02-26 00:20:09 +00:00
// setup correct core target
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $viewName_single ]))
{
$core = $this -> permissionCore [ $viewName_single ];
$coreLoad = true ;
}
2017-12-14 23:10:47 +00:00
if ( 0 ) //isset($this->categoryBuilder[$viewName_list]) && ComponentbuilderHelper::checkArray($this->categoryBuilder[$viewName_list])) <-- remove category from check
2017-02-09 16:11:10 +00:00
{
2016-02-26 00:20:09 +00:00
// check if category has another name
if ( $coreLoad && isset ( $this -> catOtherName [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> catOtherName [ $viewName_list ]))
{
$otherViews = $this -> catOtherName [ $viewName_list ][ 'views' ];
$otherView = $this -> catOtherName [ $viewName_list ][ 'view' ];
}
else
{
$otherViews = $viewName_list ;
$otherView = $viewName_single ;
}
// setup the category script
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t \$ jinput = JFactory::getApplication()->input; " ;
$allow [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t if ( \$ jinput->get('a_id')) " ;
$allow [] = " \t \t { " ;
$allow [] = " \t \t \t \$ id = \$ jinput->get('a_id', 0, 'INT'); " ;
$allow [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " The back end uses id so we use that the rest of the time and set it to 0 by default. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t else " ;
$allow [] = " \t \t { " ;
$allow [] = " \t \t \t \$ id = \$ jinput->get('id', 0, 'INT'); " ;
$allow [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Determine correct permissions to check. " ;
$allow [] = " \t \t if ( \$ this->getState(' " . $viewName_single . " .id')) " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \$ id = \$ this->getState(' " . $viewName_single . " .id'); " ;
$allow [] = PHP_EOL . " \t \t \t \$ catid = 0; " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t if (isset( \$ this->getItem( \$ id)->catid)) " ;
$allow [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " set category id " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \t \$ catid = \$ this->getItem( \$ id)->catid; " ;
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Existing record. Can only edit in selected categories. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \t \$ form->setFieldAttribute('catid', 'action', 'core.edit'); " ;
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Existing record. Can only edit own items in selected categories. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \t \$ form->setFieldAttribute('catid', 'action', 'core.edit.own'); " ;
$allow [] = " \t \t \t } " ;
$allow [] = " \t \t } " ;
$allow [] = " \t \t else " ;
$allow [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " New record. Can only create in selected categories. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \$ form->setFieldAttribute('catid', 'action', 'core.create'); " ;
$allow [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t \$ user = JFactory::getUser(); " ;
$allow [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Check for existing item. " ;
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Modify the form based on Edit State access controls. " ;
2016-02-26 00:20:09 +00:00
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit.state' ]) && isset ( $this -> permissionBuilder [ $core [ 'core.edit.state' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $core [ 'core.edit.state' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ $core [ 'core.edit.state' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t if ( \$ id != 0 && (! \$ user->authorise(' " . $core [ 'core.edit.state' ] . " ', 'com_ " . $component . " . " . $viewName_single . " .' . (int) \$ id)) " ;
$allow [] = " \t \t \t || (isset( \$ catid) && \$ catid != 0 && ! \$ user->authorise('core.edit.state', 'com_ " . $component . " . " . $viewName_list . " .category.' . (int) \$ catid)) " ;
$allow [] = " \t \t \t || ( \$ id == 0 && ! \$ user->authorise(' " . $core [ 'core.edit.state' ] . " ', 'com_ " . $component . " '))) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t if ( \$ id != 0 && (! \$ user->authorise('core.edit.state', 'com_ " . $component . " . " . $viewName_single . " .' . (int) \$ id)) " ;
$allow [] = " \t \t \t || (isset( \$ catid) && \$ catid != 0 && ! \$ user->authorise('core.edit.state', 'com_ " . $component . " . " . $viewName_list . " .category.' . (int) \$ catid)) " ;
$allow [] = " \t \t \t || ( \$ id == 0 && ! \$ user->authorise('core.edit.state', 'com_ " . $component . " '))) " ;
2016-02-26 00:20:09 +00:00
}
$allow [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Disable fields for display. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \$ form->setFieldAttribute('ordering', 'disabled', 'true'); " ;
$allow [] = " \t \t \t \$ form->setFieldAttribute('published', 'disabled', 'true'); " ;
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Disable fields while saving. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \$ form->setFieldAttribute('ordering', 'filter', 'unset'); " ;
$allow [] = " \t \t \t \$ form->setFieldAttribute('published', 'filter', 'unset'); " ;
$allow [] = " \t \t } " ;
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t \$ jinput = JFactory::getApplication()->input; " ;
$allow [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t if ( \$ jinput->get('a_id')) " ;
$allow [] = " \t \t { " ;
$allow [] = " \t \t \t \$ id = \$ jinput->get('a_id', 0, 'INT'); " ;
$allow [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " The back end uses id so we use that the rest of the time and set it to 0 by default. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t else " ;
$allow [] = " \t \t { " ;
$allow [] = " \t \t \t \$ id = \$ jinput->get('id', 0, 'INT'); " ;
$allow [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t \$ user = JFactory::getUser(); " ;
$allow [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Check for existing item. " ;
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Modify the form based on Edit State access controls. " ;
2016-02-26 00:20:09 +00:00
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit.state' ]) && isset ( $this -> permissionBuilder [ $core [ 'core.edit.state' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $core [ 'core.edit.state' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ $core [ 'core.edit.state' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t if ( \$ id != 0 && (! \$ user->authorise(' " . $core [ 'core.edit.state' ] . " ', 'com_ " . $component . " . " . $viewName_single . " .' . (int) \$ id)) " ;
$allow [] = " \t \t \t || ( \$ id == 0 && ! \$ user->authorise(' " . $core [ 'core.edit.state' ] . " ', 'com_ " . $component . " '))) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t if ( \$ id != 0 && (! \$ user->authorise('core.edit.state', 'com_ " . $component . " . " . $viewName_single . " .' . (int) \$ id)) " ;
$allow [] = " \t \t \t || ( \$ id == 0 && ! \$ user->authorise('core.edit.state', 'com_ " . $component . " '))) " ;
2016-02-26 00:20:09 +00:00
}
$allow [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Disable fields for display. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \$ form->setFieldAttribute('ordering', 'disabled', 'true'); " ;
$allow [] = " \t \t \t \$ form->setFieldAttribute('published', 'disabled', 'true'); " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Disable fields while saving. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \$ form->setFieldAttribute('ordering', 'filter', 'unset'); " ;
$allow [] = " \t \t \t \$ form->setFieldAttribute('published', 'filter', 'unset'); " ;
$allow [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
}
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " If this is a new item insure the greated by is set. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t if (0 == \$ id) " ;
$allow [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Set the created_by to this user " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \$ form->setValue('created_by', null, \$ user->id); " ;
$allow [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Modify the form based on Edit Creaded By access controls. " ;
2016-02-26 00:20:09 +00:00
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit.created_by' ]) && isset ( $this -> permissionBuilder [ $core [ 'core.edit.created_by' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $core [ 'core.edit.created_by' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ $core [ 'core.edit.created_by' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t if ( \$ id != 0 && (! \$ user->authorise(' " . $core [ 'core.edit.created_by' ] . " ', 'com_ " . $component . " . " . $viewName_single . " .' . (int) \$ id)) " ;
$allow [] = " \t \t \t || ( \$ id == 0 && ! \$ user->authorise(' " . $core [ 'core.edit.created_by' ] . " ', 'com_ " . $component . " '))) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t if (! \$ user->authorise('core.edit.created_by', 'com_ " . $component . " ')) " ;
2016-02-26 00:20:09 +00:00
}
$allow [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Disable fields for display. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \$ form->setFieldAttribute('created_by', 'disabled', 'true'); " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Disable fields for display. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \$ form->setFieldAttribute('created_by', 'readonly', 'true'); " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Disable fields while saving. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \$ form->setFieldAttribute('created_by', 'filter', 'unset'); " ;
$allow [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Modify the form based on Edit Creaded Date access controls. " ;
2016-02-26 00:20:09 +00:00
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit.created' ]) && isset ( $this -> permissionBuilder [ $core [ 'core.edit.created' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $core [ 'core.edit.created' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ $core [ 'core.edit.created' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t if ( \$ id != 0 && (! \$ user->authorise(' " . $core [ 'core.edit.created' ] . " ', 'com_ " . $component . " . " . $viewName_single . " .' . (int) \$ id)) " ;
$allow [] = " \t \t \t || ( \$ id == 0 && ! \$ user->authorise(' " . $core [ 'core.edit.created' ] . " ', 'com_ " . $component . " '))) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t if (! \$ user->authorise('core.edit.created', 'com_ " . $component . " ')) " ;
2016-02-26 00:20:09 +00:00
}
$allow [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Disable fields for display. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \$ form->setFieldAttribute('created', 'disabled', 'true'); " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Disable fields while saving. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \$ form->setFieldAttribute('created', 'filter', 'unset'); " ;
$allow [] = " \t \t } " ;
// handel the fields permissions
if ( isset ( $this -> permissionFields [ $viewName_single ]) && ComponentbuilderHelper :: checkArray ( $this -> permissionFields [ $viewName_single ]))
{
foreach ( $this -> permissionFields [ $viewName_single ] as $fieldName => $fieldType )
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Modify the form based on Edit " . ComponentbuilderHelper :: safeString ( $fieldName , 'W' ) . " access controls. " ;
$allow [] = " \t \t if ( \$ id != 0 && (! \$ user->authorise(' " . $viewName_single . " .edit. " . $fieldName . " ', 'com_ " . $component . " . " . $viewName_single . " .' . (int) \$ id)) " ;
$allow [] = " \t \t \t || ( \$ id == 0 && ! \$ user->authorise(' " . $viewName_single . " .edit. " . $fieldName . " ', 'com_ " . $component . " '))) " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Disable fields for display. " ;
$allow [] = " \t \t \t \$ form->setFieldAttribute(' " . $fieldName . " ', 'disabled', 'true'); " ;
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Disable fields for display. " ;
$allow [] = " \t \t \t \$ form->setFieldAttribute(' " . $fieldName . " ', 'readonly', 'true'); " ;
2017-02-02 11:54:07 +00:00
if ( 'radio' === $fieldType || 'repeatable' === $fieldType )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Disable radio button for display. " ;
$allow [] = " \t \t \t \$ class = \$ form->getFieldAttribute(' " . $fieldName . " ', 'class', ''); " ;
$allow [] = " \t \t \t \$ form->setFieldAttribute(' " . $fieldName . " ', 'class', \$ class.' disabled no-click'); " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t if (! \$ form->getValue(' " . $fieldName . " ')) " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Disable fields while saving. " ;
$allow [] = " \t \t \t \t \$ form->setFieldAttribute(' " . $fieldName . " ', 'filter', 'unset'); " ;
$allow [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Disable fields while saving. " ;
$allow [] = " \t \t \t \t \$ form->setFieldAttribute(' " . $fieldName . " ', 'required', 'false'); " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t } " ;
$allow [] = " \t \t } " ;
}
}
// add the redirect trick to set the field of origin
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Only load these values if no id is found " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t if (0 == \$ id) " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t { " ;
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Set redirected field name " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \$ redirectedField = \$ jinput->get('ref', null, 'STRING'); " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Set redirected field value " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \$ redirectedValue = \$ jinput->get('refid', 0, 'INT'); " ;
$allow [] = " \t \t \t if (0 != \$ redirectedValue && \$ redirectedField) " ;
$allow [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Now set the local-redirected field default value " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t \t \$ form->setValue( \$ redirectedField, null, \$ redirectedValue); " ;
$allow [] = " \t \t \t } " ;
$allow [] = " \t \t } " ;
// setup the default script
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t return \$ form; " ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $allow );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
public function setJmodelAdminAllowEdit ( $viewName_single , $viewName_list )
2016-02-26 00:20:09 +00:00
{
$allow = array ();
// set component name
$component = ComponentbuilderHelper :: safeString ( $this -> componentData -> name_code );
// prepare custom permission script
2017-12-14 23:10:47 +00:00
$customAllow = $this -> getCustomScriptBuilder ( 'php_allowedit' , $viewName_single , " \t \t \$ recordId \t = (int) isset( \$ data[ \$ key]) ? \$ data[ \$ key] : 0; " . PHP_EOL );
2016-02-26 00:20:09 +00:00
// setup correct core target
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $viewName_single ]))
{
$core = $this -> permissionCore [ $viewName_single ];
$coreLoad = true ;
}
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit' ]) && isset ( $this -> permissionBuilder [ $core [ 'core.edit' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $core [ 'core.edit' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ $core [ 'core.edit' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Check specific edit permission then general edit permission. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \$ user = JFactory::getUser(); " ;
// load custom permission script
$allow [] = $customAllow ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t return \$ user->authorise(' " . $core [ 'core.edit' ] . " ', 'com_ " . $component . " . " . $viewName_single . " .'. ((int) isset( \$ data[ \$ key]) ? \$ data[ \$ key] : 0)) or \$ user->authorise(' " . $core [ 'core.edit' ] . " ', 'com_ " . $component . " '); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Check specific edit permission then general edit permission. " ;
2016-02-26 00:20:09 +00:00
if ( ComponentbuilderHelper :: checkString ( $customAllow ))
{
$allow [] = " \t \t \$ user = JFactory::getUser(); " ;
}
// load custom permission script
$allow [] = $customAllow ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t return JFactory::getUser()->authorise('core.edit', 'com_ " . $component . " . " . $viewName_single . " .'. ((int) isset( \$ data[ \$ key]) ? \$ data[ \$ key] : 0)) or parent::allowEdit( \$ data, \$ key); " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $allow );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
public function setJmodelAdminCanDelete ( $viewName_single , $viewName_list )
2016-02-26 00:20:09 +00:00
{
$allow = array ();
// set component name
$component = ComponentbuilderHelper :: safeString ( $this -> componentData -> name_code );
// setup correct core target
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $viewName_single ]))
{
$core = $this -> permissionCore [ $viewName_single ];
$coreLoad = true ;
}
2017-12-14 23:10:47 +00:00
if ( 0 ) //isset($this->categoryBuilder[$viewName_list]) && ComponentbuilderHelper::checkArray($this->categoryBuilder[$viewName_list])) <-- remove category from check
2017-02-09 16:11:10 +00:00
{
2016-02-26 00:20:09 +00:00
// check if category has another name
if ( $coreLoad && isset ( $this -> catOtherName [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> catOtherName [ $viewName_list ]))
{
$otherViews = $this -> catOtherName [ $viewName_list ][ 'views' ];
$otherView = $this -> catOtherName [ $viewName_list ][ 'view' ];
}
else
{
$otherViews = $viewName_list ;
$otherView = $viewName_single ;
}
// setup the category script
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t if (!empty( \$ record->id)) " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t { " ;
$allow [] = " \t \t \t if ( \$ record->published != -2) " ;
$allow [] = " \t \t \t { " ;
$allow [] = " \t \t \t \t return; " ;
$allow [] = " \t \t \t } " ;
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t \t \$ user = JFactory::getUser(); " ;
$allow [] = " \t \t \t \$ allow = \$ user->authorise('core.delete', 'com_ " . $component . " . " . $otherViews . " .category.' . (int) \$ record->catid); " ;
2016-02-26 00:20:09 +00:00
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $this -> permissionBuilder [ $core [ 'core.delete' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $core [ 'core.delete' ]]) && in_array ( $otherView , $this -> permissionBuilder [ $core [ 'core.delete' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t \t if ( \$ allow) " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " The record has been set. Check the record permissions. " ;
$allow [] = " \t \t \t \t return \$ user->authorise(' " . $core [ 'core.delete' ] . " ', 'com_ " . $component . " . " . $otherView . " .' . (int) \$ record->id); " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t } " ;
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t \t if ( \$ allow) " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " The record has been set. Check the record permissions. " ;
$allow [] = " \t \t \t \t return \$ user->authorise('core.delete', 'com_ " . $component . " . " . $otherView . " .' . (int) \$ record->id); " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t } " ;
}
$allow [] = " \t \t \t return \$ allow; " ;
$allow [] = " \t \t } " ;
$allow [] = " \t \t return false; " ;
}
else
{
// setup the default script
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t if (!empty( \$ record->id)) " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t { " ;
$allow [] = " \t \t \t if ( \$ record->published != -2) " ;
$allow [] = " \t \t \t { " ;
$allow [] = " \t \t \t \t return; " ;
$allow [] = " \t \t \t } " ;
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && ( isset ( $core [ 'core.delete' ]) && isset ( $this -> permissionBuilder [ $core [ 'core.delete' ]])) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $core [ 'core.delete' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ $core [ 'core.delete' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t \t \$ user = JFactory::getUser(); " ;
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " The record has been set. Check the record permissions. " ;
$allow [] = " \t \t \t return \$ user->authorise(' " . $core [ 'core.delete' ] . " ', 'com_ " . $component . " . " . $viewName_single . " .' . (int) \$ record->id); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t \t \$ user = JFactory::getUser(); " ;
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " The record has been set. Check the record permissions. " ;
$allow [] = " \t \t \t return \$ user->authorise('core.delete', 'com_ " . $component . " . " . $viewName_single . " .' . (int) \$ record->id); " ;
2016-02-26 00:20:09 +00:00
}
$allow [] = " \t \t } " ;
$allow [] = " \t \t return false; " ;
}
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $allow );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
public function setJmodelAdminCanEditState ( $viewName_single , $viewName_list )
2016-02-26 00:20:09 +00:00
{
$allow = array ();
// set component name
$component = ComponentbuilderHelper :: safeString ( $this -> componentData -> name_code );
// setup correct core target
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $viewName_single ]))
{
$core = $this -> permissionCore [ $viewName_single ];
$coreLoad = true ;
}
2017-12-14 23:10:47 +00:00
if ( 0 ) // isset($this->categoryBuilder[$viewName_list]) && ComponentbuilderHelper::checkArray($this->categoryBuilder[$viewName_list])) <-- remove category from check
2017-02-09 16:11:10 +00:00
{
2016-02-26 00:20:09 +00:00
// check if category has another name
if ( isset ( $this -> catOtherName [ $viewName_list ]) && ComponentbuilderHelper :: checkArray ( $this -> catOtherName [ $viewName_list ]))
{
$otherViews = $this -> catOtherName [ $viewName_list ][ 'views' ];
$otherView = $this -> catOtherName [ $viewName_list ][ 'view' ];
}
else
{
$otherViews = $viewName_list ;
$otherView = $viewName_single ;
}
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t \$ user = JFactory::getUser(); " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \$ recordId \t = (!empty( \$ record->id)) ? \$ record->id : 0; " ;
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t if ( \$ recordId) " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " The record has been set. Check the record permissions. " ;
2016-02-26 00:20:09 +00:00
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit.state' ]) && isset ( $this -> permissionBuilder [ $core [ 'core.edit.state' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $core [ 'core.edit.state' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ $core [ 'core.edit.state' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \$ permission = \$ user->authorise(' " . $core [ 'core.edit.state' ] . " ', 'com_ " . $component . " . " . $viewName_single . " .' . (int) \$ recordId); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \$ permission = \$ user->authorise('core.edit.state', 'com_ " . $component . " . " . $viewName_single . " .' . (int) \$ recordId); " ;
2016-02-26 00:20:09 +00:00
}
$allow [] = " \t \t \t if (! \$ permission && !is_null( \$ permission)) " ;
$allow [] = " \t \t \t { " ;
$allow [] = " \t \t \t \t return false; " ;
$allow [] = " \t \t \t } " ;
$allow [] = " \t \t } " ;
// setup the category script
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " Check against the category. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t if (!empty( \$ record->catid)) " ;
$allow [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \$ catpermission = \$ user->authorise('core.edit.state', 'com_ " . $component . " . " . $otherViews . " .category.' . (int) \$ record->catid); " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \t if (! \$ catpermission && !is_null( \$ catpermission)) " ;
$allow [] = " \t \t \t { " ;
$allow [] = " \t \t \t \t return false; " ;
$allow [] = " \t \t \t } " ;
$allow [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit.state' ]) && isset ( $this -> permissionBuilder [ $core [ 'core.edit.state' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $core [ 'core.edit.state' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ $core [ 'core.edit.state' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " In the absense of better information, revert to the component permissions. " ;
$allow [] = " \t \t return \$ user->authorise(' " . $core [ 'core.edit.state' ] . " ', 'com_ " . $component . " '); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " In the absense of better information, revert to the component permissions. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t return parent::canEditState( \$ record); " ;
}
}
else
{
// setup the default script
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t \$ user = JFactory::getUser(); " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t \$ recordId \t = (!empty( \$ record->id)) ? \$ record->id : 0; " ;
2017-12-14 23:10:47 +00:00
$allow [] = PHP_EOL . " \t \t if ( \$ recordId) " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t { " ;
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t // " . $this -> setLine ( __LINE__ ) . " The record has been set. Check the record permissions. " ;
2016-02-26 00:20:09 +00:00
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit.state' ]) && isset ( $this -> permissionBuilder [ $core [ 'core.edit.state' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $core [ 'core.edit.state' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ $core [ 'core.edit.state' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \$ permission = \$ user->authorise(' " . $core [ 'core.edit.state' ] . " ', 'com_ " . $component . " . " . $viewName_single . " .' . (int) \$ recordId); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t \t \$ permission = \$ user->authorise('core.edit.state', 'com_ " . $component . " . " . $viewName_single . " .' . (int) \$ recordId); " ;
2016-02-26 00:20:09 +00:00
}
$allow [] = " \t \t \t if (! \$ permission && !is_null( \$ permission)) " ;
$allow [] = " \t \t \t { " ;
$allow [] = " \t \t \t \t return false; " ;
$allow [] = " \t \t \t } " ;
$allow [] = " \t \t } " ;
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit.state' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.state' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.state' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.state' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " In the absense of better information, revert to the component permissions. " ;
$allow [] = " \t \t return \$ user->authorise(' " . $core [ 'core.edit.state' ] . " ', 'com_ " . $component . " '); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$allow [] = " \t \t // " . $this -> setLine ( __LINE__ ) . " In the absense of better information, revert to the component permissions. " ;
2016-02-26 00:20:09 +00:00
$allow [] = " \t \t return parent::canEditState( \$ record); " ;
}
}
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $allow );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
public function setJviewListCanDo ( $viewName_single , $viewName_list )
2016-02-26 00:20:09 +00:00
{
$allow = array ();
// set component name
$component = ComponentbuilderHelper :: safeString ( $this -> componentData -> name_code );
// setup correct core target
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $viewName_single ]))
{
$core = $this -> permissionCore [ $viewName_single ];
$coreLoad = true ;
}
// check if the item has permissions for edit.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-15 01:10:10 +00:00
$allow [] = PHP_EOL . " \t \t \$ this->canEdit = \$ this->canDo->get(' " . $core [ 'core.edit' ] . " '); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-15 01:10:10 +00:00
$allow [] = PHP_EOL . " \t \t \$ this->canEdit = \$ this->canDo->get('core.edit'); " ;
2016-02-26 00:20:09 +00:00
}
// check if the item has permissions for edit state.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.edit.state' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.state' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.state' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit.state' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-15 01:10:10 +00:00
$allow [] = " \t \t \$ this->canState = \$ this->canDo->get(' " . $core [ 'core.edit.state' ] . " '); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-15 01:10:10 +00:00
$allow [] = " \t \t \$ this->canState = \$ this->canDo->get('core.edit.state'); " ;
2016-02-26 00:20:09 +00:00
}
// check if the item has permissions for create.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.create' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-15 01:10:10 +00:00
$allow [] = " \t \t \$ this->canCreate = \$ this->canDo->get(' " . $core [ 'core.create' ] . " '); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-15 01:10:10 +00:00
$allow [] = " \t \t \$ this->canCreate = \$ this->canDo->get('core.create'); " ;
2016-02-26 00:20:09 +00:00
}
// check if the item has permissions for delete.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.delete' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.delete' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.delete' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ $core [ 'core.delete' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-15 01:10:10 +00:00
$allow [] = " \t \t \$ this->canDelete = \$ this->canDo->get(' " . $core [ 'core.delete' ] . " '); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-15 01:10:10 +00:00
$allow [] = " \t \t \$ this->canDelete = \$ this->canDo->get('core.delete'); " ;
2016-02-26 00:20:09 +00:00
}
// check if the item has permissions for batch.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.batch' ]) && isset ( $this -> permissionBuilder [ 'global' ][ 'global' ][ $core [ 'core.batch' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ 'global' ][ $core [ 'core.batch' ]]) && in_array ( $viewName_single , $this -> permissionBuilder [ 'global' ][ 'global' ][ $core [ 'core.delete' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-15 01:10:10 +00:00
$allow [] = " \t \t \$ this->canBatch = ( \$ this->canDo->get(' " . $core [ 'core.batch' ] . " ') && \$ this->canDo->get('core.batch')); " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-15 01:10:10 +00:00
$allow [] = " \t \t \$ this->canBatch = \$ this->canDo->get('core.batch'); " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
return implode ( PHP_EOL , $allow );
2016-02-26 00:20:09 +00:00
}
2016-09-11 15:27:04 +00:00
public function setFieldSetAccessControl ( & $view )
2016-02-26 00:20:09 +00:00
{
$access = '' ;
if ( $view != 'component' )
{
// set component name
$component = ComponentbuilderHelper :: safeString ( $this -> componentData -> name_code );
// set label
2017-12-14 23:10:47 +00:00
$label = 'Permissions in relation to this ' . $view ;
2016-02-26 00:20:09 +00:00
// set the access fieldset
2017-12-14 23:10:47 +00:00
$access = " <!-- " . $this -> setLine ( __LINE__ ) . " Access Control Fields. --> " ;
$access .= PHP_EOL . " \t " . '<fieldset name="accesscontrol">' ;
$access .= PHP_EOL . " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Asset Id Field. Type: Hidden (joomla) --> " ;
$access .= PHP_EOL . " \t \t " . '<field' ;
$access .= PHP_EOL . " \t \t \t " . 'name="asset_id"' ;
$access .= PHP_EOL . " \t \t \t " . 'type="hidden"' ;
$access .= PHP_EOL . " \t \t \t " . 'filter="unset"' ;
$access .= PHP_EOL . " \t \t " . '/>' ;
$access .= PHP_EOL . " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Rules Field. Type: Rules (joomla) --> " ;
$access .= PHP_EOL . " \t \t " . '<field' ;
$access .= PHP_EOL . " \t \t \t " . 'name="rules"' ;
$access .= PHP_EOL . " \t \t \t " . 'type="rules"' ;
$access .= PHP_EOL . " \t \t \t " . 'label="' . $label . '"' ;
$access .= PHP_EOL . " \t \t \t " . 'translate_label="false"' ;
$access .= PHP_EOL . " \t \t \t " . 'filter="rules"' ;
$access .= PHP_EOL . " \t \t \t " . 'validate="rules"' ;
$access .= PHP_EOL . " \t \t \t " . 'class="inputbox"' ;
$access .= PHP_EOL . " \t \t \t " . 'component="com_' . $component . '"' ;
$access .= PHP_EOL . " \t \t \t " . 'section="' . $view . '"' ;
$access .= PHP_EOL . " \t \t " . '/>' ;
$access .= PHP_EOL . " \t " . '</fieldset>' ;
2016-02-26 00:20:09 +00:00
}
// return access field set
return $access ;
}
2016-09-11 15:27:04 +00:00
public function setFilterFields ( & $view )
2016-02-26 00:20:09 +00:00
{
// keep track of all fields already added
2017-12-14 23:10:47 +00:00
$donelist = array ( 'id' , 'search' , 'published' , 'access' , 'created_by' , 'modified_by' );
2016-02-26 00:20:09 +00:00
// default filter fields
$fields = " 'a.id','id' " ;
2017-12-14 23:10:47 +00:00
$fields .= " , " . PHP_EOL . " \t \t \t \t 'a.published','published' " ;
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> accessBuilder [ $view ]) && ComponentbuilderHelper :: checkString ( $this -> accessBuilder [ $view ]))
{
2017-12-14 23:10:47 +00:00
$fields .= " , " . PHP_EOL . " \t \t \t \t 'a.access','access' " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$fields .= " , " . PHP_EOL . " \t \t \t \t 'a.ordering','ordering' " ;
$fields .= " , " . PHP_EOL . " \t \t \t \t 'a.created_by','created_by' " ;
$fields .= " , " . PHP_EOL . " \t \t \t \t 'a.modified_by','modified_by' " ;
2016-02-26 00:20:09 +00:00
// add the rest of the set filters
if ( isset ( $this -> sortBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> sortBuilder [ $view ]))
{
foreach ( $this -> sortBuilder [ $view ] as $filter )
{
2017-12-14 23:10:47 +00:00
if ( ! in_array ( $filter [ 'code' ], $donelist ))
2016-02-26 00:20:09 +00:00
{
2017-02-01 13:17:04 +00:00
if ( $filter [ 'type' ] === 'category' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$fields .= " , " . PHP_EOL . " \t \t \t \t 'c.title','category_title' " ;
$fields .= " , " . PHP_EOL . " \t \t \t \t 'c.id', 'category_id' " ;
2016-02-26 00:20:09 +00:00
if ( $filter [ 'code' ] != 'category' )
{
2017-12-14 23:10:47 +00:00
$fields .= " , " . PHP_EOL . " \t \t \t \t 'a. " . $filter [ 'code' ] . " ', ' " . $filter [ 'code' ] . " ' " ;
2016-02-26 00:20:09 +00:00
}
}
else
{
// check if custom field is set
2017-12-14 23:10:47 +00:00
/* if ( ComponentbuilderHelper :: checkArray ( $filter [ 'custom' ]))
{
$fields .= " , " . PHP_EOL . " \t \t \t \t ' " . $filter [ 'custom' ][ 'db' ] . " . " . $filter [ 'custom' ][ 'text' ] . " ',' " . $filter [ 'code' ] . " _ " . $filter [ 'custom' ][ 'text' ] . " ' " ;
} */
$fields .= " , " . PHP_EOL . " \t \t \t \t 'a. " . $filter [ 'code' ] . " ',' " . $filter [ 'code' ] . " ' " ;
2016-02-26 00:20:09 +00:00
}
$donelist [] = $filter [ 'code' ];
}
}
}
// add the rest of the set filters
if ( isset ( $this -> filterBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> filterBuilder [ $view ]))
{
foreach ( $this -> filterBuilder [ $view ] as $filter )
{
2017-12-14 23:10:47 +00:00
if ( ! in_array ( $filter [ 'code' ], $donelist ))
2016-02-26 00:20:09 +00:00
{
2017-02-01 13:17:04 +00:00
if ( $filter [ 'type' ] === 'category' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$fields .= " , " . PHP_EOL . " \t \t \t \t 'c.title','category_title' " ;
$fields .= " , " . PHP_EOL . " \t \t \t \t 'c.id', 'category_id' " ;
2016-02-26 00:20:09 +00:00
if ( $filter [ 'code' ] != 'category' )
{
2017-12-14 23:10:47 +00:00
$fields .= " , " . PHP_EOL . " \t \t \t \t 'a. " . $filter [ 'code' ] . " ', ' " . $filter [ 'code' ] . " ' " ;
2016-02-26 00:20:09 +00:00
}
}
else
{
// check if custom field is set
2017-12-14 23:10:47 +00:00
/* if ( ComponentbuilderHelper :: checkArray ( $filter [ 'custom' ]))
{
$fields .= " , " . PHP_EOL . " \t \t \t \t ' " . $filter [ 'custom' ][ 'db' ] . " . " . $filter [ 'custom' ][ 'text' ] . " ',' " . $filter [ 'code' ] . " _ " . $filter [ 'custom' ][ 'text' ] . " ' " ;
} */
$fields .= " , " . PHP_EOL . " \t \t \t \t 'a. " . $filter [ 'code' ] . " ',' " . $filter [ 'code' ] . " ' " ;
2016-02-26 00:20:09 +00:00
}
$donelist [] = $filter [ 'code' ];
}
}
}
return $fields ;
}
2016-09-11 15:27:04 +00:00
public function setStoredId ( & $view )
2016-02-26 00:20:09 +00:00
{
// keep track of all fields already added
2017-12-14 23:10:47 +00:00
$donelist = array ( 'id' , 'search' , 'published' , 'access' , 'created_by' , 'modified_by' );
2016-02-26 00:20:09 +00:00
// set the defaults first
2017-12-14 23:10:47 +00:00
$stored = " // " . $this -> setLine ( __LINE__ ) . " Compile the store id. " ;
$stored .= PHP_EOL . " \t \t \$ id .= ':' . \$ this->getState('filter.id'); " ;
$stored .= PHP_EOL . " \t \t \$ id .= ':' . \$ this->getState('filter.search'); " ;
$stored .= PHP_EOL . " \t \t \$ id .= ':' . \$ this->getState('filter.published'); " ;
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> accessBuilder [ $view ]) && ComponentbuilderHelper :: checkString ( $this -> accessBuilder [ $view ]))
{
2017-12-14 23:10:47 +00:00
$stored .= PHP_EOL . " \t \t \$ id .= ':' . \$ this->getState('filter.access'); " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$stored .= PHP_EOL . " \t \t \$ id .= ':' . \$ this->getState('filter.ordering'); " ;
$stored .= PHP_EOL . " \t \t \$ id .= ':' . \$ this->getState('filter.created_by'); " ;
$stored .= PHP_EOL . " \t \t \$ id .= ':' . \$ this->getState('filter.modified_by'); " ;
2016-02-26 00:20:09 +00:00
// add the rest of the set filters
if ( isset ( $this -> sortBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> sortBuilder [ $view ]))
{
foreach ( $this -> sortBuilder [ $view ] as $filter )
{
2017-12-14 23:10:47 +00:00
if ( ! in_array ( $filter [ 'code' ], $donelist ))
2016-02-26 00:20:09 +00:00
{
2017-02-01 13:17:04 +00:00
if ( $filter [ 'type' ] === 'category' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$stored .= PHP_EOL . " \t \t \$ id .= ':' . \$ this->getState('filter.category'); " ;
$stored .= PHP_EOL . " \t \t \$ id .= ':' . \$ this->getState('filter.category_id'); " ;
2016-02-26 00:20:09 +00:00
if ( $filter [ 'code' ] != 'category' )
{
2017-12-14 23:10:47 +00:00
$stored .= PHP_EOL . " \t \t \$ id .= ':' . \$ this->getState('filter. " . $filter [ 'code' ] . " '); " ;
2016-02-26 00:20:09 +00:00
}
}
else
{
// check if custom field is set
2017-12-14 23:10:47 +00:00
/* if ( ComponentbuilderHelper :: checkArray ( $filter [ 'custom' ]))
{
$stored .= PHP_EOL . " \t \t \$ id .= ':' . \$ this->getState('filter. " . $filter [ 'code' ] . " _ " . $filter [ 'custom' ][ 'text' ] . " '); " ;
} */
$stored .= PHP_EOL . " \t \t \$ id .= ':' . \$ this->getState('filter. " . $filter [ 'code' ] . " '); " ;
2016-02-26 00:20:09 +00:00
}
$donelist [] = $filter [ 'code' ];
}
}
}
// add the rest of the set filters
if ( isset ( $this -> filterBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> filterBuilder [ $view ]))
{
foreach ( $this -> filterBuilder [ $view ] as $filter )
{
2017-12-14 23:10:47 +00:00
if ( ! in_array ( $filter [ 'code' ], $donelist ))
2016-02-26 00:20:09 +00:00
{
2017-02-01 13:17:04 +00:00
if ( $filter [ 'type' ] === 'category' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$stored .= PHP_EOL . " \t \t \$ id .= ':' . \$ this->getState('filter.category'); " ;
$stored .= PHP_EOL . " \t \t \$ id .= ':' . \$ this->getState('filter.category_id'); " ;
2016-02-26 00:20:09 +00:00
if ( $filter [ 'code' ] != 'category' )
{
2017-12-14 23:10:47 +00:00
$stored .= PHP_EOL . " \t \t \$ id .= ':' . \$ this->getState('filter. " . $filter [ 'code' ] . " '); " ;
2016-02-26 00:20:09 +00:00
}
}
else
{
// check if custom field is set
2017-12-14 23:10:47 +00:00
/* if ( ComponentbuilderHelper :: checkArray ( $filter [ 'custom' ]))
{
$stored .= PHP_EOL . " \t \t \$ id .= ':' . \$ this->getState('filter. " . $filter [ 'code' ] . " _ " . $filter [ 'custom' ][ 'text' ] . " '); " ;
} */
$stored .= PHP_EOL . " \t \t \$ id .= ':' . \$ this->getState('filter. " . $filter [ 'code' ] . " '); " ;
2016-02-26 00:20:09 +00:00
}
$donelist [] = $filter [ 'code' ];
}
}
}
return $stored ;
}
2016-09-11 15:27:04 +00:00
public function setAddToolBar ( & $view )
2016-02-26 00:20:09 +00:00
{
// set view name
$viewName = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_single );
// setup correct core target
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $viewName ]))
{
$core = $this -> permissionCore [ $viewName ];
$coreLoad = true ;
}
// check type
if ( $view [ 'settings' ] -> type == 2 )
{
// set lang strings
2017-12-14 23:10:47 +00:00
$viewNameLang_readonly = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_single . ' readonly' , 'U' );
2016-02-26 00:20:09 +00:00
// load to lang
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $viewNameLang_readonly ] = $view [ 'settings' ] -> name_single . ' :: Readonly' ;
2016-02-26 00:20:09 +00:00
// build toolbar
$toolBar = " JFactory::getApplication()->input->set('hidemainmenu', true); " ;
2017-12-14 23:10:47 +00:00
$toolBar .= PHP_EOL . " \t \t JToolBarHelper::title(JText::_(' " . $viewNameLang_readonly . " '), ' " . $viewName . " '); " ;
$toolBar .= PHP_EOL . " \t \t JToolBarHelper::cancel(' " . $viewName . " .cancel', 'JTOOLBAR_CLOSE'); " ;
2016-02-26 00:20:09 +00:00
}
else
{
// set lang strings
2017-12-14 23:10:47 +00:00
$viewNameLang_new = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_single . ' New' , 'U' );
$viewNameLang_edit = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_single . ' Edit' , 'U' );
2016-02-26 00:20:09 +00:00
// load to lang
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $viewNameLang_new ] = 'A New ' . $view [ 'settings' ] -> name_single ;
$this -> langContent [ $this -> lang ][ $viewNameLang_edit ] = 'Editing the ' . $view [ 'settings' ] -> name_single ;
2016-02-26 00:20:09 +00:00
// build toolbar
$toolBar = " JFactory::getApplication()->input->set('hidemainmenu', true); " ;
2017-12-14 23:10:47 +00:00
$toolBar .= PHP_EOL . " \t \t \$ user = JFactory::getUser(); " ;
$toolBar .= PHP_EOL . " \t \t \$ userId = \$ user->id; " ;
$toolBar .= PHP_EOL . " \t \t \$ isNew = \$ this->item->id == 0; " ;
$toolBar .= PHP_EOL . PHP_EOL . " \t \t JToolbarHelper::title( JText::_( \$ isNew ? ' " . $viewNameLang_new . " ' : ' " . $viewNameLang_edit . " '), 'pencil-2 article-add'); " ;
$toolBar .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Built the actions for new and existing records. " ;
$toolBar .= PHP_EOL . " \t \t if ( \$ this->refid || \$ this->ref) " ;
$toolBar .= PHP_EOL . " \t \t { " ;
if ( $coreLoad && isset ( $core [ 'core.create' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && in_array ( $viewName , $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$toolBar .= PHP_EOL . " \t \t \t if ( \$ this->canDo->get(' " . $core [ 'core.create' ] . " ') && \$ isNew) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$toolBar .= PHP_EOL . " \t \t \t if ( \$ this->canDo->get('core.create') && \$ isNew) " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$toolBar .= PHP_EOL . " \t \t \t { " ;
$toolBar .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " We can create the record. " ;
$toolBar .= PHP_EOL . " \t \t \t \t JToolBarHelper::save(' " . $viewName . " .save', 'JTOOLBAR_SAVE'); " ;
$toolBar .= PHP_EOL . " \t \t \t } " ;
if ( $coreLoad && isset ( $core [ 'core.edit' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && in_array ( $viewName , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$toolBar .= PHP_EOL . " \t \t \t elseif ( \$ this->canDo->get(' " . $core [ 'core.edit' ] . " ')) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$toolBar .= PHP_EOL . " \t \t \t elseif ( \$ this->canDo->get('core.edit')) " ;
}
$toolBar .= PHP_EOL . " \t \t \t { " ;
$toolBar .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " We can save the record. " ;
$toolBar .= PHP_EOL . " \t \t \t \t JToolBarHelper::save(' " . $viewName . " .save', 'JTOOLBAR_SAVE'); " ;
$toolBar .= PHP_EOL . " \t \t \t } " ;
$toolBar .= PHP_EOL . " \t \t \t if ( \$ isNew) " ;
$toolBar .= PHP_EOL . " \t \t \t { " ;
$toolBar .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Do not creat but cancel. " ;
$toolBar .= PHP_EOL . " \t \t \t \t JToolBarHelper::cancel(' " . $viewName . " .cancel', 'JTOOLBAR_CANCEL'); " ;
$toolBar .= PHP_EOL . " \t \t \t } " ;
$toolBar .= PHP_EOL . " \t \t \t else " ;
$toolBar .= PHP_EOL . " \t \t \t { " ;
$toolBar .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " We can close it. " ;
$toolBar .= PHP_EOL . " \t \t \t \t JToolBarHelper::cancel(' " . $viewName . " .cancel', 'JTOOLBAR_CLOSE'); " ;
$toolBar .= PHP_EOL . " \t \t \t } " ;
$toolBar .= PHP_EOL . " \t \t } " ;
$toolBar .= PHP_EOL . " \t \t else " ;
$toolBar .= PHP_EOL . " \t \t { " ;
$toolBar .= PHP_EOL . " \t \t \t if ( \$ isNew) " ;
$toolBar .= PHP_EOL . " \t \t \t { " ;
$toolBar .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " For new records, check the create permission. " ;
if ( $coreLoad && isset ( $core [ 'core.create' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && in_array ( $viewName , $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]))
{
$toolBar .= PHP_EOL . " \t \t \t \t if ( \$ this->canDo->get(' " . $core [ 'core.create' ] . " ')) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$toolBar .= PHP_EOL . " \t \t \t \t if ( \$ this->canDo->get('core.create')) " ;
2017-02-09 16:11:10 +00:00
}
2017-12-14 23:10:47 +00:00
$toolBar .= PHP_EOL . " \t \t \t \t { " ;
$toolBar .= PHP_EOL . " \t \t \t \t \t JToolBarHelper::apply(' " . $viewName . " .apply', 'JTOOLBAR_APPLY'); " ;
$toolBar .= PHP_EOL . " \t \t \t \t \t JToolBarHelper::save(' " . $viewName . " .save', 'JTOOLBAR_SAVE'); " ;
$toolBar .= PHP_EOL . " \t \t \t \t \t JToolBarHelper::custom(' " . $viewName . " .save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); " ;
$toolBar .= PHP_EOL . " \t \t \t \t }; " ;
$toolBar .= PHP_EOL . " \t \t \t \t JToolBarHelper::cancel(' " . $viewName . " .cancel', 'JTOOLBAR_CANCEL'); " ;
$toolBar .= PHP_EOL . " \t \t \t } " ;
$toolBar .= PHP_EOL . " \t \t \t else " ;
$toolBar .= PHP_EOL . " \t \t \t { " ;
if ( $coreLoad && isset ( $core [ 'core.edit' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && in_array ( $viewName , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$toolBar .= PHP_EOL . " \t \t \t \t if ( \$ this->canDo->get(' " . $core [ 'core.edit' ] . " ')) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$toolBar .= PHP_EOL . " \t \t \t \t if ( \$ this->canDo->get('core.edit')) " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$toolBar .= PHP_EOL . " \t \t \t \t { " ;
$toolBar .= PHP_EOL . " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " We can save the new record " ;
$toolBar .= PHP_EOL . " \t \t \t \t \t JToolBarHelper::apply(' " . $viewName . " .apply', 'JTOOLBAR_APPLY'); " ;
$toolBar .= PHP_EOL . " \t \t \t \t \t JToolBarHelper::save(' " . $viewName . " .save', 'JTOOLBAR_SAVE'); " ;
$toolBar .= PHP_EOL . " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " We can save this record, but check the create permission to see " ;
$toolBar .= PHP_EOL . " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " if we can return to make a new one. " ;
if ( $coreLoad && isset ( $core [ 'core.create' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && in_array ( $viewName , $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$toolBar .= PHP_EOL . " \t \t \t \t \t if ( \$ this->canDo->get(' " . $core [ 'core.create' ] . " ')) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$toolBar .= PHP_EOL . " \t \t \t \t \t if ( \$ this->canDo->get('core.create')) " ;
}
$toolBar .= PHP_EOL . " \t \t \t \t \t { " ;
$toolBar .= PHP_EOL . " \t \t \t \t \t \t JToolBarHelper::custom(' " . $viewName . " .save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); " ;
$toolBar .= PHP_EOL . " \t \t \t \t \t } " ;
$toolBar .= PHP_EOL . " \t \t \t \t } " ;
if ( $coreLoad && isset ( $core [ 'core.edit' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]) && in_array ( $viewName , $this -> permissionBuilder [ 'global' ][ $core [ 'core.edit' ]]))
{
if ( $coreLoad && isset ( $this -> historyBuilder [ $viewName ]) && ComponentbuilderHelper :: checkString ( $this -> historyBuilder [ $viewName ]))
{
$toolBar .= PHP_EOL . " \t \t \t \t \$ canVersion = ( \$ this->canDo->get('core.version') && \$ this->canDo->get(' " . $core [ 'core.version' ] . " ')); " ;
$toolBar .= PHP_EOL . " \t \t \t \t if ( \$ this->state->params->get('save_history', 1) && \$ this->canDo->get(' " . $core [ 'core.edit' ] . " ') && \$ canVersion) " ;
$toolBar .= PHP_EOL . " \t \t \t \t { " ;
$toolBar .= PHP_EOL . " \t \t \t \t \t JToolbarHelper::versions('com_ " . $this -> fileContentStatic [ '###component###' ] . " . " . $viewName . " ', \$ this->item->id); " ;
$toolBar .= PHP_EOL . " \t \t \t \t } " ;
}
}
else
{
if ( $coreLoad && isset ( $this -> historyBuilder [ $viewName ]) && ComponentbuilderHelper :: checkString ( $this -> historyBuilder [ $viewName ]))
{
$toolBar .= PHP_EOL . " \t \t \t \t \$ canVersion = ( \$ this->canDo->get('core.version') && \$ this->canDo->get(' " . $core [ 'core.version' ] . " ')); " ;
$toolBar .= PHP_EOL . " \t \t \t \t if ( \$ this->state->params->get('save_history', 1) && \$ this->canDo->get('core.edit') && \$ canVersion) " ;
$toolBar .= PHP_EOL . " \t \t \t \t { " ;
$toolBar .= PHP_EOL . " \t \t \t \t \t JToolbarHelper::versions('com_ " . $this -> fileContentStatic [ '###component###' ] . " . " . $viewName . " ', \$ this->item->id); " ;
$toolBar .= PHP_EOL . " \t \t \t \t } " ;
}
}
if ( $coreLoad && isset ( $core [ 'core.create' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]) && in_array ( $viewName , $this -> permissionBuilder [ 'global' ][ $core [ 'core.create' ]]))
{
$toolBar .= PHP_EOL . " \t \t \t \t if ( \$ this->canDo->get(' " . $core [ 'core.create' ] . " ')) " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$toolBar .= PHP_EOL . " \t \t \t \t if ( \$ this->canDo->get('core.create')) " ;
}
$toolBar .= PHP_EOL . " \t \t \t \t { " ;
$toolBar .= PHP_EOL . " \t \t \t \t \t JToolBarHelper::custom(' " . $viewName . " .save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); " ;
$toolBar .= PHP_EOL . " \t \t \t \t } " ;
// add custom buttons
$toolBar .= $this -> setCustomButtons ( $view , 2 , " \t \t " );
$toolBar .= PHP_EOL . " \t \t \t \t JToolBarHelper::cancel(' " . $viewName . " .cancel', 'JTOOLBAR_CLOSE'); " ;
$toolBar .= PHP_EOL . " \t \t \t } " ;
$toolBar .= PHP_EOL . " \t \t } " ;
$toolBar .= PHP_EOL . " \t \t JToolbarHelper::divider(); " ;
$toolBar .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " set help url for this view if found " ;
$toolBar .= PHP_EOL . " \t \t \$ help_url = " . $this -> fileContentStatic [ '###Component###' ] . " Helper::getHelpUrl(' " . $viewName . " '); " ;
$toolBar .= PHP_EOL . " \t \t if ( " . $this -> fileContentStatic [ '###Component###' ] . " Helper::checkString( \$ help_url)) " ;
$toolBar .= PHP_EOL . " \t \t { " ;
$toolBar .= PHP_EOL . " \t \t \t JToolbarHelper::help(' " . $this -> langPrefix . " _HELP_MANAGER', false, \$ help_url); " ;
$toolBar .= PHP_EOL . " \t \t } " ;
2016-02-26 00:20:09 +00:00
}
return $toolBar ;
}
2016-09-11 15:27:04 +00:00
public function setPopulateState ( & $view )
2016-02-26 00:20:09 +00:00
{
// rest buket
$state = '' ;
// keep track of all fields already added
$donelist = array ();
// add the rest of the set filters
if ( isset ( $this -> sortBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> sortBuilder [ $view ]))
{
foreach ( $this -> sortBuilder [ $view ] as $filter )
{
2017-12-14 23:10:47 +00:00
if ( ! in_array ( $filter [ 'code' ], $donelist ))
2016-02-26 00:20:09 +00:00
{
2017-02-01 13:17:04 +00:00
if ( $filter [ 'type' ] === 'category' )
2016-02-26 00:20:09 +00:00
{
if ( strlen ( $state ) == 0 )
{
$spacer = " " ;
}
else
{
2017-12-14 23:10:47 +00:00
$spacer = PHP_EOL . PHP_EOL . " \t \t " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$state .= $spacer . " \$ category = \$ app->getUserStateFromRequest( \$ this->context . '.filter.category', 'filter_category'); " ;
$state .= PHP_EOL . " \t \t \$ this->setState('filter.category', \$ category); " ;
$state .= PHP_EOL . PHP_EOL . " \t \t \$ categoryId = \$ this->getUserStateFromRequest( \$ this->context . '.filter.category_id', 'filter_category_id'); " ;
$state .= PHP_EOL . " \t \t \$ this->setState('filter.category_id', \$ categoryId); " ;
2016-02-26 00:20:09 +00:00
if ( $filter [ 'code' ] != 'category' )
{
2017-12-14 23:10:47 +00:00
$state .= PHP_EOL . PHP_EOL . " \t \t \$ " . $filter [ 'code' ] . " = \$ app->getUserStateFromRequest( \$ this->context . '.filter. " . $filter [ 'code' ] . " ', 'filter_ " . $filter [ 'code' ] . " '); " ;
$state .= PHP_EOL . " \t \t \$ this->setState('filter. " . $filter [ 'code' ] . " ', \$ " . $filter [ 'code' ] . " ); " ;
2016-02-26 00:20:09 +00:00
}
}
else
{
if ( strlen ( $state ) == 0 )
{
$spacer = " " ;
}
else
{
2017-12-14 23:10:47 +00:00
$spacer = PHP_EOL . PHP_EOL . " \t \t " ;
2016-02-26 00:20:09 +00:00
}
// check if custom field is set
2017-12-14 23:10:47 +00:00
/* if ( ComponentbuilderHelper :: checkArray ( $filter [ 'custom' ]))
{
$state .= $spacer . " \$ " . $filter [ 'code' ] . " _ " . $filter [ 'custom' ][ 'text' ] . " = \$ this->getUserStateFromRequest( \$ this->context . '.filter. " . $filter [ 'code' ] . " _ " . $filter [ 'custom' ][ 'text' ] . " ', 'filter_ " . $filter [ 'code' ] . " _ " . $filter [ 'custom' ][ 'text' ] . " '); " ;
$state .= PHP_EOL . " \t \t \$ this->setState('filter. " . $filter [ 'code' ] . " _ " . $filter [ 'custom' ][ 'text' ] . " ', \$ " . $filter [ 'code' ] . " _ " . $filter [ 'custom' ][ 'text' ] . " ); " ;
$spacer = PHP_EOL . PHP_EOL . " \t \t " ;
} */
$state .= $spacer . " \$ " . $filter [ 'code' ] . " = \$ this->getUserStateFromRequest( \$ this->context . '.filter. " . $filter [ 'code' ] . " ', 'filter_ " . $filter [ 'code' ] . " '); " ;
$state .= PHP_EOL . " \t \t \$ this->setState('filter. " . $filter [ 'code' ] . " ', \$ " . $filter [ 'code' ] . " ); " ;
2016-02-26 00:20:09 +00:00
}
$donelist [] = $filter [ 'code' ];
}
}
}
// add the rest of the set filters
if ( isset ( $this -> filterBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> filterBuilder [ $view ]))
{
foreach ( $this -> filterBuilder [ $view ] as $filter )
{
2017-12-14 23:10:47 +00:00
if ( ! in_array ( $filter [ 'code' ], $donelist ))
2016-02-26 00:20:09 +00:00
{
2017-02-01 13:17:04 +00:00
if ( $filter [ 'type' ] === 'category' )
2016-02-26 00:20:09 +00:00
{
if ( strlen ( $state ) == 0 )
{
$spacer = " " ;
}
else
{
2017-12-14 23:10:47 +00:00
$spacer = PHP_EOL . PHP_EOL . " \t \t " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$state .= $spacer . " \$ category = \$ app->getUserStateFromRequest( \$ this->context . '.filter.category', 'filter_category'); " ;
$state .= PHP_EOL . " \t \t \$ this->setState('filter.category', \$ category); " ;
$state .= PHP_EOL . PHP_EOL . " \t \t \$ categoryId = \$ this->getUserStateFromRequest( \$ this->context . '.filter.category_id', 'filter_category_id'); " ;
$state .= PHP_EOL . " \t \t \$ this->setState('filter.category_id', \$ categoryId); " ;
2016-02-26 00:20:09 +00:00
if ( $filter [ 'code' ] != 'category' )
{
2017-12-14 23:10:47 +00:00
$state .= PHP_EOL . PHP_EOL . " \t \t \$ " . $filter [ 'code' ] . " = \$ app->getUserStateFromRequest( \$ this->context . '.filter. " . $filter [ 'code' ] . " ', 'filter_ " . $filter [ 'code' ] . " '); " ;
$state .= PHP_EOL . " \t \t \$ this->setState('filter. " . $filter [ 'code' ] . " ', \$ " . $filter [ 'code' ] . " ); " ;
2016-02-26 00:20:09 +00:00
}
}
else
{
if ( strlen ( $state ) == 0 )
{
$spacer = " " ;
}
else
{
2017-12-14 23:10:47 +00:00
$spacer = PHP_EOL . PHP_EOL . " \t \t " ;
2016-02-26 00:20:09 +00:00
}
// check if custom field is set
2017-12-14 23:10:47 +00:00
/* if ( ComponentbuilderHelper :: checkArray ( $filter [ 'custom' ]))
{
$state .= $spacer . " \$ " . $filter [ 'custom' ][ 'text' ] . " = \$ this->getUserStateFromRequest( \$ this->context . '.filter. " . $filter [ 'custom' ][ 'text' ] . " ', 'filter_ " . $filter [ 'custom' ][ 'text' ] . " '); " ;
$state .= PHP_EOL . " \t \t \$ this->setState('filter. " . $filter [ 'custom' ][ 'text' ] . " ', \$ " . $filter [ 'custom' ][ 'text' ] . " ); " ;
$state .= PHP_EOL . " \t \t \$ " . $filter [ 'code' ] . " _ " . $filter [ 'custom' ][ 'text' ] . " = \$ this->getUserStateFromRequest( \$ this->context . '.filter. " . $filter [ 'code' ] . " _ " . $filter [ 'custom' ][ 'text' ] . " ', 'filter_ " . $filter [ 'code' ] . " _ " . $filter [ 'custom' ][ 'text' ] . " '); " ;
$state .= PHP_EOL . " \t \t \$ this->setState('filter. " . $filter [ 'code' ] . " _ " . $filter [ 'custom' ][ 'text' ] . " ', \$ " . $filter [ 'code' ] . " _ " . $filter [ 'custom' ][ 'text' ] . " ); " ;
$spacer = PHP_EOL . PHP_EOL . " \t \t " ;
} */
$state .= $spacer . " \$ " . $filter [ 'code' ] . " = \$ this->getUserStateFromRequest( \$ this->context . '.filter. " . $filter [ 'code' ] . " ', 'filter_ " . $filter [ 'code' ] . " '); " ;
$state .= PHP_EOL . " \t \t \$ this->setState('filter. " . $filter [ 'code' ] . " ', \$ " . $filter [ 'code' ] . " ); " ;
2016-02-26 00:20:09 +00:00
}
$donelist [] = $filter [ 'code' ];
}
}
}
return $state ;
}
2016-09-11 15:27:04 +00:00
public function setSortFields ( & $view )
2016-02-26 00:20:09 +00:00
{
2016-06-02 16:18:49 +00:00
// keep track of all fields already added
2017-12-14 23:10:47 +00:00
$donelist = array ( 'sorting' , 'published' );
2016-02-26 00:20:09 +00:00
// set the default first
$fields = " return array( " ;
2017-12-14 23:10:47 +00:00
$fields .= PHP_EOL . " \t \t \t 'a.sorting' => JText::_('JGRID_HEADING_ORDERING') " ;
$fields .= " , " . PHP_EOL . " \t \t \t 'a.published' => JText::_('JSTATUS') " ;
2016-02-26 00:20:09 +00:00
// add the rest of the set filters
if ( isset ( $this -> sortBuilder [ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> sortBuilder [ $view ]))
{
foreach ( $this -> sortBuilder [ $view ] as $filter )
{
2016-06-02 16:18:49 +00:00
if ( ! in_array ( $filter [ 'code' ], $donelist ))
2016-02-26 00:20:09 +00:00
{
2017-02-01 13:17:04 +00:00
if ( $filter [ 'type' ] === 'category' )
2016-06-02 16:18:49 +00:00
{
2017-12-14 23:10:47 +00:00
$fields .= " , " . PHP_EOL . " \t \t \t 'c.category_title' => JText::_(' " . $filter [ 'lang' ] . " ') " ;
2016-06-02 16:18:49 +00:00
}
elseif ( ComponentbuilderHelper :: checkArray ( $filter [ 'custom' ]))
{
2017-12-14 23:10:47 +00:00
$fields .= " , " . PHP_EOL . " \t \t \t ' " . $filter [ 'custom' ][ 'db' ] . " . " . $filter [ 'custom' ][ 'text' ] . " ' => JText::_(' " . $filter [ 'lang' ] . " ') " ;
2016-06-02 16:18:49 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$fields .= " , " . PHP_EOL . " \t \t \t 'a. " . $filter [ 'code' ] . " ' => JText::_(' " . $filter [ 'lang' ] . " ') " ;
2016-06-02 16:18:49 +00:00
}
2016-02-26 00:20:09 +00:00
}
}
}
2017-12-14 23:10:47 +00:00
$fields .= " , " . PHP_EOL . " \t \t \t 'a.id' => JText::_('JGRID_HEADING_ID') " ;
$fields .= PHP_EOL . " \t \t ); " ;
2016-02-26 00:20:09 +00:00
// return fields
return $fields ;
}
public function setCheckinCall ()
{
2017-12-14 23:10:47 +00:00
$call = PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " check in items " ;
$call .= PHP_EOL . " \t \t \$ this->checkInNow(); " . PHP_EOL ;
2016-02-26 00:20:09 +00:00
return $call ;
}
2017-12-14 23:10:47 +00:00
public function setAutoCheckin ( $view , $component )
{
$checkin = PHP_EOL . PHP_EOL . " \t /** " ;
$checkin .= PHP_EOL . " \t * Build an SQL query to checkin all items left checked out longer then a set time. " ;
$checkin .= PHP_EOL . " \t * " ;
$checkin .= PHP_EOL . " \t * @return a bool " ;
$checkin .= PHP_EOL . " \t * " ;
$checkin .= PHP_EOL . " \t */ " ;
$checkin .= PHP_EOL . " \t protected function checkInNow() " ;
$checkin .= PHP_EOL . " \t { " ;
$checkin .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Get set check in time " ;
$checkin .= PHP_EOL . " \t \t \$ time = JComponentHelper::getParams('com_ " . $component . " ')->get('check_in'); " ;
$checkin .= PHP_EOL . " \t \t " ;
$checkin .= PHP_EOL . " \t \t if ( \$ time) " ;
$checkin .= PHP_EOL . " \t \t { " ;
$checkin .= PHP_EOL . PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Get a db connection. " ;
$checkin .= PHP_EOL . " \t \t \t \$ db = JFactory::getDbo(); " ;
$checkin .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " reset query " ;
$checkin .= PHP_EOL . " \t \t \t \$ query = \$ db->getQuery(true); " ;
$checkin .= PHP_EOL . " \t \t \t \$ query->select('*'); " ;
$checkin .= PHP_EOL . " \t \t \t \$ query->from( \$ db->quoteName('#__ " . $component . " _ " . $view . " ')); " ;
$checkin .= PHP_EOL . " \t \t \t \$ db->setQuery( \$ query); " ;
$checkin .= PHP_EOL . " \t \t \t \$ db->execute(); " ;
$checkin .= PHP_EOL . " \t \t \t if ( \$ db->getNumRows()) " ;
$checkin .= PHP_EOL . " \t \t \t { " ;
$checkin .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Get Yesterdays date " ;
$checkin .= PHP_EOL . " \t \t \t \t \$ date = JFactory::getDate()->modify( \$ time)->toSql(); " ;
$checkin .= PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " reset query " ;
$checkin .= PHP_EOL . " \t \t \t \t \$ query = \$ db->getQuery(true); " ;
$checkin .= PHP_EOL . PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Fields to update. " ;
$checkin .= PHP_EOL . " \t \t \t \t \$ fields = array( " ;
$checkin .= PHP_EOL . " \t \t \t \t \t \$ db->quoteName('checked_out_time') . '= \ '0000-00-00 00:00:00 \ '', " ;
$checkin .= PHP_EOL . " \t \t \t \t \t \$ db->quoteName('checked_out') . '=0' " ;
$checkin .= PHP_EOL . " \t \t \t \t ); " ;
$checkin .= PHP_EOL . PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Conditions for which records should be updated. " ;
$checkin .= PHP_EOL . " \t \t \t \t \$ conditions = array( " ;
$checkin .= PHP_EOL . " \t \t \t \t \t \$ db->quoteName('checked_out') . '!=0', " ;
$checkin .= PHP_EOL . " \t \t \t \t \t \$ db->quoteName('checked_out_time') . '< \ ''. \$ date.' \ '' " ;
$checkin .= PHP_EOL . " \t \t \t \t ); " ;
$checkin .= PHP_EOL . PHP_EOL . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " Check table " ;
$checkin .= PHP_EOL . " \t \t \t \t \$ query->update( \$ db->quoteName('#__ " . $component . " _ " . $view . " '))->set( \$ fields)->where( \$ conditions); " ;
$checkin .= PHP_EOL . PHP_EOL . " \t \t \t \t \$ db->setQuery( \$ query); " ;
$checkin .= PHP_EOL . PHP_EOL . " \t \t \t \t \$ db->execute(); " ;
$checkin .= PHP_EOL . " \t \t \t } " ;
$checkin .= PHP_EOL . " \t \t } " ;
$checkin .= PHP_EOL . PHP_EOL . " \t \t return false; " ;
$checkin .= PHP_EOL . " \t } " ;
2016-02-26 00:20:09 +00:00
return $checkin ;
}
2017-04-05 13:21:10 +00:00
public function setGetItemsMethodStringFix ( $view , $Component , $tab = '' , $export = false )
2016-02-26 00:20:09 +00:00
{
// add the fix if this view has the need for it
$fix = '' ;
2017-09-13 00:37:43 +00:00
// encryption switches
2016-02-26 00:20:09 +00:00
$basicCrypt = false ;
$advancedCrypt = false ;
// setup correct core target
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $view ]))
{
$core = $this -> permissionCore [ $view ];
$coreLoad = true ;
}
$component = ComponentbuilderHelper :: safeString ( $Component );
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.access' ]) && isset ( $this -> permissionBuilder [ $core [ 'core.access' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ $core [ 'core.access' ]]) && in_array ( $view , $this -> permissionBuilder [ $core [ 'core.access' ]]))
{
$fix .= PHP_EOL . PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " set values to display correctly. " ;
$fix .= PHP_EOL . " \t " . $tab . " \t if ( " . $Component . " Helper::checkArray( \$ items)) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t // " . $this -> setLine ( __LINE__ ) . " get user object. " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \$ user = JFactory::getUser(); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t foreach ( \$ items as \$ nr => & \$ item) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \$ access = ( \$ user->authorise(' " . $core [ 'core.access' ] . " ', 'com_ " . $component . " . " . $view . " .' . (int) \$ item->id) && \$ user->authorise(' " . $core [ 'core.access' ] . " ', 'com_ " . $component . " ')); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t if (! \$ access) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t unset( \$ items[ \$ nr]); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t continue; " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t } " . PHP_EOL ;
}
2016-02-26 00:20:09 +00:00
if ( ! $export )
{
$methodName = 'getItemsMethodListStringFixBuilder' ;
}
else
{
$methodName = 'getItemsMethodEximportStringFixBuilder' ;
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> { $methodName }[ $view ]) && ComponentbuilderHelper :: checkArray ( $this -> { $methodName }[ $view ]))
{
if ( ! ComponentbuilderHelper :: checkString ( $fix ))
{
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " set values to display correctly. " ;
$fix .= PHP_EOL . " \t " . $tab . " \t if ( " . $Component . " Helper::checkArray( \$ items)) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t foreach ( \$ items as \$ nr => & \$ item) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t { " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
foreach ( $this -> { $methodName }[ $view ] as $item )
{
switch ( $item [ 'method' ])
{
case 1 :
2017-12-14 23:10:47 +00:00
// JSON_STRING_ENCODE
$decode = 'json_decode' ;
$suffix_decode = ', true' ;
break ;
2016-02-26 00:20:09 +00:00
case 2 :
2017-12-14 23:10:47 +00:00
// BASE_SIXTY_FOUR
$decode = 'base64_decode' ;
$suffix_decode = '' ;
break ;
2016-02-26 00:20:09 +00:00
case 3 :
2017-12-14 23:10:47 +00:00
// BASIC_ENCRYPTION_LOCALKEY
$decode = '$basic->decryptString' ;
$basicCrypt = true ;
$suffix_decode = '' ;
break ;
2016-02-26 00:20:09 +00:00
case 4 :
2017-12-14 23:10:47 +00:00
// ADVANCE_ENCRYPTION_VDMKEY
$decode = '$advanced->decryptString' ;
$advancedCrypt = true ;
$suffix_decode = '' ;
break ;
2016-02-26 00:20:09 +00:00
default :
2017-12-14 23:10:47 +00:00
// JSON_ARRAY_ENCODE
$decode = 'json_decode' ;
$suffix_decode = ', true' ;
break ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
2017-02-01 13:17:04 +00:00
if ( $item [ 'type' ] === 'usergroup' && ! $export )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " decode " . $item [ 'name' ];
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \$ " . $item [ 'name' ] . " Array = " . $decode . " ( \$ item-> " . $item [ 'name' ] . $suffix_decode . " ); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t if ( " . $Component . " Helper::checkArray( \$ " . $item [ 'name' ] . " Array)) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \$ " . $item [ 'name' ] . " Names = ''; " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \$ counter = 0; " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t foreach ( \$ " . $item [ 'name' ] . " Array as \$ " . $item [ 'name' ] . " ) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t if ( \$ counter == 0) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t \t \$ " . $item [ 'name' ] . " Names .= " . $Component . " Helper::getGroupName( \$ " . $item [ 'name' ] . " ); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t } " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t else " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t \t \$ " . $item [ 'name' ] . " Names .= ', '. " . $Component . " Helper::getGroupName( \$ " . $item [ 'name' ] . " ); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t } " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t \$ counter++; " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t } " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \$ item-> " . $item [ 'name' ] . " = \$ " . $item [ 'name' ] . " Names; " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t } " ;
}
/* elseif ( $item [ 'type' ] === 'usergroup' && $export )
{
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " decode " . $item [ 'name' ];
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \$ " . $item [ 'name' ] . " Array = " . $decode . " ( \$ item-> " . $item [ 'name' ] . $suffix_decode . " ); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t if ( " . $Component . " Helper::checkArray( \$ " . $item [ 'name' ] . " Array)) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \$ item-> " . $item [ 'name' ] . " = implode('|', \$ " . $item [ 'name' ] . " Array); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t } " ;
} */
2016-02-26 00:20:09 +00:00
elseif ( $item [ 'translation' ] && ! $export )
{
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " convert " . $item [ 'name' ];
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \$ " . $item [ 'name' ] . " Array = " . $decode . " ( \$ item-> " . $item [ 'name' ] . $suffix_decode . " ); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t if ( " . $Component . " Helper::checkArray( \$ " . $item [ 'name' ] . " Array)) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \$ " . $item [ 'name' ] . " Names = ''; " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \$ counter = 0; " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t foreach ( \$ " . $item [ 'name' ] . " Array as \$ " . $item [ 'name' ] . " ) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t if ( \$ counter == 0) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t \t \$ " . $item [ 'name' ] . " Names .= JText::_( \$ this->selectionTranslation( \$ " . $item [ 'name' ] . " , ' " . $item [ 'name' ] . " ')); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t } " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t else " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t \t \$ " . $item [ 'name' ] . " Names .= ', '.JText::_( \$ this->selectionTranslation( \$ " . $item [ 'name' ] . " , ' " . $item [ 'name' ] . " ')); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t } " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t \$ counter++; " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t } " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \$ item-> " . $item [ 'name' ] . " = \$ " . $item [ 'name' ] . " Names; " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t } " ;
2016-02-26 00:20:09 +00:00
}
else
{
if ( $item [ 'method' ] == 2 || $item [ 'method' ] == 3 || $item [ 'method' ] == 4 )
{
$taber = '' ;
if ( $item [ 'method' ] == 3 )
{
$taber = " \t " ;
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t if ( \$ basickey && !is_numeric( \$ item-> " . $item [ 'name' ] . " ) && \$ item-> " . $item [ 'name' ] . " === base64_encode(base64_decode( \$ item-> " . $item [ 'name' ] . " , true))) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t { " ;
2016-02-26 00:20:09 +00:00
}
if ( $item [ 'method' ] == 4 )
{
$taber = " \t " ;
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t if ( \$ advancedkey && !is_numeric( \$ item-> " . $item [ 'name' ] . " ) && \$ item-> " . $item [ 'name' ] . " === base64_encode(base64_decode( \$ item-> " . $item [ 'name' ] . " , true))) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t { " ;
2016-02-26 00:20:09 +00:00
}
if ( $item [ 'method' ] == 3 || $item [ 'method' ] == 4 )
{
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " decrypt " . $item [ 'name' ];
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t " . $tab . $taber . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " decode " . $item [ 'name' ];
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t " . $tab . $taber . " \t \t \t \$ item-> " . $item [ 'name' ] . " = " . $decode . " ( \$ item-> " . $item [ 'name' ] . " ); " ;
2016-02-26 00:20:09 +00:00
if ( $item [ 'method' ] == 3 || $item [ 'method' ] == 4 )
{
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t } " ;
2016-02-26 00:20:09 +00:00
}
}
else
{
2017-02-01 13:17:04 +00:00
if ( $export && $item [ 'type' ] === 'repeatable' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " decode repeatable " . $item [ 'name' ];
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \$ " . $item [ 'name' ] . " Array = " . $decode . " ( \$ item-> " . $item [ 'name' ] . $suffix_decode . " ); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t if ( " . $Component . " Helper::checkArray( \$ " . $item [ 'name' ] . " Array)) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \$ bucket " . $item [ 'name' ] . " = array(); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t foreach ( \$ " . $item [ 'name' ] . " Array as \$ " . $item [ 'name' ] . " FieldName => \$ " . $item [ 'name' ] . " ) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t if ( " . $Component . " Helper::checkArray( \$ " . $item [ 'name' ] . " )) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t \t \$ bucket " . $item [ 'name' ] . " [] = \$ " . $item [ 'name' ] . " FieldName . '<||VDM||>' . implode('<|VDM|>', \$ " . $item [ 'name' ] . " ); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t } " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t } " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " make sure the bucket has values. " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t if ( " . $Component . " Helper::checkArray( \$ bucket " . $item [ 'name' ] . " )) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " clear the repeatable field. " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t unset( \$ item-> " . $item [ 'name' ] . " ); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " set repeatable field for export. " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t \$ item-> " . $item [ 'name' ] . " = implode('<|||VDM|||>', \$ bucket " . $item [ 'name' ] . " ); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t // " . $this -> setLine ( __LINE__ ) . " unset the bucket. " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t \t unset( \$ bucket " . $item [ 'name' ] . " ); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \t } " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t } " ;
2016-02-26 00:20:09 +00:00
}
2016-05-10 05:47:47 +00:00
elseif ( $item [ 'method' ] == 1 && ! $export )
{
// TODO we check if this works well.
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " convert " . $item [ 'name' ];
2017-04-05 13:21:10 +00:00
if ( isset ( $item [ 'custom' ][ 'table' ]))
{
2017-12-14 23:10:47 +00:00
$keyTableNAme = str_replace ( '#__' . $this -> fileContentStatic [ '###component###' ] . '_' , '' , $item [ 'custom' ][ 'table' ]);
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \$ item-> " . $item [ 'name' ] . " = " . $Component . " Helper::jsonToString( \$ item-> " . $item [ 'name' ] . " , ', ', ' " . $keyTableNAme . " '); " ;
2017-04-05 13:21:10 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \$ item-> " . $item [ 'name' ] . " = " . $Component . " Helper::jsonToString( \$ item-> " . $item [ 'name' ] . " , ', ', ' " . $item [ 'name' ] . " '); " ;
2017-04-05 13:21:10 +00:00
}
2016-05-10 05:47:47 +00:00
}
2016-02-26 00:20:09 +00:00
else
{
if ( ! $export )
{
2016-05-10 05:47:47 +00:00
// For thos we have not cached yet.
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " convert " . $item [ 'name' ];
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \$ item-> " . $item [ 'name' ] . " = " . $Component . " Helper::jsonToString( \$ item-> " . $item [ 'name' ] . " ); " ;
2016-02-26 00:20:09 +00:00
}
}
}
}
}
}
// close the foreach if needed
if ( ! ComponentbuilderHelper :: checkString ( $fix ) && $export )
{
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " set values to display correctly. " ;
$fix .= PHP_EOL . " \t " . $tab . " \t if ( " . $Component . " Helper::checkArray( \$ items)) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t foreach ( \$ items as \$ nr => & \$ item) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t { " ;
2016-02-26 00:20:09 +00:00
}
// close the foreach if needed
if ( ComponentbuilderHelper :: checkString ( $fix ))
{
// remove these values if export
if ( $export )
{
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " unset the values we don't want exported. " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t unset( \$ item->asset_id); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t unset( \$ item->checked_out); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t unset( \$ item->checked_out_time); " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t " . $tab . " \t \t } " ;
$fix .= PHP_EOL . " \t " . $tab . " \t } " ;
2016-02-26 00:20:09 +00:00
if ( $export )
{
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " Add headers to items array. " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \$ headers = \$ this->getExImPortHeaders(); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t if ( " . $Component . " Helper::checkObject( \$ headers)) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t array_unshift( \$ items, \$ headers); " ;
$fix .= PHP_EOL . " \t " . $tab . " \t } " ;
2016-02-26 00:20:09 +00:00
}
}
// add custom php to getitems method
2017-12-14 23:10:47 +00:00
$fix .= $this -> getCustomScriptBuilder ( 'php_getitems' , $view , PHP_EOL . PHP_EOL . $tab );
2016-02-26 00:20:09 +00:00
if ( $basicCrypt )
{
2017-12-14 23:10:47 +00:00
$script = PHP_EOL . PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " Get the basic encryption key. " ;
$script .= PHP_EOL . " \t " . $tab . " \t \$ basickey = " . $Component . " Helper::getCryptKey('basic'); " ;
$script .= PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " Get the encryption object. " ;
$script .= PHP_EOL . " \t " . $tab . " \t \$ basic = new FOFEncryptAes( \$ basickey, 128); " ;
2016-02-26 00:20:09 +00:00
// add the encryption script
$fix = $script . $fix ;
}
if ( $advancedCrypt )
{
2017-12-14 23:10:47 +00:00
$script = PHP_EOL . PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " Get the advanced encryption key. " ;
$script .= PHP_EOL . " \t " . $tab . " \t \$ advancedkey = " . $Component . " Helper::getCryptKey('advanced'); " ;
$script .= PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " Get the encryption object. " ;
$script .= PHP_EOL . " \t " . $tab . " \t \$ advanced = new FOFEncryptAes( \$ advancedkey, 256); " ;
2016-02-26 00:20:09 +00:00
// add the encryption script
$fix = $script . $fix ;
}
return $fix ;
}
2017-12-14 23:10:47 +00:00
public function setSelectionTranslationFix ( $views , $Component , $tab = '' )
2016-02-26 00:20:09 +00:00
{
// add the fix if this view has the need for it
$fix = '' ;
if ( isset ( $this -> selectionTranslationFixBuilder [ $views ]) && ComponentbuilderHelper :: checkArray ( $this -> selectionTranslationFixBuilder [ $views ]))
{
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . PHP_EOL . " \t " . $tab . " \t // " . $this -> setLine ( __LINE__ ) . " set selection value to a translatable value " ;
$fix .= PHP_EOL . " \t " . $tab . " \t if ( " . $Component . " Helper::checkArray( \$ items)) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t { " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t foreach ( \$ items as \$ nr => & \$ item) " ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t { " ;
2016-02-26 00:20:09 +00:00
foreach ( $this -> selectionTranslationFixBuilder [ $views ] as $name => $values )
{
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " convert " . $name ;
$fix .= PHP_EOL . " \t " . $tab . " \t \t \t \$ item-> " . $name . " = \$ this->selectionTranslation( \$ item-> " . $name . " , ' " . $name . " '); " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t " . $tab . " \t \t } " ;
$fix .= PHP_EOL . " \t " . $tab . " \t } " . PHP_EOL ;
2016-02-26 00:20:09 +00:00
}
return $fix ;
}
2017-12-14 23:10:47 +00:00
public function setSelectionTranslationFixFunc ( $views , $Component )
2016-02-26 00:20:09 +00:00
{
// add the fix if this view has the need for it
$fix = '' ;
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> selectionTranslationFixBuilder [ $views ]) && ComponentbuilderHelper :: checkArray ( $this -> selectionTranslationFixBuilder [ $views ]))
{
$fix .= PHP_EOL . PHP_EOL . " \t /** " ;
$fix .= PHP_EOL . " \t * Method to convert selection values to translatable string. " ;
$fix .= PHP_EOL . " \t * " ;
$fix .= PHP_EOL . " \t * @return translatable string " ;
$fix .= PHP_EOL . " \t */ " ;
$fix .= PHP_EOL . " \t public function selectionTranslation( \$ value, \$ name) " ;
$fix .= PHP_EOL . " \t { " ;
2016-02-26 00:20:09 +00:00
foreach ( $this -> selectionTranslationFixBuilder [ $views ] as $name => $values )
{
if ( ComponentbuilderHelper :: checkArray ( $values ))
{
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Array of " . $name . " language strings " ;
$fix .= PHP_EOL . " \t \t if ( \$ name === ' " . $name . " ') " ;
$fix .= PHP_EOL . " \t \t { " ;
$fix .= PHP_EOL . " \t \t \t \$ " . $name . " Array = array( " ;
2016-02-26 00:20:09 +00:00
$counter = 0 ;
foreach ( $values as $value => $translang )
{
// only add quotes to strings
if ( ComponentbuilderHelper :: checkString ( $value ))
{
2017-12-14 23:10:47 +00:00
$key = " ' " . $value . " ' " ;
2016-02-26 00:20:09 +00:00
}
else
{
if ( $value == '' )
{
$value = 0 ;
}
$key = $value ;
}
if ( $counter == 0 )
{
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t \t \t \t " . $key . " => ' " . $translang . " ' " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$fix .= " , " . PHP_EOL . " \t \t \t \t " . $key . " => ' " . $translang . " ' " ;
2016-02-26 00:20:09 +00:00
}
$counter ++ ;
}
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t \t \t ); " ;
$fix .= PHP_EOL . " \t \t \t // " . $this -> setLine ( __LINE__ ) . " Now check if value is found in this array " ;
$fix .= PHP_EOL . " \t \t \t if (isset( \$ " . $name . " Array[ \$ value]) && " . $Component . " Helper::checkString( \$ " . $name . " Array[ \$ value])) " ;
$fix .= PHP_EOL . " \t \t \t { " ;
$fix .= PHP_EOL . " \t \t \t \t return \$ " . $name . " Array[ \$ value]; " ;
$fix .= PHP_EOL . " \t \t \t } " ;
$fix .= PHP_EOL . " \t \t } " ;
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
$fix .= PHP_EOL . " \t \t return \$ value; " ;
$fix .= PHP_EOL . " \t } " ;
2016-02-26 00:20:09 +00:00
}
return $fix ;
}
public function setRouterCase ( $viewName )
{
if ( strlen ( $viewName ) > 0 )
{
2017-12-14 23:10:47 +00:00
$router = PHP_EOL . " \t \t case ' " . $viewName . " ': " ;
$router .= PHP_EOL . " \t \t \t \$ id = explode(':', \$ segments[ $count -1]); " ;
$router .= PHP_EOL . " \t \t \t \$ vars['id'] = (int) \$ id[0]; " ;
$router .= PHP_EOL . " \t \t \t \$ vars['view'] = ' " . $viewName . " '; " ;
$router .= PHP_EOL . " \t \t break; " ;
2016-02-26 00:20:09 +00:00
return $router ;
}
return '' ;
}
public function setComponentImageType ( $path )
{
$type = ComponentbuilderHelper :: imageInfo ( $path );
if ( $type )
{
2017-12-14 23:10:47 +00:00
$imagePath = $this -> componentPath . '/admin/assets/images' ;
2016-02-26 00:20:09 +00:00
// move the image to its place
2017-12-14 23:10:47 +00:00
JFile :: copy ( JPATH_SITE . '/' . $path , $imagePath . '/vdm-component.' . $type , '' , true );
2016-02-26 00:20:09 +00:00
// now set the type to global for re-use
$this -> componentImageType = $type ;
// return image type
return $type ;
}
$this -> componentImageType = 'jpg' ;
return 'jpg' ;
}
public function setDashboardIconAccess ()
{
if ( isset ( $this -> permissionDashboard ) && ComponentbuilderHelper :: checkArray ( $this -> permissionDashboard ))
{
$this -> permissionDashboard = array_unique ( $this -> permissionDashboard );
2017-12-14 23:10:47 +00:00
return PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " view access array " . PHP_EOL . " \t \t \$ viewAccess = array( " . PHP_EOL . " \t \t \t " . implode ( " , " . PHP_EOL . " \t \t \t " , $this -> permissionDashboard ) . " ); " ;
2016-02-26 00:20:09 +00:00
}
return '' ;
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
public function setDashboardIcons ()
{
if ( isset ( $this -> componentData -> admin_views ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> admin_views ))
{
$icons = '' ;
$counter = 0 ;
$catArray = array ();
foreach ( $this -> componentData -> admin_views as $view )
{
$name_single = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_single );
$name_list = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_list );
2017-12-14 23:10:47 +00:00
$icons .= $this -> addCustomDashboardIcons ( $view , $counter );
2017-10-30 13:08:02 +00:00
if ( isset ( $view [ 'dashboard_add' ]) && $view [ 'dashboard_add' ] == 1 )
2016-02-26 00:20:09 +00:00
{
$type = ComponentbuilderHelper :: imageInfo ( $view [ 'settings' ] -> icon_add );
if ( $type )
{
2017-12-14 23:10:47 +00:00
$type = $type . " . " ;
2016-02-26 00:20:09 +00:00
// icon builder loader
2017-12-14 23:10:47 +00:00
$this -> iconBuilder [ $type . $name_single . " .add " ] = $view [ 'settings' ] -> icon_add ;
2016-02-26 00:20:09 +00:00
}
else
{
$type = 'png.' ;
}
if ( $counter == 0 )
{
2017-12-14 23:10:47 +00:00
$icons .= " ' " . $type . $name_single . " .add' " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$icons .= " , ' " . $type . $name_single . " .add' " ;
2016-02-26 00:20:09 +00:00
}
// build lang
2017-12-14 23:10:47 +00:00
$langName = 'Add ' . ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_single , 'W' ) . '<br /><br />' ;
$langKey = $this -> langPrefix . '_DASHBOARD_' . ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_single , 'U' ) . '_ADD' ;
2016-02-26 00:20:09 +00:00
// add to lang
$this -> langContent [ $this -> lang ][ $langKey ] = $langName ;
$counter ++ ;
}
2017-10-30 18:50:56 +00:00
if ( isset ( $view [ 'dashboard_list' ]) && $view [ 'dashboard_list' ] == 1 )
2016-02-26 00:20:09 +00:00
{
$type = ComponentbuilderHelper :: imageInfo ( $view [ 'settings' ] -> icon );
if ( $type )
{
2017-12-14 23:10:47 +00:00
$type = $type . " . " ;
2016-02-26 00:20:09 +00:00
// icon builder loader
2017-12-14 23:10:47 +00:00
$this -> iconBuilder [ $type . $name_list ] = $view [ 'settings' ] -> icon ;
2016-02-26 00:20:09 +00:00
}
else
{
$type = 'png.' ;
}
if ( $counter == 0 )
{
2017-12-14 23:10:47 +00:00
$icons .= " ' " . $type . $name_list . " ' " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$icons .= " , ' " . $type . $name_list . " ' " ;
2016-02-26 00:20:09 +00:00
}
// build lang
2017-12-14 23:10:47 +00:00
$langName = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_list , 'W' ) . '<br /><br />' ;
$langKey = $this -> langPrefix . '_DASHBOARD_' . ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_list , 'U' );
2016-02-26 00:20:09 +00:00
// add to lang
$this -> langContent [ $this -> lang ][ $langKey ] = $langName ;
$counter ++ ;
}
if ( isset ( $this -> categoryBuilder [ $name_list ]) && ComponentbuilderHelper :: checkArray ( $this -> categoryBuilder [ $name_list ]))
{
$catCode = $this -> categoryBuilder [ $name_list ][ 'code' ];
// check if category has another name
if ( isset ( $this -> catOtherName [ $name_list ]) && ComponentbuilderHelper :: checkArray ( $this -> catOtherName [ $name_list ]))
{
$otherViews = $this -> catOtherName [ $name_list ][ 'views' ];
$otherNames = $this -> catOtherName [ $name_list ][ 'name' ];
// build lang
$langName = ComponentbuilderHelper :: safeString ( $otherNames , 'W' );
}
else
{
$otherViews = $name_list ;
// build lang
2017-12-14 23:10:47 +00:00
$langName = 'Category For<br />' . ComponentbuilderHelper :: safeString ( $otherViews , 'W' );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
if ( ! in_array ( $otherViews , $catArray ))
2016-02-26 00:20:09 +00:00
{
// add to lang
2017-12-14 23:10:47 +00:00
$langKey = $this -> langPrefix . '_DASHBOARD_' . ComponentbuilderHelper :: safeString ( $otherViews , 'U' ) . '_' . ComponentbuilderHelper :: safeString ( $catCode , 'U' );
2016-02-26 00:20:09 +00:00
$this -> langContent [ $this -> lang ][ $langKey ] = $langName ;
// get image type
$type = ComponentbuilderHelper :: imageInfo ( $view [ 'settings' ] -> icon_category );
if ( $type )
{
2017-12-14 23:10:47 +00:00
$type = $type . " . " ;
2016-02-26 00:20:09 +00:00
// icon builder loader
2017-12-14 23:10:47 +00:00
$this -> iconBuilder [ $type . $otherViews . " . " . $catCode ] = $view [ 'settings' ] -> icon_category ;
2016-02-26 00:20:09 +00:00
}
else
{
$type = 'png.' ;
}
if ( $counter == 0 )
{
2017-12-14 23:10:47 +00:00
$icons .= " ' " . $type . $otherViews . " . " . $catCode . " ' " ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$icons .= " , ' " . $type . $otherViews . " . " . $catCode . " ' " ;
2016-02-26 00:20:09 +00:00
}
$counter ++ ;
// make sure we add a category only once
$catArray [] = $otherViews ;
}
}
}
if ( isset ( $this -> lastCustomDashboardIcon ) && ComponentbuilderHelper :: checkArray ( $this -> lastCustomDashboardIcon ))
{
foreach ( $this -> lastCustomDashboardIcon as $icon )
{
$icons .= $icon ;
}
unset ( $this -> lastCustomDashboardIcon );
}
if ( isset ( $this -> iconBuilder ) && ComponentbuilderHelper :: checkArray ( $this -> iconBuilder ))
{
2017-12-14 23:10:47 +00:00
$imagePath = $this -> componentPath . '/admin/assets/images/icons' ;
2016-02-26 00:20:09 +00:00
foreach ( $this -> iconBuilder as $icon => $path )
{
$array_buket = explode ( '.' , $icon );
if ( count ( $array_buket ) == 3 )
{
list ( $type , $name , $action ) = $array_buket ;
}
else
{
list ( $type , $name ) = $array_buket ;
$action = false ;
}
// set the new image name
if ( $action )
{
2017-12-14 23:10:47 +00:00
$imageName = $name . '_' . $action . '.' . $type ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$imageName = $name . '.' . $type ;
2016-02-26 00:20:09 +00:00
}
// move the image to its place
2017-12-14 23:10:47 +00:00
JFile :: copy ( JPATH_SITE . '/' . $path , $imagePath . '/' . $imageName , '' , true );
2016-02-26 00:20:09 +00:00
}
}
return $icons ;
}
return false ;
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
public function setDashboardModelMethods ()
{
2017-12-27 03:45:35 +00:00
if ( isset ( $this -> componentData -> php_dashboard_methods ) && ComponentbuilderHelper :: checkString ( $this -> componentData -> php_dashboard_methods ))
2016-02-26 00:20:09 +00:00
{
// get all the mothods that should load date to the view
2017-12-14 23:10:47 +00:00
$this -> DashboardGetCustomData = ComponentbuilderHelper :: getAllBetween ( $this -> componentData -> php_dashboard_methods , 'public function get' , '()' );
2016-02-26 00:20:09 +00:00
// return the methods
2017-12-14 23:10:47 +00:00
return PHP_EOL . PHP_EOL . $this -> setPlaceholders ( $this -> componentData -> php_dashboard_methods , $this -> placeholders );
2016-02-26 00:20:09 +00:00
}
return '' ;
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
public function setDashboardGetCustomData ()
{
2017-12-27 03:45:35 +00:00
if ( isset ( $this -> DashboardGetCustomData ) && ComponentbuilderHelper :: checkArray ( $this -> DashboardGetCustomData ))
2016-02-26 00:20:09 +00:00
{
// gets array reset
$gets = array ();
// set dashboard gets
2017-12-14 23:10:47 +00:00
foreach ( $this -> DashboardGetCustomData as $get )
2016-02-26 00:20:09 +00:00
{
$string = ComponentbuilderHelper :: safeString ( $get );
2017-12-27 03:45:35 +00:00
$gets [] = " \$ this-> " . $string . " = \$ this->get(' " . $get . " '); " ;
2016-02-26 00:20:09 +00:00
}
// return the gets
2017-12-14 23:10:47 +00:00
return PHP_EOL . " \t \t " . implode ( PHP_EOL . " \t \t " , $gets );
2016-02-26 00:20:09 +00:00
}
return '' ;
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
public function setDashboardDisplayData ()
{
// display array reset
$display = array ();
$mainAccordianName = 'cPanel' ;
$builder = array ();
$tab = " \t " ;
$loadTabs = false ;
// check if we have custom tabs
2017-12-27 03:45:35 +00:00
if ( isset ( $this -> componentData -> dashboard_tab ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> dashboard_tab ))
2016-02-26 00:20:09 +00:00
{
// build the tabs and accordians
foreach ( $this -> componentData -> dashboard_tab as $data )
{
2017-02-11 02:24:26 +00:00
$builder [ $data [ 'name' ]][ $data [ 'header' ]] = $this -> setPlaceholders ( $data [ 'html' ], $this -> placeholders );
2016-02-26 00:20:09 +00:00
}
// since we have custom tabs we must load the tab structure around the cpanel
2017-04-26 08:55:02 +00:00
$display [] = '<div id="j-main-container">' ;
2017-12-14 23:10:47 +00:00
$display [] = " \t " . '<div class="form-horizontal">' ;
2016-02-26 00:20:09 +00:00
$display [] = " \t <?php echo JHtml::_('bootstrap.startTabSet', 'cpanel_tab', array('active' => 'cpanel')); ?> " ;
2017-12-14 23:10:47 +00:00
$display [] = PHP_EOL . " \t \t <?php echo JHtml::_('bootstrap.addTab', 'cpanel_tab', 'cpanel', JText::_('cPanel', true)); ?> " ;
$display [] = " \t \t " . '<div class="row-fluid">' ;
2016-02-26 00:20:09 +00:00
// set the tab to insure correct spacing
$tab = " \t \t \t " ;
// change the name of the main tab
$mainAccordianName = 'Control Panel' ;
$loadTabs = true ;
}
else
{
$display [] = '<div id="j-main-container">' ;
}
// set dashboard display
2017-12-14 23:10:47 +00:00
$display [] = $tab . '<div class="span9">' ;
$display [] = $tab . " \t <?php echo JHtml::_('bootstrap.startAccordion', 'dashboard_left', array('active' => 'main')); ?> " ;
$display [] = $tab . " \t \t <?php echo JHtml::_('bootstrap.addSlide', 'dashboard_left', ' " . $mainAccordianName . " ', 'main'); ?> " ;
$display [] = $tab . " \t \t \t <?php echo \$ this->loadTemplate('main');?> " ;
$display [] = $tab . " \t \t <?php echo JHtml::_('bootstrap.endSlide'); ?> " ;
$display [] = $tab . " \t <?php echo JHtml::_('bootstrap.endAccordion'); ?> " ;
$display [] = $tab . " </div> " ;
$display [] = $tab . '<div class="span3">' ;
$display [] = $tab . " \t <?php echo JHtml::_('bootstrap.startAccordion', 'dashboard_right', array('active' => 'vdm')); ?> " ;
$display [] = $tab . " \t \t <?php echo JHtml::_('bootstrap.addSlide', 'dashboard_right', ' " . $this -> fileContentStatic [ '###COMPANYNAME###' ] . " ', 'vdm'); ?> " ;
$display [] = $tab . " \t \t \t <?php echo \$ this->loadTemplate('vdm');?> " ;
$display [] = $tab . " \t \t <?php echo JHtml::_('bootstrap.endSlide'); ?> " ;
$display [] = $tab . " \t <?php echo JHtml::_('bootstrap.endAccordion'); ?> " ;
$display [] = $tab . " </div> " ;
2016-02-26 00:20:09 +00:00
if ( $loadTabs )
{
$display [] = " \t \t </div> " ;
2017-12-14 23:10:47 +00:00
$display [] = " \t \t <?php echo JHtml::_('bootstrap.endTab'); ?> " ;
2016-02-26 00:20:09 +00:00
// load the new tabs
2017-12-14 23:10:47 +00:00
foreach ( $builder as $tabname => $accordians )
2016-02-26 00:20:09 +00:00
{
$alias = ComponentbuilderHelper :: safeString ( $tabname );
2017-12-14 23:10:47 +00:00
$display [] = PHP_EOL . " \t \t <?php echo JHtml::_('bootstrap.addTab', 'cpanel_tab', ' " . $alias . " ', JText::_(' " . $tabname . " ', true)); ?> " ;
$display [] = " \t \t " . '<div class="row-fluid">' ;
$display [] = $tab . '<div class="span12">' ;
$display [] = $tab . " \t <?php echo JHtml::_('bootstrap.startAccordion', ' " . $alias . " _accordian', array('active' => ' " . $alias . " _one')); ?> " ;
2016-02-26 00:20:09 +00:00
$slidecounter = 1 ;
2017-12-14 23:10:47 +00:00
foreach ( $accordians as $accordianname => $html )
2016-02-26 00:20:09 +00:00
{
$ac_alias = ComponentbuilderHelper :: safeString ( $accordianname );
$counterName = ComponentbuilderHelper :: safeString ( $slidecounter );
2017-12-14 23:10:47 +00:00
$tempName = $alias . '_' . $ac_alias ;
$display [] = $tab . " \t \t <?php echo JHtml::_('bootstrap.addSlide', ' " . $alias . " _accordian', ' " . $accordianname . " ', ' " . $alias . " _ " . $counterName . " '); ?> " ;
$display [] = $tab . " \t \t \t <?php echo \$ this->loadTemplate(' " . $tempName . " ');?> " ;
$display [] = $tab . " \t \t <?php echo JHtml::_('bootstrap.endSlide'); ?> " ;
2016-02-26 00:20:09 +00:00
$slidecounter ++ ;
// build the template file
$target = array ( 'custom_admin' => $this -> fileContentStatic [ '###component###' ]);
2017-12-14 23:10:47 +00:00
$this -> buildDynamique ( $target , 'template' , $tempName );
2016-02-26 00:20:09 +00:00
// set the file data
2017-12-14 23:10:47 +00:00
$TARGET = ComponentbuilderHelper :: safeString ( $this -> target , 'U' );
2016-02-26 00:20:09 +00:00
// ###SITE_TEMPLATE_BODY### <<<DYNAMIC>>>
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $this -> fileContentStatic [ '###component###' ] . '_' . $tempName ][ '###CUSTOM_ADMIN_TEMPLATE_BODY###' ] = PHP_EOL . $html ;
2016-02-26 00:20:09 +00:00
// ###SITE_TEMPLATE_CODE_BODY### <<<DYNAMIC>>>
2017-12-14 23:10:47 +00:00
$this -> fileContentDynamic [ $this -> fileContentStatic [ '###component###' ] . '_' . $tempName ][ '###CUSTOM_ADMIN_TEMPLATE_CODE_BODY###' ] = '' ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$display [] = $tab . " \t <?php echo JHtml::_('bootstrap.endAccordion'); ?> " ;
$display [] = $tab . " </div> " ;
2016-02-26 00:20:09 +00:00
$display [] = " \t \t </div> " ;
2017-12-14 23:10:47 +00:00
$display [] = " \t \t <?php echo JHtml::_('bootstrap.endTab'); ?> " ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
$display [] = PHP_EOL . " \t <?php echo JHtml::_('bootstrap.endTabSet'); ?> " ;
2016-02-26 00:20:09 +00:00
$display [] = " \t </div> " ;
}
$display [] = " </div> " ;
// return the display
2017-12-14 23:10:47 +00:00
return PHP_EOL . implode ( PHP_EOL , $display );
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
public function addCustomDashboardIcons ( & $view , & $counter )
2016-02-26 00:20:09 +00:00
{
2016-07-12 21:07:55 +00:00
$icon = '' ;
if ( isset ( $this -> componentData -> custom_admin_views ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> custom_admin_views ))
{
foreach ( $this -> componentData -> custom_admin_views as $nr => $menu )
{
if ( ! isset ( $this -> customAdminAdded [ $menu [ 'settings' ] -> code ]) && $menu [ 'dashboard_list' ] == 1 && $menu [ 'before' ] == $view [ 'adminview' ])
{
$type = ComponentbuilderHelper :: imageInfo ( $menu [ 'settings' ] -> icon );
if ( $type )
{
2017-12-14 23:10:47 +00:00
$type = $type . " . " ;
2016-07-12 21:07:55 +00:00
// icon builder loader
2017-12-14 23:10:47 +00:00
$this -> iconBuilder [ $type . $menu [ 'settings' ] -> code ] = $menu [ 'settings' ] -> icon ;
2016-07-12 21:07:55 +00:00
}
else
{
$type = 'png.' ;
}
// build lang
2017-12-14 23:10:47 +00:00
$langName = $menu [ 'settings' ] -> name . '<br /><br />' ;
$langKey = $this -> langPrefix . '_DASHBOARD_' . $menu [ 'settings' ] -> CODE ;
2016-07-12 21:07:55 +00:00
// add to lang
$this -> langContent [ $this -> lang ][ $langKey ] = $langName ;
// set icon
if ( $counter == 0 )
{
$counter ++ ;
2017-12-14 23:10:47 +00:00
$icon .= " ' " . $type . $menu [ 'settings' ] -> code . " ' " ;
2016-07-12 21:07:55 +00:00
}
else
{
$counter ++ ;
2017-12-14 23:10:47 +00:00
$icon .= " , ' " . $type . $menu [ 'settings' ] -> code . " ' " ;
2016-07-12 21:07:55 +00:00
}
}
2017-12-14 23:10:47 +00:00
elseif ( ! isset ( $this -> customAdminAdded [ $menu [ 'settings' ] -> code ]) && $menu [ 'dashboard_list' ] == 1 && empty ( $menu [ 'before' ]))
2016-07-12 21:07:55 +00:00
{
$type = ComponentbuilderHelper :: imageInfo ( $menu [ 'settings' ] -> icon );
if ( $type )
{
2017-12-14 23:10:47 +00:00
$type = $type . " . " ;
2016-07-12 21:07:55 +00:00
// icon builder loader
2017-12-14 23:10:47 +00:00
$this -> iconBuilder [ $type . $menu [ 'settings' ] -> code ] = $menu [ 'settings' ] -> icon ;
2016-07-12 21:07:55 +00:00
}
else
{
$type = 'png.' ;
}
// build lang
2017-12-14 23:10:47 +00:00
$langName = $menu [ 'settings' ] -> name . '<br /><br />' ;
$langKey = $this -> langPrefix . '_DASHBOARD_' . $menu [ 'settings' ] -> CODE ;
2016-07-12 21:07:55 +00:00
// add to lang
$this -> langContent [ $this -> lang ][ $langKey ] = $langName ;
// set icon
2017-12-14 23:10:47 +00:00
$this -> lastCustomDashboardIcon [ $nr ] = " , ' " . $type . $menu [ 'settings' ] -> code . " ' " ;
2016-07-12 21:07:55 +00:00
}
}
}
2016-02-26 00:20:09 +00:00
// see if we should have custom menus
if ( isset ( $this -> componentData -> custommenus ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> custommenus ))
{
foreach ( $this -> componentData -> custommenus as $nr => $menu )
{
2017-12-14 23:10:47 +00:00
$nr = $nr + 100 ;
$nameList = ComponentbuilderHelper :: safeString ( $menu [ 'name_code' ]);
$nameUpper = ComponentbuilderHelper :: safeString ( $menu [ 'name_code' ], 'U' );
2016-02-26 00:20:09 +00:00
if ( $menu [ 'dashboard_list' ] == 1 && $view [ 'adminview' ] == $menu [ 'before' ])
{
if ( isset ( $menu [ 'link' ]) && ComponentbuilderHelper :: checkString ( $menu [ 'link' ]))
{
// TODO must look at adding custom links to icons aswell
return '' ;
}
else
{
2017-12-14 23:10:47 +00:00
$type = ComponentbuilderHelper :: imageInfo ( 'images/' . $menu [ 'icon' ]);
2016-02-26 00:20:09 +00:00
if ( $type )
{
2017-12-14 23:10:47 +00:00
$type = $type . " . " ;
2016-02-26 00:20:09 +00:00
// icon builder loader
2017-12-14 23:10:47 +00:00
$this -> iconBuilder [ $type . $nameList ] = 'images/' . $menu [ 'icon' ];
2016-02-26 00:20:09 +00:00
}
else
{
$type = 'png.' ;
}
// build lang
2017-12-14 23:10:47 +00:00
$langName = $menu [ 'name' ] . '<br /><br />' ;
$langKey = $this -> langPrefix . '_DASHBOARD_' . $nameUpper ;
2016-02-26 00:20:09 +00:00
// add to lang
$this -> langContent [ $this -> lang ][ $langKey ] = $langName ;
// set icon
if ( $counter == 0 )
{
$counter ++ ;
2017-12-14 23:10:47 +00:00
$icon .= " ' " . $type . $nameList . " ' " ;
2016-02-26 00:20:09 +00:00
}
else
{
$counter ++ ;
2017-12-14 23:10:47 +00:00
$icon .= " , ' " . $type . $nameList . " ' " ;
2016-02-26 00:20:09 +00:00
}
}
}
2017-12-14 23:10:47 +00:00
elseif ( $menu [ 'dashboard_list' ] == 1 && empty ( $menu [ 'before' ]))
2016-02-26 00:20:09 +00:00
{
if ( isset ( $menu [ 'link' ]) && ComponentbuilderHelper :: checkString ( $menu [ 'link' ]))
{
// TODO must look at adding custom links to icons aswell
return '' ;
}
else
{
2017-12-14 23:10:47 +00:00
$type = ComponentbuilderHelper :: imageInfo ( 'images/' . $menu [ 'icon' ]);
2016-02-26 00:20:09 +00:00
if ( $type )
{
2017-12-14 23:10:47 +00:00
$type = $type . " . " ;
2016-02-26 00:20:09 +00:00
// icon builder loader
2017-12-14 23:10:47 +00:00
$this -> iconBuilder [ $type . $nameList ] = 'images/' . $menu [ 'icon' ];
2016-02-26 00:20:09 +00:00
}
else
{
$type = 'png.' ;
}
// build lang
2017-12-14 23:10:47 +00:00
$langName = $menu [ 'name' ] . '<br /><br />' ;
$langKey = $this -> langPrefix . '_DASHBOARD_' . $nameUpper ;
2016-02-26 00:20:09 +00:00
// add to lang
$this -> langContent [ $this -> lang ][ $langKey ] = $langName ;
// set icon
2017-12-14 23:10:47 +00:00
$this -> lastCustomDashboardIcon [ $nr ] = " , ' " . $type . $nameList . " ' " ;
2016-02-26 00:20:09 +00:00
}
}
}
}
2016-07-12 21:07:55 +00:00
return $icon ;
2016-02-26 00:20:09 +00:00
}
public function setSubMenus ()
{
if ( isset ( $this -> componentData -> admin_views ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> admin_views ))
{
$menus = '' ;
// main lang prefix
2017-12-14 23:10:47 +00:00
$lang = $this -> langPrefix . '_SUBMENU' ;
2016-02-26 00:20:09 +00:00
// set the code name
$codeName = ComponentbuilderHelper :: safeString ( $this -> componentData -> name_code );
// set dashboard
2017-12-14 23:10:47 +00:00
$menus .= " JHtmlSidebar::addEntry(JText::_(' " . $lang . " _DASHBOARD'), 'index.php?option=com_ " . $codeName . " &view= " . $codeName . " ', \$ submenu === ' " . $codeName . " '); " ;
$this -> langContent [ $this -> lang ][ $lang . '_DASHBOARD' ] = 'Dashboard' ;
2016-02-26 00:20:09 +00:00
$catArray = array ();
foreach ( $this -> componentData -> admin_views as $view )
{
// set custom menu
2017-12-14 23:10:47 +00:00
$menus .= $this -> addCustomSubMenu ( $view , $codeName , $lang );
2017-10-30 13:08:02 +00:00
if ( isset ( $view [ 'submenu' ]) && $view [ 'submenu' ] == 1 )
2016-02-26 00:20:09 +00:00
{
// setup access defaults
$tab = " " ;
$nameSingle = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_single );
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $nameSingle ]))
{
$core = $this -> permissionCore [ $nameSingle ];
$coreLoad = true ;
}
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.access' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]) && in_array ( $nameSingle , $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$menus .= PHP_EOL . " \t \t if ( \$ user->authorise(' " . $core [ 'core.access' ] . " ', 'com_ " . $codeName . " ') && \$ user->authorise(' " . $nameSingle . " .submenu', 'com_ " . $codeName . " ')) " ;
$menus .= PHP_EOL . " \t \t { " ;
2016-02-26 00:20:09 +00:00
// add tab to lines to follow
$tab = " \t " ;
}
2017-12-14 23:10:47 +00:00
$nameList = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_list );
$nameUpper = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_list , 'U' );
$menus .= PHP_EOL . " \t \t " . $tab . " JHtmlSidebar::addEntry(JText::_(' " . $lang . " _ " . $nameUpper . " '), 'index.php?option=com_ " . $codeName . " &view= " . $nameList . " ', \$ submenu === ' " . $nameList . " '); " ;
$this -> langContent [ $this -> lang ][ $lang . " _ " . $nameUpper ] = $view [ 'settings' ] -> name_list ;
2016-02-26 00:20:09 +00:00
// check if category has another name
if ( isset ( $this -> catOtherName [ $nameList ]) && ComponentbuilderHelper :: checkArray ( $this -> catOtherName [ $nameList ]))
{
$otherViews = $this -> catOtherName [ $nameList ][ 'views' ];
}
else
{
$otherViews = $nameList ;
}
2017-12-14 23:10:47 +00:00
if ( isset ( $this -> categoryBuilder [ $nameList ]) && ComponentbuilderHelper :: checkArray ( $this -> categoryBuilder [ $nameList ]) && ! in_array ( $otherViews , $catArray ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$menus .= PHP_EOL . " \t \t " . $tab . " JHtmlSidebar::addEntry(JText::_(' " . $this -> categoryBuilder [ $nameList ][ 'name' ] . " '), 'index.php?option=com_categories&view=categories&extension=com_ " . $codeName . " . " . $otherViews . " ', \$ submenu === 'categories. " . $otherViews . " '); " ;
2016-02-26 00:20:09 +00:00
// make sure we add a category only once
$catArray [] = $otherViews ;
}
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.access' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]) && in_array ( $nameSingle , $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$menus .= PHP_EOL . " \t \t } " ;
2016-02-26 00:20:09 +00:00
}
}
}
if ( isset ( $this -> lastCustomSubMenu ) && ComponentbuilderHelper :: checkArray ( $this -> lastCustomSubMenu ))
{
foreach ( $this -> lastCustomSubMenu as $menu )
{
$menus .= $menu ;
}
unset ( $this -> lastCustomSubMenu );
}
return $menus ;
}
return false ;
}
2017-12-14 23:10:47 +00:00
public function addCustomSubMenu ( & $view , & $codeName , & $lang )
2016-02-26 00:20:09 +00:00
{
// see if we should have custom menus
2016-04-22 12:03:43 +00:00
$custom = '' ;
if ( isset ( $this -> componentData -> custom_admin_views ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> custom_admin_views ))
2016-02-26 00:20:09 +00:00
{
2016-04-22 12:03:43 +00:00
foreach ( $this -> componentData -> custom_admin_views as $nr => $menu )
2016-02-26 00:20:09 +00:00
{
2016-04-22 12:03:43 +00:00
if ( ! isset ( $this -> customAdminAdded [ $menu [ 'settings' ] -> code ]))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( $custom = $this -> setCustomAdminSubMenu ( $view , $codeName , $lang , $nr , $menu , 'customView' ))
2016-02-26 00:20:09 +00:00
{
2016-04-22 12:03:43 +00:00
break ;
2016-02-26 00:20:09 +00:00
}
}
2016-04-22 12:03:43 +00:00
}
}
if ( isset ( $this -> componentData -> custommenus ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> custommenus ))
{
foreach ( $this -> componentData -> custommenus as $nr => $menu )
{
2017-12-14 23:10:47 +00:00
if ( $custom2 = $this -> setCustomAdminSubMenu ( $view , $codeName , $lang , $nr , $menu , 'customMenu' ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$custom = $custom . $custom2 ;
2016-04-22 12:03:43 +00:00
break ;
2016-02-26 00:20:09 +00:00
}
}
}
2016-04-22 12:03:43 +00:00
return $custom ;
2016-02-26 00:20:09 +00:00
}
2017-12-14 23:10:47 +00:00
public function setCustomAdminSubMenu ( & $view , & $codeName , & $lang , & $nr , & $menu , $type )
2016-04-22 12:03:43 +00:00
{
2017-02-01 13:17:04 +00:00
if ( $type === 'customMenu' )
2016-04-22 12:03:43 +00:00
{
2017-12-14 23:10:47 +00:00
$name = $menu [ 'name' ];
$nameSingle = ComponentbuilderHelper :: safeString ( $menu [ 'name' ]);
$nameList = ComponentbuilderHelper :: safeString ( $menu [ 'name' ]);
$nameUpper = ComponentbuilderHelper :: safeString ( $menu [ 'name' ], 'U' );
2016-04-22 12:03:43 +00:00
}
2017-02-01 13:17:04 +00:00
elseif ( $type === 'customView' )
2016-04-22 12:03:43 +00:00
{
2017-12-14 23:10:47 +00:00
$name = $menu [ 'settings' ] -> name ;
$nameSingle = $menu [ 'settings' ] -> code ;
$nameList = $menu [ 'settings' ] -> code ;
$nameUpper = $menu [ 'settings' ] -> CODE ;
2016-04-22 12:03:43 +00:00
}
2017-12-14 23:10:47 +00:00
2016-04-22 12:03:43 +00:00
if ( $menu [ 'submenu' ] == 1 && $view [ 'adminview' ] == $menu [ 'before' ])
{
// setup access defaults
$tab = " " ;
2017-12-14 23:10:47 +00:00
2016-04-22 12:03:43 +00:00
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $nameSingle ]))
{
$core = $this -> permissionCore [ $nameSingle ];
$coreLoad = true ;
}
$custom = '' ;
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.access' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]) && in_array ( $nameSingle , $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]))
2016-04-22 12:03:43 +00:00
{
2017-12-14 23:10:47 +00:00
$custom .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Access control ( " . $core [ 'core.access' ] . " && " . $nameSingle . " .submenu). " ;
$custom .= PHP_EOL . " \t \t if ( \$ user->authorise(' " . $core [ 'core.access' ] . " ', 'com_ " . $codeName . " ') && \$ user->authorise(' " . $nameSingle . " .submenu', 'com_ " . $codeName . " ')) " ;
$custom .= PHP_EOL . " \t \t { " ;
2016-04-22 12:03:43 +00:00
// add tab to lines to follow
$tab = " \t " ;
}
else
{
2017-12-14 23:10:47 +00:00
$custom .= PHP_EOL . " \t \t // " . $this -> setLine ( __LINE__ ) . " Access control ( " . $nameSingle . " .submenu). " ;
$custom .= PHP_EOL . " \t \t if ( \$ user->authorise(' " . $nameSingle . " .submenu', 'com_ " . $codeName . " ')) " ;
$custom .= PHP_EOL . " \t \t { " ;
2016-04-22 12:03:43 +00:00
// add tab to lines to follow
$tab = " \t " ;
}
if ( isset ( $menu [ 'link' ]) && ComponentbuilderHelper :: checkString ( $menu [ 'link' ]))
{
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_' . $nameUpper ] = $name ;
2016-04-22 12:03:43 +00:00
// add custom menu
2017-12-14 23:10:47 +00:00
$custom .= PHP_EOL . " \t \t " . $tab . " JHtmlSidebar::addEntry(JText::_(' " . $lang . " _ " . $nameUpper . " '), ' " . $menu [ 'link' ] . " ', \$ submenu === ' " . $nameList . " '); " ;
2016-04-22 12:03:43 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_' . $nameUpper ] = $name ;
2016-04-22 12:03:43 +00:00
// add custom menu
2017-12-14 23:10:47 +00:00
$custom .= PHP_EOL . " \t \t " . $tab . " JHtmlSidebar::addEntry(JText::_(' " . $lang . " _ " . $nameUpper . " '), 'index.php?option=com_ " . $codeName . " &view= " . $nameList . " ', \$ submenu === ' " . $nameList . " '); " ;
2016-04-22 12:03:43 +00:00
}
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
$custom .= PHP_EOL . " \t \t } " ;
2016-04-22 12:03:43 +00:00
return $custom ;
}
2017-12-14 23:10:47 +00:00
elseif ( $menu [ 'submenu' ] == 1 && empty ( $menu [ 'before' ]))
2016-04-22 12:03:43 +00:00
{
// setup access defaults
$tab = " " ;
2017-12-14 23:10:47 +00:00
$nameSingle = ComponentbuilderHelper :: safeString ( $name );
2016-04-22 12:03:43 +00:00
$coreLoad = false ;
if ( isset ( $this -> permissionCore [ $nameSingle ]))
{
$core = $this -> permissionCore [ $nameSingle ];
$coreLoad = true ;
}
$this -> lastCustomSubMenu [ $nr ] = '' ;
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
if ( $coreLoad && isset ( $core [ 'core.access' ]) && isset ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]) && ComponentbuilderHelper :: checkArray ( $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]) && in_array ( $nameSingle , $this -> permissionBuilder [ 'global' ][ $core [ 'core.access' ]]))
2016-04-22 12:03:43 +00:00
{
2017-12-14 23:10:47 +00:00
$this -> lastCustomSubMenu [ $nr ] .= PHP_EOL . " \t \t if ( \$ user->authorise(' " . $core [ 'core.access' ] . " ', 'com_ " . $codeName . " ') && \$ user->authorise(' " . $nameSingle . " .submenu', 'com_ " . $codeName . " ')) " ;
$this -> lastCustomSubMenu [ $nr ] .= PHP_EOL . " \t \t { " ;
2016-04-22 12:03:43 +00:00
// add tab to lines to follow
$tab = " \t " ;
}
else
{
2017-12-14 23:10:47 +00:00
$this -> lastCustomSubMenu [ $nr ] .= PHP_EOL . " \t \t if ( \$ user->authorise(' " . $nameSingle . " .submenu', 'com_ " . $codeName . " ')) " ;
$this -> lastCustomSubMenu [ $nr ] .= PHP_EOL . " \t \t { " ;
2016-04-22 12:03:43 +00:00
// add tab to lines to follow
$tab = " \t " ;
}
if ( isset ( $menu [ 'link' ]) && ComponentbuilderHelper :: checkString ( $menu [ 'link' ]))
{
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_' . $nameUpper ] = $name ;
2016-04-22 12:03:43 +00:00
// add custom menu
2017-12-14 23:10:47 +00:00
$this -> lastCustomSubMenu [ $nr ] .= PHP_EOL . " \t \t " . $tab . " JHtmlSidebar::addEntry(JText::_(' " . $lang . " _ " . $nameUpper . " '), ' " . $menu [ 'link' ] . " ', \$ submenu === ' " . $nameList . " '); " ;
2016-04-22 12:03:43 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_' . $nameUpper ] = $name ;
2016-04-22 12:03:43 +00:00
// add custom menu
2017-12-14 23:10:47 +00:00
$this -> lastCustomSubMenu [ $nr ] .= PHP_EOL . " \t \t " . $tab . " JHtmlSidebar::addEntry(JText::_(' " . $lang . " _ " . $nameUpper . " '), 'index.php?option=com_ " . $codeName . " &view= " . $nameList . " ', \$ submenu === ' " . $nameList . " '); " ;
2016-04-22 12:03:43 +00:00
}
// check if the item has permissions.
2017-12-14 23:10:47 +00:00
$this -> lastCustomSubMenu [ $nr ] .= PHP_EOL . " \t \t } " ;
2016-04-22 12:03:43 +00:00
}
return false ;
}
2016-02-26 00:20:09 +00:00
public function setMainMenus ()
{
if ( isset ( $this -> componentData -> admin_views ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> admin_views ))
{
$menus = '' ;
// main lang prefix
2017-12-14 23:10:47 +00:00
$lang = $this -> langPrefix . '_MENU' ;
2016-02-26 00:20:09 +00:00
// set the code name
$codeName = ComponentbuilderHelper :: safeString ( $this -> componentData -> name_code );
// set main menu name to lang
2017-12-14 23:10:47 +00:00
$this -> langContent [ 'adminsys' ][ $lang ] = '» ' . $this -> componentData -> name ;
2016-02-26 00:20:09 +00:00
foreach ( $this -> componentData -> admin_views as $view )
{
// set custom menu
2017-12-14 23:10:47 +00:00
$menus .= $this -> addCustomMainMenu ( $view , $codeName , $lang );
2017-10-30 13:08:02 +00:00
if ( isset ( $view [ 'mainmenu' ]) && $view [ 'mainmenu' ] == 1 )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$nameList = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_list );
$nameUpper = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_list , 'U' );
$menus .= PHP_EOL . " \t \t \t " . '<menu option="com_' . $codeName . '" view="' . $nameList . '">' . $lang . '_' . $nameUpper . '</menu>' ;
$this -> langContent [ 'adminsys' ][ $lang . '_' . $nameUpper ] = $view [ 'settings' ] -> name_list ;
2016-02-26 00:20:09 +00:00
}
}
if ( isset ( $this -> lastCustomMainMenu ) && ComponentbuilderHelper :: checkArray ( $this -> lastCustomMainMenu ))
{
foreach ( $this -> lastCustomMainMenu as $menu )
{
$menus .= $menu ;
}
unset ( $this -> lastCustomMainMenu );
}
return $menus ;
}
return false ;
}
2017-12-14 23:10:47 +00:00
public function addCustomMainMenu ( & $view , & $codeName , & $lang )
2016-02-26 00:20:09 +00:00
{
2016-07-12 21:07:55 +00:00
$customMenu = '' ;
// see if we should have custom admin views
if ( isset ( $this -> componentData -> custom_admin_views ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> custom_admin_views ))
{
foreach ( $this -> componentData -> custom_admin_views as $nr => $menu )
{
if ( ! isset ( $this -> customAdminAdded [ $menu [ 'settings' ] -> code ]))
{
if ( $menu [ 'mainmenu' ] == 1 && $view [ 'adminview' ] == $menu [ 'before' ])
{
2017-12-14 23:10:47 +00:00
$this -> langContent [ 'adminsys' ][ $lang . '_' . $menu [ 'settings' ] -> CODE ] = $menu [ 'settings' ] -> name ;
2016-07-12 21:07:55 +00:00
// add custom menu
2017-12-14 23:10:47 +00:00
$customMenu .= PHP_EOL . " \t \t \t " . '<menu option="com_' . $codeName . '" view="' . $menu [ 'settings' ] -> code . '">' . $lang . '_' . $menu [ 'settings' ] -> CODE . '</menu>' ;
2016-07-12 21:07:55 +00:00
}
2017-12-14 23:10:47 +00:00
elseif ( $menu [ 'mainmenu' ] == 1 && empty ( $menu [ 'before' ]))
2016-07-12 21:07:55 +00:00
{
2017-12-14 23:10:47 +00:00
$this -> langContent [ 'adminsys' ][ $lang . '_' . $menu [ 'settings' ] -> CODE ] = $menu [ 'settings' ] -> name ;
2016-07-12 21:07:55 +00:00
// add custom menu
2017-12-14 23:10:47 +00:00
$this -> lastCustomMainMenu [ $nr ] = PHP_EOL . " \t \t \t " . '<menu option="com_' . $codeName . '" view="' . $menu [ 'settings' ] -> code . '">' . $lang . '_' . $menu [ 'settings' ] -> CODE . '</menu>' ;
2016-07-12 21:07:55 +00:00
}
}
}
}
2016-02-26 00:20:09 +00:00
// see if we should have custom menus
if ( isset ( $this -> componentData -> custommenus ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> custommenus ))
{
foreach ( $this -> componentData -> custommenus as $nr => $menu )
{
2016-07-12 21:07:55 +00:00
$nr = $nr + 100 ;
2016-02-26 00:20:09 +00:00
if ( $menu [ 'mainmenu' ] == 1 && $view [ 'adminview' ] == $menu [ 'before' ])
{
if ( isset ( $menu [ 'link' ]) && ComponentbuilderHelper :: checkString ( $menu [ 'link' ]))
{
2017-12-14 23:10:47 +00:00
$nameList = ComponentbuilderHelper :: safeString ( $menu [ 'name' ]);
$nameUpper = ComponentbuilderHelper :: safeString ( $menu [ 'name' ], 'U' );
$this -> langContent [ 'adminsys' ][ $lang . '_' . $nameUpper ] = $menu [ 'name' ];
2017-12-10 19:20:29 +00:00
// urlencode
2017-12-14 23:10:47 +00:00
$menu [ 'link' ] = htmlspecialchars ( $menu [ 'link' ], ENT_XML1 , 'UTF-8' );
2016-02-26 00:20:09 +00:00
// add custom menu
2017-12-14 23:10:47 +00:00
$customMenu .= PHP_EOL . " \t \t \t " . '<menu link="' . $menu [ 'link' ] . '">' . $lang . '_' . $nameUpper . '</menu>' ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$nameList = ComponentbuilderHelper :: safeString ( $menu [ 'name_code' ]);
$nameUpper = ComponentbuilderHelper :: safeString ( $menu [ 'name_code' ], 'U' );
$this -> langContent [ 'adminsys' ][ $lang . '_' . $nameUpper ] = $menu [ 'name' ];
2016-02-26 00:20:09 +00:00
// add custom menu
2017-12-14 23:10:47 +00:00
$customMenu .= PHP_EOL . " \t \t \t " . '<menu option="com_' . $codeName . '" view="' . $nameList . '">' . $lang . '_' . $nameUpper . '</menu>' ;
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
elseif ( $menu [ 'mainmenu' ] == 1 && empty ( $menu [ 'before' ]))
2016-02-26 00:20:09 +00:00
{
if ( isset ( $menu [ 'link' ]) && ComponentbuilderHelper :: checkString ( $menu [ 'link' ]))
{
2017-12-14 23:10:47 +00:00
$nameList = ComponentbuilderHelper :: safeString ( $menu [ 'name' ]);
$nameUpper = ComponentbuilderHelper :: safeString ( $menu [ 'name' ], 'U' );
$this -> langContent [ 'adminsys' ][ $lang . '_' . $nameUpper ] = $menu [ 'name' ];
2017-12-10 19:20:29 +00:00
// urlencode
2017-12-14 23:10:47 +00:00
$menu [ 'link' ] = htmlspecialchars ( $menu [ 'link' ], ENT_XML1 , 'UTF-8' );
2016-02-26 00:20:09 +00:00
// add custom menu
2017-12-14 23:10:47 +00:00
$this -> lastCustomMainMenu [ $nr ] = PHP_EOL . " \t \t \t " . '<menu link="' . $menu [ 'link' ] . '">' . $lang . '_' . $nameUpper . '</menu>' ;
2016-02-26 00:20:09 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$nameList = ComponentbuilderHelper :: safeString ( $menu [ 'name_code' ]);
$nameUpper = ComponentbuilderHelper :: safeString ( $menu [ 'name_code' ], 'U' );
$this -> langContent [ 'adminsys' ][ $lang . '_' . $nameUpper ] = $menu [ 'name' ];
2016-02-26 00:20:09 +00:00
// add custom menu
2017-12-14 23:10:47 +00:00
$this -> lastCustomMainMenu [ $nr ] = PHP_EOL . " \t \t \t " . '<menu option="com_' . $codeName . '" view="' . $nameList . '">' . $lang . '_' . $nameUpper . '</menu>' ;
2016-02-26 00:20:09 +00:00
}
}
}
}
2016-07-12 21:07:55 +00:00
return $customMenu ;
2016-02-26 00:20:09 +00:00
}
public function setConfigFieldsets ( $timer = 0 )
{
// main lang prefix
2017-12-14 23:10:47 +00:00
$lang = $this -> langPrefix . '_CONFIG' ;
2016-02-26 00:20:09 +00:00
if ( 1 == $timer ) // this is before the admin views are build
{
// start loading Global params
$autorName = ComponentbuilderHelper :: htmlEscape ( $this -> componentData -> author );
$autorEmail = ComponentbuilderHelper :: htmlEscape ( $this -> componentData -> email );
2017-12-14 23:10:47 +00:00
$this -> extensionsParams [] = '"autorName":"' . $autorName . '","autorEmail":"' . $autorEmail . '"' ;
2016-02-26 00:20:09 +00:00
// set the custom fields
if ( isset ( $this -> componentData -> config ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> config ))
{
$component = ComponentbuilderHelper :: safeString ( $this -> componentData -> name_code );
$viewName = 'config' ;
$listViewName = 'configs' ;
$placeholders = array (
2017-12-14 23:10:47 +00:00
'###component###' => $component ,
'###view###' => $viewName ,
'###views###' => $listViewName );
2016-02-26 00:20:09 +00:00
$spacerCounter = 'a' ;
$view = '' ;
$viewType = 0 ;
// set the custom table key
$dbkey = 'g' ;
foreach ( $this -> componentData -> config as $field )
{
2017-12-10 19:17:26 +00:00
$newxmlField = $this -> setDynamicField ( $field , $view , $viewType , $lang , $viewName , $listViewName , $spacerCounter , $placeholders , $dbkey , false );
// tmp hack untill this whole area is also done in xml (TODO)
if ( isset ( $newxmlField -> fieldXML ))
{
$xmlField = dom_import_simplexml ( $newxmlField -> fieldXML );
2017-12-14 23:10:47 +00:00
$xmlField = PHP_EOL . " \t <!-- " . $newxmlField -> comment . ' -->' . PHP_EOL . " \t " . $this -> xmlPrettyPrint ( $xmlField , 'field' );
2017-12-10 19:17:26 +00:00
}
if ( isset ( $xmlField ) && ComponentbuilderHelper :: checkString ( $xmlField ))
2016-02-26 00:20:09 +00:00
{
$this -> configFieldSetsCustomField [ $field [ 'tabname' ]][] = $xmlField ;
// set global params to db on install
2017-12-14 23:10:47 +00:00
$fieldName = ComponentbuilderHelper :: safeString ( ComponentbuilderHelper :: getBetween ( $xmlField , 'name="' , '"' ));
$fieldDefault = ComponentbuilderHelper :: getBetween ( $xmlField , 'default="' , '"' );
2016-02-26 00:20:09 +00:00
if ( isset ( $field [ 'custom_value' ]) && ComponentbuilderHelper :: checkString ( $field [ 'custom_value' ]))
{
2017-08-12 11:47:25 +00:00
// add array if found
if (( strpos ( $field [ 'custom_value' ], '["' ) !== false ) && ( strpos ( $field [ 'custom_value' ], '"]' ) !== false ))
{
// load the Global checkin defautls
2017-12-14 23:10:47 +00:00
$this -> extensionsParams [] = '"' . $fieldName . '":' . $field [ 'custom_value' ];
2017-08-12 11:47:25 +00:00
}
else
{
// load the Global checkin defautls
2017-12-14 23:10:47 +00:00
$this -> extensionsParams [] = '"' . $fieldName . '":"' . $field [ 'custom_value' ] . '"' ;
2017-08-12 11:47:25 +00:00
}
2016-02-26 00:20:09 +00:00
}
elseif ( ComponentbuilderHelper :: checkString ( $fieldDefault ))
{
// load the Global checkin defautls
2017-12-14 23:10:47 +00:00
$this -> extensionsParams [] = '"' . $fieldName . '":"' . $fieldDefault . '"' ;
2016-02-26 00:20:09 +00:00
}
}
}
}
// first run we must set the globals
2017-12-14 23:10:47 +00:00
$this -> setGlobalConfigFieldsets ( $lang , $autorName , $autorEmail );
2016-02-26 00:20:09 +00:00
$this -> setSiteControlConfigFieldsets ( $lang );
}
elseif ( 2 == $timer ) // this is after the admin views are build
{
// these field sets can only be added after admin view is build
$this -> setGroupControlConfigFieldsets ( $lang );
// these can be added anytime really (but looks best after groups
$this -> setUikitConfigFieldsets ( $lang );
$this -> setGooglechartConfigFieldsets ( $lang );
2016-12-22 21:32:13 +00:00
$this -> setEmailHelperConfigFieldsets ( $lang );
2016-02-26 00:20:09 +00:00
$this -> setEncryptionConfigFieldsets ( $lang );
// these are the coustom settings
$this -> setCustomControlConfigFieldsets ( $lang );
}
// we cad add more event (timers as we need)
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
public function setSiteControlConfigFieldsets ( $lang )
{
$front_end = array ();
// do quick build of front-end views
if ( isset ( $this -> componentData -> site_views ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> site_views ))
{
// load the names only to link the page params
foreach ( $this -> componentData -> site_views as $siteView )
{
// now load the view name to the front-end array
$front_end [] = $siteView [ 'settings' ] -> name ;
}
}
// add frontend view stuff including menus
if ( isset ( $this -> configFieldSetsCustomField ) && ComponentbuilderHelper :: checkArray ( $this -> configFieldSetsCustomField ))
{
foreach ( $this -> configFieldSetsCustomField as $tab => & $tabFields )
{
2017-12-14 23:10:47 +00:00
$tabCode = ComponentbuilderHelper :: safeString ( $tab ) . '_custom_config' ;
$tabUpper = ComponentbuilderHelper :: safeString ( $tab , 'U' );
2016-02-26 00:20:09 +00:00
$tabLower = ComponentbuilderHelper :: safeString ( $tab );
2017-03-08 04:49:54 +00:00
// load the request id setters for menu views
2017-12-14 23:10:47 +00:00
$viewRequest = 'name="' . $tabLower . '_request_id' ;
foreach ( $tabFields as $et => $id_field )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( strpos ( $id_field , $viewRequest ) !== false )
2016-02-26 00:20:09 +00:00
{
2017-03-08 04:49:54 +00:00
$this -> setRequestValues ( $tabLower , $id_field , $viewRequest , 'id' , 'hasIdRequest' );
2016-02-26 00:20:09 +00:00
unset ( $tabFields [ $et ]);
}
2017-12-14 23:10:47 +00:00
elseif ( strpos ( $id_field , '_request_id' ) !== false )
2016-02-26 00:20:09 +00:00
{
// not loaded to a tab "view" name
2017-12-14 23:10:47 +00:00
$_viewRequest = ComponentbuilderHelper :: getBetween ( $id_field , 'name="' , '_request_id' );
$searchIdKe = 'name="' . $_viewRequest . '_request_id' ;
2017-03-08 04:49:54 +00:00
$this -> setRequestValues ( $_viewRequest , $id_field , $searchIdKe , 'id' , 'hasIdRequest' );
2016-02-26 00:20:09 +00:00
unset ( $tabFields [ $et ]);
}
}
2017-03-08 04:49:54 +00:00
// load the request catid setters for menu views
2017-12-14 23:10:47 +00:00
$viewRequestC = 'name="' . $tabLower . '_request_catid' ;
foreach ( $tabFields as $ci => $catid_field )
2017-03-08 04:49:54 +00:00
{
2017-12-14 23:10:47 +00:00
if ( strpos ( $catid_field , $viewRequestC ) !== false )
2017-03-08 04:49:54 +00:00
{
2017-12-14 23:10:47 +00:00
2017-03-08 04:49:54 +00:00
$this -> setRequestValues ( $tabLower , $catid_field , $viewRequestC , 'catid' , 'hasCatIdRequest' );
unset ( $tabFields [ $ci ]);
}
2017-12-14 23:10:47 +00:00
elseif ( strpos ( $catid_field , '_request_catid' ) !== false )
2017-03-08 04:49:54 +00:00
{
// not loaded to a tab "view" name
2017-12-14 23:10:47 +00:00
$_viewRequestC = ComponentbuilderHelper :: getBetween ( $catid_field , 'name="' , '_request_catid' );
$searchCatidKe = 'name="' . $_viewRequestC . '_request_catid' ;
2017-03-08 04:49:54 +00:00
$this -> setRequestValues ( $_viewRequestC , $catid_field , $searchCatidKe , 'catid' , 'hasCatIdRequest' );
unset ( $tabFields [ $ci ]);
}
}
2016-02-26 00:20:09 +00:00
// load the global menu setters for single fields
2017-12-14 23:10:47 +00:00
$menuSetter = $tabLower . '_menu' ;
2016-02-26 00:20:09 +00:00
$pageSettings = array ();
2017-12-14 23:10:47 +00:00
foreach ( $tabFields as $ct => $field )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
if ( strpos ( $field , $menuSetter ) !== false )
2016-02-26 00:20:09 +00:00
{
// set the values needed to insure route is done correclty
$this -> hasMenuGlobal [ $tabLower ] = $menuSetter ;
}
2017-12-14 23:10:47 +00:00
elseif ( strpos ( $field , '_menu"' ) !== false )
2016-02-26 00:20:09 +00:00
{
// not loaded to a tab "view" name
2017-12-14 23:10:47 +00:00
$_tabLower = ComponentbuilderHelper :: getBetween ( $field , 'name="' , '_menu"' );
2016-02-26 00:20:09 +00:00
// set the values needed to insure route is done correclty
2017-12-14 23:10:47 +00:00
$this -> hasMenuGlobal [ $_tabLower ] = $_tabLower . '_menu' ;
2016-02-26 00:20:09 +00:00
}
else
{
$pageSettings [ $ct ] = $field ;
}
}
// insure we load the needed params
2017-12-14 23:10:47 +00:00
if ( in_array ( $tab , $front_end ))
2016-02-26 00:20:09 +00:00
{
$this -> frontEndParams [ $tab ] = $pageSettings ;
}
}
}
}
2017-12-14 23:10:47 +00:00
2017-03-08 04:49:54 +00:00
protected function setRequestValues ( $view , $field , $search , $target , $store )
{
$key = ComponentbuilderHelper :: getBetween ( $field , $search , '"' );
if ( ! ComponentbuilderHelper :: checkString ( $key ))
{
// is not having special var
$key = $target ;
// update field
2017-12-14 23:10:47 +00:00
$field = str_replace ( $search . '"' , 'name="' . $key . '"' , $field );
2017-03-08 04:49:54 +00:00
}
else
{
// update field
2017-12-14 23:10:47 +00:00
$field = str_replace ( $search . $key . '"' , 'name="' . $key . '"' , $field );
2017-03-08 04:49:54 +00:00
}
if ( ! isset ( $this -> { $store }[ $view ]))
{
$this -> { $store }[ $view ] = array ();
}
// set the values needed for view requests to be made
$this -> { $store }[ $view ][ $key ] = $field ;
}
2016-02-26 00:20:09 +00:00
public function setCustomControlConfigFieldsets ( $lang )
{
// add custom new global fields set
if ( isset ( $this -> configFieldSetsCustomField ) && ComponentbuilderHelper :: checkArray ( $this -> configFieldSetsCustomField ))
{
foreach ( $this -> configFieldSetsCustomField as $tab => $tabFields )
{
2017-12-14 23:10:47 +00:00
$tabCode = ComponentbuilderHelper :: safeString ( $tab ) . '_custom_config' ;
$tabUpper = ComponentbuilderHelper :: safeString ( $tab , 'U' );
2016-02-26 00:20:09 +00:00
$tabLower = ComponentbuilderHelper :: safeString ( $tab );
// setup lang
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_' . $tabUpper ] = $tab ;
2016-02-26 00:20:09 +00:00
// start field set
$this -> configFieldSets [] = " \t <fieldset " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . 'name="' . $tabCode . '"' ;
$this -> configFieldSets [] = " \t \t " . 'label="' . $lang . '_' . $tabUpper . '">' ;
2017-07-20 23:26:48 +00:00
// remove display targeted fields
$bucket = array ();
foreach ( $tabFields as $tabField )
{
$display = ComponentbuilderHelper :: getBetween ( $tabField , 'display="' , '"' );
if ( ! ComponentbuilderHelper :: checkString ( $display ) || $display === 'config' )
{
// remove this display since it is not used in Joomla
$bucket [] = str_replace ( 'display="config"' , '' , $tabField );
}
}
2016-02-26 00:20:09 +00:00
// set the fields
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = implode ( " \t \t " , $bucket );
2016-02-26 00:20:09 +00:00
// close field set
$this -> configFieldSets [] = " \t </fieldset> " ;
// remove after loading
unset ( $this -> configFieldSetsCustomField [ $tab ]);
}
}
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
public function setGroupControlConfigFieldsets ( $lang )
{
// start loading Group control params if needed
if ( isset ( $this -> setGroupControl ) && ComponentbuilderHelper :: checkArray ( $this -> setGroupControl ))
{
// start building field set for config
$this -> configFieldSets [] = " \t <fieldset " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . 'name="group_config"' ;
$this -> configFieldSets [] = " \t \t " . 'label="' . $lang . '_GROUPS_LABEL"' ;
$this -> configFieldSets [] = " \t \t " . 'description="' . $lang . '_GROUPS_DESC">' ;
2016-02-26 00:20:09 +00:00
// setup lang
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_GROUPS_LABEL' ] = " Target Groups " ;
$this -> langContent [ $this -> lang ][ $lang . '_GROUPS_DESC' ] = " The Parameters for the targeted groups are set here. " ;
$this -> langContent [ $this -> lang ][ $lang . '_TARGET_GROUP_DESC' ] = " Set the group/s being targeted by this user type. " ;
2016-02-26 00:20:09 +00:00
foreach ( $this -> setGroupControl as $selector => $label )
{
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="' . $selector . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="usergroup"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $label . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $lang . '_TARGET_GROUP_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'multiple="true"' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
// set params defaults
2017-12-14 23:10:47 +00:00
$this -> extensionsParams [] = '"' . $selector . '":["2"]' ;
2016-02-26 00:20:09 +00:00
}
// add custom Target Groups fields
if ( isset ( $this -> configFieldSetsCustomField [ 'Target Groups' ]) && ComponentbuilderHelper :: checkArray ( $this -> configFieldSetsCustomField [ 'Target Groups' ]))
{
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = implode ( " \t \t " , $this -> configFieldSetsCustomField [ 'Target Groups' ]);
2016-02-26 00:20:09 +00:00
unset ( $this -> configFieldSetsCustomField [ 'Target Groups' ]);
}
2016-04-22 12:03:43 +00:00
// close that fieldse
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t </fieldset> " ;
}
}
2016-04-22 12:03:43 +00:00
/**
* @ param $lang
* @ param $autorName
* @ param $autorEmail
*/
public function setGlobalConfigFieldsets ( $lang , $autorName , $autorEmail )
2016-02-26 00:20:09 +00:00
{
2016-04-22 12:03:43 +00:00
// set component name
$component = ComponentbuilderHelper :: safeString ( $this -> componentData -> name_code );
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
// start building field set for config
$this -> configFieldSets [] = '<fieldset' ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . 'addrulepath="/administrator/components/com_' . $component . '/models/rules"' ;
$this -> configFieldSets [] = " \t \t " . 'addfieldpath="/administrator/components/com_' . $component . '/models/fields"' ;
$this -> configFieldSets [] = " \t \t " . 'name="global_config"' ;
$this -> configFieldSets [] = " \t \t " . 'label="' . $lang . '_GLOBAL_LABEL"' ;
$this -> configFieldSets [] = " \t \t " . 'description="' . $lang . '_GLOBAL_DESC">' ;
2016-02-26 00:20:09 +00:00
// set application update License Key
if ( $this -> componentData -> add_license && 1 != $this -> componentData -> license_type )
{
// set licence type switch
switch ( $this -> componentData -> license_type )
{
case 2 :
// for updates
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_LICENSE_KEY_NOTE_LABEL' ] = " Your License Key " ;
$this -> langContent [ $this -> lang ][ $lang . '_LICENSE_KEY_NOTE_DESC' ] = " To get updates you must add the license key here that you recieved from " . $this -> componentData -> companyname ;
2016-02-26 00:20:09 +00:00
// set the field
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field type="note" name="license_key_note" class="alert alert-info" label="' . $lang . '_LICENSE_KEY_NOTE_LABEL" description="' . $lang . '_LICENSE_KEY_NOTE_DESC" />' ;
2016-02-26 00:20:09 +00:00
break ;
case 3 :
// with vdm to lock down ownership
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_LICENSE_KEY_NOTE_LABEL' ] = " Your License Key " ;
$this -> langContent [ $this -> lang ][ $lang . '_LICENSE_KEY_NOTE_DESC' ] = " To use this component you must add the license key here that you recieved from " . $this -> componentData -> companyname ;
2016-02-26 00:20:09 +00:00
// set the field
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field type="note" name="license_key_note" class="alert alert-info" label="' . $lang . '_LICENSE_KEY_NOTE_LABEL" description="' . $lang . '_LICENSE_KEY_NOTE_DESC" />' ;
2016-02-26 00:20:09 +00:00
break ;
}
// setup lang
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_LICENSE_KEY_LABEL' ] = " License Key " ;
$this -> langContent [ $this -> lang ][ $lang . '_LICENSE_KEY_DESC' ] = " Add your license key here. " ;
2016-02-26 00:20:09 +00:00
// add the field
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="license_key"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="text"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $lang . '_LICENSE_KEY_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $lang . '_LICENSE_KEY_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'size="60"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default=""' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field type="spacer" name="spacerLicense" hr="true" />' ;
2016-02-26 00:20:09 +00:00
}
// setup lang
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_GLOBAL_LABEL' ] = " Global " ;
$this -> langContent [ $this -> lang ][ $lang . '_GLOBAL_DESC' ] = " The Global Parameters " ;
2016-02-26 00:20:09 +00:00
// add auto checin if required
if ( $this -> addCheckin )
{
$this -> configFieldSets [] = " \t \t <field " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t " . 'name="check_in"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="list"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default="0"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $lang . '_CHECK_TIMER_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $lang . '_CHECK_TIMER_DESC">' ;
$this -> configFieldSets [] = " \t \t \t " . '<option' ;
$this -> configFieldSets [] = " \t \t \t \t " . 'value="-5 hours">' . $lang . '_CHECK_TIMER_OPTION_ONE</option>' ;
$this -> configFieldSets [] = " \t \t \t " . '<option' ;
$this -> configFieldSets [] = " \t \t \t \t " . 'value="-12 hours">' . $lang . '_CHECK_TIMER_OPTION_TWO</option>' ;
$this -> configFieldSets [] = " \t \t \t " . '<option' ;
$this -> configFieldSets [] = " \t \t \t \t " . 'value="-1 day">' . $lang . '_CHECK_TIMER_OPTION_THREE</option>' ;
$this -> configFieldSets [] = " \t \t \t " . '<option' ;
$this -> configFieldSets [] = " \t \t \t \t " . 'value="-2 day">' . $lang . '_CHECK_TIMER_OPTION_FOUR</option>' ;
$this -> configFieldSets [] = " \t \t \t " . '<option' ;
$this -> configFieldSets [] = " \t \t \t \t " . 'value="-1 week">' . $lang . '_CHECK_TIMER_OPTION_FIVE</option>' ;
$this -> configFieldSets [] = " \t \t \t " . '<option' ;
$this -> configFieldSets [] = " \t \t \t \t " . 'value="0">' . $lang . '_CHECK_TIMER_OPTION_SIX</option>' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t </field> " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field type="spacer" name="spacerAuthor" hr="true" />' ;
2016-02-26 00:20:09 +00:00
// setup lang
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_CHECK_TIMER_LABEL' ] = " Check in timer " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHECK_TIMER_DESC' ] = " Set the intervals for the auto checkin fuction of tables that checks out the items to an user. " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHECK_TIMER_OPTION_ONE' ] = " Every five hours " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHECK_TIMER_OPTION_TWO' ] = " Every twelve hours " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHECK_TIMER_OPTION_THREE' ] = " Once a day " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHECK_TIMER_OPTION_FOUR' ] = " Every second day " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHECK_TIMER_OPTION_FIVE' ] = " Once a week " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHECK_TIMER_OPTION_SIX' ] = " Never " ;
2016-02-26 00:20:09 +00:00
// load the Global checkin defautls
2017-08-22 22:17:19 +00:00
$this -> extensionsParams [] = '"check_in":"-1 day"' ;
2016-02-26 00:20:09 +00:00
}
// set history control
if ( $this -> setTagHistory )
{
$this -> configFieldSets [] = " \t \t <field " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t " . 'name="save_history"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="radio"' ;
$this -> configFieldSets [] = " \t \t \t " . 'class="btn-group btn-group-yesno"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default="1"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="JGLOBAL_SAVE_HISTORY_OPTIONS_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="JGLOBAL_SAVE_HISTORY_OPTIONS_DESC"' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t " . '<option value="1">JYES</option>' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="0">JNO</option>' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t </field> " ;
$this -> configFieldSets [] = " \t \t <field " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t " . 'name="history_limit"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="text"' ;
$this -> configFieldSets [] = " \t \t \t " . 'filter="integer"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="JGLOBAL_HISTORY_LIMIT_OPTIONS_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="JGLOBAL_HISTORY_LIMIT_OPTIONS_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default="10"' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field type="spacer" name="spacerHistory" hr="true" />' ;
2016-02-26 00:20:09 +00:00
// load the Global checkin defautls
2017-08-22 22:17:19 +00:00
$this -> extensionsParams [] = '"save_history":"1","history_limit":"10"' ;
2016-02-26 00:20:09 +00:00
}
// add custom global fields
if ( isset ( $this -> configFieldSetsCustomField [ 'Global' ]) && ComponentbuilderHelper :: checkArray ( $this -> configFieldSetsCustomField [ 'Global' ]))
{
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = implode ( " \t \t " , $this -> configFieldSetsCustomField [ 'Global' ]);
2016-02-26 00:20:09 +00:00
unset ( $this -> configFieldSetsCustomField [ 'Global' ]);
}
// set the author details
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="autorTitle"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="spacer"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $lang . '_AUTHOR"' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="autorName"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="text"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $lang . '_AUTHOR_NAME_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $lang . '_AUTHOR_NAME_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'size="60"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default="' . $autorName . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'readonly="true"' ;
$this -> configFieldSets [] = " \t \t \t " . 'class="readonly"' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="autorEmail"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="email"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $lang . '_AUTHOR_EMAIL_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $lang . '_AUTHOR_EMAIL_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'size="60"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default="' . $autorEmail . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'readonly="true"' ;
$this -> configFieldSets [] = " \t \t \t " . 'class="readonly"' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
// setup lang
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_AUTHOR' ] = " Author Info " ;
$this -> langContent [ $this -> lang ][ $lang . '_AUTHOR_NAME_LABEL' ] = " Author Name " ;
$this -> langContent [ $this -> lang ][ $lang . '_AUTHOR_NAME_DESC' ] = " The name of the author of this component. " ;
$this -> langContent [ $this -> lang ][ $lang . '_AUTHOR_EMAIL_LABEL' ] = " Author Email " ;
$this -> langContent [ $this -> lang ][ $lang . '_AUTHOR_EMAIL_DESC' ] = " The email address of the author of this component. " ;
2016-02-26 00:20:09 +00:00
// set if contributors were added
2017-12-14 23:10:47 +00:00
$langCont = $lang . '_CONTRIBUTOR' ;
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> addContributors ) && $this -> addContributors && isset ( $this -> componentData -> contributors ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> contributors ))
{
foreach ( $this -> componentData -> contributors as $counter => $contributor )
{
// make sure we dont use 0
$counter ++ ;
// get the word for this number
2017-12-14 23:10:47 +00:00
$COUNTER = ComponentbuilderHelper :: safeString ( $counter , 'U' );
2016-02-26 00:20:09 +00:00
// set the dynamic values
2017-12-14 23:10:47 +00:00
$cbTitle = htmlspecialchars ( $contributor [ 'title' ], ENT_XML1 , 'UTF-8' );
$cbName = htmlspecialchars ( $contributor [ 'name' ], ENT_XML1 , 'UTF-8' );
$cbEmail = htmlspecialchars ( $contributor [ 'email' ], ENT_XML1 , 'UTF-8' );
$cbWebsite = htmlspecialchars ( $contributor [ 'website' ], ENT_XML1 , 'UTF-8' ); // ComponentbuilderHelper::htmlEscape($contributor['website']);
2016-02-26 00:20:09 +00:00
// load to the $fieldsets
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field type="spacer" name="spacerContributor' . $counter . '" hr="true" />' ;
$this -> configFieldSets [] = " \t \t " . '<field name="contributor' . $counter . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="spacer"' ;
$this -> configFieldSets [] = " \t \t \t " . 'class="text"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $langCont . '_' . $COUNTER . '"' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="titleContributor' . $counter . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="text"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $langCont . '_TITLE_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $langCont . '_TITLE_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'size="60"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default="' . $cbTitle . '"' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="nameContributor' . $counter . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="text"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $langCont . '_NAME_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $langCont . '_NAME_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'size="60"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default="' . $cbName . '"' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="emailContributor' . $counter . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="email"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $langCont . '_EMAIL_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $langCont . '_EMAIL_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'size="60"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default="' . $cbEmail . '"' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="linkContributor' . $counter . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="url"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $langCont . '_LINK_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $langCont . '_LINK_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'size="60"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default="' . $cbWebsite . '"' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="useContributor' . $counter . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="list"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default="' . ( int ) $contributor [ 'use' ] . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $langCont . '_USE_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $langCont . '_USE_DESC">' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="0">' . $langCont . '_USE_NONE</option>' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="1">' . $langCont . '_USE_EMAIL</option>' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="2">' . $langCont . '_USE_WWW</option>' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t </field> " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="showContributor' . $counter . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="list"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default="' . ( int ) $contributor [ 'show' ] . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $langCont . '_SHOW_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $langCont . '_SHOW_DESC">' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="0">' . $langCont . '_SHOW_NONE</option>' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="1">' . $langCont . '_SHOW_BACK</option>' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="2">' . $langCont . '_SHOW_FRONT</option>' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="3">' . $langCont . '_SHOW_ALL</option>' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t </field> " ;
// add the contributor
2017-12-14 23:10:47 +00:00
$this -> theContributors .= PHP_EOL . " \t @ " . strtolower ( $contributor [ 'title' ]) . " \t \t " . $contributor [ 'name' ] . ' <' . $contributor [ 'website' ] . '>' ;
2016-02-26 00:20:09 +00:00
// setup lang
2017-12-14 23:10:47 +00:00
$Counter = ComponentbuilderHelper :: safeString ( $counter , 'Ww' );
$this -> langContent [ $this -> lang ][ $langCont . '_' . $COUNTER ] = " Contributor " . $Counter ;
2016-02-26 00:20:09 +00:00
// load the Global checkin defautls
2017-12-14 23:10:47 +00:00
$this -> extensionsParams [] = '"titleContributor' . $counter . '":"' . $cbTitle . '"' ;
$this -> extensionsParams [] = '"nameContributor' . $counter . '":"' . $cbName . '"' ;
$this -> extensionsParams [] = '"emailContributor' . $counter . '":"' . $cbEmail . '"' ;
$this -> extensionsParams [] = '"linkContributor' . $counter . '":"' . $cbWebsite . '"' ;
$this -> extensionsParams [] = '"useContributor' . $counter . '":"' . ( int ) $contributor [ 'use' ] . '"' ;
$this -> extensionsParams [] = '"showContributor' . $counter . '":"' . ( int ) $contributor [ 'show' ] . '"' ;
2016-02-26 00:20:09 +00:00
}
}
// add more contributors if required
if ( 1 == $this -> componentData -> emptycontributors )
{
2017-12-14 23:10:47 +00:00
if ( isset ( $counter ))
{
2016-02-26 00:20:09 +00:00
$min = $counter + 1 ;
unset ( $counter );
}
else
{
$min = 1 ;
}
$max = $min + $this -> componentData -> number - 1 ;
2017-12-14 23:10:47 +00:00
$moreContributerFields = range ( $min , $max , 1 );
2016-02-26 00:20:09 +00:00
foreach ( $moreContributerFields as $counter )
{
2017-12-14 23:10:47 +00:00
$COUNTER = ComponentbuilderHelper :: safeString ( $counter , 'U' );
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field type="spacer" name="spacerContributor' . $counter . '" hr="true" />' ;
$this -> configFieldSets [] = " \t \t " . '<field name="contributor' . $counter . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="spacer"' ;
$this -> configFieldSets [] = " \t \t \t " . 'class="text"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $langCont . '_' . $COUNTER . '"' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="titleContributor' . $counter . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="text"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $langCont . '_TITLE_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $langCont . '_TITLE_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'size="60"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default=""' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="nameContributor' . $counter . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="text"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $langCont . '_NAME_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $langCont . '_NAME_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'size="60"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default=""' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="emailContributor' . $counter . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="email"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $langCont . '_EMAIL_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $langCont . '_EMAIL_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'size="60"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default=""' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="linkContributor' . $counter . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="url"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $langCont . '_LINK_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $langCont . '_LINK_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'size="60"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default=""' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="useContributor' . $counter . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="list"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default="0"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $langCont . '_USE_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $langCont . '_USE_DESC">' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="0">' . $langCont . '_USE_NONE</option>' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="1">' . $langCont . '_USE_EMAIL</option>' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="2">' . $langCont . '_USE_WWW</option>' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t </field> " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="showContributor' . $counter . '"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="list"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default="0"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $langCont . '_SHOW_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $langCont . '_SHOW_DESC">' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="0">' . $langCont . '_SHOW_NONE</option>' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="1">' . $langCont . '_SHOW_BACK</option>' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="2">' . $langCont . '_SHOW_FRONT</option>' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="3">' . $langCont . '_SHOW_ALL</option>' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t </field> " ;
// setup lang
2017-12-14 23:10:47 +00:00
$Counter = ComponentbuilderHelper :: safeString ( $counter , 'Ww' );
$this -> langContent [ $this -> lang ][ $langCont . '_' . $COUNTER ] = " Contributor " . $Counter ;
2016-02-26 00:20:09 +00:00
}
}
if ( $this -> addContributors || $this -> componentData -> emptycontributors == 1 )
{
// setup lang
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $langCont . '_TITLE_LABEL' ] = " Contributor Job Title " ;
$this -> langContent [ $this -> lang ][ $langCont . '_TITLE_DESC' ] = " The job title that best describes the contributor's relationship to this component. " ;
$this -> langContent [ $this -> lang ][ $langCont . '_NAME_LABEL' ] = " Contributor Name " ;
$this -> langContent [ $this -> lang ][ $langCont . '_NAME_DESC' ] = " The name of this contributor. " ;
$this -> langContent [ $this -> lang ][ $langCont . '_EMAIL_LABEL' ] = " Contributor Email " ;
$this -> langContent [ $this -> lang ][ $langCont . '_EMAIL_DESC' ] = " The email of this contributor. " ;
$this -> langContent [ $this -> lang ][ $langCont . '_LINK_LABEL' ] = " Contributor Website " ;
$this -> langContent [ $this -> lang ][ $langCont . '_LINK_DESC' ] = " The link to this contributor's website. " ;
$this -> langContent [ $this -> lang ][ $langCont . '_USE_LABEL' ] = " Use " ;
$this -> langContent [ $this -> lang ][ $langCont . '_USE_DESC' ] = " How should we link to this contributor. " ;
$this -> langContent [ $this -> lang ][ $langCont . '_USE_NONE' ] = " None " ;
$this -> langContent [ $this -> lang ][ $langCont . '_USE_EMAIL' ] = " Email " ;
$this -> langContent [ $this -> lang ][ $langCont . '_USE_WWW' ] = " Website " ;
$this -> langContent [ $this -> lang ][ $langCont . '_SHOW_LABEL' ] = " Show " ;
$this -> langContent [ $this -> lang ][ $langCont . '_SHOW_DESC' ] = " Select where you want this contributor's details to show in the component. " ;
$this -> langContent [ $this -> lang ][ $langCont . '_SHOW_NONE' ] = " Hide " ;
$this -> langContent [ $this -> lang ][ $langCont . '_SHOW_BACK' ] = " Back-end " ;
$this -> langContent [ $this -> lang ][ $langCont . '_SHOW_FRONT' ] = " Front-end " ;
$this -> langContent [ $this -> lang ][ $langCont . '_SHOW_ALL' ] = " Both Front & Back-end " ;
2016-02-26 00:20:09 +00:00
}
// close that fieldset
$this -> configFieldSets [] = " \t </fieldset> " ;
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
public function setUikitConfigFieldsets ( $lang )
{
2017-11-11 04:33:51 +00:00
if ( $this -> uikit > 0 )
2016-02-26 00:20:09 +00:00
{
// main lang prefix
2017-12-14 23:10:47 +00:00
$lang = $lang . '' ;
2016-02-26 00:20:09 +00:00
// start building field set for uikit functions
$this -> configFieldSets [] = " \t <fieldset " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . 'name="uikit_config"' ;
$this -> configFieldSets [] = " \t \t " . 'label="' . $lang . '_UIKIT_LABEL"' ;
$this -> configFieldSets [] = " \t \t " . 'description="' . $lang . '_UIKIT_DESC">' ;
2016-02-26 00:20:09 +00:00
// set tab lang
2017-11-11 04:33:51 +00:00
if ( 1 == $this -> uikit )
{
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_UIKIT_LABEL' ] = " Uikit2 Settings " ;
$this -> langContent [ $this -> lang ][ $lang . '_UIKIT_DESC' ] = " <b>The Parameters for the uikit are set here.</b><br />Uikit is a lightweight and modular front-end framework
2017-11-11 04:33:51 +00:00
for developing fast and powerful web interfaces . For more info visit < a href = \ " https://getuikit.com/v2/ \" target= \" _blank \" >https://getuikit.com/v2/</a> " ;
}
2017-12-14 23:10:47 +00:00
elseif ( 2 == $this -> uikit )
2017-11-11 04:33:51 +00:00
{
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_UIKIT_LABEL' ] = " Uikit2 and Uikit3 Settings " ;
$this -> langContent [ $this -> lang ][ $lang . '_UIKIT_DESC' ] = " <b>The Parameters for the uikit are set here.</b><br />Uikit is a lightweight and modular front-end framework
2017-11-11 04:33:51 +00:00
for developing fast and powerful web interfaces . For more info visit < a href = \ " https://getuikit.com/v2/ \" target= \" _blank \" >version 2</a> or <a href= \" https://getuikit.com/ \" target= \" _blank \" >version 3</a> " ;
}
2017-12-14 23:10:47 +00:00
elseif ( 3 == $this -> uikit )
2017-11-11 04:33:51 +00:00
{
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_UIKIT_LABEL' ] = " Uikit3 Settings " ;
$this -> langContent [ $this -> lang ][ $lang . '_UIKIT_DESC' ] = " <b>The Parameters for the uikit are set here.</b><br />Uikit is a lightweight and modular front-end framework
2017-11-11 04:33:51 +00:00
for developing fast and powerful web interfaces . For more info visit < a href = \ " https://getuikit.com/ \" target= \" _blank \" >https://getuikit.com/</a> " ;
}
2017-12-14 23:10:47 +00:00
2017-11-11 04:33:51 +00:00
// add version selection
if ( 2 == $this -> uikit )
{
// set field lang
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_UIKIT_VERSION_LABEL' ] = " Uikit Versions " ;
$this -> langContent [ $this -> lang ][ $lang . '_UIKIT_VERSION_DESC' ] = " Select what version you would like to use " ;
$this -> langContent [ $this -> lang ][ $lang . '_UIKIT_V2' ] = " Version 2 " ;
$this -> langContent [ $this -> lang ][ $lang . '_UIKIT_V3' ] = " Version 3 " ;
2017-11-11 04:33:51 +00:00
// set the field
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="uikit_version"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="radio"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $lang . '_UIKIT_VERSION_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $lang . '_UIKIT_VERSION_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'class="btn-group btn-group-yesno"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default="2">' ;
$this -> configFieldSets [] = " \t \t \t " . '<!--' . $this -> setLine ( __LINE__ ) . ' Option Set. -->' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="2">' ;
$this -> configFieldSets [] = " \t \t \t \t " . $lang . '_UIKIT_V2</option>"' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="3">' ;
$this -> configFieldSets [] = " \t \t \t \t " . $lang . '_UIKIT_V3</option>"' ;
2017-11-11 04:33:51 +00:00
$this -> configFieldSets [] = " \t \t </field> " ;
// set params defaults
$this -> extensionsParams [] = '"uikit_version":"2"' ;
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
// set field lang
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_UIKIT_LOAD_LABEL' ] = " Loading Options " ;
$this -> langContent [ $this -> lang ][ $lang . '_UIKIT_LOAD_DESC' ] = " Set the uikit loading option. " ;
$this -> langContent [ $this -> lang ][ $lang . '_AUTO_LOAD' ] = " Auto " ;
$this -> langContent [ $this -> lang ][ $lang . '_FORCE_LOAD' ] = " Force " ;
$this -> langContent [ $this -> lang ][ $lang . '_DONT_LOAD' ] = " Not " ;
$this -> langContent [ $this -> lang ][ $lang . '_ONLY_EXTRA' ] = " Only Extra " ;
2016-02-26 00:20:09 +00:00
// set the field
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="uikit_load"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="radio"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $lang . '_UIKIT_LOAD_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $lang . '_UIKIT_LOAD_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'class="btn-group btn-group-yesno"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default="">' ;
$this -> configFieldSets [] = " \t \t \t " . '<!--' . $this -> setLine ( __LINE__ ) . ' Option Set. -->' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="">' ;
$this -> configFieldSets [] = " \t \t \t \t " . $lang . '_AUTO_LOAD</option>"' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="1">' ;
$this -> configFieldSets [] = " \t \t \t \t " . $lang . '_FORCE_LOAD</option>"' ;
if ( 2 == $this -> uikit || 1 == $this -> uikit )
{
$this -> configFieldSets [] = " \t \t \t " . '<option value="3">' ;
$this -> configFieldSets [] = " \t \t \t \t " . $lang . '_ONLY_EXTRA</option>"' ;
}
$this -> configFieldSets [] = " \t \t \t " . '<option value="2">' ;
$this -> configFieldSets [] = " \t \t \t \t " . $lang . '_DONT_LOAD</option>"' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t </field> " ;
// set params defaults
2017-08-22 22:17:19 +00:00
$this -> extensionsParams [] = '"uikit_load":"1"' ;
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
// set field lang
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_UIKIT_MIN_LABEL' ] = " Load Minified " ;
$this -> langContent [ $this -> lang ][ $lang . '_UIKIT_MIN_DESC' ] = " Should the minified version of uikit files be loaded? " ;
$this -> langContent [ $this -> lang ][ $lang . '_YES' ] = " Yes " ;
$this -> langContent [ $this -> lang ][ $lang . '_NO' ] = " No " ;
2016-02-26 00:20:09 +00:00
// set the field
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="uikit_min"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="radio"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $lang . '_UIKIT_MIN_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $lang . '_UIKIT_MIN_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'class="btn-group btn-group-yesno"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default="">' ;
$this -> configFieldSets [] = " \t \t \t " . '<!--' . $this -> setLine ( __LINE__ ) . ' Option Set. -->' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="">' ;
$this -> configFieldSets [] = " \t \t \t \t " . $lang . '_NO</option>"' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value=".min">' ;
$this -> configFieldSets [] = " \t \t \t \t " . $lang . '_YES</option>"' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t </field> " ;
// set params defaults
2017-08-22 22:17:19 +00:00
$this -> extensionsParams [] = '"uikit_min":""' ;
2017-12-14 23:10:47 +00:00
if ( 2 == $this -> uikit || 1 == $this -> uikit )
2017-11-11 04:33:51 +00:00
{
// set field lang
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_UIKIT_STYLE_LABEL' ] = " css Style " ;
$this -> langContent [ $this -> lang ][ $lang . '_UIKIT_STYLE_DESC' ] = " Set the css style that should be used. " ;
$this -> langContent [ $this -> lang ][ $lang . '_FLAT_LOAD' ] = " Flat " ;
$this -> langContent [ $this -> lang ][ $lang . '_ALMOST_FLAT_LOAD' ] = " Almost Flat " ;
$this -> langContent [ $this -> lang ][ $lang . '_GRADIANT_LOAD' ] = " Gradient " ;
2017-11-11 04:33:51 +00:00
// set the field
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field name="uikit_style"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="radio"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $lang . '_UIKIT_STYLE_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $lang . '_UIKIT_STYLE_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'class="btn-group btn-group-yesno"' ;
if ( 2 == $this -> uikit )
{
$this -> configFieldSets [] = " \t \t \t " . 'showon="uikit_version:2"' ;
}
$this -> configFieldSets [] = " \t \t \t " . 'default="">' ;
$this -> configFieldSets [] = " \t \t \t " . '<!--' . $this -> setLine ( __LINE__ ) . ' Option Set. -->' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value="">' ;
$this -> configFieldSets [] = " \t \t \t \t " . $lang . '_FLAT_LOAD</option>"' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value=".almost-flat">' ;
$this -> configFieldSets [] = " \t \t \t \t " . $lang . '_ALMOST_FLAT_LOAD</option>"' ;
$this -> configFieldSets [] = " \t \t \t " . '<option value=".gradient">' ;
$this -> configFieldSets [] = " \t \t \t \t " . $lang . '_GRADIANT_LOAD</option>"' ;
2017-11-11 04:33:51 +00:00
$this -> configFieldSets [] = " \t \t </field> " ;
// set params defaults
$this -> extensionsParams [] = '"uikit_style":""' ;
}
2016-02-26 00:20:09 +00:00
// add custom Uikit Settings fields
if ( isset ( $this -> configFieldSetsCustomField [ 'Uikit Settings' ]) && ComponentbuilderHelper :: checkArray ( $this -> configFieldSetsCustomField [ 'Uikit Settings' ]))
{
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = implode ( " \t \t " , $this -> configFieldSetsCustomField [ 'Uikit Settings' ]);
2016-02-26 00:20:09 +00:00
unset ( $this -> configFieldSetsCustomField [ 'Uikit Settings' ]);
}
// close that fieldset
$this -> configFieldSets [] = " \t </fieldset> " ;
}
}
2017-12-14 23:10:47 +00:00
2016-12-22 21:32:13 +00:00
public function setEmailHelperConfigFieldsets ( $lang )
{
if ( isset ( $this -> componentData -> add_email_helper ) && $this -> componentData -> add_email_helper )
{
// main lang prefix
2017-12-14 23:10:47 +00:00
$lang = $lang . '' ;
2016-12-22 21:32:13 +00:00
// set main lang string
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_MAIL_CONFIGURATION' ] = " Mail Configuration " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM' ] = " DKIM " ;
2016-12-22 21:32:13 +00:00
// start building field set for email helper functions
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = PHP_EOL . " \t <fieldset " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t name= \" mail_configuration_custom_config \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t label= \" " . $lang . " _MAIL_CONFIGURATION \" > " ;
2016-12-22 21:32:13 +00:00
// add custom Mail Configurations
if ( isset ( $this -> configFieldSetsCustomField [ 'Mail Configuration' ]) && ComponentbuilderHelper :: checkArray ( $this -> configFieldSetsCustomField [ 'Mail Configuration' ]))
{
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = implode ( " \t \t " , $this -> configFieldSetsCustomField [ 'Mail Configuration' ]);
2016-12-22 21:32:13 +00:00
unset ( $this -> configFieldSetsCustomField [ 'Mail Configuration' ]);
}
else
{
// set all the laguage strings
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_MAILONLINE_LABEL' ] = " Mailer Status " ;
$this -> langContent [ $this -> lang ][ $lang . '_MAILONLINE_DESCRIPTION' ] = " Warning this will stop all emails from going out. " ;
$this -> langContent [ $this -> lang ][ $lang . '_ON' ] = " On " ;
$this -> langContent [ $this -> lang ][ $lang . '_OFF' ] = " Off " ;
$this -> langContent [ $this -> lang ][ $lang . '_MAILER_LABEL' ] = " Mailer " ;
$this -> langContent [ $this -> lang ][ $lang . '_MAILER_DESCRIPTION' ] = " Select what mailer you would like to use to send emails. " ;
$this -> langContent [ $this -> lang ][ $lang . '_GLOBAL' ] = " Global " ;
$this -> langContent [ $this -> lang ][ $lang . '_PHP_MAIL' ] = " PHP Mail " ;
$this -> langContent [ $this -> lang ][ $lang . '_SENDMAIL' ] = " Sendmail " ;
$this -> langContent [ $this -> lang ][ $lang . '_SMTP' ] = " SMTP " ;
$this -> langContent [ $this -> lang ][ $lang . '_EMAILFROM_LABEL' ] = " From Email " ;
$this -> langContent [ $this -> lang ][ $lang . '_EMAILFROM_DESCRIPTION' ] = " The global email address that will be used to send system email. " ;
$this -> langContent [ $this -> lang ][ $lang . '_EMAILFROM_HINT' ] = " Email Address Here " ;
$this -> langContent [ $this -> lang ][ $lang . '_FROMNAME_LABEL' ] = " From Name " ;
$this -> langContent [ $this -> lang ][ $lang . '_FROMNAME_DESCRIPTION' ] = " Text displayed in the header "From:" field when sending a site email. Usually the site name. " ;
$this -> langContent [ $this -> lang ][ $lang . '_FROMNAME_HINT' ] = " From Name Here " ;
$this -> langContent [ $this -> lang ][ $lang . '_EMAILREPLY_LABEL' ] = " Reply to Email " ;
$this -> langContent [ $this -> lang ][ $lang . '_EMAILREPLY_DESCRIPTION' ] = " The global email address that will be used to set as the reply email. (leave blank for none) " ;
$this -> langContent [ $this -> lang ][ $lang . '_EMAILREPLY_HINT' ] = " Email Address Here " ;
$this -> langContent [ $this -> lang ][ $lang . '_REPLYNAME_LABEL' ] = " Reply to Name " ;
$this -> langContent [ $this -> lang ][ $lang . '_REPLYNAME_DESCRIPTION' ] = " Text displayed in the header "Reply To:" field when replying to the site email. Usually the the person that receives the response. (leave blank for none) " ;
$this -> langContent [ $this -> lang ][ $lang . '_REPLYNAME_HINT' ] = " Reply Name Here " ;
$this -> langContent [ $this -> lang ][ $lang . '_SENDMAIL_LABEL' ] = " Sendmail Path " ;
$this -> langContent [ $this -> lang ][ $lang . '_SENDMAIL_DESCRIPTION' ] = " Enter the path to the sendmail program directory on your host server. " ;
$this -> langContent [ $this -> lang ][ $lang . '_SENDMAIL_HINT' ] = " /usr/sbin/sendmail " ;
$this -> langContent [ $this -> lang ][ $lang . '_SMTPAUTH_LABEL' ] = " SMTP Authentication " ;
$this -> langContent [ $this -> lang ][ $lang . '_SMTPAUTH_DESCRIPTION' ] = " Select yes if your SMTP host requires SMTP Authentication. " ;
$this -> langContent [ $this -> lang ][ $lang . '_YES' ] = " Yes " ;
$this -> langContent [ $this -> lang ][ $lang . '_NO' ] = " No " ;
$this -> langContent [ $this -> lang ][ $lang . '_SMTPSECURE_LABEL' ] = " SMTP Security " ;
$this -> langContent [ $this -> lang ][ $lang . '_SMTPSECURE_DESCRIPTION' ] = " Select the security model that your SMTP server uses. " ;
$this -> langContent [ $this -> lang ][ $lang . '_NONE' ] = " None " ;
$this -> langContent [ $this -> lang ][ $lang . '_SSL' ] = " SSL " ;
$this -> langContent [ $this -> lang ][ $lang . '_TLS' ] = " TLS " ;
$this -> langContent [ $this -> lang ][ $lang . '_SMTPPORT_LABEL' ] = " SMTP Port " ;
$this -> langContent [ $this -> lang ][ $lang . '_SMTPPORT_DESCRIPTION' ] = " Enter the port number of your SMTP server. Use 25 for most unsecured servers and 465 for most secure servers. " ;
$this -> langContent [ $this -> lang ][ $lang . '_SMTPPORT_HINT' ] = " 25 " ;
$this -> langContent [ $this -> lang ][ $lang . '_SMTPUSER_LABEL' ] = " SMTP Username " ;
$this -> langContent [ $this -> lang ][ $lang . '_SMTPUSER_DESCRIPTION' ] = " Enter the username for access to the SMTP host. " ;
$this -> langContent [ $this -> lang ][ $lang . '_SMTPUSER_HINT' ] = " email@demo.com " ;
$this -> langContent [ $this -> lang ][ $lang . '_SMTPPASS_LABEL' ] = " SMTP Password " ;
$this -> langContent [ $this -> lang ][ $lang . '_SMTPPASS_DESCRIPTION' ] = " Enter the password for access to the SMTP host. " ;
$this -> langContent [ $this -> lang ][ $lang . '_SMTPHOST_LABEL' ] = " SMTP Host " ;
$this -> langContent [ $this -> lang ][ $lang . '_SMTPHOST_DESCRIPTION' ] = " Enter the name of the SMTP host. " ;
$this -> langContent [ $this -> lang ][ $lang . '_SMTPHOST_HINT' ] = " localhost " ;
2016-12-22 21:32:13 +00:00
// set the mailer fields
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = PHP_EOL . " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Mailonline Field. Type: Radio. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" radio \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" mailonline \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _MAILONLINE_LABEL \" " ;
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _MAILONLINE_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" btn-group btn-group-yesno \" " ;
$this -> configFieldSets [] = " \t \t \t default= \" 1 \" > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Option Set. --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t <option value= \" 1 \" > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t \t " . $lang . " _ON</option> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t <option value= \" 0 \" > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t \t " . $lang . " _OFF</option> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t </field> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Mailer Field. Type: List. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" list \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" mailer \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _MAILER_LABEL \" " ;
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _MAILER_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" list_class \" " ;
$this -> configFieldSets [] = " \t \t \t multiple= \" false \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" WORD \" " ;
$this -> configFieldSets [] = " \t \t \t required= \" true \" " ;
$this -> configFieldSets [] = " \t \t \t default= \" global \" > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Option Set. --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t <option value= \" global \" > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t \t " . $lang . " _GLOBAL</option> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t <option value= \" default \" > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t \t " . $lang . " _PHP_MAIL</option> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t <option value= \" sendmail \" > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t \t " . $lang . " _SENDMAIL</option> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t <option value= \" smtp \" > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t \t " . $lang . " _SMTP</option> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t </field> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Emailfrom Field. Type: Text. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" emailfrom \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _EMAILFROM_LABEL \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 60 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 150 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _EMAILFROM_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" STRING \" " ;
$this -> configFieldSets [] = " \t \t \t validate= \" email \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add email address here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _EMAILFROM_HINT \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t showon= \" mailer:smtp,sendmail,default \" " ;
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Fromname Field. Type: Text. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" fromname \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _FROMNAME_LABEL \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 60 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 150 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _FROMNAME_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" STRING \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add some name here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _FROMNAME_HINT \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t showon= \" mailer:smtp,sendmail,default \" " ;
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Email reply to Field. Type: Text. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
2017-08-20 20:47:14 +00:00
$this -> configFieldSets [] = " \t \t \t name= \" replyto \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _EMAILREPLY_LABEL \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 60 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 150 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _EMAILREPLY_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" STRING \" " ;
$this -> configFieldSets [] = " \t \t \t validate= \" email \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add email address here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _EMAILREPLY_HINT \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t showon= \" mailer:smtp,sendmail,default \" " ;
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Reply to name Field. Type: Text. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
2017-08-20 20:47:14 +00:00
$this -> configFieldSets [] = " \t \t \t name= \" replytoname \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _REPLYNAME_LABEL \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 60 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 150 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _REPLYNAME_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" STRING \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add some name here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _REPLYNAME_HINT \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t showon= \" mailer:smtp,sendmail,default \" " ;
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Sendmail Field. Type: Text. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" sendmail \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _SENDMAIL_LABEL \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 60 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 150 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _SENDMAIL_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t required= \" false \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" PATH \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add path to you local sendmail here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _SENDMAIL_HINT \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t showon= \" mailer:sendmail \" " ;
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Smtpauth Field. Type: Radio. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" radio \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" smtpauth \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _SMTPAUTH_LABEL \" " ;
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _SMTPAUTH_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" btn-group btn-group-yesno \" " ;
$this -> configFieldSets [] = " \t \t \t default= \" 0 \" " ;
$this -> configFieldSets [] = " \t \t \t showon= \" mailer:smtp \" > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Option Set. --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t <option value= \" 1 \" > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t \t " . $lang . " _YES</option> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t <option value= \" 0 \" > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t \t " . $lang . " _NO</option> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t </field> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Smtpsecure Field. Type: List. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" list \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" smtpsecure \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _SMTPSECURE_LABEL \" " ;
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _SMTPSECURE_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" list_class \" " ;
$this -> configFieldSets [] = " \t \t \t multiple= \" false \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" WORD \" " ;
$this -> configFieldSets [] = " \t \t \t default= \" none \" " ;
$this -> configFieldSets [] = " \t \t \t showon= \" mailer:smtp \" > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Option Set. --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t <option value= \" none \" > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t \t " . $lang . " _NONE</option> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t <option value= \" ssl \" > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t \t " . $lang . " _SSL</option> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t <option value= \" tls \" > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t \t " . $lang . " _TLS</option> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t </field> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Smtpport Field. Type: Text. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" smtpport \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _SMTPPORT_LABEL \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 60 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 150 \" " ;
$this -> configFieldSets [] = " \t \t \t default= \" 25 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _SMTPPORT_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" INT \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add the port number of your SMTP server here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _SMTPPORT_HINT \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t showon= \" mailer:smtp \" " ;
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Smtpuser Field. Type: Text. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" smtpuser \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _SMTPUSER_LABEL \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 60 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 150 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _SMTPUSER_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" STRING \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add the username for SMTP server here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _SMTPUSER_HINT \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t showon= \" mailer:smtp \" " ;
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Smtppass Field. Type: Password. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" password \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" smtppass \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _SMTPPASS_LABEL \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 60 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _SMTPPASS_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" raw \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add the password for SMTP server here. \" " ;
$this -> configFieldSets [] = " \t \t \t showon= \" mailer:smtp \" " ;
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Smtphost Field. Type: Text. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" smtphost \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _SMTPHOST_LABEL \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 60 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 150 \" " ;
$this -> configFieldSets [] = " \t \t \t default= \" localhost \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _SMTPHOST_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" STRING \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add the name of the SMTP host here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _SMTPHOST_HINT \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t showon= \" mailer:smtp \" " ;
$this -> configFieldSets [] = " \t \t /> " ;
}
// close that fieldset
$this -> configFieldSets [] = " \t </fieldset> " ;
2017-12-14 23:10:47 +00:00
2016-12-22 21:32:13 +00:00
// start dkim field set
$this -> configFieldSets [] = " \t <fieldset " ;
$this -> configFieldSets [] = " \t \t name= \" dkim_custom_config \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t label= \" " . $lang . " _DKIM \" > " ;
2016-12-22 21:32:13 +00:00
// add custom DKIM fields
if ( isset ( $this -> configFieldSetsCustomField [ 'DKIM' ]) && ComponentbuilderHelper :: checkArray ( $this -> configFieldSetsCustomField [ 'DKIM' ]))
{
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = implode ( " \t \t " , $this -> configFieldSetsCustomField [ 'DKIM' ]);
2016-12-22 21:32:13 +00:00
unset ( $this -> configFieldSetsCustomField [ 'DKIM' ]);
}
else
{
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_LABEL' ] = " Enable DKIM " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_DESCRIPTION' ] = " Set this option to Yes if you want to sign your emails using DKIM. " ;
$this -> langContent [ $this -> lang ][ $lang . '_YES' ] = " Yes " ;
$this -> langContent [ $this -> lang ][ $lang . '_NO' ] = " No " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_DOMAIN_LABEL' ] = " Domain " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_DOMAIN_DESCRIPTION' ] = " Set the domain. Eg. domain.com " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_DOMAIN_HINT' ] = " domain.com " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_SELECTOR_LABEL' ] = " Selector " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_SELECTOR_DESCRIPTION' ] = " Set your DKIM/DNS selector. " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_SELECTOR_HINT' ] = " vdm " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_PASSPHRASE_LABEL' ] = " Passphrase " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_PASSPHRASE_DESCRIPTION' ] = " Enter your passphrase here. " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_IDENTITY_LABEL' ] = " Identity " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_IDENTITY_DESCRIPTION' ] = " Set DKIM identity. This can be in the format of an email address 'you@yourdomain.com' typically used as the source of the email. " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_IDENTITY_HINT' ] = " you@yourdomain.com " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_PRIVATE_KEY_LABEL' ] = " Private key " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_PRIVATE_KEY_DESCRIPTION' ] = " set private key " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_PUBLIC_KEY_LABEL' ] = " Public key " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_PUBLIC_KEY_DESCRIPTION' ] = " set public key " ;
$this -> langContent [ $this -> lang ][ $lang . '_NOTE_DKIM_USE_LABEL' ] = " Server Configuration " ;
$this -> langContent [ $this -> lang ][ $lang . '_NOTE_DKIM_USE_DESCRIPTION' ] = " <p>Using the below details, you need to configure your DNS by adding a TXT record on your domain: <b><span id='a_dkim_domain'></span></b></p>
2016-12-22 21:32:13 +00:00
< script >
jQuery ( document ) . ready ( function ()
{
// house cleaning
if ( ! jQuery ( '#jform_dkim_domain' ) . val () ) {
jQuery ( '#jform_dkim_domain' ) . val ( window . location . hostname );
}
jQuery ( '#jform_dkim_key' ) . click ( function (){
jQuery ( this ) . select ();
});
jQuery ( '#jform_dkim_value' ) . click ( function (){
jQuery ( this ) . select ();
});
vdm_dkim ();
});
function vdm_dkim () {
jQuery ( '#a_dkim_domain' ) . text ( jQuery ( '#jform_dkim_domain' ) . val ());
jQuery ( '#jform_dkim_key' ) . val ( jQuery ( '#jform_dkim_selector' ) . val () + '._domainkey' );
if ( ! jQuery ( '#jform_dkim_public_key' ) . val () ) {
jQuery ( '#jform_dkim_value' ) . val ( 'v=DKIM1;k=rsa;g=*;s=email;h=sha1;t=s;p=PUBLICKEY' );
} else {
jQuery ( '#jform_dkim_value' ) . val ( 'v=DKIM1;k=rsa;g=*;s=email;h=sha1;t=s;p=' + jQuery ( '#jform_dkim_public_key' ) . val ());
}
}
</ script > " ;
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_KEY_LABEL' ] = " Key " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_KEY_DESCRIPTION' ] = " This is the KEY to use in the DNS record. " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_KEY_HINT' ] = " vdm._domainkey " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_VALUE_LABEL' ] = " Value " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_VALUE_DESCRIPTION' ] = " This is the TXT value to use in the DNS. Replace the PUBLICKEY with your public key. " ;
$this -> langContent [ $this -> lang ][ $lang . '_DKIM_VALUE_HINT' ] = " v=DKIM1;k=rsa;g=*;s=email;h=sha1;t=s;p=PUBLICKEY " ;
2016-12-22 21:32:13 +00:00
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = PHP_EOL . " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Dkim Field. Type: Radio. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" radio \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" dkim \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _DKIM_LABEL \" " ;
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _DKIM_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" btn-group btn-group-yesno \" " ;
$this -> configFieldSets [] = " \t \t \t default= \" 0 \" " ;
$this -> configFieldSets [] = " \t \t \t required= \" true \" > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Option Set. --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t <option value= \" 1 \" > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t \t " . $lang . " _YES</option> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t <option value= \" 0 \" > " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t \t " . $lang . " _NO</option> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t </field> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Dkim_domain Field. Type: Text. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" dkim_domain \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _DKIM_DOMAIN_LABEL \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 60 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 150 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _DKIM_DOMAIN_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" STRING \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add DKIM Domain here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _DKIM_DOMAIN_HINT \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t showon= \" dkim:1 \" " ;
$this -> configFieldSets [] = " \t \t \t onchange= \" vdm_dkim(); \" " ;
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Dkim_selector Field. Type: Text. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" dkim_selector \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _DKIM_SELECTOR_LABEL \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 60 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 150 \" " ;
$this -> configFieldSets [] = " \t \t \t default= \" vdm \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _DKIM_SELECTOR_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" STRING \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add DKIM/DNS selector here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _DKIM_SELECTOR_HINT \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t showon= \" dkim:1 \" " ;
$this -> configFieldSets [] = " \t \t \t onchange= \" vdm_dkim(); \" " ;
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Dkim_passphrase Field. Type: Password. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" password \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" dkim_passphrase \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _DKIM_PASSPHRASE_LABEL \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 60 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _DKIM_PASSPHRASE_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" raw \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add passphrase here. \" " ;
$this -> configFieldSets [] = " \t \t \t showon= \" dkim:1 \" " ;
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Dkim_identity Field. Type: Text. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" dkim_identity \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _DKIM_IDENTITY_LABEL \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 60 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 150 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _DKIM_IDENTITY_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" raw \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add DKIM Identity here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _DKIM_IDENTITY_HINT \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t showon= \" dkim:1 \" " ;
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Dkim_private_key Field. Type: Textarea. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" textarea \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" dkim_private_key \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _DKIM_PRIVATE_KEY_LABEL \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t rows= \" 15 \" " ;
$this -> configFieldSets [] = " \t \t \t cols= \" 5 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _DKIM_PRIVATE_KEY_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" input-xxlarge span12 \" " ;
$this -> configFieldSets [] = " \t \t \t showon= \" dkim:1 \" " ;
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Dkim_public_key Field. Type: Textarea. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" textarea \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" dkim_public_key \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _DKIM_PUBLIC_KEY_LABEL \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t rows= \" 5 \" " ;
$this -> configFieldSets [] = " \t \t \t cols= \" 5 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _DKIM_PUBLIC_KEY_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" input-xxlarge span12 \" " ;
$this -> configFieldSets [] = " \t \t \t showon= \" dkim:1 \" " ;
$this -> configFieldSets [] = " \t \t \t onchange= \" vdm_dkim(); \" " ;
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Note_dkim_use Field. Type: Note. A None Database Field. (joomla) --> " ;
$this -> configFieldSets [] = " \t \t <field type= \" note \" name= \" note_dkim_use \" label= \" " . $lang . " _NOTE_DKIM_USE_LABEL \" description= \" " . $lang . " _NOTE_DKIM_USE_DESCRIPTION \" heading= \" h4 \" class= \" note_dkim_use \" showon= \" dkim:1 \" /> \t \t " ;
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Dkim_key Field. Type: Text. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" dkim_key \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _DKIM_KEY_LABEL \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 40 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 150 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _DKIM_KEY_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" STRING \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add KEY here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _DKIM_KEY_HINT \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t showon= \" dkim:1 \" " ;
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Dkim_value Field. Type: Text. (joomla) --> " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" dkim_value \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _DKIM_VALUE_LABEL \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 80 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 350 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _DKIM_VALUE_DESCRIPTION \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" STRING \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add TXT record here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _DKIM_VALUE_HINT \" " ;
2016-12-22 21:32:13 +00:00
$this -> configFieldSets [] = " \t \t \t showon= \" dkim:1 \" " ;
$this -> configFieldSets [] = " \t \t /> " ;
}
// close that fieldset
$this -> configFieldSets [] = " \t </fieldset> " ;
}
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
public function setGooglechartConfigFieldsets ( $lang )
{
if ( $this -> googlechart )
{
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = PHP_EOL . " \t <fieldset " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t name= \" googlechart_config \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t label= \" " . $lang . " _CHART_SETTINGS_LABEL \" " ;
$this -> configFieldSets [] = " \t \t description= \" " . $lang . " _CHART_SETTINGS_DESC \" > " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <field type= \" note \" name= \" chart_admin_naote \" class= \" alert alert-info \" label= \" " . $lang . " _ADMIN_CHART_NOTE_LABEL \" description= \" " . $lang . " _ADMIN_CHART_NOTE_DESC \" /> " ;
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Admin_chartbackground Field. Type: Color. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" color \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" admin_chartbackground \" " ;
$this -> configFieldSets [] = " \t \t \t default= \" #F7F7FA \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _CHARTBACKGROUND_LABEL \" " ;
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _CHARTBACKGROUND_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Admin_mainwidth Field. Type: Text. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" admin_mainwidth \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _MAINWIDTH_LABEL \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 20 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 50 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _MAINWIDTH_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" INT \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add area width here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _MAINWIDTH_HINT \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Spacer_chartadmin_hr_a Field. Type: Spacer. A None Database Field. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field type= \" spacer \" name= \" spacer_chartadmin_hr_a \" hr= \" true \" class= \" spacer_chartadmin_hr_a \" /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Admin_chartareatop Field. Type: Text. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" admin_chartareatop \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _CHARTAREATOP_LABEL \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 20 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 50 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _CHARTAREATOP_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" INT \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add top spacing here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _CHARTAREATOP_HINT \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Admin_chartarealeft Field. Type: Text. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" admin_chartarealeft \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _CHARTAREALEFT_LABEL \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 20 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 50 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _CHARTAREALEFT_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" INT \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add left spacing here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _CHARTAREALEFT_HINT \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Admin_chartareawidth Field. Type: Text. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" admin_chartareawidth \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _CHARTAREAWIDTH_LABEL \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 20 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 50 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _CHARTAREAWIDTH_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" INT \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add chart width here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _CHARTAREAWIDTH_HINT \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Spacer_chartadmin_hr_b Field. Type: Spacer. A None Database Field. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field type= \" spacer \" name= \" spacer_chartadmin_hr_b \" hr= \" true \" class= \" spacer_chartadmin_hr_b \" /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Admin_legendtextstylefontcolor Field. Type: Color. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" color \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" admin_legendtextstylefontcolor \" " ;
$this -> configFieldSets [] = " \t \t \t default= \" #63B1F2 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _LEGENDTEXTSTYLEFONTCOLOR_LABEL \" " ;
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _LEGENDTEXTSTYLEFONTCOLOR_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Admin_legendtextstylefontsize Field. Type: Text. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" admin_legendtextstylefontsize \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _LEGENDTEXTSTYLEFONTSIZE_LABEL \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 20 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 50 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _LEGENDTEXTSTYLEFONTSIZE_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" INT \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add size of the legend here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _LEGENDTEXTSTYLEFONTSIZE_HINT \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Spacer_chartadmin_hr_c Field. Type: Spacer. A None Database Field. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field type= \" spacer \" name= \" spacer_chartadmin_hr_c \" hr= \" true \" class= \" spacer_chartadmin_hr_c \" /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Admin_vaxistextstylefontcolor Field. Type: Color. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" color \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" admin_vaxistextstylefontcolor \" " ;
$this -> configFieldSets [] = " \t \t \t default= \" #63B1F2 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _VAXISTEXTSTYLEFONTCOLOR_LABEL \" " ;
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _VAXISTEXTSTYLEFONTCOLOR_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Spacer_chartadmin_hr_d Field. Type: Spacer. A None Database Field. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field type= \" spacer \" name= \" spacer_chartadmin_hr_d \" hr= \" true \" class= \" spacer_chartadmin_hr_d \" /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Admin_haxistextstylefontcolor Field. Type: Color. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" color \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" admin_haxistextstylefontcolor \" " ;
$this -> configFieldSets [] = " \t \t \t default= \" #63B1F2 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _HAXISTEXTSTYLEFONTCOLOR_LABEL \" " ;
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _HAXISTEXTSTYLEFONTCOLOR_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Admin_haxistitletextstylefontcolor Field. Type: Color. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" color \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" admin_haxistitletextstylefontcolor \" " ;
$this -> configFieldSets [] = " \t \t \t default= \" #63B1F2 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _HAXISTITLETEXTSTYLEFONTCOLOR_LABEL \" " ;
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _HAXISTITLETEXTSTYLEFONTCOLOR_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
$this -> configFieldSets [] = " \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <field type= \" note \" name= \" chart_site_note \" class= \" alert alert-info \" label= \" " . $lang . " _SITE_CHART_NOTE_LABEL \" description= \" " . $lang . " _SITE_CHART_NOTE_DESC \" /> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Site_chartbackground Field. Type: Color. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" color \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" site_chartbackground \" " ;
$this -> configFieldSets [] = " \t \t \t default= \" #F7F7FA \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _CHARTBACKGROUND_LABEL \" " ;
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _CHARTBACKGROUND_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Site_mainwidth Field. Type: Text. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" site_mainwidth \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _MAINWIDTH_LABEL \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 20 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 50 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _MAINWIDTH_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" INT \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add area width here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _MAINWIDTH_HINT \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Spacer_chartsite_hr_a Field. Type: Spacer. A None Database Field. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field type= \" spacer \" name= \" spacer_chartsite_hr_a \" hr= \" true \" class= \" spacer_chartsite_hr_a \" /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Site_chartareatop Field. Type: Text. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" site_chartareatop \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _CHARTAREATOP_LABEL \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 20 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 50 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _CHARTAREATOP_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" INT \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add top spacing here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _CHARTAREATOP_HINT \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Site_chartarealeft Field. Type: Text. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" site_chartarealeft \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _CHARTAREALEFT_LABEL \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 20 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 50 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _CHARTAREALEFT_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" INT \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add left spacing here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _CHARTAREALEFT_HINT \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Site_chartareawidth Field. Type: Text. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" site_chartareawidth \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _CHARTAREAWIDTH_LABEL \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 20 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 50 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _CHARTAREAWIDTH_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" INT \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add chart width here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _CHARTAREAWIDTH_HINT \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Spacer_chartsite_hr_b Field. Type: Spacer. A None Database Field. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field type= \" spacer \" name= \" spacer_chartsite_hr_b \" hr= \" true \" class= \" spacer_chartsite_hr_b \" /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Site_legendtextstylefontcolor Field. Type: Color. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" color \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" site_legendtextstylefontcolor \" " ;
$this -> configFieldSets [] = " \t \t \t default= \" #63B1F2 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _LEGENDTEXTSTYLEFONTCOLOR_LABEL \" " ;
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _LEGENDTEXTSTYLEFONTCOLOR_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Site_legendtextstylefontsize Field. Type: Text. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" text \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" site_legendtextstylefontsize \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _LEGENDTEXTSTYLEFONTSIZE_LABEL \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t size= \" 20 \" " ;
$this -> configFieldSets [] = " \t \t \t maxlength= \" 50 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _LEGENDTEXTSTYLEFONTSIZE_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t \t class= \" text_area \" " ;
$this -> configFieldSets [] = " \t \t \t filter= \" INT \" " ;
$this -> configFieldSets [] = " \t \t \t message= \" Error! Please add size of the legend here. \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t hint= \" " . $lang . " _LEGENDTEXTSTYLEFONTSIZE_HINT \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Spacer_chartsite_hr_c Field. Type: Spacer. A None Database Field. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field type= \" spacer \" name= \" spacer_chartsite_hr_c \" hr= \" true \" class= \" spacer_chartsite_hr_c \" /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Site_vaxistextstylefontcolor Field. Type: Color. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" color \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" site_vaxistextstylefontcolor \" " ;
$this -> configFieldSets [] = " \t \t \t default= \" #63B1F2 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _VAXISTEXTSTYLEFONTCOLOR_LABEL \" " ;
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _VAXISTEXTSTYLEFONTCOLOR_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Spacer_chartsite_hr_d Field. Type: Spacer. A None Database Field. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field type= \" spacer \" name= \" spacer_chartsite_hr_d \" hr= \" true \" class= \" spacer_chartsite_hr_d \" /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Site_haxistextstylefontcolor Field. Type: Color. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" color \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" site_haxistextstylefontcolor \" " ;
$this -> configFieldSets [] = " \t \t \t default= \" #63B1F2 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _HAXISTEXTSTYLEFONTCOLOR_LABEL \" " ;
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _HAXISTEXTSTYLEFONTCOLOR_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> \t \t " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t <!-- " . $this -> setLine ( __LINE__ ) . " Site_haxistitletextstylefontcolor Field. Type: Color. --> " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t <field " ;
$this -> configFieldSets [] = " \t \t \t type= \" color \" " ;
$this -> configFieldSets [] = " \t \t \t name= \" site_haxistitletextstylefontcolor \" " ;
$this -> configFieldSets [] = " \t \t \t default= \" #63B1F2 \" " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t \t label= \" " . $lang . " _HAXISTITLETEXTSTYLEFONTCOLOR_LABEL \" " ;
$this -> configFieldSets [] = " \t \t \t description= \" " . $lang . " _HAXISTITLETEXTSTYLEFONTCOLOR_DESC \" " ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
// add custom Encryption Settings fields
if ( isset ( $this -> configFieldSetsCustomField [ 'Chart Settings' ]) && ComponentbuilderHelper :: checkArray ( $this -> configFieldSetsCustomField [ 'Chart Settings' ]))
{
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = implode ( " \t \t " , $this -> configFieldSetsCustomField [ 'Chart Settings' ]);
2016-02-26 00:20:09 +00:00
unset ( $this -> configFieldSetsCustomField [ 'Chart Settings' ]);
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t </fieldset> " ;
// set params defaults
2017-08-22 22:17:19 +00:00
$this -> extensionsParams [] = '"admin_chartbackground":"#F7F7FA","admin_mainwidth":"1000","admin_chartareatop":"20","admin_chartarealeft":"20","admin_chartareawidth":"170","admin_legendtextstylefontcolor":"10","admin_legendtextstylefontsize":"20","admin_vaxistextstylefontcolor":"#63B1F2","admin_haxistextstylefontcolor":"#63B1F2","admin_haxistitletextstylefontcolor":"#63B1F2","site_chartbackground":"#F7F7FA","site_mainwidth":"1000","site_chartareatop":"20","site_chartarealeft":"20","site_chartareawidth":"170","site_legendtextstylefontcolor":"10","site_legendtextstylefontsize":"20","site_vaxistextstylefontcolor":"#63B1F2","site_haxistextstylefontcolor":"#63B1F2","site_haxistitletextstylefontcolor":"#63B1F2"' ;
2016-02-26 00:20:09 +00:00
// set field lang
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_CHART_SETTINGS_LABEL' ] = " Chart Settings " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHART_SETTINGS_DESC' ] = " The Google Chart Display Settings Are Made Here. " ;
$this -> langContent [ $this -> lang ][ $lang . '_ADMIN_CHART_NOTE_LABEL' ] = " Admin Settings " ;
$this -> langContent [ $this -> lang ][ $lang . '_ADMIN_CHART_NOTE_DESC' ] = " The following settings are used on the back-end of the site called (admin). " ;
$this -> langContent [ $this -> lang ][ $lang . '_SITE_CHART_NOTE_LABEL' ] = " Site Settings " ;
$this -> langContent [ $this -> lang ][ $lang . '_SITE_CHART_NOTE_DESC' ] = " The following settings are used on the front-end of the site called (site). " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHARTAREALEFT_DESC' ] = " Set in pixels the spacing from the left of the chart area to the beginning of the chart it self. Please don't add the px sign " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHARTAREALEFT_HINT' ] = " 170 " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHARTAREALEFT_LABEL' ] = " Left Spacing " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHARTAREATOP_DESC' ] = " Set in pixels the spacing from the top of the chart area to the beginning of the chart it self. Please don't add the px sign " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHARTAREATOP_HINT' ] = " 20 " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHARTAREATOP_LABEL' ] = " Top Spacing " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHARTAREAWIDTH_DESC' ] = " Set in % the width of the chart it self inside the chart area. Please don't add the % sign " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHARTAREAWIDTH_HINT' ] = " 60 " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHARTAREAWIDTH_LABEL' ] = " Chart Width " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHARTBACKGROUND_DESC' ] = " Select the chart background color here. " ;
$this -> langContent [ $this -> lang ][ $lang . '_CHARTBACKGROUND_LABEL' ] = " Chart Background " ;
$this -> langContent [ $this -> lang ][ $lang . '_HAXISTEXTSTYLEFONTCOLOR_DESC' ] = " Select the horizontal axis font color. " ;
$this -> langContent [ $this -> lang ][ $lang . '_HAXISTEXTSTYLEFONTCOLOR_LABEL' ] = " hAxis Font Color " ;
$this -> langContent [ $this -> lang ][ $lang . '_HAXISTITLETEXTSTYLEFONTCOLOR_DESC' ] = " Select the horizontal axis title's font color. " ;
$this -> langContent [ $this -> lang ][ $lang . '_HAXISTITLETEXTSTYLEFONTCOLOR_LABEL' ] = " hAxis Title Font Color " ;
$this -> langContent [ $this -> lang ][ $lang . '_LEGENDTEXTSTYLEFONTCOLOR_DESC' ] = " Select the legend font color. " ;
$this -> langContent [ $this -> lang ][ $lang . '_LEGENDTEXTSTYLEFONTCOLOR_LABEL' ] = " Legend Font Color " ;
$this -> langContent [ $this -> lang ][ $lang . '_LEGENDTEXTSTYLEFONTSIZE_DESC' ] = " Set in pixels the font size of the legend " ;
$this -> langContent [ $this -> lang ][ $lang . '_LEGENDTEXTSTYLEFONTSIZE_HINT' ] = " 10 " ;
$this -> langContent [ $this -> lang ][ $lang . '_LEGENDTEXTSTYLEFONTSIZE_LABEL' ] = " Legend Font Size " ;
$this -> langContent [ $this -> lang ][ $lang . '_MAINWIDTH_DESC' ] = " Set the width of the entire chart area " ;
$this -> langContent [ $this -> lang ][ $lang . '_MAINWIDTH_HINT' ] = " 1000 " ;
$this -> langContent [ $this -> lang ][ $lang . '_MAINWIDTH_LABEL' ] = " Chart Area Width " ;
$this -> langContent [ $this -> lang ][ $lang . '_VAXISTEXTSTYLEFONTCOLOR_DESC' ] = " Select the vertical axis font color. " ;
$this -> langContent [ $this -> lang ][ $lang . '_VAXISTEXTSTYLEFONTCOLOR_LABEL' ] = " vAxis Font Color " ;
2016-02-26 00:20:09 +00:00
}
}
2016-04-22 12:03:43 +00:00
/**
* @ param $lang
2017-12-14 23:10:47 +00:00
*/
2016-02-26 00:20:09 +00:00
public function setEncryptionConfigFieldsets ( $lang )
{
// Add encryption if needed
if (( isset ( $this -> basicEncryption ) && $this -> basicEncryption ) || ( isset ( $this -> advancedEncryption ) && $this -> advancedEncryption ))
{
2017-11-11 04:33:51 +00:00
// start building field set for encryption functions
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t <fieldset " ;
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . 'name="encryption_config"' ;
$this -> configFieldSets [] = " \t \t " . 'label="' . $lang . '_ENCRYPTION_LABEL"' ;
$this -> configFieldSets [] = " \t \t " . 'description="' . $lang . '_ENCRYPTION_DESC">' ;
2016-02-26 00:20:09 +00:00
// set tab lang
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_ENCRYPTION_LABEL' ] = " Encryption Settings " ;
$this -> langContent [ $this -> lang ][ $lang . '_ENCRYPTION_DESC' ] = " The encryption key for the field encryption is set here. " ;
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> basicEncryption ) && $this -> basicEncryption )
{
// set field lang
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_BASIC_KEY_LABEL' ] = " Basic Key <small>(basic encryption)</small> " ;
$this -> langContent [ $this -> lang ][ $lang . '_BASIC_KEY_DESC' ] = " Set the basic local key here. " ;
$this -> langContent [ $this -> lang ][ $lang . '_BASIC_KEY_NOTE_LABEL' ] = " Basic Encryption " ;
$this -> langContent [ $this -> lang ][ $lang . '_BASIC_KEY_NOTE_DESC' ] = " When using the basic encryption please use a 32 character passphrase.<br />Never change this passphrase once it is set! <b>DATA WILL GET CORRUPTED IF YOU DO!</b> " ;
2016-02-26 00:20:09 +00:00
// set the field
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field type="note" name="basic_key_note" class="alert alert-info" label="' . $lang . '_BASIC_KEY_NOTE_LABEL" description="' . $lang . '_BASIC_KEY_NOTE_DESC" />' ;
$this -> configFieldSets [] = " \t \t " . '<field name="basic_key"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="text"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $lang . '_BASIC_KEY_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $lang . '_BASIC_KEY_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'size="60"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default=""' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
}
if ( isset ( $this -> advancedEncryption ) && $this -> advancedEncryption )
{
// set field lang
2017-12-14 23:10:47 +00:00
$this -> langContent [ $this -> lang ][ $lang . '_VDM_KEY_LABEL' ] = " Advanced Key <small>(advanced encryption)</small> " ;
$this -> langContent [ $this -> lang ][ $lang . '_VDM_KEY_DESC' ] = " Add the advanced key here. " ;
$this -> langContent [ $this -> lang ][ $lang . '_VDM_KEY_NOTE_LABEL' ] = " Advanced Encryption " ;
$this -> langContent [ $this -> lang ][ $lang . '_VDM_KEY_NOTE_DESC' ] = " When using the advanced encryption you need to get an advanced key from " . $this -> componentData -> companyname . " .<br />Never change this advanced key once it is set! <b>DATA WILL GET CORRUPTED IF YOU DO!</b> " ;
2016-02-26 00:20:09 +00:00
// set the field
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = " \t \t " . '<field type="note" name="vdm_key_note" class="alert alert-info" label="' . $lang . '_VDM_KEY_NOTE_LABEL" description="' . $lang . '_VDM_KEY_NOTE_DESC" />' ;
$this -> configFieldSets [] = " \t \t " . '<field name="advanced_key"' ;
$this -> configFieldSets [] = " \t \t \t " . 'type="text"' ;
$this -> configFieldSets [] = " \t \t \t " . 'label="' . $lang . '_VDM_KEY_LABEL"' ;
$this -> configFieldSets [] = " \t \t \t " . 'description="' . $lang . '_VDM_KEY_DESC"' ;
$this -> configFieldSets [] = " \t \t \t " . 'size="60"' ;
$this -> configFieldSets [] = " \t \t \t " . 'default=""' ;
2016-02-26 00:20:09 +00:00
$this -> configFieldSets [] = " \t \t /> " ;
}
// add custom Encryption Settings fields
if ( isset ( $this -> configFieldSetsCustomField [ 'Encryption Settings' ]) && ComponentbuilderHelper :: checkArray ( $this -> configFieldSetsCustomField [ 'Encryption Settings' ]))
{
2017-12-14 23:10:47 +00:00
$this -> configFieldSets [] = implode ( " \t \t " , $this -> configFieldSetsCustomField [ 'Encryption Settings' ]);
2016-02-26 00:20:09 +00:00
unset ( $this -> configFieldSetsCustomField [ 'Encryption Settings' ]);
}
// close that fieldset
$this -> configFieldSets [] = " \t </fieldset> " ;
}
}
public function setAccessSectionsCategory ( $viewName_single , $viewName_list )
{
$component = '' ;
// check if view has category
if ( array_key_exists ( $viewName_single , $this -> catCodeBuilder ))
{
$otherViews = $this -> catCodeBuilder [ $viewName_single ][ 'views' ];
if ( $otherViews == $viewName_list )
{
2017-12-14 23:10:47 +00:00
$component .= PHP_EOL . " \t " . '<section name="category.' . $otherViews . '">' ;
$component .= PHP_EOL . " \t \t " . '<action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" />' ;
$component .= PHP_EOL . " \t \t " . '<action name="core.delete" title="JACTION_DELETE" description="COM_CATEGORIES_ACCESS_DELETE_DESC" />' ;
$component .= PHP_EOL . " \t \t " . '<action name="core.edit" title="JACTION_EDIT" description="COM_CATEGORIES_ACCESS_EDIT_DESC" />' ;
$component .= PHP_EOL . " \t \t " . '<action name="core.edit.state" title="JACTION_EDITSTATE" description="COM_CATEGORIES_ACCESS_EDITSTATE_DESC" />' ;
$component .= PHP_EOL . " \t \t " . '<action name="core.edit.own" title="JACTION_EDITOWN" description="COM_CATEGORIES_ACCESS_EDITOWN_DESC" />' ;
$component .= PHP_EOL . " \t </section> " ;
2016-02-26 00:20:09 +00:00
}
}
return $component ;
}
public function setAccessSections ()
{
// set the default component access values
2017-12-14 23:10:47 +00:00
$this -> componentHead = array ();
$this -> componentGlobal = array ();
$this -> permissionViews = array ();
2016-04-22 12:03:43 +00:00
$this -> componentHead [] = '<section name="component">' ;
2017-12-14 23:10:47 +00:00
$this -> componentHead [] = " \t \t " . '<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />' ;
$this -> componentHead [] = " \t \t " . '<action name="core.options" title="JACTION_OPTIONS" description="JACTION_OPTIONS_COMPONENT_DESC" />' ;
$this -> componentHead [] = " \t \t " . '<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" />' ;
2016-02-26 00:20:09 +00:00
if ( $this -> addEximport )
{
2017-12-14 23:10:47 +00:00
$exportTitle = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( 'Export Data' , 'U' );
$exportDesc = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( 'Export Data' , 'U' ) . '_DESC' ;
$this -> langContent [ 'bothadmin' ][ $exportTitle ] = 'Export Data' ;
$this -> langContent [ 'bothadmin' ][ $exportDesc ] = ' Allows users in this group to export data.' ;
$this -> componentHead [] = " \t \t " . '<action name="core.export" title="' . $exportTitle . '" description="' . $exportDesc . '" />' ;
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
$importTitle = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( 'Import Data' , 'U' );
$importDesc = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( 'Import Data' , 'U' ) . '_DESC' ;
$this -> langContent [ 'bothadmin' ][ $importTitle ] = 'Import Data' ;
$this -> langContent [ 'bothadmin' ][ $importDesc ] = ' Allows users in this group to import data.' ;
$this -> componentHead [] = " \t \t " . '<action name="core.import" title="' . $importTitle . '" description="' . $importDesc . '" />' ;
2016-02-26 00:20:09 +00:00
}
// version permission
2017-12-14 23:10:47 +00:00
$batchTitle = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( 'Use Batch' , 'U' );
$batchDesc = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( 'Use Batch' , 'U' ) . '_DESC' ;
$this -> langContent [ 'bothadmin' ][ $batchTitle ] = 'Use Batch' ;
$this -> langContent [ 'bothadmin' ][ $batchDesc ] = ' Allows users in this group to use batch copy/update method.' ;
$this -> componentHead [] = " \t \t " . '<action name="core.batch" title="' . $batchTitle . '" description="' . $batchDesc . '" />' ;
2016-02-26 00:20:09 +00:00
// version permission
2017-12-14 23:10:47 +00:00
$importTitle = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( 'Edit Versions' , 'U' );
$importDesc = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( 'Edit Versions' , 'U' ) . '_DESC' ;
$this -> langContent [ 'bothadmin' ][ $importTitle ] = 'Edit Version' ;
$this -> langContent [ 'bothadmin' ][ $importDesc ] = ' Allows users in this group to edit versions.' ;
$this -> componentHead [] = " \t \t " . '<action name="core.version" title="' . $importTitle . '" description="' . $importDesc . '" />' ;
2016-02-26 00:20:09 +00:00
// set the defaults
2017-12-14 23:10:47 +00:00
$this -> componentHead [] = " \t \t " . '<action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" />' ;
$this -> componentHead [] = " \t \t " . '<action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" />' ;
$this -> componentHead [] = " \t \t " . '<action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" />' ;
$this -> componentHead [] = " \t \t " . '<action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_ACCESS_EDITSTATE_DESC" />' ;
$this -> componentHead [] = " \t \t " . '<action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_COMPONENT_DESC" />' ;
2016-02-26 00:20:09 +00:00
// new custom created by permissions
2017-12-14 23:10:47 +00:00
$created_byTitle = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( 'Edit Created By' , 'U' );
$created_byDesc = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( 'Edit Created By' , 'U' ) . '_DESC' ;
$this -> langContent [ 'bothadmin' ][ $created_byTitle ] = 'Edit Created By' ;
$this -> langContent [ 'bothadmin' ][ $created_byDesc ] = ' Allows users in this group to edit created by.' ;
$this -> componentHead [] = " \t \t " . '<action name="core.edit.created_by" title="' . $created_byTitle . '" description="' . $created_byDesc . '" />' ;
2016-02-26 00:20:09 +00:00
// new custom created date permissions
2017-12-14 23:10:47 +00:00
$createdTitle = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( 'Edit Created Date' , 'U' );
$createdDesc = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( 'Edit Created Date' , 'U' ) . '_DESC' ;
$this -> langContent [ 'bothadmin' ][ $createdTitle ] = 'Edit Created Date' ;
$this -> langContent [ 'bothadmin' ][ $createdDesc ] = ' Allows users in this group to edit created date.' ;
$this -> componentHead [] = " \t \t " . '<action name="core.edit.created" title="' . $createdTitle . '" description="' . $createdDesc . '" />' ;
2016-02-26 00:20:09 +00:00
// set the menu controller lookup
2017-12-14 23:10:47 +00:00
$menuControllers = array ( 'access' , 'submenu' , 'dashboard_list' , 'dashboard_add' );
// set the custom admin views permissions
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> componentData -> custom_admin_views ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> custom_admin_views ))
{
2017-12-14 23:10:47 +00:00
foreach ( $this -> componentData -> custom_admin_views as $custom_admin_view )
{
// new custom permissions to access this view
$customAdminName = $custom_admin_view [ 'settings' ] -> name ;
$customAdminCode = $custom_admin_view [ 'settings' ] -> code ;
$customAdminTitle = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( $customAdminName . ' Access' , 'U' );
$customAdminDesc = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( $customAdminName . ' Access' , 'U' ) . '_DESC' ;
$sortKey = ComponentbuilderHelper :: safeString ( $customAdminName . ' Access' );
$this -> langContent [ 'bothadmin' ][ $customAdminTitle ] = $customAdminName . ' Access' ;
$this -> langContent [ 'bothadmin' ][ $customAdminDesc ] = ' Allows the users in this group to access ' . ComponentbuilderHelper :: safeString ( $customAdminName , 'w' ) . '.' ;
$this -> componentGlobal [ $sortKey ] = " \t \t " . '<action name="' . $customAdminCode . '.access" title="' . $customAdminTitle . '" description="' . $customAdminDesc . '" />' ;
// add the custom permissions to use the buttons of this view
$this -> addCustomButtonPermissions ( $custom_admin_view [ 'settings' ], $customAdminName , $customAdminCode );
2016-02-26 00:20:09 +00:00
// add menu controll view that has menus options
2017-12-14 23:10:47 +00:00
foreach ( $menuControllers as $menuController )
2016-02-26 00:20:09 +00:00
{
// add menu controll view that has menus options
if ( isset ( $custom_admin_view [ $menuController ]) && $custom_admin_view [ $menuController ])
{
2016-04-22 12:03:43 +00:00
$targetView_ = 'views.' ;
2017-02-01 13:17:04 +00:00
if ( $menuController === 'dashboard_add' )
2016-04-22 12:03:43 +00:00
{
$targetView_ = 'view.' ;
}
// menucontroller
2017-12-14 23:10:47 +00:00
$menucontrollerView [ 'action' ] = $targetView_ . $menuController ;
2016-04-22 12:03:43 +00:00
$menucontrollerView [ 'implementation' ] = '2' ;
if ( isset ( $custom_admin_view [ 'settings' ] -> permissions ) && ComponentbuilderHelper :: checkArray ( $custom_admin_view [ 'settings' ] -> permissions ))
{
2017-12-14 23:10:47 +00:00
array_push ( $custom_admin_view [ 'settings' ] -> permissions , $menucontrollerView );
2016-04-22 12:03:43 +00:00
}
else
{
$custom_admin_view [ 'settings' ] -> permissions = array ();
$custom_admin_view [ 'settings' ] -> permissions [] = $menucontrollerView ;
}
unset ( $menucontrollerView );
2016-02-26 00:20:09 +00:00
}
}
2016-04-22 12:03:43 +00:00
$this -> buildPermissions ( $custom_admin_view , $customAdminCode , $customAdminCode , $menuControllers , 'customAdmin' );
2017-12-14 23:10:47 +00:00
}
}
2016-02-26 00:20:09 +00:00
// set the site views permissions
if ( isset ( $this -> componentData -> site_views ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> site_views ))
{
2017-12-14 23:10:47 +00:00
foreach ( $this -> componentData -> site_views as $site_view )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
// new custom permissions to access this view
$siteName = $site_view [ 'settings' ] -> name ;
$siteCode = $site_view [ 'settings' ] -> code ;
$siteTitle = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( $siteName . ' Access Site' , 'U' );
$siteDesc = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( $siteName . ' Access Site' , 'U' ) . '_DESC' ;
$sortKey = ComponentbuilderHelper :: safeString ( $siteName . ' Access Site' );
2016-12-30 10:47:19 +00:00
if ( isset ( $site_view [ 'access' ]) && $site_view [ 'access' ] == 1 )
{
2017-12-14 23:10:47 +00:00
$this -> langContent [ 'bothadmin' ][ $siteTitle ] = $siteName . ' (Site) Access' ;
$this -> langContent [ 'bothadmin' ][ $siteDesc ] = ' Allows the users in this group to access site ' . ComponentbuilderHelper :: safeString ( $siteName , 'w' ) . '.' ;
$this -> componentGlobal [ $sortKey ] = " \t \t " . '<action name="site.' . $siteCode . '.access" title="' . $siteTitle . '" description="' . $siteDesc . '" />' ;
2017-08-22 22:17:19 +00:00
// check if this site view requires access rule to default to public
if ( isset ( $site_view [ 'public' ]) && $site_view [ 'public' ] == 1 )
{
// we use one as public group (TODO we see if we run into any issues)
2017-12-14 23:10:47 +00:00
$this -> assetsRules [] = '"site.' . $siteCode . '.access":{"1":1}' ;
2017-08-22 22:17:19 +00:00
}
2016-12-30 10:47:19 +00:00
}
2017-03-08 04:49:54 +00:00
// add the custom permissions to use the buttons of this view
$this -> addCustomButtonPermissions ( $site_view [ 'settings' ], $siteName , $siteCode );
2017-12-14 23:10:47 +00:00
}
}
2016-02-26 00:20:09 +00:00
if ( isset ( $this -> componentData -> admin_views ) && ComponentbuilderHelper :: checkArray ( $this -> componentData -> admin_views ))
{
foreach ( $this -> componentData -> admin_views as $view )
{
// set view name
$nameView = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_single );
$nameViews = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_list );
2017-12-14 23:10:47 +00:00
// add the custom permissions to use the buttons of this view
$this -> addCustomButtonPermissions ( $view [ 'settings' ], $view [ 'settings' ] -> name_single , $nameView );
2016-02-26 00:20:09 +00:00
if ( $nameView != 'component' )
{
// add menu controll view that has menus options
2017-12-14 23:10:47 +00:00
foreach ( $menuControllers as $menuController )
2016-02-26 00:20:09 +00:00
{
// add menu controll view that has menus options
2017-10-30 18:50:56 +00:00
if ( isset ( $view [ $menuController ]) && $view [ $menuController ])
2016-02-26 00:20:09 +00:00
{
$targetView_ = 'views.' ;
2017-02-01 13:17:04 +00:00
if ( $menuController === 'dashboard_add' )
2016-02-26 00:20:09 +00:00
{
$targetView_ = 'view.' ;
}
// menucontroller
2017-12-14 23:10:47 +00:00
$menucontrollerView [ 'action' ] = $targetView_ . $menuController ;
2016-02-26 00:20:09 +00:00
$menucontrollerView [ 'implementation' ] = '2' ;
2016-09-03 21:44:47 +00:00
if ( isset ( $view [ 'settings' ] -> permissions ) && ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> permissions ))
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
array_push ( $view [ 'settings' ] -> permissions , $menucontrollerView );
2016-02-26 00:20:09 +00:00
}
else
{
$view [ 'settings' ] -> permissions = array ();
$view [ 'settings' ] -> permissions [] = $menucontrollerView ;
}
unset ( $menucontrollerView );
}
}
// check if there are fields
if ( ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> fields ))
{
// check the fields for their permission settings
2017-12-14 23:10:47 +00:00
foreach ( $view [ 'settings' ] -> fields as $field )
2016-02-26 00:20:09 +00:00
{
// see if field require permissions to be set
if ( isset ( $field [ 'permission' ]) && $field [ 'permission' ])
{
if ( ComponentbuilderHelper :: checkArray ( $field [ 'settings' ] -> properties ))
{
foreach ( $field [ 'settings' ] -> properties as $property )
{
2017-02-01 13:17:04 +00:00
if ( $property [ 'name' ] === 'type' )
2016-02-26 00:20:09 +00:00
{
$propertyType = $property ;
}
}
2017-12-14 23:10:47 +00:00
$fieldType = $this -> getFieldType ( $field [ 'settings' ] -> type_name , $field [ 'settings' ] -> xml , $propertyType );
$fieldName = $this -> getFieldName ( $fieldType , $field [ 'settings' ] -> xml , $field [ 'alias' ]);
2016-02-26 00:20:09 +00:00
$fieldView = array ();
// set the permission for this field
2017-12-14 23:10:47 +00:00
$fieldView [ 'action' ] = 'view.edit.' . $fieldName ;
2016-02-26 00:20:09 +00:00
$fieldView [ 'implementation' ] = '3' ;
if ( ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> permissions ))
{
2017-12-14 23:10:47 +00:00
array_push ( $view [ 'settings' ] -> permissions , $fieldView );
2016-02-26 00:20:09 +00:00
}
else
{
$view [ 'settings' ] -> permissions = array ();
$view [ 'settings' ] -> permissions [] = $fieldView ;
}
2016-06-02 16:18:49 +00:00
// insure that no default field get loaded
if ( ! in_array ( $fieldName , $this -> defaultFields ))
{
// load to global field permission set
$this -> permissionFields [ $nameView ][ $fieldName ] = $fieldType ;
}
2016-02-26 00:20:09 +00:00
}
}
}
}
2016-04-22 12:03:43 +00:00
$this -> buildPermissions ( $view , $nameView , $nameViews , $menuControllers );
2016-02-26 00:20:09 +00:00
}
}
// set the views permissions now
2016-04-22 12:03:43 +00:00
if ( ComponentbuilderHelper :: checkArray ( $this -> permissionViews ))
2016-02-26 00:20:09 +00:00
{
2016-04-22 12:03:43 +00:00
foreach ( $this -> permissionViews as $viewName => $actions )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$componentViews [] = " \t " . '<section name="' . $viewName . '">' ;
2016-02-26 00:20:09 +00:00
foreach ( $actions as $action )
{
2017-12-14 23:10:47 +00:00
$componentViews [] = " \t \t " . $action ;
2016-02-26 00:20:09 +00:00
}
$componentViews [] = " \t </section> " ;
}
}
/// now build the section
2017-12-14 23:10:47 +00:00
$component = implode ( PHP_EOL , $this -> componentHead );
2016-02-26 00:20:09 +00:00
// sort the array to insure easy search
2017-12-14 23:10:47 +00:00
ksort ( $this -> componentGlobal , SORT_STRING );
2016-02-26 00:20:09 +00:00
// add global to the compnent section
2017-12-14 23:10:47 +00:00
$component .= PHP_EOL . implode ( PHP_EOL , $this -> componentGlobal ) . PHP_EOL . " \t </section> " ;
2016-02-26 00:20:09 +00:00
// add views to the compnent section
2017-12-14 23:10:47 +00:00
$component .= PHP_EOL . implode ( PHP_EOL , $componentViews );
2016-04-22 12:03:43 +00:00
// be sure to reset again. (memory)
2017-12-14 23:10:47 +00:00
$this -> componentHead = null ;
$this -> componentGlobal = null ;
$this -> permissionViews = null ;
2016-02-26 00:20:09 +00:00
// return the build
return $component ;
}
return false ;
}
2017-12-14 23:10:47 +00:00
protected function addCustomButtonPermissions ( $settings , $nameView , $code )
{
// add the custom permissions to use the buttons of this view
2016-09-11 15:27:04 +00:00
if ( isset ( $settings -> custom_buttons ) && ComponentbuilderHelper :: checkArray ( $settings -> custom_buttons ))
{
foreach ( $settings -> custom_buttons as $custom_buttons )
{
2017-12-14 23:10:47 +00:00
$customButtonName = $custom_buttons [ 'name' ];
$customButtonCode = ComponentbuilderHelper :: safeString ( $customButtonName );
$customButtonTitle = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( $nameView . ' ' . $customButtonName . ' Button Access' , 'U' );
$customButtonDesc = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( $nameView . ' ' . $customButtonName . ' Button Access' , 'U' ) . '_DESC' ;
$sortButtonKey = ComponentbuilderHelper :: safeString ( $nameView . ' ' . $customButtonName . ' Button Access' );
$this -> langContent [ 'bothadmin' ][ $customButtonTitle ] = $nameView . ' ' . $customButtonName . ' Button Access' ;
$this -> langContent [ 'bothadmin' ][ $customButtonDesc ] = ' Allows the users in this group to access the ' . ComponentbuilderHelper :: safeString ( $customButtonName , 'w' ) . ' button.' ;
$this -> componentGlobal [ $sortButtonKey ] = " \t \t " . '<action name="' . $code . '.' . $customButtonCode . '" title="' . $customButtonTitle . '" description="' . $customButtonDesc . '" />' ;
2016-09-11 15:27:04 +00:00
}
}
2017-12-14 23:10:47 +00:00
}
2016-04-22 12:03:43 +00:00
public function buildPermissions ( & $view , $nameView , $nameViews , $menuControllers , $type = 'admin' )
{
2016-05-04 04:53:33 +00:00
if ( isset ( $view [ 'settings' ] -> permissions ) && ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> permissions ) || ( isset ( $view [ 'port' ]) && $view [ 'port' ]) || ( isset ( $view [ 'history' ]) && $view [ 'history' ]))
2016-04-22 12:03:43 +00:00
{
// add export/import permissions to each view that has export/import options
if ( isset ( $view [ 'port' ]) && $view [ 'port' ])
{
// export
$exportView [ 'action' ] = 'view.export' ;
$exportView [ 'implementation' ] = '2' ;
if ( ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> permissions ))
{
2017-12-14 23:10:47 +00:00
array_push ( $view [ 'settings' ] -> permissions , $exportView );
2016-04-22 12:03:43 +00:00
}
else
{
$view [ 'settings' ] -> permissions = array ();
$view [ 'settings' ] -> permissions [] = $exportView ;
}
// import
$importView [ 'action' ] = 'view.import' ;
$importView [ 'implementation' ] = '2' ;
if ( ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> permissions ))
{
2017-12-14 23:10:47 +00:00
array_push ( $view [ 'settings' ] -> permissions , $importView );
2016-04-22 12:03:43 +00:00
}
else
{
$view [ 'settings' ] -> permissions = array ();
$view [ 'settings' ] -> permissions [] = $importView ;
}
}
// add version opstions to each view that has it added
if ( isset ( $view [ 'history' ]) && $view [ 'history' ])
{
// set version control
$versionView [ 'action' ] = 'view.version' ;
$versionView [ 'implementation' ] = '3' ;
if ( ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> permissions ))
{
2017-12-14 23:10:47 +00:00
array_push ( $view [ 'settings' ] -> permissions , $versionView );
2016-04-22 12:03:43 +00:00
}
else
{
$view [ 'settings' ] -> permissions = array ();
$view [ 'settings' ] -> permissions [] = $versionView ;
}
}
2017-02-01 13:17:04 +00:00
if ( $type === 'admin' )
2016-04-22 12:03:43 +00:00
{
// set batch control
$batchView [ 'action' ] = 'view.batch' ;
$batchView [ 'implementation' ] = '2' ;
if ( ComponentbuilderHelper :: checkArray ( $view [ 'settings' ] -> permissions ))
{
2017-12-14 23:10:47 +00:00
array_push ( $view [ 'settings' ] -> permissions , $batchView );
2016-04-22 12:03:43 +00:00
}
else
{
$view [ 'settings' ] -> permissions = array ();
$view [ 'settings' ] -> permissions [] = $batchView ;
}
}
foreach ( $view [ 'settings' ] -> permissions as $permission )
{
// set acction name
2017-12-14 23:10:47 +00:00
$arr = explode ( '.' , trim ( $permission [ 'action' ]));
2017-02-01 13:17:04 +00:00
if ( $arr [ 0 ] != 'core' || $arr [ 0 ] === 'view' )
2016-04-22 12:03:43 +00:00
{
array_shift ( $arr );
2017-12-14 23:10:47 +00:00
$actionMain = implode ( '.' , $arr );
$action = $nameView . '.' . $actionMain ;
2016-04-22 12:03:43 +00:00
}
else
{
2017-02-01 13:17:04 +00:00
if ( $arr [ 0 ] === 'core' )
2016-04-22 12:03:43 +00:00
{
// core is already set in global access
$permission [ 'implementation' ] = 1 ;
}
$action = $permission [ 'action' ];
}
// build action name
2017-12-14 23:10:47 +00:00
$actionNameBuilder = explode ( '.' , trim ( $permission [ 'action' ]));
2016-04-22 12:03:43 +00:00
array_shift ( $actionNameBuilder );
2017-12-14 23:10:47 +00:00
$nameBuilder = trim ( implode ( '___' , $actionNameBuilder ));
$customName = trim ( implode ( ' ' , $actionNameBuilder ));
2017-02-01 13:17:04 +00:00
if ( $type === 'admin' )
2016-04-22 12:03:43 +00:00
{
$W_NameList = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_list , 'W' );
2017-12-14 23:10:47 +00:00
$w_NameList = ComponentbuilderHelper :: safeString ( $customName . ' ' . $view [ 'settings' ] -> name_list , 'w' );
2016-04-22 12:03:43 +00:00
$w_NameSingle = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name_single , 'w' );
}
2017-02-01 13:17:04 +00:00
elseif ( $type === 'customAdmin' )
2016-04-22 12:03:43 +00:00
{
$W_NameList = ComponentbuilderHelper :: safeString ( $view [ 'settings' ] -> name , 'W' );
2017-12-14 23:10:47 +00:00
$w_NameList = $view [ 'settings' ] -> name ;
2016-04-22 12:03:43 +00:00
$w_NameSingle = $view [ 'settings' ] -> name ;
}
switch ( $nameBuilder )
{
case 'edit' :
2017-12-14 23:10:47 +00:00
// set edit title
$permission [ 'title' ] = $W_NameList . ' Edit' ;
// set edit description
$permission [ 'description' ] = ' Allows the users in this group to edit the ' . $w_NameSingle ;
break ;
2016-04-22 12:03:43 +00:00
case 'edit___own' :
2017-12-14 23:10:47 +00:00
// set edit title
$permission [ 'title' ] = $W_NameList . ' Edit Own' ;
// set edit description
$permission [ 'description' ] = ' Allows the users in this group to edit ' . $w_NameList . ' created by them' ;
break ;
2016-04-22 12:03:43 +00:00
case 'edit___state' :
2017-12-14 23:10:47 +00:00
// set edit title
$permission [ 'title' ] = $W_NameList . ' Edit State' ;
// set edit description
$permission [ 'description' ] = ' Allows the users in this group to update the state of the ' . $w_NameSingle ;
break ;
2016-04-22 12:03:43 +00:00
case 'edit___created_by' :
2017-12-14 23:10:47 +00:00
// set edit title
$permission [ 'title' ] = $W_NameList . ' Edit Created By' ;
// set edit description
$permission [ 'description' ] = ' Allows the users in this group to update the created by of the ' . $w_NameList ;
break ;
2016-04-22 12:03:43 +00:00
case 'edit___created' :
2017-12-14 23:10:47 +00:00
// set edit title
$permission [ 'title' ] = $W_NameList . ' Edit Created Date' ;
// set edit description
$permission [ 'description' ] = ' Allows the users in this group to update the created date of the ' . $w_NameList ;
break ;
2016-04-22 12:03:43 +00:00
case 'create' :
2017-12-14 23:10:47 +00:00
// set edit title
$permission [ 'title' ] = $W_NameList . ' Create' ;
// set edit description
$permission [ 'description' ] = ' Allows the users in this group to create ' . $w_NameList ;
break ;
2016-04-22 12:03:43 +00:00
case 'delete' :
2017-12-14 23:10:47 +00:00
// set edit title
$permission [ 'title' ] = $W_NameList . ' Delete' ;
// set edit description
$permission [ 'description' ] = ' Allows the users in this group to delete ' . $w_NameList ;
break ;
2016-04-22 12:03:43 +00:00
case 'access' :
2017-12-14 23:10:47 +00:00
// set edit title
$permission [ 'title' ] = $W_NameList . ' Access' ;
// set edit description
$permission [ 'description' ] = ' Allows the users in this group to access ' . $w_NameList ;
break ;
2016-04-22 12:03:43 +00:00
case 'export' :
2017-12-14 23:10:47 +00:00
// set edit title
$permission [ 'title' ] = $W_NameList . ' Export' ;
// set edit description
$permission [ 'description' ] = ' Allows the users in this group to export ' . $w_NameList ;
break ;
2016-04-22 12:03:43 +00:00
case 'import' :
2017-12-14 23:10:47 +00:00
// set edit title
$permission [ 'title' ] = $W_NameList . ' Import' ;
// set edit description
$permission [ 'description' ] = ' Allows the users in this group to import ' . $w_NameList ;
break ;
2016-04-22 12:03:43 +00:00
case 'version' :
2017-12-14 23:10:47 +00:00
// set edit title
$permission [ 'title' ] = $W_NameList . ' Edit Version' ;
// set edit description
$permission [ 'description' ] = ' Allows users in this group to edit versions of ' . $w_NameList ;
break ;
2016-04-22 12:03:43 +00:00
case 'batch' :
2017-12-14 23:10:47 +00:00
// set edit title
$permission [ 'title' ] = $W_NameList . ' Batch Use' ;
// set edit description
$permission [ 'description' ] = ' Allows users in this group to use batch copy/update method of ' . $w_NameList ;
break ;
2016-04-22 12:03:43 +00:00
default :
2017-12-14 23:10:47 +00:00
// set edit title
$permission [ 'title' ] = $W_NameList . ' ' . ComponentbuilderHelper :: safeString ( $customName , 'W' );
// set edit description
$permission [ 'description' ] = ' Allows the users in this group to update the ' . ComponentbuilderHelper :: safeString ( $customName , 'w' ) . ' of the ' . $w_NameSingle ;
break ;
2016-04-22 12:03:43 +00:00
}
// if core is not used update all core strings
2017-12-14 23:10:47 +00:00
$coreCheck = explode ( '.' , $action );
2016-04-22 12:03:43 +00:00
$coreCheck [ 0 ] = 'core' ;
2017-12-14 23:10:47 +00:00
$coreTarget = implode ( '.' , $coreCheck );
2016-04-22 12:03:43 +00:00
$this -> permissionCore [ $nameView ][ $coreTarget ] = $action ;
// set array sort name
$sortKey = ComponentbuilderHelper :: safeString ( $permission [ 'title' ]);
// set title
2017-12-14 23:10:47 +00:00
$title = $this -> langPrefix . '_' . ComponentbuilderHelper :: safeString ( $permission [ 'title' ], 'U' );
2016-04-22 12:03:43 +00:00
// load the actions
if ( $permission [ 'implementation' ] == 1 )
{
// only related to view
2017-12-14 23:10:47 +00:00
$this -> permissionViews [ $nameView ][] = '<action name="' . $action . '" title="' . $title . '" description="' . $title . '_DESC" />' ;
2016-04-22 12:03:43 +00:00
// load permission to action
$this -> permissionBuilder [ $action ][ $nameView ] = $nameView ;
}
elseif ( $permission [ 'implementation' ] == 2 )
{
// relation to whole component
2017-12-14 23:10:47 +00:00
$this -> componentGlobal [ $sortKey ] = " \t \t " . '<action name="' . $action . '" title="' . $title . '" description="' . $title . '_DESC" />' ;
2016-04-22 12:03:43 +00:00
// build permission switch
$this -> permissionBuilder [ 'global' ][ $action ][ $nameView ] = $nameView ;
// dashboard icon checker
2017-02-01 13:17:04 +00:00
if ( $coreTarget === 'core.access' )
2016-04-22 12:03:43 +00:00
{
$this -> permissionDashboard [] = " ' " . $nameViews . " .access' => ' " . $action . " ' " ;
$this -> permissionDashboard [] = " ' " . $nameView . " .access' => ' " . $action . " ' " ;
}
2017-02-01 13:17:04 +00:00
if ( $coreTarget === 'core.create' )
2016-04-22 12:03:43 +00:00
{
$this -> permissionDashboard [] = " ' " . $nameView . " .create' => ' " . $action . " ' " ;
}
// add menu controll view that has menus options
2017-12-14 23:10:47 +00:00
foreach ( $menuControllers as $menuController )
2016-04-22 12:03:43 +00:00
{
2017-12-14 23:10:47 +00:00
if ( $coreTarget === 'core.' . $menuController )
2016-04-22 12:03:43 +00:00
{
2017-02-01 13:17:04 +00:00
if ( $menuController === 'dashboard_add' )
2016-04-22 12:03:43 +00:00
{
2017-12-14 23:10:47 +00:00
$this -> permissionDashboard [] = " ' " . $nameView . " . " . $menuController . " ' => ' " . $action . " ' " ;
2016-04-22 12:03:43 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$this -> permissionDashboard [] = " ' " . $nameViews . " . " . $menuController . " ' => ' " . $action . " ' " ;
2016-04-22 12:03:43 +00:00
}
}
}
}
elseif ( $permission [ 'implementation' ] == 3 )
{
// only related to view
2017-12-14 23:10:47 +00:00
$this -> permissionViews [ $nameView ][] = '<action name="' . $action . '" title="' . $title . '" description="' . $title . '_DESC" />' ;
2016-04-22 12:03:43 +00:00
// load permission to action
$this -> permissionBuilder [ $action ][ $nameView ] = $nameView ;
// relation to whole component
2017-12-14 23:10:47 +00:00
$this -> componentGlobal [ $sortKey ] = " \t \t " . '<action name="' . $action . '" title="' . $title . '" description="' . $title . '_DESC" />' ;
2016-04-22 12:03:43 +00:00
// build permission switch
$this -> permissionBuilder [ 'global' ][ $action ][ $nameView ] = $nameView ;
// dashboard icon checker
2017-02-01 13:17:04 +00:00
if ( $coreTarget === 'core.access' )
2016-04-22 12:03:43 +00:00
{
$this -> permissionDashboard [] = " ' " . $nameViews . " .access' => ' " . $action . " ' " ;
$this -> permissionDashboard [] = " ' " . $nameView . " .access' => ' " . $action . " ' " ;
}
2017-02-01 13:17:04 +00:00
if ( $coreTarget === 'core.create' )
2016-04-22 12:03:43 +00:00
{
$this -> permissionDashboard [] = " ' " . $nameView . " .create' => ' " . $action . " ' " ;
}
// add menu controll view that has menus options
2017-12-14 23:10:47 +00:00
foreach ( $menuControllers as $menuController )
2016-04-22 12:03:43 +00:00
{
2017-12-14 23:10:47 +00:00
if ( $coreTarget === 'core.' . $menuController )
2016-04-22 12:03:43 +00:00
{
2017-02-01 13:17:04 +00:00
if ( $menuController === 'dashboard_add' )
2016-04-22 12:03:43 +00:00
{
2017-12-14 23:10:47 +00:00
$this -> permissionDashboard [] = " ' " . $nameView . " . " . $menuController . " ' => ' " . $action . " ' " ;
2016-04-22 12:03:43 +00:00
}
else
{
2017-12-14 23:10:47 +00:00
$this -> permissionDashboard [] = " ' " . $nameViews . " . " . $menuController . " ' => ' " . $action . " ' " ;
2016-04-22 12:03:43 +00:00
}
}
}
}
// set to language file
2017-12-14 23:10:47 +00:00
$this -> langContent [ 'bothadmin' ][ $title ] = trim ( $permission [ 'title' ]);
$this -> langContent [ 'bothadmin' ][ $title . '_DESC' ] = trim ( $permission [ 'description' ]);
2016-04-22 12:03:43 +00:00
}
}
}
2016-02-26 00:20:09 +00:00
2017-12-14 23:10:47 +00:00
public function getFieldName ( $typeName , $xml , $alias )
2016-02-26 00:20:09 +00:00
{
// if category then name must be catid (only one per view)
2017-02-01 13:17:04 +00:00
if ( $typeName === 'category' )
2016-02-26 00:20:09 +00:00
{
return 'catid' ;
}
// if tag is set then enable all tag options for this view (only one per view)
2017-02-01 13:17:04 +00:00
elseif ( $typeName === 'tag' )
2016-02-26 00:20:09 +00:00
{
return 'tags' ;
}
// if the field is set as alias it must be called alias
elseif ( $alias )
{
return 'alias' ;
}
2017-02-01 13:17:04 +00:00
elseif ( $typeName === 'spacer' )
2016-02-26 00:20:09 +00:00
{
// make sure the name is unique
return false ;
}
else
{
2017-12-14 23:10:47 +00:00
return ComponentbuilderHelper :: safeString ( ComponentbuilderHelper :: getBetween ( $xml , 'name="' , '"' ));
2016-02-26 00:20:09 +00:00
}
}
2017-12-14 23:10:47 +00:00
public function getFieldType ( $typeName , $xml , $property )
2016-02-26 00:20:09 +00:00
{
// make sure its lower case
$typeName = ComponentbuilderHelper :: safeString ( $typeName );
2017-02-01 13:17:04 +00:00
if ( $typeName === 'custom' || $typeName === 'customuser' )
2016-02-26 00:20:09 +00:00
{
2017-12-14 23:10:47 +00:00
$xmlValue = ComponentbuilderHelper :: safeString ( ComponentbuilderHelper :: getBetween ( $xml , 'type="' , '"' ));
2016-02-26 00:20:09 +00:00
}
// use field core type only if not found
elseif ( ComponentbuilderHelper :: checkString ( $typeName ))
{
$xmlValue = $typeName ;
}
// make sure none adjustable fields are set
elseif ( isset ( $property [ 'example' ]) && ComponentbuilderHelper :: checkString ( $property [ 'example' ]) && $property [ 'adjustable' ] == 0 )
{
$xmlValue = $property [ 'example' ];
}
// fall back on the xml settings
else
{
2017-12-14 23:10:47 +00:00
$xmlValue = ComponentbuilderHelper :: safeString ( ComponentbuilderHelper :: getBetween ( $xml , 'type="' , '"' ));
2016-02-26 00:20:09 +00:00
}
// check if the value is set
if ( ComponentbuilderHelper :: checkString ( $xmlValue ))
{
// add the value
return $xmlValue ;
}
else
{
// fall back to text
return 'text' ;
}
}
public function getInbetweenStrings ( $str , $start = '###' , $end = '###' )
{
$matches = array ();
$regex = " / $start ([a-zA-Z0-9_]*) $end / " ;
preg_match_all ( $regex , $str , $matches );
return $matches [ 1 ];
}
2017-12-14 23:10:47 +00:00
2016-02-26 00:20:09 +00:00
}