You are here

function theme_mee_widget_embed in Scald: Media Management made easy 7

Returns the HTML for an atom embedded through the CK widget plugin.

This is used by the mee_scald_widgets filter, and leaves a placeholder SAS code for later rendering of the atom.

Parameters

$vars: An array with the following key/value pairs:

  • atom: the atom,
  • context: the rendering context,
  • options: the options as a JSON string,
  • align: the alignment (left, right, center, none),
  • caption: the caption HTML,
  • content: the atom content. Note: to account for filter cache, the 'mee_scald_widgets' filter only passes a SAS code here, that gets replaced with the HTML for the rendered atom in mee_field_attach_view_alter().
  • wysiwyg: TRUE when the atom is displayed within a CKEditor. Defaults to FALSE.

Return value

string The HTML for the atom embed.

2 theme calls to theme_mee_widget_embed()
mee_ajax_widget_expand in modules/fields/mee/mee.module
Ajax callback: returns the expanded HTML atom widget.
mee_filter_process in modules/fields/mee/mee.module
Process callback for the 'mee_scald_widgets' filter.

File

modules/fields/mee/mee.module, line 662
Defines a special textarea, with drag and drop media driven by Scald and dnd.module.

Code

function theme_mee_widget_embed($vars) {
  $options = array();
  if (isset($vars['options'])) {
    $options = drupal_json_decode($vars['options']);
  }
  $classes = array(
    'dnd-widget-wrapper',
    'context-' . $vars['context'],
    'type-' . $vars['atom']->type,
  );
  if ($vars['align'] != 'none') {
    $classes[] = 'atom-align-' . $vars['align'];
  }
  if (!empty($options['additionalClasses'])) {
    foreach (explode(' ', $options['additionalClasses']) as $class) {
      $classes[] = $class;
    }
  }
  $output = '<div class="' . implode(' ', $classes) . '">';
  $output .= '<div class="dnd-atom-rendered">' . $vars['content'] . '</div>';

  // When displaying a widget within a CKEditor, always include a container div
  // for the editable. Otherwise, only display the caption container if there
  // is a caption.
  if (!empty($vars['caption']) || $vars['wysiwyg']) {

    // Note: The 'dnd-caption-wrapper' class is used by the CKEditor plugin to
    // identify the editable zone and should not be modified by theme overrides.
    $output .= '<div class="dnd-caption-wrapper">' . $vars['caption'] . '</div>';
  }
  $output .= '</div>';
  return $output;
}