function _om_maximenu_admin in OM Maximenu 8
Same name and namespace in other branches
- 6 inc/om_maximenu.admin.inc \_om_maximenu_admin()
- 7 inc/om_maximenu.admin.inc \_om_maximenu_admin()
Admin Form
1 call to _om_maximenu_admin()
- om_maximenu_admin in inc/
om_maximenu.admin.inc - Admin Form - Simple Editing
File
- inc/
om_maximenu.admin.inc, line 179 - OM Maximenu Admin Configuration
Code
function _om_maximenu_admin($menu_content = array()) {
global $user;
static $first_menu = 0;
$skin = om_maximenu_skin_get();
$roles = $menu_content['roles'];
$menu_key = $menu_content['menu_key'];
$code = 'om-u' . $user->uid . '-' . mt_rand();
$out = array();
// delete field is for saved menus only
if (trim($menu_content['title']) != 'New Menu') {
$out['delete'] = array(
'#type' => 'checkbox',
'#title' => t('Delete this menu.'),
'#default_value' => 0,
);
}
$out['code'] = array(
'#type' => 'hidden',
'#default_value' => isset($menu_content['code']) ? trim($menu_content['code']) : $code,
);
$out['title'] = array(
'#type' => 'textfield',
'#title' => t('Menu Title'),
'#required' => TRUE,
'#default_value' => isset($menu_content['title']) ? stripslashes(trim($menu_content['title'])) : 'New Menu',
);
$out['action'] = array(
'#type' => 'select',
'#title' => t('Mouse Action'),
'#options' => array(
'hover' => 'Hover',
'hover_fade' => 'Hover (fade/slow)',
'click_fast' => 'Click (fast)',
'click_slow' => 'Click (slow)',
),
'#default_value' => isset($menu_content['action']) ? $menu_content['action'] : 'hover',
'#description' => t('The link content will show depending on mouse action.'),
);
$out['skin'] = array(
'#type' => 'select',
'#title' => t('Skin'),
'#options' => $skin,
'#default_value' => isset($menu_content['skin']) ? $menu_content['skin'] : 'bubble',
'#description' => t('Currently, supports dropdown/floating submenu only.'),
);
$out['style'] = array(
'#type' => 'select',
'#title' => t('Style'),
'#attributes' => array(
'class' => array(
'om-maximenu-style',
),
),
'#default_value' => isset($menu_content['style']) ? $menu_content['style'] : '',
'#options' => array(
'' => 'Dropdown',
'normal' => 'Tab',
'scrollh' => 'Tab with Horizontal Scroll',
'scrollv' => 'Tab with Vertical Scroll',
'roundabout' => 'Round About',
'accordion' => 'Horizontal Accordion',
'modal' => 'Modal Window',
),
'#description' => t('
For Tabs, Round About and Accordion, all menu links will be converted to span tags, <br />
all settings on menu path, path query and anchor will be ignored.<br />
The default height is 100px, you can override this by your own css. <br />
Tab style height can be overriden by adding this to your stylesheet: <br />
Ex. #om-maximenu-your-menu .om-maximenu-tabbed-content { height: 200px; } <br />
<ul>
<li><strong>Dropdown</strong> - blocks will appear as submenus</li>
<li><strong>Tab</strong> - Normal tab without any effect</li>
<li><strong>Tab with Horizontal Scroll</strong> - menu content scrolls left and right</li>
<li><strong>Tab with Vertical Scroll</strong> - menu content scrolls up and down</li>
<li><strong>Round About</strong> - menu content moves in circular motion</li>
<li><strong>Horizontal Accordion</strong> - menu link and content scrolls left and right (accordion style)</li>
<li><strong>Modal Window</strong> - attached blocks will be displayed in popup window</li>
</ul>
'),
);
$out['style_options'] = array(
'#type' => 'fieldset',
'#title' => t('Dropdown Options'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#attributes' => array(
'class' => array(
'om-maximenu-nontabbed-options',
),
'style' => !isset($menu_content['style']) || $menu_content['style'] == '' ? 'display: block;' : 'display: none;',
),
);
$out['style_options']['disabled'] = array(
'#type' => 'checkbox',
'#title' => t('Disable link when active'),
'#default_value' => isset($menu_content['disabled']) ? $menu_content['disabled'] : 0,
'#description' => t('This will make the link unclickable when active.'),
);
$out['style_options']['displace'] = array(
'#type' => 'checkbox',
'#title' => t('Displace'),
'#default_value' => isset($menu_content['displace']) ? $menu_content['displace'] : 0,
'#description' => t('This will move the next link item from its position, which creates a sliding menu effect.'),
);
$out['style_options']['delay'] = array(
'#type' => 'textfield',
'#title' => t('Hover Delay'),
'#default_value' => isset($menu_content['delay']) ? $menu_content['delay'] : 1000,
'#description' => t('This is used for Hover (fade/slow), 1 sec = 1000'),
);
$out['style_options']['fadeout'] = array(
'#type' => 'checkbox',
'#title' => t('Fadeout'),
'#default_value' => isset($menu_content['fadeout']) ? $menu_content['fadeout'] : 1,
'#description' => t('This is used for Hover (fade/slow), if unchecked, the submenu will stay open.'),
);
$out['other_options'] = array(
'#type' => 'fieldset',
'#title' => t('Other Options'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#attributes' => array(
'class' => array(
'om-maximenu-other-options',
),
'style' => isset($menu_content['style']) && $menu_content['style'] != 'roundabout' && $menu_content['style'] != 'accordion' ? 'display: block;' : 'display: none;',
),
);
$out['other_options']['active'] = array(
'#type' => 'checkbox',
'#title' => t('Add "active-trail" to menu li when submenus are active'),
'#default_value' => isset($menu_content['active']) ? $menu_content['active'] : 0,
'#description' => t('This will only be applied to menus with attached menu blocks'),
);
$out['other_options']['longmenu'] = array(
'#type' => 'select',
'#title' => t('Long horizontal menu options'),
'#options' => array(
'' => 'No',
'hover' => 'Hover',
'prev_next' => 'Prev/Next',
),
'#default_value' => isset($menu_content['longmenu']) ? $menu_content['longmenu'] : '',
'#description' => t('
Set this menu to scroll if it won\'t fit the container.
<ul>
<li><strong>Hover</strong> - long menus will scroll on hover</li>
<li><strong>Prev/Next</strong> - adds prev and next buttons for long menus</li>
</ul>
<strong>Note:</strong> If used in menu with dropdown style, it will hide all its attached blocks.
'),
);
$out['other_options']['animated_bg'] = array(
'#type' => 'checkbox',
'#title' => t('Animated Background'),
'#default_value' => isset($menu_content['animated_bg']) ? $menu_content['animated_bg'] : 0,
'#description' => t('Links with sliding background'),
);
$out['other_options']['animated_link'] = array(
'#type' => 'checkbox',
'#title' => t('Animated Link'),
'#default_value' => isset($menu_content['animated_link']) ? $menu_content['animated_link'] : 0,
'#description' => t('Links sliding vertically'),
);
$out['other_options']['jiggle'] = array(
'#type' => 'checkbox',
'#title' => t('Jiggly Links'),
'#default_value' => isset($menu_content['jiggle']) ? $menu_content['jiggle'] : 0,
'#description' => t('Make the links jiggle on hover.'),
);
$out['other_options']['modal_content'] = array(
'#type' => 'checkbox',
'#title' => t('Render Modal Content'),
'#default_value' => isset($menu_content['modal_content']) ? $menu_content['modal_content'] : 0,
'#description' => t('For Style: Modal Window with Output: Block - checking this will force render Modal content even if its menu is not visible in any region.'),
);
$out['scroll'] = array(
'#type' => 'checkbox',
'#title' => t('Auto-Scroll Menu'),
'#default_value' => isset($menu_content['scroll']) ? $menu_content['scroll'] : 0,
'#description' => t('Make your menu automatically scroll to stay on screen.'),
);
$output_options = array(
'block' => 'Block',
'float' => 'Floating',
);
// Only 1 main menu is allowed
// the first menu is always the priority to be with main menu option
$main_menu_switch = $first_menu == 0 || isset($menu_content['main_menu']) && $menu_content['main_menu'] == 1 ? 1 : 0;
if ($main_menu_switch == 1) {
$output_options = array(
'block' => 'Block',
'float' => 'Floating',
'main_menu' => 'Main Menu',
);
$main_menu_option_desc = t('<li><strong>Main Menu</strong> - You have the option to make this as your main menu. <br />
This will automatically replace existing main menu for OM Base Theme. <br />
For other themes, add this <?php print $main_menu_tree; ?> to your page.tpl.php</li>');
}
else {
$main_menu_option_desc = '';
}
$first_menu++;
// ensures above is executed once of value is 0
$out['output'] = array(
'#type' => 'select',
'#title' => t('Output Options'),
'#options' => $output_options,
'#default_value' => isset($menu_content['output']) ? $menu_content['output'] : 'block',
'#attributes' => array(
'class' => array(
'om-maximenu-output',
),
),
'#description' => t('
<ul>
<li><strong>Block</strong> - will appear in the block list.</li>
<li><strong>Floating</strong> - goes left, middle, right of the screen.</li>
' . $main_menu_option_desc . '
</ul>
'),
);
$out['block_options'] = array(
'#type' => 'fieldset',
'#title' => t('Block Options'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#attributes' => array(
'class' => array(
'om-maximenu-block-options',
),
'style' => $menu_content['output'] == 'block' ? 'display: block;' : 'display: none;',
),
);
$out['block_options']['stacking'] = array(
'#type' => 'select',
'#title' => t('Stacking'),
'#options' => array(
'row' => 'Row',
'column' => 'Column',
),
'#default_value' => isset($menu_content['block_options']['stacking']) ? $menu_content['block_options']['stacking'] : 'row',
'#description' => t('
<ul>
<li><strong>Row</strong> - all links in 1 row</li>
<li><strong>Column</strong> -all links in 1 column</li>
</ul>
'),
);
$out['block_options']['direction'] = array(
'#type' => 'select',
'#title' => t('Block Menu Direction'),
'#options' => array(
'block-down' => 'Dropdown',
'block-up' => 'Dropup',
'block-right' => 'Right',
'block-left' => 'Left',
),
'#default_value' => isset($menu_content['block_options']['direction']) ? $menu_content['block_options']['direction'] : 'block-down',
'#attributes' => array(
'id' => 'block-options-direction-' . $menu_key,
),
'#description' => t('OM Maximenu will popup on this direction. Applicable only with dropdown style.'),
);
$theme_default = variable_get('theme_default', 'garland');
$region_none = array(
'' => 'none',
);
$regions = system_region_list($theme_default);
$regions = array_merge($region_none, $regions);
$out['block_options']['region'] = array(
'#type' => 'select',
'#title' => t('Region'),
'#options' => $regions,
'#default_value' => isset($menu_content['block_options']['region']) ? $menu_content['block_options']['region'] : '',
'#description' => t('Select theme region.'),
);
$out['block_options']['weight'] = array(
'#type' => 'weight',
'#title' => t('Block Weight'),
'#delta' => 200,
'#default_value' => isset($menu_content['block_options']['weight']) ? $menu_content['block_options']['weight'] : 0,
'#description' => t('Negative values have the highest position in the order, so -1 comes first before 0 then 1, ...'),
);
$out['float_options'] = array(
'#type' => 'fieldset',
'#title' => t('Float Options'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#attributes' => array(
'class' => array(
'om-maximenu-float-options',
),
'style' => $menu_content['output'] == 'float' ? 'display: block;' : 'display: none;',
),
);
$out['float_options']['position'] = array(
'#type' => 'select',
'#title' => t('Fixed / Absolute'),
'#options' => array(
'fixed' => 'Fixed',
'absolute' => 'Absolute',
),
'#default_value' => isset($menu_content['float_options']['position']) ? $menu_content['float_options']['position'] : 'fixed',
'#description' => t('
<ul>
<li><strong>Fixed</strong> - stays on screen on scrolling</li>
<li><strong>Absolute</strong> - moves with the page on scrolling</li>
</ul>
'),
);
$out['float_options']['y_origin'] = array(
'#type' => 'select',
'#title' => t('Y-Origin: Top / Bottom'),
'#options' => array(
'top' => 'Top',
'bottom' => 'Bottom',
),
'#default_value' => isset($menu_content['float_options']['y_origin']) ? $menu_content['float_options']['y_origin'] : 'bottom',
);
$out['float_options']['y_value'] = array(
'#type' => 'textfield',
'#title' => t('Y-Axis Value'),
'#size' => 5,
'#default_value' => isset($menu_content['float_options']['y_value']) ? $menu_content['float_options']['y_value'] : 10,
);
$out['float_options']['x_origin'] = array(
'#type' => 'select',
'#title' => t('X-Origin: Left / Middle / Right'),
'#options' => array(
'left' => 'Left',
'middle' => 'Middle',
'right' => 'Right',
),
'#attributes' => array(
'class' => array(
'om-maximenu-x-origin',
),
),
'#default_value' => isset($menu_content['float_options']['x_origin']) ? $menu_content['float_options']['x_origin'] : 'left',
);
$out['float_options']['non_middle_options'] = array(
'#type' => 'fieldset',
'#title' => t('Non-Middle Options'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#attributes' => array(
'class' => array(
'om-maximenu-non-middle-options',
),
'style' => isset($menu_content['float_options']['x_origin']) && $menu_content['float_options']['x_origin'] == 'middle' ? 'display: none;' : 'display: block;',
),
);
$out['float_options']['non_middle_options']['x_value'] = array(
'#type' => 'textfield',
'#title' => t('X-Axis Value'),
'#size' => 5,
'#default_value' => isset($menu_content['float_options']['x_value']) ? $menu_content['float_options']['x_value'] : 10,
'#attributes' => array(
'class' => array(
'om-maximenu-x-value',
),
),
);
$out['float_options']['non_middle_options']['stacking'] = array(
'#type' => 'select',
'#title' => t('Stacking'),
'#options' => array(
'row' => 'Row',
'column' => 'Column',
),
'#default_value' => isset($menu_content['float_options']['stacking']) ? $menu_content['float_options']['stacking'] : 'row',
'#attributes' => array(
'class' => array(
'om-maximenu-stacking',
),
),
'#description' => t('
<ul>
<li><strong>Row</strong> - all links in 1 row</li>
<li><strong>Column</strong> -all links in 1 column</li>
</ul>
'),
);
$out['float_options']['non_middle_options']['orientation'] = array(
'#type' => 'select',
'#title' => t('Orientation'),
'#options' => array(
'horizontal' => 'Horizontal',
'vertical' => 'Vertical',
),
'#default_value' => isset($menu_content['float_options']['orientation']) ? $menu_content['float_options']['orientation'] : 'horizontal',
'#attributes' => array(
'class' => array(
'om-maximenu-orientation',
),
),
'#description' => t('
<ul>
<li><strong>Horizontal</strong> - normal text/icon orientation</li>
<li><strong>Vertical</strong> - left(90deg rotation), right(270deg rotation)</li>
</ul>
'),
);
$out['float_options']['dock'] = array(
'#type' => 'checkbox',
'#title' => t('Dock Effect'),
'#default_value' => isset($menu_content['float_options']['dock']) ? $menu_content['float_options']['dock'] : 0,
'#attributes' => array(
'id' => 'float-options-position-' . $menu_key,
),
'#description' => t('Mac-like zoom effect on menu icons.'),
);
// counting active links
$active_links = isset($menu_content['links']) ? count($menu_content['links']) : 0;
$out['links'] = array(
'#type' => 'fieldset',
'#title' => t('Menu Links') . ' (' . $active_links . ')',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#theme' => 'om_maximenu_links_order',
);
$out['links'] += om_maximenu_links_order($menu_content, $roles, $menu_key);
$out['menu_visibility'] = array(
'#type' => 'fieldset',
'#title' => t('Menu Visibility'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('This will also update block visibility settings on block configuration.'),
);
$access = user_access('use PHP for settings');
if (isset($menu_content['menu_visibility']['visibility']) && $menu_content['menu_visibility']['visibility'] == 2 && !$access) {
$out['menu_visibility'] = array();
$out['menu_visibility']['visibility'] = array(
'#type' => 'value',
'#value' => 2,
);
$out['menu_visibility']['pages'] = array(
'#type' => 'value',
'#value' => $menu_content['menu_visibility']['pages'],
);
}
else {
$options = array(
t('Show on every page except the listed pages.'),
t('Show on only the listed 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-wildcardfor every personal blog. %front is the front page.", array(
'%blog' => 'blog',
'%blog-wildcard' => 'blog/*',
'%front' => '<front>',
));
if (module_exists('php') && $access) {
$options[] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
$description .= ' ' . t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code canbreak your Drupal site.', array(
'%php' => '<?php ?>',
));
}
$out['menu_visibility']['visibility'] = array(
'#type' => 'radios',
'#title' => t('Show menu on specific pages'),
'#options' => $options,
'#default_value' => isset($menu_content['menu_visibility']['visibility']) ? $menu_content['menu_visibility']['visibility'] : 0,
);
$out['menu_visibility']['pages'] = array(
'#type' => 'textarea',
'#title' => t('Pages'),
'#default_value' => isset($menu_content['menu_visibility']['pages']) ? $menu_content['menu_visibility']['pages'] : '',
'#description' => $description,
);
}
return $out;
}