function nodesymlinks_admin in NodeSymlinks 6
Same name and namespace in other branches
- 7 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 - Implementation of hook_menu().
File
- ./
nodesymlinks.admin.inc, line 8
Code
function nodesymlinks_admin() {
$output = '';
$form = $items = $header = $rows = array();
$mlids = db_query("SELECT mlid FROM {menu_links} WHERE module = 'nodesymlinks' AND link_path LIKE 'node/%%/mid/%%' ORDER BY mlid ASC");
if ($mlids) {
while ($row = db_fetch_array($mlids)) {
$items[$row['mlid']] = menu_link_load($row['mlid']);
}
}
// Render items
if (count($items)) {
$parent_options = menu_parent_options(menu_get_menus(), array(
'mlid' => 0,
));
$output .= '<p>' . t('All alternate node locations') . '</p>';
$header = array(
t('Original Node'),
t('Parent Item'),
t('Link title'),
t('Weight'),
t('Links'),
);
$rows = array();
foreach ($items as $item) {
$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
$row[] = l($item['options']['attributes']['title'], 'node/' . $link_parts[1]);
// Parent
$row[] = l($parent_name, $parent_menu_item['link_path']);
// Alternate locations
$row[] = l($item['link_title'], $item['link_path']);
// Weight
$row[] = $item['weight'];
// Edit link
$row[] = l(t('Edit'), 'node/' . $link_parts[1] . '/edit');
$rows[] = $row;
}
}
else {
$output .= '<p>' . t('No node duplicates found.') . '</p>';
}
$output .= theme('table', $header, $rows);
return $output;
}