Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix static analysis issues #968

Merged
merged 12 commits into from
Apr 6, 2020
6 changes: 1 addition & 5 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
"loadPage": false,
"Bloodhound": false,
"Handlebars": false,
"getUrlParams": false,
"createCookie": false,
"debounce": false,
"readCookie": false,
"noResultsTranslation": false,
"noResultsTranslation": false,
"lscache": false,
"getTreeConfiguration": false,
"invokeParentTree": false,
Expand Down
7 changes: 4 additions & 3 deletions controller/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ public function __construct($model)
{
$this->model = $model;
$this->negotiator = new \Negotiation\Negotiator();
$domain = 'skosmos';

// Specify the location of the translation tables
bindtextdomain('skosmos', 'resource/translations');
bind_textdomain_codeset('skosmos', 'UTF-8');
bindtextdomain($domain, 'resource/translations');
bind_textdomain_codeset($domain, 'UTF-8');

// Choose domain for translations
textdomain('skosmos');
textdomain($domain);

// Build arrays of language information, with 'locale' and 'name' keys
$this->languages = array();
Expand Down
4 changes: 2 additions & 2 deletions controller/WebController.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private function createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender)
* Sends the user entered message through the php's mailer.
* @param string $message only required parameter is the actual message.
* @param string $fromName senders own name.
* @param string $fromEmail senders email adress.
* @param string $fromEmail senders email address.
* @param string $fromVocab which vocabulary is the feedback related to.
*/
public function sendFeedback($request, $message, $fromName = null, $fromEmail = null, $fromVocab = null, $toMail = null)
Expand Down Expand Up @@ -447,7 +447,7 @@ public function invokeAboutPage($request)
}

/**
* Invokes the search for concepts in all the availible ontologies.
* Invokes the search for concepts in all the available ontologies.
*/
public function invokeGlobalSearch($request)
{
Expand Down
2 changes: 1 addition & 1 deletion model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function getVersion()
* @param boolean $categories whether you want everything included in a subarray of
* a category.
* @param boolean $shortname set to true if you want the vocabularies sorted by
* their shortnames instead of ther titles.
* their shortnames instead of their titles.
*/
public function getVocabularyList($categories = true, $shortname = false)
{
Expand Down
2 changes: 1 addition & 1 deletion model/VocabularyConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getDefaultLanguage()
}

/**
* Wether the alphabetical index is small enough to be shown all at once.
* Whether the alphabetical index is small enough to be shown all at once.
* @return boolean true if all concepts can be shown at once.
*/
public function getAlphabeticalFull()
Expand Down
24 changes: 12 additions & 12 deletions resource/css/styles.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* Font definitions
*****************************************/
li, td > a {
font-family: 'Fira Sans';
font-family: 'Fira Sans', sans-serif;
font-size: 14px;
}

h1, .prefLabel, .prefLabelLang, .notation {
font-family: 'Fira Sans';
font-family: 'Fira Sans', sans-serif;;
font-size: 27px;
font-weight: 400;
}
Expand All @@ -25,17 +25,17 @@ h1, .prefLabel, .prefLabelLang, .notation {
}

h2 {
font-family: 'Fira Sans';
font-family: 'Fira Sans', sans-serif;
font-size: 16px;
}

.navigation-font {
font-family: 'Fira Sans';
font-family: 'Fira Sans', sans-serif;
font-size: 16px;
}

.multiselect span, .multiselect a, .dropdown-toggle, #search-all-button, .qtip-skosmos * {
font-family: 'Fira Sans';
font-family: 'Fira Sans', sans-serif;
}

.topbar a.navigation-font, .topbar span {
Expand All @@ -44,24 +44,24 @@ h2 {

p {
color: #474b4f;
font-family: 'Fira Sans';
font-family: 'Fira Sans', sans-serif;
font-size: 14px;
}

.bread-crumb {
font-family: 'Fira Sans';
font-family: 'Fira Sans', sans-serif;
font-size: 14px;
}

.versal {
color: #474b4f;
font-family: 'Fira Sans';
font-family: 'Fira Sans', sans-serif;
font-size: 14px;
font-weight: 400;
}

.versal-bold {
font-family: 'Fira Sans';
font-family: 'Fira Sans', sans-serif;
font-size: 14px;
font-weight: bold;
}
Expand Down Expand Up @@ -1024,7 +1024,7 @@ li.sub-group {
}

#vocab-info tr {
border-image: '../pics/stripe.png' 20 20 repeat;
border-image: url('../pics/stripe.png') 20 20 repeat;
}

/* vocabulary
Expand Down Expand Up @@ -1407,7 +1407,7 @@ ul.nav-tabs > li {
}

.wide-content {
margin-left: 0px;
margin-left: 0;
}

#skiptocontent {
Expand Down Expand Up @@ -1956,7 +1956,7 @@ body, .versal, h1, h2, p, .versal-bold {
}

#service-logo {
display: normal;
display: inline;
position: absolute;
}

Expand Down
10 changes: 3 additions & 7 deletions resource/js/docready.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ $(function() { // DOCUMENT READY
function copyToClipboard() {
var $btn = $(this);
var id = $btn.attr('for');
$elem = $(id);
var $elem = $(id);
makeSelection(undefined, $elem);
document.execCommand('copy');
}
Expand Down Expand Up @@ -957,7 +957,7 @@ $(function() { // DOCUMENT READY
} else if (selectedVocabs[vocabId] !== undefined) {
delete selectedVocabs[vocabId];
}
this.vocabSelectionString = updateVocabParam();
updateVocabParam();
},
maxHeight: 300
});
Expand Down Expand Up @@ -1060,11 +1060,7 @@ $(function() { // DOCUMENT READY
});

$('#parent-limit').focus(function() {
if($('#parent-limit').attr('data-uri') !== '') {
parentLimitReady = true;
} else {
parentLimitReady = false;
}
parentLimitReady = $('#parent-limit').attr('data-uri') !== '';
});

$(document).on('submit', '.search-options', function() {
Expand Down
4 changes: 2 additions & 2 deletions resource/js/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function invokeGroupTree() {
$treeObject.jstree('open_node', node.node);
});

$('.group-hierarchy').jstree({
$treeObject.jstree({
'plugins' : ['sort'],
'sort' : function (a,b) { return naturalCompare(this.get_text(a).toLowerCase(), this.get_text(b).toLowerCase()); },
'core' : {
Expand Down Expand Up @@ -94,7 +94,7 @@ function createGroupNode(uri, groupObject) {
if (uri.indexOf(uriSpace) !== -1) {
groupPage = uri.substr(uriSpace.length);
if (/[^a-zA-Z0-9\.]/.test(groupPage) || groupPage.indexOf("/") > -1 ) {
// contains special characters or contains an additionnal '/' - fall back to full URI
// contains special characters or contains an additional '/' - fall back to full URI
groupPage = '?uri=' + encodeURIComponent(uri);
}
} else {
Expand Down
19 changes: 11 additions & 8 deletions resource/js/hierarchy.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ function invokeParentTree(tree) {
});

$treeObject.on('loaded.jstree', function() {
var $sidebarGrey = $(".sidebar-grey");
if ($('#sidebar .mCustomScrollbar').length === 0) {
$(".sidebar-grey").mCustomScrollbar(hierTreeConf);
$sidebarGrey.mCustomScrollbar(hierTreeConf);
}
if ($('.jstree-leaf-proper').length > 0) {
$('.sidebar-grey').jstree('select_node', $('.jstree-leaf-proper').toArray());
$('.sidebar-grey').mCustomScrollbar('scrollTo', getLeafOffset());
var $leafProper = $('.jstree-leaf-proper');
if ($leafProper.length > 0) {
$sidebarGrey.jstree('select_node', $leafProper.toArray());
$sidebarGrey.mCustomScrollbar('scrollTo', getLeafOffset());
}
});
}
Expand All @@ -53,8 +55,9 @@ function getLeafOffset() {
var containerHeight = $('.sidebar-grey').height();
var conceptCount = Math.floor((containerHeight * 0.66) / 18);
var scrollAmount = 18 * conceptCount;
if ($('.jstree-leaf-proper').length) {
var newOffset = $('.jstree-leaf-proper')[0].offsetTop-scrollAmount;
var $leafProper = $('.jstree-leaf-proper');
if ($leafProper.length) {
var newOffset = $leafProper[0].offsetTop-scrollAmount;
if (newOffset > 0) // only scrolls the view if the concept isn't already at the top.
return newOffset;
}
Expand Down Expand Up @@ -202,7 +205,7 @@ function getConceptHref(conceptData) {
if (conceptData.uri.indexOf(window.uriSpace) !== -1) {
var page = conceptData.uri.substr(window.uriSpace.length);
if (/[^a-zA-Z0-9\.]/.test(page) || page.indexOf("/") > -1 ) {
// contains special characters or contains an additionnal '/' - fall back to full URI
// contains special characters or contains an additional '/' - fall back to full URI
page = '?uri=' + encodeURIComponent(conceptData.uri);
}
} else {
Expand Down Expand Up @@ -272,7 +275,7 @@ function createObjectsFromNarrowers(narrowerResponse) {
parents: narrowerResponse.uri,
state: { opened: false, disabled: false, selected: false }
};
childObject.children = conceptObject.hasChildren ? true : false;
childObject.children = !!conceptObject.hasChildren;
setNode(childObject);
childArray.push(childObject);
}
Expand Down
34 changes: 21 additions & 13 deletions resource/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ $.ajaxQ = (function(){
})();

function updateContent(data) {
$('.content').empty();
var $content = $('.content');
$content.empty();
var response = $('.content', data).html();
$('.content').append(response);
$content.append(response);
}

function updateJsonLD(data) {
Expand All @@ -107,9 +108,10 @@ function updateJsonLD(data) {
}

function updateTopbarLang(data) {
$('#language').empty();
var $language = $('#language');
$language.empty();
var langBut = $('#language', data).html();
$('#language').append(langBut);
$language.append(langBut);
}

function updateTitle(data) {
Expand All @@ -118,9 +120,10 @@ function updateTitle(data) {
}

function updateSidebar(data) {
$('#sidebar').empty();
var $sidebar = $('#sidebar');
$sidebar.empty();
var response = $('#sidebar', data).html();
$('#sidebar').append(response);
$sidebar.append(response);
}

// sets the language cookie for 365 days
Expand All @@ -134,10 +137,12 @@ function clearResultsAndAddSpinner() {
}

function loadLimitations() {
var $typeLimit = $('#type-limit');
var $schemeLimit = $('#scheme-limit');
var groupLimit = $('#group-limit').val();
var parentLimit = $('#parent-limit').attr('data-uri');
var typeLimit = $('#type-limit').val() ? $('#type-limit').val().join('+') : $('#type-limit').val();
var schemeLimit = $('#scheme-limit').val() ? $('#scheme-limit').val().join('+') : $('#scheme-limit').val();
var typeLimit = $typeLimit.val() ? $typeLimit.val().join('+') : $typeLimit.val();
var schemeLimit = $schemeLimit.val() ? $schemeLimit.val().join('+') : $schemeLimit.val();
if (schemeLimit && schemeLimit[0] === '+') { // filtering the empty selection out of the search string
schemeLimit = schemeLimit.substring(1);
}
Expand Down Expand Up @@ -235,12 +240,14 @@ function countAndSetOffset() {
$('.sidebar-grey').attr('style', function() {
var pixels = $('.nav-tabs').height() + 2; // the 2 pixels are for the borders
if ($('#sidebar > .pagination').is(':visible')) { pixels += $('.pagination').height(); }
if ($('.changes-navi').is(':visible')) { pixels += $('.changes-navi').height(); }
var $changesNavi = $('.changes-navi');
if ($changesNavi.is(':visible')) { pixels += $changesNavi.height(); }
return 'height: calc(100% - ' + pixels + 'px) !important';
});
if ($('#sidebar').length && !$('#sidebar').hasClass('fixed')) {
var yOffset = window.innerHeight - ( $('#sidebar').offset().top - window.pageYOffset);
$('#sidebar').css('height', yOffset);
var $sidebar = $('#sidebar');
if ($sidebar.length && !$sidebar.hasClass('fixed')) {
var yOffset = window.innerHeight - ( $sidebar.offset().top - window.pageYOffset);
$sidebar.css('height', yOffset);
}
}

Expand Down Expand Up @@ -269,7 +276,8 @@ function makeCallbacks(data, pageType) {
var variables = data ? data.substring(data.indexOf('var uri ='), data.indexOf('var uriSpace =')).split('\n') : '';
var newUri = data ? variables[0].substring(variables[0].indexOf('"')+1, variables[0].indexOf(';')-1) : window.uri;
var newPrefs = data ? JSON.parse(variables[1].substring(variables[1].indexOf('['), variables[1].lastIndexOf(']')+1)) : window.prefLabels;
var embeddedJsonLd = $('script[type="application/ld+json"]')[0] ? JSON.parse($('script[type="application/ld+json"]')[0].innerHTML) : {};
var $ldJsonScript = $('script[type="application/ld+json"]');
var embeddedJsonLd = $ldJsonScript[0] ? JSON.parse($ldJsonScript[0].innerHTML) : {};

var params = {'uri': newUri, 'prefLabels': newPrefs, 'page': pageType, "json-ld": embeddedJsonLd};

Expand Down