Skip to content

Commit

Permalink
Merge branch 'develop-minor' into v5/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
distantnative committed Dec 10, 2024
2 parents cde80bd + 7efb01f commit 9f5424d
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 35 deletions.
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions config/components.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,15 @@
$scoring['score'] += 16 * $score;
$scoring['hits'] += 1;

// check for exact beginning matches
// check for exact beginning matches
} elseif (
$options['words'] === false &&
Str::startsWith($lowerValue, $query) === true
) {
$scoring['score'] += 8 * $score;
$scoring['hits'] += 1;

// check for exact query matches
// check for exact query matches
} elseif ($matches = preg_match_all('!' . $exact . '!ui', $value, $r)) {
$scoring['score'] += 2 * $score;
$scoring['hits'] += $matches;
Expand Down
8 changes: 4 additions & 4 deletions src/Cms/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ public function add($object): static
if ($object instanceof self) {
$this->data = [...$this->data, ...$object->data];

// add a file by id
// add a file by id
} elseif (
is_string($object) === true &&
$file = App::instance()->file($object)
) {
$this->__set($file->id(), $file);

// add a file object
// add a file object
} elseif ($object instanceof File) {
$this->__set($object->id(), $object);

// give a useful error message on invalid input;
// silently ignore "empty" values for compatibility with existing setups
// give a useful error message on invalid input;
// silently ignore "empty" values for compatibility with existing setups
} elseif (in_array($object, [null, false, true], true) !== true) {
throw new InvalidArgumentException(
message: 'You must pass a Files or File object or an ID of an existing file to the Files collection'
Expand Down
8 changes: 4 additions & 4 deletions src/Cms/PagePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ public function items(): Pages|null
if (empty($this->options['query']) === true) {
$items = $this->itemsForParent();

// when subpage navigation is enabled, a parent
// might be passed in addition to the query.
// The parent then takes priority.
// when subpage navigation is enabled, a parent
// might be passed in addition to the query.
// The parent then takes priority.
} elseif ($this->options['subpages'] === true && empty($this->options['parent']) === false) {
$items = $this->itemsForParent();

// search by query
// search by query
} else {
$items = $this->itemsForQuery();
}
Expand Down
8 changes: 4 additions & 4 deletions src/Cms/Pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ public function add($object): static
if ($object instanceof self) {
$this->data = [...$this->data, ...$object->data];

// add a page by id
// add a page by id
} elseif (
is_string($object) === true &&
$page = $site->find($object)
) {
$this->__set($page->id(), $page);

// add a page object
// add a page object
} elseif ($object instanceof Page) {
$this->__set($object->id(), $object);

// give a useful error message on invalid input;
// silently ignore "empty" values for compatibility with existing setups
// give a useful error message on invalid input;
// silently ignore "empty" values for compatibility with existing setups
} elseif (in_array($object, [null, false, true], true) !== true) {
throw new InvalidArgumentException(
message: 'You must pass a Pages or Page object or an ID of an existing page to the Pages collection'
Expand Down
8 changes: 4 additions & 4 deletions src/Cms/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ public function add($object): static
if ($object instanceof self) {
$this->data = [...$this->data, ...$object->data];

// add a user by id
// add a user by id
} elseif (
is_string($object) === true &&
$user = App::instance()->user($object)
) {
$this->__set($user->id(), $user);

// add a user object
// add a user object
} elseif ($object instanceof User) {
$this->__set($object->id(), $object);

// give a useful error message on invalid input;
// silently ignore "empty" values for compatibility with existing setups
// give a useful error message on invalid input;
// silently ignore "empty" values for compatibility with existing setups
} elseif (in_array($object, [null, false, true], true) !== true) {
throw new InvalidArgumentException(
message: 'You must pass a Users or User object or an ID of an existing user to the Users collection'
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ public function detect(
if ($options['allowed'] === '*' || $options['allowed'] === ['*']) {
$this->detectAuto(true);

// fixed environments
// fixed environments
} elseif (empty($options['allowed']) === false) {
$this->detectAllowed($options['allowed']);

// secure auto-detection
// secure auto-detection
} else {
$this->detectAuto();
}
Expand Down
16 changes: 11 additions & 5 deletions src/Image/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Kirby\Image;

use Kirby\Cms\FileVersion;
use Kirby\Content\Content;
use Kirby\Exception\LogicException;
use Kirby\Filesystem\File;
Expand Down Expand Up @@ -115,15 +116,20 @@ public function height(): int
*/
public function html(array $attr = []): string
{
$model = match (true) {
$this->model instanceof FileVersion => $this->model->original(),
default => $this->model
};

// if no alt text explicitly provided,
// try to infer from model content file
if (
$this->model !== null &&
method_exists($this->model, 'content') === true &&
$this->model->content() instanceof Content &&
$this->model->content()->get('alt')->isNotEmpty() === true
$model !== null &&
method_exists($model, 'content') === true &&
$model->content() instanceof Content &&
$model->content()->get('alt')->isNotEmpty() === true
) {
$attr['alt'] ??= $this->model->content()->get('alt')->value();
$attr['alt'] ??= $model->content()->get('alt')->value();
}

if ($url = $this->url()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Panel/Panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public static function response($result, array $options = []): Response
message: 'The data could not be found'
);

// interpret strings as errors
// interpret strings as errors
} elseif (is_string($result) === true) {
$result = new Exception($result);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Parsley/Parsley.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public function mergeOrAppend(array $block): void
) {
$this->blocks[$lastIndex]['content']['text'] .= ' ' . $block['content']['text'];

// append
// append
} else {
$this->blocks[] = $block;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Toolkit/A.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,15 +510,15 @@ public static function merge(array|int ...$arrays): array
) {
$merged[] = $value;

// recursively merge the two array values
// recursively merge the two array values
} elseif (
is_array($value) === true &&
isset($merged[$key]) === true &&
is_array($merged[$key]) === true
) {
$merged[$key] = static::merge($merged[$key], $value, $mode);

// simply overwrite with the value from the second array
// simply overwrite with the value from the second array
} else {
$merged[$key] = $value;
}
Expand Down
8 changes: 6 additions & 2 deletions tests/Cms/Files/FileVersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ public function testToString()
'slug' => 'test'
]);

$original = new File(['filename' => 'test.jpg', 'parent' => $page]);
$original = new File([
'filename' => 'test.jpg',
'parent' => $page,
'content' => ['alt' => 'Test text']
]);
$version = new FileVersion([
'original' => $original,
'root' => static::FIXTURES . '/test.txt',
Expand All @@ -120,6 +124,6 @@ public function testToString()
'url' => $url = 'https://assets.getkirby.com/test-200x200.jpg',
]);

$this->assertSame('<img alt="" src="' . $url . '">', (string)$version);
$this->assertSame('<img alt="Test text" src="' . $url . '">', (string)$version);
}
}
3 changes: 3 additions & 0 deletions vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
'Kirby\\Cms\\Blueprint' => $baseDir . '/src/Cms/Blueprint.php',
'Kirby\\Cms\\Collection' => $baseDir . '/src/Cms/Collection.php',
'Kirby\\Cms\\Collections' => $baseDir . '/src/Cms/Collections.php',
'Kirby\\Cms\\ContentLocks' => $baseDir . '/src/Cms/ContentLocks.php',
'Kirby\\Cms\\Core' => $baseDir . '/src/Cms/Core.php',
'Kirby\\Cms\\Email' => $baseDir . '/src/Cms/Email.php',
'Kirby\\Cms\\Event' => $baseDir . '/src/Cms/Event.php',
Expand Down Expand Up @@ -101,6 +102,7 @@
'Kirby\\Cms\\LicenseType' => $baseDir . '/src/Cms/LicenseType.php',
'Kirby\\Cms\\Loader' => $baseDir . '/src/Cms/Loader.php',
'Kirby\\Cms\\Media' => $baseDir . '/src/Cms/Media.php',
'Kirby\\Cms\\Model' => $baseDir . '/src/Cms/Model.php',
'Kirby\\Cms\\ModelPermissions' => $baseDir . '/src/Cms/ModelPermissions.php',
'Kirby\\Cms\\ModelWithContent' => $baseDir . '/src/Cms/ModelWithContent.php',
'Kirby\\Cms\\Nest' => $baseDir . '/src/Cms/Nest.php',
Expand Down Expand Up @@ -357,6 +359,7 @@
'Kirby\\Toolkit\\Locale' => $baseDir . '/src/Toolkit/Locale.php',
'Kirby\\Toolkit\\Obj' => $baseDir . '/src/Toolkit/Obj.php',
'Kirby\\Toolkit\\Pagination' => $baseDir . '/src/Toolkit/Pagination.php',
'Kirby\\Toolkit\\Properties' => $baseDir . '/src/Toolkit/Properties.php',
'Kirby\\Toolkit\\Silo' => $baseDir . '/src/Toolkit/Silo.php',
'Kirby\\Toolkit\\Str' => $baseDir . '/src/Toolkit/Str.php',
'Kirby\\Toolkit\\SymmetricCrypto' => $baseDir . '/src/Toolkit/SymmetricCrypto.php',
Expand Down
3 changes: 3 additions & 0 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class ComposerStaticInit0bf5c8a9cfa251a218fc581ac888fe35
'Kirby\\Cms\\Blueprint' => __DIR__ . '/../..' . '/src/Cms/Blueprint.php',
'Kirby\\Cms\\Collection' => __DIR__ . '/../..' . '/src/Cms/Collection.php',
'Kirby\\Cms\\Collections' => __DIR__ . '/../..' . '/src/Cms/Collections.php',
'Kirby\\Cms\\ContentLocks' => __DIR__ . '/../..' . '/src/Cms/ContentLocks.php',
'Kirby\\Cms\\Core' => __DIR__ . '/../..' . '/src/Cms/Core.php',
'Kirby\\Cms\\Email' => __DIR__ . '/../..' . '/src/Cms/Email.php',
'Kirby\\Cms\\Event' => __DIR__ . '/../..' . '/src/Cms/Event.php',
Expand Down Expand Up @@ -222,6 +223,7 @@ class ComposerStaticInit0bf5c8a9cfa251a218fc581ac888fe35
'Kirby\\Cms\\LicenseType' => __DIR__ . '/../..' . '/src/Cms/LicenseType.php',
'Kirby\\Cms\\Loader' => __DIR__ . '/../..' . '/src/Cms/Loader.php',
'Kirby\\Cms\\Media' => __DIR__ . '/../..' . '/src/Cms/Media.php',
'Kirby\\Cms\\Model' => __DIR__ . '/../..' . '/src/Cms/Model.php',
'Kirby\\Cms\\ModelPermissions' => __DIR__ . '/../..' . '/src/Cms/ModelPermissions.php',
'Kirby\\Cms\\ModelWithContent' => __DIR__ . '/../..' . '/src/Cms/ModelWithContent.php',
'Kirby\\Cms\\Nest' => __DIR__ . '/../..' . '/src/Cms/Nest.php',
Expand Down Expand Up @@ -478,6 +480,7 @@ class ComposerStaticInit0bf5c8a9cfa251a218fc581ac888fe35
'Kirby\\Toolkit\\Locale' => __DIR__ . '/../..' . '/src/Toolkit/Locale.php',
'Kirby\\Toolkit\\Obj' => __DIR__ . '/../..' . '/src/Toolkit/Obj.php',
'Kirby\\Toolkit\\Pagination' => __DIR__ . '/../..' . '/src/Toolkit/Pagination.php',
'Kirby\\Toolkit\\Properties' => __DIR__ . '/../..' . '/src/Toolkit/Properties.php',
'Kirby\\Toolkit\\Silo' => __DIR__ . '/../..' . '/src/Toolkit/Silo.php',
'Kirby\\Toolkit\\Str' => __DIR__ . '/../..' . '/src/Toolkit/Str.php',
'Kirby\\Toolkit\\SymmetricCrypto' => __DIR__ . '/../..' . '/src/Toolkit/SymmetricCrypto.php',
Expand Down

0 comments on commit 9f5424d

Please sign in to comment.