Upgrade Kirby from 4.3.0 to 4.4.0
This commit is contained in:
parent
03905dbd83
commit
3bed01af75
293 changed files with 54254 additions and 187 deletions
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Kirby\Filesystem;
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\Language;
|
||||
use Kirby\Toolkit\Str;
|
||||
|
||||
/**
|
||||
|
|
@ -28,44 +30,32 @@ use Kirby\Toolkit\Str;
|
|||
*/
|
||||
class Filename
|
||||
{
|
||||
/**
|
||||
* List of all applicable attributes
|
||||
*/
|
||||
protected array $attributes;
|
||||
|
||||
/**
|
||||
* The sanitized file extension
|
||||
*/
|
||||
protected string $extension;
|
||||
|
||||
/**
|
||||
* The source original filename
|
||||
*/
|
||||
protected string $filename;
|
||||
|
||||
/**
|
||||
* The sanitized file name
|
||||
*/
|
||||
protected string $name;
|
||||
|
||||
/**
|
||||
* The template for the final name
|
||||
*/
|
||||
protected string $template;
|
||||
|
||||
/**
|
||||
* Creates a new Filename object
|
||||
*
|
||||
* @param string $template for the final name
|
||||
* @param array $attributes List of all applicable attributes
|
||||
*/
|
||||
public function __construct(string $filename, string $template, array $attributes = [])
|
||||
{
|
||||
$this->filename = $filename;
|
||||
$this->template = $template;
|
||||
$this->attributes = $attributes;
|
||||
$this->extension = $this->sanitizeExtension(
|
||||
public function __construct(
|
||||
protected string $filename,
|
||||
protected string $template,
|
||||
protected array $attributes = []
|
||||
) {
|
||||
$this->name = $this->sanitizeName($filename);
|
||||
$this->extension = $this->sanitizeExtension(
|
||||
$attributes['format'] ??
|
||||
pathinfo($filename, PATHINFO_EXTENSION)
|
||||
);
|
||||
$this->name = $this->sanitizeName($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -242,7 +232,24 @@ class Filename
|
|||
*/
|
||||
protected function sanitizeName(string $name): string
|
||||
{
|
||||
return F::safeBasename($name);
|
||||
// temporarily store language rules
|
||||
$rules = Str::$language;
|
||||
$kirby = App::instance(null, true);
|
||||
|
||||
// if current user, add rules for their language to `Str` class
|
||||
if ($user = $kirby?->user()) {
|
||||
Str::$language = [
|
||||
...Str::$language,
|
||||
...Language::loadRules($user->language())];
|
||||
}
|
||||
|
||||
// sanitize name
|
||||
$name = F::safeBasename($this->filename);
|
||||
|
||||
// restore language rules
|
||||
Str::$language = $rules;
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue