diff --git a/README.md b/README.md index 5eda152..ba33c17 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ composer require drupal/search_api_solr "^4.1" composer require drupal/search_api "^1.5" ``` -However, for reference, `islandora_advanced_search` requires the following +However, for reference, `advanced_search` requires the following drupal modules: - [facets](https://www.drupal.org/project/facets) @@ -53,7 +53,7 @@ To download/enable just this module, use the following from the command line: ```bash composer require islandora/islandora -drush en islandora_advanced_search +drush en advanced_search ``` ## Configuration @@ -61,7 +61,7 @@ drush en islandora_advanced_search You can set the following configuration at `admin/config/islandora/advanced_search`: -![image](./docs/islandora_advanced_search_settings.png) +![image](./docs/advanced_search_settings.png) ## Configuring Solr diff --git a/islandora_advanced_search.info.yml b/advanced_search.info.yml similarity index 100% rename from islandora_advanced_search.info.yml rename to advanced_search.info.yml diff --git a/advanced_search.libraries.yml b/advanced_search.libraries.yml new file mode 100644 index 0000000..650343e --- /dev/null +++ b/advanced_search.libraries.yml @@ -0,0 +1,17 @@ +advanced.search.admin: + js: + js/advanced_search.admin.js: {} + dependencies: + - core/drupal.tabledrag + +advanced.search.form: + js: + js/advanced_search.form.js: {} + css: + component: + css/advanced_search.form.css: {} + +advanced.search.pager: + css: + component: + css/advanced_search.pager.css: {} diff --git a/islandora_advanced_search.links.menu.yml b/advanced_search.links.menu.yml similarity index 63% rename from islandora_advanced_search.links.menu.yml rename to advanced_search.links.menu.yml index 6aeff7c..faae707 100644 --- a/islandora_advanced_search.links.menu.yml +++ b/advanced_search.links.menu.yml @@ -1,6 +1,6 @@ -islandora_advanced_search.settings: +advanced_search.settings: title: 'Advanced Search Settings' - route_name: islandora_advanced_search.settings + route_name: advanced_search.settings description: 'Configure Islandora Advanced Search settings' parent: system.admin_config_islandora weight: 99 diff --git a/islandora_advanced_search.module b/advanced_search.module similarity index 82% rename from islandora_advanced_search.module rename to advanced_search.module index 635bc51..9e0e183 100644 --- a/islandora_advanced_search.module +++ b/advanced_search.module @@ -2,7 +2,7 @@ /** * @file - * Contains islandora_advanced_search.module. + * Contains advanced_search.module. * * This file is part of the Islandora Project. * @@ -15,9 +15,9 @@ use Drupal\block\Entity\Block; use Drupal\Component\Utility\Unicode; use Drupal\Core\Form\FormStateInterface; -use Drupal\islandora_advanced_search\AdvancedSearchQuery; -use Drupal\islandora_advanced_search\Form\SettingsForm; -use Drupal\islandora_advanced_search\Utilities; +use Drupal\advanced_search\AdvancedSearchQuery; +use Drupal\advanced_search\Form\SettingsForm; +use Drupal\advanced_search\Utilities; use Drupal\search_api\Query\QueryInterface as DrupalQueryInterface; use Drupal\views\ViewExecutable; use Solarium\Core\Query\QueryInterface as SolariumQueryInterface; @@ -25,7 +25,7 @@ use Solarium\Core\Query\QueryInterface as SolariumQueryInterface; /** * Implements hook_theme(). */ -function islandora_advanced_search_theme() { +function advanced_search_theme() { return [ 'facets_item_list__include_exclude_links' => [ 'template' => 'facets/facets-item-list--include-exclude-links', @@ -45,10 +45,10 @@ function islandora_advanced_search_theme() { /** * Implements hook_library_info_alter(). */ -function islandora_advanced_search_library_info_alter(&$libraries, $extension) { +function advanced_search_library_info_alter(&$libraries, $extension) { if ($extension == 'facets') { // Override facets module javascript with customizations. - $path = '/' . drupal_get_path('module', 'islandora_advanced_search') . '/js/facets'; + $path = '/' . drupal_get_path('module', 'advanced_search') . '/js/facets'; $libraries['soft-limit']['js'] = [ "$path/soft-limit.js" => [], ]; @@ -61,7 +61,7 @@ function islandora_advanced_search_library_info_alter(&$libraries, $extension) { /** * Implements hook_search_api_solr_converted_query_alter(). */ -function islandora_advanced_search_search_api_solr_converted_query_alter(SolariumQueryInterface $solarium_query, DrupalQueryInterface $search_api_query) { +function advanced_search_search_api_solr_converted_query_alter(SolariumQueryInterface $solarium_query, DrupalQueryInterface $search_api_query) { // We must modify the query itself rather than the representation the // search_api presents as it is not possible to use the 'OR' operator // with it as it converts conditions into separate filter queries. @@ -74,7 +74,7 @@ function islandora_advanced_search_search_api_solr_converted_query_alter(Solariu /** * Implements hook_form_form_id_alter(). */ -function islandora_advanced_search_form_block_form_alter(&$form, FormStateInterface $form_state, $form_id) { +function advanced_search_form_block_form_alter(&$form, FormStateInterface $form_state, $form_id) { // Islandora removes this condition from the form, but we require it. // So we can show blocks for nodes which belong to specific models. // Allowing us to add a block for collections only. @@ -104,7 +104,7 @@ function islandora_advanced_search_form_block_form_alter(&$form, FormStateInterf /** * Implements hook_preprocess_block__facets_summary(). */ -function islandora_advanced_search_preprocess_block__facets_summary(&$variables) { +function advanced_search_preprocess_block__facets_summary(&$variables) { // Copy data-attributes to the content as the javascript expects // there to be no elements between the data declaration and the // content of the block. @@ -118,7 +118,7 @@ function islandora_advanced_search_preprocess_block__facets_summary(&$variables) /** * Implements hook_preprocess_preprocess_views_view(). */ -function islandora_advanced_search_preprocess_views_view(&$variables) { +function advanced_search_preprocess_views_view(&$variables) { /** @var \Drupal\views\ViewExecutable $view */ $view = &$variables['view']; $views = Utilities::getPagerViewDisplays(); @@ -128,7 +128,7 @@ function islandora_advanced_search_preprocess_views_view(&$variables) { // Toggle between 'list' and 'grid' display depending on url parameter. $format = \Drupal::request()->query->get('display') ?? 'grid'; $variables['attributes']['class'][] = "view-{$format}"; - $view->element['#attached']['library'][] = 'islandora_advanced_search/advanced.search.pager'; + $view->element['#attached']['library'][] = 'advanced_search/advanced.search.pager'; } $view = &$variables['view']; } @@ -136,7 +136,7 @@ function islandora_advanced_search_preprocess_views_view(&$variables) { /** * Implements hook_views_pre_view(). */ -function islandora_advanced_search_views_pre_view(ViewExecutable $view, $display_id, array &$args) { +function advanced_search_views_pre_view(ViewExecutable $view, $display_id, array &$args) { // Allow for recursive searches by disabling contextual filter. $advanced_search_query = new AdvancedSearchQuery(); $advanced_search_query->alterView(\Drupal::request(), $view, $display_id); @@ -145,7 +145,7 @@ function islandora_advanced_search_views_pre_view(ViewExecutable $view, $display /** * Implements hook_preprocess_facets_summary_item_list(). */ -function islandora_advanced_search_preprocess_facets_summary_item_list(&$variables) { +function advanced_search_preprocess_facets_summary_item_list(&$variables) { foreach ($variables['items'] as &$item) { $item['attributes']['class'][] = 'facet-summary-item'; } @@ -154,7 +154,7 @@ function islandora_advanced_search_preprocess_facets_summary_item_list(&$variabl /** * Implements hook_preprocess_facets_item_list(). */ -function islandora_advanced_search_preprocess_facets_item_list(&$variables) { +function advanced_search_preprocess_facets_item_list(&$variables) { $widget = $variables['facet']->getWidget(); $soft_limit = $widget['config']['soft_limit']; // Break into two groups less / more which can display be toggled as a single @@ -168,7 +168,7 @@ function islandora_advanced_search_preprocess_facets_item_list(&$variables) { /** * Implements hook_preprocess_facets_result_item(). */ -function islandora_advanced_search_preprocess_facets_result_item(&$variables) { +function advanced_search_preprocess_facets_result_item(&$variables) { $settings = \Drupal::config(SettingsForm::CONFIG_NAME); $length = $settings->get(SettingsForm::FACET_TRUNCATE); if (is_numeric($length)) { diff --git a/islandora_advanced_search.routing.yml b/advanced_search.routing.yml similarity index 59% rename from islandora_advanced_search.routing.yml rename to advanced_search.routing.yml index ebbaedc..6329d05 100755 --- a/islandora_advanced_search.routing.yml +++ b/advanced_search.routing.yml @@ -1,15 +1,15 @@ -islandora_advanced_search.ajax.blocks: +advanced_search.ajax.blocks: path: '/islandora-advanced-search-ajax-blocks' defaults: - _controller: '\Drupal\islandora_advanced_search\Controller\AjaxBlocksController::respond' + _controller: '\Drupal\advanced_search\Controller\AjaxBlocksController::respond' requirements: # Allow public access to search blocks. _access: 'TRUE' -islandora_advanced_search.settings: +advanced_search.settings: path: '/admin/config/search/advanced' defaults: - _form: '\Drupal\islandora_advanced_search\Form\SettingsForm' + _form: '\Drupal\advanced_search\Form\SettingsForm' _title: 'Islandora Advanced Search Settings' requirements: _permission: 'administer site configuration' diff --git a/css/islandora_advanced_search.form.css b/css/advanced_search.form.css similarity index 100% rename from css/islandora_advanced_search.form.css rename to css/advanced_search.form.css diff --git a/css/islandora_advanced_search.pager.css b/css/advanced_search.pager.css similarity index 67% rename from css/islandora_advanced_search.pager.css rename to css/advanced_search.pager.css index dd100c3..5a5afcb 100644 --- a/css/islandora_advanced_search.pager.css +++ b/css/advanced_search.pager.css @@ -1,8 +1,8 @@ -.islandora_advanced_search_result_pager .pager__summary { +.advanced_search_result_pager .pager__summary { font-weight: 700; } -.islandora_advanced_search_result_pager .pager__group { +.advanced_search_result_pager .pager__group { margin: 1.25rem 0; padding: 1rem 0; border-top: 1px solid; @@ -15,32 +15,32 @@ } @media all and (min-width: 45.063em) { - .islandora_advanced_search_result_pager .pager__group { + .advanced_search_result_pager .pager__group { justify-content: flex-end; } - .islandora_advanced_search_result_pager .pager__group > * { + .advanced_search_result_pager .pager__group > * { margin: 0.47214rem 0 0.47214rem 2.61803rem; } - .islandora_advanced_search_result_pager .pager__group > *:first-child { + .advanced_search_result_pager .pager__group > *:first-child { margin-left: 0; } } -.islandora_advanced_search_result_pager .pager__group > * { +.advanced_search_result_pager .pager__group > * { margin: 0.47214rem 2rem 0.47214rem 0; } -.islandora_advanced_search_result_pager .pager__group > *:last-child { +.advanced_search_result_pager .pager__group > *:last-child { margin-right: 0; } -.islandora_advanced_search_result_pager .pager__group .item-list__list, -.islandora_advanced_search_result_pager .pager__group .item-list__title, -.islandora_advanced_search_result_pager .pager__group .item-list__item { +.advanced_search_result_pager .pager__group .item-list__list, +.advanced_search_result_pager .pager__group .item-list__title, +.advanced_search_result_pager .pager__group .item-list__item { display: inline; } -.islandora_advanced_search_result_pager .pager__group .item-list__title { +.advanced_search_result_pager .pager__group .item-list__title { font-size: initial; margin: 0.25rem; } @@ -112,16 +112,16 @@ /* generalizing */ -.islandora_advanced_search_result_pager .pager__group .pager { +.advanced_search_result_pager .pager__group .pager { display: none; } -.islandora_advanced_search_result_pager .pager__group > * { +.advanced_search_result_pager .pager__group > * { margin: 0.47214rem 2rem 0.47214rem 0; display:flex; } -.islandora_advanced_search_result_pager .pager__group > *:last-child { +.advanced_search_result_pager .pager__group > *:last-child { margin-right: 0; } @@ -135,7 +135,7 @@ padding-right: 0 !important; } -.islandora_advanced_search_result_pager .pager__group nav { +.advanced_search_result_pager .pager__group nav { display: none; } diff --git a/islandora_advanced_search.libraries.yml b/islandora_advanced_search.libraries.yml deleted file mode 100644 index 821f0ec..0000000 --- a/islandora_advanced_search.libraries.yml +++ /dev/null @@ -1,17 +0,0 @@ -advanced.search.admin: - js: - js/islandora_advanced_search.admin.js: {} - dependencies: - - core/drupal.tabledrag - -advanced.search.form: - js: - js/islandora_advanced_search.form.js: {} - css: - component: - css/islandora_advanced_search.form.css: {} - -advanced.search.pager: - css: - component: - css/islandora_advanced_search.pager.css: {} diff --git a/js/islandora_advanced_search.admin.js b/js/advanced_search.admin.js similarity index 97% rename from js/islandora_advanced_search.admin.js rename to js/advanced_search.admin.js index eb8796c..e85a328 100644 --- a/js/islandora_advanced_search.admin.js +++ b/js/advanced_search.admin.js @@ -1,8 +1,8 @@ -//# sourceURL=modules/contrib/islandora_advanced_search/js/islandora-advanced-search.admin.js +//# sourceURL=modules/contrib/advanced_search/js/islandora-advanced-search.admin.js /** * @file * Largely based on core/modules/blocks/js/blocks.js - * + * * This file allows for moving rows between two regions in a table and have the * 'region' field update appropriately. */ @@ -110,4 +110,4 @@ }); } }; -})(jQuery, window, Drupal); \ No newline at end of file +})(jQuery, window, Drupal); diff --git a/js/islandora_advanced_search.form.js b/js/advanced_search.form.js similarity index 88% rename from js/islandora_advanced_search.form.js rename to js/advanced_search.form.js index f81b350..7e45dda 100644 --- a/js/islandora_advanced_search.form.js +++ b/js/advanced_search.form.js @@ -1,4 +1,4 @@ -//# sourceURL=modules/contrib/islandora/modules/islandora_advanced_search/js/islandora-advanced-search.form.js +//# sourceURL=modules/contrib/islandora/modules/advanced_search/js/islandora-advanced-search.form.js /** * @file * Handles Ajax submission / updating form action on url change, etc. @@ -81,10 +81,10 @@ return window.location.href.split("?")[0] + "?" + $.param(params); } - Drupal.behaviors.islandora_advanced_search_form = { + Drupal.behaviors.advanced_search_form = { attach: function (context, settings) { - if (settings.islandora_advanced_search_form.id !== 'undefined') { - const $form = $('form#' + settings.islandora_advanced_search_form.id).once(); + if (settings.advanced_search_form.id !== 'undefined') { + const $form = $('form#' + settings.advanced_search_form.id).once(); if ($form.length > 0) { window.addEventListener("pushstate", function (e) { $form.attr('action', window.location.pathname + window.location.search); @@ -96,25 +96,25 @@ }); // Prevent form submission and push state instead. // - // Logic server side / client side should match to generate the + // Logic server side / client side should match to generate the // appropriate URL with javascript enabled or disable. // // If a route is set for the view display that this form is derived // from, and we are not on the same page as that route, rely on the - // normal submit which will redirect to the appropriate page. - if (!settings.islandora_advanced_search_form.redirect) { + // normal submit which will redirect to the appropriate page. + if (!settings.advanced_search_form.redirect) { $form.submit(function (e) { e.preventDefault(); e.stopPropagation(); const inputs = $form.serializeArray(); - const href = url(inputs, settings.islandora_advanced_search_form); + const href = url(inputs, settings.advanced_search_form); window.history.pushState(null, document.title, href); }); } // Reset should trigger refresh of AJAX Blocks / Views. $form.find('input[data-drupal-selector = "edit-reset"]').mousedown(function (e) { const inputs = []; - const href = url(inputs, settings.islandora_advanced_search_form); + const href = url(inputs, settings.advanced_search_form); window.history.pushState(null, document.title, href); }); } diff --git a/js/facets/facets-views-ajax.js b/js/facets/facets-views-ajax.js index d5c879d..e8c9eb7 100644 --- a/js/facets/facets-views-ajax.js +++ b/js/facets/facets-views-ajax.js @@ -1,4 +1,4 @@ -//# sourceURL=modules/contrib/islandora/modules/islandora_advanced_search/js/facets/facets-view.ajax.js +//# sourceURL=modules/contrib/islandora/modules/advanced_search/js/facets/facets-view.ajax.js /** * @file * Overrides the facets-view-ajax.js behavior from the 'facets' module. @@ -132,7 +132,7 @@ window.history.pushState(null, document.title, $(this).attr("href")); }); - + /* digitalutsc added */ $('.pager__sort select[name="order"]') .once() diff --git a/js/facets/soft-limit.js b/js/facets/soft-limit.js index a81a267..9f1191b 100644 --- a/js/facets/soft-limit.js +++ b/js/facets/soft-limit.js @@ -1,4 +1,4 @@ -//# sourceURL=modules/contrib/islandora/modules/islandora_advanced_search/js/facets/soft-limit.js +//# sourceURL=modules/contrib/islandora/modules/advanced_search/js/facets/soft-limit.js /** * @file * Overrides the soft-limit.js behavior from the 'facets' module. diff --git a/src/AdvancedSearchQuery.php b/src/AdvancedSearchQuery.php index 33606e3..02900f4 100644 --- a/src/AdvancedSearchQuery.php +++ b/src/AdvancedSearchQuery.php @@ -1,13 +1,13 @@ getServerInstance()->getBackend(); $language_ids = $search_api_query->getLanguages(); $field_mapping = $backend->getSolrFieldNamesKeyedByLanguage($language_ids, $index); - + // disable for Lucene and wildcard //$q[] = "{!boost b=boost_document}"; - + // To support negative queries we must first bring in all documents. $q[] = $this->negativeQuery($terms) ? "*:*" : ""; $term = array_shift($terms); @@ -197,7 +197,7 @@ class AdvancedSearchQuery { $dismax->setQueryFields($query_fields); } $solarium_query->setQuery($q); - } + } } /** diff --git a/src/AdvancedSearchQueryTerm.php b/src/AdvancedSearchQueryTerm.php index ebc57fa..65ef96c 100644 --- a/src/AdvancedSearchQueryTerm.php +++ b/src/AdvancedSearchQueryTerm.php @@ -1,8 +1,8 @@ getRouteName($form_state); $requires_redirect = $route_name ? $this->currentRouteMatch->getRouteName() !== $route_name : FALSE; - $form['#attached']['library'][] = 'islandora_advanced_search/advanced.search.form'; - $form['#attached']['drupalSettings']['islandora_advanced_search_form'] = [ + $form['#attached']['library'][] = 'advanced_search/advanced.search.form'; + $form['#attached']['drupalSettings']['advanced_search_form'] = [ 'id' => Html::getId($this->getFormId()), 'redirect' => $requires_redirect, 'query_parameter' => AdvancedSearchQuery::getQueryParameter(), diff --git a/src/Form/SearchForm.php b/src/Form/SearchForm.php index f51f8d9..5a6ada7 100644 --- a/src/Form/SearchForm.php +++ b/src/Form/SearchForm.php @@ -1,6 +1,6 @@ configuration[self::SETTING_FIELDS] as $identifier) { $configured_fields[$identifier] = $fields[$identifier]; } - return $this->formBuilder->getForm('Drupal\islandora_advanced_search\Form\AdvancedSearchForm', $this->view, $this->display, $configured_fields, $this->configuration[self::SETTING_CONTEXTUAL_FILTER]); + return $this->formBuilder->getForm('Drupal\advanced_search\Form\AdvancedSearchForm', $this->view, $this->display, $configured_fields, $this->configuration[self::SETTING_CONTEXTUAL_FILTER]); } /** diff --git a/src/Plugin/Block/AdvancedSearchBlockDeriver.php b/src/Plugin/Block/AdvancedSearchBlockDeriver.php index d4441e9..c588c98 100644 --- a/src/Plugin/Block/AdvancedSearchBlockDeriver.php +++ b/src/Plugin/Block/AdvancedSearchBlockDeriver.php @@ -1,6 +1,6 @@ getForm('Drupal\islandora_advanced_search\Form\SearchForm'); + return \Drupal::formBuilder()->getForm('Drupal\advanced_search\Form\SearchForm'); } } diff --git a/src/Plugin/Block/SearchResultsPagerBlock.php b/src/Plugin/Block/SearchResultsPagerBlock.php index f2e4a17..6ca6ce8 100644 --- a/src/Plugin/Block/SearchResultsPagerBlock.php +++ b/src/Plugin/Block/SearchResultsPagerBlock.php @@ -1,12 +1,12 @@ [ 'drupalSettings' => [ - 'islandora_advanced_search_pager_views_ajax' => [ + 'advanced_search_pager_views_ajax' => [ $id => [ 'view_id' => $view_id, 'current_display_id' => $display_id, @@ -91,7 +91,7 @@ class SearchResultsPagerBlock extends BlockBase implements ContainerFactoryPlugi ], ], '#attributes' => [ - 'class' => ['islandora_advanced_search_result_pager'], + 'class' => ['advanced_search_result_pager'], 'data-drupal-pager-id' => $id, ], 'result_summary' => $this->buildResultsSummary($view_executable), diff --git a/src/Plugin/Block/SearchResultsPagerBlockDeriver.php b/src/Plugin/Block/SearchResultsPagerBlockDeriver.php index c1378fa..d8d811a 100644 --- a/src/Plugin/Block/SearchResultsPagerBlockDeriver.php +++ b/src/Plugin/Block/SearchResultsPagerBlockDeriver.php @@ -1,6 +1,6 @@