@@ -44,10 +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() )) { |
|
48 | - date_default_timezone_set( 'Europe/Stockholm' ); |
|
47 | +if (substr(phpversion(), 0, 1) >= '5') // && ( 'UTC' == date_default_timezone_get() )) { |
|
48 | + date_default_timezone_set('Europe/Stockholm'); |
|
49 | 49 | /* version string, do NOT remove!! */ |
50 | -define( 'ICALCREATOR_VERSION', 'iCalcreator 2.6' ); |
|
50 | +define('ICALCREATOR_VERSION', 'iCalcreator 2.6'); |
|
51 | 51 | /*********************************************************************************/ |
52 | 52 | /*********************************************************************************/ |
53 | 53 | /** |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * language = <Text identifying a language, as defined in [RFC 1766]> |
98 | 98 | */ |
99 | - if( defined( 'ICAL_LANG' )) |
|
100 | - $this->setConfig( 'language', ICAL_LANG ); |
|
101 | - $this->setConfig( 'allowEmpty', TRUE ); |
|
102 | - $this->setConfig( 'nl', "\n" ); |
|
103 | - $this->setConfig( 'format', 'iCal'); |
|
99 | + if (defined('ICAL_LANG')) |
|
100 | + $this->setConfig('language', ICAL_LANG); |
|
101 | + $this->setConfig('allowEmpty', TRUE); |
|
102 | + $this->setConfig('nl', "\n"); |
|
103 | + $this->setConfig('format', 'iCal'); |
|
104 | 104 | $this->directory = null; |
105 | 105 | $this->filename = null; |
106 | 106 | $this->url = null; |
107 | - $this->setConfig( 'delimiter', DIRECTORY_SEPARATOR ); |
|
107 | + $this->setConfig('delimiter', DIRECTORY_SEPARATOR); |
|
108 | 108 | $this->xcaldecl = array(); |
109 | 109 | $this->components = array(); |
110 | 110 | } |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @return string |
121 | 121 | */ |
122 | 122 | function createCalscale() { |
123 | - if( empty( $this->calscale )) return FALSE; |
|
124 | - switch( $this->format ) { |
|
123 | + if (empty($this->calscale)) return FALSE; |
|
124 | + switch ($this->format) { |
|
125 | 125 | case 'xcal': |
126 | 126 | return ' calscale="'.$this->calscale.'"'.$this->nl; |
127 | 127 | break; |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | * @param string $value |
139 | 139 | * @return void |
140 | 140 | */ |
141 | - function setCalscale( $value ) { |
|
142 | - if( empty( $value )) return FALSE; |
|
141 | + function setCalscale($value) { |
|
142 | + if (empty($value)) return FALSE; |
|
143 | 143 | $this->calscale = $value; |
144 | 144 | } |
145 | 145 | /*********************************************************************************/ |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | * @return string |
155 | 155 | */ |
156 | 156 | function createMethod() { |
157 | - if( empty( $this->method )) return FALSE; |
|
158 | - switch( $this->format ) { |
|
157 | + if (empty($this->method)) return FALSE; |
|
158 | + switch ($this->format) { |
|
159 | 159 | case 'xcal': |
160 | 160 | return ' method="'.$this->method.'"'.$this->nl; |
161 | 161 | break; |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | * @param string $value |
173 | 173 | * @return bool |
174 | 174 | */ |
175 | - function setMethod( $value ) { |
|
176 | - if( empty( $value )) return FALSE; |
|
175 | + function setMethod($value) { |
|
176 | + if (empty($value)) return FALSE; |
|
177 | 177 | $this->method = $value; |
178 | 178 | return TRUE; |
179 | 179 | } |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | * @return string |
194 | 194 | */ |
195 | 195 | function createProdid() { |
196 | - if( !isset( $this->prodid )) |
|
196 | + if (!isset($this->prodid)) |
|
197 | 197 | $this->_makeProdid(); |
198 | - switch( $this->format ) { |
|
198 | + switch ($this->format) { |
|
199 | 199 | case 'xcal': |
200 | 200 | return ' prodid="'.$this->prodid.'"'.$this->nl; |
201 | 201 | break; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @return void |
213 | 213 | */ |
214 | 214 | function _makeProdid() { |
215 | - $this->prodid = '-//'.$this->unique_id.'//NONSGML '.ICALCREATOR_VERSION.'//'.strtoupper( $this->language ); |
|
215 | + $this->prodid = '-//'.$this->unique_id.'//NONSGML '.ICALCREATOR_VERSION.'//'.strtoupper($this->language); |
|
216 | 216 | } |
217 | 217 | /** |
218 | 218 | * Conformance: The property MUST be specified once in an iCalendar object. |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * @return void |
229 | 229 | */ |
230 | 230 | function _makeUnique_id() { |
231 | - $this->unique_id = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost'; |
|
231 | + $this->unique_id = (isset($_SERVER['SERVER_NAME'])) ? gethostbyname($_SERVER['SERVER_NAME']) : 'localhost'; |
|
232 | 232 | } |
233 | 233 | /*********************************************************************************/ |
234 | 234 | /** |
@@ -245,9 +245,9 @@ discard block |
||
245 | 245 | * @return string |
246 | 246 | */ |
247 | 247 | function createVersion() { |
248 | - if( empty( $this->version )) |
|
248 | + if (empty($this->version)) |
|
249 | 249 | $this->_makeVersion(); |
250 | - switch( $this->format ) { |
|
250 | + switch ($this->format) { |
|
251 | 251 | case 'xcal': |
252 | 252 | return ' version="'.$this->version.'"'.$this->nl; |
253 | 253 | break; |
@@ -274,8 +274,8 @@ discard block |
||
274 | 274 | * @param string $value |
275 | 275 | * @return void |
276 | 276 | */ |
277 | - function setVersion( $value ) { |
|
278 | - if( empty( $value )) return FALSE; |
|
277 | + function setVersion($value) { |
|
278 | + if (empty($value)) return FALSE; |
|
279 | 279 | $this->version = $value; |
280 | 280 | return TRUE; |
281 | 281 | } |
@@ -291,29 +291,29 @@ discard block |
||
291 | 291 | * @return string |
292 | 292 | */ |
293 | 293 | function createXprop() { |
294 | - if( 'xcal' == $this->format ) |
|
294 | + if ('xcal' == $this->format) |
|
295 | 295 | return false; |
296 | - if( 0 >= count( $this->xprop )) |
|
296 | + if (0 >= count($this->xprop)) |
|
297 | 297 | return; |
298 | 298 | $output = null; |
299 | 299 | $toolbox = new calendarComponent(); |
300 | - $toolbox->setConfig( 'language', $this->getConfig( 'language' )); |
|
301 | - $toolbox->setConfig( 'nl', $this->getConfig( 'nl' )); |
|
302 | - $toolbox->_createFormat( $this->getConfig( 'format' )); |
|
303 | - foreach( $this->xprop as $label => $xpropPart ) { |
|
304 | - if( empty( $xpropPart['value'] )) { |
|
305 | - $output .= $toolbox->_createElement( $label ); |
|
300 | + $toolbox->setConfig('language', $this->getConfig('language')); |
|
301 | + $toolbox->setConfig('nl', $this->getConfig('nl')); |
|
302 | + $toolbox->_createFormat($this->getConfig('format')); |
|
303 | + foreach ($this->xprop as $label => $xpropPart) { |
|
304 | + if (empty($xpropPart['value'])) { |
|
305 | + $output .= $toolbox->_createElement($label); |
|
306 | 306 | continue; |
307 | 307 | } |
308 | - $attributes = $toolbox->_createParams( $xpropPart['params'], array( 'LANGUAGE' )); |
|
309 | - if( is_array( $xpropPart['value'] )) { |
|
310 | - foreach( $xpropPart['value'] as $pix => $theXpart ) |
|
311 | - $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart ); |
|
312 | - $xpropPart['value'] = implode( ',', $xpropPart['value'] ); |
|
308 | + $attributes = $toolbox->_createParams($xpropPart['params'], array('LANGUAGE')); |
|
309 | + if (is_array($xpropPart['value'])) { |
|
310 | + foreach ($xpropPart['value'] as $pix => $theXpart) |
|
311 | + $xpropPart['value'][$pix] = $toolbox->_strrep($theXpart); |
|
312 | + $xpropPart['value'] = implode(',', $xpropPart['value']); |
|
313 | 313 | } |
314 | 314 | else |
315 | - $xpropPart['value'] = $toolbox->_strrep( $xpropPart['value'] ); |
|
316 | - $output .= $toolbox->_createElement( $label, $attributes, $xpropPart['value'] ); |
|
315 | + $xpropPart['value'] = $toolbox->_strrep($xpropPart['value']); |
|
316 | + $output .= $toolbox->_createElement($label, $attributes, $xpropPart['value']); |
|
317 | 317 | } |
318 | 318 | return $output; |
319 | 319 | } |
@@ -327,14 +327,14 @@ discard block |
||
327 | 327 | * @param array $params optional |
328 | 328 | * @return bool |
329 | 329 | */ |
330 | - function setXprop( $label, $value, $params=FALSE ) { |
|
331 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
332 | - if( empty( $label )) return FALSE; |
|
333 | - $xprop = array( 'value' => $value ); |
|
330 | + function setXprop($label, $value, $params = FALSE) { |
|
331 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
332 | + if (empty($label)) return FALSE; |
|
333 | + $xprop = array('value' => $value); |
|
334 | 334 | $toolbox = new calendarComponent(); |
335 | - $xprop['params'] = $toolbox->_setParams( $params ); |
|
336 | - if( !is_array( $this->xprop )) $this->xprop = array(); |
|
337 | - $this->xprop[strtoupper( $label )] = $xprop; |
|
335 | + $xprop['params'] = $toolbox->_setParams($params); |
|
336 | + if (!is_array($this->xprop)) $this->xprop = array(); |
|
337 | + $this->xprop[strtoupper($label)] = $xprop; |
|
338 | 338 | return TRUE; |
339 | 339 | } |
340 | 340 | /*********************************************************************************/ |
@@ -347,39 +347,39 @@ discard block |
||
347 | 347 | * @param int @propix, optional, if specific property is wanted in case of multiply occurences |
348 | 348 | * @return bool, if successfull delete |
349 | 349 | */ |
350 | - function deleteProperty( $propName, $propix=FALSE ) { |
|
351 | - $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP'; |
|
352 | - if( !$propix ) |
|
353 | - $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1; |
|
350 | + function deleteProperty($propName, $propix = FALSE) { |
|
351 | + $propName = ($propName) ? strtoupper($propName) : 'X-PROP'; |
|
352 | + if (!$propix) |
|
353 | + $propix = (isset($this->propdelix[$propName])) ? $this->propdelix[$propName] + 2 : 1; |
|
354 | 354 | $this->propdelix[$propName] = --$propix; |
355 | 355 | $return = FALSE; |
356 | - switch( $propName ) { |
|
356 | + switch ($propName) { |
|
357 | 357 | case 'CALSCALE': |
358 | - if( isset( $this->calscale )) { |
|
358 | + if (isset($this->calscale)) { |
|
359 | 359 | $this->calscale = null; |
360 | 360 | $return = TRUE; |
361 | 361 | } |
362 | 362 | break; |
363 | 363 | case 'METHOD': |
364 | - if( isset( $this->method )) { |
|
365 | - $this->method = null; |
|
364 | + if (isset($this->method)) { |
|
365 | + $this->method = null; |
|
366 | 366 | $return = TRUE; |
367 | 367 | } |
368 | 368 | break; |
369 | 369 | default: |
370 | 370 | $reduced = array(); |
371 | - if( $propName != 'X-PROP' ) { |
|
372 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
373 | - foreach( $this->xprop as $k => $a ) { |
|
374 | - if(( $k != $propName ) && !empty( $a )) |
|
371 | + if ($propName != 'X-PROP') { |
|
372 | + if (!isset($this->xprop[$propName])) return FALSE; |
|
373 | + foreach ($this->xprop as $k => $a) { |
|
374 | + if (($k != $propName) && !empty($a)) |
|
375 | 375 | $reduced[$k] = $a; |
376 | 376 | } |
377 | 377 | } |
378 | 378 | else { |
379 | - if( count( $this->xprop ) <= $propix ) return FALSE; |
|
379 | + if (count($this->xprop) <= $propix) return FALSE; |
|
380 | 380 | $xpropno = 0; |
381 | - foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
|
382 | - if( $propix != $xpropno ) |
|
381 | + foreach ($this->xprop as $xpropkey => $xpropvalue) { |
|
382 | + if ($propix != $xpropno) |
|
383 | 383 | $reduced[$xpropkey] = $xpropvalue; |
384 | 384 | $xpropno++; |
385 | 385 | } |
@@ -399,41 +399,41 @@ discard block |
||
399 | 399 | * @param bool $inclParam=FALSE |
400 | 400 | * @return mixed |
401 | 401 | */ |
402 | - function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE ) { |
|
403 | - $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP'; |
|
404 | - if( 'X-PROP' == $propName ) { |
|
405 | - if( !$propix ) |
|
406 | - $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; |
|
402 | + function getProperty($propName = FALSE, $propix = FALSE, $inclParam = FALSE) { |
|
403 | + $propName = ($propName) ? strtoupper($propName) : 'X-PROP'; |
|
404 | + if ('X-PROP' == $propName) { |
|
405 | + if (!$propix) |
|
406 | + $propix = (isset($this->propix[$propName])) ? $this->propix[$propName] + 2 : 1; |
|
407 | 407 | $this->propix[$propName] = --$propix; |
408 | 408 | } |
409 | - switch( $propName ) { |
|
409 | + switch ($propName) { |
|
410 | 410 | case 'CALSCALE': |
411 | - return ( !empty( $this->calscale )) ? $this->calscale : null; |
|
411 | + return (!empty($this->calscale)) ? $this->calscale : null; |
|
412 | 412 | break; |
413 | 413 | case 'METHOD': |
414 | - return ( !empty( $this->method )) ? $this->method : null; |
|
414 | + return (!empty($this->method)) ? $this->method : null; |
|
415 | 415 | break; |
416 | 416 | case 'PRODID': |
417 | - if( empty( $this->prodid )) |
|
417 | + if (empty($this->prodid)) |
|
418 | 418 | $this->_makeProdid(); |
419 | 419 | return $this->prodid; |
420 | 420 | break; |
421 | 421 | case 'VERSION': |
422 | - return ( !empty( $this->version )) ? $this->version : null; |
|
422 | + return (!empty($this->version)) ? $this->version : null; |
|
423 | 423 | break; |
424 | 424 | default: |
425 | - if( $propName != 'X-PROP' ) { |
|
426 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
427 | - return ( $inclParam ) ? array( $propName, $this->xprop[$propName] ) |
|
428 | - : array( $propName, $this->xprop[$propName]['value'] ); |
|
425 | + if ($propName != 'X-PROP') { |
|
426 | + if (!isset($this->xprop[$propName])) return FALSE; |
|
427 | + return ($inclParam) ? array($propName, $this->xprop[$propName]) |
|
428 | + : array($propName, $this->xprop[$propName]['value']); |
|
429 | 429 | } |
430 | 430 | else { |
431 | - if( empty( $this->xprop )) return FALSE; |
|
431 | + if (empty($this->xprop)) return FALSE; |
|
432 | 432 | $xpropno = 0; |
433 | - foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
|
434 | - if( $propix == $xpropno ) |
|
435 | - return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) |
|
436 | - : array( $xpropkey, $this->xprop[$xpropkey]['value'] ); |
|
433 | + foreach ($this->xprop as $xpropkey => $xpropvalue) { |
|
434 | + if ($propix == $xpropno) |
|
435 | + return ($inclParam) ? array($xpropkey, $this->xprop[$xpropkey]) |
|
436 | + : array($xpropkey, $this->xprop[$xpropkey]['value']); |
|
437 | 437 | else |
438 | 438 | $xpropno++; |
439 | 439 | } |
@@ -452,23 +452,23 @@ discard block |
||
452 | 452 | * second ALWAYS component value! |
453 | 453 | * @return bool |
454 | 454 | */ |
455 | - function setProperty () { |
|
455 | + function setProperty() { |
|
456 | 456 | $numargs = func_num_args(); |
457 | - if( 1 > $numargs ) |
|
457 | + if (1 > $numargs) |
|
458 | 458 | return FALSE; |
459 | 459 | $arglist = func_get_args(); |
460 | - $arglist[0] = strtoupper( $arglist[0] ); |
|
461 | - switch( $arglist[0] ) { |
|
460 | + $arglist[0] = strtoupper($arglist[0]); |
|
461 | + switch ($arglist[0]) { |
|
462 | 462 | case 'CALSCALE': |
463 | - return $this->setCalscale( $arglist[1] ); |
|
463 | + return $this->setCalscale($arglist[1]); |
|
464 | 464 | case 'METHOD': |
465 | - return $this->setMethod( $arglist[1] ); |
|
465 | + return $this->setMethod($arglist[1]); |
|
466 | 466 | case 'VERSION': |
467 | - return $this->setVersion( $arglist[1] ); |
|
467 | + return $this->setVersion($arglist[1]); |
|
468 | 468 | default: |
469 | - if( !isset( $arglist[1] )) $arglist[1] = null; |
|
470 | - if( !isset( $arglist[2] )) $arglist[2] = null; |
|
471 | - return $this->setXprop( $arglist[0], $arglist[1], $arglist[2] ); |
|
469 | + if (!isset($arglist[1])) $arglist[1] = null; |
|
470 | + if (!isset($arglist[2])) $arglist[2] = null; |
|
471 | + return $this->setXprop($arglist[0], $arglist[1], $arglist[2]); |
|
472 | 472 | } |
473 | 473 | return FALSE; |
474 | 474 | } |
@@ -481,23 +481,23 @@ discard block |
||
481 | 481 | * @param string $config |
482 | 482 | * @return value |
483 | 483 | */ |
484 | - function getConfig( $config ) { |
|
485 | - switch( strtoupper( $config )) { |
|
484 | + function getConfig($config) { |
|
485 | + switch (strtoupper($config)) { |
|
486 | 486 | case 'ALLOWEMPTY': |
487 | 487 | return $this->allowEmpty; |
488 | 488 | break; |
489 | 489 | case 'COMPSINFO': |
490 | - unset( $this->compix ); |
|
490 | + unset($this->compix); |
|
491 | 491 | $info = array(); |
492 | - foreach( $this->components as $cix => $component ) { |
|
493 | - if( empty( $component )) continue; |
|
494 | - unset( $component->propix ); |
|
492 | + foreach ($this->components as $cix => $component) { |
|
493 | + if (empty($component)) continue; |
|
494 | + unset($component->propix); |
|
495 | 495 | $info[$cix]['ordno'] = $cix + 1; |
496 | 496 | $info[$cix]['type'] = $component->objName; |
497 | - $info[$cix]['uid'] = $component->getProperty( 'uid' ); |
|
498 | - $info[$cix]['props'] = $component->getConfig( 'propinfo' ); |
|
499 | - $info[$cix]['sub'] = $component->getConfig( 'compsinfo' ); |
|
500 | - unset( $component->propix ); |
|
497 | + $info[$cix]['uid'] = $component->getProperty('uid'); |
|
498 | + $info[$cix]['props'] = $component->getConfig('propinfo'); |
|
499 | + $info[$cix]['sub'] = $component->getConfig('compsinfo'); |
|
500 | + unset($component->propix); |
|
501 | 501 | } |
502 | 502 | return $info; |
503 | 503 | break; |
@@ -505,32 +505,32 @@ discard block |
||
505 | 505 | return $this->delimiter; |
506 | 506 | break; |
507 | 507 | case 'DIRECTORY': |
508 | - if( empty( $this->directory )) |
|
508 | + if (empty($this->directory)) |
|
509 | 509 | $this->directory = '.'; |
510 | 510 | return $this->directory; |
511 | 511 | break; |
512 | 512 | case 'DIRFILE': |
513 | - return $this->getConfig( 'directory' ).$this->getConfig( 'delimiter' ).$this->getConfig( 'filename' ); |
|
513 | + return $this->getConfig('directory').$this->getConfig('delimiter').$this->getConfig('filename'); |
|
514 | 514 | break; |
515 | 515 | case 'FILEINFO': |
516 | - return array( $this->getConfig( 'directory' ) |
|
517 | - , $this->getConfig( 'filename' ) |
|
518 | - , $this->getConfig( 'filesize' )); |
|
516 | + return array($this->getConfig('directory') |
|
517 | + , $this->getConfig('filename') |
|
518 | + , $this->getConfig('filesize')); |
|
519 | 519 | break; |
520 | 520 | case 'FILENAME': |
521 | - if( empty( $this->filename )) { |
|
522 | - if( 'xcal' == $this->format ) |
|
523 | - $this->filename = date( 'YmdHis' ).'.xml'; // recommended xcs.. . |
|
521 | + if (empty($this->filename)) { |
|
522 | + if ('xcal' == $this->format) |
|
523 | + $this->filename = date('YmdHis').'.xml'; // recommended xcs.. . |
|
524 | 524 | else |
525 | - $this->filename = date( 'YmdHis' ).'.ics'; |
|
525 | + $this->filename = date('YmdHis').'.ics'; |
|
526 | 526 | } |
527 | 527 | return $this->filename; |
528 | 528 | break; |
529 | 529 | case 'FILESIZE': |
530 | - $size = 0; |
|
531 | - if( empty( $this->url )) { |
|
532 | - $dirfile = $this->getConfig( 'dirfile' ); |
|
533 | - if( FALSE === ( $size = filesize( $dirfile ))) |
|
530 | + $size = 0; |
|
531 | + if (empty($this->url)) { |
|
532 | + $dirfile = $this->getConfig('dirfile'); |
|
533 | + if (FALSE === ($size = filesize($dirfile))) |
|
534 | 534 | $size = 0; |
535 | 535 | clearstatcache(); |
536 | 536 | } |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | return $this->unique_id; |
552 | 552 | break; |
553 | 553 | case 'URL': |
554 | - if( !empty( $this->url )) |
|
554 | + if (!empty($this->url)) |
|
555 | 555 | return $this->url; |
556 | 556 | else |
557 | 557 | return FALSE; |
@@ -567,12 +567,12 @@ discard block |
||
567 | 567 | * @param string $value |
568 | 568 | * @return void |
569 | 569 | */ |
570 | - function setConfig( $config, $value ) { |
|
570 | + function setConfig($config, $value) { |
|
571 | 571 | $res = FALSE; |
572 | - switch( strtoupper( $config )) { |
|
572 | + switch (strtoupper($config)) { |
|
573 | 573 | case 'ALLOWEMPTY': |
574 | 574 | $this->allowEmpty = $value; |
575 | - $subcfg = array( 'ALLOWEMPTY' => $value ); |
|
575 | + $subcfg = array('ALLOWEMPTY' => $value); |
|
576 | 576 | $res = TRUE; |
577 | 577 | break; |
578 | 578 | case 'DELIMITER': |
@@ -580,11 +580,11 @@ discard block |
||
580 | 580 | return TRUE; |
581 | 581 | break; |
582 | 582 | case 'DIRECTORY': |
583 | - $value = trim( $value ); |
|
583 | + $value = trim($value); |
|
584 | 584 | $nl = $this->getConfig('delimiter'); |
585 | - if( $nl == substr( $value, ( 0 - strlen( $nl )))) |
|
586 | - $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl ))); |
|
587 | - if( is_dir( $value )) { |
|
585 | + if ($nl == substr($value, (0 - strlen($nl)))) |
|
586 | + $value = substr($value, 0, (strlen($value) - strlen($nl))); |
|
587 | + if (is_dir($value)) { |
|
588 | 588 | /* local directory */ |
589 | 589 | clearstatcache(); |
590 | 590 | $this->directory = $value; |
@@ -595,16 +595,16 @@ discard block |
||
595 | 595 | return FALSE; |
596 | 596 | break; |
597 | 597 | case 'FILENAME': |
598 | - $value = trim( $value ); |
|
599 | - if( !empty( $this->url )) { |
|
598 | + $value = trim($value); |
|
599 | + if (!empty($this->url)) { |
|
600 | 600 | /* remote directory+file - URL */ |
601 | 601 | $this->filename = $value; |
602 | 602 | return TRUE; |
603 | 603 | } |
604 | - $dirfile = $this->getConfig( 'directory' ).$this->getConfig( 'delimiter' ).$value; |
|
605 | - if( file_exists( $dirfile )) { |
|
604 | + $dirfile = $this->getConfig('directory').$this->getConfig('delimiter').$value; |
|
605 | + if (file_exists($dirfile)) { |
|
606 | 606 | /* local existing file */ |
607 | - if( is_readable( $dirfile ) || is_writable( $dirfile )) { |
|
607 | + if (is_readable($dirfile) || is_writable($dirfile)) { |
|
608 | 608 | clearstatcache(); |
609 | 609 | $this->filename = $value; |
610 | 610 | return TRUE; |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | else |
613 | 613 | return FALSE; |
614 | 614 | } |
615 | - elseif( FALSE !== touch( $dirfile )) { |
|
615 | + elseif (FALSE !== touch($dirfile)) { |
|
616 | 616 | /* new local file created */ |
617 | 617 | $this->filename = $value; |
618 | 618 | return TRUE; |
@@ -621,8 +621,8 @@ discard block |
||
621 | 621 | return FALSE; |
622 | 622 | break; |
623 | 623 | case 'FORMAT': |
624 | - $value = trim( $value ); |
|
625 | - if( 'xcal' == strtolower( $value )) { |
|
624 | + $value = trim($value); |
|
625 | + if ('xcal' == strtolower($value)) { |
|
626 | 626 | $this->format = 'xcal'; |
627 | 627 | $this->attributeDelimiter = $this->nl; |
628 | 628 | $this->valueInit = null; |
@@ -632,46 +632,46 @@ discard block |
||
632 | 632 | $this->attributeDelimiter = ';'; |
633 | 633 | $this->valueInit = ':'; |
634 | 634 | } |
635 | - $subcfg = array( 'FORMAT' => $value ); |
|
635 | + $subcfg = array('FORMAT' => $value); |
|
636 | 636 | $res = TRUE; |
637 | 637 | break; |
638 | 638 | case 'LANGUAGE': |
639 | 639 | // set language for calendar component as defined in [RFC 1766] |
640 | - $value = trim( $value ); |
|
640 | + $value = trim($value); |
|
641 | 641 | $this->language = $value; |
642 | - $subcfg = array( 'LANGUAGE' => $value ); |
|
642 | + $subcfg = array('LANGUAGE' => $value); |
|
643 | 643 | $res = TRUE; |
644 | 644 | break; |
645 | 645 | case 'NL': |
646 | 646 | case 'NEWLINECHAR': |
647 | 647 | $this->nl = $value; |
648 | - $subcfg = array( 'NL' => $value ); |
|
648 | + $subcfg = array('NL' => $value); |
|
649 | 649 | $res = TRUE; |
650 | 650 | break; |
651 | 651 | case 'UNIQUE_ID': |
652 | - $value = trim( $value ); |
|
652 | + $value = trim($value); |
|
653 | 653 | $this->unique_id = $value; |
654 | - $subcfg = array( 'UNIQUE_ID' => $value ); |
|
654 | + $subcfg = array('UNIQUE_ID' => $value); |
|
655 | 655 | $res = TRUE; |
656 | 656 | break; |
657 | 657 | case 'URL': |
658 | 658 | /* remote file - URL */ |
659 | - $value = trim( $value ); |
|
660 | - $value = str_replace( 'HTTP://', 'http://', $value ); |
|
661 | - $value = str_replace( 'WEBCAL://', 'http://', $value ); |
|
662 | - $value = str_replace( 'webcal://', 'http://', $value ); |
|
659 | + $value = trim($value); |
|
660 | + $value = str_replace('HTTP://', 'http://', $value); |
|
661 | + $value = str_replace('WEBCAL://', 'http://', $value); |
|
662 | + $value = str_replace('webcal://', 'http://', $value); |
|
663 | 663 | $this->url = $value; |
664 | 664 | $this->directory = null; |
665 | - $parts = pathinfo( $value ); |
|
666 | - return $this->setConfig( 'filename', $parts['basename'] ); |
|
665 | + $parts = pathinfo($value); |
|
666 | + return $this->setConfig('filename', $parts['basename']); |
|
667 | 667 | break; |
668 | 668 | } |
669 | - if( !$res ) return FALSE; |
|
670 | - if( isset( $subcfg ) && !empty( $this->components )) { |
|
671 | - foreach( $subcfg as $cfgkey => $cfgvalue ) { |
|
672 | - foreach( $this->components as $cix => $component ) { |
|
673 | - $res = $component->setConfig( $cfgkey, $cfgvalue ); |
|
674 | - if( !$res ) |
|
669 | + if (!$res) return FALSE; |
|
670 | + if (isset($subcfg) && !empty($this->components)) { |
|
671 | + foreach ($subcfg as $cfgkey => $cfgvalue) { |
|
672 | + foreach ($this->components as $cix => $component) { |
|
673 | + $res = $component->setConfig($cfgkey, $cfgvalue); |
|
674 | + if (!$res) |
|
675 | 675 | break 2; |
676 | 676 | $this->components[$cix] = $component->copy(); // PHP4 compliant |
677 | 677 | } |
@@ -690,8 +690,8 @@ discard block |
||
690 | 690 | * @param object $component calendar component |
691 | 691 | * @return void |
692 | 692 | */ |
693 | - function addComponent( $component ) { |
|
694 | - $this->setComponent( $component ); |
|
693 | + function addComponent($component) { |
|
694 | + $this->setComponent($component); |
|
695 | 695 | } |
696 | 696 | /** |
697 | 697 | * delete calendar component from container |
@@ -702,33 +702,33 @@ discard block |
||
702 | 702 | * @param mixed $arg2 optional, ordno if arg1 = component type |
703 | 703 | * @return void |
704 | 704 | */ |
705 | - function deleteComponent( $arg1, $arg2=FALSE ) { |
|
705 | + function deleteComponent($arg1, $arg2 = FALSE) { |
|
706 | 706 | $argType = $index = null; |
707 | - if ( ctype_digit( (string) $arg1 )) { |
|
707 | + if (ctype_digit((string) $arg1)) { |
|
708 | 708 | $argType = 'INDEX'; |
709 | 709 | $index = (int) $arg1 - 1; |
710 | 710 | } |
711 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
712 | - $argType = strtolower( $arg1 ); |
|
713 | - $index = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0; |
|
711 | + elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) { |
|
712 | + $argType = strtolower($arg1); |
|
713 | + $index = (!empty($arg2) && ctype_digit((string) $arg2)) ? ((int) $arg2 - 1) : 0; |
|
714 | 714 | } |
715 | 715 | $cix1dC = 0; |
716 | - foreach ( $this->components as $cix => $component) { |
|
717 | - if( empty( $component )) continue; |
|
718 | - unset( $component->propix ); |
|
719 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
|
720 | - unset( $this->components[$cix] ); |
|
716 | + foreach ($this->components as $cix => $component) { |
|
717 | + if (empty($component)) continue; |
|
718 | + unset($component->propix); |
|
719 | + if (('INDEX' == $argType) && ($index == $cix)) { |
|
720 | + unset($this->components[$cix]); |
|
721 | 721 | return TRUE; |
722 | 722 | } |
723 | - elseif( $argType == $component->objName ) { |
|
724 | - if( $index == $cix1dC ) { |
|
725 | - unset( $this->components[$cix] ); |
|
723 | + elseif ($argType == $component->objName) { |
|
724 | + if ($index == $cix1dC) { |
|
725 | + unset($this->components[$cix]); |
|
726 | 726 | return TRUE; |
727 | 727 | } |
728 | 728 | $cix1dC++; |
729 | 729 | } |
730 | - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
731 | - unset( $this->components[$cix] ); |
|
730 | + elseif (!$argType && ($arg1 == $component->getProperty('uid'))) { |
|
731 | + unset($this->components[$cix]); |
|
732 | 732 | return TRUE; |
733 | 733 | } |
734 | 734 | } |
@@ -743,49 +743,49 @@ discard block |
||
743 | 743 | * @param mixed $arg2 optional, ordno if arg1 = component type |
744 | 744 | * @return object |
745 | 745 | */ |
746 | - function getComponent( $arg1=FALSE, $arg2=FALSE ) { |
|
746 | + function getComponent($arg1 = FALSE, $arg2 = FALSE) { |
|
747 | 747 | $index = $argType = null; |
748 | - if ( !$arg1 ) { |
|
748 | + if (!$arg1) { |
|
749 | 749 | $argType = 'INDEX'; |
750 | 750 | $index = $this->compix['INDEX'] = |
751 | - ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1; |
|
751 | + (isset($this->compix['INDEX'])) ? $this->compix['INDEX'] + 1 : 1; |
|
752 | 752 | } |
753 | - elseif ( ctype_digit( (string) $arg1 )) { |
|
753 | + elseif (ctype_digit((string) $arg1)) { |
|
754 | 754 | $argType = 'INDEX'; |
755 | 755 | $index = (int) $arg1; |
756 | - unset( $this->compix ); |
|
756 | + unset($this->compix); |
|
757 | 757 | } |
758 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
759 | - unset( $this->compix['INDEX'] ); |
|
760 | - $argType = strtolower( $arg1 ); |
|
761 | - if( !$arg2 ) |
|
758 | + elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) { |
|
759 | + unset($this->compix['INDEX']); |
|
760 | + $argType = strtolower($arg1); |
|
761 | + if (!$arg2) |
|
762 | 762 | $index = $this->compix[$argType] = |
763 | - ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1; |
|
763 | + (isset($this->compix[$argType])) ? $this->compix[$argType] + 1 : 1; |
|
764 | 764 | else |
765 | 765 | $index = (int) $arg2; |
766 | 766 | } |
767 | - $index -= 1; |
|
768 | - $ckeys = array_keys( $this->components ); |
|
769 | - if( !empty( $index) && ( $index > end( $ckeys ))) |
|
767 | + $index -= 1; |
|
768 | + $ckeys = array_keys($this->components); |
|
769 | + if (!empty($index) && ($index > end($ckeys))) |
|
770 | 770 | return FALSE; |
771 | 771 | $cix1gC = 0; |
772 | - foreach ( $this->components as $cix => $component) { |
|
773 | - if( empty( $component )) continue; |
|
774 | - unset( $component->propix ); |
|
775 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) |
|
772 | + foreach ($this->components as $cix => $component) { |
|
773 | + if (empty($component)) continue; |
|
774 | + unset($component->propix); |
|
775 | + if (('INDEX' == $argType) && ($index == $cix)) |
|
776 | 776 | return $component->copy(); |
777 | - elseif( $argType == $component->objName ) { |
|
778 | - if( $index == $cix1gC ) |
|
777 | + elseif ($argType == $component->objName) { |
|
778 | + if ($index == $cix1gC) |
|
779 | 779 | return $component->copy(); |
780 | 780 | $cix1gC++; |
781 | 781 | } |
782 | - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
783 | - unset( $component->propix ); |
|
782 | + elseif (!$argType && ($arg1 == $component->getProperty('uid'))) { |
|
783 | + unset($component->propix); |
|
784 | 784 | return $component->copy(); |
785 | 785 | } |
786 | 786 | } |
787 | 787 | /* not found.. . */ |
788 | - unset( $this->compix ); |
|
788 | + unset($this->compix); |
|
789 | 789 | return FALSE; |
790 | 790 | } |
791 | 791 | /** |
@@ -812,242 +812,242 @@ discard block |
||
812 | 812 | * FALSE - one occurance of component only in output array</tr> |
813 | 813 | * @return array or FALSE |
814 | 814 | */ |
815 | - function selectComponents( $startY=FALSE, $startM=FALSE, $startD=FALSE, $endY=FALSE, $endM=FALSE, $endD=FALSE, $cType=FALSE, $flat=FALSE, $any=TRUE, $split=TRUE ) { |
|
815 | + function selectComponents($startY = FALSE, $startM = FALSE, $startD = FALSE, $endY = FALSE, $endM = FALSE, $endD = FALSE, $cType = FALSE, $flat = FALSE, $any = TRUE, $split = TRUE) { |
|
816 | 816 | /* check if empty calendar */ |
817 | - if( 0 >= count( $this->components )) return FALSE; |
|
817 | + if (0 >= count($this->components)) return FALSE; |
|
818 | 818 | /* check default dates */ |
819 | - if( !$startY ) $startY = date( 'Y' ); |
|
820 | - if( !$startM ) $startM = date( 'm' ); |
|
821 | - if( !$startD ) $startD = date( 'd' ); |
|
822 | - $startDate = mktime( 0, 0, 0, $startM, $startD, $startY ); |
|
823 | - if( !$endY ) $endY = $startY; |
|
824 | - if( !$endM ) $endM = $startM; |
|
825 | - if( !$endD ) $endD = $startD; |
|
826 | - $endDate = mktime( 23, 59, 59, $endM, $endD, $endY ); |
|
819 | + if (!$startY) $startY = date('Y'); |
|
820 | + if (!$startM) $startM = date('m'); |
|
821 | + if (!$startD) $startD = date('d'); |
|
822 | + $startDate = mktime(0, 0, 0, $startM, $startD, $startY); |
|
823 | + if (!$endY) $endY = $startY; |
|
824 | + if (!$endM) $endM = $startM; |
|
825 | + if (!$endD) $endD = $startD; |
|
826 | + $endDate = mktime(23, 59, 59, $endM, $endD, $endY); |
|
827 | 827 | /* check component types */ |
828 | - $validTypes = array('vevent', 'vtodo', 'vjournal', 'vfreebusy' ); |
|
829 | - if( is_array( $cType )) { |
|
830 | - foreach( $cType as $cix => $theType ) { |
|
831 | - $cType[$cix] = $theType = strtolower( $theType ); |
|
832 | - if( !in_array( $theType, $validTypes )) |
|
828 | + $validTypes = array('vevent', 'vtodo', 'vjournal', 'vfreebusy'); |
|
829 | + if (is_array($cType)) { |
|
830 | + foreach ($cType as $cix => $theType) { |
|
831 | + $cType[$cix] = $theType = strtolower($theType); |
|
832 | + if (!in_array($theType, $validTypes)) |
|
833 | 833 | $cType[$cix] = 'vevent'; |
834 | 834 | } |
835 | - $cType = array_unique( $cType ); |
|
835 | + $cType = array_unique($cType); |
|
836 | 836 | } |
837 | - elseif( !empty( $cType )) { |
|
838 | - $cType = strtolower( $cType ); |
|
839 | - if( !in_array( $cType, $validTypes )) |
|
840 | - $cType = array( 'vevent' ); |
|
837 | + elseif (!empty($cType)) { |
|
838 | + $cType = strtolower($cType); |
|
839 | + if (!in_array($cType, $validTypes)) |
|
840 | + $cType = array('vevent'); |
|
841 | 841 | else |
842 | - $cType = array( $cType ); |
|
842 | + $cType = array($cType); |
|
843 | 843 | } |
844 | 844 | else |
845 | 845 | $cType = $validTypes; |
846 | - if( 0 >= count( $cType )) |
|
846 | + if (0 >= count($cType)) |
|
847 | 847 | $cType = $validTypes; |
848 | 848 | /* iterate components */ |
849 | 849 | $result = array(); |
850 | - foreach ( $this->components as $cix => $component ) { |
|
851 | - if( empty( $component )) continue; |
|
852 | - unset( $component->propix, $start ); |
|
850 | + foreach ($this->components as $cix => $component) { |
|
851 | + if (empty($component)) continue; |
|
852 | + unset($component->propix, $start); |
|
853 | 853 | /* deselect unvalid type components */ |
854 | - if( !in_array( $component->objName, $cType )) continue; |
|
854 | + if (!in_array($component->objName, $cType)) continue; |
|
855 | 855 | /* deselect components without dtstart set */ |
856 | - if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) continue; |
|
856 | + if (FALSE === ($start = $component->getProperty('dtstart'))) continue; |
|
857 | 857 | $dtendExist = $dueExist = $durationExist = $endAllDayEvent = FALSE; |
858 | - unset( $end, $startWdate, $endWdate, $rdurWsecs, $rdur, $exdatelist, $workstart, $workend ); // clean up |
|
859 | - $startWdate = $component->_date2timestamp( $start ); |
|
860 | - $startDateFormat = ( isset( $start['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d'; |
|
858 | + unset($end, $startWdate, $endWdate, $rdurWsecs, $rdur, $exdatelist, $workstart, $workend); // clean up |
|
859 | + $startWdate = $component->_date2timestamp($start); |
|
860 | + $startDateFormat = (isset($start['hour'])) ? 'Y-m-d H:i:s' : 'Y-m-d'; |
|
861 | 861 | /* get end date from dtend/due/duration properties */ |
862 | - $end = $component->getProperty( 'dtend' ); |
|
863 | - if( !empty( $end )) { |
|
862 | + $end = $component->getProperty('dtend'); |
|
863 | + if (!empty($end)) { |
|
864 | 864 | $dtendExist = TRUE; |
865 | - $endDateFormat = ( isset( $end['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d'; |
|
865 | + $endDateFormat = (isset($end['hour'])) ? 'Y-m-d H:i:s' : 'Y-m-d'; |
|
866 | 866 | } |
867 | 867 | // if( !empty($end)) echo 'selectComp 1 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ### |
868 | - if( empty($end) && ( $component->objName == 'vtodo' )) { |
|
869 | - $end = $component->getProperty( 'due' ); |
|
870 | - if( !empty( $end )) { |
|
868 | + if (empty($end) && ($component->objName == 'vtodo')) { |
|
869 | + $end = $component->getProperty('due'); |
|
870 | + if (!empty($end)) { |
|
871 | 871 | $dueExist = TRUE; |
872 | - $endDateFormat = ( isset( $end['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d'; |
|
872 | + $endDateFormat = (isset($end['hour'])) ? 'Y-m-d H:i:s' : 'Y-m-d'; |
|
873 | 873 | } |
874 | 874 | // if( !empty($end)) echo 'selectComp 2 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ### |
875 | 875 | } |
876 | - if( !empty( $end ) && !isset( $end['hour'] )) { |
|
876 | + if (!empty($end) && !isset($end['hour'])) { |
|
877 | 877 | /* a DTEND without time part regards an event that ends the day before, |
878 | 878 | for an all-day event DTSTART=20071201 DTEND=20071202 (taking place 20071201!!! */ |
879 | 879 | $endAllDayEvent = TRUE; |
880 | - $endWdate = mktime( 23, 59, 59, $end['month'], ($end['day'] - 1), $end['year'] ); |
|
881 | - $end['year'] = date( 'Y', $endWdate ); |
|
882 | - $end['month'] = date( 'm', $endWdate ); |
|
883 | - $end['day'] = date( 'd', $endWdate ); |
|
880 | + $endWdate = mktime(23, 59, 59, $end['month'], ($end['day'] - 1), $end['year']); |
|
881 | + $end['year'] = date('Y', $endWdate); |
|
882 | + $end['month'] = date('m', $endWdate); |
|
883 | + $end['day'] = date('d', $endWdate); |
|
884 | 884 | $end['hour'] = 23; |
885 | 885 | $end['min'] = $end['sec'] = 59; |
886 | 886 | // if( !empty($end)) echo 'selectComp 3 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ### |
887 | 887 | } |
888 | - if( empty( $end )) { |
|
889 | - $end = $component->getProperty( 'duration', FALSE, FALSE, TRUE );// in dtend (array) format |
|
890 | - if( !empty( $end )) |
|
888 | + if (empty($end)) { |
|
889 | + $end = $component->getProperty('duration', FALSE, FALSE, TRUE); // in dtend (array) format |
|
890 | + if (!empty($end)) |
|
891 | 891 | $durationExist = TRUE; |
892 | 892 | // if( !empty($end)) echo 'selectComp 4 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ### |
893 | 893 | } |
894 | - if( empty( $end )) { // assume one day duration if missing end date |
|
895 | - $end = array( 'year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'hour' => 23, 'min' => 59, 'sec' => 59 ); |
|
894 | + if (empty($end)) { // assume one day duration if missing end date |
|
895 | + $end = array('year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'hour' => 23, 'min' => 59, 'sec' => 59); |
|
896 | 896 | // if( isset($end)) echo 'selectComp 5 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ### |
897 | 897 | } |
898 | - $endWdate = $component->_date2timestamp( $end ); |
|
899 | - if( $endWdate < $startWdate ) { // MUST be after start date!! |
|
900 | - $end = array( 'year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'hour' => 23, 'min' => 59, 'sec' => 59 ); |
|
901 | - $endWdate = $component->_date2timestamp( $end ); |
|
898 | + $endWdate = $component->_date2timestamp($end); |
|
899 | + if ($endWdate < $startWdate) { // MUST be after start date!! |
|
900 | + $end = array('year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'hour' => 23, 'min' => 59, 'sec' => 59); |
|
901 | + $endWdate = $component->_date2timestamp($end); |
|
902 | 902 | } |
903 | 903 | $rdurWsecs = $endWdate - $startWdate; // compute component duration in seconds |
904 | - $rdur = $component->_date2duration( $start, $end ); // compute component duration, array |
|
904 | + $rdur = $component->_date2duration($start, $end); // compute component duration, array |
|
905 | 905 | /* make a list of optional exclude dates for component occurence from exrule and exdate */ |
906 | 906 | $exdatelist = array(); |
907 | - $workstart = $component->_timestamp2date(( $startDate - $rdurWsecs ), 6); |
|
908 | - $workend = $component->_timestamp2date(( $endDate + $rdurWsecs ), 6); |
|
909 | - while( FALSE !== ( $exrule = $component->getProperty( 'exrule' ))) // check exrule |
|
910 | - $component->_recur2date( $exdatelist, $exrule, $start, $workstart, $workend ); |
|
911 | - while( FALSE !== ( $exdate = $component->getProperty( 'exdate' ))) { // check exdate |
|
912 | - foreach( $exdate as $theExdate ) { |
|
913 | - $exWdate = $component->_date2timestamp( $theExdate ); |
|
914 | - if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate )) |
|
907 | + $workstart = $component->_timestamp2date(($startDate - $rdurWsecs), 6); |
|
908 | + $workend = $component->_timestamp2date(($endDate + $rdurWsecs), 6); |
|
909 | + while (FALSE !== ($exrule = $component->getProperty('exrule'))) // check exrule |
|
910 | + $component->_recur2date($exdatelist, $exrule, $start, $workstart, $workend); |
|
911 | + while (FALSE !== ($exdate = $component->getProperty('exdate'))) { // check exdate |
|
912 | + foreach ($exdate as $theExdate) { |
|
913 | + $exWdate = $component->_date2timestamp($theExdate); |
|
914 | + if ((($startDate - $rdurWsecs) <= $exWdate) && ($endDate >= $exWdate)) |
|
915 | 915 | $exdatelist[$exWdate] = TRUE; |
916 | 916 | } |
917 | 917 | } |
918 | 918 | /* if 'any' components, check repeating components, removing all excluding dates */ |
919 | - if( TRUE === $any ) { |
|
919 | + if (TRUE === $any) { |
|
920 | 920 | /* make a list of optional repeating dates for component occurence, rrule, rdate */ |
921 | 921 | $recurlist = array(); |
922 | - while( FALSE !== ( $rrule = $component->getProperty( 'rrule' ))) // check rrule |
|
923 | - $component->_recur2date( $recurlist, $rrule, $start, $workstart, $workend ); |
|
924 | - foreach( $recurlist as $recurkey => $recurvalue ) // key=match date as timestamp |
|
922 | + while (FALSE !== ($rrule = $component->getProperty('rrule'))) // check rrule |
|
923 | + $component->_recur2date($recurlist, $rrule, $start, $workstart, $workend); |
|
924 | + foreach ($recurlist as $recurkey => $recurvalue) // key=match date as timestamp |
|
925 | 925 | $recurlist[$recurkey] = $rdurWsecs; // add duration in seconds |
926 | - while( FALSE !== ( $rdate = $component->getProperty( 'rdate' ))) { // check rdate |
|
927 | - foreach( $rdate as $theRdate ) { |
|
928 | - if( is_array( $theRdate ) && ( 2 == count( $theRdate )) && // all days within PERIOD |
|
929 | - array_key_exists( '0', $theRdate ) && array_key_exists( '1', $theRdate )) { |
|
930 | - $rstart = $component->_date2timestamp( $theRdate[0] ); |
|
931 | - if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate )) |
|
926 | + while (FALSE !== ($rdate = $component->getProperty('rdate'))) { // check rdate |
|
927 | + foreach ($rdate as $theRdate) { |
|
928 | + if (is_array($theRdate) && (2 == count($theRdate)) && // all days within PERIOD |
|
929 | + array_key_exists('0', $theRdate) && array_key_exists('1', $theRdate)) { |
|
930 | + $rstart = $component->_date2timestamp($theRdate[0]); |
|
931 | + if (($rstart < ($startDate - $rdurWsecs)) || ($rstart > $endDate)) |
|
932 | 932 | continue; |
933 | - if( isset( $theRdate[1]['year'] )) // date-date period |
|
934 | - $rend = $component->_date2timestamp( $theRdate[1] ); |
|
933 | + if (isset($theRdate[1]['year'])) // date-date period |
|
934 | + $rend = $component->_date2timestamp($theRdate[1]); |
|
935 | 935 | else { // date-duration period |
936 | - $rend = $component->duration2date( $theRdate[0], $theRdate[1] ); |
|
937 | - $rend = $component->_date2timestamp( $rend ); |
|
936 | + $rend = $component->duration2date($theRdate[0], $theRdate[1]); |
|
937 | + $rend = $component->_date2timestamp($rend); |
|
938 | 938 | } |
939 | - if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart )) |
|
940 | - $recurlist[$rstart] = ( $rstart - $rend ); // set start date + rdate duration in seconds |
|
939 | + if ((($startDate - $rdurWsecs) <= $rstart) && ($endDate >= $rstart)) |
|
940 | + $recurlist[$rstart] = ($rstart - $rend); // set start date + rdate duration in seconds |
|
941 | 941 | } // PERIOD end |
942 | 942 | else { // single date |
943 | - $theRdate = $component->_date2timestamp( $theRdate ); |
|
944 | - if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate )) |
|
943 | + $theRdate = $component->_date2timestamp($theRdate); |
|
944 | + if ((($startDate - $rdurWsecs) <= $theRdate) && ($endDate >= $theRdate)) |
|
945 | 945 | $recurlist[$theRdate] = $rdurWsecs; // set start date + event duration in seconds |
946 | 946 | } |
947 | 947 | } |
948 | 948 | } |
949 | - if( 0 < count( $recurlist )) { |
|
950 | - ksort( $recurlist ); |
|
951 | - foreach( $recurlist as $recurkey => $durvalue ) { |
|
952 | - if((( $startDate - $rdurWsecs ) > $recurkey ) || ( $endDate < $recurkey )) // not within period |
|
949 | + if (0 < count($recurlist)) { |
|
950 | + ksort($recurlist); |
|
951 | + foreach ($recurlist as $recurkey => $durvalue) { |
|
952 | + if ((($startDate - $rdurWsecs) > $recurkey) || ($endDate < $recurkey)) // not within period |
|
953 | 953 | continue; |
954 | - if( isset( $exdatelist[$recurkey] )) // check excluded dates |
|
954 | + if (isset($exdatelist[$recurkey])) // check excluded dates |
|
955 | 955 | continue; |
956 | - if( $startWdate >= $recurkey ) // exclude component start date |
|
956 | + if ($startWdate >= $recurkey) // exclude component start date |
|
957 | 957 | continue; |
958 | 958 | $component2 = $component->copy(); |
959 | - $rstart = $component2->_timestamp2date( $recurkey, 6); |
|
959 | + $rstart = $component2->_timestamp2date($recurkey, 6); |
|
960 | 960 | $datevalue = $rstart['month'].'/'.$rstart['day'].'/'.$rstart['year']; |
961 | - if( isset( $start['hour'] ) || isset( $start['min'] ) || isset( $start['sec'] )) { |
|
962 | - $datevalue .= ( isset( $rstart['hour'] )) ? ' '.$rstart['hour'] : ' 00'; |
|
963 | - $datevalue .= ( isset( $rstart['min'] )) ? ':'.$rstart['min'] : ':00'; |
|
964 | - $datevalue .= ( isset( $rstart['sec'] )) ? ':'.$rstart['sec'] : ':00'; |
|
961 | + if (isset($start['hour']) || isset($start['min']) || isset($start['sec'])) { |
|
962 | + $datevalue .= (isset($rstart['hour'])) ? ' '.$rstart['hour'] : ' 00'; |
|
963 | + $datevalue .= (isset($rstart['min'])) ? ':'.$rstart['min'] : ':00'; |
|
964 | + $datevalue .= (isset($rstart['sec'])) ? ':'.$rstart['sec'] : ':00'; |
|
965 | 965 | } |
966 | - $datestring = date( $startDateFormat, strtotime( $datevalue )); |
|
967 | - if( isset( $start['tz'] )) |
|
966 | + $datestring = date($startDateFormat, strtotime($datevalue)); |
|
967 | + if (isset($start['tz'])) |
|
968 | 968 | $datestring .= ' '.$start['tz']; |
969 | - $component2->setProperty( 'X-CURRENT-DTSTART', $datestring ); |
|
970 | - $rend = $component2->_timestamp2date(( $recurkey + $durvalue ), 6); |
|
971 | - if( $dtendExist || $dueExist ) { |
|
972 | - if( $endAllDayEvent ) { |
|
973 | - $rend2 = mktime( 0, 0, 0, $rend['month'], ($rend['day'] + 1), $rend['year'] ); |
|
974 | - $datevalue = date( 'm', $rend2 ).'/'.date( 'd', $rend2 ).'/'.date( 'Y', $rend2 ); |
|
969 | + $component2->setProperty('X-CURRENT-DTSTART', $datestring); |
|
970 | + $rend = $component2->_timestamp2date(($recurkey + $durvalue), 6); |
|
971 | + if ($dtendExist || $dueExist) { |
|
972 | + if ($endAllDayEvent) { |
|
973 | + $rend2 = mktime(0, 0, 0, $rend['month'], ($rend['day'] + 1), $rend['year']); |
|
974 | + $datevalue = date('m', $rend2).'/'.date('d', $rend2).'/'.date('Y', $rend2); |
|
975 | 975 | } |
976 | 976 | else { |
977 | 977 | $datevalue = $rend['month'].'/'.$rend['day'].'/'.$rend['year']; |
978 | - if( isset( $end['hour'] ) || isset( $end['min'] ) || isset( $end['sec'] )) { |
|
979 | - $datevalue .= ( isset( $rend['hour'] )) ? ' '.$rend['hour'] : ' 00'; |
|
980 | - $datevalue .= ( isset( $rend['min'] )) ? ':'.$rend['min'] : ':00'; |
|
981 | - $datevalue .= ( isset( $rend['sec'] )) ? ':'.$rend['sec'] : ':00'; |
|
978 | + if (isset($end['hour']) || isset($end['min']) || isset($end['sec'])) { |
|
979 | + $datevalue .= (isset($rend['hour'])) ? ' '.$rend['hour'] : ' 00'; |
|
980 | + $datevalue .= (isset($rend['min'])) ? ':'.$rend['min'] : ':00'; |
|
981 | + $datevalue .= (isset($rend['sec'])) ? ':'.$rend['sec'] : ':00'; |
|
982 | 982 | } |
983 | 983 | } |
984 | - $datestring = date( $endDateFormat, strtotime( $datevalue )); |
|
985 | - if( isset( $end['tz'] )) |
|
984 | + $datestring = date($endDateFormat, strtotime($datevalue)); |
|
985 | + if (isset($end['tz'])) |
|
986 | 986 | $datestring .= ' '.$end['tz']; |
987 | - if( $dtendExist ) |
|
988 | - $component2->setProperty( 'X-CURRENT-DTEND', $datestring ); |
|
989 | - elseif( $dueExist ) |
|
990 | - $component2->setProperty( 'X-CURRENT-DUE', $datestring ); |
|
987 | + if ($dtendExist) |
|
988 | + $component2->setProperty('X-CURRENT-DTEND', $datestring); |
|
989 | + elseif ($dueExist) |
|
990 | + $component2->setProperty('X-CURRENT-DUE', $datestring); |
|
991 | 991 | } |
992 | - $rend = $component2->_date2timestamp( $rend ); |
|
992 | + $rend = $component2->_date2timestamp($rend); |
|
993 | 993 | $rstart = $recurkey; |
994 | 994 | /* add repeating components within valid dates to output array, only start date */ |
995 | - if( $flat ) |
|
995 | + if ($flat) |
|
996 | 996 | $result[] = $component2->copy(); // copy to output |
997 | - elseif( $split ) { |
|
998 | - if( $rend > $endDate ) |
|
997 | + elseif ($split) { |
|
998 | + if ($rend > $endDate) |
|
999 | 999 | $rend = $endDate; |
1000 | - while( $rstart <= $rend ) { // iterate |
|
1001 | - $wd = getdate( $rstart ); |
|
1002 | - if(( $rstart > $startDate ) && // date after dtstart |
|
1003 | - !isset( $exdatelist[$rstart] )) // check exclude date |
|
1000 | + while ($rstart <= $rend) { // iterate |
|
1001 | + $wd = getdate($rstart); |
|
1002 | + if (($rstart > $startDate) && // date after dtstart |
|
1003 | + !isset($exdatelist[$rstart])) // check exclude date |
|
1004 | 1004 | $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output |
1005 | - $rstart += ( 24*60*60 ); // step one day |
|
1005 | + $rstart += (24 * 60 * 60); // step one day |
|
1006 | 1006 | } |
1007 | 1007 | } |
1008 | - elseif(( $rstart >= $startDate ) && // date within period |
|
1009 | - !isset( $exdatelist[$rstart] )) { // check exclude date |
|
1010 | - $wd = getdate( $rstart ); |
|
1008 | + elseif (($rstart >= $startDate) && // date within period |
|
1009 | + !isset($exdatelist[$rstart])) { // check exclude date |
|
1010 | + $wd = getdate($rstart); |
|
1011 | 1011 | $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output |
1012 | 1012 | } |
1013 | 1013 | } |
1014 | 1014 | } |
1015 | 1015 | /* deselect components with startdate/enddate not within period */ |
1016 | - if(( $endWdate < $startDate ) || ( $startWdate > $endDate )) continue; |
|
1016 | + if (($endWdate < $startDate) || ($startWdate > $endDate)) continue; |
|
1017 | 1017 | } |
1018 | 1018 | /* deselect components with startdate not within period */ |
1019 | - elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) continue; |
|
1019 | + elseif (($startWdate < $startDate) || ($startWdate > $endDate)) continue; |
|
1020 | 1020 | /* add selected components within valid dates to output array */ |
1021 | - if( $flat ) |
|
1021 | + if ($flat) |
|
1022 | 1022 | $result[] = $component->copy(); // copy to output; |
1023 | - elseif( $split ) { |
|
1024 | - if( $endWdate > $endDate ) |
|
1025 | - $endWdate = $endDate; // use period end date |
|
1026 | - if( !isset( $exdatelist[$startWdate] )) { // check excluded dates |
|
1027 | - if( $startWdate < $startDate ) |
|
1023 | + elseif ($split) { |
|
1024 | + if ($endWdate > $endDate) |
|
1025 | + $endWdate = $endDate; // use period end date |
|
1026 | + if (!isset($exdatelist[$startWdate])) { // check excluded dates |
|
1027 | + if ($startWdate < $startDate) |
|
1028 | 1028 | $startWdate = $startDate; // use period start date |
1029 | - while( $startWdate <= $endWdate ) { // iterate |
|
1030 | - $wd = getdate( $startWdate ); |
|
1029 | + while ($startWdate <= $endWdate) { // iterate |
|
1030 | + $wd = getdate($startWdate); |
|
1031 | 1031 | $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output |
1032 | - $startWdate += ( 24*60*60 ); // step one day |
|
1032 | + $startWdate += (24 * 60 * 60); // step one day |
|
1033 | 1033 | } |
1034 | 1034 | } |
1035 | 1035 | } // use component date |
1036 | - elseif( !isset( $exdatelist[$startWdate] ) && // check excluded dates |
|
1037 | - ( $startWdate >= $startDate )) { // within period |
|
1038 | - $wd = getdate( $startWdate ); |
|
1036 | + elseif (!isset($exdatelist[$startWdate]) && // check excluded dates |
|
1037 | + ($startWdate >= $startDate)) { // within period |
|
1038 | + $wd = getdate($startWdate); |
|
1039 | 1039 | $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output |
1040 | 1040 | } |
1041 | 1041 | } |
1042 | - if( 0 >= count( $result )) return FALSE; |
|
1043 | - elseif( !$flat ) { |
|
1044 | - foreach( $result as $y => $yeararr ) { |
|
1045 | - foreach( $yeararr as $m => $montharr ) { |
|
1046 | - ksort( $result[$y][$m] ); |
|
1042 | + if (0 >= count($result)) return FALSE; |
|
1043 | + elseif (!$flat) { |
|
1044 | + foreach ($result as $y => $yeararr) { |
|
1045 | + foreach ($yeararr as $m => $montharr) { |
|
1046 | + ksort($result[$y][$m]); |
|
1047 | 1047 | } |
1048 | - ksort( $result[$y] ); |
|
1048 | + ksort($result[$y]); |
|
1049 | 1049 | } |
1050 | - ksort( $result ); |
|
1050 | + ksort($result); |
|
1051 | 1051 | } |
1052 | 1052 | return $result; |
1053 | 1053 | } |
@@ -1061,48 +1061,48 @@ discard block |
||
1061 | 1061 | * @param mixed $arg2 optional, ordno if arg1 = component type |
1062 | 1062 | * @return void |
1063 | 1063 | */ |
1064 | - function setComponent( $component, $arg1=FALSE, $arg2=FALSE ) { |
|
1065 | - if( '' >= $component->getConfig( 'language')) |
|
1066 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
1067 | - $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
|
1068 | - $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
|
1069 | - $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
|
1070 | - $component->setConfig( 'format', $this->getConfig( 'format' )); |
|
1071 | - if( !in_array( $component->objName, array( 'valarm', 'vtimezone' ))) { |
|
1072 | - unset( $component->propix ); |
|
1064 | + function setComponent($component, $arg1 = FALSE, $arg2 = FALSE) { |
|
1065 | + if ('' >= $component->getConfig('language')) |
|
1066 | + $component->setConfig('language', $this->getConfig('language')); |
|
1067 | + $component->setConfig('allowEmpty', $this->getConfig('allowEmpty')); |
|
1068 | + $component->setConfig('nl', $this->getConfig('nl')); |
|
1069 | + $component->setConfig('unique_id', $this->getConfig('unique_id')); |
|
1070 | + $component->setConfig('format', $this->getConfig('format')); |
|
1071 | + if (!in_array($component->objName, array('valarm', 'vtimezone'))) { |
|
1072 | + unset($component->propix); |
|
1073 | 1073 | /* make sure dtstamp and uid is set */ |
1074 | - $dummy1 = $component->getProperty( 'dtstamp' ); |
|
1075 | - $dummy2 = $component->getProperty( 'uid' ); |
|
1074 | + $dummy1 = $component->getProperty('dtstamp'); |
|
1075 | + $dummy2 = $component->getProperty('uid'); |
|
1076 | 1076 | } |
1077 | - if( !$arg1 ) { |
|
1077 | + if (!$arg1) { |
|
1078 | 1078 | $this->components[] = $component->copy(); |
1079 | 1079 | return TRUE; |
1080 | 1080 | } |
1081 | 1081 | $argType = $index = null; |
1082 | - if ( ctype_digit( (string) $arg1 )) { |
|
1082 | + if (ctype_digit((string) $arg1)) { |
|
1083 | 1083 | $argType = 'INDEX'; |
1084 | 1084 | $index = (int) $arg1 - 1; |
1085 | 1085 | } |
1086 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
1087 | - $argType = strtolower( $arg1 ); |
|
1088 | - $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0; |
|
1086 | + elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) { |
|
1087 | + $argType = strtolower($arg1); |
|
1088 | + $index = (ctype_digit((string) $arg2)) ? ((int) $arg2) - 1 : 0; |
|
1089 | 1089 | } |
1090 | 1090 | $cix1sC = 0; |
1091 | - foreach ( $this->components as $cix => $component2) { |
|
1092 | - if( empty( $component2 )) continue; |
|
1093 | - unset( $component2->propix ); |
|
1094 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
|
1091 | + foreach ($this->components as $cix => $component2) { |
|
1092 | + if (empty($component2)) continue; |
|
1093 | + unset($component2->propix); |
|
1094 | + if (('INDEX' == $argType) && ($index == $cix)) { |
|
1095 | 1095 | $this->components[$cix] = $component->copy(); |
1096 | 1096 | return TRUE; |
1097 | 1097 | } |
1098 | - elseif( $argType == $component2->objName ) { |
|
1099 | - if( $index == $cix1sC ) { |
|
1098 | + elseif ($argType == $component2->objName) { |
|
1099 | + if ($index == $cix1sC) { |
|
1100 | 1100 | $this->components[$cix] = $component->copy(); |
1101 | 1101 | return TRUE; |
1102 | 1102 | } |
1103 | 1103 | $cix1sC++; |
1104 | 1104 | } |
1105 | - elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) { |
|
1105 | + elseif (!$argType && ($arg1 == $component2->getProperty('uid'))) { |
|
1106 | 1106 | $this->components[$cix] = $component->copy(); |
1107 | 1107 | return TRUE; |
1108 | 1108 | } |
@@ -1123,79 +1123,79 @@ discard block |
||
1123 | 1123 | * |
1124 | 1124 | */ |
1125 | 1125 | function sort() { |
1126 | - if( is_array( $this->components )) { |
|
1127 | - $this->_sortkeys = array( 'year', 'month', 'day', 'hour', 'min', 'sec' ); |
|
1128 | - usort( $this->components, array( $this, '_cmpfcn' )); |
|
1129 | - } |
|
1130 | - } |
|
1131 | - function _cmpfcn( $a, $b ) { |
|
1132 | - if( empty( $a )) return -1; |
|
1133 | - if( empty( $b )) return 1; |
|
1134 | - if( 'vtimezone' == $a->objName) return -1; |
|
1135 | - if( 'vtimezone' == $b->objName) return 1; |
|
1136 | - $astart = ( isset( $a->xprop['X-CURRENT-DTSTART']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTSTART']['value'] ) : null; |
|
1137 | - if( empty( $astart ) && isset( $a->dtstart['value'] )) |
|
1126 | + if (is_array($this->components)) { |
|
1127 | + $this->_sortkeys = array('year', 'month', 'day', 'hour', 'min', 'sec'); |
|
1128 | + usort($this->components, array($this, '_cmpfcn')); |
|
1129 | + } |
|
1130 | + } |
|
1131 | + function _cmpfcn($a, $b) { |
|
1132 | + if (empty($a)) return -1; |
|
1133 | + if (empty($b)) return 1; |
|
1134 | + if ('vtimezone' == $a->objName) return -1; |
|
1135 | + if ('vtimezone' == $b->objName) return 1; |
|
1136 | + $astart = (isset($a->xprop['X-CURRENT-DTSTART']['value'])) ? $a->_date_time_string($a->xprop['X-CURRENT-DTSTART']['value']) : null; |
|
1137 | + if (empty($astart) && isset($a->dtstart['value'])) |
|
1138 | 1138 | $astart = & $a->dtstart['value']; |
1139 | - $bstart = ( isset( $b->xprop['X-CURRENT-DTSTART']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTSTART']['value'] ) : null; |
|
1140 | - if( empty( $bstart ) && isset( $b->dtstart['value'] )) |
|
1139 | + $bstart = (isset($b->xprop['X-CURRENT-DTSTART']['value'])) ? $b->_date_time_string($b->xprop['X-CURRENT-DTSTART']['value']) : null; |
|
1140 | + if (empty($bstart) && isset($b->dtstart['value'])) |
|
1141 | 1141 | $bstart = & $b->dtstart['value']; |
1142 | - if( empty( $astart )) return -1; |
|
1143 | - elseif( empty( $bstart )) return 1; |
|
1144 | - foreach( $this->_sortkeys as $key ) { |
|
1145 | - if ( empty( $astart[$key] )) return -1; |
|
1146 | - elseif( empty( $bstart[$key] )) return 1; |
|
1147 | - if ( $astart[$key] == $bstart[$key]) continue; |
|
1148 | - if (( (int) $astart[$key] ) < ((int) $bstart[$key] )) |
|
1142 | + if (empty($astart)) return -1; |
|
1143 | + elseif (empty($bstart)) return 1; |
|
1144 | + foreach ($this->_sortkeys as $key) { |
|
1145 | + if (empty($astart[$key])) return -1; |
|
1146 | + elseif (empty($bstart[$key])) return 1; |
|
1147 | + if ($astart[$key] == $bstart[$key]) continue; |
|
1148 | + if (((int) $astart[$key]) < ((int) $bstart[$key])) |
|
1149 | 1149 | return -1; |
1150 | - elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] )) |
|
1150 | + elseif (((int) $astart[$key]) > ((int) $bstart[$key])) |
|
1151 | 1151 | return 1; |
1152 | 1152 | } |
1153 | - $c = ( isset( $a->xprop['X-CURRENT-DTEND']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTEND']['value'] ) : null; |
|
1154 | - if( empty( $c ) && !empty( $a->dtend['value'] )) |
|
1153 | + $c = (isset($a->xprop['X-CURRENT-DTEND']['value'])) ? $a->_date_time_string($a->xprop['X-CURRENT-DTEND']['value']) : null; |
|
1154 | + if (empty($c) && !empty($a->dtend['value'])) |
|
1155 | 1155 | $c = & $a->dtend['value']; |
1156 | - if( empty( $c ) && isset( $a->xprop['X-CURRENT-DUE']['value'] )) |
|
1157 | - $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] ); |
|
1158 | - if( empty( $c ) && !empty( $a->due['value'] )) |
|
1156 | + if (empty($c) && isset($a->xprop['X-CURRENT-DUE']['value'])) |
|
1157 | + $c = $a->_date_time_string($a->xprop['X-CURRENT-DUE']['value']); |
|
1158 | + if (empty($c) && !empty($a->due['value'])) |
|
1159 | 1159 | $c = & $a->due['value']; |
1160 | - if( empty( $c ) && !empty( $a->duration['value'] )) |
|
1160 | + if (empty($c) && !empty($a->duration['value'])) |
|
1161 | 1161 | $c = $a->duration2date(); |
1162 | - $d = ( isset( $b->xprop['X-CURRENT-DTEND']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTEND']['value'] ) : null; |
|
1163 | - if( empty( $d ) && !empty( $b->dtend['value'] )) |
|
1162 | + $d = (isset($b->xprop['X-CURRENT-DTEND']['value'])) ? $b->_date_time_string($b->xprop['X-CURRENT-DTEND']['value']) : null; |
|
1163 | + if (empty($d) && !empty($b->dtend['value'])) |
|
1164 | 1164 | $d = & $b->dtend['value']; |
1165 | - if( empty( $d ) && isset( $b->xprop['X-CURRENT-DUE']['value'] )) |
|
1166 | - $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] ); |
|
1167 | - if( empty( $d ) && !empty( $b->due['value'] )) |
|
1165 | + if (empty($d) && isset($b->xprop['X-CURRENT-DUE']['value'])) |
|
1166 | + $d = $b->_date_time_string($b->xprop['X-CURRENT-DUE']['value']); |
|
1167 | + if (empty($d) && !empty($b->due['value'])) |
|
1168 | 1168 | $d = & $b->due['value']; |
1169 | - if( empty( $d ) && !empty( $b->duration['value'] )) |
|
1169 | + if (empty($d) && !empty($b->duration['value'])) |
|
1170 | 1170 | $d = $b->duration2date(); |
1171 | - if( empty( $c )) return -1; |
|
1172 | - elseif( empty( $d )) return 1; |
|
1173 | - foreach( $this->_sortkeys as $key ) { |
|
1174 | - if ( !isset( $c[$key] )) return -1; |
|
1175 | - elseif( !isset( $d[$key] )) return 1; |
|
1176 | - if ( $c[$key] == $d[$key] ) continue; |
|
1177 | - if (( (int) $c[$key] ) < ((int) $d[$key])) return -1; |
|
1178 | - elseif(( (int) $c[$key] ) > ((int) $d[$key])) return 1; |
|
1179 | - } |
|
1180 | - if( isset( $a->created['value'] )) |
|
1171 | + if (empty($c)) return -1; |
|
1172 | + elseif (empty($d)) return 1; |
|
1173 | + foreach ($this->_sortkeys as $key) { |
|
1174 | + if (!isset($c[$key])) return -1; |
|
1175 | + elseif (!isset($d[$key])) return 1; |
|
1176 | + if ($c[$key] == $d[$key]) continue; |
|
1177 | + if (((int) $c[$key]) < ((int) $d[$key])) return -1; |
|
1178 | + elseif (((int) $c[$key]) > ((int) $d[$key])) return 1; |
|
1179 | + } |
|
1180 | + if (isset($a->created['value'])) |
|
1181 | 1181 | $e = & $a->created['value']; |
1182 | 1182 | else |
1183 | 1183 | $e = & $a->dtstamp['value']; |
1184 | - if( isset( $b->created['value'] )) |
|
1184 | + if (isset($b->created['value'])) |
|
1185 | 1185 | $f = & $b->created['value']; |
1186 | 1186 | else |
1187 | 1187 | $f = & $b->dtstamp['value']; |
1188 | - foreach( $this->_sortkeys as $key ) { |
|
1189 | - if( !isset( $e[$key] )) return -1; |
|
1190 | - elseif( !isset( $f[$key] )) return 1; |
|
1191 | - if ( $e[$key] == $f[$key] ) continue; |
|
1192 | - if (( (int) $e[$key] ) < ((int) $f[$key])) return -1; |
|
1193 | - elseif(( (int) $e[$key] ) > ((int) $f[$key])) return 1; |
|
1194 | - } |
|
1195 | - if (( $a->uid['value'] ) < |
|
1196 | - ( $b->uid['value'] )) return -1; |
|
1197 | - elseif(( $a->uid['value'] ) > |
|
1198 | - ( $b->uid['value'] )) return 1; |
|
1188 | + foreach ($this->_sortkeys as $key) { |
|
1189 | + if (!isset($e[$key])) return -1; |
|
1190 | + elseif (!isset($f[$key])) return 1; |
|
1191 | + if ($e[$key] == $f[$key]) continue; |
|
1192 | + if (((int) $e[$key]) < ((int) $f[$key])) return -1; |
|
1193 | + elseif (((int) $e[$key]) > ((int) $f[$key])) return 1; |
|
1194 | + } |
|
1195 | + if (($a->uid['value']) < |
|
1196 | + ($b->uid['value'])) return -1; |
|
1197 | + elseif (($a->uid['value']) > |
|
1198 | + ($b->uid['value'])) return 1; |
|
1199 | 1199 | return 0; |
1200 | 1200 | } |
1201 | 1201 | /** |
@@ -1207,104 +1207,104 @@ discard block |
||
1207 | 1207 | * @return bool FALSE if error occurs during parsing |
1208 | 1208 | * |
1209 | 1209 | */ |
1210 | - function parse( $filename=FALSE ) { |
|
1211 | - if( !$filename ) { |
|
1210 | + function parse($filename = FALSE) { |
|
1211 | + if (!$filename) { |
|
1212 | 1212 | /* directory/filename previous set via setConfig directory+filename / url */ |
1213 | - if( FALSE === ( $filename = $this->getConfig( 'url' ))) |
|
1214 | - $filename = $this->getConfig( 'dirfile' ); |
|
1213 | + if (FALSE === ($filename = $this->getConfig('url'))) |
|
1214 | + $filename = $this->getConfig('dirfile'); |
|
1215 | 1215 | } |
1216 | - elseif(( 'http://' == strtolower( substr( $filename, 0, 7 ))) || |
|
1217 | - ( 'webcal://' == strtolower( substr( $filename, 0, 9 )))) { |
|
1216 | + elseif (('http://' == strtolower(substr($filename, 0, 7))) || |
|
1217 | + ('webcal://' == strtolower(substr($filename, 0, 9)))) { |
|
1218 | 1218 | /* remote file - URL */ |
1219 | - $this->setConfig( 'URL', $filename ); |
|
1220 | - if( !$filename = $this->getConfig( 'url' )) |
|
1221 | - return FALSE; /* err 2 */ |
|
1219 | + $this->setConfig('URL', $filename); |
|
1220 | + if (!$filename = $this->getConfig('url')) |
|
1221 | + return FALSE; /* err 2 */ |
|
1222 | 1222 | } |
1223 | 1223 | else { |
1224 | 1224 | /* local directory/filename */ |
1225 | - $parts = pathinfo( $filename ); |
|
1226 | - if( !empty( $parts['dirname'] ) && ( '.' != $parts['dirname'] )) { |
|
1227 | - if( !$this->setConfig( 'directory', $parts['dirname'] )) |
|
1228 | - return FALSE; /* err 3 */ |
|
1225 | + $parts = pathinfo($filename); |
|
1226 | + if (!empty($parts['dirname']) && ('.' != $parts['dirname'])) { |
|
1227 | + if (!$this->setConfig('directory', $parts['dirname'])) |
|
1228 | + return FALSE; /* err 3 */ |
|
1229 | 1229 | } |
1230 | - if( !$this->setConfig( 'filename', $parts['basename'] )) |
|
1231 | - return FALSE; /* err 4 */ |
|
1230 | + if (!$this->setConfig('filename', $parts['basename'])) |
|
1231 | + return FALSE; /* err 4 */ |
|
1232 | 1232 | } |
1233 | - if( 'http://' != substr( $filename, 0, 7 )) { |
|
1233 | + if ('http://' != substr($filename, 0, 7)) { |
|
1234 | 1234 | /* local file error tests */ |
1235 | - if( !is_file( $filename )) /* err 5 */ |
|
1235 | + if (!is_file($filename)) /* err 5 */ |
|
1236 | 1236 | return FALSE; |
1237 | - if( !is_readable( $filename )) |
|
1238 | - return FALSE; /* err 6 */ |
|
1239 | - if( !filesize( $filename )) |
|
1240 | - return FALSE; /* err 7 */ |
|
1237 | + if (!is_readable($filename)) |
|
1238 | + return FALSE; /* err 6 */ |
|
1239 | + if (!filesize($filename)) |
|
1240 | + return FALSE; /* err 7 */ |
|
1241 | 1241 | clearstatcache(); |
1242 | 1242 | } |
1243 | 1243 | /* READ FILE */ |
1244 | - if( FALSE === ( $rows = file( $filename ))) |
|
1245 | - return FALSE; /* err 1 */ |
|
1244 | + if (FALSE === ($rows = file($filename))) |
|
1245 | + return FALSE; /* err 1 */ |
|
1246 | 1246 | /* identify BEGIN:VCALENDAR, MUST be first row */ |
1247 | - if( 'BEGIN:VCALENDAR' != strtoupper( trim( $rows[0] ))) |
|
1248 | - return FALSE; /* err 8 */ |
|
1247 | + if ('BEGIN:VCALENDAR' != strtoupper(trim($rows[0]))) |
|
1248 | + return FALSE; /* err 8 */ |
|
1249 | 1249 | /* remove empty trailing lines */ |
1250 | - while( '' == trim( $rows[count( $rows ) - 1] )) { |
|
1251 | - unset( $rows[count( $rows ) - 1] ); |
|
1252 | - $rows = array_values( $rows ); |
|
1250 | + while ('' == trim($rows[count($rows) - 1])) { |
|
1251 | + unset($rows[count($rows) - 1]); |
|
1252 | + $rows = array_values($rows); |
|
1253 | 1253 | } |
1254 | 1254 | /* identify ending END:VCALENDAR row */ |
1255 | - if( 'END:VCALENDAR' != strtoupper( trim( $rows[count( $rows ) - 1] ))) { |
|
1256 | - return FALSE; /* err 9 */ |
|
1255 | + if ('END:VCALENDAR' != strtoupper(trim($rows[count($rows) - 1]))) { |
|
1256 | + return FALSE; /* err 9 */ |
|
1257 | 1257 | } |
1258 | - if( 3 > count( $rows )) |
|
1259 | - return FALSE; /* err 10 */ |
|
1258 | + if (3 > count($rows)) |
|
1259 | + return FALSE; /* err 10 */ |
|
1260 | 1260 | $comp = $subcomp = null; |
1261 | 1261 | $actcomp = & $this; |
1262 | - $nl = $this->getConfig( 'nl' ); |
|
1262 | + $nl = $this->getConfig('nl'); |
|
1263 | 1263 | $calsync = 0; |
1264 | 1264 | /* identify components and update unparsed data within component */ |
1265 | - foreach( $rows as $line ) { |
|
1266 | - if( '' == trim( $line )) |
|
1265 | + foreach ($rows as $line) { |
|
1266 | + if ('' == trim($line)) |
|
1267 | 1267 | continue; |
1268 | - if( $nl == substr( $line, 0 - strlen( $nl ))) |
|
1269 | - $line = substr( $line, 0, ( strlen( $line ) - strlen( $nl ))).'\n'; |
|
1270 | - if( 'BEGIN:VCALENDAR' == strtoupper( substr( $line, 0, 15 ))) { |
|
1268 | + if ($nl == substr($line, 0 - strlen($nl))) |
|
1269 | + $line = substr($line, 0, (strlen($line) - strlen($nl))).'\n'; |
|
1270 | + if ('BEGIN:VCALENDAR' == strtoupper(substr($line, 0, 15))) { |
|
1271 | 1271 | $calsync++; |
1272 | 1272 | continue; |
1273 | 1273 | } |
1274 | - elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) { |
|
1274 | + elseif ('END:VCALENDAR' == strtoupper(substr($line, 0, 13))) { |
|
1275 | 1275 | $calsync--; |
1276 | 1276 | continue; |
1277 | 1277 | } |
1278 | - elseif( 1 != $calsync ) |
|
1279 | - return FALSE; /* err 20 */ |
|
1280 | - if( 'END:' == strtoupper( substr( $line, 0, 4 ))) { |
|
1281 | - if( null != $subcomp ) { |
|
1282 | - $comp->setComponent( $subcomp ); |
|
1278 | + elseif (1 != $calsync) |
|
1279 | + return FALSE; /* err 20 */ |
|
1280 | + if ('END:' == strtoupper(substr($line, 0, 4))) { |
|
1281 | + if (null != $subcomp) { |
|
1282 | + $comp->setComponent($subcomp); |
|
1283 | 1283 | $subcomp = null; |
1284 | 1284 | } |
1285 | 1285 | else { |
1286 | - $this->setComponent( $comp ); |
|
1286 | + $this->setComponent($comp); |
|
1287 | 1287 | $comp = null; |
1288 | 1288 | } |
1289 | 1289 | $actcomp = null; |
1290 | 1290 | continue; |
1291 | 1291 | } // end - if ( 'END:' ==.. . |
1292 | - elseif( 'BEGIN:' == strtoupper( substr( $line, 0, 6 ))) { |
|
1293 | - $line = str_replace( '\n', '', $line ); |
|
1294 | - $compname = trim (strtoupper( substr( $line, 6 ))); |
|
1295 | - if( null != $comp ) { |
|
1296 | - if( 'VALARM' == $compname ) |
|
1292 | + elseif ('BEGIN:' == strtoupper(substr($line, 0, 6))) { |
|
1293 | + $line = str_replace('\n', '', $line); |
|
1294 | + $compname = trim(strtoupper(substr($line, 6))); |
|
1295 | + if (null != $comp) { |
|
1296 | + if ('VALARM' == $compname) |
|
1297 | 1297 | $subcomp = new valarm(); |
1298 | - elseif( 'STANDARD' == $compname ) |
|
1299 | - $subcomp = new vtimezone( 'STANDARD' ); |
|
1300 | - elseif( 'DAYLIGHT' == $compname ) |
|
1301 | - $subcomp = new vtimezone( 'DAYLIGHT' ); |
|
1298 | + elseif ('STANDARD' == $compname) |
|
1299 | + $subcomp = new vtimezone('STANDARD'); |
|
1300 | + elseif ('DAYLIGHT' == $compname) |
|
1301 | + $subcomp = new vtimezone('DAYLIGHT'); |
|
1302 | 1302 | else |
1303 | 1303 | return FALSE; /* err 6 */ |
1304 | 1304 | $actcomp = & $subcomp; |
1305 | 1305 | } |
1306 | 1306 | else { |
1307 | - switch( $compname ) { |
|
1307 | + switch ($compname) { |
|
1308 | 1308 | case 'VALARM': |
1309 | 1309 | $comp = new valarm(); |
1310 | 1310 | break; |
@@ -1335,74 +1335,74 @@ discard block |
||
1335 | 1335 | $actcomp->unparsed[] = $line; |
1336 | 1336 | } // end - foreach( rows.. . |
1337 | 1337 | /* parse data for calendar (this) object */ |
1338 | - if( is_array( $this->unparsed ) && ( 0 < count( $this->unparsed ))) { |
|
1338 | + if (is_array($this->unparsed) && (0 < count($this->unparsed))) { |
|
1339 | 1339 | /* concatenate property values spread over several lines */ |
1340 | 1340 | $lastix = -1; |
1341 | - $propnames = array( 'calscale','method','prodid','version','x-' ); |
|
1341 | + $propnames = array('calscale', 'method', 'prodid', 'version', 'x-'); |
|
1342 | 1342 | $proprows = array(); |
1343 | - foreach( $this->unparsed as $line ) { |
|
1343 | + foreach ($this->unparsed as $line) { |
|
1344 | 1344 | $newProp = FALSE; |
1345 | - foreach ( $propnames as $propname ) { |
|
1346 | - if( $propname == strtolower( substr( $line, 0, strlen( $propname )))) { |
|
1345 | + foreach ($propnames as $propname) { |
|
1346 | + if ($propname == strtolower(substr($line, 0, strlen($propname)))) { |
|
1347 | 1347 | $newProp = TRUE; |
1348 | 1348 | break; |
1349 | 1349 | } |
1350 | 1350 | } |
1351 | - if( $newProp ) { |
|
1351 | + if ($newProp) { |
|
1352 | 1352 | $newProp = FALSE; |
1353 | 1353 | $lastix++; |
1354 | - $proprows[$lastix] = $line; |
|
1354 | + $proprows[$lastix] = $line; |
|
1355 | 1355 | } |
1356 | 1356 | else { |
1357 | 1357 | /* remove line breaks */ |
1358 | - if(( '\n' == substr( $proprows[$lastix], -2 )) && |
|
1359 | - ( ' ' == substr( $line, 0, 1 ))) { |
|
1360 | - $proprows[$lastix] = substr( $proprows[$lastix], 0, strlen( $proprows[$lastix] ) - 2 ); |
|
1361 | - $line = substr( $line, 1 ); |
|
1358 | + if (('\n' == substr($proprows[$lastix], -2)) && |
|
1359 | + (' ' == substr($line, 0, 1))) { |
|
1360 | + $proprows[$lastix] = substr($proprows[$lastix], 0, strlen($proprows[$lastix]) - 2); |
|
1361 | + $line = substr($line, 1); |
|
1362 | 1362 | } |
1363 | 1363 | $proprows[$lastix] .= $line; |
1364 | 1364 | } |
1365 | 1365 | } |
1366 | 1366 | $toolbox = new calendarComponent(); |
1367 | - foreach( $proprows as $line ) { |
|
1368 | - if( '\n' == substr( $line, -2 )) |
|
1369 | - $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
1367 | + foreach ($proprows as $line) { |
|
1368 | + if ('\n' == substr($line, -2)) |
|
1369 | + $line = substr($line, 0, strlen($line) - 2); |
|
1370 | 1370 | /* get propname */ |
1371 | 1371 | $cix = $propname = null; |
1372 | - for( $cix=0; $cix < strlen( $line ); $cix++ ) { |
|
1373 | - if( in_array( $line{$cix}, array( ':', ';' ))) |
|
1372 | + for ($cix = 0; $cix < strlen($line); $cix++) { |
|
1373 | + if (in_array($line{$cix}, array(':', ';'))) |
|
1374 | 1374 | break; |
1375 | 1375 | else |
1376 | 1376 | $propname .= $line{$cix}; |
1377 | 1377 | } |
1378 | 1378 | /* ignore version/prodid properties */ |
1379 | - if( in_array( strtoupper( $propname ), array( 'VERSION', 'PRODID' ))) |
|
1379 | + if (in_array(strtoupper($propname), array('VERSION', 'PRODID'))) |
|
1380 | 1380 | continue; |
1381 | - $line = substr( $line, $cix); |
|
1381 | + $line = substr($line, $cix); |
|
1382 | 1382 | /* separate attributes from value */ |
1383 | 1383 | $attr = array(); |
1384 | 1384 | $attrix = -1; |
1385 | - $strlen = strlen( $line ); |
|
1386 | - for( $cix=0; $cix < $strlen; $cix++ ) { |
|
1387 | - if(( ':' == $line{$cix} ) && |
|
1388 | - ( '://' != substr( $line, $cix, 3 )) && |
|
1389 | - ( 'mailto:' != strtolower( substr( $line, $cix - 6, 7 )))) { |
|
1385 | + $strlen = strlen($line); |
|
1386 | + for ($cix = 0; $cix < $strlen; $cix++) { |
|
1387 | + if ((':' == $line{$cix} ) && |
|
1388 | + ('://' != substr($line, $cix, 3)) && |
|
1389 | + ('mailto:' != strtolower(substr($line, $cix - 6, 7)))) { |
|
1390 | 1390 | $attrEnd = TRUE; |
1391 | - if(( $cix < ( $strlen - 4 )) && |
|
1392 | - ctype_digit( substr( $line, $cix+1, 4 ))) { // an URI with a (4pos) portnr?? |
|
1393 | - for( $c2ix = $cix; 3 < $c2ix; $c2ix-- ) { |
|
1394 | - if( '://' == substr( $line, $c2ix - 2, 3 )) { |
|
1391 | + if (($cix < ($strlen - 4)) && |
|
1392 | + ctype_digit(substr($line, $cix + 1, 4))) { // an URI with a (4pos) portnr?? |
|
1393 | + for ($c2ix = $cix; 3 < $c2ix; $c2ix--) { |
|
1394 | + if ('://' == substr($line, $c2ix - 2, 3)) { |
|
1395 | 1395 | $attrEnd = FALSE; |
1396 | 1396 | break; // an URI with a portnr!! |
1397 | 1397 | } |
1398 | 1398 | } |
1399 | 1399 | } |
1400 | - if( $attrEnd) { |
|
1401 | - $line = substr( $line, $cix + 1 ); |
|
1400 | + if ($attrEnd) { |
|
1401 | + $line = substr($line, $cix + 1); |
|
1402 | 1402 | break; |
1403 | 1403 | } |
1404 | 1404 | } |
1405 | - if( ';' == $line{$cix} ) |
|
1405 | + if (';' == $line{$cix} ) |
|
1406 | 1406 | $attr[++$attrix] = null; |
1407 | 1407 | else |
1408 | 1408 | $attr[$attrix] .= $line{$cix}; |
@@ -1410,46 +1410,46 @@ discard block |
||
1410 | 1410 | |
1411 | 1411 | /* make attributes in array format */ |
1412 | 1412 | $propattr = array(); |
1413 | - foreach( $attr as $attribute ) { |
|
1414 | - $attrsplit = explode( '=', $attribute, 2 ); |
|
1415 | - if( 1 < count( $attrsplit )) |
|
1413 | + foreach ($attr as $attribute) { |
|
1414 | + $attrsplit = explode('=', $attribute, 2); |
|
1415 | + if (1 < count($attrsplit)) |
|
1416 | 1416 | $propattr[$attrsplit[0]] = $attrsplit[1]; |
1417 | 1417 | else |
1418 | 1418 | $propattr[] = $attribute; |
1419 | 1419 | } |
1420 | 1420 | /* update Property */ |
1421 | - if( FALSE !== strpos( $line, ',' )) { |
|
1422 | - $content = explode( ',', $line ); |
|
1423 | - $clen = count( $content ); |
|
1424 | - for( $cix = 0; $cix < $clen; $cix++ ) { |
|
1425 | - if( "\\" == substr( $content[$cix], -1 )) { |
|
1421 | + if (FALSE !== strpos($line, ',')) { |
|
1422 | + $content = explode(',', $line); |
|
1423 | + $clen = count($content); |
|
1424 | + for ($cix = 0; $cix < $clen; $cix++) { |
|
1425 | + if ("\\" == substr($content[$cix], -1)) { |
|
1426 | 1426 | $content[$cix] .= ','.$content[$cix + 1]; |
1427 | - unset( $content[$cix + 1] ); |
|
1427 | + unset($content[$cix + 1]); |
|
1428 | 1428 | $cix++; |
1429 | 1429 | } |
1430 | 1430 | } |
1431 | - if( 1 < count( $content )) { |
|
1432 | - foreach( $content as $cix => $contentPart ) |
|
1433 | - $content[$cix] = $toolbox->_strunrep( $contentPart ); |
|
1434 | - $this->setProperty( $propname, $content, $propattr ); |
|
1431 | + if (1 < count($content)) { |
|
1432 | + foreach ($content as $cix => $contentPart) |
|
1433 | + $content[$cix] = $toolbox->_strunrep($contentPart); |
|
1434 | + $this->setProperty($propname, $content, $propattr); |
|
1435 | 1435 | continue; |
1436 | 1436 | } |
1437 | 1437 | else |
1438 | - $line = reset( $content ); |
|
1439 | - $line = $toolbox->_strunrep( $line ); |
|
1438 | + $line = reset($content); |
|
1439 | + $line = $toolbox->_strunrep($line); |
|
1440 | 1440 | } |
1441 | - $this->setProperty( $propname, trim( $line ), $propattr ); |
|
1441 | + $this->setProperty($propname, trim($line), $propattr); |
|
1442 | 1442 | } // end - foreach( $this->unparsed.. . |
1443 | 1443 | } // end - if( is_array( $this->unparsed.. . |
1444 | 1444 | /* parse Components */ |
1445 | - if( is_array( $this->components ) && ( 0 < count( $this->components ))) { |
|
1446 | - for( $six = 0; $six < count( $this->components ); $six++ ) { |
|
1447 | - if( !empty( $this->components[$six] )) |
|
1445 | + if (is_array($this->components) && (0 < count($this->components))) { |
|
1446 | + for ($six = 0; $six < count($this->components); $six++) { |
|
1447 | + if (!empty($this->components[$six])) |
|
1448 | 1448 | $this->components[$six]->parse(); |
1449 | 1449 | } |
1450 | 1450 | } |
1451 | 1451 | else |
1452 | - return FALSE; /* err 91 or something.. . */ |
|
1452 | + return FALSE; /* err 91 or something.. . */ |
|
1453 | 1453 | return TRUE; |
1454 | 1454 | } |
1455 | 1455 | /*********************************************************************************/ |
@@ -1462,7 +1462,7 @@ discard block |
||
1462 | 1462 | */ |
1463 | 1463 | function createCalendar() { |
1464 | 1464 | $calendarInit1 = $calendarInit2 = $calendarxCaldecl = $calendarStart = $calendar = null; |
1465 | - switch( $this->format ) { |
|
1465 | + switch ($this->format) { |
|
1466 | 1466 | case 'xcal': |
1467 | 1467 | $calendarInit1 = '<?xml version="1.0" encoding="UTF-8"?>'.$this->nl. |
1468 | 1468 | '<!DOCTYPE iCalendar PUBLIC "-//IETF//DTD XCAL/iCalendar XML//EN"'.$this->nl. |
@@ -1478,38 +1478,38 @@ discard block |
||
1478 | 1478 | $calendarStart .= $this->createMethod(); |
1479 | 1479 | $calendarStart .= $this->createProdid(); |
1480 | 1480 | $calendarStart .= $this->createVersion(); |
1481 | - switch( $this->format ) { |
|
1481 | + switch ($this->format) { |
|
1482 | 1482 | case 'xcal': |
1483 | - $nlstrlen = strlen( $this->nl ); |
|
1484 | - if( $this->nl == substr( $calendarStart, ( 0 - $nlstrlen ))) |
|
1485 | - $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen )); |
|
1483 | + $nlstrlen = strlen($this->nl); |
|
1484 | + if ($this->nl == substr($calendarStart, (0 - $nlstrlen))) |
|
1485 | + $calendarStart = substr($calendarStart, 0, (strlen($calendarStart) - $nlstrlen)); |
|
1486 | 1486 | $calendarStart .= '>'.$this->nl; |
1487 | 1487 | break; |
1488 | 1488 | default: |
1489 | 1489 | break; |
1490 | 1490 | } |
1491 | 1491 | $calendar .= $this->createXprop(); |
1492 | - foreach( $this->components as $component ) { |
|
1493 | - if( empty( $component )) continue; |
|
1494 | - if( '' >= $component->getConfig( 'language')) |
|
1495 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
1496 | - $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
|
1497 | - $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
|
1498 | - $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
|
1499 | - $component->setConfig( 'format', $this->getConfig( 'format' )); |
|
1500 | - $calendar .= $component->createComponent( $this->xcaldecl ); |
|
1501 | - } |
|
1502 | - if(( 0 < count( $this->xcaldecl )) && ( 'xcal' == $this->format )) { // xCal only |
|
1492 | + foreach ($this->components as $component) { |
|
1493 | + if (empty($component)) continue; |
|
1494 | + if ('' >= $component->getConfig('language')) |
|
1495 | + $component->setConfig('language', $this->getConfig('language')); |
|
1496 | + $component->setConfig('allowEmpty', $this->getConfig('allowEmpty')); |
|
1497 | + $component->setConfig('nl', $this->getConfig('nl')); |
|
1498 | + $component->setConfig('unique_id', $this->getConfig('unique_id')); |
|
1499 | + $component->setConfig('format', $this->getConfig('format')); |
|
1500 | + $calendar .= $component->createComponent($this->xcaldecl); |
|
1501 | + } |
|
1502 | + if ((0 < count($this->xcaldecl)) && ('xcal' == $this->format)) { // xCal only |
|
1503 | 1503 | $calendarInit1 .= $this->nl.'['.$this->nl; |
1504 | 1504 | $old_xcaldecl = array(); |
1505 | - foreach( $this->xcaldecl as $declix => $declPart ) { |
|
1506 | - if(( 0 < count( $old_xcaldecl)) && |
|
1507 | - ( in_array( $declPart['uri'], $old_xcaldecl['uri'] )) && |
|
1508 | - ( in_array( $declPart['external'], $old_xcaldecl['external'] ))) |
|
1505 | + foreach ($this->xcaldecl as $declix => $declPart) { |
|
1506 | + if ((0 < count($old_xcaldecl)) && |
|
1507 | + (in_array($declPart['uri'], $old_xcaldecl['uri'])) && |
|
1508 | + (in_array($declPart['external'], $old_xcaldecl['external']))) |
|
1509 | 1509 | continue; // no duplicate uri and ext. references |
1510 | 1510 | $calendarxCaldecl .= '<!'; |
1511 | - foreach( $declPart as $declKey => $declValue ) { |
|
1512 | - switch( $declKey ) { // index |
|
1511 | + foreach ($declPart as $declKey => $declValue) { |
|
1512 | + switch ($declKey) { // index |
|
1513 | 1513 | case 'xmldecl': // no 1 |
1514 | 1514 | $calendarxCaldecl .= $declValue.' '; |
1515 | 1515 | break; |
@@ -1536,7 +1536,7 @@ discard block |
||
1536 | 1536 | } |
1537 | 1537 | $calendarInit2 = ']'.$calendarInit2; |
1538 | 1538 | } |
1539 | - switch( $this->format ) { |
|
1539 | + switch ($this->format) { |
|
1540 | 1540 | case 'xcal': |
1541 | 1541 | $calendar .= '</vcalendar>'.$this->nl; |
1542 | 1542 | break; |
@@ -1554,18 +1554,18 @@ discard block |
||
1554 | 1554 | * @return redirect |
1555 | 1555 | */ |
1556 | 1556 | function returnCalendar() { |
1557 | - $filename = $this->getConfig( 'filename' ); |
|
1557 | + $filename = $this->getConfig('filename'); |
|
1558 | 1558 | $output = $this->createCalendar(); |
1559 | - $filesize = strlen( $output ); |
|
1559 | + $filesize = strlen($output); |
|
1560 | 1560 | // if( headers_sent( $filename, $linenum )) |
1561 | 1561 | // die( "Headers already sent in $filename on line $linenum\n" ); |
1562 | - if( 'xcal' == $this->format ) |
|
1563 | - header( 'Content-Type: application/calendar+xml; charset=utf-8' ); |
|
1562 | + if ('xcal' == $this->format) |
|
1563 | + header('Content-Type: application/calendar+xml; charset=utf-8'); |
|
1564 | 1564 | else |
1565 | - header( 'Content-Type: text/calendar; charset=utf-8' ); |
|
1566 | - header( 'Content-Length: '.$filesize ); |
|
1567 | - header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
|
1568 | - header( 'Cache-Control: max-age=10' ); |
|
1565 | + header('Content-Type: text/calendar; charset=utf-8'); |
|
1566 | + header('Content-Length: '.$filesize); |
|
1567 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
1568 | + header('Cache-Control: max-age=10'); |
|
1569 | 1569 | echo $output; |
1570 | 1570 | die(); |
1571 | 1571 | } |
@@ -1579,20 +1579,20 @@ discard block |
||
1579 | 1579 | * @param string $delimiter optional |
1580 | 1580 | * @return bool |
1581 | 1581 | */ |
1582 | - function saveCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE ) { |
|
1583 | - if( $directory ) |
|
1584 | - $this->setConfig( 'directory', $directory ); |
|
1585 | - if( $filename ) |
|
1586 | - $this->setConfig( 'filename', $filename ); |
|
1587 | - if( $delimiter && ($delimiter != DIRECTORY_SEPARATOR )) |
|
1588 | - $this->setConfig( 'delimiter', $delimiter ); |
|
1589 | - if( FALSE === ( $dirfile = $this->getConfig( 'url' ))) |
|
1590 | - $dirfile = $this->getConfig( 'dirfile' ); |
|
1591 | - $iCalFile = @fopen( $dirfile, 'w' ); |
|
1592 | - if( $iCalFile ) { |
|
1593 | - if( FALSE === fwrite( $iCalFile, $this->createCalendar() )) |
|
1582 | + function saveCalendar($directory = FALSE, $filename = FALSE, $delimiter = FALSE) { |
|
1583 | + if ($directory) |
|
1584 | + $this->setConfig('directory', $directory); |
|
1585 | + if ($filename) |
|
1586 | + $this->setConfig('filename', $filename); |
|
1587 | + if ($delimiter && ($delimiter != DIRECTORY_SEPARATOR)) |
|
1588 | + $this->setConfig('delimiter', $delimiter); |
|
1589 | + if (FALSE === ($dirfile = $this->getConfig('url'))) |
|
1590 | + $dirfile = $this->getConfig('dirfile'); |
|
1591 | + $iCalFile = @fopen($dirfile, 'w'); |
|
1592 | + if ($iCalFile) { |
|
1593 | + if (FALSE === fwrite($iCalFile, $this->createCalendar())) |
|
1594 | 1594 | return FALSE; |
1595 | - fclose( $iCalFile ); |
|
1595 | + fclose($iCalFile); |
|
1596 | 1596 | return TRUE; |
1597 | 1597 | } |
1598 | 1598 | else |
@@ -1610,38 +1610,38 @@ discard block |
||
1610 | 1610 | * @param int timeout optional, default 3600 sec |
1611 | 1611 | * @return redirect/FALSE |
1612 | 1612 | */ |
1613 | - function useCachedCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE, $timeout=3600) { |
|
1614 | - if ( $directory && ctype_digit( (string) $directory ) && !$filename ) { |
|
1613 | + function useCachedCalendar($directory = FALSE, $filename = FALSE, $delimiter = FALSE, $timeout = 3600) { |
|
1614 | + if ($directory && ctype_digit((string) $directory) && !$filename) { |
|
1615 | 1615 | $timeout = (int) $directory; |
1616 | 1616 | $directory = FALSE; |
1617 | 1617 | } |
1618 | - if( $directory ) |
|
1619 | - $this->setConfig( 'directory', $directory ); |
|
1620 | - if( $filename ) |
|
1621 | - $this->setConfig( 'filename', $filename ); |
|
1622 | - if( $delimiter && ( $delimiter != DIRECTORY_SEPARATOR )) |
|
1623 | - $this->setConfig( 'delimiter', $delimiter ); |
|
1624 | - $filesize = $this->getConfig( 'filesize' ); |
|
1625 | - if( 0 >= $filesize ) |
|
1618 | + if ($directory) |
|
1619 | + $this->setConfig('directory', $directory); |
|
1620 | + if ($filename) |
|
1621 | + $this->setConfig('filename', $filename); |
|
1622 | + if ($delimiter && ($delimiter != DIRECTORY_SEPARATOR)) |
|
1623 | + $this->setConfig('delimiter', $delimiter); |
|
1624 | + $filesize = $this->getConfig('filesize'); |
|
1625 | + if (0 >= $filesize) |
|
1626 | 1626 | return FALSE; |
1627 | - $dirfile = $this->getConfig( 'dirfile' ); |
|
1628 | - if( time() - filemtime( $dirfile ) < $timeout) { |
|
1627 | + $dirfile = $this->getConfig('dirfile'); |
|
1628 | + if (time() - filemtime($dirfile) < $timeout) { |
|
1629 | 1629 | clearstatcache(); |
1630 | - $dirfile = $this->getConfig( 'dirfile' ); |
|
1631 | - $filename = $this->getConfig( 'filename' ); |
|
1630 | + $dirfile = $this->getConfig('dirfile'); |
|
1631 | + $filename = $this->getConfig('filename'); |
|
1632 | 1632 | // if( headers_sent( $filename, $linenum )) |
1633 | 1633 | // die( "Headers already sent in $filename on line $linenum\n" ); |
1634 | - if( 'xcal' == $this->format ) |
|
1635 | - header( 'Content-Type: application/calendar+xml; charset=utf-8' ); |
|
1634 | + if ('xcal' == $this->format) |
|
1635 | + header('Content-Type: application/calendar+xml; charset=utf-8'); |
|
1636 | 1636 | else |
1637 | - header( 'Content-Type: text/calendar; charset=utf-8' ); |
|
1638 | - header( 'Content-Length: '.$filesize ); |
|
1639 | - header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
|
1640 | - header( 'Cache-Control: max-age=10' ); |
|
1641 | - $fp = @$fopen( $dirfile, 'r' ); |
|
1642 | - if( $fp ) { |
|
1643 | - fpassthru( $fp ); |
|
1644 | - fclose( $fp ); |
|
1637 | + header('Content-Type: text/calendar; charset=utf-8'); |
|
1638 | + header('Content-Length: '.$filesize); |
|
1639 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
1640 | + header('Cache-Control: max-age=10'); |
|
1641 | + $fp = @$fopen($dirfile, 'r'); |
|
1642 | + if ($fp) { |
|
1643 | + fpassthru($fp); |
|
1644 | + fclose($fp); |
|
1645 | 1645 | } |
1646 | 1646 | die(); |
1647 | 1647 | } |
@@ -1690,8 +1690,8 @@ discard block |
||
1690 | 1690 | * @since 2.4.19 - 2008-10-23 |
1691 | 1691 | */ |
1692 | 1692 | function __construct() { |
1693 | - $this->objName = ( isset( $this->timezonetype )) ? |
|
1694 | - strtolower( $this->timezonetype ) : get_class ( $this ); |
|
1693 | + $this->objName = (isset($this->timezonetype)) ? |
|
1694 | + strtolower($this->timezonetype) : get_class($this); |
|
1695 | 1695 | $this->uid = array(); |
1696 | 1696 | $this->dtstamp = array(); |
1697 | 1697 | |
@@ -1717,11 +1717,11 @@ discard block |
||
1717 | 1717 | * @return string |
1718 | 1718 | */ |
1719 | 1719 | function createAction() { |
1720 | - if( empty( $this->action )) return FALSE; |
|
1721 | - if( empty( $this->action['value'] )) |
|
1722 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE; |
|
1723 | - $attributes = $this->_createParams( $this->action['params'] ); |
|
1724 | - return $this->_createElement( 'ACTION', $attributes, $this->action['value'] ); |
|
1720 | + if (empty($this->action)) return FALSE; |
|
1721 | + if (empty($this->action['value'])) |
|
1722 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('ACTION') : FALSE; |
|
1723 | + $attributes = $this->_createParams($this->action['params']); |
|
1724 | + return $this->_createElement('ACTION', $attributes, $this->action['value']); |
|
1725 | 1725 | } |
1726 | 1726 | /** |
1727 | 1727 | * set calendar component property action |
@@ -1732,9 +1732,9 @@ discard block |
||
1732 | 1732 | * @param mixed $params |
1733 | 1733 | * @return bool |
1734 | 1734 | */ |
1735 | - function setAction( $value, $params=FALSE ) { |
|
1736 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1737 | - $this->action = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
1735 | + function setAction($value, $params = FALSE) { |
|
1736 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
1737 | + $this->action = array('value' => $value, 'params' => $this->_setParams($params)); |
|
1738 | 1738 | return TRUE; |
1739 | 1739 | } |
1740 | 1740 | /*********************************************************************************/ |
@@ -1749,14 +1749,14 @@ discard block |
||
1749 | 1749 | * @return string |
1750 | 1750 | */ |
1751 | 1751 | function createAttach() { |
1752 | - if( empty( $this->attach )) return FALSE; |
|
1753 | - $output = null; |
|
1754 | - foreach( $this->attach as $attachPart ) { |
|
1755 | - if(! empty( $attachPart['value'] )) { |
|
1756 | - $attributes = $this->_createParams( $attachPart['params'] ); |
|
1757 | - $output .= $this->_createElement( 'ATTACH', $attributes, $attachPart['value'] ); |
|
1752 | + if (empty($this->attach)) return FALSE; |
|
1753 | + $output = null; |
|
1754 | + foreach ($this->attach as $attachPart) { |
|
1755 | + if (!empty($attachPart['value'])) { |
|
1756 | + $attributes = $this->_createParams($attachPart['params']); |
|
1757 | + $output .= $this->_createElement('ATTACH', $attributes, $attachPart['value']); |
|
1758 | 1758 | } |
1759 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'ATTACH' ); |
|
1759 | + elseif ($this->getConfig('allowEmpty')) $output .= $this->_createElement('ATTACH'); |
|
1760 | 1760 | } |
1761 | 1761 | return $output; |
1762 | 1762 | } |
@@ -1770,9 +1770,9 @@ discard block |
||
1770 | 1770 | * @param integer $index, optional |
1771 | 1771 | * @return bool |
1772 | 1772 | */ |
1773 | - function setAttach( $value, $params=FALSE, $index=FALSE ) { |
|
1774 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1775 | - $this->_setMval( $this->attach, $value, $params, FALSE, $index ); |
|
1773 | + function setAttach($value, $params = FALSE, $index = FALSE) { |
|
1774 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
1775 | + $this->_setMval($this->attach, $value, $params, FALSE, $index); |
|
1776 | 1776 | return TRUE; |
1777 | 1777 | } |
1778 | 1778 | /*********************************************************************************/ |
@@ -1787,26 +1787,26 @@ discard block |
||
1787 | 1787 | * @return string |
1788 | 1788 | */ |
1789 | 1789 | function createAttendee() { |
1790 | - if( empty( $this->attendee )) return FALSE; |
|
1790 | + if (empty($this->attendee)) return FALSE; |
|
1791 | 1791 | $output = null; |
1792 | - foreach( $this->attendee as $attendeePart ) { // start foreach 1 |
|
1793 | - if( empty( $attendeePart['value'] )) { |
|
1794 | - if( $this->getConfig( 'allowEmpty' )) |
|
1795 | - $output .= $this->_createElement( 'ATTENDEE' ); |
|
1792 | + foreach ($this->attendee as $attendeePart) { // start foreach 1 |
|
1793 | + if (empty($attendeePart['value'])) { |
|
1794 | + if ($this->getConfig('allowEmpty')) |
|
1795 | + $output .= $this->_createElement('ATTENDEE'); |
|
1796 | 1796 | continue; |
1797 | 1797 | } |
1798 | 1798 | $attendee1 = $attendee2 = $attendeeLANG = $attendeeCN = null; |
1799 | - foreach( $attendeePart as $paramlabel => $paramvalue ) { // start foreach 2 |
|
1800 | - if( 'value' == $paramlabel ) |
|
1801 | - $attendee2 .= 'MAILTO:'.$paramvalue; |
|
1802 | - elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) { // start elseif |
|
1803 | - foreach( $paramvalue as $optparamlabel => $optparamvalue ) { // start foreach 3 |
|
1799 | + foreach ($attendeePart as $paramlabel => $paramvalue) { // start foreach 2 |
|
1800 | + if ('value' == $paramlabel) |
|
1801 | + $attendee2 .= 'MAILTO:'.$paramvalue; |
|
1802 | + elseif (('params' == $paramlabel) && (is_array($paramvalue))) { // start elseif |
|
1803 | + foreach ($paramvalue as $optparamlabel => $optparamvalue) { // start foreach 3 |
|
1804 | 1804 | $attendee11 = $attendee12 = null; |
1805 | - if( is_int( $optparamlabel )) { |
|
1805 | + if (is_int($optparamlabel)) { |
|
1806 | 1806 | $attendee1 .= $this->intAttrDelimiter.$optparamvalue; |
1807 | 1807 | continue; |
1808 | 1808 | } |
1809 | - switch( $optparamlabel ) { // start switch |
|
1809 | + switch ($optparamlabel) { // start switch |
|
1810 | 1810 | case 'CUTYPE': |
1811 | 1811 | case 'PARTSTAT': |
1812 | 1812 | case 'ROLE': |
@@ -1820,12 +1820,12 @@ discard block |
||
1820 | 1820 | $attendee11 = $this->intAttrDelimiter.'MEMBER='; |
1821 | 1821 | //no break |
1822 | 1822 | case 'DELEGATED-TO': |
1823 | - $attendee11 = ( !$attendee11 ) ? $this->intAttrDelimiter.'DELEGATED-TO=' : $attendee11; |
|
1823 | + $attendee11 = (!$attendee11) ? $this->intAttrDelimiter.'DELEGATED-TO=' : $attendee11; |
|
1824 | 1824 | //no break |
1825 | 1825 | case 'DELEGATED-FROM': |
1826 | - $attendee11 = ( !$attendee11 ) ? $this->intAttrDelimiter.'DELEGATED-FROM=' : $attendee11; |
|
1827 | - foreach( $optparamvalue as $cix => $calUserAddress ) { |
|
1828 | - $attendee12 .= ( $cix ) ? ',' : null; |
|
1826 | + $attendee11 = (!$attendee11) ? $this->intAttrDelimiter.'DELEGATED-FROM=' : $attendee11; |
|
1827 | + foreach ($optparamvalue as $cix => $calUserAddress) { |
|
1828 | + $attendee12 .= ($cix) ? ',' : null; |
|
1829 | 1829 | $attendee12 .= '"MAILTO:'.$calUserAddress.'"'; |
1830 | 1830 | } |
1831 | 1831 | $attendee1 .= $attendee11.$attendee12; |
@@ -1846,7 +1846,7 @@ discard block |
||
1846 | 1846 | } // end foreach 3 |
1847 | 1847 | } // end elseif |
1848 | 1848 | } // end foreach 2 |
1849 | - $output .= $this->_createElement( 'ATTENDEE', $attendee1.$attendeeLANG.$attendeeCN, $attendee2 ); |
|
1849 | + $output .= $this->_createElement('ATTENDEE', $attendee1.$attendeeLANG.$attendeeCN, $attendee2); |
|
1850 | 1850 | } // end foreach 1 |
1851 | 1851 | return $output; |
1852 | 1852 | } |
@@ -1860,63 +1860,63 @@ discard block |
||
1860 | 1860 | * @param integer $index, optional |
1861 | 1861 | * @return bool |
1862 | 1862 | */ |
1863 | - function setAttendee( $value, $params=FALSE, $index=FALSE ) { |
|
1864 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1865 | - $value = str_replace ( 'MAILTO:', '', $value ); |
|
1866 | - $value = str_replace ( 'mailto:', '', $value ); |
|
1863 | + function setAttendee($value, $params = FALSE, $index = FALSE) { |
|
1864 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
1865 | + $value = str_replace('MAILTO:', '', $value); |
|
1866 | + $value = str_replace('mailto:', '', $value); |
|
1867 | 1867 | $params2 = array(); |
1868 | - if( is_array($params )) { |
|
1868 | + if (is_array($params)) { |
|
1869 | 1869 | $optarrays = array(); |
1870 | - foreach( $params as $optparamlabel => $optparamvalue ) { |
|
1871 | - $optparamlabel = strtoupper( $optparamlabel ); |
|
1872 | - switch( $optparamlabel ) { |
|
1870 | + foreach ($params as $optparamlabel => $optparamvalue) { |
|
1871 | + $optparamlabel = strtoupper($optparamlabel); |
|
1872 | + switch ($optparamlabel) { |
|
1873 | 1873 | case 'MEMBER': |
1874 | 1874 | case 'DELEGATED-TO': |
1875 | 1875 | case 'DELEGATED-FROM': |
1876 | - if( is_array( $optparamvalue )) { |
|
1877 | - foreach( $optparamvalue as $part ) { |
|
1878 | - $part = str_replace( 'MAILTO:', '', $part ); |
|
1879 | - $part = str_replace( 'mailto:', '', $part ); |
|
1880 | - if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) |
|
1881 | - $part = substr( $part, 1, ( strlen($part)-2 )); |
|
1876 | + if (is_array($optparamvalue)) { |
|
1877 | + foreach ($optparamvalue as $part) { |
|
1878 | + $part = str_replace('MAILTO:', '', $part); |
|
1879 | + $part = str_replace('mailto:', '', $part); |
|
1880 | + if (('"' == $part{0} ) && ('"' == $part{strlen($part) - 1} )) |
|
1881 | + $part = substr($part, 1, (strlen($part) - 2)); |
|
1882 | 1882 | $optarrays[$optparamlabel][] = $part; |
1883 | 1883 | } |
1884 | 1884 | } |
1885 | 1885 | else { |
1886 | - $part = str_replace( 'MAILTO:', '', $optparamvalue ); |
|
1887 | - $part = str_replace( 'mailto:', '', $part ); |
|
1888 | - if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) |
|
1889 | - $part = substr( $part, 1, ( strlen($part)-2 )); |
|
1886 | + $part = str_replace('MAILTO:', '', $optparamvalue); |
|
1887 | + $part = str_replace('mailto:', '', $part); |
|
1888 | + if (('"' == $part{0} ) && ('"' == $part{strlen($part) - 1} )) |
|
1889 | + $part = substr($part, 1, (strlen($part) - 2)); |
|
1890 | 1890 | $optarrays[$optparamlabel][] = $part; |
1891 | 1891 | } |
1892 | 1892 | break; |
1893 | 1893 | default: |
1894 | - if( 'SENT-BY' == $optparamlabel ) { |
|
1895 | - $optparamvalue = str_replace( 'MAILTO:', '', $optparamvalue ); |
|
1896 | - $optparamvalue = str_replace( 'mailto:', '', $optparamvalue ); |
|
1894 | + if ('SENT-BY' == $optparamlabel) { |
|
1895 | + $optparamvalue = str_replace('MAILTO:', '', $optparamvalue); |
|
1896 | + $optparamvalue = str_replace('mailto:', '', $optparamvalue); |
|
1897 | 1897 | } |
1898 | - if(( '"' == substr( $optparamvalue, 0, 1 )) && |
|
1899 | - ( '"' == substr( $optparamvalue, -1 ))) |
|
1900 | - $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 )); |
|
1898 | + if (('"' == substr($optparamvalue, 0, 1)) && |
|
1899 | + ('"' == substr($optparamvalue, -1))) |
|
1900 | + $optparamvalue = substr($optparamvalue, 1, (strlen($optparamvalue) - 2)); |
|
1901 | 1901 | $params2[$optparamlabel] = $optparamvalue; |
1902 | 1902 | break; |
1903 | 1903 | } // end switch( $optparamlabel.. . |
1904 | 1904 | } // end foreach( $optparam.. . |
1905 | - foreach( $optarrays as $optparamlabel => $optparams ) |
|
1905 | + foreach ($optarrays as $optparamlabel => $optparams) |
|
1906 | 1906 | $params2[$optparamlabel] = $optparams; |
1907 | 1907 | } |
1908 | 1908 | // remove defaults |
1909 | - $this->_existRem( $params2, 'CUTYPE', 'INDIVIDUAL' ); |
|
1910 | - $this->_existRem( $params2, 'PARTSTAT', 'NEEDS-ACTION' ); |
|
1911 | - $this->_existRem( $params2, 'ROLE', 'REQ-PARTICIPANT' ); |
|
1912 | - $this->_existRem( $params2, 'RSVP', 'FALSE' ); |
|
1909 | + $this->_existRem($params2, 'CUTYPE', 'INDIVIDUAL'); |
|
1910 | + $this->_existRem($params2, 'PARTSTAT', 'NEEDS-ACTION'); |
|
1911 | + $this->_existRem($params2, 'ROLE', 'REQ-PARTICIPANT'); |
|
1912 | + $this->_existRem($params2, 'RSVP', 'FALSE'); |
|
1913 | 1913 | // check language setting |
1914 | - if( isset( $params2['CN' ] )) { |
|
1915 | - $lang = $this->getConfig( 'language' ); |
|
1916 | - if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang )) |
|
1917 | - $params2['LANGUAGE' ] = $lang; |
|
1914 | + if (isset($params2['CN'])) { |
|
1915 | + $lang = $this->getConfig('language'); |
|
1916 | + if (!isset($params2['LANGUAGE']) && !empty($lang)) |
|
1917 | + $params2['LANGUAGE'] = $lang; |
|
1918 | 1918 | } |
1919 | - $this->_setMval( $this->attendee, $value, $params2, FALSE, $index ); |
|
1919 | + $this->_setMval($this->attendee, $value, $params2, FALSE, $index); |
|
1920 | 1920 | return TRUE; |
1921 | 1921 | } |
1922 | 1922 | /*********************************************************************************/ |
@@ -1931,23 +1931,23 @@ discard block |
||
1931 | 1931 | * @return string |
1932 | 1932 | */ |
1933 | 1933 | function createCategories() { |
1934 | - if( empty( $this->categories )) return FALSE; |
|
1934 | + if (empty($this->categories)) return FALSE; |
|
1935 | 1935 | $output = null; |
1936 | - foreach( $this->categories as $category ) { |
|
1937 | - if( empty( $category['value'] )) { |
|
1938 | - if ( $this->getConfig( 'allowEmpty' )) |
|
1939 | - $output .= $this->_createElement( 'CATEGORIES' ); |
|
1936 | + foreach ($this->categories as $category) { |
|
1937 | + if (empty($category['value'])) { |
|
1938 | + if ($this->getConfig('allowEmpty')) |
|
1939 | + $output .= $this->_createElement('CATEGORIES'); |
|
1940 | 1940 | continue; |
1941 | 1941 | } |
1942 | - $attributes = $this->_createParams( $category['params'], array( 'LANGUAGE' )); |
|
1943 | - if( is_array( $category['value'] )) { |
|
1944 | - foreach( $category['value'] as $cix => $categoryPart ) |
|
1945 | - $category['value'][$cix] = $this->_strrep( $categoryPart ); |
|
1946 | - $content = implode( ',', $category['value'] ); |
|
1942 | + $attributes = $this->_createParams($category['params'], array('LANGUAGE')); |
|
1943 | + if (is_array($category['value'])) { |
|
1944 | + foreach ($category['value'] as $cix => $categoryPart) |
|
1945 | + $category['value'][$cix] = $this->_strrep($categoryPart); |
|
1946 | + $content = implode(',', $category['value']); |
|
1947 | 1947 | } |
1948 | 1948 | else |
1949 | - $content = $this->_strrep( $category['value'] ); |
|
1950 | - $output .= $this->_createElement( 'CATEGORIES', $attributes, $content ); |
|
1949 | + $content = $this->_strrep($category['value']); |
|
1950 | + $output .= $this->_createElement('CATEGORIES', $attributes, $content); |
|
1951 | 1951 | } |
1952 | 1952 | return $output; |
1953 | 1953 | } |
@@ -1961,9 +1961,9 @@ discard block |
||
1961 | 1961 | * @param integer $index, optional |
1962 | 1962 | * @return bool |
1963 | 1963 | */ |
1964 | - function setCategories( $value, $params=FALSE, $index=FALSE ) { |
|
1965 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1966 | - $this->_setMval( $this->categories, $value, $params, FALSE, $index ); |
|
1964 | + function setCategories($value, $params = FALSE, $index = FALSE) { |
|
1965 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
1966 | + $this->_setMval($this->categories, $value, $params, FALSE, $index); |
|
1967 | 1967 | return TRUE; |
1968 | 1968 | } |
1969 | 1969 | /*********************************************************************************/ |
@@ -1978,11 +1978,11 @@ discard block |
||
1978 | 1978 | * @return string |
1979 | 1979 | */ |
1980 | 1980 | function createClass() { |
1981 | - if( empty( $this->class )) return FALSE; |
|
1982 | - if( empty( $this->class['value'] )) |
|
1983 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE; |
|
1984 | - $attributes = $this->_createParams( $this->class['params'] ); |
|
1985 | - return $this->_createElement( 'CLASS', $attributes, $this->class['value'] ); |
|
1981 | + if (empty($this->class)) return FALSE; |
|
1982 | + if (empty($this->class['value'])) |
|
1983 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('CLASS') : FALSE; |
|
1984 | + $attributes = $this->_createParams($this->class['params']); |
|
1985 | + return $this->_createElement('CLASS', $attributes, $this->class['value']); |
|
1986 | 1986 | } |
1987 | 1987 | /** |
1988 | 1988 | * set calendar component property class |
@@ -1993,9 +1993,9 @@ discard block |
||
1993 | 1993 | * @param array $params optional |
1994 | 1994 | * @return bool |
1995 | 1995 | */ |
1996 | - function setClass( $value, $params=FALSE ) { |
|
1997 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1998 | - $this->class = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
1996 | + function setClass($value, $params = FALSE) { |
|
1997 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
1998 | + $this->class = array('value' => $value, 'params' => $this->_setParams($params)); |
|
1999 | 1999 | return TRUE; |
2000 | 2000 | } |
2001 | 2001 | /*********************************************************************************/ |
@@ -2010,16 +2010,16 @@ discard block |
||
2010 | 2010 | * @return string |
2011 | 2011 | */ |
2012 | 2012 | function createComment() { |
2013 | - if( empty( $this->comment )) return FALSE; |
|
2013 | + if (empty($this->comment)) return FALSE; |
|
2014 | 2014 | $output = null; |
2015 | - foreach( $this->comment as $commentPart ) { |
|
2016 | - if( empty( $commentPart['value'] )) { |
|
2017 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'COMMENT' ); |
|
2015 | + foreach ($this->comment as $commentPart) { |
|
2016 | + if (empty($commentPart['value'])) { |
|
2017 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('COMMENT'); |
|
2018 | 2018 | continue; |
2019 | 2019 | } |
2020 | - $attributes = $this->_createParams( $commentPart['params'], array( 'ALTREP', 'LANGUAGE' )); |
|
2021 | - $content = $this->_strrep( $commentPart['value'] ); |
|
2022 | - $output .= $this->_createElement( 'COMMENT', $attributes, $content ); |
|
2020 | + $attributes = $this->_createParams($commentPart['params'], array('ALTREP', 'LANGUAGE')); |
|
2021 | + $content = $this->_strrep($commentPart['value']); |
|
2022 | + $output .= $this->_createElement('COMMENT', $attributes, $content); |
|
2023 | 2023 | } |
2024 | 2024 | return $output; |
2025 | 2025 | } |
@@ -2033,9 +2033,9 @@ discard block |
||
2033 | 2033 | * @param integer $index, optional |
2034 | 2034 | * @return bool |
2035 | 2035 | */ |
2036 | - function setComment( $value, $params=FALSE, $index=FALSE ) { |
|
2037 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2038 | - $this->_setMval( $this->comment, $value, $params, FALSE, $index ); |
|
2036 | + function setComment($value, $params = FALSE, $index = FALSE) { |
|
2037 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
2038 | + $this->_setMval($this->comment, $value, $params, FALSE, $index); |
|
2039 | 2039 | return TRUE; |
2040 | 2040 | } |
2041 | 2041 | /*********************************************************************************/ |
@@ -2050,19 +2050,19 @@ discard block |
||
2050 | 2050 | * @return string |
2051 | 2051 | */ |
2052 | 2052 | function createCompleted( ) { |
2053 | - if( empty( $this->completed )) return FALSE; |
|
2054 | - if( !isset( $this->completed['value']['year'] ) && |
|
2055 | - !isset( $this->completed['value']['month'] ) && |
|
2056 | - !isset( $this->completed['value']['day'] ) && |
|
2057 | - !isset( $this->completed['value']['hour'] ) && |
|
2058 | - !isset( $this->completed['value']['min'] ) && |
|
2059 | - !isset( $this->completed['value']['sec'] )) |
|
2060 | - if( $this->getConfig( 'allowEmpty' )) |
|
2061 | - return $this->_createElement( 'COMPLETED' ); |
|
2053 | + if (empty($this->completed)) return FALSE; |
|
2054 | + if (!isset($this->completed['value']['year']) && |
|
2055 | + !isset($this->completed['value']['month']) && |
|
2056 | + !isset($this->completed['value']['day']) && |
|
2057 | + !isset($this->completed['value']['hour']) && |
|
2058 | + !isset($this->completed['value']['min']) && |
|
2059 | + !isset($this->completed['value']['sec'])) |
|
2060 | + if ($this->getConfig('allowEmpty')) |
|
2061 | + return $this->_createElement('COMPLETED'); |
|
2062 | 2062 | else return FALSE; |
2063 | - $formatted = $this->_format_date_time( $this->completed['value'], 7 ); |
|
2064 | - $attributes = $this->_createParams( $this->completed['params'] ); |
|
2065 | - return $this->_createElement( 'COMPLETED', $attributes, $formatted ); |
|
2063 | + $formatted = $this->_format_date_time($this->completed['value'], 7); |
|
2064 | + $attributes = $this->_createParams($this->completed['params']); |
|
2065 | + return $this->_createElement('COMPLETED', $attributes, $formatted); |
|
2066 | 2066 | } |
2067 | 2067 | /** |
2068 | 2068 | * set calendar component property completed |
@@ -2078,16 +2078,16 @@ discard block |
||
2078 | 2078 | * @param array $params optional |
2079 | 2079 | * @return bool |
2080 | 2080 | */ |
2081 | - function setCompleted( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
|
2082 | - if( empty( $year )) { |
|
2083 | - if( $this->getConfig( 'allowEmpty' )) { |
|
2084 | - $this->completed = array( 'value' => null, 'params' => $this->_setParams( $params )); |
|
2081 | + function setCompleted($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) { |
|
2082 | + if (empty($year)) { |
|
2083 | + if ($this->getConfig('allowEmpty')) { |
|
2084 | + $this->completed = array('value' => null, 'params' => $this->_setParams($params)); |
|
2085 | 2085 | return TRUE; |
2086 | 2086 | } |
2087 | 2087 | else |
2088 | 2088 | return FALSE; |
2089 | 2089 | } |
2090 | - $this->completed = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
|
2090 | + $this->completed = $this->_setDate2($year, $month, $day, $hour, $min, $sec, $params); |
|
2091 | 2091 | return TRUE; |
2092 | 2092 | } |
2093 | 2093 | /*********************************************************************************/ |
@@ -2102,15 +2102,15 @@ discard block |
||
2102 | 2102 | * @return string |
2103 | 2103 | */ |
2104 | 2104 | function createContact() { |
2105 | - if( empty( $this->contact )) return FALSE; |
|
2105 | + if (empty($this->contact)) return FALSE; |
|
2106 | 2106 | $output = null; |
2107 | - foreach( $this->contact as $contact ) { |
|
2108 | - if( !empty( $contact['value'] )) { |
|
2109 | - $attributes = $this->_createParams( $contact['params'], array( 'ALTREP', 'LANGUAGE' )); |
|
2110 | - $content = $this->_strrep( $contact['value'] ); |
|
2111 | - $output .= $this->_createElement( 'CONTACT', $attributes, $content ); |
|
2107 | + foreach ($this->contact as $contact) { |
|
2108 | + if (!empty($contact['value'])) { |
|
2109 | + $attributes = $this->_createParams($contact['params'], array('ALTREP', 'LANGUAGE')); |
|
2110 | + $content = $this->_strrep($contact['value']); |
|
2111 | + $output .= $this->_createElement('CONTACT', $attributes, $content); |
|
2112 | 2112 | } |
2113 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'CONTACT' ); |
|
2113 | + elseif ($this->getConfig('allowEmpty')) $output .= $this->_createElement('CONTACT'); |
|
2114 | 2114 | } |
2115 | 2115 | return $output; |
2116 | 2116 | } |
@@ -2124,9 +2124,9 @@ discard block |
||
2124 | 2124 | * @param integer $index, optional |
2125 | 2125 | * @return bool |
2126 | 2126 | */ |
2127 | - function setContact( $value, $params=FALSE, $index=FALSE ) { |
|
2128 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2129 | - $this->_setMval( $this->contact, $value, $params, FALSE, $index ); |
|
2127 | + function setContact($value, $params = FALSE, $index = FALSE) { |
|
2128 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
2129 | + $this->_setMval($this->contact, $value, $params, FALSE, $index); |
|
2130 | 2130 | return TRUE; |
2131 | 2131 | } |
2132 | 2132 | /*********************************************************************************/ |
@@ -2141,10 +2141,10 @@ discard block |
||
2141 | 2141 | * @return string |
2142 | 2142 | */ |
2143 | 2143 | function createCreated() { |
2144 | - if( empty( $this->created )) return FALSE; |
|
2145 | - $formatted = $this->_format_date_time( $this->created['value'], 7 ); |
|
2146 | - $attributes = $this->_createParams( $this->created['params'] ); |
|
2147 | - return $this->_createElement( 'CREATED', $attributes, $formatted ); |
|
2144 | + if (empty($this->created)) return FALSE; |
|
2145 | + $formatted = $this->_format_date_time($this->created['value'], 7); |
|
2146 | + $attributes = $this->_createParams($this->created['params']); |
|
2147 | + return $this->_createElement('CREATED', $attributes, $formatted); |
|
2148 | 2148 | } |
2149 | 2149 | /** |
2150 | 2150 | * set calendar component property created |
@@ -2160,11 +2160,11 @@ discard block |
||
2160 | 2160 | * @param mixed $params optional |
2161 | 2161 | * @return bool |
2162 | 2162 | */ |
2163 | - function setCreated( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
|
2164 | - if( !isset( $year )) { |
|
2165 | - $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' ))); |
|
2163 | + function setCreated($year = FALSE, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) { |
|
2164 | + if (!isset($year)) { |
|
2165 | + $year = date('Ymd\THis', mktime(date('H'), date('i'), date('s') - date('Z'), date('m'), date('d'), date('Y'))); |
|
2166 | 2166 | } |
2167 | - $this->created = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
|
2167 | + $this->created = $this->_setDate2($year, $month, $day, $hour, $min, $sec, $params); |
|
2168 | 2168 | return TRUE; |
2169 | 2169 | } |
2170 | 2170 | /*********************************************************************************/ |
@@ -2179,15 +2179,15 @@ discard block |
||
2179 | 2179 | * @return string |
2180 | 2180 | */ |
2181 | 2181 | function createDescription() { |
2182 | - if( empty( $this->description )) return FALSE; |
|
2183 | - $output = null; |
|
2184 | - foreach( $this->description as $description ) { |
|
2185 | - if( !empty( $description['value'] )) { |
|
2186 | - $attributes = $this->_createParams( $description['params'], array( 'ALTREP', 'LANGUAGE' )); |
|
2187 | - $content = $this->_strrep( $description['value'] ); |
|
2188 | - $output .= $this->_createElement( 'DESCRIPTION', $attributes, $content ); |
|
2182 | + if (empty($this->description)) return FALSE; |
|
2183 | + $output = null; |
|
2184 | + foreach ($this->description as $description) { |
|
2185 | + if (!empty($description['value'])) { |
|
2186 | + $attributes = $this->_createParams($description['params'], array('ALTREP', 'LANGUAGE')); |
|
2187 | + $content = $this->_strrep($description['value']); |
|
2188 | + $output .= $this->_createElement('DESCRIPTION', $attributes, $content); |
|
2189 | 2189 | } |
2190 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'DESCRIPTION' ); |
|
2190 | + elseif ($this->getConfig('allowEmpty')) $output .= $this->_createElement('DESCRIPTION'); |
|
2191 | 2191 | } |
2192 | 2192 | return $output; |
2193 | 2193 | } |
@@ -2201,9 +2201,9 @@ discard block |
||
2201 | 2201 | * @param integer $index, optional |
2202 | 2202 | * @return bool |
2203 | 2203 | */ |
2204 | - function setDescription( $value, $params=FALSE, $index=FALSE ) { |
|
2205 | - if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; } |
|
2206 | - $this->_setMval( $this->description, $value, $params, FALSE, $index ); |
|
2204 | + function setDescription($value, $params = FALSE, $index = FALSE) { |
|
2205 | + if (empty($value)) { if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; } |
|
2206 | + $this->_setMval($this->description, $value, $params, FALSE, $index); |
|
2207 | 2207 | return TRUE; |
2208 | 2208 | } |
2209 | 2209 | /*********************************************************************************/ |
@@ -2218,19 +2218,19 @@ discard block |
||
2218 | 2218 | * @return string |
2219 | 2219 | */ |
2220 | 2220 | function createDtend() { |
2221 | - if( empty( $this->dtend )) return FALSE; |
|
2222 | - if( !isset( $this->dtend['value']['year'] ) && |
|
2223 | - !isset( $this->dtend['value']['month'] ) && |
|
2224 | - !isset( $this->dtend['value']['day'] ) && |
|
2225 | - !isset( $this->dtend['value']['hour'] ) && |
|
2226 | - !isset( $this->dtend['value']['min'] ) && |
|
2227 | - !isset( $this->dtend['value']['sec'] )) |
|
2228 | - if( $this->getConfig( 'allowEmpty' )) |
|
2229 | - return $this->_createElement( 'DTEND' ); |
|
2221 | + if (empty($this->dtend)) return FALSE; |
|
2222 | + if (!isset($this->dtend['value']['year']) && |
|
2223 | + !isset($this->dtend['value']['month']) && |
|
2224 | + !isset($this->dtend['value']['day']) && |
|
2225 | + !isset($this->dtend['value']['hour']) && |
|
2226 | + !isset($this->dtend['value']['min']) && |
|
2227 | + !isset($this->dtend['value']['sec'])) |
|
2228 | + if ($this->getConfig('allowEmpty')) |
|
2229 | + return $this->_createElement('DTEND'); |
|
2230 | 2230 | else return FALSE; |
2231 | - $formatted = $this->_format_date_time( $this->dtend['value'] ); |
|
2232 | - $attributes = $this->_createParams( $this->dtend['params'] ); |
|
2233 | - return $this->_createElement( 'DTEND', $attributes, $formatted ); |
|
2231 | + $formatted = $this->_format_date_time($this->dtend['value']); |
|
2232 | + $attributes = $this->_createParams($this->dtend['params']); |
|
2233 | + return $this->_createElement('DTEND', $attributes, $formatted); |
|
2234 | 2234 | } |
2235 | 2235 | /** |
2236 | 2236 | * set calendar component property dtend |
@@ -2247,16 +2247,16 @@ discard block |
||
2247 | 2247 | * @param array params optional |
2248 | 2248 | * @return bool |
2249 | 2249 | */ |
2250 | - function setDtend( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) { |
|
2251 | - if( empty( $year )) { |
|
2252 | - if( $this->getConfig( 'allowEmpty' )) { |
|
2253 | - $this->dtend = array( 'value' => null, 'params' => $this->_setParams( $params )); |
|
2250 | + function setDtend($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE) { |
|
2251 | + if (empty($year)) { |
|
2252 | + if ($this->getConfig('allowEmpty')) { |
|
2253 | + $this->dtend = array('value' => null, 'params' => $this->_setParams($params)); |
|
2254 | 2254 | return TRUE; |
2255 | 2255 | } |
2256 | 2256 | else |
2257 | 2257 | return FALSE; |
2258 | 2258 | } |
2259 | - $this->dtend = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
|
2259 | + $this->dtend = $this->_setDate($year, $month, $day, $hour, $min, $sec, $tz, $params); |
|
2260 | 2260 | return TRUE; |
2261 | 2261 | } |
2262 | 2262 | /*********************************************************************************/ |
@@ -2271,16 +2271,16 @@ discard block |
||
2271 | 2271 | * @return string |
2272 | 2272 | */ |
2273 | 2273 | function createDtstamp() { |
2274 | - if( !isset( $this->dtstamp['value']['year'] ) && |
|
2275 | - !isset( $this->dtstamp['value']['month'] ) && |
|
2276 | - !isset( $this->dtstamp['value']['day'] ) && |
|
2277 | - !isset( $this->dtstamp['value']['hour'] ) && |
|
2278 | - !isset( $this->dtstamp['value']['min'] ) && |
|
2279 | - !isset( $this->dtstamp['value']['sec'] )) |
|
2274 | + if (!isset($this->dtstamp['value']['year']) && |
|
2275 | + !isset($this->dtstamp['value']['month']) && |
|
2276 | + !isset($this->dtstamp['value']['day']) && |
|
2277 | + !isset($this->dtstamp['value']['hour']) && |
|
2278 | + !isset($this->dtstamp['value']['min']) && |
|
2279 | + !isset($this->dtstamp['value']['sec'])) |
|
2280 | 2280 | $this->_makeDtstamp(); |
2281 | - $formatted = $this->_format_date_time( $this->dtstamp['value'], 7 ); |
|
2282 | - $attributes = $this->_createParams( $this->dtstamp['params'] ); |
|
2283 | - return $this->_createElement( 'DTSTAMP', $attributes, $formatted ); |
|
2281 | + $formatted = $this->_format_date_time($this->dtstamp['value'], 7); |
|
2282 | + $attributes = $this->_createParams($this->dtstamp['params']); |
|
2283 | + return $this->_createElement('DTSTAMP', $attributes, $formatted); |
|
2284 | 2284 | } |
2285 | 2285 | /** |
2286 | 2286 | * computes datestamp for calendar component object instance dtstamp |
@@ -2290,12 +2290,12 @@ discard block |
||
2290 | 2290 | * @return void |
2291 | 2291 | */ |
2292 | 2292 | function _makeDtstamp() { |
2293 | - $this->dtstamp['value'] = array( 'year' => date( 'Y' ) |
|
2294 | - , 'month' => date( 'm' ) |
|
2295 | - , 'day' => date( 'd' ) |
|
2296 | - , 'hour' => date( 'H' ) |
|
2297 | - , 'min' => date( 'i' ) |
|
2298 | - , 'sec' => date( 's' ) - date( 'Z' )); |
|
2293 | + $this->dtstamp['value'] = array('year' => date('Y') |
|
2294 | + , 'month' => date('m') |
|
2295 | + , 'day' => date('d') |
|
2296 | + , 'hour' => date('H') |
|
2297 | + , 'min' => date('i') |
|
2298 | + , 'sec' => date('s') - date('Z')); |
|
2299 | 2299 | $this->dtstamp['params'] = null; |
2300 | 2300 | } |
2301 | 2301 | /** |
@@ -2312,11 +2312,11 @@ discard block |
||
2312 | 2312 | * @param array $params optional |
2313 | 2313 | * @return TRUE |
2314 | 2314 | */ |
2315 | - function setDtstamp( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
|
2316 | - if( empty( $year )) |
|
2315 | + function setDtstamp($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) { |
|
2316 | + if (empty($year)) |
|
2317 | 2317 | $this->_makeDtstamp(); |
2318 | 2318 | else |
2319 | - $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
|
2319 | + $this->dtstamp = $this->_setDate2($year, $month, $day, $hour, $min, $sec, $params); |
|
2320 | 2320 | return TRUE; |
2321 | 2321 | } |
2322 | 2322 | /*********************************************************************************/ |
@@ -2331,21 +2331,21 @@ discard block |
||
2331 | 2331 | * @return string |
2332 | 2332 | */ |
2333 | 2333 | function createDtstart() { |
2334 | - if( empty( $this->dtstart )) return FALSE; |
|
2335 | - if( !isset( $this->dtstart['value']['year'] ) && |
|
2336 | - !isset( $this->dtstart['value']['month'] ) && |
|
2337 | - !isset( $this->dtstart['value']['day'] ) && |
|
2338 | - !isset( $this->dtstart['value']['hour'] ) && |
|
2339 | - !isset( $this->dtstart['value']['min'] ) && |
|
2340 | - !isset( $this->dtstart['value']['sec'] )) |
|
2341 | - if( $this->getConfig( 'allowEmpty' )) |
|
2342 | - return $this->_createElement( 'DTSTART' ); |
|
2334 | + if (empty($this->dtstart)) return FALSE; |
|
2335 | + if (!isset($this->dtstart['value']['year']) && |
|
2336 | + !isset($this->dtstart['value']['month']) && |
|
2337 | + !isset($this->dtstart['value']['day']) && |
|
2338 | + !isset($this->dtstart['value']['hour']) && |
|
2339 | + !isset($this->dtstart['value']['min']) && |
|
2340 | + !isset($this->dtstart['value']['sec'])) |
|
2341 | + if ($this->getConfig('allowEmpty')) |
|
2342 | + return $this->_createElement('DTSTART'); |
|
2343 | 2343 | else return FALSE; |
2344 | - if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) |
|
2345 | - unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] ); |
|
2346 | - $formatted = $this->_format_date_time( $this->dtstart['value'] ); |
|
2347 | - $attributes = $this->_createParams( $this->dtstart['params'] ); |
|
2348 | - return $this->_createElement( 'DTSTART', $attributes, $formatted ); |
|
2344 | + if (in_array($this->objName, array('vtimezone', 'standard', 'daylight'))) |
|
2345 | + unset($this->dtstart['value']['tz'], $this->dtstart['params']['TZID']); |
|
2346 | + $formatted = $this->_format_date_time($this->dtstart['value']); |
|
2347 | + $attributes = $this->_createParams($this->dtstart['params']); |
|
2348 | + return $this->_createElement('DTSTART', $attributes, $formatted); |
|
2349 | 2349 | } |
2350 | 2350 | /** |
2351 | 2351 | * set calendar component property dtstart |
@@ -2362,16 +2362,16 @@ discard block |
||
2362 | 2362 | * @param array $params optional |
2363 | 2363 | * @return bool |
2364 | 2364 | */ |
2365 | - function setDtstart( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) { |
|
2366 | - if( empty( $year )) { |
|
2367 | - if( $this->getConfig( 'allowEmpty' )) { |
|
2368 | - $this->dtstart = array( 'value' => null, 'params' => $this->_setParams( $params )); |
|
2365 | + function setDtstart($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE) { |
|
2366 | + if (empty($year)) { |
|
2367 | + if ($this->getConfig('allowEmpty')) { |
|
2368 | + $this->dtstart = array('value' => null, 'params' => $this->_setParams($params)); |
|
2369 | 2369 | return TRUE; |
2370 | 2370 | } |
2371 | 2371 | else |
2372 | 2372 | return FALSE; |
2373 | 2373 | } |
2374 | - $this->dtstart = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params, 'dtstart' ); |
|
2374 | + $this->dtstart = $this->_setDate($year, $month, $day, $hour, $min, $sec, $tz, $params, 'dtstart'); |
|
2375 | 2375 | return TRUE; |
2376 | 2376 | } |
2377 | 2377 | /*********************************************************************************/ |
@@ -2386,19 +2386,19 @@ discard block |
||
2386 | 2386 | * @return string |
2387 | 2387 | */ |
2388 | 2388 | function createDue() { |
2389 | - if( empty( $this->due )) return FALSE; |
|
2390 | - if( !isset( $this->due['value']['year'] ) && |
|
2391 | - !isset( $this->due['value']['month'] ) && |
|
2392 | - !isset( $this->due['value']['day'] ) && |
|
2393 | - !isset( $this->due['value']['hour'] ) && |
|
2394 | - !isset( $this->due['value']['min'] ) && |
|
2395 | - !isset( $this->due['value']['sec'] )) |
|
2396 | - if( $this->getConfig( 'allowEmpty' )) |
|
2397 | - return $this->_createElement( 'DUE' ); |
|
2389 | + if (empty($this->due)) return FALSE; |
|
2390 | + if (!isset($this->due['value']['year']) && |
|
2391 | + !isset($this->due['value']['month']) && |
|
2392 | + !isset($this->due['value']['day']) && |
|
2393 | + !isset($this->due['value']['hour']) && |
|
2394 | + !isset($this->due['value']['min']) && |
|
2395 | + !isset($this->due['value']['sec'])) |
|
2396 | + if ($this->getConfig('allowEmpty')) |
|
2397 | + return $this->_createElement('DUE'); |
|
2398 | 2398 | else return FALSE; |
2399 | - $formatted = $this->_format_date_time( $this->due['value'] ); |
|
2400 | - $attributes = $this->_createParams( $this->due['params'] ); |
|
2401 | - return $this->_createElement( 'DUE', $attributes, $formatted ); |
|
2399 | + $formatted = $this->_format_date_time($this->due['value']); |
|
2400 | + $attributes = $this->_createParams($this->due['params']); |
|
2401 | + return $this->_createElement('DUE', $attributes, $formatted); |
|
2402 | 2402 | } |
2403 | 2403 | /** |
2404 | 2404 | * set calendar component property due |
@@ -2414,16 +2414,16 @@ discard block |
||
2414 | 2414 | * @param array $params optional |
2415 | 2415 | * @return bool |
2416 | 2416 | */ |
2417 | - function setDue( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) { |
|
2418 | - if( empty( $year )) { |
|
2419 | - if( $this->getConfig( 'allowEmpty' )) { |
|
2420 | - $this->due = array( 'value' => null, 'params' => $this->_setParams( $params )); |
|
2417 | + function setDue($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE) { |
|
2418 | + if (empty($year)) { |
|
2419 | + if ($this->getConfig('allowEmpty')) { |
|
2420 | + $this->due = array('value' => null, 'params' => $this->_setParams($params)); |
|
2421 | 2421 | return TRUE; |
2422 | 2422 | } |
2423 | 2423 | else |
2424 | 2424 | return FALSE; |
2425 | 2425 | } |
2426 | - $this->due = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
|
2426 | + $this->due = $this->_setDate($year, $month, $day, $hour, $min, $sec, $tz, $params); |
|
2427 | 2427 | return TRUE; |
2428 | 2428 | } |
2429 | 2429 | /*********************************************************************************/ |
@@ -2438,17 +2438,17 @@ discard block |
||
2438 | 2438 | * @return string |
2439 | 2439 | */ |
2440 | 2440 | function createDuration() { |
2441 | - if( empty( $this->duration )) return FALSE; |
|
2442 | - if( !isset( $this->duration['value']['week'] ) && |
|
2443 | - !isset( $this->duration['value']['day'] ) && |
|
2444 | - !isset( $this->duration['value']['hour'] ) && |
|
2445 | - !isset( $this->duration['value']['min'] ) && |
|
2446 | - !isset( $this->duration['value']['sec'] )) |
|
2447 | - if( $this->getConfig( 'allowEmpty' )) |
|
2448 | - return $this->_createElement( 'DURATION', array(), null ); |
|
2441 | + if (empty($this->duration)) return FALSE; |
|
2442 | + if (!isset($this->duration['value']['week']) && |
|
2443 | + !isset($this->duration['value']['day']) && |
|
2444 | + !isset($this->duration['value']['hour']) && |
|
2445 | + !isset($this->duration['value']['min']) && |
|
2446 | + !isset($this->duration['value']['sec'])) |
|
2447 | + if ($this->getConfig('allowEmpty')) |
|
2448 | + return $this->_createElement('DURATION', array(), null); |
|
2449 | 2449 | else return FALSE; |
2450 | - $attributes = $this->_createParams( $this->duration['params'] ); |
|
2451 | - return $this->_createElement( 'DURATION', $attributes, $this->_format_duration( $this->duration['value'] )); |
|
2450 | + $attributes = $this->_createParams($this->duration['params']); |
|
2451 | + return $this->_createElement('DURATION', $attributes, $this->_format_duration($this->duration['value'])); |
|
2452 | 2452 | } |
2453 | 2453 | /** |
2454 | 2454 | * set calendar component property duration |
@@ -2463,20 +2463,20 @@ discard block |
||
2463 | 2463 | * @param array $params optional |
2464 | 2464 | * @return bool |
2465 | 2465 | */ |
2466 | - function setDuration( $week, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
|
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 )))) { |
|
2471 | - $week = trim( $week ); |
|
2472 | - if( in_array( substr( $week, 0, 1 ), array( '+', '-' ))) |
|
2473 | - $week = substr( $week, 1 ); |
|
2474 | - $this->duration = array( 'value' => $this->_duration_string( $week ), 'params' => $this->_setParams( $day )); |
|
2475 | - } |
|
2476 | - elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec )) |
|
2466 | + function setDuration($week, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) { |
|
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)))) { |
|
2471 | + $week = trim($week); |
|
2472 | + if (in_array(substr($week, 0, 1), array('+', '-'))) |
|
2473 | + $week = substr($week, 1); |
|
2474 | + $this->duration = array('value' => $this->_duration_string($week), 'params' => $this->_setParams($day)); |
|
2475 | + } |
|
2476 | + elseif (empty($week) && empty($day) && empty($hour) && empty($min) && empty($sec)) |
|
2477 | 2477 | return FALSE; |
2478 | 2478 | else |
2479 | - $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params )); |
|
2479 | + $this->duration = array('value' => $this->_duration_array(array($week, $day, $hour, $min, $sec)), 'params' => $this->_setParams($params)); |
|
2480 | 2480 | return TRUE; |
2481 | 2481 | } |
2482 | 2482 | /*********************************************************************************/ |
@@ -2491,36 +2491,36 @@ discard block |
||
2491 | 2491 | * @return string |
2492 | 2492 | */ |
2493 | 2493 | function createExdate() { |
2494 | - if( empty( $this->exdate )) return FALSE; |
|
2494 | + if (empty($this->exdate)) return FALSE; |
|
2495 | 2495 | $output = null; |
2496 | - foreach( $this->exdate as $ex => $theExdate ) { |
|
2497 | - if( empty( $theExdate['value'] )) { |
|
2498 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'EXDATE' ); |
|
2496 | + foreach ($this->exdate as $ex => $theExdate) { |
|
2497 | + if (empty($theExdate['value'])) { |
|
2498 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('EXDATE'); |
|
2499 | 2499 | continue; |
2500 | 2500 | } |
2501 | 2501 | $content = $attributes = null; |
2502 | - foreach( $theExdate['value'] as $eix => $exdatePart ) { |
|
2503 | - $parno = count( $exdatePart ); |
|
2504 | - $formatted = $this->_format_date_time( $exdatePart, $parno ); |
|
2505 | - if( isset( $theExdate['params']['TZID'] )) |
|
2506 | - $formatted = str_replace( 'Z', '', $formatted); |
|
2507 | - if( 0 < $eix ) { |
|
2508 | - if( isset( $theExdate['value'][0]['tz'] )) { |
|
2509 | - if( ctype_digit( substr( $theExdate['value'][0]['tz'], -4 )) || |
|
2510 | - ( 'Z' == $theExdate['value'][0]['tz'] )) { |
|
2511 | - if( 'Z' != substr( $formatted, -1 )) |
|
2502 | + foreach ($theExdate['value'] as $eix => $exdatePart) { |
|
2503 | + $parno = count($exdatePart); |
|
2504 | + $formatted = $this->_format_date_time($exdatePart, $parno); |
|
2505 | + if (isset($theExdate['params']['TZID'])) |
|
2506 | + $formatted = str_replace('Z', '', $formatted); |
|
2507 | + if (0 < $eix) { |
|
2508 | + if (isset($theExdate['value'][0]['tz'])) { |
|
2509 | + if (ctype_digit(substr($theExdate['value'][0]['tz'], -4)) || |
|
2510 | + ('Z' == $theExdate['value'][0]['tz'])) { |
|
2511 | + if ('Z' != substr($formatted, -1)) |
|
2512 | 2512 | $formatted .= 'Z'; |
2513 | 2513 | } |
2514 | 2514 | else |
2515 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2515 | + $formatted = str_replace('Z', '', $formatted); |
|
2516 | 2516 | } |
2517 | 2517 | else |
2518 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2518 | + $formatted = str_replace('Z', '', $formatted); |
|
2519 | 2519 | } |
2520 | - $content .= ( 0 < $eix ) ? ','.$formatted : $formatted; |
|
2520 | + $content .= (0 < $eix) ? ','.$formatted : $formatted; |
|
2521 | 2521 | } |
2522 | - $attributes .= $this->_createParams( $theExdate['params'] ); |
|
2523 | - $output .= $this->_createElement( 'EXDATE', $attributes, $content ); |
|
2522 | + $attributes .= $this->_createParams($theExdate['params']); |
|
2523 | + $output .= $this->_createElement('EXDATE', $attributes, $content); |
|
2524 | 2524 | } |
2525 | 2525 | return $output; |
2526 | 2526 | } |
@@ -2534,44 +2534,44 @@ discard block |
||
2534 | 2534 | * @param integer $index, optional |
2535 | 2535 | * @return bool |
2536 | 2536 | */ |
2537 | - function setExdate( $exdates, $params=FALSE, $index=FALSE ) { |
|
2538 | - if( empty( $exdates )) { |
|
2539 | - if( $this->getConfig( 'allowEmpty' )) { |
|
2540 | - $this->_setMval( $this->exdate, null, $params, FALSE, $index ); |
|
2537 | + function setExdate($exdates, $params = FALSE, $index = FALSE) { |
|
2538 | + if (empty($exdates)) { |
|
2539 | + if ($this->getConfig('allowEmpty')) { |
|
2540 | + $this->_setMval($this->exdate, null, $params, FALSE, $index); |
|
2541 | 2541 | return TRUE; |
2542 | 2542 | } |
2543 | 2543 | else |
2544 | 2544 | return FALSE; |
2545 | 2545 | } |
2546 | - $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ))); |
|
2546 | + $input = array('params' => $this->_setParams($params, array('VALUE' => 'DATE-TIME'))); |
|
2547 | 2547 | /* ev. check 1:st date and save ev. timezone **/ |
2548 | - $this->_chkdatecfg( reset( $exdates ), $parno, $input['params'] ); |
|
2549 | - $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default parameter |
|
2550 | - foreach( $exdates as $eix => $theExdate ) { |
|
2551 | - if( $this->_isArrayTimestampDate( $theExdate )) |
|
2552 | - $exdatea = $this->_timestamp2date( $theExdate, $parno ); |
|
2553 | - elseif( is_array( $theExdate )) |
|
2554 | - $exdatea = $this->_date_time_array( $theExdate, $parno ); |
|
2555 | - elseif( 8 <= strlen( trim( $theExdate ))) // ex. 2006-08-03 10:12:18 |
|
2556 | - $exdatea = $this->_date_time_string( $theExdate, $parno ); |
|
2557 | - if( 3 == $parno ) |
|
2558 | - unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] ); |
|
2559 | - elseif( isset( $exdatea['tz'] )) |
|
2548 | + $this->_chkdatecfg(reset($exdates), $parno, $input['params']); |
|
2549 | + $this->_existRem($input['params'], 'VALUE', 'DATE-TIME'); // remove default parameter |
|
2550 | + foreach ($exdates as $eix => $theExdate) { |
|
2551 | + if ($this->_isArrayTimestampDate($theExdate)) |
|
2552 | + $exdatea = $this->_timestamp2date($theExdate, $parno); |
|
2553 | + elseif (is_array($theExdate)) |
|
2554 | + $exdatea = $this->_date_time_array($theExdate, $parno); |
|
2555 | + elseif (8 <= strlen(trim($theExdate))) // ex. 2006-08-03 10:12:18 |
|
2556 | + $exdatea = $this->_date_time_string($theExdate, $parno); |
|
2557 | + if (3 == $parno) |
|
2558 | + unset($exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz']); |
|
2559 | + elseif (isset($exdatea['tz'])) |
|
2560 | 2560 | $exdatea['tz'] = (string) $exdatea['tz']; |
2561 | - if( isset( $input['params']['TZID'] ) || |
|
2562 | - ( isset( $exdatea['tz'] ) && !$this->_isOffset( $exdatea['tz'] )) || |
|
2563 | - ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) || |
|
2564 | - ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) |
|
2565 | - unset( $exdatea['tz'] ); |
|
2561 | + if (isset($input['params']['TZID']) || |
|
2562 | + (isset($exdatea['tz']) && !$this->_isOffset($exdatea['tz'])) || |
|
2563 | + (isset($input['value'][0]) && (!isset($input['value'][0]['tz']))) || |
|
2564 | + (isset($input['value'][0]['tz']) && !$this->_isOffset($input['value'][0]['tz']))) |
|
2565 | + unset($exdatea['tz']); |
|
2566 | 2566 | $input['value'][] = $exdatea; |
2567 | 2567 | } |
2568 | - if( 0 >= count( $input['value'] )) |
|
2568 | + if (0 >= count($input['value'])) |
|
2569 | 2569 | return FALSE; |
2570 | - if( 3 == $parno ) { |
|
2570 | + if (3 == $parno) { |
|
2571 | 2571 | $input['params']['VALUE'] = 'DATE'; |
2572 | - unset( $input['params']['TZID'] ); |
|
2572 | + unset($input['params']['TZID']); |
|
2573 | 2573 | } |
2574 | - $this->_setMval( $this->exdate, $input['value'], $input['params'], FALSE, $index ); |
|
2574 | + $this->_setMval($this->exdate, $input['value'], $input['params'], FALSE, $index); |
|
2575 | 2575 | return TRUE; |
2576 | 2576 | } |
2577 | 2577 | /*********************************************************************************/ |
@@ -2586,8 +2586,8 @@ discard block |
||
2586 | 2586 | * @return string |
2587 | 2587 | */ |
2588 | 2588 | function createExrule() { |
2589 | - if( empty( $this->exrule )) return FALSE; |
|
2590 | - return $this->_format_recur( 'EXRULE', $this->exrule ); |
|
2589 | + if (empty($this->exrule)) return FALSE; |
|
2590 | + return $this->_format_recur('EXRULE', $this->exrule); |
|
2591 | 2591 | } |
2592 | 2592 | /** |
2593 | 2593 | * set calendar component property exdate |
@@ -2599,9 +2599,9 @@ discard block |
||
2599 | 2599 | * @param integer $index, optional |
2600 | 2600 | * @return bool |
2601 | 2601 | */ |
2602 | - function setExrule( $exruleset, $params=FALSE, $index=FALSE ) { |
|
2603 | - if( empty( $exruleset )) if( $this->getConfig( 'allowEmpty' )) $exruleset = null; else return FALSE; |
|
2604 | - $this->_setMval( $this->exrule, $this->_setRexrule( $exruleset ), $params, FALSE, $index ); |
|
2602 | + function setExrule($exruleset, $params = FALSE, $index = FALSE) { |
|
2603 | + if (empty($exruleset)) if ($this->getConfig('allowEmpty')) $exruleset = null; else return FALSE; |
|
2604 | + $this->_setMval($this->exrule, $this->_setRexrule($exruleset), $params, FALSE, $index); |
|
2605 | 2605 | return TRUE; |
2606 | 2606 | } |
2607 | 2607 | /*********************************************************************************/ |
@@ -2616,47 +2616,47 @@ discard block |
||
2616 | 2616 | * @return string |
2617 | 2617 | */ |
2618 | 2618 | function createFreebusy() { |
2619 | - if( empty( $this->freebusy )) return FALSE; |
|
2619 | + if (empty($this->freebusy)) return FALSE; |
|
2620 | 2620 | $output = null; |
2621 | - foreach( $this->freebusy as $freebusyPart ) { |
|
2622 | - if( empty( $freebusyPart['value'] )) { |
|
2623 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'FREEBUSY' ); |
|
2621 | + foreach ($this->freebusy as $freebusyPart) { |
|
2622 | + if (empty($freebusyPart['value'])) { |
|
2623 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('FREEBUSY'); |
|
2624 | 2624 | continue; |
2625 | 2625 | } |
2626 | 2626 | $attributes = $content = null; |
2627 | - if( isset( $freebusyPart['value']['fbtype'] )) { |
|
2627 | + if (isset($freebusyPart['value']['fbtype'])) { |
|
2628 | 2628 | $attributes .= $this->intAttrDelimiter.'FBTYPE='.$freebusyPart['value']['fbtype']; |
2629 | - unset( $freebusyPart['value']['fbtype'] ); |
|
2630 | - $freebusyPart['value'] = array_values( $freebusyPart['value'] ); |
|
2629 | + unset($freebusyPart['value']['fbtype']); |
|
2630 | + $freebusyPart['value'] = array_values($freebusyPart['value']); |
|
2631 | 2631 | } |
2632 | 2632 | else |
2633 | 2633 | $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY'; |
2634 | - $attributes .= $this->_createParams( $freebusyPart['params'] ); |
|
2634 | + $attributes .= $this->_createParams($freebusyPart['params']); |
|
2635 | 2635 | $fno = 1; |
2636 | - $cnt = count( $freebusyPart['value']); |
|
2637 | - foreach( $freebusyPart['value'] as $periodix => $freebusyPeriod ) { |
|
2638 | - $formatted = $this->_format_date_time( $freebusyPeriod[0] ); |
|
2636 | + $cnt = count($freebusyPart['value']); |
|
2637 | + foreach ($freebusyPart['value'] as $periodix => $freebusyPeriod) { |
|
2638 | + $formatted = $this->_format_date_time($freebusyPeriod[0]); |
|
2639 | 2639 | $content .= $formatted; |
2640 | 2640 | $content .= '/'; |
2641 | - $cnt2 = count( $freebusyPeriod[1]); |
|
2642 | - if( array_key_exists( 'year', $freebusyPeriod[1] )) // date-time |
|
2641 | + $cnt2 = count($freebusyPeriod[1]); |
|
2642 | + if (array_key_exists('year', $freebusyPeriod[1])) // date-time |
|
2643 | 2643 | $cnt2 = 7; |
2644 | - elseif( array_key_exists( 'week', $freebusyPeriod[1] )) // duration |
|
2644 | + elseif (array_key_exists('week', $freebusyPeriod[1])) // duration |
|
2645 | 2645 | $cnt2 = 5; |
2646 | - if(( 7 == $cnt2 ) && // period= -> date-time |
|
2647 | - isset( $freebusyPeriod[1]['year'] ) && |
|
2648 | - isset( $freebusyPeriod[1]['month'] ) && |
|
2649 | - isset( $freebusyPeriod[1]['day'] )) { |
|
2650 | - $content .= $this->_format_date_time( $freebusyPeriod[1] ); |
|
2646 | + if ((7 == $cnt2) && // period= -> date-time |
|
2647 | + isset($freebusyPeriod[1]['year']) && |
|
2648 | + isset($freebusyPeriod[1]['month']) && |
|
2649 | + isset($freebusyPeriod[1]['day'])) { |
|
2650 | + $content .= $this->_format_date_time($freebusyPeriod[1]); |
|
2651 | 2651 | } |
2652 | 2652 | else { // period= -> dur-time |
2653 | - $content .= $this->_format_duration( $freebusyPeriod[1] ); |
|
2653 | + $content .= $this->_format_duration($freebusyPeriod[1]); |
|
2654 | 2654 | } |
2655 | - if( $fno < $cnt ) |
|
2655 | + if ($fno < $cnt) |
|
2656 | 2656 | $content .= ','; |
2657 | 2657 | $fno++; |
2658 | 2658 | } |
2659 | - $output .= $this->_createElement( 'FREEBUSY', $attributes, $content ); |
|
2659 | + $output .= $this->_createElement('FREEBUSY', $attributes, $content); |
|
2660 | 2660 | } |
2661 | 2661 | return $output; |
2662 | 2662 | } |
@@ -2671,52 +2671,52 @@ discard block |
||
2671 | 2671 | * @param integer $index, optional |
2672 | 2672 | * @return bool |
2673 | 2673 | */ |
2674 | - function setFreebusy( $fbType, $fbValues, $params=FALSE, $index=FALSE ) { |
|
2675 | - if( empty( $fbValues )) { |
|
2676 | - if( $this->getConfig( 'allowEmpty' )) { |
|
2677 | - $this->_setMval( $this->freebusy, null, $params, FALSE, $index ); |
|
2674 | + function setFreebusy($fbType, $fbValues, $params = FALSE, $index = FALSE) { |
|
2675 | + if (empty($fbValues)) { |
|
2676 | + if ($this->getConfig('allowEmpty')) { |
|
2677 | + $this->_setMval($this->freebusy, null, $params, FALSE, $index); |
|
2678 | 2678 | return TRUE; |
2679 | 2679 | } |
2680 | 2680 | else |
2681 | 2681 | return FALSE; |
2682 | 2682 | } |
2683 | - $fbType = strtoupper( $fbType ); |
|
2684 | - if(( !in_array( $fbType, array( 'FREE', 'BUSY', 'BUSY-UNAVAILABLE', 'BUSY-TENTATIVE' ))) && |
|
2685 | - ( 'X-' != substr( $fbType, 0, 2 ))) |
|
2683 | + $fbType = strtoupper($fbType); |
|
2684 | + if ((!in_array($fbType, array('FREE', 'BUSY', 'BUSY-UNAVAILABLE', 'BUSY-TENTATIVE'))) && |
|
2685 | + ('X-' != substr($fbType, 0, 2))) |
|
2686 | 2686 | $fbType = 'BUSY'; |
2687 | - $input = array( 'fbtype' => $fbType ); |
|
2688 | - foreach( $fbValues as $fbPeriod ) { // periods => period |
|
2687 | + $input = array('fbtype' => $fbType); |
|
2688 | + foreach ($fbValues as $fbPeriod) { // periods => period |
|
2689 | 2689 | $freebusyPeriod = array(); |
2690 | - foreach( $fbPeriod as $fbMember ) { // pairs => singlepart |
|
2690 | + foreach ($fbPeriod as $fbMember) { // pairs => singlepart |
|
2691 | 2691 | $freebusyPairMember = array(); |
2692 | - if( is_array( $fbMember )) { |
|
2693 | - if( $this->_isArrayDate( $fbMember )) { // date-time value |
|
2694 | - $freebusyPairMember = $this->_date_time_array( $fbMember, 7 ); |
|
2692 | + if (is_array($fbMember)) { |
|
2693 | + if ($this->_isArrayDate($fbMember)) { // date-time value |
|
2694 | + $freebusyPairMember = $this->_date_time_array($fbMember, 7); |
|
2695 | 2695 | $freebusyPairMember['tz'] = 'Z'; |
2696 | 2696 | } |
2697 | - elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value |
|
2698 | - $freebusyPairMember = $this->_timestamp2date( $fbMember['timestamp'], 7 ); |
|
2697 | + elseif ($this->_isArrayTimestampDate($fbMember)) { // timestamp value |
|
2698 | + $freebusyPairMember = $this->_timestamp2date($fbMember['timestamp'], 7); |
|
2699 | 2699 | $freebusyPairMember['tz'] = 'Z'; |
2700 | 2700 | } |
2701 | 2701 | else { // array format duration |
2702 | - $freebusyPairMember = $this->_duration_array( $fbMember ); |
|
2702 | + $freebusyPairMember = $this->_duration_array($fbMember); |
|
2703 | 2703 | } |
2704 | 2704 | } |
2705 | - elseif(( 3 <= strlen( trim( $fbMember ))) && // string format duration |
|
2706 | - ( in_array( $fbMember{0}, array( 'P', '+', '-' )))) { |
|
2707 | - if( 'P' != $fbMember{0} ) |
|
2708 | - $fbmember = substr( $fbMember, 1 ); |
|
2709 | - $freebusyPairMember = $this->_duration_string( $fbMember ); |
|
2705 | + elseif ((3 <= strlen(trim($fbMember))) && // string format duration |
|
2706 | + (in_array($fbMember{0}, array('P', '+', '-')))) { |
|
2707 | + if ('P' != $fbMember{0} ) |
|
2708 | + $fbmember = substr($fbMember, 1); |
|
2709 | + $freebusyPairMember = $this->_duration_string($fbMember); |
|
2710 | 2710 | } |
2711 | - elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18 |
|
2712 | - $freebusyPairMember = $this->_date_time_string( $fbMember, 7 ); |
|
2711 | + elseif (8 <= strlen(trim($fbMember))) { // text date ex. 2006-08-03 10:12:18 |
|
2712 | + $freebusyPairMember = $this->_date_time_string($fbMember, 7); |
|
2713 | 2713 | $freebusyPairMember['tz'] = 'Z'; |
2714 | 2714 | } |
2715 | - $freebusyPeriod[] = $freebusyPairMember; |
|
2715 | + $freebusyPeriod[] = $freebusyPairMember; |
|
2716 | 2716 | } |
2717 | - $input[] = $freebusyPeriod; |
|
2717 | + $input[] = $freebusyPeriod; |
|
2718 | 2718 | } |
2719 | - $this->_setMval( $this->freebusy, $input, $params, FALSE, $index ); |
|
2719 | + $this->_setMval($this->freebusy, $input, $params, FALSE, $index); |
|
2720 | 2720 | return TRUE; |
2721 | 2721 | } |
2722 | 2722 | /*********************************************************************************/ |
@@ -2731,15 +2731,15 @@ discard block |
||
2731 | 2731 | * @return string |
2732 | 2732 | */ |
2733 | 2733 | function createGeo() { |
2734 | - if( empty( $this->geo )) return FALSE; |
|
2735 | - if( empty( $this->geo['value'] )) |
|
2736 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE; |
|
2737 | - $attributes = $this->_createParams( $this->geo['params'] ); |
|
2734 | + if (empty($this->geo)) return FALSE; |
|
2735 | + if (empty($this->geo['value'])) |
|
2736 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('GEO') : FALSE; |
|
2737 | + $attributes = $this->_createParams($this->geo['params']); |
|
2738 | 2738 | $content = null; |
2739 | - $content .= number_format( (float) $this->geo['value']['latitude'], 6, '.', ''); |
|
2739 | + $content .= number_format((float) $this->geo['value']['latitude'], 6, '.', ''); |
|
2740 | 2740 | $content .= ';'; |
2741 | - $content .= number_format( (float) $this->geo['value']['longitude'], 6, '.', ''); |
|
2742 | - return $this->_createElement( 'GEO', $attributes, $content ); |
|
2741 | + $content .= number_format((float) $this->geo['value']['longitude'], 6, '.', ''); |
|
2742 | + return $this->_createElement('GEO', $attributes, $content); |
|
2743 | 2743 | } |
2744 | 2744 | /** |
2745 | 2745 | * set calendar component property geo |
@@ -2751,15 +2751,15 @@ discard block |
||
2751 | 2751 | * @param array $params optional |
2752 | 2752 | * @return bool |
2753 | 2753 | */ |
2754 | - function setGeo( $latitude, $longitude, $params=FALSE ) { |
|
2755 | - if( !empty( $latitude ) && !empty( $longitude )) { |
|
2756 | - if( !is_array( $this->geo )) $this->geo = array(); |
|
2754 | + function setGeo($latitude, $longitude, $params = FALSE) { |
|
2755 | + if (!empty($latitude) && !empty($longitude)) { |
|
2756 | + if (!is_array($this->geo)) $this->geo = array(); |
|
2757 | 2757 | $this->geo['value']['latitude'] = $latitude; |
2758 | 2758 | $this->geo['value']['longitude'] = $longitude; |
2759 | - $this->geo['params'] = $this->_setParams( $params ); |
|
2759 | + $this->geo['params'] = $this->_setParams($params); |
|
2760 | 2760 | } |
2761 | - elseif( $this->getConfig( 'allowEmpty' )) |
|
2762 | - $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) ); |
|
2761 | + elseif ($this->getConfig('allowEmpty')) |
|
2762 | + $this->geo = array('value' => null, 'params' => $this->_setParams($params)); |
|
2763 | 2763 | else |
2764 | 2764 | return FALSE; |
2765 | 2765 | return TRUE; |
@@ -2776,10 +2776,10 @@ discard block |
||
2776 | 2776 | * @return string |
2777 | 2777 | */ |
2778 | 2778 | function createLastModified() { |
2779 | - if( empty( $this->lastmodified )) return FALSE; |
|
2780 | - $attributes = $this->_createParams( $this->lastmodified['params'] ); |
|
2781 | - $formatted = $this->_format_date_time( $this->lastmodified['value'], 7 ); |
|
2782 | - return $this->_createElement( 'LAST-MODIFIED', $attributes, $formatted ); |
|
2779 | + if (empty($this->lastmodified)) return FALSE; |
|
2780 | + $attributes = $this->_createParams($this->lastmodified['params']); |
|
2781 | + $formatted = $this->_format_date_time($this->lastmodified['value'], 7); |
|
2782 | + return $this->_createElement('LAST-MODIFIED', $attributes, $formatted); |
|
2783 | 2783 | } |
2784 | 2784 | /** |
2785 | 2785 | * set calendar component property completed |
@@ -2795,10 +2795,10 @@ discard block |
||
2795 | 2795 | * @param array $params optional |
2796 | 2796 | * @return boll |
2797 | 2797 | */ |
2798 | - function setLastModified( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
|
2799 | - if( empty( $year )) |
|
2800 | - $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' ))); |
|
2801 | - $this->lastmodified = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
|
2798 | + function setLastModified($year = FALSE, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) { |
|
2799 | + if (empty($year)) |
|
2800 | + $year = date('Ymd\THis', mktime(date('H'), date('i'), date('s') - date('Z'), date('m'), date('d'), date('Y'))); |
|
2801 | + $this->lastmodified = $this->_setDate2($year, $month, $day, $hour, $min, $sec, $params); |
|
2802 | 2802 | return TRUE; |
2803 | 2803 | } |
2804 | 2804 | /*********************************************************************************/ |
@@ -2813,12 +2813,12 @@ discard block |
||
2813 | 2813 | * @return string |
2814 | 2814 | */ |
2815 | 2815 | function createLocation() { |
2816 | - if( empty( $this->location )) return FALSE; |
|
2817 | - if( empty( $this->location['value'] )) |
|
2818 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE; |
|
2819 | - $attributes = $this->_createParams( $this->location['params'], array( 'ALTREP', 'LANGUAGE' )); |
|
2820 | - $content = $this->_strrep( $this->location['value'] ); |
|
2821 | - return $this->_createElement( 'LOCATION', $attributes, $content ); |
|
2816 | + if (empty($this->location)) return FALSE; |
|
2817 | + if (empty($this->location['value'])) |
|
2818 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('LOCATION') : FALSE; |
|
2819 | + $attributes = $this->_createParams($this->location['params'], array('ALTREP', 'LANGUAGE')); |
|
2820 | + $content = $this->_strrep($this->location['value']); |
|
2821 | + return $this->_createElement('LOCATION', $attributes, $content); |
|
2822 | 2822 | } |
2823 | 2823 | /** |
2824 | 2824 | * set calendar component property location |
@@ -2829,9 +2829,9 @@ discard block |
||
2829 | 2829 | * @param array params optional |
2830 | 2830 | * @return bool |
2831 | 2831 | */ |
2832 | - function setLocation( $value, $params=FALSE ) { |
|
2833 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2834 | - $this->location = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
2832 | + function setLocation($value, $params = FALSE) { |
|
2833 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
2834 | + $this->location = array('value' => $value, 'params' => $this->_setParams($params)); |
|
2835 | 2835 | return TRUE; |
2836 | 2836 | } |
2837 | 2837 | /*********************************************************************************/ |
@@ -2846,13 +2846,13 @@ discard block |
||
2846 | 2846 | * @return string |
2847 | 2847 | */ |
2848 | 2848 | function createOrganizer() { |
2849 | - if( empty( $this->organizer )) return FALSE; |
|
2850 | - if( empty( $this->organizer['value'] )) |
|
2851 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE; |
|
2852 | - $attributes = $this->_createParams( $this->organizer['params'] |
|
2853 | - , array( 'CN', 'DIR', 'LANGUAGE', 'SENT-BY' )); |
|
2849 | + if (empty($this->organizer)) return FALSE; |
|
2850 | + if (empty($this->organizer['value'])) |
|
2851 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('ORGANIZER') : FALSE; |
|
2852 | + $attributes = $this->_createParams($this->organizer['params'] |
|
2853 | + , array('CN', 'DIR', 'LANGUAGE', 'SENT-BY')); |
|
2854 | 2854 | $content = 'MAILTO:'.$this->organizer['value']; |
2855 | - return $this->_createElement( 'ORGANIZER', $attributes, $content ); |
|
2855 | + return $this->_createElement('ORGANIZER', $attributes, $content); |
|
2856 | 2856 | } |
2857 | 2857 | /** |
2858 | 2858 | * set calendar component property organizer |
@@ -2863,14 +2863,14 @@ discard block |
||
2863 | 2863 | * @param array params optional |
2864 | 2864 | * @return bool |
2865 | 2865 | */ |
2866 | - function setOrganizer( $value, $params=FALSE ) { |
|
2867 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2868 | - $value = str_replace ( 'MAILTO:', '', $value ); |
|
2869 | - $value = str_replace ( 'mailto:', '', $value ); |
|
2870 | - $this->organizer = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
2871 | - if( isset( $this->organizer['params']['SENT-BY'] )) { |
|
2872 | - if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 ))) |
|
2873 | - $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 ); |
|
2866 | + function setOrganizer($value, $params = FALSE) { |
|
2867 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
2868 | + $value = str_replace('MAILTO:', '', $value); |
|
2869 | + $value = str_replace('mailto:', '', $value); |
|
2870 | + $this->organizer = array('value' => $value, 'params' => $this->_setParams($params)); |
|
2871 | + if (isset($this->organizer['params']['SENT-BY'])) { |
|
2872 | + if ('MAILTO' == strtoupper(substr($this->organizer['params']['SENT-BY'], 0, 6))) |
|
2873 | + $this->organizer['params']['SENT-BY'] = substr($this->organizer['params']['SENT-BY'], 7); |
|
2874 | 2874 | } |
2875 | 2875 | return TRUE; |
2876 | 2876 | } |
@@ -2886,11 +2886,11 @@ discard block |
||
2886 | 2886 | * @return string |
2887 | 2887 | */ |
2888 | 2888 | function createPercentComplete() { |
2889 | - if( empty( $this->percentcomplete )) return FALSE; |
|
2890 | - if( empty( $this->percentcomplete['value'] )) |
|
2891 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE; |
|
2892 | - $attributes = $this->_createParams( $this->percentcomplete['params'] ); |
|
2893 | - return $this->_createElement( 'PERCENT-COMPLETE', $attributes, $this->percentcomplete['value'] ); |
|
2889 | + if (empty($this->percentcomplete)) return FALSE; |
|
2890 | + if (empty($this->percentcomplete['value'])) |
|
2891 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('PERCENT-COMPLETE') : FALSE; |
|
2892 | + $attributes = $this->_createParams($this->percentcomplete['params']); |
|
2893 | + return $this->_createElement('PERCENT-COMPLETE', $attributes, $this->percentcomplete['value']); |
|
2894 | 2894 | } |
2895 | 2895 | /** |
2896 | 2896 | * set calendar component property percent-complete |
@@ -2901,9 +2901,9 @@ discard block |
||
2901 | 2901 | * @param array $params optional |
2902 | 2902 | * @return bool |
2903 | 2903 | */ |
2904 | - function setPercentComplete( $value, $params=FALSE ) { |
|
2905 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2906 | - $this->percentcomplete = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
2904 | + function setPercentComplete($value, $params = FALSE) { |
|
2905 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
2906 | + $this->percentcomplete = array('value' => $value, 'params' => $this->_setParams($params)); |
|
2907 | 2907 | return TRUE; |
2908 | 2908 | } |
2909 | 2909 | /*********************************************************************************/ |
@@ -2918,11 +2918,11 @@ discard block |
||
2918 | 2918 | * @return string |
2919 | 2919 | */ |
2920 | 2920 | function createPriority() { |
2921 | - if( empty( $this->priority )) return FALSE; |
|
2922 | - if( empty( $this->priority['value'] )) |
|
2923 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE; |
|
2924 | - $attributes = $this->_createParams( $this->priority['params'] ); |
|
2925 | - return $this->_createElement( 'PRIORITY', $attributes, $this->priority['value'] ); |
|
2921 | + if (empty($this->priority)) return FALSE; |
|
2922 | + if (empty($this->priority['value'])) |
|
2923 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('PRIORITY') : FALSE; |
|
2924 | + $attributes = $this->_createParams($this->priority['params']); |
|
2925 | + return $this->_createElement('PRIORITY', $attributes, $this->priority['value']); |
|
2926 | 2926 | } |
2927 | 2927 | /** |
2928 | 2928 | * set calendar component property priority |
@@ -2933,9 +2933,9 @@ discard block |
||
2933 | 2933 | * @param array $params optional |
2934 | 2934 | * @return bool |
2935 | 2935 | */ |
2936 | - function setPriority( $value, $params=FALSE ) { |
|
2937 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2938 | - $this->priority = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
2936 | + function setPriority($value, $params = FALSE) { |
|
2937 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
2938 | + $this->priority = array('value' => $value, 'params' => $this->_setParams($params)); |
|
2939 | 2939 | return TRUE; |
2940 | 2940 | } |
2941 | 2941 | /*********************************************************************************/ |
@@ -2950,91 +2950,91 @@ discard block |
||
2950 | 2950 | * @return string |
2951 | 2951 | */ |
2952 | 2952 | function createRdate() { |
2953 | - if( empty( $this->rdate )) return FALSE; |
|
2954 | - $utctime = ( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE; |
|
2953 | + if (empty($this->rdate)) return FALSE; |
|
2954 | + $utctime = (in_array($this->objName, array('vtimezone', 'standard', 'daylight'))) ? TRUE : FALSE; |
|
2955 | 2955 | $output = null; |
2956 | - if( $utctime ) |
|
2957 | - unset( $this->rdate['params']['TZID'] ); |
|
2958 | - foreach( $this->rdate as $theRdate ) { |
|
2959 | - if( empty( $theRdate['value'] )) { |
|
2960 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RDATE' ); |
|
2956 | + if ($utctime) |
|
2957 | + unset($this->rdate['params']['TZID']); |
|
2958 | + foreach ($this->rdate as $theRdate) { |
|
2959 | + if (empty($theRdate['value'])) { |
|
2960 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('RDATE'); |
|
2961 | 2961 | continue; |
2962 | 2962 | } |
2963 | - if( $utctime ) |
|
2964 | - unset( $theRdate['params']['TZID'] ); |
|
2965 | - $attributes = $this->_createParams( $theRdate['params'] ); |
|
2966 | - $cnt = count( $theRdate['value'] ); |
|
2963 | + if ($utctime) |
|
2964 | + unset($theRdate['params']['TZID']); |
|
2965 | + $attributes = $this->_createParams($theRdate['params']); |
|
2966 | + $cnt = count($theRdate['value']); |
|
2967 | 2967 | $content = null; |
2968 | 2968 | $rno = 1; |
2969 | - foreach( $theRdate['value'] as $rpix => $rdatePart ) { |
|
2969 | + foreach ($theRdate['value'] as $rpix => $rdatePart) { |
|
2970 | 2970 | $contentPart = null; |
2971 | - if( is_array( $rdatePart ) && |
|
2972 | - isset( $theRdate['params']['VALUE'] ) && ( 'PERIOD' == $theRdate['params']['VALUE'] )) { // PERIOD |
|
2973 | - if( $utctime ) |
|
2974 | - unset( $rdatePart[0]['tz'] ); |
|
2975 | - $formatted = $this->_format_date_time( $rdatePart[0]); // PERIOD part 1 |
|
2976 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
2977 | - $formatted = str_replace( 'Z', '', $formatted); |
|
2978 | - if( 0 < $rpix ) { |
|
2979 | - if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) { |
|
2980 | - if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z'; |
|
2971 | + if (is_array($rdatePart) && |
|
2972 | + isset($theRdate['params']['VALUE']) && ('PERIOD' == $theRdate['params']['VALUE'])) { // PERIOD |
|
2973 | + if ($utctime) |
|
2974 | + unset($rdatePart[0]['tz']); |
|
2975 | + $formatted = $this->_format_date_time($rdatePart[0]); // PERIOD part 1 |
|
2976 | + if ($utctime || !empty($theRdate['params']['TZID'])) |
|
2977 | + $formatted = str_replace('Z', '', $formatted); |
|
2978 | + if (0 < $rpix) { |
|
2979 | + if (!empty($rdatePart[0]['tz']) && $this->_isOffset($rdatePart[0]['tz'])) { |
|
2980 | + if ('Z' != substr($formatted, -1)) $formatted .= 'Z'; |
|
2981 | 2981 | } |
2982 | 2982 | else |
2983 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2983 | + $formatted = str_replace('Z', '', $formatted); |
|
2984 | 2984 | } |
2985 | 2985 | $contentPart .= $formatted; |
2986 | 2986 | $contentPart .= '/'; |
2987 | - $cnt2 = count( $rdatePart[1]); |
|
2988 | - if( array_key_exists( 'year', $rdatePart[1] )) { |
|
2989 | - if( array_key_exists( 'hour', $rdatePart[1] )) |
|
2990 | - $cnt2 = 7; // date-time |
|
2987 | + $cnt2 = count($rdatePart[1]); |
|
2988 | + if (array_key_exists('year', $rdatePart[1])) { |
|
2989 | + if (array_key_exists('hour', $rdatePart[1])) |
|
2990 | + $cnt2 = 7; // date-time |
|
2991 | 2991 | else |
2992 | - $cnt2 = 3; // date |
|
2992 | + $cnt2 = 3; // date |
|
2993 | 2993 | } |
2994 | - elseif( array_key_exists( 'week', $rdatePart[1] )) // duration |
|
2994 | + elseif (array_key_exists('week', $rdatePart[1])) // duration |
|
2995 | 2995 | $cnt2 = 5; |
2996 | - if(( 7 == $cnt2 ) && // period= -> date-time |
|
2997 | - isset( $rdatePart[1]['year'] ) && |
|
2998 | - isset( $rdatePart[1]['month'] ) && |
|
2999 | - isset( $rdatePart[1]['day'] )) { |
|
3000 | - if( $utctime ) |
|
3001 | - unset( $rdatePart[1]['tz'] ); |
|
3002 | - $formatted = $this->_format_date_time( $rdatePart[1] ); // PERIOD part 2 |
|
3003 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
3004 | - $formatted = str_replace( 'Z', '', $formatted); |
|
3005 | - if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) { |
|
3006 | - if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z'; |
|
2996 | + if ((7 == $cnt2) && // period= -> date-time |
|
2997 | + isset($rdatePart[1]['year']) && |
|
2998 | + isset($rdatePart[1]['month']) && |
|
2999 | + isset($rdatePart[1]['day'])) { |
|
3000 | + if ($utctime) |
|
3001 | + unset($rdatePart[1]['tz']); |
|
3002 | + $formatted = $this->_format_date_time($rdatePart[1]); // PERIOD part 2 |
|
3003 | + if ($utctime || !empty($theRdate['params']['TZID'])) |
|
3004 | + $formatted = str_replace('Z', '', $formatted); |
|
3005 | + if (!empty($rdatePart[0]['tz']) && $this->_isOffset($rdatePart[0]['tz'])) { |
|
3006 | + if ('Z' != substr($formatted, -1)) $formatted .= 'Z'; |
|
3007 | 3007 | } |
3008 | 3008 | else |
3009 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
3009 | + $formatted = str_replace('Z', '', $formatted); |
|
3010 | 3010 | $contentPart .= $formatted; |
3011 | 3011 | } |
3012 | 3012 | else { // period= -> dur-time |
3013 | - $contentPart .= $this->_format_duration( $rdatePart[1] ); |
|
3013 | + $contentPart .= $this->_format_duration($rdatePart[1]); |
|
3014 | 3014 | } |
3015 | 3015 | } // PERIOD end |
3016 | 3016 | else { // SINGLE date start |
3017 | - if( $utctime ) |
|
3018 | - unset( $rdatePart['tz'] ); |
|
3019 | - $formatted = $this->_format_date_time( $rdatePart); |
|
3020 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
3021 | - $formatted = str_replace( 'Z', '', $formatted); |
|
3022 | - if( !$utctime && ( 0 < $rpix )) { |
|
3023 | - if( !empty( $theRdate['value'][0]['tz'] ) && $this->_isOffset( $theRdate['value'][0]['tz'] )) { |
|
3024 | - if( 'Z' != substr( $formatted, -1 )) |
|
3017 | + if ($utctime) |
|
3018 | + unset($rdatePart['tz']); |
|
3019 | + $formatted = $this->_format_date_time($rdatePart); |
|
3020 | + if ($utctime || !empty($theRdate['params']['TZID'])) |
|
3021 | + $formatted = str_replace('Z', '', $formatted); |
|
3022 | + if (!$utctime && (0 < $rpix)) { |
|
3023 | + if (!empty($theRdate['value'][0]['tz']) && $this->_isOffset($theRdate['value'][0]['tz'])) { |
|
3024 | + if ('Z' != substr($formatted, -1)) |
|
3025 | 3025 | $formatted .= 'Z'; |
3026 | 3026 | } |
3027 | 3027 | else |
3028 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
3028 | + $formatted = str_replace('Z', '', $formatted); |
|
3029 | 3029 | } |
3030 | 3030 | $contentPart .= $formatted; |
3031 | 3031 | } |
3032 | 3032 | $content .= $contentPart; |
3033 | - if( $rno < $cnt ) |
|
3033 | + if ($rno < $cnt) |
|
3034 | 3034 | $content .= ','; |
3035 | 3035 | $rno++; |
3036 | 3036 | } |
3037 | - $output .= $this->_createElement( 'RDATE', $attributes, $content ); |
|
3037 | + $output .= $this->_createElement('RDATE', $attributes, $content); |
|
3038 | 3038 | } |
3039 | 3039 | return $output; |
3040 | 3040 | } |
@@ -3048,93 +3048,93 @@ discard block |
||
3048 | 3048 | * @param integer $index, optional |
3049 | 3049 | * @return bool |
3050 | 3050 | */ |
3051 | - function setRdate( $rdates, $params=FALSE, $index=FALSE ) { |
|
3052 | - if( empty( $rdates )) { |
|
3053 | - if( $this->getConfig( 'allowEmpty' )) { |
|
3054 | - $this->_setMval( $this->rdate, null, $params, FALSE, $index ); |
|
3051 | + function setRdate($rdates, $params = FALSE, $index = FALSE) { |
|
3052 | + if (empty($rdates)) { |
|
3053 | + if ($this->getConfig('allowEmpty')) { |
|
3054 | + $this->_setMval($this->rdate, null, $params, FALSE, $index); |
|
3055 | 3055 | return TRUE; |
3056 | 3056 | } |
3057 | 3057 | else |
3058 | 3058 | return FALSE; |
3059 | 3059 | } |
3060 | - $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ))); |
|
3061 | - if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) { |
|
3062 | - unset( $input['params']['TZID'] ); |
|
3060 | + $input = array('params' => $this->_setParams($params, array('VALUE' => 'DATE-TIME'))); |
|
3061 | + if (in_array($this->objName, array('vtimezone', 'standard', 'daylight'))) { |
|
3062 | + unset($input['params']['TZID']); |
|
3063 | 3063 | $input['params']['VALUE'] = 'DATE-TIME'; |
3064 | 3064 | } |
3065 | 3065 | /* check if PERIOD, if not set */ |
3066 | - if((!isset( $input['params']['VALUE'] ) || !in_array( $input['params']['VALUE'], array( 'DATE', 'PERIOD' ))) && |
|
3067 | - isset( $rdates[0] ) && is_array( $rdates[0] ) && ( 2 == count( $rdates[0] )) && |
|
3068 | - isset( $rdates[0][0] ) && isset( $rdates[0][1] ) && !isset( $rdates[0]['timestamp'] ) && |
|
3069 | - (( is_array( $rdates[0][0] ) && ( isset( $rdates[0][0]['timestamp'] ) || |
|
3070 | - $this->_isArrayDate( $rdates[0][0] ))) || |
|
3071 | - ( is_string( $rdates[0][0] ) && ( 8 <= strlen( trim( $rdates[0][0] ))))) && |
|
3072 | - ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] )))))) |
|
3066 | + if ((!isset($input['params']['VALUE']) || !in_array($input['params']['VALUE'], array('DATE', 'PERIOD'))) && |
|
3067 | + isset($rdates[0]) && is_array($rdates[0]) && (2 == count($rdates[0])) && |
|
3068 | + isset($rdates[0][0]) && isset($rdates[0][1]) && !isset($rdates[0]['timestamp']) && |
|
3069 | + ((is_array($rdates[0][0]) && (isset($rdates[0][0]['timestamp']) || |
|
3070 | + $this->_isArrayDate($rdates[0][0]))) || |
|
3071 | + (is_string($rdates[0][0]) && (8 <= strlen(trim($rdates[0][0]))))) && |
|
3072 | + (is_array($rdates[0][1]) || (is_string($rdates[0][1]) && (3 <= strlen(trim($rdates[0][1])))))) |
|
3073 | 3073 | $input['params']['VALUE'] = 'PERIOD'; |
3074 | 3074 | /* check 1:st date, upd. $parno (opt) and save ev. timezone **/ |
3075 | - $date = reset( $rdates ); |
|
3076 | - if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) // PERIOD |
|
3077 | - $date = reset( $date ); |
|
3078 | - $this->_chkdatecfg( $date, $parno, $input['params'] ); |
|
3079 | - if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) |
|
3080 | - unset( $input['params']['TZID'] ); |
|
3081 | - $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default |
|
3082 | - foreach( $rdates as $rpix => $theRdate ) { |
|
3075 | + $date = reset($rdates); |
|
3076 | + if (isset($input['params']['VALUE']) && ('PERIOD' == $input['params']['VALUE'])) // PERIOD |
|
3077 | + $date = reset($date); |
|
3078 | + $this->_chkdatecfg($date, $parno, $input['params']); |
|
3079 | + if (in_array($this->objName, array('vtimezone', 'standard', 'daylight'))) |
|
3080 | + unset($input['params']['TZID']); |
|
3081 | + $this->_existRem($input['params'], 'VALUE', 'DATE-TIME'); // remove default |
|
3082 | + foreach ($rdates as $rpix => $theRdate) { |
|
3083 | 3083 | $inputa = null; |
3084 | - if( is_array( $theRdate )) { |
|
3085 | - if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) { // PERIOD |
|
3086 | - foreach( $theRdate as $rix => $rPeriod ) { |
|
3087 | - if( is_array( $rPeriod )) { |
|
3088 | - if( $this->_isArrayTimestampDate( $rPeriod )) // timestamp |
|
3089 | - $inputab = ( isset( $rPeriod['tz'] )) ? $this->_timestamp2date( $rPeriod, $parno ) : $this->_timestamp2date( $rPeriod, 6 ); |
|
3090 | - elseif( $this->_isArrayDate( $rPeriod )) |
|
3091 | - $inputab = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 ); |
|
3092 | - elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod )))) // text-date |
|
3093 | - $inputab = $this->_date_time_string( reset( $rPeriod ), $parno ); |
|
3084 | + if (is_array($theRdate)) { |
|
3085 | + if (isset($input['params']['VALUE']) && ('PERIOD' == $input['params']['VALUE'])) { // PERIOD |
|
3086 | + foreach ($theRdate as $rix => $rPeriod) { |
|
3087 | + if (is_array($rPeriod)) { |
|
3088 | + if ($this->_isArrayTimestampDate($rPeriod)) // timestamp |
|
3089 | + $inputab = (isset($rPeriod['tz'])) ? $this->_timestamp2date($rPeriod, $parno) : $this->_timestamp2date($rPeriod, 6); |
|
3090 | + elseif ($this->_isArrayDate($rPeriod)) |
|
3091 | + $inputab = (3 < count($rPeriod)) ? $this->_date_time_array($rPeriod, $parno) : $this->_date_time_array($rPeriod, 6); |
|
3092 | + elseif ((1 == count($rPeriod)) && (8 <= strlen(reset($rPeriod)))) // text-date |
|
3093 | + $inputab = $this->_date_time_string(reset($rPeriod), $parno); |
|
3094 | 3094 | else // array format duration |
3095 | - $inputab = $this->_duration_array( $rPeriod ); |
|
3095 | + $inputab = $this->_duration_array($rPeriod); |
|
3096 | 3096 | } |
3097 | - elseif(( 3 <= strlen( trim( $rPeriod ))) && // string format duration |
|
3098 | - ( in_array( $rPeriod{0}, array( 'P', '+', '-' )))) { |
|
3099 | - if( 'P' != $rPeriod{0} ) |
|
3100 | - $rPeriod = substr( $rPeriod, 1 ); |
|
3101 | - $inputab = $this->_duration_string( $rPeriod ); |
|
3097 | + elseif ((3 <= strlen(trim($rPeriod))) && // string format duration |
|
3098 | + (in_array($rPeriod{0}, array('P', '+', '-')))) { |
|
3099 | + if ('P' != $rPeriod{0} ) |
|
3100 | + $rPeriod = substr($rPeriod, 1); |
|
3101 | + $inputab = $this->_duration_string($rPeriod); |
|
3102 | 3102 | } |
3103 | - elseif( 8 <= strlen( trim( $rPeriod ))) // text date ex. 2006-08-03 10:12:18 |
|
3104 | - $inputab = $this->_date_time_string( $rPeriod, $parno ); |
|
3105 | - if( isset( $input['params']['TZID'] ) || |
|
3106 | - ( isset( $inputab['tz'] ) && !$this->_isOffset( $inputab['tz'] )) || |
|
3107 | - ( isset( $inputa[0] ) && ( !isset( $inputa[0]['tz'] ))) || |
|
3108 | - ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] ))) |
|
3109 | - unset( $inputab['tz'] ); |
|
3110 | - $inputa[] = $inputab; |
|
3103 | + elseif (8 <= strlen(trim($rPeriod))) // text date ex. 2006-08-03 10:12:18 |
|
3104 | + $inputab = $this->_date_time_string($rPeriod, $parno); |
|
3105 | + if (isset($input['params']['TZID']) || |
|
3106 | + (isset($inputab['tz']) && !$this->_isOffset($inputab['tz'])) || |
|
3107 | + (isset($inputa[0]) && (!isset($inputa[0]['tz']))) || |
|
3108 | + (isset($inputa[0]['tz']) && !$this->_isOffset($inputa[0]['tz']))) |
|
3109 | + unset($inputab['tz']); |
|
3110 | + $inputa[] = $inputab; |
|
3111 | 3111 | } |
3112 | 3112 | } // PERIOD end |
3113 | - elseif ( $this->_isArrayTimestampDate( $theRdate )) // timestamp |
|
3114 | - $inputa = $this->_timestamp2date( $theRdate, $parno ); |
|
3113 | + elseif ($this->_isArrayTimestampDate($theRdate)) // timestamp |
|
3114 | + $inputa = $this->_timestamp2date($theRdate, $parno); |
|
3115 | 3115 | else // date[-time] |
3116 | - $inputa = $this->_date_time_array( $theRdate, $parno ); |
|
3116 | + $inputa = $this->_date_time_array($theRdate, $parno); |
|
3117 | 3117 | } |
3118 | - elseif( 8 <= strlen( trim( $theRdate ))) // text date ex. 2006-08-03 10:12:18 |
|
3119 | - $inputa = $this->_date_time_string( $theRdate, $parno ); |
|
3120 | - if( !isset( $input['params']['VALUE'] ) || ( 'PERIOD' != $input['params']['VALUE'] )) { // no PERIOD |
|
3121 | - if( 3 == $parno ) |
|
3122 | - unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] ); |
|
3123 | - elseif( isset( $inputa['tz'] )) |
|
3118 | + elseif (8 <= strlen(trim($theRdate))) // text date ex. 2006-08-03 10:12:18 |
|
3119 | + $inputa = $this->_date_time_string($theRdate, $parno); |
|
3120 | + if (!isset($input['params']['VALUE']) || ('PERIOD' != $input['params']['VALUE'])) { // no PERIOD |
|
3121 | + if (3 == $parno) |
|
3122 | + unset($inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz']); |
|
3123 | + elseif (isset($inputa['tz'])) |
|
3124 | 3124 | $inputa['tz'] = (string) $inputa['tz']; |
3125 | - if( isset( $input['params']['TZID'] ) || |
|
3126 | - ( isset( $inputa['tz'] ) && !$this->_isOffset( $inputa['tz'] )) || |
|
3127 | - ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) || |
|
3128 | - ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) |
|
3129 | - unset( $inputa['tz'] ); |
|
3125 | + if (isset($input['params']['TZID']) || |
|
3126 | + (isset($inputa['tz']) && !$this->_isOffset($inputa['tz'])) || |
|
3127 | + (isset($input['value'][0]) && (!isset($input['value'][0]['tz']))) || |
|
3128 | + (isset($input['value'][0]['tz']) && !$this->_isOffset($input['value'][0]['tz']))) |
|
3129 | + unset($inputa['tz']); |
|
3130 | 3130 | } |
3131 | 3131 | $input['value'][] = $inputa; |
3132 | 3132 | } |
3133 | - if( 3 == $parno ) { |
|
3133 | + if (3 == $parno) { |
|
3134 | 3134 | $input['params']['VALUE'] = 'DATE'; |
3135 | - unset( $input['params']['TZID'] ); |
|
3135 | + unset($input['params']['TZID']); |
|
3136 | 3136 | } |
3137 | - $this->_setMval( $this->rdate, $input['value'], $input['params'], FALSE, $index ); |
|
3137 | + $this->_setMval($this->rdate, $input['value'], $input['params'], FALSE, $index); |
|
3138 | 3138 | return TRUE; |
3139 | 3139 | } |
3140 | 3140 | /*********************************************************************************/ |
@@ -3149,12 +3149,12 @@ discard block |
||
3149 | 3149 | * @return string |
3150 | 3150 | */ |
3151 | 3151 | function createRecurrenceid() { |
3152 | - if( empty( $this->recurrenceid )) return FALSE; |
|
3153 | - if( empty( $this->recurrenceid['value'] )) |
|
3154 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE; |
|
3155 | - $formatted = $this->_format_date_time( $this->recurrenceid['value'] ); |
|
3156 | - $attributes = $this->_createParams( $this->recurrenceid['params'] ); |
|
3157 | - return $this->_createElement( 'RECURRENCE-ID', $attributes, $formatted ); |
|
3152 | + if (empty($this->recurrenceid)) return FALSE; |
|
3153 | + if (empty($this->recurrenceid['value'])) |
|
3154 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('RECURRENCE-ID') : FALSE; |
|
3155 | + $formatted = $this->_format_date_time($this->recurrenceid['value']); |
|
3156 | + $attributes = $this->_createParams($this->recurrenceid['params']); |
|
3157 | + return $this->_createElement('RECURRENCE-ID', $attributes, $formatted); |
|
3158 | 3158 | } |
3159 | 3159 | /** |
3160 | 3160 | * set calendar component property recurrence-id |
@@ -3170,16 +3170,16 @@ discard block |
||
3170 | 3170 | * @param array $params optional |
3171 | 3171 | * @return bool |
3172 | 3172 | */ |
3173 | - function setRecurrenceid( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) { |
|
3174 | - if( empty( $year )) { |
|
3175 | - if( $this->getConfig( 'allowEmpty' )) { |
|
3176 | - $this->recurrenceid = array( 'value' => null, 'params' => null ); |
|
3173 | + function setRecurrenceid($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE) { |
|
3174 | + if (empty($year)) { |
|
3175 | + if ($this->getConfig('allowEmpty')) { |
|
3176 | + $this->recurrenceid = array('value' => null, 'params' => null); |
|
3177 | 3177 | return TRUE; |
3178 | 3178 | } |
3179 | 3179 | else |
3180 | 3180 | return FALSE; |
3181 | 3181 | } |
3182 | - $this->recurrenceid = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
|
3182 | + $this->recurrenceid = $this->_setDate($year, $month, $day, $hour, $min, $sec, $tz, $params); |
|
3183 | 3183 | return TRUE; |
3184 | 3184 | } |
3185 | 3185 | /*********************************************************************************/ |
@@ -3194,18 +3194,18 @@ discard block |
||
3194 | 3194 | * @return string |
3195 | 3195 | */ |
3196 | 3196 | function createRelatedTo() { |
3197 | - if( empty( $this->relatedto )) return FALSE; |
|
3197 | + if (empty($this->relatedto)) return FALSE; |
|
3198 | 3198 | $output = null; |
3199 | - foreach( $this->relatedto as $relation ) { |
|
3200 | - if( empty( $relation['value'] )) { |
|
3201 | - if( $this->getConfig( 'allowEmpty' )) $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] )); |
|
3199 | + foreach ($this->relatedto as $relation) { |
|
3200 | + if (empty($relation['value'])) { |
|
3201 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('RELATED-TO', $this->_createParams($relation['params'])); |
|
3202 | 3202 | continue; |
3203 | 3203 | } |
3204 | - $attributes = $this->_createParams( $relation['params'] ); |
|
3205 | - $content = ( 'xcal' != $this->format ) ? '<' : ''; |
|
3206 | - $content .= $this->_strrep( $relation['value'] ); |
|
3207 | - $content .= ( 'xcal' != $this->format ) ? '>' : ''; |
|
3208 | - $output .= $this->_createElement( 'RELATED-TO', $attributes, $content ); |
|
3204 | + $attributes = $this->_createParams($relation['params']); |
|
3205 | + $content = ('xcal' != $this->format) ? '<' : ''; |
|
3206 | + $content .= $this->_strrep($relation['value']); |
|
3207 | + $content .= ('xcal' != $this->format) ? '>' : ''; |
|
3208 | + $output .= $this->_createElement('RELATED-TO', $attributes, $content); |
|
3209 | 3209 | } |
3210 | 3210 | return $output; |
3211 | 3211 | } |
@@ -3219,12 +3219,12 @@ discard block |
||
3219 | 3219 | * @param index $index, optional |
3220 | 3220 | * @return bool |
3221 | 3221 | */ |
3222 | - function setRelatedTo( $value, $params=FALSE, $index=FALSE ) { |
|
3223 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3224 | - if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 ))) |
|
3225 | - $value = substr( $value, 1, ( strlen( $value ) - 2 )); |
|
3226 | - $this->_existRem( $params, 'RELTYPE', 'PARENT', TRUE ); // remove default |
|
3227 | - $this->_setMval( $this->relatedto, $value, $params, FALSE, $index ); |
|
3222 | + function setRelatedTo($value, $params = FALSE, $index = FALSE) { |
|
3223 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3224 | + if (('<' == substr($value, 0, 1)) && ('>' == substr($value, -1))) |
|
3225 | + $value = substr($value, 1, (strlen($value) - 2)); |
|
3226 | + $this->_existRem($params, 'RELTYPE', 'PARENT', TRUE); // remove default |
|
3227 | + $this->_setMval($this->relatedto, $value, $params, FALSE, $index); |
|
3228 | 3228 | return TRUE; |
3229 | 3229 | } |
3230 | 3230 | /*********************************************************************************/ |
@@ -3239,11 +3239,11 @@ discard block |
||
3239 | 3239 | * @return string |
3240 | 3240 | */ |
3241 | 3241 | function createRepeat() { |
3242 | - if( empty( $this->repeat )) return FALSE; |
|
3243 | - if( empty( $this->repeat['value'] )) |
|
3244 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE; |
|
3245 | - $attributes = $this->_createParams( $this->repeat['params'] ); |
|
3246 | - return $this->_createElement( 'REPEAT', $attributes, $this->repeat['value'] ); |
|
3242 | + if (empty($this->repeat)) return FALSE; |
|
3243 | + if (empty($this->repeat['value'])) |
|
3244 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('REPEAT') : FALSE; |
|
3245 | + $attributes = $this->_createParams($this->repeat['params']); |
|
3246 | + return $this->_createElement('REPEAT', $attributes, $this->repeat['value']); |
|
3247 | 3247 | } |
3248 | 3248 | /** |
3249 | 3249 | * set calendar component property transp |
@@ -3254,9 +3254,9 @@ discard block |
||
3254 | 3254 | * @param array $params optional |
3255 | 3255 | * @return void |
3256 | 3256 | */ |
3257 | - function setRepeat( $value, $params=FALSE ) { |
|
3258 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3259 | - $this->repeat = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3257 | + function setRepeat($value, $params = FALSE) { |
|
3258 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3259 | + $this->repeat = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3260 | 3260 | return TRUE; |
3261 | 3261 | } |
3262 | 3262 | /*********************************************************************************/ |
@@ -3270,19 +3270,19 @@ discard block |
||
3270 | 3270 | * @return string |
3271 | 3271 | */ |
3272 | 3272 | function createRequestStatus() { |
3273 | - if( empty( $this->requeststatus )) return FALSE; |
|
3273 | + if (empty($this->requeststatus)) return FALSE; |
|
3274 | 3274 | $output = null; |
3275 | - foreach( $this->requeststatus as $rstat ) { |
|
3276 | - if( empty( $rstat['value']['statcode'] )) { |
|
3277 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'REQUEST-STATUS' ); |
|
3275 | + foreach ($this->requeststatus as $rstat) { |
|
3276 | + if (empty($rstat['value']['statcode'])) { |
|
3277 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('REQUEST-STATUS'); |
|
3278 | 3278 | continue; |
3279 | 3279 | } |
3280 | - $attributes = $this->_createParams( $rstat['params'], array( 'LANGUAGE' )); |
|
3281 | - $content = number_format( (float) $rstat['value']['statcode'], 2, '.', ''); |
|
3282 | - $content .= ';'.$this->_strrep( $rstat['value']['text'] ); |
|
3283 | - if( isset( $rstat['value']['extdata'] )) |
|
3284 | - $content .= ';'.$this->_strrep( $rstat['value']['extdata'] ); |
|
3285 | - $output .= $this->_createElement( 'REQUEST-STATUS', $attributes, $content ); |
|
3280 | + $attributes = $this->_createParams($rstat['params'], array('LANGUAGE')); |
|
3281 | + $content = number_format((float) $rstat['value']['statcode'], 2, '.', ''); |
|
3282 | + $content .= ';'.$this->_strrep($rstat['value']['text']); |
|
3283 | + if (isset($rstat['value']['extdata'])) |
|
3284 | + $content .= ';'.$this->_strrep($rstat['value']['extdata']); |
|
3285 | + $output .= $this->_createElement('REQUEST-STATUS', $attributes, $content); |
|
3286 | 3286 | } |
3287 | 3287 | return $output; |
3288 | 3288 | } |
@@ -3298,12 +3298,12 @@ discard block |
||
3298 | 3298 | * @param integer $index, optional |
3299 | 3299 | * @return bool |
3300 | 3300 | */ |
3301 | - function setRequestStatus( $statcode, $text, $extdata=FALSE, $params=FALSE, $index=FALSE ) { |
|
3302 | - if( empty( $statcode ) || empty( $text )) if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null; else return FALSE; |
|
3303 | - $input = array( 'statcode' => $statcode, 'text' => $text ); |
|
3304 | - if( $extdata ) |
|
3301 | + function setRequestStatus($statcode, $text, $extdata = FALSE, $params = FALSE, $index = FALSE) { |
|
3302 | + if (empty($statcode) || empty($text)) if ($this->getConfig('allowEmpty')) $statcode = $text = null; else return FALSE; |
|
3303 | + $input = array('statcode' => $statcode, 'text' => $text); |
|
3304 | + if ($extdata) |
|
3305 | 3305 | $input['extdata'] = $extdata; |
3306 | - $this->_setMval( $this->requeststatus, $input, $params, FALSE, $index ); |
|
3306 | + $this->_setMval($this->requeststatus, $input, $params, FALSE, $index); |
|
3307 | 3307 | return TRUE; |
3308 | 3308 | } |
3309 | 3309 | /*********************************************************************************/ |
@@ -3318,22 +3318,22 @@ discard block |
||
3318 | 3318 | * @return string |
3319 | 3319 | */ |
3320 | 3320 | function createResources() { |
3321 | - if( empty( $this->resources )) return FALSE; |
|
3321 | + if (empty($this->resources)) return FALSE; |
|
3322 | 3322 | $output = null; |
3323 | - foreach( $this->resources as $resource ) { |
|
3324 | - if( empty( $resource['value'] )) { |
|
3325 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RESOURCES' ); |
|
3323 | + foreach ($this->resources as $resource) { |
|
3324 | + if (empty($resource['value'])) { |
|
3325 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('RESOURCES'); |
|
3326 | 3326 | continue; |
3327 | 3327 | } |
3328 | - $attributes = $this->_createParams( $resource['params'], array( 'ALTREP', 'LANGUAGE' )); |
|
3329 | - if( is_array( $resource['value'] )) { |
|
3330 | - foreach( $resource['value'] as $rix => $resourcePart ) |
|
3331 | - $resource['value'][$rix] = $this->_strrep( $resourcePart ); |
|
3332 | - $content = implode( ',', $resource['value'] ); |
|
3328 | + $attributes = $this->_createParams($resource['params'], array('ALTREP', 'LANGUAGE')); |
|
3329 | + if (is_array($resource['value'])) { |
|
3330 | + foreach ($resource['value'] as $rix => $resourcePart) |
|
3331 | + $resource['value'][$rix] = $this->_strrep($resourcePart); |
|
3332 | + $content = implode(',', $resource['value']); |
|
3333 | 3333 | } |
3334 | 3334 | else |
3335 | - $content = $this->_strrep( $resource['value'] ); |
|
3336 | - $output .= $this->_createElement( 'RESOURCES', $attributes, $content ); |
|
3335 | + $content = $this->_strrep($resource['value']); |
|
3336 | + $output .= $this->_createElement('RESOURCES', $attributes, $content); |
|
3337 | 3337 | } |
3338 | 3338 | return $output; |
3339 | 3339 | } |
@@ -3347,9 +3347,9 @@ discard block |
||
3347 | 3347 | * @param integer $index, optional |
3348 | 3348 | * @return bool |
3349 | 3349 | */ |
3350 | - function setResources( $value, $params=FALSE, $index=FALSE ) { |
|
3351 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3352 | - $this->_setMval( $this->resources, $value, $params, FALSE, $index ); |
|
3350 | + function setResources($value, $params = FALSE, $index = FALSE) { |
|
3351 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3352 | + $this->_setMval($this->resources, $value, $params, FALSE, $index); |
|
3353 | 3353 | return TRUE; |
3354 | 3354 | } |
3355 | 3355 | /*********************************************************************************/ |
@@ -3364,8 +3364,8 @@ discard block |
||
3364 | 3364 | * @return string |
3365 | 3365 | */ |
3366 | 3366 | function createRrule() { |
3367 | - if( empty( $this->rrule )) return FALSE; |
|
3368 | - return $this->_format_recur( 'RRULE', $this->rrule ); |
|
3367 | + if (empty($this->rrule)) return FALSE; |
|
3368 | + return $this->_format_recur('RRULE', $this->rrule); |
|
3369 | 3369 | } |
3370 | 3370 | /** |
3371 | 3371 | * set calendar component property rrule |
@@ -3377,9 +3377,9 @@ discard block |
||
3377 | 3377 | * @param integer $index, optional |
3378 | 3378 | * @return void |
3379 | 3379 | */ |
3380 | - function setRrule( $rruleset, $params=FALSE, $index=FALSE ) { |
|
3381 | - if( empty( $rruleset )) if( $this->getConfig( 'allowEmpty' )) $rruleset = null; else return FALSE; |
|
3382 | - $this->_setMval( $this->rrule, $this->_setRexrule( $rruleset ), $params, FALSE, $index ); |
|
3380 | + function setRrule($rruleset, $params = FALSE, $index = FALSE) { |
|
3381 | + if (empty($rruleset)) if ($this->getConfig('allowEmpty')) $rruleset = null; else return FALSE; |
|
3382 | + $this->_setMval($this->rrule, $this->_setRexrule($rruleset), $params, FALSE, $index); |
|
3383 | 3383 | return TRUE; |
3384 | 3384 | } |
3385 | 3385 | /*********************************************************************************/ |
@@ -3393,11 +3393,11 @@ discard block |
||
3393 | 3393 | * @return string |
3394 | 3394 | */ |
3395 | 3395 | function createSequence() { |
3396 | - if( empty( $this->sequence )) return FALSE; |
|
3397 | - if( empty( $this->sequence['value'] )) |
|
3398 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE; |
|
3399 | - $attributes = $this->_createParams( $this->sequence['params'] ); |
|
3400 | - return $this->_createElement( 'SEQUENCE', $attributes, $this->sequence['value'] ); |
|
3396 | + if (empty($this->sequence)) return FALSE; |
|
3397 | + if (empty($this->sequence['value'])) |
|
3398 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('SEQUENCE') : FALSE; |
|
3399 | + $attributes = $this->_createParams($this->sequence['params']); |
|
3400 | + return $this->_createElement('SEQUENCE', $attributes, $this->sequence['value']); |
|
3401 | 3401 | } |
3402 | 3402 | /** |
3403 | 3403 | * set calendar component property sequence |
@@ -3407,10 +3407,10 @@ discard block |
||
3407 | 3407 | * @param array $params optional |
3408 | 3408 | * @return bool |
3409 | 3409 | */ |
3410 | - function setSequence( $value=FALSE, $params=FALSE ) { |
|
3411 | - if( empty( $value )) |
|
3412 | - $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1; |
|
3413 | - $this->sequence = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3410 | + function setSequence($value = FALSE, $params = FALSE) { |
|
3411 | + if (empty($value)) |
|
3412 | + $value = (isset($this->sequence['value']) && (0 < $this->sequence['value'])) ? $this->sequence['value'] + 1 : 1; |
|
3413 | + $this->sequence = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3414 | 3414 | return TRUE; |
3415 | 3415 | } |
3416 | 3416 | /*********************************************************************************/ |
@@ -3425,11 +3425,11 @@ discard block |
||
3425 | 3425 | * @return string |
3426 | 3426 | */ |
3427 | 3427 | function createStatus() { |
3428 | - if( empty( $this->status )) return FALSE; |
|
3429 | - if( empty( $this->status['value'] )) |
|
3430 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE; |
|
3431 | - $attributes = $this->_createParams( $this->status['params'] ); |
|
3432 | - return $this->_createElement( 'STATUS', $attributes, $this->status['value'] ); |
|
3428 | + if (empty($this->status)) return FALSE; |
|
3429 | + if (empty($this->status['value'])) |
|
3430 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('STATUS') : FALSE; |
|
3431 | + $attributes = $this->_createParams($this->status['params']); |
|
3432 | + return $this->_createElement('STATUS', $attributes, $this->status['value']); |
|
3433 | 3433 | } |
3434 | 3434 | /** |
3435 | 3435 | * set calendar component property status |
@@ -3440,9 +3440,9 @@ discard block |
||
3440 | 3440 | * @param mixed $params optional (array or false) |
3441 | 3441 | * @return bool |
3442 | 3442 | */ |
3443 | - function setStatus( $value, $params=FALSE ) { |
|
3444 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3445 | - $this->status = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3443 | + function setStatus($value, $params = FALSE) { |
|
3444 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3445 | + $this->status = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3446 | 3446 | return TRUE; |
3447 | 3447 | } |
3448 | 3448 | /*********************************************************************************/ |
@@ -3457,12 +3457,12 @@ discard block |
||
3457 | 3457 | * @return string |
3458 | 3458 | */ |
3459 | 3459 | function createSummary() { |
3460 | - if( empty( $this->summary )) return FALSE; |
|
3461 | - if( empty( $this->summary['value'] )) |
|
3462 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE; |
|
3463 | - $attributes = $this->_createParams( $this->summary['params'], array( 'ALTREP', 'LANGUAGE' )); |
|
3464 | - $content = $this->_strrep( $this->summary['value'] ); |
|
3465 | - return $this->_createElement( 'SUMMARY', $attributes, $content ); |
|
3460 | + if (empty($this->summary)) return FALSE; |
|
3461 | + if (empty($this->summary['value'])) |
|
3462 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('SUMMARY') : FALSE; |
|
3463 | + $attributes = $this->_createParams($this->summary['params'], array('ALTREP', 'LANGUAGE')); |
|
3464 | + $content = $this->_strrep($this->summary['value']); |
|
3465 | + return $this->_createElement('SUMMARY', $attributes, $content); |
|
3466 | 3466 | } |
3467 | 3467 | /** |
3468 | 3468 | * set calendar component property summary |
@@ -3473,9 +3473,9 @@ discard block |
||
3473 | 3473 | * @param string $params optional |
3474 | 3474 | * @return bool |
3475 | 3475 | */ |
3476 | - function setSummary( $value, $params=FALSE ) { |
|
3477 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3478 | - $this->summary = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3476 | + function setSummary($value, $params = FALSE) { |
|
3477 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3478 | + $this->summary = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3479 | 3479 | return TRUE; |
3480 | 3480 | } |
3481 | 3481 | /*********************************************************************************/ |
@@ -3490,11 +3490,11 @@ discard block |
||
3490 | 3490 | * @return string |
3491 | 3491 | */ |
3492 | 3492 | function createTransp() { |
3493 | - if( empty( $this->transp )) return FALSE; |
|
3494 | - if( empty( $this->transp['value'] )) |
|
3495 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE; |
|
3496 | - $attributes = $this->_createParams( $this->transp['params'] ); |
|
3497 | - return $this->_createElement( 'TRANSP', $attributes, $this->transp['value'] ); |
|
3493 | + if (empty($this->transp)) return FALSE; |
|
3494 | + if (empty($this->transp['value'])) |
|
3495 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('TRANSP') : FALSE; |
|
3496 | + $attributes = $this->_createParams($this->transp['params']); |
|
3497 | + return $this->_createElement('TRANSP', $attributes, $this->transp['value']); |
|
3498 | 3498 | } |
3499 | 3499 | /** |
3500 | 3500 | * set calendar component property transp |
@@ -3505,9 +3505,9 @@ discard block |
||
3505 | 3505 | * @param string $params optional |
3506 | 3506 | * @return bool |
3507 | 3507 | */ |
3508 | - function setTransp( $value, $params=FALSE ) { |
|
3509 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3510 | - $this->transp = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3508 | + function setTransp($value, $params = FALSE) { |
|
3509 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3510 | + $this->transp = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3511 | 3511 | return TRUE; |
3512 | 3512 | } |
3513 | 3513 | /*********************************************************************************/ |
@@ -3522,23 +3522,23 @@ discard block |
||
3522 | 3522 | * @return string |
3523 | 3523 | */ |
3524 | 3524 | function createTrigger() { |
3525 | - if( empty( $this->trigger )) return FALSE; |
|
3526 | - if( empty( $this->trigger['value'] )) |
|
3527 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE; |
|
3525 | + if (empty($this->trigger)) return FALSE; |
|
3526 | + if (empty($this->trigger['value'])) |
|
3527 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('TRIGGER') : FALSE; |
|
3528 | 3528 | $content = $attributes = null; |
3529 | - if( isset( $this->trigger['value']['year'] ) && |
|
3530 | - isset( $this->trigger['value']['month'] ) && |
|
3531 | - isset( $this->trigger['value']['day'] )) |
|
3532 | - $content .= $this->_format_date_time( $this->trigger['value'] ); |
|
3529 | + if (isset($this->trigger['value']['year']) && |
|
3530 | + isset($this->trigger['value']['month']) && |
|
3531 | + isset($this->trigger['value']['day'])) |
|
3532 | + $content .= $this->_format_date_time($this->trigger['value']); |
|
3533 | 3533 | else { |
3534 | - if( TRUE !== $this->trigger['value']['relatedStart'] ) |
|
3534 | + if (TRUE !== $this->trigger['value']['relatedStart']) |
|
3535 | 3535 | $attributes .= $this->intAttrDelimiter.'RELATED=END'; |
3536 | - if( $this->trigger['value']['before'] ) |
|
3536 | + if ($this->trigger['value']['before']) |
|
3537 | 3537 | $content .= '-'; |
3538 | - $content .= $this->_format_duration( $this->trigger['value'] ); |
|
3538 | + $content .= $this->_format_duration($this->trigger['value']); |
|
3539 | 3539 | } |
3540 | - $attributes .= $this->_createParams( $this->trigger['params'] ); |
|
3541 | - return $this->_createElement( 'TRIGGER', $attributes, $content ); |
|
3540 | + $attributes .= $this->_createParams($this->trigger['params']); |
|
3541 | + return $this->_createElement('TRIGGER', $attributes, $content); |
|
3542 | 3542 | } |
3543 | 3543 | /** |
3544 | 3544 | * set calendar component property trigger |
@@ -3557,86 +3557,86 @@ discard block |
||
3557 | 3557 | * @param array $params optional |
3558 | 3558 | * @return bool |
3559 | 3559 | */ |
3560 | - function setTrigger( $year, $month=null, $day=null, $week=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $relatedStart=TRUE, $before=TRUE, $params=FALSE ) { |
|
3561 | - if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec )) |
|
3562 | - if( $this->getConfig( 'allowEmpty' )) { |
|
3563 | - $this->trigger = array( 'value' => null, 'params' => $this->_setParams( $params ) ); |
|
3560 | + function setTrigger($year, $month = null, $day = null, $week = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $relatedStart = TRUE, $before = TRUE, $params = FALSE) { |
|
3561 | + if (empty($year) && empty($month) && empty($day) && empty($week) && empty($hour) && empty($min) && empty($sec)) |
|
3562 | + if ($this->getConfig('allowEmpty')) { |
|
3563 | + $this->trigger = array('value' => null, 'params' => $this->_setParams($params)); |
|
3564 | 3564 | return TRUE; |
3565 | 3565 | } |
3566 | 3566 | else |
3567 | 3567 | return FALSE; |
3568 | - if( $this->_isArrayTimestampDate( $year )) { // timestamp |
|
3569 | - $params = $this->_setParams( $month ); |
|
3570 | - $date = $this->_timestamp2date( $year, 7 ); |
|
3571 | - foreach( $date as $k => $v ) |
|
3568 | + if ($this->_isArrayTimestampDate($year)) { // timestamp |
|
3569 | + $params = $this->_setParams($month); |
|
3570 | + $date = $this->_timestamp2date($year, 7); |
|
3571 | + foreach ($date as $k => $v) |
|
3572 | 3572 | $$k = $v; |
3573 | 3573 | } |
3574 | - elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) { |
|
3575 | - $params = $this->_setParams( $month ); |
|
3576 | - if(!(array_key_exists( 'year', $year ) && // exclude date-time |
|
3577 | - array_key_exists( 'month', $year ) && |
|
3578 | - array_key_exists( 'day', $year ))) { // so this must be a duration |
|
3579 | - if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) |
|
3574 | + elseif (is_array($year) && (is_array($month) || empty($month))) { |
|
3575 | + $params = $this->_setParams($month); |
|
3576 | + if (!(array_key_exists('year', $year) && // exclude date-time |
|
3577 | + array_key_exists('month', $year) && |
|
3578 | + array_key_exists('day', $year))) { // so this must be a duration |
|
3579 | + if (isset($params['RELATED']) && ('END' == $params['RELATED'])) |
|
3580 | 3580 | $relatedStart = FALSE; |
3581 | 3581 | else |
3582 | - $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE; |
|
3583 | - $before = ( array_key_exists( 'before', $year ) && ( TRUE !== $year['before'] )) ? FALSE : TRUE; |
|
3582 | + $relatedStart = (array_key_exists('relatedStart', $year) && (TRUE !== $year['relatedStart'])) ? FALSE : TRUE; |
|
3583 | + $before = (array_key_exists('before', $year) && (TRUE !== $year['before'])) ? FALSE : TRUE; |
|
3584 | 3584 | } |
3585 | - $SSYY = ( array_key_exists( 'year', $year )) ? $year['year'] : null; |
|
3586 | - $month = ( array_key_exists( 'month', $year )) ? $year['month'] : null; |
|
3587 | - $day = ( array_key_exists( 'day', $year )) ? $year['day'] : null; |
|
3588 | - $week = ( array_key_exists( 'week', $year )) ? $year['week'] : null; |
|
3589 | - $hour = ( array_key_exists( 'hour', $year )) ? $year['hour'] : 0; //null; |
|
3590 | - $min = ( array_key_exists( 'min', $year )) ? $year['min'] : 0; //null; |
|
3591 | - $sec = ( array_key_exists( 'sec', $year )) ? $year['sec'] : 0; //null; |
|
3585 | + $SSYY = (array_key_exists('year', $year)) ? $year['year'] : null; |
|
3586 | + $month = (array_key_exists('month', $year)) ? $year['month'] : null; |
|
3587 | + $day = (array_key_exists('day', $year)) ? $year['day'] : null; |
|
3588 | + $week = (array_key_exists('week', $year)) ? $year['week'] : null; |
|
3589 | + $hour = (array_key_exists('hour', $year)) ? $year['hour'] : 0; //null; |
|
3590 | + $min = (array_key_exists('min', $year)) ? $year['min'] : 0; //null; |
|
3591 | + $sec = (array_key_exists('sec', $year)) ? $year['sec'] : 0; //null; |
|
3592 | 3592 | $year = $SSYY; |
3593 | 3593 | } |
3594 | - elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) { // duration or date in a string |
|
3595 | - $params = $this->_setParams( $month ); |
|
3596 | - if( in_array( $year{0}, array( 'P', '+', '-' ))) { // duration |
|
3597 | - $relatedStart = ( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) ? FALSE : TRUE; |
|
3598 | - $before = ( '-' == $year{0} ) ? TRUE : FALSE; |
|
3599 | - if( 'P' != $year{0} ) |
|
3600 | - $year = substr( $year, 1 ); |
|
3601 | - $date = $this->_duration_string( $year); |
|
3594 | + elseif (is_string($year) && (is_array($month) || empty($month))) { // duration or date in a string |
|
3595 | + $params = $this->_setParams($month); |
|
3596 | + if (in_array($year{0}, array('P', '+', '-'))) { // duration |
|
3597 | + $relatedStart = (isset($params['RELATED']) && ('END' == $params['RELATED'])) ? FALSE : TRUE; |
|
3598 | + $before = ('-' == $year{0} ) ? TRUE : FALSE; |
|
3599 | + if ('P' != $year{0} ) |
|
3600 | + $year = substr($year, 1); |
|
3601 | + $date = $this->_duration_string($year); |
|
3602 | 3602 | } |
3603 | 3603 | else // date |
3604 | - $date = $this->_date_time_string( $year, 7 ); |
|
3605 | - unset( $year, $month, $day ); |
|
3606 | - foreach( $date as $k => $v ) |
|
3604 | + $date = $this->_date_time_string($year, 7); |
|
3605 | + unset($year, $month, $day); |
|
3606 | + foreach ($date as $k => $v) |
|
3607 | 3607 | $$k = $v; |
3608 | 3608 | } |
3609 | 3609 | else // single values in function input parameters |
3610 | - $params = $this->_setParams( $params ); |
|
3611 | - if( !empty( $year ) && !empty( $month ) && !empty( $day )) { // date |
|
3610 | + $params = $this->_setParams($params); |
|
3611 | + if (!empty($year) && !empty($month) && !empty($day)) { // date |
|
3612 | 3612 | $params['VALUE'] = 'DATE-TIME'; |
3613 | - $hour = ( $hour ) ? $hour : 0; |
|
3614 | - $min = ( $min ) ? $min : 0; |
|
3615 | - $sec = ( $sec ) ? $sec : 0; |
|
3616 | - $this->trigger = array( 'params' => $params ); |
|
3617 | - $this->trigger['value'] = array( 'year' => $year |
|
3613 | + $hour = ($hour) ? $hour : 0; |
|
3614 | + $min = ($min) ? $min : 0; |
|
3615 | + $sec = ($sec) ? $sec : 0; |
|
3616 | + $this->trigger = array('params' => $params); |
|
3617 | + $this->trigger['value'] = array('year' => $year |
|
3618 | 3618 | , 'month' => $month |
3619 | 3619 | , 'day' => $day |
3620 | 3620 | , 'hour' => $hour |
3621 | 3621 | , 'min' => $min |
3622 | 3622 | , 'sec' => $sec |
3623 | - , 'tz' => 'Z' ); |
|
3623 | + , 'tz' => 'Z'); |
|
3624 | 3624 | return TRUE; |
3625 | 3625 | } |
3626 | - elseif(( empty( $year ) && empty( $month )) && // duration |
|
3627 | - (!empty( $week ) || !empty( $day ) || !empty( $hour ) || !empty( $min ) || !empty( $sec ))) { |
|
3628 | - unset( $params['RELATED'] ); // set at output creation (END only) |
|
3629 | - unset( $params['VALUE'] ); // 'DURATION' default |
|
3630 | - $this->trigger = array( 'params' => $params ); |
|
3631 | - $relatedStart = ( FALSE !== $relatedStart ) ? TRUE : FALSE; |
|
3632 | - $before = ( FALSE !== $before ) ? TRUE : FALSE; |
|
3633 | - $this->trigger['value'] = array( 'relatedStart' => $relatedStart |
|
3634 | - , 'before' => $before ); |
|
3635 | - if( !empty( $week )) $this->trigger['value']['week'] = $week; |
|
3636 | - if( !empty( $day )) $this->trigger['value']['day'] = $day; |
|
3637 | - if( !empty( $hour )) $this->trigger['value']['hour'] = $hour; |
|
3638 | - if( !empty( $min )) $this->trigger['value']['min'] = $min; |
|
3639 | - if( !empty( $sec )) $this->trigger['value']['sec'] = $sec; |
|
3626 | + elseif ((empty($year) && empty($month)) && // duration |
|
3627 | + (!empty($week) || !empty($day) || !empty($hour) || !empty($min) || !empty($sec))) { |
|
3628 | + unset($params['RELATED']); // set at output creation (END only) |
|
3629 | + unset($params['VALUE']); // 'DURATION' default |
|
3630 | + $this->trigger = array('params' => $params); |
|
3631 | + $relatedStart = (FALSE !== $relatedStart) ? TRUE : FALSE; |
|
3632 | + $before = (FALSE !== $before) ? TRUE : FALSE; |
|
3633 | + $this->trigger['value'] = array('relatedStart' => $relatedStart |
|
3634 | + , 'before' => $before); |
|
3635 | + if (!empty($week)) $this->trigger['value']['week'] = $week; |
|
3636 | + if (!empty($day)) $this->trigger['value']['day'] = $day; |
|
3637 | + if (!empty($hour)) $this->trigger['value']['hour'] = $hour; |
|
3638 | + if (!empty($min)) $this->trigger['value']['min'] = $min; |
|
3639 | + if (!empty($sec)) $this->trigger['value']['sec'] = $sec; |
|
3640 | 3640 | return TRUE; |
3641 | 3641 | } |
3642 | 3642 | return FALSE; |
@@ -3653,11 +3653,11 @@ discard block |
||
3653 | 3653 | * @return string |
3654 | 3654 | */ |
3655 | 3655 | function createTzid() { |
3656 | - if( empty( $this->tzid )) return FALSE; |
|
3657 | - if( empty( $this->tzid['value'] )) |
|
3658 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE; |
|
3659 | - $attributes = $this->_createParams( $this->tzid['params'] ); |
|
3660 | - return $this->_createElement( 'TZID', $attributes, $this->_strrep( $this->tzid['value'] )); |
|
3656 | + if (empty($this->tzid)) return FALSE; |
|
3657 | + if (empty($this->tzid['value'])) |
|
3658 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('TZID') : FALSE; |
|
3659 | + $attributes = $this->_createParams($this->tzid['params']); |
|
3660 | + return $this->_createElement('TZID', $attributes, $this->_strrep($this->tzid['value'])); |
|
3661 | 3661 | } |
3662 | 3662 | /** |
3663 | 3663 | * set calendar component property tzid |
@@ -3668,9 +3668,9 @@ discard block |
||
3668 | 3668 | * @param array $params optional |
3669 | 3669 | * @return bool |
3670 | 3670 | */ |
3671 | - function setTzid( $value, $params=FALSE ) { |
|
3672 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3673 | - $this->tzid = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3671 | + function setTzid($value, $params = FALSE) { |
|
3672 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3673 | + $this->tzid = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3674 | 3674 | return TRUE; |
3675 | 3675 | } |
3676 | 3676 | /*********************************************************************************/ |
@@ -3686,14 +3686,14 @@ discard block |
||
3686 | 3686 | * @return string |
3687 | 3687 | */ |
3688 | 3688 | function createTzname() { |
3689 | - if( empty( $this->tzname )) return FALSE; |
|
3689 | + if (empty($this->tzname)) return FALSE; |
|
3690 | 3690 | $output = null; |
3691 | - foreach( $this->tzname as $theName ) { |
|
3692 | - if( !empty( $theName['value'] )) { |
|
3693 | - $attributes = $this->_createParams( $theName['params'], array( 'LANGUAGE' )); |
|
3694 | - $output .= $this->_createElement( 'TZNAME', $attributes, $this->_strrep( $theName['value'] )); |
|
3691 | + foreach ($this->tzname as $theName) { |
|
3692 | + if (!empty($theName['value'])) { |
|
3693 | + $attributes = $this->_createParams($theName['params'], array('LANGUAGE')); |
|
3694 | + $output .= $this->_createElement('TZNAME', $attributes, $this->_strrep($theName['value'])); |
|
3695 | 3695 | } |
3696 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'TZNAME' ); |
|
3696 | + elseif ($this->getConfig('allowEmpty')) $output .= $this->_createElement('TZNAME'); |
|
3697 | 3697 | } |
3698 | 3698 | return $output; |
3699 | 3699 | } |
@@ -3707,9 +3707,9 @@ discard block |
||
3707 | 3707 | * @param integer $index, optional |
3708 | 3708 | * @return bool |
3709 | 3709 | */ |
3710 | - function setTzname( $value, $params=FALSE, $index=FALSE ) { |
|
3711 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3712 | - $this->_setMval( $this->tzname, $value, $params, FALSE, $index ); |
|
3710 | + function setTzname($value, $params = FALSE, $index = FALSE) { |
|
3711 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3712 | + $this->_setMval($this->tzname, $value, $params, FALSE, $index); |
|
3713 | 3713 | return TRUE; |
3714 | 3714 | } |
3715 | 3715 | /*********************************************************************************/ |
@@ -3724,11 +3724,11 @@ discard block |
||
3724 | 3724 | * @return string |
3725 | 3725 | */ |
3726 | 3726 | function createTzoffsetfrom() { |
3727 | - if( empty( $this->tzoffsetfrom )) return FALSE; |
|
3728 | - if( empty( $this->tzoffsetfrom['value'] )) |
|
3729 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE; |
|
3730 | - $attributes = $this->_createParams( $this->tzoffsetfrom['params'] ); |
|
3731 | - return $this->_createElement( 'TZOFFSETFROM', $attributes, $this->tzoffsetfrom['value'] ); |
|
3727 | + if (empty($this->tzoffsetfrom)) return FALSE; |
|
3728 | + if (empty($this->tzoffsetfrom['value'])) |
|
3729 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('TZOFFSETFROM') : FALSE; |
|
3730 | + $attributes = $this->_createParams($this->tzoffsetfrom['params']); |
|
3731 | + return $this->_createElement('TZOFFSETFROM', $attributes, $this->tzoffsetfrom['value']); |
|
3732 | 3732 | } |
3733 | 3733 | /** |
3734 | 3734 | * set calendar component property tzoffsetfrom |
@@ -3739,9 +3739,9 @@ discard block |
||
3739 | 3739 | * @param string $params optional |
3740 | 3740 | * @return bool |
3741 | 3741 | */ |
3742 | - function setTzoffsetfrom( $value, $params=FALSE ) { |
|
3743 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3744 | - $this->tzoffsetfrom = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3742 | + function setTzoffsetfrom($value, $params = FALSE) { |
|
3743 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3744 | + $this->tzoffsetfrom = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3745 | 3745 | return TRUE; |
3746 | 3746 | } |
3747 | 3747 | /*********************************************************************************/ |
@@ -3756,11 +3756,11 @@ discard block |
||
3756 | 3756 | * @return string |
3757 | 3757 | */ |
3758 | 3758 | function createTzoffsetto() { |
3759 | - if( empty( $this->tzoffsetto )) return FALSE; |
|
3760 | - if( empty( $this->tzoffsetto['value'] )) |
|
3761 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE; |
|
3762 | - $attributes = $this->_createParams( $this->tzoffsetto['params'] ); |
|
3763 | - return $this->_createElement( 'TZOFFSETTO', $attributes, $this->tzoffsetto['value'] ); |
|
3759 | + if (empty($this->tzoffsetto)) return FALSE; |
|
3760 | + if (empty($this->tzoffsetto['value'])) |
|
3761 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('TZOFFSETTO') : FALSE; |
|
3762 | + $attributes = $this->_createParams($this->tzoffsetto['params']); |
|
3763 | + return $this->_createElement('TZOFFSETTO', $attributes, $this->tzoffsetto['value']); |
|
3764 | 3764 | } |
3765 | 3765 | /** |
3766 | 3766 | * set calendar component property tzoffsetto |
@@ -3771,9 +3771,9 @@ discard block |
||
3771 | 3771 | * @param string $params optional |
3772 | 3772 | * @return bool |
3773 | 3773 | */ |
3774 | - function setTzoffsetto( $value, $params=FALSE ) { |
|
3775 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3776 | - $this->tzoffsetto = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3774 | + function setTzoffsetto($value, $params = FALSE) { |
|
3775 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3776 | + $this->tzoffsetto = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3777 | 3777 | return TRUE; |
3778 | 3778 | } |
3779 | 3779 | /*********************************************************************************/ |
@@ -3788,11 +3788,11 @@ discard block |
||
3788 | 3788 | * @return string |
3789 | 3789 | */ |
3790 | 3790 | function createTzurl() { |
3791 | - if( empty( $this->tzurl )) return FALSE; |
|
3792 | - if( empty( $this->tzurl['value'] )) |
|
3793 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE; |
|
3794 | - $attributes = $this->_createParams( $this->tzurl['params'] ); |
|
3795 | - return $this->_createElement( 'TZURL', $attributes, $this->tzurl['value'] ); |
|
3791 | + if (empty($this->tzurl)) return FALSE; |
|
3792 | + if (empty($this->tzurl['value'])) |
|
3793 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('TZURL') : FALSE; |
|
3794 | + $attributes = $this->_createParams($this->tzurl['params']); |
|
3795 | + return $this->_createElement('TZURL', $attributes, $this->tzurl['value']); |
|
3796 | 3796 | } |
3797 | 3797 | /** |
3798 | 3798 | * set calendar component property tzurl |
@@ -3803,9 +3803,9 @@ discard block |
||
3803 | 3803 | * @param string $params optional |
3804 | 3804 | * @return boll |
3805 | 3805 | */ |
3806 | - function setTzurl( $value, $params=FALSE ) { |
|
3807 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3808 | - $this->tzurl = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3806 | + function setTzurl($value, $params = FALSE) { |
|
3807 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3808 | + $this->tzurl = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3809 | 3809 | return TRUE; |
3810 | 3810 | } |
3811 | 3811 | /*********************************************************************************/ |
@@ -3820,10 +3820,10 @@ discard block |
||
3820 | 3820 | * @return string |
3821 | 3821 | */ |
3822 | 3822 | function createUid() { |
3823 | - if( 0 >= count( $this->uid )) |
|
3823 | + if (0 >= count($this->uid)) |
|
3824 | 3824 | $this->_makeuid(); |
3825 | - $attributes = $this->_createParams( $this->uid['params'] ); |
|
3826 | - return $this->_createElement( 'UID', $attributes, $this->uid['value'] ); |
|
3825 | + $attributes = $this->_createParams($this->uid['params']); |
|
3826 | + return $this->_createElement('UID', $attributes, $this->uid['value']); |
|
3827 | 3827 | } |
3828 | 3828 | /** |
3829 | 3829 | * create an unique id for this calendar component object instance |
@@ -3837,13 +3837,13 @@ discard block |
||
3837 | 3837 | $unique = substr(microtime(), 2, 4); |
3838 | 3838 | $base = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPrRsStTuUvVxXuUvVwWzZ1234567890'; |
3839 | 3839 | $start = 0; |
3840 | - $end = strlen( $base ) - 1; |
|
3840 | + $end = strlen($base) - 1; |
|
3841 | 3841 | $length = 6; |
3842 | 3842 | $str = null; |
3843 | - for( $p = 0; $p < $length; $p++ ) |
|
3844 | - $unique .= $base{mt_rand( $start, $end )}; |
|
3845 | - $this->uid = array( 'params' => null ); |
|
3846 | - $this->uid['value'] = $date.'-'.$unique.'@'.$this->getConfig( 'unique_id' ); |
|
3843 | + for ($p = 0; $p < $length; $p++) |
|
3844 | + $unique .= $base{mt_rand($start, $end)}; |
|
3845 | + $this->uid = array('params' => null); |
|
3846 | + $this->uid['value'] = $date.'-'.$unique.'@'.$this->getConfig('unique_id'); |
|
3847 | 3847 | } |
3848 | 3848 | /** |
3849 | 3849 | * set calendar component property uid |
@@ -3854,9 +3854,9 @@ discard block |
||
3854 | 3854 | * @param string $params optional |
3855 | 3855 | * @return bool |
3856 | 3856 | */ |
3857 | - function setUid( $value, $params=FALSE ) { |
|
3858 | - if( empty( $value )) return FALSE; // no allowEmpty check here !!!! |
|
3859 | - $this->uid = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3857 | + function setUid($value, $params = FALSE) { |
|
3858 | + if (empty($value)) return FALSE; // no allowEmpty check here !!!! |
|
3859 | + $this->uid = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3860 | 3860 | return TRUE; |
3861 | 3861 | } |
3862 | 3862 | /*********************************************************************************/ |
@@ -3871,11 +3871,11 @@ discard block |
||
3871 | 3871 | * @return string |
3872 | 3872 | */ |
3873 | 3873 | function createUrl() { |
3874 | - if( empty( $this->url )) return FALSE; |
|
3875 | - if( empty( $this->url['value'] )) |
|
3876 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE; |
|
3877 | - $attributes = $this->_createParams( $this->url['params'] ); |
|
3878 | - return $this->_createElement( 'URL', $attributes, $this->url['value'] ); |
|
3874 | + if (empty($this->url)) return FALSE; |
|
3875 | + if (empty($this->url['value'])) |
|
3876 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('URL') : FALSE; |
|
3877 | + $attributes = $this->_createParams($this->url['params']); |
|
3878 | + return $this->_createElement('URL', $attributes, $this->url['value']); |
|
3879 | 3879 | } |
3880 | 3880 | /** |
3881 | 3881 | * set calendar component property url |
@@ -3886,9 +3886,9 @@ discard block |
||
3886 | 3886 | * @param string $params optional |
3887 | 3887 | * @return bool |
3888 | 3888 | */ |
3889 | - function setUrl( $value, $params=FALSE ) { |
|
3890 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3891 | - $this->url = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3889 | + function setUrl($value, $params = FALSE) { |
|
3890 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3891 | + $this->url = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3892 | 3892 | return TRUE; |
3893 | 3893 | } |
3894 | 3894 | /*********************************************************************************/ |
@@ -3903,22 +3903,22 @@ discard block |
||
3903 | 3903 | * @return string |
3904 | 3904 | */ |
3905 | 3905 | function createXprop() { |
3906 | - if( empty( $this->xprop )) return FALSE; |
|
3906 | + if (empty($this->xprop)) return FALSE; |
|
3907 | 3907 | $output = null; |
3908 | - foreach( $this->xprop as $label => $xpropPart ) { |
|
3909 | - if( empty( $xpropPart['value'] )) { |
|
3910 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $label ); |
|
3908 | + foreach ($this->xprop as $label => $xpropPart) { |
|
3909 | + if (empty($xpropPart['value'])) { |
|
3910 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement($label); |
|
3911 | 3911 | continue; |
3912 | 3912 | } |
3913 | - $attributes = $this->_createParams( $xpropPart['params'], array( 'LANGUAGE' )); |
|
3914 | - if( is_array( $xpropPart['value'] )) { |
|
3915 | - foreach( $xpropPart['value'] as $pix => $theXpart ) |
|
3916 | - $xpropPart['value'][$pix] = $this->_strrep( $theXpart ); |
|
3917 | - $xpropPart['value'] = implode( ',', $xpropPart['value'] ); |
|
3913 | + $attributes = $this->_createParams($xpropPart['params'], array('LANGUAGE')); |
|
3914 | + if (is_array($xpropPart['value'])) { |
|
3915 | + foreach ($xpropPart['value'] as $pix => $theXpart) |
|
3916 | + $xpropPart['value'][$pix] = $this->_strrep($theXpart); |
|
3917 | + $xpropPart['value'] = implode(',', $xpropPart['value']); |
|
3918 | 3918 | } |
3919 | 3919 | else |
3920 | - $xpropPart['value'] = $this->_strrep( $xpropPart['value'] ); |
|
3921 | - $output .= $this->_createElement( $label, $attributes, $xpropPart['value'] ); |
|
3920 | + $xpropPart['value'] = $this->_strrep($xpropPart['value']); |
|
3921 | + $output .= $this->_createElement($label, $attributes, $xpropPart['value']); |
|
3922 | 3922 | } |
3923 | 3923 | return $output; |
3924 | 3924 | } |
@@ -3932,14 +3932,14 @@ discard block |
||
3932 | 3932 | * @param array $params optional |
3933 | 3933 | * @return bool |
3934 | 3934 | */ |
3935 | - function setXprop( $label, $value, $params=FALSE ) { |
|
3936 | - if( empty( $label )) return; |
|
3937 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3938 | - $xprop = array( 'value' => $value ); |
|
3935 | + function setXprop($label, $value, $params = FALSE) { |
|
3936 | + if (empty($label)) return; |
|
3937 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3938 | + $xprop = array('value' => $value); |
|
3939 | 3939 | $toolbox = new calendarComponent(); |
3940 | - $xprop['params'] = $toolbox->_setParams( $params ); |
|
3941 | - if( !is_array( $this->xprop )) $this->xprop = array(); |
|
3942 | - $this->xprop[strtoupper( $label )] = $xprop; |
|
3940 | + $xprop['params'] = $toolbox->_setParams($params); |
|
3941 | + if (!is_array($this->xprop)) $this->xprop = array(); |
|
3942 | + $this->xprop[strtoupper($label)] = $xprop; |
|
3943 | 3943 | return TRUE; |
3944 | 3944 | } |
3945 | 3945 | /*********************************************************************************/ |
@@ -3952,11 +3952,11 @@ discard block |
||
3952 | 3952 | * @return string |
3953 | 3953 | */ |
3954 | 3954 | function _createFormat() { |
3955 | - $objectname = null; |
|
3956 | - switch( $this->format ) { |
|
3955 | + $objectname = null; |
|
3956 | + switch ($this->format) { |
|
3957 | 3957 | case 'xcal': |
3958 | - $objectname = ( isset( $this->timezonetype )) ? |
|
3959 | - strtolower( $this->timezonetype ) : strtolower( $this->objName ); |
|
3958 | + $objectname = (isset($this->timezonetype)) ? |
|
3959 | + strtolower($this->timezonetype) : strtolower($this->objName); |
|
3960 | 3960 | $this->componentStart1 = $this->elementStart1 = '<'; |
3961 | 3961 | $this->componentStart2 = $this->elementStart2 = '>'; |
3962 | 3962 | $this->componentEnd1 = $this->elementEnd1 = '</'; |
@@ -3966,8 +3966,8 @@ discard block |
||
3966 | 3966 | $this->valueInit = null; |
3967 | 3967 | break; |
3968 | 3968 | default: |
3969 | - $objectname = ( isset( $this->timezonetype )) ? |
|
3970 | - strtoupper( $this->timezonetype ) : strtoupper( $this->objName ); |
|
3969 | + $objectname = (isset($this->timezonetype)) ? |
|
3970 | + strtoupper($this->timezonetype) : strtoupper($this->objName); |
|
3971 | 3971 | $this->componentStart1 = 'BEGIN:'; |
3972 | 3972 | $this->componentStart2 = null; |
3973 | 3973 | $this->componentEnd1 = 'END:'; |
@@ -3993,82 +3993,82 @@ discard block |
||
3993 | 3993 | * @param string $content property content (optional) |
3994 | 3994 | * @return string |
3995 | 3995 | */ |
3996 | - function _createElement( $label, $attributes=null, $content=FALSE ) { |
|
3997 | - $label = $this->_formatPropertyName( $label ); |
|
3996 | + function _createElement($label, $attributes = null, $content = FALSE) { |
|
3997 | + $label = $this->_formatPropertyName($label); |
|
3998 | 3998 | $output = $this->elementStart1.$label; |
3999 | 3999 | $categoriesAttrLang = null; |
4000 | 4000 | $attachInlineBinary = FALSE; |
4001 | 4001 | $attachfmttype = null; |
4002 | - if( !empty( $attributes )) { |
|
4003 | - $attributes = trim( $attributes ); |
|
4004 | - if ( 'xcal' == $this->format) { |
|
4005 | - $attributes2 = explode( $this->intAttrDelimiter, $attributes ); |
|
4002 | + if (!empty($attributes)) { |
|
4003 | + $attributes = trim($attributes); |
|
4004 | + if ('xcal' == $this->format) { |
|
4005 | + $attributes2 = explode($this->intAttrDelimiter, $attributes); |
|
4006 | 4006 | $attributes = null; |
4007 | - foreach( $attributes2 as $attribute ) { |
|
4008 | - $attrKVarr = explode( '=', $attribute ); |
|
4009 | - if( empty( $attrKVarr[0] )) |
|
4007 | + foreach ($attributes2 as $attribute) { |
|
4008 | + $attrKVarr = explode('=', $attribute); |
|
4009 | + if (empty($attrKVarr[0])) |
|
4010 | 4010 | continue; |
4011 | - if( !isset( $attrKVarr[1] )) { |
|
4011 | + if (!isset($attrKVarr[1])) { |
|
4012 | 4012 | $attrValue = $attrKVarr[0]; |
4013 | 4013 | $attrKey = null; |
4014 | 4014 | } |
4015 | - elseif( 2 == count( $attrKVarr)) { |
|
4016 | - $attrKey = strtolower( $attrKVarr[0] ); |
|
4015 | + elseif (2 == count($attrKVarr)) { |
|
4016 | + $attrKey = strtolower($attrKVarr[0]); |
|
4017 | 4017 | $attrValue = $attrKVarr[1]; |
4018 | 4018 | } |
4019 | 4019 | else { |
4020 | - $attrKey = strtolower( $attrKVarr[0] ); |
|
4021 | - unset( $attrKVarr[0] ); |
|
4022 | - $attrValue = implode( '=', $attrKVarr ); |
|
4020 | + $attrKey = strtolower($attrKVarr[0]); |
|
4021 | + unset($attrKVarr[0]); |
|
4022 | + $attrValue = implode('=', $attrKVarr); |
|
4023 | 4023 | } |
4024 | - if(( 'attach' == $label ) && ( in_array( $attrKey, array( 'fmttype', 'encoding', 'value' )))) { |
|
4024 | + if (('attach' == $label) && (in_array($attrKey, array('fmttype', 'encoding', 'value')))) { |
|
4025 | 4025 | $attachInlineBinary = TRUE; |
4026 | - if( 'fmttype' == $attrKey ) |
|
4026 | + if ('fmttype' == $attrKey) |
|
4027 | 4027 | $attachfmttype = $attrKey.'='.$attrValue; |
4028 | 4028 | continue; |
4029 | 4029 | } |
4030 | - elseif(( 'categories' == $label ) && ( 'language' == $attrKey )) |
|
4030 | + elseif (('categories' == $label) && ('language' == $attrKey)) |
|
4031 | 4031 | $categoriesAttrLang = $attrKey.'='.$attrValue; |
4032 | 4032 | else { |
4033 | - $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' '; |
|
4034 | - $attributes .= ( !empty( $attrKey )) ? $attrKey.'=' : null; |
|
4035 | - if(( '"' == substr( $attrValue, 0, 1 )) && ( '"' == substr( $attrValue, -1 ))) { |
|
4036 | - $attrValue = substr( $attrValue, 1, ( strlen( $attrValue ) - 2 )); |
|
4037 | - $attrValue = str_replace( '"', '', $attrValue ); |
|
4033 | + $attributes .= (empty($attributes)) ? ' ' : $this->attributeDelimiter.' '; |
|
4034 | + $attributes .= (!empty($attrKey)) ? $attrKey.'=' : null; |
|
4035 | + if (('"' == substr($attrValue, 0, 1)) && ('"' == substr($attrValue, -1))) { |
|
4036 | + $attrValue = substr($attrValue, 1, (strlen($attrValue) - 2)); |
|
4037 | + $attrValue = str_replace('"', '', $attrValue); |
|
4038 | 4038 | } |
4039 | - $attributes .= '"'.htmlspecialchars( $attrValue ).'"'; |
|
4039 | + $attributes .= '"'.htmlspecialchars($attrValue).'"'; |
|
4040 | 4040 | } |
4041 | 4041 | } |
4042 | 4042 | } |
4043 | 4043 | else { |
4044 | - $attributes = str_replace( $this->intAttrDelimiter, $this->attributeDelimiter, $attributes ); |
|
4044 | + $attributes = str_replace($this->intAttrDelimiter, $this->attributeDelimiter, $attributes); |
|
4045 | 4045 | } |
4046 | 4046 | } |
4047 | - if(((( 'attach' == $label ) && !$attachInlineBinary ) || |
|
4048 | - ( in_array( $label, array( 'tzurl', 'url' )))) && ( 'xcal' == $this->format)) { |
|
4047 | + if (((('attach' == $label) && !$attachInlineBinary) || |
|
4048 | + (in_array($label, array('tzurl', 'url')))) && ('xcal' == $this->format)) { |
|
4049 | 4049 | $pos = strrpos($content, "/"); |
4050 | - $docname = ( $pos !== false) ? substr( $content, (1 - strlen( $content ) + $pos )) : $content; |
|
4051 | - $this->xcaldecl[] = array( 'xmldecl' => 'ENTITY' |
|
4050 | + $docname = ($pos !== false) ? substr($content, (1 - strlen($content) + $pos)) : $content; |
|
4051 | + $this->xcaldecl[] = array('xmldecl' => 'ENTITY' |
|
4052 | 4052 | , 'uri' => $docname |
4053 | 4053 | , 'ref' => 'SYSTEM' |
4054 | 4054 | , 'external' => $content |
4055 | 4055 | , 'type' => 'NDATA' |
4056 | - , 'type2' => 'BINERY' ); |
|
4057 | - $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' '; |
|
4056 | + , 'type2' => 'BINERY'); |
|
4057 | + $attributes .= (empty($attributes)) ? ' ' : $this->attributeDelimiter.' '; |
|
4058 | 4058 | $attributes .= 'uri="'.$docname.'"'; |
4059 | 4059 | $content = null; |
4060 | - if( 'attach' == $label ) { |
|
4061 | - $attributes = str_replace( $this->attributeDelimiter, $this->intAttrDelimiter, $attributes ); |
|
4062 | - $content = $this->_createElement( 'extref', $attributes, null ); |
|
4060 | + if ('attach' == $label) { |
|
4061 | + $attributes = str_replace($this->attributeDelimiter, $this->intAttrDelimiter, $attributes); |
|
4062 | + $content = $this->_createElement('extref', $attributes, null); |
|
4063 | 4063 | $attributes = null; |
4064 | 4064 | } |
4065 | 4065 | } |
4066 | - elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) { |
|
4067 | - $content = $this->nl.$this->_createElement( 'b64bin', $attachfmttype, $content ); // max one attribute |
|
4066 | + elseif (('attach' == $label) && $attachInlineBinary && ('xcal' == $this->format)) { |
|
4067 | + $content = $this->nl.$this->_createElement('b64bin', $attachfmttype, $content); // max one attribute |
|
4068 | 4068 | } |
4069 | 4069 | $output .= $attributes; |
4070 | - if( !$content ) { |
|
4071 | - switch( $this->format ) { |
|
4070 | + if (!$content) { |
|
4071 | + switch ($this->format) { |
|
4072 | 4072 | case 'xcal': |
4073 | 4073 | $output .= ' /'; |
4074 | 4074 | $output .= $this->elementStart2; |
@@ -4076,18 +4076,18 @@ discard block |
||
4076 | 4076 | break; |
4077 | 4077 | default: |
4078 | 4078 | $output .= $this->elementStart2.$this->valueInit; |
4079 | - return $this->_size75( $output ); |
|
4079 | + return $this->_size75($output); |
|
4080 | 4080 | break; |
4081 | 4081 | } |
4082 | 4082 | } |
4083 | 4083 | $output .= $this->elementStart2; |
4084 | 4084 | $output .= $this->valueInit.$content; |
4085 | - switch( $this->format ) { |
|
4085 | + switch ($this->format) { |
|
4086 | 4086 | case 'xcal': |
4087 | 4087 | return $output.$this->elementEnd1.$label.$this->elementEnd2; |
4088 | 4088 | break; |
4089 | 4089 | default: |
4090 | - return $this->_size75( $output ); |
|
4090 | + return $this->_size75($output); |
|
4091 | 4091 | break; |
4092 | 4092 | } |
4093 | 4093 | } |
@@ -4100,36 +4100,36 @@ discard block |
||
4100 | 4100 | * @param array $ctrKeys optional |
4101 | 4101 | * @return string |
4102 | 4102 | */ |
4103 | - function _createParams( $params=array(), $ctrKeys=array() ) { |
|
4103 | + function _createParams($params = array(), $ctrKeys = array()) { |
|
4104 | 4104 | $attrLANG = $attr1 = $attr2 = null; |
4105 | - $CNattrKey = ( in_array( 'CN', $ctrKeys )) ? TRUE : FALSE ; |
|
4106 | - $LANGattrKey = ( in_array( 'LANGUAGE', $ctrKeys )) ? TRUE : FALSE ; |
|
4105 | + $CNattrKey = (in_array('CN', $ctrKeys)) ? TRUE : FALSE; |
|
4106 | + $LANGattrKey = (in_array('LANGUAGE', $ctrKeys)) ? TRUE : FALSE; |
|
4107 | 4107 | $CNattrExist = $LANGattrExist = FALSE; |
4108 | - if( is_array( $params )) { |
|
4109 | - foreach( $params as $paramKey => $paramValue ) { |
|
4110 | - if( is_int( $paramKey )) |
|
4108 | + if (is_array($params)) { |
|
4109 | + foreach ($params as $paramKey => $paramValue) { |
|
4110 | + if (is_int($paramKey)) |
|
4111 | 4111 | $attr2 .= $this->intAttrDelimiter.$paramValue; |
4112 | - elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) { |
|
4112 | + elseif (('LANGUAGE' == $paramKey) && $LANGattrKey) { |
|
4113 | 4113 | $attrLANG .= $this->intAttrDelimiter."LANGUAGE=$paramValue"; |
4114 | 4114 | $LANGattrExist = TRUE; |
4115 | 4115 | } |
4116 | - elseif(( 'CN' == $paramKey ) && $CNattrKey ) { |
|
4116 | + elseif (('CN' == $paramKey) && $CNattrKey) { |
|
4117 | 4117 | $attr1 = $this->intAttrDelimiter.'CN="'.$paramValue.'"'; |
4118 | 4118 | $CNattrExist = TRUE; |
4119 | 4119 | } |
4120 | - elseif(( 'ALTREP' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4120 | + elseif (('ALTREP' == $paramKey) && in_array($paramKey, $ctrKeys)) |
|
4121 | 4121 | $attr2 .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"'; |
4122 | - elseif(( 'DIR' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4122 | + elseif (('DIR' == $paramKey) && in_array($paramKey, $ctrKeys)) |
|
4123 | 4123 | $attr2 .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"'; |
4124 | - elseif(( 'SENT-BY' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4124 | + elseif (('SENT-BY' == $paramKey) && in_array($paramKey, $ctrKeys)) |
|
4125 | 4125 | $attr2 .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"'; |
4126 | 4126 | else |
4127 | 4127 | $attr2 .= $this->intAttrDelimiter."$paramKey=$paramValue"; |
4128 | 4128 | } |
4129 | 4129 | } |
4130 | - if( !$LANGattrExist ) { |
|
4131 | - $lang = $this->getConfig( 'language' ); |
|
4132 | - if(( $CNattrExist || $LANGattrKey ) && $lang ) |
|
4130 | + if (!$LANGattrExist) { |
|
4131 | + $lang = $this->getConfig('language'); |
|
4132 | + if (($CNattrExist || $LANGattrKey) && $lang) |
|
4133 | 4133 | $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang; |
4134 | 4134 | } |
4135 | 4135 | return $attrLANG.$attr1.$attr2; |
@@ -4143,47 +4143,47 @@ discard block |
||
4143 | 4143 | * @param int $parno, no of date parts (i.e. year, month.. .) |
4144 | 4144 | * @return array $params, property parameters |
4145 | 4145 | */ |
4146 | - function _chkdatecfg( $theDate, & $parno, & $params ) { |
|
4147 | - if( isset( $params['TZID'] )) |
|
4146 | + function _chkdatecfg($theDate, & $parno, & $params) { |
|
4147 | + if (isset($params['TZID'])) |
|
4148 | 4148 | $parno = 6; |
4149 | - elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )) |
|
4149 | + elseif (isset($params['VALUE']) && ('DATE' == $params['VALUE'])) |
|
4150 | 4150 | $parno = 3; |
4151 | 4151 | else { |
4152 | - if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] )) |
|
4152 | + if (isset($params['VALUE']) && ('PERIOD' == $params['VALUE'])) |
|
4153 | 4153 | $parno = 7; |
4154 | - if( is_array( $theDate )) { |
|
4155 | - if( isset( $theDate['timestamp'] )) |
|
4156 | - $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null; |
|
4154 | + if (is_array($theDate)) { |
|
4155 | + if (isset($theDate['timestamp'])) |
|
4156 | + $tzid = (isset($theDate['tz'])) ? $theDate['tz'] : null; |
|
4157 | 4157 | else |
4158 | - $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null; |
|
4159 | - if( !empty( $tzid )) { |
|
4158 | + $tzid = (isset($theDate['tz'])) ? $theDate['tz'] : (7 == count($theDate)) ? end($theDate) : null; |
|
4159 | + if (!empty($tzid)) { |
|
4160 | 4160 | $parno = 7; |
4161 | - if( !$this->_isOffset( $tzid )) |
|
4161 | + if (!$this->_isOffset($tzid)) |
|
4162 | 4162 | $params['TZID'] = $tzid; // save only timezone |
4163 | 4163 | } |
4164 | - elseif( !$parno && ( 3 == count( $theDate )) && |
|
4165 | - ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))) |
|
4164 | + elseif (!$parno && (3 == count($theDate)) && |
|
4165 | + (isset($params['VALUE']) && ('DATE' == $params['VALUE']))) |
|
4166 | 4166 | $parno = 3; |
4167 | 4167 | else |
4168 | 4168 | $parno = 6; |
4169 | 4169 | } |
4170 | 4170 | else { // string |
4171 | - $date = trim( $theDate ); |
|
4172 | - if( 'Z' == substr( $date, -1 )) |
|
4171 | + $date = trim($theDate); |
|
4172 | + if ('Z' == substr($date, -1)) |
|
4173 | 4173 | $parno = 7; // UTC DATE-TIME |
4174 | - elseif((( 8 == strlen( $date ) && ctype_digit( $date )) || ( 11 >= strlen( $date ))) && |
|
4175 | - ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' )))) |
|
4174 | + elseif (((8 == strlen($date) && ctype_digit($date)) || (11 >= strlen($date))) && |
|
4175 | + (!isset($params['VALUE']) || !in_array($params['VALUE'], array('DATE-TIME', 'PERIOD')))) |
|
4176 | 4176 | $parno = 3; // DATE |
4177 | - $date = $this->_date_time_string( $date, $parno ); |
|
4178 | - if( !empty( $date['tz'] )) { |
|
4177 | + $date = $this->_date_time_string($date, $parno); |
|
4178 | + if (!empty($date['tz'])) { |
|
4179 | 4179 | $parno = 7; |
4180 | - if( !$this->_isOffset( $date['tz'] )) |
|
4180 | + if (!$this->_isOffset($date['tz'])) |
|
4181 | 4181 | $params['TZID'] = $date['tz']; // save only timezone |
4182 | 4182 | } |
4183 | - elseif( empty( $parno )) |
|
4183 | + elseif (empty($parno)) |
|
4184 | 4184 | $parno = 6; |
4185 | 4185 | } |
4186 | - if( isset( $params['TZID'] )) |
|
4186 | + if (isset($params['TZID'])) |
|
4187 | 4187 | $parno = 6; |
4188 | 4188 | } |
4189 | 4189 | } |
@@ -4198,28 +4198,28 @@ discard block |
||
4198 | 4198 | * @param array $duration, optional |
4199 | 4199 | * @return array duration |
4200 | 4200 | */ |
4201 | - function _date2duration( $startdate=FALSE, $enddate=FALSE ) { |
|
4202 | - if( !$startdate || !$enddate ) { |
|
4203 | - if( FALSE === ( $startdate = $this->getProperty( 'dtstart' ))) |
|
4201 | + function _date2duration($startdate = FALSE, $enddate = FALSE) { |
|
4202 | + if (!$startdate || !$enddate) { |
|
4203 | + if (FALSE === ($startdate = $this->getProperty('dtstart'))) |
|
4204 | 4204 | return null; |
4205 | - if( FALSE === ( $enddate = $this->getProperty( 'dtend' ))) // vevent/vfreebusy |
|
4206 | - if( FALSE === ( $enddate = $this->getProperty( 'due' ))) // vtodo |
|
4205 | + if (FALSE === ($enddate = $this->getProperty('dtend'))) // vevent/vfreebusy |
|
4206 | + if (FALSE === ($enddate = $this->getProperty('due'))) // vtodo |
|
4207 | 4207 | return null; |
4208 | 4208 | } |
4209 | - if( !$startdate || !$enddate ) |
|
4209 | + if (!$startdate || !$enddate) |
|
4210 | 4210 | return null; |
4211 | - $startWdate = mktime( 0, 0, 0, $startdate['month'], $startdate['day'], $startdate['year'] ); |
|
4212 | - $endWdate = mktime( 0, 0, 0, $enddate['month'], $enddate['day'], $enddate['year'] ); |
|
4211 | + $startWdate = mktime(0, 0, 0, $startdate['month'], $startdate['day'], $startdate['year']); |
|
4212 | + $endWdate = mktime(0, 0, 0, $enddate['month'], $enddate['day'], $enddate['year']); |
|
4213 | 4213 | $wduration = $endWdate - $startWdate; |
4214 | 4214 | $dur = array(); |
4215 | - $dur['week'] = (int) floor( $wduration / ( 7 * 24 * 60 * 60 )); |
|
4216 | - $wduration = $wduration % ( 7 * 24 * 60 * 60 ); |
|
4217 | - $dur['day'] = (int) floor( $wduration / ( 24 * 60 * 60 )); |
|
4218 | - $wduration = $wduration % ( 24 * 60 * 60 ); |
|
4219 | - $dur['hour'] = (int) floor( $wduration / ( 60 * 60 )); |
|
4220 | - $wduration = $wduration % ( 60 * 60 ); |
|
4221 | - $dur['min'] = (int) floor( $wduration / ( 60 )); |
|
4222 | - $dur['sec'] = (int) $wduration % ( 60 ); |
|
4215 | + $dur['week'] = (int) floor($wduration / (7 * 24 * 60 * 60)); |
|
4216 | + $wduration = $wduration % (7 * 24 * 60 * 60); |
|
4217 | + $dur['day'] = (int) floor($wduration / (24 * 60 * 60)); |
|
4218 | + $wduration = $wduration % (24 * 60 * 60); |
|
4219 | + $dur['hour'] = (int) floor($wduration / (60 * 60)); |
|
4220 | + $wduration = $wduration % (60 * 60); |
|
4221 | + $dur['min'] = (int) floor($wduration / (60)); |
|
4222 | + $dur['sec'] = (int) $wduration % (60); |
|
4223 | 4223 | return $dur; |
4224 | 4224 | } |
4225 | 4225 | /** |
@@ -4231,19 +4231,19 @@ discard block |
||
4231 | 4231 | * @param string $tz timezone |
4232 | 4232 | * @return timestamp |
4233 | 4233 | */ |
4234 | - function _date2timestamp( $datetime, $tz=null ) { |
|
4234 | + function _date2timestamp($datetime, $tz = null) { |
|
4235 | 4235 | $output = null; |
4236 | - if( !isset( $datetime['hour'] )) $datetime['hour'] = '0'; |
|
4237 | - if( !isset( $datetime['min'] )) $datetime['min'] = '0'; |
|
4238 | - if( !isset( $datetime['sec'] )) $datetime['sec'] = '0'; |
|
4239 | - foreach( $datetime as $dkey => $dvalue ) { |
|
4240 | - if( 'tz' != $dkey ) |
|
4236 | + if (!isset($datetime['hour'])) $datetime['hour'] = '0'; |
|
4237 | + if (!isset($datetime['min'])) $datetime['min'] = '0'; |
|
4238 | + if (!isset($datetime['sec'])) $datetime['sec'] = '0'; |
|
4239 | + foreach ($datetime as $dkey => $dvalue) { |
|
4240 | + if ('tz' != $dkey) |
|
4241 | 4241 | $datetime[$dkey] = (integer) $dvalue; |
4242 | 4242 | } |
4243 | - if( $tz ) |
|
4243 | + if ($tz) |
|
4244 | 4244 | $datetime['tz'] = $tz; |
4245 | - $offset = ( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) ? $this->_tz2offset( $datetime['tz'] ) : 0; |
|
4246 | - $output = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year'] ); |
|
4245 | + $offset = (isset($datetime['tz']) && ('' < trim($datetime['tz']))) ? $this->_tz2offset($datetime['tz']) : 0; |
|
4246 | + $output = mktime($datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']); |
|
4247 | 4247 | return $output; |
4248 | 4248 | } |
4249 | 4249 | /** |
@@ -4255,13 +4255,13 @@ discard block |
||
4255 | 4255 | * @param int $parno optional, default FALSE |
4256 | 4256 | * @return array |
4257 | 4257 | */ |
4258 | - function _date_time_array( $datetime, $parno=FALSE ) { |
|
4258 | + function _date_time_array($datetime, $parno = FALSE) { |
|
4259 | 4259 | $output = array(); |
4260 | - foreach( $datetime as $dateKey => $datePart ) { |
|
4261 | - switch ( $dateKey ) { |
|
4260 | + foreach ($datetime as $dateKey => $datePart) { |
|
4261 | + switch ($dateKey) { |
|
4262 | 4262 | case '0': |
4263 | 4263 | case 'year': |
4264 | - $output['year'] = $datePart; |
|
4264 | + $output['year'] = $datePart; |
|
4265 | 4265 | break; |
4266 | 4266 | case '1': |
4267 | 4267 | case 'month': |
@@ -4269,40 +4269,40 @@ discard block |
||
4269 | 4269 | break; |
4270 | 4270 | case '2': |
4271 | 4271 | case 'day': |
4272 | - $output['day'] = $datePart; |
|
4272 | + $output['day'] = $datePart; |
|
4273 | 4273 | break; |
4274 | 4274 | } |
4275 | - if( 3 != $parno ) { |
|
4276 | - switch ( $dateKey ) { |
|
4275 | + if (3 != $parno) { |
|
4276 | + switch ($dateKey) { |
|
4277 | 4277 | case '0': |
4278 | 4278 | case '1': |
4279 | 4279 | case '2': |
4280 | 4280 | break; |
4281 | 4281 | case '3': |
4282 | 4282 | case 'hour': |
4283 | - $output['hour'] = $datePart; |
|
4283 | + $output['hour'] = $datePart; |
|
4284 | 4284 | break; |
4285 | 4285 | case '4': |
4286 | 4286 | case 'min': |
4287 | - $output['min'] = $datePart; |
|
4287 | + $output['min'] = $datePart; |
|
4288 | 4288 | break; |
4289 | 4289 | case '5': |
4290 | 4290 | case 'sec': |
4291 | - $output['sec'] = $datePart; |
|
4291 | + $output['sec'] = $datePart; |
|
4292 | 4292 | break; |
4293 | 4293 | case '6': |
4294 | 4294 | case 'tz': |
4295 | - $output['tz'] = $datePart; |
|
4295 | + $output['tz'] = $datePart; |
|
4296 | 4296 | break; |
4297 | 4297 | } |
4298 | 4298 | } |
4299 | 4299 | } |
4300 | - if( 3 != $parno ) { |
|
4301 | - if( !isset( $output['hour'] )) |
|
4300 | + if (3 != $parno) { |
|
4301 | + if (!isset($output['hour'])) |
|
4302 | 4302 | $output['hour'] = 0; |
4303 | - if( !isset( $output['min'] )) |
|
4303 | + if (!isset($output['min'])) |
|
4304 | 4304 | $output['min'] = 0; |
4305 | - if( !isset( $output['sec'] )) |
|
4305 | + if (!isset($output['sec'])) |
|
4306 | 4306 | $output['sec'] = 0; |
4307 | 4307 | } |
4308 | 4308 | return $output; |
@@ -4316,88 +4316,88 @@ discard block |
||
4316 | 4316 | * @param int $parno optional, default FALSE |
4317 | 4317 | * @return array |
4318 | 4318 | */ |
4319 | - function _date_time_string( $datetime, $parno=FALSE ) { |
|
4320 | - $datetime = (string) trim( $datetime ); |
|
4319 | + function _date_time_string($datetime, $parno = FALSE) { |
|
4320 | + $datetime = (string) trim($datetime); |
|
4321 | 4321 | $tz = null; |
4322 | - $len = strlen( $datetime ) - 1; |
|
4323 | - if( 'Z' == substr( $datetime, -1 )) { |
|
4322 | + $len = strlen($datetime) - 1; |
|
4323 | + if ('Z' == substr($datetime, -1)) { |
|
4324 | 4324 | $tz = 'Z'; |
4325 | - $datetime = trim( substr( $datetime, 0, $len )); |
|
4325 | + $datetime = trim(substr($datetime, 0, $len)); |
|
4326 | 4326 | } |
4327 | - elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date |
|
4328 | - ( '-' == substr( $datetime, -3, 1 )) || |
|
4329 | - ( ':' == substr( $datetime, -3, 1 )) || |
|
4330 | - ( '.' == substr( $datetime, -3, 1 ))) { |
|
4327 | + elseif ((ctype_digit(substr($datetime, -2, 2))) && // time or date |
|
4328 | + ('-' == substr($datetime, -3, 1)) || |
|
4329 | + (':' == substr($datetime, -3, 1)) || |
|
4330 | + ('.' == substr($datetime, -3, 1))) { |
|
4331 | 4331 | $continue = TRUE; |
4332 | 4332 | } |
4333 | - elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset |
|
4334 | - ( ' +' == substr( $datetime, -6, 2 )) || |
|
4335 | - ( ' -' == substr( $datetime, -6, 2 ))) { |
|
4336 | - $tz = substr( $datetime, -5, 5 ); |
|
4337 | - $datetime = substr( $datetime, 0, ($len - 5)); |
|
4333 | + elseif ((ctype_digit(substr($datetime, -4, 4))) && // 4 pos offset |
|
4334 | + (' +' == substr($datetime, -6, 2)) || |
|
4335 | + (' -' == substr($datetime, -6, 2))) { |
|
4336 | + $tz = substr($datetime, -5, 5); |
|
4337 | + $datetime = substr($datetime, 0, ($len - 5)); |
|
4338 | 4338 | } |
4339 | - elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset |
|
4340 | - ( ' +' == substr( $datetime, -8, 2 )) || |
|
4341 | - ( ' -' == substr( $datetime, -8, 2 ))) { |
|
4342 | - $tz = substr( $datetime, -7, 7 ); |
|
4343 | - $datetime = substr( $datetime, 0, ($len - 7)); |
|
4339 | + elseif ((ctype_digit(substr($datetime, -6, 6))) && // 6 pos offset |
|
4340 | + (' +' == substr($datetime, -8, 2)) || |
|
4341 | + (' -' == substr($datetime, -8, 2))) { |
|
4342 | + $tz = substr($datetime, -7, 7); |
|
4343 | + $datetime = substr($datetime, 0, ($len - 7)); |
|
4344 | 4344 | } |
4345 | - elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) { |
|
4345 | + elseif ((6 < $len) && (ctype_digit(substr($datetime, -6, 6)))) { |
|
4346 | 4346 | $continue = TRUE; |
4347 | 4347 | } |
4348 | - elseif( 'T' == substr( $datetime, -7, 1 )) { |
|
4348 | + elseif ('T' == substr($datetime, -7, 1)) { |
|
4349 | 4349 | $continue = TRUE; |
4350 | 4350 | } |
4351 | 4351 | else { |
4352 | - $cx = $tx = 0; // 19970415T133000 US-Eastern |
|
4353 | - for( $cx = -1; $cx > ( 9 - $len ); $cx-- ) { |
|
4354 | - if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 ))) |
|
4352 | + $cx = $tx = 0; // 19970415T133000 US-Eastern |
|
4353 | + for ($cx = -1; $cx > (9 - $len); $cx--) { |
|
4354 | + if ((' ' == substr($datetime, $cx, 1)) || ctype_digit(substr($datetime, $cx, 1))) |
|
4355 | 4355 | break; // if exists, tz ends here.. . ? |
4356 | - elseif( ctype_alpha( substr( $datetime, $cx, 1 )) || |
|
4357 | - ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' )))) |
|
4356 | + elseif (ctype_alpha(substr($datetime, $cx, 1)) || |
|
4357 | + (in_array(substr($datetime, $cx, 1), array('-', '/')))) |
|
4358 | 4358 | $tx--; // tz length counter |
4359 | 4359 | } |
4360 | - if( 0 > $tx ) { |
|
4361 | - $tz = substr( $datetime, $tx ); |
|
4362 | - $datetime = trim( substr( $datetime, 0, $len + $tx + 1 )); |
|
4360 | + if (0 > $tx) { |
|
4361 | + $tz = substr($datetime, $tx); |
|
4362 | + $datetime = trim(substr($datetime, 0, $len + $tx + 1)); |
|
4363 | 4363 | } |
4364 | 4364 | } |
4365 | - if( 0 < substr_count( $datetime, '-' )) { |
|
4366 | - $datetime = str_replace( '-', '/', $datetime ); |
|
4367 | - } |
|
4368 | - elseif( ctype_digit( substr( $datetime, 0, 8 )) && |
|
4369 | - ( 'T' == substr( $datetime, 8, 1 )) && |
|
4370 | - ctype_digit( substr( $datetime, 9, 6 ))) { |
|
4371 | - $datetime = substr( $datetime, 4, 2 ) |
|
4372 | - .'/'.substr( $datetime, 6, 2 ) |
|
4373 | - .'/'.substr( $datetime, 0, 4 ) |
|
4374 | - .' '.substr( $datetime, 9, 2 ) |
|
4375 | - .':'.substr( $datetime, 11, 2 ) |
|
4376 | - .':'.substr( $datetime, 13); |
|
4377 | - } |
|
4378 | - $datestring = date( 'Y-m-d H:i:s', strtotime( $datetime )); |
|
4379 | - $tz = trim( $tz ); |
|
4365 | + if (0 < substr_count($datetime, '-')) { |
|
4366 | + $datetime = str_replace('-', '/', $datetime); |
|
4367 | + } |
|
4368 | + elseif (ctype_digit(substr($datetime, 0, 8)) && |
|
4369 | + ('T' == substr($datetime, 8, 1)) && |
|
4370 | + ctype_digit(substr($datetime, 9, 6))) { |
|
4371 | + $datetime = substr($datetime, 4, 2) |
|
4372 | + .'/'.substr($datetime, 6, 2) |
|
4373 | + .'/'.substr($datetime, 0, 4) |
|
4374 | + .' '.substr($datetime, 9, 2) |
|
4375 | + .':'.substr($datetime, 11, 2) |
|
4376 | + .':'.substr($datetime, 13); |
|
4377 | + } |
|
4378 | + $datestring = date('Y-m-d H:i:s', strtotime($datetime)); |
|
4379 | + $tz = trim($tz); |
|
4380 | 4380 | $output = array(); |
4381 | - $output['year'] = substr( $datestring, 0, 4 ); |
|
4382 | - $output['month'] = substr( $datestring, 5, 2 ); |
|
4383 | - $output['day'] = substr( $datestring, 8, 2 ); |
|
4384 | - if(( 6 == $parno ) || ( 7 == $parno )) { |
|
4385 | - $output['hour'] = substr( $datestring, 11, 2 ); |
|
4386 | - $output['min'] = substr( $datestring, 14, 2 ); |
|
4387 | - $output['sec'] = substr( $datestring, 17, 2 ); |
|
4388 | - if( !empty( $tz )) |
|
4389 | - $output['tz'] = $tz; |
|
4390 | - } |
|
4391 | - elseif( 3 != $parno ) { |
|
4392 | - if(( '00' < substr( $datestring, 11, 2 )) || |
|
4393 | - ( '00' < substr( $datestring, 14, 2 )) || |
|
4394 | - ( '00' < substr( $datestring, 17, 2 ))) { |
|
4395 | - $output['hour'] = substr( $datestring, 11, 2 ); |
|
4396 | - $output['min'] = substr( $datestring, 14, 2 ); |
|
4397 | - $output['sec'] = substr( $datestring, 17, 2 ); |
|
4381 | + $output['year'] = substr($datestring, 0, 4); |
|
4382 | + $output['month'] = substr($datestring, 5, 2); |
|
4383 | + $output['day'] = substr($datestring, 8, 2); |
|
4384 | + if ((6 == $parno) || (7 == $parno)) { |
|
4385 | + $output['hour'] = substr($datestring, 11, 2); |
|
4386 | + $output['min'] = substr($datestring, 14, 2); |
|
4387 | + $output['sec'] = substr($datestring, 17, 2); |
|
4388 | + if (!empty($tz)) |
|
4389 | + $output['tz'] = $tz; |
|
4390 | + } |
|
4391 | + elseif (3 != $parno) { |
|
4392 | + if (('00' < substr($datestring, 11, 2)) || |
|
4393 | + ('00' < substr($datestring, 14, 2)) || |
|
4394 | + ('00' < substr($datestring, 17, 2))) { |
|
4395 | + $output['hour'] = substr($datestring, 11, 2); |
|
4396 | + $output['min'] = substr($datestring, 14, 2); |
|
4397 | + $output['sec'] = substr($datestring, 17, 2); |
|
4398 | 4398 | } |
4399 | - if( !empty( $tz )) |
|
4400 | - $output['tz'] = $tz; |
|
4399 | + if (!empty($tz)) |
|
4400 | + $output['tz'] = $tz; |
|
4401 | 4401 | } |
4402 | 4402 | return $output; |
4403 | 4403 | } |
@@ -4409,62 +4409,62 @@ discard block |
||
4409 | 4409 | * @param array $duration |
4410 | 4410 | * @return array |
4411 | 4411 | */ |
4412 | - function _duration_array( $duration ) { |
|
4412 | + function _duration_array($duration) { |
|
4413 | 4413 | $output = array(); |
4414 | - if( is_array( $duration ) && |
|
4415 | - ( 1 == count( $duration )) && |
|
4416 | - isset( $duration['sec'] ) && |
|
4417 | - ( 60 < $duration['sec'] )) { |
|
4414 | + if (is_array($duration) && |
|
4415 | + (1 == count($duration)) && |
|
4416 | + isset($duration['sec']) && |
|
4417 | + (60 < $duration['sec'])) { |
|
4418 | 4418 | $durseconds = $duration['sec']; |
4419 | - $output['week'] = floor( $durseconds / ( 60 * 60 * 24 * 7 )); |
|
4420 | - $durseconds = $durseconds % ( 60 * 60 * 24 * 7 ); |
|
4421 | - $output['day'] = floor( $durseconds / ( 60 * 60 * 24 )); |
|
4422 | - $durseconds = $durseconds % ( 60 * 60 * 24 ); |
|
4423 | - $output['hour'] = floor( $durseconds / ( 60 * 60 )); |
|
4424 | - $durseconds = $durseconds % ( 60 * 60 ); |
|
4425 | - $output['min'] = floor( $durseconds / ( 60 )); |
|
4426 | - $output['sec'] = ( $durseconds % ( 60 )); |
|
4419 | + $output['week'] = floor($durseconds / (60 * 60 * 24 * 7)); |
|
4420 | + $durseconds = $durseconds % (60 * 60 * 24 * 7); |
|
4421 | + $output['day'] = floor($durseconds / (60 * 60 * 24)); |
|
4422 | + $durseconds = $durseconds % (60 * 60 * 24); |
|
4423 | + $output['hour'] = floor($durseconds / (60 * 60)); |
|
4424 | + $durseconds = $durseconds % (60 * 60); |
|
4425 | + $output['min'] = floor($durseconds / (60)); |
|
4426 | + $output['sec'] = ($durseconds % (60)); |
|
4427 | 4427 | } |
4428 | 4428 | else { |
4429 | - foreach( $duration as $durKey => $durValue ) { |
|
4430 | - if( empty( $durValue )) continue; |
|
4431 | - switch ( $durKey ) { |
|
4429 | + foreach ($duration as $durKey => $durValue) { |
|
4430 | + if (empty($durValue)) continue; |
|
4431 | + switch ($durKey) { |
|
4432 | 4432 | case '0': |
4433 | 4433 | case 'week': |
4434 | - $output['week'] = $durValue; |
|
4434 | + $output['week'] = $durValue; |
|
4435 | 4435 | break; |
4436 | 4436 | case '1': |
4437 | 4437 | case 'day': |
4438 | - $output['day'] = $durValue; |
|
4438 | + $output['day'] = $durValue; |
|
4439 | 4439 | break; |
4440 | 4440 | case '2': |
4441 | 4441 | case 'hour': |
4442 | - $output['hour'] = $durValue; |
|
4442 | + $output['hour'] = $durValue; |
|
4443 | 4443 | break; |
4444 | 4444 | case '3': |
4445 | 4445 | case 'min': |
4446 | - $output['min'] = $durValue; |
|
4446 | + $output['min'] = $durValue; |
|
4447 | 4447 | break; |
4448 | 4448 | case '4': |
4449 | 4449 | case 'sec': |
4450 | - $output['sec'] = $durValue; |
|
4450 | + $output['sec'] = $durValue; |
|
4451 | 4451 | break; |
4452 | 4452 | } |
4453 | 4453 | } |
4454 | 4454 | } |
4455 | - if( isset( $output['week'] ) && ( 0 < $output['week'] )) { |
|
4456 | - unset( $output['day'], $output['hour'], $output['min'], $output['sec'] ); |
|
4455 | + if (isset($output['week']) && (0 < $output['week'])) { |
|
4456 | + unset($output['day'], $output['hour'], $output['min'], $output['sec']); |
|
4457 | 4457 | return $output; |
4458 | 4458 | } |
4459 | - unset( $output['week'] ); |
|
4460 | - if( empty( $output['day'] )) |
|
4461 | - unset( $output['day'] ); |
|
4462 | - if ( isset( $output['hour'] ) || isset( $output['min'] ) || isset( $output['sec'] )) { |
|
4463 | - if( !isset( $output['hour'] )) $output['hour'] = 0; |
|
4464 | - if( !isset( $output['min'] )) $output['min'] = 0; |
|
4465 | - if( !isset( $output['sec'] )) $output['sec'] = 0; |
|
4466 | - if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] )) |
|
4467 | - unset( $output['hour'], $output['min'], $output['sec'] ); |
|
4459 | + unset($output['week']); |
|
4460 | + if (empty($output['day'])) |
|
4461 | + unset($output['day']); |
|
4462 | + if (isset($output['hour']) || isset($output['min']) || isset($output['sec'])) { |
|
4463 | + if (!isset($output['hour'])) $output['hour'] = 0; |
|
4464 | + if (!isset($output['min'])) $output['min'] = 0; |
|
4465 | + if (!isset($output['sec'])) $output['sec'] = 0; |
|
4466 | + if ((0 == $output['hour']) && (0 == $output['min']) && (0 == $output['sec'])) |
|
4467 | + unset($output['hour'], $output['min'], $output['sec']); |
|
4468 | 4468 | } |
4469 | 4469 | return $output; |
4470 | 4470 | } |
@@ -4477,43 +4477,43 @@ discard block |
||
4477 | 4477 | * @param array $duration, optional |
4478 | 4478 | * @return array, date format |
4479 | 4479 | */ |
4480 | - function duration2date( $startdate=FALSE, $duration=FALSE ) { |
|
4481 | - if( $startdate && $duration ) { |
|
4480 | + function duration2date($startdate = FALSE, $duration = FALSE) { |
|
4481 | + if ($startdate && $duration) { |
|
4482 | 4482 | $d1 = $startdate; |
4483 | 4483 | $dur = $duration; |
4484 | 4484 | } |
4485 | - elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) { |
|
4485 | + elseif (isset($this->dtstart['value']) && isset($this->duration['value'])) { |
|
4486 | 4486 | $d1 = $this->dtstart['value']; |
4487 | 4487 | $dur = $this->duration['value']; |
4488 | 4488 | } |
4489 | 4489 | else |
4490 | 4490 | return null; |
4491 | - $dateOnly = ( isset( $d1['hour'] ) || isset( $d1['min'] ) || isset( $d1['sec'] )) ? FALSE : TRUE; |
|
4492 | - $d1['hour'] = ( isset( $d1['hour'] )) ? $d1['hour'] : 0; |
|
4493 | - $d1['min'] = ( isset( $d1['min'] )) ? $d1['min'] : 0; |
|
4494 | - $d1['sec'] = ( isset( $d1['sec'] )) ? $d1['sec'] : 0; |
|
4495 | - $dtend = mktime( $d1['hour'], $d1['min'], $d1['sec'], $d1['month'], $d1['day'], $d1['year'] ); |
|
4496 | - if( isset( $dur['week'] )) |
|
4497 | - $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 ); |
|
4498 | - if( isset( $dur['day'] )) |
|
4499 | - $dtend += ( $dur['day'] * 24 * 60 * 60 ); |
|
4500 | - if( isset( $dur['hour'] )) |
|
4501 | - $dtend += ( $dur['hour'] * 60 *60 ); |
|
4502 | - if( isset( $dur['min'] )) |
|
4503 | - $dtend += ( $dur['min'] * 60 ); |
|
4504 | - if( isset( $dur['sec'] )) |
|
4505 | - $dtend += $dur['sec']; |
|
4491 | + $dateOnly = (isset($d1['hour']) || isset($d1['min']) || isset($d1['sec'])) ? FALSE : TRUE; |
|
4492 | + $d1['hour'] = (isset($d1['hour'])) ? $d1['hour'] : 0; |
|
4493 | + $d1['min'] = (isset($d1['min'])) ? $d1['min'] : 0; |
|
4494 | + $d1['sec'] = (isset($d1['sec'])) ? $d1['sec'] : 0; |
|
4495 | + $dtend = mktime($d1['hour'], $d1['min'], $d1['sec'], $d1['month'], $d1['day'], $d1['year']); |
|
4496 | + if (isset($dur['week'])) |
|
4497 | + $dtend += ($dur['week'] * 7 * 24 * 60 * 60); |
|
4498 | + if (isset($dur['day'])) |
|
4499 | + $dtend += ($dur['day'] * 24 * 60 * 60); |
|
4500 | + if (isset($dur['hour'])) |
|
4501 | + $dtend += ($dur['hour'] * 60 * 60); |
|
4502 | + if (isset($dur['min'])) |
|
4503 | + $dtend += ($dur['min'] * 60); |
|
4504 | + if (isset($dur['sec'])) |
|
4505 | + $dtend += $dur['sec']; |
|
4506 | 4506 | $dtend2 = array(); |
4507 | - $dtend2['year'] = date('Y', $dtend ); |
|
4508 | - $dtend2['month'] = date('m', $dtend ); |
|
4509 | - $dtend2['day'] = date('d', $dtend ); |
|
4510 | - $dtend2['hour'] = date('H', $dtend ); |
|
4511 | - $dtend2['min'] = date('i', $dtend ); |
|
4512 | - $dtend2['sec'] = date('s', $dtend ); |
|
4513 | - if( isset( $d1['tz'] )) |
|
4514 | - $dtend2['tz'] = $d1['tz']; |
|
4515 | - if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] ))) |
|
4516 | - unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] ); |
|
4507 | + $dtend2['year'] = date('Y', $dtend); |
|
4508 | + $dtend2['month'] = date('m', $dtend); |
|
4509 | + $dtend2['day'] = date('d', $dtend); |
|
4510 | + $dtend2['hour'] = date('H', $dtend); |
|
4511 | + $dtend2['min'] = date('i', $dtend); |
|
4512 | + $dtend2['sec'] = date('s', $dtend); |
|
4513 | + if (isset($d1['tz'])) |
|
4514 | + $dtend2['tz'] = $d1['tz']; |
|
4515 | + if ($dateOnly && ((0 == $dtend2['hour']) && (0 == $dtend2['min']) && (0 == $dtend2['sec']))) |
|
4516 | + unset($dtend2['hour'], $dtend2['min'], $dtend2['sec']); |
|
4517 | 4517 | return $dtend2; |
4518 | 4518 | } |
4519 | 4519 | /** |
@@ -4524,21 +4524,21 @@ discard block |
||
4524 | 4524 | * @param string $duration |
4525 | 4525 | * @return array |
4526 | 4526 | */ |
4527 | - function _duration_string( $duration ) { |
|
4528 | - $duration = (string) trim( $duration ); |
|
4529 | - while( 'P' != strtoupper( substr( $duration, 0, 1 ))) { |
|
4530 | - if( 0 < strlen( $duration )) |
|
4531 | - $duration = substr( $duration, 1 ); |
|
4527 | + function _duration_string($duration) { |
|
4528 | + $duration = (string) trim($duration); |
|
4529 | + while ('P' != strtoupper(substr($duration, 0, 1))) { |
|
4530 | + if (0 < strlen($duration)) |
|
4531 | + $duration = substr($duration, 1); |
|
4532 | 4532 | else |
4533 | 4533 | return false; // no leading P !?!? |
4534 | 4534 | } |
4535 | - $duration = substr( $duration, 1 ); // skip P |
|
4536 | - $duration = str_replace ( 't', 'T', $duration ); |
|
4537 | - $duration = str_replace ( 'T', '', $duration ); |
|
4535 | + $duration = substr($duration, 1); // skip P |
|
4536 | + $duration = str_replace('t', 'T', $duration); |
|
4537 | + $duration = str_replace('T', '', $duration); |
|
4538 | 4538 | $output = array(); |
4539 | 4539 | $val = null; |
4540 | - for( $ix=0; $ix < strlen( $duration ); $ix++ ) { |
|
4541 | - switch( strtoupper( $duration{$ix} )) { |
|
4540 | + for ($ix = 0; $ix < strlen($duration); $ix++) { |
|
4541 | + switch (strtoupper($duration{$ix} )) { |
|
4542 | 4542 | case 'W': |
4543 | 4543 | $output['week'] = $val; |
4544 | 4544 | $val = null; |
@@ -4560,13 +4560,13 @@ discard block |
||
4560 | 4560 | $val = null; |
4561 | 4561 | break; |
4562 | 4562 | default: |
4563 | - if( !ctype_digit( $duration{$ix} )) |
|
4563 | + if (!ctype_digit($duration{$ix} )) |
|
4564 | 4564 | return false; // unknown duration controll character !?!? |
4565 | 4565 | else |
4566 | 4566 | $val .= $duration{$ix}; |
4567 | 4567 | } |
4568 | 4568 | } |
4569 | - return $this->_duration_array( $output ); |
|
4569 | + return $this->_duration_array($output); |
|
4570 | 4570 | } |
4571 | 4571 | /** |
4572 | 4572 | * if not preSet, if exist, remove key with expected value from array and return hit value else return elseValue |
@@ -4581,15 +4581,15 @@ discard block |
||
4581 | 4581 | * @param int $preSet optional, return value if already preset |
4582 | 4582 | * @return int |
4583 | 4583 | */ |
4584 | - function _existRem( &$array, $expkey, $expval=FALSE, $hitVal=null, $elseVal=null, $preSet=null ) { |
|
4585 | - if( $preSet ) |
|
4584 | + function _existRem(&$array, $expkey, $expval = FALSE, $hitVal = null, $elseVal = null, $preSet = null) { |
|
4585 | + if ($preSet) |
|
4586 | 4586 | return $preSet; |
4587 | - if( !is_array( $array ) || ( 0 == count( $array ))) |
|
4587 | + if (!is_array($array) || (0 == count($array))) |
|
4588 | 4588 | return $elseVal; |
4589 | - foreach( $array as $key => $value ) { |
|
4590 | - if( strtoupper( $expkey ) == strtoupper( $key )) { |
|
4591 | - if( !$expval || ( strtoupper( $expval ) == strtoupper( $array[$key] ))) { |
|
4592 | - unset( $array[$key] ); |
|
4589 | + foreach ($array as $key => $value) { |
|
4590 | + if (strtoupper($expkey) == strtoupper($key)) { |
|
4591 | + if (!$expval || (strtoupper($expval) == strtoupper($array[$key]))) { |
|
4592 | + unset($array[$key]); |
|
4593 | 4593 | return $hitVal; |
4594 | 4594 | } |
4595 | 4595 | } |
@@ -4605,48 +4605,48 @@ discard block |
||
4605 | 4605 | * @param int $parno, optional, default 6 |
4606 | 4606 | * @return string |
4607 | 4607 | */ |
4608 | - function _format_date_time( $datetime, $parno=6 ) { |
|
4609 | - if( !isset( $datetime['year'] ) && |
|
4610 | - !isset( $datetime['month'] ) && |
|
4611 | - !isset( $datetime['day'] ) && |
|
4612 | - !isset( $datetime['hour'] ) && |
|
4613 | - !isset( $datetime['min'] ) && |
|
4614 | - !isset( $datetime['sec'] )) |
|
4615 | - return ; |
|
4608 | + function _format_date_time($datetime, $parno = 6) { |
|
4609 | + if (!isset($datetime['year']) && |
|
4610 | + !isset($datetime['month']) && |
|
4611 | + !isset($datetime['day']) && |
|
4612 | + !isset($datetime['hour']) && |
|
4613 | + !isset($datetime['min']) && |
|
4614 | + !isset($datetime['sec'])) |
|
4615 | + return; |
|
4616 | 4616 | $output = null; |
4617 | 4617 | // 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"; } |
4618 | - foreach( $datetime as $dkey => $dvalue ) { |
|
4619 | - if( 'tz' != $dkey ) |
|
4618 | + foreach ($datetime as $dkey => $dvalue) { |
|
4619 | + if ('tz' != $dkey) |
|
4620 | 4620 | $datetime[$dkey] = (integer) $dvalue; |
4621 | 4621 | } |
4622 | - $output = date('Ymd', mktime( 0, 0, 0, $datetime['month'], $datetime['day'], $datetime['year'])); |
|
4623 | - if( isset( $datetime['hour'] ) || |
|
4624 | - isset( $datetime['min'] ) || |
|
4625 | - isset( $datetime['sec'] ) || |
|
4626 | - isset( $datetime['tz'] )) { |
|
4627 | - if( isset( $datetime['tz'] ) && |
|
4628 | - !isset( $datetime['hour'] )) |
|
4622 | + $output = date('Ymd', mktime(0, 0, 0, $datetime['month'], $datetime['day'], $datetime['year'])); |
|
4623 | + if (isset($datetime['hour']) || |
|
4624 | + isset($datetime['min']) || |
|
4625 | + isset($datetime['sec']) || |
|
4626 | + isset($datetime['tz'])) { |
|
4627 | + if (isset($datetime['tz']) && |
|
4628 | + !isset($datetime['hour'])) |
|
4629 | 4629 | $datetime['hour'] = 0; |
4630 | - if( isset( $datetime['hour'] ) && |
|
4631 | - !isset( $datetime['min'] )) |
|
4630 | + if (isset($datetime['hour']) && |
|
4631 | + !isset($datetime['min'])) |
|
4632 | 4632 | $datetime['min'] = 0; |
4633 | - if( isset( $datetime['hour'] ) && |
|
4634 | - isset( $datetime['min'] ) && |
|
4635 | - !isset( $datetime['sec'] )) |
|
4633 | + if (isset($datetime['hour']) && |
|
4634 | + isset($datetime['min']) && |
|
4635 | + !isset($datetime['sec'])) |
|
4636 | 4636 | $datetime['sec'] = 0; |
4637 | - $date = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']); |
|
4638 | - $output .= date('\THis', $date ); |
|
4639 | - if( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) { |
|
4640 | - $datetime['tz'] = trim( $datetime['tz'] ); |
|
4641 | - if( 'Z' == $datetime['tz'] ) |
|
4637 | + $date = mktime($datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']); |
|
4638 | + $output .= date('\THis', $date); |
|
4639 | + if (isset($datetime['tz']) && ('' < trim($datetime['tz']))) { |
|
4640 | + $datetime['tz'] = trim($datetime['tz']); |
|
4641 | + if ('Z' == $datetime['tz']) |
|
4642 | 4642 | $output .= 'Z'; |
4643 | - $offset = $this->_tz2offset( $datetime['tz'] ); |
|
4644 | - if( 0 != $offset ) { |
|
4645 | - $date = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']); |
|
4646 | - $output = date( 'Ymd\THis\Z', $date ); |
|
4643 | + $offset = $this->_tz2offset($datetime['tz']); |
|
4644 | + if (0 != $offset) { |
|
4645 | + $date = mktime($datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']); |
|
4646 | + $output = date('Ymd\THis\Z', $date); |
|
4647 | 4647 | } |
4648 | 4648 | } |
4649 | - elseif( 7 == $parno ) |
|
4649 | + elseif (7 == $parno) |
|
4650 | 4650 | $output .= 'Z'; |
4651 | 4651 | } |
4652 | 4652 | return $output; |
@@ -4659,26 +4659,26 @@ discard block |
||
4659 | 4659 | * @param array $duration ( week, day, hour, min, sec ) |
4660 | 4660 | * @return string |
4661 | 4661 | */ |
4662 | - function _format_duration( $duration ) { |
|
4663 | - if( !isset( $duration['week'] ) && |
|
4664 | - !isset( $duration['day'] ) && |
|
4665 | - !isset( $duration['hour'] ) && |
|
4666 | - !isset( $duration['min'] ) && |
|
4667 | - !isset( $duration['sec'] )) |
|
4662 | + function _format_duration($duration) { |
|
4663 | + if (!isset($duration['week']) && |
|
4664 | + !isset($duration['day']) && |
|
4665 | + !isset($duration['hour']) && |
|
4666 | + !isset($duration['min']) && |
|
4667 | + !isset($duration['sec'])) |
|
4668 | 4668 | return; |
4669 | 4669 | $output = 'P'; |
4670 | - if( isset( $duration['week'] ) && ( 0 < $duration['week'] )) |
|
4671 | - $output .= $duration['week'].'W'; |
|
4670 | + if (isset($duration['week']) && (0 < $duration['week'])) |
|
4671 | + $output .= $duration['week'].'W'; |
|
4672 | 4672 | else { |
4673 | - if( isset($duration['day'] ) && ( 0 < $duration['day'] )) |
|
4673 | + if (isset($duration['day']) && (0 < $duration['day'])) |
|
4674 | 4674 | $output .= $duration['day'].'D'; |
4675 | - if(( isset( $duration['hour']) && ( 0 < $duration['hour'] )) || |
|
4676 | - ( isset( $duration['min']) && ( 0 < $duration['min'] )) || |
|
4677 | - ( isset( $duration['sec']) && ( 0 < $duration['sec'] ))) { |
|
4675 | + if ((isset($duration['hour']) && (0 < $duration['hour'])) || |
|
4676 | + (isset($duration['min']) && (0 < $duration['min'])) || |
|
4677 | + (isset($duration['sec']) && (0 < $duration['sec']))) { |
|
4678 | 4678 | $output .= 'T'; |
4679 | - $output .= ( isset( $duration['hour']) && ( 0 < $duration['hour'] )) ? $duration['hour'].'H' : '0H'; |
|
4680 | - $output .= ( isset( $duration['min']) && ( 0 < $duration['min'] )) ? $duration['min']. 'M' : '0M'; |
|
4681 | - $output .= ( isset( $duration['sec']) && ( 0 < $duration['sec'] )) ? $duration['sec']. 'S' : '0S'; |
|
4679 | + $output .= (isset($duration['hour']) && (0 < $duration['hour'])) ? $duration['hour'].'H' : '0H'; |
|
4680 | + $output .= (isset($duration['min']) && (0 < $duration['min'])) ? $duration['min'].'M' : '0M'; |
|
4681 | + $output .= (isset($duration['sec']) && (0 < $duration['sec'])) ? $duration['sec'].'S' : '0S'; |
|
4682 | 4682 | } |
4683 | 4683 | } |
4684 | 4684 | return $output; |
@@ -4692,23 +4692,23 @@ discard block |
||
4692 | 4692 | * @param array $recurdata |
4693 | 4693 | * @return string |
4694 | 4694 | */ |
4695 | - function _format_recur( $recurlabel, $recurdata ) { |
|
4695 | + function _format_recur($recurlabel, $recurdata) { |
|
4696 | 4696 | $output = null; |
4697 | - foreach( $recurdata as $therule ) { |
|
4698 | - if( empty( $therule['value'] )) { |
|
4699 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $recurlabel ); |
|
4697 | + foreach ($recurdata as $therule) { |
|
4698 | + if (empty($therule['value'])) { |
|
4699 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement($recurlabel); |
|
4700 | 4700 | continue; |
4701 | 4701 | } |
4702 | - $attributes = ( isset( $therule['params'] )) ? $this->_createParams( $therule['params'] ) : null; |
|
4703 | - $content1 = $content2 = null; |
|
4704 | - foreach( $therule['value'] as $rulelabel => $rulevalue ) { |
|
4705 | - switch( $rulelabel ) { |
|
4702 | + $attributes = (isset($therule['params'])) ? $this->_createParams($therule['params']) : null; |
|
4703 | + $content1 = $content2 = null; |
|
4704 | + foreach ($therule['value'] as $rulelabel => $rulevalue) { |
|
4705 | + switch ($rulelabel) { |
|
4706 | 4706 | case 'FREQ': |
4707 | 4707 | $content1 .= "FREQ=$rulevalue"; |
4708 | 4708 | break; |
4709 | 4709 | case 'UNTIL': |
4710 | 4710 | $content2 .= ";UNTIL="; |
4711 | - $content2 .= $this->_format_date_time( $rulevalue ); |
|
4711 | + $content2 .= $this->_format_date_time($rulevalue); |
|
4712 | 4712 | break; |
4713 | 4713 | case 'COUNT': |
4714 | 4714 | case 'INTERVAL': |
@@ -4724,9 +4724,9 @@ discard block |
||
4724 | 4724 | case 'BYMONTH': |
4725 | 4725 | case 'BYSETPOS': |
4726 | 4726 | $content2 .= ";$rulelabel="; |
4727 | - if (is_array( $rulevalue )) { |
|
4728 | - foreach( $rulevalue as $vix => $valuePart ) { |
|
4729 | - $content2 .= ( $vix ) ? ',' : null; |
|
4727 | + if (is_array($rulevalue)) { |
|
4728 | + foreach ($rulevalue as $vix => $valuePart) { |
|
4729 | + $content2 .= ($vix) ? ',' : null; |
|
4730 | 4730 | $content2 .= $valuePart; |
4731 | 4731 | } |
4732 | 4732 | } else { |
@@ -4736,12 +4736,12 @@ discard block |
||
4736 | 4736 | case 'BYDAY': |
4737 | 4737 | $content2 .= ";$rulelabel="; |
4738 | 4738 | $bydaycnt = 0; |
4739 | - foreach( $rulevalue as $vix => $valuePart ) { |
|
4739 | + foreach ($rulevalue as $vix => $valuePart) { |
|
4740 | 4740 | $content21 = $content22 = null; |
4741 | - if( is_array( $valuePart )) { |
|
4742 | - $content2 .= ( $bydaycnt ) ? ',' : null; |
|
4743 | - foreach( $valuePart as $vix2 => $valuePart2 ) { |
|
4744 | - if( 'DAY' != strtoupper( $vix2 )) |
|
4741 | + if (is_array($valuePart)) { |
|
4742 | + $content2 .= ($bydaycnt) ? ',' : null; |
|
4743 | + foreach ($valuePart as $vix2 => $valuePart2) { |
|
4744 | + if ('DAY' != strtoupper($vix2)) |
|
4745 | 4745 | $content21 .= $valuePart2; |
4746 | 4746 | else |
4747 | 4747 | $content22 .= $valuePart2; |
@@ -4750,8 +4750,8 @@ discard block |
||
4750 | 4750 | $bydaycnt++; |
4751 | 4751 | } |
4752 | 4752 | else { |
4753 | - $content2 .= ( $bydaycnt ) ? ',' : null; |
|
4754 | - if( 'DAY' != strtoupper( $vix )) |
|
4753 | + $content2 .= ($bydaycnt) ? ',' : null; |
|
4754 | + if ('DAY' != strtoupper($vix)) |
|
4755 | 4755 | $content21 .= $valuePart; |
4756 | 4756 | else { |
4757 | 4757 | $content22 .= $valuePart; |
@@ -4766,7 +4766,7 @@ discard block |
||
4766 | 4766 | break; |
4767 | 4767 | } |
4768 | 4768 | } |
4769 | - $output .= $this->_createElement( $recurlabel, $attributes, $content1.$content2 ); |
|
4769 | + $output .= $this->_createElement($recurlabel, $attributes, $content1.$content2); |
|
4770 | 4770 | } |
4771 | 4771 | return $output; |
4772 | 4772 | } |
@@ -4778,13 +4778,13 @@ discard block |
||
4778 | 4778 | * @param string $propertyName |
4779 | 4779 | * @return string |
4780 | 4780 | */ |
4781 | - function _formatPropertyName( $propertyName ) { |
|
4782 | - switch( $this->format ) { |
|
4781 | + function _formatPropertyName($propertyName) { |
|
4782 | + switch ($this->format) { |
|
4783 | 4783 | case 'xcal': |
4784 | - return strtolower( $propertyName ); |
|
4784 | + return strtolower($propertyName); |
|
4785 | 4785 | break; |
4786 | 4786 | default: |
4787 | - return strtoupper( $propertyName ); |
|
4787 | + return strtoupper($propertyName); |
|
4788 | 4788 | break; |
4789 | 4789 | } |
4790 | 4790 | } |
@@ -4796,25 +4796,25 @@ discard block |
||
4796 | 4796 | * @param array $input |
4797 | 4797 | * @return bool |
4798 | 4798 | */ |
4799 | - function _isArrayDate( $input ) { |
|
4800 | - if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 )))) |
|
4799 | + function _isArrayDate($input) { |
|
4800 | + if (isset($input['week']) || (!in_array(count($input), array(3, 6, 7)))) |
|
4801 | 4801 | return FALSE; |
4802 | - if( 7 == count( $input )) |
|
4802 | + if (7 == count($input)) |
|
4803 | 4803 | return TRUE; |
4804 | - if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) |
|
4805 | - return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
4806 | - if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] )) |
|
4804 | + if (isset($input['year']) && isset($input['month']) && isset($input['day'])) |
|
4805 | + return checkdate((int) $input['month'], (int) $input['day'], (int) $input['year']); |
|
4806 | + if (isset($input['day']) || isset($input['hour']) || isset($input['min']) || isset($input['sec'])) |
|
4807 | 4807 | return FALSE; |
4808 | - if( in_array( 0, $input )) |
|
4808 | + if (in_array(0, $input)) |
|
4809 | 4809 | return FALSE; |
4810 | - if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] )) |
|
4810 | + if ((1970 > $input[0]) || (12 < $input[1]) || (31 < $input[2])) |
|
4811 | 4811 | return FALSE; |
4812 | - if(( isset( $input[0] ) && isset( $input[1] ) && isset( $input[2] )) && |
|
4813 | - checkdate( (int) $input[1], (int) $input[2], (int) $input[0] )) |
|
4812 | + if ((isset($input[0]) && isset($input[1]) && isset($input[2])) && |
|
4813 | + checkdate((int) $input[1], (int) $input[2], (int) $input[0])) |
|
4814 | 4814 | return TRUE; |
4815 | - $input = $this->_date_time_string( $input[1].'/'.$input[2].'/'.$input[0], 3 ); // m - d - Y |
|
4816 | - if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) |
|
4817 | - return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
4815 | + $input = $this->_date_time_string($input[1].'/'.$input[2].'/'.$input[0], 3); // m - d - Y |
|
4816 | + if (isset($input['year']) && isset($input['month']) && isset($input['day'])) |
|
4817 | + return checkdate((int) $input['month'], (int) $input['day'], (int) $input['year']); |
|
4818 | 4818 | return FALSE; |
4819 | 4819 | } |
4820 | 4820 | /** |
@@ -4825,8 +4825,8 @@ discard block |
||
4825 | 4825 | * @param array $input |
4826 | 4826 | * @return bool |
4827 | 4827 | */ |
4828 | - function _isArrayTimestampDate( $input ) { |
|
4829 | - return ( is_array( $input ) && isset( $input['timestamp'] )) ? TRUE : FALSE ; |
|
4828 | + function _isArrayTimestampDate($input) { |
|
4829 | + return (is_array($input) && isset($input['timestamp'])) ? TRUE : FALSE; |
|
4830 | 4830 | } |
4831 | 4831 | /** |
4832 | 4832 | * controll if input string contains traling UTC offset |
@@ -4836,17 +4836,17 @@ discard block |
||
4836 | 4836 | * @param string $input |
4837 | 4837 | * @return bool |
4838 | 4838 | */ |
4839 | - function _isOffset( $input ) { |
|
4840 | - $input = trim( (string) $input ); |
|
4841 | - if( 'Z' == substr( $input, -1 )) |
|
4839 | + function _isOffset($input) { |
|
4840 | + $input = trim((string) $input); |
|
4841 | + if ('Z' == substr($input, -1)) |
|
4842 | 4842 | return TRUE; |
4843 | - elseif(( 5 <= strlen( $input )) && |
|
4844 | - ( in_array( substr( $input, -5, 1 ), array( '+', '-' ))) && |
|
4845 | - ( '0000' < substr( $input, -4 )) && ( '9999' >= substr( $input, -4 ))) |
|
4843 | + elseif ((5 <= strlen($input)) && |
|
4844 | + (in_array(substr($input, -5, 1), array('+', '-'))) && |
|
4845 | + ('0000' < substr($input, -4)) && ('9999' >= substr($input, -4))) |
|
4846 | 4846 | return TRUE; |
4847 | - elseif(( 7 <= strlen( $input )) && |
|
4848 | - ( in_array( substr( $input, -7, 1 ), array( '+', '-' ))) && |
|
4849 | - ( '000000' < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 ))) |
|
4847 | + elseif ((7 <= strlen($input)) && |
|
4848 | + (in_array(substr($input, -7, 1), array('+', '-'))) && |
|
4849 | + ('000000' < substr($input, -6)) && ('999999' >= substr($input, -6))) |
|
4850 | 4850 | return TRUE; |
4851 | 4851 | return FALSE; |
4852 | 4852 | |
@@ -4859,15 +4859,15 @@ discard block |
||
4859 | 4859 | * @param string $propName |
4860 | 4860 | * @return bool |
4861 | 4861 | */ |
4862 | - function _notExistProp( $propName ) { |
|
4863 | - if( empty( $propName )) return FALSE; // when deleting x-prop, an empty propName may be used=allowed |
|
4864 | - $propName = strtolower( $propName ); |
|
4865 | - if( 'last-modified' == $propName ) { if( !isset( $this->lastmodified )) return TRUE; } |
|
4866 | - elseif( 'percent-complete' == $propName ) { if( !isset( $this->percentcomplete )) return TRUE; } |
|
4867 | - elseif( 'recurrence-id' == $propName ) { if( !isset( $this->recurrenceid )) return TRUE; } |
|
4868 | - elseif( 'related-to' == $propName ) { if( !isset( $this->relatedto )) return TRUE; } |
|
4869 | - elseif( 'request-status' == $propName ) { if( !isset( $this->requeststatus )) return TRUE; } |
|
4870 | - elseif(( 'x-' != substr($propName,0,2)) && !isset( $this->$propName )) return TRUE; |
|
4862 | + function _notExistProp($propName) { |
|
4863 | + if (empty($propName)) return FALSE; // when deleting x-prop, an empty propName may be used=allowed |
|
4864 | + $propName = strtolower($propName); |
|
4865 | + if ('last-modified' == $propName) { if (!isset($this->lastmodified)) return TRUE; } |
|
4866 | + elseif ('percent-complete' == $propName) { if (!isset($this->percentcomplete)) return TRUE; } |
|
4867 | + elseif ('recurrence-id' == $propName) { if (!isset($this->recurrenceid)) return TRUE; } |
|
4868 | + elseif ('related-to' == $propName) { if (!isset($this->relatedto)) return TRUE; } |
|
4869 | + elseif ('request-status' == $propName) { if (!isset($this->requeststatus)) return TRUE; } |
|
4870 | + elseif (('x-' != substr($propName, 0, 2)) && !isset($this->$propName)) return TRUE; |
|
4871 | 4871 | return FALSE; |
4872 | 4872 | } |
4873 | 4873 | /** |
@@ -4885,101 +4885,101 @@ discard block |
||
4885 | 4885 | * @return array of recurrence (start-)dates as index |
4886 | 4886 | * @todo BYHOUR, BYMINUTE, BYSECOND, ev. BYSETPOS due to ambiguity, WEEKLY at year end/start |
4887 | 4887 | */ |
4888 | - function _recur2date( & $result, $recur, $wdate, $startdate, $enddate=FALSE ) { |
|
4889 | - foreach( $wdate as $k => $v ) if( ctype_digit( $v )) $wdate[$k] = (int) $v; |
|
4890 | - $wdatets = $this->_date2timestamp( $wdate ); |
|
4891 | - $startdatets = $this->_date2timestamp( $startdate ); |
|
4892 | - if( !$enddate ) { |
|
4888 | + function _recur2date(& $result, $recur, $wdate, $startdate, $enddate = FALSE) { |
|
4889 | + foreach ($wdate as $k => $v) if (ctype_digit($v)) $wdate[$k] = (int) $v; |
|
4890 | + $wdatets = $this->_date2timestamp($wdate); |
|
4891 | + $startdatets = $this->_date2timestamp($startdate); |
|
4892 | + if (!$enddate) { |
|
4893 | 4893 | $enddate = $startdate; |
4894 | 4894 | $enddate['year'] += 1; |
4895 | 4895 | // echo "recur __in_ ".implode('-',$startdate)." period start ".implode('-',$wdate)." period end ".implode('-',$enddate)."<br />\n";print_r($recur);echo "<br />\n";//test### |
4896 | 4896 | } |
4897 | - $endDatets = $this->_date2timestamp( $enddate ); // fix break |
|
4898 | - if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] )) |
|
4897 | + $endDatets = $this->_date2timestamp($enddate); // fix break |
|
4898 | + if (!isset($recur['COUNT']) && !isset($recur['UNTIL'])) |
|
4899 | 4899 | $recur['UNTIL'] = $enddate; // create break |
4900 | - if( isset( $recur['UNTIL'] )) { |
|
4901 | - $tdatets = $this->_date2timestamp( $recur['UNTIL'] ); |
|
4902 | - if( $endDatets > $tdatets ) { |
|
4900 | + if (isset($recur['UNTIL'])) { |
|
4901 | + $tdatets = $this->_date2timestamp($recur['UNTIL']); |
|
4902 | + if ($endDatets > $tdatets) { |
|
4903 | 4903 | $endDatets = $tdatets; // emergency break |
4904 | - $enddate = $this->_timestamp2date( $endDatets, 6 ); |
|
4904 | + $enddate = $this->_timestamp2date($endDatets, 6); |
|
4905 | 4905 | } |
4906 | 4906 | else |
4907 | - $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 ); |
|
4907 | + $recur['UNTIL'] = $this->_timestamp2date($endDatets, 6); |
|
4908 | 4908 | } |
4909 | - if( $wdatets > $endDatets ) { |
|
4909 | + if ($wdatets > $endDatets) { |
|
4910 | 4910 | //echo "recur out of date ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test |
4911 | 4911 | return array(); // nothing to do.. . |
4912 | 4912 | } |
4913 | - if( !isset( $recur['FREQ'] )) // "MUST be specified.. ." |
|
4913 | + if (!isset($recur['FREQ'])) // "MUST be specified.. ." |
|
4914 | 4914 | $recur['FREQ'] = 'DAILY'; // ?? |
4915 | - $wkst = ( isset( $recur['WKST'] ) && ( 'SU' == $recur['WKST'] )) ? 24*60*60 : 0; // ?? |
|
4916 | - if( !isset( $recur['INTERVAL'] )) |
|
4915 | + $wkst = (isset($recur['WKST']) && ('SU' == $recur['WKST'])) ? 24 * 60 * 60 : 0; // ?? |
|
4916 | + if (!isset($recur['INTERVAL'])) |
|
4917 | 4917 | $recur['INTERVAL'] = 1; |
4918 | - $countcnt = ( !isset( $recur['BYSETPOS'] )) ? 1 : 0; // DTSTART counts as the first occurrence |
|
4918 | + $countcnt = (!isset($recur['BYSETPOS'])) ? 1 : 0; // DTSTART counts as the first occurrence |
|
4919 | 4919 | /* find out how to step up dates and set index for interval count */ |
4920 | 4920 | $step = array(); |
4921 | - if( 'YEARLY' == $recur['FREQ'] ) |
|
4921 | + if ('YEARLY' == $recur['FREQ']) |
|
4922 | 4922 | $step['year'] = 1; |
4923 | - elseif( 'MONTHLY' == $recur['FREQ'] ) |
|
4923 | + elseif ('MONTHLY' == $recur['FREQ']) |
|
4924 | 4924 | $step['month'] = 1; |
4925 | - elseif( 'WEEKLY' == $recur['FREQ'] ) |
|
4925 | + elseif ('WEEKLY' == $recur['FREQ']) |
|
4926 | 4926 | $step['day'] = 7; |
4927 | 4927 | else |
4928 | 4928 | $step['day'] = 1; |
4929 | - if( isset( $step['year'] ) && isset( $recur['BYMONTH'] )) |
|
4930 | - $step = array( 'month' => 1 ); |
|
4931 | - if( empty( $step ) && isset( $recur['BYWEEKNO'] )) // ?? |
|
4932 | - $step = array( 'day' => 7 ); |
|
4933 | - if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] )) |
|
4934 | - $step = array( 'day' => 1 ); |
|
4929 | + if (isset($step['year']) && isset($recur['BYMONTH'])) |
|
4930 | + $step = array('month' => 1); |
|
4931 | + if (empty($step) && isset($recur['BYWEEKNO'])) // ?? |
|
4932 | + $step = array('day' => 7); |
|
4933 | + if (isset($recur['BYYEARDAY']) || isset($recur['BYMONTHDAY']) || isset($recur['BYDAY'])) |
|
4934 | + $step = array('day' => 1); |
|
4935 | 4935 | $intervalarr = array(); |
4936 | - if( 1 < $recur['INTERVAL'] ) { |
|
4937 | - $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst ); |
|
4938 | - $intervalarr = array( $intervalix => 0 ); |
|
4936 | + if (1 < $recur['INTERVAL']) { |
|
4937 | + $intervalix = $this->_recurIntervalIx($recur['FREQ'], $wdate, $wkst); |
|
4938 | + $intervalarr = array($intervalix => 0); |
|
4939 | 4939 | } |
4940 | - if( isset( $recur['BYSETPOS'] )) { // save start date + weekno |
|
4940 | + if (isset($recur['BYSETPOS'])) { // save start date + weekno |
|
4941 | 4941 | $bysetposymd1 = $bysetposymd2 = $bysetposw1 = $bysetposw2 = array(); |
4942 | - $bysetposWold = (int) date( 'W', ( $wdatets + $wkst )); |
|
4942 | + $bysetposWold = (int) date('W', ($wdatets + $wkst)); |
|
4943 | 4943 | $bysetposYold = $wdate['year']; |
4944 | 4944 | $bysetposMold = $wdate['month']; |
4945 | 4945 | $bysetposDold = $wdate['day']; |
4946 | - if( is_array( $recur['BYSETPOS'] )) { |
|
4947 | - foreach( $recur['BYSETPOS'] as $bix => $bval ) |
|
4946 | + if (is_array($recur['BYSETPOS'])) { |
|
4947 | + foreach ($recur['BYSETPOS'] as $bix => $bval) |
|
4948 | 4948 | $recur['BYSETPOS'][$bix] = (int) $bval; |
4949 | 4949 | } |
4950 | 4950 | else |
4951 | - $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] ); |
|
4952 | - $this->_stepdate( $enddate, $endDatets, $step); // make sure to count whole last period |
|
4951 | + $recur['BYSETPOS'] = array((int) $recur['BYSETPOS']); |
|
4952 | + $this->_stepdate($enddate, $endDatets, $step); // make sure to count whole last period |
|
4953 | 4953 | } |
4954 | - $this->_stepdate( $wdate, $wdatets, $step); |
|
4954 | + $this->_stepdate($wdate, $wdatets, $step); |
|
4955 | 4955 | $year_old = null; |
4956 | - $daynames = array( 'SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA' ); |
|
4956 | + $daynames = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'); |
|
4957 | 4957 | /* MAIN LOOP */ |
4958 | 4958 | // echo "recur start ".implode('-',$wdate)." end ".implode('-',$enddate)."<br />\n";//test |
4959 | - while( TRUE ) { |
|
4960 | - if( isset( $endDatets ) && ( $wdatets > $endDatets )) |
|
4959 | + while (TRUE) { |
|
4960 | + if (isset($endDatets) && ($wdatets > $endDatets)) |
|
4961 | 4961 | break; |
4962 | - if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) |
|
4962 | + if (isset($recur['COUNT']) && ($countcnt >= $recur['COUNT'])) |
|
4963 | 4963 | break; |
4964 | - if( $year_old != $wdate['year'] ) { |
|
4964 | + if ($year_old != $wdate['year']) { |
|
4965 | 4965 | $year_old = $wdate['year']; |
4966 | 4966 | $daycnts = array(); |
4967 | 4967 | $yeardays = $weekno = 0; |
4968 | 4968 | $yeardaycnt = array(); |
4969 | - for( $m = 1; $m <= 12; $m++ ) { // count up and update up-counters |
|
4969 | + for ($m = 1; $m <= 12; $m++) { // count up and update up-counters |
|
4970 | 4970 | $daycnts[$m] = array(); |
4971 | 4971 | $weekdaycnt = array(); |
4972 | - foreach( $daynames as $dn ) |
|
4972 | + foreach ($daynames as $dn) |
|
4973 | 4973 | $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
4974 | - $mcnt = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] )); |
|
4975 | - for( $d = 1; $d <= $mcnt; $d++ ) { |
|
4974 | + $mcnt = date('t', mktime(0, 0, 0, $m, 1, $wdate['year'])); |
|
4975 | + for ($d = 1; $d <= $mcnt; $d++) { |
|
4976 | 4976 | $daycnts[$m][$d] = array(); |
4977 | - if( isset( $recur['BYYEARDAY'] )) { |
|
4977 | + if (isset($recur['BYYEARDAY'])) { |
|
4978 | 4978 | $yeardays++; |
4979 | 4979 | $daycnts[$m][$d]['yearcnt_up'] = $yeardays; |
4980 | 4980 | } |
4981 | - if( isset( $recur['BYDAY'] )) { |
|
4982 | - $day = date( 'w', mktime( 0, 0, 0, $m, $d, $wdate['year'] )); |
|
4981 | + if (isset($recur['BYDAY'])) { |
|
4982 | + $day = date('w', mktime(0, 0, 0, $m, $d, $wdate['year'])); |
|
4983 | 4983 | $day = $daynames[$day]; |
4984 | 4984 | $daycnts[$m][$d]['DAY'] = $day; |
4985 | 4985 | $weekdaycnt[$day]++; |
@@ -4987,64 +4987,64 @@ discard block |
||
4987 | 4987 | $yeardaycnt[$day]++; |
4988 | 4988 | $daycnts[$m][$d]['yeardayno_up'] = $yeardaycnt[$day]; |
4989 | 4989 | } |
4990 | - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) |
|
4991 | - $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year'])); |
|
4990 | + if (isset($recur['BYWEEKNO']) || ($recur['FREQ'] == 'WEEKLY')) |
|
4991 | + $daycnts[$m][$d]['weekno_up'] = (int) date('W', mktime(0, 0, $wkst, $m, $d, $wdate['year'])); |
|
4992 | 4992 | } |
4993 | 4993 | } |
4994 | 4994 | $daycnt = 0; |
4995 | 4995 | $yeardaycnt = array(); |
4996 | - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) { |
|
4996 | + if (isset($recur['BYWEEKNO']) || ($recur['FREQ'] == 'WEEKLY')) { |
|
4997 | 4997 | $weekno = null; |
4998 | - for( $d=31; $d > 25; $d-- ) { // get last weekno for year |
|
4999 | - if( !$weekno ) |
|
4998 | + for ($d = 31; $d > 25; $d--) { // get last weekno for year |
|
4999 | + if (!$weekno) |
|
5000 | 5000 | $weekno = $daycnts[12][$d]['weekno_up']; |
5001 | - elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) { |
|
5001 | + elseif ($weekno < $daycnts[12][$d]['weekno_up']) { |
|
5002 | 5002 | $weekno = $daycnts[12][$d]['weekno_up']; |
5003 | 5003 | break; |
5004 | 5004 | } |
5005 | 5005 | } |
5006 | 5006 | } |
5007 | - for( $m = 12; $m > 0; $m-- ) { // count down and update down-counters |
|
5007 | + for ($m = 12; $m > 0; $m--) { // count down and update down-counters |
|
5008 | 5008 | $weekdaycnt = array(); |
5009 | - foreach( $daynames as $dn ) |
|
5009 | + foreach ($daynames as $dn) |
|
5010 | 5010 | $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
5011 | 5011 | $monthcnt = 0; |
5012 | - $mcnt = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] )); |
|
5013 | - for( $d = $mcnt; $d > 0; $d-- ) { |
|
5014 | - if( isset( $recur['BYYEARDAY'] )) { |
|
5012 | + $mcnt = date('t', mktime(0, 0, 0, $m, 1, $wdate['year'])); |
|
5013 | + for ($d = $mcnt; $d > 0; $d--) { |
|
5014 | + if (isset($recur['BYYEARDAY'])) { |
|
5015 | 5015 | $daycnt -= 1; |
5016 | 5016 | $daycnts[$m][$d]['yearcnt_down'] = $daycnt; |
5017 | 5017 | } |
5018 | - if( isset( $recur['BYMONTHDAY'] )) { |
|
5018 | + if (isset($recur['BYMONTHDAY'])) { |
|
5019 | 5019 | $monthcnt -= 1; |
5020 | 5020 | $daycnts[$m][$d]['monthcnt_down'] = $monthcnt; |
5021 | 5021 | } |
5022 | - if( isset( $recur['BYDAY'] )) { |
|
5023 | - $day = $daycnts[$m][$d]['DAY']; |
|
5022 | + if (isset($recur['BYDAY'])) { |
|
5023 | + $day = $daycnts[$m][$d]['DAY']; |
|
5024 | 5024 | $weekdaycnt[$day] -= 1; |
5025 | 5025 | $daycnts[$m][$d]['monthdayno_down'] = $weekdaycnt[$day]; |
5026 | 5026 | $yeardaycnt[$day] -= 1; |
5027 | 5027 | $daycnts[$m][$d]['yeardayno_down'] = $yeardaycnt[$day]; |
5028 | 5028 | } |
5029 | - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) |
|
5029 | + if (isset($recur['BYWEEKNO']) || ($recur['FREQ'] == 'WEEKLY')) |
|
5030 | 5030 | $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1); |
5031 | 5031 | } |
5032 | 5032 | } |
5033 | 5033 | } |
5034 | 5034 | /* check interval */ |
5035 | - if( 1 < $recur['INTERVAL'] ) { |
|
5035 | + if (1 < $recur['INTERVAL']) { |
|
5036 | 5036 | /* create interval index */ |
5037 | - $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst ); |
|
5037 | + $intervalix = $this->_recurIntervalIx($recur['FREQ'], $wdate, $wkst); |
|
5038 | 5038 | /* check interval */ |
5039 | - $currentKey = array_keys( $intervalarr ); |
|
5040 | - $currentKey = end( $currentKey ); // get last index |
|
5041 | - if( $currentKey != $intervalix ) |
|
5042 | - $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 )); |
|
5043 | - if(( $recur['INTERVAL'] != $intervalarr[$intervalix] ) && |
|
5044 | - ( 0 != $intervalarr[$intervalix] )) { |
|
5039 | + $currentKey = array_keys($intervalarr); |
|
5040 | + $currentKey = end($currentKey); // get last index |
|
5041 | + if ($currentKey != $intervalix) |
|
5042 | + $intervalarr = array($intervalix => ($intervalarr[$currentKey] + 1)); |
|
5043 | + if (($recur['INTERVAL'] != $intervalarr[$intervalix]) && |
|
5044 | + (0 != $intervalarr[$intervalix])) { |
|
5045 | 5045 | /* step up date */ |
5046 | 5046 | //echo "skip: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test |
5047 | - $this->_stepdate( $wdate, $wdatets, $step); |
|
5047 | + $this->_stepdate($wdate, $wdatets, $step); |
|
5048 | 5048 | continue; |
5049 | 5049 | } |
5050 | 5050 | else // continue within the selected interval |
@@ -5052,69 +5052,69 @@ discard block |
||
5052 | 5052 | //echo "cont: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test |
5053 | 5053 | } |
5054 | 5054 | $updateOK = TRUE; |
5055 | - if( $updateOK && isset( $recur['BYMONTH'] )) |
|
5056 | - $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH'] |
|
5055 | + if ($updateOK && isset($recur['BYMONTH'])) |
|
5056 | + $updateOK = $this->_recurBYcntcheck($recur['BYMONTH'] |
|
5057 | 5057 | , $wdate['month'] |
5058 | 5058 | ,($wdate['month'] - 13)); |
5059 | - if( $updateOK && isset( $recur['BYWEEKNO'] )) |
|
5060 | - $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO'] |
|
5059 | + if ($updateOK && isset($recur['BYWEEKNO'])) |
|
5060 | + $updateOK = $this->_recurBYcntcheck($recur['BYWEEKNO'] |
|
5061 | 5061 | , $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] |
5062 | - , $daycnts[$wdate['month']][$wdate['day']]['weekno_down'] ); |
|
5063 | - if( $updateOK && isset( $recur['BYYEARDAY'] )) |
|
5064 | - $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY'] |
|
5062 | + , $daycnts[$wdate['month']][$wdate['day']]['weekno_down']); |
|
5063 | + if ($updateOK && isset($recur['BYYEARDAY'])) |
|
5064 | + $updateOK = $this->_recurBYcntcheck($recur['BYYEARDAY'] |
|
5065 | 5065 | , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_up'] |
5066 | - , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down'] ); |
|
5067 | - if( $updateOK && isset( $recur['BYMONTHDAY'] )) |
|
5068 | - $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY'] |
|
5066 | + , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down']); |
|
5067 | + if ($updateOK && isset($recur['BYMONTHDAY'])) |
|
5068 | + $updateOK = $this->_recurBYcntcheck($recur['BYMONTHDAY'] |
|
5069 | 5069 | , $wdate['day'] |
5070 | - , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down'] ); |
|
5070 | + , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down']); |
|
5071 | 5071 | //echo "efter BYMONTHDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n";//test### |
5072 | - if( $updateOK && isset( $recur['BYDAY'] )) { |
|
5072 | + if ($updateOK && isset($recur['BYDAY'])) { |
|
5073 | 5073 | $updateOK = FALSE; |
5074 | 5074 | $m = $wdate['month']; |
5075 | 5075 | $d = $wdate['day']; |
5076 | - if( isset( $recur['BYDAY']['DAY'] )) { // single day, opt with year/month day order no |
|
5077 | - $daynoexists = $daynosw = $daynamesw = FALSE; |
|
5078 | - if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] ) |
|
5076 | + if (isset($recur['BYDAY']['DAY'])) { // single day, opt with year/month day order no |
|
5077 | + $daynoexists = $daynosw = $daynamesw = FALSE; |
|
5078 | + if ($recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY']) |
|
5079 | 5079 | $daynamesw = TRUE; |
5080 | - if( isset( $recur['BYDAY'][0] )) { |
|
5080 | + if (isset($recur['BYDAY'][0])) { |
|
5081 | 5081 | $daynoexists = TRUE; |
5082 | - if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] )) |
|
5083 | - $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5082 | + if ((isset($recur['FREQ']) && ($recur['FREQ'] == 'MONTHLY')) || isset($recur['BYMONTH'])) |
|
5083 | + $daynosw = $this->_recurBYcntcheck($recur['BYDAY'][0] |
|
5084 | 5084 | , $daycnts[$m][$d]['monthdayno_up'] |
5085 | - , $daycnts[$m][$d]['monthdayno_down'] ); |
|
5086 | - elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) |
|
5087 | - $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5085 | + , $daycnts[$m][$d]['monthdayno_down']); |
|
5086 | + elseif (isset($recur['FREQ']) && ($recur['FREQ'] == 'YEARLY')) |
|
5087 | + $daynosw = $this->_recurBYcntcheck($recur['BYDAY'][0] |
|
5088 | 5088 | , $daycnts[$m][$d]['yeardayno_up'] |
5089 | - , $daycnts[$m][$d]['yeardayno_down'] ); |
|
5089 | + , $daycnts[$m][$d]['yeardayno_down']); |
|
5090 | 5090 | } |
5091 | - if(( $daynoexists && $daynosw && $daynamesw ) || |
|
5092 | - ( !$daynoexists && !$daynosw && $daynamesw )) { |
|
5091 | + if (($daynoexists && $daynosw && $daynamesw) || |
|
5092 | + (!$daynoexists && !$daynosw && $daynamesw)) { |
|
5093 | 5093 | $updateOK = TRUE; |
5094 | 5094 | } |
5095 | 5095 | //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ### |
5096 | 5096 | } |
5097 | 5097 | else { |
5098 | - foreach( $recur['BYDAY'] as $bydayvalue ) { |
|
5098 | + foreach ($recur['BYDAY'] as $bydayvalue) { |
|
5099 | 5099 | $daynoexists = $daynosw = $daynamesw = FALSE; |
5100 | - if( isset( $bydayvalue['DAY'] ) && |
|
5101 | - ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] )) |
|
5100 | + if (isset($bydayvalue['DAY']) && |
|
5101 | + ($bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'])) |
|
5102 | 5102 | $daynamesw = TRUE; |
5103 | - if( isset( $bydayvalue[0] )) { |
|
5103 | + if (isset($bydayvalue[0])) { |
|
5104 | 5104 | $daynoexists = TRUE; |
5105 | - if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || |
|
5106 | - isset( $recur['BYMONTH'] )) |
|
5107 | - $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5105 | + if ((isset($recur['FREQ']) && ($recur['FREQ'] == 'MONTHLY')) || |
|
5106 | + isset($recur['BYMONTH'])) |
|
5107 | + $daynosw = $this->_recurBYcntcheck($bydayvalue['0'] |
|
5108 | 5108 | , $daycnts[$m][$d]['monthdayno_up'] |
5109 | - , $daycnts[$m][$d]['monthdayno_down'] ); |
|
5110 | - elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) |
|
5111 | - $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5109 | + , $daycnts[$m][$d]['monthdayno_down']); |
|
5110 | + elseif (isset($recur['FREQ']) && ($recur['FREQ'] == 'YEARLY')) |
|
5111 | + $daynosw = $this->_recurBYcntcheck($bydayvalue['0'] |
|
5112 | 5112 | , $daycnts[$m][$d]['yeardayno_up'] |
5113 | - , $daycnts[$m][$d]['yeardayno_down'] ); |
|
5113 | + , $daycnts[$m][$d]['yeardayno_down']); |
|
5114 | 5114 | } |
5115 | 5115 | //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ### |
5116 | - if(( $daynoexists && $daynosw && $daynamesw ) || |
|
5117 | - ( !$daynoexists && !$daynosw && $daynamesw )) { |
|
5116 | + if (($daynoexists && $daynosw && $daynamesw) || |
|
5117 | + (!$daynoexists && !$daynosw && $daynamesw)) { |
|
5118 | 5118 | $updateOK = TRUE; |
5119 | 5119 | break; |
5120 | 5120 | } |
@@ -5123,25 +5123,25 @@ discard block |
||
5123 | 5123 | } |
5124 | 5124 | //echo "efter BYDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n"; // test ### |
5125 | 5125 | /* check BYSETPOS */ |
5126 | - if( $updateOK ) { |
|
5127 | - if( isset( $recur['BYSETPOS'] ) && |
|
5128 | - ( in_array( $recur['FREQ'], array( 'YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY' )))) { |
|
5129 | - if( isset( $recur['WEEKLY'] )) { |
|
5130 | - if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] ) |
|
5126 | + if ($updateOK) { |
|
5127 | + if (isset($recur['BYSETPOS']) && |
|
5128 | + (in_array($recur['FREQ'], array('YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY')))) { |
|
5129 | + if (isset($recur['WEEKLY'])) { |
|
5130 | + if ($bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up']) |
|
5131 | 5131 | $bysetposw1[] = $wdatets; |
5132 | 5132 | else |
5133 | 5133 | $bysetposw2[] = $wdatets; |
5134 | 5134 | } |
5135 | 5135 | else { |
5136 | - if(( isset( $recur['FREQ'] ) && ( 'YEARLY' == $recur['FREQ'] ) && |
|
5137 | - ( $bysetposYold == $wdate['year'] )) || |
|
5138 | - ( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] ) && |
|
5139 | - (( $bysetposYold == $wdate['year'] ) && |
|
5140 | - ( $bysetposMold == $wdate['month'] ))) || |
|
5141 | - ( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] ) && |
|
5142 | - (( $bysetposYold == $wdate['year'] ) && |
|
5143 | - ( $bysetposMold == $wdate['month']) && |
|
5144 | - ( $bysetposDold == $wdate['sday'] )))) |
|
5136 | + if ((isset($recur['FREQ']) && ('YEARLY' == $recur['FREQ']) && |
|
5137 | + ($bysetposYold == $wdate['year'])) || |
|
5138 | + (isset($recur['FREQ']) && ('MONTHLY' == $recur['FREQ']) && |
|
5139 | + (($bysetposYold == $wdate['year']) && |
|
5140 | + ($bysetposMold == $wdate['month']))) || |
|
5141 | + (isset($recur['FREQ']) && ('MONTHLY' == $recur['FREQ']) && |
|
5142 | + (($bysetposYold == $wdate['year']) && |
|
5143 | + ($bysetposMold == $wdate['month']) && |
|
5144 | + ($bysetposDold == $wdate['sday'])))) |
|
5145 | 5145 | $bysetposymd1[] = $wdatets; |
5146 | 5146 | else |
5147 | 5147 | $bysetposymd2[] = $wdatets; |
@@ -5150,7 +5150,7 @@ discard block |
||
5150 | 5150 | else { |
5151 | 5151 | /* update result array if BYSETPOS is set */ |
5152 | 5152 | $countcnt++; |
5153 | - if( $startdatets <= $wdatets ) { // only output within period |
|
5153 | + if ($startdatets <= $wdatets) { // only output within period |
|
5154 | 5154 | $result[$wdatets] = TRUE; |
5155 | 5155 | //echo "recur ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test |
5156 | 5156 | } |
@@ -5159,39 +5159,39 @@ discard block |
||
5159 | 5159 | } |
5160 | 5160 | } |
5161 | 5161 | /* step up date */ |
5162 | - $this->_stepdate( $wdate, $wdatets, $step); |
|
5162 | + $this->_stepdate($wdate, $wdatets, $step); |
|
5163 | 5163 | /* check if BYSETPOS is set for updating result array */ |
5164 | - if( $updateOK && isset( $recur['BYSETPOS'] )) { |
|
5165 | - $bysetpos = FALSE; |
|
5166 | - if( isset( $recur['FREQ'] ) && ( 'YEARLY' == $recur['FREQ'] ) && |
|
5167 | - ( $bysetposYold != $wdate['year'] )) { |
|
5164 | + if ($updateOK && isset($recur['BYSETPOS'])) { |
|
5165 | + $bysetpos = FALSE; |
|
5166 | + if (isset($recur['FREQ']) && ('YEARLY' == $recur['FREQ']) && |
|
5167 | + ($bysetposYold != $wdate['year'])) { |
|
5168 | 5168 | $bysetpos = TRUE; |
5169 | 5169 | $bysetposYold = $wdate['year']; |
5170 | 5170 | } |
5171 | - elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] && |
|
5172 | - (( $bysetposYold != $wdate['year'] ) || ( $bysetposMold != $wdate['month'] )))) { |
|
5171 | + elseif (isset($recur['FREQ']) && ('MONTHLY' == $recur['FREQ'] && |
|
5172 | + (($bysetposYold != $wdate['year']) || ($bysetposMold != $wdate['month'])))) { |
|
5173 | 5173 | $bysetpos = TRUE; |
5174 | 5174 | $bysetposYold = $wdate['year']; |
5175 | 5175 | $bysetposMold = $wdate['month']; |
5176 | 5176 | } |
5177 | - elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY' == $recur['FREQ'] )) { |
|
5178 | - $weekno = (int) date( 'W', mktime( 0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year'])); |
|
5179 | - if( $bysetposWold != $weekno ) { |
|
5177 | + elseif (isset($recur['FREQ']) && ('WEEKLY' == $recur['FREQ'])) { |
|
5178 | + $weekno = (int) date('W', mktime(0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year'])); |
|
5179 | + if ($bysetposWold != $weekno) { |
|
5180 | 5180 | $bysetposWold = $weekno; |
5181 | 5181 | $bysetpos = TRUE; |
5182 | 5182 | } |
5183 | 5183 | } |
5184 | - elseif( isset( $recur['FREQ'] ) && ( 'DAILY' == $recur['FREQ'] ) && |
|
5185 | - (( $bysetposYold != $wdate['year'] ) || |
|
5186 | - ( $bysetposMold != $wdate['month'] ) || |
|
5187 | - ( $bysetposDold != $wdate['sday'] ))) { |
|
5184 | + elseif (isset($recur['FREQ']) && ('DAILY' == $recur['FREQ']) && |
|
5185 | + (($bysetposYold != $wdate['year']) || |
|
5186 | + ($bysetposMold != $wdate['month']) || |
|
5187 | + ($bysetposDold != $wdate['sday']))) { |
|
5188 | 5188 | $bysetpos = TRUE; |
5189 | 5189 | $bysetposYold = $wdate['year']; |
5190 | 5190 | $bysetposMold = $wdate['month']; |
5191 | 5191 | $bysetposDold = $wdate['day']; |
5192 | 5192 | } |
5193 | - if( $bysetpos ) { |
|
5194 | - if( isset( $recur['BYWEEKNO'] )) { |
|
5193 | + if ($bysetpos) { |
|
5194 | + if (isset($recur['BYWEEKNO'])) { |
|
5195 | 5195 | $bysetposarr1 = & $bysetposw1; |
5196 | 5196 | $bysetposarr2 = & $bysetposw2; |
5197 | 5197 | } |
@@ -5199,18 +5199,18 @@ discard block |
||
5199 | 5199 | $bysetposarr1 = & $bysetposymd1; |
5200 | 5200 | $bysetposarr2 = & $bysetposymd2; |
5201 | 5201 | } |
5202 | - foreach( $recur['BYSETPOS'] as $ix ) { |
|
5203 | - if( 0 > $ix ) // both positive and negative BYSETPOS allowed |
|
5204 | - $ix = ( count( $bysetposarr1 ) + $ix + 1); |
|
5202 | + foreach ($recur['BYSETPOS'] as $ix) { |
|
5203 | + if (0 > $ix) // both positive and negative BYSETPOS allowed |
|
5204 | + $ix = (count($bysetposarr1) + $ix + 1); |
|
5205 | 5205 | $ix--; |
5206 | - if( isset( $bysetposarr1[$ix] )) { |
|
5207 | - if( $startdatets <= $bysetposarr1[$ix] ) { // only output within period |
|
5206 | + if (isset($bysetposarr1[$ix])) { |
|
5207 | + if ($startdatets <= $bysetposarr1[$ix]) { // only output within period |
|
5208 | 5208 | $result[$bysetposarr1[$ix]] = TRUE; |
5209 | 5209 | //echo "recur ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$bysetposarr1[$ix]),6))."<br />\n";//test |
5210 | 5210 | } |
5211 | 5211 | $countcnt++; |
5212 | 5212 | } |
5213 | - if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) |
|
5213 | + if (isset($recur['COUNT']) && ($countcnt >= $recur['COUNT'])) |
|
5214 | 5214 | break; |
5215 | 5215 | } |
5216 | 5216 | $bysetposarr1 = $bysetposarr2; |
@@ -5219,18 +5219,18 @@ discard block |
||
5219 | 5219 | } |
5220 | 5220 | } |
5221 | 5221 | } |
5222 | - function _recurBYcntcheck( $BYvalue, $upValue, $downValue ) { |
|
5223 | - if( is_array( $BYvalue ) && |
|
5224 | - ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue ))) |
|
5222 | + function _recurBYcntcheck($BYvalue, $upValue, $downValue) { |
|
5223 | + if (is_array($BYvalue) && |
|
5224 | + (in_array($upValue, $BYvalue) || in_array($downValue, $BYvalue))) |
|
5225 | 5225 | return TRUE; |
5226 | - elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue )) |
|
5226 | + elseif (($BYvalue == $upValue) || ($BYvalue == $downValue)) |
|
5227 | 5227 | return TRUE; |
5228 | 5228 | else |
5229 | 5229 | return FALSE; |
5230 | 5230 | } |
5231 | - function _recurIntervalIx( $freq, $date, $wkst ) { |
|
5231 | + function _recurIntervalIx($freq, $date, $wkst) { |
|
5232 | 5232 | /* create interval index */ |
5233 | - switch( $freq ) { |
|
5233 | + switch ($freq) { |
|
5234 | 5234 | case 'YEARLY': |
5235 | 5235 | $intervalix = $date['year']; |
5236 | 5236 | break; |
@@ -5238,8 +5238,8 @@ discard block |
||
5238 | 5238 | $intervalix = $date['year'].'-'.$date['month']; |
5239 | 5239 | break; |
5240 | 5240 | case 'WEEKLY': |
5241 | - $wdatets = $this->_date2timestamp( $date ); |
|
5242 | - $intervalix = (int) date( 'W', ( $wdatets + $wkst )); |
|
5241 | + $wdatets = $this->_date2timestamp($date); |
|
5242 | + $intervalix = (int) date('W', ($wdatets + $wkst)); |
|
5243 | 5243 | break; |
5244 | 5244 | case 'DAILY': |
5245 | 5245 | default: |
@@ -5256,22 +5256,22 @@ discard block |
||
5256 | 5256 | * @param array $rexrule |
5257 | 5257 | * @return array |
5258 | 5258 | */ |
5259 | - function _setRexrule( $rexrule ) { |
|
5260 | - $input = array(); |
|
5261 | - if( empty( $rexrule )) |
|
5259 | + function _setRexrule($rexrule) { |
|
5260 | + $input = array(); |
|
5261 | + if (empty($rexrule)) |
|
5262 | 5262 | return $input; |
5263 | - foreach( $rexrule as $rexrulelabel => $rexrulevalue ) { |
|
5264 | - $rexrulelabel = strtoupper( $rexrulelabel ); |
|
5265 | - if( 'UNTIL' != $rexrulelabel ) |
|
5266 | - $input[$rexrulelabel] = $rexrulevalue; |
|
5263 | + foreach ($rexrule as $rexrulelabel => $rexrulevalue) { |
|
5264 | + $rexrulelabel = strtoupper($rexrulelabel); |
|
5265 | + if ('UNTIL' != $rexrulelabel) |
|
5266 | + $input[$rexrulelabel] = $rexrulevalue; |
|
5267 | 5267 | else { |
5268 | - if( $this->_isArrayTimestampDate( $rexrulevalue )) // timestamp date |
|
5269 | - $input[$rexrulelabel] = $this->_timestamp2date( $rexrulevalue, 6 ); |
|
5270 | - elseif( $this->_isArrayDate( $rexrulevalue )) // date-time |
|
5271 | - $input[$rexrulelabel] = $this->_date_time_array( $rexrulevalue, 6 ); |
|
5272 | - elseif( 8 <= strlen( trim( $rexrulevalue ))) // ex. 2006-08-03 10:12:18 |
|
5273 | - $input[$rexrulelabel] = $this->_date_time_string( $rexrulevalue ); |
|
5274 | - if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] )) |
|
5268 | + if ($this->_isArrayTimestampDate($rexrulevalue)) // timestamp date |
|
5269 | + $input[$rexrulelabel] = $this->_timestamp2date($rexrulevalue, 6); |
|
5270 | + elseif ($this->_isArrayDate($rexrulevalue)) // date-time |
|
5271 | + $input[$rexrulelabel] = $this->_date_time_array($rexrulevalue, 6); |
|
5272 | + elseif (8 <= strlen(trim($rexrulevalue))) // ex. 2006-08-03 10:12:18 |
|
5273 | + $input[$rexrulelabel] = $this->_date_time_string($rexrulevalue); |
|
5274 | + if ((3 < count($input[$rexrulelabel])) && !isset($input[$rexrulelabel]['tz'])) |
|
5275 | 5275 | $input[$rexrulelabel]['tz'] = 'Z'; |
5276 | 5276 | } |
5277 | 5277 | } |
@@ -5292,85 +5292,85 @@ discard block |
||
5292 | 5292 | * @param string $caller optional |
5293 | 5293 | * @return array |
5294 | 5294 | */ |
5295 | - function _setDate( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE, $caller=null ) { |
|
5295 | + function _setDate($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE, $caller = null) { |
|
5296 | 5296 | $input = $parno = null; |
5297 | - $localtime = (( 'dtstart' == $caller ) && in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE; |
|
5298 | - if( $this->_isArrayDate( $year )) { |
|
5299 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5300 | - $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
|
5301 | - if( isset( $input['params']['TZID'] )) { |
|
5297 | + $localtime = (('dtstart' == $caller) && in_array($this->objName, array('vtimezone', 'standard', 'daylight'))) ? TRUE : FALSE; |
|
5298 | + if ($this->_isArrayDate($year)) { |
|
5299 | + if ($localtime) unset ($month['VALUE'], $month['TZID']); |
|
5300 | + $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME')); |
|
5301 | + if (isset($input['params']['TZID'])) { |
|
5302 | 5302 | $input['params']['VALUE'] = 'DATE-TIME'; |
5303 | - unset( $year['tz'] ); |
|
5303 | + unset($year['tz']); |
|
5304 | 5304 | } |
5305 | - $hitval = (( !empty( $year['tz'] ) || !empty( $year[6] ))) ? 7 : 6; |
|
5306 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval ); |
|
5307 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, count( $year ), $parno ); |
|
5308 | - $input['value'] = $this->_date_time_array( $year, $parno ); |
|
5309 | - } |
|
5310 | - elseif( $this->_isArrayTimestampDate( $year )) { |
|
5311 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5312 | - $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
|
5313 | - if( isset( $input['params']['TZID'] )) { |
|
5305 | + $hitval = ((!empty($year['tz']) || !empty($year[6]))) ? 7 : 6; |
|
5306 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', $hitval); |
|
5307 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE', 3, count($year), $parno); |
|
5308 | + $input['value'] = $this->_date_time_array($year, $parno); |
|
5309 | + } |
|
5310 | + elseif ($this->_isArrayTimestampDate($year)) { |
|
5311 | + if ($localtime) unset ($month['VALUE'], $month['TZID']); |
|
5312 | + $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME')); |
|
5313 | + if (isset($input['params']['TZID'])) { |
|
5314 | 5314 | $input['params']['VALUE'] = 'DATE-TIME'; |
5315 | - unset( $year['tz'] ); |
|
5315 | + unset($year['tz']); |
|
5316 | 5316 | } |
5317 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3 ); |
|
5318 | - $hitval = ( isset( $year['tz'] )) ? 7 : 6; |
|
5319 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno ); |
|
5320 | - $input['value'] = $this->_timestamp2date( $year, $parno ); |
|
5321 | - } |
|
5322 | - elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
5323 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5324 | - $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
|
5325 | - if( isset( $input['params']['TZID'] )) { |
|
5317 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE', 3); |
|
5318 | + $hitval = (isset($year['tz'])) ? 7 : 6; |
|
5319 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno); |
|
5320 | + $input['value'] = $this->_timestamp2date($year, $parno); |
|
5321 | + } |
|
5322 | + elseif (8 <= strlen(trim($year))) { // ex. 2006-08-03 10:12:18 |
|
5323 | + if ($localtime) unset ($month['VALUE'], $month['TZID']); |
|
5324 | + $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME')); |
|
5325 | + if (isset($input['params']['TZID'])) { |
|
5326 | 5326 | $input['params']['VALUE'] = 'DATE-TIME'; |
5327 | 5327 | $parno = 6; |
5328 | 5328 | } |
5329 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7, $parno ); |
|
5330 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, $parno, $parno ); |
|
5331 | - $input['value'] = $this->_date_time_string( $year, $parno ); |
|
5329 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', 7, $parno); |
|
5330 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE', 3, $parno, $parno); |
|
5331 | + $input['value'] = $this->_date_time_string($year, $parno); |
|
5332 | 5332 | } |
5333 | 5333 | else { |
5334 | - if( is_array( $params )) { |
|
5335 | - if( $localtime ) unset ( $params['VALUE'], $params['TZID'] ); |
|
5336 | - $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )); |
|
5334 | + if (is_array($params)) { |
|
5335 | + if ($localtime) unset ($params['VALUE'], $params['TZID']); |
|
5336 | + $input['params'] = $this->_setParams($params, array('VALUE' => 'DATE-TIME')); |
|
5337 | 5337 | } |
5338 | - elseif( is_array( $tz )) { |
|
5339 | - $input['params'] = $this->_setParams( $tz, array( 'VALUE' => 'DATE-TIME' )); |
|
5338 | + elseif (is_array($tz)) { |
|
5339 | + $input['params'] = $this->_setParams($tz, array('VALUE' => 'DATE-TIME')); |
|
5340 | 5340 | $tz = FALSE; |
5341 | 5341 | } |
5342 | - elseif( is_array( $hour )) { |
|
5343 | - $input['params'] = $this->_setParams( $hour, array( 'VALUE' => 'DATE-TIME' )); |
|
5342 | + elseif (is_array($hour)) { |
|
5343 | + $input['params'] = $this->_setParams($hour, array('VALUE' => 'DATE-TIME')); |
|
5344 | 5344 | $hour = $min = $sec = $tz = FALSE; |
5345 | 5345 | } |
5346 | - if( isset( $input['params']['TZID'] )) { |
|
5347 | - $tz = null; |
|
5346 | + if (isset($input['params']['TZID'])) { |
|
5347 | + $tz = null; |
|
5348 | 5348 | $input['params']['VALUE'] = 'DATE-TIME'; |
5349 | 5349 | } |
5350 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3 ); |
|
5351 | - $hitval = ( !empty( $tz )) ? 7 : 6; |
|
5352 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno, $parno ); |
|
5353 | - $input['value'] = array( 'year' => $year, 'month' => $month, 'day' => $day ); |
|
5354 | - if( 3 != $parno ) { |
|
5355 | - $input['value']['hour'] = ( $hour ) ? $hour : '0'; |
|
5356 | - $input['value']['min'] = ( $min ) ? $min : '0'; |
|
5357 | - $input['value']['sec'] = ( $sec ) ? $sec : '0'; |
|
5358 | - if( !empty( $tz )) |
|
5350 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE', 3); |
|
5351 | + $hitval = (!empty($tz)) ? 7 : 6; |
|
5352 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno, $parno); |
|
5353 | + $input['value'] = array('year' => $year, 'month' => $month, 'day' => $day); |
|
5354 | + if (3 != $parno) { |
|
5355 | + $input['value']['hour'] = ($hour) ? $hour : '0'; |
|
5356 | + $input['value']['min'] = ($min) ? $min : '0'; |
|
5357 | + $input['value']['sec'] = ($sec) ? $sec : '0'; |
|
5358 | + if (!empty($tz)) |
|
5359 | 5359 | $input['value']['tz'] = $tz; |
5360 | 5360 | } |
5361 | 5361 | } |
5362 | - if( 3 == $parno ) { |
|
5362 | + if (3 == $parno) { |
|
5363 | 5363 | $input['params']['VALUE'] = 'DATE'; |
5364 | - unset( $input['value']['tz'] ); |
|
5365 | - unset( $input['params']['TZID'] ); |
|
5364 | + unset($input['value']['tz']); |
|
5365 | + unset($input['params']['TZID']); |
|
5366 | 5366 | } |
5367 | - elseif( isset( $input['params']['TZID'] )) |
|
5368 | - unset( $input['value']['tz'] ); |
|
5369 | - if( $localtime ) unset( $input['value']['tz'], $input['params']['TZID'] ); |
|
5370 | - if( isset( $input['value']['tz'] )) |
|
5367 | + elseif (isset($input['params']['TZID'])) |
|
5368 | + unset($input['value']['tz']); |
|
5369 | + if ($localtime) unset($input['value']['tz'], $input['params']['TZID']); |
|
5370 | + if (isset($input['value']['tz'])) |
|
5371 | 5371 | $input['value']['tz'] = (string) $input['value']['tz']; |
5372 | - if( !empty( $input['value']['tz'] ) && ( 'Z' != $input['value']['tz'] ) && |
|
5373 | - ( !$this->_isOffset( $input['value']['tz'] ))) |
|
5372 | + if (!empty($input['value']['tz']) && ('Z' != $input['value']['tz']) && |
|
5373 | + (!$this->_isOffset($input['value']['tz']))) |
|
5374 | 5374 | $input['params']['TZID'] = $input['value']['tz']; |
5375 | 5375 | return $input; |
5376 | 5376 | } |
@@ -5388,37 +5388,37 @@ discard block |
||
5388 | 5388 | * @param array $params optional |
5389 | 5389 | * @return array |
5390 | 5390 | */ |
5391 | - function _setDate2( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
|
5391 | + function _setDate2($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) { |
|
5392 | 5392 | $input = null; |
5393 | - if( $this->_isArrayDate( $year )) { |
|
5394 | - $input['value'] = $this->_date_time_array( $year, 7 ); |
|
5395 | - $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
|
5393 | + if ($this->_isArrayDate($year)) { |
|
5394 | + $input['value'] = $this->_date_time_array($year, 7); |
|
5395 | + $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME')); |
|
5396 | 5396 | } |
5397 | - elseif( $this->_isArrayTimestampDate( $year )) { |
|
5398 | - $input['value'] = $this->_timestamp2date( $year, 7 ); |
|
5399 | - $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
|
5397 | + elseif ($this->_isArrayTimestampDate($year)) { |
|
5398 | + $input['value'] = $this->_timestamp2date($year, 7); |
|
5399 | + $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME')); |
|
5400 | 5400 | } |
5401 | - elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
5402 | - $input['value'] = $this->_date_time_string( $year, 7 ); |
|
5403 | - $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
|
5401 | + elseif (8 <= strlen(trim($year))) { // ex. 2006-08-03 10:12:18 |
|
5402 | + $input['value'] = $this->_date_time_string($year, 7); |
|
5403 | + $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME')); |
|
5404 | 5404 | } |
5405 | 5405 | else { |
5406 | - $input['value'] = array( 'year' => $year |
|
5406 | + $input['value'] = array('year' => $year |
|
5407 | 5407 | , 'month' => $month |
5408 | 5408 | , 'day' => $day |
5409 | 5409 | , 'hour' => $hour |
5410 | 5410 | , 'min' => $min |
5411 | - , 'sec' => $sec ); |
|
5412 | - $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )); |
|
5411 | + , 'sec' => $sec); |
|
5412 | + $input['params'] = $this->_setParams($params, array('VALUE' => 'DATE-TIME')); |
|
5413 | 5413 | } |
5414 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7 ); // remove default |
|
5415 | - if( !isset( $input['value']['hour'] )) |
|
5414 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', 7); // remove default |
|
5415 | + if (!isset($input['value']['hour'])) |
|
5416 | 5416 | $input['value']['hour'] = 0; |
5417 | - if( !isset( $input['value']['min'] )) |
|
5417 | + if (!isset($input['value']['min'])) |
|
5418 | 5418 | $input['value']['min'] = 0; |
5419 | - if( !isset( $input['value']['sec'] )) |
|
5419 | + if (!isset($input['value']['sec'])) |
|
5420 | 5420 | $input['value']['sec'] = 0; |
5421 | - if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] )) |
|
5421 | + if (!isset($input['value']['tz']) || !$this->_isOffset($input['value']['tz'])) |
|
5422 | 5422 | $input['value']['tz'] = 'Z'; |
5423 | 5423 | return $input; |
5424 | 5424 | } |
@@ -5434,18 +5434,18 @@ discard block |
||
5434 | 5434 | * @param int $index |
5435 | 5435 | * @return void |
5436 | 5436 | */ |
5437 | - function _setMval( & $valArr, $value, $params=FALSE, $defaults=FALSE, $index=FALSE ) { |
|
5438 | - if( !is_array( $valArr )) $valArr = array(); |
|
5439 | - if( $index ) |
|
5437 | + function _setMval(& $valArr, $value, $params = FALSE, $defaults = FALSE, $index = FALSE) { |
|
5438 | + if (!is_array($valArr)) $valArr = array(); |
|
5439 | + if ($index) |
|
5440 | 5440 | $index = $index - 1; |
5441 | - elseif( 0 < count( $valArr )) { |
|
5442 | - $index = end( array_keys( $valArr )); |
|
5441 | + elseif (0 < count($valArr)) { |
|
5442 | + $index = end(array_keys($valArr)); |
|
5443 | 5443 | $index += 1; |
5444 | 5444 | } |
5445 | 5445 | else |
5446 | 5446 | $index = 0; |
5447 | - $valArr[$index] = array( 'value' => $value, 'params' => $this->_setParams( $params, $defaults )); |
|
5448 | - ksort( $valArr ); |
|
5447 | + $valArr[$index] = array('value' => $value, 'params' => $this->_setParams($params, $defaults)); |
|
5448 | + ksort($valArr); |
|
5449 | 5449 | } |
5450 | 5450 | /** |
5451 | 5451 | * set input (formatted) parameters- component property attributes |
@@ -5458,31 +5458,31 @@ discard block |
||
5458 | 5458 | * @param array $defaults |
5459 | 5459 | * @return array |
5460 | 5460 | */ |
5461 | - function _setParams( $params, $defaults=FALSE ) { |
|
5462 | - if( !is_array( $params)) |
|
5461 | + function _setParams($params, $defaults = FALSE) { |
|
5462 | + if (!is_array($params)) |
|
5463 | 5463 | $params = array(); |
5464 | 5464 | $input = array(); |
5465 | - foreach( $params as $paramKey => $paramValue ) { |
|
5466 | - if( is_array( $paramValue )) { |
|
5467 | - foreach( $paramValue as $pkey => $pValue ) { |
|
5468 | - if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 ))) |
|
5469 | - $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 )); |
|
5465 | + foreach ($params as $paramKey => $paramValue) { |
|
5466 | + if (is_array($paramValue)) { |
|
5467 | + foreach ($paramValue as $pkey => $pValue) { |
|
5468 | + if (('"' == substr($pValue, 0, 1)) && ('"' == substr($pValue, -1))) |
|
5469 | + $paramValue[$pkey] = substr($pValue, 1, (strlen($pValue) - 2)); |
|
5470 | 5470 | } |
5471 | 5471 | } |
5472 | - elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 ))) |
|
5473 | - $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 )); |
|
5474 | - if( 'VALUE' == strtoupper( $paramKey )) |
|
5475 | - $input['VALUE'] = strtoupper( $paramValue ); |
|
5472 | + elseif (('"' == substr($paramValue, 0, 1)) && ('"' == substr($paramValue, -1))) |
|
5473 | + $paramValue = substr($paramValue, 1, (strlen($paramValue) - 2)); |
|
5474 | + if ('VALUE' == strtoupper($paramKey)) |
|
5475 | + $input['VALUE'] = strtoupper($paramValue); |
|
5476 | 5476 | else |
5477 | - $input[strtoupper( $paramKey )] = $paramValue; |
|
5477 | + $input[strtoupper($paramKey)] = $paramValue; |
|
5478 | 5478 | } |
5479 | - if( is_array( $defaults )) { |
|
5480 | - foreach( $defaults as $paramKey => $paramValue ) { |
|
5481 | - if( !isset( $input[$paramKey] )) |
|
5479 | + if (is_array($defaults)) { |
|
5480 | + foreach ($defaults as $paramKey => $paramValue) { |
|
5481 | + if (!isset($input[$paramKey])) |
|
5482 | 5482 | $input[$paramKey] = $paramValue; |
5483 | 5483 | } |
5484 | 5484 | } |
5485 | - return (0 < count( $input )) ? $input : null; |
|
5485 | + return (0 < count($input)) ? $input : null; |
|
5486 | 5486 | } |
5487 | 5487 | /** |
5488 | 5488 | * step date, return updated date, array and timpstamp |
@@ -5494,13 +5494,13 @@ discard block |
||
5494 | 5494 | * @param array $step, default array( 'day' => 1 ) |
5495 | 5495 | * @return void |
5496 | 5496 | */ |
5497 | - function _stepdate( &$date, &$timestamp, $step=array( 'day' => 1 )) { |
|
5498 | - foreach( $step as $stepix => $stepvalue ) |
|
5497 | + function _stepdate(&$date, &$timestamp, $step = array('day' => 1)) { |
|
5498 | + foreach ($step as $stepix => $stepvalue) |
|
5499 | 5499 | $date[$stepix] += $stepvalue; |
5500 | - $timestamp = $this->_date2timestamp( $date ); |
|
5501 | - $date = $this->_timestamp2date( $timestamp, 6 ); |
|
5502 | - foreach( $date as $k => $v ) { |
|
5503 | - if( ctype_digit( $v )) |
|
5500 | + $timestamp = $this->_date2timestamp($date); |
|
5501 | + $date = $this->_timestamp2date($timestamp, 6); |
|
5502 | + foreach ($date as $k => $v) { |
|
5503 | + if (ctype_digit($v)) |
|
5504 | 5504 | $date[$k] = (int) $v; |
5505 | 5505 | } |
5506 | 5506 | } |
@@ -5513,20 +5513,20 @@ discard block |
||
5513 | 5513 | * @param int $parno |
5514 | 5514 | * @return array |
5515 | 5515 | */ |
5516 | - function _timestamp2date( $timestamp, $parno=6 ) { |
|
5517 | - if( is_array( $timestamp )) { |
|
5518 | - if(( 7 == $parno ) && !empty( $timestamp['tz'] )) |
|
5516 | + function _timestamp2date($timestamp, $parno = 6) { |
|
5517 | + if (is_array($timestamp)) { |
|
5518 | + if ((7 == $parno) && !empty($timestamp['tz'])) |
|
5519 | 5519 | $tz = $timestamp['tz']; |
5520 | 5520 | $timestamp = $timestamp['timestamp']; |
5521 | 5521 | } |
5522 | - $output = array( 'year' => date( 'Y', $timestamp ) |
|
5523 | - , 'month' => date( 'm', $timestamp ) |
|
5524 | - , 'day' => date( 'd', $timestamp )); |
|
5525 | - if( 3 != $parno ) { |
|
5526 | - $output['hour'] = date( 'H', $timestamp ); |
|
5527 | - $output['min'] = date( 'i', $timestamp ); |
|
5528 | - $output['sec'] = date( 's', $timestamp ); |
|
5529 | - if( isset( $tz )) |
|
5522 | + $output = array('year' => date('Y', $timestamp) |
|
5523 | + , 'month' => date('m', $timestamp) |
|
5524 | + , 'day' => date('d', $timestamp)); |
|
5525 | + if (3 != $parno) { |
|
5526 | + $output['hour'] = date('H', $timestamp); |
|
5527 | + $output['min'] = date('i', $timestamp); |
|
5528 | + $output['sec'] = date('s', $timestamp); |
|
5529 | + if (isset($tz)) |
|
5530 | 5530 | $output['tz'] = $tz; |
5531 | 5531 | } |
5532 | 5532 | return $output; |
@@ -5539,19 +5539,19 @@ discard block |
||
5539 | 5539 | * @param string $offset |
5540 | 5540 | * @return integer |
5541 | 5541 | */ |
5542 | - function _tz2offset( $tz ) { |
|
5543 | - $tz = trim( (string) $tz ); |
|
5542 | + function _tz2offset($tz) { |
|
5543 | + $tz = trim((string) $tz); |
|
5544 | 5544 | $offset = 0; |
5545 | - if((( 5 != strlen( $tz )) && ( 7 != strlen( $tz ))) || |
|
5546 | - (( '+' != substr( $tz, 0, 1 )) && ( '-' != substr( $tz, 0, 1 ))) || |
|
5547 | - (( '0000' >= substr( $tz, 1, 4 )) && ( '9999' < substr( $tz, 1, 4 ))) || |
|
5548 | - (( 7 == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 )))) |
|
5545 | + if (((5 != strlen($tz)) && (7 != strlen($tz))) || |
|
5546 | + (('+' != substr($tz, 0, 1)) && ('-' != substr($tz, 0, 1))) || |
|
5547 | + (('0000' >= substr($tz, 1, 4)) && ('9999' < substr($tz, 1, 4))) || |
|
5548 | + ((7 == strlen($tz)) && ('00' > substr($tz, 5, 2)) && ('99' < substr($tz, 5, 2)))) |
|
5549 | 5549 | return $offset; |
5550 | - $hours2sec = (int) substr( $tz, 1, 2 ) * 3600; |
|
5551 | - $min2sec = (int) substr( $tz, 3, 2 ) * 60; |
|
5552 | - $sec = ( 7 == strlen( $tz )) ? (int) substr( $tz, -2 ) : '00'; |
|
5550 | + $hours2sec = (int) substr($tz, 1, 2) * 3600; |
|
5551 | + $min2sec = (int) substr($tz, 3, 2) * 60; |
|
5552 | + $sec = (7 == strlen($tz)) ? (int) substr($tz, -2) : '00'; |
|
5553 | 5553 | $offset = $hours2sec + $min2sec + $sec; |
5554 | - $offset = ('-' == substr( $tz, 0, 1 )) ? $offset : -1 * $offset; |
|
5554 | + $offset = ('-' == substr($tz, 0, 1)) ? $offset : -1 * $offset; |
|
5555 | 5555 | return $offset; |
5556 | 5556 | } |
5557 | 5557 | /*********************************************************************************/ |
@@ -5564,24 +5564,24 @@ discard block |
||
5564 | 5564 | * @param string $config |
5565 | 5565 | * @return value |
5566 | 5566 | */ |
5567 | - function getConfig( $config ) { |
|
5568 | - switch( strtoupper( $config )) { |
|
5567 | + function getConfig($config) { |
|
5568 | + switch (strtoupper($config)) { |
|
5569 | 5569 | case 'ALLOWEMPTY': |
5570 | 5570 | return $this->allowEmpty; |
5571 | 5571 | break; |
5572 | 5572 | case 'COMPSINFO': |
5573 | - unset( $this->compix ); |
|
5573 | + unset($this->compix); |
|
5574 | 5574 | $info = array(); |
5575 | - if( isset( $this->components )) { |
|
5576 | - foreach( $this->components as $cix => $component ) { |
|
5577 | - if( empty( $component )) continue; |
|
5578 | - unset( $component->propix ); |
|
5575 | + if (isset($this->components)) { |
|
5576 | + foreach ($this->components as $cix => $component) { |
|
5577 | + if (empty($component)) continue; |
|
5578 | + unset($component->propix); |
|
5579 | 5579 | $info[$cix]['ordno'] = $cix + 1; |
5580 | 5580 | $info[$cix]['type'] = $component->objName; |
5581 | - $info[$cix]['uid'] = $component->getProperty( 'uid' ); |
|
5582 | - $info[$cix]['props'] = $component->getConfig( 'propinfo' ); |
|
5583 | - $info[$cix]['sub'] = $component->getConfig( 'compsinfo' ); |
|
5584 | - unset( $component->propix ); |
|
5581 | + $info[$cix]['uid'] = $component->getProperty('uid'); |
|
5582 | + $info[$cix]['props'] = $component->getConfig('propinfo'); |
|
5583 | + $info[$cix]['sub'] = $component->getConfig('compsinfo'); |
|
5584 | + unset($component->propix); |
|
5585 | 5585 | } |
5586 | 5586 | } |
5587 | 5587 | return $info; |
@@ -5599,58 +5599,58 @@ discard block |
||
5599 | 5599 | break; |
5600 | 5600 | case 'PROPINFO': |
5601 | 5601 | $output = array(); |
5602 | - if( !in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
5603 | - if( empty( $this->uid['value'] )) $this->_makeuid(); |
|
5604 | - $output['UID'] = 1; |
|
5602 | + if (!in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) { |
|
5603 | + if (empty($this->uid['value'])) $this->_makeuid(); |
|
5604 | + $output['UID'] = 1; |
|
5605 | 5605 | } |
5606 | - if( !empty( $this->dtstamp )) $output['DTSTAMP'] = 1; |
|
5607 | - if( !empty( $this->summary )) $output['SUMMARY'] = 1; |
|
5608 | - if( !empty( $this->description )) $output['DESCRIPTION'] = count( $this->description ); |
|
5609 | - if( !empty( $this->dtstart )) $output['DTSTART'] = 1; |
|
5610 | - if( !empty( $this->dtend )) $output['DTEND'] = 1; |
|
5611 | - if( !empty( $this->due )) $output['DUE'] = 1; |
|
5612 | - if( !empty( $this->duration )) $output['DURATION'] = 1; |
|
5613 | - if( !empty( $this->rrule )) $output['RRULE'] = count( $this->rrule ); |
|
5614 | - if( !empty( $this->rdate )) $output['RDATE'] = count( $this->rdate ); |
|
5615 | - if( !empty( $this->exdate )) $output['EXDATE'] = count( $this->exdate ); |
|
5616 | - if( !empty( $this->exrule )) $output['EXRULE'] = count( $this->exrule ); |
|
5617 | - if( !empty( $this->action )) $output['ACTION'] = 1; |
|
5618 | - if( !empty( $this->attach )) $output['ATTACH'] = count( $this->attach ); |
|
5619 | - if( !empty( $this->attendee )) $output['ATTENDEE'] = count( $this->attendee ); |
|
5620 | - if( !empty( $this->categories )) $output['CATEGORIES'] = count( $this->categories ); |
|
5621 | - if( !empty( $this->class )) $output['CLASS'] = 1; |
|
5622 | - if( !empty( $this->comment )) $output['COMMENT'] = count( $this->comment ); |
|
5623 | - if( !empty( $this->completed )) $output['COMPLETED'] = 1; |
|
5624 | - if( !empty( $this->contact )) $output['CONTACT'] = count( $this->contact ); |
|
5625 | - if( !empty( $this->created )) $output['CREATED'] = 1; |
|
5626 | - if( !empty( $this->freebusy )) $output['FREEBUSY'] = count( $this->freebusy ); |
|
5627 | - if( !empty( $this->geo )) $output['GEO'] = 1; |
|
5628 | - if( !empty( $this->lastmodified )) $output['LAST-MODIFIED'] = 1; |
|
5629 | - if( !empty( $this->location )) $output['LOCATION'] = 1; |
|
5630 | - if( !empty( $this->organizer )) $output['ORGANIZER'] = 1; |
|
5631 | - if( !empty( $this->percentcomplete )) $output['PERCENT-COMPLETE'] = 1; |
|
5632 | - if( !empty( $this->priority )) $output['PRIORITY'] = 1; |
|
5633 | - if( !empty( $this->recurrenceid )) $output['RECURRENCE-ID'] = 1; |
|
5634 | - if( !empty( $this->relatedto )) $output['RELATED-TO'] = count( $this->relatedto ); |
|
5635 | - if( !empty( $this->repeat )) $output['REPEAT'] = 1; |
|
5636 | - if( !empty( $this->requeststatus )) $output['REQUEST-STATUS'] = count( $this->requeststatus ); |
|
5637 | - if( !empty( $this->resources )) $output['RESOURCES'] = count( $this->resources ); |
|
5638 | - if( !empty( $this->sequence )) $output['SEQUENCE'] = 1; |
|
5639 | - if( !empty( $this->status )) $output['STATUS'] = 1; |
|
5640 | - if( !empty( $this->transp )) $output['TRANSP'] = 1; |
|
5641 | - if( !empty( $this->trigger )) $output['TRIGGER'] = 1; |
|
5642 | - if( !empty( $this->tzid )) $output['TZID'] = 1; |
|
5643 | - if( !empty( $this->tzname )) $output['TZNAME'] = count( $this->tzname ); |
|
5644 | - if( !empty( $this->tzoffsetfrom )) $output['TZOFFSETTFROM'] = 1; |
|
5645 | - if( !empty( $this->tzoffsetto )) $output['TZOFFSETTO'] = 1; |
|
5646 | - if( !empty( $this->tzurl )) $output['TZURL'] = 1; |
|
5647 | - if( !empty( $this->url )) $output['URL'] = 1; |
|
5648 | - if( !empty( $this->xprop )) $output['X-PROP'] = count( $this->xprop ); |
|
5606 | + if (!empty($this->dtstamp)) $output['DTSTAMP'] = 1; |
|
5607 | + if (!empty($this->summary)) $output['SUMMARY'] = 1; |
|
5608 | + if (!empty($this->description)) $output['DESCRIPTION'] = count($this->description); |
|
5609 | + if (!empty($this->dtstart)) $output['DTSTART'] = 1; |
|
5610 | + if (!empty($this->dtend)) $output['DTEND'] = 1; |
|
5611 | + if (!empty($this->due)) $output['DUE'] = 1; |
|
5612 | + if (!empty($this->duration)) $output['DURATION'] = 1; |
|
5613 | + if (!empty($this->rrule)) $output['RRULE'] = count($this->rrule); |
|
5614 | + if (!empty($this->rdate)) $output['RDATE'] = count($this->rdate); |
|
5615 | + if (!empty($this->exdate)) $output['EXDATE'] = count($this->exdate); |
|
5616 | + if (!empty($this->exrule)) $output['EXRULE'] = count($this->exrule); |
|
5617 | + if (!empty($this->action)) $output['ACTION'] = 1; |
|
5618 | + if (!empty($this->attach)) $output['ATTACH'] = count($this->attach); |
|
5619 | + if (!empty($this->attendee)) $output['ATTENDEE'] = count($this->attendee); |
|
5620 | + if (!empty($this->categories)) $output['CATEGORIES'] = count($this->categories); |
|
5621 | + if (!empty($this->class)) $output['CLASS'] = 1; |
|
5622 | + if (!empty($this->comment)) $output['COMMENT'] = count($this->comment); |
|
5623 | + if (!empty($this->completed)) $output['COMPLETED'] = 1; |
|
5624 | + if (!empty($this->contact)) $output['CONTACT'] = count($this->contact); |
|
5625 | + if (!empty($this->created)) $output['CREATED'] = 1; |
|
5626 | + if (!empty($this->freebusy)) $output['FREEBUSY'] = count($this->freebusy); |
|
5627 | + if (!empty($this->geo)) $output['GEO'] = 1; |
|
5628 | + if (!empty($this->lastmodified)) $output['LAST-MODIFIED'] = 1; |
|
5629 | + if (!empty($this->location)) $output['LOCATION'] = 1; |
|
5630 | + if (!empty($this->organizer)) $output['ORGANIZER'] = 1; |
|
5631 | + if (!empty($this->percentcomplete)) $output['PERCENT-COMPLETE'] = 1; |
|
5632 | + if (!empty($this->priority)) $output['PRIORITY'] = 1; |
|
5633 | + if (!empty($this->recurrenceid)) $output['RECURRENCE-ID'] = 1; |
|
5634 | + if (!empty($this->relatedto)) $output['RELATED-TO'] = count($this->relatedto); |
|
5635 | + if (!empty($this->repeat)) $output['REPEAT'] = 1; |
|
5636 | + if (!empty($this->requeststatus)) $output['REQUEST-STATUS'] = count($this->requeststatus); |
|
5637 | + if (!empty($this->resources)) $output['RESOURCES'] = count($this->resources); |
|
5638 | + if (!empty($this->sequence)) $output['SEQUENCE'] = 1; |
|
5639 | + if (!empty($this->status)) $output['STATUS'] = 1; |
|
5640 | + if (!empty($this->transp)) $output['TRANSP'] = 1; |
|
5641 | + if (!empty($this->trigger)) $output['TRIGGER'] = 1; |
|
5642 | + if (!empty($this->tzid)) $output['TZID'] = 1; |
|
5643 | + if (!empty($this->tzname)) $output['TZNAME'] = count($this->tzname); |
|
5644 | + if (!empty($this->tzoffsetfrom)) $output['TZOFFSETTFROM'] = 1; |
|
5645 | + if (!empty($this->tzoffsetto)) $output['TZOFFSETTO'] = 1; |
|
5646 | + if (!empty($this->tzurl)) $output['TZURL'] = 1; |
|
5647 | + if (!empty($this->url)) $output['URL'] = 1; |
|
5648 | + if (!empty($this->xprop)) $output['X-PROP'] = count($this->xprop); |
|
5649 | 5649 | return $output; |
5650 | 5650 | break; |
5651 | 5651 | case 'UNIQUE_ID': |
5652 | - if( empty( $this->unique_id )) |
|
5653 | - $this->unique_id = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost'; |
|
5652 | + if (empty($this->unique_id)) |
|
5653 | + $this->unique_id = (isset($_SERVER['SERVER_NAME'])) ? gethostbyname($_SERVER['SERVER_NAME']) : 'localhost'; |
|
5654 | 5654 | return $this->unique_id; |
5655 | 5655 | break; |
5656 | 5656 | } |
@@ -5664,47 +5664,47 @@ discard block |
||
5664 | 5664 | * @param string $value |
5665 | 5665 | * @return void |
5666 | 5666 | */ |
5667 | - function setConfig( $config, $value ) { |
|
5667 | + function setConfig($config, $value) { |
|
5668 | 5668 | $res = FALSE; |
5669 | - switch( strtoupper( $config )) { |
|
5669 | + switch (strtoupper($config)) { |
|
5670 | 5670 | case 'ALLOWEMPTY': |
5671 | 5671 | $this->allowEmpty = $value; |
5672 | - $subcfg = array( 'ALLOWEMPTY' => $value ); |
|
5672 | + $subcfg = array('ALLOWEMPTY' => $value); |
|
5673 | 5673 | $res = TRUE; |
5674 | 5674 | break; |
5675 | 5675 | case 'FORMAT': |
5676 | - $value = trim( $value ); |
|
5676 | + $value = trim($value); |
|
5677 | 5677 | $this->format = $value; |
5678 | 5678 | $this->_createFormat(); |
5679 | - $subcfg = array( 'FORMAT' => $value ); |
|
5679 | + $subcfg = array('FORMAT' => $value); |
|
5680 | 5680 | $res = TRUE; |
5681 | 5681 | break; |
5682 | 5682 | case 'LANGUAGE': |
5683 | 5683 | // set language for calendar component as defined in [RFC 1766] |
5684 | - $value = trim( $value ); |
|
5684 | + $value = trim($value); |
|
5685 | 5685 | $this->language = $value; |
5686 | - $subcfg = array( 'LANGUAGE' => $value ); |
|
5686 | + $subcfg = array('LANGUAGE' => $value); |
|
5687 | 5687 | $res = TRUE; |
5688 | 5688 | break; |
5689 | 5689 | case 'NL': |
5690 | 5690 | case 'NEWLINECHAR': |
5691 | 5691 | $this->nl = $value; |
5692 | - $subcfg = array( 'NL' => $value ); |
|
5692 | + $subcfg = array('NL' => $value); |
|
5693 | 5693 | $res = TRUE; |
5694 | 5694 | break; |
5695 | 5695 | case 'UNIQUE_ID': |
5696 | - $value = trim( $value ); |
|
5696 | + $value = trim($value); |
|
5697 | 5697 | $this->unique_id = $value; |
5698 | - $subcfg = array( 'UNIQUE_ID' => $value ); |
|
5698 | + $subcfg = array('UNIQUE_ID' => $value); |
|
5699 | 5699 | $res = TRUE; |
5700 | 5700 | break; |
5701 | 5701 | } |
5702 | - if( !$res ) return FALSE; |
|
5703 | - if( isset( $subcfg ) && !empty( $this->components )) { |
|
5704 | - foreach( $subcfg as $cfgkey => $cfgvalue ) { |
|
5705 | - foreach( $this->components as $cix => $component ) { |
|
5706 | - $res = $component->setConfig( $cfgkey, $cfgvalue ); |
|
5707 | - if( !$res ) |
|
5702 | + if (!$res) return FALSE; |
|
5703 | + if (isset($subcfg) && !empty($this->components)) { |
|
5704 | + foreach ($subcfg as $cfgkey => $cfgvalue) { |
|
5705 | + foreach ($this->components as $cix => $component) { |
|
5706 | + $res = $component->setConfig($cfgkey, $cfgvalue); |
|
5707 | + if (!$res) |
|
5708 | 5708 | break 2; |
5709 | 5709 | $this->components[$cix] = $component; // PHP4 compliant |
5710 | 5710 | } |
@@ -5722,248 +5722,248 @@ discard block |
||
5722 | 5722 | * @param int @propix, optional, if specific property is wanted in case of multiply occurences |
5723 | 5723 | * @return bool, if successfull delete TRUE |
5724 | 5724 | */ |
5725 | - function deleteProperty( $propName, $propix=FALSE ) { |
|
5726 | - if( $this->_notExistProp( $propName )) return FALSE; |
|
5727 | - $propName = strtoupper( $propName ); |
|
5728 | - if( in_array( $propName, array( 'ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
|
5729 | - 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP' ))) { |
|
5730 | - if( !$propix ) |
|
5731 | - $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1; |
|
5725 | + function deleteProperty($propName, $propix = FALSE) { |
|
5726 | + if ($this->_notExistProp($propName)) return FALSE; |
|
5727 | + $propName = strtoupper($propName); |
|
5728 | + if (in_array($propName, array('ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
|
5729 | + 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP'))) { |
|
5730 | + if (!$propix) |
|
5731 | + $propix = (isset($this->propdelix[$propName])) ? $this->propdelix[$propName] + 2 : 1; |
|
5732 | 5732 | $this->propdelix[$propName] = --$propix; |
5733 | 5733 | } |
5734 | 5734 | $return = FALSE; |
5735 | - switch( $propName ) { |
|
5735 | + switch ($propName) { |
|
5736 | 5736 | case 'ACTION': |
5737 | - if( !empty( $this->action )) { |
|
5737 | + if (!empty($this->action)) { |
|
5738 | 5738 | $this->action = ''; |
5739 | 5739 | $return = TRUE; |
5740 | 5740 | } |
5741 | 5741 | break; |
5742 | 5742 | case 'ATTACH': |
5743 | - return $this->deletePropertyM( $this->attach, $propix ); |
|
5743 | + return $this->deletePropertyM($this->attach, $propix); |
|
5744 | 5744 | break; |
5745 | 5745 | case 'ATTENDEE': |
5746 | - return $this->deletePropertyM( $this->attendee, $propix ); |
|
5746 | + return $this->deletePropertyM($this->attendee, $propix); |
|
5747 | 5747 | break; |
5748 | 5748 | case 'CATEGORIES': |
5749 | - return $this->deletePropertyM( $this->categories, $propix ); |
|
5749 | + return $this->deletePropertyM($this->categories, $propix); |
|
5750 | 5750 | break; |
5751 | 5751 | case 'CLASS': |
5752 | - if( !empty( $this->class )) { |
|
5752 | + if (!empty($this->class)) { |
|
5753 | 5753 | $this->class = ''; |
5754 | 5754 | $return = TRUE; |
5755 | 5755 | } |
5756 | 5756 | break; |
5757 | 5757 | case 'COMMENT': |
5758 | - return $this->deletePropertyM( $this->comment, $propix ); |
|
5758 | + return $this->deletePropertyM($this->comment, $propix); |
|
5759 | 5759 | break; |
5760 | 5760 | case 'COMPLETED': |
5761 | - if( !empty( $this->completed )) { |
|
5761 | + if (!empty($this->completed)) { |
|
5762 | 5762 | $this->completed = ''; |
5763 | 5763 | $return = TRUE; |
5764 | 5764 | } |
5765 | 5765 | break; |
5766 | 5766 | case 'CONTACT': |
5767 | - return $this->deletePropertyM( $this->contact, $propix ); |
|
5767 | + return $this->deletePropertyM($this->contact, $propix); |
|
5768 | 5768 | break; |
5769 | 5769 | case 'CREATED': |
5770 | - if( !empty( $this->created )) { |
|
5770 | + if (!empty($this->created)) { |
|
5771 | 5771 | $this->created = ''; |
5772 | 5772 | $return = TRUE; |
5773 | 5773 | } |
5774 | 5774 | break; |
5775 | 5775 | case 'DESCRIPTION': |
5776 | - return $this->deletePropertyM( $this->description, $propix ); |
|
5776 | + return $this->deletePropertyM($this->description, $propix); |
|
5777 | 5777 | break; |
5778 | 5778 | case 'DTEND': |
5779 | - if( !empty( $this->dtend )) { |
|
5779 | + if (!empty($this->dtend)) { |
|
5780 | 5780 | $this->dtend = ''; |
5781 | 5781 | $return = TRUE; |
5782 | 5782 | } |
5783 | 5783 | break; |
5784 | 5784 | case 'DTSTAMP': |
5785 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
5785 | + if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) |
|
5786 | 5786 | return FALSE; |
5787 | - if( !empty( $this->dtstamp )) { |
|
5787 | + if (!empty($this->dtstamp)) { |
|
5788 | 5788 | $this->dtstamp = ''; |
5789 | 5789 | $return = TRUE; |
5790 | 5790 | } |
5791 | 5791 | break; |
5792 | 5792 | case 'DTSTART': |
5793 | - if( !empty( $this->dtstart )) { |
|
5793 | + if (!empty($this->dtstart)) { |
|
5794 | 5794 | $this->dtstart = ''; |
5795 | 5795 | $return = TRUE; |
5796 | 5796 | } |
5797 | 5797 | break; |
5798 | 5798 | case 'DUE': |
5799 | - if( !empty( $this->due )) { |
|
5799 | + if (!empty($this->due)) { |
|
5800 | 5800 | $this->due = ''; |
5801 | 5801 | $return = TRUE; |
5802 | 5802 | } |
5803 | 5803 | break; |
5804 | 5804 | case 'DURATION': |
5805 | - if( !empty( $this->duration )) { |
|
5805 | + if (!empty($this->duration)) { |
|
5806 | 5806 | $this->duration = ''; |
5807 | 5807 | $return = TRUE; |
5808 | 5808 | } |
5809 | 5809 | break; |
5810 | 5810 | case 'EXDATE': |
5811 | - return $this->deletePropertyM( $this->exdate, $propix ); |
|
5811 | + return $this->deletePropertyM($this->exdate, $propix); |
|
5812 | 5812 | break; |
5813 | 5813 | case 'EXRULE': |
5814 | - return $this->deletePropertyM( $this->exrule, $propix ); |
|
5814 | + return $this->deletePropertyM($this->exrule, $propix); |
|
5815 | 5815 | break; |
5816 | 5816 | case 'FREEBUSY': |
5817 | - return $this->deletePropertyM( $this->freebusy, $propix ); |
|
5817 | + return $this->deletePropertyM($this->freebusy, $propix); |
|
5818 | 5818 | break; |
5819 | 5819 | case 'GEO': |
5820 | - if( !empty( $this->geo )) { |
|
5820 | + if (!empty($this->geo)) { |
|
5821 | 5821 | $this->geo = ''; |
5822 | 5822 | $return = TRUE; |
5823 | 5823 | } |
5824 | 5824 | break; |
5825 | 5825 | case 'LAST-MODIFIED': |
5826 | - if( !empty( $this->lastmodified )) { |
|
5826 | + if (!empty($this->lastmodified)) { |
|
5827 | 5827 | $this->lastmodified = ''; |
5828 | 5828 | $return = TRUE; |
5829 | 5829 | } |
5830 | 5830 | break; |
5831 | 5831 | case 'LOCATION': |
5832 | - if( !empty( $this->location )) { |
|
5832 | + if (!empty($this->location)) { |
|
5833 | 5833 | $this->location = ''; |
5834 | 5834 | $return = TRUE; |
5835 | 5835 | } |
5836 | 5836 | break; |
5837 | 5837 | case 'ORGANIZER': |
5838 | - if( !empty( $this->organizer )) { |
|
5838 | + if (!empty($this->organizer)) { |
|
5839 | 5839 | $this->organizer = ''; |
5840 | 5840 | $return = TRUE; |
5841 | 5841 | } |
5842 | 5842 | break; |
5843 | 5843 | case 'PERCENT-COMPLETE': |
5844 | - if( !empty( $this->percentcomplete )) { |
|
5844 | + if (!empty($this->percentcomplete)) { |
|
5845 | 5845 | $this->percentcomplete = ''; |
5846 | 5846 | $return = TRUE; |
5847 | 5847 | } |
5848 | 5848 | break; |
5849 | 5849 | case 'PRIORITY': |
5850 | - if( !empty( $this->priority )) { |
|
5850 | + if (!empty($this->priority)) { |
|
5851 | 5851 | $this->priority = ''; |
5852 | 5852 | $return = TRUE; |
5853 | 5853 | } |
5854 | 5854 | break; |
5855 | 5855 | case 'RDATE': |
5856 | - return $this->deletePropertyM( $this->rdate, $propix ); |
|
5856 | + return $this->deletePropertyM($this->rdate, $propix); |
|
5857 | 5857 | break; |
5858 | 5858 | case 'RECURRENCE-ID': |
5859 | - if( !empty( $this->recurrenceid )) { |
|
5859 | + if (!empty($this->recurrenceid)) { |
|
5860 | 5860 | $this->recurrenceid = ''; |
5861 | 5861 | $return = TRUE; |
5862 | 5862 | } |
5863 | 5863 | break; |
5864 | 5864 | case 'RELATED-TO': |
5865 | - return $this->deletePropertyM( $this->relatedto, $propix ); |
|
5865 | + return $this->deletePropertyM($this->relatedto, $propix); |
|
5866 | 5866 | break; |
5867 | 5867 | case 'REPEAT': |
5868 | - if( !empty( $this->repeat )) { |
|
5868 | + if (!empty($this->repeat)) { |
|
5869 | 5869 | $this->repeat = ''; |
5870 | 5870 | $return = TRUE; |
5871 | 5871 | } |
5872 | 5872 | break; |
5873 | 5873 | case 'REQUEST-STATUS': |
5874 | - return $this->deletePropertyM( $this->requeststatus, $propix ); |
|
5874 | + return $this->deletePropertyM($this->requeststatus, $propix); |
|
5875 | 5875 | break; |
5876 | 5876 | case 'RESOURCES': |
5877 | - return $this->deletePropertyM( $this->resources, $propix ); |
|
5877 | + return $this->deletePropertyM($this->resources, $propix); |
|
5878 | 5878 | break; |
5879 | 5879 | case 'RRULE': |
5880 | - return $this->deletePropertyM( $this->rrule, $propix ); |
|
5880 | + return $this->deletePropertyM($this->rrule, $propix); |
|
5881 | 5881 | break; |
5882 | 5882 | case 'SEQUENCE': |
5883 | - if( !empty( $this->sequence )) { |
|
5883 | + if (!empty($this->sequence)) { |
|
5884 | 5884 | $this->sequence = ''; |
5885 | 5885 | $return = TRUE; |
5886 | 5886 | } |
5887 | 5887 | break; |
5888 | 5888 | case 'STATUS': |
5889 | - if( !empty( $this->status )) { |
|
5889 | + if (!empty($this->status)) { |
|
5890 | 5890 | $this->status = ''; |
5891 | 5891 | $return = TRUE; |
5892 | 5892 | } |
5893 | 5893 | break; |
5894 | 5894 | case 'SUMMARY': |
5895 | - if( !empty( $this->summary )) { |
|
5895 | + if (!empty($this->summary)) { |
|
5896 | 5896 | $this->summary = ''; |
5897 | 5897 | $return = TRUE; |
5898 | 5898 | } |
5899 | 5899 | break; |
5900 | 5900 | case 'TRANSP': |
5901 | - if( !empty( $this->transp )) { |
|
5901 | + if (!empty($this->transp)) { |
|
5902 | 5902 | $this->transp = ''; |
5903 | 5903 | $return = TRUE; |
5904 | 5904 | } |
5905 | 5905 | break; |
5906 | 5906 | case 'TRIGGER': |
5907 | - if( !empty( $this->trigger )) { |
|
5907 | + if (!empty($this->trigger)) { |
|
5908 | 5908 | $this->trigger = ''; |
5909 | 5909 | $return = TRUE; |
5910 | 5910 | } |
5911 | 5911 | break; |
5912 | 5912 | case 'TZID': |
5913 | - if( !empty( $this->tzid )) { |
|
5913 | + if (!empty($this->tzid)) { |
|
5914 | 5914 | $this->tzid = ''; |
5915 | 5915 | $return = TRUE; |
5916 | 5916 | } |
5917 | 5917 | break; |
5918 | 5918 | case 'TZNAME': |
5919 | - return $this->deletePropertyM( $this->tzname, $propix ); |
|
5919 | + return $this->deletePropertyM($this->tzname, $propix); |
|
5920 | 5920 | break; |
5921 | 5921 | case 'TZOFFSETFROM': |
5922 | - if( !empty( $this->tzoffsetfrom )) { |
|
5922 | + if (!empty($this->tzoffsetfrom)) { |
|
5923 | 5923 | $this->tzoffsetfrom = ''; |
5924 | 5924 | $return = TRUE; |
5925 | 5925 | } |
5926 | 5926 | break; |
5927 | 5927 | case 'TZOFFSETTO': |
5928 | - if( !empty( $this->tzoffsetto )) { |
|
5928 | + if (!empty($this->tzoffsetto)) { |
|
5929 | 5929 | $this->tzoffsetto = ''; |
5930 | 5930 | $return = TRUE; |
5931 | 5931 | } |
5932 | 5932 | break; |
5933 | 5933 | case 'TZURL': |
5934 | - if( !empty( $this->tzurl )) { |
|
5934 | + if (!empty($this->tzurl)) { |
|
5935 | 5935 | $this->tzurl = ''; |
5936 | 5936 | $return = TRUE; |
5937 | 5937 | } |
5938 | 5938 | break; |
5939 | 5939 | case 'UID': |
5940 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
5940 | + if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) |
|
5941 | 5941 | return FALSE; |
5942 | - if( !empty( $this->uid )) { |
|
5942 | + if (!empty($this->uid)) { |
|
5943 | 5943 | $this->uid = ''; |
5944 | 5944 | $return = TRUE; |
5945 | 5945 | } |
5946 | 5946 | break; |
5947 | 5947 | case 'URL': |
5948 | - if( !empty( $this->url )) { |
|
5948 | + if (!empty($this->url)) { |
|
5949 | 5949 | $this->url = ''; |
5950 | 5950 | $return = TRUE; |
5951 | 5951 | } |
5952 | 5952 | break; |
5953 | 5953 | default: |
5954 | 5954 | $reduced = ''; |
5955 | - if( $propName != 'X-PROP' ) { |
|
5956 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
5957 | - foreach( $this->xprop as $k => $a ) { |
|
5958 | - if(( $k != $propName ) && !empty( $a )) |
|
5955 | + if ($propName != 'X-PROP') { |
|
5956 | + if (!isset($this->xprop[$propName])) return FALSE; |
|
5957 | + foreach ($this->xprop as $k => $a) { |
|
5958 | + if (($k != $propName) && !empty($a)) |
|
5959 | 5959 | $reduced[$k] = $a; |
5960 | 5960 | } |
5961 | 5961 | } |
5962 | 5962 | else { |
5963 | - if( count( $this->xprop ) <= $propix ) return FALSE; |
|
5963 | + if (count($this->xprop) <= $propix) return FALSE; |
|
5964 | 5964 | $xpropno = 0; |
5965 | - foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
|
5966 | - if( $propix != $xpropno ) |
|
5965 | + foreach ($this->xprop as $xpropkey => $xpropvalue) { |
|
5966 | + if ($propix != $xpropno) |
|
5967 | 5967 | $reduced[$xpropkey] = $xpropvalue; |
5968 | 5968 | $xpropno++; |
5969 | 5969 | } |
@@ -5983,11 +5983,11 @@ discard block |
||
5983 | 5983 | * @param int @propix, default 0 |
5984 | 5984 | * @return bool TRUE |
5985 | 5985 | */ |
5986 | - function deletePropertyM( & $multiprop, $propix=0 ) { |
|
5987 | - if( !isset( $multiprop[$propix])) return FALSE; |
|
5988 | - unset( $multiprop[$propix] ); |
|
5989 | - if( empty( $multiprop )) $multiprop = ''; |
|
5990 | - return ( isset( $this->multiprop[$propix] )) ? FALSE : TRUE; |
|
5986 | + function deletePropertyM(& $multiprop, $propix = 0) { |
|
5987 | + if (!isset($multiprop[$propix])) return FALSE; |
|
5988 | + unset($multiprop[$propix]); |
|
5989 | + if (empty($multiprop)) $multiprop = ''; |
|
5990 | + return (isset($this->multiprop[$propix])) ? FALSE : TRUE; |
|
5991 | 5991 | } |
5992 | 5992 | /** |
5993 | 5993 | * get component property value/params |
@@ -6002,183 +6002,183 @@ discard block |
||
6002 | 6002 | * @param bool $specform=FALSE |
6003 | 6003 | * @return mixed |
6004 | 6004 | */ |
6005 | - function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE, $specform=FALSE ) { |
|
6006 | - if( $this->_notExistProp( $propName )) return FALSE; |
|
6007 | - $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP'; |
|
6008 | - if( in_array( $propName, array( 'ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
|
6009 | - 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP' ))) { |
|
6010 | - if( !$propix ) |
|
6011 | - $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; |
|
6005 | + function getProperty($propName = FALSE, $propix = FALSE, $inclParam = FALSE, $specform = FALSE) { |
|
6006 | + if ($this->_notExistProp($propName)) return FALSE; |
|
6007 | + $propName = ($propName) ? strtoupper($propName) : 'X-PROP'; |
|
6008 | + if (in_array($propName, array('ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
|
6009 | + 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP'))) { |
|
6010 | + if (!$propix) |
|
6011 | + $propix = (isset($this->propix[$propName])) ? $this->propix[$propName] + 2 : 1; |
|
6012 | 6012 | $this->propix[$propName] = --$propix; |
6013 | 6013 | } |
6014 | - switch( $propName ) { |
|
6014 | + switch ($propName) { |
|
6015 | 6015 | case 'ACTION': |
6016 | - if( !empty( $this->action['value'] )) return ( $inclParam ) ? $this->action : $this->action['value']; |
|
6016 | + if (!empty($this->action['value'])) return ($inclParam) ? $this->action : $this->action['value']; |
|
6017 | 6017 | break; |
6018 | 6018 | case 'ATTACH': |
6019 | - if( !isset( $this->attach[$propix] )) return FALSE; |
|
6020 | - return ( $inclParam ) ? $this->attach[$propix] : $this->attach[$propix]['value']; |
|
6019 | + if (!isset($this->attach[$propix])) return FALSE; |
|
6020 | + return ($inclParam) ? $this->attach[$propix] : $this->attach[$propix]['value']; |
|
6021 | 6021 | break; |
6022 | 6022 | case 'ATTENDEE': |
6023 | - if( !isset( $this->attendee[$propix] )) return FALSE; |
|
6024 | - return ( $inclParam ) ? $this->attendee[$propix] : $this->attendee[$propix]['value']; |
|
6023 | + if (!isset($this->attendee[$propix])) return FALSE; |
|
6024 | + return ($inclParam) ? $this->attendee[$propix] : $this->attendee[$propix]['value']; |
|
6025 | 6025 | break; |
6026 | 6026 | case 'CATEGORIES': |
6027 | - if( !isset( $this->categories[$propix] )) return FALSE; |
|
6028 | - return ( $inclParam ) ? $this->categories[$propix] : $this->categories[$propix]['value']; |
|
6027 | + if (!isset($this->categories[$propix])) return FALSE; |
|
6028 | + return ($inclParam) ? $this->categories[$propix] : $this->categories[$propix]['value']; |
|
6029 | 6029 | break; |
6030 | 6030 | case 'CLASS': |
6031 | - if( !empty( $this->class['value'] )) return ( $inclParam ) ? $this->class : $this->class['value']; |
|
6031 | + if (!empty($this->class['value'])) return ($inclParam) ? $this->class : $this->class['value']; |
|
6032 | 6032 | break; |
6033 | 6033 | case 'COMMENT': |
6034 | - if( !isset( $this->comment[$propix] )) return FALSE; |
|
6035 | - return ( $inclParam ) ? $this->comment[$propix] : $this->comment[$propix]['value']; |
|
6034 | + if (!isset($this->comment[$propix])) return FALSE; |
|
6035 | + return ($inclParam) ? $this->comment[$propix] : $this->comment[$propix]['value']; |
|
6036 | 6036 | break; |
6037 | 6037 | case 'COMPLETED': |
6038 | - if( !empty( $this->completed['value'] )) return ( $inclParam ) ? $this->completed : $this->completed['value']; |
|
6038 | + if (!empty($this->completed['value'])) return ($inclParam) ? $this->completed : $this->completed['value']; |
|
6039 | 6039 | break; |
6040 | 6040 | case 'CONTACT': |
6041 | - if( !isset( $this->contact[$propix] )) return FALSE; |
|
6042 | - return ( $inclParam ) ? $this->contact[$propix] : $this->contact[$propix]['value']; |
|
6041 | + if (!isset($this->contact[$propix])) return FALSE; |
|
6042 | + return ($inclParam) ? $this->contact[$propix] : $this->contact[$propix]['value']; |
|
6043 | 6043 | break; |
6044 | 6044 | case 'CREATED': |
6045 | - if( !empty( $this->created['value'] )) return ( $inclParam ) ? $this->created : $this->created['value']; |
|
6045 | + if (!empty($this->created['value'])) return ($inclParam) ? $this->created : $this->created['value']; |
|
6046 | 6046 | break; |
6047 | 6047 | case 'DESCRIPTION': |
6048 | - if( !isset( $this->description[$propix] )) return FALSE; |
|
6049 | - return ( $inclParam ) ? $this->description[$propix] : $this->description[$propix]['value']; |
|
6048 | + if (!isset($this->description[$propix])) return FALSE; |
|
6049 | + return ($inclParam) ? $this->description[$propix] : $this->description[$propix]['value']; |
|
6050 | 6050 | break; |
6051 | 6051 | case 'DTEND': |
6052 | - if( !empty( $this->dtend['value'] )) return ( $inclParam ) ? $this->dtend : $this->dtend['value']; |
|
6052 | + if (!empty($this->dtend['value'])) return ($inclParam) ? $this->dtend : $this->dtend['value']; |
|
6053 | 6053 | break; |
6054 | 6054 | case 'DTSTAMP': |
6055 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
6055 | + if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) |
|
6056 | 6056 | return; |
6057 | - if( !isset( $this->dtstamp['value'] )) |
|
6057 | + if (!isset($this->dtstamp['value'])) |
|
6058 | 6058 | $this->_makeDtstamp(); |
6059 | - return ( $inclParam ) ? $this->dtstamp : $this->dtstamp['value']; |
|
6059 | + return ($inclParam) ? $this->dtstamp : $this->dtstamp['value']; |
|
6060 | 6060 | break; |
6061 | 6061 | case 'DTSTART': |
6062 | - if( !empty( $this->dtstart['value'] )) return ( $inclParam ) ? $this->dtstart : $this->dtstart['value']; |
|
6062 | + if (!empty($this->dtstart['value'])) return ($inclParam) ? $this->dtstart : $this->dtstart['value']; |
|
6063 | 6063 | break; |
6064 | 6064 | case 'DUE': |
6065 | - if( !empty( $this->due['value'] )) return ( $inclParam ) ? $this->due : $this->due['value']; |
|
6065 | + if (!empty($this->due['value'])) return ($inclParam) ? $this->due : $this->due['value']; |
|
6066 | 6066 | break; |
6067 | 6067 | case 'DURATION': |
6068 | - if( !isset( $this->duration['value'] )) return FALSE; |
|
6069 | - $value = ( $specform ) ? $this->duration2date() : $this->duration['value']; |
|
6070 | - return ( $inclParam ) ? array( 'value' => $value, 'params' => $this->duration['params'] ) : $value; |
|
6068 | + if (!isset($this->duration['value'])) return FALSE; |
|
6069 | + $value = ($specform) ? $this->duration2date() : $this->duration['value']; |
|
6070 | + return ($inclParam) ? array('value' => $value, 'params' => $this->duration['params']) : $value; |
|
6071 | 6071 | break; |
6072 | 6072 | case 'EXDATE': |
6073 | - if( !isset( $this->exdate[$propix] )) return FALSE; |
|
6074 | - return ( $inclParam ) ? $this->exdate[$propix] : $this->exdate[$propix]['value']; |
|
6073 | + if (!isset($this->exdate[$propix])) return FALSE; |
|
6074 | + return ($inclParam) ? $this->exdate[$propix] : $this->exdate[$propix]['value']; |
|
6075 | 6075 | break; |
6076 | 6076 | case 'EXRULE': |
6077 | - if( !isset( $this->exrule[$propix] )) return FALSE; |
|
6078 | - return ( $inclParam ) ? $this->exrule[$propix] : $this->exrule[$propix]['value']; |
|
6077 | + if (!isset($this->exrule[$propix])) return FALSE; |
|
6078 | + return ($inclParam) ? $this->exrule[$propix] : $this->exrule[$propix]['value']; |
|
6079 | 6079 | break; |
6080 | 6080 | case 'FREEBUSY': |
6081 | - if( !isset( $this->freebusy[$propix] )) return FALSE; |
|
6082 | - return ( $inclParam ) ? $this->freebusy[$propix] : $this->freebusy[$propix]['value']; |
|
6081 | + if (!isset($this->freebusy[$propix])) return FALSE; |
|
6082 | + return ($inclParam) ? $this->freebusy[$propix] : $this->freebusy[$propix]['value']; |
|
6083 | 6083 | break; |
6084 | 6084 | case 'GEO': |
6085 | - if( !empty( $this->geo['value'] )) return ( $inclParam ) ? $this->geo : $this->geo['value']; |
|
6085 | + if (!empty($this->geo['value'])) return ($inclParam) ? $this->geo : $this->geo['value']; |
|
6086 | 6086 | break; |
6087 | 6087 | case 'LAST-MODIFIED': |
6088 | - if( !empty( $this->lastmodified['value'] )) return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value']; |
|
6088 | + if (!empty($this->lastmodified['value'])) return ($inclParam) ? $this->lastmodified : $this->lastmodified['value']; |
|
6089 | 6089 | break; |
6090 | 6090 | case 'LOCATION': |
6091 | - if( !empty( $this->location['value'] )) return ( $inclParam ) ? $this->location : $this->location['value']; |
|
6091 | + if (!empty($this->location['value'])) return ($inclParam) ? $this->location : $this->location['value']; |
|
6092 | 6092 | break; |
6093 | 6093 | case 'ORGANIZER': |
6094 | - if( !empty( $this->organizer['value'] )) return ( $inclParam ) ? $this->organizer : $this->organizer['value']; |
|
6094 | + if (!empty($this->organizer['value'])) return ($inclParam) ? $this->organizer : $this->organizer['value']; |
|
6095 | 6095 | break; |
6096 | 6096 | case 'PERCENT-COMPLETE': |
6097 | - if( !empty( $this->percentcomplete['value'] )) return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value']; |
|
6097 | + if (!empty($this->percentcomplete['value'])) return ($inclParam) ? $this->percentcomplete : $this->percentcomplete['value']; |
|
6098 | 6098 | break; |
6099 | 6099 | case 'PRIORITY': |
6100 | - if( !empty( $this->priority['value'] )) return ( $inclParam ) ? $this->priority : $this->priority['value']; |
|
6100 | + if (!empty($this->priority['value'])) return ($inclParam) ? $this->priority : $this->priority['value']; |
|
6101 | 6101 | break; |
6102 | 6102 | case 'RDATE': |
6103 | - if( !isset( $this->rdate[$propix] )) return FALSE; |
|
6104 | - return ( $inclParam ) ? $this->rdate[$propix] : $this->rdate[$propix]['value']; |
|
6103 | + if (!isset($this->rdate[$propix])) return FALSE; |
|
6104 | + return ($inclParam) ? $this->rdate[$propix] : $this->rdate[$propix]['value']; |
|
6105 | 6105 | break; |
6106 | 6106 | case 'RECURRENCE-ID': |
6107 | - if( !empty( $this->recurrenceid['value'] )) return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value']; |
|
6107 | + if (!empty($this->recurrenceid['value'])) return ($inclParam) ? $this->recurrenceid : $this->recurrenceid['value']; |
|
6108 | 6108 | break; |
6109 | 6109 | case 'RELATED-TO': |
6110 | - if( !isset( $this->relatedto[$propix] )) return FALSE; |
|
6111 | - return ( $inclParam ) ? $this->relatedto[$propix] : $this->relatedto[$propix]['value']; |
|
6110 | + if (!isset($this->relatedto[$propix])) return FALSE; |
|
6111 | + return ($inclParam) ? $this->relatedto[$propix] : $this->relatedto[$propix]['value']; |
|
6112 | 6112 | break; |
6113 | 6113 | case 'REPEAT': |
6114 | - if( !empty( $this->repeat['value'] )) return ( $inclParam ) ? $this->repeat : $this->repeat['value']; |
|
6114 | + if (!empty($this->repeat['value'])) return ($inclParam) ? $this->repeat : $this->repeat['value']; |
|
6115 | 6115 | break; |
6116 | 6116 | case 'REQUEST-STATUS': |
6117 | - if( !isset( $this->requeststatus[$propix] )) return FALSE; |
|
6118 | - return ( $inclParam ) ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value']; |
|
6117 | + if (!isset($this->requeststatus[$propix])) return FALSE; |
|
6118 | + return ($inclParam) ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value']; |
|
6119 | 6119 | break; |
6120 | 6120 | case 'RESOURCES': |
6121 | - if( !isset( $this->resources[$propix] )) return FALSE; |
|
6122 | - return ( $inclParam ) ? $this->resources[$propix] : $this->resources[$propix]['value']; |
|
6121 | + if (!isset($this->resources[$propix])) return FALSE; |
|
6122 | + return ($inclParam) ? $this->resources[$propix] : $this->resources[$propix]['value']; |
|
6123 | 6123 | break; |
6124 | 6124 | case 'RRULE': |
6125 | - if( !isset( $this->rrule[$propix] )) return FALSE; |
|
6126 | - return ( $inclParam ) ? $this->rrule[$propix] : $this->rrule[$propix]['value']; |
|
6125 | + if (!isset($this->rrule[$propix])) return FALSE; |
|
6126 | + return ($inclParam) ? $this->rrule[$propix] : $this->rrule[$propix]['value']; |
|
6127 | 6127 | break; |
6128 | 6128 | case 'SEQUENCE': |
6129 | - if( !empty( $this->sequence['value'] )) return ( $inclParam ) ? $this->sequence : $this->sequence['value']; |
|
6129 | + if (!empty($this->sequence['value'])) return ($inclParam) ? $this->sequence : $this->sequence['value']; |
|
6130 | 6130 | break; |
6131 | 6131 | case 'STATUS': |
6132 | - if( !empty( $this->status['value'] )) return ( $inclParam ) ? $this->status : $this->status['value']; |
|
6132 | + if (!empty($this->status['value'])) return ($inclParam) ? $this->status : $this->status['value']; |
|
6133 | 6133 | break; |
6134 | 6134 | case 'SUMMARY': |
6135 | - if( !empty( $this->summary['value'] )) return ( $inclParam ) ? $this->summary : $this->summary['value']; |
|
6135 | + if (!empty($this->summary['value'])) return ($inclParam) ? $this->summary : $this->summary['value']; |
|
6136 | 6136 | break; |
6137 | 6137 | case 'TRANSP': |
6138 | - if( !empty( $this->transp['value'] )) return ( $inclParam ) ? $this->transp : $this->transp['value']; |
|
6138 | + if (!empty($this->transp['value'])) return ($inclParam) ? $this->transp : $this->transp['value']; |
|
6139 | 6139 | break; |
6140 | 6140 | case 'TRIGGER': |
6141 | - if( !empty( $this->trigger['value'] )) return ( $inclParam ) ? $this->trigger : $this->trigger['value']; |
|
6141 | + if (!empty($this->trigger['value'])) return ($inclParam) ? $this->trigger : $this->trigger['value']; |
|
6142 | 6142 | break; |
6143 | 6143 | case 'TZID': |
6144 | - if( !empty( $this->tzid['value'] )) return ( $inclParam ) ? $this->tzid : $this->tzid['value']; |
|
6144 | + if (!empty($this->tzid['value'])) return ($inclParam) ? $this->tzid : $this->tzid['value']; |
|
6145 | 6145 | break; |
6146 | 6146 | case 'TZNAME': |
6147 | - if( !isset( $this->tzname[$propix] )) return FALSE; |
|
6148 | - return ( $inclParam ) ? $this->tzname[$propix] : $this->tzname[$propix]['value']; |
|
6147 | + if (!isset($this->tzname[$propix])) return FALSE; |
|
6148 | + return ($inclParam) ? $this->tzname[$propix] : $this->tzname[$propix]['value']; |
|
6149 | 6149 | break; |
6150 | 6150 | case 'TZOFFSETFROM': |
6151 | - if( !empty( $this->tzoffsetfrom['value'] )) return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value']; |
|
6151 | + if (!empty($this->tzoffsetfrom['value'])) return ($inclParam) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value']; |
|
6152 | 6152 | break; |
6153 | 6153 | case 'TZOFFSETTO': |
6154 | - if( !empty( $this->tzoffsetto['value'] )) return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value']; |
|
6154 | + if (!empty($this->tzoffsetto['value'])) return ($inclParam) ? $this->tzoffsetto : $this->tzoffsetto['value']; |
|
6155 | 6155 | break; |
6156 | 6156 | case 'TZURL': |
6157 | - if( !empty( $this->tzurl['value'] )) return ( $inclParam ) ? $this->tzurl : $this->tzurl['value']; |
|
6157 | + if (!empty($this->tzurl['value'])) return ($inclParam) ? $this->tzurl : $this->tzurl['value']; |
|
6158 | 6158 | break; |
6159 | 6159 | case 'UID': |
6160 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
6160 | + if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) |
|
6161 | 6161 | return FALSE; |
6162 | - if( empty( $this->uid['value'] )) |
|
6162 | + if (empty($this->uid['value'])) |
|
6163 | 6163 | $this->_makeuid(); |
6164 | - return ( $inclParam ) ? $this->uid : $this->uid['value']; |
|
6164 | + return ($inclParam) ? $this->uid : $this->uid['value']; |
|
6165 | 6165 | break; |
6166 | 6166 | case 'URL': |
6167 | - if( !empty( $this->url['value'] )) return ( $inclParam ) ? $this->url : $this->url['value']; |
|
6167 | + if (!empty($this->url['value'])) return ($inclParam) ? $this->url : $this->url['value']; |
|
6168 | 6168 | break; |
6169 | 6169 | default: |
6170 | - if( $propName != 'X-PROP' ) { |
|
6171 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
6172 | - return ( $inclParam ) ? array( $propName, $this->xprop[$propName] ) |
|
6173 | - : array( $propName, $this->xprop[$propName]['value'] ); |
|
6170 | + if ($propName != 'X-PROP') { |
|
6171 | + if (!isset($this->xprop[$propName])) return FALSE; |
|
6172 | + return ($inclParam) ? array($propName, $this->xprop[$propName]) |
|
6173 | + : array($propName, $this->xprop[$propName]['value']); |
|
6174 | 6174 | } |
6175 | 6175 | else { |
6176 | - if( empty( $this->xprop )) return FALSE; |
|
6176 | + if (empty($this->xprop)) return FALSE; |
|
6177 | 6177 | $xpropno = 0; |
6178 | - foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
|
6179 | - if( $propix == $xpropno ) |
|
6180 | - return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) |
|
6181 | - : array( $xpropkey, $this->xprop[$xpropkey]['value'] ); |
|
6178 | + foreach ($this->xprop as $xpropkey => $xpropvalue) { |
|
6179 | + if ($propix == $xpropno) |
|
6180 | + return ($inclParam) ? array($xpropkey, $this->xprop[$xpropkey]) |
|
6181 | + : array($xpropkey, $this->xprop[$xpropkey]['value']); |
|
6182 | 6182 | else |
6183 | 6183 | $xpropno++; |
6184 | 6184 | } |
@@ -6199,105 +6199,105 @@ discard block |
||
6199 | 6199 | */ |
6200 | 6200 | function setProperty() { |
6201 | 6201 | $numargs = func_num_args(); |
6202 | - if( 1 > $numargs ) return FALSE; |
|
6202 | + if (1 > $numargs) return FALSE; |
|
6203 | 6203 | $arglist = func_get_args(); |
6204 | - if( $this->_notExistProp( $arglist[0] )) return FALSE; |
|
6205 | - if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] ))) |
|
6204 | + if ($this->_notExistProp($arglist[0])) return FALSE; |
|
6205 | + if (!$this->getConfig('allowEmpty') && (!isset($arglist[1]) || empty($arglist[1]))) |
|
6206 | 6206 | return FALSE; |
6207 | - $arglist[0] = strtoupper( $arglist[0] ); |
|
6208 | - for( $argix=$numargs; $argix < 12; $argix++ ) { |
|
6209 | - if( !isset( $arglist[$argix] )) |
|
6207 | + $arglist[0] = strtoupper($arglist[0]); |
|
6208 | + for ($argix = $numargs; $argix < 12; $argix++) { |
|
6209 | + if (!isset($arglist[$argix])) |
|
6210 | 6210 | $arglist[$argix] = null; |
6211 | 6211 | } |
6212 | - switch( $arglist[0] ) { |
|
6212 | + switch ($arglist[0]) { |
|
6213 | 6213 | case 'ACTION': |
6214 | - return $this->setAction( $arglist[1], $arglist[2] ); |
|
6214 | + return $this->setAction($arglist[1], $arglist[2]); |
|
6215 | 6215 | case 'ATTACH': |
6216 | - return $this->setAttach( $arglist[1], $arglist[2], $arglist[3] ); |
|
6216 | + return $this->setAttach($arglist[1], $arglist[2], $arglist[3]); |
|
6217 | 6217 | case 'ATTENDEE': |
6218 | - return $this->setAttendee( $arglist[1], $arglist[2], $arglist[3] ); |
|
6218 | + return $this->setAttendee($arglist[1], $arglist[2], $arglist[3]); |
|
6219 | 6219 | case 'CATEGORIES': |
6220 | - return $this->setCategories( $arglist[1], $arglist[2], $arglist[3] ); |
|
6220 | + return $this->setCategories($arglist[1], $arglist[2], $arglist[3]); |
|
6221 | 6221 | case 'CLASS': |
6222 | - return $this->setClass( $arglist[1], $arglist[2] ); |
|
6222 | + return $this->setClass($arglist[1], $arglist[2]); |
|
6223 | 6223 | case 'COMMENT': |
6224 | - return $this->setComment( $arglist[1], $arglist[2], $arglist[3] ); |
|
6224 | + return $this->setComment($arglist[1], $arglist[2], $arglist[3]); |
|
6225 | 6225 | case 'COMPLETED': |
6226 | - return $this->setCompleted( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] ); |
|
6226 | + return $this->setCompleted($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7]); |
|
6227 | 6227 | case 'CONTACT': |
6228 | - return $this->setContact( $arglist[1], $arglist[2], $arglist[3] ); |
|
6228 | + return $this->setContact($arglist[1], $arglist[2], $arglist[3]); |
|
6229 | 6229 | case 'CREATED': |
6230 | - return $this->setCreated( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] ); |
|
6230 | + return $this->setCreated($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7]); |
|
6231 | 6231 | case 'DESCRIPTION': |
6232 | - return $this->setDescription( $arglist[1], $arglist[2], $arglist[3] ); |
|
6232 | + return $this->setDescription($arglist[1], $arglist[2], $arglist[3]); |
|
6233 | 6233 | case 'DTEND': |
6234 | - return $this->setDtend( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] ); |
|
6234 | + return $this->setDtend($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8]); |
|
6235 | 6235 | case 'DTSTAMP': |
6236 | - return $this->setDtstamp( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] ); |
|
6236 | + return $this->setDtstamp($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7]); |
|
6237 | 6237 | case 'DTSTART': |
6238 | - return $this->setDtstart( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] ); |
|
6238 | + return $this->setDtstart($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8]); |
|
6239 | 6239 | case 'DUE': |
6240 | - return $this->setDue( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] ); |
|
6240 | + return $this->setDue($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8]); |
|
6241 | 6241 | case 'DURATION': |
6242 | - return $this->setDuration( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6] ); |
|
6242 | + return $this->setDuration($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6]); |
|
6243 | 6243 | case 'EXDATE': |
6244 | - return $this->setExdate( $arglist[1], $arglist[2], $arglist[3] ); |
|
6244 | + return $this->setExdate($arglist[1], $arglist[2], $arglist[3]); |
|
6245 | 6245 | case 'EXRULE': |
6246 | - return $this->setExrule( $arglist[1], $arglist[2], $arglist[3] ); |
|
6246 | + return $this->setExrule($arglist[1], $arglist[2], $arglist[3]); |
|
6247 | 6247 | case 'FREEBUSY': |
6248 | - return $this->setFreebusy( $arglist[1], $arglist[2], $arglist[3], $arglist[4] ); |
|
6248 | + return $this->setFreebusy($arglist[1], $arglist[2], $arglist[3], $arglist[4]); |
|
6249 | 6249 | case 'GEO': |
6250 | - return $this->setGeo( $arglist[1], $arglist[2], $arglist[3] ); |
|
6250 | + return $this->setGeo($arglist[1], $arglist[2], $arglist[3]); |
|
6251 | 6251 | case 'LAST-MODIFIED': |
6252 | - return $this->setLastModified( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] ); |
|
6252 | + return $this->setLastModified($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7]); |
|
6253 | 6253 | case 'LOCATION': |
6254 | - return $this->setLocation( $arglist[1], $arglist[2] ); |
|
6254 | + return $this->setLocation($arglist[1], $arglist[2]); |
|
6255 | 6255 | case 'ORGANIZER': |
6256 | - return $this->setOrganizer( $arglist[1], $arglist[2] ); |
|
6256 | + return $this->setOrganizer($arglist[1], $arglist[2]); |
|
6257 | 6257 | case 'PERCENT-COMPLETE': |
6258 | - return $this->setPercentComplete( $arglist[1], $arglist[2] ); |
|
6258 | + return $this->setPercentComplete($arglist[1], $arglist[2]); |
|
6259 | 6259 | case 'PRIORITY': |
6260 | - return $this->setPriority( $arglist[1], $arglist[2] ); |
|
6260 | + return $this->setPriority($arglist[1], $arglist[2]); |
|
6261 | 6261 | case 'RDATE': |
6262 | - return $this->setRdate( $arglist[1], $arglist[2], $arglist[3] ); |
|
6262 | + return $this->setRdate($arglist[1], $arglist[2], $arglist[3]); |
|
6263 | 6263 | case 'RECURRENCE-ID': |
6264 | - return $this->setRecurrenceid( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] ); |
|
6264 | + return $this->setRecurrenceid($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8]); |
|
6265 | 6265 | case 'RELATED-TO': |
6266 | - return $this->setRelatedTo( $arglist[1], $arglist[2], $arglist[3] ); |
|
6266 | + return $this->setRelatedTo($arglist[1], $arglist[2], $arglist[3]); |
|
6267 | 6267 | case 'REPEAT': |
6268 | - return $this->setRepeat( $arglist[1], $arglist[2] ); |
|
6268 | + return $this->setRepeat($arglist[1], $arglist[2]); |
|
6269 | 6269 | case 'REQUEST-STATUS': |
6270 | - return $this->setRequestStatus( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5] ); |
|
6270 | + return $this->setRequestStatus($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5]); |
|
6271 | 6271 | case 'RESOURCES': |
6272 | - return $this->setResources( $arglist[1], $arglist[2], $arglist[3] ); |
|
6272 | + return $this->setResources($arglist[1], $arglist[2], $arglist[3]); |
|
6273 | 6273 | case 'RRULE': |
6274 | - return $this->setRrule( $arglist[1], $arglist[2], $arglist[3] ); |
|
6274 | + return $this->setRrule($arglist[1], $arglist[2], $arglist[3]); |
|
6275 | 6275 | case 'SEQUENCE': |
6276 | - return $this->setSequence( $arglist[1], $arglist[2] ); |
|
6276 | + return $this->setSequence($arglist[1], $arglist[2]); |
|
6277 | 6277 | case 'STATUS': |
6278 | - return $this->setStatus( $arglist[1], $arglist[2] ); |
|
6278 | + return $this->setStatus($arglist[1], $arglist[2]); |
|
6279 | 6279 | case 'SUMMARY': |
6280 | - return $this->setSummary( $arglist[1], $arglist[2] ); |
|
6280 | + return $this->setSummary($arglist[1], $arglist[2]); |
|
6281 | 6281 | case 'TRANSP': |
6282 | - return $this->setTransp( $arglist[1], $arglist[2] ); |
|
6282 | + return $this->setTransp($arglist[1], $arglist[2]); |
|
6283 | 6283 | case 'TRIGGER': |
6284 | - return $this->setTrigger( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8], $arglist[9], $arglist[10], $arglist[11] ); |
|
6284 | + return $this->setTrigger($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8], $arglist[9], $arglist[10], $arglist[11]); |
|
6285 | 6285 | case 'TZID': |
6286 | - return $this->setTzid( $arglist[1], $arglist[2] ); |
|
6286 | + return $this->setTzid($arglist[1], $arglist[2]); |
|
6287 | 6287 | case 'TZNAME': |
6288 | - return $this->setTzname( $arglist[1], $arglist[2], $arglist[3] ); |
|
6288 | + return $this->setTzname($arglist[1], $arglist[2], $arglist[3]); |
|
6289 | 6289 | case 'TZOFFSETFROM': |
6290 | - return $this->setTzoffsetfrom( $arglist[1], $arglist[2] ); |
|
6290 | + return $this->setTzoffsetfrom($arglist[1], $arglist[2]); |
|
6291 | 6291 | case 'TZOFFSETTO': |
6292 | - return $this->setTzoffsetto( $arglist[1], $arglist[2] ); |
|
6292 | + return $this->setTzoffsetto($arglist[1], $arglist[2]); |
|
6293 | 6293 | case 'TZURL': |
6294 | - return $this->setTzurl( $arglist[1], $arglist[2] ); |
|
6294 | + return $this->setTzurl($arglist[1], $arglist[2]); |
|
6295 | 6295 | case 'UID': |
6296 | - return $this->setUid( $arglist[1], $arglist[2] ); |
|
6296 | + return $this->setUid($arglist[1], $arglist[2]); |
|
6297 | 6297 | case 'URL': |
6298 | - return $this->setUrl( $arglist[1], $arglist[2] ); |
|
6298 | + return $this->setUrl($arglist[1], $arglist[2]); |
|
6299 | 6299 | default: |
6300 | - return $this->setXprop( $arglist[0], $arglist[1], $arglist[2] ); |
|
6300 | + return $this->setXprop($arglist[0], $arglist[1], $arglist[2]); |
|
6301 | 6301 | } |
6302 | 6302 | return FALSE; |
6303 | 6303 | } |
@@ -6311,18 +6311,18 @@ discard block |
||
6311 | 6311 | * @return bool FALSE if error occurs during parsing |
6312 | 6312 | * |
6313 | 6313 | */ |
6314 | - function parse( $unparsedtext=null ) { |
|
6315 | - if( $unparsedtext ) { |
|
6314 | + function parse($unparsedtext = null) { |
|
6315 | + if ($unparsedtext) { |
|
6316 | 6316 | $this->unparsed = array(); |
6317 | - if( is_array( $unparsedtext )) { |
|
6317 | + if (is_array($unparsedtext)) { |
|
6318 | 6318 | $comp = & $this; |
6319 | - foreach ( $unparsedtext as $line ) { |
|
6320 | - if( 'END:VALARM' == strtoupper( substr( $line, 0, 10 ))) { |
|
6321 | - $this->setComponent( $comp ); |
|
6322 | - $comp = & $this; |
|
6319 | + foreach ($unparsedtext as $line) { |
|
6320 | + if ('END:VALARM' == strtoupper(substr($line, 0, 10))) { |
|
6321 | + $this->setComponent($comp); |
|
6322 | + $comp = & $this; |
|
6323 | 6323 | continue; |
6324 | 6324 | } |
6325 | - elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) { |
|
6325 | + elseif ('BEGIN:VALARM' == strtoupper(substr($line, 0, 12))) { |
|
6326 | 6326 | $comp = new valarm(); |
6327 | 6327 | continue; |
6328 | 6328 | } |
@@ -6331,217 +6331,217 @@ discard block |
||
6331 | 6331 | } |
6332 | 6332 | } |
6333 | 6333 | else |
6334 | - $this->unparsed = array( trim( $unparsedtext )); |
|
6334 | + $this->unparsed = array(trim($unparsedtext)); |
|
6335 | 6335 | } |
6336 | - elseif( !isset( $this->unparsed )) |
|
6336 | + elseif (!isset($this->unparsed)) |
|
6337 | 6337 | $this->unparsed = array(); |
6338 | 6338 | /* concatenate property values spread over several lines */ |
6339 | 6339 | $lastix = -1; |
6340 | - $propnames = array( 'action', 'attach', 'attendee', 'categories', 'comment', 'completed' |
|
6340 | + $propnames = array('action', 'attach', 'attendee', 'categories', 'comment', 'completed' |
|
6341 | 6341 | , 'contact', 'class', 'created', 'description', 'dtend', 'dtstart' |
6342 | 6342 | , 'dtstamp', 'due', 'duration', 'exdate', 'exrule', 'freebusy', 'geo' |
6343 | 6343 | , 'last-modified', 'location', 'organizer', 'percent-complete' |
6344 | 6344 | , 'priority', 'rdate', 'recurrence-id', 'related-to', 'repeat' |
6345 | 6345 | , 'request-status', 'resources', 'rrule', 'sequence', 'status' |
6346 | 6346 | , 'summary', 'transp', 'trigger', 'tzid', 'tzname', 'tzoffsetfrom' |
6347 | - , 'tzoffsetto', 'tzurl', 'uid', 'url', 'x-' ); |
|
6348 | - $proprows = array(); |
|
6349 | - foreach( $this->unparsed as $line ) { |
|
6347 | + , 'tzoffsetto', 'tzurl', 'uid', 'url', 'x-'); |
|
6348 | + $proprows = array(); |
|
6349 | + foreach ($this->unparsed as $line) { |
|
6350 | 6350 | $newProp = FALSE; |
6351 | - foreach ( $propnames as $propname ) { |
|
6352 | - if( $propname == strtolower( substr( $line, 0, strlen( $propname )))) { |
|
6351 | + foreach ($propnames as $propname) { |
|
6352 | + if ($propname == strtolower(substr($line, 0, strlen($propname)))) { |
|
6353 | 6353 | $newProp = TRUE; |
6354 | 6354 | break; |
6355 | 6355 | } |
6356 | 6356 | } |
6357 | - if( $newProp ) { |
|
6357 | + if ($newProp) { |
|
6358 | 6358 | $newProp = FALSE; |
6359 | 6359 | $lastix++; |
6360 | - $proprows[$lastix] = $line; |
|
6360 | + $proprows[$lastix] = $line; |
|
6361 | 6361 | } |
6362 | 6362 | else { |
6363 | 6363 | /* remove line breaks */ |
6364 | - if(( '\n' == substr( $proprows[$lastix], -2 )) && |
|
6365 | - ( ' ' == substr( $line, 0, 1 ))) { |
|
6366 | - $proprows[$lastix] = substr( $proprows[$lastix], 0, strlen( $proprows[$lastix] ) - 2 ); |
|
6367 | - $line = substr( $line, 1 ); |
|
6364 | + if (('\n' == substr($proprows[$lastix], -2)) && |
|
6365 | + (' ' == substr($line, 0, 1))) { |
|
6366 | + $proprows[$lastix] = substr($proprows[$lastix], 0, strlen($proprows[$lastix]) - 2); |
|
6367 | + $line = substr($line, 1); |
|
6368 | 6368 | } |
6369 | 6369 | $proprows[$lastix] .= $line; |
6370 | 6370 | } |
6371 | 6371 | } |
6372 | 6372 | /* parse each property 'line' */ |
6373 | - foreach( $proprows as $line ) { |
|
6374 | - $line = str_replace( "\n ", '', $line ); |
|
6375 | - if( '\n' == substr( $line, -2 )) |
|
6376 | - $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
6373 | + foreach ($proprows as $line) { |
|
6374 | + $line = str_replace("\n ", '', $line); |
|
6375 | + if ('\n' == substr($line, -2)) |
|
6376 | + $line = substr($line, 0, strlen($line) - 2); |
|
6377 | 6377 | /* get propname, (problem with x-properties, otherwise in previous loop) */ |
6378 | 6378 | $cix = $propname = null; |
6379 | - for( $cix=0; $cix < strlen( $line ); $cix++ ) { |
|
6380 | - if( in_array( $line{$cix}, array( ':', ';' ))) |
|
6379 | + for ($cix = 0; $cix < strlen($line); $cix++) { |
|
6380 | + if (in_array($line{$cix}, array(':', ';'))) |
|
6381 | 6381 | break; |
6382 | 6382 | else { |
6383 | 6383 | $propname .= $line{$cix}; |
6384 | 6384 | } |
6385 | 6385 | } |
6386 | - if(( 'x-' == substr( $propname, 0, 2 )) || ( 'X-' == substr( $propname, 0, 2 ))) { |
|
6386 | + if (('x-' == substr($propname, 0, 2)) || ('X-' == substr($propname, 0, 2))) { |
|
6387 | 6387 | $propname2 = $propname; |
6388 | 6388 | $propname = 'X-'; |
6389 | 6389 | } |
6390 | 6390 | /* rest of the line is opt.params and value */ |
6391 | - $line = substr( $line, $cix ); |
|
6391 | + $line = substr($line, $cix); |
|
6392 | 6392 | /* separate attributes from value */ |
6393 | 6393 | $attr = array(); |
6394 | 6394 | $attrix = -1; |
6395 | - $strlen = strlen( $line ); |
|
6396 | - for( $cix=0; $cix < $strlen; $cix++ ) { |
|
6397 | - if(( ':' == $line{$cix} ) && |
|
6398 | - ( '://' != substr( $line, $cix, 3 )) && |
|
6399 | - ( 'mailto:' != strtolower( substr( $line, $cix - 6, 7 )))) { |
|
6395 | + $strlen = strlen($line); |
|
6396 | + for ($cix = 0; $cix < $strlen; $cix++) { |
|
6397 | + if ((':' == $line{$cix} ) && |
|
6398 | + ('://' != substr($line, $cix, 3)) && |
|
6399 | + ('mailto:' != strtolower(substr($line, $cix - 6, 7)))) { |
|
6400 | 6400 | $attrEnd = TRUE; |
6401 | - if(( $cix < ( $strlen - 4 )) && |
|
6402 | - ctype_digit( substr( $line, $cix+1, 4 ))) { // an URI with a (4pos) portnr?? |
|
6403 | - for( $c2ix = $cix; 3 < $c2ix; $c2ix-- ) { |
|
6404 | - if( '://' == substr( $line, $c2ix - 2, 3 )) { |
|
6401 | + if (($cix < ($strlen - 4)) && |
|
6402 | + ctype_digit(substr($line, $cix + 1, 4))) { // an URI with a (4pos) portnr?? |
|
6403 | + for ($c2ix = $cix; 3 < $c2ix; $c2ix--) { |
|
6404 | + if ('://' == substr($line, $c2ix - 2, 3)) { |
|
6405 | 6405 | $attrEnd = FALSE; |
6406 | 6406 | break; // an URI with a portnr!! |
6407 | 6407 | } |
6408 | 6408 | } |
6409 | 6409 | } |
6410 | - if( $attrEnd) { |
|
6411 | - $line = substr( $line, $cix + 1 ); |
|
6410 | + if ($attrEnd) { |
|
6411 | + $line = substr($line, $cix + 1); |
|
6412 | 6412 | break; |
6413 | 6413 | } |
6414 | 6414 | } |
6415 | - if( ';' == $line{$cix} ) |
|
6415 | + if (';' == $line{$cix} ) |
|
6416 | 6416 | $attr[++$attrix] = null; |
6417 | 6417 | else |
6418 | 6418 | $attr[$attrix] .= $line{$cix}; |
6419 | 6419 | } |
6420 | 6420 | /* make attributes in array format */ |
6421 | 6421 | $propattr = array(); |
6422 | - foreach( $attr as $attribute ) { |
|
6423 | - $attrsplit = explode( '=', $attribute, 2 ); |
|
6424 | - if( 1 < count( $attrsplit )) |
|
6422 | + foreach ($attr as $attribute) { |
|
6423 | + $attrsplit = explode('=', $attribute, 2); |
|
6424 | + if (1 < count($attrsplit)) |
|
6425 | 6425 | $propattr[$attrsplit[0]] = $attrsplit[1]; |
6426 | 6426 | else |
6427 | 6427 | $propattr[] = $attribute; |
6428 | 6428 | } |
6429 | 6429 | /* call setProperty( $propname.. . */ |
6430 | - switch( $propname ) { |
|
6430 | + switch ($propname) { |
|
6431 | 6431 | case 'ATTENDEE': |
6432 | - foreach( $propattr as $pix => $attr ) { |
|
6433 | - $attr2 = explode( ',', $attr ); |
|
6434 | - if( 1 < count( $attr2 )) |
|
6432 | + foreach ($propattr as $pix => $attr) { |
|
6433 | + $attr2 = explode(',', $attr); |
|
6434 | + if (1 < count($attr2)) |
|
6435 | 6435 | $propattr[$pix] = $attr2; |
6436 | 6436 | } |
6437 | - $this->setProperty( $propname, $line, $propattr ); |
|
6437 | + $this->setProperty($propname, $line, $propattr); |
|
6438 | 6438 | break; |
6439 | 6439 | case 'CATEGORIES': |
6440 | 6440 | case 'RESOURCES': |
6441 | - if( FALSE !== strpos( $line, ',' )) { |
|
6442 | - $content = explode( ',', $line ); |
|
6443 | - $clen = count( $content ); |
|
6444 | - for( $cix = 0; $cix < $clen; $cix++ ) { |
|
6445 | - if( "\\" == substr($content[$cix], -1)) { |
|
6441 | + if (FALSE !== strpos($line, ',')) { |
|
6442 | + $content = explode(',', $line); |
|
6443 | + $clen = count($content); |
|
6444 | + for ($cix = 0; $cix < $clen; $cix++) { |
|
6445 | + if ("\\" == substr($content[$cix], -1)) { |
|
6446 | 6446 | $content[$cix] .= ','.$content[$cix + 1]; |
6447 | 6447 | unset($content[$cix + 1]); |
6448 | 6448 | $cix++; |
6449 | 6449 | } |
6450 | 6450 | } |
6451 | - if( 1 < count( $content )) { |
|
6452 | - $content = array_values( $content ); |
|
6453 | - foreach( $content as $cix => $contentPart ) |
|
6454 | - $content[$cix] = $this->_strunrep( $contentPart ); |
|
6455 | - $this->setProperty( $propname, $content, $propattr ); |
|
6451 | + if (1 < count($content)) { |
|
6452 | + $content = array_values($content); |
|
6453 | + foreach ($content as $cix => $contentPart) |
|
6454 | + $content[$cix] = $this->_strunrep($contentPart); |
|
6455 | + $this->setProperty($propname, $content, $propattr); |
|
6456 | 6456 | break; |
6457 | 6457 | } |
6458 | 6458 | else |
6459 | - $line = reset( $content ); |
|
6459 | + $line = reset($content); |
|
6460 | 6460 | } |
6461 | 6461 | //no break |
6462 | 6462 | case 'X-': |
6463 | - $propname = ( isset( $propname2 )) ? $propname2 : $propname; |
|
6463 | + $propname = (isset($propname2)) ? $propname2 : $propname; |
|
6464 | 6464 | //no break |
6465 | 6465 | case 'COMMENT': |
6466 | 6466 | case 'CONTACT': |
6467 | 6467 | case 'DESCRIPTION': |
6468 | 6468 | case 'LOCATION': |
6469 | 6469 | case 'SUMMARY': |
6470 | - if( empty( $line )) |
|
6470 | + if (empty($line)) |
|
6471 | 6471 | $propattr = null; |
6472 | - $this->setProperty( $propname, $this->_strunrep( $line ), $propattr ); |
|
6473 | - unset( $propname2 ); |
|
6472 | + $this->setProperty($propname, $this->_strunrep($line), $propattr); |
|
6473 | + unset($propname2); |
|
6474 | 6474 | break; |
6475 | 6475 | case 'REQUEST-STATUS': |
6476 | - $values = explode( ';', $line, 3 ); |
|
6477 | - $values[1] = ( !isset( $values[1] )) ? null : $this->_strunrep( $values[1] ); |
|
6478 | - $values[2] = ( !isset( $values[2] )) ? null : $this->_strunrep( $values[2] ); |
|
6479 | - $this->setProperty( $propname |
|
6476 | + $values = explode(';', $line, 3); |
|
6477 | + $values[1] = (!isset($values[1])) ? null : $this->_strunrep($values[1]); |
|
6478 | + $values[2] = (!isset($values[2])) ? null : $this->_strunrep($values[2]); |
|
6479 | + $this->setProperty($propname |
|
6480 | 6480 | , $values[0] // statcode |
6481 | 6481 | , $values[1] // statdesc |
6482 | 6482 | , $values[2] // extdata |
6483 | - , $propattr ); |
|
6483 | + , $propattr); |
|
6484 | 6484 | break; |
6485 | 6485 | case 'FREEBUSY': |
6486 | - $fbtype = ( isset( $propattr['FBTYPE'] )) ? $propattr['FBTYPE'] : ''; // force setting default, if missing |
|
6487 | - unset( $propattr['FBTYPE'] ); |
|
6488 | - $values = explode( ',', $line ); |
|
6489 | - foreach( $values as $vix => $value ) { |
|
6490 | - $value2 = explode( '/', $value ); |
|
6491 | - if( 1 < count( $value2 )) |
|
6486 | + $fbtype = (isset($propattr['FBTYPE'])) ? $propattr['FBTYPE'] : ''; // force setting default, if missing |
|
6487 | + unset($propattr['FBTYPE']); |
|
6488 | + $values = explode(',', $line); |
|
6489 | + foreach ($values as $vix => $value) { |
|
6490 | + $value2 = explode('/', $value); |
|
6491 | + if (1 < count($value2)) |
|
6492 | 6492 | $values[$vix] = $value2; |
6493 | 6493 | } |
6494 | - $this->setProperty( $propname, $fbtype, $values, $propattr ); |
|
6494 | + $this->setProperty($propname, $fbtype, $values, $propattr); |
|
6495 | 6495 | break; |
6496 | 6496 | case 'GEO': |
6497 | - $value = explode( ';', $line, 2 ); |
|
6498 | - if( 2 > count( $value )) |
|
6497 | + $value = explode(';', $line, 2); |
|
6498 | + if (2 > count($value)) |
|
6499 | 6499 | $value[1] = null; |
6500 | - $this->setProperty( $propname, $value[0], $value[1], $propattr ); |
|
6500 | + $this->setProperty($propname, $value[0], $value[1], $propattr); |
|
6501 | 6501 | break; |
6502 | 6502 | case 'EXDATE': |
6503 | - $values = ( !empty( $line )) ? explode( ',', $line ) : null; |
|
6504 | - $this->setProperty( $propname, $values, $propattr ); |
|
6503 | + $values = (!empty($line)) ? explode(',', $line) : null; |
|
6504 | + $this->setProperty($propname, $values, $propattr); |
|
6505 | 6505 | break; |
6506 | 6506 | case 'RDATE': |
6507 | - if( empty( $line )) { |
|
6508 | - $this->setProperty( $propname, $line, $propattr ); |
|
6507 | + if (empty($line)) { |
|
6508 | + $this->setProperty($propname, $line, $propattr); |
|
6509 | 6509 | break; |
6510 | 6510 | } |
6511 | - $values = explode( ',', $line ); |
|
6512 | - foreach( $values as $vix => $value ) { |
|
6513 | - $value2 = explode( '/', $value ); |
|
6514 | - if( 1 < count( $value2 )) |
|
6511 | + $values = explode(',', $line); |
|
6512 | + foreach ($values as $vix => $value) { |
|
6513 | + $value2 = explode('/', $value); |
|
6514 | + if (1 < count($value2)) |
|
6515 | 6515 | $values[$vix] = $value2; |
6516 | 6516 | } |
6517 | - $this->setProperty( $propname, $values, $propattr ); |
|
6517 | + $this->setProperty($propname, $values, $propattr); |
|
6518 | 6518 | break; |
6519 | 6519 | case 'EXRULE': |
6520 | 6520 | case 'RRULE': |
6521 | - $values = explode( ';', $line ); |
|
6521 | + $values = explode(';', $line); |
|
6522 | 6522 | $recur = array(); |
6523 | - foreach( $values as $value2 ) { |
|
6524 | - if( empty( $value2 )) |
|
6523 | + foreach ($values as $value2) { |
|
6524 | + if (empty($value2)) |
|
6525 | 6525 | continue; // ;-char in ending position ??? |
6526 | - $value3 = explode( '=', $value2, 2 ); |
|
6527 | - $rulelabel = strtoupper( $value3[0] ); |
|
6528 | - switch( $rulelabel ) { |
|
6526 | + $value3 = explode('=', $value2, 2); |
|
6527 | + $rulelabel = strtoupper($value3[0]); |
|
6528 | + switch ($rulelabel) { |
|
6529 | 6529 | case 'BYDAY': |
6530 | - $value4 = explode( ',', $value3[1] ); |
|
6531 | - if( 1 < count( $value4 )) { |
|
6532 | - foreach( $value4 as $v5ix => $value5 ) { |
|
6530 | + $value4 = explode(',', $value3[1]); |
|
6531 | + if (1 < count($value4)) { |
|
6532 | + foreach ($value4 as $v5ix => $value5) { |
|
6533 | 6533 | $value6 = array(); |
6534 | 6534 | $dayno = $dayname = null; |
6535 | - $value5 = trim( (string) $value5 ); |
|
6536 | - if(( ctype_alpha( substr( $value5, -1 ))) && |
|
6537 | - ( ctype_alpha( substr( $value5, -2, 1 )))) { |
|
6538 | - $dayname = substr( $value5, -2, 2 ); |
|
6539 | - if( 2 < strlen( $value5 )) |
|
6540 | - $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
6535 | + $value5 = trim((string) $value5); |
|
6536 | + if ((ctype_alpha(substr($value5, -1))) && |
|
6537 | + (ctype_alpha(substr($value5, -2, 1)))) { |
|
6538 | + $dayname = substr($value5, -2, 2); |
|
6539 | + if (2 < strlen($value5)) |
|
6540 | + $dayno = substr($value5, 0, (strlen($value5) - 2)); |
|
6541 | 6541 | } |
6542 | - if( $dayno ) |
|
6542 | + if ($dayno) |
|
6543 | 6543 | $value6[] = $dayno; |
6544 | - if( $dayname ) |
|
6544 | + if ($dayname) |
|
6545 | 6545 | $value6['DAY'] = $dayname; |
6546 | 6546 | $value4[$v5ix] = $value6; |
6547 | 6547 | } |
@@ -6549,39 +6549,39 @@ discard block |
||
6549 | 6549 | else { |
6550 | 6550 | $value4 = array(); |
6551 | 6551 | $dayno = $dayname = null; |
6552 | - $value5 = trim( (string) $value3[1] ); |
|
6553 | - if(( ctype_alpha( substr( $value5, -1 ))) && |
|
6554 | - ( ctype_alpha( substr( $value5, -2, 1 )))) { |
|
6555 | - $dayname = substr( $value5, -2, 2 ); |
|
6556 | - if( 2 < strlen( $value5 )) |
|
6557 | - $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
6552 | + $value5 = trim((string) $value3[1]); |
|
6553 | + if ((ctype_alpha(substr($value5, -1))) && |
|
6554 | + (ctype_alpha(substr($value5, -2, 1)))) { |
|
6555 | + $dayname = substr($value5, -2, 2); |
|
6556 | + if (2 < strlen($value5)) |
|
6557 | + $dayno = substr($value5, 0, (strlen($value5) - 2)); |
|
6558 | 6558 | } |
6559 | - if( $dayno ) |
|
6559 | + if ($dayno) |
|
6560 | 6560 | $value4[] = $dayno; |
6561 | - if( $dayname ) |
|
6561 | + if ($dayname) |
|
6562 | 6562 | $value4['DAY'] = $dayname; |
6563 | 6563 | } |
6564 | 6564 | $recur[$rulelabel] = $value4; |
6565 | 6565 | break; |
6566 | 6566 | default: |
6567 | - $value4 = explode( ',', $value3[1] ); |
|
6568 | - if( 1 < count( $value4 )) |
|
6567 | + $value4 = explode(',', $value3[1]); |
|
6568 | + if (1 < count($value4)) |
|
6569 | 6569 | $value3[1] = $value4; |
6570 | 6570 | $recur[$rulelabel] = $value3[1]; |
6571 | 6571 | break; |
6572 | 6572 | } // end - switch $rulelabel |
6573 | 6573 | } // end - foreach( $values.. . |
6574 | - $this->setProperty( $propname, $recur, $propattr ); |
|
6574 | + $this->setProperty($propname, $recur, $propattr); |
|
6575 | 6575 | break; |
6576 | 6576 | default: |
6577 | - $this->setProperty( $propname, $line, $propattr ); |
|
6577 | + $this->setProperty($propname, $line, $propattr); |
|
6578 | 6578 | break; |
6579 | 6579 | } // end switch( $propname.. . |
6580 | 6580 | } // end - foreach( $proprows.. . |
6581 | - unset( $this->unparsed, $proprows ); |
|
6582 | - if( isset( $this->components ) && is_array( $this->components ) && ( 0 < count( $this->components ))) { |
|
6583 | - for( $six = 0; $six < count( $this->components ); $six++ ) { |
|
6584 | - if( !empty( $this->components[$six]->unparsed )) |
|
6581 | + unset($this->unparsed, $proprows); |
|
6582 | + if (isset($this->components) && is_array($this->components) && (0 < count($this->components))) { |
|
6583 | + for ($six = 0; $six < count($this->components); $six++) { |
|
6584 | + if (!empty($this->components[$six]->unparsed)) |
|
6585 | 6585 | $this->components[$six]->parse(); |
6586 | 6586 | } |
6587 | 6587 | } |
@@ -6598,7 +6598,7 @@ discard block |
||
6598 | 6598 | function copy() { |
6599 | 6599 | $serialized_contents = serialize($this); |
6600 | 6600 | $copy = unserialize($serialized_contents); |
6601 | - unset( $copy->propix ); |
|
6601 | + unset($copy->propix); |
|
6602 | 6602 | return $copy; |
6603 | 6603 | } |
6604 | 6604 | /*********************************************************************************/ |
@@ -6612,34 +6612,34 @@ discard block |
||
6612 | 6612 | * @param mixed $arg2 optional, ordno if arg1 = component type |
6613 | 6613 | * @return void |
6614 | 6614 | */ |
6615 | - function deleteComponent( $arg1, $arg2=FALSE ) { |
|
6616 | - if( !isset( $this->components )) return FALSE; |
|
6615 | + function deleteComponent($arg1, $arg2 = FALSE) { |
|
6616 | + if (!isset($this->components)) return FALSE; |
|
6617 | 6617 | $argType = $index = null; |
6618 | - if ( ctype_digit( (string) $arg1 )) { |
|
6618 | + if (ctype_digit((string) $arg1)) { |
|
6619 | 6619 | $argType = 'INDEX'; |
6620 | 6620 | $index = (int) $arg1 - 1; |
6621 | 6621 | } |
6622 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6623 | - $argType = strtolower( $arg1 ); |
|
6624 | - $index = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0; |
|
6622 | + elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) { |
|
6623 | + $argType = strtolower($arg1); |
|
6624 | + $index = (!empty($arg2) && ctype_digit((string) $arg2)) ? ((int) $arg2 - 1) : 0; |
|
6625 | 6625 | } |
6626 | 6626 | $cix2dC = 0; |
6627 | - foreach ( $this->components as $cix => $component) { |
|
6628 | - if( empty( $component )) continue; |
|
6629 | - unset( $component->propix ); |
|
6630 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
|
6631 | - unset( $this->components[$cix] ); |
|
6627 | + foreach ($this->components as $cix => $component) { |
|
6628 | + if (empty($component)) continue; |
|
6629 | + unset($component->propix); |
|
6630 | + if (('INDEX' == $argType) && ($index == $cix)) { |
|
6631 | + unset($this->components[$cix]); |
|
6632 | 6632 | return TRUE; |
6633 | 6633 | } |
6634 | - elseif( $argType == $component->objName ) { |
|
6635 | - if( $index == $cix2dC ) { |
|
6636 | - unset( $this->components[$cix] ); |
|
6634 | + elseif ($argType == $component->objName) { |
|
6635 | + if ($index == $cix2dC) { |
|
6636 | + unset($this->components[$cix]); |
|
6637 | 6637 | return TRUE; |
6638 | 6638 | } |
6639 | 6639 | $cix2dC++; |
6640 | 6640 | } |
6641 | - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
6642 | - unset( $this->components[$cix] ); |
|
6641 | + elseif (!$argType && ($arg1 == $component->getProperty('uid'))) { |
|
6642 | + unset($this->components[$cix]); |
|
6643 | 6643 | return TRUE; |
6644 | 6644 | } |
6645 | 6645 | } |
@@ -6654,50 +6654,50 @@ discard block |
||
6654 | 6654 | * @param mixed $arg2 optional, ordno if arg1 = component type |
6655 | 6655 | * @return object |
6656 | 6656 | */ |
6657 | - function getComponent ( $arg1=FALSE, $arg2=FALSE ) { |
|
6658 | - if( !isset( $this->components )) return FALSE; |
|
6657 | + function getComponent($arg1 = FALSE, $arg2 = FALSE) { |
|
6658 | + if (!isset($this->components)) return FALSE; |
|
6659 | 6659 | $index = $argType = null; |
6660 | - if ( !$arg1 ) { |
|
6660 | + if (!$arg1) { |
|
6661 | 6661 | $argType = 'INDEX'; |
6662 | 6662 | $index = $this->compix['INDEX'] = |
6663 | - ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1; |
|
6663 | + (isset($this->compix['INDEX'])) ? $this->compix['INDEX'] + 1 : 1; |
|
6664 | 6664 | } |
6665 | - elseif ( ctype_digit( (string) $arg1 )) { |
|
6665 | + elseif (ctype_digit((string) $arg1)) { |
|
6666 | 6666 | $argType = 'INDEX'; |
6667 | 6667 | $index = (int) $arg1; |
6668 | - unset( $this->compix ); |
|
6668 | + unset($this->compix); |
|
6669 | 6669 | } |
6670 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6671 | - unset( $this->compix['INDEX'] ); |
|
6672 | - $argType = strtolower( $arg1 ); |
|
6673 | - if( !$arg2 ) |
|
6670 | + elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) { |
|
6671 | + unset($this->compix['INDEX']); |
|
6672 | + $argType = strtolower($arg1); |
|
6673 | + if (!$arg2) |
|
6674 | 6674 | $index = $this->compix[$argType] = |
6675 | - ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1; |
|
6675 | + (isset($this->compix[$argType])) ? $this->compix[$argType] + 1 : 1; |
|
6676 | 6676 | else |
6677 | 6677 | $index = (int) $arg2; |
6678 | 6678 | } |
6679 | - $index -= 1; |
|
6680 | - $ckeys = array_keys( $this->components ); |
|
6681 | - if( !empty( $index) && ( $index > end( $ckeys ))) |
|
6679 | + $index -= 1; |
|
6680 | + $ckeys = array_keys($this->components); |
|
6681 | + if (!empty($index) && ($index > end($ckeys))) |
|
6682 | 6682 | return FALSE; |
6683 | 6683 | $cix2gC = 0; |
6684 | - foreach( $this->components as $cix => $component ) { |
|
6685 | - if( empty( $component )) continue; |
|
6686 | - unset( $component->propix ); |
|
6687 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) |
|
6684 | + foreach ($this->components as $cix => $component) { |
|
6685 | + if (empty($component)) continue; |
|
6686 | + unset($component->propix); |
|
6687 | + if (('INDEX' == $argType) && ($index == $cix)) |
|
6688 | 6688 | return $component->copy(); |
6689 | - elseif( $argType == $component->objName ) { |
|
6690 | - if( $index == $cix2gC ) |
|
6689 | + elseif ($argType == $component->objName) { |
|
6690 | + if ($index == $cix2gC) |
|
6691 | 6691 | return $component->copy(); |
6692 | 6692 | $cix2gC++; |
6693 | 6693 | } |
6694 | - elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) { |
|
6695 | - unset( $component->propix ); |
|
6694 | + elseif (!$argType && ($arg1 == $component->getProperty('uid'))) { |
|
6695 | + unset($component->propix); |
|
6696 | 6696 | return $component->copy(); |
6697 | 6697 | } |
6698 | 6698 | } |
6699 | 6699 | /* not found.. . */ |
6700 | - unset( $this->compix ); |
|
6700 | + unset($this->compix); |
|
6701 | 6701 | return false; |
6702 | 6702 | } |
6703 | 6703 | /** |
@@ -6708,8 +6708,8 @@ discard block |
||
6708 | 6708 | * @param object $component calendar component |
6709 | 6709 | * @return void |
6710 | 6710 | */ |
6711 | - function addSubComponent ( $component ) { |
|
6712 | - $this->setComponent( $component ); |
|
6711 | + function addSubComponent($component) { |
|
6712 | + $this->setComponent($component); |
|
6713 | 6713 | } |
6714 | 6714 | /** |
6715 | 6715 | * add calendar component as subcomponent to container for subcomponents |
@@ -6721,49 +6721,49 @@ discard block |
||
6721 | 6721 | * @param mixed $arg2 optional, ordno if arg1 = component type |
6722 | 6722 | * @return bool |
6723 | 6723 | */ |
6724 | - function setComponent( $component, $arg1=FALSE, $arg2=FALSE ) { |
|
6725 | - if( !isset( $this->components )) return FALSE; |
|
6726 | - if( '' >= $component->getConfig( 'language')) |
|
6727 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
6728 | - $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
|
6729 | - $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
|
6730 | - $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
|
6731 | - $component->setConfig( 'format', $this->getConfig( 'format' )); |
|
6732 | - if( !in_array( $component->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
6733 | - unset( $component->propix ); |
|
6724 | + function setComponent($component, $arg1 = FALSE, $arg2 = FALSE) { |
|
6725 | + if (!isset($this->components)) return FALSE; |
|
6726 | + if ('' >= $component->getConfig('language')) |
|
6727 | + $component->setConfig('language', $this->getConfig('language')); |
|
6728 | + $component->setConfig('allowEmpty', $this->getConfig('allowEmpty')); |
|
6729 | + $component->setConfig('nl', $this->getConfig('nl')); |
|
6730 | + $component->setConfig('unique_id', $this->getConfig('unique_id')); |
|
6731 | + $component->setConfig('format', $this->getConfig('format')); |
|
6732 | + if (!in_array($component->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) { |
|
6733 | + unset($component->propix); |
|
6734 | 6734 | /* make sure dtstamp and uid is set */ |
6735 | - $dummy = $component->getProperty( 'dtstamp' ); |
|
6736 | - $dummy = $component->getProperty( 'uid' ); |
|
6735 | + $dummy = $component->getProperty('dtstamp'); |
|
6736 | + $dummy = $component->getProperty('uid'); |
|
6737 | 6737 | } |
6738 | - if( !$arg1 ) { |
|
6738 | + if (!$arg1) { |
|
6739 | 6739 | $this->components[] = $component->copy(); |
6740 | 6740 | return TRUE; |
6741 | 6741 | } |
6742 | 6742 | $argType = $index = null; |
6743 | - if ( ctype_digit( (string) $arg1 )) { |
|
6743 | + if (ctype_digit((string) $arg1)) { |
|
6744 | 6744 | $argType = 'INDEX'; |
6745 | 6745 | $index = (int) $arg1 - 1; |
6746 | 6746 | } |
6747 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6748 | - $argType = strtolower( $arg1 ); |
|
6749 | - $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0; |
|
6747 | + elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) { |
|
6748 | + $argType = strtolower($arg1); |
|
6749 | + $index = (ctype_digit((string) $arg2)) ? ((int) $arg2) - 1 : 0; |
|
6750 | 6750 | } |
6751 | 6751 | $cix2sC = 0; |
6752 | - foreach ( $this->components as $cix => $component2 ) { |
|
6753 | - if( empty( $component2 )) continue; |
|
6754 | - unset( $component2->propix ); |
|
6755 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
|
6752 | + foreach ($this->components as $cix => $component2) { |
|
6753 | + if (empty($component2)) continue; |
|
6754 | + unset($component2->propix); |
|
6755 | + if (('INDEX' == $argType) && ($index == $cix)) { |
|
6756 | 6756 | $this->components[$cix] = $component->copy(); |
6757 | 6757 | return TRUE; |
6758 | 6758 | } |
6759 | - elseif( $argType == $component2->objName ) { |
|
6760 | - if( $index == $cix2sC ) { |
|
6759 | + elseif ($argType == $component2->objName) { |
|
6760 | + if ($index == $cix2sC) { |
|
6761 | 6761 | $this->components[$cix] = $component->copy(); |
6762 | 6762 | return TRUE; |
6763 | 6763 | } |
6764 | 6764 | $cix2sC++; |
6765 | 6765 | } |
6766 | - elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) { |
|
6766 | + elseif (!$argType && ($arg1 == $component2->getProperty('uid'))) { |
|
6767 | 6767 | $this->components[$cix] = $component->copy(); |
6768 | 6768 | return TRUE; |
6769 | 6769 | } |
@@ -6781,15 +6781,15 @@ discard block |
||
6781 | 6781 | */ |
6782 | 6782 | function createSubComponent() { |
6783 | 6783 | $output = null; |
6784 | - foreach( $this->components as $component ) { |
|
6785 | - if( empty( $component )) continue; |
|
6786 | - if( '' >= $component->getConfig( 'language')) |
|
6787 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
6788 | - $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
|
6789 | - $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
|
6790 | - $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
|
6791 | - $component->setConfig( 'format', $this->getConfig( 'format' )); |
|
6792 | - $output .= $component->createComponent( $this->xcaldecl ); |
|
6784 | + foreach ($this->components as $component) { |
|
6785 | + if (empty($component)) continue; |
|
6786 | + if ('' >= $component->getConfig('language')) |
|
6787 | + $component->setConfig('language', $this->getConfig('language')); |
|
6788 | + $component->setConfig('allowEmpty', $this->getConfig('allowEmpty')); |
|
6789 | + $component->setConfig('nl', $this->getConfig('nl')); |
|
6790 | + $component->setConfig('unique_id', $this->getConfig('unique_id')); |
|
6791 | + $component->setConfig('format', $this->getConfig('format')); |
|
6792 | + $output .= $component->createComponent($this->xcaldecl); |
|
6793 | 6793 | } |
6794 | 6794 | return $output; |
6795 | 6795 | } |
@@ -6816,21 +6816,21 @@ discard block |
||
6816 | 6816 | * @param string $value |
6817 | 6817 | * @return string |
6818 | 6818 | */ |
6819 | - function _size75( $string ) { |
|
6820 | - $strlen = strlen( $string ); |
|
6819 | + function _size75($string) { |
|
6820 | + $strlen = strlen($string); |
|
6821 | 6821 | $tmp = $string; |
6822 | 6822 | $string = null; |
6823 | - while( $strlen > 75 ) { |
|
6823 | + while ($strlen > 75) { |
|
6824 | 6824 | $breakAtChar = 75; |
6825 | - if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' ) |
|
6825 | + if (substr($tmp, ($breakAtChar - 1), strlen('\n')) == '\n') |
|
6826 | 6826 | $breakAtChar = $breakAtChar - 1; |
6827 | - $string .= substr( $tmp, 0, $breakAtChar ); |
|
6827 | + $string .= substr($tmp, 0, $breakAtChar); |
|
6828 | 6828 | $string .= $this->nl; |
6829 | - $tmp = ' '.substr( $tmp, $breakAtChar ); |
|
6830 | - $strlen = strlen( $tmp ); |
|
6829 | + $tmp = ' '.substr($tmp, $breakAtChar); |
|
6830 | + $strlen = strlen($tmp); |
|
6831 | 6831 | } // while |
6832 | - $string .= rtrim( $tmp ); // the rest |
|
6833 | - if( $this->nl != substr( $string, ( 0 - strlen( $this->nl )))) |
|
6832 | + $string .= rtrim($tmp); // the rest |
|
6833 | + if ($this->nl != substr($string, (0 - strlen($this->nl)))) |
|
6834 | 6834 | $string .= $this->nl; |
6835 | 6835 | return $string; |
6836 | 6836 | } |
@@ -6842,38 +6842,38 @@ discard block |
||
6842 | 6842 | * @param string $string |
6843 | 6843 | * @return string |
6844 | 6844 | */ |
6845 | - function _strrep( $string ) { |
|
6846 | - switch( $this->format ) { |
|
6845 | + function _strrep($string) { |
|
6846 | + switch ($this->format) { |
|
6847 | 6847 | case 'xcal': |
6848 | - $string = str_replace( '\n', $this->nl, $string); |
|
6849 | - $string = htmlspecialchars( strip_tags( stripslashes( urldecode ( $string )))); |
|
6848 | + $string = str_replace('\n', $this->nl, $string); |
|
6849 | + $string = htmlspecialchars(strip_tags(stripslashes(urldecode($string)))); |
|
6850 | 6850 | break; |
6851 | 6851 | default: |
6852 | 6852 | $pos = 0; |
6853 | - while( $pos <= strlen( $string )) { |
|
6854 | - $pos = strpos( $string, "\\", $pos ); |
|
6855 | - if( FALSE === $pos ) |
|
6853 | + while ($pos <= strlen($string)) { |
|
6854 | + $pos = strpos($string, "\\", $pos); |
|
6855 | + if (FALSE === $pos) |
|
6856 | 6856 | break; |
6857 | - if( !in_array( $string{($pos + 1)}, array( 'n', 'N', 'r', ',', ';' ))) { |
|
6858 | - $string = substr( $string, 0, $pos )."\\".substr( $string, ( $pos + 1 )); |
|
6857 | + if (!in_array($string{($pos + 1)}, array('n', 'N', 'r', ',', ';'))) { |
|
6858 | + $string = substr($string, 0, $pos)."\\".substr($string, ($pos + 1)); |
|
6859 | 6859 | $pos += 1; |
6860 | 6860 | } |
6861 | 6861 | $pos += 1; |
6862 | 6862 | } |
6863 | - if( FALSE !== strpos( $string, '"' )) |
|
6864 | - $string = str_replace('"', "'", $string); |
|
6865 | - if( FALSE !== strpos( $string, ',' )) |
|
6866 | - $string = str_replace(',', '\,', $string); |
|
6867 | - if( FALSE !== strpos( $string, ';' )) |
|
6868 | - $string = str_replace(';', '\;', $string); |
|
6869 | - if( FALSE !== strpos( $string, "\r\n" )) |
|
6870 | - $string = str_replace( "\r\n", '\n', $string); |
|
6871 | - elseif( FALSE !== strpos( $string, "\r" )) |
|
6872 | - $string = str_replace( "\r", '\n', $string); |
|
6873 | - if( FALSE !== strpos( $string, '\N' )) |
|
6874 | - $string = str_replace( '\N', '\n', $string); |
|
6863 | + if (FALSE !== strpos($string, '"')) |
|
6864 | + $string = str_replace('"', "'", $string); |
|
6865 | + if (FALSE !== strpos($string, ',')) |
|
6866 | + $string = str_replace(',', '\,', $string); |
|
6867 | + if (FALSE !== strpos($string, ';')) |
|
6868 | + $string = str_replace(';', '\;', $string); |
|
6869 | + if (FALSE !== strpos($string, "\r\n")) |
|
6870 | + $string = str_replace("\r\n", '\n', $string); |
|
6871 | + elseif (FALSE !== strpos($string, "\r")) |
|
6872 | + $string = str_replace("\r", '\n', $string); |
|
6873 | + if (FALSE !== strpos($string, '\N')) |
|
6874 | + $string = str_replace('\N', '\n', $string); |
|
6875 | 6875 | // if( FALSE !== strpos( $string, $this->nl )) |
6876 | - $string = str_replace( $this->nl, '\n', $string); |
|
6876 | + $string = str_replace($this->nl, '\n', $string); |
|
6877 | 6877 | break; |
6878 | 6878 | } |
6879 | 6879 | return $string; |
@@ -6886,10 +6886,10 @@ discard block |
||
6886 | 6886 | * @param string $string |
6887 | 6887 | * @return string |
6888 | 6888 | */ |
6889 | - function _strunrep( $string ) { |
|
6890 | - $string = str_replace( '\\\\', '\\', $string); |
|
6891 | - $string = str_replace( '\,', ',', $string); |
|
6892 | - $string = str_replace( '\;', ';', $string); |
|
6889 | + function _strunrep($string) { |
|
6890 | + $string = str_replace('\\\\', '\\', $string); |
|
6891 | + $string = str_replace('\,', ',', $string); |
|
6892 | + $string = str_replace('\;', ';', $string); |
|
6893 | 6893 | // $string = str_replace( '\n', $this->nl, $string); // ?? |
6894 | 6894 | return $string; |
6895 | 6895 | } |
@@ -6986,7 +6986,7 @@ discard block |
||
6986 | 6986 | * @param array $xcaldecl |
6987 | 6987 | * @return string |
6988 | 6988 | */ |
6989 | - function createComponent( &$xcaldecl ) { |
|
6989 | + function createComponent(&$xcaldecl) { |
|
6990 | 6990 | $objectname = $this->_createFormat(); |
6991 | 6991 | $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; |
6992 | 6992 | $component .= $this->createUid(); |
@@ -7023,8 +7023,8 @@ discard block |
||
7023 | 7023 | $component .= $this->createXprop(); |
7024 | 7024 | $component .= $this->createSubComponent(); |
7025 | 7025 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7026 | - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
|
7027 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7026 | + if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) { |
|
7027 | + foreach ($this->xcaldecl as $localxcaldecl) |
|
7028 | 7028 | $xcaldecl[] = $localxcaldecl; |
7029 | 7029 | } |
7030 | 7030 | return $component; |
@@ -7123,7 +7123,7 @@ discard block |
||
7123 | 7123 | * @param array $xcaldecl |
7124 | 7124 | * @return string |
7125 | 7125 | */ |
7126 | - function createComponent( &$xcaldecl ) { |
|
7126 | + function createComponent(&$xcaldecl) { |
|
7127 | 7127 | $objectname = $this->_createFormat(); |
7128 | 7128 | $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; |
7129 | 7129 | $component .= $this->createUid(); |
@@ -7161,8 +7161,8 @@ discard block |
||
7161 | 7161 | $component .= $this->createXprop(); |
7162 | 7162 | $component .= $this->createSubComponent(); |
7163 | 7163 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7164 | - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
|
7165 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7164 | + if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) { |
|
7165 | + foreach ($this->xcaldecl as $localxcaldecl) |
|
7166 | 7166 | $xcaldecl[] = $localxcaldecl; |
7167 | 7167 | } |
7168 | 7168 | return $component; |
@@ -7241,7 +7241,7 @@ discard block |
||
7241 | 7241 | * @param array $xcaldecl |
7242 | 7242 | * @return string |
7243 | 7243 | */ |
7244 | - function createComponent( &$xcaldecl ) { |
|
7244 | + function createComponent(&$xcaldecl) { |
|
7245 | 7245 | $objectname = $this->_createFormat(); |
7246 | 7246 | $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; |
7247 | 7247 | $component .= $this->createUid(); |
@@ -7270,8 +7270,8 @@ discard block |
||
7270 | 7270 | $component .= $this->createUrl(); |
7271 | 7271 | $component .= $this->createXprop(); |
7272 | 7272 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7273 | - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
|
7274 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7273 | + if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) { |
|
7274 | + foreach ($this->xcaldecl as $localxcaldecl) |
|
7275 | 7275 | $xcaldecl[] = $localxcaldecl; |
7276 | 7276 | } |
7277 | 7277 | return $component; |
@@ -7328,7 +7328,7 @@ discard block |
||
7328 | 7328 | * @param array $xcaldecl |
7329 | 7329 | * @return string |
7330 | 7330 | */ |
7331 | - function createComponent( &$xcaldecl ) { |
|
7331 | + function createComponent(&$xcaldecl) { |
|
7332 | 7332 | $objectname = $this->_createFormat(); |
7333 | 7333 | $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; |
7334 | 7334 | $component .= $this->createUid(); |
@@ -7345,8 +7345,8 @@ discard block |
||
7345 | 7345 | $component .= $this->createUrl(); |
7346 | 7346 | $component .= $this->createXprop(); |
7347 | 7347 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7348 | - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
|
7349 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7348 | + if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) { |
|
7349 | + foreach ($this->xcaldecl as $localxcaldecl) |
|
7350 | 7350 | $xcaldecl[] = $localxcaldecl; |
7351 | 7351 | } |
7352 | 7352 | return $component; |
@@ -7397,7 +7397,7 @@ discard block |
||
7397 | 7397 | * @param array $xcaldecl |
7398 | 7398 | * @return string |
7399 | 7399 | */ |
7400 | - function createComponent( &$xcaldecl ) { |
|
7400 | + function createComponent(&$xcaldecl) { |
|
7401 | 7401 | $objectname = $this->_createFormat(); |
7402 | 7402 | $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; |
7403 | 7403 | $component .= $this->createAction(); |
@@ -7445,11 +7445,11 @@ discard block |
||
7445 | 7445 | * @since 2.5.1 - 2008-10-31 |
7446 | 7446 | * @param string $timezonetype optional, default FALSE ( STANDARD / DAYLIGHT ) |
7447 | 7447 | */ |
7448 | - function __construct($timezonetype=false) { |
|
7448 | + function __construct($timezonetype = false) { |
|
7449 | 7449 | if (!$timezonetype) { |
7450 | 7450 | $this->timezonetype = 'VTIMEZONE'; |
7451 | 7451 | } else { |
7452 | - $this->timezonetype = strtoupper( $timezonetype ); |
|
7452 | + $this->timezonetype = strtoupper($timezonetype); |
|
7453 | 7453 | } |
7454 | 7454 | $this->calendarComponent(); |
7455 | 7455 | |
@@ -7475,7 +7475,7 @@ discard block |
||
7475 | 7475 | * @param array $xcaldecl |
7476 | 7476 | * @return string |
7477 | 7477 | */ |
7478 | - function createComponent( &$xcaldecl ) { |
|
7478 | + function createComponent(&$xcaldecl) { |
|
7479 | 7479 | $objectname = $this->_createFormat(); |
7480 | 7480 | $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; |
7481 | 7481 | $component .= $this->createTzid(); |
@@ -7491,8 +7491,8 @@ discard block |
||
7491 | 7491 | $component .= $this->createXprop(); |
7492 | 7492 | $component .= $this->createSubComponent(); |
7493 | 7493 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7494 | - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
|
7495 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7494 | + if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) { |
|
7495 | + foreach ($this->xcaldecl as $localxcaldecl) |
|
7496 | 7496 | $xcaldecl[] = $localxcaldecl; |
7497 | 7497 | } |
7498 | 7498 | return $component; |
@@ -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=FALSE ) { |
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 | return FALSE; |
@@ -490,7 +533,9 @@ discard block |
||
490 | 533 | unset( $this->compix ); |
491 | 534 | $info = array(); |
492 | 535 | foreach( $this->components as $cix => $component ) { |
493 | - if( empty( $component )) continue; |
|
536 | + if( empty( $component )) { |
|
537 | + continue; |
|
538 | + } |
|
494 | 539 | unset( $component->propix ); |
495 | 540 | $info[$cix]['ordno'] = $cix + 1; |
496 | 541 | $info[$cix]['type'] = $component->objName; |
@@ -505,8 +550,9 @@ discard block |
||
505 | 550 | return $this->delimiter; |
506 | 551 | break; |
507 | 552 | case 'DIRECTORY': |
508 | - if( empty( $this->directory )) |
|
509 | - $this->directory = '.'; |
|
553 | + if( empty( $this->directory )) { |
|
554 | + $this->directory = '.'; |
|
555 | + } |
|
510 | 556 | return $this->directory; |
511 | 557 | break; |
512 | 558 | case 'DIRFILE': |
@@ -519,10 +565,13 @@ discard block |
||
519 | 565 | break; |
520 | 566 | case 'FILENAME': |
521 | 567 | if( empty( $this->filename )) { |
522 | - if( 'xcal' == $this->format ) |
|
523 | - $this->filename = date( 'YmdHis' ).'.xml'; // recommended xcs.. . |
|
524 | - else |
|
525 | - $this->filename = date( 'YmdHis' ).'.ics'; |
|
568 | + if( 'xcal' == $this->format ) { |
|
569 | + $this->filename = date( 'YmdHis' ).'.xml'; |
|
570 | + } |
|
571 | + // recommended xcs.. . |
|
572 | + else { |
|
573 | + $this->filename = date( 'YmdHis' ).'.ics'; |
|
574 | + } |
|
526 | 575 | } |
527 | 576 | return $this->filename; |
528 | 577 | break; |
@@ -530,8 +579,9 @@ discard block |
||
530 | 579 | $size = 0; |
531 | 580 | if( empty( $this->url )) { |
532 | 581 | $dirfile = $this->getConfig( 'dirfile' ); |
533 | - if( FALSE === ( $size = filesize( $dirfile ))) |
|
534 | - $size = 0; |
|
582 | + if( FALSE === ( $size = filesize( $dirfile ))) { |
|
583 | + $size = 0; |
|
584 | + } |
|
535 | 585 | clearstatcache(); |
536 | 586 | } |
537 | 587 | return $size; |
@@ -551,10 +601,11 @@ discard block |
||
551 | 601 | return $this->unique_id; |
552 | 602 | break; |
553 | 603 | case 'URL': |
554 | - if( !empty( $this->url )) |
|
555 | - return $this->url; |
|
556 | - else |
|
557 | - return FALSE; |
|
604 | + if( !empty( $this->url )) { |
|
605 | + return $this->url; |
|
606 | + } else { |
|
607 | + return FALSE; |
|
608 | + } |
|
558 | 609 | break; |
559 | 610 | } |
560 | 611 | } |
@@ -582,17 +633,18 @@ discard block |
||
582 | 633 | case 'DIRECTORY': |
583 | 634 | $value = trim( $value ); |
584 | 635 | $nl = $this->getConfig('delimiter'); |
585 | - if( $nl == substr( $value, ( 0 - strlen( $nl )))) |
|
586 | - $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl ))); |
|
636 | + if( $nl == substr( $value, ( 0 - strlen( $nl )))) { |
|
637 | + $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl ))); |
|
638 | + } |
|
587 | 639 | if( is_dir( $value )) { |
588 | 640 | /* local directory */ |
589 | 641 | clearstatcache(); |
590 | 642 | $this->directory = $value; |
591 | 643 | $this->url = null; |
592 | 644 | return TRUE; |
645 | + } else { |
|
646 | + return FALSE; |
|
593 | 647 | } |
594 | - else |
|
595 | - return FALSE; |
|
596 | 648 | break; |
597 | 649 | case 'FILENAME': |
598 | 650 | $value = trim( $value ); |
@@ -608,17 +660,16 @@ discard block |
||
608 | 660 | clearstatcache(); |
609 | 661 | $this->filename = $value; |
610 | 662 | return TRUE; |
663 | + } else { |
|
664 | + return FALSE; |
|
611 | 665 | } |
612 | - else |
|
613 | - return FALSE; |
|
614 | - } |
|
615 | - elseif( FALSE !== touch( $dirfile )) { |
|
666 | + } elseif( FALSE !== touch( $dirfile )) { |
|
616 | 667 | /* new local file created */ |
617 | 668 | $this->filename = $value; |
618 | 669 | return TRUE; |
670 | + } else { |
|
671 | + return FALSE; |
|
619 | 672 | } |
620 | - else |
|
621 | - return FALSE; |
|
622 | 673 | break; |
623 | 674 | case 'FORMAT': |
624 | 675 | $value = trim( $value ); |
@@ -626,8 +677,7 @@ discard block |
||
626 | 677 | $this->format = 'xcal'; |
627 | 678 | $this->attributeDelimiter = $this->nl; |
628 | 679 | $this->valueInit = null; |
629 | - } |
|
630 | - else { |
|
680 | + } else { |
|
631 | 681 | $this->format = null; |
632 | 682 | $this->attributeDelimiter = ';'; |
633 | 683 | $this->valueInit = ':'; |
@@ -666,13 +716,16 @@ discard block |
||
666 | 716 | return $this->setConfig( 'filename', $parts['basename'] ); |
667 | 717 | break; |
668 | 718 | } |
669 | - if( !$res ) return FALSE; |
|
719 | + if( !$res ) { |
|
720 | + return FALSE; |
|
721 | + } |
|
670 | 722 | if( isset( $subcfg ) && !empty( $this->components )) { |
671 | 723 | foreach( $subcfg as $cfgkey => $cfgvalue ) { |
672 | 724 | foreach( $this->components as $cix => $component ) { |
673 | 725 | $res = $component->setConfig( $cfgkey, $cfgvalue ); |
674 | - if( !$res ) |
|
675 | - break 2; |
|
726 | + if( !$res ) { |
|
727 | + break 2; |
|
728 | + } |
|
676 | 729 | $this->components[$cix] = $component->copy(); // PHP4 compliant |
677 | 730 | } |
678 | 731 | } |
@@ -707,27 +760,26 @@ discard block |
||
707 | 760 | if ( ctype_digit( (string) $arg1 )) { |
708 | 761 | $argType = 'INDEX'; |
709 | 762 | $index = (int) $arg1 - 1; |
710 | - } |
|
711 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
763 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
712 | 764 | $argType = strtolower( $arg1 ); |
713 | 765 | $index = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0; |
714 | 766 | } |
715 | 767 | $cix1dC = 0; |
716 | 768 | foreach ( $this->components as $cix => $component) { |
717 | - if( empty( $component )) continue; |
|
769 | + if( empty( $component )) { |
|
770 | + continue; |
|
771 | + } |
|
718 | 772 | unset( $component->propix ); |
719 | 773 | if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
720 | 774 | unset( $this->components[$cix] ); |
721 | 775 | return TRUE; |
722 | - } |
|
723 | - elseif( $argType == $component->objName ) { |
|
776 | + } elseif( $argType == $component->objName ) { |
|
724 | 777 | if( $index == $cix1dC ) { |
725 | 778 | unset( $this->components[$cix] ); |
726 | 779 | return TRUE; |
727 | 780 | } |
728 | 781 | $cix1dC++; |
729 | - } |
|
730 | - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
782 | + } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
731 | 783 | unset( $this->components[$cix] ); |
732 | 784 | return TRUE; |
733 | 785 | } |
@@ -749,37 +801,39 @@ discard block |
||
749 | 801 | $argType = 'INDEX'; |
750 | 802 | $index = $this->compix['INDEX'] = |
751 | 803 | ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1; |
752 | - } |
|
753 | - elseif ( ctype_digit( (string) $arg1 )) { |
|
804 | + } elseif ( ctype_digit( (string) $arg1 )) { |
|
754 | 805 | $argType = 'INDEX'; |
755 | 806 | $index = (int) $arg1; |
756 | 807 | unset( $this->compix ); |
757 | - } |
|
758 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
808 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
759 | 809 | unset( $this->compix['INDEX'] ); |
760 | 810 | $argType = strtolower( $arg1 ); |
761 | - if( !$arg2 ) |
|
762 | - $index = $this->compix[$argType] = |
|
811 | + if( !$arg2 ) { |
|
812 | + $index = $this->compix[$argType] = |
|
763 | 813 | ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1; |
764 | - else |
|
765 | - $index = (int) $arg2; |
|
814 | + } else { |
|
815 | + $index = (int) $arg2; |
|
816 | + } |
|
766 | 817 | } |
767 | 818 | $index -= 1; |
768 | 819 | $ckeys = array_keys( $this->components ); |
769 | - if( !empty( $index) && ( $index > end( $ckeys ))) |
|
770 | - return FALSE; |
|
820 | + if( !empty( $index) && ( $index > end( $ckeys ))) { |
|
821 | + return FALSE; |
|
822 | + } |
|
771 | 823 | $cix1gC = 0; |
772 | 824 | foreach ( $this->components as $cix => $component) { |
773 | - if( empty( $component )) continue; |
|
825 | + if( empty( $component )) { |
|
826 | + continue; |
|
827 | + } |
|
774 | 828 | unset( $component->propix ); |
775 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) |
|
776 | - return $component->copy(); |
|
777 | - elseif( $argType == $component->objName ) { |
|
778 | - if( $index == $cix1gC ) |
|
779 | - return $component->copy(); |
|
829 | + if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
|
830 | + return $component->copy(); |
|
831 | + } elseif( $argType == $component->objName ) { |
|
832 | + if( $index == $cix1gC ) { |
|
833 | + return $component->copy(); |
|
834 | + } |
|
780 | 835 | $cix1gC++; |
781 | - } |
|
782 | - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
836 | + } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
783 | 837 | unset( $component->propix ); |
784 | 838 | return $component->copy(); |
785 | 839 | } |
@@ -814,46 +868,68 @@ discard block |
||
814 | 868 | */ |
815 | 869 | function selectComponents( $startY=FALSE, $startM=FALSE, $startD=FALSE, $endY=FALSE, $endM=FALSE, $endD=FALSE, $cType=FALSE, $flat=FALSE, $any=TRUE, $split=TRUE ) { |
816 | 870 | /* check if empty calendar */ |
817 | - if( 0 >= count( $this->components )) return FALSE; |
|
871 | + if( 0 >= count( $this->components )) { |
|
872 | + return FALSE; |
|
873 | + } |
|
818 | 874 | /* check default dates */ |
819 | - if( !$startY ) $startY = date( 'Y' ); |
|
820 | - if( !$startM ) $startM = date( 'm' ); |
|
821 | - if( !$startD ) $startD = date( 'd' ); |
|
875 | + if( !$startY ) { |
|
876 | + $startY = date( 'Y' ); |
|
877 | + } |
|
878 | + if( !$startM ) { |
|
879 | + $startM = date( 'm' ); |
|
880 | + } |
|
881 | + if( !$startD ) { |
|
882 | + $startD = date( 'd' ); |
|
883 | + } |
|
822 | 884 | $startDate = mktime( 0, 0, 0, $startM, $startD, $startY ); |
823 | - if( !$endY ) $endY = $startY; |
|
824 | - if( !$endM ) $endM = $startM; |
|
825 | - if( !$endD ) $endD = $startD; |
|
885 | + if( !$endY ) { |
|
886 | + $endY = $startY; |
|
887 | + } |
|
888 | + if( !$endM ) { |
|
889 | + $endM = $startM; |
|
890 | + } |
|
891 | + if( !$endD ) { |
|
892 | + $endD = $startD; |
|
893 | + } |
|
826 | 894 | $endDate = mktime( 23, 59, 59, $endM, $endD, $endY ); |
827 | 895 | /* check component types */ |
828 | 896 | $validTypes = array('vevent', 'vtodo', 'vjournal', 'vfreebusy' ); |
829 | 897 | if( is_array( $cType )) { |
830 | 898 | foreach( $cType as $cix => $theType ) { |
831 | 899 | $cType[$cix] = $theType = strtolower( $theType ); |
832 | - if( !in_array( $theType, $validTypes )) |
|
833 | - $cType[$cix] = 'vevent'; |
|
900 | + if( !in_array( $theType, $validTypes )) { |
|
901 | + $cType[$cix] = 'vevent'; |
|
902 | + } |
|
834 | 903 | } |
835 | 904 | $cType = array_unique( $cType ); |
836 | - } |
|
837 | - elseif( !empty( $cType )) { |
|
905 | + } elseif( !empty( $cType )) { |
|
838 | 906 | $cType = strtolower( $cType ); |
839 | - if( !in_array( $cType, $validTypes )) |
|
840 | - $cType = array( 'vevent' ); |
|
841 | - else |
|
842 | - $cType = array( $cType ); |
|
843 | - } |
|
844 | - else |
|
845 | - $cType = $validTypes; |
|
846 | - if( 0 >= count( $cType )) |
|
847 | - $cType = $validTypes; |
|
907 | + if( !in_array( $cType, $validTypes )) { |
|
908 | + $cType = array( 'vevent' ); |
|
909 | + } else { |
|
910 | + $cType = array( $cType ); |
|
911 | + } |
|
912 | + } else { |
|
913 | + $cType = $validTypes; |
|
914 | + } |
|
915 | + if( 0 >= count( $cType )) { |
|
916 | + $cType = $validTypes; |
|
917 | + } |
|
848 | 918 | /* iterate components */ |
849 | 919 | $result = array(); |
850 | 920 | foreach ( $this->components as $cix => $component ) { |
851 | - if( empty( $component )) continue; |
|
921 | + if( empty( $component )) { |
|
922 | + continue; |
|
923 | + } |
|
852 | 924 | unset( $component->propix, $start ); |
853 | 925 | /* deselect unvalid type components */ |
854 | - if( !in_array( $component->objName, $cType )) continue; |
|
926 | + if( !in_array( $component->objName, $cType )) { |
|
927 | + continue; |
|
928 | + } |
|
855 | 929 | /* deselect components without dtstart set */ |
856 | - if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) continue; |
|
930 | + if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) { |
|
931 | + continue; |
|
932 | + } |
|
857 | 933 | $dtendExist = $dueExist = $durationExist = $endAllDayEvent = FALSE; |
858 | 934 | unset( $end, $startWdate, $endWdate, $rdurWsecs, $rdur, $exdatelist, $workstart, $workend ); // clean up |
859 | 935 | $startWdate = $component->_date2timestamp( $start ); |
@@ -887,8 +963,9 @@ discard block |
||
887 | 963 | } |
888 | 964 | if( empty( $end )) { |
889 | 965 | $end = $component->getProperty( 'duration', FALSE, FALSE, TRUE );// in dtend (array) format |
890 | - if( !empty( $end )) |
|
891 | - $durationExist = TRUE; |
|
966 | + if( !empty( $end )) { |
|
967 | + $durationExist = TRUE; |
|
968 | + } |
|
892 | 969 | // if( !empty($end)) echo 'selectComp 4 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ### |
893 | 970 | } |
894 | 971 | if( empty( $end )) { // assume one day duration if missing end date |
@@ -906,55 +983,75 @@ discard block |
||
906 | 983 | $exdatelist = array(); |
907 | 984 | $workstart = $component->_timestamp2date(( $startDate - $rdurWsecs ), 6); |
908 | 985 | $workend = $component->_timestamp2date(( $endDate + $rdurWsecs ), 6); |
909 | - while( FALSE !== ( $exrule = $component->getProperty( 'exrule' ))) // check exrule |
|
986 | + while( FALSE !== ( $exrule = $component->getProperty( 'exrule' ))) { |
|
987 | + // check exrule |
|
910 | 988 | $component->_recur2date( $exdatelist, $exrule, $start, $workstart, $workend ); |
989 | + } |
|
911 | 990 | while( FALSE !== ( $exdate = $component->getProperty( 'exdate' ))) { // check exdate |
912 | 991 | foreach( $exdate as $theExdate ) { |
913 | 992 | $exWdate = $component->_date2timestamp( $theExdate ); |
914 | - if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate )) |
|
915 | - $exdatelist[$exWdate] = TRUE; |
|
993 | + if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate )) { |
|
994 | + $exdatelist[$exWdate] = TRUE; |
|
995 | + } |
|
916 | 996 | } |
917 | 997 | } |
918 | 998 | /* if 'any' components, check repeating components, removing all excluding dates */ |
919 | 999 | if( TRUE === $any ) { |
920 | 1000 | /* make a list of optional repeating dates for component occurence, rrule, rdate */ |
921 | 1001 | $recurlist = array(); |
922 | - while( FALSE !== ( $rrule = $component->getProperty( 'rrule' ))) // check rrule |
|
1002 | + while( FALSE !== ( $rrule = $component->getProperty( 'rrule' ))) { |
|
1003 | + // check rrule |
|
923 | 1004 | $component->_recur2date( $recurlist, $rrule, $start, $workstart, $workend ); |
924 | - foreach( $recurlist as $recurkey => $recurvalue ) // key=match date as timestamp |
|
925 | - $recurlist[$recurkey] = $rdurWsecs; // add duration in seconds |
|
1005 | + } |
|
1006 | + foreach( $recurlist as $recurkey => $recurvalue ) { |
|
1007 | + // key=match date as timestamp |
|
1008 | + $recurlist[$recurkey] = $rdurWsecs; |
|
1009 | + } |
|
1010 | + // add duration in seconds |
|
926 | 1011 | while( FALSE !== ( $rdate = $component->getProperty( 'rdate' ))) { // check rdate |
927 | 1012 | foreach( $rdate as $theRdate ) { |
928 | 1013 | if( is_array( $theRdate ) && ( 2 == count( $theRdate )) && // all days within PERIOD |
929 | 1014 | array_key_exists( '0', $theRdate ) && array_key_exists( '1', $theRdate )) { |
930 | 1015 | $rstart = $component->_date2timestamp( $theRdate[0] ); |
931 | - if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate )) |
|
932 | - continue; |
|
933 | - if( isset( $theRdate[1]['year'] )) // date-date period |
|
1016 | + if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate )) { |
|
1017 | + continue; |
|
1018 | + } |
|
1019 | + if( isset( $theRdate[1]['year'] )) { |
|
1020 | + // date-date period |
|
934 | 1021 | $rend = $component->_date2timestamp( $theRdate[1] ); |
935 | - else { // date-duration period |
|
1022 | + } else { // date-duration period |
|
936 | 1023 | $rend = $component->duration2date( $theRdate[0], $theRdate[1] ); |
937 | 1024 | $rend = $component->_date2timestamp( $rend ); |
938 | 1025 | } |
939 | - if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart )) |
|
940 | - $recurlist[$rstart] = ( $rstart - $rend ); // set start date + rdate duration in seconds |
|
1026 | + if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart )) { |
|
1027 | + $recurlist[$rstart] = ( $rstart - $rend ); |
|
1028 | + } |
|
1029 | + // set start date + rdate duration in seconds |
|
941 | 1030 | } // PERIOD end |
942 | 1031 | else { // single date |
943 | 1032 | $theRdate = $component->_date2timestamp( $theRdate ); |
944 | - if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate )) |
|
945 | - $recurlist[$theRdate] = $rdurWsecs; // set start date + event duration in seconds |
|
1033 | + if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate )) { |
|
1034 | + $recurlist[$theRdate] = $rdurWsecs; |
|
1035 | + } |
|
1036 | + // set start date + event duration in seconds |
|
946 | 1037 | } |
947 | 1038 | } |
948 | 1039 | } |
949 | 1040 | if( 0 < count( $recurlist )) { |
950 | 1041 | ksort( $recurlist ); |
951 | 1042 | foreach( $recurlist as $recurkey => $durvalue ) { |
952 | - if((( $startDate - $rdurWsecs ) > $recurkey ) || ( $endDate < $recurkey )) // not within period |
|
1043 | + if((( $startDate - $rdurWsecs ) > $recurkey ) || ( $endDate < $recurkey )) { |
|
1044 | + // not within period |
|
953 | 1045 | continue; |
954 | - if( isset( $exdatelist[$recurkey] )) // check excluded dates |
|
1046 | + } |
|
1047 | + if( isset( $exdatelist[$recurkey] )) { |
|
1048 | + // check excluded dates |
|
955 | 1049 | continue; |
956 | - if( $startWdate >= $recurkey ) // exclude component start date |
|
1050 | + } |
|
1051 | + if( $startWdate >= $recurkey ) { |
|
1052 | + // exclude component start date |
|
957 | 1053 | continue; |
1054 | + } |
|
958 | 1055 | $component2 = $component->copy(); |
959 | 1056 | $rstart = $component2->_timestamp2date( $recurkey, 6); |
960 | 1057 | $datevalue = $rstart['month'].'/'.$rstart['day'].'/'.$rstart['year']; |
@@ -964,16 +1061,16 @@ discard block |
||
964 | 1061 | $datevalue .= ( isset( $rstart['sec'] )) ? ':'.$rstart['sec'] : ':00'; |
965 | 1062 | } |
966 | 1063 | $datestring = date( $startDateFormat, strtotime( $datevalue )); |
967 | - if( isset( $start['tz'] )) |
|
968 | - $datestring .= ' '.$start['tz']; |
|
1064 | + if( isset( $start['tz'] )) { |
|
1065 | + $datestring .= ' '.$start['tz']; |
|
1066 | + } |
|
969 | 1067 | $component2->setProperty( 'X-CURRENT-DTSTART', $datestring ); |
970 | 1068 | $rend = $component2->_timestamp2date(( $recurkey + $durvalue ), 6); |
971 | 1069 | if( $dtendExist || $dueExist ) { |
972 | 1070 | if( $endAllDayEvent ) { |
973 | 1071 | $rend2 = mktime( 0, 0, 0, $rend['month'], ($rend['day'] + 1), $rend['year'] ); |
974 | 1072 | $datevalue = date( 'm', $rend2 ).'/'.date( 'd', $rend2 ).'/'.date( 'Y', $rend2 ); |
975 | - } |
|
976 | - else { |
|
1073 | + } else { |
|
977 | 1074 | $datevalue = $rend['month'].'/'.$rend['day'].'/'.$rend['year']; |
978 | 1075 | if( isset( $end['hour'] ) || isset( $end['min'] ) || isset( $end['sec'] )) { |
979 | 1076 | $datevalue .= ( isset( $rend['hour'] )) ? ' '.$rend['hour'] : ' 00'; |
@@ -982,30 +1079,37 @@ discard block |
||
982 | 1079 | } |
983 | 1080 | } |
984 | 1081 | $datestring = date( $endDateFormat, strtotime( $datevalue )); |
985 | - if( isset( $end['tz'] )) |
|
986 | - $datestring .= ' '.$end['tz']; |
|
987 | - if( $dtendExist ) |
|
988 | - $component2->setProperty( 'X-CURRENT-DTEND', $datestring ); |
|
989 | - elseif( $dueExist ) |
|
990 | - $component2->setProperty( 'X-CURRENT-DUE', $datestring ); |
|
1082 | + if( isset( $end['tz'] )) { |
|
1083 | + $datestring .= ' '.$end['tz']; |
|
1084 | + } |
|
1085 | + if( $dtendExist ) { |
|
1086 | + $component2->setProperty( 'X-CURRENT-DTEND', $datestring ); |
|
1087 | + } elseif( $dueExist ) { |
|
1088 | + $component2->setProperty( 'X-CURRENT-DUE', $datestring ); |
|
1089 | + } |
|
991 | 1090 | } |
992 | 1091 | $rend = $component2->_date2timestamp( $rend ); |
993 | 1092 | $rstart = $recurkey; |
994 | 1093 | /* add repeating components within valid dates to output array, only start date */ |
995 | - if( $flat ) |
|
996 | - $result[] = $component2->copy(); // copy to output |
|
1094 | + if( $flat ) { |
|
1095 | + $result[] = $component2->copy(); |
|
1096 | + } |
|
1097 | + // copy to output |
|
997 | 1098 | elseif( $split ) { |
998 | - if( $rend > $endDate ) |
|
999 | - $rend = $endDate; |
|
1099 | + if( $rend > $endDate ) { |
|
1100 | + $rend = $endDate; |
|
1101 | + } |
|
1000 | 1102 | while( $rstart <= $rend ) { // iterate |
1001 | 1103 | $wd = getdate( $rstart ); |
1002 | 1104 | if(( $rstart > $startDate ) && // date after dtstart |
1003 | - !isset( $exdatelist[$rstart] )) // check exclude date |
|
1004 | - $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output |
|
1105 | + !isset( $exdatelist[$rstart] )) { |
|
1106 | + // check exclude date |
|
1107 | + $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); |
|
1108 | + } |
|
1109 | + // copy to output |
|
1005 | 1110 | $rstart += ( 24*60*60 ); // step one day |
1006 | 1111 | } |
1007 | - } |
|
1008 | - elseif(( $rstart >= $startDate ) && // date within period |
|
1112 | + } elseif(( $rstart >= $startDate ) && // date within period |
|
1009 | 1113 | !isset( $exdatelist[$rstart] )) { // check exclude date |
1010 | 1114 | $wd = getdate( $rstart ); |
1011 | 1115 | $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output |
@@ -1013,19 +1117,29 @@ discard block |
||
1013 | 1117 | } |
1014 | 1118 | } |
1015 | 1119 | /* deselect components with startdate/enddate not within period */ |
1016 | - if(( $endWdate < $startDate ) || ( $startWdate > $endDate )) continue; |
|
1120 | + if(( $endWdate < $startDate ) || ( $startWdate > $endDate )) { |
|
1121 | + continue; |
|
1122 | + } |
|
1017 | 1123 | } |
1018 | 1124 | /* deselect components with startdate not within period */ |
1019 | - elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) continue; |
|
1125 | + elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) { |
|
1126 | + continue; |
|
1127 | + } |
|
1020 | 1128 | /* add selected components within valid dates to output array */ |
1021 | - if( $flat ) |
|
1022 | - $result[] = $component->copy(); // copy to output; |
|
1129 | + if( $flat ) { |
|
1130 | + $result[] = $component->copy(); |
|
1131 | + } |
|
1132 | + // copy to output; |
|
1023 | 1133 | elseif( $split ) { |
1024 | - if( $endWdate > $endDate ) |
|
1025 | - $endWdate = $endDate; // use period end date |
|
1134 | + if( $endWdate > $endDate ) { |
|
1135 | + $endWdate = $endDate; |
|
1136 | + } |
|
1137 | + // use period end date |
|
1026 | 1138 | if( !isset( $exdatelist[$startWdate] )) { // check excluded dates |
1027 | - if( $startWdate < $startDate ) |
|
1028 | - $startWdate = $startDate; // use period start date |
|
1139 | + if( $startWdate < $startDate ) { |
|
1140 | + $startWdate = $startDate; |
|
1141 | + } |
|
1142 | + // use period start date |
|
1029 | 1143 | while( $startWdate <= $endWdate ) { // iterate |
1030 | 1144 | $wd = getdate( $startWdate ); |
1031 | 1145 | $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output |
@@ -1039,8 +1153,9 @@ discard block |
||
1039 | 1153 | $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output |
1040 | 1154 | } |
1041 | 1155 | } |
1042 | - if( 0 >= count( $result )) return FALSE; |
|
1043 | - elseif( !$flat ) { |
|
1156 | + if( 0 >= count( $result )) { |
|
1157 | + return FALSE; |
|
1158 | + } elseif( !$flat ) { |
|
1044 | 1159 | foreach( $result as $y => $yeararr ) { |
1045 | 1160 | foreach( $yeararr as $m => $montharr ) { |
1046 | 1161 | ksort( $result[$y][$m] ); |
@@ -1062,8 +1177,9 @@ discard block |
||
1062 | 1177 | * @return void |
1063 | 1178 | */ |
1064 | 1179 | function setComponent( $component, $arg1=FALSE, $arg2=FALSE ) { |
1065 | - if( '' >= $component->getConfig( 'language')) |
|
1066 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
1180 | + if( '' >= $component->getConfig( 'language')) { |
|
1181 | + $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
1182 | + } |
|
1067 | 1183 | $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
1068 | 1184 | $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
1069 | 1185 | $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
@@ -1082,27 +1198,26 @@ discard block |
||
1082 | 1198 | if ( ctype_digit( (string) $arg1 )) { |
1083 | 1199 | $argType = 'INDEX'; |
1084 | 1200 | $index = (int) $arg1 - 1; |
1085 | - } |
|
1086 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
1201 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
1087 | 1202 | $argType = strtolower( $arg1 ); |
1088 | 1203 | $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0; |
1089 | 1204 | } |
1090 | 1205 | $cix1sC = 0; |
1091 | 1206 | foreach ( $this->components as $cix => $component2) { |
1092 | - if( empty( $component2 )) continue; |
|
1207 | + if( empty( $component2 )) { |
|
1208 | + continue; |
|
1209 | + } |
|
1093 | 1210 | unset( $component2->propix ); |
1094 | 1211 | if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
1095 | 1212 | $this->components[$cix] = $component->copy(); |
1096 | 1213 | return TRUE; |
1097 | - } |
|
1098 | - elseif( $argType == $component2->objName ) { |
|
1214 | + } elseif( $argType == $component2->objName ) { |
|
1099 | 1215 | if( $index == $cix1sC ) { |
1100 | 1216 | $this->components[$cix] = $component->copy(); |
1101 | 1217 | return TRUE; |
1102 | 1218 | } |
1103 | 1219 | $cix1sC++; |
1104 | - } |
|
1105 | - elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) { |
|
1220 | + } elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) { |
|
1106 | 1221 | $this->components[$cix] = $component->copy(); |
1107 | 1222 | return TRUE; |
1108 | 1223 | } |
@@ -1129,73 +1244,124 @@ discard block |
||
1129 | 1244 | } |
1130 | 1245 | } |
1131 | 1246 | function _cmpfcn( $a, $b ) { |
1132 | - if( empty( $a )) return -1; |
|
1133 | - if( empty( $b )) return 1; |
|
1134 | - if( 'vtimezone' == $a->objName) return -1; |
|
1135 | - if( 'vtimezone' == $b->objName) return 1; |
|
1247 | + if( empty( $a )) { |
|
1248 | + return -1; |
|
1249 | + } |
|
1250 | + if( empty( $b )) { |
|
1251 | + return 1; |
|
1252 | + } |
|
1253 | + if( 'vtimezone' == $a->objName) { |
|
1254 | + return -1; |
|
1255 | + } |
|
1256 | + if( 'vtimezone' == $b->objName) { |
|
1257 | + return 1; |
|
1258 | + } |
|
1136 | 1259 | $astart = ( isset( $a->xprop['X-CURRENT-DTSTART']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTSTART']['value'] ) : null; |
1137 | - if( empty( $astart ) && isset( $a->dtstart['value'] )) |
|
1138 | - $astart = & $a->dtstart['value']; |
|
1260 | + if( empty( $astart ) && isset( $a->dtstart['value'] )) { |
|
1261 | + $astart = & $a->dtstart['value']; |
|
1262 | + } |
|
1139 | 1263 | $bstart = ( isset( $b->xprop['X-CURRENT-DTSTART']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTSTART']['value'] ) : null; |
1140 | - if( empty( $bstart ) && isset( $b->dtstart['value'] )) |
|
1141 | - $bstart = & $b->dtstart['value']; |
|
1142 | - if( empty( $astart )) return -1; |
|
1143 | - elseif( empty( $bstart )) return 1; |
|
1264 | + if( empty( $bstart ) && isset( $b->dtstart['value'] )) { |
|
1265 | + $bstart = & $b->dtstart['value']; |
|
1266 | + } |
|
1267 | + if( empty( $astart )) { |
|
1268 | + return -1; |
|
1269 | + } elseif( empty( $bstart )) { |
|
1270 | + return 1; |
|
1271 | + } |
|
1144 | 1272 | foreach( $this->_sortkeys as $key ) { |
1145 | - if ( empty( $astart[$key] )) return -1; |
|
1146 | - elseif( empty( $bstart[$key] )) return 1; |
|
1147 | - if ( $astart[$key] == $bstart[$key]) continue; |
|
1148 | - if (( (int) $astart[$key] ) < ((int) $bstart[$key] )) |
|
1273 | + if ( empty( $astart[$key] )) { |
|
1149 | 1274 | return -1; |
1150 | - elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] )) |
|
1275 | + } elseif( empty( $bstart[$key] )) { |
|
1151 | 1276 | return 1; |
1277 | + } |
|
1278 | + if ( $astart[$key] == $bstart[$key]) { |
|
1279 | + continue; |
|
1280 | + } |
|
1281 | + if (( (int) $astart[$key] ) < ((int) $bstart[$key] )) { |
|
1282 | + return -1; |
|
1283 | + } elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] )) { |
|
1284 | + return 1; |
|
1285 | + } |
|
1152 | 1286 | } |
1153 | 1287 | $c = ( isset( $a->xprop['X-CURRENT-DTEND']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTEND']['value'] ) : null; |
1154 | - if( empty( $c ) && !empty( $a->dtend['value'] )) |
|
1155 | - $c = & $a->dtend['value']; |
|
1156 | - if( empty( $c ) && isset( $a->xprop['X-CURRENT-DUE']['value'] )) |
|
1157 | - $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] ); |
|
1158 | - if( empty( $c ) && !empty( $a->due['value'] )) |
|
1159 | - $c = & $a->due['value']; |
|
1160 | - if( empty( $c ) && !empty( $a->duration['value'] )) |
|
1161 | - $c = $a->duration2date(); |
|
1288 | + if( empty( $c ) && !empty( $a->dtend['value'] )) { |
|
1289 | + $c = & $a->dtend['value']; |
|
1290 | + } |
|
1291 | + if( empty( $c ) && isset( $a->xprop['X-CURRENT-DUE']['value'] )) { |
|
1292 | + $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] ); |
|
1293 | + } |
|
1294 | + if( empty( $c ) && !empty( $a->due['value'] )) { |
|
1295 | + $c = & $a->due['value']; |
|
1296 | + } |
|
1297 | + if( empty( $c ) && !empty( $a->duration['value'] )) { |
|
1298 | + $c = $a->duration2date(); |
|
1299 | + } |
|
1162 | 1300 | $d = ( isset( $b->xprop['X-CURRENT-DTEND']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTEND']['value'] ) : null; |
1163 | - if( empty( $d ) && !empty( $b->dtend['value'] )) |
|
1164 | - $d = & $b->dtend['value']; |
|
1165 | - if( empty( $d ) && isset( $b->xprop['X-CURRENT-DUE']['value'] )) |
|
1166 | - $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] ); |
|
1167 | - if( empty( $d ) && !empty( $b->due['value'] )) |
|
1168 | - $d = & $b->due['value']; |
|
1169 | - if( empty( $d ) && !empty( $b->duration['value'] )) |
|
1170 | - $d = $b->duration2date(); |
|
1171 | - if( empty( $c )) return -1; |
|
1172 | - elseif( empty( $d )) return 1; |
|
1301 | + if( empty( $d ) && !empty( $b->dtend['value'] )) { |
|
1302 | + $d = & $b->dtend['value']; |
|
1303 | + } |
|
1304 | + if( empty( $d ) && isset( $b->xprop['X-CURRENT-DUE']['value'] )) { |
|
1305 | + $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] ); |
|
1306 | + } |
|
1307 | + if( empty( $d ) && !empty( $b->due['value'] )) { |
|
1308 | + $d = & $b->due['value']; |
|
1309 | + } |
|
1310 | + if( empty( $d ) && !empty( $b->duration['value'] )) { |
|
1311 | + $d = $b->duration2date(); |
|
1312 | + } |
|
1313 | + if( empty( $c )) { |
|
1314 | + return -1; |
|
1315 | + } elseif( empty( $d )) { |
|
1316 | + return 1; |
|
1317 | + } |
|
1173 | 1318 | foreach( $this->_sortkeys as $key ) { |
1174 | - if ( !isset( $c[$key] )) return -1; |
|
1175 | - elseif( !isset( $d[$key] )) return 1; |
|
1176 | - if ( $c[$key] == $d[$key] ) continue; |
|
1177 | - if (( (int) $c[$key] ) < ((int) $d[$key])) return -1; |
|
1178 | - elseif(( (int) $c[$key] ) > ((int) $d[$key])) return 1; |
|
1179 | - } |
|
1180 | - if( isset( $a->created['value'] )) |
|
1181 | - $e = & $a->created['value']; |
|
1182 | - else |
|
1183 | - $e = & $a->dtstamp['value']; |
|
1184 | - if( isset( $b->created['value'] )) |
|
1185 | - $f = & $b->created['value']; |
|
1186 | - else |
|
1187 | - $f = & $b->dtstamp['value']; |
|
1319 | + if ( !isset( $c[$key] )) { |
|
1320 | + return -1; |
|
1321 | + } elseif( !isset( $d[$key] )) { |
|
1322 | + return 1; |
|
1323 | + } |
|
1324 | + if ( $c[$key] == $d[$key] ) { |
|
1325 | + continue; |
|
1326 | + } |
|
1327 | + if (( (int) $c[$key] ) < ((int) $d[$key])) { |
|
1328 | + return -1; |
|
1329 | + } elseif(( (int) $c[$key] ) > ((int) $d[$key])) { |
|
1330 | + return 1; |
|
1331 | + } |
|
1332 | + } |
|
1333 | + if( isset( $a->created['value'] )) { |
|
1334 | + $e = & $a->created['value']; |
|
1335 | + } else { |
|
1336 | + $e = & $a->dtstamp['value']; |
|
1337 | + } |
|
1338 | + if( isset( $b->created['value'] )) { |
|
1339 | + $f = & $b->created['value']; |
|
1340 | + } else { |
|
1341 | + $f = & $b->dtstamp['value']; |
|
1342 | + } |
|
1188 | 1343 | foreach( $this->_sortkeys as $key ) { |
1189 | - if( !isset( $e[$key] )) return -1; |
|
1190 | - elseif( !isset( $f[$key] )) return 1; |
|
1191 | - if ( $e[$key] == $f[$key] ) continue; |
|
1192 | - if (( (int) $e[$key] ) < ((int) $f[$key])) return -1; |
|
1193 | - elseif(( (int) $e[$key] ) > ((int) $f[$key])) return 1; |
|
1344 | + if( !isset( $e[$key] )) { |
|
1345 | + return -1; |
|
1346 | + } elseif( !isset( $f[$key] )) { |
|
1347 | + return 1; |
|
1348 | + } |
|
1349 | + if ( $e[$key] == $f[$key] ) { |
|
1350 | + continue; |
|
1351 | + } |
|
1352 | + if (( (int) $e[$key] ) < ((int) $f[$key])) { |
|
1353 | + return -1; |
|
1354 | + } elseif(( (int) $e[$key] ) > ((int) $f[$key])) { |
|
1355 | + return 1; |
|
1356 | + } |
|
1194 | 1357 | } |
1195 | 1358 | if (( $a->uid['value'] ) < |
1196 | - ( $b->uid['value'] )) return -1; |
|
1197 | - elseif(( $a->uid['value'] ) > |
|
1198 | - ( $b->uid['value'] )) return 1; |
|
1359 | + ( $b->uid['value'] )) { |
|
1360 | + return -1; |
|
1361 | + } elseif(( $a->uid['value'] ) > |
|
1362 | + ( $b->uid['value'] )) { |
|
1363 | + return 1; |
|
1364 | + } |
|
1199 | 1365 | return 0; |
1200 | 1366 | } |
1201 | 1367 | /** |
@@ -1210,42 +1376,57 @@ discard block |
||
1210 | 1376 | function parse( $filename=FALSE ) { |
1211 | 1377 | if( !$filename ) { |
1212 | 1378 | /* directory/filename previous set via setConfig directory+filename / url */ |
1213 | - if( FALSE === ( $filename = $this->getConfig( 'url' ))) |
|
1214 | - $filename = $this->getConfig( 'dirfile' ); |
|
1215 | - } |
|
1216 | - elseif(( 'http://' == strtolower( substr( $filename, 0, 7 ))) || |
|
1379 | + if( FALSE === ( $filename = $this->getConfig( 'url' ))) { |
|
1380 | + $filename = $this->getConfig( 'dirfile' ); |
|
1381 | + } |
|
1382 | + } elseif(( 'http://' == strtolower( substr( $filename, 0, 7 ))) || |
|
1217 | 1383 | ( 'webcal://' == strtolower( substr( $filename, 0, 9 )))) { |
1218 | 1384 | /* remote file - URL */ |
1219 | 1385 | $this->setConfig( 'URL', $filename ); |
1220 | - if( !$filename = $this->getConfig( 'url' )) |
|
1221 | - return FALSE; /* err 2 */ |
|
1222 | - } |
|
1223 | - else { |
|
1386 | + if( !$filename = $this->getConfig( 'url' )) { |
|
1387 | + return FALSE; |
|
1388 | + } |
|
1389 | + /* err 2 */ |
|
1390 | + } else { |
|
1224 | 1391 | /* local directory/filename */ |
1225 | 1392 | $parts = pathinfo( $filename ); |
1226 | 1393 | if( !empty( $parts['dirname'] ) && ( '.' != $parts['dirname'] )) { |
1227 | - if( !$this->setConfig( 'directory', $parts['dirname'] )) |
|
1228 | - return FALSE; /* err 3 */ |
|
1394 | + if( !$this->setConfig( 'directory', $parts['dirname'] )) { |
|
1395 | + return FALSE; |
|
1396 | + } |
|
1397 | + /* err 3 */ |
|
1398 | + } |
|
1399 | + if( !$this->setConfig( 'filename', $parts['basename'] )) { |
|
1400 | + return FALSE; |
|
1229 | 1401 | } |
1230 | - if( !$this->setConfig( 'filename', $parts['basename'] )) |
|
1231 | - return FALSE; /* err 4 */ |
|
1402 | + /* err 4 */ |
|
1232 | 1403 | } |
1233 | 1404 | if( 'http://' != substr( $filename, 0, 7 )) { |
1234 | 1405 | /* local file error tests */ |
1235 | - if( !is_file( $filename )) /* err 5 */ |
|
1406 | + if( !is_file( $filename )) { |
|
1407 | + /* err 5 */ |
|
1236 | 1408 | return FALSE; |
1237 | - if( !is_readable( $filename )) |
|
1238 | - return FALSE; /* err 6 */ |
|
1239 | - if( !filesize( $filename )) |
|
1240 | - return FALSE; /* err 7 */ |
|
1409 | + } |
|
1410 | + if( !is_readable( $filename )) { |
|
1411 | + return FALSE; |
|
1412 | + } |
|
1413 | + /* err 6 */ |
|
1414 | + if( !filesize( $filename )) { |
|
1415 | + return FALSE; |
|
1416 | + } |
|
1417 | + /* err 7 */ |
|
1241 | 1418 | clearstatcache(); |
1242 | 1419 | } |
1243 | 1420 | /* READ FILE */ |
1244 | - if( FALSE === ( $rows = file( $filename ))) |
|
1245 | - return FALSE; /* err 1 */ |
|
1421 | + if( FALSE === ( $rows = file( $filename ))) { |
|
1422 | + return FALSE; |
|
1423 | + } |
|
1424 | + /* err 1 */ |
|
1246 | 1425 | /* identify BEGIN:VCALENDAR, MUST be first row */ |
1247 | - if( 'BEGIN:VCALENDAR' != strtoupper( trim( $rows[0] ))) |
|
1248 | - return FALSE; /* err 8 */ |
|
1426 | + if( 'BEGIN:VCALENDAR' != strtoupper( trim( $rows[0] ))) { |
|
1427 | + return FALSE; |
|
1428 | + } |
|
1429 | + /* err 8 */ |
|
1249 | 1430 | /* remove empty trailing lines */ |
1250 | 1431 | while( '' == trim( $rows[count( $rows ) - 1] )) { |
1251 | 1432 | unset( $rows[count( $rows ) - 1] ); |
@@ -1255,34 +1436,37 @@ discard block |
||
1255 | 1436 | if( 'END:VCALENDAR' != strtoupper( trim( $rows[count( $rows ) - 1] ))) { |
1256 | 1437 | return FALSE; /* err 9 */ |
1257 | 1438 | } |
1258 | - if( 3 > count( $rows )) |
|
1259 | - return FALSE; /* err 10 */ |
|
1439 | + if( 3 > count( $rows )) { |
|
1440 | + return FALSE; |
|
1441 | + } |
|
1442 | + /* err 10 */ |
|
1260 | 1443 | $comp = $subcomp = null; |
1261 | 1444 | $actcomp = & $this; |
1262 | 1445 | $nl = $this->getConfig( 'nl' ); |
1263 | 1446 | $calsync = 0; |
1264 | 1447 | /* identify components and update unparsed data within component */ |
1265 | 1448 | foreach( $rows as $line ) { |
1266 | - if( '' == trim( $line )) |
|
1267 | - continue; |
|
1268 | - if( $nl == substr( $line, 0 - strlen( $nl ))) |
|
1269 | - $line = substr( $line, 0, ( strlen( $line ) - strlen( $nl ))).'\n'; |
|
1449 | + if( '' == trim( $line )) { |
|
1450 | + continue; |
|
1451 | + } |
|
1452 | + if( $nl == substr( $line, 0 - strlen( $nl ))) { |
|
1453 | + $line = substr( $line, 0, ( strlen( $line ) - strlen( $nl ))).'\n'; |
|
1454 | + } |
|
1270 | 1455 | if( 'BEGIN:VCALENDAR' == strtoupper( substr( $line, 0, 15 ))) { |
1271 | 1456 | $calsync++; |
1272 | 1457 | continue; |
1273 | - } |
|
1274 | - elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) { |
|
1458 | + } elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) { |
|
1275 | 1459 | $calsync--; |
1276 | 1460 | continue; |
1461 | + } elseif( 1 != $calsync ) { |
|
1462 | + return FALSE; |
|
1277 | 1463 | } |
1278 | - elseif( 1 != $calsync ) |
|
1279 | - return FALSE; /* err 20 */ |
|
1464 | + /* err 20 */ |
|
1280 | 1465 | if( 'END:' == strtoupper( substr( $line, 0, 4 ))) { |
1281 | 1466 | if( null != $subcomp ) { |
1282 | 1467 | $comp->setComponent( $subcomp ); |
1283 | 1468 | $subcomp = null; |
1284 | - } |
|
1285 | - else { |
|
1469 | + } else { |
|
1286 | 1470 | $this->setComponent( $comp ); |
1287 | 1471 | $comp = null; |
1288 | 1472 | } |
@@ -1293,17 +1477,18 @@ discard block |
||
1293 | 1477 | $line = str_replace( '\n', '', $line ); |
1294 | 1478 | $compname = trim (strtoupper( substr( $line, 6 ))); |
1295 | 1479 | if( null != $comp ) { |
1296 | - if( 'VALARM' == $compname ) |
|
1297 | - $subcomp = new valarm(); |
|
1298 | - elseif( 'STANDARD' == $compname ) |
|
1299 | - $subcomp = new vtimezone( 'STANDARD' ); |
|
1300 | - elseif( 'DAYLIGHT' == $compname ) |
|
1301 | - $subcomp = new vtimezone( 'DAYLIGHT' ); |
|
1302 | - else |
|
1303 | - return FALSE; /* err 6 */ |
|
1480 | + if( 'VALARM' == $compname ) { |
|
1481 | + $subcomp = new valarm(); |
|
1482 | + } elseif( 'STANDARD' == $compname ) { |
|
1483 | + $subcomp = new vtimezone( 'STANDARD' ); |
|
1484 | + } elseif( 'DAYLIGHT' == $compname ) { |
|
1485 | + $subcomp = new vtimezone( 'DAYLIGHT' ); |
|
1486 | + } else { |
|
1487 | + return FALSE; |
|
1488 | + } |
|
1489 | + /* err 6 */ |
|
1304 | 1490 | $actcomp = & $subcomp; |
1305 | - } |
|
1306 | - else { |
|
1491 | + } else { |
|
1307 | 1492 | switch( $compname ) { |
1308 | 1493 | case 'VALARM': |
1309 | 1494 | $comp = new valarm(); |
@@ -1352,8 +1537,7 @@ discard block |
||
1352 | 1537 | $newProp = FALSE; |
1353 | 1538 | $lastix++; |
1354 | 1539 | $proprows[$lastix] = $line; |
1355 | - } |
|
1356 | - else { |
|
1540 | + } else { |
|
1357 | 1541 | /* remove line breaks */ |
1358 | 1542 | if(( '\n' == substr( $proprows[$lastix], -2 )) && |
1359 | 1543 | ( ' ' == substr( $line, 0, 1 ))) { |
@@ -1365,19 +1549,22 @@ discard block |
||
1365 | 1549 | } |
1366 | 1550 | $toolbox = new calendarComponent(); |
1367 | 1551 | foreach( $proprows as $line ) { |
1368 | - if( '\n' == substr( $line, -2 )) |
|
1369 | - $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
1552 | + if( '\n' == substr( $line, -2 )) { |
|
1553 | + $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
1554 | + } |
|
1370 | 1555 | /* get propname */ |
1371 | 1556 | $cix = $propname = null; |
1372 | 1557 | for( $cix=0; $cix < strlen( $line ); $cix++ ) { |
1373 | - if( in_array( $line{$cix}, array( ':', ';' ))) |
|
1374 | - break; |
|
1375 | - else |
|
1376 | - $propname .= $line{$cix}; |
|
1558 | + if( in_array( $line{$cix}, array( ':', ';' ))) { |
|
1559 | + break; |
|
1560 | + } else { |
|
1561 | + $propname .= $line{$cix}; |
|
1562 | + } |
|
1377 | 1563 | } |
1378 | 1564 | /* ignore version/prodid properties */ |
1379 | - if( in_array( strtoupper( $propname ), array( 'VERSION', 'PRODID' ))) |
|
1380 | - continue; |
|
1565 | + if( in_array( strtoupper( $propname ), array( 'VERSION', 'PRODID' ))) { |
|
1566 | + continue; |
|
1567 | + } |
|
1381 | 1568 | $line = substr( $line, $cix); |
1382 | 1569 | /* separate attributes from value */ |
1383 | 1570 | $attr = array(); |
@@ -1402,20 +1589,22 @@ discard block |
||
1402 | 1589 | break; |
1403 | 1590 | } |
1404 | 1591 | } |
1405 | - if( ';' == $line{$cix} ) |
|
1406 | - $attr[++$attrix] = null; |
|
1407 | - else |
|
1408 | - $attr[$attrix] .= $line{$cix}; |
|
1592 | + if( ';' == $line{$cix} ) { |
|
1593 | + $attr[++$attrix] = null; |
|
1594 | + } else { |
|
1595 | + $attr[$attrix] .= $line{$cix}; |
|
1596 | + } |
|
1409 | 1597 | } |
1410 | 1598 | |
1411 | 1599 | /* make attributes in array format */ |
1412 | 1600 | $propattr = array(); |
1413 | 1601 | foreach( $attr as $attribute ) { |
1414 | 1602 | $attrsplit = explode( '=', $attribute, 2 ); |
1415 | - if( 1 < count( $attrsplit )) |
|
1416 | - $propattr[$attrsplit[0]] = $attrsplit[1]; |
|
1417 | - else |
|
1418 | - $propattr[] = $attribute; |
|
1603 | + if( 1 < count( $attrsplit )) { |
|
1604 | + $propattr[$attrsplit[0]] = $attrsplit[1]; |
|
1605 | + } else { |
|
1606 | + $propattr[] = $attribute; |
|
1607 | + } |
|
1419 | 1608 | } |
1420 | 1609 | /* update Property */ |
1421 | 1610 | if( FALSE !== strpos( $line, ',' )) { |
@@ -1429,13 +1618,14 @@ discard block |
||
1429 | 1618 | } |
1430 | 1619 | } |
1431 | 1620 | if( 1 < count( $content )) { |
1432 | - foreach( $content as $cix => $contentPart ) |
|
1433 | - $content[$cix] = $toolbox->_strunrep( $contentPart ); |
|
1621 | + foreach( $content as $cix => $contentPart ) { |
|
1622 | + $content[$cix] = $toolbox->_strunrep( $contentPart ); |
|
1623 | + } |
|
1434 | 1624 | $this->setProperty( $propname, $content, $propattr ); |
1435 | 1625 | continue; |
1626 | + } else { |
|
1627 | + $line = reset( $content ); |
|
1436 | 1628 | } |
1437 | - else |
|
1438 | - $line = reset( $content ); |
|
1439 | 1629 | $line = $toolbox->_strunrep( $line ); |
1440 | 1630 | } |
1441 | 1631 | $this->setProperty( $propname, trim( $line ), $propattr ); |
@@ -1444,12 +1634,14 @@ discard block |
||
1444 | 1634 | /* parse Components */ |
1445 | 1635 | if( is_array( $this->components ) && ( 0 < count( $this->components ))) { |
1446 | 1636 | for( $six = 0; $six < count( $this->components ); $six++ ) { |
1447 | - if( !empty( $this->components[$six] )) |
|
1448 | - $this->components[$six]->parse(); |
|
1637 | + if( !empty( $this->components[$six] )) { |
|
1638 | + $this->components[$six]->parse(); |
|
1639 | + } |
|
1449 | 1640 | } |
1641 | + } else { |
|
1642 | + return FALSE; |
|
1450 | 1643 | } |
1451 | - else |
|
1452 | - return FALSE; /* err 91 or something.. . */ |
|
1644 | + /* err 91 or something.. . */ |
|
1453 | 1645 | return TRUE; |
1454 | 1646 | } |
1455 | 1647 | /*********************************************************************************/ |
@@ -1481,8 +1673,9 @@ discard block |
||
1481 | 1673 | switch( $this->format ) { |
1482 | 1674 | case 'xcal': |
1483 | 1675 | $nlstrlen = strlen( $this->nl ); |
1484 | - if( $this->nl == substr( $calendarStart, ( 0 - $nlstrlen ))) |
|
1485 | - $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen )); |
|
1676 | + if( $this->nl == substr( $calendarStart, ( 0 - $nlstrlen ))) { |
|
1677 | + $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen )); |
|
1678 | + } |
|
1486 | 1679 | $calendarStart .= '>'.$this->nl; |
1487 | 1680 | break; |
1488 | 1681 | default: |
@@ -1490,9 +1683,12 @@ discard block |
||
1490 | 1683 | } |
1491 | 1684 | $calendar .= $this->createXprop(); |
1492 | 1685 | foreach( $this->components as $component ) { |
1493 | - if( empty( $component )) continue; |
|
1494 | - if( '' >= $component->getConfig( 'language')) |
|
1495 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
1686 | + if( empty( $component )) { |
|
1687 | + continue; |
|
1688 | + } |
|
1689 | + if( '' >= $component->getConfig( 'language')) { |
|
1690 | + $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
1691 | + } |
|
1496 | 1692 | $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
1497 | 1693 | $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
1498 | 1694 | $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
@@ -1505,8 +1701,10 @@ discard block |
||
1505 | 1701 | foreach( $this->xcaldecl as $declix => $declPart ) { |
1506 | 1702 | if(( 0 < count( $old_xcaldecl)) && |
1507 | 1703 | ( in_array( $declPart['uri'], $old_xcaldecl['uri'] )) && |
1508 | - ( in_array( $declPart['external'], $old_xcaldecl['external'] ))) |
|
1509 | - continue; // no duplicate uri and ext. references |
|
1704 | + ( in_array( $declPart['external'], $old_xcaldecl['external'] ))) { |
|
1705 | + continue; |
|
1706 | + } |
|
1707 | + // no duplicate uri and ext. references |
|
1510 | 1708 | $calendarxCaldecl .= '<!'; |
1511 | 1709 | foreach( $declPart as $declKey => $declValue ) { |
1512 | 1710 | switch( $declKey ) { // index |
@@ -1559,10 +1757,11 @@ discard block |
||
1559 | 1757 | $filesize = strlen( $output ); |
1560 | 1758 | // if( headers_sent( $filename, $linenum )) |
1561 | 1759 | // die( "Headers already sent in $filename on line $linenum\n" ); |
1562 | - if( 'xcal' == $this->format ) |
|
1563 | - header( 'Content-Type: application/calendar+xml; charset=utf-8' ); |
|
1564 | - else |
|
1565 | - header( 'Content-Type: text/calendar; charset=utf-8' ); |
|
1760 | + if( 'xcal' == $this->format ) { |
|
1761 | + header( 'Content-Type: application/calendar+xml; charset=utf-8' ); |
|
1762 | + } else { |
|
1763 | + header( 'Content-Type: text/calendar; charset=utf-8' ); |
|
1764 | + } |
|
1566 | 1765 | header( 'Content-Length: '.$filesize ); |
1567 | 1766 | header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
1568 | 1767 | header( 'Cache-Control: max-age=10' ); |
@@ -1580,23 +1779,28 @@ discard block |
||
1580 | 1779 | * @return bool |
1581 | 1780 | */ |
1582 | 1781 | function saveCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE ) { |
1583 | - if( $directory ) |
|
1584 | - $this->setConfig( 'directory', $directory ); |
|
1585 | - if( $filename ) |
|
1586 | - $this->setConfig( 'filename', $filename ); |
|
1587 | - if( $delimiter && ($delimiter != DIRECTORY_SEPARATOR )) |
|
1588 | - $this->setConfig( 'delimiter', $delimiter ); |
|
1589 | - if( FALSE === ( $dirfile = $this->getConfig( 'url' ))) |
|
1590 | - $dirfile = $this->getConfig( 'dirfile' ); |
|
1782 | + if( $directory ) { |
|
1783 | + $this->setConfig( 'directory', $directory ); |
|
1784 | + } |
|
1785 | + if( $filename ) { |
|
1786 | + $this->setConfig( 'filename', $filename ); |
|
1787 | + } |
|
1788 | + if( $delimiter && ($delimiter != DIRECTORY_SEPARATOR )) { |
|
1789 | + $this->setConfig( 'delimiter', $delimiter ); |
|
1790 | + } |
|
1791 | + if( FALSE === ( $dirfile = $this->getConfig( 'url' ))) { |
|
1792 | + $dirfile = $this->getConfig( 'dirfile' ); |
|
1793 | + } |
|
1591 | 1794 | $iCalFile = @fopen( $dirfile, 'w' ); |
1592 | 1795 | if( $iCalFile ) { |
1593 | - if( FALSE === fwrite( $iCalFile, $this->createCalendar() )) |
|
1594 | - return FALSE; |
|
1796 | + if( FALSE === fwrite( $iCalFile, $this->createCalendar() )) { |
|
1797 | + return FALSE; |
|
1798 | + } |
|
1595 | 1799 | fclose( $iCalFile ); |
1596 | 1800 | return TRUE; |
1801 | + } else { |
|
1802 | + return FALSE; |
|
1597 | 1803 | } |
1598 | - else |
|
1599 | - return FALSE; |
|
1600 | 1804 | } |
1601 | 1805 | /** |
1602 | 1806 | * if recent version of calendar file exists (default one hour), an HTTP redirect header is sent |
@@ -1615,15 +1819,19 @@ discard block |
||
1615 | 1819 | $timeout = (int) $directory; |
1616 | 1820 | $directory = FALSE; |
1617 | 1821 | } |
1618 | - if( $directory ) |
|
1619 | - $this->setConfig( 'directory', $directory ); |
|
1620 | - if( $filename ) |
|
1621 | - $this->setConfig( 'filename', $filename ); |
|
1622 | - if( $delimiter && ( $delimiter != DIRECTORY_SEPARATOR )) |
|
1623 | - $this->setConfig( 'delimiter', $delimiter ); |
|
1822 | + if( $directory ) { |
|
1823 | + $this->setConfig( 'directory', $directory ); |
|
1824 | + } |
|
1825 | + if( $filename ) { |
|
1826 | + $this->setConfig( 'filename', $filename ); |
|
1827 | + } |
|
1828 | + if( $delimiter && ( $delimiter != DIRECTORY_SEPARATOR )) { |
|
1829 | + $this->setConfig( 'delimiter', $delimiter ); |
|
1830 | + } |
|
1624 | 1831 | $filesize = $this->getConfig( 'filesize' ); |
1625 | - if( 0 >= $filesize ) |
|
1626 | - return FALSE; |
|
1832 | + if( 0 >= $filesize ) { |
|
1833 | + return FALSE; |
|
1834 | + } |
|
1627 | 1835 | $dirfile = $this->getConfig( 'dirfile' ); |
1628 | 1836 | if( time() - filemtime( $dirfile ) < $timeout) { |
1629 | 1837 | clearstatcache(); |
@@ -1631,10 +1839,11 @@ discard block |
||
1631 | 1839 | $filename = $this->getConfig( 'filename' ); |
1632 | 1840 | // if( headers_sent( $filename, $linenum )) |
1633 | 1841 | // die( "Headers already sent in $filename on line $linenum\n" ); |
1634 | - if( 'xcal' == $this->format ) |
|
1635 | - header( 'Content-Type: application/calendar+xml; charset=utf-8' ); |
|
1636 | - else |
|
1637 | - header( 'Content-Type: text/calendar; charset=utf-8' ); |
|
1842 | + if( 'xcal' == $this->format ) { |
|
1843 | + header( 'Content-Type: application/calendar+xml; charset=utf-8' ); |
|
1844 | + } else { |
|
1845 | + header( 'Content-Type: text/calendar; charset=utf-8' ); |
|
1846 | + } |
|
1638 | 1847 | header( 'Content-Length: '.$filesize ); |
1639 | 1848 | header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
1640 | 1849 | header( 'Cache-Control: max-age=10' ); |
@@ -1644,9 +1853,9 @@ discard block |
||
1644 | 1853 | fclose( $fp ); |
1645 | 1854 | } |
1646 | 1855 | die(); |
1856 | + } else { |
|
1857 | + return FALSE; |
|
1647 | 1858 | } |
1648 | - else |
|
1649 | - return FALSE; |
|
1650 | 1859 | } |
1651 | 1860 | } |
1652 | 1861 | /*********************************************************************************/ |
@@ -1717,9 +1926,12 @@ discard block |
||
1717 | 1926 | * @return string |
1718 | 1927 | */ |
1719 | 1928 | function createAction() { |
1720 | - if( empty( $this->action )) return FALSE; |
|
1721 | - if( empty( $this->action['value'] )) |
|
1722 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE; |
|
1929 | + if( empty( $this->action )) { |
|
1930 | + return FALSE; |
|
1931 | + } |
|
1932 | + if( empty( $this->action['value'] )) { |
|
1933 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE; |
|
1934 | + } |
|
1723 | 1935 | $attributes = $this->_createParams( $this->action['params'] ); |
1724 | 1936 | return $this->_createElement( 'ACTION', $attributes, $this->action['value'] ); |
1725 | 1937 | } |
@@ -1733,7 +1945,11 @@ discard block |
||
1733 | 1945 | * @return bool |
1734 | 1946 | */ |
1735 | 1947 | function setAction( $value, $params=FALSE ) { |
1736 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1948 | + if( empty( $value )) { |
|
1949 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
1950 | + } else { |
|
1951 | + return FALSE; |
|
1952 | + } |
|
1737 | 1953 | $this->action = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
1738 | 1954 | return TRUE; |
1739 | 1955 | } |
@@ -1749,14 +1965,17 @@ discard block |
||
1749 | 1965 | * @return string |
1750 | 1966 | */ |
1751 | 1967 | function createAttach() { |
1752 | - if( empty( $this->attach )) return FALSE; |
|
1968 | + if( empty( $this->attach )) { |
|
1969 | + return FALSE; |
|
1970 | + } |
|
1753 | 1971 | $output = null; |
1754 | 1972 | foreach( $this->attach as $attachPart ) { |
1755 | 1973 | if(! empty( $attachPart['value'] )) { |
1756 | 1974 | $attributes = $this->_createParams( $attachPart['params'] ); |
1757 | 1975 | $output .= $this->_createElement( 'ATTACH', $attributes, $attachPart['value'] ); |
1976 | + } elseif( $this->getConfig( 'allowEmpty' )) { |
|
1977 | + $output .= $this->_createElement( 'ATTACH' ); |
|
1758 | 1978 | } |
1759 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'ATTACH' ); |
|
1760 | 1979 | } |
1761 | 1980 | return $output; |
1762 | 1981 | } |
@@ -1771,7 +1990,11 @@ discard block |
||
1771 | 1990 | * @return bool |
1772 | 1991 | */ |
1773 | 1992 | function setAttach( $value, $params=FALSE, $index=FALSE ) { |
1774 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1993 | + if( empty( $value )) { |
|
1994 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
1995 | + } else { |
|
1996 | + return FALSE; |
|
1997 | + } |
|
1775 | 1998 | $this->_setMval( $this->attach, $value, $params, FALSE, $index ); |
1776 | 1999 | return TRUE; |
1777 | 2000 | } |
@@ -1787,19 +2010,22 @@ discard block |
||
1787 | 2010 | * @return string |
1788 | 2011 | */ |
1789 | 2012 | function createAttendee() { |
1790 | - if( empty( $this->attendee )) return FALSE; |
|
1791 | - $output = null; |
|
2013 | + if( empty( $this->attendee )) { |
|
2014 | + return FALSE; |
|
2015 | + } |
|
2016 | + $output = null; |
|
1792 | 2017 | foreach( $this->attendee as $attendeePart ) { // start foreach 1 |
1793 | 2018 | if( empty( $attendeePart['value'] )) { |
1794 | - if( $this->getConfig( 'allowEmpty' )) |
|
1795 | - $output .= $this->_createElement( 'ATTENDEE' ); |
|
2019 | + if( $this->getConfig( 'allowEmpty' )) { |
|
2020 | + $output .= $this->_createElement( 'ATTENDEE' ); |
|
2021 | + } |
|
1796 | 2022 | continue; |
1797 | 2023 | } |
1798 | 2024 | $attendee1 = $attendee2 = $attendeeLANG = $attendeeCN = null; |
1799 | 2025 | foreach( $attendeePart as $paramlabel => $paramvalue ) { // start foreach 2 |
1800 | - if( 'value' == $paramlabel ) |
|
1801 | - $attendee2 .= 'MAILTO:'.$paramvalue; |
|
1802 | - elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) { // start elseif |
|
2026 | + if( 'value' == $paramlabel ) { |
|
2027 | + $attendee2 .= 'MAILTO:'.$paramvalue; |
|
2028 | + } elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) { // start elseif |
|
1803 | 2029 | foreach( $paramvalue as $optparamlabel => $optparamvalue ) { // start foreach 3 |
1804 | 2030 | $attendee11 = $attendee12 = null; |
1805 | 2031 | if( is_int( $optparamlabel )) { |
@@ -1861,7 +2087,11 @@ discard block |
||
1861 | 2087 | * @return bool |
1862 | 2088 | */ |
1863 | 2089 | function setAttendee( $value, $params=FALSE, $index=FALSE ) { |
1864 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2090 | + if( empty( $value )) { |
|
2091 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
2092 | + } else { |
|
2093 | + return FALSE; |
|
2094 | + } |
|
1865 | 2095 | $value = str_replace ( 'MAILTO:', '', $value ); |
1866 | 2096 | $value = str_replace ( 'mailto:', '', $value ); |
1867 | 2097 | $params2 = array(); |
@@ -1877,16 +2107,17 @@ discard block |
||
1877 | 2107 | foreach( $optparamvalue as $part ) { |
1878 | 2108 | $part = str_replace( 'MAILTO:', '', $part ); |
1879 | 2109 | $part = str_replace( 'mailto:', '', $part ); |
1880 | - if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) |
|
1881 | - $part = substr( $part, 1, ( strlen($part)-2 )); |
|
2110 | + if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) { |
|
2111 | + $part = substr( $part, 1, ( strlen($part)-2 )); |
|
2112 | + } |
|
1882 | 2113 | $optarrays[$optparamlabel][] = $part; |
1883 | 2114 | } |
1884 | - } |
|
1885 | - else { |
|
2115 | + } else { |
|
1886 | 2116 | $part = str_replace( 'MAILTO:', '', $optparamvalue ); |
1887 | 2117 | $part = str_replace( 'mailto:', '', $part ); |
1888 | - if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) |
|
1889 | - $part = substr( $part, 1, ( strlen($part)-2 )); |
|
2118 | + if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) { |
|
2119 | + $part = substr( $part, 1, ( strlen($part)-2 )); |
|
2120 | + } |
|
1890 | 2121 | $optarrays[$optparamlabel][] = $part; |
1891 | 2122 | } |
1892 | 2123 | break; |
@@ -1896,14 +2127,16 @@ discard block |
||
1896 | 2127 | $optparamvalue = str_replace( 'mailto:', '', $optparamvalue ); |
1897 | 2128 | } |
1898 | 2129 | if(( '"' == substr( $optparamvalue, 0, 1 )) && |
1899 | - ( '"' == substr( $optparamvalue, -1 ))) |
|
1900 | - $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 )); |
|
2130 | + ( '"' == substr( $optparamvalue, -1 ))) { |
|
2131 | + $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 )); |
|
2132 | + } |
|
1901 | 2133 | $params2[$optparamlabel] = $optparamvalue; |
1902 | 2134 | break; |
1903 | 2135 | } // end switch( $optparamlabel.. . |
1904 | 2136 | } // end foreach( $optparam.. . |
1905 | - foreach( $optarrays as $optparamlabel => $optparams ) |
|
1906 | - $params2[$optparamlabel] = $optparams; |
|
2137 | + foreach( $optarrays as $optparamlabel => $optparams ) { |
|
2138 | + $params2[$optparamlabel] = $optparams; |
|
2139 | + } |
|
1907 | 2140 | } |
1908 | 2141 | // remove defaults |
1909 | 2142 | $this->_existRem( $params2, 'CUTYPE', 'INDIVIDUAL' ); |
@@ -1913,8 +2146,9 @@ discard block |
||
1913 | 2146 | // check language setting |
1914 | 2147 | if( isset( $params2['CN' ] )) { |
1915 | 2148 | $lang = $this->getConfig( 'language' ); |
1916 | - if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang )) |
|
1917 | - $params2['LANGUAGE' ] = $lang; |
|
2149 | + if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang )) { |
|
2150 | + $params2['LANGUAGE' ] = $lang; |
|
2151 | + } |
|
1918 | 2152 | } |
1919 | 2153 | $this->_setMval( $this->attendee, $value, $params2, FALSE, $index ); |
1920 | 2154 | return TRUE; |
@@ -1931,22 +2165,26 @@ discard block |
||
1931 | 2165 | * @return string |
1932 | 2166 | */ |
1933 | 2167 | function createCategories() { |
1934 | - if( empty( $this->categories )) return FALSE; |
|
2168 | + if( empty( $this->categories )) { |
|
2169 | + return FALSE; |
|
2170 | + } |
|
1935 | 2171 | $output = null; |
1936 | 2172 | foreach( $this->categories as $category ) { |
1937 | 2173 | if( empty( $category['value'] )) { |
1938 | - if ( $this->getConfig( 'allowEmpty' )) |
|
1939 | - $output .= $this->_createElement( 'CATEGORIES' ); |
|
2174 | + if ( $this->getConfig( 'allowEmpty' )) { |
|
2175 | + $output .= $this->_createElement( 'CATEGORIES' ); |
|
2176 | + } |
|
1940 | 2177 | continue; |
1941 | 2178 | } |
1942 | 2179 | $attributes = $this->_createParams( $category['params'], array( 'LANGUAGE' )); |
1943 | 2180 | if( is_array( $category['value'] )) { |
1944 | - foreach( $category['value'] as $cix => $categoryPart ) |
|
1945 | - $category['value'][$cix] = $this->_strrep( $categoryPart ); |
|
2181 | + foreach( $category['value'] as $cix => $categoryPart ) { |
|
2182 | + $category['value'][$cix] = $this->_strrep( $categoryPart ); |
|
2183 | + } |
|
1946 | 2184 | $content = implode( ',', $category['value'] ); |
2185 | + } else { |
|
2186 | + $content = $this->_strrep( $category['value'] ); |
|
1947 | 2187 | } |
1948 | - else |
|
1949 | - $content = $this->_strrep( $category['value'] ); |
|
1950 | 2188 | $output .= $this->_createElement( 'CATEGORIES', $attributes, $content ); |
1951 | 2189 | } |
1952 | 2190 | return $output; |
@@ -1962,7 +2200,11 @@ discard block |
||
1962 | 2200 | * @return bool |
1963 | 2201 | */ |
1964 | 2202 | function setCategories( $value, $params=FALSE, $index=FALSE ) { |
1965 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2203 | + if( empty( $value )) { |
|
2204 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
2205 | + } else { |
|
2206 | + return FALSE; |
|
2207 | + } |
|
1966 | 2208 | $this->_setMval( $this->categories, $value, $params, FALSE, $index ); |
1967 | 2209 | return TRUE; |
1968 | 2210 | } |
@@ -1978,9 +2220,12 @@ discard block |
||
1978 | 2220 | * @return string |
1979 | 2221 | */ |
1980 | 2222 | function createClass() { |
1981 | - if( empty( $this->class )) return FALSE; |
|
1982 | - if( empty( $this->class['value'] )) |
|
1983 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE; |
|
2223 | + if( empty( $this->class )) { |
|
2224 | + return FALSE; |
|
2225 | + } |
|
2226 | + if( empty( $this->class['value'] )) { |
|
2227 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE; |
|
2228 | + } |
|
1984 | 2229 | $attributes = $this->_createParams( $this->class['params'] ); |
1985 | 2230 | return $this->_createElement( 'CLASS', $attributes, $this->class['value'] ); |
1986 | 2231 | } |
@@ -1994,7 +2239,11 @@ discard block |
||
1994 | 2239 | * @return bool |
1995 | 2240 | */ |
1996 | 2241 | function setClass( $value, $params=FALSE ) { |
1997 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2242 | + if( empty( $value )) { |
|
2243 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
2244 | + } else { |
|
2245 | + return FALSE; |
|
2246 | + } |
|
1998 | 2247 | $this->class = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
1999 | 2248 | return TRUE; |
2000 | 2249 | } |
@@ -2010,11 +2259,15 @@ discard block |
||
2010 | 2259 | * @return string |
2011 | 2260 | */ |
2012 | 2261 | function createComment() { |
2013 | - if( empty( $this->comment )) return FALSE; |
|
2262 | + if( empty( $this->comment )) { |
|
2263 | + return FALSE; |
|
2264 | + } |
|
2014 | 2265 | $output = null; |
2015 | 2266 | foreach( $this->comment as $commentPart ) { |
2016 | 2267 | if( empty( $commentPart['value'] )) { |
2017 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'COMMENT' ); |
|
2268 | + if( $this->getConfig( 'allowEmpty' )) { |
|
2269 | + $output .= $this->_createElement( 'COMMENT' ); |
|
2270 | + } |
|
2018 | 2271 | continue; |
2019 | 2272 | } |
2020 | 2273 | $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,19 +2761,24 @@ discard block |
||
2464 | 2761 | * @return bool |
2465 | 2762 | */ |
2466 | 2763 | function setDuration( $week, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
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 )); |
2777 | + } elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec )) { |
|
2778 | + return FALSE; |
|
2779 | + } else { |
|
2780 | + $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params )); |
|
2475 | 2781 | } |
2476 | - elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec )) |
|
2477 | - return FALSE; |
|
2478 | - else |
|
2479 | - $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params )); |
|
2480 | 2782 | return TRUE; |
2481 | 2783 | } |
2482 | 2784 | /*********************************************************************************/ |
@@ -2491,31 +2793,37 @@ discard block |
||
2491 | 2793 | * @return string |
2492 | 2794 | */ |
2493 | 2795 | function createExdate() { |
2494 | - if( empty( $this->exdate )) return FALSE; |
|
2796 | + if( empty( $this->exdate )) { |
|
2797 | + return FALSE; |
|
2798 | + } |
|
2495 | 2799 | $output = null; |
2496 | 2800 | foreach( $this->exdate as $ex => $theExdate ) { |
2497 | 2801 | if( empty( $theExdate['value'] )) { |
2498 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'EXDATE' ); |
|
2802 | + if( $this->getConfig( 'allowEmpty' )) { |
|
2803 | + $output .= $this->_createElement( 'EXDATE' ); |
|
2804 | + } |
|
2499 | 2805 | continue; |
2500 | 2806 | } |
2501 | 2807 | $content = $attributes = null; |
2502 | 2808 | foreach( $theExdate['value'] as $eix => $exdatePart ) { |
2503 | 2809 | $parno = count( $exdatePart ); |
2504 | 2810 | $formatted = $this->_format_date_time( $exdatePart, $parno ); |
2505 | - if( isset( $theExdate['params']['TZID'] )) |
|
2506 | - $formatted = str_replace( 'Z', '', $formatted); |
|
2811 | + if( isset( $theExdate['params']['TZID'] )) { |
|
2812 | + $formatted = str_replace( 'Z', '', $formatted); |
|
2813 | + } |
|
2507 | 2814 | if( 0 < $eix ) { |
2508 | 2815 | if( isset( $theExdate['value'][0]['tz'] )) { |
2509 | 2816 | if( ctype_digit( substr( $theExdate['value'][0]['tz'], -4 )) || |
2510 | 2817 | ( 'Z' == $theExdate['value'][0]['tz'] )) { |
2511 | - if( 'Z' != substr( $formatted, -1 )) |
|
2512 | - $formatted .= 'Z'; |
|
2818 | + if( 'Z' != substr( $formatted, -1 )) { |
|
2819 | + $formatted .= 'Z'; |
|
2820 | + } |
|
2821 | + } else { |
|
2822 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
2513 | 2823 | } |
2514 | - else |
|
2515 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2824 | + } else { |
|
2825 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
2516 | 2826 | } |
2517 | - else |
|
2518 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2519 | 2827 | } |
2520 | 2828 | $content .= ( 0 < $eix ) ? ','.$formatted : $formatted; |
2521 | 2829 | } |
@@ -2539,34 +2847,39 @@ discard block |
||
2539 | 2847 | if( $this->getConfig( 'allowEmpty' )) { |
2540 | 2848 | $this->_setMval( $this->exdate, null, $params, FALSE, $index ); |
2541 | 2849 | return TRUE; |
2850 | + } else { |
|
2851 | + return FALSE; |
|
2542 | 2852 | } |
2543 | - else |
|
2544 | - return FALSE; |
|
2545 | 2853 | } |
2546 | 2854 | $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ))); |
2547 | 2855 | /* ev. check 1:st date and save ev. timezone **/ |
2548 | 2856 | $this->_chkdatecfg( reset( $exdates ), $parno, $input['params'] ); |
2549 | 2857 | $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default parameter |
2550 | 2858 | foreach( $exdates as $eix => $theExdate ) { |
2551 | - if( $this->_isArrayTimestampDate( $theExdate )) |
|
2552 | - $exdatea = $this->_timestamp2date( $theExdate, $parno ); |
|
2553 | - elseif( is_array( $theExdate )) |
|
2554 | - $exdatea = $this->_date_time_array( $theExdate, $parno ); |
|
2555 | - elseif( 8 <= strlen( trim( $theExdate ))) // ex. 2006-08-03 10:12:18 |
|
2859 | + if( $this->_isArrayTimestampDate( $theExdate )) { |
|
2860 | + $exdatea = $this->_timestamp2date( $theExdate, $parno ); |
|
2861 | + } elseif( is_array( $theExdate )) { |
|
2862 | + $exdatea = $this->_date_time_array( $theExdate, $parno ); |
|
2863 | + } elseif( 8 <= strlen( trim( $theExdate ))) { |
|
2864 | + // ex. 2006-08-03 10:12:18 |
|
2556 | 2865 | $exdatea = $this->_date_time_string( $theExdate, $parno ); |
2557 | - if( 3 == $parno ) |
|
2558 | - unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] ); |
|
2559 | - elseif( isset( $exdatea['tz'] )) |
|
2560 | - $exdatea['tz'] = (string) $exdatea['tz']; |
|
2866 | + } |
|
2867 | + if( 3 == $parno ) { |
|
2868 | + unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] ); |
|
2869 | + } elseif( isset( $exdatea['tz'] )) { |
|
2870 | + $exdatea['tz'] = (string) $exdatea['tz']; |
|
2871 | + } |
|
2561 | 2872 | if( isset( $input['params']['TZID'] ) || |
2562 | 2873 | ( isset( $exdatea['tz'] ) && !$this->_isOffset( $exdatea['tz'] )) || |
2563 | 2874 | ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) || |
2564 | - ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) |
|
2565 | - unset( $exdatea['tz'] ); |
|
2875 | + ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) { |
|
2876 | + unset( $exdatea['tz'] ); |
|
2877 | + } |
|
2566 | 2878 | $input['value'][] = $exdatea; |
2567 | 2879 | } |
2568 | - if( 0 >= count( $input['value'] )) |
|
2569 | - return FALSE; |
|
2880 | + if( 0 >= count( $input['value'] )) { |
|
2881 | + return FALSE; |
|
2882 | + } |
|
2570 | 2883 | if( 3 == $parno ) { |
2571 | 2884 | $input['params']['VALUE'] = 'DATE'; |
2572 | 2885 | unset( $input['params']['TZID'] ); |
@@ -2586,7 +2899,9 @@ discard block |
||
2586 | 2899 | * @return string |
2587 | 2900 | */ |
2588 | 2901 | function createExrule() { |
2589 | - if( empty( $this->exrule )) return FALSE; |
|
2902 | + if( empty( $this->exrule )) { |
|
2903 | + return FALSE; |
|
2904 | + } |
|
2590 | 2905 | return $this->_format_recur( 'EXRULE', $this->exrule ); |
2591 | 2906 | } |
2592 | 2907 | /** |
@@ -2600,7 +2915,11 @@ discard block |
||
2600 | 2915 | * @return bool |
2601 | 2916 | */ |
2602 | 2917 | function setExrule( $exruleset, $params=FALSE, $index=FALSE ) { |
2603 | - if( empty( $exruleset )) if( $this->getConfig( 'allowEmpty' )) $exruleset = null; else return FALSE; |
|
2918 | + if( empty( $exruleset )) { |
|
2919 | + if( $this->getConfig( 'allowEmpty' )) $exruleset = null; |
|
2920 | + } else { |
|
2921 | + return FALSE; |
|
2922 | + } |
|
2604 | 2923 | $this->_setMval( $this->exrule, $this->_setRexrule( $exruleset ), $params, FALSE, $index ); |
2605 | 2924 | return TRUE; |
2606 | 2925 | } |
@@ -2616,11 +2935,15 @@ discard block |
||
2616 | 2935 | * @return string |
2617 | 2936 | */ |
2618 | 2937 | function createFreebusy() { |
2619 | - if( empty( $this->freebusy )) return FALSE; |
|
2938 | + if( empty( $this->freebusy )) { |
|
2939 | + return FALSE; |
|
2940 | + } |
|
2620 | 2941 | $output = null; |
2621 | 2942 | foreach( $this->freebusy as $freebusyPart ) { |
2622 | 2943 | if( empty( $freebusyPart['value'] )) { |
2623 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'FREEBUSY' ); |
|
2944 | + if( $this->getConfig( 'allowEmpty' )) { |
|
2945 | + $output .= $this->_createElement( 'FREEBUSY' ); |
|
2946 | + } |
|
2624 | 2947 | continue; |
2625 | 2948 | } |
2626 | 2949 | $attributes = $content = null; |
@@ -2628,9 +2951,9 @@ discard block |
||
2628 | 2951 | $attributes .= $this->intAttrDelimiter.'FBTYPE='.$freebusyPart['value']['fbtype']; |
2629 | 2952 | unset( $freebusyPart['value']['fbtype'] ); |
2630 | 2953 | $freebusyPart['value'] = array_values( $freebusyPart['value'] ); |
2954 | + } else { |
|
2955 | + $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY'; |
|
2631 | 2956 | } |
2632 | - else |
|
2633 | - $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY'; |
|
2634 | 2957 | $attributes .= $this->_createParams( $freebusyPart['params'] ); |
2635 | 2958 | $fno = 1; |
2636 | 2959 | $cnt = count( $freebusyPart['value']); |
@@ -2639,21 +2962,24 @@ discard block |
||
2639 | 2962 | $content .= $formatted; |
2640 | 2963 | $content .= '/'; |
2641 | 2964 | $cnt2 = count( $freebusyPeriod[1]); |
2642 | - if( array_key_exists( 'year', $freebusyPeriod[1] )) // date-time |
|
2965 | + if( array_key_exists( 'year', $freebusyPeriod[1] )) { |
|
2966 | + // date-time |
|
2643 | 2967 | $cnt2 = 7; |
2644 | - elseif( array_key_exists( 'week', $freebusyPeriod[1] )) // duration |
|
2968 | + } elseif( array_key_exists( 'week', $freebusyPeriod[1] )) { |
|
2969 | + // duration |
|
2645 | 2970 | $cnt2 = 5; |
2971 | + } |
|
2646 | 2972 | if(( 7 == $cnt2 ) && // period= -> date-time |
2647 | 2973 | isset( $freebusyPeriod[1]['year'] ) && |
2648 | 2974 | isset( $freebusyPeriod[1]['month'] ) && |
2649 | 2975 | isset( $freebusyPeriod[1]['day'] )) { |
2650 | 2976 | $content .= $this->_format_date_time( $freebusyPeriod[1] ); |
2651 | - } |
|
2652 | - else { // period= -> dur-time |
|
2977 | + } else { // period= -> dur-time |
|
2653 | 2978 | $content .= $this->_format_duration( $freebusyPeriod[1] ); |
2654 | 2979 | } |
2655 | - if( $fno < $cnt ) |
|
2656 | - $content .= ','; |
|
2980 | + if( $fno < $cnt ) { |
|
2981 | + $content .= ','; |
|
2982 | + } |
|
2657 | 2983 | $fno++; |
2658 | 2984 | } |
2659 | 2985 | $output .= $this->_createElement( 'FREEBUSY', $attributes, $content ); |
@@ -2676,14 +3002,15 @@ discard block |
||
2676 | 3002 | if( $this->getConfig( 'allowEmpty' )) { |
2677 | 3003 | $this->_setMval( $this->freebusy, null, $params, FALSE, $index ); |
2678 | 3004 | return TRUE; |
3005 | + } else { |
|
3006 | + return FALSE; |
|
2679 | 3007 | } |
2680 | - else |
|
2681 | - return FALSE; |
|
2682 | 3008 | } |
2683 | 3009 | $fbType = strtoupper( $fbType ); |
2684 | 3010 | if(( !in_array( $fbType, array( 'FREE', 'BUSY', 'BUSY-UNAVAILABLE', 'BUSY-TENTATIVE' ))) && |
2685 | - ( 'X-' != substr( $fbType, 0, 2 ))) |
|
2686 | - $fbType = 'BUSY'; |
|
3011 | + ( 'X-' != substr( $fbType, 0, 2 ))) { |
|
3012 | + $fbType = 'BUSY'; |
|
3013 | + } |
|
2687 | 3014 | $input = array( 'fbtype' => $fbType ); |
2688 | 3015 | foreach( $fbValues as $fbPeriod ) { // periods => period |
2689 | 3016 | $freebusyPeriod = array(); |
@@ -2693,22 +3020,19 @@ discard block |
||
2693 | 3020 | if( $this->_isArrayDate( $fbMember )) { // date-time value |
2694 | 3021 | $freebusyPairMember = $this->_date_time_array( $fbMember, 7 ); |
2695 | 3022 | $freebusyPairMember['tz'] = 'Z'; |
2696 | - } |
|
2697 | - elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value |
|
3023 | + } elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value |
|
2698 | 3024 | $freebusyPairMember = $this->_timestamp2date( $fbMember['timestamp'], 7 ); |
2699 | 3025 | $freebusyPairMember['tz'] = 'Z'; |
2700 | - } |
|
2701 | - else { // array format duration |
|
3026 | + } else { // array format duration |
|
2702 | 3027 | $freebusyPairMember = $this->_duration_array( $fbMember ); |
2703 | 3028 | } |
2704 | - } |
|
2705 | - elseif(( 3 <= strlen( trim( $fbMember ))) && // string format duration |
|
3029 | + } elseif(( 3 <= strlen( trim( $fbMember ))) && // string format duration |
|
2706 | 3030 | ( in_array( $fbMember{0}, array( 'P', '+', '-' )))) { |
2707 | - if( 'P' != $fbMember{0} ) |
|
2708 | - $fbmember = substr( $fbMember, 1 ); |
|
3031 | + if( 'P' != $fbMember{0} ) { |
|
3032 | + $fbmember = substr( $fbMember, 1 ); |
|
3033 | + } |
|
2709 | 3034 | $freebusyPairMember = $this->_duration_string( $fbMember ); |
2710 | - } |
|
2711 | - elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18 |
|
3035 | + } elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18 |
|
2712 | 3036 | $freebusyPairMember = $this->_date_time_string( $fbMember, 7 ); |
2713 | 3037 | $freebusyPairMember['tz'] = 'Z'; |
2714 | 3038 | } |
@@ -2731,9 +3055,12 @@ discard block |
||
2731 | 3055 | * @return string |
2732 | 3056 | */ |
2733 | 3057 | function createGeo() { |
2734 | - if( empty( $this->geo )) return FALSE; |
|
2735 | - if( empty( $this->geo['value'] )) |
|
2736 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE; |
|
3058 | + if( empty( $this->geo )) { |
|
3059 | + return FALSE; |
|
3060 | + } |
|
3061 | + if( empty( $this->geo['value'] )) { |
|
3062 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE; |
|
3063 | + } |
|
2737 | 3064 | $attributes = $this->_createParams( $this->geo['params'] ); |
2738 | 3065 | $content = null; |
2739 | 3066 | $content .= number_format( (float) $this->geo['value']['latitude'], 6, '.', ''); |
@@ -2753,15 +3080,17 @@ discard block |
||
2753 | 3080 | */ |
2754 | 3081 | function setGeo( $latitude, $longitude, $params=FALSE ) { |
2755 | 3082 | if( !empty( $latitude ) && !empty( $longitude )) { |
2756 | - if( !is_array( $this->geo )) $this->geo = array(); |
|
3083 | + if( !is_array( $this->geo )) { |
|
3084 | + $this->geo = array(); |
|
3085 | + } |
|
2757 | 3086 | $this->geo['value']['latitude'] = $latitude; |
2758 | 3087 | $this->geo['value']['longitude'] = $longitude; |
2759 | 3088 | $this->geo['params'] = $this->_setParams( $params ); |
3089 | + } elseif( $this->getConfig( 'allowEmpty' )) { |
|
3090 | + $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) ); |
|
3091 | + } else { |
|
3092 | + return FALSE; |
|
2760 | 3093 | } |
2761 | - elseif( $this->getConfig( 'allowEmpty' )) |
|
2762 | - $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) ); |
|
2763 | - else |
|
2764 | - return FALSE; |
|
2765 | 3094 | return TRUE; |
2766 | 3095 | } |
2767 | 3096 | /*********************************************************************************/ |
@@ -2776,7 +3105,9 @@ discard block |
||
2776 | 3105 | * @return string |
2777 | 3106 | */ |
2778 | 3107 | function createLastModified() { |
2779 | - if( empty( $this->lastmodified )) return FALSE; |
|
3108 | + if( empty( $this->lastmodified )) { |
|
3109 | + return FALSE; |
|
3110 | + } |
|
2780 | 3111 | $attributes = $this->_createParams( $this->lastmodified['params'] ); |
2781 | 3112 | $formatted = $this->_format_date_time( $this->lastmodified['value'], 7 ); |
2782 | 3113 | return $this->_createElement( 'LAST-MODIFIED', $attributes, $formatted ); |
@@ -2796,8 +3127,9 @@ discard block |
||
2796 | 3127 | * @return boll |
2797 | 3128 | */ |
2798 | 3129 | function setLastModified( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
2799 | - if( empty( $year )) |
|
2800 | - $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' ))); |
|
3130 | + if( empty( $year )) { |
|
3131 | + $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' ))); |
|
3132 | + } |
|
2801 | 3133 | $this->lastmodified = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
2802 | 3134 | return TRUE; |
2803 | 3135 | } |
@@ -2813,9 +3145,12 @@ discard block |
||
2813 | 3145 | * @return string |
2814 | 3146 | */ |
2815 | 3147 | function createLocation() { |
2816 | - if( empty( $this->location )) return FALSE; |
|
2817 | - if( empty( $this->location['value'] )) |
|
2818 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE; |
|
3148 | + if( empty( $this->location )) { |
|
3149 | + return FALSE; |
|
3150 | + } |
|
3151 | + if( empty( $this->location['value'] )) { |
|
3152 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE; |
|
3153 | + } |
|
2819 | 3154 | $attributes = $this->_createParams( $this->location['params'], array( 'ALTREP', 'LANGUAGE' )); |
2820 | 3155 | $content = $this->_strrep( $this->location['value'] ); |
2821 | 3156 | return $this->_createElement( 'LOCATION', $attributes, $content ); |
@@ -2830,7 +3165,11 @@ discard block |
||
2830 | 3165 | * @return bool |
2831 | 3166 | */ |
2832 | 3167 | function setLocation( $value, $params=FALSE ) { |
2833 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3168 | + if( empty( $value )) { |
|
3169 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3170 | + } else { |
|
3171 | + return FALSE; |
|
3172 | + } |
|
2834 | 3173 | $this->location = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
2835 | 3174 | return TRUE; |
2836 | 3175 | } |
@@ -2846,9 +3185,12 @@ discard block |
||
2846 | 3185 | * @return string |
2847 | 3186 | */ |
2848 | 3187 | function createOrganizer() { |
2849 | - if( empty( $this->organizer )) return FALSE; |
|
2850 | - if( empty( $this->organizer['value'] )) |
|
2851 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE; |
|
3188 | + if( empty( $this->organizer )) { |
|
3189 | + return FALSE; |
|
3190 | + } |
|
3191 | + if( empty( $this->organizer['value'] )) { |
|
3192 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE; |
|
3193 | + } |
|
2852 | 3194 | $attributes = $this->_createParams( $this->organizer['params'] |
2853 | 3195 | , array( 'CN', 'DIR', 'LANGUAGE', 'SENT-BY' )); |
2854 | 3196 | $content = 'MAILTO:'.$this->organizer['value']; |
@@ -2864,13 +3206,18 @@ discard block |
||
2864 | 3206 | * @return bool |
2865 | 3207 | */ |
2866 | 3208 | function setOrganizer( $value, $params=FALSE ) { |
2867 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3209 | + if( empty( $value )) { |
|
3210 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3211 | + } else { |
|
3212 | + return FALSE; |
|
3213 | + } |
|
2868 | 3214 | $value = str_replace ( 'MAILTO:', '', $value ); |
2869 | 3215 | $value = str_replace ( 'mailto:', '', $value ); |
2870 | 3216 | $this->organizer = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
2871 | 3217 | if( isset( $this->organizer['params']['SENT-BY'] )) { |
2872 | - if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 ))) |
|
2873 | - $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 ); |
|
3218 | + if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 ))) { |
|
3219 | + $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 ); |
|
3220 | + } |
|
2874 | 3221 | } |
2875 | 3222 | return TRUE; |
2876 | 3223 | } |
@@ -2886,9 +3233,12 @@ discard block |
||
2886 | 3233 | * @return string |
2887 | 3234 | */ |
2888 | 3235 | function createPercentComplete() { |
2889 | - if( empty( $this->percentcomplete )) return FALSE; |
|
2890 | - if( empty( $this->percentcomplete['value'] )) |
|
2891 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE; |
|
3236 | + if( empty( $this->percentcomplete )) { |
|
3237 | + return FALSE; |
|
3238 | + } |
|
3239 | + if( empty( $this->percentcomplete['value'] )) { |
|
3240 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE; |
|
3241 | + } |
|
2892 | 3242 | $attributes = $this->_createParams( $this->percentcomplete['params'] ); |
2893 | 3243 | return $this->_createElement( 'PERCENT-COMPLETE', $attributes, $this->percentcomplete['value'] ); |
2894 | 3244 | } |
@@ -2902,7 +3252,11 @@ discard block |
||
2902 | 3252 | * @return bool |
2903 | 3253 | */ |
2904 | 3254 | function setPercentComplete( $value, $params=FALSE ) { |
2905 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3255 | + if( empty( $value )) { |
|
3256 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3257 | + } else { |
|
3258 | + return FALSE; |
|
3259 | + } |
|
2906 | 3260 | $this->percentcomplete = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
2907 | 3261 | return TRUE; |
2908 | 3262 | } |
@@ -2918,9 +3272,12 @@ discard block |
||
2918 | 3272 | * @return string |
2919 | 3273 | */ |
2920 | 3274 | function createPriority() { |
2921 | - if( empty( $this->priority )) return FALSE; |
|
2922 | - if( empty( $this->priority['value'] )) |
|
2923 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE; |
|
3275 | + if( empty( $this->priority )) { |
|
3276 | + return FALSE; |
|
3277 | + } |
|
3278 | + if( empty( $this->priority['value'] )) { |
|
3279 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE; |
|
3280 | + } |
|
2924 | 3281 | $attributes = $this->_createParams( $this->priority['params'] ); |
2925 | 3282 | return $this->_createElement( 'PRIORITY', $attributes, $this->priority['value'] ); |
2926 | 3283 | } |
@@ -2934,7 +3291,11 @@ discard block |
||
2934 | 3291 | * @return bool |
2935 | 3292 | */ |
2936 | 3293 | function setPriority( $value, $params=FALSE ) { |
2937 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3294 | + if( empty( $value )) { |
|
3295 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3296 | + } else { |
|
3297 | + return FALSE; |
|
3298 | + } |
|
2938 | 3299 | $this->priority = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
2939 | 3300 | return TRUE; |
2940 | 3301 | } |
@@ -2950,18 +3311,24 @@ discard block |
||
2950 | 3311 | * @return string |
2951 | 3312 | */ |
2952 | 3313 | function createRdate() { |
2953 | - if( empty( $this->rdate )) return FALSE; |
|
3314 | + if( empty( $this->rdate )) { |
|
3315 | + return FALSE; |
|
3316 | + } |
|
2954 | 3317 | $utctime = ( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE; |
2955 | 3318 | $output = null; |
2956 | - if( $utctime ) |
|
2957 | - unset( $this->rdate['params']['TZID'] ); |
|
3319 | + if( $utctime ) { |
|
3320 | + unset( $this->rdate['params']['TZID'] ); |
|
3321 | + } |
|
2958 | 3322 | foreach( $this->rdate as $theRdate ) { |
2959 | 3323 | if( empty( $theRdate['value'] )) { |
2960 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RDATE' ); |
|
3324 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3325 | + $output .= $this->_createElement( 'RDATE' ); |
|
3326 | + } |
|
2961 | 3327 | continue; |
2962 | 3328 | } |
2963 | - if( $utctime ) |
|
2964 | - unset( $theRdate['params']['TZID'] ); |
|
3329 | + if( $utctime ) { |
|
3330 | + unset( $theRdate['params']['TZID'] ); |
|
3331 | + } |
|
2965 | 3332 | $attributes = $this->_createParams( $theRdate['params'] ); |
2966 | 3333 | $cnt = count( $theRdate['value'] ); |
2967 | 3334 | $content = null; |
@@ -2970,68 +3337,84 @@ discard block |
||
2970 | 3337 | $contentPart = null; |
2971 | 3338 | if( is_array( $rdatePart ) && |
2972 | 3339 | isset( $theRdate['params']['VALUE'] ) && ( 'PERIOD' == $theRdate['params']['VALUE'] )) { // PERIOD |
2973 | - if( $utctime ) |
|
2974 | - unset( $rdatePart[0]['tz'] ); |
|
3340 | + if( $utctime ) { |
|
3341 | + unset( $rdatePart[0]['tz'] ); |
|
3342 | + } |
|
2975 | 3343 | $formatted = $this->_format_date_time( $rdatePart[0]); // PERIOD part 1 |
2976 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
2977 | - $formatted = str_replace( 'Z', '', $formatted); |
|
3344 | + if( $utctime || !empty( $theRdate['params']['TZID'] )) { |
|
3345 | + $formatted = str_replace( 'Z', '', $formatted); |
|
3346 | + } |
|
2978 | 3347 | if( 0 < $rpix ) { |
2979 | 3348 | if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) { |
2980 | - if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z'; |
|
3349 | + if( 'Z' != substr( $formatted, -1 )) { |
|
3350 | + $formatted .= 'Z'; |
|
3351 | + } |
|
3352 | + } else { |
|
3353 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
2981 | 3354 | } |
2982 | - else |
|
2983 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2984 | 3355 | } |
2985 | 3356 | $contentPart .= $formatted; |
2986 | 3357 | $contentPart .= '/'; |
2987 | 3358 | $cnt2 = count( $rdatePart[1]); |
2988 | 3359 | if( array_key_exists( 'year', $rdatePart[1] )) { |
2989 | - if( array_key_exists( 'hour', $rdatePart[1] )) |
|
2990 | - $cnt2 = 7; // date-time |
|
2991 | - else |
|
2992 | - $cnt2 = 3; // date |
|
2993 | - } |
|
2994 | - elseif( array_key_exists( 'week', $rdatePart[1] )) // duration |
|
3360 | + if( array_key_exists( 'hour', $rdatePart[1] )) { |
|
3361 | + $cnt2 = 7; |
|
3362 | + } |
|
3363 | + // date-time |
|
3364 | + else { |
|
3365 | + $cnt2 = 3; |
|
3366 | + } |
|
3367 | + // date |
|
3368 | + } elseif( array_key_exists( 'week', $rdatePart[1] )) { |
|
3369 | + // duration |
|
2995 | 3370 | $cnt2 = 5; |
3371 | + } |
|
2996 | 3372 | if(( 7 == $cnt2 ) && // period= -> date-time |
2997 | 3373 | isset( $rdatePart[1]['year'] ) && |
2998 | 3374 | isset( $rdatePart[1]['month'] ) && |
2999 | 3375 | isset( $rdatePart[1]['day'] )) { |
3000 | - if( $utctime ) |
|
3001 | - unset( $rdatePart[1]['tz'] ); |
|
3376 | + if( $utctime ) { |
|
3377 | + unset( $rdatePart[1]['tz'] ); |
|
3378 | + } |
|
3002 | 3379 | $formatted = $this->_format_date_time( $rdatePart[1] ); // PERIOD part 2 |
3003 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
3004 | - $formatted = str_replace( 'Z', '', $formatted); |
|
3380 | + if( $utctime || !empty( $theRdate['params']['TZID'] )) { |
|
3381 | + $formatted = str_replace( 'Z', '', $formatted); |
|
3382 | + } |
|
3005 | 3383 | if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) { |
3006 | - if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z'; |
|
3384 | + if( 'Z' != substr( $formatted, -1 )) { |
|
3385 | + $formatted .= 'Z'; |
|
3386 | + } |
|
3387 | + } else { |
|
3388 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
3007 | 3389 | } |
3008 | - else |
|
3009 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
3010 | 3390 | $contentPart .= $formatted; |
3011 | - } |
|
3012 | - else { // period= -> dur-time |
|
3391 | + } else { // period= -> dur-time |
|
3013 | 3392 | $contentPart .= $this->_format_duration( $rdatePart[1] ); |
3014 | 3393 | } |
3015 | 3394 | } // PERIOD end |
3016 | 3395 | else { // SINGLE date start |
3017 | - if( $utctime ) |
|
3018 | - unset( $rdatePart['tz'] ); |
|
3396 | + if( $utctime ) { |
|
3397 | + unset( $rdatePart['tz'] ); |
|
3398 | + } |
|
3019 | 3399 | $formatted = $this->_format_date_time( $rdatePart); |
3020 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
3021 | - $formatted = str_replace( 'Z', '', $formatted); |
|
3400 | + if( $utctime || !empty( $theRdate['params']['TZID'] )) { |
|
3401 | + $formatted = str_replace( 'Z', '', $formatted); |
|
3402 | + } |
|
3022 | 3403 | if( !$utctime && ( 0 < $rpix )) { |
3023 | 3404 | if( !empty( $theRdate['value'][0]['tz'] ) && $this->_isOffset( $theRdate['value'][0]['tz'] )) { |
3024 | - if( 'Z' != substr( $formatted, -1 )) |
|
3025 | - $formatted .= 'Z'; |
|
3405 | + if( 'Z' != substr( $formatted, -1 )) { |
|
3406 | + $formatted .= 'Z'; |
|
3407 | + } |
|
3408 | + } else { |
|
3409 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
3026 | 3410 | } |
3027 | - else |
|
3028 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
3029 | 3411 | } |
3030 | 3412 | $contentPart .= $formatted; |
3031 | 3413 | } |
3032 | 3414 | $content .= $contentPart; |
3033 | - if( $rno < $cnt ) |
|
3034 | - $content .= ','; |
|
3415 | + if( $rno < $cnt ) { |
|
3416 | + $content .= ','; |
|
3417 | + } |
|
3035 | 3418 | $rno++; |
3036 | 3419 | } |
3037 | 3420 | $output .= $this->_createElement( 'RDATE', $attributes, $content ); |
@@ -3053,9 +3436,9 @@ discard block |
||
3053 | 3436 | if( $this->getConfig( 'allowEmpty' )) { |
3054 | 3437 | $this->_setMval( $this->rdate, null, $params, FALSE, $index ); |
3055 | 3438 | return TRUE; |
3439 | + } else { |
|
3440 | + return FALSE; |
|
3056 | 3441 | } |
3057 | - else |
|
3058 | - return FALSE; |
|
3059 | 3442 | } |
3060 | 3443 | $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ))); |
3061 | 3444 | if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) { |
@@ -3069,15 +3452,19 @@ discard block |
||
3069 | 3452 | (( is_array( $rdates[0][0] ) && ( isset( $rdates[0][0]['timestamp'] ) || |
3070 | 3453 | $this->_isArrayDate( $rdates[0][0] ))) || |
3071 | 3454 | ( is_string( $rdates[0][0] ) && ( 8 <= strlen( trim( $rdates[0][0] ))))) && |
3072 | - ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] )))))) |
|
3073 | - $input['params']['VALUE'] = 'PERIOD'; |
|
3455 | + ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] )))))) { |
|
3456 | + $input['params']['VALUE'] = 'PERIOD'; |
|
3457 | + } |
|
3074 | 3458 | /* check 1:st date, upd. $parno (opt) and save ev. timezone **/ |
3075 | 3459 | $date = reset( $rdates ); |
3076 | - if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) // PERIOD |
|
3460 | + if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) { |
|
3461 | + // PERIOD |
|
3077 | 3462 | $date = reset( $date ); |
3463 | + } |
|
3078 | 3464 | $this->_chkdatecfg( $date, $parno, $input['params'] ); |
3079 | - if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) |
|
3080 | - unset( $input['params']['TZID'] ); |
|
3465 | + if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) { |
|
3466 | + unset( $input['params']['TZID'] ); |
|
3467 | + } |
|
3081 | 3468 | $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default |
3082 | 3469 | foreach( $rdates as $rpix => $theRdate ) { |
3083 | 3470 | $inputa = null; |
@@ -3085,48 +3472,60 @@ discard block |
||
3085 | 3472 | if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) { // PERIOD |
3086 | 3473 | foreach( $theRdate as $rix => $rPeriod ) { |
3087 | 3474 | if( is_array( $rPeriod )) { |
3088 | - if( $this->_isArrayTimestampDate( $rPeriod )) // timestamp |
|
3475 | + if( $this->_isArrayTimestampDate( $rPeriod )) { |
|
3476 | + // timestamp |
|
3089 | 3477 | $inputab = ( isset( $rPeriod['tz'] )) ? $this->_timestamp2date( $rPeriod, $parno ) : $this->_timestamp2date( $rPeriod, 6 ); |
3090 | - elseif( $this->_isArrayDate( $rPeriod )) |
|
3091 | - $inputab = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 ); |
|
3092 | - elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod )))) // text-date |
|
3478 | + } elseif( $this->_isArrayDate( $rPeriod )) { |
|
3479 | + $inputab = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 ); |
|
3480 | + } elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod )))) { |
|
3481 | + // text-date |
|
3093 | 3482 | $inputab = $this->_date_time_string( reset( $rPeriod ), $parno ); |
3094 | - else // array format duration |
|
3483 | + } else { |
|
3484 | + // array format duration |
|
3095 | 3485 | $inputab = $this->_duration_array( $rPeriod ); |
3096 | - } |
|
3097 | - elseif(( 3 <= strlen( trim( $rPeriod ))) && // string format duration |
|
3486 | + } |
|
3487 | + } elseif(( 3 <= strlen( trim( $rPeriod ))) && // string format duration |
|
3098 | 3488 | ( in_array( $rPeriod{0}, array( 'P', '+', '-' )))) { |
3099 | - if( 'P' != $rPeriod{0} ) |
|
3100 | - $rPeriod = substr( $rPeriod, 1 ); |
|
3489 | + if( 'P' != $rPeriod{0} ) { |
|
3490 | + $rPeriod = substr( $rPeriod, 1 ); |
|
3491 | + } |
|
3101 | 3492 | $inputab = $this->_duration_string( $rPeriod ); |
3102 | - } |
|
3103 | - elseif( 8 <= strlen( trim( $rPeriod ))) // text date ex. 2006-08-03 10:12:18 |
|
3493 | + } elseif( 8 <= strlen( trim( $rPeriod ))) { |
|
3494 | + // text date ex. 2006-08-03 10:12:18 |
|
3104 | 3495 | $inputab = $this->_date_time_string( $rPeriod, $parno ); |
3496 | + } |
|
3105 | 3497 | if( isset( $input['params']['TZID'] ) || |
3106 | 3498 | ( isset( $inputab['tz'] ) && !$this->_isOffset( $inputab['tz'] )) || |
3107 | 3499 | ( isset( $inputa[0] ) && ( !isset( $inputa[0]['tz'] ))) || |
3108 | - ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] ))) |
|
3109 | - unset( $inputab['tz'] ); |
|
3500 | + ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] ))) { |
|
3501 | + unset( $inputab['tz'] ); |
|
3502 | + } |
|
3110 | 3503 | $inputa[] = $inputab; |
3111 | 3504 | } |
3112 | 3505 | } // PERIOD end |
3113 | - elseif ( $this->_isArrayTimestampDate( $theRdate )) // timestamp |
|
3506 | + elseif ( $this->_isArrayTimestampDate( $theRdate )) { |
|
3507 | + // timestamp |
|
3114 | 3508 | $inputa = $this->_timestamp2date( $theRdate, $parno ); |
3115 | - else // date[-time] |
|
3509 | + } else { |
|
3510 | + // date[-time] |
|
3116 | 3511 | $inputa = $this->_date_time_array( $theRdate, $parno ); |
3117 | - } |
|
3118 | - elseif( 8 <= strlen( trim( $theRdate ))) // text date ex. 2006-08-03 10:12:18 |
|
3512 | + } |
|
3513 | + } elseif( 8 <= strlen( trim( $theRdate ))) { |
|
3514 | + // text date ex. 2006-08-03 10:12:18 |
|
3119 | 3515 | $inputa = $this->_date_time_string( $theRdate, $parno ); |
3516 | + } |
|
3120 | 3517 | if( !isset( $input['params']['VALUE'] ) || ( 'PERIOD' != $input['params']['VALUE'] )) { // no PERIOD |
3121 | - if( 3 == $parno ) |
|
3122 | - unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] ); |
|
3123 | - elseif( isset( $inputa['tz'] )) |
|
3124 | - $inputa['tz'] = (string) $inputa['tz']; |
|
3518 | + if( 3 == $parno ) { |
|
3519 | + unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] ); |
|
3520 | + } elseif( isset( $inputa['tz'] )) { |
|
3521 | + $inputa['tz'] = (string) $inputa['tz']; |
|
3522 | + } |
|
3125 | 3523 | if( isset( $input['params']['TZID'] ) || |
3126 | 3524 | ( isset( $inputa['tz'] ) && !$this->_isOffset( $inputa['tz'] )) || |
3127 | 3525 | ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) || |
3128 | - ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) |
|
3129 | - unset( $inputa['tz'] ); |
|
3526 | + ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) { |
|
3527 | + unset( $inputa['tz'] ); |
|
3528 | + } |
|
3130 | 3529 | } |
3131 | 3530 | $input['value'][] = $inputa; |
3132 | 3531 | } |
@@ -3149,9 +3548,12 @@ discard block |
||
3149 | 3548 | * @return string |
3150 | 3549 | */ |
3151 | 3550 | function createRecurrenceid() { |
3152 | - if( empty( $this->recurrenceid )) return FALSE; |
|
3153 | - if( empty( $this->recurrenceid['value'] )) |
|
3154 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE; |
|
3551 | + if( empty( $this->recurrenceid )) { |
|
3552 | + return FALSE; |
|
3553 | + } |
|
3554 | + if( empty( $this->recurrenceid['value'] )) { |
|
3555 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE; |
|
3556 | + } |
|
3155 | 3557 | $formatted = $this->_format_date_time( $this->recurrenceid['value'] ); |
3156 | 3558 | $attributes = $this->_createParams( $this->recurrenceid['params'] ); |
3157 | 3559 | return $this->_createElement( 'RECURRENCE-ID', $attributes, $formatted ); |
@@ -3175,9 +3577,9 @@ discard block |
||
3175 | 3577 | if( $this->getConfig( 'allowEmpty' )) { |
3176 | 3578 | $this->recurrenceid = array( 'value' => null, 'params' => null ); |
3177 | 3579 | return TRUE; |
3580 | + } else { |
|
3581 | + return FALSE; |
|
3178 | 3582 | } |
3179 | - else |
|
3180 | - return FALSE; |
|
3181 | 3583 | } |
3182 | 3584 | $this->recurrenceid = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
3183 | 3585 | return TRUE; |
@@ -3194,11 +3596,15 @@ discard block |
||
3194 | 3596 | * @return string |
3195 | 3597 | */ |
3196 | 3598 | function createRelatedTo() { |
3197 | - if( empty( $this->relatedto )) return FALSE; |
|
3599 | + if( empty( $this->relatedto )) { |
|
3600 | + return FALSE; |
|
3601 | + } |
|
3198 | 3602 | $output = null; |
3199 | 3603 | foreach( $this->relatedto as $relation ) { |
3200 | 3604 | if( empty( $relation['value'] )) { |
3201 | - if( $this->getConfig( 'allowEmpty' )) $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] )); |
|
3605 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3606 | + $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] )); |
|
3607 | + } |
|
3202 | 3608 | continue; |
3203 | 3609 | } |
3204 | 3610 | $attributes = $this->_createParams( $relation['params'] ); |
@@ -3220,9 +3626,14 @@ discard block |
||
3220 | 3626 | * @return bool |
3221 | 3627 | */ |
3222 | 3628 | function setRelatedTo( $value, $params=FALSE, $index=FALSE ) { |
3223 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3224 | - if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 ))) |
|
3225 | - $value = substr( $value, 1, ( strlen( $value ) - 2 )); |
|
3629 | + if( empty( $value )) { |
|
3630 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3631 | + } else { |
|
3632 | + return FALSE; |
|
3633 | + } |
|
3634 | + if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 ))) { |
|
3635 | + $value = substr( $value, 1, ( strlen( $value ) - 2 )); |
|
3636 | + } |
|
3226 | 3637 | $this->_existRem( $params, 'RELTYPE', 'PARENT', TRUE ); // remove default |
3227 | 3638 | $this->_setMval( $this->relatedto, $value, $params, FALSE, $index ); |
3228 | 3639 | return TRUE; |
@@ -3239,9 +3650,12 @@ discard block |
||
3239 | 3650 | * @return string |
3240 | 3651 | */ |
3241 | 3652 | function createRepeat() { |
3242 | - if( empty( $this->repeat )) return FALSE; |
|
3243 | - if( empty( $this->repeat['value'] )) |
|
3244 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE; |
|
3653 | + if( empty( $this->repeat )) { |
|
3654 | + return FALSE; |
|
3655 | + } |
|
3656 | + if( empty( $this->repeat['value'] )) { |
|
3657 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE; |
|
3658 | + } |
|
3245 | 3659 | $attributes = $this->_createParams( $this->repeat['params'] ); |
3246 | 3660 | return $this->_createElement( 'REPEAT', $attributes, $this->repeat['value'] ); |
3247 | 3661 | } |
@@ -3255,7 +3669,11 @@ discard block |
||
3255 | 3669 | * @return void |
3256 | 3670 | */ |
3257 | 3671 | function setRepeat( $value, $params=FALSE ) { |
3258 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3672 | + if( empty( $value )) { |
|
3673 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3674 | + } else { |
|
3675 | + return FALSE; |
|
3676 | + } |
|
3259 | 3677 | $this->repeat = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3260 | 3678 | return TRUE; |
3261 | 3679 | } |
@@ -3270,18 +3688,23 @@ discard block |
||
3270 | 3688 | * @return string |
3271 | 3689 | */ |
3272 | 3690 | function createRequestStatus() { |
3273 | - if( empty( $this->requeststatus )) return FALSE; |
|
3691 | + if( empty( $this->requeststatus )) { |
|
3692 | + return FALSE; |
|
3693 | + } |
|
3274 | 3694 | $output = null; |
3275 | 3695 | foreach( $this->requeststatus as $rstat ) { |
3276 | 3696 | if( empty( $rstat['value']['statcode'] )) { |
3277 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'REQUEST-STATUS' ); |
|
3697 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3698 | + $output .= $this->_createElement( 'REQUEST-STATUS' ); |
|
3699 | + } |
|
3278 | 3700 | continue; |
3279 | 3701 | } |
3280 | 3702 | $attributes = $this->_createParams( $rstat['params'], array( 'LANGUAGE' )); |
3281 | 3703 | $content = number_format( (float) $rstat['value']['statcode'], 2, '.', ''); |
3282 | 3704 | $content .= ';'.$this->_strrep( $rstat['value']['text'] ); |
3283 | - if( isset( $rstat['value']['extdata'] )) |
|
3284 | - $content .= ';'.$this->_strrep( $rstat['value']['extdata'] ); |
|
3705 | + if( isset( $rstat['value']['extdata'] )) { |
|
3706 | + $content .= ';'.$this->_strrep( $rstat['value']['extdata'] ); |
|
3707 | + } |
|
3285 | 3708 | $output .= $this->_createElement( 'REQUEST-STATUS', $attributes, $content ); |
3286 | 3709 | } |
3287 | 3710 | return $output; |
@@ -3299,10 +3722,15 @@ discard block |
||
3299 | 3722 | * @return bool |
3300 | 3723 | */ |
3301 | 3724 | function setRequestStatus( $statcode, $text, $extdata=FALSE, $params=FALSE, $index=FALSE ) { |
3302 | - if( empty( $statcode ) || empty( $text )) if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null; else return FALSE; |
|
3725 | + if( empty( $statcode ) || empty( $text )) { |
|
3726 | + if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null; |
|
3727 | + } else { |
|
3728 | + return FALSE; |
|
3729 | + } |
|
3303 | 3730 | $input = array( 'statcode' => $statcode, 'text' => $text ); |
3304 | - if( $extdata ) |
|
3305 | - $input['extdata'] = $extdata; |
|
3731 | + if( $extdata ) { |
|
3732 | + $input['extdata'] = $extdata; |
|
3733 | + } |
|
3306 | 3734 | $this->_setMval( $this->requeststatus, $input, $params, FALSE, $index ); |
3307 | 3735 | return TRUE; |
3308 | 3736 | } |
@@ -3318,21 +3746,26 @@ discard block |
||
3318 | 3746 | * @return string |
3319 | 3747 | */ |
3320 | 3748 | function createResources() { |
3321 | - if( empty( $this->resources )) return FALSE; |
|
3749 | + if( empty( $this->resources )) { |
|
3750 | + return FALSE; |
|
3751 | + } |
|
3322 | 3752 | $output = null; |
3323 | 3753 | foreach( $this->resources as $resource ) { |
3324 | 3754 | if( empty( $resource['value'] )) { |
3325 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RESOURCES' ); |
|
3755 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3756 | + $output .= $this->_createElement( 'RESOURCES' ); |
|
3757 | + } |
|
3326 | 3758 | continue; |
3327 | 3759 | } |
3328 | 3760 | $attributes = $this->_createParams( $resource['params'], array( 'ALTREP', 'LANGUAGE' )); |
3329 | 3761 | if( is_array( $resource['value'] )) { |
3330 | - foreach( $resource['value'] as $rix => $resourcePart ) |
|
3331 | - $resource['value'][$rix] = $this->_strrep( $resourcePart ); |
|
3762 | + foreach( $resource['value'] as $rix => $resourcePart ) { |
|
3763 | + $resource['value'][$rix] = $this->_strrep( $resourcePart ); |
|
3764 | + } |
|
3332 | 3765 | $content = implode( ',', $resource['value'] ); |
3766 | + } else { |
|
3767 | + $content = $this->_strrep( $resource['value'] ); |
|
3333 | 3768 | } |
3334 | - else |
|
3335 | - $content = $this->_strrep( $resource['value'] ); |
|
3336 | 3769 | $output .= $this->_createElement( 'RESOURCES', $attributes, $content ); |
3337 | 3770 | } |
3338 | 3771 | return $output; |
@@ -3348,7 +3781,11 @@ discard block |
||
3348 | 3781 | * @return bool |
3349 | 3782 | */ |
3350 | 3783 | function setResources( $value, $params=FALSE, $index=FALSE ) { |
3351 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3784 | + if( empty( $value )) { |
|
3785 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3786 | + } else { |
|
3787 | + return FALSE; |
|
3788 | + } |
|
3352 | 3789 | $this->_setMval( $this->resources, $value, $params, FALSE, $index ); |
3353 | 3790 | return TRUE; |
3354 | 3791 | } |
@@ -3364,7 +3801,9 @@ discard block |
||
3364 | 3801 | * @return string |
3365 | 3802 | */ |
3366 | 3803 | function createRrule() { |
3367 | - if( empty( $this->rrule )) return FALSE; |
|
3804 | + if( empty( $this->rrule )) { |
|
3805 | + return FALSE; |
|
3806 | + } |
|
3368 | 3807 | return $this->_format_recur( 'RRULE', $this->rrule ); |
3369 | 3808 | } |
3370 | 3809 | /** |
@@ -3378,7 +3817,11 @@ discard block |
||
3378 | 3817 | * @return void |
3379 | 3818 | */ |
3380 | 3819 | function setRrule( $rruleset, $params=FALSE, $index=FALSE ) { |
3381 | - if( empty( $rruleset )) if( $this->getConfig( 'allowEmpty' )) $rruleset = null; else return FALSE; |
|
3820 | + if( empty( $rruleset )) { |
|
3821 | + if( $this->getConfig( 'allowEmpty' )) $rruleset = null; |
|
3822 | + } else { |
|
3823 | + return FALSE; |
|
3824 | + } |
|
3382 | 3825 | $this->_setMval( $this->rrule, $this->_setRexrule( $rruleset ), $params, FALSE, $index ); |
3383 | 3826 | return TRUE; |
3384 | 3827 | } |
@@ -3393,9 +3836,12 @@ discard block |
||
3393 | 3836 | * @return string |
3394 | 3837 | */ |
3395 | 3838 | function createSequence() { |
3396 | - if( empty( $this->sequence )) return FALSE; |
|
3397 | - if( empty( $this->sequence['value'] )) |
|
3398 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE; |
|
3839 | + if( empty( $this->sequence )) { |
|
3840 | + return FALSE; |
|
3841 | + } |
|
3842 | + if( empty( $this->sequence['value'] )) { |
|
3843 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE; |
|
3844 | + } |
|
3399 | 3845 | $attributes = $this->_createParams( $this->sequence['params'] ); |
3400 | 3846 | return $this->_createElement( 'SEQUENCE', $attributes, $this->sequence['value'] ); |
3401 | 3847 | } |
@@ -3408,8 +3854,9 @@ discard block |
||
3408 | 3854 | * @return bool |
3409 | 3855 | */ |
3410 | 3856 | function setSequence( $value=FALSE, $params=FALSE ) { |
3411 | - if( empty( $value )) |
|
3412 | - $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1; |
|
3857 | + if( empty( $value )) { |
|
3858 | + $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1; |
|
3859 | + } |
|
3413 | 3860 | $this->sequence = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3414 | 3861 | return TRUE; |
3415 | 3862 | } |
@@ -3425,9 +3872,12 @@ discard block |
||
3425 | 3872 | * @return string |
3426 | 3873 | */ |
3427 | 3874 | function createStatus() { |
3428 | - if( empty( $this->status )) return FALSE; |
|
3429 | - if( empty( $this->status['value'] )) |
|
3430 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE; |
|
3875 | + if( empty( $this->status )) { |
|
3876 | + return FALSE; |
|
3877 | + } |
|
3878 | + if( empty( $this->status['value'] )) { |
|
3879 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE; |
|
3880 | + } |
|
3431 | 3881 | $attributes = $this->_createParams( $this->status['params'] ); |
3432 | 3882 | return $this->_createElement( 'STATUS', $attributes, $this->status['value'] ); |
3433 | 3883 | } |
@@ -3441,7 +3891,11 @@ discard block |
||
3441 | 3891 | * @return bool |
3442 | 3892 | */ |
3443 | 3893 | function setStatus( $value, $params=FALSE ) { |
3444 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3894 | + if( empty( $value )) { |
|
3895 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3896 | + } else { |
|
3897 | + return FALSE; |
|
3898 | + } |
|
3445 | 3899 | $this->status = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3446 | 3900 | return TRUE; |
3447 | 3901 | } |
@@ -3457,9 +3911,12 @@ discard block |
||
3457 | 3911 | * @return string |
3458 | 3912 | */ |
3459 | 3913 | function createSummary() { |
3460 | - if( empty( $this->summary )) return FALSE; |
|
3461 | - if( empty( $this->summary['value'] )) |
|
3462 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE; |
|
3914 | + if( empty( $this->summary )) { |
|
3915 | + return FALSE; |
|
3916 | + } |
|
3917 | + if( empty( $this->summary['value'] )) { |
|
3918 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE; |
|
3919 | + } |
|
3463 | 3920 | $attributes = $this->_createParams( $this->summary['params'], array( 'ALTREP', 'LANGUAGE' )); |
3464 | 3921 | $content = $this->_strrep( $this->summary['value'] ); |
3465 | 3922 | return $this->_createElement( 'SUMMARY', $attributes, $content ); |
@@ -3474,9 +3931,13 @@ discard block |
||
3474 | 3931 | * @return bool |
3475 | 3932 | */ |
3476 | 3933 | function setSummary( $value, $params=FALSE ) { |
3477 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3478 | - $this->summary = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3479 | - return TRUE; |
|
3934 | + if( empty( $value )) { |
|
3935 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3936 | + } else { |
|
3937 | + return FALSE; |
|
3938 | + } |
|
3939 | + $this->summary = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3940 | + return TRUE; |
|
3480 | 3941 | } |
3481 | 3942 | /*********************************************************************************/ |
3482 | 3943 | /** |
@@ -3490,9 +3951,12 @@ discard block |
||
3490 | 3951 | * @return string |
3491 | 3952 | */ |
3492 | 3953 | function createTransp() { |
3493 | - if( empty( $this->transp )) return FALSE; |
|
3494 | - if( empty( $this->transp['value'] )) |
|
3495 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE; |
|
3954 | + if( empty( $this->transp )) { |
|
3955 | + return FALSE; |
|
3956 | + } |
|
3957 | + if( empty( $this->transp['value'] )) { |
|
3958 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE; |
|
3959 | + } |
|
3496 | 3960 | $attributes = $this->_createParams( $this->transp['params'] ); |
3497 | 3961 | return $this->_createElement( 'TRANSP', $attributes, $this->transp['value'] ); |
3498 | 3962 | } |
@@ -3506,7 +3970,11 @@ discard block |
||
3506 | 3970 | * @return bool |
3507 | 3971 | */ |
3508 | 3972 | function setTransp( $value, $params=FALSE ) { |
3509 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3973 | + if( empty( $value )) { |
|
3974 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3975 | + } else { |
|
3976 | + return FALSE; |
|
3977 | + } |
|
3510 | 3978 | $this->transp = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3511 | 3979 | return TRUE; |
3512 | 3980 | } |
@@ -3522,19 +3990,24 @@ discard block |
||
3522 | 3990 | * @return string |
3523 | 3991 | */ |
3524 | 3992 | function createTrigger() { |
3525 | - if( empty( $this->trigger )) return FALSE; |
|
3526 | - if( empty( $this->trigger['value'] )) |
|
3527 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE; |
|
3993 | + if( empty( $this->trigger )) { |
|
3994 | + return FALSE; |
|
3995 | + } |
|
3996 | + if( empty( $this->trigger['value'] )) { |
|
3997 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE; |
|
3998 | + } |
|
3528 | 3999 | $content = $attributes = null; |
3529 | 4000 | if( isset( $this->trigger['value']['year'] ) && |
3530 | 4001 | isset( $this->trigger['value']['month'] ) && |
3531 | - isset( $this->trigger['value']['day'] )) |
|
3532 | - $content .= $this->_format_date_time( $this->trigger['value'] ); |
|
3533 | - else { |
|
3534 | - if( TRUE !== $this->trigger['value']['relatedStart'] ) |
|
3535 | - $attributes .= $this->intAttrDelimiter.'RELATED=END'; |
|
3536 | - if( $this->trigger['value']['before'] ) |
|
3537 | - $content .= '-'; |
|
4002 | + isset( $this->trigger['value']['day'] )) { |
|
4003 | + $content .= $this->_format_date_time( $this->trigger['value'] ); |
|
4004 | + } else { |
|
4005 | + if( TRUE !== $this->trigger['value']['relatedStart'] ) { |
|
4006 | + $attributes .= $this->intAttrDelimiter.'RELATED=END'; |
|
4007 | + } |
|
4008 | + if( $this->trigger['value']['before'] ) { |
|
4009 | + $content .= '-'; |
|
4010 | + } |
|
3538 | 4011 | $content .= $this->_format_duration( $this->trigger['value'] ); |
3539 | 4012 | } |
3540 | 4013 | $attributes .= $this->_createParams( $this->trigger['params'] ); |
@@ -3558,28 +4031,30 @@ discard block |
||
3558 | 4031 | * @return bool |
3559 | 4032 | */ |
3560 | 4033 | function setTrigger( $year, $month=null, $day=null, $week=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $relatedStart=TRUE, $before=TRUE, $params=FALSE ) { |
3561 | - if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec )) |
|
3562 | - if( $this->getConfig( 'allowEmpty' )) { |
|
4034 | + if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec )) { |
|
4035 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3563 | 4036 | $this->trigger = array( 'value' => null, 'params' => $this->_setParams( $params ) ); |
4037 | + } |
|
3564 | 4038 | return TRUE; |
4039 | + } else { |
|
4040 | + return FALSE; |
|
3565 | 4041 | } |
3566 | - else |
|
3567 | - return FALSE; |
|
3568 | 4042 | if( $this->_isArrayTimestampDate( $year )) { // timestamp |
3569 | 4043 | $params = $this->_setParams( $month ); |
3570 | 4044 | $date = $this->_timestamp2date( $year, 7 ); |
3571 | - foreach( $date as $k => $v ) |
|
3572 | - $$k = $v; |
|
3573 | - } |
|
3574 | - elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) { |
|
4045 | + foreach( $date as $k => $v ) { |
|
4046 | + $$k = $v; |
|
4047 | + } |
|
4048 | + } elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) { |
|
3575 | 4049 | $params = $this->_setParams( $month ); |
3576 | 4050 | if(!(array_key_exists( 'year', $year ) && // exclude date-time |
3577 | 4051 | array_key_exists( 'month', $year ) && |
3578 | 4052 | array_key_exists( 'day', $year ))) { // so this must be a duration |
3579 | - if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) |
|
3580 | - $relatedStart = FALSE; |
|
3581 | - else |
|
3582 | - $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE; |
|
4053 | + if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) { |
|
4054 | + $relatedStart = FALSE; |
|
4055 | + } else { |
|
4056 | + $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE; |
|
4057 | + } |
|
3583 | 4058 | $before = ( array_key_exists( 'before', $year ) && ( TRUE !== $year['before'] )) ? FALSE : TRUE; |
3584 | 4059 | } |
3585 | 4060 | $SSYY = ( array_key_exists( 'year', $year )) ? $year['year'] : null; |
@@ -3590,24 +4065,27 @@ discard block |
||
3590 | 4065 | $min = ( array_key_exists( 'min', $year )) ? $year['min'] : 0; //null; |
3591 | 4066 | $sec = ( array_key_exists( 'sec', $year )) ? $year['sec'] : 0; //null; |
3592 | 4067 | $year = $SSYY; |
3593 | - } |
|
3594 | - elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) { // duration or date in a string |
|
4068 | + } elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) { // duration or date in a string |
|
3595 | 4069 | $params = $this->_setParams( $month ); |
3596 | 4070 | if( in_array( $year{0}, array( 'P', '+', '-' ))) { // duration |
3597 | 4071 | $relatedStart = ( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) ? FALSE : TRUE; |
3598 | 4072 | $before = ( '-' == $year{0} ) ? TRUE : FALSE; |
3599 | - if( 'P' != $year{0} ) |
|
3600 | - $year = substr( $year, 1 ); |
|
4073 | + if( 'P' != $year{0} ) { |
|
4074 | + $year = substr( $year, 1 ); |
|
4075 | + } |
|
3601 | 4076 | $date = $this->_duration_string( $year); |
3602 | - } |
|
3603 | - else // date |
|
4077 | + } else { |
|
4078 | + // date |
|
3604 | 4079 | $date = $this->_date_time_string( $year, 7 ); |
4080 | + } |
|
3605 | 4081 | unset( $year, $month, $day ); |
3606 | - foreach( $date as $k => $v ) |
|
3607 | - $$k = $v; |
|
3608 | - } |
|
3609 | - else // single values in function input parameters |
|
4082 | + foreach( $date as $k => $v ) { |
|
4083 | + $$k = $v; |
|
4084 | + } |
|
4085 | + } else { |
|
4086 | + // single values in function input parameters |
|
3610 | 4087 | $params = $this->_setParams( $params ); |
4088 | + } |
|
3611 | 4089 | if( !empty( $year ) && !empty( $month ) && !empty( $day )) { // date |
3612 | 4090 | $params['VALUE'] = 'DATE-TIME'; |
3613 | 4091 | $hour = ( $hour ) ? $hour : 0; |
@@ -3622,8 +4100,7 @@ discard block |
||
3622 | 4100 | , 'sec' => $sec |
3623 | 4101 | , 'tz' => 'Z' ); |
3624 | 4102 | return TRUE; |
3625 | - } |
|
3626 | - elseif(( empty( $year ) && empty( $month )) && // duration |
|
4103 | + } elseif(( empty( $year ) && empty( $month )) && // duration |
|
3627 | 4104 | (!empty( $week ) || !empty( $day ) || !empty( $hour ) || !empty( $min ) || !empty( $sec ))) { |
3628 | 4105 | unset( $params['RELATED'] ); // set at output creation (END only) |
3629 | 4106 | unset( $params['VALUE'] ); // 'DURATION' default |
@@ -3632,11 +4109,21 @@ discard block |
||
3632 | 4109 | $before = ( FALSE !== $before ) ? TRUE : FALSE; |
3633 | 4110 | $this->trigger['value'] = array( 'relatedStart' => $relatedStart |
3634 | 4111 | , 'before' => $before ); |
3635 | - if( !empty( $week )) $this->trigger['value']['week'] = $week; |
|
3636 | - if( !empty( $day )) $this->trigger['value']['day'] = $day; |
|
3637 | - if( !empty( $hour )) $this->trigger['value']['hour'] = $hour; |
|
3638 | - if( !empty( $min )) $this->trigger['value']['min'] = $min; |
|
3639 | - if( !empty( $sec )) $this->trigger['value']['sec'] = $sec; |
|
4112 | + if( !empty( $week )) { |
|
4113 | + $this->trigger['value']['week'] = $week; |
|
4114 | + } |
|
4115 | + if( !empty( $day )) { |
|
4116 | + $this->trigger['value']['day'] = $day; |
|
4117 | + } |
|
4118 | + if( !empty( $hour )) { |
|
4119 | + $this->trigger['value']['hour'] = $hour; |
|
4120 | + } |
|
4121 | + if( !empty( $min )) { |
|
4122 | + $this->trigger['value']['min'] = $min; |
|
4123 | + } |
|
4124 | + if( !empty( $sec )) { |
|
4125 | + $this->trigger['value']['sec'] = $sec; |
|
4126 | + } |
|
3640 | 4127 | return TRUE; |
3641 | 4128 | } |
3642 | 4129 | return FALSE; |
@@ -3653,9 +4140,12 @@ discard block |
||
3653 | 4140 | * @return string |
3654 | 4141 | */ |
3655 | 4142 | function createTzid() { |
3656 | - if( empty( $this->tzid )) return FALSE; |
|
3657 | - if( empty( $this->tzid['value'] )) |
|
3658 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE; |
|
4143 | + if( empty( $this->tzid )) { |
|
4144 | + return FALSE; |
|
4145 | + } |
|
4146 | + if( empty( $this->tzid['value'] )) { |
|
4147 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE; |
|
4148 | + } |
|
3659 | 4149 | $attributes = $this->_createParams( $this->tzid['params'] ); |
3660 | 4150 | return $this->_createElement( 'TZID', $attributes, $this->_strrep( $this->tzid['value'] )); |
3661 | 4151 | } |
@@ -3669,7 +4159,11 @@ discard block |
||
3669 | 4159 | * @return bool |
3670 | 4160 | */ |
3671 | 4161 | function setTzid( $value, $params=FALSE ) { |
3672 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4162 | + if( empty( $value )) { |
|
4163 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4164 | + } else { |
|
4165 | + return FALSE; |
|
4166 | + } |
|
3673 | 4167 | $this->tzid = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3674 | 4168 | return TRUE; |
3675 | 4169 | } |
@@ -3686,14 +4180,17 @@ discard block |
||
3686 | 4180 | * @return string |
3687 | 4181 | */ |
3688 | 4182 | function createTzname() { |
3689 | - if( empty( $this->tzname )) return FALSE; |
|
4183 | + if( empty( $this->tzname )) { |
|
4184 | + return FALSE; |
|
4185 | + } |
|
3690 | 4186 | $output = null; |
3691 | 4187 | foreach( $this->tzname as $theName ) { |
3692 | 4188 | if( !empty( $theName['value'] )) { |
3693 | 4189 | $attributes = $this->_createParams( $theName['params'], array( 'LANGUAGE' )); |
3694 | 4190 | $output .= $this->_createElement( 'TZNAME', $attributes, $this->_strrep( $theName['value'] )); |
4191 | + } elseif( $this->getConfig( 'allowEmpty' )) { |
|
4192 | + $output .= $this->_createElement( 'TZNAME' ); |
|
3695 | 4193 | } |
3696 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'TZNAME' ); |
|
3697 | 4194 | } |
3698 | 4195 | return $output; |
3699 | 4196 | } |
@@ -3708,7 +4205,11 @@ discard block |
||
3708 | 4205 | * @return bool |
3709 | 4206 | */ |
3710 | 4207 | function setTzname( $value, $params=FALSE, $index=FALSE ) { |
3711 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4208 | + if( empty( $value )) { |
|
4209 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4210 | + } else { |
|
4211 | + return FALSE; |
|
4212 | + } |
|
3712 | 4213 | $this->_setMval( $this->tzname, $value, $params, FALSE, $index ); |
3713 | 4214 | return TRUE; |
3714 | 4215 | } |
@@ -3724,9 +4225,12 @@ discard block |
||
3724 | 4225 | * @return string |
3725 | 4226 | */ |
3726 | 4227 | function createTzoffsetfrom() { |
3727 | - if( empty( $this->tzoffsetfrom )) return FALSE; |
|
3728 | - if( empty( $this->tzoffsetfrom['value'] )) |
|
3729 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE; |
|
4228 | + if( empty( $this->tzoffsetfrom )) { |
|
4229 | + return FALSE; |
|
4230 | + } |
|
4231 | + if( empty( $this->tzoffsetfrom['value'] )) { |
|
4232 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE; |
|
4233 | + } |
|
3730 | 4234 | $attributes = $this->_createParams( $this->tzoffsetfrom['params'] ); |
3731 | 4235 | return $this->_createElement( 'TZOFFSETFROM', $attributes, $this->tzoffsetfrom['value'] ); |
3732 | 4236 | } |
@@ -3740,7 +4244,11 @@ discard block |
||
3740 | 4244 | * @return bool |
3741 | 4245 | */ |
3742 | 4246 | function setTzoffsetfrom( $value, $params=FALSE ) { |
3743 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4247 | + if( empty( $value )) { |
|
4248 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4249 | + } else { |
|
4250 | + return FALSE; |
|
4251 | + } |
|
3744 | 4252 | $this->tzoffsetfrom = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3745 | 4253 | return TRUE; |
3746 | 4254 | } |
@@ -3756,9 +4264,12 @@ discard block |
||
3756 | 4264 | * @return string |
3757 | 4265 | */ |
3758 | 4266 | function createTzoffsetto() { |
3759 | - if( empty( $this->tzoffsetto )) return FALSE; |
|
3760 | - if( empty( $this->tzoffsetto['value'] )) |
|
3761 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE; |
|
4267 | + if( empty( $this->tzoffsetto )) { |
|
4268 | + return FALSE; |
|
4269 | + } |
|
4270 | + if( empty( $this->tzoffsetto['value'] )) { |
|
4271 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE; |
|
4272 | + } |
|
3762 | 4273 | $attributes = $this->_createParams( $this->tzoffsetto['params'] ); |
3763 | 4274 | return $this->_createElement( 'TZOFFSETTO', $attributes, $this->tzoffsetto['value'] ); |
3764 | 4275 | } |
@@ -3772,7 +4283,11 @@ discard block |
||
3772 | 4283 | * @return bool |
3773 | 4284 | */ |
3774 | 4285 | function setTzoffsetto( $value, $params=FALSE ) { |
3775 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4286 | + if( empty( $value )) { |
|
4287 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4288 | + } else { |
|
4289 | + return FALSE; |
|
4290 | + } |
|
3776 | 4291 | $this->tzoffsetto = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3777 | 4292 | return TRUE; |
3778 | 4293 | } |
@@ -3788,9 +4303,12 @@ discard block |
||
3788 | 4303 | * @return string |
3789 | 4304 | */ |
3790 | 4305 | function createTzurl() { |
3791 | - if( empty( $this->tzurl )) return FALSE; |
|
3792 | - if( empty( $this->tzurl['value'] )) |
|
3793 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE; |
|
4306 | + if( empty( $this->tzurl )) { |
|
4307 | + return FALSE; |
|
4308 | + } |
|
4309 | + if( empty( $this->tzurl['value'] )) { |
|
4310 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE; |
|
4311 | + } |
|
3794 | 4312 | $attributes = $this->_createParams( $this->tzurl['params'] ); |
3795 | 4313 | return $this->_createElement( 'TZURL', $attributes, $this->tzurl['value'] ); |
3796 | 4314 | } |
@@ -3804,7 +4322,11 @@ discard block |
||
3804 | 4322 | * @return boll |
3805 | 4323 | */ |
3806 | 4324 | function setTzurl( $value, $params=FALSE ) { |
3807 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4325 | + if( empty( $value )) { |
|
4326 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4327 | + } else { |
|
4328 | + return FALSE; |
|
4329 | + } |
|
3808 | 4330 | $this->tzurl = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3809 | 4331 | return TRUE; |
3810 | 4332 | } |
@@ -3820,8 +4342,9 @@ discard block |
||
3820 | 4342 | * @return string |
3821 | 4343 | */ |
3822 | 4344 | function createUid() { |
3823 | - if( 0 >= count( $this->uid )) |
|
3824 | - $this->_makeuid(); |
|
4345 | + if( 0 >= count( $this->uid )) { |
|
4346 | + $this->_makeuid(); |
|
4347 | + } |
|
3825 | 4348 | $attributes = $this->_createParams( $this->uid['params'] ); |
3826 | 4349 | return $this->_createElement( 'UID', $attributes, $this->uid['value'] ); |
3827 | 4350 | } |
@@ -3840,8 +4363,9 @@ discard block |
||
3840 | 4363 | $end = strlen( $base ) - 1; |
3841 | 4364 | $length = 6; |
3842 | 4365 | $str = null; |
3843 | - for( $p = 0; $p < $length; $p++ ) |
|
3844 | - $unique .= $base{mt_rand( $start, $end )}; |
|
4366 | + for( $p = 0; $p < $length; $p++ ) { |
|
4367 | + $unique .= $base{mt_rand( $start, $end )}; |
|
4368 | + } |
|
3845 | 4369 | $this->uid = array( 'params' => null ); |
3846 | 4370 | $this->uid['value'] = $date.'-'.$unique.'@'.$this->getConfig( 'unique_id' ); |
3847 | 4371 | } |
@@ -3855,7 +4379,10 @@ discard block |
||
3855 | 4379 | * @return bool |
3856 | 4380 | */ |
3857 | 4381 | function setUid( $value, $params=FALSE ) { |
3858 | - if( empty( $value )) return FALSE; // no allowEmpty check here !!!! |
|
4382 | + if( empty( $value )) { |
|
4383 | + return FALSE; |
|
4384 | + } |
|
4385 | + // no allowEmpty check here !!!! |
|
3859 | 4386 | $this->uid = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3860 | 4387 | return TRUE; |
3861 | 4388 | } |
@@ -3871,9 +4398,12 @@ discard block |
||
3871 | 4398 | * @return string |
3872 | 4399 | */ |
3873 | 4400 | function createUrl() { |
3874 | - if( empty( $this->url )) return FALSE; |
|
3875 | - if( empty( $this->url['value'] )) |
|
3876 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE; |
|
4401 | + if( empty( $this->url )) { |
|
4402 | + return FALSE; |
|
4403 | + } |
|
4404 | + if( empty( $this->url['value'] )) { |
|
4405 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE; |
|
4406 | + } |
|
3877 | 4407 | $attributes = $this->_createParams( $this->url['params'] ); |
3878 | 4408 | return $this->_createElement( 'URL', $attributes, $this->url['value'] ); |
3879 | 4409 | } |
@@ -3887,7 +4417,11 @@ discard block |
||
3887 | 4417 | * @return bool |
3888 | 4418 | */ |
3889 | 4419 | function setUrl( $value, $params=FALSE ) { |
3890 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4420 | + if( empty( $value )) { |
|
4421 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4422 | + } else { |
|
4423 | + return FALSE; |
|
4424 | + } |
|
3891 | 4425 | $this->url = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3892 | 4426 | return TRUE; |
3893 | 4427 | } |
@@ -3903,21 +4437,26 @@ discard block |
||
3903 | 4437 | * @return string |
3904 | 4438 | */ |
3905 | 4439 | function createXprop() { |
3906 | - if( empty( $this->xprop )) return FALSE; |
|
4440 | + if( empty( $this->xprop )) { |
|
4441 | + return FALSE; |
|
4442 | + } |
|
3907 | 4443 | $output = null; |
3908 | 4444 | foreach( $this->xprop as $label => $xpropPart ) { |
3909 | 4445 | if( empty( $xpropPart['value'] )) { |
3910 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $label ); |
|
4446 | + if( $this->getConfig( 'allowEmpty' )) { |
|
4447 | + $output .= $this->_createElement( $label ); |
|
4448 | + } |
|
3911 | 4449 | continue; |
3912 | 4450 | } |
3913 | 4451 | $attributes = $this->_createParams( $xpropPart['params'], array( 'LANGUAGE' )); |
3914 | 4452 | if( is_array( $xpropPart['value'] )) { |
3915 | - foreach( $xpropPart['value'] as $pix => $theXpart ) |
|
3916 | - $xpropPart['value'][$pix] = $this->_strrep( $theXpart ); |
|
4453 | + foreach( $xpropPart['value'] as $pix => $theXpart ) { |
|
4454 | + $xpropPart['value'][$pix] = $this->_strrep( $theXpart ); |
|
4455 | + } |
|
3917 | 4456 | $xpropPart['value'] = implode( ',', $xpropPart['value'] ); |
4457 | + } else { |
|
4458 | + $xpropPart['value'] = $this->_strrep( $xpropPart['value'] ); |
|
3918 | 4459 | } |
3919 | - else |
|
3920 | - $xpropPart['value'] = $this->_strrep( $xpropPart['value'] ); |
|
3921 | 4460 | $output .= $this->_createElement( $label, $attributes, $xpropPart['value'] ); |
3922 | 4461 | } |
3923 | 4462 | return $output; |
@@ -3933,12 +4472,20 @@ discard block |
||
3933 | 4472 | * @return bool |
3934 | 4473 | */ |
3935 | 4474 | function setXprop( $label, $value, $params=FALSE ) { |
3936 | - if( empty( $label )) return; |
|
3937 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4475 | + if( empty( $label )) { |
|
4476 | + return; |
|
4477 | + } |
|
4478 | + if( empty( $value )) { |
|
4479 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4480 | + } else { |
|
4481 | + return FALSE; |
|
4482 | + } |
|
3938 | 4483 | $xprop = array( 'value' => $value ); |
3939 | 4484 | $toolbox = new calendarComponent(); |
3940 | 4485 | $xprop['params'] = $toolbox->_setParams( $params ); |
3941 | - if( !is_array( $this->xprop )) $this->xprop = array(); |
|
4486 | + if( !is_array( $this->xprop )) { |
|
4487 | + $this->xprop = array(); |
|
4488 | + } |
|
3942 | 4489 | $this->xprop[strtoupper( $label )] = $xprop; |
3943 | 4490 | return TRUE; |
3944 | 4491 | } |
@@ -4006,30 +4553,29 @@ discard block |
||
4006 | 4553 | $attributes = null; |
4007 | 4554 | foreach( $attributes2 as $attribute ) { |
4008 | 4555 | $attrKVarr = explode( '=', $attribute ); |
4009 | - if( empty( $attrKVarr[0] )) |
|
4010 | - continue; |
|
4556 | + if( empty( $attrKVarr[0] )) { |
|
4557 | + continue; |
|
4558 | + } |
|
4011 | 4559 | if( !isset( $attrKVarr[1] )) { |
4012 | 4560 | $attrValue = $attrKVarr[0]; |
4013 | 4561 | $attrKey = null; |
4014 | - } |
|
4015 | - elseif( 2 == count( $attrKVarr)) { |
|
4562 | + } elseif( 2 == count( $attrKVarr)) { |
|
4016 | 4563 | $attrKey = strtolower( $attrKVarr[0] ); |
4017 | 4564 | $attrValue = $attrKVarr[1]; |
4018 | - } |
|
4019 | - else { |
|
4565 | + } else { |
|
4020 | 4566 | $attrKey = strtolower( $attrKVarr[0] ); |
4021 | 4567 | unset( $attrKVarr[0] ); |
4022 | 4568 | $attrValue = implode( '=', $attrKVarr ); |
4023 | 4569 | } |
4024 | 4570 | if(( 'attach' == $label ) && ( in_array( $attrKey, array( 'fmttype', 'encoding', 'value' )))) { |
4025 | 4571 | $attachInlineBinary = TRUE; |
4026 | - if( 'fmttype' == $attrKey ) |
|
4027 | - $attachfmttype = $attrKey.'='.$attrValue; |
|
4572 | + if( 'fmttype' == $attrKey ) { |
|
4573 | + $attachfmttype = $attrKey.'='.$attrValue; |
|
4574 | + } |
|
4028 | 4575 | continue; |
4029 | - } |
|
4030 | - elseif(( 'categories' == $label ) && ( 'language' == $attrKey )) |
|
4031 | - $categoriesAttrLang = $attrKey.'='.$attrValue; |
|
4032 | - else { |
|
4576 | + } elseif(( 'categories' == $label ) && ( 'language' == $attrKey )) { |
|
4577 | + $categoriesAttrLang = $attrKey.'='.$attrValue; |
|
4578 | + } else { |
|
4033 | 4579 | $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' '; |
4034 | 4580 | $attributes .= ( !empty( $attrKey )) ? $attrKey.'=' : null; |
4035 | 4581 | if(( '"' == substr( $attrValue, 0, 1 )) && ( '"' == substr( $attrValue, -1 ))) { |
@@ -4039,8 +4585,7 @@ discard block |
||
4039 | 4585 | $attributes .= '"'.htmlspecialchars( $attrValue ).'"'; |
4040 | 4586 | } |
4041 | 4587 | } |
4042 | - } |
|
4043 | - else { |
|
4588 | + } else { |
|
4044 | 4589 | $attributes = str_replace( $this->intAttrDelimiter, $this->attributeDelimiter, $attributes ); |
4045 | 4590 | } |
4046 | 4591 | } |
@@ -4062,8 +4607,7 @@ discard block |
||
4062 | 4607 | $content = $this->_createElement( 'extref', $attributes, null ); |
4063 | 4608 | $attributes = null; |
4064 | 4609 | } |
4065 | - } |
|
4066 | - elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) { |
|
4610 | + } elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) { |
|
4067 | 4611 | $content = $this->nl.$this->_createElement( 'b64bin', $attachfmttype, $content ); // max one attribute |
4068 | 4612 | } |
4069 | 4613 | $output .= $attributes; |
@@ -4107,30 +4651,30 @@ discard block |
||
4107 | 4651 | $CNattrExist = $LANGattrExist = FALSE; |
4108 | 4652 | if( is_array( $params )) { |
4109 | 4653 | foreach( $params as $paramKey => $paramValue ) { |
4110 | - if( is_int( $paramKey )) |
|
4111 | - $attr2 .= $this->intAttrDelimiter.$paramValue; |
|
4112 | - elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) { |
|
4654 | + if( is_int( $paramKey )) { |
|
4655 | + $attr2 .= $this->intAttrDelimiter.$paramValue; |
|
4656 | + } elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) { |
|
4113 | 4657 | $attrLANG .= $this->intAttrDelimiter."LANGUAGE=$paramValue"; |
4114 | 4658 | $LANGattrExist = TRUE; |
4115 | - } |
|
4116 | - elseif(( 'CN' == $paramKey ) && $CNattrKey ) { |
|
4659 | + } elseif(( 'CN' == $paramKey ) && $CNattrKey ) { |
|
4117 | 4660 | $attr1 = $this->intAttrDelimiter.'CN="'.$paramValue.'"'; |
4118 | 4661 | $CNattrExist = TRUE; |
4662 | + } elseif(( 'ALTREP' == $paramKey ) && in_array( $paramKey, $ctrKeys )) { |
|
4663 | + $attr2 .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"'; |
|
4664 | + } elseif(( 'DIR' == $paramKey ) && in_array( $paramKey, $ctrKeys )) { |
|
4665 | + $attr2 .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"'; |
|
4666 | + } elseif(( 'SENT-BY' == $paramKey ) && in_array( $paramKey, $ctrKeys )) { |
|
4667 | + $attr2 .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"'; |
|
4668 | + } else { |
|
4669 | + $attr2 .= $this->intAttrDelimiter."$paramKey=$paramValue"; |
|
4119 | 4670 | } |
4120 | - elseif(( 'ALTREP' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4121 | - $attr2 .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"'; |
|
4122 | - elseif(( 'DIR' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4123 | - $attr2 .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"'; |
|
4124 | - elseif(( 'SENT-BY' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4125 | - $attr2 .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"'; |
|
4126 | - else |
|
4127 | - $attr2 .= $this->intAttrDelimiter."$paramKey=$paramValue"; |
|
4128 | 4671 | } |
4129 | 4672 | } |
4130 | 4673 | if( !$LANGattrExist ) { |
4131 | 4674 | $lang = $this->getConfig( 'language' ); |
4132 | - if(( $CNattrExist || $LANGattrKey ) && $lang ) |
|
4133 | - $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang; |
|
4675 | + if(( $CNattrExist || $LANGattrKey ) && $lang ) { |
|
4676 | + $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang; |
|
4677 | + } |
|
4134 | 4678 | } |
4135 | 4679 | return $attrLANG.$attr1.$attr2; |
4136 | 4680 | } |
@@ -4144,47 +4688,57 @@ discard block |
||
4144 | 4688 | * @return array $params, property parameters |
4145 | 4689 | */ |
4146 | 4690 | function _chkdatecfg( $theDate, & $parno, & $params ) { |
4147 | - if( isset( $params['TZID'] )) |
|
4148 | - $parno = 6; |
|
4149 | - elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )) |
|
4150 | - $parno = 3; |
|
4151 | - else { |
|
4152 | - if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] )) |
|
4153 | - $parno = 7; |
|
4691 | + if( isset( $params['TZID'] )) { |
|
4692 | + $parno = 6; |
|
4693 | + } elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )) { |
|
4694 | + $parno = 3; |
|
4695 | + } else { |
|
4696 | + if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] )) { |
|
4697 | + $parno = 7; |
|
4698 | + } |
|
4154 | 4699 | if( is_array( $theDate )) { |
4155 | - if( isset( $theDate['timestamp'] )) |
|
4156 | - $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null; |
|
4157 | - else |
|
4158 | - $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null; |
|
4700 | + if( isset( $theDate['timestamp'] )) { |
|
4701 | + $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null; |
|
4702 | + } else { |
|
4703 | + $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null; |
|
4704 | + } |
|
4159 | 4705 | if( !empty( $tzid )) { |
4160 | 4706 | $parno = 7; |
4161 | - if( !$this->_isOffset( $tzid )) |
|
4162 | - $params['TZID'] = $tzid; // save only timezone |
|
4707 | + if( !$this->_isOffset( $tzid )) { |
|
4708 | + $params['TZID'] = $tzid; |
|
4709 | + } |
|
4710 | + // save only timezone |
|
4711 | + } elseif( !$parno && ( 3 == count( $theDate )) && |
|
4712 | + ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))) { |
|
4713 | + $parno = 3; |
|
4714 | + } else { |
|
4715 | + $parno = 6; |
|
4163 | 4716 | } |
4164 | - elseif( !$parno && ( 3 == count( $theDate )) && |
|
4165 | - ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))) |
|
4166 | - $parno = 3; |
|
4167 | - else |
|
4168 | - $parno = 6; |
|
4169 | - } |
|
4170 | - else { // string |
|
4717 | + } else { // string |
|
4171 | 4718 | $date = trim( $theDate ); |
4172 | - if( 'Z' == substr( $date, -1 )) |
|
4173 | - $parno = 7; // UTC DATE-TIME |
|
4719 | + if( 'Z' == substr( $date, -1 )) { |
|
4720 | + $parno = 7; |
|
4721 | + } |
|
4722 | + // UTC DATE-TIME |
|
4174 | 4723 | elseif((( 8 == strlen( $date ) && ctype_digit( $date )) || ( 11 >= strlen( $date ))) && |
4175 | - ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' )))) |
|
4176 | - $parno = 3; // DATE |
|
4724 | + ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' )))) { |
|
4725 | + $parno = 3; |
|
4726 | + } |
|
4727 | + // DATE |
|
4177 | 4728 | $date = $this->_date_time_string( $date, $parno ); |
4178 | 4729 | if( !empty( $date['tz'] )) { |
4179 | 4730 | $parno = 7; |
4180 | - if( !$this->_isOffset( $date['tz'] )) |
|
4181 | - $params['TZID'] = $date['tz']; // save only timezone |
|
4731 | + if( !$this->_isOffset( $date['tz'] )) { |
|
4732 | + $params['TZID'] = $date['tz']; |
|
4733 | + } |
|
4734 | + // save only timezone |
|
4735 | + } elseif( empty( $parno )) { |
|
4736 | + $parno = 6; |
|
4182 | 4737 | } |
4183 | - elseif( empty( $parno )) |
|
4184 | - $parno = 6; |
|
4185 | 4738 | } |
4186 | - if( isset( $params['TZID'] )) |
|
4187 | - $parno = 6; |
|
4739 | + if( isset( $params['TZID'] )) { |
|
4740 | + $parno = 6; |
|
4741 | + } |
|
4188 | 4742 | } |
4189 | 4743 | } |
4190 | 4744 | /** |
@@ -4200,14 +4754,18 @@ discard block |
||
4200 | 4754 | */ |
4201 | 4755 | function _date2duration( $startdate=FALSE, $enddate=FALSE ) { |
4202 | 4756 | if( !$startdate || !$enddate ) { |
4203 | - if( FALSE === ( $startdate = $this->getProperty( 'dtstart' ))) |
|
4204 | - return null; |
|
4205 | - if( FALSE === ( $enddate = $this->getProperty( 'dtend' ))) // vevent/vfreebusy |
|
4757 | + if( FALSE === ( $startdate = $this->getProperty( 'dtstart' ))) { |
|
4758 | + return null; |
|
4759 | + } |
|
4760 | + if( FALSE === ( $enddate = $this->getProperty( 'dtend' ))) { |
|
4761 | + // vevent/vfreebusy |
|
4206 | 4762 | if( FALSE === ( $enddate = $this->getProperty( 'due' ))) // vtodo |
4207 | 4763 | return null; |
4764 | + } |
|
4765 | + } |
|
4766 | + if( !$startdate || !$enddate ) { |
|
4767 | + return null; |
|
4208 | 4768 | } |
4209 | - if( !$startdate || !$enddate ) |
|
4210 | - return null; |
|
4211 | 4769 | $startWdate = mktime( 0, 0, 0, $startdate['month'], $startdate['day'], $startdate['year'] ); |
4212 | 4770 | $endWdate = mktime( 0, 0, 0, $enddate['month'], $enddate['day'], $enddate['year'] ); |
4213 | 4771 | $wduration = $endWdate - $startWdate; |
@@ -4233,15 +4791,23 @@ discard block |
||
4233 | 4791 | */ |
4234 | 4792 | function _date2timestamp( $datetime, $tz=null ) { |
4235 | 4793 | $output = null; |
4236 | - if( !isset( $datetime['hour'] )) $datetime['hour'] = '0'; |
|
4237 | - if( !isset( $datetime['min'] )) $datetime['min'] = '0'; |
|
4238 | - if( !isset( $datetime['sec'] )) $datetime['sec'] = '0'; |
|
4794 | + if( !isset( $datetime['hour'] )) { |
|
4795 | + $datetime['hour'] = '0'; |
|
4796 | + } |
|
4797 | + if( !isset( $datetime['min'] )) { |
|
4798 | + $datetime['min'] = '0'; |
|
4799 | + } |
|
4800 | + if( !isset( $datetime['sec'] )) { |
|
4801 | + $datetime['sec'] = '0'; |
|
4802 | + } |
|
4239 | 4803 | foreach( $datetime as $dkey => $dvalue ) { |
4240 | - if( 'tz' != $dkey ) |
|
4241 | - $datetime[$dkey] = (integer) $dvalue; |
|
4804 | + if( 'tz' != $dkey ) { |
|
4805 | + $datetime[$dkey] = (integer) $dvalue; |
|
4806 | + } |
|
4807 | + } |
|
4808 | + if( $tz ) { |
|
4809 | + $datetime['tz'] = $tz; |
|
4242 | 4810 | } |
4243 | - if( $tz ) |
|
4244 | - $datetime['tz'] = $tz; |
|
4245 | 4811 | $offset = ( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) ? $this->_tz2offset( $datetime['tz'] ) : 0; |
4246 | 4812 | $output = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year'] ); |
4247 | 4813 | return $output; |
@@ -4298,12 +4864,15 @@ discard block |
||
4298 | 4864 | } |
4299 | 4865 | } |
4300 | 4866 | if( 3 != $parno ) { |
4301 | - if( !isset( $output['hour'] )) |
|
4302 | - $output['hour'] = 0; |
|
4303 | - if( !isset( $output['min'] )) |
|
4304 | - $output['min'] = 0; |
|
4305 | - if( !isset( $output['sec'] )) |
|
4306 | - $output['sec'] = 0; |
|
4867 | + if( !isset( $output['hour'] )) { |
|
4868 | + $output['hour'] = 0; |
|
4869 | + } |
|
4870 | + if( !isset( $output['min'] )) { |
|
4871 | + $output['min'] = 0; |
|
4872 | + } |
|
4873 | + if( !isset( $output['sec'] )) { |
|
4874 | + $output['sec'] = 0; |
|
4875 | + } |
|
4307 | 4876 | } |
4308 | 4877 | return $output; |
4309 | 4878 | } |
@@ -4323,39 +4892,37 @@ discard block |
||
4323 | 4892 | if( 'Z' == substr( $datetime, -1 )) { |
4324 | 4893 | $tz = 'Z'; |
4325 | 4894 | $datetime = trim( substr( $datetime, 0, $len )); |
4326 | - } |
|
4327 | - elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date |
|
4895 | + } elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date |
|
4328 | 4896 | ( '-' == substr( $datetime, -3, 1 )) || |
4329 | 4897 | ( ':' == substr( $datetime, -3, 1 )) || |
4330 | 4898 | ( '.' == substr( $datetime, -3, 1 ))) { |
4331 | 4899 | $continue = TRUE; |
4332 | - } |
|
4333 | - elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset |
|
4900 | + } elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset |
|
4334 | 4901 | ( ' +' == substr( $datetime, -6, 2 )) || |
4335 | 4902 | ( ' -' == substr( $datetime, -6, 2 ))) { |
4336 | 4903 | $tz = substr( $datetime, -5, 5 ); |
4337 | 4904 | $datetime = substr( $datetime, 0, ($len - 5)); |
4338 | - } |
|
4339 | - elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset |
|
4905 | + } elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset |
|
4340 | 4906 | ( ' +' == substr( $datetime, -8, 2 )) || |
4341 | 4907 | ( ' -' == substr( $datetime, -8, 2 ))) { |
4342 | 4908 | $tz = substr( $datetime, -7, 7 ); |
4343 | 4909 | $datetime = substr( $datetime, 0, ($len - 7)); |
4344 | - } |
|
4345 | - elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) { |
|
4910 | + } elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) { |
|
4346 | 4911 | $continue = TRUE; |
4347 | - } |
|
4348 | - elseif( 'T' == substr( $datetime, -7, 1 )) { |
|
4912 | + } elseif( 'T' == substr( $datetime, -7, 1 )) { |
|
4349 | 4913 | $continue = TRUE; |
4350 | - } |
|
4351 | - else { |
|
4914 | + } else { |
|
4352 | 4915 | $cx = $tx = 0; // 19970415T133000 US-Eastern |
4353 | 4916 | for( $cx = -1; $cx > ( 9 - $len ); $cx-- ) { |
4354 | - if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 ))) |
|
4355 | - break; // if exists, tz ends here.. . ? |
|
4917 | + if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 ))) { |
|
4918 | + break; |
|
4919 | + } |
|
4920 | + // if exists, tz ends here.. . ? |
|
4356 | 4921 | elseif( ctype_alpha( substr( $datetime, $cx, 1 )) || |
4357 | - ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' )))) |
|
4358 | - $tx--; // tz length counter |
|
4922 | + ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' )))) { |
|
4923 | + $tx--; |
|
4924 | + } |
|
4925 | + // tz length counter |
|
4359 | 4926 | } |
4360 | 4927 | if( 0 > $tx ) { |
4361 | 4928 | $tz = substr( $datetime, $tx ); |
@@ -4364,8 +4931,7 @@ discard block |
||
4364 | 4931 | } |
4365 | 4932 | if( 0 < substr_count( $datetime, '-' )) { |
4366 | 4933 | $datetime = str_replace( '-', '/', $datetime ); |
4367 | - } |
|
4368 | - elseif( ctype_digit( substr( $datetime, 0, 8 )) && |
|
4934 | + } elseif( ctype_digit( substr( $datetime, 0, 8 )) && |
|
4369 | 4935 | ( 'T' == substr( $datetime, 8, 1 )) && |
4370 | 4936 | ctype_digit( substr( $datetime, 9, 6 ))) { |
4371 | 4937 | $datetime = substr( $datetime, 4, 2 ) |
@@ -4385,10 +4951,10 @@ discard block |
||
4385 | 4951 | $output['hour'] = substr( $datestring, 11, 2 ); |
4386 | 4952 | $output['min'] = substr( $datestring, 14, 2 ); |
4387 | 4953 | $output['sec'] = substr( $datestring, 17, 2 ); |
4388 | - if( !empty( $tz )) |
|
4389 | - $output['tz'] = $tz; |
|
4390 | - } |
|
4391 | - elseif( 3 != $parno ) { |
|
4954 | + if( !empty( $tz )) { |
|
4955 | + $output['tz'] = $tz; |
|
4956 | + } |
|
4957 | + } elseif( 3 != $parno ) { |
|
4392 | 4958 | if(( '00' < substr( $datestring, 11, 2 )) || |
4393 | 4959 | ( '00' < substr( $datestring, 14, 2 )) || |
4394 | 4960 | ( '00' < substr( $datestring, 17, 2 ))) { |
@@ -4396,8 +4962,9 @@ discard block |
||
4396 | 4962 | $output['min'] = substr( $datestring, 14, 2 ); |
4397 | 4963 | $output['sec'] = substr( $datestring, 17, 2 ); |
4398 | 4964 | } |
4399 | - if( !empty( $tz )) |
|
4400 | - $output['tz'] = $tz; |
|
4965 | + if( !empty( $tz )) { |
|
4966 | + $output['tz'] = $tz; |
|
4967 | + } |
|
4401 | 4968 | } |
4402 | 4969 | return $output; |
4403 | 4970 | } |
@@ -4424,10 +4991,11 @@ discard block |
||
4424 | 4991 | $durseconds = $durseconds % ( 60 * 60 ); |
4425 | 4992 | $output['min'] = floor( $durseconds / ( 60 )); |
4426 | 4993 | $output['sec'] = ( $durseconds % ( 60 )); |
4427 | - } |
|
4428 | - else { |
|
4994 | + } else { |
|
4429 | 4995 | foreach( $duration as $durKey => $durValue ) { |
4430 | - if( empty( $durValue )) continue; |
|
4996 | + if( empty( $durValue )) { |
|
4997 | + continue; |
|
4998 | + } |
|
4431 | 4999 | switch ( $durKey ) { |
4432 | 5000 | case '0': |
4433 | 5001 | case 'week': |
@@ -4457,14 +5025,22 @@ discard block |
||
4457 | 5025 | return $output; |
4458 | 5026 | } |
4459 | 5027 | unset( $output['week'] ); |
4460 | - if( empty( $output['day'] )) |
|
4461 | - unset( $output['day'] ); |
|
5028 | + if( empty( $output['day'] )) { |
|
5029 | + unset( $output['day'] ); |
|
5030 | + } |
|
4462 | 5031 | if ( isset( $output['hour'] ) || isset( $output['min'] ) || isset( $output['sec'] )) { |
4463 | - if( !isset( $output['hour'] )) $output['hour'] = 0; |
|
4464 | - if( !isset( $output['min'] )) $output['min'] = 0; |
|
4465 | - if( !isset( $output['sec'] )) $output['sec'] = 0; |
|
4466 | - if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] )) |
|
4467 | - unset( $output['hour'], $output['min'], $output['sec'] ); |
|
5032 | + if( !isset( $output['hour'] )) { |
|
5033 | + $output['hour'] = 0; |
|
5034 | + } |
|
5035 | + if( !isset( $output['min'] )) { |
|
5036 | + $output['min'] = 0; |
|
5037 | + } |
|
5038 | + if( !isset( $output['sec'] )) { |
|
5039 | + $output['sec'] = 0; |
|
5040 | + } |
|
5041 | + if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] )) { |
|
5042 | + unset( $output['hour'], $output['min'], $output['sec'] ); |
|
5043 | + } |
|
4468 | 5044 | } |
4469 | 5045 | return $output; |
4470 | 5046 | } |
@@ -4481,28 +5057,32 @@ discard block |
||
4481 | 5057 | if( $startdate && $duration ) { |
4482 | 5058 | $d1 = $startdate; |
4483 | 5059 | $dur = $duration; |
4484 | - } |
|
4485 | - elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) { |
|
5060 | + } elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) { |
|
4486 | 5061 | $d1 = $this->dtstart['value']; |
4487 | 5062 | $dur = $this->duration['value']; |
5063 | + } else { |
|
5064 | + return null; |
|
4488 | 5065 | } |
4489 | - else |
|
4490 | - return null; |
|
4491 | 5066 | $dateOnly = ( isset( $d1['hour'] ) || isset( $d1['min'] ) || isset( $d1['sec'] )) ? FALSE : TRUE; |
4492 | 5067 | $d1['hour'] = ( isset( $d1['hour'] )) ? $d1['hour'] : 0; |
4493 | 5068 | $d1['min'] = ( isset( $d1['min'] )) ? $d1['min'] : 0; |
4494 | 5069 | $d1['sec'] = ( isset( $d1['sec'] )) ? $d1['sec'] : 0; |
4495 | 5070 | $dtend = mktime( $d1['hour'], $d1['min'], $d1['sec'], $d1['month'], $d1['day'], $d1['year'] ); |
4496 | - if( isset( $dur['week'] )) |
|
4497 | - $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 ); |
|
4498 | - if( isset( $dur['day'] )) |
|
4499 | - $dtend += ( $dur['day'] * 24 * 60 * 60 ); |
|
4500 | - if( isset( $dur['hour'] )) |
|
4501 | - $dtend += ( $dur['hour'] * 60 *60 ); |
|
4502 | - if( isset( $dur['min'] )) |
|
4503 | - $dtend += ( $dur['min'] * 60 ); |
|
4504 | - if( isset( $dur['sec'] )) |
|
4505 | - $dtend += $dur['sec']; |
|
5071 | + if( isset( $dur['week'] )) { |
|
5072 | + $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 ); |
|
5073 | + } |
|
5074 | + if( isset( $dur['day'] )) { |
|
5075 | + $dtend += ( $dur['day'] * 24 * 60 * 60 ); |
|
5076 | + } |
|
5077 | + if( isset( $dur['hour'] )) { |
|
5078 | + $dtend += ( $dur['hour'] * 60 *60 ); |
|
5079 | + } |
|
5080 | + if( isset( $dur['min'] )) { |
|
5081 | + $dtend += ( $dur['min'] * 60 ); |
|
5082 | + } |
|
5083 | + if( isset( $dur['sec'] )) { |
|
5084 | + $dtend += $dur['sec']; |
|
5085 | + } |
|
4506 | 5086 | $dtend2 = array(); |
4507 | 5087 | $dtend2['year'] = date('Y', $dtend ); |
4508 | 5088 | $dtend2['month'] = date('m', $dtend ); |
@@ -4510,10 +5090,12 @@ discard block |
||
4510 | 5090 | $dtend2['hour'] = date('H', $dtend ); |
4511 | 5091 | $dtend2['min'] = date('i', $dtend ); |
4512 | 5092 | $dtend2['sec'] = date('s', $dtend ); |
4513 | - if( isset( $d1['tz'] )) |
|
4514 | - $dtend2['tz'] = $d1['tz']; |
|
4515 | - if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] ))) |
|
4516 | - unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] ); |
|
5093 | + if( isset( $d1['tz'] )) { |
|
5094 | + $dtend2['tz'] = $d1['tz']; |
|
5095 | + } |
|
5096 | + if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] ))) { |
|
5097 | + unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] ); |
|
5098 | + } |
|
4517 | 5099 | return $dtend2; |
4518 | 5100 | } |
4519 | 5101 | /** |
@@ -4527,10 +5109,12 @@ discard block |
||
4527 | 5109 | function _duration_string( $duration ) { |
4528 | 5110 | $duration = (string) trim( $duration ); |
4529 | 5111 | while( 'P' != strtoupper( substr( $duration, 0, 1 ))) { |
4530 | - if( 0 < strlen( $duration )) |
|
4531 | - $duration = substr( $duration, 1 ); |
|
4532 | - else |
|
4533 | - return false; // no leading P !?!? |
|
5112 | + if( 0 < strlen( $duration )) { |
|
5113 | + $duration = substr( $duration, 1 ); |
|
5114 | + } else { |
|
5115 | + return false; |
|
5116 | + } |
|
5117 | + // no leading P !?!? |
|
4534 | 5118 | } |
4535 | 5119 | $duration = substr( $duration, 1 ); // skip P |
4536 | 5120 | $duration = str_replace ( 't', 'T', $duration ); |
@@ -4560,10 +5144,13 @@ discard block |
||
4560 | 5144 | $val = null; |
4561 | 5145 | break; |
4562 | 5146 | default: |
4563 | - if( !ctype_digit( $duration{$ix} )) |
|
4564 | - return false; // unknown duration controll character !?!? |
|
4565 | - else |
|
4566 | - $val .= $duration{$ix}; |
|
5147 | + if( !ctype_digit( $duration{$ix} )) { |
|
5148 | + return false; |
|
5149 | + } |
|
5150 | + // unknown duration controll character !?!? |
|
5151 | + else { |
|
5152 | + $val .= $duration{$ix}; |
|
5153 | + } |
|
4567 | 5154 | } |
4568 | 5155 | } |
4569 | 5156 | return $this->_duration_array( $output ); |
@@ -4582,10 +5169,12 @@ discard block |
||
4582 | 5169 | * @return int |
4583 | 5170 | */ |
4584 | 5171 | function _existRem( &$array, $expkey, $expval=FALSE, $hitVal=null, $elseVal=null, $preSet=null ) { |
4585 | - if( $preSet ) |
|
4586 | - return $preSet; |
|
4587 | - if( !is_array( $array ) || ( 0 == count( $array ))) |
|
4588 | - return $elseVal; |
|
5172 | + if( $preSet ) { |
|
5173 | + return $preSet; |
|
5174 | + } |
|
5175 | + if( !is_array( $array ) || ( 0 == count( $array ))) { |
|
5176 | + return $elseVal; |
|
5177 | + } |
|
4589 | 5178 | foreach( $array as $key => $value ) { |
4590 | 5179 | if( strtoupper( $expkey ) == strtoupper( $key )) { |
4591 | 5180 | if( !$expval || ( strtoupper( $expval ) == strtoupper( $array[$key] ))) { |
@@ -4611,13 +5200,15 @@ discard block |
||
4611 | 5200 | !isset( $datetime['day'] ) && |
4612 | 5201 | !isset( $datetime['hour'] ) && |
4613 | 5202 | !isset( $datetime['min'] ) && |
4614 | - !isset( $datetime['sec'] )) |
|
4615 | - return ; |
|
5203 | + !isset( $datetime['sec'] )) { |
|
5204 | + return ; |
|
5205 | + } |
|
4616 | 5206 | $output = null; |
4617 | 5207 | // 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"; } |
4618 | 5208 | foreach( $datetime as $dkey => $dvalue ) { |
4619 | - if( 'tz' != $dkey ) |
|
4620 | - $datetime[$dkey] = (integer) $dvalue; |
|
5209 | + if( 'tz' != $dkey ) { |
|
5210 | + $datetime[$dkey] = (integer) $dvalue; |
|
5211 | + } |
|
4621 | 5212 | } |
4622 | 5213 | $output = date('Ymd', mktime( 0, 0, 0, $datetime['month'], $datetime['day'], $datetime['year'])); |
4623 | 5214 | if( isset( $datetime['hour'] ) || |
@@ -4625,29 +5216,33 @@ discard block |
||
4625 | 5216 | isset( $datetime['sec'] ) || |
4626 | 5217 | isset( $datetime['tz'] )) { |
4627 | 5218 | if( isset( $datetime['tz'] ) && |
4628 | - !isset( $datetime['hour'] )) |
|
4629 | - $datetime['hour'] = 0; |
|
5219 | + !isset( $datetime['hour'] )) { |
|
5220 | + $datetime['hour'] = 0; |
|
5221 | + } |
|
4630 | 5222 | if( isset( $datetime['hour'] ) && |
4631 | - !isset( $datetime['min'] )) |
|
4632 | - $datetime['min'] = 0; |
|
5223 | + !isset( $datetime['min'] )) { |
|
5224 | + $datetime['min'] = 0; |
|
5225 | + } |
|
4633 | 5226 | if( isset( $datetime['hour'] ) && |
4634 | 5227 | isset( $datetime['min'] ) && |
4635 | - !isset( $datetime['sec'] )) |
|
4636 | - $datetime['sec'] = 0; |
|
5228 | + !isset( $datetime['sec'] )) { |
|
5229 | + $datetime['sec'] = 0; |
|
5230 | + } |
|
4637 | 5231 | $date = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']); |
4638 | 5232 | $output .= date('\THis', $date ); |
4639 | 5233 | if( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) { |
4640 | 5234 | $datetime['tz'] = trim( $datetime['tz'] ); |
4641 | - if( 'Z' == $datetime['tz'] ) |
|
4642 | - $output .= 'Z'; |
|
5235 | + if( 'Z' == $datetime['tz'] ) { |
|
5236 | + $output .= 'Z'; |
|
5237 | + } |
|
4643 | 5238 | $offset = $this->_tz2offset( $datetime['tz'] ); |
4644 | 5239 | if( 0 != $offset ) { |
4645 | 5240 | $date = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']); |
4646 | 5241 | $output = date( 'Ymd\THis\Z', $date ); |
4647 | 5242 | } |
5243 | + } elseif( 7 == $parno ) { |
|
5244 | + $output .= 'Z'; |
|
4648 | 5245 | } |
4649 | - elseif( 7 == $parno ) |
|
4650 | - $output .= 'Z'; |
|
4651 | 5246 | } |
4652 | 5247 | return $output; |
4653 | 5248 | } |
@@ -4664,14 +5259,16 @@ discard block |
||
4664 | 5259 | !isset( $duration['day'] ) && |
4665 | 5260 | !isset( $duration['hour'] ) && |
4666 | 5261 | !isset( $duration['min'] ) && |
4667 | - !isset( $duration['sec'] )) |
|
4668 | - return; |
|
5262 | + !isset( $duration['sec'] )) { |
|
5263 | + return; |
|
5264 | + } |
|
4669 | 5265 | $output = 'P'; |
4670 | - if( isset( $duration['week'] ) && ( 0 < $duration['week'] )) |
|
4671 | - $output .= $duration['week'].'W'; |
|
4672 | - else { |
|
4673 | - if( isset($duration['day'] ) && ( 0 < $duration['day'] )) |
|
4674 | - $output .= $duration['day'].'D'; |
|
5266 | + if( isset( $duration['week'] ) && ( 0 < $duration['week'] )) { |
|
5267 | + $output .= $duration['week'].'W'; |
|
5268 | + } else { |
|
5269 | + if( isset($duration['day'] ) && ( 0 < $duration['day'] )) { |
|
5270 | + $output .= $duration['day'].'D'; |
|
5271 | + } |
|
4675 | 5272 | if(( isset( $duration['hour']) && ( 0 < $duration['hour'] )) || |
4676 | 5273 | ( isset( $duration['min']) && ( 0 < $duration['min'] )) || |
4677 | 5274 | ( isset( $duration['sec']) && ( 0 < $duration['sec'] ))) { |
@@ -4696,7 +5293,9 @@ discard block |
||
4696 | 5293 | $output = null; |
4697 | 5294 | foreach( $recurdata as $therule ) { |
4698 | 5295 | if( empty( $therule['value'] )) { |
4699 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $recurlabel ); |
|
5296 | + if( $this->getConfig( 'allowEmpty' )) { |
|
5297 | + $output .= $this->_createElement( $recurlabel ); |
|
5298 | + } |
|
4700 | 5299 | continue; |
4701 | 5300 | } |
4702 | 5301 | $attributes = ( isset( $therule['params'] )) ? $this->_createParams( $therule['params'] ) : null; |
@@ -4741,19 +5340,19 @@ discard block |
||
4741 | 5340 | if( is_array( $valuePart )) { |
4742 | 5341 | $content2 .= ( $bydaycnt ) ? ',' : null; |
4743 | 5342 | foreach( $valuePart as $vix2 => $valuePart2 ) { |
4744 | - if( 'DAY' != strtoupper( $vix2 )) |
|
4745 | - $content21 .= $valuePart2; |
|
4746 | - else |
|
4747 | - $content22 .= $valuePart2; |
|
5343 | + if( 'DAY' != strtoupper( $vix2 )) { |
|
5344 | + $content21 .= $valuePart2; |
|
5345 | + } else { |
|
5346 | + $content22 .= $valuePart2; |
|
5347 | + } |
|
4748 | 5348 | } |
4749 | 5349 | $content2 .= $content21.$content22; |
4750 | 5350 | $bydaycnt++; |
4751 | - } |
|
4752 | - else { |
|
5351 | + } else { |
|
4753 | 5352 | $content2 .= ( $bydaycnt ) ? ',' : null; |
4754 | - if( 'DAY' != strtoupper( $vix )) |
|
4755 | - $content21 .= $valuePart; |
|
4756 | - else { |
|
5353 | + if( 'DAY' != strtoupper( $vix )) { |
|
5354 | + $content21 .= $valuePart; |
|
5355 | + } else { |
|
4757 | 5356 | $content22 .= $valuePart; |
4758 | 5357 | $bydaycnt++; |
4759 | 5358 | } |
@@ -4797,24 +5396,32 @@ discard block |
||
4797 | 5396 | * @return bool |
4798 | 5397 | */ |
4799 | 5398 | function _isArrayDate( $input ) { |
4800 | - if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 )))) |
|
4801 | - return FALSE; |
|
4802 | - if( 7 == count( $input )) |
|
4803 | - return TRUE; |
|
4804 | - if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) |
|
4805 | - return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
4806 | - if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] )) |
|
4807 | - return FALSE; |
|
4808 | - if( in_array( 0, $input )) |
|
4809 | - return FALSE; |
|
4810 | - if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] )) |
|
4811 | - return FALSE; |
|
5399 | + if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 )))) { |
|
5400 | + return FALSE; |
|
5401 | + } |
|
5402 | + if( 7 == count( $input )) { |
|
5403 | + return TRUE; |
|
5404 | + } |
|
5405 | + if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) { |
|
5406 | + return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
5407 | + } |
|
5408 | + if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] )) { |
|
5409 | + return FALSE; |
|
5410 | + } |
|
5411 | + if( in_array( 0, $input )) { |
|
5412 | + return FALSE; |
|
5413 | + } |
|
5414 | + if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] )) { |
|
5415 | + return FALSE; |
|
5416 | + } |
|
4812 | 5417 | if(( isset( $input[0] ) && isset( $input[1] ) && isset( $input[2] )) && |
4813 | - checkdate( (int) $input[1], (int) $input[2], (int) $input[0] )) |
|
4814 | - return TRUE; |
|
5418 | + checkdate( (int) $input[1], (int) $input[2], (int) $input[0] )) { |
|
5419 | + return TRUE; |
|
5420 | + } |
|
4815 | 5421 | $input = $this->_date_time_string( $input[1].'/'.$input[2].'/'.$input[0], 3 ); // m - d - Y |
4816 | - if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) |
|
4817 | - return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
5422 | + if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) { |
|
5423 | + return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
5424 | + } |
|
4818 | 5425 | return FALSE; |
4819 | 5426 | } |
4820 | 5427 | /** |
@@ -4838,16 +5445,17 @@ discard block |
||
4838 | 5445 | */ |
4839 | 5446 | function _isOffset( $input ) { |
4840 | 5447 | $input = trim( (string) $input ); |
4841 | - if( 'Z' == substr( $input, -1 )) |
|
4842 | - return TRUE; |
|
4843 | - elseif(( 5 <= strlen( $input )) && |
|
5448 | + if( 'Z' == substr( $input, -1 )) { |
|
5449 | + return TRUE; |
|
5450 | + } elseif(( 5 <= strlen( $input )) && |
|
4844 | 5451 | ( in_array( substr( $input, -5, 1 ), array( '+', '-' ))) && |
4845 | - ( '0000' < substr( $input, -4 )) && ( '9999' >= substr( $input, -4 ))) |
|
4846 | - return TRUE; |
|
4847 | - elseif(( 7 <= strlen( $input )) && |
|
5452 | + ( '0000' < substr( $input, -4 )) && ( '9999' >= substr( $input, -4 ))) { |
|
5453 | + return TRUE; |
|
5454 | + } elseif(( 7 <= strlen( $input )) && |
|
4848 | 5455 | ( in_array( substr( $input, -7, 1 ), array( '+', '-' ))) && |
4849 | - ( '000000' < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 ))) |
|
4850 | - return TRUE; |
|
5456 | + ( '000000' < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 ))) { |
|
5457 | + return TRUE; |
|
5458 | + } |
|
4851 | 5459 | return FALSE; |
4852 | 5460 | |
4853 | 5461 | } |
@@ -4860,14 +5468,29 @@ discard block |
||
4860 | 5468 | * @return bool |
4861 | 5469 | */ |
4862 | 5470 | function _notExistProp( $propName ) { |
4863 | - if( empty( $propName )) return FALSE; // when deleting x-prop, an empty propName may be used=allowed |
|
5471 | + if( empty( $propName )) { |
|
5472 | + return FALSE; |
|
5473 | + } |
|
5474 | + // when deleting x-prop, an empty propName may be used=allowed |
|
4864 | 5475 | $propName = strtolower( $propName ); |
4865 | - if( 'last-modified' == $propName ) { if( !isset( $this->lastmodified )) return TRUE; } |
|
4866 | - elseif( 'percent-complete' == $propName ) { if( !isset( $this->percentcomplete )) return TRUE; } |
|
4867 | - elseif( 'recurrence-id' == $propName ) { if( !isset( $this->recurrenceid )) return TRUE; } |
|
4868 | - elseif( 'related-to' == $propName ) { if( !isset( $this->relatedto )) return TRUE; } |
|
4869 | - elseif( 'request-status' == $propName ) { if( !isset( $this->requeststatus )) return TRUE; } |
|
4870 | - elseif(( 'x-' != substr($propName,0,2)) && !isset( $this->$propName )) return TRUE; |
|
5476 | + if( 'last-modified' == $propName ) { if( !isset( $this->lastmodified )) { |
|
5477 | + return TRUE; |
|
5478 | + } |
|
5479 | + } elseif( 'percent-complete' == $propName ) { if( !isset( $this->percentcomplete )) { |
|
5480 | + return TRUE; |
|
5481 | + } |
|
5482 | + } elseif( 'recurrence-id' == $propName ) { if( !isset( $this->recurrenceid )) { |
|
5483 | + return TRUE; |
|
5484 | + } |
|
5485 | + } elseif( 'related-to' == $propName ) { if( !isset( $this->relatedto )) { |
|
5486 | + return TRUE; |
|
5487 | + } |
|
5488 | + } elseif( 'request-status' == $propName ) { if( !isset( $this->requeststatus )) { |
|
5489 | + return TRUE; |
|
5490 | + } |
|
5491 | + } elseif(( 'x-' != substr($propName,0,2)) && !isset( $this->$propName )) { |
|
5492 | + return TRUE; |
|
5493 | + } |
|
4871 | 5494 | return FALSE; |
4872 | 5495 | } |
4873 | 5496 | /** |
@@ -4886,7 +5509,9 @@ discard block |
||
4886 | 5509 | * @todo BYHOUR, BYMINUTE, BYSECOND, ev. BYSETPOS due to ambiguity, WEEKLY at year end/start |
4887 | 5510 | */ |
4888 | 5511 | function _recur2date( & $result, $recur, $wdate, $startdate, $enddate=FALSE ) { |
4889 | - foreach( $wdate as $k => $v ) if( ctype_digit( $v )) $wdate[$k] = (int) $v; |
|
5512 | + foreach( $wdate as $k => $v ) { |
|
5513 | + if( ctype_digit( $v )) $wdate[$k] = (int) $v; |
|
5514 | + } |
|
4890 | 5515 | $wdatets = $this->_date2timestamp( $wdate ); |
4891 | 5516 | $startdatets = $this->_date2timestamp( $startdate ); |
4892 | 5517 | if( !$enddate ) { |
@@ -4895,43 +5520,54 @@ discard block |
||
4895 | 5520 | // echo "recur __in_ ".implode('-',$startdate)." period start ".implode('-',$wdate)." period end ".implode('-',$enddate)."<br />\n";print_r($recur);echo "<br />\n";//test### |
4896 | 5521 | } |
4897 | 5522 | $endDatets = $this->_date2timestamp( $enddate ); // fix break |
4898 | - if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] )) |
|
4899 | - $recur['UNTIL'] = $enddate; // create break |
|
5523 | + if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] )) { |
|
5524 | + $recur['UNTIL'] = $enddate; |
|
5525 | + } |
|
5526 | + // create break |
|
4900 | 5527 | if( isset( $recur['UNTIL'] )) { |
4901 | 5528 | $tdatets = $this->_date2timestamp( $recur['UNTIL'] ); |
4902 | 5529 | if( $endDatets > $tdatets ) { |
4903 | 5530 | $endDatets = $tdatets; // emergency break |
4904 | 5531 | $enddate = $this->_timestamp2date( $endDatets, 6 ); |
5532 | + } else { |
|
5533 | + $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 ); |
|
4905 | 5534 | } |
4906 | - else |
|
4907 | - $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 ); |
|
4908 | 5535 | } |
4909 | 5536 | if( $wdatets > $endDatets ) { |
4910 | 5537 | //echo "recur out of date ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test |
4911 | 5538 | return array(); // nothing to do.. . |
4912 | 5539 | } |
4913 | - if( !isset( $recur['FREQ'] )) // "MUST be specified.. ." |
|
4914 | - $recur['FREQ'] = 'DAILY'; // ?? |
|
5540 | + if( !isset( $recur['FREQ'] )) { |
|
5541 | + // "MUST be specified.. ." |
|
5542 | + $recur['FREQ'] = 'DAILY'; |
|
5543 | + } |
|
5544 | + // ?? |
|
4915 | 5545 | $wkst = ( isset( $recur['WKST'] ) && ( 'SU' == $recur['WKST'] )) ? 24*60*60 : 0; // ?? |
4916 | - if( !isset( $recur['INTERVAL'] )) |
|
4917 | - $recur['INTERVAL'] = 1; |
|
5546 | + if( !isset( $recur['INTERVAL'] )) { |
|
5547 | + $recur['INTERVAL'] = 1; |
|
5548 | + } |
|
4918 | 5549 | $countcnt = ( !isset( $recur['BYSETPOS'] )) ? 1 : 0; // DTSTART counts as the first occurrence |
4919 | 5550 | /* find out how to step up dates and set index for interval count */ |
4920 | 5551 | $step = array(); |
4921 | - if( 'YEARLY' == $recur['FREQ'] ) |
|
4922 | - $step['year'] = 1; |
|
4923 | - elseif( 'MONTHLY' == $recur['FREQ'] ) |
|
4924 | - $step['month'] = 1; |
|
4925 | - elseif( 'WEEKLY' == $recur['FREQ'] ) |
|
4926 | - $step['day'] = 7; |
|
4927 | - else |
|
4928 | - $step['day'] = 1; |
|
4929 | - if( isset( $step['year'] ) && isset( $recur['BYMONTH'] )) |
|
4930 | - $step = array( 'month' => 1 ); |
|
4931 | - if( empty( $step ) && isset( $recur['BYWEEKNO'] )) // ?? |
|
5552 | + if( 'YEARLY' == $recur['FREQ'] ) { |
|
5553 | + $step['year'] = 1; |
|
5554 | + } elseif( 'MONTHLY' == $recur['FREQ'] ) { |
|
5555 | + $step['month'] = 1; |
|
5556 | + } elseif( 'WEEKLY' == $recur['FREQ'] ) { |
|
5557 | + $step['day'] = 7; |
|
5558 | + } else { |
|
5559 | + $step['day'] = 1; |
|
5560 | + } |
|
5561 | + if( isset( $step['year'] ) && isset( $recur['BYMONTH'] )) { |
|
5562 | + $step = array( 'month' => 1 ); |
|
5563 | + } |
|
5564 | + if( empty( $step ) && isset( $recur['BYWEEKNO'] )) { |
|
5565 | + // ?? |
|
4932 | 5566 | $step = array( 'day' => 7 ); |
4933 | - if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] )) |
|
4934 | - $step = array( 'day' => 1 ); |
|
5567 | + } |
|
5568 | + if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] )) { |
|
5569 | + $step = array( 'day' => 1 ); |
|
5570 | + } |
|
4935 | 5571 | $intervalarr = array(); |
4936 | 5572 | if( 1 < $recur['INTERVAL'] ) { |
4937 | 5573 | $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst ); |
@@ -4944,11 +5580,12 @@ discard block |
||
4944 | 5580 | $bysetposMold = $wdate['month']; |
4945 | 5581 | $bysetposDold = $wdate['day']; |
4946 | 5582 | if( is_array( $recur['BYSETPOS'] )) { |
4947 | - foreach( $recur['BYSETPOS'] as $bix => $bval ) |
|
4948 | - $recur['BYSETPOS'][$bix] = (int) $bval; |
|
5583 | + foreach( $recur['BYSETPOS'] as $bix => $bval ) { |
|
5584 | + $recur['BYSETPOS'][$bix] = (int) $bval; |
|
5585 | + } |
|
5586 | + } else { |
|
5587 | + $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] ); |
|
4949 | 5588 | } |
4950 | - else |
|
4951 | - $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] ); |
|
4952 | 5589 | $this->_stepdate( $enddate, $endDatets, $step); // make sure to count whole last period |
4953 | 5590 | } |
4954 | 5591 | $this->_stepdate( $wdate, $wdatets, $step); |
@@ -4957,10 +5594,12 @@ discard block |
||
4957 | 5594 | /* MAIN LOOP */ |
4958 | 5595 | // echo "recur start ".implode('-',$wdate)." end ".implode('-',$enddate)."<br />\n";//test |
4959 | 5596 | while( TRUE ) { |
4960 | - if( isset( $endDatets ) && ( $wdatets > $endDatets )) |
|
4961 | - break; |
|
4962 | - if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) |
|
4963 | - break; |
|
5597 | + if( isset( $endDatets ) && ( $wdatets > $endDatets )) { |
|
5598 | + break; |
|
5599 | + } |
|
5600 | + if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) { |
|
5601 | + break; |
|
5602 | + } |
|
4964 | 5603 | if( $year_old != $wdate['year'] ) { |
4965 | 5604 | $year_old = $wdate['year']; |
4966 | 5605 | $daycnts = array(); |
@@ -4969,8 +5608,9 @@ discard block |
||
4969 | 5608 | for( $m = 1; $m <= 12; $m++ ) { // count up and update up-counters |
4970 | 5609 | $daycnts[$m] = array(); |
4971 | 5610 | $weekdaycnt = array(); |
4972 | - foreach( $daynames as $dn ) |
|
4973 | - $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
|
5611 | + foreach( $daynames as $dn ) { |
|
5612 | + $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
|
5613 | + } |
|
4974 | 5614 | $mcnt = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] )); |
4975 | 5615 | for( $d = 1; $d <= $mcnt; $d++ ) { |
4976 | 5616 | $daycnts[$m][$d] = array(); |
@@ -4987,8 +5627,9 @@ discard block |
||
4987 | 5627 | $yeardaycnt[$day]++; |
4988 | 5628 | $daycnts[$m][$d]['yeardayno_up'] = $yeardaycnt[$day]; |
4989 | 5629 | } |
4990 | - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) |
|
4991 | - $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year'])); |
|
5630 | + if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) { |
|
5631 | + $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year'])); |
|
5632 | + } |
|
4992 | 5633 | } |
4993 | 5634 | } |
4994 | 5635 | $daycnt = 0; |
@@ -4996,9 +5637,9 @@ discard block |
||
4996 | 5637 | if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) { |
4997 | 5638 | $weekno = null; |
4998 | 5639 | for( $d=31; $d > 25; $d-- ) { // get last weekno for year |
4999 | - if( !$weekno ) |
|
5000 | - $weekno = $daycnts[12][$d]['weekno_up']; |
|
5001 | - elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) { |
|
5640 | + if( !$weekno ) { |
|
5641 | + $weekno = $daycnts[12][$d]['weekno_up']; |
|
5642 | + } elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) { |
|
5002 | 5643 | $weekno = $daycnts[12][$d]['weekno_up']; |
5003 | 5644 | break; |
5004 | 5645 | } |
@@ -5006,8 +5647,9 @@ discard block |
||
5006 | 5647 | } |
5007 | 5648 | for( $m = 12; $m > 0; $m-- ) { // count down and update down-counters |
5008 | 5649 | $weekdaycnt = array(); |
5009 | - foreach( $daynames as $dn ) |
|
5010 | - $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
|
5650 | + foreach( $daynames as $dn ) { |
|
5651 | + $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
|
5652 | + } |
|
5011 | 5653 | $monthcnt = 0; |
5012 | 5654 | $mcnt = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] )); |
5013 | 5655 | for( $d = $mcnt; $d > 0; $d-- ) { |
@@ -5026,8 +5668,9 @@ discard block |
||
5026 | 5668 | $yeardaycnt[$day] -= 1; |
5027 | 5669 | $daycnts[$m][$d]['yeardayno_down'] = $yeardaycnt[$day]; |
5028 | 5670 | } |
5029 | - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) |
|
5030 | - $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1); |
|
5671 | + if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) { |
|
5672 | + $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1); |
|
5673 | + } |
|
5031 | 5674 | } |
5032 | 5675 | } |
5033 | 5676 | } |
@@ -5038,36 +5681,42 @@ discard block |
||
5038 | 5681 | /* check interval */ |
5039 | 5682 | $currentKey = array_keys( $intervalarr ); |
5040 | 5683 | $currentKey = end( $currentKey ); // get last index |
5041 | - if( $currentKey != $intervalix ) |
|
5042 | - $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 )); |
|
5684 | + if( $currentKey != $intervalix ) { |
|
5685 | + $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 )); |
|
5686 | + } |
|
5043 | 5687 | if(( $recur['INTERVAL'] != $intervalarr[$intervalix] ) && |
5044 | 5688 | ( 0 != $intervalarr[$intervalix] )) { |
5045 | 5689 | /* step up date */ |
5046 | 5690 | //echo "skip: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test |
5047 | 5691 | $this->_stepdate( $wdate, $wdatets, $step); |
5048 | 5692 | continue; |
5049 | - } |
|
5050 | - else // continue within the selected interval |
|
5693 | + } else { |
|
5694 | + // continue within the selected interval |
|
5051 | 5695 | $intervalarr[$intervalix] = 0; |
5696 | + } |
|
5052 | 5697 | //echo "cont: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test |
5053 | 5698 | } |
5054 | 5699 | $updateOK = TRUE; |
5055 | - if( $updateOK && isset( $recur['BYMONTH'] )) |
|
5056 | - $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH'] |
|
5700 | + if( $updateOK && isset( $recur['BYMONTH'] )) { |
|
5701 | + $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH'] |
|
5057 | 5702 | , $wdate['month'] |
5058 | 5703 | ,($wdate['month'] - 13)); |
5059 | - if( $updateOK && isset( $recur['BYWEEKNO'] )) |
|
5060 | - $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO'] |
|
5704 | + } |
|
5705 | + if( $updateOK && isset( $recur['BYWEEKNO'] )) { |
|
5706 | + $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO'] |
|
5061 | 5707 | , $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] |
5062 | 5708 | , $daycnts[$wdate['month']][$wdate['day']]['weekno_down'] ); |
5063 | - if( $updateOK && isset( $recur['BYYEARDAY'] )) |
|
5064 | - $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY'] |
|
5709 | + } |
|
5710 | + if( $updateOK && isset( $recur['BYYEARDAY'] )) { |
|
5711 | + $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY'] |
|
5065 | 5712 | , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_up'] |
5066 | 5713 | , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down'] ); |
5067 | - if( $updateOK && isset( $recur['BYMONTHDAY'] )) |
|
5068 | - $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY'] |
|
5714 | + } |
|
5715 | + if( $updateOK && isset( $recur['BYMONTHDAY'] )) { |
|
5716 | + $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY'] |
|
5069 | 5717 | , $wdate['day'] |
5070 | 5718 | , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down'] ); |
5719 | + } |
|
5071 | 5720 | //echo "efter BYMONTHDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n";//test### |
5072 | 5721 | if( $updateOK && isset( $recur['BYDAY'] )) { |
5073 | 5722 | $updateOK = FALSE; |
@@ -5075,42 +5724,45 @@ discard block |
||
5075 | 5724 | $d = $wdate['day']; |
5076 | 5725 | if( isset( $recur['BYDAY']['DAY'] )) { // single day, opt with year/month day order no |
5077 | 5726 | $daynoexists = $daynosw = $daynamesw = FALSE; |
5078 | - if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] ) |
|
5079 | - $daynamesw = TRUE; |
|
5727 | + if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] ) { |
|
5728 | + $daynamesw = TRUE; |
|
5729 | + } |
|
5080 | 5730 | if( isset( $recur['BYDAY'][0] )) { |
5081 | 5731 | $daynoexists = TRUE; |
5082 | - if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] )) |
|
5083 | - $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5732 | + if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] )) { |
|
5733 | + $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5084 | 5734 | , $daycnts[$m][$d]['monthdayno_up'] |
5085 | 5735 | , $daycnts[$m][$d]['monthdayno_down'] ); |
5086 | - elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) |
|
5087 | - $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5736 | + } elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) { |
|
5737 | + $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5088 | 5738 | , $daycnts[$m][$d]['yeardayno_up'] |
5089 | 5739 | , $daycnts[$m][$d]['yeardayno_down'] ); |
5740 | + } |
|
5090 | 5741 | } |
5091 | 5742 | if(( $daynoexists && $daynosw && $daynamesw ) || |
5092 | 5743 | ( !$daynoexists && !$daynosw && $daynamesw )) { |
5093 | 5744 | $updateOK = TRUE; |
5094 | 5745 | } |
5095 | 5746 | //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ### |
5096 | - } |
|
5097 | - else { |
|
5747 | + } else { |
|
5098 | 5748 | foreach( $recur['BYDAY'] as $bydayvalue ) { |
5099 | 5749 | $daynoexists = $daynosw = $daynamesw = FALSE; |
5100 | 5750 | if( isset( $bydayvalue['DAY'] ) && |
5101 | - ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] )) |
|
5102 | - $daynamesw = TRUE; |
|
5751 | + ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] )) { |
|
5752 | + $daynamesw = TRUE; |
|
5753 | + } |
|
5103 | 5754 | if( isset( $bydayvalue[0] )) { |
5104 | 5755 | $daynoexists = TRUE; |
5105 | 5756 | if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || |
5106 | - isset( $recur['BYMONTH'] )) |
|
5107 | - $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5757 | + isset( $recur['BYMONTH'] )) { |
|
5758 | + $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5108 | 5759 | , $daycnts[$m][$d]['monthdayno_up'] |
5109 | 5760 | , $daycnts[$m][$d]['monthdayno_down'] ); |
5110 | - elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) |
|
5111 | - $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5761 | + } elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) { |
|
5762 | + $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5112 | 5763 | , $daycnts[$m][$d]['yeardayno_up'] |
5113 | 5764 | , $daycnts[$m][$d]['yeardayno_down'] ); |
5765 | + } |
|
5114 | 5766 | } |
5115 | 5767 | //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ### |
5116 | 5768 | if(( $daynoexists && $daynosw && $daynamesw ) || |
@@ -5127,12 +5779,12 @@ discard block |
||
5127 | 5779 | if( isset( $recur['BYSETPOS'] ) && |
5128 | 5780 | ( in_array( $recur['FREQ'], array( 'YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY' )))) { |
5129 | 5781 | if( isset( $recur['WEEKLY'] )) { |
5130 | - if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] ) |
|
5131 | - $bysetposw1[] = $wdatets; |
|
5132 | - else |
|
5133 | - $bysetposw2[] = $wdatets; |
|
5134 | - } |
|
5135 | - else { |
|
5782 | + if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] ) { |
|
5783 | + $bysetposw1[] = $wdatets; |
|
5784 | + } else { |
|
5785 | + $bysetposw2[] = $wdatets; |
|
5786 | + } |
|
5787 | + } else { |
|
5136 | 5788 | if(( isset( $recur['FREQ'] ) && ( 'YEARLY' == $recur['FREQ'] ) && |
5137 | 5789 | ( $bysetposYold == $wdate['year'] )) || |
5138 | 5790 | ( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] ) && |
@@ -5141,13 +5793,13 @@ discard block |
||
5141 | 5793 | ( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] ) && |
5142 | 5794 | (( $bysetposYold == $wdate['year'] ) && |
5143 | 5795 | ( $bysetposMold == $wdate['month']) && |
5144 | - ( $bysetposDold == $wdate['sday'] )))) |
|
5145 | - $bysetposymd1[] = $wdatets; |
|
5146 | - else |
|
5147 | - $bysetposymd2[] = $wdatets; |
|
5796 | + ( $bysetposDold == $wdate['sday'] )))) { |
|
5797 | + $bysetposymd1[] = $wdatets; |
|
5798 | + } else { |
|
5799 | + $bysetposymd2[] = $wdatets; |
|
5800 | + } |
|
5148 | 5801 | } |
5149 | - } |
|
5150 | - else { |
|
5802 | + } else { |
|
5151 | 5803 | /* update result array if BYSETPOS is set */ |
5152 | 5804 | $countcnt++; |
5153 | 5805 | if( $startdatets <= $wdatets ) { // only output within period |
@@ -5167,21 +5819,18 @@ discard block |
||
5167 | 5819 | ( $bysetposYold != $wdate['year'] )) { |
5168 | 5820 | $bysetpos = TRUE; |
5169 | 5821 | $bysetposYold = $wdate['year']; |
5170 | - } |
|
5171 | - elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] && |
|
5822 | + } elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] && |
|
5172 | 5823 | (( $bysetposYold != $wdate['year'] ) || ( $bysetposMold != $wdate['month'] )))) { |
5173 | 5824 | $bysetpos = TRUE; |
5174 | 5825 | $bysetposYold = $wdate['year']; |
5175 | 5826 | $bysetposMold = $wdate['month']; |
5176 | - } |
|
5177 | - elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY' == $recur['FREQ'] )) { |
|
5827 | + } elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY' == $recur['FREQ'] )) { |
|
5178 | 5828 | $weekno = (int) date( 'W', mktime( 0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year'])); |
5179 | 5829 | if( $bysetposWold != $weekno ) { |
5180 | 5830 | $bysetposWold = $weekno; |
5181 | 5831 | $bysetpos = TRUE; |
5182 | 5832 | } |
5183 | - } |
|
5184 | - elseif( isset( $recur['FREQ'] ) && ( 'DAILY' == $recur['FREQ'] ) && |
|
5833 | + } elseif( isset( $recur['FREQ'] ) && ( 'DAILY' == $recur['FREQ'] ) && |
|
5185 | 5834 | (( $bysetposYold != $wdate['year'] ) || |
5186 | 5835 | ( $bysetposMold != $wdate['month'] ) || |
5187 | 5836 | ( $bysetposDold != $wdate['sday'] ))) { |
@@ -5194,14 +5843,15 @@ discard block |
||
5194 | 5843 | if( isset( $recur['BYWEEKNO'] )) { |
5195 | 5844 | $bysetposarr1 = & $bysetposw1; |
5196 | 5845 | $bysetposarr2 = & $bysetposw2; |
5197 | - } |
|
5198 | - else { |
|
5846 | + } else { |
|
5199 | 5847 | $bysetposarr1 = & $bysetposymd1; |
5200 | 5848 | $bysetposarr2 = & $bysetposymd2; |
5201 | 5849 | } |
5202 | 5850 | foreach( $recur['BYSETPOS'] as $ix ) { |
5203 | - if( 0 > $ix ) // both positive and negative BYSETPOS allowed |
|
5851 | + if( 0 > $ix ) { |
|
5852 | + // both positive and negative BYSETPOS allowed |
|
5204 | 5853 | $ix = ( count( $bysetposarr1 ) + $ix + 1); |
5854 | + } |
|
5205 | 5855 | $ix--; |
5206 | 5856 | if( isset( $bysetposarr1[$ix] )) { |
5207 | 5857 | if( $startdatets <= $bysetposarr1[$ix] ) { // only output within period |
@@ -5210,8 +5860,9 @@ discard block |
||
5210 | 5860 | } |
5211 | 5861 | $countcnt++; |
5212 | 5862 | } |
5213 | - if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) |
|
5214 | - break; |
|
5863 | + if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) { |
|
5864 | + break; |
|
5865 | + } |
|
5215 | 5866 | } |
5216 | 5867 | $bysetposarr1 = $bysetposarr2; |
5217 | 5868 | $bysetposarr2 = array(); |
@@ -5221,12 +5872,13 @@ discard block |
||
5221 | 5872 | } |
5222 | 5873 | function _recurBYcntcheck( $BYvalue, $upValue, $downValue ) { |
5223 | 5874 | if( is_array( $BYvalue ) && |
5224 | - ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue ))) |
|
5225 | - return TRUE; |
|
5226 | - elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue )) |
|
5227 | - return TRUE; |
|
5228 | - else |
|
5229 | - return FALSE; |
|
5875 | + ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue ))) { |
|
5876 | + return TRUE; |
|
5877 | + } elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue )) { |
|
5878 | + return TRUE; |
|
5879 | + } else { |
|
5880 | + return FALSE; |
|
5881 | + } |
|
5230 | 5882 | } |
5231 | 5883 | function _recurIntervalIx( $freq, $date, $wkst ) { |
5232 | 5884 | /* create interval index */ |
@@ -5258,21 +5910,27 @@ discard block |
||
5258 | 5910 | */ |
5259 | 5911 | function _setRexrule( $rexrule ) { |
5260 | 5912 | $input = array(); |
5261 | - if( empty( $rexrule )) |
|
5262 | - return $input; |
|
5913 | + if( empty( $rexrule )) { |
|
5914 | + return $input; |
|
5915 | + } |
|
5263 | 5916 | foreach( $rexrule as $rexrulelabel => $rexrulevalue ) { |
5264 | 5917 | $rexrulelabel = strtoupper( $rexrulelabel ); |
5265 | - if( 'UNTIL' != $rexrulelabel ) |
|
5266 | - $input[$rexrulelabel] = $rexrulevalue; |
|
5267 | - else { |
|
5268 | - if( $this->_isArrayTimestampDate( $rexrulevalue )) // timestamp date |
|
5918 | + if( 'UNTIL' != $rexrulelabel ) { |
|
5919 | + $input[$rexrulelabel] = $rexrulevalue; |
|
5920 | + } else { |
|
5921 | + if( $this->_isArrayTimestampDate( $rexrulevalue )) { |
|
5922 | + // timestamp date |
|
5269 | 5923 | $input[$rexrulelabel] = $this->_timestamp2date( $rexrulevalue, 6 ); |
5270 | - elseif( $this->_isArrayDate( $rexrulevalue )) // date-time |
|
5924 | + } elseif( $this->_isArrayDate( $rexrulevalue )) { |
|
5925 | + // date-time |
|
5271 | 5926 | $input[$rexrulelabel] = $this->_date_time_array( $rexrulevalue, 6 ); |
5272 | - elseif( 8 <= strlen( trim( $rexrulevalue ))) // ex. 2006-08-03 10:12:18 |
|
5927 | + } elseif( 8 <= strlen( trim( $rexrulevalue ))) { |
|
5928 | + // ex. 2006-08-03 10:12:18 |
|
5273 | 5929 | $input[$rexrulelabel] = $this->_date_time_string( $rexrulevalue ); |
5274 | - if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] )) |
|
5275 | - $input[$rexrulelabel]['tz'] = 'Z'; |
|
5930 | + } |
|
5931 | + if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] )) { |
|
5932 | + $input[$rexrulelabel]['tz'] = 'Z'; |
|
5933 | + } |
|
5276 | 5934 | } |
5277 | 5935 | } |
5278 | 5936 | return $input; |
@@ -5296,7 +5954,9 @@ discard block |
||
5296 | 5954 | $input = $parno = null; |
5297 | 5955 | $localtime = (( 'dtstart' == $caller ) && in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE; |
5298 | 5956 | if( $this->_isArrayDate( $year )) { |
5299 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5957 | + if( $localtime ) { |
|
5958 | + unset ( $month['VALUE'], $month['TZID'] ); |
|
5959 | + } |
|
5300 | 5960 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
5301 | 5961 | if( isset( $input['params']['TZID'] )) { |
5302 | 5962 | $input['params']['VALUE'] = 'DATE-TIME'; |
@@ -5306,9 +5966,10 @@ discard block |
||
5306 | 5966 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval ); |
5307 | 5967 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, count( $year ), $parno ); |
5308 | 5968 | $input['value'] = $this->_date_time_array( $year, $parno ); |
5309 | - } |
|
5310 | - elseif( $this->_isArrayTimestampDate( $year )) { |
|
5311 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5969 | + } elseif( $this->_isArrayTimestampDate( $year )) { |
|
5970 | + if( $localtime ) { |
|
5971 | + unset ( $month['VALUE'], $month['TZID'] ); |
|
5972 | + } |
|
5312 | 5973 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
5313 | 5974 | if( isset( $input['params']['TZID'] )) { |
5314 | 5975 | $input['params']['VALUE'] = 'DATE-TIME'; |
@@ -5318,9 +5979,10 @@ discard block |
||
5318 | 5979 | $hitval = ( isset( $year['tz'] )) ? 7 : 6; |
5319 | 5980 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno ); |
5320 | 5981 | $input['value'] = $this->_timestamp2date( $year, $parno ); |
5321 | - } |
|
5322 | - elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
5323 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5982 | + } elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
5983 | + if( $localtime ) { |
|
5984 | + unset ( $month['VALUE'], $month['TZID'] ); |
|
5985 | + } |
|
5324 | 5986 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
5325 | 5987 | if( isset( $input['params']['TZID'] )) { |
5326 | 5988 | $input['params']['VALUE'] = 'DATE-TIME'; |
@@ -5329,17 +5991,16 @@ discard block |
||
5329 | 5991 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7, $parno ); |
5330 | 5992 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, $parno, $parno ); |
5331 | 5993 | $input['value'] = $this->_date_time_string( $year, $parno ); |
5332 | - } |
|
5333 | - else { |
|
5994 | + } else { |
|
5334 | 5995 | if( is_array( $params )) { |
5335 | - if( $localtime ) unset ( $params['VALUE'], $params['TZID'] ); |
|
5996 | + if( $localtime ) { |
|
5997 | + unset ( $params['VALUE'], $params['TZID'] ); |
|
5998 | + } |
|
5336 | 5999 | $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )); |
5337 | - } |
|
5338 | - elseif( is_array( $tz )) { |
|
6000 | + } elseif( is_array( $tz )) { |
|
5339 | 6001 | $input['params'] = $this->_setParams( $tz, array( 'VALUE' => 'DATE-TIME' )); |
5340 | 6002 | $tz = FALSE; |
5341 | - } |
|
5342 | - elseif( is_array( $hour )) { |
|
6003 | + } elseif( is_array( $hour )) { |
|
5343 | 6004 | $input['params'] = $this->_setParams( $hour, array( 'VALUE' => 'DATE-TIME' )); |
5344 | 6005 | $hour = $min = $sec = $tz = FALSE; |
5345 | 6006 | } |
@@ -5355,23 +6016,28 @@ discard block |
||
5355 | 6016 | $input['value']['hour'] = ( $hour ) ? $hour : '0'; |
5356 | 6017 | $input['value']['min'] = ( $min ) ? $min : '0'; |
5357 | 6018 | $input['value']['sec'] = ( $sec ) ? $sec : '0'; |
5358 | - if( !empty( $tz )) |
|
5359 | - $input['value']['tz'] = $tz; |
|
6019 | + if( !empty( $tz )) { |
|
6020 | + $input['value']['tz'] = $tz; |
|
6021 | + } |
|
5360 | 6022 | } |
5361 | 6023 | } |
5362 | 6024 | if( 3 == $parno ) { |
5363 | 6025 | $input['params']['VALUE'] = 'DATE'; |
5364 | 6026 | unset( $input['value']['tz'] ); |
5365 | 6027 | unset( $input['params']['TZID'] ); |
6028 | + } elseif( isset( $input['params']['TZID'] )) { |
|
6029 | + unset( $input['value']['tz'] ); |
|
6030 | + } |
|
6031 | + if( $localtime ) { |
|
6032 | + unset( $input['value']['tz'], $input['params']['TZID'] ); |
|
6033 | + } |
|
6034 | + if( isset( $input['value']['tz'] )) { |
|
6035 | + $input['value']['tz'] = (string) $input['value']['tz']; |
|
5366 | 6036 | } |
5367 | - elseif( isset( $input['params']['TZID'] )) |
|
5368 | - unset( $input['value']['tz'] ); |
|
5369 | - if( $localtime ) unset( $input['value']['tz'], $input['params']['TZID'] ); |
|
5370 | - if( isset( $input['value']['tz'] )) |
|
5371 | - $input['value']['tz'] = (string) $input['value']['tz']; |
|
5372 | 6037 | if( !empty( $input['value']['tz'] ) && ( 'Z' != $input['value']['tz'] ) && |
5373 | - ( !$this->_isOffset( $input['value']['tz'] ))) |
|
5374 | - $input['params']['TZID'] = $input['value']['tz']; |
|
6038 | + ( !$this->_isOffset( $input['value']['tz'] ))) { |
|
6039 | + $input['params']['TZID'] = $input['value']['tz']; |
|
6040 | + } |
|
5375 | 6041 | return $input; |
5376 | 6042 | } |
5377 | 6043 | /** |
@@ -5393,16 +6059,13 @@ discard block |
||
5393 | 6059 | if( $this->_isArrayDate( $year )) { |
5394 | 6060 | $input['value'] = $this->_date_time_array( $year, 7 ); |
5395 | 6061 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
5396 | - } |
|
5397 | - elseif( $this->_isArrayTimestampDate( $year )) { |
|
6062 | + } elseif( $this->_isArrayTimestampDate( $year )) { |
|
5398 | 6063 | $input['value'] = $this->_timestamp2date( $year, 7 ); |
5399 | 6064 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
5400 | - } |
|
5401 | - elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
6065 | + } elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
5402 | 6066 | $input['value'] = $this->_date_time_string( $year, 7 ); |
5403 | 6067 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
5404 | - } |
|
5405 | - else { |
|
6068 | + } else { |
|
5406 | 6069 | $input['value'] = array( 'year' => $year |
5407 | 6070 | , 'month' => $month |
5408 | 6071 | , 'day' => $day |
@@ -5412,14 +6075,18 @@ discard block |
||
5412 | 6075 | $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )); |
5413 | 6076 | } |
5414 | 6077 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7 ); // remove default |
5415 | - if( !isset( $input['value']['hour'] )) |
|
5416 | - $input['value']['hour'] = 0; |
|
5417 | - if( !isset( $input['value']['min'] )) |
|
5418 | - $input['value']['min'] = 0; |
|
5419 | - if( !isset( $input['value']['sec'] )) |
|
5420 | - $input['value']['sec'] = 0; |
|
5421 | - if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] )) |
|
5422 | - $input['value']['tz'] = 'Z'; |
|
6078 | + if( !isset( $input['value']['hour'] )) { |
|
6079 | + $input['value']['hour'] = 0; |
|
6080 | + } |
|
6081 | + if( !isset( $input['value']['min'] )) { |
|
6082 | + $input['value']['min'] = 0; |
|
6083 | + } |
|
6084 | + if( !isset( $input['value']['sec'] )) { |
|
6085 | + $input['value']['sec'] = 0; |
|
6086 | + } |
|
6087 | + if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] )) { |
|
6088 | + $input['value']['tz'] = 'Z'; |
|
6089 | + } |
|
5423 | 6090 | return $input; |
5424 | 6091 | } |
5425 | 6092 | /** |
@@ -5435,15 +6102,17 @@ discard block |
||
5435 | 6102 | * @return void |
5436 | 6103 | */ |
5437 | 6104 | function _setMval( & $valArr, $value, $params=FALSE, $defaults=FALSE, $index=FALSE ) { |
5438 | - if( !is_array( $valArr )) $valArr = array(); |
|
5439 | - if( $index ) |
|
5440 | - $index = $index - 1; |
|
5441 | - elseif( 0 < count( $valArr )) { |
|
6105 | + if( !is_array( $valArr )) { |
|
6106 | + $valArr = array(); |
|
6107 | + } |
|
6108 | + if( $index ) { |
|
6109 | + $index = $index - 1; |
|
6110 | + } elseif( 0 < count( $valArr )) { |
|
5442 | 6111 | $index = end( array_keys( $valArr )); |
5443 | 6112 | $index += 1; |
6113 | + } else { |
|
6114 | + $index = 0; |
|
5444 | 6115 | } |
5445 | - else |
|
5446 | - $index = 0; |
|
5447 | 6116 | $valArr[$index] = array( 'value' => $value, 'params' => $this->_setParams( $params, $defaults )); |
5448 | 6117 | ksort( $valArr ); |
5449 | 6118 | } |
@@ -5459,27 +6128,31 @@ discard block |
||
5459 | 6128 | * @return array |
5460 | 6129 | */ |
5461 | 6130 | function _setParams( $params, $defaults=FALSE ) { |
5462 | - if( !is_array( $params)) |
|
5463 | - $params = array(); |
|
6131 | + if( !is_array( $params)) { |
|
6132 | + $params = array(); |
|
6133 | + } |
|
5464 | 6134 | $input = array(); |
5465 | 6135 | foreach( $params as $paramKey => $paramValue ) { |
5466 | 6136 | if( is_array( $paramValue )) { |
5467 | 6137 | foreach( $paramValue as $pkey => $pValue ) { |
5468 | - if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 ))) |
|
5469 | - $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 )); |
|
6138 | + if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 ))) { |
|
6139 | + $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 )); |
|
6140 | + } |
|
5470 | 6141 | } |
6142 | + } elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 ))) { |
|
6143 | + $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 )); |
|
6144 | + } |
|
6145 | + if( 'VALUE' == strtoupper( $paramKey )) { |
|
6146 | + $input['VALUE'] = strtoupper( $paramValue ); |
|
6147 | + } else { |
|
6148 | + $input[strtoupper( $paramKey )] = $paramValue; |
|
5471 | 6149 | } |
5472 | - elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 ))) |
|
5473 | - $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 )); |
|
5474 | - if( 'VALUE' == strtoupper( $paramKey )) |
|
5475 | - $input['VALUE'] = strtoupper( $paramValue ); |
|
5476 | - else |
|
5477 | - $input[strtoupper( $paramKey )] = $paramValue; |
|
5478 | 6150 | } |
5479 | 6151 | if( is_array( $defaults )) { |
5480 | 6152 | foreach( $defaults as $paramKey => $paramValue ) { |
5481 | - if( !isset( $input[$paramKey] )) |
|
5482 | - $input[$paramKey] = $paramValue; |
|
6153 | + if( !isset( $input[$paramKey] )) { |
|
6154 | + $input[$paramKey] = $paramValue; |
|
6155 | + } |
|
5483 | 6156 | } |
5484 | 6157 | } |
5485 | 6158 | return (0 < count( $input )) ? $input : null; |
@@ -5495,13 +6168,15 @@ discard block |
||
5495 | 6168 | * @return void |
5496 | 6169 | */ |
5497 | 6170 | function _stepdate( &$date, &$timestamp, $step=array( 'day' => 1 )) { |
5498 | - foreach( $step as $stepix => $stepvalue ) |
|
5499 | - $date[$stepix] += $stepvalue; |
|
6171 | + foreach( $step as $stepix => $stepvalue ) { |
|
6172 | + $date[$stepix] += $stepvalue; |
|
6173 | + } |
|
5500 | 6174 | $timestamp = $this->_date2timestamp( $date ); |
5501 | 6175 | $date = $this->_timestamp2date( $timestamp, 6 ); |
5502 | 6176 | foreach( $date as $k => $v ) { |
5503 | - if( ctype_digit( $v )) |
|
5504 | - $date[$k] = (int) $v; |
|
6177 | + if( ctype_digit( $v )) { |
|
6178 | + $date[$k] = (int) $v; |
|
6179 | + } |
|
5505 | 6180 | } |
5506 | 6181 | } |
5507 | 6182 | /** |
@@ -5515,8 +6190,9 @@ discard block |
||
5515 | 6190 | */ |
5516 | 6191 | function _timestamp2date( $timestamp, $parno=6 ) { |
5517 | 6192 | if( is_array( $timestamp )) { |
5518 | - if(( 7 == $parno ) && !empty( $timestamp['tz'] )) |
|
5519 | - $tz = $timestamp['tz']; |
|
6193 | + if(( 7 == $parno ) && !empty( $timestamp['tz'] )) { |
|
6194 | + $tz = $timestamp['tz']; |
|
6195 | + } |
|
5520 | 6196 | $timestamp = $timestamp['timestamp']; |
5521 | 6197 | } |
5522 | 6198 | $output = array( 'year' => date( 'Y', $timestamp ) |
@@ -5526,8 +6202,9 @@ discard block |
||
5526 | 6202 | $output['hour'] = date( 'H', $timestamp ); |
5527 | 6203 | $output['min'] = date( 'i', $timestamp ); |
5528 | 6204 | $output['sec'] = date( 's', $timestamp ); |
5529 | - if( isset( $tz )) |
|
5530 | - $output['tz'] = $tz; |
|
6205 | + if( isset( $tz )) { |
|
6206 | + $output['tz'] = $tz; |
|
6207 | + } |
|
5531 | 6208 | } |
5532 | 6209 | return $output; |
5533 | 6210 | } |
@@ -5545,8 +6222,9 @@ discard block |
||
5545 | 6222 | if((( 5 != strlen( $tz )) && ( 7 != strlen( $tz ))) || |
5546 | 6223 | (( '+' != substr( $tz, 0, 1 )) && ( '-' != substr( $tz, 0, 1 ))) || |
5547 | 6224 | (( '0000' >= substr( $tz, 1, 4 )) && ( '9999' < substr( $tz, 1, 4 ))) || |
5548 | - (( 7 == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 )))) |
|
5549 | - return $offset; |
|
6225 | + (( 7 == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 )))) { |
|
6226 | + return $offset; |
|
6227 | + } |
|
5550 | 6228 | $hours2sec = (int) substr( $tz, 1, 2 ) * 3600; |
5551 | 6229 | $min2sec = (int) substr( $tz, 3, 2 ) * 60; |
5552 | 6230 | $sec = ( 7 == strlen( $tz )) ? (int) substr( $tz, -2 ) : '00'; |
@@ -5574,7 +6252,9 @@ discard block |
||
5574 | 6252 | $info = array(); |
5575 | 6253 | if( isset( $this->components )) { |
5576 | 6254 | foreach( $this->components as $cix => $component ) { |
5577 | - if( empty( $component )) continue; |
|
6255 | + if( empty( $component )) { |
|
6256 | + continue; |
|
6257 | + } |
|
5578 | 6258 | unset( $component->propix ); |
5579 | 6259 | $info[$cix]['ordno'] = $cix + 1; |
5580 | 6260 | $info[$cix]['type'] = $component->objName; |
@@ -5600,57 +6280,146 @@ discard block |
||
5600 | 6280 | case 'PROPINFO': |
5601 | 6281 | $output = array(); |
5602 | 6282 | if( !in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
5603 | - if( empty( $this->uid['value'] )) $this->_makeuid(); |
|
6283 | + if( empty( $this->uid['value'] )) { |
|
6284 | + $this->_makeuid(); |
|
6285 | + } |
|
5604 | 6286 | $output['UID'] = 1; |
5605 | 6287 | } |
5606 | - if( !empty( $this->dtstamp )) $output['DTSTAMP'] = 1; |
|
5607 | - if( !empty( $this->summary )) $output['SUMMARY'] = 1; |
|
5608 | - if( !empty( $this->description )) $output['DESCRIPTION'] = count( $this->description ); |
|
5609 | - if( !empty( $this->dtstart )) $output['DTSTART'] = 1; |
|
5610 | - if( !empty( $this->dtend )) $output['DTEND'] = 1; |
|
5611 | - if( !empty( $this->due )) $output['DUE'] = 1; |
|
5612 | - if( !empty( $this->duration )) $output['DURATION'] = 1; |
|
5613 | - if( !empty( $this->rrule )) $output['RRULE'] = count( $this->rrule ); |
|
5614 | - if( !empty( $this->rdate )) $output['RDATE'] = count( $this->rdate ); |
|
5615 | - if( !empty( $this->exdate )) $output['EXDATE'] = count( $this->exdate ); |
|
5616 | - if( !empty( $this->exrule )) $output['EXRULE'] = count( $this->exrule ); |
|
5617 | - if( !empty( $this->action )) $output['ACTION'] = 1; |
|
5618 | - if( !empty( $this->attach )) $output['ATTACH'] = count( $this->attach ); |
|
5619 | - if( !empty( $this->attendee )) $output['ATTENDEE'] = count( $this->attendee ); |
|
5620 | - if( !empty( $this->categories )) $output['CATEGORIES'] = count( $this->categories ); |
|
5621 | - if( !empty( $this->class )) $output['CLASS'] = 1; |
|
5622 | - if( !empty( $this->comment )) $output['COMMENT'] = count( $this->comment ); |
|
5623 | - if( !empty( $this->completed )) $output['COMPLETED'] = 1; |
|
5624 | - if( !empty( $this->contact )) $output['CONTACT'] = count( $this->contact ); |
|
5625 | - if( !empty( $this->created )) $output['CREATED'] = 1; |
|
5626 | - if( !empty( $this->freebusy )) $output['FREEBUSY'] = count( $this->freebusy ); |
|
5627 | - if( !empty( $this->geo )) $output['GEO'] = 1; |
|
5628 | - if( !empty( $this->lastmodified )) $output['LAST-MODIFIED'] = 1; |
|
5629 | - if( !empty( $this->location )) $output['LOCATION'] = 1; |
|
5630 | - if( !empty( $this->organizer )) $output['ORGANIZER'] = 1; |
|
5631 | - if( !empty( $this->percentcomplete )) $output['PERCENT-COMPLETE'] = 1; |
|
5632 | - if( !empty( $this->priority )) $output['PRIORITY'] = 1; |
|
5633 | - if( !empty( $this->recurrenceid )) $output['RECURRENCE-ID'] = 1; |
|
5634 | - if( !empty( $this->relatedto )) $output['RELATED-TO'] = count( $this->relatedto ); |
|
5635 | - if( !empty( $this->repeat )) $output['REPEAT'] = 1; |
|
5636 | - if( !empty( $this->requeststatus )) $output['REQUEST-STATUS'] = count( $this->requeststatus ); |
|
5637 | - if( !empty( $this->resources )) $output['RESOURCES'] = count( $this->resources ); |
|
5638 | - if( !empty( $this->sequence )) $output['SEQUENCE'] = 1; |
|
5639 | - if( !empty( $this->status )) $output['STATUS'] = 1; |
|
5640 | - if( !empty( $this->transp )) $output['TRANSP'] = 1; |
|
5641 | - if( !empty( $this->trigger )) $output['TRIGGER'] = 1; |
|
5642 | - if( !empty( $this->tzid )) $output['TZID'] = 1; |
|
5643 | - if( !empty( $this->tzname )) $output['TZNAME'] = count( $this->tzname ); |
|
5644 | - if( !empty( $this->tzoffsetfrom )) $output['TZOFFSETTFROM'] = 1; |
|
5645 | - if( !empty( $this->tzoffsetto )) $output['TZOFFSETTO'] = 1; |
|
5646 | - if( !empty( $this->tzurl )) $output['TZURL'] = 1; |
|
5647 | - if( !empty( $this->url )) $output['URL'] = 1; |
|
5648 | - if( !empty( $this->xprop )) $output['X-PROP'] = count( $this->xprop ); |
|
6288 | + if( !empty( $this->dtstamp )) { |
|
6289 | + $output['DTSTAMP'] = 1; |
|
6290 | + } |
|
6291 | + if( !empty( $this->summary )) { |
|
6292 | + $output['SUMMARY'] = 1; |
|
6293 | + } |
|
6294 | + if( !empty( $this->description )) { |
|
6295 | + $output['DESCRIPTION'] = count( $this->description ); |
|
6296 | + } |
|
6297 | + if( !empty( $this->dtstart )) { |
|
6298 | + $output['DTSTART'] = 1; |
|
6299 | + } |
|
6300 | + if( !empty( $this->dtend )) { |
|
6301 | + $output['DTEND'] = 1; |
|
6302 | + } |
|
6303 | + if( !empty( $this->due )) { |
|
6304 | + $output['DUE'] = 1; |
|
6305 | + } |
|
6306 | + if( !empty( $this->duration )) { |
|
6307 | + $output['DURATION'] = 1; |
|
6308 | + } |
|
6309 | + if( !empty( $this->rrule )) { |
|
6310 | + $output['RRULE'] = count( $this->rrule ); |
|
6311 | + } |
|
6312 | + if( !empty( $this->rdate )) { |
|
6313 | + $output['RDATE'] = count( $this->rdate ); |
|
6314 | + } |
|
6315 | + if( !empty( $this->exdate )) { |
|
6316 | + $output['EXDATE'] = count( $this->exdate ); |
|
6317 | + } |
|
6318 | + if( !empty( $this->exrule )) { |
|
6319 | + $output['EXRULE'] = count( $this->exrule ); |
|
6320 | + } |
|
6321 | + if( !empty( $this->action )) { |
|
6322 | + $output['ACTION'] = 1; |
|
6323 | + } |
|
6324 | + if( !empty( $this->attach )) { |
|
6325 | + $output['ATTACH'] = count( $this->attach ); |
|
6326 | + } |
|
6327 | + if( !empty( $this->attendee )) { |
|
6328 | + $output['ATTENDEE'] = count( $this->attendee ); |
|
6329 | + } |
|
6330 | + if( !empty( $this->categories )) { |
|
6331 | + $output['CATEGORIES'] = count( $this->categories ); |
|
6332 | + } |
|
6333 | + if( !empty( $this->class )) { |
|
6334 | + $output['CLASS'] = 1; |
|
6335 | + } |
|
6336 | + if( !empty( $this->comment )) { |
|
6337 | + $output['COMMENT'] = count( $this->comment ); |
|
6338 | + } |
|
6339 | + if( !empty( $this->completed )) { |
|
6340 | + $output['COMPLETED'] = 1; |
|
6341 | + } |
|
6342 | + if( !empty( $this->contact )) { |
|
6343 | + $output['CONTACT'] = count( $this->contact ); |
|
6344 | + } |
|
6345 | + if( !empty( $this->created )) { |
|
6346 | + $output['CREATED'] = 1; |
|
6347 | + } |
|
6348 | + if( !empty( $this->freebusy )) { |
|
6349 | + $output['FREEBUSY'] = count( $this->freebusy ); |
|
6350 | + } |
|
6351 | + if( !empty( $this->geo )) { |
|
6352 | + $output['GEO'] = 1; |
|
6353 | + } |
|
6354 | + if( !empty( $this->lastmodified )) { |
|
6355 | + $output['LAST-MODIFIED'] = 1; |
|
6356 | + } |
|
6357 | + if( !empty( $this->location )) { |
|
6358 | + $output['LOCATION'] = 1; |
|
6359 | + } |
|
6360 | + if( !empty( $this->organizer )) { |
|
6361 | + $output['ORGANIZER'] = 1; |
|
6362 | + } |
|
6363 | + if( !empty( $this->percentcomplete )) { |
|
6364 | + $output['PERCENT-COMPLETE'] = 1; |
|
6365 | + } |
|
6366 | + if( !empty( $this->priority )) { |
|
6367 | + $output['PRIORITY'] = 1; |
|
6368 | + } |
|
6369 | + if( !empty( $this->recurrenceid )) { |
|
6370 | + $output['RECURRENCE-ID'] = 1; |
|
6371 | + } |
|
6372 | + if( !empty( $this->relatedto )) { |
|
6373 | + $output['RELATED-TO'] = count( $this->relatedto ); |
|
6374 | + } |
|
6375 | + if( !empty( $this->repeat )) { |
|
6376 | + $output['REPEAT'] = 1; |
|
6377 | + } |
|
6378 | + if( !empty( $this->requeststatus )) { |
|
6379 | + $output['REQUEST-STATUS'] = count( $this->requeststatus ); |
|
6380 | + } |
|
6381 | + if( !empty( $this->resources )) { |
|
6382 | + $output['RESOURCES'] = count( $this->resources ); |
|
6383 | + } |
|
6384 | + if( !empty( $this->sequence )) { |
|
6385 | + $output['SEQUENCE'] = 1; |
|
6386 | + } |
|
6387 | + if( !empty( $this->status )) { |
|
6388 | + $output['STATUS'] = 1; |
|
6389 | + } |
|
6390 | + if( !empty( $this->transp )) { |
|
6391 | + $output['TRANSP'] = 1; |
|
6392 | + } |
|
6393 | + if( !empty( $this->trigger )) { |
|
6394 | + $output['TRIGGER'] = 1; |
|
6395 | + } |
|
6396 | + if( !empty( $this->tzid )) { |
|
6397 | + $output['TZID'] = 1; |
|
6398 | + } |
|
6399 | + if( !empty( $this->tzname )) { |
|
6400 | + $output['TZNAME'] = count( $this->tzname ); |
|
6401 | + } |
|
6402 | + if( !empty( $this->tzoffsetfrom )) { |
|
6403 | + $output['TZOFFSETTFROM'] = 1; |
|
6404 | + } |
|
6405 | + if( !empty( $this->tzoffsetto )) { |
|
6406 | + $output['TZOFFSETTO'] = 1; |
|
6407 | + } |
|
6408 | + if( !empty( $this->tzurl )) { |
|
6409 | + $output['TZURL'] = 1; |
|
6410 | + } |
|
6411 | + if( !empty( $this->url )) { |
|
6412 | + $output['URL'] = 1; |
|
6413 | + } |
|
6414 | + if( !empty( $this->xprop )) { |
|
6415 | + $output['X-PROP'] = count( $this->xprop ); |
|
6416 | + } |
|
5649 | 6417 | return $output; |
5650 | 6418 | break; |
5651 | 6419 | case 'UNIQUE_ID': |
5652 | - if( empty( $this->unique_id )) |
|
5653 | - $this->unique_id = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost'; |
|
6420 | + if( empty( $this->unique_id )) { |
|
6421 | + $this->unique_id = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost'; |
|
6422 | + } |
|
5654 | 6423 | return $this->unique_id; |
5655 | 6424 | break; |
5656 | 6425 | } |
@@ -5699,13 +6468,16 @@ discard block |
||
5699 | 6468 | $res = TRUE; |
5700 | 6469 | break; |
5701 | 6470 | } |
5702 | - if( !$res ) return FALSE; |
|
6471 | + if( !$res ) { |
|
6472 | + return FALSE; |
|
6473 | + } |
|
5703 | 6474 | if( isset( $subcfg ) && !empty( $this->components )) { |
5704 | 6475 | foreach( $subcfg as $cfgkey => $cfgvalue ) { |
5705 | 6476 | foreach( $this->components as $cix => $component ) { |
5706 | 6477 | $res = $component->setConfig( $cfgkey, $cfgvalue ); |
5707 | - if( !$res ) |
|
5708 | - break 2; |
|
6478 | + if( !$res ) { |
|
6479 | + break 2; |
|
6480 | + } |
|
5709 | 6481 | $this->components[$cix] = $component; // PHP4 compliant |
5710 | 6482 | } |
5711 | 6483 | } |
@@ -5723,12 +6495,15 @@ discard block |
||
5723 | 6495 | * @return bool, if successfull delete TRUE |
5724 | 6496 | */ |
5725 | 6497 | function deleteProperty( $propName, $propix=FALSE ) { |
5726 | - if( $this->_notExistProp( $propName )) return FALSE; |
|
6498 | + if( $this->_notExistProp( $propName )) { |
|
6499 | + return FALSE; |
|
6500 | + } |
|
5727 | 6501 | $propName = strtoupper( $propName ); |
5728 | 6502 | if( in_array( $propName, array( 'ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
5729 | 6503 | 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP' ))) { |
5730 | - if( !$propix ) |
|
5731 | - $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1; |
|
6504 | + if( !$propix ) { |
|
6505 | + $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1; |
|
6506 | + } |
|
5732 | 6507 | $this->propdelix[$propName] = --$propix; |
5733 | 6508 | } |
5734 | 6509 | $return = FALSE; |
@@ -5782,8 +6557,9 @@ discard block |
||
5782 | 6557 | } |
5783 | 6558 | break; |
5784 | 6559 | case 'DTSTAMP': |
5785 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
5786 | - return FALSE; |
|
6560 | + if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
6561 | + return FALSE; |
|
6562 | + } |
|
5787 | 6563 | if( !empty( $this->dtstamp )) { |
5788 | 6564 | $this->dtstamp = ''; |
5789 | 6565 | $return = TRUE; |
@@ -5937,8 +6713,9 @@ discard block |
||
5937 | 6713 | } |
5938 | 6714 | break; |
5939 | 6715 | case 'UID': |
5940 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
5941 | - return FALSE; |
|
6716 | + if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
6717 | + return FALSE; |
|
6718 | + } |
|
5942 | 6719 | if( !empty( $this->uid )) { |
5943 | 6720 | $this->uid = ''; |
5944 | 6721 | $return = TRUE; |
@@ -5953,18 +6730,23 @@ discard block |
||
5953 | 6730 | default: |
5954 | 6731 | $reduced = ''; |
5955 | 6732 | if( $propName != 'X-PROP' ) { |
5956 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
6733 | + if( !isset( $this->xprop[$propName] )) { |
|
6734 | + return FALSE; |
|
6735 | + } |
|
5957 | 6736 | foreach( $this->xprop as $k => $a ) { |
5958 | - if(( $k != $propName ) && !empty( $a )) |
|
5959 | - $reduced[$k] = $a; |
|
6737 | + if(( $k != $propName ) && !empty( $a )) { |
|
6738 | + $reduced[$k] = $a; |
|
6739 | + } |
|
6740 | + } |
|
6741 | + } else { |
|
6742 | + if( count( $this->xprop ) <= $propix ) { |
|
6743 | + return FALSE; |
|
5960 | 6744 | } |
5961 | - } |
|
5962 | - else { |
|
5963 | - if( count( $this->xprop ) <= $propix ) return FALSE; |
|
5964 | 6745 | $xpropno = 0; |
5965 | 6746 | foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
5966 | - if( $propix != $xpropno ) |
|
5967 | - $reduced[$xpropkey] = $xpropvalue; |
|
6747 | + if( $propix != $xpropno ) { |
|
6748 | + $reduced[$xpropkey] = $xpropvalue; |
|
6749 | + } |
|
5968 | 6750 | $xpropno++; |
5969 | 6751 | } |
5970 | 6752 | } |
@@ -5984,9 +6766,13 @@ discard block |
||
5984 | 6766 | * @return bool TRUE |
5985 | 6767 | */ |
5986 | 6768 | function deletePropertyM( & $multiprop, $propix=0 ) { |
5987 | - if( !isset( $multiprop[$propix])) return FALSE; |
|
6769 | + if( !isset( $multiprop[$propix])) { |
|
6770 | + return FALSE; |
|
6771 | + } |
|
5988 | 6772 | unset( $multiprop[$propix] ); |
5989 | - if( empty( $multiprop )) $multiprop = ''; |
|
6773 | + if( empty( $multiprop )) { |
|
6774 | + $multiprop = ''; |
|
6775 | + } |
|
5990 | 6776 | return ( isset( $this->multiprop[$propix] )) ? FALSE : TRUE; |
5991 | 6777 | } |
5992 | 6778 | /** |
@@ -6003,184 +6789,277 @@ discard block |
||
6003 | 6789 | * @return mixed |
6004 | 6790 | */ |
6005 | 6791 | function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE, $specform=FALSE ) { |
6006 | - if( $this->_notExistProp( $propName )) return FALSE; |
|
6792 | + if( $this->_notExistProp( $propName )) { |
|
6793 | + return FALSE; |
|
6794 | + } |
|
6007 | 6795 | $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP'; |
6008 | 6796 | if( in_array( $propName, array( 'ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
6009 | 6797 | 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP' ))) { |
6010 | - if( !$propix ) |
|
6011 | - $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; |
|
6798 | + if( !$propix ) { |
|
6799 | + $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; |
|
6800 | + } |
|
6012 | 6801 | $this->propix[$propName] = --$propix; |
6013 | 6802 | } |
6014 | 6803 | switch( $propName ) { |
6015 | 6804 | case 'ACTION': |
6016 | - if( !empty( $this->action['value'] )) return ( $inclParam ) ? $this->action : $this->action['value']; |
|
6805 | + if( !empty( $this->action['value'] )) { |
|
6806 | + return ( $inclParam ) ? $this->action : $this->action['value']; |
|
6807 | + } |
|
6017 | 6808 | break; |
6018 | 6809 | case 'ATTACH': |
6019 | - if( !isset( $this->attach[$propix] )) return FALSE; |
|
6810 | + if( !isset( $this->attach[$propix] )) { |
|
6811 | + return FALSE; |
|
6812 | + } |
|
6020 | 6813 | return ( $inclParam ) ? $this->attach[$propix] : $this->attach[$propix]['value']; |
6021 | 6814 | break; |
6022 | 6815 | case 'ATTENDEE': |
6023 | - if( !isset( $this->attendee[$propix] )) return FALSE; |
|
6816 | + if( !isset( $this->attendee[$propix] )) { |
|
6817 | + return FALSE; |
|
6818 | + } |
|
6024 | 6819 | return ( $inclParam ) ? $this->attendee[$propix] : $this->attendee[$propix]['value']; |
6025 | 6820 | break; |
6026 | 6821 | case 'CATEGORIES': |
6027 | - if( !isset( $this->categories[$propix] )) return FALSE; |
|
6822 | + if( !isset( $this->categories[$propix] )) { |
|
6823 | + return FALSE; |
|
6824 | + } |
|
6028 | 6825 | return ( $inclParam ) ? $this->categories[$propix] : $this->categories[$propix]['value']; |
6029 | 6826 | break; |
6030 | 6827 | case 'CLASS': |
6031 | - if( !empty( $this->class['value'] )) return ( $inclParam ) ? $this->class : $this->class['value']; |
|
6828 | + if( !empty( $this->class['value'] )) { |
|
6829 | + return ( $inclParam ) ? $this->class : $this->class['value']; |
|
6830 | + } |
|
6032 | 6831 | break; |
6033 | 6832 | case 'COMMENT': |
6034 | - if( !isset( $this->comment[$propix] )) return FALSE; |
|
6833 | + if( !isset( $this->comment[$propix] )) { |
|
6834 | + return FALSE; |
|
6835 | + } |
|
6035 | 6836 | return ( $inclParam ) ? $this->comment[$propix] : $this->comment[$propix]['value']; |
6036 | 6837 | break; |
6037 | 6838 | case 'COMPLETED': |
6038 | - if( !empty( $this->completed['value'] )) return ( $inclParam ) ? $this->completed : $this->completed['value']; |
|
6839 | + if( !empty( $this->completed['value'] )) { |
|
6840 | + return ( $inclParam ) ? $this->completed : $this->completed['value']; |
|
6841 | + } |
|
6039 | 6842 | break; |
6040 | 6843 | case 'CONTACT': |
6041 | - if( !isset( $this->contact[$propix] )) return FALSE; |
|
6844 | + if( !isset( $this->contact[$propix] )) { |
|
6845 | + return FALSE; |
|
6846 | + } |
|
6042 | 6847 | return ( $inclParam ) ? $this->contact[$propix] : $this->contact[$propix]['value']; |
6043 | 6848 | break; |
6044 | 6849 | case 'CREATED': |
6045 | - if( !empty( $this->created['value'] )) return ( $inclParam ) ? $this->created : $this->created['value']; |
|
6850 | + if( !empty( $this->created['value'] )) { |
|
6851 | + return ( $inclParam ) ? $this->created : $this->created['value']; |
|
6852 | + } |
|
6046 | 6853 | break; |
6047 | 6854 | case 'DESCRIPTION': |
6048 | - if( !isset( $this->description[$propix] )) return FALSE; |
|
6855 | + if( !isset( $this->description[$propix] )) { |
|
6856 | + return FALSE; |
|
6857 | + } |
|
6049 | 6858 | return ( $inclParam ) ? $this->description[$propix] : $this->description[$propix]['value']; |
6050 | 6859 | break; |
6051 | 6860 | case 'DTEND': |
6052 | - if( !empty( $this->dtend['value'] )) return ( $inclParam ) ? $this->dtend : $this->dtend['value']; |
|
6861 | + if( !empty( $this->dtend['value'] )) { |
|
6862 | + return ( $inclParam ) ? $this->dtend : $this->dtend['value']; |
|
6863 | + } |
|
6053 | 6864 | break; |
6054 | 6865 | case 'DTSTAMP': |
6055 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
6056 | - return; |
|
6057 | - if( !isset( $this->dtstamp['value'] )) |
|
6058 | - $this->_makeDtstamp(); |
|
6866 | + if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
6867 | + return; |
|
6868 | + } |
|
6869 | + if( !isset( $this->dtstamp['value'] )) { |
|
6870 | + $this->_makeDtstamp(); |
|
6871 | + } |
|
6059 | 6872 | return ( $inclParam ) ? $this->dtstamp : $this->dtstamp['value']; |
6060 | 6873 | break; |
6061 | 6874 | case 'DTSTART': |
6062 | - if( !empty( $this->dtstart['value'] )) return ( $inclParam ) ? $this->dtstart : $this->dtstart['value']; |
|
6875 | + if( !empty( $this->dtstart['value'] )) { |
|
6876 | + return ( $inclParam ) ? $this->dtstart : $this->dtstart['value']; |
|
6877 | + } |
|
6063 | 6878 | break; |
6064 | 6879 | case 'DUE': |
6065 | - if( !empty( $this->due['value'] )) return ( $inclParam ) ? $this->due : $this->due['value']; |
|
6880 | + if( !empty( $this->due['value'] )) { |
|
6881 | + return ( $inclParam ) ? $this->due : $this->due['value']; |
|
6882 | + } |
|
6066 | 6883 | break; |
6067 | 6884 | case 'DURATION': |
6068 | - if( !isset( $this->duration['value'] )) return FALSE; |
|
6885 | + if( !isset( $this->duration['value'] )) { |
|
6886 | + return FALSE; |
|
6887 | + } |
|
6069 | 6888 | $value = ( $specform ) ? $this->duration2date() : $this->duration['value']; |
6070 | 6889 | return ( $inclParam ) ? array( 'value' => $value, 'params' => $this->duration['params'] ) : $value; |
6071 | 6890 | break; |
6072 | 6891 | case 'EXDATE': |
6073 | - if( !isset( $this->exdate[$propix] )) return FALSE; |
|
6892 | + if( !isset( $this->exdate[$propix] )) { |
|
6893 | + return FALSE; |
|
6894 | + } |
|
6074 | 6895 | return ( $inclParam ) ? $this->exdate[$propix] : $this->exdate[$propix]['value']; |
6075 | 6896 | break; |
6076 | 6897 | case 'EXRULE': |
6077 | - if( !isset( $this->exrule[$propix] )) return FALSE; |
|
6898 | + if( !isset( $this->exrule[$propix] )) { |
|
6899 | + return FALSE; |
|
6900 | + } |
|
6078 | 6901 | return ( $inclParam ) ? $this->exrule[$propix] : $this->exrule[$propix]['value']; |
6079 | 6902 | break; |
6080 | 6903 | case 'FREEBUSY': |
6081 | - if( !isset( $this->freebusy[$propix] )) return FALSE; |
|
6904 | + if( !isset( $this->freebusy[$propix] )) { |
|
6905 | + return FALSE; |
|
6906 | + } |
|
6082 | 6907 | return ( $inclParam ) ? $this->freebusy[$propix] : $this->freebusy[$propix]['value']; |
6083 | 6908 | break; |
6084 | 6909 | case 'GEO': |
6085 | - if( !empty( $this->geo['value'] )) return ( $inclParam ) ? $this->geo : $this->geo['value']; |
|
6910 | + if( !empty( $this->geo['value'] )) { |
|
6911 | + return ( $inclParam ) ? $this->geo : $this->geo['value']; |
|
6912 | + } |
|
6086 | 6913 | break; |
6087 | 6914 | case 'LAST-MODIFIED': |
6088 | - if( !empty( $this->lastmodified['value'] )) return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value']; |
|
6915 | + if( !empty( $this->lastmodified['value'] )) { |
|
6916 | + return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value']; |
|
6917 | + } |
|
6089 | 6918 | break; |
6090 | 6919 | case 'LOCATION': |
6091 | - if( !empty( $this->location['value'] )) return ( $inclParam ) ? $this->location : $this->location['value']; |
|
6920 | + if( !empty( $this->location['value'] )) { |
|
6921 | + return ( $inclParam ) ? $this->location : $this->location['value']; |
|
6922 | + } |
|
6092 | 6923 | break; |
6093 | 6924 | case 'ORGANIZER': |
6094 | - if( !empty( $this->organizer['value'] )) return ( $inclParam ) ? $this->organizer : $this->organizer['value']; |
|
6925 | + if( !empty( $this->organizer['value'] )) { |
|
6926 | + return ( $inclParam ) ? $this->organizer : $this->organizer['value']; |
|
6927 | + } |
|
6095 | 6928 | break; |
6096 | 6929 | case 'PERCENT-COMPLETE': |
6097 | - if( !empty( $this->percentcomplete['value'] )) return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value']; |
|
6930 | + if( !empty( $this->percentcomplete['value'] )) { |
|
6931 | + return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value']; |
|
6932 | + } |
|
6098 | 6933 | break; |
6099 | 6934 | case 'PRIORITY': |
6100 | - if( !empty( $this->priority['value'] )) return ( $inclParam ) ? $this->priority : $this->priority['value']; |
|
6935 | + if( !empty( $this->priority['value'] )) { |
|
6936 | + return ( $inclParam ) ? $this->priority : $this->priority['value']; |
|
6937 | + } |
|
6101 | 6938 | break; |
6102 | 6939 | case 'RDATE': |
6103 | - if( !isset( $this->rdate[$propix] )) return FALSE; |
|
6940 | + if( !isset( $this->rdate[$propix] )) { |
|
6941 | + return FALSE; |
|
6942 | + } |
|
6104 | 6943 | return ( $inclParam ) ? $this->rdate[$propix] : $this->rdate[$propix]['value']; |
6105 | 6944 | break; |
6106 | 6945 | case 'RECURRENCE-ID': |
6107 | - if( !empty( $this->recurrenceid['value'] )) return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value']; |
|
6946 | + if( !empty( $this->recurrenceid['value'] )) { |
|
6947 | + return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value']; |
|
6948 | + } |
|
6108 | 6949 | break; |
6109 | 6950 | case 'RELATED-TO': |
6110 | - if( !isset( $this->relatedto[$propix] )) return FALSE; |
|
6951 | + if( !isset( $this->relatedto[$propix] )) { |
|
6952 | + return FALSE; |
|
6953 | + } |
|
6111 | 6954 | return ( $inclParam ) ? $this->relatedto[$propix] : $this->relatedto[$propix]['value']; |
6112 | 6955 | break; |
6113 | 6956 | case 'REPEAT': |
6114 | - if( !empty( $this->repeat['value'] )) return ( $inclParam ) ? $this->repeat : $this->repeat['value']; |
|
6957 | + if( !empty( $this->repeat['value'] )) { |
|
6958 | + return ( $inclParam ) ? $this->repeat : $this->repeat['value']; |
|
6959 | + } |
|
6115 | 6960 | break; |
6116 | 6961 | case 'REQUEST-STATUS': |
6117 | - if( !isset( $this->requeststatus[$propix] )) return FALSE; |
|
6962 | + if( !isset( $this->requeststatus[$propix] )) { |
|
6963 | + return FALSE; |
|
6964 | + } |
|
6118 | 6965 | return ( $inclParam ) ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value']; |
6119 | 6966 | break; |
6120 | 6967 | case 'RESOURCES': |
6121 | - if( !isset( $this->resources[$propix] )) return FALSE; |
|
6968 | + if( !isset( $this->resources[$propix] )) { |
|
6969 | + return FALSE; |
|
6970 | + } |
|
6122 | 6971 | return ( $inclParam ) ? $this->resources[$propix] : $this->resources[$propix]['value']; |
6123 | 6972 | break; |
6124 | 6973 | case 'RRULE': |
6125 | - if( !isset( $this->rrule[$propix] )) return FALSE; |
|
6974 | + if( !isset( $this->rrule[$propix] )) { |
|
6975 | + return FALSE; |
|
6976 | + } |
|
6126 | 6977 | return ( $inclParam ) ? $this->rrule[$propix] : $this->rrule[$propix]['value']; |
6127 | 6978 | break; |
6128 | 6979 | case 'SEQUENCE': |
6129 | - if( !empty( $this->sequence['value'] )) return ( $inclParam ) ? $this->sequence : $this->sequence['value']; |
|
6980 | + if( !empty( $this->sequence['value'] )) { |
|
6981 | + return ( $inclParam ) ? $this->sequence : $this->sequence['value']; |
|
6982 | + } |
|
6130 | 6983 | break; |
6131 | 6984 | case 'STATUS': |
6132 | - if( !empty( $this->status['value'] )) return ( $inclParam ) ? $this->status : $this->status['value']; |
|
6985 | + if( !empty( $this->status['value'] )) { |
|
6986 | + return ( $inclParam ) ? $this->status : $this->status['value']; |
|
6987 | + } |
|
6133 | 6988 | break; |
6134 | 6989 | case 'SUMMARY': |
6135 | - if( !empty( $this->summary['value'] )) return ( $inclParam ) ? $this->summary : $this->summary['value']; |
|
6990 | + if( !empty( $this->summary['value'] )) { |
|
6991 | + return ( $inclParam ) ? $this->summary : $this->summary['value']; |
|
6992 | + } |
|
6136 | 6993 | break; |
6137 | 6994 | case 'TRANSP': |
6138 | - if( !empty( $this->transp['value'] )) return ( $inclParam ) ? $this->transp : $this->transp['value']; |
|
6995 | + if( !empty( $this->transp['value'] )) { |
|
6996 | + return ( $inclParam ) ? $this->transp : $this->transp['value']; |
|
6997 | + } |
|
6139 | 6998 | break; |
6140 | 6999 | case 'TRIGGER': |
6141 | - if( !empty( $this->trigger['value'] )) return ( $inclParam ) ? $this->trigger : $this->trigger['value']; |
|
7000 | + if( !empty( $this->trigger['value'] )) { |
|
7001 | + return ( $inclParam ) ? $this->trigger : $this->trigger['value']; |
|
7002 | + } |
|
6142 | 7003 | break; |
6143 | 7004 | case 'TZID': |
6144 | - if( !empty( $this->tzid['value'] )) return ( $inclParam ) ? $this->tzid : $this->tzid['value']; |
|
7005 | + if( !empty( $this->tzid['value'] )) { |
|
7006 | + return ( $inclParam ) ? $this->tzid : $this->tzid['value']; |
|
7007 | + } |
|
6145 | 7008 | break; |
6146 | 7009 | case 'TZNAME': |
6147 | - if( !isset( $this->tzname[$propix] )) return FALSE; |
|
7010 | + if( !isset( $this->tzname[$propix] )) { |
|
7011 | + return FALSE; |
|
7012 | + } |
|
6148 | 7013 | return ( $inclParam ) ? $this->tzname[$propix] : $this->tzname[$propix]['value']; |
6149 | 7014 | break; |
6150 | 7015 | case 'TZOFFSETFROM': |
6151 | - if( !empty( $this->tzoffsetfrom['value'] )) return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value']; |
|
7016 | + if( !empty( $this->tzoffsetfrom['value'] )) { |
|
7017 | + return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value']; |
|
7018 | + } |
|
6152 | 7019 | break; |
6153 | 7020 | case 'TZOFFSETTO': |
6154 | - if( !empty( $this->tzoffsetto['value'] )) return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value']; |
|
7021 | + if( !empty( $this->tzoffsetto['value'] )) { |
|
7022 | + return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value']; |
|
7023 | + } |
|
6155 | 7024 | break; |
6156 | 7025 | case 'TZURL': |
6157 | - if( !empty( $this->tzurl['value'] )) return ( $inclParam ) ? $this->tzurl : $this->tzurl['value']; |
|
7026 | + if( !empty( $this->tzurl['value'] )) { |
|
7027 | + return ( $inclParam ) ? $this->tzurl : $this->tzurl['value']; |
|
7028 | + } |
|
6158 | 7029 | break; |
6159 | 7030 | case 'UID': |
6160 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
6161 | - return FALSE; |
|
6162 | - if( empty( $this->uid['value'] )) |
|
6163 | - $this->_makeuid(); |
|
7031 | + if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
7032 | + return FALSE; |
|
7033 | + } |
|
7034 | + if( empty( $this->uid['value'] )) { |
|
7035 | + $this->_makeuid(); |
|
7036 | + } |
|
6164 | 7037 | return ( $inclParam ) ? $this->uid : $this->uid['value']; |
6165 | 7038 | break; |
6166 | 7039 | case 'URL': |
6167 | - if( !empty( $this->url['value'] )) return ( $inclParam ) ? $this->url : $this->url['value']; |
|
7040 | + if( !empty( $this->url['value'] )) { |
|
7041 | + return ( $inclParam ) ? $this->url : $this->url['value']; |
|
7042 | + } |
|
6168 | 7043 | break; |
6169 | 7044 | default: |
6170 | 7045 | if( $propName != 'X-PROP' ) { |
6171 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
7046 | + if( !isset( $this->xprop[$propName] )) { |
|
7047 | + return FALSE; |
|
7048 | + } |
|
6172 | 7049 | return ( $inclParam ) ? array( $propName, $this->xprop[$propName] ) |
6173 | 7050 | : array( $propName, $this->xprop[$propName]['value'] ); |
6174 | - } |
|
6175 | - else { |
|
6176 | - if( empty( $this->xprop )) return FALSE; |
|
7051 | + } else { |
|
7052 | + if( empty( $this->xprop )) { |
|
7053 | + return FALSE; |
|
7054 | + } |
|
6177 | 7055 | $xpropno = 0; |
6178 | 7056 | foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
6179 | - if( $propix == $xpropno ) |
|
6180 | - return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) |
|
7057 | + if( $propix == $xpropno ) { |
|
7058 | + return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) |
|
6181 | 7059 | : array( $xpropkey, $this->xprop[$xpropkey]['value'] ); |
6182 | - else |
|
6183 | - $xpropno++; |
|
7060 | + } else { |
|
7061 | + $xpropno++; |
|
7062 | + } |
|
6184 | 7063 | } |
6185 | 7064 | return FALSE; // not found ?? |
6186 | 7065 | } |
@@ -6199,15 +7078,21 @@ discard block |
||
6199 | 7078 | */ |
6200 | 7079 | function setProperty() { |
6201 | 7080 | $numargs = func_num_args(); |
6202 | - if( 1 > $numargs ) return FALSE; |
|
7081 | + if( 1 > $numargs ) { |
|
7082 | + return FALSE; |
|
7083 | + } |
|
6203 | 7084 | $arglist = func_get_args(); |
6204 | - if( $this->_notExistProp( $arglist[0] )) return FALSE; |
|
6205 | - if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] ))) |
|
7085 | + if( $this->_notExistProp( $arglist[0] )) { |
|
6206 | 7086 | return FALSE; |
7087 | + } |
|
7088 | + if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] ))) { |
|
7089 | + return FALSE; |
|
7090 | + } |
|
6207 | 7091 | $arglist[0] = strtoupper( $arglist[0] ); |
6208 | 7092 | for( $argix=$numargs; $argix < 12; $argix++ ) { |
6209 | - if( !isset( $arglist[$argix] )) |
|
6210 | - $arglist[$argix] = null; |
|
7093 | + if( !isset( $arglist[$argix] )) { |
|
7094 | + $arglist[$argix] = null; |
|
7095 | + } |
|
6211 | 7096 | } |
6212 | 7097 | switch( $arglist[0] ) { |
6213 | 7098 | case 'ACTION': |
@@ -6321,20 +7206,19 @@ discard block |
||
6321 | 7206 | $this->setComponent( $comp ); |
6322 | 7207 | $comp = & $this; |
6323 | 7208 | continue; |
6324 | - } |
|
6325 | - elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) { |
|
7209 | + } elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) { |
|
6326 | 7210 | $comp = new valarm(); |
6327 | 7211 | continue; |
7212 | + } else { |
|
7213 | + $comp->unparsed[] = $line; |
|
6328 | 7214 | } |
6329 | - else |
|
6330 | - $comp->unparsed[] = $line; |
|
6331 | 7215 | } |
7216 | + } else { |
|
7217 | + $this->unparsed = array( trim( $unparsedtext )); |
|
6332 | 7218 | } |
6333 | - else |
|
6334 | - $this->unparsed = array( trim( $unparsedtext )); |
|
7219 | + } elseif( !isset( $this->unparsed )) { |
|
7220 | + $this->unparsed = array(); |
|
6335 | 7221 | } |
6336 | - elseif( !isset( $this->unparsed )) |
|
6337 | - $this->unparsed = array(); |
|
6338 | 7222 | /* concatenate property values spread over several lines */ |
6339 | 7223 | $lastix = -1; |
6340 | 7224 | $propnames = array( 'action', 'attach', 'attendee', 'categories', 'comment', 'completed' |
@@ -6358,8 +7242,7 @@ discard block |
||
6358 | 7242 | $newProp = FALSE; |
6359 | 7243 | $lastix++; |
6360 | 7244 | $proprows[$lastix] = $line; |
6361 | - } |
|
6362 | - else { |
|
7245 | + } else { |
|
6363 | 7246 | /* remove line breaks */ |
6364 | 7247 | if(( '\n' == substr( $proprows[$lastix], -2 )) && |
6365 | 7248 | ( ' ' == substr( $line, 0, 1 ))) { |
@@ -6372,14 +7255,15 @@ discard block |
||
6372 | 7255 | /* parse each property 'line' */ |
6373 | 7256 | foreach( $proprows as $line ) { |
6374 | 7257 | $line = str_replace( "\n ", '', $line ); |
6375 | - if( '\n' == substr( $line, -2 )) |
|
6376 | - $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
7258 | + if( '\n' == substr( $line, -2 )) { |
|
7259 | + $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
7260 | + } |
|
6377 | 7261 | /* get propname, (problem with x-properties, otherwise in previous loop) */ |
6378 | 7262 | $cix = $propname = null; |
6379 | 7263 | for( $cix=0; $cix < strlen( $line ); $cix++ ) { |
6380 | - if( in_array( $line{$cix}, array( ':', ';' ))) |
|
6381 | - break; |
|
6382 | - else { |
|
7264 | + if( in_array( $line{$cix}, array( ':', ';' ))) { |
|
7265 | + break; |
|
7266 | + } else { |
|
6383 | 7267 | $propname .= $line{$cix}; |
6384 | 7268 | } |
6385 | 7269 | } |
@@ -6412,27 +7296,30 @@ discard block |
||
6412 | 7296 | break; |
6413 | 7297 | } |
6414 | 7298 | } |
6415 | - if( ';' == $line{$cix} ) |
|
6416 | - $attr[++$attrix] = null; |
|
6417 | - else |
|
6418 | - $attr[$attrix] .= $line{$cix}; |
|
7299 | + if( ';' == $line{$cix} ) { |
|
7300 | + $attr[++$attrix] = null; |
|
7301 | + } else { |
|
7302 | + $attr[$attrix] .= $line{$cix}; |
|
7303 | + } |
|
6419 | 7304 | } |
6420 | 7305 | /* make attributes in array format */ |
6421 | 7306 | $propattr = array(); |
6422 | 7307 | foreach( $attr as $attribute ) { |
6423 | 7308 | $attrsplit = explode( '=', $attribute, 2 ); |
6424 | - if( 1 < count( $attrsplit )) |
|
6425 | - $propattr[$attrsplit[0]] = $attrsplit[1]; |
|
6426 | - else |
|
6427 | - $propattr[] = $attribute; |
|
7309 | + if( 1 < count( $attrsplit )) { |
|
7310 | + $propattr[$attrsplit[0]] = $attrsplit[1]; |
|
7311 | + } else { |
|
7312 | + $propattr[] = $attribute; |
|
7313 | + } |
|
6428 | 7314 | } |
6429 | 7315 | /* call setProperty( $propname.. . */ |
6430 | 7316 | switch( $propname ) { |
6431 | 7317 | case 'ATTENDEE': |
6432 | 7318 | foreach( $propattr as $pix => $attr ) { |
6433 | 7319 | $attr2 = explode( ',', $attr ); |
6434 | - if( 1 < count( $attr2 )) |
|
6435 | - $propattr[$pix] = $attr2; |
|
7320 | + if( 1 < count( $attr2 )) { |
|
7321 | + $propattr[$pix] = $attr2; |
|
7322 | + } |
|
6436 | 7323 | } |
6437 | 7324 | $this->setProperty( $propname, $line, $propattr ); |
6438 | 7325 | break; |
@@ -6450,13 +7337,14 @@ discard block |
||
6450 | 7337 | } |
6451 | 7338 | if( 1 < count( $content )) { |
6452 | 7339 | $content = array_values( $content ); |
6453 | - foreach( $content as $cix => $contentPart ) |
|
6454 | - $content[$cix] = $this->_strunrep( $contentPart ); |
|
7340 | + foreach( $content as $cix => $contentPart ) { |
|
7341 | + $content[$cix] = $this->_strunrep( $contentPart ); |
|
7342 | + } |
|
6455 | 7343 | $this->setProperty( $propname, $content, $propattr ); |
6456 | 7344 | break; |
7345 | + } else { |
|
7346 | + $line = reset( $content ); |
|
6457 | 7347 | } |
6458 | - else |
|
6459 | - $line = reset( $content ); |
|
6460 | 7348 | } |
6461 | 7349 | //no break |
6462 | 7350 | case 'X-': |
@@ -6467,8 +7355,9 @@ discard block |
||
6467 | 7355 | case 'DESCRIPTION': |
6468 | 7356 | case 'LOCATION': |
6469 | 7357 | case 'SUMMARY': |
6470 | - if( empty( $line )) |
|
6471 | - $propattr = null; |
|
7358 | + if( empty( $line )) { |
|
7359 | + $propattr = null; |
|
7360 | + } |
|
6472 | 7361 | $this->setProperty( $propname, $this->_strunrep( $line ), $propattr ); |
6473 | 7362 | unset( $propname2 ); |
6474 | 7363 | break; |
@@ -6488,15 +7377,17 @@ discard block |
||
6488 | 7377 | $values = explode( ',', $line ); |
6489 | 7378 | foreach( $values as $vix => $value ) { |
6490 | 7379 | $value2 = explode( '/', $value ); |
6491 | - if( 1 < count( $value2 )) |
|
6492 | - $values[$vix] = $value2; |
|
7380 | + if( 1 < count( $value2 )) { |
|
7381 | + $values[$vix] = $value2; |
|
7382 | + } |
|
6493 | 7383 | } |
6494 | 7384 | $this->setProperty( $propname, $fbtype, $values, $propattr ); |
6495 | 7385 | break; |
6496 | 7386 | case 'GEO': |
6497 | 7387 | $value = explode( ';', $line, 2 ); |
6498 | - if( 2 > count( $value )) |
|
6499 | - $value[1] = null; |
|
7388 | + if( 2 > count( $value )) { |
|
7389 | + $value[1] = null; |
|
7390 | + } |
|
6500 | 7391 | $this->setProperty( $propname, $value[0], $value[1], $propattr ); |
6501 | 7392 | break; |
6502 | 7393 | case 'EXDATE': |
@@ -6511,8 +7402,9 @@ discard block |
||
6511 | 7402 | $values = explode( ',', $line ); |
6512 | 7403 | foreach( $values as $vix => $value ) { |
6513 | 7404 | $value2 = explode( '/', $value ); |
6514 | - if( 1 < count( $value2 )) |
|
6515 | - $values[$vix] = $value2; |
|
7405 | + if( 1 < count( $value2 )) { |
|
7406 | + $values[$vix] = $value2; |
|
7407 | + } |
|
6516 | 7408 | } |
6517 | 7409 | $this->setProperty( $propname, $values, $propattr ); |
6518 | 7410 | break; |
@@ -6521,8 +7413,10 @@ discard block |
||
6521 | 7413 | $values = explode( ';', $line ); |
6522 | 7414 | $recur = array(); |
6523 | 7415 | foreach( $values as $value2 ) { |
6524 | - if( empty( $value2 )) |
|
6525 | - continue; // ;-char in ending position ??? |
|
7416 | + if( empty( $value2 )) { |
|
7417 | + continue; |
|
7418 | + } |
|
7419 | + // ;-char in ending position ??? |
|
6526 | 7420 | $value3 = explode( '=', $value2, 2 ); |
6527 | 7421 | $rulelabel = strtoupper( $value3[0] ); |
6528 | 7422 | switch( $rulelabel ) { |
@@ -6536,37 +7430,43 @@ discard block |
||
6536 | 7430 | if(( ctype_alpha( substr( $value5, -1 ))) && |
6537 | 7431 | ( ctype_alpha( substr( $value5, -2, 1 )))) { |
6538 | 7432 | $dayname = substr( $value5, -2, 2 ); |
6539 | - if( 2 < strlen( $value5 )) |
|
6540 | - $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
7433 | + if( 2 < strlen( $value5 )) { |
|
7434 | + $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
7435 | + } |
|
7436 | + } |
|
7437 | + if( $dayno ) { |
|
7438 | + $value6[] = $dayno; |
|
7439 | + } |
|
7440 | + if( $dayname ) { |
|
7441 | + $value6['DAY'] = $dayname; |
|
6541 | 7442 | } |
6542 | - if( $dayno ) |
|
6543 | - $value6[] = $dayno; |
|
6544 | - if( $dayname ) |
|
6545 | - $value6['DAY'] = $dayname; |
|
6546 | 7443 | $value4[$v5ix] = $value6; |
6547 | 7444 | } |
6548 | - } |
|
6549 | - else { |
|
7445 | + } else { |
|
6550 | 7446 | $value4 = array(); |
6551 | 7447 | $dayno = $dayname = null; |
6552 | 7448 | $value5 = trim( (string) $value3[1] ); |
6553 | 7449 | if(( ctype_alpha( substr( $value5, -1 ))) && |
6554 | 7450 | ( ctype_alpha( substr( $value5, -2, 1 )))) { |
6555 | 7451 | $dayname = substr( $value5, -2, 2 ); |
6556 | - if( 2 < strlen( $value5 )) |
|
6557 | - $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
7452 | + if( 2 < strlen( $value5 )) { |
|
7453 | + $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
7454 | + } |
|
7455 | + } |
|
7456 | + if( $dayno ) { |
|
7457 | + $value4[] = $dayno; |
|
7458 | + } |
|
7459 | + if( $dayname ) { |
|
7460 | + $value4['DAY'] = $dayname; |
|
6558 | 7461 | } |
6559 | - if( $dayno ) |
|
6560 | - $value4[] = $dayno; |
|
6561 | - if( $dayname ) |
|
6562 | - $value4['DAY'] = $dayname; |
|
6563 | 7462 | } |
6564 | 7463 | $recur[$rulelabel] = $value4; |
6565 | 7464 | break; |
6566 | 7465 | default: |
6567 | 7466 | $value4 = explode( ',', $value3[1] ); |
6568 | - if( 1 < count( $value4 )) |
|
6569 | - $value3[1] = $value4; |
|
7467 | + if( 1 < count( $value4 )) { |
|
7468 | + $value3[1] = $value4; |
|
7469 | + } |
|
6570 | 7470 | $recur[$rulelabel] = $value3[1]; |
6571 | 7471 | break; |
6572 | 7472 | } // end - switch $rulelabel |
@@ -6581,8 +7481,9 @@ discard block |
||
6581 | 7481 | unset( $this->unparsed, $proprows ); |
6582 | 7482 | if( isset( $this->components ) && is_array( $this->components ) && ( 0 < count( $this->components ))) { |
6583 | 7483 | for( $six = 0; $six < count( $this->components ); $six++ ) { |
6584 | - if( !empty( $this->components[$six]->unparsed )) |
|
6585 | - $this->components[$six]->parse(); |
|
7484 | + if( !empty( $this->components[$six]->unparsed )) { |
|
7485 | + $this->components[$six]->parse(); |
|
7486 | + } |
|
6586 | 7487 | } |
6587 | 7488 | } |
6588 | 7489 | } |
@@ -6613,32 +7514,33 @@ discard block |
||
6613 | 7514 | * @return void |
6614 | 7515 | */ |
6615 | 7516 | function deleteComponent( $arg1, $arg2=FALSE ) { |
6616 | - if( !isset( $this->components )) return FALSE; |
|
7517 | + if( !isset( $this->components )) { |
|
7518 | + return FALSE; |
|
7519 | + } |
|
6617 | 7520 | $argType = $index = null; |
6618 | 7521 | if ( ctype_digit( (string) $arg1 )) { |
6619 | 7522 | $argType = 'INDEX'; |
6620 | 7523 | $index = (int) $arg1 - 1; |
6621 | - } |
|
6622 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
7524 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6623 | 7525 | $argType = strtolower( $arg1 ); |
6624 | 7526 | $index = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0; |
6625 | 7527 | } |
6626 | 7528 | $cix2dC = 0; |
6627 | 7529 | foreach ( $this->components as $cix => $component) { |
6628 | - if( empty( $component )) continue; |
|
7530 | + if( empty( $component )) { |
|
7531 | + continue; |
|
7532 | + } |
|
6629 | 7533 | unset( $component->propix ); |
6630 | 7534 | if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
6631 | 7535 | unset( $this->components[$cix] ); |
6632 | 7536 | return TRUE; |
6633 | - } |
|
6634 | - elseif( $argType == $component->objName ) { |
|
7537 | + } elseif( $argType == $component->objName ) { |
|
6635 | 7538 | if( $index == $cix2dC ) { |
6636 | 7539 | unset( $this->components[$cix] ); |
6637 | 7540 | return TRUE; |
6638 | 7541 | } |
6639 | 7542 | $cix2dC++; |
6640 | - } |
|
6641 | - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
7543 | + } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
6642 | 7544 | unset( $this->components[$cix] ); |
6643 | 7545 | return TRUE; |
6644 | 7546 | } |
@@ -6655,43 +7557,47 @@ discard block |
||
6655 | 7557 | * @return object |
6656 | 7558 | */ |
6657 | 7559 | function getComponent ( $arg1=FALSE, $arg2=FALSE ) { |
6658 | - if( !isset( $this->components )) return FALSE; |
|
7560 | + if( !isset( $this->components )) { |
|
7561 | + return FALSE; |
|
7562 | + } |
|
6659 | 7563 | $index = $argType = null; |
6660 | 7564 | if ( !$arg1 ) { |
6661 | 7565 | $argType = 'INDEX'; |
6662 | 7566 | $index = $this->compix['INDEX'] = |
6663 | 7567 | ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1; |
6664 | - } |
|
6665 | - elseif ( ctype_digit( (string) $arg1 )) { |
|
7568 | + } elseif ( ctype_digit( (string) $arg1 )) { |
|
6666 | 7569 | $argType = 'INDEX'; |
6667 | 7570 | $index = (int) $arg1; |
6668 | 7571 | unset( $this->compix ); |
6669 | - } |
|
6670 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
7572 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6671 | 7573 | unset( $this->compix['INDEX'] ); |
6672 | 7574 | $argType = strtolower( $arg1 ); |
6673 | - if( !$arg2 ) |
|
6674 | - $index = $this->compix[$argType] = |
|
7575 | + if( !$arg2 ) { |
|
7576 | + $index = $this->compix[$argType] = |
|
6675 | 7577 | ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1; |
6676 | - else |
|
6677 | - $index = (int) $arg2; |
|
7578 | + } else { |
|
7579 | + $index = (int) $arg2; |
|
7580 | + } |
|
6678 | 7581 | } |
6679 | 7582 | $index -= 1; |
6680 | 7583 | $ckeys = array_keys( $this->components ); |
6681 | - if( !empty( $index) && ( $index > end( $ckeys ))) |
|
6682 | - return FALSE; |
|
7584 | + if( !empty( $index) && ( $index > end( $ckeys ))) { |
|
7585 | + return FALSE; |
|
7586 | + } |
|
6683 | 7587 | $cix2gC = 0; |
6684 | 7588 | foreach( $this->components as $cix => $component ) { |
6685 | - if( empty( $component )) continue; |
|
7589 | + if( empty( $component )) { |
|
7590 | + continue; |
|
7591 | + } |
|
6686 | 7592 | unset( $component->propix ); |
6687 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) |
|
6688 | - return $component->copy(); |
|
6689 | - elseif( $argType == $component->objName ) { |
|
6690 | - if( $index == $cix2gC ) |
|
6691 | - return $component->copy(); |
|
7593 | + if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
|
7594 | + return $component->copy(); |
|
7595 | + } elseif( $argType == $component->objName ) { |
|
7596 | + if( $index == $cix2gC ) { |
|
7597 | + return $component->copy(); |
|
7598 | + } |
|
6692 | 7599 | $cix2gC++; |
6693 | - } |
|
6694 | - elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) { |
|
7600 | + } elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) { |
|
6695 | 7601 | unset( $component->propix ); |
6696 | 7602 | return $component->copy(); |
6697 | 7603 | } |
@@ -6722,9 +7628,12 @@ discard block |
||
6722 | 7628 | * @return bool |
6723 | 7629 | */ |
6724 | 7630 | function setComponent( $component, $arg1=FALSE, $arg2=FALSE ) { |
6725 | - if( !isset( $this->components )) return FALSE; |
|
6726 | - if( '' >= $component->getConfig( 'language')) |
|
6727 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
7631 | + if( !isset( $this->components )) { |
|
7632 | + return FALSE; |
|
7633 | + } |
|
7634 | + if( '' >= $component->getConfig( 'language')) { |
|
7635 | + $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
7636 | + } |
|
6728 | 7637 | $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
6729 | 7638 | $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
6730 | 7639 | $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
@@ -6743,27 +7652,26 @@ discard block |
||
6743 | 7652 | if ( ctype_digit( (string) $arg1 )) { |
6744 | 7653 | $argType = 'INDEX'; |
6745 | 7654 | $index = (int) $arg1 - 1; |
6746 | - } |
|
6747 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
7655 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6748 | 7656 | $argType = strtolower( $arg1 ); |
6749 | 7657 | $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0; |
6750 | 7658 | } |
6751 | 7659 | $cix2sC = 0; |
6752 | 7660 | foreach ( $this->components as $cix => $component2 ) { |
6753 | - if( empty( $component2 )) continue; |
|
7661 | + if( empty( $component2 )) { |
|
7662 | + continue; |
|
7663 | + } |
|
6754 | 7664 | unset( $component2->propix ); |
6755 | 7665 | if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
6756 | 7666 | $this->components[$cix] = $component->copy(); |
6757 | 7667 | return TRUE; |
6758 | - } |
|
6759 | - elseif( $argType == $component2->objName ) { |
|
7668 | + } elseif( $argType == $component2->objName ) { |
|
6760 | 7669 | if( $index == $cix2sC ) { |
6761 | 7670 | $this->components[$cix] = $component->copy(); |
6762 | 7671 | return TRUE; |
6763 | 7672 | } |
6764 | 7673 | $cix2sC++; |
6765 | - } |
|
6766 | - elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) { |
|
7674 | + } elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) { |
|
6767 | 7675 | $this->components[$cix] = $component->copy(); |
6768 | 7676 | return TRUE; |
6769 | 7677 | } |
@@ -6782,9 +7690,12 @@ discard block |
||
6782 | 7690 | function createSubComponent() { |
6783 | 7691 | $output = null; |
6784 | 7692 | foreach( $this->components as $component ) { |
6785 | - if( empty( $component )) continue; |
|
6786 | - if( '' >= $component->getConfig( 'language')) |
|
6787 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
7693 | + if( empty( $component )) { |
|
7694 | + continue; |
|
7695 | + } |
|
7696 | + if( '' >= $component->getConfig( 'language')) { |
|
7697 | + $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
7698 | + } |
|
6788 | 7699 | $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
6789 | 7700 | $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
6790 | 7701 | $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
@@ -6822,16 +7733,18 @@ discard block |
||
6822 | 7733 | $string = null; |
6823 | 7734 | while( $strlen > 75 ) { |
6824 | 7735 | $breakAtChar = 75; |
6825 | - if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' ) |
|
6826 | - $breakAtChar = $breakAtChar - 1; |
|
7736 | + if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' ) { |
|
7737 | + $breakAtChar = $breakAtChar - 1; |
|
7738 | + } |
|
6827 | 7739 | $string .= substr( $tmp, 0, $breakAtChar ); |
6828 | 7740 | $string .= $this->nl; |
6829 | 7741 | $tmp = ' '.substr( $tmp, $breakAtChar ); |
6830 | 7742 | $strlen = strlen( $tmp ); |
6831 | 7743 | } // while |
6832 | 7744 | $string .= rtrim( $tmp ); // the rest |
6833 | - if( $this->nl != substr( $string, ( 0 - strlen( $this->nl )))) |
|
6834 | - $string .= $this->nl; |
|
7745 | + if( $this->nl != substr( $string, ( 0 - strlen( $this->nl )))) { |
|
7746 | + $string .= $this->nl; |
|
7747 | + } |
|
6835 | 7748 | return $string; |
6836 | 7749 | } |
6837 | 7750 | /** |
@@ -6852,27 +7765,33 @@ discard block |
||
6852 | 7765 | $pos = 0; |
6853 | 7766 | while( $pos <= strlen( $string )) { |
6854 | 7767 | $pos = strpos( $string, "\\", $pos ); |
6855 | - if( FALSE === $pos ) |
|
6856 | - break; |
|
7768 | + if( FALSE === $pos ) { |
|
7769 | + break; |
|
7770 | + } |
|
6857 | 7771 | if( !in_array( $string{($pos + 1)}, array( 'n', 'N', 'r', ',', ';' ))) { |
6858 | 7772 | $string = substr( $string, 0, $pos )."\\".substr( $string, ( $pos + 1 )); |
6859 | 7773 | $pos += 1; |
6860 | 7774 | } |
6861 | 7775 | $pos += 1; |
6862 | 7776 | } |
6863 | - if( FALSE !== strpos( $string, '"' )) |
|
6864 | - $string = str_replace('"', "'", $string); |
|
6865 | - if( FALSE !== strpos( $string, ',' )) |
|
6866 | - $string = str_replace(',', '\,', $string); |
|
6867 | - if( FALSE !== strpos( $string, ';' )) |
|
6868 | - $string = str_replace(';', '\;', $string); |
|
6869 | - if( FALSE !== strpos( $string, "\r\n" )) |
|
6870 | - $string = str_replace( "\r\n", '\n', $string); |
|
6871 | - elseif( FALSE !== strpos( $string, "\r" )) |
|
6872 | - $string = str_replace( "\r", '\n', $string); |
|
6873 | - if( FALSE !== strpos( $string, '\N' )) |
|
6874 | - $string = str_replace( '\N', '\n', $string); |
|
6875 | -// if( FALSE !== strpos( $string, $this->nl )) |
|
7777 | + if( FALSE !== strpos( $string, '"' )) { |
|
7778 | + $string = str_replace('"', "'", $string); |
|
7779 | + } |
|
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, "\r\n" )) { |
|
7787 | + $string = str_replace( "\r\n", '\n', $string); |
|
7788 | + } elseif( FALSE !== strpos( $string, "\r" )) { |
|
7789 | + $string = str_replace( "\r", '\n', $string); |
|
7790 | + } |
|
7791 | + if( FALSE !== strpos( $string, '\N' )) { |
|
7792 | + $string = str_replace( '\N', '\n', $string); |
|
7793 | + } |
|
7794 | + // if( FALSE !== strpos( $string, $this->nl )) |
|
6876 | 7795 | $string = str_replace( $this->nl, '\n', $string); |
6877 | 7796 | break; |
6878 | 7797 | } |
@@ -7024,8 +7943,9 @@ discard block |
||
7024 | 7943 | $component .= $this->createSubComponent(); |
7025 | 7944 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7026 | 7945 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7027 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7028 | - $xcaldecl[] = $localxcaldecl; |
|
7946 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
7947 | + $xcaldecl[] = $localxcaldecl; |
|
7948 | + } |
|
7029 | 7949 | } |
7030 | 7950 | return $component; |
7031 | 7951 | } |
@@ -7162,8 +8082,9 @@ discard block |
||
7162 | 8082 | $component .= $this->createSubComponent(); |
7163 | 8083 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7164 | 8084 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7165 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7166 | - $xcaldecl[] = $localxcaldecl; |
|
8085 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
8086 | + $xcaldecl[] = $localxcaldecl; |
|
8087 | + } |
|
7167 | 8088 | } |
7168 | 8089 | return $component; |
7169 | 8090 | } |
@@ -7271,8 +8192,9 @@ discard block |
||
7271 | 8192 | $component .= $this->createXprop(); |
7272 | 8193 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7273 | 8194 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7274 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7275 | - $xcaldecl[] = $localxcaldecl; |
|
8195 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
8196 | + $xcaldecl[] = $localxcaldecl; |
|
8197 | + } |
|
7276 | 8198 | } |
7277 | 8199 | return $component; |
7278 | 8200 | } |
@@ -7346,8 +8268,9 @@ discard block |
||
7346 | 8268 | $component .= $this->createXprop(); |
7347 | 8269 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7348 | 8270 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7349 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7350 | - $xcaldecl[] = $localxcaldecl; |
|
8271 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
8272 | + $xcaldecl[] = $localxcaldecl; |
|
8273 | + } |
|
7351 | 8274 | } |
7352 | 8275 | return $component; |
7353 | 8276 | } |
@@ -7492,8 +8415,9 @@ discard block |
||
7492 | 8415 | $component .= $this->createSubComponent(); |
7493 | 8416 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7494 | 8417 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7495 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7496 | - $xcaldecl[] = $localxcaldecl; |
|
8418 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
8419 | + $xcaldecl[] = $localxcaldecl; |
|
8420 | + } |
|
7497 | 8421 | } |
7498 | 8422 | return $component; |
7499 | 8423 | } |