|
| 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> |
0 commit comments