Completed
Pull Request — master (#748)
by Dan Michael O.
02:06
created
controller/RestController.php 1 patch
Spacing   +15 added lines, -15 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
             }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         if ($request->getQueryParam('labellang')) {
161 161
             $ret['@context']['@language'] = $request->getQueryParam('labellang');
162 162
         } elseif ($request->getQueryParam('lang')) {
163
-            $ret['@context']['@language'] = $request->getQueryParam('lang');;
163
+            $ret['@context']['@language'] = $request->getQueryParam('lang'); ;
164 164
         }
165 165
         return $ret;
166 166
     }
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
                 'prefLabel' => 'skos:prefLabel',
228 228
                 'title' => 'dct:title',
229 229
                 '@language' => $request->getLang(),
230
-                '@base' => $this->getBaseHref() . "rest/v1/" . $vocab->getId() . "/",
230
+                '@base' => $this->getBaseHref()."rest/v1/".$vocab->getId()."/",
231 231
             ),
232 232
             'uri' => '',
233 233
             'id' => $vocab->getId(),
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                 'subTypes' => array('@id' => 'void:class', '@type' => '@id'),
278 278
                 'count' => 'void:entities',
279 279
                 '@language' => $request->getLang(),
280
-                '@base' => $this->getBaseHref() . "rest/v1/" . $request->getVocab()->getId() . "/",
280
+                '@base' => $this->getBaseHref()."rest/v1/".$request->getVocab()->getId()."/",
281 281
             ),
282 282
             'uri' => '',
283 283
             'id' => $request->getVocab()->getId(),
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
                 'language' => 'void-ext:language',
352 352
                 'properties' => 'void:propertyPartition',
353 353
                 'labels' => 'void:triples',
354
-                '@base' => $this->getBaseHref() . "rest/v1/" . $request->getVocab()->getId() . "/",
354
+                '@base' => $this->getBaseHref()."rest/v1/".$request->getVocab()->getId()."/",
355 355
             ),
356 356
             'uri' => '',
357 357
             'id' => $request->getVocab()->getId(),
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
             $types[] = $type;
389 389
         }
390 390
 
391
-        $base = $request->getVocab() ? $this->getBaseHref() . "rest/v1/" . $request->getVocab()->getId() . "/" : $this->getBaseHref() . "rest/v1/";
391
+        $base = $request->getVocab() ? $this->getBaseHref()."rest/v1/".$request->getVocab()->getId()."/" : $this->getBaseHref()."rest/v1/";
392 392
 
393 393
         $ret = array_merge_recursive($this->context, array(
394 394
             '@context' => array(
@@ -548,10 +548,10 @@  discard block
 block discarded – undo
548 548
 
549 549
         $format = $this->negotiateFormat(array_keys($urls), $request->getServerConstant('HTTP_ACCEPT'), $request->getQueryParam('format'));
550 550
         if (!$format) {
551
-            return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: " . implode(' ', array_keys($urls)));
551
+            return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: ".implode(' ', array_keys($urls)));
552 552
         }
553 553
 
554
-        header("Location: " . $urls[$format]);
554
+        header("Location: ".$urls[$format]);
555 555
     }
556 556
 
557 557
     private function returnDataResults($results, $format) {
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 
611 611
         $format = $this->negotiateFormat(explode(' ', self::SUPPORTED_FORMATS), $request->getServerConstant('HTTP_ACCEPT'), $request->getQueryParam('format'));
612 612
         if (!$format) {
613
-            return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: " . self::SUPPORTED_FORMATS);
613
+            return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: ".self::SUPPORTED_FORMATS);
614 614
         }
615 615
 
616 616
         $vocid = $vocab ? $vocab->getId() : null;
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
                         }
771 771
                     }
772 772
                     // if the main concept scheme was not found, set 'top' to the first 'tops' (sorted alphabetically on the URIs)
773
-                    if (! isset($results[$uri]['top'])) {
773
+                    if (!isset($results[$uri]['top'])) {
774 774
                         $results[$uri]['top'] = $results[$uri]['tops'][0];
775 775
                     }
776 776
                 } else {
Please login to merge, or discard this patch.
model/Request.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -74,7 +74,9 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function getQueryParam($paramName)
76 76
     {
77
-        if (!isset($this->queryParams[$paramName])) return null;
77
+        if (!isset($this->queryParams[$paramName])) {
78
+          return null;
79
+        }
78 80
         $val = filter_var($this->queryParams[$paramName], FILTER_SANITIZE_STRING);
79 81
         return ($val !== null ? str_replace('\\', '', $val) : null);
80 82
     }
@@ -91,7 +93,9 @@  discard block
 block discarded – undo
91 93
 
92 94
     public function getQueryParamPOST($paramName)
93 95
     {
94
-        if (!isset($this->queryParamsPOST[$paramName])) return null;
96
+        if (!isset($this->queryParamsPOST[$paramName])) {
97
+          return null;
98
+        }
95 99
         return filter_var($this->queryParamsPOST[$paramName], FILTER_SANITIZE_STRING);
96 100
     }
97 101
 
@@ -106,7 +110,9 @@  discard block
 block discarded – undo
106 110
 
107 111
     public function getServerConstant($paramName)
108 112
     {
109
-        if (!isset($this->serverConstants[$paramName])) return null;
113
+        if (!isset($this->serverConstants[$paramName])) {
114
+          return null;
115
+        }
110 116
         return filter_var($this->serverConstants[$paramName], FILTER_SANITIZE_STRING);
111 117
     }
112 118
 
@@ -239,9 +245,11 @@  discard block
 block discarded – undo
239 245
      */
240 246
     public function setVocab($vocabid)
241 247
     {
242
-        if (strpos($vocabid, ' ') !== false) // if there are multiple vocabularies just storing the string
248
+        if (strpos($vocabid, ' ') !== false) {
249
+          // if there are multiple vocabularies just storing the string
243 250
         {
244 251
             $this->setVocabids($vocabid);
252
+        }
245 253
         } else {
246 254
             $this->vocab = $this->model->getVocabulary($vocabid);
247 255
         }
Please login to merge, or discard this patch.