function power_menu_token_values in Power Menu 6
Implementation of hook_token_values().
Parameters
$type:
$object:
$options:
File
- ./
power_menu.module, line 583 - This module provides some additional menu features. The features are not actually new, but are part of other modules. it's though very cumbersome to creating a new menu item, because one has to go to all the different places to configure these…
Code
function power_menu_token_values($type, $object = NULL, $options = array()) {
if ($type == 'node') {
$node = $object;
$pms = power_menu_get_pm_menus();
foreach (array_filter($pms) as $pm) {
$mlid = db_result(db_query("SELECT mlid FROM {menu_links} WHERE menu_name='%s' AND link_path='%s'", array(
$pm,
"node/{$node->nid}",
)));
if ($mlid > 0) {
//we have a node that is in the menu
$href = db_result(db_query("select ml2.link_path FROM {menu_links} ml INNER JOIN {menu_links} ml2 ON ml.plid = ml2.mlid WHERE ml.mlid=%d", $mlid));
}
else {
if (($href = db_result(db_query("SELECT path FROM {power_menu} WHERE nodetype='%s' AND menu_name = '%s'", array(
$node->type,
$pm,
)))) != '') {
// a node type that belongs to a defined menu entry
}
else {
if (!empty($node->taxonomy)) {
// a node that belongs to the taxonomy
$href = _power_menu_get_node_location_taxonomy($node, $pm);
}
}
}
if (!module_exists('pm_external_url_aliases')) {
$tokens["power_menu_path_{$pm}-path"] = $href ? drupal_get_path_alias($href, $node->language) : 'content-default';
}
else {
if ($href) {
$path_alias = drupal_get_path_alias($href, $node->language);
if ($path_alias != $href) {
$tokens["power_menu_path_{$pm}-path"] = $path_alias;
}
else {
$path_alias = pm_external_url_aliases_get_alias($href);
if ($path_alias != $href) {
$tokens["power_menu_path_{$pm}-path"] = $path_alias;
}
else {
$tokens["power_menu_path_{$pm}-path"] = 'content-default';
}
}
}
else {
$tokens["power_menu_path_{$pm}-path"] = 'content-default';
}
}
}
return $tokens;
}
}