From 48a3a49d6f444e336d209ae41cec8bdcef4918d0 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Wed, 18 Apr 2018 21:11:14 +0200 Subject: [PATCH] Added minify of JS to the compiler area, also improved the infusion area to make more use of the getCustomScriptBuilder method --- README.md | 2 +- admin/README.txt | 2 +- admin/controllers/compiler.php | 23 ++- admin/helpers/compiler/a_Get.php | 13 +- admin/helpers/compiler/e_Interpretation.php | 18 +- admin/helpers/compiler/f_Infusion.php | 193 ++++-------------- .../en-GB/en-GB.com_componentbuilder.ini | 2 + admin/models/compiler.php | 5 +- admin/views/compiler/view.html.php | 26 +++ .../views/joomla_components/tmpl/default.php | 2 +- .../language_translations/tmpl/default.php | 25 ++- admin/views/languages/tmpl/default.php | 25 ++- 12 files changed, 165 insertions(+), 171 deletions(-) diff --git a/README.md b/README.md index 4434c3a56..3b9fc641f 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ Component Builder is mapped as a component in itself on my local development env + *Version*: 2.7.5 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **182910** ++ *Line count*: **182984** + *Field count*: **1012** + *File count*: **1199** + *Folder count*: **193** diff --git a/admin/README.txt b/admin/README.txt index 4434c3a56..3b9fc641f 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -130,7 +130,7 @@ Component Builder is mapped as a component in itself on my local development env + *Version*: 2.7.5 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **182910** ++ *Line count*: **182984** + *Field count*: **1012** + *File count*: **1199** + *Folder count*: **193** diff --git a/admin/controllers/compiler.php b/admin/controllers/compiler.php index 784b28daf..445d35742 100644 --- a/admin/controllers/compiler.php +++ b/admin/controllers/compiler.php @@ -66,17 +66,18 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin if($user->authorise('core.admin', 'com_componentbuilder')) { // get the post values - $jinput = JFactory::getApplication()->input; - $componentId = $jinput->post->get('component', 0, 'INT'); - $version = $jinput->post->get('version', 0, 'INT'); - $addBackup = $jinput->post->get('backup', 0, 'INT'); - $addRepo = $jinput->post->get('repository', 0, 'INT'); - $addPlaceholders = $jinput->post->get('placeholders', 2, 'INT'); - $debugLinenr = $jinput->post->get('debuglinenr', 2, 'INT'); + $jinput = JFactory::getApplication()->input; + $componentId = $jinput->post->get('component', 0, 'INT'); + $version = $jinput->post->get('version', 0, 'INT'); + $addBackup = $jinput->post->get('backup', 0, 'INT'); + $addRepo = $jinput->post->get('repository', 0, 'INT'); + $addPlaceholders = $jinput->post->get('placeholders', 2, 'INT'); + $debugLinenr = $jinput->post->get('debuglinenr', 2, 'INT'); + $minify = $jinput->post->get('minify', 2, 'INT'); // include component compiler require_once JPATH_ADMINISTRATOR.'/components/com_componentbuilder/helpers/compiler.php'; - $model = $this->getModel('compiler'); - if ($model->builder($version,$componentId,$addBackup,$addRepo,$addPlaceholders,$debugLinenr)) + $model = $this->getModel('compiler'); + if ($model->builder($version,$componentId,$addBackup,$addRepo,$addPlaceholders,$debugLinenr, $minify)) { $cache = JFactory::getCache('mod_menu'); $cache->clean(); @@ -88,8 +89,8 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin } $app = JFactory::getApplication(); - $redirect_url = $app->getUserState('com_componentbuilder.redirect_url'); - $message = $app->getUserState('com_componentbuilder.message'); + $redirect_url = $app->getUserState('com_componentbuilder.redirect_url'); + $message = $app->getUserState('com_componentbuilder.message'); if (empty($redirect_url) && $componentId > 0) { $redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=compiler', false); diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index 15fe7638a..ede4bf8b9 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -607,6 +607,13 @@ class Get */ public $libraries = array(); + /** + * Is minify Enabled + * + * @var int + */ + public $minify = 0; + /** * Is Tidy Enabled * @@ -631,10 +638,12 @@ class Get { // load application $this->app = JFactory::getApplication(); - // check if we have Tidy enabled - $this->tidy = extension_loaded('Tidy'); // Set the params $this->params = JComponentHelper::getParams('com_componentbuilder'); + // set the minfy switch of the JavaScript + $this->minify = (isset($config['minify']) && $config['minify'] != 2) ? $config['minify'] : $this->params->get('minify', 0); + // check if we have Tidy enabled + $this->tidy = extension_loaded('Tidy'); // set the field type builder $this->fieldBuilderType = $this->params->get('compiler_field_builder_type', 2); // check the field builder type logic diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index 94bdc993b..185be36c6 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -2821,6 +2821,20 @@ class Interpretation extends Fields return $method; } + /** + * get the custom script in the script builder + * + * @param string $first The first key + * @param string $second The second key + * @param string $prefix The prefix to add in front of the script if found + * @param string/bool $note The switch/note to add to the script + * @param bool $unset The switch to unset the value if found + * @param string/bool $unset The switch/string to use as default return if script not found + * @param string $sufix The sufix to add after the script if found + * + * @return mix The string/script if found or the default value if not found + * + */ public function getCustomScriptBuilder($first, $second, $prefix = '', $note = null, $unset = null, $default = null, $sufix = '') { // check if there is any custom script @@ -9052,7 +9066,7 @@ class Interpretation extends Fields } } // minfy the script - if ($this->params->get('minify') && isset($fileScript) && ComponentbuilderHelper::checkString($fileScript)) + if ($this->minify && isset($fileScript) && ComponentbuilderHelper::checkString($fileScript)) { // minify the fielScript javscript $minifier = new JS; @@ -9060,7 +9074,7 @@ class Interpretation extends Fields $fileScript = $minifier->minify(); } // minfy the script - if ($this->params->get('minify') && isset($footerScript) && ComponentbuilderHelper::checkString($footerScript)) + if ($this->minify && isset($footerScript) && ComponentbuilderHelper::checkString($footerScript)) { // minify the footerScript javscript $minifier = new JS; diff --git a/admin/helpers/compiler/f_Infusion.php b/admin/helpers/compiler/f_Infusion.php index b95d8c1ec..ee6805652 100644 --- a/admin/helpers/compiler/f_Infusion.php +++ b/admin/helpers/compiler/f_Infusion.php @@ -299,14 +299,12 @@ class Infusion extends Interpretation // ###AJAXTOKE### <<>> $this->fileContentDynamic[$viewName_single]['###AJAXTOKE###'] = $this->setAjaxToke($viewName_single); - if (isset($this->customScriptBuilder['php_document'][$viewName_single]) && ComponentbuilderHelper::checkString($this->customScriptBuilder['php_document'][$viewName_single])) + // ###DOCUMENT_CUSTOM_PHP### <<>> + if ($phpDocument = $this->getCustomScriptBuilder('php_document', $viewName_single, PHP_EOL, null, true, false)) { - // ###DOCUMENT_CUSTOM_PHP### <<>> - $this->customScriptBuilder['php_document'][$viewName_single] = str_replace('$document->', '$this->document->', $this->customScriptBuilder['php_document'][$viewName_single]); - $this->fileContentDynamic[$viewName_single]['###DOCUMENT_CUSTOM_PHP###'] = PHP_EOL . $this->setPlaceholders( - $this->customScriptBuilder['php_document'][$viewName_single], $this->placeholders); + $this->fileContentDynamic[$viewName_single]['###DOCUMENT_CUSTOM_PHP###'] = str_replace('$document->', '$this->document->', $phpDocument); // clear some memory - unset($this->customScriptBuilder['php_document'][$viewName_single]); + unset($phpDocument); } else { @@ -361,18 +359,9 @@ class Infusion extends Interpretation // ###POSTSAVEHOOK### <<>> $this->fileContentDynamic[$viewName_single]['###POSTSAVEHOOK###'] = $this->getCustomScriptBuilder('php_postsavehook', $viewName_single, PHP_EOL, null, true, PHP_EOL . "\t\treturn;", PHP_EOL . PHP_EOL . "\t\treturn;"); - if (isset($this->customScriptBuilder['css_view'][$viewName_single]) && ComponentbuilderHelper::checkString($this->customScriptBuilder['css_view'][$viewName_single])) - { - // ###VIEWCSS### <<>> - $this->fileContentDynamic[$viewName_single]['###VIEWCSS###'] = $this->setPlaceholders($this->customScriptBuilder['css_view'][$viewName_single], $this->placeholders); - // clear some memory - unset($this->customScriptBuilder['css_view'][$viewName_single]); - } - else - { - // ###VIEWCSS### <<>> - $this->fileContentDynamic[$viewName_single]['###VIEWCSS###'] = ''; - } + // ###VIEWCSS### <<>> + $this->fileContentDynamic[$viewName_single]['###VIEWCSS###'] = $this->getCustomScriptBuilder('css_view', $viewName_single, '', null, true); + // add css to front end if (isset($view['edit_create_site_view']) && $view['edit_create_site_view']) { @@ -489,22 +478,26 @@ class Infusion extends Interpretation // ###JVIEWLISTCANDO### <<>> $this->fileContentDynamic[$viewName_list]['###JVIEWLISTCANDO###'] = $this->setJviewListCanDo($viewName_single, $viewName_list); - if (isset($this->customScriptBuilder['css_views'][$viewName_list]) && ComponentbuilderHelper::checkString($this->customScriptBuilder['css_views'][$viewName_list])) + // ###VIEWSCSS### <<>> + $this->fileContentDynamic[$viewName_list]['###VIEWSCSS###'] = $this->getCustomScriptBuilder('css_views', $viewName_list, '', null, true); + + // ###VIEWS_FOOTER_SCRIPT### <<>> + $scriptNote = PHP_EOL . '//' . $this->setLine(__LINE__) . ' ' . $viewName_list.' footer script'; + if ($footerScript = $this->getCustomScriptBuilder('views_footer', $viewName_single, '', $scriptNote, true, false, PHP_EOL)) { - // ###VIEWCSS### <<>> - $this->fileContentDynamic[$viewName_list]['###VIEWSCSS###'] = $this->setPlaceholders($this->customScriptBuilder['css_views'][$viewName_list], $this->placeholders); + // only minfy if no php is added to the footer script + if ($this->minify && strpos($footerScript, 'add($footerScript); + $footerScript = $minifier->minify(); + // clear some memory + unset($minifier); + } + $this->fileContentDynamic[$viewName_list]['###VIEWS_FOOTER_SCRIPT###'] = PHP_EOL . '"; // clear some memory - unset($this->customScriptBuilder['css_views'][$viewName_list]); - } - else - { - // ###VIEWCSS### <<>> - $this->fileContentDynamic[$viewName_list]['###VIEWSCSS###'] = ''; - } - // ###VIEWS_FOOTER_SCRIPT### - if ($footerScript = $this->getCustomScriptBuilder('views_footer', $viewName_single, PHP_EOL)) - { - $this->fileContentDynamic[$viewName_list]['###VIEWS_FOOTER_SCRIPT###'] = PHP_EOL . '"; + unset($footerScript); } else { @@ -626,86 +619,31 @@ class Infusion extends Interpretation if ($view['settings']->main_get->gettype == 1) { - // check if there is any custom script - if (isset($this->customScriptBuilder[$this->target . '_php_before_getitem'][$view['settings']->code]) && ComponentbuilderHelper::checkString($this->customScriptBuilder[$this->target . '_php_before_getitem'][$view['settings']->code])) - { - // ###CUSTOM_ADMIN_BEFORE_GET_ITEM### <<>> - $this->fileContentDynamic[$view['settings']->code]['###CUSTOM_ADMIN_BEFORE_GET_ITEM###'] = $this->setPlaceholders($this->customScriptBuilder[$this->target . '_php_before_getitem'][$view['settings']->code], $this->placeholders); - // clear some memory - unset($this->customScriptBuilder[$this->target . '_php_before_getitem'][$view['settings']->code]); - } - else - { - // ###CUSTOM_ADMIN_BEFORE_GET_ITEM### <<>> - $this->fileContentDynamic[$view['settings']->code]['###CUSTOM_ADMIN_BEFORE_GET_ITEM###'] = ''; - } + // ###CUSTOM_ADMIN_BEFORE_GET_ITEM### <<>> + $this->fileContentDynamic[$view['settings']->code]['###CUSTOM_ADMIN_BEFORE_GET_ITEM###'] = $this->getCustomScriptBuilder($this->target . '_php_before_getitem', $view['settings']->code, '', null, true); // ###CUSTOM_ADMIN_GET_ITEM### <<>> $this->fileContentDynamic[$view['settings']->code]['###CUSTOM_ADMIN_GET_ITEM###'] = $this->setCustomViewGetItem($view['settings']->main_get, $view['settings']->code, "\t\t"); - // check if there is any custom script - if (isset($this->customScriptBuilder[$this->target . '_php_after_getitem'][$view['settings']->code]) && ComponentbuilderHelper::checkString($this->customScriptBuilder[$this->target . '_php_after_getitem'][$view['settings']->code])) - { - // ###CUSTOM_ADMIN_AFTER_GET_ITEM### <<>> - $this->fileContentDynamic[$view['settings']->code]['###CUSTOM_ADMIN_AFTER_GET_ITEM###'] = $this->setPlaceholders($this->customScriptBuilder[$this->target . '_php_after_getitem'][$view['settings']->code], $this->placeholders); - // clear some memory - unset($this->customScriptBuilder[$this->target . '_php_after_getitem'][$view['settings']->code]); - } - else - { - // ###CUSTOM_ADMIN_AFTER_GET_ITEM### <<>> - $this->fileContentDynamic[$view['settings']->code]['###CUSTOM_ADMIN_AFTER_GET_ITEM###'] = ''; - } + // ###CUSTOM_ADMIN_AFTER_GET_ITEM### <<>> + $this->fileContentDynamic[$view['settings']->code]['###CUSTOM_ADMIN_AFTER_GET_ITEM###'] = $this->getCustomScriptBuilder($this->target . '_php_after_getitem', $view['settings']->code, '', null, true); } elseif ($view['settings']->main_get->gettype == 2) { // ###CUSTOM_ADMIN_GET_LIST_QUERY### <<>> $this->fileContentDynamic[$view['settings']->code]['###CUSTOM_ADMIN_GET_LIST_QUERY###'] = $this->setCustomViewListQuery($view['settings']->main_get, $view['settings']->code); - // check if there is any custom script - if (isset($this->customScriptBuilder[$this->target . '_php_getlistquery'][$view['settings']->code]) && ComponentbuilderHelper::checkString($this->customScriptBuilder[$this->target . '_php_getlistquery'][$view['settings']->code])) - { - // ###CUSTOM_ADMIN_CUSTOM_BEFORE_LIST_QUERY### <<>> - $this->fileContentDynamic[$view['settings']->code]['###CUSTOM_ADMIN_CUSTOM_BEFORE_LIST_QUERY###'] = PHP_EOL . $this->setPlaceholders($this->customScriptBuilder[$this->target . '_php_getlistquery'][$view['settings']->code], $this->placeholders); - // clear some memory - unset($this->customScriptBuilder[$this->target . '_php_getlistquery'][$view['settings']->code]); - } - else - { - // ###CUSTOM_ADMIN_CUSTOM_BEFORE_LIST_QUERY### <<>> - $this->fileContentDynamic[$view['settings']->code]['###CUSTOM_ADMIN_CUSTOM_BEFORE_LIST_QUERY###'] = ''; - } + // ###CUSTOM_ADMIN_CUSTOM_BEFORE_LIST_QUERY### <<>> + $this->fileContentDynamic[$view['settings']->code]['###CUSTOM_ADMIN_CUSTOM_BEFORE_LIST_QUERY###'] = $this->getCustomScriptBuilder($this->target . '_php_getlistquery', $view['settings']->code, PHP_EOL, null, true); - // check if there is any custom script - if (isset($this->customScriptBuilder[$this->target . '_php_before_getitems'][$view['settings']->code]) && ComponentbuilderHelper::checkString($this->customScriptBuilder[$this->target . '_php_before_getitems'][$view['settings']->code])) - { - // ###CUSTOM_ADMIN_BEFORE_GET_ITEMS### <<>> - $this->fileContentDynamic[$view['settings']->code]['###CUSTOM_ADMIN_BEFORE_GET_ITEMS###'] = PHP_EOL . $this->setPlaceholders($this->customScriptBuilder[$this->target . '_php_before_getitems'][$view['settings']->code], $this->placeholders); - // clear some memory - unset($this->customScriptBuilder[$this->target . '_php_before_getitems'][$view['settings']->code]); - } - else - { - // ###CUSTOM_ADMIN_BEFORE_GET_ITEMS### <<>> - $this->fileContentDynamic[$view['settings']->code]['###CUSTOM_ADMIN_BEFORE_GET_ITEMS###'] = ''; - } + // ###CUSTOM_ADMIN_BEFORE_GET_ITEMS### <<>> + $this->fileContentDynamic[$view['settings']->code]['###CUSTOM_ADMIN_BEFORE_GET_ITEMS###'] = $this->getCustomScriptBuilder($this->target . '_php_before_getitems', $view['settings']->code, PHP_EOL, null, true); // ###CUSTOM_ADMIN_GET_ITEMS### <<>> $this->fileContentDynamic[$view['settings']->code]['###CUSTOM_ADMIN_GET_ITEMS###'] = $this->setCustomViewGetItems($view['settings']->main_get, $view['settings']->code); - // check if there is any custom script - if (isset($this->customScriptBuilder[$this->target . '_php_after_getitems'][$view['settings']->code]) && ComponentbuilderHelper::checkString($this->customScriptBuilder[$this->target . '_php_after_getitems'][$view['settings']->code])) - { - // ###CUSTOM_ADMIN_AFTER_GET_ITEMS### <<>> - $this->fileContentDynamic[$view['settings']->code]['###CUSTOM_ADMIN_AFTER_GET_ITEMS###'] = PHP_EOL . $this->setPlaceholders($this->customScriptBuilder[$this->target . '_php_after_getitems'][$view['settings']->code], $this->placeholders); - // clear some memory - unset($this->customScriptBuilder[$this->target . '_php_after_getitems'][$view['settings']->code]); - } - else - { - // ###CUSTOM_ADMIN_AFTER_GET_ITEMS### <<>> - $this->fileContentDynamic[$view['settings']->code]['###CUSTOM_ADMIN_AFTER_GET_ITEMS###'] = ''; - } + // ###CUSTOM_ADMIN_AFTER_GET_ITEMS### <<>> + $this->fileContentDynamic[$view['settings']->code]['###CUSTOM_ADMIN_AFTER_GET_ITEMS###'] = $this->getCustomScriptBuilder($this->target . '_php_after_getitems', $view['settings']->code, PHP_EOL, null, true); } // ###CUSTOM_ADMIN_CUSTOM_METHODS### <<>> @@ -917,36 +855,15 @@ class Infusion extends Interpretation { // set user permission access check ###USER_PERMISSION_CHECK_ACCESS### <<>> $this->fileContentDynamic[$view['settings']->code]['###USER_PERMISSION_CHECK_ACCESS###'] = $this->setUserPermissionCheckAccess($view, 1); - // check if there is any custom script - if (isset($this->customScriptBuilder[$this->target . '_php_before_getitem'][$view['settings']->code]) && ComponentbuilderHelper::checkString($this->customScriptBuilder[$this->target . '_php_before_getitem'][$view['settings']->code])) - { - // ###SITE_BEFORE_GET_ITEM### <<>> - $this->fileContentDynamic[$view['settings']->code]['###SITE_BEFORE_GET_ITEM###'] = $this->setPlaceholders($this->customScriptBuilder[$this->target . '_php_before_getitem'][$view['settings']->code], $this->placeholders); - // clear some memory - unset($this->customScriptBuilder[$this->target . '_php_before_getitem'][$view['settings']->code]); - } - else - { - // ###SITE_BEFORE_GET_ITEM### <<>> - $this->fileContentDynamic[$view['settings']->code]['###SITE_BEFORE_GET_ITEM###'] = ''; - } + + // ###SITE_BEFORE_GET_ITEM### <<>> + $this->fileContentDynamic[$view['settings']->code]['###SITE_BEFORE_GET_ITEM###'] = $this->getCustomScriptBuilder($this->target . '_php_before_getitem', $view['settings']->code, '', null, true); // ###SITE_GET_ITEM### <<>> $this->fileContentDynamic[$view['settings']->code]['###SITE_GET_ITEM###'] = $this->setCustomViewGetItem($view['settings']->main_get, $view['settings']->code, "\t\t"); - // check if there is any custom script - if (isset($this->customScriptBuilder[$this->target . '_php_after_getitem'][$view['settings']->code]) && ComponentbuilderHelper::checkString($this->customScriptBuilder[$this->target . '_php_after_getitem'][$view['settings']->code])) - { - // ###SITE_AFTER_GET_ITEM### <<>> - $this->fileContentDynamic[$view['settings']->code]['###SITE_AFTER_GET_ITEM###'] = $this->setPlaceholders($this->customScriptBuilder[$this->target . '_php_after_getitem'][$view['settings']->code], $this->placeholders); - // clear some memory - unset($this->customScriptBuilder[$this->target . '_php_after_getitem'][$view['settings']->code]); - } - else - { - // ###SITE_AFTER_GET_ITEM### <<>> - $this->fileContentDynamic[$view['settings']->code]['###SITE_AFTER_GET_ITEM###'] = ''; - } + // ###SITE_AFTER_GET_ITEM### <<>> + $this->fileContentDynamic[$view['settings']->code]['###SITE_AFTER_GET_ITEM###'] = $this->getCustomScriptBuilder($this->target . '_php_after_getitem', $view['settings']->code, '', null, true); } elseif ($view['settings']->main_get->gettype == 2) { @@ -955,36 +872,14 @@ class Infusion extends Interpretation // ###SITE_GET_LIST_QUERY### <<>> $this->fileContentDynamic[$view['settings']->code]['###SITE_GET_LIST_QUERY###'] = $this->setCustomViewListQuery($view['settings']->main_get, $view['settings']->code); - // check if there is any custom script - if (isset($this->customScriptBuilder[$this->target . '_php_before_getitems'][$view['settings']->code]) && ComponentbuilderHelper::checkString($this->customScriptBuilder[$this->target . '_php_before_getitems'][$view['settings']->code])) - { - // ###SITE_BEFORE_GET_ITEMS### <<>> - $this->fileContentDynamic[$view['settings']->code]['###SITE_BEFORE_GET_ITEMS###'] = PHP_EOL . $this->setPlaceholders($this->customScriptBuilder[$this->target . '_php_before_getitems'][$view['settings']->code], $this->placeholders); - // clear some memory - unset($this->customScriptBuilder[$this->target . '_php_before_getitems'][$view['settings']->code]); - } - else - { - // ###SITE_BEFORE_GET_ITEMS### <<>> - $this->fileContentDynamic[$view['settings']->code]['###SITE_BEFORE_GET_ITEMS###'] = ''; - } + // ###SITE_BEFORE_GET_ITEMS### <<>> + $this->fileContentDynamic[$view['settings']->code]['###SITE_BEFORE_GET_ITEMS###'] = $this->getCustomScriptBuilder($this->target . '_php_before_getitems', $view['settings']->code, PHP_EOL, null, true); // ###SITE_GET_ITEMS### <<>> $this->fileContentDynamic[$view['settings']->code]['###SITE_GET_ITEMS###'] = $this->setCustomViewGetItems($view['settings']->main_get, $view['settings']->code); - // check if there is any custom script - if (isset($this->customScriptBuilder[$this->target . '_php_after_getitems'][$view['settings']->code]) && ComponentbuilderHelper::checkString($this->customScriptBuilder[$this->target . '_php_after_getitems'][$view['settings']->code])) - { - // ###SITE_AFTER_GET_ITEMS### <<>> - $this->fileContentDynamic[$view['settings']->code]['###SITE_AFTER_GET_ITEMS###'] = PHP_EOL . $this->setPlaceholders($this->customScriptBuilder[$this->target . '_php_after_getitems'][$view['settings']->code], $this->placeholders); - // clear some memory - unset($this->customScriptBuilder[$this->target . '_php_after_getitems'][$view['settings']->code]); - } - else - { - // ###SITE_AFTER_GET_ITEMS### <<>> - $this->fileContentDynamic[$view['settings']->code]['###SITE_AFTER_GET_ITEMS###'] = ''; - } + // ###SITE_AFTER_GET_ITEMS### <<>> + $this->fileContentDynamic[$view['settings']->code]['###SITE_AFTER_GET_ITEMS###'] = $this->getCustomScriptBuilder($this->target . '_php_after_getitems', $view['settings']->code, PHP_EOL, null, true); } // add to lang array if (!isset($this->langContent['site'][$this->langPrefix . '_' . $view['settings']->CODE])) diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.ini b/admin/language/en-GB/en-GB.com_componentbuilder.ini index 9a1ac3110..3251cc8e8 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.ini @@ -5325,6 +5325,7 @@ COM_COMPONENTBUILDER_MATCH_FIELD="Match Field" COM_COMPONENTBUILDER_MATCH_OPTIONS="Match Options" COM_COMPONENTBUILDER_MAX_LENGTH_ONLY_FOUR_TEXT_FIELD="Max Length (only 4 text_field)" COM_COMPONENTBUILDER_MERGE="Merge" +COM_COMPONENTBUILDER_MINIFY_JAVASCRIPT="Minify JavaScript" COM_COMPONENTBUILDER_MIN_LENGTH_ONLY_FOUR_TEXT_FIELD="Min Length (only 4 text_field)" COM_COMPONENTBUILDER_NAME="Name" COM_COMPONENTBUILDER_NAME_ASC="Name (Asc)" @@ -5574,6 +5575,7 @@ COM_COMPONENTBUILDER_SET_A_CLASS_VALUE_FOR_THE_LIST_VIEW_OF_THIS_FIELD="Set a cl COM_COMPONENTBUILDER_SHARE_SNIPPETS="Share Snippets" COM_COMPONENTBUILDER_SHOULD_JCB_INSERT_THE_CUSTOM_CODE_PLACEHOLDERS_THIS_IS_ONLY_APPLICABLE_IF_THIS_COMPONENT_HAS_CUSTOM_CODE="Should JCB insert the custom code placeholders? This is only applicable if this component has custom code." COM_COMPONENTBUILDER_SHOULD_THE_COMPONENT_BE_MOVED_TO_YOUR_LOCAL_REPOSITORY_FOLDER="Should the component be moved to your local repository folder?" +COM_COMPONENTBUILDER_SHOULD_THE_JAVASCRIPT_BE_MINIFIED_IN_THE_COMPONENT="Should the JavaScript be minified in the component." COM_COMPONENTBUILDER_SHOULD_THE_ZIPPED_PACKAGE_OF_THE_COMPONENT_BE_MOVED_TO_THE_LOCAL_BACKUP_AND_REMOTE_SALES_SERVER_THIS_IS_ONLY_APPLICABLE_IF_THIS_COMPONENT_HAS_THOSE_VALUES_SET="Should the zipped package of the component be moved to the local backup and remote sales server? This is only applicable if this component has those values set." COM_COMPONENTBUILDER_SHOULD_THIS_FIELD_BE_ESCAPED_IN_THE_LIST_VIEW="Should this field be escaped in the list view." COM_COMPONENTBUILDER_SHOULD_WE_BE_SHOWING_MORE_ELABORATE_INFORMATION_DURING_IMPORT="Should we be showing more elaborate information during import." diff --git a/admin/models/compiler.php b/admin/models/compiler.php index af518f26f..3406f632c 100644 --- a/admin/models/compiler.php +++ b/admin/models/compiler.php @@ -170,14 +170,15 @@ class ComponentbuilderModelCompiler extends JModelList return $db->loadObjectList(); } - public function builder($version, $id, $backup, $repo, $addPlaceholders, $debugLinenr) + public function builder($version, $id, $backup, $repo, $addPlaceholders, $debugLinenr, $minify) { - $set['joomlaVersion'] = $version; + $set['joomlaVersion'] = $version; $set['componentId'] = $id; $set['addBackup'] = $backup; $set['addRepo'] = $repo; $set['addPlaceholders'] = $addPlaceholders; $set['debugLinenr'] = $debugLinenr; + $set['minify'] = $minify; // start up Compiler $this->compiler = new Compiler($set); if($this->compiler) diff --git a/admin/views/compiler/view.html.php b/admin/views/compiler/view.html.php index dfa370c99..7f6dbdeac 100644 --- a/admin/views/compiler/view.html.php +++ b/admin/views/compiler/view.html.php @@ -186,6 +186,32 @@ class ComponentbuilderViewCompiler extends JViewLegacy // add to form $form[] = $debuglinenr; + // get the minify radio field + $minify = JFormHelper::loadFieldType('radio',true); + // start minify xml + $minifyXML = new SimpleXMLElement(''); + // minify attributes + $minifyAttributes = array( + 'type' => 'radio', + 'name' => 'minify', + 'label' => 'COM_COMPONENTBUILDER_MINIFY_JAVASCRIPT', + 'class' => 'btn-group btn-group-yesno', + 'description' => 'COM_COMPONENTBUILDER_SHOULD_THE_JAVASCRIPT_BE_MINIFIED_IN_THE_COMPONENT', + 'default' => '2'); + // load the minify attributes + ComponentbuilderHelper::xmlAddAttributes($minifyXML, $minifyAttributes); + // start the minify options + $minifyOptions = array( + '2' => 'COM_COMPONENTBUILDER_GLOBAL', + '1' => 'COM_COMPONENTBUILDER_YES', + '0' => 'COM_COMPONENTBUILDER_NO'); + // load the minify options + ComponentbuilderHelper::xmlAddOptions($minifyXML, $minifyOptions); + // setup the minify radio field + $minify->setup($minifyXML,2); + // add to form + $form[] = $minify; + // get the component list field $component = JFormHelper::loadFieldType('list',true); // start component xml diff --git a/admin/views/joomla_components/tmpl/default.php b/admin/views/joomla_components/tmpl/default.php index 9e03d5ff1..0c65d07f6 100644 --- a/admin/views/joomla_components/tmpl/default.php +++ b/admin/views/joomla_components/tmpl/default.php @@ -98,7 +98,7 @@ if ($this->saveOrder) \ No newline at end of file diff --git a/admin/views/languages/tmpl/default.php b/admin/views/languages/tmpl/default.php index d3869dddc..c70621df2 100644 --- a/admin/views/languages/tmpl/default.php +++ b/admin/views/languages/tmpl/default.php @@ -96,4 +96,27 @@ if ($this->saveOrder) - \ No newline at end of file + + \ No newline at end of file