Skip to content

Commit

Permalink
Update File Entity to 7.x-2.35
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Hunt committed Jan 20, 2022
1 parent 89dd04f commit ccd501e
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,17 @@ function file_entity_field_formatter_view($entity_type, $entity, $field, $instan
if (isset($item['description'])) {
$file->description = $item['description'];
}

$text = $settings['text'];
if (module_exists('i18n_string')) {
$key = 'file_entity:file_download_link:' . $entity_type . ':' . $instance['bundle'] . ':link_text:' . $text;
$text = i18n_string($key, $text);
}

$element[$delta] = array(
'#theme' => 'file_entity_download_link',
'#file' => $file,
'#text' => $settings['text'],
'#text' => $text,
);
}
}
Expand Down
40 changes: 40 additions & 0 deletions docroot/sites/all/modules/contrib/file_entity/file_entity.i18n.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* Implements hook_i18n_string_info().
*/
function file_entity_i18n_string_info() {
$groups['file_entity'] = array(
'title' => t('File Entity'),
'format' => FALSE,
);
return $groups;
}

/**
* Implements hook_i18n_string_list().
*/
function file_entity_i18n_string_list($group) {
if ($group == 'file_entity') {
$fields = field_info_instances();

$strings = array();
foreach ($fields as $entity_type => $bundles) {
foreach ($bundles as $bundle => $fields) {
foreach ($fields as $field_key => $field_settings) {
foreach ($field_settings['display'] as $view_mode => $view_mode_settings) {
if (!empty($view_mode_settings['type']) && $view_mode_settings['type'] == 'file_download_link') {
$text = $view_mode_settings['settings']['text'];

$key = $entity_type . ':' . $bundle . ':' . 'link_text';

$strings['file_entity']['file_download_link'][$key][$text] = $text;
}
}
}
}
}

return $strings;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ configure = admin/config/media/file-settings
; We have to add a fake version so Git checkouts do not fail Media dependencies
version = 7.x-2.x-dev

; Information added by Drupal.org packaging script on 2021-11-10
version = "7.x-2.33"
; Information added by Drupal.org packaging script on 2021-12-15
version = "7.x-2.35"
core = "7.x"
project = "file_entity"
datestamp = "1636506143"
datestamp = "1639611298"
32 changes: 20 additions & 12 deletions docroot/sites/all/modules/contrib/file_entity/file_entity.module
Original file line number Diff line number Diff line change
Expand Up @@ -1233,19 +1233,27 @@ function file_entity_file_formatter_file_field_settings($form, &$form_state, $se
// formatter functions, but we are not working with a Field API field, so
// set $field accordingly. Unfortunately, the API is for $settings to be
// transferred via the $instance parameter, so we must mock it.
if (isset($field_formatter_info['module']) && ($function = ($field_formatter_info['module'] . '_field_formatter_settings_form')) && function_exists($function)) {
$field = NULL;
$mock_instance = array(
'display' => array(
$view_mode => array(
'type' => $field_formatter_type,
'settings' => $settings,
if (isset($field_formatter_info['module'])) {
$function = $field_formatter_info['module'] . '_field_formatter_settings_form';
if (function_exists($function)) {
// The formatter's first argument is expected to be a field definition
// with at least "type" and "bundles" elements.
$mock_field = array(
'type' => NULL,
'bundles' => array(),
);
$mock_instance = array(
'display' => array(
$view_mode => array(
'type' => $field_formatter_type,
'settings' => $settings,
),
),
),
'entity_type' => 'file',
'bundle' => $file_type,
);
return $function($field, $mock_instance, $view_mode, $form, $form_state);
'entity_type' => 'file',
'bundle' => $file_type,
);
return $function($mock_field, $mock_instance, $view_mode, $form, $form_state);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ function file_entity_usage_page($file) {

// Determine all of the locations where a file is used, then loop through the
// occurrences and filter out any duplicates.
foreach (file_usage_list($file) as $type) {
foreach (file_usage_list($file) as $module => $type) {
foreach ($type as $entity_type => $entity_ids) {
// There are cases where the actual entity doesn't exist.
// We have to handle this.
Expand Down Expand Up @@ -435,6 +435,11 @@ function file_entity_usage_page($file) {
}
}
}
// For file_lock module, display relevant usage information.
elseif ($module == 'file_lock') {
$entity_label = t('File lock');
$entity_id = '--';
}
else {
$entity_label = check_plain($label);
}
Expand Down Expand Up @@ -1273,12 +1278,9 @@ function file_entity_get_upload_validators(array $options = array()) {
$validators['file_validate_extensions'] = array(variable_get('file_entity_default_allowed_extensions', 'jpg jpeg gif png txt doc docx xls xlsx pdf ppt pptx pps ppsx odt ods odp mp3 mov mp4 m4a m4v mpeg avi ogg oga ogv weba webp webm'));
}

// Cap the upload size according to the system or user defined limit. Note: In
// PHP 8 file_upload_max_size() returns a string instead of an integer, so
// cast it to an integer to avoid a critical error; do the same for the
// variable, just in case.
$max_filesize = parse_size(intval(file_upload_max_size()));
$file_entity_max_filesize = parse_size(intval(variable_get('file_entity_max_filesize', '')));
// Cap the upload size according to the system or user defined limit.
$max_filesize = parse_size(file_upload_max_size());
$file_entity_max_filesize = parse_size(variable_get('file_entity_max_filesize', ''));

// If the user defined a size limit, use the smaller of the two.
if (!empty($file_entity_max_filesize)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ core = 7.x
dependencies[] = file_entity
hidden = TRUE

; Information added by Drupal.org packaging script on 2021-11-10
version = "7.x-2.33"
; Information added by Drupal.org packaging script on 2021-12-15
version = "7.x-2.35"
core = "7.x"
project = "file_entity"
datestamp = "1636506143"
datestamp = "1639611298"

0 comments on commit ccd501e

Please sign in to comment.