@@ -167,9 +167,11 @@ |
||
167 | 167 | */ |
168 | 168 | public function setVocab($vocabid) |
169 | 169 | { |
170 | - if (strpos($vocabid, ' ') !== false) // if there are multiple vocabularies just storing the string |
|
170 | + if (strpos($vocabid, ' ') !== false) { |
|
171 | + // if there are multiple vocabularies just storing the string |
|
171 | 172 | { |
172 | 173 | $this->setVocabids($vocabid); |
174 | + } |
|
173 | 175 | } else { |
174 | 176 | $this->vocab = $this->model->getVocabulary($vocabid); |
175 | 177 | } |
@@ -76,10 +76,12 @@ |
||
76 | 76 | */ |
77 | 77 | public function getUriSpace() |
78 | 78 | { |
79 | - if ($this->urispace === null) // initialize cache |
|
79 | + if ($this->urispace === null) { |
|
80 | + // initialize cache |
|
80 | 81 | { |
81 | 82 | $this->urispace = $this->resource->getLiteral('void:uriSpace')->getValue(); |
82 | 83 | } |
84 | + } |
|
83 | 85 | |
84 | 86 | return $this->urispace; |
85 | 87 | } |
@@ -68,10 +68,12 @@ |
||
68 | 68 | if ($sortable !== null) { |
69 | 69 | uksort($sortable, array($this, 'mycompare')); |
70 | 70 | foreach ($sortable as $prop => $vals) { |
71 | - if (is_array($prop)) // the ConceptProperty objects have their own sorting methods |
|
71 | + if (is_array($prop)) { |
|
72 | + // the ConceptProperty objects have their own sorting methods |
|
72 | 73 | { |
73 | 74 | ksort($sortable[$prop]); |
74 | 75 | } |
76 | + } |
|
75 | 77 | |
76 | 78 | } |
77 | 79 | } |
@@ -53,8 +53,9 @@ discard block |
||
53 | 53 | |
54 | 54 | // not found with selected language, try any language |
55 | 55 | $literal = $this->resource->getLiteral($property); |
56 | - if ($literal) |
|
57 | - return $literal->getValue(); |
|
56 | + if ($literal) { |
|
57 | + return $literal->getValue(); |
|
58 | + } |
|
58 | 59 | } |
59 | 60 | |
60 | 61 | /** |
@@ -95,8 +96,9 @@ discard block |
||
95 | 96 | public function getShortName() |
96 | 97 | { |
97 | 98 | $shortname = $this->getLiteral('skosmos:shortName'); |
98 | - if ($shortname) |
|
99 | - return $shortname; |
|
99 | + if ($shortname) { |
|
100 | + return $shortname; |
|
101 | + } |
|
100 | 102 | |
101 | 103 | // if no shortname exists fall back to the id |
102 | 104 | return $this->getId(); |
@@ -215,10 +217,12 @@ discard block |
||
215 | 217 | $ret = array(); |
216 | 218 | foreach ($resources as $res) { |
217 | 219 | $prop = $res->getURI(); |
218 | - if (EasyRdf_Namespace::shorten($prop) !== null) // shortening property labels if possible |
|
220 | + if (EasyRdf_Namespace::shorten($prop) !== null) { |
|
221 | + // shortening property labels if possible |
|
219 | 222 | { |
220 | 223 | $prop = EasyRdf_Namespace::shorten($prop); |
221 | 224 | } |
225 | + } |
|
222 | 226 | |
223 | 227 | $ret[] = $prop; |
224 | 228 | } |
@@ -235,10 +239,12 @@ discard block |
||
235 | 239 | $resources = $this->resource->allResources("skosmos:hasMultiLingualProperty"); |
236 | 240 | foreach ($resources as $res) { |
237 | 241 | $prop = $res->getURI(); |
238 | - if (EasyRdf_Namespace::shorten($prop) !== null) // shortening property labels if possible |
|
242 | + if (EasyRdf_Namespace::shorten($prop) !== null) { |
|
243 | + // shortening property labels if possible |
|
239 | 244 | { |
240 | 245 | $prop = EasyRdf_Namespace::shorten($prop); |
241 | 246 | } |
247 | + } |
|
242 | 248 | |
243 | 249 | if ($prop === $property) { |
244 | 250 | return true; |
@@ -339,11 +345,12 @@ discard block |
||
339 | 345 | public function getId() |
340 | 346 | { |
341 | 347 | $uriparts = explode("#", $this->resource->getURI()); |
342 | - if (count($uriparts) != 1) |
|
343 | - // hash namespace |
|
348 | + if (count($uriparts) != 1) { |
|
349 | + // hash namespace |
|
344 | 350 | { |
345 | 351 | return $uriparts[1]; |
346 | 352 | } |
353 | + } |
|
347 | 354 | |
348 | 355 | // slash namespace |
349 | 356 | $uriparts = explode("/", $this->resource->getURI()); |
@@ -371,10 +378,12 @@ discard block |
||
371 | 378 | $ret = array(); |
372 | 379 | foreach ($resources as $res) { |
373 | 380 | $prop = $res->getURI(); |
374 | - if (EasyRdf_Namespace::shorten($prop) !== null) // prefixing if possible |
|
381 | + if (EasyRdf_Namespace::shorten($prop) !== null) { |
|
382 | + // prefixing if possible |
|
375 | 383 | { |
376 | 384 | $prop = EasyRdf_Namespace::shorten($prop); |
377 | 385 | } |
386 | + } |
|
378 | 387 | |
379 | 388 | $ret[] = $prop; |
380 | 389 | } |
@@ -109,10 +109,12 @@ discard block |
||
109 | 109 | |
110 | 110 | private function initializeNamespaces() { |
111 | 111 | foreach ($this->namespaces as $prefix => $fullUri) { |
112 | - if ($prefix != '' && EasyRdf_Namespace::get($prefix) === null) // if not already defined |
|
112 | + if ($prefix != '' && EasyRdf_Namespace::get($prefix) === null) { |
|
113 | + // if not already defined |
|
113 | 114 | { |
114 | 115 | EasyRdf_Namespace::set($prefix, $fullUri); |
115 | 116 | } |
117 | + } |
|
116 | 118 | } |
117 | 119 | } |
118 | 120 | |
@@ -391,10 +393,12 @@ discard block |
||
391 | 393 | // register vocabulary ids as RDF namespace prefixes |
392 | 394 | $prefix = preg_replace('/\W+/', '', $voc->getId()); // strip non-word characters |
393 | 395 | try { |
394 | - if ($prefix != '' && EasyRdf_Namespace::get($prefix) === null) // if not already defined |
|
396 | + if ($prefix != '' && EasyRdf_Namespace::get($prefix) === null) { |
|
397 | + // if not already defined |
|
395 | 398 | { |
396 | 399 | EasyRdf_Namespace::set($prefix, $voc->getUriSpace()); |
397 | 400 | } |
401 | + } |
|
398 | 402 | |
399 | 403 | } catch (Exception $e) { |
400 | 404 | // not valid as namespace identifier, ignore |
@@ -506,8 +510,9 @@ discard block |
||
506 | 510 | } |
507 | 511 | |
508 | 512 | foreach ($vocabs as $vocab) { |
509 | - if ($vocab->getConceptLabel($uri, null) !== null) |
|
510 | - return $vocab; |
|
513 | + if ($vocab->getConceptLabel($uri, null) !== null) { |
|
514 | + return $vocab; |
|
515 | + } |
|
511 | 516 | } |
512 | 517 | |
513 | 518 | // if the URI couldn't be found, fall back to the first vocabulary |
@@ -387,7 +387,9 @@ discard block |
||
387 | 387 | $hits[] = $res; |
388 | 388 | } |
389 | 389 | } |
390 | - if (sizeof($hits) > 0) return $hits; |
|
390 | + if (sizeof($hits) > 0) { |
|
391 | + return $hits; |
|
392 | + } |
|
391 | 393 | |
392 | 394 | // case 2: case-insensitive match on preferred label |
393 | 395 | foreach ($results as $res) { |
@@ -395,7 +397,9 @@ discard block |
||
395 | 397 | $hits[] = $res; |
396 | 398 | } |
397 | 399 | } |
398 | - if (sizeof($hits) > 0) return $hits; |
|
400 | + if (sizeof($hits) > 0) { |
|
401 | + return $hits; |
|
402 | + } |
|
399 | 403 | |
400 | 404 | if ($lang === null) { |
401 | 405 | // case 1A: exact match on preferred label in any language |
@@ -406,7 +410,9 @@ discard block |
||
406 | 410 | $hits[] = $res; |
407 | 411 | } |
408 | 412 | } |
409 | - if (sizeof($hits) > 0) return $hits; |
|
413 | + if (sizeof($hits) > 0) { |
|
414 | + return $hits; |
|
415 | + } |
|
410 | 416 | |
411 | 417 | // case 2A: case-insensitive match on preferred label in any language |
412 | 418 | foreach ($results as $res) { |
@@ -416,7 +422,9 @@ discard block |
||
416 | 422 | $hits[] = $res; |
417 | 423 | } |
418 | 424 | } |
419 | - if (sizeof($hits) > 0) return $hits; |
|
425 | + if (sizeof($hits) > 0) { |
|
426 | + return $hits; |
|
427 | + } |
|
420 | 428 | } |
421 | 429 | |
422 | 430 | // case 3: exact match on alternate label |
@@ -425,7 +433,9 @@ discard block |
||
425 | 433 | $hits[] = $res; |
426 | 434 | } |
427 | 435 | } |
428 | - if (sizeof($hits) > 0) return $hits; |
|
436 | + if (sizeof($hits) > 0) { |
|
437 | + return $hits; |
|
438 | + } |
|
429 | 439 | |
430 | 440 | |
431 | 441 | // case 4: case-insensitive match on alternate label |
@@ -434,7 +444,9 @@ discard block |
||
434 | 444 | $hits[] = $res; |
435 | 445 | } |
436 | 446 | } |
437 | - if (sizeof($hits) > 0) return $hits; |
|
447 | + if (sizeof($hits) > 0) { |
|
448 | + return $hits; |
|
449 | + } |
|
438 | 450 | |
439 | 451 | return $hits; |
440 | 452 | } |
@@ -46,12 +46,16 @@ discard block |
||
46 | 46 | $this->client = new EasyRdf_Sparql_Client($endpoint); |
47 | 47 | |
48 | 48 | // set graphClause so that it can be used by all queries |
49 | - if ($this->isDefaultEndpoint()) // default endpoint; query any graph (and catch it in a variable) |
|
49 | + if ($this->isDefaultEndpoint()) { |
|
50 | + // default endpoint; query any graph (and catch it in a variable) |
|
50 | 51 | { |
51 | 52 | $this->graphClause = "GRAPH $graph"; |
52 | - } elseif ($graph) // query a specific graph |
|
53 | + } |
|
54 | + } elseif ($graph) { |
|
55 | + // query a specific graph |
|
53 | 56 | { |
54 | 57 | $this->graphClause = "GRAPH <$graph>"; |
58 | + } |
|
55 | 59 | } else // query the default graph |
56 | 60 | { |
57 | 61 | $this->graphClause = ""; |
@@ -78,8 +82,9 @@ discard block |
||
78 | 82 | } |
79 | 83 | } |
80 | 84 | foreach ($graphs as $graph) { |
81 | - if($graph !== NULL) |
|
82 | - $clause .= "FROM NAMED <$graph> "; |
|
85 | + if($graph !== NULL) { |
|
86 | + $clause .= "FROM NAMED <$graph> "; |
|
87 | + } |
|
83 | 88 | } |
84 | 89 | return $clause; |
85 | 90 | } |
@@ -1776,8 +1781,7 @@ discard block |
||
1776 | 1781 | if (sizeof($ret) > 0) { |
1777 | 1782 | // existing concept, with children |
1778 | 1783 | return $ret; |
1779 | - } |
|
1780 | - else { |
|
1784 | + } else { |
|
1781 | 1785 | // nonexistent concept |
1782 | 1786 | return null; |
1783 | 1787 | } |
@@ -75,8 +75,9 @@ |
||
75 | 75 | public function getSearchTerm() |
76 | 76 | { |
77 | 77 | $term = $this->request->getQueryParamRaw('q') ? $this->request->getQueryParamRaw('q') : $this->request->getQueryParamRaw('query'); |
78 | - if (!$term && $this->rest) |
|
79 | - $term = $this->request->getQueryParamRaw('label'); |
|
78 | + if (!$term && $this->rest) { |
|
79 | + $term = $this->request->getQueryParamRaw('label'); |
|
80 | + } |
|
80 | 81 | $term = trim($term); // surrounding whitespace is not considered significant |
81 | 82 | if ($this->rest) { |
82 | 83 | return $term; |
@@ -25,8 +25,7 @@ |
||
25 | 25 | public function store($key, $value, $ttl=3600) { |
26 | 26 | if (function_exists('apc_store')) { |
27 | 27 | return apc_store($key, $value); |
28 | - } |
|
29 | - else if (function_exists('apcu_store')) { |
|
28 | + } else if (function_exists('apcu_store')) { |
|
30 | 29 | return apcu_store($key, $value, $ttl); |
31 | 30 | } |
32 | 31 | } |