From 27ff09226b5263344485cecb0a09bebf4d55526b Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Tue, 12 Dec 2017 02:28:35 +0200 Subject: [PATCH] execution order fix to insure folders are loaded --- README.md | 2 +- admin/README.txt | 2 +- admin/helpers/compiler/b_Structure.php | 63 +++++++++++++++++++------- componentbuilder.xml | 2 +- 4 files changed, 50 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index cebb2aee4..fad0ea3ff 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ Component Builder is mapped as a component in itself on my local development env + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Component Builder](http://vdm.bz/component-builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 11th December, 2017 ++ *Last Build*: 12th December, 2017 + *Version*: 2.6.6 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html diff --git a/admin/README.txt b/admin/README.txt index cebb2aee4..fad0ea3ff 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -111,7 +111,7 @@ Component Builder is mapped as a component in itself on my local development env + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Component Builder](http://vdm.bz/component-builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 11th December, 2017 ++ *Last Build*: 12th December, 2017 + *Version*: 2.6.6 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html diff --git a/admin/helpers/compiler/b_Structure.php b/admin/helpers/compiler/b_Structure.php index 790aba427..53fcb13d7 100644 --- a/admin/helpers/compiler/b_Structure.php +++ b/admin/helpers/compiler/b_Structure.php @@ -327,17 +327,17 @@ class Structure extends Get $this->componentPath = $this->compilerPath.'/'.$this->componentFolderName; // set the template path for custom $this->templatePathCustom = $this->params->get('custom_folder_path', JPATH_COMPONENT_ADMINISTRATOR.'/custom'); - // set the Joomla Version Data - $this->joomlaVersionData = $this->setJoomlaVersionData(); // make sure there is no old build $this->removeFolder($this->componentPath); + // load the libraries files/folders and url's + $this->setLibaries(); + // set the Joomla Version Data + $this->joomlaVersionData = $this->setJoomlaVersionData(); // set the new folders if (!$this->setFolders()) { return false; } - // load the libraries files/folders and url's - $this->setLibaries(); // set all static folders and files if (!$this->setStatic()) { @@ -348,7 +348,6 @@ class Structure extends Get { return false; } - return true; } return false; @@ -381,6 +380,22 @@ class Structure extends Get { if (ComponentbuilderHelper::checkArray($this->libraries)) { + // creat the main component folder + if (!JFolder::exists($this->componentPath)) + { + JFolder::create($this->componentPath); + // count the folder created + $this->folderCount++; + $this->indexHTML(''); + } + // create media path if not set + if (!JFolder::exists( $this->componentPath . '/media')) + { + JFolder::create($this->componentPath . '/media'); + // count the folder created + $this->folderCount++; + $this->indexHTML('/media'); + } foreach($this->libraries as $id => &$library) { if (ComponentbuilderHelper::checkObject($library)) @@ -407,20 +422,26 @@ class Structure extends Get if (isset($library->urls) && ComponentbuilderHelper::checkArray($library->urls)) { // build media folder path - $mediaPath = '/media/' . strtolower( preg_replace('/\s+/', '-', ComponentbuilderHelper::safeString($library->name, 'filename', ' ', false))); - // create media path if not set - if (!JFolder::exists( $this->componentPath . $mediaPath)) - { - JFolder::create($this->componentPath . $mediaPath); - // count the folder created - $this->folderCount++; - $this->indexHTML($mediaPath); - } + $libFolder = strtolower( preg_replace('/\s+/', '-', ComponentbuilderHelper::safeString($library->name, 'filename', ' ', false))); + $mediaPath = '/media/' . $libFolder; + // should we add the local folder + $addLocalFolder = false; // add to component urls foreach ($library->urls as $n => &$url) { if (isset($url['type']) && $url['type'] > 1 && isset($url['url']) && ComponentbuilderHelper::checkString($url['url'])) { + // create media/lib path if not set + if (!JFolder::exists( $this->componentPath . $mediaPath)) + { + JFolder::create($this->componentPath . $mediaPath); + // count the folder created + $this->folderCount++; + $this->indexHTML($mediaPath); + } + // add local folder + $addLocalFolder = true; + // set file name $fileName = basename($url['url']); // get the file contents $data = ComponentbuilderHelper::getFileContents($url['url']); @@ -455,6 +476,16 @@ class Structure extends Get $this->fileCount++; } } + // only add if local + if ($addLocalFolder) + { + // check if we sould add it to the media xml list + if (!isset($this->fileContentStatic['###EXSTRA_MEDIA_FOLDERS###'])) + { + $this->fileContentStatic['###EXSTRA_MEDIA_FOLDERS###'] = ''; + } + $this->fileContentStatic['###EXSTRA_MEDIA_FOLDERS###'] .= PHP_EOL."\t\t".$libFolder.""; + } } // if config fields are found load into component config (avoiding dublicates) if (isset($library->how) && $library->how > 1 && isset($library->config) && ComponentbuilderHelper::checkArray($library->config)) @@ -497,7 +528,7 @@ class Structure extends Get { if (ComponentbuilderHelper::checkObject($this->joomlaVersionData->create)) { - // creat the main componet folder + // creat the main component folder if (!JFolder::exists($this->componentPath)) { JFolder::create($this->componentPath); @@ -1099,7 +1130,7 @@ class Structure extends Get { $this->fileContentStatic['###EXSTRA_MEDIA_FOLDERS###'] = ''; } - if (count($pathArray) == 1 && $firstFolder === 'media') + if (count($pathArray) >= 1 && $firstFolder === 'media') { $this->fileContentStatic['###EXSTRA_MEDIA_FOLDERS###'] .= PHP_EOL."\t\t".$lastFolder.""; } diff --git a/componentbuilder.xml b/componentbuilder.xml index 2c159cdb3..224d7756f 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 11th December, 2017 + 12th December, 2017 Llewellyn van der Merwe joomla@vdm.io http://vdm.bz/component-builder