Commit d6241476 authored by Joseph Yanick's avatar Joseph Yanick
Browse files

Default search option has been moved to core. Clean up

parent ba6b2667
......@@ -166,22 +166,20 @@ function search_config_form_alter(&$form, &$form_state, $form_id) {
unset($form['advanced']['type']);
}
else {
$types = node_type_get_types();
foreach ($types as $module => $type) {
if ($remove[$module]) {
unset($types[$module]);
$content_types = node_type_get_types();
foreach ($content_types as $machine_name => $content_type) {
if ($remove[$machine_name]) {
unset($content_types[$machine_name]);
}
else {
$types[$module] = t($type);
$options[$machine_name] = $content_type->name;
}
}
// Rebuild form item -- copied from node.module, but only if advanced
// fieldset exists.
if (!empty($form['advanced'])) {
if (count($types) == 1) {
$type_keys = array_keys($types);
if (count($content_types) == 1) {
$type_keys = array_keys($content_types);
$form['advanced']['type'] = array(
'#type' => 'hidden',
'#default_value' => $type_keys[0],
......@@ -193,7 +191,7 @@ function search_config_form_alter(&$form, &$form_state, $form_id) {
'#title' => t('Only of the type(s)'),
'#prefix' => '<div class="criterion">',
'#suffix' => '</div>',
'#options' => $types,
'#options' => $options, //$types,
);
}
}
......@@ -250,19 +248,6 @@ function search_config_form_alter(&$form, &$form_state, $form_id) {
}
}
/**
* Process a block search form submission.
*
* Taken from the core search module. It allows the search block to work
* with other default search types than node.
*/
function search_config_form_submit($form, &$form_state) {
$form_id = $form['form_id']['#value'];
$type = $form['module']['#value'];
$form_state['redirect'] = 'search/'. $type .'/'. trim($form_state['values'][$form_id]);
}
function search_config_validate($form, &$form_state) {
if ($form_state['values']['form_id'] == 'search_admin_settings' && $form_state['values']['op'] == t('Save configuration')) {
......@@ -313,22 +298,22 @@ function search_config_validate($form, &$form_state) {
*/
function search_config_query_alter(QueryAlterableInterface $query) {
$tables = $query->getTables();
$search = array(
$search_tables = array(
'i' => 'search_index',
'n' => 'node',
);
$intersection = array_intersect_key($search, $tables);
$intersection = array_intersect_key($search_tables, $tables);
if (empty($intersection)) {
return;
}
// Double check to ensure that the i and n aliases are pointing to
// the search index and node table.
foreach ($intersection as $alias => $table) {
if ($tables[$alias]['table'] != $table) {
foreach ($search_tables as $alias => $table) {
if (empty($tables[$alias]) OR $tables[$alias]['table'] != $table) {
return;
}
}
// Remove hidden content types.
$hidden_content_types = variable_get('search_config_disable_index_type', array());
$hidden_content_types = array_filter($hidden_content_types);
if (!empty($hidden_content_types)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment