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

Merge master #7

Merged
merged 10 commits into from
Nov 30, 2017
3 changes: 3 additions & 0 deletions config.inc.dist
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,6 @@ define("UI_HONEYPOT_ENABLED", TRUE);

// default time a user must wait before submitting a form
define("UI_HONEYPOT_TIME", 5);

// whether to enable collation in sparql queries
define("SPARQL_COLLATION_ENABLED", FALSE);
2 changes: 1 addition & 1 deletion model/ConceptSearchParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private function getQueryParam($name) {
}

private function getQueryParamArray($name) {
return $this->request->getQueryParam($name) ? explode(' ', $this->request->getQueryParam($name)) : null;
return $this->request->getQueryParam($name) ? explode(' ', urldecode($this->request->getQueryParam($name))) : null;
}

public function getGroupLimit()
Expand Down
9 changes: 8 additions & 1 deletion model/GlobalConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,5 +239,12 @@ public function getHoneypotTime()
{
return $this->getConstant('UI_HONEYPOT_TIME', 5);
}


/**
* @return boolean
*/
public function getCollationEnabled()
{
return $this->getConstant('SPARQL_COLLATION_ENABLED', FALSE);
}
}
5 changes: 4 additions & 1 deletion model/sparql/GenericSparql.php
Original file line number Diff line number Diff line change
Expand Up @@ -936,11 +936,14 @@ protected function generateConceptSearchQuery($fields, $unique, $params, $showDe
$extrafields = $formattedfields['extrafields'];
$schemes = $params->getSchemeLimit();

// limit the search to only requested concept schemes
$schemecond = '';
if (!empty($schemes)) {
$conditions = array();
foreach($schemes as $scheme) {
$schemecond .= "?s skos:inScheme <$scheme> . ";
$conditions[] = "{?s skos:inScheme <$scheme>}";
}
$schemecond = '{'.implode(" UNION ",$conditions).'}';
}
$filterDeprecated="";
//show or hide deprecated concepts
Expand Down
19 changes: 18 additions & 1 deletion model/sparql/JenaTextSparql.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/* Register text: namespace needed for jena-text queries */
EasyRdf\RdfNamespace::set('text', 'http://jena.apache.org/text#'); // @codeCoverageIgnore
EasyRdf\RdfNamespace::set('arq', 'http://jena.apache.org/ARQ/function#'); // @codeCoverageIgnore

/**
* Provides functions tailored to the JenaTextSparql extensions for the Fuseki SPARQL index.
Expand Down Expand Up @@ -73,6 +74,21 @@ protected function generateConceptSearchQueryCondition($term, $searchLang)
return $textcond;
}

/**
* Generates sparql query clauses used for ordering by an expression. Uses a special collation function
* if configuration for it is enabled.
* @param string $expression the expression used for ordering the results
* @param string $lang language
* @return string sparql order by clause
*/
private function formatOrderBy($expression, $lang) {
if(!$this->model->getConfig()->getCollationEnabled()) {
return $expression;
}
$orderby = sprintf('arq:collation(\'%2$s\', %1$s)', $expression, $lang);
return $orderby;
}

/**
* Generates the jena-text-specific sparql query used for rendering the alphabetical index.
* @param string $letter the letter (or special class) to search for
Expand Down Expand Up @@ -100,6 +116,7 @@ public function generateAlphabeticalListQuery($letter, $lang, $limit = null, $of
$lcletter = mb_strtolower($letter, 'UTF-8'); // convert to lower case, UTF-8 safe
$textcondPref = $this->createTextQueryCondition($letter . '*', 'skos:prefLabel', $lang);
$textcondAlt = $this->createTextQueryCondition($letter . '*', 'skos:altLabel', $lang);
$orderbyclause = $this->formatOrderBy("LCASE(?match)", $lang);

$filterDeprecated="";
if(!$showDeprecated){
Expand Down Expand Up @@ -131,7 +148,7 @@ public function generateAlphabeticalListQuery($letter, $lang, $limit = null, $of
$filterDeprecated
} $values
}
ORDER BY LCASE(?match) $limitandoffset
ORDER BY $orderbyclause $limitandoffset
EOQ;
return $query;
}
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<phpunit colors="true" bootstrap="tests/bootstrap.php">
<phpunit colors="true" bootstrap="tests/bootstrap.php" processIsolation="true">
<logging>
<log type="coverage-html" target="./report" charset="UTF-8" highlight="false" lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
Expand Down
Binary file modified resource/translations/de/LC_MESSAGES/skosmos.mo
Binary file not shown.
33 changes: 17 additions & 16 deletions resource/translations/skosmos_de.po
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#
# Translators:
# CH_ <ch@infobib.de>, 2017
# Joachim Neubert <j.neubert@zbw.eu>, 2015-2016
# osma <osma.suominen@helsinki.fi>, 2015,2017
msgid ""
msgstr ""
"Project-Id-Version: Skosmos\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-01-16 10:26+0200\n"
"PO-Revision-Date: 2017-05-30 07:43+0000\n"
"Last-Translator: osma <osma.suominen@helsinki.fi>\n"
"PO-Revision-Date: 2017-11-21 13:54+0000\n"
"Last-Translator: CH_ <ch@infobib.de>\n"
"Language-Team: German (http://www.transifex.com/national-library-of-finland/skosmos/language/de/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -164,7 +165,7 @@ msgstr "Feedback"

#: /tmp/cache/587c83c09abaa/4a/4a8733799c4f4aa865ece4715881ffcbef92985ed08edc2acd445e7b0c129fab.php:64
msgid "Feedback has been sent!"
msgstr "Ihr Feedback wurde versended!"
msgstr "Ihr Feedback wurde versendet!"

#: /tmp/cache/587c83c09abaa/d1/d13f81e53ff33f31fff259d66f8ddbf7cfc39d25c6219ff727553feca6d87d37.php:35
msgid "Group index"
Expand Down Expand Up @@ -218,7 +219,7 @@ msgstr "Keine Ergebnisse"
#: /tmp/cache/587c83c09abaa/4a/4a8733799c4f4aa865ece4715881ffcbef92985ed08edc2acd445e7b0c129fab.php:103
#: /tmp/cache/587c83c09abaa/4a/4a8733799c4f4aa865ece4715881ffcbef92985ed08edc2acd445e7b0c129fab.php:111
msgid "Not to a specific vocabulary"
msgstr "Nicht in einem speziellen Vokabular"
msgstr "Nicht zu einem speziellen Vokabular"

#: /tmp/cache/587c83c09abaa/9a/9a6d69d72b35f38585477d2f25d50cacf270791aa84e4d523f237566dd428822.php:233
msgid "Search"
Expand All @@ -242,7 +243,7 @@ msgstr "Sende Feedback"

#: /tmp/cache/587c83c09abaa/f2/f29f57cf31b29541d6f810d43d1f7a07e79cfddcf23678f04612a410c0f0607b.php:51
msgid "Show all breadcrumb paths"
msgstr "Zeige alle Brotkrümel Pfade"
msgstr "Zeige alle Brotkrümel-Pfade"

#: /tmp/cache/587c83c09abaa/58/58e9c1cebb82d52daf56fab57cd7b86ed47b1d8a86a915177156746eef73248e.php:72
msgid "Skosmos version %version%"
Expand All @@ -254,15 +255,15 @@ msgstr "Suche absenden"

#: /tmp/cache/587c83c09abaa/4a/4a8733799c4f4aa865ece4715881ffcbef92985ed08edc2acd445e7b0c129fab.php:68
msgid "Thank you for your feedback"
msgstr "Danke für Ihr Feedback"
msgstr "Danke für Ihr Feedback. Wir versuchen, so schnell wie möglich zu antworten."

#: /tmp/cache/587c83c09abaa/8a/8aeec9eddcf0848575d119210eda5a849c129c96ea86195b4448536a02a47817.php:129
msgid "The search provided no results."
msgstr "Die Suche ergab keine Ergebnisse"
msgstr "Die Suche ergab keine Ergebnisse."

#: /tmp/cache/587c83c09abaa/3c/3c4ea3202d0add91bf2080022b707c23115e0beb434024ddb2de27749e6bbe83.php:48
msgid "There is no term for this concept in this language"
msgstr ""
msgstr "In dieser Sprache gibt es keinen Begriff für dieses concept."

#: /tmp/cache/587c83c09abaa/4a/4a8733799c4f4aa865ece4715881ffcbef92985ed08edc2acd445e7b0c129fab.php:173
#: /tmp/cache/587c83c09abaa/f2/f29f57cf31b29541d6f810d43d1f7a07e79cfddcf23678f04612a410c0f0607b.php:47
Expand Down Expand Up @@ -311,7 +312,7 @@ msgstr "Ersteller"

#: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:45
msgid "dc:date"
msgstr "Päiväys"
msgstr "Datum"

#: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:47
msgid "dc:description"
Expand Down Expand Up @@ -375,27 +376,27 @@ msgstr "Quelle"

#: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:77
msgid "dc:source_help"
msgstr ""
msgstr "Quelle für die Beschreibung dieses concepts."

#: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:79
msgid "dc:spatial"
msgstr ""
msgstr "Räumliche Abdeckung"

#: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:81
msgid "dc:subject"
msgstr "Bezug"

#: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:83
msgid "dc:temporal"
msgstr ""
msgstr "Zeitliche Abdeckung"

#: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:85
msgid "dc:title"
msgstr "Titel"

#: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:87
msgid "dc:type"
msgstr ""
msgstr "Typ"

#: /tmp/cache/587c83c09abaa/3c/3c4ea3202d0add91bf2080022b707c23115e0beb434024ddb2de27749e6bbe83.php:36
#: /tmp/cache/587c83c09abaa/8a/8aeec9eddcf0848575d119210eda5a849c129c96ea86195b4448536a02a47817.php:256
Expand Down Expand Up @@ -673,12 +674,12 @@ msgstr "Gehört zur Gruppe"
#: /tmp/cache/587c83c09abaa/3c/3c4ea3202d0add91bf2080022b707c23115e0beb434024ddb2de27749e6bbe83.php:611
#: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:205
msgid "skosmos:memberOfArray"
msgstr ""
msgstr "Gehört zu Array"

#: /tmp/cache/587c83c09abaa/3c/3c4ea3202d0add91bf2080022b707c23115e0beb434024ddb2de27749e6bbe83.php:609
#: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:207
msgid "skosmos:memberOfArray_help"
msgstr ""
msgstr "Array, zu dem das Konzept gehört."

#: /tmp/cache/587c83c09abaa/3c/3c4ea3202d0add91bf2080022b707c23115e0beb434024ddb2de27749e6bbe83.php:546
#: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:203
Expand All @@ -687,7 +688,7 @@ msgstr "Gruppe zu der das concept Objekt gehört."

#: /tmp/cache/587c83c09abaa/4e/4e05e5051b20c875609479922a558d59b8500ae386eaf79bc460e69d8781a753.php:23
msgid "zxx-x-taxon"
msgstr ""
msgstr "Wissenschaftlicher Name"

#: /tmp/cache/587c83c13194c/0b/0bbfc29e05e244fa07889ce1678840902f16e5f76560e00137de0cc3bb084b8b.php:168
msgid "About page"
Expand Down
7 changes: 2 additions & 5 deletions resource/translations/skosmos_fi.po
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# Finnish translation of ONKI Light
# Copyright SeCo 2012 (C)
#
msgid ""
msgstr ""
"Project-Id-Version: ONKI Light\n"
"Project-Id-Version: Skosmos\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-01-16 10:23+0200\n"
"PO-Revision-Date: \n"
"Last-Translator: Henri Ylikotila <henri.ylikotila@helsinki.fi>\n"
"Language-Team: ONKI Team <onki-posti@helsinki.fi>\n"
"Language-Team: Finto Team <finto-posti@helsinki.fi>\n"
"Language: fi\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down
7 changes: 2 additions & 5 deletions resource/translations/skosmos_sv.po
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# Finnish translation of ONKI Light
# Copyright SeCo 2012 (C)
#
msgid ""
msgstr ""
"Project-Id-Version: ONKI Light\n"
"Project-Id-Version: Skosmos\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-01-16 10:24+0200\n"
"PO-Revision-Date: \n"
"Last-Translator: Henri Ylikotila <henri.ylikotila@helsinki.fi>\n"
"Language-Team: ONKI Team <onki-posti@helsinki.fi>\n"
"Language-Team: Finto Team <finto-posti@helsinki.fi>\n"
"Language: sv\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down
24 changes: 24 additions & 0 deletions tests/GenericSparqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,30 @@ public function testQueryConceptsMultipleVocabs()
$this->assertEquals('http://www.skosmos.skos/test/ta112', $actual[1]['uri']);
}

/**
* @covers GenericSparql::queryConcepts
* @covers GenericSparql::generateConceptSearchQueryCondition
* @covers GenericSparql::generateConceptSearchQueryInner
* @covers GenericSparql::generateConceptSearchQuery
* @covers GenericSparql::formatFilterGraph
* @covers GenericSparql::transformConceptSearchResults
* @covers GenericSparql::transformConceptSearchResult
* @covers GenericSparql::shortenUri
*/
public function testQueryConceptsMultipleSchemes()
{
$voc = $this->model->getVocabulary('multiple-schemes');
// returns 3 concepts without the scheme limit, and only 2 with the scheme limit below
$this->params->method('getSearchTerm')->will($this->returnValue('concept*'));
$this->params->method('getSchemeLimit')->will($this->returnValue(array('http://www.skosmos.skos/multiple-schemes/cs1', 'http://www.skosmos.skos/multiple-schemes/cs2')));
$sparql = new GenericSparql('http://localhost:3030/ds/sparql', 'http://www.skosmos.skos/multiple-schemes/', $this->model);
$actual = $sparql->queryConcepts(array($voc), null, null, $this->params);
$this->assertEquals(2, sizeof($actual));
$this->assertEquals('http://www.skosmos.skos/multiple-schemes/c1-in-cs1', $actual[0]['uri']);
$this->assertEquals('http://www.skosmos.skos/multiple-schemes/c2-in-cs2', $actual[1]['uri']);
}


/**
* @covers GenericSparql::queryConcepts
* @covers GenericSparql::generateConceptSearchQueryCondition
Expand Down
8 changes: 8 additions & 0 deletions tests/GlobalConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,13 @@ public function testGetVocabularyConfigFile() {
$actual = $this->config->getVocabularyConfigFile();
$this->assertEquals('tests/testvocabularies.ttl', $actual);
}

/**
* @covers GlobalConfig::getCollationEnabled
*/
public function testGetCollationEnabled() {
$actual = $this->config->getCollationEnabled();
$this->assertFalse($actual);
}
}

25 changes: 25 additions & 0 deletions tests/JenaTextSparqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,29 @@ public function testQueryConceptsDefaultGraph()
$this->assertEquals('Bass', $actual[0]['prefLabel']);
}

/**
* @covers JenaTextSparql::formatOrderBy
*/
public function testQueryConceptsAlphabeticalOrderBy() {
$vocab = $this->model->getVocabulary('collation');
$graph = $vocab->getGraph();
$sparql = new JenaTextSparql('http://localhost:3030/ds/sparql', $graph, $this->model);
$actual = $sparql->queryConceptsAlphabetical('t', 'fi');
$expected = array (
0 => array (
'uri' => 'http://www.skosmos.skos/collation/val1',
'localname' => 'val1',
'prefLabel' => 'tšekin kieli',
'lang' => 'fi',
),
1 => array (
'uri' => 'http://www.skosmos.skos/collation/val2',
'localname' => 'val2',
'prefLabel' => 'töyhtöhyyppä',
'lang' => 'fi',
)
);
$this->assertEquals($expected, $actual);
}

}
1 change: 0 additions & 1 deletion tests/VocabularyCategoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class VocabularyCategoryTest extends PHPUnit_Framework_TestCase
private $mockres;

protected function setUp() {
require_once 'testconfig.inc';
putenv("LC_ALL=en_GB.utf8");
setlocale(LC_ALL, 'en_GB.utf8');
$this->model = new Model(new GlobalConfig('/../tests/testconfig.inc'));
Expand Down
1 change: 1 addition & 0 deletions tests/jenatestconfig.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

define("VOCABULARIES_FILE", "tests/testvocabularies.ttl");
define("DEFAULT_SPARQL_DIALECT", "JenaText");
define("SPARQL_COLLATION_ENABLED", TRUE);
34 changes: 34 additions & 0 deletions tests/test-vocab-data/collation.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dc11: <http://purl.org/dc/elements/1.1/> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix collation: <http://www.skosmos.skos/collation/> .
@prefix meta: <http://www.skosmos.skos/test-meta/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix skosmos: <http://www.skosmos.skos/> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix mads: <http://www.loc.gov/mads/rdf/v1#> .

skos:prefLabel a rdf:Property ;
rdfs:label "preferred label"@en .

skos:altLabel a rdf:Property ;
rdfs:label "alternative label"@en .

skos:scopeNote a rdf:Property ;
rdfs:label "scope note"@en .

skos:broader a rdf:Property ;
rdfs:label "has broader"@en .

skos:narrower a rdf:Property ;
rdfs:label "has narrower"@en .

collation:val1 a skos:Concept ;
skos:prefLabel "tšekin kieli"@fi .

collation:val2 a skos:Concept ;
skos:prefLabel "töyhtöhyyppä"@fi .
Loading