Upgrade to 3.4.1
This commit is contained in:
@@ -165,20 +165,21 @@ return [
|
||||
|
||||
$options = array_merge($defaults, $params);
|
||||
$collection = clone $collection;
|
||||
$searchwords = preg_replace('/(\s)/u', ',', $query);
|
||||
$searchwords = Str::split($searchwords, ',', $options['minlength']);
|
||||
$lowerQuery = mb_strtolower($query);
|
||||
$searchWords = preg_replace('/(\s)/u', ',', $query);
|
||||
$searchWords = Str::split($searchWords, ',', $options['minlength']);
|
||||
$lowerQuery = Str::lower($query);
|
||||
$exactQuery = $options['words'] ? '(\b' . preg_quote($query) . '\b)' : preg_quote($query);
|
||||
|
||||
if (empty($options['stopwords']) === false) {
|
||||
$searchwords = array_diff($searchwords, $options['stopwords']);
|
||||
$searchWords = array_diff($searchWords, $options['stopwords']);
|
||||
}
|
||||
|
||||
$searchwords = array_map(function ($value) use ($options) {
|
||||
$searchWords = array_map(function ($value) use ($options) {
|
||||
return $options['words'] ? '\b' . preg_quote($value) . '\b' : preg_quote($value);
|
||||
}, $searchwords);
|
||||
}, $searchWords);
|
||||
|
||||
$preg = '!(' . implode('|', $searchwords) . ')!i';
|
||||
$results = $collection->filter(function ($item) use ($query, $preg, $options, $lowerQuery) {
|
||||
$preg = '!(' . implode('|', $searchWords) . ')!i';
|
||||
$results = $collection->filter(function ($item) use ($query, $preg, $options, $lowerQuery, $exactQuery) {
|
||||
$data = $item->content()->toArray();
|
||||
$keys = array_keys($data);
|
||||
$keys[] = 'id';
|
||||
@@ -207,7 +208,7 @@ return [
|
||||
$score = $options['score'][$key] ?? 1;
|
||||
$value = $data[$key] ?? (string)$item->$key();
|
||||
|
||||
$lowerValue = mb_strtolower($value);
|
||||
$lowerValue = Str::lower($value);
|
||||
|
||||
// check for exact matches
|
||||
if ($lowerQuery == $lowerValue) {
|
||||
@@ -215,12 +216,12 @@ return [
|
||||
$item->searchHits += 1;
|
||||
|
||||
// check for exact beginning matches
|
||||
} elseif (Str::startsWith($lowerValue, $lowerQuery) === true) {
|
||||
} elseif ($options['words'] === false && Str::startsWith($lowerValue, $lowerQuery) === true) {
|
||||
$item->searchScore += 8 * $score;
|
||||
$item->searchHits += 1;
|
||||
|
||||
// check for exact query matches
|
||||
} elseif ($matches = preg_match_all('!' . preg_quote($query) . '!i', $value, $r)) {
|
||||
} elseif ($matches = preg_match_all('!' . $exactQuery . '!i', $value, $r)) {
|
||||
$item->searchScore += 2 * $score;
|
||||
$item->searchHits += $matches;
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ return [
|
||||
'date' => __DIR__ . '/fields/date.php',
|
||||
'email' => __DIR__ . '/fields/email.php',
|
||||
'files' => __DIR__ . '/fields/files.php',
|
||||
'gap' => __DIR__ . '/fields/gap.php',
|
||||
'headline' => __DIR__ . '/fields/headline.php',
|
||||
'hidden' => __DIR__ . '/fields/hidden.php',
|
||||
'info' => __DIR__ . '/fields/info.php',
|
||||
|
5
kirby/config/fields/gap.php
Executable file
5
kirby/config/fields/gap.php
Executable file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'save' => false
|
||||
];
|
@@ -110,9 +110,9 @@ return [
|
||||
if (empty($this->columns)) {
|
||||
foreach ($this->fields as $field) {
|
||||
|
||||
// Skip hidden fields.
|
||||
// Skip hidden and unsaveable fields
|
||||
// They should never be included as column
|
||||
if ($field['type'] === 'hidden') {
|
||||
if ($field['type'] === 'hidden' || $field['saveable'] === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ return [
|
||||
|
||||
$field = $this->fields[$columnName] ?? null;
|
||||
|
||||
if (empty($field) === true) {
|
||||
if (empty($field) === true || $field['saveable'] === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ return [
|
||||
$data = [];
|
||||
|
||||
foreach ($value as $row) {
|
||||
$data[] = $this->form($row)->data();
|
||||
$data[] = $this->form($row)->content();
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
Reference in New Issue
Block a user