Skip to content

Commit

Permalink
showing notation codes in the autocomplete search, fixes #517
Browse files Browse the repository at this point in the history
  • Loading branch information
henriyli committed Jul 7, 2016
1 parent 1f04850 commit 392a152
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
13 changes: 9 additions & 4 deletions model/sparql/GenericSparql.php
Original file line number Diff line number Diff line change
Expand Up @@ -837,10 +837,10 @@ protected function generateConceptSearchQueryInner($term, $lang, $searchLang, $p
* the structure is unpacked to get back the original string. Phew!
*/
$hitvar = $unique ? '(MIN(?matchstr) AS ?hit)' : '(?matchstr AS ?hit)';
$hitgroup = $unique ? 'GROUP BY ?s ?label' : '';
$hitgroup = $unique ? 'GROUP BY ?s ?label ?notation' : '';

$query = <<<EOQ
SELECT DISTINCT ?s ?label $hitvar
SELECT DISTINCT ?s ?label ?notation $hitvar
WHERE {
$graphClause {
$valuesProp
Expand All @@ -855,6 +855,7 @@ protected function generateConceptSearchQueryInner($term, $lang, $searchLang, $p
} $labelcondFallback
BIND(IF(langMatches(LANG(?match),'$lang'), ?pri, ?pri+1) AS ?npri)
BIND(CONCAT(STR(?npri), LANG(?match), '@', STR(?match)) AS ?matchstr)
OPTIONAL { ?s skos:notation ?notation }
}
$filterGraph
}
Expand Down Expand Up @@ -910,7 +911,7 @@ protected function generateConceptSearchQuery($fields, $unique, $params) {
$innerquery = $this->generateConceptSearchQueryInner($params->getSearchTerm(), $params->getLang(), $params->getSearchLang(), $props, $unique, $filterGraph);

$query = <<<EOQ
SELECT DISTINCT ?s ?label ?plabel ?alabel ?hlabel ?graph (GROUP_CONCAT(DISTINCT ?type) as ?types)
SELECT DISTINCT ?s ?label ?plabel ?alabel ?hlabel ?graph ?notation (GROUP_CONCAT(DISTINCT ?type) as ?types)
$extravars
WHERE {
$gcl {
Expand All @@ -932,7 +933,7 @@ protected function generateConceptSearchQuery($fields, $unique, $params) {
}
$filterGraph
}
GROUP BY ?s ?match ?label ?plabel ?alabel ?hlabel ?graph
GROUP BY ?s ?match ?label ?plabel ?alabel ?hlabel ?notation ?graph
ORDER BY LCASE(STR(?match)) LANG(?match) $orderextra
EOQ;
return $query;
Expand Down Expand Up @@ -1004,6 +1005,10 @@ private function transformConceptSearchResult($row, $vocabs, $fields)
$hit['lang'] = $row->label->getLang();
}

if (isset($row->notation)) {
$hit['notation'] = $row->notation->getValue();
}

if (isset($row->plabel)) {
$hit['matchedPrefLabel'] = $row->plabel->getValue();
$hit['lang'] = $row->plabel->getLang();
Expand Down
1 change: 1 addition & 0 deletions resource/js/docready.js
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ $(function() { // DOCUMENT READY
var autocompleteTemplate =[
'{{# if matched }}<p>{{matched}}{{# if lang}} ({{lang}}){{/if}} = </p>{{/if}}',
'{{# if replaced }}<p class="replaced">{{replaced}}{{# if lang}} ({{lang}}){{/if}} &rarr; </p>{{/if}}',
'{{# if notation }}<p>{{notation}}</p>{{/if}}',
'<p class="autocomplete-label">{{label}}{{# if lang}}{{# unless matched }}<p>({{lang}})</p>{{/unless}}{{/if}}</p>',
'{{# if typeLabel }}<span class="concept-type">{{typeLabel}}</span>{{/if}}',
'<div class="vocab">{{vocabLabel}}</div>'
Expand Down
1 change: 1 addition & 0 deletions view/light.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html dir="ltr" lang="{{ request.lang }}">
<head>
<base href="{{ BaseHref }}">
<link rel="shortcut icon" href="favicon.ico">
{% include 'meta.twig' %}
<link href="vendor/components/jqueryui/themes/cupertino/jquery-ui.min.css" media="screen, print" rel="stylesheet" type="text/css">
<link href="vendor/twitter/bootstrap/dist/css/bootstrap.min.css" media="screen, print" rel="stylesheet" type="text/css">
Expand Down

0 comments on commit 392a152

Please sign in to comment.