You are here

popup_descriptions.module in Popup 8

File

modules/popup_descriptions/popup_descriptions.module
View source
<?php

/**
 * Implementation of hook_menu
 */
function popup_descriptions_menu() {
  $path = drupal_get_path('module', 'popup_descriptions');
  return array(
    'admin/config/user-interface/popup/descriptions' => array(
      'access arguments' => array(
        'administer popup elements',
      ),
      'description' => t('Configure field description popups.'),
      'file' => 'popup_descriptions.admin.inc',
      'file path' => $path . '/includes',
      'page arguments' => array(
        'popup_description_admin_settings',
      ),
      'page callback' => 'drupal_get_form',
      'title' => 'Form field descriptions',
      'type' => MENU_LOCAL_TASK,
      'weight' => 5,
    ),
    'admin/config/user-interface/popup/descriptions/rule' => array(
      'access arguments' => array(
        'administer popup elements',
      ),
      'file' => 'popup_descriptions.admin.inc',
      'file path' => $path . '/includes',
      'page callback' => 'popup_descriptions_rule',
      'type' => MENU_CALLBACK,
    ),
  );
}

/**
 * Implementation of hook_form_alter to add admin css
 */
function popup_descriptions_form_alter(&$form, &$form_state, $form_id) {
  $access = user_access('administer popup elements');
  $admin_links = variable_get('description-popup-admin', FALSE);
  if ($access && $admin_links) {
    drupal_add_css(drupal_get_path('module', 'popup_descriptions') . '/style/popup-descriptions.css');
  }
}

/**
 *  Implementation of hook_preprocess_form_element
 */
function popup_descriptions_preprocess_form_element(&$variables) {
  static $exclusions = false;
  if (!$exclusions) {
    $exclusions = module_invoke_all('popup_description_exclusions');
  }
  $element =& $variables['element'];
  $included = !(isset($element['#id']) && in_array($element['#id'], $exclusions));
  if ($included && isset($element['#description']) && strlen(trim($element['#description']))) {
    module_load_include('inc', 'popup_descriptions', 'includes/popup_descriptions.util');
    module_load_include('inc', 'popup', 'includes/popup.api');
    _popup_descriptions_apply_popup_description($element);
    _popup_descriptions_apply_popup_admin($element);
  }
}

Functions

Namesort descending Description
popup_descriptions_form_alter Implementation of hook_form_alter to add admin css
popup_descriptions_menu Implementation of hook_menu
popup_descriptions_preprocess_form_element Implementation of hook_preprocess_form_element