diff --git a/core/includes/common.inc b/core/includes/common.inc
index 77e270b..4163da2 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -2139,8 +2139,8 @@ function _drupal_add_library($library_name, $every_page = NULL) {
* In a situation where tree relationships are present, adding multiple
* subgroups is not necessary, because the table will contain indentations that
* provide enough information about the sibling and parent relationships. See
- * theme_menu_overview_form() for an example creating a table containing parent
- * relationships.
+ * MenuForm::BuildOverviewForm for an example creating a table
+ * containing parent relationships.
*
* @param $element
* A form element to attach the tableDrag behavior to.
@@ -2177,7 +2177,7 @@ function _drupal_add_library($library_name, $every_page = NULL) {
* to FALSE if the column should not be hidden.
* - 'limit': (optional) Limit the maximum amount of parenting in this table.
*
- * @see theme_menu_overview_form()
+ * @see MenuForm::BuildOverviewForm()
*/
function drupal_attach_tabledrag(&$element, array $options) {
// Add default values to elements.
diff --git a/core/includes/file.inc b/core/includes/file.inc
index 8d2ebbe..b38cf14 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -323,7 +323,19 @@ function file_create_url($uri) {
else {
// If this is not a properly formatted stream, then it is a shipped file.
// Therefore, return the urlencoded URI with the base URL prepended.
- return $GLOBALS['base_url'] . '/' . UrlHelper::encodePath($uri);
+ $options = UrlHelper::parse($uri);
+ $path = $GLOBALS['base_url'] . '/' . UrlHelper::encodePath($options['path']);
+ // Append the query.
+ if ($options['query']) {
+ $path .= '?' . UrlHelper::buildQuery($options['query']);
+ }
+
+ // Append fragment.
+ if ($options['fragment']) {
+ $path .= '#' . $options['fragment'];
+ }
+
+ return $path;
}
}
elseif ($scheme == 'http' || $scheme == 'https' || $scheme == 'data') {
diff --git a/core/modules/menu_ui/menu_ui.admin.inc b/core/modules/menu_ui/menu_ui.admin.inc
deleted file mode 100644
index f23093f..0000000
--- a/core/modules/menu_ui/menu_ui.admin.inc
+++ /dev/null
@@ -1,97 +0,0 @@
- t('Enabled'), 'class' => array('checkbox')),
- t('Weight'),
- t('Operations'),
- );
-
- $rows = array();
- foreach (Element::children($form) as $id) {
- if (isset($form[$id]['#item'])) {
- $element = &$form[$id];
-
- // Add special classes to be used for tabledrag.js.
- $element['parent']['#attributes']['class'] = array('menu-parent');
- $element['id']['#attributes']['class'] = array('menu-id');
- $element['weight']['#attributes']['class'] = array('menu-weight');
-
- // Change the parent field to a hidden. This allows any value but hides
- // the field.
- $element['parent']['#type'] = 'hidden';
-
- $indent = array(
- '#theme' => 'indentation',
- '#size' => $element['#item']->depth - 1,
- );
-
- $row = array();
- $row[] = SafeMarkup::set(drupal_render($indent) . drupal_render($element['title']));
- $row[] = array('data' => drupal_render($element['enabled']), 'class' => array('checkbox', 'menu-enabled'));
- $row[] = SafeMarkup::set(drupal_render($element['weight']) . drupal_render($element['parent']) . drupal_render($element['id']));
- $row[] = drupal_render($element['operations']);
-
- $row = array_merge(array('data' => $row), $element['#attributes']);
- $row['class'][] = 'draggable';
- $rows[] = $row;
- }
- }
- $output = '';
- if (empty($rows)) {
- $rows[] = array(array('data' => $form['#empty_text'], 'colspan' => '7'));
- }
-
- $table = array(
- '#type' => 'table',
- '#header' => $header,
- '#rows' => $rows,
- '#attributes' => array(
- 'id' => 'menu-overview',
- ),
- '#tabledrag' => array(
- array(
- 'action' => 'match',
- 'relationship' => 'parent',
- 'group' => 'menu-parent',
- 'subgroup' => 'menu-parent',
- 'source' => 'menu-id',
- 'hidden' => TRUE,
- 'limit' => \Drupal::menuTree()->maxDepth() - 1,
- ),
- array(
- 'action' => 'order',
- 'relationship' => 'sibling',
- 'group' => 'menu-weight',
- ),
- ),
- );
-
- $output .= drupal_render($form['inline_actions']);
- $output .= drupal_render($table);
- $output .= drupal_render_children($form);
- return $output;
-}
diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module
index 1669aea..f0674de 100644
--- a/core/modules/menu_ui/menu_ui.module
+++ b/core/modules/menu_ui/menu_ui.module
@@ -69,20 +69,6 @@ function menu_ui_entity_type_build(array &$entity_types) {
->setLinkTemplate('add-link-form', 'entity.menu.add_link_form');
}
-
-/**
- * Implements hook_theme().
- */
-function menu_ui_theme() {
- return array(
- 'menu_overview_form' => array(
- 'file' => 'menu_ui.admin.inc',
- 'render element' => 'form',
- 'function' => 'theme_menu_overview_form',
- ),
- );
-}
-
/**
* Implements hook_ENTITY_TYPE_insert( for menu entities.
*/
diff --git a/core/modules/menu_ui/src/MenuForm.php b/core/modules/menu_ui/src/MenuForm.php
index d0b904e..110bb5d 100644
--- a/core/modules/menu_ui/src/MenuForm.php
+++ b/core/modules/menu_ui/src/MenuForm.php
@@ -214,13 +214,11 @@ protected function buildOverviewForm(array &$form, FormStateInterface $form_stat
// Ensure that menu_overview_form_submit() knows the parents of this form
// section.
$form['#tree'] = TRUE;
- $form['#theme'] = 'menu_overview_form';
-
if (!$form_state->has('menu_overview_form_parents')) {
$form_state->set('menu_overview_form_parents', []);
}
- $form['#attached']['css'] = array(drupal_get_path('module', 'menu') . '/css/menu.admin.css');
+ $form['#attached']['css'] = array(drupal_get_path('module', 'menu') . '/css/menu_ui.admin.css');
$tree = $this->menuTree->load($this->entity->id(), new MenuTreeParameters());
@@ -242,10 +240,81 @@ protected function buildOverviewForm(array &$form, FormStateInterface $form_stat
};
$delta = max($count($tree), 50);
- $form = array_merge($form, $this->buildOverviewTreeForm($tree, $delta));
+ $form['links'] = array(
+ '#type' => 'table',
+ '#theme' => 'table__menu_overview',
+ '#header' => array(
+ $this->t('Menu link'),
+ array(
+ 'data' => $this->t('Enabled'),
+ 'class' => array('checkbox'),
+ ),
+ $this->t('Weight'),
+ $this->t('Operations'),
+ ),
+ '#attributes' => array(
+ 'id' => 'menu-overview',
+ ),
+ '#tabledrag' => array(
+ array(
+ 'action' => 'match',
+ 'relationship' => 'parent',
+ 'group' => 'menu-parent',
+ 'subgroup' => 'menu-parent',
+ 'source' => 'menu-id',
+ 'hidden' => TRUE,
+ 'limit' => \Drupal::menuTree()->maxDepth() - 1,
+ ),
+ array(
+ 'action' => 'order',
+ 'relationship' => 'sibling',
+ 'group' => 'menu-weight',
+ ),
+ ),
+ );
+
$destination = $this->getUrlGenerator()->getPathFromRoute('entity.menu.edit_form', array('menu' => $this->entity->id()));
$url = $destination = $this->url('entity.menu.add_link_form', array('menu' => $this->entity->id()), array('query' => array('destination' => $destination)));
- $form['#empty_text'] = $this->t('There are no menu links yet. Add link.', array('@url' => $url));
+ $form['links']['#empty'] = $this->t('There are no menu links yet. Add link.', array('@url' => $url));
+ $links = $this->buildOverviewTreeForm($tree, $delta);
+ foreach (Element::children($links) as $id) {
+ if (isset($links[$id]['#item'])) {
+ $element = $links[$id];
+
+ $form['links'][$id]['#item'] = $element['#item'];
+
+ // TableDrag: Mark the table row as draggable.
+ $form['links'][$id]['#attributes'] = $element['#attributes'];
+ $form['links'][$id]['#attributes']['class'][] = 'draggable';
+
+ $form['links'][$id]['#item'] = $element['#item'];
+
+ // TableDrag: Sort the table row according to its existing/configured weight.
+ $form['links'][$id]['#weight'] = $element['#item']->link->getWeight();
+
+ // Add special classes to be used for tabledrag.js.
+ $element['parent']['#attributes']['class'] = array('menu-parent');
+ $element['weight']['#attributes']['class'] = array('menu-weight');
+ $element['id']['#attributes']['class'] = array('menu-id');
+
+ $form['links'][$id]['title'] = array(
+ array(
+ '#theme' => 'indentation',
+ '#size' => $element['#item']->depth - 1,
+ ),
+ $element['title'],
+ );
+ $form['links'][$id]['enabled'] = $element['enabled'];
+ $form['links'][$id]['enabled']['#wrapper_attributes']['class'] = array('checkbox', 'menu-enabled');
+
+ $form['links'][$id]['weight'] = $element['weight'];
+ $form['links'][$id]['id'] = $element['id'];
+ $form['links'][$id]['parent'] = $element['parent'];
+
+ // Operations (dropbutton) column.
+ $form['links'][$id]['operations'] = $element['operations'];
+ }
+ }
return $form;
}
@@ -374,9 +443,10 @@ protected function submitOverviewForm(array $complete_form, FormStateInterface $
$form = array_intersect_key(array_merge($order, $form), $form);
$fields = array('weight', 'parent', 'enabled');
- foreach (Element::children($form) as $id) {
- if (isset($form[$id]['#item'])) {
- $element = $form[$id];
+ $form_links = $form['links'];
+ foreach (Element::children($form_links) as $id) {
+ if (isset($form_links[$id]['#item'])) {
+ $element = $form_links[$id];
$updated_values = array();
// Update any fields that have changed in this menu item.
foreach ($fields as $field) {
diff --git a/core/modules/system/src/Tests/File/UrlRewritingTest.php b/core/modules/system/src/Tests/File/UrlRewritingTest.php
index 2c428ae..8b2f455 100644
--- a/core/modules/system/src/Tests/File/UrlRewritingTest.php
+++ b/core/modules/system/src/Tests/File/UrlRewritingTest.php
@@ -56,6 +56,18 @@ function testShippedFileURL() {
$filepath = 'core/misc/favicon.ico';
$url = file_create_url($filepath);
$this->assertEqual('/' . base_path() . '/' . $filepath, $url, 'Correctly generated a protocol-relative URL for a shipped file.');
+
+ // Test alteration of file URLs with query strings and/or fragment.
+ \Drupal::state()->delete('file_test.hook_file_url_alter');
+ $filepath = 'core/misc/favicon.ico';
+ $url = file_create_url($filepath . '?foo');
+ $this->assertEqual($GLOBALS['base_url'] . '/' . $filepath . '?foo=', $url, 'Correctly generated url. The query string is present.');
+ $url = file_create_url($filepath . '?foo=bar');
+ $this->assertEqual($GLOBALS['base_url'] . '/' . $filepath . '?foo=bar', $url, 'Correctly generated url. The query string is present.');
+ $url = file_create_url($filepath . '#v1.2');
+ $this->assertEqual($GLOBALS['base_url'] . '/' . $filepath . '#v1.2', $url, 'Correctly generated url. The fragment is present.');
+ $url = file_create_url($filepath . '?foo=bar#v1.2');
+ $this->assertEqual($GLOBALS['base_url'] . '/' . $filepath . '?foo=bar#v1.2', $url, 'Correctly generated url. The query string amd fragment is present.');
}
/**