3 * StatusNet, the distributed open-source microblogging tool
7 * LICENCE: This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 * @author Brion Vibber <brion@status.net>
23 * @copyright 2009 Control Yourself, Inc.
24 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
25 * @link http://laconi.ca/
28 if (!defined('STATUSNET')) {
32 // Set defaults if not already set in the config array...
35 array('enabled' => true,
36 'server' => 'localhost',
38 foreach($sphinxDefaults as $key => $val) {
39 if (!isset($config['sphinx'][$key])) {
40 $config['sphinx'][$key] = $val;
45 * Plugin for Sphinx search backend.
49 * @author Brion Vibber <brion@status.net>
50 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
51 * @link http://laconi.ca/
52 * @link http://twitter.com/
54 class SphinxSearchPlugin extends Plugin
57 * Automatically load any classes used
59 * @param string $cls the class
60 * @return boolean hook return
62 function onAutoload($cls)
66 include_once INSTALLDIR . '/plugins/SphinxSearch/' .
67 strtolower($cls) . '.php';
75 * Create sphinx search engine object for the given table type.
77 * @param Memcached_DataObject $target
78 * @param string $table
79 * @param out &$search_engine SearchEngine object on output if successful
80 * @ return boolean hook return
82 function onGetSearchEngine(Memcached_DataObject $target, $table, &$search_engine)
84 if (common_config('sphinx', 'enabled')) {
85 if (!class_exists('SphinxClient')) {
86 // TRANS: Server exception.
87 throw new ServerException(_m('Sphinx PHP extension must be installed.'));
89 $engine = new SphinxSearch($target, $table);
90 if ($engine->is_connected()) {
91 $search_engine = $engine;
95 // Sphinx disabled or disconnected
100 * Provide plugin version information.
102 * This data is used when showing the version page.
104 * @param array &$versions array of version data arrays; see EVENTS.txt
106 * @return boolean hook value
108 function onPluginVersion(&$versions)
110 $url = 'http://status.net/wiki/Plugin:SphinxSearch';
112 $versions[] = array('name' => 'SphinxSearch',
113 'version' => STATUSNET_VERSION,
114 'author' => 'Brion Vibber',
117 // TRANS: Plugin description.
118 _m('Plugin for Sphinx search backend.'));