You are here

function addtocalendar_field_formatter_view in Add To Calendar Button (AddEvent.com) 7.2

Implements hook_field_formatter_view().

File

./addtocalendar.module, line 209
Contains module code.

Code

function addtocalendar_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
  if ($display['type'] == 'addtocalendar_formatter') {
    $settings = $instance['widget']['settings']['addtocalendar_settings'];

    // Start building renderable array.
    if (isset($items[0])) {
      $formatter_settings['addtocalendar_show'] = TRUE;
      $build = [];
      module_load_include('inc', 'addtocalendar', 'includes/addtocalendar');
      foreach ($items as $delta => $item) {
        $build = addtocalendar_preprocess_setting_fields($entity_type, $entity, $settings, $formatter_settings);
      }
      $element[]['#markup'] = !empty($build['addtocalendar']) ? render($build['addtocalendar']) : '';
    }
    else {
      $element = array(
        '#prefix' => '<div class="wrapper">',
        '#suffix' => '<div>' . $settings['disable_text'] . '</div></div>',
      );
    }
  }
  return $element;
}