X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fcriteria%2Fclass_SearchCriteria.php;h=f948909671be7412d9fa19ac8e744c3847167b3a;hp=a2f0910052abb4ba996be3001279fa964560942b;hb=42bc0e1fc5ae4653fe04c9d41474c874a0050b69;hpb=1b7df549b9e8eb283d201606489c0e388c7917a2 diff --git a/inc/classes/main/criteria/class_SearchCriteria.php b/inc/classes/main/criteria/class_SearchCriteria.php index a2f0910052..f948909671 100644 --- a/inc/classes/main/criteria/class_SearchCriteria.php +++ b/inc/classes/main/criteria/class_SearchCriteria.php @@ -23,7 +23,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -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]