public function view($entity, $view_mode = 'full', $langcode = NULL)
 {
     // Allow modules to change the view mode.
     $context = array('entity_type' => 'fieldable_panels_pane', 'entity' => $entity, 'langcode' => $langcode);
     drupal_alter('entity_view_mode', $view_mode, $context);
     // attach our fields and prepare the pane for rendering
     field_attach_prepare_view('fieldable_panels_pane', array($entity->fpid => $entity), $view_mode, $langcode);
     entity_prepare_view('fieldable_panels_pane', array($entity->fpid => $entity), $langcode);
     $build = field_attach_view('fieldable_panels_pane', $entity, $view_mode, $langcode);
     $build += array('#fieldable_panels_pane' => $entity, '#theme' => 'fieldable_panels_pane', '#element' => $entity, '#view_mode' => $view_mode, '#language' => $langcode);
     // Add contextual links for this fieldable panel pane, except when the pane
     // is already being displayed on its own page. Modules may alter this
     // behavior (for example, to restrict contextual links to certain view
     // modes) by implementing hook_fieldable_panels_pane_view_alter().
     if (!empty($entity->fpid) && !($view_mode == 'full' && fieldable_panels_pane_is_page($entity))) {
         $build['#contextual_links']['fieldable_panels_panes'] = array('admin/structure/fieldable-panels-panes/view', array($entity->fpid));
     }
     $entity_type = 'fieldable_panels_pane';
     drupal_alter(array('fieldable_panels_pane_view', 'entity_view'), $build, $entity_type);
     return $build;
 }
 public function view($entity, $view_mode = 'full', $langcode = NULL)
 {
     if (!isset($langcode)) {
         $langcode = $GLOBALS['language_content']->language;
     }
     // Populate $entity->content with a render() array.
     $this->buildContent($entity, $view_mode, $langcode);
     $build = $entity->content;
     // We don't need duplicate rendering info in $entity->content.
     unset($entity->content);
     $build += array('#theme' => 'fieldable_panels_pane', '#fieldable_panels_pane' => $entity, '#element' => $entity, '#view_mode' => $view_mode, '#language' => $langcode);
     // Add contextual links for this fieldable panel pane, except when the pane
     // is already being displayed on its own page. Modules may alter this
     // behavior (for example, to restrict contextual links to certain view
     // modes) by implementing hook_fieldable_panels_pane_view_alter().
     if (!empty($entity->fpid) && !($view_mode == 'full' && fieldable_panels_pane_is_page($entity))) {
         $build['#contextual_links']['fieldable_panels_panes'] = array('admin/structure/fieldable-panels-panes/view', array($entity->fpid));
     }
     // Allow modules to modify the structured pane.
     $type = 'fieldable_panels_pane';
     drupal_alter(array('fieldable_panels_pane_view', 'entity_view'), $build, $type);
     return $build;
 }