mirror of
https://github.com/getgrav/grav.git
synced 2026-03-02 18:41:34 +01:00
Merge branch 'develop' of github.com:getgrav/grav into 1.7
# Conflicts: # system/src/Grav/Common/Page/Pages.php
This commit is contained in:
@@ -21,9 +21,10 @@
|
||||
|
||||
1. [](#new)
|
||||
* Added `FormTrait::getAllFlashes()` method to get all the available form flash objects for the form
|
||||
* Added creation and update timestamps to `FormFlash` objects
|
||||
1. [](#bugfix)
|
||||
* Fixed error in `ImageMedium::url()` if the image cache folder does not exist
|
||||
* Fixed empty form flash name after update
|
||||
* Fixed empty form flash name after file upload or form state update
|
||||
* Fixed a bug in `Route::withParam()` method
|
||||
|
||||
# v1.6.10
|
||||
|
||||
@@ -67,9 +67,11 @@ class Pages
|
||||
/** @var string */
|
||||
protected $check_method;
|
||||
|
||||
/** @var string */
|
||||
protected $pages_cache_id;
|
||||
|
||||
/** @var bool */
|
||||
protected $initialized = false;
|
||||
|
||||
/** @var Types */
|
||||
static protected $types;
|
||||
|
||||
@@ -212,6 +214,10 @@ class Pages
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if ($this->initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
$config = $this->grav['config'];
|
||||
$this->ignore_files = $config->get('system.pages.ignore_files');
|
||||
$this->ignore_folders = $config->get('system.pages.ignore_folders');
|
||||
|
||||
@@ -26,6 +26,10 @@ class FormFlash implements \JsonSerializable
|
||||
protected $url;
|
||||
/** @var array */
|
||||
protected $user;
|
||||
/** @var int */
|
||||
protected $createdTimestamp;
|
||||
/** @var int */
|
||||
protected $updatedTimestamp;
|
||||
/** @var array */
|
||||
protected $data;
|
||||
/** @var array */
|
||||
@@ -69,11 +73,14 @@ class FormFlash implements \JsonSerializable
|
||||
$this->formName = $content['form'] ?? $formName;
|
||||
$this->url = $data['url'] ?? '';
|
||||
$this->user = $data['user'] ?? null;
|
||||
$this->updatedTimestamp = $data['timestamps']['updated'] ?? time();
|
||||
$this->createdTimestamp = $data['timestamps']['created'] ?? $this->updatedTimestamp;
|
||||
$this->data = $data['data'] ?? null;
|
||||
$this->files = $data['files'] ?? [];
|
||||
} else {
|
||||
$this->formName = $formName;
|
||||
$this->url = '';
|
||||
$this->createdTimestamp = $this->updatedTimestamp = time();
|
||||
$this->files = [];
|
||||
}
|
||||
}
|
||||
@@ -94,6 +101,22 @@ class FormFlash implements \JsonSerializable
|
||||
return $this->uniqueId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCreatedTimestamp(): int
|
||||
{
|
||||
return $this->createdTimestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getUpdatedTimestamp(): int
|
||||
{
|
||||
return $this->updatedTimestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
@@ -107,9 +130,15 @@ class FormFlash implements \JsonSerializable
|
||||
*/
|
||||
public function save(): self
|
||||
{
|
||||
$file = $this->getTmpIndex();
|
||||
$file->save($this->jsonSerialize());
|
||||
$this->exists = true;
|
||||
if ($this->data || $this->files) {
|
||||
// Only save if there is data or files to be saved.
|
||||
$file = $this->getTmpIndex();
|
||||
$file->save($this->jsonSerialize());
|
||||
$this->exists = true;
|
||||
} elseif ($this->exists) {
|
||||
// Delete empty form flash if it exists (it carries no information).
|
||||
return $this->delete();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -341,6 +370,10 @@ class FormFlash implements \JsonSerializable
|
||||
'unique_id' => $this->uniqueId,
|
||||
'url' => $this->url,
|
||||
'user' => $this->user,
|
||||
'timestamps' => [
|
||||
'created' => $this->createdTimestamp,
|
||||
'updated' => time(),
|
||||
],
|
||||
'data' => $this->data,
|
||||
'files' => $this->files
|
||||
];
|
||||
|
||||
@@ -154,16 +154,11 @@ class Route
|
||||
* If the parameter exists in both, return Grav parameter.
|
||||
*
|
||||
* @param string $param
|
||||
* @return string|null
|
||||
* @return string|array|null
|
||||
*/
|
||||
public function getParam($param)
|
||||
{
|
||||
$value = $this->getGravParam($param);
|
||||
if ($value === null) {
|
||||
$value = $this->getQueryParam($param);
|
||||
}
|
||||
|
||||
return $value;
|
||||
return $this->getGravParam($param) ?? $this->getQueryParam($param);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,7 +172,7 @@ class Route
|
||||
|
||||
/**
|
||||
* @param string $param
|
||||
* @return string|null
|
||||
* @return string|array|null
|
||||
*/
|
||||
public function getQueryParam($param)
|
||||
{
|
||||
@@ -313,20 +308,22 @@ class Route
|
||||
*/
|
||||
protected function withParam($type, $param, $value)
|
||||
{
|
||||
$typeValue = $this->{$type}[$param] ?? null;
|
||||
$values = $this->{$type} ?? [];
|
||||
$oldValue = $values[$param] ?? null;
|
||||
|
||||
if ($typeValue === $value) {
|
||||
if ($oldValue === $value) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$new = $this->copy();
|
||||
if ($value === null) {
|
||||
unset($new->{$type}[$param]);
|
||||
unset($values[$param]);
|
||||
} else {
|
||||
$typeValue[$param] = $value;
|
||||
$new->{$type} = $typeValue;
|
||||
$values[$param] = $value;
|
||||
}
|
||||
|
||||
$new->{$type} = $values;
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
@@ -377,8 +374,8 @@ class Route
|
||||
$this->language = $gravParts['language'];
|
||||
$this->route = $gravParts['route'];
|
||||
$this->extension = $gravParts['extension'] ?? '';
|
||||
$this->gravParams = $gravParts['params'];
|
||||
$this->queryParams = $parts['query_params'];
|
||||
$this->gravParams = $gravParts['params'] ?: [];
|
||||
$this->queryParams = $parts['query_params'] ?: [];
|
||||
|
||||
} else {
|
||||
$this->root = RouteFactory::getRoot();
|
||||
|
||||
Reference in New Issue
Block a user