View source
<?php
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,
),
);
}
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');
}
}
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);
}
}