2009-10-17 00:51:53 +00:00
<?php
/**
* @file
* Allows users to manage customizable lists of shortcut links.
*/
2018-05-01 15:14:09 +00:00
use Drupal\Component\Render\FormattableMarkup;
2014-09-17 14:39:29 +00:00
use Drupal\Core\Access\AccessResult;
2014-09-25 07:30:31 +00:00
use Drupal\Core\Cache\Cache;
Issue #2914110 by Berdir, neclimdul, acbramley, yongt9412, Wim Leers, arpad.rozsa, kim.pepper, Fabianx, davidwhthomas, pameeela, kualee, amateescu, jibran, longwave: Shortcut hook_toolbar implementation makes all pages uncacheable
2020-01-15 23:22:23 +00:00
use Drupal\Core\Cache\CacheableMetadata;
2014-06-30 03:33:08 +00:00
use Drupal\Core\Routing\RouteMatchInterface;
2014-02-09 01:29:41 +00:00
use Drupal\Core\Url;
2014-05-20 09:29:40 +00:00
use Drupal\shortcut\Entity\ShortcutSet;
2013-12-15 09:51:10 +00:00
use Drupal\shortcut\ShortcutSetInterface;
2009-10-17 00:51:53 +00:00
2009-12-04 16:02:42 +00:00
/**
* Implements hook_help().
*/
2014-06-30 03:33:08 +00:00
function shortcut_help($route_name, RouteMatchInterface $route_match) {
2014-05-07 02:04:53 +00:00
switch ($route_name) {
case 'help.page.shortcut':
2009-12-04 16:02:42 +00:00
$output = '<h3>' . t('About') . '</h3>';
2017-03-04 01:20:24 +00:00
$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>';
2009-12-04 16:02:42 +00:00
$output .= '<h3>' . t('Uses') . '</h3>';
2010-02-25 15:58:54 +00:00
$output .= '<dl><dt>' . t('Administering shortcuts') . '</dt>';
2019-04-16 05:38:27 +00:00
$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>';
2010-02-25 15:58:54 +00:00
$output .= '<dt>' . t('Choosing shortcut sets') . '</dt>';
$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>';
2009-12-04 16:02:42 +00:00
$output .= '<dt>' . t('Adding and removing shortcuts') . '</dt>';
2020-07-14 15:02:10 +00:00
$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 gray or yellow star. If you click on the gray 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>';
2009-12-04 16:02:42 +00:00
$output .= '<dt>' . t('Displaying shortcuts') . '</dt>';
2020-07-16 19:10:13 +00:00
$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 link.', [':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>';
2009-12-04 16:02:42 +00:00
$output .= '</dl>';
return $output;
2010-02-25 15:58:54 +00:00
2015-01-19 09:37:11 +00:00
case 'entity.shortcut_set.collection':
2014-05-07 02:04:53 +00:00
case 'shortcut.set_add':
2014-08-04 17:06:25 +00:00
case 'entity.shortcut_set.edit_form':
2014-05-07 02:04:53 +00:00
$user = \Drupal::currentUser();
2014-06-09 23:13:41 +00:00
if ($user->hasPermission('access shortcuts') && $user->hasPermission('switch shortcut sets')) {
2019-04-16 05:38:27 +00:00
$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>';
2010-02-25 15:58:54 +00:00
return $output;
}
2009-12-04 16:02:42 +00:00
}
}
2010-01-07 11:03:18 +00:00
2009-10-17 00:51:53 +00:00
/**
* Access callback for editing a shortcut set.
*
2013-12-15 09:51:10 +00:00
* @param Drupal\shortcut\ShortcutSetInterface $shortcut_set
2010-02-25 15:58:54 +00:00
* (optional) The shortcut set to be edited. If not set, the current user's
* shortcut set will be used.
*
2014-09-17 14:39:29 +00:00
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
2009-10-17 00:51:53 +00:00
*/
2013-12-15 09:51:10 +00:00
function shortcut_set_edit_access(ShortcutSetInterface $shortcut_set = NULL) {
2013-09-16 03:58:06 +00:00
$account = \Drupal::currentUser();
2014-06-09 23:13:41 +00:00
// Shortcut administrators can edit any set.
2013-09-04 21:18:30 +00:00
if ($account->hasPermission('administer shortcuts')) {
2015-03-26 09:41:35 +00:00
return AccessResult::allowed()->cachePerPermissions();
2014-06-09 23:13:41 +00:00
}
2014-09-17 14:39:29 +00:00
2014-06-09 23:13:41 +00:00
// Sufficiently-privileged users can edit their currently displayed shortcut
2014-09-17 14:39:29 +00:00
// set, but not other sets. They must also be able to access shortcuts.
$may_edit_current_shortcut_set = $account->hasPermission('customize shortcut links') && (!isset($shortcut_set) || $shortcut_set == shortcut_current_displayed_set()) && $account->hasPermission('access shortcuts');
2017-03-28 17:39:27 +00:00
$result = AccessResult::allowedIf($may_edit_current_shortcut_set)->cachePerPermissions();
if (!$result->isAllowed()) {
$result->setReason("The shortcut set must be the currently displayed set for the user and the user must have 'access shortcuts' AND 'customize shortcut links' permissions.");
}
return $result;
2009-10-17 00:51:53 +00:00
}
/**
* Access callback for switching the shortcut set assigned to a user account.
*
2010-02-25 15:58:54 +00:00
* @param object $account
2009-10-17 00:51:53 +00:00
* (optional) The user account whose shortcuts will be switched. If not set,
2010-02-25 15:58:54 +00:00
* permissions will be checked for switching the logged-in user's own
* shortcut set.
*
2014-09-17 14:39:29 +00:00
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
2009-10-17 00:51:53 +00:00
*/
function shortcut_set_switch_access($account = NULL) {
2013-09-16 03:58:06 +00:00
$user = \Drupal::currentUser();
2010-02-25 15:58:54 +00:00
2013-09-04 21:18:30 +00:00
if ($user->hasPermission('administer shortcuts')) {
2010-02-25 15:58:54 +00:00
// Administrators can switch anyone's shortcut set.
2015-03-26 09:41:35 +00:00
return AccessResult::allowed()->cachePerPermissions();
2010-02-25 15:58:54 +00:00
}
2014-06-09 23:13:41 +00:00
if (!$user->hasPermission('access shortcuts')) {
// The user has no permission to use shortcuts.
2015-03-26 09:41:35 +00:00
return AccessResult::neutral()->cachePerPermissions();
2014-06-09 23:13:41 +00:00
}
2013-09-04 21:18:30 +00:00
if (!$user->hasPermission('switch shortcut sets')) {
2010-02-25 15:58:54 +00:00
// The user has no permission to switch anyone's shortcut set.
2015-03-26 09:41:35 +00:00
return AccessResult::neutral()->cachePerPermissions();
2010-02-25 15:58:54 +00:00
}
2014-09-17 14:39:29 +00:00
// Users with the 'switch shortcut sets' permission can switch their own
// shortcuts sets.
if (!isset($account)) {
2015-03-26 09:41:35 +00:00
return AccessResult::allowed()->cachePerPermissions();
2014-09-17 14:39:29 +00:00
}
2015-11-28 15:50:23 +00:00
elseif ($user->id() == $account->id()) {
2015-03-26 09:41:35 +00:00
return AccessResult::allowed()->cachePerPermissions()->cachePerUser();
2010-02-25 15:58:54 +00:00
}
2014-09-17 14:39:29 +00:00
// No opinion.
2015-03-26 09:41:35 +00:00
return AccessResult::neutral()->cachePerPermissions();
2009-10-17 00:51:53 +00:00
}
/**
* Returns the current displayed shortcut set for the provided user account.
*
* @param $account
* (optional) The user account whose shortcuts will be returned. Defaults to
2010-02-25 15:58:54 +00:00
* the currently logged-in user.
*
2009-10-17 00:51:53 +00:00
* @return
* An object representing the shortcut set that should be displayed to the
* current user. If the user does not have an explicit shortcut set defined,
* the default set is returned.
*/
function shortcut_current_displayed_set($account = NULL) {
2017-03-04 01:20:24 +00:00
$shortcut_sets = &drupal_static(__FUNCTION__, []);
2013-10-02 21:42:16 +00:00
$user = \Drupal::currentUser();
2009-10-17 00:51:53 +00:00
if (!isset($account)) {
$account = $user;
}
// Try to return a shortcut set from the static cache.
2013-07-11 17:29:02 +00:00
if (isset($shortcut_sets[$account->id()])) {
return $shortcut_sets[$account->id()];
2009-10-17 00:51:53 +00:00
}
// If none was found, try to find a shortcut set that is explicitly assigned
// to this user.
2019-05-24 06:44:36 +00:00
$shortcut_set_name = \Drupal::entityTypeManager()
2014-03-27 11:54:40 +00:00
->getStorage('shortcut_set')
2013-06-16 09:40:11 +00:00
->getAssignedToUser($account);
2009-11-11 06:56:52 +00:00
if ($shortcut_set_name) {
2014-05-20 09:29:40 +00:00
$shortcut_set = ShortcutSet::load($shortcut_set_name);
2009-11-11 06:56:52 +00:00
}
2009-10-17 00:51:53 +00:00
// Otherwise, use the default set.
2010-01-30 07:59:26 +00:00
else {
2009-10-17 00:51:53 +00:00
$shortcut_set = shortcut_default_set($account);
}
2009-11-11 06:56:52 +00:00
2013-07-11 17:29:02 +00:00
$shortcut_sets[$account->id()] = $shortcut_set;
2009-10-17 00:51:53 +00:00
return $shortcut_set;
}
/**
* Returns the default shortcut set for a given user account.
*
2010-02-25 15:58:54 +00:00
* @param object $account
* (optional) The user account whose default shortcut set will be returned.
* If not provided, the function will return the currently logged-in user's
* default shortcut set.
*
2009-10-17 00:51:53 +00:00
* @return
* An object representing the default shortcut set.
*/
function shortcut_default_set($account = NULL) {
2013-10-02 21:42:16 +00:00
$user = \Drupal::currentUser();
2009-10-17 00:51:53 +00:00
if (!isset($account)) {
$account = $user;
}
2010-02-25 15:58:54 +00:00
2009-10-17 00:51:53 +00:00
// Allow modules to return a default shortcut set name. Since we can only
// have one, we allow the last module which returns a valid result to take
// precedence. If no module returns a valid set, fall back on the site-wide
2010-02-25 15:58:54 +00:00
// default, which is the lowest-numbered shortcut set.
2017-03-04 01:20:24 +00:00
$suggestions = array_reverse(\Drupal::moduleHandler()->invokeAll('shortcut_default_set', [$account]));
2013-01-19 05:26:12 +00:00
$suggestions[] = 'default';
2010-02-25 15:58:54 +00:00
foreach ($suggestions as $name) {
2014-05-20 09:29:40 +00:00
if ($shortcut_set = ShortcutSet::load($name)) {
2009-10-17 00:51:53 +00:00
break;
}
}
2010-02-25 15:58:54 +00:00
2009-10-17 00:51:53 +00:00
return $shortcut_set;
}
/**
* Returns an array of shortcut links, suitable for rendering.
*
2013-12-15 09:51:10 +00:00
* @param \Drupal\shortcut\ShortcutSetInterface $shortcut_set
2009-10-17 00:51:53 +00:00
* (optional) An object representing the set whose links will be displayed.
* If not provided, the user's current set will be displayed.
2013-12-15 09:51:10 +00:00
*
* @return \Drupal\shortcut\ShortcutInterface[]
2009-10-17 00:51:53 +00:00
* An array of shortcut links, in the format returned by the menu system.
*/
function shortcut_renderable_links($shortcut_set = NULL) {
2017-03-04 01:20:24 +00:00
$shortcut_links = [];
2013-12-15 09:51:10 +00:00
2009-10-17 00:51:53 +00:00
if (!isset($shortcut_set)) {
$shortcut_set = shortcut_current_displayed_set();
}
2013-12-15 09:51:10 +00:00
2017-03-04 01:20:24 +00:00
$cache_tags = [];
2015-02-04 12:21:51 +00:00
foreach ($shortcut_set->getShortcuts() as $shortcut) {
2019-02-17 00:00:58 +00:00
$shortcut = \Drupal::service('entity.repository')->getTranslationFromContext($shortcut);
2015-02-06 16:36:47 +00:00
$url = $shortcut->getUrl();
if ($url->access()) {
2017-03-04 01:20:24 +00:00
$links[$shortcut->id()] = [
2015-02-06 16:36:47 +00:00
'type' => 'link',
'title' => $shortcut->label(),
'url' => $shortcut->getUrl(),
2017-03-04 01:20:24 +00:00
];
2015-02-06 16:36:47 +00:00
$cache_tags = Cache::mergeTags($cache_tags, $shortcut->getCacheTags());
}
2013-12-15 09:51:10 +00:00
}
if (!empty($links)) {
2017-03-04 01:20:24 +00:00
$shortcut_links = [
2013-12-15 09:51:10 +00:00
'#theme' => 'links__toolbar_shortcuts',
'#links' => $links,
2017-03-04 01:20:24 +00:00
'#attributes' => [
'class' => ['toolbar-menu'],
],
'#cache' => [
2014-09-25 07:30:31 +00:00
'tags' => $cache_tags,
2017-03-04 01:20:24 +00:00
],
];
2013-12-15 09:51:10 +00:00
}
return $shortcut_links;
2009-10-17 00:51:53 +00:00
}
2012-01-10 03:22:24 +00:00
/**
2013-10-03 20:55:34 +00:00
* Implements hook_preprocess_HOOK() for block templates.
2012-01-10 03:22:24 +00:00
*/
function shortcut_preprocess_block(&$variables) {
2014-04-01 21:14:13 +00:00
if ($variables['configuration']['provider'] == 'shortcut') {
2012-08-03 15:31:18 +00:00
$variables['attributes']['role'] = 'navigation';
2012-01-10 03:22:24 +00:00
}
}
2009-10-17 00:51:53 +00:00
/**
2015-09-30 13:00:49 +00:00
* Implements hook_preprocess_HOOK() for page title templates.
2009-10-17 00:51:53 +00:00
*/
2015-09-30 13:00:49 +00:00
function shortcut_preprocess_page_title(&$variables) {
2011-09-28 03:06:39 +00:00
// Only display the shortcut link if the user has the ability to edit
Issue #2914110 by Berdir, neclimdul, acbramley, yongt9412, Wim Leers, arpad.rozsa, kim.pepper, Fabianx, davidwhthomas, pameeela, kualee, amateescu, jibran, longwave: Shortcut hook_toolbar implementation makes all pages uncacheable
2020-01-15 23:22:23 +00:00
// shortcuts, the feature is enabled for the current theme and if the page's
// actual content is being shown (for example, we do not want to display it on
// "access denied" or "page not found" pages).
if (shortcut_set_edit_access()->isAllowed() && theme_get_setting('third_party_settings.shortcut.module_link') && !\Drupal::request()->attributes->has('exception')) {
2014-11-28 13:38:17 +00:00
$link = Url::fromRouteMatch(\Drupal::routeMatch())->getInternalPath();
2014-10-30 13:07:31 +00:00
$route_match = \Drupal::routeMatch();
2013-12-15 09:51:10 +00:00
2015-09-30 13:00:49 +00:00
// Replicate template_preprocess_html()'s processing to get the title in
// string form, so we can set the default name for the shortcut.
2016-10-12 13:20:39 +00:00
// Strip HTML tags from the title.
$name = trim(strip_tags(render($variables['title'])));
2017-03-04 01:20:24 +00:00
$query = [
2014-02-24 20:12:19 +00:00
'link' => $link,
2015-09-30 13:00:49 +00:00
'name' => $name,
2017-03-04 01:20:24 +00:00
];
2009-10-17 00:51:53 +00:00
$shortcut_set = shortcut_current_displayed_set();
2009-11-11 06:56:52 +00:00
Issue #2914110 by Berdir, neclimdul, acbramley, yongt9412, Wim Leers, arpad.rozsa, kim.pepper, Fabianx, davidwhthomas, pameeela, kualee, amateescu, jibran, longwave: Shortcut hook_toolbar implementation makes all pages uncacheable
2020-01-15 23:22:23 +00:00
// Pages with the add or remove shortcut button need cache invalidation when
// a shortcut is added, edited, or removed.
$cacheability_metadata = CacheableMetadata::createFromRenderArray($variables);
$cacheability_metadata->addCacheTags(\Drupal::entityTypeManager()->getDefinition('shortcut')->getListCacheTags());
$cacheability_metadata->applyTo($variables);
2009-11-11 06:56:52 +00:00
// Check if $link is already a shortcut and set $link_mode accordingly.
2019-05-24 06:44:36 +00:00
$shortcuts = \Drupal::entityTypeManager()->getStorage('shortcut')->loadByProperties(['shortcut_set' => $shortcut_set->id()]);
Issue #2235457 by dawehner, amateescu, hussainweb, Berdir, benjy, Wim Leers, lokapujya, RavindraSingh, Ryan Weal, jibran, Jalandhar: Use link field for shortcut entity
2015-01-27 16:15:59 +00:00
/** @var \Drupal\shortcut\ShortcutInterface $shortcut */
2013-12-15 09:51:10 +00:00
foreach ($shortcuts as $shortcut) {
2015-06-27 07:45:04 +00:00
if (($shortcut_url = $shortcut->getUrl()) && $shortcut_url->isRouted() && $shortcut_url->getRouteName() == $route_match->getRouteName() && $shortcut_url->getRouteParameters() == $route_match->getRawParameters()->all()) {
2013-12-15 09:51:10 +00:00
$shortcut_id = $shortcut->id();
2009-11-11 06:56:52 +00:00
break;
}
}
2013-12-15 09:51:10 +00:00
$link_mode = isset($shortcut_id) ? "remove" : "add";
2009-11-11 06:56:52 +00:00
if ($link_mode == "add") {
2017-03-04 01:20:24 +00:00
$link_text = shortcut_set_switch_access()->isAllowed() ? t('Add to %shortcut_set shortcuts', ['%shortcut_set' => $shortcut_set->label()]) : t('Add to shortcuts');
2013-11-11 11:38:41 +00:00
$route_name = 'shortcut.link_add_inline';
2017-03-04 01:20:24 +00:00
$route_parameters = ['shortcut_set' => $shortcut_set->id()];
2009-11-11 06:56:52 +00:00
}
else {
2013-12-15 09:51:10 +00:00
$query['id'] = $shortcut_id;
2017-03-04 01:20:24 +00:00
$link_text = shortcut_set_switch_access()->isAllowed() ? t('Remove from %shortcut_set shortcuts', ['%shortcut_set' => $shortcut_set->label()]) : t('Remove from shortcuts');
2014-09-08 16:48:41 +00:00
$route_name = 'entity.shortcut.link_delete_inline';
2017-03-04 01:20:24 +00:00
$route_parameters = ['shortcut' => $shortcut_id];
2009-11-11 06:56:52 +00:00
}
Issue #2914110 by Berdir, neclimdul, acbramley, yongt9412, Wim Leers, arpad.rozsa, kim.pepper, Fabianx, davidwhthomas, pameeela, kualee, amateescu, jibran, longwave: Shortcut hook_toolbar implementation makes all pages uncacheable
2020-01-15 23:22:23 +00:00
$query += \Drupal::destination()->getAsArray();
$variables['title_suffix']['add_or_remove_shortcut'] = [
'#attached' => [
'library' => [
'shortcut/drupal.shortcut',
2017-03-04 01:20:24 +00:00
],
Issue #2914110 by Berdir, neclimdul, acbramley, yongt9412, Wim Leers, arpad.rozsa, kim.pepper, Fabianx, davidwhthomas, pameeela, kualee, amateescu, jibran, longwave: Shortcut hook_toolbar implementation makes all pages uncacheable
2020-01-15 23:22:23 +00:00
],
'#type' => 'link',
'#title' => new FormattableMarkup('<span class="shortcut-action__icon"></span><span class="shortcut-action__message">@text</span>', ['@text' => $link_text]),
'#url' => Url::fromRoute($route_name, $route_parameters),
'#options' => ['query' => $query],
'#attributes' => [
'class' => [
'shortcut-action',
'shortcut-action--' . $link_mode,
2017-03-04 01:20:24 +00:00
],
Issue #2914110 by Berdir, neclimdul, acbramley, yongt9412, Wim Leers, arpad.rozsa, kim.pepper, Fabianx, davidwhthomas, pameeela, kualee, amateescu, jibran, longwave: Shortcut hook_toolbar implementation makes all pages uncacheable
2020-01-15 23:22:23 +00:00
],
];
2009-10-17 00:51:53 +00:00
}
2009-11-19 03:57:15 +00:00
}
/**
Issue #1137920 by jessebeach, lewisnyman, tkoleary, Bojhan, webchick, benjifisher, nod_, sjbassett, kathryn531, effulgentsia, Everett Zufelt: fixed toolbar on small screen sizes and redesign toolbar for desktop.
2012-11-21 17:18:57 +00:00
* Implements hook_toolbar().
2009-11-19 03:57:15 +00:00
*/
Issue #1137920 by jessebeach, lewisnyman, tkoleary, Bojhan, webchick, benjifisher, nod_, sjbassett, kathryn531, effulgentsia, Everett Zufelt: fixed toolbar on small screen sizes and redesign toolbar for desktop.
2012-11-21 17:18:57 +00:00
function shortcut_toolbar() {
2014-06-09 23:13:41 +00:00
$user = \Drupal::currentUser();
2015-06-01 16:49:02 +00:00
$items = [];
$items['shortcuts'] = [
'#cache' => [
'contexts' => [
Issue #2914110 by Berdir, neclimdul, acbramley, yongt9412, Wim Leers, arpad.rozsa, kim.pepper, Fabianx, davidwhthomas, pameeela, kualee, amateescu, jibran, longwave: Shortcut hook_toolbar implementation makes all pages uncacheable
2020-01-15 23:22:23 +00:00
'user.permissions',
2015-06-01 16:49:02 +00:00
],
],
];
2014-06-09 23:13:41 +00:00
if ($user->hasPermission('access shortcuts')) {
$shortcut_set = shortcut_current_displayed_set();
Issue #2914110 by Berdir, neclimdul, acbramley, yongt9412, Wim Leers, arpad.rozsa, kim.pepper, Fabianx, davidwhthomas, pameeela, kualee, amateescu, jibran, longwave: Shortcut hook_toolbar implementation makes all pages uncacheable
2020-01-15 23:22:23 +00:00
$items['shortcuts'] += [
'#type' => 'toolbar_item',
'tab' => [
2013-02-01 16:31:47 +00:00
'#type' => 'link',
Issue #2914110 by Berdir, neclimdul, acbramley, yongt9412, Wim Leers, arpad.rozsa, kim.pepper, Fabianx, davidwhthomas, pameeela, kualee, amateescu, jibran, longwave: Shortcut hook_toolbar implementation makes all pages uncacheable
2020-01-15 23:22:23 +00:00
'#title' => t('Shortcuts'),
'#url' => $shortcut_set->toUrl('collection'),
'#attributes' => [
'title' => t('Shortcuts'),
'class' => ['toolbar-icon', 'toolbar-icon-shortcut'],
2017-03-04 01:20:24 +00:00
],
Issue #2914110 by Berdir, neclimdul, acbramley, yongt9412, Wim Leers, arpad.rozsa, kim.pepper, Fabianx, davidwhthomas, pameeela, kualee, amateescu, jibran, longwave: Shortcut hook_toolbar implementation makes all pages uncacheable
2020-01-15 23:22:23 +00:00
],
'tray' => [
'#heading' => t('User-defined shortcuts'),
'children' => [
'#lazy_builder' => ['shortcut.lazy_builders:lazyLinks', []],
'#create_placeholder' => TRUE,
'#cache' => [
'keys' => ['shortcut_set_toolbar_links'],
'contexts' => ['user'],
2017-03-04 01:20:24 +00:00
],
],
Issue #2914110 by Berdir, neclimdul, acbramley, yongt9412, Wim Leers, arpad.rozsa, kim.pepper, Fabianx, davidwhthomas, pameeela, kualee, amateescu, jibran, longwave: Shortcut hook_toolbar implementation makes all pages uncacheable
2020-01-15 23:22:23 +00:00
],
'#weight' => -10,
'#attached' => [
'library' => [
'shortcut/drupal.shortcut',
],
],
];
2013-02-01 16:31:47 +00:00
}
Issue #1137920 by jessebeach, lewisnyman, tkoleary, Bojhan, webchick, benjifisher, nod_, sjbassett, kathryn531, effulgentsia, Everett Zufelt: fixed toolbar on small screen sizes and redesign toolbar for desktop.
2012-11-21 17:18:57 +00:00
return $items;
2009-10-17 00:51:53 +00:00
}
2014-12-10 20:08:40 +00:00
/**
* Implements hook_themes_installed().
*/
function shortcut_themes_installed($theme_list) {
Issue #3079738 by lauriii, saschaeggi, webchick, xjm, andrewmacpherson, shimpy, effulgentsia, Wim Leers, DyanneNova, svettes, rainbreaw, fhaeberle, ckrina, AaronMcHale, justafish, catch, charlieweb82, AntoineH, lot007, pzajacz, kostyashupenko, jasonbarrie, antonellasevero, finnsky, worldlinemine, bnjmnm, RobLoach, Dennis Cohn, huzooka, Archita Arora, joachim, jrockowitz, benjifisher, shaal, Gábor Hojtsy, quiron, L2G2, ccasals, hampercm, if-jds, abhisekmazumdar, Kami Amiga, pivica, zrpnr, BrightBold, imalabya, jhedstrom, Neslee Canil Pinto, maliknaik, junaidmasoodi, Maithri Shetty, pranav73, mandclu, modulist, nod_, philosurfer, phenaproxima, mherchel, mlncn, rafuel92, leymannx, kiboman, Swapnil_Kotwal, anevins, evankay, rfmarcelino, thamas, brianperry, idebr, joelpittet, boulaffasae, alexpott, volkerk, DuneBL, Eli-T, Mahenkvyas22: Add Claro administration theme to core
2019-10-13 20:42:58 +00:00
// Theme settings are not configuration entities and cannot depend on modules
// so to set a module-specific setting, we need to set it with logic.
foreach (['seven', 'claro'] as $theme) {
if (in_array($theme, $theme_list, TRUE)) {
\Drupal::configFactory()->getEditable("$theme.settings")
->set('third_party_settings.shortcut.module_link', TRUE)
->save(TRUE);
2014-12-10 20:08:40 +00:00
}
}
}