mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-26 11:19:55 +03:00
Merge d1eef85b47
into ee0d29a0e9
This commit is contained in:
commit
5ffc1b4331
3 changed files with 35 additions and 21 deletions
|
@ -1,3 +1,5 @@
|
|||
This is my horrible fork of piwigo, I add the changes I make to my piwigo instance here.
|
||||
Use at your own risk.
|
||||
<img src="https://piwigo.org/plugins/piwigo-piwigodotorg/images/piwigo.org.svg" width="200" alt="Piwigo logo">
|
||||
|
||||
Manage your photo library. Piwigo is open source photo gallery software for the web. Designed for organisations, teams and individuals.
|
||||
|
|
|
@ -1000,6 +1000,11 @@ $conf['checksum_compute_blocksize'] = 50;
|
|||
// _data/cache directory
|
||||
$conf['quick_search_include_sub_albums'] = false;
|
||||
|
||||
// Search split words: Split words in a search query.
|
||||
// For example, if search is "red tomatoes", then we only display photos
|
||||
// with "red tomatoes" and not "red", "tomatoes" in the fields
|
||||
$conf['search_split_words'] = true;
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | log |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
|
|
@ -2029,31 +2029,38 @@ function get_search_results($search_id, $super_order_by, $images_where='')
|
|||
|
||||
function split_allwords($raw_allwords)
|
||||
{
|
||||
$words = null;
|
||||
global $conf;
|
||||
$words = null;
|
||||
|
||||
// we specify the list of characters to trim, to add the ".". We don't want to split words
|
||||
// on "." but on ". ", and we have to deal with trailing dots.
|
||||
$raw_allwords = trim($raw_allwords, " \n\r\t\v\x00.");
|
||||
// Trim unwanted characters, including trailing dots
|
||||
$raw_allwords = trim($raw_allwords, " \n\r\t\v\x00.");
|
||||
|
||||
if (!preg_match('/^\s*$/', $raw_allwords))
|
||||
{
|
||||
$drop_char_match = array(';','&','(',')','<','>','`','\'','"','|',',','@','?','%','. ','[',']','{','}',':','\\','/','=','\'','!','*');
|
||||
$drop_char_replace = array(' ',' ',' ',' ',' ',' ', '', '', ' ',' ',' ',' ',' ',' ',' ' ,' ',' ',' ',' ',' ','' , ' ',' ',' ', ' ',' ');
|
||||
if (!preg_match('/^\s*$/', $raw_allwords)) {
|
||||
$drop_char_match = array(';', '&', '(', ')', '<', '>', '`', '|', ',', '@', '?', '%', '. ', '[', ']', '{', '}', ':', '\\', '/', '=', '!', '*');
|
||||
$drop_char_replace = array(' ', ' ', ' ', ' ', ' ', ' ', '', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '', ' ', ' ', ' ', ' ', ' ');
|
||||
|
||||
// Split words
|
||||
$words = array_unique(
|
||||
preg_split(
|
||||
'/\s+/',
|
||||
str_replace(
|
||||
$drop_char_match,
|
||||
$drop_char_replace,
|
||||
$raw_allwords
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
// Replace unwanted characters
|
||||
$processed_words = str_replace($drop_char_match, $drop_char_replace, $raw_allwords);
|
||||
|
||||
return $words;
|
||||
// Remove extra spaces introduced during replacement
|
||||
$processed_words = preg_replace('/\s+/', ' ', $processed_words);
|
||||
$processed_words = trim($processed_words);
|
||||
|
||||
// Use a regular expression to split words while respecting quoted text
|
||||
$pattern = '/"([^"]+)"|\'([^\']+)\'|(\S+)/';
|
||||
preg_match_all($pattern, $processed_words, $matches);
|
||||
|
||||
// Extract matches and flatten the array
|
||||
$result = array_merge(
|
||||
array_filter($matches[1]), // Double-quoted phrases
|
||||
array_filter($matches[2]), // Single-quoted phrases
|
||||
array_filter($matches[3]) // Unquoted words
|
||||
);
|
||||
|
||||
return array_unique($result);
|
||||
}
|
||||
|
||||
return $words;
|
||||
}
|
||||
|
||||
function get_available_search_uuid()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue