1 search.module | search_block_view($delta = '', $settings = array(), $contexts = array()) |
Implements hook_block_view().
File
- core/
modules/ search/ search.module, line 169 - Enables site-wide keyword searching.
Code
function search_block_view($delta = '', $settings = array(), $contexts = array()) {
if (user_access('search content')) {
$search_settings = !empty($settings['search']) ? $settings['search'] : array();
$search_settings += array(
'label' => '',
'label_hide' => TRUE,
'placeholder' => '',
'button_text' => 'Search',
);
$form = backdrop_get_form('search_block_form');
// Show the label.
if (!$search_settings['label_hide']) {
$form['search_block_form']['#title_display'] = 'before';
// Update the label text.
if ($search_settings['label'] != '') {
$form['search_block_form']['#title'] = t(check_plain($search_settings['label']));
}
}
// Add a placeholder.
if ($search_settings['placeholder'] != '') {
$form['search_block_form']['#attributes']['placeholder'] = t(trim($search_settings['placeholder']));
}
// Change the button text.
if ($search_settings['button_text'] != 'Search') {
if ($search_settings['button_text'] == '') {
$form['actions']['submit']['#access'] = FALSE;
}
else {
$form['actions']['submit']['#value'] = t(check_plain(trim($search_settings['button_text'])));
}
}
$block['subject'] = t('Search');
$block['content'] = $form;
return $block;
}
}