You are here

function popup_element in Popup 8

Same name and namespace in other branches
  1. 7 includes/popup.api.inc \popup_element()
  2. 7.x includes/popup.api.inc \popup_element()
  3. 6.x includes/popup.api.inc \popup_element()

Renders a popup elements' HTML

Parameters

string $title:

string $body:

array $attributes:

This method should be used to create popups programmatically where the title and body of the popup element is known. It will automatically assign classes and default behaviors. Any additional information should be passed in attributes, eg. array('activate' => 'click')

13 calls to popup_element()
popup in includes/popup.api.inc
Renders a popup element using specified attributes. This method should be used to create popups programmatically.
popup_block_preprocess_block in modules/popup_block/popup_block.module
popup_filter_form_alter in modules/popup_filter/popup_filter.module
Implementation of hook_form_alter
popup_ui_confirm in modules/popup_ui/includes/popup_ui.api.inc
Renders a link that pops up a yes/no confirmation dialog.
_popup_block in includes/popup.api.inc

... See full list

File

includes/popup.api.inc, line 191

Code

function popup_element($title, $body, $attributes = array()) {
  module_load_include('inc', 'popup', 'includes/popup.util');
  if (!isset($attributes['altered'])) {
    drupal_alter('popup_attributes', $attributes);
  }
  $style = $attributes['style'] ? $attributes['style'] : variable_get('popup-style', 'White');
  $attributes['style-class'] = _popup_title_to_key($style);
  $style_suffix = $style ? '-' . $attributes['style-class'] : '';
  $id = _popup_id($attributes['id']);
  $classes = _popup_classes($attributes);
  $close = $attributes['close'] && $attributes['activate'] == 'click' ? '<a class="popup-close popup-close-button"><span>[X]</span></a>' : '';
  $href = isset($attributes['link']) ? 'href="' . url($attributes['link']) . '"' : '';
  $keys = array_keys($attributes);
  $intersect = array_intersect(array(
    'node',
    'block',
    'form',
    'view',
    'php',
  ), $keys);
  $ajax_type = @array_shift($intersect);
  $popup_title = theme('popup-element-title' . $style_suffix, array(
    'title' => _popup_title($title, $attributes['image']),
    'class' => $classes['title'],
    'href' => $href,
  ));
  if ($attributes['ajax'] && $ajax_type) {
    $body = theme('popup_ahah_placeholder', array(
      'type' => $ajax_type,
      'attributes' => $attributes,
    ));
  }
  else {
    unset($attributes['ajax']);
  }
  $popup_body = count(trim($body)) || $attributes['empty-body'] == 'all' ? theme('popup-element-body' . $style_suffix, array(
    'body' => $body,
    'class' => $classes['body'],
    'close' => $close,
  )) : '';
  return trim($body) || $attributes['empty-body'] != 'none' ? theme('popup-element' . $style_suffix, array(
    'title' => $popup_title,
    'body' => $popup_body,
    'css_id' => $id,
    'class' => $classes['element'],
    'style' => $style,
  )) : '';
}