You are here

function oa_core_summary_render in Open Atrium Core 7.2

Render callback for the content visibility panel.

1 string reference to 'oa_core_summary_render'
oa_core_summary.inc in plugins/content_types/oa_core_summary.inc

File

plugins/content_types/oa_core_summary.inc, line 28

Code

function oa_core_summary_render($subtype, $conf, $args, $context = NULL) {
  if (!isset($context->data->nid) || !(($space_nid = oa_core_get_group_from_node($context->data, array(
    OA_SPACE_TYPE,
  ))) && ($space = node_load($space_nid))) || !node_access('view', $space)) {
    return;
  }
  global $user;
  $vars = array();
  $vars['title'] = check_plain($space->title);
  $vars['description'] = '';
  $vars['picture'] = '';
  $vars['links']['favorite'] = '';
  $vars['links']['edit'] = '';
  if (!empty($conf['show_description'])) {
    $field = field_view_field('node', $space, 'body', array(
      'label' => 'hidden',
    ));
    if (!empty($field)) {
      $vars['description'] = drupal_render($field);
    }
    $picture = field_get_items('node', $space, 'field_featured_image');
    if (!empty($picture)) {
      $picture = array_shift($picture);
      $vars['picture'] = theme('image_style', array(
        'style_name' => 'panopoly_image_' . $conf['image_size'],
        'path' => $picture['uri'],
        'width' => $picture['width'],
        'height' => $picture['height'],
        'alt' => $picture['alt'],
      ));
    }
    if (isset($space->field_oa_related)) {
      $paragraphs = field_view_field('node', $space, 'field_oa_related');
      $paragraphs['#label_display'] = 'hidden';
      $vars['related'] = drupal_render($paragraphs);
    }
  }
  $vars['links'] = array();
  if (!empty($conf['show_favorite']) && $user->uid && module_exists('oa_favorites')) {
    $favorite = oa_favorites_is_favorite_space($user->uid, $space->nid);
    $vars['links']['favorite'] = theme('flag', array(
      'flag' => flag_get_flag(FAVORITE_SPACE),
      'action' => $favorite ? 'unflag' : 'flag',
      'content_id' => $space->nid,
    ));
  }
  if (!empty($conf['show_links']) && node_access('update', $space)) {
    $vars['links']['edit'] = l(t('Edit'), 'node/' . $space->nid . '/edit');
  }
  $block = new stdClass();
  $block->title = check_plain($space->title);
  $block->content = theme('oa_core_summary', $vars);
  return $block;
}