Skip to content

Commit fdaec9d

Browse files
Merge pull request #32 from MITLibraries/post-114
Customize advanced search form
2 parents d2ff645 + 3dd396f commit fdaec9d

8 files changed

Lines changed: 121 additions & 3 deletions

File tree

asset/css/base.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
form#advanced-search {
2+
input,
3+
select {
4+
padding: 1rem;
5+
}
6+
7+
.advanced-search-content {
8+
> div {
9+
border-bottom: 1px solid $gray-l3;
10+
padding: 2rem 0;
11+
}
12+
13+
span.label,
14+
div.field .field-meta label {
15+
font-size: 2rem;
16+
font-weight: bold;
17+
padding-bottom: 1rem;
18+
}
19+
}
20+
21+
#page-actions {
22+
padding-top: 2rem;
23+
}
24+
}

asset/scss/content/_all.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@import "advanced-search";
12
@import "breadcrumbs";
23
@import "navigation";
34
@import "resource-list";

config/theme.ini

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[info]
22
name = "Tesseract"
3-
version = "0.9"
3+
version = "0.10"
44
author = "MIT Libraries"
55
description = "An Omeka S theme to implement the MIT Libraries' branding materials"
66
theme_link = "https://github.com/MITLibraries/mitlibraries-theme-omeka"
@@ -53,6 +53,12 @@ elements.browse_style.options.label = "Browse page layout"
5353
elements.browse_style.options.value_options.list = "List layout"
5454
elements.browse_style.options.value_options.grid = "Grid layout"
5555

56+
elements.no_advanced_search.name = "no_advanced_search"
57+
elements.no_advanced_search.type = "Zend\Form\Element\Checkbox"
58+
elements.no_advanced_search.options.element_group = "browse"
59+
elements.no_advanced_search.options.label = "Suppress advanced search form"
60+
elements.no_advanced_search.options.info = "Optional. If checked, links to the advanced search form will not be displayed. The form itself will still function, however."
61+
5662
elements.no_search.name = "no_search"
5763
elements.no_search.type = "Zend\Form\Element\Checkbox"
5864
elements.no_search.options.element_group = "homepage"

view/common/advanced-search.phtml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
* This template accepts three variables:
4+
* - $query: The query array
5+
* - $resourceType: The resource type; options are item, media, itemSet
6+
* - $partialExcludelist: An array of partials to exclude
7+
*/
8+
$query = isset($query) ? $query : null;
9+
$resourceType = isset($resourceType) ? $resourceType : 'item';
10+
$partialExcludelist = (isset($partialExcludelist) && is_array($partialExcludelist)) ? $partialExcludelist : [];
11+
12+
$this->headLink()->prependStylesheet($this->assetUrl('css/advanced-search.css', 'Omeka'));
13+
$this->headScript()->appendFile($this->assetUrl('js/advanced-search.js', 'Omeka'));
14+
15+
$partials = [];
16+
$addPartial = function ($partial) use (&$partials, $partialExcludelist) {
17+
if (!in_array($partial, $partialExcludelist)) {
18+
// Add the partial if it is not in the exclude list.
19+
$partials[] = $partial;
20+
}
21+
};
22+
23+
$addPartial('common/advanced-search/fulltext');
24+
$addPartial('common/advanced-search/properties');
25+
$addPartial('common/advanced-search/resource-class');
26+
switch ($resourceType) {
27+
case 'item':
28+
$addPartial('common/advanced-search/has-media');
29+
break;
30+
}
31+
if ($this->status()->isSiteRequest()) {
32+
$addPartial('common/advanced-search/resource-template-restrict');
33+
}
34+
$addPartial('common/advanced-search/ids');
35+
$addPartial('common/advanced-search/sort');
36+
37+
$filterResults = $this->trigger(
38+
'view.advanced_search',
39+
[
40+
'query' => $query,
41+
'resourceType' => $resourceType,
42+
'partials' => $partials,
43+
],
44+
true
45+
);
46+
$partials = $filterResults['partials'];
47+
?>
48+
49+
<div class="advanced-search-content">
50+
<?php
51+
foreach ($partials as $partial) {
52+
echo $this->partial($partial, ['query' => $query, 'resourceType' => $resourceType]);
53+
}
54+
?>
55+
</div>
56+
<script>Omeka.prepareSearchForm($('#advanced-search'));</script>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
$value = isset($query['fulltext_search']) ? $query['fulltext_search'] : null;
3+
?>
4+
<div class="field">
5+
<div class="field-meta">
6+
<label for="fulltext_search"><?php echo $this->translate('Search full-text'); ?></label>
7+
</div>
8+
<div class="inputs">
9+
<textarea id="fulltext_search" rows="4" name="fulltext_search" class="field field-text field-textarea wide"><?php echo $this->escapeHtml($value); ?></textarea>
10+
</div>
11+
</div>

view/omeka/site/item/browse.phtml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ $filterLocale = (bool) $this->siteSetting('filter_locale_values');
88
$lang = $this->lang();
99
$valueLang = $filterLocale ? [$lang, ''] : null;
1010

11+
$no_advanced_search = $this->themeSetting('no_advanced_search');
12+
1113
$browse_style = $this->themeSetting('browse_style');
1214
if (!isset($browse_style)) {
1315
$browse_style = "list";
@@ -39,7 +41,10 @@ endif;
3941
<div class="browse-controls">
4042
<span class="browse-label">Browse by:</span><?php echo $this->browse()->renderSortSelector('items'); ?>
4143
</div>
42-
<p><?php echo $this->hyperlink($translate('Advanced search'), $this->url('site/resource', ['controller' => 'item', 'action' => 'search'], ['query' => $query], true), ['class' => 'advanced-search']); ?></p>
44+
45+
<?php if (!$no_advanced_search) { ?>
46+
<p><?php echo $this->hyperlink($translate('Advanced search'), $this->url('site/resource', ['controller' => 'item', 'action' => 'search'], ['query' => $query], true), ['class' => 'advanced-search']); ?></p>
47+
<?php } ?>
4348

4449
<?php $this->trigger('view.browse.before'); ?>
4550
<ul class="resource-list <?php echo $browse_style; ?>">

view/omeka/site/item/search.phtml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
$translate = $this->plugin('translate');
3+
$this->htmlElement('body')->appendAttribute('class', 'items search');
4+
?>
5+
6+
<h2><?php echo $translate('Advanced item search'); ?></h2>
7+
<form id="advanced-search" method="get" action="<?php echo $this->escapeHtml($this->url(null, ['action' => 'browse'], true)); ?>">
8+
<?php echo $this->partial(
9+
'common/advanced-search',
10+
['query' => $this->params()->fromQuery(), 'resourceType' => 'item']
11+
); ?>
12+
<div id="page-actions">
13+
<input type="submit" name="submit" value="<?php echo $this->escapeHtml($translate('Search')); ?>" class="btn button-primary">
14+
</div>
15+
</form>

0 commit comments

Comments
 (0)