Completed
Pull Request — master (#39)
by Thierry
03:03
created
src/Jaxon.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -159,13 +159,13 @@  discard block
 block discarded – undo
159 159
         $aArgs = func_get_args();
160 160
         $nArgs = func_num_args();
161 161
 
162
-        if(self::PROCESSING_EVENT == $sType)
162
+        if (self::PROCESSING_EVENT == $sType)
163 163
         {
164
-            if($nArgs > 2)
164
+            if ($nArgs > 2)
165 165
             {
166 166
                 $sEvent = $xArgs;
167 167
                 $xUserFunction = $aArgs[2];
168
-                if(!is_a($xUserFunction, 'Request\\Support\\UserFunction'))
168
+                if (!is_a($xUserFunction, 'Request\\Support\\UserFunction'))
169 169
                     $xUserFunction = new Request\Support\UserFunction($xUserFunction);
170 170
                 $this->aProcessingEvents[$sEvent] = $xUserFunction;
171 171
             }
@@ -237,16 +237,16 @@  discard block
 block discarded – undo
237 237
      */
238 238
     public function getScript($bIncludeJs = false, $bIncludeCss = false)
239 239
     {
240
-        if(!$this->getOption('core.request.uri'))
240
+        if (!$this->getOption('core.request.uri'))
241 241
         {
242 242
             $this->setOption('core.request.uri', URI::detect());
243 243
         }
244 244
         $sCode = '';
245
-        if(($bIncludeCss))
245
+        if (($bIncludeCss))
246 246
         {
247 247
             $sCode .= $this->getPluginManager()->getCss() . "\n";
248 248
         }
249
-        if(($bIncludeJs))
249
+        if (($bIncludeJs))
250 250
         {
251 251
             $sCode .= $this->getPluginManager()->getJs() . "\n";
252 252
         }
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
     public function processRequest()
318 318
     {
319 319
         // Check to see if headers have already been sent out, in which case we can't do our job
320
-        if(headers_sent($filename, $linenumber))
320
+        if (headers_sent($filename, $linenumber))
321 321
         {
322 322
             echo $this->trans('errors.output.already-sent', array(
323 323
                 'location' => $filename . ':' . $linenumber
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
         }
327 327
 
328 328
         // Check if there is a plugin to process this request
329
-        if(!$this->canProcessRequest())
329
+        if (!$this->canProcessRequest())
330 330
         {
331 331
             return;
332 332
         }
@@ -336,18 +336,18 @@  discard block
 block discarded – undo
336 336
         $xResponseManager = $this->getResponseManager();
337 337
 
338 338
         // Handle before processing event
339
-        if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE]))
339
+        if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE]))
340 340
         {
341 341
             $this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE]->call(array(&$bEndRequest));
342 342
         }
343 343
 
344
-        if(!$bEndRequest)
344
+        if (!$bEndRequest)
345 345
         {
346 346
             try
347 347
             {
348 348
                 $mResult = $this->getPluginManager()->processRequest();
349 349
             }
350
-            catch(Exception $e)
350
+            catch (Exception $e)
351 351
             {
352 352
                 // An exception was thrown while processing the request.
353 353
                 // The request missed the corresponding handler function,
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
                 $xResponseManager->debug($e->getMessage());
360 360
                 $mResult = false;
361 361
 
362
-                if($e instanceof \Jaxon\Exception\Error)
362
+                if ($e instanceof \Jaxon\Exception\Error)
363 363
                 {
364 364
                     $sEvent = self::PROCESSING_EVENT_INVALID;
365 365
                     $aParams = array($e->getMessage());
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
                     $aParams = array($e);
371 371
                 }
372 372
 
373
-                if(isset($this->aProcessingEvents[$sEvent]))
373
+                if (isset($this->aProcessingEvents[$sEvent]))
374 374
                 {
375 375
                     // Call the processing event
376 376
                     $this->aProcessingEvents[$sEvent]->call($aParams);
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
             }
384 384
         }
385 385
         // Clean the processing buffer
386
-        if(($this->getOption('core.process.clean')))
386
+        if (($this->getOption('core.process.clean')))
387 387
         {
388 388
             $er = error_reporting(0);
389 389
             while (ob_get_level() > 0)
@@ -393,16 +393,16 @@  discard block
 block discarded – undo
393 393
             error_reporting($er);
394 394
         }
395 395
 
396
-        if($mResult === true)
396
+        if ($mResult === true)
397 397
         {
398 398
             // Handle after processing event
399
-            if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER]))
399
+            if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER]))
400 400
             {
401 401
                 $bEndRequest = false;
402 402
                 $this->aProcessingEvents[self::PROCESSING_EVENT_AFTER]->call(array($bEndRequest));
403 403
             }
404 404
             // If the called function returned no response, give the the global response instead
405
-            if($xResponseManager->hasNoResponse())
405
+            if ($xResponseManager->hasNoResponse())
406 406
             {
407 407
                 $xResponseManager->append($this->getResponse());
408 408
             }
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 
411 411
         $xResponseManager->printDebug();
412 412
 
413
-        if(($this->getOption('core.process.exit')))
413
+        if (($this->getOption('core.process.exit')))
414 414
         {
415 415
             $xResponseManager->sendOutput();
416 416
             exit();
Please login to merge, or discard this patch.
src/Request/Plugin/FileUpload.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
         $this->aUserFiles = [];
60 60
         $this->sUploadSubdir = uniqid() . DIRECTORY_SEPARATOR;
61 61
 
62
-        if(array_key_exists('jxnupl', $_POST))
62
+        if (array_key_exists('jxnupl', $_POST))
63 63
         {
64 64
             $this->sTempFile = $_POST['jxnupl'];
65 65
         }
66
-        elseif(array_key_exists('jxnupl', $_GET))
66
+        elseif (array_key_exists('jxnupl', $_GET))
67 67
         {
68 68
             $this->sTempFile = $_GET['jxnupl'];
69 69
         }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     protected function filterFilename($sFilename, $sVarName)
93 93
     {
94
-        if(($this->fFileFilter))
94
+        if (($this->fFileFilter))
95 95
         {
96 96
             $fFileFilter = $this->fFileFilter;
97 97
             $sFilename = (string)$fFileFilter($sFilename, $sVarName);
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         $sUploadDir = $this->getOption('upload.files.' . $sFieldId . '.dir', $sDefaultUploadDir);
114 114
         $sUploadDir = rtrim(trim($sUploadDir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
115 115
         // Verify that the upload dir exists and is writable
116
-        if(!is_writable($sUploadDir))
116
+        if (!is_writable($sUploadDir))
117 117
         {
118 118
             throw new \Jaxon\Exception\Error($this->trans('errors.upload.access'));
119 119
         }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         $sUploadDir = $this->getOption('upload.default.dir');
134 134
         $sUploadDir = rtrim(trim($sUploadDir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
135 135
         // Verify that the upload dir exists and is writable
136
-        if(!is_writable($sUploadDir))
136
+        if (!is_writable($sUploadDir))
137 137
         {
138 138
             throw new \Jaxon\Exception\Error($this->trans('errors.upload.access'));
139 139
         }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         $sUploadDir = rtrim(trim($sUploadDir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
154 154
         $sUploadDir .= 'tmp' . DIRECTORY_SEPARATOR;
155 155
         $sUploadTempFile = $sUploadDir . $this->sTempFile . '.json';
156
-        if(!is_readable($sUploadTempFile))
156
+        if (!is_readable($sUploadTempFile))
157 157
         {
158 158
             throw new \Jaxon\Exception\Error($this->trans('errors.upload.access'));
159 159
         }
@@ -169,17 +169,17 @@  discard block
 block discarded – undo
169 169
     {
170 170
         // Check validity of the uploaded files
171 171
         $aTempFiles = [];
172
-        foreach($_FILES as $sVarName => $aFile)
172
+        foreach ($_FILES as $sVarName => $aFile)
173 173
         {
174
-            if(is_array($aFile['name']))
174
+            if (is_array($aFile['name']))
175 175
             {
176
-                for($i = 0; $i < count($aFile['name']); $i++)
176
+                for ($i = 0; $i < count($aFile['name']); $i++)
177 177
                 {
178
-                    if(!$aFile['name'][$i])
178
+                    if (!$aFile['name'][$i])
179 179
                     {
180 180
                         continue;
181 181
                     }
182
-                    if(!array_key_exists($sVarName, $aTempFiles))
182
+                    if (!array_key_exists($sVarName, $aTempFiles))
183 183
                     {
184 184
                         $aTempFiles[$sVarName] = [];
185 185
                     }
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
             }
200 200
             else
201 201
             {
202
-                if(!$aFile['name'])
202
+                if (!$aFile['name'])
203 203
                 {
204 204
                     continue;
205 205
                 }
206
-                if(!array_key_exists($sVarName, $aTempFiles))
206
+                if (!array_key_exists($sVarName, $aTempFiles))
207 207
                 {
208 208
                     $aTempFiles[$sVarName] = [];
209 209
                 }
@@ -223,17 +223,17 @@  discard block
 block discarded – undo
223 223
         }
224 224
 
225 225
         // Check uploaded files validity
226
-        foreach($aTempFiles as $sVarName => $aFiles)
226
+        foreach ($aTempFiles as $sVarName => $aFiles)
227 227
         {
228
-            foreach($aFiles as $aFile)
228
+            foreach ($aFiles as $aFile)
229 229
             {
230 230
                 // Verify upload result
231
-                if($aFile['error'] != 0)
231
+                if ($aFile['error'] != 0)
232 232
                 {
233 233
                     throw new \Jaxon\Exception\Error($this->trans('errors.upload.failed', $aFile));
234 234
                 }
235 235
                 // Verify file validity (format, size)
236
-                if(!$this->validateUploadedFile($sVarName, $aFile))
236
+                if (!$this->validateUploadedFile($sVarName, $aFile))
237 237
                 {
238 238
                     throw new \Jaxon\Exception\Error($this->getValidatorMessage());
239 239
                 }
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
         }
244 244
 
245 245
         // Copy the uploaded files from the temp dir to the user dir
246
-        foreach($aTempFiles as $sVarName => $aTempFiles)
246
+        foreach ($aTempFiles as $sVarName => $aTempFiles)
247 247
         {
248 248
             $this->aUserFiles[$sVarName] = [];
249
-            foreach($aTempFiles as $aFile)
249
+            foreach ($aTempFiles as $aFile)
250 250
             {
251 251
                 // Get the path to the upload dir
252 252
                 $sUploadDir = $this->getUploadDir($sVarName);
@@ -268,10 +268,10 @@  discard block
 block discarded – undo
268 268
     {
269 269
         // Convert uploaded file to an array
270 270
         $aFiles = [];
271
-        foreach($this->aUserFiles as $sVarName => $aUserFiles)
271
+        foreach ($this->aUserFiles as $sVarName => $aUserFiles)
272 272
         {
273 273
             $aFiles[$sVarName] = [];
274
-            foreach($aUserFiles as $aUserFile)
274
+            foreach ($aUserFiles as $aUserFile)
275 275
             {
276 276
                  $aFiles[$sVarName][] = $aUserFile->toTempData();
277 277
             }
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
         // Upload temp file
293 293
         $sUploadTempFile = $this->getUploadTempFile();
294 294
         $aFiles = json_decode(file_get_contents($sUploadTempFile), true);
295
-        foreach($aFiles as $sVarName => $aUserFiles)
295
+        foreach ($aFiles as $sVarName => $aUserFiles)
296 296
         {
297 297
             $this->aUserFiles[$sVarName] = [];
298
-            foreach($aUserFiles as $aUserFile)
298
+            foreach ($aUserFiles as $aUserFile)
299 299
             {
300 300
                 $this->aUserFiles[$sVarName][] = UploadedFile::fromTempData($aUserFile);
301 301
             }
@@ -372,15 +372,15 @@  discard block
 block discarded – undo
372 372
      */
373 373
     public function processRequest()
374 374
     {
375
-        if(!$this->canProcessRequest())
375
+        if (!$this->canProcessRequest())
376 376
         {
377 377
             return false;
378 378
         }
379
-        if(count($_FILES) > 0)
379
+        if (count($_FILES) > 0)
380 380
         {
381 381
             $this->readFromHttpData();
382 382
         }
383
-        elseif(($this->sTempFile))
383
+        elseif (($this->sTempFile))
384 384
         {
385 385
             $this->readFromTempFile();
386 386
         }
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
     public function saveUploadedFiles()
396 396
     {
397 397
         // Process uploaded files
398
-        if(!$this->processRequest())
398
+        if (!$this->processRequest())
399 399
         {
400 400
             return '';
401 401
         }
Please login to merge, or discard this patch.