3 * An interface for criterias
5 * @author Roland Haeder <webmaster@ship-simu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.ship-simu.org
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 interface Criteria extends FrameworkInterface {
26 * Setter for wrapper class name
28 * @param $wrapperConfigEntry Configuration entry which hold the wrapper class' name
31 function setWrapperConfigEntry ($wrapperConfigEntry);
34 * Getter for wrapper class name
36 * @return $wrapperConfigEntry Configuration entry which hold the wrapper class' name
38 function getWrapperConfigEntry ();
41 * Getter for criteria array
43 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
46 function getCriteriaArray ($criteriaType = 'default');
49 * Getter for criteria array 'choice' type
53 function getCriteriaChoiceArray ();
56 * Getter for criteria array 'exclude' type
60 function getCriteriaExcludeArray ();
63 * Add criteria, this method converts dashes to underscores because dashes
64 * are not valid for criteria keys.
66 * @param $criteriaKey Criteria key
67 * @param $criteriaValue Criteria value
68 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
71 function addCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default');
74 * Add "choice" criteria, this method converts dashes to underscores because
75 * dashes are not valid for criteria keys.
77 * @param $criteriaKey Criteria key
78 * @param $criteriaValue Criteria value
81 function addChoiceCriteria ($criteriaKey, $criteriaValue);
84 * Add "exclude" criteria, this method converts dashes to underscores because
85 * dashes are not valid for criteria keys.
87 * @param $criteriaKey Criteria key
88 * @param $criteriaValue Criteria value
91 function addExcludeCriteria ($criteriaKey, $criteriaValue);
94 * Add configured criteria
96 * @param $criteriaKey Criteria key
97 * @param $configEntry Configuration entry
98 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
101 function addConfiguredCriteria ($criteriaKey, $configEntry, $criteriaType = 'default');
104 * Get criteria element or null if not found
106 * @param $criteriaKey The requested criteria key
107 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
108 * @return $value Whether the value of the critera or null
110 function getCriteriaElemnent ($criteriaKey, $criteriaType = 'default');
113 * Get criteria element or null if not found for 'choice' type
115 * @param $criteriaKey The requested criteria key
116 * @return $value Whether the value of the critera or null
118 function getCriteriaChoiceElemnent ($criteriaKey);
121 * Get criteria element or null if not found for 'exclude' type
123 * @param $criteriaKey The requested criteria key
124 * @return $value Whether the value of the critera or null
126 function getCriteriaExcludeElemnent ($criteriaKey);
129 * Checks whether given array entry matches
131 * @param $entryArray Array with the entries to find
132 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
133 * @return $matches Whether the entry matches or not
135 function ifEntryMatches (array $entryArray, $criteriaType = 'default');
138 * Checks whether given array 'choice' entry matches
140 * @param $entryArray Array with the entries to find
141 * @return $matches Whether the entry matches or not
143 function ifChoiceMatches (array $entryArray);
146 * Checks whether given array 'exclude' entry matches
148 * @param $entryArray Array with the entries to find
149 * @return $matches Whether the entry matches or not
151 function ifExcludeMatches (array $entryArray);
154 * "Getter" for a cache key
156 * @param $onlyKeys Only use these keys for a cache key
157 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
158 * @return $cacheKey The key suitable for the cache system
160 function getCacheKey ($onlyKeys = array(), $criteriaType = 'default');
163 * "Getter" for a cache key ('choice' type)
165 * @param $onlyKeys Only use these keys for a cache key
166 * @return $cacheKey The key suitable for the cache system
168 function getCacheKeyChoice ($onlyKeys = array());
171 * "Getter" for a cache key ('exclude' type)
173 * @param $onlyKeys Only use these keys for a cache key
174 * @return $cacheKey The key suitable for the cache system
176 function getCacheKeyExclude ($onlyKeys = array());
179 * Count the criteria, e.g. useful to find out if a database query has no
180 * limitation (search criteria).
182 * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
183 * @return $count Count of all criteria entries
185 function count ($criteriaType = 'default');
188 * Count 'choice' criteria, e.g. useful to find out if a database query
189 * has no limitation (search criteria).
191 * @return $count Count of all criteria entries
193 function countChoice ();
196 * Count 'exclude' criteria, e.g. useful to find out if a database query
197 * has no limitation (search criteria).
199 * @return $count Count of all criteria entries
201 function countExclude ();