- On popular demand, patch #10178 by jhriggs: made it possible to expand menu items.
parent
6f7aa2a095
commit
c214cee319
|
@ -80,6 +80,7 @@ define('MENU_MODIFIABLE_BY_ADMIN', 0x0010);
|
|||
define('MENU_MODIFIED_BY_ADMIN', 0x0020);
|
||||
define('MENU_CREATED_BY_ADMIN', 0x0040);
|
||||
define('MENU_IS_LOCAL_TASK', 0x0080);
|
||||
define('MENU_EXPANDED', 0x0100);
|
||||
define('MENU_LINKS_TO_PARENT', 0x0200);
|
||||
|
||||
/**
|
||||
|
@ -554,10 +555,10 @@ function theme_menu_tree($pid = 1, $all = FALSE) {
|
|||
if (isset($menu['visible'][$pid]) && $menu['visible'][$pid]['children']) {
|
||||
|
||||
foreach ($menu['visible'][$pid]['children'] as $mid) {
|
||||
$style = (count($menu['visible'][$mid]['children']) ? (menu_in_active_trail($mid) ? 'expanded' : 'collapsed') : 'leaf');
|
||||
$style = (count($menu['visible'][$mid]['children']) ? ((menu_in_active_trail($mid) || ($menu['visible'][$mid]['type'] & MENU_EXPANDED)) ? 'expanded' : 'collapsed') : 'leaf');
|
||||
$output .= "<li class=\"$style\">";
|
||||
$output .= theme('menu_item', $mid);
|
||||
if ($all || menu_in_active_trail($mid)) {
|
||||
if ($all || menu_in_active_trail($mid) || ($menu['visible'][$mid]['type'] & MENU_EXPANDED)) {
|
||||
$output .= theme('menu_tree', $mid);
|
||||
}
|
||||
$output .= "</li>\n";
|
||||
|
@ -820,7 +821,7 @@ function _menu_build_visible_tree($pid = 0) {
|
|||
$allowed = _menu_item_is_accessible($pid);
|
||||
|
||||
if (($parent['type'] & MENU_IS_ROOT) || ($visible && $allowed)) {
|
||||
$_menu['visible'][$pid] = array('title' => $parent['title'], 'path' => $parent['path'], 'children' => $children);
|
||||
$_menu['visible'][$pid] = array('title' => $parent['title'], 'path' => $parent['path'], 'children' => $children, 'type' => $parent['type']);
|
||||
foreach ($children as $mid) {
|
||||
$_menu['visible'][$mid]['pid'] = $pid;
|
||||
}
|
||||
|
|
|
@ -282,6 +282,8 @@ function menu_edit_item_form($edit) {
|
|||
$form .= form_hidden('path', $edit['path']);
|
||||
}
|
||||
|
||||
$form .= form_checkbox(t('Expanded'), 'expanded', 1, ($edit['type'] & MENU_EXPANDED), t('If selected and this menu item has children, the menu will always appear expanded.'));
|
||||
|
||||
// Generate a list of possible parents (not including this item or descendants).
|
||||
$options = menu_parent_options($edit['mid']);
|
||||
$form .= form_select(t('Parent item'), 'pid', $edit['pid'], $options);
|
||||
|
@ -324,6 +326,13 @@ function menu_edit_item_validate($edit) {
|
|||
function menu_edit_item_save($edit) {
|
||||
$menu = menu_get_menu();
|
||||
|
||||
if ($edit['expanded']) {
|
||||
$edit['type'] |= MENU_EXPANDED;
|
||||
}
|
||||
else {
|
||||
$edit['type'] &= ~MENU_EXPANDED;
|
||||
}
|
||||
|
||||
if ($edit['mid']) {
|
||||
db_query("UPDATE {menu} SET pid = %d, path = '%s', title = '%s', description = '%s', weight = %d, type = %d WHERE mid = %d", $edit['pid'], $edit['path'], $edit['title'], $edit['description'], $edit['weight'], $edit['type'] | MENU_MODIFIED_BY_ADMIN, $edit['mid']);
|
||||
drupal_set_message(t('Updated menu item %title.', array('%title' => '<em>'. $edit['title'] .'</em>')));
|
||||
|
@ -345,7 +354,7 @@ function menu_edit_item_save($edit) {
|
|||
*/
|
||||
function menu_overview_tree() {
|
||||
$menu = menu_get_menu();
|
||||
$header = array(t('Menu item'), array('data' => t('Operations'), 'colspan' => 3));
|
||||
$header = array(t('Menu item'), t('Expanded'), array('data' => t('Operations'), 'colspan' => 3));
|
||||
$output = '';
|
||||
|
||||
foreach ($menu['items'][0]['children'] as $mid) {
|
||||
|
@ -430,7 +439,7 @@ function menu_overview_tree_rows($pid = 0, $depth = 0) {
|
|||
}
|
||||
|
||||
if ($menu['items'][$mid]['type'] & (MENU_MODIFIABLE_BY_ADMIN | MENU_VISIBLE_IN_TREE)) {
|
||||
$row = array(array('data' => $title, 'class' => $class));
|
||||
$row = array(array('data' => $title, 'class' => $class), array('data' => ($menu['items'][$mid]['children'] ? (($menu['items'][$mid]['type'] & MENU_EXPANDED) ? t('Yes') : t('No')) : ''), 'class' => $class));
|
||||
foreach ($operations as $operation) {
|
||||
$operation['class'] = $class;
|
||||
$row[] = $operation;
|
||||
|
|
|
@ -282,6 +282,8 @@ function menu_edit_item_form($edit) {
|
|||
$form .= form_hidden('path', $edit['path']);
|
||||
}
|
||||
|
||||
$form .= form_checkbox(t('Expanded'), 'expanded', 1, ($edit['type'] & MENU_EXPANDED), t('If selected and this menu item has children, the menu will always appear expanded.'));
|
||||
|
||||
// Generate a list of possible parents (not including this item or descendants).
|
||||
$options = menu_parent_options($edit['mid']);
|
||||
$form .= form_select(t('Parent item'), 'pid', $edit['pid'], $options);
|
||||
|
@ -324,6 +326,13 @@ function menu_edit_item_validate($edit) {
|
|||
function menu_edit_item_save($edit) {
|
||||
$menu = menu_get_menu();
|
||||
|
||||
if ($edit['expanded']) {
|
||||
$edit['type'] |= MENU_EXPANDED;
|
||||
}
|
||||
else {
|
||||
$edit['type'] &= ~MENU_EXPANDED;
|
||||
}
|
||||
|
||||
if ($edit['mid']) {
|
||||
db_query("UPDATE {menu} SET pid = %d, path = '%s', title = '%s', description = '%s', weight = %d, type = %d WHERE mid = %d", $edit['pid'], $edit['path'], $edit['title'], $edit['description'], $edit['weight'], $edit['type'] | MENU_MODIFIED_BY_ADMIN, $edit['mid']);
|
||||
drupal_set_message(t('Updated menu item %title.', array('%title' => '<em>'. $edit['title'] .'</em>')));
|
||||
|
@ -345,7 +354,7 @@ function menu_edit_item_save($edit) {
|
|||
*/
|
||||
function menu_overview_tree() {
|
||||
$menu = menu_get_menu();
|
||||
$header = array(t('Menu item'), array('data' => t('Operations'), 'colspan' => 3));
|
||||
$header = array(t('Menu item'), t('Expanded'), array('data' => t('Operations'), 'colspan' => 3));
|
||||
$output = '';
|
||||
|
||||
foreach ($menu['items'][0]['children'] as $mid) {
|
||||
|
@ -430,7 +439,7 @@ function menu_overview_tree_rows($pid = 0, $depth = 0) {
|
|||
}
|
||||
|
||||
if ($menu['items'][$mid]['type'] & (MENU_MODIFIABLE_BY_ADMIN | MENU_VISIBLE_IN_TREE)) {
|
||||
$row = array(array('data' => $title, 'class' => $class));
|
||||
$row = array(array('data' => $title, 'class' => $class), array('data' => ($menu['items'][$mid]['children'] ? (($menu['items'][$mid]['type'] & MENU_EXPANDED) ? t('Yes') : t('No')) : ''), 'class' => $class));
|
||||
foreach ($operations as $operation) {
|
||||
$operation['class'] = $class;
|
||||
$row[] = $operation;
|
||||
|
|
Loading…
Reference in New Issue