Skip to content

Commit

Permalink
Merge pull request #4279 from getkirby/release/3.6.5
Browse files Browse the repository at this point in the history
3.6.5
  • Loading branch information
bastianallgeier authored Apr 19, 2022
2 parents 3de403c + 292580c commit 40d2ee9
Show file tree
Hide file tree
Showing 37 changed files with 679 additions and 135 deletions.
8 changes: 7 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ tests/ export-ignore

# panel
panel/.env.example export-ignore
panel/.eslintrc.js export-ignore
panel/.prettierrc.json export-ignore
panel/cypress.json export-ignore
panel/package-lock.json export-ignore
panel/package.json export-ignore
panel/public export-ignore
panel/README.md export-ignore
panel/src export-ignore
panel/vue.config.js export-ignore
panel/vite.config.js export-ignore
panel/vitest.setup.js export-ignore

# other
.vscode/ export-ignore
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Please post all bug reports in our [issue tracker](https://github.com/getkirby/k
If you have ideas for a feature or enhancement for Kirby, please use our [feedback platform](https://feedback.getkirby.com).

**Translations, bug fixes, code contributions ...**
Read about how to contribute to the development in our [contributing guide](/.github/CONTRIBUTING.md).
Read about how to contribute to the development in our [contributing guide](/CONTRIBUTING.md).



Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "The Kirby 3 core",
"license": "proprietary",
"type": "kirby-cms",
"version": "3.6.4",
"version": "3.6.5",
"keywords": [
"kirby",
"cms",
Expand Down
2 changes: 1 addition & 1 deletion 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/methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@
* Converts the field value to a timestamp or a formatted date
*
* @param \Kirby\Cms\Field $field
* @param string|null $format PHP date formatting string
* @param string|\IntlDateFormatter|null $format PHP date formatting string
* @param string|null $fallback Fallback string for `strtotime` (since 3.2)
* @return string|int
*/
'toDate' => function (Field $field, string $format = null, string $fallback = null) use ($app) {
'toDate' => function (Field $field, $format = null, string $fallback = null) use ($app) {
if (empty($field->value) === true && $fallback === null) {
return null;
}
Expand Down
138 changes: 69 additions & 69 deletions i18n/translations/fr.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion i18n/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@

"error.template.default.notFound": "Het standaard template bestaat niet",

"error.unexpected": "An unexpected error occurred! Enable debug mode for more info: https://getkirby.com/docs/reference/system/options/debug",
"error.unexpected": "Een onverwacht fout heeft plaats gevonden! Schakel debug-modus in voor meer informatie: https://getkirby.com/docs/reference/system/options/debug",

"error.user.changeEmail.permission": "Je hebt geen rechten om het e-mailadres van gebruiker \"{name}\" te wijzigen",
"error.user.changeLanguage.permission": "Je hebt geen rechten om de taal voor gebruiker \"{name}\" te wijzigen",
Expand Down
2 changes: 1 addition & 1 deletion panel/dist/css/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion panel/src/components/Forms/Writer/Writer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export default {
}
.k-writer .ProseMirror ul,
.k-writer .ProseMirror ol {
padding-inline-start: 1rem;
padding-inline-start: 1.75rem;
}
.k-writer .ProseMirror ul > li {
list-style: disc;
Expand Down
16 changes: 14 additions & 2 deletions src/Cms/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Kirby\Filesystem\Dir;
use Kirby\Filesystem\F;
use Kirby\Http\Request;
use Kirby\Http\Response;
use Kirby\Http\Router;
use Kirby\Http\Server;
use Kirby\Http\Uri;
Expand Down Expand Up @@ -709,14 +710,25 @@ public function io($input)
return $this->io(new NotFoundException());
}

// Response Configuration
// (Modified) global response configuration, e.g. in routes
if (is_a($input, 'Kirby\Cms\Responder') === true) {
// return the passed object unmodified (without injecting headers
// from the global object) to allow a complete response override
// https://github.com/getkirby/kirby/pull/4144#issuecomment-1034766726
return $input->send();
}

// Responses
if (is_a($input, 'Kirby\Http\Response') === true) {
return $input;
$data = $input->toArray();

// inject headers from the global response configuration
// lazily (only if they are not already set);
// the case-insensitive nature of headers will be
// handled by PHP's `header()` function
$data['headers'] = array_merge($response->headers(), $data['headers']);

return new Response($data);
}

// Pages
Expand Down
6 changes: 3 additions & 3 deletions src/Cms/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,12 @@ public function mediaUrl(): string
/**
* Get the file's last modification time.
*
* @param string|null $format
* @param string|null $handler date or strftime
* @param string|\IntlDateFormatter|null $format
* @param string|null $handler date, intl or strftime
* @param string|null $languageCode
* @return mixed
*/
public function modified(string $format = null, string $handler = null, string $languageCode = null)
public function modified($format = null, string $handler = null, string $languageCode = null)
{
$file = $this->modifiedFile();
$content = $this->modifiedContent($languageCode);
Expand Down
29 changes: 22 additions & 7 deletions src/Cms/FileRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,30 @@ public static function changeSort(File $file, int $sort): bool
*/
public static function create(File $file, BaseFile $upload): bool
{
// We want to ensure that we are not creating duplicate files.
// If a file with the same name already exists
if ($file->exists() === true) {
if ($file->sha1() !== $upload->sha1()) {
throw new DuplicateException([
'key' => 'file.duplicate',
'data' => [
'filename' => $file->filename()
]
]);
// $file will be based on the props of the new file,
// to compare templates, we need to get the props of
// the already existing file from meta content file
$existing = $file->parent()->file($file->filename());

// if the new upload is the exact same file
// and uses the same template, we can continue
if (
$file->sha1() === $upload->sha1() &&
$file->template() === $existing->template()
) {
return true;
}

// otherwise throw an error for duplicate file
throw new DuplicateException([
'key' => 'file.duplicate',
'data' => [
'filename' => $file->filename()
]
]);
}

if ($file->permissions()->create() !== true) {
Expand Down
11 changes: 10 additions & 1 deletion src/Database/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,11 @@ public function page(int $page, int $limit)

// apply it to the dataset and retrieve all rows. make sure to use Collection as the iterator to be able to attach the pagination object
$iterator = $this->iterator;
$collection = $this->offset($pagination->offset())->limit($pagination->limit())->iterator('Collection')->all();
$collection = $this
->offset($pagination->offset())
->limit($pagination->limit())
->iterator('Kirby\Toolkit\Collection')
->all();

$this->iterator($iterator);

Expand Down Expand Up @@ -968,6 +972,11 @@ protected function filterQuery(array $args, $current)
$this->bindings($sql['bindings']);
} elseif (is_callable($args[0]) === true) {
$query = clone $this;

// since the callback uses its own where condition
// it is necessary to clear/reset the cloned where condition
$query->where = null;

call_user_func($args[0], $query);

// copy over the bindings from the nested query
Expand Down
14 changes: 12 additions & 2 deletions src/Database/Sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,14 @@ public function valueList(string $table, $values, string $separator = ',', bool
$query = [];
$bindings = [];

foreach ($values as $key => $value) {
$fields[] = $this->columnName($table, $key, $enforceQualified);
foreach ($values as $column => $value) {
$key = $this->columnName($table, $column, $enforceQualified);

if ($key === null) {
continue;
}

$fields[] = $key;

if (in_array($value, static::$literals, true) === true) {
$query[] = $value ?: 'null';
Expand Down Expand Up @@ -896,6 +902,10 @@ public function valueSet(string $table, $values, string $separator = ',', bool $
foreach ($values as $column => $value) {
$key = $this->columnName($table, $column, $enforceQualified);

if ($key === null) {
continue;
}

if (in_array($value, static::$literals, true) === true) {
$query[] = $key . ' = ' . ($value ?: 'null');
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Sql/Sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function quoteIdentifier(string $identifier): string
public function tables(): array
{
return [
'query' => 'SELECT name FROM sqlite_master WHERE type = "table"',
'query' => 'SELECT name FROM sqlite_master WHERE type = "table" OR type = "view"',
'bindings' => []
];
}
Expand Down
6 changes: 3 additions & 3 deletions src/Filesystem/F.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,11 @@ public static function mimeToType(string $mime)
* Get the file's last modification time.
*
* @param string $file
* @param string $format
* @param string $handler date or strftime
* @param string|\IntlDateFormatter|null $format
* @param string $handler date, intl or strftime
* @return mixed
*/
public static function modified(string $file, string $format = null, string $handler = 'date')
public static function modified(string $file, $format = null, string $handler = 'date')
{
if (file_exists($file) !== true) {
return false;
Expand Down
6 changes: 3 additions & 3 deletions src/Filesystem/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,11 @@ public function mime()
/**
* Returns the file's last modification time
*
* @param string $format
* @param string|null $handler date or strftime
* @param string|\IntlDateFormatter|null $format
* @param string|null $handler date, intl or strftime
* @return mixed
*/
public function modified(?string $format = null, ?string $handler = null)
public function modified($format = null, ?string $handler = null)
{
$kirby = $this->kirby();

Expand Down
9 changes: 7 additions & 2 deletions src/Panel/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
*/
class File extends Model
{
/**
* @var \Kirby\Cms\File
*/
protected $model;

/**
* Breadcrumb array
*
Expand Down Expand Up @@ -423,11 +428,11 @@ public function prevNext(): array
return [
'next' => function () use ($file, $siblings): ?array {
$next = $siblings->nth($siblings->indexOf($file) + 1);
return $next ? $next->panel()->toLink('filename') : null;
return $this->toPrevNextLink($next, 'filename');
},
'prev' => function () use ($file, $siblings): ?array {
$prev = $siblings->nth($siblings->indexOf($file) - 1);
return $prev ? $prev->panel()->toLink('filename') : null;
return $this->toPrevNextLink($prev, 'filename');
}
];
}
Expand Down
31 changes: 31 additions & 0 deletions src/Panel/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Kirby\Panel;

use Kirby\Form\Form;
use Kirby\Http\Uri;
use Kirby\Toolkit\A;

/**
Expand Down Expand Up @@ -387,6 +388,36 @@ public function toLink(string $tooltip = 'title'): array
];
}

/**
* Returns link url and tooltip
* for optional sibling model and
* preserves tab selection
*
* @internal
*
* @param \Kirby\Cms\ModelWithContent|null $model
* @param string $tooltip
* @return array
*/
protected function toPrevNextLink($model = null, string $tooltip = 'title'): ?array
{
if ($model === null) {
return null;
}

$data = $model->panel()->toLink($tooltip);

if ($tab = get('tab')) {
$uri = new Uri($data['link'], [
'query' => ['tab' => $tab]
]);

$data['link'] = $uri->toString();
}

return $data;
}

/**
* Returns the url to the editing view
* in the Panel
Expand Down
15 changes: 7 additions & 8 deletions src/Panel/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
*/
class Page extends Model
{
/**
* @var \Kirby\Cms\Page
*/
protected $model;

/**
* Breadcrumb array
*
Expand Down Expand Up @@ -309,14 +314,8 @@ public function prevNext(): array
};

return [
'next' => function () use ($siblings) {
$next = $siblings('next')->first();
return $next ? $next->panel()->toLink('title') : null;
},
'prev' => function () use ($siblings) {
$prev = $siblings('prev')->last();
return $prev ? $prev->panel()->toLink('title') : null;
}
'next' => fn () => $this->toPrevNextLink($siblings('next')->first()),
'prev' => fn () => $this->toPrevNextLink($siblings('prev')->last())
];
}

Expand Down
5 changes: 5 additions & 0 deletions src/Panel/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
*/
class Site extends Model
{
/**
* @var \Kirby\Cms\Site
*/
protected $model;

/**
* Returns the setup for a dropdown option
* which is used in the changes dropdown
Expand Down
Loading

0 comments on commit 40d2ee9

Please sign in to comment.