diff --git a/src/Form/SettingsForm.php b/src/Form/SettingsForm.php index e82ed02..c9af001 100644 --- a/src/Form/SettingsForm.php +++ b/src/Form/SettingsForm.php @@ -66,6 +66,88 @@ class SettingsForm extends ConfigFormBase { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { + $form['eDisMax'] = [ + '#type' => 'fieldset', + '#title' => $this->t('Advanced Search Block'), + '#weight' => -1, + ]; + $form['eDisMax']['advanced-search-block-description'] = [ + '#markup' => $this->t("Advanced Search Blocks are available in the Blocks interface for each Search API view. When placing an Advanced Search Block, you can configure the fields that are used for field-based search and whether a “recursive” search is available. The following settings apply to all Advanced Search blocks."), + '#weight' => -2, + ]; + $form['eDisMax'][self::EDISMAX_SEARCH_FLAG] = [ + '#type' => 'checkbox', + '#title' => $this + ->t('Enable Extended DisMax Query.'), + '#description' => $this->t(''), + '#default_value' => self::getConfig(self::EDISMAX_SEARCH_FLAG, 1), + ]; + + $form['eDisMax']['textfields_container'] = [ + '#type' => 'container', + '#attributes' => ['id' => 'edismax-container'], + ]; + + $form['eDisMax']['textfields_container'][self::SEARCH_ALL_FIELDS_FLAG] = [ + '#type' => 'checkbox', + '#title' => $this + ->t('Enable searching all fields'), + '#description' => $this->t(''), + '#default_value' => self::getConfig(self::SEARCH_ALL_FIELDS_FLAG, 0), + ]; + $form['eDisMax']['textfields_container'][self::EDISMAX_SEARCH_LABEL] = [ + '#type' => 'textfield', + '#title' => $this->t('If enabled, set the label for the option of searching all fields'), + '#description' => $this->t('E.g. keyword.'), + '#default_value' => self::getConfig(self::EDISMAX_SEARCH_LABEL, "Keyword"), + ]; + + + $form['display-mode'] = [ + '#type' => 'fieldset', + '#title' => $this->t("Pager Block"), + ]; + $form['display-mode']['pager-block-description'] = [ + '#markup' => $this->t("Pager blocks are available in the Blocks interface for each Search API view. The following settings apply for all Pager blocks."), + ]; + + $form['display-mode'][self::DISPLAY_LIST_FLAG] = [ + '#type' => 'checkbox', + '#title' => $this + ->t('Expose "List view" option.'), + '#default_value' => self::getConfig(self::DISPLAY_LIST_FLAG, 0), + ]; + + $form['display-mode'][self::DISPLAY_GRID_FLAG] = [ + '#type' => 'checkbox', + '#title' => $this + ->t('Expose "Grid view" option.'), + '#default_value' => self::getConfig(self::DISPLAY_GRID_FLAG, 0), + ]; + + $form['display-mode'][self::DISPLAY_DEFAULT] = [ + '#type' => 'select', + '#title' => $this + ->t('Default view mode:'), + '#options' => [ + 'list' => 'List', + 'grid' => 'Grid' + ], + '#default_value' => self::getConfig(self::DISPLAY_DEFAULT, 'grid'), + ]; + $form += [ 'search' => [ '#type' => 'fieldset', @@ -107,68 +189,7 @@ class SettingsForm extends ConfigFormBase { ], ], ]; - - $form['display-mode'] = [ - '#type' => 'fieldset', - '#title' => $this->t("Display Mode"), - ]; - $form['display-mode'][self::DISPLAY_LIST_FLAG] = [ - '#type' => 'checkbox', - '#title' => $this - ->t('Enable List View.'), - '#default_value' => self::getConfig(self::DISPLAY_LIST_FLAG, 0), - ]; - - $form['display-mode'][self::DISPLAY_GRID_FLAG] = [ - '#type' => 'checkbox', - '#title' => $this - ->t('Enable Grid View.'), - '#default_value' => self::getConfig(self::DISPLAY_GRID_FLAG, 0), - ]; - - $form['display-mode'][self::DISPLAY_DEFAULT] = [ - '#type' => 'select', - '#title' => $this - ->t('Default display mode:'), - '#options' => [ - 'list' => 'List', - 'grid' => 'Grid' - ], - '#default_value' => self::getConfig(self::DISPLAY_DEFAULT, 'grid'), - ]; - - $form['edismax'] = [ - '#type' => 'fieldset', - '#title' => $this->t("Extended DisMax Query"), - ]; - - $form['edismax'][self::EDISMAX_SEARCH_FLAG] = [ - '#type' => 'checkbox', - '#title' => $this - ->t('Enable Extended DisMax Query.'), - '#description' => $this->t('If enabled, this applies to all fields searching in the Advanced Search Block.'), - '#default_value' => self::getConfig(self::EDISMAX_SEARCH_FLAG, 1), - ]; - - $form['edismax']['textfields_container'] = [ - '#type' => 'container', - '#attributes' => ['id' => 'edismax-container'], - ]; - - $form['edismax']['textfields_container'][self::SEARCH_ALL_FIELDS_FLAG] = [ - '#type' => 'checkbox', - '#title' => $this - ->t('Enable searching all fields'), - '#description' => $this->t('This will add an additional option (which label can be configured below) in Advanced Search block.'), - '#default_value' => self::getConfig(self::SEARCH_ALL_FIELDS_FLAG, 0), - ]; - $form['edismax']['textfields_container'][self::EDISMAX_SEARCH_LABEL] = [ - '#type' => 'textfield', - '#title' => $this->t('If enabled, set the label for the option of searching all fields'), - '#description' => $this->t('This will apply for the additional option above in Advanced Search block.'), - '#default_value' => self::getConfig(self::EDISMAX_SEARCH_LABEL, "All"), - ]; return parent::buildForm($form, $form_state); } diff --git a/src/Plugin/Block/SearchBlock.php b/src/Plugin/Block/SearchBlock.php index c56377e..0aa9b4d 100644 --- a/src/Plugin/Block/SearchBlock.php +++ b/src/Plugin/Block/SearchBlock.php @@ -38,7 +38,7 @@ class SearchBlock extends BlockBase { $form['search-attributes'][SettingsForm::SEARCH_ALL_FIELDS_FLAG] = [ '#markup' => $this ->t('This block is required to enable searching all fields for the Advanced Search. - To proceed, please enable the Search All fields in + To proceed, please enable "Enable searching all fields" in Advanced Seach Configuration.'), ]; }