Skip to content

Commit

Permalink
Merge pull request vufind-org#14 from samuli/search-tabs
Browse files Browse the repository at this point in the history
[ALLI-3219] Search tabs.
  • Loading branch information
EreMaijala committed Feb 17, 2015
2 parents fcdafb2 + f6e4a47 commit 3a90775
Show file tree
Hide file tree
Showing 12 changed files with 8,425 additions and 13 deletions.
5 changes: 2 additions & 3 deletions local/config/finna/config.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -1045,9 +1045,8 @@ max_tag_length = 64
; between search modules. Keys are search backend names, values are labels for use in
; the user interface (subject to translation).
[SearchTabs]
;Solr = Catalog
;Summon = Summon
;WorldCat = WorldCat
;Solr = tabs_local
;Primo = tabs_pci

; Uncomment portions of this section to label searches from particular sources in the
; search history display. Keys are search backend names, values are labels for use in
Expand Down
8 changes: 4 additions & 4 deletions local/config/finna/searches.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ Title = Title
;JournalTitle = "Journal Title"
Author = Author
Subject = Subject
CallNumber = "Call Number"
Classification = Classification
ISN = "ISBN/ISSN"
tag = Tag
;CallNumber = "Call Number"
;Classification = Classification
;ISN = "ISBN/ISSN"
;tag = Tag

; This section defines which search options will be included on the advanced
; search screen. All the notes above [Basic_Searches] also apply here.
Expand Down
4 changes: 4 additions & 0 deletions local/languages/en-gb.ini
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ search_history_desc = "Your session-specific search history. To save your search
; Content pages
Privacy & Terms = "Privacy & terms"

; Tabs
tabs_local = "TODO Kirjaston kokoelmat"
tabs_pci = "TODO Ulkomainen aineisto"

; Collection and Hierarchy functions
Collections = Collections
collection_empty = "The collection does not contain records."
Expand Down
5 changes: 5 additions & 0 deletions local/languages/fi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Playing Time = "Kesto"
Presenters = "Esittäjät"
See Also = "Katso myös"
Sector = "Toimiala"
Title = "Otsikko"
Title and Authors = "Nimeke ja tekijät"
To the record = "Tietueeseen"
Unit ID = "Tunniste"
Expand All @@ -42,6 +43,10 @@ Archive_plural = Arkistot
Library_plural = Kirjastot
Museum_plural = Museot

; Tabs
tabs_local = "Kirjaston kokoelmat"
tabs_pci = "Ulkomainen aineisto"

; Collection and Hierarchy functions
Collections = Kokoelmat
collection_empty = "Kokoelmaan ei sisälly tietueita."
Expand Down
4 changes: 4 additions & 0 deletions local/languages/sv.ini
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ search_history_desc = "Din sökhistorik enligt session. Om du loggar in kan du s
; Content pages
Privacy & Terms = "Sekretess och villkor"

; Tabs
tabs_local = "TODO Kirjaston kokoelmat"
tabs_pci = "TODO Ulkomainen aineisto"

; Collection and Hierarchy functions, TODO translations
Collections = Samlingar
collection_empty = "Samlingen innehåller inga poster."
Expand Down
8,132 changes: 8,130 additions & 2 deletions themes/finna/css/finna.css

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions themes/finna/less/bootstrap.less
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ section.main.template-dir-search.template-name-results > .container, section.mai
}
.finna-main-header {
background: @finna-main-header-background;
padding: 15px 0 15px 0;
& .container > div {
padding-left: 0;
}
}
.record-view-header {
background: @finna-record-header-background;
Expand Down
1 change: 1 addition & 0 deletions themes/finna/less/bootstrap/bootstrap.less
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@
// Finna extensions
@import "image-popup.less";
@import "finnaicons.less";
@import "tabs.less";
37 changes: 37 additions & 0 deletions themes/finna/less/tabs.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.finna-main-tabs {
background-color: @brand-secondary;
margin-bottom: 30px;

& ul.nav-tabs {
border-bottom: none;
margin: 0;

> li {
color: #fff;
margin: 0 4px 0 0;

> a {
background-color: @brand-primary;
padding: 10px 15px 10px 15px;
margin-bottom: 0;
border: 0;
border-radius: 0;
font-size: 1em;
font-weight: bold;
color: #fff;
transition: none;
}

&.active {
> a {
background-color: #fff;
color: #4d4d4d;
border: none;
}
}
}
}
}
.main.template-name-advanced .finna-main-tabs {
padding-top: 25px;
}
126 changes: 126 additions & 0 deletions themes/finna/templates/primo/advanced.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?
// Set page title.
$this->headTitle($this->translate('Advanced Search'));

// Disable top search box -- this page has a special layout.
$this->layout()->searchbox = false;

// Set up breadcrumbs:
$this->layout()->breadcrumbs = '<li class="active">' . $this->transEsc('Advanced Search') . '</li>';

// Set up saved search details:
if (isset($this->saved) && is_object($this->saved)) {
$searchDetails = $this->saved->getParams()->getQuery();
if ($searchDetails instanceof \VuFindSearch\Query\Query) {
// Not an advanced query -- ignore it.
$searchDetails = $groups = false;
} else {
$groups = $searchDetails->getQueries();
}
$hasDefaultsApplied = $this->saved->getParams()->hasDefaultsApplied();
$searchFilters = $this->saved->getParams()->getFilterList();
} else {
$hasDefaultsApplied = $searchDetails = $searchFilters = $groups = false;
}
?>
<form id="advSearchForm" name="searchForm" method="get" action="<?=$this->url($this->options->getSearchAction())?>" class="form-horizontal">
<input type="hidden" name="join" value="AND" />
<div class="row">
<div class="<?=$this->layoutClass('mainbody')?>">
<?
$this->searchType = 'advanced';
$this->layout()->finnaMainTabs = $this->render('search/searchTabs');
?>
<h3><?=$this->transEsc('Advanced Search')?></h3>
<? /* fallback to a fixed set of search groups/fields if JavaScript is turned off */ ?>
<? if ($groups !== false) {
$numGroups = count($groups);
}
if (!isset($numGroups) || $numGroups < 3) {
$numGroups = 1;
}
?>
<? for ($i = 0; $i < $numGroups; $i++): ?>
<input type="hidden" name="bool<?=$i?>[]" value="AND" />
<div class="group well row" id="group<?=$i?>">
<div class="col-sm-2" id="group<?=$i?>SearchHolder"><label><?=$this->transEsc("adv_search_label")?>:</label></div>
<div class="col-sm-10">
<?
if (isset($groups[$i])) {
$currentGroup = $groups[$i]->getQueries();
$numRows = count($currentGroup);
} else {
$currentGroup = false;
}
if (!isset($numRows) || $numRows < 3) {
$numRows = 3;
}
?>
<? for ($j = 0; $j < $numRows; $j++): ?>
<? $currRow = isset($currentGroup[$j]) ? $currentGroup[$j] : false; ?>
<div class="row">
<div class="col-sm-3">
<select id="search_type<?=$i?>_<?=$j?>" name="type<?=$i?>[]" class="form-control">
<? foreach ($this->options->getAdvancedHandlers() as $searchVal => $searchDesc): ?>
<option value="<?=$this->escapeHtmlAttr($searchVal)?>"<?=($currRow && $currRow->getHandler() == $searchVal)?' selected="selected"':''?>><?=$this->transEsc($searchDesc)?></option>
<? endforeach; ?>
</select>
</div>
<div class="col-sm-3">
<select name="op<?=$i?>[]" id="searchForm_op<?=$i?>_<?=$j?>" class="form-control">
<? foreach ($this->options->getAdvancedOperators() as $searchVal => $searchDesc): ?>
<option value="<?=$this->escapeHtmlAttr($searchVal)?>"<?=($currRow && $currRow->getOperator() == $searchVal)?' selected="selected"':''?>><?=$this->transEsc($searchDesc)?></option>
<? endforeach; ?>
</select>
</div>
<div class="col-sm-6">
<input id="search_lookfor<?=$i?>_<?=$j?>" type="text" value="<?=$currRow?$this->escapeHtmlAttr($currRow->getString()):''?>" size="30" name="lookfor<?=$i?>[]" class="form-control"/>
</div>
</div>
<? endfor; ?>
</div>
</div>
<? endfor; ?>
<? $lastSort = $this->options->getLastSort(); ?>
<? if (!empty($lastSort)): ?>
<input type="hidden" name="sort" value="<?=$this->escapeHtmlAttr($lastSort)?>" />
<? endif; ?>
<input type="submit" class="btn btn-primary" name="submit" value="<?=$this->transEsc("Find")?>"/>
</div>

<div class="<?=$this->layoutClass('sidebar')?>">
<? if ($hasDefaultsApplied): ?>
<input type="hidden" name="dfApplied" value="1" />
<? endif ?>
<? if (!empty($searchFilters)): ?>
<h4><?=$this->transEsc("adv_search_filters")?></h4>
<ul class="list-group">
<li class="list-group-item">
<div class="checkbox">
<label>
<?=$this->transEsc("adv_search_select_all")?>
<input type="checkbox" checked="checked" class="checkbox-select-all" />
</label>
</div>
</li>
</ul>
<? foreach ($searchFilters as $field => $data): ?>
<div>
<ul class="list-group">
<li class="list-group-item title"><?=$this->transEsc($field)?></li>
<? foreach ($data as $value): ?>
<li class="list-group-item">
<div class="checkbox">
<label>
<input type="checkbox" class="checkbox-select-item" checked="checked" name="filter[]" value='<?=$this->escapeHtmlAttr($value['field'])?>:"<?=$this->escapeHtmlAttr($value['value'])?>"' /> <?=$this->escapeHtml($value['displayText'])?>
</label>
</div>
</li>
<? endforeach; ?>
</ul>
</div>
<? endforeach; ?>
<? endif; ?>
</div>
</div>
</form>
99 changes: 99 additions & 0 deletions themes/finna/templates/search/advanced/layout.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?
// Set page title.
$this->headTitle($this->translate('Advanced Search'));

// Disable top search box -- this page has a special layout.
$this->layout()->searchbox = false;

// Set up breadcrumbs:
$this->layout()->breadcrumbs = '<li>' . $this->getLastSearchLink($this->transEsc('Search'), '', '</li> ')
. '<li class="active">' . $this->transEsc('Advanced') . '</li>';

// Set up saved search details:
if (isset($this->saved) && is_object($this->saved)) {
$searchDetails = $this->saved->getParams()->getQuery();
if ($searchDetails instanceof \VuFindSearch\Query\Query) {
// Not an advanced query -- ignore it.
$searchDetails = $groups = false;
} else {
$groups = $searchDetails->getQueries();
}
$hasDefaultsApplied = $this->saved->getParams()->hasDefaultsApplied();
$searchFilters = $this->saved->getParams()->getFilterList();
} else {
$hasDefaultsApplied = $searchDetails = $searchFilters = $groups = false;
}

// Set up Javascript:
// Step 1: Define our search arrays so they are usuable in the javascript
$this->headScript()->appendScript($this->render('search/advanced/globals.phtml'));
// Step 2: Call the javascript to make use of the above
$this->headScript()->appendFile(
isset($this->advancedSearchJsOverride) ? $this->advancedSearchJsOverride : 'advanced_search.js'
);
// Step 3: Build the page
$this->headScript()->appendScript(
$this->partial(
isset($this->buildPageOverride) ? $this->buildPageOverride : 'search/advanced/build_page.phtml',
array('searchDetails' => $searchDetails)
)
);
?>

<?=$this->flashmessages()?>
<form role="search" name="searchForm" id="advSearchForm" method="get" action="<?=$this->url($this->options->getSearchAction())?>">
<div class="row">
<div class="<?=$this->layoutClass('mainbody')?>">
<input type="hidden" name="sort" value="relevance">
<?
$this->searchType = 'advanced';
$this->layout()->finnaMainTabs = $this->render('search/searchTabs');
?>
<div class="clearfix">
<p class="lead pull-left"><?=$this->transEsc('Advanced Search')?></p>
<div id="groupJoin" class="form-inline pull-right hidden">
<label for="groupJoinOptions"><?=$this->transEsc("search_match")?>:</label>
<select id="groupJoinOptions" name="join" class="form-control">
<option value="AND"<? if($searchDetails && $searchDetails->getOperator()=='ALL'):?> selected<?endif?>><?= $this->transEsc('group_AND') ?></option>
<option value="OR"<? if($searchDetails && $searchDetails->getOperator()=='OR'):?> selected<?endif?>><?= $this->transEsc('group_OR') ?></option>
</select>
</div>
</div>
<span id="groupPlaceHolder">
<i class="fa fa-plus-circle"></i> <a href="#" onClick="addGroup()"><?= $this->transEsc('add_search_group') ?></a>
</span>
<input class="btn btn-primary pull-right" type="submit" value="<?= $this->transEsc('Find')?>">
<? if (isset($this->extraAdvancedControls)): ?>
<?=$this->extraAdvancedControls ?>
<input class="btn btn-primary pull-right" type="submit" value="<?= $this->transEsc('Find')?>"/>
<? endif; ?>
</div>

<div class="<?=$this->layoutClass('sidebar')?>">
<? if ($hasDefaultsApplied): ?>
<input type="hidden" name="dfApplied" value="1" />
<? endif ?>
<? if (!empty($searchFilters)): ?>
<h4><?=$this->transEsc("adv_search_filters")?></h4>
<ul class="list-group">
<label class="list-group-item checkbox"><?=$this->transEsc("adv_search_select_all")?> <input type="checkbox" checked="checked" class="checkbox-select-all"/></label>
</ul>
<? foreach ($searchFilters as $field => $data): ?>
<ul class="list-group">
<li class="list-group-item title"><?=$this->transEsc($field)?></li>
<? foreach ($data as $value): ?>
<label class="list-group-item checkbox"><input class="checkbox-select-item" type="checkbox" checked="checked" name="filter[]" value='<?=$this->escapeHtmlAttr($value['field'])?>:"<?=$this->escapeHtmlAttr($value['value'])?>"' /> <?=$this->escapeHtml($value['displayText'])?></label>
<? endforeach; ?>
</ul>
<? endforeach; ?>
<? endif; ?>
<div class="sidegroup">
<h4><?=$this->transEsc("Search Tips")?></h4>
<ul class="list-group">
<a class="list-group-item help-link" href="<?=$this->url('help-home')?>?topic=advsearch" title="<?=$this->transEsc('Help with Advanced Search')?>"><?=$this->transEsc("Help with Advanced Search")?></a>
<a class="list-group-item help-link" href="<?=$this->url('help-home')?>?topic=search" title="<?=$this->transEsc('Help with Search Operators')?>"><?=$this->transEsc("Help with Search Operators")?></a>
</ul>
</div>
</div>
</div>
</form>
13 changes: 9 additions & 4 deletions themes/finna/templates/search/searchbox.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,27 @@
$advSearch = $options->getAdvancedSearchAction();
$lastSort = $options->getLastSort();
$lastLimit = $options->getLastLimit();

// Set up Finna Main Tabs:
$module = $this->layout()->templateDir;
$action = $this->layout()->templateName;
if (($module === 'search' && $action === 'results')
|| ($module === 'primo' && $action === 'search')
) {
$this->layout()->finnaMainTabs = $this->render('search/searchTabs');
}
?>
<? if ($this->searchType == 'advanced'): ?>
<div id="searchForm">
<? $tabs = $this->render('search/searchTabs'); ?>
<? if (!empty($tabs)): ?><?=$tabs ?><div class="tab-content clearfix"><? endif; ?>
<p class="adv_search_terms"><?=$this->transEsc("Your search terms")?> : "<strong><?=$this->escapeHtml($this->lookfor)?>"</strong></p>
<p class="adv_search_links">
<a href="<?=$this->url($advSearch)?>?edit=<?=$this->escapeHtmlAttr($this->searchId)?>"><?=$this->transEsc("Edit this Advanced Search")?></a>
<a href="<?=$this->url($advSearch)?>"><?=$this->transEsc("Start a new Advanced Search")?></a>
<a href="<?=$this->url($searchHome)?>"><?=$this->transEsc("Start a new Basic Search")?></a>
</p>
<? if (!empty($tabs)): ?></div><? endif; ?>
</div>
<? else: ?>
<form role="search" class="navbar-form navbar-left col-xs-12 col-sm-10 col-md-8 col-lg-7" method="get" action="<?=$this->url($basicSearch)?>" name="searchForm" id="searchForm" autocomplete="off">
<?= $this->render('search/searchTabs'); ?>
<input class="form-control search-query<? if($this->searchbox()->autocompleteEnabled($this->searchClassId)):?> autocomplete searcher:<?=$this->escapeHtmlAttr($this->searchClassId) ?><? endif ?>" placeholder="<?=$this->transEsc("Find")?>..." id="searchForm_lookfor" type="text" name="lookfor" value="<?=$this->escapeHtmlAttr($this->lookfor)?>"/>
<? if ($handlerCount > 1): ?>
<select class="form-control" id="searchForm_type" name="type" data-native-menu="false">
Expand Down

0 comments on commit 3a90775

Please sign in to comment.