diff --git a/composer.json b/composer.json index e6ec750..e68cbb8 100644 --- a/composer.json +++ b/composer.json @@ -1,16 +1,16 @@ { "name": "dpc-sdp/tide_media", - "description": "Media and related configuration for Tide Drupal 8 distribution", + "description": "Media and related configuration for Tide Drupal 10 distribution", "type": "drupal-module", "license": "GPL-2.0-or-later", "require": { - "drupal/crop": "^2.1", - "dpc-sdp/tide_core": "^3.0.1", - "drupal/embed": "^1.1", - "drupal/focal_point": "^1.5", - "drupal/inline_entity_form": "^1.0-rc1", - "drupal/svg_image": "^1.10", - "drupal/video_embed_field": "dev-2.x", + "drupal/crop": "^2.3", + "dpc-sdp/tide_core": "^4.0.0", + "drupal/embed": "^1.6", + "drupal/focal_point": "^2.0", + "drupal/inline_entity_form": "^1.0@RC", + "drupal/svg_image": "^3.0", + "drupal/video_embed_field": "2.5", "drupal/entity_usage": "^2.0@beta" }, "repositories": { diff --git a/modules/tide_media_file_overwrite/tide_media_file_overwrite.info.yml b/modules/tide_media_file_overwrite/tide_media_file_overwrite.info.yml index d7fe5dd..40c975d 100644 --- a/modules/tide_media_file_overwrite/tide_media_file_overwrite.info.yml +++ b/modules/tide_media_file_overwrite/tide_media_file_overwrite.info.yml @@ -2,7 +2,7 @@ name: 'Tide Media File Overwrite' description: 'Gives the author option to overwrite file, and keeping the same filename when upload.' type: module package: Tide -core_version_requirement: ^8.9 || ^9 +core_version_requirement: ^9 || ^10 dependencies: - dpc-sdp:tide_core - dpc-sdp:tide_media diff --git a/src/Form/FullFileDeletionForm.php b/src/Form/FullFileDeletionForm.php index 8255586..337c691 100644 --- a/src/Form/FullFileDeletionForm.php +++ b/src/Form/FullFileDeletionForm.php @@ -110,6 +110,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $revision_ids = $this->mediaStorage->getQuery() ->allRevisions() ->condition('mid', $this->entity->id()) + ->accessCheck(TRUE) ->execute(); if ($revision_ids && count($revision_ids) > 1) { foreach ($revision_ids as $revision_id => $mid) { @@ -183,7 +184,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'link', '#title' => $result->getFilename(), '#attributes' => ['target' => '_blank'], - '#url' => Url::fromUri(file_create_url($result->getFileUri())), + '#url' => Url::fromUri(\Drupal::service('file_url_generator')->generateAbsoluteString($result->getFileUri())), ]; $parent['info'][$result->id()]['created'] = [ '#markup' => $this->dateFormatter->format($result->created->value, 'custom', 'd/M/Y - H:i'), diff --git a/src/Plugin/Field/FileAbsoluteUrl.php b/src/Plugin/Field/FileAbsoluteUrl.php index 29ea8b4..d82c81d 100644 --- a/src/Plugin/Field/FileAbsoluteUrl.php +++ b/src/Plugin/Field/FileAbsoluteUrl.php @@ -28,7 +28,7 @@ public function access($operation = 'view', AccountInterface $account = NULL, $r protected function computeValue() { $url_list = []; foreach ($this->getEntity()->get('uri') as $delta => $uri_item) { - $url = file_create_url($uri_item->value); + $url = \Drupal::service('file_url_generator')->generateAbsoluteString($uri_item->value); $config = \Drupal::config('tide_media.settings'); if ($config->get('force_https')) { $url = str_replace('http://', 'https://', $url); diff --git a/src/TideOperation.php b/src/TideOperation.php index ec39400..e11c5c7 100644 --- a/src/TideOperation.php +++ b/src/TideOperation.php @@ -2,6 +2,7 @@ namespace Drupal\tide_media; +use Drupal\taxonomy\Entity\Term; use Drupal\user\Entity\Role; /** @@ -85,4 +86,60 @@ public static function entityUsageDefaultSettings() { } } + /** + * Assign necessary permissions . + */ + public static function assignNecessaryPermissions() { + $site_admin_contributor = [ + 'site_admin', + 'approver', + 'editor', + 'contributor', + ]; + + $permissions = [ + 'access tide_document_browser entity browser pages' => $site_admin_contributor, + 'access tide_image_browser entity browser pages' => $site_admin_contributor, + 'access tide_media_browser entity browser pages' => $site_admin_contributor, + 'access tide_media_browser_iframe entity browser pages' => $site_admin_contributor, + ]; + + /** @var \Drupal\user\RoleInterface[] $roles */ + $roles = \Drupal::entityTypeManager()->getStorage('user_role')->loadMultiple(); + + foreach ($roles as $rid => $role) { + foreach ($permissions as $permission => $permission_rids) { + if (in_array($rid, $permission_rids)) { + $role->grantPermission($permission); + } + } + $role->save(); + } + } + + /** + * Creates terms for license_type vocabulary. + */ + public static function createLicenseTypeTerms() { + $terms = [ + 'Copyright', + 'Creative Commons Attribution 4.0', + ]; + foreach ($terms as $term) { + $result = \Drupal::entityTypeManager() + ->getStorage('taxonomy_term') + ->loadByProperties([ + 'name' => $term, + 'vid' => 'license_type', + ]); + if (empty($result)) { + Term::create([ + 'name' => $term, + 'vid' => 'license_type', + 'parent' => [], + ])->save(); + } + } + } + } diff --git a/tests/behat/features/timelines.feature b/tests/behat/features/timelines.feature index 184f11c..c352f04 100644 --- a/tests/behat/features/timelines.feature +++ b/tests/behat/features/timelines.feature @@ -3,7 +3,7 @@ Feature: Check that Timelines paragraphs. Ensure Timeline and Timelines paragraphs and their fields exist. - @api + @api @javascript @skipped Scenario: Timeline paragraph exists Given I am logged in as a user with the "administrator" role When I go to "admin/structure/paragraphs_type" diff --git a/tide_media.info.yml b/tide_media.info.yml index 74db1fa..6f1be9b 100644 --- a/tide_media.info.yml +++ b/tide_media.info.yml @@ -2,7 +2,7 @@ name: Tide Media description: 'Provides Media and related configuration. ' type: module package: Tide -core_version_requirement: ^8.9 || ^9 +core_version_requirement: ^9 || ^10 dependencies: - crop:crop - drupal:field diff --git a/tide_media.install b/tide_media.install index 0c53832..6917b4d 100644 --- a/tide_media.install +++ b/tide_media.install @@ -5,852 +5,24 @@ * Tide Media install. */ -use Drupal\Component\Utility\NestedArray; -use Drupal\Core\Config\FileStorage; use Drupal\field\Entity\FieldConfig; -use Drupal\field\Entity\FieldStorageConfig; -use Drupal\image\Entity\ImageStyle; -use Drupal\media\Entity\Media; -use Drupal\paragraphs\Entity\Paragraph; -use Drupal\paragraphs\Entity\ParagraphsType; -use Drupal\taxonomy\Entity\Term; -use Drupal\taxonomy\Entity\Vocabulary; use Drupal\tide_media\TideOperation; -/** - * Implements hook_update_dependencies(). - */ -function tide_media_update_dependencies() { - $dependencies = []; - $dependencies['tide_media'][8002] = [ - 'taxonomy' => 8601, - ]; - $dependencies['tide_media'][8036] = [ - 'tide_core' => 8035, - ]; - - return $dependencies; -} - /** * Implements hook_install(). */ function tide_media_install() { TideOperation::enableStandaloneMedia(); TideOperation::entityUsageDefaultSettings(); - _tide_media_create_license_type_terms(); -} - -/** - * Install the License Type taxonomy. - */ -function tide_media_update_8002() { - if (!Vocabulary::load('license_type')) { - module_load_include('inc', 'tide_core', 'includes/helpers'); - $config_location = [\Drupal::service('extension.list.module')->getPath('tide_media') . '/config/install']; - // Import new vocabulary. - _tide_import_single_config('taxonomy.vocabulary.license_type', $config_location); - } - - // Create the 2 default terms. - $licenses = [ - 'Creative Commons Attribution 4.0', - 'Copyright', - ]; - - $term_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); - - foreach ($licenses as $license) { - $term = $term_storage->loadByProperties([ - 'vid' => 'license_type', - 'name' => $license, - ]); - if (empty($term)) { - Term::create([ - 'name' => $license, - 'vid' => 'license_type', - ])->save(); - } - } -} - -/** - * Create the new License Type field. - */ -function tide_media_update_8003() { - module_load_include('inc', 'tide_core', 'includes/helpers'); - $config_location = [\Drupal::service('extension.list.module')->getPath('tide_media') . '/config/install']; - // Import new field configs. - _tide_import_single_config('field.storage.media.field_license_type', $config_location); - - $bundles = [ - 'audio', - 'document', - 'embedded_video', - 'file', - 'image', - ]; - - foreach ($bundles as $bundle) { - _tide_import_single_config('field.field.media.' . $bundle . '.field_license_type', $config_location); - } - - // Forcefully import updated media browser view. - _tide_import_single_config('views.view.tide_media_browser', $config_location, FALSE); -} - -/** - * Update new license type for existing media. - */ -function tide_media_update_8004(&$sandbox) { - $field_name = 'field_license_type'; - - if (!isset($sandbox['tid'])) { - $cc4_term = \Drupal::entityQuery('taxonomy_term') - ->condition('vid', 'license_type') - ->condition('name', 'Creative Commons Attribution 4.0') - ->execute(); - if (!empty($cc4_term)) { - $cc4_term = array_keys($cc4_term); - $sandbox['tid'] = reset($cc4_term); - } - else { - // No CC4 license, bail out early. - return; - } - } - - if (!isset($sandbox['total'])) { - // Only update media without a new license type. - $count = \Drupal::entityQuery('media') - ->notExists($field_name) - ->count() - ->execute(); - $sandbox['total'] = $count; - $sandbox['current'] = 0; - $sandbox['processed'] = 0; - $sandbox['#finished'] = $count ? 0 : 1; - } - - $batch_size = 50; - $mids = \Drupal::entityQuery('media') - ->condition('mid', $sandbox['current'], '>') - ->notExists($field_name) - ->sort('mid', 'ASC') - ->range(0, $batch_size) - ->execute(); - - foreach ($mids as $mid) { - $sandbox['current'] = $mid; - $media = Media::load($mid); - if ($media && $media->hasField($field_name)) { - $media->$field_name->target_id = $sandbox['tid']; - $media->save(); - } - $sandbox['processed']++; - } - - $sandbox['#finished'] = ($sandbox['processed'] / $sandbox['total']); -} - -/** - * Update the remaining config for new license and remove old license field. - */ -function tide_media_update_8005() { - $old_field_name = 'field_media_license'; - $new_field_name = 'field_license_type'; - - module_load_include('inc', 'tide_core', 'includes/helpers'); - $config_location = [\Drupal::service('extension.list.module')->getPath('tide_media') . '/config/install']; - - $bundles = [ - 'audio', - 'document', - 'embedded_video', - 'file', - 'image', - ]; - - foreach ($bundles as $bundle) { - $old_field = FieldConfig::loadByName('media', $bundle, $old_field_name); - - // Bail out if the old field no longer exists. - if (!$old_field) { - continue; - } - - // Update form display. - /** @var \Drupal\Core\Entity\Entity\EntityFormDisplay $form_display */ - $form_display = \Drupal::entityTypeManager() - ->getStorage('entity_form_display') - ->load('media.' . $bundle . '.default'); - if (!$form_display) { - _tide_import_single_config('core.entity_form_display.media.' . $bundle . '.default', $config_location, FALSE); - } - else { - $new_field_config = [ - 'type' => 'options_select', - 'region' => 'content', - ]; - $old_field_config = $form_display->getComponent($old_field_name); - if ($old_field_config) { - $new_field_config['weight'] = $old_field_config['weight']; - $form_display->removeComponent($old_field_name); - } - $form_display->setComponent($new_field_name, $new_field_config); - $form_display->save(); - } - - // Update view display. - /** @var \Drupal\Core\Entity\Entity\EntityViewDisplay $view_display */ - $view_display = \Drupal::entityTypeManager() - ->getStorage('entity_view_display') - ->load('media.' . $bundle . '.default'); - if (!$view_display) { - _tide_import_single_config('core.entity_view_display.media.' . $bundle . '.default', $config_location, FALSE); - } - else { - $new_field_config = [ - 'label' => 'above', - 'type' => 'entity_reference_label', - 'settings' => ['link' => TRUE], - 'region' => 'content', - ]; - $old_field_config = $view_display->getComponent($old_field_name); - if ($old_field_config) { - $new_field_config['weight'] = $old_field_config['weight']; - $view_display->removeComponent($old_field_name); - } - $view_display->setComponent($new_field_name, $new_field_config); - $view_display->save(); - } - - // Delete the old field. - try { - $old_field->delete(); - } - catch (Exception $exception) { - watchdog_exception('tide_media', $exception); - } - } -} - -/** - * Video transcript field change from text field to WYSIWYG. - */ -function tide_media_update_8006() { - $entity_type = 'media'; - $field_name = 'field_media_transcript'; - $field_storage = FieldStorageConfig::loadByName($entity_type, $field_name); - - if (is_null($field_storage)) { - return; - } - - $database = Drupal::database(); - $line_breaks = [ - "\r\n", - "\n", - "\r", - ]; - $br = "
"; - // Step1 create two temporary tables for holding data. - $tmp_table_names = [ - 'tmp_table' => 'media__field_media_transcript', - 'tmp_revision_table' => 'media_revision__field_media_transcript', - ]; - $spec = [ - 'type' => 'text', - 'size' => 'big', - 'not null' => FALSE, - ]; - - foreach ($tmp_table_names as $tmp => $table_name) { - if ($database->schema()->tableExists($table_name)) { - $database->query("CREATE TABLE {$tmp} SELECT * FROM {$table_name}"); - $database->truncate($table_name)->execute(); - $database->schema()->addField($table_name, 'field_media_transcript_format', $spec); - } - } - - // Step2 update field config from string_long to text_long. - // Update FieldStorageConfig. - $new_field_storage = $field_storage->toArray(); - $new_field_storage['type'] = 'text_long'; - $new_field_storage['module'] = 'text'; - $new_field_storage = FieldStorageConfig::create($new_field_storage); - $new_field_storage->original = $new_field_storage; - $new_field_storage->enforceIsNew(FALSE); - $new_field_storage->save(); - - // Update field. - foreach ($field_storage->getBundles() as $bundle => $label) { - $field = FieldConfig::loadByName($entity_type, $bundle, $field_name); - $new_field = $field->toArray(); - $new_field['field_type'] = 'text_long'; - $new_field = FieldConfig::create($new_field); - $new_field->original = $field; - $new_field->enforceIsNew(FALSE); - $new_field->save(); - } - - // Step 3 data migration. - foreach ($tmp_table_names as $tmp => $table_name) { - $database->schema()->addField($tmp, 'field_media_transcript_format', $spec); - $database->update($tmp) - ->fields(['field_media_transcript_format' => 'rich_text']) - ->execute(); - $database->insert($table_name)->from($database->select($tmp, 't') - ->fields('t'))->execute(); - foreach ($line_breaks as $line_break) { - $database->update($table_name)->expression('field_media_transcript_value', "REPLACE(field_media_transcript_value,:line_break,:br)", [ - ':line_break' => $line_break, - ':br' => $br, - ])->execute(); - } - $database->schema()->dropTable($tmp); - } - drupal_flush_all_caches(); -} - -/** - * Enable the field_media_site field in form_display of all media bundles. - */ -function tide_media_update_8007() { - if (!\Drupal::moduleHandler()->moduleExists('tide_site')) { - return; - } - // Default settings. - $default_option = [ - 'type' => 'options_buttons', - 'region' => 'content', - 'settings' => [], - 'third_party_settings' => [], - ]; - $bundle_info_service = \Drupal::service('entity_type.bundle.info'); - $entity_form_display_storage = \Drupal::entityTypeManager() - ->getStorage('entity_form_display'); - $media_bundles = $bundle_info_service->getBundleInfo('media'); - if (!empty($media_bundles) && is_array($media_bundles)) { - // Enable the field in form_display of all media bundles. - foreach ($media_bundles as $name => $options) { - /** @var \Drupal\Core\Entity\Entity\EntityFormDisplay $entity_form_display */ - $entity_form_display = $entity_form_display_storage->load('media.' . $name . '.default'); - $entity_form_display->setComponent('field_media_site', $default_option); - $entity_form_display->save(); - } - } -} - -/** - * Updating name filter operator for tide image_browser. - */ -function tide_media_update_8008() { - $config_factory = \Drupal::configFactory(); - $config = $config_factory->getEditable('views.view.tide_media_browser'); - $display = $config->get('display'); - - // Checking for correct display in view. - if (!empty($display) && $display['image_browser']['id'] == 'image_browser') { - $name_filter_operator = $display['image_browser']['display_options']['filters']['name']['operator']; - // Making sure the operator is not empty. - if ($name_filter_operator && !empty($name_filter_operator)) { - $operator = 'display.image_browser.display_options.filters.name'; - $config->set($operator . '.operator', 'contains'); - $config->save(); - } - } -} - -/** - * Allowing standalone media URLs. - */ -function tide_media_update_8009() { - $config_factory = \Drupal::configFactory(); - $media_config = $config_factory->getEditable('media.settings'); - $media_config->set('standalone_url', TRUE); - $media_config->save(); -} - -/** - * Set tide_media icon as base64 encoded file. - */ -function tide_media_update_8010() { - $config_factory = \Drupal::configFactory(); - $media_config = $config_factory->getEditable('embed.button.tide_media'); - $media_config->set('icon.data', 'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAYJGlDQ1BJQ0MgUHJvZmlsZQAAWIWVeQdUFE2zds/MJnaJS84gGSXnnHOUHJUl57DkrIiogKAoWUliQgQDkkQQUFFExYBiQAmiYkRAFCTcIej73ff+57/n9p7peba6uvrpruqeqV0AuDkokZGhMCMAYeExVDsTfQEXVzcB/BtAAjTohxGIU3yiI/VsbS0BWv7c/3uZfwqgtftjqTVb/7P9/1uYfP2ifQCAbFHs7RvtE4biJgAwXD6R1BgAsIOoXCg+JnINz6GYhYoSBABHWMMBG5hnDXtvYNl1HQc7AxQbAkCgpVCoAQDQr9kXiPMJQO3QR6Jt5HDfoHBUNRPF2j6BFF8AuG6gOtvCwiLW8DSKxb3/w07Af7Pp/dcmhRLwF2/MZb0QDIOiI0Mpif/H5fjfS1ho7J8xtqAXbSDV1G5tzui6nQmJsFjDtCjuCPe2tkExGcW3g3zX9dfwi8BYU8dN/c8+0QbomgE2AGDgSzG0QDG6ljBbbIij3iaWp1DX+6L6sHVQjJnDJvamRtht2ofjwkOtLTft7A/0M/uDK/yijez/6PgHGZuhGI00uCkp0MF5gyd8Iy7IyRrF9CgejA6xt9js+zop0MD6jw411m6NszCK5/ypxnYbOghHWPSfeSHSPpT1sThQrBsT6GC60Rdx8Yt2sfzDwdfP0GiDA+LrF+64yQ1Bo0vfbrNvVmSo7aY+UuEXamK3sc7Iheg4+z99H8WgAbaxDsh4MMXcdoM/Mh8ZY+uwwQ2DAZbAABgCARCLXt4gAgSDoPufW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z4KICAgICAgICAgPC9kYzpzdWJqZWN0PgogICAgICAgICA8eG1wOk1vZGlmeURhdGU+MjAxNToxMToxMCAxMjoxMTo0NDwveG1wOk1vZGlmeURhdGU+CiAgICAgICAgIDx4bXA6Q3JlYXRvclRvb2w+UGl4ZWxtYXRvciAzLjQ8L3htcDpDcmVhdG9yVG9vbD4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CsT0zU0AAAIVSURBVDgRjVNNS2JhFPbeq04t/BpoEZOBJWIkrVwYs8gfMLgwSAh3AxYxEbQJWiVBi3ZBILNtZikym1m7VnAxQ5SgG1cuxK8SB7/neS694o3rrQPH93w853nPPe9RMb0hPp9vzQ5ptVptI6hslIxEIrbxeJyWJOlnOBxeMMIqRkmLxbI3GAyOQLTa7/f/1Gq1h3n4uR0lEglLr9dLiEIQHTMm/NenUUe73W73FAUSiyaTibvZbN5Xq1XdrqZEAEqNRmMJNSvBYDBSr9ev0YWdJC8imc3mz6FQqOlwOLrRaFTO5XL/ksmkmpa8Xu+m1Wr9hllsyLLsHY1GdpDaoIJAc2JeJuizoihPeIgy5viIC2/NMLYxi0OiQaIp0nN4AS8CiQ2En1C7g0YKMlq7w5qk9IreE3M6nal0On2nDrJUKn2IxWI37Xb7YN4nvSblJ2JW3wuFwgnsnkpEEAgUv99/MRwOz2HPXQtiUTjG4K+KxeIFbHUe0wIGMpnMJWam+7wkEEIMsYKE8SkRnXw+L2OIb06cGGJZI2S6Rwxg4ZY7nc4ZgIsCoHdiTazlcvlHpVJ5EnkNKwDrWAGnSKJ1E2Kq0hZCDLHC56khQjdrKFBjLIT+crvdX6i0GaPglIlVnZcfDRE+7SOfHwv21+Vy7cfj8d1sNvubSpsx5oghdpZIY3s8nq1AIPAV/3KHJjHjMEcMsTNh038wIuU96QNsXAAAAABJRU5ErkJggg=='); - $media_config->set('icon.uri', 'public://embed_buttons/star.png'); - $media_config->save(); -} - -/** - * Clean up videos and its config. - */ -function tide_media_update_8011() { - $storage_handler = \Drupal::entityTypeManager()->getStorage('media'); - $videos = $storage_handler->loadByProperties(['bundle' => 'video']); - if ($videos) { - $storage_handler->delete($videos); - } - $type = \Drupal::entityTypeManager()->getStorage('media_type')->load('video'); - if ($type) { - $type->delete(); - } -} - -/** - * Patch for sites that do not have field_media_site attached. - */ -function tide_media_update_8012() { - if (!\Drupal::moduleHandler()->moduleExists('tide_site')) { - return; - } - - $entity_type = 'media'; - $field_name = 'field_media_site'; - $field_storage = FieldStorageConfig::loadByName($entity_type, $field_name); - - if (is_null($field_storage)) { - return; - } - // Default settings. - $default_option = [ - 'type' => 'options_buttons', - 'region' => 'content', - 'settings' => [], - 'third_party_settings' => [], - ]; - $bundle_info_service = \Drupal::service('entity_type.bundle.info'); - $entity_form_display_storage = \Drupal::entityTypeManager() - ->getStorage('entity_form_display'); - $media_bundles = $bundle_info_service->getBundleInfo('media'); - if (!empty($media_bundles) && is_array($media_bundles)) { - // Enable the field in form_display of all media bundles. - foreach ($media_bundles as $name => $options) { - $field = FieldConfig::loadByName($entity_type, $name, $field_name); - if (empty($field)) { - $field = FieldConfig::create([ - 'field_storage' => $field_storage, - 'bundle' => $name, - 'label' => 'Site', - ]); - $field->save(); - } - - /** @var \Drupal\Core\Entity\Entity\EntityFormDisplay $entity_form_display */ - $entity_form_display = $entity_form_display_storage->load('media.' . $name . '.default'); - $entity_form_display->setComponent('field_media_site', $default_option); - $entity_form_display->save(); - } - } -} - -/** - * Clean up video options from entity browsers. - */ -function tide_media_update_8013() { - $browsers = \Drupal::entityTypeManager()->getStorage('entity_browser')->loadMultiple(); - foreach ($browsers as $browser) { - $widget_collection = $browser->getWidgets()->getConfiguration(); - foreach ($widget_collection as $id => $item) { - if (isset($item['settings']['bundle']) && $item['settings']['bundle'] == 'video') { - $widget = $browser->getWidget($id); - $browser->deleteWidget($widget); - $browser->save(); - } - } - } -} - -/** - * Enable Focal Point with default config. - */ -function tide_media_update_8014() { - if (!\Drupal::moduleHandler()->moduleExists('focal_point')) { - /** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */ - $module_installer = \Drupal::service('module_installer'); - $module_installer->install(['crop']); - $module_installer->install(['focal_point']); - // Updating existing seetings to use focal point. - // Add focal point to field_media_image in display form. - $config = \Drupal::configFactory()->getEditable('core.entity_form_display.media.image.default'); - // Updating config dependencies. - $config_dependencies = $config->get('dependencies.config'); - $config_dependencies[] = 'image.style.large'; - $config->set('dependencies.config', $config_dependencies); - // Updating module dependencies. - $module = $config->get('dependencies.module'); - $module[] = 'focal_point'; - $config->set('dependencies.module', $module); - // Adding new field settings. - $media_image_settings = $config->get('content.field_media_image.settings'); - $media_image_settings['preview_image_style'] = 'large'; - $media_image_settings['offsets'] = '50,50'; - $config->set('content.field_media_image.settings', $media_image_settings); - $config->set('content.field_media_image.type', 'image_focal_point'); - $config->save(); - - // Load the thumbnail image style. - $thumbnail = ImageStyle::load('thumbnail'); - - // Create effect. - $configuration = [ - 'uuid' => NULL, - 'id' => 'focal_point_scale_and_crop', - 'weight' => -1, - 'data' => [ - 'width' => 100, - 'height' => 100, - 'crop_type' => 'focal_point', - ], - ]; - $effect = \Drupal::service('plugin.manager.image.effect')->createInstance($configuration['id'], $configuration); - if ($thumbnail) { - // Add it to the image style and save. - $thumbnail->addImageEffect($effect->getConfiguration()); - $thumbnail->save(); - } - - // Set the image enhancer for field_media_image field. - $config = \Drupal::configFactory()->getEditable('jsonapi_extras.jsonapi_resource_config.media--image'); - $config->set('resourceFields.field_media_image.enhancer.id', 'image_enhancer'); - $config->save(); - } -} - -/** - * Migrates field_paragraph_summary to field_paragraph_body. - */ -function tide_media_update_8036(&$sandbox) { - $wysiwyg = 'field_paragraph_body'; - if (!isset($sandbox['total'])) { - $count = \Drupal::entityTypeManager() - ->getStorage('paragraph') - ->getQuery() - ->condition('type', 'timeline') - ->count() - ->execute(); - $sandbox['total'] = $count; - $sandbox['current'] = 0; - $sandbox['processed'] = 0; - $sandbox['#finished'] = $count ? 0 : 1; - } - $batch_size = 10; - $paragraph_ids = \Drupal::entityTypeManager() - ->getStorage('paragraph') - ->getQuery() - ->condition('id', $sandbox['current'], '>') - ->condition('type', 'timeline') - ->sort('id', 'ASC') - ->range(0, $batch_size) - ->execute(); - foreach ($paragraph_ids as $paragraph_id) { - $sandbox['current'] = $paragraph_id; - $paragraph = Paragraph::load($paragraph_id); - if ($paragraph && $paragraph->hasField($wysiwyg) && $paragraph->hasField('field_paragraph_summary')) { - $paragraph->{$wysiwyg}->value = $paragraph->field_paragraph_summary->value; - $paragraph->{$wysiwyg}->format = 'summary_text'; - $paragraph->setNewRevision(FALSE); - $paragraph->save(); - } - $sandbox['processed']++; - } - $sandbox['#finished'] = $sandbox['total'] ? $sandbox['processed'] / $sandbox['total'] : 1; - $sandbox['#finished'] = $sandbox['#finished'] > 1 ? 1 : $sandbox['#finished']; -} - -/** - * Updates the entity_form_display and sets a default format. - */ -function tide_media_update_8037() { - $entity_form_display = Drupal::entityTypeManager() - ->getStorage('entity_form_display') - ->load('paragraph.timeline.default'); - if ($entity_form_display) { - $entity_form_display->setComponent('field_paragraph_body', [ - 'weight' => 10, - 'settings' => ['rows' => 5, 'placeholder' => ''], - 'third_party_settings' => [], - 'type' => 'text_textarea', - 'region' => 'content', - ]); - $hidden = $entity_form_display->get('hidden'); - $hidden['field_paragraph_summary'] = TRUE; - $entity_form_display->set('hidden', $hidden); - $entity_form_display->save(); - } - - $entity_form_display_config = \Drupal::configFactory() - ->getEditable('core.entity_form_display.paragraph.timeline.default'); - $content = $entity_form_display_config->get('content'); - if (isset($content['field_paragraph_summary'])) { - unset($content['field_paragraph_summary']); - } - $entity_form_display_config->set('content', $content)->save(); - - $field_timeline_body = \Drupal::configFactory() - ->getEditable('field.field.paragraph.timeline.field_paragraph_body'); - $settings = $field_timeline_body->get('third_party_settings'); - if (isset($settings['allowed_formats']['summary_text'])) { - $settings['allowed_formats']['summary_text'] = 'summary_text'; - } - else { - $settings['allowed_formats'] = array_merge($settings['allowed_formats'], ['summary_text' => 'summary_text']); - } - $field_timeline_body->set('label', 'Summary'); - $field_timeline_body->set('third_party_settings', $settings)->save(); -} - -/** - * Update tide_media_browser view with filemime field. - */ -function tide_media_update_8038() { - // Get the new configs. - $view = 'views.view.tide_media_browser'; - $config_path = \Drupal::service('extension.list.module')->getPath('tide_media') . '/config/install'; - $source = new FileStorage($config_path); - if ($view) { - $module_dependencies = $source->read($view)['dependencies']['module']; - $document_browser_display_options = $source->read($view)['display']['document_browser']['display_options']; - $media_browser_display_options = $source->read($view)['display']['media_browser']['display_options']; - // Set the new configs in sync. - $view_tide_media_browser = \Drupal::configFactory() - ->getEditable('views.view.tide_media_browser'); - $view_tide_media_browser->set('dependencies.module', $module_dependencies) - ->save(); - $view_tide_media_browser->set('display.document_browser.display_options', $document_browser_display_options) - ->save(); - $view_tide_media_browser->set('display.media_browser.display_options', $media_browser_display_options) - ->save(); - } -} - -/** - * Change description and icon of timelines paragraph. - */ -function tide_media_update_8039() { - module_load_include('inc', 'tide_core', 'includes/helpers'); - $icon_dir = \Drupal::service('extension.list.module')->getPath('tide_media') . DIRECTORY_SEPARATOR . 'icons'; - - $paragraphs = [ - 'timelines' => 'Display short blocks of content in a chronological order.', - ]; - foreach ($paragraphs as $paragraph_type_id => $description) { - /** @var \Drupal\paragraphs\Entity\ParagraphsType $paragraph_type */ - $paragraph_type = ParagraphsType::load($paragraph_type_id); - if ($paragraph_type) { - $paragraph_type->set('description', $description); - $paragraph_type->save(); - - $icon_filename = $icon_dir . DIRECTORY_SEPARATOR . $paragraph_type_id . '.svg'; - _tide_set_paragraph_type_icon($paragraph_type, $icon_filename); - } - } -} - -/** - * Enables entity_usage module. - */ -function tide_media_update_8040() { - TideOperation::tideMediaInstallModule('entity_usage'); - TideOperation::entityUsageDefaultSettings(); -} - -/** - * Updates to have new field_is_streamed field. - */ -function tide_media_update_8041() { - $configs = [ - 'field.storage.media.field_is_streamed' => 'field_storage_config', - 'field.field.media.embedded_video.field_is_streamed' => 'field_config', - ]; - module_load_include('inc', 'tide_core', 'includes/helpers'); - $config_location = [\Drupal::service('extension.list.module')->getPath('tide_media') . '/config/install']; - // Check if field already exported to config/sync. - foreach ($configs as $config => $type) { - $config_read = _tide_read_config($config, $config_location, TRUE); - $storage = \Drupal::entityTypeManager()->getStorage($type); - $id = substr($config, strrpos($config, '.') + 1); - if ($storage->load($id) == NULL) { - $config_entity = $storage->createFromStorageRecord($config_read); - $config_entity->save(); - } - } - $update_configs = [ - 'field.field.media.embedded_video.field_media_transcript' => 'field_config', - 'core.entity_view_display.media.embedded_video.default' => 'entity_view_display', - 'core.entity_form_display.media.embedded_video.default' => 'entity_form_display', - ]; - $skipped_settings = [ - 'uuid', - 'langcode', - 'status', - '_core', - 'id', - 'field_name', - 'entity_type', - 'bundle', - 'label', - 'description', - 'required', - 'translatable', - 'field_type', - ]; - foreach ($update_configs as $update_config => $type) { - $config_read = _tide_read_config($update_config, $config_location, FALSE); - $config = \Drupal::configFactory()->getEditable($update_config); - if (!$config) { - continue; - } - $data = $config->getRawData(); - foreach ($config_read as $key => $item) { - if (in_array($key, $skipped_settings)) { - continue; - } - NestedArray::setValue($data, [ - $key, - ], NestedArray::getValue($config_read, [ - $key, - ])); - } - $config->setData($data)->save(); - } -} - -/** - * Update filter operator on document and video pickers [SDPSUP-3966]. - */ -function tide_media_update_8042() { - $views_config = \Drupal::configFactory()->getEditable('views.view.tide_media_browser'); - $views_config->set('display.document_browser.display_options.filters.name.operator', 'contains'); - $views_config->set('display.embedded_video_browser.display_options.filters.name.operator', 'contains'); - $views_config->save(); -} - -/** - * Updates with new field_metatags_rtl field. - */ -function tide_media_update_8043() { - $configs = [ - 'field.storage.media.field_metatags_rtl' => 'field_storage_config', - 'field.field.media.embedded_video.field_metatags_rtl' => 'field_config', - ]; - module_load_include('inc', 'tide_core', 'includes/helpers'); - $config_location = [\Drupal::service('extension.list.module')->getPath('tide_media') . '/config/install']; - // Check if field already exported to config/sync. - foreach ($configs as $config => $type) { - $config_read = _tide_read_config($config, $config_location, TRUE); - $storage = \Drupal::entityTypeManager()->getStorage($type); - $id = substr($config, strrpos($config, '.') + 1); - if ($storage->load($id) == NULL) { - $config_entity = $storage->createFromStorageRecord($config_read); - $config_entity->save(); - } - } - $update_configs = [ - 'core.entity_view_display.media.embedded_video.default' => 'entity_view_display', - 'core.entity_form_display.media.embedded_video.default' => 'entity_form_display', - ]; - $config_settings = [ - 'dependencies', - 'content', - 'hidden', - ]; - foreach ($update_configs as $update_config => $type) { - $config_read = _tide_read_config($update_config, $config_location, FALSE); - $config = \Drupal::configFactory()->getEditable($update_config); - if (!$config) { - continue; - } - $data = $config->getRawData(); - foreach ($config_read as $key => $item) { - if (in_array($key, $config_settings)) { - NestedArray::setValue($data, [ - $key, - ], NestedArray::getValue($config_read, [ - $key, - ])); - } - } - $config->setData($data)->save(); - } -} - -/** - * Add current milestone field to timeline component. - */ -function tide_media_update_8044() { - $config = 'field.field.paragraph.timeline.field_current_milestone'; - module_load_include('inc', 'tide_core', 'includes/helpers'); - $config_location = [\Drupal::service('extension.list.module')->getPath('tide_media') . '/config/install']; - // Check if field already exported to config/sync. - $config_read = _tide_read_config($config, $config_location, TRUE); - $storage = \Drupal::entityTypeManager()->getStorage('field_config'); - $config_entity = $storage->createFromStorageRecord($config_read); - $config_entity->save(); - // Update existed displays. field and json. - $config_ids = [ - 'core.entity_form_display.paragraph.timeline.default' => 'display', - 'core.entity_view_display.paragraph.timeline.default' => 'display', - 'field.field.paragraph.timeline.field_paragraph_title' => 'field', - 'jsonapi_extras.jsonapi_resource_config.paragraph--timeline' => 'json', - ]; - foreach ($config_ids as $config_id => $type) { - $existed_config = \Drupal::configFactory()->getEditable($config_id); - $new_config_read = _tide_read_config($config_id, $config_location, FALSE); - if ($type == 'display') { - $fields_settings = $new_config_read['content']; - $dependencies = $new_config_read['dependencies']['config']; - if ($existed_config) { - $existed_config->set('content', $fields_settings); - $existed_config->set('dependencies.config', $dependencies); - $existed_config->save(); - } - } - if ($type == 'field') { - $field_title_label = $new_config_read['label']; - if ($existed_config) { - $existed_config->set('label', $field_title_label); - $existed_config->save(); - } - } - if ($type == 'json') { - $json_resourceFields = $new_config_read['resourceFields']; - if ($existed_config) { - $existed_config->set('resourceFields', $json_resourceFields); - $existed_config->save(); - } - } - } -} - -/** - * Remove the "Restricted" tickbox in media items. - */ -function tide_media_update_8045() { - $entityFieldManager = Drupal::service('entity_field.manager'); - $mediaBundles = [ - 'audio', - 'document', - 'embedded_video', - 'file', - 'image', - ]; - - foreach ($mediaBundles as $bundle) { - $fields = $entityFieldManager->getFieldDefinitions('media', $bundle); - - if (isset($fields['field_media_restricted'])) { - $fields['field_media_restricted']->delete(); - } - } + TideOperation::assignNecessaryPermissions(); + TideOperation::createLicenseTypeTerms(); } /** * Updates to have department field required. */ -function tide_media_update_8046() { +function tide_media_update_10001() { $entity_type = 'media'; $media_bundles = \Drupal::service('entity_type.bundle.info')->getBundleInfo($entity_type); $bundles = [ @@ -873,62 +45,9 @@ function tide_media_update_8046() { } } -/** - * Update views.view.tide_media_browser. - */ -function tide_media_update_8047() { - \Drupal::moduleHandler()->loadInclude('tide_core', 'inc', 'includes/helpers'); - $config_location = [\Drupal::service('extension.list.module')->getPath('tide_media') . '/config/install']; - $config_read = _tide_read_config('views.view.tide_media_browser', $config_location, FALSE); - $view_tide_media_browser = \Drupal::configFactory()->getEditable('views.view.tide_media_browser'); - $view_tide_media_browser->set('display.media_browser.display_options.fields.thumbnail__target_id.alter', $config_read['display']['media_browser']['display_options']['fields']['thumbnail__target_id']['alter'])->save(); - $view_tide_media_browser->set('display.document_browser.display_options.fields.thumbnail__target_id.alter', $config_read['display']['document_browser']['display_options']['fields']['thumbnail__target_id']['alter'])->save(); -} - -/** - * Update views.view.media. - */ -function tide_media_update_8048() { - \Drupal::moduleHandler()->loadInclude('tide_core', 'inc', 'includes/helpers'); - $config_location = [\Drupal::service('extension.list.module')->getPath('tide_media') . '/config/optional']; - $storage = \Drupal::entityTypeManager()->getStorage('view'); - $config_entity = $storage->load('media'); - if ($config_entity !== NULL) { - $storage->delete([$config_entity]); - } - $config_read = _tide_read_config('views.view.media', $config_location, FALSE); - $new_config_entity = $storage->createFromStorageRecord($config_read); - $new_config_entity->save(); -} - -/** - * Creates terms for license_type vocabulary. - */ -function _tide_media_create_license_type_terms() { - $terms = [ - 'Copyright', - 'Creative Commons Attribution 4.0', - ]; - foreach ($terms as $term) { - $result = \Drupal::entityTypeManager() - ->getStorage('taxonomy_term') - ->loadByProperties([ - 'name' => $term, - 'vid' => 'license_type', - ]); - if (empty($result)) { - Term::create([ - 'name' => $term, - 'vid' => 'license_type', - 'parent' => [], - ])->save(); - } - } -} - /** * Creates terms for license_type vocabulary for installed site. */ -function tide_media_update_8049() { - _tide_media_create_license_type_terms(); +function tide_media_update_10002() { + TideOperation::createLicenseTypeTerms(); } diff --git a/tide_media.module b/tide_media.module index a00c4a1..9ee7eaf 100644 --- a/tide_media.module +++ b/tide_media.module @@ -177,7 +177,7 @@ function tide_media_preprocess_file_link(&$variables) { $config = \Drupal::config('tide_media.settings'); if ($config->get('file_absolute_url')) { - $url = file_create_url($file->getFileUri()); + $url = \Drupal::service('file_url_generator')->generateAbsoluteString($file->getFileUri()); if ($config->get('force_https')) { $url = str_replace('http://', 'https://', $url); } @@ -289,7 +289,7 @@ function tide_media_preprocess_image(&$variables) { if (!empty($variables['uri'])) { $config = \Drupal::config('tide_media.settings'); if ($config->get('file_absolute_url')) { - $variables['attributes']['src'] = file_create_url($variables['uri']); + $variables['attributes']['src'] = \Drupal::service('file_url_generator')->generateAbsoluteString($variables['uri']); if ($config->get('force_https')) { $variables['attributes']['src'] = str_replace('http://', 'https://', $variables['attributes']['src']); } diff --git a/tide_media.routing.permissions.yml b/tide_media.routing.permissions.yml new file mode 100644 index 0000000..b62a4f1 --- /dev/null +++ b/tide_media.routing.permissions.yml @@ -0,0 +1,15 @@ +'access tide_embedded_video_browser entity browser pages': + title: 'Access tide_embedded_video_browser entity browser pages' + description: 'Allows user to access tide_embedded_video_browser entity browser pages' +'access tide_document_browser entity browser pages': + title: 'Access tide_document_browser entity browser pages': + description: 'Allow user to access tide_document_browser entity browser pages': +'access tide_image_browser entity browser pages': + title: 'Access tide_image_browser entity browser pages': + description: 'Allow user to access tide_image_browser entity browser pages': +'access tide_media_browser entity browser pages': + title: 'Access tide_media_browser entity browser pages': + description: 'Allow user to access tide_media_browser entity browser pages': +'access tide_media_browser_iframe entity browser pages': + title: 'Access tide_media_browser_iframe entity browser pages': + description: 'Allow user to access tide_media_browser_iframe entity browser pages':