shortcut_page_build
- Versions
- 7
shortcut_page_build(&$page)
Implement hook_page_build().
Code
modules/shortcut/shortcut.module, line 506
<?php
function shortcut_page_build(&$page) {
if (shortcut_set_edit_access()) {
$link = $_GET['q'];
$query_parameters = drupal_get_query_parameters();
if (!empty($query_parameters)) {
$link .= '?' . drupal_http_build_query($query_parameters);
}
$query = array(
'link' => $link,
'name' => drupal_get_title(),
);
$query += drupal_get_destination();
$shortcut_set = shortcut_current_displayed_set();
// Check if $link is already a shortcut and set $link_mode accordingly.
foreach ($shortcut_set->links as $shortcut) {
if ($link == $shortcut['link_path']) {
$mlid = $shortcut['mlid'];
break;
}
}
$link_mode = isset($mlid) ? "remove" : "add";
if ($link_mode == "add") {
$query['token'] = drupal_get_token('shortcut-add-link');
$link_text = shortcut_set_switch_access() ? t('Add to %shortcut_set shortcuts', array('%shortcut_set' => $shortcut_set->title)) : t('Add to shortcuts');
$link_path = 'admin/config/system/shortcut/' . $shortcut_set->set_name . '/add-link-inline';
}
else {
$query['mlid'] = $mlid;
$link_text = shortcut_set_switch_access() ? t('Remove from %shortcut_set shortcuts', array('%shortcut_set' => $shortcut_set->title)) : t('Remove from shortcuts');
$link_path = 'admin/config/system/shortcut/link/' . $mlid . '/delete';
}
$page['add_or_remove_shortcut'] = array(
'#prefix' => '<div class="add-or-remove-shortcuts ' . $link_mode . '-shortcut">',
'#type' => 'link',
'#title' => '<span class="icon"></span><span class="text">' . $link_text . '</span>',
'#href' => $link_path,
'#options' => array('query' => $query, 'html' => TRUE),
'#suffix' => '</div>',
);
}
}
?>Login or register to post comments 