You are here

function _custom_search_ordering_admin_form in Custom Search 7

Same name and namespace in other branches
  1. 6 includes/forms.inc \_custom_search_ordering_admin_form()

Ordering admin form.

2 calls to _custom_search_ordering_admin_form()
custom_search_admin in ./custom_search.admin.inc
General settings.
custom_search_blocks_block_configure in modules/custom_search_blocks/custom_search_blocks.module
Implements hook_block_configure().

File

includes/forms.inc, line 344
Search forms

Code

function _custom_search_ordering_admin_form($delta = '') {
  drupal_add_css(drupal_get_path('module', 'custom_search') . '/custom_search.css');
  if ($delta != '') {
    $delta = 'blocks_' . $delta . '_';
  }
  $form['order'] = array(
    '#type' => 'fieldset',
    '#title' => t('Elements ordering'),
    '#description' => t('Order the form elements as you want them to be displayed. If you put elements in the Popup section, they will only appear when the search field is clicked.'),
  );
  $form['order']['custom_search_' . $delta . 'order'] = array(
    '#tree' => TRUE,
    '#theme' => 'custom_search_sort_form',
  );
  $elements = array(
    'search_box' => array(
      'title' => t('Search box'),
      'default_weight' => -1,
    ),
    'criteria_or' => array(
      'title' => t('Advanced search criterion: Or'),
      'default_weight' => 6,
    ),
    'criteria_phrase' => array(
      'title' => t('Advanced search criterion: Phrase'),
      'default_weight' => 7,
    ),
    'criteria_negative' => array(
      'title' => t('Advanced search criterion: Negative'),
      'default_weight' => 8,
    ),
    'custom_paths' => array(
      'title' => t('Custom search paths'),
      'default_weight' => 9,
    ),
    'submit_button' => array(
      'title' => t('Submit button'),
      'default_weight' => 10,
    ),
  );
  if (count(array_filter(array_merge(variable_get('custom_search_' . $delta . 'node_types', array()), variable_get('custom_search_' . $delta . 'other', array()))))) {
    $elements['content_types'] = array(
      'title' => t('Content Types'),
      'default_weight' => 0,
    );
  }
  foreach ($elements as $element => $data) {
    $form['order']['custom_search_' . $delta . 'order'][$element] = array(
      '#title' => $data['title'],
      '#weight' => variable_get('custom_search_' . $delta . $element . '_weight', $data['default_weight']),
    );
    $form['order']['custom_search_' . $delta . 'order'][$element]['sort'] = array(
      '#type' => 'weight',
      '#default_value' => variable_get('custom_search_' . $delta . $element . '_weight', $data['default_weight']),
      '#attributes' => array(
        'class' => array(
          'sort-select',
          'sort-select-' . variable_get('custom_search_' . $delta . $element . '_region', 'block'),
        ),
      ),
    );
    $form['order']['custom_search_' . $delta . 'order'][$element]['region'] = array(
      '#type' => 'select',
      '#options' => array(
        'block' => t('Block'),
        'popup' => t('Popup'),
      ),
      '#default_value' => variable_get('custom_search_' . $delta . $element . '_region', 'block'),
      '#attributes' => array(
        'class' => array(
          'region-select',
          'region-select-' . variable_get('custom_search_' . $delta . $element . '_region', 'block'),
        ),
      ),
    );
  }
  return $form;
}