diff --git a/modules/backend/assets/js/october-min.js b/modules/backend/assets/js/october-min.js index 17b58ce59..d960a8189 100644 --- a/modules/backend/assets/js/october-min.js +++ b/modules/backend/assets/js/october-min.js @@ -997,7 +997,7 @@ this.hide() var indicator=$('
') indicator.append($('').text(this.options.text)) indicator.append($('')) -if(this.options.opaque!==undefined&&this.options.opaque){indicator.addClass('is-opaque')} +if(this.options.opaque!==undefined){indicator.addClass('is-opaque')} this.$el.prepend(indicator) this.$el.addClass('in-progress') this.tally++} diff --git a/modules/backend/assets/js/october.loadindicator.js b/modules/backend/assets/js/october.loadindicator.js index 3d45d8c11..9a87d2575 100644 --- a/modules/backend/assets/js/october.loadindicator.js +++ b/modules/backend/assets/js/october.loadindicator.js @@ -44,7 +44,7 @@ var indicator = $('') indicator.append($('').text(this.options.text)) indicator.append($('')) - if (this.options.opaque !== undefined && this.options.opaque) { + if (this.options.opaque !== undefined) { indicator.addClass('is-opaque') } diff --git a/modules/cms/models/ThemeImport.php b/modules/cms/models/ThemeImport.php index 85c12ddd2..5e9fa034f 100644 --- a/modules/cms/models/ThemeImport.php +++ b/modules/cms/models/ThemeImport.php @@ -6,6 +6,7 @@ use Model; use ApplicationException; use October\Rain\Filesystem\Zip; use Cms\Classes\Theme as CmsTheme; +use FilesystemIterator; use Exception; /** @@ -110,12 +111,12 @@ class ThemeImport extends Model // } if (File::isDirectory($tempPath.'/meta')) { - File::copyDirectory($tempPath.'/meta', $themePath.'/meta'); + $this->copyDirectory($tempPath.'/meta', $themePath.'/meta'); } foreach ($this->folders as $folder) { if (!array_key_exists($folder, $this->getFoldersOptions())) continue; - File::copyDirectory($tempPath.'/'.$folder, $themePath.'/'.$folder); + $this->copyDirectory($tempPath.'/'.$folder, $themePath.'/'.$folder); } File::deleteDirectory($tempPath); @@ -136,4 +137,48 @@ class ThemeImport extends Model } } + /** + * Helper for copying directories that supports the ability + * to not overwrite existing files. Inherited from File::copyDirectory + * + * @param string $directory + * @param string $destination + * @return bool + */ + protected function copyDirectory($directory, $destination) + { + // Preference is to overwrite existing files + if ($this->overwrite) { + return File::copyDirectory($directory, $destination); + } + + if (!File::isDirectory($directory)) return false; + + $options = FilesystemIterator::SKIP_DOTS; + + if (!File::isDirectory($destination)) { + File::makeDirectory($destination, 0777, true); + } + + $items = new FilesystemIterator($directory, $options); + + foreach ($items as $item) { + $target = $destination.'/'.$item->getBasename(); + + if ($item->isDir()) { + $path = $item->getPathname(); + + if (!$this->copyDirectory($path, $target)) return false; + } + else { + // Do not overwrite existing files + if (File::isFile($target)) continue; + + if (!File::copy($item->getPathname(), $target)) return false; + } + } + + return true; + } + } \ No newline at end of file