forked from vufind-org/vufind
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for advanced search with Blender.
- Loading branch information
1 parent
b564d95
commit fe4b7b1
Showing
19 changed files
with
289 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
/** | ||
* Blended Search Controller | ||
* | ||
* PHP version 8 | ||
* | ||
* Copyright (C) The National Library of Finland 2023. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* @category VuFind | ||
* @package Controller | ||
* @author Demian Katz <[email protected]> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org Main Site | ||
*/ | ||
|
||
namespace VuFind\Controller; | ||
|
||
use Laminas\ServiceManager\ServiceLocatorInterface; | ||
|
||
/** | ||
* Blended Search Controller | ||
* | ||
* @category VuFind | ||
* @package Controller | ||
* @author Demian Katz <[email protected]> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org Main Site | ||
*/ | ||
class BlenderController extends AbstractSearch | ||
{ | ||
/** | ||
* Constructor | ||
* | ||
* @param ServiceLocatorInterface $sm Service locator | ||
*/ | ||
public function __construct(ServiceLocatorInterface $sm) | ||
{ | ||
$this->searchClassId = 'Blender'; | ||
parent::__construct($sm); | ||
} | ||
|
||
/** | ||
* Is the result scroller active? | ||
* | ||
* @return bool | ||
*/ | ||
protected function resultScrollerActive() | ||
{ | ||
$config = $this->serviceLocator->get(\VuFind\Config\PluginManager::class) | ||
->get('config'); | ||
return isset($config->Record->next_prev_navigation) | ||
&& $config->Record->next_prev_navigation; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
// Load the Blender-specific advanced search and inject it into the | ||
// standard advanced search layout: | ||
$this->buildPageOverride = '/search/advanced/build_page_blender.phtml'; | ||
|
||
ob_start(); | ||
?> | ||
<div id="new_group_template"> | ||
<div class="adv-group adv-group__blender"> | ||
<input type="hidden" name="join" value="AND"> | ||
<input type="hidden" name="bool0[]" value="AND"> | ||
<label class="adv-group-label"><?=$this->transEsc('adv_search_label')?>:</label> | ||
<?php for ($search = 0; $search < 3; $search++): ?> | ||
<?php if ($search === 0): ?> | ||
<div id="new_search_template"> | ||
<?php endif; ?> | ||
<div class="adv-search"> | ||
<input id="search_lookfor0_<?=$search ?>" name="lookfor0[]" class="adv-term-input form-control" type="text" value="" aria-label="<?=$this->transEscAttr('search_terms')?>"> | ||
<select id="search_type0_<?=$search ?>" name="type0[]" class="adv-term-type form-control" aria-label="<?=$this->transEscAttr('Search type')?>"> | ||
<?php foreach ($this->options->getAdvancedHandlers() as $searchVal => $searchDesc): ?> | ||
<option value="<?=$this->escapeHtml($searchVal)?>"><?=$this->transEsc($searchDesc)?></option> | ||
<?php endforeach; ?> | ||
</select> | ||
<a href="#" class="adv-term-remove"> | ||
<?=$this->icon('ui-remove') ?> | ||
<span class="sr-only"><?=$this->transEsc('remove') ?></span> | ||
</a> | ||
</div> | ||
<?php if ($search === 0): ?> | ||
</div> | ||
<?php endif; ?> | ||
<?php endfor; ?> | ||
<span class="search_place_holder"></span> | ||
<div> | ||
<a href="#" class="add_search_link hidden icon-link"> | ||
<?=$this->icon('ui-add', 'search_place_holder icon-link__icon hidden') ?> | ||
<span class="icon-link__label"><?=$this->transEsc('add_search')?></span> | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
<?php | ||
$this->formOverride = ob_get_contents(); | ||
ob_end_clean(); | ||
|
||
$params = (array)$this->vars() + [ | ||
'helpTopics' => ['blender_advsearch' => 'Help with Advanced Search', 'blender' => 'Help with Search Operators'], | ||
]; | ||
echo $this->render('search/advanced/layout.phtml', $params); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?=$this->render('search/home.phtml'); |
File renamed without changes.
35 changes: 35 additions & 0 deletions
35
themes/bootstrap3/templates/search/advanced/build_page_blender.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
$(document).ready(function() { | ||
// Switch and prepare for JS mode | ||
$('#groupPlaceHolder').addClass('hidden'); | ||
$('#new_search_template').addClass('hidden').detach().appendTo('[role="main"]'); | ||
$('#new_search_template').find('.adv-search').removeAttr('id'); | ||
$('#new_search_template').find('input').removeAttr('value'); | ||
$('#new_search_template').find('option').removeAttr('selected'); | ||
$('#new_group_template').addClass('hidden').detach().appendTo('[role="main"]'); | ||
$('#new_group_template .adv-search').remove(); | ||
$('#advSearchForm .no-js').remove(); | ||
$('#groupJoin').remove(); | ||
// Build page | ||
<?php if (isset($this->searchDetails) && is_object($this->searchDetails)): ?> | ||
<?php foreach ($this->searchDetails->getQueries() as $searchGroup): ?> | ||
<?php $i = 0; ?> | ||
<?php foreach ($searchGroup->getQueries() as $search): ?> | ||
<?php if (++$i == 1): ?> | ||
var new_group = addGroup( | ||
'<?=addslashes($search->getString())?>', | ||
'<?=addslashes($search->getHandler())?>' | ||
); | ||
<?php else: ?> | ||
addSearch(new_group, { | ||
term :'<?=addslashes($search->getString())?>', | ||
field:'<?=addslashes($search->getHandler())?>' | ||
}); | ||
<?php endif; ?> | ||
<?php endforeach; ?> | ||
<?php endforeach; ?> | ||
<?php else: ?> | ||
var new_group = addGroup(); | ||
addSearch(new_group); | ||
addSearch(new_group); | ||
<?php endif; ?> | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.