@@ -207,7 +207,10 @@ discard block |
||
207 | 207 | |
208 | 208 | unset($Courses); |
209 | 209 | ?> |
210 | -<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?page=<?php echo $page; ?>&id_session=<?php echo $sessionId; ?><?php if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>> |
|
210 | +<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?page=<?php echo $page; ?>&id_session=<?php echo $sessionId; ?><?php if(!empty($_GET['add'])) { |
|
211 | + echo '&add=true' ; |
|
212 | +} |
|
213 | +?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>> |
|
211 | 214 | <legend><?php echo $tool_name.' ('.$session_info['name'].')'; ?></legend> |
212 | 215 | <input type="hidden" name="formSent" value="1" /> |
213 | 216 | |
@@ -230,7 +233,10 @@ discard block |
||
230 | 233 | <div id="ajax_list_courses_multiple"> |
231 | 234 | <select id="origin" name="NoSessionCoursesList[]" multiple="multiple" size="20" class="form-control"> |
232 | 235 | <?php foreach ($nosessionCourses as $enreg) { ?> |
233 | - <option value="<?php echo $enreg['id']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['title'].' ('.$enreg['visual_code'].')',ENT_QUOTES).'"'; if(in_array($enreg['code'],$CourseList)) echo 'selected="selected"'; ?>> |
|
236 | + <option value="<?php echo $enreg['id']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['title'].' ('.$enreg['visual_code'].')',ENT_QUOTES).'"'; if(in_array($enreg['code'],$CourseList)) { |
|
237 | + echo 'selected="selected"'; |
|
238 | +} |
|
239 | +?>> |
|
234 | 240 | <?php echo $enreg['title'].' ('.$enreg['visual_code'].')'; ?> |
235 | 241 | </option> |
236 | 242 | <?php } ?> |
@@ -3342,7 +3342,7 @@ discard block |
||
3342 | 3342 | $html .= '<a class="thumbnail" href="'.$params['link'].'">'; |
3343 | 3343 | $html .= $params['icon']; |
3344 | 3344 | $html .= '</a>'; |
3345 | - }else{ |
|
3345 | + } else{ |
|
3346 | 3346 | $html .= $params['icon']; |
3347 | 3347 | } |
3348 | 3348 | $html .= '</div>'; |
@@ -3423,7 +3423,7 @@ discard block |
||
3423 | 3423 | . Display::returnFontAwesomeIcon('folder-open') . '</a>'; |
3424 | 3424 | $params['document'] .= Display::div('', ['id' => 'document_result_' . $course_info['real_id'] . '_0', 'class' => 'document_preview_container']); |
3425 | 3425 | } |
3426 | - }else{ |
|
3426 | + } else{ |
|
3427 | 3427 | if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED && $load_dirs) { |
3428 | 3428 | $params['document'] = '<a id="document_preview_' . $course_info['real_id'] . '_0" class="document_preview btn btn-default btn-sm" href="javascript:void(0);">' |
3429 | 3429 | . Display::returnFontAwesomeIcon('folder-open') . '</a>'; |
@@ -3598,7 +3598,7 @@ discard block |
||
3598 | 3598 | if ($showCustomIcon === 'true' && $iconName != 'course.png') { |
3599 | 3599 | $thumbnails = $course_info['course_image']; |
3600 | 3600 | $image = $course_info['course_image_large']; |
3601 | - }else{ |
|
3601 | + } else{ |
|
3602 | 3602 | $image = Display::return_icon('session_default.png', null, null, null,null, true); |
3603 | 3603 | } |
3604 | 3604 | |
@@ -3736,7 +3736,7 @@ discard block |
||
3736 | 3736 | if ($showCustomIcon === 'true' && $iconName != 'course.png') { |
3737 | 3737 | $thumbnails = $course_info['course_image']; |
3738 | 3738 | $image = $course_info['course_image_large']; |
3739 | - }else{ |
|
3739 | + } else{ |
|
3740 | 3740 | $image = Display::return_icon('session_default.png', null, null, null,null, true); |
3741 | 3741 | } |
3742 | 3742 | |
@@ -3998,7 +3998,7 @@ discard block |
||
3998 | 3998 | if ($showCustomIcon === 'true' && $iconName != 'course.png') { |
3999 | 3999 | $thumbnails = $course_info['course_image']; |
4000 | 4000 | $image = $course_info['course_image_large']; |
4001 | - }else{ |
|
4001 | + } else{ |
|
4002 | 4002 | $image = Display::return_icon('session_default.png', null, null, null,null, true); |
4003 | 4003 | } |
4004 | 4004 | $params['thumbnails'] = $thumbnails; |
@@ -9,9 +9,10 @@ |
||
9 | 9 | |
10 | 10 | // actions menu |
11 | 11 | $new_thematic_plan_data = array(); |
12 | -if (!empty($thematic_plan_data)) |
|
13 | -foreach($thematic_plan_data as $thematic_item) { |
|
12 | +if (!empty($thematic_plan_data)) { |
|
13 | + foreach($thematic_plan_data as $thematic_item) { |
|
14 | 14 | $thematic_simple_list[] = $thematic_item['description_type']; |
15 | +} |
|
15 | 16 | $new_thematic_plan_data[$thematic_item['description_type']] = $thematic_item; |
16 | 17 | } |
17 | 18 |
@@ -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 | /*********************************************************************************/ |
@@ -96,8 +98,9 @@ discard block |
||
96 | 98 | /** |
97 | 99 | * language = <Text identifying a language, as defined in [RFC 1766]> |
98 | 100 | */ |
99 | - if( defined( 'ICAL_LANG' )) |
|
100 | - $this->setConfig( 'language', ICAL_LANG ); |
|
101 | + if( defined( 'ICAL_LANG' )) { |
|
102 | + $this->setConfig( 'language', ICAL_LANG ); |
|
103 | + } |
|
101 | 104 | $this->setConfig( 'allowEmpty', TRUE ); |
102 | 105 | $this->setConfig( 'nl', "\n" ); |
103 | 106 | $this->setConfig( 'format', 'iCal'); |
@@ -120,7 +123,9 @@ discard block |
||
120 | 123 | * @return string |
121 | 124 | */ |
122 | 125 | function createCalscale() { |
123 | - if( empty( $this->calscale )) return FALSE; |
|
126 | + if( empty( $this->calscale )) { |
|
127 | + return FALSE; |
|
128 | + } |
|
124 | 129 | switch( $this->format ) { |
125 | 130 | case 'xcal': |
126 | 131 | return ' calscale="'.$this->calscale.'"'.$this->nl; |
@@ -139,7 +144,9 @@ discard block |
||
139 | 144 | * @return void |
140 | 145 | */ |
141 | 146 | function setCalscale( $value ) { |
142 | - if( empty( $value )) return FALSE; |
|
147 | + if( empty( $value )) { |
|
148 | + return FALSE; |
|
149 | + } |
|
143 | 150 | $this->calscale = $value; |
144 | 151 | } |
145 | 152 | /*********************************************************************************/ |
@@ -154,7 +161,9 @@ discard block |
||
154 | 161 | * @return string |
155 | 162 | */ |
156 | 163 | function createMethod() { |
157 | - if( empty( $this->method )) return FALSE; |
|
164 | + if( empty( $this->method )) { |
|
165 | + return FALSE; |
|
166 | + } |
|
158 | 167 | switch( $this->format ) { |
159 | 168 | case 'xcal': |
160 | 169 | return ' method="'.$this->method.'"'.$this->nl; |
@@ -173,7 +182,9 @@ discard block |
||
173 | 182 | * @return bool |
174 | 183 | */ |
175 | 184 | function setMethod( $value ) { |
176 | - if( empty( $value )) return FALSE; |
|
185 | + if( empty( $value )) { |
|
186 | + return FALSE; |
|
187 | + } |
|
177 | 188 | $this->method = $value; |
178 | 189 | return TRUE; |
179 | 190 | } |
@@ -193,8 +204,9 @@ discard block |
||
193 | 204 | * @return string |
194 | 205 | */ |
195 | 206 | function createProdid() { |
196 | - if( !isset( $this->prodid )) |
|
197 | - $this->_makeProdid(); |
|
207 | + if( !isset( $this->prodid )) { |
|
208 | + $this->_makeProdid(); |
|
209 | + } |
|
198 | 210 | switch( $this->format ) { |
199 | 211 | case 'xcal': |
200 | 212 | return ' prodid="'.$this->prodid.'"'.$this->nl; |
@@ -245,8 +257,9 @@ discard block |
||
245 | 257 | * @return string |
246 | 258 | */ |
247 | 259 | function createVersion() { |
248 | - if( empty( $this->version )) |
|
249 | - $this->_makeVersion(); |
|
260 | + if( empty( $this->version )) { |
|
261 | + $this->_makeVersion(); |
|
262 | + } |
|
250 | 263 | switch( $this->format ) { |
251 | 264 | case 'xcal': |
252 | 265 | return ' version="'.$this->version.'"'.$this->nl; |
@@ -275,7 +288,9 @@ discard block |
||
275 | 288 | * @return void |
276 | 289 | */ |
277 | 290 | function setVersion( $value ) { |
278 | - if( empty( $value )) return FALSE; |
|
291 | + if( empty( $value )) { |
|
292 | + return FALSE; |
|
293 | + } |
|
279 | 294 | $this->version = $value; |
280 | 295 | return TRUE; |
281 | 296 | } |
@@ -291,10 +306,12 @@ discard block |
||
291 | 306 | * @return string |
292 | 307 | */ |
293 | 308 | function createXprop() { |
294 | - if( 'xcal' == $this->format ) |
|
295 | - return false; |
|
296 | - if( 0 >= count( $this->xprop )) |
|
297 | - return; |
|
309 | + if( 'xcal' == $this->format ) { |
|
310 | + return false; |
|
311 | + } |
|
312 | + if( 0 >= count( $this->xprop )) { |
|
313 | + return; |
|
314 | + } |
|
298 | 315 | $output = null; |
299 | 316 | $toolbox = new calendarComponent(); |
300 | 317 | $toolbox->setConfig( 'language', $this->getConfig( 'language' )); |
@@ -307,12 +324,13 @@ discard block |
||
307 | 324 | } |
308 | 325 | $attributes = $toolbox->_createParams( $xpropPart['params'], array( 'LANGUAGE' )); |
309 | 326 | if( is_array( $xpropPart['value'] )) { |
310 | - foreach( $xpropPart['value'] as $pix => $theXpart ) |
|
311 | - $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart ); |
|
327 | + foreach( $xpropPart['value'] as $pix => $theXpart ) { |
|
328 | + $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart ); |
|
329 | + } |
|
312 | 330 | $xpropPart['value'] = implode( ',', $xpropPart['value'] ); |
331 | + } else { |
|
332 | + $xpropPart['value'] = $toolbox->_strrep( $xpropPart['value'] ); |
|
313 | 333 | } |
314 | - else |
|
315 | - $xpropPart['value'] = $toolbox->_strrep( $xpropPart['value'] ); |
|
316 | 334 | $output .= $toolbox->_createElement( $label, $attributes, $xpropPart['value'] ); |
317 | 335 | } |
318 | 336 | return $output; |
@@ -328,12 +346,20 @@ discard block |
||
328 | 346 | * @return bool |
329 | 347 | */ |
330 | 348 | function setXprop($label, $value, $params = array()) { |
331 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
332 | - if( empty( $label )) return FALSE; |
|
349 | + if( empty( $value )) { |
|
350 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
351 | + } else { |
|
352 | + return FALSE; |
|
353 | + } |
|
354 | + if( empty( $label )) { |
|
355 | + return FALSE; |
|
356 | + } |
|
333 | 357 | $xprop = array( 'value' => $value ); |
334 | 358 | $toolbox = new calendarComponent(); |
335 | 359 | $xprop['params'] = $toolbox->_setParams( $params ); |
336 | - if( !is_array( $this->xprop )) $this->xprop = array(); |
|
360 | + if( !is_array( $this->xprop )) { |
|
361 | + $this->xprop = array(); |
|
362 | + } |
|
337 | 363 | $this->xprop[strtoupper( $label )] = $xprop; |
338 | 364 | return TRUE; |
339 | 365 | } |
@@ -349,8 +375,9 @@ discard block |
||
349 | 375 | */ |
350 | 376 | function deleteProperty( $propName, $propix = FALSE ) { |
351 | 377 | $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP'; |
352 | - if( !$propix ) |
|
353 | - $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1; |
|
378 | + if( !$propix ) { |
|
379 | + $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1; |
|
380 | + } |
|
354 | 381 | $this->propdelix[$propName] = --$propix; |
355 | 382 | $return = FALSE; |
356 | 383 | switch( $propName ) { |
@@ -369,18 +396,23 @@ discard block |
||
369 | 396 | default: |
370 | 397 | $reduced = array(); |
371 | 398 | if( $propName != 'X-PROP' ) { |
372 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
399 | + if( !isset( $this->xprop[$propName] )) { |
|
400 | + return FALSE; |
|
401 | + } |
|
373 | 402 | foreach( $this->xprop as $k => $a ) { |
374 | - if(( $k != $propName ) && !empty( $a )) |
|
375 | - $reduced[$k] = $a; |
|
403 | + if(( $k != $propName ) && !empty( $a )) { |
|
404 | + $reduced[$k] = $a; |
|
405 | + } |
|
406 | + } |
|
407 | + } else { |
|
408 | + if( count( $this->xprop ) <= $propix ) { |
|
409 | + return FALSE; |
|
376 | 410 | } |
377 | - } |
|
378 | - else { |
|
379 | - if( count( $this->xprop ) <= $propix ) return FALSE; |
|
380 | 411 | $xpropno = 0; |
381 | 412 | foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
382 | - if( $propix != $xpropno ) |
|
383 | - $reduced[$xpropkey] = $xpropvalue; |
|
413 | + if( $propix != $xpropno ) { |
|
414 | + $reduced[$xpropkey] = $xpropvalue; |
|
415 | + } |
|
384 | 416 | $xpropno++; |
385 | 417 | } |
386 | 418 | } |
@@ -402,8 +434,9 @@ discard block |
||
402 | 434 | function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE ) { |
403 | 435 | $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP'; |
404 | 436 | if( 'X-PROP' == $propName ) { |
405 | - if( !$propix ) |
|
406 | - $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; |
|
437 | + if( !$propix ) { |
|
438 | + $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; |
|
439 | + } |
|
407 | 440 | $this->propix[$propName] = --$propix; |
408 | 441 | } |
409 | 442 | switch( $propName ) { |
@@ -414,8 +447,9 @@ discard block |
||
414 | 447 | return ( !empty( $this->method )) ? $this->method : null; |
415 | 448 | break; |
416 | 449 | case 'PRODID': |
417 | - if( empty( $this->prodid )) |
|
418 | - $this->_makeProdid(); |
|
450 | + if( empty( $this->prodid )) { |
|
451 | + $this->_makeProdid(); |
|
452 | + } |
|
419 | 453 | return $this->prodid; |
420 | 454 | break; |
421 | 455 | case 'VERSION': |
@@ -423,19 +457,23 @@ discard block |
||
423 | 457 | break; |
424 | 458 | default: |
425 | 459 | if( $propName != 'X-PROP' ) { |
426 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
460 | + if( !isset( $this->xprop[$propName] )) { |
|
461 | + return FALSE; |
|
462 | + } |
|
427 | 463 | return ( $inclParam ) ? array( $propName, $this->xprop[$propName] ) |
428 | 464 | : array( $propName, $this->xprop[$propName]['value'] ); |
429 | - } |
|
430 | - else { |
|
431 | - if( empty( $this->xprop )) return FALSE; |
|
465 | + } else { |
|
466 | + if( empty( $this->xprop )) { |
|
467 | + return FALSE; |
|
468 | + } |
|
432 | 469 | $xpropno = 0; |
433 | 470 | foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
434 | - if( $propix == $xpropno ) |
|
435 | - return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) |
|
471 | + if( $propix == $xpropno ) { |
|
472 | + return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) |
|
436 | 473 | : array( $xpropkey, $this->xprop[$xpropkey]['value'] ); |
437 | - else |
|
438 | - $xpropno++; |
|
474 | + } else { |
|
475 | + $xpropno++; |
|
476 | + } |
|
439 | 477 | } |
440 | 478 | return FALSE; // not found ?? |
441 | 479 | } |
@@ -454,8 +492,9 @@ discard block |
||
454 | 492 | */ |
455 | 493 | function setProperty () { |
456 | 494 | $numargs = func_num_args(); |
457 | - if( 1 > $numargs ) |
|
458 | - return FALSE; |
|
495 | + if( 1 > $numargs ) { |
|
496 | + return FALSE; |
|
497 | + } |
|
459 | 498 | $arglist = func_get_args(); |
460 | 499 | $arglist[0] = strtoupper( $arglist[0] ); |
461 | 500 | switch( $arglist[0] ) { |
@@ -466,8 +505,12 @@ discard block |
||
466 | 505 | case 'VERSION': |
467 | 506 | return $this->setVersion( $arglist[1] ); |
468 | 507 | default: |
469 | - if( !isset( $arglist[1] )) $arglist[1] = null; |
|
470 | - if( !isset( $arglist[2] )) $arglist[2] = null; |
|
508 | + if( !isset( $arglist[1] )) { |
|
509 | + $arglist[1] = null; |
|
510 | + } |
|
511 | + if( !isset( $arglist[2] )) { |
|
512 | + $arglist[2] = null; |
|
513 | + } |
|
471 | 514 | return $this->setXprop( $arglist[0], $arglist[1], $arglist[2] ); |
472 | 515 | } |
473 | 516 | } |
@@ -489,7 +532,9 @@ discard block |
||
489 | 532 | unset( $this->compix ); |
490 | 533 | $info = array(); |
491 | 534 | foreach( $this->components as $cix => $component ) { |
492 | - if( empty( $component )) continue; |
|
535 | + if( empty( $component )) { |
|
536 | + continue; |
|
537 | + } |
|
493 | 538 | unset( $component->propix ); |
494 | 539 | $info[$cix]['ordno'] = $cix + 1; |
495 | 540 | $info[$cix]['type'] = $component->objName; |
@@ -504,8 +549,9 @@ discard block |
||
504 | 549 | return $this->delimiter; |
505 | 550 | break; |
506 | 551 | case 'DIRECTORY': |
507 | - if( empty( $this->directory )) |
|
508 | - $this->directory = '.'; |
|
552 | + if( empty( $this->directory )) { |
|
553 | + $this->directory = '.'; |
|
554 | + } |
|
509 | 555 | return $this->directory; |
510 | 556 | break; |
511 | 557 | case 'DIRFILE': |
@@ -518,10 +564,13 @@ discard block |
||
518 | 564 | break; |
519 | 565 | case 'FILENAME': |
520 | 566 | if( empty( $this->filename )) { |
521 | - if( 'xcal' == $this->format ) |
|
522 | - $this->filename = date( 'YmdHis' ).'.xml'; // recommended xcs.. . |
|
523 | - else |
|
524 | - $this->filename = date( 'YmdHis' ).'.ics'; |
|
567 | + if( 'xcal' == $this->format ) { |
|
568 | + $this->filename = date( 'YmdHis' ).'.xml'; |
|
569 | + } |
|
570 | + // recommended xcs.. . |
|
571 | + else { |
|
572 | + $this->filename = date( 'YmdHis' ).'.ics'; |
|
573 | + } |
|
525 | 574 | } |
526 | 575 | return $this->filename; |
527 | 576 | break; |
@@ -529,8 +578,9 @@ discard block |
||
529 | 578 | $size = 0; |
530 | 579 | if( empty( $this->url )) { |
531 | 580 | $dirfile = $this->getConfig( 'dirfile' ); |
532 | - if( FALSE === ( $size = filesize( $dirfile ))) |
|
533 | - $size = 0; |
|
581 | + if( FALSE === ( $size = filesize( $dirfile ))) { |
|
582 | + $size = 0; |
|
583 | + } |
|
534 | 584 | clearstatcache(); |
535 | 585 | } |
536 | 586 | return $size; |
@@ -550,10 +600,11 @@ discard block |
||
550 | 600 | return $this->unique_id; |
551 | 601 | break; |
552 | 602 | case 'URL': |
553 | - if( !empty( $this->url )) |
|
554 | - return $this->url; |
|
555 | - else |
|
556 | - return FALSE; |
|
603 | + if( !empty( $this->url )) { |
|
604 | + return $this->url; |
|
605 | + } else { |
|
606 | + return FALSE; |
|
607 | + } |
|
557 | 608 | // no break needed |
558 | 609 | } |
559 | 610 | } |
@@ -581,8 +632,9 @@ discard block |
||
581 | 632 | case 'DIRECTORY': |
582 | 633 | $value = trim( $value ); |
583 | 634 | $nl = $this->getConfig('delimiter'); |
584 | - if( $nl == substr( $value, ( 0 - strlen( $nl )))) |
|
585 | - $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl ))); |
|
635 | + if( $nl == substr( $value, ( 0 - strlen( $nl )))) { |
|
636 | + $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl ))); |
|
637 | + } |
|
586 | 638 | if( is_dir( $value )) { |
587 | 639 | /* local directory */ |
588 | 640 | clearstatcache(); |
@@ -610,8 +662,7 @@ discard block |
||
610 | 662 | } else { |
611 | 663 | return FALSE; |
612 | 664 | } |
613 | - } |
|
614 | - elseif( FALSE !== touch( $dirfile )) { |
|
665 | + } elseif( FALSE !== touch( $dirfile )) { |
|
615 | 666 | /* new local file created */ |
616 | 667 | $this->filename = $value; |
617 | 668 | return TRUE; |
@@ -625,8 +676,7 @@ discard block |
||
625 | 676 | $this->format = 'xcal'; |
626 | 677 | $this->attributeDelimiter = $this->nl; |
627 | 678 | $this->valueInit = null; |
628 | - } |
|
629 | - else { |
|
679 | + } else { |
|
630 | 680 | $this->format = null; |
631 | 681 | $this->attributeDelimiter = ';'; |
632 | 682 | $this->valueInit = ':'; |
@@ -665,13 +715,16 @@ discard block |
||
665 | 715 | return $this->setConfig( 'filename', $parts['basename'] ); |
666 | 716 | break; |
667 | 717 | } |
668 | - if( !$res ) return FALSE; |
|
718 | + if( !$res ) { |
|
719 | + return FALSE; |
|
720 | + } |
|
669 | 721 | if( isset( $subcfg ) && !empty( $this->components )) { |
670 | 722 | foreach( $subcfg as $cfgkey => $cfgvalue ) { |
671 | 723 | foreach( $this->components as $cix => $component ) { |
672 | 724 | $res = $component->setConfig( $cfgkey, $cfgvalue ); |
673 | - if( !$res ) |
|
674 | - break 2; |
|
725 | + if( !$res ) { |
|
726 | + break 2; |
|
727 | + } |
|
675 | 728 | $this->components[$cix] = $component->copy(); // PHP4 compliant |
676 | 729 | } |
677 | 730 | } |
@@ -706,27 +759,26 @@ discard block |
||
706 | 759 | if ( ctype_digit( (string) $arg1 )) { |
707 | 760 | $argType = 'INDEX'; |
708 | 761 | $index = (int) $arg1 - 1; |
709 | - } |
|
710 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
762 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
711 | 763 | $argType = strtolower( $arg1 ); |
712 | 764 | $index = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0; |
713 | 765 | } |
714 | 766 | $cix1dC = 0; |
715 | 767 | foreach ( $this->components as $cix => $component) { |
716 | - if( empty( $component )) continue; |
|
768 | + if( empty( $component )) { |
|
769 | + continue; |
|
770 | + } |
|
717 | 771 | unset( $component->propix ); |
718 | 772 | if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
719 | 773 | unset( $this->components[$cix] ); |
720 | 774 | return TRUE; |
721 | - } |
|
722 | - elseif( $argType == $component->objName ) { |
|
775 | + } elseif( $argType == $component->objName ) { |
|
723 | 776 | if( $index == $cix1dC ) { |
724 | 777 | unset( $this->components[$cix] ); |
725 | 778 | return TRUE; |
726 | 779 | } |
727 | 780 | $cix1dC++; |
728 | - } |
|
729 | - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
781 | + } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
730 | 782 | unset( $this->components[$cix] ); |
731 | 783 | return TRUE; |
732 | 784 | } |
@@ -748,37 +800,39 @@ discard block |
||
748 | 800 | $argType = 'INDEX'; |
749 | 801 | $index = $this->compix['INDEX'] = |
750 | 802 | ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1; |
751 | - } |
|
752 | - elseif ( ctype_digit( (string) $arg1 )) { |
|
803 | + } elseif ( ctype_digit( (string) $arg1 )) { |
|
753 | 804 | $argType = 'INDEX'; |
754 | 805 | $index = (int) $arg1; |
755 | 806 | unset( $this->compix ); |
756 | - } |
|
757 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
807 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
758 | 808 | unset( $this->compix['INDEX'] ); |
759 | 809 | $argType = strtolower( $arg1 ); |
760 | - if( !$arg2 ) |
|
761 | - $index = $this->compix[$argType] = |
|
810 | + if( !$arg2 ) { |
|
811 | + $index = $this->compix[$argType] = |
|
762 | 812 | ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1; |
763 | - else |
|
764 | - $index = (int) $arg2; |
|
813 | + } else { |
|
814 | + $index = (int) $arg2; |
|
815 | + } |
|
765 | 816 | } |
766 | 817 | $index -= 1; |
767 | 818 | $ckeys = array_keys( $this->components ); |
768 | - if( !empty( $index) && ( $index > end( $ckeys ))) |
|
769 | - return FALSE; |
|
819 | + if( !empty( $index) && ( $index > end( $ckeys ))) { |
|
820 | + return FALSE; |
|
821 | + } |
|
770 | 822 | $cix1gC = 0; |
771 | 823 | foreach ( $this->components as $cix => $component) { |
772 | - if( empty( $component )) continue; |
|
824 | + if( empty( $component )) { |
|
825 | + continue; |
|
826 | + } |
|
773 | 827 | unset( $component->propix ); |
774 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) |
|
775 | - return $component->copy(); |
|
776 | - elseif( $argType == $component->objName ) { |
|
777 | - if( $index == $cix1gC ) |
|
778 | - return $component->copy(); |
|
828 | + if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
|
829 | + return $component->copy(); |
|
830 | + } elseif( $argType == $component->objName ) { |
|
831 | + if( $index == $cix1gC ) { |
|
832 | + return $component->copy(); |
|
833 | + } |
|
779 | 834 | $cix1gC++; |
780 | - } |
|
781 | - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
835 | + } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
782 | 836 | unset( $component->propix ); |
783 | 837 | return $component->copy(); |
784 | 838 | } |
@@ -813,46 +867,68 @@ discard block |
||
813 | 867 | */ |
814 | 868 | function selectComponents( $startY=FALSE, $startM=FALSE, $startD=FALSE, $endY=FALSE, $endM=FALSE, $endD=FALSE, $cType=FALSE, $flat=FALSE, $any=TRUE, $split=TRUE ) { |
815 | 869 | /* check if empty calendar */ |
816 | - if( 0 >= count( $this->components )) return FALSE; |
|
870 | + if( 0 >= count( $this->components )) { |
|
871 | + return FALSE; |
|
872 | + } |
|
817 | 873 | /* check default dates */ |
818 | - if( !$startY ) $startY = date( 'Y' ); |
|
819 | - if( !$startM ) $startM = date( 'm' ); |
|
820 | - if( !$startD ) $startD = date( 'd' ); |
|
874 | + if( !$startY ) { |
|
875 | + $startY = date( 'Y' ); |
|
876 | + } |
|
877 | + if( !$startM ) { |
|
878 | + $startM = date( 'm' ); |
|
879 | + } |
|
880 | + if( !$startD ) { |
|
881 | + $startD = date( 'd' ); |
|
882 | + } |
|
821 | 883 | $startDate = mktime( 0, 0, 0, $startM, $startD, $startY ); |
822 | - if( !$endY ) $endY = $startY; |
|
823 | - if( !$endM ) $endM = $startM; |
|
824 | - if( !$endD ) $endD = $startD; |
|
884 | + if( !$endY ) { |
|
885 | + $endY = $startY; |
|
886 | + } |
|
887 | + if( !$endM ) { |
|
888 | + $endM = $startM; |
|
889 | + } |
|
890 | + if( !$endD ) { |
|
891 | + $endD = $startD; |
|
892 | + } |
|
825 | 893 | $endDate = mktime( 23, 59, 59, $endM, $endD, $endY ); |
826 | 894 | /* check component types */ |
827 | 895 | $validTypes = array('vevent', 'vtodo', 'vjournal', 'vfreebusy' ); |
828 | 896 | if( is_array( $cType )) { |
829 | 897 | foreach( $cType as $cix => $theType ) { |
830 | 898 | $cType[$cix] = $theType = strtolower( $theType ); |
831 | - if( !in_array( $theType, $validTypes )) |
|
832 | - $cType[$cix] = 'vevent'; |
|
899 | + if( !in_array( $theType, $validTypes )) { |
|
900 | + $cType[$cix] = 'vevent'; |
|
901 | + } |
|
833 | 902 | } |
834 | 903 | $cType = array_unique( $cType ); |
835 | - } |
|
836 | - elseif( !empty( $cType )) { |
|
904 | + } elseif( !empty( $cType )) { |
|
837 | 905 | $cType = strtolower( $cType ); |
838 | - if( !in_array( $cType, $validTypes )) |
|
839 | - $cType = array( 'vevent' ); |
|
840 | - else |
|
841 | - $cType = array( $cType ); |
|
842 | - } |
|
843 | - else |
|
844 | - $cType = $validTypes; |
|
845 | - if( 0 >= count( $cType )) |
|
846 | - $cType = $validTypes; |
|
906 | + if( !in_array( $cType, $validTypes )) { |
|
907 | + $cType = array( 'vevent' ); |
|
908 | + } else { |
|
909 | + $cType = array( $cType ); |
|
910 | + } |
|
911 | + } else { |
|
912 | + $cType = $validTypes; |
|
913 | + } |
|
914 | + if( 0 >= count( $cType )) { |
|
915 | + $cType = $validTypes; |
|
916 | + } |
|
847 | 917 | /* iterate components */ |
848 | 918 | $result = array(); |
849 | 919 | foreach ( $this->components as $cix => $component ) { |
850 | - if( empty( $component )) continue; |
|
920 | + if( empty( $component )) { |
|
921 | + continue; |
|
922 | + } |
|
851 | 923 | unset( $component->propix, $start ); |
852 | 924 | /* deselect unvalid type components */ |
853 | - if( !in_array( $component->objName, $cType )) continue; |
|
925 | + if( !in_array( $component->objName, $cType )) { |
|
926 | + continue; |
|
927 | + } |
|
854 | 928 | /* deselect components without dtstart set */ |
855 | - if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) continue; |
|
929 | + if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) { |
|
930 | + continue; |
|
931 | + } |
|
856 | 932 | $dtendExist = $dueExist = $durationExist = $endAllDayEvent = FALSE; |
857 | 933 | unset( $end, $startWdate, $endWdate, $rdurWsecs, $rdur, $exdatelist, $workstart, $workend ); // clean up |
858 | 934 | $startWdate = $component->_date2timestamp( $start ); |
@@ -886,8 +962,9 @@ discard block |
||
886 | 962 | } |
887 | 963 | if( empty( $end )) { |
888 | 964 | $end = $component->getProperty( 'duration', FALSE, FALSE, TRUE );// in dtend (array) format |
889 | - if( !empty( $end )) |
|
890 | - $durationExist = TRUE; |
|
965 | + if( !empty( $end )) { |
|
966 | + $durationExist = TRUE; |
|
967 | + } |
|
891 | 968 | // if( !empty($end)) echo 'selectComp 4 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ### |
892 | 969 | } |
893 | 970 | if( empty( $end )) { // assume one day duration if missing end date |
@@ -905,55 +982,75 @@ discard block |
||
905 | 982 | $exdatelist = array(); |
906 | 983 | $workstart = $component->_timestamp2date(( $startDate - $rdurWsecs ), 6); |
907 | 984 | $workend = $component->_timestamp2date(( $endDate + $rdurWsecs ), 6); |
908 | - while( FALSE !== ( $exrule = $component->getProperty( 'exrule' ))) // check exrule |
|
985 | + while( FALSE !== ( $exrule = $component->getProperty( 'exrule' ))) { |
|
986 | + // check exrule |
|
909 | 987 | $component->_recur2date( $exdatelist, $exrule, $start, $workstart, $workend ); |
988 | + } |
|
910 | 989 | while( FALSE !== ( $exdate = $component->getProperty( 'exdate' ))) { // check exdate |
911 | 990 | foreach( $exdate as $theExdate ) { |
912 | 991 | $exWdate = $component->_date2timestamp( $theExdate ); |
913 | - if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate )) |
|
914 | - $exdatelist[$exWdate] = TRUE; |
|
992 | + if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate )) { |
|
993 | + $exdatelist[$exWdate] = TRUE; |
|
994 | + } |
|
915 | 995 | } |
916 | 996 | } |
917 | 997 | /* if 'any' components, check repeating components, removing all excluding dates */ |
918 | 998 | if( TRUE === $any ) { |
919 | 999 | /* make a list of optional repeating dates for component occurence, rrule, rdate */ |
920 | 1000 | $recurlist = array(); |
921 | - while( FALSE !== ( $rrule = $component->getProperty( 'rrule' ))) // check rrule |
|
1001 | + while( FALSE !== ( $rrule = $component->getProperty( 'rrule' ))) { |
|
1002 | + // check rrule |
|
922 | 1003 | $component->_recur2date( $recurlist, $rrule, $start, $workstart, $workend ); |
923 | - foreach( $recurlist as $recurkey => $recurvalue ) // key=match date as timestamp |
|
924 | - $recurlist[$recurkey] = $rdurWsecs; // add duration in seconds |
|
1004 | + } |
|
1005 | + foreach( $recurlist as $recurkey => $recurvalue ) { |
|
1006 | + // key=match date as timestamp |
|
1007 | + $recurlist[$recurkey] = $rdurWsecs; |
|
1008 | + } |
|
1009 | + // add duration in seconds |
|
925 | 1010 | while( FALSE !== ( $rdate = $component->getProperty( 'rdate' ))) { // check rdate |
926 | 1011 | foreach( $rdate as $theRdate ) { |
927 | 1012 | if( is_array( $theRdate ) && ( 2 == count( $theRdate )) && // all days within PERIOD |
928 | 1013 | array_key_exists( '0', $theRdate ) && array_key_exists( '1', $theRdate )) { |
929 | 1014 | $rstart = $component->_date2timestamp( $theRdate[0] ); |
930 | - if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate )) |
|
931 | - continue; |
|
932 | - if( isset( $theRdate[1]['year'] )) // date-date period |
|
1015 | + if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate )) { |
|
1016 | + continue; |
|
1017 | + } |
|
1018 | + if( isset( $theRdate[1]['year'] )) { |
|
1019 | + // date-date period |
|
933 | 1020 | $rend = $component->_date2timestamp( $theRdate[1] ); |
934 | - else { // date-duration period |
|
1021 | + } else { // date-duration period |
|
935 | 1022 | $rend = $component->duration2date( $theRdate[0], $theRdate[1] ); |
936 | 1023 | $rend = $component->_date2timestamp( $rend ); |
937 | 1024 | } |
938 | - if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart )) |
|
939 | - $recurlist[$rstart] = ( $rstart - $rend ); // set start date + rdate duration in seconds |
|
1025 | + if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart )) { |
|
1026 | + $recurlist[$rstart] = ( $rstart - $rend ); |
|
1027 | + } |
|
1028 | + // set start date + rdate duration in seconds |
|
940 | 1029 | } // PERIOD end |
941 | 1030 | else { // single date |
942 | 1031 | $theRdate = $component->_date2timestamp( $theRdate ); |
943 | - if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate )) |
|
944 | - $recurlist[$theRdate] = $rdurWsecs; // set start date + event duration in seconds |
|
1032 | + if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate )) { |
|
1033 | + $recurlist[$theRdate] = $rdurWsecs; |
|
1034 | + } |
|
1035 | + // set start date + event duration in seconds |
|
945 | 1036 | } |
946 | 1037 | } |
947 | 1038 | } |
948 | 1039 | if( 0 < count( $recurlist )) { |
949 | 1040 | ksort( $recurlist ); |
950 | 1041 | foreach( $recurlist as $recurkey => $durvalue ) { |
951 | - if((( $startDate - $rdurWsecs ) > $recurkey ) || ( $endDate < $recurkey )) // not within period |
|
1042 | + if((( $startDate - $rdurWsecs ) > $recurkey ) || ( $endDate < $recurkey )) { |
|
1043 | + // not within period |
|
952 | 1044 | continue; |
953 | - if( isset( $exdatelist[$recurkey] )) // check excluded dates |
|
1045 | + } |
|
1046 | + if( isset( $exdatelist[$recurkey] )) { |
|
1047 | + // check excluded dates |
|
954 | 1048 | continue; |
955 | - if( $startWdate >= $recurkey ) // exclude component start date |
|
1049 | + } |
|
1050 | + if( $startWdate >= $recurkey ) { |
|
1051 | + // exclude component start date |
|
956 | 1052 | continue; |
1053 | + } |
|
957 | 1054 | $component2 = $component->copy(); |
958 | 1055 | $rstart = $component2->_timestamp2date( $recurkey, 6); |
959 | 1056 | $datevalue = $rstart['month'].'/'.$rstart['day'].'/'.$rstart['year']; |
@@ -963,16 +1060,16 @@ discard block |
||
963 | 1060 | $datevalue .= ( isset( $rstart['sec'] )) ? ':'.$rstart['sec'] : ':00'; |
964 | 1061 | } |
965 | 1062 | $datestring = date( $startDateFormat, strtotime( $datevalue )); |
966 | - if( isset( $start['tz'] )) |
|
967 | - $datestring .= ' '.$start['tz']; |
|
1063 | + if( isset( $start['tz'] )) { |
|
1064 | + $datestring .= ' '.$start['tz']; |
|
1065 | + } |
|
968 | 1066 | $component2->setProperty( 'X-CURRENT-DTSTART', $datestring ); |
969 | 1067 | $rend = $component2->_timestamp2date(( $recurkey + $durvalue ), 6); |
970 | 1068 | if( $dtendExist || $dueExist ) { |
971 | 1069 | if( $endAllDayEvent ) { |
972 | 1070 | $rend2 = mktime( 0, 0, 0, $rend['month'], ($rend['day'] + 1), $rend['year'] ); |
973 | 1071 | $datevalue = date( 'm', $rend2 ).'/'.date( 'd', $rend2 ).'/'.date( 'Y', $rend2 ); |
974 | - } |
|
975 | - else { |
|
1072 | + } else { |
|
976 | 1073 | $datevalue = $rend['month'].'/'.$rend['day'].'/'.$rend['year']; |
977 | 1074 | if( isset( $end['hour'] ) || isset( $end['min'] ) || isset( $end['sec'] )) { |
978 | 1075 | $datevalue .= ( isset( $rend['hour'] )) ? ' '.$rend['hour'] : ' 00'; |
@@ -981,30 +1078,37 @@ discard block |
||
981 | 1078 | } |
982 | 1079 | } |
983 | 1080 | $datestring = date( $endDateFormat, strtotime( $datevalue )); |
984 | - if( isset( $end['tz'] )) |
|
985 | - $datestring .= ' '.$end['tz']; |
|
986 | - if( $dtendExist ) |
|
987 | - $component2->setProperty( 'X-CURRENT-DTEND', $datestring ); |
|
988 | - elseif( $dueExist ) |
|
989 | - $component2->setProperty( 'X-CURRENT-DUE', $datestring ); |
|
1081 | + if( isset( $end['tz'] )) { |
|
1082 | + $datestring .= ' '.$end['tz']; |
|
1083 | + } |
|
1084 | + if( $dtendExist ) { |
|
1085 | + $component2->setProperty( 'X-CURRENT-DTEND', $datestring ); |
|
1086 | + } elseif( $dueExist ) { |
|
1087 | + $component2->setProperty( 'X-CURRENT-DUE', $datestring ); |
|
1088 | + } |
|
990 | 1089 | } |
991 | 1090 | $rend = $component2->_date2timestamp( $rend ); |
992 | 1091 | $rstart = $recurkey; |
993 | 1092 | /* add repeating components within valid dates to output array, only start date */ |
994 | - if( $flat ) |
|
995 | - $result[] = $component2->copy(); // copy to output |
|
1093 | + if( $flat ) { |
|
1094 | + $result[] = $component2->copy(); |
|
1095 | + } |
|
1096 | + // copy to output |
|
996 | 1097 | elseif( $split ) { |
997 | - if( $rend > $endDate ) |
|
998 | - $rend = $endDate; |
|
1098 | + if( $rend > $endDate ) { |
|
1099 | + $rend = $endDate; |
|
1100 | + } |
|
999 | 1101 | while( $rstart <= $rend ) { // iterate |
1000 | 1102 | $wd = getdate( $rstart ); |
1001 | 1103 | if(( $rstart > $startDate ) && // date after dtstart |
1002 | - !isset( $exdatelist[$rstart] )) // check exclude date |
|
1003 | - $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output |
|
1104 | + !isset( $exdatelist[$rstart] )) { |
|
1105 | + // check exclude date |
|
1106 | + $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); |
|
1107 | + } |
|
1108 | + // copy to output |
|
1004 | 1109 | $rstart += ( 24*60*60 ); // step one day |
1005 | 1110 | } |
1006 | - } |
|
1007 | - elseif(( $rstart >= $startDate ) && // date within period |
|
1111 | + } elseif(( $rstart >= $startDate ) && // date within period |
|
1008 | 1112 | !isset( $exdatelist[$rstart] )) { // check exclude date |
1009 | 1113 | $wd = getdate( $rstart ); |
1010 | 1114 | $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output |
@@ -1012,19 +1116,29 @@ discard block |
||
1012 | 1116 | } |
1013 | 1117 | } |
1014 | 1118 | /* deselect components with startdate/enddate not within period */ |
1015 | - if(( $endWdate < $startDate ) || ( $startWdate > $endDate )) continue; |
|
1119 | + if(( $endWdate < $startDate ) || ( $startWdate > $endDate )) { |
|
1120 | + continue; |
|
1121 | + } |
|
1016 | 1122 | } |
1017 | 1123 | /* deselect components with startdate not within period */ |
1018 | - elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) continue; |
|
1124 | + elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) { |
|
1125 | + continue; |
|
1126 | + } |
|
1019 | 1127 | /* add selected components within valid dates to output array */ |
1020 | - if( $flat ) |
|
1021 | - $result[] = $component->copy(); // copy to output; |
|
1128 | + if( $flat ) { |
|
1129 | + $result[] = $component->copy(); |
|
1130 | + } |
|
1131 | + // copy to output; |
|
1022 | 1132 | elseif( $split ) { |
1023 | - if( $endWdate > $endDate ) |
|
1024 | - $endWdate = $endDate; // use period end date |
|
1133 | + if( $endWdate > $endDate ) { |
|
1134 | + $endWdate = $endDate; |
|
1135 | + } |
|
1136 | + // use period end date |
|
1025 | 1137 | if( !isset( $exdatelist[$startWdate] )) { // check excluded dates |
1026 | - if( $startWdate < $startDate ) |
|
1027 | - $startWdate = $startDate; // use period start date |
|
1138 | + if( $startWdate < $startDate ) { |
|
1139 | + $startWdate = $startDate; |
|
1140 | + } |
|
1141 | + // use period start date |
|
1028 | 1142 | while( $startWdate <= $endWdate ) { // iterate |
1029 | 1143 | $wd = getdate( $startWdate ); |
1030 | 1144 | $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output |
@@ -1038,8 +1152,9 @@ discard block |
||
1038 | 1152 | $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output |
1039 | 1153 | } |
1040 | 1154 | } |
1041 | - if( 0 >= count( $result )) return FALSE; |
|
1042 | - elseif( !$flat ) { |
|
1155 | + if( 0 >= count( $result )) { |
|
1156 | + return FALSE; |
|
1157 | + } elseif( !$flat ) { |
|
1043 | 1158 | foreach( $result as $y => $yeararr ) { |
1044 | 1159 | foreach( $yeararr as $m => $montharr ) { |
1045 | 1160 | ksort( $result[$y][$m] ); |
@@ -1061,8 +1176,9 @@ discard block |
||
1061 | 1176 | * @return void |
1062 | 1177 | */ |
1063 | 1178 | function setComponent( $component, $arg1=FALSE, $arg2=FALSE ) { |
1064 | - if( '' >= $component->getConfig( 'language')) |
|
1065 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
1179 | + if( '' >= $component->getConfig( 'language')) { |
|
1180 | + $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
1181 | + } |
|
1066 | 1182 | $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
1067 | 1183 | $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
1068 | 1184 | $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
@@ -1081,27 +1197,26 @@ discard block |
||
1081 | 1197 | if ( ctype_digit( (string) $arg1 )) { |
1082 | 1198 | $argType = 'INDEX'; |
1083 | 1199 | $index = (int) $arg1 - 1; |
1084 | - } |
|
1085 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
1200 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
1086 | 1201 | $argType = strtolower( $arg1 ); |
1087 | 1202 | $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0; |
1088 | 1203 | } |
1089 | 1204 | $cix1sC = 0; |
1090 | 1205 | foreach ( $this->components as $cix => $component2) { |
1091 | - if( empty( $component2 )) continue; |
|
1206 | + if( empty( $component2 )) { |
|
1207 | + continue; |
|
1208 | + } |
|
1092 | 1209 | unset( $component2->propix ); |
1093 | 1210 | if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
1094 | 1211 | $this->components[$cix] = $component->copy(); |
1095 | 1212 | return TRUE; |
1096 | - } |
|
1097 | - elseif( $argType == $component2->objName ) { |
|
1213 | + } elseif( $argType == $component2->objName ) { |
|
1098 | 1214 | if( $index == $cix1sC ) { |
1099 | 1215 | $this->components[$cix] = $component->copy(); |
1100 | 1216 | return TRUE; |
1101 | 1217 | } |
1102 | 1218 | $cix1sC++; |
1103 | - } |
|
1104 | - elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) { |
|
1219 | + } elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) { |
|
1105 | 1220 | $this->components[$cix] = $component->copy(); |
1106 | 1221 | return TRUE; |
1107 | 1222 | } |
@@ -1128,73 +1243,124 @@ discard block |
||
1128 | 1243 | } |
1129 | 1244 | } |
1130 | 1245 | function _cmpfcn( $a, $b ) { |
1131 | - if( empty( $a )) return -1; |
|
1132 | - if( empty( $b )) return 1; |
|
1133 | - if( 'vtimezone' == $a->objName) return -1; |
|
1134 | - if( 'vtimezone' == $b->objName) return 1; |
|
1246 | + if( empty( $a )) { |
|
1247 | + return -1; |
|
1248 | + } |
|
1249 | + if( empty( $b )) { |
|
1250 | + return 1; |
|
1251 | + } |
|
1252 | + if( 'vtimezone' == $a->objName) { |
|
1253 | + return -1; |
|
1254 | + } |
|
1255 | + if( 'vtimezone' == $b->objName) { |
|
1256 | + return 1; |
|
1257 | + } |
|
1135 | 1258 | $astart = ( isset( $a->xprop['X-CURRENT-DTSTART']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTSTART']['value'] ) : null; |
1136 | - if( empty( $astart ) && isset( $a->dtstart['value'] )) |
|
1137 | - $astart = & $a->dtstart['value']; |
|
1259 | + if( empty( $astart ) && isset( $a->dtstart['value'] )) { |
|
1260 | + $astart = & $a->dtstart['value']; |
|
1261 | + } |
|
1138 | 1262 | $bstart = ( isset( $b->xprop['X-CURRENT-DTSTART']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTSTART']['value'] ) : null; |
1139 | - if( empty( $bstart ) && isset( $b->dtstart['value'] )) |
|
1140 | - $bstart = & $b->dtstart['value']; |
|
1141 | - if( empty( $astart )) return -1; |
|
1142 | - elseif( empty( $bstart )) return 1; |
|
1263 | + if( empty( $bstart ) && isset( $b->dtstart['value'] )) { |
|
1264 | + $bstart = & $b->dtstart['value']; |
|
1265 | + } |
|
1266 | + if( empty( $astart )) { |
|
1267 | + return -1; |
|
1268 | + } elseif( empty( $bstart )) { |
|
1269 | + return 1; |
|
1270 | + } |
|
1143 | 1271 | foreach( $this->_sortkeys as $key ) { |
1144 | - if ( empty( $astart[$key] )) return -1; |
|
1145 | - elseif( empty( $bstart[$key] )) return 1; |
|
1146 | - if ( $astart[$key] == $bstart[$key]) continue; |
|
1147 | - if (( (int) $astart[$key] ) < ((int) $bstart[$key] )) |
|
1272 | + if ( empty( $astart[$key] )) { |
|
1148 | 1273 | return -1; |
1149 | - elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] )) |
|
1274 | + } elseif( empty( $bstart[$key] )) { |
|
1150 | 1275 | return 1; |
1276 | + } |
|
1277 | + if ( $astart[$key] == $bstart[$key]) { |
|
1278 | + continue; |
|
1279 | + } |
|
1280 | + if (( (int) $astart[$key] ) < ((int) $bstart[$key] )) { |
|
1281 | + return -1; |
|
1282 | + } elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] )) { |
|
1283 | + return 1; |
|
1284 | + } |
|
1151 | 1285 | } |
1152 | 1286 | $c = ( isset( $a->xprop['X-CURRENT-DTEND']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTEND']['value'] ) : null; |
1153 | - if( empty( $c ) && !empty( $a->dtend['value'] )) |
|
1154 | - $c = & $a->dtend['value']; |
|
1155 | - if( empty( $c ) && isset( $a->xprop['X-CURRENT-DUE']['value'] )) |
|
1156 | - $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] ); |
|
1157 | - if( empty( $c ) && !empty( $a->due['value'] )) |
|
1158 | - $c = & $a->due['value']; |
|
1159 | - if( empty( $c ) && !empty( $a->duration['value'] )) |
|
1160 | - $c = $a->duration2date(); |
|
1287 | + if( empty( $c ) && !empty( $a->dtend['value'] )) { |
|
1288 | + $c = & $a->dtend['value']; |
|
1289 | + } |
|
1290 | + if( empty( $c ) && isset( $a->xprop['X-CURRENT-DUE']['value'] )) { |
|
1291 | + $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] ); |
|
1292 | + } |
|
1293 | + if( empty( $c ) && !empty( $a->due['value'] )) { |
|
1294 | + $c = & $a->due['value']; |
|
1295 | + } |
|
1296 | + if( empty( $c ) && !empty( $a->duration['value'] )) { |
|
1297 | + $c = $a->duration2date(); |
|
1298 | + } |
|
1161 | 1299 | $d = ( isset( $b->xprop['X-CURRENT-DTEND']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTEND']['value'] ) : null; |
1162 | - if( empty( $d ) && !empty( $b->dtend['value'] )) |
|
1163 | - $d = & $b->dtend['value']; |
|
1164 | - if( empty( $d ) && isset( $b->xprop['X-CURRENT-DUE']['value'] )) |
|
1165 | - $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] ); |
|
1166 | - if( empty( $d ) && !empty( $b->due['value'] )) |
|
1167 | - $d = & $b->due['value']; |
|
1168 | - if( empty( $d ) && !empty( $b->duration['value'] )) |
|
1169 | - $d = $b->duration2date(); |
|
1170 | - if( empty( $c )) return -1; |
|
1171 | - elseif( empty( $d )) return 1; |
|
1300 | + if( empty( $d ) && !empty( $b->dtend['value'] )) { |
|
1301 | + $d = & $b->dtend['value']; |
|
1302 | + } |
|
1303 | + if( empty( $d ) && isset( $b->xprop['X-CURRENT-DUE']['value'] )) { |
|
1304 | + $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] ); |
|
1305 | + } |
|
1306 | + if( empty( $d ) && !empty( $b->due['value'] )) { |
|
1307 | + $d = & $b->due['value']; |
|
1308 | + } |
|
1309 | + if( empty( $d ) && !empty( $b->duration['value'] )) { |
|
1310 | + $d = $b->duration2date(); |
|
1311 | + } |
|
1312 | + if( empty( $c )) { |
|
1313 | + return -1; |
|
1314 | + } elseif( empty( $d )) { |
|
1315 | + return 1; |
|
1316 | + } |
|
1172 | 1317 | foreach( $this->_sortkeys as $key ) { |
1173 | - if ( !isset( $c[$key] )) return -1; |
|
1174 | - elseif( !isset( $d[$key] )) return 1; |
|
1175 | - if ( $c[$key] == $d[$key] ) continue; |
|
1176 | - if (( (int) $c[$key] ) < ((int) $d[$key])) return -1; |
|
1177 | - elseif(( (int) $c[$key] ) > ((int) $d[$key])) return 1; |
|
1178 | - } |
|
1179 | - if( isset( $a->created['value'] )) |
|
1180 | - $e = & $a->created['value']; |
|
1181 | - else |
|
1182 | - $e = & $a->dtstamp['value']; |
|
1183 | - if( isset( $b->created['value'] )) |
|
1184 | - $f = & $b->created['value']; |
|
1185 | - else |
|
1186 | - $f = & $b->dtstamp['value']; |
|
1318 | + if ( !isset( $c[$key] )) { |
|
1319 | + return -1; |
|
1320 | + } elseif( !isset( $d[$key] )) { |
|
1321 | + return 1; |
|
1322 | + } |
|
1323 | + if ( $c[$key] == $d[$key] ) { |
|
1324 | + continue; |
|
1325 | + } |
|
1326 | + if (( (int) $c[$key] ) < ((int) $d[$key])) { |
|
1327 | + return -1; |
|
1328 | + } elseif(( (int) $c[$key] ) > ((int) $d[$key])) { |
|
1329 | + return 1; |
|
1330 | + } |
|
1331 | + } |
|
1332 | + if( isset( $a->created['value'] )) { |
|
1333 | + $e = & $a->created['value']; |
|
1334 | + } else { |
|
1335 | + $e = & $a->dtstamp['value']; |
|
1336 | + } |
|
1337 | + if( isset( $b->created['value'] )) { |
|
1338 | + $f = & $b->created['value']; |
|
1339 | + } else { |
|
1340 | + $f = & $b->dtstamp['value']; |
|
1341 | + } |
|
1187 | 1342 | foreach( $this->_sortkeys as $key ) { |
1188 | - if( !isset( $e[$key] )) return -1; |
|
1189 | - elseif( !isset( $f[$key] )) return 1; |
|
1190 | - if ( $e[$key] == $f[$key] ) continue; |
|
1191 | - if (( (int) $e[$key] ) < ((int) $f[$key])) return -1; |
|
1192 | - elseif(( (int) $e[$key] ) > ((int) $f[$key])) return 1; |
|
1343 | + if( !isset( $e[$key] )) { |
|
1344 | + return -1; |
|
1345 | + } elseif( !isset( $f[$key] )) { |
|
1346 | + return 1; |
|
1347 | + } |
|
1348 | + if ( $e[$key] == $f[$key] ) { |
|
1349 | + continue; |
|
1350 | + } |
|
1351 | + if (( (int) $e[$key] ) < ((int) $f[$key])) { |
|
1352 | + return -1; |
|
1353 | + } elseif(( (int) $e[$key] ) > ((int) $f[$key])) { |
|
1354 | + return 1; |
|
1355 | + } |
|
1193 | 1356 | } |
1194 | 1357 | if (( $a->uid['value'] ) < |
1195 | - ( $b->uid['value'] )) return -1; |
|
1196 | - elseif(( $a->uid['value'] ) > |
|
1197 | - ( $b->uid['value'] )) return 1; |
|
1358 | + ( $b->uid['value'] )) { |
|
1359 | + return -1; |
|
1360 | + } elseif(( $a->uid['value'] ) > |
|
1361 | + ( $b->uid['value'] )) { |
|
1362 | + return 1; |
|
1363 | + } |
|
1198 | 1364 | return 0; |
1199 | 1365 | } |
1200 | 1366 | /** |
@@ -1209,42 +1375,57 @@ discard block |
||
1209 | 1375 | function parse( $filename=FALSE ) { |
1210 | 1376 | if( !$filename ) { |
1211 | 1377 | /* directory/filename previous set via setConfig directory+filename / url */ |
1212 | - if( FALSE === ( $filename = $this->getConfig( 'url' ))) |
|
1213 | - $filename = $this->getConfig( 'dirfile' ); |
|
1214 | - } |
|
1215 | - elseif(( 'http://' == strtolower( substr( $filename, 0, 7 ))) || |
|
1378 | + if( FALSE === ( $filename = $this->getConfig( 'url' ))) { |
|
1379 | + $filename = $this->getConfig( 'dirfile' ); |
|
1380 | + } |
|
1381 | + } elseif(( 'http://' == strtolower( substr( $filename, 0, 7 ))) || |
|
1216 | 1382 | ( 'webcal://' == strtolower( substr( $filename, 0, 9 )))) { |
1217 | 1383 | /* remote file - URL */ |
1218 | 1384 | $this->setConfig( 'URL', $filename ); |
1219 | - if( !$filename = $this->getConfig( 'url' )) |
|
1220 | - return FALSE; /* err 2 */ |
|
1221 | - } |
|
1222 | - else { |
|
1385 | + if( !$filename = $this->getConfig( 'url' )) { |
|
1386 | + return FALSE; |
|
1387 | + } |
|
1388 | + /* err 2 */ |
|
1389 | + } else { |
|
1223 | 1390 | /* local directory/filename */ |
1224 | 1391 | $parts = pathinfo( $filename ); |
1225 | 1392 | if( !empty( $parts['dirname'] ) && ( '.' != $parts['dirname'] )) { |
1226 | - if( !$this->setConfig( 'directory', $parts['dirname'] )) |
|
1227 | - return FALSE; /* err 3 */ |
|
1393 | + if( !$this->setConfig( 'directory', $parts['dirname'] )) { |
|
1394 | + return FALSE; |
|
1395 | + } |
|
1396 | + /* err 3 */ |
|
1228 | 1397 | } |
1229 | - if( !$this->setConfig( 'filename', $parts['basename'] )) |
|
1230 | - return FALSE; /* err 4 */ |
|
1398 | + if( !$this->setConfig( 'filename', $parts['basename'] )) { |
|
1399 | + return FALSE; |
|
1400 | + } |
|
1401 | + /* err 4 */ |
|
1231 | 1402 | } |
1232 | 1403 | if( 'http://' != substr( $filename, 0, 7 )) { |
1233 | 1404 | /* local file error tests */ |
1234 | - if( !is_file( $filename )) /* err 5 */ |
|
1405 | + if( !is_file( $filename )) { |
|
1406 | + /* err 5 */ |
|
1235 | 1407 | return FALSE; |
1236 | - if( !is_readable( $filename )) |
|
1237 | - return FALSE; /* err 6 */ |
|
1238 | - if( !filesize( $filename )) |
|
1239 | - return FALSE; /* err 7 */ |
|
1408 | + } |
|
1409 | + if( !is_readable( $filename )) { |
|
1410 | + return FALSE; |
|
1411 | + } |
|
1412 | + /* err 6 */ |
|
1413 | + if( !filesize( $filename )) { |
|
1414 | + return FALSE; |
|
1415 | + } |
|
1416 | + /* err 7 */ |
|
1240 | 1417 | clearstatcache(); |
1241 | 1418 | } |
1242 | 1419 | /* READ FILE */ |
1243 | - if( FALSE === ( $rows = file( $filename ))) |
|
1244 | - return FALSE; /* err 1 */ |
|
1420 | + if( FALSE === ( $rows = file( $filename ))) { |
|
1421 | + return FALSE; |
|
1422 | + } |
|
1423 | + /* err 1 */ |
|
1245 | 1424 | /* identify BEGIN:VCALENDAR, MUST be first row */ |
1246 | - if( 'BEGIN:VCALENDAR' != strtoupper( trim( $rows[0] ))) |
|
1247 | - return FALSE; /* err 8 */ |
|
1425 | + if( 'BEGIN:VCALENDAR' != strtoupper( trim( $rows[0] ))) { |
|
1426 | + return FALSE; |
|
1427 | + } |
|
1428 | + /* err 8 */ |
|
1248 | 1429 | /* remove empty trailing lines */ |
1249 | 1430 | while( '' == trim( $rows[count( $rows ) - 1] )) { |
1250 | 1431 | unset( $rows[count( $rows ) - 1] ); |
@@ -1254,34 +1435,37 @@ discard block |
||
1254 | 1435 | if( 'END:VCALENDAR' != strtoupper( trim( $rows[count( $rows ) - 1] ))) { |
1255 | 1436 | return FALSE; /* err 9 */ |
1256 | 1437 | } |
1257 | - if( 3 > count( $rows )) |
|
1258 | - return FALSE; /* err 10 */ |
|
1438 | + if( 3 > count( $rows )) { |
|
1439 | + return FALSE; |
|
1440 | + } |
|
1441 | + /* err 10 */ |
|
1259 | 1442 | $comp = $subcomp = null; |
1260 | 1443 | $actcomp = & $this; |
1261 | 1444 | $nl = $this->getConfig( 'nl' ); |
1262 | 1445 | $calsync = 0; |
1263 | 1446 | /* identify components and update unparsed data within component */ |
1264 | 1447 | foreach( $rows as $line ) { |
1265 | - if( '' == trim( $line )) |
|
1266 | - continue; |
|
1267 | - if( $nl == substr( $line, 0 - strlen( $nl ))) |
|
1268 | - $line = substr( $line, 0, ( strlen( $line ) - strlen( $nl ))).'\n'; |
|
1448 | + if( '' == trim( $line )) { |
|
1449 | + continue; |
|
1450 | + } |
|
1451 | + if( $nl == substr( $line, 0 - strlen( $nl ))) { |
|
1452 | + $line = substr( $line, 0, ( strlen( $line ) - strlen( $nl ))).'\n'; |
|
1453 | + } |
|
1269 | 1454 | if( 'BEGIN:VCALENDAR' == strtoupper( substr( $line, 0, 15 ))) { |
1270 | 1455 | $calsync++; |
1271 | 1456 | continue; |
1272 | - } |
|
1273 | - elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) { |
|
1457 | + } elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) { |
|
1274 | 1458 | $calsync--; |
1275 | 1459 | continue; |
1460 | + } elseif( 1 != $calsync ) { |
|
1461 | + return FALSE; |
|
1276 | 1462 | } |
1277 | - elseif( 1 != $calsync ) |
|
1278 | - return FALSE; /* err 20 */ |
|
1463 | + /* err 20 */ |
|
1279 | 1464 | if( 'END:' == strtoupper( substr( $line, 0, 4 ))) { |
1280 | 1465 | if( null != $subcomp ) { |
1281 | 1466 | $comp->setComponent( $subcomp ); |
1282 | 1467 | $subcomp = null; |
1283 | - } |
|
1284 | - else { |
|
1468 | + } else { |
|
1285 | 1469 | $this->setComponent( $comp ); |
1286 | 1470 | $comp = null; |
1287 | 1471 | } |
@@ -1292,17 +1476,18 @@ discard block |
||
1292 | 1476 | $line = str_replace( '\n', '', $line ); |
1293 | 1477 | $compname = trim (strtoupper( substr( $line, 6 ))); |
1294 | 1478 | if( null != $comp ) { |
1295 | - if( 'VALARM' == $compname ) |
|
1296 | - $subcomp = new valarm(); |
|
1297 | - elseif( 'STANDARD' == $compname ) |
|
1298 | - $subcomp = new vtimezone( 'STANDARD' ); |
|
1299 | - elseif( 'DAYLIGHT' == $compname ) |
|
1300 | - $subcomp = new vtimezone( 'DAYLIGHT' ); |
|
1301 | - else |
|
1302 | - return FALSE; /* err 6 */ |
|
1479 | + if( 'VALARM' == $compname ) { |
|
1480 | + $subcomp = new valarm(); |
|
1481 | + } elseif( 'STANDARD' == $compname ) { |
|
1482 | + $subcomp = new vtimezone( 'STANDARD' ); |
|
1483 | + } elseif( 'DAYLIGHT' == $compname ) { |
|
1484 | + $subcomp = new vtimezone( 'DAYLIGHT' ); |
|
1485 | + } else { |
|
1486 | + return FALSE; |
|
1487 | + } |
|
1488 | + /* err 6 */ |
|
1303 | 1489 | $actcomp = & $subcomp; |
1304 | - } |
|
1305 | - else { |
|
1490 | + } else { |
|
1306 | 1491 | switch( $compname ) { |
1307 | 1492 | case 'VALARM': |
1308 | 1493 | $comp = new valarm(); |
@@ -1351,8 +1536,7 @@ discard block |
||
1351 | 1536 | $newProp = FALSE; |
1352 | 1537 | $lastix++; |
1353 | 1538 | $proprows[$lastix] = $line; |
1354 | - } |
|
1355 | - else { |
|
1539 | + } else { |
|
1356 | 1540 | /* remove line breaks */ |
1357 | 1541 | if(( '\n' == substr( $proprows[$lastix], -2 )) && |
1358 | 1542 | ( ' ' == substr( $line, 0, 1 ))) { |
@@ -1364,19 +1548,22 @@ discard block |
||
1364 | 1548 | } |
1365 | 1549 | $toolbox = new calendarComponent(); |
1366 | 1550 | foreach( $proprows as $line ) { |
1367 | - if( '\n' == substr( $line, -2 )) |
|
1368 | - $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
1551 | + if( '\n' == substr( $line, -2 )) { |
|
1552 | + $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
1553 | + } |
|
1369 | 1554 | /* get propname */ |
1370 | 1555 | $cix = $propname = null; |
1371 | 1556 | for( $cix=0; $cix < strlen( $line ); $cix++ ) { |
1372 | - if( in_array( $line{$cix}, array( ':', ';' ))) |
|
1373 | - break; |
|
1374 | - else |
|
1375 | - $propname .= $line{$cix}; |
|
1557 | + if( in_array( $line{$cix}, array( ':', ';' ))) { |
|
1558 | + break; |
|
1559 | + } else { |
|
1560 | + $propname .= $line{$cix}; |
|
1561 | + } |
|
1376 | 1562 | } |
1377 | 1563 | /* ignore version/prodid properties */ |
1378 | - if( in_array( strtoupper( $propname ), array( 'VERSION', 'PRODID' ))) |
|
1379 | - continue; |
|
1564 | + if( in_array( strtoupper( $propname ), array( 'VERSION', 'PRODID' ))) { |
|
1565 | + continue; |
|
1566 | + } |
|
1380 | 1567 | $line = substr( $line, $cix); |
1381 | 1568 | /* separate attributes from value */ |
1382 | 1569 | $attr = array(); |
@@ -1401,20 +1588,22 @@ discard block |
||
1401 | 1588 | break; |
1402 | 1589 | } |
1403 | 1590 | } |
1404 | - if( ';' == $line{$cix} ) |
|
1405 | - $attr[++$attrix] = null; |
|
1406 | - else |
|
1407 | - $attr[$attrix] .= $line{$cix}; |
|
1591 | + if( ';' == $line{$cix} ) { |
|
1592 | + $attr[++$attrix] = null; |
|
1593 | + } else { |
|
1594 | + $attr[$attrix] .= $line{$cix}; |
|
1595 | + } |
|
1408 | 1596 | } |
1409 | 1597 | |
1410 | 1598 | /* make attributes in array format */ |
1411 | 1599 | $propattr = array(); |
1412 | 1600 | foreach( $attr as $attribute ) { |
1413 | 1601 | $attrsplit = explode( '=', $attribute, 2 ); |
1414 | - if( 1 < count( $attrsplit )) |
|
1415 | - $propattr[$attrsplit[0]] = $attrsplit[1]; |
|
1416 | - else |
|
1417 | - $propattr[] = $attribute; |
|
1602 | + if( 1 < count( $attrsplit )) { |
|
1603 | + $propattr[$attrsplit[0]] = $attrsplit[1]; |
|
1604 | + } else { |
|
1605 | + $propattr[] = $attribute; |
|
1606 | + } |
|
1418 | 1607 | } |
1419 | 1608 | /* update Property */ |
1420 | 1609 | if( FALSE !== strpos( $line, ',' )) { |
@@ -1428,13 +1617,14 @@ discard block |
||
1428 | 1617 | } |
1429 | 1618 | } |
1430 | 1619 | if( 1 < count( $content )) { |
1431 | - foreach( $content as $cix => $contentPart ) |
|
1432 | - $content[$cix] = $toolbox->_strunrep( $contentPart ); |
|
1620 | + foreach( $content as $cix => $contentPart ) { |
|
1621 | + $content[$cix] = $toolbox->_strunrep( $contentPart ); |
|
1622 | + } |
|
1433 | 1623 | $this->setProperty( $propname, $content, $propattr ); |
1434 | 1624 | continue; |
1625 | + } else { |
|
1626 | + $line = reset( $content ); |
|
1435 | 1627 | } |
1436 | - else |
|
1437 | - $line = reset( $content ); |
|
1438 | 1628 | $line = $toolbox->_strunrep( $line ); |
1439 | 1629 | } |
1440 | 1630 | $this->setProperty( $propname, trim( $line ), $propattr ); |
@@ -1443,12 +1633,14 @@ discard block |
||
1443 | 1633 | /* parse Components */ |
1444 | 1634 | if( is_array( $this->components ) && ( 0 < count( $this->components ))) { |
1445 | 1635 | for( $six = 0; $six < count( $this->components ); $six++ ) { |
1446 | - if( !empty( $this->components[$six] )) |
|
1447 | - $this->components[$six]->parse(); |
|
1636 | + if( !empty( $this->components[$six] )) { |
|
1637 | + $this->components[$six]->parse(); |
|
1638 | + } |
|
1448 | 1639 | } |
1640 | + } else { |
|
1641 | + return FALSE; |
|
1449 | 1642 | } |
1450 | - else |
|
1451 | - return FALSE; /* err 91 or something.. . */ |
|
1643 | + /* err 91 or something.. . */ |
|
1452 | 1644 | return TRUE; |
1453 | 1645 | } |
1454 | 1646 | /*********************************************************************************/ |
@@ -1480,8 +1672,9 @@ discard block |
||
1480 | 1672 | switch( $this->format ) { |
1481 | 1673 | case 'xcal': |
1482 | 1674 | $nlstrlen = strlen( $this->nl ); |
1483 | - if( $this->nl == substr( $calendarStart, ( 0 - $nlstrlen ))) |
|
1484 | - $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen )); |
|
1675 | + if( $this->nl == substr( $calendarStart, ( 0 - $nlstrlen ))) { |
|
1676 | + $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen )); |
|
1677 | + } |
|
1485 | 1678 | $calendarStart .= '>'.$this->nl; |
1486 | 1679 | break; |
1487 | 1680 | default: |
@@ -1489,9 +1682,12 @@ discard block |
||
1489 | 1682 | } |
1490 | 1683 | $calendar .= $this->createXprop(); |
1491 | 1684 | foreach( $this->components as $component ) { |
1492 | - if( empty( $component )) continue; |
|
1493 | - if( '' >= $component->getConfig( 'language')) |
|
1494 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
1685 | + if( empty( $component )) { |
|
1686 | + continue; |
|
1687 | + } |
|
1688 | + if( '' >= $component->getConfig( 'language')) { |
|
1689 | + $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
1690 | + } |
|
1495 | 1691 | $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
1496 | 1692 | $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
1497 | 1693 | $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
@@ -1504,8 +1700,10 @@ discard block |
||
1504 | 1700 | foreach( $this->xcaldecl as $declix => $declPart ) { |
1505 | 1701 | if(( 0 < count( $old_xcaldecl)) && |
1506 | 1702 | ( in_array( $declPart['uri'], $old_xcaldecl['uri'] )) && |
1507 | - ( in_array( $declPart['external'], $old_xcaldecl['external'] ))) |
|
1508 | - continue; // no duplicate uri and ext. references |
|
1703 | + ( in_array( $declPart['external'], $old_xcaldecl['external'] ))) { |
|
1704 | + continue; |
|
1705 | + } |
|
1706 | + // no duplicate uri and ext. references |
|
1509 | 1707 | $calendarxCaldecl .= '<!'; |
1510 | 1708 | foreach( $declPart as $declKey => $declValue ) { |
1511 | 1709 | switch( $declKey ) { // index |
@@ -1558,10 +1756,11 @@ discard block |
||
1558 | 1756 | $filesize = strlen( $output ); |
1559 | 1757 | // if( headers_sent( $filename, $linenum )) |
1560 | 1758 | // die( "Headers already sent in $filename on line $linenum\n" ); |
1561 | - if( 'xcal' == $this->format ) |
|
1562 | - header( 'Content-Type: application/calendar+xml; charset=utf-8' ); |
|
1563 | - else |
|
1564 | - header( 'Content-Type: text/calendar; charset=utf-8' ); |
|
1759 | + if( 'xcal' == $this->format ) { |
|
1760 | + header( 'Content-Type: application/calendar+xml; charset=utf-8' ); |
|
1761 | + } else { |
|
1762 | + header( 'Content-Type: text/calendar; charset=utf-8' ); |
|
1763 | + } |
|
1565 | 1764 | header( 'Content-Length: '.$filesize ); |
1566 | 1765 | header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
1567 | 1766 | header( 'Cache-Control: max-age=10' ); |
@@ -1579,23 +1778,28 @@ discard block |
||
1579 | 1778 | * @return bool |
1580 | 1779 | */ |
1581 | 1780 | function saveCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE ) { |
1582 | - if( $directory ) |
|
1583 | - $this->setConfig( 'directory', $directory ); |
|
1584 | - if( $filename ) |
|
1585 | - $this->setConfig( 'filename', $filename ); |
|
1586 | - if( $delimiter && ($delimiter != DIRECTORY_SEPARATOR )) |
|
1587 | - $this->setConfig( 'delimiter', $delimiter ); |
|
1588 | - if( FALSE === ( $dirfile = $this->getConfig( 'url' ))) |
|
1589 | - $dirfile = $this->getConfig( 'dirfile' ); |
|
1781 | + if( $directory ) { |
|
1782 | + $this->setConfig( 'directory', $directory ); |
|
1783 | + } |
|
1784 | + if( $filename ) { |
|
1785 | + $this->setConfig( 'filename', $filename ); |
|
1786 | + } |
|
1787 | + if( $delimiter && ($delimiter != DIRECTORY_SEPARATOR )) { |
|
1788 | + $this->setConfig( 'delimiter', $delimiter ); |
|
1789 | + } |
|
1790 | + if( FALSE === ( $dirfile = $this->getConfig( 'url' ))) { |
|
1791 | + $dirfile = $this->getConfig( 'dirfile' ); |
|
1792 | + } |
|
1590 | 1793 | $iCalFile = @fopen( $dirfile, 'w' ); |
1591 | 1794 | if( $iCalFile ) { |
1592 | - if( FALSE === fwrite( $iCalFile, $this->createCalendar() )) |
|
1593 | - return FALSE; |
|
1795 | + if( FALSE === fwrite( $iCalFile, $this->createCalendar() )) { |
|
1796 | + return FALSE; |
|
1797 | + } |
|
1594 | 1798 | fclose( $iCalFile ); |
1595 | 1799 | return TRUE; |
1800 | + } else { |
|
1801 | + return FALSE; |
|
1596 | 1802 | } |
1597 | - else |
|
1598 | - return FALSE; |
|
1599 | 1803 | } |
1600 | 1804 | /** |
1601 | 1805 | * if recent version of calendar file exists (default one hour), an HTTP redirect header is sent |
@@ -1614,15 +1818,19 @@ discard block |
||
1614 | 1818 | $timeout = (int) $directory; |
1615 | 1819 | $directory = FALSE; |
1616 | 1820 | } |
1617 | - if ( $directory ) |
|
1618 | - $this->setConfig( 'directory', $directory ); |
|
1619 | - if ( $filename ) |
|
1620 | - $this->setConfig( 'filename', $filename ); |
|
1621 | - if ( $delimiter && ( $delimiter != DIRECTORY_SEPARATOR )) |
|
1622 | - $this->setConfig( 'delimiter', $delimiter ); |
|
1821 | + if ( $directory ) { |
|
1822 | + $this->setConfig( 'directory', $directory ); |
|
1823 | + } |
|
1824 | + if ( $filename ) { |
|
1825 | + $this->setConfig( 'filename', $filename ); |
|
1826 | + } |
|
1827 | + if ( $delimiter && ( $delimiter != DIRECTORY_SEPARATOR )) { |
|
1828 | + $this->setConfig( 'delimiter', $delimiter ); |
|
1829 | + } |
|
1623 | 1830 | $filesize = $this->getConfig( 'filesize' ); |
1624 | - if ( 0 >= $filesize ) |
|
1625 | - return FALSE; |
|
1831 | + if ( 0 >= $filesize ) { |
|
1832 | + return FALSE; |
|
1833 | + } |
|
1626 | 1834 | $dirfile = $this->getConfig( 'dirfile' ); |
1627 | 1835 | if ( time() - filemtime( $dirfile ) < $timeout) { |
1628 | 1836 | clearstatcache(); |
@@ -1630,10 +1838,11 @@ discard block |
||
1630 | 1838 | $filename = $this->getConfig( 'filename' ); |
1631 | 1839 | // if( headers_sent( $filename, $linenum )) |
1632 | 1840 | // die( "Headers already sent in $filename on line $linenum\n" ); |
1633 | - if ( 'xcal' == $this->format ) |
|
1634 | - header( 'Content-Type: application/calendar+xml; charset=utf-8' ); |
|
1635 | - else |
|
1636 | - header( 'Content-Type: text/calendar; charset=utf-8' ); |
|
1841 | + if ( 'xcal' == $this->format ) { |
|
1842 | + header( 'Content-Type: application/calendar+xml; charset=utf-8' ); |
|
1843 | + } else { |
|
1844 | + header( 'Content-Type: text/calendar; charset=utf-8' ); |
|
1845 | + } |
|
1637 | 1846 | header( 'Content-Length: '.$filesize ); |
1638 | 1847 | header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
1639 | 1848 | header( 'Cache-Control: max-age=10' ); |
@@ -1716,9 +1925,12 @@ discard block |
||
1716 | 1925 | * @return string |
1717 | 1926 | */ |
1718 | 1927 | function createAction() { |
1719 | - if( empty( $this->action )) return FALSE; |
|
1720 | - if( empty( $this->action['value'] )) |
|
1721 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE; |
|
1928 | + if( empty( $this->action )) { |
|
1929 | + return FALSE; |
|
1930 | + } |
|
1931 | + if( empty( $this->action['value'] )) { |
|
1932 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE; |
|
1933 | + } |
|
1722 | 1934 | $attributes = $this->_createParams( $this->action['params'] ); |
1723 | 1935 | return $this->_createElement( 'ACTION', $attributes, $this->action['value'] ); |
1724 | 1936 | } |
@@ -1732,8 +1944,12 @@ discard block |
||
1732 | 1944 | * @return bool |
1733 | 1945 | */ |
1734 | 1946 | function setAction( $value, $params=FALSE ) { |
1735 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1736 | - $this->action = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
1947 | + if( empty( $value )) { |
|
1948 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
1949 | + } else { |
|
1950 | + return FALSE; |
|
1951 | + } |
|
1952 | + $this->action = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
1737 | 1953 | return TRUE; |
1738 | 1954 | } |
1739 | 1955 | /*********************************************************************************/ |
@@ -1748,14 +1964,17 @@ discard block |
||
1748 | 1964 | * @return string |
1749 | 1965 | */ |
1750 | 1966 | function createAttach() { |
1751 | - if( empty( $this->attach )) return FALSE; |
|
1967 | + if( empty( $this->attach )) { |
|
1968 | + return FALSE; |
|
1969 | + } |
|
1752 | 1970 | $output = null; |
1753 | 1971 | foreach( $this->attach as $attachPart ) { |
1754 | 1972 | if(! empty( $attachPart['value'] )) { |
1755 | 1973 | $attributes = $this->_createParams( $attachPart['params'] ); |
1756 | 1974 | $output .= $this->_createElement( 'ATTACH', $attributes, $attachPart['value'] ); |
1975 | + } elseif( $this->getConfig( 'allowEmpty' )) { |
|
1976 | + $output .= $this->_createElement( 'ATTACH' ); |
|
1757 | 1977 | } |
1758 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'ATTACH' ); |
|
1759 | 1978 | } |
1760 | 1979 | return $output; |
1761 | 1980 | } |
@@ -1770,7 +1989,11 @@ discard block |
||
1770 | 1989 | * @return bool |
1771 | 1990 | */ |
1772 | 1991 | function setAttach( $value, $params=FALSE, $index=FALSE ) { |
1773 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1992 | + if( empty( $value )) { |
|
1993 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
1994 | + } else { |
|
1995 | + return FALSE; |
|
1996 | + } |
|
1774 | 1997 | $this->_setMval( $this->attach, $value, $params, FALSE, $index ); |
1775 | 1998 | return TRUE; |
1776 | 1999 | } |
@@ -1786,19 +2009,22 @@ discard block |
||
1786 | 2009 | * @return string |
1787 | 2010 | */ |
1788 | 2011 | function createAttendee() { |
1789 | - if( empty( $this->attendee )) return FALSE; |
|
2012 | + if( empty( $this->attendee )) { |
|
2013 | + return FALSE; |
|
2014 | + } |
|
1790 | 2015 | $output = null; |
1791 | 2016 | foreach( $this->attendee as $attendeePart ) { // start foreach 1 |
1792 | 2017 | if( empty( $attendeePart['value'] )) { |
1793 | - if( $this->getConfig( 'allowEmpty' )) |
|
1794 | - $output .= $this->_createElement( 'ATTENDEE' ); |
|
2018 | + if( $this->getConfig( 'allowEmpty' )) { |
|
2019 | + $output .= $this->_createElement( 'ATTENDEE' ); |
|
2020 | + } |
|
1795 | 2021 | continue; |
1796 | 2022 | } |
1797 | 2023 | $attendee1 = $attendee2 = $attendeeLANG = $attendeeCN = null; |
1798 | 2024 | foreach( $attendeePart as $paramlabel => $paramvalue ) { // start foreach 2 |
1799 | - if( 'value' == $paramlabel ) |
|
1800 | - $attendee2 .= 'MAILTO:'.$paramvalue; |
|
1801 | - elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) { // start elseif |
|
2025 | + if( 'value' == $paramlabel ) { |
|
2026 | + $attendee2 .= 'MAILTO:'.$paramvalue; |
|
2027 | + } elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) { // start elseif |
|
1802 | 2028 | foreach( $paramvalue as $optparamlabel => $optparamvalue ) { // start foreach 3 |
1803 | 2029 | $attendee11 = $attendee12 = null; |
1804 | 2030 | if( is_int( $optparamlabel )) { |
@@ -1860,7 +2086,11 @@ discard block |
||
1860 | 2086 | * @return bool |
1861 | 2087 | */ |
1862 | 2088 | function setAttendee( $value, $params=FALSE, $index=FALSE ) { |
1863 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2089 | + if( empty( $value )) { |
|
2090 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
2091 | + } else { |
|
2092 | + return FALSE; |
|
2093 | + } |
|
1864 | 2094 | $value = str_replace ( 'MAILTO:', '', $value ); |
1865 | 2095 | $value = str_replace ( 'mailto:', '', $value ); |
1866 | 2096 | $params2 = array(); |
@@ -1876,16 +2106,17 @@ discard block |
||
1876 | 2106 | foreach( $optparamvalue as $part ) { |
1877 | 2107 | $part = str_replace( 'MAILTO:', '', $part ); |
1878 | 2108 | $part = str_replace( 'mailto:', '', $part ); |
1879 | - if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) |
|
1880 | - $part = substr( $part, 1, ( strlen($part)-2 )); |
|
2109 | + if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) { |
|
2110 | + $part = substr( $part, 1, ( strlen($part)-2 )); |
|
2111 | + } |
|
1881 | 2112 | $optarrays[$optparamlabel][] = $part; |
1882 | 2113 | } |
1883 | - } |
|
1884 | - else { |
|
2114 | + } else { |
|
1885 | 2115 | $part = str_replace( 'MAILTO:', '', $optparamvalue ); |
1886 | 2116 | $part = str_replace( 'mailto:', '', $part ); |
1887 | - if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) |
|
1888 | - $part = substr( $part, 1, ( strlen($part)-2 )); |
|
2117 | + if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) { |
|
2118 | + $part = substr( $part, 1, ( strlen($part)-2 )); |
|
2119 | + } |
|
1889 | 2120 | $optarrays[$optparamlabel][] = $part; |
1890 | 2121 | } |
1891 | 2122 | break; |
@@ -1895,14 +2126,16 @@ discard block |
||
1895 | 2126 | $optparamvalue = str_replace( 'mailto:', '', $optparamvalue ); |
1896 | 2127 | } |
1897 | 2128 | if(( '"' == substr( $optparamvalue, 0, 1 )) && |
1898 | - ( '"' == substr( $optparamvalue, -1 ))) |
|
1899 | - $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 )); |
|
2129 | + ( '"' == substr( $optparamvalue, -1 ))) { |
|
2130 | + $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 )); |
|
2131 | + } |
|
1900 | 2132 | $params2[$optparamlabel] = $optparamvalue; |
1901 | 2133 | break; |
1902 | 2134 | } // end switch( $optparamlabel.. . |
1903 | 2135 | } // end foreach( $optparam.. . |
1904 | - foreach( $optarrays as $optparamlabel => $optparams ) |
|
1905 | - $params2[$optparamlabel] = $optparams; |
|
2136 | + foreach( $optarrays as $optparamlabel => $optparams ) { |
|
2137 | + $params2[$optparamlabel] = $optparams; |
|
2138 | + } |
|
1906 | 2139 | } |
1907 | 2140 | // remove defaults |
1908 | 2141 | $this->_existRem( $params2, 'CUTYPE', 'INDIVIDUAL' ); |
@@ -1912,8 +2145,9 @@ discard block |
||
1912 | 2145 | // check language setting |
1913 | 2146 | if( isset( $params2['CN' ] )) { |
1914 | 2147 | $lang = $this->getConfig( 'language' ); |
1915 | - if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang )) |
|
1916 | - $params2['LANGUAGE' ] = $lang; |
|
2148 | + if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang )) { |
|
2149 | + $params2['LANGUAGE' ] = $lang; |
|
2150 | + } |
|
1917 | 2151 | } |
1918 | 2152 | $this->_setMval( $this->attendee, $value, $params2, FALSE, $index ); |
1919 | 2153 | return TRUE; |
@@ -1930,22 +2164,26 @@ discard block |
||
1930 | 2164 | * @return string |
1931 | 2165 | */ |
1932 | 2166 | function createCategories() { |
1933 | - if( empty( $this->categories )) return FALSE; |
|
2167 | + if( empty( $this->categories )) { |
|
2168 | + return FALSE; |
|
2169 | + } |
|
1934 | 2170 | $output = null; |
1935 | 2171 | foreach( $this->categories as $category ) { |
1936 | 2172 | if( empty( $category['value'] )) { |
1937 | - if ( $this->getConfig( 'allowEmpty' )) |
|
1938 | - $output .= $this->_createElement( 'CATEGORIES' ); |
|
2173 | + if ( $this->getConfig( 'allowEmpty' )) { |
|
2174 | + $output .= $this->_createElement( 'CATEGORIES' ); |
|
2175 | + } |
|
1939 | 2176 | continue; |
1940 | 2177 | } |
1941 | 2178 | $attributes = $this->_createParams( $category['params'], array( 'LANGUAGE' )); |
1942 | 2179 | if( is_array( $category['value'] )) { |
1943 | - foreach( $category['value'] as $cix => $categoryPart ) |
|
1944 | - $category['value'][$cix] = $this->_strrep( $categoryPart ); |
|
2180 | + foreach( $category['value'] as $cix => $categoryPart ) { |
|
2181 | + $category['value'][$cix] = $this->_strrep( $categoryPart ); |
|
2182 | + } |
|
1945 | 2183 | $content = implode( ',', $category['value'] ); |
2184 | + } else { |
|
2185 | + $content = $this->_strrep( $category['value'] ); |
|
1946 | 2186 | } |
1947 | - else |
|
1948 | - $content = $this->_strrep( $category['value'] ); |
|
1949 | 2187 | $output .= $this->_createElement( 'CATEGORIES', $attributes, $content ); |
1950 | 2188 | } |
1951 | 2189 | return $output; |
@@ -1961,7 +2199,11 @@ discard block |
||
1961 | 2199 | * @return bool |
1962 | 2200 | */ |
1963 | 2201 | function setCategories( $value, $params=FALSE, $index=FALSE ) { |
1964 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2202 | + if( empty( $value )) { |
|
2203 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
2204 | + } else { |
|
2205 | + return FALSE; |
|
2206 | + } |
|
1965 | 2207 | $this->_setMval( $this->categories, $value, $params, FALSE, $index ); |
1966 | 2208 | return TRUE; |
1967 | 2209 | } |
@@ -1977,9 +2219,12 @@ discard block |
||
1977 | 2219 | * @return string |
1978 | 2220 | */ |
1979 | 2221 | function createClass() { |
1980 | - if( empty( $this->class )) return FALSE; |
|
1981 | - if( empty( $this->class['value'] )) |
|
1982 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE; |
|
2222 | + if( empty( $this->class )) { |
|
2223 | + return FALSE; |
|
2224 | + } |
|
2225 | + if( empty( $this->class['value'] )) { |
|
2226 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE; |
|
2227 | + } |
|
1983 | 2228 | $attributes = $this->_createParams( $this->class['params'] ); |
1984 | 2229 | return $this->_createElement( 'CLASS', $attributes, $this->class['value'] ); |
1985 | 2230 | } |
@@ -1993,7 +2238,11 @@ discard block |
||
1993 | 2238 | * @return bool |
1994 | 2239 | */ |
1995 | 2240 | function setClass( $value, $params=FALSE ) { |
1996 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2241 | + if( empty( $value )) { |
|
2242 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
2243 | + } else { |
|
2244 | + return FALSE; |
|
2245 | + } |
|
1997 | 2246 | $this->class = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
1998 | 2247 | return TRUE; |
1999 | 2248 | } |
@@ -2009,11 +2258,15 @@ discard block |
||
2009 | 2258 | * @return string |
2010 | 2259 | */ |
2011 | 2260 | function createComment() { |
2012 | - if( empty( $this->comment )) return FALSE; |
|
2261 | + if( empty( $this->comment )) { |
|
2262 | + return FALSE; |
|
2263 | + } |
|
2013 | 2264 | $output = null; |
2014 | 2265 | foreach( $this->comment as $commentPart ) { |
2015 | 2266 | if( empty( $commentPart['value'] )) { |
2016 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'COMMENT' ); |
|
2267 | + if( $this->getConfig( 'allowEmpty' )) { |
|
2268 | + $output .= $this->_createElement( 'COMMENT' ); |
|
2269 | + } |
|
2017 | 2270 | continue; |
2018 | 2271 | } |
2019 | 2272 | $attributes = $this->_createParams( $commentPart['params'], array( 'ALTREP', 'LANGUAGE' )); |
@@ -2034,7 +2287,11 @@ discard block |
||
2034 | 2287 | * @return bool |
2035 | 2288 | */ |
2036 | 2289 | function setComment( $value, $params=FALSE, $index=FALSE ) { |
2037 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2290 | + if( empty( $value )) { |
|
2291 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
2292 | + } else { |
|
2293 | + return FALSE; |
|
2294 | + } |
|
2038 | 2295 | $this->_setMval( $this->comment, $value, $params, FALSE, $index ); |
2039 | 2296 | return TRUE; |
2040 | 2297 | } |
@@ -2050,16 +2307,20 @@ discard block |
||
2050 | 2307 | * @return string |
2051 | 2308 | */ |
2052 | 2309 | function createCompleted( ) { |
2053 | - if( empty( $this->completed )) return FALSE; |
|
2310 | + if( empty( $this->completed )) { |
|
2311 | + return FALSE; |
|
2312 | + } |
|
2054 | 2313 | if( !isset( $this->completed['value']['year'] ) && |
2055 | 2314 | !isset( $this->completed['value']['month'] ) && |
2056 | 2315 | !isset( $this->completed['value']['day'] ) && |
2057 | 2316 | !isset( $this->completed['value']['hour'] ) && |
2058 | 2317 | !isset( $this->completed['value']['min'] ) && |
2059 | - !isset( $this->completed['value']['sec'] )) |
|
2060 | - if( $this->getConfig( 'allowEmpty' )) |
|
2318 | + !isset( $this->completed['value']['sec'] )) { |
|
2319 | + if( $this->getConfig( 'allowEmpty' )) |
|
2061 | 2320 | return $this->_createElement( 'COMPLETED' ); |
2062 | - else return FALSE; |
|
2321 | + } else { |
|
2322 | + return FALSE; |
|
2323 | + } |
|
2063 | 2324 | $formatted = $this->_format_date_time( $this->completed['value'], 7 ); |
2064 | 2325 | $attributes = $this->_createParams( $this->completed['params'] ); |
2065 | 2326 | return $this->_createElement( 'COMPLETED', $attributes, $formatted ); |
@@ -2083,9 +2344,9 @@ discard block |
||
2083 | 2344 | if( $this->getConfig( 'allowEmpty' )) { |
2084 | 2345 | $this->completed = array( 'value' => null, 'params' => $this->_setParams( $params )); |
2085 | 2346 | return TRUE; |
2347 | + } else { |
|
2348 | + return FALSE; |
|
2086 | 2349 | } |
2087 | - else |
|
2088 | - return FALSE; |
|
2089 | 2350 | } |
2090 | 2351 | $this->completed = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
2091 | 2352 | return TRUE; |
@@ -2102,15 +2363,18 @@ discard block |
||
2102 | 2363 | * @return string |
2103 | 2364 | */ |
2104 | 2365 | function createContact() { |
2105 | - if( empty( $this->contact )) return FALSE; |
|
2366 | + if( empty( $this->contact )) { |
|
2367 | + return FALSE; |
|
2368 | + } |
|
2106 | 2369 | $output = null; |
2107 | 2370 | foreach( $this->contact as $contact ) { |
2108 | 2371 | if( !empty( $contact['value'] )) { |
2109 | 2372 | $attributes = $this->_createParams( $contact['params'], array( 'ALTREP', 'LANGUAGE' )); |
2110 | 2373 | $content = $this->_strrep( $contact['value'] ); |
2111 | 2374 | $output .= $this->_createElement( 'CONTACT', $attributes, $content ); |
2375 | + } elseif( $this->getConfig( 'allowEmpty' )) { |
|
2376 | + $output .= $this->_createElement( 'CONTACT' ); |
|
2112 | 2377 | } |
2113 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'CONTACT' ); |
|
2114 | 2378 | } |
2115 | 2379 | return $output; |
2116 | 2380 | } |
@@ -2125,7 +2389,11 @@ discard block |
||
2125 | 2389 | * @return bool |
2126 | 2390 | */ |
2127 | 2391 | function setContact( $value, $params=FALSE, $index=FALSE ) { |
2128 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2392 | + if( empty( $value )) { |
|
2393 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
2394 | + } else { |
|
2395 | + return FALSE; |
|
2396 | + } |
|
2129 | 2397 | $this->_setMval( $this->contact, $value, $params, FALSE, $index ); |
2130 | 2398 | return TRUE; |
2131 | 2399 | } |
@@ -2141,7 +2409,9 @@ discard block |
||
2141 | 2409 | * @return string |
2142 | 2410 | */ |
2143 | 2411 | function createCreated() { |
2144 | - if( empty( $this->created )) return FALSE; |
|
2412 | + if( empty( $this->created )) { |
|
2413 | + return FALSE; |
|
2414 | + } |
|
2145 | 2415 | $formatted = $this->_format_date_time( $this->created['value'], 7 ); |
2146 | 2416 | $attributes = $this->_createParams( $this->created['params'] ); |
2147 | 2417 | return $this->_createElement( 'CREATED', $attributes, $formatted ); |
@@ -2179,15 +2449,18 @@ discard block |
||
2179 | 2449 | * @return string |
2180 | 2450 | */ |
2181 | 2451 | function createDescription() { |
2182 | - if( empty( $this->description )) return FALSE; |
|
2452 | + if( empty( $this->description )) { |
|
2453 | + return FALSE; |
|
2454 | + } |
|
2183 | 2455 | $output = null; |
2184 | 2456 | foreach( $this->description as $description ) { |
2185 | 2457 | if( !empty( $description['value'] )) { |
2186 | 2458 | $attributes = $this->_createParams( $description['params'], array( 'ALTREP', 'LANGUAGE' )); |
2187 | 2459 | $content = $this->_strrep( $description['value'] ); |
2188 | 2460 | $output .= $this->_createElement( 'DESCRIPTION', $attributes, $content ); |
2461 | + } elseif( $this->getConfig( 'allowEmpty' )) { |
|
2462 | + $output .= $this->_createElement( 'DESCRIPTION' ); |
|
2189 | 2463 | } |
2190 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'DESCRIPTION' ); |
|
2191 | 2464 | } |
2192 | 2465 | return $output; |
2193 | 2466 | } |
@@ -2202,7 +2475,12 @@ discard block |
||
2202 | 2475 | * @return bool |
2203 | 2476 | */ |
2204 | 2477 | function setDescription( $value, $params=FALSE, $index=FALSE ) { |
2205 | - if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; } |
|
2478 | + if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) { |
|
2479 | + $value = null; |
|
2480 | + } else { |
|
2481 | + return FALSE; |
|
2482 | + } |
|
2483 | + } |
|
2206 | 2484 | $this->_setMval( $this->description, $value, $params, FALSE, $index ); |
2207 | 2485 | return TRUE; |
2208 | 2486 | } |
@@ -2218,16 +2496,20 @@ discard block |
||
2218 | 2496 | * @return string |
2219 | 2497 | */ |
2220 | 2498 | function createDtend() { |
2221 | - if( empty( $this->dtend )) return FALSE; |
|
2499 | + if( empty( $this->dtend )) { |
|
2500 | + return FALSE; |
|
2501 | + } |
|
2222 | 2502 | if( !isset( $this->dtend['value']['year'] ) && |
2223 | 2503 | !isset( $this->dtend['value']['month'] ) && |
2224 | 2504 | !isset( $this->dtend['value']['day'] ) && |
2225 | 2505 | !isset( $this->dtend['value']['hour'] ) && |
2226 | 2506 | !isset( $this->dtend['value']['min'] ) && |
2227 | - !isset( $this->dtend['value']['sec'] )) |
|
2228 | - if( $this->getConfig( 'allowEmpty' )) |
|
2507 | + !isset( $this->dtend['value']['sec'] )) { |
|
2508 | + if( $this->getConfig( 'allowEmpty' )) |
|
2229 | 2509 | return $this->_createElement( 'DTEND' ); |
2230 | - else return FALSE; |
|
2510 | + } else { |
|
2511 | + return FALSE; |
|
2512 | + } |
|
2231 | 2513 | $formatted = $this->_format_date_time( $this->dtend['value'] ); |
2232 | 2514 | $attributes = $this->_createParams( $this->dtend['params'] ); |
2233 | 2515 | return $this->_createElement( 'DTEND', $attributes, $formatted ); |
@@ -2252,9 +2534,9 @@ discard block |
||
2252 | 2534 | if( $this->getConfig( 'allowEmpty' )) { |
2253 | 2535 | $this->dtend = array( 'value' => null, 'params' => $this->_setParams( $params )); |
2254 | 2536 | return TRUE; |
2537 | + } else { |
|
2538 | + return FALSE; |
|
2255 | 2539 | } |
2256 | - else |
|
2257 | - return FALSE; |
|
2258 | 2540 | } |
2259 | 2541 | $this->dtend = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
2260 | 2542 | return TRUE; |
@@ -2276,8 +2558,9 @@ discard block |
||
2276 | 2558 | !isset( $this->dtstamp['value']['day'] ) && |
2277 | 2559 | !isset( $this->dtstamp['value']['hour'] ) && |
2278 | 2560 | !isset( $this->dtstamp['value']['min'] ) && |
2279 | - !isset( $this->dtstamp['value']['sec'] )) |
|
2280 | - $this->_makeDtstamp(); |
|
2561 | + !isset( $this->dtstamp['value']['sec'] )) { |
|
2562 | + $this->_makeDtstamp(); |
|
2563 | + } |
|
2281 | 2564 | $formatted = $this->_format_date_time( $this->dtstamp['value'], 7 ); |
2282 | 2565 | $attributes = $this->_createParams( $this->dtstamp['params'] ); |
2283 | 2566 | return $this->_createElement( 'DTSTAMP', $attributes, $formatted ); |
@@ -2313,10 +2596,11 @@ discard block |
||
2313 | 2596 | * @return TRUE |
2314 | 2597 | */ |
2315 | 2598 | function setDtstamp( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
2316 | - if( empty( $year )) |
|
2317 | - $this->_makeDtstamp(); |
|
2318 | - else |
|
2319 | - $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
|
2599 | + if( empty( $year )) { |
|
2600 | + $this->_makeDtstamp(); |
|
2601 | + } else { |
|
2602 | + $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
|
2603 | + } |
|
2320 | 2604 | return TRUE; |
2321 | 2605 | } |
2322 | 2606 | /*********************************************************************************/ |
@@ -2331,18 +2615,23 @@ discard block |
||
2331 | 2615 | * @return string |
2332 | 2616 | */ |
2333 | 2617 | function createDtstart() { |
2334 | - if( empty( $this->dtstart )) return FALSE; |
|
2618 | + if( empty( $this->dtstart )) { |
|
2619 | + return FALSE; |
|
2620 | + } |
|
2335 | 2621 | if( !isset( $this->dtstart['value']['year'] ) && |
2336 | 2622 | !isset( $this->dtstart['value']['month'] ) && |
2337 | 2623 | !isset( $this->dtstart['value']['day'] ) && |
2338 | 2624 | !isset( $this->dtstart['value']['hour'] ) && |
2339 | 2625 | !isset( $this->dtstart['value']['min'] ) && |
2340 | - !isset( $this->dtstart['value']['sec'] )) |
|
2341 | - if( $this->getConfig( 'allowEmpty' )) |
|
2626 | + !isset( $this->dtstart['value']['sec'] )) { |
|
2627 | + if( $this->getConfig( 'allowEmpty' )) |
|
2342 | 2628 | return $this->_createElement( 'DTSTART' ); |
2343 | - else return FALSE; |
|
2344 | - if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) |
|
2345 | - unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] ); |
|
2629 | + } else { |
|
2630 | + return FALSE; |
|
2631 | + } |
|
2632 | + if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) { |
|
2633 | + unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] ); |
|
2634 | + } |
|
2346 | 2635 | $formatted = $this->_format_date_time( $this->dtstart['value'] ); |
2347 | 2636 | $attributes = $this->_createParams( $this->dtstart['params'] ); |
2348 | 2637 | return $this->_createElement( 'DTSTART', $attributes, $formatted ); |
@@ -2367,9 +2656,9 @@ discard block |
||
2367 | 2656 | if( $this->getConfig( 'allowEmpty' )) { |
2368 | 2657 | $this->dtstart = array( 'value' => null, 'params' => $this->_setParams( $params )); |
2369 | 2658 | return TRUE; |
2659 | + } else { |
|
2660 | + return FALSE; |
|
2370 | 2661 | } |
2371 | - else |
|
2372 | - return FALSE; |
|
2373 | 2662 | } |
2374 | 2663 | $this->dtstart = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params, 'dtstart' ); |
2375 | 2664 | return TRUE; |
@@ -2386,16 +2675,20 @@ discard block |
||
2386 | 2675 | * @return string |
2387 | 2676 | */ |
2388 | 2677 | function createDue() { |
2389 | - if( empty( $this->due )) return FALSE; |
|
2678 | + if( empty( $this->due )) { |
|
2679 | + return FALSE; |
|
2680 | + } |
|
2390 | 2681 | if( !isset( $this->due['value']['year'] ) && |
2391 | 2682 | !isset( $this->due['value']['month'] ) && |
2392 | 2683 | !isset( $this->due['value']['day'] ) && |
2393 | 2684 | !isset( $this->due['value']['hour'] ) && |
2394 | 2685 | !isset( $this->due['value']['min'] ) && |
2395 | - !isset( $this->due['value']['sec'] )) |
|
2396 | - if( $this->getConfig( 'allowEmpty' )) |
|
2686 | + !isset( $this->due['value']['sec'] )) { |
|
2687 | + if( $this->getConfig( 'allowEmpty' )) |
|
2397 | 2688 | return $this->_createElement( 'DUE' ); |
2398 | - else return FALSE; |
|
2689 | + } else { |
|
2690 | + return FALSE; |
|
2691 | + } |
|
2399 | 2692 | $formatted = $this->_format_date_time( $this->due['value'] ); |
2400 | 2693 | $attributes = $this->_createParams( $this->due['params'] ); |
2401 | 2694 | return $this->_createElement( 'DUE', $attributes, $formatted ); |
@@ -2419,9 +2712,9 @@ discard block |
||
2419 | 2712 | if( $this->getConfig( 'allowEmpty' )) { |
2420 | 2713 | $this->due = array( 'value' => null, 'params' => $this->_setParams( $params )); |
2421 | 2714 | return TRUE; |
2715 | + } else { |
|
2716 | + return FALSE; |
|
2422 | 2717 | } |
2423 | - else |
|
2424 | - return FALSE; |
|
2425 | 2718 | } |
2426 | 2719 | $this->due = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
2427 | 2720 | return TRUE; |
@@ -2438,15 +2731,19 @@ discard block |
||
2438 | 2731 | * @return string |
2439 | 2732 | */ |
2440 | 2733 | function createDuration() { |
2441 | - if( empty( $this->duration )) return FALSE; |
|
2734 | + if( empty( $this->duration )) { |
|
2735 | + return FALSE; |
|
2736 | + } |
|
2442 | 2737 | if( !isset( $this->duration['value']['week'] ) && |
2443 | 2738 | !isset( $this->duration['value']['day'] ) && |
2444 | 2739 | !isset( $this->duration['value']['hour'] ) && |
2445 | 2740 | !isset( $this->duration['value']['min'] ) && |
2446 | - !isset( $this->duration['value']['sec'] )) |
|
2447 | - if( $this->getConfig( 'allowEmpty' )) |
|
2741 | + !isset( $this->duration['value']['sec'] )) { |
|
2742 | + if( $this->getConfig( 'allowEmpty' )) |
|
2448 | 2743 | return $this->_createElement( 'DURATION', array(), null ); |
2449 | - else return FALSE; |
|
2744 | + } else { |
|
2745 | + return FALSE; |
|
2746 | + } |
|
2450 | 2747 | $attributes = $this->_createParams( $this->duration['params'] ); |
2451 | 2748 | return $this->_createElement( 'DURATION', $attributes, $this->_format_duration( $this->duration['value'] )); |
2452 | 2749 | } |
@@ -2464,13 +2761,18 @@ discard block |
||
2464 | 2761 | * @return bool |
2465 | 2762 | */ |
2466 | 2763 | function setDuration( $week, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=array() ) { |
2467 | - if( empty( $week )) if( $this->getConfig( 'allowEmpty' )) $week = null; else return FALSE; |
|
2468 | - if( is_array( $week ) && ( 1 <= count( $week ))) |
|
2469 | - $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day )); |
|
2470 | - elseif( is_string( $week ) && ( 3 <= strlen( trim( $week )))) { |
|
2764 | + if( empty( $week )) { |
|
2765 | + if( $this->getConfig( 'allowEmpty' )) $week = null; |
|
2766 | + } else { |
|
2767 | + return FALSE; |
|
2768 | + } |
|
2769 | + if( is_array( $week ) && ( 1 <= count( $week ))) { |
|
2770 | + $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day )); |
|
2771 | + } elseif( is_string( $week ) && ( 3 <= strlen( trim( $week )))) { |
|
2471 | 2772 | $week = trim( $week ); |
2472 | - if( in_array( substr( $week, 0, 1 ), array( '+', '-' ))) |
|
2473 | - $week = substr( $week, 1 ); |
|
2773 | + if( in_array( substr( $week, 0, 1 ), array( '+', '-' ))) { |
|
2774 | + $week = substr( $week, 1 ); |
|
2775 | + } |
|
2474 | 2776 | $this->duration = array( 'value' => $this->_duration_string( $week ), 'params' => $this->_setParams( $day )); |
2475 | 2777 | } elseif (empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec )) { |
2476 | 2778 | return false; |
@@ -2494,31 +2796,37 @@ discard block |
||
2494 | 2796 | * @return string |
2495 | 2797 | */ |
2496 | 2798 | function createExdate() { |
2497 | - if( empty( $this->exdate )) return FALSE; |
|
2799 | + if( empty( $this->exdate )) { |
|
2800 | + return FALSE; |
|
2801 | + } |
|
2498 | 2802 | $output = null; |
2499 | 2803 | foreach( $this->exdate as $ex => $theExdate ) { |
2500 | 2804 | if( empty( $theExdate['value'] )) { |
2501 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'EXDATE' ); |
|
2805 | + if( $this->getConfig( 'allowEmpty' )) { |
|
2806 | + $output .= $this->_createElement( 'EXDATE' ); |
|
2807 | + } |
|
2502 | 2808 | continue; |
2503 | 2809 | } |
2504 | 2810 | $content = $attributes = null; |
2505 | 2811 | foreach( $theExdate['value'] as $eix => $exdatePart ) { |
2506 | 2812 | $parno = count( $exdatePart ); |
2507 | 2813 | $formatted = $this->_format_date_time( $exdatePart, $parno ); |
2508 | - if( isset( $theExdate['params']['TZID'] )) |
|
2509 | - $formatted = str_replace( 'Z', '', $formatted); |
|
2814 | + if( isset( $theExdate['params']['TZID'] )) { |
|
2815 | + $formatted = str_replace( 'Z', '', $formatted); |
|
2816 | + } |
|
2510 | 2817 | if( 0 < $eix ) { |
2511 | 2818 | if( isset( $theExdate['value'][0]['tz'] )) { |
2512 | 2819 | if( ctype_digit( substr( $theExdate['value'][0]['tz'], -4 )) || |
2513 | 2820 | ( 'Z' == $theExdate['value'][0]['tz'] )) { |
2514 | - if( 'Z' != substr( $formatted, -1 )) |
|
2515 | - $formatted .= 'Z'; |
|
2821 | + if( 'Z' != substr( $formatted, -1 )) { |
|
2822 | + $formatted .= 'Z'; |
|
2823 | + } |
|
2824 | + } else { |
|
2825 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
2516 | 2826 | } |
2517 | - else |
|
2518 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2827 | + } else { |
|
2828 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
2519 | 2829 | } |
2520 | - else |
|
2521 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2522 | 2830 | } |
2523 | 2831 | $content .= ( 0 < $eix ) ? ','.$formatted : $formatted; |
2524 | 2832 | } |
@@ -2542,34 +2850,39 @@ discard block |
||
2542 | 2850 | if( $this->getConfig( 'allowEmpty' )) { |
2543 | 2851 | $this->_setMval( $this->exdate, null, $params, FALSE, $index ); |
2544 | 2852 | return TRUE; |
2853 | + } else { |
|
2854 | + return FALSE; |
|
2545 | 2855 | } |
2546 | - else |
|
2547 | - return FALSE; |
|
2548 | 2856 | } |
2549 | 2857 | $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ))); |
2550 | 2858 | /* ev. check 1:st date and save ev. timezone **/ |
2551 | 2859 | $this->_chkdatecfg( reset( $exdates ), $parno, $input['params'] ); |
2552 | 2860 | $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default parameter |
2553 | 2861 | foreach( $exdates as $eix => $theExdate ) { |
2554 | - if( $this->_isArrayTimestampDate( $theExdate )) |
|
2555 | - $exdatea = $this->_timestamp2date( $theExdate, $parno ); |
|
2556 | - elseif( is_array( $theExdate )) |
|
2557 | - $exdatea = $this->_date_time_array( $theExdate, $parno ); |
|
2558 | - elseif( 8 <= strlen( trim( $theExdate ))) // ex. 2006-08-03 10:12:18 |
|
2862 | + if( $this->_isArrayTimestampDate( $theExdate )) { |
|
2863 | + $exdatea = $this->_timestamp2date( $theExdate, $parno ); |
|
2864 | + } elseif( is_array( $theExdate )) { |
|
2865 | + $exdatea = $this->_date_time_array( $theExdate, $parno ); |
|
2866 | + } elseif( 8 <= strlen( trim( $theExdate ))) { |
|
2867 | + // ex. 2006-08-03 10:12:18 |
|
2559 | 2868 | $exdatea = $this->_date_time_string( $theExdate, $parno ); |
2560 | - if( 3 == $parno ) |
|
2561 | - unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] ); |
|
2562 | - elseif( isset( $exdatea['tz'] )) |
|
2563 | - $exdatea['tz'] = (string) $exdatea['tz']; |
|
2869 | + } |
|
2870 | + if( 3 == $parno ) { |
|
2871 | + unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] ); |
|
2872 | + } elseif( isset( $exdatea['tz'] )) { |
|
2873 | + $exdatea['tz'] = (string) $exdatea['tz']; |
|
2874 | + } |
|
2564 | 2875 | if( isset( $input['params']['TZID'] ) || |
2565 | 2876 | ( isset( $exdatea['tz'] ) && !$this->_isOffset( $exdatea['tz'] )) || |
2566 | 2877 | ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) || |
2567 | - ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) |
|
2568 | - unset( $exdatea['tz'] ); |
|
2878 | + ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) { |
|
2879 | + unset( $exdatea['tz'] ); |
|
2880 | + } |
|
2569 | 2881 | $input['value'][] = $exdatea; |
2570 | 2882 | } |
2571 | - if( 0 >= count( $input['value'] )) |
|
2572 | - return FALSE; |
|
2883 | + if( 0 >= count( $input['value'] )) { |
|
2884 | + return FALSE; |
|
2885 | + } |
|
2573 | 2886 | if( 3 == $parno ) { |
2574 | 2887 | $input['params']['VALUE'] = 'DATE'; |
2575 | 2888 | unset( $input['params']['TZID'] ); |
@@ -2589,7 +2902,9 @@ discard block |
||
2589 | 2902 | * @return string |
2590 | 2903 | */ |
2591 | 2904 | function createExrule() { |
2592 | - if( empty( $this->exrule )) return FALSE; |
|
2905 | + if( empty( $this->exrule )) { |
|
2906 | + return FALSE; |
|
2907 | + } |
|
2593 | 2908 | return $this->_format_recur( 'EXRULE', $this->exrule ); |
2594 | 2909 | } |
2595 | 2910 | /** |
@@ -2603,7 +2918,11 @@ discard block |
||
2603 | 2918 | * @return bool |
2604 | 2919 | */ |
2605 | 2920 | function setExrule( $exruleset, $params=FALSE, $index=FALSE ) { |
2606 | - if( empty( $exruleset )) if( $this->getConfig( 'allowEmpty' )) $exruleset = null; else return FALSE; |
|
2921 | + if( empty( $exruleset )) { |
|
2922 | + if( $this->getConfig( 'allowEmpty' )) $exruleset = null; |
|
2923 | + } else { |
|
2924 | + return FALSE; |
|
2925 | + } |
|
2607 | 2926 | $this->_setMval( $this->exrule, $this->_setRexrule( $exruleset ), $params, FALSE, $index ); |
2608 | 2927 | return TRUE; |
2609 | 2928 | } |
@@ -2619,11 +2938,15 @@ discard block |
||
2619 | 2938 | * @return string |
2620 | 2939 | */ |
2621 | 2940 | function createFreebusy() { |
2622 | - if( empty( $this->freebusy )) return FALSE; |
|
2941 | + if( empty( $this->freebusy )) { |
|
2942 | + return FALSE; |
|
2943 | + } |
|
2623 | 2944 | $output = null; |
2624 | 2945 | foreach( $this->freebusy as $freebusyPart ) { |
2625 | 2946 | if( empty( $freebusyPart['value'] )) { |
2626 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'FREEBUSY' ); |
|
2947 | + if( $this->getConfig( 'allowEmpty' )) { |
|
2948 | + $output .= $this->_createElement( 'FREEBUSY' ); |
|
2949 | + } |
|
2627 | 2950 | continue; |
2628 | 2951 | } |
2629 | 2952 | $attributes = $content = null; |
@@ -2631,9 +2954,9 @@ discard block |
||
2631 | 2954 | $attributes .= $this->intAttrDelimiter.'FBTYPE='.$freebusyPart['value']['fbtype']; |
2632 | 2955 | unset( $freebusyPart['value']['fbtype'] ); |
2633 | 2956 | $freebusyPart['value'] = array_values( $freebusyPart['value'] ); |
2957 | + } else { |
|
2958 | + $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY'; |
|
2634 | 2959 | } |
2635 | - else |
|
2636 | - $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY'; |
|
2637 | 2960 | $attributes .= $this->_createParams( $freebusyPart['params'] ); |
2638 | 2961 | $fno = 1; |
2639 | 2962 | $cnt = count( $freebusyPart['value']); |
@@ -2642,21 +2965,24 @@ discard block |
||
2642 | 2965 | $content .= $formatted; |
2643 | 2966 | $content .= '/'; |
2644 | 2967 | $cnt2 = count( $freebusyPeriod[1]); |
2645 | - if( array_key_exists( 'year', $freebusyPeriod[1] )) // date-time |
|
2968 | + if( array_key_exists( 'year', $freebusyPeriod[1] )) { |
|
2969 | + // date-time |
|
2646 | 2970 | $cnt2 = 7; |
2647 | - elseif( array_key_exists( 'week', $freebusyPeriod[1] )) // duration |
|
2971 | + } elseif( array_key_exists( 'week', $freebusyPeriod[1] )) { |
|
2972 | + // duration |
|
2648 | 2973 | $cnt2 = 5; |
2974 | + } |
|
2649 | 2975 | if(( 7 == $cnt2 ) && // period= -> date-time |
2650 | 2976 | isset( $freebusyPeriod[1]['year'] ) && |
2651 | 2977 | isset( $freebusyPeriod[1]['month'] ) && |
2652 | 2978 | isset( $freebusyPeriod[1]['day'] )) { |
2653 | 2979 | $content .= $this->_format_date_time( $freebusyPeriod[1] ); |
2654 | - } |
|
2655 | - else { // period= -> dur-time |
|
2980 | + } else { // period= -> dur-time |
|
2656 | 2981 | $content .= $this->_format_duration( $freebusyPeriod[1] ); |
2657 | 2982 | } |
2658 | - if( $fno < $cnt ) |
|
2659 | - $content .= ','; |
|
2983 | + if( $fno < $cnt ) { |
|
2984 | + $content .= ','; |
|
2985 | + } |
|
2660 | 2986 | $fno++; |
2661 | 2987 | } |
2662 | 2988 | $output .= $this->_createElement( 'FREEBUSY', $attributes, $content ); |
@@ -2679,14 +3005,15 @@ discard block |
||
2679 | 3005 | if( $this->getConfig( 'allowEmpty' )) { |
2680 | 3006 | $this->_setMval( $this->freebusy, null, $params, FALSE, $index ); |
2681 | 3007 | return TRUE; |
3008 | + } else { |
|
3009 | + return FALSE; |
|
2682 | 3010 | } |
2683 | - else |
|
2684 | - return FALSE; |
|
2685 | 3011 | } |
2686 | 3012 | $fbType = strtoupper( $fbType ); |
2687 | 3013 | if(( !in_array( $fbType, array( 'FREE', 'BUSY', 'BUSY-UNAVAILABLE', 'BUSY-TENTATIVE' ))) && |
2688 | - ( 'X-' != substr( $fbType, 0, 2 ))) |
|
2689 | - $fbType = 'BUSY'; |
|
3014 | + ( 'X-' != substr( $fbType, 0, 2 ))) { |
|
3015 | + $fbType = 'BUSY'; |
|
3016 | + } |
|
2690 | 3017 | $input = array( 'fbtype' => $fbType ); |
2691 | 3018 | foreach( $fbValues as $fbPeriod ) { // periods => period |
2692 | 3019 | $freebusyPeriod = array(); |
@@ -2696,22 +3023,19 @@ discard block |
||
2696 | 3023 | if( $this->_isArrayDate( $fbMember )) { // date-time value |
2697 | 3024 | $freebusyPairMember = $this->_date_time_array( $fbMember, 7 ); |
2698 | 3025 | $freebusyPairMember['tz'] = 'Z'; |
2699 | - } |
|
2700 | - elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value |
|
3026 | + } elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value |
|
2701 | 3027 | $freebusyPairMember = $this->_timestamp2date( $fbMember['timestamp'], 7 ); |
2702 | 3028 | $freebusyPairMember['tz'] = 'Z'; |
2703 | - } |
|
2704 | - else { // array format duration |
|
3029 | + } else { // array format duration |
|
2705 | 3030 | $freebusyPairMember = $this->_duration_array( $fbMember ); |
2706 | 3031 | } |
2707 | - } |
|
2708 | - elseif(( 3 <= strlen( trim( $fbMember ))) && // string format duration |
|
3032 | + } elseif(( 3 <= strlen( trim( $fbMember ))) && // string format duration |
|
2709 | 3033 | ( in_array( $fbMember{0}, array( 'P', '+', '-' )))) { |
2710 | - if( 'P' != $fbMember{0} ) |
|
2711 | - $fbmember = substr( $fbMember, 1 ); |
|
3034 | + if( 'P' != $fbMember{0} ) { |
|
3035 | + $fbmember = substr( $fbMember, 1 ); |
|
3036 | + } |
|
2712 | 3037 | $freebusyPairMember = $this->_duration_string( $fbMember ); |
2713 | - } |
|
2714 | - elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18 |
|
3038 | + } elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18 |
|
2715 | 3039 | $freebusyPairMember = $this->_date_time_string( $fbMember, 7 ); |
2716 | 3040 | $freebusyPairMember['tz'] = 'Z'; |
2717 | 3041 | } |
@@ -2734,9 +3058,12 @@ discard block |
||
2734 | 3058 | * @return string |
2735 | 3059 | */ |
2736 | 3060 | function createGeo() { |
2737 | - if( empty( $this->geo )) return FALSE; |
|
2738 | - if( empty( $this->geo['value'] )) |
|
2739 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE; |
|
3061 | + if( empty( $this->geo )) { |
|
3062 | + return FALSE; |
|
3063 | + } |
|
3064 | + if( empty( $this->geo['value'] )) { |
|
3065 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE; |
|
3066 | + } |
|
2740 | 3067 | $attributes = $this->_createParams( $this->geo['params'] ); |
2741 | 3068 | $content = null; |
2742 | 3069 | $content .= number_format( (float) $this->geo['value']['latitude'], 6, '.', ''); |
@@ -2756,15 +3083,17 @@ discard block |
||
2756 | 3083 | */ |
2757 | 3084 | function setGeo( $latitude, $longitude, $params=array() ) { |
2758 | 3085 | if( !empty( $latitude ) && !empty( $longitude )) { |
2759 | - if( !is_array( $this->geo )) $this->geo = array(); |
|
3086 | + if( !is_array( $this->geo )) { |
|
3087 | + $this->geo = array(); |
|
3088 | + } |
|
2760 | 3089 | $this->geo['value']['latitude'] = $latitude; |
2761 | 3090 | $this->geo['value']['longitude'] = $longitude; |
2762 | 3091 | $this->geo['params'] = $this->_setParams( $params ); |
3092 | + } elseif( $this->getConfig( 'allowEmpty' )) { |
|
3093 | + $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) ); |
|
3094 | + } else { |
|
3095 | + return FALSE; |
|
2763 | 3096 | } |
2764 | - elseif( $this->getConfig( 'allowEmpty' )) |
|
2765 | - $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) ); |
|
2766 | - else |
|
2767 | - return FALSE; |
|
2768 | 3097 | return TRUE; |
2769 | 3098 | } |
2770 | 3099 | /*********************************************************************************/ |
@@ -2779,7 +3108,9 @@ discard block |
||
2779 | 3108 | * @return string |
2780 | 3109 | */ |
2781 | 3110 | function createLastModified() { |
2782 | - if( empty( $this->lastmodified )) return FALSE; |
|
3111 | + if( empty( $this->lastmodified )) { |
|
3112 | + return FALSE; |
|
3113 | + } |
|
2783 | 3114 | $attributes = $this->_createParams( $this->lastmodified['params'] ); |
2784 | 3115 | $formatted = $this->_format_date_time( $this->lastmodified['value'], 7 ); |
2785 | 3116 | return $this->_createElement( 'LAST-MODIFIED', $attributes, $formatted ); |
@@ -2799,8 +3130,9 @@ discard block |
||
2799 | 3130 | * @return boll |
2800 | 3131 | */ |
2801 | 3132 | function setLastModified( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
2802 | - if( empty( $year )) |
|
2803 | - $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' ))); |
|
3133 | + if( empty( $year )) { |
|
3134 | + $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' ))); |
|
3135 | + } |
|
2804 | 3136 | $this->lastmodified = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
2805 | 3137 | return TRUE; |
2806 | 3138 | } |
@@ -2816,9 +3148,12 @@ discard block |
||
2816 | 3148 | * @return string |
2817 | 3149 | */ |
2818 | 3150 | function createLocation() { |
2819 | - if( empty( $this->location )) return FALSE; |
|
2820 | - if( empty( $this->location['value'] )) |
|
2821 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE; |
|
3151 | + if( empty( $this->location )) { |
|
3152 | + return FALSE; |
|
3153 | + } |
|
3154 | + if( empty( $this->location['value'] )) { |
|
3155 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE; |
|
3156 | + } |
|
2822 | 3157 | $attributes = $this->_createParams( $this->location['params'], array( 'ALTREP', 'LANGUAGE' )); |
2823 | 3158 | $content = $this->_strrep( $this->location['value'] ); |
2824 | 3159 | return $this->_createElement( 'LOCATION', $attributes, $content ); |
@@ -2833,7 +3168,11 @@ discard block |
||
2833 | 3168 | * @return bool |
2834 | 3169 | */ |
2835 | 3170 | function setLocation( $value, $params=FALSE ) { |
2836 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3171 | + if( empty( $value )) { |
|
3172 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3173 | + } else { |
|
3174 | + return FALSE; |
|
3175 | + } |
|
2837 | 3176 | $this->location = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
2838 | 3177 | return TRUE; |
2839 | 3178 | } |
@@ -2849,9 +3188,12 @@ discard block |
||
2849 | 3188 | * @return string |
2850 | 3189 | */ |
2851 | 3190 | function createOrganizer() { |
2852 | - if( empty( $this->organizer )) return FALSE; |
|
2853 | - if( empty( $this->organizer['value'] )) |
|
2854 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE; |
|
3191 | + if( empty( $this->organizer )) { |
|
3192 | + return FALSE; |
|
3193 | + } |
|
3194 | + if( empty( $this->organizer['value'] )) { |
|
3195 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE; |
|
3196 | + } |
|
2855 | 3197 | $attributes = $this->_createParams( $this->organizer['params'] |
2856 | 3198 | , array( 'CN', 'DIR', 'LANGUAGE', 'SENT-BY' )); |
2857 | 3199 | $content = 'MAILTO:'.$this->organizer['value']; |
@@ -2867,13 +3209,18 @@ discard block |
||
2867 | 3209 | * @return bool |
2868 | 3210 | */ |
2869 | 3211 | function setOrganizer( $value, $params=FALSE ) { |
2870 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3212 | + if( empty( $value )) { |
|
3213 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3214 | + } else { |
|
3215 | + return FALSE; |
|
3216 | + } |
|
2871 | 3217 | $value = str_replace ( 'MAILTO:', '', $value ); |
2872 | 3218 | $value = str_replace ( 'mailto:', '', $value ); |
2873 | 3219 | $this->organizer = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
2874 | 3220 | if( isset( $this->organizer['params']['SENT-BY'] )) { |
2875 | - if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 ))) |
|
2876 | - $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 ); |
|
3221 | + if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 ))) { |
|
3222 | + $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 ); |
|
3223 | + } |
|
2877 | 3224 | } |
2878 | 3225 | return TRUE; |
2879 | 3226 | } |
@@ -2889,9 +3236,12 @@ discard block |
||
2889 | 3236 | * @return string |
2890 | 3237 | */ |
2891 | 3238 | function createPercentComplete() { |
2892 | - if( empty( $this->percentcomplete )) return FALSE; |
|
2893 | - if( empty( $this->percentcomplete['value'] )) |
|
2894 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE; |
|
3239 | + if( empty( $this->percentcomplete )) { |
|
3240 | + return FALSE; |
|
3241 | + } |
|
3242 | + if( empty( $this->percentcomplete['value'] )) { |
|
3243 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE; |
|
3244 | + } |
|
2895 | 3245 | $attributes = $this->_createParams( $this->percentcomplete['params'] ); |
2896 | 3246 | return $this->_createElement( 'PERCENT-COMPLETE', $attributes, $this->percentcomplete['value'] ); |
2897 | 3247 | } |
@@ -2905,7 +3255,11 @@ discard block |
||
2905 | 3255 | * @return bool |
2906 | 3256 | */ |
2907 | 3257 | function setPercentComplete( $value, $params=FALSE ) { |
2908 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3258 | + if( empty( $value )) { |
|
3259 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3260 | + } else { |
|
3261 | + return FALSE; |
|
3262 | + } |
|
2909 | 3263 | $this->percentcomplete = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
2910 | 3264 | return TRUE; |
2911 | 3265 | } |
@@ -2921,9 +3275,12 @@ discard block |
||
2921 | 3275 | * @return string |
2922 | 3276 | */ |
2923 | 3277 | function createPriority() { |
2924 | - if( empty( $this->priority )) return FALSE; |
|
2925 | - if( empty( $this->priority['value'] )) |
|
2926 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE; |
|
3278 | + if( empty( $this->priority )) { |
|
3279 | + return FALSE; |
|
3280 | + } |
|
3281 | + if( empty( $this->priority['value'] )) { |
|
3282 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE; |
|
3283 | + } |
|
2927 | 3284 | $attributes = $this->_createParams( $this->priority['params'] ); |
2928 | 3285 | return $this->_createElement( 'PRIORITY', $attributes, $this->priority['value'] ); |
2929 | 3286 | } |
@@ -2937,7 +3294,11 @@ discard block |
||
2937 | 3294 | * @return bool |
2938 | 3295 | */ |
2939 | 3296 | function setPriority( $value, $params=array() ) { |
2940 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3297 | + if( empty( $value )) { |
|
3298 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3299 | + } else { |
|
3300 | + return FALSE; |
|
3301 | + } |
|
2941 | 3302 | $this->priority = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
2942 | 3303 | return TRUE; |
2943 | 3304 | } |
@@ -2953,18 +3314,24 @@ discard block |
||
2953 | 3314 | * @return string |
2954 | 3315 | */ |
2955 | 3316 | function createRdate() { |
2956 | - if( empty( $this->rdate )) return FALSE; |
|
3317 | + if( empty( $this->rdate )) { |
|
3318 | + return FALSE; |
|
3319 | + } |
|
2957 | 3320 | $utctime = ( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE; |
2958 | 3321 | $output = null; |
2959 | - if( $utctime ) |
|
2960 | - unset( $this->rdate['params']['TZID'] ); |
|
3322 | + if( $utctime ) { |
|
3323 | + unset( $this->rdate['params']['TZID'] ); |
|
3324 | + } |
|
2961 | 3325 | foreach( $this->rdate as $theRdate ) { |
2962 | 3326 | if( empty( $theRdate['value'] )) { |
2963 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RDATE' ); |
|
3327 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3328 | + $output .= $this->_createElement( 'RDATE' ); |
|
3329 | + } |
|
2964 | 3330 | continue; |
2965 | 3331 | } |
2966 | - if( $utctime ) |
|
2967 | - unset( $theRdate['params']['TZID'] ); |
|
3332 | + if( $utctime ) { |
|
3333 | + unset( $theRdate['params']['TZID'] ); |
|
3334 | + } |
|
2968 | 3335 | $attributes = $this->_createParams( $theRdate['params'] ); |
2969 | 3336 | $cnt = count( $theRdate['value'] ); |
2970 | 3337 | $content = null; |
@@ -2973,68 +3340,84 @@ discard block |
||
2973 | 3340 | $contentPart = null; |
2974 | 3341 | if( is_array( $rdatePart ) && |
2975 | 3342 | isset( $theRdate['params']['VALUE'] ) && ( 'PERIOD' == $theRdate['params']['VALUE'] )) { // PERIOD |
2976 | - if( $utctime ) |
|
2977 | - unset( $rdatePart[0]['tz'] ); |
|
3343 | + if( $utctime ) { |
|
3344 | + unset( $rdatePart[0]['tz'] ); |
|
3345 | + } |
|
2978 | 3346 | $formatted = $this->_format_date_time( $rdatePart[0]); // PERIOD part 1 |
2979 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
2980 | - $formatted = str_replace( 'Z', '', $formatted); |
|
3347 | + if( $utctime || !empty( $theRdate['params']['TZID'] )) { |
|
3348 | + $formatted = str_replace( 'Z', '', $formatted); |
|
3349 | + } |
|
2981 | 3350 | if( 0 < $rpix ) { |
2982 | 3351 | if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) { |
2983 | - if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z'; |
|
3352 | + if( 'Z' != substr( $formatted, -1 )) { |
|
3353 | + $formatted .= 'Z'; |
|
3354 | + } |
|
3355 | + } else { |
|
3356 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
2984 | 3357 | } |
2985 | - else |
|
2986 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2987 | 3358 | } |
2988 | 3359 | $contentPart .= $formatted; |
2989 | 3360 | $contentPart .= '/'; |
2990 | 3361 | $cnt2 = count( $rdatePart[1]); |
2991 | 3362 | if( array_key_exists( 'year', $rdatePart[1] )) { |
2992 | - if( array_key_exists( 'hour', $rdatePart[1] )) |
|
2993 | - $cnt2 = 7; // date-time |
|
2994 | - else |
|
2995 | - $cnt2 = 3; // date |
|
2996 | - } |
|
2997 | - elseif( array_key_exists( 'week', $rdatePart[1] )) // duration |
|
3363 | + if( array_key_exists( 'hour', $rdatePart[1] )) { |
|
3364 | + $cnt2 = 7; |
|
3365 | + } |
|
3366 | + // date-time |
|
3367 | + else { |
|
3368 | + $cnt2 = 3; |
|
3369 | + } |
|
3370 | + // date |
|
3371 | + } elseif( array_key_exists( 'week', $rdatePart[1] )) { |
|
3372 | + // duration |
|
2998 | 3373 | $cnt2 = 5; |
3374 | + } |
|
2999 | 3375 | if(( 7 == $cnt2 ) && // period= -> date-time |
3000 | 3376 | isset( $rdatePart[1]['year'] ) && |
3001 | 3377 | isset( $rdatePart[1]['month'] ) && |
3002 | 3378 | isset( $rdatePart[1]['day'] )) { |
3003 | - if( $utctime ) |
|
3004 | - unset( $rdatePart[1]['tz'] ); |
|
3379 | + if( $utctime ) { |
|
3380 | + unset( $rdatePart[1]['tz'] ); |
|
3381 | + } |
|
3005 | 3382 | $formatted = $this->_format_date_time( $rdatePart[1] ); // PERIOD part 2 |
3006 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
3007 | - $formatted = str_replace( 'Z', '', $formatted); |
|
3383 | + if( $utctime || !empty( $theRdate['params']['TZID'] )) { |
|
3384 | + $formatted = str_replace( 'Z', '', $formatted); |
|
3385 | + } |
|
3008 | 3386 | if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) { |
3009 | - if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z'; |
|
3387 | + if( 'Z' != substr( $formatted, -1 )) { |
|
3388 | + $formatted .= 'Z'; |
|
3389 | + } |
|
3390 | + } else { |
|
3391 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
3010 | 3392 | } |
3011 | - else |
|
3012 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
3013 | 3393 | $contentPart .= $formatted; |
3014 | - } |
|
3015 | - else { // period= -> dur-time |
|
3394 | + } else { // period= -> dur-time |
|
3016 | 3395 | $contentPart .= $this->_format_duration( $rdatePart[1] ); |
3017 | 3396 | } |
3018 | 3397 | } // PERIOD end |
3019 | 3398 | else { // SINGLE date start |
3020 | - if( $utctime ) |
|
3021 | - unset( $rdatePart['tz'] ); |
|
3399 | + if( $utctime ) { |
|
3400 | + unset( $rdatePart['tz'] ); |
|
3401 | + } |
|
3022 | 3402 | $formatted = $this->_format_date_time( $rdatePart); |
3023 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
3024 | - $formatted = str_replace( 'Z', '', $formatted); |
|
3403 | + if( $utctime || !empty( $theRdate['params']['TZID'] )) { |
|
3404 | + $formatted = str_replace( 'Z', '', $formatted); |
|
3405 | + } |
|
3025 | 3406 | if( !$utctime && ( 0 < $rpix )) { |
3026 | 3407 | if( !empty( $theRdate['value'][0]['tz'] ) && $this->_isOffset( $theRdate['value'][0]['tz'] )) { |
3027 | - if( 'Z' != substr( $formatted, -1 )) |
|
3028 | - $formatted .= 'Z'; |
|
3408 | + if( 'Z' != substr( $formatted, -1 )) { |
|
3409 | + $formatted .= 'Z'; |
|
3410 | + } |
|
3411 | + } else { |
|
3412 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
3029 | 3413 | } |
3030 | - else |
|
3031 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
3032 | 3414 | } |
3033 | 3415 | $contentPart .= $formatted; |
3034 | 3416 | } |
3035 | 3417 | $content .= $contentPart; |
3036 | - if( $rno < $cnt ) |
|
3037 | - $content .= ','; |
|
3418 | + if( $rno < $cnt ) { |
|
3419 | + $content .= ','; |
|
3420 | + } |
|
3038 | 3421 | $rno++; |
3039 | 3422 | } |
3040 | 3423 | $output .= $this->_createElement( 'RDATE', $attributes, $content ); |
@@ -3056,9 +3439,9 @@ discard block |
||
3056 | 3439 | if( $this->getConfig( 'allowEmpty' )) { |
3057 | 3440 | $this->_setMval( $this->rdate, null, $params, FALSE, $index ); |
3058 | 3441 | return TRUE; |
3442 | + } else { |
|
3443 | + return FALSE; |
|
3059 | 3444 | } |
3060 | - else |
|
3061 | - return FALSE; |
|
3062 | 3445 | } |
3063 | 3446 | $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ))); |
3064 | 3447 | if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) { |
@@ -3072,15 +3455,19 @@ discard block |
||
3072 | 3455 | (( is_array( $rdates[0][0] ) && ( isset( $rdates[0][0]['timestamp'] ) || |
3073 | 3456 | $this->_isArrayDate( $rdates[0][0] ))) || |
3074 | 3457 | ( is_string( $rdates[0][0] ) && ( 8 <= strlen( trim( $rdates[0][0] ))))) && |
3075 | - ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] )))))) |
|
3076 | - $input['params']['VALUE'] = 'PERIOD'; |
|
3458 | + ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] )))))) { |
|
3459 | + $input['params']['VALUE'] = 'PERIOD'; |
|
3460 | + } |
|
3077 | 3461 | /* check 1:st date, upd. $parno (opt) and save ev. timezone **/ |
3078 | 3462 | $date = reset( $rdates ); |
3079 | - if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) // PERIOD |
|
3463 | + if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) { |
|
3464 | + // PERIOD |
|
3080 | 3465 | $date = reset( $date ); |
3466 | + } |
|
3081 | 3467 | $this->_chkdatecfg( $date, $parno, $input['params'] ); |
3082 | - if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) |
|
3083 | - unset( $input['params']['TZID'] ); |
|
3468 | + if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) { |
|
3469 | + unset( $input['params']['TZID'] ); |
|
3470 | + } |
|
3084 | 3471 | $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default |
3085 | 3472 | foreach( $rdates as $rpix => $theRdate ) { |
3086 | 3473 | $inputa = null; |
@@ -3088,48 +3475,60 @@ discard block |
||
3088 | 3475 | if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) { // PERIOD |
3089 | 3476 | foreach( $theRdate as $rix => $rPeriod ) { |
3090 | 3477 | if( is_array( $rPeriod )) { |
3091 | - if( $this->_isArrayTimestampDate( $rPeriod )) // timestamp |
|
3478 | + if( $this->_isArrayTimestampDate( $rPeriod )) { |
|
3479 | + // timestamp |
|
3092 | 3480 | $inputab = ( isset( $rPeriod['tz'] )) ? $this->_timestamp2date( $rPeriod, $parno ) : $this->_timestamp2date( $rPeriod, 6 ); |
3093 | - elseif( $this->_isArrayDate( $rPeriod )) |
|
3094 | - $inputab = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 ); |
|
3095 | - elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod )))) // text-date |
|
3481 | + } elseif( $this->_isArrayDate( $rPeriod )) { |
|
3482 | + $inputab = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 ); |
|
3483 | + } elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod )))) { |
|
3484 | + // text-date |
|
3096 | 3485 | $inputab = $this->_date_time_string( reset( $rPeriod ), $parno ); |
3097 | - else // array format duration |
|
3486 | + } else { |
|
3487 | + // array format duration |
|
3098 | 3488 | $inputab = $this->_duration_array( $rPeriod ); |
3099 | - } |
|
3100 | - elseif(( 3 <= strlen( trim( $rPeriod ))) && // string format duration |
|
3489 | + } |
|
3490 | + } elseif(( 3 <= strlen( trim( $rPeriod ))) && // string format duration |
|
3101 | 3491 | ( in_array( $rPeriod{0}, array( 'P', '+', '-' )))) { |
3102 | - if( 'P' != $rPeriod{0} ) |
|
3103 | - $rPeriod = substr( $rPeriod, 1 ); |
|
3492 | + if( 'P' != $rPeriod{0} ) { |
|
3493 | + $rPeriod = substr( $rPeriod, 1 ); |
|
3494 | + } |
|
3104 | 3495 | $inputab = $this->_duration_string( $rPeriod ); |
3105 | - } |
|
3106 | - elseif( 8 <= strlen( trim( $rPeriod ))) // text date ex. 2006-08-03 10:12:18 |
|
3496 | + } elseif( 8 <= strlen( trim( $rPeriod ))) { |
|
3497 | + // text date ex. 2006-08-03 10:12:18 |
|
3107 | 3498 | $inputab = $this->_date_time_string( $rPeriod, $parno ); |
3499 | + } |
|
3108 | 3500 | if( isset( $input['params']['TZID'] ) || |
3109 | 3501 | ( isset( $inputab['tz'] ) && !$this->_isOffset( $inputab['tz'] )) || |
3110 | 3502 | ( isset( $inputa[0] ) && ( !isset( $inputa[0]['tz'] ))) || |
3111 | - ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] ))) |
|
3112 | - unset( $inputab['tz'] ); |
|
3503 | + ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] ))) { |
|
3504 | + unset( $inputab['tz'] ); |
|
3505 | + } |
|
3113 | 3506 | $inputa[] = $inputab; |
3114 | 3507 | } |
3115 | 3508 | } // PERIOD end |
3116 | - elseif ( $this->_isArrayTimestampDate( $theRdate )) // timestamp |
|
3509 | + elseif ( $this->_isArrayTimestampDate( $theRdate )) { |
|
3510 | + // timestamp |
|
3117 | 3511 | $inputa = $this->_timestamp2date( $theRdate, $parno ); |
3118 | - else // date[-time] |
|
3512 | + } else { |
|
3513 | + // date[-time] |
|
3119 | 3514 | $inputa = $this->_date_time_array( $theRdate, $parno ); |
3120 | - } |
|
3121 | - elseif( 8 <= strlen( trim( $theRdate ))) // text date ex. 2006-08-03 10:12:18 |
|
3515 | + } |
|
3516 | + } elseif( 8 <= strlen( trim( $theRdate ))) { |
|
3517 | + // text date ex. 2006-08-03 10:12:18 |
|
3122 | 3518 | $inputa = $this->_date_time_string( $theRdate, $parno ); |
3519 | + } |
|
3123 | 3520 | if( !isset( $input['params']['VALUE'] ) || ( 'PERIOD' != $input['params']['VALUE'] )) { // no PERIOD |
3124 | - if( 3 == $parno ) |
|
3125 | - unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] ); |
|
3126 | - elseif( isset( $inputa['tz'] )) |
|
3127 | - $inputa['tz'] = (string) $inputa['tz']; |
|
3521 | + if( 3 == $parno ) { |
|
3522 | + unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] ); |
|
3523 | + } elseif( isset( $inputa['tz'] )) { |
|
3524 | + $inputa['tz'] = (string) $inputa['tz']; |
|
3525 | + } |
|
3128 | 3526 | if( isset( $input['params']['TZID'] ) || |
3129 | 3527 | ( isset( $inputa['tz'] ) && !$this->_isOffset( $inputa['tz'] )) || |
3130 | 3528 | ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) || |
3131 | - ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) |
|
3132 | - unset( $inputa['tz'] ); |
|
3529 | + ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) { |
|
3530 | + unset( $inputa['tz'] ); |
|
3531 | + } |
|
3133 | 3532 | } |
3134 | 3533 | $input['value'][] = $inputa; |
3135 | 3534 | } |
@@ -3152,9 +3551,12 @@ discard block |
||
3152 | 3551 | * @return string |
3153 | 3552 | */ |
3154 | 3553 | function createRecurrenceid() { |
3155 | - if( empty( $this->recurrenceid )) return FALSE; |
|
3156 | - if( empty( $this->recurrenceid['value'] )) |
|
3157 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE; |
|
3554 | + if( empty( $this->recurrenceid )) { |
|
3555 | + return FALSE; |
|
3556 | + } |
|
3557 | + if( empty( $this->recurrenceid['value'] )) { |
|
3558 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE; |
|
3559 | + } |
|
3158 | 3560 | $formatted = $this->_format_date_time( $this->recurrenceid['value'] ); |
3159 | 3561 | $attributes = $this->_createParams( $this->recurrenceid['params'] ); |
3160 | 3562 | return $this->_createElement( 'RECURRENCE-ID', $attributes, $formatted ); |
@@ -3178,9 +3580,9 @@ discard block |
||
3178 | 3580 | if( $this->getConfig( 'allowEmpty' )) { |
3179 | 3581 | $this->recurrenceid = array( 'value' => null, 'params' => null ); |
3180 | 3582 | return TRUE; |
3583 | + } else { |
|
3584 | + return FALSE; |
|
3181 | 3585 | } |
3182 | - else |
|
3183 | - return FALSE; |
|
3184 | 3586 | } |
3185 | 3587 | $this->recurrenceid = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
3186 | 3588 | return TRUE; |
@@ -3197,11 +3599,15 @@ discard block |
||
3197 | 3599 | * @return string |
3198 | 3600 | */ |
3199 | 3601 | function createRelatedTo() { |
3200 | - if( empty( $this->relatedto )) return FALSE; |
|
3602 | + if( empty( $this->relatedto )) { |
|
3603 | + return FALSE; |
|
3604 | + } |
|
3201 | 3605 | $output = null; |
3202 | 3606 | foreach( $this->relatedto as $relation ) { |
3203 | 3607 | if( empty( $relation['value'] )) { |
3204 | - if( $this->getConfig( 'allowEmpty' )) $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] )); |
|
3608 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3609 | + $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] )); |
|
3610 | + } |
|
3205 | 3611 | continue; |
3206 | 3612 | } |
3207 | 3613 | $attributes = $this->_createParams( $relation['params'] ); |
@@ -3223,9 +3629,14 @@ discard block |
||
3223 | 3629 | * @return bool |
3224 | 3630 | */ |
3225 | 3631 | function setRelatedTo( $value, $params=FALSE, $index=FALSE ) { |
3226 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3227 | - if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 ))) |
|
3228 | - $value = substr( $value, 1, ( strlen( $value ) - 2 )); |
|
3632 | + if( empty( $value )) { |
|
3633 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3634 | + } else { |
|
3635 | + return FALSE; |
|
3636 | + } |
|
3637 | + if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 ))) { |
|
3638 | + $value = substr( $value, 1, ( strlen( $value ) - 2 )); |
|
3639 | + } |
|
3229 | 3640 | $this->_existRem( $params, 'RELTYPE', 'PARENT', TRUE ); // remove default |
3230 | 3641 | $this->_setMval( $this->relatedto, $value, $params, FALSE, $index ); |
3231 | 3642 | return TRUE; |
@@ -3242,9 +3653,12 @@ discard block |
||
3242 | 3653 | * @return string |
3243 | 3654 | */ |
3244 | 3655 | function createRepeat() { |
3245 | - if( empty( $this->repeat )) return FALSE; |
|
3246 | - if( empty( $this->repeat['value'] )) |
|
3247 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE; |
|
3656 | + if( empty( $this->repeat )) { |
|
3657 | + return FALSE; |
|
3658 | + } |
|
3659 | + if( empty( $this->repeat['value'] )) { |
|
3660 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE; |
|
3661 | + } |
|
3248 | 3662 | $attributes = $this->_createParams( $this->repeat['params'] ); |
3249 | 3663 | return $this->_createElement( 'REPEAT', $attributes, $this->repeat['value'] ); |
3250 | 3664 | } |
@@ -3258,7 +3672,11 @@ discard block |
||
3258 | 3672 | * @return void |
3259 | 3673 | */ |
3260 | 3674 | function setRepeat( $value, $params=FALSE ) { |
3261 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3675 | + if( empty( $value )) { |
|
3676 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3677 | + } else { |
|
3678 | + return FALSE; |
|
3679 | + } |
|
3262 | 3680 | $this->repeat = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3263 | 3681 | return TRUE; |
3264 | 3682 | } |
@@ -3273,18 +3691,23 @@ discard block |
||
3273 | 3691 | * @return string |
3274 | 3692 | */ |
3275 | 3693 | function createRequestStatus() { |
3276 | - if( empty( $this->requeststatus )) return FALSE; |
|
3694 | + if( empty( $this->requeststatus )) { |
|
3695 | + return FALSE; |
|
3696 | + } |
|
3277 | 3697 | $output = null; |
3278 | 3698 | foreach( $this->requeststatus as $rstat ) { |
3279 | 3699 | if( empty( $rstat['value']['statcode'] )) { |
3280 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'REQUEST-STATUS' ); |
|
3700 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3701 | + $output .= $this->_createElement( 'REQUEST-STATUS' ); |
|
3702 | + } |
|
3281 | 3703 | continue; |
3282 | 3704 | } |
3283 | 3705 | $attributes = $this->_createParams( $rstat['params'], array( 'LANGUAGE' )); |
3284 | 3706 | $content = number_format( (float) $rstat['value']['statcode'], 2, '.', ''); |
3285 | 3707 | $content .= ';'.$this->_strrep( $rstat['value']['text'] ); |
3286 | - if( isset( $rstat['value']['extdata'] )) |
|
3287 | - $content .= ';'.$this->_strrep( $rstat['value']['extdata'] ); |
|
3708 | + if( isset( $rstat['value']['extdata'] )) { |
|
3709 | + $content .= ';'.$this->_strrep( $rstat['value']['extdata'] ); |
|
3710 | + } |
|
3288 | 3711 | $output .= $this->_createElement( 'REQUEST-STATUS', $attributes, $content ); |
3289 | 3712 | } |
3290 | 3713 | return $output; |
@@ -3302,10 +3725,15 @@ discard block |
||
3302 | 3725 | * @return bool |
3303 | 3726 | */ |
3304 | 3727 | function setRequestStatus( $statcode, $text, $extdata=FALSE, $params=FALSE, $index=FALSE ) { |
3305 | - if( empty( $statcode ) || empty( $text )) if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null; else return FALSE; |
|
3728 | + if( empty( $statcode ) || empty( $text )) { |
|
3729 | + if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null; |
|
3730 | + } else { |
|
3731 | + return FALSE; |
|
3732 | + } |
|
3306 | 3733 | $input = array( 'statcode' => $statcode, 'text' => $text ); |
3307 | - if( $extdata ) |
|
3308 | - $input['extdata'] = $extdata; |
|
3734 | + if( $extdata ) { |
|
3735 | + $input['extdata'] = $extdata; |
|
3736 | + } |
|
3309 | 3737 | $this->_setMval( $this->requeststatus, $input, $params, FALSE, $index ); |
3310 | 3738 | return TRUE; |
3311 | 3739 | } |
@@ -3321,21 +3749,26 @@ discard block |
||
3321 | 3749 | * @return string |
3322 | 3750 | */ |
3323 | 3751 | function createResources() { |
3324 | - if( empty( $this->resources )) return FALSE; |
|
3752 | + if( empty( $this->resources )) { |
|
3753 | + return FALSE; |
|
3754 | + } |
|
3325 | 3755 | $output = null; |
3326 | 3756 | foreach( $this->resources as $resource ) { |
3327 | 3757 | if( empty( $resource['value'] )) { |
3328 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RESOURCES' ); |
|
3758 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3759 | + $output .= $this->_createElement( 'RESOURCES' ); |
|
3760 | + } |
|
3329 | 3761 | continue; |
3330 | 3762 | } |
3331 | 3763 | $attributes = $this->_createParams( $resource['params'], array( 'ALTREP', 'LANGUAGE' )); |
3332 | 3764 | if( is_array( $resource['value'] )) { |
3333 | - foreach( $resource['value'] as $rix => $resourcePart ) |
|
3334 | - $resource['value'][$rix] = $this->_strrep( $resourcePart ); |
|
3765 | + foreach( $resource['value'] as $rix => $resourcePart ) { |
|
3766 | + $resource['value'][$rix] = $this->_strrep( $resourcePart ); |
|
3767 | + } |
|
3335 | 3768 | $content = implode( ',', $resource['value'] ); |
3769 | + } else { |
|
3770 | + $content = $this->_strrep( $resource['value'] ); |
|
3336 | 3771 | } |
3337 | - else |
|
3338 | - $content = $this->_strrep( $resource['value'] ); |
|
3339 | 3772 | $output .= $this->_createElement( 'RESOURCES', $attributes, $content ); |
3340 | 3773 | } |
3341 | 3774 | return $output; |
@@ -3351,7 +3784,11 @@ discard block |
||
3351 | 3784 | * @return bool |
3352 | 3785 | */ |
3353 | 3786 | function setResources( $value, $params=FALSE, $index=FALSE ) { |
3354 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3787 | + if( empty( $value )) { |
|
3788 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3789 | + } else { |
|
3790 | + return FALSE; |
|
3791 | + } |
|
3355 | 3792 | $this->_setMval( $this->resources, $value, $params, FALSE, $index ); |
3356 | 3793 | return TRUE; |
3357 | 3794 | } |
@@ -3367,7 +3804,9 @@ discard block |
||
3367 | 3804 | * @return string |
3368 | 3805 | */ |
3369 | 3806 | function createRrule() { |
3370 | - if( empty( $this->rrule )) return FALSE; |
|
3807 | + if( empty( $this->rrule )) { |
|
3808 | + return FALSE; |
|
3809 | + } |
|
3371 | 3810 | return $this->_format_recur( 'RRULE', $this->rrule ); |
3372 | 3811 | } |
3373 | 3812 | /** |
@@ -3381,7 +3820,11 @@ discard block |
||
3381 | 3820 | * @return void |
3382 | 3821 | */ |
3383 | 3822 | function setRrule( $rruleset, $params=FALSE, $index=FALSE ) { |
3384 | - if( empty( $rruleset )) if( $this->getConfig( 'allowEmpty' )) $rruleset = null; else return FALSE; |
|
3823 | + if( empty( $rruleset )) { |
|
3824 | + if( $this->getConfig( 'allowEmpty' )) $rruleset = null; |
|
3825 | + } else { |
|
3826 | + return FALSE; |
|
3827 | + } |
|
3385 | 3828 | $this->_setMval( $this->rrule, $this->_setRexrule( $rruleset ), $params, FALSE, $index ); |
3386 | 3829 | return TRUE; |
3387 | 3830 | } |
@@ -3396,9 +3839,12 @@ discard block |
||
3396 | 3839 | * @return string |
3397 | 3840 | */ |
3398 | 3841 | function createSequence() { |
3399 | - if( empty( $this->sequence )) return FALSE; |
|
3400 | - if( empty( $this->sequence['value'] )) |
|
3401 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE; |
|
3842 | + if( empty( $this->sequence )) { |
|
3843 | + return FALSE; |
|
3844 | + } |
|
3845 | + if( empty( $this->sequence['value'] )) { |
|
3846 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE; |
|
3847 | + } |
|
3402 | 3848 | $attributes = $this->_createParams( $this->sequence['params'] ); |
3403 | 3849 | return $this->_createElement( 'SEQUENCE', $attributes, $this->sequence['value'] ); |
3404 | 3850 | } |
@@ -3411,8 +3857,9 @@ discard block |
||
3411 | 3857 | * @return bool |
3412 | 3858 | */ |
3413 | 3859 | function setSequence( $value=FALSE, $params=FALSE ) { |
3414 | - if( empty( $value )) |
|
3415 | - $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1; |
|
3860 | + if( empty( $value )) { |
|
3861 | + $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1; |
|
3862 | + } |
|
3416 | 3863 | $this->sequence = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3417 | 3864 | return TRUE; |
3418 | 3865 | } |
@@ -3428,9 +3875,12 @@ discard block |
||
3428 | 3875 | * @return string |
3429 | 3876 | */ |
3430 | 3877 | function createStatus() { |
3431 | - if( empty( $this->status )) return FALSE; |
|
3432 | - if( empty( $this->status['value'] )) |
|
3433 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE; |
|
3878 | + if( empty( $this->status )) { |
|
3879 | + return FALSE; |
|
3880 | + } |
|
3881 | + if( empty( $this->status['value'] )) { |
|
3882 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE; |
|
3883 | + } |
|
3434 | 3884 | $attributes = $this->_createParams( $this->status['params'] ); |
3435 | 3885 | return $this->_createElement( 'STATUS', $attributes, $this->status['value'] ); |
3436 | 3886 | } |
@@ -3444,8 +3894,12 @@ discard block |
||
3444 | 3894 | * @return bool |
3445 | 3895 | */ |
3446 | 3896 | function setStatus( $value, $params=FALSE ) { |
3447 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3448 | - $this->status = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3897 | + if( empty( $value )) { |
|
3898 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3899 | + } else { |
|
3900 | + return FALSE; |
|
3901 | + } |
|
3902 | + $this->status = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3449 | 3903 | return TRUE; |
3450 | 3904 | } |
3451 | 3905 | /*********************************************************************************/ |
@@ -3460,9 +3914,12 @@ discard block |
||
3460 | 3914 | * @return string |
3461 | 3915 | */ |
3462 | 3916 | function createSummary() { |
3463 | - if( empty( $this->summary )) return FALSE; |
|
3464 | - if( empty( $this->summary['value'] )) |
|
3465 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE; |
|
3917 | + if( empty( $this->summary )) { |
|
3918 | + return FALSE; |
|
3919 | + } |
|
3920 | + if( empty( $this->summary['value'] )) { |
|
3921 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE; |
|
3922 | + } |
|
3466 | 3923 | $attributes = $this->_createParams( $this->summary['params'], array( 'ALTREP', 'LANGUAGE' )); |
3467 | 3924 | $content = $this->_strrep( $this->summary['value'] ); |
3468 | 3925 | return $this->_createElement( 'SUMMARY', $attributes, $content ); |
@@ -3477,7 +3934,11 @@ discard block |
||
3477 | 3934 | * @return bool |
3478 | 3935 | */ |
3479 | 3936 | function setSummary( $value, $params=FALSE ) { |
3480 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3937 | + if( empty( $value )) { |
|
3938 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3939 | + } else { |
|
3940 | + return FALSE; |
|
3941 | + } |
|
3481 | 3942 | $this->summary = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3482 | 3943 | return TRUE; |
3483 | 3944 | } |
@@ -3493,9 +3954,12 @@ discard block |
||
3493 | 3954 | * @return string |
3494 | 3955 | */ |
3495 | 3956 | function createTransp() { |
3496 | - if( empty( $this->transp )) return FALSE; |
|
3497 | - if( empty( $this->transp['value'] )) |
|
3498 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE; |
|
3957 | + if( empty( $this->transp )) { |
|
3958 | + return FALSE; |
|
3959 | + } |
|
3960 | + if( empty( $this->transp['value'] )) { |
|
3961 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE; |
|
3962 | + } |
|
3499 | 3963 | $attributes = $this->_createParams( $this->transp['params'] ); |
3500 | 3964 | return $this->_createElement( 'TRANSP', $attributes, $this->transp['value'] ); |
3501 | 3965 | } |
@@ -3509,7 +3973,11 @@ discard block |
||
3509 | 3973 | * @return bool |
3510 | 3974 | */ |
3511 | 3975 | function setTransp( $value, $params=FALSE ) { |
3512 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3976 | + if( empty( $value )) { |
|
3977 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3978 | + } else { |
|
3979 | + return FALSE; |
|
3980 | + } |
|
3513 | 3981 | $this->transp = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3514 | 3982 | return TRUE; |
3515 | 3983 | } |
@@ -3525,19 +3993,24 @@ discard block |
||
3525 | 3993 | * @return string |
3526 | 3994 | */ |
3527 | 3995 | function createTrigger() { |
3528 | - if( empty( $this->trigger )) return FALSE; |
|
3529 | - if( empty( $this->trigger['value'] )) |
|
3530 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE; |
|
3996 | + if( empty( $this->trigger )) { |
|
3997 | + return FALSE; |
|
3998 | + } |
|
3999 | + if( empty( $this->trigger['value'] )) { |
|
4000 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE; |
|
4001 | + } |
|
3531 | 4002 | $content = $attributes = null; |
3532 | 4003 | if( isset( $this->trigger['value']['year'] ) && |
3533 | 4004 | isset( $this->trigger['value']['month'] ) && |
3534 | - isset( $this->trigger['value']['day'] )) |
|
3535 | - $content .= $this->_format_date_time( $this->trigger['value'] ); |
|
3536 | - else { |
|
3537 | - if( TRUE !== $this->trigger['value']['relatedStart'] ) |
|
3538 | - $attributes .= $this->intAttrDelimiter.'RELATED=END'; |
|
3539 | - if( $this->trigger['value']['before'] ) |
|
3540 | - $content .= '-'; |
|
4005 | + isset( $this->trigger['value']['day'] )) { |
|
4006 | + $content .= $this->_format_date_time( $this->trigger['value'] ); |
|
4007 | + } else { |
|
4008 | + if( TRUE !== $this->trigger['value']['relatedStart'] ) { |
|
4009 | + $attributes .= $this->intAttrDelimiter.'RELATED=END'; |
|
4010 | + } |
|
4011 | + if( $this->trigger['value']['before'] ) { |
|
4012 | + $content .= '-'; |
|
4013 | + } |
|
3541 | 4014 | $content .= $this->_format_duration( $this->trigger['value'] ); |
3542 | 4015 | } |
3543 | 4016 | $attributes .= $this->_createParams( $this->trigger['params'] ); |
@@ -3561,28 +4034,30 @@ discard block |
||
3561 | 4034 | * @return bool |
3562 | 4035 | */ |
3563 | 4036 | function setTrigger( $year, $month=null, $day=null, $week=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $relatedStart=TRUE, $before=TRUE, $params=FALSE ) { |
3564 | - if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec )) |
|
3565 | - if( $this->getConfig( 'allowEmpty' )) { |
|
4037 | + if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec )) { |
|
4038 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3566 | 4039 | $this->trigger = array( 'value' => null, 'params' => $this->_setParams( $params ) ); |
4040 | + } |
|
3567 | 4041 | return TRUE; |
4042 | + } else { |
|
4043 | + return FALSE; |
|
3568 | 4044 | } |
3569 | - else |
|
3570 | - return FALSE; |
|
3571 | 4045 | if( $this->_isArrayTimestampDate( $year )) { // timestamp |
3572 | 4046 | $params = $this->_setParams( $month ); |
3573 | 4047 | $date = $this->_timestamp2date( $year, 7 ); |
3574 | - foreach( $date as $k => $v ) |
|
3575 | - $$k = $v; |
|
3576 | - } |
|
3577 | - elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) { |
|
4048 | + foreach( $date as $k => $v ) { |
|
4049 | + $$k = $v; |
|
4050 | + } |
|
4051 | + } elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) { |
|
3578 | 4052 | $params = $this->_setParams( $month ); |
3579 | 4053 | if(!(array_key_exists( 'year', $year ) && // exclude date-time |
3580 | 4054 | array_key_exists( 'month', $year ) && |
3581 | 4055 | array_key_exists( 'day', $year ))) { // so this must be a duration |
3582 | - if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) |
|
3583 | - $relatedStart = FALSE; |
|
3584 | - else |
|
3585 | - $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE; |
|
4056 | + if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) { |
|
4057 | + $relatedStart = FALSE; |
|
4058 | + } else { |
|
4059 | + $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE; |
|
4060 | + } |
|
3586 | 4061 | $before = ( array_key_exists( 'before', $year ) && ( TRUE !== $year['before'] )) ? FALSE : TRUE; |
3587 | 4062 | } |
3588 | 4063 | $SSYY = ( array_key_exists( 'year', $year )) ? $year['year'] : null; |
@@ -3593,24 +4068,27 @@ discard block |
||
3593 | 4068 | $min = ( array_key_exists( 'min', $year )) ? $year['min'] : 0; //null; |
3594 | 4069 | $sec = ( array_key_exists( 'sec', $year )) ? $year['sec'] : 0; //null; |
3595 | 4070 | $year = $SSYY; |
3596 | - } |
|
3597 | - elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) { // duration or date in a string |
|
4071 | + } elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) { // duration or date in a string |
|
3598 | 4072 | $params = $this->_setParams( $month ); |
3599 | 4073 | if( in_array( $year{0}, array( 'P', '+', '-' ))) { // duration |
3600 | 4074 | $relatedStart = ( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) ? FALSE : TRUE; |
3601 | 4075 | $before = ( '-' == $year{0} ) ? TRUE : FALSE; |
3602 | - if( 'P' != $year{0} ) |
|
3603 | - $year = substr( $year, 1 ); |
|
4076 | + if( 'P' != $year{0} ) { |
|
4077 | + $year = substr( $year, 1 ); |
|
4078 | + } |
|
3604 | 4079 | $date = $this->_duration_string( $year); |
3605 | - } |
|
3606 | - else // date |
|
4080 | + } else { |
|
4081 | + // date |
|
3607 | 4082 | $date = $this->_date_time_string( $year, 7 ); |
4083 | + } |
|
3608 | 4084 | unset( $year, $month, $day ); |
3609 | - foreach( $date as $k => $v ) |
|
3610 | - $$k = $v; |
|
3611 | - } |
|
3612 | - else // single values in function input parameters |
|
4085 | + foreach( $date as $k => $v ) { |
|
4086 | + $$k = $v; |
|
4087 | + } |
|
4088 | + } else { |
|
4089 | + // single values in function input parameters |
|
3613 | 4090 | $params = $this->_setParams( $params ); |
4091 | + } |
|
3614 | 4092 | if( !empty( $year ) && !empty( $month ) && !empty( $day )) { // date |
3615 | 4093 | $params['VALUE'] = 'DATE-TIME'; |
3616 | 4094 | $hour = ( $hour ) ? $hour : 0; |
@@ -3625,8 +4103,7 @@ discard block |
||
3625 | 4103 | , 'sec' => $sec |
3626 | 4104 | , 'tz' => 'Z' ); |
3627 | 4105 | return TRUE; |
3628 | - } |
|
3629 | - elseif(( empty( $year ) && empty( $month )) && // duration |
|
4106 | + } elseif(( empty( $year ) && empty( $month )) && // duration |
|
3630 | 4107 | (!empty( $week ) || !empty( $day ) || !empty( $hour ) || !empty( $min ) || !empty( $sec ))) { |
3631 | 4108 | unset( $params['RELATED'] ); // set at output creation (END only) |
3632 | 4109 | unset( $params['VALUE'] ); // 'DURATION' default |
@@ -3635,11 +4112,21 @@ discard block |
||
3635 | 4112 | $before = ( FALSE !== $before ) ? TRUE : FALSE; |
3636 | 4113 | $this->trigger['value'] = array( 'relatedStart' => $relatedStart |
3637 | 4114 | , 'before' => $before ); |
3638 | - if( !empty( $week )) $this->trigger['value']['week'] = $week; |
|
3639 | - if( !empty( $day )) $this->trigger['value']['day'] = $day; |
|
3640 | - if( !empty( $hour )) $this->trigger['value']['hour'] = $hour; |
|
3641 | - if( !empty( $min )) $this->trigger['value']['min'] = $min; |
|
3642 | - if( !empty( $sec )) $this->trigger['value']['sec'] = $sec; |
|
4115 | + if( !empty( $week )) { |
|
4116 | + $this->trigger['value']['week'] = $week; |
|
4117 | + } |
|
4118 | + if( !empty( $day )) { |
|
4119 | + $this->trigger['value']['day'] = $day; |
|
4120 | + } |
|
4121 | + if( !empty( $hour )) { |
|
4122 | + $this->trigger['value']['hour'] = $hour; |
|
4123 | + } |
|
4124 | + if( !empty( $min )) { |
|
4125 | + $this->trigger['value']['min'] = $min; |
|
4126 | + } |
|
4127 | + if( !empty( $sec )) { |
|
4128 | + $this->trigger['value']['sec'] = $sec; |
|
4129 | + } |
|
3643 | 4130 | return TRUE; |
3644 | 4131 | } |
3645 | 4132 | return FALSE; |
@@ -3656,9 +4143,12 @@ discard block |
||
3656 | 4143 | * @return string |
3657 | 4144 | */ |
3658 | 4145 | function createTzid() { |
3659 | - if( empty( $this->tzid )) return FALSE; |
|
3660 | - if( empty( $this->tzid['value'] )) |
|
3661 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE; |
|
4146 | + if( empty( $this->tzid )) { |
|
4147 | + return FALSE; |
|
4148 | + } |
|
4149 | + if( empty( $this->tzid['value'] )) { |
|
4150 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE; |
|
4151 | + } |
|
3662 | 4152 | $attributes = $this->_createParams( $this->tzid['params'] ); |
3663 | 4153 | return $this->_createElement( 'TZID', $attributes, $this->_strrep( $this->tzid['value'] )); |
3664 | 4154 | } |
@@ -3672,7 +4162,11 @@ discard block |
||
3672 | 4162 | * @return bool |
3673 | 4163 | */ |
3674 | 4164 | function setTzid( $value, $params=FALSE ) { |
3675 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4165 | + if( empty( $value )) { |
|
4166 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4167 | + } else { |
|
4168 | + return FALSE; |
|
4169 | + } |
|
3676 | 4170 | $this->tzid = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3677 | 4171 | return TRUE; |
3678 | 4172 | } |
@@ -3689,14 +4183,17 @@ discard block |
||
3689 | 4183 | * @return string |
3690 | 4184 | */ |
3691 | 4185 | function createTzname() { |
3692 | - if( empty( $this->tzname )) return FALSE; |
|
4186 | + if( empty( $this->tzname )) { |
|
4187 | + return FALSE; |
|
4188 | + } |
|
3693 | 4189 | $output = null; |
3694 | 4190 | foreach( $this->tzname as $theName ) { |
3695 | 4191 | if( !empty( $theName['value'] )) { |
3696 | 4192 | $attributes = $this->_createParams( $theName['params'], array( 'LANGUAGE' )); |
3697 | 4193 | $output .= $this->_createElement( 'TZNAME', $attributes, $this->_strrep( $theName['value'] )); |
4194 | + } elseif( $this->getConfig( 'allowEmpty' )) { |
|
4195 | + $output .= $this->_createElement( 'TZNAME' ); |
|
3698 | 4196 | } |
3699 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'TZNAME' ); |
|
3700 | 4197 | } |
3701 | 4198 | return $output; |
3702 | 4199 | } |
@@ -3711,7 +4208,11 @@ discard block |
||
3711 | 4208 | * @return bool |
3712 | 4209 | */ |
3713 | 4210 | function setTzname( $value, $params=FALSE, $index=FALSE ) { |
3714 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4211 | + if( empty( $value )) { |
|
4212 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4213 | + } else { |
|
4214 | + return FALSE; |
|
4215 | + } |
|
3715 | 4216 | $this->_setMval( $this->tzname, $value, $params, FALSE, $index ); |
3716 | 4217 | return TRUE; |
3717 | 4218 | } |
@@ -3727,9 +4228,12 @@ discard block |
||
3727 | 4228 | * @return string |
3728 | 4229 | */ |
3729 | 4230 | function createTzoffsetfrom() { |
3730 | - if( empty( $this->tzoffsetfrom )) return FALSE; |
|
3731 | - if( empty( $this->tzoffsetfrom['value'] )) |
|
3732 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE; |
|
4231 | + if( empty( $this->tzoffsetfrom )) { |
|
4232 | + return FALSE; |
|
4233 | + } |
|
4234 | + if( empty( $this->tzoffsetfrom['value'] )) { |
|
4235 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE; |
|
4236 | + } |
|
3733 | 4237 | $attributes = $this->_createParams( $this->tzoffsetfrom['params'] ); |
3734 | 4238 | return $this->_createElement( 'TZOFFSETFROM', $attributes, $this->tzoffsetfrom['value'] ); |
3735 | 4239 | } |
@@ -3743,7 +4247,11 @@ discard block |
||
3743 | 4247 | * @return bool |
3744 | 4248 | */ |
3745 | 4249 | function setTzoffsetfrom( $value, $params=FALSE ) { |
3746 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4250 | + if( empty( $value )) { |
|
4251 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4252 | + } else { |
|
4253 | + return FALSE; |
|
4254 | + } |
|
3747 | 4255 | $this->tzoffsetfrom = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3748 | 4256 | return TRUE; |
3749 | 4257 | } |
@@ -3759,9 +4267,12 @@ discard block |
||
3759 | 4267 | * @return string |
3760 | 4268 | */ |
3761 | 4269 | function createTzoffsetto() { |
3762 | - if( empty( $this->tzoffsetto )) return FALSE; |
|
3763 | - if( empty( $this->tzoffsetto['value'] )) |
|
3764 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE; |
|
4270 | + if( empty( $this->tzoffsetto )) { |
|
4271 | + return FALSE; |
|
4272 | + } |
|
4273 | + if( empty( $this->tzoffsetto['value'] )) { |
|
4274 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE; |
|
4275 | + } |
|
3765 | 4276 | $attributes = $this->_createParams( $this->tzoffsetto['params'] ); |
3766 | 4277 | return $this->_createElement( 'TZOFFSETTO', $attributes, $this->tzoffsetto['value'] ); |
3767 | 4278 | } |
@@ -3775,7 +4286,11 @@ discard block |
||
3775 | 4286 | * @return bool |
3776 | 4287 | */ |
3777 | 4288 | function setTzoffsetto( $value, $params=FALSE ) { |
3778 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4289 | + if( empty( $value )) { |
|
4290 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4291 | + } else { |
|
4292 | + return FALSE; |
|
4293 | + } |
|
3779 | 4294 | $this->tzoffsetto = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3780 | 4295 | return TRUE; |
3781 | 4296 | } |
@@ -3791,9 +4306,12 @@ discard block |
||
3791 | 4306 | * @return string |
3792 | 4307 | */ |
3793 | 4308 | function createTzurl() { |
3794 | - if( empty( $this->tzurl )) return FALSE; |
|
3795 | - if( empty( $this->tzurl['value'] )) |
|
3796 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE; |
|
4309 | + if( empty( $this->tzurl )) { |
|
4310 | + return FALSE; |
|
4311 | + } |
|
4312 | + if( empty( $this->tzurl['value'] )) { |
|
4313 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE; |
|
4314 | + } |
|
3797 | 4315 | $attributes = $this->_createParams( $this->tzurl['params'] ); |
3798 | 4316 | return $this->_createElement( 'TZURL', $attributes, $this->tzurl['value'] ); |
3799 | 4317 | } |
@@ -3807,7 +4325,11 @@ discard block |
||
3807 | 4325 | * @return boll |
3808 | 4326 | */ |
3809 | 4327 | function setTzurl( $value, $params=FALSE ) { |
3810 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4328 | + if( empty( $value )) { |
|
4329 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4330 | + } else { |
|
4331 | + return FALSE; |
|
4332 | + } |
|
3811 | 4333 | $this->tzurl = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3812 | 4334 | return TRUE; |
3813 | 4335 | } |
@@ -3823,8 +4345,9 @@ discard block |
||
3823 | 4345 | * @return string |
3824 | 4346 | */ |
3825 | 4347 | function createUid() { |
3826 | - if( 0 >= count( $this->uid )) |
|
3827 | - $this->_makeuid(); |
|
4348 | + if( 0 >= count( $this->uid )) { |
|
4349 | + $this->_makeuid(); |
|
4350 | + } |
|
3828 | 4351 | $attributes = $this->_createParams( $this->uid['params'] ); |
3829 | 4352 | return $this->_createElement( 'UID', $attributes, $this->uid['value'] ); |
3830 | 4353 | } |
@@ -3843,8 +4366,9 @@ discard block |
||
3843 | 4366 | $end = strlen( $base ) - 1; |
3844 | 4367 | $length = 6; |
3845 | 4368 | $str = null; |
3846 | - for( $p = 0; $p < $length; $p++ ) |
|
3847 | - $unique .= $base{mt_rand( $start, $end )}; |
|
4369 | + for( $p = 0; $p < $length; $p++ ) { |
|
4370 | + $unique .= $base{mt_rand( $start, $end )}; |
|
4371 | + } |
|
3848 | 4372 | $this->uid = array( 'params' => null ); |
3849 | 4373 | $this->uid['value'] = $date.'-'.$unique.'@'.$this->getConfig( 'unique_id' ); |
3850 | 4374 | } |
@@ -3858,7 +4382,10 @@ discard block |
||
3858 | 4382 | * @return bool |
3859 | 4383 | */ |
3860 | 4384 | function setUid( $value, $params=FALSE ) { |
3861 | - if( empty( $value )) return FALSE; // no allowEmpty check here !!!! |
|
4385 | + if( empty( $value )) { |
|
4386 | + return FALSE; |
|
4387 | + } |
|
4388 | + // no allowEmpty check here !!!! |
|
3862 | 4389 | $this->uid = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3863 | 4390 | return TRUE; |
3864 | 4391 | } |
@@ -3874,9 +4401,12 @@ discard block |
||
3874 | 4401 | * @return string |
3875 | 4402 | */ |
3876 | 4403 | function createUrl() { |
3877 | - if( empty( $this->url )) return FALSE; |
|
3878 | - if( empty( $this->url['value'] )) |
|
3879 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE; |
|
4404 | + if( empty( $this->url )) { |
|
4405 | + return FALSE; |
|
4406 | + } |
|
4407 | + if( empty( $this->url['value'] )) { |
|
4408 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE; |
|
4409 | + } |
|
3880 | 4410 | $attributes = $this->_createParams( $this->url['params'] ); |
3881 | 4411 | return $this->_createElement( 'URL', $attributes, $this->url['value'] ); |
3882 | 4412 | } |
@@ -3890,7 +4420,11 @@ discard block |
||
3890 | 4420 | * @return bool |
3891 | 4421 | */ |
3892 | 4422 | function setUrl( $value, $params=FALSE ) { |
3893 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4423 | + if( empty( $value )) { |
|
4424 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4425 | + } else { |
|
4426 | + return FALSE; |
|
4427 | + } |
|
3894 | 4428 | $this->url = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3895 | 4429 | return TRUE; |
3896 | 4430 | } |
@@ -3906,21 +4440,26 @@ discard block |
||
3906 | 4440 | * @return string |
3907 | 4441 | */ |
3908 | 4442 | function createXprop() { |
3909 | - if( empty( $this->xprop )) return FALSE; |
|
4443 | + if( empty( $this->xprop )) { |
|
4444 | + return FALSE; |
|
4445 | + } |
|
3910 | 4446 | $output = null; |
3911 | 4447 | foreach( $this->xprop as $label => $xpropPart ) { |
3912 | 4448 | if( empty( $xpropPart['value'] )) { |
3913 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $label ); |
|
4449 | + if( $this->getConfig( 'allowEmpty' )) { |
|
4450 | + $output .= $this->_createElement( $label ); |
|
4451 | + } |
|
3914 | 4452 | continue; |
3915 | 4453 | } |
3916 | 4454 | $attributes = $this->_createParams( $xpropPart['params'], array( 'LANGUAGE' )); |
3917 | 4455 | if( is_array( $xpropPart['value'] )) { |
3918 | - foreach( $xpropPart['value'] as $pix => $theXpart ) |
|
3919 | - $xpropPart['value'][$pix] = $this->_strrep( $theXpart ); |
|
4456 | + foreach( $xpropPart['value'] as $pix => $theXpart ) { |
|
4457 | + $xpropPart['value'][$pix] = $this->_strrep( $theXpart ); |
|
4458 | + } |
|
3920 | 4459 | $xpropPart['value'] = implode( ',', $xpropPart['value'] ); |
4460 | + } else { |
|
4461 | + $xpropPart['value'] = $this->_strrep( $xpropPart['value'] ); |
|
3921 | 4462 | } |
3922 | - else |
|
3923 | - $xpropPart['value'] = $this->_strrep( $xpropPart['value'] ); |
|
3924 | 4463 | $output .= $this->_createElement( $label, $attributes, $xpropPart['value'] ); |
3925 | 4464 | } |
3926 | 4465 | return $output; |
@@ -3936,12 +4475,20 @@ discard block |
||
3936 | 4475 | * @return bool |
3937 | 4476 | */ |
3938 | 4477 | function setXprop( $label, $value, $params=FALSE ) { |
3939 | - if( empty( $label )) return; |
|
3940 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4478 | + if( empty( $label )) { |
|
4479 | + return; |
|
4480 | + } |
|
4481 | + if( empty( $value )) { |
|
4482 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4483 | + } else { |
|
4484 | + return FALSE; |
|
4485 | + } |
|
3941 | 4486 | $xprop = array( 'value' => $value ); |
3942 | 4487 | $toolbox = new calendarComponent(); |
3943 | 4488 | $xprop['params'] = $toolbox->_setParams( $params ); |
3944 | - if( !is_array( $this->xprop )) $this->xprop = array(); |
|
4489 | + if( !is_array( $this->xprop )) { |
|
4490 | + $this->xprop = array(); |
|
4491 | + } |
|
3945 | 4492 | $this->xprop[strtoupper( $label )] = $xprop; |
3946 | 4493 | return TRUE; |
3947 | 4494 | } |
@@ -4009,30 +4556,29 @@ discard block |
||
4009 | 4556 | $attributes = null; |
4010 | 4557 | foreach( $attributes2 as $attribute ) { |
4011 | 4558 | $attrKVarr = explode( '=', $attribute ); |
4012 | - if( empty( $attrKVarr[0] )) |
|
4013 | - continue; |
|
4559 | + if( empty( $attrKVarr[0] )) { |
|
4560 | + continue; |
|
4561 | + } |
|
4014 | 4562 | if( !isset( $attrKVarr[1] )) { |
4015 | 4563 | $attrValue = $attrKVarr[0]; |
4016 | 4564 | $attrKey = null; |
4017 | - } |
|
4018 | - elseif( 2 == count( $attrKVarr)) { |
|
4565 | + } elseif( 2 == count( $attrKVarr)) { |
|
4019 | 4566 | $attrKey = strtolower( $attrKVarr[0] ); |
4020 | 4567 | $attrValue = $attrKVarr[1]; |
4021 | - } |
|
4022 | - else { |
|
4568 | + } else { |
|
4023 | 4569 | $attrKey = strtolower( $attrKVarr[0] ); |
4024 | 4570 | unset( $attrKVarr[0] ); |
4025 | 4571 | $attrValue = implode( '=', $attrKVarr ); |
4026 | 4572 | } |
4027 | 4573 | if(( 'attach' == $label ) && ( in_array( $attrKey, array( 'fmttype', 'encoding', 'value' )))) { |
4028 | 4574 | $attachInlineBinary = TRUE; |
4029 | - if( 'fmttype' == $attrKey ) |
|
4030 | - $attachfmttype = $attrKey.'='.$attrValue; |
|
4575 | + if( 'fmttype' == $attrKey ) { |
|
4576 | + $attachfmttype = $attrKey.'='.$attrValue; |
|
4577 | + } |
|
4031 | 4578 | continue; |
4032 | - } |
|
4033 | - elseif(( 'categories' == $label ) && ( 'language' == $attrKey )) |
|
4034 | - $categoriesAttrLang = $attrKey.'='.$attrValue; |
|
4035 | - else { |
|
4579 | + } elseif(( 'categories' == $label ) && ( 'language' == $attrKey )) { |
|
4580 | + $categoriesAttrLang = $attrKey.'='.$attrValue; |
|
4581 | + } else { |
|
4036 | 4582 | $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' '; |
4037 | 4583 | $attributes .= ( !empty( $attrKey )) ? $attrKey.'=' : null; |
4038 | 4584 | if(( '"' == substr( $attrValue, 0, 1 )) && ( '"' == substr( $attrValue, -1 ))) { |
@@ -4042,8 +4588,7 @@ discard block |
||
4042 | 4588 | $attributes .= '"'.htmlspecialchars( $attrValue ).'"'; |
4043 | 4589 | } |
4044 | 4590 | } |
4045 | - } |
|
4046 | - else { |
|
4591 | + } else { |
|
4047 | 4592 | $attributes = str_replace( $this->intAttrDelimiter, $this->attributeDelimiter, $attributes ); |
4048 | 4593 | } |
4049 | 4594 | } |
@@ -4065,8 +4610,7 @@ discard block |
||
4065 | 4610 | $content = $this->_createElement( 'extref', $attributes, null ); |
4066 | 4611 | $attributes = null; |
4067 | 4612 | } |
4068 | - } |
|
4069 | - elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) { |
|
4613 | + } elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) { |
|
4070 | 4614 | $content = $this->nl.$this->_createElement( 'b64bin', $attachfmttype, $content ); // max one attribute |
4071 | 4615 | } |
4072 | 4616 | $output .= $attributes; |
@@ -4110,30 +4654,30 @@ discard block |
||
4110 | 4654 | $CNattrExist = $LANGattrExist = FALSE; |
4111 | 4655 | if( is_array( $params )) { |
4112 | 4656 | foreach( $params as $paramKey => $paramValue ) { |
4113 | - if( is_int( $paramKey )) |
|
4114 | - $attr2 .= $this->intAttrDelimiter.$paramValue; |
|
4115 | - elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) { |
|
4657 | + if( is_int( $paramKey )) { |
|
4658 | + $attr2 .= $this->intAttrDelimiter.$paramValue; |
|
4659 | + } elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) { |
|
4116 | 4660 | $attrLANG .= $this->intAttrDelimiter."LANGUAGE=$paramValue"; |
4117 | 4661 | $LANGattrExist = TRUE; |
4118 | - } |
|
4119 | - elseif(( 'CN' == $paramKey ) && $CNattrKey ) { |
|
4662 | + } elseif(( 'CN' == $paramKey ) && $CNattrKey ) { |
|
4120 | 4663 | $attr1 = $this->intAttrDelimiter.'CN="'.$paramValue.'"'; |
4121 | 4664 | $CNattrExist = TRUE; |
4665 | + } elseif(( 'ALTREP' == $paramKey ) && in_array( $paramKey, $ctrKeys )) { |
|
4666 | + $attr2 .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"'; |
|
4667 | + } elseif(( 'DIR' == $paramKey ) && in_array( $paramKey, $ctrKeys )) { |
|
4668 | + $attr2 .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"'; |
|
4669 | + } elseif(( 'SENT-BY' == $paramKey ) && in_array( $paramKey, $ctrKeys )) { |
|
4670 | + $attr2 .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"'; |
|
4671 | + } else { |
|
4672 | + $attr2 .= $this->intAttrDelimiter."$paramKey=$paramValue"; |
|
4122 | 4673 | } |
4123 | - elseif(( 'ALTREP' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4124 | - $attr2 .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"'; |
|
4125 | - elseif(( 'DIR' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4126 | - $attr2 .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"'; |
|
4127 | - elseif(( 'SENT-BY' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4128 | - $attr2 .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"'; |
|
4129 | - else |
|
4130 | - $attr2 .= $this->intAttrDelimiter."$paramKey=$paramValue"; |
|
4131 | 4674 | } |
4132 | 4675 | } |
4133 | 4676 | if( !$LANGattrExist ) { |
4134 | 4677 | $lang = $this->getConfig( 'language' ); |
4135 | - if(( $CNattrExist || $LANGattrKey ) && $lang ) |
|
4136 | - $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang; |
|
4678 | + if(( $CNattrExist || $LANGattrKey ) && $lang ) { |
|
4679 | + $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang; |
|
4680 | + } |
|
4137 | 4681 | } |
4138 | 4682 | return $attrLANG.$attr1.$attr2; |
4139 | 4683 | } |
@@ -4147,47 +4691,57 @@ discard block |
||
4147 | 4691 | * @return array $params property parameters |
4148 | 4692 | */ |
4149 | 4693 | function _chkdatecfg( $theDate, & $parno, & $params ) { |
4150 | - if( isset( $params['TZID'] )) |
|
4151 | - $parno = 6; |
|
4152 | - elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )) |
|
4153 | - $parno = 3; |
|
4154 | - else { |
|
4155 | - if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] )) |
|
4156 | - $parno = 7; |
|
4694 | + if( isset( $params['TZID'] )) { |
|
4695 | + $parno = 6; |
|
4696 | + } elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )) { |
|
4697 | + $parno = 3; |
|
4698 | + } else { |
|
4699 | + if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] )) { |
|
4700 | + $parno = 7; |
|
4701 | + } |
|
4157 | 4702 | if( is_array( $theDate )) { |
4158 | - if( isset( $theDate['timestamp'] )) |
|
4159 | - $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null; |
|
4160 | - else |
|
4161 | - $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null; |
|
4703 | + if( isset( $theDate['timestamp'] )) { |
|
4704 | + $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null; |
|
4705 | + } else { |
|
4706 | + $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null; |
|
4707 | + } |
|
4162 | 4708 | if( !empty( $tzid )) { |
4163 | 4709 | $parno = 7; |
4164 | - if( !$this->_isOffset( $tzid )) |
|
4165 | - $params['TZID'] = $tzid; // save only timezone |
|
4710 | + if( !$this->_isOffset( $tzid )) { |
|
4711 | + $params['TZID'] = $tzid; |
|
4712 | + } |
|
4713 | + // save only timezone |
|
4714 | + } elseif( !$parno && ( 3 == count( $theDate )) && |
|
4715 | + ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))) { |
|
4716 | + $parno = 3; |
|
4717 | + } else { |
|
4718 | + $parno = 6; |
|
4166 | 4719 | } |
4167 | - elseif( !$parno && ( 3 == count( $theDate )) && |
|
4168 | - ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))) |
|
4169 | - $parno = 3; |
|
4170 | - else |
|
4171 | - $parno = 6; |
|
4172 | - } |
|
4173 | - else { // string |
|
4720 | + } else { // string |
|
4174 | 4721 | $date = trim( $theDate ); |
4175 | - if( 'Z' == substr( $date, -1 )) |
|
4176 | - $parno = 7; // UTC DATE-TIME |
|
4722 | + if( 'Z' == substr( $date, -1 )) { |
|
4723 | + $parno = 7; |
|
4724 | + } |
|
4725 | + // UTC DATE-TIME |
|
4177 | 4726 | elseif((( 8 == strlen( $date ) && ctype_digit( $date )) || ( 11 >= strlen( $date ))) && |
4178 | - ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' )))) |
|
4179 | - $parno = 3; // DATE |
|
4727 | + ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' )))) { |
|
4728 | + $parno = 3; |
|
4729 | + } |
|
4730 | + // DATE |
|
4180 | 4731 | $date = $this->_date_time_string( $date, $parno ); |
4181 | 4732 | if( !empty( $date['tz'] )) { |
4182 | 4733 | $parno = 7; |
4183 | - if( !$this->_isOffset( $date['tz'] )) |
|
4184 | - $params['TZID'] = $date['tz']; // save only timezone |
|
4734 | + if( !$this->_isOffset( $date['tz'] )) { |
|
4735 | + $params['TZID'] = $date['tz']; |
|
4736 | + } |
|
4737 | + // save only timezone |
|
4738 | + } elseif( empty( $parno )) { |
|
4739 | + $parno = 6; |
|
4185 | 4740 | } |
4186 | - elseif( empty( $parno )) |
|
4187 | - $parno = 6; |
|
4188 | 4741 | } |
4189 | - if( isset( $params['TZID'] )) |
|
4190 | - $parno = 6; |
|
4742 | + if( isset( $params['TZID'] )) { |
|
4743 | + $parno = 6; |
|
4744 | + } |
|
4191 | 4745 | } |
4192 | 4746 | } |
4193 | 4747 | /** |
@@ -4203,14 +4757,18 @@ discard block |
||
4203 | 4757 | */ |
4204 | 4758 | function _date2duration( $startdate=FALSE, $enddate=FALSE ) { |
4205 | 4759 | if( !$startdate || !$enddate ) { |
4206 | - if( FALSE === ( $startdate = $this->getProperty( 'dtstart' ))) |
|
4207 | - return null; |
|
4208 | - if( FALSE === ( $enddate = $this->getProperty( 'dtend' ))) // vevent/vfreebusy |
|
4760 | + if( FALSE === ( $startdate = $this->getProperty( 'dtstart' ))) { |
|
4761 | + return null; |
|
4762 | + } |
|
4763 | + if( FALSE === ( $enddate = $this->getProperty( 'dtend' ))) { |
|
4764 | + // vevent/vfreebusy |
|
4209 | 4765 | if( FALSE === ( $enddate = $this->getProperty( 'due' ))) // vtodo |
4210 | 4766 | return null; |
4767 | + } |
|
4768 | + } |
|
4769 | + if( !$startdate || !$enddate ) { |
|
4770 | + return null; |
|
4211 | 4771 | } |
4212 | - if( !$startdate || !$enddate ) |
|
4213 | - return null; |
|
4214 | 4772 | $startWdate = mktime( 0, 0, 0, $startdate['month'], $startdate['day'], $startdate['year'] ); |
4215 | 4773 | $endWdate = mktime( 0, 0, 0, $enddate['month'], $enddate['day'], $enddate['year'] ); |
4216 | 4774 | $wduration = $endWdate - $startWdate; |
@@ -4236,15 +4794,23 @@ discard block |
||
4236 | 4794 | */ |
4237 | 4795 | function _date2timestamp( $datetime, $tz=null ) { |
4238 | 4796 | $output = null; |
4239 | - if( !isset( $datetime['hour'] )) $datetime['hour'] = '0'; |
|
4240 | - if( !isset( $datetime['min'] )) $datetime['min'] = '0'; |
|
4241 | - if( !isset( $datetime['sec'] )) $datetime['sec'] = '0'; |
|
4797 | + if( !isset( $datetime['hour'] )) { |
|
4798 | + $datetime['hour'] = '0'; |
|
4799 | + } |
|
4800 | + if( !isset( $datetime['min'] )) { |
|
4801 | + $datetime['min'] = '0'; |
|
4802 | + } |
|
4803 | + if( !isset( $datetime['sec'] )) { |
|
4804 | + $datetime['sec'] = '0'; |
|
4805 | + } |
|
4242 | 4806 | foreach( $datetime as $dkey => $dvalue ) { |
4243 | - if( 'tz' != $dkey ) |
|
4244 | - $datetime[$dkey] = (integer) $dvalue; |
|
4807 | + if( 'tz' != $dkey ) { |
|
4808 | + $datetime[$dkey] = (integer) $dvalue; |
|
4809 | + } |
|
4810 | + } |
|
4811 | + if( $tz ) { |
|
4812 | + $datetime['tz'] = $tz; |
|
4245 | 4813 | } |
4246 | - if( $tz ) |
|
4247 | - $datetime['tz'] = $tz; |
|
4248 | 4814 | $offset = ( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) ? $this->_tz2offset( $datetime['tz'] ) : 0; |
4249 | 4815 | $output = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year'] ); |
4250 | 4816 | return $output; |
@@ -4301,12 +4867,15 @@ discard block |
||
4301 | 4867 | } |
4302 | 4868 | } |
4303 | 4869 | if( 3 != $parno ) { |
4304 | - if( !isset( $output['hour'] )) |
|
4305 | - $output['hour'] = 0; |
|
4306 | - if( !isset( $output['min'] )) |
|
4307 | - $output['min'] = 0; |
|
4308 | - if( !isset( $output['sec'] )) |
|
4309 | - $output['sec'] = 0; |
|
4870 | + if( !isset( $output['hour'] )) { |
|
4871 | + $output['hour'] = 0; |
|
4872 | + } |
|
4873 | + if( !isset( $output['min'] )) { |
|
4874 | + $output['min'] = 0; |
|
4875 | + } |
|
4876 | + if( !isset( $output['sec'] )) { |
|
4877 | + $output['sec'] = 0; |
|
4878 | + } |
|
4310 | 4879 | } |
4311 | 4880 | return $output; |
4312 | 4881 | } |
@@ -4326,39 +4895,37 @@ discard block |
||
4326 | 4895 | if( 'Z' == substr( $datetime, -1 )) { |
4327 | 4896 | $tz = 'Z'; |
4328 | 4897 | $datetime = trim( substr( $datetime, 0, $len )); |
4329 | - } |
|
4330 | - elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date |
|
4898 | + } elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date |
|
4331 | 4899 | ( '-' == substr( $datetime, -3, 1 )) || |
4332 | 4900 | ( ':' == substr( $datetime, -3, 1 )) || |
4333 | 4901 | ( '.' == substr( $datetime, -3, 1 ))) { |
4334 | 4902 | $continue = TRUE; |
4335 | - } |
|
4336 | - elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset |
|
4903 | + } elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset |
|
4337 | 4904 | ( ' +' == substr( $datetime, -6, 2 )) || |
4338 | 4905 | ( ' -' == substr( $datetime, -6, 2 ))) { |
4339 | 4906 | $tz = substr( $datetime, -5, 5 ); |
4340 | 4907 | $datetime = substr( $datetime, 0, ($len - 5)); |
4341 | - } |
|
4342 | - elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset |
|
4908 | + } elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset |
|
4343 | 4909 | ( ' +' == substr( $datetime, -8, 2 )) || |
4344 | 4910 | ( ' -' == substr( $datetime, -8, 2 ))) { |
4345 | 4911 | $tz = substr( $datetime, -7, 7 ); |
4346 | 4912 | $datetime = substr( $datetime, 0, ($len - 7)); |
4347 | - } |
|
4348 | - elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) { |
|
4913 | + } elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) { |
|
4349 | 4914 | $continue = TRUE; |
4350 | - } |
|
4351 | - elseif( 'T' == substr( $datetime, -7, 1 )) { |
|
4915 | + } elseif( 'T' == substr( $datetime, -7, 1 )) { |
|
4352 | 4916 | $continue = TRUE; |
4353 | - } |
|
4354 | - else { |
|
4917 | + } else { |
|
4355 | 4918 | $cx = $tx = 0; // 19970415T133000 US-Eastern |
4356 | 4919 | for( $cx = -1; $cx > ( 9 - $len ); $cx-- ) { |
4357 | - if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 ))) |
|
4358 | - break; // if exists, tz ends here.. . ? |
|
4920 | + if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 ))) { |
|
4921 | + break; |
|
4922 | + } |
|
4923 | + // if exists, tz ends here.. . ? |
|
4359 | 4924 | elseif( ctype_alpha( substr( $datetime, $cx, 1 )) || |
4360 | - ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' )))) |
|
4361 | - $tx--; // tz length counter |
|
4925 | + ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' )))) { |
|
4926 | + $tx--; |
|
4927 | + } |
|
4928 | + // tz length counter |
|
4362 | 4929 | } |
4363 | 4930 | if( 0 > $tx ) { |
4364 | 4931 | $tz = substr( $datetime, $tx ); |
@@ -4367,8 +4934,7 @@ discard block |
||
4367 | 4934 | } |
4368 | 4935 | if( 0 < substr_count( $datetime, '-' )) { |
4369 | 4936 | $datetime = str_replace( '-', '/', $datetime ); |
4370 | - } |
|
4371 | - elseif( ctype_digit( substr( $datetime, 0, 8 )) && |
|
4937 | + } elseif( ctype_digit( substr( $datetime, 0, 8 )) && |
|
4372 | 4938 | ( 'T' == substr( $datetime, 8, 1 )) && |
4373 | 4939 | ctype_digit( substr( $datetime, 9, 6 ))) { |
4374 | 4940 | $datetime = substr( $datetime, 4, 2 ) |
@@ -4388,10 +4954,10 @@ discard block |
||
4388 | 4954 | $output['hour'] = substr( $datestring, 11, 2 ); |
4389 | 4955 | $output['min'] = substr( $datestring, 14, 2 ); |
4390 | 4956 | $output['sec'] = substr( $datestring, 17, 2 ); |
4391 | - if( !empty( $tz )) |
|
4392 | - $output['tz'] = $tz; |
|
4393 | - } |
|
4394 | - elseif( 3 != $parno ) { |
|
4957 | + if( !empty( $tz )) { |
|
4958 | + $output['tz'] = $tz; |
|
4959 | + } |
|
4960 | + } elseif( 3 != $parno ) { |
|
4395 | 4961 | if(( '00' < substr( $datestring, 11, 2 )) || |
4396 | 4962 | ( '00' < substr( $datestring, 14, 2 )) || |
4397 | 4963 | ( '00' < substr( $datestring, 17, 2 ))) { |
@@ -4399,8 +4965,9 @@ discard block |
||
4399 | 4965 | $output['min'] = substr( $datestring, 14, 2 ); |
4400 | 4966 | $output['sec'] = substr( $datestring, 17, 2 ); |
4401 | 4967 | } |
4402 | - if( !empty( $tz )) |
|
4403 | - $output['tz'] = $tz; |
|
4968 | + if( !empty( $tz )) { |
|
4969 | + $output['tz'] = $tz; |
|
4970 | + } |
|
4404 | 4971 | } |
4405 | 4972 | return $output; |
4406 | 4973 | } |
@@ -4427,10 +4994,11 @@ discard block |
||
4427 | 4994 | $durseconds = $durseconds % ( 60 * 60 ); |
4428 | 4995 | $output['min'] = floor( $durseconds / ( 60 )); |
4429 | 4996 | $output['sec'] = ( $durseconds % ( 60 )); |
4430 | - } |
|
4431 | - else { |
|
4997 | + } else { |
|
4432 | 4998 | foreach( $duration as $durKey => $durValue ) { |
4433 | - if( empty( $durValue )) continue; |
|
4999 | + if( empty( $durValue )) { |
|
5000 | + continue; |
|
5001 | + } |
|
4434 | 5002 | switch ( $durKey ) { |
4435 | 5003 | case '0': |
4436 | 5004 | case 'week': |
@@ -4460,14 +5028,22 @@ discard block |
||
4460 | 5028 | return $output; |
4461 | 5029 | } |
4462 | 5030 | unset( $output['week'] ); |
4463 | - if( empty( $output['day'] )) |
|
4464 | - unset( $output['day'] ); |
|
5031 | + if( empty( $output['day'] )) { |
|
5032 | + unset( $output['day'] ); |
|
5033 | + } |
|
4465 | 5034 | if ( isset( $output['hour'] ) || isset( $output['min'] ) || isset( $output['sec'] )) { |
4466 | - if( !isset( $output['hour'] )) $output['hour'] = 0; |
|
4467 | - if( !isset( $output['min'] )) $output['min'] = 0; |
|
4468 | - if( !isset( $output['sec'] )) $output['sec'] = 0; |
|
4469 | - if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] )) |
|
4470 | - unset( $output['hour'], $output['min'], $output['sec'] ); |
|
5035 | + if( !isset( $output['hour'] )) { |
|
5036 | + $output['hour'] = 0; |
|
5037 | + } |
|
5038 | + if( !isset( $output['min'] )) { |
|
5039 | + $output['min'] = 0; |
|
5040 | + } |
|
5041 | + if( !isset( $output['sec'] )) { |
|
5042 | + $output['sec'] = 0; |
|
5043 | + } |
|
5044 | + if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] )) { |
|
5045 | + unset( $output['hour'], $output['min'], $output['sec'] ); |
|
5046 | + } |
|
4471 | 5047 | } |
4472 | 5048 | return $output; |
4473 | 5049 | } |
@@ -4484,28 +5060,32 @@ discard block |
||
4484 | 5060 | if( $startdate && $duration ) { |
4485 | 5061 | $d1 = $startdate; |
4486 | 5062 | $dur = $duration; |
4487 | - } |
|
4488 | - elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) { |
|
5063 | + } elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) { |
|
4489 | 5064 | $d1 = $this->dtstart['value']; |
4490 | 5065 | $dur = $this->duration['value']; |
5066 | + } else { |
|
5067 | + return null; |
|
4491 | 5068 | } |
4492 | - else |
|
4493 | - return null; |
|
4494 | 5069 | $dateOnly = ( isset( $d1['hour'] ) || isset( $d1['min'] ) || isset( $d1['sec'] )) ? FALSE : TRUE; |
4495 | 5070 | $d1['hour'] = ( isset( $d1['hour'] )) ? $d1['hour'] : 0; |
4496 | 5071 | $d1['min'] = ( isset( $d1['min'] )) ? $d1['min'] : 0; |
4497 | 5072 | $d1['sec'] = ( isset( $d1['sec'] )) ? $d1['sec'] : 0; |
4498 | 5073 | $dtend = mktime( $d1['hour'], $d1['min'], $d1['sec'], $d1['month'], $d1['day'], $d1['year'] ); |
4499 | - if( isset( $dur['week'] )) |
|
4500 | - $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 ); |
|
4501 | - if( isset( $dur['day'] )) |
|
4502 | - $dtend += ( $dur['day'] * 24 * 60 * 60 ); |
|
4503 | - if( isset( $dur['hour'] )) |
|
4504 | - $dtend += ( $dur['hour'] * 60 *60 ); |
|
4505 | - if( isset( $dur['min'] )) |
|
4506 | - $dtend += ( $dur['min'] * 60 ); |
|
4507 | - if( isset( $dur['sec'] )) |
|
4508 | - $dtend += $dur['sec']; |
|
5074 | + if( isset( $dur['week'] )) { |
|
5075 | + $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 ); |
|
5076 | + } |
|
5077 | + if( isset( $dur['day'] )) { |
|
5078 | + $dtend += ( $dur['day'] * 24 * 60 * 60 ); |
|
5079 | + } |
|
5080 | + if( isset( $dur['hour'] )) { |
|
5081 | + $dtend += ( $dur['hour'] * 60 *60 ); |
|
5082 | + } |
|
5083 | + if( isset( $dur['min'] )) { |
|
5084 | + $dtend += ( $dur['min'] * 60 ); |
|
5085 | + } |
|
5086 | + if( isset( $dur['sec'] )) { |
|
5087 | + $dtend += $dur['sec']; |
|
5088 | + } |
|
4509 | 5089 | $dtend2 = array(); |
4510 | 5090 | $dtend2['year'] = date('Y', $dtend ); |
4511 | 5091 | $dtend2['month'] = date('m', $dtend ); |
@@ -4513,10 +5093,12 @@ discard block |
||
4513 | 5093 | $dtend2['hour'] = date('H', $dtend ); |
4514 | 5094 | $dtend2['min'] = date('i', $dtend ); |
4515 | 5095 | $dtend2['sec'] = date('s', $dtend ); |
4516 | - if( isset( $d1['tz'] )) |
|
4517 | - $dtend2['tz'] = $d1['tz']; |
|
4518 | - if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] ))) |
|
4519 | - unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] ); |
|
5096 | + if( isset( $d1['tz'] )) { |
|
5097 | + $dtend2['tz'] = $d1['tz']; |
|
5098 | + } |
|
5099 | + if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] ))) { |
|
5100 | + unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] ); |
|
5101 | + } |
|
4520 | 5102 | return $dtend2; |
4521 | 5103 | } |
4522 | 5104 | /** |
@@ -4530,10 +5112,12 @@ discard block |
||
4530 | 5112 | function _duration_string( $duration ) { |
4531 | 5113 | $duration = (string) trim( $duration ); |
4532 | 5114 | while( 'P' != strtoupper( substr( $duration, 0, 1 ))) { |
4533 | - if( 0 < strlen( $duration )) |
|
4534 | - $duration = substr( $duration, 1 ); |
|
4535 | - else |
|
4536 | - return false; // no leading P !?!? |
|
5115 | + if( 0 < strlen( $duration )) { |
|
5116 | + $duration = substr( $duration, 1 ); |
|
5117 | + } else { |
|
5118 | + return false; |
|
5119 | + } |
|
5120 | + // no leading P !?!? |
|
4537 | 5121 | } |
4538 | 5122 | $duration = substr( $duration, 1 ); // skip P |
4539 | 5123 | $duration = str_replace ( 't', 'T', $duration ); |
@@ -4563,10 +5147,13 @@ discard block |
||
4563 | 5147 | $val = null; |
4564 | 5148 | break; |
4565 | 5149 | default: |
4566 | - if( !ctype_digit( $duration{$ix} )) |
|
4567 | - return false; // unknown duration controll character !?!? |
|
4568 | - else |
|
4569 | - $val .= $duration{$ix}; |
|
5150 | + if( !ctype_digit( $duration{$ix} )) { |
|
5151 | + return false; |
|
5152 | + } |
|
5153 | + // unknown duration controll character !?!? |
|
5154 | + else { |
|
5155 | + $val .= $duration{$ix}; |
|
5156 | + } |
|
4570 | 5157 | } |
4571 | 5158 | } |
4572 | 5159 | return $this->_duration_array( $output ); |
@@ -4585,10 +5172,12 @@ discard block |
||
4585 | 5172 | * @return int |
4586 | 5173 | */ |
4587 | 5174 | function _existRem( &$array, $expkey, $expval=FALSE, $hitVal=null, $elseVal=null, $preSet=null ) { |
4588 | - if( $preSet ) |
|
4589 | - return $preSet; |
|
4590 | - if( !is_array( $array ) || ( 0 == count( $array ))) |
|
4591 | - return $elseVal; |
|
5175 | + if( $preSet ) { |
|
5176 | + return $preSet; |
|
5177 | + } |
|
5178 | + if( !is_array( $array ) || ( 0 == count( $array ))) { |
|
5179 | + return $elseVal; |
|
5180 | + } |
|
4592 | 5181 | foreach( $array as $key => $value ) { |
4593 | 5182 | if( strtoupper( $expkey ) == strtoupper( $key )) { |
4594 | 5183 | if( !$expval || ( strtoupper( $expval ) == strtoupper( $array[$key] ))) { |
@@ -4614,13 +5203,15 @@ discard block |
||
4614 | 5203 | !isset( $datetime['day'] ) && |
4615 | 5204 | !isset( $datetime['hour'] ) && |
4616 | 5205 | !isset( $datetime['min'] ) && |
4617 | - !isset( $datetime['sec'] )) |
|
4618 | - return ; |
|
5206 | + !isset( $datetime['sec'] )) { |
|
5207 | + return ; |
|
5208 | + } |
|
4619 | 5209 | $output = null; |
4620 | 5210 | // 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"; } |
4621 | 5211 | foreach( $datetime as $dkey => $dvalue ) { |
4622 | - if( 'tz' != $dkey ) |
|
4623 | - $datetime[$dkey] = (integer) $dvalue; |
|
5212 | + if( 'tz' != $dkey ) { |
|
5213 | + $datetime[$dkey] = (integer) $dvalue; |
|
5214 | + } |
|
4624 | 5215 | } |
4625 | 5216 | $output = date('Ymd', mktime( 0, 0, 0, $datetime['month'], $datetime['day'], $datetime['year'])); |
4626 | 5217 | if( isset( $datetime['hour'] ) || |
@@ -4628,29 +5219,33 @@ discard block |
||
4628 | 5219 | isset( $datetime['sec'] ) || |
4629 | 5220 | isset( $datetime['tz'] )) { |
4630 | 5221 | if( isset( $datetime['tz'] ) && |
4631 | - !isset( $datetime['hour'] )) |
|
4632 | - $datetime['hour'] = 0; |
|
5222 | + !isset( $datetime['hour'] )) { |
|
5223 | + $datetime['hour'] = 0; |
|
5224 | + } |
|
4633 | 5225 | if( isset( $datetime['hour'] ) && |
4634 | - !isset( $datetime['min'] )) |
|
4635 | - $datetime['min'] = 0; |
|
5226 | + !isset( $datetime['min'] )) { |
|
5227 | + $datetime['min'] = 0; |
|
5228 | + } |
|
4636 | 5229 | if( isset( $datetime['hour'] ) && |
4637 | 5230 | isset( $datetime['min'] ) && |
4638 | - !isset( $datetime['sec'] )) |
|
4639 | - $datetime['sec'] = 0; |
|
5231 | + !isset( $datetime['sec'] )) { |
|
5232 | + $datetime['sec'] = 0; |
|
5233 | + } |
|
4640 | 5234 | $date = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']); |
4641 | 5235 | $output .= date('\THis', $date ); |
4642 | 5236 | if( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) { |
4643 | 5237 | $datetime['tz'] = trim( $datetime['tz'] ); |
4644 | - if( 'Z' == $datetime['tz'] ) |
|
4645 | - $output .= 'Z'; |
|
5238 | + if( 'Z' == $datetime['tz'] ) { |
|
5239 | + $output .= 'Z'; |
|
5240 | + } |
|
4646 | 5241 | $offset = $this->_tz2offset( $datetime['tz'] ); |
4647 | 5242 | if( 0 != $offset ) { |
4648 | 5243 | $date = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']); |
4649 | 5244 | $output = date( 'Ymd\THis\Z', $date ); |
4650 | 5245 | } |
5246 | + } elseif( 7 == $parno ) { |
|
5247 | + $output .= 'Z'; |
|
4651 | 5248 | } |
4652 | - elseif( 7 == $parno ) |
|
4653 | - $output .= 'Z'; |
|
4654 | 5249 | } |
4655 | 5250 | return $output; |
4656 | 5251 | } |
@@ -4667,14 +5262,16 @@ discard block |
||
4667 | 5262 | !isset( $duration['day'] ) && |
4668 | 5263 | !isset( $duration['hour'] ) && |
4669 | 5264 | !isset( $duration['min'] ) && |
4670 | - !isset( $duration['sec'] )) |
|
4671 | - return; |
|
5265 | + !isset( $duration['sec'] )) { |
|
5266 | + return; |
|
5267 | + } |
|
4672 | 5268 | $output = 'P'; |
4673 | - if( isset( $duration['week'] ) && ( 0 < $duration['week'] )) |
|
4674 | - $output .= $duration['week'].'W'; |
|
4675 | - else { |
|
4676 | - if( isset($duration['day'] ) && ( 0 < $duration['day'] )) |
|
4677 | - $output .= $duration['day'].'D'; |
|
5269 | + if( isset( $duration['week'] ) && ( 0 < $duration['week'] )) { |
|
5270 | + $output .= $duration['week'].'W'; |
|
5271 | + } else { |
|
5272 | + if( isset($duration['day'] ) && ( 0 < $duration['day'] )) { |
|
5273 | + $output .= $duration['day'].'D'; |
|
5274 | + } |
|
4678 | 5275 | if(( isset( $duration['hour']) && ( 0 < $duration['hour'] )) || |
4679 | 5276 | ( isset( $duration['min']) && ( 0 < $duration['min'] )) || |
4680 | 5277 | ( isset( $duration['sec']) && ( 0 < $duration['sec'] ))) { |
@@ -4699,7 +5296,9 @@ discard block |
||
4699 | 5296 | $output = null; |
4700 | 5297 | foreach( $recurdata as $therule ) { |
4701 | 5298 | if( empty( $therule['value'] )) { |
4702 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $recurlabel ); |
|
5299 | + if( $this->getConfig( 'allowEmpty' )) { |
|
5300 | + $output .= $this->_createElement( $recurlabel ); |
|
5301 | + } |
|
4703 | 5302 | continue; |
4704 | 5303 | } |
4705 | 5304 | $attributes = ( isset( $therule['params'] )) ? $this->_createParams( $therule['params'] ) : null; |
@@ -4744,19 +5343,19 @@ discard block |
||
4744 | 5343 | if( is_array( $valuePart )) { |
4745 | 5344 | $content2 .= ( $bydaycnt ) ? ',' : null; |
4746 | 5345 | foreach( $valuePart as $vix2 => $valuePart2 ) { |
4747 | - if( 'DAY' != strtoupper( $vix2 )) |
|
4748 | - $content21 .= $valuePart2; |
|
4749 | - else |
|
4750 | - $content22 .= $valuePart2; |
|
5346 | + if( 'DAY' != strtoupper( $vix2 )) { |
|
5347 | + $content21 .= $valuePart2; |
|
5348 | + } else { |
|
5349 | + $content22 .= $valuePart2; |
|
5350 | + } |
|
4751 | 5351 | } |
4752 | 5352 | $content2 .= $content21.$content22; |
4753 | 5353 | $bydaycnt++; |
4754 | - } |
|
4755 | - else { |
|
5354 | + } else { |
|
4756 | 5355 | $content2 .= ( $bydaycnt ) ? ',' : null; |
4757 | - if( 'DAY' != strtoupper( $vix )) |
|
4758 | - $content21 .= $valuePart; |
|
4759 | - else { |
|
5356 | + if( 'DAY' != strtoupper( $vix )) { |
|
5357 | + $content21 .= $valuePart; |
|
5358 | + } else { |
|
4760 | 5359 | $content22 .= $valuePart; |
4761 | 5360 | $bydaycnt++; |
4762 | 5361 | } |
@@ -4800,24 +5399,32 @@ discard block |
||
4800 | 5399 | * @return bool |
4801 | 5400 | */ |
4802 | 5401 | function _isArrayDate( $input ) { |
4803 | - if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 )))) |
|
4804 | - return FALSE; |
|
4805 | - if( 7 == count( $input )) |
|
4806 | - return TRUE; |
|
4807 | - if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) |
|
4808 | - return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
4809 | - if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] )) |
|
4810 | - return FALSE; |
|
4811 | - if( in_array( 0, $input )) |
|
4812 | - return FALSE; |
|
4813 | - if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] )) |
|
4814 | - return FALSE; |
|
5402 | + if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 )))) { |
|
5403 | + return FALSE; |
|
5404 | + } |
|
5405 | + if( 7 == count( $input )) { |
|
5406 | + return TRUE; |
|
5407 | + } |
|
5408 | + if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) { |
|
5409 | + return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
5410 | + } |
|
5411 | + if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] )) { |
|
5412 | + return FALSE; |
|
5413 | + } |
|
5414 | + if( in_array( 0, $input )) { |
|
5415 | + return FALSE; |
|
5416 | + } |
|
5417 | + if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] )) { |
|
5418 | + return FALSE; |
|
5419 | + } |
|
4815 | 5420 | if(( isset( $input[0] ) && isset( $input[1] ) && isset( $input[2] )) && |
4816 | - checkdate( (int) $input[1], (int) $input[2], (int) $input[0] )) |
|
4817 | - return TRUE; |
|
5421 | + checkdate( (int) $input[1], (int) $input[2], (int) $input[0] )) { |
|
5422 | + return TRUE; |
|
5423 | + } |
|
4818 | 5424 | $input = $this->_date_time_string( $input[1].'/'.$input[2].'/'.$input[0], 3 ); // m - d - Y |
4819 | - if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) |
|
4820 | - return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
5425 | + if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) { |
|
5426 | + return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
5427 | + } |
|
4821 | 5428 | return FALSE; |
4822 | 5429 | } |
4823 | 5430 | /** |
@@ -4841,16 +5448,17 @@ discard block |
||
4841 | 5448 | */ |
4842 | 5449 | function _isOffset( $input ) { |
4843 | 5450 | $input = trim( (string) $input ); |
4844 | - if( 'Z' == substr( $input, -1 )) |
|
4845 | - return TRUE; |
|
4846 | - elseif(( 5 <= strlen( $input )) && |
|
5451 | + if( 'Z' == substr( $input, -1 )) { |
|
5452 | + return TRUE; |
|
5453 | + } elseif(( 5 <= strlen( $input )) && |
|
4847 | 5454 | ( in_array( substr( $input, -5, 1 ), array( '+', '-' ))) && |
4848 | - ( '0000' < substr( $input, -4 )) && ( '9999' >= substr( $input, -4 ))) |
|
4849 | - return TRUE; |
|
4850 | - elseif(( 7 <= strlen( $input )) && |
|
5455 | + ( '0000' < substr( $input, -4 )) && ( '9999' >= substr( $input, -4 ))) { |
|
5456 | + return TRUE; |
|
5457 | + } elseif(( 7 <= strlen( $input )) && |
|
4851 | 5458 | ( in_array( substr( $input, -7, 1 ), array( '+', '-' ))) && |
4852 | - ( '000000' < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 ))) |
|
4853 | - return TRUE; |
|
5459 | + ( '000000' < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 ))) { |
|
5460 | + return TRUE; |
|
5461 | + } |
|
4854 | 5462 | return FALSE; |
4855 | 5463 | |
4856 | 5464 | } |
@@ -4863,14 +5471,29 @@ discard block |
||
4863 | 5471 | * @return bool |
4864 | 5472 | */ |
4865 | 5473 | function _notExistProp( $propName ) { |
4866 | - if( empty( $propName )) return FALSE; // when deleting x-prop, an empty propName may be used=allowed |
|
5474 | + if( empty( $propName )) { |
|
5475 | + return FALSE; |
|
5476 | + } |
|
5477 | + // when deleting x-prop, an empty propName may be used=allowed |
|
4867 | 5478 | $propName = strtolower( $propName ); |
4868 | - if( 'last-modified' == $propName ) { if( !isset( $this->lastmodified )) return TRUE; } |
|
4869 | - elseif( 'percent-complete' == $propName ) { if( !isset( $this->percentcomplete )) return TRUE; } |
|
4870 | - elseif( 'recurrence-id' == $propName ) { if( !isset( $this->recurrenceid )) return TRUE; } |
|
4871 | - elseif( 'related-to' == $propName ) { if( !isset( $this->relatedto )) return TRUE; } |
|
4872 | - elseif( 'request-status' == $propName ) { if( !isset( $this->requeststatus )) return TRUE; } |
|
4873 | - elseif(( 'x-' != substr($propName,0,2)) && !isset( $this->$propName )) return TRUE; |
|
5479 | + if( 'last-modified' == $propName ) { if( !isset( $this->lastmodified )) { |
|
5480 | + return TRUE; |
|
5481 | + } |
|
5482 | + } elseif( 'percent-complete' == $propName ) { if( !isset( $this->percentcomplete )) { |
|
5483 | + return TRUE; |
|
5484 | + } |
|
5485 | + } elseif( 'recurrence-id' == $propName ) { if( !isset( $this->recurrenceid )) { |
|
5486 | + return TRUE; |
|
5487 | + } |
|
5488 | + } elseif( 'related-to' == $propName ) { if( !isset( $this->relatedto )) { |
|
5489 | + return TRUE; |
|
5490 | + } |
|
5491 | + } elseif( 'request-status' == $propName ) { if( !isset( $this->requeststatus )) { |
|
5492 | + return TRUE; |
|
5493 | + } |
|
5494 | + } elseif(( 'x-' != substr($propName,0,2)) && !isset( $this->$propName )) { |
|
5495 | + return TRUE; |
|
5496 | + } |
|
4874 | 5497 | return FALSE; |
4875 | 5498 | } |
4876 | 5499 | /** |
@@ -4889,7 +5512,9 @@ discard block |
||
4889 | 5512 | * @todo BYHOUR, BYMINUTE, BYSECOND, ev. BYSETPOS due to ambiguity, WEEKLY at year end/start |
4890 | 5513 | */ |
4891 | 5514 | function _recur2date( & $result, $recur, $wdate, $startdate, $enddate=FALSE ) { |
4892 | - foreach( $wdate as $k => $v ) if( ctype_digit( $v )) $wdate[$k] = (int) $v; |
|
5515 | + foreach( $wdate as $k => $v ) { |
|
5516 | + if( ctype_digit( $v )) $wdate[$k] = (int) $v; |
|
5517 | + } |
|
4893 | 5518 | $wdatets = $this->_date2timestamp( $wdate ); |
4894 | 5519 | $startdatets = $this->_date2timestamp( $startdate ); |
4895 | 5520 | if( !$enddate ) { |
@@ -4898,43 +5523,54 @@ discard block |
||
4898 | 5523 | // echo "recur __in_ ".implode('-',$startdate)." period start ".implode('-',$wdate)." period end ".implode('-',$enddate)."<br />\n";print_r($recur);echo "<br />\n";//test### |
4899 | 5524 | } |
4900 | 5525 | $endDatets = $this->_date2timestamp( $enddate ); // fix break |
4901 | - if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] )) |
|
4902 | - $recur['UNTIL'] = $enddate; // create break |
|
5526 | + if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] )) { |
|
5527 | + $recur['UNTIL'] = $enddate; |
|
5528 | + } |
|
5529 | + // create break |
|
4903 | 5530 | if( isset( $recur['UNTIL'] )) { |
4904 | 5531 | $tdatets = $this->_date2timestamp( $recur['UNTIL'] ); |
4905 | 5532 | if( $endDatets > $tdatets ) { |
4906 | 5533 | $endDatets = $tdatets; // emergency break |
4907 | 5534 | $enddate = $this->_timestamp2date( $endDatets, 6 ); |
5535 | + } else { |
|
5536 | + $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 ); |
|
4908 | 5537 | } |
4909 | - else |
|
4910 | - $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 ); |
|
4911 | 5538 | } |
4912 | 5539 | if( $wdatets > $endDatets ) { |
4913 | 5540 | //echo "recur out of date ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test |
4914 | 5541 | return array(); // nothing to do.. . |
4915 | 5542 | } |
4916 | - if( !isset( $recur['FREQ'] )) // "MUST be specified.. ." |
|
4917 | - $recur['FREQ'] = 'DAILY'; // ?? |
|
5543 | + if( !isset( $recur['FREQ'] )) { |
|
5544 | + // "MUST be specified.. ." |
|
5545 | + $recur['FREQ'] = 'DAILY'; |
|
5546 | + } |
|
5547 | + // ?? |
|
4918 | 5548 | $wkst = ( isset( $recur['WKST'] ) && ( 'SU' == $recur['WKST'] )) ? 24*60*60 : 0; // ?? |
4919 | - if( !isset( $recur['INTERVAL'] )) |
|
4920 | - $recur['INTERVAL'] = 1; |
|
5549 | + if( !isset( $recur['INTERVAL'] )) { |
|
5550 | + $recur['INTERVAL'] = 1; |
|
5551 | + } |
|
4921 | 5552 | $countcnt = ( !isset( $recur['BYSETPOS'] )) ? 1 : 0; // DTSTART counts as the first occurrence |
4922 | 5553 | /* find out how to step up dates and set index for interval count */ |
4923 | 5554 | $step = array(); |
4924 | - if( 'YEARLY' == $recur['FREQ'] ) |
|
4925 | - $step['year'] = 1; |
|
4926 | - elseif( 'MONTHLY' == $recur['FREQ'] ) |
|
4927 | - $step['month'] = 1; |
|
4928 | - elseif( 'WEEKLY' == $recur['FREQ'] ) |
|
4929 | - $step['day'] = 7; |
|
4930 | - else |
|
4931 | - $step['day'] = 1; |
|
4932 | - if( isset( $step['year'] ) && isset( $recur['BYMONTH'] )) |
|
4933 | - $step = array( 'month' => 1 ); |
|
4934 | - if( empty( $step ) && isset( $recur['BYWEEKNO'] )) // ?? |
|
5555 | + if( 'YEARLY' == $recur['FREQ'] ) { |
|
5556 | + $step['year'] = 1; |
|
5557 | + } elseif( 'MONTHLY' == $recur['FREQ'] ) { |
|
5558 | + $step['month'] = 1; |
|
5559 | + } elseif( 'WEEKLY' == $recur['FREQ'] ) { |
|
5560 | + $step['day'] = 7; |
|
5561 | + } else { |
|
5562 | + $step['day'] = 1; |
|
5563 | + } |
|
5564 | + if( isset( $step['year'] ) && isset( $recur['BYMONTH'] )) { |
|
5565 | + $step = array( 'month' => 1 ); |
|
5566 | + } |
|
5567 | + if( empty( $step ) && isset( $recur['BYWEEKNO'] )) { |
|
5568 | + // ?? |
|
4935 | 5569 | $step = array( 'day' => 7 ); |
4936 | - if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] )) |
|
4937 | - $step = array( 'day' => 1 ); |
|
5570 | + } |
|
5571 | + if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] )) { |
|
5572 | + $step = array( 'day' => 1 ); |
|
5573 | + } |
|
4938 | 5574 | $intervalarr = array(); |
4939 | 5575 | if( 1 < $recur['INTERVAL'] ) { |
4940 | 5576 | $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst ); |
@@ -4947,11 +5583,12 @@ discard block |
||
4947 | 5583 | $bysetposMold = $wdate['month']; |
4948 | 5584 | $bysetposDold = $wdate['day']; |
4949 | 5585 | if( is_array( $recur['BYSETPOS'] )) { |
4950 | - foreach( $recur['BYSETPOS'] as $bix => $bval ) |
|
4951 | - $recur['BYSETPOS'][$bix] = (int) $bval; |
|
5586 | + foreach( $recur['BYSETPOS'] as $bix => $bval ) { |
|
5587 | + $recur['BYSETPOS'][$bix] = (int) $bval; |
|
5588 | + } |
|
5589 | + } else { |
|
5590 | + $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] ); |
|
4952 | 5591 | } |
4953 | - else |
|
4954 | - $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] ); |
|
4955 | 5592 | $this->_stepdate( $enddate, $endDatets, $step); // make sure to count whole last period |
4956 | 5593 | } |
4957 | 5594 | $this->_stepdate( $wdate, $wdatets, $step); |
@@ -4960,10 +5597,12 @@ discard block |
||
4960 | 5597 | /* MAIN LOOP */ |
4961 | 5598 | // echo "recur start ".implode('-',$wdate)." end ".implode('-',$enddate)."<br />\n";//test |
4962 | 5599 | while( TRUE ) { |
4963 | - if( isset( $endDatets ) && ( $wdatets > $endDatets )) |
|
4964 | - break; |
|
4965 | - if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) |
|
4966 | - break; |
|
5600 | + if( isset( $endDatets ) && ( $wdatets > $endDatets )) { |
|
5601 | + break; |
|
5602 | + } |
|
5603 | + if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) { |
|
5604 | + break; |
|
5605 | + } |
|
4967 | 5606 | if( $year_old != $wdate['year'] ) { |
4968 | 5607 | $year_old = $wdate['year']; |
4969 | 5608 | $daycnts = array(); |
@@ -4972,8 +5611,9 @@ discard block |
||
4972 | 5611 | for( $m = 1; $m <= 12; $m++ ) { // count up and update up-counters |
4973 | 5612 | $daycnts[$m] = array(); |
4974 | 5613 | $weekdaycnt = array(); |
4975 | - foreach( $daynames as $dn ) |
|
4976 | - $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
|
5614 | + foreach( $daynames as $dn ) { |
|
5615 | + $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
|
5616 | + } |
|
4977 | 5617 | $mcnt = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] )); |
4978 | 5618 | for( $d = 1; $d <= $mcnt; $d++ ) { |
4979 | 5619 | $daycnts[$m][$d] = array(); |
@@ -4990,8 +5630,9 @@ discard block |
||
4990 | 5630 | $yeardaycnt[$day]++; |
4991 | 5631 | $daycnts[$m][$d]['yeardayno_up'] = $yeardaycnt[$day]; |
4992 | 5632 | } |
4993 | - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) |
|
4994 | - $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year'])); |
|
5633 | + if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) { |
|
5634 | + $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year'])); |
|
5635 | + } |
|
4995 | 5636 | } |
4996 | 5637 | } |
4997 | 5638 | $daycnt = 0; |
@@ -4999,9 +5640,9 @@ discard block |
||
4999 | 5640 | if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) { |
5000 | 5641 | $weekno = null; |
5001 | 5642 | for( $d=31; $d > 25; $d-- ) { // get last weekno for year |
5002 | - if( !$weekno ) |
|
5003 | - $weekno = $daycnts[12][$d]['weekno_up']; |
|
5004 | - elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) { |
|
5643 | + if( !$weekno ) { |
|
5644 | + $weekno = $daycnts[12][$d]['weekno_up']; |
|
5645 | + } elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) { |
|
5005 | 5646 | $weekno = $daycnts[12][$d]['weekno_up']; |
5006 | 5647 | break; |
5007 | 5648 | } |
@@ -5009,8 +5650,9 @@ discard block |
||
5009 | 5650 | } |
5010 | 5651 | for( $m = 12; $m > 0; $m-- ) { // count down and update down-counters |
5011 | 5652 | $weekdaycnt = array(); |
5012 | - foreach( $daynames as $dn ) |
|
5013 | - $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
|
5653 | + foreach( $daynames as $dn ) { |
|
5654 | + $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
|
5655 | + } |
|
5014 | 5656 | $monthcnt = 0; |
5015 | 5657 | $mcnt = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] )); |
5016 | 5658 | for( $d = $mcnt; $d > 0; $d-- ) { |
@@ -5029,8 +5671,9 @@ discard block |
||
5029 | 5671 | $yeardaycnt[$day] -= 1; |
5030 | 5672 | $daycnts[$m][$d]['yeardayno_down'] = $yeardaycnt[$day]; |
5031 | 5673 | } |
5032 | - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) |
|
5033 | - $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1); |
|
5674 | + if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) { |
|
5675 | + $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1); |
|
5676 | + } |
|
5034 | 5677 | } |
5035 | 5678 | } |
5036 | 5679 | } |
@@ -5041,36 +5684,42 @@ discard block |
||
5041 | 5684 | /* check interval */ |
5042 | 5685 | $currentKey = array_keys( $intervalarr ); |
5043 | 5686 | $currentKey = end( $currentKey ); // get last index |
5044 | - if( $currentKey != $intervalix ) |
|
5045 | - $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 )); |
|
5687 | + if( $currentKey != $intervalix ) { |
|
5688 | + $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 )); |
|
5689 | + } |
|
5046 | 5690 | if(( $recur['INTERVAL'] != $intervalarr[$intervalix] ) && |
5047 | 5691 | ( 0 != $intervalarr[$intervalix] )) { |
5048 | 5692 | /* step up date */ |
5049 | 5693 | //echo "skip: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test |
5050 | 5694 | $this->_stepdate( $wdate, $wdatets, $step); |
5051 | 5695 | continue; |
5052 | - } |
|
5053 | - else // continue within the selected interval |
|
5696 | + } else { |
|
5697 | + // continue within the selected interval |
|
5054 | 5698 | $intervalarr[$intervalix] = 0; |
5699 | + } |
|
5055 | 5700 | //echo "cont: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test |
5056 | 5701 | } |
5057 | 5702 | $updateOK = TRUE; |
5058 | - if( $updateOK && isset( $recur['BYMONTH'] )) |
|
5059 | - $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH'] |
|
5703 | + if( $updateOK && isset( $recur['BYMONTH'] )) { |
|
5704 | + $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH'] |
|
5060 | 5705 | , $wdate['month'] |
5061 | 5706 | ,($wdate['month'] - 13)); |
5062 | - if( $updateOK && isset( $recur['BYWEEKNO'] )) |
|
5063 | - $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO'] |
|
5707 | + } |
|
5708 | + if( $updateOK && isset( $recur['BYWEEKNO'] )) { |
|
5709 | + $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO'] |
|
5064 | 5710 | , $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] |
5065 | 5711 | , $daycnts[$wdate['month']][$wdate['day']]['weekno_down'] ); |
5066 | - if( $updateOK && isset( $recur['BYYEARDAY'] )) |
|
5067 | - $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY'] |
|
5712 | + } |
|
5713 | + if( $updateOK && isset( $recur['BYYEARDAY'] )) { |
|
5714 | + $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY'] |
|
5068 | 5715 | , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_up'] |
5069 | 5716 | , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down'] ); |
5070 | - if( $updateOK && isset( $recur['BYMONTHDAY'] )) |
|
5071 | - $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY'] |
|
5717 | + } |
|
5718 | + if( $updateOK && isset( $recur['BYMONTHDAY'] )) { |
|
5719 | + $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY'] |
|
5072 | 5720 | , $wdate['day'] |
5073 | 5721 | , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down'] ); |
5722 | + } |
|
5074 | 5723 | //echo "efter BYMONTHDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n";//test### |
5075 | 5724 | if( $updateOK && isset( $recur['BYDAY'] )) { |
5076 | 5725 | $updateOK = FALSE; |
@@ -5078,42 +5727,45 @@ discard block |
||
5078 | 5727 | $d = $wdate['day']; |
5079 | 5728 | if( isset( $recur['BYDAY']['DAY'] )) { // single day, opt with year/month day order no |
5080 | 5729 | $daynoexists = $daynosw = $daynamesw = FALSE; |
5081 | - if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] ) |
|
5082 | - $daynamesw = TRUE; |
|
5730 | + if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] ) { |
|
5731 | + $daynamesw = TRUE; |
|
5732 | + } |
|
5083 | 5733 | if( isset( $recur['BYDAY'][0] )) { |
5084 | 5734 | $daynoexists = TRUE; |
5085 | - if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] )) |
|
5086 | - $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5735 | + if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] )) { |
|
5736 | + $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5087 | 5737 | , $daycnts[$m][$d]['monthdayno_up'] |
5088 | 5738 | , $daycnts[$m][$d]['monthdayno_down'] ); |
5089 | - elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) |
|
5090 | - $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5739 | + } elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) { |
|
5740 | + $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5091 | 5741 | , $daycnts[$m][$d]['yeardayno_up'] |
5092 | 5742 | , $daycnts[$m][$d]['yeardayno_down'] ); |
5743 | + } |
|
5093 | 5744 | } |
5094 | 5745 | if(( $daynoexists && $daynosw && $daynamesw ) || |
5095 | 5746 | ( !$daynoexists && !$daynosw && $daynamesw )) { |
5096 | 5747 | $updateOK = TRUE; |
5097 | 5748 | } |
5098 | 5749 | //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ### |
5099 | - } |
|
5100 | - else { |
|
5750 | + } else { |
|
5101 | 5751 | foreach( $recur['BYDAY'] as $bydayvalue ) { |
5102 | 5752 | $daynoexists = $daynosw = $daynamesw = FALSE; |
5103 | 5753 | if( isset( $bydayvalue['DAY'] ) && |
5104 | - ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] )) |
|
5105 | - $daynamesw = TRUE; |
|
5754 | + ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] )) { |
|
5755 | + $daynamesw = TRUE; |
|
5756 | + } |
|
5106 | 5757 | if( isset( $bydayvalue[0] )) { |
5107 | 5758 | $daynoexists = TRUE; |
5108 | 5759 | if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || |
5109 | - isset( $recur['BYMONTH'] )) |
|
5110 | - $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5760 | + isset( $recur['BYMONTH'] )) { |
|
5761 | + $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5111 | 5762 | , $daycnts[$m][$d]['monthdayno_up'] |
5112 | 5763 | , $daycnts[$m][$d]['monthdayno_down'] ); |
5113 | - elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) |
|
5114 | - $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5764 | + } elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) { |
|
5765 | + $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5115 | 5766 | , $daycnts[$m][$d]['yeardayno_up'] |
5116 | 5767 | , $daycnts[$m][$d]['yeardayno_down'] ); |
5768 | + } |
|
5117 | 5769 | } |
5118 | 5770 | //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ### |
5119 | 5771 | if(( $daynoexists && $daynosw && $daynamesw ) || |
@@ -5130,12 +5782,12 @@ discard block |
||
5130 | 5782 | if( isset( $recur['BYSETPOS'] ) && |
5131 | 5783 | ( in_array( $recur['FREQ'], array( 'YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY' )))) { |
5132 | 5784 | if( isset( $recur['WEEKLY'] )) { |
5133 | - if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] ) |
|
5134 | - $bysetposw1[] = $wdatets; |
|
5135 | - else |
|
5136 | - $bysetposw2[] = $wdatets; |
|
5137 | - } |
|
5138 | - else { |
|
5785 | + if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] ) { |
|
5786 | + $bysetposw1[] = $wdatets; |
|
5787 | + } else { |
|
5788 | + $bysetposw2[] = $wdatets; |
|
5789 | + } |
|
5790 | + } else { |
|
5139 | 5791 | if(( isset( $recur['FREQ'] ) && ( 'YEARLY' == $recur['FREQ'] ) && |
5140 | 5792 | ( $bysetposYold == $wdate['year'] )) || |
5141 | 5793 | ( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] ) && |
@@ -5144,13 +5796,13 @@ discard block |
||
5144 | 5796 | ( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] ) && |
5145 | 5797 | (( $bysetposYold == $wdate['year'] ) && |
5146 | 5798 | ( $bysetposMold == $wdate['month']) && |
5147 | - ( $bysetposDold == $wdate['sday'] )))) |
|
5148 | - $bysetposymd1[] = $wdatets; |
|
5149 | - else |
|
5150 | - $bysetposymd2[] = $wdatets; |
|
5799 | + ( $bysetposDold == $wdate['sday'] )))) { |
|
5800 | + $bysetposymd1[] = $wdatets; |
|
5801 | + } else { |
|
5802 | + $bysetposymd2[] = $wdatets; |
|
5803 | + } |
|
5151 | 5804 | } |
5152 | - } |
|
5153 | - else { |
|
5805 | + } else { |
|
5154 | 5806 | /* update result array if BYSETPOS is set */ |
5155 | 5807 | $countcnt++; |
5156 | 5808 | if( $startdatets <= $wdatets ) { // only output within period |
@@ -5170,21 +5822,18 @@ discard block |
||
5170 | 5822 | ( $bysetposYold != $wdate['year'] )) { |
5171 | 5823 | $bysetpos = TRUE; |
5172 | 5824 | $bysetposYold = $wdate['year']; |
5173 | - } |
|
5174 | - elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] && |
|
5825 | + } elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] && |
|
5175 | 5826 | (( $bysetposYold != $wdate['year'] ) || ( $bysetposMold != $wdate['month'] )))) { |
5176 | 5827 | $bysetpos = TRUE; |
5177 | 5828 | $bysetposYold = $wdate['year']; |
5178 | 5829 | $bysetposMold = $wdate['month']; |
5179 | - } |
|
5180 | - elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY' == $recur['FREQ'] )) { |
|
5830 | + } elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY' == $recur['FREQ'] )) { |
|
5181 | 5831 | $weekno = (int) date( 'W', mktime( 0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year'])); |
5182 | 5832 | if( $bysetposWold != $weekno ) { |
5183 | 5833 | $bysetposWold = $weekno; |
5184 | 5834 | $bysetpos = TRUE; |
5185 | 5835 | } |
5186 | - } |
|
5187 | - elseif( isset( $recur['FREQ'] ) && ( 'DAILY' == $recur['FREQ'] ) && |
|
5836 | + } elseif( isset( $recur['FREQ'] ) && ( 'DAILY' == $recur['FREQ'] ) && |
|
5188 | 5837 | (( $bysetposYold != $wdate['year'] ) || |
5189 | 5838 | ( $bysetposMold != $wdate['month'] ) || |
5190 | 5839 | ( $bysetposDold != $wdate['sday'] ))) { |
@@ -5197,14 +5846,15 @@ discard block |
||
5197 | 5846 | if( isset( $recur['BYWEEKNO'] )) { |
5198 | 5847 | $bysetposarr1 = & $bysetposw1; |
5199 | 5848 | $bysetposarr2 = & $bysetposw2; |
5200 | - } |
|
5201 | - else { |
|
5849 | + } else { |
|
5202 | 5850 | $bysetposarr1 = & $bysetposymd1; |
5203 | 5851 | $bysetposarr2 = & $bysetposymd2; |
5204 | 5852 | } |
5205 | 5853 | foreach( $recur['BYSETPOS'] as $ix ) { |
5206 | - if( 0 > $ix ) // both positive and negative BYSETPOS allowed |
|
5854 | + if( 0 > $ix ) { |
|
5855 | + // both positive and negative BYSETPOS allowed |
|
5207 | 5856 | $ix = ( count( $bysetposarr1 ) + $ix + 1); |
5857 | + } |
|
5208 | 5858 | $ix--; |
5209 | 5859 | if( isset( $bysetposarr1[$ix] )) { |
5210 | 5860 | if( $startdatets <= $bysetposarr1[$ix] ) { // only output within period |
@@ -5213,8 +5863,9 @@ discard block |
||
5213 | 5863 | } |
5214 | 5864 | $countcnt++; |
5215 | 5865 | } |
5216 | - if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) |
|
5217 | - break; |
|
5866 | + if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) { |
|
5867 | + break; |
|
5868 | + } |
|
5218 | 5869 | } |
5219 | 5870 | $bysetposarr1 = $bysetposarr2; |
5220 | 5871 | $bysetposarr2 = array(); |
@@ -5224,12 +5875,13 @@ discard block |
||
5224 | 5875 | } |
5225 | 5876 | function _recurBYcntcheck( $BYvalue, $upValue, $downValue ) { |
5226 | 5877 | if( is_array( $BYvalue ) && |
5227 | - ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue ))) |
|
5228 | - return TRUE; |
|
5229 | - elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue )) |
|
5230 | - return TRUE; |
|
5231 | - else |
|
5232 | - return FALSE; |
|
5878 | + ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue ))) { |
|
5879 | + return TRUE; |
|
5880 | + } elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue )) { |
|
5881 | + return TRUE; |
|
5882 | + } else { |
|
5883 | + return FALSE; |
|
5884 | + } |
|
5233 | 5885 | } |
5234 | 5886 | function _recurIntervalIx( $freq, $date, $wkst ) { |
5235 | 5887 | /* create interval index */ |
@@ -5261,21 +5913,27 @@ discard block |
||
5261 | 5913 | */ |
5262 | 5914 | function _setRexrule( $rexrule ) { |
5263 | 5915 | $input = array(); |
5264 | - if( empty( $rexrule )) |
|
5265 | - return $input; |
|
5916 | + if( empty( $rexrule )) { |
|
5917 | + return $input; |
|
5918 | + } |
|
5266 | 5919 | foreach( $rexrule as $rexrulelabel => $rexrulevalue ) { |
5267 | 5920 | $rexrulelabel = strtoupper( $rexrulelabel ); |
5268 | - if( 'UNTIL' != $rexrulelabel ) |
|
5269 | - $input[$rexrulelabel] = $rexrulevalue; |
|
5270 | - else { |
|
5271 | - if( $this->_isArrayTimestampDate( $rexrulevalue )) // timestamp date |
|
5921 | + if( 'UNTIL' != $rexrulelabel ) { |
|
5922 | + $input[$rexrulelabel] = $rexrulevalue; |
|
5923 | + } else { |
|
5924 | + if( $this->_isArrayTimestampDate( $rexrulevalue )) { |
|
5925 | + // timestamp date |
|
5272 | 5926 | $input[$rexrulelabel] = $this->_timestamp2date( $rexrulevalue, 6 ); |
5273 | - elseif( $this->_isArrayDate( $rexrulevalue )) // date-time |
|
5927 | + } elseif( $this->_isArrayDate( $rexrulevalue )) { |
|
5928 | + // date-time |
|
5274 | 5929 | $input[$rexrulelabel] = $this->_date_time_array( $rexrulevalue, 6 ); |
5275 | - elseif( 8 <= strlen( trim( $rexrulevalue ))) // ex. 2006-08-03 10:12:18 |
|
5930 | + } elseif( 8 <= strlen( trim( $rexrulevalue ))) { |
|
5931 | + // ex. 2006-08-03 10:12:18 |
|
5276 | 5932 | $input[$rexrulelabel] = $this->_date_time_string( $rexrulevalue ); |
5277 | - if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] )) |
|
5278 | - $input[$rexrulelabel]['tz'] = 'Z'; |
|
5933 | + } |
|
5934 | + if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] )) { |
|
5935 | + $input[$rexrulelabel]['tz'] = 'Z'; |
|
5936 | + } |
|
5279 | 5937 | } |
5280 | 5938 | } |
5281 | 5939 | return $input; |
@@ -5299,7 +5957,9 @@ discard block |
||
5299 | 5957 | $input = $parno = null; |
5300 | 5958 | $localtime = (( 'dtstart' == $caller ) && in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE; |
5301 | 5959 | if( $this->_isArrayDate( $year )) { |
5302 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5960 | + if( $localtime ) { |
|
5961 | + unset ( $month['VALUE'], $month['TZID'] ); |
|
5962 | + } |
|
5303 | 5963 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
5304 | 5964 | if( isset( $input['params']['TZID'] )) { |
5305 | 5965 | $input['params']['VALUE'] = 'DATE-TIME'; |
@@ -5309,9 +5969,10 @@ discard block |
||
5309 | 5969 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval ); |
5310 | 5970 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, count( $year ), $parno ); |
5311 | 5971 | $input['value'] = $this->_date_time_array( $year, $parno ); |
5312 | - } |
|
5313 | - elseif( $this->_isArrayTimestampDate( $year )) { |
|
5314 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5972 | + } elseif( $this->_isArrayTimestampDate( $year )) { |
|
5973 | + if( $localtime ) { |
|
5974 | + unset ( $month['VALUE'], $month['TZID'] ); |
|
5975 | + } |
|
5315 | 5976 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
5316 | 5977 | if( isset( $input['params']['TZID'] )) { |
5317 | 5978 | $input['params']['VALUE'] = 'DATE-TIME'; |
@@ -5321,9 +5982,10 @@ discard block |
||
5321 | 5982 | $hitval = ( isset( $year['tz'] )) ? 7 : 6; |
5322 | 5983 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno ); |
5323 | 5984 | $input['value'] = $this->_timestamp2date( $year, $parno ); |
5324 | - } |
|
5325 | - elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
5326 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5985 | + } elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
5986 | + if( $localtime ) { |
|
5987 | + unset ( $month['VALUE'], $month['TZID'] ); |
|
5988 | + } |
|
5327 | 5989 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
5328 | 5990 | if( isset( $input['params']['TZID'] )) { |
5329 | 5991 | $input['params']['VALUE'] = 'DATE-TIME'; |
@@ -5332,17 +5994,16 @@ discard block |
||
5332 | 5994 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7, $parno ); |
5333 | 5995 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, $parno, $parno ); |
5334 | 5996 | $input['value'] = $this->_date_time_string( $year, $parno ); |
5335 | - } |
|
5336 | - else { |
|
5997 | + } else { |
|
5337 | 5998 | if( is_array( $params )) { |
5338 | - if( $localtime ) unset ( $params['VALUE'], $params['TZID'] ); |
|
5999 | + if( $localtime ) { |
|
6000 | + unset ( $params['VALUE'], $params['TZID'] ); |
|
6001 | + } |
|
5339 | 6002 | $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )); |
5340 | - } |
|
5341 | - elseif( is_array( $tz )) { |
|
6003 | + } elseif( is_array( $tz )) { |
|
5342 | 6004 | $input['params'] = $this->_setParams( $tz, array( 'VALUE' => 'DATE-TIME' )); |
5343 | 6005 | $tz = FALSE; |
5344 | - } |
|
5345 | - elseif( is_array( $hour )) { |
|
6006 | + } elseif( is_array( $hour )) { |
|
5346 | 6007 | $input['params'] = $this->_setParams( $hour, array( 'VALUE' => 'DATE-TIME' )); |
5347 | 6008 | $hour = $min = $sec = $tz = FALSE; |
5348 | 6009 | } |
@@ -5358,23 +6019,28 @@ discard block |
||
5358 | 6019 | $input['value']['hour'] = ( $hour ) ? $hour : '0'; |
5359 | 6020 | $input['value']['min'] = ( $min ) ? $min : '0'; |
5360 | 6021 | $input['value']['sec'] = ( $sec ) ? $sec : '0'; |
5361 | - if( !empty( $tz )) |
|
5362 | - $input['value']['tz'] = $tz; |
|
6022 | + if( !empty( $tz )) { |
|
6023 | + $input['value']['tz'] = $tz; |
|
6024 | + } |
|
5363 | 6025 | } |
5364 | 6026 | } |
5365 | 6027 | if( 3 == $parno ) { |
5366 | 6028 | $input['params']['VALUE'] = 'DATE'; |
5367 | 6029 | unset( $input['value']['tz'] ); |
5368 | 6030 | unset( $input['params']['TZID'] ); |
6031 | + } elseif( isset( $input['params']['TZID'] )) { |
|
6032 | + unset( $input['value']['tz'] ); |
|
6033 | + } |
|
6034 | + if( $localtime ) { |
|
6035 | + unset( $input['value']['tz'], $input['params']['TZID'] ); |
|
6036 | + } |
|
6037 | + if( isset( $input['value']['tz'] )) { |
|
6038 | + $input['value']['tz'] = (string) $input['value']['tz']; |
|
5369 | 6039 | } |
5370 | - elseif( isset( $input['params']['TZID'] )) |
|
5371 | - unset( $input['value']['tz'] ); |
|
5372 | - if( $localtime ) unset( $input['value']['tz'], $input['params']['TZID'] ); |
|
5373 | - if( isset( $input['value']['tz'] )) |
|
5374 | - $input['value']['tz'] = (string) $input['value']['tz']; |
|
5375 | 6040 | if( !empty( $input['value']['tz'] ) && ( 'Z' != $input['value']['tz'] ) && |
5376 | - ( !$this->_isOffset( $input['value']['tz'] ))) |
|
5377 | - $input['params']['TZID'] = $input['value']['tz']; |
|
6041 | + ( !$this->_isOffset( $input['value']['tz'] ))) { |
|
6042 | + $input['params']['TZID'] = $input['value']['tz']; |
|
6043 | + } |
|
5378 | 6044 | return $input; |
5379 | 6045 | } |
5380 | 6046 | /** |
@@ -5396,16 +6062,13 @@ discard block |
||
5396 | 6062 | if( $this->_isArrayDate( $year )) { |
5397 | 6063 | $input['value'] = $this->_date_time_array( $year, 7 ); |
5398 | 6064 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
5399 | - } |
|
5400 | - elseif( $this->_isArrayTimestampDate( $year )) { |
|
6065 | + } elseif( $this->_isArrayTimestampDate( $year )) { |
|
5401 | 6066 | $input['value'] = $this->_timestamp2date( $year, 7 ); |
5402 | 6067 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
5403 | - } |
|
5404 | - elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
6068 | + } elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
5405 | 6069 | $input['value'] = $this->_date_time_string( $year, 7 ); |
5406 | 6070 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
5407 | - } |
|
5408 | - else { |
|
6071 | + } else { |
|
5409 | 6072 | $input['value'] = array( 'year' => $year |
5410 | 6073 | , 'month' => $month |
5411 | 6074 | , 'day' => $day |
@@ -5415,14 +6078,18 @@ discard block |
||
5415 | 6078 | $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )); |
5416 | 6079 | } |
5417 | 6080 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7 ); // remove default |
5418 | - if( !isset( $input['value']['hour'] )) |
|
5419 | - $input['value']['hour'] = 0; |
|
5420 | - if( !isset( $input['value']['min'] )) |
|
5421 | - $input['value']['min'] = 0; |
|
5422 | - if( !isset( $input['value']['sec'] )) |
|
5423 | - $input['value']['sec'] = 0; |
|
5424 | - if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] )) |
|
5425 | - $input['value']['tz'] = 'Z'; |
|
6081 | + if( !isset( $input['value']['hour'] )) { |
|
6082 | + $input['value']['hour'] = 0; |
|
6083 | + } |
|
6084 | + if( !isset( $input['value']['min'] )) { |
|
6085 | + $input['value']['min'] = 0; |
|
6086 | + } |
|
6087 | + if( !isset( $input['value']['sec'] )) { |
|
6088 | + $input['value']['sec'] = 0; |
|
6089 | + } |
|
6090 | + if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] )) { |
|
6091 | + $input['value']['tz'] = 'Z'; |
|
6092 | + } |
|
5426 | 6093 | return $input; |
5427 | 6094 | } |
5428 | 6095 | /** |
@@ -5438,15 +6105,17 @@ discard block |
||
5438 | 6105 | * @return void |
5439 | 6106 | */ |
5440 | 6107 | function _setMval( & $valArr, $value, $params=FALSE, $defaults=FALSE, $index=FALSE ) { |
5441 | - if( !is_array( $valArr )) $valArr = array(); |
|
5442 | - if( $index ) |
|
5443 | - $index = $index - 1; |
|
5444 | - elseif( 0 < count( $valArr )) { |
|
6108 | + if( !is_array( $valArr )) { |
|
6109 | + $valArr = array(); |
|
6110 | + } |
|
6111 | + if( $index ) { |
|
6112 | + $index = $index - 1; |
|
6113 | + } elseif( 0 < count( $valArr )) { |
|
5445 | 6114 | $index = end( array_keys( $valArr )); |
5446 | 6115 | $index += 1; |
6116 | + } else { |
|
6117 | + $index = 0; |
|
5447 | 6118 | } |
5448 | - else |
|
5449 | - $index = 0; |
|
5450 | 6119 | $valArr[$index] = array( 'value' => $value, 'params' => $this->_setParams( $params, $defaults )); |
5451 | 6120 | ksort( $valArr ); |
5452 | 6121 | } |
@@ -5462,27 +6131,31 @@ discard block |
||
5462 | 6131 | * @return array |
5463 | 6132 | */ |
5464 | 6133 | function _setParams( $params, $defaults=FALSE ) { |
5465 | - if( !is_array( $params)) |
|
5466 | - $params = array(); |
|
6134 | + if( !is_array( $params)) { |
|
6135 | + $params = array(); |
|
6136 | + } |
|
5467 | 6137 | $input = array(); |
5468 | 6138 | foreach( $params as $paramKey => $paramValue ) { |
5469 | 6139 | if( is_array( $paramValue )) { |
5470 | 6140 | foreach( $paramValue as $pkey => $pValue ) { |
5471 | - if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 ))) |
|
5472 | - $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 )); |
|
6141 | + if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 ))) { |
|
6142 | + $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 )); |
|
6143 | + } |
|
5473 | 6144 | } |
6145 | + } elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 ))) { |
|
6146 | + $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 )); |
|
6147 | + } |
|
6148 | + if( 'VALUE' == strtoupper( $paramKey )) { |
|
6149 | + $input['VALUE'] = strtoupper( $paramValue ); |
|
6150 | + } else { |
|
6151 | + $input[strtoupper( $paramKey )] = $paramValue; |
|
5474 | 6152 | } |
5475 | - elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 ))) |
|
5476 | - $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 )); |
|
5477 | - if( 'VALUE' == strtoupper( $paramKey )) |
|
5478 | - $input['VALUE'] = strtoupper( $paramValue ); |
|
5479 | - else |
|
5480 | - $input[strtoupper( $paramKey )] = $paramValue; |
|
5481 | 6153 | } |
5482 | 6154 | if( is_array( $defaults )) { |
5483 | 6155 | foreach( $defaults as $paramKey => $paramValue ) { |
5484 | - if( !isset( $input[$paramKey] )) |
|
5485 | - $input[$paramKey] = $paramValue; |
|
6156 | + if( !isset( $input[$paramKey] )) { |
|
6157 | + $input[$paramKey] = $paramValue; |
|
6158 | + } |
|
5486 | 6159 | } |
5487 | 6160 | } |
5488 | 6161 | return (0 < count( $input )) ? $input : null; |
@@ -5498,13 +6171,15 @@ discard block |
||
5498 | 6171 | * @return void |
5499 | 6172 | */ |
5500 | 6173 | function _stepdate( &$date, &$timestamp, $step=array( 'day' => 1 )) { |
5501 | - foreach( $step as $stepix => $stepvalue ) |
|
5502 | - $date[$stepix] += $stepvalue; |
|
6174 | + foreach( $step as $stepix => $stepvalue ) { |
|
6175 | + $date[$stepix] += $stepvalue; |
|
6176 | + } |
|
5503 | 6177 | $timestamp = $this->_date2timestamp( $date ); |
5504 | 6178 | $date = $this->_timestamp2date( $timestamp, 6 ); |
5505 | 6179 | foreach( $date as $k => $v ) { |
5506 | - if( ctype_digit( $v )) |
|
5507 | - $date[$k] = (int) $v; |
|
6180 | + if( ctype_digit( $v )) { |
|
6181 | + $date[$k] = (int) $v; |
|
6182 | + } |
|
5508 | 6183 | } |
5509 | 6184 | } |
5510 | 6185 | /** |
@@ -5518,8 +6193,9 @@ discard block |
||
5518 | 6193 | */ |
5519 | 6194 | function _timestamp2date( $timestamp, $parno=6 ) { |
5520 | 6195 | if( is_array( $timestamp )) { |
5521 | - if(( 7 == $parno ) && !empty( $timestamp['tz'] )) |
|
5522 | - $tz = $timestamp['tz']; |
|
6196 | + if(( 7 == $parno ) && !empty( $timestamp['tz'] )) { |
|
6197 | + $tz = $timestamp['tz']; |
|
6198 | + } |
|
5523 | 6199 | $timestamp = $timestamp['timestamp']; |
5524 | 6200 | } |
5525 | 6201 | $output = array( 'year' => date( 'Y', $timestamp ) |
@@ -5529,8 +6205,9 @@ discard block |
||
5529 | 6205 | $output['hour'] = date( 'H', $timestamp ); |
5530 | 6206 | $output['min'] = date( 'i', $timestamp ); |
5531 | 6207 | $output['sec'] = date( 's', $timestamp ); |
5532 | - if( isset( $tz )) |
|
5533 | - $output['tz'] = $tz; |
|
6208 | + if( isset( $tz )) { |
|
6209 | + $output['tz'] = $tz; |
|
6210 | + } |
|
5534 | 6211 | } |
5535 | 6212 | return $output; |
5536 | 6213 | } |
@@ -5548,8 +6225,9 @@ discard block |
||
5548 | 6225 | if((( 5 != strlen( $tz )) && ( 7 != strlen( $tz ))) || |
5549 | 6226 | (( '+' != substr( $tz, 0, 1 )) && ( '-' != substr( $tz, 0, 1 ))) || |
5550 | 6227 | (( '0000' >= substr( $tz, 1, 4 )) && ( '9999' < substr( $tz, 1, 4 ))) || |
5551 | - (( 7 == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 )))) |
|
5552 | - return $offset; |
|
6228 | + (( 7 == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 )))) { |
|
6229 | + return $offset; |
|
6230 | + } |
|
5553 | 6231 | $hours2sec = (int) substr( $tz, 1, 2 ) * 3600; |
5554 | 6232 | $min2sec = (int) substr( $tz, 3, 2 ) * 60; |
5555 | 6233 | $sec = ( 7 == strlen( $tz )) ? (int) substr( $tz, -2 ) : '00'; |
@@ -5577,7 +6255,9 @@ discard block |
||
5577 | 6255 | $info = array(); |
5578 | 6256 | if( isset( $this->components )) { |
5579 | 6257 | foreach( $this->components as $cix => $component ) { |
5580 | - if( empty( $component )) continue; |
|
6258 | + if( empty( $component )) { |
|
6259 | + continue; |
|
6260 | + } |
|
5581 | 6261 | unset( $component->propix ); |
5582 | 6262 | $info[$cix]['ordno'] = $cix + 1; |
5583 | 6263 | $info[$cix]['type'] = $component->objName; |
@@ -5603,57 +6283,146 @@ discard block |
||
5603 | 6283 | case 'PROPINFO': |
5604 | 6284 | $output = array(); |
5605 | 6285 | if( !in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
5606 | - if( empty( $this->uid['value'] )) $this->_makeuid(); |
|
6286 | + if( empty( $this->uid['value'] )) { |
|
6287 | + $this->_makeuid(); |
|
6288 | + } |
|
5607 | 6289 | $output['UID'] = 1; |
5608 | 6290 | } |
5609 | - if( !empty( $this->dtstamp )) $output['DTSTAMP'] = 1; |
|
5610 | - if( !empty( $this->summary )) $output['SUMMARY'] = 1; |
|
5611 | - if( !empty( $this->description )) $output['DESCRIPTION'] = count( $this->description ); |
|
5612 | - if( !empty( $this->dtstart )) $output['DTSTART'] = 1; |
|
5613 | - if( !empty( $this->dtend )) $output['DTEND'] = 1; |
|
5614 | - if( !empty( $this->due )) $output['DUE'] = 1; |
|
5615 | - if( !empty( $this->duration )) $output['DURATION'] = 1; |
|
5616 | - if( !empty( $this->rrule )) $output['RRULE'] = count( $this->rrule ); |
|
5617 | - if( !empty( $this->rdate )) $output['RDATE'] = count( $this->rdate ); |
|
5618 | - if( !empty( $this->exdate )) $output['EXDATE'] = count( $this->exdate ); |
|
5619 | - if( !empty( $this->exrule )) $output['EXRULE'] = count( $this->exrule ); |
|
5620 | - if( !empty( $this->action )) $output['ACTION'] = 1; |
|
5621 | - if( !empty( $this->attach )) $output['ATTACH'] = count( $this->attach ); |
|
5622 | - if( !empty( $this->attendee )) $output['ATTENDEE'] = count( $this->attendee ); |
|
5623 | - if( !empty( $this->categories )) $output['CATEGORIES'] = count( $this->categories ); |
|
5624 | - if( !empty( $this->class )) $output['CLASS'] = 1; |
|
5625 | - if( !empty( $this->comment )) $output['COMMENT'] = count( $this->comment ); |
|
5626 | - if( !empty( $this->completed )) $output['COMPLETED'] = 1; |
|
5627 | - if( !empty( $this->contact )) $output['CONTACT'] = count( $this->contact ); |
|
5628 | - if( !empty( $this->created )) $output['CREATED'] = 1; |
|
5629 | - if( !empty( $this->freebusy )) $output['FREEBUSY'] = count( $this->freebusy ); |
|
5630 | - if( !empty( $this->geo )) $output['GEO'] = 1; |
|
5631 | - if( !empty( $this->lastmodified )) $output['LAST-MODIFIED'] = 1; |
|
5632 | - if( !empty( $this->location )) $output['LOCATION'] = 1; |
|
5633 | - if( !empty( $this->organizer )) $output['ORGANIZER'] = 1; |
|
5634 | - if( !empty( $this->percentcomplete )) $output['PERCENT-COMPLETE'] = 1; |
|
5635 | - if( !empty( $this->priority )) $output['PRIORITY'] = 1; |
|
5636 | - if( !empty( $this->recurrenceid )) $output['RECURRENCE-ID'] = 1; |
|
5637 | - if( !empty( $this->relatedto )) $output['RELATED-TO'] = count( $this->relatedto ); |
|
5638 | - if( !empty( $this->repeat )) $output['REPEAT'] = 1; |
|
5639 | - if( !empty( $this->requeststatus )) $output['REQUEST-STATUS'] = count( $this->requeststatus ); |
|
5640 | - if( !empty( $this->resources )) $output['RESOURCES'] = count( $this->resources ); |
|
5641 | - if( !empty( $this->sequence )) $output['SEQUENCE'] = 1; |
|
5642 | - if( !empty( $this->status )) $output['STATUS'] = 1; |
|
5643 | - if( !empty( $this->transp )) $output['TRANSP'] = 1; |
|
5644 | - if( !empty( $this->trigger )) $output['TRIGGER'] = 1; |
|
5645 | - if( !empty( $this->tzid )) $output['TZID'] = 1; |
|
5646 | - if( !empty( $this->tzname )) $output['TZNAME'] = count( $this->tzname ); |
|
5647 | - if( !empty( $this->tzoffsetfrom )) $output['TZOFFSETTFROM'] = 1; |
|
5648 | - if( !empty( $this->tzoffsetto )) $output['TZOFFSETTO'] = 1; |
|
5649 | - if( !empty( $this->tzurl )) $output['TZURL'] = 1; |
|
5650 | - if( !empty( $this->url )) $output['URL'] = 1; |
|
5651 | - if( !empty( $this->xprop )) $output['X-PROP'] = count( $this->xprop ); |
|
6291 | + if( !empty( $this->dtstamp )) { |
|
6292 | + $output['DTSTAMP'] = 1; |
|
6293 | + } |
|
6294 | + if( !empty( $this->summary )) { |
|
6295 | + $output['SUMMARY'] = 1; |
|
6296 | + } |
|
6297 | + if( !empty( $this->description )) { |
|
6298 | + $output['DESCRIPTION'] = count( $this->description ); |
|
6299 | + } |
|
6300 | + if( !empty( $this->dtstart )) { |
|
6301 | + $output['DTSTART'] = 1; |
|
6302 | + } |
|
6303 | + if( !empty( $this->dtend )) { |
|
6304 | + $output['DTEND'] = 1; |
|
6305 | + } |
|
6306 | + if( !empty( $this->due )) { |
|
6307 | + $output['DUE'] = 1; |
|
6308 | + } |
|
6309 | + if( !empty( $this->duration )) { |
|
6310 | + $output['DURATION'] = 1; |
|
6311 | + } |
|
6312 | + if( !empty( $this->rrule )) { |
|
6313 | + $output['RRULE'] = count( $this->rrule ); |
|
6314 | + } |
|
6315 | + if( !empty( $this->rdate )) { |
|
6316 | + $output['RDATE'] = count( $this->rdate ); |
|
6317 | + } |
|
6318 | + if( !empty( $this->exdate )) { |
|
6319 | + $output['EXDATE'] = count( $this->exdate ); |
|
6320 | + } |
|
6321 | + if( !empty( $this->exrule )) { |
|
6322 | + $output['EXRULE'] = count( $this->exrule ); |
|
6323 | + } |
|
6324 | + if( !empty( $this->action )) { |
|
6325 | + $output['ACTION'] = 1; |
|
6326 | + } |
|
6327 | + if( !empty( $this->attach )) { |
|
6328 | + $output['ATTACH'] = count( $this->attach ); |
|
6329 | + } |
|
6330 | + if( !empty( $this->attendee )) { |
|
6331 | + $output['ATTENDEE'] = count( $this->attendee ); |
|
6332 | + } |
|
6333 | + if( !empty( $this->categories )) { |
|
6334 | + $output['CATEGORIES'] = count( $this->categories ); |
|
6335 | + } |
|
6336 | + if( !empty( $this->class )) { |
|
6337 | + $output['CLASS'] = 1; |
|
6338 | + } |
|
6339 | + if( !empty( $this->comment )) { |
|
6340 | + $output['COMMENT'] = count( $this->comment ); |
|
6341 | + } |
|
6342 | + if( !empty( $this->completed )) { |
|
6343 | + $output['COMPLETED'] = 1; |
|
6344 | + } |
|
6345 | + if( !empty( $this->contact )) { |
|
6346 | + $output['CONTACT'] = count( $this->contact ); |
|
6347 | + } |
|
6348 | + if( !empty( $this->created )) { |
|
6349 | + $output['CREATED'] = 1; |
|
6350 | + } |
|
6351 | + if( !empty( $this->freebusy )) { |
|
6352 | + $output['FREEBUSY'] = count( $this->freebusy ); |
|
6353 | + } |
|
6354 | + if( !empty( $this->geo )) { |
|
6355 | + $output['GEO'] = 1; |
|
6356 | + } |
|
6357 | + if( !empty( $this->lastmodified )) { |
|
6358 | + $output['LAST-MODIFIED'] = 1; |
|
6359 | + } |
|
6360 | + if( !empty( $this->location )) { |
|
6361 | + $output['LOCATION'] = 1; |
|
6362 | + } |
|
6363 | + if( !empty( $this->organizer )) { |
|
6364 | + $output['ORGANIZER'] = 1; |
|
6365 | + } |
|
6366 | + if( !empty( $this->percentcomplete )) { |
|
6367 | + $output['PERCENT-COMPLETE'] = 1; |
|
6368 | + } |
|
6369 | + if( !empty( $this->priority )) { |
|
6370 | + $output['PRIORITY'] = 1; |
|
6371 | + } |
|
6372 | + if( !empty( $this->recurrenceid )) { |
|
6373 | + $output['RECURRENCE-ID'] = 1; |
|
6374 | + } |
|
6375 | + if( !empty( $this->relatedto )) { |
|
6376 | + $output['RELATED-TO'] = count( $this->relatedto ); |
|
6377 | + } |
|
6378 | + if( !empty( $this->repeat )) { |
|
6379 | + $output['REPEAT'] = 1; |
|
6380 | + } |
|
6381 | + if( !empty( $this->requeststatus )) { |
|
6382 | + $output['REQUEST-STATUS'] = count( $this->requeststatus ); |
|
6383 | + } |
|
6384 | + if( !empty( $this->resources )) { |
|
6385 | + $output['RESOURCES'] = count( $this->resources ); |
|
6386 | + } |
|
6387 | + if( !empty( $this->sequence )) { |
|
6388 | + $output['SEQUENCE'] = 1; |
|
6389 | + } |
|
6390 | + if( !empty( $this->status )) { |
|
6391 | + $output['STATUS'] = 1; |
|
6392 | + } |
|
6393 | + if( !empty( $this->transp )) { |
|
6394 | + $output['TRANSP'] = 1; |
|
6395 | + } |
|
6396 | + if( !empty( $this->trigger )) { |
|
6397 | + $output['TRIGGER'] = 1; |
|
6398 | + } |
|
6399 | + if( !empty( $this->tzid )) { |
|
6400 | + $output['TZID'] = 1; |
|
6401 | + } |
|
6402 | + if( !empty( $this->tzname )) { |
|
6403 | + $output['TZNAME'] = count( $this->tzname ); |
|
6404 | + } |
|
6405 | + if( !empty( $this->tzoffsetfrom )) { |
|
6406 | + $output['TZOFFSETTFROM'] = 1; |
|
6407 | + } |
|
6408 | + if( !empty( $this->tzoffsetto )) { |
|
6409 | + $output['TZOFFSETTO'] = 1; |
|
6410 | + } |
|
6411 | + if( !empty( $this->tzurl )) { |
|
6412 | + $output['TZURL'] = 1; |
|
6413 | + } |
|
6414 | + if( !empty( $this->url )) { |
|
6415 | + $output['URL'] = 1; |
|
6416 | + } |
|
6417 | + if( !empty( $this->xprop )) { |
|
6418 | + $output['X-PROP'] = count( $this->xprop ); |
|
6419 | + } |
|
5652 | 6420 | return $output; |
5653 | 6421 | break; |
5654 | 6422 | case 'UNIQUE_ID': |
5655 | - if( empty( $this->unique_id )) |
|
5656 | - $this->unique_id = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost'; |
|
6423 | + if( empty( $this->unique_id )) { |
|
6424 | + $this->unique_id = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost'; |
|
6425 | + } |
|
5657 | 6426 | return $this->unique_id; |
5658 | 6427 | break; |
5659 | 6428 | } |
@@ -5702,13 +6471,16 @@ discard block |
||
5702 | 6471 | $res = TRUE; |
5703 | 6472 | break; |
5704 | 6473 | } |
5705 | - if( !$res ) return FALSE; |
|
6474 | + if( !$res ) { |
|
6475 | + return FALSE; |
|
6476 | + } |
|
5706 | 6477 | if( isset( $subcfg ) && !empty( $this->components )) { |
5707 | 6478 | foreach( $subcfg as $cfgkey => $cfgvalue ) { |
5708 | 6479 | foreach( $this->components as $cix => $component ) { |
5709 | 6480 | $res = $component->setConfig( $cfgkey, $cfgvalue ); |
5710 | - if( !$res ) |
|
5711 | - break 2; |
|
6481 | + if( !$res ) { |
|
6482 | + break 2; |
|
6483 | + } |
|
5712 | 6484 | $this->components[$cix] = $component; // PHP4 compliant |
5713 | 6485 | } |
5714 | 6486 | } |
@@ -5726,12 +6498,15 @@ discard block |
||
5726 | 6498 | * @return bool if successfull delete TRUE |
5727 | 6499 | */ |
5728 | 6500 | function deleteProperty( $propName, $propix=FALSE ) { |
5729 | - if( $this->_notExistProp( $propName )) return FALSE; |
|
6501 | + if( $this->_notExistProp( $propName )) { |
|
6502 | + return FALSE; |
|
6503 | + } |
|
5730 | 6504 | $propName = strtoupper( $propName ); |
5731 | 6505 | if( in_array( $propName, array( 'ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
5732 | 6506 | 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP' ))) { |
5733 | - if( !$propix ) |
|
5734 | - $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1; |
|
6507 | + if( !$propix ) { |
|
6508 | + $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1; |
|
6509 | + } |
|
5735 | 6510 | $this->propdelix[$propName] = --$propix; |
5736 | 6511 | } |
5737 | 6512 | $return = FALSE; |
@@ -5785,8 +6560,9 @@ discard block |
||
5785 | 6560 | } |
5786 | 6561 | break; |
5787 | 6562 | case 'DTSTAMP': |
5788 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
5789 | - return FALSE; |
|
6563 | + if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
6564 | + return FALSE; |
|
6565 | + } |
|
5790 | 6566 | if( !empty( $this->dtstamp )) { |
5791 | 6567 | $this->dtstamp = ''; |
5792 | 6568 | $return = TRUE; |
@@ -5940,8 +6716,9 @@ discard block |
||
5940 | 6716 | } |
5941 | 6717 | break; |
5942 | 6718 | case 'UID': |
5943 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
5944 | - return FALSE; |
|
6719 | + if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
6720 | + return FALSE; |
|
6721 | + } |
|
5945 | 6722 | if( !empty( $this->uid )) { |
5946 | 6723 | $this->uid = ''; |
5947 | 6724 | $return = TRUE; |
@@ -5956,18 +6733,23 @@ discard block |
||
5956 | 6733 | default: |
5957 | 6734 | $reduced = ''; |
5958 | 6735 | if( $propName != 'X-PROP' ) { |
5959 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
6736 | + if( !isset( $this->xprop[$propName] )) { |
|
6737 | + return FALSE; |
|
6738 | + } |
|
5960 | 6739 | foreach( $this->xprop as $k => $a ) { |
5961 | - if(( $k != $propName ) && !empty( $a )) |
|
5962 | - $reduced[$k] = $a; |
|
6740 | + if(( $k != $propName ) && !empty( $a )) { |
|
6741 | + $reduced[$k] = $a; |
|
6742 | + } |
|
6743 | + } |
|
6744 | + } else { |
|
6745 | + if( count( $this->xprop ) <= $propix ) { |
|
6746 | + return FALSE; |
|
5963 | 6747 | } |
5964 | - } |
|
5965 | - else { |
|
5966 | - if( count( $this->xprop ) <= $propix ) return FALSE; |
|
5967 | 6748 | $xpropno = 0; |
5968 | 6749 | foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
5969 | - if( $propix != $xpropno ) |
|
5970 | - $reduced[$xpropkey] = $xpropvalue; |
|
6750 | + if( $propix != $xpropno ) { |
|
6751 | + $reduced[$xpropkey] = $xpropvalue; |
|
6752 | + } |
|
5971 | 6753 | $xpropno++; |
5972 | 6754 | } |
5973 | 6755 | } |
@@ -5987,9 +6769,13 @@ discard block |
||
5987 | 6769 | * @return bool TRUE |
5988 | 6770 | */ |
5989 | 6771 | function deletePropertyM( & $multiprop, $propix=0 ) { |
5990 | - if( !isset( $multiprop[$propix])) return FALSE; |
|
6772 | + if( !isset( $multiprop[$propix])) { |
|
6773 | + return FALSE; |
|
6774 | + } |
|
5991 | 6775 | unset( $multiprop[$propix] ); |
5992 | - if( empty( $multiprop )) $multiprop = ''; |
|
6776 | + if( empty( $multiprop )) { |
|
6777 | + $multiprop = ''; |
|
6778 | + } |
|
5993 | 6779 | return ( isset( $this->multiprop[$propix] )) ? FALSE : TRUE; |
5994 | 6780 | } |
5995 | 6781 | /** |
@@ -6006,184 +6792,277 @@ discard block |
||
6006 | 6792 | * @return mixed |
6007 | 6793 | */ |
6008 | 6794 | function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE, $specform=FALSE ) { |
6009 | - if( $this->_notExistProp( $propName )) return FALSE; |
|
6795 | + if( $this->_notExistProp( $propName )) { |
|
6796 | + return FALSE; |
|
6797 | + } |
|
6010 | 6798 | $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP'; |
6011 | 6799 | if( in_array( $propName, array( 'ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
6012 | 6800 | 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP' ))) { |
6013 | - if( !$propix ) |
|
6014 | - $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; |
|
6801 | + if( !$propix ) { |
|
6802 | + $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; |
|
6803 | + } |
|
6015 | 6804 | $this->propix[$propName] = --$propix; |
6016 | 6805 | } |
6017 | 6806 | switch( $propName ) { |
6018 | 6807 | case 'ACTION': |
6019 | - if( !empty( $this->action['value'] )) return ( $inclParam ) ? $this->action : $this->action['value']; |
|
6808 | + if( !empty( $this->action['value'] )) { |
|
6809 | + return ( $inclParam ) ? $this->action : $this->action['value']; |
|
6810 | + } |
|
6020 | 6811 | break; |
6021 | 6812 | case 'ATTACH': |
6022 | - if( !isset( $this->attach[$propix] )) return FALSE; |
|
6813 | + if( !isset( $this->attach[$propix] )) { |
|
6814 | + return FALSE; |
|
6815 | + } |
|
6023 | 6816 | return ( $inclParam ) ? $this->attach[$propix] : $this->attach[$propix]['value']; |
6024 | 6817 | break; |
6025 | 6818 | case 'ATTENDEE': |
6026 | - if( !isset( $this->attendee[$propix] )) return FALSE; |
|
6819 | + if( !isset( $this->attendee[$propix] )) { |
|
6820 | + return FALSE; |
|
6821 | + } |
|
6027 | 6822 | return ( $inclParam ) ? $this->attendee[$propix] : $this->attendee[$propix]['value']; |
6028 | 6823 | break; |
6029 | 6824 | case 'CATEGORIES': |
6030 | - if( !isset( $this->categories[$propix] )) return FALSE; |
|
6825 | + if( !isset( $this->categories[$propix] )) { |
|
6826 | + return FALSE; |
|
6827 | + } |
|
6031 | 6828 | return ( $inclParam ) ? $this->categories[$propix] : $this->categories[$propix]['value']; |
6032 | 6829 | break; |
6033 | 6830 | case 'CLASS': |
6034 | - if( !empty( $this->class['value'] )) return ( $inclParam ) ? $this->class : $this->class['value']; |
|
6831 | + if( !empty( $this->class['value'] )) { |
|
6832 | + return ( $inclParam ) ? $this->class : $this->class['value']; |
|
6833 | + } |
|
6035 | 6834 | break; |
6036 | 6835 | case 'COMMENT': |
6037 | - if( !isset( $this->comment[$propix] )) return FALSE; |
|
6836 | + if( !isset( $this->comment[$propix] )) { |
|
6837 | + return FALSE; |
|
6838 | + } |
|
6038 | 6839 | return ( $inclParam ) ? $this->comment[$propix] : $this->comment[$propix]['value']; |
6039 | 6840 | break; |
6040 | 6841 | case 'COMPLETED': |
6041 | - if( !empty( $this->completed['value'] )) return ( $inclParam ) ? $this->completed : $this->completed['value']; |
|
6842 | + if( !empty( $this->completed['value'] )) { |
|
6843 | + return ( $inclParam ) ? $this->completed : $this->completed['value']; |
|
6844 | + } |
|
6042 | 6845 | break; |
6043 | 6846 | case 'CONTACT': |
6044 | - if( !isset( $this->contact[$propix] )) return FALSE; |
|
6847 | + if( !isset( $this->contact[$propix] )) { |
|
6848 | + return FALSE; |
|
6849 | + } |
|
6045 | 6850 | return ( $inclParam ) ? $this->contact[$propix] : $this->contact[$propix]['value']; |
6046 | 6851 | break; |
6047 | 6852 | case 'CREATED': |
6048 | - if( !empty( $this->created['value'] )) return ( $inclParam ) ? $this->created : $this->created['value']; |
|
6853 | + if( !empty( $this->created['value'] )) { |
|
6854 | + return ( $inclParam ) ? $this->created : $this->created['value']; |
|
6855 | + } |
|
6049 | 6856 | break; |
6050 | 6857 | case 'DESCRIPTION': |
6051 | - if( !isset( $this->description[$propix] )) return FALSE; |
|
6858 | + if( !isset( $this->description[$propix] )) { |
|
6859 | + return FALSE; |
|
6860 | + } |
|
6052 | 6861 | return ( $inclParam ) ? $this->description[$propix] : $this->description[$propix]['value']; |
6053 | 6862 | break; |
6054 | 6863 | case 'DTEND': |
6055 | - if( !empty( $this->dtend['value'] )) return ( $inclParam ) ? $this->dtend : $this->dtend['value']; |
|
6864 | + if( !empty( $this->dtend['value'] )) { |
|
6865 | + return ( $inclParam ) ? $this->dtend : $this->dtend['value']; |
|
6866 | + } |
|
6056 | 6867 | break; |
6057 | 6868 | case 'DTSTAMP': |
6058 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
6059 | - return; |
|
6060 | - if( !isset( $this->dtstamp['value'] )) |
|
6061 | - $this->_makeDtstamp(); |
|
6869 | + if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
6870 | + return; |
|
6871 | + } |
|
6872 | + if( !isset( $this->dtstamp['value'] )) { |
|
6873 | + $this->_makeDtstamp(); |
|
6874 | + } |
|
6062 | 6875 | return ( $inclParam ) ? $this->dtstamp : $this->dtstamp['value']; |
6063 | 6876 | break; |
6064 | 6877 | case 'DTSTART': |
6065 | - if( !empty( $this->dtstart['value'] )) return ( $inclParam ) ? $this->dtstart : $this->dtstart['value']; |
|
6878 | + if( !empty( $this->dtstart['value'] )) { |
|
6879 | + return ( $inclParam ) ? $this->dtstart : $this->dtstart['value']; |
|
6880 | + } |
|
6066 | 6881 | break; |
6067 | 6882 | case 'DUE': |
6068 | - if( !empty( $this->due['value'] )) return ( $inclParam ) ? $this->due : $this->due['value']; |
|
6883 | + if( !empty( $this->due['value'] )) { |
|
6884 | + return ( $inclParam ) ? $this->due : $this->due['value']; |
|
6885 | + } |
|
6069 | 6886 | break; |
6070 | 6887 | case 'DURATION': |
6071 | - if( !isset( $this->duration['value'] )) return FALSE; |
|
6888 | + if( !isset( $this->duration['value'] )) { |
|
6889 | + return FALSE; |
|
6890 | + } |
|
6072 | 6891 | $value = ( $specform ) ? $this->duration2date() : $this->duration['value']; |
6073 | 6892 | return ( $inclParam ) ? array( 'value' => $value, 'params' => $this->duration['params'] ) : $value; |
6074 | 6893 | break; |
6075 | 6894 | case 'EXDATE': |
6076 | - if( !isset( $this->exdate[$propix] )) return FALSE; |
|
6895 | + if( !isset( $this->exdate[$propix] )) { |
|
6896 | + return FALSE; |
|
6897 | + } |
|
6077 | 6898 | return ( $inclParam ) ? $this->exdate[$propix] : $this->exdate[$propix]['value']; |
6078 | 6899 | break; |
6079 | 6900 | case 'EXRULE': |
6080 | - if( !isset( $this->exrule[$propix] )) return FALSE; |
|
6901 | + if( !isset( $this->exrule[$propix] )) { |
|
6902 | + return FALSE; |
|
6903 | + } |
|
6081 | 6904 | return ( $inclParam ) ? $this->exrule[$propix] : $this->exrule[$propix]['value']; |
6082 | 6905 | break; |
6083 | 6906 | case 'FREEBUSY': |
6084 | - if( !isset( $this->freebusy[$propix] )) return FALSE; |
|
6907 | + if( !isset( $this->freebusy[$propix] )) { |
|
6908 | + return FALSE; |
|
6909 | + } |
|
6085 | 6910 | return ( $inclParam ) ? $this->freebusy[$propix] : $this->freebusy[$propix]['value']; |
6086 | 6911 | break; |
6087 | 6912 | case 'GEO': |
6088 | - if( !empty( $this->geo['value'] )) return ( $inclParam ) ? $this->geo : $this->geo['value']; |
|
6913 | + if( !empty( $this->geo['value'] )) { |
|
6914 | + return ( $inclParam ) ? $this->geo : $this->geo['value']; |
|
6915 | + } |
|
6089 | 6916 | break; |
6090 | 6917 | case 'LAST-MODIFIED': |
6091 | - if( !empty( $this->lastmodified['value'] )) return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value']; |
|
6918 | + if( !empty( $this->lastmodified['value'] )) { |
|
6919 | + return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value']; |
|
6920 | + } |
|
6092 | 6921 | break; |
6093 | 6922 | case 'LOCATION': |
6094 | - if( !empty( $this->location['value'] )) return ( $inclParam ) ? $this->location : $this->location['value']; |
|
6923 | + if( !empty( $this->location['value'] )) { |
|
6924 | + return ( $inclParam ) ? $this->location : $this->location['value']; |
|
6925 | + } |
|
6095 | 6926 | break; |
6096 | 6927 | case 'ORGANIZER': |
6097 | - if( !empty( $this->organizer['value'] )) return ( $inclParam ) ? $this->organizer : $this->organizer['value']; |
|
6928 | + if( !empty( $this->organizer['value'] )) { |
|
6929 | + return ( $inclParam ) ? $this->organizer : $this->organizer['value']; |
|
6930 | + } |
|
6098 | 6931 | break; |
6099 | 6932 | case 'PERCENT-COMPLETE': |
6100 | - if( !empty( $this->percentcomplete['value'] )) return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value']; |
|
6933 | + if( !empty( $this->percentcomplete['value'] )) { |
|
6934 | + return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value']; |
|
6935 | + } |
|
6101 | 6936 | break; |
6102 | 6937 | case 'PRIORITY': |
6103 | - if( !empty( $this->priority['value'] )) return ( $inclParam ) ? $this->priority : $this->priority['value']; |
|
6938 | + if( !empty( $this->priority['value'] )) { |
|
6939 | + return ( $inclParam ) ? $this->priority : $this->priority['value']; |
|
6940 | + } |
|
6104 | 6941 | break; |
6105 | 6942 | case 'RDATE': |
6106 | - if( !isset( $this->rdate[$propix] )) return FALSE; |
|
6943 | + if( !isset( $this->rdate[$propix] )) { |
|
6944 | + return FALSE; |
|
6945 | + } |
|
6107 | 6946 | return ( $inclParam ) ? $this->rdate[$propix] : $this->rdate[$propix]['value']; |
6108 | 6947 | break; |
6109 | 6948 | case 'RECURRENCE-ID': |
6110 | - if( !empty( $this->recurrenceid['value'] )) return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value']; |
|
6949 | + if( !empty( $this->recurrenceid['value'] )) { |
|
6950 | + return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value']; |
|
6951 | + } |
|
6111 | 6952 | break; |
6112 | 6953 | case 'RELATED-TO': |
6113 | - if( !isset( $this->relatedto[$propix] )) return FALSE; |
|
6954 | + if( !isset( $this->relatedto[$propix] )) { |
|
6955 | + return FALSE; |
|
6956 | + } |
|
6114 | 6957 | return ( $inclParam ) ? $this->relatedto[$propix] : $this->relatedto[$propix]['value']; |
6115 | 6958 | break; |
6116 | 6959 | case 'REPEAT': |
6117 | - if( !empty( $this->repeat['value'] )) return ( $inclParam ) ? $this->repeat : $this->repeat['value']; |
|
6960 | + if( !empty( $this->repeat['value'] )) { |
|
6961 | + return ( $inclParam ) ? $this->repeat : $this->repeat['value']; |
|
6962 | + } |
|
6118 | 6963 | break; |
6119 | 6964 | case 'REQUEST-STATUS': |
6120 | - if( !isset( $this->requeststatus[$propix] )) return FALSE; |
|
6965 | + if( !isset( $this->requeststatus[$propix] )) { |
|
6966 | + return FALSE; |
|
6967 | + } |
|
6121 | 6968 | return ( $inclParam ) ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value']; |
6122 | 6969 | break; |
6123 | 6970 | case 'RESOURCES': |
6124 | - if( !isset( $this->resources[$propix] )) return FALSE; |
|
6971 | + if( !isset( $this->resources[$propix] )) { |
|
6972 | + return FALSE; |
|
6973 | + } |
|
6125 | 6974 | return ( $inclParam ) ? $this->resources[$propix] : $this->resources[$propix]['value']; |
6126 | 6975 | break; |
6127 | 6976 | case 'RRULE': |
6128 | - if( !isset( $this->rrule[$propix] )) return FALSE; |
|
6977 | + if( !isset( $this->rrule[$propix] )) { |
|
6978 | + return FALSE; |
|
6979 | + } |
|
6129 | 6980 | return ( $inclParam ) ? $this->rrule[$propix] : $this->rrule[$propix]['value']; |
6130 | 6981 | break; |
6131 | 6982 | case 'SEQUENCE': |
6132 | - if( !empty( $this->sequence['value'] )) return ( $inclParam ) ? $this->sequence : $this->sequence['value']; |
|
6983 | + if( !empty( $this->sequence['value'] )) { |
|
6984 | + return ( $inclParam ) ? $this->sequence : $this->sequence['value']; |
|
6985 | + } |
|
6133 | 6986 | break; |
6134 | 6987 | case 'STATUS': |
6135 | - if( !empty( $this->status['value'] )) return ( $inclParam ) ? $this->status : $this->status['value']; |
|
6988 | + if( !empty( $this->status['value'] )) { |
|
6989 | + return ( $inclParam ) ? $this->status : $this->status['value']; |
|
6990 | + } |
|
6136 | 6991 | break; |
6137 | 6992 | case 'SUMMARY': |
6138 | - if( !empty( $this->summary['value'] )) return ( $inclParam ) ? $this->summary : $this->summary['value']; |
|
6993 | + if( !empty( $this->summary['value'] )) { |
|
6994 | + return ( $inclParam ) ? $this->summary : $this->summary['value']; |
|
6995 | + } |
|
6139 | 6996 | break; |
6140 | 6997 | case 'TRANSP': |
6141 | - if( !empty( $this->transp['value'] )) return ( $inclParam ) ? $this->transp : $this->transp['value']; |
|
6998 | + if( !empty( $this->transp['value'] )) { |
|
6999 | + return ( $inclParam ) ? $this->transp : $this->transp['value']; |
|
7000 | + } |
|
6142 | 7001 | break; |
6143 | 7002 | case 'TRIGGER': |
6144 | - if( !empty( $this->trigger['value'] )) return ( $inclParam ) ? $this->trigger : $this->trigger['value']; |
|
7003 | + if( !empty( $this->trigger['value'] )) { |
|
7004 | + return ( $inclParam ) ? $this->trigger : $this->trigger['value']; |
|
7005 | + } |
|
6145 | 7006 | break; |
6146 | 7007 | case 'TZID': |
6147 | - if( !empty( $this->tzid['value'] )) return ( $inclParam ) ? $this->tzid : $this->tzid['value']; |
|
7008 | + if( !empty( $this->tzid['value'] )) { |
|
7009 | + return ( $inclParam ) ? $this->tzid : $this->tzid['value']; |
|
7010 | + } |
|
6148 | 7011 | break; |
6149 | 7012 | case 'TZNAME': |
6150 | - if( !isset( $this->tzname[$propix] )) return FALSE; |
|
7013 | + if( !isset( $this->tzname[$propix] )) { |
|
7014 | + return FALSE; |
|
7015 | + } |
|
6151 | 7016 | return ( $inclParam ) ? $this->tzname[$propix] : $this->tzname[$propix]['value']; |
6152 | 7017 | break; |
6153 | 7018 | case 'TZOFFSETFROM': |
6154 | - if( !empty( $this->tzoffsetfrom['value'] )) return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value']; |
|
7019 | + if( !empty( $this->tzoffsetfrom['value'] )) { |
|
7020 | + return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value']; |
|
7021 | + } |
|
6155 | 7022 | break; |
6156 | 7023 | case 'TZOFFSETTO': |
6157 | - if( !empty( $this->tzoffsetto['value'] )) return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value']; |
|
7024 | + if( !empty( $this->tzoffsetto['value'] )) { |
|
7025 | + return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value']; |
|
7026 | + } |
|
6158 | 7027 | break; |
6159 | 7028 | case 'TZURL': |
6160 | - if( !empty( $this->tzurl['value'] )) return ( $inclParam ) ? $this->tzurl : $this->tzurl['value']; |
|
7029 | + if( !empty( $this->tzurl['value'] )) { |
|
7030 | + return ( $inclParam ) ? $this->tzurl : $this->tzurl['value']; |
|
7031 | + } |
|
6161 | 7032 | break; |
6162 | 7033 | case 'UID': |
6163 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
6164 | - return FALSE; |
|
6165 | - if( empty( $this->uid['value'] )) |
|
6166 | - $this->_makeuid(); |
|
7034 | + if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
7035 | + return FALSE; |
|
7036 | + } |
|
7037 | + if( empty( $this->uid['value'] )) { |
|
7038 | + $this->_makeuid(); |
|
7039 | + } |
|
6167 | 7040 | return ( $inclParam ) ? $this->uid : $this->uid['value']; |
6168 | 7041 | break; |
6169 | 7042 | case 'URL': |
6170 | - if( !empty( $this->url['value'] )) return ( $inclParam ) ? $this->url : $this->url['value']; |
|
7043 | + if( !empty( $this->url['value'] )) { |
|
7044 | + return ( $inclParam ) ? $this->url : $this->url['value']; |
|
7045 | + } |
|
6171 | 7046 | break; |
6172 | 7047 | default: |
6173 | 7048 | if( $propName != 'X-PROP' ) { |
6174 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
7049 | + if( !isset( $this->xprop[$propName] )) { |
|
7050 | + return FALSE; |
|
7051 | + } |
|
6175 | 7052 | return ( $inclParam ) ? array( $propName, $this->xprop[$propName] ) |
6176 | 7053 | : array( $propName, $this->xprop[$propName]['value'] ); |
6177 | - } |
|
6178 | - else { |
|
6179 | - if( empty( $this->xprop )) return FALSE; |
|
7054 | + } else { |
|
7055 | + if( empty( $this->xprop )) { |
|
7056 | + return FALSE; |
|
7057 | + } |
|
6180 | 7058 | $xpropno = 0; |
6181 | 7059 | foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
6182 | - if( $propix == $xpropno ) |
|
6183 | - return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) |
|
7060 | + if( $propix == $xpropno ) { |
|
7061 | + return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) |
|
6184 | 7062 | : array( $xpropkey, $this->xprop[$xpropkey]['value'] ); |
6185 | - else |
|
6186 | - $xpropno++; |
|
7063 | + } else { |
|
7064 | + $xpropno++; |
|
7065 | + } |
|
6187 | 7066 | } |
6188 | 7067 | return FALSE; // not found ?? |
6189 | 7068 | } |
@@ -6202,15 +7081,21 @@ discard block |
||
6202 | 7081 | */ |
6203 | 7082 | function setProperty() { |
6204 | 7083 | $numargs = func_num_args(); |
6205 | - if( 1 > $numargs ) return FALSE; |
|
7084 | + if( 1 > $numargs ) { |
|
7085 | + return FALSE; |
|
7086 | + } |
|
6206 | 7087 | $arglist = func_get_args(); |
6207 | - if( $this->_notExistProp( $arglist[0] )) return FALSE; |
|
6208 | - if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] ))) |
|
7088 | + if( $this->_notExistProp( $arglist[0] )) { |
|
6209 | 7089 | return FALSE; |
7090 | + } |
|
7091 | + if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] ))) { |
|
7092 | + return FALSE; |
|
7093 | + } |
|
6210 | 7094 | $arglist[0] = strtoupper( $arglist[0] ); |
6211 | 7095 | for( $argix=$numargs; $argix < 12; $argix++ ) { |
6212 | - if( !isset( $arglist[$argix] )) |
|
6213 | - $arglist[$argix] = null; |
|
7096 | + if( !isset( $arglist[$argix] )) { |
|
7097 | + $arglist[$argix] = null; |
|
7098 | + } |
|
6214 | 7099 | } |
6215 | 7100 | switch( $arglist[0] ) { |
6216 | 7101 | case 'ACTION': |
@@ -6324,20 +7209,19 @@ discard block |
||
6324 | 7209 | $this->setComponent( $comp ); |
6325 | 7210 | $comp = & $this; |
6326 | 7211 | continue; |
6327 | - } |
|
6328 | - elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) { |
|
7212 | + } elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) { |
|
6329 | 7213 | $comp = new valarm(); |
6330 | 7214 | continue; |
7215 | + } else { |
|
7216 | + $comp->unparsed[] = $line; |
|
6331 | 7217 | } |
6332 | - else |
|
6333 | - $comp->unparsed[] = $line; |
|
6334 | 7218 | } |
7219 | + } else { |
|
7220 | + $this->unparsed = array( trim( $unparsedtext )); |
|
6335 | 7221 | } |
6336 | - else |
|
6337 | - $this->unparsed = array( trim( $unparsedtext )); |
|
7222 | + } elseif( !isset( $this->unparsed )) { |
|
7223 | + $this->unparsed = array(); |
|
6338 | 7224 | } |
6339 | - elseif( !isset( $this->unparsed )) |
|
6340 | - $this->unparsed = array(); |
|
6341 | 7225 | /* concatenate property values spread over several lines */ |
6342 | 7226 | $lastix = -1; |
6343 | 7227 | $propnames = array( 'action', 'attach', 'attendee', 'categories', 'comment', 'completed' |
@@ -6361,8 +7245,7 @@ discard block |
||
6361 | 7245 | $newProp = FALSE; |
6362 | 7246 | $lastix++; |
6363 | 7247 | $proprows[$lastix] = $line; |
6364 | - } |
|
6365 | - else { |
|
7248 | + } else { |
|
6366 | 7249 | /* remove line breaks */ |
6367 | 7250 | if(( '\n' == substr( $proprows[$lastix], -2 )) && |
6368 | 7251 | ( ' ' == substr( $line, 0, 1 ))) { |
@@ -6375,14 +7258,15 @@ discard block |
||
6375 | 7258 | /* parse each property 'line' */ |
6376 | 7259 | foreach( $proprows as $line ) { |
6377 | 7260 | $line = str_replace( "\n ", '', $line ); |
6378 | - if( '\n' == substr( $line, -2 )) |
|
6379 | - $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
7261 | + if( '\n' == substr( $line, -2 )) { |
|
7262 | + $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
7263 | + } |
|
6380 | 7264 | /* get propname, (problem with x-properties, otherwise in previous loop) */ |
6381 | 7265 | $cix = $propname = null; |
6382 | 7266 | for( $cix=0; $cix < strlen( $line ); $cix++ ) { |
6383 | - if( in_array( $line{$cix}, array( ':', ';' ))) |
|
6384 | - break; |
|
6385 | - else { |
|
7267 | + if( in_array( $line{$cix}, array( ':', ';' ))) { |
|
7268 | + break; |
|
7269 | + } else { |
|
6386 | 7270 | $propname .= $line{$cix}; |
6387 | 7271 | } |
6388 | 7272 | } |
@@ -6415,27 +7299,30 @@ discard block |
||
6415 | 7299 | break; |
6416 | 7300 | } |
6417 | 7301 | } |
6418 | - if( ';' == $line{$cix} ) |
|
6419 | - $attr[++$attrix] = null; |
|
6420 | - else |
|
6421 | - $attr[$attrix] .= $line{$cix}; |
|
7302 | + if( ';' == $line{$cix} ) { |
|
7303 | + $attr[++$attrix] = null; |
|
7304 | + } else { |
|
7305 | + $attr[$attrix] .= $line{$cix}; |
|
7306 | + } |
|
6422 | 7307 | } |
6423 | 7308 | /* make attributes in array format */ |
6424 | 7309 | $propattr = array(); |
6425 | 7310 | foreach( $attr as $attribute ) { |
6426 | 7311 | $attrsplit = explode( '=', $attribute, 2 ); |
6427 | - if( 1 < count( $attrsplit )) |
|
6428 | - $propattr[$attrsplit[0]] = $attrsplit[1]; |
|
6429 | - else |
|
6430 | - $propattr[] = $attribute; |
|
7312 | + if( 1 < count( $attrsplit )) { |
|
7313 | + $propattr[$attrsplit[0]] = $attrsplit[1]; |
|
7314 | + } else { |
|
7315 | + $propattr[] = $attribute; |
|
7316 | + } |
|
6431 | 7317 | } |
6432 | 7318 | /* call setProperty( $propname.. . */ |
6433 | 7319 | switch( $propname ) { |
6434 | 7320 | case 'ATTENDEE': |
6435 | 7321 | foreach( $propattr as $pix => $attr ) { |
6436 | 7322 | $attr2 = explode( ',', $attr ); |
6437 | - if( 1 < count( $attr2 )) |
|
6438 | - $propattr[$pix] = $attr2; |
|
7323 | + if( 1 < count( $attr2 )) { |
|
7324 | + $propattr[$pix] = $attr2; |
|
7325 | + } |
|
6439 | 7326 | } |
6440 | 7327 | $this->setProperty( $propname, $line, $propattr ); |
6441 | 7328 | break; |
@@ -6453,13 +7340,14 @@ discard block |
||
6453 | 7340 | } |
6454 | 7341 | if( 1 < count( $content )) { |
6455 | 7342 | $content = array_values( $content ); |
6456 | - foreach( $content as $cix => $contentPart ) |
|
6457 | - $content[$cix] = $this->_strunrep( $contentPart ); |
|
7343 | + foreach( $content as $cix => $contentPart ) { |
|
7344 | + $content[$cix] = $this->_strunrep( $contentPart ); |
|
7345 | + } |
|
6458 | 7346 | $this->setProperty( $propname, $content, $propattr ); |
6459 | 7347 | break; |
7348 | + } else { |
|
7349 | + $line = reset( $content ); |
|
6460 | 7350 | } |
6461 | - else |
|
6462 | - $line = reset( $content ); |
|
6463 | 7351 | } |
6464 | 7352 | //no break |
6465 | 7353 | case 'X-': |
@@ -6470,8 +7358,9 @@ discard block |
||
6470 | 7358 | case 'DESCRIPTION': |
6471 | 7359 | case 'LOCATION': |
6472 | 7360 | case 'SUMMARY': |
6473 | - if( empty( $line )) |
|
6474 | - $propattr = null; |
|
7361 | + if( empty( $line )) { |
|
7362 | + $propattr = null; |
|
7363 | + } |
|
6475 | 7364 | $this->setProperty( $propname, $this->_strunrep( $line ), $propattr ); |
6476 | 7365 | unset( $propname2 ); |
6477 | 7366 | break; |
@@ -6491,15 +7380,17 @@ discard block |
||
6491 | 7380 | $values = explode( ',', $line ); |
6492 | 7381 | foreach( $values as $vix => $value ) { |
6493 | 7382 | $value2 = explode( '/', $value ); |
6494 | - if( 1 < count( $value2 )) |
|
6495 | - $values[$vix] = $value2; |
|
7383 | + if( 1 < count( $value2 )) { |
|
7384 | + $values[$vix] = $value2; |
|
7385 | + } |
|
6496 | 7386 | } |
6497 | 7387 | $this->setProperty( $propname, $fbtype, $values, $propattr ); |
6498 | 7388 | break; |
6499 | 7389 | case 'GEO': |
6500 | 7390 | $value = explode( ';', $line, 2 ); |
6501 | - if( 2 > count( $value )) |
|
6502 | - $value[1] = null; |
|
7391 | + if( 2 > count( $value )) { |
|
7392 | + $value[1] = null; |
|
7393 | + } |
|
6503 | 7394 | $this->setProperty( $propname, $value[0], $value[1], $propattr ); |
6504 | 7395 | break; |
6505 | 7396 | case 'EXDATE': |
@@ -6514,8 +7405,9 @@ discard block |
||
6514 | 7405 | $values = explode( ',', $line ); |
6515 | 7406 | foreach( $values as $vix => $value ) { |
6516 | 7407 | $value2 = explode( '/', $value ); |
6517 | - if( 1 < count( $value2 )) |
|
6518 | - $values[$vix] = $value2; |
|
7408 | + if( 1 < count( $value2 )) { |
|
7409 | + $values[$vix] = $value2; |
|
7410 | + } |
|
6519 | 7411 | } |
6520 | 7412 | $this->setProperty( $propname, $values, $propattr ); |
6521 | 7413 | break; |
@@ -6524,8 +7416,10 @@ discard block |
||
6524 | 7416 | $values = explode( ';', $line ); |
6525 | 7417 | $recur = array(); |
6526 | 7418 | foreach( $values as $value2 ) { |
6527 | - if( empty( $value2 )) |
|
6528 | - continue; // ;-char in ending position ??? |
|
7419 | + if( empty( $value2 )) { |
|
7420 | + continue; |
|
7421 | + } |
|
7422 | + // ;-char in ending position ??? |
|
6529 | 7423 | $value3 = explode( '=', $value2, 2 ); |
6530 | 7424 | $rulelabel = strtoupper( $value3[0] ); |
6531 | 7425 | switch( $rulelabel ) { |
@@ -6539,37 +7433,43 @@ discard block |
||
6539 | 7433 | if(( ctype_alpha( substr( $value5, -1 ))) && |
6540 | 7434 | ( ctype_alpha( substr( $value5, -2, 1 )))) { |
6541 | 7435 | $dayname = substr( $value5, -2, 2 ); |
6542 | - if( 2 < strlen( $value5 )) |
|
6543 | - $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
7436 | + if( 2 < strlen( $value5 )) { |
|
7437 | + $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
7438 | + } |
|
7439 | + } |
|
7440 | + if( $dayno ) { |
|
7441 | + $value6[] = $dayno; |
|
7442 | + } |
|
7443 | + if( $dayname ) { |
|
7444 | + $value6['DAY'] = $dayname; |
|
6544 | 7445 | } |
6545 | - if( $dayno ) |
|
6546 | - $value6[] = $dayno; |
|
6547 | - if( $dayname ) |
|
6548 | - $value6['DAY'] = $dayname; |
|
6549 | 7446 | $value4[$v5ix] = $value6; |
6550 | 7447 | } |
6551 | - } |
|
6552 | - else { |
|
7448 | + } else { |
|
6553 | 7449 | $value4 = array(); |
6554 | 7450 | $dayno = $dayname = null; |
6555 | 7451 | $value5 = trim( (string) $value3[1] ); |
6556 | 7452 | if(( ctype_alpha( substr( $value5, -1 ))) && |
6557 | 7453 | ( ctype_alpha( substr( $value5, -2, 1 )))) { |
6558 | 7454 | $dayname = substr( $value5, -2, 2 ); |
6559 | - if( 2 < strlen( $value5 )) |
|
6560 | - $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
7455 | + if( 2 < strlen( $value5 )) { |
|
7456 | + $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
7457 | + } |
|
7458 | + } |
|
7459 | + if( $dayno ) { |
|
7460 | + $value4[] = $dayno; |
|
7461 | + } |
|
7462 | + if( $dayname ) { |
|
7463 | + $value4['DAY'] = $dayname; |
|
6561 | 7464 | } |
6562 | - if( $dayno ) |
|
6563 | - $value4[] = $dayno; |
|
6564 | - if( $dayname ) |
|
6565 | - $value4['DAY'] = $dayname; |
|
6566 | 7465 | } |
6567 | 7466 | $recur[$rulelabel] = $value4; |
6568 | 7467 | break; |
6569 | 7468 | default: |
6570 | 7469 | $value4 = explode( ',', $value3[1] ); |
6571 | - if( 1 < count( $value4 )) |
|
6572 | - $value3[1] = $value4; |
|
7470 | + if( 1 < count( $value4 )) { |
|
7471 | + $value3[1] = $value4; |
|
7472 | + } |
|
6573 | 7473 | $recur[$rulelabel] = $value3[1]; |
6574 | 7474 | break; |
6575 | 7475 | } // end - switch $rulelabel |
@@ -6584,8 +7484,9 @@ discard block |
||
6584 | 7484 | unset( $this->unparsed, $proprows ); |
6585 | 7485 | if( isset( $this->components ) && is_array( $this->components ) && ( 0 < count( $this->components ))) { |
6586 | 7486 | for( $six = 0; $six < count( $this->components ); $six++ ) { |
6587 | - if( !empty( $this->components[$six]->unparsed )) |
|
6588 | - $this->components[$six]->parse(); |
|
7487 | + if( !empty( $this->components[$six]->unparsed )) { |
|
7488 | + $this->components[$six]->parse(); |
|
7489 | + } |
|
6589 | 7490 | } |
6590 | 7491 | } |
6591 | 7492 | } |
@@ -6616,32 +7517,33 @@ discard block |
||
6616 | 7517 | * @return void |
6617 | 7518 | */ |
6618 | 7519 | function deleteComponent( $arg1, $arg2=FALSE ) { |
6619 | - if( !isset( $this->components )) return FALSE; |
|
7520 | + if( !isset( $this->components )) { |
|
7521 | + return FALSE; |
|
7522 | + } |
|
6620 | 7523 | $argType = $index = null; |
6621 | 7524 | if ( ctype_digit( (string) $arg1 )) { |
6622 | 7525 | $argType = 'INDEX'; |
6623 | 7526 | $index = (int) $arg1 - 1; |
6624 | - } |
|
6625 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
7527 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6626 | 7528 | $argType = strtolower( $arg1 ); |
6627 | 7529 | $index = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0; |
6628 | 7530 | } |
6629 | 7531 | $cix2dC = 0; |
6630 | 7532 | foreach ( $this->components as $cix => $component) { |
6631 | - if( empty( $component )) continue; |
|
7533 | + if( empty( $component )) { |
|
7534 | + continue; |
|
7535 | + } |
|
6632 | 7536 | unset( $component->propix ); |
6633 | 7537 | if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
6634 | 7538 | unset( $this->components[$cix] ); |
6635 | 7539 | return TRUE; |
6636 | - } |
|
6637 | - elseif( $argType == $component->objName ) { |
|
7540 | + } elseif( $argType == $component->objName ) { |
|
6638 | 7541 | if( $index == $cix2dC ) { |
6639 | 7542 | unset( $this->components[$cix] ); |
6640 | 7543 | return TRUE; |
6641 | 7544 | } |
6642 | 7545 | $cix2dC++; |
6643 | - } |
|
6644 | - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
7546 | + } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
6645 | 7547 | unset( $this->components[$cix] ); |
6646 | 7548 | return TRUE; |
6647 | 7549 | } |
@@ -6658,43 +7560,47 @@ discard block |
||
6658 | 7560 | * @return object |
6659 | 7561 | */ |
6660 | 7562 | function getComponent ( $arg1=FALSE, $arg2=FALSE ) { |
6661 | - if( !isset( $this->components )) return FALSE; |
|
7563 | + if( !isset( $this->components )) { |
|
7564 | + return FALSE; |
|
7565 | + } |
|
6662 | 7566 | $index = $argType = null; |
6663 | 7567 | if ( !$arg1 ) { |
6664 | 7568 | $argType = 'INDEX'; |
6665 | 7569 | $index = $this->compix['INDEX'] = |
6666 | 7570 | ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1; |
6667 | - } |
|
6668 | - elseif ( ctype_digit( (string) $arg1 )) { |
|
7571 | + } elseif ( ctype_digit( (string) $arg1 )) { |
|
6669 | 7572 | $argType = 'INDEX'; |
6670 | 7573 | $index = (int) $arg1; |
6671 | 7574 | unset( $this->compix ); |
6672 | - } |
|
6673 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
7575 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6674 | 7576 | unset( $this->compix['INDEX'] ); |
6675 | 7577 | $argType = strtolower( $arg1 ); |
6676 | - if( !$arg2 ) |
|
6677 | - $index = $this->compix[$argType] = |
|
7578 | + if( !$arg2 ) { |
|
7579 | + $index = $this->compix[$argType] = |
|
6678 | 7580 | ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1; |
6679 | - else |
|
6680 | - $index = (int) $arg2; |
|
7581 | + } else { |
|
7582 | + $index = (int) $arg2; |
|
7583 | + } |
|
6681 | 7584 | } |
6682 | 7585 | $index -= 1; |
6683 | 7586 | $ckeys = array_keys( $this->components ); |
6684 | - if( !empty( $index) && ( $index > end( $ckeys ))) |
|
6685 | - return FALSE; |
|
7587 | + if( !empty( $index) && ( $index > end( $ckeys ))) { |
|
7588 | + return FALSE; |
|
7589 | + } |
|
6686 | 7590 | $cix2gC = 0; |
6687 | 7591 | foreach( $this->components as $cix => $component ) { |
6688 | - if( empty( $component )) continue; |
|
7592 | + if( empty( $component )) { |
|
7593 | + continue; |
|
7594 | + } |
|
6689 | 7595 | unset( $component->propix ); |
6690 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) |
|
6691 | - return $component->copy(); |
|
6692 | - elseif( $argType == $component->objName ) { |
|
6693 | - if( $index == $cix2gC ) |
|
6694 | - return $component->copy(); |
|
7596 | + if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
|
7597 | + return $component->copy(); |
|
7598 | + } elseif( $argType == $component->objName ) { |
|
7599 | + if( $index == $cix2gC ) { |
|
7600 | + return $component->copy(); |
|
7601 | + } |
|
6695 | 7602 | $cix2gC++; |
6696 | - } |
|
6697 | - elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) { |
|
7603 | + } elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) { |
|
6698 | 7604 | unset( $component->propix ); |
6699 | 7605 | return $component->copy(); |
6700 | 7606 | } |
@@ -6725,9 +7631,12 @@ discard block |
||
6725 | 7631 | * @return bool |
6726 | 7632 | */ |
6727 | 7633 | function setComponent( $component, $arg1=FALSE, $arg2=FALSE ) { |
6728 | - if( !isset( $this->components )) return FALSE; |
|
6729 | - if( '' >= $component->getConfig( 'language')) |
|
6730 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
7634 | + if( !isset( $this->components )) { |
|
7635 | + return FALSE; |
|
7636 | + } |
|
7637 | + if( '' >= $component->getConfig( 'language')) { |
|
7638 | + $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
7639 | + } |
|
6731 | 7640 | $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
6732 | 7641 | $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
6733 | 7642 | $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
@@ -6746,27 +7655,26 @@ discard block |
||
6746 | 7655 | if ( ctype_digit( (string) $arg1 )) { |
6747 | 7656 | $argType = 'INDEX'; |
6748 | 7657 | $index = (int) $arg1 - 1; |
6749 | - } |
|
6750 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
7658 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6751 | 7659 | $argType = strtolower( $arg1 ); |
6752 | 7660 | $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0; |
6753 | 7661 | } |
6754 | 7662 | $cix2sC = 0; |
6755 | 7663 | foreach ( $this->components as $cix => $component2 ) { |
6756 | - if( empty( $component2 )) continue; |
|
7664 | + if( empty( $component2 )) { |
|
7665 | + continue; |
|
7666 | + } |
|
6757 | 7667 | unset( $component2->propix ); |
6758 | 7668 | if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
6759 | 7669 | $this->components[$cix] = $component->copy(); |
6760 | 7670 | return TRUE; |
6761 | - } |
|
6762 | - elseif( $argType == $component2->objName ) { |
|
7671 | + } elseif( $argType == $component2->objName ) { |
|
6763 | 7672 | if( $index == $cix2sC ) { |
6764 | 7673 | $this->components[$cix] = $component->copy(); |
6765 | 7674 | return TRUE; |
6766 | 7675 | } |
6767 | 7676 | $cix2sC++; |
6768 | - } |
|
6769 | - elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) { |
|
7677 | + } elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) { |
|
6770 | 7678 | $this->components[$cix] = $component->copy(); |
6771 | 7679 | return TRUE; |
6772 | 7680 | } |
@@ -6785,9 +7693,12 @@ discard block |
||
6785 | 7693 | function createSubComponent() { |
6786 | 7694 | $output = null; |
6787 | 7695 | foreach( $this->components as $component ) { |
6788 | - if( empty( $component )) continue; |
|
6789 | - if( '' >= $component->getConfig( 'language')) |
|
6790 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
7696 | + if( empty( $component )) { |
|
7697 | + continue; |
|
7698 | + } |
|
7699 | + if( '' >= $component->getConfig( 'language')) { |
|
7700 | + $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
7701 | + } |
|
6791 | 7702 | $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
6792 | 7703 | $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
6793 | 7704 | $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
@@ -6825,16 +7736,18 @@ discard block |
||
6825 | 7736 | $string = null; |
6826 | 7737 | while( $strlen > 75 ) { |
6827 | 7738 | $breakAtChar = 75; |
6828 | - if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' ) |
|
6829 | - $breakAtChar = $breakAtChar - 1; |
|
7739 | + if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' ) { |
|
7740 | + $breakAtChar = $breakAtChar - 1; |
|
7741 | + } |
|
6830 | 7742 | $string .= substr( $tmp, 0, $breakAtChar ); |
6831 | 7743 | $string .= $this->nl; |
6832 | 7744 | $tmp = ' '.substr( $tmp, $breakAtChar ); |
6833 | 7745 | $strlen = strlen( $tmp ); |
6834 | 7746 | } // while |
6835 | 7747 | $string .= rtrim( $tmp ); // the rest |
6836 | - if( $this->nl != substr( $string, ( 0 - strlen( $this->nl )))) |
|
6837 | - $string .= $this->nl; |
|
7748 | + if( $this->nl != substr( $string, ( 0 - strlen( $this->nl )))) { |
|
7749 | + $string .= $this->nl; |
|
7750 | + } |
|
6838 | 7751 | return $string; |
6839 | 7752 | } |
6840 | 7753 | /** |
@@ -6855,27 +7768,33 @@ discard block |
||
6855 | 7768 | $pos = 0; |
6856 | 7769 | while( $pos <= strlen( $string )) { |
6857 | 7770 | $pos = strpos( $string, "\\", $pos ); |
6858 | - if( FALSE === $pos ) |
|
6859 | - break; |
|
7771 | + if( FALSE === $pos ) { |
|
7772 | + break; |
|
7773 | + } |
|
6860 | 7774 | if( !in_array( $string{($pos + 1)}, array( 'n', 'N', 'r', ',', ';' ))) { |
6861 | 7775 | $string = substr( $string, 0, $pos )."\\".substr( $string, ( $pos + 1 )); |
6862 | 7776 | $pos += 1; |
6863 | 7777 | } |
6864 | 7778 | $pos += 1; |
6865 | 7779 | } |
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, ';' )) |
|
6871 | - $string = str_replace(';', '\;', $string); |
|
6872 | - if( FALSE !== strpos( $string, "\r\n" )) |
|
6873 | - $string = str_replace( "\r\n", '\n', $string); |
|
6874 | - elseif( FALSE !== strpos( $string, "\r" )) |
|
6875 | - $string = str_replace( "\r", '\n', $string); |
|
6876 | - if( FALSE !== strpos( $string, '\N' )) |
|
6877 | - $string = str_replace( '\N', '\n', $string); |
|
6878 | -// if( FALSE !== strpos( $string, $this->nl )) |
|
7780 | + if( FALSE !== strpos( $string, '"' )) { |
|
7781 | + $string = str_replace('"', "'", $string); |
|
7782 | + } |
|
7783 | + if( FALSE !== strpos( $string, ',' )) { |
|
7784 | + $string = str_replace(',', '\,', $string); |
|
7785 | + } |
|
7786 | + if( FALSE !== strpos( $string, ';' )) { |
|
7787 | + $string = str_replace(';', '\;', $string); |
|
7788 | + } |
|
7789 | + if( FALSE !== strpos( $string, "\r\n" )) { |
|
7790 | + $string = str_replace( "\r\n", '\n', $string); |
|
7791 | + } elseif( FALSE !== strpos( $string, "\r" )) { |
|
7792 | + $string = str_replace( "\r", '\n', $string); |
|
7793 | + } |
|
7794 | + if( FALSE !== strpos( $string, '\N' )) { |
|
7795 | + $string = str_replace( '\N', '\n', $string); |
|
7796 | + } |
|
7797 | + // if( FALSE !== strpos( $string, $this->nl )) |
|
6879 | 7798 | $string = str_replace( $this->nl, '\n', $string); |
6880 | 7799 | break; |
6881 | 7800 | } |
@@ -7027,8 +7946,9 @@ discard block |
||
7027 | 7946 | $component .= $this->createSubComponent(); |
7028 | 7947 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7029 | 7948 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7030 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7031 | - $xcaldecl[] = $localxcaldecl; |
|
7949 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
7950 | + $xcaldecl[] = $localxcaldecl; |
|
7951 | + } |
|
7032 | 7952 | } |
7033 | 7953 | return $component; |
7034 | 7954 | } |
@@ -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 | } |
@@ -7274,8 +8195,9 @@ discard block |
||
7274 | 8195 | $component .= $this->createXprop(); |
7275 | 8196 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7276 | 8197 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7277 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7278 | - $xcaldecl[] = $localxcaldecl; |
|
8198 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
8199 | + $xcaldecl[] = $localxcaldecl; |
|
8200 | + } |
|
7279 | 8201 | } |
7280 | 8202 | return $component; |
7281 | 8203 | } |
@@ -7349,8 +8271,9 @@ discard block |
||
7349 | 8271 | $component .= $this->createXprop(); |
7350 | 8272 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7351 | 8273 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7352 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7353 | - $xcaldecl[] = $localxcaldecl; |
|
8274 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
8275 | + $xcaldecl[] = $localxcaldecl; |
|
8276 | + } |
|
7354 | 8277 | } |
7355 | 8278 | return $component; |
7356 | 8279 | } |
@@ -7495,8 +8418,9 @@ discard block |
||
7495 | 8418 | $component .= $this->createSubComponent(); |
7496 | 8419 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7497 | 8420 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7498 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7499 | - $xcaldecl[] = $localxcaldecl; |
|
8421 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
8422 | + $xcaldecl[] = $localxcaldecl; |
|
8423 | + } |
|
7500 | 8424 | } |
7501 | 8425 | return $component; |
7502 | 8426 | } |
@@ -287,7 +287,10 @@ discard block |
||
287 | 287 | <td width="40%" align="center"> |
288 | 288 | <select name="UserList[]" multiple="multiple" size="20" style="width:300px;"> |
289 | 289 | <?php foreach ($db_users as $user) { ?> |
290 | - <option value="<?php echo $user['user_id']; ?>" <?php if(in_array($user['user_id'],$users)) echo 'selected="selected"'; ?>> |
|
290 | + <option value="<?php echo $user['user_id']; ?>" <?php if(in_array($user['user_id'],$users)) { |
|
291 | + echo 'selected="selected"'; |
|
292 | +} |
|
293 | +?>> |
|
291 | 294 | <?php |
292 | 295 | $userName = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')'; |
293 | 296 | if ($showOfficialCode) { |
@@ -308,7 +311,10 @@ discard block |
||
308 | 311 | <td width="40%" align="center"> |
309 | 312 | <select name="CourseList[]" multiple="multiple" size="20" style="width:300px;"> |
310 | 313 | <?php foreach ($db_courses as $course) { ?> |
311 | - <option value="<?php echo $course['code']; ?>" <?php if(in_array($course['code'],$courses)) echo 'selected="selected"'; ?>> |
|
314 | + <option value="<?php echo $course['code']; ?>" <?php if(in_array($course['code'],$courses)) { |
|
315 | + echo 'selected="selected"'; |
|
316 | +} |
|
317 | +?>> |
|
312 | 318 | <?php echo '('.$course['visual_code'].') '.$course['title']; ?> |
313 | 319 | </option> |
314 | 320 | <?php } ?> |
@@ -3944,8 +3944,9 @@ discard block |
||
3944 | 3944 | WHERE c_id = ".$course_id." |
3945 | 3945 | ORDER BY display_order"; |
3946 | 3946 | $res = Database::query($sql); |
3947 | - if ($res === false) |
|
3948 | - return false; |
|
3947 | + if ($res === false) { |
|
3948 | + return false; |
|
3949 | + } |
|
3949 | 3950 | $lps = array (); |
3950 | 3951 | $lp_order = array (); |
3951 | 3952 | $num = Database :: num_rows($res); |
@@ -4545,8 +4546,9 @@ discard block |
||
4545 | 4546 | if ($this->debug > 0) { |
4546 | 4547 | error_log('New LP - In learnpath::set_maker()', 0); |
4547 | 4548 | } |
4548 | - if (empty ($name)) |
|
4549 | - return false; |
|
4549 | + if (empty ($name)) { |
|
4550 | + return false; |
|
4551 | + } |
|
4550 | 4552 | $this->maker = $name; |
4551 | 4553 | $lp_table = Database :: get_course_table(TABLE_LP_MAIN); |
4552 | 4554 | $course_id = api_get_course_int_id(); |
@@ -4611,8 +4613,9 @@ discard block |
||
4611 | 4613 | public function set_terms_by_prefix($terms_string, $prefix) |
4612 | 4614 | { |
4613 | 4615 | $course_id = api_get_course_int_id(); |
4614 | - if (api_get_setting('search_enabled') !== 'true') |
|
4615 | - return false; |
|
4616 | + if (api_get_setting('search_enabled') !== 'true') { |
|
4617 | + return false; |
|
4618 | + } |
|
4616 | 4619 | |
4617 | 4620 | if (!extension_loaded('xapian')) { |
4618 | 4621 | return false; |
@@ -4625,8 +4628,9 @@ discard block |
||
4625 | 4628 | $stored_terms = $this->get_common_index_terms_by_prefix($prefix); |
4626 | 4629 | |
4627 | 4630 | // Don't do anything if no change, verify only at DB, not the search engine. |
4628 | - if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) |
|
4629 | - return false; |
|
4631 | + if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) { |
|
4632 | + return false; |
|
4633 | + } |
|
4630 | 4634 | |
4631 | 4635 | require_once 'xapian.php'; // TODO: Try catch every xapian use or make wrappers on API. |
4632 | 4636 | require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'; |
@@ -4818,8 +4822,9 @@ discard block |
||
4818 | 4822 | if ($this->debug > 0) { |
4819 | 4823 | error_log('New LP - In learnpath::set_proximity()', 0); |
4820 | 4824 | } |
4821 | - if (empty ($name)) |
|
4822 | - return false; |
|
4825 | + if (empty ($name)) { |
|
4826 | + return false; |
|
4827 | + } |
|
4823 | 4828 | |
4824 | 4829 | $this->proximity = $name; |
4825 | 4830 | $lp_table = Database :: get_course_table(TABLE_LP_MAIN); |
@@ -5163,8 +5168,9 @@ discard block |
||
5163 | 5168 | |
5164 | 5169 | $sql = "SELECT * FROM $lp_table WHERE c_id = ".$course_id." ORDER BY display_order"; |
5165 | 5170 | $res = Database::query($sql); |
5166 | - if ($res === false) |
|
5167 | - return false; |
|
5171 | + if ($res === false) { |
|
5172 | + return false; |
|
5173 | + } |
|
5168 | 5174 | |
5169 | 5175 | $num = Database :: num_rows($res); |
5170 | 5176 | // First check the order is correct, globally (might be wrong because |
@@ -5475,8 +5481,9 @@ discard block |
||
5475 | 5481 | $position[$key] = $row['display_order']; |
5476 | 5482 | } |
5477 | 5483 | |
5478 | - if (count($array) > 0) |
|
5479 | - array_multisort($parent, SORT_ASC, $position, SORT_ASC, $array); |
|
5484 | + if (count($array) > 0) { |
|
5485 | + array_multisort($parent, SORT_ASC, $position, SORT_ASC, $array); |
|
5486 | + } |
|
5480 | 5487 | |
5481 | 5488 | return $array; |
5482 | 5489 | } |
@@ -6190,10 +6197,12 @@ discard block |
||
6190 | 6197 | if ($new_comment || $new_title) { |
6191 | 6198 | $tbl_doc = Database :: get_course_table(TABLE_DOCUMENT); |
6192 | 6199 | $ct = ''; |
6193 | - if ($new_comment) |
|
6194 | - $ct .= ", comment='" . Database::escape_string($new_comment). "'"; |
|
6195 | - if ($new_title) |
|
6196 | - $ct .= ", title='" . Database::escape_string($new_title)."' "; |
|
6200 | + if ($new_comment) { |
|
6201 | + $ct .= ", comment='" . Database::escape_string($new_comment). "'"; |
|
6202 | + } |
|
6203 | + if ($new_title) { |
|
6204 | + $ct .= ", title='" . Database::escape_string($new_title)."' "; |
|
6205 | + } |
|
6197 | 6206 | |
6198 | 6207 | $sql = "UPDATE " . $tbl_doc ." SET " . substr($ct, 1)." |
6199 | 6208 | WHERE c_id = ".$course_id." AND id = " . $document_id; |
@@ -6217,17 +6226,21 @@ discard block |
||
6217 | 6226 | // Please, do not modify this dirname formatting. |
6218 | 6227 | $dir = isset($_GET['dir']) ? $_GET['dir'] : $_POST['dir']; |
6219 | 6228 | |
6220 | - if (strstr($dir, '..')) |
|
6221 | - $dir = '/'; |
|
6229 | + if (strstr($dir, '..')) { |
|
6230 | + $dir = '/'; |
|
6231 | + } |
|
6222 | 6232 | |
6223 | - if ($dir[0] == '.') |
|
6224 | - $dir = substr($dir, 1); |
|
6233 | + if ($dir[0] == '.') { |
|
6234 | + $dir = substr($dir, 1); |
|
6235 | + } |
|
6225 | 6236 | |
6226 | - if ($dir[0] != '/') |
|
6227 | - $dir = '/' . $dir; |
|
6237 | + if ($dir[0] != '/') { |
|
6238 | + $dir = '/' . $dir; |
|
6239 | + } |
|
6228 | 6240 | |
6229 | - if ($dir[strlen($dir) - 1] != '/') |
|
6230 | - $dir .= '/'; |
|
6241 | + if ($dir[strlen($dir) - 1] != '/') { |
|
6242 | + $dir .= '/'; |
|
6243 | + } |
|
6231 | 6244 | |
6232 | 6245 | $filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document' . $dir; |
6233 | 6246 | |
@@ -6292,8 +6305,9 @@ discard block |
||
6292 | 6305 | } |
6293 | 6306 | $return .= '<div style="padding:10px;">'; |
6294 | 6307 | |
6295 | - if ($msg != '') |
|
6296 | - $return .= $msg; |
|
6308 | + if ($msg != '') { |
|
6309 | + $return .= $msg; |
|
6310 | + } |
|
6297 | 6311 | |
6298 | 6312 | $return .= '<h3>'.$row['title'].'</h3>'; |
6299 | 6313 | switch ($row['item_type']) { |
@@ -6554,10 +6568,11 @@ discard block |
||
6554 | 6568 | $item_title = Security::remove_XSS($item_title); |
6555 | 6569 | $item_description = Security::remove_XSS($item_description); |
6556 | 6570 | |
6557 | - if ($id != 0 && is_array($extra_info)) |
|
6558 | - $parent = $extra_info['parent_item_id']; |
|
6559 | - else |
|
6560 | - $parent = 0; |
|
6571 | + if ($id != 0 && is_array($extra_info)) { |
|
6572 | + $parent = $extra_info['parent_item_id']; |
|
6573 | + } else { |
|
6574 | + $parent = 0; |
|
6575 | + } |
|
6561 | 6576 | |
6562 | 6577 | $sql = "SELECT * FROM " . $tbl_lp_item . " |
6563 | 6578 | WHERE c_id = ".$course_id." AND lp_id = " . $this->lp_id; |
@@ -6822,11 +6837,13 @@ discard block |
||
6822 | 6837 | } |
6823 | 6838 | |
6824 | 6839 | $legend = '<legend>'; |
6825 | - if ($action == 'add') |
|
6826 | - $legend .= get_lang('CreateTheExercise'); |
|
6827 | - elseif ($action == 'move') $legend .= get_lang('MoveTheCurrentExercise'); |
|
6828 | - else |
|
6829 | - $legend .= get_lang('EditCurrentExecice'); |
|
6840 | + if ($action == 'add') { |
|
6841 | + $legend .= get_lang('CreateTheExercise'); |
|
6842 | + } elseif ($action == 'move') { |
|
6843 | + $legend .= get_lang('MoveTheCurrentExercise'); |
|
6844 | + } else { |
|
6845 | + $legend .= get_lang('EditCurrentExecice'); |
|
6846 | + } |
|
6830 | 6847 | if (isset ($_GET['edit']) && $_GET['edit'] == 'true') { |
6831 | 6848 | $legend .= Display :: return_warning_message(get_lang('Warning') . ' ! ' . get_lang('WarningEditingDocument')); |
6832 | 6849 | } |
@@ -6853,8 +6870,9 @@ discard block |
||
6853 | 6870 | $arrHide[] = $arrLP[$i]['id']; |
6854 | 6871 | } |
6855 | 6872 | } else { |
6856 | - if ($arrLP[$i]['item_type'] == 'dir') |
|
6857 | - $return .= '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . $arrLP[$i]['title'] . '</option>'; |
|
6873 | + if ($arrLP[$i]['item_type'] == 'dir') { |
|
6874 | + $return .= '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . $arrLP[$i]['title'] . '</option>'; |
|
6875 | + } |
|
6858 | 6876 | } |
6859 | 6877 | } |
6860 | 6878 | |
@@ -6872,11 +6890,13 @@ discard block |
||
6872 | 6890 | |
6873 | 6891 | for ($i = 0; $i < count($arrLP); $i++) { |
6874 | 6892 | if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) { |
6875 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
6893 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
6894 | + $selected = 'selected="selected" '; |
|
6895 | + } elseif ($action == 'add') { |
|
6876 | 6896 | $selected = 'selected="selected" '; |
6877 | - elseif ($action == 'add') $selected = 'selected="selected" '; |
|
6878 | - else |
|
6879 | - $selected = ''; |
|
6897 | + } else { |
|
6898 | + $selected = ''; |
|
6899 | + } |
|
6880 | 6900 | |
6881 | 6901 | $return .= '<option ' . $selected . 'value="' . $arrLP[$i]['id'] . '">' . get_lang('After') . ' "' . $arrLP[$i]['title'] . '"</option>'; |
6882 | 6902 | } |
@@ -6903,9 +6923,11 @@ discard block |
||
6903 | 6923 | $arrHide = array (); |
6904 | 6924 | for ($i = 0; $i < count($arrLP); $i++) { |
6905 | 6925 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir') { |
6906 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
6907 | - $s_selected_position = $arrLP[$i]['id']; |
|
6908 | - elseif ($action == 'add') $s_selected_position = 0; |
|
6926 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
6927 | + $s_selected_position = $arrLP[$i]['id']; |
|
6928 | + } elseif ($action == 'add') { |
|
6929 | + $s_selected_position = 0; |
|
6930 | + } |
|
6909 | 6931 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
6910 | 6932 | |
6911 | 6933 | } |
@@ -7098,9 +7120,11 @@ discard block |
||
7098 | 7120 | $arrHide = array(); |
7099 | 7121 | for ($i = 0; $i < count($arrLP); $i++) { |
7100 | 7122 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir') { |
7101 | - if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
7102 | - $s_selected_position = $arrLP[$i]['id']; |
|
7103 | - elseif ($action == 'add') $s_selected_position = 0; |
|
7123 | + if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
7124 | + $s_selected_position = $arrLP[$i]['id']; |
|
7125 | + } elseif ($action == 'add') { |
|
7126 | + $s_selected_position = 0; |
|
7127 | + } |
|
7104 | 7128 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
7105 | 7129 | } |
7106 | 7130 | } |
@@ -7295,9 +7319,11 @@ discard block |
||
7295 | 7319 | |
7296 | 7320 | for ($i = 0; $i < count($arrLP); $i++) { |
7297 | 7321 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir') { |
7298 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
7299 | - $s_selected_position = $arrLP[$i]['id']; |
|
7300 | - elseif ($action == 'add') $s_selected_position = 0; |
|
7322 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
7323 | + $s_selected_position = $arrLP[$i]['id']; |
|
7324 | + } elseif ($action == 'add') { |
|
7325 | + $s_selected_position = 0; |
|
7326 | + } |
|
7301 | 7327 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
7302 | 7328 | |
7303 | 7329 | } |
@@ -7331,8 +7357,7 @@ discard block |
||
7331 | 7357 | |
7332 | 7358 | if (is_numeric($extra_info)) { |
7333 | 7359 | $form->addHidden('path', $extra_info); |
7334 | - } |
|
7335 | - elseif (is_array($extra_info)) { |
|
7360 | + } elseif (is_array($extra_info)) { |
|
7336 | 7361 | $form->addHidden('path', $extra_info['path']); |
7337 | 7362 | } |
7338 | 7363 | |
@@ -7385,8 +7410,9 @@ discard block |
||
7385 | 7410 | lp_id = " . $this->lp_id . " AND |
7386 | 7411 | id != $id"; |
7387 | 7412 | |
7388 | - if ($item_type == 'dir') |
|
7389 | - $sql .= " AND parent_item_id = 0"; |
|
7413 | + if ($item_type == 'dir') { |
|
7414 | + $sql .= " AND parent_item_id = 0"; |
|
7415 | + } |
|
7390 | 7416 | |
7391 | 7417 | $result = Database::query($sql); |
7392 | 7418 | $arrLP = array (); |
@@ -7787,9 +7813,11 @@ discard block |
||
7787 | 7813 | $arrHide = array(); |
7788 | 7814 | for ($i = 0; $i < count($arrLP); $i++) { |
7789 | 7815 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir' && $arrLP[$i]['item_type'] !== TOOL_LP_FINAL_ITEM) { |
7790 | - if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
7816 | + if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
7817 | + $s_selected_position = $arrLP[$i]['id']; |
|
7818 | + } elseif ($action == 'add') { |
|
7791 | 7819 | $s_selected_position = $arrLP[$i]['id']; |
7792 | - elseif ($action == 'add') $s_selected_position = $arrLP[$i]['id']; |
|
7820 | + } |
|
7793 | 7821 | |
7794 | 7822 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
7795 | 7823 | |
@@ -7800,17 +7828,18 @@ discard block |
||
7800 | 7828 | $item_type = isset($extra_info['item_type']) ? $extra_info['item_type'] : null; |
7801 | 7829 | $edit = isset($_GET['edit']) ? $_GET['edit'] : null; |
7802 | 7830 | if (($extra_info == 'new' || $item_type == TOOL_DOCUMENT || $item_type == TOOL_LP_FINAL_ITEM || $edit == 'true')) { |
7803 | - if (isset ($_POST['content'])) |
|
7804 | - $content = stripslashes($_POST['content']); |
|
7805 | - elseif (is_array($extra_info)) { |
|
7831 | + if (isset ($_POST['content'])) { |
|
7832 | + $content = stripslashes($_POST['content']); |
|
7833 | + } elseif (is_array($extra_info)) { |
|
7806 | 7834 | //If it's an html document or a text file |
7807 | 7835 | if (!$no_display_edit_textarea) { |
7808 | 7836 | $content = $this->display_document($extra_info['path'], false, false); |
7809 | 7837 | } |
7810 | - } elseif (is_numeric($extra_info)) |
|
7811 | - $content = $this->display_document($extra_info, false, false); |
|
7812 | - else |
|
7813 | - $content = ''; |
|
7838 | + } elseif (is_numeric($extra_info)) { |
|
7839 | + $content = $this->display_document($extra_info, false, false); |
|
7840 | + } else { |
|
7841 | + $content = ''; |
|
7842 | + } |
|
7814 | 7843 | |
7815 | 7844 | if (!$no_display_edit_textarea) { |
7816 | 7845 | // We need to calculate here some specific settings for the online editor. |
@@ -8074,9 +8103,11 @@ discard block |
||
8074 | 8103 | $arrHide = array(); |
8075 | 8104 | for ($i = 0; $i < count($arrLP); $i++) { |
8076 | 8105 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir') { |
8077 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
8078 | - $s_selected_position = $arrLP[$i]['id']; |
|
8079 | - elseif ($action == 'add') $s_selected_position = 0; |
|
8106 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
8107 | + $s_selected_position = $arrLP[$i]['id']; |
|
8108 | + } elseif ($action == 'add') { |
|
8109 | + $s_selected_position = 0; |
|
8110 | + } |
|
8080 | 8111 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
8081 | 8112 | |
8082 | 8113 | } |
@@ -8272,9 +8303,11 @@ discard block |
||
8272 | 8303 | $arrHide = array (); |
8273 | 8304 | for ($i = 0; $i < count($arrLP); $i++) { |
8274 | 8305 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir') { |
8275 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
8276 | - $s_selected_position = $arrLP[$i]['id']; |
|
8277 | - elseif ($action == 'add') $s_selected_position = 0; |
|
8306 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
8307 | + $s_selected_position = $arrLP[$i]['id']; |
|
8308 | + } elseif ($action == 'add') { |
|
8309 | + $s_selected_position = 0; |
|
8310 | + } |
|
8278 | 8311 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
8279 | 8312 | |
8280 | 8313 | } |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | $isAdmin = api_is_platform_admin(); |
139 | 139 | |
140 | 140 | Display::display_header(get_lang('MyTickets')); |
141 | -if (!empty($projectId)) |
|
142 | -if ($isAdmin ) { |
|
141 | +if (!empty($projectId)) { |
|
142 | + if ($isAdmin ) { |
|
143 | 143 | $getParameters = [ |
144 | 144 | 'keyword', |
145 | 145 | 'keyword_status', |
@@ -151,6 +151,7 @@ discard block |
||
151 | 151 | 'Tickets_per_page', |
152 | 152 | 'Tickets_column' |
153 | 153 | ]; |
154 | +} |
|
154 | 155 | $get_parameter = ''; |
155 | 156 | foreach ($getParameters as $getParameter) { |
156 | 157 | if (isset($_GET[$getParameter])) { |