Commit | Line | Data |
---|---|---|
b52f751b AE |
1 | <?php |
2 | namespace wcf\system\search; | |
71952a87 | 3 | use wcf\system\database\util\PreparedStatementConditionBuilder; |
b52f751b AE |
4 | use wcf\system\SingletonFactory; |
5 | ||
6 | /** | |
7 | * Default implementation for search engines, this class should be extended by | |
8 | * all search engines to preserve compatibility in case of interface changes. | |
9 | * | |
10 | * @author Alexander Ebert | |
7b7b9764 | 11 | * @copyright 2001-2019 WoltLab GmbH |
b52f751b | 12 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> |
e71525e4 | 13 | * @package WoltLabSuite\Core\System\Search |
b52f751b | 14 | */ |
0cd425be AE |
15 | abstract class AbstractSearchEngine extends SingletonFactory implements ISearchEngine { |
16 | /** | |
17 | * class name for preferred condition builder | |
18 | * @var string | |
19 | */ | |
71952a87 | 20 | protected $conditionBuilderClassName = PreparedStatementConditionBuilder::class; |
0cd425be | 21 | |
11767746 AE |
22 | /** |
23 | * list of engine-specific special characters | |
71952a87 | 24 | * @var string[] |
11767746 | 25 | */ |
71952a87 | 26 | protected $specialCharacters = []; |
11767746 | 27 | |
0cd425be | 28 | /** |
71952a87 | 29 | * @inheritDoc |
0cd425be AE |
30 | */ |
31 | public function getConditionBuilderClassName() { | |
32 | return $this->conditionBuilderClassName; | |
33 | } | |
34 | ||
35 | /** | |
7d059540 | 36 | * @deprecated 5.4 - This method is dangerous. See https://github.com/WoltLab/WCF/issues/3815. |
0cd425be AE |
37 | */ |
38 | protected function parseSearchQuery($query) { | |
7d059540 | 39 | throw new \BadMethodCallException('Using the generic `parseSearchQuery()` method is dangerous. See WoltLab/WCF#3815 (https://github.com/WoltLab/WCF/issues/3815).'); |
0cd425be AE |
40 | } |
41 | ||
42 | /** | |
7d059540 | 43 | * @deprecated 5.4 - This method was required for use in parseSearchQuery(). |
0cd425be AE |
44 | */ |
45 | abstract protected function getFulltextMinimumWordLength(); | |
11767746 AE |
46 | |
47 | /** | |
71952a87 | 48 | * @inheritDoc |
11767746 AE |
49 | */ |
50 | public function removeSpecialCharacters($string) { | |
51 | if (!empty($this->specialCharacters)) { | |
52 | return str_replace($this->specialCharacters, '', $string); | |
53 | } | |
54 | ||
55 | return $string; | |
56 | } | |
0cd425be | 57 | } |