Skip to content

Commit

Permalink
Allow turning search on and off
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Jun 9, 2017
1 parent d1e1574 commit 1551fea
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 14 deletions.
4 changes: 3 additions & 1 deletion MiradorPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ class MiradorPlugin extends Omeka_Plugin_AbstractPlugin

public function hookInstall() {
set_option('mirador_override_viewer_in_theme', '0');
set_option('mirador_search', '0');
}

public function hookInitialize()
{
// allow option to display mirador viewer in theme's files
// by default, just override all image viewers
if (get_option('mirador_override_viewer_in_theme') == '0') {
if (empty(get_option('mirador_override_viewer_in_theme'))) {
add_file_display_callback(array(
'mimeTypes' => array('image/tiff'),
'fileExtensions' => array('tif', 'tiff'),
Expand Down Expand Up @@ -116,6 +117,7 @@ public function hookConfig()
'mirador_iiif_server_prod',
'mirador_iiif_server_test',
'mirador_override_viewer_in_theme',
'mirador_search',
);
foreach ($options as $option) {
if (empty($_POST[$option])) {
Expand Down
10 changes: 10 additions & 0 deletions config-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
</div>
</div>

<div class="field">
<div class="two columns alpha">
<label for="mirador_search"><?php echo __('Allow Searching files in an item');?></label>
</div>
<div class="inputs five columns omega">
<input type="checkbox" name="mirador_search" value="1" <?php if (get_option('mirador_search')) echo 'checked="checked"'; ?>/>
<p><?php echo __('Check this box if you want to provide a search box within the image viewer that will search the metadata for all the files of an item.');?></p>
</div>
</div>

<h3><?php echo __('Advanced Settings'); ?></h3>
<div class="field">
<div class="two columns alpha">
Expand Down
10 changes: 6 additions & 4 deletions controllers/ManifestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@ public function showAction()
'label' => 'Item Show',
'canvases' => array(),
),
),
'service' => array(
)
);
if (get_option('mirador_search')) {
$this->view->json['service'] = array(
'@context' => 'http://iiif.io/api/search/1/context.json',
"@id" => $base_url . "/iiif-search/" . $item->id,
"profile" => "http://iiif.io/api/search/1/search",
"label" => "Search"
),
);
);
}

$count = 0;
if ($item) {
Expand Down
3 changes: 3 additions & 0 deletions controllers/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public function showAction()
$uri = explode('?', $uri);
$item_id = array_shift($uri);

// no chance of integrating with solr since we need to know the exact
// file ID that's metadata matched the search term so when they click on it
// in the mirador viewer it jumps right to that file
$query = "SELECT record_id, `text`, metadata FROM element_texts t
INNER JOIN files f ON f.id = t.record_id AND t.record_type = 'File'
WHERE f.item_id = ? AND t.text LIKE ?";
Expand Down
2 changes: 1 addition & 1 deletion plugin.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ license="GPLv3"
support_link = "https://github.com/kent-state-university-libraries/Mirador/issues"
omeka_minimum_version="2.0"
omeka_target_version="2.3"
version="0.1"
version="2.0"
30 changes: 22 additions & 8 deletions views/public/viewer/show.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php global $base_url; ?>
<?php
global $base_url;
$search = get_option('mirador_search');
?>
<!DOCTYPE html>
<html>
<head>
Expand Down Expand Up @@ -33,17 +36,28 @@
canvasID: "<?php echo $base_url; ?>/items/canvas/<?php echo isset($_GET['item_id']) ? $_GET['item_id'] : 0; ?>",
viewType: "ImageView",
displayLayout: false,
sidePanel: true,
sidePanelVisible: true,
sidePanelOptions: {
"tocTabAvailable": false,
"layersTabAvailable": false,
"searchTabAvailable": true
},
sidePanel: <?php echo $search ? 'true' : 'false'; ?>,
sidePanelVisible: false,
<?php if ($search): ?>
sidePanelOptions: {
"searchTabAvailable": true
},
<?php endif; ?>
annotationLayer: true,
overlay: true,
}],
});

// the default search for mirador is a little ugly, so clean it up a bit
// @todo call on the proper mirador event
(function($) {
$(document).ready(function() {
setTimeout(function() {
$('.tabGroup li:last-child').click();
$('.tabGroup, .searchResults label, .js-search-expand').hide();
},1000);
})
})(jQuery);
</script>
</body>
</html>

0 comments on commit 1551fea

Please sign in to comment.