]> BookStack Code Mirror - bookstack/blobdiff - app/Search/SearchOptions.php
ZIP Imports: Added API examples, finished testing
[bookstack] / app / Search / SearchOptions.php
index e362a8a015f476a4003dbe9c949156b436971dcd..bf527d9c3058c1a87f988212da0d086c63fe66e6 100644 (file)
@@ -73,7 +73,7 @@ class SearchOptions
         }
 
         if (isset($inputs['types']) && count($inputs['types']) < 4) {
-            $cleanedFilters[] = new FilterSearchOption(implode('|', $inputs['types']), 'types');
+            $cleanedFilters[] = new FilterSearchOption(implode('|', $inputs['types']), 'type');
         }
 
         $instance->filters = new SearchOptionSet($cleanedFilters);
@@ -181,7 +181,7 @@ class SearchOptions
     protected static function parseStandardTermString(string $termString): array
     {
         $terms = explode(' ', $termString);
-        $indexDelimiters = SearchIndex::$delimiters;
+        $indexDelimiters = implode('', array_diff(str_split(SearchIndex::$delimiters), str_split(SearchIndex::$softDelimiters)));
         $parsed = [
             'terms'  => [],
             'exacts' => [],
@@ -235,18 +235,21 @@ class SearchOptions
     {
         $options = [];
 
-        // Non-[created/updated]-by-me options
+        // Handle filters without UI support
         $userFilters = ['updated_by', 'created_by', 'owned_by'];
+        $unsupportedFilters = ['is_template', 'sort_by'];
         foreach ($this->filters->all() as $filter) {
             if (in_array($filter->getKey(), $userFilters, true) && $filter->value !== null && $filter->value !== 'me') {
                 $options[] = $filter;
+            } else if (in_array($filter->getKey(), $unsupportedFilters, true)) {
+                $options[] = $filter;
             }
         }
 
         // Negated items
-        array_push($options, ...$this->exacts->negated());
-        array_push($options, ...$this->tags->negated());
-        array_push($options, ...$this->filters->negated());
+        array_push($options, ...$this->exacts->negated()->all());
+        array_push($options, ...$this->tags->negated()->all());
+        array_push($options, ...$this->filters->negated()->all());
 
         return implode(' ', array_map(fn(SearchOption $o) => $o->toString(), $options));
     }