[TikiWiki-commits] [Git][tikiwiki/tiki][master] [ENH][FIX] multi-exact match for numeric, text and math fields

"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]> Mon, 29 Jun 2026 08:07:43 +0000
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6a4227cf51c4f_38199858675e8@gitlab-sidekiq-low-urgency-cpu-bound-v2-656d6f88d7-sjp2m.mail>

Victor Emanouilov pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
56e5cebd by Victor Emanouilov at 2026-06-29T07:53:49+00:00
[ENH][FIX] multi-exact match for numeric, text and math fields
---
* [ENH][FIX] multi-exact match for numeric, text and math fields

See merge request tikiwiki/tiki!10614

- - - - -


4 changed files:

- lib/core/Search/Query.php
- lib/core/Tracker/Field/Math.php
- lib/core/Tracker/Field/Numeric.php
- lib/core/Tracker/Field/Text.php


Changes:

=====================================
lib/core/Search/Query.php
=====================================
@@ -111,6 +111,24 @@ class Search_Query implements Search_Query_Interface
         $this->addPart(new Search_Expr_Token($query), 'identifier', $field);
     }
 
+    /**
+     * Match one or more exact values on an identifier field.
+     * Multiple values are separated by " OR " in $query.
+     */
+    public function filterMultiIdentifier($query, $field)
+    {
+        $values = array_filter(array_map('trim', preg_split('/\s+OR\s+/', $query)), 'strlen');
+
+        if (count($values) <= 1) {
+            $this->filterIdentifier(reset($values) ?: $query, $field);
+        } else {
+            $tokens = array_map(function ($v) {
+                return new Search_Expr_Token($v);
+            }, $values);
+            $this->addPart(new Search_Expr_Or($tokens), 'identifier', $field);
+        }
+    }
+
     public function filterType($types)
     {
         if (is_array($types)) {


=====================================
lib/core/Tracker/Field/Math.php
=====================================
@@ -313,6 +313,17 @@ class Tracker_Field_Math extends \Tracker\Field\AbstractItemField implements \Tr
                     $query->filterIdentifier($value, $baseKey);
                 }
             });
+
+            $collection->addNew($permName, 'multiexact')
+            ->setLabel($name)
+            ->setHelp(tr('Search for one or more precise values separated by OR.'))
+            ->setControl(new Tracker\Filter\Control\TextField("tf_{$permName}_mem"))
+            ->setApplyCondition(function ($control, Search_Query $query) use ($baseKey) {
+                $value = $control->getValue();
+                if ($value) {
+                    $query->filterMultiIdentifier($value, $baseKey);
+                }
+            });
         }
 
         return $collection;


=====================================
lib/core/Tracker/Field/Numeric.php
=====================================
@@ -255,6 +255,17 @@ class Tracker_Field_Numeric extends \Tracker\Field\AbstractItemField implements
                 }
             });
 
+        $filters->addNew($permName, 'multiexact')
+            ->setLabel($name)
+            ->setHelp(tr('Search for one or more precise values separated by OR.'))
+            ->setControl(new Tracker\Filter\Control\TextField("tf_{$permName}_mem"))
+            ->setApplyCondition(function ($control, Search_Query $query) use ($baseKey) {
+                $value = $control->getValue();
+                if ($value) {
+                    $query->filterMultiIdentifier($value, $baseKey);
+                }
+            });
+
         $filters->addNew($permName, 'range')
             ->setLabel($name)
             ->setControl(new Tracker\Filter\Control\NumericRange("tf_{$permName}_range", $this->getOption('decimals')))


=====================================
lib/core/Tracker/Field/Text.php
=====================================
@@ -594,6 +594,18 @@ class Tracker_Field_Text extends \Tracker\Field\AbstractItemField implements \Tr
                         }
                     })
                     ;
+
+                $filters->addNew($permName, 'multiexact')
+                    ->setLabel($name)
+                    ->setHelp(tr('Search for one or more precise values separated by OR.'))
+                    ->setControl(new Tracker\Filter\Control\TextField("tf_{$permName}_mem"))
+                    ->setApplyCondition(function ($control, Search_Query $query) use ($baseKey) {
+                        $value = $control->getValue();
+                        if ($value) {
+                            $query->filterMultiIdentifier($value, $baseKey . '_exact');
+                        }
+                    })
+                    ;
             }
         } else {
             $language = Language::getCurrentLanguage();



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/56e5cebdc79e30fe5846c2e67ad0210a18d0fa1a

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/56e5cebdc79e30fe5846c2e67ad0210a18d0fa1a
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.