diff --git a/menu_block.admin.inc b/menu_block.admin.inc index d79ccb7..0009cea 100644 --- a/menu_block.admin.inc +++ b/menu_block.admin.inc @@ -69,50 +69,6 @@ function _menu_block_form_block_admin_display_form_alter(&$form, $form_state) { } /** - * Menu callback: confirm deletion of menu blocks. - */ -function menu_block_delete($form, &$form_state, $delta = 0) { - $title = _menu_block_format_title(menu_block_get_config($delta)); - $form['block_title'] = array('#type' => 'hidden', '#value' => $title); - $form['delta'] = array('#type' => 'hidden', '#value' => $delta); - - return confirm_form($form, t('Are you sure you want to delete the "%name" block?', array('%name' => $title)), 'admin/structure/block', NULL, t('Delete'), t('Cancel')); -} - -/** - * Deletion of menu blocks. - */ -function menu_block_delete_submit($form, &$form_state) { - // Remove the menu block configuration variables. - $delta = $form_state['values']['delta']; - $block_ids = variable_get('menu_block_ids', array()); - unset($block_ids[array_search($delta, $block_ids)]); - sort($block_ids); - variable_set('menu_block_ids', $block_ids); - variable_del("menu_block_{$delta}_title_link"); - variable_del("menu_block_{$delta}_admin_title"); - variable_del("menu_block_{$delta}_parent"); - variable_del("menu_block_{$delta}_level"); - variable_del("menu_block_{$delta}_follow"); - variable_del("menu_block_{$delta}_depth"); - variable_del("menu_block_{$delta}_expanded"); - variable_del("menu_block_{$delta}_sort"); - - db_delete('block') - ->condition('module', 'menu_block') - ->condition('delta', $delta) - ->execute(); - db_delete('block_role') - ->condition('module', 'menu_block') - ->condition('delta', $delta) - ->execute(); - drupal_set_message(t('The block "%name" has been removed.', array('%name' => $form_state['values']['block_title']))); - cache_clear_all(); - $form_state['redirect'] = 'admin/structure/block'; - return; -} - -/** * Implements hook_block_info(). */ function _menu_block_block_info() { diff --git a/menu_block.inc b/menu_block.inc deleted file mode 100644 index 3ad0ef7..0000000 --- a/menu_block.inc +++ /dev/null @@ -1,218 +0,0 @@ - 'menu_blocks', - - 'menu' => array( - 'menu prefix' => 'admin/structure', - 'menu item' => 'menu_block', - 'menu title' => 'Menu Blocks', - 'menu description' => 'Administer Menu Blocks.', - ), - - 'title singular' => t('menu block'), - 'title singular proper' => t('Menu Block'), - 'title plural' => t('menu blocks'), - 'title plural proper' => t('Menu Blocks'), - - 'form' => array( - 'settings' => 'menu_block_export_ui_form', - ), - - 'export' => array( - 'admin_title' => 'label', - 'admin_description' => 'description', - ), - ); -} - -/** - * Menu Block settings form. - */ -function menu_block_export_ui_form(&$form, &$form_state) { - list($form_state['item']->menu_name, $form_state['item']->parent_mlid) = explode(':', !empty($form_state['item']->parent) ? $form_state['item']->parent : 'main-menu:0'); - - $form['#attached']['js'][] = drupal_get_path('module', 'menu_block') . '/menu-block.js'; - $form['#attached']['css'][] = drupal_get_path('module', 'menu_block') . '/menu-block.admin.css'; - $form['#attached']['library'][] = array('system', 'ui.button'); - - $form['menu-block-wrapper-start'] = array( - '#markup' => ''); - - // Set visibility of advanced options. - foreach (array('title_link', 'follow', 'follow_parent', 'expanded', 'sort', 'parent_mlid') as $key) { - $form[$key]['#states']['visible'][':input[name=display_options]'] = array('value' => 'advanced'); - if (!empty($form_state['item']->{$key})) { - $form['display_options']['#default_value'] = 'advanced'; - } - } -} - -/** - * Validates the parent element of the block configuration form. - */ -function menu_block_configure_form_parent_validate($element, &$form_state) { - // Determine the fixed parent item's menu and mlid. - list($menu_name, $parent_mlid) = explode(':', $form_state['values']['parent_mlid']); - if ($parent_mlid) { - // If mlid is set, its menu overrides the menu_name option. - $form_state['values']['menu_name'] = $menu_name; - } - else { - // Otherwise the menu_name overrides the parent item option. - $form_state['values']['parent_mlid'] = $menu_name . ':0'; - } - // The value of "parent" stored in the database/config array is the menu name - // combined with the optional parent menu item's mlid. - $form_state['values']['parent'] = $form_state['values']['parent_mlid']; -} - -/** - * Validates the follow element of the block configuration form. - */ -function menu_block_configure_form_follow_validate($element, &$form_state) { - // The value of "follow" stored in the database/config array is either FALSE - // or the value of the "follow_parent" form element. - if ($form_state['values']['follow'] && !empty($form_state['values']['follow_parent'])) { - $form_state['values']['follow'] = $form_state['values']['follow_parent']; - } -} diff --git a/plugins/content_types/menu_tree/menu_tree.inc b/plugins/content_types/menu_tree/menu_tree.inc index 1b75582..662e494 100644 --- a/plugins/content_types/menu_tree/menu_tree.inc +++ b/plugins/content_types/menu_tree/menu_tree.inc @@ -101,13 +101,14 @@ function menu_block_menu_tree_content_type_edit_form($form, &$form_state) { $conf = $form_state['conf']; // Load the standard config form. - module_load_include('inc', 'menu_block', 'menu_block.admin'); + module_load_include('inc', 'menu_block', 'plugins/export_ui/menu_block'); // Create a pseudo form state. $sub_form_state = array('values' => $conf); - $form += menu_block_configure_form($form, $sub_form_state); + menu_block_export_ui_form($form, $sub_form_state); - // Hide the menu selector. + // Set and hide the menu selector. $form['menu_name']['#type'] = 'hidden'; + $form['menu_name']['#value'] = $conf['menu_name']; // Set the options to a simple list of menu links for the configured menu. $menus = menu_block_get_all_menus(); @@ -140,8 +141,8 @@ function menu_block_menu_tree_content_type_admin_title($subtype, $conf, $context } else { // Build the menu tree. - module_load_include('inc', 'menu_block', 'menu_block.admin'); - $output = _menu_block_format_title($conf); + $menus = menu_block_get_all_menus(); + $output = t('Menu tree') . ': ' . $menus[$conf['menu_name']]; } return $output; } diff --git a/plugins/export_ui/menu_block.inc b/plugins/export_ui/menu_block.inc new file mode 100644 index 0000000..3ad0ef7 --- /dev/null +++ b/plugins/export_ui/menu_block.inc @@ -0,0 +1,218 @@ + 'menu_blocks', + + 'menu' => array( + 'menu prefix' => 'admin/structure', + 'menu item' => 'menu_block', + 'menu title' => 'Menu Blocks', + 'menu description' => 'Administer Menu Blocks.', + ), + + 'title singular' => t('menu block'), + 'title singular proper' => t('Menu Block'), + 'title plural' => t('menu blocks'), + 'title plural proper' => t('Menu Blocks'), + + 'form' => array( + 'settings' => 'menu_block_export_ui_form', + ), + + 'export' => array( + 'admin_title' => 'label', + 'admin_description' => 'description', + ), + ); +} + +/** + * Menu Block settings form. + */ +function menu_block_export_ui_form(&$form, &$form_state) { + list($form_state['item']->menu_name, $form_state['item']->parent_mlid) = explode(':', !empty($form_state['item']->parent) ? $form_state['item']->parent : 'main-menu:0'); + + $form['#attached']['js'][] = drupal_get_path('module', 'menu_block') . '/menu-block.js'; + $form['#attached']['css'][] = drupal_get_path('module', 'menu_block') . '/menu-block.admin.css'; + $form['#attached']['library'][] = array('system', 'ui.button'); + + $form['menu-block-wrapper-start'] = array( + '#markup' => ''); + + // Set visibility of advanced options. + foreach (array('title_link', 'follow', 'follow_parent', 'expanded', 'sort', 'parent_mlid') as $key) { + $form[$key]['#states']['visible'][':input[name=display_options]'] = array('value' => 'advanced'); + if (!empty($form_state['item']->{$key})) { + $form['display_options']['#default_value'] = 'advanced'; + } + } +} + +/** + * Validates the parent element of the block configuration form. + */ +function menu_block_configure_form_parent_validate($element, &$form_state) { + // Determine the fixed parent item's menu and mlid. + list($menu_name, $parent_mlid) = explode(':', $form_state['values']['parent_mlid']); + if ($parent_mlid) { + // If mlid is set, its menu overrides the menu_name option. + $form_state['values']['menu_name'] = $menu_name; + } + else { + // Otherwise the menu_name overrides the parent item option. + $form_state['values']['parent_mlid'] = $menu_name . ':0'; + } + // The value of "parent" stored in the database/config array is the menu name + // combined with the optional parent menu item's mlid. + $form_state['values']['parent'] = $form_state['values']['parent_mlid']; +} + +/** + * Validates the follow element of the block configuration form. + */ +function menu_block_configure_form_follow_validate($element, &$form_state) { + // The value of "follow" stored in the database/config array is either FALSE + // or the value of the "follow_parent" form element. + if ($form_state['values']['follow'] && !empty($form_state['values']['follow_parent'])) { + $form_state['values']['follow'] = $form_state['values']['follow_parent']; + } +}