Merge pull request #32 from digitalutsc/1.x
Run the code though phpstan, phpcs
This commit is contained in:
commit
094342c05a
14 changed files with 202 additions and 180 deletions
|
|
@ -40,7 +40,8 @@ function advanced_search_theme() {
|
||||||
function advanced_search_library_info_alter(&$libraries, $extension) {
|
function advanced_search_library_info_alter(&$libraries, $extension) {
|
||||||
if ($extension == 'facets') {
|
if ($extension == 'facets') {
|
||||||
// Override facets module javascript with customizations.
|
// Override facets module javascript with customizations.
|
||||||
$path = '/' . drupal_get_path('module', 'advanced_search') . '/js/facets';
|
// https://www.drupal.org/node/2940438
|
||||||
|
$path = '/' . \Drupal::service('extension.list.module')->getPath('advanced_search') . '/js/facets';
|
||||||
$libraries['soft-limit']['js'] = [
|
$libraries['soft-limit']['js'] = [
|
||||||
"$path/soft-limit.js" => [],
|
"$path/soft-limit.js" => [],
|
||||||
];
|
];
|
||||||
|
|
@ -81,7 +82,7 @@ function advanced_search_form_block_form_alter(&$form, FormStateInterface $form_
|
||||||
|
|
||||||
/** @var \Drupal\Core\Condition\ConditionInterface $condition */
|
/** @var \Drupal\Core\Condition\ConditionInterface $condition */
|
||||||
if (array_key_exists($condition_id, $visibility)) {
|
if (array_key_exists($condition_id, $visibility)) {
|
||||||
$condition = $manager->createInstance($condition_id, isset($visibility[$condition_id]) ? $visibility[$condition_id] : []);
|
$condition = $manager->createInstance($condition_id, $visibility[$condition_id] ?? []);
|
||||||
$form_state->set(['conditions', $condition_id], $condition);
|
$form_state->set(['conditions', $condition_id], $condition);
|
||||||
$condition_form = $condition->buildConfigurationForm([], $form_state);
|
$condition_form = $condition->buildConfigurationForm([], $form_state);
|
||||||
$condition_form['#type'] = 'details';
|
$condition_form['#type'] = 'details';
|
||||||
|
|
|
||||||
|
|
@ -155,5 +155,3 @@
|
||||||
grid-template-columns: repeat(1, 1fr);
|
grid-template-columns: repeat(1, 1fr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -150,15 +150,15 @@ class AdvancedSearchQuery {
|
||||||
$language_ids = $search_api_query->getLanguages();
|
$language_ids = $search_api_query->getLanguages();
|
||||||
$field_mapping = $backend->getSolrFieldNamesKeyedByLanguage($language_ids, $index);
|
$field_mapping = $backend->getSolrFieldNamesKeyedByLanguage($language_ids, $index);
|
||||||
|
|
||||||
// disable for Lucene and wildcard
|
// Disable for Lucene and wildcard
|
||||||
// $q[] = "{!boost b=boost_document}";
|
// $q[] = "{!boost b=boost_document}";
|
||||||
|
// Create a flag for active/inactive dismax.
|
||||||
// create a flag for active/inactive dismax
|
|
||||||
$config = \Drupal::config(SettingsForm::CONFIG_NAME);
|
$config = \Drupal::config(SettingsForm::CONFIG_NAME);
|
||||||
$isDismax = $config->get(SettingsForm::EDISMAX_SEARCH_FLAG);
|
$isDismax = $config->get(SettingsForm::EDISMAX_SEARCH_FLAG);
|
||||||
if (!isset($isDismax))
|
if (!isset($isDismax)) {
|
||||||
$isDismax = true;
|
$isDismax = TRUE;
|
||||||
$isSearchAllFields = false;
|
}
|
||||||
|
$isSearchAllFields = FALSE;
|
||||||
$fields_list = [];
|
$fields_list = [];
|
||||||
|
|
||||||
if (!$isDismax) {
|
if (!$isDismax) {
|
||||||
|
|
@ -169,47 +169,50 @@ class AdvancedSearchQuery {
|
||||||
$term = array_shift($terms);
|
$term = array_shift($terms);
|
||||||
$q[] = $term->toSolrQuery($field_mapping);
|
$q[] = $term->toSolrQuery($field_mapping);
|
||||||
|
|
||||||
// new
|
// New.
|
||||||
$fields_list[] = $term->toSolrFields($field_mapping);
|
$fields_list[] = $term->toSolrFields($field_mapping);
|
||||||
|
|
||||||
// set edismax is enabled if the field set to "all"
|
// Set edismax is enabled if the field set to "all".
|
||||||
if ($term->getField() === "all") {
|
if ($term->getField() === "all") {
|
||||||
$isSearchAllFields = true;
|
$isSearchAllFields = TRUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// for multiple conditions
|
// For multiple conditions.
|
||||||
foreach ($terms as $term) {
|
foreach ($terms as $term) {
|
||||||
$q[] = $term->getConjunction();
|
$q[] = $term->getConjunction();
|
||||||
$q[] = $term->toSolrQuery($field_mapping);
|
$q[] = $term->toSolrQuery($field_mapping);
|
||||||
|
|
||||||
// new
|
// New.
|
||||||
$fields_list[] = $term->toSolrFields($field_mapping);
|
$fields_list[] = $term->toSolrFields($field_mapping);
|
||||||
|
|
||||||
// set dismax is enabled if the field set to "all"
|
// Set dismax is enabled if the field set to "all".
|
||||||
if ($term->getField() === "all") {
|
if ($term->getField() === "all") {
|
||||||
$isSearchAllFields = true;
|
$isSearchAllFields = TRUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$q = implode(' ', $q);
|
$q = implode(' ', $q);
|
||||||
|
|
||||||
|
// Limit extra processing if Luncene Search is enable.
|
||||||
// Limit extra processing if Luncene Search is enable
|
|
||||||
if ($isDismax) {
|
if ($isDismax) {
|
||||||
|
|
||||||
if ((strpos($q, "*") !== false || strpos($q, "?") !== false)) {
|
if ((strpos($q, "*") !== FALSE || strpos($q, "?") !== FALSE)) {
|
||||||
// if the query string contain '*', '?', OR is a single world, enable wildcard
|
// If the query string contain '*','?',a single world,enable wildcard.
|
||||||
$tmp = str_replace('"', "", trim($q));
|
$tmp = str_replace('"', "", trim($q));
|
||||||
$query_fields = [];
|
$query_fields = [];
|
||||||
|
|
||||||
if ($isSearchAllFields) {
|
if ($isSearchAllFields) {
|
||||||
foreach ($field_mapping as $key => $field) {
|
foreach ($field_mapping as $key => $field) {
|
||||||
foreach ($field as $f => $item) {
|
foreach ($field as $f => $item) {
|
||||||
// bs_ are boolean fields, do not work well with text search
|
// bs_ are boolean fields, do not work well with text search.
|
||||||
if (substr($item, 0, 3) !== "bs_" && !in_array($item, ['score', 'random', 'boost_document'])
|
if (substr($item, 0, 3) !== "bs_"
|
||||||
&& ((strpos( $item, "sm_" ) === 0) || (strpos( $item, "tm_" ) === 0) || (strpos($item, "sort_ss_") === 0) || (strpos($item, "ts_") === 0)
|
&& !in_array($item, ['score', 'random', 'boost_document'])
|
||||||
|
&& ((strpos($item, "sm_") === 0)
|
||||||
|
|| (strpos($item, "tm_") === 0)
|
||||||
|
|| (strpos($item, "sort_ss_") === 0)
|
||||||
|
|| (strpos($item, "ts_") === 0)
|
||||||
|| (strpos($item, "ss_") === 0)
|
|| (strpos($item, "ss_") === 0)
|
||||||
)) {
|
)) {
|
||||||
array_push($query_fields, '(' . $item . ':' . $tmp . ')');
|
array_push($query_fields, '(' . $item . ':' . $tmp . ')');
|
||||||
|
|
@ -229,7 +232,7 @@ class AdvancedSearchQuery {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// enable dismax search query option
|
// Enable dismax search query option.
|
||||||
/** @var Solarium\QueryType\Select\Query\Component\DisMax $dismax */
|
/** @var Solarium\QueryType\Select\Query\Component\DisMax $dismax */
|
||||||
$dismax = $solarium_query->getEDisMax();
|
$dismax = $solarium_query->getEDisMax();
|
||||||
$dismax->setQueryParser('edismax');
|
$dismax->setQueryParser('edismax');
|
||||||
|
|
@ -238,7 +241,7 @@ class AdvancedSearchQuery {
|
||||||
if ($isSearchAllFields) {
|
if ($isSearchAllFields) {
|
||||||
foreach ($field_mapping as $key => $field) {
|
foreach ($field_mapping as $key => $field) {
|
||||||
foreach ($field as $f => $item) {
|
foreach ($field as $f => $item) {
|
||||||
// bs_ are boolean fields, do not work well with text search
|
// bs_ are boolean fields, do not work well with text search.
|
||||||
if (substr($item, 0, 3) !== "bs_") {
|
if (substr($item, 0, 3) !== "bs_") {
|
||||||
array_push($query_fields, $item);
|
array_push($query_fields, $item);
|
||||||
}
|
}
|
||||||
|
|
@ -371,9 +374,9 @@ class AdvancedSearchQuery {
|
||||||
/**
|
/**
|
||||||
* Sets the highlighting parameters.
|
* Sets the highlighting parameters.
|
||||||
*
|
*
|
||||||
* @param \Solarium\QueryType\Select\Query\Query $solarium_query
|
* @param \Solarium\Core\Query\QueryInterface $solarium_query
|
||||||
* The Solarium select query object.
|
* The Solarium select query object.
|
||||||
* @param \Drupal\search_api\Query\QueryInterface $query
|
* @param \Drupal\search_api\Query\QueryInterface $search_api_query
|
||||||
* The query object.
|
* The query object.
|
||||||
* @param array $highlighted_fields
|
* @param array $highlighted_fields
|
||||||
* (optional) The solr fields to be highlighted.
|
* (optional) The solr fields to be highlighted.
|
||||||
|
|
@ -424,4 +427,5 @@ class AdvancedSearchQuery {
|
||||||
$hl->addField($highlighted_field);
|
$hl->addField($highlighted_field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ namespace Drupal\advanced_search;
|
||||||
|
|
||||||
use Drupal\advanced_search\Form\AdvancedSearchForm;
|
use Drupal\advanced_search\Form\AdvancedSearchForm;
|
||||||
use Drupal\advanced_search\Form\SettingsForm;
|
use Drupal\advanced_search\Form\SettingsForm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a single search term.
|
* Defines a single search term.
|
||||||
*
|
*
|
||||||
|
|
@ -288,14 +289,14 @@ class AdvancedSearchQueryTerm {
|
||||||
$config = \Drupal::config(SettingsForm::CONFIG_NAME);
|
$config = \Drupal::config(SettingsForm::CONFIG_NAME);
|
||||||
$isDismax = $config->get(SettingsForm::EDISMAX_SEARCH_FLAG);
|
$isDismax = $config->get(SettingsForm::EDISMAX_SEARCH_FLAG);
|
||||||
if (!isset($isDismax)) {
|
if (!isset($isDismax)) {
|
||||||
$isDismax = true;
|
$isDismax = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($isDismax || $this->field === "all") {
|
if ($isDismax || $this->field === "all") {
|
||||||
|
|
||||||
// Case 1: if keyword contains one word or a phrase
|
// Case 1: if keyword contains one word or a phrase.
|
||||||
if(strpos(trim($value), ' ') !== false) {
|
if (strpos(trim($value), ' ') !== FALSE) {
|
||||||
// add Or for the search case "scarborough bulletin" show no results
|
// Add Or for the search case "scarborough bulletin" show no results.
|
||||||
$isNot = $this->getInclude() ? "" : "-";
|
$isNot = $this->getInclude() ? "" : "-";
|
||||||
if (substr_count($value, '\"') == 2) {
|
if (substr_count($value, '\"') == 2) {
|
||||||
$value = str_replace('\"', "", trim($value));
|
$value = str_replace('\"', "", trim($value));
|
||||||
|
|
@ -310,38 +311,37 @@ class AdvancedSearchQueryTerm {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Case 2: keywords is one word
|
// Case 2: keywords is one word
|
||||||
// if there is quotation (with backslash) surrounded,
|
// if there is quotation (with backslash) surrounded,.
|
||||||
if (strpos(trim($value), '\"' ) !== false) {
|
if (strpos(trim($value), '\"') !== FALSE) {
|
||||||
$value = str_replace('\"', "", trim($value));
|
$value = str_replace('\"', "", trim($value));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// if there is quotation (without backslash) surrounded
|
// If there is quotation (without backslash) surrounded.
|
||||||
$value = str_replace('"', "", trim($value));
|
$value = str_replace('"', "", trim($value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$isTitleSearch = false;
|
$isTitleSearch = FALSE;
|
||||||
foreach ($solr_field_mapping[$this->field] as $field) {
|
foreach ($solr_field_mapping[$this->field] as $field) {
|
||||||
// if field fulltext title is selected
|
// If field fulltext title is selected.
|
||||||
if (strpos($field, "fulltext_title") !== false) {
|
if (strpos($field, "fulltext_title") !== FALSE) {
|
||||||
$isTitleSearch = true;
|
$isTitleSearch = TRUE;
|
||||||
if (strpos(trim($value), " AND " ) !== false) {
|
if (strpos(trim($value), " AND ") !== FALSE) {
|
||||||
//When you type 'Orientation AND games' into the title search, you get one result.
|
// Handle keyword with 'Orientation AND games'.
|
||||||
// When you do the same search but add a search box, you get a lot more results.
|
|
||||||
// (Recreation: Add a search box, set both search criteria to 'Title' and keep the operator to 'and'.
|
|
||||||
// Type 'orientation' in one box and 'games' in the second box and click seach.)
|
|
||||||
$keyword = str_replace('"', '', $value);
|
$keyword = str_replace('"', '', $value);
|
||||||
$keys = explode(" AND ", $keyword);
|
$keys = explode(" AND ", $keyword);
|
||||||
$str = "(";
|
$str = "(";
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
|
|
||||||
if ($i != count($keys)-1)
|
if ($i != count($keys) - 1) {
|
||||||
$str .= $field . ':"' . $key . '" AND ';
|
$str .= $field . ':"' . $key . '" AND ';
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
$str .= $field . ':"' . $key . '")';
|
$str .= $field . ':"' . $key . '")';
|
||||||
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$terms[] = $str;
|
$terms[] = $str;
|
||||||
|
|
@ -366,7 +366,6 @@ class AdvancedSearchQueryTerm {
|
||||||
return $this->include ? "($terms)" : "-($terms)";
|
return $this->include ? "($terms)" : "-($terms)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Using the provided field mapping create a Solr Fields string.
|
* Using the provided field mapping create a Solr Fields string.
|
||||||
*
|
*
|
||||||
|
|
@ -390,11 +389,10 @@ class AdvancedSearchQueryTerm {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Field search
|
* Get Field search.
|
||||||
*/
|
*/
|
||||||
public function getField() {
|
public function getField() {
|
||||||
return $this->field;
|
return $this->field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ class AjaxBlocksController extends ControllerBase {
|
||||||
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
|
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
|
||||||
* The drupal container.
|
* The drupal container.
|
||||||
*/
|
*/
|
||||||
public function __construct(RendererInterface $renderer, CurrentPathStack $currentPath, RouterInterface $router, PathProcessorManager $pathProcessor, CurrentRouteMatch $currentRouteMatch, ContainerInterface $container) {
|
final public function __construct(RendererInterface $renderer, CurrentPathStack $currentPath, RouterInterface $router, PathProcessorManager $pathProcessor, CurrentRouteMatch $currentRouteMatch, ContainerInterface $container) {
|
||||||
$this->storage = $this->entityTypeManager()->getStorage('block');
|
$this->storage = $this->entityTypeManager()->getStorage('block');
|
||||||
$this->renderer = $renderer;
|
$this->renderer = $renderer;
|
||||||
$this->currentPath = $currentPath;
|
$this->currentPath = $currentPath;
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ class AdvancedSearchForm extends FormBase {
|
||||||
/**
|
/**
|
||||||
* Class constructor.
|
* Class constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(Request $request, RouteMatchInterface $current_route_match) {
|
final public function __construct(Request $request, RouteMatchInterface $current_route_match) {
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
$this->currentRouteMatch = $current_route_match;
|
$this->currentRouteMatch = $current_route_match;
|
||||||
}
|
}
|
||||||
|
|
@ -104,20 +104,20 @@ class AdvancedSearchForm extends FormBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get if Edismax Search checkbox is enabled or disable
|
* Get if Search All Fields checkbox is enabled or disable.
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*
|
*
|
||||||
|
* @return bool
|
||||||
|
* the enable or disable for Search All Fields checkbox
|
||||||
*/
|
*/
|
||||||
public static function getSearchAllFields() {
|
public static function getSearchAllFields() {
|
||||||
return self::getConfig(SettingsForm::SEARCH_ALL_FIELDS_FLAG, 0);
|
return self::getConfig(SettingsForm::SEARCH_ALL_FIELDS_FLAG, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get if Edismax Search checkbox is enabled or disable
|
* Get if Edismax Search checkbox is enabled or disable.
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*
|
*
|
||||||
|
* @return bool
|
||||||
|
* the enable or disable for Edismax Search checkbox
|
||||||
*/
|
*/
|
||||||
public static function getEdismaxSearch() {
|
public static function getEdismaxSearch() {
|
||||||
return self::getConfig(SettingsForm::EDISMAX_SEARCH_FLAG, 0);
|
return self::getConfig(SettingsForm::EDISMAX_SEARCH_FLAG, 0);
|
||||||
|
|
@ -185,7 +185,7 @@ class AdvancedSearchForm extends FormBase {
|
||||||
*/
|
*/
|
||||||
protected function processInput(FormStateInterface $form_state, array $term_default_values) {
|
protected function processInput(FormStateInterface $form_state, array $term_default_values) {
|
||||||
$input = $form_state->getUserInput();
|
$input = $form_state->getUserInput();
|
||||||
$recursive = isset($input['recursive']) ? $input['recursive'] : NULL;
|
$recursive = $input['recursive'] ?? NULL;
|
||||||
$term_values = isset($input['terms']) && is_array($input['terms']) ? $input['terms'] : [];
|
$term_values = isset($input['terms']) && is_array($input['terms']) ? $input['terms'] : [];
|
||||||
// Form was not submitted see if we can rebuild from query parameters.
|
// Form was not submitted see if we can rebuild from query parameters.
|
||||||
$advanced_search_query = new AdvancedSearchQuery();
|
$advanced_search_query = new AdvancedSearchQuery();
|
||||||
|
|
@ -273,9 +273,9 @@ class AdvancedSearchForm extends FormBase {
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$options = (self::getEdismaxSearch() && self::getSearchAllFields()) ? ["all" => $this->t(self::getEdismaxSearchLabel())] + $this->fieldOptions($fields) : $this->fieldOptions($fields);
|
$options = (self::getEdismaxSearch() && self::getSearchAllFields()) ? ["all" => $this->t("@label", ["@label" => self::getEdismaxSearchLabel()])] + $this->fieldOptions($fields) : $this->fieldOptions($fields);
|
||||||
$term_default_values = $this->defaultTermValues($options);
|
$term_default_values = $this->defaultTermValues($options);
|
||||||
list($recursive, $term_values) = $this->processInput($form_state, $term_default_values);
|
[$recursive, $term_values] = $this->processInput($form_state, $term_default_values);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$term_elements = [];
|
$term_elements = [];
|
||||||
$total_terms = count($term_values);
|
$total_terms = count($term_values);
|
||||||
|
|
@ -284,20 +284,20 @@ class AdvancedSearchForm extends FormBase {
|
||||||
// Either specified by the user in the request or use the default.
|
// Either specified by the user in the request or use the default.
|
||||||
$first = $i == 0;
|
$first = $i == 0;
|
||||||
$term_value = !empty($term_values) ? array_shift($term_values) : $term_default_values;
|
$term_value = !empty($term_values) ? array_shift($term_values) : $term_default_values;
|
||||||
$conjunction = isset($term_value[self::CONJUNCTION_FORM_FIELD]) ? $term_value[self::CONJUNCTION_FORM_FIELD] : $term_default_values[self::CONJUNCTION_FORM_FIELD];
|
$conjunction = $term_value[self::CONJUNCTION_FORM_FIELD] ?? $term_default_values[self::CONJUNCTION_FORM_FIELD];
|
||||||
$term_elements[] = [
|
$term_elements[] = [
|
||||||
// Only show on terms after the first.
|
// Only show on terms after the first.
|
||||||
self::CONJUNCTION_FORM_FIELD => $first ? NULL : [
|
self::CONJUNCTION_FORM_FIELD => $first ? NULL : [
|
||||||
'#type' => 'select',
|
'#type' => 'select',
|
||||||
'#attributes' => [
|
'#attributes' => [
|
||||||
'aria-label' => $this->t("Select search condition")
|
'aria-label' => $this->t("Select search condition"),
|
||||||
],
|
],
|
||||||
'#options' => [
|
'#options' => [
|
||||||
self::AND_OP => $this->t('and'),
|
self::AND_OP => $this->t('and'),
|
||||||
self::OR_OP => $this->t('or'),
|
self::OR_OP => $this->t('or'),
|
||||||
],
|
],
|
||||||
'#default_value' => $conjunction,
|
'#default_value' => $conjunction,
|
||||||
'#theme_wrappers' => []
|
'#theme_wrappers' => [],
|
||||||
],
|
],
|
||||||
self::SEARCH_FORM_FIELD => [
|
self::SEARCH_FORM_FIELD => [
|
||||||
'#type' => 'select',
|
'#type' => 'select',
|
||||||
|
|
@ -306,7 +306,7 @@ class AdvancedSearchForm extends FormBase {
|
||||||
],
|
],
|
||||||
'#options' => $options,
|
'#options' => $options,
|
||||||
'#default_value' => $term_value[self::SEARCH_FORM_FIELD],
|
'#default_value' => $term_value[self::SEARCH_FORM_FIELD],
|
||||||
'#theme_wrappers' => []
|
'#theme_wrappers' => [],
|
||||||
],
|
],
|
||||||
self::INCLUDE_FORM_FIELD => [
|
self::INCLUDE_FORM_FIELD => [
|
||||||
'#type' => 'select',
|
'#type' => 'select',
|
||||||
|
|
@ -325,7 +325,7 @@ class AdvancedSearchForm extends FormBase {
|
||||||
':input[name="terms[' . $i . '][' . self::CONJUNCTION_FORM_FIELD . ']"]' => ['value' => self::AND_OP],
|
':input[name="terms[' . $i . '][' . self::CONJUNCTION_FORM_FIELD . ']"]' => ['value' => self::AND_OP],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'#theme_wrappers' => []
|
'#theme_wrappers' => [],
|
||||||
],
|
],
|
||||||
// Just markup to show when 'include' is not alterable due to the
|
// Just markup to show when 'include' is not alterable due to the
|
||||||
// selected 'conjunction'. Hide for the first term.
|
// selected 'conjunction'. Hide for the first term.
|
||||||
|
|
@ -340,15 +340,15 @@ class AdvancedSearchForm extends FormBase {
|
||||||
/*'content' => [
|
/*'content' => [
|
||||||
'#markup' => $this->t('is'),
|
'#markup' => $this->t('is'),
|
||||||
],*/
|
],*/
|
||||||
'#theme_wrappers' => []
|
'#theme_wrappers' => [],
|
||||||
],
|
],
|
||||||
self::VALUE_FORM_FIELD => [
|
self::VALUE_FORM_FIELD => [
|
||||||
'#type' => 'textfield',
|
'#type' => 'textfield',
|
||||||
'#attributes' => [
|
'#attributes' => [
|
||||||
'aria-label' => $this->t("Enter a search term")
|
'aria-label' => $this->t("Enter a search term"),
|
||||||
],
|
],
|
||||||
'#default_value' => $term_value[self::VALUE_FORM_FIELD],
|
'#default_value' => $term_value[self::VALUE_FORM_FIELD],
|
||||||
'#theme_wrappers' => []
|
'#theme_wrappers' => [],
|
||||||
],
|
],
|
||||||
'actions' => [
|
'actions' => [
|
||||||
'#type' => 'container',
|
'#type' => 'container',
|
||||||
|
|
@ -440,7 +440,7 @@ class AdvancedSearchForm extends FormBase {
|
||||||
$terms[] = AdvancedSearchQueryTerm::fromUserInput($term);
|
$terms[] = AdvancedSearchQueryTerm::fromUserInput($term);
|
||||||
}
|
}
|
||||||
$terms = array_filter($terms);
|
$terms = array_filter($terms);
|
||||||
$recurse = filter_var(isset($values['recursive']) ? $values['recursive'] : FALSE, FILTER_VALIDATE_BOOLEAN);
|
$recurse = filter_var($values['recursive'] ?? FALSE, FILTER_VALIDATE_BOOLEAN);
|
||||||
$route = $this->getRouteName($form_state);
|
$route = $this->getRouteName($form_state);
|
||||||
$advanced_search_query = new AdvancedSearchQuery();
|
$advanced_search_query = new AdvancedSearchQuery();
|
||||||
return $advanced_search_query->toUrl($this->request, $terms, $recurse, $route);
|
return $advanced_search_query->toUrl($this->request, $terms, $recurse, $route);
|
||||||
|
|
|
||||||
|
|
@ -2,50 +2,64 @@
|
||||||
|
|
||||||
namespace Drupal\advanced_search\Form;
|
namespace Drupal\advanced_search\Form;
|
||||||
|
|
||||||
|
use Drupal\block\Entity\Block;
|
||||||
use Drupal\Core\Form\FormBase;
|
use Drupal\Core\Form\FormBase;
|
||||||
use Drupal\Core\Form\FormStateInterface;
|
use Drupal\Core\Form\FormStateInterface;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Drupal\Core\Url;
|
||||||
use \Drupal\Core\Url;
|
|
||||||
|
|
||||||
class SearchForm extends FormBase
|
|
||||||
{
|
|
||||||
protected $block_id;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $block_id
|
* Form for building and Simple Search.
|
||||||
|
*/
|
||||||
|
class SearchForm extends FormBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Block ID.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $blockId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constructor.
|
||||||
|
*
|
||||||
|
* @param string $block_id
|
||||||
|
* Passing the block_id.
|
||||||
*/
|
*/
|
||||||
public function __construct($block_id) {
|
public function __construct($block_id) {
|
||||||
$this->block_id = $block_id;
|
$this->blockId = $block_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get Block Id.
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* Return the Block ID
|
||||||
*/
|
*/
|
||||||
public function getBlockId() {
|
public function getBlockId() {
|
||||||
return $this->block_id;
|
return $this->blockId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $block_id
|
* Set Block ID.
|
||||||
|
*
|
||||||
|
* @param mixed $blockId
|
||||||
|
* Set the block ID.
|
||||||
*/
|
*/
|
||||||
public function setBlockId($block_id): void {
|
public function setBlockId($blockId): void {
|
||||||
$this->block_id = $block_id;
|
$this->blockId = $blockId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getFormId()
|
public function getFormId() {
|
||||||
{
|
|
||||||
return 'search_form';
|
return 'search_form';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function buildForm(array $form, FormStateInterface $form_state)
|
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||||
{
|
|
||||||
$config = \Drupal::config(SettingsForm::CONFIG_NAME);
|
$config = \Drupal::config(SettingsForm::CONFIG_NAME);
|
||||||
|
|
||||||
if (!$config->get(SettingsForm::SEARCH_ALL_FIELDS_FLAG)) {
|
if (!$config->get(SettingsForm::SEARCH_ALL_FIELDS_FLAG)) {
|
||||||
|
|
@ -57,29 +71,29 @@ class SearchForm extends FormBase
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$block = \Drupal\block\Entity\Block::load($this->block_id);
|
$block = Block::load($this->blockId);
|
||||||
|
|
||||||
if ($block) {
|
if ($block) {
|
||||||
$settings = $block->get('settings');
|
$settings = $block->get('settings');
|
||||||
$view_machine_name = $settings['search_view_machine_name'];
|
$view_machine_name = $settings['search_view_machine_name'];
|
||||||
|
|
||||||
}
|
}
|
||||||
$form['search-textfield'] = array(
|
$form['search-textfield'] = [
|
||||||
'#type' => 'textfield',
|
'#type' => 'textfield',
|
||||||
'#title' => (!empty($settings['search_textfield_label']) ? $settings['search_textfield_label'] : ''),
|
'#title' => (!empty($settings['search_textfield_label']) ? $settings['search_textfield_label'] : ''),
|
||||||
'#attributes' => [
|
'#attributes' => [
|
||||||
'placeholder' => isset($settings['search_placeholder']) ? $this->t($settings['search_placeholder']) : $this->t("Search collections"),
|
'placeholder' => isset($settings['search_placeholder']) ? $this->t("@placeholder", ["@placeholder" => $settings['search_placeholder']]) : $this->t("Search collections"),
|
||||||
'aria-label' => (isset($settings['search_textfield_label']) ? $this->t($settings['search_textfield_label']) : $this->t('Enter Keyword'))
|
'aria-label' => (isset($settings['search_textfield_label']) ? $this->t("@label", ["@label" => $settings['search_textfield_label']]) : $this->t('Enter Keyword')),
|
||||||
],
|
],
|
||||||
'#theme_wrappers' => []
|
'#theme_wrappers' => [],
|
||||||
);
|
];
|
||||||
|
|
||||||
$form['actions']['#type'] = 'actions';
|
$form['actions']['#type'] = 'actions';
|
||||||
$form['actions']['submit'] = array(
|
$form['actions']['submit'] = [
|
||||||
'#type' => 'submit',
|
'#type' => 'submit',
|
||||||
'#value' => (!empty($settings['search_submit_label']) ? $settings['search_submit_label'] : 'Search'),
|
'#value' => (!empty($settings['search_submit_label']) ? $settings['search_submit_label'] : 'Search'),
|
||||||
'#button_type' => 'primary',
|
'#button_type' => 'primary',
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
|
|
@ -88,9 +102,8 @@ class SearchForm extends FormBase
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function submitForm(array &$form, FormStateInterface $form_state)
|
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||||
{
|
$block = Block::load($this->blockId);
|
||||||
$block = \Drupal\block\Entity\Block::load($this->block_id);
|
|
||||||
if ($block) {
|
if ($block) {
|
||||||
$settings = $block->get('settings');
|
$settings = $block->get('settings');
|
||||||
$view_machine_name = $settings['search_view_machine_name'];
|
$view_machine_name = $settings['search_view_machine_name'];
|
||||||
|
|
@ -103,4 +116,5 @@ class SearchForm extends FormBase
|
||||||
]);
|
]);
|
||||||
$form_state->setRedirectUrl($url);
|
$form_state->setRedirectUrl($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class SettingsForm extends ConfigFormBase {
|
||||||
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
|
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
|
||||||
* The factory for configuration objects.
|
* The factory for configuration objects.
|
||||||
*/
|
*/
|
||||||
public function __construct(ConfigFactoryInterface $config_factory) {
|
final public function __construct(ConfigFactoryInterface $config_factory) {
|
||||||
$this->setConfigFactory($config_factory);
|
$this->setConfigFactory($config_factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,7 +91,7 @@ class SettingsForm extends ConfigFormBase {
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>'),
|
</ul>'),
|
||||||
'#default_value' => isset($isEDismax) ? $isEDismax : 1,
|
'#default_value' => $isEDismax ?? 1,
|
||||||
];
|
];
|
||||||
|
|
||||||
$form['eDisMax']['textfields_container'] = [
|
$form['eDisMax']['textfields_container'] = [
|
||||||
|
|
@ -116,7 +116,6 @@ class SettingsForm extends ConfigFormBase {
|
||||||
'#default_value' => self::getConfig(self::EDISMAX_SEARCH_LABEL, "Keyword"),
|
'#default_value' => self::getConfig(self::EDISMAX_SEARCH_LABEL, "Keyword"),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
$form['display-mode'] = [
|
$form['display-mode'] = [
|
||||||
'#type' => 'fieldset',
|
'#type' => 'fieldset',
|
||||||
'#title' => $this->t("Pager Block"),
|
'#title' => $this->t("Pager Block"),
|
||||||
|
|
@ -145,7 +144,7 @@ class SettingsForm extends ConfigFormBase {
|
||||||
->t('Default view mode:'),
|
->t('Default view mode:'),
|
||||||
'#options' => [
|
'#options' => [
|
||||||
'list' => 'List',
|
'list' => 'List',
|
||||||
'grid' => 'Grid'
|
'grid' => 'Grid',
|
||||||
],
|
],
|
||||||
'#default_value' => self::getConfig(self::DISPLAY_DEFAULT, 'grid'),
|
'#default_value' => self::getConfig(self::DISPLAY_DEFAULT, 'grid'),
|
||||||
];
|
];
|
||||||
|
|
@ -192,7 +191,6 @@ class SettingsForm extends ConfigFormBase {
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
return parent::buildForm($form, $form_state);
|
return parent::buildForm($form, $form_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,10 +88,10 @@ class AdvancedSearchBlock extends BlockBase implements ContainerFactoryPluginInt
|
||||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||||
* A request object for the current request.
|
* A request object for the current request.
|
||||||
*/
|
*/
|
||||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, DisplayPluginManager $display_plugin_manager, FormBuilderInterface $form_builder, Request $request) {
|
final public function __construct(array $configuration, $plugin_id, $plugin_definition, DisplayPluginManager $display_plugin_manager, FormBuilderInterface $form_builder, Request $request) {
|
||||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||||
$this->displayPluginManager = $display_plugin_manager;
|
$this->displayPluginManager = $display_plugin_manager;
|
||||||
list($view_id, $display_id) = preg_split('/__/', $this->getDerivativeId(), 2);
|
[$view_id, $display_id] = preg_split('/__/', $this->getDerivativeId(), 2);
|
||||||
$this->view = View::Load($view_id);
|
$this->view = View::Load($view_id);
|
||||||
$this->display = $this->view->getDisplay($display_id);
|
$this->display = $this->view->getDisplay($display_id);
|
||||||
$this->formBuilder = $form_builder;
|
$this->formBuilder = $form_builder;
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,11 @@ abstract class SearchApiDisplayBlockDeriver implements ContainerDeriverInterface
|
||||||
*/
|
*/
|
||||||
abstract protected function label();
|
abstract protected function label();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constructor.
|
||||||
|
*/
|
||||||
|
final public function __construct(ContainerInterface $container, $base_plugin_id) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
@ -55,7 +60,7 @@ abstract class SearchApiDisplayBlockDeriver implements ContainerDeriverInterface
|
||||||
*/
|
*/
|
||||||
public function getDerivativeDefinition($derivative_id, $base_plugin_definition) {
|
public function getDerivativeDefinition($derivative_id, $base_plugin_definition) {
|
||||||
$derivatives = $this->getDerivativeDefinitions($base_plugin_definition);
|
$derivatives = $this->getDerivativeDefinitions($base_plugin_definition);
|
||||||
return isset($derivatives[$derivative_id]) ? $derivatives[$derivative_id] : NULL;
|
return $derivatives[$derivative_id] ?? NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Drupal\advanced_search\Plugin\Block;
|
namespace Drupal\advanced_search\Plugin\Block;
|
||||||
|
|
||||||
|
use Drupal\advanced_search\Form\SearchForm;
|
||||||
use Drupal\Core\Block\BlockBase;
|
use Drupal\Core\Block\BlockBase;
|
||||||
use Drupal\Core\Form\FormStateInterface;
|
use Drupal\Core\Form\FormStateInterface;
|
||||||
use Drupal\advanced_search\Form\SettingsForm;
|
use Drupal\advanced_search\Form\SettingsForm;
|
||||||
|
|
@ -20,8 +21,7 @@ class SearchBlock extends BlockBase {
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function defaultConfiguration() {
|
public function defaultConfiguration() {
|
||||||
return [
|
return [] + parent::defaultConfiguration();
|
||||||
] + parent::defaultConfiguration();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -55,19 +55,19 @@ class SearchBlock extends BlockBase {
|
||||||
}
|
}
|
||||||
$form['search-attributes']['view_machine_name'] = [
|
$form['search-attributes']['view_machine_name'] = [
|
||||||
'#type' => 'select',
|
'#type' => 'select',
|
||||||
'#title' => $this->t('Select Search Results Page\'s Machine Name:'),
|
'#title' => $this->t('Select the machine name of Search Results Page:'),
|
||||||
'#default_value' => $this->configuration['search_view_machine_name'],
|
'#default_value' => $this->configuration['search_view_machine_name'],
|
||||||
'#options' => $options
|
'#options' => $options,
|
||||||
];
|
];
|
||||||
$form['search-attributes']['search_textfield'] = [
|
$form['search-attributes']['search_textfield'] = [
|
||||||
'#type' => 'textfield',
|
'#type' => 'textfield',
|
||||||
'#title' => $this->t('Search Keyword Textfield Label:'),
|
'#title' => $this->t('Search Keyword Text field label:'),
|
||||||
'#default_value' => $this->configuration['search_textfield_label'],
|
'#default_value' => $this->configuration['search_textfield_label'],
|
||||||
'#maxlength' => 255,
|
'#maxlength' => 255,
|
||||||
];
|
];
|
||||||
$form['search-attributes']['search_placeholder_textfield'] = [
|
$form['search-attributes']['search_placeholder_textfield'] = [
|
||||||
'#type' => 'textfield',
|
'#type' => 'textfield',
|
||||||
'#title' => $this->t('Search Keyword Textfield Placeholder:'),
|
'#title' => $this->t('Search Keyword text field placeholder:'),
|
||||||
'#default_value' => $this->configuration['search_placeholder'],
|
'#default_value' => $this->configuration['search_placeholder'],
|
||||||
'#maxlength' => 255,
|
'#maxlength' => 255,
|
||||||
];
|
];
|
||||||
|
|
@ -100,7 +100,7 @@ class SearchBlock extends BlockBase {
|
||||||
public function build() {
|
public function build() {
|
||||||
$config = $this->getConfiguration();
|
$config = $this->getConfiguration();
|
||||||
$blockId = $config['block_id'];
|
$blockId = $config['block_id'];
|
||||||
$searchForm = new \Drupal\advanced_search\Form\SearchForm($blockId);
|
$searchForm = new SearchForm($blockId);
|
||||||
return \Drupal::formBuilder()->getForm($searchForm);
|
return \Drupal::formBuilder()->getForm($searchForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class SearchResultsPagerBlock extends BlockBase implements ContainerFactoryPlugi
|
||||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||||
* A request object for the current request.
|
* A request object for the current request.
|
||||||
*/
|
*/
|
||||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, Request $request) {
|
final public function __construct(array $configuration, $plugin_id, $plugin_definition, Request $request) {
|
||||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||||
$this->request = clone $request;
|
$this->request = clone $request;
|
||||||
}
|
}
|
||||||
|
|
@ -68,7 +68,7 @@ class SearchResultsPagerBlock extends BlockBase implements ContainerFactoryPlugi
|
||||||
*/
|
*/
|
||||||
public function build() {
|
public function build() {
|
||||||
$id = $this->getDerivativeId();
|
$id = $this->getDerivativeId();
|
||||||
list($view_id, $display_id) = $this->getViewAndDisplayIdentifiers();
|
[$view_id, $display_id] = $this->getViewAndDisplayIdentifiers();
|
||||||
$view = View::Load($view_id);
|
$view = View::Load($view_id);
|
||||||
$view_executable = $view->getExecutable();
|
$view_executable = $view->getExecutable();
|
||||||
$view_executable->setDisplay($display_id);
|
$view_executable->setDisplay($display_id);
|
||||||
|
|
@ -121,7 +121,7 @@ class SearchResultsPagerBlock extends BlockBase implements ContainerFactoryPlugi
|
||||||
protected function buildResultsSummary(ViewExecutable $view_executable) {
|
protected function buildResultsSummary(ViewExecutable $view_executable) {
|
||||||
$current_page = (int) $view_executable->getCurrentPage() + 1;
|
$current_page = (int) $view_executable->getCurrentPage() + 1;
|
||||||
$per_page = (int) $view_executable->getItemsPerPage();
|
$per_page = (int) $view_executable->getItemsPerPage();
|
||||||
$total = isset($view_executable->total_rows) ? $view_executable->total_rows : count($view_executable->result);
|
$total = $view_executable->total_rows ?? count($view_executable->result);
|
||||||
// If there is no result the "start" and "current_record_count" should be
|
// If there is no result the "start" and "current_record_count" should be
|
||||||
// equal to 0. To have the same calculation logic, we use a "start offset"
|
// equal to 0. To have the same calculation logic, we use a "start offset"
|
||||||
// to handle all the cases.
|
// to handle all the cases.
|
||||||
|
|
@ -186,8 +186,10 @@ class SearchResultsPagerBlock extends BlockBase implements ContainerFactoryPlugi
|
||||||
'#url' => $url,
|
'#url' => $url,
|
||||||
'#title' => $items_per_page,
|
'#title' => $items_per_page,
|
||||||
'#attributes' => [
|
'#attributes' => [
|
||||||
'aria-label' => $this->t($items_per_page . " items per page"),
|
'aria-label' => $this->t("@item items per page", ["@item" => $items_per_page]),
|
||||||
'class' => $active ? ['pager__link', 'pager__link--is-active', 'pager__itemsperpage'] : ['pager__link', 'pager__itemsperpage'],
|
'class' => $active ?
|
||||||
|
['pager__link', 'pager__link--is-active', 'pager__itemsperpage'] :
|
||||||
|
['pager__link', 'pager__itemsperpage'],
|
||||||
],
|
],
|
||||||
'#wrapper_attributes' => [
|
'#wrapper_attributes' => [
|
||||||
'class' => $active ? ['pager__item', 'is-active'] : ['pager__item'],
|
'class' => $active ? ['pager__item', 'is-active'] : ['pager__item'],
|
||||||
|
|
@ -227,7 +229,7 @@ class SearchResultsPagerBlock extends BlockBase implements ContainerFactoryPlugi
|
||||||
if ($config->get(SettingsForm::DISPLAY_GRID_FLAG) == 1) {
|
if ($config->get(SettingsForm::DISPLAY_GRID_FLAG) == 1) {
|
||||||
$display_options['grid'] = [
|
$display_options['grid'] = [
|
||||||
'icon' => 'fa-th',
|
'icon' => 'fa-th',
|
||||||
'title' => $this->t('Grid')
|
'title' => $this->t('Grid'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -245,8 +247,10 @@ class SearchResultsPagerBlock extends BlockBase implements ContainerFactoryPlugi
|
||||||
'#url' => $url,
|
'#url' => $url,
|
||||||
'#title' => Markup::create($text),
|
'#title' => Markup::create($text),
|
||||||
'#attributes' => [
|
'#attributes' => [
|
||||||
'class' => $active ? ['pager__link', 'pager__link--is-active', 'pager__display'] : ['pager__link', 'pager__display'],
|
'class' => $active ?
|
||||||
'aria-label' => $this->t("Display as " . Markup::create($text))
|
['pager__link', 'pager__link--is-active', 'pager__display'] :
|
||||||
|
['pager__link', 'pager__display'],
|
||||||
|
'aria-label' => $this->t("Display as @link", ["@link" => Markup::create($text)]),
|
||||||
],
|
],
|
||||||
'#wrapper_attributes' => [
|
'#wrapper_attributes' => [
|
||||||
'class' => $active ? ['pager__item', 'is-active'] : ['pager__item'],
|
'class' => $active ? ['pager__item', 'is-active'] : ['pager__item'],
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class Utilities {
|
||||||
foreach ($block_storage->loadByProperties(['theme' => $active_theme->getName()]) as $block) {
|
foreach ($block_storage->loadByProperties(['theme' => $active_theme->getName()]) as $block) {
|
||||||
$plugin = $block->getPlugin();
|
$plugin = $block->getPlugin();
|
||||||
if ($plugin instanceof SearchResultsPagerBlock) {
|
if ($plugin instanceof SearchResultsPagerBlock) {
|
||||||
list($view_id, $display_id) = $plugin->getViewAndDisplayIdentifiers();
|
[$view_id, $display_id] = $plugin->getViewAndDisplayIdentifiers();
|
||||||
$views[$block->id()] = [$view_id, $display_id];
|
$views[$block->id()] = [$view_id, $display_id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +52,7 @@ class Utilities {
|
||||||
foreach ($block_storage->loadByProperties(['theme' => $active_theme->getName()]) as $block) {
|
foreach ($block_storage->loadByProperties(['theme' => $active_theme->getName()]) as $block) {
|
||||||
$plugin = $block->getPlugin();
|
$plugin = $block->getPlugin();
|
||||||
if ($plugin instanceof AdvancedSearchBlock) {
|
if ($plugin instanceof AdvancedSearchBlock) {
|
||||||
list($view_id, $display_id) = $plugin->getViewAndDisplayIdentifiers();
|
[$view_id, $display_id] = $plugin->getViewAndDisplayIdentifiers();
|
||||||
$views[$block->id()] = [$view_id, $display_id];
|
$views[$block->id()] = [$view_id, $display_id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue