You are here

function panopoly_magic_preview_callback_fpp in Panopoly Magic 7

Default 'preview callback' for FPP widgets.

1 string reference to 'panopoly_magic_preview_callback_fpp'
_panopoly_magic_render_preview_pane in ./panopoly_magic.module
Helper function to display the pane for showing previews in the add_content modal

File

./panopoly_magic.module, line 1619

Code

function panopoly_magic_preview_callback_fpp($type, $subtype, $plugin, $renderer) {
  if (!empty($plugin['entity_id'])) {
    $fpp = fieldable_panels_panes_load_from_subtype($plugin['entity_id']);
  }
  elseif (!empty($plugin['preview settings'])) {
    $values = $plugin['preview settings'];
    $values['bundle'] = $plugin['bundle'];
    $fpp = fieldable_panels_panes_create($values);
    $fpp->fpid = NULL;
  }
  else {

    // For a new (non-existant) FPP with no 'preview settings', don't show
    // any preview.
    return NULL;
  }

  // Set a property so it's possible to tell that the FPP is being rendered
  // in a preview, for example, in the template.
  $fpp->panopoly_magic_preview = TRUE;
  $content = fieldable_panels_pane_view($fpp, 'full', NULL);
  if ($content) {
    $block = (object) array(
      'title' => check_plain($fpp->title),
      'content' => $content,
      'type' => $type,
      'subtype' => $subtype,
    );
    $pane = panels_new_pane($type, $subtype, TRUE);
    return theme('panels_pane', array(
      'content' => $block,
      'pane' => $pane,
      'display' => $renderer->display,
    ));
  }
}