You are here

function itweak_upload_field_formatter_view in iTweak Upload 7.3

Implements hook_field_formatter_view().

File

./itweak_upload.module, line 480
iTweakUpload - Tweak attachments display and file upload forms.

Code

function itweak_upload_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {

  //drupal_set_message('DEBUG itweak_upload_field_formatter_view field=<pre>'.htmlentities(print_r($field,1)).'</pre> display=<pre>'.htmlentities(print_r($display,1)).'</pre> items=<pre>'.htmlentities(print_r($items,1)).'</pre>');
  $element = array();
  $settings = $display['settings'];
  $files_display_mode = $settings['files_display_mode'];
  $icon_directory = $settings['mime_icon_directory'];
  $gallery_limit = !empty($settings['gallery_limit']) ? $settings['gallery_limit'] : -1;
  $group = _itweak_upload_group_id($entity_type, $entity);
  switch ($display['type']) {
    case 'itu_file_table':
      if (!empty($items)) {
        $cnt_other = _itweak_upload_preprocess_files($items, $thumbnails, $display, $entity_type, $entity, $field['type']);
        if ($cnt_other) {
          if ($files_display_mode != ITU_DISPLAY_GALLERY) {

            // Display all files in a single element.
            $element[] = array(
              '#theme' => 'file_formatter_table_itu',
              '#items' => $items,
              '#icon_directory' => $icon_directory,
            );
          }
        }
        else {

          //?          unset($node->content['files']);
        }

        //        // Preserve files in private property (this prevents upload.module from showing the files)
        //        $node->itu_files = $node->files;
        //        // Clear files list so other modules will not try to display it
        //        $node->files = array();
        if (count($thumbnails)) {
          $options = array(
            'gallery_type' => $settings['gallery_type'],
          );
          $element[] = array(
            '#theme' => 'itweak_upload_image_gallery_body',
            '#items' => $thumbnails,
            '#limit' => $gallery_limit,
            '#options' => $options,
          );
        }
      }

      //?      if ($files_display_mode && $node->files && !user_access('view uploaded files')) {

      //        $node->content['itweak_upload'] = array(
      //          '#value' => theme('view_uploaded_files_forbidden', $node),
      //          '#weight' => 49,
      //        );
      //      }
      break;
  }
  return $element;
}