function nodesymlinks_admin in NodeSymlinks 7
Same name and namespace in other branches
- 6 nodesymlinks.admin.inc \nodesymlinks_admin()
Admin Settings Page callback.
Just renders a listing of currently active node alternate locations.
1 string reference to 'nodesymlinks_admin'
- nodesymlinks_menu in ./
nodesymlinks.module - Implements hook_menu().
File
- ./
nodesymlinks.admin.inc, line 12 - Administration screen for NodeSymlinks
Code
function nodesymlinks_admin() {
$output = '<p>' . t('All alternate node locations') . '</p>';
$result = db_query("SELECT * FROM {menu_links} WHERE module = :module AND link_path LIKE 'node/%%/mid/%%' ORDER BY link_path ASC", array(
':module' => 'nodesymlinks',
));
$menus = menu_get_menus();
// Render items.
$rows = array();
while ($item = $result
->fetch()) {
$item->options = unserialize($item->options);
$parent_options = menu_parent_options($menus, array(
'mlid' => 0,
));
$row = array();
$parent_option_id = $item->menu_name . ':' . $item->plid;
$parent_name = isset($parent_options[$parent_option_id]) ? $parent_options[$parent_option_id] : '';
$parent_menu_item = menu_link_load($item->plid);
$link_parts = explode('/', $item->link_path);
// Original node, Parent, Alternate location, Weight, Edit link.
$row[] = l($item->options['attributes']['title'], 'node/' . $link_parts[1]);
$row[] = l($parent_name, $parent_menu_item['link_path']);
$row[] = l($item->link_title, $item->link_path);
$row[] = $item->weight;
$row[] = l(t('Edit'), 'node/' . $link_parts[1] . '/edit');
$rows[] = $row;
}
if (empty($rows)) {
$output .= '<p>' . t('No node symlink found.') . '</p>';
}
else {
$header = array(
t('Original Node'),
t('Parent Item'),
t('Link title'),
t('Weight'),
t('Links'),
);
$output .= theme('table', array(
'header' => $header,
'rows' => $rows,
));
}
return $output;
}