More code merged from ship-simu
[mailer.git] / inc / classes / main / criteria / class_SearchCriteria.php
index a2f0910052abb4ba996be3001279fa964560942b..f948909671be7412d9fa19ac8e744c3847167b3a 100644 (file)
@@ -23,7 +23,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-class SearchCriteria extends BaseFrameworkSystem implements LocalCriteria {
+class SearchCriteria extends BaseFrameworkSystem implements LocalSearchCriteria {
        /**
         * Criteria to handle
         */
@@ -40,7 +40,7 @@ class SearchCriteria extends BaseFrameworkSystem implements LocalCriteria {
        private $skip = 0;
 
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
@@ -52,7 +52,7 @@ class SearchCriteria extends BaseFrameworkSystem implements LocalCriteria {
                $this->setObjectDescription("Search criteria class");
 
                // Create unique ID number
-               $this->createUniqueID();
+               $this->generateUniqueId();
 
                // Clean up a little
                $this->removeNumberFormaters();
@@ -73,7 +73,7 @@ class SearchCriteria extends BaseFrameworkSystem implements LocalCriteria {
        }
 
        /**
-        * Add extra criteria
+        * Add criteria
         *
         * @param       $criteriaKey    Criteria key
         * @param       $criteriaValue  Criteria value
@@ -83,6 +83,19 @@ class SearchCriteria extends BaseFrameworkSystem implements LocalCriteria {
                $this->searchCriteria[$criteriaKey] = $criteriaValue;
        }
 
+       /**
+        * Add configured criteria
+        *
+        * @param       $criteriaKey    Criteria key
+        * @param       $configEntry    Configuration entry
+        * @return      void
+        */
+       public function addConfiguredCriteria ($criteriaKey, $configEntry) {
+               // Add the configuration entry as a criteria
+               $value = $this->getConfigInstance()->readConfig($configEntry);
+               $this->addCriteria($criteriaKey, $value);
+       }
+
        /**
         * Setter for limit
         *
@@ -93,6 +106,16 @@ class SearchCriteria extends BaseFrameworkSystem implements LocalCriteria {
                $this->limit = $limit;
        }
 
+       /**
+        * Getter for limit
+        *
+        * @param       
+        * @return      $limit  Search limit
+        */
+       public final function getLimit () {
+               return $this->limit;
+       }
+
        /**
         * Setter for skip
         *
@@ -103,6 +126,16 @@ class SearchCriteria extends BaseFrameworkSystem implements LocalCriteria {
                $this->skip = $skip;
        }
 
+       /**
+        * Getter for skip
+        *
+        * @param       
+        * @return      $skip   Search skip
+        */
+       public final function getSkip () {
+               return $this->skip;
+       }
+
        /**
         * "Getter" for a cache key
         *
@@ -130,6 +163,26 @@ class SearchCriteria extends BaseFrameworkSystem implements LocalCriteria {
                // Return the cache key
                return $cacheKey;
        }
+
+       /**
+        * Get criteria element or null if not found
+        *
+        * @param       $criteria       The criteria we want to have
+        * @return      $value          Wether the value of the critera or null
+        */
+       public function getCriteriaElemnent ($criteria) {
+               // Default is not found
+               $value = null;
+
+               // Is the criteria there?
+               if (isset($this->searchCriteria[$criteria])) {
+                       // Then use it
+                       $value = $this->searchCriteria[$criteria];
+               }
+
+               // Return the value
+               return $value;
+       }
 }
 
 // [EOF]