Explorar el Código

remove dependency on menu module

Ted Serbinski hace 17 años
padre
commit
5c6bec1d8a
Se han modificado 2 ficheros con 29 adiciones y 16 borrados
  1. 4 2
      README.txt
  2. 25 14
      simplemenu.module

+ 4 - 2
README.txt

@@ -30,7 +30,7 @@ jQuery Superfish: http://users.tpg.com.au/j_birch/plugins/superfish/
 
 --- CHANGELOG --------------------------------------------------------
 
-4.0, 2007-Nov-21
+4.0, 2007-Nov-22
 ----------------------
 - new CHANGELOG to keep track of changes
 - #156256 upgrade to SuperFish 1.3
@@ -40,4 +40,6 @@ jQuery Superfish: http://users.tpg.com.au/j_birch/plugins/superfish/
 - new option to select which theme to style SimpleMenu with, or provide a custom one
 - #184051 - don't hardcode CSS, add class to body
 - #180106 - fix missing translatable strings"      
-- #144742 - don't show annoying A titles
+- #144742 - don't show annoying A titles     
+- remove dependency on menu module, now works with menu module off
+- 

+ 25 - 14
simplemenu.module

@@ -67,20 +67,24 @@ function simplemenu_perm() {
  * SimpleMenu settings page.
  */
 function simplemenu_admin_settings() {
-  $form['default_menu']['simplemenu_menu'] = array(
-    '#type' => 'select',
-    '#title' => t('Menu'),
-    '#options' => menu_parent_options(0),
-    '#default_value' => variable_get('simplemenu_menu', 1),
-    '#description' => t('Select the menu to display.')
-  );
+  if (module_exists('menu')) {
+    $form['default_menu']['simplemenu_menu'] = array(
+      '#type' => 'select',
+      '#title' => t('Menu'),
+      '#options' => menu_parent_options(0),
+      '#default_value' => variable_get('simplemenu_menu', 1),
+      '#description' => t('Select the menu to display.')
+    );
+  }
 
-  $form['default_menu']['simplemenu_devel'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Add devel module links'),
-    '#default_value' => variable_get('simplemenu_devel', 0),
-    '#description' => t('Add devel module links for those users that can access the devel module.')
-  );
+  if (module_exists('devel')) {
+    $form['default_menu']['simplemenu_devel'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Add devel module links'),
+      '#default_value' => variable_get('simplemenu_devel', 0),
+      '#description' => t('Add devel module links for those users that can access the devel module.')
+    );
+  }
 
   $form['default_menu']['simplemenu_theme'] = array(
     '#type' => 'select',
@@ -131,7 +135,14 @@ function simplemenu_admin_settings() {
 function simplemenu_get_menu() {
   $output = '';
 
-  $menu = simplemenu_menu_tree(variable_get('simplemenu_menu', 1));
+  // if a user turned off menu module but SimpleMenu was previously set
+  // reset variable so a menu appears
+  if (module_exists('menu')) {
+    $menu = simplemenu_menu_tree(variable_get('simplemenu_menu', 1));
+  }
+  else {
+    $menu = simplemenu_menu_tree(1);
+  }
 
   if (!$menu) {
     $menu = '<li><a href="'. url('admin/settings/simplemenu') .'">'. t('No menu items found. Try a different menu as the default.') .'</a></li>';