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) { ...@@ -166,22 +166,20 @@ function search_config_form_alter(&$form, &$form_state, $form_id) {
unset($form['advanced']['type']); unset($form['advanced']['type']);
} }
else { else {
$types = node_type_get_types(); $content_types = node_type_get_types();
foreach ($content_types as $machine_name => $content_type) {
foreach ($types as $module => $type) { if ($remove[$machine_name]) {
if ($remove[$module]) { unset($content_types[$machine_name]);
unset($types[$module]);
} }
else { else {
$types[$module] = t($type); $options[$machine_name] = $content_type->name;
} }
} }
// Rebuild form item -- copied from node.module, but only if advanced // Rebuild form item -- copied from node.module, but only if advanced
// fieldset exists. // fieldset exists.
if (!empty($form['advanced'])) { if (!empty($form['advanced'])) {
if (count($types) == 1) { if (count($content_types) == 1) {
$type_keys = array_keys($types); $type_keys = array_keys($content_types);
$form['advanced']['type'] = array( $form['advanced']['type'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#default_value' => $type_keys[0], '#default_value' => $type_keys[0],
...@@ -193,7 +191,7 @@ function search_config_form_alter(&$form, &$form_state, $form_id) { ...@@ -193,7 +191,7 @@ function search_config_form_alter(&$form, &$form_state, $form_id) {
'#title' => t('Only of the type(s)'), '#title' => t('Only of the type(s)'),
'#prefix' => '<div class="criterion">', '#prefix' => '<div class="criterion">',
'#suffix' => '</div>', '#suffix' => '</div>',
'#options' => $types, '#options' => $options, //$types,
); );
} }
} }
...@@ -250,19 +248,6 @@ function search_config_form_alter(&$form, &$form_state, $form_id) { ...@@ -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) { function search_config_validate($form, &$form_state) {
if ($form_state['values']['form_id'] == 'search_admin_settings' && $form_state['values']['op'] == t('Save configuration')) { 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) { ...@@ -313,22 +298,22 @@ function search_config_validate($form, &$form_state) {
*/ */
function search_config_query_alter(QueryAlterableInterface $query) { function search_config_query_alter(QueryAlterableInterface $query) {
$tables = $query->getTables(); $tables = $query->getTables();
$search = array( $search_tables = array(
'i' => 'search_index', 'i' => 'search_index',
'n' => 'node', 'n' => 'node',
); );
$intersection = array_intersect_key($search, $tables); $intersection = array_intersect_key($search_tables, $tables);
if (empty($intersection)) { if (empty($intersection)) {
return; return;
} }
// Double check to ensure that the i and n aliases are pointing to // Double check to ensure that the i and n aliases are pointing to
// the search index and node table. // the search index and node table.
foreach ($intersection as $alias => $table) { foreach ($search_tables as $alias => $table) {
if ($tables[$alias]['table'] != $table) { if (empty($tables[$alias]) OR $tables[$alias]['table'] != $table) {
return; return;
} }
} }
// Remove hidden content types.
$hidden_content_types = variable_get('search_config_disable_index_type', array()); $hidden_content_types = variable_get('search_config_disable_index_type', array());
$hidden_content_types = array_filter($hidden_content_types); $hidden_content_types = array_filter($hidden_content_types);
if (!empty($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