You are here

function jquerymenu_admin_settings in JQuery menu 7.3

Same name and namespace in other branches
  1. 7.4 jquerymenu.admin.inc \jquerymenu_admin_settings()

Admin form for jQuery menu module.

See also

system_settings_form(),

1 string reference to 'jquerymenu_admin_settings'
jquerymenu_menu in ./jquerymenu.module
Implements hook_menu().

File

./jquerymenu.admin.inc, line 13
Administration page callbacks for the jQuerymenu module

Code

function jquerymenu_admin_settings() {

  // List all custom menus - $menulist
  $result = db_query("SELECT menu_name, title FROM {menu_custom}");
  $menulist = array();
  foreach ($result as $menu) {
    $menulist[$menu->menu_name] = $menu->title;
  }

  // get a list of all jquerymenus - $enabledmenus
  $result = db_query("SELECT menu_name FROM {jquerymenus}");
  $enabledmenus = array();
  foreach ($result as $enabled) {
    $enabledmenus[] = $enabled->menu_name;
  }

  // find which items in $menulist are in $enabledmenus - $defaultvalue
  $defaultvalue = array();
  foreach ($menulist as $index => $value) {
    foreach ($enabledmenus as $em) {
      if ($index == $em) {
        $defaultvalue[] = $index;
      }
      else {
        $defaultvalue[] = 0;
      }
    }
  }

  // Create a list of available menus - jquerymenu_activate.
  $form['jquerymenu_activate'] = array(
    '#type' => 'checkboxes',
    '#title' => t('jQuery Menu blocks'),
    '#options' => $menulist,
    '#default_value' => $defaultvalue,
    '#multiple' => TRUE,
    '#description' => t('Choose which menus you wish to create a jQuery Menu version for. Please note that this only creates the block. You will still have to activate the block on the blocks page.'),
  );

  // Create a checkbox to enable animation - jquerymenu_animate.
  $form['jquerymenu_animate'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable animation.'),
    '#description' => t('If checked your menus will open with transition effects.'),
    '#default_value' => variable_get('jquerymenu_animate', 1),
  );

  // Create a checkbox to display an edit link - jquerymenu_edit_link.
  $form['jquerymenu_edit_link'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display Edit Link.'),
    '#description' => t('If checked the edit link will display when hovering over menu items to those having administration privileges. This setting will only affect menus directly created by the jQuery Menu module. Other modules that implement the edit link will have their own settings.'),
    '#default_value' => variable_get('jquerymenu_edit_link', 1),
  );

  // create a checkbox to disable link on items with children
  $form['jquerymenu_parentlink'] = array(
    '#type' => 'checkbox',
    '#title' => t('Disable links for menu items with children.'),
    '#description' => t('If checked, menu items which contain children will not have hyperlinks, rather will use plain titles.'),
    '#default_value' => variable_get('jquerymenu_parentlink', 0),
  );

  // create a checkbox to enable hover
  $form['jquerymenu_hover'] = array(
    '#type' => 'checkbox',
    '#title' => t('Expand children on hover.'),
    '#description' => t('If checked the child menu items will be displayed when hovering over the parent menu item.'),
    '#default_value' => variable_get('jquerymenu_hover', 0),
  );

  // Create a submit button.
  $form['jquerymenu_admin_settings_submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}