Added more header options and renamed the header method in the compiler.

This commit is contained in:
2020-12-26 22:28:36 +02:00
parent a28c5cf746
commit d36410281d
16 changed files with 132 additions and 102 deletions

View File

@ -6496,7 +6496,8 @@ class Get
public function setLang($string)
{
// this is there to insure we dont break already added Language strings
if (ComponentbuilderHelper::safeString($string, 'U', '_', false, false) === $string)
if (ComponentbuilderHelper::safeString($string, 'U', '_', false, false)
=== $string)
{
return false;
}

View File

@ -466,27 +466,6 @@ class Interpretation extends Fields
return implode(PHP_EOL, $bool);
}
/**
* set Helper Dynamic Headers
*
* @param string $target_client
*
* @return string
*/
public function setHelperClassHeader($target_client)
{
$header = '';
// add only to admin client
if ('admin' === $target_client && $this->addEximport)
{
$header .= PHP_EOL . 'use PhpOffice\PhpSpreadsheet\IOFactory;';
$header .= PHP_EOL . 'use PhpOffice\PhpSpreadsheet\Spreadsheet;';
$header .= PHP_EOL . 'use PhpOffice\PhpSpreadsheet\Writer\Xlsx;';
}
return $header;
}
/**
* set Helper License Lock
*
@ -8524,7 +8503,8 @@ class Interpretation extends Fields
if ($this->addAssetsTableFix == 2)
{
// get the type we will convert to
$data_type = ($this->accessWorseCase > 64000) ? "MEDIUMTEXT" : "TEXT";
$data_type = ($this->accessWorseCase > 64000) ? "MEDIUMTEXT"
: "TEXT";
// the if statement about $rule_length
$codeIF = "\$rule_length <= " . $this->accessWorseCase;
// fix column size
@ -8534,7 +8514,8 @@ class Interpretation extends Fields
$script[] = $this->_t(5)
. '$fix_rules_size = "ALTER TABLE `#__assets` CHANGE `rules` `rules` '
. $data_type
. ' NOT NULL COMMENT \'JSON encoded access control. Enlarged to ' . $data_type . ' by JCB\';";';
. ' NOT NULL COMMENT \'JSON encoded access control. Enlarged to '
. $data_type . ' by JCB\';";';
$script[] = $this->_t(5) . "\$db->setQuery(\$fix_rules_size);";
$script[] = $this->_t(5) . "\$db->execute();";
$codeA = implode(PHP_EOL, $script);
@ -22117,7 +22098,7 @@ class Interpretation extends Fields
}
/**
* Build headers for the model/view/controller headers
* Build headers for the various files
*
* @param string $context The name of the context
* @param string $viewsCodeName The view or views name
@ -22125,12 +22106,25 @@ class Interpretation extends Fields
* @return string The php to place in the header
*
*/
public function setClassHeaders($context, $viewsCodeName)
public function setFileHeader($context, $viewsCodeName)
{
// set the defaults
$headers = array();
switch ($context)
{
case 'admin.component':
case 'site.component':
$headers[] = 'JHtml::_(\'behavior.tabstate\');';
break;
case 'admin.helper':
case 'site.helper':
$headers[] = 'use Joomla\CMS\Language\Language;';
$headers[] = 'use Joomla\Registry\Registry;';
$headers[] = 'use Joomla\String\StringHelper;';
$headers[] = 'use Joomla\Utilities\ArrayHelper;';
// load the internal custom headers
$this->setHelperClassHeader($headers, $viewsCodeName);
break;
case 'admin.view.model':
case 'site.admin.view.model':
$headers[] = 'use Joomla\Registry\Registry;';
@ -22185,6 +22179,25 @@ class Interpretation extends Fields
return '';
}
/**
* set Helper Dynamic Headers
*
* @param array $headers The headers array
* @param string $target_client
*
* @return void
*/
protected function setHelperClassHeader(&$headers, $target_client)
{
// add only to admin client
if ('admin' === $target_client && $this->addEximport)
{
$headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;';
$headers[] = 'use PhpOffice\PhpSpreadsheet\Spreadsheet;';
$headers[] = 'use PhpOffice\PhpSpreadsheet\Writer\Xlsx;';
}
}
/**
* Build chosen multi selection headers for the view
*
@ -27189,7 +27202,7 @@ function vdm_dkim() {
{
// get the worse case column size required (can be worse I know)
// access/action size x 20 characters x 8 groups
$character_length = (int) ComponentbuilderHelper::bcmath(
$character_length = (int) ComponentbuilderHelper::bcmath(
'mul', $this->accessSize, 20, 0
);
$this->accessWorseCase = (int) ComponentbuilderHelper::bcmath(

View File

@ -634,21 +634,21 @@ class Infusion extends Interpretation
// SITE_ADMIN_VIEW_CONTROLLER_HEADER <<<DYNAMIC>>> add the header details for the controller
$this->fileContentDynamic[$nameSingleCode][$this->hhh
. 'SITE_ADMIN_VIEW_CONTROLLER_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'site.admin.view.controller',
$nameSingleCode
);
// SITE_ADMIN_VIEW_MODEL_HEADER <<<DYNAMIC>>> add the header details for the model
$this->fileContentDynamic[$nameSingleCode][$this->hhh
. 'SITE_ADMIN_VIEW_MODEL_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'site.admin.view.model',
$nameSingleCode
);
// SITE_ADMIN_VIEW_HEADER <<<DYNAMIC>>> add the header details for the view
$this->fileContentDynamic[$nameSingleCode][$this->hhh
. 'SITE_ADMIN_VIEW_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'site.admin.view',
$nameSingleCode
);
@ -664,20 +664,20 @@ class Infusion extends Interpretation
// ADMIN_VIEW_CONTROLLER_HEADER <<<DYNAMIC>>> add the header details for the controller
$this->fileContentDynamic[$nameSingleCode][$this->hhh
. 'ADMIN_VIEW_CONTROLLER_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'admin.view.controller',
$nameSingleCode
);
// ADMIN_VIEW_MODEL_HEADER <<<DYNAMIC>>> add the header details for the model
$this->fileContentDynamic[$nameSingleCode][$this->hhh
. 'ADMIN_VIEW_MODEL_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'admin.view.model', $nameSingleCode
);
// ADMIN_VIEW_HEADER <<<DYNAMIC>>> add the header details for the view
$this->fileContentDynamic[$nameSingleCode][$this->hhh
. 'ADMIN_VIEW_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'admin.view', $nameSingleCode
);
@ -1036,20 +1036,20 @@ class Infusion extends Interpretation
// ADMIN_VIEWS_CONTROLLER_HEADER <<<DYNAMIC>>> add the header details for the controller
$this->fileContentDynamic[$nameListCode][$this->hhh
. 'ADMIN_VIEWS_CONTROLLER_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'admin.views.controller',
$nameListCode
);
// ADMIN_VIEWS_MODEL_HEADER <<<DYNAMIC>>> add the header details for the model
$this->fileContentDynamic[$nameListCode][$this->hhh
. 'ADMIN_VIEWS_MODEL_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'admin.views.model', $nameListCode
);
// ADMIN_VIEWS_HEADER <<<DYNAMIC>>> add the header details for the views
$this->fileContentDynamic[$nameListCode][$this->hhh
. 'ADMIN_VIEWS_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'admin.views', $nameListCode
);
@ -1264,21 +1264,6 @@ class Infusion extends Interpretation
// setup the layouts
$this->setCustomViewLayouts();
// ADMIN_HELPER_CLASS_HEADER
$this->fileContentStatic[$this->hhh . 'ADMIN_HELPER_CLASS_HEADER'
. $this->hhh]
= $this->setHelperClassHeader('admin');
// SITE_HELPER_CLASS_HEADER
$this->fileContentStatic[$this->hhh . 'SITE_HELPER_CLASS_HEADER'
. $this->hhh]
= $this->setHelperClassHeader('site');
// HELPER_EXEL
$this->fileContentStatic[$this->hhh . 'HELPER_EXEL'
. $this->hhh]
= $this->setHelperExelMethods();
// setup custom_admin_views and all needed stuff for the site
if (isset($this->componentData->custom_admin_views)
&& ComponentbuilderHelper::checkArray(
@ -1512,20 +1497,20 @@ class Infusion extends Interpretation
// CUSTOM_ADMIN_VIEW_CONTROLLER_HEADER <<<DYNAMIC>>> add the header details for the controller
$this->fileContentDynamic[$view['settings']->code][$this->hhh
. 'CUSTOM_ADMIN_VIEW_CONTROLLER_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'custom.admin.view.controller',
$view['settings']->code
);
// CUSTOM_ADMIN_VIEW_MODEL_HEADER <<<DYNAMIC>>> add the header details for the model
$this->fileContentDynamic[$view['settings']->code][$this->hhh
. 'CUSTOM_ADMIN_VIEW_MODEL_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'custom.admin.view.model', $view['settings']->code
);
// CUSTOM_ADMIN_VIEW_HEADER <<<DYNAMIC>>> add the header details for the view
$this->fileContentDynamic[$view['settings']->code][$this->hhh
. 'CUSTOM_ADMIN_VIEW_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'custom.admin.view', $view['settings']->code
);
}
@ -1534,20 +1519,20 @@ class Infusion extends Interpretation
// CUSTOM_ADMIN_VIEWS_CONTROLLER_HEADER <<<DYNAMIC>>> add the header details for the controller
$this->fileContentDynamic[$view['settings']->code][$this->hhh
. 'CUSTOM_ADMIN_VIEWS_CONTROLLER_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'custom.admin.views.controller',
$view['settings']->code
);
// CUSTOM_ADMIN_VIEWS_MODEL_HEADER <<<DYNAMIC>>> add the header details for the model
$this->fileContentDynamic[$view['settings']->code][$this->hhh
. 'CUSTOM_ADMIN_VIEWS_MODEL_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'custom.admin.views.model', $view['settings']->code
);
// CUSTOM_ADMIN_VIEWS_HEADER <<<DYNAMIC>>> add the header details for the view
$this->fileContentDynamic[$view['settings']->code][$this->hhh
. 'CUSTOM_ADMIN_VIEWS_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'custom.admin.views', $view['settings']->code
);
}
@ -1567,6 +1552,39 @@ class Infusion extends Interpretation
$this->setCustomViewLayouts();
}
// ADMIN_HELPER_CLASS_HEADER
$this->fileContentStatic[$this->hhh . 'ADMIN_HELPER_CLASS_HEADER'
. $this->hhh]
= $this->setFileHeader(
'admin.helper', 'admin'
);
// ADMIN_COMPONENT_HEADER
$this->fileContentStatic[$this->hhh . 'ADMIN_COMPONENT_HEADER'
. $this->hhh]
= $this->setFileHeader(
'admin.component', 'admin'
);
// SITE_HELPER_CLASS_HEADER
$this->fileContentStatic[$this->hhh . 'SITE_HELPER_CLASS_HEADER'
. $this->hhh]
= $this->setFileHeader(
'site.helper', 'site'
);
// SITE_COMPONENT_HEADER
$this->fileContentStatic[$this->hhh . 'SITE_COMPONENT_HEADER'
. $this->hhh]
= $this->setFileHeader(
'site.component', 'site'
);
// HELPER_EXEL
$this->fileContentStatic[$this->hhh . 'HELPER_EXEL'
. $this->hhh]
= $this->setHelperExelMethods();
// VIEWARRAY
$this->fileContentStatic[$this->hhh . 'VIEWARRAY' . $this->hhh]
= PHP_EOL . implode("," . PHP_EOL, $viewarray);
@ -1995,20 +2013,20 @@ class Infusion extends Interpretation
// SITE_VIEW_CONTROLLER_HEADER <<<DYNAMIC>>> add the header details for the model
$this->fileContentDynamic[$view['settings']->code][$this->hhh
. 'SITE_VIEW_CONTROLLER_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'site.view.controller', $view['settings']->code
);
}
// SITE_VIEW_MODEL_HEADER <<<DYNAMIC>>> add the header details for the model
$this->fileContentDynamic[$view['settings']->code][$this->hhh
. 'SITE_VIEW_MODEL_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'site.view.model', $view['settings']->code
);
// SITE_VIEW_HEADER <<<DYNAMIC>>> add the header details for the view
$this->fileContentDynamic[$view['settings']->code][$this->hhh
. 'SITE_VIEW_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'site.view', $view['settings']->code
);
}
@ -2023,20 +2041,20 @@ class Infusion extends Interpretation
// SITE_VIEW_CONTROLLER_HEADER <<<DYNAMIC>>> add the header details for the model
$this->fileContentDynamic[$view['settings']->code][$this->hhh
. 'SITE_VIEW_CONTROLLER_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'site.views.controller', $view['settings']->code
);
}
// SITE_VIEWS_MODEL_HEADER <<<DYNAMIC>>> add the header details for the model
$this->fileContentDynamic[$view['settings']->code][$this->hhh
. 'SITE_VIEWS_MODEL_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'site.views.model', $view['settings']->code
);
// SITE_VIEWS_HEADER <<<DYNAMIC>>> add the header details for the view
$this->fileContentDynamic[$view['settings']->code][$this->hhh
. 'SITE_VIEWS_HEADER' . $this->hhh]
= $this->setClassHeaders(
= $this->setFileHeader(
'site.views', $view['settings']->code
);
}

View File

@ -12,9 +12,9 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Language\Language;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\CMS\Language\Language;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;