You are here

improved_multi_select.module in Improved Multi Select 6

The improved_multi_select module main php code.

File

improved_multi_select.module
View source
<?php

/**
 * @file
 * The improved_multi_select module main php code.
 */

/**
 * Implements hook_init().
 */
function improved_multi_select_init() {
  $is_enabled = FALSE;
  if (variable_get('improved_multi_select:isall', 0)) {
    $is_enabled = TRUE;
  }
  else {
    $arg = arg();
    if (isset($arg[0]) and !($arg[0] == 'system' or $arg[0] == 'public')) {
      if ($url = variable_get('improved_multi_select:url', '')) {
        if (drupal_match_path($_GET['q'], $url)) {
          $is_enabled = TRUE;
        }
      }
    }
  }
  if ($is_enabled) {
    drupal_add_css(drupal_get_path('module', 'improved_multi_select') . '/improved_multi_select.css');
    drupal_add_js(drupal_get_path('module', 'improved_multi_select') . '/improved_multi_select.js');
  }
}

/**
 * Implements hook_menu().
 */
function improved_multi_select_menu() {
  $items = array();
  $items['admin/settings/improved_multi_select'] = array(
    'title' => 'Improved Multi Select',
    'description' => 'Configure Improved Multi Select module.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'improved_multi_select_admin',
    ),
    'access arguments' => array(
      'administer site configuration',
    ),
  );
  return $items;
}

/**
 * Administration settings page
 */
function improved_multi_select_admin() {
  $form = array();
  $form['improved_multi_select:isall'] = array(
    '#type' => 'checkbox',
    '#title' => t('Replace all multi-select lists'),
    '#default_value' => variable_get('improved_multi_select:isall', 0),
  );
  $form['improved_multi_select:url'] = array(
    '#type' => 'textarea',
    '#title' => t('Replace multi-select lists on specific pages'),
    '#default_value' => variable_get('improved_multi_select:url', ''),
    '#description' => t("Specify pages by using their paths. Enter one path per line. 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);
}

Functions

Namesort descending Description
improved_multi_select_admin Administration settings page
improved_multi_select_init Implements hook_init().
improved_multi_select_menu Implements hook_menu().