123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- global $config;
- $sphinxDefaults =
- array('enabled' => true,
- 'server' => 'localhost',
- 'port' => 3312);
- foreach($sphinxDefaults as $key => $val) {
- if (!isset($config['sphinx'][$key])) {
- $config['sphinx'][$key] = $val;
- }
- }
- class SphinxSearchPlugin extends Plugin
- {
- const PLUGIN_VERSION = '2.0.0';
-
- function onAutoload($cls)
- {
- switch ($cls) {
- case 'SphinxSearch':
- include_once INSTALLDIR . '/plugins/SphinxSearch/' .
- strtolower($cls) . '.php';
- return false;
- }
- return parent::onAutoload($cls);
- }
-
- function onGetSearchEngine(Memcached_DataObject $target, $table, &$search_engine)
- {
- if (common_config('sphinx', 'enabled')) {
- if (!class_exists('SphinxClient')) {
-
- throw new ServerException(_m('Sphinx PHP extension must be installed.'));
- }
- $engine = new SphinxSearch($target, $table);
- if ($engine->is_connected()) {
- $search_engine = $engine;
- return false;
- }
- }
-
- return true;
- }
-
- function onPluginVersion(array &$versions)
- {
- $url = 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/SphinxSearch';
- $versions[] = array('name' => 'SphinxSearch',
- 'version' => self::PLUGIN_VERSION,
- 'author' => 'Brion Vibber',
- 'homepage' => $url,
- 'rawdescription' =>
-
- _m('Plugin for Sphinx search backend.'));
- return true;
- }
- }
|