| @@ -136,9 +136,9 @@ discard block | ||
| 136 | 136 | return $this->resource->label($fallback); | 
| 137 | 137 | } | 
| 138 | 138 | // We need to check all the labels in case one of them matches a subtag of the current language | 
| 139 | -            foreach($this->resource->allLiterals('skos:prefLabel') as $label) { | |
| 139 | +            foreach ($this->resource->allLiterals('skos:prefLabel') as $label) { | |
| 140 | 140 | // the label lang code is a subtag of the UI lang eg. en-GB - create a new literal with the main language | 
| 141 | -                if ($label !== null && strpos($label->getLang(), $fallback . '-') === 0) { | |
| 141 | +                if ($label !== null && strpos($label->getLang(), $fallback.'-') === 0) { | |
| 142 | 142 | return EasyRdf\Literal::create($label, $fallback); | 
| 143 | 143 | } | 
| 144 | 144 | } | 
| @@ -159,7 +159,7 @@ discard block | ||
| 159 | 159 | |
| 160 | 160 | public function hasXlLabel($prop = 'prefLabel') | 
| 161 | 161 |      { | 
| 162 | -        if ($this->resource->hasProperty('skosxl:' . $prop)) { | |
| 162 | +        if ($this->resource->hasProperty('skosxl:'.$prop)) { | |
| 163 | 163 | return true; | 
| 164 | 164 | } | 
| 165 | 165 | return false; | 
| @@ -168,7 +168,7 @@ discard block | ||
| 168 | 168 | public function getXlLabel() | 
| 169 | 169 |      { | 
| 170 | 170 |          $labels = $this->resource->allResources('skosxl:prefLabel'); | 
| 171 | -        foreach($labels as $labres) { | |
| 171 | +        foreach ($labels as $labres) { | |
| 172 | 172 |              $label = $labres->getLiteral('skosxl:literalForm'); | 
| 173 | 173 |              if ($label !== null && $label->getLang() == $this->clang) { | 
| 174 | 174 | return new LabelSkosXL($this->model, $labres); | 
| @@ -275,7 +275,7 @@ discard block | ||
| 275 | 275 | // catch external subjects that have $res as object | 
| 276 | 276 |          $extSubjects = $exGraph->resourcesMatching("schema:about", $res); | 
| 277 | 277 | |
| 278 | - $propList = array_unique(array_merge( | |
| 278 | + $propList = array_unique(array_merge( | |
| 279 | 279 | $this->DEFAULT_EXT_PROPERTIES, | 
| 280 | 280 | $this->getVocab()->getConfig()->getExtProperties(), | 
| 281 | 281 | $this->getVocab()->getConfig()->getPluginRegister()->getExtProperties() | 
| @@ -300,7 +300,7 @@ discard block | ||
| 300 | 300 | * @param string[] $seen Processed resources so far | 
| 301 | 301 | * @param string[] $props (optional) limit to these property URIs | 
| 302 | 302 | */ | 
| 303 | - private function addExternalTriplesToGraph($res, &$seen, $props=null) | |
| 303 | + private function addExternalTriplesToGraph($res, &$seen, $props = null) | |
| 304 | 304 |      { | 
| 305 | 305 |          if (array_key_exists($res->getUri(), $seen) && $seen[$res->getUri()] === 0) { | 
| 306 | 306 | return; | 
| @@ -330,7 +330,7 @@ discard block | ||
| 330 | 330 | */ | 
| 331 | 331 | private function addPropertyValues($res, $prop, &$seen) | 
| 332 | 332 |      { | 
| 333 | -        $resList = $res->allResources('<' . $prop . '>'); | |
| 333 | +        $resList = $res->allResources('<'.$prop.'>'); | |
| 334 | 334 | |
| 335 | 335 |          foreach ($resList as $res2) { | 
| 336 | 336 |              if ($res2->isBNode()) { | 
| @@ -340,7 +340,7 @@ discard block | ||
| 340 | 340 | $this->addResourceReifications($res, $prop, $res2, $seen); | 
| 341 | 341 | } | 
| 342 | 342 | |
| 343 | -        $litList = $res->allLiterals('<' . $prop . '>'); | |
| 343 | +        $litList = $res->allLiterals('<'.$prop.'>'); | |
| 344 | 344 | |
| 345 | 345 |          foreach ($litList as $lit) { | 
| 346 | 346 | $this->graph->addLiteral($res, $prop, $lit); | 
| @@ -528,15 +528,15 @@ discard block | ||
| 528 | 528 | // if not found in current vocabulary, look up in the default graph to be able | 
| 529 | 529 | // to read an ontology loaded in a separate graph | 
| 530 | 530 | // note that this imply that the property has an rdf:type declared for the query to work | 
| 531 | -                if(!$is_well_known && !$proplabel) { | |
| 531 | +                if (!$is_well_known && !$proplabel) { | |
| 532 | 532 | $envLangLabels = $this->model->getDefaultSparql()->queryLabel($longUri, $this->getEnvLang()); | 
| 533 | 533 | |
| 534 | 534 | $defaultPropLabel = $this->model->getDefaultSparql()->queryLabel($longUri, ''); | 
| 535 | 535 | |
| 536 | -					if($envLangLabels) { | |
| 536 | +					if ($envLangLabels) { | |
| 537 | 537 | $proplabel = $envLangLabels[$this->getEnvLang()]; | 
| 538 | 538 |                      } else { | 
| 539 | -						if($defaultPropLabel) { | |
| 539 | +						if ($defaultPropLabel) { | |
| 540 | 540 | $proplabel = $defaultPropLabel['']; | 
| 541 | 541 | } | 
| 542 | 542 | } | 
| @@ -549,12 +549,12 @@ discard block | ||
| 549 | 549 | } | 
| 550 | 550 | |
| 551 | 551 | // also look up superprops in the default graph if not found in current vocabulary | 
| 552 | -                if(!$is_well_known && (!$superprops || empty($superprops))) { | |
| 552 | +                if (!$is_well_known && (!$superprops || empty($superprops))) { | |
| 553 | 553 | $superprops = $this->model->getDefaultSparql()->querySuperProperties($longUri); | 
| 554 | 554 | } | 
| 555 | 555 | |
| 556 | 556 | // we're reading only one super property, even if there are multiple ones | 
| 557 | - $superprop = ($superprops)?$superprops[0]:null; | |
| 557 | + $superprop = ($superprops) ? $superprops[0] : null; | |
| 558 | 558 |                  if ($superprop) { | 
| 559 | 559 | $superprop = EasyRdf\RdfNamespace::shorten($superprop) ? EasyRdf\RdfNamespace::shorten($superprop) : $superprop; | 
| 560 | 560 | } | 
| @@ -567,7 +567,7 @@ discard block | ||
| 567 | 567 | } | 
| 568 | 568 | |
| 569 | 569 | // searching for subproperties of literals too | 
| 570 | -                if($superprops) { | |
| 570 | +                if ($superprops) { | |
| 571 | 571 |                      foreach ($superprops as $subi) { | 
| 572 | 572 | $suburi = EasyRdf\RdfNamespace::shorten($subi) ? EasyRdf\RdfNamespace::shorten($subi) : $subi; | 
| 573 | 573 | $duplicates[$suburi] = $prop; | 
| @@ -729,14 +729,14 @@ discard block | ||
| 729 | 729 | |
| 730 | 730 | // making a human readable string from the timestamps | 
| 731 | 731 |              if ($created != '') { | 
| 732 | -                $ret = gettext('skosmos:created') . ' ' . (Punic\Calendar::formatDate($created, 'short', $this->getEnvLang())); | |
| 732 | +                $ret = gettext('skosmos:created').' '.(Punic\Calendar::formatDate($created, 'short', $this->getEnvLang())); | |
| 733 | 733 | } | 
| 734 | 734 | |
| 735 | 735 |              if ($modified != '') { | 
| 736 | 736 |                  if ($created != '') { | 
| 737 | -                    $ret .= ', ' . gettext('skosmos:modified') . ' ' . (Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang())); | |
| 737 | +                    $ret .= ', '.gettext('skosmos:modified').' '.(Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang())); | |
| 738 | 738 |                  } else { | 
| 739 | -                    $ret .= ' ' . ucfirst(gettext('skosmos:modified')) . ' ' . (Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang())); | |
| 739 | +                    $ret .= ' '.ucfirst(gettext('skosmos:modified')).' '.(Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang())); | |
| 740 | 740 | } | 
| 741 | 741 | |
| 742 | 742 | } | 
| @@ -744,12 +744,12 @@ discard block | ||
| 744 | 744 | trigger_error($e->getMessage(), E_USER_WARNING); | 
| 745 | 745 | $ret = ''; | 
| 746 | 746 |              if ($this->resource->get('dc:modified')) { | 
| 747 | -                $modified = (string) $this->resource->get('dc:modified'); | |
| 748 | -                $ret = gettext('skosmos:modified') . ' ' . $modified; | |
| 747 | +                $modified = (string)$this->resource->get('dc:modified'); | |
| 748 | +                $ret = gettext('skosmos:modified').' '.$modified; | |
| 749 | 749 | } | 
| 750 | 750 |              if ($this->resource->get('dc:created')) { | 
| 751 | -                $created .= (string) $this->resource->get('dc:created'); | |
| 752 | -                $ret .= ' ' . gettext('skosmos:created') . ' ' . $created; | |
| 751 | +                $created .= (string)$this->resource->get('dc:created'); | |
| 752 | +                $ret .= ' '.gettext('skosmos:created').' '.$created; | |
| 753 | 753 | } | 
| 754 | 754 | } | 
| 755 | 755 | return $ret; | 
| @@ -821,7 +821,7 @@ discard block | ||
| 821 | 821 | $groups[$collLabel] = array($group); | 
| 822 | 822 | |
| 823 | 823 | $res = $collection; | 
| 824 | -                    while($super = $this->graph->resourcesMatching('skos:member', $res)) { | |
| 824 | +                    while ($super = $this->graph->resourcesMatching('skos:member', $res)) { | |
| 825 | 825 |                          foreach ($super as $res) { | 
| 826 | 826 | $superprop = new ConceptPropertyValue($this->model, $this->vocab, $res, 'skosmos:memberOfSuper', $this->clang); | 
| 827 | 827 | array_unshift($groups[$collLabel], $superprop); | 
| @@ -866,7 +866,7 @@ discard block | ||
| 866 | 866 | |
| 867 | 867 |          foreach ($labels as $lit) { | 
| 868 | 868 | // filtering away subsets of the current language eg. en vs en-GB | 
| 869 | -            if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang() . '-') !== 0) { | |
| 869 | +            if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang().'-') !== 0) { | |
| 870 | 870 | $langCode = $lit->getLang() ? $lit->getLang() : ''; | 
| 871 | 871 | $ret[$langCode][$key][] = new ConceptPropertyValueLiteral($this->model, $this->vocab, $this->resource, $lit, $prop); | 
| 872 | 872 | } | 
| @@ -958,10 +958,10 @@ discard block | ||
| 958 | 958 | } | 
| 959 | 959 |              else if ($context[$vocabPrefix] !== $vocabUriSpace) { | 
| 960 | 960 | $i = 2; | 
| 961 | -                while (isset($context[$vocabPrefix . $i]) && $context[$vocabPrefix . $i] !== $vocabUriSpace) { | |
| 961 | +                while (isset($context[$vocabPrefix.$i]) && $context[$vocabPrefix.$i] !== $vocabUriSpace) { | |
| 962 | 962 | $i += 1; | 
| 963 | 963 | } | 
| 964 | - $context[$vocabPrefix . $i] = $vocabUriSpace; | |
| 964 | + $context[$vocabPrefix.$i] = $vocabUriSpace; | |
| 965 | 965 | } | 
| 966 | 966 | } | 
| 967 | 967 |          $compactJsonLD = \ML\JsonLD\JsonLD::compact($this->graph->serialise('jsonld'), json_encode($context)); | 
| @@ -28,7 +28,7 @@ discard block | ||
| 28 | 28 | "skos:related", "skos:historyNote", "skosmos:memberOf", | 
| 29 | 29 | "skosmos:memberOfArray"); | 
| 30 | 30 | |
| 31 | - public function __construct($resource, $globalPlugins=array()) | |
| 31 | + public function __construct($resource, $globalPlugins = array()) | |
| 32 | 32 |      { | 
| 33 | 33 | $this->resource = $resource; | 
| 34 | 34 | $this->globalPlugins = $globalPlugins; | 
| @@ -117,7 +117,7 @@ discard block | ||
| 117 | 117 | $paramValue = $paramLiteral->getValue(); | 
| 118 | 118 | $paramLang = $paramLiteral->getLang(); | 
| 119 | 119 |                  if ($paramLang) { | 
| 120 | - $paramName .= '_' . $paramLang; | |
| 120 | + $paramName .= '_'.$paramLang; | |
| 121 | 121 | } | 
| 122 | 122 | $this->pluginParameters[$pluginName][$paramName] = $paramValue; | 
| 123 | 123 | } | 
| @@ -183,7 +183,7 @@ discard block | ||
| 183 | 183 | $langs = $this->getLanguages(); | 
| 184 | 184 | $deflang = reset($langs); // picking the first one from the list with reset since the keys are not numeric | 
| 185 | 185 |          if (sizeof($langs) > 1) { | 
| 186 | -            trigger_error("Default language for vocabulary '" . $this->getShortName() . "' unknown, choosing '$deflang'.", E_USER_WARNING); | |
| 186 | +            trigger_error("Default language for vocabulary '".$this->getShortName()."' unknown, choosing '$deflang'.", E_USER_WARNING); | |
| 187 | 187 | } | 
| 188 | 188 | |
| 189 | 189 | return $deflang; | 
| @@ -52,8 +52,7 @@ discard block | ||
| 52 | 52 |                  if ($plugin instanceof EasyRdf\Literal) { | 
| 53 | 53 | $pluginName = $plugin->getValue(); | 
| 54 | 54 | array_push($pluginArray, $pluginName); | 
| 55 | - } | |
| 56 | -                else { | |
| 55 | +                } else { | |
| 57 | 56 |                      array_push($pluginArray, $plugin->getLiteral('skosmos:usePlugin')->getValue()); | 
| 58 | 57 | } | 
| 59 | 58 | } | 
| @@ -206,8 +205,9 @@ discard block | ||
| 206 | 205 | public function getShortName() | 
| 207 | 206 |      { | 
| 208 | 207 |          $shortname = $this->getLiteral('skosmos:shortName'); | 
| 209 | - if ($shortname) | |
| 210 | - return $shortname; | |
| 208 | +        if ($shortname) { | |
| 209 | + return $shortname; | |
| 210 | + } | |
| 211 | 211 | |
| 212 | 212 | // if no shortname exists fall back to the id | 
| 213 | 213 | return $this->getId(); | 
| @@ -357,10 +357,12 @@ discard block | ||
| 357 | 357 | $ret = array(); | 
| 358 | 358 |          foreach ($resources as $res) { | 
| 359 | 359 | $prop = $res->getURI(); | 
| 360 | - if (EasyRdf\RdfNamespace::shorten($prop) !== null) // shortening property labels if possible | |
| 360 | +            if (EasyRdf\RdfNamespace::shorten($prop) !== null) { | |
| 361 | + // shortening property labels if possible | |
| 361 | 362 |              { | 
| 362 | 363 | $prop = EasyRdf\RdfNamespace::shorten($prop); | 
| 363 | 364 | } | 
| 365 | + } | |
| 364 | 366 | |
| 365 | 367 | $ret[] = $prop; | 
| 366 | 368 | } | 
| @@ -377,10 +379,12 @@ discard block | ||
| 377 | 379 |          $resources = $this->resource->allResources("skosmos:hasMultiLingualProperty"); | 
| 378 | 380 |          foreach ($resources as $res) { | 
| 379 | 381 | $prop = $res->getURI(); | 
| 380 | - if (EasyRdf\RdfNamespace::shorten($prop) !== null) // shortening property labels if possible | |
| 382 | +            if (EasyRdf\RdfNamespace::shorten($prop) !== null) { | |
| 383 | + // shortening property labels if possible | |
| 381 | 384 |              { | 
| 382 | 385 | $prop = EasyRdf\RdfNamespace::shorten($prop); | 
| 383 | 386 | } | 
| 387 | + } | |
| 384 | 388 | |
| 385 | 389 |              if ($prop === $property) { | 
| 386 | 390 | return true; | 
| @@ -526,11 +530,12 @@ discard block | ||
| 526 | 530 | public function getId() | 
| 527 | 531 |      { | 
| 528 | 532 |          $uriparts = explode("#", $this->resource->getURI()); | 
| 529 | - if (count($uriparts) != 1) | |
| 530 | - // hash namespace | |
| 533 | +        if (count($uriparts) != 1) { | |
| 534 | + // hash namespace | |
| 531 | 535 |          { | 
| 532 | 536 | return $uriparts[1]; | 
| 533 | 537 | } | 
| 538 | + } | |
| 534 | 539 | |
| 535 | 540 | // slash namespace | 
| 536 | 541 |          $uriparts = explode("/", $this->resource->getURI()); | 
| @@ -558,10 +563,12 @@ discard block | ||
| 558 | 563 | $ret = array(); | 
| 559 | 564 |          foreach ($resources as $res) { | 
| 560 | 565 | $prop = $res->getURI(); | 
| 561 | - if (EasyRdf\RdfNamespace::shorten($prop) !== null) // prefixing if possible | |
| 566 | +            if (EasyRdf\RdfNamespace::shorten($prop) !== null) { | |
| 567 | + // prefixing if possible | |
| 562 | 568 |              { | 
| 563 | 569 | $prop = EasyRdf\RdfNamespace::shorten($prop); | 
| 564 | 570 | } | 
| 571 | + } | |
| 565 | 572 | |
| 566 | 573 | $ret[] = $prop; | 
| 567 | 574 | } |