@@ -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 | } |
@@ -106,7 +106,7 @@ |
||
| 106 | 106 | |
| 107 | 107 | public function getRequestUri() |
| 108 | 108 | { |
| 109 | - return $this->getServerConstant('HTTP_HOST') . $this->getServerConstant('REQUEST_URI'); |
|
| 109 | + return $this->getServerConstant('HTTP_HOST').$this->getServerConstant('REQUEST_URI'); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | return Punic\Calendar::formatDate($val, 'short'); |
| 45 | 45 | } catch (Exception $e) { |
| 46 | 46 | trigger_error($e->getMessage(), E_USER_WARNING); |
| 47 | - return (string) $this->literal; |
|
| 47 | + return (string)$this->literal; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | return $this->literal->getValue(); |
@@ -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 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | return $lname; |
| 98 | 98 | } |
| 99 | 99 | // already a full URI |
| 100 | - return $this->getUriSpace() . $lname; |
|
| 100 | + return $this->getUriSpace().$lname; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | $prop = (substr($prop, 0, 5) == 'dc11:') ? str_replace('dc11:', 'dc:', $prop) : $prop; |
| 160 | 160 | $value = $val->getValue(); |
| 161 | 161 | if ($value instanceof DateTime) { |
| 162 | - $val = Punic\Calendar::formatDate($value, 'full', $lang) . ' ' . Punic\Calendar::format($value, 'HH:mm:ss', $lang); |
|
| 162 | + $val = Punic\Calendar::formatDate($value, 'full', $lang).' '.Punic\Calendar::format($value, 'HH:mm:ss', $lang); |
|
| 163 | 163 | } |
| 164 | 164 | $ret[$prop][] = $val; |
| 165 | 165 | } |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | } |
| 271 | 271 | // don't know how to parse |
| 272 | 272 | $rev = $parts[2]; |
| 273 | - $datestr = $parts[3] . ' ' . $parts[4]; |
|
| 273 | + $datestr = $parts[3].' '.$parts[4]; |
|
| 274 | 274 | |
| 275 | 275 | return "$datestr (r$rev)"; |
| 276 | 276 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | * Counts the statistics of the vocabulary. |
| 280 | 280 | * @return array of the concept/group counts |
| 281 | 281 | */ |
| 282 | - public function getStatistics($lang = '', $array=null, $group=null) |
|
| 282 | + public function getStatistics($lang = '', $array = null, $group = null) |
|
| 283 | 283 | { |
| 284 | 284 | $sparql = $this->getSparql(); |
| 285 | 285 | // find the number of concepts |
@@ -595,14 +595,14 @@ discard block |
||
| 595 | 595 | { |
| 596 | 596 | $changelist = $this->getSparql()->queryChangeList($clang, $offset, $prop); |
| 597 | 597 | $bydate = array(); |
| 598 | - foreach($changelist as $concept) { |
|
| 598 | + foreach ($changelist as $concept) { |
|
| 599 | 599 | $concept['datestring'] = Punic\Calendar::formatDate($concept['date'], 'medium', $lang); |
| 600 | - $bydate[Punic\Calendar::getMonthName($concept['date'], 'wide', $lang, true) . Punic\Calendar::format($concept['date'], ' y', $lang) ][strtolower($concept['prefLabel'])] = $concept; |
|
| 600 | + $bydate[Punic\Calendar::getMonthName($concept['date'], 'wide', $lang, true).Punic\Calendar::format($concept['date'], ' y', $lang)][strtolower($concept['prefLabel'])] = $concept; |
|
| 601 | 601 | } |
| 602 | 602 | return $bydate; |
| 603 | 603 | } |
| 604 | 604 | |
| 605 | - public function getTitle($lang=null) { |
|
| 605 | + public function getTitle($lang = null) { |
|
| 606 | 606 | return $this->config->getTitle($lang); |
| 607 | 607 | } |
| 608 | 608 | |
@@ -523,7 +523,7 @@ |
||
| 523 | 523 | * Get the label for a resource, preferring 1. the given language 2. configured languages 3. any language. |
| 524 | 524 | * @param EasyRdf_Resource $res resource whose label to return |
| 525 | 525 | * @param string $lang preferred language |
| 526 | - * @return EasyRdf_Literal label as an EasyRdf_Literal object, or null if not found |
|
| 526 | + * @return string label as an EasyRdf_Literal object, or null if not found |
|
| 527 | 527 | */ |
| 528 | 528 | public function getResourceLabel($res, $lang) |
| 529 | 529 | { |
@@ -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 |
@@ -63,15 +63,15 @@ discard block |
||
| 63 | 63 | private function initializeVocabularies() |
| 64 | 64 | { |
| 65 | 65 | if (!file_exists($this->getConfig()->getVocabularyConfigFile())) { |
| 66 | - throw new Exception($this->getConfig()->getVocabularyConfigFile() . ' is missing, please provide one.'); |
|
| 66 | + throw new Exception($this->getConfig()->getVocabularyConfigFile().' is missing, please provide one.'); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | try { |
| 70 | 70 | // use APC user cache to store parsed vocabularies.ttl configuration |
| 71 | 71 | if ($this->cache->isAvailable()) { |
| 72 | 72 | // @codeCoverageIgnoreStart |
| 73 | - $key = realpath($this->getConfig()->getVocabularyConfigFile()) . ", " . filemtime($this->getConfig()->getVocabularyConfigFile()); |
|
| 74 | - $nskey = "namespaces of " . $key; |
|
| 73 | + $key = realpath($this->getConfig()->getVocabularyConfigFile()).", ".filemtime($this->getConfig()->getVocabularyConfigFile()); |
|
| 74 | + $nskey = "namespaces of ".$key; |
|
| 75 | 75 | $this->graph = $this->cache->fetch($key); |
| 76 | 76 | $this->namespaces = $this->cache->fetch($nskey); |
| 77 | 77 | if ($this->graph === false || $this->namespaces === false) { // was not found in cache |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $this->parseVocabularies($this->getConfig()->getVocabularyConfigFile()); |
| 85 | 85 | } |
| 86 | 86 | } catch (Exception $e) { |
| 87 | - echo "Error: " . $e->getMessage(); |
|
| 87 | + echo "Error: ".$e->getMessage(); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | public function getVocabularyCategories() |
| 457 | 457 | { |
| 458 | 458 | $cats = $this->graph->allOfType('skos:Concept'); |
| 459 | - if(empty($cats)) { |
|
| 459 | + if (empty($cats)) { |
|
| 460 | 460 | return array(new VocabularyCategory($this, null)); |
| 461 | 461 | } |
| 462 | 462 | |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | // using apc cache for the resource if available |
| 630 | 630 | if ($this->cache->isAvailable()) { |
| 631 | 631 | // @codeCoverageIgnoreStart |
| 632 | - $key = 'fetch: ' . EasyRdf_Utils::removeFragmentFromUri($uri); |
|
| 632 | + $key = 'fetch: '.EasyRdf_Utils::removeFragmentFromUri($uri); |
|
| 633 | 633 | $resource = $this->cache->fetch($key); |
| 634 | 634 | if ($resource === null || $resource === false) { // was not found in cache, or previous request failed |
| 635 | 635 | $resource = $this->fetchResourceFromUri($uri); |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | */ |
| 651 | 651 | public function getSparqlImplementation($dialect, $endpoint, $graph) |
| 652 | 652 | { |
| 653 | - $classname = $dialect . "Sparql"; |
|
| 653 | + $classname = $dialect."Sparql"; |
|
| 654 | 654 | |
| 655 | 655 | return new $classname($endpoint, $graph, $this); |
| 656 | 656 | } |
@@ -10,6 +10,9 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class VocabularyCategory extends DataObject |
| 12 | 12 | { |
| 13 | + /** |
|
| 14 | + * @param Model $model |
|
| 15 | + */ |
|
| 13 | 16 | public function __construct($model, $resource) |
| 14 | 17 | { |
| 15 | 18 | if (!($model instanceof Model)) { |
@@ -23,6 +23,9 @@ |
||
| 23 | 23 | } |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | + /** |
|
| 27 | + * @param string $name |
|
| 28 | + */ |
|
| 26 | 29 | private function getConstant($name, $default) |
| 27 | 30 | { |
| 28 | 31 | if (defined($name) && constant($name)) { |
@@ -6,10 +6,10 @@ discard block |
||
| 6 | 6 | class GlobalConfig { |
| 7 | 7 | private $languages; |
| 8 | 8 | |
| 9 | - public function __construct($config_name='/../config.inc') |
|
| 9 | + public function __construct($config_name = '/../config.inc') |
|
| 10 | 10 | { |
| 11 | 11 | try { |
| 12 | - $file_path = dirname(__FILE__) . $config_name; |
|
| 12 | + $file_path = dirname(__FILE__).$config_name; |
|
| 13 | 13 | if (!file_exists($file_path)) { |
| 14 | 14 | throw new Exception('config.inc file is missing, please provide one.'); |
| 15 | 15 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | $this->languages = $LANGUAGES; |
| 19 | 19 | } |
| 20 | 20 | } catch (Exception $e) { |
| 21 | - echo "Error: " . $e->getMessage(); |
|
| 21 | + echo "Error: ".$e->getMessage(); |
|
| 22 | 22 | return; |
| 23 | 23 | } |
| 24 | 24 | } |
@@ -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 | } |
@@ -114,7 +114,7 @@ |
||
| 114 | 114 | */ |
| 115 | 115 | public function getEnvLang() |
| 116 | 116 | { |
| 117 | - // get language from locale, same as used by gettext, set by Controller |
|
| 118 | - return substr(getenv("LC_ALL"), 0, 2); // @codeCoverageIgnore |
|
| 117 | + // get language from locale, same as used by gettext, set by Controller |
|
| 118 | + return substr(getenv("LC_ALL"), 0, 2); // @codeCoverageIgnore |
|
| 119 | 119 | } |
| 120 | 120 | } |
@@ -55,6 +55,7 @@ discard block |
||
| 55 | 55 | * @param Vocabulary $vocab |
| 56 | 56 | * @param EasyRdf_Resource $resource |
| 57 | 57 | * @param EasyRdf_Graph $graph |
| 58 | + * @param string|null $clang |
|
| 58 | 59 | */ |
| 59 | 60 | public function __construct($model, $vocab, $resource, $graph, $clang) |
| 60 | 61 | { |
@@ -512,6 +513,7 @@ discard block |
||
| 512 | 513 | |
| 513 | 514 | /** |
| 514 | 515 | * Gets the groups/arrays the concept belongs to. |
| 516 | + * @param boolean $includeArrays |
|
| 515 | 517 | */ |
| 516 | 518 | public function getReverseResources($includeArrays) { |
| 517 | 519 | $groups = array(); |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | // 3. label in a subtag of the current language |
| 123 | 123 | // We need to check all the labels in case one of them matches a subtag of the current language |
| 124 | - foreach($this->resource->allLiterals('skos:prefLabel') as $label) { |
|
| 124 | + foreach ($this->resource->allLiterals('skos:prefLabel') as $label) { |
|
| 125 | 125 | // the label lang code is a subtag of the UI lang eg. en-GB - create a new literal with the main language |
| 126 | - if ($label !== null && strpos($label->getLang(), $lang . '-') === 0) { |
|
| 126 | + if ($label !== null && strpos($label->getLang(), $lang.'-') === 0) { |
|
| 127 | 127 | return EasyRdf_Literal::create($label, $lang); |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | // 4. label in any language, including literal with empty language tag |
| 132 | 132 | $label = $this->resource->label(); |
| 133 | 133 | if ($label !== null) { |
| 134 | - return $label->getLang() ? $label->getValue() . " (" . $label->getLang() . ")" : $label->getValue(); |
|
| 134 | + return $label->getLang() ? $label->getValue()." (".$label->getLang().")" : $label->getValue(); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // empty |
@@ -456,14 +456,14 @@ discard block |
||
| 456 | 456 | |
| 457 | 457 | // making a human readable string from the timestamps |
| 458 | 458 | if ($created != '') { |
| 459 | - $ret = gettext('skosmos:created') . ' ' . (Punic\Calendar::formatDate($created, 'short')); |
|
| 459 | + $ret = gettext('skosmos:created').' '.(Punic\Calendar::formatDate($created, 'short')); |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | if ($modified != '') { |
| 463 | 463 | if ($created != '') { |
| 464 | - $ret .= ', ' . gettext('skosmos:modified') . ' ' . (Punic\Calendar::formatDate($modified, 'short')); |
|
| 464 | + $ret .= ', '.gettext('skosmos:modified').' '.(Punic\Calendar::formatDate($modified, 'short')); |
|
| 465 | 465 | } else { |
| 466 | - $ret .= ' ' . ucfirst(gettext('skosmos:modified')) . ' ' . (Punic\Calendar::formatDate($modified, 'short')); |
|
| 466 | + $ret .= ' '.ucfirst(gettext('skosmos:modified')).' '.(Punic\Calendar::formatDate($modified, 'short')); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | } |
@@ -471,12 +471,12 @@ discard block |
||
| 471 | 471 | trigger_error($e->getMessage(), E_USER_WARNING); |
| 472 | 472 | $ret = ''; |
| 473 | 473 | if ($this->resource->get('dc:modified')) { |
| 474 | - $modified = (string) $this->resource->get('dc:modified'); |
|
| 475 | - $ret = gettext('skosmos:modified') . ' ' . $modified; |
|
| 474 | + $modified = (string)$this->resource->get('dc:modified'); |
|
| 475 | + $ret = gettext('skosmos:modified').' '.$modified; |
|
| 476 | 476 | } |
| 477 | 477 | if ($this->resource->get('dc:created')) { |
| 478 | - $created .= (string) $this->resource->get('dc:created'); |
|
| 479 | - $ret .= ' ' . gettext('skosmos:created') . ' ' . $created; |
|
| 478 | + $created .= (string)$this->resource->get('dc:created'); |
|
| 479 | + $ret .= ' '.gettext('skosmos:created').' '.$created; |
|
| 480 | 480 | } |
| 481 | 481 | } |
| 482 | 482 | return $ret; |
@@ -584,13 +584,13 @@ discard block |
||
| 584 | 584 | $labels = array(); |
| 585 | 585 | foreach ($this->resource->allLiterals('skos:prefLabel') as $lit) { |
| 586 | 586 | // filtering away subsets of the current language eg. en vs en-GB |
| 587 | - if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang() . '-') !== 0) { |
|
| 587 | + if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang().'-') !== 0) { |
|
| 588 | 588 | $labels[$this->literalLanguageToString($lit)][] = new ConceptPropertyValueLiteral($lit, 'skos:prefLabel'); |
| 589 | 589 | } |
| 590 | 590 | } |
| 591 | 591 | foreach ($this->resource->allLiterals('skos:altLabel') as $lit) { |
| 592 | 592 | // filtering away subsets of the current language eg. en vs en-GB |
| 593 | - if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang() . '-') !== 0) { |
|
| 593 | + if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang().'-') !== 0) { |
|
| 594 | 594 | $labels[$this->literalLanguageToString($lit)][] = new ConceptPropertyValueLiteral($lit, 'skos:altLabel'); |
| 595 | 595 | } |
| 596 | 596 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | } elseif ($parts[1] == 'data') { |
| 38 | 38 | $controller->data($request); |
| 39 | 39 | } elseif (sizeof($parts) == 2) { |
| 40 | - header("Location: " . $parts[1] . "/"); |
|
| 40 | + header("Location: ".$parts[1]."/"); |
|
| 41 | 41 | } else { |
| 42 | 42 | $vocab = $parts[1]; |
| 43 | 43 | try { |
@@ -93,5 +93,5 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | } catch (Exception $e) { |
| 95 | 95 | header("HTTP/1.0 500 Internal Server Error"); |
| 96 | - echo('ERROR: ' . $e->getMessage()); |
|
| 96 | + echo('ERROR: '.$e->getMessage()); |
|
| 97 | 97 | } |