Skip to content

Commit

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

private function getDefaultTypeLimit()
Expand Down
5 changes: 0 additions & 5 deletions model/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ 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
3 changes: 3 additions & 0 deletions resource/js/docready.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,9 @@ $(function() { // DOCUMENT READY

// Setting the language parameters according to the clang parameter or if that's not possible the cookie.
var search_lang = (content_lang !== '' && !getUrlParams().anylang && vocab !== '') ? content_lang : readCookie('SKOSMOS_SEARCH_LANG');
if (vocab === '' && readCookie('SKOSMOS_SEARCH_LANG') === 'anything') {
$('#all-languages-true').click();
}

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
5 changes: 1 addition & 4 deletions view/headerbar.twig
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@
</div>
</div>
<div id="search-from-all-vocabularies-radio-buttons">
<input type="radio" name="all" id="all-languages-false" value="0"
onClick="createCookie('SKOSMOS_SEARCH_ALL', this.value , 365);" />
<input type="radio"
id="all-languages-true" name="all" value="1"
<input type="radio" id="all-languages-true" name="anylang" value="on"
onClick="createCookie('SKOSMOS_SEARCH_ALL', this.value , 365);" />
</div>
{% if request.page == '' or request.page == 'search' %}<input id="selected-vocabs" type="text" name="vocabs">{% endif %}
Expand Down

0 comments on commit 554fb28

Please sign in to comment.