From 3c32024b03ec0654283aa2d5098d27a926b424de Mon Sep 17 00:00:00 2001 From: Chris Gross <gross.364@osu.edu> Date: Mon, 14 Aug 2017 14:26:09 -0400 Subject: [PATCH] 7.x-1.2 Release Candidate 1 --- profiles/wcm_base/CHANGELOG.txt | 5 +- .../modules/contrib/file_entity/PATCHES.txt | 1 + .../file.admin-content-file.inc | 270 +++++++++--------- .../contrib/file_entity/file_entity.admin.inc | 69 +++-- .../contrib/file_entity/file_entity.api.php | 8 +- .../file_entity.devel_generate.inc | 23 ++ .../contrib/file_entity/file_entity.field.inc | 95 +++--- .../contrib/file_entity/file_entity.file.inc | 13 +- .../contrib/file_entity/file_entity.info | 8 +- .../contrib/file_entity/file_entity.install | 1 + .../contrib/file_entity/file_entity.module | 130 ++++++--- .../contrib/file_entity/file_entity.pages.inc | 82 ++++-- .../file_entity/file_entity.pathauto.inc | 2 +- .../contrib/file_entity/file_entity.test | 130 ++++++++- .../contrib/file_entity/file_entity.theme.inc | 64 ++++- .../contrib/file_entity/file_entity.tpl.php | 10 +- .../file_entity/file_entity_views.test | 114 ++++++++ .../file_entity/plugins/tasks/file_view.inc | 1 + .../file_entity/tests/file_entity_test.info | 6 +- .../views_handler_field_file_link_usage.inc | 37 ++- .../contrib/media/includes/media.fields.inc | 14 +- .../modules/contrib/media/js/media.popups.js | 3 +- .../wcm_base/modules/contrib/media/media.info | 8 +- .../modules/contrib/media/media.install | 17 +- .../modules/contrib/media/media.media.inc | 21 ++ .../modules/contrib/media/media.module | 15 +- .../modules/contrib/media/media.views.inc | 1 + .../media_bulk_upload/media_bulk_upload.info | 6 +- .../media_bulk_upload.module | 2 + .../media_internet/media_internet.info | 6 +- .../tests/media_internet_test.info | 6 +- .../media_migrate_file_types.info | 6 +- .../media_wysiwyg/css/media_wysiwyg.css | 6 +- .../includes/media_wysiwyg.filter.inc | 76 ++++- .../includes/media_wysiwyg.pages.inc | 18 +- .../media_wysiwyg/js/media_wysiwyg.filter.js | 8 +- .../modules/media_wysiwyg/media_wysiwyg.info | 7 +- .../media_wysiwyg/media_wysiwyg.install | 10 + .../media_wysiwyg/media_wysiwyg.module | 28 +- .../modules/media_wysiwyg/media_wysiwyg.test | 2 + .../media_wysiwyg.paragraph_fix_filter.test | 166 +++++++++++ .../media_wysiwyg_view_mode.info | 6 +- .../media/modules/mediafield/mediafield.info | 6 +- .../modules/contrib/media/tests/media.test | 1 + .../media/tests/media_module_test.info | 6 +- .../modules/contrib/media_youtube/PATCHES.txt | 4 - .../includes/MediaInternetYouTubeHandler.inc | 42 ++- .../includes/MediaYouTubeStreamWrapper.inc | 99 +++++-- .../includes/media_youtube.formatters.inc | 14 +- .../media_youtube.file_default_displays.inc | 10 +- .../contrib/media_youtube/media_youtube.info | 9 +- .../contrib/media_youtube/media_youtube.test | 104 +++++++ .../includes/MediaYouTubeTestHandler.inc | 51 ++++ .../MediaYouTubeTestStreamWrapper.inc | 28 ++ .../tests/media_youtube_test.info | 16 ++ .../tests/media_youtube_test.module | 73 +++++ .../themes/media_youtube.theme.inc | 80 +++++- ...ocio_media.features.features_overrides.inc | 3 +- .../ocio_media.features.field_instance.inc | 36 +++ .../custom/ocio_media/ocio_media.features.inc | 11 +- .../modules/custom/ocio_media/ocio_media.info | 6 +- .../ocio_media/ocio_media.strongarm.inc | 17 +- .../ocio_news.features.field_instance.inc | 2 +- .../modules/custom/ocio_news/ocio_news.info | 1 + profiles/wcm_base/wcm_base.make | 8 +- 65 files changed, 1712 insertions(+), 416 deletions(-) create mode 100644 profiles/wcm_base/modules/contrib/file_entity/file_entity_views.test create mode 100644 profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/tests/media_wysiwyg.paragraph_fix_filter.test delete mode 100644 profiles/wcm_base/modules/contrib/media_youtube/PATCHES.txt create mode 100644 profiles/wcm_base/modules/contrib/media_youtube/media_youtube.test create mode 100644 profiles/wcm_base/modules/contrib/media_youtube/tests/includes/MediaYouTubeTestHandler.inc create mode 100644 profiles/wcm_base/modules/contrib/media_youtube/tests/includes/MediaYouTubeTestStreamWrapper.inc create mode 100644 profiles/wcm_base/modules/contrib/media_youtube/tests/media_youtube_test.info create mode 100644 profiles/wcm_base/modules/contrib/media_youtube/tests/media_youtube_test.module diff --git a/profiles/wcm_base/CHANGELOG.txt b/profiles/wcm_base/CHANGELOG.txt index f80cc207..a282e055 100644 --- a/profiles/wcm_base/CHANGELOG.txt +++ b/profiles/wcm_base/CHANGELOG.txt @@ -1,7 +1,10 @@ WCM Base 7.x-1.2-rc1, 2017-08-14 -------------------------------- - WCM Omega: Improved accessibility of AJAX-enabled views using aria-live. -- WCM Base: Added core patch to fix problems uploading private files from WYSIWYG. +- WCM Base: + - Added core patch to fix problems uploading private files from WYSIWYG. + - Updated media, media_youtube, file_entity modules. +- OCIO Media: Updated file upload directory for media browser, added for file entities. WCM Base 7.x-1.1, 2017-07-31 ---------------------------- diff --git a/profiles/wcm_base/modules/contrib/file_entity/PATCHES.txt b/profiles/wcm_base/modules/contrib/file_entity/PATCHES.txt index c4d526d8..76bb5747 100644 --- a/profiles/wcm_base/modules/contrib/file_entity/PATCHES.txt +++ b/profiles/wcm_base/modules/contrib/file_entity/PATCHES.txt @@ -1,4 +1,5 @@ The following patches have been applied to this project: - http://drupal.org/files/issues/file_entity-file-size-limit-per-file-type-2530656-3.patch +- http://drupal.org/files/issues/use-file_entity_default_file_directory-1997208-33.patch This file was automatically generated by Drush Make (http://drupal.org/project/drush). diff --git a/profiles/wcm_base/modules/contrib/file_entity/admin_views_default/file.admin-content-file.inc b/profiles/wcm_base/modules/contrib/file_entity/admin_views_default/file.admin-content-file.inc index c108497c..dc2f0de5 100644 --- a/profiles/wcm_base/modules/contrib/file_entity/admin_views_default/file.admin-content-file.inc +++ b/profiles/wcm_base/modules/contrib/file_entity/admin_views_default/file.admin-content-file.inc @@ -33,78 +33,78 @@ $handler->display->display_options['pager']['options']['id'] = '0'; $handler->display->display_options['pager']['options']['quantity'] = '9'; $handler->display->display_options['style_plugin'] = 'table'; $handler->display->display_options['style_options']['columns'] = array( - 'views_bulk_operations' => 'views_bulk_operations', - 'filename' => 'filename', - 'type' => 'type', - 'name' => 'name', - 'filesize' => 'filesize', - 'timestamp' => 'timestamp', - 'edit' => 'edit', - 'delete' => 'delete', + 'views_bulk_operations' => 'views_bulk_operations', + 'filename' => 'filename', + 'type' => 'type', + 'name' => 'name', + 'filesize' => 'filesize', + 'timestamp' => 'timestamp', + 'edit' => 'edit', + 'delete' => 'delete', ); $handler->display->display_options['style_options']['default'] = 'timestamp'; $handler->display->display_options['style_options']['info'] = array( - 'views_bulk_operations' => array( - 'align' => '', - 'separator' => '', - 'empty_column' => 0, - ), - 'filename' => array( - 'sortable' => 1, - 'default_sort_order' => 'asc', - 'align' => '', - 'separator' => '', - 'empty_column' => 0, - ), - 'type' => array( - 'sortable' => 1, - 'default_sort_order' => 'asc', - 'align' => '', - 'separator' => '', - 'empty_column' => 0, - ), - 'name' => array( - 'sortable' => 1, - 'default_sort_order' => 'asc', - 'align' => '', - 'separator' => '', - 'empty_column' => 0, - ), - 'filesize' => array( - 'sortable' => 1, - 'default_sort_order' => 'asc', - 'align' => '', - 'separator' => '', - 'empty_column' => 0, - ), - 'timestamp' => array( - 'sortable' => 1, - 'default_sort_order' => 'desc', - 'align' => '', - 'separator' => '', - 'empty_column' => 0, - ), - 'edit' => array( - 'sortable' => 0, - 'default_sort_order' => 'asc', - 'align' => '', - 'separator' => '', - 'empty_column' => 0, - ), - 'usage' => array( - 'sortable' => 1, - 'default_sort_order' => 'asc', - 'align' => '', - 'separator' => '', - 'empty_column' => 0, - ), - 'delete' => array( - 'sortable' => 0, - 'default_sort_order' => 'asc', - 'align' => '', - 'separator' => '', - 'empty_column' => 0, - ), + 'views_bulk_operations' => array( + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'filename' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'type' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'name' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'filesize' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'timestamp' => array( + 'sortable' => 1, + 'default_sort_order' => 'desc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'edit' => array( + 'sortable' => 0, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'usage' => array( + 'sortable' => 1, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + 'delete' => array( + 'sortable' => 0, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), ); $handler->display->display_options['style_options']['sticky'] = TRUE; $handler->display->display_options['style_options']['empty_table'] = TRUE; @@ -130,67 +130,67 @@ $handler->display->display_options['fields']['views_bulk_operations']['vbo_setti $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0; $handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '10'; $handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array( - 'action::views_bulk_operations_archive_action' => array( - 'selected' => 1, - 'postpone_processing' => 0, - 'skip_confirmation' => 0, - 'override_label' => 1, - 'label' => 'Archive', - 'settings' => array( - 'scheme' => 'public', - 'temporary' => 1, - ), - ), - 'action::views_bulk_operations_delete_item' => array( - 'selected' => 1, - 'postpone_processing' => 0, - 'skip_confirmation' => 0, - 'override_label' => 1, - 'label' => 'Delete', - ), - 'action::views_bulk_operations_script_action' => array( - 'selected' => 0, - 'postpone_processing' => 0, - 'skip_confirmation' => 0, - 'override_label' => 0, - 'label' => '', + 'action::views_bulk_operations_archive_action' => array( + 'selected' => 1, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 1, + 'label' => 'Archive', + 'settings' => array( + 'scheme' => 'public', + 'temporary' => 1, ), - 'action::views_bulk_operations_modify_action' => array( - 'selected' => 1, - 'postpone_processing' => 0, - 'skip_confirmation' => 1, - 'override_label' => 1, - 'label' => 'Change value', - 'settings' => array( - 'show_all_tokens' => 1, - 'display_values' => array( - '_all_' => '_all_', - ), + ), + 'action::views_bulk_operations_delete_item' => array( + 'selected' => 1, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 1, + 'label' => 'Delete', + ), + 'action::views_bulk_operations_script_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::views_bulk_operations_modify_action' => array( + 'selected' => 1, + 'postpone_processing' => 0, + 'skip_confirmation' => 1, + 'override_label' => 1, + 'label' => 'Change value', + 'settings' => array( + 'show_all_tokens' => 1, + 'display_values' => array( + '_all_' => '_all_', ), ), - 'action::views_bulk_operations_argument_selector_action' => array( - 'selected' => 0, - 'skip_confirmation' => 0, - 'override_label' => 0, - 'label' => '', - 'settings' => array( - 'url' => '', - ), - ), - 'action::system_send_email_action' => array( - 'selected' => 0, - 'postpone_processing' => 0, - 'skip_confirmation' => 0, - 'override_label' => 0, - 'label' => '', - ), - 'action::panelizer_set_status_action' => array( - 'selected' => 0, - 'postpone_processing' => 0, - 'skip_confirmation' => 0, - 'override_label' => 0, - 'label' => '', + ), + 'action::views_bulk_operations_argument_selector_action' => array( + 'selected' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + 'settings' => array( + 'url' => '', ), + ), + 'action::system_send_email_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), + 'action::panelizer_set_status_action' => array( + 'selected' => 0, + 'postpone_processing' => 0, + 'skip_confirmation' => 0, + 'override_label' => 0, + 'label' => '', + ), ); /* Field: File: Name */ $handler->display->display_options['fields']['filename']['id'] = 'filename'; @@ -267,9 +267,9 @@ $handler->display->display_options['filters']['filename']['expose']['operator'] $handler->display->display_options['filters']['filename']['expose']['identifier'] = 'filename'; $handler->display->display_options['filters']['filename']['expose']['remember'] = TRUE; $handler->display->display_options['filters']['filename']['expose']['remember_roles'] = array( - 2 => '2', - 1 => 0, - 3 => 0, + 2 => '2', + 1 => 0, + 3 => 0, ); /* Filter criterion: File: Type */ $handler->display->display_options['filters']['type']['id'] = 'type'; @@ -283,9 +283,9 @@ $handler->display->display_options['filters']['type']['expose']['operator'] = 't $handler->display->display_options['filters']['type']['expose']['identifier'] = 'type'; $handler->display->display_options['filters']['type']['expose']['remember'] = TRUE; $handler->display->display_options['filters']['type']['expose']['remember_roles'] = array( - 2 => '2', - 1 => 0, - 3 => 0, + 2 => '2', + 1 => 0, + 3 => 0, ); /* Filter criterion: User: Name */ $handler->display->display_options['filters']['uid']['id'] = 'uid'; @@ -301,9 +301,9 @@ $handler->display->display_options['filters']['uid']['expose']['operator'] = 'ui $handler->display->display_options['filters']['uid']['expose']['identifier'] = 'uid'; $handler->display->display_options['filters']['uid']['expose']['remember'] = TRUE; $handler->display->display_options['filters']['uid']['expose']['remember_roles'] = array( - 2 => '2', - 1 => 0, - 3 => 0, + 2 => '2', + 1 => 0, + 3 => 0, ); /* Display: System */ diff --git a/profiles/wcm_base/modules/contrib/file_entity/file_entity.admin.inc b/profiles/wcm_base/modules/contrib/file_entity/file_entity.admin.inc index b3e1a185..85e8c2e4 100644 --- a/profiles/wcm_base/modules/contrib/file_entity/file_entity.admin.inc +++ b/profiles/wcm_base/modules/contrib/file_entity/file_entity.admin.inc @@ -1,4 +1,5 @@ <?php + /** * @file * File administration and module settings UI. @@ -178,7 +179,7 @@ function file_entity_filter_form_submit($form, &$form_state) { * Array of key/value pairs with file field names and the * value to update that field to. */ -function file_entity_mass_update($files, $updates) { +function file_entity_mass_update(array $files, array $updates) { // We use batch processing to prevent timeout when updating a large number // of files. if (count($files) > 10) { @@ -323,17 +324,26 @@ function file_entity_admin_files() { 'timestamp' => array( 'data' => t('Updated'), 'field' => 'fm.timestamp', - 'sort' => 'desc'), + 'sort' => 'desc', + ), 'usage' => array('data' => t('Used in'), 'field' => 'total_count'), 'operations' => array('data' => t('Operations')), ); + if (variable_get('file_entity_total_count_optimization', FALSE)) { + // If the total_count is being retrieved by subqueries, + // the table is not sortable by this column. + unset($header['usage']['field']); + } + $query = db_select('file_managed', 'fm')->extend('PagerDefault')->extend('TableSort'); - $query->leftJoin('file_usage', 'fu', 'fm.fid = fu.fid'); - $query->groupBy('fm.fid'); - $query->groupBy('fm.uid'); - $query->groupBy('fm.timestamp'); - $query->addExpression('SUM(fu.count)', 'total_count'); + if (!variable_get('file_entity_total_count_optimization', FALSE)) { + $query->leftJoin('file_usage', 'fu', 'fm.fid = fu.fid'); + $query->groupBy('fm.fid'); + $query->groupBy('fm.uid'); + $query->groupBy('fm.timestamp'); + $query->addExpression('SUM(fu.count)', 'total_count'); + } file_entity_build_filter_query($query); $result = $query @@ -343,6 +353,24 @@ function file_entity_admin_files() { ->addTag('file_access') ->execute() ->fetchAllAssoc('fid'); + + if (variable_get('file_entity_total_count_optimization', FALSE)) { + // Get the total_count in separate queries, otherwise the main + // query will take too long. + // This setting can be configured under /admin/config/development/performance. + foreach ($result as &$file_result) { + $count_query = db_select('file_usage', 'fu') + ->fields('fu', array('fid', 'count')) + ->condition('fu.fid', $file_result->fid, '='); + $count_query->addExpression('SUM(fu.count)', 'total_count'); + $count_result = $count_query->execute()->fetchAll(); + + if (!empty($count_result[0]->total_count)) { + $file_result->total_count = $count_result[0]->total_count; + } + } + } + $files = file_load_multiple(array_keys($result)); $uids = array(); @@ -931,7 +959,6 @@ function file_entity_file_type_form_submit($form, &$form_state) { $form_state['redirect'] = 'admin/structure/file-types'; } - /** * Menu callback; disable a single file type. */ @@ -942,7 +969,6 @@ function file_entity_type_enable_confirm($form, &$form_state, $type) { return confirm_form($form, $message, 'admin/structure/file-types', '', t('Enable')); } - /** * Process file type disable confirm submissions. */ @@ -952,10 +978,8 @@ function file_entity_type_enable_confirm_submit($form, &$form_state) { drupal_set_message(t('The file type %label has been enabled.', $t_args)); watchdog('file_entity', 'Enabled file type %label.', $t_args, WATCHDOG_NOTICE); $form_state['redirect'] = 'admin/structure/file-types'; - return; } - /** * Menu callback; disable a single file type. */ @@ -989,10 +1013,8 @@ function file_entity_type_disable_confirm_submit($form, &$form_state) { drupal_set_message(t('The file type %label has been disabled.', $t_args)); watchdog('file_entity', 'Disabled file type %label.', $t_args, WATCHDOG_NOTICE); $form_state['redirect'] = 'admin/structure/file-types'; - return; } - /** * Menu callback; revert a single file type. */ @@ -1003,7 +1025,6 @@ function file_entity_type_revert_confirm($form, &$form_state, $type) { return confirm_form($form, $message, 'admin/structure/file-types', '', t('Revert')); } - /** * Process file type delete confirm submissions. */ @@ -1014,10 +1035,8 @@ function file_entity_type_revert_confirm_submit($form, &$form_state) { drupal_set_message(t('The file type %label has been reverted.', $t_args)); watchdog('file_entity', 'Reverted file type %label.', $t_args, WATCHDOG_NOTICE); $form_state['redirect'] = 'admin/structure/file-types'; - return; } - /** * Menu callback; delete a single file type. */ @@ -1049,7 +1068,6 @@ function file_entity_type_delete_confirm_submit($form, &$form_state) { watchdog('file_entity', 'Deleted file type %label.', $t_args, WATCHDOG_NOTICE); $form_state['redirect'] = 'admin/structure/file-types'; - return; } /** @@ -1065,6 +1083,23 @@ function file_entity_settings_form($form, &$form_state) { '#element_validate' => array('_file_generic_settings_max_filesize'), ); + $form['file_entity_default_file_directory'] = array( + '#type' => 'textfield', + '#title' => t('Default file directory'), + '#default_value' => variable_get('file_entity_default_file_directory', ''), + '#maxlength' => NULL, + ); + if (module_exists('token')) { + $form['file_entity_default_file_directory']['#description'] = t('Optional subdirectory within the upload destination where files will be stored if the file is uploaded through the file entity overview page and the directory is not specified otherwise. Do not include preceding or trailing slashes. This field supports tokens. Suggest using: [current-date:custom:Y]/[current-date:custom:m]/[current-date:custom:d]'); + $form['file_entity_default_file_directory']['tokens'] = array( + '#theme' => 'token_tree', + '#dialog' => TRUE, + ); + } + else { + $form['file_entity_default_file_directory']['#description'] = t('Optional subdirectory within the upload destination where files will be stored if the file is uploaded through the file entity overview page and the directory is not specified otherwise. Do not include preceding or trailing slashes.'); + } + $form['file_entity_default_allowed_extensions'] = array( '#type' => 'textfield', '#title' => t('Default allowed file extensions'), diff --git a/profiles/wcm_base/modules/contrib/file_entity/file_entity.api.php b/profiles/wcm_base/modules/contrib/file_entity/file_entity.api.php index 3a736812..01c6e881 100644 --- a/profiles/wcm_base/modules/contrib/file_entity/file_entity.api.php +++ b/profiles/wcm_base/modules/contrib/file_entity/file_entity.api.php @@ -78,7 +78,7 @@ function hook_file_formatter_info() { * Array of information on file formatters exposed by * hook_file_formatter_info() implementations. */ -function hook_file_formatter_info_alter(&$info) { +function hook_file_formatter_info_alter(array &$info) { // @todo Add example. } @@ -170,7 +170,7 @@ function hook_file_operations() { * - "delete" * - "update" * - "view" - * - "download" + * - "download". * @param object $file * The file on which the operation is to be performed, or, if it does * not yet exist, the type of file to be created. @@ -178,7 +178,7 @@ function hook_file_operations() { * A user object representing the user for whom the operation is to be * performed. * - * @return string|NULL + * @return string|null * FILE_ENTITY_ACCESS_ALLOW if the operation is to be allowed; * FILE_ENTITY_ACCESS_DENY if the operation is to be denied; * FILE_ENTITY_ACCESS_IGNORE to not affect this operation at all. @@ -377,7 +377,7 @@ function hook_file_type($file) { * @param object $file * File object. */ -function hook_file_type_alter(&$types, $file) { +function hook_file_type_alter(array &$types, $file) { // Choose a specific, non-first, file type. $types = array($types[4]); } diff --git a/profiles/wcm_base/modules/contrib/file_entity/file_entity.devel_generate.inc b/profiles/wcm_base/modules/contrib/file_entity/file_entity.devel_generate.inc index 05842c30..7de4483e 100644 --- a/profiles/wcm_base/modules/contrib/file_entity/file_entity.devel_generate.inc +++ b/profiles/wcm_base/modules/contrib/file_entity/file_entity.devel_generate.inc @@ -5,6 +5,11 @@ * Devel generate integration for the File Entity module. */ +/** + * Devel generate file form. + * + * Options for Devel generate file integration. + */ function file_entity_generate_file_form() { $form['count'] = array( '#type' => 'textfield', @@ -32,12 +37,18 @@ function file_entity_generate_file_form() { return $form; } +/** + * Implements hook_ID_form_submit(). + */ function file_entity_generate_file_form_submit(&$form, &$form_state) { $file_types = array_values(array_filter($form_state['values']['file_types'])); $batch = file_entity_generate_file_batch_info($form_state['values']['count'], $file_types, $form_state['values']['delete']); batch_set($batch); } +/** + * Implements hook_batch_info(). + */ function file_entity_generate_file_batch_info($count, array $file_types = array(), $delete = FALSE) { if (empty($file_types)) { $file_types = array_keys(file_entity_type_get_names()); @@ -56,6 +67,9 @@ function file_entity_generate_file_batch_info($count, array $file_types = array( ); } +/** + * Implements hook_batch_delete(). + */ function file_entity_generate_file_batch_delete(array $file_types, array &$context) { if (empty($context['sandbox'])) { $context['sandbox'] = array(); @@ -80,6 +94,9 @@ function file_entity_generate_file_batch_delete(array $file_types, array &$conte } } +/** + * Implements hook_generate_file_batch_generate() using Devel generate api. + */ function file_entity_generate_file_batch_generate(array $file_types, $num, array &$context) { if (empty($context['sandbox'])) { module_load_include('inc', 'devel_generate'); @@ -114,6 +131,9 @@ function file_entity_generate_file_batch_generate(array $file_types, $num, array } } +/** + * When the batch is finished set a status message. + */ function file_entity_generate_file_batch_finished($success, $results, $operations) { if ($success) { drupal_set_message(format_plural(count($results), 'One file created.', '@count files created.')); @@ -126,6 +146,9 @@ function file_entity_generate_file_batch_finished($success, $results, $operation } } +/** + * Generate file function for file_entity. + */ function file_entity_generate_file($file_type) { $type = file_type_load($file_type); $possible_extensions = file_type_get_valid_extensions($type); diff --git a/profiles/wcm_base/modules/contrib/file_entity/file_entity.field.inc b/profiles/wcm_base/modules/contrib/file_entity/file_entity.field.inc index 1701c88f..4f7a11b4 100644 --- a/profiles/wcm_base/modules/contrib/file_entity/file_entity.field.inc +++ b/profiles/wcm_base/modules/contrib/file_entity/file_entity.field.inc @@ -272,6 +272,18 @@ function file_entity_field_formatter_settings_summary($field, $instance, $view_m return implode('<br />', $summary); } +/** + * Implements hook_field_formatter_prepare_view(). + */ +function file_entity_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) { + // File and image fields set item values to NULL if a file cannot be loaded. + // Remove those empty items so we can simply iterate through $items normally + // in file_entity_field_formatter_view(). + foreach (array_keys($entities) as $id) { + $items[$id] = array_filter($items[$id]); + } +} + /** * Implements hook_field_formatter_view(). */ @@ -284,45 +296,66 @@ function file_entity_field_formatter_view($entity_type, $entity, $field, $instan foreach ($items as $delta => $item) { // Protect ourselves from recursive rendering. static $recursive_render_depth = array(); - $recursive_render_id = $entity_type . $field['field_name'] . $item['fid']; + if (!empty($item)) { + $recursive_render_id = $entity_type . $field['field_name'] . $item['fid']; + if (isset($recursive_render_depth[$recursive_render_id])) { + $recursive_render_depth[$recursive_render_id]++; + } + else { + $recursive_render_depth[$recursive_render_id] = 1; + } - if (isset($recursive_render_depth[$recursive_render_id])) { - $recursive_render_depth[$recursive_render_id]++; - } - else { - $recursive_render_depth[$recursive_render_id] = 1; - } + if ($recursive_render_depth[$recursive_render_id] > 20) { + watchdog( + 'file_entity', + 'Recursive rendering detected when rendering entity %entity_type: %entity_id, using the %field_name field. Aborting rendering.', + array( + '%entity_type' => 'file', + '%entity_id' => $item['fid'], + '%field_name' => $field['field_name'], + ), + WATCHDOG_ERROR + ); + return $element; + } + + $file = file_load($item['fid']); + if (isset($item['display'])) { + $file->display = $item['display']; + } + if (isset($item['description'])) { + $file->description = $item['description']; + } + + // Add some references to the referencing entity. + // @see https://www.drupal.org/node/2333107 + $file->referencing_entity = $entity; + $file->referencing_entity_type = $entity_type; + $file->referencing_field = $field['field_name']; - if ($recursive_render_depth[$recursive_render_id] > 20) { + // Untranslatable fields are rendered with no language code, fall back + // to the content language in that case. + $element[$delta] = file_view($file, $settings['file_view_mode'], $langcode !== LANGUAGE_NONE ? $langcode : NULL); + } else { watchdog( 'file_entity', - 'Recursive rendering detected when rendering entity %entity_type: %entity_id, using the %field_name field. Aborting rendering.', + 'In the %referencing_entity_type, the %field_name field refers to a %entity_type which does not exist. Aborting the render for it.', array( - '%entity_type' => 'file', - '%entity_id' => $item['fid'], + '%referencing_entity_type' => $entity_type, '%field_name' => $field['field_name'], + '%entity_type' => 'file', ), WATCHDOG_ERROR ); - return $element; } - - $file = (object) $item; - - // Add some references to the referencing entity. - // @see https://www.drupal.org/node/2333107 - $file->referencing_entity = $entity; - $file->referencing_entity_type = $entity_type; - $file->referencing_field = $field['field_name']; - - $element[$delta] = file_view($file, $settings['file_view_mode'], $langcode); } break; case 'file_download_link': + // Prevent 'empty' fields from causing a WSOD. + $items = array_filter($items); foreach ($items as $delta => $item) { - $file = (object) $item; - if (file_entity_access('download', $file)) { + if (!empty($item['fid']) && ($file = file_load($item['fid'])) && file_entity_access('download', $file)) { $element[$delta] = array( '#theme' => 'file_entity_download_link', '#file' => $file, @@ -335,21 +368,18 @@ function file_entity_field_formatter_view($entity_type, $entity, $field, $instan case 'file_audio': $multiple_file_behavior = $settings['multiple_file_behavior']; - // Prevent 'empty' fields from causing a WSOD. - $items = array_filter($items); - // Build an array of sources for each <audio> element. $source_lists = array(); if ($multiple_file_behavior == 'tags') { foreach ($items as $delta => $item) { - if ($item['type'] == 'audio') { + if (file_entity_file_get_mimetype_type($item) == 'audio') { $source_lists[$delta] = array($item); } } } else { foreach ($items as $delta => $item) { - if ($item['type'] == 'audio') { + if (file_entity_file_get_mimetype_type($item) == 'audio') { $source_lists[0][$delta] = $item; } } @@ -371,21 +401,18 @@ function file_entity_field_formatter_view($entity_type, $entity, $field, $instan case 'file_video': $multiple_file_behavior = $settings['multiple_file_behavior']; - // Prevent 'empty' fields from causing a WSOD. - $items = array_filter($items); - // Build an array of sources for each <video> element. $source_lists = array(); if ($multiple_file_behavior == 'tags') { foreach ($items as $delta => $item) { - if ($item['type'] == 'video') { + if (file_entity_file_get_mimetype_type($item) == 'video') { $source_lists[$delta] = array($item); } } } else { foreach ($items as $delta => $item) { - if ($item['type'] == 'video') { + if (file_entity_file_get_mimetype_type($item) == 'video') { $source_lists[0][$delta] = $item; } } diff --git a/profiles/wcm_base/modules/contrib/file_entity/file_entity.file.inc b/profiles/wcm_base/modules/contrib/file_entity/file_entity.file.inc index c9aab5c0..ef505b4d 100644 --- a/profiles/wcm_base/modules/contrib/file_entity/file_entity.file.inc +++ b/profiles/wcm_base/modules/contrib/file_entity/file_entity.file.inc @@ -95,7 +95,18 @@ function file_entity_file_update($file) { $query->execute(); } - if (module_exists('image') && file_entity_file_get_mimetype_type($file) == 'image' && $file->filesize) { + if (module_exists('image') && file_entity_file_get_mimetype_type($file) == 'image' && $file->filesize && isset($file->original)) { + if (!isset($file->metadata)) { + $file->metadata = array(); + } + + if (!isset($file->original->metadata)) { + if (!is_object($file->original)) { + $file->original = new stdClass(); + } + $file->original->metadata = array(); + } + // If the file has changed dimensions or a new file has been uploaded, // update any image field reference to this file and flush image style // derivatives. diff --git a/profiles/wcm_base/modules/contrib/file_entity/file_entity.info b/profiles/wcm_base/modules/contrib/file_entity/file_entity.info index 03afc179..347861b6 100644 --- a/profiles/wcm_base/modules/contrib/file_entity/file_entity.info +++ b/profiles/wcm_base/modules/contrib/file_entity/file_entity.info @@ -9,6 +9,7 @@ dependencies[] = ctools dependencies[] = system (>=7.33) test_dependencies[] = token +test_dependencies[] = views files[] = views/views_handler_argument_file_type.inc files[] = views/views_handler_field_file_rendered.inc @@ -24,15 +25,16 @@ files[] = views/views_handler_field_file_link_usage.inc files[] = views/views_plugin_row_file_rss.inc files[] = views/views_plugin_row_file_view.inc files[] = file_entity.test +files[] = file_entity_views.test 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 2016-05-31 -version = "7.x-2.0-beta3" +; Information added by Drupal.org packaging script on 2017-08-10 +version = "7.x-2.4" core = "7.x" project = "file_entity" -datestamp = "1464653173" +datestamp = "1502334549" diff --git a/profiles/wcm_base/modules/contrib/file_entity/file_entity.install b/profiles/wcm_base/modules/contrib/file_entity/file_entity.install index 6f07b917..526d043c 100644 --- a/profiles/wcm_base/modules/contrib/file_entity/file_entity.install +++ b/profiles/wcm_base/modules/contrib/file_entity/file_entity.install @@ -239,6 +239,7 @@ function file_entity_uninstall() { // Remove variables. variable_del('file_entity_max_filesize'); variable_del('file_entity_default_allowed_extensions'); + variable_del('file_entity_default_file_directory'); variable_del('file_entity_alt'); variable_del('file_entity_title'); variable_del('file_entity_allow_insecure_download'); diff --git a/profiles/wcm_base/modules/contrib/file_entity/file_entity.module b/profiles/wcm_base/modules/contrib/file_entity/file_entity.module index 36f82830..ada703f0 100644 --- a/profiles/wcm_base/modules/contrib/file_entity/file_entity.module +++ b/profiles/wcm_base/modules/contrib/file_entity/file_entity.module @@ -1141,8 +1141,8 @@ function file_entity_file_formatter_info() { 'label' => t('Image'), 'default settings' => array( 'image_style' => '', - 'alt' => '[file:field_file_image_alt_text]', - 'title' => '[file:field_file_image_title_text]' + 'alt' => '[file:field-file-image-alt-text]', + 'title' => '[file:field-file-image-title-text]' ), 'view callback' => 'file_entity_file_formatter_file_image_view', 'settings callback' => 'file_entity_file_formatter_file_image_settings', @@ -1677,7 +1677,16 @@ function file_entity_access($op, $file = NULL, $account = NULL) { // $file may be either an object or a file type. Since file types cannot be // an integer, use either fid or type as the static cache id. - $cache_id = is_object($file) ? $file->fid : $file; + $cache_id = NULL; + if (!empty($file->id)) { + $cache_id = $file->id; + } + elseif (is_string($file) && $op == 'create') { + $cache_id = $file; + } + else { + $cache_id = drupal_hash_base64(serialize($file)); + } // If we've already checked access for this file, user and op, return from // cache. @@ -1738,7 +1747,10 @@ function file_entity_access($op, $file = NULL, $account = NULL) { */ function file_entity_file_entity_access($op, $file, $account) { // If the file URI is invalid, deny access. - if (is_object($file) && !file_valid_uri($file->uri)) { + if (is_object($file) && isset($file->uri) && !file_valid_uri($file->uri)) { + if(isset($file->is_new) && $file->is_new == true && user_access('create files')) { + return FILE_ENTITY_ACCESS_ALLOW; + } return FILE_ENTITY_ACCESS_DENY; } @@ -1794,7 +1806,7 @@ function file_entity_query_file_access_alter(QueryAlterableInterface $query) { * access conditions are added for field values belonging to files only. */ function file_entity_query_entity_field_access_alter(QueryAlterableInterface $query) { - //_file_entity_query_file_entity_access_alter($query, 'entity'); + _file_entity_query_file_entity_access_alter($query, 'entity'); } /** @@ -1822,11 +1834,17 @@ function _file_entity_query_file_entity_access_alter($query, $type) { $tables = $query->getTables(); $base_table = $query->getMetaData('base_table'); + // Do not use the base table for general entity queries unless this is + // querying the file_managed table directly. + if ($base_table && $type == 'entity' && $base_table != 'file_managed') { + $base_table = ''; + } + // If no base table is specified explicitly, search for one. if (!$base_table) { $fallback = ''; foreach ($tables as $alias => $table_info) { - if (!($table_info instanceof SelectQueryInterface)) { + if (!($table_info instanceof SelectQueryInterface || $table_info['table'] instanceof SelectQueryInterface)) { $table = $table_info['table']; // If the file_managed table is in the query, it wins immediately. if ($table == 'file_managed') { @@ -1853,6 +1871,10 @@ function _file_entity_query_file_entity_access_alter($query, $type) { $fallback = $table; } } + elseif (isset($schema['fields']['entity_id']) && isset($schema['fields']['entity_type']) && isset($schema['fields']['deleted']) && isset($schema['fields']['delta'])) { + // The table is a field data table, use it as fallback. + $base_table = $table; + } } } } @@ -1863,6 +1885,11 @@ function _file_entity_query_file_entity_access_alter($query, $type) { $base_table = $fallback; } else { + // Ignore this query as it was a general field query and no + // relationships were found to the file_managed table. + if ($type == 'entity') { + return; + } throw new Exception(t('Query tagged for file access but there is no fid. Add foreign keys to file_managed.fid in schema to fix.')); } } @@ -1925,33 +1952,36 @@ function _file_entity_query_file_entity_access_alter($query, $type) { } } - if ($subquery_conditions->count()) { + // If there is no subquery conditions, the query is likely for file usage. + // Or user can only access public files. + // If there are subquery conditions then add them to the subquery. + if ($subquery_conditions->count() >= 1) { $subquery->condition($subquery_conditions); + } - $field = 'fid'; - // Now handle entities. - if ($type == 'entity') { - // Set a common alias for entities. - $base_alias = $falias; - $field = 'entity_id'; - } - $subquery->where("$falias.$field = fm_access.fid"); + $field = 'fid'; + // Now handle entities. + if ($type == 'entity') { + // Set a common alias for entities. + $base_alias = $falias; + $field = ($falias == 'file_managed' ? 'fid' : 'entity_id'); + } + $subquery->where("$falias.$field = fm_access.fid"); - // For an entity query, attach the subquery to entity conditions. - if ($type == 'entity') { - $file_conditions->exists($subquery); - } - // Otherwise attach it to the node query itself. - elseif ($table == 'file_managed') { - // Fix for https://drupal.org/node/2073085 - $db_or = db_or(); - $db_or->exists($subquery); - $db_or->isNull($falias . '.' . $field); - $query->condition($db_or); - } - else { - $query->exists($subquery); - } + // For an entity query, attach the subquery to entity conditions. + if ($type == 'entity') { + $file_conditions->exists($subquery); + } + // Otherwise attach it to the node query itself. + elseif ($table == 'file_managed') { + // Fix for https://drupal.org/node/2073085 + $db_or = db_or(); + $db_or->exists($subquery); + $db_or->isNull($falias . '.' . $field); + $query->condition($db_or); + } + else { + $query->exists($subquery); } } } @@ -1959,14 +1989,19 @@ function _file_entity_query_file_entity_access_alter($query, $type) { if ($type == 'entity' && $file_conditions->count()) { // All the file access conditions are only for field values belonging to // files. - $file_conditions->condition("$base_alias.entity_type", 'file'); - $or = db_or(); - $or->condition($file_conditions); - // If the field value belongs to a non-file entity type then this function - // does not do anything with it. - $or->condition("$base_alias.entity_type", 'file', '<>'); - // Add the compiled set of rules to the query. - $query->condition($or); + if ($base_alias !== 'file_managed') { + $file_conditions->condition("$base_alias.entity_type", 'file'); + $or = db_or(); + $or->condition($file_conditions); + // If the field value belongs to a non-file entity type then this function + // does not do anything with it. + $or->condition("$base_alias.entity_type", 'file', '<>'); + // Add the compiled set of rules to the query. + $query->condition($or); + } + else { + $query->condition($file_conditions); + } } } @@ -2113,6 +2148,10 @@ function file_entity_file_default_types() { 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'application/zip', + 'application/x-7z-compressed', + 'application/x-tar', + 'application/gzip', ), ); @@ -2479,6 +2518,9 @@ function file_entity_download_uri($file) { } function file_entity_file_get_mimetype_type($file) { + if (is_array($file)) { + $file = (object) $file; + } list($type, $subtype) = explode('/', $file->filemime, 2); return $type; } @@ -2600,3 +2642,15 @@ function file_entity_features_pipe_file_type_alter(&$pipe, $data, $export) { $pipe['variable'][] = "pathauto_file_{$file_type}_pattern"; } } + +/** + * Implements hook_FORM_ID_alter(). + */ +function file_entity_form_system_performance_settings_alter(&$form, &$form_state) { + $form['bandwidth_optimization']['file_entity_total_count_optimization'] = array( + '#type' => 'checkbox', + '#title' => t('Optimize the calculation of the total usage count of files in the files overview.'), + '#default_value' => variable_get('file_entity_total_count_optimization', FALSE), + '#description' => t('Recommended if the files admin page loads too slowly due to a high number of files.'), + ); +} diff --git a/profiles/wcm_base/modules/contrib/file_entity/file_entity.pages.inc b/profiles/wcm_base/modules/contrib/file_entity/file_entity.pages.inc index 65262b61..488b37fd 100644 --- a/profiles/wcm_base/modules/contrib/file_entity/file_entity.pages.inc +++ b/profiles/wcm_base/modules/contrib/file_entity/file_entity.pages.inc @@ -35,10 +35,12 @@ function file_entity_download_page($file) { if (!is_file($file->uri)) { return MENU_NOT_FOUND; } - + // @todo Remove this once drupal_basename is fixed for PHP versions greater + // than '5.3.29'. + $basename_function = version_compare(PHP_VERSION,'5.3.29','>') ? 'basename' : 'drupal_basename'; $headers = array( 'Content-Type' => mime_header_encode($file->filemime), - 'Content-Disposition' => 'attachment; filename="' . mime_header_encode(drupal_basename($file->uri)) . '"', + 'Content-Disposition' => 'attachment; filename="' . mime_header_encode($basename_function($file->uri)) . '"', 'Content-Length' => $file->filesize, 'Content-Transfer-Encoding' => 'binary', 'Pragma' => 'no-cache', @@ -77,10 +79,21 @@ function file_entity_download_page($file) { * - Edit fields * Skip this step if there are no fields on this entity type. */ -function file_entity_add_upload($form, &$form_state, array $options = array()) { +function file_entity_add_upload($form, &$form_state, $options = array()) { + if (!is_array($options)) { + $options = array($options); + } $step = (isset($form_state['step']) && in_array($form_state['step'], array(1, 2, 3, 4))) ? $form_state['step'] : 1; $form['#step'] = $step; - $form['#options'] = $options; + $form['#options'] = $options + array( + 'types' => array(), + 'enabledPlugins' => array(), + 'schemes' => array(), + 'max_filesize' => '', + 'uri_scheme' => 'public', + 'plugins' => '' + ); + switch ($step) { case 1: return file_entity_add_upload_step_upload($form, $form_state, $options); @@ -193,11 +206,12 @@ function file_entity_validate_size_extensions(stdClass $file, $file_limit = 0, $ */ function file_entity_add_upload_step_filetype($form, &$form_state, array $options = array()) { $file = file_load($form_state['storage']['upload']); + $selected_files = $form['#options']['types']; $form['type'] = array( '#type' => 'radios', '#title' => t('File type'), - '#options' => file_entity_get_filetype_candidates($file), + '#options' => file_entity_get_filetype_candidates($file, $selected_files), '#default_value' => isset($form_state['storage']['type']) ? $form_state['storage']['type'] : NULL, '#required' => TRUE, ); @@ -372,9 +386,17 @@ function file_entity_usage_page($file) { * @return array * An array of file type bundles that support the file's mime type. */ -function file_entity_get_filetype_candidates($file) { +function file_entity_get_filetype_candidates($file, $selected_files = array()) { $types = module_invoke_all('file_type', $file); drupal_alter('file_type', $types, $file); + + // If no file types are selected in field instance settings, allow all + // available types. + if (!empty($selected_files)) { + // Limit file type candidates to field allowed types. + $types = array_intersect($types, $selected_files); + } + $candidates = array(); foreach ($types as $type) { $file->type = $type; @@ -392,6 +414,9 @@ function file_entity_add_upload_submit($form, &$form_state) { $form_state['storage'] = isset($form_state['storage']) ? $form_state['storage'] : array(); $form_state['storage'] = array_merge($form_state['storage'], $form_state['values']); + // Field selected allowed types. + $selected_files = $form['#options']['types']; + // This var is set to TRUE when we are ready to save the file. $save = FALSE; $trigger = $form_state['triggering_element']['#id']; @@ -409,7 +434,7 @@ function file_entity_add_upload_submit($form, &$form_state) { $file = file_load($form_state['storage']['upload']); if ($step == 2) { // Check if we can skip step 2. - $candidates = file_entity_get_filetype_candidates($file); + $candidates = file_entity_get_filetype_candidates($file, $selected_files); if (count($candidates) == 1) { $candidates_keys = array_keys($candidates); // There is only one possible filetype for this file. @@ -463,6 +488,7 @@ function file_entity_add_upload_submit($form, &$form_state) { // We have the filetype, check if we can skip step 4. if (($form['#step'] == 3 && $trigger == 'edit-next')) { $file = file_load($form_state['storage']['upload']); + $form_state['file'] = $file; if (!field_info_instances('file', $form_state['storage']['type'])) { // This filetype doesn't have fields, save the file. $save = TRUE; @@ -550,7 +576,7 @@ function file_entity_add_upload_submit($form, &$form_state) { function file_entity_upload_destination_uri(array $params, array $data = array()) { $params += array( 'uri_scheme' => file_default_scheme(), - 'file_directory' => '', + 'file_directory' => variable_get('file_entity_default_file_directory', ''), ); $destination = trim($params['file_directory'], '/'); @@ -865,21 +891,28 @@ function file_entity_edit_submit($form, &$form_state) { if (!empty($form_state['values']['replace_upload'])) { $replacement = $form_state['values']['replace_upload']; // Move file from temp to permanent home. - $destination_uri = rtrim($file->uri, drupal_basename($file->uri)) . drupal_basename($replacement->uri); - $replace_mode = $destination_uri == $file->uri ? FILE_EXISTS_REPLACE : FILE_EXISTS_RENAME; - if ($new_file_uri = file_unmanaged_copy($replacement->uri, $destination_uri, $replace_mode)) { - // @todo Add watchdog() about replaced file here? - - // Remove temporary file. - file_delete($replacement); - - // Update if the uri target has changed. - if ($new_file_uri != $file->uri) { - // Store the original file uri to delete if save is successful. - $orphaned_uri = $file->uri; - - // Update file entity uri. - $file->uri = $new_file_uri; + if (pathinfo($replacement->uri, PATHINFO_EXTENSION) == pathinfo($file->uri, PATHINFO_EXTENSION)) { + if ($new_file_uri = file_unmanaged_copy($replacement->uri, $file->uri, FILE_EXISTS_REPLACE)) { + // Remove temporary file. + file_delete($replacement); + } + } else { + $destination_uri = rtrim($file->uri, drupal_basename($file->uri)) . drupal_basename($replacement->uri); + $replace_mode = $destination_uri == $file->uri ? FILE_EXISTS_REPLACE : FILE_EXISTS_RENAME; + if ($new_file_uri = file_unmanaged_copy($replacement->uri, $destination_uri, $replace_mode)) { + // @todo Add watchdog() about replaced file here? + + // Remove temporary file. + file_delete($replacement); + + // Update if the uri target has changed. + if ($new_file_uri != $file->uri) { + // Store the original file uri to delete if save is successful. + $orphaned_uri = $file->uri; + + // Update file entity uri. + $file->uri = $new_file_uri; + } } } } @@ -908,6 +941,9 @@ function file_entity_edit_submit($form, &$form_state) { if (file_uri_scheme($file->uri) != $form_state['values']['scheme']) { $file_destination = $form_state['values']['scheme'] . '://' . file_uri_target($file->uri); $file_destination = file_stream_wrapper_uri_normalize($file_destination); + $file_destination_dirname = drupal_dirname($file_destination); + // Create the directory in case it doesn't exist. + file_prepare_directory($file_destination_dirname, FILE_CREATE_DIRECTORY); if ($moved_file = file_move($file, $file_destination, FILE_EXISTS_RENAME)) { // Only re-assign the file object if file_move() did not fail. $file = $moved_file; diff --git a/profiles/wcm_base/modules/contrib/file_entity/file_entity.pathauto.inc b/profiles/wcm_base/modules/contrib/file_entity/file_entity.pathauto.inc index 3b3d6957..98befe3a 100644 --- a/profiles/wcm_base/modules/contrib/file_entity/file_entity.pathauto.inc +++ b/profiles/wcm_base/modules/contrib/file_entity/file_entity.pathauto.inc @@ -27,7 +27,7 @@ function file_entity_pathauto($op) { $settings['token_type'] = 'file'; $settings['groupheader'] = t('File paths'); $settings['patterndescr'] = t('Default path pattern (applies to all file types with blank patterns below)'); - $settings['patterndefault'] = 'files/[file:name]'; + $settings['patterndefault'] = ''; $settings['batch_update_callback'] = 'file_entity_pathauto_bulk_update_batch_process'; $settings['batch_file'] = drupal_get_path('module', 'file_entity') . '/file_entity.pathauto.inc'; diff --git a/profiles/wcm_base/modules/contrib/file_entity/file_entity.test b/profiles/wcm_base/modules/contrib/file_entity/file_entity.test index 20f47cab..96a45102 100644 --- a/profiles/wcm_base/modules/contrib/file_entity/file_entity.test +++ b/profiles/wcm_base/modules/contrib/file_entity/file_entity.test @@ -1205,7 +1205,7 @@ class FileEntityTypeTestCase extends FileEntityTestHelper { $this->drupalGet('admin/structure/file-types'); $this->assertResponse(403, 'File types UI page is not accessible to unauthorized users.'); - $user = $this->drupalCreateUser(array('administer file types')); + $user = $this->drupalCreateUser(array('administer file types', 'administer fields')); $this->drupalLogin($user); $this->drupalGet('admin/structure/file-types'); @@ -1671,4 +1671,132 @@ class FileEntityAttributeOverrideTestCase extends FileEntityTestHelper { $this->assertEqual($build['#file']->$attribute, $expected_value, format_string('The %attribute was overridden correctly.', array('%attribute' => $attribute))); } } + + /** + * @param EntityFieldQuery $query + * @param $expected + * An associative array of expected result. Keys are file ids, values are + * booleans to indicate if the result should include the file. + */ + function assertEntityFieldQueryAccess(EntityFieldQuery $query, $expected, $account = NULL, $query_name = 'unnamed') { + if ($account) { + $query->addMetaData('account', $account); + } + $query->addTag('entity_field_access'); + $results = $query->execute(); + $fids = isset($results['file']) ? array_keys($results['file']) : array(); + foreach ($expected as $fid => $in_result) { + if ($in_result) { + $this->assertTrue(in_array($fid, $fids), format_string("For the %name query, the result should contain %fid", array('%name' => $query_name, '%fid' => $fid))); + } + else { + $this->assertFalse(in_array($fid, $fids), format_string("For the %name query, the result should not contain %fid", array('%name' => $query_name, '%fid' => $fid))); + } + } + } + + /** + * Test file entity access for entity field queries. + */ + function testEntityFieldQueryAccess() { + // Attach a text field to the default image file type. + $field = array( + 'field_name' => drupal_strtolower($this->randomName()), + 'type' => 'text', + 'settings' => array( + 'max_length' => 255, + ) + ); + field_create_field($field); + $instance = array( + 'field_name' => $field['field_name'], + 'entity_type' => 'file', + 'bundle' => 'document', + 'widget' => array( + 'type' => 'text_textfield', + ), + 'display' => array( + 'default' => array( + 'type' => 'text_default', + ), + ), + ); + field_create_instance($instance); + // Create test files. + $file_owner = $this->drupalCreateUser(array('view own files', 'view own private files')); + $public_file = $this->createFileEntity(array( + 'status' => 0, + )); + $private_file = $this->createFileEntity(array('scheme' => 'private')); + $owned_public_file = $this->createFileEntity(array( + 'uid' => $file_owner->uid, + 'scheme' => 'public', + )); + $owned_private_file = $this->createFileEntity(array( + 'uid' => $file_owner->uid, + 'scheme' => 'private', + )); + $fids = array( + $public_file->fid, + $private_file->fid, + $owned_public_file->fid, + $owned_private_file->fid, + ); + foreach (file_load_multiple($fids) as $file) { + $file->{$field['field_name']}[LANGUAGE_NONE][0] = array('value' => 'find me'); + file_save($file); + } + + $efq_fids = new EntityFieldQuery(); + $queries['entity type and id conditions'] = $efq_fids + ->entityCondition('entity_type', 'file') + ->entityCondition('entity_id', $fids); + $efq_field_name = new EntityFieldQuery(); + $queries['single field condition'] = $efq_field_name + ->fieldCondition($field['field_name'], 'value', 'find me'); + + foreach($queries as $name => $query) { + $message = format_string(''); + // User should not see private files, only his own public files. + $this->assertEntityFieldQueryAccess(clone $query, array( + $public_file->fid => TRUE, + $private_file->fid => FALSE, + $owned_public_file->fid => TRUE, + $owned_private_file->fid => FALSE, + ), $this->drupalCreateUser(array('create files')), $name); + + // A user with the 'view own files' and 'view own private files' permissions should only see owned files and public files. + $this->drupalLogin($file_owner); + $this->assertEntityFieldQueryAccess(clone $query, array( + $public_file->fid => TRUE, + $private_file->fid => FALSE, + $owned_public_file->fid => TRUE, + $owned_private_file->fid => TRUE, + ), $file_owner, $name); + + // User with the 'view files' permission should only see public files but cannot create files. + $this->assertEntityFieldQueryAccess(clone $query, array( + $public_file->fid => TRUE, + $private_file->fid => FALSE, + $owned_public_file->fid => TRUE, + $owned_private_file->fid => FALSE, + ), $this->drupalCreateUser(array('view files')), $name); + + // User with the 'view files' and 'view private files' permissions should only see all files. + $this->assertEntityFieldQueryAccess(clone $query, array( + $public_file->fid => TRUE, + $private_file->fid => TRUE, + $owned_public_file->fid => TRUE, + $owned_private_file->fid => TRUE, + ), $this->drupalCreateUser(array('view files', 'view private files')), $name); + + // User with the 'bypass file access' permissions should only see all files. + $this->assertEntityFieldQueryAccess(clone $query, array( + $public_file->fid => TRUE, + $private_file->fid => TRUE, + $owned_public_file->fid => TRUE, + $owned_private_file->fid => TRUE, + ), $this->drupalCreateUser(array('bypass file access')), $name); + } + } } diff --git a/profiles/wcm_base/modules/contrib/file_entity/file_entity.theme.inc b/profiles/wcm_base/modules/contrib/file_entity/file_entity.theme.inc index c05d3320..aa78d5d2 100644 --- a/profiles/wcm_base/modules/contrib/file_entity/file_entity.theme.inc +++ b/profiles/wcm_base/modules/contrib/file_entity/file_entity.theme.inc @@ -12,18 +12,37 @@ */ function theme_file_entity_file_link($variables) { $file = $variables['file']; - $icon_directory = $variables['icon_directory']; + $uri = entity_uri('file', $file); + + // Human-readable names, for use as text-alternatives to icons. + $mime_name = array( + 'application/msword' => t('Microsoft Office document icon'), + 'application/vnd.ms-excel' => t('Office spreadsheet icon'), + 'application/vnd.ms-powerpoint' => t('Office presentation icon'), + 'application/pdf' => t('PDF icon'), + 'video/quicktime' => t('Movie icon'), + 'audio/mpeg' => t('Audio icon'), + 'audio/wav' => t('Audio icon'), + 'image/jpeg' => t('Image icon'), + 'image/png' => t('Image icon'), + 'image/gif' => t('Image icon'), + 'application/zip' => t('Package icon'), + 'text/html' => t('HTML icon'), + 'text/plain' => t('Plain text icon'), + 'application/octet-stream' => t('Binary Data'), + ); + + $mimetype = file_get_mimetype($file->uri); - $url = 'file/' . $file->fid; - $icon = theme('file_icon', array('file' => $file, 'icon_directory' => $icon_directory)); + $icon = theme('file_icon', array( + 'file' => $file, + 'icon_directory' => $variables['icon_directory'], + 'alt' => !empty($mime_name[$mimetype]) ? $mime_name[$mimetype] : t('File'), + )); // Set options as per anchor format described at // http://microformats.org/wiki/file-format-examples - $options = array( - 'attributes' => array( - 'type' => $file->filemime . '; length=' . $file->filesize, - ), - ); + $uri['options']['attributes']['type'] = $file->filemime . '; length=' . $file->filesize; // Use the description as the link text if available. if (empty($file->description)) { @@ -44,10 +63,33 @@ function theme_file_entity_file_link($variables) { */ function theme_file_entity_download_link($variables) { $file = $variables['file']; - $icon_directory = $variables['icon_directory']; - $uri = file_entity_download_uri($file); - $icon = theme('file_icon', array('file' => $file, 'icon_directory' => $icon_directory)); + + // Human-readable names, for use as text-alternatives to icons. + $mime_name = array( + 'application/msword' => t('Microsoft Office document icon'), + 'application/vnd.ms-excel' => t('Office spreadsheet icon'), + 'application/vnd.ms-powerpoint' => t('Office presentation icon'), + 'application/pdf' => t('PDF icon'), + 'video/quicktime' => t('Movie icon'), + 'audio/mpeg' => t('Audio icon'), + 'audio/wav' => t('Audio icon'), + 'image/jpeg' => t('Image icon'), + 'image/png' => t('Image icon'), + 'image/gif' => t('Image icon'), + 'application/zip' => t('Package icon'), + 'text/html' => t('HTML icon'), + 'text/plain' => t('Plain text icon'), + 'application/octet-stream' => t('Binary Data'), + ); + + $mimetype = file_get_mimetype($file->uri); + + $icon = theme('file_icon', array( + 'file' => $file, + 'icon_directory' => $variables['icon_directory'], + 'alt' => !empty($mime_name[$mimetype]) ? $mime_name[$mimetype] : t('File'), + )); // Set options as per anchor format described at // http://microformats.org/wiki/file-format-examples diff --git a/profiles/wcm_base/modules/contrib/file_entity/file_entity.tpl.php b/profiles/wcm_base/modules/contrib/file_entity/file_entity.tpl.php index cc12db7c..69e9a631 100644 --- a/profiles/wcm_base/modules/contrib/file_entity/file_entity.tpl.php +++ b/profiles/wcm_base/modules/contrib/file_entity/file_entity.tpl.php @@ -84,9 +84,15 @@ <div class="content"<?php print $content_attributes; ?>> <?php - // We hide the links now so that we can render them later. - hide($content['links']); + // We hide the links now so that we can render them later. + hide($content['links']); + // Check to see if the file has an external url for linking. + if(!empty($content['file']['#file']->external_url)) {;?> + <a href="<?php print render($content['file']['#file']->external_url);?>"><?php print render($content);?></a> + <?php + } else { print render($content); + } ?> </div> diff --git a/profiles/wcm_base/modules/contrib/file_entity/file_entity_views.test b/profiles/wcm_base/modules/contrib/file_entity/file_entity_views.test new file mode 100644 index 00000000..5e0bac55 --- /dev/null +++ b/profiles/wcm_base/modules/contrib/file_entity/file_entity_views.test @@ -0,0 +1,114 @@ +<?php + +/** + * @file + * Definition of FileEntityViewsFieldLinkUsageHandlerTest. + */ + +/** + * Tests for file_entity views file usage handlers. + */ +class FileEntityViewsFieldLinkUsageHandlerTest extends FileEntityTestHelper { + + /** + * {@inheritdoc} + */ + public function setUp() { + parent::setUp('views'); + } + + /** + * {@inheritdoc} + */ + public static function getInfo() { + return array( + 'name' => 'File entity views integration: file link usage', + 'description' => 'Test file usage Views field.', + 'group' => 'File entity', + ); + } + + /** + * Test views file usage handlers. + */ + public function testViewsUsageField() { + $file = $this->createFileEntity(); + file_usage_add($file, 'foo', 'bar', 1,1); + file_usage_add($file, 'foo', 'bar', 1,2); + $file2 = $this->createFileEntity(); + file_usage_add($file2, 'foo', 'bar', 1, 99); + + $view = $this->getTestView(); + $view->set_display(); + $view->pre_execute(); + $view->execute(); + + $row = $view->result[0]; + $render = $view->field['usage']->render_link($row, $row); + $this->assertEqual($render, '1 place'); + + $row = $view->result[1]; + $render = $view->field['usage']->render_link($row, $row); + $this->assertEqual($render, '1 place'); + + $view->field['usage']->options['count_entities_once'] = 0; + + $row = $view->result[0]; + $render = $view->field['usage']->render_link($row, $row); + $this->assertEqual($render, '3 places'); + + $row = $view->result[1]; + $render = $view->field['usage']->render_link($row, $row); + $this->assertEqual($render, '99 places'); + } + + /** + * Creates a test view containing a file usage field. + */ + protected function getTestView() { + $view = new view(); + $view->name = 'file_list'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'file_managed'; + $view->human_name = 'File List'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'File List'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'none'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Field: File: Name */ + $handler->display->display_options['fields']['filename']['id'] = 'filename'; + $handler->display->display_options['fields']['filename']['table'] = 'file_managed'; + $handler->display->display_options['fields']['filename']['field'] = 'filename'; + $handler->display->display_options['fields']['filename']['label'] = ''; + $handler->display->display_options['fields']['filename']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['filename']['alter']['ellipsis'] = FALSE; + /* Field: File: Usage link */ + $handler->display->display_options['fields']['usage']['id'] = 'usage'; + $handler->display->display_options['fields']['usage']['table'] = 'file_managed'; + $handler->display->display_options['fields']['usage']['field'] = 'usage'; + $handler->display->display_options['fields']['usage']['count_entities_once'] = 1; + /* Field: File Usage: Use count */ + $handler->display->display_options['fields']['count']['id'] = 'count'; + $handler->display->display_options['fields']['count']['table'] = 'file_usage'; + $handler->display->display_options['fields']['count']['field'] = 'count'; + + /* Display: Page */ + $handler = $view->new_display('page', 'Page', 'page'); + $handler->display->display_options['path'] = 'file-list'; + + return $view; + } + +} diff --git a/profiles/wcm_base/modules/contrib/file_entity/plugins/tasks/file_view.inc b/profiles/wcm_base/modules/contrib/file_entity/plugins/tasks/file_view.inc index 5b823758..be14e5a4 100644 --- a/profiles/wcm_base/modules/contrib/file_entity/plugins/tasks/file_view.inc +++ b/profiles/wcm_base/modules/contrib/file_entity/plugins/tasks/file_view.inc @@ -105,6 +105,7 @@ function file_entity_file_view_page($file) { } // Otherwise, fall back. + module_load_include('inc', 'file_entity', 'file_entity.pages'); return $function($file); } diff --git a/profiles/wcm_base/modules/contrib/file_entity/tests/file_entity_test.info b/profiles/wcm_base/modules/contrib/file_entity/tests/file_entity_test.info index e9b51c51..24d311fe 100644 --- a/profiles/wcm_base/modules/contrib/file_entity/tests/file_entity_test.info +++ b/profiles/wcm_base/modules/contrib/file_entity/tests/file_entity_test.info @@ -5,9 +5,9 @@ core = 7.x dependencies[] = file_entity hidden = TRUE -; Information added by Drupal.org packaging script on 2016-05-31 -version = "7.x-2.0-beta3" +; Information added by Drupal.org packaging script on 2017-08-10 +version = "7.x-2.4" core = "7.x" project = "file_entity" -datestamp = "1464653173" +datestamp = "1502334549" diff --git a/profiles/wcm_base/modules/contrib/file_entity/views/views_handler_field_file_link_usage.inc b/profiles/wcm_base/modules/contrib/file_entity/views/views_handler_field_file_link_usage.inc index 49e1df8d..aa461c82 100644 --- a/profiles/wcm_base/modules/contrib/file_entity/views/views_handler_field_file_link_usage.inc +++ b/profiles/wcm_base/modules/contrib/file_entity/views/views_handler_field_file_link_usage.inc @@ -12,6 +12,28 @@ */ class views_handler_field_file_link_usage extends views_handler_field_file_link { + /** + * {@inheritdoc} + */ + function option_definition() { + $options = parent::option_definition(); + $options['count_entities_once'] = array('default' => TRUE); + return $options; + } + + /** + * {@inheritdoc} + */ + function options_form(&$form, &$form_state) { + $form['count_entities_once'] = array( + '#type' => 'checkbox', + '#title' => t('Count each unique entity once'), + '#description' => t('Files can be used multiple times for an entity, especially when an entity is revisionable.'), + '#default_value' => !empty($this->options['count_entities_once']), + ); + parent::options_form($form, $form_state); + } + /** * Renders the link. */ @@ -27,10 +49,19 @@ class views_handler_field_file_link_usage extends views_handler_field_file_link // Get total count for each file. $total_count = 0; - foreach (file_usage_list($file) as $module => $usage) { + $file_usage = file_usage_list($file); + $count_entities_once = !empty($this->options['count_entities_once']); + foreach ($file_usage as $module => $usage) { foreach ($usage as $entity_type => $entity_ids) { - foreach ($entity_ids as $id => $count) { - $total_count += $count; + if ($count_entities_once) { + // Just count each unique entity once. + $total_count += count($entity_ids); + } + else { + // Count multiple usages for each entity. + foreach ($entity_ids as $id => $count) { + $total_count += $count; + } } } } diff --git a/profiles/wcm_base/modules/contrib/media/includes/media.fields.inc b/profiles/wcm_base/modules/contrib/media/includes/media.fields.inc index 9105fd1b..99be107b 100644 --- a/profiles/wcm_base/modules/contrib/media/includes/media.fields.inc +++ b/profiles/wcm_base/modules/contrib/media/includes/media.fields.inc @@ -116,6 +116,7 @@ function media_field_widget_form(&$form, &$form_state, $field, $instance, $langc 'max_filesize' => isset($field_settings['max_filesize']) ? $field_settings['max_filesize'] : 0, 'uri_scheme' => !empty($field['settings']['uri_scheme']) ? $field['settings']['uri_scheme'] : file_default_scheme(), 'multiselect' => $multiselect, + 'field' => $field['field_name'], ), ), // Allows this field to return an array instead of a single value. @@ -137,6 +138,13 @@ function media_field_widget_form(&$form, &$form_state, $field, $instance, $langc } elseif ($element['#entity_type'] == 'field_collection_item' && !empty($form['#entity']) && property_exists($form['#entity'], 'language')) { $element['#media_parent_entity_form_langcode'] = $form['#entity']->language; } + else if ($element['#entity_type'] == 'paragraphs_item' && !empty($form['#entity'])) { + $host = $element['#entity']->hostEntity(); + if (isset($host->language)) { + $element['#media_parent_entity_form_langcode'] = $host->language; + $element['#media_parent_entity_source_langcode'] = $host->language; + } + } // Add image field specific validators. if ($field['type'] == 'image') { @@ -551,10 +559,14 @@ function theme_media_widget_multiple($variables) { ); } + $table = array('header' => $headers, 'rows' => $rows, 'attributes' => array('id' => $table_id)); + + drupal_alter('media_widget_multiple', $table, $element); + drupal_add_tabledrag($table_id, 'order', 'sibling', $weight_class); $output = ''; - $output = empty($rows) ? '' : theme('table', array('header' => $headers, 'rows' => $rows, 'attributes' => array('id' => $table_id))); + $output = empty($rows) ? '' : theme('table', $table); $output .= drupal_render_children($element); return $output; } diff --git a/profiles/wcm_base/modules/contrib/media/js/media.popups.js b/profiles/wcm_base/modules/contrib/media/js/media.popups.js index 2c8c775f..c8cf2a0a 100644 --- a/profiles/wcm_base/modules/contrib/media/js/media.popups.js +++ b/profiles/wcm_base/modules/contrib/media/js/media.popups.js @@ -111,7 +111,7 @@ Drupal.media.popups.mediaBrowser.getDefaults = function () { return { global: { types: [], // Types to allow, defaults to all. - activePlugins: [] // If provided, a list of plugins which should be enabled. + enabledPlugins: [] // If provided, a list of plugins which should be enabled. }, widget: { // Settings for the actual iFrame which is launched. src: Drupal.settings.media.browserUrl, // Src of the media browser (if you want to totally override it) @@ -213,6 +213,7 @@ Drupal.media.popups.mediaStyleSelector = function (mediaFile, onSelect, options) dialogOptions.buttons[ok] = function () { // Find the current file selection. var formattedMedia = this.contentWindow.Drupal.media.formatForm.getFormattedMedia(); + formattedMedia.options = $.extend({}, mediaFile.attributes, formattedMedia.options); // Alert the user if a selection has yet to be made. if (!formattedMedia) { diff --git a/profiles/wcm_base/modules/contrib/media/media.info b/profiles/wcm_base/modules/contrib/media/media.info index e256ca89..f17ac602 100644 --- a/profiles/wcm_base/modules/contrib/media/media.info +++ b/profiles/wcm_base/modules/contrib/media/media.info @@ -3,7 +3,7 @@ description = Provides the core Media API package = Media core = 7.x -dependencies[] = file_entity +dependencies[] = file_entity (>7.x-2.0) dependencies[] = image dependencies[] = views @@ -24,9 +24,9 @@ configure = admin/config/media/browser ; 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 2017-05-10 -version = "7.x-2.1" +; Information added by Drupal.org packaging script on 2017-08-05 +version = "7.x-2.10" core = "7.x" project = "media" -datestamp = "1494376994" +datestamp = "1501961348" diff --git a/profiles/wcm_base/modules/contrib/media/media.install b/profiles/wcm_base/modules/contrib/media/media.install index 371e6213..6aa7981d 100644 --- a/profiles/wcm_base/modules/contrib/media/media.install +++ b/profiles/wcm_base/modules/contrib/media/media.install @@ -87,8 +87,8 @@ function media_update_dependencies() { 'rules' => 7205, ); // Those updates require {file_type} table created. - $dependencies['media'][7204] = array( - 'file_entity' => 7201, + $dependencies['media'][7200] = array( + 'file_entity' => 7207, ); // Require {file_type}.mimetypes column before updating them. $dependencies['media'][7208] = array( @@ -949,7 +949,7 @@ function media_update_7211() { // Clear the image cache to remove any old image styles that only exist in // code. - cache_clear_all('*', 'cache_image', TRUE); + cache_clear_all('image_styles', 'cache_image', TRUE); // Check if the square_thumbnail image style exists. // The style will only exist if the user has customized it, otherwise it would @@ -965,8 +965,8 @@ function media_update_7211() { $effect = array( 'name' => 'image_scale_and_crop', 'data' => array( - 'width' => 180, - 'height' => 180, + 'width' => 100, + 'height' => 100, 'weight' => 0, ), 'isid' => $style['isid'], @@ -1207,3 +1207,10 @@ function media_update_7226() { user_role_grant_permissions($rid, array('access media browser')); } } + +/** + * Make sure that the image style square_thumbnail is created. + */ +function media_update_7227() { + media_update_7211(); +} diff --git a/profiles/wcm_base/modules/contrib/media/media.media.inc b/profiles/wcm_base/modules/contrib/media/media.media.inc index 2700265f..6298bc9f 100644 --- a/profiles/wcm_base/modules/contrib/media/media.media.inc +++ b/profiles/wcm_base/modules/contrib/media/media.media.inc @@ -108,3 +108,24 @@ function media_query_media_browser_alter($query) { $query->condition($or); } } + +/** + * Implements hook_form_FORM_ID_alter(). + */ +function media_form_views_exposed_form_alter(&$form, &$form_state, $form_id) { + $view = $form_state['view']; + $display = $form_state['display']; + + if ($view->name == 'media_default' && $display->id == 'media_browser_1') { + $params = media_get_browser_params(); + + // Remove any unsupported types from the 'Type' filter. + if (!empty($form['type']) && !empty($params['types'])) { + foreach (array_keys($form['type']['#options']) as $type) { + if ($type != 'All' && !in_array($type, $params['types'])) { + unset($form['type']['#options'][$type]); + } + } + } + } +} diff --git a/profiles/wcm_base/modules/contrib/media/media.module b/profiles/wcm_base/modules/contrib/media/media.module index 1c378824..098e503b 100644 --- a/profiles/wcm_base/modules/contrib/media/media.module +++ b/profiles/wcm_base/modules/contrib/media/media.module @@ -1137,7 +1137,12 @@ function media_get_thumbnail_preview($file, $link = FALSE, $view_mode = 'preview */ function media_file_validate_types($file, $types) { $errors = array(); - if (!in_array(file_get_type($file), $types)) { + + if (!function_exists('file_entity_get_filetype_candidates')) { + module_load_include('inc', 'file_entity', 'file_entity.pages'); + } + $file_candidates = array_keys(file_entity_get_filetype_candidates($file)); + if (!array_intersect($file_candidates, $types)) { $errors[] = t('Only the following types of files are allowed to be uploaded: %types-allowed', array('%types-allowed' => implode(', ', $types))); } @@ -1215,20 +1220,22 @@ function media_set_browser_params() { // Filter out everything except a whitelist of known safe options. $safe_options = array( - 'activePlugins', + 'enabledPlugins', 'fid', 'id', 'multiselect', + 'field', 'options', 'plugins', 'render', 'types', + 'render_multi_edit_form', ); $params = array_intersect_key($params, array_flip($safe_options)); - // Retrieve the security sensitive options from the cache. + // If the cache is present, use its values instead of the GET parameters. if (!empty($params['options']) && is_string($params['options']) && $options = cache_get('media_options:' . $params['options'], 'cache_form')) { - $params = array_merge($options->data, $params); + $params = $options->data; } // Transform text 'true' and 'false' to actual booleans. diff --git a/profiles/wcm_base/modules/contrib/media/media.views.inc b/profiles/wcm_base/modules/contrib/media/media.views.inc index 70d5c2f1..9640dde2 100644 --- a/profiles/wcm_base/modules/contrib/media/media.views.inc +++ b/profiles/wcm_base/modules/contrib/media/media.views.inc @@ -33,6 +33,7 @@ function media_views_plugins() { 'help' => t('Display as a tab in the media browser.'), 'handler' => 'media_views_plugin_display_media_browser', 'theme' => 'views_view', + 'theme path' => drupal_get_path('module', 'views') . '/theme', 'base' => $base, 'use ajax' => TRUE, 'use pager' => TRUE, diff --git a/profiles/wcm_base/modules/contrib/media/modules/media_bulk_upload/media_bulk_upload.info b/profiles/wcm_base/modules/contrib/media/modules/media_bulk_upload/media_bulk_upload.info index 6c9a870d..e758e99f 100644 --- a/profiles/wcm_base/modules/contrib/media/modules/media_bulk_upload/media_bulk_upload.info +++ b/profiles/wcm_base/modules/contrib/media/modules/media_bulk_upload/media_bulk_upload.info @@ -15,9 +15,9 @@ test_dependencies[] = plupload files[] = includes/MediaBrowserBulkUpload.inc files[] = tests/media_bulk_upload.test -; Information added by Drupal.org packaging script on 2017-05-10 -version = "7.x-2.1" +; Information added by Drupal.org packaging script on 2017-08-05 +version = "7.x-2.10" core = "7.x" project = "media" -datestamp = "1494376994" +datestamp = "1501961348" diff --git a/profiles/wcm_base/modules/contrib/media/modules/media_bulk_upload/media_bulk_upload.module b/profiles/wcm_base/modules/contrib/media/modules/media_bulk_upload/media_bulk_upload.module index 7db48cdf..8c157d76 100644 --- a/profiles/wcm_base/modules/contrib/media/modules/media_bulk_upload/media_bulk_upload.module +++ b/profiles/wcm_base/modules/contrib/media/modules/media_bulk_upload/media_bulk_upload.module @@ -52,7 +52,9 @@ function media_bulk_upload_permission() { * Implements hook_media_browser_plugin_info_alter(). */ function media_bulk_upload_media_browser_plugin_info_alter(&$info) { + $info['upload']['title'] = t('Upload'); $info['upload']['class'] = 'MediaBrowserBulkUpload'; + } /** diff --git a/profiles/wcm_base/modules/contrib/media/modules/media_internet/media_internet.info b/profiles/wcm_base/modules/contrib/media/modules/media_internet/media_internet.info index b5e694e0..03a9db69 100644 --- a/profiles/wcm_base/modules/contrib/media/modules/media_internet/media_internet.info +++ b/profiles/wcm_base/modules/contrib/media/modules/media_internet/media_internet.info @@ -12,9 +12,9 @@ files[] = includes/MediaInternetNoHandlerException.inc files[] = includes/MediaInternetValidationException.inc files[] = tests/media_internet.test -; Information added by Drupal.org packaging script on 2017-05-10 -version = "7.x-2.1" +; Information added by Drupal.org packaging script on 2017-08-05 +version = "7.x-2.10" core = "7.x" project = "media" -datestamp = "1494376994" +datestamp = "1501961348" diff --git a/profiles/wcm_base/modules/contrib/media/modules/media_internet/tests/media_internet_test.info b/profiles/wcm_base/modules/contrib/media/modules/media_internet/tests/media_internet_test.info index 733991b0..214d704f 100644 --- a/profiles/wcm_base/modules/contrib/media/modules/media_internet/tests/media_internet_test.info +++ b/profiles/wcm_base/modules/contrib/media/modules/media_internet/tests/media_internet_test.info @@ -7,9 +7,9 @@ hidden = TRUE files[] = includes/MediaInternetTestStreamWrapper.inc files[] = includes/MediaInternetTestHandler.inc -; Information added by Drupal.org packaging script on 2017-05-10 -version = "7.x-2.1" +; Information added by Drupal.org packaging script on 2017-08-05 +version = "7.x-2.10" core = "7.x" project = "media" -datestamp = "1494376994" +datestamp = "1501961348" diff --git a/profiles/wcm_base/modules/contrib/media/modules/media_migrate_file_types/media_migrate_file_types.info b/profiles/wcm_base/modules/contrib/media/modules/media_migrate_file_types/media_migrate_file_types.info index 17e12322..889616ba 100644 --- a/profiles/wcm_base/modules/contrib/media/modules/media_migrate_file_types/media_migrate_file_types.info +++ b/profiles/wcm_base/modules/contrib/media/modules/media_migrate_file_types/media_migrate_file_types.info @@ -8,9 +8,9 @@ dependencies[] = media configure = admin/structure/file-types/upgrade -; Information added by Drupal.org packaging script on 2017-05-10 -version = "7.x-2.1" +; Information added by Drupal.org packaging script on 2017-08-05 +version = "7.x-2.10" core = "7.x" project = "media" -datestamp = "1494376994" +datestamp = "1501961348" diff --git a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/css/media_wysiwyg.css b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/css/media_wysiwyg.css index 7a0f3b70..a04734c5 100644 --- a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/css/media_wysiwyg.css +++ b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/css/media_wysiwyg.css @@ -10,11 +10,15 @@ margin: 20px; } -#media-wysiwyg-format-form .media-item { +#media-wysiwyg-format-form .media-preview-group { float: left; margin-right: 10px; } +#media-wysiwyg-format-form .media-preview-group .edit-file-link { + text-align: center; +} + #media-wysiwyg-format-form .form-item-format label { display: inline; } diff --git a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc index ef7261f3..c9c61307 100644 --- a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc +++ b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc @@ -5,7 +5,7 @@ * Functions related to the WYSIWYG editor and the media input filter. */ -define('MEDIA_WYSIWYG_TOKEN_REGEX', '/\[\[.*?\]\]/s'); +define('MEDIA_WYSIWYG_TOKEN_REGEX', '/\[\[.+?"type":"media".+?\]\]/s'); /** * Filter callback for media markup filter. @@ -27,21 +27,70 @@ function media_wysiwyg_filter($text, $filter = NULL, $format = NULL, $langcode = return $rendered_text; } +/** + * Filter callback to configure media_filter_paragraph_fix filter. + */ +function _media_filter_paragraph_fix_settings($form, &$form_state, $filter, $format, $defaults) { + $filter->settings += $defaults; + $settings['replace'] = array( + '#type' => 'checkbox', + '#title' => t('Replace paragraph tags with DIV.media-p tags'), + '#default_value' => $filter->settings['replace'], + '#description' => t('Default behaviour is to strip out parent P tags of media elements rather than replacing these.'), + ); + return $settings; +} + /** * Filter callback to remove paragraph tags surrounding embedded media. */ -function media_wysiwyg_filter_paragraph_fix($text) { +function media_wysiwyg_filter_paragraph_fix($text, $filter) { $html_dom = filter_dom_load($text); + // Store Nodes to remove to avoid inferferring with the NodeList iteration. + $dom_nodes_to_remove = array(); foreach ($html_dom->getElementsByTagName('p') as $paragraph) { if (preg_match(MEDIA_WYSIWYG_TOKEN_REGEX, $paragraph->nodeValue)) { - $sibling = $paragraph->firstChild; - do { - $next = $sibling->nextSibling; - $paragraph->parentNode->insertBefore($sibling, $paragraph); - } while ($sibling = $next); - $paragraph->parentNode->removeChild($paragraph); + if (empty($filter->settings['replace'])) { + $sibling = $paragraph->firstChild; + do { + $next = $sibling->nextSibling; + $paragraph->parentNode->insertBefore($sibling, $paragraph); + } while ($sibling = $next); + $dom_nodes_to_remove[] = $paragraph; + } + else { + // Clone the P node into a DIV node. + $div = $html_dom->createElement('div'); + $sibling = $paragraph->firstChild; + do { + $next = $sibling->nextSibling; + $div->appendChild($sibling); + } while ($sibling = $next); + + $classes = array('media-p'); + if ($paragraph->hasAttributes()) { + foreach ($paragraph->attributes as $attr) { + $name = $attr->nodeName; + $value = $attr->nodeValue; + if (strtolower($name) == 'class') { + $classes[] = $value; + } + else { + // Supressing errors with ID attribute or duplicate properties. + @$div->setAttribute($name, $value); + } + } + } + $div->setAttribute('class', implode(' ', $classes)); + + $paragraph->parentNode->insertBefore($div, $paragraph); + $dom_nodes_to_remove[] = $paragraph; + } } } + foreach ($dom_nodes_to_remove as $paragraph) { + $paragraph->parentNode->removeChild($paragraph); + } $text = filter_dom_serialize($html_dom); return $text; } @@ -97,7 +146,6 @@ function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE, $langcode = NUL } $tag_info = drupal_json_decode($tag); - if (!isset($tag_info['fid'])) { throw new Exception('No file Id'); } @@ -167,7 +215,9 @@ function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE, $langcode = NUL $attribute_whitelist = media_wysiwyg_allowed_attributes(); $settings['attributes'] = array_intersect_key($attributes, array_flip($attribute_whitelist)); $settings['fields'] = $fields; - + if (isset($tag_info['fields']['external_url'])) { + $settings['fields']['external_url'] = $tag_info['fields']['external_url']; + } if (!empty($tag_info['attributes']) && is_array($tag_info['attributes'])) { $settings['attributes'] = array_intersect_key($tag_info['attributes'], array_flip($attribute_whitelist)); @@ -292,6 +342,10 @@ function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE, $langcode = NUL 'media-element-container', 'media-' . $element['content']['file']['#view_mode'], ); + if (variable_get('media_wysiwyg_remove_media_class', FALSE)) { + $classes = $element['content']['#attributes']['class']; + $element['content']['#attributes']['class'] = array_diff($classes, array('media')); + } } // Conditionally add a pre-render if the media filter output is be cached. @@ -401,7 +455,7 @@ function _media_wysiwyg_generate_tagMap($text) { // between function calls. Since media_process_form is multiple times // with same form, this function is also called multiple times. static $tagmap = array(); - preg_match_all("/\[\[.*?\]\]/s", $text, $matches, PREG_SET_ORDER); + preg_match_all("/\[\[(?!nid:).*?\]\]/s", $text, $matches, PREG_SET_ORDER); foreach ($matches as $match) { // We see if tagContent is already in $tagMap, if not we add it // to $tagmap. If we return an empty array, we break embeddings of the same diff --git a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/includes/media_wysiwyg.pages.inc b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/includes/media_wysiwyg.pages.inc index a2ca6474..fdb4c535 100644 --- a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/includes/media_wysiwyg.pages.inc +++ b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/includes/media_wysiwyg.pages.inc @@ -104,12 +104,24 @@ function media_wysiwyg_format_form($form, &$form_state, $file) { '#default_value' => $align_default, ); } - // Add fields from the file, so that we can override them if necessary. $form['options']['fields'] = array(); foreach ($fields as $field_name => $field_value) { $file->{$field_name} = $field_value; } + // Get the external url from the fid array. + $external_url = empty($query_fields['external_url']) ? NULL : $query_fields['external_url']; + // Field to attach external url's to files for linking. + if(variable_get('media_wysiwyg_external_link', FALSE)) { + if($file->type == 'image') { + $form['options']['external_url'] = array( + '#type' => 'textfield', + '#title' => t('Link Image'), + '#description' => t('Enter a URL to turn the image into a link.'), + '#default_value' => $external_url, + ); + } + } field_attach_form('file', $file, $form['options']['fields'], $form_state); $instance = field_info_instances('file', $file->type); foreach ($instance as $field_name => $field_value) { @@ -164,8 +176,8 @@ function media_wysiwyg_format_form_view_mode(&$form, $form_state, $file) { } $form['preview'] = array(); - $form['preview']['#prefix'] = '<div class="media-item"><div class="media-thumbnail">'; - $form['preview']['#suffix'] = '</div><div class="label-wrapper"><label class="media-filename">' . check_plain($file->filename) . '</label></div></div>'; + $form['preview']['#prefix'] = '<div class="media-preview-group"><div class="media-item"><div class="media-thumbnail">'; + $form['preview']['#suffix'] = '</div><div class="label-wrapper"><label class="media-filename">' . check_plain($file->filename) . '</label></div></div><div class="edit-file-link">' . l(t('Edit file'), 'file/'.$file->fid.'/edit', array('attributes' => array('class' => 'button', 'title' => t('Use for replace file or edit file fields.')))) . '</div></div>'; $form['preview']['thumbnail'] = file_view_file($file, $view_mode); $form['preview']['thumbnail']['#prefix'] = '<div id="media-preview">'; $form['preview']['thumbnail']['#suffix'] = '</div>'; diff --git a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/js/media_wysiwyg.filter.js b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/js/media_wysiwyg.filter.js index 3a80bb9b..6f906b75 100644 --- a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/js/media_wysiwyg.filter.js +++ b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/js/media_wysiwyg.filter.js @@ -175,7 +175,8 @@ Drupal.media.filter.ensure_tagmap(); // Locate and process all the media placeholders in the WYSIWYG content. - var contentElements = $('<div/>').html(content); // TODO: once baseline jQuery is 1.8+, switch to using $.parseHTML(content) + var contentElements = $('<div/>'); // TODO: once baseline jQuery is 1.8+, switch to using $.parseHTML(content) + contentElements.get(0).innerHTML = content; var mediaElements = contentElements.find('.media-element'); if (mediaElements) { $(mediaElements).each(function (i) { @@ -299,7 +300,7 @@ // Attempt to override the link_title if the user has chosen to do this. info.link_text = this.overrideLinkTitle(info); // Apply link_text if present. - if (info.link_text) { + if ((info.link_text) && (!info.fields || !info.fields.external_url || info.fields.external_url.length === 0)) { $('a', element).html(info.link_text); } @@ -351,8 +352,7 @@ }); // Extract the link text, if there is any. - file_info.link_text = (Drupal.settings.mediaDoLinkText) ? element.find('a').html() : false; - + file_info.link_text = (Drupal.settings.mediaDoLinkText) ? element.find('a:not(:has(img))').html() : false; // When a file is embedded, its fields can be overridden. To allow for // the edge case where the same file is embedded multiple times with // different field overrides, we look for a data-delta attribute on diff --git a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/media_wysiwyg.info b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/media_wysiwyg.info index 5a8ce8e7..96a99867 100644 --- a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/media_wysiwyg.info +++ b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/media_wysiwyg.info @@ -12,12 +12,13 @@ test_dependencies[] = wysiwyg files[] = media_wysiwyg.test files[] = tests/media_wysiwyg.file_usage.test files[] = tests/media_wysiwyg.macro.test +files[] = tests/media_wysiwyg.paragraph_fix_filter.test configure = admin/config/media/browser -; Information added by Drupal.org packaging script on 2017-05-10 -version = "7.x-2.1" +; Information added by Drupal.org packaging script on 2017-08-05 +version = "7.x-2.10" core = "7.x" project = "media" -datestamp = "1494376994" +datestamp = "1501961348" diff --git a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/media_wysiwyg.install b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/media_wysiwyg.install index cab6b9b8..d83998de 100644 --- a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/media_wysiwyg.install +++ b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/media_wysiwyg.install @@ -76,6 +76,8 @@ function media_wysiwyg_uninstall() { variable_del('media_wysiwyg_wysiwyg_override_field_types'); variable_del('media_wysiwyg_use_link_text_for_filename'); variable_del('media_wysiwyg_alignment'); + variable_del('media_wysiwyg_external_link'); + variable_del('media_wysiwyg_remove_media_class'); } /** @@ -242,3 +244,11 @@ function media_wysiwyg_update_7206() { $message = t('If you would like to be able to align your embedded media (left, right, or center), go to /admin/config/media/browser and check "Provide alignment option when embedding media", and save the settings.'); drupal_set_message($message, 'warning', TRUE); } + +/** + * Notify upgraders that there's optional media linking functionality that needs to be enabled. + */ +function media_wysiwyg_update_7207() { + $message = t('If you would like to be able to link images to a page, go to /admin/config/media/browser, check "Provide the ability to link media to pages", and save the settings.'); + drupal_set_message($message, 'warning', TRUE); +} diff --git a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/media_wysiwyg.module b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/media_wysiwyg.module index 66eb1cc4..0a8482e6 100644 --- a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/media_wysiwyg.module +++ b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/media_wysiwyg.module @@ -120,7 +120,7 @@ function media_wysiwyg_pre_render_text_format($element) { $tagmap = array(); foreach (array('value', 'summary') as $column) { - if (isset($element[$column])) { + if (isset($element[$column]['#value'])) { $tagmap += _media_wysiwyg_generate_tagMap($element[$column]['#value']); } } @@ -281,7 +281,7 @@ function media_wysiwyg_form_media_admin_config_browser_alter(&$form, &$form_stat $options = array(); foreach(field_info_field_types() as $key => $type) { - $options[$key] = $type['label']; + $options[$key] = (!empty($type['label']))? $type['label'] : ucfirst(str_replace("_"," ",$key)); } asort($options); $form['wysiwyg']['media_wysiwyg_wysiwyg_override_field_types'] = array( @@ -313,6 +313,20 @@ function media_wysiwyg_form_media_admin_config_browser_alter(&$form, &$form_stat '#description' => t('If checked, there will be an alignment (left/right/center) option when embedding media in a WYSIWYG.'), ); + $form['wysiwyg']['media_wysiwyg_external_link'] = array( + '#type' => 'checkbox', + '#title' => t('Provide the ability to link media to pages'), + '#default_value' => variable_get('media_wysiwyg_external_link', FALSE), + '#description' => t('If checked there will be a new field when embedding that will allow users to link to the media to urls'), + ); + + $form['wysiwyg']['media_wysiwyg_remove_media_class'] = array( + '#type' => 'checkbox', + '#title' => t('Remove the ".media" class from embedded media'), + '#description' => t('If checked, the ".media" class will be removed from embedded media. Particularlly for sites using Bootstrap, the ".media" class can cause CSS to be unexpectedly applied to embedded media.'), + '#default_value' => variable_get('media_wysiwyg_remove_media_class', FALSE), + ); + $form['#submit'][] = 'media_wysiwyg_admin_config_browser_pre_submit'; } @@ -342,8 +356,12 @@ function media_wysiwyg_filter_info() { $filters['media_filter_paragraph_fix'] = array( 'title' => t('Ensure that embedded Media tags are not contained in paragraphs'), - 'description' => t('This filter will strip any paragraph tags surrounding embedded Media tags. This helps to avoid the chopped up markup that can result from unexpectedly closed paragraph tags. This filter should be positioned above (before) the "Convert Media tags to markup" filter.'), + 'description' => t('This filter will fix any paragraph tags surrounding embedded Media tags. This helps to avoid the chopped up markup that can result from unexpectedly closed paragraph tags. This filter should be positioned above (before) the "Convert Media tags to markup" filter.'), 'process callback' => 'media_wysiwyg_filter_paragraph_fix', + 'settings callback' => '_media_filter_paragraph_fix_settings', + 'default settings' => array( + 'replace' => 0, + ), 'weight' => 1, ); @@ -389,7 +407,7 @@ function media_wysiwyg_allowed_attributes() { 'data-delta', )); drupal_alter('media_wysiwyg_allowed_attributes', $allowed_attributes); - return $allowed_attributes; + return $allowed_attributes; } /** @@ -603,7 +621,7 @@ function media_wysiwyg_form_file_entity_file_type_form_alter(&$form, &$form_stat if (empty($form_state['build_info']['args'][0])) { return; } - + $options = array(); // Add an option allowing users not to use a view mode. diff --git a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/media_wysiwyg.test b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/media_wysiwyg.test index 6b0aaa37..117aab57 100644 --- a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/media_wysiwyg.test +++ b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/media_wysiwyg.test @@ -58,9 +58,11 @@ abstract class MediaWYSIWYGTestHelper extends DrupalWebTestCase { ); // Create the file usage markup. + $markup .= '<p>Intro paragraph</p>'; for ($i = 1; $i <= $count; $i++) { $markup .= '<p>[[' . drupal_json_encode($data) . ']]</p>'; } + $markup .= '<p>Finish paragraph</p>'; return $markup; } diff --git a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/tests/media_wysiwyg.paragraph_fix_filter.test b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/tests/media_wysiwyg.paragraph_fix_filter.test new file mode 100644 index 00000000..610d4f2b --- /dev/null +++ b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg/tests/media_wysiwyg.paragraph_fix_filter.test @@ -0,0 +1,166 @@ +<?php + +/** + * @file + * Tests for ensuring filters are working properly. + */ + +/** + * Defines media macro test cases. + */ +class MediaWYSIWYGParagraphFixFilterTest extends MediaWYSIWYGTestHelper { + + /** + * Defines the regex to test for a media tag replacement. + * + * @var string + */ + protected $regexpMediaTag = '/<div [^>]*media\-element\-container[^>]*>/i'; + + /** + * Defines the regex to test for in the raw body field source. + * + * @var string + */ + protected $regexpPWrapped = '/<p[^>]*><div [^>]*media\-element\-container[^>]*>/i'; + + /** + * Defines the regex to test for the P replacement filter. + * + * @var string + */ + protected $regexpReplaced = '/<div class\="media\-p"><div/i'; + + /** + * Provide test information. + */ + public static function getInfo() { + return array( + 'name' => t('Media WYSIWYG Paragraph Filter Test'), + 'description' => t('Tests that this media filter is working.'), + 'group' => t('Media WYSIWYG'), + 'dependencies' => array('token'), + ); + } + + /** + * Set-up the system for testing without the filter enabled. + */ + public function setUp() { + parent::setUp('token'); + + // Create and log in a user. + $account = $this->drupalCreateUser(array( + 'create article content', + 'administer filters', + 'use text format filtered_html', + )); + $this->drupalLogin($account); + + // Enable the media filter for full html. + $edit = array( + 'filters[media_filter][status]' => TRUE, + 'filters[filter_autop][status]' => FALSE, + 'filters[filter_html][status]' => FALSE, + 'filters[filter_htmlcorrector][status]' => FALSE, + ); + $this->drupalPost('admin/config/content/formats/filtered_html', $edit, t('Save configuration')); + } + + /** + * Test image media overrides. + */ + public function testMediaFilterParagraphFixMultipleImages() { + $files = $this->drupalGetTestFiles('image'); + $file = file_save($files[0]); + + // Create a node to test with 3 images. + $nid = $this->createNode($file->fid); + $node = node_load($nid); + $node->body[LANGUAGE_NONE][0]['value'] = $this->generateJsonTokenMarkup($file->fid, 3); + node_save($node); + + // Check without the filter enabled. + $html = $this->drupalGet('node/' . $nid); + $forphp53compat = array(); + $count = preg_match_all($this->regexpMediaTag, $html, $forphp53compat); + $this->assertEqual($count, 3, t('Three media tags found, found @count.', array('@count' => $count))); + + $count = preg_match_all($this->regexpPWrapped, $html, $forphp53compat); + $this->assertEqual($count, 3, t('Three media tags with original wrapping HTML present, found @count.', array('@count' => $count))); + + $count = preg_match_all($this->regexpReplaced, $html, $forphp53compat); + $this->assertEqual($count, 0, t('No media tags with P replaced present, found @count.', array('@count' => $count))); + + // Enable the default P fix filter. + $edit = array( + 'filters[media_filter_paragraph_fix][status]' => TRUE, + ); + $this->drupalPost('admin/config/content/formats/filtered_html', $edit, t('Save configuration')); + $html = $this->drupalGet('node/' . $nid); + + $count = preg_match_all($this->regexpMediaTag, $html, $forphp53compat); + $this->assertEqual($count, 3, t('Three media tags found, found @count.', array('@count' => $count))); + + $count = preg_match_all($this->regexpPWrapped, $html, $forphp53compat); + $this->assertEqual($count, 0, t('No media tags with original wrapping HTML present, found @count.', array('@count' => $count))); + + $count = preg_match_all($this->regexpReplaced, $html, $forphp53compat); + $this->assertEqual($count, 0, t('No media tags with P replaced present, found @count.', array('@count' => $count))); + + // Enable the replace P fix filter option. + $edit = array( + 'filters[media_filter_paragraph_fix][settings][replace]' => TRUE, + ); + $this->drupalPost('admin/config/content/formats/filtered_html', $edit, t('Save configuration')); + $html = $this->drupalGet('node/' . $nid); + + $count = preg_match_all($this->regexpMediaTag, $html, $forphp53compat); + $this->assertEqual($count, 3, t('Three media tags found, found @count.', array('@count' => $count))); + + $count = preg_match_all($this->regexpPWrapped, $html, $forphp53compat); + $this->assertEqual($count, 0, t('No media tags with original wrapping HTML present, found @count.', array('@count' => $count))); + + $count = preg_match_all($this->regexpReplaced, $html, $forphp53compat); + $this->assertEqual($count, 3, t('Three media tags with P replaced present, found @count.', array('@count' => $count))); + } + + /** + * Test image media overrides. + */ + public function testMediaFilterParagraphFixDefault() { + $files = $this->drupalGetTestFiles('image'); + $file = file_save($files[0]); + + // Create a node to test with. + $nid = $this->createNode($file->fid); + + // Check without the filter enabled. + $this->drupalGet('node/' . $nid); + $this->assertPattern($this->regexpPWrapped, t('Nested media DIV tags within paragraphs without filter.')); + $this->assertNoPattern($this->regexpReplaced, t('No replacement DIV tag found without filter.')); + + // Enable the default P fix filter. + $edit = array( + 'filters[media_filter_paragraph_fix][status]' => TRUE, + ); + $this->drupalPost('admin/config/content/formats/filtered_html', $edit, t('Save configuration')); + + // Retest the content to check nested paragraphs are removed. + $this->drupalGet('node/' . $nid); + $this->assertNoPattern($this->regexpPWrapped, t('Nested media DIV tags within paragraphs with filter defaults.')); + $this->assertNoPattern($this->regexpReplaced, t('No replacement DIV tag found with filter defaults.')); + + // Enable replacement option. + $edit = array( + 'filters[media_filter_paragraph_fix][settings][replace]' => TRUE, + ); + $this->drupalPost('admin/config/content/formats/filtered_html', $edit, t('Save configuration')); + + // Test that the replace text was found. + $this->drupalGet('node/' . $nid); + $this->assertNoPattern($this->regexpPWrapped, t('No nested media DIV tags within paragraphs with filter P replacement.')); + $this->assertPattern($this->regexpReplaced, t('No replacement DIV tag found with filter P replacement.')); + } + +} diff --git a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg_view_mode/media_wysiwyg_view_mode.info b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg_view_mode/media_wysiwyg_view_mode.info index fa65f406..e57d8842 100644 --- a/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg_view_mode/media_wysiwyg_view_mode.info +++ b/profiles/wcm_base/modules/contrib/media/modules/media_wysiwyg_view_mode/media_wysiwyg_view_mode.info @@ -3,9 +3,9 @@ description = DEPRECATED, this folder is only here so that the module can be uni package = Media core = 7.x -; Information added by Drupal.org packaging script on 2017-05-10 -version = "7.x-2.1" +; Information added by Drupal.org packaging script on 2017-08-05 +version = "7.x-2.10" core = "7.x" project = "media" -datestamp = "1494376994" +datestamp = "1501961348" diff --git a/profiles/wcm_base/modules/contrib/media/modules/mediafield/mediafield.info b/profiles/wcm_base/modules/contrib/media/modules/mediafield/mediafield.info index 0bc87836..a9bc1022 100644 --- a/profiles/wcm_base/modules/contrib/media/modules/mediafield/mediafield.info +++ b/profiles/wcm_base/modules/contrib/media/modules/mediafield/mediafield.info @@ -4,9 +4,9 @@ package = Media core = 7.x dependencies[] = media -; Information added by Drupal.org packaging script on 2017-05-10 -version = "7.x-2.1" +; Information added by Drupal.org packaging script on 2017-08-05 +version = "7.x-2.10" core = "7.x" project = "media" -datestamp = "1494376994" +datestamp = "1501961348" diff --git a/profiles/wcm_base/modules/contrib/media/tests/media.test b/profiles/wcm_base/modules/contrib/media/tests/media.test index a60e3adf..1e822ea5 100644 --- a/profiles/wcm_base/modules/contrib/media/tests/media.test +++ b/profiles/wcm_base/modules/contrib/media/tests/media.test @@ -1001,6 +1001,7 @@ class MediaElementSettingsTestCase extends MediaFileFieldTestCase { 'max_filesize' => '', 'uri_scheme' => 'public', 'multiselect' => $multiselect, + 'field' => $field_name, ), ), ), diff --git a/profiles/wcm_base/modules/contrib/media/tests/media_module_test.info b/profiles/wcm_base/modules/contrib/media/tests/media_module_test.info index 1023224c..e01e8b10 100644 --- a/profiles/wcm_base/modules/contrib/media/tests/media_module_test.info +++ b/profiles/wcm_base/modules/contrib/media/tests/media_module_test.info @@ -6,9 +6,9 @@ hidden = TRUE files[] = includes/MediaModuleTest.inc -; Information added by Drupal.org packaging script on 2017-05-10 -version = "7.x-2.1" +; Information added by Drupal.org packaging script on 2017-08-05 +version = "7.x-2.10" core = "7.x" project = "media" -datestamp = "1494376994" +datestamp = "1501961348" diff --git a/profiles/wcm_base/modules/contrib/media_youtube/PATCHES.txt b/profiles/wcm_base/modules/contrib/media_youtube/PATCHES.txt deleted file mode 100644 index a1b62b8f..00000000 --- a/profiles/wcm_base/modules/contrib/media_youtube/PATCHES.txt +++ /dev/null @@ -1,4 +0,0 @@ -The following patches have been applied to this project: -- http://drupal.org/files/issues/media_youtube-remove_thumbnail_exception-2498493-23.patch - -This file was automatically generated by Drush Make (http://drupal.org/project/drush). diff --git a/profiles/wcm_base/modules/contrib/media_youtube/includes/MediaInternetYouTubeHandler.inc b/profiles/wcm_base/modules/contrib/media_youtube/includes/MediaInternetYouTubeHandler.inc index 986f785c..a5809733 100644 --- a/profiles/wcm_base/modules/contrib/media_youtube/includes/MediaInternetYouTubeHandler.inc +++ b/profiles/wcm_base/modules/contrib/media_youtube/includes/MediaInternetYouTubeHandler.inc @@ -11,7 +11,20 @@ * @see hook_media_internet_providers(). */ class MediaInternetYouTubeHandler extends MediaInternetBaseHandler { + public function parse($embedCode) { + $list_patterns = array( + '@youtube\.com/playlist[#\?].*?list=([^"#\& ]+)@i', + '@youtube\.com/view_play_list[#\?].*?p=([^"#\& ]+)@i', + ); + + foreach ($list_patterns as $pattern) { + preg_match($pattern, $embedCode, $matches); + + if (isset($matches[1]) && $this->validId($matches[1], 'l')) { + return file_stream_wrapper_uri_normalize('youtube://l/' . $matches[1]); + } + } // http://youtube.com/watch/* // http://youtube.com/embed/* // http://youtube.com/v/* @@ -19,20 +32,27 @@ class MediaInternetYouTubeHandler extends MediaInternetBaseHandler { // http://youtu.be/* // http://gdata.youtube.com/feeds/api/videos/* $patterns = array( - '@youtube\.com/watch[#\?].*?v=([^"\& ]+)@i', - '@youtube\.com/embed/([^"\&\? ]+)@i', - '@youtube\.com/v/([^"\&\? ]+)@i', - '@youtube\.com/\?v=([^"\& ]+)@i', - '@youtu\.be/([^"\&\? ]+)@i', - '@gdata\.youtube\.com/feeds/api/videos/([^"\&\? ]+)@i', + '@youtube\.com/watch[#\?].*?v=([^"#\& ]+).*&list=([^"#\& ]+)@i', + '@youtu\.be/([^"#\&\? ]+)\?list=([^"#\& ]+)@i', + '@youtube\.com/embed/([^"#\&\? ]+)\?list=([^"#\& ]+)@i', + '@youtube\.com/watch[#\?].*?v=([^"#\& ]+)@i', + '@youtube\.com/embed/([^"#\&\? ]+)@i', + '@youtube\.com/v/([^"#\&\? ]+)@i', + '@youtube\.com/\?v=([^"#\& ]+)@i', + '@youtu\.be/([^"#\&\? ]+)@i', + '@gdata\.youtube\.com/feeds/api/videos/([^"#\&\? ]+)@i', ); foreach ($patterns as $pattern) { - preg_match($pattern, $embedCode, $matches); + preg_match_all($pattern, $embedCode, $matches); // @TODO: Parse is called often. Refactor so that valid ID is checked // when a video is added, but not every time the embedCode is parsed. - if (isset($matches[1]) && self::validId($matches[1])) { - return file_stream_wrapper_uri_normalize('youtube://v/' . $matches[1]); + if (isset($matches[1][0]) && $this->validId($matches[1][0])) { + $uri = 'youtube://v/' . $matches[1][0]; + if (isset($matches[2][0]) && $this->validId($matches[2][0], 'l')) { + $uri .= '/l/' . $matches[2][0]; + } + return file_stream_wrapper_uri_normalize($uri); } } } @@ -87,8 +107,8 @@ class MediaInternetYouTubeHandler extends MediaInternetBaseHandler { * TRUE if the video ID is valid, or throws a * MediaInternetValidationException otherwise. */ - static public function validId($id) { - $uri = file_stream_wrapper_uri_normalize('youtube://v/' . check_plain($id)); + public function validId($id, $type = 'v') { + $uri = file_stream_wrapper_uri_normalize('youtube://' . $type . '/' . check_plain($id)); $external_url = file_create_url($uri); $oembed_url = url('http://www.youtube.com/oembed', array('query' => array('url' => $external_url, 'format' => 'json'))); $response = drupal_http_request($oembed_url, array('method' => 'HEAD')); diff --git a/profiles/wcm_base/modules/contrib/media_youtube/includes/MediaYouTubeStreamWrapper.inc b/profiles/wcm_base/modules/contrib/media_youtube/includes/MediaYouTubeStreamWrapper.inc index 0e564fc5..46c08b6a 100644 --- a/profiles/wcm_base/modules/contrib/media_youtube/includes/MediaYouTubeStreamWrapper.inc +++ b/profiles/wcm_base/modules/contrib/media_youtube/includes/MediaYouTubeStreamWrapper.inc @@ -10,7 +10,7 @@ * $youtube = new MediaYouTubeStreamWrapper('youtube://v/[video-code]'); */ class MediaYouTubeStreamWrapper extends MediaReadOnlyStreamWrapper { - protected $base_url = 'http://www.youtube.com/watch'; + protected $base_url = 'https://www.youtube.com/watch'; static function getMimeType($uri, $mapping = NULL) { return 'video/youtube'; @@ -18,43 +18,96 @@ class MediaYouTubeStreamWrapper extends MediaReadOnlyStreamWrapper { function getOriginalThumbnailPath() { $parts = $this->get_parameters(); - $uri = file_stream_wrapper_uri_normalize('youtube://v/' . check_plain($parts['v'])); - $external_url = file_create_url($uri); - $oembed_url = url('http://www.youtube.com/oembed', array('query' => array('url' => $external_url, 'format' => 'json'))); - $response = drupal_http_request($oembed_url); - + $thumbnail_url = 'https://img.youtube.com/vi/' . check_plain($parts['v']) . "/maxresdefault.jpg"; + $response = drupal_http_request($thumbnail_url); + if ($response->code == 404) { + $thumbnail_url = 'https://img.youtube.com/vi/' . check_plain($parts['v']) . "/hqdefault.jpg"; + $response = drupal_http_request($thumbnail_url); + } if (!isset($response->error)) { - $data = drupal_json_decode($response->data); - return $data['thumbnail_url']; + return $thumbnail_url; + } + elseif ($response->code == 401) { + throw new MediaInternetValidationException("Embedding has been disabled for this video."); + } + elseif ($response->code == 404) { + return "https://s.ytimg.com/yts/img/image-hh-404-vflvCykRp.png"; + } + elseif ($response->code != 200) { + throw new MediaInternetValidationException("The YouTube video ID is invalid or the video was deleted."); } else { - $file = file_uri_to_object($this->uri); - $icon_dir = variable_get('media_icon_base_directory', 'public://media-icons') . '/' . variable_get('media_icon_set', 'default'); - $local_path = file_icon_path($file, $icon_dir); + $uri = file_stream_wrapper_uri_normalize('youtube://v/' . check_plain($parts['v'])); + $external_url = file_create_url($uri); + $oembed_url = url('https://www.youtube.com/oembed', array('query' => array('url' => $external_url, 'format' => 'json'))); + $response = drupal_http_request($oembed_url); - return $local_path; + if (!isset($response->error)) { + $data = drupal_json_decode($response->data); + return $data['thumbnail_url']; + } + else { + throw new Exception("Error Processing Request. (Error: {$response->code}, {$response->error})"); + return; + } } } function getLocalThumbnailPath() { $parts = $this->get_parameters(); - // There's no need to hide thumbnails, always use the public system rather - // than file_default_scheme(). - $local_path = 'public://media-youtube/' . check_plain($parts['v']) . '.jpg'; - + $id = array_pop($parts); + $local_path = file_default_scheme() . '://media-youtube/' . check_plain($id) . '.jpg'; if (!file_exists($local_path)) { - $dirname = drupal_dirname($local_path); - file_prepare_directory($dirname, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); - $response = drupal_http_request($this->getOriginalThumbnailPath()); + // getOriginalThumbnailPath throws an exception if there are any errors + // when retrieving the original thumbnail from YouTube. + try { + $dirname = drupal_dirname($local_path); + file_prepare_directory($dirname, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); + $response = drupal_http_request($this->getOriginalThumbnailPath()); - if (!isset($response->error)) { - file_unmanaged_save_data($response->data, $local_path, TRUE); + if (!isset($response->error)) { + file_unmanaged_save_data($response->data, $local_path, TRUE); + } + else { + system_retrieve_file($this->getOriginalThumbnailPath(), $local_path, FALSE, FILE_EXISTS_REPLACE); + } } - else { - @copy($this->getOriginalThumbnailPath(), $local_path); + catch (Exception $e) { + // In the event of an endpoint error, use the mime type icon provided + // by the Media module. + $file = file_uri_to_object($this->uri); + $icon_dir = variable_get('media_icon_base_directory', 'public://media-icons') . '/' . variable_get('media_icon_set', 'default'); + $local_path = file_icon_path($file, $icon_dir); } } return $local_path; } + + /** + * Updates $base_url depending on whether the embed is a video or playlist. + */ + function setBaseUrl($parameters) { + if (isset($parameters['l'])) { + if (!isset($parameters['v'])) { + $this->base_url = 'https://youtube.com/playlist'; + } + $parameters['list'] = $parameters['l']; + unset($parameters['l']); + } + return $parameters; + } + + /** + * Returns a url in the format "http://www.youtube.com/watch?v=qsPQN4MiTeE". + * + * Overrides interpolateUrl() defined in MediaReadOnlyStreamWrapper. + */ + function interpolateUrl() { + if ($parameters = $this->get_parameters()) { + $parameters = $this->setBaseUrl($parameters); + return $this->base_url . '?' . http_build_query($parameters); + } + } + } diff --git a/profiles/wcm_base/modules/contrib/media_youtube/includes/media_youtube.formatters.inc b/profiles/wcm_base/modules/contrib/media_youtube/includes/media_youtube.formatters.inc index 970251f8..639a3395 100644 --- a/profiles/wcm_base/modules/contrib/media_youtube/includes/media_youtube.formatters.inc +++ b/profiles/wcm_base/modules/contrib/media_youtube/includes/media_youtube.formatters.inc @@ -29,6 +29,7 @@ function media_youtube_file_formatter_info() { 'showinfo' => TRUE, 'theme' => 'dark', 'captions' => FALSE, + 'controls' => FALSE, ), 'view callback' => 'media_youtube_file_formatter_video_view', 'settings callback' => 'media_youtube_file_formatter_video_settings', @@ -66,7 +67,7 @@ function media_youtube_file_formatter_video_view($file, $display, $langcode) { // Fake a default for attributes so the ternary doesn't choke. $display['settings']['attributes'] = array(); - foreach (array('width', 'height', 'autohide', 'autoplay', 'color', 'enablejsapi', 'loop', 'modestbranding', 'nocookie', 'origin', 'protocol', 'protocol_specify', 'rel', 'showinfo', 'theme', 'attributes', 'captions') as $setting) { + foreach (array('width', 'height', 'autohide', 'autoplay', 'color', 'enablejsapi', 'loop', 'modestbranding', 'nocookie', 'origin', 'protocol', 'protocol_specify', 'rel', 'showinfo', 'theme', 'attributes', 'captions','controls') as $setting) { $element['#options'][$setting] = isset($file->override[$setting]) ? $file->override[$setting] : $display['settings'][$setting]; } @@ -146,8 +147,13 @@ function media_youtube_file_formatter_video_settings($form, &$form_state, $setti '#type' => 'checkbox', '#default_value' => $settings['loop'], ); + $element['controls'] = array( + '#title' => t('Show Controls'), + '#type' => 'checkbox', + '#default_value' => $settings['controls'], + ); - // Note: make sure the positive/negitive language lines up with option + // Note: make sure the positive/negative language lines up with option // processing in media_youtube.theme.inc. $element['showinfo'] = array( '#title' => t('Display video title and uploader'), @@ -173,7 +179,7 @@ function media_youtube_file_formatter_video_settings($form, &$form_state, $setti '#title' => t('Specify an http protocol'), '#type' => 'checkbox', '#default_value' => $settings['protocol_specify'], - '#description' => t('An explicit protocol may be neccesary for videos embedded in RSS feeds and emails. If no protocol is specified, iframes will be protocol relative.'), + '#description' => t('An explicit protocol may be necessary for videos embedded in RSS feeds and emails. If no protocol is specified, iframes will be protocol relative.'), ); $element['protocol'] = array( '#title' => t('Iframe protocol'), @@ -246,7 +252,7 @@ function media_youtube_file_formatter_image_view($file, $display, $langcode) { if (empty($image_style) || !isset($valid_image_styles[$image_style])) { $element = array( '#theme' => 'image', - '#path' => str_replace('http:', '', $wrapper->getOriginalThumbnailPath()), + '#path' => str_replace('http:', '', $wrapper->getLocalThumbnailPath()), '#alt' => isset($file->override['attributes']['alt']) ? $file->override['attributes']['alt'] : $file->filename, ); } diff --git a/profiles/wcm_base/modules/contrib/media_youtube/media_youtube.file_default_displays.inc b/profiles/wcm_base/modules/contrib/media_youtube/media_youtube.file_default_displays.inc index 25f0f69d..45078b24 100644 --- a/profiles/wcm_base/modules/contrib/media_youtube/media_youtube.file_default_displays.inc +++ b/profiles/wcm_base/modules/contrib/media_youtube/media_youtube.file_default_displays.inc @@ -27,7 +27,7 @@ function media_youtube_file_default_displays() { 'loop' => 0, 'showinfo' => 1, 'modestbranding' => 0, - 'rel' => 1, + 'rel' => 0, 'nocookie' => 0, 'protocol_specify' => 0, 'protocol' => 'https:', @@ -61,7 +61,7 @@ function media_youtube_file_default_displays() { 'loop' => 0, 'showinfo' => 1, 'modestbranding' => 0, - 'rel' => 1, + 'rel' => 0, 'nocookie' => 0, 'protocol_specify' => 0, 'protocol' => 'https:', @@ -86,7 +86,7 @@ function media_youtube_file_default_displays() { 'loop' => 0, 'showinfo' => 1, 'modestbranding' => 0, - 'rel' => 1, + 'rel' => 0, 'nocookie' => 0, 'protocol_specify' => 0, 'protocol' => 'https:', @@ -110,7 +110,7 @@ function media_youtube_file_default_displays() { 'loop' => 0, 'showinfo' => 1, 'modestbranding' => 0, - 'rel' => 1, + 'rel' => 0, 'nocookie' => 0, 'protocol_specify' => 0, 'protocol' => 'https:', @@ -134,7 +134,7 @@ function media_youtube_file_default_displays() { 'loop' => 0, 'showinfo' => 1, 'modestbranding' => 0, - 'rel' => 1, + 'rel' => 0, 'nocookie' => 0, 'protocol_specify' => 0, 'protocol' => 'https:', diff --git a/profiles/wcm_base/modules/contrib/media_youtube/media_youtube.info b/profiles/wcm_base/modules/contrib/media_youtube/media_youtube.info index 82763adb..e6d86203 100644 --- a/profiles/wcm_base/modules/contrib/media_youtube/media_youtube.info +++ b/profiles/wcm_base/modules/contrib/media_youtube/media_youtube.info @@ -5,12 +5,15 @@ core = 7.x dependencies[] = media_internet +test_dependencies[] = media_internet (2.x) + +files[] = media_youtube.test files[] = includes/MediaYouTubeStreamWrapper.inc files[] = includes/MediaInternetYouTubeHandler.inc -; Information added by Drupal.org packaging script on 2015-05-28 -version = "7.x-3.0" +; Information added by Drupal.org packaging script on 2017-08-14 +version = "7.x-3.5" core = "7.x" project = "media_youtube" -datestamp = "1432800182" +datestamp = "1502719245" diff --git a/profiles/wcm_base/modules/contrib/media_youtube/media_youtube.test b/profiles/wcm_base/modules/contrib/media_youtube/media_youtube.test new file mode 100644 index 00000000..ca63c86a --- /dev/null +++ b/profiles/wcm_base/modules/contrib/media_youtube/media_youtube.test @@ -0,0 +1,104 @@ +<?php + +/** + * @file + * Tests for media_youtube.module. + */ + +/** + * Provides methods specifically for testing Media YouTube's YouTube video handling. + */ +class MediaYouTubeTestHelper extends MediaInternetTestHelper { + function setUp() { + // Since this is a base class for many test cases, support the same + // flexibility that DrupalWebTestCase::setUp() has for the modules to be + // passed in as either an array or a variable number of string arguments. + $modules = func_get_args(); + if (isset($modules[0]) && is_array($modules[0])) { + $modules = $modules[0]; + } + $modules[] = 'media_youtube'; + parent::setUp($modules); + } +} + +/** + * Test the MediaInternetYouTubeHandler provider. + */ +class MediaInternetYouTubeTestCase extends MediaYouTubeTestHelper { + public static function getInfo() { + return array( + 'name' => 'YouTube file handler provider', + 'description' => 'Test the YouTube handler provider.', + 'group' => 'Media YouTube', + ); + } + + function setUp() { + parent::setUp('media_youtube_test'); + + // Disable the private file system which is automatically enabled by + // DrupalTestCase so we can test the upload wizard correctly. + variable_del('file_private_path'); + + $web_user = $this->drupalCreateUser(array('create files', 'add media from remote sources', 'edit own video files')); + $this->drupalLogin($web_user); + } + + /** + * Tests YouTube file handler. + */ + function testYouTubeFileHandling() { + // Step 1: Add a video file by providing a URL to the resource on YouTube. + $edit = array(); + $edit['embed_code'] = 'https://www.youtube.com/watch?v=9g2U12SsRns'; + $this->drupalPost('file/add/web', $edit, t('Next')); + + // Check that the file exists in the database. + $fid = $this->getLastFileId(); + $file = file_load($fid); + $this->assertTrue($file, t('File found in database.')); + + // Check that the video file has been uploaded. + $this->assertRaw(t('!type %name was uploaded.', array('!type' => 'Video', '%name' => $file->filename)), t('Video file uploaded.')); + + // Verify that the video formatter is used to render the full video. + $video_info = array( + 'uri' => $file->uri, + 'options' => array( + 'width' => 640, + 'height' => 390, + 'autohide' => 2, + 'autoplay' => FALSE, + 'color' => 'red', + 'enablejsapi' => FALSE, + 'loop' => FALSE, + 'modestbranding' => FALSE, + 'nocookie' => FALSE, + 'origin' => '', + 'protocol' => 'https:', + 'protocol_specify' => FALSE, + 'rel' => TRUE, + 'showinfo' => TRUE, + 'theme' => 'dark', + 'captions' => FALSE, + ), + ); + $default_output = theme('media_youtube_video', $video_info); + $this->assertRaw($default_output, 'Video displayed using the Media: YouTube Video formatter.'); + + // Edit the file. + $this->drupalGet('file/' . $file->fid . '/edit'); + + // Verify that the image formatter is used to render the video preview. + $wrapper = file_stream_wrapper_get_instance_by_uri($file->uri); + $image_info = array( + 'uri' => $file->uri, + 'style_name' => 'media_thumbnail', + 'path' => $wrapper->getLocalThumbnailPath(), + 'alt' => isset($file->override['attributes']['alt']) ? $file->override['attributes']['alt'] : $file->filename, + ); + $default_output = theme('image_style', $image_info); + $this->assertRaw($default_output, 'Video displayed using the Media: YouTube Image formatter.'); + } +} diff --git a/profiles/wcm_base/modules/contrib/media_youtube/tests/includes/MediaYouTubeTestHandler.inc b/profiles/wcm_base/modules/contrib/media_youtube/tests/includes/MediaYouTubeTestHandler.inc new file mode 100644 index 00000000..9873d546 --- /dev/null +++ b/profiles/wcm_base/modules/contrib/media_youtube/tests/includes/MediaYouTubeTestHandler.inc @@ -0,0 +1,51 @@ +<?php + +/** + * @file + * Extends the MediaInternetYouTubeHandler class to make it suitable for local testing. + */ + +/** + * A test handler for YouTube videos. + * + * @see MediaInternetYouTubeHandler(). + */ +class MediaYouTubeTestHandler extends MediaInternetYouTubeHandler { + public function getOEmbed() { + $uri = $this->parse($this->embedCode); + $external_url = file_create_url($uri); + $oembed_url = url('media-youtube-test/oembed', array('query' => array('url' => $external_url, 'format' => 'json'), 'absolute' => TRUE)); + $response = drupal_http_request($oembed_url); + + if (!isset($response->error)) { + return drupal_json_decode($response->data); + } + else { + throw new Exception("Error Processing Request. (Error: {$response->code}, {$response->error})"); + return; + } + } + + /** + * Check if a YouTube video ID is valid. + * + * @return boolean + * TRUE if the video ID is valid, or throws a + * MediaInternetValidationException otherwise. + */ + public function validId($id, $type = 'v') { + $uri = file_stream_wrapper_uri_normalize('youtube://' . $type . '/' . check_plain($id)); + $external_url = file_create_url($uri); + $oembed_url = url('media-youtube-test/oembed', array('query' => array('url' => $external_url, 'format' => 'json'), 'absolute' => TRUE)); + $response = drupal_http_request($oembed_url, array('method' => 'HEAD')); + + if ($response->code == 401) { + throw new MediaInternetValidationException('Embedding has been disabled for this YouTube video.'); + } + elseif ($response->code != 200) { + throw new MediaInternetValidationException('The YouTube video ID is invalid or the video was deleted.'); + } + + return TRUE; + } +} diff --git a/profiles/wcm_base/modules/contrib/media_youtube/tests/includes/MediaYouTubeTestStreamWrapper.inc b/profiles/wcm_base/modules/contrib/media_youtube/tests/includes/MediaYouTubeTestStreamWrapper.inc new file mode 100644 index 00000000..ec7ee94f --- /dev/null +++ b/profiles/wcm_base/modules/contrib/media_youtube/tests/includes/MediaYouTubeTestStreamWrapper.inc @@ -0,0 +1,28 @@ +<?php + +/** + * @file + * Extends the MediaYouTubeStreamWrapper class to make it suitable for local testing. + */ + +/** + * Create an instance like this: + * $youtube = new MediaYouTubeTestStreamWrapper('youtube://v/[video-code]'); + */ +class MediaYouTubeTestStreamWrapper extends MediaYouTubeStreamWrapper { + function getOriginalThumbnailPath() { + $parts = $this->get_parameters(); + $uri = file_stream_wrapper_uri_normalize('youtube://v/' . check_plain($parts['v'])); + $external_url = file_create_url($uri); + $oembed_url = url('media-youtube-test/oembed', array('query' => array('url' => $external_url, 'format' => 'json'), 'absolute' => TRUE)); + $response = drupal_http_request($oembed_url); + + if (!isset($response->error)) { + $data = drupal_json_decode($response->data); + return $data['thumbnail_url']; + } + else { + throw new Exception(t('Error Processing Request. (Error: %code, %error)', array('%code' => $response->code, '%error' => $response->error))); + } + } +} diff --git a/profiles/wcm_base/modules/contrib/media_youtube/tests/media_youtube_test.info b/profiles/wcm_base/modules/contrib/media_youtube/tests/media_youtube_test.info new file mode 100644 index 00000000..a1cc74b9 --- /dev/null +++ b/profiles/wcm_base/modules/contrib/media_youtube/tests/media_youtube_test.info @@ -0,0 +1,16 @@ +name = Media YouTube Test +description = Provides hooks for testing Media YouTube module functionality. +package = Media +core = 7.x +dependencies[] = media_youtube +hidden = TRUE + +files[] = includes/MediaYouTubeTestStreamWrapper.inc +files[] = includes/MediaYouTubeTestHandler.inc + +; Information added by Drupal.org packaging script on 2017-08-14 +version = "7.x-3.5" +core = "7.x" +project = "media_youtube" +datestamp = "1502719245" + diff --git a/profiles/wcm_base/modules/contrib/media_youtube/tests/media_youtube_test.module b/profiles/wcm_base/modules/contrib/media_youtube/tests/media_youtube_test.module new file mode 100644 index 00000000..44f3c4ba --- /dev/null +++ b/profiles/wcm_base/modules/contrib/media_youtube/tests/media_youtube_test.module @@ -0,0 +1,73 @@ +<?php + +/** + * @file + * Alters Media: YouTube video handling to make it suitable for local testing. + */ + +/** + * Implements hook_menu(). + */ +function media_youtube_test_menu() { + $items['media-youtube-test/oembed'] = array( + 'title' => 'Drupal Goto', + 'page callback' => 'media_youtube_test_oembed', + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + ); + + return $items; +} + +/** + * Provides a fake oEmbed endpoint for local testing. + */ +function media_youtube_test_oembed() { + $query_parameters = drupal_get_query_parameters(); + $query = parse_url($query_parameters['url'], PHP_URL_QUERY); + parse_str($query, $params); + + $data = array( + 'thumbnail_url' => 'https://i.ytimg.com/vi/' . $params['v'] . '/hqdefault.jpg', + 'thumbnail_width' => 480, + 'author_name' => 'YouTube Help', + 'height' => 270, + 'provider_url' => 'http://www.youtube.com/', + 'html' => '<iframe width="480" height="270" src="https://www.youtube.com/embed/' . $params['v'] . '?feature=oembed" frameborder="0" allowfullscreen></iframe>', + 'thumbnail_height' => 360, + 'title' => 'YouTube Content ID', + 'provider_name' => 'YouTube', + 'type' => 'video', + 'width' => 480, + 'version' => '1.0', + 'author_url' => 'http://www.youtube.com/user/YouTubeHelp', + ); + + drupal_json_output($data); +} + +/** + * Implements hook_media_internet_providers_alter(). + */ +function media_youtube_test_media_internet_providers_alter(&$providers) { + $provider = $providers['MediaInternetYouTubeHandler']; + unset($providers['MediaInternetYouTubeHandler']); + $providers['MediaYouTubeTestHandler'] = $provider; +} + +/** + * Implements hook_stream_wrappers_alter(). + */ +function media_youtube_test_stream_wrappers_alter(&$wrappers) { + $wrappers['youtube']['class'] = 'MediaYouTubeTestStreamWrapper'; +} + +/** + * Implements hook_media_parse_alter(). + */ +function media_youtube_test_media_parse_alter(&$success, $context) { + if ($context['module'] == 'media_youtube') { + $handler = new MediaYouTubeTestHandler($context['url']); + $success = $handler->parse($context['url']); + } +} diff --git a/profiles/wcm_base/modules/contrib/media_youtube/themes/media_youtube.theme.inc b/profiles/wcm_base/modules/contrib/media_youtube/themes/media_youtube.theme.inc index 25e339e6..85aa6205 100644 --- a/profiles/wcm_base/modules/contrib/media_youtube/themes/media_youtube.theme.inc +++ b/profiles/wcm_base/modules/contrib/media_youtube/themes/media_youtube.theme.inc @@ -12,11 +12,34 @@ function media_youtube_preprocess_media_youtube_video(&$variables) { // Build the URI. $wrapper = file_stream_wrapper_get_instance_by_uri($variables['uri']); - $parts = $wrapper->get_parameters(); - $variables['video_id'] = check_plain($parts['v']); + if ($wrapper instanceof MediaReadOnlyStreamWrapper) { + $parts = $wrapper->get_parameters(); + if (isset($parts['v'])) { + $variables['embed_type'] = 'video'; + $variables['video_id'] = check_plain($parts['v']); + $embed_path = '/embed/' . $variables['video_id']; + } + elseif (isset($parts['l'])) { + $variables['embed_type'] = 'playlist'; + $variables['video_id'] = check_plain($parts['l']); + $embed_path = '/embed/videoseries'; + } + } + else { + // This happens when stream wrappers are not yet initialized. This is + // normally only encountered when creating content during profile install + // using drush make. At that point, video_id is irrelevant anyway. + $variables['video_id'] = ''; + } - // Make the file object available. - $file_object = file_uri_to_object($variables['uri']); + // Checked existing function. + if(function_exists('file_uri_to_object')) { + // Make the file object available. + $file_object = file_uri_to_object($variables['uri']); + } + else { + $file_object = media_youtube_file_uri_to_object($variables['uri']); + } // Parse options and build the query string. Only add the option to the query // array if the option value is not default. Be careful, depending on the @@ -27,6 +50,14 @@ function media_youtube_preprocess_media_youtube_video(&$variables) { // Make css z-index work with flash object. Must be the first parameter. $query['wmode'] = 'opaque'; + //YouTube video controls, on or off. + if (isset($variables['options']['controls'])) { + //on or off (TRUE/FALSE) depending on what is stored in $variables['options']['controls']. + $query['controls'] = $variables['options']['controls']; + } else { + //on + $query['controls'] = TRUE; + } // These queries default to 0. If the option is true, set value to 1. foreach (array('autoplay', 'enablejsapi', 'loop', 'modestbranding') as $option) { if ($variables['options'][$option]) { @@ -85,19 +116,19 @@ function media_youtube_preprocess_media_youtube_video(&$variables) { } } - // Non-query options. - if ($variables['options']['nocookie']) { - $url_base = 'youtube-nocookie.com'; + if ($variables['options']['protocol_specify']) { + $protocol = $variables['options']['protocol']; } else { - $url_base = 'youtube.com'; + $protocol = 'https:'; } - if ($variables['options']['protocol_specify']) { - $protocol = $variables['options']['protocol']; + // Non-query options. + if ($variables['options']['nocookie']) { + $url_base = 'youtube-nocookie.com'; } else { - $protocol = ''; + $url_base = 'youtube.com'; } // Add some options as their own template variables. @@ -123,6 +154,31 @@ function media_youtube_preprocess_media_youtube_video(&$variables) { // to use for the alternative content. $variables['alternative_content'] = t('Video of @title', array('@title' => $variables['title'])); + if (isset($parts['l'])) { + $query['list'] = $parts['l']; + } // Build the iframe URL with options query string. - $variables['url'] = url($protocol . '//www.' . $url_base . '/embed/' . $variables['video_id'], array('query' => $query, 'external' => TRUE)); + $variables['url'] = url($protocol . '//www.' . $url_base . $embed_path, array('query' => $query, 'external' => TRUE)); +} + +/** + * Helping function. + */ +function media_youtube_file_uri_to_object($uri) { + $uri = file_stream_wrapper_uri_normalize($uri); + $files = entity_load('file', FALSE, array('uri' => $uri)); + $file = !empty($files) ? reset($files) : FALSE; + if (!$file) { + global $user; + $file = new stdClass(); + $file->uid = $user->uid; + $file->filename = basename($uri); + $file->uri = $uri; + $file->filemime = file_get_mimetype($uri); + // This is gagged because some uris will not support it. + $file->filesize = @filesize($uri); + $file->timestamp = REQUEST_TIME; + $file->status = FILE_STATUS_PERMANENT; + } + return $file; } diff --git a/profiles/wcm_base/modules/custom/ocio_media/ocio_media.features.features_overrides.inc b/profiles/wcm_base/modules/custom/ocio_media/ocio_media.features.features_overrides.inc index e8149a72..93133c54 100644 --- a/profiles/wcm_base/modules/custom/ocio_media/ocio_media.features.features_overrides.inc +++ b/profiles/wcm_base/modules/custom/ocio_media/ocio_media.features.features_overrides.inc @@ -28,13 +28,14 @@ function ocio_media_features_override_default_overrides() { $overrides["file_display.video__default__media_vimeo_video.settings|protocol_specify"] = FALSE; $overrides["file_display.video__default__media_youtube_video.settings|captions"] = FALSE; $overrides["file_display.video__default__media_youtube_video.settings|modestbranding"] = 1; - $overrides["file_display.video__default__media_youtube_video.settings|rel"] = 0; $overrides["file_display.video__default__media_youtube_video.weight"] = -47; $overrides["file_display.video__preview__file_field_file_default.status"] = FALSE; $overrides["file_display.video__preview__file_field_file_default.weight"] = -41; $overrides["file_display.video__preview__file_field_media_large_icon.status"] = FALSE; $overrides["file_display.video__preview__file_field_media_large_icon.weight"] = -42; + $overrides["file_display.video__preview__media_vimeo_image.settings|image_style"] = 'panopoly_image_thumbnail'; $overrides["file_display.video__preview__media_vimeo_image.weight"] = -48; + $overrides["file_display.video__preview__media_youtube_image.settings|image_style"] = 'panopoly_image_thumbnail'; $overrides["file_display.video__preview__media_youtube_image.weight"] = -49; // Exported overrides for: file_type diff --git a/profiles/wcm_base/modules/custom/ocio_media/ocio_media.features.field_instance.inc b/profiles/wcm_base/modules/custom/ocio_media/ocio_media.features.field_instance.inc index 92071a83..4d650cb5 100644 --- a/profiles/wcm_base/modules/custom/ocio_media/ocio_media.features.field_instance.inc +++ b/profiles/wcm_base/modules/custom/ocio_media/ocio_media.features.field_instance.inc @@ -47,6 +47,12 @@ function ocio_media_field_default_field_instances() { 'type' => 'hidden', 'weight' => 0, ), + 'wysiwyg' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), ), 'ds_extras_field_template' => '', 'entity_type' => 'file', @@ -149,6 +155,12 @@ function ocio_media_field_default_field_instances() { 'type' => 'hidden', 'weight' => 1, ), + 'wysiwyg' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), ), 'ds_extras_field_template' => '', 'entity_type' => 'file', @@ -257,6 +269,12 @@ function ocio_media_field_default_field_instances() { 'type' => 'hidden', 'weight' => 0, ), + 'wysiwyg' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), ), 'ds_extras_field_template' => '', 'entity_type' => 'file', @@ -369,6 +387,12 @@ function ocio_media_field_default_field_instances() { 'type' => 'hidden', 'weight' => 0, ), + 'wysiwyg' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), ), 'entity_type' => 'file', 'field_name' => 'field_file_image_alt_text', @@ -474,6 +498,12 @@ function ocio_media_field_default_field_instances() { 'type' => 'hidden', 'weight' => 0, ), + 'wysiwyg' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), ), 'entity_type' => 'file', 'field_name' => 'field_file_image_title_text', @@ -579,6 +609,12 @@ function ocio_media_field_default_field_instances() { 'type' => 'hidden', 'weight' => 2, ), + 'wysiwyg' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), ), 'ds_extras_field_template' => '', 'entity_type' => 'file', diff --git a/profiles/wcm_base/modules/custom/ocio_media/ocio_media.features.inc b/profiles/wcm_base/modules/custom/ocio_media/ocio_media.features.inc index a5989753..a9babced 100644 --- a/profiles/wcm_base/modules/custom/ocio_media/ocio_media.features.inc +++ b/profiles/wcm_base/modules/custom/ocio_media/ocio_media.features.inc @@ -58,7 +58,6 @@ function ocio_media_file_default_displays_alter(&$data) { if (isset($data['video__default__media_youtube_video'])) { $data['video__default__media_youtube_video']->settings['captions'] = FALSE; /* WAS: '' */ $data['video__default__media_youtube_video']->settings['modestbranding'] = 1; /* WAS: 0 */ - $data['video__default__media_youtube_video']->settings['rel'] = 0; /* WAS: 1 */ $data['video__default__media_youtube_video']->weight = -47; /* WAS: 0 */ } if (isset($data['video__preview__file_field_file_default'])) { @@ -70,9 +69,11 @@ function ocio_media_file_default_displays_alter(&$data) { $data['video__preview__file_field_media_large_icon']->weight = -42; /* WAS: 49 */ } if (isset($data['video__preview__media_vimeo_image'])) { + $data['video__preview__media_vimeo_image']->settings['image_style'] = 'panopoly_image_thumbnail'; /* WAS: 'media_thumbnail' */ $data['video__preview__media_vimeo_image']->weight = -48; /* WAS: 0 */ } if (isset($data['video__preview__media_youtube_image'])) { + $data['video__preview__media_youtube_image']->settings['image_style'] = 'panopoly_image_thumbnail'; /* WAS: 'media_thumbnail' */ $data['video__preview__media_youtube_image']->weight = -49; /* WAS: 0 */ } } @@ -87,10 +88,10 @@ function ocio_media_file_default_types_alter(&$data) { if (isset($data['document'])) { $data['document']->disabled = FALSE; /* WAS: '' */ $data['document']->mimetypes[10] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; /* WAS: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' */ - $data['document']->mimetypes[11] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; /* WAS: '' */ - $data['document']->mimetypes[12] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'; /* WAS: '' */ - $data['document']->mimetypes[13] = 'application/acad'; /* WAS: '' */ - $data['document']->mimetypes[14] = 'application/dxf'; /* WAS: '' */ + $data['document']->mimetypes[11] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; /* WAS: 'application/zip' */ + $data['document']->mimetypes[12] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'; /* WAS: 'application/x-7z-compressed' */ + $data['document']->mimetypes[13] = 'application/acad'; /* WAS: 'application/x-tar' */ + $data['document']->mimetypes[14] = 'application/dxf'; /* WAS: 'application/gzip' */ $data['document']->mimetypes[4] = 'application/zip'; /* WAS: 'application/vnd.ms-powerpoint' */ $data['document']->mimetypes[5] = 'application/vnd.ms-powerpoint'; /* WAS: 'application/vnd.oasis.opendocument.text' */ $data['document']->mimetypes[6] = 'application/vnd.oasis.opendocument.text'; /* WAS: 'application/vnd.oasis.opendocument.spreadsheet' */ diff --git a/profiles/wcm_base/modules/custom/ocio_media/ocio_media.info b/profiles/wcm_base/modules/custom/ocio_media/ocio_media.info index 0470bbb9..c6084d5a 100644 --- a/profiles/wcm_base/modules/custom/ocio_media/ocio_media.info +++ b/profiles/wcm_base/modules/custom/ocio_media/ocio_media.info @@ -62,16 +62,16 @@ features[features_overrides][] = file_display.image__preview__file_field_media_l features[features_overrides][] = file_display.image__preview__file_field_media_large_icon.weight features[features_overrides][] = file_display.video__default__media_vimeo_video.settings|protocol features[features_overrides][] = file_display.video__default__media_vimeo_video.settings|protocol_specify -features[features_overrides][] = file_display.video__default__media_vimeo_video.weight features[features_overrides][] = file_display.video__default__media_youtube_video.settings|captions features[features_overrides][] = file_display.video__default__media_youtube_video.settings|modestbranding -features[features_overrides][] = file_display.video__default__media_youtube_video.settings|rel features[features_overrides][] = file_display.video__default__media_youtube_video.weight features[features_overrides][] = file_display.video__preview__file_field_file_default.status features[features_overrides][] = file_display.video__preview__file_field_file_default.weight features[features_overrides][] = file_display.video__preview__file_field_media_large_icon.status features[features_overrides][] = file_display.video__preview__file_field_media_large_icon.weight +features[features_overrides][] = file_display.video__preview__media_vimeo_image.settings|image_style features[features_overrides][] = file_display.video__preview__media_vimeo_image.weight +features[features_overrides][] = file_display.video__preview__media_youtube_image.settings|image_style features[features_overrides][] = file_display.video__preview__media_youtube_image.weight features[features_overrides][] = file_type.audio.disabled features[features_overrides][] = file_type.document.disabled @@ -221,8 +221,10 @@ features[variable][] = field_bundle_settings_file__image features[variable][] = field_bundle_settings_file__video features[variable][] = file_entity_alt features[variable][] = file_entity_default_allowed_extensions +features[variable][] = file_entity_default_file_directory features[variable][] = file_entity_file_upload_wizard_skip_scheme features[variable][] = file_entity_max_filesize +features[variable][] = file_entity_max_filesize_extensions features[variable][] = file_entity_title features[variable][] = manualcrop_file_entity_settings_image features[variable][] = media_wysiwyg_default_render diff --git a/profiles/wcm_base/modules/custom/ocio_media/ocio_media.strongarm.inc b/profiles/wcm_base/modules/custom/ocio_media/ocio_media.strongarm.inc index e4583722..4b9cff05 100644 --- a/profiles/wcm_base/modules/custom/ocio_media/ocio_media.strongarm.inc +++ b/profiles/wcm_base/modules/custom/ocio_media/ocio_media.strongarm.inc @@ -340,6 +340,13 @@ function ocio_media_strongarm() { $strongarm->value = 'jpg jpeg gif png svg txt doc docx xls xlsx pdf ppt pptx pps ppsx odt ods odp zip dwg dxf dotx'; $export['file_entity_default_allowed_extensions'] = $strongarm; + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'file_entity_default_file_directory'; + $strongarm->value = '[current-date:custom:Y]/[current-date:custom:m]/[current-date:custom:d]'; + $export['file_entity_default_file_directory'] = $strongarm; + $strongarm = new stdClass(); $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ $strongarm->api_version = 1; @@ -354,6 +361,14 @@ function ocio_media_strongarm() { $strongarm->value = '5mb'; $export['file_entity_max_filesize'] = $strongarm; + $strongarm = new stdClass(); + $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'file_entity_max_filesize_extensions'; + $strongarm->value = 'pdf|50 MB +zip|50 MB'; + $export['file_entity_max_filesize_extensions'] = $strongarm; + $strongarm = new stdClass(); $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ $strongarm->api_version = 1; @@ -404,7 +419,7 @@ function ocio_media_strongarm() { $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ $strongarm->api_version = 1; $strongarm->name = 'media_wysiwyg_wysiwyg_upload_directory'; - $strongarm->value = 'files-[current-date:raw]'; + $strongarm->value = '[current-date:custom:Y]/[current-date:custom:m]/[current-date:custom:d]'; $export['media_wysiwyg_wysiwyg_upload_directory'] = $strongarm; return $export; diff --git a/profiles/wcm_base/modules/custom/ocio_news/ocio_news.features.field_instance.inc b/profiles/wcm_base/modules/custom/ocio_news/ocio_news.features.field_instance.inc index db786c37..e08853fb 100644 --- a/profiles/wcm_base/modules/custom/ocio_news/ocio_news.features.field_instance.inc +++ b/profiles/wcm_base/modules/custom/ocio_news/ocio_news.features.field_instance.inc @@ -214,7 +214,7 @@ function ocio_news_field_default_field_instances() { 'settings' => array( 'alt_field' => 0, 'default_image' => 0, - 'file_directory' => '', + 'file_directory' => '[current-date:custom:Y]/[current-date:custom:m]/[current-date:custom:d]', 'file_extensions' => 'png gif jpg jpeg', 'max_filesize' => '', 'max_resolution' => '', diff --git a/profiles/wcm_base/modules/custom/ocio_news/ocio_news.info b/profiles/wcm_base/modules/custom/ocio_news/ocio_news.info index 2265b688..13f413eb 100644 --- a/profiles/wcm_base/modules/custom/ocio_news/ocio_news.info +++ b/profiles/wcm_base/modules/custom/ocio_news/ocio_news.info @@ -5,6 +5,7 @@ package = OCIO Features version = 7.x-1.0 project = ocio_news dependencies[] = context +dependencies[] = file_entity dependencies[] = media dependencies[] = ocio_field_bases dependencies[] = ocio_taxonomy diff --git a/profiles/wcm_base/wcm_base.make b/profiles/wcm_base/wcm_base.make index 9b39970d..524106ea 100644 --- a/profiles/wcm_base/wcm_base.make +++ b/profiles/wcm_base/wcm_base.make @@ -51,9 +51,10 @@ projects[field_group][patch][1670136] = http://drupal.org/files/issues/1670136-e projects[fieldable_panels_panes][version] = 1.10 projects[fieldable_panels_panes][subdir] = contrib -projects[file_entity][version] = 2.0-beta3 +projects[file_entity][version] = 2.4 projects[file_entity][subdir] = contrib projects[file_entity][patch][2530656] = http://drupal.org/files/issues/file_entity-file-size-limit-per-file-type-2530656-3.patch +projects[file_entity][patch][1997208] = http://drupal.org/files/issues/use-file_entity_default_file_directory-1997208-33.patch projects[file_entity_swf][version] = 1.0-rc2 projects[file_entity_swf][subdir] = contrib @@ -86,13 +87,12 @@ projects[migrate][2654222][2297685] = http://drupal.org/files/issues/migrate-php projects[mimemail][version] = 1.0-beta4 projects[mimemail][subdir] = contrib -projects[media][version] = 2.1 +projects[media][version] = 2.10 projects[media][subdir] = contrib projects[media][patch][2297685] = http://drupal.org/files/issues/media-edit_uri_for_remote_files-2297685-6.patch -projects[media_youtube][version] = 3.0 +projects[media_youtube][version] = 3.5 projects[media_youtube][subdir] = contrib -projects[media_youtube][patch][2498493] = http://drupal.org/files/issues/media_youtube-remove_thumbnail_exception-2498493-23.patch projects[navbar][version] = 1.5 projects[navbar][subdir] = contrib -- GitLab