* Many fixes as found in many issues.
[#565736] [#412500] [#421732] [#766466] * Passed through coder (fixed tabs, missing spaces) * Added missing hook_uninstall() function to delete variables * Fixed some formatting in code (.module, .inc, .css, .js)
This commit is contained in:
parent
b21bbdb14f
commit
18f4b720a8
157
simplemenu.admin.inc
Normal file
157
simplemenu.admin.inc
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
<?php
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Settings of the simplemenu.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SimpleMenu settings page.
|
||||||
|
*/
|
||||||
|
function simplemenu_admin_settings() {
|
||||||
|
// menu selection
|
||||||
|
$form['default_menu'] = array(
|
||||||
|
'#type' => 'fieldset',
|
||||||
|
'#title' => t('Menu settings'),
|
||||||
|
'#collapsible' => TRUE,
|
||||||
|
'#collapsed' => FALSE,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (module_exists('menu')) {
|
||||||
|
$form['default_menu']['simplemenu_menu'] = array(
|
||||||
|
'#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'),
|
||||||
|
'#description' => t('Select the menu to display.'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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',
|
||||||
|
'#title' => t('Theme'),
|
||||||
|
'#options' => array(
|
||||||
|
'original' => t('original'),
|
||||||
|
'blackblue' => t('black & blue'),
|
||||||
|
'custom' => t('custom'),
|
||||||
|
),
|
||||||
|
'#default_value' => variable_get('simplemenu_theme', 'original'),
|
||||||
|
'#description' => t('Select which theme to use. If you specify custom, you need to define CSS in your theme.'),
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// advanced options
|
||||||
|
$form['advanced'] = array(
|
||||||
|
'#type' => 'fieldset',
|
||||||
|
'#title' => t('Advanced settings'),
|
||||||
|
'#collapsible' => TRUE,
|
||||||
|
'#collapsed' => TRUE,
|
||||||
|
);
|
||||||
|
|
||||||
|
$form['advanced']['simplemenu_uid1'] = array(
|
||||||
|
'#type' => 'checkbox',
|
||||||
|
'#title' => t('Show to User ID 1'),
|
||||||
|
'#description' => t('Check this option to enable simplemenu for user 1 (superuser/administration). This is useful if you want to use a different menu (such as admin_menu) for the superuser/admin and simplemenu for others.'),
|
||||||
|
'#default_value' => variable_get('simplemenu_uid1', 1),
|
||||||
|
);
|
||||||
|
|
||||||
|
$form['advanced']['simplemenu_element'] = array(
|
||||||
|
'#type' => 'textfield',
|
||||||
|
'#title' => t('CSS selector to attach menu to'),
|
||||||
|
'#default_value' => variable_get('simplemenu_element', 'body'),
|
||||||
|
'#description' => t('A valid CSS selector to attach the menu to. <em>Example: body, #primary, div.my-class</em>'),
|
||||||
|
'#required' => TRUE,
|
||||||
|
);
|
||||||
|
|
||||||
|
$form['advanced']['simplemenu_element_method'] = array(
|
||||||
|
'#type' => 'radios',
|
||||||
|
'#title' => t('Attach method'),
|
||||||
|
'#options' => array(
|
||||||
|
'prepend' => t('Prepend'),
|
||||||
|
'append' => t('Append'),
|
||||||
|
),
|
||||||
|
'#default_value' => variable_get('simplemenu_element_method', 'prepend'),
|
||||||
|
'#description' => t('Choose how the menu should be attached to the above selector.'),
|
||||||
|
'#required' => TRUE,
|
||||||
|
);
|
||||||
|
|
||||||
|
// when someone has many themes, this list grows big!
|
||||||
|
$themes = list_themes();
|
||||||
|
$use_list = count($themes) > 15;
|
||||||
|
$form['advanced']['simplemenu_exclusions'] = array(
|
||||||
|
'#type' => $use_list ? 'select' : 'checkboxes',
|
||||||
|
'#title' => t('Theme exclusions'),
|
||||||
|
'#options' => drupal_map_assoc(array_keys($themes)),
|
||||||
|
'#multiple' => $use_list,
|
||||||
|
'#default_value' => variable_get('simplemenu_exclusions', array()),
|
||||||
|
'#description' => t('Select which themes to <strong>not</strong> display the menu. Use this when you have a theme that displays its own admin navigation.'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$form['advanced']['simplemenu_hide_delay'] = array(
|
||||||
|
'#type' => 'textfield',
|
||||||
|
'#title' => t('Hide delay'),
|
||||||
|
'#size' => 4,
|
||||||
|
'#default_value' => variable_get('simplemenu_hide_delay', 800),
|
||||||
|
'#description' => t('How long (in milliseconds) should a menu still appear after losing focus.'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$form['advanced']['simplemenu_effect'] = array(
|
||||||
|
'#type' => 'radios',
|
||||||
|
'#title' => t('Show effect'),
|
||||||
|
'#options' => array(
|
||||||
|
'opacity' => t('Fade'),
|
||||||
|
'height' => t('Slide'),
|
||||||
|
'none' => t('None')
|
||||||
|
),
|
||||||
|
'#default_value' => variable_get('simplemenu_effect', 'opacity'),
|
||||||
|
'#description' => t('The effect used when displaying a menu.'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$form['advanced']['simplemenu_effect_speed'] = array(
|
||||||
|
'#type' => 'radios',
|
||||||
|
'#title' => t('Show speed'),
|
||||||
|
'#options' => array('slow' => t('Slow'), 'medium' => t('Medium'), 'fast' => t('Fast')),
|
||||||
|
'#default_value' => variable_get('simplemenu_effect_speed', 'fast'),
|
||||||
|
'#description' => t('The speed of the effect, not used when "none" is set to show effect.'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$form['advanced']['simplemenu_detect_popop'] = array(
|
||||||
|
'#type' => 'checkbox',
|
||||||
|
'#title' => t('Detect pop-up windows'),
|
||||||
|
'#default_value' => variable_get('simplemenu_detect_popop', 1),
|
||||||
|
'#description' => t("Choose whether SimpleMenu should attempt to detect if it is inside of a pop-up window. If enabled, SimpleMenu will not display if it is inside of a pop-up window."),
|
||||||
|
);
|
||||||
|
|
||||||
|
$form['advanced']['simplemenu_visibility_operator'] = array(
|
||||||
|
'#type' => 'radios',
|
||||||
|
'#title' => t('Show block on specific pages'),
|
||||||
|
'#default_value' => variable_get('simplemenu_visibility_operator', 0),
|
||||||
|
'#options' => array(
|
||||||
|
0 => t('Show on every page except the listed pages.'),
|
||||||
|
1 => t('Show on only the listed pages.'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$form['advanced']['simplemenu_visibility_pages'] = array(
|
||||||
|
'#type' => 'textarea',
|
||||||
|
'#title' => t('Pages'),
|
||||||
|
'#default_value' => variable_get('simplemenu_visibility_pages', ''),
|
||||||
|
'#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.",
|
||||||
|
array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
|
||||||
|
'#wysiwyg' => FALSE,
|
||||||
|
);
|
||||||
|
|
||||||
|
return system_settings_form($form);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -6,49 +6,58 @@
|
|||||||
|
|
||||||
/*** ESSENTIAL STYLES ***/
|
/*** ESSENTIAL STYLES ***/
|
||||||
#simplemenu, #simplemenu * {
|
#simplemenu, #simplemenu * {
|
||||||
margin:0;
|
margin: 0;
|
||||||
padding:0;
|
padding: 0;
|
||||||
list-style:none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#simplemenu {
|
#simplemenu {
|
||||||
line-height:1.0;
|
line-height: 1.0;
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
}
|
}
|
||||||
|
|
||||||
#simplemenu ul {
|
#simplemenu ul {
|
||||||
position:absolute;
|
position: absolute;
|
||||||
top:-999em;
|
top: -999em;
|
||||||
width:14em;
|
width: 14em;
|
||||||
font-size:1em;
|
font-size: 1em;
|
||||||
line-height:1em;
|
line-height: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#simplemenu ul li,
|
#simplemenu ul li,
|
||||||
#simplemenu a {
|
#simplemenu a {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#simplemenu li {
|
#simplemenu li {
|
||||||
float:left;
|
float: left;
|
||||||
position:relative;
|
position: relative;
|
||||||
z-index:99;
|
z-index: 99;
|
||||||
}
|
}
|
||||||
|
|
||||||
#simplemenu a {
|
#simplemenu a {
|
||||||
display:block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
#simplemenu li:hover ul,
|
#simplemenu li:hover ul,
|
||||||
ul#simplemenu li.sfHover ul {
|
ul#simplemenu li.sfHover ul {
|
||||||
left:0px;
|
left: 0px;
|
||||||
top:21px;
|
top: 21px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#simplemenu li:hover li ul,
|
#simplemenu li:hover li ul,
|
||||||
#simplemenu li.sfHover li ul {
|
#simplemenu li.sfHover li ul {
|
||||||
top:-999em;
|
top: -999em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#simplemenu li li:hover ul,
|
#simplemenu li li:hover ul,
|
||||||
ul#simplemenu li li.sfHover ul {
|
ul#simplemenu li li.sfHover ul {
|
||||||
left:14em;
|
left: 14em;
|
||||||
top:-1px;
|
top: -1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.superfish li:hover ul,
|
.superfish li:hover ul,
|
||||||
.superfish li li:hover ul {
|
.superfish li li:hover ul {
|
||||||
top: -999em;
|
top: -999em;
|
||||||
}
|
}
|
||||||
|
@ -2,3 +2,10 @@
|
|||||||
name = SimpleMenu
|
name = SimpleMenu
|
||||||
description = Creates a menu bar that is displayed at the top of every page.
|
description = Creates a menu bar that is displayed at the top of every page.
|
||||||
core = 6.x
|
core = 6.x
|
||||||
|
|
||||||
|
; Information added by drupal.org packaging script on 2009-04-02
|
||||||
|
version = "6.x-1.x-dev"
|
||||||
|
core = "6.x"
|
||||||
|
project = "simplemenu"
|
||||||
|
datestamp = "1238675022"
|
||||||
|
|
||||||
|
@ -1,14 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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().
|
* Implementation of hook_update_N().
|
||||||
*/
|
*/
|
||||||
function simplemenu_update_6001() {
|
function simplemenu_update_6001() {
|
||||||
// if navigation menu was used in Drupal 5 use the same in Drupal 6.
|
// if navigation menu was used in Drupal 5 use the same in Drupal 6.
|
||||||
// otherwise, we can't do anything.
|
// otherwise, we can't do anything.
|
||||||
if(variable_get('simplemenu_menu', 1) == 1) {
|
if (variable_get('simplemenu_menu', 1) == 1) {
|
||||||
variable_set('simplemenu_menu', 'navigation:0');
|
variable_set('simplemenu_menu', 'navigation:0');
|
||||||
}
|
}
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// vim: ts=2 sw=2 et syntax=php
|
||||||
|
@ -3,9 +3,13 @@
|
|||||||
Drupal.behaviors.simplemenuAttach = function(context) {
|
Drupal.behaviors.simplemenuAttach = function(context) {
|
||||||
// If detect pop-ups setting is enabled and we are in a pop-up window
|
// If detect pop-ups setting is enabled and we are in a pop-up window
|
||||||
if (Drupal.settings.simplemenu.detectPopup && window.opener) {
|
if (Drupal.settings.simplemenu.detectPopup && window.opener) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($('body').hasClass('simplemenu-enabled')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// get the element to add the menu to
|
// get the element to add the menu to
|
||||||
var element = Drupal.settings.simplemenu.element;
|
var element = Drupal.settings.simplemenu.element;
|
||||||
var menu = $(simplemenu).attr("id", "simplemenu").addClass('clear-block');
|
var menu = $(simplemenu).attr("id", "simplemenu").addClass('clear-block');
|
||||||
@ -29,25 +33,26 @@ Drupal.behaviors.simplemenuAttach = function(context) {
|
|||||||
|
|
||||||
// Build menu
|
// Build menu
|
||||||
$(menu)
|
$(menu)
|
||||||
.superfish( {
|
.superfish({
|
||||||
|
pathClass: 'current',
|
||||||
animation: animation,
|
animation: animation,
|
||||||
delay: Drupal.settings.simplemenu.hideDelay,
|
delay: Drupal.settings.simplemenu.hideDelay,
|
||||||
speed: Drupal.settings.simplemenu.effectSpeed
|
speed: Drupal.settings.simplemenu.effectSpeed
|
||||||
} )
|
})
|
||||||
.find(">li:has(ul)")
|
.find(">li:has(ul)")
|
||||||
.mouseover(function(){
|
.mouseover(function(){
|
||||||
$("ul", this).bgIframe();
|
$("ul", this).bgIframe();
|
||||||
})
|
})
|
||||||
.find("a")
|
.find("a")
|
||||||
.focus(function(){
|
.focus(function(){
|
||||||
$("ul", $(".nav>li:has(ul)")).bgIframe();
|
$("ul", $(".nav>li:has(ul)")).bgIframe();
|
||||||
})
|
})
|
||||||
.end()
|
.end()
|
||||||
.end()
|
.end()
|
||||||
.find("a")
|
.find("a")
|
||||||
.removeAttr('title');
|
.removeAttr('title');
|
||||||
|
|
||||||
$('#simplemenu').children('li.expanded').addClass('root');
|
$('#simplemenu').children('li.expanded').addClass('root');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -60,4 +65,4 @@ Drupal.behaviors.simplemenuAttach = function(context) {
|
|||||||
*
|
*
|
||||||
* Version 2.1.1
|
* Version 2.1.1
|
||||||
*/
|
*/
|
||||||
(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);
|
(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);
|
||||||
|
@ -17,8 +17,9 @@ function simplemenu_menu() {
|
|||||||
'description' => 'Select the menu to display.',
|
'description' => 'Select the menu to display.',
|
||||||
'page callback' => 'drupal_get_form',
|
'page callback' => 'drupal_get_form',
|
||||||
'page arguments' => array('simplemenu_admin_settings'),
|
'page arguments' => array('simplemenu_admin_settings'),
|
||||||
'access arguments' => array('administer simplemenu')
|
'access arguments' => array('administer simplemenu'),
|
||||||
);
|
'file' => 'simplemenu.admin.inc',
|
||||||
|
);
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
@ -28,16 +29,17 @@ function simplemenu_menu() {
|
|||||||
*/
|
*/
|
||||||
function simplemenu_enabled() {
|
function simplemenu_enabled() {
|
||||||
static $enabled;
|
static $enabled;
|
||||||
|
|
||||||
if(!isset($enabled)) {
|
if (!isset($enabled)) {
|
||||||
global $theme;
|
global $theme;
|
||||||
$exclusions = variable_get('simplemenu_exclusions', array());
|
$exclusions = variable_get('simplemenu_exclusions', array());
|
||||||
$enabled = (user_access('view simplemenu')
|
$enabled = (user_access('view simplemenu')
|
||||||
&& (!isset($exclusions[$theme]) || !$exclusions[$theme])
|
&& (!isset($exclusions[$theme]) || !$exclusions[$theme])
|
||||||
&& _simplemenu_page_visibility());
|
&& _simplemenu_page_visibility()
|
||||||
|
&& _simplemenu_superuser_active());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $enabled;
|
return $enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,10 +47,10 @@ function simplemenu_enabled() {
|
|||||||
*/
|
*/
|
||||||
function simplemenu_init() {
|
function simplemenu_init() {
|
||||||
// do a simple access check here, since theme isn't available to check yet
|
// do a simple access check here, since theme isn't available to check yet
|
||||||
if (user_access('view simplemenu')) {
|
if (user_access('view simplemenu') && simplemenu_enabled()) {
|
||||||
$path = drupal_get_path('module', 'simplemenu');
|
$path = drupal_get_path('module', 'simplemenu');
|
||||||
$simplemenu_theme = variable_get('simplemenu_theme', 'original');
|
|
||||||
drupal_add_css($path .'/simplemenu.css');
|
drupal_add_css($path .'/simplemenu.css');
|
||||||
|
$simplemenu_theme = variable_get('simplemenu_theme', 'original');
|
||||||
|
|
||||||
if ($simplemenu_theme != 'custom') {
|
if ($simplemenu_theme != 'custom') {
|
||||||
drupal_add_css($path .'/themes/'. $simplemenu_theme .'/'. $simplemenu_theme .'.css');
|
drupal_add_css($path .'/themes/'. $simplemenu_theme .'/'. $simplemenu_theme .'.css');
|
||||||
@ -63,29 +65,29 @@ function simplemenu_init() {
|
|||||||
'detectPopup' => variable_get('simplemenu_detect_popop', 1),
|
'detectPopup' => variable_get('simplemenu_detect_popop', 1),
|
||||||
);
|
);
|
||||||
|
|
||||||
drupal_add_js(array('simplemenu' => $settings), 'setting');
|
drupal_add_js(array('simplemenu' => $settings), 'setting');
|
||||||
drupal_add_js($path .'/simplemenu.js');
|
drupal_add_js($path .'/simplemenu.js');
|
||||||
drupal_add_js($path .'/superfish.js');
|
drupal_add_js($path .'/superfish.js');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of hook_footer().
|
* Implementation of hook_footer().
|
||||||
*
|
*
|
||||||
* This has been broken off of simplemenu_init() because simplemenu_get_menu()
|
* This has been broken off of simplemenu_init() because simplemenu_get_menu()
|
||||||
* calls simplemenu_menu_tree() which calls menu_tree_output() which has several
|
* calls simplemenu_menu_tree() which calls menu_tree_output() which has several
|
||||||
* calls to theme(). This initializes the theme system too early causing hard
|
* calls to theme(). This initializes the theme system too early causing hard
|
||||||
* to track bugs.
|
* to track bugs.
|
||||||
*
|
*
|
||||||
* @see http://drupal.org/node/219910
|
* @see http://drupal.org/node/219910
|
||||||
*/
|
*/
|
||||||
function simplemenu_footer() {
|
function simplemenu_footer() {
|
||||||
if(simplemenu_enabled()) {
|
if (simplemenu_enabled()) {
|
||||||
$simplemenu = drupal_to_js(simplemenu_get_menu());
|
$simplemenu = drupal_to_js(simplemenu_get_menu());
|
||||||
$path = base_path() . drupal_get_path('module', 'simplemenu');
|
$path = base_path() . drupal_get_path('module', 'simplemenu');
|
||||||
|
|
||||||
$output = "<script type=\"text/javascript\">var simplemenu = $simplemenu;</script>\n";
|
$output = "<script type=\"text/javascript\">var simplemenu = $simplemenu;</script>\n";
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,127 +99,6 @@ function simplemenu_perm() {
|
|||||||
return array('view simplemenu', 'administer simplemenu');
|
return array('view simplemenu', 'administer simplemenu');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* SimpleMenu settings page.
|
|
||||||
*/
|
|
||||||
function simplemenu_admin_settings() {
|
|
||||||
if (module_exists('menu')) {
|
|
||||||
$form['default_menu']['simplemenu_menu'] = array(
|
|
||||||
'#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'),
|
|
||||||
'#description' => t('Select the menu to display.')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
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',
|
|
||||||
'#title' => t('Theme'),
|
|
||||||
'#options' => array(
|
|
||||||
'original' => t('original'),
|
|
||||||
'blackblue' => t('black & blue'),
|
|
||||||
'custom' => t('custom'),
|
|
||||||
),
|
|
||||||
'#default_value' => variable_get('simplemenu_theme', 'original'),
|
|
||||||
'#description' => t('Select which theme to use. If you specify custom, you need to define CSS in your theme.')
|
|
||||||
);
|
|
||||||
|
|
||||||
$form['default_menu']['advanced'] = array(
|
|
||||||
'#type' => 'fieldset',
|
|
||||||
'#title' => t('Advanced settings'),
|
|
||||||
'#collapsible' => TRUE,
|
|
||||||
'#collapsed' => TRUE
|
|
||||||
);
|
|
||||||
|
|
||||||
$form['default_menu']['advanced']['simplemenu_element'] = array(
|
|
||||||
'#type' => 'textfield',
|
|
||||||
'#title' => t('CSS selector to attach menu to'),
|
|
||||||
'#default_value' => variable_get('simplemenu_element', 'body'),
|
|
||||||
'#description' => t('A valid CSS selector to attach the menu to. <em>Example: body, #primary, div.my-class</em>'),
|
|
||||||
'#required' => TRUE
|
|
||||||
);
|
|
||||||
|
|
||||||
$form['default_menu']['advanced']['simplemenu_element_method'] = array(
|
|
||||||
'#type' => 'radios',
|
|
||||||
'#title' => t('Attach method'),
|
|
||||||
'#options' => array(
|
|
||||||
'prepend' => t('Prepend'),
|
|
||||||
'append' => t('Append'),
|
|
||||||
),
|
|
||||||
'#default_value' => variable_get('simplemenu_element_method', 'prepend'),
|
|
||||||
'#description' => t('Choose how the menu should be attached to the above selector.'),
|
|
||||||
'#required' => TRUE
|
|
||||||
);
|
|
||||||
|
|
||||||
$form['default_menu']['advanced']['simplemenu_exclusions'] = array(
|
|
||||||
'#type' => 'checkboxes',
|
|
||||||
'#title' => t('Theme exclusions'),
|
|
||||||
'#options' => drupal_map_assoc(array_keys(list_themes())),
|
|
||||||
'#default_value' => variable_get('simplemenu_exclusions', array()),
|
|
||||||
'#description' => t('Select which themes to <strong>not</strong> display the menu. Use this when you have a theme that displays its own admin navigation.'),
|
|
||||||
);
|
|
||||||
|
|
||||||
$form['default_menu']['advanced']['simplemenu_hide_delay'] = array(
|
|
||||||
'#type' => 'textfield',
|
|
||||||
'#title' => t('Hide delay'),
|
|
||||||
'#size' => 4,
|
|
||||||
'#default_value' => variable_get('simplemenu_hide_delay', 800),
|
|
||||||
'#description' => t('How long (in milliseconds) should a menu still appear after losing focus.')
|
|
||||||
);
|
|
||||||
|
|
||||||
$form['default_menu']['advanced']['simplemenu_effect'] = array(
|
|
||||||
'#type' => 'radios',
|
|
||||||
'#title' => t('Show effect'),
|
|
||||||
'#options' => array('opacity' => t('Fade'), 'height' => t('Slide'), 'none' => t('None')),
|
|
||||||
'#default_value' => variable_get('simplemenu_effect', 'opacity'),
|
|
||||||
'#description' => t('The effect used when displaying a menu.')
|
|
||||||
);
|
|
||||||
|
|
||||||
$form['default_menu']['advanced']['simplemenu_effect_speed'] = array(
|
|
||||||
'#type' => 'radios',
|
|
||||||
'#title' => t('Show speed'),
|
|
||||||
'#options' => array('slow' => t('Slow'), 'medium' => t('Medium'), 'fast' => t('Fast')),
|
|
||||||
'#default_value' => variable_get('simplemenu_effect_speed', 'fast'),
|
|
||||||
'#description' => t('The speed of the effect, not used when "none" is set to show effect.')
|
|
||||||
);
|
|
||||||
|
|
||||||
$form['default_menu']['advanced']['simplemenu_detect_popop'] = array(
|
|
||||||
'#type' => 'checkbox',
|
|
||||||
'#title' => t('Detect pop-up windows'),
|
|
||||||
'#default_value' => variable_get('simplemenu_detect_popop', 1),
|
|
||||||
'#description' => t("Choose whether SimpleMenu should attempt to detect if it is inside of a pop-up window. If enabled, SimpleMenu will not display if it is inside of a pop-up window."),
|
|
||||||
);
|
|
||||||
|
|
||||||
$form['default_menu']['advanced']['simplemenu_visibility_operator'] = array(
|
|
||||||
'#type' => 'radios',
|
|
||||||
'#title' => t('Show block on specific pages'),
|
|
||||||
'#default_value' => variable_get('simplemenu_visibility_operator', 0),
|
|
||||||
'#options' => array(
|
|
||||||
0 => t('Show on every page except the listed pages.'),
|
|
||||||
1 => t('Show on only the listed pages.')
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
$form['default_menu']['advanced']['simplemenu_visibility_pages'] = array(
|
|
||||||
'#type' => 'textarea',
|
|
||||||
'#title' => t('Pages'),
|
|
||||||
'#default_value' => variable_get('simplemenu_visibility_pages', ''),
|
|
||||||
'#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
|
|
||||||
);
|
|
||||||
|
|
||||||
return system_settings_form($form);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render an HTML list of links for a given menu.
|
* Render an HTML list of links for a given menu.
|
||||||
*/
|
*/
|
||||||
@ -232,14 +113,14 @@ function simplemenu_get_menu() {
|
|||||||
if (!$menu) {
|
if (!$menu) {
|
||||||
$menu = '<li><a href="'. url('admin/settings/simplemenu') .'">'. t('No menu items found. Try a different menu as the default.') .'</a></li>';
|
$menu = '<li><a href="'. url('admin/settings/simplemenu') .'">'. t('No menu items found. Try a different menu as the default.') .'</a></li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is ugly, I know, but it is the only way I can see to get the additional
|
// This is ugly, I know, but it is the only way I can see to get the additional
|
||||||
// links inside the <ul> tags
|
// links inside the <ul> tags
|
||||||
if($devel = simplemenu_get_devel()) {
|
if ($devel = simplemenu_get_devel()) {
|
||||||
$pos = strpos($menu, '>') + 1;
|
$pos = strpos($menu, '>') + 1;
|
||||||
$menu = substr($menu, 0, $pos) . $devel .substr($menu, $pos);
|
$menu = substr($menu, 0, $pos) . $devel . substr($menu, $pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
$output .= $menu;
|
$output .= $menu;
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
@ -254,11 +135,11 @@ function simplemenu_get_menu() {
|
|||||||
function simplemenu_menu_tree($menu_name = 'navigation:0') {
|
function simplemenu_menu_tree($menu_name = 'navigation:0') {
|
||||||
static $menu_output = array();
|
static $menu_output = array();
|
||||||
|
|
||||||
if (!isset($menu_output[$menu_name])) {
|
if (!isset($menu_output[$menu_name])) {
|
||||||
$tree = simplemenu_tree_all_data($menu_name);
|
$tree = simplemenu_tree_all_data($menu_name);
|
||||||
$menu_output[$menu_name] = menu_tree_output($tree);
|
$menu_output[$menu_name] = menu_tree_output($tree);
|
||||||
}
|
}
|
||||||
return $menu_output[$menu_name];
|
return $menu_output[$menu_name];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -272,7 +153,7 @@ function simplemenu_menu_tree($menu_name = 'navigation:0') {
|
|||||||
*/
|
*/
|
||||||
function simplemenu_tree_all_data($root_menu = 'navigation:0') {
|
function simplemenu_tree_all_data($root_menu = 'navigation:0') {
|
||||||
static $tree = array();
|
static $tree = array();
|
||||||
|
|
||||||
list($menu_name, $mlid) = explode(':', $root_menu);
|
list($menu_name, $mlid) = explode(':', $root_menu);
|
||||||
|
|
||||||
// Generate the cache ID.
|
// Generate the cache ID.
|
||||||
@ -336,7 +217,7 @@ function simplemenu_get_devel() {
|
|||||||
$output .= '</li>';
|
$output .= '</li>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,7 +229,7 @@ function simplemenu_get_devel() {
|
|||||||
function _simplemenu_page_visibility() {
|
function _simplemenu_page_visibility() {
|
||||||
$operator = variable_get('simplemenu_visibility_operator', 0);
|
$operator = variable_get('simplemenu_visibility_operator', 0);
|
||||||
$pages = variable_get('simplemenu_visibility_pages', '');
|
$pages = variable_get('simplemenu_visibility_pages', '');
|
||||||
|
|
||||||
if ($pages) {
|
if ($pages) {
|
||||||
$path = drupal_get_path_alias($_GET['q']);
|
$path = drupal_get_path_alias($_GET['q']);
|
||||||
// Compare with the internal and path alias (if any).
|
// Compare with the internal and path alias (if any).
|
||||||
@ -359,11 +240,21 @@ function _simplemenu_page_visibility() {
|
|||||||
// When $operator has a value of 0, the menu is displayed on
|
// When $operator has a value of 0, the menu is displayed on
|
||||||
// all pages except those listed in $pages. When set to 1, it
|
// all pages except those listed in $pages. When set to 1, it
|
||||||
// is displayed only on those pages listed in $pages.
|
// is displayed only on those pages listed in $pages.
|
||||||
$page_match = !($operator xor $page_match);
|
$page_match = !($operator ^ $page_match);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$page_match = TRUE;
|
$page_match = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $page_match;
|
return $page_match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the superuser/admin should be shown simplemenu.
|
||||||
|
*/
|
||||||
|
function _simplemenu_superuser_active() {
|
||||||
|
global $user;
|
||||||
|
return $user->uid != 1 || variable_get('simplemenu_uid1', 1) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// vim: ts=2 sw=2 et syntax=php
|
||||||
|
Loading…
x
Reference in New Issue
Block a user