mirror of
https://github.com/getgrav/grav.git
synced 2026-07-13 01:43:47 +02:00
Added support for user provided folder in Flex $page->copy()
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
1. [](#improved)
|
||||
* Moved `gregwar/Image` and `gregwar/Cache` in-house to official `getgrav/Image` and `getgrav/Cache` packagist packages. This will help environments with very strict proxy setups that don't allow VCS setup. [#3289](https://github.com/getgrav/grav/issues/3289)
|
||||
* Improved XSS Invalid Protocol detection regex [#3298](https://github.com/getgrav/grav/issues/3298)
|
||||
* Added support for user provided folder in Flex `$page->copy()`
|
||||
1. [](#bugfix)
|
||||
* Fixed `The "Grav/Common/Twig/TwigExtension" extension is not enabled` when using markdown twig tag [#3317](https://github.com/getgrav/grav/issues/3317)
|
||||
* Fixed text field maxlength validation newline issue [#3324](https://github.com/getgrav/grav/issues/3324)
|
||||
|
||||
@@ -320,14 +320,21 @@ trait PageLegacyTrait
|
||||
|
||||
// Find non-existing key.
|
||||
$parentKey = $parent ? $parent->getKey() : '';
|
||||
$key = trim($parentKey . '/' . basename($this->getKey()), '/');
|
||||
$key = preg_replace('/-\d+$/', '', $key);
|
||||
$i = 1;
|
||||
do {
|
||||
$i++;
|
||||
$test = "{$key}-{$i}";
|
||||
} while ($index->containsKey($test));
|
||||
$key = $test;
|
||||
if ($this instanceof FlexPageObject) {
|
||||
$key = trim($parentKey . '/' . $this->folder(), '/');
|
||||
} else {
|
||||
$key = trim($parentKey . '/' . basename($this->getKey()), '/');
|
||||
}
|
||||
|
||||
if ($index->containsKey($key)) {
|
||||
$key = preg_replace('/\d+$/', '', $key);
|
||||
$i = 1;
|
||||
do {
|
||||
$i++;
|
||||
$test = "{$key}{$i}";
|
||||
} while ($index->containsKey($test));
|
||||
$key = $test;
|
||||
}
|
||||
$folder = basename($key);
|
||||
|
||||
// Get the folder name.
|
||||
|
||||
Reference in New Issue
Block a user