diff --git a/README.md b/README.md index 2d01077d..16f22acb 100644 --- a/README.md +++ b/README.md @@ -231,3 +231,4 @@ an Islandora Foundation [Contributor License Agreement][5] or [5]: http://islandora.ca/sites/default/files/islandora_cla.pdf [6]: http://islandora.ca/sites/default/files/islandora_ccla.pdf [7]: http://islandora.ca/resources/contributors + diff --git a/composer.json b/composer.json index a00fcff6..1923cff9 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,6 @@ "drupal/migrate_plus" : "4.0-beta3", "drupal/migrate_tools" : "4.0-beta3", "drupal/migrate_source_csv" : "^2.1", - "drupal/permissions_by_term" : "^1.51", "drupal/token" : "^1.3", "drupal/flysystem" : "^1.0", "islandora/chullo" : "dev-master" diff --git a/config/install/system.action.delete_media.yml b/config/install/system.action.delete_media.yml index c90edea0..c95e8423 100644 --- a/config/install/system.action.delete_media.yml +++ b/config/install/system.action.delete_media.yml @@ -5,9 +5,9 @@ dependencies: module: - islandora module: - - media + - islandora id: delete_media label: 'Delete media' -type: media -plugin: delete_media +type: media +plugin: delete_media configuration: { } diff --git a/config/install/system.action.delete_media_and_file.yml b/config/install/system.action.delete_media_and_file.yml index c0012c24..f5e4da88 100644 --- a/config/install/system.action.delete_media_and_file.yml +++ b/config/install/system.action.delete_media_and_file.yml @@ -5,9 +5,9 @@ dependencies: module: - islandora module: - - media + - islandora id: delete_media_and_file label: 'Delete media and file(s)' -type: media -plugin: delete_media_and_file +type: media +plugin: delete_media_and_file configuration: { } diff --git a/islandora.services.yml b/islandora.services.yml index 12bbbdb7..6f6b85c7 100644 --- a/islandora.services.yml +++ b/islandora.services.yml @@ -47,7 +47,7 @@ services: - { name: 'context_provider' } islandora.media_source_service: class: Drupal\islandora\MediaSource\MediaSourceService - arguments: ['@entity_type.manager', '@current_user', '@language_manager', '@entity.query', '@file_system'] + arguments: ['@entity_type.manager', '@current_user', '@language_manager', '@entity.query', '@file_system', '@islandora.utils'] islandora.utils: class: Drupal\islandora\IslandoraUtils arguments: ['@entity_type.manager', '@entity_field.manager', '@entity.query', '@context.manager', '@flysystem_factory'] diff --git a/migrate/tags.csv b/migrate/tags.csv index 6f54f3db..d7766c44 100644 --- a/migrate/tags.csv +++ b/migrate/tags.csv @@ -1,9 +1,13 @@ vid,name,description,external_uri -tags,"Preservation Master","Best quality representation of the Object appropriate for long-term preservation",http://pcdm.org/use#PreservationMasterFile -tags,"Service File","A medium quality representation of the Object appropriate for serving to users",http://pcdm.org/use#ServiceFile -tags,"Thumbnail","A low resolution image representation of the Object appropriate for using as an icon",http://pcdm.org/use#ThumbnailImage -tags,"Audio","A resource primarily intended to be heard. Examples include a music playback file format, an audio compact disc, and recorded speech or sounds",http://purl.org/coar/resource_type/c_18cc -tags,"Binary","A generic binary file for repository items that don't fall into any other category or cannot be shown in a browser",http://purl.org/coar/resource_type/c_1843 -tags,"Collection","A collection is an aggregation of items",http://purl.org/dc/dcmitype/Collection -tags,"Image","A visual representation other than text, including all types of moving image and still image",http://purl.org/coar/resource_type/c_c513 -tags,"Video","A recording of visual images, usually in motion and with sound accompaniment",http://purl.org/coar/resource_type/c_12ce +islandora_media_use,"Extracted Text","A textual representation of the Object appropriate for fulltext indexing, such as a plaintext version of a document, or OCR text",http://pcdm.org/use#ExtractedText +islandora_media_use,"Intermediate File","High quality representation of the Object, appropriate for generating derivatives or other additional processing",http://pcdm.org/use#IntermediateFile +islandora_media_use,"Original File","The original creation format of a file",http://pcdm.org/use#OriginalFile +islandora_media_use,"Preservation Master File","Best quality representation of the Object appropriate for long-term preservation",http://pcdm.org/use#PreservationMasterFile +islandora_media_use,"Service File","A medium quality representation of the Object appropriate for serving to users",http://pcdm.org/use#ServiceFile +islandora_media_use,"Thumbnail Image","A low resolution image representation of the Object appropriate for using as an icon",http://pcdm.org/use#ThumbnailImage +islandora_media_use,"Transcript","A textual representation of the Object appropriate for presenting to users, such as subtitles or transcript of a video. Can be used as a substitute or complement to other files for accessibility purposes",http://pcdm.org/use#Transcript +islandora_models,"Audio","A resource primarily intended to be heard. Examples include a music playback file format, an audio compact disc, and recorded speech or sounds",http://purl.org/coar/resource_type/c_18cc +islandora_models,"Binary","A generic binary file for repository items that don't fall into any other category or cannot be shown in a browser",http://purl.org/coar/resource_type/c_1843 +islandora_models,"Collection","A collection is an aggregation of items",http://purl.org/dc/dcmitype/Collection +islandora_models,"Image","A visual representation other than text, including all types of moving image and still image",http://purl.org/coar/resource_type/c_c513 +islandora_models,"Video","A recording of visual images, usually in motion and with sound accompaniment",http://purl.org/coar/resource_type/c_12ce diff --git a/modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.changed.yml b/modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.changed.yml deleted file mode 100644 index bf6c10b9..00000000 --- a/modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.changed.yml +++ /dev/null @@ -1,17 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - taxonomy.vocabulary.tags -id: taxonomy_term.tags.changed -field_name: changed -entity_type: taxonomy_term -bundle: tags -label: Changed -description: 'The time that the term was last edited.' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: changed diff --git a/modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.description.yml b/modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.description.yml deleted file mode 100644 index 6dadd51c..00000000 --- a/modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.description.yml +++ /dev/null @@ -1,19 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - taxonomy.vocabulary.tags - module: - - text -id: taxonomy_term.tags.description -field_name: description -entity_type: taxonomy_term -bundle: tags -label: Description -description: '' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: text_long diff --git a/modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.name.yml b/modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.name.yml deleted file mode 100644 index cee26973..00000000 --- a/modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.name.yml +++ /dev/null @@ -1,17 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - taxonomy.vocabulary.tags -id: taxonomy_term.tags.name -field_name: name -entity_type: taxonomy_term -bundle: tags -label: Name -description: '' -required: true -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: string diff --git a/modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.path.yml b/modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.path.yml deleted file mode 100644 index 05bbe86a..00000000 --- a/modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.path.yml +++ /dev/null @@ -1,19 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - taxonomy.vocabulary.tags - module: - - path -id: taxonomy_term.tags.path -field_name: path -entity_type: taxonomy_term -bundle: tags -label: 'URL alias' -description: '' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: path diff --git a/modules/islandora_core_feature/config/install/core.entity_view_display.media.audio.source.yml b/modules/islandora_core_feature/config/install/core.entity_view_display.media.audio.source.yml index 033b3f64..b305bc80 100644 --- a/modules/islandora_core_feature/config/install/core.entity_view_display.media.audio.source.yml +++ b/modules/islandora_core_feature/config/install/core.entity_view_display.media.audio.source.yml @@ -6,8 +6,8 @@ dependencies: - field.field.media.audio.field_file_size - field.field.media.audio.field_media_audio_file - field.field.media.audio.field_media_of + - field.field.media.audio.field_media_use - field.field.media.audio.field_mime_type - - field.field.media.audio.field_tags - media.type.audio enforced: module: @@ -34,8 +34,8 @@ hidden: created: true field_file_size: true field_media_of: true + field_media_use: true field_mime_type: true - field_tags: true langcode: true name: true thumbnail: true diff --git a/modules/islandora_core_feature/config/install/core.entity_view_display.media.file.source.yml b/modules/islandora_core_feature/config/install/core.entity_view_display.media.file.source.yml index 3c646ecd..e6718127 100644 --- a/modules/islandora_core_feature/config/install/core.entity_view_display.media.file.source.yml +++ b/modules/islandora_core_feature/config/install/core.entity_view_display.media.file.source.yml @@ -6,8 +6,8 @@ dependencies: - field.field.media.file.field_file_size - field.field.media.file.field_media_file - field.field.media.file.field_media_of + - field.field.media.file.field_media_use - field.field.media.file.field_mime_type - - field.field.media.file.field_tags - media.type.file enforced: module: @@ -31,8 +31,8 @@ hidden: created: true field_file_size: true field_media_of: true + field_media_use: true field_mime_type: true - field_tags: true langcode: true name: true thumbnail: true diff --git a/modules/islandora_core_feature/config/install/core.entity_view_display.media.image.source.yml b/modules/islandora_core_feature/config/install/core.entity_view_display.media.image.source.yml index b32541c6..e205f5a5 100644 --- a/modules/islandora_core_feature/config/install/core.entity_view_display.media.image.source.yml +++ b/modules/islandora_core_feature/config/install/core.entity_view_display.media.image.source.yml @@ -7,8 +7,8 @@ dependencies: - field.field.media.image.field_height - field.field.media.image.field_media_image - field.field.media.image.field_media_of + - field.field.media.image.field_media_use - field.field.media.image.field_mime_type - - field.field.media.image.field_tags - field.field.media.image.field_width - media.type.image enforced: @@ -35,8 +35,8 @@ hidden: field_file_size: true field_height: true field_media_of: true + field_media_use: true field_mime_type: true - field_tags: true field_width: true langcode: true name: true diff --git a/modules/islandora_core_feature/config/install/core.entity_view_display.media.video.source.yml b/modules/islandora_core_feature/config/install/core.entity_view_display.media.video.source.yml index caf243b0..3b81c2ef 100644 --- a/modules/islandora_core_feature/config/install/core.entity_view_display.media.video.source.yml +++ b/modules/islandora_core_feature/config/install/core.entity_view_display.media.video.source.yml @@ -5,9 +5,9 @@ dependencies: - core.entity_view_mode.media.source - field.field.media.video.field_file_size - field.field.media.video.field_media_of + - field.field.media.video.field_media_use - field.field.media.video.field_media_video_file - field.field.media.video.field_mime_type - - field.field.media.video.field_tags - media.type.video enforced: module: @@ -37,8 +37,8 @@ hidden: created: true field_file_size: true field_media_of: true + field_media_use: true field_mime_type: true - field_tags: true langcode: true name: true thumbnail: true diff --git a/modules/islandora_core_feature/config/install/field.field.media.audio.field_media_use.yml b/modules/islandora_core_feature/config/install/field.field.media.audio.field_media_use.yml new file mode 100644 index 00000000..88f5be9c --- /dev/null +++ b/modules/islandora_core_feature/config/install/field.field.media.audio.field_media_use.yml @@ -0,0 +1,28 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.media.field_media_use + - media.type.audio + - taxonomy.vocabulary.islandora_media_use +id: media.audio.field_media_use +field_name: field_media_use +entity_type: media +bundle: audio +label: 'Media Use' +description: '' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: + handler: 'default:taxonomy_term' + handler_settings: + target_bundles: + islandora_media_use: islandora_media_use + sort: + field: name + direction: asc + auto_create: false + auto_create_bundle: '' +field_type: entity_reference diff --git a/modules/islandora_core_feature/config/install/field.field.media.audio.field_tags.yml b/modules/islandora_core_feature/config/install/field.field.media.audio.field_tags.yml deleted file mode 100644 index bd56c97d..00000000 --- a/modules/islandora_core_feature/config/install/field.field.media.audio.field_tags.yml +++ /dev/null @@ -1,23 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - field.storage.media.field_tags - - media.type.audio - enforced: - module: - - islandora_core_feature -id: media.audio.field_tags -field_name: field_tags -entity_type: media -bundle: audio -label: Tags -description: '' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: - handler: 'default:taxonomy_term' - handler_settings: { } -field_type: entity_reference diff --git a/modules/islandora_core_feature/config/install/field.field.media.file.field_media_use.yml b/modules/islandora_core_feature/config/install/field.field.media.file.field_media_use.yml new file mode 100644 index 00000000..85eab457 --- /dev/null +++ b/modules/islandora_core_feature/config/install/field.field.media.file.field_media_use.yml @@ -0,0 +1,28 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.media.field_media_use + - media.type.file + - taxonomy.vocabulary.islandora_media_use +id: media.file.field_media_use +field_name: field_media_use +entity_type: media +bundle: file +label: 'Media Use' +description: '' +required: false +translatable: true +default_value: { } +default_value_callback: '' +settings: + handler: 'default:taxonomy_term' + handler_settings: + target_bundles: + islandora_media_use: islandora_media_use + sort: + field: name + direction: asc + auto_create: false + auto_create_bundle: '' +field_type: entity_reference diff --git a/modules/islandora_core_feature/config/install/field.field.media.file.field_tags.yml b/modules/islandora_core_feature/config/install/field.field.media.file.field_tags.yml deleted file mode 100644 index 9841cbe4..00000000 --- a/modules/islandora_core_feature/config/install/field.field.media.file.field_tags.yml +++ /dev/null @@ -1,23 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - field.storage.media.field_tags - - media.type.file - enforced: - module: - - islandora_core_feature -id: media.file.field_tags -field_name: field_tags -entity_type: media -bundle: file -label: Tags -description: '' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: - handler: 'default:taxonomy_term' - handler_settings: { } -field_type: entity_reference diff --git a/modules/islandora_core_feature/config/install/field.field.media.image.field_media_use.yml b/modules/islandora_core_feature/config/install/field.field.media.image.field_media_use.yml new file mode 100644 index 00000000..5b93f475 --- /dev/null +++ b/modules/islandora_core_feature/config/install/field.field.media.image.field_media_use.yml @@ -0,0 +1,28 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.media.field_media_use + - media.type.image + - taxonomy.vocabulary.islandora_media_use +id: media.image.field_media_use +field_name: field_media_use +entity_type: media +bundle: image +label: 'Media Use' +description: '' +required: false +translatable: true +default_value: { } +default_value_callback: '' +settings: + handler: 'default:taxonomy_term' + handler_settings: + target_bundles: + islandora_media_use: islandora_media_use + sort: + field: name + direction: asc + auto_create: false + auto_create_bundle: '' +field_type: entity_reference diff --git a/modules/islandora_core_feature/config/install/field.field.media.image.field_tags.yml b/modules/islandora_core_feature/config/install/field.field.media.image.field_tags.yml deleted file mode 100644 index 80ce1ec1..00000000 --- a/modules/islandora_core_feature/config/install/field.field.media.image.field_tags.yml +++ /dev/null @@ -1,23 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - field.storage.media.field_tags - - media.type.image - enforced: - module: - - islandora_core_feature -id: media.image.field_tags -field_name: field_tags -entity_type: media -bundle: image -label: Tags -description: '' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: - handler: 'default:taxonomy_term' - handler_settings: { } -field_type: entity_reference diff --git a/modules/islandora_core_feature/config/install/field.field.media.video.field_media_use.yml b/modules/islandora_core_feature/config/install/field.field.media.video.field_media_use.yml new file mode 100644 index 00000000..e8cc3098 --- /dev/null +++ b/modules/islandora_core_feature/config/install/field.field.media.video.field_media_use.yml @@ -0,0 +1,28 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.media.field_media_use + - media.type.video + - taxonomy.vocabulary.islandora_media_use +id: media.video.field_media_use +field_name: field_media_use +entity_type: media +bundle: video +label: 'Media Use' +description: '' +required: false +translatable: true +default_value: { } +default_value_callback: '' +settings: + handler: 'default:taxonomy_term' + handler_settings: + target_bundles: + islandora_media_use: islandora_media_use + sort: + field: name + direction: asc + auto_create: false + auto_create_bundle: '' +field_type: entity_reference diff --git a/modules/islandora_core_feature/config/install/field.field.media.video.field_tags.yml b/modules/islandora_core_feature/config/install/field.field.media.video.field_tags.yml deleted file mode 100644 index a018ca4e..00000000 --- a/modules/islandora_core_feature/config/install/field.field.media.video.field_tags.yml +++ /dev/null @@ -1,23 +0,0 @@ -langcode: en -status: true -dependencies: - config: - - field.storage.media.field_tags - - media.type.video - enforced: - module: - - islandora_core_feature -id: media.video.field_tags -field_name: field_tags -entity_type: media -bundle: video -label: Tags -description: '' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: - handler: 'default:taxonomy_term' - handler_settings: { } -field_type: entity_reference diff --git a/modules/islandora_core_feature/config/install/field.field.taxonomy_term.tags.field_external_uri.yml b/modules/islandora_core_feature/config/install/field.field.taxonomy_term.islandora_display.field_external_uri.yml similarity index 62% rename from modules/islandora_core_feature/config/install/field.field.taxonomy_term.tags.field_external_uri.yml rename to modules/islandora_core_feature/config/install/field.field.taxonomy_term.islandora_display.field_external_uri.yml index 939e5a12..5c4d2661 100644 --- a/modules/islandora_core_feature/config/install/field.field.taxonomy_term.tags.field_external_uri.yml +++ b/modules/islandora_core_feature/config/install/field.field.taxonomy_term.islandora_display.field_external_uri.yml @@ -3,23 +3,20 @@ status: true dependencies: config: - field.storage.taxonomy_term.field_external_uri - - taxonomy.vocabulary.tags - enforced: - module: - - islandora_core_feature + - taxonomy.vocabulary.islandora_display module: - link -id: taxonomy_term.tags.field_external_uri +id: taxonomy_term.islandora_display.field_external_uri field_name: field_external_uri entity_type: taxonomy_term -bundle: tags +bundle: islandora_display label: 'External URI' description: '' required: false -translatable: false +translatable: true default_value: { } default_value_callback: '' settings: - link_type: 16 - title: 0 + title: 1 + link_type: 17 field_type: link diff --git a/modules/islandora_core_feature/config/install/field.field.taxonomy_term.islandora_media_use.field_external_uri.yml b/modules/islandora_core_feature/config/install/field.field.taxonomy_term.islandora_media_use.field_external_uri.yml new file mode 100644 index 00000000..b2f558ad --- /dev/null +++ b/modules/islandora_core_feature/config/install/field.field.taxonomy_term.islandora_media_use.field_external_uri.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.taxonomy_term.field_external_uri + - taxonomy.vocabulary.islandora_media_use + module: + - link +id: taxonomy_term.islandora_media_use.field_external_uri +field_name: field_external_uri +entity_type: taxonomy_term +bundle: islandora_media_use +label: 'External URI' +description: '' +required: false +translatable: true +default_value: { } +default_value_callback: '' +settings: + title: 1 + link_type: 17 +field_type: link diff --git a/modules/islandora_core_feature/config/install/field.field.taxonomy_term.islandora_models.field_external_uri.yml b/modules/islandora_core_feature/config/install/field.field.taxonomy_term.islandora_models.field_external_uri.yml new file mode 100644 index 00000000..403fe108 --- /dev/null +++ b/modules/islandora_core_feature/config/install/field.field.taxonomy_term.islandora_models.field_external_uri.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.taxonomy_term.field_external_uri + - taxonomy.vocabulary.islandora_models + module: + - link +id: taxonomy_term.islandora_models.field_external_uri +field_name: field_external_uri +entity_type: taxonomy_term +bundle: islandora_models +label: 'External URI' +description: '' +required: false +translatable: true +default_value: { } +default_value_callback: '' +settings: + title: 1 + link_type: 17 +field_type: link diff --git a/modules/islandora_core_feature/config/install/field.storage.media.field_tags.yml b/modules/islandora_core_feature/config/install/field.storage.media.field_media_use.yml similarity index 70% rename from modules/islandora_core_feature/config/install/field.storage.media.field_tags.yml rename to modules/islandora_core_feature/config/install/field.storage.media.field_media_use.yml index b76af0b7..90a0cb1b 100644 --- a/modules/islandora_core_feature/config/install/field.storage.media.field_tags.yml +++ b/modules/islandora_core_feature/config/install/field.storage.media.field_media_use.yml @@ -1,21 +1,18 @@ langcode: en status: true dependencies: - enforced: - module: - - islandora_core_feature module: - media - taxonomy -id: media.field_tags -field_name: field_tags +id: media.field_media_use +field_name: field_media_use entity_type: media type: entity_reference settings: target_type: taxonomy_term module: core locked: false -cardinality: -1 +cardinality: 1 translatable: true indexes: { } persist_with_no_fields: false diff --git a/modules/islandora_core_feature/config/install/field.storage.node.field_display_hints.yml b/modules/islandora_core_feature/config/install/field.storage.node.field_display_hints.yml new file mode 100644 index 00000000..7bbfacad --- /dev/null +++ b/modules/islandora_core_feature/config/install/field.storage.node.field_display_hints.yml @@ -0,0 +1,19 @@ +langcode: en +status: true +dependencies: + module: + - node + - taxonomy +id: node.field_display_hints +field_name: field_display_hints +entity_type: node +type: entity_reference +settings: + target_type: taxonomy_term +module: core +locked: false +cardinality: -1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/modules/islandora_core_feature/config/install/field.storage.node.field_model.yml b/modules/islandora_core_feature/config/install/field.storage.node.field_model.yml new file mode 100644 index 00000000..c827deea --- /dev/null +++ b/modules/islandora_core_feature/config/install/field.storage.node.field_model.yml @@ -0,0 +1,19 @@ +langcode: en +status: true +dependencies: + module: + - node + - taxonomy +id: node.field_model +field_name: field_model +entity_type: node +type: entity_reference +settings: + target_type: taxonomy_term +module: core +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/modules/islandora_core_feature/config/install/field.storage.taxonomy_term.field_external_uri.yml b/modules/islandora_core_feature/config/install/field.storage.taxonomy_term.field_external_uri.yml index b1d10e19..c85ac67c 100644 --- a/modules/islandora_core_feature/config/install/field.storage.taxonomy_term.field_external_uri.yml +++ b/modules/islandora_core_feature/config/install/field.storage.taxonomy_term.field_external_uri.yml @@ -14,7 +14,7 @@ type: link settings: { } module: link locked: false -cardinality: -1 +cardinality: 1 translatable: true indexes: { } persist_with_no_fields: false diff --git a/modules/islandora_core_feature/config/install/language.content_settings.taxonomy_term.tags.yml b/modules/islandora_core_feature/config/install/language.content_settings.taxonomy_term.islandora_media_use.yml similarity index 59% rename from modules/islandora_core_feature/config/install/language.content_settings.taxonomy_term.tags.yml rename to modules/islandora_core_feature/config/install/language.content_settings.taxonomy_term.islandora_media_use.yml index d8ce77b8..63ef8494 100644 --- a/modules/islandora_core_feature/config/install/language.content_settings.taxonomy_term.tags.yml +++ b/modules/islandora_core_feature/config/install/language.content_settings.taxonomy_term.islandora_media_use.yml @@ -2,16 +2,14 @@ langcode: en status: true dependencies: config: - - taxonomy.vocabulary.tags + - taxonomy.vocabulary.islandora_media_use module: - content_translation third_party_settings: content_translation: - enabled: false - bundle_settings: - untranslatable_fields_hide: '0' -id: taxonomy_term.tags + enabled: true +id: taxonomy_term.islandora_media_use target_entity_type_id: taxonomy_term -target_bundle: tags +target_bundle: islandora_media_use default_langcode: site_default language_alterable: false diff --git a/modules/islandora_core_feature/config/install/language.content_settings.taxonomy_term.islandora_models.yml b/modules/islandora_core_feature/config/install/language.content_settings.taxonomy_term.islandora_models.yml new file mode 100644 index 00000000..646fab08 --- /dev/null +++ b/modules/islandora_core_feature/config/install/language.content_settings.taxonomy_term.islandora_models.yml @@ -0,0 +1,15 @@ +langcode: en +status: true +dependencies: + config: + - taxonomy.vocabulary.islandora_models + module: + - content_translation +third_party_settings: + content_translation: + enabled: true +id: taxonomy_term.islandora_models +target_entity_type_id: taxonomy_term +target_bundle: islandora_models +default_langcode: site_default +language_alterable: false diff --git a/modules/islandora_core_feature/config/install/media.type.audio.yml b/modules/islandora_core_feature/config/install/media.type.audio.yml index 4ca59fd5..5a4456e0 100644 --- a/modules/islandora_core_feature/config/install/media.type.audio.yml +++ b/modules/islandora_core_feature/config/install/media.type.audio.yml @@ -13,5 +13,6 @@ new_revision: true source_configuration: source_field: field_media_audio_file field_map: + name: name mimetype: field_mime_type filesize: field_file_size diff --git a/modules/islandora_core_feature/config/install/media.type.file.yml b/modules/islandora_core_feature/config/install/media.type.file.yml index 319485ca..a79d9518 100644 --- a/modules/islandora_core_feature/config/install/media.type.file.yml +++ b/modules/islandora_core_feature/config/install/media.type.file.yml @@ -13,5 +13,6 @@ new_revision: true source_configuration: source_field: field_media_file field_map: + name: name mimetype: field_mime_type filesize: field_file_size diff --git a/modules/islandora_core_feature/config/install/media.type.image.yml b/modules/islandora_core_feature/config/install/media.type.image.yml index 790835b6..4ecfbf64 100644 --- a/modules/islandora_core_feature/config/install/media.type.image.yml +++ b/modules/islandora_core_feature/config/install/media.type.image.yml @@ -13,6 +13,7 @@ new_revision: true source_configuration: source_field: field_media_image field_map: + name: name mimetype: field_mime_type filesize: field_file_size width: field_width diff --git a/modules/islandora_core_feature/config/install/media.type.video.yml b/modules/islandora_core_feature/config/install/media.type.video.yml index fd127305..c4a7c9a1 100644 --- a/modules/islandora_core_feature/config/install/media.type.video.yml +++ b/modules/islandora_core_feature/config/install/media.type.video.yml @@ -13,5 +13,6 @@ new_revision: true source_configuration: source_field: field_media_video_file field_map: + name: name mimetype: field_mime_type filesize: field_file_size diff --git a/modules/islandora_core_feature/config/install/rdf.mapping.taxonomy_term.islandora_media_use.yml b/modules/islandora_core_feature/config/install/rdf.mapping.taxonomy_term.islandora_media_use.yml new file mode 100644 index 00000000..4e809514 --- /dev/null +++ b/modules/islandora_core_feature/config/install/rdf.mapping.taxonomy_term.islandora_media_use.yml @@ -0,0 +1,30 @@ +langcode: en +status: true +dependencies: + config: + - taxonomy.vocabulary.islandora_media_use + enforced: + module: + - islandora_core_feature + module: + - taxonomy +id: taxonomy_term.islandora_media_use +targetEntityType: taxonomy_term +bundle: islandora_media_use +types: + - 'schema:Thing' +fieldMappings: + name: + properties: + - 'dc:title' + description: + properties: + - 'dc:description' + field_external_uri: + properties: + - 'owl:sameAs' + changed: + properties: + - 'schema:dateModified' + datatype_callback: + callable: 'Drupal\rdf\CommonDataConverter::dateIso8601Value' diff --git a/modules/islandora_core_feature/config/install/rdf.mapping.taxonomy_term.tags.yml b/modules/islandora_core_feature/config/install/rdf.mapping.taxonomy_term.islandora_models.yml similarity index 83% rename from modules/islandora_core_feature/config/install/rdf.mapping.taxonomy_term.tags.yml rename to modules/islandora_core_feature/config/install/rdf.mapping.taxonomy_term.islandora_models.yml index 0e07aad3..b1a6bebb 100644 --- a/modules/islandora_core_feature/config/install/rdf.mapping.taxonomy_term.tags.yml +++ b/modules/islandora_core_feature/config/install/rdf.mapping.taxonomy_term.islandora_models.yml @@ -2,15 +2,15 @@ langcode: en status: true dependencies: config: - - taxonomy.vocabulary.tags + - taxonomy.vocabulary.islandora_models enforced: module: - islandora_core_feature module: - taxonomy -id: taxonomy_term.tags +id: taxonomy_term.islandora_models targetEntityType: taxonomy_term -bundle: tags +bundle: islandora_models types: - 'schema:Thing' fieldMappings: diff --git a/modules/islandora_core_feature/config/install/taxonomy.vocabulary.islandora_display.yml b/modules/islandora_core_feature/config/install/taxonomy.vocabulary.islandora_display.yml new file mode 100644 index 00000000..f121cbb3 --- /dev/null +++ b/modules/islandora_core_feature/config/install/taxonomy.vocabulary.islandora_display.yml @@ -0,0 +1,8 @@ +langcode: en +status: true +dependencies: { } +name: 'Islandora Display' +vid: islandora_display +description: 'Terms used to alter how a repository item is viewed. ie. basic image vs large image' +hierarchy: 0 +weight: 0 diff --git a/modules/islandora_core_feature/config/install/taxonomy.vocabulary.islandora_media_use.yml b/modules/islandora_core_feature/config/install/taxonomy.vocabulary.islandora_media_use.yml new file mode 100644 index 00000000..fb922bcf --- /dev/null +++ b/modules/islandora_core_feature/config/install/taxonomy.vocabulary.islandora_media_use.yml @@ -0,0 +1,8 @@ +langcode: en +status: true +dependencies: { } +name: 'Islandora Media Use' +vid: islandora_media_use +description: 'Terms to define how a media object is to be used.' +hierarchy: 0 +weight: 0 diff --git a/modules/islandora_core_feature/config/install/taxonomy.vocabulary.islandora_models.yml b/modules/islandora_core_feature/config/install/taxonomy.vocabulary.islandora_models.yml new file mode 100644 index 00000000..b82e075c --- /dev/null +++ b/modules/islandora_core_feature/config/install/taxonomy.vocabulary.islandora_models.yml @@ -0,0 +1,8 @@ +langcode: en +status: true +dependencies: { } +name: 'Islandora Models' +vid: islandora_models +description: 'Types of repository objects' +hierarchy: 0 +weight: 0 diff --git a/modules/islandora_core_feature/config/install/taxonomy.vocabulary.tags.yml b/modules/islandora_core_feature/config/install/taxonomy.vocabulary.tags.yml deleted file mode 100644 index 92aa1809..00000000 --- a/modules/islandora_core_feature/config/install/taxonomy.vocabulary.tags.yml +++ /dev/null @@ -1,11 +0,0 @@ -langcode: en -status: true -dependencies: - enforced: - module: - - islandora_core_feature -name: Tags -vid: tags -description: 'Use tags to group articles on similar topics into categories.' -hierarchy: 0 -weight: 0 diff --git a/modules/islandora_core_feature/config/install/views.view.display_media.yml b/modules/islandora_core_feature/config/install/views.view.display_media.yml index 68b8b31a..d73b039e 100644 --- a/modules/islandora_core_feature/config/install/views.view.display_media.yml +++ b/modules/islandora_core_feature/config/install/views.view.display_media.yml @@ -133,13 +133,13 @@ display: footer: { } empty: { } relationships: - field_tags: - id: field_tags - table: media__field_tags - field: field_tags + field_media_use: + id: field_media_use + table: media__field_media_use + field: field_media_use relationship: none group_type: group - admin_label: 'field_tags: Taxonomy term' + admin_label: 'field_media_use: Taxonomy term' required: false plugin_id: standard arguments: @@ -210,7 +210,7 @@ display: id: field_external_uri_uri table: taxonomy_term__field_external_uri field: field_external_uri_uri - relationship: field_tags + relationship: field_media_use group_type: group admin_label: '' operator: '=' @@ -288,7 +288,7 @@ display: id: field_external_uri_uri table: taxonomy_term__field_external_uri field: field_external_uri_uri - relationship: field_tags + relationship: field_media_use group_type: group admin_label: '' operator: '=' @@ -332,6 +332,7 @@ display: entity_type: node bundles: { } title: 'Service File' + show_title: false cache_metadata: max-age: -1 contexts: @@ -364,7 +365,7 @@ display: id: field_external_uri_uri table: taxonomy_term__field_external_uri field: field_external_uri_uri - relationship: field_tags + relationship: field_media_use group_type: group admin_label: '' operator: '=' diff --git a/modules/islandora_core_feature/config/install/views.view.media_of.yml b/modules/islandora_core_feature/config/install/views.view.media_of.yml index 8d92e16b..28ade48b 100644 --- a/modules/islandora_core_feature/config/install/views.view.media_of.yml +++ b/modules/islandora_core_feature/config/install/views.view.media_of.yml @@ -2,8 +2,8 @@ langcode: en status: true dependencies: config: + - field.storage.media.field_media_use - field.storage.media.field_mime_type - - field.storage.media.field_tags enforced: module: - islandora_core_feature @@ -743,14 +743,14 @@ display: separator: ', ' field_api_classes: false plugin_id: field - field_tags: - id: field_tags - table: media__field_tags - field: field_tags + field_media_use: + id: field_media_use + table: media__field_media_use + field: field_media_use relationship: none group_type: group admin_label: '' - label: Tags + label: 'Media Use' exclude: false alter: alter_text: false @@ -935,8 +935,8 @@ display: - url.query_args - user.permissions tags: + - 'config:field.storage.media.field_media_use' - 'config:field.storage.media.field_mime_type' - - 'config:field.storage.media.field_tags' - extensions rest_export_1: display_plugin: rest_export diff --git a/modules/islandora_core_feature/islandora_core_feature.features.yml b/modules/islandora_core_feature/islandora_core_feature.features.yml index 7c06112e..425bfa80 100644 --- a/modules/islandora_core_feature/islandora_core_feature.features.yml +++ b/modules/islandora_core_feature/islandora_core_feature.features.yml @@ -3,5 +3,14 @@ excluded: - core.entity_view_display.node.article.default - core.entity_view_display.node.article.rss - core.entity_view_display.node.article.teaser + - core.entity_view_display.taxonomy_term.islandora_display.default + - core.entity_view_display.taxonomy_term.islandora_media_use.default + - core.entity_view_display.taxonomy_term.islandora_models.default - field.field.node.article.field_tags + - core.entity_form_display.taxonomy_term.islandora_display.default + - core.entity_form_display.taxonomy_term.islandora_media_use.default + - core.entity_form_display.taxonomy_term.islandora_models.default + - language.content_settings.taxonomy_term.islandora_access + - field.storage.node.field_access_terms + - taxonomy.vocabulary.islandora_access required: true diff --git a/src/IslandoraUtils.php b/src/IslandoraUtils.php index 23b5f0d3..e6ba1b75 100644 --- a/src/IslandoraUtils.php +++ b/src/IslandoraUtils.php @@ -6,7 +6,9 @@ use Drupal\context\ContextManager; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityFieldManager; use Drupal\Core\Entity\EntityTypeManager; +use Drupal\Core\Entity\Query\QueryException; use Drupal\Core\Entity\Query\QueryFactory; +use Drupal\Core\Entity\Query\QueryInterface; use Drupal\Core\Site\Settings; use Drupal\file\FileInterface; use Drupal\flysystem\FlysystemFactory; @@ -25,7 +27,7 @@ class IslandoraUtils { const EXTERNAL_URI_FIELD = 'field_external_uri'; const MEDIA_OF_FIELD = 'field_media_of'; - const TAGS_FIELD = 'field_tags'; + const MEDIA_USAGE_FIELD = 'field_media_use'; /** * The entity type manager. @@ -98,6 +100,10 @@ class IslandoraUtils { * * @return \Drupal\node\NodeInterface * Parent node. + * + * @throws \Drupal\Core\TypedData\Exception\MissingDataException + * Method $field->first() throws if data structure is unset and no item can + * be created. */ public function getParentNode(MediaInterface $media) { if (!$media->hasField(self::MEDIA_OF_FIELD)) { @@ -124,6 +130,11 @@ class IslandoraUtils { * * @return \Drupal\media\MediaInterface[] * The children Media. + * + * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException + * Calling getStorage() throws if the entity type doesn't exist. + * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException + * Calling getStorage() throws if the storage handler couldn't be loaded. */ public function getMedia(NodeInterface $node) { if (!$this->entityTypeManager->getStorage('field_storage_config')->load('media.' . self::MEDIA_OF_FIELD)) { @@ -146,12 +157,14 @@ class IslandoraUtils { * * @return \Drupal\media\MediaInterface * The child Media. + * + * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException + * Calling getStorage() throws if the entity type doesn't exist. + * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException + * Calling getStorage() throws if the storage handler couldn't be loaded. */ public function getMediaWithTerm(NodeInterface $node, TermInterface $term) { - $mids = $this->entityQuery->get('media') - ->condition(self::MEDIA_OF_FIELD, $node->id()) - ->condition(self::TAGS_FIELD, $term->id()) - ->execute(); + $mids = $this->getMediaReferencingNodeAndTerm($node, $term); if (empty($mids)) { return NULL; } @@ -166,13 +179,15 @@ class IslandoraUtils { * * @return \Drupal\media\MediaInterface[] * Array of media. + * + * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException + * Calling getStorage() throws if the entity type doesn't exist. + * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException + * Calling getStorage() throws if the storage handler couldn't be loaded. */ public function getReferencingMedia($fid) { // Get media fields that reference files. - $fields = $this->entityQuery->get('field_storage_config') - ->condition('entity_type', 'media') - ->condition('settings.target_type', 'file') - ->execute(); + $fields = $this->getReferencingFields('media', 'file'); // Process field names, stripping off 'media.' and appending 'target_id'. $conditions = array_map( @@ -199,12 +214,16 @@ class IslandoraUtils { * * @return \Drupal\taxonomy\TermInterface|null * Term or NULL if not found. + * + * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException + * Calling getStorage() throws if the entity type doesn't exist. + * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException + * Calling getStorage() throws if the storage handler couldn't be loaded. */ public function getTermForUri($uri) { $results = $this->entityQuery->get('taxonomy_term') ->condition(self::EXTERNAL_URI_FIELD . '.uri', $uri) ->execute(); - if (empty($results)) { return NULL; } @@ -219,6 +238,10 @@ class IslandoraUtils { * * @return string|null * URI or NULL if not found. + * + * @throws \Drupal\Core\TypedData\Exception\MissingDataException + * Method $field->first() throws if data structure is unset and no item can + * be created. */ public function getUriForTerm(TermInterface $term) { if ($term && $term->hasField(self::EXTERNAL_URI_FIELD)) { @@ -335,6 +358,9 @@ class IslandoraUtils { * The updated entity. * @param \Drupal\Core\Entity\ContentEntityInterface $original * The original entity. + * + * @return bool + * TRUE if the fields have changed. */ public function haveFieldsChanged(ContentEntityInterface $entity, ContentEntityInterface $original) { @@ -385,4 +411,91 @@ class IslandoraUtils { return array_merge($schemes, $this->flysystemFactory->getSchemes()); } + /** + * Get array of media ids that have fields that reference $node and $term. + * + * @param \Drupal\node\NodeInterface $node + * The node to reference. + * @param \Drupal\taxonomy\TermInterface $term + * The term to reference. + * + * @return array|int|null + * Array of media IDs or NULL. + */ + public function getMediaReferencingNodeAndTerm(NodeInterface $node, TermInterface $term) { + $term_fields = $this->getReferencingFields('media', 'taxonomy_term'); + if (count($term_fields) <= 0) { + \Drupal::logger("No media fields reference a taxonomy term"); + return NULL; + } + $node_fields = $this->getReferencingFields('media', 'node'); + if (count($node_fields) <= 0) { + \Drupal::logger("No media fields reference a node."); + return NULL; + } + + $remove_entity = function (&$o) { + $o = substr($o, strpos($o, '.') + 1); + }; + array_walk($term_fields, $remove_entity); + array_walk($node_fields, $remove_entity); + + $query = $this->entityQuery->get('media'); + $taxon_condition = $this->getEntityQueryOrCondition($query, $term_fields, $term->id()); + $query->condition($taxon_condition); + $node_condition = $this->getEntityQueryOrCondition($query, $node_fields, $node->id()); + $query->condition($node_condition); + // Does the tags field exist? + try { + $mids = $query->execute(); + } + catch (QueryException $e) { + $mids = []; + } + return $mids; + } + + /** + * Get the fields on an entity of $entity_type that reference a $target_type. + * + * @param string $entity_type + * Type of entity to search for. + * @param string $target_type + * Type of entity the field references. + * + * @return array + * Array of fields. + */ + public function getReferencingFields($entity_type, $target_type) { + $fields = $this->entityQuery->get('field_storage_config') + ->condition('entity_type', $entity_type) + ->condition('settings.target_type', $target_type) + ->execute(); + if (!is_array($fields)) { + $fields = [$fields]; + } + return $fields; + } + + /** + * Make an OR condition for an array of fields and a value. + * + * @param \Drupal\Core\Entity\Query\QueryInterface $query + * The QueryInterface for the query. + * @param array $fields + * The array of field names. + * @param string $value + * The value to search the fields for. + * + * @return \Drupal\Core\Entity\Query\ConditionInterface + * The OR condition to add to your query. + */ + private function getEntityQueryOrCondition(QueryInterface $query, array $fields, $value) { + $condition = $query->orConditionGroup(); + foreach ($fields as $field) { + $condition->condition($field, $value); + } + return $condition; + } + } diff --git a/src/MediaSource/MediaSourceService.php b/src/MediaSource/MediaSourceService.php index 01b6b1f3..2044ab00 100644 --- a/src/MediaSource/MediaSourceService.php +++ b/src/MediaSource/MediaSourceService.php @@ -8,6 +8,7 @@ use Drupal\Core\File\FileSystem; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Session\AccountInterface; use Drupal\file\FileInterface; +use Drupal\islandora\IslandoraUtils; use Drupal\media\MediaInterface; use Drupal\media\MediaTypeInterface; use Drupal\node\NodeInterface; @@ -56,6 +57,13 @@ class MediaSourceService { */ protected $fileSystem; + /** + * Islandora Utility service. + * + * @var \Drupal\islandora\IslandoraUtils + */ + protected $islandoraUtils; + /** * Constructor. * @@ -69,19 +77,23 @@ class MediaSourceService { * Entity query. * @param \Drupal\Core\File\FileSystem $file_system * File system service. + * @param \Drupal\islandora\IslandoraUtils $islandora_utils + * Utility service. */ public function __construct( EntityTypeManager $entity_type_manager, AccountInterface $account, LanguageManagerInterface $language_manager, QueryFactory $entity_query, - FileSystem $file_system + FileSystem $file_system, + IslandoraUtils $islandora_utils ) { $this->entityTypeManager = $entity_type_manager; $this->account = $account; $this->languageManager = $language_manager; $this->entityQuery = $entity_query; $this->fileSystem = $file_system; + $this->islandoraUtils = $islandora_utils; } /** @@ -238,10 +250,7 @@ class MediaSourceService { $mimetype, $content_location ) { - $existing = $this->entityQuery->get('media') - ->condition('field_media_of', $node->id()) - ->condition('field_tags', $taxonomy_term->id()) - ->execute(); + $existing = $this->islandoraUtils->getMediaReferencingNodeAndTerm($node, $taxonomy_term); if (!empty($existing)) { // Just update already existing media. @@ -299,12 +308,12 @@ class MediaSourceService { "$source_field" => [ 'target_id' => $file->id(), ], - 'field_tags' => [ - 'target_id' => $taxonomy_term->id(), - ], - 'field_media_of' => [ + IslandoraUtils::MEDIA_OF_FIELD => [ 'target_id' => $node->id(), ], + IslandoraUtils::MEDIA_USAGE_FIELD => [ + 'target_id' => $taxonomy_term->id(), + ], ]; // Set alt text. diff --git a/src/Plugin/Condition/.NodeHasTerm.php.swp b/src/Plugin/Condition/.NodeHasTerm.php.swp deleted file mode 100644 index 54aa9596..00000000 Binary files a/src/Plugin/Condition/.NodeHasTerm.php.swp and /dev/null differ diff --git a/src/Plugin/Condition/NodeHasTerm.php b/src/Plugin/Condition/NodeHasTerm.php index 3b79450a..774f6d7e 100644 --- a/src/Plugin/Condition/NodeHasTerm.php +++ b/src/Plugin/Condition/NodeHasTerm.php @@ -145,8 +145,7 @@ class NodeHasTerm extends ConditionPluginBase implements ContainerFactoryPluginI */ protected function evaluateEntity(EntityInterface $entity) { foreach ($entity->referencedEntities() as $referenced_entity) { - if ($referenced_entity->getEntityTypeId() == 'taxonomy_term' - && $referenced_entity->hasField(IslandoraUtils::EXTERNAL_URI_FIELD)) { + if ($referenced_entity->getEntityTypeId() == 'taxonomy_term' && $referenced_entity->hasField(IslandoraUtils::EXTERNAL_URI_FIELD)) { $field = $referenced_entity->get(IslandoraUtils::EXTERNAL_URI_FIELD); if (!$field->isEmpty()) { $link = $field->first()->getValue();