@@ -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 | } |
@@ -67,8 +67,9 @@ |
||
| 67 | 67 | public function getSearchTerm() |
| 68 | 68 | { |
| 69 | 69 | $term = $this->request->getQueryParam('q') ? $this->request->getQueryParam('q') : $this->request->getQueryParam('query'); |
| 70 | - if (!$term && $this->rest) |
|
| 71 | - $term = $this->request->getQueryParam('label'); |
|
| 70 | + if (!$term && $this->rest) { |
|
| 71 | + $term = $this->request->getQueryParam('label'); |
|
| 72 | + } |
|
| 72 | 73 | $term = trim($term); // surrounding whitespace is not considered significant |
| 73 | 74 | return strpos($term, "*") === false ? $term . "*" : $term; // default to prefix search |
| 74 | 75 | } |
@@ -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 | } |
@@ -407,7 +407,9 @@ discard block |
||
| 407 | 407 | $hits[] = $res; |
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | - if (sizeof($hits) > 0) return $hits; |
|
| 410 | + if (sizeof($hits) > 0) { |
|
| 411 | + return $hits; |
|
| 412 | + } |
|
| 411 | 413 | |
| 412 | 414 | // case 2: case-insensitive match on preferred label |
| 413 | 415 | foreach ($results as $res) { |
@@ -415,7 +417,9 @@ discard block |
||
| 415 | 417 | $hits[] = $res; |
| 416 | 418 | } |
| 417 | 419 | } |
| 418 | - if (sizeof($hits) > 0) return $hits; |
|
| 420 | + if (sizeof($hits) > 0) { |
|
| 421 | + return $hits; |
|
| 422 | + } |
|
| 419 | 423 | |
| 420 | 424 | // case 3: exact match on alternate label |
| 421 | 425 | foreach ($results as $res) { |
@@ -423,7 +427,9 @@ discard block |
||
| 423 | 427 | $hits[] = $res; |
| 424 | 428 | } |
| 425 | 429 | } |
| 426 | - if (sizeof($hits) > 0) return $hits; |
|
| 430 | + if (sizeof($hits) > 0) { |
|
| 431 | + return $hits; |
|
| 432 | + } |
|
| 427 | 433 | |
| 428 | 434 | |
| 429 | 435 | // case 4: case-insensitive match on alternate label |
@@ -64,12 +64,16 @@ discard block |
||
| 64 | 64 | $this->model = $model; |
| 65 | 65 | |
| 66 | 66 | // set graphClause so that it can be used by all queries |
| 67 | - if ($this->isDefaultEndpoint()) // default endpoint; query any graph (and catch it in a variable) |
|
| 67 | + if ($this->isDefaultEndpoint()) { |
|
| 68 | + // default endpoint; query any graph (and catch it in a variable) |
|
| 68 | 69 | { |
| 69 | 70 | $this->graphClause = "GRAPH $graph"; |
| 70 | - } elseif ($graph) // query a specific graph |
|
| 71 | + } |
|
| 72 | + } elseif ($graph) { |
|
| 73 | + // query a specific graph |
|
| 71 | 74 | { |
| 72 | 75 | $this->graphClause = "GRAPH <$graph>"; |
| 76 | + } |
|
| 73 | 77 | } else // query the default graph |
| 74 | 78 | { |
| 75 | 79 | $this->graphClause = ""; |
@@ -1711,8 +1715,7 @@ discard block |
||
| 1711 | 1715 | if (sizeof($ret) > 0) { |
| 1712 | 1716 | // existing concept, with children |
| 1713 | 1717 | return $ret; |
| 1714 | - } |
|
| 1715 | - else { |
|
| 1718 | + } else { |
|
| 1716 | 1719 | // nonexistent concept |
| 1717 | 1720 | return null; |
| 1718 | 1721 | } |
@@ -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 |