From d1734645af503560b686eb8cba34be093d849edf Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Mon, 4 Mar 2019 00:00:00 +0100 Subject: [PATCH] Removed a useless option. --- Module.php | 7 +++++++ config/module.config.php | 1 - config/module.ini | 2 +- data/scripts/upgrade.php | 17 +++++++++++++++++ src/Form/ConfigForm.php | 27 ++++++++++++--------------- src/View/Helper/IiifCollection.php | 6 +++++- src/View/Helper/IiifManifest.php | 17 ++++++++++------- 7 files changed, 52 insertions(+), 25 deletions(-) diff --git a/Module.php b/Module.php index 1052400..899799c 100644 --- a/Module.php +++ b/Module.php @@ -314,6 +314,13 @@ public function handleConfigForm(AbstractController $controller) $params = $params['iiifserver_manifest'] + $params['iiifserver_image']; + // Specific options. + foreach (['iiifserver_manifest_collection_properties', 'iiifserver_manifest_item_properties', 'iiifserver_manifest_media_properties'] as $key) { + $params[$key] = empty($params[$key]) || in_array('', $params[$key]) + ? [] + : (in_array('none', $params[$key]) ? ['none'] : $params[$key]); + } + $defaultSettings = $config[strtolower(__NAMESPACE__)]['config']; $params = array_intersect_key($params, $defaultSettings); foreach ($params as $name => $value) { diff --git a/config/module.config.php b/config/module.config.php index c32a7a5..0ffa76b 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -374,7 +374,6 @@ 'iiifserver_manifest_attribution_default' => 'Provided by Example Organization', // @translate 'iiifserver_manifest_license_property' => 'dcterms:license', 'iiifserver_manifest_license_default' => 'http://www.example.org/license.html', - 'iiifserver_manifest_media_metadata' => true, 'iiifserver_manifest_properties_collection' => [], 'iiifserver_manifest_properties_item' => [], 'iiifserver_manifest_properties_media' => [], diff --git a/config/module.ini b/config/module.ini index 074af34..5778676 100644 --- a/config/module.ini +++ b/config/module.ini @@ -8,5 +8,5 @@ author_link = "https://github.com/Daniel-KM" module_link = "https://github.com/Daniel-KM/Omeka-S-module-IiifServer" support_link = "https://github.com/Daniel-KM/Omeka-S-module-IiifServer/issues" configurable = true -version = "3.5.13" +version = "3.5.14" omeka_version_constraint = "^1.2.0" diff --git a/data/scripts/upgrade.php b/data/scripts/upgrade.php index 74a2cda..56f5207 100644 --- a/data/scripts/upgrade.php +++ b/data/scripts/upgrade.php @@ -66,3 +66,20 @@ $defaultSettings['iiifserver_manifest_media_metadata'] ); } + +if (version_compare($oldVersion, '3.5.14', '<')) { + $settings->set( + 'iiifserver_manifest_collection_properties', + $defaultSettings['iiifserver_manifest_collection_properties'] + ); + $settings->set( + 'iiifserver_manifest_item_properties', + $defaultSettings['iiifserver_manifest_item_properties'] + ); + $value = $settings->delete('iiifserver_manifest_media_metadata'); + $settings->set( + 'iiifserver_manifest_media_properties', + $value === '0' ? ['none'] : $defaultSettings['iiifserver_manifest_media_properties'] + ); + $settings->delete('iiifserver_manifest_media_metadata'); +} diff --git a/src/Form/ConfigForm.php b/src/Form/ConfigForm.php index 24a8ec5..9aa9005 100644 --- a/src/Form/ConfigForm.php +++ b/src/Form/ConfigForm.php @@ -104,25 +104,16 @@ public function init() ], ]); - $manifestFieldset->add([ - 'name' => 'iiifserver_manifest_media_metadata', - 'type' => Element\Checkbox::class, - 'options' => [ - 'label' => 'Append media metadata', // @translate - 'info' => 'Append descriptive metadata of the media, if any, for example details about each page of a book.', // @translate - ], - 'attributes' => [ - 'id' => 'iiifserver-manifest-media-metadata', - ], - ]); - $manifestFieldset->add([ 'name' => 'iiifserver_manifest_properties_collection', 'type' => PropertySelect::class, 'options' => [ 'label' => 'Limit properties for collection in manifest', // @translate 'info' => 'If empty, all public values will be output.', // @translate - 'empty_option' => '', // @translate + 'empty_option' => 'All', // @translate + 'prepend_value_options' => [ + 'none' => 'None', // @translate + ], 'term_as_value' => true, ], 'attributes' => [ @@ -139,7 +130,10 @@ public function init() 'options' => [ 'label' => 'Limit properties for item in manifest', // @translate 'info' => 'If empty, all public values will be output.', // @translate - 'empty_option' => '', // @translate + 'empty_option' => 'All', // @translate + 'prepend_value_options' => [ + 'none' => 'None', // @translate + ], 'term_as_value' => true, ], 'attributes' => [ @@ -156,7 +150,10 @@ public function init() 'options' => [ 'label' => 'Limit properties for media in manifest', // @translate 'info' => 'If empty, all public values will be output.', // @translate - 'empty_option' => '', // @translate + 'empty_option' => 'All', // @translate + 'prepend_value_options' => [ + 'none' => 'None', // @translate + ], 'term_as_value' => true, ], 'attributes' => [ diff --git a/src/View/Helper/IiifCollection.php b/src/View/Helper/IiifCollection.php index f10503a..5b0ce81 100644 --- a/src/View/Helper/IiifCollection.php +++ b/src/View/Helper/IiifCollection.php @@ -215,8 +215,12 @@ protected function buildManifestBase(AbstractResourceEntityRepresentation $resou */ protected function iiifMetadata(AbstractResourceEntityRepresentation $resource) { - $metadata = []; $properties = $this->view->setting('iiifserver_manifest_properties_collection'); + if ($properties === ['none']) { + return []; + } + + $metadata = []; $values = $properties ? array_intersect_key($resource->values(), array_flip($properties)) : $resource->values(); foreach ($values as $propertyData) { $valueMetadata = []; diff --git a/src/View/Helper/IiifManifest.php b/src/View/Helper/IiifManifest.php index b777f4d..69cba3e 100644 --- a/src/View/Helper/IiifManifest.php +++ b/src/View/Helper/IiifManifest.php @@ -470,6 +470,8 @@ protected function buildManifestItem(ItemRepresentation $item) /** * Prepare the metadata of a resource. * + * @todo Factorize with IiifCollection. + * * @param AbstractResourceEntityRepresentation $resource * @return array */ @@ -485,8 +487,12 @@ protected function iiifMetadata(AbstractResourceEntityRepresentation $resource) return []; } - $metadata = []; $properties = $this->view->setting($map[$jsonLdType]); + if ($properties === ['none']) { + return []; + } + + $metadata = []; $values = $properties ? array_intersect_key($resource->values(), array_flip($properties)) : $resource->values(); foreach ($values as $propertyData) { $valueMetadata = []; @@ -671,12 +677,9 @@ protected function _iiifCanvasImage(MediaRepresentation $media, $index) $images[] = $image; $canvas['images'] = $images; - $mediaMetadata = $this->getView()->setting('iiifserver_manifest_media_metadata'); - if ($mediaMetadata) { - $metadata = $this->iiifMetadata($media); - if ($metadata) { - $canvas['metadata'] = $metadata; - } + $metadata = $this->iiifMetadata($media); + if ($metadata) { + $canvas['metadata'] = $metadata; } $canvas = (object) $canvas;