@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -79,10 +79,12 @@ |
||
| 79 | 79 | if ($sortable !== null) { |
| 80 | 80 | uksort($sortable, array($this, 'mycompare')); |
| 81 | 81 | foreach ($sortable as $prop => $vals) { |
| 82 | - if (is_array($prop)) // the ConceptProperty objects have their own sorting methods |
|
| 82 | + if (is_array($prop)) { |
|
| 83 | + // the ConceptProperty objects have their own sorting methods |
|
| 83 | 84 | { |
| 84 | 85 | ksort($sortable[$prop]); |
| 85 | 86 | } |
| 87 | + } |
|
| 86 | 88 | } |
| 87 | 89 | } |
| 88 | 90 | return $sortable; |
@@ -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 = ""; |
@@ -100,8 +104,9 @@ discard block |
||
| 100 | 104 | } |
| 101 | 105 | } |
| 102 | 106 | foreach ($graphs as $graph) { |
| 103 | - if($graph !== NULL) |
|
| 104 | - $clause .= "FROM NAMED <$graph> "; |
|
| 107 | + if($graph !== NULL) { |
|
| 108 | + $clause .= "FROM NAMED <$graph> "; |
|
| 109 | + } |
|
| 105 | 110 | } |
| 106 | 111 | return $clause; |
| 107 | 112 | } |
@@ -1847,8 +1852,7 @@ discard block |
||
| 1847 | 1852 | if (sizeof($ret) > 0) { |
| 1848 | 1853 | // existing concept, with children |
| 1849 | 1854 | return $ret; |
| 1850 | - } |
|
| 1851 | - else { |
|
| 1855 | + } else { |
|
| 1852 | 1856 | // nonexistent concept |
| 1853 | 1857 | return null; |
| 1854 | 1858 | } |
@@ -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\RdfNamespace::shorten($prop) !== null) // shortening property labels if possible |
|
| 220 | + if (EasyRdf\RdfNamespace::shorten($prop) !== null) { |
|
| 221 | + // shortening property labels if possible |
|
| 219 | 222 | { |
| 220 | 223 | $prop = EasyRdf\RdfNamespace::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\RdfNamespace::shorten($prop) !== null) // shortening property labels if possible |
|
| 242 | + if (EasyRdf\RdfNamespace::shorten($prop) !== null) { |
|
| 243 | + // shortening property labels if possible |
|
| 239 | 244 | { |
| 240 | 245 | $prop = EasyRdf\RdfNamespace::shorten($prop); |
| 241 | 246 | } |
| 247 | + } |
|
| 242 | 248 | |
| 243 | 249 | if ($prop === $property) { |
| 244 | 250 | return true; |
@@ -346,11 +352,12 @@ discard block |
||
| 346 | 352 | public function getId() |
| 347 | 353 | { |
| 348 | 354 | $uriparts = explode("#", $this->resource->getURI()); |
| 349 | - if (count($uriparts) != 1) |
|
| 350 | - // hash namespace |
|
| 355 | + if (count($uriparts) != 1) { |
|
| 356 | + // hash namespace |
|
| 351 | 357 | { |
| 352 | 358 | return $uriparts[1]; |
| 353 | 359 | } |
| 360 | + } |
|
| 354 | 361 | |
| 355 | 362 | // slash namespace |
| 356 | 363 | $uriparts = explode("/", $this->resource->getURI()); |
@@ -378,10 +385,12 @@ discard block |
||
| 378 | 385 | $ret = array(); |
| 379 | 386 | foreach ($resources as $res) { |
| 380 | 387 | $prop = $res->getURI(); |
| 381 | - if (EasyRdf\RdfNamespace::shorten($prop) !== null) // prefixing if possible |
|
| 388 | + if (EasyRdf\RdfNamespace::shorten($prop) !== null) { |
|
| 389 | + // prefixing if possible |
|
| 382 | 390 | { |
| 383 | 391 | $prop = EasyRdf\RdfNamespace::shorten($prop); |
| 384 | 392 | } |
| 393 | + } |
|
| 385 | 394 | |
| 386 | 395 | $ret[] = $prop; |
| 387 | 396 | } |
@@ -108,10 +108,12 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | private function initializeNamespaces() { |
| 110 | 110 | foreach ($this->namespaces as $prefix => $fullUri) { |
| 111 | - if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) // if not already defined |
|
| 111 | + if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) { |
|
| 112 | + // if not already defined |
|
| 112 | 113 | { |
| 113 | 114 | EasyRdf\RdfNamespace::set($prefix, $fullUri); |
| 114 | 115 | } |
| 116 | + } |
|
| 115 | 117 | } |
| 116 | 118 | } |
| 117 | 119 | |
@@ -423,10 +425,12 @@ discard block |
||
| 423 | 425 | // register vocabulary ids as RDF namespace prefixes |
| 424 | 426 | $prefix = preg_replace('/\W+/', '', $voc->getId()); // strip non-word characters |
| 425 | 427 | try { |
| 426 | - if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) // if not already defined |
|
| 428 | + if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) { |
|
| 429 | + // if not already defined |
|
| 427 | 430 | { |
| 428 | 431 | EasyRdf\RdfNamespace::set($prefix, $voc->getUriSpace()); |
| 429 | 432 | } |
| 433 | + } |
|
| 430 | 434 | |
| 431 | 435 | } catch (Exception $e) { |
| 432 | 436 | // not valid as namespace identifier, ignore |
@@ -538,8 +542,9 @@ discard block |
||
| 538 | 542 | } |
| 539 | 543 | |
| 540 | 544 | foreach ($vocabs as $vocab) { |
| 541 | - if ($vocab->getConceptLabel($uri, null) !== null) |
|
| 542 | - return $vocab; |
|
| 545 | + if ($vocab->getConceptLabel($uri, null) !== null) { |
|
| 546 | + return $vocab; |
|
| 547 | + } |
|
| 543 | 548 | } |
| 544 | 549 | |
| 545 | 550 | // if the URI couldn't be found, fall back to the first vocabulary |