You are here

function menu_icons_form_alter in Menu Icons 6.2

Same name and namespace in other branches
  1. 8 menu_icons.module \menu_icons_form_alter()
  2. 6 menu_icons.module \menu_icons_form_alter()
  3. 7.3 menu_icons.module \menu_icons_form_alter()

Implementation of hook_form_alter().

File

./menu_icons.module, line 38
Module to associate icons with menu items

Code

function menu_icons_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'menu_edit_item') {
    $options = unserialize(db_result(db_query('SELECT options FROM {menu_links} WHERE mlid = %d', $form['menu']['mlid']['#value'])));
    $form['icon'] = array(
      '#type' => 'fieldset',
      '#weight' => 5,
      '#title' => t('Menu icon settings'),
      '#description' => t('If checked, the following icon will be used as background image for this menu item.'),
      '#attributes' => array(
        'class' => 'theme-settings-bottom',
      ),
    );
    $form['icon']["use_icon_logo"] = array(
      '#type' => 'checkbox',
      '#title' => t('Use an icon'),
      '#default_value' => $options['menu_icon']['enable'],
      '#tree' => FALSE,
      '#description' => t('Check this if you want this icon to be used.'),
    );
    $form['icon']['icon_path'] = array(
      '#type' => 'textfield',
      '#title' => t('Path to the icon'),
      '#default_value' => $options['menu_icon']['path'],
      '#description' => t('The path to the image you would like to use as a backround image for this menu item.'),
    );
    $form['icon']['icon_upload'] = array(
      '#type' => 'file',
      '#title' => t('Upload a new icon image'),
      '#maxlength' => 40,
      '#description' => t("If you don't have direct file access to the server, use this field to upload your icon."),
    );
    $form['submit']['#weight'] = 9;
    $form['delete']['#weight'] = 10;
    $form['#attributes']['enctype'] = 'multipart/form-data';
    $form['#submit'][] = 'menu_icons_form_submit';
  }
}