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

Make it possible to define order of plugins in configuration #1201

Merged
merged 70 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
276bf88
Added translations for skos:notation properties
Aug 4, 2021
faebcea
Added datatype labels to concept info query
Aug 4, 2021
2725e49
Show datatype on concept info page. Uri only for now.
Aug 4, 2021
c273b91
On the concept page a label for notation is shown
Aug 4, 2021
fcb125f
On the concept page a label for the datatype is shown
Aug 4, 2021
a4c88e6
Minor changes to improve readability of code
Aug 5, 2021
d7087f3
Empty spaces between the data type label and the square brackets on t…
Aug 6, 2021
72091cd
Displays a skos:notation with rdfs:Datatype and label in the properti…
Sep 7, 2021
3bee24d
Preparing to the merge: conflicts in the translations aligned with ma…
Sep 8, 2021
790533e
An unnecessary method getPrefLabelInTheConceptPageHeaderWithNotation(…
Sep 8, 2021
fba9465
2-3 options to choose from in the loop (lines 578 -> 595). This commi…
Sep 8, 2021
f0a932d
Early check for the skos:notation if it is shown in the properties on…
Sep 9, 2021
c6301a0
Vain indentation changes reverted
Sep 9, 2021
68682d1
The checking if skos:notation should be shown in the properties was m…
Sep 9, 2021
29f3e07
Added a docstring for the method getShowNotationAsProperty()
Sep 9, 2021
0b28daa
add order of plugins
Vainonen Sep 9, 2021
3d4b80a
"decimal" and "natural" sort strategies for notation codes. Fixes #927
osma Sep 14, 2021
651a5fe
Revert (partially) refactoring of showNotation, as it could cause pro…
osma Sep 14, 2021
21d24a4
removed unnecessary parameters and functions
Vainonen Sep 14, 2021
57e0da5
removed unnecessary array_merge
Vainonen Sep 14, 2021
5911225
Replace NBSP by spaces
kinow Sep 15, 2021
33a2222
Merge pull request #1207 from kinow/replace-nbsp-space
osma Sep 15, 2021
499a121
Remove tests for functionality that was removed
osma Sep 15, 2021
dbd4dc7
Add tests for decimal and natural sorting of notations
osma Sep 15, 2021
65714de
rename "decimal" notation sort strategy to "lexical" which is more ac…
osma Sep 16, 2021
4b8a7c9
Better sorting of hierarchy nodes, ignoring notation unless configure…
osma Sep 16, 2021
e5a1597
modified comments and adding variables to arrays
Vainonen Sep 16, 2021
05c55e3
Avoid unnecessary triples in concept info query and fixed tests
Sep 16, 2021
a1cd377
Merge branch 'master' into issue1087-displaying-skos-notation-with-da…
Sep 16, 2021
c50d3d5
moved to the constructor of Concept class
Sep 16, 2021
bf93425
fixed getPluginArray function and added test
Vainonen Sep 16, 2021
163f16a
Add var declaration (bug found by sonarqube)
osma Sep 16, 2021
e53e82b
Clarify comments about default values
osma Sep 16, 2021
794bd18
Merge pull request #1205 from NatLibFi/issue937-sort-by-notation-stra…
osma Sep 16, 2021
fbd5546
Added a test testGetLabelForDatatype
Sep 16, 2021
62a728a
Datatype tests added
Sep 16, 2021
aff26b4
Tests done
Sep 16, 2021
9db5409
Merge pull request #1198 from NatLibFi/issue1087-displaying-skos-nota…
miguelvaara Sep 16, 2021
6242fa2
Allow clicking on either label or notation in hierarchy. Fixes #1210
osma Sep 16, 2021
c960e09
Merge pull request #1211 from NatLibFi/issue1210-fix-hierarchy-click-…
osma Sep 16, 2021
e0e6b2d
fix coverage annotations for ConceptPropertyValueLiteral::getDatatype…
osma Sep 16, 2021
15b1300
getDatatype() should return null if the datatype has no label
osma Sep 16, 2021
fbe2be0
Merge pull request #1212 from NatLibFi/fix-notation-data-type-tests
osma Sep 16, 2021
5214675
A broken properties view on the concept page fixed
Sep 17, 2021
6688f21
Merge pull request #1213 from NatLibFi/issue1087-displaying-skos-nota…
miguelvaara Sep 17, 2021
9ac8831
Gracefully produce 404 error page for URLs with unknown vocabulary ID
osma Oct 6, 2021
649e09a
Merge pull request #1215 from NatLibFi/fix-invalid-vocabid-404-error
osma Oct 6, 2021
c087ce4
Fixed performance problems in query for notation label
Oct 6, 2021
747c63e
Fixed performance problems in query for notation label
Oct 6, 2021
2b00744
Revert "Fixed performance problems in query for notation label"
osma Oct 6, 2021
e2c5ebf
Fixed performance problems in query for notation label
Oct 6, 2021
47c93be
Merge pull request #1216 from NatLibFi/fix-notation-label-performance
osma Oct 6, 2021
c6b4aa5
added check for getting plugin order
Vainonen Oct 6, 2021
5fd3402
Update translations from Transifex for 2.12 release. Includes Dutch t…
osma Oct 6, 2021
f013404
Add Frysk (West Frisian, fy) translation by @redmer
osma Oct 6, 2021
5fe4234
Merge pull request #1218 from NatLibFi/update-translations-for-2.12
osma Oct 6, 2021
5cf55f0
mark the start of 2.13 development
Oct 6, 2021
09fa432
Avoid uncaught fatal errors in REST API if vocabulary ID not found. F…
osma Nov 2, 2021
d12c2d3
Merge pull request #1231 from NatLibFi/issue1170-rest-fatal-error-voc…
osma Nov 2, 2021
0f19fd0
add order of plugins
Vainonen Sep 9, 2021
03612b2
removed unnecessary parameters and functions
Vainonen Sep 14, 2021
141518e
removed unnecessary array_merge
Vainonen Sep 14, 2021
393ad96
modified comments and adding variables to arrays
Vainonen Sep 16, 2021
de12c0a
fixed getPluginArray function and added test
Vainonen Sep 16, 2021
06e1237
added check for getting plugin order
Vainonen Oct 6, 2021
152e2a6
add order of plugins
Vainonen Sep 9, 2021
8e16c57
removed unnecessary parameters and functions
Vainonen Sep 14, 2021
8f8812d
modified comments and adding variables to arrays
Vainonen Sep 16, 2021
c4b730b
Merge branch 'issue1148-order-of-plugins' of https://github.com/NatLi…
Vainonen Nov 2, 2021
148ded6
added covers annotation to VocabularyConfigTest
Vainonen Nov 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions controller/WebController.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function invokeVocabularyConcept(Request $request)
if ($this->notModified($results[0])) {
return;
}
$pluginParameters = $vocab->getConfig()->getPluginParameters();
$pluginParameters = json_encode($vocab->getConfig()->getPluginParameters());
$template = (in_array('skos:Concept', $results[0]->getType()) || in_array('skos:ConceptScheme', $results[0]->getType())) ? $this->twig->loadTemplate('concept-info.twig') : $this->twig->loadTemplate('group-contents.twig');

$crumbs = $vocab->getBreadCrumbs($request->getContentLang(), $uri);
Expand Down Expand Up @@ -532,7 +532,7 @@ public function invokeVocabularyHome($request)
$this->invokeGroupIndex($request, true);
return;
}
$pluginParameters = $vocab->getConfig()->getPluginParameters();
$pluginParameters = json_encode($vocab->getConfig()->getPluginParameters());

$template = $this->twig->loadTemplate('vocab.twig');

Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
$vocab = $parts[1];
try {
$request->setVocab($parts[1]);
} catch (Exception $e) {
} catch (Exception | ValueError $e) {
$request->setLang($controller->guessLanguage());
$controller->invokeGenericErrorPage($request);
return;
Expand Down
13 changes: 9 additions & 4 deletions model/Concept.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Concept extends VocabularyDataObject implements Modifiable
/** the EasyRdf\Graph object of the concept */
private $graph;
private $clang;
private $deleted;

/** concept properties that should not be shown to users */
private $DELETED_PROPERTIES = array(
Expand Down Expand Up @@ -78,8 +79,13 @@ class Concept extends VocabularyDataObject implements Modifiable
public function __construct($model, $vocab, $resource, $graph, $clang)
{
parent::__construct($model, $vocab, $resource);
$this->deleted = $this->DELETED_PROPERTIES;
if ($vocab !== null) {
$this->order = $vocab->getConfig()->getPropertyOrder();
// delete notations unless configured to show them
if (!$vocab->getConfig()->getShowNotationAsProperty()) {
$this->deleted[] = 'skos:notation';
}
} else {
$this->order = VocabularyConfig::DEFAULT_PROPERTY_ORDER;
}
Expand Down Expand Up @@ -278,7 +284,7 @@ public function processExternalResource($res)
$propList = array_unique(array_merge(
$this->DEFAULT_EXT_PROPERTIES,
$this->getVocab()->getConfig()->getExtProperties(),
$this->getVocab()->getConfig()->getPlugins()->getExtProperties()
$this->getVocab()->getConfig()->getPluginRegister()->getExtProperties()
));

$seen = array();
Expand Down Expand Up @@ -508,7 +514,7 @@ public function getProperties()
$sprop = "<$prop>";
}

if (!in_array($prop, $this->DELETED_PROPERTIES) || ($this->isGroup() === false && $prop === 'skos:member')) {
if (!in_array($prop, $this->deleted) || ($this->isGroup() === false && $prop === 'skos:member')) {
// retrieve property label and super properties from the current vocabulary first
$propres = new EasyRdf\Resource($prop, $this->graph);
$proplabel = $propres->label($this->getEnvLang()) ? $propres->label($this->getEnvLang()) : $propres->label();
Expand Down Expand Up @@ -558,7 +564,7 @@ public function getProperties()
if ($superprop) {
$superprop = EasyRdf\RdfNamespace::shorten($superprop) ? EasyRdf\RdfNamespace::shorten($superprop) : $superprop;
}
$sort_by_notation = $this->vocab->getConfig()->sortByNotation();
$sort_by_notation = $this->vocab->getConfig()->getSortByNotation();
$propobj = new ConceptProperty($prop, $proplabel, $prophelp, $superprop, $sort_by_notation);

if ($propobj->getLabel() !== null) {
Expand All @@ -581,7 +587,6 @@ public function getProperties()
if (isset($ret[$prop]) && ($literal->getLang() === $this->clang || $literal->getLang() === null) || $this->vocab->getConfig()->hasMultiLingualProperty($prop)) {
$ret[$prop]->addValue($literal);
}

}

// Iterating through every resource and adding these to the data object.
Expand Down
8 changes: 6 additions & 2 deletions model/ConceptProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,12 @@ private function sortValues()
return -1;
}
else {
// assume that notations are unique
return strnatcasecmp($anot, $bnot);
// assume that notations are unique, choose strategy
if ($this->sort_by_notation == "lexical") {
return strcoll($anot, $bnot);
} else { // natural
return strnatcasecmp($anot, $bnot);
}
}
});
}
Expand Down
7 changes: 1 addition & 6 deletions model/ConceptPropertyValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@ public function __construct($model, $vocab, $resource, $prop, $clang = '')

public function __toString()
{
$label = is_string($this->getLabel()) ? $this->getLabel() : $this->getLabel()->getValue();
if ($this->vocab->getConfig()->sortByNotation()) {
$label = ltrim($this->getNotation() . ' ') . $label;
}

return $label;
return is_string($this->getLabel()) ? $this->getLabel() : $this->getLabel()->getValue();
}

public function getLang()
Expand Down
22 changes: 21 additions & 1 deletion model/ConceptPropertyValueLiteral.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ class ConceptPropertyValueLiteral extends VocabularyDataObject
private $literal;
/** property type */
private $type;
/** content language */
private $clang;

public function __construct($model, $vocab, $resource, $literal, $prop)
public function __construct($model, $vocab, $resource, $literal, $prop, $clang = '')
{
parent::__construct($model, $vocab, $resource);
$this->literal = $literal;
$this->type = $prop;
$this->clang = $clang;
}

public function __toString()
Expand All @@ -31,6 +34,23 @@ public function getLang()
return $this->literal->getLang();
}

/**
* A method for fetching a datatype.
*/
public function getDatatype(): ?string
{
$datatype = $this->literal->getDatatype();
if ($datatype === null) {
return null;
}
$graph = $this->resource->getGraph();
if ($graph->resource($datatype)->label($this->clang)) {
$dtLabel = $graph->resource($datatype)->label($this->clang);
return $dtLabel->getValue();
}
return null;
}

public function getType()
{
return $this->type;
Expand Down
4 changes: 2 additions & 2 deletions model/DataObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function getExternalLabel($exvoc, $exuri, $lang)
$exsparql = $exvoc->getSparql();
$results = $exsparql->queryLabel($exuri, $lang);
return isset($results[$lang]) ? $results[$lang] : null;
} catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
} catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
if ($this->model->getConfig()->getLogCaughtExceptions()) {
error_log('Caught exception: ' . $e->getMessage());
}
Expand All @@ -72,7 +72,7 @@ protected function getExternalNotation($exvoc, $exuri)
$exsparql = $exvoc->getSparql();
$results = $exsparql->queryNotation($exuri);
return isset($results) ? $results : null;
} catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
} catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
if ($this->model->getConfig()->getLogCaughtExceptions()) {
error_log('Caught exception: ' . $e->getMessage());
}
Expand Down
4 changes: 2 additions & 2 deletions model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ private function disambiguateVocabulary($vocabs, $uri, $preferredVocabId = null)
// not found in preferred vocabulary, fall back to next method
break;
}
} catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
} catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
if ($this->getConfig()->getLogCaughtExceptions()) {
error_log('Caught exception: ' . $e->getMessage());
}
Expand All @@ -494,7 +494,7 @@ private function disambiguateVocabulary($vocabs, $uri, $preferredVocabId = null)
if ($vocab->getConceptLabel($uri, null) !== null) {
return $vocab;
}
} catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
} catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
if ($this->getConfig()->getLogCaughtExceptions()) {
error_log('Caught exception: ' . $e->getMessage());
}
Expand Down
2 changes: 1 addition & 1 deletion model/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public function getVocabList() {

public function getPlugins() {
if ($this->vocab) {
return $this->vocab->getConfig()->getPlugins();
return $this->vocab->getConfig()->getPluginRegister();
}
return new PluginRegister($this->model->getConfig()->getGlobalPlugins());
}
Expand Down
6 changes: 3 additions & 3 deletions model/Vocabulary.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function getInfo($lang = null)
// query everything the endpoint knows about the ConceptScheme
$sparql = $this->getSparql();
$result = $sparql->queryConceptScheme($defaultcs);
} catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
} catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
if ($this->model->getConfig()->getLogCaughtExceptions()) {
error_log('Caught exception: ' . $e->getMessage());
}
Expand Down Expand Up @@ -252,7 +252,7 @@ public function getConceptSchemes($lang = '')
$conceptSchemes = null;
try {
$conceptSchemes = $this->getSparql()->queryConceptSchemes($lang);
} catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
} catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
if ($this->model->getConfig()->getLogCaughtExceptions()) {
error_log('Caught exception: ' . $e->getMessage());
}
Expand Down Expand Up @@ -452,7 +452,7 @@ public function getConceptInfo($uri, $clang)
$conceptInfo = null;
try {
$conceptInfo = $sparql->queryConceptInfo($uri, $this->config->getArrayClassURI(), array($this), $clang);
} catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
} catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
if ($this->model->getConfig()->getLogCaughtExceptions()) {
error_log('Caught exception: ' . $e->getMessage());
}
Expand Down
Loading