1 node.module node_search_admin()

Implements hook_search_admin().

File

core/modules/node/node.module, line 1330
The core module that allows content to be submitted to the site.

Code

function node_search_admin() {
  $config = config('search.settings');

  // Output form for defining rank factor weights.
  $form['node_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Content settings'),
    '#states' => array(
      'visible' => array(
        '[name*="search_active_modules[node]"]' => array('checked' => TRUE)
      ),
    ),
    '#element_validate' => array('node_search_admin_validate'),
  );
  $form['node_settings']['node_types'] = array(
    '#title' => t('Enabled content types'),
    '#type' => 'checkboxes',
    '#default_value' => _node_search_get_types(),
    '#options' => node_type_get_names(),
    '#description' => t('Only enabled content types will be available in search results. Disabled content types will not be indexed in the future.'),
  );

  $form['node_settings']['factors'] = array(
    '#type' => 'item',
    '#title' => t('Content rankings'),
    '#theme' => 'node_search_factors',
    '#help' => '<em>' . t('Influence is a numeric multiplier used in ordering search results. A higher number means the corresponding factor has more influence on search results; zero means the factor is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') . '</em>',
  );

  // Note: reversed to reflect that higher number = higher ranking.
  $options = backdrop_map_assoc(range(0, 10));
  foreach (module_invoke_all('ranking') as $var => $values) {
    $form['node_settings']['factors']['node_rank_' . $var] = array(
      '#title' => $values['title'],
      '#type' => 'select',
      '#options' => $options,
      '#default_value' => $config->get('node_rank_' . $var),
    );
  }

  // Sort factors by rank, highest first.
  backdrop_sort($form['node_settings']['factors'], array('#default_value' => SORT_NUMERIC), SORT_DESC);
  return $form;
}