diff --git a/simplemenu.admin.inc b/simplemenu.admin.inc
index b3eb97e0..9dc5029a 100644
--- a/simplemenu.admin.inc
+++ b/simplemenu.admin.inc
@@ -25,14 +25,14 @@ function simplemenu_admin_settings() {
'#type' => 'select',
'#title' => t('Menu'),
'#options' => menu_parent_options(menu_get_menus(), array('mlid' => 0)), // return complete tree
- '#default_value' => variable_get('simplemenu_menu', 'navigation:0'),
+ '#default_value' => variable_get('simplemenu_menu', 'management:0'),
'#description' => t('Select the menu to display.'),
'#weight' => -1,
);
}
- $themes = file_scan_directory($simplemenu_path . '/themes', '.*',
- array('.', '..', 'CVS', '.svn'), 0, FALSE, 'basename');
+ $themes = file_scan_directory($simplemenu_path . '/themes', '%.*%',
+ array('key' => 'filename', 'recurse' => FALSE));
$theme_selection = array('custom' => 'custom');
foreach ($themes as $name => $ignore) {
$theme_selection[$name] = $name;
@@ -66,7 +66,7 @@ function simplemenu_admin_settings() {
'#default_value' => variable_get('simplemenu_fix', 'scroll'),
'#description' => t('Select the mode to use. The default is to let the menu scroll with the page.')
. '
' . t('WARNING') . ': '
- . t('The At the Top/Bottom options prevent you from ever seeing the bottom of your drop-down menus. In other words, if you have many modules installed, it is not unlikely that your Site configuration menu will not fit the screen and the last few entries won\'t be accessible via Simplemenu.'),
+ . t('The At the Top option prevents you from ever seeing the bottom of your drop-down menus when they are too long. In other words, if you have many modules installed, it is not unlikely that some drop down menus will not fit the height of the screen and the last few entries won\'t be accessible via Simplemenu.'),
);
$form['settings']['simplemenu_hide_delay'] = array(
@@ -113,8 +113,8 @@ function simplemenu_admin_settings() {
'#default_value' => variable_get('simplemenu_uid1', 1),
);
- $superfish_js = file_scan_directory($simplemenu_path, '^superfish-[0-9.]*\.js$',
- array('.', '..', 'CVS', '.svn'), 0, FALSE, 'basename');
+ $superfish_js = file_scan_directory($simplemenu_path, '%^superfish-[0-9.]*\.js$%',
+ array('key' => 'filename', 'recurse' => FALSE));
$superfish = array('custom' => 'custom or theme');
foreach ($superfish_js as $name => $ignore) {
$superfish[$name] = $name;
@@ -135,7 +135,7 @@ function simplemenu_admin_settings() {
'#type' => 'select',
'#title' => t('Scope of simplemenu variable'),
'#options' => $scope,
- '#description' => t('By default, the simplemenu
variable is put in the footer (backward compatible.) It is also possible to put it in the header instead.'),
+ '#description' => t('By default, the simplemenu
variable is put in the footer (backward compatible.) It is possible to put it in the header instead.'),
'#default_value' => variable_get('simplemenu_menu_scope', 'footer'),
);
diff --git a/simplemenu.info b/simplemenu.info
index f927d0c0..a629313d 100644
--- a/simplemenu.info
+++ b/simplemenu.info
@@ -1,5 +1,14 @@
; $Id$
name = SimpleMenu
description = Displays a menu bar with drop down items. By default it appears at the top of the screen with the Navigation menu.
-core = 6.x
+core = 7.x
package = Menu
+files[] = simplemenu.admin.inc
+files[] = simplemenu.install
+files[] = simplemenu.module
+configure = admin/config/simplemenu
+
+; Normally aded by Drupal
+version = "7.x-1.x-dev"
+project = simplemenu
+datestamp = "1274876110"
diff --git a/simplemenu.install b/simplemenu.install
index fabbc263..7b3f6239 100644
--- a/simplemenu.install
+++ b/simplemenu.install
@@ -5,49 +5,8 @@
* Get rid of the variables used by simple menu.
*/
function simplemenu_uninstall() {
- db_query("DELETE FROM {variable} WHERE name LIKE 'simplemenu_%'");
-}
-
-/**
- * Implementation of hook_update_N().
- */
-function simplemenu_update_6001() {
- // if navigation menu was used in Drupal 5 use the same in Drupal 6.
- // otherwise, we can't do anything.
- if (variable_get('simplemenu_menu', 1) == 1) {
- variable_set('simplemenu_menu', 'navigation:0');
- }
- return array();
-}
-
-/**
- * Implementation of hook_update_N().
- */
-function simplemenu_update_6002() {
- // fix variable name
- variable_set('simplemenu_detect_popup', variable_get('simplemenu_detect_popop', 1));
- variable_del('simplemenu_detect_popop');
- return array();
-}
-
-/**
- * Implementation of hook_update_N().
- */
-function simplemenu_update_6003() {
- if (variable_get('simplemenu_devel', 0)) {
- drupal_set_message('The Simplemenu Devel is now defined in a separate module. Enable that module if you want to use the devel menu.', 'warning');
- }
- variable_del('simplemenu_devel');
- return array();
-}
-
-/**
- * Implementation of hook_update_N().
- */
-function simplemenu_update_6004() {
- // enable multiple menus selection
- variable_set('simplemenu_menus', array(variable_get('simplemenu_menu', 'navigation:0')));
- return array();
+ // XXX
+ //db_query("DELETE FROM {variable} WHERE name LIKE 'simplemenu_%'");
}
// vim: ts=2 sw=2 et syntax=php
diff --git a/simplemenu.js b/simplemenu.js
index 098281eb..3617e8a7 100644
--- a/simplemenu.js
+++ b/simplemenu.js
@@ -1,61 +1,65 @@
// $Id$
+(function($){
-Drupal.behaviors.simplemenuAttach = function(context) {
- // If detect pop-ups setting is enabled and we are in a pop-up window
- if (Drupal.settings.simplemenu.detectPopup && window.opener) {
- return;
- }
-
- if ($('body').hasClass('simplemenu-enabled')) {
- return;
- }
-
- // get the element to add the menu to
- var element = Drupal.settings.simplemenu.element;
- var menu = $(simplemenu);
-
- switch (Drupal.settings.simplemenu.placement) {
- case 'prepend':
- $(menu).prependTo(element);
- break;
- case 'append':
- $(menu).appendTo(element);
- break;
- case 'replace':
- $(element).html(menu);
- break;
- }
-
- $('body').addClass('simplemenu-enabled');
+Drupal.behaviors.simplemenuAttach = {
+ attach: function(context, settings) {
+ // If detect pop-ups setting is enabled and we are in a pop-up window
+ if (settings.simplemenu.detectPopup && window.opener) {
+ return;
+ }
- var animation = {};
- animation[Drupal.settings.simplemenu.effect] = 'toggle';
+ if ($('body').hasClass('simplemenu-enabled')) {
+ return;
+ }
- // Build menu
- $(menu)
- .find('#simplemenu')
- .superfish({
- pathClass: 'current',
- animation: animation,
- delay: Drupal.settings.simplemenu.hideDelay,
- speed: Drupal.settings.simplemenu.effectSpeed,
- autoArrows: false
- })
- .find(">li:has(ul)")
- .mouseover(function(){
- $("ul", this).bgIframe();
+ // get the element to add the menu to
+ var element = settings.simplemenu.element;
+ var menu = $(simplemenu);
+
+ switch (settings.simplemenu.placement) {
+ case 'prepend':
+ $(menu).prependTo(element);
+ break;
+ case 'append':
+ $(menu).appendTo(element);
+ break;
+ case 'replace':
+ $(element).html(menu);
+ break;
+ }
+
+ $('body').addClass('simplemenu-enabled');
+
+ var animation = {};
+ animation[settings.simplemenu.effect] = 'toggle';
+
+ // Build menu
+ $(menu)
+ .find('#simplemenu')
+ .superfish({
+ pathClass: 'current',
+ animation: animation,
+ delay: settings.simplemenu.hideDelay,
+ speed: settings.simplemenu.effectSpeed,
+ autoArrows: false
})
- .find("a")
- .focus(function(){
- $("ul", $(".nav>li:has(ul)")).bgIframe();
+ .find(">li:has(ul)")
+ .mouseover(function(){
+ $("ul", this).bgIframe();
})
+ .find("a")
+ .focus(function(){
+ $("ul", $(".nav>li:has(ul)")).bgIframe();
+ })
+ .end()
.end()
- .end()
- .find("a")
- .removeAttr('title');
-
- $('#simplemenu').children('li.expanded').addClass('root');
+ .find("a")
+ .removeAttr('title');
+
+ $('#simplemenu').children('li.expanded').addClass('root');
+ }
};
+})(jQuery);
/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
diff --git a/simplemenu.module b/simplemenu.module
index de46ffd7..45a7098f 100644
--- a/simplemenu.module
+++ b/simplemenu.module
@@ -12,7 +12,7 @@
function simplemenu_menu() {
$items = array();
- $items['admin/settings/simplemenu'] = array(
+ $items['admin/config/simplemenu'] = array(
'title' => 'SimpleMenu',
'description' => 'Select the menu to display.',
'page callback' => 'drupal_get_form',
@@ -65,34 +65,34 @@ function simplemenu_init() {
* to be sent inline.
*/
function _simplemenu_add_menu() {
- $simplemenu = 'var simplemenu=' . drupal_to_js(simplemenu_get_menu()) . ';';
+ // XXX -- should we put that in the settings instead? why put it in its own variable?
+ $simplemenu = 'var simplemenu=' . drupal_json_encode(simplemenu_get_menu()) . ';';
$has_file = variable_get('simplemenu_cache_menu', TRUE);
if ($has_file) {
- $js_path = file_create_path('js'); // same path as concatenated Core JS
- $js_md5 = md5($simplemenu); // this is a lot faster than transferring the menu for each page!
- $js_filename = $js_path . '/simplemenu-' . $js_md5 . '.js';
-
- $has_file = file_check_directory($js_path, FILE_CREATE_DIRECTORY);
- if ($has_file) {
- // The old way was to send the whole menu each time
- if (!file_exists($js_filename)) {
- // use LOCK so concurrent writes don't mess up the file
- @file_put_contents($js_filename, $simplemenu);
- $has_file = file_exists($js_filename);
- }
- else {
- $has_file = TRUE;
+ $js_hash = drupal_hash_base64($simplemenu);
+ $js_path = 'public://js'; // same path as concatenated Core JS
+ $js_filename = $js_path . '/simplemenu_' . $js_hash . '.js';
+ if (!file_exists($js_filename)) {
+ file_prepare_directory($js_path, FILE_CREATE_DIRECTORY);
+ if (!file_unmanaged_save_data($simplemenu, $js_filename, FILE_EXISTS_REPLACE)) {
+ $has_file = FALSE;
}
}
}
- $scope = variable_get('simplemenu_menu_scope', 'footer');
+ $options = array(
+ 'scope' => variable_get('simplemenu_menu_scope', 'footer'),
+ // 'version' => ?, -- could we make use of the version?
+ );
if ($has_file) {
- drupal_add_js($js_filename, 'module', $scope);
+ //$options['type'] = 'file'; -- default
+ drupal_add_js($js_filename, $options);
}
else {
- drupal_add_js($simplemenu, 'inline', $scope);
+ // inline adds the value as is (untouched)
+ $options['type'] = 'inline';
+ drupal_add_js($simplemenu, $options);
}
}
@@ -111,8 +111,8 @@ function _simplemenu_add_css() {
global $user;
$simplemenu_path = drupal_get_path('module', 'simplemenu');
- $css_path = file_create_path('css'); // same path as concatenated Core CSS
- if (file_check_directory($css_path, FILE_CREATE_DIRECTORY)) {
+ $css_path = 'public://css'; // same path as concatenated Core CSS
+ if (file_prepare_directory($css_path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
$fix = variable_get('simplemenu_fix', 'scroll');
// XXX add a variable simplemenu_update which is set to TRUE whenever
@@ -139,8 +139,8 @@ function _simplemenu_add_css() {
}
$css = file_get_contents($simplemenu_path . '/simplemenu.css.tpl');
$css = strtr($css, $tags);
- $css_md5 = md5($css);
- $output_filename = $css_path . '/simplemenu-' . $css_md5 . '.css';
+ $css_hash = hash('sha256', $css);
+ $output_filename = $css_path . '/simplemenu-' . $css_hash . '.css';
if (!file_exists($output_filename)) {
// new content, create a new file
file_put_contents($output_filename, $css);
@@ -231,15 +231,16 @@ function _simplemenu_add_js() {
'hideDelay' => variable_get('simplemenu_hide_delay', 800),
'detectPopup' => variable_get('simplemenu_detect_popup', 1),
);
- drupal_add_js(array('simplemenu' => $settings), 'setting');
+ drupal_add_js(array('simplemenu' => $settings), array('type' => 'setting'));
// Simplemenu
- drupal_add_js($simplemenu_path . '/simplemenu.js');
+ drupal_add_js($simplemenu_path . '/simplemenu.js', array('version' => '1.2'));
// Superfish
$superfish = variable_get('simplemenu_superfish_version', 'superfish-1.4.1.js');
if ($superfish != 'custom') {
- drupal_add_js($simplemenu_path . '/' . $superfish);
+ $sf_version = str_replace(array('superfish-', '.js'), '', $superfish);
+ drupal_add_js($simplemenu_path . '/' . $superfish, array('version' => $sf_version));
}
}
@@ -282,7 +283,7 @@ function simplemenu_get_menu() {
// if a user turned off menu module but SimpleMenu was previously set
// reset variable so a menu appears
- $all_menus = array(variable_get('simplemenu_menu', 'navigation:0'));
+ $all_menus = array(variable_get('simplemenu_menu', 'management:0'));
drupal_alter('simplemenu_menus', $all_menus);
if (count($all_menus) > 1) {
@@ -316,9 +317,11 @@ function simplemenu_get_menu() {
// allow other modules to modify the menu tree
drupal_alter('simplemenu_tree', $tree);
+ $tree = simplemenu_tree_remove_hidden($tree);
// now generate the output
- $menu = menu_tree_output($tree);
+ $menu_form = menu_tree_output($tree);
+ $menu = drupal_render($menu_form);
if (!$menu) {
$menu = '