From 29a6913890a675ddf1a9239b4407f105e02dc95d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ctibor=20Bran=C4=8D=C3=ADk?= Date: Sun, 20 Mar 2016 19:27:01 +0100 Subject: Added drupal modules for site --- .../all/modules/file_entity/file_entity.field.inc | 426 +++++++++++++++++++++ 1 file changed, 426 insertions(+) create mode 100644 sites/all/modules/file_entity/file_entity.field.inc (limited to 'sites/all/modules/file_entity/file_entity.field.inc') diff --git a/sites/all/modules/file_entity/file_entity.field.inc b/sites/all/modules/file_entity/file_entity.field.inc new file mode 100644 index 000000000..4b039b632 --- /dev/null +++ b/sites/all/modules/file_entity/file_entity.field.inc @@ -0,0 +1,426 @@ + t('Rendered file'), + 'description' => t('Display the file in a specific view mode'), + 'field types' => array('file', 'image'), + 'settings' => array( + 'file_view_mode' => 'default', + ), + 'file formatter' => array( + 'hidden' => TRUE, + ), + ); + $info['file_download_link'] = array( + 'label' => t('Download link'), + 'description' => t('Displays a link that will force the browser to download the file.'), + 'field types' => array('file', 'image'), + 'settings' => array( + 'text' => t('Download [file:name]'), + ), + ); + $info['file_audio'] = array( + 'label' => t('Audio'), + 'description' => t('Render the file using an HTML5 audio tag.'), + 'field types' => array('file'), + 'settings' => array( + 'controls' => TRUE, + 'autoplay' => FALSE, + 'loop' => FALSE, + 'preload' => '', + 'multiple_file_behavior' => 'tags', + ), + 'file formatter' => array( + 'mime types' => array('audio/*'), + ), + ); + $info['file_video'] = array( + 'label' => t('Video'), + 'description' => t('Render the file using an HTML5 video tag.'), + 'field types' => array('file'), + 'settings' => array( + 'controls' => TRUE, + 'autoplay' => FALSE, + 'loop' => FALSE, + 'muted' => FALSE, + 'width' => NULL, + 'height' => NULL, + 'preload' => '', + 'multiple_file_behavior' => 'tags', + ), + 'file formatter' => array( + 'mime types' => array('video/*'), + ), + ); + return $info; +} + +/** + * Implements hook_field_formatter_info_alter(). + */ +function file_entity_field_formatter_info_alter(&$info) { + // Add descriptions to core formatters. + $descriptions = array( + 'file_default' => t('Create a simple link to the file. The link is prefixed by a file type icon and the name of the file is used as the link text'), + 'file_table' => t('Build a two-column table where the first column contains a generic link to the file and the second column displays the size of the file.'), + 'file_url_plain' => t('Display a plain text URL to the file.'), + 'image' => t('Format the file as an image. The image can be displayed using an image style and can optionally be linked to the image file itself or its parent content.'), + ); + foreach ($descriptions as $key => $description) { + if (isset($info[$key]) && empty($info[$key]['description'])) { + $info[$key]['description'] = $description; + } + } + + // Formatters that can be used for images but not files, should have a + // default mimetype restriction added to the image/* mime type for use with + // file formatters. + foreach ($info as &$formatter) { + if (!isset($formatter['file formatter']) && in_array('image', $formatter['field types']) && !in_array('file', $formatter['field types'])) { + $formatter['file formatter']['mime types'] = array('image/*'); + } + } +} + +/** + * Implements hook_field_formatter_settings_form(). + */ +function file_entity_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) { + $display = $instance['display'][$view_mode]; + $settings = $display['settings']; + $element = array(); + + if ($display['type'] == 'file_rendered') { + $element['file_view_mode'] = array( + '#title' => t('View mode'), + '#type' => 'select', + '#options' => file_entity_view_mode_labels(), + '#default_value' => $settings['file_view_mode'], + // Never empty, so no #empty_option + ); + } + elseif ($display['type'] == 'file_download_link') { + $element['text'] = array( + '#type' => 'textfield', + '#title' => t('Link text'), + '#description' => t('This field support tokens.'), + '#default_value' => $settings['text'], + '#required' => TRUE, + ); + } + elseif ($display['type'] == 'file_audio') { + $element['controls'] = array( + '#title' => t('Show audio controls'), + '#type' => 'checkbox', + '#default_value' => $settings['controls'], + ); + $element['autoplay'] = array( + '#title' => t('Autoplay'), + '#type' => 'checkbox', + '#default_value' => $settings['autoplay'], + ); + $element['loop'] = array( + '#title' => t('Loop'), + '#type' => 'checkbox', + '#default_value' => $settings['loop'], + ); + $element['preload'] = array( + '#title' => t('Preload'), + '#type' => 'select', + '#default_value' => $settings['preload'], + '#options' => drupal_map_assoc(array('none', 'auto', 'metadata')), + '#empty_option' => 'unspecified', + ); + $element['multiple_file_behavior'] = array( + '#title' => t('Display of multiple files'), + '#type' => 'radios', + '#options' => array( + 'tags' => t('Use multiple @tag tags, each with a single source', array('@tag' => '