Skip to content

Commit

Permalink
Removed a useless option.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-KM committed Mar 3, 2019
1 parent 9f9b530 commit d173464
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 25 deletions.
7 changes: 7 additions & 0 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [],
Expand Down
2 changes: 1 addition & 1 deletion config/module.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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"
17 changes: 17 additions & 0 deletions data/scripts/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
27 changes: 12 additions & 15 deletions src/Form/ConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand All @@ -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' => [
Expand All @@ -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' => [
Expand Down
6 changes: 5 additions & 1 deletion src/View/Helper/IiifCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
17 changes: 10 additions & 7 deletions src/View/Helper/IiifManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ protected function buildManifestItem(ItemRepresentation $item)
/**
* Prepare the metadata of a resource.
*
* @todo Factorize with IiifCollection.
*
* @param AbstractResourceEntityRepresentation $resource
* @return array
*/
Expand All @@ -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 = [];
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d173464

Please sign in to comment.