function panels_get_pane_links_alter in Panels 7.3
Implements hook_get_pane_links_alter().
File
- ./
panels.module, line 2055 - Core functionality for the Panels engine.
Code
function panels_get_pane_links_alter(&$links, $pane, $content_type) {
// Add links to the Panels pane dropdown menu.
if ($pane->type === "block") {
$prefixed_name = $pane->subtype;
// Breakup the subtype string into parts.
$exploded_subtype = explode('-', $pane->subtype);
// Get the first part of the string.
$subtype_prefix = $exploded_subtype[0];
// Get the first part of the string and add a hyphen.
$subtype_prefix_hyphen = $exploded_subtype[0] . '-';
// Remove the prefix block- to get the name.
$name_of_block = preg_replace("/^{$subtype_prefix_hyphen}/", '', $prefixed_name, 1);
// Check for user added menus created at /admin/structure/menu/add
// menus of that type have a subtype that is prefixed with menu-menu-.
if (substr($prefixed_name, 0, 10) === "menu-menu-") {
// Remove the first prefix menu- from menu-menu- to get the name.
$name_of_block = substr($prefixed_name, 5);
$links['top'][] = array(
'title' => t('Edit block'),
'href' => url('admin/structure/block/manage/' . $subtype_prefix . '/' . $name_of_block . '/configure', array(
'absolute' => TRUE,
)),
'attributes' => array(
'target' => array(
'_blank',
),
),
);
$links['top'][] = array(
'title' => t('Edit menu links'),
'href' => url('admin/structure/menu/manage/' . $name_of_block, array(
'absolute' => TRUE,
)),
'attributes' => array(
'target' => array(
'_blank',
),
),
);
}
elseif (substr($prefixed_name, 0, 5) === "menu-") {
// Remove the first prefix menu- to get the name.
$name_of_block = substr($prefixed_name, 5);
$links['top'][] = array(
'title' => t('Edit block'),
'href' => url('admin/structure/block/manage/' . $subtype_prefix . '/' . $name_of_block . '/configure', array(
'absolute' => TRUE,
)),
'attributes' => array(
'target' => array(
'_blank',
),
),
);
$links['top'][] = array(
'title' => t('Edit menu links'),
'href' => url('admin/structure/menu/manage/' . $name_of_block, array(
'absolute' => TRUE,
)),
'attributes' => array(
'target' => array(
'_blank',
),
),
);
}
elseif (substr($prefixed_name, 0, 7) === "system-") {
// Remove the first prefix system- to get the name.
$name_of_block = substr($prefixed_name, 7);
$names_of_system_menus = menu_list_system_menus();
$links['top'][] = array(
'title' => t('Edit block'),
'href' => url('admin/structure/block/manage/' . $subtype_prefix . '/' . $name_of_block . '/configure', array(
'absolute' => TRUE,
)),
'attributes' => array(
'target' => array(
'_blank',
),
),
);
if (array_key_exists($name_of_block, $names_of_system_menus)) {
$links['top'][] = array(
'title' => t('Edit menu links'),
'href' => url('admin/structure/menu/manage/' . $name_of_block, array(
'absolute' => TRUE,
)),
'attributes' => array(
'target' => array(
'_blank',
),
),
);
}
}
else {
$links['top'][] = array(
'title' => t('Edit block'),
'href' => url('admin/structure/block/manage/' . $subtype_prefix . '/' . $name_of_block . '/configure', array(
'absolute' => TRUE,
)),
'attributes' => array(
'target' => array(
'_blank',
),
),
);
}
}
}