Completed
Push — master ( 47c93b...5fe423 )
by Osma
18s queued 12s
created
controller/RestController.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         // wrap with JSONP callback if requested
26 26
         if (filter_input(INPUT_GET, 'callback', FILTER_SANITIZE_STRING)) {
27 27
             header("Content-type: application/javascript; charset=utf-8");
28
-            echo filter_input(INPUT_GET, 'callback', FILTER_UNSAFE_RAW) . "(" . json_encode($data) . ");";
28
+            echo filter_input(INPUT_GET, 'callback', FILTER_UNSAFE_RAW)."(".json_encode($data).");";
29 29
             return;
30 30
         }
31 31
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
                 'vocabularies' => 'onki:hasVocabulary',
89 89
                 'id' => 'onki:vocabularyIdentifier',
90 90
                 'uri' => '@id',
91
-                '@base' => $this->getBaseHref() . "rest/v1/vocabularies",
91
+                '@base' => $this->getBaseHref()."rest/v1/vocabularies",
92 92
             ),
93 93
             'uri' => '',
94 94
             'vocabularies' => $results,
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
         // convert to vocids array to support multi-vocabulary search
106 106
         $vocids = ($vocabs !== null && $vocabs !== '') ? explode(' ', $vocabs) : array();
107 107
         $vocabObjects = array();
108
-        foreach($vocids as $vocid) {
108
+        foreach ($vocids as $vocid) {
109 109
             $vocabObjects[] = $this->model->getVocabulary($vocid);
110 110
         }
111 111
         $parameters->setVocabularies($vocabObjects);
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
         foreach ($parameters->getAdditionalFields() as $field) {
137 137
 
138 138
             // Quick-and-dirty compactification
139
-            $context[$field] = 'skos:' . $field;
139
+            $context[$field] = 'skos:'.$field;
140 140
             foreach ($results as &$result) {
141 141
                 foreach ($result as $k => $v) {
142
-                    if ($k == 'skos:' . $field) {
142
+                    if ($k == 'skos:'.$field) {
143 143
                         $result[$field] = $v;
144
-                        unset($result['skos:' . $field]);
144
+                        unset($result['skos:'.$field]);
145 145
                     }
146 146
                 }
147 147
             }
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
                 'prefLabel' => 'skos:prefLabel',
230 230
                 'title' => 'dct:title',
231 231
                 '@language' => $request->getLang(),
232
-                '@base' => $this->getBaseHref() . "rest/v1/" . $vocab->getId() . "/",
232
+                '@base' => $this->getBaseHref()."rest/v1/".$vocab->getId()."/",
233 233
             ),
234 234
             'uri' => '',
235 235
             'id' => $vocab->getId(),
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
                 'subTypes' => array('@id' => 'void:class', '@type' => '@id'),
284 284
                 'count' => 'void:entities',
285 285
                 '@language' => $request->getLang(),
286
-                '@base' => $this->getBaseHref() . "rest/v1/" . $request->getVocab()->getId() . "/",
286
+                '@base' => $this->getBaseHref()."rest/v1/".$request->getVocab()->getId()."/",
287 287
             ),
288 288
             'uri' => '',
289 289
             'id' => $request->getVocab()->getId(),
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
                 'language' => 'void-ext:language',
361 361
                 'properties' => 'void:propertyPartition',
362 362
                 'labels' => 'void:triples',
363
-                '@base' => $this->getBaseHref() . "rest/v1/" . $request->getVocab()->getId() . "/",
363
+                '@base' => $this->getBaseHref()."rest/v1/".$request->getVocab()->getId()."/",
364 364
             ),
365 365
             'uri' => '',
366 366
             'id' => $request->getVocab()->getId(),
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
             $types[] = $type;
402 402
         }
403 403
 
404
-        $base = $request->getVocab() ? $this->getBaseHref() . "rest/v1/" . $request->getVocab()->getId() . "/" : $this->getBaseHref() . "rest/v1/";
404
+        $base = $request->getVocab() ? $this->getBaseHref()."rest/v1/".$request->getVocab()->getId()."/" : $this->getBaseHref()."rest/v1/";
405 405
 
406 406
         $ret = array_merge_recursive($this->context, array(
407 407
             '@context' => array(
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
         if ($lang === null) {
443 443
             // case 1A: exact match on preferred label in any language
444 444
             foreach ($results as $res) {
445
-                if (isset($res['matchedPrefLabel']) && $res['matchedPrefLabel']  == $label) {
445
+                if (isset($res['matchedPrefLabel']) && $res['matchedPrefLabel'] == $label) {
446 446
                     $res['prefLabel'] = $res['matchedPrefLabel'];
447 447
                     unset($res['matchedPrefLabel']);
448 448
                     $hits[] = $res;
@@ -564,19 +564,19 @@  discard block
 block discarded – undo
564 564
 
565 565
         $format = $this->negotiateFormat(array_keys($urls), $request->getServerConstant('HTTP_ACCEPT'), $request->getQueryParam('format'));
566 566
         if (!$format) {
567
-            return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: " . implode(' ', array_keys($urls)));
567
+            return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: ".implode(' ', array_keys($urls)));
568 568
         }
569 569
         if (is_array($urls[$format])) {
570 570
             $arr = $urls[$format];
571 571
             $dataLang = $request->getLang();
572 572
             if (isset($arr[$dataLang])) {
573
-                header("Location: " . $arr[$dataLang]);
573
+                header("Location: ".$arr[$dataLang]);
574 574
             } else {
575 575
                 $vocid = $request->getVocab()->getId();
576 576
                 return $this->returnError('404', 'Not Found', "No download source URL known for vocabulary $vocid in language $dataLang");
577 577
             }
578 578
 		} else {
579
-            header("Location: " . $urls[$format]);
579
+            header("Location: ".$urls[$format]);
580 580
 		}
581 581
     }
582 582
 
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 
640 640
         $format = $this->negotiateFormat(explode(' ', self::SUPPORTED_FORMATS), $request->getServerConstant('HTTP_ACCEPT'), $request->getQueryParam('format'));
641 641
         if (!$format) {
642
-            return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: " . self::SUPPORTED_FORMATS);
642
+            return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: ".self::SUPPORTED_FORMATS);
643 643
         }
644 644
 
645 645
         $vocid = $vocab ? $vocab->getId() : null;
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
                         }
925 925
                     }
926 926
                     // if the main concept scheme was not found, set 'top' to the first 'tops' (sorted alphabetically on the URIs)
927
-                    if (! isset($results[$uri]['top'])) {
927
+                    if (!isset($results[$uri]['top'])) {
928 928
                         $results[$uri]['top'] = $results[$uri]['tops'][0];
929 929
                     }
930 930
                 } else {
@@ -1102,18 +1102,18 @@  discard block
 block discarded – undo
1102 1102
         $changeList = $request->getVocab()->getChangeList($prop, $request->getLang(), $offset, $limit);
1103 1103
 
1104 1104
         $simpleChangeList = array();
1105
-        foreach($changeList as $conceptInfo) {
1105
+        foreach ($changeList as $conceptInfo) {
1106 1106
             if (array_key_exists('date', $conceptInfo)) {
1107
-                $simpleChangeList[] =  array( 'uri' => $conceptInfo['uri'],
1107
+                $simpleChangeList[] = array('uri' => $conceptInfo['uri'],
1108 1108
                                                'prefLabel' => $conceptInfo['prefLabel'],
1109
-                                               'date' => $conceptInfo['date']->format("Y-m-d\TH:i:sO") );
1109
+                                               'date' => $conceptInfo['date']->format("Y-m-d\TH:i:sO"));
1110 1110
             }
1111 1111
         }
1112 1112
         return $this->returnJson(array_merge_recursive($this->context,
1113
-                                                        array('@context' => array( '@language' => $request->getLang(),
1113
+                                                        array('@context' => array('@language' => $request->getLang(),
1114 1114
                                                                                      'prefLabel' => 'skos:prefLabel',
1115 1115
                                                                                      'xsd' => 'http://www.w3.org/2001/XMLSchema#',
1116
-                                                                                     'date' => array( '@id' => 'http://purl.org/dc/terms/date', '@type' => 'http://www.w3.org/2001/XMLSchema#dateTime') )
1116
+                                                                                     'date' => array('@id' => 'http://purl.org/dc/terms/date', '@type' => 'http://www.w3.org/2001/XMLSchema#dateTime'))
1117 1117
                                                         ),
1118 1118
                                                         array('changeList' => $simpleChangeList)));
1119 1119
 
Please login to merge, or discard this patch.
model/sparql/GenericSparql.php 1 patch
Spacing   +51 added lines, -51 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
         $clause = '';
113 113
         if (!$vocabs) {
114 114
             return $this->graph !== '?graph' && $this->graph !== NULL ? "FROM <$this->graph>" : '';
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 
236 236
 	$quote_string = function($val) { return "'$val'"; };
237 237
 	$quoted_values = array_map($quote_string, $langs);
238
-	$langFilter = "FILTER(?lang IN (" . implode(',', $quoted_values) . "))";
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);
@@ -672,9 +672,9 @@  discard block
 block discarded – undo
672 672
                 $conceptscheme['title'] = $row->title->getValue();
673 673
             }
674 674
             // add dct:subject and their labels in the result
675
-            if(isset($row->domain) && isset($row->domainLabel)){
676
-                $conceptscheme['subject']['uri']=$row->domain->getURI();
677
-                $conceptscheme['subject']['prefLabel']=$row->domainLabel->getValue();
675
+            if (isset($row->domain) && isset($row->domainLabel)) {
676
+                $conceptscheme['subject']['uri'] = $row->domain->getURI();
677
+                $conceptscheme['subject']['prefLabel'] = $row->domainLabel->getValue();
678 678
             }
679 679
 
680 680
             $ret[$row->cs->getURI()] = $conceptscheme;
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
           $values[] = "<$graph>";
742 742
         }
743 743
         if (count($values)) {
744
-          return "FILTER (?graph IN (" . implode(',', $values) . "))";
744
+          return "FILTER (?graph IN (".implode(',', $values)."))";
745 745
         }
746 746
     }
747 747
 
@@ -752,16 +752,16 @@  discard block
 block discarded – undo
752 752
      * @return string sparql query clauses
753 753
      */
754 754
     protected function formatLimitAndOffset($limit, $offset) {
755
-        $limit = ($limit) ? 'LIMIT ' . $limit : '';
756
-        $offset = ($offset) ? 'OFFSET ' . $offset : '';
755
+        $limit = ($limit) ? 'LIMIT '.$limit : '';
756
+        $offset = ($offset) ? 'OFFSET '.$offset : '';
757 757
         // eliminating whitespace and line changes when the conditions aren't needed.
758 758
         $limitandoffset = '';
759 759
         if ($limit && $offset) {
760
-            $limitandoffset = "\n" . $limit . "\n" . $offset;
760
+            $limitandoffset = "\n".$limit."\n".$offset;
761 761
         } elseif ($limit) {
762
-            $limitandoffset = "\n" . $limit;
762
+            $limitandoffset = "\n".$limit;
763 763
         } elseif ($offset) {
764
-            $limitandoffset = "\n" . $offset;
764
+            $limitandoffset = "\n".$offset;
765 765
         }
766 766
 
767 767
         return $limitandoffset;
@@ -913,14 +913,14 @@  discard block
 block discarded – undo
913 913
         // if search language and UI/display language differ, must also consider case where there is no prefLabel in
914 914
         // the display language; in that case, should use the label with the same language as the matched label
915 915
         $labelcondFallback = ($searchLang != $lang) ?
916
-          "OPTIONAL { # in case previous OPTIONAL block gives no labels\n" .
916
+          "OPTIONAL { # in case previous OPTIONAL block gives no labels\n".
917 917
           "?s skos:prefLabel ?label . FILTER (LANGMATCHES(LANG(?label), LANG(?match))) }" : "";
918 918
 
919 919
         //  Including the labels if there is no query term given.
920 920
         if ($rawterm === '') {
921 921
           $labelClause = "?s skos:prefLabel ?label .";
922
-          $labelClause = ($lang) ? $labelClause . " FILTER (LANGMATCHES(LANG(?label), '$lang'))" : $labelClause . "";
923
-          return $labelClause . " BIND(?label AS ?match)";
922
+          $labelClause = ($lang) ? $labelClause." FILTER (LANGMATCHES(LANG(?label), '$lang'))" : $labelClause."";
923
+          return $labelClause." BIND(?label AS ?match)";
924 924
         }
925 925
 
926 926
         /*
@@ -992,20 +992,20 @@  discard block
 block discarded – undo
992 992
         $schemecond = '';
993 993
         if (!empty($schemes)) {
994 994
             $conditions = array();
995
-            foreach($schemes as $scheme) {
995
+            foreach ($schemes as $scheme) {
996 996
                 $conditions[] = "{?s skos:inScheme <$scheme>}";
997 997
             }
998
-            $schemecond = '{'.implode(" UNION ",$conditions).'}';
998
+            $schemecond = '{'.implode(" UNION ", $conditions).'}';
999 999
         }
1000
-        $filterDeprecated="";
1000
+        $filterDeprecated = "";
1001 1001
         //show or hide deprecated concepts
1002
-        if(!$showDeprecated){
1003
-            $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }";
1002
+        if (!$showDeprecated) {
1003
+            $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }";
1004 1004
         }
1005 1005
         // extra conditions for parent and group, if specified
1006
-        $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <" . $params->getParentLimit() . "> ." : "";
1007
-        $groupcond = ($params->getGroupLimit()) ? "<" . $params->getGroupLimit() . "> skos:member ?s ." : "";
1008
-        $pgcond = $parentcond . $groupcond;
1006
+        $parentcond = ($params->getParentLimit()) ? "?s skos:broader+ <".$params->getParentLimit()."> ." : "";
1007
+        $groupcond = ($params->getGroupLimit()) ? "<".$params->getGroupLimit()."> skos:member ?s ." : "";
1008
+        $pgcond = $parentcond.$groupcond;
1009 1009
 
1010 1010
         $orderextra = $this->isDefaultEndpoint() ? $this->graph : '';
1011 1011
 
@@ -1091,9 +1091,9 @@  discard block
 block discarded – undo
1091 1091
             $hit['type'][] = $this->shortenUri($typeuri);
1092 1092
         }
1093 1093
 
1094
-        if(!empty($fields)) {
1094
+        if (!empty($fields)) {
1095 1095
             foreach ($fields as $prop) {
1096
-                $propname = $prop . 's';
1096
+                $propname = $prop.'s';
1097 1097
                 if (isset($row->$propname)) {
1098 1098
                     foreach (explode("\n", $row->$propname->getValue()) as $line) {
1099 1099
                         $rdata = str_getcsv($line, ',', '"', '"');
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
                             $propvals = $rdata[2];
1109 1109
                         }
1110 1110
 
1111
-                        $hit['skos:' . $prop][] = $propvals;
1111
+                        $hit['skos:'.$prop][] = $propvals;
1112 1112
                     }
1113 1113
                 }
1114 1114
             }
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
      * @return array query result object
1185 1185
      */
1186 1186
     public function queryConcepts($vocabs, $fields = null, $unique = false, $params, $showDeprecated = false) {
1187
-        $query = $this->generateConceptSearchQuery($fields, $unique, $params,$showDeprecated);
1187
+        $query = $this->generateConceptSearchQuery($fields, $unique, $params, $showDeprecated);
1188 1188
         $results = $this->query($query);
1189 1189
         return $this->transformConceptSearchResults($results, $vocabs, $fields);
1190 1190
     }
@@ -1239,10 +1239,10 @@  discard block
 block discarded – undo
1239 1239
         $conditions = $this->formatFilterConditions($letter, $lang);
1240 1240
         $filtercondLabel = $conditions['filterpref'];
1241 1241
         $filtercondALabel = $conditions['filteralt'];
1242
-        $qualifierClause = $qualifier ? "OPTIONAL { ?s <" . $qualifier->getURI() . "> ?qualifier }" : "";
1243
-        $filterDeprecated="";
1244
-        if(!$showDeprecated){
1245
-            $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }";
1242
+        $qualifierClause = $qualifier ? "OPTIONAL { ?s <".$qualifier->getURI()."> ?qualifier }" : "";
1243
+        $filterDeprecated = "";
1244
+        if (!$showDeprecated) {
1245
+            $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }";
1246 1246
         }
1247 1247
         $query = <<<EOQ
1248 1248
 SELECT DISTINCT ?s ?label ?alabel ?qualifier
@@ -1719,7 +1719,7 @@  discard block
 block discarded – undo
1719 1719
                 if (!isset($row->label) || $row->label->getLang() === $lang) {
1720 1720
                     $ret[$row->object->getUri()] = $val;
1721 1721
                 } elseif ($row->label->getLang() === $fallbacklang) {
1722
-                    $val['label'] .= ' (' . $row->label->getLang() . ')';
1722
+                    $val['label'] .= ' ('.$row->label->getLang().')';
1723 1723
                     $ret[$row->object->getUri()] = $val;
1724 1724
                 }
1725 1725
             }
@@ -1815,10 +1815,10 @@  discard block
 block discarded – undo
1815 1815
 
1816 1816
             $label = null;
1817 1817
             if (isset($row->label)) {
1818
-                if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang . "-") == 0) {
1818
+                if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang."-") == 0) {
1819 1819
                     $label = $row->label->getValue();
1820 1820
                 } else {
1821
-                    $label = $row->label->getValue() . " (" . $row->label->getLang() . ")";
1821
+                    $label = $row->label->getValue()." (".$row->label->getLang().")";
1822 1822
                 }
1823 1823
 
1824 1824
             }
@@ -1894,8 +1894,8 @@  discard block
 block discarded – undo
1894 1894
         foreach ($result as $row) {
1895 1895
             if (isset($row->top) && isset($row->label)) {
1896 1896
                 $label = $row->label->getValue();
1897
-                if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang . "-") !== 0) {
1898
-                    $label .= ' (' . $row->label->getLang() . ')';
1897
+                if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang."-") !== 0) {
1898
+                    $label .= ' ('.$row->label->getLang().')';
1899 1899
                 }
1900 1900
                 $top = array('uri' => $row->top->getUri(), 'topConceptOf' => $row->topuri->getUri(), 'label' => $label, 'hasChildren' => filter_var($row->children->getValue(), FILTER_VALIDATE_BOOLEAN));
1901 1901
                 if (isset($row->notation)) {
@@ -1988,7 +1988,7 @@  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());
1991
+               $topConceptsList = explode(" ", $row->tops->getValue());
1992 1992
                // sort to guarantee an alphabetical ordering of the URI
1993 1993
                sort($topConceptsList);
1994 1994
                $ret[$uri]['tops'] = $topConceptsList;
@@ -2001,8 +2001,8 @@  discard block
 block discarded – undo
2001 2001
                 $label = null;
2002 2002
                 if (isset($row->childlabel)) {
2003 2003
                     $label = $row->childlabel->getValue();
2004
-                    if ($row->childlabel->getLang() !== $lang && strpos($row->childlabel->getLang(), $lang . "-") !== 0) {
2005
-                        $label .= " (" . $row->childlabel->getLang() . ")";
2004
+                    if ($row->childlabel->getLang() !== $lang && strpos($row->childlabel->getLang(), $lang."-") !== 0) {
2005
+                        $label .= " (".$row->childlabel->getLang().")";
2006 2006
                     }
2007 2007
 
2008 2008
                 }
@@ -2023,8 +2023,8 @@  discard block
 block discarded – undo
2023 2023
             }
2024 2024
             if (isset($row->label)) {
2025 2025
                 $preflabel = $row->label->getValue();
2026
-                if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang . "-") !== 0) {
2027
-                    $preflabel .= ' (' . $row->label->getLang() . ')';
2026
+                if ($row->label->getLang() && $row->label->getLang() !== $lang && strpos($row->label->getLang(), $lang."-") !== 0) {
2027
+                    $preflabel .= ' ('.$row->label->getLang().')';
2028 2028
                 }
2029 2029
 
2030 2030
                 $ret[$uri]['prefLabel'] = $preflabel;
@@ -2145,9 +2145,9 @@  discard block
 block discarded – undo
2145 2145
      */
2146 2146
     private function generateConceptGroupContentsQuery($groupClass, $group, $lang, $showDeprecated = false) {
2147 2147
         $fcl = $this->generateFromClause();
2148
-        $filterDeprecated="";
2149
-        if(!$showDeprecated){
2150
-            $filterDeprecated="  FILTER NOT EXISTS { ?conc owl:deprecated true }";
2148
+        $filterDeprecated = "";
2149
+        if (!$showDeprecated) {
2150
+            $filterDeprecated = "  FILTER NOT EXISTS { ?conc owl:deprecated true }";
2151 2151
         }
2152 2152
         $query = <<<EOQ
2153 2153
 SELECT ?conc ?super ?label ?members ?type ?notation $fcl
@@ -2186,10 +2186,10 @@  discard block
 block discarded – undo
2186 2186
                     'type' => array($row->type->shorten()),
2187 2187
                 );
2188 2188
                 if (isset($row->label)) {
2189
-                    if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang . "-") == 0) {
2189
+                    if ($row->label->getLang() == $lang || strpos($row->label->getLang(), $lang."-") == 0) {
2190 2190
                         $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue();
2191 2191
                     } else {
2192
-                        $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue() . " (" . $row->label->getLang() . ")";
2192
+                        $values[$row->conc->getURI()]['prefLabel'] = $row->label->getValue()." (".$row->label->getLang().")";
2193 2193
                     }
2194 2194
 
2195 2195
                 }
@@ -2217,8 +2217,8 @@  discard block
 block discarded – undo
2217 2217
      * @param boolean $showDeprecated whether to include deprecated concepts in search results
2218 2218
      * @return array Result array with concept URI as key and concept label as value
2219 2219
      */
2220
-    public function listConceptGroupContents($groupClass, $group, $lang,$showDeprecated = false) {
2221
-        $query = $this->generateConceptGroupContentsQuery($groupClass, $group, $lang,$showDeprecated);
2220
+    public function listConceptGroupContents($groupClass, $group, $lang, $showDeprecated = false) {
2221
+        $query = $this->generateConceptGroupContentsQuery($groupClass, $group, $lang, $showDeprecated);
2222 2222
         $result = $this->query($query);
2223 2223
         return $this->transformConceptGroupContentsResults($result, $lang);
2224 2224
     }
@@ -2231,9 +2231,9 @@  discard block
 block discarded – undo
2231 2231
      * @param int $limit maximum number of results to return
2232 2232
      * @return string sparql query
2233 2233
      */
2234
-    private function generateChangeListQuery($prop, $lang, $offset, $limit=200) {
2234
+    private function generateChangeListQuery($prop, $lang, $offset, $limit = 200) {
2235 2235
         $fcl = $this->generateFromClause();
2236
-        $offset = ($offset) ? 'OFFSET ' . $offset : '';
2236
+        $offset = ($offset) ? 'OFFSET '.$offset : '';
2237 2237
 
2238 2238
         $query = <<<EOQ
2239 2239
 SELECT DISTINCT ?concept ?date ?label $fcl
Please login to merge, or discard this patch.
model/BaseConfig.php 1 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.
controller/WebController.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         // specify where to look for templates and cache
38 38
         $loader = new Twig_Loader_Filesystem('view');
39 39
         // initialize Twig environment
40
-        $this->twig = new Twig_Environment($loader, array('cache' => $tmpDir,'auto_reload' => true));
40
+        $this->twig = new Twig_Environment($loader, array('cache' => $tmpDir, 'auto_reload' => true));
41 41
         $this->twig->addExtension(new Twig_Extensions_Extension_I18n());
42 42
         // used for setting the base href for the relative urls
43 43
         $this->twig->addGlobal("BaseHref", $this->getBaseHref());
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         $this->twig->addFilter(new Twig_SimpleFilter('link_url', array($this, 'linkUrlFilter')));
61 61
 
62 62
         // register a Twig filter for generating strings from language codes with CLDR
63
-        $langFilter = new Twig_SimpleFilter('lang_name', function ($langcode, $lang) {
63
+        $langFilter = new Twig_SimpleFilter('lang_name', function($langcode, $lang) {
64 64
             return Language::getName($langcode, $lang);
65 65
         });
66 66
         $this->twig->addFilter($langFilter);
@@ -234,16 +234,16 @@  discard block
 block discarded – undo
234 234
 
235 235
     private function createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender)
236 236
     {
237
-        $headers = "MIME-Version: 1.0" . "\r\n";
238
-        $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";
237
+        $headers = "MIME-Version: 1.0"."\r\n";
238
+        $headers .= "Content-type: text/html; charset=UTF-8"."\r\n";
239 239
         if (!empty($toMail)) {
240
-            $headers .= "Cc: " . $this->model->getConfig()->getFeedbackAddress() . "\r\n";
240
+            $headers .= "Cc: ".$this->model->getConfig()->getFeedbackAddress()."\r\n";
241 241
         }
242 242
         if (!empty($fromEmail)) {
243 243
             $headers .= "Reply-To: $fromName <$fromEmail>\r\n";
244 244
         }
245 245
         $service = $this->model->getConfig()->getServiceName();
246
-        return $headers . "From: $fromName via $service <$sender>";
246
+        return $headers."From: $fromName via $service <$sender>";
247 247
     }
248 248
 
249 249
     /**
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
     public function sendFeedback($request, $message, $messageSubject, $fromName = null, $fromEmail = null, $fromVocab = null, $toMail = null)
258 258
     {
259 259
         $toAddress = ($toMail) ? $toMail : $this->model->getConfig()->getFeedbackAddress();
260
-        $messageSubject = "[" . $this->model->getConfig()->getServiceName() . "] " . $messageSubject;
260
+        $messageSubject = "[".$this->model->getConfig()->getServiceName()."] ".$messageSubject;
261 261
         if ($fromVocab !== null && $fromVocab !== '') {
262
-            $message = 'Feedback from vocab: ' . strtoupper($fromVocab) . "<br />" . $message;
262
+            $message = 'Feedback from vocab: '.strtoupper($fromVocab)."<br />".$message;
263 263
         }
264 264
         $envelopeSender = $this->model->getConfig()->getFeedbackEnvelopeSender();
265 265
         // determine the sender address of the message
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
         $headers = $this->createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender);
273 273
         $params = empty($envelopeSender) ? '' : "-f $envelopeSender";
274 274
         // adding some information about the user for debugging purposes.
275
-        $message = $message . "<br /><br /> Debugging information:"
276
-            . "<br />Timestamp: " . date(DATE_RFC2822)
277
-            . "<br />User agent: " . $request->getServerConstant('HTTP_USER_AGENT')
278
-            . "<br />Referer: " . $request->getServerConstant('HTTP_REFERER');
275
+        $message = $message."<br /><br /> Debugging information:"
276
+            . "<br />Timestamp: ".date(DATE_RFC2822)
277
+            . "<br />User agent: ".$request->getServerConstant('HTTP_USER_AGENT')
278
+            . "<br />Referer: ".$request->getServerConstant('HTTP_REFERER');
279 279
 
280 280
         try {
281 281
             mail($toAddress, $messageSubject, $message, $headers, $params);
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
             header("HTTP/1.0 404 Not Found");
284 284
             $template = $this->twig->loadTemplate('error-page.twig');
285 285
             if ($this->model->getConfig()->getLogCaughtExceptions()) {
286
-                error_log('Caught exception: ' . $e->getMessage());
286
+                error_log('Caught exception: '.$e->getMessage());
287 287
             }
288 288
 
289 289
             echo $template->render(
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
         $vocids = ($vocabs !== null && $vocabs !== '') ? explode(' ', $vocabs) : null;
329 329
         $vocabObjects = array();
330 330
         if ($vocids) {
331
-            foreach($vocids as $vocid) {
331
+            foreach ($vocids as $vocid) {
332 332
                 try {
333 333
                     $vocabObjects[] = $this->model->getVocabulary($vocid);
334 334
                 } catch (ValueError $e) {
335 335
                     // fail fast with an error page if the vocabulary cannot be found
336 336
                     if ($this->model->getConfig()->getLogCaughtExceptions()) {
337
-                        error_log('Caught exception: ' . $e->getMessage());
337
+                        error_log('Caught exception: '.$e->getMessage());
338 338
                     }
339 339
                     header("HTTP/1.0 400 Bad Request");
340 340
                     $this->invokeGenericErrorPage($request, $e->getMessage());
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
             $errored = true;
357 357
             header("HTTP/1.0 500 Internal Server Error");
358 358
             if ($this->model->getConfig()->getLogCaughtExceptions()) {
359
-                error_log('Caught exception: ' . $e->getMessage());
359
+                error_log('Caught exception: '.$e->getMessage());
360 360
             }
361 361
         }
362 362
         $vocabList = $this->model->getVocabularyList();
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
                 'search_count' => $counts,
369 369
                 'languages' => $this->languages,
370 370
                 'search_results' => $searchResults,
371
-                'rest' => $parameters->getOffset()>0,
371
+                'rest' => $parameters->getOffset() > 0,
372 372
                 'global_search' => true,
373 373
                 'search_failed' => $errored,
374 374
                 'term' => $request->getQueryParamRaw('q'),
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
         } catch (Exception $e) {
396 396
             header("HTTP/1.0 500 Internal Server Error");
397 397
             if ($this->model->getConfig()->getLogCaughtExceptions()) {
398
-                error_log('Caught exception: ' . $e->getMessage());
398
+                error_log('Caught exception: '.$e->getMessage());
399 399
             }
400 400
 
401 401
             echo $template->render(
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
         } catch (Exception $e) {
420 420
             header("HTTP/1.0 404 Not Found");
421 421
             if ($this->model->getConfig()->getLogCaughtExceptions()) {
422
-                error_log('Caught exception: ' . $e->getMessage());
422
+                error_log('Caught exception: '.$e->getMessage());
423 423
             }
424 424
 
425 425
             echo $template->render(
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
                 'vocab' => $vocab,
438 438
                 'search_results' => $searchResults,
439 439
                 'search_count' => $counts,
440
-                'rest' => $parameters->getOffset()>0,
440
+                'rest' => $parameters->getOffset() > 0,
441 441
                 'limit_parent' => $parameters->getParentLimit(),
442 442
                 'limit_type' =>  $request->getQueryParam('type') ? explode('+', $request->getQueryParam('type')) : null,
443 443
                 'limit_group' => $parameters->getGroupLimit(),
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
      * Loads and renders the view containing a list of recent changes in the vocabulary.
570 570
      * @param Request $request
571 571
      */
572
-    public function invokeChangeList($request, $prop='dc:created')
572
+    public function invokeChangeList($request, $prop = 'dc:created')
573 573
     {
574 574
         $offset = ($request->getQueryParam('offset') && is_numeric($request->getQueryParam('offset')) && $request->getQueryParam('offset') >= 0) ? $request->getQueryParam('offset') : 0;
575 575
         $limit = ($request->getQueryParam('limit') && is_numeric($request->getQueryParam('limit')) && $request->getQueryParam('limit') >= 0) ? $request->getQueryParam('limit') : 200;
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
      * @param int $limit maximum number of concepts to return
598 598
      * @return Array list of concepts
599 599
      */
600
-    public function getChangeList($request, $prop, $offset=0, $limit=200)
600
+    public function getChangeList($request, $prop, $offset = 0, $limit = 200)
601 601
     {
602 602
         // set language parameters for gettext
603 603
         $this->setLanguageProperties($request->getLang());
@@ -614,9 +614,9 @@  discard block
 block discarded – undo
614 614
     public function formatChangeList($changeList, $lang)
615 615
     {
616 616
         $formatByDate = array();
617
-        foreach($changeList as $concept) {
617
+        foreach ($changeList as $concept) {
618 618
             $concept['datestring'] = Punic\Calendar::formatDate($concept['date'], 'medium', $lang);
619
-            $formatByDate[Punic\Calendar::getMonthName($concept['date'], 'wide', $lang, true) . Punic\Calendar::format($concept['date'], ' y', $lang) ][strtolower($concept['prefLabel'])] = $concept;
619
+            $formatByDate[Punic\Calendar::getMonthName($concept['date'], 'wide', $lang, true).Punic\Calendar::format($concept['date'], ' y', $lang)][strtolower($concept['prefLabel'])] = $concept;
620 620
         }
621 621
         return $formatByDate;
622 622
     }
Please login to merge, or discard this patch.
model/ConceptPropertyValue.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
                 }
54 54
                 // We need to check all the labels in case one of them matches a subtag of the current language
55 55
                 if ($this->resource->allLiterals('skos:prefLabel')) {
56
-                    foreach($this->resource->allLiterals('skos:prefLabel') as $label) {
56
+                    foreach ($this->resource->allLiterals('skos:prefLabel') as $label) {
57 57
                         // the label lang code is a subtag of the UI lang eg. en-GB - create a new literal with the main language
58
-                        if ($label !== null && strpos($label->getLang(), $fallback . '-') === 0) {
58
+                        if ($label !== null && strpos($label->getLang(), $fallback.'-') === 0) {
59 59
                             return EasyRdf\Literal::create($label, $fallback);
60 60
                         }
61 61
                     }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
     public function getReifiedPropertyValues() {
157 157
         $ret = array();
158 158
         $props = $this->resource->propertyUris();
159
-        foreach($props as $prop) {
159
+        foreach ($props as $prop) {
160 160
             $prop = (EasyRdf\RdfNamespace::shorten($prop) !== null) ? EasyRdf\RdfNamespace::shorten($prop) : $prop;
161 161
             foreach ($this->resource->allLiterals($prop) as $val) {
162 162
                 if ($prop !== 'rdf:value') { // shown elsewhere
Please login to merge, or discard this patch.
model/Model.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -220,18 +220,18 @@  discard block
 block discarded – undo
220 220
         }
221 221
 
222 222
         $vocabs = $params->getVocabs();
223
-        $showDeprecated=false;
223
+        $showDeprecated = false;
224 224
         if (sizeof($vocabs) === 1) { // search within vocabulary
225 225
             $voc = $vocabs[0];
226 226
             $sparql = $voc->getSparql();
227
-            $showDeprecated=$voc->getConfig()->getShowDeprecated();
227
+            $showDeprecated = $voc->getConfig()->getShowDeprecated();
228 228
         } else { // multi-vocabulary or global search
229 229
             $voc = null;
230 230
             $sparql = $this->getDefaultSparql();
231 231
             // @TODO : in a global search showDeprecated will always be false and cannot be set globally
232 232
         }
233 233
 
234
-        $results = $sparql->queryConcepts($vocabs, $params->getAdditionalFields(), $params->getUnique(), $params,$showDeprecated);
234
+        $results = $sparql->queryConcepts($vocabs, $params->getAdditionalFields(), $params->getUnique(), $params, $showDeprecated);
235 235
         if ($params->getRest() && $results && $params->getSearchLimit() !== 0) {
236 236
           $results = array_slice($results, $params->getOffset(), $params->getSearchLimit());
237 237
         }
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
     public function getVocabularyCategories()
387 387
     {
388 388
         $cats = $this->globalConfig->getGraph()->allOfType('skos:Concept');
389
-        if(empty($cats)) {
389
+        if (empty($cats)) {
390 390
             return array(new VocabularyCategory($this, null));
391 391
         }
392 392
 
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
         }
468 468
 
469 469
         // if there are multiple vocabularies and one is the preferred vocabulary, return it
470
-        if($preferredVocabId != null) {
470
+        if ($preferredVocabId != null) {
471 471
             foreach ($vocabs as $vocab) {
472
-                if($vocab->getId() == $preferredVocabId) {
472
+                if ($vocab->getId() == $preferredVocabId) {
473 473
                     try {
474 474
                         // double check that a label exists in the preferred vocabulary
475 475
                         if ($vocab->getConceptLabel($uri, null) !== null) {
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
                         }
481 481
                     } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
482 482
                         if ($this->getConfig()->getLogCaughtExceptions()) {
483
-                            error_log('Caught exception: ' . $e->getMessage());
483
+                            error_log('Caught exception: '.$e->getMessage());
484 484
                         }
485 485
                         break;
486 486
                     }
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
                 }
497 497
             } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
498 498
                 if ($this->getConfig()->getLogCaughtExceptions()) {
499
-                    error_log('Caught exception: ' . $e->getMessage());
499
+                    error_log('Caught exception: '.$e->getMessage());
500 500
                 }
501 501
                 break;
502 502
             }
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
         // using apc cache for the resource if available
567 567
         if ($this->globalConfig->getCache()->isAvailable()) {
568 568
             // @codeCoverageIgnoreStart
569
-            $key = 'fetch: ' . $uri;
569
+            $key = 'fetch: '.$uri;
570 570
             $resource = $this->globalConfig->getCache()->fetch($key);
571 571
             if ($resource === null || $resource === false) { // was not found in cache, or previous request failed
572 572
                 $resource = $this->resolver->resolve($uri, $this->getConfig()->getHttpTimeout());
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
      */
588 588
     public function getSparqlImplementation($dialect, $endpoint, $graph)
589 589
     {
590
-        $classname = $dialect . "Sparql";
590
+        $classname = $dialect."Sparql";
591 591
 
592 592
         return new $classname($endpoint, $graph, $this);
593 593
     }
Please login to merge, or discard this patch.
model/DataObject.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
                 return isset($results[$lang]) ? $results[$lang] : null;
53 53
             } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
54 54
                 if ($this->model->getConfig()->getLogCaughtExceptions()) {
55
-                    error_log('Caught exception: ' . $e->getMessage());
55
+                    error_log('Caught exception: '.$e->getMessage());
56 56
                 }
57 57
             }
58 58
         }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
                 return isset($results) ? $results : null;
75 75
             } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
76 76
                 if ($this->model->getConfig()->getLogCaughtExceptions()) {
77
-                    error_log('Caught exception: ' . $e->getMessage());
77
+                    error_log('Caught exception: '.$e->getMessage());
78 78
                 }
79 79
             }
80 80
         }
Please login to merge, or discard this patch.
model/Vocabulary.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
             return $lname;
103 103
         }
104 104
         // already a full URI
105
-        return $this->getUriSpace() . $lname;
105
+        return $this->getUriSpace().$lname;
106 106
     }
107 107
 
108 108
     /**
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
             $result = $sparql->queryConceptScheme($defaultcs);
165 165
         } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
166 166
              if ($this->model->getConfig()->getLogCaughtExceptions()) {
167
-                 error_log('Caught exception: ' . $e->getMessage());
167
+                 error_log('Caught exception: '.$e->getMessage());
168 168
              }
169 169
              return null;
170 170
         }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
                 foreach ($conceptscheme->allLiterals($prop, null) as $val) {
198 198
                     $prop = (substr($prop, 0, 5) == 'dc11:') ? str_replace('dc11:', 'dc:', $prop) : $prop;
199 199
                     if ($val->getValue() instanceof DateTime) {
200
-                        $val = Punic\Calendar::formatDate($val->getValue(), 'full', $lang) . ' ' . Punic\Calendar::format($val->getValue(), 'HH:mm:ss', $lang);
200
+                        $val = Punic\Calendar::formatDate($val->getValue(), 'full', $lang).' '.Punic\Calendar::format($val->getValue(), 'HH:mm:ss', $lang);
201 201
                     }
202 202
                     $ret[$prop][] = $val;
203 203
                 }
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
             $conceptSchemes = $this->getSparql()->queryConceptSchemes($lang);
255 255
         } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
256 256
              if ($this->model->getConfig()->getLogCaughtExceptions()) {
257
-                 error_log('Caught exception: ' . $e->getMessage());
257
+                 error_log('Caught exception: '.$e->getMessage());
258 258
              }
259 259
         }
260 260
         return $conceptSchemes;
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
         }
326 326
         // don't know how to parse
327 327
         $rev = $parts[2];
328
-        $datestr = $parts[3] . ' ' . $parts[4];
328
+        $datestr = $parts[3].' '.$parts[4];
329 329
 
330 330
         return "$datestr (r$rev)";
331 331
     }
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
      * @param string $array the uri of the concept array class, eg. isothes:ThesaurusArray
337 337
      * @param string $group the uri of the  concept group class, eg. isothes:ConceptGroup
338 338
      */
339
-    public function getStatistics($lang = '', $array=null, $group=null)
339
+    public function getStatistics($lang = '', $array = null, $group = null)
340 340
     {
341 341
         $sparql = $this->getSparql();
342 342
         // find the number of concepts
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
             $conceptInfo = $sparql->queryConceptInfo($uri, $this->config->getArrayClassURI(), array($this), $clang);
455 455
         } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
456 456
              if ($this->model->getConfig()->getLogCaughtExceptions()) {
457
-                 error_log('Caught exception: ' . $e->getMessage());
457
+                 error_log('Caught exception: '.$e->getMessage());
458 458
              }
459 459
         }
460 460
         return $conceptInfo;
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
       return $this->getSparql()->queryChangeList($prop, $clang, $offset, $limit);
665 665
     }
666 666
 
667
-    public function getTitle($lang=null) {
667
+    public function getTitle($lang = null) {
668 668
       return $this->config->getTitle($lang);
669 669
     }
670 670
 
Please login to merge, or discard this patch.