You are here

function nodequeue_form_apachesolr_search_bias_form_alter in Nodequeue 7.2

Same name and namespace in other branches
  1. 6.2 nodequeue.module \nodequeue_form_apachesolr_search_bias_form_alter()
  2. 7.3 nodequeue.module \nodequeue_form_apachesolr_search_bias_form_alter()

Implements hook_form_FORM_ID_alter().

File

./nodequeue.module, line 581
Maintains queues of nodes in arbitrary order.

Code

function nodequeue_form_apachesolr_search_bias_form_alter(&$form, &$form_state) {

  // Setup for the form building.
  $weights = drupal_map_assoc(array(
    '21.0',
    '13.0',
    '8.0',
    '5.0',
    '3.0',
    '2.0',
    '1.0',
    '0.8',
    '0.5',
    '0.3',
    '0.2',
    '0.1',
  ));
  $weights['0'] = t('Normal');
  $queues = nodequeue_load_subqueues_by_queue(array_keys(nodequeue_get_all_qids()));
  $env_id = $form['#env_id'];

  // Build the form.
  $form['biasing']['nodequeue_boost'] = array(
    '#type' => 'fieldset',
    '#title' => t('Nodequeue Biasing'),
    '#weight' => -5,
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['biasing']['nodequeue_boost']['nodequeue_apachesolr_boost'] = array(
    '#type' => 'item',
    '#description' => t("Specify to bias the search result when a node is in a queue. Any value except <em>Normal</em> will increase the score for the given queue in the search results"),
  );
  foreach ($queues as $sqid => $queue) {
    $boost = apachesolr_environment_variable_get($env_id, "nodequeue_apachesolr_boost_{$sqid}", 0);

    // Add in setting for each queue.
    $form['biasing']['nodequeue_boost']['nodequeue_apachesolr_boost']["nodequeue_apachesolr_boost_{$sqid}"] = array(
      '#type' => 'select',
      '#title' => t('Weight for %title nodequeue', array(
        '%title' => $queue->title,
      )),
      '#options' => $weights,
      '#default_value' => $boost,
    );
  }
  $form['actions']['submit']['#submit'][] = 'nodequeue_search_bias_form_submit';
}