diff --git a/core/authorize.php b/core/authorize.php index fe374fa..f1921cb 100644 --- a/core/authorize.php +++ b/core/authorize.php @@ -182,7 +182,7 @@ function authorize_access_allowed(Request $request) { } $bare_html_page_renderer = \Drupal::service('bare_html_page_renderer'); -$response = $bare_html_page_renderer->renderBarePage($content, $page_title, 'maintenance_page', array( +$response = $bare_html_page_renderer->renderBarePage($content, $page_title, 'page__maintenance', array( '#show_messages' => $show_messages, )); if (!$is_allowed) { diff --git a/core/includes/batch.inc b/core/includes/batch.inc index 0958c3a..d273929 100644 --- a/core/includes/batch.inc +++ b/core/includes/batch.inc @@ -138,7 +138,7 @@ function _batch_progress_page() { // it. While this causes invalid HTML, the same would be true if we didn't, // as content is not allowed to appear after anyway. $bare_html_page_renderer = \Drupal::service('bare_html_page_renderer'); - $response = $bare_html_page_renderer->renderBarePage(['#markup' => $fallback], $current_set['title'], 'maintenance_page', array( + $response = $bare_html_page_renderer->renderBarePage(['#markup' => $fallback], $current_set['title'], 'page__maintenance', array( '#show_messages' => FALSE, )); diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index b25d28c..9eb5e4b 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -984,7 +984,7 @@ function install_display_output($output, $install_state) { } $bare_html_page_renderer = \Drupal::service('bare_html_page_renderer'); - $response = $bare_html_page_renderer->renderBarePage($output, $output['#title'], 'install_page', $regions); + $response = $bare_html_page_renderer->renderBarePage($output, $output['#title'], 'page__maintenance__install', $regions); $default_headers = array( 'Expires' => 'Sun, 19 Nov 1978 05:00:00 GMT', 'Last-Modified' => gmdate(DATE_RFC1123, REQUEST_TIME), diff --git a/core/includes/theme.inc b/core/includes/theme.inc index b1a911a..a7e4660 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1390,52 +1390,6 @@ function theme_get_suggestions($args, $base, $delimiter = '__') { } /** - * Prepares variables for maintenance page templates. - * - * Default template: maintenance-page.html.twig. - * - * @param array $variables - * An associative array containing: - * - content - An array of page content. - * - * @see system_page_attachments() - */ -function template_preprocess_maintenance_page(&$variables) { - // @todo Rename the templates to page--maintenance + page--install. - template_preprocess_page($variables); - - // @see system_page_attachments() - $variables['#attached']['library'][] = 'system/maintenance'; - - // Maintenance page and install page need branding info in variables because - // there is no blocks. - $site_config = \Drupal::config('system.site'); - $variables['logo'] = theme_get_setting('logo.url'); - $variables['site_name'] = $site_config->get('name'); - $variables['site_slogan'] = $site_config->get('slogan'); -} - -/** - * Prepares variables for install page templates. - * - * Default template: install-page.html.twig. - * - * @param array $variables - * An associative array containing: - * - content - An array of page content. - * - * @see template_preprocess_maintenance_page() - */ -function template_preprocess_install_page(&$variables) { - template_preprocess_maintenance_page($variables); - - // Override the site name that is displayed on the page, since Drupal is - // still in the process of being installed. - $distribution_name = drupal_install_profile_distribution_name(); - $variables['site_name'] = $distribution_name; -} - -/** * Prepares variables for region templates. * * Default template: region.html.twig. @@ -1721,12 +1675,6 @@ function drupal_common_theme() { 'function' => 'theme_indentation', ), // From theme.maintenance.inc. - 'maintenance_page' => array( - 'render element' => 'page', - ), - 'install_page' => array( - 'render element' => 'page', - ), 'maintenance_task_list' => array( 'variables' => array('items' => NULL, 'active' => NULL, 'variant' => NULL), ), diff --git a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php index 92071da..bb2a215 100644 --- a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php @@ -106,7 +106,7 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) { $content = Xss::filterAdmin(SafeMarkup::format($this->config->get('system.maintenance')->get('message'), array( '@site' => $this->config->get('system.site')->get('name'), ))); - $response = $this->bareHtmlPageRenderer->renderBarePage(['#markup' => $content], $this->t('Site under maintenance'), 'maintenance_page'); + $response = $this->bareHtmlPageRenderer->renderBarePage(['#markup' => $content], $this->t('Site under maintenance'), 'page__maintenance'); $response->setStatusCode(503); $event->setResponse($response); } diff --git a/core/lib/Drupal/Core/Render/BareHtmlPageRendererInterface.php b/core/lib/Drupal/Core/Render/BareHtmlPageRendererInterface.php index 9e1f8ee..5ead056 100644 --- a/core/lib/Drupal/Core/Render/BareHtmlPageRendererInterface.php +++ b/core/lib/Drupal/Core/Render/BareHtmlPageRendererInterface.php @@ -38,9 +38,10 @@ * in a limited environment). * * Currently, there are two types of bare pages available: - * - Install (hook_preprocess_install_page(), install-page.html.twig). - * - Maintenance (hook_preprocess_maintenance_page(), - * maintenance-page.html.twig). + * - Install (hook_preprocess_page__maintenance__install(), + * page--maintenance--install.html.twig). + * - Maintenance (hook_preprocess_page__maintenance(), + * page--maintenance.html.twig). * * @see \Drupal\Core\Render\MainContent\HtmlRenderer */ diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php index 61e89a2..740d711 100644 --- a/core/modules/system/src/Controller/DbUpdateController.php +++ b/core/modules/system/src/Controller/DbUpdateController.php @@ -198,7 +198,7 @@ public function handle($op, Request $request) { } $title = isset($output['#title']) ? $output['#title'] : $this->t('Drupal database update'); - return $this->bareHtmlPageRenderer->renderBarePage($output, $title, 'maintenance_page', $regions); + return $this->bareHtmlPageRenderer->renderBarePage($output, $title, 'page__maintenance', $regions); } /** diff --git a/core/modules/system/system.module b/core/modules/system/system.module index a8cc12d..3a22a9f 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -253,39 +253,71 @@ function system_theme_suggestions_html(array $variables) { * Implements hook_theme_suggestions_HOOK(). */ function system_theme_suggestions_page(array $variables) { - if (\Drupal::service('path.matcher')->isFrontPage()) { - $path_args = ['']; - } - else { - $path_args = explode('/', Url::fromRoute('')->getInternalPath()); - } - return theme_get_suggestions($path_args, 'page'); -} - -/** - * Implements hook_theme_suggestions_HOOK(). - */ -function system_theme_suggestions_maintenance_page(array $variables) { - $suggestions = array(); - // Dead databases will show error messages so supplying this template will // allow themers to override the page and the content completely. - $offline = defined('MAINTENANCE_MODE'); try { - \Drupal::service('path.matcher')->isFrontPage(); + if (\Drupal::service('path.matcher')->isFrontPage()) { + $path_args = ['']; + } + else { + $path_args = explode('/', Url::fromRoute('')->getInternalPath()); + } + return theme_get_suggestions($path_args, 'page'); } catch (Exception $e) { // The database is not yet available. $offline = TRUE; } - if ($offline) { - $suggestions[] = 'maintenance_page__offline'; + $suggestions = []; + if (isset($offline) || defined('MAINTENANCE_MODE')) { + $suggestions[] = 'page__maintenance__offline'; } return $suggestions; } /** + * Prepares variables for maintenance page templates. + * + * Default template: page--maintenance.html.twig. + * + * @param array $variables + * An associative array containing: + * - content - An array of page content. + * + * @see system_page_attachments() + */ +function system_preprocess_page__maintenance(&$variables) { + // @see system_page_attachments() + $variables['#attached']['library'][] = 'system/maintenance'; + + // Maintenance page and install page need branding info in variables because + // there is no blocks. + $site_config = \Drupal::config('system.site'); + $variables['logo'] = theme_get_setting('logo.url'); + $variables['site_name'] = $site_config->get('name'); + $variables['site_slogan'] = $site_config->get('slogan'); +} + +/** + * Prepares variables for install page templates. + * + * Default template: page--maintenance--install.html.twig. + * + * @param array $variables + * An associative array containing: + * - content - An array of page content. + * + * @see template_preprocess_page__maintenance() + */ +function system_preprocess_page__maintenance__install(&$variables) { + // Override the site name that is displayed on the page, since Drupal is + // still in the process of being installed. + $distribution_name = drupal_install_profile_distribution_name(); + $variables['site_name'] = $distribution_name; +} + +/** * Implements hook_theme_suggestions_HOOK(). */ function system_theme_suggestions_region(array $variables) { @@ -511,11 +543,11 @@ function system_filetransfer_info() { /** * Implements hook_page_attachments(). * - * @see template_preprocess_maintenance_page() + * @see system_preprocess_page__maintenance() * @see \Drupal\Core\EventSubscriber\ActiveLinkResponseFilter */ function system_page_attachments(array &$page) { - // Ensure the same CSS is loaded in template_preprocess_maintenance_page(). + // Ensure the same CSS is loaded in system_preprocess_page__maintenance(). $page['#attached']['library'][] = 'system/base'; if (\Drupal::service('router.admin_context')->isAdminRoute()) { $page['#attached']['library'][] = 'system/admin'; diff --git a/core/modules/system/templates/install-page.html.twig b/core/modules/system/templates/page--maintenance--install.html.twig similarity index 95% rename from core/modules/system/templates/install-page.html.twig rename to core/modules/system/templates/page--maintenance--install.html.twig index 1d0e479..964821e 100644 --- a/core/modules/system/templates/install-page.html.twig +++ b/core/modules/system/templates/page--maintenance--install.html.twig @@ -6,7 +6,7 @@ * All available variables are mirrored in page.html.twig. * Some may be blank but they are provided for consistency. * - * @see template_preprocess_install_page() + * @see template_preprocess_page__maintenance__install() * * @ingroup themeable */ diff --git a/core/modules/system/templates/maintenance-page.html.twig b/core/modules/system/templates/page--maintenance.html.twig similarity index 96% rename from core/modules/system/templates/maintenance-page.html.twig rename to core/modules/system/templates/page--maintenance.html.twig index 748ed5a..6ca60fd 100644 --- a/core/modules/system/templates/maintenance-page.html.twig +++ b/core/modules/system/templates/page--maintenance.html.twig @@ -6,7 +6,7 @@ * All available variables are mirrored in page.html.twig. * Some may be blank but they are provided for consistency. * - * @see template_preprocess_maintenance_page() + * @see template_preprocess_page__maintenance() * * @ingroup themeable */ diff --git a/core/themes/bartik/bartik.theme b/core/themes/bartik/bartik.theme index 556342f..e864f9f 100644 --- a/core/themes/bartik/bartik.theme +++ b/core/themes/bartik/bartik.theme @@ -59,13 +59,13 @@ function bartik_preprocess_page(&$variables) { } /** - * Implements hook_preprocess_HOOK() for maintenance-page.html.twig. + * Implements hook_preprocess_HOOK() for page--maintenance templates. */ -function bartik_preprocess_maintenance_page(&$variables) { +function bartik_preprocess_page__maintenance(&$variables) { // By default, site_name is set to Drupal if no db connection is available // or during site installation. Setting site_name to an empty string makes // the site and update pages look cleaner. - // @see template_preprocess_maintenance_page + // @see template_preprocess_page__maintenance if (!$variables['db_is_active']) { $variables['site_name'] = ''; } diff --git a/core/themes/bartik/css/maintenance-page.css b/core/themes/bartik/css/maintenance-page.css index dd473d4..f8cc373 100644 --- a/core/themes/bartik/css/maintenance-page.css +++ b/core/themes/bartik/css/maintenance-page.css @@ -1,8 +1,8 @@ -body.maintenance-page { +body.page--maintenance { background-color: #fff; color: #000; } -.maintenance-page #page-wrapper { +.page--maintenance #page-wrapper { background: #fff; margin-left: auto; margin-right: auto; @@ -11,71 +11,71 @@ body.maintenance-page { border: 1px solid #ddd; margin-top: 40px; } -.maintenance-page #page { +.page--maintenance #page { margin: 10px; } -.maintenance-page #main-wrapper { +.page--maintenance #main-wrapper { min-height: inherit; } -.maintenance-page #header, -.maintenance-page #messages { +.page--maintenance #header, +.page--maintenance #messages { width: auto; } -.maintenance-page #main { +.page--maintenance #main { margin: 0; } -.maintenance-page .content .section { +.page--maintenance .content .section { padding: 0 0 0 10px; /* LTR */ } -[dir="rtl"] .maintenance-page .content .section { +[dir="rtl"] .page--maintenance .content .section { padding-left: 0; padding-right: 10px; } -.maintenance-page #header { +.page--maintenance #header { background-color: #fff; background-image: none; } -.maintenance-page .site-branding-text { +.page--maintenance .site-branding-text { margin-bottom: 50px; margin-left: 0; /* LTR */ padding-top: 20px; font-size: 90%; } -[dir="rtl"] .maintenance-page .site-branding-text { +[dir="rtl"] .page--maintenance .site-branding-text { margin-right: 0; } -.maintenance-page .site-branding-text, -.maintenance-page .site-branding-text a, -.maintenance-page .site-branding-text a:hover, -.maintenance-page .site-branding-text a:focus { +.page--maintenance .site-branding-text, +.page--maintenance .site-branding-text a, +.page--maintenance .site-branding-text a:hover, +.page--maintenance .site-branding-text a:focus { color: #777; } -.maintenance-page .page-title { +.page--maintenance .page-title { line-height: 1em; margin-top: 0; } -.maintenance-page #messages { +.page--maintenance #messages { padding: 0; margin-top: 30px; } -.maintenance-page #messages div.messages { +.page--maintenance #messages div.messages { margin: 0; } @media all and (min-width: 800px) { - .maintenance-page #page-wrapper { + .page--maintenance #page-wrapper { width: 800px; } - .maintenance-page #header div.section, - .maintenance-page #main { + .page--maintenance #header div.section, + .page--maintenance #main { width: 700px; } - .maintenance-page #messages div.section { + .page--maintenance #messages div.section { padding: 0; width: auto; } } @media all and (min-width: 600px) { /* @TODO find the proper breakpoint */ - .maintenance-page #page { + .page--maintenance #page { margin: 20px 40px 40px; } } diff --git a/core/themes/bartik/templates/maintenance-page.html.twig b/core/themes/bartik/templates/page--maintenance.html.twig similarity index 96% rename from core/themes/bartik/templates/maintenance-page.html.twig rename to core/themes/bartik/templates/page--maintenance.html.twig index 3cd787b..f414e47 100644 --- a/core/themes/bartik/templates/maintenance-page.html.twig +++ b/core/themes/bartik/templates/page--maintenance.html.twig @@ -5,7 +5,7 @@ * * All available variables are mirrored in page.html.twig. * - * @see template_preprocess_maintenance_page() + * @see template_preprocess_page__maintenance() */ #}
diff --git a/core/themes/classy/templates/layout/maintenance-page.html.twig b/core/themes/classy/templates/layout/page--maintenance.html.twig similarity index 96% rename from core/themes/classy/templates/layout/maintenance-page.html.twig rename to core/themes/classy/templates/layout/page--maintenance.html.twig index 7463b02..f929470 100644 --- a/core/themes/classy/templates/layout/maintenance-page.html.twig +++ b/core/themes/classy/templates/layout/page--maintenance.html.twig @@ -6,7 +6,7 @@ * All available variables are mirrored in page.html.twig. * Some may be blank but they are provided for consistency. * - * @see template_preprocess_maintenance_page() + * @see template_preprocess_page__maintenance() */ #}
diff --git a/core/themes/seven/css/theme/install-page.css b/core/themes/seven/css/theme/install-page.css index 3a2f217..4558c2f 100644 --- a/core/themes/seven/css/theme/install-page.css +++ b/core/themes/seven/css/theme/install-page.css @@ -3,9 +3,9 @@ * Installation styling. * * Unfortunately we have to make our styling quite strong, to override the - * .maintenance-page styling. + * .page--maintenance styling. */ -.install-page { +.page--maintenance--install { background-color: #1275b2; background-image: url(../../images/noise-low.png), @@ -17,28 +17,28 @@ background-position: left top, 50% 50%; /* LTR */ min-height: 100%; } -[dir="rtl"] .install-page { +[dir="rtl"] .page--maintenance--install { background-position: right top, 50% 50%; } /** * Password widget */ -.install-page .password-parent, -.install-page .confirm-parent { +.page--maintenance--install .password-parent, +.page--maintenance--install .confirm-parent { width: auto; } -.install-page .form-item .password-suggestions { +.page--maintenance--install .form-item .password-suggestions { float: none; width: auto; } -.install-page table td { +.page--maintenance--install table td { word-break: break-word; } @media all and (max-width: 1010px) and (min-width: 48em) { - .install-page .password-strength, - .install-page .confirm-parent { + .page--maintenance--install .password-strength, + .page--maintenance--install .confirm-parent { width: 100%; } .install-configure-form .form-type-password { diff --git a/core/themes/seven/css/theme/maintenance-page.css b/core/themes/seven/css/theme/maintenance-page.css index 6784343..2a37575 100644 --- a/core/themes/seven/css/theme/maintenance-page.css +++ b/core/themes/seven/css/theme/maintenance-page.css @@ -2,7 +2,7 @@ * @file * Maintenance theming. */ -.maintenance-page { +.page--maintenance { background-color: #e0e0d8; background-image: -webkit-radial-gradient(hsl(203, 2%, 90%), hsl(203, 2%, 95%)); background-image: radial-gradient(hsl(203, 2%, 90%), hsl(203, 2%, 95%)); @@ -10,7 +10,7 @@ background-position: left top, 50% 50%; /* LTR */ min-height: 100%; } -[dir="rtl"] .maintenance-page { +[dir="rtl"] .page--maintenance { background-position: right top, 50% 50%; } @@ -129,13 +129,13 @@ html { display: table; } - .install-page, - .maintenance-page { + .page--maintenance--install, + .page--maintenance { display: table-cell; padding: 1em 0; vertical-align: middle; } - html, .install-page, .maintenance-page { + html, .page--maintenance--install, .page--maintenance { margin: 0; width: 100%; height: 100%; diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme index 1a44bc4..0b96450 100644 --- a/core/themes/seven/seven.theme +++ b/core/themes/seven/seven.theme @@ -128,17 +128,17 @@ function seven_element_info_alter(&$type) { } /** - * Implements hook_preprocess_install_page(). + * Implements hook_preprocess_HOOK() for page--maintenance--install templates. */ -function seven_preprocess_install_page(&$variables) { +function seven_preprocess_page__maintenance__install(&$variables) { // Seven has custom styling for the install page. $variables['#attached']['library'][] = 'seven/install-page'; } /** - * Implements hook_preprocess_maintenance_page(). + * Implements hook_preprocess_HOOK() for page--maintenance templates. */ -function seven_preprocess_maintenance_page(&$variables) { +function seven_preprocess_page__maintenance(&$variables) { // Seven has custom styling for the maintenance page. $variables['#attached']['library'][] = 'seven/maintenance-page'; } diff --git a/core/themes/seven/templates/install-page.html.twig b/core/themes/seven/templates/page--maintenance--install.html.twig similarity index 94% rename from core/themes/seven/templates/install-page.html.twig rename to core/themes/seven/templates/page--maintenance--install.html.twig index b501fb8..d8e28fa 100644 --- a/core/themes/seven/templates/install-page.html.twig +++ b/core/themes/seven/templates/page--maintenance--install.html.twig @@ -6,7 +6,7 @@ * All available variables are mirrored in page.html.twig. * Some may be blank but they are provided for consistency. * - * @see template_preprocess_install_page() + * @see template_preprocess_page__maintenance__install() */ #}
diff --git a/core/themes/seven/templates/maintenance-page.html.twig b/core/themes/seven/templates/page--maintenance.html.twig similarity index 94% rename from core/themes/seven/templates/maintenance-page.html.twig rename to core/themes/seven/templates/page--maintenance.html.twig index 2286e88..6fd85d5 100644 --- a/core/themes/seven/templates/maintenance-page.html.twig +++ b/core/themes/seven/templates/page--maintenance.html.twig @@ -6,7 +6,7 @@ * All available variables are mirrored in page.html.twig. * Some may be blank but they are provided for consistency. * - * @see template_preprocess_maintenance_page() + * @see template_preprocess_page__maintenance() */ #}