You are here

function scald_dnd_library_add_item in Scald: Media Management made easy 7

Same name and namespace in other branches
  1. 6 scald_dnd_library/scald_dnd_library.module \scald_dnd_library_add_item()

Adds an item in the library array.

1 call to scald_dnd_library_add_item()
scald_plugin_display_library::execute in modules/library/scald_dnd_library/includes/scald_plugin_display_library.inc
Overrides views_plugin_display_page::execute().

File

modules/library/scald_dnd_library/scald_dnd_library.module, line 83
Scald DnD Library

Code

function scald_dnd_library_add_item(&$library, $sid) {
  $atom = scald_fetch($sid);
  $context = variable_get('dnd_context_default', 'sdl_editor_representation');
  $library['atoms'][$sid] = array(
    'meta' => array(
      'title' => $atom->title,
      'type' => $atom->type,
      'data' => !empty($atom->data) ? $atom->data : array(),
      'legend' => '',
    ),
    'sas' => '[scald=' . $atom->sid . ':' . $context . ']',
    'editor' => scald_render($atom, $context),
    'preview' => scald_render($atom, 'sdl_preview'),
    'actions' => array_keys(scald_atom_actions_available($atom)),
  );

  // theme_sdl_editor_legend() requires a rendered atom. We call it only here to
  // make sure that $atom is rendered.
  if (empty($atom->omit_legend)) {
    $library['atoms'][$sid]['meta']['legend'] = theme('sdl_editor_legend', array(
      'atom' => $atom,
    ));
  }

  // Allow other modules to alter this library item.
  drupal_alter('scald_dnd_library_item', $atom, $library['atoms'][$sid]);
}