diff --git a/core/lib/Drupal/Core/Render/Element/MoreLink.php b/core/lib/Drupal/Core/Render/Element/MoreLink.php index 4f7e90c..6551abb 100644 --- a/core/lib/Drupal/Core/Render/Element/MoreLink.php +++ b/core/lib/Drupal/Core/Render/Element/MoreLink.php @@ -24,7 +24,7 @@ public function getInfo() { '#title' => $this->t('More'), '#theme_wrappers' => array( 'container' => array( - '#attributes' => array('class' => 'more-link'), + '#attributes' => array('class' => array('more-link')), ), ), ) + $info; diff --git a/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php b/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php new file mode 100644 index 0000000..6ce349e --- /dev/null +++ b/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php @@ -0,0 +1,77 @@ + array( + array($class, 'preRenderCompactLink'), + array($class, 'preRenderLink'), + ), + '#theme_wrappers' => array( + 'container' => array( + '#attributes' => array('class' => array('compact-link')), + ), + ), + ); + } + + /** + * Pre-render callback: Renders a lin k into #markup. + * + * Doing so during pre_render gives modules a chance to alter the link parts. + * + * @param array $element + * A structured array whose keys form the arguments to l(): + * - #title: The link text to pass as argument to l(). + * - One of the following + * - #route_name and (optionally) a #route_parameters array; The route + * name and route parameters which will be passed into the link + * generator. + * - #href: The system path or URL to pass as argument to l(). + * - #options: (optional) An array of options to pass to l() or the link + * generator. + * + * @return array + * The passed-in element containing the system compact link default values. + */ + public static function preRenderCompactLink($element) { + // By default, link options to pass to l() are normally set in #options. + $element += array('#options' => array()); + + if (system_admin_compact_mode()) { + $element['#title'] = t('Show descriptions'); + $element['#href'] = 'admin/compact/off'; + $element['#options'] = array( + 'title' => t('Expand layout to include descriptions.'), + 'query' => drupal_get_destination(), + ); + } + else { + $element['#title'] = t('Hide descriptions'); + $element['#href'] = 'admin/compact/on'; + $element['#options'] = array( + 'title' => t('Compress layout by hiding descriptions.'), + 'query' => drupal_get_destination(), + ); + } + return $element; + } + +} diff --git a/core/modules/system/css/system.admin.css b/core/modules/system/css/system.admin.css index 51bd1de..6e4f4db 100644 --- a/core/modules/system/css/system.admin.css +++ b/core/modules/system/css/system.admin.css @@ -28,7 +28,7 @@ div.admin .expert-link { } /** - * Markup generated by theme_system_compact_link(). + * System compact link: to toggle the display of description text. */ .compact-link { margin: 0 0 0.5em 0; diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 57edc26..0fc5922 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -84,7 +84,7 @@ function template_preprocess_admin_block_content(&$variables) { */ function template_preprocess_admin_page(&$variables) { $variables['system_compact_link'] = array( - '#theme' => 'system_compact_link', + '#type' => 'system_compact_link', ); $variables['containers'] = array(); $stripe = 0; @@ -113,7 +113,7 @@ function template_preprocess_admin_page(&$variables) { */ function template_preprocess_system_admin_index(&$variables) { $variables['system_compact_link'] = array( - '#theme' => 'system_compact_link', + '#type' => 'system_compact_link', ); $variables['containers'] = array(); $stripe = 0; diff --git a/core/modules/system/system.module b/core/modules/system/system.module index f3b65a2..f9a68ba 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -210,9 +210,6 @@ function system_theme() { 'file' => 'system.admin.inc', 'template' => 'system-admin-index', ), - 'system_compact_link' => array( - 'variables' => array(), - ), )); } @@ -1204,24 +1201,6 @@ function system_time_zones($blank = NULL) { } /** - * Returns HTML for a link to show or hide inline help descriptions. - * - * @ingroup themeable - */ -function theme_system_compact_link() { - $output = ''; - - return $output; -} - -/** * Attempts to get a file using Guzzle HTTP client and to store it locally. * * @param string $url diff --git a/core/modules/user/src/Form/UserPermissionsForm.php b/core/modules/user/src/Form/UserPermissionsForm.php index 83408d6..d98275d 100644 --- a/core/modules/user/src/Form/UserPermissionsForm.php +++ b/core/modules/user/src/Form/UserPermissionsForm.php @@ -97,7 +97,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $hide_descriptions = system_admin_compact_mode(); $form['system_compact_link'] = array( - '#theme' => 'system_compact_link', + '#type' => 'system_compact_link', ); $form['permissions'] = array(