Skip to content

Commit

Permalink
fixes #552
Browse files Browse the repository at this point in the history
  • Loading branch information
henriyli committed Sep 29, 2016
1 parent 4d32572 commit 8083780
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
5 changes: 4 additions & 1 deletion model/ConceptSearchParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ public function getSearchLang()
if ($this->rest) {
return $this->request->getQueryParam('lang');
}
return $this->request->getQueryParam('anylang') ? '' : $this->getContentLang();
if ($this->request->getCookie('SKOSMOS_ANYLANG') === '1' || $this->request->getQueryParam('anylang')) {
return '';
}
return $this->getContentLang();
}

private function getDefaultTypeLimit()
Expand Down
5 changes: 5 additions & 0 deletions model/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public function getServerConstant($paramName)
return filter_input(INPUT_SERVER, $paramName, FILTER_SANITIZE_STRING);
}

public function getCookie($cookieName)
{
return filter_input(INPUT_COOKIE, $cookieName, FILTER_SANITIZE_STRING);
}

public function getLang()
{
return $this->lang;
Expand Down
14 changes: 4 additions & 10 deletions resource/js/docready.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ $(function() { // DOCUMENT READY
$('#hierarchy-disabled > #hier-trigger').qtip(qtip_skosmos_hierarchy);

// Setting the language parameters according to the clang parameter or if that's not possible the cookie.
var search_lang = (content_lang !== '' && !getUrlParams().anylang) ? content_lang : readCookie('SKOSMOS_SEARCH_LANG');
var search_lang = (content_lang !== '' && !getUrlParams().anylang && vocab !== '') ? content_lang : readCookie('SKOSMOS_SEARCH_LANG');

var rest_url = rest_base_url;
if (rest_url.indexOf('..') === -1 && rest_url.indexOf('http') === -1) { rest_url = encodeURI(location.protocol + '//' + rest_url); }
Expand Down Expand Up @@ -533,18 +533,12 @@ $(function() { // DOCUMENT READY
}

$('.lang-button').click(function() {
qlang = $(this)[0].attributes.hreflang.value;
if (qlang === '') { qlang = 'anything'; }
qlang = $(this)[0].attributes.hreflang ? $(this)[0].attributes.hreflang.value : 'anything';
var any = (qlang === 'anything') ? '1' : '0';
$('#lang-dropdown-toggle').html($(this).html() + ' <span class="caret"></span>');
$('#lang-input').val(qlang);
createCookie('SKOSMOS_SEARCH_LANG', qlang, 365);
if (concepts) { concepts.clear(); }
});

$('.lang-button-all').on('click', function() {
createCookie('SKOSMOS_SEARCH_LANG', 'anything', 365);
$('#lang-input').val('');
$('#lang-dropdown-toggle').html($('.lang-button-all').html() + ' <span class="caret"></span>');
createCookie('SKOSMOS_ANYLANG', any, 365);
if (concepts) { concepts.clear(); }
});

Expand Down

0 comments on commit 8083780

Please sign in to comment.