diff --git a/core/modules/node/config/schema/node.schema.yml b/core/modules/node/config/schema/node.schema.yml index 7105ef6..36c4228 100644 --- a/core/modules/node/config/schema/node.schema.yml +++ b/core/modules/node/config/schema/node.schema.yml @@ -79,17 +79,21 @@ node.settings.node: # Plugin \Drupal\node\Plugin\Search\NodeSearch search.plugin.node_search: type: mapping - label: 'Node search' + label: 'Content search' mapping: - node_rank_comments: - type: integer - label: 'Number of comments' - node_rank_relevance: - type: float - label: 'Keyword relevance' - node_rank_sticky: - type: boolean - label: 'Content is sticky at top of lists' - node_rank_promote: - type: boolean - label: 'Content is promoted to the front page' + rankings: + type: mapping + label: 'Content Ranking' + mapping: + comments: + type: integer + label: 'Number of comments' + relevance: + type: integer + label: 'Keyword relevance' + sticky: + type: integer + label: 'Content is sticky at top of lists' + promote: + type: integer + label: 'Content is promoted to the front page' diff --git a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php index d921881..04cb30b 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php @@ -274,7 +274,7 @@ protected function addNodeRankings(SelectExtender $query) { if ($ranking = $this->getRankings()) { $tables = &$query->getTables(); foreach ($ranking as $rank => $values) { - if ($node_rank = $this->configuration[$rank]) { + if ($node_rank = $this->configuration['rankings'][$rank]) { // If the table defined in the ranking isn't already joined, then add it. if (isset($values['join']) && !isset($tables[$values['join']['alias']])) { $query->addJoin($values['join']['type'], $values['join']['table'], $values['join']['alias'], $values['join']['on']); @@ -528,10 +528,7 @@ public function searchFormSubmit(array &$form, array &$form_state) { */ protected function getRankings() { if (!$this->rankings) { - $this->rankings = array(); - foreach ($this->moduleHandler->invokeAll('ranking') as $var => $value) { - $this->rankings["node_rank_$var"] = $value; - } + $this->rankings = $this->moduleHandler->invokeAll('ranking'); } return $this->rankings; } @@ -540,9 +537,11 @@ protected function getRankings() { * {@inheritdoc} */ public function defaultConfiguration() { - $configuration = array(); + $configuration = array( + 'rankings' => array(), + ); foreach ($this->getRankings() as $var => $value) { - $configuration[$var] = 0; + $configuration['rankings'][$var] = 0; } return $configuration; } @@ -564,11 +563,11 @@ public function buildConfigurationForm(array $form, array &$form_state) { // Note: reversed to reflect that higher number = higher ranking. $options = drupal_map_assoc(range(0, 10)); foreach ($this->getRankings() as $var => $values) { - $form['content_ranking']['factors'][$var] = array( + $form['content_ranking']['factors']['rankings_' . $var] = array( '#title' => $values['title'], '#type' => 'select', '#options' => $options, - '#default_value' => $this->configuration[$var], + '#default_value' => $this->configuration['rankings'][$var], ); } return $form; @@ -579,8 +578,8 @@ public function buildConfigurationForm(array $form, array &$form_state) { */ public function submitConfigurationForm(array &$form, array &$form_state) { foreach ($this->getRankings() as $var => $values) { - if (isset($form_state['values'][$var])) { - $this->configuration[$var] = $form_state['values'][$var]; + if (isset($form_state['values']['rankings_'.$var])) { + $this->configuration['rankings'][$var] = $form_state['values']['rankings_' . $var]; } } }