Antes /
kittenground
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * Simple Machines Forum (SMF) |
||
| 5 | * |
||
| 6 | * @package SMF |
||
| 7 | * @author Simple Machines http://www.simplemachines.org |
||
| 8 | * @copyright 2019 Simple Machines and individual contributors |
||
| 9 | * @license http://www.simplemachines.org/about/smf/license.php BSD |
||
| 10 | * |
||
| 11 | * @version 2.1 RC2 |
||
| 12 | */ |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Interface search_api_interface |
||
| 16 | */ |
||
| 17 | interface search_api_interface |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * Check whether the specific search operation can be performed by this API. |
||
| 21 | * The operations are the functions listed in the interface, if not supported |
||
| 22 | * they need not be declared |
||
| 23 | * |
||
| 24 | * @access public |
||
| 25 | * @param string $methodName The method |
||
| 26 | * @param array $query_params Any parameters for the query |
||
| 27 | * @return boolean Whether or not the specified method is supported |
||
| 28 | */ |
||
| 29 | public function supportsMethod($methodName, $query_params = array()); |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Whether this method is valid for implementation or not |
||
| 33 | * |
||
| 34 | * @access public |
||
| 35 | * @return bool Whether or not this method is valid |
||
| 36 | */ |
||
| 37 | public function isValid(); |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Callback function for usort used to sort the fulltext results. |
||
| 41 | * the order of sorting is: large words, small words, large words that |
||
| 42 | * are excluded from the search, small words that are excluded. |
||
| 43 | * |
||
| 44 | * @access public |
||
| 45 | * @param string $a Word A |
||
| 46 | * @param string $b Word B |
||
| 47 | * @return int An integer indicating how the words should be sorted |
||
| 48 | */ |
||
| 49 | public function searchSort($a, $b); |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Callback while preparing indexes for searching |
||
| 53 | * |
||
| 54 | * @access public |
||
| 55 | * @param string $word A word to index |
||
| 56 | * @param array $wordsSearch Search words |
||
| 57 | * @param array $wordsExclude Words to exclude |
||
| 58 | * @param bool $isExcluded Whether the specfied word should be excluded |
||
| 59 | */ |
||
| 60 | public function prepareIndexes($word, array &$wordsSearch, array &$wordsExclude, $isExcluded); |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Search for indexed words. |
||
| 64 | * |
||
| 65 | * @access public |
||
| 66 | * @param array $words An array of words |
||
| 67 | * @param array $search_data An array of search data |
||
| 68 | * @return mixed |
||
| 69 | */ |
||
| 70 | public function indexedWordQuery(array $words, array $search_data); |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Callback when a post is created |
||
| 74 | * |
||
| 75 | * @see createPost() |
||
| 76 | * |
||
| 77 | * @access public |
||
| 78 | * @param array $msgOptions An array of post data |
||
| 79 | * @param array $topicOptions An array of topic data |
||
| 80 | * @param array $posterOptions An array of info about the person who made this post |
||
| 81 | * @return void |
||
| 82 | */ |
||
| 83 | public function postCreated(array &$msgOptions, array &$topicOptions, array &$posterOptions); |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Callback when a post is modified |
||
| 87 | * |
||
| 88 | * @see modifyPost() |
||
| 89 | * |
||
| 90 | * @access public |
||
| 91 | * @param array $msgOptions An array of post data |
||
| 92 | * @param array $topicOptions An array of topic data |
||
| 93 | * @param array $posterOptions An array of info about the person who made this post |
||
| 94 | * @return void |
||
| 95 | */ |
||
| 96 | public function postModified(array &$msgOptions, array &$topicOptions, array &$posterOptions); |
||
| 97 | |||
| 98 | /** |
||
| 99 | * Callback when a post is removed |
||
| 100 | * |
||
| 101 | * @access public |
||
| 102 | * @param int $id_msg The ID of the post that was removed |
||
| 103 | * @return void |
||
| 104 | */ |
||
| 105 | public function postRemoved($id_msg); |
||
| 106 | |||
| 107 | /** |
||
| 108 | * Callback when a topic is removed |
||
| 109 | * |
||
| 110 | * @access public |
||
| 111 | * @param array $topics The ID(s) of the removed topic(s) |
||
| 112 | * @return void |
||
| 113 | */ |
||
| 114 | public function topicsRemoved(array $topics); |
||
| 115 | |||
| 116 | /** |
||
| 117 | * Callback when a topic is moved |
||
| 118 | * |
||
| 119 | * @access public |
||
| 120 | * @param array $topics The ID(s) of the moved topic(s) |
||
| 121 | * @param int $board_to The board that the topics were moved to |
||
| 122 | * @return void |
||
| 123 | */ |
||
| 124 | public function topicsMoved(array $topics, $board_to); |
||
| 125 | |||
| 126 | /** |
||
| 127 | * Callback for actually performing the search query |
||
| 128 | * |
||
| 129 | * @access public |
||
| 130 | * @param array $query_params An array of parameters for the query |
||
| 131 | * @param array $searchWords The words that were searched for |
||
| 132 | * @param array $excludedIndexWords Indexed words that should be excluded |
||
| 133 | * @param array $participants |
||
| 134 | * @param array $searchArray |
||
| 135 | * @return mixed |
||
| 136 | */ |
||
| 137 | public function searchQuery(array $query_params, array $searchWords, array $excludedIndexWords, array &$participants, array &$searchArray); |
||
| 138 | } |
||
| 139 | |||
| 140 | /** |
||
| 141 | * Class search_api |
||
| 142 | */ |
||
| 143 | abstract class search_api implements search_api_interface |
||
| 144 | { |
||
| 145 | /** |
||
| 146 | * @var string The maximum SMF version that this will work with. |
||
| 147 | */ |
||
| 148 | public $version_compatible = '2.1.999'; |
||
| 149 | |||
| 150 | /** |
||
| 151 | * @var string The minimum SMF version that this will work with. |
||
| 152 | */ |
||
| 153 | public $min_smf_version = '2.1 RC1'; |
||
| 154 | |||
| 155 | /** |
||
| 156 | * @var bool Whether or not it's supported |
||
| 157 | */ |
||
| 158 | public $is_supported = true; |
||
| 159 | |||
| 160 | /** |
||
| 161 | * {@inheritDoc} |
||
| 162 | */ |
||
| 163 | public function supportsMethod($methodName, $query_params = null) |
||
| 164 | { |
||
| 165 | switch ($methodName) |
||
| 166 | { |
||
| 167 | case 'postRemoved': |
||
| 168 | return true; |
||
| 169 | break; |
||
|
0 ignored issues
–
show
|
|||
| 170 | |||
| 171 | // All other methods, too bad dunno you. |
||
| 172 | default: |
||
| 173 | return false; |
||
| 174 | break; |
||
| 175 | } |
||
| 176 | } |
||
| 177 | |||
| 178 | /** |
||
| 179 | * {@inheritDoc} |
||
| 180 | */ |
||
| 181 | public function isValid() |
||
| 182 | { |
||
| 183 | } |
||
| 184 | |||
| 185 | /** |
||
| 186 | * {@inheritDoc} |
||
| 187 | */ |
||
| 188 | public function searchSort($a, $b) |
||
| 189 | { |
||
| 190 | } |
||
| 191 | |||
| 192 | /** |
||
| 193 | * {@inheritDoc} |
||
| 194 | */ |
||
| 195 | public function prepareIndexes($word, array &$wordsSearch, array &$wordsExclude, $isExcluded) |
||
| 196 | { |
||
| 197 | } |
||
| 198 | |||
| 199 | /** |
||
| 200 | * {@inheritDoc} |
||
| 201 | */ |
||
| 202 | public function indexedWordQuery(array $words, array $search_data) |
||
| 203 | { |
||
| 204 | } |
||
| 205 | |||
| 206 | /** |
||
| 207 | * {@inheritDoc} |
||
| 208 | */ |
||
| 209 | public function postCreated(array &$msgOptions, array &$topicOptions, array &$posterOptions) |
||
| 210 | { |
||
| 211 | } |
||
| 212 | |||
| 213 | /** |
||
| 214 | * {@inheritDoc} |
||
| 215 | */ |
||
| 216 | public function postModified(array &$msgOptions, array &$topicOptions, array &$posterOptions) |
||
| 217 | { |
||
| 218 | } |
||
| 219 | |||
| 220 | /** |
||
| 221 | * {@inheritDoc} |
||
| 222 | */ |
||
| 223 | public function postRemoved($id_msg) |
||
| 224 | { |
||
| 225 | |||
| 226 | global $smcFunc; |
||
| 227 | |||
| 228 | $result = $smcFunc['db_query']('', ' |
||
| 229 | SELECT DISTINCT id_search |
||
| 230 | FROM {db_prefix}log_search_results |
||
| 231 | WHERE id_msg = {int:id_msg}', |
||
| 232 | array( |
||
| 233 | 'id_msg' => $id_msg, |
||
| 234 | ) |
||
| 235 | ); |
||
| 236 | |||
| 237 | $id_searchs = array(); |
||
| 238 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
||
| 239 | $id_searchs[] = $row['id_search']; |
||
| 240 | |||
| 241 | if (count($id_searchs) < 1) |
||
| 242 | return; |
||
| 243 | |||
| 244 | $smcFunc['db_query']('', ' |
||
| 245 | DELETE FROM {db_prefix}log_search_results |
||
| 246 | WHERE id_search in ({array_int:id_searchs})', |
||
| 247 | array( |
||
| 248 | 'id_searchs' => $id_searchs, |
||
| 249 | ) |
||
| 250 | ); |
||
| 251 | |||
| 252 | $smcFunc['db_query']('', ' |
||
| 253 | DELETE FROM {db_prefix}log_search_topics |
||
| 254 | WHERE id_search in ({array_int:id_searchs})', |
||
| 255 | array( |
||
| 256 | 'id_searchs' => $id_searchs, |
||
| 257 | ) |
||
| 258 | ); |
||
| 259 | |||
| 260 | $smcFunc['db_query']('', ' |
||
| 261 | DELETE FROM {db_prefix}log_search_messages |
||
| 262 | WHERE id_search in ({array_int:id_searchs})', |
||
| 263 | array( |
||
| 264 | 'id_searchs' => $id_searchs, |
||
| 265 | ) |
||
| 266 | ); |
||
| 267 | } |
||
| 268 | |||
| 269 | /** |
||
| 270 | * {@inheritDoc} |
||
| 271 | */ |
||
| 272 | public function topicsRemoved(array $topics) |
||
| 273 | { |
||
| 274 | } |
||
| 275 | |||
| 276 | /** |
||
| 277 | * {@inheritDoc} |
||
| 278 | */ |
||
| 279 | public function topicsMoved(array $topics, $board_to) |
||
| 280 | { |
||
| 281 | } |
||
| 282 | |||
| 283 | /** |
||
| 284 | * {@inheritDoc} |
||
| 285 | */ |
||
| 286 | public function searchQuery(array $query_params, array $searchWords, array $excludedIndexWords, array &$participants, array &$searchArray) |
||
| 287 | { |
||
| 288 | } |
||
| 289 | } |
||
| 290 | |||
| 291 | ?> |
The
breakstatement is not necessary if it is preceded for example by areturnstatement:If you would like to keep this construct to be consistent with other
casestatements, you can safely mark this issue as a false-positive.