1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-09 08:17:12 +02:00
This commit is contained in:
Ryan Cramer
2022-03-18 08:57:19 -04:00
parent 3280507bec
commit fd538897d0
2 changed files with 10 additions and 6 deletions

View File

@@ -9,7 +9,8 @@
* *
* ProcessWire 3.x, Copyright 2022 by Ryan Cramer * ProcessWire 3.x, Copyright 2022 by Ryan Cramer
* https://processwire.com * https://processwire.com
* *
* @method Fieldgroup clone(Saveable $item, $name = '')
* @method int saveContext(Fieldgroup $fieldgroup) * @method int saveContext(Fieldgroup $fieldgroup)
* @method array getExportData(Fieldgroup $fieldgroup) * @method array getExportData(Fieldgroup $fieldgroup)
* @method array setImportData(Fieldgroup $fieldgroup, array $data) * @method array setImportData(Fieldgroup $fieldgroup, array $data)

View File

@@ -380,7 +380,7 @@ class Templates extends WireSaveableItems {
if($fieldgroup->name == $item->name) { if($fieldgroup->name == $item->name) {
// if the fieldgroup and the item have the same name, we'll also clone the fieldgroup // if the fieldgroup and the item have the same name, we'll also clone the fieldgroup
$fieldgroup = $this->wire('fieldgroups')->clone($fieldgroup, $name); $fieldgroup = $this->wire()->fieldgroups->clone($fieldgroup, $name);
$item->fieldgroup = $fieldgroup; $item->fieldgroup = $fieldgroup;
} }
@@ -388,10 +388,13 @@ class Templates extends WireSaveableItems {
if($item && $item->id && !$item->altFilename) { if($item && $item->id && !$item->altFilename) {
// now that we have a clone, lets also clone the template file, if it exists // now that we have a clone, lets also clone the template file, if it exists
$path = $this->wire('config')->paths->templates; $config = $this->wire()->config;
$file = $path . $item->name . '.' . $this->wire('config')->templateExtension; $files = $this->wire()->files;
if($original->filenameExists() && is_writable($path) && !file_exists($file)) { $path = $config->paths->templates;
if(copy($original->filename, $file)) $item->filename = $file; $ext = $config->templateExtension ? $config->templateExtension : 'php';
$file = "$path$item->name.$ext";
if($original->filenameExists() && is_writable($path) && !$files->exists($file)) {
if($files->copy($original->filename, $file)) $item->filename = $file;
} }
} }