Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/shortcut/shortcut.module @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
21 case 'help.page.shortcut': | 21 case 'help.page.shortcut': |
22 $output = '<h3>' . t('About') . '</h3>'; | 22 $output = '<h3>' . t('About') . '</h3>'; |
23 $output .= '<p>' . t('The Shortcut module allows users to create sets of <em>shortcut</em> links to commonly-visited pages of the site. Shortcuts are contained within <em>sets</em>. Each user with <em>Select any shortcut set</em> permission can select a shortcut set created by anyone at the site. For more information, see the <a href=":shortcut">online documentation for the Shortcut module</a>.', [':shortcut' => 'https://www.drupal.org/documentation/modules/shortcut']) . '</p>'; | 23 $output .= '<p>' . t('The Shortcut module allows users to create sets of <em>shortcut</em> links to commonly-visited pages of the site. Shortcuts are contained within <em>sets</em>. Each user with <em>Select any shortcut set</em> permission can select a shortcut set created by anyone at the site. For more information, see the <a href=":shortcut">online documentation for the Shortcut module</a>.', [':shortcut' => 'https://www.drupal.org/documentation/modules/shortcut']) . '</p>'; |
24 $output .= '<h3>' . t('Uses') . '</h3>'; | 24 $output .= '<h3>' . t('Uses') . '</h3>'; |
25 $output .= '<dl><dt>' . t('Administering shortcuts') . '</dt>'; | 25 $output .= '<dl><dt>' . t('Administering shortcuts') . '</dt>'; |
26 $output .= '<dd>' . t('Users with the <em>Administer shortcuts</em> permission can manage shortcut sets and edit the shortcuts within sets from the <a href=":shortcuts">Shortcuts administration page</a>.', [':shortcuts' => \Drupal::url('entity.shortcut_set.collection')]) . '</dd>'; | 26 $output .= '<dd>' . t('Users with the <em>Administer shortcuts</em> permission can manage shortcut sets and edit the shortcuts within sets from the <a href=":shortcuts">Shortcuts administration page</a>.', [':shortcuts' => Url::fromRoute('entity.shortcut_set.collection')->toString()]) . '</dd>'; |
27 $output .= '<dt>' . t('Choosing shortcut sets') . '</dt>'; | 27 $output .= '<dt>' . t('Choosing shortcut sets') . '</dt>'; |
28 $output .= '<dd>' . t('Users with permission to switch shortcut sets can choose a shortcut set to use from the Shortcuts tab of their user account page.') . '</dd>'; | 28 $output .= '<dd>' . t('Users with permission to switch shortcut sets can choose a shortcut set to use from the Shortcuts tab of their user account page.') . '</dd>'; |
29 $output .= '<dt>' . t('Adding and removing shortcuts') . '</dt>'; | 29 $output .= '<dt>' . t('Adding and removing shortcuts') . '</dt>'; |
30 $output .= '<dd>' . t('The Shortcut module creates an add/remove link for each page on your site; the link lets you add or remove the current page from the currently-enabled set of shortcuts (if your theme displays it and you have permission to edit your shortcut set). The core Seven administration theme displays this link next to the page title, as a grey or yellow star. If you click on the grey star, you will add that page to your preferred set of shortcuts. If the page is already part of your shortcut set, the link will be a yellow star, and will allow you to remove the current page from your shortcut set.') . '</dd>'; | 30 $output .= '<dd>' . t('The Shortcut module creates an add/remove link for each page on your site; the link lets you add or remove the current page from the currently-enabled set of shortcuts (if your theme displays it and you have permission to edit your shortcut set). The core Seven administration theme displays this link next to the page title, as a grey or yellow star. If you click on the grey star, you will add that page to your preferred set of shortcuts. If the page is already part of your shortcut set, the link will be a yellow star, and will allow you to remove the current page from your shortcut set.') . '</dd>'; |
31 $output .= '<dt>' . t('Displaying shortcuts') . '</dt>'; | 31 $output .= '<dt>' . t('Displaying shortcuts') . '</dt>'; |
32 $output .= '<dd>' . t('You can display your shortcuts by enabling the <em>Shortcuts</em> block on the <a href=":blocks">Blocks administration page</a>. Certain administrative modules also display your shortcuts; for example, the core <a href=":toolbar-help">Toolbar module</a> provides a corresponding menu item.', [':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#', ':toolbar-help' => (\Drupal::moduleHandler()->moduleExists('toolbar')) ? \Drupal::url('help.page', ['name' => 'toolbar']) : '#']) . '</dd>'; | 32 $output .= '<dd>' . t('You can display your shortcuts by enabling the <em>Shortcuts</em> block on the <a href=":blocks">Blocks administration page</a>. Certain administrative modules also display your shortcuts; for example, the core <a href=":toolbar-help">Toolbar module</a> provides a corresponding menu item.', [':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? Url::fromRoute('block.admin_display')->toString() : '#', ':toolbar-help' => (\Drupal::moduleHandler()->moduleExists('toolbar')) ? Url::fromRoute('help.page', ['name' => 'toolbar'])->toString() : '#']) . '</dd>'; |
33 $output .= '</dl>'; | 33 $output .= '</dl>'; |
34 return $output; | 34 return $output; |
35 | 35 |
36 case 'entity.shortcut_set.collection': | 36 case 'entity.shortcut_set.collection': |
37 case 'shortcut.set_add': | 37 case 'shortcut.set_add': |
38 case 'entity.shortcut_set.edit_form': | 38 case 'entity.shortcut_set.edit_form': |
39 $user = \Drupal::currentUser(); | 39 $user = \Drupal::currentUser(); |
40 if ($user->hasPermission('access shortcuts') && $user->hasPermission('switch shortcut sets')) { | 40 if ($user->hasPermission('access shortcuts') && $user->hasPermission('switch shortcut sets')) { |
41 $output = '<p>' . t('Define which shortcut set you are using on the <a href=":shortcut-link">Shortcuts tab</a> of your account page.', [':shortcut-link' => \Drupal::url('shortcut.set_switch', ['user' => $user->id()])]) . '</p>'; | 41 $output = '<p>' . t('Define which shortcut set you are using on the <a href=":shortcut-link">Shortcuts tab</a> of your account page.', [':shortcut-link' => Url::fromRoute('shortcut.set_switch', ['user' => $user->id()])->toString()]) . '</p>'; |
42 return $output; | 42 return $output; |
43 } | 43 } |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
262 $shortcut_set = shortcut_current_displayed_set(); | 262 $shortcut_set = shortcut_current_displayed_set(); |
263 } | 263 } |
264 | 264 |
265 $cache_tags = []; | 265 $cache_tags = []; |
266 foreach ($shortcut_set->getShortcuts() as $shortcut) { | 266 foreach ($shortcut_set->getShortcuts() as $shortcut) { |
267 $shortcut = \Drupal::entityManager()->getTranslationFromContext($shortcut); | 267 $shortcut = \Drupal::service('entity.repository')->getTranslationFromContext($shortcut); |
268 $url = $shortcut->getUrl(); | 268 $url = $shortcut->getUrl(); |
269 if ($url->access()) { | 269 if ($url->access()) { |
270 $links[$shortcut->id()] = [ | 270 $links[$shortcut->id()] = [ |
271 'type' => 'link', | 271 'type' => 'link', |
272 'title' => $shortcut->label(), | 272 'title' => $shortcut->label(), |
405 $items['shortcuts'] += [ | 405 $items['shortcuts'] += [ |
406 '#type' => 'toolbar_item', | 406 '#type' => 'toolbar_item', |
407 'tab' => [ | 407 'tab' => [ |
408 '#type' => 'link', | 408 '#type' => 'link', |
409 '#title' => t('Shortcuts'), | 409 '#title' => t('Shortcuts'), |
410 '#url' => $shortcut_set->urlInfo('collection'), | 410 '#url' => $shortcut_set->toUrl('collection'), |
411 '#attributes' => [ | 411 '#attributes' => [ |
412 'title' => t('Shortcuts'), | 412 'title' => t('Shortcuts'), |
413 'class' => ['toolbar-icon', 'toolbar-icon-shortcut'], | 413 'class' => ['toolbar-icon', 'toolbar-icon-shortcut'], |
414 ], | 414 ], |
415 ], | 415 ], |