diff --git a/core/modules/system/src/Plugin/Block/SystemPageActionsBlock.php b/core/modules/system/src/Plugin/Block/SystemPageActionsBlock.php new file mode 100644 index 0000000..efe0a4b --- /dev/null +++ b/core/modules/system/src/Plugin/Block/SystemPageActionsBlock.php @@ -0,0 +1,106 @@ +configFactory = $config_factory; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('config.factory') + ); + } + + /** + * {@inheritdoc} + */ + public function defaultConfiguration() { + return array( + 'label_display' => FALSE, + ); + } + + /** + * {@inheritdoc} + */ + public function build() { + $build = array(); + $action_links = menu_get_local_actions(); + + $build['action_links'] = array( + '#markup' => $action_links, + ); + + return $build; + } + + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, array &$form_state) { + $form = parent::buildConfigurationForm($form, $form_state); + + // The page actions block is never cacheable, because it may be dynamic. + $form['cache']['#disabled'] = TRUE; + $form['cache']['#description'] = t('This block is never cacheable, it is not configurable.'); + $form['cache']['max_age']['#value'] = 0; + + return $form; + } + + /** + * {@inheritdoc} + */ + public function isCacheable() { + // The page actions block is never cacheable, because it may be dynamic. + return FALSE; + } + +} diff --git a/core/modules/system/src/Plugin/Block/SystemPageTitleBlock.php b/core/modules/system/src/Plugin/Block/SystemPageTitleBlock.php new file mode 100644 index 0000000..85d57f3 --- /dev/null +++ b/core/modules/system/src/Plugin/Block/SystemPageTitleBlock.php @@ -0,0 +1,134 @@ +configFactory = $config_factory; + $this->titleResolver = $titleResolver; + $this->requestStack = $requestStack; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('config.factory'), + $container->get('title_resolver'), + $container->get('request_stack') + ); + } + + /** + * {@inheritdoc} + */ + public function defaultConfiguration() { + return array( + 'label_display' => FALSE, + ); + } + + /** + * {@inheritdoc} + */ + public function build() { + $build = array(); + $title = ''; + $request = $this->requestStack->getCurrentRequest(); + if ($route = $request->attributes->get(\Symfony\Cmf\Component\Routing\RouteObjectInterface::ROUTE_OBJECT)) { + $title = $this->titleResolver->getTitle($request, $route); + } + + $build['title'] = array( + '#markup' => $title, + ); + + return $build; + } + + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, array &$form_state) { + $form = parent::buildConfigurationForm($form, $form_state); + + // The page title block is never cacheable, because it may be dynamic. + $form['cache']['#disabled'] = TRUE; + $form['cache']['#description'] = t('This block is never cacheable, it is not configurable.'); + $form['cache']['max_age']['#value'] = 0; + + return $form; + } + + /** + * {@inheritdoc} + */ + public function isCacheable() { + // The page title block is never cacheable, because it may be dynamic. + return FALSE; + } + +} diff --git a/core/modules/system/src/Plugin/Block/SystemTitleBlock.php b/core/modules/system/src/Plugin/Block/SystemTitleBlock.php deleted file mode 100644 index 2a47f5b..0000000 --- a/core/modules/system/src/Plugin/Block/SystemTitleBlock.php +++ /dev/null @@ -1,134 +0,0 @@ -configFactory = $config_factory; - $this->titleResolver = $titleResolver; - $this->requestStack = $requestStack; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('config.factory'), - $container->get('title_resolver'), - $container->get('request_stack') - ); - } - - /** - * {@inheritdoc} - */ - public function defaultConfiguration() { - return array( - 'label_display' => FALSE, - ); - } - - /** - * {@inheritdoc} - */ - public function build() { - $build = array(); - $title = ''; - $request = $this->requestStack->getCurrentRequest(); - if ($route = $request->attributes->get(\Symfony\Cmf\Component\Routing\RouteObjectInterface::ROUTE_OBJECT)) { - $title = $this->titleResolver->getTitle($request, $route); - } - - $build['title'] = array( - '#markup' => $title, - ); - - return $build; - } - - /** - * {@inheritdoc} - */ - public function buildConfigurationForm(array $form, array &$form_state) { - $form = parent::buildConfigurationForm($form, $form_state); - - // The page title block is never cacheable, because it may be dynamic. - $form['cache']['#disabled'] = TRUE; - $form['cache']['#description'] = t('This block is never cacheable, it is not configurable.'); - $form['cache']['max_age']['#value'] = 0; - - return $form; - } - - /** - * {@inheritdoc} - */ - public function isCacheable() { - // The page title block is never cacheable, because it may be dynamic. - return FALSE; - } - -} diff --git a/core/modules/system/system.module b/core/modules/system/system.module index e8c733f..c21c652 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -160,16 +160,19 @@ function system_help($route_name, Request $request) { function system_theme() { return array_merge(drupal_common_theme(), array( // Normally theme suggestion templates are only picked up when they are in - // themes. We explicitly define the block__system_branding_block and - // block__system_title_block theme suggestions here so that the templates in - // core/modules/system/templates are picked up. + // themes. We explicitly define theme suggestions here so that the + // block templates in core/modules/system/templates are picked up. 'block__system_branding_block' => array( 'base hook' => 'block', 'template' => 'block--system-branding-block', ), - 'block__system_title_block' => array( + 'block__system_page_title_block' => array( 'base hook' => 'block', - 'template' => 'block--system-title-block', + 'template' => 'block--system-page-title-block', + ), + 'block__system_page_actions_block' => array( + 'base hook' => 'block', + 'template' => 'block--system-page-actions-block', ), 'system_themes_page' => array( 'variables' => array( @@ -1076,13 +1079,20 @@ function system_preprocess_block(&$variables) { } break; - case 'system_title_block': + case 'system_page_title_block': $variables['title'] = ''; if($variables['content']['title']['#markup']) { $variables['title'] = $variables['content']['title']['#markup']; } break; + case 'system_page_actions_block': + $variables['action_links'] = ''; + if($variables['content']['action_links']['#markup']) { + $variables['action_links'] = $variables['content']['action_links']['#markup']; + } + break; + case 'system_powered_by_block': $variables['attributes']['role'] = 'complementary'; break; diff --git a/core/modules/system/templates/block--system-page-actions-block.html.twig b/core/modules/system/templates/block--system-page-actions-block.html.twig new file mode 100644 index 0000000..9b3335e --- /dev/null +++ b/core/modules/system/templates/block--system-page-actions-block.html.twig @@ -0,0 +1,17 @@ +{% extends "@block/block.html.twig" %} +{# +/** + * @file + * Default theme implementation for page local actions. + * + * Available variables: + * - action_links: The local actions for the page. + * + * @ingroup themeable + */ +#} +{% block content %} + {% if action_links %} + + {% endif %} +{% endblock %} diff --git a/core/modules/system/templates/block--system-page-title-block.html.twig b/core/modules/system/templates/block--system-page-title-block.html.twig new file mode 100644 index 0000000..8ec31ff --- /dev/null +++ b/core/modules/system/templates/block--system-page-title-block.html.twig @@ -0,0 +1,23 @@ +{% extends "@block/block.html.twig" %} +{# +/** + * @file + * Default theme implementation for a page title. + * + * Available variables: + * - title_prefix: Additional output populated by modules, intended to be + * displayed in front of the main title tag that appears in the template. + * - title: The page title, for use in the actual content. + * - title_suffix: Additional output populated by modules, intended to be + * displayed after the main title tag that appears in the template. + * + * @ingroup themeable + */ +#} +{% block content %} + {{ title_prefix }} + {% if title %} +

{{ title }}

+ {% endif %} + {{ title_suffix }} +{% endblock %} diff --git a/core/modules/system/templates/block--system-title-block.html.twig b/core/modules/system/templates/block--system-title-block.html.twig deleted file mode 100644 index 8ec31ff..0000000 --- a/core/modules/system/templates/block--system-title-block.html.twig +++ /dev/null @@ -1,23 +0,0 @@ -{% extends "@block/block.html.twig" %} -{# -/** - * @file - * Default theme implementation for a page title. - * - * Available variables: - * - title_prefix: Additional output populated by modules, intended to be - * displayed in front of the main title tag that appears in the template. - * - title: The page title, for use in the actual content. - * - title_suffix: Additional output populated by modules, intended to be - * displayed after the main title tag that appears in the template. - * - * @ingroup themeable - */ -#} -{% block content %} - {{ title_prefix }} - {% if title %} -

{{ title }}

- {% endif %} - {{ title_suffix }} -{% endblock %} diff --git a/core/themes/bartik/templates/block--system-page-actions-block.html.twig b/core/themes/bartik/templates/block--system-page-actions-block.html.twig new file mode 100644 index 0000000..11a9675 --- /dev/null +++ b/core/themes/bartik/templates/block--system-page-actions-block.html.twig @@ -0,0 +1,19 @@ +{% extends "@block/block.html.twig" %} +{# +/** + * @file + * Bartik's theme implementation for page local actions. + * + * Available variables: + * - action_links: The local actions for the page. + * + * @ingroup themeable + */ +#} +{% block content %} + {% if action_links %} + + {% endif %} +{% endblock %} diff --git a/core/themes/bartik/templates/block--system-page-title-block.html.twig b/core/themes/bartik/templates/block--system-page-title-block.html.twig new file mode 100644 index 0000000..1b7e66f --- /dev/null +++ b/core/themes/bartik/templates/block--system-page-title-block.html.twig @@ -0,0 +1,25 @@ +{% extends "@block/block.html.twig" %} +{# +/** + * @file + * Bartik's theme implementation for a page title. + * + * Available variables: + * - title_prefix: Additional output populated by modules, intended to be + * displayed in front of the main title tag that appears in the template. + * - title: The page title, for use in the actual content. + * - title_suffix: Additional output populated by modules, intended to be + * displayed after the main title tag that appears in the template. + * + * @ingroup themeable + */ +#} +{% block content %} + {{ title_prefix }} + {% if title %} +

+ {{ title }} +

+ {% endif %} + {{ title_suffix }} +{% endblock %} diff --git a/core/themes/bartik/templates/block--system-title-block.html.twig b/core/themes/bartik/templates/block--system-title-block.html.twig deleted file mode 100644 index 09abdcf..0000000 --- a/core/themes/bartik/templates/block--system-title-block.html.twig +++ /dev/null @@ -1,25 +0,0 @@ -{% extends "@block/block.html.twig" %} -{# -/** - * @file - * Default theme implementation for a page title. - * - * Available variables: - * - title_prefix: Additional output populated by modules, intended to be - * displayed in front of the main title tag that appears in the template. - * - title: The page title, for use in the actual content. - * - title_suffix: Additional output populated by modules, intended to be - * displayed after the main title tag that appears in the template. - * - * @ingroup themeable - */ -#} -{% block content %} - {{ title_prefix }} - {% if title %} -

- {{ title }} -

- {% endif %} - {{ title_suffix }} -{% endblock %}