Commit 65348abd authored by profix898's avatar profix898

- task: menu parent selector (#269398)

parent 7aad04f4
...@@ -111,7 +111,8 @@ function gallery_menu_build_links($rebuild = FALSE) { ...@@ -111,7 +111,8 @@ function gallery_menu_build_links($rebuild = FALSE) {
// Derive array of link items from G2 album tree // Derive array of link items from G2 album tree
$items = array(); $items = array();
$depth = variable_get('gallery_menu_depth', 3); $depth = variable_get('gallery_menu_depth', 3);
$menu_name = variable_get('gallery_menu_menu', 'navigation'); $default_mlid = db_result(db_query('SELECT mlid FROM {menu_links} WHERE link_path = \'gallery\''));
$menu_parent = variable_get('gallery_menu_parent', 'navigation:'. $default_mlid);
$tree = gallery_album_tree(NULL, $depth ? $depth : NULL); $tree = gallery_album_tree(NULL, $depth ? $depth : NULL);
_gallery_menu_traverse($tree, $items); _gallery_menu_traverse($tree, $items);
...@@ -136,7 +137,10 @@ function gallery_menu_build_links($rebuild = FALSE) { ...@@ -136,7 +137,10 @@ function gallery_menu_build_links($rebuild = FALSE) {
} }
else { else {
// Add new item // Add new item
$item['menu_name'] = $menu_name; list($item['menu_name'], $item['plid']) = explode(':', $menu_parent);
if (count(explode('/', $item['link_path'])) > 2) {
unset($item['plid']);
}
menu_link_save($item); menu_link_save($item);
} }
} }
...@@ -225,13 +229,23 @@ function _gallery_menu_settings() { ...@@ -225,13 +229,23 @@ function _gallery_menu_settings() {
'#collapsible' => TRUE, '#collapsible' => TRUE,
'#collapsed' => TRUE '#collapsed' => TRUE
); );
$menus = array_filter(menu_get_menus()); // Get a menu tree and remove all gallery items
$form['menu']['gallery_menu_menu'] = array( $options = menu_parent_options(menu_get_menus(), array('mlid' => 0));
$result = db_query('SELECT menu_name, mlid FROM {menu_links} WHERE link_path LIKE \'gallery/%\'');
while ($item = db_fetch_object($result)) {
unset($options[$item->menu_name .':'. $item->mlid]);
}
//
$default_mlid = db_result(db_query('SELECT mlid FROM {menu_links} WHERE link_path = \'gallery\''));
$form['menu']['gallery_menu_parent'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Menu'), '#title' => t('Parent item'),
'#default_value' => variable_get('gallery_menu_menu', 'navigation'), '#default_value' => variable_get('gallery_menu_parent', 'navigation:'. $default_mlid),
'#options' => $menus, '#options' => $options,
'#description' => t('Select the menu where gallery menu items will be added.') '#description' => t('The maximum depth for an item and all its children is fixed at !maxdepth. Some menu
items may not be available as parents if selecting them would exceed this limit.',
array('!maxdepth' => MENU_MAX_DEPTH)),
'#attributes' => array('class' => 'menu-title-select'),
); );
$form['menu']['gallery_menu_depth'] = array( $form['menu']['gallery_menu_depth'] = array(
'#type' => 'select', '#type' => 'select',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment