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 bcbfff8..2dbf35d 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php @@ -549,17 +549,26 @@ public function buildConfigurationForm(array $form, array &$form_state) { '#title' => t('Content ranking'), '#open' => TRUE, ); - $form['content_ranking']['#theme'] = 'node_search_admin'; $form['content_ranking']['info'] = array( '#markup' => '

' . $this->t('Influence is a numeric multiplier used in ordering search results. A higher number means the corresponding factor has more influence on search results; zero means the factor is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') . '

' ); + // Prepare table. + $header = array(t('Factor'), t('Influence')); + $form['content_ranking']['rankings'] = array( + '#type' => 'table', + '#header' => $header, + ); + // Note: reversed to reflect that higher number = higher ranking. $range = range(0, 10); $options = array_combine($range, $range); foreach ($this->getRankings() as $var => $values) { - $form['content_ranking']['factors']["rankings_$var"] = array( - '#title' => $values['title'], + $form['content_ranking']['rankings'][$var]['name'] = array( + '#markup' => $values['title'], + '#type' => 'markup', + ); + $form['content_ranking']['rankings'][$var]['value'] = array( '#type' => 'select', '#options' => $options, '#default_value' => isset($this->configuration['rankings'][$var]) ? $this->configuration['rankings'][$var] : 0, @@ -573,13 +582,12 @@ public function buildConfigurationForm(array $form, array &$form_state) { */ public function submitConfigurationForm(array &$form, array &$form_state) { foreach ($this->getRankings() as $var => $values) { - if (!empty($form_state['values']["rankings_$var"])) { - $this->configuration['rankings'][$var] = $form_state['values']["rankings_$var"]; + if (!empty($form_state['values']['rankings'][$var]['value'])) { + $this->configuration['rankings'][$var] = $form_state['values']['rankings'][$var]['value']; } else { unset($this->configuration['rankings'][$var]); } } } - -} +} \ No newline at end of file diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 564f4c5..34d87e3 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -865,40 +865,6 @@ function node_user_predelete($account) { } /** - * Returns HTML for the content ranking part of the search settings admin page. - * - * @param $variables - * An associative array containing: - * - form: A render element representing the form. - * - * @see node_search_admin() - * @ingroup themeable - */ -function theme_node_search_admin($variables) { - $form = $variables['form']; - - $output = drupal_render($form['info']); - - $header = array(t('Factor'), t('Influence')); - foreach (Element::children($form['factors']) as $key) { - $row = array(); - $row[] = $form['factors'][$key]['#title']; - $form['factors'][$key]['#title_display'] = 'invisible'; - $row[] = drupal_render($form['factors'][$key]); - $rows[] = $row; - } - $table = array( - '#type' => 'table', - '#header' => $header, - '#rows' => $rows, - ); - $output .= drupal_render($table); - - $output .= drupal_render_children($form); - return $output; -} - -/** * Title callback: Displays the node's title. * * @param \Drupal\node\NodeInterface $node