]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/criteria/class_BaseCriteria.php
Rewrote search criteria matching:
[core.git] / inc / classes / main / criteria / class_BaseCriteria.php
index 3b97b8b5f432d1b4fad74e23e9151d54671bf66b..b53ce6482845616efafdb17cc0fe32f9d7ff6580 100644 (file)
@@ -50,6 +50,43 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria {
                parent::__construct($className);
        }
 
                parent::__construct($className);
        }
 
+       /**
+        * Checks whether given key is set
+        *
+        * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
+        * @param       $criteriaKey    Criteria key
+        * @return      $isSet                  Whether key is set
+        */
+       public function isKeySet ($criteriaType, $criteriaKey) {
+               // Determine it
+               $isSet = isset($this->criteria[$criteriaType][$criteriaKey]);
+
+               // Return it
+               return $isSet;
+       }
+
+       /**
+        * Checks whether given key is set for 'choice' type
+        *
+        * @param       $criteriaKey    Criteria key
+        * @return      $isSet                  Whether key is set
+        */
+       public function isChoiceKeySet ($criteriaKey) {
+               // Call inner method
+               return $this->isKeySet('choice', $criteriaKey);
+       }
+
+       /**
+        * Checks whether given key is set for 'exclude' type
+        *
+        * @param       $criteriaKey    Criteria key
+        * @return      $isSet                  Whether key is set
+        */
+       public function isExcludeKeySet ($criteriaKey) {
+               // Call inner method
+               return $this->isKeySet('exclude', $criteriaKey);
+       }
+
        /**
         * Setter for wrapper class name
         *
        /**
         * Setter for wrapper class name
         *
@@ -115,7 +152,7 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria {
                $criteriaKey = $this->convertDashesToUnderscores($criteriaKey);
 
                // Is it already there?
                $criteriaKey = $this->convertDashesToUnderscores($criteriaKey);
 
                // Is it already there?
-               if (isset($this->criteria[$criteriaType][$criteriaKey])) {
+               if ($this->isKeySet($criteriaType, $criteriaKey)) {
                        // Append it
                        $this->criteria[$criteriaType][$criteriaKey] .= ',' . $criteriaValue;
                } else {
                        // Append it
                        $this->criteria[$criteriaType][$criteriaKey] .= ',' . $criteriaValue;
                } else {
@@ -186,7 +223,7 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria {
                $value = NULL;
 
                // Is the criteria there?
                $value = NULL;
 
                // Is the criteria there?
-               if (isset($this->criteria[$criteriaType][$criteriaKey])) {
+               if ($this->isKeySet($criteriaType, $criteriaKey)) {
                        // Then use it
                        $value = $this->criteria[$criteriaType][$criteriaKey];
                } // END - if
                        // Then use it
                        $value = $this->criteria[$criteriaType][$criteriaKey];
                } // END - if