Skip to content

Commit

Permalink
When search service is provided by IiifSearch & ExtractOcr modules, we
Browse files Browse the repository at this point in the history
can check if there is an XML in order to disable search for items that
only contain images for example.
  • Loading branch information
symac committed Oct 28, 2019
1 parent 4c196e4 commit facca51
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
1 change: 1 addition & 0 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@
'iiifserver_image_tile_dir' => 'tile',
'iiifserver_image_tile_type' => 'deepzoom',
'iiifserver_manifest_service_iiifSearch' => '',
'iiifserver_manifest_service_iiifSearch_extractOcr' => false,
],
],
];
16 changes: 16 additions & 0 deletions src/Form/ConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,17 @@ public function init()
],
]);

$manifestFieldset->add([
'name' => 'iiifserver_manifest_service_iiifSearch_extractOcr',
'type' => Element\Checkbox::class,
'options' => [
'label' => 'IIIF Search provided by ExtractOcr module', // @translate
'info' => 'If you use IiifSearch & ExtractOcr modules to provide IiifSearch results, check this box to disable the search box when there is no OCR.', // @translate
],
]);



$this->add([
'name' => 'iiifserver_image',
'type' => Fieldset::class,
Expand Down Expand Up @@ -375,6 +386,11 @@ public function init()
'name' => 'iiifserver_manifest_service_iiifSearch',
'required' => false,
]);
$manifestFilter->add([
'name' => 'iiifserver_manifest_service_iiifSearch_extractOcr',
'required' => false,
]);


$imageFilter = $inputFilter->get('iiifserver_image');
$imageFilter->add([
Expand Down
28 changes: 22 additions & 6 deletions src/View/Helper/IiifManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

namespace IiifServer\View\Helper;

use IiifSearch\View\Helper\IiifSearch;
use IiifServer\Mvc\Controller\Plugin\TileInfo;
use Omeka\Api\Representation\AbstractResourceEntityRepresentation;
use Omeka\Api\Representation\ItemRepresentation;
Expand Down Expand Up @@ -160,12 +161,27 @@ protected function buildManifestItem(ItemRepresentation $item)

$iiifSearch = $this->view->setting('iiifserver_manifest_service_iiifSearch');
if ( $iiifSearch ) {
$manifest['service'] = [
'@context' =>'http://iiif.io/api/search/0/context.json',
'@id' => $iiifSearch . $item->id(),
"profile" => "http://iiif.io/api/search/0/search",
"label" => "Search within this manifest"
];
$searchServiceAvailable = true;
$iiifSearchExtractOcr = $this->view->setting('iiifserver_manifest_service_iiifSearch_extractOcr');
if ($iiifSearchExtractOcr) {
// Checking if item has at least an XML file that will allow search
$searchServiceAvailable = false;
foreach ( $item->media() as $media ) {
$mediaType = $media->mediaType();
if (($mediaType == 'application/xml') || ($mediaType == 'text/xml')) {
$searchServiceAvailable = true;
}
}
}

if ($searchServiceAvailable) {
$manifest['service'] = [
'@context' => 'http://iiif.io/api/search/0/context.json',
'@id' => $iiifSearch . $item->id(),
"profile" => "http://iiif.io/api/search/0/search",
"label" => "Search within this manifest"
];
}
}


Expand Down

0 comments on commit facca51

Please sign in to comment.