You are here

function _popup_descriptions_apply_popup_admin in Popup 7

Same name and namespace in other branches
  1. 8 modules/popup_descriptions/includes/popup_descriptions.util.inc \_popup_descriptions_apply_popup_admin()
  2. 7.x modules/popup_descriptions/includes/popup_descriptions.util.inc \_popup_descriptions_apply_popup_admin()

Adds description popup admin links to the form element

1 call to _popup_descriptions_apply_popup_admin()
popup_descriptions_preprocess_form_element in modules/popup_descriptions/popup_descriptions.module
Implementation of hook_preprocess_form_element

File

modules/popup_descriptions/includes/popup_descriptions.util.inc, line 70

Code

function _popup_descriptions_apply_popup_admin(&$element) {
  $access = user_access('administer popup elements');
  $admin_links = variable_get('description-popup-admin', FALSE);
  if ($access && $admin_links) {
    $popup = '';
    $link = array();
    $link[] = _popup_descriptions_enabled_id($element) ? l('Display this description inline', 'admin/config/user-interface/popup/descriptions/rule/remove/id/' . $element['#id'], array(
      'query' => array(
        'destination' => $_GET['q'],
      ),
    )) : l('Display this description as a popup', 'admin/config/user-interface/popup/descriptions/rule/add/id/' . $element['#id'], array(
      'query' => array(
        'destination' => $_GET['q'],
      ),
    ));
    $link[] = _popup_descriptions_enabled_path() ? l('Do not display all descriptions on this page as popups', 'admin/config/user-interface/popup/descriptions/rule/remove/page', array(
      'query' => array(
        'destination' => $_GET['q'],
      ),
    )) : l('Display all descriptions on this page as popups', 'admin/config/user-interface/popup/descriptions/rule/add/page', array(
      'query' => array(
        'destination' => $_GET['q'],
      ),
    ));
    $popup = popup_element(t('Configure description popup behaviour'), '<ul><li>' . implode('</li><li>', $link) . '</ul>', array(
      'activate' => 'hover',
      'element-class' => 'popup-description popup-description-admin',
      'origin' => 'bottom-right',
      'expand' => 'bottom-left',
      'width' => 400,
    ));
    $element['#description'] = isset($element['#description']) ? $element['#description'] . $popup : $popup;
  }
}