From ccbf21fddbd772afae22ff484dddea8d98f24408 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Wed, 6 Mar 2019 22:32:16 +0200 Subject: [PATCH] resolved gh-380 to insure that the list view JS file also gets added if set. --- README.md | 2 +- admin/README.txt | 2 +- admin/compiler/joomla_3/JViewLegacy_list.php | 2 +- admin/compiler/joomla_3/settings.json | 5 ++ admin/compiler/joomla_3/viewFile.js | 2 +- admin/helpers/compiler/e_Interpretation.php | 71 +++++++++++++------- admin/helpers/compiler/f_Infusion.php | 6 +- componentbuilder.xml | 2 +- 8 files changed, 62 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index e9f4ab0ba..c460df5dc 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 5th March, 2019 ++ *Last Build*: 6th March, 2019 + *Version*: 2.9.13 + *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt diff --git a/admin/README.txt b/admin/README.txt index e9f4ab0ba..c460df5dc 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -146,7 +146,7 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 5th March, 2019 ++ *Last Build*: 6th March, 2019 + *Version*: 2.9.13 + *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt diff --git a/admin/compiler/joomla_3/JViewLegacy_list.php b/admin/compiler/joomla_3/JViewLegacy_list.php index da24aba75..3935b832c 100644 --- a/admin/compiler/joomla_3/JViewLegacy_list.php +++ b/admin/compiler/joomla_3/JViewLegacy_list.php @@ -189,7 +189,7 @@ class ###Component###View###Views### extends JViewLegacy $this->document = JFactory::getDocument(); } $this->document->setTitle(JText::_('COM_###COMPONENT###_###VIEWS###')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_###component###/assets/css/###views###.css", (###Component###Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_###component###/assets/css/###views###.css", (###Component###Helper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');###ADMIN_ADD_JAVASCRIPT_FILE### } /** diff --git a/admin/compiler/joomla_3/settings.json b/admin/compiler/joomla_3/settings.json index 13c789464..7a49c9bea 100644 --- a/admin/compiler/joomla_3/settings.json +++ b/admin/compiler/joomla_3/settings.json @@ -503,6 +503,11 @@ "path": "c0mp0n3nt/", "rename": "update_server", "type": "update_server" + }, + "viewFile.js": { + "path": "c0mp0n3nt/admin/assets/js", + "rename": "viewFile", + "type": "javascript_file" } }, "site": { diff --git a/admin/compiler/joomla_3/viewFile.js b/admin/compiler/joomla_3/viewFile.js index 9c701e5be..d855708a8 100644 --- a/admin/compiler/joomla_3/viewFile.js +++ b/admin/compiler/joomla_3/viewFile.js @@ -1,4 +1,4 @@ ###BOM### /* JS Document */ -###ADMINJS### \ No newline at end of file +###ADMIN_JAVASCRIPT_FILE### \ No newline at end of file diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index b7a78792f..ee2fbd346 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -96,11 +96,11 @@ class Interpretation extends Fields public $validationFixBuilder = array(); /** - * The edit body script builder + * The view script builder * * @var array */ - public $editBodyViewScriptBuilder = array(); + public $viewScriptBuilder = array(); /** * The target relation control @@ -9646,15 +9646,12 @@ class Interpretation extends Fields $fileScript = $initial . $func . $validation . $isSet; $footerScript = $listener; } - // add custom script to file - if (isset($this->customScriptBuilder['view_file'][$viewName]) && ComponentbuilderHelper::checkString($this->customScriptBuilder['view_file'][$viewName])) + // add custom script to edit form JS file + if (!isset($fileScript)) { - if (!isset($fileScript)) - { - $fileScript = ''; - } - $fileScript .= PHP_EOL . PHP_EOL . $this->setPlaceholders($this->customScriptBuilder['view_file'][$viewName], $this->placeholders); + $fileScript = ''; } + $fileScript .= $this->getCustomScriptBuilder('view_file', $viewName, PHP_EOL . PHP_EOL, null, true, ''); // add custom script to footer if (isset($this->customScriptBuilder['view_footer'][$viewName]) && ComponentbuilderHelper::checkString($this->customScriptBuilder['view_footer'][$viewName])) { @@ -9670,6 +9667,37 @@ class Interpretation extends Fields unset($customFooterScript); } } + // set view listname + $viewName_list = ComponentbuilderHelper::safeString($viewArray['settings']->name_list); + // add custom script to list view JS file + if (($list_fileScript = $this->getCustomScriptBuilder('views_file', $viewName, PHP_EOL . PHP_EOL, null, true, false)) !== false && + ComponentbuilderHelper::checkString($list_fileScript)) + { + // get dates + $_created = $this->getCreatedDate($viewArray); + $_modified = $this->getLastModifiedDate($viewArray); + // add file to view + $_target = array($this->target => $viewName_list); + $_config = array($this->hhh . 'CREATIONDATE' . $this->hhh => $_created, $this->hhh . 'BUILDDATE' . $this->hhh => $_modified, $this->hhh . 'VERSION' . $this->hhh => $viewArray['settings']->version); + $this->buildDynamique($_target, 'javascript_file', false, $_config); + // set path + $_path = '/administrator/components/com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '/assets/js/' . $viewName_list . '.js'; + // load the file to the list view + $this->fileContentDynamic[$viewName_list][$this->hhh . 'ADMIN_ADD_JAVASCRIPT_FILE' . $this->hhh] = PHP_EOL . PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Add List View JavaScript File" . PHP_EOL . $this->_t(2) . $this->setIncludeLibScript($_path); + } + else + { + $list_fileScript = ''; + $this->fileContentDynamic[$viewName_list][$this->hhh . 'ADMIN_ADD_JAVASCRIPT_FILE' . $this->hhh] = ''; + } + // minfy the script + if ($this->minify && isset($list_fileScript) && ComponentbuilderHelper::checkString($list_fileScript)) + { + // minify the fielScript javscript + $minifier = new JS; + $minifier->add($list_fileScript); + $list_fileScript = $minifier->minify(); + } // minfy the script if ($this->minify && isset($fileScript) && ComponentbuilderHelper::checkString($fileScript)) { @@ -9687,6 +9715,12 @@ class Interpretation extends Fields $footerScript = $minifier->minify(); } // make sure there is script to add + if (isset($list_fileScript) && ComponentbuilderHelper::checkString($list_fileScript)) + { + // load the script + $this->viewScriptBuilder[$viewName]['list_fileScript'] = $list_fileScript; + } + // make sure there is script to add if (isset($fileScript) && ComponentbuilderHelper::checkString($fileScript)) { // add the head script if set @@ -9695,7 +9729,7 @@ class Interpretation extends Fields $fileScript = "// Some Global Values" . PHP_EOL . $head . PHP_EOL . $fileScript; } // load the script - $this->editBodyViewScriptBuilder[$viewName]['fileScript'] = $fileScript; + $this->viewScriptBuilder[$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)) @@ -9711,7 +9745,7 @@ class Interpretation extends Fields { // add the needed script tags $footerScript = PHP_EOL . PHP_EOL . '"; - $this->editBodyViewScriptBuilder[$viewName]['footerScript'] = $footerScript; + $this->viewScriptBuilder[$viewName]['footerScript'] = $footerScript; } } @@ -10306,20 +10340,11 @@ class Interpretation extends Fields return $clear; } - public function setViewScript(&$view) + public function setViewScript(&$view, $type) { - if (isset($this->editBodyViewScriptBuilder[$view]) && isset($this->editBodyViewScriptBuilder[$view]['fileScript'])) + if (isset($this->viewScriptBuilder[$view]) && isset($this->viewScriptBuilder[$view][$type])) { - return $this->editBodyViewScriptBuilder[$view]['fileScript']; - } - return ''; - } - - public function setEditBodyScript(&$view) - { - if (isset($this->editBodyViewScriptBuilder[$view]) && isset($this->editBodyViewScriptBuilder[$view]['footerScript'])) - { - return $this->editBodyViewScriptBuilder[$view]['footerScript']; + return $this->viewScriptBuilder[$view][$type]; } return ''; } diff --git a/admin/helpers/compiler/f_Infusion.php b/admin/helpers/compiler/f_Infusion.php index 79b603b10..666461538 100644 --- a/admin/helpers/compiler/f_Infusion.php +++ b/admin/helpers/compiler/f_Infusion.php @@ -285,10 +285,10 @@ class Infusion extends Interpretation $this->buildTheViewScript($view); // VIEW_SCRIPT - $this->fileContentDynamic[$viewName_single][$this->hhh . 'VIEW_SCRIPT' . $this->hhh] = $this->setViewScript($viewName_single); + $this->fileContentDynamic[$viewName_single][$this->hhh . 'VIEW_SCRIPT' . $this->hhh] = $this->setViewScript($viewName_single, 'fileScript'); // EDITBODYSCRIPT - $this->fileContentDynamic[$viewName_single][$this->hhh . 'EDITBODYSCRIPT' . $this->hhh] = $this->setEditBodyScript($viewName_single); + $this->fileContentDynamic[$viewName_single][$this->hhh . 'EDITBODYSCRIPT' . $this->hhh] = $this->setViewScript($viewName_single, 'footerScript'); // AJAXTOKE <<>> $this->fileContentDynamic[$viewName_single][$this->hhh . 'AJAXTOKE' . $this->hhh] = $this->setAjaxToke($viewName_single); @@ -401,6 +401,8 @@ class Infusion extends Interpretation // CHECKINCALL <<>> $this->fileContentDynamic[$viewName_list][$this->hhh . 'CHECKINCALL' . $this->hhh] = ''; } + // admin list file contnet + $this->fileContentDynamic[$viewName_list][$this->hhh . 'ADMIN_JAVASCRIPT_FILE' . $this->hhh] = $this->setViewScript($viewName_list, 'list_fileScript'); // ADMIN_CUSTOM_BUTTONS_LIST $this->fileContentDynamic[$viewName_list][$this->hhh . 'ADMIN_CUSTOM_BUTTONS_LIST' . $this->hhh] = $this->setCustomButtons($view, 3, $this->_t(1)); $this->fileContentDynamic[$viewName_list][$this->hhh . 'ADMIN_CUSTOM_FUNCTION_ONLY_BUTTONS_LIST' . $this->hhh] = $this->setFunctionOnlyButtons($viewName_list); diff --git a/componentbuilder.xml b/componentbuilder.xml index 7f859c5fb..7b7cdb4e0 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 5th March, 2019 + 6th March, 2019 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://www.joomlacomponentbuilder.com