From d0e0c299212eb3810979c151e4aef9a219a5eb8d Mon Sep 17 00:00:00 2001 From: Alan Stanley Date: Wed, 20 Dec 2023 14:13:10 -0400 Subject: [PATCH] Issue 1000 (#1001) * Change to Boolean logic * added forward slash to path * Made Viewer display configurable --------- Co-authored-by: Rosie Le Faive --- .../config/schema/islandora_iiif.schema.yml | 7 ++++-- .../src/Form/IslandoraIIIFConfigForm.php | 14 +++++++++++ .../src/Plugin/views/style/IIIFManifest.php | 24 ++++++++++++++++--- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/modules/islandora_iiif/config/schema/islandora_iiif.schema.yml b/modules/islandora_iiif/config/schema/islandora_iiif.schema.yml index f9e870ef..1f91450f 100644 --- a/modules/islandora_iiif/config/schema/islandora_iiif.schema.yml +++ b/modules/islandora_iiif/config/schema/islandora_iiif.schema.yml @@ -6,8 +6,11 @@ islandora_iiif.settings: type: string label: 'IIIF Server Url' use_relative_paths: - type: boolean - label: 'Use relative paths in manifest.' + type: boolean + label: 'Use relative paths in manifest.' + show_title: + type: string + label: 'Show title in view' views.style.iiif_manifest: type: views_style diff --git a/modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php b/modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php index a99539a3..41bd84a4 100644 --- a/modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php +++ b/modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php @@ -66,6 +66,11 @@ class IslandoraIIIFConfigForm extends ConfigFormBase { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { + $options = [ + 'none' => $this->t('None'), + 'view' => $this->t("From view title"), + 'node' => $this->t("From node title"), + ]; $config = $this->config('islandora_iiif.settings'); $form['iiif_server'] = [ '#type' => 'url', @@ -84,6 +89,14 @@ class IslandoraIIIFConfigForm extends ConfigFormBase { '#default_value' => $config->get('use_relative_paths'), ]; + $form['show_title'] = [ + '#type' => 'select', + '#options' => $options, + '#title' => $this->t("Show title in viewer."), + '#description' => $this->t("Show title on your viewer, if viewer allows"), + '#default_value' => $config->get('show_title'), + ]; + return parent::buildForm($form, $form_state); } @@ -111,6 +124,7 @@ class IslandoraIIIFConfigForm extends ConfigFormBase { $this->config('islandora_iiif.settings') ->set('iiif_server', $form_state->getValue('iiif_server')) ->set('use_relative_paths', $form_state->getValue('use_relative_paths')) + ->set('show_title', $form_state->getValue('show_title')) ->save(); } diff --git a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php index 4360e2c2..2fc8a431 100644 --- a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php +++ b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php @@ -167,15 +167,33 @@ class IIIFManifest extends StylePluginBase { // @todo assumming the view is a path like /node/1/manifest.json $url_components = explode('/', trim($request_url, '/')); array_pop($url_components); - $content_path = implode('/', $url_components); - $iiif_base_id = $request_host . '/' . $content_path; + $content_path = '/' . implode('/', $url_components); + $iiif_base_id = "{$request_host}{$content_path}"; + $display = $this->iiifConfig->get('show_title'); + switch ($display) { + case 'none': + $label = ''; + break; + + case 'view': + $label = $this->view->getTitle(); + break; + + case 'node': + $label = $this->getEntityTitle($content_path); + + break; + + default: + $label = $this->t("IIIF Manifest"); + } // @see https://iiif.io/api/presentation/2.1/#manifest $json += [ '@type' => 'sc:Manifest', '@id' => $request_url, // If the View has a title, set the View title as the manifest label. - 'label' => $this->view->getTitle() ?: $this->getEntityTitle($content_path), + 'label' => $label, '@context' => 'http://iiif.io/api/presentation/2/context.json', // @see https://iiif.io/api/presentation/2.1/#sequence 'sequences' => [