Passed
Pull Request — master (#1327)
by
unknown
03:11
created
model/BaseConfig.php 3 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,8 +55,9 @@
 block discarded – undo
55 55
 
56 56
         // not found with selected language, try any language
57 57
         $literal = $this->getResource()->getLiteral($property);
58
-        if ($literal)
59
-          return $literal->getValue();
58
+        if ($literal) {
59
+                  return $literal->getValue();
60
+        }
60 61
 
61 62
         return $default;
62 63
     }
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@
 block discarded – undo
7 7
 abstract class BaseConfig extends DataObject
8 8
 {
9 9
 
10
-	/**
11
-     * Returns a boolean value based on a literal value from the config.ttl configuration.
12
-     * @param string $property the property to query
13
-     * @param boolean $default the default value if the value is not set in configuration
14
-     * @return boolean the boolean value for the given property, or the default value if not found
15
-     */
10
+  /**
11
+   * Returns a boolean value based on a literal value from the config.ttl configuration.
12
+   * @param string $property the property to query
13
+   * @param boolean $default the default value if the value is not set in configuration
14
+   * @return boolean the boolean value for the given property, or the default value if not found
15
+   */
16 16
     protected function getBoolean($property, $default = false)
17 17
     {
18 18
         $val = $this->getResource()->getLiteral($property);
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
      * @param string $lang preferred language for the literal
45 45
      * @return string string value for the given property, or the default value if not found
46 46
      */
47
-    protected function getLiteral($property, $default=null, $lang=null)
47
+    protected function getLiteral($property, $default = null, $lang = null)
48 48
     {
49 49
         if (!isset($lang)) {
50 50
             $lang = $this->getEnvLang();
Please login to merge, or discard this patch.
migrate-config.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
     foreach (explode(' ', GLOBAL_PLUGINS) as $pluginName) {
85 85
         $globalPluginsArray[] = "\"$pluginName\"";
86 86
     }
87
-    $globalPlugins = " " . implode(', ', $globalPluginsArray) . " ";
87
+    $globalPlugins = " ".implode(', ', $globalPluginsArray)." ";
88 88
 }
89 89
 
90 90
 # print the prefixes
Please login to merge, or discard this patch.
model/LabelSkosXL.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
     public function getPrefLabel() {
12 12
         $label = null;
13 13
         $labels = $this->resource->allResources('skosxl:prefLabel');
14
-        foreach($labels as $labres) {
14
+        foreach ($labels as $labres) {
15 15
             $label = $labres->getLiteral('skosxl:literalForm');
16 16
             if ($label->getLang() == $this->clang) {
17 17
                 return $label;
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     public function getProperties() {
24 24
         $ret = array();
25 25
         $props = $this->resource->properties();
26
-        foreach($props as $prop) {
26
+        foreach ($props as $prop) {
27 27
             if ($prop !== 'skosxl:prefLabel') {
28 28
                 $ret[$prop] = $this->resource->get($prop);
29 29
             }
Please login to merge, or discard this patch.
model/Concept.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -517,13 +517,13 @@
 block discarded – undo
517 517
                     
518 518
                     $defaultPropLabel = $this->model->getDefaultSparql()->queryLabel($longUri, '');
519 519
 
520
-					if($envLangLabels) {
521
-						$proplabel = $envLangLabels[$this->getEnvLang()];
520
+          if($envLangLabels) {
521
+            $proplabel = $envLangLabels[$this->getEnvLang()];
522 522
                     } else {
523
-						if($defaultPropLabel) {
524
-							$proplabel = $defaultPropLabel[''];
525
-						}
526
-					}
523
+            if($defaultPropLabel) {
524
+              $proplabel = $defaultPropLabel[''];
525
+            }
526
+          }
527 527
                 }
528 528
 
529 529
                 // look for superproperties in the current graph
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -312,8 +312,7 @@  discard block
 block discarded – undo
312 312
             foreach ($res->propertyUris() as $prop) {
313 313
                 $this->addPropertyValues($res, $prop, $seen);
314 314
             }
315
-        }
316
-        else {
315
+        } else {
317 316
             foreach ($props as $prop) {
318 317
                 if ($res->hasProperty($prop)) {
319 318
                     $this->addPropertyValues($res, $prop, $seen);
@@ -678,7 +677,9 @@  discard block
 block discarded – undo
678 677
         $subPrefLabelProps = $this->graph->resourcesMatching('rdfs:subPropertyOf', $prefLabelProp);
679 678
         foreach ($subPrefLabelProps as $subPrefLabelProp) {
680 679
             // return the first available translation
681
-            if ($subPrefLabelProp->label($lang)) return $subPrefLabelProp->label($lang);
680
+            if ($subPrefLabelProp->label($lang)) {
681
+              return $subPrefLabelProp->label($lang);
682
+            }
682 683
         }
683 684
         return null;
684 685
     }
@@ -909,8 +910,7 @@  discard block
 block discarded – undo
909 910
         if (!in_array($vocabUriSpace, $context, true)) {
910 911
             if (!isset($context[$vocabPrefix])) {
911 912
                 $context[$vocabPrefix] = $vocabUriSpace;
912
-            }
913
-            else if ($context[$vocabPrefix] !== $vocabUriSpace) {
913
+            } else if ($context[$vocabPrefix] !== $vocabUriSpace) {
914 914
                 $i = 2;
915 915
                 while (isset($context[$vocabPrefix . $i]) && $context[$vocabPrefix . $i] !== $vocabUriSpace) {
916 916
                     $i += 1;
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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));
Please login to merge, or discard this patch.
controller/EntityController.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@
 block discarded – undo
30 30
             $url = $baseurl . "$vocid/";
31 31
         } else {
32 32
 
33
-   	        if ($localname !== $uri && $localname === urlencode($localname)) {
34
-   	        // the URI can be shortened
33
+              if ($localname !== $uri && $localname === urlencode($localname)) {
34
+              // the URI can be shortened
35 35
             $url = $baseurl . "$vocid/page/$localname";
36 36
             } else {
37 37
                 // must use full URI
38
-   	            $query = http_build_query(array('uri'=>$uri));
38
+                  $query = http_build_query(array('uri'=>$uri));
39 39
                 $url = $baseurl . "$vocid/page/?" . $query;
40
-	        }
40
+          }
41 41
         }
42 42
         $this->redirect303($url);
43 43
     }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
         $baseurl = $this->getBaseHref();
17 17
         $vocid = $vocab->getId();
18 18
         $query = http_build_query(array('uri'=>$uri, 'format'=>$targetFormat));
19
-        $url = $baseurl . "rest/v1/$vocid/data?$query";
19
+        $url = $baseurl."rest/v1/$vocid/data?$query";
20 20
         $this->redirect303($url);
21 21
     }
22 22
 
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
         $localname = $vocab->getLocalName($uri);
28 28
 
29 29
         if (!$localname) {
30
-            $url = $baseurl . "$vocid/";
30
+            $url = $baseurl."$vocid/";
31 31
         } else {
32 32
 
33 33
    	        if ($localname !== $uri && $localname === urlencode($localname)) {
34 34
    	        // the URI can be shortened
35
-            $url = $baseurl . "$vocid/page/$localname";
35
+            $url = $baseurl."$vocid/page/$localname";
36 36
             } else {
37 37
                 // must use full URI
38 38
    	            $query = http_build_query(array('uri'=>$uri));
39
-                $url = $baseurl . "$vocid/page/?" . $query;
39
+                $url = $baseurl."$vocid/page/?".$query;
40 40
 	        }
41 41
         }
42 42
         $this->redirect303($url);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
             // guess vocabulary based on URI
58 58
             $vocab = $this->model->guessVocabularyFromURI($request->getUri());
59 59
             if ($vocab === null) {
60
-                return $this->returnError('404', 'Not Found', 'Unrecognized URI ' . $request->getUri());
60
+                return $this->returnError('404', 'Not Found', 'Unrecognized URI '.$request->getUri());
61 61
             }
62 62
             $request->setVocab($vocab->getId());
63 63
         }
Please login to merge, or discard this patch.
model/resolver/LOCResource.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
             $opts = array('http' => array('method'=>'HEAD',
14 14
                                           'user_agent' => 'Skosmos',
15 15
                                           'timeout' => $timeout));
16
-            $context  = stream_context_create($opts);
16
+            $context = stream_context_create($opts);
17 17
             $fd = fopen($this->uri, 'rb', false, $context);
18 18
             $headers = stream_get_meta_data($fd)['wrapper_data'];
19 19
             foreach ($headers as $header) {
Please login to merge, or discard this patch.
model/sparql/GenericSparql.php 3 patches
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -47,12 +47,16 @@  discard block
 block discarded – undo
47 47
         $this->client = new EasyRdf\Sparql\Client($endpoint);
48 48
 
49 49
         // set graphClause so that it can be used by all queries
50
-        if ($this->isDefaultEndpoint()) // default endpoint; query any graph (and catch it in a variable)
50
+        if ($this->isDefaultEndpoint()) {
51
+          // default endpoint; query any graph (and catch it in a variable)
51 52
         {
52 53
             $this->graphClause = "GRAPH $graph";
53
-        } elseif ($graph !== null) // query a specific graph
54
+        }
55
+        } elseif ($graph !== null) {
56
+          // query a specific graph
54 57
         {
55 58
             $this->graphClause = "GRAPH <$graph>";
59
+        }
56 60
         } else // query the default graph
57 61
         {
58 62
             $this->graphClause = "";
@@ -1274,8 +1278,7 @@  discard block
 block discarded – undo
1274 1278
             if (isset($row->qualifier)) {
1275 1279
                 if ($row->qualifier instanceof EasyRdf\Literal) {
1276 1280
                     $hit['qualifier'] = $row->qualifier->getValue();
1277
-                }
1278
-                else {
1281
+                } else {
1279 1282
                     $hit['qualifier'] = $row->qualifier->localName();
1280 1283
                 }
1281 1284
             }
@@ -1955,8 +1958,7 @@  discard block
 block discarded – undo
1955 1958
         if (sizeof($ret) > 0) {
1956 1959
             // existing concept, with children
1957 1960
             return $ret;
1958
-        }
1959
-        else {
1961
+        } else {
1960 1962
             // nonexistent concept
1961 1963
             return null;
1962 1964
         }
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      *
66 66
      * @param string $query
67 67
      * @return string
68
-    */
68
+     */
69 69
     protected function generateQueryPrefixes($query)
70 70
     {
71 71
         // Check for undefined prefixes
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
         $gcl = $this->graphClause;
234 234
         $classes = ($classes) ? $classes : array('http://www.w3.org/2004/02/skos/core#Concept');
235 235
 
236
-	$quote_string = function($val) { return "'$val'"; };
237
-	$quoted_values = array_map($quote_string, $langs);
238
-	$langFilter = "FILTER(?lang IN (" . implode(',', $quoted_values) . "))";
236
+  $quote_string = function($val) { return "'$val'"; };
237
+  $quoted_values = array_map($quote_string, $langs);
238
+  $langFilter = "FILTER(?lang IN (" . implode(',', $quoted_values) . "))";
239 239
 
240 240
         $values = $this->formatValues('?type', $classes, 'uri');
241 241
         $valuesProp = $this->formatValues('?prop', $props, null);
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
         return $query;
963 963
     }
964 964
     /**
965
-    *  This function can be overwritten in other SPARQL dialects for the possibility of handling the different language clauses
965
+     *  This function can be overwritten in other SPARQL dialects for the possibility of handling the different language clauses
966 966
      * @param string $lang
967 967
      * @return string formatted language clause
968 968
      */
@@ -1911,7 +1911,7 @@  discard block
 block discarded – undo
1911 1911
 
1912 1912
     /**
1913 1913
      * Generates a sparql query for finding the hierarchy for a concept.
1914
-	 * A concept may be a top concept in multiple schemes, returned as a single whitespace-separated literal.
1914
+     * A concept may be a top concept in multiple schemes, returned as a single whitespace-separated literal.
1915 1915
      * @param string $uri concept uri.
1916 1916
      * @param string $lang
1917 1917
      * @param string $fallback language to use if label is not available in the preferred language
@@ -1988,10 +1988,10 @@  discard block
 block discarded – undo
1988 1988
                 $ret[$uri]['exact'] = $row->exact->getUri();
1989 1989
             }
1990 1990
             if (isset($row->tops)) {
1991
-               $topConceptsList=explode(" ", $row->tops->getValue());
1992
-               // sort to guarantee an alphabetical ordering of the URI
1993
-               sort($topConceptsList);
1994
-               $ret[$uri]['tops'] = $topConceptsList;
1991
+                $topConceptsList=explode(" ", $row->tops->getValue());
1992
+                // sort to guarantee an alphabetical ordering of the URI
1993
+                sort($topConceptsList);
1994
+                $ret[$uri]['tops'] = $topConceptsList;
1995 1995
             }
1996 1996
             if (isset($row->children)) {
1997 1997
                 if (!isset($ret[$uri]['narrower'])) {
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
     protected function query($query) {
89 89
         $queryId = sprintf("%05d", rand(0, 99999));
90 90
         $logger = $this->model->getLogger();
91
-        $logger->info("[qid $queryId] SPARQL query:\n" . $this->generateQueryPrefixes($query) . "\n$query\n");
91
+        $logger->info("[qid $queryId] SPARQL query:\n".$this->generateQueryPrefixes($query)."\n$query\n");
92 92
         $starttime = microtime(true);
93 93
         $result = $this->client->query($query);
94 94
         $elapsed = intval(round((microtime(true) - $starttime) * 1000));
95
-        if(method_exists($result, 'numRows')) {
95
+        if (method_exists($result, 'numRows')) {
96 96
             $numRows = $result->numRows();
97 97
             $logger->info("[qid $queryId] result: $numRows rows returned in $elapsed ms");
98 98
         } else { // graph result
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      * @param Vocabulary[]|null $vocabs
109 109
      * @return string
110 110
      */
111
-    protected function generateFromClause($vocabs=null) {
111
+    protected function generateFromClause($vocabs = null) {
112 112
         if (!$vocabs) {
113 113
             return $this->graph !== '?graph' && $this->graph !== NULL ? "FROM <$this->graph>" : '';
114 114
         }
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 
251 251
 	$quote_string = function($val) { return "'$val'"; };
252 252
 	$quoted_values = array_map($quote_string, $langs);
253
-	$langFilter = "FILTER(?lang IN (" . implode(',', $quoted_values) . "))";
253
+	$langFilter = "FILTER(?lang IN (".implode(',', $quoted_values)."))";
254 254
 
255 255
         $values = $this->formatValues('?type', $classes, 'uri');
256 256
         $valuesProp = $this->formatValues('?prop', $props, null);
@@ -697,9 +697,9 @@  discard block
 block discarded – undo
697 697
                 $conceptscheme['title'] = $row->title->getValue();
698 698
             }
699 699
             // add dct:subject and their labels in the result
700
-            if(isset($row->domain) && isset($row->domainLabel)){
701
-                $conceptscheme['subject']['uri']=$row->domain->getURI();
702
-                $conceptscheme['subject']['prefLabel']=$row->domainLabel->getValue();
700
+            if (isset($row->domain) && isset($row->domainLabel)) {
701
+                $conceptscheme['subject']['uri'] = $row->domain->getURI();
702
+                $conceptscheme['subject']['prefLabel'] = $row->domainLabel->getValue();
703 703
             }
704 704
 
705 705
             $ret[$row->cs->getURI()] = $conceptscheme;
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
           $values[] = "<$graph>";
767 767
         }
768 768
         if (count($values)) {
769
-          return "FILTER (?graph IN (" . implode(',', $values) . "))";
769
+          return "FILTER (?graph IN (".implode(',', $values)."))";
770 770
         }
771 771
     }
772 772
 
@@ -777,16 +777,16 @@  discard block
 block discarded – undo
777 777
      * @return string sparql query clauses
778 778
      */
779 779
     protected function formatLimitAndOffset($limit, $offset) {
780
-        $limit = ($limit) ? 'LIMIT ' . $limit : '';
781
-        $offset = ($offset) ? 'OFFSET ' . $offset : '';
780
+        $limit = ($limit) ? 'LIMIT '.$limit : '';
781
+        $offset = ($offset) ? 'OFFSET '.$offset : '';
782 782
         // eliminating whitespace and line changes when the conditions aren't needed.
783 783
         $limitandoffset = '';
784 784
         if ($limit && $offset) {
785
-            $limitandoffset = "\n" . $limit . "\n" . $offset;
785
+            $limitandoffset = "\n".$limit."\n".$offset;
786 786
         } elseif ($limit) {
787
-            $limitandoffset = "\n" . $limit;
787
+            $limitandoffset = "\n".$limit;
788 788
         } elseif ($offset) {
789
-            $limitandoffset = "\n" . $offset;
789
+            $limitandoffset = "\n".$offset;
790 790
         }
791 791
 
792 792
         return $limitandoffset;
@@ -938,14 +938,14 @@  discard block
 block discarded – undo
938 938
         // if search language and UI/display language differ, must also consider case where there is no prefLabel in
939 939
         // the display language; in that case, should use the label with the same language as the matched label
940 940
         $labelcondFallback = ($searchLang != $lang) ?
941
-          "OPTIONAL { # in case previous OPTIONAL block gives no labels\n" .
941
+          "OPTIONAL { # in case previous OPTIONAL block gives no labels\n".
942 942
           "?s skos:prefLabel ?label . FILTER (LANGMATCHES(LANG(?label), LANG(?match))) }" : "";
943 943
 
944 944
         //  Including the labels if there is no query term given.
945 945
         if ($rawterm === '') {
946 946
           $labelClause = "?s skos:prefLabel ?label .";
947
-          $labelClause = ($lang) ? $labelClause . " FILTER (LANGMATCHES(LANG(?label), '$lang'))" : $labelClause . "";
948
-          return $labelClause . " BIND(?label AS ?match)";
947
+          $labelClause = ($lang) ? $labelClause." FILTER (LANGMATCHES(LANG(?label), '$lang'))" : $labelClause."";
948
+          return $labelClause." BIND(?label AS ?match)";
949 949
         }
950 950
 
951 951
         /*
@@ -1016,20 +1016,20 @@  discard block
 block discarded – undo
1016 1016
         $schemecond = '';
1017 1017
         if (!empty($schemes)) {
1018 1018
             $conditions = array();
1019
-            foreach($schemes as $scheme) {
1019
+            foreach ($schemes as $scheme) {
1020 1020
                 $conditions[] = "{?s skos:inScheme <$scheme>}";
1021 1021
             }
1022
-            $schemecond = '{'.implode(" UNION ",$conditions).'}';
1022
+            $schemecond = '{'.implode(" UNION ", $conditions).'}';
1023 1023
         }
1024
-        $filterDeprecated="";
1024
+        $filterDeprecated = "";
1025 1025
         //show or hide deprecated concepts
1026
-        if(!$showDeprecated){
1027
-            $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }";
1026
+        if (!$showDeprecated) {
1027
+            $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }";
1028 1028
         }
1029 1029
         // extra conditions for parent and group, if specified
1030
-        $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <" . $params->getParentLimit() . "> ." : "";
1031
-        $groupcond = ($params->getGroupLimit()) ? "<" . $params->getGroupLimit() . "> skos:member ?s ." : "";
1032
-        $pgcond = $parentcond . $groupcond;
1030
+        $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <".$params->getParentLimit()."> ." : "";
1031
+        $groupcond = ($params->getGroupLimit()) ? "<".$params->getGroupLimit()."> skos:member ?s ." : "";
1032
+        $pgcond = $parentcond.$groupcond;
1033 1033
 
1034 1034
         $orderextra = $this->isDefaultEndpoint() ? $this->graph : '';
1035 1035
 
@@ -1115,9 +1115,9 @@  discard block
 block discarded – undo
1115 1115
             $hit['type'][] = $this->shortenUri($typeuri);
1116 1116
         }
1117 1117
 
1118
-        if(!empty($fields)) {
1118
+        if (!empty($fields)) {
1119 1119
             foreach ($fields as $prop) {
1120
-                $propname = $prop . 's';
1120
+                $propname = $prop.'s';
1121 1121
                 if (isset($row->$propname)) {
1122 1122
                     foreach (explode("\n", $row->$propname->getValue()) as $line) {
1123 1123
                         $rdata = str_getcsv($line, ',', '"', '"');
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
                             $propvals = $rdata[2];
1133 1133
                         }
1134 1134
 
1135
-                        $hit['skos:' . $prop][] = $propvals;
1135
+                        $hit['skos:'.$prop][] = $propvals;
1136 1136
                     }
1137 1137
                 }
1138 1138
             }
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
      * @return array query result object
1209 1209
      */
1210 1210
     public function queryConcepts($vocabs, $fields, $unique, $params, $showDeprecated = false) {
1211
-        $query = $this->generateConceptSearchQuery($fields, $unique, $params,$showDeprecated);
1211
+        $query = $this->generateConceptSearchQuery($fields, $unique, $params, $showDeprecated);
1212 1212
         $results = $this->query($query);
1213 1213
         return $this->transformConceptSearchResults($results, $vocabs, $fields);
1214 1214
     }
@@ -1263,10 +1263,10 @@  discard block
 block discarded – undo
1263 1263
         $conditions = $this->formatFilterConditions($letter, $lang);
1264 1264
         $filtercondLabel = $conditions['filterpref'];
1265 1265
         $filtercondALabel = $conditions['filteralt'];
1266
-        $qualifierClause = $qualifier ? "OPTIONAL { ?s <" . $qualifier->getURI() . "> ?qualifier }" : "";
1267
-        $filterDeprecated="";
1268
-        if(!$showDeprecated){
1269
-            $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }";
1266
+        $qualifierClause = $qualifier ? "OPTIONAL { ?s <".$qualifier->getURI()."> ?qualifier }" : "";
1267
+        $filterDeprecated = "";
1268
+        if (!$showDeprecated) {
1269
+            $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }";
1270 1270
         }
1271 1271
         $query = <<<EOQ
1272 1272
 SELECT DISTINCT ?s ?label ?alabel ?qualifier
@@ -1743,7 +1743,7 @@  discard block
 block discarded – undo
1743 1743
                 if (!isset($row->label) || $row->label->getLang() === $lang) {
1744 1744
                     $ret[$row->object->getUri()] = $val;
1745 1745
                 } elseif ($row->label->getLang() === $fallbacklang) {
1746
-                    $val['label'] .= ' (' . $row->label->getLang() . ')';
1746
+                    $val['label'] .= ' ('.$row->label->getLang().')';
1747 1747
                     $ret[$row->object->getUri()] = $val;
1748 1748
                 }
1749 1749
             }
@@ -1839,10 +1839,10 @@  discard block
 block discarded – undo
1839 1839
 
1840 1840
             $label = null;
1841 1841
             if (isset($row->label)) {
1842
-                if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang . "-") == 0) {
1842
+                if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang."-") == 0) {
1843 1843
                     $label = $row->label->getValue();
1844 1844
                 } else {
1845
-                    $label = $row->label->getValue() . " (" . $row->label->getLang() . ")";
1845
+                    $label = $row->label->getValue()." (".$row->label->getLang().")";
1846 1846
                 }
1847 1847
 
1848 1848
             }
@@ -1918,8 +1918,8 @@  discard block
 block discarded – undo
1918 1918
         foreach ($result as $row) {
1919 1919
             if (isset($row->top) && isset($row->label)) {
1920 1920
                 $label = $row->label->getValue();
1921
-                if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang . "-") !== 0) {
1922
-                    $label .= ' (' . $row->label->getLang() . ')';
1921
+                if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang."-") !== 0) {
1922
+                    $label .= ' ('.$row->label->getLang().')';
1923 1923
                 }
1924 1924
                 $top = array('uri' => $row->top->getUri(), 'topConceptOf' => $row->topuri->getUri(), 'label' => $label, 'hasChildren' => filter_var($row->children->getValue(), FILTER_VALIDATE_BOOLEAN));
1925 1925
                 if (isset($row->notation)) {
@@ -2012,7 +2012,7 @@  discard block
 block discarded – undo
2012 2012
                 $ret[$uri]['exact'] = $row->exact->getUri();
2013 2013
             }
2014 2014
             if (isset($row->tops)) {
2015
-               $topConceptsList=explode(" ", $row->tops->getValue());
2015
+               $topConceptsList = explode(" ", $row->tops->getValue());
2016 2016
                // sort to guarantee an alphabetical ordering of the URI
2017 2017
                sort($topConceptsList);
2018 2018
                $ret[$uri]['tops'] = $topConceptsList;
@@ -2025,8 +2025,8 @@  discard block
 block discarded – undo
2025 2025
                 $label = null;
2026 2026
                 if (isset($row->childlabel)) {
2027 2027
                     $label = $row->childlabel->getValue();
2028
-                    if ($row->childlabel->getLang() !== $lang && strpos($row->childlabel->getLang(), $lang . "-") !== 0) {
2029
-                        $label .= " (" . $row->childlabel->getLang() . ")";
2028
+                    if ($row->childlabel->getLang() !== $lang && strpos($row->childlabel->getLang(), $lang."-") !== 0) {
2029
+                        $label .= " (".$row->childlabel->getLang().")";
2030 2030
                     }
2031 2031
 
2032 2032
                 }
@@ -2047,8 +2047,8 @@  discard block
 block discarded – undo
2047 2047
             }
2048 2048
             if (isset($row->label)) {
2049 2049
                 $preflabel = $row->label->getValue();
2050
-                if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang . "-") !== 0) {
2051
-                    $preflabel .= ' (' . $row->label->getLang() . ')';
2050
+                if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang."-") !== 0) {
2051
+                    $preflabel .= ' ('.$row->label->getLang().')';
2052 2052
                 }
2053 2053
 
2054 2054
                 $ret[$uri]['prefLabel'] = $preflabel;
@@ -2169,9 +2169,9 @@  discard block
 block discarded – undo
2169 2169
      */
2170 2170
     private function generateConceptGroupContentsQuery($groupClass, $group, $lang, $showDeprecated = false) {
2171 2171
         $fcl = $this->generateFromClause();
2172
-        $filterDeprecated="";
2173
-        if(!$showDeprecated){
2174
-            $filterDeprecated="  FILTER NOT EXISTS { ?conc owl:deprecated true }";
2172
+        $filterDeprecated = "";
2173
+        if (!$showDeprecated) {
2174
+            $filterDeprecated = "  FILTER NOT EXISTS { ?conc owl:deprecated true }";
2175 2175
         }
2176 2176
         $query = <<<EOQ
2177 2177
 SELECT ?conc ?super ?label ?members ?type ?notation $fcl
@@ -2210,10 +2210,10 @@  discard block
 block discarded – undo
2210 2210
                     'type' => array($row->type->shorten()),
2211 2211
                 );
2212 2212
                 if (isset($row->label)) {
2213
-                    if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang . "-") == 0) {
2213
+                    if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang."-") == 0) {
2214 2214
                         $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue();
2215 2215
                     } else {
2216
-                        $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue() . " (" . $row->label->getLang() . ")";
2216
+                        $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue()." (".$row->label->getLang().")";
2217 2217
                     }
2218 2218
 
2219 2219
                 }
@@ -2241,8 +2241,8 @@  discard block
 block discarded – undo
2241 2241
      * @param boolean $showDeprecated whether to include deprecated concepts in search results
2242 2242
      * @return array Result array with concept URI as key and concept label as value
2243 2243
      */
2244
-    public function listConceptGroupContents($groupClass, $group, $lang,$showDeprecated = false) {
2245
-        $query = $this->generateConceptGroupContentsQuery($groupClass, $group, $lang,$showDeprecated);
2244
+    public function listConceptGroupContents($groupClass, $group, $lang, $showDeprecated = false) {
2245
+        $query = $this->generateConceptGroupContentsQuery($groupClass, $group, $lang, $showDeprecated);
2246 2246
         $result = $this->query($query);
2247 2247
         return $this->transformConceptGroupContentsResults($result, $lang);
2248 2248
     }
@@ -2256,9 +2256,9 @@  discard block
 block discarded – undo
2256 2256
      * @param boolean $showDeprecated whether to include deprecated concepts in the change list
2257 2257
      * @return string sparql query
2258 2258
      */
2259
-    private function generateChangeListQuery($prop, $lang, $offset, $limit=200, $showDeprecated=false) {
2259
+    private function generateChangeListQuery($prop, $lang, $offset, $limit = 200, $showDeprecated = false) {
2260 2260
         $fcl = $this->generateFromClause();
2261
-        $offset = ($offset) ? 'OFFSET ' . $offset : '';
2261
+        $offset = ($offset) ? 'OFFSET '.$offset : '';
2262 2262
 
2263 2263
         //Additional clauses when deprecated concepts need to be included in the results
2264 2264
         $deprecatedOptions = '';
@@ -2336,7 +2336,7 @@  discard block
 block discarded – undo
2336 2336
      * @param boolean $showDeprecated whether to include deprecated concepts in the change list
2337 2337
      * @return array Result array
2338 2338
      */
2339
-    public function queryChangeList($prop, $lang, $offset, $limit, $showDeprecated=false) {
2339
+    public function queryChangeList($prop, $lang, $offset, $limit, $showDeprecated = false) {
2340 2340
         $query = $this->generateChangeListQuery($prop, $lang, $offset, $limit, $showDeprecated);
2341 2341
 
2342 2342
         $result = $this->query($query);
Please login to merge, or discard this patch.
model/sparql/JenaTextSparql.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         // 1. Ensure characters with special meaning in Lucene are escaped
42 42
         $lucenemap = array();
43 43
         foreach (str_split(self::LUCENE_ESCAPE_CHARS) as $char) {
44
-            $lucenemap[$char] = '\\' . $char; // escape with a backslash
44
+            $lucenemap[$char] = '\\'.$char; // escape with a backslash
45 45
         }
46 46
         $term = strtr($term, $lucenemap);
47 47
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      * @return string sparql order by clause
93 93
      */
94 94
     private function formatOrderBy($expression, $lang) {
95
-        if(!$this->model->getConfig()->getCollationEnabled()) {
95
+        if (!$this->model->getConfig()->getCollationEnabled()) {
96 96
             return $expression;
97 97
         }
98 98
         $orderby = sprintf('arq:collation(\'%2$s\', %1$s)', $expression, $lang);
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
         # make text query clause
127 127
         $lcletter = mb_strtolower($letter, 'UTF-8'); // convert to lower case, UTF-8 safe
128 128
         $langClause = $this->generateLangClause($lang);
129
-        $textcondPref = $this->createTextQueryCondition($letter . '*', 'skos:prefLabel', $langClause);
130
-        $textcondAlt = $this->createTextQueryCondition($letter . '*', 'skos:altLabel', $langClause);
131
-        $orderbyclause = $this->formatOrderBy("LCASE(?match)", $lang) . " STR(?s) LCASE(STR(?qualifier))";
129
+        $textcondPref = $this->createTextQueryCondition($letter.'*', 'skos:prefLabel', $langClause);
130
+        $textcondAlt = $this->createTextQueryCondition($letter.'*', 'skos:altLabel', $langClause);
131
+        $orderbyclause = $this->formatOrderBy("LCASE(?match)", $lang)." STR(?s) LCASE(STR(?qualifier))";
132 132
 
133
-        $qualifierClause = $qualifier ? "OPTIONAL { ?s <" . $qualifier->getURI() . "> ?qualifier }" : "";
133
+        $qualifierClause = $qualifier ? "OPTIONAL { ?s <".$qualifier->getURI()."> ?qualifier }" : "";
134 134
 
135
-        $filterDeprecated="";
136
-        if(!$showDeprecated){
137
-            $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }";
135
+        $filterDeprecated = "";
136
+        if (!$showDeprecated) {
137
+            $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }";
138 138
         }
139 139
 
140 140
         $query = <<<EOQ
Please login to merge, or discard this patch.
controller/Controller.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -156,18 +156,18 @@  discard block
 block discarded – undo
156 156
         $localname = $vocab->getLocalName($uri);
157 157
         if ($localname !== $uri && $localname === urlencode($localname)) {
158 158
             // check that the prefix stripping worked, and there are no problematic chars in localname
159
-            $paramstr = count($params) > 0 ? '?' . http_build_query($params) : '';
159
+            $paramstr = count($params) > 0 ? '?'.http_build_query($params) : '';
160 160
             if ($type && $type !== '' && $type !== 'vocab' && !($localname === '' && $type === 'page')) {
161
-                return "$vocid/$lang/$type/$localname" . $paramstr;
161
+                return "$vocid/$lang/$type/$localname".$paramstr;
162 162
             }
163 163
 
164
-            return "$vocid/$lang/$localname" . $paramstr;
164
+            return "$vocid/$lang/$localname".$paramstr;
165 165
         }
166 166
 
167 167
         // case 2: URI outside vocabulary namespace, or has problematic chars
168 168
         // pass the full URI as parameter instead
169 169
         $params['uri'] = $uri;
170
-        return "$vocid/$lang/$type/?" . http_build_query($params);
170
+        return "$vocid/$lang/$type/?".http_build_query($params);
171 171
     }
172 172
 
173 173
     /**
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
     {
294 294
         if ($modifiedDate) {
295 295
             $ifModifiedSince = $this->getIfModifiedSince();
296
-            $this->sendHeader("Last-Modified: " . $modifiedDate->format('D, d M Y H:i:s \G\M\T'));
296
+            $this->sendHeader("Last-Modified: ".$modifiedDate->format('D, d M Y H:i:s \G\M\T'));
297 297
             if ($ifModifiedSince !== null && $ifModifiedSince >= $modifiedDate) {
298 298
                 $this->sendHeader("HTTP/1.0 304 Not Modified");
299 299
                 return true;
Please login to merge, or discard this patch.