Passed
Push — 1.10.x ( f64eef...04397c )
by Angel Fernando Quiroz
132:38 queued 79:40
created
main/inc/lib/course_home.lib.php 1 patch
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1200,9 +1200,9 @@
 block discarded – undo
1200 1200
         $navigation_items = self::get_navigation_items(false);
1201 1201
         $html = '';
1202 1202
         if (!empty($navigation_items)) {
1203
-            if ($orientation == SHORTCUTS_HORIZONTAL)
1204
-                $style_id = "toolshortcuts_horizontal";
1205
-            else {
1203
+            if ($orientation == SHORTCUTS_HORIZONTAL) {
1204
+                            $style_id = "toolshortcuts_horizontal";
1205
+            } else {
1206 1206
                 $style_id = "toolshortcuts_vertical";
1207 1207
             }
1208 1208
             $html .= '<div id="'.$style_id.'">';
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.soapclient.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -173,8 +173,9 @@  discard block
 block discarded – undo
173 173
 		}
174 174
 		if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
175 175
 			$this->loadWSDL();
176
-			if ($this->getError())
177
-				return false;
176
+			if ($this->getError()) {
177
+							return false;
178
+			}
178 179
 		}
179 180
 		// serialize parameters
180 181
 		if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){
@@ -388,8 +389,9 @@  discard block
 block discarded – undo
388 389
 	function getOperationData($operation){
389 390
 		if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
390 391
 			$this->loadWSDL();
391
-			if ($this->getError())
392
-				return false;
392
+			if ($this->getError()) {
393
+							return false;
394
+			}
393 395
 		}
394 396
 		if(isset($this->operations[$operation])){
395 397
 			return $this->operations[$operation];
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.soap_transport_http.php 1 patch
Braces   +39 added lines, -29 removed lines patch added patch discarded remove patch
@@ -159,10 +159,12 @@  discard block
 block discarded – undo
159 159
 	* @access	private
160 160
 	*/
161 161
 	function io_method() {
162
-		if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm'))
163
-			return 'curl';
164
-		if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm'))
165
-			return 'socket';
162
+		if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm')) {
163
+					return 'curl';
164
+		}
165
+		if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm')) {
166
+					return 'socket';
167
+		}
166 168
 		return 'unknown';
167 169
 	}
168 170
 
@@ -246,30 +248,36 @@  discard block
 block discarded – undo
246 248
 			return false;
247 249
 		}
248 250
 		// Avoid warnings when PHP does not have these options
249
-		if (defined('CURLOPT_CONNECTIONTIMEOUT'))
250
-			$CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
251
-		else
252
-			$CURLOPT_CONNECTIONTIMEOUT = 78;
253
-		if (defined('CURLOPT_HTTPAUTH'))
254
-			$CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
255
-		else
256
-			$CURLOPT_HTTPAUTH = 107;
257
-		if (defined('CURLOPT_PROXYAUTH'))
258
-			$CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
259
-		else
260
-			$CURLOPT_PROXYAUTH = 111;
261
-		if (defined('CURLAUTH_BASIC'))
262
-			$CURLAUTH_BASIC = CURLAUTH_BASIC;
263
-		else
264
-			$CURLAUTH_BASIC = 1;
265
-		if (defined('CURLAUTH_DIGEST'))
266
-			$CURLAUTH_DIGEST = CURLAUTH_DIGEST;
267
-		else
268
-			$CURLAUTH_DIGEST = 2;
269
-		if (defined('CURLAUTH_NTLM'))
270
-			$CURLAUTH_NTLM = CURLAUTH_NTLM;
271
-		else
272
-			$CURLAUTH_NTLM = 8;
251
+		if (defined('CURLOPT_CONNECTIONTIMEOUT')) {
252
+					$CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
253
+		} else {
254
+					$CURLOPT_CONNECTIONTIMEOUT = 78;
255
+		}
256
+		if (defined('CURLOPT_HTTPAUTH')) {
257
+					$CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
258
+		} else {
259
+					$CURLOPT_HTTPAUTH = 107;
260
+		}
261
+		if (defined('CURLOPT_PROXYAUTH')) {
262
+					$CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
263
+		} else {
264
+					$CURLOPT_PROXYAUTH = 111;
265
+		}
266
+		if (defined('CURLAUTH_BASIC')) {
267
+					$CURLAUTH_BASIC = CURLAUTH_BASIC;
268
+		} else {
269
+					$CURLAUTH_BASIC = 1;
270
+		}
271
+		if (defined('CURLAUTH_DIGEST')) {
272
+					$CURLAUTH_DIGEST = CURLAUTH_DIGEST;
273
+		} else {
274
+					$CURLAUTH_DIGEST = 2;
275
+		}
276
+		if (defined('CURLAUTH_NTLM')) {
277
+					$CURLAUTH_NTLM = CURLAUTH_NTLM;
278
+		} else {
279
+					$CURLAUTH_NTLM = 8;
280
+		}
273 281
 
274 282
 		$this->debug('connect using cURL');
275 283
 		// init CURL
@@ -612,7 +620,9 @@  discard block
 block discarded – undo
612 620
 								'HTTP/1.0 200 Connection established');
613 621
 		foreach ($skipHeaders as $hd) {
614 622
 			$prefix = substr($data, 0, strlen($hd));
615
-			if ($prefix == $hd) return true;
623
+			if ($prefix == $hd) {
624
+			    return true;
625
+			}
616 626
 		}
617 627
 
618 628
 		return false;
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.wsdl.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,8 +78,9 @@
 block discarded – undo
78 78
 		$this->proxypassword = $proxypassword;
79 79
 		$this->timeout = $timeout;
80 80
 		$this->response_timeout = $response_timeout;
81
-		if (is_array($curl_options))
82
-			$this->curl_options = $curl_options;
81
+		if (is_array($curl_options)) {
82
+					$this->curl_options = $curl_options;
83
+		}
83 84
 		$this->use_curl = $use_curl;
84 85
 		$this->fetchWSDL($wsdl);
85 86
     }
Please login to merge, or discard this patch.
main/inc/lib/icalcreator/iCalcreator.class.php 1 patch
Braces   +2276 added lines, -1351 removed lines patch added patch discarded remove patch
@@ -44,8 +44,10 @@  discard block
 block discarded – undo
44 44
 }
45 45
 */
46 46
             /* only for phpversion 5.x, date management, default timezone setting */
47
-if( substr( phpversion(), 0, 1) >= '5' ) // && ( 'UTC' == date_default_timezone_get() )) {
47
+if( substr( phpversion(), 0, 1) >= '5' ) {
48
+    // && ( 'UTC' == date_default_timezone_get() )) {
48 49
   date_default_timezone_set( 'Europe/Stockholm' );
50
+}
49 51
             /* version string, do NOT remove!! */
50 52
 define( 'ICALCREATOR_VERSION', 'iCalcreator 2.6' );
51 53
 /*********************************************************************************/
@@ -97,8 +99,9 @@  discard block
 block discarded – undo
97 99
 /**
98 100
  *   language = <Text identifying a language, as defined in [RFC 1766]>
99 101
  */
100
-    if( defined( 'ICAL_LANG' ))
101
-      $this->setConfig( 'language', ICAL_LANG );
102
+    if( defined( 'ICAL_LANG' )) {
103
+          $this->setConfig( 'language', ICAL_LANG );
104
+    }
102 105
     $this->setConfig( 'allowEmpty', TRUE );
103 106
     $this->setConfig( 'nl',         "\n" );
104 107
     $this->setConfig( 'format',     'iCal');
@@ -121,7 +124,9 @@  discard block
 block discarded – undo
121 124
  * @return string
122 125
  */
123 126
   function createCalscale() {
124
-    if( empty( $this->calscale )) return FALSE;
127
+    if( empty( $this->calscale )) {
128
+        return FALSE;
129
+    }
125 130
     switch( $this->format ) {
126 131
       case 'xcal':
127 132
         return ' calscale="'.$this->calscale.'"'.$this->nl;
@@ -140,7 +145,9 @@  discard block
 block discarded – undo
140 145
  * @return void
141 146
  */
142 147
   function setCalscale( $value ) {
143
-    if( empty( $value )) return FALSE;
148
+    if( empty( $value )) {
149
+        return FALSE;
150
+    }
144 151
     $this->calscale = $value;
145 152
   }
146 153
 /*********************************************************************************/
@@ -155,7 +162,9 @@  discard block
 block discarded – undo
155 162
  * @return string
156 163
  */
157 164
   function createMethod() {
158
-    if( empty( $this->method )) return FALSE;
165
+    if( empty( $this->method )) {
166
+        return FALSE;
167
+    }
159 168
     switch( $this->format ) {
160 169
       case 'xcal':
161 170
         return ' method="'.$this->method.'"'.$this->nl;
@@ -174,7 +183,9 @@  discard block
 block discarded – undo
174 183
  * @return bool
175 184
  */
176 185
   function setMethod( $value ) {
177
-    if( empty( $value )) return FALSE;
186
+    if( empty( $value )) {
187
+        return FALSE;
188
+    }
178 189
     $this->method = $value;
179 190
     return TRUE;
180 191
   }
@@ -194,8 +205,9 @@  discard block
 block discarded – undo
194 205
  * @return string
195 206
  */
196 207
   function createProdid() {
197
-    if( !isset( $this->prodid ))
198
-      $this->_makeProdid();
208
+    if( !isset( $this->prodid )) {
209
+          $this->_makeProdid();
210
+    }
199 211
     switch( $this->format ) {
200 212
       case 'xcal':
201 213
         return ' prodid="'.$this->prodid.'"'.$this->nl;
@@ -246,8 +258,9 @@  discard block
 block discarded – undo
246 258
  * @return string
247 259
  */
248 260
   function createVersion() {
249
-    if( empty( $this->version ))
250
-      $this->_makeVersion();
261
+    if( empty( $this->version )) {
262
+          $this->_makeVersion();
263
+    }
251 264
     switch( $this->format ) {
252 265
       case 'xcal':
253 266
         return ' version="'.$this->version.'"'.$this->nl;
@@ -276,7 +289,9 @@  discard block
 block discarded – undo
276 289
  * @return void
277 290
  */
278 291
   function setVersion( $value ) {
279
-    if( empty( $value )) return FALSE;
292
+    if( empty( $value )) {
293
+        return FALSE;
294
+    }
280 295
     $this->version = $value;
281 296
     return TRUE;
282 297
   }
@@ -292,10 +307,12 @@  discard block
 block discarded – undo
292 307
  * @return string
293 308
  */
294 309
   function createXprop() {
295
-    if( 'xcal' == $this->format )
296
-      return false;
297
-    if( 0 >= count( $this->xprop ))
298
-      return;
310
+    if( 'xcal' == $this->format ) {
311
+          return false;
312
+    }
313
+    if( 0 >= count( $this->xprop )) {
314
+          return;
315
+    }
299 316
     $output = null;
300 317
     $toolbox = new calendarComponent();
301 318
     $toolbox->setConfig( 'language', $this->getConfig( 'language' ));
@@ -308,12 +325,13 @@  discard block
 block discarded – undo
308 325
       }
309 326
       $attributes = $toolbox->_createParams( $xpropPart['params'], array( 'LANGUAGE' ));
310 327
       if( is_array( $xpropPart['value'] )) {
311
-        foreach( $xpropPart['value'] as $pix => $theXpart )
312
-          $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart );
328
+        foreach( $xpropPart['value'] as $pix => $theXpart ) {
329
+                  $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart );
330
+        }
313 331
         $xpropPart['value']  = implode( ',', $xpropPart['value'] );
332
+      } else {
333
+              $xpropPart['value'] = $toolbox->_strrep( $xpropPart['value'] );
314 334
       }
315
-      else
316
-        $xpropPart['value'] = $toolbox->_strrep( $xpropPart['value'] );
317 335
       $output    .= $toolbox->_createElement( $label, $attributes, $xpropPart['value'] );
318 336
     }
319 337
     return $output;
@@ -329,12 +347,20 @@  discard block
 block discarded – undo
329 347
  * @return bool
330 348
  */
331 349
   function setXprop( $label, $value, $params=FALSE ) {
332
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
333
-    if( empty( $label )) return FALSE;
350
+    if( empty( $value )) {
351
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
352
+    } else {
353
+        return FALSE;
354
+    }
355
+    if( empty( $label )) {
356
+        return FALSE;
357
+    }
334 358
     $xprop           = array( 'value' => $value );
335 359
     $toolbox         = new calendarComponent();
336 360
     $xprop['params'] = $toolbox->_setParams( $params );
337
-    if( !is_array( $this->xprop )) $this->xprop = array();
361
+    if( !is_array( $this->xprop )) {
362
+        $this->xprop = array();
363
+    }
338 364
     $this->xprop[strtoupper( $label )] = $xprop;
339 365
     return TRUE;
340 366
   }
@@ -350,8 +376,9 @@  discard block
 block discarded – undo
350 376
  */
351 377
   function deleteProperty( $propName, $propix=FALSE ) {
352 378
     $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';
353
-    if( !$propix )
354
-      $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
379
+    if( !$propix ) {
380
+          $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
381
+    }
355 382
     $this->propdelix[$propName] = --$propix;
356 383
     $return = FALSE;
357 384
     switch( $propName ) {
@@ -370,18 +397,23 @@  discard block
 block discarded – undo
370 397
       default:
371 398
         $reduced = array();
372 399
         if( $propName != 'X-PROP' ) {
373
-          if( !isset( $this->xprop[$propName] )) return FALSE;
400
+          if( !isset( $this->xprop[$propName] )) {
401
+              return FALSE;
402
+          }
374 403
           foreach( $this->xprop as $k => $a ) {
375
-            if(( $k != $propName ) && !empty( $a ))
376
-              $reduced[$k] = $a;
404
+            if(( $k != $propName ) && !empty( $a )) {
405
+                          $reduced[$k] = $a;
406
+            }
407
+          }
408
+        } else {
409
+          if( count( $this->xprop ) <= $propix ) {
410
+              return FALSE;
377 411
           }
378
-        }
379
-        else {
380
-          if( count( $this->xprop ) <= $propix )  return FALSE;
381 412
           $xpropno = 0;
382 413
           foreach( $this->xprop as $xpropkey => $xpropvalue ) {
383
-            if( $propix != $xpropno )
384
-              $reduced[$xpropkey] = $xpropvalue;
414
+            if( $propix != $xpropno ) {
415
+                          $reduced[$xpropkey] = $xpropvalue;
416
+            }
385 417
             $xpropno++;
386 418
           }
387 419
         }
@@ -403,8 +435,9 @@  discard block
 block discarded – undo
403 435
   function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE ) {
404 436
     $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';
405 437
     if( 'X-PROP' == $propName ) {
406
-      if( !$propix )
407
-        $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;
438
+      if( !$propix ) {
439
+              $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;
440
+      }
408 441
       $this->propix[$propName] = --$propix;
409 442
     }
410 443
     switch( $propName ) {
@@ -415,8 +448,9 @@  discard block
 block discarded – undo
415 448
         return ( !empty( $this->method )) ? $this->method : null;
416 449
         break;
417 450
       case 'PRODID':
418
-        if( empty( $this->prodid ))
419
-          $this->_makeProdid();
451
+        if( empty( $this->prodid )) {
452
+                  $this->_makeProdid();
453
+        }
420 454
         return $this->prodid;
421 455
         break;
422 456
       case 'VERSION':
@@ -424,19 +458,23 @@  discard block
 block discarded – undo
424 458
         break;
425 459
       default:
426 460
         if( $propName != 'X-PROP' ) {
427
-          if( !isset( $this->xprop[$propName] )) return FALSE;
461
+          if( !isset( $this->xprop[$propName] )) {
462
+              return FALSE;
463
+          }
428 464
           return ( $inclParam ) ? array( $propName, $this->xprop[$propName] )
429 465
                                 : array( $propName, $this->xprop[$propName]['value'] );
430
-        }
431
-        else {
432
-          if( empty( $this->xprop )) return FALSE;
466
+        } else {
467
+          if( empty( $this->xprop )) {
468
+              return FALSE;
469
+          }
433 470
           $xpropno = 0;
434 471
           foreach( $this->xprop as $xpropkey => $xpropvalue ) {
435
-            if( $propix == $xpropno )
436
-              return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
472
+            if( $propix == $xpropno ) {
473
+                          return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
437 474
                                     : array( $xpropkey, $this->xprop[$xpropkey]['value'] );
438
-            else
439
-              $xpropno++;
475
+            } else {
476
+                          $xpropno++;
477
+            }
440 478
           }
441 479
           return FALSE; // not found ??
442 480
         }
@@ -455,8 +493,9 @@  discard block
 block discarded – undo
455 493
  */
456 494
   function setProperty () {
457 495
     $numargs    = func_num_args();
458
-    if( 1 > $numargs )
459
-      return FALSE;
496
+    if( 1 > $numargs ) {
497
+          return FALSE;
498
+    }
460 499
     $arglist    = func_get_args();
461 500
     $arglist[0] = strtoupper( $arglist[0] );
462 501
     switch( $arglist[0] ) {
@@ -467,8 +506,12 @@  discard block
 block discarded – undo
467 506
       case 'VERSION':
468 507
         return $this->setVersion( $arglist[1] );
469 508
       default:
470
-        if( !isset( $arglist[1] )) $arglist[1] = null;
471
-        if( !isset( $arglist[2] )) $arglist[2] = null;
509
+        if( !isset( $arglist[1] )) {
510
+            $arglist[1] = null;
511
+        }
512
+        if( !isset( $arglist[2] )) {
513
+            $arglist[2] = null;
514
+        }
472 515
         return $this->setXprop( $arglist[0], $arglist[1], $arglist[2] );
473 516
     }
474 517
     return FALSE;
@@ -491,7 +534,9 @@  discard block
 block discarded – undo
491 534
         unset( $this->compix );
492 535
         $info = array();
493 536
         foreach( $this->components as $cix => $component ) {
494
-          if( empty( $component )) continue;
537
+          if( empty( $component )) {
538
+              continue;
539
+          }
495 540
           unset( $component->propix );
496 541
           $info[$cix]['ordno'] = $cix + 1;
497 542
           $info[$cix]['type']  = $component->objName;
@@ -506,8 +551,9 @@  discard block
 block discarded – undo
506 551
         return $this->delimiter;
507 552
         break;
508 553
       case 'DIRECTORY':
509
-        if( empty( $this->directory ))
510
-          $this->directory = '.';
554
+        if( empty( $this->directory )) {
555
+                  $this->directory = '.';
556
+        }
511 557
         return $this->directory;
512 558
         break;
513 559
       case 'DIRFILE':
@@ -520,10 +566,13 @@  discard block
 block discarded – undo
520 566
         break;
521 567
       case 'FILENAME':
522 568
         if( empty( $this->filename )) {
523
-          if( 'xcal' == $this->format )
524
-            $this->filename = date( 'YmdHis' ).'.xml'; // recommended xcs.. .
525
-          else
526
-            $this->filename = date( 'YmdHis' ).'.ics';
569
+          if( 'xcal' == $this->format ) {
570
+                      $this->filename = date( 'YmdHis' ).'.xml';
571
+          }
572
+          // recommended xcs.. .
573
+          else {
574
+                      $this->filename = date( 'YmdHis' ).'.ics';
575
+          }
527 576
         }
528 577
         return $this->filename;
529 578
         break;
@@ -531,8 +580,9 @@  discard block
 block discarded – undo
531 580
         $size    = 0;
532 581
         if( empty( $this->url )) {
533 582
           $dirfile = $this->getConfig( 'dirfile' );
534
-          if( FALSE === ( $size = filesize( $dirfile )))
535
-            $size = 0;
583
+          if( FALSE === ( $size = filesize( $dirfile ))) {
584
+                      $size = 0;
585
+          }
536 586
           clearstatcache();
537 587
         }
538 588
         return $size;
@@ -552,10 +602,11 @@  discard block
 block discarded – undo
552 602
         return $this->unique_id;
553 603
         break;
554 604
       case 'URL':
555
-        if( !empty( $this->url ))
556
-          return $this->url;
557
-        else
558
-          return FALSE;
605
+        if( !empty( $this->url )) {
606
+                  return $this->url;
607
+        } else {
608
+                  return FALSE;
609
+        }
559 610
         break;
560 611
     }
561 612
   }
@@ -583,17 +634,18 @@  discard block
 block discarded – undo
583 634
       case 'DIRECTORY':
584 635
         $value   = trim( $value );
585 636
         $nl      = $this->getConfig('delimiter');
586
-        if( $nl == substr( $value, ( 0 - strlen( $nl ))))
587
-          $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl )));
637
+        if( $nl == substr( $value, ( 0 - strlen( $nl )))) {
638
+                  $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl )));
639
+        }
588 640
         if( is_dir( $value )) {
589 641
             /* local directory */
590 642
           clearstatcache();
591 643
           $this->directory = $value;
592 644
           $this->url       = null;
593 645
           return TRUE;
646
+        } else {
647
+                  return FALSE;
594 648
         }
595
-        else
596
-          return FALSE;
597 649
         break;
598 650
       case 'FILENAME':
599 651
         $value   = trim( $value );
@@ -609,17 +661,16 @@  discard block
 block discarded – undo
609 661
             clearstatcache();
610 662
             $this->filename = $value;
611 663
             return TRUE;
664
+          } else {
665
+                      return FALSE;
612 666
           }
613
-          else
614
-            return FALSE;
615
-        }
616
-        elseif( FALSE !== touch( $dirfile )) {
667
+        } elseif( FALSE !== touch( $dirfile )) {
617 668
             /* new local file created */
618 669
           $this->filename = $value;
619 670
           return TRUE;
671
+        } else {
672
+                  return FALSE;
620 673
         }
621
-        else
622
-          return FALSE;
623 674
         break;
624 675
       case 'FORMAT':
625 676
         $value   = trim( $value );
@@ -627,8 +678,7 @@  discard block
 block discarded – undo
627 678
           $this->format             = 'xcal';
628 679
           $this->attributeDelimiter = $this->nl;
629 680
           $this->valueInit          = null;
630
-        }
631
-        else {
681
+        } else {
632 682
           $this->format             = null;
633 683
           $this->attributeDelimiter = ';';
634 684
           $this->valueInit          = ':';
@@ -667,13 +717,16 @@  discard block
 block discarded – undo
667 717
         return $this->setConfig( 'filename',  $parts['basename'] );
668 718
         break;
669 719
     }
670
-    if( !$res ) return FALSE;
720
+    if( !$res ) {
721
+        return FALSE;
722
+    }
671 723
     if( isset( $subcfg ) && !empty( $this->components )) {
672 724
       foreach( $subcfg as $cfgkey => $cfgvalue ) {
673 725
         foreach( $this->components as $cix => $component ) {
674 726
           $res = $component->setConfig( $cfgkey, $cfgvalue );
675
-          if( !$res )
676
-            break 2;
727
+          if( !$res ) {
728
+                      break 2;
729
+          }
677 730
           $this->components[$cix] = $component->copy(); // PHP4 compliant
678 731
         }
679 732
       }
@@ -708,27 +761,26 @@  discard block
 block discarded – undo
708 761
     if ( ctype_digit( (string) $arg1 )) {
709 762
       $argType = 'INDEX';
710 763
       $index   = (int) $arg1 - 1;
711
-    }
712
-    elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
764
+    } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
713 765
       $argType = strtolower( $arg1 );
714 766
       $index   = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0;
715 767
     }
716 768
     $cix1dC = 0;
717 769
     foreach ( $this->components as $cix => $component) {
718
-      if( empty( $component )) continue;
770
+      if( empty( $component )) {
771
+          continue;
772
+      }
719 773
       unset( $component->propix );
720 774
       if(( 'INDEX' == $argType ) && ( $index == $cix )) {
721 775
         unset( $this->components[$cix] );
722 776
         return TRUE;
723
-      }
724
-      elseif( $argType == $component->objName ) {
777
+      } elseif( $argType == $component->objName ) {
725 778
         if( $index == $cix1dC ) {
726 779
           unset( $this->components[$cix] );
727 780
           return TRUE;
728 781
         }
729 782
         $cix1dC++;
730
-      }
731
-      elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
783
+      } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
732 784
         unset( $this->components[$cix] );
733 785
         return TRUE;
734 786
       }
@@ -750,37 +802,39 @@  discard block
 block discarded – undo
750 802
       $argType = 'INDEX';
751 803
       $index   = $this->compix['INDEX'] =
752 804
         ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1;
753
-    }
754
-    elseif ( ctype_digit( (string) $arg1 )) {
805
+    } elseif ( ctype_digit( (string) $arg1 )) {
755 806
       $argType = 'INDEX';
756 807
       $index   = (int) $arg1;
757 808
       unset( $this->compix );
758
-    }
759
-    elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
809
+    } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
760 810
       unset( $this->compix['INDEX'] );
761 811
       $argType = strtolower( $arg1 );
762
-      if( !$arg2 )
763
-        $index = $this->compix[$argType] =
812
+      if( !$arg2 ) {
813
+              $index = $this->compix[$argType] =
764 814
         ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1;
765
-      else
766
-        $index = (int) $arg2;
815
+      } else {
816
+              $index = (int) $arg2;
817
+      }
767 818
     }
768 819
     $index  -= 1;
769 820
     $ckeys =  array_keys( $this->components );
770
-    if( !empty( $index) && ( $index > end(  $ckeys )))
771
-      return FALSE;
821
+    if( !empty( $index) && ( $index > end(  $ckeys ))) {
822
+          return FALSE;
823
+    }
772 824
     $cix1gC = 0;
773 825
     foreach ( $this->components as $cix => $component) {
774
-      if( empty( $component )) continue;
826
+      if( empty( $component )) {
827
+          continue;
828
+      }
775 829
       unset( $component->propix );
776
-      if(( 'INDEX' == $argType ) && ( $index == $cix ))
777
-        return $component->copy();
778
-      elseif( $argType == $component->objName ) {
779
-         if( $index == $cix1gC )
780
-           return $component->copy();
830
+      if(( 'INDEX' == $argType ) && ( $index == $cix )) {
831
+              return $component->copy();
832
+      } elseif( $argType == $component->objName ) {
833
+         if( $index == $cix1gC ) {
834
+                    return $component->copy();
835
+         }
781 836
          $cix1gC++;
782
-      }
783
-      elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
837
+      } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
784 838
         unset( $component->propix );
785 839
         return $component->copy();
786 840
       }
@@ -815,46 +869,68 @@  discard block
 block discarded – undo
815 869
  */
816 870
   function selectComponents( $startY=FALSE, $startM=FALSE, $startD=FALSE, $endY=FALSE, $endM=FALSE, $endD=FALSE, $cType=FALSE, $flat=FALSE, $any=TRUE, $split=TRUE ) {
817 871
             /* check  if empty calendar */
818
-    if( 0 >= count( $this->components )) return FALSE;
872
+    if( 0 >= count( $this->components )) {
873
+        return FALSE;
874
+    }
819 875
             /* check default dates */
820
-    if( !$startY ) $startY = date( 'Y' );
821
-    if( !$startM ) $startM = date( 'm' );
822
-    if( !$startD ) $startD = date( 'd' );
876
+    if( !$startY ) {
877
+        $startY = date( 'Y' );
878
+    }
879
+    if( !$startM ) {
880
+        $startM = date( 'm' );
881
+    }
882
+    if( !$startD ) {
883
+        $startD = date( 'd' );
884
+    }
823 885
     $startDate = mktime( 0, 0, 0, $startM, $startD, $startY );
824
-    if( !$endY )   $endY   = $startY;
825
-    if( !$endM )   $endM   = $startM;
826
-    if( !$endD )   $endD   = $startD;
886
+    if( !$endY ) {
887
+        $endY   = $startY;
888
+    }
889
+    if( !$endM ) {
890
+        $endM   = $startM;
891
+    }
892
+    if( !$endD ) {
893
+        $endD   = $startD;
894
+    }
827 895
     $endDate   = mktime( 23, 59, 59, $endM, $endD, $endY );
828 896
             /* check component types */
829 897
     $validTypes = array('vevent', 'vtodo', 'vjournal', 'vfreebusy' );
830 898
     if( is_array( $cType )) {
831 899
       foreach( $cType as $cix => $theType ) {
832 900
         $cType[$cix] = $theType = strtolower( $theType );
833
-        if( !in_array( $theType, $validTypes ))
834
-          $cType[$cix] = 'vevent';
901
+        if( !in_array( $theType, $validTypes )) {
902
+                  $cType[$cix] = 'vevent';
903
+        }
835 904
       }
836 905
       $cType = array_unique( $cType );
837
-    }
838
-    elseif( !empty( $cType )) {
906
+    } elseif( !empty( $cType )) {
839 907
       $cType = strtolower( $cType );
840
-      if( !in_array( $cType, $validTypes ))
841
-        $cType = array( 'vevent' );
842
-      else
843
-        $cType = array( $cType );
844
-    }
845
-    else
846
-      $cType = $validTypes;
847
-    if( 0 >= count( $cType ))
848
-      $cType = $validTypes;
908
+      if( !in_array( $cType, $validTypes )) {
909
+              $cType = array( 'vevent' );
910
+      } else {
911
+              $cType = array( $cType );
912
+      }
913
+    } else {
914
+          $cType = $validTypes;
915
+    }
916
+    if( 0 >= count( $cType )) {
917
+          $cType = $validTypes;
918
+    }
849 919
             /* iterate components */
850 920
     $result = array();
851 921
     foreach ( $this->components as $cix => $component ) {
852
-      if( empty( $component )) continue;
922
+      if( empty( $component )) {
923
+          continue;
924
+      }
853 925
       unset( $component->propix, $start );
854 926
             /* deselect unvalid type components */
855
-      if( !in_array( $component->objName, $cType )) continue;
927
+      if( !in_array( $component->objName, $cType )) {
928
+          continue;
929
+      }
856 930
             /* deselect components without dtstart set */
857
-      if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) continue;
931
+      if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) {
932
+          continue;
933
+      }
858 934
       $dtendExist = $dueExist = $durationExist = $endAllDayEvent = FALSE;
859 935
       unset( $end, $startWdate, $endWdate, $rdurWsecs, $rdur, $exdatelist, $workstart, $workend ); // clean up
860 936
       $startWdate = $component->_date2timestamp( $start );
@@ -888,8 +964,9 @@  discard block
 block discarded – undo
888 964
       }
889 965
       if( empty( $end )) {
890 966
         $end = $component->getProperty( 'duration', FALSE, FALSE, TRUE );// in dtend (array) format
891
-        if( !empty( $end ))
892
-          $durationExist = TRUE;
967
+        if( !empty( $end )) {
968
+                  $durationExist = TRUE;
969
+        }
893 970
    // if( !empty($end))  echo 'selectComp 4 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
894 971
       }
895 972
       if( empty( $end )) { // assume one day duration if missing end date
@@ -907,55 +984,75 @@  discard block
 block discarded – undo
907 984
       $exdatelist = array();
908 985
       $workstart  = $component->_timestamp2date(( $startDate - $rdurWsecs ), 6);
909 986
       $workend    = $component->_timestamp2date(( $endDate + $rdurWsecs ), 6);
910
-      while( FALSE !== ( $exrule = $component->getProperty( 'exrule' )))    // check exrule
987
+      while( FALSE !== ( $exrule = $component->getProperty( 'exrule' ))) {
988
+          // check exrule
911 989
         $component->_recur2date( $exdatelist, $exrule, $start, $workstart, $workend );
990
+      }
912 991
       while( FALSE !== ( $exdate = $component->getProperty( 'exdate' ))) {  // check exdate
913 992
         foreach( $exdate as $theExdate ) {
914 993
           $exWdate = $component->_date2timestamp( $theExdate );
915
-          if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate ))
916
-            $exdatelist[$exWdate] = TRUE;
994
+          if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate )) {
995
+                      $exdatelist[$exWdate] = TRUE;
996
+          }
917 997
         }
918 998
       }
919 999
             /* if 'any' components, check repeating components, removing all excluding dates */
920 1000
       if( TRUE === $any ) {
921 1001
             /* make a list of optional repeating dates for component occurence, rrule, rdate */
922 1002
         $recurlist = array();
923
-        while( FALSE !== ( $rrule = $component->getProperty( 'rrule' )))    // check rrule
1003
+        while( FALSE !== ( $rrule = $component->getProperty( 'rrule' ))) {
1004
+            // check rrule
924 1005
           $component->_recur2date( $recurlist, $rrule, $start, $workstart, $workend );
925
-        foreach( $recurlist as $recurkey => $recurvalue ) // key=match date as timestamp
926
-          $recurlist[$recurkey] = $rdurWsecs; // add duration in seconds
1006
+        }
1007
+        foreach( $recurlist as $recurkey => $recurvalue ) {
1008
+            // key=match date as timestamp
1009
+          $recurlist[$recurkey] = $rdurWsecs;
1010
+        }
1011
+        // add duration in seconds
927 1012
         while( FALSE !== ( $rdate = $component->getProperty( 'rdate' ))) {  // check rdate
928 1013
           foreach( $rdate as $theRdate ) {
929 1014
             if( is_array( $theRdate ) && ( 2 == count( $theRdate )) &&  // all days within PERIOD
930 1015
                    array_key_exists( '0', $theRdate ) &&  array_key_exists( '1', $theRdate )) {
931 1016
               $rstart = $component->_date2timestamp( $theRdate[0] );
932
-              if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate ))
933
-                continue;
934
-              if( isset( $theRdate[1]['year'] )) // date-date period
1017
+              if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate )) {
1018
+                              continue;
1019
+              }
1020
+              if( isset( $theRdate[1]['year'] )) {
1021
+                  // date-date period
935 1022
                 $rend = $component->_date2timestamp( $theRdate[1] );
936
-              else {                             // date-duration period
1023
+              } else {                             // date-duration period
937 1024
                 $rend = $component->duration2date( $theRdate[0], $theRdate[1] );
938 1025
                 $rend = $component->_date2timestamp( $rend );
939 1026
               }
940
-              if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart ))
941
-                $recurlist[$rstart] = ( $rstart - $rend ); // set start date + rdate duration in seconds
1027
+              if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart )) {
1028
+                              $recurlist[$rstart] = ( $rstart - $rend );
1029
+              }
1030
+              // set start date + rdate duration in seconds
942 1031
             } // PERIOD end
943 1032
             else { // single date
944 1033
               $theRdate = $component->_date2timestamp( $theRdate );
945
-              if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate ))
946
-                $recurlist[$theRdate] = $rdurWsecs; // set start date + event duration in seconds
1034
+              if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate )) {
1035
+                              $recurlist[$theRdate] = $rdurWsecs;
1036
+              }
1037
+              // set start date + event duration in seconds
947 1038
             }
948 1039
           }
949 1040
         }
950 1041
         if( 0 < count( $recurlist )) {
951 1042
           ksort( $recurlist );
952 1043
           foreach( $recurlist as $recurkey => $durvalue ) {
953
-            if((( $startDate - $rdurWsecs ) > $recurkey ) || ( $endDate < $recurkey )) // not within period
1044
+            if((( $startDate - $rdurWsecs ) > $recurkey ) || ( $endDate < $recurkey )) {
1045
+                // not within period
954 1046
               continue;
955
-            if( isset( $exdatelist[$recurkey] )) // check excluded dates
1047
+            }
1048
+            if( isset( $exdatelist[$recurkey] )) {
1049
+                // check excluded dates
956 1050
               continue;
957
-            if( $startWdate >= $recurkey ) // exclude component start date
1051
+            }
1052
+            if( $startWdate >= $recurkey ) {
1053
+                // exclude component start date
958 1054
               continue;
1055
+            }
959 1056
             $component2   = $component->copy();
960 1057
             $rstart       = $component2->_timestamp2date( $recurkey, 6);
961 1058
             $datevalue    = $rstart['month'].'/'.$rstart['day'].'/'.$rstart['year'];
@@ -965,16 +1062,16 @@  discard block
 block discarded – undo
965 1062
               $datevalue .= ( isset( $rstart['sec'] ))  ? ':'.$rstart['sec']  : ':00';
966 1063
             }
967 1064
             $datestring = date( $startDateFormat, strtotime( $datevalue ));
968
-            if( isset( $start['tz'] ))
969
-              $datestring .= ' '.$start['tz'];
1065
+            if( isset( $start['tz'] )) {
1066
+                          $datestring .= ' '.$start['tz'];
1067
+            }
970 1068
             $component2->setProperty( 'X-CURRENT-DTSTART', $datestring );
971 1069
             $rend   = $component2->_timestamp2date(( $recurkey + $durvalue ), 6);
972 1070
             if( $dtendExist || $dueExist ) {
973 1071
               if( $endAllDayEvent ) {
974 1072
                 $rend2 = mktime( 0, 0, 0, $rend['month'], ($rend['day'] + 1), $rend['year'] );
975 1073
                 $datevalue  = date( 'm', $rend2 ).'/'.date( 'd', $rend2 ).'/'.date( 'Y', $rend2 );
976
-              }
977
-              else {
1074
+              } else {
978 1075
                 $datevalue  = $rend['month'].'/'.$rend['day'].'/'.$rend['year'];
979 1076
                 if( isset( $end['hour'] ) || isset( $end['min'] ) || isset( $end['sec'] )) {
980 1077
                   $datevalue .= ( isset( $rend['hour'] )) ? ' '.$rend['hour'] : ' 00';
@@ -983,30 +1080,37 @@  discard block
 block discarded – undo
983 1080
                 }
984 1081
               }
985 1082
               $datestring = date( $endDateFormat, strtotime( $datevalue ));
986
-              if( isset( $end['tz'] ))
987
-                $datestring .= ' '.$end['tz'];
988
-              if( $dtendExist )
989
-                $component2->setProperty( 'X-CURRENT-DTEND', $datestring );
990
-              elseif( $dueExist )
991
-                $component2->setProperty( 'X-CURRENT-DUE', $datestring );
1083
+              if( isset( $end['tz'] )) {
1084
+                              $datestring .= ' '.$end['tz'];
1085
+              }
1086
+              if( $dtendExist ) {
1087
+                              $component2->setProperty( 'X-CURRENT-DTEND', $datestring );
1088
+              } elseif( $dueExist ) {
1089
+                              $component2->setProperty( 'X-CURRENT-DUE', $datestring );
1090
+              }
992 1091
             }
993 1092
             $rend   = $component2->_date2timestamp( $rend );
994 1093
             $rstart = $recurkey;
995 1094
             /* add repeating components within valid dates to output array, only start date */
996
-            if( $flat )
997
-              $result[] = $component2->copy(); // copy to output
1095
+            if( $flat ) {
1096
+                          $result[] = $component2->copy();
1097
+            }
1098
+            // copy to output
998 1099
             elseif( $split ) {
999
-              if( $rend > $endDate )
1000
-                $rend = $endDate;
1100
+              if( $rend > $endDate ) {
1101
+                              $rend = $endDate;
1102
+              }
1001 1103
               while( $rstart <= $rend ) { // iterate
1002 1104
                 $wd = getdate( $rstart );
1003 1105
                 if(( $rstart > $startDate ) &&      // date after dtstart
1004
-                    !isset( $exdatelist[$rstart] )) // check exclude date
1005
-                  $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output
1106
+                    !isset( $exdatelist[$rstart] )) {
1107
+                    // check exclude date
1108
+                  $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy();
1109
+                }
1110
+                // copy to output
1006 1111
                 $rstart += ( 24*60*60 ); // step one day
1007 1112
               }
1008
-            }
1009
-            elseif(( $rstart >= $startDate ) &&     // date within period
1113
+            } elseif(( $rstart >= $startDate ) &&     // date within period
1010 1114
                   !isset( $exdatelist[$rstart] )) { // check exclude date
1011 1115
               $wd = getdate( $rstart );
1012 1116
               $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output
@@ -1014,19 +1118,29 @@  discard block
 block discarded – undo
1014 1118
           }
1015 1119
         }
1016 1120
             /* deselect components with startdate/enddate not within period */
1017
-        if(( $endWdate < $startDate ) || ( $startWdate > $endDate )) continue;
1121
+        if(( $endWdate < $startDate ) || ( $startWdate > $endDate )) {
1122
+            continue;
1123
+        }
1018 1124
       }
1019 1125
             /* deselect components with startdate not within period */
1020
-      elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) continue;
1126
+      elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) {
1127
+          continue;
1128
+      }
1021 1129
             /* add selected components within valid dates to output array */
1022
-      if( $flat )
1023
-        $result[] = $component->copy(); // copy to output;
1130
+      if( $flat ) {
1131
+              $result[] = $component->copy();
1132
+      }
1133
+      // copy to output;
1024 1134
       elseif( $split ) {
1025
-        if( $endWdate > $endDate )
1026
-          $endWdate = $endDate;     // use period end date
1135
+        if( $endWdate > $endDate ) {
1136
+                  $endWdate = $endDate;
1137
+        }
1138
+        // use period end date
1027 1139
         if( !isset( $exdatelist[$startWdate] ))  { // check excluded dates
1028
-          if( $startWdate < $startDate )
1029
-            $startWdate = $startDate; // use period start date
1140
+          if( $startWdate < $startDate ) {
1141
+                      $startWdate = $startDate;
1142
+          }
1143
+          // use period start date
1030 1144
           while( $startWdate <= $endWdate ) { // iterate
1031 1145
             $wd = getdate( $startWdate );
1032 1146
             $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output
@@ -1040,8 +1154,9 @@  discard block
 block discarded – undo
1040 1154
         $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output
1041 1155
       }
1042 1156
     }
1043
-    if( 0 >= count( $result )) return FALSE;
1044
-    elseif( !$flat ) {
1157
+    if( 0 >= count( $result )) {
1158
+        return FALSE;
1159
+    } elseif( !$flat ) {
1045 1160
       foreach( $result as $y => $yeararr ) {
1046 1161
         foreach( $yeararr as $m => $montharr ) {
1047 1162
           ksort( $result[$y][$m] );
@@ -1063,8 +1178,9 @@  discard block
 block discarded – undo
1063 1178
  * @return void
1064 1179
  */
1065 1180
   function setComponent( $component, $arg1=FALSE, $arg2=FALSE  ) {
1066
-    if( '' >= $component->getConfig( 'language'))
1067
-      $component->setConfig( 'language',  $this->getConfig( 'language' ));
1181
+    if( '' >= $component->getConfig( 'language')) {
1182
+          $component->setConfig( 'language',  $this->getConfig( 'language' ));
1183
+    }
1068 1184
     $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
1069 1185
     $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
1070 1186
     $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
@@ -1083,27 +1199,26 @@  discard block
 block discarded – undo
1083 1199
     if ( ctype_digit( (string) $arg1 )) {
1084 1200
       $argType = 'INDEX';
1085 1201
       $index   = (int) $arg1 - 1;
1086
-    }
1087
-    elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
1202
+    } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
1088 1203
       $argType = strtolower( $arg1 );
1089 1204
       $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0;
1090 1205
     }
1091 1206
     $cix1sC = 0;
1092 1207
     foreach ( $this->components as $cix => $component2) {
1093
-      if( empty( $component2 )) continue;
1208
+      if( empty( $component2 )) {
1209
+          continue;
1210
+      }
1094 1211
       unset( $component2->propix );
1095 1212
       if(( 'INDEX' == $argType ) && ( $index == $cix )) {
1096 1213
         $this->components[$cix] = $component->copy();
1097 1214
         return TRUE;
1098
-      }
1099
-      elseif( $argType == $component2->objName ) {
1215
+      } elseif( $argType == $component2->objName ) {
1100 1216
         if( $index == $cix1sC ) {
1101 1217
           $this->components[$cix] = $component->copy();
1102 1218
           return TRUE;
1103 1219
         }
1104 1220
         $cix1sC++;
1105
-      }
1106
-      elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) {
1221
+      } elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) {
1107 1222
         $this->components[$cix] = $component->copy();
1108 1223
         return TRUE;
1109 1224
       }
@@ -1130,73 +1245,124 @@  discard block
 block discarded – undo
1130 1245
     }
1131 1246
   }
1132 1247
   function _cmpfcn( $a, $b ) {
1133
-    if( empty( $a ))                                   return -1;
1134
-    if( empty( $b ))                                   return  1;
1135
-    if(  'vtimezone' == $a->objName)                   return -1;
1136
-    if(  'vtimezone' == $b->objName)                   return  1;
1248
+    if( empty( $a )) {
1249
+        return -1;
1250
+    }
1251
+    if( empty( $b )) {
1252
+        return  1;
1253
+    }
1254
+    if(  'vtimezone' == $a->objName) {
1255
+        return -1;
1256
+    }
1257
+    if(  'vtimezone' == $b->objName) {
1258
+        return  1;
1259
+    }
1137 1260
     $astart = ( isset( $a->xprop['X-CURRENT-DTSTART']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTSTART']['value'] ) : null;
1138
-    if( empty( $astart ) && isset( $a->dtstart['value'] ))
1139
-      $astart = & $a->dtstart['value'];
1261
+    if( empty( $astart ) && isset( $a->dtstart['value'] )) {
1262
+          $astart = & $a->dtstart['value'];
1263
+    }
1140 1264
     $bstart = ( isset( $b->xprop['X-CURRENT-DTSTART']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTSTART']['value'] ) : null;
1141
-    if( empty( $bstart ) && isset( $b->dtstart['value'] ))
1142
-      $bstart = & $b->dtstart['value'];
1143
-    if(     empty( $astart ))                          return -1;
1144
-    elseif( empty( $bstart ))                          return  1;
1265
+    if( empty( $bstart ) && isset( $b->dtstart['value'] )) {
1266
+          $bstart = & $b->dtstart['value'];
1267
+    }
1268
+    if(     empty( $astart )) {
1269
+        return -1;
1270
+    } elseif( empty( $bstart )) {
1271
+        return  1;
1272
+    }
1145 1273
     foreach( $this->_sortkeys as $key ) {
1146
-      if    ( empty( $astart[$key] ))                  return -1;
1147
-      elseif( empty( $bstart[$key] ))                  return  1;
1148
-      if    (        $astart[$key] == $bstart[$key])   continue;
1149
-      if    (( (int) $astart[$key] ) < ((int) $bstart[$key] ))
1150
-                                                       return -1;
1151
-      elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] ))
1152
-                                                       return  1;
1274
+      if    ( empty( $astart[$key] )) {
1275
+          return -1;
1276
+      } elseif( empty( $bstart[$key] )) {
1277
+          return  1;
1278
+      }
1279
+      if    (        $astart[$key] == $bstart[$key]) {
1280
+          continue;
1281
+      }
1282
+      if    (( (int) $astart[$key] ) < ((int) $bstart[$key] )) {
1283
+                                                             return -1;
1284
+      } elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] )) {
1285
+                                                             return  1;
1286
+      }
1153 1287
     }
1154 1288
     $c   = ( isset( $a->xprop['X-CURRENT-DTEND']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTEND']['value'] ) : null;
1155
-    if(     empty( $c ) && !empty( $a->dtend['value'] ))
1156
-      $c = & $a->dtend['value'];
1157
-    if(     empty( $c ) && isset( $a->xprop['X-CURRENT-DUE']['value'] ))
1158
-      $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] );
1159
-    if(     empty( $c ) && !empty( $a->due['value'] ))
1160
-      $c = & $a->due['value'];
1161
-    if(     empty( $c ) && !empty( $a->duration['value'] ))
1162
-      $c = $a->duration2date();
1289
+    if(     empty( $c ) && !empty( $a->dtend['value'] )) {
1290
+          $c = & $a->dtend['value'];
1291
+    }
1292
+    if(     empty( $c ) && isset( $a->xprop['X-CURRENT-DUE']['value'] )) {
1293
+          $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] );
1294
+    }
1295
+    if(     empty( $c ) && !empty( $a->due['value'] )) {
1296
+          $c = & $a->due['value'];
1297
+    }
1298
+    if(     empty( $c ) && !empty( $a->duration['value'] )) {
1299
+          $c = $a->duration2date();
1300
+    }
1163 1301
     $d   = ( isset( $b->xprop['X-CURRENT-DTEND']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTEND']['value'] ) : null;
1164
-    if(     empty( $d ) && !empty( $b->dtend['value'] ))
1165
-      $d = & $b->dtend['value'];
1166
-    if(     empty( $d ) && isset( $b->xprop['X-CURRENT-DUE']['value'] ))
1167
-      $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] );
1168
-    if(     empty( $d ) && !empty( $b->due['value'] ))
1169
-      $d = & $b->due['value'];
1170
-    if(     empty( $d ) && !empty( $b->duration['value'] ))
1171
-      $d = $b->duration2date();
1172
-    if(     empty( $c ))                               return -1;
1173
-    elseif( empty( $d ))                               return  1;
1302
+    if(     empty( $d ) && !empty( $b->dtend['value'] )) {
1303
+          $d = & $b->dtend['value'];
1304
+    }
1305
+    if(     empty( $d ) && isset( $b->xprop['X-CURRENT-DUE']['value'] )) {
1306
+          $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] );
1307
+    }
1308
+    if(     empty( $d ) && !empty( $b->due['value'] )) {
1309
+          $d = & $b->due['value'];
1310
+    }
1311
+    if(     empty( $d ) && !empty( $b->duration['value'] )) {
1312
+          $d = $b->duration2date();
1313
+    }
1314
+    if(     empty( $c )) {
1315
+        return -1;
1316
+    } elseif( empty( $d )) {
1317
+        return  1;
1318
+    }
1174 1319
     foreach( $this->_sortkeys as $key ) {
1175
-      if    ( !isset( $c[$key] ))                      return -1;
1176
-      elseif( !isset( $d[$key] ))                      return  1;
1177
-      if    (         $c[$key] == $d[$key] )           continue;
1178
-      if    ((  (int) $c[$key] ) < ((int) $d[$key]))   return -1;
1179
-      elseif((  (int) $c[$key] ) > ((int) $d[$key]))   return  1;
1180
-    }
1181
-    if( isset( $a->created['value'] ))
1182
-     $e = & $a->created['value'];
1183
-    else
1184
-     $e = & $a->dtstamp['value'];
1185
-    if( isset( $b->created['value'] ))
1186
-      $f = & $b->created['value'];
1187
-    else
1188
-      $f = & $b->dtstamp['value'];
1320
+      if    ( !isset( $c[$key] )) {
1321
+          return -1;
1322
+      } elseif( !isset( $d[$key] )) {
1323
+          return  1;
1324
+      }
1325
+      if    (         $c[$key] == $d[$key] ) {
1326
+          continue;
1327
+      }
1328
+      if    ((  (int) $c[$key] ) < ((int) $d[$key])) {
1329
+          return -1;
1330
+      } elseif((  (int) $c[$key] ) > ((int) $d[$key])) {
1331
+          return  1;
1332
+      }
1333
+    }
1334
+    if( isset( $a->created['value'] )) {
1335
+         $e = & $a->created['value'];
1336
+    } else {
1337
+         $e = & $a->dtstamp['value'];
1338
+    }
1339
+    if( isset( $b->created['value'] )) {
1340
+          $f = & $b->created['value'];
1341
+    } else {
1342
+          $f = & $b->dtstamp['value'];
1343
+    }
1189 1344
     foreach( $this->_sortkeys as $key ) {
1190
-      if(       !isset( $e[$key] ))                    return -1;
1191
-      elseif(   !isset( $f[$key] ))                    return  1;
1192
-      if    (           $e[$key] == $f[$key] )         continue;
1193
-      if    ((    (int) $e[$key] ) < ((int) $f[$key])) return -1;
1194
-      elseif((    (int) $e[$key] ) > ((int) $f[$key])) return  1;
1345
+      if(       !isset( $e[$key] )) {
1346
+          return -1;
1347
+      } elseif(   !isset( $f[$key] )) {
1348
+          return  1;
1349
+      }
1350
+      if    (           $e[$key] == $f[$key] ) {
1351
+          continue;
1352
+      }
1353
+      if    ((    (int) $e[$key] ) < ((int) $f[$key])) {
1354
+          return -1;
1355
+      } elseif((    (int) $e[$key] ) > ((int) $f[$key])) {
1356
+          return  1;
1357
+      }
1195 1358
     }
1196 1359
     if    ((            $a->uid['value'] ) <
1197
-           (            $b->uid['value'] ))            return -1;
1198
-    elseif((            $a->uid['value'] ) >
1199
-           (            $b->uid['value'] ))            return  1;
1360
+           (            $b->uid['value'] )) {
1361
+        return -1;
1362
+    } elseif((            $a->uid['value'] ) >
1363
+           (            $b->uid['value'] )) {
1364
+        return  1;
1365
+    }
1200 1366
     return 0;
1201 1367
   }
1202 1368
 /**
@@ -1211,42 +1377,57 @@  discard block
 block discarded – undo
1211 1377
   function parse( $filename=FALSE ) {
1212 1378
     if( !$filename ) {
1213 1379
             /* directory/filename previous set via setConfig directory+filename / url */
1214
-      if( FALSE === ( $filename = $this->getConfig( 'url' )))
1215
-        $filename = $this->getConfig( 'dirfile' );
1216
-    }
1217
-    elseif(( 'http://'   == strtolower( substr( $filename, 0, 7 ))) ||
1380
+      if( FALSE === ( $filename = $this->getConfig( 'url' ))) {
1381
+              $filename = $this->getConfig( 'dirfile' );
1382
+      }
1383
+    } elseif(( 'http://'   == strtolower( substr( $filename, 0, 7 ))) ||
1218 1384
            ( 'webcal://' == strtolower( substr( $filename, 0, 9 ))))  {
1219 1385
             /* remote file - URL */
1220 1386
       $this->setConfig( 'URL', $filename );
1221
-      if( !$filename = $this->getConfig( 'url' ))
1222
-        return FALSE;                 /* err 2 */
1223
-    }
1224
-    else {
1387
+      if( !$filename = $this->getConfig( 'url' )) {
1388
+              return FALSE;
1389
+      }
1390
+      /* err 2 */
1391
+    } else {
1225 1392
             /* local directory/filename */
1226 1393
       $parts = pathinfo( $filename );
1227 1394
       if( !empty( $parts['dirname'] ) && ( '.' != $parts['dirname'] )) {
1228
-        if( !$this->setConfig( 'directory', $parts['dirname'] ))
1229
-          return FALSE;               /* err 3 */
1395
+        if( !$this->setConfig( 'directory', $parts['dirname'] )) {
1396
+                  return FALSE;
1397
+        }
1398
+        /* err 3 */
1399
+      }
1400
+      if( !$this->setConfig( 'filename', $parts['basename'] )) {
1401
+              return FALSE;
1230 1402
       }
1231
-      if( !$this->setConfig( 'filename', $parts['basename'] ))
1232
-        return FALSE;                 /* err 4 */
1403
+      /* err 4 */
1233 1404
     }
1234 1405
     if( 'http://' != substr( $filename, 0, 7 )) {
1235 1406
             /* local file error tests */
1236
-      if( !is_file( $filename ))      /* err 5 */
1407
+      if( !is_file( $filename )) {
1408
+          /* err 5 */
1237 1409
         return FALSE;
1238
-      if( !is_readable( $filename ))
1239
-        return FALSE;                 /* err 6 */
1240
-      if( !filesize( $filename ))
1241
-        return FALSE;                 /* err 7 */
1410
+      }
1411
+      if( !is_readable( $filename )) {
1412
+              return FALSE;
1413
+      }
1414
+      /* err 6 */
1415
+      if( !filesize( $filename )) {
1416
+              return FALSE;
1417
+      }
1418
+      /* err 7 */
1242 1419
       clearstatcache();
1243 1420
     }
1244 1421
             /* READ FILE */
1245
-    if( FALSE === ( $rows = file( $filename )))
1246
-      return FALSE;                   /* err 1 */
1422
+    if( FALSE === ( $rows = file( $filename ))) {
1423
+          return FALSE;
1424
+    }
1425
+    /* err 1 */
1247 1426
             /* identify BEGIN:VCALENDAR, MUST be first row */
1248
-    if( 'BEGIN:VCALENDAR' != strtoupper( trim( $rows[0] )))
1249
-      return FALSE;                   /* err 8 */
1427
+    if( 'BEGIN:VCALENDAR' != strtoupper( trim( $rows[0] ))) {
1428
+          return FALSE;
1429
+    }
1430
+    /* err 8 */
1250 1431
             /* remove empty trailing lines */
1251 1432
     while( '' == trim( $rows[count( $rows ) - 1] )) {
1252 1433
       unset( $rows[count( $rows ) - 1] );
@@ -1256,34 +1437,37 @@  discard block
 block discarded – undo
1256 1437
     if( 'END:VCALENDAR'   != strtoupper( trim( $rows[count( $rows ) - 1] ))) {
1257 1438
       return FALSE;                   /* err 9 */
1258 1439
     }
1259
-    if( 3 > count( $rows ))
1260
-      return FALSE;                   /* err 10 */
1440
+    if( 3 > count( $rows )) {
1441
+          return FALSE;
1442
+    }
1443
+    /* err 10 */
1261 1444
     $comp    = $subcomp = null;
1262 1445
     $actcomp = & $this;
1263 1446
     $nl      = $this->getConfig( 'nl' );
1264 1447
     $calsync = 0;
1265 1448
             /* identify components and update unparsed data within component */
1266 1449
     foreach( $rows as $line ) {
1267
-      if( '' == trim( $line ))
1268
-        continue;
1269
-      if( $nl == substr( $line, 0 - strlen( $nl )))
1270
-        $line = substr( $line, 0, ( strlen( $line ) - strlen( $nl ))).'\n';
1450
+      if( '' == trim( $line )) {
1451
+              continue;
1452
+      }
1453
+      if( $nl == substr( $line, 0 - strlen( $nl ))) {
1454
+              $line = substr( $line, 0, ( strlen( $line ) - strlen( $nl ))).'\n';
1455
+      }
1271 1456
       if( 'BEGIN:VCALENDAR' == strtoupper( substr( $line, 0, 15 ))) {
1272 1457
         $calsync++;
1273 1458
         continue;
1274
-      }
1275
-      elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) {
1459
+      } elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) {
1276 1460
         $calsync--;
1277 1461
         continue;
1462
+      } elseif( 1 != $calsync ) {
1463
+              return FALSE;
1278 1464
       }
1279
-      elseif( 1 != $calsync )
1280
-        return FALSE;                 /* err 20 */
1465
+      /* err 20 */
1281 1466
       if( 'END:' == strtoupper( substr( $line, 0, 4 ))) {
1282 1467
         if( null != $subcomp ) {
1283 1468
           $comp->setComponent( $subcomp );
1284 1469
           $subcomp = null;
1285
-        }
1286
-        else {
1470
+        } else {
1287 1471
           $this->setComponent( $comp );
1288 1472
           $comp = null;
1289 1473
         }
@@ -1294,17 +1478,18 @@  discard block
 block discarded – undo
1294 1478
         $line = str_replace( '\n', '', $line );
1295 1479
         $compname = trim (strtoupper( substr( $line, 6 )));
1296 1480
         if( null != $comp ) {
1297
-          if( 'VALARM' == $compname )
1298
-            $subcomp = new valarm();
1299
-          elseif( 'STANDARD' == $compname )
1300
-            $subcomp = new vtimezone( 'STANDARD' );
1301
-          elseif( 'DAYLIGHT' == $compname )
1302
-            $subcomp = new vtimezone( 'DAYLIGHT' );
1303
-          else
1304
-            return FALSE; /* err 6 */
1481
+          if( 'VALARM' == $compname ) {
1482
+                      $subcomp = new valarm();
1483
+          } elseif( 'STANDARD' == $compname ) {
1484
+                      $subcomp = new vtimezone( 'STANDARD' );
1485
+          } elseif( 'DAYLIGHT' == $compname ) {
1486
+                      $subcomp = new vtimezone( 'DAYLIGHT' );
1487
+          } else {
1488
+                      return FALSE;
1489
+          }
1490
+          /* err 6 */
1305 1491
           $actcomp = & $subcomp;
1306
-        }
1307
-        else {
1492
+        } else {
1308 1493
           switch( $compname ) {
1309 1494
             case 'VALARM':
1310 1495
               $comp = new valarm();
@@ -1353,8 +1538,7 @@  discard block
 block discarded – undo
1353 1538
           $newProp = FALSE;
1354 1539
           $lastix++;
1355 1540
           $proprows[$lastix]  = $line;
1356
-        }
1357
-        else {
1541
+        } else {
1358 1542
             /* remove line breaks */
1359 1543
           if(( '\n' == substr( $proprows[$lastix], -2 )) &&
1360 1544
              (  ' ' == substr( $line, 0, 1 ))) {
@@ -1366,19 +1550,22 @@  discard block
 block discarded – undo
1366 1550
       }
1367 1551
       $toolbox = new calendarComponent();
1368 1552
       foreach( $proprows as $line ) {
1369
-        if( '\n' == substr( $line, -2 ))
1370
-          $line = substr( $line, 0, strlen( $line ) - 2 );
1553
+        if( '\n' == substr( $line, -2 )) {
1554
+                  $line = substr( $line, 0, strlen( $line ) - 2 );
1555
+        }
1371 1556
             /* get propname */
1372 1557
         $cix = $propname = null;
1373 1558
         for( $cix=0; $cix < strlen( $line ); $cix++ ) {
1374
-          if( in_array( $line{$cix}, array( ':', ';' )))
1375
-            break;
1376
-          else
1377
-            $propname .= $line{$cix};
1559
+          if( in_array( $line{$cix}, array( ':', ';' ))) {
1560
+                      break;
1561
+          } else {
1562
+                      $propname .= $line{$cix};
1563
+          }
1378 1564
         }
1379 1565
             /* ignore version/prodid properties */
1380
-        if( in_array( strtoupper( $propname ), array( 'VERSION', 'PRODID' )))
1381
-          continue;
1566
+        if( in_array( strtoupper( $propname ), array( 'VERSION', 'PRODID' ))) {
1567
+                  continue;
1568
+        }
1382 1569
         $line = substr( $line, $cix);
1383 1570
             /* separate attributes from value */
1384 1571
         $attr   = array();
@@ -1403,20 +1590,22 @@  discard block
 block discarded – undo
1403 1590
               break;
1404 1591
             }
1405 1592
           }
1406
-          if( ';' == $line{$cix} )
1407
-            $attr[++$attrix] = null;
1408
-          else
1409
-            $attr[$attrix] .= $line{$cix};
1593
+          if( ';' == $line{$cix} ) {
1594
+                      $attr[++$attrix] = null;
1595
+          } else {
1596
+                      $attr[$attrix] .= $line{$cix};
1597
+          }
1410 1598
         }
1411 1599
 
1412 1600
             /* make attributes in array format */
1413 1601
         $propattr = array();
1414 1602
         foreach( $attr as $attribute ) {
1415 1603
           $attrsplit = explode( '=', $attribute, 2 );
1416
-          if( 1 < count( $attrsplit ))
1417
-            $propattr[$attrsplit[0]] = $attrsplit[1];
1418
-          else
1419
-            $propattr[] = $attribute;
1604
+          if( 1 < count( $attrsplit )) {
1605
+                      $propattr[$attrsplit[0]] = $attrsplit[1];
1606
+          } else {
1607
+                      $propattr[] = $attribute;
1608
+          }
1420 1609
         }
1421 1610
             /* update Property */
1422 1611
         if( FALSE !== strpos( $line, ',' )) {
@@ -1430,13 +1619,14 @@  discard block
 block discarded – undo
1430 1619
             }
1431 1620
           }
1432 1621
           if( 1 < count( $content )) {
1433
-            foreach( $content as $cix => $contentPart )
1434
-              $content[$cix] = $toolbox->_strunrep( $contentPart );
1622
+            foreach( $content as $cix => $contentPart ) {
1623
+                          $content[$cix] = $toolbox->_strunrep( $contentPart );
1624
+            }
1435 1625
             $this->setProperty( $propname, $content, $propattr );
1436 1626
             continue;
1627
+          } else {
1628
+                      $line = reset( $content );
1437 1629
           }
1438
-          else
1439
-            $line = reset( $content );
1440 1630
           $line = $toolbox->_strunrep( $line );
1441 1631
         }
1442 1632
         $this->setProperty( $propname, trim( $line ), $propattr );
@@ -1445,12 +1635,14 @@  discard block
 block discarded – undo
1445 1635
             /* parse Components */
1446 1636
     if( is_array( $this->components ) && ( 0 < count( $this->components ))) {
1447 1637
       for( $six = 0; $six < count( $this->components ); $six++ ) {
1448
-        if( !empty( $this->components[$six] ))
1449
-          $this->components[$six]->parse();
1638
+        if( !empty( $this->components[$six] )) {
1639
+                  $this->components[$six]->parse();
1640
+        }
1450 1641
       }
1642
+    } else {
1643
+          return FALSE;
1451 1644
     }
1452
-    else
1453
-      return FALSE;                   /* err 91 or something.. . */
1645
+    /* err 91 or something.. . */
1454 1646
     return TRUE;
1455 1647
   }
1456 1648
 /*********************************************************************************/
@@ -1482,8 +1674,9 @@  discard block
 block discarded – undo
1482 1674
     switch( $this->format ) {
1483 1675
       case 'xcal':
1484 1676
         $nlstrlen = strlen( $this->nl );
1485
-        if( $this->nl == substr( $calendarStart, ( 0 - $nlstrlen )))
1486
-          $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen ));
1677
+        if( $this->nl == substr( $calendarStart, ( 0 - $nlstrlen ))) {
1678
+                  $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen ));
1679
+        }
1487 1680
         $calendarStart .= '>'.$this->nl;
1488 1681
         break;
1489 1682
       default:
@@ -1491,9 +1684,12 @@  discard block
 block discarded – undo
1491 1684
     }
1492 1685
     $calendar .= $this->createXprop();
1493 1686
     foreach( $this->components as $component ) {
1494
-      if( empty( $component )) continue;
1495
-      if( '' >= $component->getConfig( 'language'))
1496
-        $component->setConfig( 'language',  $this->getConfig( 'language' ));
1687
+      if( empty( $component )) {
1688
+          continue;
1689
+      }
1690
+      if( '' >= $component->getConfig( 'language')) {
1691
+              $component->setConfig( 'language',  $this->getConfig( 'language' ));
1692
+      }
1497 1693
       $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
1498 1694
       $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
1499 1695
       $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
@@ -1506,8 +1702,10 @@  discard block
 block discarded – undo
1506 1702
       foreach( $this->xcaldecl as $declix => $declPart ) {
1507 1703
         if(( 0 < count( $old_xcaldecl)) &&
1508 1704
            ( in_array( $declPart['uri'],      $old_xcaldecl['uri'] )) &&
1509
-           ( in_array( $declPart['external'], $old_xcaldecl['external'] )))
1510
-          continue; // no duplicate uri and ext. references
1705
+           ( in_array( $declPart['external'], $old_xcaldecl['external'] ))) {
1706
+                  continue;
1707
+        }
1708
+        // no duplicate uri and ext. references
1511 1709
         $calendarxCaldecl .= '<!';
1512 1710
         foreach( $declPart as $declKey => $declValue ) {
1513 1711
           switch( $declKey ) {                    // index
@@ -1560,10 +1758,11 @@  discard block
 block discarded – undo
1560 1758
     $filesize = strlen( $output );
1561 1759
 //    if( headers_sent( $filename, $linenum ))
1562 1760
 //      die( "Headers already sent in $filename on line $linenum\n" );
1563
-    if( 'xcal' == $this->format )
1564
-      header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1565
-    else
1566
-      header( 'Content-Type: text/calendar; charset=utf-8' );
1761
+    if( 'xcal' == $this->format ) {
1762
+          header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1763
+    } else {
1764
+          header( 'Content-Type: text/calendar; charset=utf-8' );
1765
+    }
1567 1766
     header( 'Content-Length: '.$filesize );
1568 1767
     header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
1569 1768
     header( 'Cache-Control: max-age=10' );
@@ -1581,23 +1780,28 @@  discard block
 block discarded – undo
1581 1780
  * @return bool
1582 1781
  */
1583 1782
   function saveCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE ) {
1584
-    if( $directory )
1585
-      $this->setConfig( 'directory', $directory );
1586
-    if( $filename )
1587
-      $this->setConfig( 'filename',  $filename );
1588
-    if( $delimiter && ($delimiter != DIRECTORY_SEPARATOR ))
1589
-      $this->setConfig( 'delimiter', $delimiter );
1590
-    if( FALSE === ( $dirfile = $this->getConfig( 'url' )))
1591
-      $dirfile = $this->getConfig( 'dirfile' );
1783
+    if( $directory ) {
1784
+          $this->setConfig( 'directory', $directory );
1785
+    }
1786
+    if( $filename ) {
1787
+          $this->setConfig( 'filename',  $filename );
1788
+    }
1789
+    if( $delimiter && ($delimiter != DIRECTORY_SEPARATOR )) {
1790
+          $this->setConfig( 'delimiter', $delimiter );
1791
+    }
1792
+    if( FALSE === ( $dirfile = $this->getConfig( 'url' ))) {
1793
+          $dirfile = $this->getConfig( 'dirfile' );
1794
+    }
1592 1795
     $iCalFile = @fopen( $dirfile, 'w' );
1593 1796
     if( $iCalFile ) {
1594
-      if( FALSE === fwrite( $iCalFile, $this->createCalendar() ))
1595
-        return FALSE;
1797
+      if( FALSE === fwrite( $iCalFile, $this->createCalendar() )) {
1798
+              return FALSE;
1799
+      }
1596 1800
       fclose( $iCalFile );
1597 1801
       return TRUE;
1802
+    } else {
1803
+          return FALSE;
1598 1804
     }
1599
-    else
1600
-      return FALSE;
1601 1805
   }
1602 1806
 /**
1603 1807
  * if recent version of calendar file exists (default one hour), an HTTP redirect header is sent
@@ -1616,15 +1820,19 @@  discard block
 block discarded – undo
1616 1820
       $timeout   = (int) $directory;
1617 1821
       $directory = FALSE;
1618 1822
     }
1619
-    if( $directory )
1620
-      $this->setConfig( 'directory', $directory );
1621
-    if( $filename )
1622
-      $this->setConfig( 'filename',  $filename );
1623
-    if( $delimiter && ( $delimiter != DIRECTORY_SEPARATOR ))
1624
-      $this->setConfig( 'delimiter', $delimiter );
1823
+    if( $directory ) {
1824
+          $this->setConfig( 'directory', $directory );
1825
+    }
1826
+    if( $filename ) {
1827
+          $this->setConfig( 'filename',  $filename );
1828
+    }
1829
+    if( $delimiter && ( $delimiter != DIRECTORY_SEPARATOR )) {
1830
+          $this->setConfig( 'delimiter', $delimiter );
1831
+    }
1625 1832
     $filesize    = $this->getConfig( 'filesize' );
1626
-    if( 0 >= $filesize )
1627
-      return FALSE;
1833
+    if( 0 >= $filesize ) {
1834
+          return FALSE;
1835
+    }
1628 1836
     $dirfile     = $this->getConfig( 'dirfile' );
1629 1837
     if( time() - filemtime( $dirfile ) < $timeout) {
1630 1838
       clearstatcache();
@@ -1632,10 +1840,11 @@  discard block
 block discarded – undo
1632 1840
       $filename  = $this->getConfig( 'filename' );
1633 1841
 //    if( headers_sent( $filename, $linenum ))
1634 1842
 //      die( "Headers already sent in $filename on line $linenum\n" );
1635
-      if( 'xcal' == $this->format )
1636
-        header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1637
-      else
1638
-        header( 'Content-Type: text/calendar; charset=utf-8' );
1843
+      if( 'xcal' == $this->format ) {
1844
+              header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1845
+      } else {
1846
+              header( 'Content-Type: text/calendar; charset=utf-8' );
1847
+      }
1639 1848
       header( 'Content-Length: '.$filesize );
1640 1849
       header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
1641 1850
       header( 'Cache-Control: max-age=10' );
@@ -1645,9 +1854,9 @@  discard block
 block discarded – undo
1645 1854
         fclose( $fp );
1646 1855
       }
1647 1856
       die();
1857
+    } else {
1858
+          return FALSE;
1648 1859
     }
1649
-    else
1650
-      return FALSE;
1651 1860
   }
1652 1861
 }
1653 1862
 /*********************************************************************************/
@@ -1718,9 +1927,12 @@  discard block
 block discarded – undo
1718 1927
  * @return string
1719 1928
  */
1720 1929
   function createAction() {
1721
-    if( empty( $this->action )) return FALSE;
1722
-    if( empty( $this->action['value'] ))
1723
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE;
1930
+    if( empty( $this->action )) {
1931
+        return FALSE;
1932
+    }
1933
+    if( empty( $this->action['value'] )) {
1934
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE;
1935
+    }
1724 1936
     $attributes = $this->_createParams( $this->action['params'] );
1725 1937
     return $this->_createElement( 'ACTION', $attributes, $this->action['value'] );
1726 1938
   }
@@ -1734,7 +1946,11 @@  discard block
 block discarded – undo
1734 1946
  * @return bool
1735 1947
  */
1736 1948
   function setAction( $value, $params=FALSE ) {
1737
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1949
+    if( empty( $value )) {
1950
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
1951
+    } else {
1952
+        return FALSE;
1953
+    }
1738 1954
     $this->action = array( 'value' => $value, 'params' => $this->_setParams( $params ));
1739 1955
     return TRUE;
1740 1956
   }
@@ -1750,14 +1966,17 @@  discard block
 block discarded – undo
1750 1966
  * @return string
1751 1967
  */
1752 1968
   function createAttach() {
1753
-    if( empty( $this->attach )) return FALSE;
1969
+    if( empty( $this->attach )) {
1970
+        return FALSE;
1971
+    }
1754 1972
     $output       = null;
1755 1973
     foreach( $this->attach as $attachPart ) {
1756 1974
       if(! empty( $attachPart['value'] )) {
1757 1975
         $attributes = $this->_createParams( $attachPart['params'] );
1758 1976
         $output    .= $this->_createElement( 'ATTACH', $attributes, $attachPart['value'] );
1977
+      } elseif( $this->getConfig( 'allowEmpty' )) {
1978
+          $output .= $this->_createElement( 'ATTACH' );
1759 1979
       }
1760
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'ATTACH' );
1761 1980
     }
1762 1981
     return $output;
1763 1982
   }
@@ -1772,7 +1991,11 @@  discard block
 block discarded – undo
1772 1991
  * @return bool
1773 1992
  */
1774 1993
   function setAttach( $value, $params=FALSE, $index=FALSE ) {
1775
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1994
+    if( empty( $value )) {
1995
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
1996
+    } else {
1997
+        return FALSE;
1998
+    }
1776 1999
     $this->_setMval( $this->attach, $value, $params, FALSE, $index );
1777 2000
     return TRUE;
1778 2001
   }
@@ -1788,19 +2011,22 @@  discard block
 block discarded – undo
1788 2011
  * @return string
1789 2012
  */
1790 2013
   function createAttendee() {
1791
-    if( empty( $this->attendee )) return FALSE;
2014
+    if( empty( $this->attendee )) {
2015
+        return FALSE;
2016
+    }
1792 2017
     $output = null;
1793 2018
     foreach( $this->attendee as $attendeePart ) {                      // start foreach 1
1794 2019
       if( empty( $attendeePart['value'] )) {
1795
-        if( $this->getConfig( 'allowEmpty' ))
1796
-          $output .= $this->_createElement( 'ATTENDEE' );
2020
+        if( $this->getConfig( 'allowEmpty' )) {
2021
+                  $output .= $this->_createElement( 'ATTENDEE' );
2022
+        }
1797 2023
         continue;
1798 2024
       }
1799 2025
       $attendee1 = $attendee2 = $attendeeLANG = $attendeeCN = null;
1800 2026
       foreach( $attendeePart as $paramlabel => $paramvalue ) {         // start foreach 2
1801
-        if( 'value' == $paramlabel )
1802
-          $attendee2  .= 'MAILTO:'.$paramvalue;
1803
-        elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) { // start elseif
2027
+        if( 'value' == $paramlabel ) {
2028
+                  $attendee2  .= 'MAILTO:'.$paramvalue;
2029
+        } elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) { // start elseif
1804 2030
           foreach( $paramvalue as $optparamlabel => $optparamvalue ) { // start foreach 3
1805 2031
             $attendee11 = $attendee12 = null;
1806 2032
             if( is_int( $optparamlabel )) {
@@ -1860,7 +2086,11 @@  discard block
 block discarded – undo
1860 2086
  * @return bool
1861 2087
  */
1862 2088
   function setAttendee( $value, $params=FALSE, $index=FALSE ) {
1863
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2089
+    if( empty( $value )) {
2090
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
2091
+    } else {
2092
+        return FALSE;
2093
+    }
1864 2094
     $value = str_replace ( 'MAILTO:', '', $value );
1865 2095
     $value = str_replace ( 'mailto:', '', $value );
1866 2096
     $params2 = array();
@@ -1876,16 +2106,17 @@  discard block
 block discarded – undo
1876 2106
               foreach( $optparamvalue as $part ) {
1877 2107
                 $part = str_replace( 'MAILTO:', '', $part );
1878 2108
                 $part = str_replace( 'mailto:', '', $part );
1879
-                if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} ))
1880
-                  $part = substr( $part, 1, ( strlen($part)-2 ));
2109
+                if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) {
2110
+                                  $part = substr( $part, 1, ( strlen($part)-2 ));
2111
+                }
1881 2112
                 $optarrays[$optparamlabel][] = $part;
1882 2113
               }
1883
-            }
1884
-            else {
2114
+            } else {
1885 2115
               $part = str_replace( 'MAILTO:', '', $optparamvalue );
1886 2116
               $part = str_replace( 'mailto:', '', $part );
1887
-              if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} ))
1888
-                $part = substr( $part, 1, ( strlen($part)-2 ));
2117
+              if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) {
2118
+                              $part = substr( $part, 1, ( strlen($part)-2 ));
2119
+              }
1889 2120
               $optarrays[$optparamlabel][] = $part;
1890 2121
             }
1891 2122
             break;
@@ -1895,14 +2126,16 @@  discard block
 block discarded – undo
1895 2126
               $optparamvalue = str_replace( 'mailto:', '', $optparamvalue );
1896 2127
             }
1897 2128
             if(( '"' == substr( $optparamvalue, 0, 1 )) &&
1898
-               ( '"' == substr( $optparamvalue, -1 )))
1899
-              $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 ));
2129
+               ( '"' == substr( $optparamvalue, -1 ))) {
2130
+                          $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 ));
2131
+            }
1900 2132
             $params2[$optparamlabel] = $optparamvalue;
1901 2133
             break;
1902 2134
         } // end switch( $optparamlabel.. .
1903 2135
       } // end foreach( $optparam.. .
1904
-      foreach( $optarrays as $optparamlabel => $optparams )
1905
-        $params2[$optparamlabel] = $optparams;
2136
+      foreach( $optarrays as $optparamlabel => $optparams ) {
2137
+              $params2[$optparamlabel] = $optparams;
2138
+      }
1906 2139
     }
1907 2140
         // remove defaults
1908 2141
     $this->_existRem( $params2, 'CUTYPE',   'INDIVIDUAL' );
@@ -1912,8 +2145,9 @@  discard block
 block discarded – undo
1912 2145
         // check language setting
1913 2146
     if( isset( $params2['CN' ] )) {
1914 2147
       $lang = $this->getConfig( 'language' );
1915
-      if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang ))
1916
-        $params2['LANGUAGE' ] = $lang;
2148
+      if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang )) {
2149
+              $params2['LANGUAGE' ] = $lang;
2150
+      }
1917 2151
     }
1918 2152
     $this->_setMval( $this->attendee, $value, $params2, FALSE, $index );
1919 2153
     return TRUE;
@@ -1930,22 +2164,26 @@  discard block
 block discarded – undo
1930 2164
  * @return string
1931 2165
  */
1932 2166
   function createCategories() {
1933
-    if( empty( $this->categories )) return FALSE;
2167
+    if( empty( $this->categories )) {
2168
+        return FALSE;
2169
+    }
1934 2170
     $output = null;
1935 2171
     foreach( $this->categories as $category ) {
1936 2172
       if( empty( $category['value'] )) {
1937
-        if ( $this->getConfig( 'allowEmpty' ))
1938
-          $output .= $this->_createElement( 'CATEGORIES' );
2173
+        if ( $this->getConfig( 'allowEmpty' )) {
2174
+                  $output .= $this->_createElement( 'CATEGORIES' );
2175
+        }
1939 2176
         continue;
1940 2177
       }
1941 2178
       $attributes = $this->_createParams( $category['params'], array( 'LANGUAGE' ));
1942 2179
       if( is_array( $category['value'] )) {
1943
-        foreach( $category['value'] as $cix => $categoryPart )
1944
-          $category['value'][$cix] = $this->_strrep( $categoryPart );
2180
+        foreach( $category['value'] as $cix => $categoryPart ) {
2181
+                  $category['value'][$cix] = $this->_strrep( $categoryPart );
2182
+        }
1945 2183
         $content  = implode( ',', $category['value'] );
2184
+      } else {
2185
+              $content  = $this->_strrep( $category['value'] );
1946 2186
       }
1947
-      else
1948
-        $content  = $this->_strrep( $category['value'] );
1949 2187
       $output    .= $this->_createElement( 'CATEGORIES', $attributes, $content );
1950 2188
     }
1951 2189
     return $output;
@@ -1961,7 +2199,11 @@  discard block
 block discarded – undo
1961 2199
  * @return bool
1962 2200
  */
1963 2201
   function setCategories( $value, $params=FALSE, $index=FALSE ) {
1964
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2202
+    if( empty( $value )) {
2203
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
2204
+    } else {
2205
+        return FALSE;
2206
+    }
1965 2207
     $this->_setMval( $this->categories, $value, $params, FALSE, $index );
1966 2208
     return TRUE;
1967 2209
  }
@@ -1977,9 +2219,12 @@  discard block
 block discarded – undo
1977 2219
  * @return string
1978 2220
  */
1979 2221
   function createClass() {
1980
-    if( empty( $this->class )) return FALSE;
1981
-    if( empty( $this->class['value'] ))
1982
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE;
2222
+    if( empty( $this->class )) {
2223
+        return FALSE;
2224
+    }
2225
+    if( empty( $this->class['value'] )) {
2226
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE;
2227
+    }
1983 2228
     $attributes = $this->_createParams( $this->class['params'] );
1984 2229
     return $this->_createElement( 'CLASS', $attributes, $this->class['value'] );
1985 2230
   }
@@ -1993,7 +2238,11 @@  discard block
 block discarded – undo
1993 2238
  * @return bool
1994 2239
  */
1995 2240
   function setClass( $value, $params=FALSE ) {
1996
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2241
+    if( empty( $value )) {
2242
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
2243
+    } else {
2244
+        return FALSE;
2245
+    }
1997 2246
     $this->class = array( 'value' => $value, 'params' => $this->_setParams( $params ));
1998 2247
     return TRUE;
1999 2248
   }
@@ -2009,11 +2258,15 @@  discard block
 block discarded – undo
2009 2258
  * @return string
2010 2259
  */
2011 2260
   function createComment() {
2012
-    if( empty( $this->comment )) return FALSE;
2013
-    $output = null;
2261
+    if( empty( $this->comment )) {
2262
+        return FALSE;
2263
+    }
2264
+    $output = null;
2014 2265
     foreach( $this->comment as $commentPart ) {
2015 2266
       if( empty( $commentPart['value'] )) {
2016
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'COMMENT' );
2267
+        if( $this->getConfig( 'allowEmpty' )) {
2268
+            $output .= $this->_createElement( 'COMMENT' );
2269
+        }
2017 2270
         continue;
2018 2271
       }
2019 2272
       $attributes = $this->_createParams( $commentPart['params'], array( 'ALTREP', 'LANGUAGE' ));
@@ -2033,7 +2286,11 @@  discard block
 block discarded – undo
2033 2286
  * @return bool
2034 2287
  */
2035 2288
   function setComment( $value, $params=FALSE, $index=FALSE ) {
2036
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2289
+    if( empty( $value )) {
2290
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
2291
+    } else {
2292
+        return FALSE;
2293
+    }
2037 2294
     $this->_setMval( $this->comment, $value, $params, FALSE, $index );
2038 2295
     return TRUE;
2039 2296
   }
@@ -2049,16 +2306,20 @@  discard block
 block discarded – undo
2049 2306
  * @return string
2050 2307
  */
2051 2308
   function createCompleted( ) {
2052
-    if( empty( $this->completed )) return FALSE;
2309
+    if( empty( $this->completed )) {
2310
+        return FALSE;
2311
+    }
2053 2312
     if( !isset( $this->completed['value']['year'] )  &&
2054 2313
         !isset( $this->completed['value']['month'] ) &&
2055 2314
         !isset( $this->completed['value']['day'] )   &&
2056 2315
         !isset( $this->completed['value']['hour'] )  &&
2057 2316
         !isset( $this->completed['value']['min'] )   &&
2058
-        !isset( $this->completed['value']['sec'] ))
2059
-      if( $this->getConfig( 'allowEmpty' ))
2317
+        !isset( $this->completed['value']['sec'] )) {
2318
+          if( $this->getConfig( 'allowEmpty' ))
2060 2319
         return $this->_createElement( 'COMPLETED' );
2061
-      else return FALSE;
2320
+    } else {
2321
+          return FALSE;
2322
+      }
2062 2323
     $formatted  = $this->_format_date_time( $this->completed['value'], 7 );
2063 2324
     $attributes = $this->_createParams( $this->completed['params'] );
2064 2325
     return $this->_createElement( 'COMPLETED', $attributes, $formatted );
@@ -2082,9 +2343,9 @@  discard block
 block discarded – undo
2082 2343
       if( $this->getConfig( 'allowEmpty' )) {
2083 2344
         $this->completed = array( 'value' => null, 'params' => $this->_setParams( $params ));
2084 2345
         return TRUE;
2346
+      } else {
2347
+              return FALSE;
2085 2348
       }
2086
-      else
2087
-        return FALSE;
2088 2349
     }
2089 2350
     $this->completed = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2090 2351
     return TRUE;
@@ -2101,15 +2362,18 @@  discard block
 block discarded – undo
2101 2362
  * @return string
2102 2363
  */
2103 2364
   function createContact() {
2104
-    if( empty( $this->contact )) return FALSE;
2365
+    if( empty( $this->contact )) {
2366
+        return FALSE;
2367
+    }
2105 2368
     $output = null;
2106 2369
     foreach( $this->contact as $contact ) {
2107 2370
       if( !empty( $contact['value'] )) {
2108 2371
         $attributes = $this->_createParams( $contact['params'], array( 'ALTREP', 'LANGUAGE' ));
2109 2372
         $content    = $this->_strrep( $contact['value'] );
2110 2373
         $output    .= $this->_createElement( 'CONTACT', $attributes, $content );
2374
+      } elseif( $this->getConfig( 'allowEmpty' )) {
2375
+          $output .= $this->_createElement( 'CONTACT' );
2111 2376
       }
2112
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'CONTACT' );
2113 2377
     }
2114 2378
     return $output;
2115 2379
   }
@@ -2124,7 +2388,11 @@  discard block
 block discarded – undo
2124 2388
  * @return bool
2125 2389
  */
2126 2390
   function setContact( $value, $params=FALSE, $index=FALSE ) {
2127
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2391
+    if( empty( $value )) {
2392
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
2393
+    } else {
2394
+        return FALSE;
2395
+    }
2128 2396
     $this->_setMval( $this->contact, $value, $params, FALSE, $index );
2129 2397
     return TRUE;
2130 2398
   }
@@ -2140,7 +2408,9 @@  discard block
 block discarded – undo
2140 2408
  * @return string
2141 2409
  */
2142 2410
   function createCreated() {
2143
-    if( empty( $this->created )) return FALSE;
2411
+    if( empty( $this->created )) {
2412
+        return FALSE;
2413
+    }
2144 2414
     $formatted  = $this->_format_date_time( $this->created['value'], 7 );
2145 2415
     $attributes = $this->_createParams( $this->created['params'] );
2146 2416
     return $this->_createElement( 'CREATED', $attributes, $formatted );
@@ -2178,15 +2448,18 @@  discard block
 block discarded – undo
2178 2448
  * @return string
2179 2449
  */
2180 2450
   function createDescription() {
2181
-    if( empty( $this->description )) return FALSE;
2451
+    if( empty( $this->description )) {
2452
+        return FALSE;
2453
+    }
2182 2454
     $output       = null;
2183 2455
     foreach( $this->description as $description ) {
2184 2456
       if( !empty( $description['value'] )) {
2185 2457
         $attributes = $this->_createParams( $description['params'], array( 'ALTREP', 'LANGUAGE' ));
2186 2458
         $content    = $this->_strrep( $description['value'] );
2187 2459
         $output    .= $this->_createElement( 'DESCRIPTION', $attributes, $content );
2460
+      } elseif( $this->getConfig( 'allowEmpty' )) {
2461
+          $output .= $this->_createElement( 'DESCRIPTION' );
2188 2462
       }
2189
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'DESCRIPTION' );
2190 2463
     }
2191 2464
     return $output;
2192 2465
   }
@@ -2201,7 +2474,12 @@  discard block
 block discarded – undo
2201 2474
  * @return bool
2202 2475
  */
2203 2476
   function setDescription( $value, $params=FALSE, $index=FALSE ) {
2204
-    if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; }
2477
+    if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) {
2478
+        $value = null;
2479
+    } else {
2480
+        return FALSE;
2481
+    }
2482
+    }
2205 2483
     $this->_setMval( $this->description, $value, $params, FALSE, $index );
2206 2484
     return TRUE;
2207 2485
   }
@@ -2217,16 +2495,20 @@  discard block
 block discarded – undo
2217 2495
  * @return string
2218 2496
  */
2219 2497
   function createDtend() {
2220
-    if( empty( $this->dtend )) return FALSE;
2498
+    if( empty( $this->dtend )) {
2499
+        return FALSE;
2500
+    }
2221 2501
     if( !isset( $this->dtend['value']['year'] )  &&
2222 2502
         !isset( $this->dtend['value']['month'] ) &&
2223 2503
         !isset( $this->dtend['value']['day'] )   &&
2224 2504
         !isset( $this->dtend['value']['hour'] )  &&
2225 2505
         !isset( $this->dtend['value']['min'] )   &&
2226
-        !isset( $this->dtend['value']['sec'] ))
2227
-      if( $this->getConfig( 'allowEmpty' ))
2506
+        !isset( $this->dtend['value']['sec'] )) {
2507
+          if( $this->getConfig( 'allowEmpty' ))
2228 2508
         return $this->_createElement( 'DTEND' );
2229
-      else return FALSE;
2509
+    } else {
2510
+          return FALSE;
2511
+      }
2230 2512
     $formatted  = $this->_format_date_time( $this->dtend['value'] );
2231 2513
     $attributes = $this->_createParams( $this->dtend['params'] );
2232 2514
     return $this->_createElement( 'DTEND', $attributes, $formatted );
@@ -2251,9 +2533,9 @@  discard block
 block discarded – undo
2251 2533
       if( $this->getConfig( 'allowEmpty' )) {
2252 2534
         $this->dtend = array( 'value' => null, 'params' => $this->_setParams( $params ));
2253 2535
         return TRUE;
2536
+      } else {
2537
+              return FALSE;
2254 2538
       }
2255
-      else
2256
-        return FALSE;
2257 2539
     }
2258 2540
     $this->dtend = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params );
2259 2541
     return TRUE;
@@ -2275,8 +2557,9 @@  discard block
 block discarded – undo
2275 2557
         !isset( $this->dtstamp['value']['day'] )   &&
2276 2558
         !isset( $this->dtstamp['value']['hour'] )  &&
2277 2559
         !isset( $this->dtstamp['value']['min'] )   &&
2278
-        !isset( $this->dtstamp['value']['sec'] ))
2279
-      $this->_makeDtstamp();
2560
+        !isset( $this->dtstamp['value']['sec'] )) {
2561
+          $this->_makeDtstamp();
2562
+    }
2280 2563
     $formatted  = $this->_format_date_time( $this->dtstamp['value'], 7 );
2281 2564
     $attributes = $this->_createParams( $this->dtstamp['params'] );
2282 2565
     return $this->_createElement( 'DTSTAMP', $attributes, $formatted );
@@ -2312,10 +2595,11 @@  discard block
 block discarded – undo
2312 2595
  * @return TRUE
2313 2596
  */
2314 2597
   function setDtstamp( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2315
-    if( empty( $year ))
2316
-      $this->_makeDtstamp();
2317
-    else
2318
-      $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2598
+    if( empty( $year )) {
2599
+          $this->_makeDtstamp();
2600
+    } else {
2601
+          $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2602
+    }
2319 2603
     return TRUE;
2320 2604
   }
2321 2605
 /*********************************************************************************/
@@ -2330,18 +2614,23 @@  discard block
 block discarded – undo
2330 2614
  * @return string
2331 2615
  */
2332 2616
   function createDtstart() {
2333
-    if( empty( $this->dtstart )) return FALSE;
2617
+    if( empty( $this->dtstart )) {
2618
+        return FALSE;
2619
+    }
2334 2620
     if( !isset( $this->dtstart['value']['year'] )  &&
2335 2621
         !isset( $this->dtstart['value']['month'] ) &&
2336 2622
         !isset( $this->dtstart['value']['day'] )   &&
2337 2623
         !isset( $this->dtstart['value']['hour'] )  &&
2338 2624
         !isset( $this->dtstart['value']['min'] )   &&
2339
-        !isset( $this->dtstart['value']['sec'] ))
2340
-    if( $this->getConfig( 'allowEmpty' ))
2625
+        !isset( $this->dtstart['value']['sec'] )) {
2626
+        if( $this->getConfig( 'allowEmpty' ))
2341 2627
       return $this->_createElement( 'DTSTART' );
2342
-    else return FALSE;
2343
-    if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' )))
2344
-      unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] );
2628
+    } else {
2629
+        return FALSE;
2630
+    }
2631
+    if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) {
2632
+          unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] );
2633
+    }
2345 2634
     $formatted  = $this->_format_date_time( $this->dtstart['value'] );
2346 2635
     $attributes = $this->_createParams( $this->dtstart['params'] );
2347 2636
     return $this->_createElement( 'DTSTART', $attributes, $formatted );
@@ -2366,9 +2655,9 @@  discard block
 block discarded – undo
2366 2655
       if( $this->getConfig( 'allowEmpty' )) {
2367 2656
         $this->dtstart = array( 'value' => null, 'params' => $this->_setParams( $params ));
2368 2657
         return TRUE;
2658
+      } else {
2659
+              return FALSE;
2369 2660
       }
2370
-      else
2371
-        return FALSE;
2372 2661
     }
2373 2662
     $this->dtstart = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params, 'dtstart' );
2374 2663
     return TRUE;
@@ -2385,16 +2674,20 @@  discard block
 block discarded – undo
2385 2674
  * @return string
2386 2675
  */
2387 2676
   function createDue() {
2388
-    if( empty( $this->due )) return FALSE;
2677
+    if( empty( $this->due )) {
2678
+        return FALSE;
2679
+    }
2389 2680
     if( !isset( $this->due['value']['year'] )  &&
2390 2681
         !isset( $this->due['value']['month'] ) &&
2391 2682
         !isset( $this->due['value']['day'] )   &&
2392 2683
         !isset( $this->due['value']['hour'] )  &&
2393 2684
         !isset( $this->due['value']['min'] )   &&
2394
-        !isset( $this->due['value']['sec'] ))
2395
-      if( $this->getConfig( 'allowEmpty' ))
2685
+        !isset( $this->due['value']['sec'] )) {
2686
+          if( $this->getConfig( 'allowEmpty' ))
2396 2687
         return $this->_createElement( 'DUE' );
2397
-      else return FALSE;
2688
+    } else {
2689
+          return FALSE;
2690
+      }
2398 2691
     $formatted  = $this->_format_date_time( $this->due['value'] );
2399 2692
     $attributes = $this->_createParams( $this->due['params'] );
2400 2693
     return $this->_createElement( 'DUE', $attributes, $formatted );
@@ -2418,9 +2711,9 @@  discard block
 block discarded – undo
2418 2711
       if( $this->getConfig( 'allowEmpty' )) {
2419 2712
         $this->due = array( 'value' => null, 'params' => $this->_setParams( $params ));
2420 2713
         return TRUE;
2714
+      } else {
2715
+              return FALSE;
2421 2716
       }
2422
-      else
2423
-        return FALSE;
2424 2717
     }
2425 2718
     $this->due = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params );
2426 2719
     return TRUE;
@@ -2437,15 +2730,19 @@  discard block
 block discarded – undo
2437 2730
  * @return string
2438 2731
  */
2439 2732
   function createDuration() {
2440
-    if( empty( $this->duration )) return FALSE;
2733
+    if( empty( $this->duration )) {
2734
+        return FALSE;
2735
+    }
2441 2736
     if( !isset( $this->duration['value']['week'] ) &&
2442 2737
         !isset( $this->duration['value']['day'] )  &&
2443 2738
         !isset( $this->duration['value']['hour'] ) &&
2444 2739
         !isset( $this->duration['value']['min'] )  &&
2445
-        !isset( $this->duration['value']['sec'] ))
2446
-      if( $this->getConfig( 'allowEmpty' ))
2740
+        !isset( $this->duration['value']['sec'] )) {
2741
+          if( $this->getConfig( 'allowEmpty' ))
2447 2742
         return $this->_createElement( 'DURATION', array(), null );
2448
-      else return FALSE;
2743
+    } else {
2744
+          return FALSE;
2745
+      }
2449 2746
     $attributes = $this->_createParams( $this->duration['params'] );
2450 2747
     return $this->_createElement( 'DURATION', $attributes, $this->_format_duration( $this->duration['value'] ));
2451 2748
   }
@@ -2463,19 +2760,24 @@  discard block
 block discarded – undo
2463 2760
  * @return bool
2464 2761
  */
2465 2762
   function setDuration( $week, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2466
-    if( empty( $week )) if( $this->getConfig( 'allowEmpty' )) $week = null; else return FALSE;
2467
-    if( is_array( $week ) && ( 1 <= count( $week )))
2468
-      $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day ));
2469
-    elseif( is_string( $week ) && ( 3 <= strlen( trim( $week )))) {
2763
+    if( empty( $week )) {
2764
+        if( $this->getConfig( 'allowEmpty' )) $week = null;
2765
+    } else {
2766
+        return FALSE;
2767
+    }
2768
+    if( is_array( $week ) && ( 1 <= count( $week ))) {
2769
+          $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day ));
2770
+    } elseif( is_string( $week ) && ( 3 <= strlen( trim( $week )))) {
2470 2771
       $week = trim( $week );
2471
-      if( in_array( substr( $week, 0, 1 ), array( '+', '-' )))
2472
-        $week = substr( $week, 1 );
2772
+      if( in_array( substr( $week, 0, 1 ), array( '+', '-' ))) {
2773
+              $week = substr( $week, 1 );
2774
+      }
2473 2775
       $this->duration = array( 'value' => $this->_duration_string( $week ), 'params' => $this->_setParams( $day ));
2776
+    } elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec )) {
2777
+          return FALSE;
2778
+    } else {
2779
+          $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params ));
2474 2780
     }
2475
-    elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec ))
2476
-      return FALSE;
2477
-    else
2478
-      $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params ));
2479 2781
     return TRUE;
2480 2782
   }
2481 2783
 /*********************************************************************************/
@@ -2490,31 +2792,37 @@  discard block
 block discarded – undo
2490 2792
  * @return string
2491 2793
  */
2492 2794
   function createExdate() {
2493
-    if( empty( $this->exdate )) return FALSE;
2795
+    if( empty( $this->exdate )) {
2796
+        return FALSE;
2797
+    }
2494 2798
     $output = null;
2495 2799
     foreach( $this->exdate as $ex => $theExdate ) {
2496 2800
       if( empty( $theExdate['value'] )) {
2497
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'EXDATE' );
2801
+        if( $this->getConfig( 'allowEmpty' )) {
2802
+            $output .= $this->_createElement( 'EXDATE' );
2803
+        }
2498 2804
         continue;
2499 2805
       }
2500 2806
       $content = $attributes = null;
2501 2807
       foreach( $theExdate['value'] as $eix => $exdatePart ) {
2502 2808
         $parno = count( $exdatePart );
2503 2809
         $formatted = $this->_format_date_time( $exdatePart, $parno );
2504
-        if( isset( $theExdate['params']['TZID'] ))
2505
-          $formatted = str_replace( 'Z', '', $formatted);
2810
+        if( isset( $theExdate['params']['TZID'] )) {
2811
+                  $formatted = str_replace( 'Z', '', $formatted);
2812
+        }
2506 2813
         if( 0 < $eix ) {
2507 2814
           if( isset( $theExdate['value'][0]['tz'] )) {
2508 2815
             if( ctype_digit( substr( $theExdate['value'][0]['tz'], -4 )) ||
2509 2816
                ( 'Z' == $theExdate['value'][0]['tz'] )) {
2510
-              if( 'Z' != substr( $formatted, -1 ))
2511
-                $formatted .= 'Z';
2817
+              if( 'Z' != substr( $formatted, -1 )) {
2818
+                              $formatted .= 'Z';
2819
+              }
2820
+            } else {
2821
+                          $formatted = str_replace( 'Z', '', $formatted );
2512 2822
             }
2513
-            else
2514
-              $formatted = str_replace( 'Z', '', $formatted );
2823
+          } else {
2824
+                      $formatted = str_replace( 'Z', '', $formatted );
2515 2825
           }
2516
-          else
2517
-            $formatted = str_replace( 'Z', '', $formatted );
2518 2826
         }
2519 2827
         $content .= ( 0 < $eix ) ? ','.$formatted : $formatted;
2520 2828
       }
@@ -2538,34 +2846,39 @@  discard block
 block discarded – undo
2538 2846
       if( $this->getConfig( 'allowEmpty' )) {
2539 2847
         $this->_setMval( $this->exdate, null, $params, FALSE, $index );
2540 2848
         return TRUE;
2849
+      } else {
2850
+              return FALSE;
2541 2851
       }
2542
-      else
2543
-        return FALSE;
2544 2852
     }
2545 2853
     $input  = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )));
2546 2854
             /* ev. check 1:st date and save ev. timezone **/
2547 2855
     $this->_chkdatecfg( reset( $exdates ), $parno, $input['params'] );
2548 2856
     $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default parameter
2549 2857
     foreach( $exdates as $eix => $theExdate ) {
2550
-      if( $this->_isArrayTimestampDate( $theExdate ))
2551
-        $exdatea = $this->_timestamp2date( $theExdate, $parno );
2552
-      elseif(  is_array( $theExdate ))
2553
-        $exdatea = $this->_date_time_array( $theExdate, $parno );
2554
-      elseif( 8 <= strlen( trim( $theExdate ))) // ex. 2006-08-03 10:12:18
2858
+      if( $this->_isArrayTimestampDate( $theExdate )) {
2859
+              $exdatea = $this->_timestamp2date( $theExdate, $parno );
2860
+      } elseif(  is_array( $theExdate )) {
2861
+              $exdatea = $this->_date_time_array( $theExdate, $parno );
2862
+      } elseif( 8 <= strlen( trim( $theExdate ))) {
2863
+          // ex. 2006-08-03 10:12:18
2555 2864
         $exdatea = $this->_date_time_string( $theExdate, $parno );
2556
-      if( 3 == $parno )
2557
-        unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] );
2558
-      elseif( isset( $exdatea['tz'] ))
2559
-        $exdatea['tz'] = (string) $exdatea['tz'];
2865
+      }
2866
+      if( 3 == $parno ) {
2867
+              unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] );
2868
+      } elseif( isset( $exdatea['tz'] )) {
2869
+              $exdatea['tz'] = (string) $exdatea['tz'];
2870
+      }
2560 2871
       if(  isset( $input['params']['TZID'] ) ||
2561 2872
          ( isset( $exdatea['tz'] ) && !$this->_isOffset( $exdatea['tz'] )) ||
2562 2873
          ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) ||
2563
-         ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] )))
2564
-        unset( $exdatea['tz'] );
2874
+         ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) {
2875
+              unset( $exdatea['tz'] );
2876
+      }
2565 2877
       $input['value'][] = $exdatea;
2566 2878
     }
2567
-    if( 0 >= count( $input['value'] ))
2568
-      return FALSE;
2879
+    if( 0 >= count( $input['value'] )) {
2880
+          return FALSE;
2881
+    }
2569 2882
     if( 3 == $parno ) {
2570 2883
       $input['params']['VALUE'] = 'DATE';
2571 2884
       unset( $input['params']['TZID'] );
@@ -2585,7 +2898,9 @@  discard block
 block discarded – undo
2585 2898
  * @return string
2586 2899
  */
2587 2900
   function createExrule() {
2588
-    if( empty( $this->exrule )) return FALSE;
2901
+    if( empty( $this->exrule )) {
2902
+        return FALSE;
2903
+    }
2589 2904
     return $this->_format_recur( 'EXRULE', $this->exrule );
2590 2905
   }
2591 2906
 /**
@@ -2599,7 +2914,11 @@  discard block
 block discarded – undo
2599 2914
  * @return bool
2600 2915
  */
2601 2916
   function setExrule( $exruleset, $params=FALSE, $index=FALSE ) {
2602
-    if( empty( $exruleset )) if( $this->getConfig( 'allowEmpty' )) $exruleset = null; else return FALSE;
2917
+    if( empty( $exruleset )) {
2918
+        if( $this->getConfig( 'allowEmpty' )) $exruleset = null;
2919
+    } else {
2920
+        return FALSE;
2921
+    }
2603 2922
     $this->_setMval( $this->exrule, $this->_setRexrule( $exruleset ), $params, FALSE, $index );
2604 2923
     return TRUE;
2605 2924
   }
@@ -2615,11 +2934,15 @@  discard block
 block discarded – undo
2615 2934
  * @return string
2616 2935
  */
2617 2936
   function createFreebusy() {
2618
-    if( empty( $this->freebusy )) return FALSE;
2937
+    if( empty( $this->freebusy )) {
2938
+        return FALSE;
2939
+    }
2619 2940
     $output = null;
2620 2941
     foreach( $this->freebusy as $freebusyPart ) {
2621 2942
       if( empty( $freebusyPart['value'] )) {
2622
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'FREEBUSY' );
2943
+        if( $this->getConfig( 'allowEmpty' )) {
2944
+            $output .= $this->_createElement( 'FREEBUSY' );
2945
+        }
2623 2946
         continue;
2624 2947
       }
2625 2948
       $attributes = $content = null;
@@ -2627,9 +2950,9 @@  discard block
 block discarded – undo
2627 2950
         $attributes .= $this->intAttrDelimiter.'FBTYPE='.$freebusyPart['value']['fbtype'];
2628 2951
         unset( $freebusyPart['value']['fbtype'] );
2629 2952
         $freebusyPart['value'] = array_values( $freebusyPart['value'] );
2953
+      } else {
2954
+              $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY';
2630 2955
       }
2631
-      else
2632
-        $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY';
2633 2956
       $attributes .= $this->_createParams( $freebusyPart['params'] );
2634 2957
       $fno = 1;
2635 2958
       $cnt = count( $freebusyPart['value']);
@@ -2638,21 +2961,24 @@  discard block
 block discarded – undo
2638 2961
         $content .= $formatted;
2639 2962
         $content .= '/';
2640 2963
         $cnt2 = count( $freebusyPeriod[1]);
2641
-        if( array_key_exists( 'year', $freebusyPeriod[1] ))      // date-time
2964
+        if( array_key_exists( 'year', $freebusyPeriod[1] )) {
2965
+            // date-time
2642 2966
           $cnt2 = 7;
2643
-        elseif( array_key_exists( 'week', $freebusyPeriod[1] ))  // duration
2967
+        } elseif( array_key_exists( 'week', $freebusyPeriod[1] )) {
2968
+            // duration
2644 2969
           $cnt2 = 5;
2970
+        }
2645 2971
         if(( 7 == $cnt2 )   &&    // period=  -> date-time
2646 2972
             isset( $freebusyPeriod[1]['year'] )  &&
2647 2973
             isset( $freebusyPeriod[1]['month'] ) &&
2648 2974
             isset( $freebusyPeriod[1]['day'] )) {
2649 2975
           $content .= $this->_format_date_time( $freebusyPeriod[1] );
2650
-        }
2651
-        else {                                  // period=  -> dur-time
2976
+        } else {                                  // period=  -> dur-time
2652 2977
           $content .= $this->_format_duration( $freebusyPeriod[1] );
2653 2978
         }
2654
-        if( $fno < $cnt )
2655
-          $content .= ',';
2979
+        if( $fno < $cnt ) {
2980
+                  $content .= ',';
2981
+        }
2656 2982
         $fno++;
2657 2983
       }
2658 2984
       $output .= $this->_createElement( 'FREEBUSY', $attributes, $content );
@@ -2675,14 +3001,15 @@  discard block
 block discarded – undo
2675 3001
       if( $this->getConfig( 'allowEmpty' )) {
2676 3002
         $this->_setMval( $this->freebusy, null, $params, FALSE, $index );
2677 3003
         return TRUE;
3004
+      } else {
3005
+              return FALSE;
2678 3006
       }
2679
-      else
2680
-        return FALSE;
2681 3007
     }
2682 3008
     $fbType = strtoupper( $fbType );
2683 3009
     if(( !in_array( $fbType, array( 'FREE', 'BUSY', 'BUSY-UNAVAILABLE', 'BUSY-TENTATIVE' ))) &&
2684
-       ( 'X-' != substr( $fbType, 0, 2 )))
2685
-      $fbType = 'BUSY';
3010
+       ( 'X-' != substr( $fbType, 0, 2 ))) {
3011
+          $fbType = 'BUSY';
3012
+    }
2686 3013
     $input = array( 'fbtype' => $fbType );
2687 3014
     foreach( $fbValues as $fbPeriod ) {   // periods => period
2688 3015
       $freebusyPeriod = array();
@@ -2692,22 +3019,19 @@  discard block
 block discarded – undo
2692 3019
           if( $this->_isArrayDate( $fbMember )) { // date-time value
2693 3020
             $freebusyPairMember       = $this->_date_time_array( $fbMember, 7 );
2694 3021
             $freebusyPairMember['tz'] = 'Z';
2695
-          }
2696
-          elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value
3022
+          } elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value
2697 3023
             $freebusyPairMember       = $this->_timestamp2date( $fbMember['timestamp'], 7 );
2698 3024
             $freebusyPairMember['tz'] = 'Z';
2699
-          }
2700
-          else {                                         // array format duration
3025
+          } else {                                         // array format duration
2701 3026
             $freebusyPairMember = $this->_duration_array( $fbMember );
2702 3027
           }
2703
-        }
2704
-        elseif(( 3 <= strlen( trim( $fbMember ))) &&    // string format duration
3028
+        } elseif(( 3 <= strlen( trim( $fbMember ))) &&    // string format duration
2705 3029
                ( in_array( $fbMember{0}, array( 'P', '+', '-' )))) {
2706
-          if( 'P' != $fbMember{0} )
2707
-            $fbmember = substr( $fbMember, 1 );
3030
+          if( 'P' != $fbMember{0} ) {
3031
+                      $fbmember = substr( $fbMember, 1 );
3032
+          }
2708 3033
           $freebusyPairMember = $this->_duration_string( $fbMember );
2709
-        }
2710
-        elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18
3034
+        } elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18
2711 3035
           $freebusyPairMember       = $this->_date_time_string( $fbMember, 7 );
2712 3036
           $freebusyPairMember['tz'] = 'Z';
2713 3037
         }
@@ -2730,9 +3054,12 @@  discard block
 block discarded – undo
2730 3054
  * @return string
2731 3055
  */
2732 3056
   function createGeo() {
2733
-    if( empty( $this->geo )) return FALSE;
2734
-    if( empty( $this->geo['value'] ))
2735
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE;
3057
+    if( empty( $this->geo )) {
3058
+        return FALSE;
3059
+    }
3060
+    if( empty( $this->geo['value'] )) {
3061
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE;
3062
+    }
2736 3063
     $attributes = $this->_createParams( $this->geo['params'] );
2737 3064
     $content    = null;
2738 3065
     $content   .= number_format( (float) $this->geo['value']['latitude'], 6, '.', '');
@@ -2752,15 +3079,17 @@  discard block
 block discarded – undo
2752 3079
  */
2753 3080
   function setGeo( $latitude, $longitude, $params=FALSE ) {
2754 3081
     if( !empty( $latitude ) && !empty( $longitude )) {
2755
-      if( !is_array( $this->geo )) $this->geo = array();
3082
+      if( !is_array( $this->geo )) {
3083
+          $this->geo = array();
3084
+      }
2756 3085
       $this->geo['value']['latitude']  = $latitude;
2757 3086
       $this->geo['value']['longitude'] = $longitude;
2758 3087
       $this->geo['params'] = $this->_setParams( $params );
3088
+    } elseif( $this->getConfig( 'allowEmpty' )) {
3089
+          $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) );
3090
+    } else {
3091
+          return FALSE;
2759 3092
     }
2760
-    elseif( $this->getConfig( 'allowEmpty' ))
2761
-      $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) );
2762
-    else
2763
-      return FALSE;
2764 3093
     return TRUE;
2765 3094
   }
2766 3095
 /*********************************************************************************/
@@ -2775,7 +3104,9 @@  discard block
 block discarded – undo
2775 3104
  * @return string
2776 3105
  */
2777 3106
   function createLastModified() {
2778
-    if( empty( $this->lastmodified )) return FALSE;
3107
+    if( empty( $this->lastmodified )) {
3108
+        return FALSE;
3109
+    }
2779 3110
     $attributes = $this->_createParams( $this->lastmodified['params'] );
2780 3111
     $formatted  = $this->_format_date_time( $this->lastmodified['value'], 7 );
2781 3112
     return $this->_createElement( 'LAST-MODIFIED', $attributes, $formatted );
@@ -2795,8 +3126,9 @@  discard block
 block discarded – undo
2795 3126
  * @return boll
2796 3127
  */
2797 3128
   function setLastModified( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2798
-    if( empty( $year ))
2799
-      $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' )));
3129
+    if( empty( $year )) {
3130
+          $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' )));
3131
+    }
2800 3132
     $this->lastmodified = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2801 3133
     return TRUE;
2802 3134
   }
@@ -2812,9 +3144,12 @@  discard block
 block discarded – undo
2812 3144
  * @return string
2813 3145
  */
2814 3146
   function createLocation() {
2815
-    if( empty( $this->location )) return FALSE;
2816
-    if( empty( $this->location['value'] ))
2817
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE;
3147
+    if( empty( $this->location )) {
3148
+        return FALSE;
3149
+    }
3150
+    if( empty( $this->location['value'] )) {
3151
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE;
3152
+    }
2818 3153
     $attributes = $this->_createParams( $this->location['params'], array( 'ALTREP', 'LANGUAGE' ));
2819 3154
     $content    = $this->_strrep( $this->location['value'] );
2820 3155
     return $this->_createElement( 'LOCATION', $attributes, $content );
@@ -2829,7 +3164,11 @@  discard block
 block discarded – undo
2829 3164
  * @return bool
2830 3165
  */
2831 3166
   function setLocation( $value, $params=FALSE ) {
2832
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3167
+    if( empty( $value )) {
3168
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3169
+    } else {
3170
+        return FALSE;
3171
+    }
2833 3172
     $this->location = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2834 3173
     return TRUE;
2835 3174
   }
@@ -2845,9 +3184,12 @@  discard block
 block discarded – undo
2845 3184
  * @return string
2846 3185
  */
2847 3186
   function createOrganizer() {
2848
-    if( empty( $this->organizer )) return FALSE;
2849
-    if( empty( $this->organizer['value'] ))
2850
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE;
3187
+    if( empty( $this->organizer )) {
3188
+        return FALSE;
3189
+    }
3190
+    if( empty( $this->organizer['value'] )) {
3191
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE;
3192
+    }
2851 3193
     $attributes = $this->_createParams( $this->organizer['params']
2852 3194
                                       , array( 'CN', 'DIR', 'LANGUAGE', 'SENT-BY' ));
2853 3195
     $content    = 'MAILTO:'.$this->organizer['value'];
@@ -2863,13 +3205,18 @@  discard block
 block discarded – undo
2863 3205
  * @return bool
2864 3206
  */
2865 3207
   function setOrganizer( $value, $params=FALSE ) {
2866
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3208
+    if( empty( $value )) {
3209
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3210
+    } else {
3211
+        return FALSE;
3212
+    }
2867 3213
     $value = str_replace ( 'MAILTO:', '', $value );
2868 3214
     $value = str_replace ( 'mailto:', '', $value );
2869 3215
     $this->organizer = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2870 3216
     if( isset( $this->organizer['params']['SENT-BY'] )) {
2871
-      if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 )))
2872
-        $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 );
3217
+      if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 ))) {
3218
+              $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 );
3219
+      }
2873 3220
     }
2874 3221
     return TRUE;
2875 3222
   }
@@ -2885,9 +3232,12 @@  discard block
 block discarded – undo
2885 3232
  * @return string
2886 3233
  */
2887 3234
   function createPercentComplete() {
2888
-    if( empty( $this->percentcomplete )) return FALSE;
2889
-    if( empty( $this->percentcomplete['value'] ))
2890
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE;
3235
+    if( empty( $this->percentcomplete )) {
3236
+        return FALSE;
3237
+    }
3238
+    if( empty( $this->percentcomplete['value'] )) {
3239
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE;
3240
+    }
2891 3241
     $attributes = $this->_createParams( $this->percentcomplete['params'] );
2892 3242
     return $this->_createElement( 'PERCENT-COMPLETE', $attributes, $this->percentcomplete['value'] );
2893 3243
   }
@@ -2901,7 +3251,11 @@  discard block
 block discarded – undo
2901 3251
  * @return bool
2902 3252
  */
2903 3253
   function setPercentComplete( $value, $params=FALSE ) {
2904
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3254
+    if( empty( $value )) {
3255
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3256
+    } else {
3257
+        return FALSE;
3258
+    }
2905 3259
     $this->percentcomplete = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2906 3260
     return TRUE;
2907 3261
   }
@@ -2917,9 +3271,12 @@  discard block
 block discarded – undo
2917 3271
  * @return string
2918 3272
  */
2919 3273
   function createPriority() {
2920
-    if( empty( $this->priority )) return FALSE;
2921
-    if( empty( $this->priority['value'] ))
2922
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE;
3274
+    if( empty( $this->priority )) {
3275
+        return FALSE;
3276
+    }
3277
+    if( empty( $this->priority['value'] )) {
3278
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE;
3279
+    }
2923 3280
     $attributes = $this->_createParams( $this->priority['params'] );
2924 3281
     return $this->_createElement( 'PRIORITY', $attributes, $this->priority['value'] );
2925 3282
   }
@@ -2933,7 +3290,11 @@  discard block
 block discarded – undo
2933 3290
  * @return bool
2934 3291
  */
2935 3292
   function setPriority( $value, $params=FALSE  ) {
2936
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3293
+    if( empty( $value )) {
3294
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3295
+    } else {
3296
+        return FALSE;
3297
+    }
2937 3298
     $this->priority = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2938 3299
     return TRUE;
2939 3300
   }
@@ -2949,18 +3310,24 @@  discard block
 block discarded – undo
2949 3310
  * @return string
2950 3311
  */
2951 3312
   function createRdate() {
2952
-    if( empty( $this->rdate )) return FALSE;
3313
+    if( empty( $this->rdate )) {
3314
+        return FALSE;
3315
+    }
2953 3316
     $utctime = ( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE;
2954 3317
     $output = null;
2955
-    if( $utctime  )
2956
-      unset( $this->rdate['params']['TZID'] );
3318
+    if( $utctime  ) {
3319
+          unset( $this->rdate['params']['TZID'] );
3320
+    }
2957 3321
     foreach( $this->rdate as $theRdate ) {
2958 3322
       if( empty( $theRdate['value'] )) {
2959
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RDATE' );
3323
+        if( $this->getConfig( 'allowEmpty' )) {
3324
+            $output .= $this->_createElement( 'RDATE' );
3325
+        }
2960 3326
         continue;
2961 3327
       }
2962
-      if( $utctime  )
2963
-        unset( $theRdate['params']['TZID'] );
3328
+      if( $utctime  ) {
3329
+              unset( $theRdate['params']['TZID'] );
3330
+      }
2964 3331
       $attributes = $this->_createParams( $theRdate['params'] );
2965 3332
       $cnt = count( $theRdate['value'] );
2966 3333
       $content = null;
@@ -2969,68 +3336,84 @@  discard block
 block discarded – undo
2969 3336
         $contentPart = null;
2970 3337
         if( is_array( $rdatePart ) &&
2971 3338
             isset( $theRdate['params']['VALUE'] ) && ( 'PERIOD' == $theRdate['params']['VALUE'] )) { // PERIOD
2972
-          if( $utctime )
2973
-            unset( $rdatePart[0]['tz'] );
3339
+          if( $utctime ) {
3340
+                      unset( $rdatePart[0]['tz'] );
3341
+          }
2974 3342
           $formatted = $this->_format_date_time( $rdatePart[0]); // PERIOD part 1
2975
-          if( $utctime || !empty( $theRdate['params']['TZID'] ))
2976
-            $formatted = str_replace( 'Z', '', $formatted);
3343
+          if( $utctime || !empty( $theRdate['params']['TZID'] )) {
3344
+                      $formatted = str_replace( 'Z', '', $formatted);
3345
+          }
2977 3346
           if( 0 < $rpix ) {
2978 3347
             if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) {
2979
-              if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z';
3348
+              if( 'Z' != substr( $formatted, -1 )) {
3349
+                  $formatted .= 'Z';
3350
+              }
3351
+            } else {
3352
+                          $formatted = str_replace( 'Z', '', $formatted );
2980 3353
             }
2981
-            else
2982
-              $formatted = str_replace( 'Z', '', $formatted );
2983 3354
           }
2984 3355
           $contentPart .= $formatted;
2985 3356
           $contentPart .= '/';
2986 3357
           $cnt2 = count( $rdatePart[1]);
2987 3358
           if( array_key_exists( 'year', $rdatePart[1] )) {
2988
-            if( array_key_exists( 'hour', $rdatePart[1] ))
2989
-              $cnt2 = 7;                                      // date-time
2990
-            else
2991
-              $cnt2 = 3;                                      // date
2992
-          }
2993
-          elseif( array_key_exists( 'week', $rdatePart[1] ))  // duration
3359
+            if( array_key_exists( 'hour', $rdatePart[1] )) {
3360
+                          $cnt2 = 7;
3361
+            }
3362
+            // date-time
3363
+            else {
3364
+                          $cnt2 = 3;
3365
+            }
3366
+            // date
3367
+          } elseif( array_key_exists( 'week', $rdatePart[1] )) {
3368
+              // duration
2994 3369
             $cnt2 = 5;
3370
+          }
2995 3371
           if(( 7 == $cnt2 )   &&    // period=  -> date-time
2996 3372
               isset( $rdatePart[1]['year'] )  &&
2997 3373
               isset( $rdatePart[1]['month'] ) &&
2998 3374
               isset( $rdatePart[1]['day'] )) {
2999
-            if( $utctime )
3000
-              unset( $rdatePart[1]['tz'] );
3375
+            if( $utctime ) {
3376
+                          unset( $rdatePart[1]['tz'] );
3377
+            }
3001 3378
             $formatted = $this->_format_date_time( $rdatePart[1] ); // PERIOD part 2
3002
-            if( $utctime || !empty( $theRdate['params']['TZID'] ))
3003
-              $formatted = str_replace( 'Z', '', $formatted);
3379
+            if( $utctime || !empty( $theRdate['params']['TZID'] )) {
3380
+                          $formatted = str_replace( 'Z', '', $formatted);
3381
+            }
3004 3382
             if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) {
3005
-              if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z';
3383
+              if( 'Z' != substr( $formatted, -1 )) {
3384
+                  $formatted .= 'Z';
3385
+              }
3386
+            } else {
3387
+                          $formatted = str_replace( 'Z', '', $formatted );
3006 3388
             }
3007
-            else
3008
-              $formatted = str_replace( 'Z', '', $formatted );
3009 3389
            $contentPart .= $formatted;
3010
-          }
3011
-          else {                                  // period=  -> dur-time
3390
+          } else {                                  // period=  -> dur-time
3012 3391
             $contentPart .= $this->_format_duration( $rdatePart[1] );
3013 3392
           }
3014 3393
         } // PERIOD end
3015 3394
         else { // SINGLE date start
3016
-          if( $utctime )
3017
-            unset( $rdatePart['tz'] );
3395
+          if( $utctime ) {
3396
+                      unset( $rdatePart['tz'] );
3397
+          }
3018 3398
           $formatted = $this->_format_date_time( $rdatePart);
3019
-          if( $utctime || !empty( $theRdate['params']['TZID'] ))
3020
-            $formatted = str_replace( 'Z', '', $formatted);
3399
+          if( $utctime || !empty( $theRdate['params']['TZID'] )) {
3400
+                      $formatted = str_replace( 'Z', '', $formatted);
3401
+          }
3021 3402
           if( !$utctime && ( 0 < $rpix )) {
3022 3403
             if( !empty( $theRdate['value'][0]['tz'] ) && $this->_isOffset( $theRdate['value'][0]['tz'] )) {
3023
-              if( 'Z' != substr( $formatted, -1 ))
3024
-                $formatted .= 'Z';
3404
+              if( 'Z' != substr( $formatted, -1 )) {
3405
+                              $formatted .= 'Z';
3406
+              }
3407
+            } else {
3408
+                          $formatted = str_replace( 'Z', '', $formatted );
3025 3409
             }
3026
-            else
3027
-              $formatted = str_replace( 'Z', '', $formatted );
3028 3410
           }
3029 3411
           $contentPart .= $formatted;
3030 3412
         }
3031 3413
         $content .= $contentPart;
3032
-        if( $rno < $cnt )
3033
-          $content .= ',';
3414
+        if( $rno < $cnt ) {
3415
+                  $content .= ',';
3416
+        }
3034 3417
         $rno++;
3035 3418
       }
3036 3419
       $output    .= $this->_createElement( 'RDATE', $attributes, $content );
@@ -3052,9 +3435,9 @@  discard block
 block discarded – undo
3052 3435
       if( $this->getConfig( 'allowEmpty' )) {
3053 3436
         $this->_setMval( $this->rdate, null, $params, FALSE, $index );
3054 3437
         return TRUE;
3438
+      } else {
3439
+              return FALSE;
3055 3440
       }
3056
-      else
3057
-        return FALSE;
3058 3441
     }
3059 3442
     $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )));
3060 3443
     if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) {
@@ -3068,15 +3451,19 @@  discard block
 block discarded – undo
3068 3451
     (( is_array( $rdates[0][0] ) && ( isset( $rdates[0][0]['timestamp'] ) ||
3069 3452
                                       $this->_isArrayDate( $rdates[0][0] ))) ||
3070 3453
                                     ( is_string( $rdates[0][0] ) && ( 8 <= strlen( trim( $rdates[0][0] )))))  &&
3071
-     ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] ))))))
3072
-      $input['params']['VALUE'] = 'PERIOD';
3454
+     ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] )))))) {
3455
+          $input['params']['VALUE'] = 'PERIOD';
3456
+    }
3073 3457
             /* check 1:st date, upd. $parno (opt) and save ev. timezone **/
3074 3458
     $date  = reset( $rdates );
3075
-    if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) // PERIOD
3459
+    if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) {
3460
+        // PERIOD
3076 3461
       $date  = reset( $date );
3462
+    }
3077 3463
     $this->_chkdatecfg( $date, $parno, $input['params'] );
3078
-    if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' )))
3079
-      unset( $input['params']['TZID'] );
3464
+    if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) {
3465
+          unset( $input['params']['TZID'] );
3466
+    }
3080 3467
     $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default
3081 3468
     foreach( $rdates as $rpix => $theRdate ) {
3082 3469
       $inputa = null;
@@ -3084,48 +3471,60 @@  discard block
 block discarded – undo
3084 3471
         if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) { // PERIOD
3085 3472
           foreach( $theRdate as $rix => $rPeriod ) {
3086 3473
             if( is_array( $rPeriod )) {
3087
-              if( $this->_isArrayTimestampDate( $rPeriod ))      // timestamp
3474
+              if( $this->_isArrayTimestampDate( $rPeriod )) {
3475
+                  // timestamp
3088 3476
                 $inputab  = ( isset( $rPeriod['tz'] )) ? $this->_timestamp2date( $rPeriod, $parno ) : $this->_timestamp2date( $rPeriod, 6 );
3089
-              elseif( $this->_isArrayDate( $rPeriod ))
3090
-                $inputab  = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 );
3091
-              elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod ))))  // text-date
3477
+              } elseif( $this->_isArrayDate( $rPeriod )) {
3478
+                              $inputab  = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 );
3479
+              } elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod )))) {
3480
+                  // text-date
3092 3481
                 $inputab  = $this->_date_time_string( reset( $rPeriod ), $parno );
3093
-              else                                               // array format duration
3482
+              } else {
3483
+                  // array format duration
3094 3484
                 $inputab  = $this->_duration_array( $rPeriod );
3095
-            }
3096
-            elseif(( 3 <= strlen( trim( $rPeriod ))) &&          // string format duration
3485
+              }
3486
+            } elseif(( 3 <= strlen( trim( $rPeriod ))) &&          // string format duration
3097 3487
                    ( in_array( $rPeriod{0}, array( 'P', '+', '-' )))) {
3098
-              if( 'P' != $rPeriod{0} )
3099
-                $rPeriod  = substr( $rPeriod, 1 );
3488
+              if( 'P' != $rPeriod{0} ) {
3489
+                              $rPeriod  = substr( $rPeriod, 1 );
3490
+              }
3100 3491
               $inputab    = $this->_duration_string( $rPeriod );
3101
-            }
3102
-            elseif( 8 <= strlen( trim( $rPeriod )))              // text date ex. 2006-08-03 10:12:18
3492
+            } elseif( 8 <= strlen( trim( $rPeriod ))) {
3493
+                // text date ex. 2006-08-03 10:12:18
3103 3494
               $inputab    = $this->_date_time_string( $rPeriod, $parno );
3495
+            }
3104 3496
             if(  isset( $input['params']['TZID'] ) ||
3105 3497
                ( isset( $inputab['tz'] )   && !$this->_isOffset( $inputab['tz'] )) ||
3106 3498
                ( isset( $inputa[0] )       && ( !isset( $inputa[0]['tz'] )))       ||
3107
-               ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] )))
3108
-              unset( $inputab['tz'] );
3499
+               ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] ))) {
3500
+                          unset( $inputab['tz'] );
3501
+            }
3109 3502
             $inputa[]     = $inputab;
3110 3503
           }
3111 3504
         } // PERIOD end
3112
-        elseif ( $this->_isArrayTimestampDate( $theRdate ))      // timestamp
3505
+        elseif ( $this->_isArrayTimestampDate( $theRdate )) {
3506
+            // timestamp
3113 3507
           $inputa = $this->_timestamp2date( $theRdate, $parno );
3114
-        else                                                     // date[-time]
3508
+        } else {
3509
+            // date[-time]
3115 3510
           $inputa = $this->_date_time_array( $theRdate, $parno );
3116
-      }
3117
-      elseif( 8 <= strlen( trim( $theRdate )))                   // text date ex. 2006-08-03 10:12:18
3511
+        }
3512
+      } elseif( 8 <= strlen( trim( $theRdate ))) {
3513
+          // text date ex. 2006-08-03 10:12:18
3118 3514
         $inputa       = $this->_date_time_string( $theRdate, $parno );
3515
+      }
3119 3516
       if( !isset( $input['params']['VALUE'] ) || ( 'PERIOD' != $input['params']['VALUE'] )) { // no PERIOD
3120
-        if( 3 == $parno )
3121
-          unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] );
3122
-        elseif( isset( $inputa['tz'] ))
3123
-          $inputa['tz'] = (string) $inputa['tz'];
3517
+        if( 3 == $parno ) {
3518
+                  unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] );
3519
+        } elseif( isset( $inputa['tz'] )) {
3520
+                  $inputa['tz'] = (string) $inputa['tz'];
3521
+        }
3124 3522
         if(  isset( $input['params']['TZID'] ) ||
3125 3523
            ( isset( $inputa['tz'] )            && !$this->_isOffset( $inputa['tz'] ))     ||
3126 3524
            ( isset( $input['value'][0] )       && ( !isset( $input['value'][0]['tz'] )))  ||
3127
-           ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] )))
3128
-          unset( $inputa['tz'] );
3525
+           ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) {
3526
+                  unset( $inputa['tz'] );
3527
+        }
3129 3528
       }
3130 3529
       $input['value'][] = $inputa;
3131 3530
     }
@@ -3148,9 +3547,12 @@  discard block
 block discarded – undo
3148 3547
  * @return string
3149 3548
  */
3150 3549
   function createRecurrenceid() {
3151
-    if( empty( $this->recurrenceid )) return FALSE;
3152
-    if( empty( $this->recurrenceid['value'] ))
3153
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE;
3550
+    if( empty( $this->recurrenceid )) {
3551
+        return FALSE;
3552
+    }
3553
+    if( empty( $this->recurrenceid['value'] )) {
3554
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE;
3555
+    }
3154 3556
     $formatted  = $this->_format_date_time( $this->recurrenceid['value'] );
3155 3557
     $attributes = $this->_createParams( $this->recurrenceid['params'] );
3156 3558
     return $this->_createElement( 'RECURRENCE-ID', $attributes, $formatted );
@@ -3174,9 +3576,9 @@  discard block
 block discarded – undo
3174 3576
       if( $this->getConfig( 'allowEmpty' )) {
3175 3577
         $this->recurrenceid = array( 'value' => null, 'params' => null );
3176 3578
         return TRUE;
3579
+      } else {
3580
+              return FALSE;
3177 3581
       }
3178
-      else
3179
-        return FALSE;
3180 3582
     }
3181 3583
     $this->recurrenceid = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params );
3182 3584
     return TRUE;
@@ -3193,11 +3595,15 @@  discard block
 block discarded – undo
3193 3595
  * @return string
3194 3596
  */
3195 3597
   function createRelatedTo() {
3196
-    if( empty( $this->relatedto )) return FALSE;
3598
+    if( empty( $this->relatedto )) {
3599
+        return FALSE;
3600
+    }
3197 3601
     $output = null;
3198 3602
     foreach( $this->relatedto as $relation ) {
3199 3603
       if( empty( $relation['value'] )) {
3200
-        if( $this->getConfig( 'allowEmpty' )) $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] ));
3604
+        if( $this->getConfig( 'allowEmpty' )) {
3605
+            $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] ));
3606
+        }
3201 3607
         continue;
3202 3608
       }
3203 3609
       $attributes = $this->_createParams( $relation['params'] );
@@ -3219,9 +3625,14 @@  discard block
 block discarded – undo
3219 3625
  * @return bool
3220 3626
  */
3221 3627
   function setRelatedTo( $value, $params=FALSE, $index=FALSE ) {
3222
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3223
-    if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 )))
3224
-      $value = substr( $value, 1, ( strlen( $value ) - 2 ));
3628
+    if( empty( $value )) {
3629
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3630
+    } else {
3631
+        return FALSE;
3632
+    }
3633
+    if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 ))) {
3634
+          $value = substr( $value, 1, ( strlen( $value ) - 2 ));
3635
+    }
3225 3636
     $this->_existRem( $params, 'RELTYPE', 'PARENT', TRUE ); // remove default
3226 3637
     $this->_setMval( $this->relatedto, $value, $params, FALSE, $index );
3227 3638
     return TRUE;
@@ -3238,9 +3649,12 @@  discard block
 block discarded – undo
3238 3649
  * @return string
3239 3650
  */
3240 3651
   function createRepeat() {
3241
-    if( empty( $this->repeat )) return FALSE;
3242
-    if( empty( $this->repeat['value'] ))
3243
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE;
3652
+    if( empty( $this->repeat )) {
3653
+        return FALSE;
3654
+    }
3655
+    if( empty( $this->repeat['value'] )) {
3656
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE;
3657
+    }
3244 3658
     $attributes = $this->_createParams( $this->repeat['params'] );
3245 3659
     return $this->_createElement( 'REPEAT', $attributes, $this->repeat['value'] );
3246 3660
   }
@@ -3254,7 +3668,11 @@  discard block
 block discarded – undo
3254 3668
  * @return void
3255 3669
  */
3256 3670
   function setRepeat( $value, $params=FALSE ) {
3257
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3671
+    if( empty( $value )) {
3672
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3673
+    } else {
3674
+        return FALSE;
3675
+    }
3258 3676
     $this->repeat = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3259 3677
     return TRUE;
3260 3678
   }
@@ -3269,18 +3687,23 @@  discard block
 block discarded – undo
3269 3687
  * @return string
3270 3688
  */
3271 3689
   function createRequestStatus() {
3272
-    if( empty( $this->requeststatus )) return FALSE;
3690
+    if( empty( $this->requeststatus )) {
3691
+        return FALSE;
3692
+    }
3273 3693
     $output = null;
3274 3694
     foreach( $this->requeststatus as $rstat ) {
3275 3695
       if( empty( $rstat['value']['statcode'] )) {
3276
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'REQUEST-STATUS' );
3696
+        if( $this->getConfig( 'allowEmpty' )) {
3697
+            $output .= $this->_createElement( 'REQUEST-STATUS' );
3698
+        }
3277 3699
         continue;
3278 3700
       }
3279 3701
       $attributes  = $this->_createParams( $rstat['params'], array( 'LANGUAGE' ));
3280 3702
       $content     = number_format( (float) $rstat['value']['statcode'], 2, '.', '');
3281 3703
       $content    .= ';'.$this->_strrep( $rstat['value']['text'] );
3282
-      if( isset( $rstat['value']['extdata'] ))
3283
-        $content  .= ';'.$this->_strrep( $rstat['value']['extdata'] );
3704
+      if( isset( $rstat['value']['extdata'] )) {
3705
+              $content  .= ';'.$this->_strrep( $rstat['value']['extdata'] );
3706
+      }
3284 3707
       $output     .= $this->_createElement( 'REQUEST-STATUS', $attributes, $content );
3285 3708
     }
3286 3709
     return $output;
@@ -3298,10 +3721,15 @@  discard block
 block discarded – undo
3298 3721
  * @return bool
3299 3722
  */
3300 3723
   function setRequestStatus( $statcode, $text, $extdata=FALSE, $params=FALSE, $index=FALSE ) {
3301
-    if( empty( $statcode ) || empty( $text )) if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null; else return FALSE;
3724
+    if( empty( $statcode ) || empty( $text )) {
3725
+        if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null;
3726
+    } else {
3727
+        return FALSE;
3728
+    }
3302 3729
     $input              = array( 'statcode' => $statcode, 'text' => $text );
3303
-    if( $extdata )
3304
-      $input['extdata'] = $extdata;
3730
+    if( $extdata ) {
3731
+          $input['extdata'] = $extdata;
3732
+    }
3305 3733
     $this->_setMval( $this->requeststatus, $input, $params, FALSE, $index );
3306 3734
     return TRUE;
3307 3735
   }
@@ -3317,21 +3745,26 @@  discard block
 block discarded – undo
3317 3745
  * @return string
3318 3746
  */
3319 3747
   function createResources() {
3320
-    if( empty( $this->resources )) return FALSE;
3748
+    if( empty( $this->resources )) {
3749
+        return FALSE;
3750
+    }
3321 3751
     $output = null;
3322 3752
     foreach( $this->resources as $resource ) {
3323 3753
       if( empty( $resource['value'] )) {
3324
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RESOURCES' );
3754
+        if( $this->getConfig( 'allowEmpty' )) {
3755
+            $output .= $this->_createElement( 'RESOURCES' );
3756
+        }
3325 3757
         continue;
3326 3758
       }
3327 3759
       $attributes  = $this->_createParams( $resource['params'], array( 'ALTREP', 'LANGUAGE' ));
3328 3760
       if( is_array( $resource['value'] )) {
3329
-        foreach( $resource['value'] as $rix => $resourcePart )
3330
-          $resource['value'][$rix] = $this->_strrep( $resourcePart );
3761
+        foreach( $resource['value'] as $rix => $resourcePart ) {
3762
+                  $resource['value'][$rix] = $this->_strrep( $resourcePart );
3763
+        }
3331 3764
         $content   = implode( ',', $resource['value'] );
3765
+      } else {
3766
+              $content   = $this->_strrep( $resource['value'] );
3332 3767
       }
3333
-      else
3334
-        $content   = $this->_strrep( $resource['value'] );
3335 3768
       $output     .= $this->_createElement( 'RESOURCES', $attributes, $content );
3336 3769
     }
3337 3770
     return $output;
@@ -3347,7 +3780,11 @@  discard block
 block discarded – undo
3347 3780
  * @return bool
3348 3781
  */
3349 3782
   function setResources( $value, $params=FALSE, $index=FALSE ) {
3350
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3783
+    if( empty( $value )) {
3784
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3785
+    } else {
3786
+        return FALSE;
3787
+    }
3351 3788
     $this->_setMval( $this->resources, $value, $params, FALSE, $index );
3352 3789
     return TRUE;
3353 3790
   }
@@ -3363,7 +3800,9 @@  discard block
 block discarded – undo
3363 3800
  * @return string
3364 3801
  */
3365 3802
   function createRrule() {
3366
-    if( empty( $this->rrule )) return FALSE;
3803
+    if( empty( $this->rrule )) {
3804
+        return FALSE;
3805
+    }
3367 3806
     return $this->_format_recur( 'RRULE', $this->rrule );
3368 3807
   }
3369 3808
 /**
@@ -3377,7 +3816,11 @@  discard block
 block discarded – undo
3377 3816
  * @return void
3378 3817
  */
3379 3818
   function setRrule( $rruleset, $params=FALSE, $index=FALSE ) {
3380
-    if( empty( $rruleset )) if( $this->getConfig( 'allowEmpty' )) $rruleset = null; else return FALSE;
3819
+    if( empty( $rruleset )) {
3820
+        if( $this->getConfig( 'allowEmpty' )) $rruleset = null;
3821
+    } else {
3822
+        return FALSE;
3823
+    }
3381 3824
     $this->_setMval( $this->rrule, $this->_setRexrule( $rruleset ), $params, FALSE, $index );
3382 3825
     return TRUE;
3383 3826
   }
@@ -3392,9 +3835,12 @@  discard block
 block discarded – undo
3392 3835
  * @return string
3393 3836
  */
3394 3837
   function createSequence() {
3395
-    if( empty( $this->sequence )) return FALSE;
3396
-    if( empty( $this->sequence['value'] ))
3397
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE;
3838
+    if( empty( $this->sequence )) {
3839
+        return FALSE;
3840
+    }
3841
+    if( empty( $this->sequence['value'] )) {
3842
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE;
3843
+    }
3398 3844
     $attributes = $this->_createParams( $this->sequence['params'] );
3399 3845
     return $this->_createElement( 'SEQUENCE', $attributes, $this->sequence['value'] );
3400 3846
   }
@@ -3407,8 +3853,9 @@  discard block
 block discarded – undo
3407 3853
  * @return bool
3408 3854
  */
3409 3855
   function setSequence( $value=FALSE, $params=FALSE ) {
3410
-    if( empty( $value ))
3411
-      $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1;
3856
+    if( empty( $value )) {
3857
+          $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1;
3858
+    }
3412 3859
     $this->sequence = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3413 3860
     return TRUE;
3414 3861
   }
@@ -3424,9 +3871,12 @@  discard block
 block discarded – undo
3424 3871
  * @return string
3425 3872
  */
3426 3873
   function createStatus() {
3427
-    if( empty( $this->status )) return FALSE;
3428
-    if( empty( $this->status['value'] ))
3429
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE;
3874
+    if( empty( $this->status )) {
3875
+        return FALSE;
3876
+    }
3877
+    if( empty( $this->status['value'] )) {
3878
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE;
3879
+    }
3430 3880
     $attributes = $this->_createParams( $this->status['params'] );
3431 3881
     return $this->_createElement( 'STATUS', $attributes, $this->status['value'] );
3432 3882
   }
@@ -3440,7 +3890,11 @@  discard block
 block discarded – undo
3440 3890
  * @return bool
3441 3891
  */
3442 3892
   function setStatus( $value, $params=FALSE ) {
3443
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3893
+    if( empty( $value )) {
3894
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3895
+    } else {
3896
+        return FALSE;
3897
+    }
3444 3898
     $this->status = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3445 3899
     return TRUE;
3446 3900
   }
@@ -3456,9 +3910,12 @@  discard block
 block discarded – undo
3456 3910
  * @return string
3457 3911
  */
3458 3912
   function createSummary() {
3459
-    if( empty( $this->summary )) return FALSE;
3460
-    if( empty( $this->summary['value'] ))
3461
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE;
3913
+    if( empty( $this->summary )) {
3914
+        return FALSE;
3915
+    }
3916
+    if( empty( $this->summary['value'] )) {
3917
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE;
3918
+    }
3462 3919
     $attributes = $this->_createParams( $this->summary['params'], array( 'ALTREP', 'LANGUAGE' ));
3463 3920
     $content    = $this->_strrep( $this->summary['value'] );
3464 3921
     return $this->_createElement( 'SUMMARY', $attributes, $content );
@@ -3473,7 +3930,11 @@  discard block
 block discarded – undo
3473 3930
  * @return bool
3474 3931
  */
3475 3932
   function setSummary( $value, $params=FALSE ) {
3476
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3933
+    if( empty( $value )) {
3934
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3935
+    } else {
3936
+        return FALSE;
3937
+    }
3477 3938
     $this->summary = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3478 3939
     return TRUE;
3479 3940
   }
@@ -3489,9 +3950,12 @@  discard block
 block discarded – undo
3489 3950
  * @return string
3490 3951
  */
3491 3952
   function createTransp() {
3492
-    if( empty( $this->transp )) return FALSE;
3493
-    if( empty( $this->transp['value'] ))
3494
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE;
3953
+    if( empty( $this->transp )) {
3954
+        return FALSE;
3955
+    }
3956
+    if( empty( $this->transp['value'] )) {
3957
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE;
3958
+    }
3495 3959
     $attributes = $this->_createParams( $this->transp['params'] );
3496 3960
     return $this->_createElement( 'TRANSP', $attributes, $this->transp['value'] );
3497 3961
   }
@@ -3505,7 +3969,11 @@  discard block
 block discarded – undo
3505 3969
  * @return bool
3506 3970
  */
3507 3971
   function setTransp( $value, $params=FALSE ) {
3508
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3972
+    if( empty( $value )) {
3973
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
3974
+    } else {
3975
+        return FALSE;
3976
+    }
3509 3977
     $this->transp = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3510 3978
     return TRUE;
3511 3979
   }
@@ -3521,19 +3989,24 @@  discard block
 block discarded – undo
3521 3989
  * @return string
3522 3990
  */
3523 3991
   function createTrigger() {
3524
-    if( empty( $this->trigger )) return FALSE;
3525
-    if( empty( $this->trigger['value'] ))
3526
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE;
3992
+    if( empty( $this->trigger )) {
3993
+        return FALSE;
3994
+    }
3995
+    if( empty( $this->trigger['value'] )) {
3996
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE;
3997
+    }
3527 3998
     $content = $attributes = null;
3528 3999
     if( isset( $this->trigger['value']['year'] )   &&
3529 4000
         isset( $this->trigger['value']['month'] )  &&
3530
-        isset( $this->trigger['value']['day'] ))
3531
-      $content      .= $this->_format_date_time( $this->trigger['value'] );
3532
-    else {
3533
-      if( TRUE !== $this->trigger['value']['relatedStart'] )
3534
-        $attributes .= $this->intAttrDelimiter.'RELATED=END';
3535
-      if( $this->trigger['value']['before'] )
3536
-        $content    .= '-';
4001
+        isset( $this->trigger['value']['day'] )) {
4002
+          $content      .= $this->_format_date_time( $this->trigger['value'] );
4003
+    } else {
4004
+      if( TRUE !== $this->trigger['value']['relatedStart'] ) {
4005
+              $attributes .= $this->intAttrDelimiter.'RELATED=END';
4006
+      }
4007
+      if( $this->trigger['value']['before'] ) {
4008
+              $content    .= '-';
4009
+      }
3537 4010
       $content      .= $this->_format_duration( $this->trigger['value'] );
3538 4011
     }
3539 4012
     $attributes     .= $this->_createParams( $this->trigger['params'] );
@@ -3557,28 +4030,30 @@  discard block
 block discarded – undo
3557 4030
  * @return bool
3558 4031
  */
3559 4032
   function setTrigger( $year, $month=null, $day=null, $week=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $relatedStart=TRUE, $before=TRUE, $params=FALSE ) {
3560
-    if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec ))
3561
-      if( $this->getConfig( 'allowEmpty' )) {
4033
+    if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec )) {
4034
+          if( $this->getConfig( 'allowEmpty' )) {
3562 4035
         $this->trigger = array( 'value' => null, 'params' => $this->_setParams( $params ) );
4036
+    }
3563 4037
         return TRUE;
4038
+      } else {
4039
+              return FALSE;
3564 4040
       }
3565
-      else
3566
-        return FALSE;
3567 4041
     if( $this->_isArrayTimestampDate( $year )) { // timestamp
3568 4042
       $params = $this->_setParams( $month );
3569 4043
       $date   = $this->_timestamp2date( $year, 7 );
3570
-      foreach( $date as $k => $v )
3571
-        $$k = $v;
3572
-    }
3573
-    elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) {
4044
+      foreach( $date as $k => $v ) {
4045
+              $$k = $v;
4046
+      }
4047
+    } elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) {
3574 4048
       $params = $this->_setParams( $month );
3575 4049
       if(!(array_key_exists( 'year',  $year ) &&   // exclude date-time
3576 4050
            array_key_exists( 'month', $year ) &&
3577 4051
            array_key_exists( 'day',   $year ))) {  // so this must be a duration
3578
-        if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] ))
3579
-          $relatedStart = FALSE;
3580
-        else
3581
-          $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE;
4052
+        if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) {
4053
+                  $relatedStart = FALSE;
4054
+        } else {
4055
+                  $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE;
4056
+        }
3582 4057
         $before         = ( array_key_exists( 'before', $year )       && ( TRUE !== $year['before'] ))       ? FALSE : TRUE;
3583 4058
       }
3584 4059
       $SSYY  = ( array_key_exists( 'year',  $year )) ? $year['year']  : null;
@@ -3589,24 +4064,27 @@  discard block
 block discarded – undo
3589 4064
       $min   = ( array_key_exists( 'min',   $year )) ? $year['min']   : 0; //null;
3590 4065
       $sec   = ( array_key_exists( 'sec',   $year )) ? $year['sec']   : 0; //null;
3591 4066
       $year  = $SSYY;
3592
-    }
3593
-    elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) {  // duration or date in a string
4067
+    } elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) {  // duration or date in a string
3594 4068
       $params = $this->_setParams( $month );
3595 4069
       if( in_array( $year{0}, array( 'P', '+', '-' ))) { // duration
3596 4070
         $relatedStart = ( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) ? FALSE : TRUE;
3597 4071
         $before       = ( '-'  == $year{0} ) ? TRUE : FALSE;
3598
-        if(     'P'  != $year{0} )
3599
-          $year       = substr( $year, 1 );
4072
+        if(     'P'  != $year{0} ) {
4073
+                  $year       = substr( $year, 1 );
4074
+        }
3600 4075
         $date         = $this->_duration_string( $year);
3601
-      }
3602
-      else   // date
4076
+      } else {
4077
+          // date
3603 4078
         $date    = $this->_date_time_string( $year, 7 );
4079
+      }
3604 4080
       unset( $year, $month, $day );
3605
-      foreach( $date as $k => $v )
3606
-        $$k = $v;
3607
-    }
3608
-    else // single values in function input parameters
4081
+      foreach( $date as $k => $v ) {
4082
+              $$k = $v;
4083
+      }
4084
+    } else {
4085
+        // single values in function input parameters
3609 4086
       $params = $this->_setParams( $params );
4087
+    }
3610 4088
     if( !empty( $year ) && !empty( $month ) && !empty( $day )) { // date
3611 4089
       $params['VALUE'] = 'DATE-TIME';
3612 4090
       $hour = ( $hour ) ? $hour : 0;
@@ -3621,8 +4099,7 @@  discard block
 block discarded – undo
3621 4099
                                      , 'sec'   => $sec
3622 4100
                                      , 'tz'    => 'Z' );
3623 4101
       return TRUE;
3624
-    }
3625
-    elseif(( empty( $year ) && empty( $month )) &&    // duration
4102
+    } elseif(( empty( $year ) && empty( $month )) &&    // duration
3626 4103
            (!empty( $week ) || !empty( $day ) || !empty( $hour ) || !empty( $min ) || !empty( $sec ))) {
3627 4104
       unset( $params['RELATED'] ); // set at output creation (END only)
3628 4105
       unset( $params['VALUE'] );   // 'DURATION' default
@@ -3631,11 +4108,21 @@  discard block
 block discarded – undo
3631 4108
       $before       = ( FALSE !== $before )       ? TRUE : FALSE;
3632 4109
       $this->trigger['value']  = array( 'relatedStart' => $relatedStart
3633 4110
                                       , 'before'       => $before );
3634
-      if( !empty( $week )) $this->trigger['value']['week'] = $week;
3635
-      if( !empty( $day  )) $this->trigger['value']['day']  = $day;
3636
-      if( !empty( $hour )) $this->trigger['value']['hour'] = $hour;
3637
-      if( !empty( $min  )) $this->trigger['value']['min']  = $min;
3638
-      if( !empty( $sec  )) $this->trigger['value']['sec']  = $sec;
4111
+      if( !empty( $week )) {
4112
+          $this->trigger['value']['week'] = $week;
4113
+      }
4114
+      if( !empty( $day  )) {
4115
+          $this->trigger['value']['day']  = $day;
4116
+      }
4117
+      if( !empty( $hour )) {
4118
+          $this->trigger['value']['hour'] = $hour;
4119
+      }
4120
+      if( !empty( $min  )) {
4121
+          $this->trigger['value']['min']  = $min;
4122
+      }
4123
+      if( !empty( $sec  )) {
4124
+          $this->trigger['value']['sec']  = $sec;
4125
+      }
3639 4126
       return TRUE;
3640 4127
     }
3641 4128
     return FALSE;
@@ -3652,9 +4139,12 @@  discard block
 block discarded – undo
3652 4139
  * @return string
3653 4140
  */
3654 4141
   function createTzid() {
3655
-    if( empty( $this->tzid )) return FALSE;
3656
-    if( empty( $this->tzid['value'] ))
3657
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE;
4142
+    if( empty( $this->tzid )) {
4143
+        return FALSE;
4144
+    }
4145
+    if( empty( $this->tzid['value'] )) {
4146
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE;
4147
+    }
3658 4148
     $attributes = $this->_createParams( $this->tzid['params'] );
3659 4149
     return $this->_createElement( 'TZID', $attributes, $this->_strrep( $this->tzid['value'] ));
3660 4150
   }
@@ -3668,7 +4158,11 @@  discard block
 block discarded – undo
3668 4158
  * @return bool
3669 4159
  */
3670 4160
   function setTzid( $value, $params=FALSE ) {
3671
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4161
+    if( empty( $value )) {
4162
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
4163
+    } else {
4164
+        return FALSE;
4165
+    }
3672 4166
     $this->tzid = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3673 4167
     return TRUE;
3674 4168
   }
@@ -3685,14 +4179,17 @@  discard block
 block discarded – undo
3685 4179
  * @return string
3686 4180
  */
3687 4181
   function createTzname() {
3688
-    if( empty( $this->tzname )) return FALSE;
4182
+    if( empty( $this->tzname )) {
4183
+        return FALSE;
4184
+    }
3689 4185
     $output = null;
3690 4186
     foreach( $this->tzname as $theName ) {
3691 4187
       if( !empty( $theName['value'] )) {
3692 4188
         $attributes = $this->_createParams( $theName['params'], array( 'LANGUAGE' ));
3693 4189
         $output    .= $this->_createElement( 'TZNAME', $attributes, $this->_strrep( $theName['value'] ));
4190
+      } elseif( $this->getConfig( 'allowEmpty' )) {
4191
+          $output .= $this->_createElement( 'TZNAME' );
3694 4192
       }
3695
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'TZNAME' );
3696 4193
     }
3697 4194
     return $output;
3698 4195
   }
@@ -3707,7 +4204,11 @@  discard block
 block discarded – undo
3707 4204
  * @return bool
3708 4205
  */
3709 4206
   function setTzname( $value, $params=FALSE, $index=FALSE ) {
3710
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4207
+    if( empty( $value )) {
4208
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
4209
+    } else {
4210
+        return FALSE;
4211
+    }
3711 4212
     $this->_setMval( $this->tzname, $value, $params, FALSE, $index );
3712 4213
     return TRUE;
3713 4214
   }
@@ -3723,9 +4224,12 @@  discard block
 block discarded – undo
3723 4224
  * @return string
3724 4225
  */
3725 4226
   function createTzoffsetfrom() {
3726
-    if( empty( $this->tzoffsetfrom )) return FALSE;
3727
-    if( empty( $this->tzoffsetfrom['value'] ))
3728
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE;
4227
+    if( empty( $this->tzoffsetfrom )) {
4228
+        return FALSE;
4229
+    }
4230
+    if( empty( $this->tzoffsetfrom['value'] )) {
4231
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE;
4232
+    }
3729 4233
     $attributes = $this->_createParams( $this->tzoffsetfrom['params'] );
3730 4234
     return $this->_createElement( 'TZOFFSETFROM', $attributes, $this->tzoffsetfrom['value'] );
3731 4235
   }
@@ -3739,7 +4243,11 @@  discard block
 block discarded – undo
3739 4243
  * @return bool
3740 4244
  */
3741 4245
   function setTzoffsetfrom( $value, $params=FALSE ) {
3742
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4246
+    if( empty( $value )) {
4247
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
4248
+    } else {
4249
+        return FALSE;
4250
+    }
3743 4251
     $this->tzoffsetfrom = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3744 4252
     return TRUE;
3745 4253
   }
@@ -3755,9 +4263,12 @@  discard block
 block discarded – undo
3755 4263
  * @return string
3756 4264
  */
3757 4265
   function createTzoffsetto() {
3758
-    if( empty( $this->tzoffsetto )) return FALSE;
3759
-    if( empty( $this->tzoffsetto['value'] ))
3760
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE;
4266
+    if( empty( $this->tzoffsetto )) {
4267
+        return FALSE;
4268
+    }
4269
+    if( empty( $this->tzoffsetto['value'] )) {
4270
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE;
4271
+    }
3761 4272
     $attributes = $this->_createParams( $this->tzoffsetto['params'] );
3762 4273
     return $this->_createElement( 'TZOFFSETTO', $attributes, $this->tzoffsetto['value'] );
3763 4274
   }
@@ -3771,7 +4282,11 @@  discard block
 block discarded – undo
3771 4282
  * @return bool
3772 4283
  */
3773 4284
   function setTzoffsetto( $value, $params=FALSE ) {
3774
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4285
+    if( empty( $value )) {
4286
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
4287
+    } else {
4288
+        return FALSE;
4289
+    }
3775 4290
     $this->tzoffsetto = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3776 4291
     return TRUE;
3777 4292
   }
@@ -3787,9 +4302,12 @@  discard block
 block discarded – undo
3787 4302
  * @return string
3788 4303
  */
3789 4304
   function createTzurl() {
3790
-    if( empty( $this->tzurl )) return FALSE;
3791
-    if( empty( $this->tzurl['value'] ))
3792
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE;
4305
+    if( empty( $this->tzurl )) {
4306
+        return FALSE;
4307
+    }
4308
+    if( empty( $this->tzurl['value'] )) {
4309
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE;
4310
+    }
3793 4311
     $attributes = $this->_createParams( $this->tzurl['params'] );
3794 4312
     return $this->_createElement( 'TZURL', $attributes, $this->tzurl['value'] );
3795 4313
   }
@@ -3803,7 +4321,11 @@  discard block
 block discarded – undo
3803 4321
  * @return boll
3804 4322
  */
3805 4323
   function setTzurl( $value, $params=FALSE ) {
3806
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4324
+    if( empty( $value )) {
4325
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
4326
+    } else {
4327
+        return FALSE;
4328
+    }
3807 4329
     $this->tzurl = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3808 4330
     return TRUE;
3809 4331
   }
@@ -3819,8 +4341,9 @@  discard block
 block discarded – undo
3819 4341
  * @return string
3820 4342
  */
3821 4343
   function createUid() {
3822
-    if( 0 >= count( $this->uid ))
3823
-      $this->_makeuid();
4344
+    if( 0 >= count( $this->uid )) {
4345
+          $this->_makeuid();
4346
+    }
3824 4347
     $attributes = $this->_createParams( $this->uid['params'] );
3825 4348
     return $this->_createElement( 'UID', $attributes, $this->uid['value'] );
3826 4349
   }
@@ -3839,8 +4362,9 @@  discard block
 block discarded – undo
3839 4362
     $end    = strlen( $base ) - 1;
3840 4363
     $length = 6;
3841 4364
     $str    = null;
3842
-    for( $p = 0; $p < $length; $p++ )
3843
-      $unique .= $base{mt_rand( $start, $end )};
4365
+    for( $p = 0; $p < $length; $p++ ) {
4366
+          $unique .= $base{mt_rand( $start, $end )};
4367
+    }
3844 4368
     $this->uid = array( 'params' => null );
3845 4369
     $this->uid['value']  = $date.'-'.$unique.'@'.$this->getConfig( 'unique_id' );
3846 4370
   }
@@ -3854,7 +4378,10 @@  discard block
 block discarded – undo
3854 4378
  * @return bool
3855 4379
  */
3856 4380
   function setUid( $value, $params=FALSE ) {
3857
-    if( empty( $value )) return FALSE; // no allowEmpty check here !!!!
4381
+    if( empty( $value )) {
4382
+        return FALSE;
4383
+    }
4384
+    // no allowEmpty check here !!!!
3858 4385
     $this->uid = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3859 4386
     return TRUE;
3860 4387
   }
@@ -3870,9 +4397,12 @@  discard block
 block discarded – undo
3870 4397
  * @return string
3871 4398
  */
3872 4399
   function createUrl() {
3873
-    if( empty( $this->url )) return FALSE;
3874
-    if( empty( $this->url['value'] ))
3875
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE;
4400
+    if( empty( $this->url )) {
4401
+        return FALSE;
4402
+    }
4403
+    if( empty( $this->url['value'] )) {
4404
+          return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE;
4405
+    }
3876 4406
     $attributes = $this->_createParams( $this->url['params'] );
3877 4407
     return $this->_createElement( 'URL', $attributes, $this->url['value'] );
3878 4408
   }
@@ -3886,7 +4416,11 @@  discard block
 block discarded – undo
3886 4416
  * @return bool
3887 4417
  */
3888 4418
   function setUrl( $value, $params=FALSE ) {
3889
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4419
+    if( empty( $value )) {
4420
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
4421
+    } else {
4422
+        return FALSE;
4423
+    }
3890 4424
     $this->url = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3891 4425
     return TRUE;
3892 4426
   }
@@ -3902,21 +4436,26 @@  discard block
 block discarded – undo
3902 4436
  * @return string
3903 4437
  */
3904 4438
   function createXprop() {
3905
-    if( empty( $this->xprop )) return FALSE;
4439
+    if( empty( $this->xprop )) {
4440
+        return FALSE;
4441
+    }
3906 4442
     $output = null;
3907 4443
     foreach( $this->xprop as $label => $xpropPart ) {
3908 4444
       if( empty( $xpropPart['value'] )) {
3909
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $label );
4445
+        if( $this->getConfig( 'allowEmpty' )) {
4446
+            $output .= $this->_createElement( $label );
4447
+        }
3910 4448
         continue;
3911 4449
       }
3912 4450
       $attributes = $this->_createParams( $xpropPart['params'], array( 'LANGUAGE' ));
3913 4451
       if( is_array( $xpropPart['value'] )) {
3914
-        foreach( $xpropPart['value'] as $pix => $theXpart )
3915
-          $xpropPart['value'][$pix] = $this->_strrep( $theXpart );
4452
+        foreach( $xpropPart['value'] as $pix => $theXpart ) {
4453
+                  $xpropPart['value'][$pix] = $this->_strrep( $theXpart );
4454
+        }
3916 4455
         $xpropPart['value']  = implode( ',', $xpropPart['value'] );
4456
+      } else {
4457
+              $xpropPart['value'] = $this->_strrep( $xpropPart['value'] );
3917 4458
       }
3918
-      else
3919
-        $xpropPart['value'] = $this->_strrep( $xpropPart['value'] );
3920 4459
       $output    .= $this->_createElement( $label, $attributes, $xpropPart['value'] );
3921 4460
     }
3922 4461
     return $output;
@@ -3932,12 +4471,20 @@  discard block
 block discarded – undo
3932 4471
  * @return bool
3933 4472
  */
3934 4473
   function setXprop( $label, $value, $params=FALSE ) {
3935
-    if( empty( $label )) return;
3936
-    if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4474
+    if( empty( $label )) {
4475
+        return;
4476
+    }
4477
+    if( empty( $value )) {
4478
+        if( $this->getConfig( 'allowEmpty' )) $value = null;
4479
+    } else {
4480
+        return FALSE;
4481
+    }
3937 4482
     $xprop           = array( 'value' => $value );
3938 4483
     $toolbox         = new calendarComponent();
3939 4484
     $xprop['params'] = $toolbox->_setParams( $params );
3940
-    if( !is_array( $this->xprop )) $this->xprop = array();
4485
+    if( !is_array( $this->xprop )) {
4486
+        $this->xprop = array();
4487
+    }
3941 4488
     $this->xprop[strtoupper( $label )] = $xprop;
3942 4489
     return TRUE;
3943 4490
   }
@@ -4005,30 +4552,29 @@  discard block
 block discarded – undo
4005 4552
         $attributes  = null;
4006 4553
         foreach( $attributes2 as $attribute ) {
4007 4554
           $attrKVarr = explode( '=', $attribute );
4008
-          if( empty( $attrKVarr[0] ))
4009
-            continue;
4555
+          if( empty( $attrKVarr[0] )) {
4556
+                      continue;
4557
+          }
4010 4558
           if( !isset( $attrKVarr[1] )) {
4011 4559
             $attrValue = $attrKVarr[0];
4012 4560
             $attrKey   = null;
4013
-          }
4014
-          elseif( 2 == count( $attrKVarr)) {
4561
+          } elseif( 2 == count( $attrKVarr)) {
4015 4562
             $attrKey   = strtolower( $attrKVarr[0] );
4016 4563
             $attrValue = $attrKVarr[1];
4017
-          }
4018
-          else {
4564
+          } else {
4019 4565
             $attrKey   = strtolower( $attrKVarr[0] );
4020 4566
             unset( $attrKVarr[0] );
4021 4567
             $attrValue = implode( '=', $attrKVarr );
4022 4568
           }
4023 4569
           if(( 'attach' == $label ) && ( in_array( $attrKey, array( 'fmttype', 'encoding', 'value' )))) {
4024 4570
             $attachInlineBinary = TRUE;
4025
-            if( 'fmttype' == $attrKey )
4026
-              $attachfmttype = $attrKey.'='.$attrValue;
4571
+            if( 'fmttype' == $attrKey ) {
4572
+                          $attachfmttype = $attrKey.'='.$attrValue;
4573
+            }
4027 4574
             continue;
4028
-          }
4029
-          elseif(( 'categories' == $label ) && ( 'language' == $attrKey ))
4030
-            $categoriesAttrLang = $attrKey.'='.$attrValue;
4031
-          else {
4575
+          } elseif(( 'categories' == $label ) && ( 'language' == $attrKey )) {
4576
+                      $categoriesAttrLang = $attrKey.'='.$attrValue;
4577
+          } else {
4032 4578
             $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' ';
4033 4579
             $attributes .= ( !empty( $attrKey )) ? $attrKey.'=' : null;
4034 4580
             if(( '"' == substr( $attrValue, 0, 1 )) && ( '"' == substr( $attrValue, -1 ))) {
@@ -4038,8 +4584,7 @@  discard block
 block discarded – undo
4038 4584
             $attributes .= '"'.htmlspecialchars( $attrValue ).'"';
4039 4585
           }
4040 4586
         }
4041
-      }
4042
-      else {
4587
+      } else {
4043 4588
         $attributes = str_replace( $this->intAttrDelimiter, $this->attributeDelimiter, $attributes );
4044 4589
       }
4045 4590
     }
@@ -4061,8 +4606,7 @@  discard block
 block discarded – undo
4061 4606
         $content = $this->_createElement( 'extref', $attributes, null );
4062 4607
         $attributes = null;
4063 4608
       }
4064
-    }
4065
-    elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) {
4609
+    } elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) {
4066 4610
       $content = $this->nl.$this->_createElement( 'b64bin', $attachfmttype, $content ); // max one attribute
4067 4611
     }
4068 4612
     $output .= $attributes;
@@ -4106,30 +4650,30 @@  discard block
 block discarded – undo
4106 4650
     $CNattrExist = $LANGattrExist = FALSE;
4107 4651
     if( is_array( $params )) {
4108 4652
       foreach( $params as $paramKey => $paramValue ) {
4109
-        if( is_int( $paramKey ))
4110
-          $attr2            .= $this->intAttrDelimiter.$paramValue;
4111
-        elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) {
4653
+        if( is_int( $paramKey )) {
4654
+                  $attr2            .= $this->intAttrDelimiter.$paramValue;
4655
+        } elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) {
4112 4656
           $attrLANG         .= $this->intAttrDelimiter."LANGUAGE=$paramValue";
4113 4657
           $LANGattrExist     = TRUE;
4114
-        }
4115
-        elseif(( 'CN'       == $paramKey ) && $CNattrKey ) {
4658
+        } elseif(( 'CN'       == $paramKey ) && $CNattrKey ) {
4116 4659
           $attr1             = $this->intAttrDelimiter.'CN="'.$paramValue.'"';
4117 4660
           $CNattrExist       = TRUE;
4661
+        } elseif(( 'ALTREP'   == $paramKey ) && in_array( $paramKey, $ctrKeys )) {
4662
+                  $attr2            .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"';
4663
+        } elseif(( 'DIR'      == $paramKey ) && in_array( $paramKey, $ctrKeys )) {
4664
+                  $attr2            .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"';
4665
+        } elseif(( 'SENT-BY'  == $paramKey ) && in_array( $paramKey, $ctrKeys )) {
4666
+                  $attr2            .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"';
4667
+        } else {
4668
+                  $attr2            .= $this->intAttrDelimiter."$paramKey=$paramValue";
4118 4669
         }
4119
-        elseif(( 'ALTREP'   == $paramKey ) && in_array( $paramKey, $ctrKeys ))
4120
-          $attr2            .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"';
4121
-        elseif(( 'DIR'      == $paramKey ) && in_array( $paramKey, $ctrKeys ))
4122
-          $attr2            .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"';
4123
-        elseif(( 'SENT-BY'  == $paramKey ) && in_array( $paramKey, $ctrKeys ))
4124
-          $attr2            .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"';
4125
-        else
4126
-          $attr2            .= $this->intAttrDelimiter."$paramKey=$paramValue";
4127 4670
       }
4128 4671
     }
4129 4672
     if( !$LANGattrExist ) {
4130 4673
       $lang = $this->getConfig( 'language' );
4131
-      if(( $CNattrExist || $LANGattrKey ) && $lang )
4132
-        $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang;
4674
+      if(( $CNattrExist || $LANGattrKey ) && $lang ) {
4675
+              $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang;
4676
+      }
4133 4677
     }
4134 4678
     return $attrLANG.$attr1.$attr2;
4135 4679
   }
@@ -4143,47 +4687,57 @@  discard block
 block discarded – undo
4143 4687
  * @return array $params, property parameters
4144 4688
  */
4145 4689
   function _chkdatecfg( $theDate, & $parno, & $params ) {
4146
-    if( isset( $params['TZID'] ))
4147
-      $parno = 6;
4148
-    elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))
4149
-      $parno = 3;
4150
-    else {
4151
-      if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] ))
4152
-        $parno = 7;
4690
+    if( isset( $params['TZID'] )) {
4691
+          $parno = 6;
4692
+    } elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )) {
4693
+          $parno = 3;
4694
+    } else {
4695
+      if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] )) {
4696
+              $parno = 7;
4697
+      }
4153 4698
       if( is_array( $theDate )) {
4154
-        if( isset( $theDate['timestamp'] ))
4155
-          $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null;
4156
-        else
4157
-          $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null;
4699
+        if( isset( $theDate['timestamp'] )) {
4700
+                  $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null;
4701
+        } else {
4702
+                  $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null;
4703
+        }
4158 4704
         if( !empty( $tzid )) {
4159 4705
           $parno = 7;
4160
-          if( !$this->_isOffset( $tzid ))
4161
-            $params['TZID'] = $tzid; // save only timezone
4706
+          if( !$this->_isOffset( $tzid )) {
4707
+                      $params['TZID'] = $tzid;
4708
+          }
4709
+          // save only timezone
4710
+        } elseif( !$parno && ( 3 == count( $theDate )) && 
4711
+          ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))) {
4712
+                  $parno = 3;
4713
+        } else {
4714
+                  $parno = 6;
4162 4715
         }
4163
-        elseif( !$parno && ( 3 == count( $theDate )) && 
4164
-          ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )))
4165
-          $parno = 3;
4166
-        else
4167
-          $parno = 6;
4168
-      }
4169
-      else { // string
4716
+      } else { // string
4170 4717
         $date = trim( $theDate );
4171
-        if( 'Z' == substr( $date, -1 ))
4172
-          $parno = 7; // UTC DATE-TIME
4718
+        if( 'Z' == substr( $date, -1 )) {
4719
+                  $parno = 7;
4720
+        }
4721
+        // UTC DATE-TIME
4173 4722
         elseif((( 8 == strlen( $date ) && ctype_digit( $date )) || ( 11 >= strlen( $date ))) && 
4174
-          ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' ))))
4175
-          $parno = 3; // DATE
4723
+          ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' )))) {
4724
+                  $parno = 3;
4725
+        }
4726
+        // DATE
4176 4727
         $date = $this->_date_time_string( $date, $parno );
4177 4728
         if( !empty( $date['tz'] )) {
4178 4729
           $parno = 7;
4179
-          if( !$this->_isOffset( $date['tz'] ))
4180
-            $params['TZID'] = $date['tz']; // save only timezone
4730
+          if( !$this->_isOffset( $date['tz'] )) {
4731
+                      $params['TZID'] = $date['tz'];
4732
+          }
4733
+          // save only timezone
4734
+        } elseif( empty( $parno )) {
4735
+                  $parno = 6;
4181 4736
         }
4182
-        elseif( empty( $parno ))
4183
-          $parno = 6;
4184 4737
       }
4185
-      if( isset( $params['TZID'] ))
4186
-        $parno = 6;
4738
+      if( isset( $params['TZID'] )) {
4739
+              $parno = 6;
4740
+      }
4187 4741
     }
4188 4742
   }
4189 4743
 /**
@@ -4199,14 +4753,18 @@  discard block
 block discarded – undo
4199 4753
  */
4200 4754
   function _date2duration( $startdate=FALSE, $enddate=FALSE ) {
4201 4755
     if( !$startdate || !$enddate ) {
4202
-      if(   FALSE === ( $startdate = $this->getProperty( 'dtstart' )))
4203
-        return null;
4204
-      if(   FALSE === ( $enddate   = $this->getProperty( 'dtend' )))    // vevent/vfreebusy
4756
+      if(   FALSE === ( $startdate = $this->getProperty( 'dtstart' ))) {
4757
+              return null;
4758
+      }
4759
+      if(   FALSE === ( $enddate   = $this->getProperty( 'dtend' ))) {
4760
+          // vevent/vfreebusy
4205 4761
         if( FALSE === ( $enddate   = $this->getProperty( 'due' )))      // vtodo
4206 4762
           return null;
4763
+      }
4764
+    }
4765
+    if( !$startdate || !$enddate ) {
4766
+          return null;
4207 4767
     }
4208
-    if( !$startdate || !$enddate )
4209
-      return null;
4210 4768
     $startWdate  = mktime( 0, 0, 0, $startdate['month'], $startdate['day'], $startdate['year'] );
4211 4769
     $endWdate    = mktime( 0, 0, 0, $enddate['month'],   $enddate['day'],   $enddate['year'] );
4212 4770
     $wduration   = $endWdate - $startWdate;
@@ -4232,15 +4790,23 @@  discard block
 block discarded – undo
4232 4790
  */
4233 4791
   function _date2timestamp( $datetime, $tz=null ) {
4234 4792
     $output = null;
4235
-    if( !isset( $datetime['hour'] )) $datetime['hour'] = '0';
4236
-    if( !isset( $datetime['min'] ))  $datetime['min']  = '0';
4237
-    if( !isset( $datetime['sec'] ))  $datetime['sec']  = '0';
4793
+    if( !isset( $datetime['hour'] )) {
4794
+        $datetime['hour'] = '0';
4795
+    }
4796
+    if( !isset( $datetime['min'] )) {
4797
+        $datetime['min']  = '0';
4798
+    }
4799
+    if( !isset( $datetime['sec'] )) {
4800
+        $datetime['sec']  = '0';
4801
+    }
4238 4802
     foreach( $datetime as $dkey => $dvalue ) {
4239
-      if( 'tz' != $dkey )
4240
-        $datetime[$dkey] = (integer) $dvalue;
4803
+      if( 'tz' != $dkey ) {
4804
+              $datetime[$dkey] = (integer) $dvalue;
4805
+      }
4806
+    }
4807
+    if( $tz ) {
4808
+          $datetime['tz'] = $tz;
4241 4809
     }
4242
-    if( $tz )
4243
-      $datetime['tz'] = $tz;
4244 4810
     $offset = ( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) ? $this->_tz2offset( $datetime['tz'] ) : 0;
4245 4811
     $output = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year'] );
4246 4812
     return $output;
@@ -4275,12 +4841,15 @@  discard block
 block discarded – undo
4275 4841
       }
4276 4842
     }
4277 4843
     if( 3 != $parno ) {
4278
-      if( !isset( $output['hour'] ))
4279
-        $output['hour'] = 0;
4280
-      if( !isset( $output['min']  ))
4281
-        $output['min'] = 0;
4282
-      if( !isset( $output['sec']  ))
4283
-        $output['sec'] = 0;
4844
+      if( !isset( $output['hour'] )) {
4845
+              $output['hour'] = 0;
4846
+      }
4847
+      if( !isset( $output['min']  )) {
4848
+              $output['min'] = 0;
4849
+      }
4850
+      if( !isset( $output['sec']  )) {
4851
+              $output['sec'] = 0;
4852
+      }
4284 4853
     }
4285 4854
     return $output;
4286 4855
   }
@@ -4300,39 +4869,37 @@  discard block
 block discarded – undo
4300 4869
     if( 'Z' == substr( $datetime, -1 )) {
4301 4870
       $tz = 'Z';
4302 4871
       $datetime = trim( substr( $datetime, 0, $len ));
4303
-    }
4304
-    elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date
4872
+    } elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date
4305 4873
                   ( '-' == substr( $datetime, -3, 1 )) ||
4306 4874
                   ( ':' == substr( $datetime, -3, 1 )) ||
4307 4875
                   ( '.' == substr( $datetime, -3, 1 ))) {
4308 4876
       $continue = TRUE;
4309
-    }
4310
-    elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset
4877
+    } elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset
4311 4878
             ( ' +' == substr( $datetime, -6, 2 )) ||
4312 4879
             ( ' -' == substr( $datetime, -6, 2 ))) {
4313 4880
       $tz = substr( $datetime, -5, 5 );
4314 4881
       $datetime = substr( $datetime, 0, ($len - 5));
4315
-    }
4316
-    elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset
4882
+    } elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset
4317 4883
             ( ' +' == substr( $datetime, -8, 2 )) ||
4318 4884
             ( ' -' == substr( $datetime, -8, 2 ))) {
4319 4885
       $tz = substr( $datetime, -7, 7 );
4320 4886
       $datetime = substr( $datetime, 0, ($len - 7));
4321
-    }
4322
-    elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) {
4887
+    } elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) {
4323 4888
       $continue = TRUE;
4324
-    }
4325
-    elseif( 'T' ==  substr( $datetime, -7, 1 )) {
4889
+    } elseif( 'T' ==  substr( $datetime, -7, 1 )) {
4326 4890
       $continue = TRUE;
4327
-    }
4328
-    else {
4891
+    } else {
4329 4892
       $cx  = $tx = 0;    //  19970415T133000 US-Eastern
4330 4893
       for( $cx = -1; $cx > ( 9 - $len ); $cx-- ) {
4331
-        if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 )))
4332
-          break; // if exists, tz ends here.. . ?
4894
+        if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 ))) {
4895
+                  break;
4896
+        }
4897
+        // if exists, tz ends here.. . ?
4333 4898
         elseif( ctype_alpha( substr( $datetime, $cx, 1 )) ||
4334
-             ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' ))))
4335
-          $tx--; // tz length counter
4899
+             ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' )))) {
4900
+                  $tx--;
4901
+        }
4902
+        // tz length counter
4336 4903
       }
4337 4904
       if( 0 > $tx ) {
4338 4905
         $tz = substr( $datetime, $tx );
@@ -4341,8 +4908,7 @@  discard block
 block discarded – undo
4341 4908
     }
4342 4909
     if( 0 < substr_count( $datetime, '-' )) {
4343 4910
       $datetime = str_replace( '-', '/', $datetime );
4344
-    }
4345
-    elseif( ctype_digit( substr( $datetime, 0, 8 )) &&
4911
+    } elseif( ctype_digit( substr( $datetime, 0, 8 )) &&
4346 4912
            ( 'T' ==      substr( $datetime, 8, 1 )) &&
4347 4913
             ctype_digit( substr( $datetime, 9, 6 ))) {
4348 4914
       $datetime = substr( $datetime,  4, 2 )
@@ -4362,10 +4928,10 @@  discard block
 block discarded – undo
4362 4928
       $output['hour']  = substr( $datestring, 11, 2 );
4363 4929
       $output['min']   = substr( $datestring, 14, 2 );
4364 4930
       $output['sec']   = substr( $datestring, 17, 2 );
4365
-      if( !empty( $tz ))
4366
-        $output['tz']  = $tz;
4367
-    }
4368
-    elseif( 3 != $parno ) {
4931
+      if( !empty( $tz )) {
4932
+              $output['tz']  = $tz;
4933
+      }
4934
+    } elseif( 3 != $parno ) {
4369 4935
       if(( '00' < substr( $datestring, 11, 2 )) ||
4370 4936
          ( '00' < substr( $datestring, 14, 2 )) ||
4371 4937
          ( '00' < substr( $datestring, 17, 2 ))) {
@@ -4373,8 +4939,9 @@  discard block
 block discarded – undo
4373 4939
         $output['min']   = substr( $datestring, 14, 2 );
4374 4940
         $output['sec']   = substr( $datestring, 17, 2 );
4375 4941
       }
4376
-      if( !empty( $tz ))
4377
-        $output['tz']  = $tz;
4942
+      if( !empty( $tz )) {
4943
+              $output['tz']  = $tz;
4944
+      }
4378 4945
     }
4379 4946
     return $output;
4380 4947
   }
@@ -4401,10 +4968,11 @@  discard block
 block discarded – undo
4401 4968
       $durseconds  =           $durseconds % ( 60 * 60 );
4402 4969
       $output['min']  = floor( $durseconds / ( 60 ));
4403 4970
       $output['sec']  =      ( $durseconds % ( 60 ));
4404
-    }
4405
-    else {
4971
+    } else {
4406 4972
       foreach( $duration as $durKey => $durValue ) {
4407
-        if( empty( $durValue )) continue;
4973
+        if( empty( $durValue )) {
4974
+            continue;
4975
+        }
4408 4976
         switch ( $durKey ) {
4409 4977
           case '0': case 'week': $output['week']  = $durValue; break;
4410 4978
           case '1': case 'day':  $output['day']   = $durValue; break;
@@ -4419,14 +4987,22 @@  discard block
 block discarded – undo
4419 4987
       return $output;
4420 4988
     }
4421 4989
     unset( $output['week'] );
4422
-    if( empty( $output['day'] ))
4423
-      unset( $output['day'] );
4990
+    if( empty( $output['day'] )) {
4991
+          unset( $output['day'] );
4992
+    }
4424 4993
     if ( isset( $output['hour'] ) || isset( $output['min'] ) || isset( $output['sec'] )) {
4425
-      if( !isset( $output['hour'] )) $output['hour'] = 0;
4426
-      if( !isset( $output['min']  )) $output['min']  = 0;
4427
-      if( !isset( $output['sec']  )) $output['sec']  = 0;
4428
-      if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] ))
4429
-        unset( $output['hour'], $output['min'], $output['sec'] );
4994
+      if( !isset( $output['hour'] )) {
4995
+          $output['hour'] = 0;
4996
+      }
4997
+      if( !isset( $output['min']  )) {
4998
+          $output['min']  = 0;
4999
+      }
5000
+      if( !isset( $output['sec']  )) {
5001
+          $output['sec']  = 0;
5002
+      }
5003
+      if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] )) {
5004
+              unset( $output['hour'], $output['min'], $output['sec'] );
5005
+      }
4430 5006
     }
4431 5007
     return $output;
4432 5008
   }
@@ -4443,28 +5019,32 @@  discard block
 block discarded – undo
4443 5019
     if( $startdate && $duration ) {
4444 5020
       $d1               = $startdate;
4445 5021
       $dur              = $duration;
4446
-    }
4447
-    elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) {
5022
+    } elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) {
4448 5023
       $d1               = $this->dtstart['value'];
4449 5024
       $dur              = $this->duration['value'];
5025
+    } else {
5026
+          return null;
4450 5027
     }
4451
-    else
4452
-      return null;
4453 5028
     $dateOnly         = ( isset( $d1['hour'] ) || isset( $d1['min'] ) || isset( $d1['sec'] )) ? FALSE : TRUE;
4454 5029
     $d1['hour']       = ( isset( $d1['hour'] )) ? $d1['hour'] : 0;
4455 5030
     $d1['min']        = ( isset( $d1['min'] ))  ? $d1['min']  : 0;
4456 5031
     $d1['sec']        = ( isset( $d1['sec'] ))  ? $d1['sec']  : 0;
4457 5032
     $dtend = mktime( $d1['hour'], $d1['min'], $d1['sec'], $d1['month'], $d1['day'], $d1['year'] );
4458
-    if( isset( $dur['week'] ))
4459
-      $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 );
4460
-    if( isset( $dur['day'] ))
4461
-      $dtend += ( $dur['day'] * 24 * 60 * 60 );
4462
-    if( isset( $dur['hour'] ))
4463
-      $dtend += ( $dur['hour'] * 60 *60 );
4464
-    if( isset( $dur['min'] ))
4465
-      $dtend += ( $dur['min'] * 60 );
4466
-    if( isset( $dur['sec'] ))
4467
-      $dtend +=   $dur['sec'];
5033
+    if( isset( $dur['week'] )) {
5034
+          $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 );
5035
+    }
5036
+    if( isset( $dur['day'] )) {
5037
+          $dtend += ( $dur['day'] * 24 * 60 * 60 );
5038
+    }
5039
+    if( isset( $dur['hour'] )) {
5040
+          $dtend += ( $dur['hour'] * 60 *60 );
5041
+    }
5042
+    if( isset( $dur['min'] )) {
5043
+          $dtend += ( $dur['min'] * 60 );
5044
+    }
5045
+    if( isset( $dur['sec'] )) {
5046
+          $dtend +=   $dur['sec'];
5047
+    }
4468 5048
     $dtend2 = array();
4469 5049
     $dtend2['year']   = date('Y', $dtend );
4470 5050
     $dtend2['month']  = date('m', $dtend );
@@ -4472,10 +5052,12 @@  discard block
 block discarded – undo
4472 5052
     $dtend2['hour']   = date('H', $dtend );
4473 5053
     $dtend2['min']    = date('i', $dtend );
4474 5054
     $dtend2['sec']    = date('s', $dtend );
4475
-    if( isset( $d1['tz'] ))
4476
-      $dtend2['tz']   = $d1['tz'];
4477
-    if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] )))
4478
-      unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] );
5055
+    if( isset( $d1['tz'] )) {
5056
+          $dtend2['tz']   = $d1['tz'];
5057
+    }
5058
+    if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] ))) {
5059
+          unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] );
5060
+    }
4479 5061
     return $dtend2;
4480 5062
   }
4481 5063
 /**
@@ -4489,10 +5071,12 @@  discard block
 block discarded – undo
4489 5071
   function _duration_string( $duration ) {
4490 5072
    $duration = (string) trim( $duration );
4491 5073
    while( 'P' != strtoupper( substr( $duration, 0, 1 ))) {
4492
-     if( 0 < strlen( $duration ))
4493
-       $duration = substr( $duration, 1 );
4494
-     else
4495
-       return false; // no leading P !?!?
5074
+     if( 0 < strlen( $duration )) {
5075
+            $duration = substr( $duration, 1 );
5076
+     } else {
5077
+            return false;
5078
+     }
5079
+     // no leading P !?!?
4496 5080
    }
4497 5081
    $duration = substr( $duration, 1 ); // skip P
4498 5082
    $duration = str_replace ( 't', 'T', $duration );
@@ -4522,10 +5106,13 @@  discard block
 block discarded – undo
4522 5106
         $val            = null;
4523 5107
         break;
4524 5108
       default:
4525
-        if( !ctype_digit( $duration{$ix} ))
4526
-          return false; // unknown duration controll character  !?!?
4527
-        else
4528
-          $val .= $duration{$ix};
5109
+        if( !ctype_digit( $duration{$ix} )) {
5110
+                  return false;
5111
+        }
5112
+        // unknown duration controll character  !?!?
5113
+        else {
5114
+                  $val .= $duration{$ix};
5115
+        }
4529 5116
      }
4530 5117
    }
4531 5118
    return $this->_duration_array( $output );
@@ -4544,10 +5131,12 @@  discard block
 block discarded – undo
4544 5131
  * @return int
4545 5132
  */
4546 5133
   function _existRem( &$array, $expkey, $expval=FALSE, $hitVal=null, $elseVal=null, $preSet=null ) {
4547
-    if( $preSet )
4548
-      return $preSet;
4549
-    if( !is_array( $array ) || ( 0 == count( $array )))
4550
-      return $elseVal;
5134
+    if( $preSet ) {
5135
+          return $preSet;
5136
+    }
5137
+    if( !is_array( $array ) || ( 0 == count( $array ))) {
5138
+          return $elseVal;
5139
+    }
4551 5140
     foreach( $array as $key => $value ) {
4552 5141
       if( strtoupper( $expkey ) == strtoupper( $key )) {
4553 5142
         if( !$expval || ( strtoupper( $expval ) == strtoupper( $array[$key] ))) {
@@ -4573,13 +5162,15 @@  discard block
 block discarded – undo
4573 5162
         !isset( $datetime['day'] )   &&
4574 5163
         !isset( $datetime['hour'] )  &&
4575 5164
         !isset( $datetime['min'] )   &&
4576
-        !isset( $datetime['sec'] ))
4577
-      return ;
5165
+        !isset( $datetime['sec'] )) {
5166
+          return ;
5167
+    }
4578 5168
     $output = null;
4579 5169
     // if( !isset( $datetime['day'] )) { $o=''; foreach($datetime as $k=>$v) {if(is_array($v)) $v=implode('-',$v);$o.=" $k=>$v";} echo " day SAKNAS : $o <br />\n"; }
4580 5170
     foreach( $datetime as $dkey => $dvalue ) {
4581
-      if( 'tz' != $dkey )
4582
-        $datetime[$dkey] = (integer) $dvalue;
5171
+      if( 'tz' != $dkey ) {
5172
+              $datetime[$dkey] = (integer) $dvalue;
5173
+      }
4583 5174
     }
4584 5175
     $output = date('Ymd', mktime( 0, 0, 0, $datetime['month'], $datetime['day'], $datetime['year']));
4585 5176
     if( isset( $datetime['hour'] )  ||
@@ -4587,29 +5178,33 @@  discard block
 block discarded – undo
4587 5178
         isset( $datetime['sec'] )   ||
4588 5179
         isset( $datetime['tz'] )) {
4589 5180
       if( isset( $datetime['tz'] )  &&
4590
-         !isset( $datetime['hour'] ))
4591
-        $datetime['hour'] = 0;
5181
+         !isset( $datetime['hour'] )) {
5182
+              $datetime['hour'] = 0;
5183
+      }
4592 5184
       if( isset( $datetime['hour'] )  &&
4593
-         !isset( $datetime['min'] ))
4594
-        $datetime['min'] = 0;
5185
+         !isset( $datetime['min'] )) {
5186
+              $datetime['min'] = 0;
5187
+      }
4595 5188
       if( isset( $datetime['hour'] )  &&
4596 5189
           isset( $datetime['min'] )   &&
4597
-         !isset( $datetime['sec'] ))
4598
-        $datetime['sec'] = 0;
5190
+         !isset( $datetime['sec'] )) {
5191
+              $datetime['sec'] = 0;
5192
+      }
4599 5193
       $date = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']);
4600 5194
       $output .= date('\THis', $date );
4601 5195
       if( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) {
4602 5196
         $datetime['tz'] = trim( $datetime['tz'] );
4603
-        if( 'Z' == $datetime['tz'] )
4604
-          $output .= 'Z';
5197
+        if( 'Z' == $datetime['tz'] ) {
5198
+                  $output .= 'Z';
5199
+        }
4605 5200
         $offset = $this->_tz2offset( $datetime['tz'] );
4606 5201
         if( 0 != $offset ) {
4607 5202
           $date = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']);
4608 5203
           $output    = date( 'Ymd\THis\Z', $date );
4609 5204
         }
5205
+      } elseif( 7 == $parno ) {
5206
+              $output .= 'Z';
4610 5207
       }
4611
-      elseif( 7 == $parno )
4612
-        $output .= 'Z';
4613 5208
     }
4614 5209
     return $output;
4615 5210
   }
@@ -4626,14 +5221,16 @@  discard block
 block discarded – undo
4626 5221
         !isset( $duration['day'] )  &&
4627 5222
         !isset( $duration['hour'] ) &&
4628 5223
         !isset( $duration['min'] )  &&
4629
-        !isset( $duration['sec'] ))
4630
-      return;
5224
+        !isset( $duration['sec'] )) {
5225
+          return;
5226
+    }
4631 5227
     $output = 'P';
4632
-    if( isset( $duration['week'] ) && ( 0 < $duration['week'] ))
4633
-      $output   .= $duration['week'].'W';
4634
-    else {
4635
-      if( isset($duration['day'] ) && ( 0 < $duration['day'] ))
4636
-        $output .= $duration['day'].'D';
5228
+    if( isset( $duration['week'] ) && ( 0 < $duration['week'] )) {
5229
+          $output   .= $duration['week'].'W';
5230
+    } else {
5231
+      if( isset($duration['day'] ) && ( 0 < $duration['day'] )) {
5232
+              $output .= $duration['day'].'D';
5233
+      }
4637 5234
       if(( isset( $duration['hour']) && ( 0 < $duration['hour'] )) ||
4638 5235
          ( isset( $duration['min'])  && ( 0 < $duration['min'] ))  ||
4639 5236
          ( isset( $duration['sec'])  && ( 0 < $duration['sec'] ))) {
@@ -4658,7 +5255,9 @@  discard block
 block discarded – undo
4658 5255
     $output = null;
4659 5256
     foreach( $recurdata as $therule ) {
4660 5257
       if( empty( $therule['value'] )) {
4661
-        if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $recurlabel );
5258
+        if( $this->getConfig( 'allowEmpty' )) {
5259
+            $output .= $this->_createElement( $recurlabel );
5260
+        }
4662 5261
         continue;
4663 5262
       }
4664 5263
       $attributes = ( isset( $therule['params'] )) ? $this->_createParams( $therule['params'] ) : null;
@@ -4694,9 +5293,9 @@  discard block
 block discarded – undo
4694 5293
                 $content2 .= ( $vix ) ? ',' : null;
4695 5294
                 $content2 .= $valuePart;
4696 5295
               }
5296
+            } else {
5297
+                         $content2 .= $rulevalue;
4697 5298
             }
4698
-            else
4699
-             $content2 .= $rulevalue;
4700 5299
             break;
4701 5300
           }
4702 5301
           case 'BYDAY': {
@@ -4707,19 +5306,19 @@  discard block
 block discarded – undo
4707 5306
               if( is_array( $valuePart )) {
4708 5307
                 $content2 .= ( $bydaycnt ) ? ',' : null;
4709 5308
                 foreach( $valuePart as $vix2 => $valuePart2 ) {
4710
-                  if( 'DAY' != strtoupper( $vix2 ))
4711
-                      $content21 .= $valuePart2;
4712
-                  else
4713
-                    $content22 .= $valuePart2;
5309
+                  if( 'DAY' != strtoupper( $vix2 )) {
5310
+                                        $content21 .= $valuePart2;
5311
+                  } else {
5312
+                                      $content22 .= $valuePart2;
5313
+                  }
4714 5314
                 }
4715 5315
                 $content2 .= $content21.$content22;
4716 5316
                 $bydaycnt++;
4717
-              }
4718
-              else {
5317
+              } else {
4719 5318
                 $content2 .= ( $bydaycnt ) ? ',' : null;
4720
-                if( 'DAY' != strtoupper( $vix ))
4721
-                    $content21 .= $valuePart;
4722
-                else {
5319
+                if( 'DAY' != strtoupper( $vix )) {
5320
+                                    $content21 .= $valuePart;
5321
+                } else {
4723 5322
                   $content22 .= $valuePart;
4724 5323
                   $bydaycnt++;
4725 5324
                 }
@@ -4765,24 +5364,32 @@  discard block
 block discarded – undo
4765 5364
  * @return bool
4766 5365
  */
4767 5366
   function _isArrayDate( $input ) {
4768
-    if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 ))))
4769
-      return FALSE;
4770
-    if( 7 == count( $input ))
4771
-      return TRUE;
4772
-    if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] ))
4773
-      return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
4774
-    if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] ))
4775
-      return FALSE;
4776
-    if( in_array( 0, $input ))
4777
-      return FALSE;
4778
-    if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] ))
4779
-      return FALSE;
5367
+    if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 )))) {
5368
+          return FALSE;
5369
+    }
5370
+    if( 7 == count( $input )) {
5371
+          return TRUE;
5372
+    }
5373
+    if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) {
5374
+          return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
5375
+    }
5376
+    if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] )) {
5377
+          return FALSE;
5378
+    }
5379
+    if( in_array( 0, $input )) {
5380
+          return FALSE;
5381
+    }
5382
+    if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] )) {
5383
+          return FALSE;
5384
+    }
4780 5385
     if(( isset( $input[0] ) && isset( $input[1] ) && isset( $input[2] )) &&
4781
-         checkdate( (int) $input[1], (int) $input[2], (int) $input[0] ))
4782
-      return TRUE;
5386
+         checkdate( (int) $input[1], (int) $input[2], (int) $input[0] )) {
5387
+          return TRUE;
5388
+    }
4783 5389
     $input = $this->_date_time_string( $input[1].'/'.$input[2].'/'.$input[0], 3 ); //  m - d - Y
4784
-    if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] ))
4785
-      return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
5390
+    if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) {
5391
+          return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
5392
+    }
4786 5393
     return FALSE;
4787 5394
   }
4788 5395
 /**
@@ -4806,16 +5413,17 @@  discard block
 block discarded – undo
4806 5413
  */
4807 5414
   function _isOffset( $input ) {
4808 5415
     $input         = trim( (string) $input );
4809
-    if( 'Z' == substr( $input, -1 ))
4810
-      return TRUE;
4811
-    elseif((   5 <= strlen( $input )) &&
5416
+    if( 'Z' == substr( $input, -1 )) {
5417
+          return TRUE;
5418
+    } elseif((   5 <= strlen( $input )) &&
4812 5419
        ( in_array( substr( $input, -5, 1 ), array( '+', '-' ))) &&
4813
-       (   '0000'  < substr( $input, -4 )) && (   '9999' >= substr( $input, -4 )))
4814
-      return TRUE;
4815
-    elseif((    7 <= strlen( $input )) &&
5420
+       (   '0000'  < substr( $input, -4 )) && (   '9999' >= substr( $input, -4 ))) {
5421
+          return TRUE;
5422
+    } elseif((    7 <= strlen( $input )) &&
4816 5423
        ( in_array( substr( $input, -7, 1 ), array( '+', '-' ))) &&
4817
-       ( '000000'  < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 )))
4818
-      return TRUE;
5424
+       ( '000000'  < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 ))) {
5425
+          return TRUE;
5426
+    }
4819 5427
     return FALSE;
4820 5428
 
4821 5429
   }
@@ -4828,14 +5436,29 @@  discard block
 block discarded – undo
4828 5436
  * @return bool
4829 5437
  */
4830 5438
   function _notExistProp( $propName ) {
4831
-    if( empty( $propName )) return FALSE; // when deleting x-prop, an empty propName may be used=allowed
5439
+    if( empty( $propName )) {
5440
+        return FALSE;
5441
+    }
5442
+    // when deleting x-prop, an empty propName may be used=allowed
4832 5443
     $propName = strtolower( $propName );
4833
-    if(     'last-modified'    == $propName )  { if( !isset( $this->lastmodified ))    return TRUE; }
4834
-    elseif( 'percent-complete' == $propName )  { if( !isset( $this->percentcomplete )) return TRUE; }
4835
-    elseif( 'recurrence-id'    == $propName )  { if( !isset( $this->recurrenceid ))    return TRUE; }
4836
-    elseif( 'related-to'       == $propName )  { if( !isset( $this->relatedto ))       return TRUE; }
4837
-    elseif( 'request-status'   == $propName )  { if( !isset( $this->requeststatus ))   return TRUE; }
4838
-    elseif((       'x-' != substr($propName,0,2)) && !isset( $this->$propName ))       return TRUE;
5444
+    if(     'last-modified'    == $propName )  { if( !isset( $this->lastmodified )) {
5445
+        return TRUE;
5446
+    }
5447
+    } elseif( 'percent-complete' == $propName )  { if( !isset( $this->percentcomplete )) {
5448
+        return TRUE;
5449
+    }
5450
+    } elseif( 'recurrence-id'    == $propName )  { if( !isset( $this->recurrenceid )) {
5451
+        return TRUE;
5452
+    }
5453
+    } elseif( 'related-to'       == $propName )  { if( !isset( $this->relatedto )) {
5454
+        return TRUE;
5455
+    }
5456
+    } elseif( 'request-status'   == $propName )  { if( !isset( $this->requeststatus )) {
5457
+        return TRUE;
5458
+    }
5459
+    } elseif((       'x-' != substr($propName,0,2)) && !isset( $this->$propName )) {
5460
+        return TRUE;
5461
+    }
4839 5462
     return FALSE;
4840 5463
   }
4841 5464
 /**
@@ -4854,7 +5477,9 @@  discard block
 block discarded – undo
4854 5477
  * @todo BYHOUR, BYMINUTE, BYSECOND, ev. BYSETPOS due to ambiguity, WEEKLY at year end/start
4855 5478
  */
4856 5479
   function _recur2date( & $result, $recur, $wdate, $startdate, $enddate=FALSE ) {
4857
-    foreach( $wdate as $k => $v ) if( ctype_digit( $v )) $wdate[$k] = (int) $v;
5480
+    foreach( $wdate as $k => $v ) {
5481
+        if( ctype_digit( $v )) $wdate[$k] = (int) $v;
5482
+    }
4858 5483
     $wdatets     = $this->_date2timestamp( $wdate );
4859 5484
     $startdatets = $this->_date2timestamp( $startdate );
4860 5485
     if( !$enddate ) {
@@ -4863,43 +5488,54 @@  discard block
 block discarded – undo
4863 5488
 // echo "recur __in_ ".implode('-',$startdate)." period start ".implode('-',$wdate)." period end ".implode('-',$enddate)."<br />\n";print_r($recur);echo "<br />\n";//test###
4864 5489
     }
4865 5490
     $endDatets = $this->_date2timestamp( $enddate ); // fix break
4866
-    if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] ))
4867
-      $recur['UNTIL'] = $enddate; // create break
5491
+    if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] )) {
5492
+          $recur['UNTIL'] = $enddate;
5493
+    }
5494
+    // create break
4868 5495
     if( isset( $recur['UNTIL'] )) {
4869 5496
       $tdatets = $this->_date2timestamp( $recur['UNTIL'] );
4870 5497
       if( $endDatets > $tdatets ) {
4871 5498
         $endDatets = $tdatets; // emergency break
4872 5499
         $enddate   = $this->_timestamp2date( $endDatets, 6 );
5500
+      } else {
5501
+              $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 );
4873 5502
       }
4874
-      else
4875
-        $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 );
4876 5503
     }
4877 5504
     if( $wdatets > $endDatets ) {
4878 5505
      //echo "recur out of date ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test
4879 5506
       return array(); // nothing to do.. .
4880 5507
     }
4881
-    if( !isset( $recur['FREQ'] )) // "MUST be specified.. ."
4882
-      $recur['FREQ'] = 'DAILY'; // ??
5508
+    if( !isset( $recur['FREQ'] )) {
5509
+        // "MUST be specified.. ."
5510
+      $recur['FREQ'] = 'DAILY';
5511
+    }
5512
+    // ??
4883 5513
     $wkst = ( isset( $recur['WKST'] ) && ( 'SU' == $recur['WKST'] )) ? 24*60*60 : 0; // ??
4884
-    if( !isset( $recur['INTERVAL'] ))
4885
-      $recur['INTERVAL'] = 1;
5514
+    if( !isset( $recur['INTERVAL'] )) {
5515
+          $recur['INTERVAL'] = 1;
5516
+    }
4886 5517
     $countcnt = ( !isset( $recur['BYSETPOS'] )) ? 1 : 0; // DTSTART counts as the first occurrence
4887 5518
             /* find out how to step up dates and set index for interval count */
4888 5519
     $step = array();
4889
-    if( 'YEARLY' == $recur['FREQ'] )
4890
-      $step['year']  = 1;
4891
-    elseif( 'MONTHLY' == $recur['FREQ'] )
4892
-      $step['month'] = 1;
4893
-    elseif( 'WEEKLY' == $recur['FREQ'] )
4894
-      $step['day']   = 7;
4895
-    else
4896
-      $step['day']   = 1;
4897
-    if( isset( $step['year'] ) && isset( $recur['BYMONTH'] ))
4898
-      $step = array( 'month' => 1 );
4899
-    if( empty( $step ) && isset( $recur['BYWEEKNO'] )) // ??
5520
+    if( 'YEARLY' == $recur['FREQ'] ) {
5521
+          $step['year']  = 1;
5522
+    } elseif( 'MONTHLY' == $recur['FREQ'] ) {
5523
+          $step['month'] = 1;
5524
+    } elseif( 'WEEKLY' == $recur['FREQ'] ) {
5525
+          $step['day']   = 7;
5526
+    } else {
5527
+          $step['day']   = 1;
5528
+    }
5529
+    if( isset( $step['year'] ) && isset( $recur['BYMONTH'] )) {
5530
+          $step = array( 'month' => 1 );
5531
+    }
5532
+    if( empty( $step ) && isset( $recur['BYWEEKNO'] )) {
5533
+        // ??
4900 5534
       $step = array( 'day' => 7 );
4901
-    if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] ))
4902
-      $step = array( 'day' => 1 );
5535
+    }
5536
+    if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] )) {
5537
+          $step = array( 'day' => 1 );
5538
+    }
4903 5539
     $intervalarr = array();
4904 5540
     if( 1 < $recur['INTERVAL'] ) {
4905 5541
       $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst );
@@ -4912,11 +5548,12 @@  discard block
 block discarded – undo
4912 5548
       $bysetposMold = $wdate['month'];
4913 5549
       $bysetposDold = $wdate['day'];
4914 5550
       if( is_array( $recur['BYSETPOS'] )) {
4915
-        foreach( $recur['BYSETPOS'] as $bix => $bval )
4916
-          $recur['BYSETPOS'][$bix] = (int) $bval;
5551
+        foreach( $recur['BYSETPOS'] as $bix => $bval ) {
5552
+                  $recur['BYSETPOS'][$bix] = (int) $bval;
5553
+        }
5554
+      } else {
5555
+              $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] );
4917 5556
       }
4918
-      else
4919
-        $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] );
4920 5557
       $this->_stepdate( $enddate, $endDatets, $step); // make sure to count whole last period
4921 5558
     }
4922 5559
     $this->_stepdate( $wdate, $wdatets, $step);
@@ -4925,10 +5562,12 @@  discard block
 block discarded – undo
4925 5562
              /* MAIN LOOP */
4926 5563
      // echo "recur start ".implode('-',$wdate)." end ".implode('-',$enddate)."<br />\n";//test
4927 5564
     while( TRUE ) {
4928
-      if( isset( $endDatets ) && ( $wdatets > $endDatets ))
4929
-        break;
4930
-      if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] ))
4931
-        break;
5565
+      if( isset( $endDatets ) && ( $wdatets > $endDatets )) {
5566
+              break;
5567
+      }
5568
+      if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) {
5569
+              break;
5570
+      }
4932 5571
       if( $year_old != $wdate['year'] ) {
4933 5572
         $year_old   = $wdate['year'];
4934 5573
         $daycnts    = array();
@@ -4937,8 +5576,9 @@  discard block
 block discarded – undo
4937 5576
         for( $m = 1; $m <= 12; $m++ ) { // count up and update up-counters
4938 5577
           $daycnts[$m] = array();
4939 5578
           $weekdaycnt = array();
4940
-          foreach( $daynames as $dn )
4941
-            $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0;
5579
+          foreach( $daynames as $dn ) {
5580
+                      $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0;
5581
+          }
4942 5582
           $mcnt     = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] ));
4943 5583
           for( $d   = 1; $d <= $mcnt; $d++ ) {
4944 5584
             $daycnts[$m][$d] = array();
@@ -4955,8 +5595,9 @@  discard block
 block discarded – undo
4955 5595
               $yeardaycnt[$day]++;
4956 5596
               $daycnts[$m][$d]['yeardayno_up'] = $yeardaycnt[$day];
4957 5597
             }
4958
-            if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' ))
4959
-              $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year']));
5598
+            if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) {
5599
+                          $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year']));
5600
+            }
4960 5601
           }
4961 5602
         }
4962 5603
         $daycnt = 0;
@@ -4964,9 +5605,9 @@  discard block
 block discarded – undo
4964 5605
         if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) {
4965 5606
           $weekno = null;
4966 5607
           for( $d=31; $d > 25; $d-- ) { // get last weekno for year
4967
-            if( !$weekno )
4968
-              $weekno = $daycnts[12][$d]['weekno_up'];
4969
-            elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) {
5608
+            if( !$weekno ) {
5609
+                          $weekno = $daycnts[12][$d]['weekno_up'];
5610
+            } elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) {
4970 5611
               $weekno = $daycnts[12][$d]['weekno_up'];
4971 5612
               break;
4972 5613
             }
@@ -4974,8 +5615,9 @@  discard block
 block discarded – undo
4974 5615
         }
4975 5616
         for( $m = 12; $m > 0; $m-- ) { // count down and update down-counters
4976 5617
           $weekdaycnt = array();
4977
-          foreach( $daynames as $dn )
4978
-            $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0;
5618
+          foreach( $daynames as $dn ) {
5619
+                      $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0;
5620
+          }
4979 5621
           $monthcnt = 0;
4980 5622
           $mcnt     = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] ));
4981 5623
           for( $d   = $mcnt; $d > 0; $d-- ) {
@@ -4994,8 +5636,9 @@  discard block
 block discarded – undo
4994 5636
               $yeardaycnt[$day] -= 1;
4995 5637
               $daycnts[$m][$d]['yeardayno_down'] = $yeardaycnt[$day];
4996 5638
             }
4997
-            if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' ))
4998
-              $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1);
5639
+            if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) {
5640
+                          $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1);
5641
+            }
4999 5642
           }
5000 5643
         }
5001 5644
       }
@@ -5006,36 +5649,42 @@  discard block
 block discarded – undo
5006 5649
             /* check interval */
5007 5650
         $currentKey = array_keys( $intervalarr );
5008 5651
         $currentKey = end( $currentKey ); // get last index
5009
-        if( $currentKey != $intervalix )
5010
-          $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 ));
5652
+        if( $currentKey != $intervalix ) {
5653
+                  $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 ));
5654
+        }
5011 5655
         if(( $recur['INTERVAL'] != $intervalarr[$intervalix] ) &&
5012 5656
            ( 0 != $intervalarr[$intervalix] )) {
5013 5657
             /* step up date */
5014 5658
     //echo "skip: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test
5015 5659
           $this->_stepdate( $wdate, $wdatets, $step);
5016 5660
           continue;
5017
-        }
5018
-        else // continue within the selected interval
5661
+        } else {
5662
+            // continue within the selected interval
5019 5663
           $intervalarr[$intervalix] = 0;
5664
+        }
5020 5665
    //echo "cont: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test
5021 5666
       }
5022 5667
       $updateOK = TRUE;
5023
-      if( $updateOK && isset( $recur['BYMONTH'] ))
5024
-        $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH']
5668
+      if( $updateOK && isset( $recur['BYMONTH'] )) {
5669
+              $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH']
5025 5670
                                            , $wdate['month']
5026 5671
                                            ,($wdate['month'] - 13));
5027
-      if( $updateOK && isset( $recur['BYWEEKNO'] ))
5028
-        $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO']
5672
+      }
5673
+      if( $updateOK && isset( $recur['BYWEEKNO'] )) {
5674
+              $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO']
5029 5675
                                            , $daycnts[$wdate['month']][$wdate['day']]['weekno_up']
5030 5676
                                            , $daycnts[$wdate['month']][$wdate['day']]['weekno_down'] );
5031
-      if( $updateOK && isset( $recur['BYYEARDAY'] ))
5032
-        $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY']
5677
+      }
5678
+      if( $updateOK && isset( $recur['BYYEARDAY'] )) {
5679
+              $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY']
5033 5680
                                            , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_up']
5034 5681
                                            , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down'] );
5035
-      if( $updateOK && isset( $recur['BYMONTHDAY'] ))
5036
-        $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY']
5682
+      }
5683
+      if( $updateOK && isset( $recur['BYMONTHDAY'] )) {
5684
+              $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY']
5037 5685
                                            , $wdate['day']
5038 5686
                                            , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down'] );
5687
+      }
5039 5688
     //echo "efter BYMONTHDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n";//test###
5040 5689
       if( $updateOK && isset( $recur['BYDAY'] )) {
5041 5690
         $updateOK = FALSE;
@@ -5043,42 +5692,45 @@  discard block
 block discarded – undo
5043 5692
         $d = $wdate['day'];
5044 5693
         if( isset( $recur['BYDAY']['DAY'] )) { // single day, opt with year/month day order no
5045 5694
           $daynoexists = $daynosw = $daynamesw =  FALSE;
5046
-          if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] )
5047
-            $daynamesw = TRUE;
5695
+          if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] ) {
5696
+                      $daynamesw = TRUE;
5697
+          }
5048 5698
           if( isset( $recur['BYDAY'][0] )) {
5049 5699
             $daynoexists = TRUE;
5050
-            if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] ))
5051
-              $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5700
+            if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] )) {
5701
+                          $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5052 5702
                                                 , $daycnts[$m][$d]['monthdayno_up']
5053 5703
                                                 , $daycnts[$m][$d]['monthdayno_down'] );
5054
-            elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' ))
5055
-              $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5704
+            } elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) {
5705
+                          $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5056 5706
                                                 , $daycnts[$m][$d]['yeardayno_up']
5057 5707
                                                 , $daycnts[$m][$d]['yeardayno_down'] );
5708
+            }
5058 5709
           }
5059 5710
           if((  $daynoexists &&  $daynosw && $daynamesw ) ||
5060 5711
              ( !$daynoexists && !$daynosw && $daynamesw )) {
5061 5712
             $updateOK = TRUE;
5062 5713
           }
5063 5714
         //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ###
5064
-        }
5065
-        else {
5715
+        } else {
5066 5716
           foreach( $recur['BYDAY'] as $bydayvalue ) {
5067 5717
             $daynoexists = $daynosw = $daynamesw = FALSE;
5068 5718
             if( isset( $bydayvalue['DAY'] ) &&
5069
-                     ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] ))
5070
-              $daynamesw = TRUE;
5719
+                     ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] )) {
5720
+                          $daynamesw = TRUE;
5721
+            }
5071 5722
             if( isset( $bydayvalue[0] )) {
5072 5723
               $daynoexists = TRUE;
5073 5724
               if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) ||
5074
-                   isset( $recur['BYMONTH'] ))
5075
-                $daynosw = $this->_recurBYcntcheck( $bydayvalue['0']
5725
+                   isset( $recur['BYMONTH'] )) {
5726
+                              $daynosw = $this->_recurBYcntcheck( $bydayvalue['0']
5076 5727
                                                   , $daycnts[$m][$d]['monthdayno_up']
5077 5728
                                                   , $daycnts[$m][$d]['monthdayno_down'] );
5078
-              elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' ))
5079
-                $daynosw = $this->_recurBYcntcheck( $bydayvalue['0']
5729
+              } elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) {
5730
+                              $daynosw = $this->_recurBYcntcheck( $bydayvalue['0']
5080 5731
                                                   , $daycnts[$m][$d]['yeardayno_up']
5081 5732
                                                   , $daycnts[$m][$d]['yeardayno_down'] );
5733
+              }
5082 5734
             }
5083 5735
         //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ###
5084 5736
             if((  $daynoexists &&  $daynosw && $daynamesw ) ||
@@ -5095,12 +5747,12 @@  discard block
 block discarded – undo
5095 5747
         if( isset( $recur['BYSETPOS'] ) &&
5096 5748
           ( in_array( $recur['FREQ'], array( 'YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY' )))) {
5097 5749
           if( isset( $recur['WEEKLY'] )) {
5098
-            if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] )
5099
-              $bysetposw1[] = $wdatets;
5100
-            else
5101
-              $bysetposw2[] = $wdatets;
5102
-          }
5103
-          else {
5750
+            if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] ) {
5751
+                          $bysetposw1[] = $wdatets;
5752
+            } else {
5753
+                          $bysetposw2[] = $wdatets;
5754
+            }
5755
+          } else {
5104 5756
             if(( isset( $recur['FREQ'] ) && ( 'YEARLY'      == $recur['FREQ'] )  &&
5105 5757
                                             ( $bysetposYold == $wdate['year'] ))   ||
5106 5758
                ( isset( $recur['FREQ'] ) && ( 'MONTHLY'     == $recur['FREQ'] )  &&
@@ -5109,13 +5761,13 @@  discard block
 block discarded – undo
5109 5761
                ( isset( $recur['FREQ'] ) && ( 'MONTHLY'     == $recur['FREQ'] )  &&
5110 5762
                                            (( $bysetposYold == $wdate['year'] )  &&
5111 5763
                                             ( $bysetposMold == $wdate['month'])  &&
5112
-                                            ( $bysetposDold == $wdate['sday'] ))))
5113
-              $bysetposymd1[] = $wdatets;
5114
-            else
5115
-              $bysetposymd2[] = $wdatets;
5764
+                                            ( $bysetposDold == $wdate['sday'] )))) {
5765
+                          $bysetposymd1[] = $wdatets;
5766
+            } else {
5767
+                          $bysetposymd2[] = $wdatets;
5768
+            }
5116 5769
           }
5117
-        }
5118
-        else {
5770
+        } else {
5119 5771
             /* update result array if BYSETPOS is set */
5120 5772
           $countcnt++;
5121 5773
           if( $startdatets <= $wdatets ) { // only output within period
@@ -5135,21 +5787,18 @@  discard block
 block discarded – undo
5135 5787
           ( $bysetposYold != $wdate['year'] )) {
5136 5788
           $bysetpos     = TRUE;
5137 5789
           $bysetposYold = $wdate['year'];
5138
-        }
5139
-        elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] &&
5790
+        } elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] &&
5140 5791
          (( $bysetposYold != $wdate['year'] ) || ( $bysetposMold != $wdate['month'] )))) {
5141 5792
           $bysetpos     = TRUE;
5142 5793
           $bysetposYold = $wdate['year'];
5143 5794
           $bysetposMold = $wdate['month'];
5144
-        }
5145
-        elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY'  == $recur['FREQ'] )) {
5795
+        } elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY'  == $recur['FREQ'] )) {
5146 5796
           $weekno = (int) date( 'W', mktime( 0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year']));
5147 5797
           if( $bysetposWold != $weekno ) {
5148 5798
             $bysetposWold = $weekno;
5149 5799
             $bysetpos     = TRUE;
5150 5800
           }
5151
-        }
5152
-        elseif( isset( $recur['FREQ'] ) && ( 'DAILY'   == $recur['FREQ'] ) &&
5801
+        } elseif( isset( $recur['FREQ'] ) && ( 'DAILY'   == $recur['FREQ'] ) &&
5153 5802
          (( $bysetposYold != $wdate['year'] )  ||
5154 5803
           ( $bysetposMold != $wdate['month'] ) ||
5155 5804
           ( $bysetposDold != $wdate['sday'] ))) {
@@ -5162,14 +5811,15 @@  discard block
 block discarded – undo
5162 5811
           if( isset( $recur['BYWEEKNO'] )) {
5163 5812
             $bysetposarr1 = & $bysetposw1;
5164 5813
             $bysetposarr2 = & $bysetposw2;
5165
-          }
5166
-          else {
5814
+          } else {
5167 5815
             $bysetposarr1 = & $bysetposymd1;
5168 5816
             $bysetposarr2 = & $bysetposymd2;
5169 5817
           }
5170 5818
           foreach( $recur['BYSETPOS'] as $ix ) {
5171
-            if( 0 > $ix ) // both positive and negative BYSETPOS allowed
5819
+            if( 0 > $ix ) {
5820
+                // both positive and negative BYSETPOS allowed
5172 5821
               $ix = ( count( $bysetposarr1 ) + $ix + 1);
5822
+            }
5173 5823
             $ix--;
5174 5824
             if( isset( $bysetposarr1[$ix] )) {
5175 5825
               if( $startdatets <= $bysetposarr1[$ix] ) { // only output within period
@@ -5178,8 +5828,9 @@  discard block
 block discarded – undo
5178 5828
               }
5179 5829
               $countcnt++;
5180 5830
             }
5181
-            if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] ))
5182
-              break;
5831
+            if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) {
5832
+                          break;
5833
+            }
5183 5834
           }
5184 5835
           $bysetposarr1 = $bysetposarr2;
5185 5836
           $bysetposarr2 = array();
@@ -5189,12 +5840,13 @@  discard block
 block discarded – undo
5189 5840
   }
5190 5841
   function _recurBYcntcheck( $BYvalue, $upValue, $downValue ) {
5191 5842
     if( is_array( $BYvalue ) &&
5192
-      ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue )))
5193
-      return TRUE;
5194
-    elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue ))
5195
-      return TRUE;
5196
-    else
5197
-      return FALSE;
5843
+      ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue ))) {
5844
+          return TRUE;
5845
+    } elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue )) {
5846
+          return TRUE;
5847
+    } else {
5848
+          return FALSE;
5849
+    }
5198 5850
   }
5199 5851
   function _recurIntervalIx( $freq, $date, $wkst ) {
5200 5852
             /* create interval index */
@@ -5226,21 +5878,27 @@  discard block
 block discarded – undo
5226 5878
  */
5227 5879
   function _setRexrule( $rexrule ) {
5228 5880
     $input          = array();
5229
-    if( empty( $rexrule ))
5230
-      return $input;
5881
+    if( empty( $rexrule )) {
5882
+          return $input;
5883
+    }
5231 5884
     foreach( $rexrule as $rexrulelabel => $rexrulevalue ) {
5232 5885
       $rexrulelabel = strtoupper( $rexrulelabel );
5233
-      if( 'UNTIL'  != $rexrulelabel )
5234
-        $input[$rexrulelabel]   = $rexrulevalue;
5235
-      else {
5236
-        if( $this->_isArrayTimestampDate( $rexrulevalue )) // timestamp date
5886
+      if( 'UNTIL'  != $rexrulelabel ) {
5887
+              $input[$rexrulelabel]   = $rexrulevalue;
5888
+      } else {
5889
+        if( $this->_isArrayTimestampDate( $rexrulevalue )) {
5890
+            // timestamp date
5237 5891
           $input[$rexrulelabel] = $this->_timestamp2date( $rexrulevalue, 6 );
5238
-        elseif( $this->_isArrayDate( $rexrulevalue )) // date-time
5892
+        } elseif( $this->_isArrayDate( $rexrulevalue )) {
5893
+            // date-time
5239 5894
           $input[$rexrulelabel] = $this->_date_time_array( $rexrulevalue, 6 );
5240
-        elseif( 8 <= strlen( trim( $rexrulevalue ))) // ex. 2006-08-03 10:12:18
5895
+        } elseif( 8 <= strlen( trim( $rexrulevalue ))) {
5896
+            // ex. 2006-08-03 10:12:18
5241 5897
           $input[$rexrulelabel] = $this->_date_time_string( $rexrulevalue );
5242
-        if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] ))
5243
-          $input[$rexrulelabel]['tz'] = 'Z';
5898
+        }
5899
+        if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] )) {
5900
+                  $input[$rexrulelabel]['tz'] = 'Z';
5901
+        }
5244 5902
       }
5245 5903
     }
5246 5904
     return $input;
@@ -5264,7 +5922,9 @@  discard block
 block discarded – undo
5264 5922
     $input = $parno = null;
5265 5923
     $localtime = (( 'dtstart' == $caller ) && in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE;
5266 5924
     if( $this->_isArrayDate( $year )) {
5267
-      if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5925
+      if( $localtime ) {
5926
+          unset ( $month['VALUE'], $month['TZID'] );
5927
+      }
5268 5928
       $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5269 5929
       if( isset( $input['params']['TZID'] )) {
5270 5930
         $input['params']['VALUE'] = 'DATE-TIME';
@@ -5274,9 +5934,10 @@  discard block
 block discarded – undo
5274 5934
       $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval );
5275 5935
       $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, count( $year ), $parno );
5276 5936
       $input['value']  = $this->_date_time_array( $year, $parno );
5277
-    }
5278
-    elseif( $this->_isArrayTimestampDate( $year )) {
5279
-      if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5937
+    } elseif( $this->_isArrayTimestampDate( $year )) {
5938
+      if( $localtime ) {
5939
+          unset ( $month['VALUE'], $month['TZID'] );
5940
+      }
5280 5941
       $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5281 5942
       if( isset( $input['params']['TZID'] )) {
5282 5943
         $input['params']['VALUE'] = 'DATE-TIME';
@@ -5286,9 +5947,10 @@  discard block
 block discarded – undo
5286 5947
       $hitval          = ( isset( $year['tz'] )) ? 7 : 6;
5287 5948
       $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno );
5288 5949
       $input['value']  = $this->_timestamp2date( $year, $parno );
5289
-    }
5290
-    elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18
5291
-      if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5950
+    } elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18
5951
+      if( $localtime ) {
5952
+          unset ( $month['VALUE'], $month['TZID'] );
5953
+      }
5292 5954
       $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5293 5955
       if( isset( $input['params']['TZID'] )) {
5294 5956
         $input['params']['VALUE'] = 'DATE-TIME';
@@ -5297,17 +5959,16 @@  discard block
 block discarded – undo
5297 5959
       $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7, $parno );
5298 5960
       $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, $parno, $parno );
5299 5961
       $input['value']  = $this->_date_time_string( $year, $parno );
5300
-    }
5301
-    else {
5962
+    } else {
5302 5963
       if( is_array( $params )) {
5303
-        if( $localtime ) unset ( $params['VALUE'], $params['TZID'] );
5964
+        if( $localtime ) {
5965
+            unset ( $params['VALUE'], $params['TZID'] );
5966
+        }
5304 5967
         $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ));
5305
-      }
5306
-      elseif( is_array( $tz )) {
5968
+      } elseif( is_array( $tz )) {
5307 5969
         $input['params'] = $this->_setParams( $tz,     array( 'VALUE' => 'DATE-TIME' ));
5308 5970
         $tz = FALSE;
5309
-      }
5310
-      elseif( is_array( $hour )) {
5971
+      } elseif( is_array( $hour )) {
5311 5972
         $input['params'] = $this->_setParams( $hour,   array( 'VALUE' => 'DATE-TIME' ));
5312 5973
         $hour = $min = $sec = $tz = FALSE;
5313 5974
       }
@@ -5323,23 +5984,28 @@  discard block
 block discarded – undo
5323 5984
         $input['value']['hour'] = ( $hour ) ? $hour : '0';
5324 5985
         $input['value']['min']  = ( $min )  ? $min  : '0';
5325 5986
         $input['value']['sec']  = ( $sec )  ? $sec  : '0';
5326
-        if( !empty( $tz ))
5327
-          $input['value']['tz'] = $tz;
5987
+        if( !empty( $tz )) {
5988
+                  $input['value']['tz'] = $tz;
5989
+        }
5328 5990
       }
5329 5991
     }
5330 5992
     if( 3 == $parno ) {
5331 5993
       $input['params']['VALUE'] = 'DATE';
5332 5994
       unset( $input['value']['tz'] );
5333 5995
       unset( $input['params']['TZID'] );
5996
+    } elseif( isset( $input['params']['TZID'] )) {
5997
+          unset( $input['value']['tz'] );
5998
+    }
5999
+    if( $localtime ) {
6000
+        unset( $input['value']['tz'], $input['params']['TZID'] );
6001
+    }
6002
+    if( isset( $input['value']['tz'] )) {
6003
+          $input['value']['tz'] = (string) $input['value']['tz'];
5334 6004
     }
5335
-    elseif( isset( $input['params']['TZID'] ))
5336
-      unset( $input['value']['tz'] );
5337
-    if( $localtime ) unset( $input['value']['tz'], $input['params']['TZID'] );
5338
-    if( isset( $input['value']['tz'] ))
5339
-      $input['value']['tz'] = (string) $input['value']['tz'];
5340 6005
     if( !empty( $input['value']['tz'] ) && ( 'Z' != $input['value']['tz'] ) &&
5341
-      ( !$this->_isOffset( $input['value']['tz'] )))
5342
-      $input['params']['TZID'] = $input['value']['tz'];
6006
+      ( !$this->_isOffset( $input['value']['tz'] ))) {
6007
+          $input['params']['TZID'] = $input['value']['tz'];
6008
+    }
5343 6009
     return $input;
5344 6010
   }
5345 6011
 /**
@@ -5361,16 +6027,13 @@  discard block
 block discarded – undo
5361 6027
     if( $this->_isArrayDate( $year )) {
5362 6028
       $input['value']  = $this->_date_time_array( $year, 7 );
5363 6029
       $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5364
-    }
5365
-    elseif( $this->_isArrayTimestampDate( $year )) {
6030
+    } elseif( $this->_isArrayTimestampDate( $year )) {
5366 6031
       $input['value']  = $this->_timestamp2date( $year, 7 );
5367 6032
       $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5368
-    }
5369
-    elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18
6033
+    } elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18
5370 6034
       $input['value']  = $this->_date_time_string( $year, 7 );
5371 6035
       $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5372
-    }
5373
-    else {
6036
+    } else {
5374 6037
       $input['value']  = array( 'year'  => $year
5375 6038
                               , 'month' => $month
5376 6039
                               , 'day'   => $day
@@ -5380,14 +6043,18 @@  discard block
 block discarded – undo
5380 6043
       $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ));
5381 6044
     }
5382 6045
     $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7 ); // remove default
5383
-    if( !isset( $input['value']['hour'] ))
5384
-      $input['value']['hour'] = 0;
5385
-    if( !isset( $input['value']['min'] ))
5386
-      $input['value']['min'] = 0;
5387
-    if( !isset( $input['value']['sec'] ))
5388
-      $input['value']['sec'] = 0;
5389
-    if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] ))
5390
-      $input['value']['tz'] = 'Z';
6046
+    if( !isset( $input['value']['hour'] )) {
6047
+          $input['value']['hour'] = 0;
6048
+    }
6049
+    if( !isset( $input['value']['min'] )) {
6050
+          $input['value']['min'] = 0;
6051
+    }
6052
+    if( !isset( $input['value']['sec'] )) {
6053
+          $input['value']['sec'] = 0;
6054
+    }
6055
+    if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] )) {
6056
+          $input['value']['tz'] = 'Z';
6057
+    }
5391 6058
     return $input;
5392 6059
   }
5393 6060
 /**
@@ -5403,15 +6070,17 @@  discard block
 block discarded – undo
5403 6070
  * @return void
5404 6071
  */
5405 6072
   function _setMval( & $valArr, $value, $params=FALSE, $defaults=FALSE, $index=FALSE ) {
5406
-    if( !is_array( $valArr )) $valArr = array();
5407
-    if( $index )
5408
-      $index = $index - 1;
5409
-    elseif( 0 < count( $valArr )) {
6073
+    if( !is_array( $valArr )) {
6074
+        $valArr = array();
6075
+    }
6076
+    if( $index ) {
6077
+          $index = $index - 1;
6078
+    } elseif( 0 < count( $valArr )) {
5410 6079
       $index = end( array_keys( $valArr ));
5411 6080
       $index += 1;
6081
+    } else {
6082
+          $index = 0;
5412 6083
     }
5413
-    else
5414
-      $index = 0;
5415 6084
     $valArr[$index] = array( 'value' => $value, 'params' => $this->_setParams( $params, $defaults ));
5416 6085
     ksort( $valArr );
5417 6086
   }
@@ -5427,27 +6096,31 @@  discard block
 block discarded – undo
5427 6096
  * @return array
5428 6097
  */
5429 6098
   function _setParams( $params, $defaults=FALSE ) {
5430
-    if( !is_array( $params))
5431
-      $params = array();
6099
+    if( !is_array( $params)) {
6100
+          $params = array();
6101
+    }
5432 6102
     $input = array();
5433 6103
     foreach( $params as $paramKey => $paramValue ) {
5434 6104
       if( is_array( $paramValue )) {
5435 6105
         foreach( $paramValue as $pkey => $pValue ) {
5436
-          if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 )))
5437
-            $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 ));
6106
+          if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 ))) {
6107
+                      $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 ));
6108
+          }
5438 6109
         }
6110
+      } elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 ))) {
6111
+              $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 ));
6112
+      }
6113
+      if( 'VALUE' == strtoupper( $paramKey )) {
6114
+              $input['VALUE']                 = strtoupper( $paramValue );
6115
+      } else {
6116
+              $input[strtoupper( $paramKey )] = $paramValue;
5439 6117
       }
5440
-      elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 )))
5441
-        $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 ));
5442
-      if( 'VALUE' == strtoupper( $paramKey ))
5443
-        $input['VALUE']                 = strtoupper( $paramValue );
5444
-      else
5445
-        $input[strtoupper( $paramKey )] = $paramValue;
5446 6118
     }
5447 6119
     if( is_array( $defaults )) {
5448 6120
       foreach( $defaults as $paramKey => $paramValue ) {
5449
-        if( !isset( $input[$paramKey] ))
5450
-          $input[$paramKey] = $paramValue;
6121
+        if( !isset( $input[$paramKey] )) {
6122
+                  $input[$paramKey] = $paramValue;
6123
+        }
5451 6124
       }
5452 6125
     }
5453 6126
     return (0 < count( $input )) ? $input : null;
@@ -5463,13 +6136,15 @@  discard block
 block discarded – undo
5463 6136
  * @return void
5464 6137
  */
5465 6138
   function _stepdate( &$date, &$timestamp, $step=array( 'day' => 1 )) {
5466
-    foreach( $step as $stepix => $stepvalue )
5467
-      $date[$stepix] += $stepvalue;
6139
+    foreach( $step as $stepix => $stepvalue ) {
6140
+          $date[$stepix] += $stepvalue;
6141
+    }
5468 6142
     $timestamp  = $this->_date2timestamp( $date );
5469 6143
     $date       = $this->_timestamp2date( $timestamp, 6 );
5470 6144
     foreach( $date as $k => $v ) {
5471
-      if( ctype_digit( $v ))
5472
-        $date[$k] = (int) $v;
6145
+      if( ctype_digit( $v )) {
6146
+              $date[$k] = (int) $v;
6147
+      }
5473 6148
     }
5474 6149
   }
5475 6150
 /**
@@ -5483,8 +6158,9 @@  discard block
 block discarded – undo
5483 6158
  */
5484 6159
   function _timestamp2date( $timestamp, $parno=6 ) {
5485 6160
     if( is_array( $timestamp )) {
5486
-      if(( 7 == $parno ) && !empty( $timestamp['tz'] ))
5487
-        $tz = $timestamp['tz'];
6161
+      if(( 7 == $parno ) && !empty( $timestamp['tz'] )) {
6162
+              $tz = $timestamp['tz'];
6163
+      }
5488 6164
       $timestamp = $timestamp['timestamp'];
5489 6165
     }
5490 6166
     $output = array( 'year'  => date( 'Y', $timestamp )
@@ -5494,8 +6170,9 @@  discard block
 block discarded – undo
5494 6170
              $output['hour'] =  date( 'H', $timestamp );
5495 6171
              $output['min']  =  date( 'i', $timestamp );
5496 6172
              $output['sec']  =  date( 's', $timestamp );
5497
-      if( isset( $tz ))
5498
-        $output['tz'] = $tz;
6173
+      if( isset( $tz )) {
6174
+              $output['tz'] = $tz;
6175
+      }
5499 6176
     }
5500 6177
     return $output;
5501 6178
   }
@@ -5513,8 +6190,9 @@  discard block
 block discarded – undo
5513 6190
     if(((     5  != strlen( $tz )) && ( 7  != strlen( $tz ))) ||
5514 6191
        ((    '+' != substr( $tz, 0, 1 )) && ( '-' != substr( $tz, 0, 1 ))) ||
5515 6192
        (( '0000' >= substr( $tz, 1, 4 )) && ( '9999' < substr( $tz, 1, 4 ))) ||
5516
-           (( 7  == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 ))))
5517
-      return $offset;
6193
+           (( 7  == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 )))) {
6194
+          return $offset;
6195
+    }
5518 6196
     $hours2sec    = (int) substr( $tz, 1, 2 ) * 3600;
5519 6197
     $min2sec      = (int) substr( $tz, 3, 2 ) *   60;
5520 6198
     $sec          = ( 7  == strlen( $tz )) ? (int) substr( $tz, -2 ) : '00';
@@ -5542,7 +6220,9 @@  discard block
 block discarded – undo
5542 6220
         $info = array();
5543 6221
         if( isset( $this->components )) {
5544 6222
           foreach( $this->components as $cix => $component ) {
5545
-            if( empty( $component )) continue;
6223
+            if( empty( $component )) {
6224
+                continue;
6225
+            }
5546 6226
             unset( $component->propix );
5547 6227
             $info[$cix]['ordno'] = $cix + 1;
5548 6228
             $info[$cix]['type']  = $component->objName;
@@ -5568,57 +6248,146 @@  discard block
 block discarded – undo
5568 6248
       case 'PROPINFO':
5569 6249
         $output = array();
5570 6250
         if( !in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
5571
-          if( empty( $this->uid['value'] )) $this->_makeuid();
6251
+          if( empty( $this->uid['value'] )) {
6252
+              $this->_makeuid();
6253
+          }
5572 6254
                                               $output['UID']              = 1;
5573 6255
         }
5574
-        if( !empty( $this->dtstamp ))         $output['DTSTAMP']          = 1;
5575
-        if( !empty( $this->summary ))         $output['SUMMARY']          = 1;
5576
-        if( !empty( $this->description ))     $output['DESCRIPTION']      = count( $this->description );
5577
-        if( !empty( $this->dtstart ))         $output['DTSTART']          = 1;
5578
-        if( !empty( $this->dtend ))           $output['DTEND']            = 1;
5579
-        if( !empty( $this->due ))             $output['DUE']              = 1;
5580
-        if( !empty( $this->duration ))        $output['DURATION']         = 1;
5581
-        if( !empty( $this->rrule ))           $output['RRULE']            = count( $this->rrule );
5582
-        if( !empty( $this->rdate ))           $output['RDATE']            = count( $this->rdate );
5583
-        if( !empty( $this->exdate ))          $output['EXDATE']           = count( $this->exdate );
5584
-        if( !empty( $this->exrule ))          $output['EXRULE']           = count( $this->exrule );
5585
-        if( !empty( $this->action ))          $output['ACTION']           = 1;
5586
-        if( !empty( $this->attach ))          $output['ATTACH']           = count( $this->attach );
5587
-        if( !empty( $this->attendee ))        $output['ATTENDEE']         = count( $this->attendee );
5588
-        if( !empty( $this->categories ))      $output['CATEGORIES']       = count( $this->categories );
5589
-        if( !empty( $this->class ))           $output['CLASS']            = 1;
5590
-        if( !empty( $this->comment ))         $output['COMMENT']          = count( $this->comment );
5591
-        if( !empty( $this->completed ))       $output['COMPLETED']        = 1;
5592
-        if( !empty( $this->contact ))         $output['CONTACT']          = count( $this->contact );
5593
-        if( !empty( $this->created ))         $output['CREATED']          = 1;
5594
-        if( !empty( $this->freebusy ))        $output['FREEBUSY']         = count( $this->freebusy );
5595
-        if( !empty( $this->geo ))             $output['GEO']              = 1;
5596
-        if( !empty( $this->lastmodified ))    $output['LAST-MODIFIED']    = 1;
5597
-        if( !empty( $this->location ))        $output['LOCATION']         = 1;
5598
-        if( !empty( $this->organizer ))       $output['ORGANIZER']        = 1;
5599
-        if( !empty( $this->percentcomplete )) $output['PERCENT-COMPLETE'] = 1;
5600
-        if( !empty( $this->priority ))        $output['PRIORITY']         = 1;
5601
-        if( !empty( $this->recurrenceid ))    $output['RECURRENCE-ID']    = 1;
5602
-        if( !empty( $this->relatedto ))       $output['RELATED-TO']       = count( $this->relatedto );
5603
-        if( !empty( $this->repeat ))          $output['REPEAT']           = 1;
5604
-        if( !empty( $this->requeststatus ))   $output['REQUEST-STATUS']   = count( $this->requeststatus );
5605
-        if( !empty( $this->resources ))       $output['RESOURCES']        = count( $this->resources );
5606
-        if( !empty( $this->sequence ))        $output['SEQUENCE']         = 1;
5607
-        if( !empty( $this->status ))          $output['STATUS']           = 1;
5608
-        if( !empty( $this->transp ))          $output['TRANSP']           = 1;
5609
-        if( !empty( $this->trigger ))         $output['TRIGGER']          = 1;
5610
-        if( !empty( $this->tzid ))            $output['TZID']             = 1;
5611
-        if( !empty( $this->tzname ))          $output['TZNAME']           = count( $this->tzname );
5612
-        if( !empty( $this->tzoffsetfrom ))    $output['TZOFFSETTFROM']    = 1;
5613
-        if( !empty( $this->tzoffsetto ))      $output['TZOFFSETTO']       = 1;
5614
-        if( !empty( $this->tzurl ))           $output['TZURL']            = 1;
5615
-        if( !empty( $this->url ))             $output['URL']              = 1;
5616
-        if( !empty( $this->xprop ))           $output['X-PROP']           = count( $this->xprop );
6256
+        if( !empty( $this->dtstamp )) {
6257
+            $output['DTSTAMP']          = 1;
6258
+        }
6259
+        if( !empty( $this->summary )) {
6260
+            $output['SUMMARY']          = 1;
6261
+        }
6262
+        if( !empty( $this->description )) {
6263
+            $output['DESCRIPTION']      = count( $this->description );
6264
+        }
6265
+        if( !empty( $this->dtstart )) {
6266
+            $output['DTSTART']          = 1;
6267
+        }
6268
+        if( !empty( $this->dtend )) {
6269
+            $output['DTEND']            = 1;
6270
+        }
6271
+        if( !empty( $this->due )) {
6272
+            $output['DUE']              = 1;
6273
+        }
6274
+        if( !empty( $this->duration )) {
6275
+            $output['DURATION']         = 1;
6276
+        }
6277
+        if( !empty( $this->rrule )) {
6278
+            $output['RRULE']            = count( $this->rrule );
6279
+        }
6280
+        if( !empty( $this->rdate )) {
6281
+            $output['RDATE']            = count( $this->rdate );
6282
+        }
6283
+        if( !empty( $this->exdate )) {
6284
+            $output['EXDATE']           = count( $this->exdate );
6285
+        }
6286
+        if( !empty( $this->exrule )) {
6287
+            $output['EXRULE']           = count( $this->exrule );
6288
+        }
6289
+        if( !empty( $this->action )) {
6290
+            $output['ACTION']           = 1;
6291
+        }
6292
+        if( !empty( $this->attach )) {
6293
+            $output['ATTACH']           = count( $this->attach );
6294
+        }
6295
+        if( !empty( $this->attendee )) {
6296
+            $output['ATTENDEE']         = count( $this->attendee );
6297
+        }
6298
+        if( !empty( $this->categories )) {
6299
+            $output['CATEGORIES']       = count( $this->categories );
6300
+        }
6301
+        if( !empty( $this->class )) {
6302
+            $output['CLASS']            = 1;
6303
+        }
6304
+        if( !empty( $this->comment )) {
6305
+            $output['COMMENT']          = count( $this->comment );
6306
+        }
6307
+        if( !empty( $this->completed )) {
6308
+            $output['COMPLETED']        = 1;
6309
+        }
6310
+        if( !empty( $this->contact )) {
6311
+            $output['CONTACT']          = count( $this->contact );
6312
+        }
6313
+        if( !empty( $this->created )) {
6314
+            $output['CREATED']          = 1;
6315
+        }
6316
+        if( !empty( $this->freebusy )) {
6317
+            $output['FREEBUSY']         = count( $this->freebusy );
6318
+        }
6319
+        if( !empty( $this->geo )) {
6320
+            $output['GEO']              = 1;
6321
+        }
6322
+        if( !empty( $this->lastmodified )) {
6323
+            $output['LAST-MODIFIED']    = 1;
6324
+        }
6325
+        if( !empty( $this->location )) {
6326
+            $output['LOCATION']         = 1;
6327
+        }
6328
+        if( !empty( $this->organizer )) {
6329
+            $output['ORGANIZER']        = 1;
6330
+        }
6331
+        if( !empty( $this->percentcomplete )) {
6332
+            $output['PERCENT-COMPLETE'] = 1;
6333
+        }
6334
+        if( !empty( $this->priority )) {
6335
+            $output['PRIORITY']         = 1;
6336
+        }
6337
+        if( !empty( $this->recurrenceid )) {
6338
+            $output['RECURRENCE-ID']    = 1;
6339
+        }
6340
+        if( !empty( $this->relatedto )) {
6341
+            $output['RELATED-TO']       = count( $this->relatedto );
6342
+        }
6343
+        if( !empty( $this->repeat )) {
6344
+            $output['REPEAT']           = 1;
6345
+        }
6346
+        if( !empty( $this->requeststatus )) {
6347
+            $output['REQUEST-STATUS']   = count( $this->requeststatus );
6348
+        }
6349
+        if( !empty( $this->resources )) {
6350
+            $output['RESOURCES']        = count( $this->resources );
6351
+        }
6352
+        if( !empty( $this->sequence )) {
6353
+            $output['SEQUENCE']         = 1;
6354
+        }
6355
+        if( !empty( $this->status )) {
6356
+            $output['STATUS']           = 1;
6357
+        }
6358
+        if( !empty( $this->transp )) {
6359
+            $output['TRANSP']           = 1;
6360
+        }
6361
+        if( !empty( $this->trigger )) {
6362
+            $output['TRIGGER']          = 1;
6363
+        }
6364
+        if( !empty( $this->tzid )) {
6365
+            $output['TZID']             = 1;
6366
+        }
6367
+        if( !empty( $this->tzname )) {
6368
+            $output['TZNAME']           = count( $this->tzname );
6369
+        }
6370
+        if( !empty( $this->tzoffsetfrom )) {
6371
+            $output['TZOFFSETTFROM']    = 1;
6372
+        }
6373
+        if( !empty( $this->tzoffsetto )) {
6374
+            $output['TZOFFSETTO']       = 1;
6375
+        }
6376
+        if( !empty( $this->tzurl )) {
6377
+            $output['TZURL']            = 1;
6378
+        }
6379
+        if( !empty( $this->url )) {
6380
+            $output['URL']              = 1;
6381
+        }
6382
+        if( !empty( $this->xprop )) {
6383
+            $output['X-PROP']           = count( $this->xprop );
6384
+        }
5617 6385
         return $output;
5618 6386
         break;
5619 6387
       case 'UNIQUE_ID':
5620
-        if( empty( $this->unique_id ))
5621
-          $this->unique_id  = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost';
6388
+        if( empty( $this->unique_id )) {
6389
+                  $this->unique_id  = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost';
6390
+        }
5622 6391
         return $this->unique_id;
5623 6392
         break;
5624 6393
     }
@@ -5667,13 +6436,16 @@  discard block
 block discarded – undo
5667 6436
         $res    = TRUE;
5668 6437
         break;
5669 6438
     }
5670
-    if( !$res ) return FALSE;
6439
+    if( !$res ) {
6440
+        return FALSE;
6441
+    }
5671 6442
     if( isset( $subcfg ) && !empty( $this->components )) {
5672 6443
       foreach( $subcfg as $cfgkey => $cfgvalue ) {
5673 6444
         foreach( $this->components as $cix => $component ) {
5674 6445
           $res = $component->setConfig( $cfgkey, $cfgvalue );
5675
-          if( !$res )
5676
-            break 2;
6446
+          if( !$res ) {
6447
+                      break 2;
6448
+          }
5677 6449
           $this->components[$cix] = $component; // PHP4 compliant
5678 6450
         }
5679 6451
       }
@@ -5691,12 +6463,15 @@  discard block
 block discarded – undo
5691 6463
  * @return bool, if successfull delete TRUE
5692 6464
  */
5693 6465
   function deleteProperty( $propName, $propix=FALSE ) {
5694
-    if( $this->_notExistProp( $propName )) return FALSE;
6466
+    if( $this->_notExistProp( $propName )) {
6467
+        return FALSE;
6468
+    }
5695 6469
     $propName = strtoupper( $propName );
5696 6470
     if( in_array( $propName, array( 'ATTACH',   'ATTENDEE', 'CATEGORIES', 'COMMENT',   'CONTACT', 'DESCRIPTION',    'EXDATE', 'EXRULE',
5697 6471
                                     'FREEBUSY', 'RDATE',    'RELATED-TO', 'RESOURCES', 'RRULE',   'REQUEST-STATUS', 'TZNAME', 'X-PROP'  ))) {
5698
-      if( !$propix )
5699
-        $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
6472
+      if( !$propix ) {
6473
+              $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
6474
+      }
5700 6475
       $this->propdelix[$propName] = --$propix;
5701 6476
     }
5702 6477
     $return = FALSE;
@@ -5750,8 +6525,9 @@  discard block
 block discarded – undo
5750 6525
         }
5751 6526
         break;
5752 6527
       case 'DTSTAMP':
5753
-        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
5754
-          return FALSE;
6528
+        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
6529
+                  return FALSE;
6530
+        }
5755 6531
         if( !empty( $this->dtstamp )) {
5756 6532
           $this->dtstamp = '';
5757 6533
           $return = TRUE;
@@ -5905,8 +6681,9 @@  discard block
 block discarded – undo
5905 6681
         }
5906 6682
         break;
5907 6683
       case 'UID':
5908
-        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
5909
-          return FALSE;
6684
+        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
6685
+                  return FALSE;
6686
+        }
5910 6687
         if( !empty( $this->uid )) {
5911 6688
           $this->uid = '';
5912 6689
           $return = TRUE;
@@ -5921,18 +6698,23 @@  discard block
 block discarded – undo
5921 6698
       default:
5922 6699
         $reduced = '';
5923 6700
         if( $propName != 'X-PROP' ) {
5924
-          if( !isset( $this->xprop[$propName] )) return FALSE;
6701
+          if( !isset( $this->xprop[$propName] )) {
6702
+              return FALSE;
6703
+          }
5925 6704
           foreach( $this->xprop as $k => $a ) {
5926
-            if(( $k != $propName ) && !empty( $a ))
5927
-              $reduced[$k] = $a;
6705
+            if(( $k != $propName ) && !empty( $a )) {
6706
+                          $reduced[$k] = $a;
6707
+            }
6708
+          }
6709
+        } else {
6710
+          if( count( $this->xprop ) <= $propix ) {
6711
+              return FALSE;
5928 6712
           }
5929
-        }
5930
-        else {
5931
-          if( count( $this->xprop ) <= $propix )  return FALSE;
5932 6713
           $xpropno = 0;
5933 6714
           foreach( $this->xprop as $xpropkey => $xpropvalue ) {
5934
-            if( $propix != $xpropno )
5935
-              $reduced[$xpropkey] = $xpropvalue;
6715
+            if( $propix != $xpropno ) {
6716
+                          $reduced[$xpropkey] = $xpropvalue;
6717
+            }
5936 6718
             $xpropno++;
5937 6719
           }
5938 6720
         }
@@ -5952,9 +6734,13 @@  discard block
 block discarded – undo
5952 6734
  * @return bool TRUE
5953 6735
  */
5954 6736
   function deletePropertyM( & $multiprop, $propix=0 ) {
5955
-    if( !isset( $multiprop[$propix])) return FALSE;
6737
+    if( !isset( $multiprop[$propix])) {
6738
+        return FALSE;
6739
+    }
5956 6740
     unset( $multiprop[$propix] );
5957
-    if( empty( $multiprop )) $multiprop = '';
6741
+    if( empty( $multiprop )) {
6742
+        $multiprop = '';
6743
+    }
5958 6744
     return ( isset( $this->multiprop[$propix] )) ? FALSE : TRUE;
5959 6745
   }
5960 6746
 /**
@@ -5971,184 +6757,277 @@  discard block
 block discarded – undo
5971 6757
  * @return mixed
5972 6758
  */
5973 6759
   function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE, $specform=FALSE ) {
5974
-    if( $this->_notExistProp( $propName )) return FALSE;
6760
+    if( $this->_notExistProp( $propName )) {
6761
+        return FALSE;
6762
+    }
5975 6763
     $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';
5976 6764
     if( in_array( $propName, array( 'ATTACH',   'ATTENDEE', 'CATEGORIES', 'COMMENT',   'CONTACT', 'DESCRIPTION',    'EXDATE', 'EXRULE',
5977 6765
                                     'FREEBUSY', 'RDATE',    'RELATED-TO', 'RESOURCES', 'RRULE',   'REQUEST-STATUS', 'TZNAME', 'X-PROP'  ))) {
5978
-      if( !$propix )
5979
-        $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;
6766
+      if( !$propix ) {
6767
+              $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;
6768
+      }
5980 6769
       $this->propix[$propName] = --$propix;
5981 6770
     }
5982 6771
     switch( $propName ) {
5983 6772
       case 'ACTION':
5984
-        if( !empty( $this->action['value'] )) return ( $inclParam ) ? $this->action : $this->action['value'];
6773
+        if( !empty( $this->action['value'] )) {
6774
+            return ( $inclParam ) ? $this->action : $this->action['value'];
6775
+        }
5985 6776
         break;
5986 6777
       case 'ATTACH':
5987
-        if( !isset( $this->attach[$propix] )) return FALSE;
6778
+        if( !isset( $this->attach[$propix] )) {
6779
+            return FALSE;
6780
+        }
5988 6781
         return ( $inclParam ) ? $this->attach[$propix] : $this->attach[$propix]['value'];
5989 6782
         break;
5990 6783
       case 'ATTENDEE':
5991
-        if( !isset( $this->attendee[$propix] )) return FALSE;
6784
+        if( !isset( $this->attendee[$propix] )) {
6785
+            return FALSE;
6786
+        }
5992 6787
         return ( $inclParam ) ? $this->attendee[$propix] : $this->attendee[$propix]['value'];
5993 6788
         break;
5994 6789
       case 'CATEGORIES':
5995
-        if( !isset( $this->categories[$propix] )) return FALSE;
6790
+        if( !isset( $this->categories[$propix] )) {
6791
+            return FALSE;
6792
+        }
5996 6793
         return ( $inclParam ) ? $this->categories[$propix] : $this->categories[$propix]['value'];
5997 6794
         break;
5998 6795
       case 'CLASS':
5999
-        if( !empty( $this->class['value'] )) return ( $inclParam ) ? $this->class : $this->class['value'];
6796
+        if( !empty( $this->class['value'] )) {
6797
+            return ( $inclParam ) ? $this->class : $this->class['value'];
6798
+        }
6000 6799
         break;
6001 6800
       case 'COMMENT':
6002
-        if( !isset( $this->comment[$propix] )) return FALSE;
6801
+        if( !isset( $this->comment[$propix] )) {
6802
+            return FALSE;
6803
+        }
6003 6804
         return ( $inclParam ) ? $this->comment[$propix] : $this->comment[$propix]['value'];
6004 6805
         break;
6005 6806
       case 'COMPLETED':
6006
-        if( !empty( $this->completed['value'] )) return ( $inclParam ) ? $this->completed : $this->completed['value'];
6807
+        if( !empty( $this->completed['value'] )) {
6808
+            return ( $inclParam ) ? $this->completed : $this->completed['value'];
6809
+        }
6007 6810
         break;
6008 6811
       case 'CONTACT':
6009
-        if( !isset( $this->contact[$propix] )) return FALSE;
6812
+        if( !isset( $this->contact[$propix] )) {
6813
+            return FALSE;
6814
+        }
6010 6815
         return ( $inclParam ) ? $this->contact[$propix] : $this->contact[$propix]['value'];
6011 6816
         break;
6012 6817
       case 'CREATED':
6013
-        if( !empty( $this->created['value'] )) return ( $inclParam ) ? $this->created : $this->created['value'];
6818
+        if( !empty( $this->created['value'] )) {
6819
+            return ( $inclParam ) ? $this->created : $this->created['value'];
6820
+        }
6014 6821
         break;
6015 6822
       case 'DESCRIPTION':
6016
-        if( !isset( $this->description[$propix] )) return FALSE;
6823
+        if( !isset( $this->description[$propix] )) {
6824
+            return FALSE;
6825
+        }
6017 6826
         return ( $inclParam ) ? $this->description[$propix] : $this->description[$propix]['value'];
6018 6827
         break;
6019 6828
       case 'DTEND':
6020
-        if( !empty( $this->dtend['value'] )) return ( $inclParam ) ? $this->dtend : $this->dtend['value'];
6829
+        if( !empty( $this->dtend['value'] )) {
6830
+            return ( $inclParam ) ? $this->dtend : $this->dtend['value'];
6831
+        }
6021 6832
         break;
6022 6833
       case 'DTSTAMP':
6023
-        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
6024
-          return;
6025
-        if( !isset( $this->dtstamp['value'] ))
6026
-          $this->_makeDtstamp();
6834
+        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
6835
+                  return;
6836
+        }
6837
+        if( !isset( $this->dtstamp['value'] )) {
6838
+                  $this->_makeDtstamp();
6839
+        }
6027 6840
         return ( $inclParam ) ? $this->dtstamp : $this->dtstamp['value'];
6028 6841
         break;
6029 6842
       case 'DTSTART':
6030
-        if( !empty( $this->dtstart['value'] )) return ( $inclParam ) ? $this->dtstart : $this->dtstart['value'];
6843
+        if( !empty( $this->dtstart['value'] )) {
6844
+            return ( $inclParam ) ? $this->dtstart : $this->dtstart['value'];
6845
+        }
6031 6846
         break;
6032 6847
       case 'DUE':
6033
-        if( !empty( $this->due['value'] )) return ( $inclParam ) ? $this->due : $this->due['value'];
6848
+        if( !empty( $this->due['value'] )) {
6849
+            return ( $inclParam ) ? $this->due : $this->due['value'];
6850
+        }
6034 6851
         break;
6035 6852
       case 'DURATION':
6036
-        if( !isset( $this->duration['value'] )) return FALSE;
6853
+        if( !isset( $this->duration['value'] )) {
6854
+            return FALSE;
6855
+        }
6037 6856
         $value = ( $specform ) ? $this->duration2date() : $this->duration['value'];
6038 6857
         return ( $inclParam ) ? array( 'value' => $value, 'params' =>  $this->duration['params'] ) : $value;
6039 6858
         break;
6040 6859
       case 'EXDATE':
6041
-        if( !isset( $this->exdate[$propix] )) return FALSE;
6860
+        if( !isset( $this->exdate[$propix] )) {
6861
+            return FALSE;
6862
+        }
6042 6863
         return ( $inclParam ) ? $this->exdate[$propix] : $this->exdate[$propix]['value'];
6043 6864
         break;
6044 6865
       case 'EXRULE':
6045
-        if( !isset( $this->exrule[$propix] )) return FALSE;
6866
+        if( !isset( $this->exrule[$propix] )) {
6867
+            return FALSE;
6868
+        }
6046 6869
         return ( $inclParam ) ? $this->exrule[$propix] : $this->exrule[$propix]['value'];
6047 6870
         break;
6048 6871
       case 'FREEBUSY':
6049
-        if( !isset( $this->freebusy[$propix] )) return FALSE;
6872
+        if( !isset( $this->freebusy[$propix] )) {
6873
+            return FALSE;
6874
+        }
6050 6875
         return ( $inclParam ) ? $this->freebusy[$propix] : $this->freebusy[$propix]['value'];
6051 6876
         break;
6052 6877
       case 'GEO':
6053
-        if( !empty( $this->geo['value'] )) return ( $inclParam ) ? $this->geo : $this->geo['value'];
6878
+        if( !empty( $this->geo['value'] )) {
6879
+            return ( $inclParam ) ? $this->geo : $this->geo['value'];
6880
+        }
6054 6881
         break;
6055 6882
       case 'LAST-MODIFIED':
6056
-        if( !empty( $this->lastmodified['value'] )) return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value'];
6883
+        if( !empty( $this->lastmodified['value'] )) {
6884
+            return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value'];
6885
+        }
6057 6886
         break;
6058 6887
       case 'LOCATION':
6059
-        if( !empty( $this->location['value'] )) return ( $inclParam ) ? $this->location : $this->location['value'];
6888
+        if( !empty( $this->location['value'] )) {
6889
+            return ( $inclParam ) ? $this->location : $this->location['value'];
6890
+        }
6060 6891
         break;
6061 6892
       case 'ORGANIZER':
6062
-        if( !empty( $this->organizer['value'] )) return ( $inclParam ) ? $this->organizer : $this->organizer['value'];
6893
+        if( !empty( $this->organizer['value'] )) {
6894
+            return ( $inclParam ) ? $this->organizer : $this->organizer['value'];
6895
+        }
6063 6896
         break;
6064 6897
       case 'PERCENT-COMPLETE':
6065
-        if( !empty( $this->percentcomplete['value'] )) return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value'];
6898
+        if( !empty( $this->percentcomplete['value'] )) {
6899
+            return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value'];
6900
+        }
6066 6901
         break;
6067 6902
       case 'PRIORITY':
6068
-        if( !empty( $this->priority['value'] )) return ( $inclParam ) ? $this->priority : $this->priority['value'];
6903
+        if( !empty( $this->priority['value'] )) {
6904
+            return ( $inclParam ) ? $this->priority : $this->priority['value'];
6905
+        }
6069 6906
         break;
6070 6907
       case 'RDATE':
6071
-        if( !isset( $this->rdate[$propix] )) return FALSE;
6908
+        if( !isset( $this->rdate[$propix] )) {
6909
+            return FALSE;
6910
+        }
6072 6911
         return ( $inclParam ) ? $this->rdate[$propix] : $this->rdate[$propix]['value'];
6073 6912
         break;
6074 6913
       case 'RECURRENCE-ID':
6075
-        if( !empty( $this->recurrenceid['value'] )) return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value'];
6914
+        if( !empty( $this->recurrenceid['value'] )) {
6915
+            return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value'];
6916
+        }
6076 6917
         break;
6077 6918
       case 'RELATED-TO':
6078
-        if( !isset( $this->relatedto[$propix] )) return FALSE;
6919
+        if( !isset( $this->relatedto[$propix] )) {
6920
+            return FALSE;
6921
+        }
6079 6922
         return ( $inclParam ) ? $this->relatedto[$propix] : $this->relatedto[$propix]['value'];
6080 6923
         break;
6081 6924
       case 'REPEAT':
6082
-        if( !empty( $this->repeat['value'] )) return ( $inclParam ) ? $this->repeat : $this->repeat['value'];
6925
+        if( !empty( $this->repeat['value'] )) {
6926
+            return ( $inclParam ) ? $this->repeat : $this->repeat['value'];
6927
+        }
6083 6928
         break;
6084 6929
       case 'REQUEST-STATUS':
6085
-        if( !isset( $this->requeststatus[$propix] )) return FALSE;
6930
+        if( !isset( $this->requeststatus[$propix] )) {
6931
+            return FALSE;
6932
+        }
6086 6933
         return ( $inclParam ) ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value'];
6087 6934
         break;
6088 6935
       case 'RESOURCES':
6089
-        if( !isset( $this->resources[$propix] )) return FALSE;
6936
+        if( !isset( $this->resources[$propix] )) {
6937
+            return FALSE;
6938
+        }
6090 6939
         return ( $inclParam ) ? $this->resources[$propix] : $this->resources[$propix]['value'];
6091 6940
         break;
6092 6941
       case 'RRULE':
6093
-        if( !isset( $this->rrule[$propix] )) return FALSE;
6942
+        if( !isset( $this->rrule[$propix] )) {
6943
+            return FALSE;
6944
+        }
6094 6945
         return ( $inclParam ) ? $this->rrule[$propix] : $this->rrule[$propix]['value'];
6095 6946
         break;
6096 6947
       case 'SEQUENCE':
6097
-        if( !empty( $this->sequence['value'] )) return ( $inclParam ) ? $this->sequence : $this->sequence['value'];
6948
+        if( !empty( $this->sequence['value'] )) {
6949
+            return ( $inclParam ) ? $this->sequence : $this->sequence['value'];
6950
+        }
6098 6951
         break;
6099 6952
       case 'STATUS':
6100
-        if( !empty( $this->status['value'] )) return ( $inclParam ) ? $this->status : $this->status['value'];
6953
+        if( !empty( $this->status['value'] )) {
6954
+            return ( $inclParam ) ? $this->status : $this->status['value'];
6955
+        }
6101 6956
         break;
6102 6957
       case 'SUMMARY':
6103
-        if( !empty( $this->summary['value'] )) return ( $inclParam ) ? $this->summary : $this->summary['value'];
6958
+        if( !empty( $this->summary['value'] )) {
6959
+            return ( $inclParam ) ? $this->summary : $this->summary['value'];
6960
+        }
6104 6961
         break;
6105 6962
       case 'TRANSP':
6106
-        if( !empty( $this->transp['value'] )) return ( $inclParam ) ? $this->transp : $this->transp['value'];
6963
+        if( !empty( $this->transp['value'] )) {
6964
+            return ( $inclParam ) ? $this->transp : $this->transp['value'];
6965
+        }
6107 6966
         break;
6108 6967
       case 'TRIGGER':
6109
-        if( !empty( $this->trigger['value'] )) return ( $inclParam ) ? $this->trigger : $this->trigger['value'];
6968
+        if( !empty( $this->trigger['value'] )) {
6969
+            return ( $inclParam ) ? $this->trigger : $this->trigger['value'];
6970
+        }
6110 6971
         break;
6111 6972
       case 'TZID':
6112
-        if( !empty( $this->tzid['value'] )) return ( $inclParam ) ? $this->tzid : $this->tzid['value'];
6973
+        if( !empty( $this->tzid['value'] )) {
6974
+            return ( $inclParam ) ? $this->tzid : $this->tzid['value'];
6975
+        }
6113 6976
         break;
6114 6977
       case 'TZNAME':
6115
-        if( !isset( $this->tzname[$propix] )) return FALSE;
6978
+        if( !isset( $this->tzname[$propix] )) {
6979
+            return FALSE;
6980
+        }
6116 6981
         return ( $inclParam ) ? $this->tzname[$propix] : $this->tzname[$propix]['value'];
6117 6982
         break;
6118 6983
       case 'TZOFFSETFROM':
6119
-        if( !empty( $this->tzoffsetfrom['value'] )) return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value'];
6984
+        if( !empty( $this->tzoffsetfrom['value'] )) {
6985
+            return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value'];
6986
+        }
6120 6987
         break;
6121 6988
       case 'TZOFFSETTO':
6122
-        if( !empty( $this->tzoffsetto['value'] )) return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value'];
6989
+        if( !empty( $this->tzoffsetto['value'] )) {
6990
+            return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value'];
6991
+        }
6123 6992
         break;
6124 6993
       case 'TZURL':
6125
-        if( !empty( $this->tzurl['value'] )) return ( $inclParam ) ? $this->tzurl : $this->tzurl['value'];
6994
+        if( !empty( $this->tzurl['value'] )) {
6995
+            return ( $inclParam ) ? $this->tzurl : $this->tzurl['value'];
6996
+        }
6126 6997
         break;
6127 6998
       case 'UID':
6128
-        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
6129
-          return FALSE;
6130
-        if( empty( $this->uid['value'] ))
6131
-          $this->_makeuid();
6999
+        if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
7000
+                  return FALSE;
7001
+        }
7002
+        if( empty( $this->uid['value'] )) {
7003
+                  $this->_makeuid();
7004
+        }
6132 7005
         return ( $inclParam ) ? $this->uid : $this->uid['value'];
6133 7006
         break;
6134 7007
       case 'URL':
6135
-        if( !empty( $this->url['value'] )) return ( $inclParam ) ? $this->url : $this->url['value'];
7008
+        if( !empty( $this->url['value'] )) {
7009
+            return ( $inclParam ) ? $this->url : $this->url['value'];
7010
+        }
6136 7011
         break;
6137 7012
       default:
6138 7013
         if( $propName != 'X-PROP' ) {
6139
-          if( !isset( $this->xprop[$propName] )) return FALSE;
7014
+          if( !isset( $this->xprop[$propName] )) {
7015
+              return FALSE;
7016
+          }
6140 7017
           return ( $inclParam ) ? array( $propName, $this->xprop[$propName] )
6141 7018
                                 : array( $propName, $this->xprop[$propName]['value'] );
6142
-        }
6143
-        else {
6144
-          if( empty( $this->xprop )) return FALSE;
7019
+        } else {
7020
+          if( empty( $this->xprop )) {
7021
+              return FALSE;
7022
+          }
6145 7023
           $xpropno = 0;
6146 7024
           foreach( $this->xprop as $xpropkey => $xpropvalue ) {
6147
-            if( $propix == $xpropno )
6148
-              return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
7025
+            if( $propix == $xpropno ) {
7026
+                          return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
6149 7027
                                     : array( $xpropkey, $this->xprop[$xpropkey]['value'] );
6150
-            else
6151
-              $xpropno++;
7028
+            } else {
7029
+                          $xpropno++;
7030
+            }
6152 7031
           }
6153 7032
           return FALSE; // not found ??
6154 7033
         }
@@ -6167,15 +7046,21 @@  discard block
 block discarded – undo
6167 7046
  */
6168 7047
   function setProperty() {
6169 7048
     $numargs    = func_num_args();
6170
-    if( 1 > $numargs ) return FALSE;
7049
+    if( 1 > $numargs ) {
7050
+        return FALSE;
7051
+    }
6171 7052
     $arglist    = func_get_args();
6172
-    if( $this->_notExistProp( $arglist[0] )) return FALSE;
6173
-    if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] )))
6174
-      return FALSE;
7053
+    if( $this->_notExistProp( $arglist[0] )) {
7054
+        return FALSE;
7055
+    }
7056
+    if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] ))) {
7057
+          return FALSE;
7058
+    }
6175 7059
     $arglist[0] = strtoupper( $arglist[0] );
6176 7060
     for( $argix=$numargs; $argix < 12; $argix++ ) {
6177
-      if( !isset( $arglist[$argix] ))
6178
-        $arglist[$argix] = null;
7061
+      if( !isset( $arglist[$argix] )) {
7062
+              $arglist[$argix] = null;
7063
+      }
6179 7064
     }
6180 7065
     switch( $arglist[0] ) {
6181 7066
       case 'ACTION':
@@ -6289,20 +7174,19 @@  discard block
 block discarded – undo
6289 7174
             $this->setComponent( $comp );
6290 7175
             $comp =  & $this;
6291 7176
             continue;
6292
-          }
6293
-          elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) {
7177
+          } elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) {
6294 7178
             $comp = new valarm();
6295 7179
             continue;
7180
+          } else {
7181
+                      $comp->unparsed[] = $line;
6296 7182
           }
6297
-          else
6298
-            $comp->unparsed[] = $line;
6299 7183
         }
7184
+      } else {
7185
+              $this->unparsed = array( trim( $unparsedtext ));
6300 7186
       }
6301
-      else
6302
-        $this->unparsed = array( trim( $unparsedtext ));
7187
+    } elseif( !isset( $this->unparsed )) {
7188
+          $this->unparsed = array();
6303 7189
     }
6304
-    elseif( !isset( $this->unparsed ))
6305
-      $this->unparsed = array();
6306 7190
             /* concatenate property values spread over several lines */
6307 7191
     $lastix    = -1;
6308 7192
     $propnames = array( 'action', 'attach', 'attendee', 'categories', 'comment', 'completed'
@@ -6326,8 +7210,7 @@  discard block
 block discarded – undo
6326 7210
         $newProp = FALSE;
6327 7211
         $lastix++;
6328 7212
         $proprows[$lastix]  = $line;
6329
-      }
6330
-      else {
7213
+      } else {
6331 7214
             /* remove line breaks */
6332 7215
         if(( '\n' == substr( $proprows[$lastix], -2 )) &&
6333 7216
            (  ' ' == substr( $line, 0, 1 ))) {
@@ -6340,14 +7223,15 @@  discard block
 block discarded – undo
6340 7223
             /* parse each property 'line' */
6341 7224
     foreach( $proprows as $line ) {
6342 7225
       $line = str_replace( "\n ", '', $line );
6343
-      if( '\n' == substr( $line, -2 ))
6344
-        $line = substr( $line, 0, strlen( $line ) - 2 );
7226
+      if( '\n' == substr( $line, -2 )) {
7227
+              $line = substr( $line, 0, strlen( $line ) - 2 );
7228
+      }
6345 7229
             /* get propname, (problem with x-properties, otherwise in previous loop) */
6346 7230
       $cix = $propname = null;
6347 7231
       for( $cix=0; $cix < strlen( $line ); $cix++ ) {
6348
-        if( in_array( $line{$cix}, array( ':', ';' )))
6349
-          break;
6350
-        else {
7232
+        if( in_array( $line{$cix}, array( ':', ';' ))) {
7233
+                  break;
7234
+        } else {
6351 7235
           $propname .= $line{$cix};
6352 7236
         }
6353 7237
       }
@@ -6380,27 +7264,30 @@  discard block
 block discarded – undo
6380 7264
             break;
6381 7265
           }
6382 7266
         }
6383
-        if( ';' == $line{$cix} )
6384
-          $attr[++$attrix] = null;
6385
-        else
6386
-          $attr[$attrix] .= $line{$cix};
7267
+        if( ';' == $line{$cix} ) {
7268
+                  $attr[++$attrix] = null;
7269
+        } else {
7270
+                  $attr[$attrix] .= $line{$cix};
7271
+        }
6387 7272
       }
6388 7273
             /* make attributes in array format */
6389 7274
       $propattr = array();
6390 7275
       foreach( $attr as $attribute ) {
6391 7276
         $attrsplit = explode( '=', $attribute, 2 );
6392
-        if( 1 < count( $attrsplit ))
6393
-          $propattr[$attrsplit[0]] = $attrsplit[1];
6394
-        else
6395
-          $propattr[] = $attribute;
7277
+        if( 1 < count( $attrsplit )) {
7278
+                  $propattr[$attrsplit[0]] = $attrsplit[1];
7279
+        } else {
7280
+                  $propattr[] = $attribute;
7281
+        }
6396 7282
       }
6397 7283
             /* call setProperty( $propname.. . */
6398 7284
       switch( $propname ) {
6399 7285
         case 'ATTENDEE':
6400 7286
           foreach( $propattr as $pix => $attr ) {
6401 7287
             $attr2 = explode( ',', $attr );
6402
-              if( 1 < count( $attr2 ))
6403
-                $propattr[$pix] = $attr2;
7288
+              if( 1 < count( $attr2 )) {
7289
+                              $propattr[$pix] = $attr2;
7290
+              }
6404 7291
           }
6405 7292
           $this->setProperty( $propname, $line, $propattr );
6406 7293
           break;
@@ -6418,13 +7305,14 @@  discard block
 block discarded – undo
6418 7305
             }
6419 7306
             if( 1 < count( $content )) {
6420 7307
               $content = array_values( $content );
6421
-              foreach( $content as $cix => $contentPart )
6422
-                $content[$cix] = $this->_strunrep( $contentPart );
7308
+              foreach( $content as $cix => $contentPart ) {
7309
+                              $content[$cix] = $this->_strunrep( $contentPart );
7310
+              }
6423 7311
               $this->setProperty( $propname, $content, $propattr );
6424 7312
               break;
7313
+            } else {
7314
+                          $line = reset( $content );
6425 7315
             }
6426
-            else
6427
-              $line = reset( $content );
6428 7316
           }
6429 7317
         case 'X-':
6430 7318
           $propname = ( isset( $propname2 )) ? $propname2 : $propname;
@@ -6433,8 +7321,9 @@  discard block
 block discarded – undo
6433 7321
         case 'DESCRIPTION':
6434 7322
         case 'LOCATION':
6435 7323
         case 'SUMMARY':
6436
-          if( empty( $line ))
6437
-            $propattr = null;
7324
+          if( empty( $line )) {
7325
+                      $propattr = null;
7326
+          }
6438 7327
           $this->setProperty( $propname, $this->_strunrep( $line ), $propattr );
6439 7328
           unset( $propname2 );
6440 7329
           break;
@@ -6454,15 +7343,17 @@  discard block
 block discarded – undo
6454 7343
           $values = explode( ',', $line );
6455 7344
           foreach( $values as $vix => $value ) {
6456 7345
             $value2 = explode( '/', $value );
6457
-            if( 1 < count( $value2 ))
6458
-              $values[$vix] = $value2;
7346
+            if( 1 < count( $value2 )) {
7347
+                          $values[$vix] = $value2;
7348
+            }
6459 7349
           }
6460 7350
           $this->setProperty( $propname, $fbtype, $values, $propattr );
6461 7351
           break;
6462 7352
         case 'GEO':
6463 7353
           $value = explode( ';', $line, 2 );
6464
-          if( 2 > count( $value ))
6465
-            $value[1] = null;
7354
+          if( 2 > count( $value )) {
7355
+                      $value[1] = null;
7356
+          }
6466 7357
           $this->setProperty( $propname, $value[0], $value[1], $propattr );
6467 7358
           break;
6468 7359
         case 'EXDATE':
@@ -6477,8 +7368,9 @@  discard block
 block discarded – undo
6477 7368
           $values = explode( ',', $line );
6478 7369
           foreach( $values as $vix => $value ) {
6479 7370
             $value2 = explode( '/', $value );
6480
-            if( 1 < count( $value2 ))
6481
-              $values[$vix] = $value2;
7371
+            if( 1 < count( $value2 )) {
7372
+                          $values[$vix] = $value2;
7373
+            }
6482 7374
           }
6483 7375
           $this->setProperty( $propname, $values, $propattr );
6484 7376
           break;
@@ -6487,8 +7379,10 @@  discard block
 block discarded – undo
6487 7379
           $values = explode( ';', $line );
6488 7380
           $recur = array();
6489 7381
           foreach( $values as $value2 ) {
6490
-            if( empty( $value2 ))
6491
-              continue; // ;-char in ending position ???
7382
+            if( empty( $value2 )) {
7383
+                          continue;
7384
+            }
7385
+            // ;-char in ending position ???
6492 7386
             $value3 = explode( '=', $value2, 2 );
6493 7387
             $rulelabel = strtoupper( $value3[0] );
6494 7388
             switch( $rulelabel ) {
@@ -6502,38 +7396,44 @@  discard block
 block discarded – undo
6502 7396
                     if(( ctype_alpha( substr( $value5, -1 ))) &&
6503 7397
                        ( ctype_alpha( substr( $value5, -2, 1 )))) {
6504 7398
                       $dayname = substr( $value5, -2, 2 );
6505
-                      if( 2 < strlen( $value5 ))
6506
-                        $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
7399
+                      if( 2 < strlen( $value5 )) {
7400
+                                              $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
7401
+                      }
7402
+                    }
7403
+                    if( $dayno ) {
7404
+                                          $value6[] = $dayno;
7405
+                    }
7406
+                    if( $dayname ) {
7407
+                                          $value6['DAY'] = $dayname;
6507 7408
                     }
6508
-                    if( $dayno )
6509
-                      $value6[] = $dayno;
6510
-                    if( $dayname )
6511
-                      $value6['DAY'] = $dayname;
6512 7409
                     $value4[$v5ix] = $value6;
6513 7410
                   }
6514
-                }
6515
-                else {
7411
+                } else {
6516 7412
                   $value4 = array();
6517 7413
                   $dayno  = $dayname = null;
6518 7414
                   $value5 = trim( (string) $value3[1] );
6519 7415
                   if(( ctype_alpha( substr( $value5, -1 ))) &&
6520 7416
                      ( ctype_alpha( substr( $value5, -2, 1 )))) {
6521 7417
                       $dayname = substr( $value5, -2, 2 );
6522
-                    if( 2 < strlen( $value5 ))
6523
-                      $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
7418
+                    if( 2 < strlen( $value5 )) {
7419
+                                          $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
7420
+                    }
7421
+                  }
7422
+                  if( $dayno ) {
7423
+                                      $value4[] = $dayno;
7424
+                  }
7425
+                  if( $dayname ) {
7426
+                                      $value4['DAY'] = $dayname;
6524 7427
                   }
6525
-                  if( $dayno )
6526
-                    $value4[] = $dayno;
6527
-                  if( $dayname )
6528
-                    $value4['DAY'] = $dayname;
6529 7428
                 }
6530 7429
                 $recur[$rulelabel] = $value4;
6531 7430
                 break;
6532 7431
               }
6533 7432
               default: {
6534 7433
                 $value4 = explode( ',', $value3[1] );
6535
-                if( 1 < count( $value4 ))
6536
-                  $value3[1] = $value4;
7434
+                if( 1 < count( $value4 )) {
7435
+                                  $value3[1] = $value4;
7436
+                }
6537 7437
                 $recur[$rulelabel] = $value3[1];
6538 7438
                 break;
6539 7439
               }
@@ -6549,8 +7449,9 @@  discard block
 block discarded – undo
6549 7449
     unset( $this->unparsed, $proprows );
6550 7450
     if( isset( $this->components ) && is_array( $this->components ) && ( 0 < count( $this->components ))) {
6551 7451
       for( $six = 0; $six < count( $this->components ); $six++ ) {
6552
-        if( !empty( $this->components[$six]->unparsed ))
6553
-          $this->components[$six]->parse();
7452
+        if( !empty( $this->components[$six]->unparsed )) {
7453
+                  $this->components[$six]->parse();
7454
+        }
6554 7455
       }
6555 7456
     }
6556 7457
   }
@@ -6581,32 +7482,33 @@  discard block
 block discarded – undo
6581 7482
  * @return void
6582 7483
  */
6583 7484
   function deleteComponent( $arg1, $arg2=FALSE  ) {
6584
-    if( !isset( $this->components )) return FALSE;
7485
+    if( !isset( $this->components )) {
7486
+        return FALSE;
7487
+    }
6585 7488
     $argType = $index = null;
6586 7489
     if ( ctype_digit( (string) $arg1 )) {
6587 7490
       $argType = 'INDEX';
6588 7491
       $index   = (int) $arg1 - 1;
6589
-    }
6590
-    elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
7492
+    } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6591 7493
       $argType = strtolower( $arg1 );
6592 7494
       $index   = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0;
6593 7495
     }
6594 7496
     $cix2dC = 0;
6595 7497
     foreach ( $this->components as $cix => $component) {
6596
-      if( empty( $component )) continue;
7498
+      if( empty( $component )) {
7499
+          continue;
7500
+      }
6597 7501
       unset( $component->propix );
6598 7502
       if(( 'INDEX' == $argType ) && ( $index == $cix )) {
6599 7503
         unset( $this->components[$cix] );
6600 7504
         return TRUE;
6601
-      }
6602
-      elseif( $argType == $component->objName ) {
7505
+      } elseif( $argType == $component->objName ) {
6603 7506
         if( $index == $cix2dC ) {
6604 7507
           unset( $this->components[$cix] );
6605 7508
           return TRUE;
6606 7509
         }
6607 7510
         $cix2dC++;
6608
-      }
6609
-      elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
7511
+      } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
6610 7512
         unset( $this->components[$cix] );
6611 7513
         return TRUE;
6612 7514
       }
@@ -6623,43 +7525,47 @@  discard block
 block discarded – undo
6623 7525
  * @return object
6624 7526
  */
6625 7527
   function getComponent ( $arg1=FALSE, $arg2=FALSE ) {
6626
-    if( !isset( $this->components )) return FALSE;
7528
+    if( !isset( $this->components )) {
7529
+        return FALSE;
7530
+    }
6627 7531
     $index = $argType = null;
6628 7532
     if ( !$arg1 ) {
6629 7533
       $argType = 'INDEX';
6630 7534
       $index   = $this->compix['INDEX'] =
6631 7535
         ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1;
6632
-    }
6633
-    elseif ( ctype_digit( (string) $arg1 )) {
7536
+    } elseif ( ctype_digit( (string) $arg1 )) {
6634 7537
       $argType = 'INDEX';
6635 7538
       $index   = (int) $arg1;
6636 7539
       unset( $this->compix );
6637
-    }
6638
-    elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
7540
+    } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6639 7541
       unset( $this->compix['INDEX'] );
6640 7542
       $argType = strtolower( $arg1 );
6641
-      if( !$arg2 )
6642
-        $index = $this->compix[$argType] =
7543
+      if( !$arg2 ) {
7544
+              $index = $this->compix[$argType] =
6643 7545
         ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1;
6644
-      else
6645
-        $index = (int) $arg2;
7546
+      } else {
7547
+              $index = (int) $arg2;
7548
+      }
6646 7549
     }
6647 7550
     $index  -= 1;
6648 7551
     $ckeys = array_keys( $this->components );
6649
-    if( !empty( $index) && ( $index > end( $ckeys )))
6650
-      return FALSE;
7552
+    if( !empty( $index) && ( $index > end( $ckeys ))) {
7553
+          return FALSE;
7554
+    }
6651 7555
     $cix2gC = 0;
6652 7556
     foreach( $this->components as $cix => $component ) {
6653
-      if( empty( $component )) continue;
7557
+      if( empty( $component )) {
7558
+          continue;
7559
+      }
6654 7560
       unset( $component->propix );
6655
-      if(( 'INDEX' == $argType ) && ( $index == $cix ))
6656
-        return $component->copy();
6657
-      elseif( $argType == $component->objName ) {
6658
-         if( $index == $cix2gC )
6659
-           return $component->copy();
7561
+      if(( 'INDEX' == $argType ) && ( $index == $cix )) {
7562
+              return $component->copy();
7563
+      } elseif( $argType == $component->objName ) {
7564
+         if( $index == $cix2gC ) {
7565
+                    return $component->copy();
7566
+         }
6660 7567
          $cix2gC++;
6661
-      }
6662
-      elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) {
7568
+      } elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) {
6663 7569
         unset( $component->propix );
6664 7570
         return $component->copy();
6665 7571
       }
@@ -6690,9 +7596,12 @@  discard block
 block discarded – undo
6690 7596
  * @return bool
6691 7597
  */
6692 7598
   function setComponent( $component, $arg1=FALSE, $arg2=FALSE  ) {
6693
-    if( !isset( $this->components )) return FALSE;
6694
-    if( '' >= $component->getConfig( 'language'))
6695
-      $component->setConfig( 'language',  $this->getConfig( 'language' ));
7599
+    if( !isset( $this->components )) {
7600
+        return FALSE;
7601
+    }
7602
+    if( '' >= $component->getConfig( 'language')) {
7603
+          $component->setConfig( 'language',  $this->getConfig( 'language' ));
7604
+    }
6696 7605
     $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
6697 7606
     $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
6698 7607
     $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
@@ -6711,27 +7620,26 @@  discard block
 block discarded – undo
6711 7620
     if ( ctype_digit( (string) $arg1 )) {
6712 7621
       $argType = 'INDEX';
6713 7622
       $index   = (int) $arg1 - 1;
6714
-    }
6715
-    elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
7623
+    } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6716 7624
       $argType = strtolower( $arg1 );
6717 7625
       $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0;
6718 7626
     }
6719 7627
     $cix2sC = 0;
6720 7628
     foreach ( $this->components as $cix => $component2 ) {
6721
-      if( empty( $component2 )) continue;
7629
+      if( empty( $component2 )) {
7630
+          continue;
7631
+      }
6722 7632
       unset( $component2->propix );
6723 7633
       if(( 'INDEX' == $argType ) && ( $index == $cix )) {
6724 7634
         $this->components[$cix] = $component->copy();
6725 7635
         return TRUE;
6726
-      }
6727
-      elseif( $argType == $component2->objName ) {
7636
+      } elseif( $argType == $component2->objName ) {
6728 7637
         if( $index == $cix2sC ) {
6729 7638
           $this->components[$cix] = $component->copy();
6730 7639
           return TRUE;
6731 7640
         }
6732 7641
         $cix2sC++;
6733
-      }
6734
-      elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) {
7642
+      } elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) {
6735 7643
         $this->components[$cix] = $component->copy();
6736 7644
         return TRUE;
6737 7645
       }
@@ -6750,9 +7658,12 @@  discard block
 block discarded – undo
6750 7658
   function createSubComponent() {
6751 7659
     $output = null;
6752 7660
     foreach( $this->components as $component ) {
6753
-      if( empty( $component )) continue;
6754
-      if( '' >= $component->getConfig( 'language'))
6755
-        $component->setConfig( 'language',  $this->getConfig( 'language' ));
7661
+      if( empty( $component )) {
7662
+          continue;
7663
+      }
7664
+      if( '' >= $component->getConfig( 'language')) {
7665
+              $component->setConfig( 'language',  $this->getConfig( 'language' ));
7666
+      }
6756 7667
       $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
6757 7668
       $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
6758 7669
       $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
@@ -6790,16 +7701,18 @@  discard block
 block discarded – undo
6790 7701
     $string = null;
6791 7702
     while( $strlen > 75 ) {
6792 7703
        $breakAtChar = 75;
6793
-       if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' )
6794
-         $breakAtChar = $breakAtChar - 1;
7704
+       if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' ) {
7705
+                $breakAtChar = $breakAtChar - 1;
7706
+       }
6795 7707
        $string .= substr( $tmp, 0, $breakAtChar );
6796 7708
        $string .= $this->nl;
6797 7709
        $tmp     = ' '.substr( $tmp, $breakAtChar );
6798 7710
        $strlen  = strlen( $tmp );
6799 7711
     } // while
6800 7712
     $string .= rtrim( $tmp ); // the rest
6801
-    if( $this->nl != substr( $string, ( 0 - strlen( $this->nl ))))
6802
-      $string .= $this->nl;
7713
+    if( $this->nl != substr( $string, ( 0 - strlen( $this->nl )))) {
7714
+          $string .= $this->nl;
7715
+    }
6803 7716
     return $string;
6804 7717
   }
6805 7718
 /**
@@ -6820,27 +7733,33 @@  discard block
 block discarded – undo
6820 7733
         $pos = 0;
6821 7734
         while( $pos <= strlen( $string )) {
6822 7735
           $pos = strpos( $string, "\\", $pos );
6823
-          if( FALSE === $pos )
6824
-            break;
7736
+          if( FALSE === $pos ) {
7737
+                      break;
7738
+          }
6825 7739
           if( !in_array( $string{($pos + 1)}, array( 'n', 'N', 'r', ',', ';' ))) {
6826 7740
             $string = substr( $string, 0, $pos )."\\".substr( $string, ( $pos + 1 ));
6827 7741
             $pos += 1;
6828 7742
           }
6829 7743
           $pos += 1;
6830 7744
         }
6831
-        if( FALSE !== strpos( $string, '"' ))
6832
-          $string = str_replace('"',   "'",       $string);
6833
-        if( FALSE !== strpos( $string, ',' ))
6834
-          $string = str_replace(',',   '\,',      $string);
6835
-        if( FALSE !== strpos( $string, ';' ))
6836
-          $string = str_replace(';',   '\;',      $string);
6837
-        if( FALSE !== strpos( $string, "\r\n" ))
6838
-          $string = str_replace( "\r\n", '\n',    $string);
6839
-        elseif( FALSE !== strpos( $string, "\r" ))
6840
-          $string = str_replace( "\r", '\n',      $string);
6841
-        if( FALSE !== strpos( $string, '\N' ))
6842
-          $string = str_replace( '\N', '\n',      $string);
6843
-//        if( FALSE !== strpos( $string, $this->nl ))
7745
+        if( FALSE !== strpos( $string, '"' )) {
7746
+                  $string = str_replace('"',   "'",       $string);
7747
+        }
7748
+        if( FALSE !== strpos( $string, ',' )) {
7749
+                  $string = str_replace(',',   '\,',      $string);
7750
+        }
7751
+        if( FALSE !== strpos( $string, ';' )) {
7752
+                  $string = str_replace(';',   '\;',      $string);
7753
+        }
7754
+        if( FALSE !== strpos( $string, "\r\n" )) {
7755
+                  $string = str_replace( "\r\n", '\n',    $string);
7756
+        } elseif( FALSE !== strpos( $string, "\r" )) {
7757
+                  $string = str_replace( "\r", '\n',      $string);
7758
+        }
7759
+        if( FALSE !== strpos( $string, '\N' )) {
7760
+                  $string = str_replace( '\N', '\n',      $string);
7761
+        }
7762
+        //        if( FALSE !== strpos( $string, $this->nl ))
6844 7763
           $string = str_replace( $this->nl, '\n', $string);
6845 7764
         break;
6846 7765
     }
@@ -6993,8 +7912,9 @@  discard block
 block discarded – undo
6993 7912
     $component    .= $this->createSubComponent();
6994 7913
     $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
6995 7914
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
6996
-      foreach( $this->xcaldecl as $localxcaldecl )
6997
-        $xcaldecl[] = $localxcaldecl;
7915
+      foreach( $this->xcaldecl as $localxcaldecl ) {
7916
+              $xcaldecl[] = $localxcaldecl;
7917
+      }
6998 7918
     }
6999 7919
     return $component;
7000 7920
   }
@@ -7132,8 +8052,9 @@  discard block
 block discarded – undo
7132 8052
     $component    .= $this->createSubComponent();
7133 8053
     $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
7134 8054
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7135
-      foreach( $this->xcaldecl as $localxcaldecl )
7136
-        $xcaldecl[] = $localxcaldecl;
8055
+      foreach( $this->xcaldecl as $localxcaldecl ) {
8056
+              $xcaldecl[] = $localxcaldecl;
8057
+      }
7137 8058
     }
7138 8059
     return $component;
7139 8060
   }
@@ -7242,8 +8163,9 @@  discard block
 block discarded – undo
7242 8163
     $component .= $this->createXprop();
7243 8164
     $component .= $this->componentEnd1.$objectname.$this->componentEnd2;
7244 8165
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7245
-      foreach( $this->xcaldecl as $localxcaldecl )
7246
-        $xcaldecl[] = $localxcaldecl;
8166
+      foreach( $this->xcaldecl as $localxcaldecl ) {
8167
+              $xcaldecl[] = $localxcaldecl;
8168
+      }
7247 8169
     }
7248 8170
     return $component;
7249 8171
   }
@@ -7318,8 +8240,9 @@  discard block
 block discarded – undo
7318 8240
     $component .= $this->createXprop();
7319 8241
     $component .= $this->componentEnd1.$objectname.$this->componentEnd2;
7320 8242
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7321
-      foreach( $this->xcaldecl as $localxcaldecl )
7322
-        $xcaldecl[] = $localxcaldecl;
8243
+      foreach( $this->xcaldecl as $localxcaldecl ) {
8244
+              $xcaldecl[] = $localxcaldecl;
8245
+      }
7323 8246
     }
7324 8247
     return $component;
7325 8248
   }
@@ -7419,10 +8342,11 @@  discard block
 block discarded – undo
7419 8342
  * @return void
7420 8343
  */
7421 8344
   function vtimezone( $timezonetype=FALSE ) {
7422
-    if( !$timezonetype )
7423
-      $this->timezonetype = 'VTIMEZONE';
7424
-    else
7425
-      $this->timezonetype = strtoupper( $timezonetype );
8345
+    if( !$timezonetype ) {
8346
+          $this->timezonetype = 'VTIMEZONE';
8347
+    } else {
8348
+          $this->timezonetype = strtoupper( $timezonetype );
8349
+    }
7426 8350
     $this->calendarComponent();
7427 8351
 
7428 8352
     $this->comment         = '';
@@ -7464,8 +8388,9 @@  discard block
 block discarded – undo
7464 8388
     $component    .= $this->createSubComponent();
7465 8389
     $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
7466 8390
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7467
-      foreach( $this->xcaldecl as $localxcaldecl )
7468
-        $xcaldecl[] = $localxcaldecl;
8391
+      foreach( $this->xcaldecl as $localxcaldecl ) {
8392
+              $xcaldecl[] = $localxcaldecl;
8393
+      }
7469 8394
     }
7470 8395
     return $component;
7471 8396
   }
Please login to merge, or discard this patch.
main/inc/lib/events_dispatcher.class.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,9 +18,11 @@
 block discarded – undo
18 18
 
19 19
         foreach ($event_config[$event_name]["actions"] as $func) {
20 20
             $execute = true;
21
-            if (!function_exists($func)) // if the function doesn't exist, we log
21
+            if (!function_exists($func)) {
22
+                // if the function doesn't exist, we log
22 23
             {
23 24
                 error_log("EventsDispatcher warning : ".$func." does not exist.");
25
+            }
24 26
                 $execute = false;
25 27
             }
26 28
 
Please login to merge, or discard this patch.
main/inc/lib/glossary.lib.php 1 patch
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -108,8 +108,9 @@  discard block
 block discarded – undo
108 108
         // check if the glossary term already exists
109 109
         if (GlossaryManager::glossary_exists($values['glossary_title'])) {
110 110
             // display the feedback message
111
-            if ($message)
112
-                Display::display_error_message(get_lang('GlossaryTermAlreadyExistsYouShouldEditIt'));
111
+            if ($message) {
112
+                            Display::display_error_message(get_lang('GlossaryTermAlreadyExistsYouShouldEditIt'));
113
+            }
113 114
             return false;
114 115
         } else {
115 116
 
@@ -165,8 +166,9 @@  discard block
 block discarded – undo
165 166
         // check if the glossary term already exists
166 167
         if (GlossaryManager::glossary_exists($values['glossary_title'],$values['glossary_id'])) {
167 168
             // display the feedback message
168
-            if ($message)
169
-                Display::display_error_message(get_lang('GlossaryTermAlreadyExistsYouShouldEditIt'));
169
+            if ($message) {
170
+                            Display::display_error_message(get_lang('GlossaryTermAlreadyExistsYouShouldEditIt'));
171
+            }
170 172
             return false;
171 173
         } else {
172 174
             $sql = "UPDATE $t_glossary SET
@@ -188,8 +190,9 @@  discard block
 block discarded – undo
188 190
                 api_get_user_id()
189 191
             );
190 192
             // display the feedback message
191
-            if ($message)
192
-                Display::display_confirmation_message(get_lang('TermUpdated'));
193
+            if ($message) {
194
+                            Display::display_confirmation_message(get_lang('TermUpdated'));
195
+            }
193 196
         }
194 197
 
195 198
         return true;
@@ -323,8 +326,9 @@  discard block
 block discarded – undo
323 326
         // reorder the remaining terms
324 327
         GlossaryManager::reorder_glossary();
325 328
         $_SESSION['max_glossary_display'] = GlossaryManager::get_max_glossary_item();
326
-        if ($message)
327
-            Display::display_confirmation_message(get_lang('TermDeleted'));
329
+        if ($message) {
330
+                    Display::display_confirmation_message(get_lang('TermDeleted'));
331
+        }
328 332
         return true;
329 333
     }
330 334
 
@@ -633,8 +637,9 @@  discard block
 block discarded – undo
633 637
                  WHERE c_id = $course_id  AND glossary_id = '".Database::escape_string($next_id)."'";
634 638
         Database::query($sql1);
635 639
         Database::query($sql2);
636
-        if ($message)
637
-            Display::display_confirmation_message(get_lang('TermMoved'));
640
+        if ($message) {
641
+                    Display::display_confirmation_message(get_lang('TermMoved'));
642
+        }
638 643
     }
639 644
 
640 645
     /**
Please login to merge, or discard this patch.
main/inc/lib/internationalization.lib.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1710,8 +1710,7 @@
 block discarded – undo
1710 1710
             }
1711 1711
         }
1712 1712
         return false;
1713
-    }
1714
-    elseif (is_array($encoding2)) {
1713
+    } elseif (is_array($encoding2)) {
1715 1714
         foreach ($encoding2 as $encoding) {
1716 1715
             if (api_equal_encodings($encoding1, $encoding, $strict)) {
1717 1716
                 return true;
Please login to merge, or discard this patch.
main/inc/lib/rights.lib.php 1 patch
Braces   +23 added lines, -15 removed lines patch added patch discarded remove patch
@@ -16,31 +16,39 @@
 block discarded – undo
16 16
 	// warning the goal of this function is to enforce rights managment in Chamilo
17 17
 	// thus default return value is always true
18 18
 	public static function hasRight($handler) {
19
-		if (array_key_exists($handler, self::$rights_cache))
20
-			return self::$rights_cache[$handler];
19
+		if (array_key_exists($handler, self::$rights_cache)) {
20
+					return self::$rights_cache[$handler];
21
+		}
21 22
 
22
-		if (!array_key_exists($handler, self::$rights))
23
-			return true; // handler does not exists
23
+		if (!array_key_exists($handler, self::$rights)) {
24
+					return true;
25
+		}
26
+		// handler does not exists
24 27
 
25 28
 		if (self::$rights[$handler]['type'] == 'sql') {
26 29
 			$result = Database::query(self::$rights[$handler]['sql']);
27
-			if (Database::num_rows($result) > 0)
28
-				$result = true;
29
-			else
30
-				$result = false;
31
-		} else if (self::$rights[$handler]['type'] == 'const')
32
-			$result = self::$rights[$handler]['const'];
33
-		else if (self::$rights[$handler]['type'] == 'func')
34
-			$result = self::$rights[$handler]['func']();
35
-		else // handler type not implemented
30
+			if (Database::num_rows($result) > 0) {
31
+							$result = true;
32
+			} else {
33
+							$result = false;
34
+			}
35
+		} else if (self::$rights[$handler]['type'] == 'const') {
36
+					$result = self::$rights[$handler]['const'];
37
+		} else if (self::$rights[$handler]['type'] == 'func') {
38
+					$result = self::$rights[$handler]['func']();
39
+		} else {
40
+		    // handler type not implemented
36 41
 			return true;
42
+		}
37 43
 		self::$rights_cache[$handler] = $result;
38 44
 		return $result;
39 45
 	}
40 46
 
41 47
 	public static function hasRightClosePageWithError($handler) {
42
-		if (hasRight($handler) == false)
43
-			die("You are not allowed here"); //FIXME
48
+		if (hasRight($handler) == false) {
49
+					die("You are not allowed here");
50
+		}
51
+		//FIXME
44 52
 	}
45 53
 
46 54
 }
Please login to merge, or discard this patch.