function _custom_search_default_admin_form in Custom Search 7
Same name and namespace in other branches
- 6 includes/forms.inc \_custom_search_default_admin_form()
Default admin form.
2 calls to _custom_search_default_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 10 - Search forms
Code
function _custom_search_default_admin_form($delta = '') {
if ($delta != '') {
$delta = 'blocks_' . $delta . '_';
}
// Labels & default text.
$form['search_box'] = array(
'#type' => 'fieldset',
'#title' => t('Search box'),
);
$form['search_box']['custom_search_' . $delta . 'label_visibility'] = array(
'#type' => 'checkbox',
'#title' => t('Display label'),
'#default_value' => variable_get('custom_search_' . $delta . 'label_visibility', TRUE),
);
$form['search_box']['custom_search_' . $delta . 'label'] = array(
'#type' => 'textfield',
'#title' => t('Search box label'),
'#default_value' => variable_get('custom_search_' . $delta . 'label', CUSTOM_SEARCH_LABEL_DEFAULT),
'#description' => t('Enter the label text for the search box. The default value is "!default".', array(
'!default' => CUSTOM_SEARCH_LABEL_DEFAULT,
)),
'#states' => array(
'visible' => array(
':input[name="custom_search_' . $delta . 'label_visibility"]' => array(
'checked' => TRUE,
),
),
),
);
$form['search_box']['custom_search_' . $delta . 'text'] = array(
'#type' => 'textfield',
'#title' => t('Search box placeholder text'),
'#default_value' => variable_get('custom_search_' . $delta . 'text', ''),
'#description' => t('This will change the default text inside the search form. This is the <a href="http://www.w3schools.com/tags/att_input_placeholder.asp" target="_blank">placeholder</a> attribute for the TextField. Leave blank for no text. This field is blank by default.'),
);
$form['search_box']['custom_search_' . $delta . 'hint_text'] = array(
'#type' => 'textfield',
'#title' => t('Search box hint text'),
'#default_value' => variable_get('custom_search_' . $delta . 'hint_text', CUSTOM_SEARCH_HINT_TEXT_DEFAULT),
'#description' => t('Enter the text that will be displayed when hovering the input field (HTML <em>title</em> attritube).'),
);
if (module_exists('elements')) {
$form['search_box']['custom_search_' . $delta . 'element'] = array(
'#type' => 'select',
'#title' => t('Search box input type'),
'#options' => array(
'textfield' => 'text',
'searchfield' => 'search (HTML5)',
),
'#default_value' => variable_get('custom_search_' . $delta . 'element', 'textfield'),
'#description' => t('The default value is "text".'),
);
}
$form['search_box']['custom_search_' . $delta . 'operator'] = array(
'#type' => 'select',
'#title' => t('Search operator'),
'#options' => array(
'AND' => t('AND'),
'OR' => t('OR'),
),
'#default_value' => variable_get('custom_search_' . $delta . 'operator', 'AND'),
'#description' => t('The default value is "AND", and will search for results containing ALL the words. Choose "OR" to search for results containing ANY of the words.'),
);
$form['search_box']['custom_search_' . $delta . 'size'] = array(
'#type' => 'textfield',
'#title' => t('Search box size'),
'#size' => 3,
'#default_value' => variable_get('custom_search_' . $delta . 'size', CUSTOM_SEARCH_SIZE_DEFAULT),
'#description' => t('The default value is "!default".', array(
'!default' => CUSTOM_SEARCH_SIZE_DEFAULT,
)),
);
$form['search_box']['custom_search_' . $delta . 'max_length'] = array(
'#type' => 'textfield',
'#title' => t('Search box maximum length'),
'#size' => 3,
'#default_value' => variable_get('custom_search_' . $delta . 'max_length', CUSTOM_SEARCH_MAX_LENGTH_DEFAULT),
'#description' => t('The default value is "!default".', array(
'!default' => CUSTOM_SEARCH_MAX_LENGTH_DEFAULT,
)),
'#required' => TRUE,
);
// Submit button.
$form['submit_button'] = array(
'#type' => 'fieldset',
'#title' => t('Submit button'),
);
$form['submit_button']['custom_search_' . $delta . 'submit_text'] = array(
'#type' => 'textfield',
'#title' => t('Submit button text'),
'#default_value' => variable_get('custom_search_' . $delta . 'submit_text', CUSTOM_SEARCH_SUBMIT_TEXT_DEFAULT),
'#description' => t('Enter the text for the submit button. Leave blank to hide it. The default value is "!default".', array(
'!default' => CUSTOM_SEARCH_SUBMIT_TEXT_DEFAULT,
)),
);
$form['submit_button']['custom_search_' . $delta . 'image_path'] = array(
'#type' => 'textfield',
'#title' => t('Submit image path'),
'#description' => t('The path to the file you would like to use as submit button instead of the default text button.'),
'#default_value' => variable_get('custom_search_' . $delta . 'image_path', ''),
);
$form['submit_button']['custom_search_image'] = array(
'#type' => 'file',
'#title' => t('Submit image'),
'#description' => t("If you don't have direct file access to the server, use this field to upload your image."),
);
// Criteria.
$form['criteria'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced search criteria'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['criteria']['or'] = array(
'#type' => 'fieldset',
'#title' => t('Or'),
);
$form['criteria']['or']['custom_search_' . $delta . 'criteria_or_display'] = array(
'#type' => 'checkbox',
'#title' => t('Display'),
'#default_value' => variable_get('custom_search_' . $delta . 'criteria_or_display', FALSE),
);
$form['criteria']['or']['custom_search_' . $delta . 'criteria_or_label'] = array(
'#type' => 'textfield',
'#title' => t('Label'),
'#default_value' => variable_get('custom_search_' . $delta . 'criteria_or_label', CUSTOM_SEARCH_CRITERIA_OR_LABEL_DEFAULT),
'#description' => t('Enter the label text for this field. The default value is "!default".', array(
'!default' => CUSTOM_SEARCH_CRITERIA_OR_LABEL_DEFAULT,
)),
'#states' => array(
'visible' => array(
':input[name="custom_search_' . $delta . 'criteria_or_display"]' => array(
'checked' => TRUE,
),
),
),
);
$form['criteria']['phrase'] = array(
'#type' => 'fieldset',
'#title' => t('Phrase'),
);
$form['criteria']['phrase']['custom_search_' . $delta . 'criteria_phrase_display'] = array(
'#type' => 'checkbox',
'#title' => t('Display'),
'#default_value' => variable_get('custom_search_' . $delta . 'criteria_phrase_display', FALSE),
);
$form['criteria']['phrase']['custom_search_' . $delta . 'criteria_phrase_label'] = array(
'#type' => 'textfield',
'#title' => t('Label'),
'#default_value' => variable_get('custom_search_' . $delta . 'criteria_phrase_label', CUSTOM_SEARCH_CRITERIA_PHRASE_LABEL_DEFAULT),
'#description' => t('Enter the label text for this field. The default value is "!default".', array(
'!default' => CUSTOM_SEARCH_CRITERIA_PHRASE_LABEL_DEFAULT,
)),
'#states' => array(
'visible' => array(
':input[name="custom_search_' . $delta . 'criteria_phrase_display"]' => array(
'checked' => TRUE,
),
),
),
);
$form['criteria']['negative'] = array(
'#type' => 'fieldset',
'#title' => t('Negative'),
);
$form['criteria']['negative']['custom_search_' . $delta . 'criteria_negative_display'] = array(
'#type' => 'checkbox',
'#title' => t('Display'),
'#default_value' => variable_get('custom_search_' . $delta . 'criteria_negative_display', FALSE),
);
$form['criteria']['negative']['custom_search_' . $delta . 'criteria_negative_label'] = array(
'#type' => 'textfield',
'#title' => t('Label'),
'#default_value' => variable_get('custom_search_' . $delta . 'criteria_negative_label', CUSTOM_SEARCH_CRITERIA_NEGATIVE_LABEL_DEFAULT),
'#description' => t('Enter the label text for this field. The default value is "!default".', array(
'!default' => CUSTOM_SEARCH_CRITERIA_NEGATIVE_LABEL_DEFAULT,
)),
'#states' => array(
'visible' => array(
':input[name="custom_search_' . $delta . 'criteria_negative_display"]' => array(
'checked' => TRUE,
),
),
),
);
if (module_exists('search_api_page')) {
$search_api_pages = search_api_page_load_multiple();
$options[0] = t('None');
foreach ($search_api_pages as $page) {
$options[$page->id] = $page->name;
}
$form['searchapi'] = array(
'#type' => 'fieldset',
'#title' => t('Search API'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['searchapi']['custom_search_' . $delta . 'search_api_page'] = array(
'#type' => 'select',
'#title' => t('Search API Page to use'),
'#options' => $options,
'#default_value' => variable_get('custom_search_' . $delta . 'search_api_page', 0),
);
}
return $form;
}