| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
function _check_searchd($host = 'localhost', $port = '3312') {
|
| 5 |
$cl = new SphinxClient();
|
| 6 |
//$cl->SetServer($host, $port);
|
| 7 |
$connect = $cl->_Connect();
|
| 8 |
if (!$connect) {
|
| 9 |
drupal_set_message(t('Searchd not running'), 'warning');
|
| 10 |
}
|
| 11 |
}
|
| 12 |
|
| 13 |
/**
|
| 14 |
* The admin page callback
|
| 15 |
*/
|
| 16 |
function _sphinx_admin() {
|
| 17 |
_check_searchd();
|
| 18 |
return drupal_get_form('sphinx_admin_form');
|
| 19 |
}
|
| 20 |
|
| 21 |
function _sphinx_admin_indexes($op = '', $iid = '') {
|
| 22 |
_check_searchd();
|
| 23 |
if (!empty($op) && !empty($iid)) {
|
| 24 |
switch ($op) {
|
| 25 |
case 'delete':
|
| 26 |
return drupal_get_form('sphinx_index_confirm_delete', $iid);
|
| 27 |
break;
|
| 28 |
|
| 29 |
case 'edit':
|
| 30 |
return drupal_get_form('sphinx_index_edit', $iid);
|
| 31 |
break;
|
| 32 |
|
| 33 |
case 'enable':
|
| 34 |
db_query('UPDATE {sphinx_indexes} SET active = 1 WHERE iid =%d', $iid);
|
| 35 |
drupal_goto('admin/settings/sphinx/indexes');
|
| 36 |
break;
|
| 37 |
|
| 38 |
case 'disable':
|
| 39 |
db_query('UPDATE {sphinx_indexes} SET active = 0 WHERE iid =%d', $iid);
|
| 40 |
drupal_goto('admin/settings/sphinx/indexes');
|
| 41 |
break;
|
| 42 |
|
| 43 |
case 'fields':
|
| 44 |
return _sphinx_manage_fields($iid);
|
| 45 |
break;
|
| 46 |
|
| 47 |
case 'attributes':
|
| 48 |
return _sphinx_manage_attributes($iid);
|
| 49 |
break;
|
| 50 |
}
|
| 51 |
}
|
| 52 |
|
| 53 |
$header = array(
|
| 54 |
array('data' => t('Index'), 'field' => 'index_name'),
|
| 55 |
array('data' => t('Display name'), 'field' => 'display_name'),
|
| 56 |
array('data' => t('Path'), 'field' => 'path'),
|
| 57 |
array('data' => t('Sort'), 'field' => 'sort_field'),
|
| 58 |
array('data' => t('Order'), 'field' => 'default_sort_order'),
|
| 59 |
array('data' => t('Server'), 'field' => 'server'),
|
| 60 |
array('data' => t('Port'), 'field' => 'port'),
|
| 61 |
array('data' => t('Excerpt'), 'field' => 'excerpt'),
|
| 62 |
array('data' => t('Multi-query'), 'field' => 'multiquery'),
|
| 63 |
array('data' => t('Active'), 'field' => 'active'),
|
| 64 |
array('data' => t('')),
|
| 65 |
array('data' => t('')),
|
| 66 |
array('data' => t('')),
|
| 67 |
array('data' => t('')),
|
| 68 |
array('data' => t('')),
|
| 69 |
);
|
| 70 |
|
| 71 |
$sql = 'SELECT {sphinx_indexes}.*, {sphinx_attributes}.display_name AS sort_field FROM {sphinx_indexes} LEFT JOIN {sphinx_attributes} ON default_sort_key_fid = aid '. tablesort_sql($header);
|
| 72 |
$result = pager_query($sql, 10);
|
| 73 |
$client = new SphinxClient();
|
| 74 |
$connect = $client->_Connect();
|
| 75 |
|
| 76 |
while ($indexes = db_fetch_object($result)) {
|
| 77 |
if ($indexes->active) {
|
| 78 |
$client->SetServer($indexes->server, (int)$indexes->port);
|
| 79 |
$client->SetLimits(0, 1);
|
| 80 |
$res = $client->Query('', $indexes->index_name);
|
| 81 |
if ($res) {
|
| 82 |
$status = 'Serving ('. $res['total_found'] .')';
|
| 83 |
}
|
| 84 |
else {
|
| 85 |
$status = '<span class="error">Error</span>';
|
| 86 |
}
|
| 87 |
}
|
| 88 |
else {
|
| 89 |
$status = 'Disabled';
|
| 90 |
$res = false;
|
| 91 |
}
|
| 92 |
$active = ($indexes->active == 0) ? l(t('Enable'), 'admin/settings/sphinx/indexes/enable/'. $indexes->iid) : l(t('Disable'), 'admin/settings/sphinx/indexes/disable/'. $indexes->iid);
|
| 93 |
$rows[] = array(
|
| 94 |
$indexes->index_name,
|
| 95 |
$indexes->display_name,
|
| 96 |
$indexes->path,
|
| 97 |
$indexes->sort_field,
|
| 98 |
$indexes->default_sort_order,
|
| 99 |
$indexes->server,
|
| 100 |
$indexes->port,
|
| 101 |
$indexes->excerpt ? t('Enabled') : t('Disabled'),
|
| 102 |
$indexes->multiquery ? t('Enabled') : t('Disabled'),
|
| 103 |
$status,
|
| 104 |
($res) ? l(t('Fields'), 'admin/settings/sphinx/indexes/fields/'. $indexes->iid) : '',
|
| 105 |
($res) ? l(t('Attributes'), 'admin/settings/sphinx/indexes/attributes/'. $indexes->iid) : '',
|
| 106 |
l(t('Delete'), 'admin/settings/sphinx/indexes/delete/'. $indexes->iid),
|
| 107 |
$active,
|
| 108 |
l(t('Edit'), 'admin/settings/sphinx/indexes/edit/'. $indexes->iid),
|
| 109 |
);
|
| 110 |
}
|
| 111 |
|
| 112 |
$output .= theme('table', $header, $rows);
|
| 113 |
$output .= drupal_get_form('sphinx_admin_add_index_form');
|
| 114 |
$output .= theme('pager', null, 10, 10);
|
| 115 |
|
| 116 |
return $output;
|
| 117 |
}
|
| 118 |
|
| 119 |
/**
|
| 120 |
* FAPI definition for the sphinx administration form.
|
| 121 |
*
|
| 122 |
* ...
|
| 123 |
* @ingroup forms
|
| 124 |
* @see sphinx_admin_form_submit()
|
| 125 |
*/
|
| 126 |
function sphinx_admin_form() {
|
| 127 |
|
| 128 |
$options = array();
|
| 129 |
for ($n = 1; $n < 10; $n++) {
|
| 130 |
$options[$n] = $n;
|
| 131 |
$options[$n * 10] = $n * 10;
|
| 132 |
$options[$n * 100] = $n * 100;
|
| 133 |
}
|
| 134 |
asort($options, SORT_NUMERIC);
|
| 135 |
$sql = 'SELECT iid, index_name, display_name FROM {sphinx_indexes}';
|
| 136 |
$result = db_query($sql);
|
| 137 |
$index_options = array();
|
| 138 |
while ($indexes = db_fetch_object($result)) {
|
| 139 |
$index_options[$indexes->iid] = $indexes->display_name .' ('. $indexes->index_name .')';
|
| 140 |
}
|
| 141 |
|
| 142 |
$form['sphinx']['sphinx_offline_message'] = array(
|
| 143 |
'#type' => 'textarea',
|
| 144 |
'#title' => t('Offline message'),
|
| 145 |
'#default_value' => variable_get('sphinx_offline_message', 'The search engine is unfortunately not working at the moment. Please return later'),
|
| 146 |
'#description' => t('Type the message you users will see, if the search daemon is not running'),
|
| 147 |
'#required' => true,
|
| 148 |
);
|
| 149 |
|
| 150 |
$form['sphinx']['sphinx_default_server'] = array(
|
| 151 |
'#type' => 'textfield',
|
| 152 |
'#title' => t('Default server'),
|
| 153 |
'#default_value' => variable_get('sphinx_default_server', 'localhost'),
|
| 154 |
'#description' => t('Type the ip-addresse of the server where you main searchd is running (this setting can be altered per index)'),
|
| 155 |
);
|
| 156 |
$form['sphinx']['sphinx_default_port'] = array(
|
| 157 |
'#type' => 'textfield',
|
| 158 |
'#title' => t('Default port'),
|
| 159 |
'#default_value' => variable_get('sphinx_default_port ', '3312'),
|
| 160 |
'#description' => t('Type the port on which your default searchd is listening (this setting can be altered per index)'),
|
| 161 |
);
|
| 162 |
$form['sphinx']['sphinx_default_index'] = array(
|
| 163 |
'#type' => 'select',
|
| 164 |
'#title' => t('Default index'),
|
| 165 |
'#default_value' => variable_get('sphinx_default_index', null),
|
| 166 |
'#options' => $index_options,
|
| 167 |
'#description' => t('Select the default index'),
|
| 168 |
);
|
| 169 |
$form['sphinx']['sphinx_results_per_page'] = array(
|
| 170 |
'#type' => 'select',
|
| 171 |
'#title' => t('Results pr. page'),
|
| 172 |
'#default_value' => variable_get('sphinx_results_per_page', 10),
|
| 173 |
'#options' => $options,
|
| 174 |
'#description' => t('Select the default number of search results displayed to the user'),
|
| 175 |
);
|
| 176 |
return system_settings_form($form);
|
| 177 |
}
|
| 178 |
|
| 179 |
function sphinx_admin_form_validate($form_id, $form_values) {
|
| 180 |
//TODO insert check for portnum and server ip
|
| 181 |
}
|
| 182 |
|
| 183 |
function sphinx_admin_form_submit($form_id, $form_values) {
|
| 184 |
|
| 185 |
variable_set('sphinx_offline_message', $form_values['sphinx_offline_message']);
|
| 186 |
variable_set('sphinx_default_server', $form_values['sphinx_default_server']);
|
| 187 |
variable_set('sphinx_default_port', $form_values['sphinx_default_port']);
|
| 188 |
variable_set('sphinx_default_index', $form_values['sphinx_default_index']);
|
| 189 |
variable_set('sphinx_results_per_page', $form_values['sphinx_results_per_page']);
|
| 190 |
drupal_set_message(t('Your Sphinx settings are saved'));
|
| 191 |
}
|
| 192 |
|
| 193 |
function sphinx_admin_add_index_form() {
|
| 194 |
|
| 195 |
|
| 196 |
$form['sphinx']['addnew'] = array(
|
| 197 |
'#type' => 'fieldset',
|
| 198 |
'#title' => t('Add new index'),
|
| 199 |
'#weight' => 5,
|
| 200 |
'#collapsible' => true,
|
| 201 |
'#collapsed' => true,
|
| 202 |
);
|
| 203 |
|
| 204 |
$form['sphinx']['addnew']['index_name'] = array(
|
| 205 |
'#type' => 'textfield',
|
| 206 |
'#title' => t('Index name'),
|
| 207 |
'#description' => t('Type the name of the index you want you users to search'),
|
| 208 |
'#required' => true,
|
| 209 |
);
|
| 210 |
$form['sphinx']['addnew']['display_name'] = array(
|
| 211 |
'#type' => 'textfield',
|
| 212 |
'#title' => t('Display name'),
|
| 213 |
'#description' => t('Type the name you want the users to see'),
|
| 214 |
'#required' => true,
|
| 215 |
);
|
| 216 |
$form['sphinx']['addnew']['path'] = array(
|
| 217 |
'#type' => 'textfield',
|
| 218 |
'#title' => t('Path'),
|
| 219 |
'#description' => t('Type the path of this index. If you type <i>products</i>, the path will be <i>/search/products</i>'),
|
| 220 |
'#required' => true,
|
| 221 |
);
|
| 222 |
$form['sphinx']['addnew']['server'] = array(
|
| 223 |
'#type' => 'textfield',
|
| 224 |
'#title' => t('Server'),
|
| 225 |
'#description' => t('Type the name the name of the server on which the searchd of this index is running'),
|
| 226 |
'#required' => true,
|
| 227 |
'#default_value' => variable_get('sphinx_default_server', 'localhost'),
|
| 228 |
);
|
| 229 |
$form['sphinx']['addnew']['port'] = array(
|
| 230 |
'#type' => 'textfield',
|
| 231 |
'#title' => t('Port'),
|
| 232 |
'#description' => t('Type the name the number of the port the searchd for this index is listening'),
|
| 233 |
'#required' => true,
|
| 234 |
'#default_value' => variable_get('sphinx_default_port', '3312'),
|
| 235 |
);
|
| 236 |
$form['sphinx']['addnew']['exerpt'] = array(
|
| 237 |
'#type' => 'checkbox',
|
| 238 |
'#title' => t('Excerpt'),
|
| 239 |
'#description' => t('Do you want to display excerpts for results from this index'),
|
| 240 |
);
|
| 241 |
$form['sphinx']['addnew']['multiquery'] = array(
|
| 242 |
'#type' => 'checkbox',
|
| 243 |
'#title' => t('Multiquery'),
|
| 244 |
'#description' => t('Does this index provide multiquerys for facets or the like'),
|
| 245 |
);
|
| 246 |
$form['sphinx']['addnew']['active'] = array(
|
| 247 |
'#type' => 'checkbox',
|
| 248 |
'#title' => t('Enable'),
|
| 249 |
'#description' => t('Should this index be activated?'),
|
| 250 |
);
|
| 251 |
$form['sphinx']['addnew']['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
|
| 252 |
return $form;
|
| 253 |
}
|
| 254 |
|
| 255 |
function sphinx_admin_add_index_form_submit($form_id, $form_values) {
|
| 256 |
db_query("INSERT INTO {sphinx_indexes} (index_name, display_name, path, server, port, excerpt, multiquery, active) VALUES ('%s','%s','%s',%d,%d,%d,%d,%d)", $form_values['index_name'], $form_values['display_name'], $form_values['path'], $form_values['server'], $form_values['port'], $form_values['excerpt'], $form_values['multiquery'], $form_values['active']);
|
| 257 |
}
|
| 258 |
|
| 259 |
function sphinx_index_confirm_delete($iid = '') {
|
| 260 |
|
| 261 |
|
| 262 |
if (!empty($iid)) {
|
| 263 |
$result = db_query('SELECT index_name, display_name FROM {sphinx_indexes} WHERE iid = %d;', $iid);
|
| 264 |
$names = db_fetch_object($result);
|
| 265 |
$form = array();
|
| 266 |
$form['text'] = array(
|
| 267 |
'#value' => t('Are you sure you want to delete the index <strong>%title</strong> (<i>%display</i>)? ', array('%title' => $names->index_name, '%display' => $names->display_name)),
|
| 268 |
);
|
| 269 |
$form['index'] = array('#type' => 'hidden', '#value' => $iid);
|
| 270 |
$form['submit'] = array('#type' => 'submit', '#value' => t('Delete'));
|
| 271 |
$form['cancel'] = array('#type' => 'submit', '#value' => t('Cancel'));
|
| 272 |
|
| 273 |
return $form;
|
| 274 |
}
|
| 275 |
}
|
| 276 |
|
| 277 |
function sphinx_index_confirm_delete_submit($form_id, $form_values) {
|
| 278 |
if ($form_values['op'] == 'Delete') {
|
| 279 |
db_query('DELETE FROM {sphinx_indexes} WHERE iid = %d;', $form_values['index']);
|
| 280 |
db_query('DELETE FROM {sphinx_fields} WHERE iid = %d;', $form_values['index']);
|
| 281 |
db_query('DELETE FROM {sphinx_attributes} WHERE iid = %d;', $form_values['index']);
|
| 282 |
}
|
| 283 |
drupal_goto('admin/settings/sphinx/indexes');
|
| 284 |
}
|
| 285 |
|
| 286 |
function sphinx_index_edit($iid = '') {
|
| 287 |
|
| 288 |
|
| 289 |
if (!empty($iid)) {
|
| 290 |
$result = db_query('SELECT * FROM {sphinx_indexes} WHERE iid = %d;', $iid);
|
| 291 |
$index = db_fetch_object($result);
|
| 292 |
|
| 293 |
$sql = 'SELECT aid, attribute_name, display_name FROM {sphinx_attributes} WHERE iid=%d AND active=1';
|
| 294 |
$result = db_query($sql, $iid);
|
| 295 |
$options = array();
|
| 296 |
while ($attributes = db_fetch_object($result)) {
|
| 297 |
$options[$attributes->aid] = $attributes->display_name;
|
| 298 |
}
|
| 299 |
|
| 300 |
$form['sphinx']['index_name'] = array(
|
| 301 |
'#type' => 'textfield',
|
| 302 |
'#title' => t('Index name'),
|
| 303 |
'#description' => t('Type the name of the index you want you users to search'),
|
| 304 |
'#required' => true,
|
| 305 |
'#default_value' => $index->index_name,
|
| 306 |
);
|
| 307 |
$form['sphinx']['display_name'] = array(
|
| 308 |
'#type' => 'textfield',
|
| 309 |
'#title' => t('Display name'),
|
| 310 |
'#description' => t('Type the name you want the users to see'),
|
| 311 |
'#required' => true,
|
| 312 |
'#default_value' => $index->display_name,
|
| 313 |
);
|
| 314 |
$form['sphinx']['path'] = array(
|
| 315 |
'#type' => 'textfield',
|
| 316 |
'#title' => t('Path'),
|
| 317 |
'#description' => t('Type the path of this index. If you type <i>products</i>, the path will be <i>/search/products</i>'),
|
| 318 |
'#required' => true,
|
| 319 |
'#default_value' => $index->path,
|
| 320 |
);
|
| 321 |
$form['sphinx']['default_sort_key_fid'] = array(
|
| 322 |
'#type' => 'select',
|
| 323 |
'#title' => t('Default sort'),
|
| 324 |
'#options' => $options,
|
| 325 |
'#default_value' => $index->default_sort_key_fid,
|
| 326 |
'#description' => t('Select how result should be ordered by default'),
|
| 327 |
);
|
| 328 |
$form['sphinx']['default_sort_order'] = array(
|
| 329 |
'#type' => 'select',
|
| 330 |
'#title' => t('Default order'),
|
| 331 |
'#options' => array('asc' => t('Ascending'), 'desc' => t('Descending')),
|
| 332 |
'#default_value' => $index->default_sort_order,
|
| 333 |
'#description' => t('Select which direction results should be ordered by default'),
|
| 334 |
);
|
| 335 |
$form['sphinx']['server'] = array(
|
| 336 |
'#type' => 'textfield',
|
| 337 |
'#title' => t('Server'),
|
| 338 |
'#description' => t('Type the name the name of the server on which the searchd of this index is running'),
|
| 339 |
'#required' => true,
|
| 340 |
'#default_value' => $index->server,
|
| 341 |
);
|
| 342 |
$form['sphinx']['port'] = array(
|
| 343 |
'#type' => 'textfield',
|
| 344 |
'#title' => t('Port'),
|
| 345 |
'#description' => t('Type the name the number of the port the searchd for this index is listening'),
|
| 346 |
'#required' => true,
|
| 347 |
'#default_value' => $index->port,
|
| 348 |
);
|
| 349 |
$form['sphinx']['excerpt'] = array(
|
| 350 |
'#type' => 'checkbox',
|
| 351 |
'#title' => t('Excerpt'),
|
| 352 |
'#description' => t('Do you want to display excerpts for results from this index'),
|
| 353 |
'#default_value' => $index->excerpt,
|
| 354 |
);
|
| 355 |
$form['sphinx']['multiquery'] = array(
|
| 356 |
'#type' => 'checkbox',
|
| 357 |
'#title' => t('Multiquery'),
|
| 358 |
'#description' => t('Does this index provide multiquerys for facets or the like'),
|
| 359 |
'#default_value' => $index->multiquery,
|
| 360 |
);
|
| 361 |
$form['sphinx']['active'] = array(
|
| 362 |
'#type' => 'checkbox',
|
| 363 |
'#title' => t('Enable'),
|
| 364 |
'#description' => t('Should this index be activated?'),
|
| 365 |
'#default_value' => $index->active,
|
| 366 |
);
|
| 367 |
$form['sphinx']['index'] = array('#type' => 'hidden', '#value' => $iid);
|
| 368 |
$form['sphinx']['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
|
| 369 |
return $form;
|
| 370 |
}
|
| 371 |
}
|
| 372 |
|
| 373 |
function sphinx_index_edit_submit($form_id, $form_values) {
|
| 374 |
db_query("UPDATE {sphinx_indexes} SET index_name='%s', display_name='%s', path='%s', default_sort_key_fid=%s, default_sort_order='%s', server='%s', port=%d, excerpt=%d, multiquery=%d, active=%d WHERE iid=%d;",
|
| 375 |
$form_values['index_name'],
|
| 376 |
$form_values['display_name'],
|
| 377 |
$form_values['path'],
|
| 378 |
$form_values['default_sort_key_fid'],
|
| 379 |
$form_values['default_sort_order'],
|
| 380 |
$form_values['server'],
|
| 381 |
$form_values['port'],
|
| 382 |
$form_values['excerpt'],
|
| 383 |
$form_values['multiquery'],
|
| 384 |
$form_values['active'],
|
| 385 |
$form_values['index']
|
| 386 |
);
|
| 387 |
drupal_goto('admin/settings/sphinx/indexes');
|
| 388 |
}
|
| 389 |
|
| 390 |
function _sphinx_manage_fields($iid) {
|
| 391 |
|
| 392 |
$output = '';
|
| 393 |
$sql = 'SELECT * FROM {sphinx_indexes} WHERE iid=%d;';
|
| 394 |
$result = db_query($sql, $iid);
|
| 395 |
$index = db_fetch_object($result);
|
| 396 |
$client = new SphinxClient();
|
| 397 |
$client->SetServer($index->server, (int)$index->port);
|
| 398 |
$connect = $client->_Connect();
|
| 399 |
if (!$connect) {
|
| 400 |
return 'Index not available';
|
| 401 |
}
|
| 402 |
$client->SetLimits(0, 1);
|
| 403 |
$res = $client->Query('', $index->index_name);
|
| 404 |
$serving = $res['fields'];
|
| 405 |
$header = array(
|
| 406 |
array('data' => t('Field'), 'field' => 'field_name'),
|
| 407 |
array('data' => t('Display name'), 'field' => 'display_name'),
|
| 408 |
array('data' => t('Excerpt'), 'field' => 'excerpt'),
|
| 409 |
array('data' => t('Weight'), 'field' => 'weight', 'sort' => 'desc'),
|
| 410 |
array('data' => t('Active'), 'field' => 'active'),
|
| 411 |
array('data' => t('Served')),
|
| 412 |
array(),
|
| 413 |
array(),
|
| 414 |
);
|
| 415 |
|
| 416 |
$sql = 'SELECT * FROM {sphinx_fields} WHERE iid=%d '. tablesort_sql($header);
|
| 417 |
$result = db_query($sql, $iid);
|
| 418 |
$counter = 0;
|
| 419 |
while ($fields = db_fetch_object($result)) {
|
| 420 |
$counter++;
|
| 421 |
if (in_array($fields->field_name, $serving)) {
|
| 422 |
unset($serving[array_search($fields->field_name, $serving)]);
|
| 423 |
$status = 'Serving';
|
| 424 |
}
|
| 425 |
else {
|
| 426 |
$status = '<span class="error">Not served!</span>';
|
| 427 |
}
|
| 428 |
$active = ($fields->active == 0) ? l(t('Enable'), 'admin/settings/sphinx/fields/enable/'. $iid .'/'. $fields->fid) : l(t('Disable'), 'admin/settings/sphinx/fields/disable/'. $iid .'/'. $fields->fid);
|
| 429 |
$rows[] = array(
|
| 430 |
$fields->field_name,
|
| 431 |
$fields->display_name,
|
| 432 |
$fields->excerpt ? 'Enabled' : 'Disabled',
|
| 433 |
$fields->weight,
|
| 434 |
$fields->active ? 'Enabled' : 'Disabled',
|
| 435 |
$status,
|
| 436 |
l(t('Delete'), 'admin/settings/sphinx/fields/delete/'. $iid .'/'. $fields->fid),
|
| 437 |
$active,
|
| 438 |
l(t('Edit'), 'admin/settings/sphinx/fields/edit/'. $iid .'/'. $fields->fid),
|
| 439 |
);
|
| 440 |
}
|
| 441 |
if ($counter) {
|
| 442 |
$output .= theme('table', $header, $rows);
|
| 443 |
}
|
| 444 |
if (count($serving)) {
|
| 445 |
|
| 446 |
$add_header = array(
|
| 447 |
array('data' => t('Field')),
|
| 448 |
array(),
|
| 449 |
);
|
| 450 |
foreach ($serving as $field) {
|
| 451 |
$add_rows[] = array($field, l(t('Add'), 'admin/settings/sphinx/fields/add/'. $iid .'/'. $field));
|
| 452 |
}
|
| 453 |
$output .= theme('table', $add_header, $add_rows);
|
| 454 |
}
|
| 455 |
return $output;
|
| 456 |
}
|
| 457 |
|
| 458 |
function _sphinx_alter_fields($op, $iid, $field) {
|
| 459 |
switch ($op) {
|
| 460 |
case 'delete':
|
| 461 |
return drupal_get_form('sphinx_field_confirm_delete', $iid, $field);
|
| 462 |
break;
|
| 463 |
|
| 464 |
case 'edit':
|
| 465 |
return drupal_get_form('sphinx_field_edit', $iid, $field);
|
| 466 |
break;
|
| 467 |
|
| 468 |
case 'add':
|
| 469 |
if (!empty($field)) {
|
| 470 |
return drupal_get_form('sphinx_field_add', $iid, $field);
|
| 471 |
}
|
| 472 |
else {
|
| 473 |
return;
|
| 474 |
}
|
| 475 |
break;
|
| 476 |
|
| 477 |
case 'enable':
|
| 478 |
$res = db_query('UPDATE {sphinx_fields} SET active = 1 WHERE fid =%d', $field);
|
| 479 |
drupal_goto('admin/settings/sphinx/indexes/fields/'. $iid);
|
| 480 |
break;
|
| 481 |
|
| 482 |
case 'disable':
|
| 483 |
$res = db_query('UPDATE {sphinx_fields} SET active = 0 WHERE fid =%d', $field);
|
| 484 |
drupal_goto('admin/settings/sphinx/indexes/fields/'. $iid);
|
| 485 |
break;
|
| 486 |
}
|
| 487 |
}
|
| 488 |
|
| 489 |
function sphinx_field_confirm_delete($iid, $fid) {
|
| 490 |
|
| 491 |
|
| 492 |
$result = db_query('SELECT field_name, display_name FROM {sphinx_fields} WHERE iid = %d && fid= %d;', $iid, $fid);
|
| 493 |
$names = db_fetch_object($result);
|
| 494 |
$form = array();
|
| 495 |
$form['text'] = array(
|
| 496 |
'#value' => t('Are you sure you want to delete the field <strong>%title</strong> (<i>%display</i>)? ', array('%title' => $names->field_name, '%display' => $names->display_name)),
|
| 497 |
);
|
| 498 |
$form['iid'] = array('#type' => 'hidden', '#value' => $iid);
|
| 499 |
$form['fid'] = array('#type' => 'hidden', '#value' => $fid);
|
| 500 |
$form['submit'] = array('#type' => 'submit', '#value' => t('Delete'));
|
| 501 |
$form['cancel'] = array('#type' => 'submit', '#value' => t('Cancel'));
|
| 502 |
|
| 503 |
return $form;
|
| 504 |
}
|
| 505 |
|
| 506 |
function sphinx_field_confirm_delete_submit($form_id, $form_values) {
|
| 507 |
if ($form_values['op'] == 'Delete') {
|
| 508 |
db_query('DELETE FROM {sphinx_fields} WHERE iid=%d && fid=%d;', $form_values['iid'], $form_values['fid']);
|
| 509 |
}
|
| 510 |
drupal_goto('admin/settings/sphinx/indexes/fields/'. $form_values['iid']);
|
| 511 |
}
|
| 512 |
|
| 513 |
function sphinx_field_add($iid, $field) {
|
| 514 |
|
| 515 |
|
| 516 |
if (!empty($iid)) {
|
| 517 |
$result = db_query('SELECT index_name, display_name FROM {sphinx_indexes} WHERE iid = %d;', $iid);
|
| 518 |
$names = db_fetch_object($result);
|
| 519 |
}
|
| 520 |
|
| 521 |
$form['sphinx']['addnew']['text'] = array(
|
| 522 |
'#value' => t('You are about to add the field <i>%field</i> to the index <strong>%title</strong> (<i>%display</i>)', array('%field' => $field, '%title' => $names->index_name, '%display' => $names->display_name)),
|
| 523 |
);
|
| 524 |
$form['sphinx']['addnew']['field_name'] = array('#type' => 'hidden', '#value' => $field);
|
| 525 |
$form['sphinx']['addnew']['display_name'] = array(
|
| 526 |
'#type' => 'textfield',
|
| 527 |
'#title' => t('Display name'),
|
| 528 |
'#description' => t('Type the name you want the users to see when using this field'),
|
| 529 |
'#required' => true,
|
| 530 |
);
|
| 531 |
$form['sphinx']['addnew']['excerpt'] = array(
|
| 532 |
'#type' => 'checkbox',
|
| 533 |
'#title' => t('Enable'),
|
| 534 |
'#description' => t('Should this field be in excerpts?'),
|
| 535 |
);
|
| 536 |
$form['sphinx']['addnew']['weight'] = array(
|
| 537 |
'#type' => 'weight',
|
| 538 |
'#title' => t('Weight'),
|
| 539 |
'#description' => t('Choose in which order field should appear in excerpts and in advanced search dropdown'),
|
| 540 |
);
|
| 541 |
$form['sphinx']['addnew']['active'] = array(
|
| 542 |
'#type' => 'checkbox',
|
| 543 |
'#title' => t('Enable'),
|
| 544 |
'#description' => t('Should this field be activated?'),
|
| 545 |
);
|
| 546 |
$form['sphinx']['addnew']['iid'] = array('#type' => 'hidden', '#value' => $iid);
|
| 547 |
$form['sphinx']['addnew']['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
|
| 548 |
return $form;
|
| 549 |
}
|
| 550 |
|
| 551 |
function sphinx_field_add_submit($form_id, $form_values) {
|
| 552 |
db_query("INSERT INTO {sphinx_fields} (iid, field_name, display_name, excerpt, weight, active) VALUES (%d, '%s','%s',%d,%d,%d)", $form_values['iid'], $form_values['field_name'], $form_values['display_name'], $form_values['excerpt'], $form_values['weight'], $form_values['active']);
|
| 553 |
//exit;
|
| 554 |
drupal_goto('admin/settings/sphinx/indexes/fields/'. $form_values['iid']);
|
| 555 |
}
|
| 556 |
|
| 557 |
function sphinx_field_edit($iid, $fid) {
|
| 558 |
|
| 559 |
|
| 560 |
if (!empty($iid)) {
|
| 561 |
$result = db_query('SELECT index_name, display_name FROM {sphinx_indexes} WHERE iid = %d;', $iid);
|
| 562 |
$index = db_fetch_object($result);
|
| 563 |
}
|
| 564 |
if (!empty($fid)) {
|
| 565 |
$result = db_query('SELECT field_name, display_name, excerpt, weight, active FROM {sphinx_fields} WHERE fid = %d;', $fid);
|
| 566 |
$field = db_fetch_object($result);
|
| 567 |
}
|
| 568 |
|
| 569 |
$form['sphinx']['addnew']['text'] = array(
|
| 570 |
'#value' => t('You are about to edit the field <i>%field</i> in the index <strong>%title</strong> (<i>%display</i>)', array('%field' => $field->field_name, '%title' => $index->index_name, '%display' => $index->display_name)),
|
| 571 |
);
|
| 572 |
|
| 573 |
$form['sphinx']['addnew']['display_name'] = array(
|
| 574 |
'#type' => 'textfield',
|
| 575 |
'#title' => t('Display name'),
|
| 576 |
'#description' => t('Type the name you want the users to see when using this field'),
|
| 577 |
'#default_value' => $field->display_name,
|
| 578 |
'#required' => true,
|
| 579 |
);
|
| 580 |
$form['sphinx']['addnew']['excerpt'] = array(
|
| 581 |
'#type' => 'checkbox',
|
| 582 |
'#title' => t('Excerpt'),
|
| 583 |
'#default_value' => $field->excerpt,
|
| 584 |
'#description' => t('Should this field be in excerpts?'),
|
| 585 |
);
|
| 586 |
$form['sphinx']['addnew']['weight'] = array(
|
| 587 |
'#type' => 'weight',
|
| 588 |
'#title' => t('Weight'),
|
| 589 |
'#default_value' => $field->weight,
|
| 590 |
'#description' => t('Choose in which order field should appear in excerpts and in advanced search dropdown'),
|
| 591 |
);
|
| 592 |
$form['sphinx']['addnew']['active'] = array(
|
| 593 |
'#type' => 'checkbox',
|
| 594 |
'#title' => t('Enable'),
|
| 595 |
'#description' => t('Should this field be activated?'),
|
| 596 |
'#default_value' => $field->active,
|
| 597 |
);
|
| 598 |
$form['sphinx']['addnew']['fid'] = array('#type' => 'hidden', '#value' => $fid);
|
| 599 |
$form['sphinx']['addnew']['iid'] = array('#type' => 'hidden', '#value' => $iid);
|
| 600 |
$form['sphinx']['addnew']['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
|
| 601 |
return $form;
|
| 602 |
}
|
| 603 |
|
| 604 |
function sphinx_field_edit_submit($form_id, $form_values) {
|
| 605 |
db_query("UPDATE {sphinx_fields} SET display_name = '%s', excerpt=%d, weight=%d, active=%d WHERE fid=%d AND iid=%d", $form_values['display_name'], $form_values['excerpt'], $form_values['weight'], $form_values['active'], $form_values['fid'], $form_values['iid']);
|
| 606 |
drupal_goto('admin/settings/sphinx/indexes/fields/'. $form_values['iid']);
|
| 607 |
}
|
| 608 |
|
| 609 |
function _sphinx_manage_attributes($iid) {
|
| 610 |
$output = '';
|
| 611 |
$sql = "SELECT * FROM {sphinx_indexes} WHERE iid=%d;";
|
| 612 |
$result = db_query($sql, $iid);
|
| 613 |
$index = db_fetch_object($result);
|
| 614 |
$client = new SphinxClient();
|
| 615 |
$client->SetServer($index->server, (int)$index->port);
|
| 616 |
|
| 617 |
$connect = $client->_Connect();
|
| 618 |
if (!$connect) {
|
| 619 |
return 'Index not available';
|
| 620 |
}
|
| 621 |
$client->SetLimits(0, 1);
|
| 622 |
$res = $client->Query('', $index->index_name);
|
| 623 |
$serving = $res['attrs'];
|
| 624 |
if(module_exists('sphinx_facet')) {
|
| 625 |
$header = array(
|
| 626 |
array('data' => t('Attribute'), 'field' => 'attribute_name'),
|
| 627 |
array('data' => t('Display name'), 'field' => 'display_name'),
|
| 628 |
array('data' => t('Sort'), 'field' => 'sort'),
|
| 629 |
array('data' => t('Active'), 'field' => 'active'),
|
| 630 |
array('data' => t('Facet'), 'field' => 'facet'),
|
| 631 |
array('data' => t('Type'), 'field' => 'type'),
|
| 632 |
array('data' => t('Served')),
|
| 633 |
array(),
|
| 634 |
array(),
|
| 635 |
);
|
| 636 |
} else {
|
| 637 |
$header = array(
|
| 638 |
array('data' => t('Attribute'), 'field' => 'attribute_name'),
|
| 639 |
array('data' => t('Display name'), 'field' => 'display_name'),
|
| 640 |
array('data' => t('Sort'), 'field' => 'sort'),
|
| 641 |
array('data' => t('Active'), 'field' => 'active'),
|
| 642 |
array('data' => t('Served')),
|
| 643 |
array(),
|
| 644 |
array(),
|
| 645 |
);
|
| 646 |
|
| 647 |
}
|
| 648 |
|
| 649 |
$sql = 'SELECT * FROM {sphinx_attributes} WHERE iid=%d '. tablesort_sql($header);
|
| 650 |
$result = db_query($sql, $iid);
|
| 651 |
$counter = 0;
|
| 652 |
while ($attributes = db_fetch_object($result)) {
|
| 653 |
$counter++;
|
| 654 |
if (array_key_exists($attributes->attribute_name, $serving)) {
|
| 655 |
unset($serving[$attributes->attribute_name]);
|
| 656 |
$status = 'Serving';
|
| 657 |
}
|
| 658 |
else {
|
| 659 |
$status = '<span class="error">Not served!</span>';
|
| 660 |
}
|
| 661 |
$active = ($attributes->active == 0) ? l(t('Enable'), 'admin/settings/sphinx/attributes/enable/'. $iid .'/'. $attributes->aid) : l(t('Disable'), 'admin/settings/sphinx/attributes/disable/'. $iid .'/'. $attributes->aid);
|
| 662 |
if(module_exists('sphinx_facet')) {
|
| 663 |
$rows[] = array(
|
| 664 |
$attributes->attribute_name,
|
| 665 |
$attributes->display_name,
|
| 666 |
$attributes->sort,
|
| 667 |
$attributes->active ? 'Enabled' : 'Disabled',
|
| 668 |
$attributes->facet ? 'Enabled' : 'Disabled',
|
| 669 |
$attributes->type,
|
| 670 |
$status,
|
| 671 |
l(t('Delete'), 'admin/settings/sphinx/attributes/delete/'. $iid .'/'. $attributes->aid),
|
| 672 |
$active,
|
| 673 |
l(t('Edit'), 'admin/settings/sphinx/attributes/edit/'. $iid .'/'. $attributes->aid),
|
| 674 |
);
|
| 675 |
} else {
|
| 676 |
$rows[] = array(
|
| 677 |
$attributes->attribute_name,
|
| 678 |
$attributes->display_name,
|
| 679 |
$attributes->sort,
|
| 680 |
$attributes->active ? 'Enabled' : 'Disabled',
|
| 681 |
$status,
|
| 682 |
l(t('Delete'), 'admin/settings/sphinx/attributes/delete/'. $iid .'/'. $attributes->aid),
|
| 683 |
$active,
|
| 684 |
l(t('Edit'), 'admin/settings/sphinx/attributes/edit/'. $iid .'/'. $attributes->aid),
|
| 685 |
);
|
| 686 |
|
| 687 |
|
| 688 |
}
|
| 689 |
}
|
| 690 |
if ($counter) {
|
| 691 |
$output .= theme('table', $header, $rows);
|
| 692 |
}
|
| 693 |
if (count($serving)) {
|
| 694 |
|
| 695 |
$add_header = array(
|
| 696 |
array('data' => t('Attribute')),
|
| 697 |
array(),
|
| 698 |
);
|
| 699 |
foreach ($serving as $attribute => $value) {
|
| 700 |
$add_rows[] = array($attribute, l(t('Add'), 'admin/settings/sphinx/attributes/add/'. $iid .'/'. $attribute));
|
| 701 |
}
|
| 702 |
$output .= theme('table', $add_header, $add_rows);
|
| 703 |
}
|
| 704 |
return $output;
|
| 705 |
}
|
| 706 |
|
| 707 |
function _sphinx_alter_attributes($op, $iid, $attribute) {
|
| 708 |
switch ($op) {
|
| 709 |
case 'delete':
|
| 710 |
return drupal_get_form('sphinx_attribute_confirm_delete', $iid, $attribute);
|
| 711 |
break;
|
| 712 |
|
| 713 |
case 'edit':
|
| 714 |
return drupal_get_form('sphinx_attribute_edit', $iid, $attribute);
|
| 715 |
break;
|
| 716 |
|
| 717 |
case 'add':
|
| 718 |
if (!empty($attribute)) {
|
| 719 |
return drupal_get_form('sphinx_attribute_add', $iid, $attribute);
|
| 720 |
}
|
| 721 |
else {
|
| 722 |
return;
|
| 723 |
}
|
| 724 |
break;
|
| 725 |
|
| 726 |
case 'enable':
|
| 727 |
$res = db_query('UPDATE {sphinx_attributes} SET active = 1 WHERE aid =%d', $attribute);
|
| 728 |
drupal_goto('admin/settings/sphinx/indexes/attributes/'. $iid);
|
| 729 |
break;
|
| 730 |
|
| 731 |
case 'disable':
|
| 732 |
$res = db_query('UPDATE {sphinx_attributes} SET active = 0 WHERE aid =%d', $attribute);
|
| 733 |
drupal_goto('admin/settings/sphinx/indexes/attributes/'. $iid);
|
| 734 |
break;
|
| 735 |
}
|
| 736 |
}
|
| 737 |
|
| 738 |
function sphinx_attribute_confirm_delete($iid, $aid) {
|
| 739 |
|
| 740 |
|
| 741 |
$result = db_query('SELECT attribute_name, display_name FROM {sphinx_attributes} WHERE iid = %d && aid= %d;', $iid, $aid);
|
| 742 |
$names = db_fetch_object($result);
|
| 743 |
$form = array();
|
| 744 |
$form['text'] = array(
|
| 745 |
'#value' => t('Are you sure you want to delete the attribute <strong>%title</strong> (<i>%display</i>)? ', array('%title' => $names->attribute_name, '%display' => $names->display_name)),
|
| 746 |
);
|
| 747 |
$form['iid'] = array('#type' => 'hidden', '#value' => $iid);
|
| 748 |
$form['aid'] = array('#type' => 'hidden', '#value' => $aid);
|
| 749 |
$form['submit'] = array('#type' => 'submit', '#value' => t('Delete'));
|
| 750 |
$form['cancel'] = array('#type' => 'submit', '#value' => t('Cancel'));
|
| 751 |
|
| 752 |
return $form;
|
| 753 |
}
|
| 754 |
|
| 755 |
function sphinx_attribute_confirm_delete_submit($form_id, $form_values) {
|
| 756 |
if ($form_values['op'] == 'Delete') {
|
| 757 |
db_query('DELETE FROM {sphinx_attributes} WHERE iid=%d && aid=%d;', $form_values['iid'], $form_values['aid']);
|
| 758 |
}
|
| 759 |
drupal_goto('admin/settings/sphinx/indexes/attributes/'. $form_values['iid']);
|
| 760 |
}
|
| 761 |
|
| 762 |
function sphinx_attribute_add($iid, $attribute) {
|
| 763 |
|
| 764 |
|
| 765 |
if (!empty($iid)) {
|
| 766 |
$result = db_query('SELECT index_name, display_name FROM {sphinx_indexes} WHERE iid = %d;', $iid);
|
| 767 |
$names = db_fetch_object($result);
|
| 768 |
}
|
| 769 |
|
| 770 |
$form['sphinx']['addnew']['text'] = array(
|
| 771 |
'#value' => t('You are about to add the attribute <i>%attribute</i> to the index <strong>%title</strong> (<i>%display</i>)', array('%attribute' => $attribute, '%title' => $names->index_name, '%display' => $names->display_name)),
|
| 772 |
);
|
| 773 |
$form['sphinx']['addnew']['attribute_name'] = array('#type' => 'hidden', '#value' => $attribute);
|
| 774 |
$form['sphinx']['addnew']['display_name'] = array(
|
| 775 |
'#type' => 'textfield',
|
| 776 |
'#title' => t('Display name'),
|
| 777 |
'#description' => t('Type the name you want the users to see when using this attribute'),
|
| 778 |
'#required' => true,
|
| 779 |
);
|
| 780 |
|
| 781 |
$form['sphinx']['addnew']['active'] = array(
|
| 782 |
'#type' => 'checkbox',
|
| 783 |
'#title' => t('Enable'),
|
| 784 |
'#description' => t('Should this attribute be activated?'),
|
| 785 |
);
|
| 786 |
if(module_exists('sphinx_facet')) {
|
| 787 |
$form['sphinx']['addnew']['facet'] = array(
|
| 788 |
'#type' => 'checkbox',
|
| 789 |
'#title' => t('Enable'),
|
| 790 |
'#description' => t('Should this attribute be used as a facet?'),
|
| 791 |
);
|
| 792 |
$form['sphinx']['addnew']['type'] = array(
|
| 793 |
'#type' => 'select',
|
| 794 |
'#title' => t('Type'),
|
| 795 |
'#options' => array('term' => t('Term'), 'user' => t('User'), 'node' => t('Node'), 'date' => t('Date'), 'other' => t('Other')),
|
| 796 |
'#description' => t('Should this attribute be used as a facet?'),
|
| 797 |
);
|
| 798 |
}
|
| 799 |
$form['sphinx']['addnew']['iid'] = array('#type' => 'hidden', '#value' => $iid);
|
| 800 |
$form['sphinx']['addnew']['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
|
| 801 |
return $form;
|
| 802 |
}
|
| 803 |
|
| 804 |
function sphinx_attribute_add_submit($form_id, $form_values) {
|
| 805 |
$facet = (empty($form_values['facet']))?0:$form_values['facet'];
|
| 806 |
$type = (empty($form_values['type']))?'':$form_values['type'];
|
| 807 |
db_query("INSERT INTO {sphinx_attributes} (iid, attribute_name, display_name, active, facet, type) VALUES (%d, '%s','%s',%d, %d, '%s')", $form_values['iid'], $form_values['attribute_name'], $form_values['display_name'], $form_values['active'], $facet, $type);
|
| 808 |
drupal_goto('admin/settings/sphinx/indexes/attributes/'. $form_values['iid']);
|
| 809 |
}
|
| 810 |
|
| 811 |
function sphinx_attribute_edit($iid, $aid) {
|
| 812 |
|
| 813 |
|
| 814 |
if (!empty($iid)) {
|
| 815 |
$result = db_query('SELECT index_name, display_name FROM {sphinx_indexes} WHERE iid = %d;', $iid);
|
| 816 |
$index = db_fetch_object($result);
|
| 817 |
}
|
| 818 |
if (!empty($aid)) {
|
| 819 |
$result = db_query('SELECT attribute_name, display_name, active, facet, type FROM {sphinx_attributes} WHERE aid = %d;', $aid);
|
| 820 |
$attribute = db_fetch_object($result);
|
| 821 |
}
|
| 822 |
|
| 823 |
$form['sphinx']['addnew']['text'] = array(
|
| 824 |
'#value' => t('You are about to edit the attribute <i>%attribute</i> in the index <strong>%title</strong> (<i>%display</i>)', array('%attribute' => $attribute->attribute_name, '%title' => $index->index_name, '%display' => $index->display_name)),
|
| 825 |
);
|
| 826 |
|
| 827 |
$form['sphinx']['addnew']['display_name'] = array(
|
| 828 |
'#type' => 'textfield',
|
| 829 |
'#title' => t('Display name'),
|
| 830 |
'#description' => t('Type the name you want the users to see when using this attribute'),
|
| 831 |
'#default_value' => $attribute->display_name,
|
| 832 |
'#required' => true,
|
| 833 |
);
|
| 834 |
|
| 835 |
$form['sphinx']['addnew']['active'] = array(
|
| 836 |
'#type' => 'checkbox',
|
| 837 |
'#title' => t('Enable'),
|
| 838 |
'#description' => t('Should this attribute be activated?'),
|
| 839 |
'#default_value' => $attribute->active,
|
| 840 |
);
|
| 841 |
if(module_exists('sphinx_facet')) {
|
| 842 |
$form['sphinx']['addnew']['facet'] = array(
|
| 843 |
'#type' => 'checkbox',
|
| 844 |
'#title' => t('Enable'),
|
| 845 |
'#description' => t('Should this attribute be used as a facet?'),
|
| 846 |
'#default_value' => $attribute->facet,
|
| 847 |
);
|
| 848 |
$form['sphinx']['addnew']['type'] = array(
|
| 849 |
'#type' => 'select',
|
| 850 |
'#title' => t('Type'),
|
| 851 |
'#options' => array('term' => t('Term'), 'user' => t('User'), 'node' => t('Node'), 'date' => t('Date'), 'other' => t('Other')),
|
| 852 |
'#description' => t('Should this attribute be used as a facet?'),
|
| 853 |
'#default_value' => $attribute->type,
|
| 854 |
|
| 855 |
);
|
| 856 |
}
|
| 857 |
$form['sphinx']['addnew']['aid'] = array('#type' => 'hidden', '#value' => $aid);
|
| 858 |
$form['sphinx']['addnew']['iid'] = array('#type' => 'hidden', '#value' => $iid);
|
| 859 |
$form['sphinx']['addnew']['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
|
| 860 |
return $form;
|
| 861 |
}
|
| 862 |
|
| 863 |
function sphinx_attribute_edit_submit($form_id, $form_values) {
|
| 864 |
if(module_exists('sphinx_facet')) {
|
| 865 |
db_query("UPDATE {sphinx_attributes} SET display_name = '%s', active=%d, facet=%d, type='%s' WHERE aid=%d AND iid=%d", $form_values['display_name'], $form_values['active'], $form_values['facet'], $form_values['type'], $form_values['aid'], $form_values['iid']);
|
| 866 |
} else {
|
| 867 |
db_query("UPDATE {sphinx_attributes} SET display_name = '%s', active=%d WHERE aid=%d AND iid=%d", $form_values['display_name'], $form_values['active'], $form_values['aid'], $form_values['iid']);
|
| 868 |
}
|
| 869 |
drupal_goto('admin/settings/sphinx/indexes/attributes/'. $form_values['iid']);
|
| 870 |
}
|
| 871 |
|
| 872 |
function _sphinx_get_field_display_name_by_iid($fid = null) {
|
| 873 |
if (!empty($iid)) {
|
| 874 |
$res = db_query("SELECT display_name FROM {sphinx_fields} WHERE fid=%d", $fid);
|
| 875 |
$index = db_fetch_object($res);
|
| 876 |
return $index->display_name;
|
| 877 |
}
|
| 878 |
}
|
| 879 |
|