mirror of
https://github.com/processwire/processwire.git
synced 2025-08-11 17:24:46 +02:00
Bump version to 3.0.161
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
* https://processwire.com
|
* https://processwire.com
|
||||||
*
|
*
|
||||||
* @property-read $tableField
|
* @property-read $tableField
|
||||||
|
* @method array getWordAlternates($word)
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@@ -516,11 +517,11 @@ class DatabaseQuerySelectFulltext extends Wire {
|
|||||||
// **+= Contains match + expand
|
// **+= Contains match + expand
|
||||||
|
|
||||||
$tableField = $this->tableField();
|
$tableField = $this->tableField();
|
||||||
$not = strpos($this->operator, '!') === 0;
|
|
||||||
$scoreField = $this->getScoreFieldName();
|
$scoreField = $this->getScoreFieldName();
|
||||||
|
$expand = strpos($this->operator, '+') !== false;
|
||||||
|
|
||||||
// standard MATCH/AGAINST with optional query expansion
|
// standard MATCH/AGAINST with optional query expansion
|
||||||
$words = $this->words($value, array('indexable' => true));
|
$words = $this->words($value, array('indexable' => true, 'alternates' => $expand));
|
||||||
$againstValue = $this->escapeAGAINST(implode(' ', $words));
|
$againstValue = $this->escapeAGAINST(implode(' ', $words));
|
||||||
|
|
||||||
if(!count($words) || !strlen(trim($againstValue))) {
|
if(!count($words) || !strlen(trim($againstValue))) {
|
||||||
@@ -529,9 +530,9 @@ class DatabaseQuerySelectFulltext extends Wire {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$match = $not ? 'NOT MATCH' : 'MATCH';
|
$match = $this->not ? 'NOT MATCH' : 'MATCH';
|
||||||
$bindKey = $this->query->bindValueGetKey($againstValue);
|
$bindKey = $this->query->bindValueGetKey($againstValue);
|
||||||
$againstType = strpos($this->operator, '+') ? 'WITH QUERY EXPANSION' : '';
|
$againstType = $expand ? 'WITH QUERY EXPANSION' : '';
|
||||||
$where = "$match($tableField) AGAINST($bindKey $againstType)";
|
$where = "$match($tableField) AGAINST($bindKey $againstType)";
|
||||||
$this->query->select("$where AS $scoreField");
|
$this->query->select("$where AS $scoreField");
|
||||||
$this->query->where($where);
|
$this->query->where($where);
|
||||||
@@ -740,12 +741,22 @@ class DatabaseQuerySelectFulltext extends Wire {
|
|||||||
'minWordLength' => 1, // minimum allowed length or true for ft_min_word_len
|
'minWordLength' => 1, // minimum allowed length or true for ft_min_word_len
|
||||||
'stopwords' => true, // allow stopwords
|
'stopwords' => true, // allow stopwords
|
||||||
'indexable' => false, // include only indexable words?
|
'indexable' => false, // include only indexable words?
|
||||||
|
'alternates' => false, // include alternate versions of words?
|
||||||
);
|
);
|
||||||
|
|
||||||
$options = count($options) ? array_merge($defaults, $options) : $defaults;
|
$options = count($options) ? array_merge($defaults, $options) : $defaults;
|
||||||
if($options['minWordLength'] === true) $options['minWordLength'] = (int) $this->database->getVariable('ft_min_word_len');
|
if($options['minWordLength'] === true) $options['minWordLength'] = (int) $this->database->getVariable('ft_min_word_len');
|
||||||
$words = $this->wire()->sanitizer->wordsArray($value, $options);
|
$words = $this->wire()->sanitizer->wordsArray($value, $options);
|
||||||
|
|
||||||
|
if($options['alternates']) {
|
||||||
|
foreach($words as $word) {
|
||||||
|
$alts = $this->getWordAlternates($word);
|
||||||
|
foreach($alts as $alt) {
|
||||||
|
if(!in_array($alt, $words)) $words[] = $alt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($options['indexable']) {
|
if($options['indexable']) {
|
||||||
foreach($words as $key => $word) {
|
foreach($words as $key => $word) {
|
||||||
if(!$this->isIndexableWord($word)) unset($words[$key]);
|
if(!$this->isIndexableWord($word)) unset($words[$key]);
|
||||||
@@ -815,4 +826,23 @@ class DatabaseQuerySelectFulltext extends Wire {
|
|||||||
self::$scoreFields[$scoreField] = 1;
|
self::$scoreFields[$scoreField] = 1;
|
||||||
return $scoreField;
|
return $scoreField;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get other variations of given word to search (such as plural, singular, etc.)
|
||||||
|
*
|
||||||
|
* Method is currently used by the **+= operator but will be also added
|
||||||
|
* to ~~= and ~+= operators shortly.
|
||||||
|
*
|
||||||
|
* This method is for hooks to implement.
|
||||||
|
*
|
||||||
|
* #pw-hooker
|
||||||
|
*
|
||||||
|
* @param string $word
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function ___getWordAlternates($word) {
|
||||||
|
if($word) {}
|
||||||
|
return array();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -567,7 +567,7 @@ class Field extends WireData implements Saveable, Exportable {
|
|||||||
// populate import data
|
// populate import data
|
||||||
foreach($changes as $key => $change) {
|
foreach($changes as $key => $change) {
|
||||||
$this->errors('clear all');
|
$this->errors('clear all');
|
||||||
$this->set($key, $data[$key]);
|
if(isset($data[$key])) $this->set($key, $data[$key]);
|
||||||
if(!empty($data['errors'][$key])) {
|
if(!empty($data['errors'][$key])) {
|
||||||
$error = $data['errors'][$key];
|
$error = $data['errors'][$key];
|
||||||
// just in case they switched it to an array of multiple errors, convert back to string
|
// just in case they switched it to an array of multiple errors, convert back to string
|
||||||
|
@@ -77,7 +77,7 @@ class ProcessWire extends Wire {
|
|||||||
* Reversion revision number
|
* Reversion revision number
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const versionRevision = 160;
|
const versionRevision = 161;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Version suffix string (when applicable)
|
* Version suffix string (when applicable)
|
||||||
@@ -358,6 +358,7 @@ class ProcessWire extends Wire {
|
|||||||
$version = self::versionMajor . "." . self::versionMinor . "." . self::versionRevision;
|
$version = self::versionMajor . "." . self::versionMinor . "." . self::versionRevision;
|
||||||
$config->version = $version;
|
$config->version = $version;
|
||||||
$config->versionName = trim($version . " " . self::versionSuffix);
|
$config->versionName = trim($version . " " . self::versionSuffix);
|
||||||
|
$config->moduleServiceKey .= str_replace('.', '', $version);
|
||||||
|
|
||||||
// $config->debugIf: optional setting to determine if debug mode should be on or off
|
// $config->debugIf: optional setting to determine if debug mode should be on or off
|
||||||
if($config->debugIf && is_string($config->debugIf)) {
|
if($config->debugIf && is_string($config->debugIf)) {
|
||||||
|
Reference in New Issue
Block a user