@@ -44,8 +44,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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] )) |
|
1274 | + if ( empty( $astart[$key] )) { |
|
1150 | 1275 | return -1; |
1151 | - elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] )) |
|
1276 | + } elseif( empty( $bstart[$key] )) { |
|
1152 | 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 |
||
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 */ |
|
1230 | 1399 | } |
1231 | - if( !$this->setConfig( 'filename', $parts['basename'] )) |
|
1232 | - return FALSE; /* err 4 */ |
|
1400 | + if( !$this->setConfig( 'filename', $parts['basename'] )) { |
|
1401 | + return FALSE; |
|
1402 | + } |
|
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 )) { |
@@ -1862,7 +2088,11 @@ discard block |
||
1862 | 2088 | * @return bool |
1863 | 2089 | */ |
1864 | 2090 | function setAttendee( $value, $params=FALSE, $index=FALSE ) { |
1865 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2091 | + if( empty( $value )) { |
|
2092 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
2093 | + } else { |
|
2094 | + return FALSE; |
|
2095 | + } |
|
1866 | 2096 | $value = str_replace ( 'MAILTO:', '', $value ); |
1867 | 2097 | $value = str_replace ( 'mailto:', '', $value ); |
1868 | 2098 | $params2 = array(); |
@@ -1878,16 +2108,17 @@ discard block |
||
1878 | 2108 | foreach( $optparamvalue as $part ) { |
1879 | 2109 | $part = str_replace( 'MAILTO:', '', $part ); |
1880 | 2110 | $part = str_replace( 'mailto:', '', $part ); |
1881 | - if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) |
|
1882 | - $part = substr( $part, 1, ( strlen($part)-2 )); |
|
2111 | + if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) { |
|
2112 | + $part = substr( $part, 1, ( strlen($part)-2 )); |
|
2113 | + } |
|
1883 | 2114 | $optarrays[$optparamlabel][] = $part; |
1884 | 2115 | } |
1885 | - } |
|
1886 | - else { |
|
2116 | + } else { |
|
1887 | 2117 | $part = str_replace( 'MAILTO:', '', $optparamvalue ); |
1888 | 2118 | $part = str_replace( 'mailto:', '', $part ); |
1889 | - if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) |
|
1890 | - $part = substr( $part, 1, ( strlen($part)-2 )); |
|
2119 | + if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) { |
|
2120 | + $part = substr( $part, 1, ( strlen($part)-2 )); |
|
2121 | + } |
|
1891 | 2122 | $optarrays[$optparamlabel][] = $part; |
1892 | 2123 | } |
1893 | 2124 | break; |
@@ -1897,14 +2128,16 @@ discard block |
||
1897 | 2128 | $optparamvalue = str_replace( 'mailto:', '', $optparamvalue ); |
1898 | 2129 | } |
1899 | 2130 | if(( '"' == substr( $optparamvalue, 0, 1 )) && |
1900 | - ( '"' == substr( $optparamvalue, -1 ))) |
|
1901 | - $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 )); |
|
2131 | + ( '"' == substr( $optparamvalue, -1 ))) { |
|
2132 | + $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 )); |
|
2133 | + } |
|
1902 | 2134 | $params2[$optparamlabel] = $optparamvalue; |
1903 | 2135 | break; |
1904 | 2136 | } // end switch( $optparamlabel.. . |
1905 | 2137 | } // end foreach( $optparam.. . |
1906 | - foreach( $optarrays as $optparamlabel => $optparams ) |
|
1907 | - $params2[$optparamlabel] = $optparams; |
|
2138 | + foreach( $optarrays as $optparamlabel => $optparams ) { |
|
2139 | + $params2[$optparamlabel] = $optparams; |
|
2140 | + } |
|
1908 | 2141 | } |
1909 | 2142 | // remove defaults |
1910 | 2143 | $this->_existRem( $params2, 'CUTYPE', 'INDIVIDUAL' ); |
@@ -1914,8 +2147,9 @@ discard block |
||
1914 | 2147 | // check language setting |
1915 | 2148 | if( isset( $params2['CN' ] )) { |
1916 | 2149 | $lang = $this->getConfig( 'language' ); |
1917 | - if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang )) |
|
1918 | - $params2['LANGUAGE' ] = $lang; |
|
2150 | + if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang )) { |
|
2151 | + $params2['LANGUAGE' ] = $lang; |
|
2152 | + } |
|
1919 | 2153 | } |
1920 | 2154 | $this->_setMval( $this->attendee, $value, $params2, FALSE, $index ); |
1921 | 2155 | return TRUE; |
@@ -1932,22 +2166,26 @@ discard block |
||
1932 | 2166 | * @return string |
1933 | 2167 | */ |
1934 | 2168 | function createCategories() { |
1935 | - if( empty( $this->categories )) return FALSE; |
|
2169 | + if( empty( $this->categories )) { |
|
2170 | + return FALSE; |
|
2171 | + } |
|
1936 | 2172 | $output = null; |
1937 | 2173 | foreach( $this->categories as $category ) { |
1938 | 2174 | if( empty( $category['value'] )) { |
1939 | - if ( $this->getConfig( 'allowEmpty' )) |
|
1940 | - $output .= $this->_createElement( 'CATEGORIES' ); |
|
2175 | + if ( $this->getConfig( 'allowEmpty' )) { |
|
2176 | + $output .= $this->_createElement( 'CATEGORIES' ); |
|
2177 | + } |
|
1941 | 2178 | continue; |
1942 | 2179 | } |
1943 | 2180 | $attributes = $this->_createParams( $category['params'], array( 'LANGUAGE' )); |
1944 | 2181 | if( is_array( $category['value'] )) { |
1945 | - foreach( $category['value'] as $cix => $categoryPart ) |
|
1946 | - $category['value'][$cix] = $this->_strrep( $categoryPart ); |
|
2182 | + foreach( $category['value'] as $cix => $categoryPart ) { |
|
2183 | + $category['value'][$cix] = $this->_strrep( $categoryPart ); |
|
2184 | + } |
|
1947 | 2185 | $content = implode( ',', $category['value'] ); |
2186 | + } else { |
|
2187 | + $content = $this->_strrep( $category['value'] ); |
|
1948 | 2188 | } |
1949 | - else |
|
1950 | - $content = $this->_strrep( $category['value'] ); |
|
1951 | 2189 | $output .= $this->_createElement( 'CATEGORIES', $attributes, $content ); |
1952 | 2190 | } |
1953 | 2191 | return $output; |
@@ -1963,7 +2201,11 @@ discard block |
||
1963 | 2201 | * @return bool |
1964 | 2202 | */ |
1965 | 2203 | function setCategories( $value, $params=FALSE, $index=FALSE ) { |
1966 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2204 | + if( empty( $value )) { |
|
2205 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
2206 | + } else { |
|
2207 | + return FALSE; |
|
2208 | + } |
|
1967 | 2209 | $this->_setMval( $this->categories, $value, $params, FALSE, $index ); |
1968 | 2210 | return TRUE; |
1969 | 2211 | } |
@@ -1979,9 +2221,12 @@ discard block |
||
1979 | 2221 | * @return string |
1980 | 2222 | */ |
1981 | 2223 | function createClass() { |
1982 | - if( empty( $this->class )) return FALSE; |
|
1983 | - if( empty( $this->class['value'] )) |
|
1984 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE; |
|
2224 | + if( empty( $this->class )) { |
|
2225 | + return FALSE; |
|
2226 | + } |
|
2227 | + if( empty( $this->class['value'] )) { |
|
2228 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE; |
|
2229 | + } |
|
1985 | 2230 | $attributes = $this->_createParams( $this->class['params'] ); |
1986 | 2231 | return $this->_createElement( 'CLASS', $attributes, $this->class['value'] ); |
1987 | 2232 | } |
@@ -1995,7 +2240,11 @@ discard block |
||
1995 | 2240 | * @return bool |
1996 | 2241 | */ |
1997 | 2242 | function setClass( $value, $params=FALSE ) { |
1998 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2243 | + if( empty( $value )) { |
|
2244 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
2245 | + } else { |
|
2246 | + return FALSE; |
|
2247 | + } |
|
1999 | 2248 | $this->class = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
2000 | 2249 | return TRUE; |
2001 | 2250 | } |
@@ -2011,11 +2260,15 @@ discard block |
||
2011 | 2260 | * @return string |
2012 | 2261 | */ |
2013 | 2262 | function createComment() { |
2014 | - if( empty( $this->comment )) return FALSE; |
|
2263 | + if( empty( $this->comment )) { |
|
2264 | + return FALSE; |
|
2265 | + } |
|
2015 | 2266 | $output = null; |
2016 | 2267 | foreach( $this->comment as $commentPart ) { |
2017 | 2268 | if( empty( $commentPart['value'] )) { |
2018 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'COMMENT' ); |
|
2269 | + if( $this->getConfig( 'allowEmpty' )) { |
|
2270 | + $output .= $this->_createElement( 'COMMENT' ); |
|
2271 | + } |
|
2019 | 2272 | continue; |
2020 | 2273 | } |
2021 | 2274 | $attributes = $this->_createParams( $commentPart['params'], array( 'ALTREP', 'LANGUAGE' )); |
@@ -2035,7 +2288,11 @@ discard block |
||
2035 | 2288 | * @return bool |
2036 | 2289 | */ |
2037 | 2290 | function setComment( $value, $params=FALSE, $index=FALSE ) { |
2038 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2291 | + if( empty( $value )) { |
|
2292 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
2293 | + } else { |
|
2294 | + return FALSE; |
|
2295 | + } |
|
2039 | 2296 | $this->_setMval( $this->comment, $value, $params, FALSE, $index ); |
2040 | 2297 | return TRUE; |
2041 | 2298 | } |
@@ -2051,16 +2308,20 @@ discard block |
||
2051 | 2308 | * @return string |
2052 | 2309 | */ |
2053 | 2310 | function createCompleted( ) { |
2054 | - if( empty( $this->completed )) return FALSE; |
|
2311 | + if( empty( $this->completed )) { |
|
2312 | + return FALSE; |
|
2313 | + } |
|
2055 | 2314 | if( !isset( $this->completed['value']['year'] ) && |
2056 | 2315 | !isset( $this->completed['value']['month'] ) && |
2057 | 2316 | !isset( $this->completed['value']['day'] ) && |
2058 | 2317 | !isset( $this->completed['value']['hour'] ) && |
2059 | 2318 | !isset( $this->completed['value']['min'] ) && |
2060 | - !isset( $this->completed['value']['sec'] )) |
|
2061 | - if( $this->getConfig( 'allowEmpty' )) |
|
2319 | + !isset( $this->completed['value']['sec'] )) { |
|
2320 | + if( $this->getConfig( 'allowEmpty' )) |
|
2062 | 2321 | return $this->_createElement( 'COMPLETED' ); |
2063 | - else return FALSE; |
|
2322 | + } else { |
|
2323 | + return FALSE; |
|
2324 | + } |
|
2064 | 2325 | $formatted = $this->_format_date_time( $this->completed['value'], 7 ); |
2065 | 2326 | $attributes = $this->_createParams( $this->completed['params'] ); |
2066 | 2327 | return $this->_createElement( 'COMPLETED', $attributes, $formatted ); |
@@ -2084,9 +2345,9 @@ discard block |
||
2084 | 2345 | if( $this->getConfig( 'allowEmpty' )) { |
2085 | 2346 | $this->completed = array( 'value' => null, 'params' => $this->_setParams( $params )); |
2086 | 2347 | return TRUE; |
2348 | + } else { |
|
2349 | + return FALSE; |
|
2087 | 2350 | } |
2088 | - else |
|
2089 | - return FALSE; |
|
2090 | 2351 | } |
2091 | 2352 | $this->completed = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
2092 | 2353 | return TRUE; |
@@ -2103,15 +2364,18 @@ discard block |
||
2103 | 2364 | * @return string |
2104 | 2365 | */ |
2105 | 2366 | function createContact() { |
2106 | - if( empty( $this->contact )) return FALSE; |
|
2367 | + if( empty( $this->contact )) { |
|
2368 | + return FALSE; |
|
2369 | + } |
|
2107 | 2370 | $output = null; |
2108 | 2371 | foreach( $this->contact as $contact ) { |
2109 | 2372 | if( !empty( $contact['value'] )) { |
2110 | 2373 | $attributes = $this->_createParams( $contact['params'], array( 'ALTREP', 'LANGUAGE' )); |
2111 | 2374 | $content = $this->_strrep( $contact['value'] ); |
2112 | 2375 | $output .= $this->_createElement( 'CONTACT', $attributes, $content ); |
2376 | + } elseif( $this->getConfig( 'allowEmpty' )) { |
|
2377 | + $output .= $this->_createElement( 'CONTACT' ); |
|
2113 | 2378 | } |
2114 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'CONTACT' ); |
|
2115 | 2379 | } |
2116 | 2380 | return $output; |
2117 | 2381 | } |
@@ -2126,7 +2390,11 @@ discard block |
||
2126 | 2390 | * @return bool |
2127 | 2391 | */ |
2128 | 2392 | function setContact( $value, $params=FALSE, $index=FALSE ) { |
2129 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2393 | + if( empty( $value )) { |
|
2394 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
2395 | + } else { |
|
2396 | + return FALSE; |
|
2397 | + } |
|
2130 | 2398 | $this->_setMval( $this->contact, $value, $params, FALSE, $index ); |
2131 | 2399 | return TRUE; |
2132 | 2400 | } |
@@ -2142,7 +2410,9 @@ discard block |
||
2142 | 2410 | * @return string |
2143 | 2411 | */ |
2144 | 2412 | function createCreated() { |
2145 | - if( empty( $this->created )) return FALSE; |
|
2413 | + if( empty( $this->created )) { |
|
2414 | + return FALSE; |
|
2415 | + } |
|
2146 | 2416 | $formatted = $this->_format_date_time( $this->created['value'], 7 ); |
2147 | 2417 | $attributes = $this->_createParams( $this->created['params'] ); |
2148 | 2418 | return $this->_createElement( 'CREATED', $attributes, $formatted ); |
@@ -2180,15 +2450,18 @@ discard block |
||
2180 | 2450 | * @return string |
2181 | 2451 | */ |
2182 | 2452 | function createDescription() { |
2183 | - if( empty( $this->description )) return FALSE; |
|
2453 | + if( empty( $this->description )) { |
|
2454 | + return FALSE; |
|
2455 | + } |
|
2184 | 2456 | $output = null; |
2185 | 2457 | foreach( $this->description as $description ) { |
2186 | 2458 | if( !empty( $description['value'] )) { |
2187 | 2459 | $attributes = $this->_createParams( $description['params'], array( 'ALTREP', 'LANGUAGE' )); |
2188 | 2460 | $content = $this->_strrep( $description['value'] ); |
2189 | 2461 | $output .= $this->_createElement( 'DESCRIPTION', $attributes, $content ); |
2462 | + } elseif( $this->getConfig( 'allowEmpty' )) { |
|
2463 | + $output .= $this->_createElement( 'DESCRIPTION' ); |
|
2190 | 2464 | } |
2191 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'DESCRIPTION' ); |
|
2192 | 2465 | } |
2193 | 2466 | return $output; |
2194 | 2467 | } |
@@ -2203,7 +2476,12 @@ discard block |
||
2203 | 2476 | * @return bool |
2204 | 2477 | */ |
2205 | 2478 | function setDescription( $value, $params=FALSE, $index=FALSE ) { |
2206 | - if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; } |
|
2479 | + if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) { |
|
2480 | + $value = null; |
|
2481 | + } else { |
|
2482 | + return FALSE; |
|
2483 | + } |
|
2484 | + } |
|
2207 | 2485 | $this->_setMval( $this->description, $value, $params, FALSE, $index ); |
2208 | 2486 | return TRUE; |
2209 | 2487 | } |
@@ -2219,16 +2497,20 @@ discard block |
||
2219 | 2497 | * @return string |
2220 | 2498 | */ |
2221 | 2499 | function createDtend() { |
2222 | - if( empty( $this->dtend )) return FALSE; |
|
2500 | + if( empty( $this->dtend )) { |
|
2501 | + return FALSE; |
|
2502 | + } |
|
2223 | 2503 | if( !isset( $this->dtend['value']['year'] ) && |
2224 | 2504 | !isset( $this->dtend['value']['month'] ) && |
2225 | 2505 | !isset( $this->dtend['value']['day'] ) && |
2226 | 2506 | !isset( $this->dtend['value']['hour'] ) && |
2227 | 2507 | !isset( $this->dtend['value']['min'] ) && |
2228 | - !isset( $this->dtend['value']['sec'] )) |
|
2229 | - if( $this->getConfig( 'allowEmpty' )) |
|
2508 | + !isset( $this->dtend['value']['sec'] )) { |
|
2509 | + if( $this->getConfig( 'allowEmpty' )) |
|
2230 | 2510 | return $this->_createElement( 'DTEND' ); |
2231 | - else return FALSE; |
|
2511 | + } else { |
|
2512 | + return FALSE; |
|
2513 | + } |
|
2232 | 2514 | $formatted = $this->_format_date_time( $this->dtend['value'] ); |
2233 | 2515 | $attributes = $this->_createParams( $this->dtend['params'] ); |
2234 | 2516 | return $this->_createElement( 'DTEND', $attributes, $formatted ); |
@@ -2253,9 +2535,9 @@ discard block |
||
2253 | 2535 | if( $this->getConfig( 'allowEmpty' )) { |
2254 | 2536 | $this->dtend = array( 'value' => null, 'params' => $this->_setParams( $params )); |
2255 | 2537 | return TRUE; |
2538 | + } else { |
|
2539 | + return FALSE; |
|
2256 | 2540 | } |
2257 | - else |
|
2258 | - return FALSE; |
|
2259 | 2541 | } |
2260 | 2542 | $this->dtend = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
2261 | 2543 | return TRUE; |
@@ -2277,8 +2559,9 @@ discard block |
||
2277 | 2559 | !isset( $this->dtstamp['value']['day'] ) && |
2278 | 2560 | !isset( $this->dtstamp['value']['hour'] ) && |
2279 | 2561 | !isset( $this->dtstamp['value']['min'] ) && |
2280 | - !isset( $this->dtstamp['value']['sec'] )) |
|
2281 | - $this->_makeDtstamp(); |
|
2562 | + !isset( $this->dtstamp['value']['sec'] )) { |
|
2563 | + $this->_makeDtstamp(); |
|
2564 | + } |
|
2282 | 2565 | $formatted = $this->_format_date_time( $this->dtstamp['value'], 7 ); |
2283 | 2566 | $attributes = $this->_createParams( $this->dtstamp['params'] ); |
2284 | 2567 | return $this->_createElement( 'DTSTAMP', $attributes, $formatted ); |
@@ -2314,10 +2597,11 @@ discard block |
||
2314 | 2597 | * @return TRUE |
2315 | 2598 | */ |
2316 | 2599 | function setDtstamp( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
2317 | - if( empty( $year )) |
|
2318 | - $this->_makeDtstamp(); |
|
2319 | - else |
|
2320 | - $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
|
2600 | + if( empty( $year )) { |
|
2601 | + $this->_makeDtstamp(); |
|
2602 | + } else { |
|
2603 | + $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
|
2604 | + } |
|
2321 | 2605 | return TRUE; |
2322 | 2606 | } |
2323 | 2607 | /*********************************************************************************/ |
@@ -2332,18 +2616,23 @@ discard block |
||
2332 | 2616 | * @return string |
2333 | 2617 | */ |
2334 | 2618 | function createDtstart() { |
2335 | - if( empty( $this->dtstart )) return FALSE; |
|
2619 | + if( empty( $this->dtstart )) { |
|
2620 | + return FALSE; |
|
2621 | + } |
|
2336 | 2622 | if( !isset( $this->dtstart['value']['year'] ) && |
2337 | 2623 | !isset( $this->dtstart['value']['month'] ) && |
2338 | 2624 | !isset( $this->dtstart['value']['day'] ) && |
2339 | 2625 | !isset( $this->dtstart['value']['hour'] ) && |
2340 | 2626 | !isset( $this->dtstart['value']['min'] ) && |
2341 | - !isset( $this->dtstart['value']['sec'] )) |
|
2342 | - if( $this->getConfig( 'allowEmpty' )) |
|
2627 | + !isset( $this->dtstart['value']['sec'] )) { |
|
2628 | + if( $this->getConfig( 'allowEmpty' )) |
|
2343 | 2629 | return $this->_createElement( 'DTSTART' ); |
2344 | - else return FALSE; |
|
2345 | - if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) |
|
2346 | - unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] ); |
|
2630 | + } else { |
|
2631 | + return FALSE; |
|
2632 | + } |
|
2633 | + if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) { |
|
2634 | + unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] ); |
|
2635 | + } |
|
2347 | 2636 | $formatted = $this->_format_date_time( $this->dtstart['value'] ); |
2348 | 2637 | $attributes = $this->_createParams( $this->dtstart['params'] ); |
2349 | 2638 | return $this->_createElement( 'DTSTART', $attributes, $formatted ); |
@@ -2368,9 +2657,9 @@ discard block |
||
2368 | 2657 | if( $this->getConfig( 'allowEmpty' )) { |
2369 | 2658 | $this->dtstart = array( 'value' => null, 'params' => $this->_setParams( $params )); |
2370 | 2659 | return TRUE; |
2660 | + } else { |
|
2661 | + return FALSE; |
|
2371 | 2662 | } |
2372 | - else |
|
2373 | - return FALSE; |
|
2374 | 2663 | } |
2375 | 2664 | $this->dtstart = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params, 'dtstart' ); |
2376 | 2665 | return TRUE; |
@@ -2387,16 +2676,20 @@ discard block |
||
2387 | 2676 | * @return string |
2388 | 2677 | */ |
2389 | 2678 | function createDue() { |
2390 | - if( empty( $this->due )) return FALSE; |
|
2679 | + if( empty( $this->due )) { |
|
2680 | + return FALSE; |
|
2681 | + } |
|
2391 | 2682 | if( !isset( $this->due['value']['year'] ) && |
2392 | 2683 | !isset( $this->due['value']['month'] ) && |
2393 | 2684 | !isset( $this->due['value']['day'] ) && |
2394 | 2685 | !isset( $this->due['value']['hour'] ) && |
2395 | 2686 | !isset( $this->due['value']['min'] ) && |
2396 | - !isset( $this->due['value']['sec'] )) |
|
2397 | - if( $this->getConfig( 'allowEmpty' )) |
|
2687 | + !isset( $this->due['value']['sec'] )) { |
|
2688 | + if( $this->getConfig( 'allowEmpty' )) |
|
2398 | 2689 | return $this->_createElement( 'DUE' ); |
2399 | - else return FALSE; |
|
2690 | + } else { |
|
2691 | + return FALSE; |
|
2692 | + } |
|
2400 | 2693 | $formatted = $this->_format_date_time( $this->due['value'] ); |
2401 | 2694 | $attributes = $this->_createParams( $this->due['params'] ); |
2402 | 2695 | return $this->_createElement( 'DUE', $attributes, $formatted ); |
@@ -2420,9 +2713,9 @@ discard block |
||
2420 | 2713 | if( $this->getConfig( 'allowEmpty' )) { |
2421 | 2714 | $this->due = array( 'value' => null, 'params' => $this->_setParams( $params )); |
2422 | 2715 | return TRUE; |
2716 | + } else { |
|
2717 | + return FALSE; |
|
2423 | 2718 | } |
2424 | - else |
|
2425 | - return FALSE; |
|
2426 | 2719 | } |
2427 | 2720 | $this->due = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
2428 | 2721 | return TRUE; |
@@ -2439,15 +2732,19 @@ discard block |
||
2439 | 2732 | * @return string |
2440 | 2733 | */ |
2441 | 2734 | function createDuration() { |
2442 | - if( empty( $this->duration )) return FALSE; |
|
2735 | + if( empty( $this->duration )) { |
|
2736 | + return FALSE; |
|
2737 | + } |
|
2443 | 2738 | if( !isset( $this->duration['value']['week'] ) && |
2444 | 2739 | !isset( $this->duration['value']['day'] ) && |
2445 | 2740 | !isset( $this->duration['value']['hour'] ) && |
2446 | 2741 | !isset( $this->duration['value']['min'] ) && |
2447 | - !isset( $this->duration['value']['sec'] )) |
|
2448 | - if( $this->getConfig( 'allowEmpty' )) |
|
2742 | + !isset( $this->duration['value']['sec'] )) { |
|
2743 | + if( $this->getConfig( 'allowEmpty' )) |
|
2449 | 2744 | return $this->_createElement( 'DURATION', array(), null ); |
2450 | - else return FALSE; |
|
2745 | + } else { |
|
2746 | + return FALSE; |
|
2747 | + } |
|
2451 | 2748 | $attributes = $this->_createParams( $this->duration['params'] ); |
2452 | 2749 | return $this->_createElement( 'DURATION', $attributes, $this->_format_duration( $this->duration['value'] )); |
2453 | 2750 | } |
@@ -2465,19 +2762,24 @@ discard block |
||
2465 | 2762 | * @return bool |
2466 | 2763 | */ |
2467 | 2764 | function setDuration( $week, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
2468 | - if( empty( $week )) if( $this->getConfig( 'allowEmpty' )) $week = null; else return FALSE; |
|
2469 | - if( is_array( $week ) && ( 1 <= count( $week ))) |
|
2470 | - $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day )); |
|
2471 | - elseif( is_string( $week ) && ( 3 <= strlen( trim( $week )))) { |
|
2765 | + if( empty( $week )) { |
|
2766 | + if( $this->getConfig( 'allowEmpty' )) $week = null; |
|
2767 | + } else { |
|
2768 | + return FALSE; |
|
2769 | + } |
|
2770 | + if( is_array( $week ) && ( 1 <= count( $week ))) { |
|
2771 | + $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day )); |
|
2772 | + } elseif( is_string( $week ) && ( 3 <= strlen( trim( $week )))) { |
|
2472 | 2773 | $week = trim( $week ); |
2473 | - if( in_array( substr( $week, 0, 1 ), array( '+', '-' ))) |
|
2474 | - $week = substr( $week, 1 ); |
|
2774 | + if( in_array( substr( $week, 0, 1 ), array( '+', '-' ))) { |
|
2775 | + $week = substr( $week, 1 ); |
|
2776 | + } |
|
2475 | 2777 | $this->duration = array( 'value' => $this->_duration_string( $week ), 'params' => $this->_setParams( $day )); |
2778 | + } elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec )) { |
|
2779 | + return FALSE; |
|
2780 | + } else { |
|
2781 | + $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params )); |
|
2476 | 2782 | } |
2477 | - elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec )) |
|
2478 | - return FALSE; |
|
2479 | - else |
|
2480 | - $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params )); |
|
2481 | 2783 | return TRUE; |
2482 | 2784 | } |
2483 | 2785 | /*********************************************************************************/ |
@@ -2492,31 +2794,37 @@ discard block |
||
2492 | 2794 | * @return string |
2493 | 2795 | */ |
2494 | 2796 | function createExdate() { |
2495 | - if( empty( $this->exdate )) return FALSE; |
|
2797 | + if( empty( $this->exdate )) { |
|
2798 | + return FALSE; |
|
2799 | + } |
|
2496 | 2800 | $output = null; |
2497 | 2801 | foreach( $this->exdate as $ex => $theExdate ) { |
2498 | 2802 | if( empty( $theExdate['value'] )) { |
2499 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'EXDATE' ); |
|
2803 | + if( $this->getConfig( 'allowEmpty' )) { |
|
2804 | + $output .= $this->_createElement( 'EXDATE' ); |
|
2805 | + } |
|
2500 | 2806 | continue; |
2501 | 2807 | } |
2502 | 2808 | $content = $attributes = null; |
2503 | 2809 | foreach( $theExdate['value'] as $eix => $exdatePart ) { |
2504 | 2810 | $parno = count( $exdatePart ); |
2505 | 2811 | $formatted = $this->_format_date_time( $exdatePart, $parno ); |
2506 | - if( isset( $theExdate['params']['TZID'] )) |
|
2507 | - $formatted = str_replace( 'Z', '', $formatted); |
|
2812 | + if( isset( $theExdate['params']['TZID'] )) { |
|
2813 | + $formatted = str_replace( 'Z', '', $formatted); |
|
2814 | + } |
|
2508 | 2815 | if( 0 < $eix ) { |
2509 | 2816 | if( isset( $theExdate['value'][0]['tz'] )) { |
2510 | 2817 | if( ctype_digit( substr( $theExdate['value'][0]['tz'], -4 )) || |
2511 | 2818 | ( 'Z' == $theExdate['value'][0]['tz'] )) { |
2512 | - if( 'Z' != substr( $formatted, -1 )) |
|
2513 | - $formatted .= 'Z'; |
|
2819 | + if( 'Z' != substr( $formatted, -1 )) { |
|
2820 | + $formatted .= 'Z'; |
|
2821 | + } |
|
2822 | + } else { |
|
2823 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
2514 | 2824 | } |
2515 | - else |
|
2516 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2825 | + } else { |
|
2826 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
2517 | 2827 | } |
2518 | - else |
|
2519 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2520 | 2828 | } |
2521 | 2829 | $content .= ( 0 < $eix ) ? ','.$formatted : $formatted; |
2522 | 2830 | } |
@@ -2540,34 +2848,39 @@ discard block |
||
2540 | 2848 | if( $this->getConfig( 'allowEmpty' )) { |
2541 | 2849 | $this->_setMval( $this->exdate, null, $params, FALSE, $index ); |
2542 | 2850 | return TRUE; |
2851 | + } else { |
|
2852 | + return FALSE; |
|
2543 | 2853 | } |
2544 | - else |
|
2545 | - return FALSE; |
|
2546 | 2854 | } |
2547 | 2855 | $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ))); |
2548 | 2856 | /* ev. check 1:st date and save ev. timezone **/ |
2549 | 2857 | $this->_chkdatecfg( reset( $exdates ), $parno, $input['params'] ); |
2550 | 2858 | $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default parameter |
2551 | 2859 | foreach( $exdates as $eix => $theExdate ) { |
2552 | - if( $this->_isArrayTimestampDate( $theExdate )) |
|
2553 | - $exdatea = $this->_timestamp2date( $theExdate, $parno ); |
|
2554 | - elseif( is_array( $theExdate )) |
|
2555 | - $exdatea = $this->_date_time_array( $theExdate, $parno ); |
|
2556 | - elseif( 8 <= strlen( trim( $theExdate ))) // ex. 2006-08-03 10:12:18 |
|
2860 | + if( $this->_isArrayTimestampDate( $theExdate )) { |
|
2861 | + $exdatea = $this->_timestamp2date( $theExdate, $parno ); |
|
2862 | + } elseif( is_array( $theExdate )) { |
|
2863 | + $exdatea = $this->_date_time_array( $theExdate, $parno ); |
|
2864 | + } elseif( 8 <= strlen( trim( $theExdate ))) { |
|
2865 | + // ex. 2006-08-03 10:12:18 |
|
2557 | 2866 | $exdatea = $this->_date_time_string( $theExdate, $parno ); |
2558 | - if( 3 == $parno ) |
|
2559 | - unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] ); |
|
2560 | - elseif( isset( $exdatea['tz'] )) |
|
2561 | - $exdatea['tz'] = (string) $exdatea['tz']; |
|
2867 | + } |
|
2868 | + if( 3 == $parno ) { |
|
2869 | + unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] ); |
|
2870 | + } elseif( isset( $exdatea['tz'] )) { |
|
2871 | + $exdatea['tz'] = (string) $exdatea['tz']; |
|
2872 | + } |
|
2562 | 2873 | if( isset( $input['params']['TZID'] ) || |
2563 | 2874 | ( isset( $exdatea['tz'] ) && !$this->_isOffset( $exdatea['tz'] )) || |
2564 | 2875 | ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) || |
2565 | - ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) |
|
2566 | - unset( $exdatea['tz'] ); |
|
2876 | + ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) { |
|
2877 | + unset( $exdatea['tz'] ); |
|
2878 | + } |
|
2567 | 2879 | $input['value'][] = $exdatea; |
2568 | 2880 | } |
2569 | - if( 0 >= count( $input['value'] )) |
|
2570 | - return FALSE; |
|
2881 | + if( 0 >= count( $input['value'] )) { |
|
2882 | + return FALSE; |
|
2883 | + } |
|
2571 | 2884 | if( 3 == $parno ) { |
2572 | 2885 | $input['params']['VALUE'] = 'DATE'; |
2573 | 2886 | unset( $input['params']['TZID'] ); |
@@ -2587,7 +2900,9 @@ discard block |
||
2587 | 2900 | * @return string |
2588 | 2901 | */ |
2589 | 2902 | function createExrule() { |
2590 | - if( empty( $this->exrule )) return FALSE; |
|
2903 | + if( empty( $this->exrule )) { |
|
2904 | + return FALSE; |
|
2905 | + } |
|
2591 | 2906 | return $this->_format_recur( 'EXRULE', $this->exrule ); |
2592 | 2907 | } |
2593 | 2908 | /** |
@@ -2601,7 +2916,11 @@ discard block |
||
2601 | 2916 | * @return bool |
2602 | 2917 | */ |
2603 | 2918 | function setExrule( $exruleset, $params=FALSE, $index=FALSE ) { |
2604 | - if( empty( $exruleset )) if( $this->getConfig( 'allowEmpty' )) $exruleset = null; else return FALSE; |
|
2919 | + if( empty( $exruleset )) { |
|
2920 | + if( $this->getConfig( 'allowEmpty' )) $exruleset = null; |
|
2921 | + } else { |
|
2922 | + return FALSE; |
|
2923 | + } |
|
2605 | 2924 | $this->_setMval( $this->exrule, $this->_setRexrule( $exruleset ), $params, FALSE, $index ); |
2606 | 2925 | return TRUE; |
2607 | 2926 | } |
@@ -2617,11 +2936,15 @@ discard block |
||
2617 | 2936 | * @return string |
2618 | 2937 | */ |
2619 | 2938 | function createFreebusy() { |
2620 | - if( empty( $this->freebusy )) return FALSE; |
|
2939 | + if( empty( $this->freebusy )) { |
|
2940 | + return FALSE; |
|
2941 | + } |
|
2621 | 2942 | $output = null; |
2622 | 2943 | foreach( $this->freebusy as $freebusyPart ) { |
2623 | 2944 | if( empty( $freebusyPart['value'] )) { |
2624 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'FREEBUSY' ); |
|
2945 | + if( $this->getConfig( 'allowEmpty' )) { |
|
2946 | + $output .= $this->_createElement( 'FREEBUSY' ); |
|
2947 | + } |
|
2625 | 2948 | continue; |
2626 | 2949 | } |
2627 | 2950 | $attributes = $content = null; |
@@ -2629,9 +2952,9 @@ discard block |
||
2629 | 2952 | $attributes .= $this->intAttrDelimiter.'FBTYPE='.$freebusyPart['value']['fbtype']; |
2630 | 2953 | unset( $freebusyPart['value']['fbtype'] ); |
2631 | 2954 | $freebusyPart['value'] = array_values( $freebusyPart['value'] ); |
2955 | + } else { |
|
2956 | + $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY'; |
|
2632 | 2957 | } |
2633 | - else |
|
2634 | - $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY'; |
|
2635 | 2958 | $attributes .= $this->_createParams( $freebusyPart['params'] ); |
2636 | 2959 | $fno = 1; |
2637 | 2960 | $cnt = count( $freebusyPart['value']); |
@@ -2640,21 +2963,24 @@ discard block |
||
2640 | 2963 | $content .= $formatted; |
2641 | 2964 | $content .= '/'; |
2642 | 2965 | $cnt2 = count( $freebusyPeriod[1]); |
2643 | - if( array_key_exists( 'year', $freebusyPeriod[1] )) // date-time |
|
2966 | + if( array_key_exists( 'year', $freebusyPeriod[1] )) { |
|
2967 | + // date-time |
|
2644 | 2968 | $cnt2 = 7; |
2645 | - elseif( array_key_exists( 'week', $freebusyPeriod[1] )) // duration |
|
2969 | + } elseif( array_key_exists( 'week', $freebusyPeriod[1] )) { |
|
2970 | + // duration |
|
2646 | 2971 | $cnt2 = 5; |
2972 | + } |
|
2647 | 2973 | if(( 7 == $cnt2 ) && // period= -> date-time |
2648 | 2974 | isset( $freebusyPeriod[1]['year'] ) && |
2649 | 2975 | isset( $freebusyPeriod[1]['month'] ) && |
2650 | 2976 | isset( $freebusyPeriod[1]['day'] )) { |
2651 | 2977 | $content .= $this->_format_date_time( $freebusyPeriod[1] ); |
2652 | - } |
|
2653 | - else { // period= -> dur-time |
|
2978 | + } else { // period= -> dur-time |
|
2654 | 2979 | $content .= $this->_format_duration( $freebusyPeriod[1] ); |
2655 | 2980 | } |
2656 | - if( $fno < $cnt ) |
|
2657 | - $content .= ','; |
|
2981 | + if( $fno < $cnt ) { |
|
2982 | + $content .= ','; |
|
2983 | + } |
|
2658 | 2984 | $fno++; |
2659 | 2985 | } |
2660 | 2986 | $output .= $this->_createElement( 'FREEBUSY', $attributes, $content ); |
@@ -2677,14 +3003,15 @@ discard block |
||
2677 | 3003 | if( $this->getConfig( 'allowEmpty' )) { |
2678 | 3004 | $this->_setMval( $this->freebusy, null, $params, FALSE, $index ); |
2679 | 3005 | return TRUE; |
3006 | + } else { |
|
3007 | + return FALSE; |
|
2680 | 3008 | } |
2681 | - else |
|
2682 | - return FALSE; |
|
2683 | 3009 | } |
2684 | 3010 | $fbType = strtoupper( $fbType ); |
2685 | 3011 | if(( !in_array( $fbType, array( 'FREE', 'BUSY', 'BUSY-UNAVAILABLE', 'BUSY-TENTATIVE' ))) && |
2686 | - ( 'X-' != substr( $fbType, 0, 2 ))) |
|
2687 | - $fbType = 'BUSY'; |
|
3012 | + ( 'X-' != substr( $fbType, 0, 2 ))) { |
|
3013 | + $fbType = 'BUSY'; |
|
3014 | + } |
|
2688 | 3015 | $input = array( 'fbtype' => $fbType ); |
2689 | 3016 | foreach( $fbValues as $fbPeriod ) { // periods => period |
2690 | 3017 | $freebusyPeriod = array(); |
@@ -2694,22 +3021,19 @@ discard block |
||
2694 | 3021 | if( $this->_isArrayDate( $fbMember )) { // date-time value |
2695 | 3022 | $freebusyPairMember = $this->_date_time_array( $fbMember, 7 ); |
2696 | 3023 | $freebusyPairMember['tz'] = 'Z'; |
2697 | - } |
|
2698 | - elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value |
|
3024 | + } elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value |
|
2699 | 3025 | $freebusyPairMember = $this->_timestamp2date( $fbMember['timestamp'], 7 ); |
2700 | 3026 | $freebusyPairMember['tz'] = 'Z'; |
2701 | - } |
|
2702 | - else { // array format duration |
|
3027 | + } else { // array format duration |
|
2703 | 3028 | $freebusyPairMember = $this->_duration_array( $fbMember ); |
2704 | 3029 | } |
2705 | - } |
|
2706 | - elseif(( 3 <= strlen( trim( $fbMember ))) && // string format duration |
|
3030 | + } elseif(( 3 <= strlen( trim( $fbMember ))) && // string format duration |
|
2707 | 3031 | ( in_array( $fbMember{0}, array( 'P', '+', '-' )))) { |
2708 | - if( 'P' != $fbMember{0} ) |
|
2709 | - $fbmember = substr( $fbMember, 1 ); |
|
3032 | + if( 'P' != $fbMember{0} ) { |
|
3033 | + $fbmember = substr( $fbMember, 1 ); |
|
3034 | + } |
|
2710 | 3035 | $freebusyPairMember = $this->_duration_string( $fbMember ); |
2711 | - } |
|
2712 | - elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18 |
|
3036 | + } elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18 |
|
2713 | 3037 | $freebusyPairMember = $this->_date_time_string( $fbMember, 7 ); |
2714 | 3038 | $freebusyPairMember['tz'] = 'Z'; |
2715 | 3039 | } |
@@ -2732,9 +3056,12 @@ discard block |
||
2732 | 3056 | * @return string |
2733 | 3057 | */ |
2734 | 3058 | function createGeo() { |
2735 | - if( empty( $this->geo )) return FALSE; |
|
2736 | - if( empty( $this->geo['value'] )) |
|
2737 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE; |
|
3059 | + if( empty( $this->geo )) { |
|
3060 | + return FALSE; |
|
3061 | + } |
|
3062 | + if( empty( $this->geo['value'] )) { |
|
3063 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE; |
|
3064 | + } |
|
2738 | 3065 | $attributes = $this->_createParams( $this->geo['params'] ); |
2739 | 3066 | $content = null; |
2740 | 3067 | $content .= number_format( (float) $this->geo['value']['latitude'], 6, '.', ''); |
@@ -2754,15 +3081,17 @@ discard block |
||
2754 | 3081 | */ |
2755 | 3082 | function setGeo( $latitude, $longitude, $params=FALSE ) { |
2756 | 3083 | if( !empty( $latitude ) && !empty( $longitude )) { |
2757 | - if( !is_array( $this->geo )) $this->geo = array(); |
|
3084 | + if( !is_array( $this->geo )) { |
|
3085 | + $this->geo = array(); |
|
3086 | + } |
|
2758 | 3087 | $this->geo['value']['latitude'] = $latitude; |
2759 | 3088 | $this->geo['value']['longitude'] = $longitude; |
2760 | 3089 | $this->geo['params'] = $this->_setParams( $params ); |
3090 | + } elseif( $this->getConfig( 'allowEmpty' )) { |
|
3091 | + $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) ); |
|
3092 | + } else { |
|
3093 | + return FALSE; |
|
2761 | 3094 | } |
2762 | - elseif( $this->getConfig( 'allowEmpty' )) |
|
2763 | - $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) ); |
|
2764 | - else |
|
2765 | - return FALSE; |
|
2766 | 3095 | return TRUE; |
2767 | 3096 | } |
2768 | 3097 | /*********************************************************************************/ |
@@ -2777,7 +3106,9 @@ discard block |
||
2777 | 3106 | * @return string |
2778 | 3107 | */ |
2779 | 3108 | function createLastModified() { |
2780 | - if( empty( $this->lastmodified )) return FALSE; |
|
3109 | + if( empty( $this->lastmodified )) { |
|
3110 | + return FALSE; |
|
3111 | + } |
|
2781 | 3112 | $attributes = $this->_createParams( $this->lastmodified['params'] ); |
2782 | 3113 | $formatted = $this->_format_date_time( $this->lastmodified['value'], 7 ); |
2783 | 3114 | return $this->_createElement( 'LAST-MODIFIED', $attributes, $formatted ); |
@@ -2797,8 +3128,9 @@ discard block |
||
2797 | 3128 | * @return boll |
2798 | 3129 | */ |
2799 | 3130 | function setLastModified( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
2800 | - if( empty( $year )) |
|
2801 | - $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' ))); |
|
3131 | + if( empty( $year )) { |
|
3132 | + $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' ))); |
|
3133 | + } |
|
2802 | 3134 | $this->lastmodified = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
2803 | 3135 | return TRUE; |
2804 | 3136 | } |
@@ -2814,9 +3146,12 @@ discard block |
||
2814 | 3146 | * @return string |
2815 | 3147 | */ |
2816 | 3148 | function createLocation() { |
2817 | - if( empty( $this->location )) return FALSE; |
|
2818 | - if( empty( $this->location['value'] )) |
|
2819 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE; |
|
3149 | + if( empty( $this->location )) { |
|
3150 | + return FALSE; |
|
3151 | + } |
|
3152 | + if( empty( $this->location['value'] )) { |
|
3153 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE; |
|
3154 | + } |
|
2820 | 3155 | $attributes = $this->_createParams( $this->location['params'], array( 'ALTREP', 'LANGUAGE' )); |
2821 | 3156 | $content = $this->_strrep( $this->location['value'] ); |
2822 | 3157 | return $this->_createElement( 'LOCATION', $attributes, $content ); |
@@ -2831,7 +3166,11 @@ discard block |
||
2831 | 3166 | * @return bool |
2832 | 3167 | */ |
2833 | 3168 | function setLocation( $value, $params=FALSE ) { |
2834 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3169 | + if( empty( $value )) { |
|
3170 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3171 | + } else { |
|
3172 | + return FALSE; |
|
3173 | + } |
|
2835 | 3174 | $this->location = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
2836 | 3175 | return TRUE; |
2837 | 3176 | } |
@@ -2847,9 +3186,12 @@ discard block |
||
2847 | 3186 | * @return string |
2848 | 3187 | */ |
2849 | 3188 | function createOrganizer() { |
2850 | - if( empty( $this->organizer )) return FALSE; |
|
2851 | - if( empty( $this->organizer['value'] )) |
|
2852 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE; |
|
3189 | + if( empty( $this->organizer )) { |
|
3190 | + return FALSE; |
|
3191 | + } |
|
3192 | + if( empty( $this->organizer['value'] )) { |
|
3193 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE; |
|
3194 | + } |
|
2853 | 3195 | $attributes = $this->_createParams( $this->organizer['params'] |
2854 | 3196 | , array( 'CN', 'DIR', 'LANGUAGE', 'SENT-BY' )); |
2855 | 3197 | $content = 'MAILTO:'.$this->organizer['value']; |
@@ -2865,13 +3207,18 @@ discard block |
||
2865 | 3207 | * @return bool |
2866 | 3208 | */ |
2867 | 3209 | function setOrganizer( $value, $params=FALSE ) { |
2868 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3210 | + if( empty( $value )) { |
|
3211 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3212 | + } else { |
|
3213 | + return FALSE; |
|
3214 | + } |
|
2869 | 3215 | $value = str_replace ( 'MAILTO:', '', $value ); |
2870 | 3216 | $value = str_replace ( 'mailto:', '', $value ); |
2871 | 3217 | $this->organizer = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
2872 | 3218 | if( isset( $this->organizer['params']['SENT-BY'] )) { |
2873 | - if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 ))) |
|
2874 | - $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 ); |
|
3219 | + if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 ))) { |
|
3220 | + $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 ); |
|
3221 | + } |
|
2875 | 3222 | } |
2876 | 3223 | return TRUE; |
2877 | 3224 | } |
@@ -2887,9 +3234,12 @@ discard block |
||
2887 | 3234 | * @return string |
2888 | 3235 | */ |
2889 | 3236 | function createPercentComplete() { |
2890 | - if( empty( $this->percentcomplete )) return FALSE; |
|
2891 | - if( empty( $this->percentcomplete['value'] )) |
|
2892 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE; |
|
3237 | + if( empty( $this->percentcomplete )) { |
|
3238 | + return FALSE; |
|
3239 | + } |
|
3240 | + if( empty( $this->percentcomplete['value'] )) { |
|
3241 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE; |
|
3242 | + } |
|
2893 | 3243 | $attributes = $this->_createParams( $this->percentcomplete['params'] ); |
2894 | 3244 | return $this->_createElement( 'PERCENT-COMPLETE', $attributes, $this->percentcomplete['value'] ); |
2895 | 3245 | } |
@@ -2903,7 +3253,11 @@ discard block |
||
2903 | 3253 | * @return bool |
2904 | 3254 | */ |
2905 | 3255 | function setPercentComplete( $value, $params=FALSE ) { |
2906 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3256 | + if( empty( $value )) { |
|
3257 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3258 | + } else { |
|
3259 | + return FALSE; |
|
3260 | + } |
|
2907 | 3261 | $this->percentcomplete = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
2908 | 3262 | return TRUE; |
2909 | 3263 | } |
@@ -2919,9 +3273,12 @@ discard block |
||
2919 | 3273 | * @return string |
2920 | 3274 | */ |
2921 | 3275 | function createPriority() { |
2922 | - if( empty( $this->priority )) return FALSE; |
|
2923 | - if( empty( $this->priority['value'] )) |
|
2924 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE; |
|
3276 | + if( empty( $this->priority )) { |
|
3277 | + return FALSE; |
|
3278 | + } |
|
3279 | + if( empty( $this->priority['value'] )) { |
|
3280 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE; |
|
3281 | + } |
|
2925 | 3282 | $attributes = $this->_createParams( $this->priority['params'] ); |
2926 | 3283 | return $this->_createElement( 'PRIORITY', $attributes, $this->priority['value'] ); |
2927 | 3284 | } |
@@ -2935,7 +3292,11 @@ discard block |
||
2935 | 3292 | * @return bool |
2936 | 3293 | */ |
2937 | 3294 | function setPriority( $value, $params=FALSE ) { |
2938 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3295 | + if( empty( $value )) { |
|
3296 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3297 | + } else { |
|
3298 | + return FALSE; |
|
3299 | + } |
|
2939 | 3300 | $this->priority = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
2940 | 3301 | return TRUE; |
2941 | 3302 | } |
@@ -2951,18 +3312,24 @@ discard block |
||
2951 | 3312 | * @return string |
2952 | 3313 | */ |
2953 | 3314 | function createRdate() { |
2954 | - if( empty( $this->rdate )) return FALSE; |
|
3315 | + if( empty( $this->rdate )) { |
|
3316 | + return FALSE; |
|
3317 | + } |
|
2955 | 3318 | $utctime = ( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE; |
2956 | 3319 | $output = null; |
2957 | - if( $utctime ) |
|
2958 | - unset( $this->rdate['params']['TZID'] ); |
|
3320 | + if( $utctime ) { |
|
3321 | + unset( $this->rdate['params']['TZID'] ); |
|
3322 | + } |
|
2959 | 3323 | foreach( $this->rdate as $theRdate ) { |
2960 | 3324 | if( empty( $theRdate['value'] )) { |
2961 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RDATE' ); |
|
3325 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3326 | + $output .= $this->_createElement( 'RDATE' ); |
|
3327 | + } |
|
2962 | 3328 | continue; |
2963 | 3329 | } |
2964 | - if( $utctime ) |
|
2965 | - unset( $theRdate['params']['TZID'] ); |
|
3330 | + if( $utctime ) { |
|
3331 | + unset( $theRdate['params']['TZID'] ); |
|
3332 | + } |
|
2966 | 3333 | $attributes = $this->_createParams( $theRdate['params'] ); |
2967 | 3334 | $cnt = count( $theRdate['value'] ); |
2968 | 3335 | $content = null; |
@@ -2971,68 +3338,84 @@ discard block |
||
2971 | 3338 | $contentPart = null; |
2972 | 3339 | if( is_array( $rdatePart ) && |
2973 | 3340 | isset( $theRdate['params']['VALUE'] ) && ( 'PERIOD' == $theRdate['params']['VALUE'] )) { // PERIOD |
2974 | - if( $utctime ) |
|
2975 | - unset( $rdatePart[0]['tz'] ); |
|
3341 | + if( $utctime ) { |
|
3342 | + unset( $rdatePart[0]['tz'] ); |
|
3343 | + } |
|
2976 | 3344 | $formatted = $this->_format_date_time( $rdatePart[0]); // PERIOD part 1 |
2977 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
2978 | - $formatted = str_replace( 'Z', '', $formatted); |
|
3345 | + if( $utctime || !empty( $theRdate['params']['TZID'] )) { |
|
3346 | + $formatted = str_replace( 'Z', '', $formatted); |
|
3347 | + } |
|
2979 | 3348 | if( 0 < $rpix ) { |
2980 | 3349 | if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) { |
2981 | - if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z'; |
|
3350 | + if( 'Z' != substr( $formatted, -1 )) { |
|
3351 | + $formatted .= 'Z'; |
|
3352 | + } |
|
3353 | + } else { |
|
3354 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
2982 | 3355 | } |
2983 | - else |
|
2984 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2985 | 3356 | } |
2986 | 3357 | $contentPart .= $formatted; |
2987 | 3358 | $contentPart .= '/'; |
2988 | 3359 | $cnt2 = count( $rdatePart[1]); |
2989 | 3360 | if( array_key_exists( 'year', $rdatePart[1] )) { |
2990 | - if( array_key_exists( 'hour', $rdatePart[1] )) |
|
2991 | - $cnt2 = 7; // date-time |
|
2992 | - else |
|
2993 | - $cnt2 = 3; // date |
|
2994 | - } |
|
2995 | - elseif( array_key_exists( 'week', $rdatePart[1] )) // duration |
|
3361 | + if( array_key_exists( 'hour', $rdatePart[1] )) { |
|
3362 | + $cnt2 = 7; |
|
3363 | + } |
|
3364 | + // date-time |
|
3365 | + else { |
|
3366 | + $cnt2 = 3; |
|
3367 | + } |
|
3368 | + // date |
|
3369 | + } elseif( array_key_exists( 'week', $rdatePart[1] )) { |
|
3370 | + // duration |
|
2996 | 3371 | $cnt2 = 5; |
3372 | + } |
|
2997 | 3373 | if(( 7 == $cnt2 ) && // period= -> date-time |
2998 | 3374 | isset( $rdatePart[1]['year'] ) && |
2999 | 3375 | isset( $rdatePart[1]['month'] ) && |
3000 | 3376 | isset( $rdatePart[1]['day'] )) { |
3001 | - if( $utctime ) |
|
3002 | - unset( $rdatePart[1]['tz'] ); |
|
3377 | + if( $utctime ) { |
|
3378 | + unset( $rdatePart[1]['tz'] ); |
|
3379 | + } |
|
3003 | 3380 | $formatted = $this->_format_date_time( $rdatePart[1] ); // PERIOD part 2 |
3004 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
3005 | - $formatted = str_replace( 'Z', '', $formatted); |
|
3381 | + if( $utctime || !empty( $theRdate['params']['TZID'] )) { |
|
3382 | + $formatted = str_replace( 'Z', '', $formatted); |
|
3383 | + } |
|
3006 | 3384 | if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) { |
3007 | - if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z'; |
|
3385 | + if( 'Z' != substr( $formatted, -1 )) { |
|
3386 | + $formatted .= 'Z'; |
|
3387 | + } |
|
3388 | + } else { |
|
3389 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
3008 | 3390 | } |
3009 | - else |
|
3010 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
3011 | 3391 | $contentPart .= $formatted; |
3012 | - } |
|
3013 | - else { // period= -> dur-time |
|
3392 | + } else { // period= -> dur-time |
|
3014 | 3393 | $contentPart .= $this->_format_duration( $rdatePart[1] ); |
3015 | 3394 | } |
3016 | 3395 | } // PERIOD end |
3017 | 3396 | else { // SINGLE date start |
3018 | - if( $utctime ) |
|
3019 | - unset( $rdatePart['tz'] ); |
|
3397 | + if( $utctime ) { |
|
3398 | + unset( $rdatePart['tz'] ); |
|
3399 | + } |
|
3020 | 3400 | $formatted = $this->_format_date_time( $rdatePart); |
3021 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
3022 | - $formatted = str_replace( 'Z', '', $formatted); |
|
3401 | + if( $utctime || !empty( $theRdate['params']['TZID'] )) { |
|
3402 | + $formatted = str_replace( 'Z', '', $formatted); |
|
3403 | + } |
|
3023 | 3404 | if( !$utctime && ( 0 < $rpix )) { |
3024 | 3405 | if( !empty( $theRdate['value'][0]['tz'] ) && $this->_isOffset( $theRdate['value'][0]['tz'] )) { |
3025 | - if( 'Z' != substr( $formatted, -1 )) |
|
3026 | - $formatted .= 'Z'; |
|
3406 | + if( 'Z' != substr( $formatted, -1 )) { |
|
3407 | + $formatted .= 'Z'; |
|
3408 | + } |
|
3409 | + } else { |
|
3410 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
3027 | 3411 | } |
3028 | - else |
|
3029 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
3030 | 3412 | } |
3031 | 3413 | $contentPart .= $formatted; |
3032 | 3414 | } |
3033 | 3415 | $content .= $contentPart; |
3034 | - if( $rno < $cnt ) |
|
3035 | - $content .= ','; |
|
3416 | + if( $rno < $cnt ) { |
|
3417 | + $content .= ','; |
|
3418 | + } |
|
3036 | 3419 | $rno++; |
3037 | 3420 | } |
3038 | 3421 | $output .= $this->_createElement( 'RDATE', $attributes, $content ); |
@@ -3054,9 +3437,9 @@ discard block |
||
3054 | 3437 | if( $this->getConfig( 'allowEmpty' )) { |
3055 | 3438 | $this->_setMval( $this->rdate, null, $params, FALSE, $index ); |
3056 | 3439 | return TRUE; |
3440 | + } else { |
|
3441 | + return FALSE; |
|
3057 | 3442 | } |
3058 | - else |
|
3059 | - return FALSE; |
|
3060 | 3443 | } |
3061 | 3444 | $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ))); |
3062 | 3445 | if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) { |
@@ -3070,15 +3453,19 @@ discard block |
||
3070 | 3453 | (( is_array( $rdates[0][0] ) && ( isset( $rdates[0][0]['timestamp'] ) || |
3071 | 3454 | $this->_isArrayDate( $rdates[0][0] ))) || |
3072 | 3455 | ( is_string( $rdates[0][0] ) && ( 8 <= strlen( trim( $rdates[0][0] ))))) && |
3073 | - ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] )))))) |
|
3074 | - $input['params']['VALUE'] = 'PERIOD'; |
|
3456 | + ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] )))))) { |
|
3457 | + $input['params']['VALUE'] = 'PERIOD'; |
|
3458 | + } |
|
3075 | 3459 | /* check 1:st date, upd. $parno (opt) and save ev. timezone **/ |
3076 | 3460 | $date = reset( $rdates ); |
3077 | - if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) // PERIOD |
|
3461 | + if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) { |
|
3462 | + // PERIOD |
|
3078 | 3463 | $date = reset( $date ); |
3464 | + } |
|
3079 | 3465 | $this->_chkdatecfg( $date, $parno, $input['params'] ); |
3080 | - if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) |
|
3081 | - unset( $input['params']['TZID'] ); |
|
3466 | + if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) { |
|
3467 | + unset( $input['params']['TZID'] ); |
|
3468 | + } |
|
3082 | 3469 | $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default |
3083 | 3470 | foreach( $rdates as $rpix => $theRdate ) { |
3084 | 3471 | $inputa = null; |
@@ -3086,48 +3473,60 @@ discard block |
||
3086 | 3473 | if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) { // PERIOD |
3087 | 3474 | foreach( $theRdate as $rix => $rPeriod ) { |
3088 | 3475 | if( is_array( $rPeriod )) { |
3089 | - if( $this->_isArrayTimestampDate( $rPeriod )) // timestamp |
|
3476 | + if( $this->_isArrayTimestampDate( $rPeriod )) { |
|
3477 | + // timestamp |
|
3090 | 3478 | $inputab = ( isset( $rPeriod['tz'] )) ? $this->_timestamp2date( $rPeriod, $parno ) : $this->_timestamp2date( $rPeriod, 6 ); |
3091 | - elseif( $this->_isArrayDate( $rPeriod )) |
|
3092 | - $inputab = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 ); |
|
3093 | - elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod )))) // text-date |
|
3479 | + } elseif( $this->_isArrayDate( $rPeriod )) { |
|
3480 | + $inputab = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 ); |
|
3481 | + } elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod )))) { |
|
3482 | + // text-date |
|
3094 | 3483 | $inputab = $this->_date_time_string( reset( $rPeriod ), $parno ); |
3095 | - else // array format duration |
|
3484 | + } else { |
|
3485 | + // array format duration |
|
3096 | 3486 | $inputab = $this->_duration_array( $rPeriod ); |
3097 | - } |
|
3098 | - elseif(( 3 <= strlen( trim( $rPeriod ))) && // string format duration |
|
3487 | + } |
|
3488 | + } elseif(( 3 <= strlen( trim( $rPeriod ))) && // string format duration |
|
3099 | 3489 | ( in_array( $rPeriod{0}, array( 'P', '+', '-' )))) { |
3100 | - if( 'P' != $rPeriod{0} ) |
|
3101 | - $rPeriod = substr( $rPeriod, 1 ); |
|
3490 | + if( 'P' != $rPeriod{0} ) { |
|
3491 | + $rPeriod = substr( $rPeriod, 1 ); |
|
3492 | + } |
|
3102 | 3493 | $inputab = $this->_duration_string( $rPeriod ); |
3103 | - } |
|
3104 | - elseif( 8 <= strlen( trim( $rPeriod ))) // text date ex. 2006-08-03 10:12:18 |
|
3494 | + } elseif( 8 <= strlen( trim( $rPeriod ))) { |
|
3495 | + // text date ex. 2006-08-03 10:12:18 |
|
3105 | 3496 | $inputab = $this->_date_time_string( $rPeriod, $parno ); |
3497 | + } |
|
3106 | 3498 | if( isset( $input['params']['TZID'] ) || |
3107 | 3499 | ( isset( $inputab['tz'] ) && !$this->_isOffset( $inputab['tz'] )) || |
3108 | 3500 | ( isset( $inputa[0] ) && ( !isset( $inputa[0]['tz'] ))) || |
3109 | - ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] ))) |
|
3110 | - unset( $inputab['tz'] ); |
|
3501 | + ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] ))) { |
|
3502 | + unset( $inputab['tz'] ); |
|
3503 | + } |
|
3111 | 3504 | $inputa[] = $inputab; |
3112 | 3505 | } |
3113 | 3506 | } // PERIOD end |
3114 | - elseif ( $this->_isArrayTimestampDate( $theRdate )) // timestamp |
|
3507 | + elseif ( $this->_isArrayTimestampDate( $theRdate )) { |
|
3508 | + // timestamp |
|
3115 | 3509 | $inputa = $this->_timestamp2date( $theRdate, $parno ); |
3116 | - else // date[-time] |
|
3510 | + } else { |
|
3511 | + // date[-time] |
|
3117 | 3512 | $inputa = $this->_date_time_array( $theRdate, $parno ); |
3118 | - } |
|
3119 | - elseif( 8 <= strlen( trim( $theRdate ))) // text date ex. 2006-08-03 10:12:18 |
|
3513 | + } |
|
3514 | + } elseif( 8 <= strlen( trim( $theRdate ))) { |
|
3515 | + // text date ex. 2006-08-03 10:12:18 |
|
3120 | 3516 | $inputa = $this->_date_time_string( $theRdate, $parno ); |
3517 | + } |
|
3121 | 3518 | if( !isset( $input['params']['VALUE'] ) || ( 'PERIOD' != $input['params']['VALUE'] )) { // no PERIOD |
3122 | - if( 3 == $parno ) |
|
3123 | - unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] ); |
|
3124 | - elseif( isset( $inputa['tz'] )) |
|
3125 | - $inputa['tz'] = (string) $inputa['tz']; |
|
3519 | + if( 3 == $parno ) { |
|
3520 | + unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] ); |
|
3521 | + } elseif( isset( $inputa['tz'] )) { |
|
3522 | + $inputa['tz'] = (string) $inputa['tz']; |
|
3523 | + } |
|
3126 | 3524 | if( isset( $input['params']['TZID'] ) || |
3127 | 3525 | ( isset( $inputa['tz'] ) && !$this->_isOffset( $inputa['tz'] )) || |
3128 | 3526 | ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) || |
3129 | - ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) |
|
3130 | - unset( $inputa['tz'] ); |
|
3527 | + ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) { |
|
3528 | + unset( $inputa['tz'] ); |
|
3529 | + } |
|
3131 | 3530 | } |
3132 | 3531 | $input['value'][] = $inputa; |
3133 | 3532 | } |
@@ -3150,9 +3549,12 @@ discard block |
||
3150 | 3549 | * @return string |
3151 | 3550 | */ |
3152 | 3551 | function createRecurrenceid() { |
3153 | - if( empty( $this->recurrenceid )) return FALSE; |
|
3154 | - if( empty( $this->recurrenceid['value'] )) |
|
3155 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE; |
|
3552 | + if( empty( $this->recurrenceid )) { |
|
3553 | + return FALSE; |
|
3554 | + } |
|
3555 | + if( empty( $this->recurrenceid['value'] )) { |
|
3556 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE; |
|
3557 | + } |
|
3156 | 3558 | $formatted = $this->_format_date_time( $this->recurrenceid['value'] ); |
3157 | 3559 | $attributes = $this->_createParams( $this->recurrenceid['params'] ); |
3158 | 3560 | return $this->_createElement( 'RECURRENCE-ID', $attributes, $formatted ); |
@@ -3176,9 +3578,9 @@ discard block |
||
3176 | 3578 | if( $this->getConfig( 'allowEmpty' )) { |
3177 | 3579 | $this->recurrenceid = array( 'value' => null, 'params' => null ); |
3178 | 3580 | return TRUE; |
3581 | + } else { |
|
3582 | + return FALSE; |
|
3179 | 3583 | } |
3180 | - else |
|
3181 | - return FALSE; |
|
3182 | 3584 | } |
3183 | 3585 | $this->recurrenceid = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
3184 | 3586 | return TRUE; |
@@ -3195,11 +3597,15 @@ discard block |
||
3195 | 3597 | * @return string |
3196 | 3598 | */ |
3197 | 3599 | function createRelatedTo() { |
3198 | - if( empty( $this->relatedto )) return FALSE; |
|
3600 | + if( empty( $this->relatedto )) { |
|
3601 | + return FALSE; |
|
3602 | + } |
|
3199 | 3603 | $output = null; |
3200 | 3604 | foreach( $this->relatedto as $relation ) { |
3201 | 3605 | if( empty( $relation['value'] )) { |
3202 | - if( $this->getConfig( 'allowEmpty' )) $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] )); |
|
3606 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3607 | + $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] )); |
|
3608 | + } |
|
3203 | 3609 | continue; |
3204 | 3610 | } |
3205 | 3611 | $attributes = $this->_createParams( $relation['params'] ); |
@@ -3221,9 +3627,14 @@ discard block |
||
3221 | 3627 | * @return bool |
3222 | 3628 | */ |
3223 | 3629 | function setRelatedTo( $value, $params=FALSE, $index=FALSE ) { |
3224 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3225 | - if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 ))) |
|
3226 | - $value = substr( $value, 1, ( strlen( $value ) - 2 )); |
|
3630 | + if( empty( $value )) { |
|
3631 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3632 | + } else { |
|
3633 | + return FALSE; |
|
3634 | + } |
|
3635 | + if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 ))) { |
|
3636 | + $value = substr( $value, 1, ( strlen( $value ) - 2 )); |
|
3637 | + } |
|
3227 | 3638 | $this->_existRem( $params, 'RELTYPE', 'PARENT', TRUE ); // remove default |
3228 | 3639 | $this->_setMval( $this->relatedto, $value, $params, FALSE, $index ); |
3229 | 3640 | return TRUE; |
@@ -3240,9 +3651,12 @@ discard block |
||
3240 | 3651 | * @return string |
3241 | 3652 | */ |
3242 | 3653 | function createRepeat() { |
3243 | - if( empty( $this->repeat )) return FALSE; |
|
3244 | - if( empty( $this->repeat['value'] )) |
|
3245 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE; |
|
3654 | + if( empty( $this->repeat )) { |
|
3655 | + return FALSE; |
|
3656 | + } |
|
3657 | + if( empty( $this->repeat['value'] )) { |
|
3658 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE; |
|
3659 | + } |
|
3246 | 3660 | $attributes = $this->_createParams( $this->repeat['params'] ); |
3247 | 3661 | return $this->_createElement( 'REPEAT', $attributes, $this->repeat['value'] ); |
3248 | 3662 | } |
@@ -3256,7 +3670,11 @@ discard block |
||
3256 | 3670 | * @return void |
3257 | 3671 | */ |
3258 | 3672 | function setRepeat( $value, $params=FALSE ) { |
3259 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3673 | + if( empty( $value )) { |
|
3674 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3675 | + } else { |
|
3676 | + return FALSE; |
|
3677 | + } |
|
3260 | 3678 | $this->repeat = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3261 | 3679 | return TRUE; |
3262 | 3680 | } |
@@ -3271,18 +3689,23 @@ discard block |
||
3271 | 3689 | * @return string |
3272 | 3690 | */ |
3273 | 3691 | function createRequestStatus() { |
3274 | - if( empty( $this->requeststatus )) return FALSE; |
|
3692 | + if( empty( $this->requeststatus )) { |
|
3693 | + return FALSE; |
|
3694 | + } |
|
3275 | 3695 | $output = null; |
3276 | 3696 | foreach( $this->requeststatus as $rstat ) { |
3277 | 3697 | if( empty( $rstat['value']['statcode'] )) { |
3278 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'REQUEST-STATUS' ); |
|
3698 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3699 | + $output .= $this->_createElement( 'REQUEST-STATUS' ); |
|
3700 | + } |
|
3279 | 3701 | continue; |
3280 | 3702 | } |
3281 | 3703 | $attributes = $this->_createParams( $rstat['params'], array( 'LANGUAGE' )); |
3282 | 3704 | $content = number_format( (float) $rstat['value']['statcode'], 2, '.', ''); |
3283 | 3705 | $content .= ';'.$this->_strrep( $rstat['value']['text'] ); |
3284 | - if( isset( $rstat['value']['extdata'] )) |
|
3285 | - $content .= ';'.$this->_strrep( $rstat['value']['extdata'] ); |
|
3706 | + if( isset( $rstat['value']['extdata'] )) { |
|
3707 | + $content .= ';'.$this->_strrep( $rstat['value']['extdata'] ); |
|
3708 | + } |
|
3286 | 3709 | $output .= $this->_createElement( 'REQUEST-STATUS', $attributes, $content ); |
3287 | 3710 | } |
3288 | 3711 | return $output; |
@@ -3300,10 +3723,15 @@ discard block |
||
3300 | 3723 | * @return bool |
3301 | 3724 | */ |
3302 | 3725 | function setRequestStatus( $statcode, $text, $extdata=FALSE, $params=FALSE, $index=FALSE ) { |
3303 | - if( empty( $statcode ) || empty( $text )) if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null; else return FALSE; |
|
3726 | + if( empty( $statcode ) || empty( $text )) { |
|
3727 | + if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null; |
|
3728 | + } else { |
|
3729 | + return FALSE; |
|
3730 | + } |
|
3304 | 3731 | $input = array( 'statcode' => $statcode, 'text' => $text ); |
3305 | - if( $extdata ) |
|
3306 | - $input['extdata'] = $extdata; |
|
3732 | + if( $extdata ) { |
|
3733 | + $input['extdata'] = $extdata; |
|
3734 | + } |
|
3307 | 3735 | $this->_setMval( $this->requeststatus, $input, $params, FALSE, $index ); |
3308 | 3736 | return TRUE; |
3309 | 3737 | } |
@@ -3319,21 +3747,26 @@ discard block |
||
3319 | 3747 | * @return string |
3320 | 3748 | */ |
3321 | 3749 | function createResources() { |
3322 | - if( empty( $this->resources )) return FALSE; |
|
3750 | + if( empty( $this->resources )) { |
|
3751 | + return FALSE; |
|
3752 | + } |
|
3323 | 3753 | $output = null; |
3324 | 3754 | foreach( $this->resources as $resource ) { |
3325 | 3755 | if( empty( $resource['value'] )) { |
3326 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RESOURCES' ); |
|
3756 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3757 | + $output .= $this->_createElement( 'RESOURCES' ); |
|
3758 | + } |
|
3327 | 3759 | continue; |
3328 | 3760 | } |
3329 | 3761 | $attributes = $this->_createParams( $resource['params'], array( 'ALTREP', 'LANGUAGE' )); |
3330 | 3762 | if( is_array( $resource['value'] )) { |
3331 | - foreach( $resource['value'] as $rix => $resourcePart ) |
|
3332 | - $resource['value'][$rix] = $this->_strrep( $resourcePart ); |
|
3763 | + foreach( $resource['value'] as $rix => $resourcePart ) { |
|
3764 | + $resource['value'][$rix] = $this->_strrep( $resourcePart ); |
|
3765 | + } |
|
3333 | 3766 | $content = implode( ',', $resource['value'] ); |
3767 | + } else { |
|
3768 | + $content = $this->_strrep( $resource['value'] ); |
|
3334 | 3769 | } |
3335 | - else |
|
3336 | - $content = $this->_strrep( $resource['value'] ); |
|
3337 | 3770 | $output .= $this->_createElement( 'RESOURCES', $attributes, $content ); |
3338 | 3771 | } |
3339 | 3772 | return $output; |
@@ -3349,7 +3782,11 @@ discard block |
||
3349 | 3782 | * @return bool |
3350 | 3783 | */ |
3351 | 3784 | function setResources( $value, $params=FALSE, $index=FALSE ) { |
3352 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3785 | + if( empty( $value )) { |
|
3786 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3787 | + } else { |
|
3788 | + return FALSE; |
|
3789 | + } |
|
3353 | 3790 | $this->_setMval( $this->resources, $value, $params, FALSE, $index ); |
3354 | 3791 | return TRUE; |
3355 | 3792 | } |
@@ -3365,7 +3802,9 @@ discard block |
||
3365 | 3802 | * @return string |
3366 | 3803 | */ |
3367 | 3804 | function createRrule() { |
3368 | - if( empty( $this->rrule )) return FALSE; |
|
3805 | + if( empty( $this->rrule )) { |
|
3806 | + return FALSE; |
|
3807 | + } |
|
3369 | 3808 | return $this->_format_recur( 'RRULE', $this->rrule ); |
3370 | 3809 | } |
3371 | 3810 | /** |
@@ -3379,7 +3818,11 @@ discard block |
||
3379 | 3818 | * @return void |
3380 | 3819 | */ |
3381 | 3820 | function setRrule( $rruleset, $params=FALSE, $index=FALSE ) { |
3382 | - if( empty( $rruleset )) if( $this->getConfig( 'allowEmpty' )) $rruleset = null; else return FALSE; |
|
3821 | + if( empty( $rruleset )) { |
|
3822 | + if( $this->getConfig( 'allowEmpty' )) $rruleset = null; |
|
3823 | + } else { |
|
3824 | + return FALSE; |
|
3825 | + } |
|
3383 | 3826 | $this->_setMval( $this->rrule, $this->_setRexrule( $rruleset ), $params, FALSE, $index ); |
3384 | 3827 | return TRUE; |
3385 | 3828 | } |
@@ -3394,9 +3837,12 @@ discard block |
||
3394 | 3837 | * @return string |
3395 | 3838 | */ |
3396 | 3839 | function createSequence() { |
3397 | - if( empty( $this->sequence )) return FALSE; |
|
3398 | - if( empty( $this->sequence['value'] )) |
|
3399 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE; |
|
3840 | + if( empty( $this->sequence )) { |
|
3841 | + return FALSE; |
|
3842 | + } |
|
3843 | + if( empty( $this->sequence['value'] )) { |
|
3844 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE; |
|
3845 | + } |
|
3400 | 3846 | $attributes = $this->_createParams( $this->sequence['params'] ); |
3401 | 3847 | return $this->_createElement( 'SEQUENCE', $attributes, $this->sequence['value'] ); |
3402 | 3848 | } |
@@ -3409,8 +3855,9 @@ discard block |
||
3409 | 3855 | * @return bool |
3410 | 3856 | */ |
3411 | 3857 | function setSequence( $value=FALSE, $params=FALSE ) { |
3412 | - if( empty( $value )) |
|
3413 | - $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1; |
|
3858 | + if( empty( $value )) { |
|
3859 | + $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1; |
|
3860 | + } |
|
3414 | 3861 | $this->sequence = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3415 | 3862 | return TRUE; |
3416 | 3863 | } |
@@ -3426,9 +3873,12 @@ discard block |
||
3426 | 3873 | * @return string |
3427 | 3874 | */ |
3428 | 3875 | function createStatus() { |
3429 | - if( empty( $this->status )) return FALSE; |
|
3430 | - if( empty( $this->status['value'] )) |
|
3431 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE; |
|
3876 | + if( empty( $this->status )) { |
|
3877 | + return FALSE; |
|
3878 | + } |
|
3879 | + if( empty( $this->status['value'] )) { |
|
3880 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE; |
|
3881 | + } |
|
3432 | 3882 | $attributes = $this->_createParams( $this->status['params'] ); |
3433 | 3883 | return $this->_createElement( 'STATUS', $attributes, $this->status['value'] ); |
3434 | 3884 | } |
@@ -3442,7 +3892,11 @@ discard block |
||
3442 | 3892 | * @return bool |
3443 | 3893 | */ |
3444 | 3894 | function setStatus( $value, $params=FALSE ) { |
3445 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3895 | + if( empty( $value )) { |
|
3896 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3897 | + } else { |
|
3898 | + return FALSE; |
|
3899 | + } |
|
3446 | 3900 | $this->status = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3447 | 3901 | return TRUE; |
3448 | 3902 | } |
@@ -3458,9 +3912,12 @@ discard block |
||
3458 | 3912 | * @return string |
3459 | 3913 | */ |
3460 | 3914 | function createSummary() { |
3461 | - if( empty( $this->summary )) return FALSE; |
|
3462 | - if( empty( $this->summary['value'] )) |
|
3463 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE; |
|
3915 | + if( empty( $this->summary )) { |
|
3916 | + return FALSE; |
|
3917 | + } |
|
3918 | + if( empty( $this->summary['value'] )) { |
|
3919 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE; |
|
3920 | + } |
|
3464 | 3921 | $attributes = $this->_createParams( $this->summary['params'], array( 'ALTREP', 'LANGUAGE' )); |
3465 | 3922 | $content = $this->_strrep( $this->summary['value'] ); |
3466 | 3923 | return $this->_createElement( 'SUMMARY', $attributes, $content ); |
@@ -3475,7 +3932,11 @@ discard block |
||
3475 | 3932 | * @return bool |
3476 | 3933 | */ |
3477 | 3934 | function setSummary( $value, $params=FALSE ) { |
3478 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3935 | + if( empty( $value )) { |
|
3936 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3937 | + } else { |
|
3938 | + return FALSE; |
|
3939 | + } |
|
3479 | 3940 | $this->summary = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3480 | 3941 | return TRUE; |
3481 | 3942 | } |
@@ -3491,9 +3952,12 @@ discard block |
||
3491 | 3952 | * @return string |
3492 | 3953 | */ |
3493 | 3954 | function createTransp() { |
3494 | - if( empty( $this->transp )) return FALSE; |
|
3495 | - if( empty( $this->transp['value'] )) |
|
3496 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE; |
|
3955 | + if( empty( $this->transp )) { |
|
3956 | + return FALSE; |
|
3957 | + } |
|
3958 | + if( empty( $this->transp['value'] )) { |
|
3959 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE; |
|
3960 | + } |
|
3497 | 3961 | $attributes = $this->_createParams( $this->transp['params'] ); |
3498 | 3962 | return $this->_createElement( 'TRANSP', $attributes, $this->transp['value'] ); |
3499 | 3963 | } |
@@ -3507,7 +3971,11 @@ discard block |
||
3507 | 3971 | * @return bool |
3508 | 3972 | */ |
3509 | 3973 | function setTransp( $value, $params=FALSE ) { |
3510 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3974 | + if( empty( $value )) { |
|
3975 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3976 | + } else { |
|
3977 | + return FALSE; |
|
3978 | + } |
|
3511 | 3979 | $this->transp = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3512 | 3980 | return TRUE; |
3513 | 3981 | } |
@@ -3523,19 +3991,24 @@ discard block |
||
3523 | 3991 | * @return string |
3524 | 3992 | */ |
3525 | 3993 | function createTrigger() { |
3526 | - if( empty( $this->trigger )) return FALSE; |
|
3527 | - if( empty( $this->trigger['value'] )) |
|
3528 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE; |
|
3994 | + if( empty( $this->trigger )) { |
|
3995 | + return FALSE; |
|
3996 | + } |
|
3997 | + if( empty( $this->trigger['value'] )) { |
|
3998 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE; |
|
3999 | + } |
|
3529 | 4000 | $content = $attributes = null; |
3530 | 4001 | if( isset( $this->trigger['value']['year'] ) && |
3531 | 4002 | isset( $this->trigger['value']['month'] ) && |
3532 | - isset( $this->trigger['value']['day'] )) |
|
3533 | - $content .= $this->_format_date_time( $this->trigger['value'] ); |
|
3534 | - else { |
|
3535 | - if( TRUE !== $this->trigger['value']['relatedStart'] ) |
|
3536 | - $attributes .= $this->intAttrDelimiter.'RELATED=END'; |
|
3537 | - if( $this->trigger['value']['before'] ) |
|
3538 | - $content .= '-'; |
|
4003 | + isset( $this->trigger['value']['day'] )) { |
|
4004 | + $content .= $this->_format_date_time( $this->trigger['value'] ); |
|
4005 | + } else { |
|
4006 | + if( TRUE !== $this->trigger['value']['relatedStart'] ) { |
|
4007 | + $attributes .= $this->intAttrDelimiter.'RELATED=END'; |
|
4008 | + } |
|
4009 | + if( $this->trigger['value']['before'] ) { |
|
4010 | + $content .= '-'; |
|
4011 | + } |
|
3539 | 4012 | $content .= $this->_format_duration( $this->trigger['value'] ); |
3540 | 4013 | } |
3541 | 4014 | $attributes .= $this->_createParams( $this->trigger['params'] ); |
@@ -3559,28 +4032,30 @@ discard block |
||
3559 | 4032 | * @return bool |
3560 | 4033 | */ |
3561 | 4034 | function setTrigger( $year, $month=null, $day=null, $week=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $relatedStart=TRUE, $before=TRUE, $params=FALSE ) { |
3562 | - if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec )) |
|
3563 | - if( $this->getConfig( 'allowEmpty' )) { |
|
4035 | + if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec )) { |
|
4036 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3564 | 4037 | $this->trigger = array( 'value' => null, 'params' => $this->_setParams( $params ) ); |
4038 | + } |
|
3565 | 4039 | return TRUE; |
4040 | + } else { |
|
4041 | + return FALSE; |
|
3566 | 4042 | } |
3567 | - else |
|
3568 | - return FALSE; |
|
3569 | 4043 | if( $this->_isArrayTimestampDate( $year )) { // timestamp |
3570 | 4044 | $params = $this->_setParams( $month ); |
3571 | 4045 | $date = $this->_timestamp2date( $year, 7 ); |
3572 | - foreach( $date as $k => $v ) |
|
3573 | - $$k = $v; |
|
3574 | - } |
|
3575 | - elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) { |
|
4046 | + foreach( $date as $k => $v ) { |
|
4047 | + $$k = $v; |
|
4048 | + } |
|
4049 | + } elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) { |
|
3576 | 4050 | $params = $this->_setParams( $month ); |
3577 | 4051 | if(!(array_key_exists( 'year', $year ) && // exclude date-time |
3578 | 4052 | array_key_exists( 'month', $year ) && |
3579 | 4053 | array_key_exists( 'day', $year ))) { // so this must be a duration |
3580 | - if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) |
|
3581 | - $relatedStart = FALSE; |
|
3582 | - else |
|
3583 | - $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE; |
|
4054 | + if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) { |
|
4055 | + $relatedStart = FALSE; |
|
4056 | + } else { |
|
4057 | + $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE; |
|
4058 | + } |
|
3584 | 4059 | $before = ( array_key_exists( 'before', $year ) && ( TRUE !== $year['before'] )) ? FALSE : TRUE; |
3585 | 4060 | } |
3586 | 4061 | $SSYY = ( array_key_exists( 'year', $year )) ? $year['year'] : null; |
@@ -3591,24 +4066,27 @@ discard block |
||
3591 | 4066 | $min = ( array_key_exists( 'min', $year )) ? $year['min'] : 0; //null; |
3592 | 4067 | $sec = ( array_key_exists( 'sec', $year )) ? $year['sec'] : 0; //null; |
3593 | 4068 | $year = $SSYY; |
3594 | - } |
|
3595 | - elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) { // duration or date in a string |
|
4069 | + } elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) { // duration or date in a string |
|
3596 | 4070 | $params = $this->_setParams( $month ); |
3597 | 4071 | if( in_array( $year{0}, array( 'P', '+', '-' ))) { // duration |
3598 | 4072 | $relatedStart = ( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) ? FALSE : TRUE; |
3599 | 4073 | $before = ( '-' == $year{0} ) ? TRUE : FALSE; |
3600 | - if( 'P' != $year{0} ) |
|
3601 | - $year = substr( $year, 1 ); |
|
4074 | + if( 'P' != $year{0} ) { |
|
4075 | + $year = substr( $year, 1 ); |
|
4076 | + } |
|
3602 | 4077 | $date = $this->_duration_string( $year); |
3603 | - } |
|
3604 | - else // date |
|
4078 | + } else { |
|
4079 | + // date |
|
3605 | 4080 | $date = $this->_date_time_string( $year, 7 ); |
4081 | + } |
|
3606 | 4082 | unset( $year, $month, $day ); |
3607 | - foreach( $date as $k => $v ) |
|
3608 | - $$k = $v; |
|
3609 | - } |
|
3610 | - else // single values in function input parameters |
|
4083 | + foreach( $date as $k => $v ) { |
|
4084 | + $$k = $v; |
|
4085 | + } |
|
4086 | + } else { |
|
4087 | + // single values in function input parameters |
|
3611 | 4088 | $params = $this->_setParams( $params ); |
4089 | + } |
|
3612 | 4090 | if( !empty( $year ) && !empty( $month ) && !empty( $day )) { // date |
3613 | 4091 | $params['VALUE'] = 'DATE-TIME'; |
3614 | 4092 | $hour = ( $hour ) ? $hour : 0; |
@@ -3623,8 +4101,7 @@ discard block |
||
3623 | 4101 | , 'sec' => $sec |
3624 | 4102 | , 'tz' => 'Z' ); |
3625 | 4103 | return TRUE; |
3626 | - } |
|
3627 | - elseif(( empty( $year ) && empty( $month )) && // duration |
|
4104 | + } elseif(( empty( $year ) && empty( $month )) && // duration |
|
3628 | 4105 | (!empty( $week ) || !empty( $day ) || !empty( $hour ) || !empty( $min ) || !empty( $sec ))) { |
3629 | 4106 | unset( $params['RELATED'] ); // set at output creation (END only) |
3630 | 4107 | unset( $params['VALUE'] ); // 'DURATION' default |
@@ -3633,11 +4110,21 @@ discard block |
||
3633 | 4110 | $before = ( FALSE !== $before ) ? TRUE : FALSE; |
3634 | 4111 | $this->trigger['value'] = array( 'relatedStart' => $relatedStart |
3635 | 4112 | , 'before' => $before ); |
3636 | - if( !empty( $week )) $this->trigger['value']['week'] = $week; |
|
3637 | - if( !empty( $day )) $this->trigger['value']['day'] = $day; |
|
3638 | - if( !empty( $hour )) $this->trigger['value']['hour'] = $hour; |
|
3639 | - if( !empty( $min )) $this->trigger['value']['min'] = $min; |
|
3640 | - if( !empty( $sec )) $this->trigger['value']['sec'] = $sec; |
|
4113 | + if( !empty( $week )) { |
|
4114 | + $this->trigger['value']['week'] = $week; |
|
4115 | + } |
|
4116 | + if( !empty( $day )) { |
|
4117 | + $this->trigger['value']['day'] = $day; |
|
4118 | + } |
|
4119 | + if( !empty( $hour )) { |
|
4120 | + $this->trigger['value']['hour'] = $hour; |
|
4121 | + } |
|
4122 | + if( !empty( $min )) { |
|
4123 | + $this->trigger['value']['min'] = $min; |
|
4124 | + } |
|
4125 | + if( !empty( $sec )) { |
|
4126 | + $this->trigger['value']['sec'] = $sec; |
|
4127 | + } |
|
3641 | 4128 | return TRUE; |
3642 | 4129 | } |
3643 | 4130 | return FALSE; |
@@ -3654,9 +4141,12 @@ discard block |
||
3654 | 4141 | * @return string |
3655 | 4142 | */ |
3656 | 4143 | function createTzid() { |
3657 | - if( empty( $this->tzid )) return FALSE; |
|
3658 | - if( empty( $this->tzid['value'] )) |
|
3659 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE; |
|
4144 | + if( empty( $this->tzid )) { |
|
4145 | + return FALSE; |
|
4146 | + } |
|
4147 | + if( empty( $this->tzid['value'] )) { |
|
4148 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE; |
|
4149 | + } |
|
3660 | 4150 | $attributes = $this->_createParams( $this->tzid['params'] ); |
3661 | 4151 | return $this->_createElement( 'TZID', $attributes, $this->_strrep( $this->tzid['value'] )); |
3662 | 4152 | } |
@@ -3670,7 +4160,11 @@ discard block |
||
3670 | 4160 | * @return bool |
3671 | 4161 | */ |
3672 | 4162 | function setTzid( $value, $params=FALSE ) { |
3673 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4163 | + if( empty( $value )) { |
|
4164 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4165 | + } else { |
|
4166 | + return FALSE; |
|
4167 | + } |
|
3674 | 4168 | $this->tzid = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3675 | 4169 | return TRUE; |
3676 | 4170 | } |
@@ -3687,14 +4181,17 @@ discard block |
||
3687 | 4181 | * @return string |
3688 | 4182 | */ |
3689 | 4183 | function createTzname() { |
3690 | - if( empty( $this->tzname )) return FALSE; |
|
4184 | + if( empty( $this->tzname )) { |
|
4185 | + return FALSE; |
|
4186 | + } |
|
3691 | 4187 | $output = null; |
3692 | 4188 | foreach( $this->tzname as $theName ) { |
3693 | 4189 | if( !empty( $theName['value'] )) { |
3694 | 4190 | $attributes = $this->_createParams( $theName['params'], array( 'LANGUAGE' )); |
3695 | 4191 | $output .= $this->_createElement( 'TZNAME', $attributes, $this->_strrep( $theName['value'] )); |
4192 | + } elseif( $this->getConfig( 'allowEmpty' )) { |
|
4193 | + $output .= $this->_createElement( 'TZNAME' ); |
|
3696 | 4194 | } |
3697 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'TZNAME' ); |
|
3698 | 4195 | } |
3699 | 4196 | return $output; |
3700 | 4197 | } |
@@ -3709,7 +4206,11 @@ discard block |
||
3709 | 4206 | * @return bool |
3710 | 4207 | */ |
3711 | 4208 | function setTzname( $value, $params=FALSE, $index=FALSE ) { |
3712 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4209 | + if( empty( $value )) { |
|
4210 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4211 | + } else { |
|
4212 | + return FALSE; |
|
4213 | + } |
|
3713 | 4214 | $this->_setMval( $this->tzname, $value, $params, FALSE, $index ); |
3714 | 4215 | return TRUE; |
3715 | 4216 | } |
@@ -3725,9 +4226,12 @@ discard block |
||
3725 | 4226 | * @return string |
3726 | 4227 | */ |
3727 | 4228 | function createTzoffsetfrom() { |
3728 | - if( empty( $this->tzoffsetfrom )) return FALSE; |
|
3729 | - if( empty( $this->tzoffsetfrom['value'] )) |
|
3730 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE; |
|
4229 | + if( empty( $this->tzoffsetfrom )) { |
|
4230 | + return FALSE; |
|
4231 | + } |
|
4232 | + if( empty( $this->tzoffsetfrom['value'] )) { |
|
4233 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE; |
|
4234 | + } |
|
3731 | 4235 | $attributes = $this->_createParams( $this->tzoffsetfrom['params'] ); |
3732 | 4236 | return $this->_createElement( 'TZOFFSETFROM', $attributes, $this->tzoffsetfrom['value'] ); |
3733 | 4237 | } |
@@ -3741,7 +4245,11 @@ discard block |
||
3741 | 4245 | * @return bool |
3742 | 4246 | */ |
3743 | 4247 | function setTzoffsetfrom( $value, $params=FALSE ) { |
3744 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4248 | + if( empty( $value )) { |
|
4249 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4250 | + } else { |
|
4251 | + return FALSE; |
|
4252 | + } |
|
3745 | 4253 | $this->tzoffsetfrom = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3746 | 4254 | return TRUE; |
3747 | 4255 | } |
@@ -3757,9 +4265,12 @@ discard block |
||
3757 | 4265 | * @return string |
3758 | 4266 | */ |
3759 | 4267 | function createTzoffsetto() { |
3760 | - if( empty( $this->tzoffsetto )) return FALSE; |
|
3761 | - if( empty( $this->tzoffsetto['value'] )) |
|
3762 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE; |
|
4268 | + if( empty( $this->tzoffsetto )) { |
|
4269 | + return FALSE; |
|
4270 | + } |
|
4271 | + if( empty( $this->tzoffsetto['value'] )) { |
|
4272 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE; |
|
4273 | + } |
|
3763 | 4274 | $attributes = $this->_createParams( $this->tzoffsetto['params'] ); |
3764 | 4275 | return $this->_createElement( 'TZOFFSETTO', $attributes, $this->tzoffsetto['value'] ); |
3765 | 4276 | } |
@@ -3773,7 +4284,11 @@ discard block |
||
3773 | 4284 | * @return bool |
3774 | 4285 | */ |
3775 | 4286 | function setTzoffsetto( $value, $params=FALSE ) { |
3776 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4287 | + if( empty( $value )) { |
|
4288 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4289 | + } else { |
|
4290 | + return FALSE; |
|
4291 | + } |
|
3777 | 4292 | $this->tzoffsetto = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3778 | 4293 | return TRUE; |
3779 | 4294 | } |
@@ -3789,9 +4304,12 @@ discard block |
||
3789 | 4304 | * @return string |
3790 | 4305 | */ |
3791 | 4306 | function createTzurl() { |
3792 | - if( empty( $this->tzurl )) return FALSE; |
|
3793 | - if( empty( $this->tzurl['value'] )) |
|
3794 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE; |
|
4307 | + if( empty( $this->tzurl )) { |
|
4308 | + return FALSE; |
|
4309 | + } |
|
4310 | + if( empty( $this->tzurl['value'] )) { |
|
4311 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE; |
|
4312 | + } |
|
3795 | 4313 | $attributes = $this->_createParams( $this->tzurl['params'] ); |
3796 | 4314 | return $this->_createElement( 'TZURL', $attributes, $this->tzurl['value'] ); |
3797 | 4315 | } |
@@ -3805,7 +4323,11 @@ discard block |
||
3805 | 4323 | * @return boll |
3806 | 4324 | */ |
3807 | 4325 | function setTzurl( $value, $params=FALSE ) { |
3808 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4326 | + if( empty( $value )) { |
|
4327 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4328 | + } else { |
|
4329 | + return FALSE; |
|
4330 | + } |
|
3809 | 4331 | $this->tzurl = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3810 | 4332 | return TRUE; |
3811 | 4333 | } |
@@ -3821,8 +4343,9 @@ discard block |
||
3821 | 4343 | * @return string |
3822 | 4344 | */ |
3823 | 4345 | function createUid() { |
3824 | - if( 0 >= count( $this->uid )) |
|
3825 | - $this->_makeuid(); |
|
4346 | + if( 0 >= count( $this->uid )) { |
|
4347 | + $this->_makeuid(); |
|
4348 | + } |
|
3826 | 4349 | $attributes = $this->_createParams( $this->uid['params'] ); |
3827 | 4350 | return $this->_createElement( 'UID', $attributes, $this->uid['value'] ); |
3828 | 4351 | } |
@@ -3841,8 +4364,9 @@ discard block |
||
3841 | 4364 | $end = strlen( $base ) - 1; |
3842 | 4365 | $length = 6; |
3843 | 4366 | $str = null; |
3844 | - for( $p = 0; $p < $length; $p++ ) |
|
3845 | - $unique .= $base{mt_rand( $start, $end )}; |
|
4367 | + for( $p = 0; $p < $length; $p++ ) { |
|
4368 | + $unique .= $base{mt_rand( $start, $end )}; |
|
4369 | + } |
|
3846 | 4370 | $this->uid = array( 'params' => null ); |
3847 | 4371 | $this->uid['value'] = $date.'-'.$unique.'@'.$this->getConfig( 'unique_id' ); |
3848 | 4372 | } |
@@ -3856,7 +4380,10 @@ discard block |
||
3856 | 4380 | * @return bool |
3857 | 4381 | */ |
3858 | 4382 | function setUid( $value, $params=FALSE ) { |
3859 | - if( empty( $value )) return FALSE; // no allowEmpty check here !!!! |
|
4383 | + if( empty( $value )) { |
|
4384 | + return FALSE; |
|
4385 | + } |
|
4386 | + // no allowEmpty check here !!!! |
|
3860 | 4387 | $this->uid = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3861 | 4388 | return TRUE; |
3862 | 4389 | } |
@@ -3872,9 +4399,12 @@ discard block |
||
3872 | 4399 | * @return string |
3873 | 4400 | */ |
3874 | 4401 | function createUrl() { |
3875 | - if( empty( $this->url )) return FALSE; |
|
3876 | - if( empty( $this->url['value'] )) |
|
3877 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE; |
|
4402 | + if( empty( $this->url )) { |
|
4403 | + return FALSE; |
|
4404 | + } |
|
4405 | + if( empty( $this->url['value'] )) { |
|
4406 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE; |
|
4407 | + } |
|
3878 | 4408 | $attributes = $this->_createParams( $this->url['params'] ); |
3879 | 4409 | return $this->_createElement( 'URL', $attributes, $this->url['value'] ); |
3880 | 4410 | } |
@@ -3888,7 +4418,11 @@ discard block |
||
3888 | 4418 | * @return bool |
3889 | 4419 | */ |
3890 | 4420 | function setUrl( $value, $params=FALSE ) { |
3891 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4421 | + if( empty( $value )) { |
|
4422 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4423 | + } else { |
|
4424 | + return FALSE; |
|
4425 | + } |
|
3892 | 4426 | $this->url = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3893 | 4427 | return TRUE; |
3894 | 4428 | } |
@@ -3904,21 +4438,26 @@ discard block |
||
3904 | 4438 | * @return string |
3905 | 4439 | */ |
3906 | 4440 | function createXprop() { |
3907 | - if( empty( $this->xprop )) return FALSE; |
|
4441 | + if( empty( $this->xprop )) { |
|
4442 | + return FALSE; |
|
4443 | + } |
|
3908 | 4444 | $output = null; |
3909 | 4445 | foreach( $this->xprop as $label => $xpropPart ) { |
3910 | 4446 | if( empty( $xpropPart['value'] )) { |
3911 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $label ); |
|
4447 | + if( $this->getConfig( 'allowEmpty' )) { |
|
4448 | + $output .= $this->_createElement( $label ); |
|
4449 | + } |
|
3912 | 4450 | continue; |
3913 | 4451 | } |
3914 | 4452 | $attributes = $this->_createParams( $xpropPart['params'], array( 'LANGUAGE' )); |
3915 | 4453 | if( is_array( $xpropPart['value'] )) { |
3916 | - foreach( $xpropPart['value'] as $pix => $theXpart ) |
|
3917 | - $xpropPart['value'][$pix] = $this->_strrep( $theXpart ); |
|
4454 | + foreach( $xpropPart['value'] as $pix => $theXpart ) { |
|
4455 | + $xpropPart['value'][$pix] = $this->_strrep( $theXpart ); |
|
4456 | + } |
|
3918 | 4457 | $xpropPart['value'] = implode( ',', $xpropPart['value'] ); |
4458 | + } else { |
|
4459 | + $xpropPart['value'] = $this->_strrep( $xpropPart['value'] ); |
|
3919 | 4460 | } |
3920 | - else |
|
3921 | - $xpropPart['value'] = $this->_strrep( $xpropPart['value'] ); |
|
3922 | 4461 | $output .= $this->_createElement( $label, $attributes, $xpropPart['value'] ); |
3923 | 4462 | } |
3924 | 4463 | return $output; |
@@ -3934,12 +4473,20 @@ discard block |
||
3934 | 4473 | * @return bool |
3935 | 4474 | */ |
3936 | 4475 | function setXprop( $label, $value, $params=FALSE ) { |
3937 | - if( empty( $label )) return; |
|
3938 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4476 | + if( empty( $label )) { |
|
4477 | + return; |
|
4478 | + } |
|
4479 | + if( empty( $value )) { |
|
4480 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4481 | + } else { |
|
4482 | + return FALSE; |
|
4483 | + } |
|
3939 | 4484 | $xprop = array( 'value' => $value ); |
3940 | 4485 | $toolbox = new calendarComponent(); |
3941 | 4486 | $xprop['params'] = $toolbox->_setParams( $params ); |
3942 | - if( !is_array( $this->xprop )) $this->xprop = array(); |
|
4487 | + if( !is_array( $this->xprop )) { |
|
4488 | + $this->xprop = array(); |
|
4489 | + } |
|
3943 | 4490 | $this->xprop[strtoupper( $label )] = $xprop; |
3944 | 4491 | return TRUE; |
3945 | 4492 | } |
@@ -4007,30 +4554,29 @@ discard block |
||
4007 | 4554 | $attributes = null; |
4008 | 4555 | foreach( $attributes2 as $attribute ) { |
4009 | 4556 | $attrKVarr = explode( '=', $attribute ); |
4010 | - if( empty( $attrKVarr[0] )) |
|
4011 | - continue; |
|
4557 | + if( empty( $attrKVarr[0] )) { |
|
4558 | + continue; |
|
4559 | + } |
|
4012 | 4560 | if( !isset( $attrKVarr[1] )) { |
4013 | 4561 | $attrValue = $attrKVarr[0]; |
4014 | 4562 | $attrKey = null; |
4015 | - } |
|
4016 | - elseif( 2 == count( $attrKVarr)) { |
|
4563 | + } elseif( 2 == count( $attrKVarr)) { |
|
4017 | 4564 | $attrKey = strtolower( $attrKVarr[0] ); |
4018 | 4565 | $attrValue = $attrKVarr[1]; |
4019 | - } |
|
4020 | - else { |
|
4566 | + } else { |
|
4021 | 4567 | $attrKey = strtolower( $attrKVarr[0] ); |
4022 | 4568 | unset( $attrKVarr[0] ); |
4023 | 4569 | $attrValue = implode( '=', $attrKVarr ); |
4024 | 4570 | } |
4025 | 4571 | if(( 'attach' == $label ) && ( in_array( $attrKey, array( 'fmttype', 'encoding', 'value' )))) { |
4026 | 4572 | $attachInlineBinary = TRUE; |
4027 | - if( 'fmttype' == $attrKey ) |
|
4028 | - $attachfmttype = $attrKey.'='.$attrValue; |
|
4573 | + if( 'fmttype' == $attrKey ) { |
|
4574 | + $attachfmttype = $attrKey.'='.$attrValue; |
|
4575 | + } |
|
4029 | 4576 | continue; |
4030 | - } |
|
4031 | - elseif(( 'categories' == $label ) && ( 'language' == $attrKey )) |
|
4032 | - $categoriesAttrLang = $attrKey.'='.$attrValue; |
|
4033 | - else { |
|
4577 | + } elseif(( 'categories' == $label ) && ( 'language' == $attrKey )) { |
|
4578 | + $categoriesAttrLang = $attrKey.'='.$attrValue; |
|
4579 | + } else { |
|
4034 | 4580 | $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' '; |
4035 | 4581 | $attributes .= ( !empty( $attrKey )) ? $attrKey.'=' : null; |
4036 | 4582 | if(( '"' == substr( $attrValue, 0, 1 )) && ( '"' == substr( $attrValue, -1 ))) { |
@@ -4040,8 +4586,7 @@ discard block |
||
4040 | 4586 | $attributes .= '"'.htmlspecialchars( $attrValue ).'"'; |
4041 | 4587 | } |
4042 | 4588 | } |
4043 | - } |
|
4044 | - else { |
|
4589 | + } else { |
|
4045 | 4590 | $attributes = str_replace( $this->intAttrDelimiter, $this->attributeDelimiter, $attributes ); |
4046 | 4591 | } |
4047 | 4592 | } |
@@ -4063,8 +4608,7 @@ discard block |
||
4063 | 4608 | $content = $this->_createElement( 'extref', $attributes, null ); |
4064 | 4609 | $attributes = null; |
4065 | 4610 | } |
4066 | - } |
|
4067 | - elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) { |
|
4611 | + } elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) { |
|
4068 | 4612 | $content = $this->nl.$this->_createElement( 'b64bin', $attachfmttype, $content ); // max one attribute |
4069 | 4613 | } |
4070 | 4614 | $output .= $attributes; |
@@ -4108,30 +4652,30 @@ discard block |
||
4108 | 4652 | $CNattrExist = $LANGattrExist = FALSE; |
4109 | 4653 | if( is_array( $params )) { |
4110 | 4654 | foreach( $params as $paramKey => $paramValue ) { |
4111 | - if( is_int( $paramKey )) |
|
4112 | - $attr2 .= $this->intAttrDelimiter.$paramValue; |
|
4113 | - elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) { |
|
4655 | + if( is_int( $paramKey )) { |
|
4656 | + $attr2 .= $this->intAttrDelimiter.$paramValue; |
|
4657 | + } elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) { |
|
4114 | 4658 | $attrLANG .= $this->intAttrDelimiter."LANGUAGE=$paramValue"; |
4115 | 4659 | $LANGattrExist = TRUE; |
4116 | - } |
|
4117 | - elseif(( 'CN' == $paramKey ) && $CNattrKey ) { |
|
4660 | + } elseif(( 'CN' == $paramKey ) && $CNattrKey ) { |
|
4118 | 4661 | $attr1 = $this->intAttrDelimiter.'CN="'.$paramValue.'"'; |
4119 | 4662 | $CNattrExist = TRUE; |
4663 | + } elseif(( 'ALTREP' == $paramKey ) && in_array( $paramKey, $ctrKeys )) { |
|
4664 | + $attr2 .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"'; |
|
4665 | + } elseif(( 'DIR' == $paramKey ) && in_array( $paramKey, $ctrKeys )) { |
|
4666 | + $attr2 .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"'; |
|
4667 | + } elseif(( 'SENT-BY' == $paramKey ) && in_array( $paramKey, $ctrKeys )) { |
|
4668 | + $attr2 .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"'; |
|
4669 | + } else { |
|
4670 | + $attr2 .= $this->intAttrDelimiter."$paramKey=$paramValue"; |
|
4120 | 4671 | } |
4121 | - elseif(( 'ALTREP' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4122 | - $attr2 .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"'; |
|
4123 | - elseif(( 'DIR' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4124 | - $attr2 .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"'; |
|
4125 | - elseif(( 'SENT-BY' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4126 | - $attr2 .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"'; |
|
4127 | - else |
|
4128 | - $attr2 .= $this->intAttrDelimiter."$paramKey=$paramValue"; |
|
4129 | 4672 | } |
4130 | 4673 | } |
4131 | 4674 | if( !$LANGattrExist ) { |
4132 | 4675 | $lang = $this->getConfig( 'language' ); |
4133 | - if(( $CNattrExist || $LANGattrKey ) && $lang ) |
|
4134 | - $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang; |
|
4676 | + if(( $CNattrExist || $LANGattrKey ) && $lang ) { |
|
4677 | + $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang; |
|
4678 | + } |
|
4135 | 4679 | } |
4136 | 4680 | return $attrLANG.$attr1.$attr2; |
4137 | 4681 | } |
@@ -4145,47 +4689,57 @@ discard block |
||
4145 | 4689 | * @return array $params, property parameters |
4146 | 4690 | */ |
4147 | 4691 | function _chkdatecfg( $theDate, & $parno, & $params ) { |
4148 | - if( isset( $params['TZID'] )) |
|
4149 | - $parno = 6; |
|
4150 | - elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )) |
|
4151 | - $parno = 3; |
|
4152 | - else { |
|
4153 | - if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] )) |
|
4154 | - $parno = 7; |
|
4692 | + if( isset( $params['TZID'] )) { |
|
4693 | + $parno = 6; |
|
4694 | + } elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )) { |
|
4695 | + $parno = 3; |
|
4696 | + } else { |
|
4697 | + if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] )) { |
|
4698 | + $parno = 7; |
|
4699 | + } |
|
4155 | 4700 | if( is_array( $theDate )) { |
4156 | - if( isset( $theDate['timestamp'] )) |
|
4157 | - $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null; |
|
4158 | - else |
|
4159 | - $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null; |
|
4701 | + if( isset( $theDate['timestamp'] )) { |
|
4702 | + $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null; |
|
4703 | + } else { |
|
4704 | + $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null; |
|
4705 | + } |
|
4160 | 4706 | if( !empty( $tzid )) { |
4161 | 4707 | $parno = 7; |
4162 | - if( !$this->_isOffset( $tzid )) |
|
4163 | - $params['TZID'] = $tzid; // save only timezone |
|
4708 | + if( !$this->_isOffset( $tzid )) { |
|
4709 | + $params['TZID'] = $tzid; |
|
4710 | + } |
|
4711 | + // save only timezone |
|
4712 | + } elseif( !$parno && ( 3 == count( $theDate )) && |
|
4713 | + ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))) { |
|
4714 | + $parno = 3; |
|
4715 | + } else { |
|
4716 | + $parno = 6; |
|
4164 | 4717 | } |
4165 | - elseif( !$parno && ( 3 == count( $theDate )) && |
|
4166 | - ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))) |
|
4167 | - $parno = 3; |
|
4168 | - else |
|
4169 | - $parno = 6; |
|
4170 | - } |
|
4171 | - else { // string |
|
4718 | + } else { // string |
|
4172 | 4719 | $date = trim( $theDate ); |
4173 | - if( 'Z' == substr( $date, -1 )) |
|
4174 | - $parno = 7; // UTC DATE-TIME |
|
4720 | + if( 'Z' == substr( $date, -1 )) { |
|
4721 | + $parno = 7; |
|
4722 | + } |
|
4723 | + // UTC DATE-TIME |
|
4175 | 4724 | elseif((( 8 == strlen( $date ) && ctype_digit( $date )) || ( 11 >= strlen( $date ))) && |
4176 | - ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' )))) |
|
4177 | - $parno = 3; // DATE |
|
4725 | + ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' )))) { |
|
4726 | + $parno = 3; |
|
4727 | + } |
|
4728 | + // DATE |
|
4178 | 4729 | $date = $this->_date_time_string( $date, $parno ); |
4179 | 4730 | if( !empty( $date['tz'] )) { |
4180 | 4731 | $parno = 7; |
4181 | - if( !$this->_isOffset( $date['tz'] )) |
|
4182 | - $params['TZID'] = $date['tz']; // save only timezone |
|
4732 | + if( !$this->_isOffset( $date['tz'] )) { |
|
4733 | + $params['TZID'] = $date['tz']; |
|
4734 | + } |
|
4735 | + // save only timezone |
|
4736 | + } elseif( empty( $parno )) { |
|
4737 | + $parno = 6; |
|
4183 | 4738 | } |
4184 | - elseif( empty( $parno )) |
|
4185 | - $parno = 6; |
|
4186 | 4739 | } |
4187 | - if( isset( $params['TZID'] )) |
|
4188 | - $parno = 6; |
|
4740 | + if( isset( $params['TZID'] )) { |
|
4741 | + $parno = 6; |
|
4742 | + } |
|
4189 | 4743 | } |
4190 | 4744 | } |
4191 | 4745 | /** |
@@ -4201,14 +4755,18 @@ discard block |
||
4201 | 4755 | */ |
4202 | 4756 | function _date2duration( $startdate=FALSE, $enddate=FALSE ) { |
4203 | 4757 | if( !$startdate || !$enddate ) { |
4204 | - if( FALSE === ( $startdate = $this->getProperty( 'dtstart' ))) |
|
4205 | - return null; |
|
4206 | - if( FALSE === ( $enddate = $this->getProperty( 'dtend' ))) // vevent/vfreebusy |
|
4758 | + if( FALSE === ( $startdate = $this->getProperty( 'dtstart' ))) { |
|
4759 | + return null; |
|
4760 | + } |
|
4761 | + if( FALSE === ( $enddate = $this->getProperty( 'dtend' ))) { |
|
4762 | + // vevent/vfreebusy |
|
4207 | 4763 | if( FALSE === ( $enddate = $this->getProperty( 'due' ))) // vtodo |
4208 | 4764 | return null; |
4765 | + } |
|
4766 | + } |
|
4767 | + if( !$startdate || !$enddate ) { |
|
4768 | + return null; |
|
4209 | 4769 | } |
4210 | - if( !$startdate || !$enddate ) |
|
4211 | - return null; |
|
4212 | 4770 | $startWdate = mktime( 0, 0, 0, $startdate['month'], $startdate['day'], $startdate['year'] ); |
4213 | 4771 | $endWdate = mktime( 0, 0, 0, $enddate['month'], $enddate['day'], $enddate['year'] ); |
4214 | 4772 | $wduration = $endWdate - $startWdate; |
@@ -4234,15 +4792,23 @@ discard block |
||
4234 | 4792 | */ |
4235 | 4793 | function _date2timestamp( $datetime, $tz=null ) { |
4236 | 4794 | $output = null; |
4237 | - if( !isset( $datetime['hour'] )) $datetime['hour'] = '0'; |
|
4238 | - if( !isset( $datetime['min'] )) $datetime['min'] = '0'; |
|
4239 | - if( !isset( $datetime['sec'] )) $datetime['sec'] = '0'; |
|
4795 | + if( !isset( $datetime['hour'] )) { |
|
4796 | + $datetime['hour'] = '0'; |
|
4797 | + } |
|
4798 | + if( !isset( $datetime['min'] )) { |
|
4799 | + $datetime['min'] = '0'; |
|
4800 | + } |
|
4801 | + if( !isset( $datetime['sec'] )) { |
|
4802 | + $datetime['sec'] = '0'; |
|
4803 | + } |
|
4240 | 4804 | foreach( $datetime as $dkey => $dvalue ) { |
4241 | - if( 'tz' != $dkey ) |
|
4242 | - $datetime[$dkey] = (integer) $dvalue; |
|
4805 | + if( 'tz' != $dkey ) { |
|
4806 | + $datetime[$dkey] = (integer) $dvalue; |
|
4807 | + } |
|
4808 | + } |
|
4809 | + if( $tz ) { |
|
4810 | + $datetime['tz'] = $tz; |
|
4243 | 4811 | } |
4244 | - if( $tz ) |
|
4245 | - $datetime['tz'] = $tz; |
|
4246 | 4812 | $offset = ( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) ? $this->_tz2offset( $datetime['tz'] ) : 0; |
4247 | 4813 | $output = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year'] ); |
4248 | 4814 | return $output; |
@@ -4299,12 +4865,15 @@ discard block |
||
4299 | 4865 | } |
4300 | 4866 | } |
4301 | 4867 | if( 3 != $parno ) { |
4302 | - if( !isset( $output['hour'] )) |
|
4303 | - $output['hour'] = 0; |
|
4304 | - if( !isset( $output['min'] )) |
|
4305 | - $output['min'] = 0; |
|
4306 | - if( !isset( $output['sec'] )) |
|
4307 | - $output['sec'] = 0; |
|
4868 | + if( !isset( $output['hour'] )) { |
|
4869 | + $output['hour'] = 0; |
|
4870 | + } |
|
4871 | + if( !isset( $output['min'] )) { |
|
4872 | + $output['min'] = 0; |
|
4873 | + } |
|
4874 | + if( !isset( $output['sec'] )) { |
|
4875 | + $output['sec'] = 0; |
|
4876 | + } |
|
4308 | 4877 | } |
4309 | 4878 | return $output; |
4310 | 4879 | } |
@@ -4324,39 +4893,37 @@ discard block |
||
4324 | 4893 | if( 'Z' == substr( $datetime, -1 )) { |
4325 | 4894 | $tz = 'Z'; |
4326 | 4895 | $datetime = trim( substr( $datetime, 0, $len )); |
4327 | - } |
|
4328 | - elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date |
|
4896 | + } elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date |
|
4329 | 4897 | ( '-' == substr( $datetime, -3, 1 )) || |
4330 | 4898 | ( ':' == substr( $datetime, -3, 1 )) || |
4331 | 4899 | ( '.' == substr( $datetime, -3, 1 ))) { |
4332 | 4900 | $continue = TRUE; |
4333 | - } |
|
4334 | - elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset |
|
4901 | + } elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset |
|
4335 | 4902 | ( ' +' == substr( $datetime, -6, 2 )) || |
4336 | 4903 | ( ' -' == substr( $datetime, -6, 2 ))) { |
4337 | 4904 | $tz = substr( $datetime, -5, 5 ); |
4338 | 4905 | $datetime = substr( $datetime, 0, ($len - 5)); |
4339 | - } |
|
4340 | - elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset |
|
4906 | + } elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset |
|
4341 | 4907 | ( ' +' == substr( $datetime, -8, 2 )) || |
4342 | 4908 | ( ' -' == substr( $datetime, -8, 2 ))) { |
4343 | 4909 | $tz = substr( $datetime, -7, 7 ); |
4344 | 4910 | $datetime = substr( $datetime, 0, ($len - 7)); |
4345 | - } |
|
4346 | - elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) { |
|
4911 | + } elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) { |
|
4347 | 4912 | $continue = TRUE; |
4348 | - } |
|
4349 | - elseif( 'T' == substr( $datetime, -7, 1 )) { |
|
4913 | + } elseif( 'T' == substr( $datetime, -7, 1 )) { |
|
4350 | 4914 | $continue = TRUE; |
4351 | - } |
|
4352 | - else { |
|
4915 | + } else { |
|
4353 | 4916 | $cx = $tx = 0; // 19970415T133000 US-Eastern |
4354 | 4917 | for( $cx = -1; $cx > ( 9 - $len ); $cx-- ) { |
4355 | - if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 ))) |
|
4356 | - break; // if exists, tz ends here.. . ? |
|
4918 | + if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 ))) { |
|
4919 | + break; |
|
4920 | + } |
|
4921 | + // if exists, tz ends here.. . ? |
|
4357 | 4922 | elseif( ctype_alpha( substr( $datetime, $cx, 1 )) || |
4358 | - ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' )))) |
|
4359 | - $tx--; // tz length counter |
|
4923 | + ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' )))) { |
|
4924 | + $tx--; |
|
4925 | + } |
|
4926 | + // tz length counter |
|
4360 | 4927 | } |
4361 | 4928 | if( 0 > $tx ) { |
4362 | 4929 | $tz = substr( $datetime, $tx ); |
@@ -4365,8 +4932,7 @@ discard block |
||
4365 | 4932 | } |
4366 | 4933 | if( 0 < substr_count( $datetime, '-' )) { |
4367 | 4934 | $datetime = str_replace( '-', '/', $datetime ); |
4368 | - } |
|
4369 | - elseif( ctype_digit( substr( $datetime, 0, 8 )) && |
|
4935 | + } elseif( ctype_digit( substr( $datetime, 0, 8 )) && |
|
4370 | 4936 | ( 'T' == substr( $datetime, 8, 1 )) && |
4371 | 4937 | ctype_digit( substr( $datetime, 9, 6 ))) { |
4372 | 4938 | $datetime = substr( $datetime, 4, 2 ) |
@@ -4386,10 +4952,10 @@ discard block |
||
4386 | 4952 | $output['hour'] = substr( $datestring, 11, 2 ); |
4387 | 4953 | $output['min'] = substr( $datestring, 14, 2 ); |
4388 | 4954 | $output['sec'] = substr( $datestring, 17, 2 ); |
4389 | - if( !empty( $tz )) |
|
4390 | - $output['tz'] = $tz; |
|
4391 | - } |
|
4392 | - elseif( 3 != $parno ) { |
|
4955 | + if( !empty( $tz )) { |
|
4956 | + $output['tz'] = $tz; |
|
4957 | + } |
|
4958 | + } elseif( 3 != $parno ) { |
|
4393 | 4959 | if(( '00' < substr( $datestring, 11, 2 )) || |
4394 | 4960 | ( '00' < substr( $datestring, 14, 2 )) || |
4395 | 4961 | ( '00' < substr( $datestring, 17, 2 ))) { |
@@ -4397,8 +4963,9 @@ discard block |
||
4397 | 4963 | $output['min'] = substr( $datestring, 14, 2 ); |
4398 | 4964 | $output['sec'] = substr( $datestring, 17, 2 ); |
4399 | 4965 | } |
4400 | - if( !empty( $tz )) |
|
4401 | - $output['tz'] = $tz; |
|
4966 | + if( !empty( $tz )) { |
|
4967 | + $output['tz'] = $tz; |
|
4968 | + } |
|
4402 | 4969 | } |
4403 | 4970 | return $output; |
4404 | 4971 | } |
@@ -4425,10 +4992,11 @@ discard block |
||
4425 | 4992 | $durseconds = $durseconds % ( 60 * 60 ); |
4426 | 4993 | $output['min'] = floor( $durseconds / ( 60 )); |
4427 | 4994 | $output['sec'] = ( $durseconds % ( 60 )); |
4428 | - } |
|
4429 | - else { |
|
4995 | + } else { |
|
4430 | 4996 | foreach( $duration as $durKey => $durValue ) { |
4431 | - if( empty( $durValue )) continue; |
|
4997 | + if( empty( $durValue )) { |
|
4998 | + continue; |
|
4999 | + } |
|
4432 | 5000 | switch ( $durKey ) { |
4433 | 5001 | case '0': |
4434 | 5002 | case 'week': |
@@ -4458,14 +5026,22 @@ discard block |
||
4458 | 5026 | return $output; |
4459 | 5027 | } |
4460 | 5028 | unset( $output['week'] ); |
4461 | - if( empty( $output['day'] )) |
|
4462 | - unset( $output['day'] ); |
|
5029 | + if( empty( $output['day'] )) { |
|
5030 | + unset( $output['day'] ); |
|
5031 | + } |
|
4463 | 5032 | if ( isset( $output['hour'] ) || isset( $output['min'] ) || isset( $output['sec'] )) { |
4464 | - if( !isset( $output['hour'] )) $output['hour'] = 0; |
|
4465 | - if( !isset( $output['min'] )) $output['min'] = 0; |
|
4466 | - if( !isset( $output['sec'] )) $output['sec'] = 0; |
|
4467 | - if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] )) |
|
4468 | - unset( $output['hour'], $output['min'], $output['sec'] ); |
|
5033 | + if( !isset( $output['hour'] )) { |
|
5034 | + $output['hour'] = 0; |
|
5035 | + } |
|
5036 | + if( !isset( $output['min'] )) { |
|
5037 | + $output['min'] = 0; |
|
5038 | + } |
|
5039 | + if( !isset( $output['sec'] )) { |
|
5040 | + $output['sec'] = 0; |
|
5041 | + } |
|
5042 | + if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] )) { |
|
5043 | + unset( $output['hour'], $output['min'], $output['sec'] ); |
|
5044 | + } |
|
4469 | 5045 | } |
4470 | 5046 | return $output; |
4471 | 5047 | } |
@@ -4482,28 +5058,32 @@ discard block |
||
4482 | 5058 | if( $startdate && $duration ) { |
4483 | 5059 | $d1 = $startdate; |
4484 | 5060 | $dur = $duration; |
4485 | - } |
|
4486 | - elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) { |
|
5061 | + } elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) { |
|
4487 | 5062 | $d1 = $this->dtstart['value']; |
4488 | 5063 | $dur = $this->duration['value']; |
5064 | + } else { |
|
5065 | + return null; |
|
4489 | 5066 | } |
4490 | - else |
|
4491 | - return null; |
|
4492 | 5067 | $dateOnly = ( isset( $d1['hour'] ) || isset( $d1['min'] ) || isset( $d1['sec'] )) ? FALSE : TRUE; |
4493 | 5068 | $d1['hour'] = ( isset( $d1['hour'] )) ? $d1['hour'] : 0; |
4494 | 5069 | $d1['min'] = ( isset( $d1['min'] )) ? $d1['min'] : 0; |
4495 | 5070 | $d1['sec'] = ( isset( $d1['sec'] )) ? $d1['sec'] : 0; |
4496 | 5071 | $dtend = mktime( $d1['hour'], $d1['min'], $d1['sec'], $d1['month'], $d1['day'], $d1['year'] ); |
4497 | - if( isset( $dur['week'] )) |
|
4498 | - $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 ); |
|
4499 | - if( isset( $dur['day'] )) |
|
4500 | - $dtend += ( $dur['day'] * 24 * 60 * 60 ); |
|
4501 | - if( isset( $dur['hour'] )) |
|
4502 | - $dtend += ( $dur['hour'] * 60 *60 ); |
|
4503 | - if( isset( $dur['min'] )) |
|
4504 | - $dtend += ( $dur['min'] * 60 ); |
|
4505 | - if( isset( $dur['sec'] )) |
|
4506 | - $dtend += $dur['sec']; |
|
5072 | + if( isset( $dur['week'] )) { |
|
5073 | + $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 ); |
|
5074 | + } |
|
5075 | + if( isset( $dur['day'] )) { |
|
5076 | + $dtend += ( $dur['day'] * 24 * 60 * 60 ); |
|
5077 | + } |
|
5078 | + if( isset( $dur['hour'] )) { |
|
5079 | + $dtend += ( $dur['hour'] * 60 *60 ); |
|
5080 | + } |
|
5081 | + if( isset( $dur['min'] )) { |
|
5082 | + $dtend += ( $dur['min'] * 60 ); |
|
5083 | + } |
|
5084 | + if( isset( $dur['sec'] )) { |
|
5085 | + $dtend += $dur['sec']; |
|
5086 | + } |
|
4507 | 5087 | $dtend2 = array(); |
4508 | 5088 | $dtend2['year'] = date('Y', $dtend ); |
4509 | 5089 | $dtend2['month'] = date('m', $dtend ); |
@@ -4511,10 +5091,12 @@ discard block |
||
4511 | 5091 | $dtend2['hour'] = date('H', $dtend ); |
4512 | 5092 | $dtend2['min'] = date('i', $dtend ); |
4513 | 5093 | $dtend2['sec'] = date('s', $dtend ); |
4514 | - if( isset( $d1['tz'] )) |
|
4515 | - $dtend2['tz'] = $d1['tz']; |
|
4516 | - if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] ))) |
|
4517 | - unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] ); |
|
5094 | + if( isset( $d1['tz'] )) { |
|
5095 | + $dtend2['tz'] = $d1['tz']; |
|
5096 | + } |
|
5097 | + if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] ))) { |
|
5098 | + unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] ); |
|
5099 | + } |
|
4518 | 5100 | return $dtend2; |
4519 | 5101 | } |
4520 | 5102 | /** |
@@ -4528,10 +5110,12 @@ discard block |
||
4528 | 5110 | function _duration_string( $duration ) { |
4529 | 5111 | $duration = (string) trim( $duration ); |
4530 | 5112 | while( 'P' != strtoupper( substr( $duration, 0, 1 ))) { |
4531 | - if( 0 < strlen( $duration )) |
|
4532 | - $duration = substr( $duration, 1 ); |
|
4533 | - else |
|
4534 | - return false; // no leading P !?!? |
|
5113 | + if( 0 < strlen( $duration )) { |
|
5114 | + $duration = substr( $duration, 1 ); |
|
5115 | + } else { |
|
5116 | + return false; |
|
5117 | + } |
|
5118 | + // no leading P !?!? |
|
4535 | 5119 | } |
4536 | 5120 | $duration = substr( $duration, 1 ); // skip P |
4537 | 5121 | $duration = str_replace ( 't', 'T', $duration ); |
@@ -4561,10 +5145,13 @@ discard block |
||
4561 | 5145 | $val = null; |
4562 | 5146 | break; |
4563 | 5147 | default: |
4564 | - if( !ctype_digit( $duration{$ix} )) |
|
4565 | - return false; // unknown duration controll character !?!? |
|
4566 | - else |
|
4567 | - $val .= $duration{$ix}; |
|
5148 | + if( !ctype_digit( $duration{$ix} )) { |
|
5149 | + return false; |
|
5150 | + } |
|
5151 | + // unknown duration controll character !?!? |
|
5152 | + else { |
|
5153 | + $val .= $duration{$ix}; |
|
5154 | + } |
|
4568 | 5155 | } |
4569 | 5156 | } |
4570 | 5157 | return $this->_duration_array( $output ); |
@@ -4583,10 +5170,12 @@ discard block |
||
4583 | 5170 | * @return int |
4584 | 5171 | */ |
4585 | 5172 | function _existRem( &$array, $expkey, $expval=FALSE, $hitVal=null, $elseVal=null, $preSet=null ) { |
4586 | - if( $preSet ) |
|
4587 | - return $preSet; |
|
4588 | - if( !is_array( $array ) || ( 0 == count( $array ))) |
|
4589 | - return $elseVal; |
|
5173 | + if( $preSet ) { |
|
5174 | + return $preSet; |
|
5175 | + } |
|
5176 | + if( !is_array( $array ) || ( 0 == count( $array ))) { |
|
5177 | + return $elseVal; |
|
5178 | + } |
|
4590 | 5179 | foreach( $array as $key => $value ) { |
4591 | 5180 | if( strtoupper( $expkey ) == strtoupper( $key )) { |
4592 | 5181 | if( !$expval || ( strtoupper( $expval ) == strtoupper( $array[$key] ))) { |
@@ -4612,13 +5201,15 @@ discard block |
||
4612 | 5201 | !isset( $datetime['day'] ) && |
4613 | 5202 | !isset( $datetime['hour'] ) && |
4614 | 5203 | !isset( $datetime['min'] ) && |
4615 | - !isset( $datetime['sec'] )) |
|
4616 | - return ; |
|
5204 | + !isset( $datetime['sec'] )) { |
|
5205 | + return ; |
|
5206 | + } |
|
4617 | 5207 | $output = null; |
4618 | 5208 | // 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"; } |
4619 | 5209 | foreach( $datetime as $dkey => $dvalue ) { |
4620 | - if( 'tz' != $dkey ) |
|
4621 | - $datetime[$dkey] = (integer) $dvalue; |
|
5210 | + if( 'tz' != $dkey ) { |
|
5211 | + $datetime[$dkey] = (integer) $dvalue; |
|
5212 | + } |
|
4622 | 5213 | } |
4623 | 5214 | $output = date('Ymd', mktime( 0, 0, 0, $datetime['month'], $datetime['day'], $datetime['year'])); |
4624 | 5215 | if( isset( $datetime['hour'] ) || |
@@ -4626,29 +5217,33 @@ discard block |
||
4626 | 5217 | isset( $datetime['sec'] ) || |
4627 | 5218 | isset( $datetime['tz'] )) { |
4628 | 5219 | if( isset( $datetime['tz'] ) && |
4629 | - !isset( $datetime['hour'] )) |
|
4630 | - $datetime['hour'] = 0; |
|
5220 | + !isset( $datetime['hour'] )) { |
|
5221 | + $datetime['hour'] = 0; |
|
5222 | + } |
|
4631 | 5223 | if( isset( $datetime['hour'] ) && |
4632 | - !isset( $datetime['min'] )) |
|
4633 | - $datetime['min'] = 0; |
|
5224 | + !isset( $datetime['min'] )) { |
|
5225 | + $datetime['min'] = 0; |
|
5226 | + } |
|
4634 | 5227 | if( isset( $datetime['hour'] ) && |
4635 | 5228 | isset( $datetime['min'] ) && |
4636 | - !isset( $datetime['sec'] )) |
|
4637 | - $datetime['sec'] = 0; |
|
5229 | + !isset( $datetime['sec'] )) { |
|
5230 | + $datetime['sec'] = 0; |
|
5231 | + } |
|
4638 | 5232 | $date = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']); |
4639 | 5233 | $output .= date('\THis', $date ); |
4640 | 5234 | if( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) { |
4641 | 5235 | $datetime['tz'] = trim( $datetime['tz'] ); |
4642 | - if( 'Z' == $datetime['tz'] ) |
|
4643 | - $output .= 'Z'; |
|
5236 | + if( 'Z' == $datetime['tz'] ) { |
|
5237 | + $output .= 'Z'; |
|
5238 | + } |
|
4644 | 5239 | $offset = $this->_tz2offset( $datetime['tz'] ); |
4645 | 5240 | if( 0 != $offset ) { |
4646 | 5241 | $date = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']); |
4647 | 5242 | $output = date( 'Ymd\THis\Z', $date ); |
4648 | 5243 | } |
5244 | + } elseif( 7 == $parno ) { |
|
5245 | + $output .= 'Z'; |
|
4649 | 5246 | } |
4650 | - elseif( 7 == $parno ) |
|
4651 | - $output .= 'Z'; |
|
4652 | 5247 | } |
4653 | 5248 | return $output; |
4654 | 5249 | } |
@@ -4665,14 +5260,16 @@ discard block |
||
4665 | 5260 | !isset( $duration['day'] ) && |
4666 | 5261 | !isset( $duration['hour'] ) && |
4667 | 5262 | !isset( $duration['min'] ) && |
4668 | - !isset( $duration['sec'] )) |
|
4669 | - return; |
|
5263 | + !isset( $duration['sec'] )) { |
|
5264 | + return; |
|
5265 | + } |
|
4670 | 5266 | $output = 'P'; |
4671 | - if( isset( $duration['week'] ) && ( 0 < $duration['week'] )) |
|
4672 | - $output .= $duration['week'].'W'; |
|
4673 | - else { |
|
4674 | - if( isset($duration['day'] ) && ( 0 < $duration['day'] )) |
|
4675 | - $output .= $duration['day'].'D'; |
|
5267 | + if( isset( $duration['week'] ) && ( 0 < $duration['week'] )) { |
|
5268 | + $output .= $duration['week'].'W'; |
|
5269 | + } else { |
|
5270 | + if( isset($duration['day'] ) && ( 0 < $duration['day'] )) { |
|
5271 | + $output .= $duration['day'].'D'; |
|
5272 | + } |
|
4676 | 5273 | if(( isset( $duration['hour']) && ( 0 < $duration['hour'] )) || |
4677 | 5274 | ( isset( $duration['min']) && ( 0 < $duration['min'] )) || |
4678 | 5275 | ( isset( $duration['sec']) && ( 0 < $duration['sec'] ))) { |
@@ -4697,7 +5294,9 @@ discard block |
||
4697 | 5294 | $output = null; |
4698 | 5295 | foreach( $recurdata as $therule ) { |
4699 | 5296 | if( empty( $therule['value'] )) { |
4700 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $recurlabel ); |
|
5297 | + if( $this->getConfig( 'allowEmpty' )) { |
|
5298 | + $output .= $this->_createElement( $recurlabel ); |
|
5299 | + } |
|
4701 | 5300 | continue; |
4702 | 5301 | } |
4703 | 5302 | $attributes = ( isset( $therule['params'] )) ? $this->_createParams( $therule['params'] ) : null; |
@@ -4742,19 +5341,19 @@ discard block |
||
4742 | 5341 | if( is_array( $valuePart )) { |
4743 | 5342 | $content2 .= ( $bydaycnt ) ? ',' : null; |
4744 | 5343 | foreach( $valuePart as $vix2 => $valuePart2 ) { |
4745 | - if( 'DAY' != strtoupper( $vix2 )) |
|
4746 | - $content21 .= $valuePart2; |
|
4747 | - else |
|
4748 | - $content22 .= $valuePart2; |
|
5344 | + if( 'DAY' != strtoupper( $vix2 )) { |
|
5345 | + $content21 .= $valuePart2; |
|
5346 | + } else { |
|
5347 | + $content22 .= $valuePart2; |
|
5348 | + } |
|
4749 | 5349 | } |
4750 | 5350 | $content2 .= $content21.$content22; |
4751 | 5351 | $bydaycnt++; |
4752 | - } |
|
4753 | - else { |
|
5352 | + } else { |
|
4754 | 5353 | $content2 .= ( $bydaycnt ) ? ',' : null; |
4755 | - if( 'DAY' != strtoupper( $vix )) |
|
4756 | - $content21 .= $valuePart; |
|
4757 | - else { |
|
5354 | + if( 'DAY' != strtoupper( $vix )) { |
|
5355 | + $content21 .= $valuePart; |
|
5356 | + } else { |
|
4758 | 5357 | $content22 .= $valuePart; |
4759 | 5358 | $bydaycnt++; |
4760 | 5359 | } |
@@ -4798,24 +5397,32 @@ discard block |
||
4798 | 5397 | * @return bool |
4799 | 5398 | */ |
4800 | 5399 | function _isArrayDate( $input ) { |
4801 | - if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 )))) |
|
4802 | - return FALSE; |
|
4803 | - if( 7 == count( $input )) |
|
4804 | - return TRUE; |
|
4805 | - if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) |
|
4806 | - return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
4807 | - if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] )) |
|
4808 | - return FALSE; |
|
4809 | - if( in_array( 0, $input )) |
|
4810 | - return FALSE; |
|
4811 | - if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] )) |
|
4812 | - return FALSE; |
|
5400 | + if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 )))) { |
|
5401 | + return FALSE; |
|
5402 | + } |
|
5403 | + if( 7 == count( $input )) { |
|
5404 | + return TRUE; |
|
5405 | + } |
|
5406 | + if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) { |
|
5407 | + return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
5408 | + } |
|
5409 | + if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] )) { |
|
5410 | + return FALSE; |
|
5411 | + } |
|
5412 | + if( in_array( 0, $input )) { |
|
5413 | + return FALSE; |
|
5414 | + } |
|
5415 | + if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] )) { |
|
5416 | + return FALSE; |
|
5417 | + } |
|
4813 | 5418 | if(( isset( $input[0] ) && isset( $input[1] ) && isset( $input[2] )) && |
4814 | - checkdate( (int) $input[1], (int) $input[2], (int) $input[0] )) |
|
4815 | - return TRUE; |
|
5419 | + checkdate( (int) $input[1], (int) $input[2], (int) $input[0] )) { |
|
5420 | + return TRUE; |
|
5421 | + } |
|
4816 | 5422 | $input = $this->_date_time_string( $input[1].'/'.$input[2].'/'.$input[0], 3 ); // m - d - Y |
4817 | - if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) |
|
4818 | - return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
5423 | + if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) { |
|
5424 | + return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
5425 | + } |
|
4819 | 5426 | return FALSE; |
4820 | 5427 | } |
4821 | 5428 | /** |
@@ -4839,16 +5446,17 @@ discard block |
||
4839 | 5446 | */ |
4840 | 5447 | function _isOffset( $input ) { |
4841 | 5448 | $input = trim( (string) $input ); |
4842 | - if( 'Z' == substr( $input, -1 )) |
|
4843 | - return TRUE; |
|
4844 | - elseif(( 5 <= strlen( $input )) && |
|
5449 | + if( 'Z' == substr( $input, -1 )) { |
|
5450 | + return TRUE; |
|
5451 | + } elseif(( 5 <= strlen( $input )) && |
|
4845 | 5452 | ( in_array( substr( $input, -5, 1 ), array( '+', '-' ))) && |
4846 | - ( '0000' < substr( $input, -4 )) && ( '9999' >= substr( $input, -4 ))) |
|
4847 | - return TRUE; |
|
4848 | - elseif(( 7 <= strlen( $input )) && |
|
5453 | + ( '0000' < substr( $input, -4 )) && ( '9999' >= substr( $input, -4 ))) { |
|
5454 | + return TRUE; |
|
5455 | + } elseif(( 7 <= strlen( $input )) && |
|
4849 | 5456 | ( in_array( substr( $input, -7, 1 ), array( '+', '-' ))) && |
4850 | - ( '000000' < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 ))) |
|
4851 | - return TRUE; |
|
5457 | + ( '000000' < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 ))) { |
|
5458 | + return TRUE; |
|
5459 | + } |
|
4852 | 5460 | return FALSE; |
4853 | 5461 | |
4854 | 5462 | } |
@@ -4861,14 +5469,29 @@ discard block |
||
4861 | 5469 | * @return bool |
4862 | 5470 | */ |
4863 | 5471 | function _notExistProp( $propName ) { |
4864 | - if( empty( $propName )) return FALSE; // when deleting x-prop, an empty propName may be used=allowed |
|
5472 | + if( empty( $propName )) { |
|
5473 | + return FALSE; |
|
5474 | + } |
|
5475 | + // when deleting x-prop, an empty propName may be used=allowed |
|
4865 | 5476 | $propName = strtolower( $propName ); |
4866 | - if( 'last-modified' == $propName ) { if( !isset( $this->lastmodified )) return TRUE; } |
|
4867 | - elseif( 'percent-complete' == $propName ) { if( !isset( $this->percentcomplete )) return TRUE; } |
|
4868 | - elseif( 'recurrence-id' == $propName ) { if( !isset( $this->recurrenceid )) return TRUE; } |
|
4869 | - elseif( 'related-to' == $propName ) { if( !isset( $this->relatedto )) return TRUE; } |
|
4870 | - elseif( 'request-status' == $propName ) { if( !isset( $this->requeststatus )) return TRUE; } |
|
4871 | - elseif(( 'x-' != substr($propName,0,2)) && !isset( $this->$propName )) return TRUE; |
|
5477 | + if( 'last-modified' == $propName ) { if( !isset( $this->lastmodified )) { |
|
5478 | + return TRUE; |
|
5479 | + } |
|
5480 | + } elseif( 'percent-complete' == $propName ) { if( !isset( $this->percentcomplete )) { |
|
5481 | + return TRUE; |
|
5482 | + } |
|
5483 | + } elseif( 'recurrence-id' == $propName ) { if( !isset( $this->recurrenceid )) { |
|
5484 | + return TRUE; |
|
5485 | + } |
|
5486 | + } elseif( 'related-to' == $propName ) { if( !isset( $this->relatedto )) { |
|
5487 | + return TRUE; |
|
5488 | + } |
|
5489 | + } elseif( 'request-status' == $propName ) { if( !isset( $this->requeststatus )) { |
|
5490 | + return TRUE; |
|
5491 | + } |
|
5492 | + } elseif(( 'x-' != substr($propName,0,2)) && !isset( $this->$propName )) { |
|
5493 | + return TRUE; |
|
5494 | + } |
|
4872 | 5495 | return FALSE; |
4873 | 5496 | } |
4874 | 5497 | /** |
@@ -4887,7 +5510,9 @@ discard block |
||
4887 | 5510 | * @todo BYHOUR, BYMINUTE, BYSECOND, ev. BYSETPOS due to ambiguity, WEEKLY at year end/start |
4888 | 5511 | */ |
4889 | 5512 | function _recur2date( & $result, $recur, $wdate, $startdate, $enddate=FALSE ) { |
4890 | - foreach( $wdate as $k => $v ) if( ctype_digit( $v )) $wdate[$k] = (int) $v; |
|
5513 | + foreach( $wdate as $k => $v ) { |
|
5514 | + if( ctype_digit( $v )) $wdate[$k] = (int) $v; |
|
5515 | + } |
|
4891 | 5516 | $wdatets = $this->_date2timestamp( $wdate ); |
4892 | 5517 | $startdatets = $this->_date2timestamp( $startdate ); |
4893 | 5518 | if( !$enddate ) { |
@@ -4896,43 +5521,54 @@ discard block |
||
4896 | 5521 | // echo "recur __in_ ".implode('-',$startdate)." period start ".implode('-',$wdate)." period end ".implode('-',$enddate)."<br />\n";print_r($recur);echo "<br />\n";//test### |
4897 | 5522 | } |
4898 | 5523 | $endDatets = $this->_date2timestamp( $enddate ); // fix break |
4899 | - if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] )) |
|
4900 | - $recur['UNTIL'] = $enddate; // create break |
|
5524 | + if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] )) { |
|
5525 | + $recur['UNTIL'] = $enddate; |
|
5526 | + } |
|
5527 | + // create break |
|
4901 | 5528 | if( isset( $recur['UNTIL'] )) { |
4902 | 5529 | $tdatets = $this->_date2timestamp( $recur['UNTIL'] ); |
4903 | 5530 | if( $endDatets > $tdatets ) { |
4904 | 5531 | $endDatets = $tdatets; // emergency break |
4905 | 5532 | $enddate = $this->_timestamp2date( $endDatets, 6 ); |
5533 | + } else { |
|
5534 | + $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 ); |
|
4906 | 5535 | } |
4907 | - else |
|
4908 | - $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 ); |
|
4909 | 5536 | } |
4910 | 5537 | if( $wdatets > $endDatets ) { |
4911 | 5538 | //echo "recur out of date ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test |
4912 | 5539 | return array(); // nothing to do.. . |
4913 | 5540 | } |
4914 | - if( !isset( $recur['FREQ'] )) // "MUST be specified.. ." |
|
4915 | - $recur['FREQ'] = 'DAILY'; // ?? |
|
5541 | + if( !isset( $recur['FREQ'] )) { |
|
5542 | + // "MUST be specified.. ." |
|
5543 | + $recur['FREQ'] = 'DAILY'; |
|
5544 | + } |
|
5545 | + // ?? |
|
4916 | 5546 | $wkst = ( isset( $recur['WKST'] ) && ( 'SU' == $recur['WKST'] )) ? 24*60*60 : 0; // ?? |
4917 | - if( !isset( $recur['INTERVAL'] )) |
|
4918 | - $recur['INTERVAL'] = 1; |
|
5547 | + if( !isset( $recur['INTERVAL'] )) { |
|
5548 | + $recur['INTERVAL'] = 1; |
|
5549 | + } |
|
4919 | 5550 | $countcnt = ( !isset( $recur['BYSETPOS'] )) ? 1 : 0; // DTSTART counts as the first occurrence |
4920 | 5551 | /* find out how to step up dates and set index for interval count */ |
4921 | 5552 | $step = array(); |
4922 | - if( 'YEARLY' == $recur['FREQ'] ) |
|
4923 | - $step['year'] = 1; |
|
4924 | - elseif( 'MONTHLY' == $recur['FREQ'] ) |
|
4925 | - $step['month'] = 1; |
|
4926 | - elseif( 'WEEKLY' == $recur['FREQ'] ) |
|
4927 | - $step['day'] = 7; |
|
4928 | - else |
|
4929 | - $step['day'] = 1; |
|
4930 | - if( isset( $step['year'] ) && isset( $recur['BYMONTH'] )) |
|
4931 | - $step = array( 'month' => 1 ); |
|
4932 | - if( empty( $step ) && isset( $recur['BYWEEKNO'] )) // ?? |
|
5553 | + if( 'YEARLY' == $recur['FREQ'] ) { |
|
5554 | + $step['year'] = 1; |
|
5555 | + } elseif( 'MONTHLY' == $recur['FREQ'] ) { |
|
5556 | + $step['month'] = 1; |
|
5557 | + } elseif( 'WEEKLY' == $recur['FREQ'] ) { |
|
5558 | + $step['day'] = 7; |
|
5559 | + } else { |
|
5560 | + $step['day'] = 1; |
|
5561 | + } |
|
5562 | + if( isset( $step['year'] ) && isset( $recur['BYMONTH'] )) { |
|
5563 | + $step = array( 'month' => 1 ); |
|
5564 | + } |
|
5565 | + if( empty( $step ) && isset( $recur['BYWEEKNO'] )) { |
|
5566 | + // ?? |
|
4933 | 5567 | $step = array( 'day' => 7 ); |
4934 | - if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] )) |
|
4935 | - $step = array( 'day' => 1 ); |
|
5568 | + } |
|
5569 | + if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] )) { |
|
5570 | + $step = array( 'day' => 1 ); |
|
5571 | + } |
|
4936 | 5572 | $intervalarr = array(); |
4937 | 5573 | if( 1 < $recur['INTERVAL'] ) { |
4938 | 5574 | $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst ); |
@@ -4945,11 +5581,12 @@ discard block |
||
4945 | 5581 | $bysetposMold = $wdate['month']; |
4946 | 5582 | $bysetposDold = $wdate['day']; |
4947 | 5583 | if( is_array( $recur['BYSETPOS'] )) { |
4948 | - foreach( $recur['BYSETPOS'] as $bix => $bval ) |
|
4949 | - $recur['BYSETPOS'][$bix] = (int) $bval; |
|
5584 | + foreach( $recur['BYSETPOS'] as $bix => $bval ) { |
|
5585 | + $recur['BYSETPOS'][$bix] = (int) $bval; |
|
5586 | + } |
|
5587 | + } else { |
|
5588 | + $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] ); |
|
4950 | 5589 | } |
4951 | - else |
|
4952 | - $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] ); |
|
4953 | 5590 | $this->_stepdate( $enddate, $endDatets, $step); // make sure to count whole last period |
4954 | 5591 | } |
4955 | 5592 | $this->_stepdate( $wdate, $wdatets, $step); |
@@ -4958,10 +5595,12 @@ discard block |
||
4958 | 5595 | /* MAIN LOOP */ |
4959 | 5596 | // echo "recur start ".implode('-',$wdate)." end ".implode('-',$enddate)."<br />\n";//test |
4960 | 5597 | while( TRUE ) { |
4961 | - if( isset( $endDatets ) && ( $wdatets > $endDatets )) |
|
4962 | - break; |
|
4963 | - if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) |
|
4964 | - break; |
|
5598 | + if( isset( $endDatets ) && ( $wdatets > $endDatets )) { |
|
5599 | + break; |
|
5600 | + } |
|
5601 | + if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) { |
|
5602 | + break; |
|
5603 | + } |
|
4965 | 5604 | if( $year_old != $wdate['year'] ) { |
4966 | 5605 | $year_old = $wdate['year']; |
4967 | 5606 | $daycnts = array(); |
@@ -4970,8 +5609,9 @@ discard block |
||
4970 | 5609 | for( $m = 1; $m <= 12; $m++ ) { // count up and update up-counters |
4971 | 5610 | $daycnts[$m] = array(); |
4972 | 5611 | $weekdaycnt = array(); |
4973 | - foreach( $daynames as $dn ) |
|
4974 | - $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
|
5612 | + foreach( $daynames as $dn ) { |
|
5613 | + $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
|
5614 | + } |
|
4975 | 5615 | $mcnt = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] )); |
4976 | 5616 | for( $d = 1; $d <= $mcnt; $d++ ) { |
4977 | 5617 | $daycnts[$m][$d] = array(); |
@@ -4988,8 +5628,9 @@ discard block |
||
4988 | 5628 | $yeardaycnt[$day]++; |
4989 | 5629 | $daycnts[$m][$d]['yeardayno_up'] = $yeardaycnt[$day]; |
4990 | 5630 | } |
4991 | - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) |
|
4992 | - $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year'])); |
|
5631 | + if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) { |
|
5632 | + $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year'])); |
|
5633 | + } |
|
4993 | 5634 | } |
4994 | 5635 | } |
4995 | 5636 | $daycnt = 0; |
@@ -4997,9 +5638,9 @@ discard block |
||
4997 | 5638 | if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) { |
4998 | 5639 | $weekno = null; |
4999 | 5640 | for( $d=31; $d > 25; $d-- ) { // get last weekno for year |
5000 | - if( !$weekno ) |
|
5001 | - $weekno = $daycnts[12][$d]['weekno_up']; |
|
5002 | - elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) { |
|
5641 | + if( !$weekno ) { |
|
5642 | + $weekno = $daycnts[12][$d]['weekno_up']; |
|
5643 | + } elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) { |
|
5003 | 5644 | $weekno = $daycnts[12][$d]['weekno_up']; |
5004 | 5645 | break; |
5005 | 5646 | } |
@@ -5007,8 +5648,9 @@ discard block |
||
5007 | 5648 | } |
5008 | 5649 | for( $m = 12; $m > 0; $m-- ) { // count down and update down-counters |
5009 | 5650 | $weekdaycnt = array(); |
5010 | - foreach( $daynames as $dn ) |
|
5011 | - $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
|
5651 | + foreach( $daynames as $dn ) { |
|
5652 | + $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
|
5653 | + } |
|
5012 | 5654 | $monthcnt = 0; |
5013 | 5655 | $mcnt = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] )); |
5014 | 5656 | for( $d = $mcnt; $d > 0; $d-- ) { |
@@ -5027,8 +5669,9 @@ discard block |
||
5027 | 5669 | $yeardaycnt[$day] -= 1; |
5028 | 5670 | $daycnts[$m][$d]['yeardayno_down'] = $yeardaycnt[$day]; |
5029 | 5671 | } |
5030 | - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) |
|
5031 | - $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1); |
|
5672 | + if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) { |
|
5673 | + $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1); |
|
5674 | + } |
|
5032 | 5675 | } |
5033 | 5676 | } |
5034 | 5677 | } |
@@ -5039,36 +5682,42 @@ discard block |
||
5039 | 5682 | /* check interval */ |
5040 | 5683 | $currentKey = array_keys( $intervalarr ); |
5041 | 5684 | $currentKey = end( $currentKey ); // get last index |
5042 | - if( $currentKey != $intervalix ) |
|
5043 | - $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 )); |
|
5685 | + if( $currentKey != $intervalix ) { |
|
5686 | + $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 )); |
|
5687 | + } |
|
5044 | 5688 | if(( $recur['INTERVAL'] != $intervalarr[$intervalix] ) && |
5045 | 5689 | ( 0 != $intervalarr[$intervalix] )) { |
5046 | 5690 | /* step up date */ |
5047 | 5691 | //echo "skip: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test |
5048 | 5692 | $this->_stepdate( $wdate, $wdatets, $step); |
5049 | 5693 | continue; |
5050 | - } |
|
5051 | - else // continue within the selected interval |
|
5694 | + } else { |
|
5695 | + // continue within the selected interval |
|
5052 | 5696 | $intervalarr[$intervalix] = 0; |
5697 | + } |
|
5053 | 5698 | //echo "cont: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test |
5054 | 5699 | } |
5055 | 5700 | $updateOK = TRUE; |
5056 | - if( $updateOK && isset( $recur['BYMONTH'] )) |
|
5057 | - $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH'] |
|
5701 | + if( $updateOK && isset( $recur['BYMONTH'] )) { |
|
5702 | + $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH'] |
|
5058 | 5703 | , $wdate['month'] |
5059 | 5704 | ,($wdate['month'] - 13)); |
5060 | - if( $updateOK && isset( $recur['BYWEEKNO'] )) |
|
5061 | - $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO'] |
|
5705 | + } |
|
5706 | + if( $updateOK && isset( $recur['BYWEEKNO'] )) { |
|
5707 | + $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO'] |
|
5062 | 5708 | , $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] |
5063 | 5709 | , $daycnts[$wdate['month']][$wdate['day']]['weekno_down'] ); |
5064 | - if( $updateOK && isset( $recur['BYYEARDAY'] )) |
|
5065 | - $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY'] |
|
5710 | + } |
|
5711 | + if( $updateOK && isset( $recur['BYYEARDAY'] )) { |
|
5712 | + $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY'] |
|
5066 | 5713 | , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_up'] |
5067 | 5714 | , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down'] ); |
5068 | - if( $updateOK && isset( $recur['BYMONTHDAY'] )) |
|
5069 | - $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY'] |
|
5715 | + } |
|
5716 | + if( $updateOK && isset( $recur['BYMONTHDAY'] )) { |
|
5717 | + $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY'] |
|
5070 | 5718 | , $wdate['day'] |
5071 | 5719 | , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down'] ); |
5720 | + } |
|
5072 | 5721 | //echo "efter BYMONTHDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n";//test### |
5073 | 5722 | if( $updateOK && isset( $recur['BYDAY'] )) { |
5074 | 5723 | $updateOK = FALSE; |
@@ -5076,42 +5725,45 @@ discard block |
||
5076 | 5725 | $d = $wdate['day']; |
5077 | 5726 | if( isset( $recur['BYDAY']['DAY'] )) { // single day, opt with year/month day order no |
5078 | 5727 | $daynoexists = $daynosw = $daynamesw = FALSE; |
5079 | - if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] ) |
|
5080 | - $daynamesw = TRUE; |
|
5728 | + if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] ) { |
|
5729 | + $daynamesw = TRUE; |
|
5730 | + } |
|
5081 | 5731 | if( isset( $recur['BYDAY'][0] )) { |
5082 | 5732 | $daynoexists = TRUE; |
5083 | - if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] )) |
|
5084 | - $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5733 | + if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] )) { |
|
5734 | + $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5085 | 5735 | , $daycnts[$m][$d]['monthdayno_up'] |
5086 | 5736 | , $daycnts[$m][$d]['monthdayno_down'] ); |
5087 | - elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) |
|
5088 | - $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5737 | + } elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) { |
|
5738 | + $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5089 | 5739 | , $daycnts[$m][$d]['yeardayno_up'] |
5090 | 5740 | , $daycnts[$m][$d]['yeardayno_down'] ); |
5741 | + } |
|
5091 | 5742 | } |
5092 | 5743 | if(( $daynoexists && $daynosw && $daynamesw ) || |
5093 | 5744 | ( !$daynoexists && !$daynosw && $daynamesw )) { |
5094 | 5745 | $updateOK = TRUE; |
5095 | 5746 | } |
5096 | 5747 | //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ### |
5097 | - } |
|
5098 | - else { |
|
5748 | + } else { |
|
5099 | 5749 | foreach( $recur['BYDAY'] as $bydayvalue ) { |
5100 | 5750 | $daynoexists = $daynosw = $daynamesw = FALSE; |
5101 | 5751 | if( isset( $bydayvalue['DAY'] ) && |
5102 | - ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] )) |
|
5103 | - $daynamesw = TRUE; |
|
5752 | + ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] )) { |
|
5753 | + $daynamesw = TRUE; |
|
5754 | + } |
|
5104 | 5755 | if( isset( $bydayvalue[0] )) { |
5105 | 5756 | $daynoexists = TRUE; |
5106 | 5757 | if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || |
5107 | - isset( $recur['BYMONTH'] )) |
|
5108 | - $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5758 | + isset( $recur['BYMONTH'] )) { |
|
5759 | + $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5109 | 5760 | , $daycnts[$m][$d]['monthdayno_up'] |
5110 | 5761 | , $daycnts[$m][$d]['monthdayno_down'] ); |
5111 | - elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) |
|
5112 | - $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5762 | + } elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) { |
|
5763 | + $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5113 | 5764 | , $daycnts[$m][$d]['yeardayno_up'] |
5114 | 5765 | , $daycnts[$m][$d]['yeardayno_down'] ); |
5766 | + } |
|
5115 | 5767 | } |
5116 | 5768 | //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ### |
5117 | 5769 | if(( $daynoexists && $daynosw && $daynamesw ) || |
@@ -5128,12 +5780,12 @@ discard block |
||
5128 | 5780 | if( isset( $recur['BYSETPOS'] ) && |
5129 | 5781 | ( in_array( $recur['FREQ'], array( 'YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY' )))) { |
5130 | 5782 | if( isset( $recur['WEEKLY'] )) { |
5131 | - if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] ) |
|
5132 | - $bysetposw1[] = $wdatets; |
|
5133 | - else |
|
5134 | - $bysetposw2[] = $wdatets; |
|
5135 | - } |
|
5136 | - else { |
|
5783 | + if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] ) { |
|
5784 | + $bysetposw1[] = $wdatets; |
|
5785 | + } else { |
|
5786 | + $bysetposw2[] = $wdatets; |
|
5787 | + } |
|
5788 | + } else { |
|
5137 | 5789 | if(( isset( $recur['FREQ'] ) && ( 'YEARLY' == $recur['FREQ'] ) && |
5138 | 5790 | ( $bysetposYold == $wdate['year'] )) || |
5139 | 5791 | ( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] ) && |
@@ -5142,13 +5794,13 @@ discard block |
||
5142 | 5794 | ( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] ) && |
5143 | 5795 | (( $bysetposYold == $wdate['year'] ) && |
5144 | 5796 | ( $bysetposMold == $wdate['month']) && |
5145 | - ( $bysetposDold == $wdate['sday'] )))) |
|
5146 | - $bysetposymd1[] = $wdatets; |
|
5147 | - else |
|
5148 | - $bysetposymd2[] = $wdatets; |
|
5797 | + ( $bysetposDold == $wdate['sday'] )))) { |
|
5798 | + $bysetposymd1[] = $wdatets; |
|
5799 | + } else { |
|
5800 | + $bysetposymd2[] = $wdatets; |
|
5801 | + } |
|
5149 | 5802 | } |
5150 | - } |
|
5151 | - else { |
|
5803 | + } else { |
|
5152 | 5804 | /* update result array if BYSETPOS is set */ |
5153 | 5805 | $countcnt++; |
5154 | 5806 | if( $startdatets <= $wdatets ) { // only output within period |
@@ -5168,21 +5820,18 @@ discard block |
||
5168 | 5820 | ( $bysetposYold != $wdate['year'] )) { |
5169 | 5821 | $bysetpos = TRUE; |
5170 | 5822 | $bysetposYold = $wdate['year']; |
5171 | - } |
|
5172 | - elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] && |
|
5823 | + } elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] && |
|
5173 | 5824 | (( $bysetposYold != $wdate['year'] ) || ( $bysetposMold != $wdate['month'] )))) { |
5174 | 5825 | $bysetpos = TRUE; |
5175 | 5826 | $bysetposYold = $wdate['year']; |
5176 | 5827 | $bysetposMold = $wdate['month']; |
5177 | - } |
|
5178 | - elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY' == $recur['FREQ'] )) { |
|
5828 | + } elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY' == $recur['FREQ'] )) { |
|
5179 | 5829 | $weekno = (int) date( 'W', mktime( 0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year'])); |
5180 | 5830 | if( $bysetposWold != $weekno ) { |
5181 | 5831 | $bysetposWold = $weekno; |
5182 | 5832 | $bysetpos = TRUE; |
5183 | 5833 | } |
5184 | - } |
|
5185 | - elseif( isset( $recur['FREQ'] ) && ( 'DAILY' == $recur['FREQ'] ) && |
|
5834 | + } elseif( isset( $recur['FREQ'] ) && ( 'DAILY' == $recur['FREQ'] ) && |
|
5186 | 5835 | (( $bysetposYold != $wdate['year'] ) || |
5187 | 5836 | ( $bysetposMold != $wdate['month'] ) || |
5188 | 5837 | ( $bysetposDold != $wdate['sday'] ))) { |
@@ -5195,14 +5844,15 @@ discard block |
||
5195 | 5844 | if( isset( $recur['BYWEEKNO'] )) { |
5196 | 5845 | $bysetposarr1 = & $bysetposw1; |
5197 | 5846 | $bysetposarr2 = & $bysetposw2; |
5198 | - } |
|
5199 | - else { |
|
5847 | + } else { |
|
5200 | 5848 | $bysetposarr1 = & $bysetposymd1; |
5201 | 5849 | $bysetposarr2 = & $bysetposymd2; |
5202 | 5850 | } |
5203 | 5851 | foreach( $recur['BYSETPOS'] as $ix ) { |
5204 | - if( 0 > $ix ) // both positive and negative BYSETPOS allowed |
|
5852 | + if( 0 > $ix ) { |
|
5853 | + // both positive and negative BYSETPOS allowed |
|
5205 | 5854 | $ix = ( count( $bysetposarr1 ) + $ix + 1); |
5855 | + } |
|
5206 | 5856 | $ix--; |
5207 | 5857 | if( isset( $bysetposarr1[$ix] )) { |
5208 | 5858 | if( $startdatets <= $bysetposarr1[$ix] ) { // only output within period |
@@ -5211,8 +5861,9 @@ discard block |
||
5211 | 5861 | } |
5212 | 5862 | $countcnt++; |
5213 | 5863 | } |
5214 | - if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) |
|
5215 | - break; |
|
5864 | + if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) { |
|
5865 | + break; |
|
5866 | + } |
|
5216 | 5867 | } |
5217 | 5868 | $bysetposarr1 = $bysetposarr2; |
5218 | 5869 | $bysetposarr2 = array(); |
@@ -5222,12 +5873,13 @@ discard block |
||
5222 | 5873 | } |
5223 | 5874 | function _recurBYcntcheck( $BYvalue, $upValue, $downValue ) { |
5224 | 5875 | if( is_array( $BYvalue ) && |
5225 | - ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue ))) |
|
5226 | - return TRUE; |
|
5227 | - elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue )) |
|
5228 | - return TRUE; |
|
5229 | - else |
|
5230 | - return FALSE; |
|
5876 | + ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue ))) { |
|
5877 | + return TRUE; |
|
5878 | + } elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue )) { |
|
5879 | + return TRUE; |
|
5880 | + } else { |
|
5881 | + return FALSE; |
|
5882 | + } |
|
5231 | 5883 | } |
5232 | 5884 | function _recurIntervalIx( $freq, $date, $wkst ) { |
5233 | 5885 | /* create interval index */ |
@@ -5259,21 +5911,27 @@ discard block |
||
5259 | 5911 | */ |
5260 | 5912 | function _setRexrule( $rexrule ) { |
5261 | 5913 | $input = array(); |
5262 | - if( empty( $rexrule )) |
|
5263 | - return $input; |
|
5914 | + if( empty( $rexrule )) { |
|
5915 | + return $input; |
|
5916 | + } |
|
5264 | 5917 | foreach( $rexrule as $rexrulelabel => $rexrulevalue ) { |
5265 | 5918 | $rexrulelabel = strtoupper( $rexrulelabel ); |
5266 | - if( 'UNTIL' != $rexrulelabel ) |
|
5267 | - $input[$rexrulelabel] = $rexrulevalue; |
|
5268 | - else { |
|
5269 | - if( $this->_isArrayTimestampDate( $rexrulevalue )) // timestamp date |
|
5919 | + if( 'UNTIL' != $rexrulelabel ) { |
|
5920 | + $input[$rexrulelabel] = $rexrulevalue; |
|
5921 | + } else { |
|
5922 | + if( $this->_isArrayTimestampDate( $rexrulevalue )) { |
|
5923 | + // timestamp date |
|
5270 | 5924 | $input[$rexrulelabel] = $this->_timestamp2date( $rexrulevalue, 6 ); |
5271 | - elseif( $this->_isArrayDate( $rexrulevalue )) // date-time |
|
5925 | + } elseif( $this->_isArrayDate( $rexrulevalue )) { |
|
5926 | + // date-time |
|
5272 | 5927 | $input[$rexrulelabel] = $this->_date_time_array( $rexrulevalue, 6 ); |
5273 | - elseif( 8 <= strlen( trim( $rexrulevalue ))) // ex. 2006-08-03 10:12:18 |
|
5928 | + } elseif( 8 <= strlen( trim( $rexrulevalue ))) { |
|
5929 | + // ex. 2006-08-03 10:12:18 |
|
5274 | 5930 | $input[$rexrulelabel] = $this->_date_time_string( $rexrulevalue ); |
5275 | - if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] )) |
|
5276 | - $input[$rexrulelabel]['tz'] = 'Z'; |
|
5931 | + } |
|
5932 | + if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] )) { |
|
5933 | + $input[$rexrulelabel]['tz'] = 'Z'; |
|
5934 | + } |
|
5277 | 5935 | } |
5278 | 5936 | } |
5279 | 5937 | return $input; |
@@ -5297,7 +5955,9 @@ discard block |
||
5297 | 5955 | $input = $parno = null; |
5298 | 5956 | $localtime = (( 'dtstart' == $caller ) && in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE; |
5299 | 5957 | if( $this->_isArrayDate( $year )) { |
5300 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5958 | + if( $localtime ) { |
|
5959 | + unset ( $month['VALUE'], $month['TZID'] ); |
|
5960 | + } |
|
5301 | 5961 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
5302 | 5962 | if( isset( $input['params']['TZID'] )) { |
5303 | 5963 | $input['params']['VALUE'] = 'DATE-TIME'; |
@@ -5307,9 +5967,10 @@ discard block |
||
5307 | 5967 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval ); |
5308 | 5968 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, count( $year ), $parno ); |
5309 | 5969 | $input['value'] = $this->_date_time_array( $year, $parno ); |
5310 | - } |
|
5311 | - elseif( $this->_isArrayTimestampDate( $year )) { |
|
5312 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5970 | + } elseif( $this->_isArrayTimestampDate( $year )) { |
|
5971 | + if( $localtime ) { |
|
5972 | + unset ( $month['VALUE'], $month['TZID'] ); |
|
5973 | + } |
|
5313 | 5974 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
5314 | 5975 | if( isset( $input['params']['TZID'] )) { |
5315 | 5976 | $input['params']['VALUE'] = 'DATE-TIME'; |
@@ -5319,9 +5980,10 @@ discard block |
||
5319 | 5980 | $hitval = ( isset( $year['tz'] )) ? 7 : 6; |
5320 | 5981 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno ); |
5321 | 5982 | $input['value'] = $this->_timestamp2date( $year, $parno ); |
5322 | - } |
|
5323 | - elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
5324 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5983 | + } elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
5984 | + if( $localtime ) { |
|
5985 | + unset ( $month['VALUE'], $month['TZID'] ); |
|
5986 | + } |
|
5325 | 5987 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
5326 | 5988 | if( isset( $input['params']['TZID'] )) { |
5327 | 5989 | $input['params']['VALUE'] = 'DATE-TIME'; |
@@ -5330,17 +5992,16 @@ discard block |
||
5330 | 5992 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7, $parno ); |
5331 | 5993 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, $parno, $parno ); |
5332 | 5994 | $input['value'] = $this->_date_time_string( $year, $parno ); |
5333 | - } |
|
5334 | - else { |
|
5995 | + } else { |
|
5335 | 5996 | if( is_array( $params )) { |
5336 | - if( $localtime ) unset ( $params['VALUE'], $params['TZID'] ); |
|
5997 | + if( $localtime ) { |
|
5998 | + unset ( $params['VALUE'], $params['TZID'] ); |
|
5999 | + } |
|
5337 | 6000 | $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )); |
5338 | - } |
|
5339 | - elseif( is_array( $tz )) { |
|
6001 | + } elseif( is_array( $tz )) { |
|
5340 | 6002 | $input['params'] = $this->_setParams( $tz, array( 'VALUE' => 'DATE-TIME' )); |
5341 | 6003 | $tz = FALSE; |
5342 | - } |
|
5343 | - elseif( is_array( $hour )) { |
|
6004 | + } elseif( is_array( $hour )) { |
|
5344 | 6005 | $input['params'] = $this->_setParams( $hour, array( 'VALUE' => 'DATE-TIME' )); |
5345 | 6006 | $hour = $min = $sec = $tz = FALSE; |
5346 | 6007 | } |
@@ -5356,23 +6017,28 @@ discard block |
||
5356 | 6017 | $input['value']['hour'] = ( $hour ) ? $hour : '0'; |
5357 | 6018 | $input['value']['min'] = ( $min ) ? $min : '0'; |
5358 | 6019 | $input['value']['sec'] = ( $sec ) ? $sec : '0'; |
5359 | - if( !empty( $tz )) |
|
5360 | - $input['value']['tz'] = $tz; |
|
6020 | + if( !empty( $tz )) { |
|
6021 | + $input['value']['tz'] = $tz; |
|
6022 | + } |
|
5361 | 6023 | } |
5362 | 6024 | } |
5363 | 6025 | if( 3 == $parno ) { |
5364 | 6026 | $input['params']['VALUE'] = 'DATE'; |
5365 | 6027 | unset( $input['value']['tz'] ); |
5366 | 6028 | unset( $input['params']['TZID'] ); |
6029 | + } elseif( isset( $input['params']['TZID'] )) { |
|
6030 | + unset( $input['value']['tz'] ); |
|
6031 | + } |
|
6032 | + if( $localtime ) { |
|
6033 | + unset( $input['value']['tz'], $input['params']['TZID'] ); |
|
6034 | + } |
|
6035 | + if( isset( $input['value']['tz'] )) { |
|
6036 | + $input['value']['tz'] = (string) $input['value']['tz']; |
|
5367 | 6037 | } |
5368 | - elseif( isset( $input['params']['TZID'] )) |
|
5369 | - unset( $input['value']['tz'] ); |
|
5370 | - if( $localtime ) unset( $input['value']['tz'], $input['params']['TZID'] ); |
|
5371 | - if( isset( $input['value']['tz'] )) |
|
5372 | - $input['value']['tz'] = (string) $input['value']['tz']; |
|
5373 | 6038 | if( !empty( $input['value']['tz'] ) && ( 'Z' != $input['value']['tz'] ) && |
5374 | - ( !$this->_isOffset( $input['value']['tz'] ))) |
|
5375 | - $input['params']['TZID'] = $input['value']['tz']; |
|
6039 | + ( !$this->_isOffset( $input['value']['tz'] ))) { |
|
6040 | + $input['params']['TZID'] = $input['value']['tz']; |
|
6041 | + } |
|
5376 | 6042 | return $input; |
5377 | 6043 | } |
5378 | 6044 | /** |
@@ -5394,16 +6060,13 @@ discard block |
||
5394 | 6060 | if( $this->_isArrayDate( $year )) { |
5395 | 6061 | $input['value'] = $this->_date_time_array( $year, 7 ); |
5396 | 6062 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
5397 | - } |
|
5398 | - elseif( $this->_isArrayTimestampDate( $year )) { |
|
6063 | + } elseif( $this->_isArrayTimestampDate( $year )) { |
|
5399 | 6064 | $input['value'] = $this->_timestamp2date( $year, 7 ); |
5400 | 6065 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
5401 | - } |
|
5402 | - elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
6066 | + } elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
5403 | 6067 | $input['value'] = $this->_date_time_string( $year, 7 ); |
5404 | 6068 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
5405 | - } |
|
5406 | - else { |
|
6069 | + } else { |
|
5407 | 6070 | $input['value'] = array( 'year' => $year |
5408 | 6071 | , 'month' => $month |
5409 | 6072 | , 'day' => $day |
@@ -5413,14 +6076,18 @@ discard block |
||
5413 | 6076 | $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )); |
5414 | 6077 | } |
5415 | 6078 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7 ); // remove default |
5416 | - if( !isset( $input['value']['hour'] )) |
|
5417 | - $input['value']['hour'] = 0; |
|
5418 | - if( !isset( $input['value']['min'] )) |
|
5419 | - $input['value']['min'] = 0; |
|
5420 | - if( !isset( $input['value']['sec'] )) |
|
5421 | - $input['value']['sec'] = 0; |
|
5422 | - if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] )) |
|
5423 | - $input['value']['tz'] = 'Z'; |
|
6079 | + if( !isset( $input['value']['hour'] )) { |
|
6080 | + $input['value']['hour'] = 0; |
|
6081 | + } |
|
6082 | + if( !isset( $input['value']['min'] )) { |
|
6083 | + $input['value']['min'] = 0; |
|
6084 | + } |
|
6085 | + if( !isset( $input['value']['sec'] )) { |
|
6086 | + $input['value']['sec'] = 0; |
|
6087 | + } |
|
6088 | + if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] )) { |
|
6089 | + $input['value']['tz'] = 'Z'; |
|
6090 | + } |
|
5424 | 6091 | return $input; |
5425 | 6092 | } |
5426 | 6093 | /** |
@@ -5436,15 +6103,17 @@ discard block |
||
5436 | 6103 | * @return void |
5437 | 6104 | */ |
5438 | 6105 | function _setMval( & $valArr, $value, $params=FALSE, $defaults=FALSE, $index=FALSE ) { |
5439 | - if( !is_array( $valArr )) $valArr = array(); |
|
5440 | - if( $index ) |
|
5441 | - $index = $index - 1; |
|
5442 | - elseif( 0 < count( $valArr )) { |
|
6106 | + if( !is_array( $valArr )) { |
|
6107 | + $valArr = array(); |
|
6108 | + } |
|
6109 | + if( $index ) { |
|
6110 | + $index = $index - 1; |
|
6111 | + } elseif( 0 < count( $valArr )) { |
|
5443 | 6112 | $index = end( array_keys( $valArr )); |
5444 | 6113 | $index += 1; |
6114 | + } else { |
|
6115 | + $index = 0; |
|
5445 | 6116 | } |
5446 | - else |
|
5447 | - $index = 0; |
|
5448 | 6117 | $valArr[$index] = array( 'value' => $value, 'params' => $this->_setParams( $params, $defaults )); |
5449 | 6118 | ksort( $valArr ); |
5450 | 6119 | } |
@@ -5460,27 +6129,31 @@ discard block |
||
5460 | 6129 | * @return array |
5461 | 6130 | */ |
5462 | 6131 | function _setParams( $params, $defaults=FALSE ) { |
5463 | - if( !is_array( $params)) |
|
5464 | - $params = array(); |
|
6132 | + if( !is_array( $params)) { |
|
6133 | + $params = array(); |
|
6134 | + } |
|
5465 | 6135 | $input = array(); |
5466 | 6136 | foreach( $params as $paramKey => $paramValue ) { |
5467 | 6137 | if( is_array( $paramValue )) { |
5468 | 6138 | foreach( $paramValue as $pkey => $pValue ) { |
5469 | - if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 ))) |
|
5470 | - $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 )); |
|
6139 | + if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 ))) { |
|
6140 | + $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 )); |
|
6141 | + } |
|
5471 | 6142 | } |
6143 | + } elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 ))) { |
|
6144 | + $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 )); |
|
6145 | + } |
|
6146 | + if( 'VALUE' == strtoupper( $paramKey )) { |
|
6147 | + $input['VALUE'] = strtoupper( $paramValue ); |
|
6148 | + } else { |
|
6149 | + $input[strtoupper( $paramKey )] = $paramValue; |
|
5472 | 6150 | } |
5473 | - elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 ))) |
|
5474 | - $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 )); |
|
5475 | - if( 'VALUE' == strtoupper( $paramKey )) |
|
5476 | - $input['VALUE'] = strtoupper( $paramValue ); |
|
5477 | - else |
|
5478 | - $input[strtoupper( $paramKey )] = $paramValue; |
|
5479 | 6151 | } |
5480 | 6152 | if( is_array( $defaults )) { |
5481 | 6153 | foreach( $defaults as $paramKey => $paramValue ) { |
5482 | - if( !isset( $input[$paramKey] )) |
|
5483 | - $input[$paramKey] = $paramValue; |
|
6154 | + if( !isset( $input[$paramKey] )) { |
|
6155 | + $input[$paramKey] = $paramValue; |
|
6156 | + } |
|
5484 | 6157 | } |
5485 | 6158 | } |
5486 | 6159 | return (0 < count( $input )) ? $input : null; |
@@ -5496,13 +6169,15 @@ discard block |
||
5496 | 6169 | * @return void |
5497 | 6170 | */ |
5498 | 6171 | function _stepdate( &$date, &$timestamp, $step=array( 'day' => 1 )) { |
5499 | - foreach( $step as $stepix => $stepvalue ) |
|
5500 | - $date[$stepix] += $stepvalue; |
|
6172 | + foreach( $step as $stepix => $stepvalue ) { |
|
6173 | + $date[$stepix] += $stepvalue; |
|
6174 | + } |
|
5501 | 6175 | $timestamp = $this->_date2timestamp( $date ); |
5502 | 6176 | $date = $this->_timestamp2date( $timestamp, 6 ); |
5503 | 6177 | foreach( $date as $k => $v ) { |
5504 | - if( ctype_digit( $v )) |
|
5505 | - $date[$k] = (int) $v; |
|
6178 | + if( ctype_digit( $v )) { |
|
6179 | + $date[$k] = (int) $v; |
|
6180 | + } |
|
5506 | 6181 | } |
5507 | 6182 | } |
5508 | 6183 | /** |
@@ -5516,8 +6191,9 @@ discard block |
||
5516 | 6191 | */ |
5517 | 6192 | function _timestamp2date( $timestamp, $parno=6 ) { |
5518 | 6193 | if( is_array( $timestamp )) { |
5519 | - if(( 7 == $parno ) && !empty( $timestamp['tz'] )) |
|
5520 | - $tz = $timestamp['tz']; |
|
6194 | + if(( 7 == $parno ) && !empty( $timestamp['tz'] )) { |
|
6195 | + $tz = $timestamp['tz']; |
|
6196 | + } |
|
5521 | 6197 | $timestamp = $timestamp['timestamp']; |
5522 | 6198 | } |
5523 | 6199 | $output = array( 'year' => date( 'Y', $timestamp ) |
@@ -5527,8 +6203,9 @@ discard block |
||
5527 | 6203 | $output['hour'] = date( 'H', $timestamp ); |
5528 | 6204 | $output['min'] = date( 'i', $timestamp ); |
5529 | 6205 | $output['sec'] = date( 's', $timestamp ); |
5530 | - if( isset( $tz )) |
|
5531 | - $output['tz'] = $tz; |
|
6206 | + if( isset( $tz )) { |
|
6207 | + $output['tz'] = $tz; |
|
6208 | + } |
|
5532 | 6209 | } |
5533 | 6210 | return $output; |
5534 | 6211 | } |
@@ -5546,8 +6223,9 @@ discard block |
||
5546 | 6223 | if((( 5 != strlen( $tz )) && ( 7 != strlen( $tz ))) || |
5547 | 6224 | (( '+' != substr( $tz, 0, 1 )) && ( '-' != substr( $tz, 0, 1 ))) || |
5548 | 6225 | (( '0000' >= substr( $tz, 1, 4 )) && ( '9999' < substr( $tz, 1, 4 ))) || |
5549 | - (( 7 == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 )))) |
|
5550 | - return $offset; |
|
6226 | + (( 7 == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 )))) { |
|
6227 | + return $offset; |
|
6228 | + } |
|
5551 | 6229 | $hours2sec = (int) substr( $tz, 1, 2 ) * 3600; |
5552 | 6230 | $min2sec = (int) substr( $tz, 3, 2 ) * 60; |
5553 | 6231 | $sec = ( 7 == strlen( $tz )) ? (int) substr( $tz, -2 ) : '00'; |
@@ -5575,7 +6253,9 @@ discard block |
||
5575 | 6253 | $info = array(); |
5576 | 6254 | if( isset( $this->components )) { |
5577 | 6255 | foreach( $this->components as $cix => $component ) { |
5578 | - if( empty( $component )) continue; |
|
6256 | + if( empty( $component )) { |
|
6257 | + continue; |
|
6258 | + } |
|
5579 | 6259 | unset( $component->propix ); |
5580 | 6260 | $info[$cix]['ordno'] = $cix + 1; |
5581 | 6261 | $info[$cix]['type'] = $component->objName; |
@@ -5601,57 +6281,146 @@ discard block |
||
5601 | 6281 | case 'PROPINFO': |
5602 | 6282 | $output = array(); |
5603 | 6283 | if( !in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
5604 | - if( empty( $this->uid['value'] )) $this->_makeuid(); |
|
6284 | + if( empty( $this->uid['value'] )) { |
|
6285 | + $this->_makeuid(); |
|
6286 | + } |
|
5605 | 6287 | $output['UID'] = 1; |
5606 | 6288 | } |
5607 | - if( !empty( $this->dtstamp )) $output['DTSTAMP'] = 1; |
|
5608 | - if( !empty( $this->summary )) $output['SUMMARY'] = 1; |
|
5609 | - if( !empty( $this->description )) $output['DESCRIPTION'] = count( $this->description ); |
|
5610 | - if( !empty( $this->dtstart )) $output['DTSTART'] = 1; |
|
5611 | - if( !empty( $this->dtend )) $output['DTEND'] = 1; |
|
5612 | - if( !empty( $this->due )) $output['DUE'] = 1; |
|
5613 | - if( !empty( $this->duration )) $output['DURATION'] = 1; |
|
5614 | - if( !empty( $this->rrule )) $output['RRULE'] = count( $this->rrule ); |
|
5615 | - if( !empty( $this->rdate )) $output['RDATE'] = count( $this->rdate ); |
|
5616 | - if( !empty( $this->exdate )) $output['EXDATE'] = count( $this->exdate ); |
|
5617 | - if( !empty( $this->exrule )) $output['EXRULE'] = count( $this->exrule ); |
|
5618 | - if( !empty( $this->action )) $output['ACTION'] = 1; |
|
5619 | - if( !empty( $this->attach )) $output['ATTACH'] = count( $this->attach ); |
|
5620 | - if( !empty( $this->attendee )) $output['ATTENDEE'] = count( $this->attendee ); |
|
5621 | - if( !empty( $this->categories )) $output['CATEGORIES'] = count( $this->categories ); |
|
5622 | - if( !empty( $this->class )) $output['CLASS'] = 1; |
|
5623 | - if( !empty( $this->comment )) $output['COMMENT'] = count( $this->comment ); |
|
5624 | - if( !empty( $this->completed )) $output['COMPLETED'] = 1; |
|
5625 | - if( !empty( $this->contact )) $output['CONTACT'] = count( $this->contact ); |
|
5626 | - if( !empty( $this->created )) $output['CREATED'] = 1; |
|
5627 | - if( !empty( $this->freebusy )) $output['FREEBUSY'] = count( $this->freebusy ); |
|
5628 | - if( !empty( $this->geo )) $output['GEO'] = 1; |
|
5629 | - if( !empty( $this->lastmodified )) $output['LAST-MODIFIED'] = 1; |
|
5630 | - if( !empty( $this->location )) $output['LOCATION'] = 1; |
|
5631 | - if( !empty( $this->organizer )) $output['ORGANIZER'] = 1; |
|
5632 | - if( !empty( $this->percentcomplete )) $output['PERCENT-COMPLETE'] = 1; |
|
5633 | - if( !empty( $this->priority )) $output['PRIORITY'] = 1; |
|
5634 | - if( !empty( $this->recurrenceid )) $output['RECURRENCE-ID'] = 1; |
|
5635 | - if( !empty( $this->relatedto )) $output['RELATED-TO'] = count( $this->relatedto ); |
|
5636 | - if( !empty( $this->repeat )) $output['REPEAT'] = 1; |
|
5637 | - if( !empty( $this->requeststatus )) $output['REQUEST-STATUS'] = count( $this->requeststatus ); |
|
5638 | - if( !empty( $this->resources )) $output['RESOURCES'] = count( $this->resources ); |
|
5639 | - if( !empty( $this->sequence )) $output['SEQUENCE'] = 1; |
|
5640 | - if( !empty( $this->status )) $output['STATUS'] = 1; |
|
5641 | - if( !empty( $this->transp )) $output['TRANSP'] = 1; |
|
5642 | - if( !empty( $this->trigger )) $output['TRIGGER'] = 1; |
|
5643 | - if( !empty( $this->tzid )) $output['TZID'] = 1; |
|
5644 | - if( !empty( $this->tzname )) $output['TZNAME'] = count( $this->tzname ); |
|
5645 | - if( !empty( $this->tzoffsetfrom )) $output['TZOFFSETTFROM'] = 1; |
|
5646 | - if( !empty( $this->tzoffsetto )) $output['TZOFFSETTO'] = 1; |
|
5647 | - if( !empty( $this->tzurl )) $output['TZURL'] = 1; |
|
5648 | - if( !empty( $this->url )) $output['URL'] = 1; |
|
5649 | - if( !empty( $this->xprop )) $output['X-PROP'] = count( $this->xprop ); |
|
6289 | + if( !empty( $this->dtstamp )) { |
|
6290 | + $output['DTSTAMP'] = 1; |
|
6291 | + } |
|
6292 | + if( !empty( $this->summary )) { |
|
6293 | + $output['SUMMARY'] = 1; |
|
6294 | + } |
|
6295 | + if( !empty( $this->description )) { |
|
6296 | + $output['DESCRIPTION'] = count( $this->description ); |
|
6297 | + } |
|
6298 | + if( !empty( $this->dtstart )) { |
|
6299 | + $output['DTSTART'] = 1; |
|
6300 | + } |
|
6301 | + if( !empty( $this->dtend )) { |
|
6302 | + $output['DTEND'] = 1; |
|
6303 | + } |
|
6304 | + if( !empty( $this->due )) { |
|
6305 | + $output['DUE'] = 1; |
|
6306 | + } |
|
6307 | + if( !empty( $this->duration )) { |
|
6308 | + $output['DURATION'] = 1; |
|
6309 | + } |
|
6310 | + if( !empty( $this->rrule )) { |
|
6311 | + $output['RRULE'] = count( $this->rrule ); |
|
6312 | + } |
|
6313 | + if( !empty( $this->rdate )) { |
|
6314 | + $output['RDATE'] = count( $this->rdate ); |
|
6315 | + } |
|
6316 | + if( !empty( $this->exdate )) { |
|
6317 | + $output['EXDATE'] = count( $this->exdate ); |
|
6318 | + } |
|
6319 | + if( !empty( $this->exrule )) { |
|
6320 | + $output['EXRULE'] = count( $this->exrule ); |
|
6321 | + } |
|
6322 | + if( !empty( $this->action )) { |
|
6323 | + $output['ACTION'] = 1; |
|
6324 | + } |
|
6325 | + if( !empty( $this->attach )) { |
|
6326 | + $output['ATTACH'] = count( $this->attach ); |
|
6327 | + } |
|
6328 | + if( !empty( $this->attendee )) { |
|
6329 | + $output['ATTENDEE'] = count( $this->attendee ); |
|
6330 | + } |
|
6331 | + if( !empty( $this->categories )) { |
|
6332 | + $output['CATEGORIES'] = count( $this->categories ); |
|
6333 | + } |
|
6334 | + if( !empty( $this->class )) { |
|
6335 | + $output['CLASS'] = 1; |
|
6336 | + } |
|
6337 | + if( !empty( $this->comment )) { |
|
6338 | + $output['COMMENT'] = count( $this->comment ); |
|
6339 | + } |
|
6340 | + if( !empty( $this->completed )) { |
|
6341 | + $output['COMPLETED'] = 1; |
|
6342 | + } |
|
6343 | + if( !empty( $this->contact )) { |
|
6344 | + $output['CONTACT'] = count( $this->contact ); |
|
6345 | + } |
|
6346 | + if( !empty( $this->created )) { |
|
6347 | + $output['CREATED'] = 1; |
|
6348 | + } |
|
6349 | + if( !empty( $this->freebusy )) { |
|
6350 | + $output['FREEBUSY'] = count( $this->freebusy ); |
|
6351 | + } |
|
6352 | + if( !empty( $this->geo )) { |
|
6353 | + $output['GEO'] = 1; |
|
6354 | + } |
|
6355 | + if( !empty( $this->lastmodified )) { |
|
6356 | + $output['LAST-MODIFIED'] = 1; |
|
6357 | + } |
|
6358 | + if( !empty( $this->location )) { |
|
6359 | + $output['LOCATION'] = 1; |
|
6360 | + } |
|
6361 | + if( !empty( $this->organizer )) { |
|
6362 | + $output['ORGANIZER'] = 1; |
|
6363 | + } |
|
6364 | + if( !empty( $this->percentcomplete )) { |
|
6365 | + $output['PERCENT-COMPLETE'] = 1; |
|
6366 | + } |
|
6367 | + if( !empty( $this->priority )) { |
|
6368 | + $output['PRIORITY'] = 1; |
|
6369 | + } |
|
6370 | + if( !empty( $this->recurrenceid )) { |
|
6371 | + $output['RECURRENCE-ID'] = 1; |
|
6372 | + } |
|
6373 | + if( !empty( $this->relatedto )) { |
|
6374 | + $output['RELATED-TO'] = count( $this->relatedto ); |
|
6375 | + } |
|
6376 | + if( !empty( $this->repeat )) { |
|
6377 | + $output['REPEAT'] = 1; |
|
6378 | + } |
|
6379 | + if( !empty( $this->requeststatus )) { |
|
6380 | + $output['REQUEST-STATUS'] = count( $this->requeststatus ); |
|
6381 | + } |
|
6382 | + if( !empty( $this->resources )) { |
|
6383 | + $output['RESOURCES'] = count( $this->resources ); |
|
6384 | + } |
|
6385 | + if( !empty( $this->sequence )) { |
|
6386 | + $output['SEQUENCE'] = 1; |
|
6387 | + } |
|
6388 | + if( !empty( $this->status )) { |
|
6389 | + $output['STATUS'] = 1; |
|
6390 | + } |
|
6391 | + if( !empty( $this->transp )) { |
|
6392 | + $output['TRANSP'] = 1; |
|
6393 | + } |
|
6394 | + if( !empty( $this->trigger )) { |
|
6395 | + $output['TRIGGER'] = 1; |
|
6396 | + } |
|
6397 | + if( !empty( $this->tzid )) { |
|
6398 | + $output['TZID'] = 1; |
|
6399 | + } |
|
6400 | + if( !empty( $this->tzname )) { |
|
6401 | + $output['TZNAME'] = count( $this->tzname ); |
|
6402 | + } |
|
6403 | + if( !empty( $this->tzoffsetfrom )) { |
|
6404 | + $output['TZOFFSETTFROM'] = 1; |
|
6405 | + } |
|
6406 | + if( !empty( $this->tzoffsetto )) { |
|
6407 | + $output['TZOFFSETTO'] = 1; |
|
6408 | + } |
|
6409 | + if( !empty( $this->tzurl )) { |
|
6410 | + $output['TZURL'] = 1; |
|
6411 | + } |
|
6412 | + if( !empty( $this->url )) { |
|
6413 | + $output['URL'] = 1; |
|
6414 | + } |
|
6415 | + if( !empty( $this->xprop )) { |
|
6416 | + $output['X-PROP'] = count( $this->xprop ); |
|
6417 | + } |
|
5650 | 6418 | return $output; |
5651 | 6419 | break; |
5652 | 6420 | case 'UNIQUE_ID': |
5653 | - if( empty( $this->unique_id )) |
|
5654 | - $this->unique_id = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost'; |
|
6421 | + if( empty( $this->unique_id )) { |
|
6422 | + $this->unique_id = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost'; |
|
6423 | + } |
|
5655 | 6424 | return $this->unique_id; |
5656 | 6425 | break; |
5657 | 6426 | } |
@@ -5700,13 +6469,16 @@ discard block |
||
5700 | 6469 | $res = TRUE; |
5701 | 6470 | break; |
5702 | 6471 | } |
5703 | - if( !$res ) return FALSE; |
|
6472 | + if( !$res ) { |
|
6473 | + return FALSE; |
|
6474 | + } |
|
5704 | 6475 | if( isset( $subcfg ) && !empty( $this->components )) { |
5705 | 6476 | foreach( $subcfg as $cfgkey => $cfgvalue ) { |
5706 | 6477 | foreach( $this->components as $cix => $component ) { |
5707 | 6478 | $res = $component->setConfig( $cfgkey, $cfgvalue ); |
5708 | - if( !$res ) |
|
5709 | - break 2; |
|
6479 | + if( !$res ) { |
|
6480 | + break 2; |
|
6481 | + } |
|
5710 | 6482 | $this->components[$cix] = $component; // PHP4 compliant |
5711 | 6483 | } |
5712 | 6484 | } |
@@ -5724,12 +6496,15 @@ discard block |
||
5724 | 6496 | * @return bool, if successfull delete TRUE |
5725 | 6497 | */ |
5726 | 6498 | function deleteProperty( $propName, $propix=FALSE ) { |
5727 | - if( $this->_notExistProp( $propName )) return FALSE; |
|
6499 | + if( $this->_notExistProp( $propName )) { |
|
6500 | + return FALSE; |
|
6501 | + } |
|
5728 | 6502 | $propName = strtoupper( $propName ); |
5729 | 6503 | if( in_array( $propName, array( 'ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
5730 | 6504 | 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP' ))) { |
5731 | - if( !$propix ) |
|
5732 | - $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1; |
|
6505 | + if( !$propix ) { |
|
6506 | + $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1; |
|
6507 | + } |
|
5733 | 6508 | $this->propdelix[$propName] = --$propix; |
5734 | 6509 | } |
5735 | 6510 | $return = FALSE; |
@@ -5783,8 +6558,9 @@ discard block |
||
5783 | 6558 | } |
5784 | 6559 | break; |
5785 | 6560 | case 'DTSTAMP': |
5786 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
5787 | - return FALSE; |
|
6561 | + if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
6562 | + return FALSE; |
|
6563 | + } |
|
5788 | 6564 | if( !empty( $this->dtstamp )) { |
5789 | 6565 | $this->dtstamp = ''; |
5790 | 6566 | $return = TRUE; |
@@ -5938,8 +6714,9 @@ discard block |
||
5938 | 6714 | } |
5939 | 6715 | break; |
5940 | 6716 | case 'UID': |
5941 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
5942 | - return FALSE; |
|
6717 | + if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
6718 | + return FALSE; |
|
6719 | + } |
|
5943 | 6720 | if( !empty( $this->uid )) { |
5944 | 6721 | $this->uid = ''; |
5945 | 6722 | $return = TRUE; |
@@ -5954,18 +6731,23 @@ discard block |
||
5954 | 6731 | default: |
5955 | 6732 | $reduced = ''; |
5956 | 6733 | if( $propName != 'X-PROP' ) { |
5957 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
6734 | + if( !isset( $this->xprop[$propName] )) { |
|
6735 | + return FALSE; |
|
6736 | + } |
|
5958 | 6737 | foreach( $this->xprop as $k => $a ) { |
5959 | - if(( $k != $propName ) && !empty( $a )) |
|
5960 | - $reduced[$k] = $a; |
|
6738 | + if(( $k != $propName ) && !empty( $a )) { |
|
6739 | + $reduced[$k] = $a; |
|
6740 | + } |
|
6741 | + } |
|
6742 | + } else { |
|
6743 | + if( count( $this->xprop ) <= $propix ) { |
|
6744 | + return FALSE; |
|
5961 | 6745 | } |
5962 | - } |
|
5963 | - else { |
|
5964 | - if( count( $this->xprop ) <= $propix ) return FALSE; |
|
5965 | 6746 | $xpropno = 0; |
5966 | 6747 | foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
5967 | - if( $propix != $xpropno ) |
|
5968 | - $reduced[$xpropkey] = $xpropvalue; |
|
6748 | + if( $propix != $xpropno ) { |
|
6749 | + $reduced[$xpropkey] = $xpropvalue; |
|
6750 | + } |
|
5969 | 6751 | $xpropno++; |
5970 | 6752 | } |
5971 | 6753 | } |
@@ -5985,9 +6767,13 @@ discard block |
||
5985 | 6767 | * @return bool TRUE |
5986 | 6768 | */ |
5987 | 6769 | function deletePropertyM( & $multiprop, $propix=0 ) { |
5988 | - if( !isset( $multiprop[$propix])) return FALSE; |
|
6770 | + if( !isset( $multiprop[$propix])) { |
|
6771 | + return FALSE; |
|
6772 | + } |
|
5989 | 6773 | unset( $multiprop[$propix] ); |
5990 | - if( empty( $multiprop )) $multiprop = ''; |
|
6774 | + if( empty( $multiprop )) { |
|
6775 | + $multiprop = ''; |
|
6776 | + } |
|
5991 | 6777 | return ( isset( $this->multiprop[$propix] )) ? FALSE : TRUE; |
5992 | 6778 | } |
5993 | 6779 | /** |
@@ -6004,184 +6790,277 @@ discard block |
||
6004 | 6790 | * @return mixed |
6005 | 6791 | */ |
6006 | 6792 | function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE, $specform=FALSE ) { |
6007 | - if( $this->_notExistProp( $propName )) return FALSE; |
|
6793 | + if( $this->_notExistProp( $propName )) { |
|
6794 | + return FALSE; |
|
6795 | + } |
|
6008 | 6796 | $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP'; |
6009 | 6797 | if( in_array( $propName, array( 'ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
6010 | 6798 | 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP' ))) { |
6011 | - if( !$propix ) |
|
6012 | - $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; |
|
6799 | + if( !$propix ) { |
|
6800 | + $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; |
|
6801 | + } |
|
6013 | 6802 | $this->propix[$propName] = --$propix; |
6014 | 6803 | } |
6015 | 6804 | switch( $propName ) { |
6016 | 6805 | case 'ACTION': |
6017 | - if( !empty( $this->action['value'] )) return ( $inclParam ) ? $this->action : $this->action['value']; |
|
6806 | + if( !empty( $this->action['value'] )) { |
|
6807 | + return ( $inclParam ) ? $this->action : $this->action['value']; |
|
6808 | + } |
|
6018 | 6809 | break; |
6019 | 6810 | case 'ATTACH': |
6020 | - if( !isset( $this->attach[$propix] )) return FALSE; |
|
6811 | + if( !isset( $this->attach[$propix] )) { |
|
6812 | + return FALSE; |
|
6813 | + } |
|
6021 | 6814 | return ( $inclParam ) ? $this->attach[$propix] : $this->attach[$propix]['value']; |
6022 | 6815 | break; |
6023 | 6816 | case 'ATTENDEE': |
6024 | - if( !isset( $this->attendee[$propix] )) return FALSE; |
|
6817 | + if( !isset( $this->attendee[$propix] )) { |
|
6818 | + return FALSE; |
|
6819 | + } |
|
6025 | 6820 | return ( $inclParam ) ? $this->attendee[$propix] : $this->attendee[$propix]['value']; |
6026 | 6821 | break; |
6027 | 6822 | case 'CATEGORIES': |
6028 | - if( !isset( $this->categories[$propix] )) return FALSE; |
|
6823 | + if( !isset( $this->categories[$propix] )) { |
|
6824 | + return FALSE; |
|
6825 | + } |
|
6029 | 6826 | return ( $inclParam ) ? $this->categories[$propix] : $this->categories[$propix]['value']; |
6030 | 6827 | break; |
6031 | 6828 | case 'CLASS': |
6032 | - if( !empty( $this->class['value'] )) return ( $inclParam ) ? $this->class : $this->class['value']; |
|
6829 | + if( !empty( $this->class['value'] )) { |
|
6830 | + return ( $inclParam ) ? $this->class : $this->class['value']; |
|
6831 | + } |
|
6033 | 6832 | break; |
6034 | 6833 | case 'COMMENT': |
6035 | - if( !isset( $this->comment[$propix] )) return FALSE; |
|
6834 | + if( !isset( $this->comment[$propix] )) { |
|
6835 | + return FALSE; |
|
6836 | + } |
|
6036 | 6837 | return ( $inclParam ) ? $this->comment[$propix] : $this->comment[$propix]['value']; |
6037 | 6838 | break; |
6038 | 6839 | case 'COMPLETED': |
6039 | - if( !empty( $this->completed['value'] )) return ( $inclParam ) ? $this->completed : $this->completed['value']; |
|
6840 | + if( !empty( $this->completed['value'] )) { |
|
6841 | + return ( $inclParam ) ? $this->completed : $this->completed['value']; |
|
6842 | + } |
|
6040 | 6843 | break; |
6041 | 6844 | case 'CONTACT': |
6042 | - if( !isset( $this->contact[$propix] )) return FALSE; |
|
6845 | + if( !isset( $this->contact[$propix] )) { |
|
6846 | + return FALSE; |
|
6847 | + } |
|
6043 | 6848 | return ( $inclParam ) ? $this->contact[$propix] : $this->contact[$propix]['value']; |
6044 | 6849 | break; |
6045 | 6850 | case 'CREATED': |
6046 | - if( !empty( $this->created['value'] )) return ( $inclParam ) ? $this->created : $this->created['value']; |
|
6851 | + if( !empty( $this->created['value'] )) { |
|
6852 | + return ( $inclParam ) ? $this->created : $this->created['value']; |
|
6853 | + } |
|
6047 | 6854 | break; |
6048 | 6855 | case 'DESCRIPTION': |
6049 | - if( !isset( $this->description[$propix] )) return FALSE; |
|
6856 | + if( !isset( $this->description[$propix] )) { |
|
6857 | + return FALSE; |
|
6858 | + } |
|
6050 | 6859 | return ( $inclParam ) ? $this->description[$propix] : $this->description[$propix]['value']; |
6051 | 6860 | break; |
6052 | 6861 | case 'DTEND': |
6053 | - if( !empty( $this->dtend['value'] )) return ( $inclParam ) ? $this->dtend : $this->dtend['value']; |
|
6862 | + if( !empty( $this->dtend['value'] )) { |
|
6863 | + return ( $inclParam ) ? $this->dtend : $this->dtend['value']; |
|
6864 | + } |
|
6054 | 6865 | break; |
6055 | 6866 | case 'DTSTAMP': |
6056 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
6057 | - return; |
|
6058 | - if( !isset( $this->dtstamp['value'] )) |
|
6059 | - $this->_makeDtstamp(); |
|
6867 | + if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
6868 | + return; |
|
6869 | + } |
|
6870 | + if( !isset( $this->dtstamp['value'] )) { |
|
6871 | + $this->_makeDtstamp(); |
|
6872 | + } |
|
6060 | 6873 | return ( $inclParam ) ? $this->dtstamp : $this->dtstamp['value']; |
6061 | 6874 | break; |
6062 | 6875 | case 'DTSTART': |
6063 | - if( !empty( $this->dtstart['value'] )) return ( $inclParam ) ? $this->dtstart : $this->dtstart['value']; |
|
6876 | + if( !empty( $this->dtstart['value'] )) { |
|
6877 | + return ( $inclParam ) ? $this->dtstart : $this->dtstart['value']; |
|
6878 | + } |
|
6064 | 6879 | break; |
6065 | 6880 | case 'DUE': |
6066 | - if( !empty( $this->due['value'] )) return ( $inclParam ) ? $this->due : $this->due['value']; |
|
6881 | + if( !empty( $this->due['value'] )) { |
|
6882 | + return ( $inclParam ) ? $this->due : $this->due['value']; |
|
6883 | + } |
|
6067 | 6884 | break; |
6068 | 6885 | case 'DURATION': |
6069 | - if( !isset( $this->duration['value'] )) return FALSE; |
|
6886 | + if( !isset( $this->duration['value'] )) { |
|
6887 | + return FALSE; |
|
6888 | + } |
|
6070 | 6889 | $value = ( $specform ) ? $this->duration2date() : $this->duration['value']; |
6071 | 6890 | return ( $inclParam ) ? array( 'value' => $value, 'params' => $this->duration['params'] ) : $value; |
6072 | 6891 | break; |
6073 | 6892 | case 'EXDATE': |
6074 | - if( !isset( $this->exdate[$propix] )) return FALSE; |
|
6893 | + if( !isset( $this->exdate[$propix] )) { |
|
6894 | + return FALSE; |
|
6895 | + } |
|
6075 | 6896 | return ( $inclParam ) ? $this->exdate[$propix] : $this->exdate[$propix]['value']; |
6076 | 6897 | break; |
6077 | 6898 | case 'EXRULE': |
6078 | - if( !isset( $this->exrule[$propix] )) return FALSE; |
|
6899 | + if( !isset( $this->exrule[$propix] )) { |
|
6900 | + return FALSE; |
|
6901 | + } |
|
6079 | 6902 | return ( $inclParam ) ? $this->exrule[$propix] : $this->exrule[$propix]['value']; |
6080 | 6903 | break; |
6081 | 6904 | case 'FREEBUSY': |
6082 | - if( !isset( $this->freebusy[$propix] )) return FALSE; |
|
6905 | + if( !isset( $this->freebusy[$propix] )) { |
|
6906 | + return FALSE; |
|
6907 | + } |
|
6083 | 6908 | return ( $inclParam ) ? $this->freebusy[$propix] : $this->freebusy[$propix]['value']; |
6084 | 6909 | break; |
6085 | 6910 | case 'GEO': |
6086 | - if( !empty( $this->geo['value'] )) return ( $inclParam ) ? $this->geo : $this->geo['value']; |
|
6911 | + if( !empty( $this->geo['value'] )) { |
|
6912 | + return ( $inclParam ) ? $this->geo : $this->geo['value']; |
|
6913 | + } |
|
6087 | 6914 | break; |
6088 | 6915 | case 'LAST-MODIFIED': |
6089 | - if( !empty( $this->lastmodified['value'] )) return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value']; |
|
6916 | + if( !empty( $this->lastmodified['value'] )) { |
|
6917 | + return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value']; |
|
6918 | + } |
|
6090 | 6919 | break; |
6091 | 6920 | case 'LOCATION': |
6092 | - if( !empty( $this->location['value'] )) return ( $inclParam ) ? $this->location : $this->location['value']; |
|
6921 | + if( !empty( $this->location['value'] )) { |
|
6922 | + return ( $inclParam ) ? $this->location : $this->location['value']; |
|
6923 | + } |
|
6093 | 6924 | break; |
6094 | 6925 | case 'ORGANIZER': |
6095 | - if( !empty( $this->organizer['value'] )) return ( $inclParam ) ? $this->organizer : $this->organizer['value']; |
|
6926 | + if( !empty( $this->organizer['value'] )) { |
|
6927 | + return ( $inclParam ) ? $this->organizer : $this->organizer['value']; |
|
6928 | + } |
|
6096 | 6929 | break; |
6097 | 6930 | case 'PERCENT-COMPLETE': |
6098 | - if( !empty( $this->percentcomplete['value'] )) return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value']; |
|
6931 | + if( !empty( $this->percentcomplete['value'] )) { |
|
6932 | + return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value']; |
|
6933 | + } |
|
6099 | 6934 | break; |
6100 | 6935 | case 'PRIORITY': |
6101 | - if( !empty( $this->priority['value'] )) return ( $inclParam ) ? $this->priority : $this->priority['value']; |
|
6936 | + if( !empty( $this->priority['value'] )) { |
|
6937 | + return ( $inclParam ) ? $this->priority : $this->priority['value']; |
|
6938 | + } |
|
6102 | 6939 | break; |
6103 | 6940 | case 'RDATE': |
6104 | - if( !isset( $this->rdate[$propix] )) return FALSE; |
|
6941 | + if( !isset( $this->rdate[$propix] )) { |
|
6942 | + return FALSE; |
|
6943 | + } |
|
6105 | 6944 | return ( $inclParam ) ? $this->rdate[$propix] : $this->rdate[$propix]['value']; |
6106 | 6945 | break; |
6107 | 6946 | case 'RECURRENCE-ID': |
6108 | - if( !empty( $this->recurrenceid['value'] )) return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value']; |
|
6947 | + if( !empty( $this->recurrenceid['value'] )) { |
|
6948 | + return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value']; |
|
6949 | + } |
|
6109 | 6950 | break; |
6110 | 6951 | case 'RELATED-TO': |
6111 | - if( !isset( $this->relatedto[$propix] )) return FALSE; |
|
6952 | + if( !isset( $this->relatedto[$propix] )) { |
|
6953 | + return FALSE; |
|
6954 | + } |
|
6112 | 6955 | return ( $inclParam ) ? $this->relatedto[$propix] : $this->relatedto[$propix]['value']; |
6113 | 6956 | break; |
6114 | 6957 | case 'REPEAT': |
6115 | - if( !empty( $this->repeat['value'] )) return ( $inclParam ) ? $this->repeat : $this->repeat['value']; |
|
6958 | + if( !empty( $this->repeat['value'] )) { |
|
6959 | + return ( $inclParam ) ? $this->repeat : $this->repeat['value']; |
|
6960 | + } |
|
6116 | 6961 | break; |
6117 | 6962 | case 'REQUEST-STATUS': |
6118 | - if( !isset( $this->requeststatus[$propix] )) return FALSE; |
|
6963 | + if( !isset( $this->requeststatus[$propix] )) { |
|
6964 | + return FALSE; |
|
6965 | + } |
|
6119 | 6966 | return ( $inclParam ) ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value']; |
6120 | 6967 | break; |
6121 | 6968 | case 'RESOURCES': |
6122 | - if( !isset( $this->resources[$propix] )) return FALSE; |
|
6969 | + if( !isset( $this->resources[$propix] )) { |
|
6970 | + return FALSE; |
|
6971 | + } |
|
6123 | 6972 | return ( $inclParam ) ? $this->resources[$propix] : $this->resources[$propix]['value']; |
6124 | 6973 | break; |
6125 | 6974 | case 'RRULE': |
6126 | - if( !isset( $this->rrule[$propix] )) return FALSE; |
|
6975 | + if( !isset( $this->rrule[$propix] )) { |
|
6976 | + return FALSE; |
|
6977 | + } |
|
6127 | 6978 | return ( $inclParam ) ? $this->rrule[$propix] : $this->rrule[$propix]['value']; |
6128 | 6979 | break; |
6129 | 6980 | case 'SEQUENCE': |
6130 | - if( !empty( $this->sequence['value'] )) return ( $inclParam ) ? $this->sequence : $this->sequence['value']; |
|
6981 | + if( !empty( $this->sequence['value'] )) { |
|
6982 | + return ( $inclParam ) ? $this->sequence : $this->sequence['value']; |
|
6983 | + } |
|
6131 | 6984 | break; |
6132 | 6985 | case 'STATUS': |
6133 | - if( !empty( $this->status['value'] )) return ( $inclParam ) ? $this->status : $this->status['value']; |
|
6986 | + if( !empty( $this->status['value'] )) { |
|
6987 | + return ( $inclParam ) ? $this->status : $this->status['value']; |
|
6988 | + } |
|
6134 | 6989 | break; |
6135 | 6990 | case 'SUMMARY': |
6136 | - if( !empty( $this->summary['value'] )) return ( $inclParam ) ? $this->summary : $this->summary['value']; |
|
6991 | + if( !empty( $this->summary['value'] )) { |
|
6992 | + return ( $inclParam ) ? $this->summary : $this->summary['value']; |
|
6993 | + } |
|
6137 | 6994 | break; |
6138 | 6995 | case 'TRANSP': |
6139 | - if( !empty( $this->transp['value'] )) return ( $inclParam ) ? $this->transp : $this->transp['value']; |
|
6996 | + if( !empty( $this->transp['value'] )) { |
|
6997 | + return ( $inclParam ) ? $this->transp : $this->transp['value']; |
|
6998 | + } |
|
6140 | 6999 | break; |
6141 | 7000 | case 'TRIGGER': |
6142 | - if( !empty( $this->trigger['value'] )) return ( $inclParam ) ? $this->trigger : $this->trigger['value']; |
|
7001 | + if( !empty( $this->trigger['value'] )) { |
|
7002 | + return ( $inclParam ) ? $this->trigger : $this->trigger['value']; |
|
7003 | + } |
|
6143 | 7004 | break; |
6144 | 7005 | case 'TZID': |
6145 | - if( !empty( $this->tzid['value'] )) return ( $inclParam ) ? $this->tzid : $this->tzid['value']; |
|
7006 | + if( !empty( $this->tzid['value'] )) { |
|
7007 | + return ( $inclParam ) ? $this->tzid : $this->tzid['value']; |
|
7008 | + } |
|
6146 | 7009 | break; |
6147 | 7010 | case 'TZNAME': |
6148 | - if( !isset( $this->tzname[$propix] )) return FALSE; |
|
7011 | + if( !isset( $this->tzname[$propix] )) { |
|
7012 | + return FALSE; |
|
7013 | + } |
|
6149 | 7014 | return ( $inclParam ) ? $this->tzname[$propix] : $this->tzname[$propix]['value']; |
6150 | 7015 | break; |
6151 | 7016 | case 'TZOFFSETFROM': |
6152 | - if( !empty( $this->tzoffsetfrom['value'] )) return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value']; |
|
7017 | + if( !empty( $this->tzoffsetfrom['value'] )) { |
|
7018 | + return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value']; |
|
7019 | + } |
|
6153 | 7020 | break; |
6154 | 7021 | case 'TZOFFSETTO': |
6155 | - if( !empty( $this->tzoffsetto['value'] )) return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value']; |
|
7022 | + if( !empty( $this->tzoffsetto['value'] )) { |
|
7023 | + return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value']; |
|
7024 | + } |
|
6156 | 7025 | break; |
6157 | 7026 | case 'TZURL': |
6158 | - if( !empty( $this->tzurl['value'] )) return ( $inclParam ) ? $this->tzurl : $this->tzurl['value']; |
|
7027 | + if( !empty( $this->tzurl['value'] )) { |
|
7028 | + return ( $inclParam ) ? $this->tzurl : $this->tzurl['value']; |
|
7029 | + } |
|
6159 | 7030 | break; |
6160 | 7031 | case 'UID': |
6161 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
6162 | - return FALSE; |
|
6163 | - if( empty( $this->uid['value'] )) |
|
6164 | - $this->_makeuid(); |
|
7032 | + if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
7033 | + return FALSE; |
|
7034 | + } |
|
7035 | + if( empty( $this->uid['value'] )) { |
|
7036 | + $this->_makeuid(); |
|
7037 | + } |
|
6165 | 7038 | return ( $inclParam ) ? $this->uid : $this->uid['value']; |
6166 | 7039 | break; |
6167 | 7040 | case 'URL': |
6168 | - if( !empty( $this->url['value'] )) return ( $inclParam ) ? $this->url : $this->url['value']; |
|
7041 | + if( !empty( $this->url['value'] )) { |
|
7042 | + return ( $inclParam ) ? $this->url : $this->url['value']; |
|
7043 | + } |
|
6169 | 7044 | break; |
6170 | 7045 | default: |
6171 | 7046 | if( $propName != 'X-PROP' ) { |
6172 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
7047 | + if( !isset( $this->xprop[$propName] )) { |
|
7048 | + return FALSE; |
|
7049 | + } |
|
6173 | 7050 | return ( $inclParam ) ? array( $propName, $this->xprop[$propName] ) |
6174 | 7051 | : array( $propName, $this->xprop[$propName]['value'] ); |
6175 | - } |
|
6176 | - else { |
|
6177 | - if( empty( $this->xprop )) return FALSE; |
|
7052 | + } else { |
|
7053 | + if( empty( $this->xprop )) { |
|
7054 | + return FALSE; |
|
7055 | + } |
|
6178 | 7056 | $xpropno = 0; |
6179 | 7057 | foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
6180 | - if( $propix == $xpropno ) |
|
6181 | - return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) |
|
7058 | + if( $propix == $xpropno ) { |
|
7059 | + return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) |
|
6182 | 7060 | : array( $xpropkey, $this->xprop[$xpropkey]['value'] ); |
6183 | - else |
|
6184 | - $xpropno++; |
|
7061 | + } else { |
|
7062 | + $xpropno++; |
|
7063 | + } |
|
6185 | 7064 | } |
6186 | 7065 | return FALSE; // not found ?? |
6187 | 7066 | } |
@@ -6200,15 +7079,21 @@ discard block |
||
6200 | 7079 | */ |
6201 | 7080 | function setProperty() { |
6202 | 7081 | $numargs = func_num_args(); |
6203 | - if( 1 > $numargs ) return FALSE; |
|
7082 | + if( 1 > $numargs ) { |
|
7083 | + return FALSE; |
|
7084 | + } |
|
6204 | 7085 | $arglist = func_get_args(); |
6205 | - if( $this->_notExistProp( $arglist[0] )) return FALSE; |
|
6206 | - if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] ))) |
|
7086 | + if( $this->_notExistProp( $arglist[0] )) { |
|
6207 | 7087 | return FALSE; |
7088 | + } |
|
7089 | + if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] ))) { |
|
7090 | + return FALSE; |
|
7091 | + } |
|
6208 | 7092 | $arglist[0] = strtoupper( $arglist[0] ); |
6209 | 7093 | for( $argix=$numargs; $argix < 12; $argix++ ) { |
6210 | - if( !isset( $arglist[$argix] )) |
|
6211 | - $arglist[$argix] = null; |
|
7094 | + if( !isset( $arglist[$argix] )) { |
|
7095 | + $arglist[$argix] = null; |
|
7096 | + } |
|
6212 | 7097 | } |
6213 | 7098 | switch( $arglist[0] ) { |
6214 | 7099 | case 'ACTION': |
@@ -6322,20 +7207,19 @@ discard block |
||
6322 | 7207 | $this->setComponent( $comp ); |
6323 | 7208 | $comp = & $this; |
6324 | 7209 | continue; |
6325 | - } |
|
6326 | - elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) { |
|
7210 | + } elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) { |
|
6327 | 7211 | $comp = new valarm(); |
6328 | 7212 | continue; |
7213 | + } else { |
|
7214 | + $comp->unparsed[] = $line; |
|
6329 | 7215 | } |
6330 | - else |
|
6331 | - $comp->unparsed[] = $line; |
|
6332 | 7216 | } |
7217 | + } else { |
|
7218 | + $this->unparsed = array( trim( $unparsedtext )); |
|
6333 | 7219 | } |
6334 | - else |
|
6335 | - $this->unparsed = array( trim( $unparsedtext )); |
|
7220 | + } elseif( !isset( $this->unparsed )) { |
|
7221 | + $this->unparsed = array(); |
|
6336 | 7222 | } |
6337 | - elseif( !isset( $this->unparsed )) |
|
6338 | - $this->unparsed = array(); |
|
6339 | 7223 | /* concatenate property values spread over several lines */ |
6340 | 7224 | $lastix = -1; |
6341 | 7225 | $propnames = array( 'action', 'attach', 'attendee', 'categories', 'comment', 'completed' |
@@ -6359,8 +7243,7 @@ discard block |
||
6359 | 7243 | $newProp = FALSE; |
6360 | 7244 | $lastix++; |
6361 | 7245 | $proprows[$lastix] = $line; |
6362 | - } |
|
6363 | - else { |
|
7246 | + } else { |
|
6364 | 7247 | /* remove line breaks */ |
6365 | 7248 | if(( '\n' == substr( $proprows[$lastix], -2 )) && |
6366 | 7249 | ( ' ' == substr( $line, 0, 1 ))) { |
@@ -6373,14 +7256,15 @@ discard block |
||
6373 | 7256 | /* parse each property 'line' */ |
6374 | 7257 | foreach( $proprows as $line ) { |
6375 | 7258 | $line = str_replace( "\n ", '', $line ); |
6376 | - if( '\n' == substr( $line, -2 )) |
|
6377 | - $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
7259 | + if( '\n' == substr( $line, -2 )) { |
|
7260 | + $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
7261 | + } |
|
6378 | 7262 | /* get propname, (problem with x-properties, otherwise in previous loop) */ |
6379 | 7263 | $cix = $propname = null; |
6380 | 7264 | for( $cix=0; $cix < strlen( $line ); $cix++ ) { |
6381 | - if( in_array( $line{$cix}, array( ':', ';' ))) |
|
6382 | - break; |
|
6383 | - else { |
|
7265 | + if( in_array( $line{$cix}, array( ':', ';' ))) { |
|
7266 | + break; |
|
7267 | + } else { |
|
6384 | 7268 | $propname .= $line{$cix}; |
6385 | 7269 | } |
6386 | 7270 | } |
@@ -6413,27 +7297,30 @@ discard block |
||
6413 | 7297 | break; |
6414 | 7298 | } |
6415 | 7299 | } |
6416 | - if( ';' == $line{$cix} ) |
|
6417 | - $attr[++$attrix] = null; |
|
6418 | - else |
|
6419 | - $attr[$attrix] .= $line{$cix}; |
|
7300 | + if( ';' == $line{$cix} ) { |
|
7301 | + $attr[++$attrix] = null; |
|
7302 | + } else { |
|
7303 | + $attr[$attrix] .= $line{$cix}; |
|
7304 | + } |
|
6420 | 7305 | } |
6421 | 7306 | /* make attributes in array format */ |
6422 | 7307 | $propattr = array(); |
6423 | 7308 | foreach( $attr as $attribute ) { |
6424 | 7309 | $attrsplit = explode( '=', $attribute, 2 ); |
6425 | - if( 1 < count( $attrsplit )) |
|
6426 | - $propattr[$attrsplit[0]] = $attrsplit[1]; |
|
6427 | - else |
|
6428 | - $propattr[] = $attribute; |
|
7310 | + if( 1 < count( $attrsplit )) { |
|
7311 | + $propattr[$attrsplit[0]] = $attrsplit[1]; |
|
7312 | + } else { |
|
7313 | + $propattr[] = $attribute; |
|
7314 | + } |
|
6429 | 7315 | } |
6430 | 7316 | /* call setProperty( $propname.. . */ |
6431 | 7317 | switch( $propname ) { |
6432 | 7318 | case 'ATTENDEE': |
6433 | 7319 | foreach( $propattr as $pix => $attr ) { |
6434 | 7320 | $attr2 = explode( ',', $attr ); |
6435 | - if( 1 < count( $attr2 )) |
|
6436 | - $propattr[$pix] = $attr2; |
|
7321 | + if( 1 < count( $attr2 )) { |
|
7322 | + $propattr[$pix] = $attr2; |
|
7323 | + } |
|
6437 | 7324 | } |
6438 | 7325 | $this->setProperty( $propname, $line, $propattr ); |
6439 | 7326 | break; |
@@ -6451,13 +7338,14 @@ discard block |
||
6451 | 7338 | } |
6452 | 7339 | if( 1 < count( $content )) { |
6453 | 7340 | $content = array_values( $content ); |
6454 | - foreach( $content as $cix => $contentPart ) |
|
6455 | - $content[$cix] = $this->_strunrep( $contentPart ); |
|
7341 | + foreach( $content as $cix => $contentPart ) { |
|
7342 | + $content[$cix] = $this->_strunrep( $contentPart ); |
|
7343 | + } |
|
6456 | 7344 | $this->setProperty( $propname, $content, $propattr ); |
6457 | 7345 | break; |
7346 | + } else { |
|
7347 | + $line = reset( $content ); |
|
6458 | 7348 | } |
6459 | - else |
|
6460 | - $line = reset( $content ); |
|
6461 | 7349 | } |
6462 | 7350 | //no break |
6463 | 7351 | case 'X-': |
@@ -6468,8 +7356,9 @@ discard block |
||
6468 | 7356 | case 'DESCRIPTION': |
6469 | 7357 | case 'LOCATION': |
6470 | 7358 | case 'SUMMARY': |
6471 | - if( empty( $line )) |
|
6472 | - $propattr = null; |
|
7359 | + if( empty( $line )) { |
|
7360 | + $propattr = null; |
|
7361 | + } |
|
6473 | 7362 | $this->setProperty( $propname, $this->_strunrep( $line ), $propattr ); |
6474 | 7363 | unset( $propname2 ); |
6475 | 7364 | break; |
@@ -6489,15 +7378,17 @@ discard block |
||
6489 | 7378 | $values = explode( ',', $line ); |
6490 | 7379 | foreach( $values as $vix => $value ) { |
6491 | 7380 | $value2 = explode( '/', $value ); |
6492 | - if( 1 < count( $value2 )) |
|
6493 | - $values[$vix] = $value2; |
|
7381 | + if( 1 < count( $value2 )) { |
|
7382 | + $values[$vix] = $value2; |
|
7383 | + } |
|
6494 | 7384 | } |
6495 | 7385 | $this->setProperty( $propname, $fbtype, $values, $propattr ); |
6496 | 7386 | break; |
6497 | 7387 | case 'GEO': |
6498 | 7388 | $value = explode( ';', $line, 2 ); |
6499 | - if( 2 > count( $value )) |
|
6500 | - $value[1] = null; |
|
7389 | + if( 2 > count( $value )) { |
|
7390 | + $value[1] = null; |
|
7391 | + } |
|
6501 | 7392 | $this->setProperty( $propname, $value[0], $value[1], $propattr ); |
6502 | 7393 | break; |
6503 | 7394 | case 'EXDATE': |
@@ -6512,8 +7403,9 @@ discard block |
||
6512 | 7403 | $values = explode( ',', $line ); |
6513 | 7404 | foreach( $values as $vix => $value ) { |
6514 | 7405 | $value2 = explode( '/', $value ); |
6515 | - if( 1 < count( $value2 )) |
|
6516 | - $values[$vix] = $value2; |
|
7406 | + if( 1 < count( $value2 )) { |
|
7407 | + $values[$vix] = $value2; |
|
7408 | + } |
|
6517 | 7409 | } |
6518 | 7410 | $this->setProperty( $propname, $values, $propattr ); |
6519 | 7411 | break; |
@@ -6522,8 +7414,10 @@ discard block |
||
6522 | 7414 | $values = explode( ';', $line ); |
6523 | 7415 | $recur = array(); |
6524 | 7416 | foreach( $values as $value2 ) { |
6525 | - if( empty( $value2 )) |
|
6526 | - continue; // ;-char in ending position ??? |
|
7417 | + if( empty( $value2 )) { |
|
7418 | + continue; |
|
7419 | + } |
|
7420 | + // ;-char in ending position ??? |
|
6527 | 7421 | $value3 = explode( '=', $value2, 2 ); |
6528 | 7422 | $rulelabel = strtoupper( $value3[0] ); |
6529 | 7423 | switch( $rulelabel ) { |
@@ -6537,37 +7431,43 @@ discard block |
||
6537 | 7431 | if(( ctype_alpha( substr( $value5, -1 ))) && |
6538 | 7432 | ( ctype_alpha( substr( $value5, -2, 1 )))) { |
6539 | 7433 | $dayname = substr( $value5, -2, 2 ); |
6540 | - if( 2 < strlen( $value5 )) |
|
6541 | - $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
7434 | + if( 2 < strlen( $value5 )) { |
|
7435 | + $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
7436 | + } |
|
7437 | + } |
|
7438 | + if( $dayno ) { |
|
7439 | + $value6[] = $dayno; |
|
7440 | + } |
|
7441 | + if( $dayname ) { |
|
7442 | + $value6['DAY'] = $dayname; |
|
6542 | 7443 | } |
6543 | - if( $dayno ) |
|
6544 | - $value6[] = $dayno; |
|
6545 | - if( $dayname ) |
|
6546 | - $value6['DAY'] = $dayname; |
|
6547 | 7444 | $value4[$v5ix] = $value6; |
6548 | 7445 | } |
6549 | - } |
|
6550 | - else { |
|
7446 | + } else { |
|
6551 | 7447 | $value4 = array(); |
6552 | 7448 | $dayno = $dayname = null; |
6553 | 7449 | $value5 = trim( (string) $value3[1] ); |
6554 | 7450 | if(( ctype_alpha( substr( $value5, -1 ))) && |
6555 | 7451 | ( ctype_alpha( substr( $value5, -2, 1 )))) { |
6556 | 7452 | $dayname = substr( $value5, -2, 2 ); |
6557 | - if( 2 < strlen( $value5 )) |
|
6558 | - $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
7453 | + if( 2 < strlen( $value5 )) { |
|
7454 | + $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
7455 | + } |
|
7456 | + } |
|
7457 | + if( $dayno ) { |
|
7458 | + $value4[] = $dayno; |
|
7459 | + } |
|
7460 | + if( $dayname ) { |
|
7461 | + $value4['DAY'] = $dayname; |
|
6559 | 7462 | } |
6560 | - if( $dayno ) |
|
6561 | - $value4[] = $dayno; |
|
6562 | - if( $dayname ) |
|
6563 | - $value4['DAY'] = $dayname; |
|
6564 | 7463 | } |
6565 | 7464 | $recur[$rulelabel] = $value4; |
6566 | 7465 | break; |
6567 | 7466 | default: |
6568 | 7467 | $value4 = explode( ',', $value3[1] ); |
6569 | - if( 1 < count( $value4 )) |
|
6570 | - $value3[1] = $value4; |
|
7468 | + if( 1 < count( $value4 )) { |
|
7469 | + $value3[1] = $value4; |
|
7470 | + } |
|
6571 | 7471 | $recur[$rulelabel] = $value3[1]; |
6572 | 7472 | break; |
6573 | 7473 | } // end - switch $rulelabel |
@@ -6582,8 +7482,9 @@ discard block |
||
6582 | 7482 | unset( $this->unparsed, $proprows ); |
6583 | 7483 | if( isset( $this->components ) && is_array( $this->components ) && ( 0 < count( $this->components ))) { |
6584 | 7484 | for( $six = 0; $six < count( $this->components ); $six++ ) { |
6585 | - if( !empty( $this->components[$six]->unparsed )) |
|
6586 | - $this->components[$six]->parse(); |
|
7485 | + if( !empty( $this->components[$six]->unparsed )) { |
|
7486 | + $this->components[$six]->parse(); |
|
7487 | + } |
|
6587 | 7488 | } |
6588 | 7489 | } |
6589 | 7490 | } |
@@ -6614,32 +7515,33 @@ discard block |
||
6614 | 7515 | * @return void |
6615 | 7516 | */ |
6616 | 7517 | function deleteComponent( $arg1, $arg2=FALSE ) { |
6617 | - if( !isset( $this->components )) return FALSE; |
|
7518 | + if( !isset( $this->components )) { |
|
7519 | + return FALSE; |
|
7520 | + } |
|
6618 | 7521 | $argType = $index = null; |
6619 | 7522 | if ( ctype_digit( (string) $arg1 )) { |
6620 | 7523 | $argType = 'INDEX'; |
6621 | 7524 | $index = (int) $arg1 - 1; |
6622 | - } |
|
6623 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
7525 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6624 | 7526 | $argType = strtolower( $arg1 ); |
6625 | 7527 | $index = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0; |
6626 | 7528 | } |
6627 | 7529 | $cix2dC = 0; |
6628 | 7530 | foreach ( $this->components as $cix => $component) { |
6629 | - if( empty( $component )) continue; |
|
7531 | + if( empty( $component )) { |
|
7532 | + continue; |
|
7533 | + } |
|
6630 | 7534 | unset( $component->propix ); |
6631 | 7535 | if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
6632 | 7536 | unset( $this->components[$cix] ); |
6633 | 7537 | return TRUE; |
6634 | - } |
|
6635 | - elseif( $argType == $component->objName ) { |
|
7538 | + } elseif( $argType == $component->objName ) { |
|
6636 | 7539 | if( $index == $cix2dC ) { |
6637 | 7540 | unset( $this->components[$cix] ); |
6638 | 7541 | return TRUE; |
6639 | 7542 | } |
6640 | 7543 | $cix2dC++; |
6641 | - } |
|
6642 | - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
7544 | + } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
6643 | 7545 | unset( $this->components[$cix] ); |
6644 | 7546 | return TRUE; |
6645 | 7547 | } |
@@ -6656,43 +7558,47 @@ discard block |
||
6656 | 7558 | * @return object |
6657 | 7559 | */ |
6658 | 7560 | function getComponent ( $arg1=FALSE, $arg2=FALSE ) { |
6659 | - if( !isset( $this->components )) return FALSE; |
|
7561 | + if( !isset( $this->components )) { |
|
7562 | + return FALSE; |
|
7563 | + } |
|
6660 | 7564 | $index = $argType = null; |
6661 | 7565 | if ( !$arg1 ) { |
6662 | 7566 | $argType = 'INDEX'; |
6663 | 7567 | $index = $this->compix['INDEX'] = |
6664 | 7568 | ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1; |
6665 | - } |
|
6666 | - elseif ( ctype_digit( (string) $arg1 )) { |
|
7569 | + } elseif ( ctype_digit( (string) $arg1 )) { |
|
6667 | 7570 | $argType = 'INDEX'; |
6668 | 7571 | $index = (int) $arg1; |
6669 | 7572 | unset( $this->compix ); |
6670 | - } |
|
6671 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
7573 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6672 | 7574 | unset( $this->compix['INDEX'] ); |
6673 | 7575 | $argType = strtolower( $arg1 ); |
6674 | - if( !$arg2 ) |
|
6675 | - $index = $this->compix[$argType] = |
|
7576 | + if( !$arg2 ) { |
|
7577 | + $index = $this->compix[$argType] = |
|
6676 | 7578 | ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1; |
6677 | - else |
|
6678 | - $index = (int) $arg2; |
|
7579 | + } else { |
|
7580 | + $index = (int) $arg2; |
|
7581 | + } |
|
6679 | 7582 | } |
6680 | 7583 | $index -= 1; |
6681 | 7584 | $ckeys = array_keys( $this->components ); |
6682 | - if( !empty( $index) && ( $index > end( $ckeys ))) |
|
6683 | - return FALSE; |
|
7585 | + if( !empty( $index) && ( $index > end( $ckeys ))) { |
|
7586 | + return FALSE; |
|
7587 | + } |
|
6684 | 7588 | $cix2gC = 0; |
6685 | 7589 | foreach( $this->components as $cix => $component ) { |
6686 | - if( empty( $component )) continue; |
|
7590 | + if( empty( $component )) { |
|
7591 | + continue; |
|
7592 | + } |
|
6687 | 7593 | unset( $component->propix ); |
6688 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) |
|
6689 | - return $component->copy(); |
|
6690 | - elseif( $argType == $component->objName ) { |
|
6691 | - if( $index == $cix2gC ) |
|
6692 | - return $component->copy(); |
|
7594 | + if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
|
7595 | + return $component->copy(); |
|
7596 | + } elseif( $argType == $component->objName ) { |
|
7597 | + if( $index == $cix2gC ) { |
|
7598 | + return $component->copy(); |
|
7599 | + } |
|
6693 | 7600 | $cix2gC++; |
6694 | - } |
|
6695 | - elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) { |
|
7601 | + } elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) { |
|
6696 | 7602 | unset( $component->propix ); |
6697 | 7603 | return $component->copy(); |
6698 | 7604 | } |
@@ -6723,9 +7629,12 @@ discard block |
||
6723 | 7629 | * @return bool |
6724 | 7630 | */ |
6725 | 7631 | function setComponent( $component, $arg1=FALSE, $arg2=FALSE ) { |
6726 | - if( !isset( $this->components )) return FALSE; |
|
6727 | - if( '' >= $component->getConfig( 'language')) |
|
6728 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
7632 | + if( !isset( $this->components )) { |
|
7633 | + return FALSE; |
|
7634 | + } |
|
7635 | + if( '' >= $component->getConfig( 'language')) { |
|
7636 | + $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
7637 | + } |
|
6729 | 7638 | $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
6730 | 7639 | $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
6731 | 7640 | $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
@@ -6744,27 +7653,26 @@ discard block |
||
6744 | 7653 | if ( ctype_digit( (string) $arg1 )) { |
6745 | 7654 | $argType = 'INDEX'; |
6746 | 7655 | $index = (int) $arg1 - 1; |
6747 | - } |
|
6748 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
7656 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6749 | 7657 | $argType = strtolower( $arg1 ); |
6750 | 7658 | $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0; |
6751 | 7659 | } |
6752 | 7660 | $cix2sC = 0; |
6753 | 7661 | foreach ( $this->components as $cix => $component2 ) { |
6754 | - if( empty( $component2 )) continue; |
|
7662 | + if( empty( $component2 )) { |
|
7663 | + continue; |
|
7664 | + } |
|
6755 | 7665 | unset( $component2->propix ); |
6756 | 7666 | if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
6757 | 7667 | $this->components[$cix] = $component->copy(); |
6758 | 7668 | return TRUE; |
6759 | - } |
|
6760 | - elseif( $argType == $component2->objName ) { |
|
7669 | + } elseif( $argType == $component2->objName ) { |
|
6761 | 7670 | if( $index == $cix2sC ) { |
6762 | 7671 | $this->components[$cix] = $component->copy(); |
6763 | 7672 | return TRUE; |
6764 | 7673 | } |
6765 | 7674 | $cix2sC++; |
6766 | - } |
|
6767 | - elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) { |
|
7675 | + } elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) { |
|
6768 | 7676 | $this->components[$cix] = $component->copy(); |
6769 | 7677 | return TRUE; |
6770 | 7678 | } |
@@ -6783,9 +7691,12 @@ discard block |
||
6783 | 7691 | function createSubComponent() { |
6784 | 7692 | $output = null; |
6785 | 7693 | foreach( $this->components as $component ) { |
6786 | - if( empty( $component )) continue; |
|
6787 | - if( '' >= $component->getConfig( 'language')) |
|
6788 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
7694 | + if( empty( $component )) { |
|
7695 | + continue; |
|
7696 | + } |
|
7697 | + if( '' >= $component->getConfig( 'language')) { |
|
7698 | + $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
7699 | + } |
|
6789 | 7700 | $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
6790 | 7701 | $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
6791 | 7702 | $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
@@ -6823,16 +7734,18 @@ discard block |
||
6823 | 7734 | $string = null; |
6824 | 7735 | while( $strlen > 75 ) { |
6825 | 7736 | $breakAtChar = 75; |
6826 | - if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' ) |
|
6827 | - $breakAtChar = $breakAtChar - 1; |
|
7737 | + if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' ) { |
|
7738 | + $breakAtChar = $breakAtChar - 1; |
|
7739 | + } |
|
6828 | 7740 | $string .= substr( $tmp, 0, $breakAtChar ); |
6829 | 7741 | $string .= $this->nl; |
6830 | 7742 | $tmp = ' '.substr( $tmp, $breakAtChar ); |
6831 | 7743 | $strlen = strlen( $tmp ); |
6832 | 7744 | } // while |
6833 | 7745 | $string .= rtrim( $tmp ); // the rest |
6834 | - if( $this->nl != substr( $string, ( 0 - strlen( $this->nl )))) |
|
6835 | - $string .= $this->nl; |
|
7746 | + if( $this->nl != substr( $string, ( 0 - strlen( $this->nl )))) { |
|
7747 | + $string .= $this->nl; |
|
7748 | + } |
|
6836 | 7749 | return $string; |
6837 | 7750 | } |
6838 | 7751 | /** |
@@ -6853,27 +7766,33 @@ discard block |
||
6853 | 7766 | $pos = 0; |
6854 | 7767 | while( $pos <= strlen( $string )) { |
6855 | 7768 | $pos = strpos( $string, "\\", $pos ); |
6856 | - if( FALSE === $pos ) |
|
6857 | - break; |
|
7769 | + if( FALSE === $pos ) { |
|
7770 | + break; |
|
7771 | + } |
|
6858 | 7772 | if( !in_array( $string{($pos + 1)}, array( 'n', 'N', 'r', ',', ';' ))) { |
6859 | 7773 | $string = substr( $string, 0, $pos )."\\".substr( $string, ( $pos + 1 )); |
6860 | 7774 | $pos += 1; |
6861 | 7775 | } |
6862 | 7776 | $pos += 1; |
6863 | 7777 | } |
6864 | - if( FALSE !== strpos( $string, '"' )) |
|
6865 | - $string = str_replace('"', "'", $string); |
|
6866 | - if( FALSE !== strpos( $string, ',' )) |
|
6867 | - $string = str_replace(',', '\,', $string); |
|
6868 | - if( FALSE !== strpos( $string, ';' )) |
|
6869 | - $string = str_replace(';', '\;', $string); |
|
6870 | - if( FALSE !== strpos( $string, "\r\n" )) |
|
6871 | - $string = str_replace( "\r\n", '\n', $string); |
|
6872 | - elseif( FALSE !== strpos( $string, "\r" )) |
|
6873 | - $string = str_replace( "\r", '\n', $string); |
|
6874 | - if( FALSE !== strpos( $string, '\N' )) |
|
6875 | - $string = str_replace( '\N', '\n', $string); |
|
6876 | -// if( FALSE !== strpos( $string, $this->nl )) |
|
7778 | + if( FALSE !== strpos( $string, '"' )) { |
|
7779 | + $string = str_replace('"', "'", $string); |
|
7780 | + } |
|
7781 | + if( FALSE !== strpos( $string, ',' )) { |
|
7782 | + $string = str_replace(',', '\,', $string); |
|
7783 | + } |
|
7784 | + if( FALSE !== strpos( $string, ';' )) { |
|
7785 | + $string = str_replace(';', '\;', $string); |
|
7786 | + } |
|
7787 | + if( FALSE !== strpos( $string, "\r\n" )) { |
|
7788 | + $string = str_replace( "\r\n", '\n', $string); |
|
7789 | + } elseif( FALSE !== strpos( $string, "\r" )) { |
|
7790 | + $string = str_replace( "\r", '\n', $string); |
|
7791 | + } |
|
7792 | + if( FALSE !== strpos( $string, '\N' )) { |
|
7793 | + $string = str_replace( '\N', '\n', $string); |
|
7794 | + } |
|
7795 | + // if( FALSE !== strpos( $string, $this->nl )) |
|
6877 | 7796 | $string = str_replace( $this->nl, '\n', $string); |
6878 | 7797 | break; |
6879 | 7798 | } |
@@ -7026,8 +7945,9 @@ discard block |
||
7026 | 7945 | $component .= $this->createSubComponent(); |
7027 | 7946 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7028 | 7947 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7029 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7030 | - $xcaldecl[] = $localxcaldecl; |
|
7948 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
7949 | + $xcaldecl[] = $localxcaldecl; |
|
7950 | + } |
|
7031 | 7951 | } |
7032 | 7952 | return $component; |
7033 | 7953 | } |
@@ -7165,8 +8085,9 @@ discard block |
||
7165 | 8085 | $component .= $this->createSubComponent(); |
7166 | 8086 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7167 | 8087 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7168 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7169 | - $xcaldecl[] = $localxcaldecl; |
|
8088 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
8089 | + $xcaldecl[] = $localxcaldecl; |
|
8090 | + } |
|
7170 | 8091 | } |
7171 | 8092 | return $component; |
7172 | 8093 | } |
@@ -7275,8 +8196,9 @@ discard block |
||
7275 | 8196 | $component .= $this->createXprop(); |
7276 | 8197 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7277 | 8198 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7278 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7279 | - $xcaldecl[] = $localxcaldecl; |
|
8199 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
8200 | + $xcaldecl[] = $localxcaldecl; |
|
8201 | + } |
|
7280 | 8202 | } |
7281 | 8203 | return $component; |
7282 | 8204 | } |
@@ -7351,8 +8273,9 @@ discard block |
||
7351 | 8273 | $component .= $this->createXprop(); |
7352 | 8274 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7353 | 8275 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7354 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7355 | - $xcaldecl[] = $localxcaldecl; |
|
8276 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
8277 | + $xcaldecl[] = $localxcaldecl; |
|
8278 | + } |
|
7356 | 8279 | } |
7357 | 8280 | return $component; |
7358 | 8281 | } |
@@ -7452,10 +8375,11 @@ discard block |
||
7452 | 8375 | * @return void |
7453 | 8376 | */ |
7454 | 8377 | function __construct( $timezonetype=FALSE ) { |
7455 | - if( !$timezonetype ) |
|
7456 | - $this->timezonetype = 'VTIMEZONE'; |
|
7457 | - else |
|
7458 | - $this->timezonetype = strtoupper( $timezonetype ); |
|
8378 | + if( !$timezonetype ) { |
|
8379 | + $this->timezonetype = 'VTIMEZONE'; |
|
8380 | + } else { |
|
8381 | + $this->timezonetype = strtoupper( $timezonetype ); |
|
8382 | + } |
|
7459 | 8383 | $this->calendarComponent(); |
7460 | 8384 | |
7461 | 8385 | $this->comment = ''; |
@@ -7497,8 +8421,9 @@ discard block |
||
7497 | 8421 | $component .= $this->createSubComponent(); |
7498 | 8422 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7499 | 8423 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7500 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7501 | - $xcaldecl[] = $localxcaldecl; |
|
8424 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
8425 | + $xcaldecl[] = $localxcaldecl; |
|
8426 | + } |
|
7502 | 8427 | } |
7503 | 8428 | return $component; |
7504 | 8429 | } |