@@ -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 | /** |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @since 2.2.13 - 2007-12-30 |
88 | 88 | * @return void |
89 | 89 | */ |
90 | - function vcalendar () { |
|
90 | + function vcalendar() { |
|
91 | 91 | $this->_makeVersion(); |
92 | 92 | $this->calscale = null; |
93 | 93 | $this->method = null; |
@@ -97,15 +97,15 @@ discard block |
||
97 | 97 | /** |
98 | 98 | * language = <Text identifying a language, as defined in [RFC 1766]> |
99 | 99 | */ |
100 | - if( defined( 'ICAL_LANG' )) |
|
101 | - $this->setConfig( 'language', ICAL_LANG ); |
|
102 | - $this->setConfig( 'allowEmpty', TRUE ); |
|
103 | - $this->setConfig( 'nl', "\n" ); |
|
104 | - $this->setConfig( 'format', 'iCal'); |
|
100 | + if (defined('ICAL_LANG')) |
|
101 | + $this->setConfig('language', ICAL_LANG); |
|
102 | + $this->setConfig('allowEmpty', TRUE); |
|
103 | + $this->setConfig('nl', "\n"); |
|
104 | + $this->setConfig('format', 'iCal'); |
|
105 | 105 | $this->directory = null; |
106 | 106 | $this->filename = null; |
107 | 107 | $this->url = null; |
108 | - $this->setConfig( 'delimiter', DIRECTORY_SEPARATOR ); |
|
108 | + $this->setConfig('delimiter', DIRECTORY_SEPARATOR); |
|
109 | 109 | $this->xcaldecl = array(); |
110 | 110 | $this->components = array(); |
111 | 111 | } |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | * @return string |
122 | 122 | */ |
123 | 123 | function createCalscale() { |
124 | - if( empty( $this->calscale )) return FALSE; |
|
125 | - switch( $this->format ) { |
|
124 | + if (empty($this->calscale)) return FALSE; |
|
125 | + switch ($this->format) { |
|
126 | 126 | case 'xcal': |
127 | 127 | return ' calscale="'.$this->calscale.'"'.$this->nl; |
128 | 128 | break; |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param string $value |
140 | 140 | * @return void |
141 | 141 | */ |
142 | - function setCalscale( $value ) { |
|
143 | - if( empty( $value )) return FALSE; |
|
142 | + function setCalscale($value) { |
|
143 | + if (empty($value)) return FALSE; |
|
144 | 144 | $this->calscale = $value; |
145 | 145 | } |
146 | 146 | /*********************************************************************************/ |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | * @return string |
156 | 156 | */ |
157 | 157 | function createMethod() { |
158 | - if( empty( $this->method )) return FALSE; |
|
159 | - switch( $this->format ) { |
|
158 | + if (empty($this->method)) return FALSE; |
|
159 | + switch ($this->format) { |
|
160 | 160 | case 'xcal': |
161 | 161 | return ' method="'.$this->method.'"'.$this->nl; |
162 | 162 | break; |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @param string $value |
174 | 174 | * @return bool |
175 | 175 | */ |
176 | - function setMethod( $value ) { |
|
177 | - if( empty( $value )) return FALSE; |
|
176 | + function setMethod($value) { |
|
177 | + if (empty($value)) return FALSE; |
|
178 | 178 | $this->method = $value; |
179 | 179 | return TRUE; |
180 | 180 | } |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | * @return string |
195 | 195 | */ |
196 | 196 | function createProdid() { |
197 | - if( !isset( $this->prodid )) |
|
197 | + if (!isset($this->prodid)) |
|
198 | 198 | $this->_makeProdid(); |
199 | - switch( $this->format ) { |
|
199 | + switch ($this->format) { |
|
200 | 200 | case 'xcal': |
201 | 201 | return ' prodid="'.$this->prodid.'"'.$this->nl; |
202 | 202 | break; |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * @return void |
214 | 214 | */ |
215 | 215 | function _makeProdid() { |
216 | - $this->prodid = '-//'.$this->unique_id.'//NONSGML '.ICALCREATOR_VERSION.'//'.strtoupper( $this->language ); |
|
216 | + $this->prodid = '-//'.$this->unique_id.'//NONSGML '.ICALCREATOR_VERSION.'//'.strtoupper($this->language); |
|
217 | 217 | } |
218 | 218 | /** |
219 | 219 | * Conformance: The property MUST be specified once in an iCalendar object. |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @return void |
230 | 230 | */ |
231 | 231 | function _makeUnique_id() { |
232 | - $this->unique_id = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost'; |
|
232 | + $this->unique_id = (isset($_SERVER['SERVER_NAME'])) ? gethostbyname($_SERVER['SERVER_NAME']) : 'localhost'; |
|
233 | 233 | } |
234 | 234 | /*********************************************************************************/ |
235 | 235 | /** |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | * @return string |
247 | 247 | */ |
248 | 248 | function createVersion() { |
249 | - if( empty( $this->version )) |
|
249 | + if (empty($this->version)) |
|
250 | 250 | $this->_makeVersion(); |
251 | - switch( $this->format ) { |
|
251 | + switch ($this->format) { |
|
252 | 252 | case 'xcal': |
253 | 253 | return ' version="'.$this->version.'"'.$this->nl; |
254 | 254 | break; |
@@ -275,8 +275,8 @@ discard block |
||
275 | 275 | * @param string $value |
276 | 276 | * @return void |
277 | 277 | */ |
278 | - function setVersion( $value ) { |
|
279 | - if( empty( $value )) return FALSE; |
|
278 | + function setVersion($value) { |
|
279 | + if (empty($value)) return FALSE; |
|
280 | 280 | $this->version = $value; |
281 | 281 | return TRUE; |
282 | 282 | } |
@@ -292,29 +292,29 @@ discard block |
||
292 | 292 | * @return string |
293 | 293 | */ |
294 | 294 | function createXprop() { |
295 | - if( 'xcal' == $this->format ) |
|
295 | + if ('xcal' == $this->format) |
|
296 | 296 | return false; |
297 | - if( 0 >= count( $this->xprop )) |
|
297 | + if (0 >= count($this->xprop)) |
|
298 | 298 | return; |
299 | 299 | $output = null; |
300 | 300 | $toolbox = new calendarComponent(); |
301 | - $toolbox->setConfig( 'language', $this->getConfig( 'language' )); |
|
302 | - $toolbox->setConfig( 'nl', $this->getConfig( 'nl' )); |
|
303 | - $toolbox->_createFormat( $this->getConfig( 'format' )); |
|
304 | - foreach( $this->xprop as $label => $xpropPart ) { |
|
305 | - if( empty( $xpropPart['value'] )) { |
|
306 | - $output .= $toolbox->_createElement( $label ); |
|
301 | + $toolbox->setConfig('language', $this->getConfig('language')); |
|
302 | + $toolbox->setConfig('nl', $this->getConfig('nl')); |
|
303 | + $toolbox->_createFormat($this->getConfig('format')); |
|
304 | + foreach ($this->xprop as $label => $xpropPart) { |
|
305 | + if (empty($xpropPart['value'])) { |
|
306 | + $output .= $toolbox->_createElement($label); |
|
307 | 307 | continue; |
308 | 308 | } |
309 | - $attributes = $toolbox->_createParams( $xpropPart['params'], array( 'LANGUAGE' )); |
|
310 | - if( is_array( $xpropPart['value'] )) { |
|
311 | - foreach( $xpropPart['value'] as $pix => $theXpart ) |
|
312 | - $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart ); |
|
313 | - $xpropPart['value'] = implode( ',', $xpropPart['value'] ); |
|
309 | + $attributes = $toolbox->_createParams($xpropPart['params'], array('LANGUAGE')); |
|
310 | + if (is_array($xpropPart['value'])) { |
|
311 | + foreach ($xpropPart['value'] as $pix => $theXpart) |
|
312 | + $xpropPart['value'][$pix] = $toolbox->_strrep($theXpart); |
|
313 | + $xpropPart['value'] = implode(',', $xpropPart['value']); |
|
314 | 314 | } |
315 | 315 | else |
316 | - $xpropPart['value'] = $toolbox->_strrep( $xpropPart['value'] ); |
|
317 | - $output .= $toolbox->_createElement( $label, $attributes, $xpropPart['value'] ); |
|
316 | + $xpropPart['value'] = $toolbox->_strrep($xpropPart['value']); |
|
317 | + $output .= $toolbox->_createElement($label, $attributes, $xpropPart['value']); |
|
318 | 318 | } |
319 | 319 | return $output; |
320 | 320 | } |
@@ -328,14 +328,14 @@ discard block |
||
328 | 328 | * @param array $params optional |
329 | 329 | * @return bool |
330 | 330 | */ |
331 | - function setXprop( $label, $value, $params=FALSE ) { |
|
332 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
333 | - if( empty( $label )) return FALSE; |
|
334 | - $xprop = array( 'value' => $value ); |
|
331 | + function setXprop($label, $value, $params = FALSE) { |
|
332 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
333 | + if (empty($label)) return FALSE; |
|
334 | + $xprop = array('value' => $value); |
|
335 | 335 | $toolbox = new calendarComponent(); |
336 | - $xprop['params'] = $toolbox->_setParams( $params ); |
|
337 | - if( !is_array( $this->xprop )) $this->xprop = array(); |
|
338 | - $this->xprop[strtoupper( $label )] = $xprop; |
|
336 | + $xprop['params'] = $toolbox->_setParams($params); |
|
337 | + if (!is_array($this->xprop)) $this->xprop = array(); |
|
338 | + $this->xprop[strtoupper($label)] = $xprop; |
|
339 | 339 | return TRUE; |
340 | 340 | } |
341 | 341 | /*********************************************************************************/ |
@@ -348,39 +348,39 @@ discard block |
||
348 | 348 | * @param int @propix, optional, if specific property is wanted in case of multiply occurences |
349 | 349 | * @return bool, if successfull delete |
350 | 350 | */ |
351 | - function deleteProperty( $propName, $propix=FALSE ) { |
|
352 | - $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP'; |
|
353 | - if( !$propix ) |
|
354 | - $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1; |
|
351 | + function deleteProperty($propName, $propix = FALSE) { |
|
352 | + $propName = ($propName) ? strtoupper($propName) : 'X-PROP'; |
|
353 | + if (!$propix) |
|
354 | + $propix = (isset($this->propdelix[$propName])) ? $this->propdelix[$propName] + 2 : 1; |
|
355 | 355 | $this->propdelix[$propName] = --$propix; |
356 | 356 | $return = FALSE; |
357 | - switch( $propName ) { |
|
357 | + switch ($propName) { |
|
358 | 358 | case 'CALSCALE': |
359 | - if( isset( $this->calscale )) { |
|
359 | + if (isset($this->calscale)) { |
|
360 | 360 | $this->calscale = null; |
361 | 361 | $return = TRUE; |
362 | 362 | } |
363 | 363 | break; |
364 | 364 | case 'METHOD': |
365 | - if( isset( $this->method )) { |
|
366 | - $this->method = null; |
|
365 | + if (isset($this->method)) { |
|
366 | + $this->method = null; |
|
367 | 367 | $return = TRUE; |
368 | 368 | } |
369 | 369 | break; |
370 | 370 | default: |
371 | 371 | $reduced = array(); |
372 | - if( $propName != 'X-PROP' ) { |
|
373 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
374 | - foreach( $this->xprop as $k => $a ) { |
|
375 | - if(( $k != $propName ) && !empty( $a )) |
|
372 | + if ($propName != 'X-PROP') { |
|
373 | + if (!isset($this->xprop[$propName])) return FALSE; |
|
374 | + foreach ($this->xprop as $k => $a) { |
|
375 | + if (($k != $propName) && !empty($a)) |
|
376 | 376 | $reduced[$k] = $a; |
377 | 377 | } |
378 | 378 | } |
379 | 379 | else { |
380 | - if( count( $this->xprop ) <= $propix ) return FALSE; |
|
380 | + if (count($this->xprop) <= $propix) return FALSE; |
|
381 | 381 | $xpropno = 0; |
382 | - foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
|
383 | - if( $propix != $xpropno ) |
|
382 | + foreach ($this->xprop as $xpropkey => $xpropvalue) { |
|
383 | + if ($propix != $xpropno) |
|
384 | 384 | $reduced[$xpropkey] = $xpropvalue; |
385 | 385 | $xpropno++; |
386 | 386 | } |
@@ -400,41 +400,41 @@ discard block |
||
400 | 400 | * @param bool $inclParam=FALSE |
401 | 401 | * @return mixed |
402 | 402 | */ |
403 | - function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE ) { |
|
404 | - $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP'; |
|
405 | - if( 'X-PROP' == $propName ) { |
|
406 | - if( !$propix ) |
|
407 | - $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; |
|
403 | + function getProperty($propName = FALSE, $propix = FALSE, $inclParam = FALSE) { |
|
404 | + $propName = ($propName) ? strtoupper($propName) : 'X-PROP'; |
|
405 | + if ('X-PROP' == $propName) { |
|
406 | + if (!$propix) |
|
407 | + $propix = (isset($this->propix[$propName])) ? $this->propix[$propName] + 2 : 1; |
|
408 | 408 | $this->propix[$propName] = --$propix; |
409 | 409 | } |
410 | - switch( $propName ) { |
|
410 | + switch ($propName) { |
|
411 | 411 | case 'CALSCALE': |
412 | - return ( !empty( $this->calscale )) ? $this->calscale : null; |
|
412 | + return (!empty($this->calscale)) ? $this->calscale : null; |
|
413 | 413 | break; |
414 | 414 | case 'METHOD': |
415 | - return ( !empty( $this->method )) ? $this->method : null; |
|
415 | + return (!empty($this->method)) ? $this->method : null; |
|
416 | 416 | break; |
417 | 417 | case 'PRODID': |
418 | - if( empty( $this->prodid )) |
|
418 | + if (empty($this->prodid)) |
|
419 | 419 | $this->_makeProdid(); |
420 | 420 | return $this->prodid; |
421 | 421 | break; |
422 | 422 | case 'VERSION': |
423 | - return ( !empty( $this->version )) ? $this->version : null; |
|
423 | + return (!empty($this->version)) ? $this->version : null; |
|
424 | 424 | break; |
425 | 425 | default: |
426 | - if( $propName != 'X-PROP' ) { |
|
427 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
428 | - return ( $inclParam ) ? array( $propName, $this->xprop[$propName] ) |
|
429 | - : array( $propName, $this->xprop[$propName]['value'] ); |
|
426 | + if ($propName != 'X-PROP') { |
|
427 | + if (!isset($this->xprop[$propName])) return FALSE; |
|
428 | + return ($inclParam) ? array($propName, $this->xprop[$propName]) |
|
429 | + : array($propName, $this->xprop[$propName]['value']); |
|
430 | 430 | } |
431 | 431 | else { |
432 | - if( empty( $this->xprop )) return FALSE; |
|
432 | + if (empty($this->xprop)) return FALSE; |
|
433 | 433 | $xpropno = 0; |
434 | - foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
|
435 | - if( $propix == $xpropno ) |
|
436 | - return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) |
|
437 | - : array( $xpropkey, $this->xprop[$xpropkey]['value'] ); |
|
434 | + foreach ($this->xprop as $xpropkey => $xpropvalue) { |
|
435 | + if ($propix == $xpropno) |
|
436 | + return ($inclParam) ? array($xpropkey, $this->xprop[$xpropkey]) |
|
437 | + : array($xpropkey, $this->xprop[$xpropkey]['value']); |
|
438 | 438 | else |
439 | 439 | $xpropno++; |
440 | 440 | } |
@@ -453,23 +453,23 @@ discard block |
||
453 | 453 | * second ALWAYS component value! |
454 | 454 | * @return bool |
455 | 455 | */ |
456 | - function setProperty () { |
|
456 | + function setProperty() { |
|
457 | 457 | $numargs = func_num_args(); |
458 | - if( 1 > $numargs ) |
|
458 | + if (1 > $numargs) |
|
459 | 459 | return FALSE; |
460 | 460 | $arglist = func_get_args(); |
461 | - $arglist[0] = strtoupper( $arglist[0] ); |
|
462 | - switch( $arglist[0] ) { |
|
461 | + $arglist[0] = strtoupper($arglist[0]); |
|
462 | + switch ($arglist[0]) { |
|
463 | 463 | case 'CALSCALE': |
464 | - return $this->setCalscale( $arglist[1] ); |
|
464 | + return $this->setCalscale($arglist[1]); |
|
465 | 465 | case 'METHOD': |
466 | - return $this->setMethod( $arglist[1] ); |
|
466 | + return $this->setMethod($arglist[1]); |
|
467 | 467 | case 'VERSION': |
468 | - return $this->setVersion( $arglist[1] ); |
|
468 | + return $this->setVersion($arglist[1]); |
|
469 | 469 | default: |
470 | - if( !isset( $arglist[1] )) $arglist[1] = null; |
|
471 | - if( !isset( $arglist[2] )) $arglist[2] = null; |
|
472 | - return $this->setXprop( $arglist[0], $arglist[1], $arglist[2] ); |
|
470 | + if (!isset($arglist[1])) $arglist[1] = null; |
|
471 | + if (!isset($arglist[2])) $arglist[2] = null; |
|
472 | + return $this->setXprop($arglist[0], $arglist[1], $arglist[2]); |
|
473 | 473 | } |
474 | 474 | return FALSE; |
475 | 475 | } |
@@ -482,23 +482,23 @@ discard block |
||
482 | 482 | * @param string $config |
483 | 483 | * @return value |
484 | 484 | */ |
485 | - function getConfig( $config ) { |
|
486 | - switch( strtoupper( $config )) { |
|
485 | + function getConfig($config) { |
|
486 | + switch (strtoupper($config)) { |
|
487 | 487 | case 'ALLOWEMPTY': |
488 | 488 | return $this->allowEmpty; |
489 | 489 | break; |
490 | 490 | case 'COMPSINFO': |
491 | - unset( $this->compix ); |
|
491 | + unset($this->compix); |
|
492 | 492 | $info = array(); |
493 | - foreach( $this->components as $cix => $component ) { |
|
494 | - if( empty( $component )) continue; |
|
495 | - unset( $component->propix ); |
|
493 | + foreach ($this->components as $cix => $component) { |
|
494 | + if (empty($component)) continue; |
|
495 | + unset($component->propix); |
|
496 | 496 | $info[$cix]['ordno'] = $cix + 1; |
497 | 497 | $info[$cix]['type'] = $component->objName; |
498 | - $info[$cix]['uid'] = $component->getProperty( 'uid' ); |
|
499 | - $info[$cix]['props'] = $component->getConfig( 'propinfo' ); |
|
500 | - $info[$cix]['sub'] = $component->getConfig( 'compsinfo' ); |
|
501 | - unset( $component->propix ); |
|
498 | + $info[$cix]['uid'] = $component->getProperty('uid'); |
|
499 | + $info[$cix]['props'] = $component->getConfig('propinfo'); |
|
500 | + $info[$cix]['sub'] = $component->getConfig('compsinfo'); |
|
501 | + unset($component->propix); |
|
502 | 502 | } |
503 | 503 | return $info; |
504 | 504 | break; |
@@ -506,32 +506,32 @@ discard block |
||
506 | 506 | return $this->delimiter; |
507 | 507 | break; |
508 | 508 | case 'DIRECTORY': |
509 | - if( empty( $this->directory )) |
|
509 | + if (empty($this->directory)) |
|
510 | 510 | $this->directory = '.'; |
511 | 511 | return $this->directory; |
512 | 512 | break; |
513 | 513 | case 'DIRFILE': |
514 | - return $this->getConfig( 'directory' ).$this->getConfig( 'delimiter' ).$this->getConfig( 'filename' ); |
|
514 | + return $this->getConfig('directory').$this->getConfig('delimiter').$this->getConfig('filename'); |
|
515 | 515 | break; |
516 | 516 | case 'FILEINFO': |
517 | - return array( $this->getConfig( 'directory' ) |
|
518 | - , $this->getConfig( 'filename' ) |
|
519 | - , $this->getConfig( 'filesize' )); |
|
517 | + return array($this->getConfig('directory') |
|
518 | + , $this->getConfig('filename') |
|
519 | + , $this->getConfig('filesize')); |
|
520 | 520 | break; |
521 | 521 | case 'FILENAME': |
522 | - if( empty( $this->filename )) { |
|
523 | - if( 'xcal' == $this->format ) |
|
524 | - $this->filename = date( 'YmdHis' ).'.xml'; // recommended xcs.. . |
|
522 | + if (empty($this->filename)) { |
|
523 | + if ('xcal' == $this->format) |
|
524 | + $this->filename = date('YmdHis').'.xml'; // recommended xcs.. . |
|
525 | 525 | else |
526 | - $this->filename = date( 'YmdHis' ).'.ics'; |
|
526 | + $this->filename = date('YmdHis').'.ics'; |
|
527 | 527 | } |
528 | 528 | return $this->filename; |
529 | 529 | break; |
530 | 530 | case 'FILESIZE': |
531 | - $size = 0; |
|
532 | - if( empty( $this->url )) { |
|
533 | - $dirfile = $this->getConfig( 'dirfile' ); |
|
534 | - if( FALSE === ( $size = filesize( $dirfile ))) |
|
531 | + $size = 0; |
|
532 | + if (empty($this->url)) { |
|
533 | + $dirfile = $this->getConfig('dirfile'); |
|
534 | + if (FALSE === ($size = filesize($dirfile))) |
|
535 | 535 | $size = 0; |
536 | 536 | clearstatcache(); |
537 | 537 | } |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | return $this->unique_id; |
553 | 553 | break; |
554 | 554 | case 'URL': |
555 | - if( !empty( $this->url )) |
|
555 | + if (!empty($this->url)) |
|
556 | 556 | return $this->url; |
557 | 557 | else |
558 | 558 | return FALSE; |
@@ -568,12 +568,12 @@ discard block |
||
568 | 568 | * @param string $value |
569 | 569 | * @return void |
570 | 570 | */ |
571 | - function setConfig( $config, $value ) { |
|
571 | + function setConfig($config, $value) { |
|
572 | 572 | $res = FALSE; |
573 | - switch( strtoupper( $config )) { |
|
573 | + switch (strtoupper($config)) { |
|
574 | 574 | case 'ALLOWEMPTY': |
575 | 575 | $this->allowEmpty = $value; |
576 | - $subcfg = array( 'ALLOWEMPTY' => $value ); |
|
576 | + $subcfg = array('ALLOWEMPTY' => $value); |
|
577 | 577 | $res = TRUE; |
578 | 578 | break; |
579 | 579 | case 'DELIMITER': |
@@ -581,11 +581,11 @@ discard block |
||
581 | 581 | return TRUE; |
582 | 582 | break; |
583 | 583 | case 'DIRECTORY': |
584 | - $value = trim( $value ); |
|
584 | + $value = trim($value); |
|
585 | 585 | $nl = $this->getConfig('delimiter'); |
586 | - if( $nl == substr( $value, ( 0 - strlen( $nl )))) |
|
587 | - $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl ))); |
|
588 | - if( is_dir( $value )) { |
|
586 | + if ($nl == substr($value, (0 - strlen($nl)))) |
|
587 | + $value = substr($value, 0, (strlen($value) - strlen($nl))); |
|
588 | + if (is_dir($value)) { |
|
589 | 589 | /* local directory */ |
590 | 590 | clearstatcache(); |
591 | 591 | $this->directory = $value; |
@@ -596,16 +596,16 @@ discard block |
||
596 | 596 | return FALSE; |
597 | 597 | break; |
598 | 598 | case 'FILENAME': |
599 | - $value = trim( $value ); |
|
600 | - if( !empty( $this->url )) { |
|
599 | + $value = trim($value); |
|
600 | + if (!empty($this->url)) { |
|
601 | 601 | /* remote directory+file - URL */ |
602 | 602 | $this->filename = $value; |
603 | 603 | return TRUE; |
604 | 604 | } |
605 | - $dirfile = $this->getConfig( 'directory' ).$this->getConfig( 'delimiter' ).$value; |
|
606 | - if( file_exists( $dirfile )) { |
|
605 | + $dirfile = $this->getConfig('directory').$this->getConfig('delimiter').$value; |
|
606 | + if (file_exists($dirfile)) { |
|
607 | 607 | /* local existing file */ |
608 | - if( is_readable( $dirfile ) || is_writable( $dirfile )) { |
|
608 | + if (is_readable($dirfile) || is_writable($dirfile)) { |
|
609 | 609 | clearstatcache(); |
610 | 610 | $this->filename = $value; |
611 | 611 | return TRUE; |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | else |
614 | 614 | return FALSE; |
615 | 615 | } |
616 | - elseif( FALSE !== touch( $dirfile )) { |
|
616 | + elseif (FALSE !== touch($dirfile)) { |
|
617 | 617 | /* new local file created */ |
618 | 618 | $this->filename = $value; |
619 | 619 | return TRUE; |
@@ -622,8 +622,8 @@ discard block |
||
622 | 622 | return FALSE; |
623 | 623 | break; |
624 | 624 | case 'FORMAT': |
625 | - $value = trim( $value ); |
|
626 | - if( 'xcal' == strtolower( $value )) { |
|
625 | + $value = trim($value); |
|
626 | + if ('xcal' == strtolower($value)) { |
|
627 | 627 | $this->format = 'xcal'; |
628 | 628 | $this->attributeDelimiter = $this->nl; |
629 | 629 | $this->valueInit = null; |
@@ -633,46 +633,46 @@ discard block |
||
633 | 633 | $this->attributeDelimiter = ';'; |
634 | 634 | $this->valueInit = ':'; |
635 | 635 | } |
636 | - $subcfg = array( 'FORMAT' => $value ); |
|
636 | + $subcfg = array('FORMAT' => $value); |
|
637 | 637 | $res = TRUE; |
638 | 638 | break; |
639 | 639 | case 'LANGUAGE': |
640 | 640 | // set language for calendar component as defined in [RFC 1766] |
641 | - $value = trim( $value ); |
|
641 | + $value = trim($value); |
|
642 | 642 | $this->language = $value; |
643 | - $subcfg = array( 'LANGUAGE' => $value ); |
|
643 | + $subcfg = array('LANGUAGE' => $value); |
|
644 | 644 | $res = TRUE; |
645 | 645 | break; |
646 | 646 | case 'NL': |
647 | 647 | case 'NEWLINECHAR': |
648 | 648 | $this->nl = $value; |
649 | - $subcfg = array( 'NL' => $value ); |
|
649 | + $subcfg = array('NL' => $value); |
|
650 | 650 | $res = TRUE; |
651 | 651 | break; |
652 | 652 | case 'UNIQUE_ID': |
653 | - $value = trim( $value ); |
|
653 | + $value = trim($value); |
|
654 | 654 | $this->unique_id = $value; |
655 | - $subcfg = array( 'UNIQUE_ID' => $value ); |
|
655 | + $subcfg = array('UNIQUE_ID' => $value); |
|
656 | 656 | $res = TRUE; |
657 | 657 | break; |
658 | 658 | case 'URL': |
659 | 659 | /* remote file - URL */ |
660 | - $value = trim( $value ); |
|
661 | - $value = str_replace( 'HTTP://', 'http://', $value ); |
|
662 | - $value = str_replace( 'WEBCAL://', 'http://', $value ); |
|
663 | - $value = str_replace( 'webcal://', 'http://', $value ); |
|
660 | + $value = trim($value); |
|
661 | + $value = str_replace('HTTP://', 'http://', $value); |
|
662 | + $value = str_replace('WEBCAL://', 'http://', $value); |
|
663 | + $value = str_replace('webcal://', 'http://', $value); |
|
664 | 664 | $this->url = $value; |
665 | 665 | $this->directory = null; |
666 | - $parts = pathinfo( $value ); |
|
667 | - return $this->setConfig( 'filename', $parts['basename'] ); |
|
666 | + $parts = pathinfo($value); |
|
667 | + return $this->setConfig('filename', $parts['basename']); |
|
668 | 668 | break; |
669 | 669 | } |
670 | - if( !$res ) return FALSE; |
|
671 | - if( isset( $subcfg ) && !empty( $this->components )) { |
|
672 | - foreach( $subcfg as $cfgkey => $cfgvalue ) { |
|
673 | - foreach( $this->components as $cix => $component ) { |
|
674 | - $res = $component->setConfig( $cfgkey, $cfgvalue ); |
|
675 | - if( !$res ) |
|
670 | + if (!$res) return FALSE; |
|
671 | + if (isset($subcfg) && !empty($this->components)) { |
|
672 | + foreach ($subcfg as $cfgkey => $cfgvalue) { |
|
673 | + foreach ($this->components as $cix => $component) { |
|
674 | + $res = $component->setConfig($cfgkey, $cfgvalue); |
|
675 | + if (!$res) |
|
676 | 676 | break 2; |
677 | 677 | $this->components[$cix] = $component->copy(); // PHP4 compliant |
678 | 678 | } |
@@ -691,8 +691,8 @@ discard block |
||
691 | 691 | * @param object $component calendar component |
692 | 692 | * @return void |
693 | 693 | */ |
694 | - function addComponent( $component ) { |
|
695 | - $this->setComponent( $component ); |
|
694 | + function addComponent($component) { |
|
695 | + $this->setComponent($component); |
|
696 | 696 | } |
697 | 697 | /** |
698 | 698 | * delete calendar component from container |
@@ -703,33 +703,33 @@ discard block |
||
703 | 703 | * @param mixed $arg2 optional, ordno if arg1 = component type |
704 | 704 | * @return void |
705 | 705 | */ |
706 | - function deleteComponent( $arg1, $arg2=FALSE ) { |
|
706 | + function deleteComponent($arg1, $arg2 = FALSE) { |
|
707 | 707 | $argType = $index = null; |
708 | - if ( ctype_digit( (string) $arg1 )) { |
|
708 | + if (ctype_digit((string) $arg1)) { |
|
709 | 709 | $argType = 'INDEX'; |
710 | 710 | $index = (int) $arg1 - 1; |
711 | 711 | } |
712 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
713 | - $argType = strtolower( $arg1 ); |
|
714 | - $index = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0; |
|
712 | + elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) { |
|
713 | + $argType = strtolower($arg1); |
|
714 | + $index = (!empty($arg2) && ctype_digit((string) $arg2)) ? ((int) $arg2 - 1) : 0; |
|
715 | 715 | } |
716 | 716 | $cix1dC = 0; |
717 | - foreach ( $this->components as $cix => $component) { |
|
718 | - if( empty( $component )) continue; |
|
719 | - unset( $component->propix ); |
|
720 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
|
721 | - unset( $this->components[$cix] ); |
|
717 | + foreach ($this->components as $cix => $component) { |
|
718 | + if (empty($component)) continue; |
|
719 | + unset($component->propix); |
|
720 | + if (('INDEX' == $argType) && ($index == $cix)) { |
|
721 | + unset($this->components[$cix]); |
|
722 | 722 | return TRUE; |
723 | 723 | } |
724 | - elseif( $argType == $component->objName ) { |
|
725 | - if( $index == $cix1dC ) { |
|
726 | - unset( $this->components[$cix] ); |
|
724 | + elseif ($argType == $component->objName) { |
|
725 | + if ($index == $cix1dC) { |
|
726 | + unset($this->components[$cix]); |
|
727 | 727 | return TRUE; |
728 | 728 | } |
729 | 729 | $cix1dC++; |
730 | 730 | } |
731 | - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
732 | - unset( $this->components[$cix] ); |
|
731 | + elseif (!$argType && ($arg1 == $component->getProperty('uid'))) { |
|
732 | + unset($this->components[$cix]); |
|
733 | 733 | return TRUE; |
734 | 734 | } |
735 | 735 | } |
@@ -744,49 +744,49 @@ discard block |
||
744 | 744 | * @param mixed $arg2 optional, ordno if arg1 = component type |
745 | 745 | * @return object |
746 | 746 | */ |
747 | - function getComponent( $arg1=FALSE, $arg2=FALSE ) { |
|
747 | + function getComponent($arg1 = FALSE, $arg2 = FALSE) { |
|
748 | 748 | $index = $argType = null; |
749 | - if ( !$arg1 ) { |
|
749 | + if (!$arg1) { |
|
750 | 750 | $argType = 'INDEX'; |
751 | 751 | $index = $this->compix['INDEX'] = |
752 | - ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1; |
|
752 | + (isset($this->compix['INDEX'])) ? $this->compix['INDEX'] + 1 : 1; |
|
753 | 753 | } |
754 | - elseif ( ctype_digit( (string) $arg1 )) { |
|
754 | + elseif (ctype_digit((string) $arg1)) { |
|
755 | 755 | $argType = 'INDEX'; |
756 | 756 | $index = (int) $arg1; |
757 | - unset( $this->compix ); |
|
757 | + unset($this->compix); |
|
758 | 758 | } |
759 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
760 | - unset( $this->compix['INDEX'] ); |
|
761 | - $argType = strtolower( $arg1 ); |
|
762 | - if( !$arg2 ) |
|
759 | + elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) { |
|
760 | + unset($this->compix['INDEX']); |
|
761 | + $argType = strtolower($arg1); |
|
762 | + if (!$arg2) |
|
763 | 763 | $index = $this->compix[$argType] = |
764 | - ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1; |
|
764 | + (isset($this->compix[$argType])) ? $this->compix[$argType] + 1 : 1; |
|
765 | 765 | else |
766 | 766 | $index = (int) $arg2; |
767 | 767 | } |
768 | - $index -= 1; |
|
769 | - $ckeys = array_keys( $this->components ); |
|
770 | - if( !empty( $index) && ( $index > end( $ckeys ))) |
|
768 | + $index -= 1; |
|
769 | + $ckeys = array_keys($this->components); |
|
770 | + if (!empty($index) && ($index > end($ckeys))) |
|
771 | 771 | return FALSE; |
772 | 772 | $cix1gC = 0; |
773 | - foreach ( $this->components as $cix => $component) { |
|
774 | - if( empty( $component )) continue; |
|
775 | - unset( $component->propix ); |
|
776 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) |
|
773 | + foreach ($this->components as $cix => $component) { |
|
774 | + if (empty($component)) continue; |
|
775 | + unset($component->propix); |
|
776 | + if (('INDEX' == $argType) && ($index == $cix)) |
|
777 | 777 | return $component->copy(); |
778 | - elseif( $argType == $component->objName ) { |
|
779 | - if( $index == $cix1gC ) |
|
778 | + elseif ($argType == $component->objName) { |
|
779 | + if ($index == $cix1gC) |
|
780 | 780 | return $component->copy(); |
781 | 781 | $cix1gC++; |
782 | 782 | } |
783 | - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
784 | - unset( $component->propix ); |
|
783 | + elseif (!$argType && ($arg1 == $component->getProperty('uid'))) { |
|
784 | + unset($component->propix); |
|
785 | 785 | return $component->copy(); |
786 | 786 | } |
787 | 787 | } |
788 | 788 | /* not found.. . */ |
789 | - unset( $this->compix ); |
|
789 | + unset($this->compix); |
|
790 | 790 | return FALSE; |
791 | 791 | } |
792 | 792 | /** |
@@ -813,242 +813,242 @@ discard block |
||
813 | 813 | * FALSE - one occurance of component only in output array</tr> |
814 | 814 | * @return array or FALSE |
815 | 815 | */ |
816 | - function selectComponents( $startY=FALSE, $startM=FALSE, $startD=FALSE, $endY=FALSE, $endM=FALSE, $endD=FALSE, $cType=FALSE, $flat=FALSE, $any=TRUE, $split=TRUE ) { |
|
816 | + function selectComponents($startY = FALSE, $startM = FALSE, $startD = FALSE, $endY = FALSE, $endM = FALSE, $endD = FALSE, $cType = FALSE, $flat = FALSE, $any = TRUE, $split = TRUE) { |
|
817 | 817 | /* check if empty calendar */ |
818 | - if( 0 >= count( $this->components )) return FALSE; |
|
818 | + if (0 >= count($this->components)) return FALSE; |
|
819 | 819 | /* check default dates */ |
820 | - if( !$startY ) $startY = date( 'Y' ); |
|
821 | - if( !$startM ) $startM = date( 'm' ); |
|
822 | - if( !$startD ) $startD = date( 'd' ); |
|
823 | - $startDate = mktime( 0, 0, 0, $startM, $startD, $startY ); |
|
824 | - if( !$endY ) $endY = $startY; |
|
825 | - if( !$endM ) $endM = $startM; |
|
826 | - if( !$endD ) $endD = $startD; |
|
827 | - $endDate = mktime( 23, 59, 59, $endM, $endD, $endY ); |
|
820 | + if (!$startY) $startY = date('Y'); |
|
821 | + if (!$startM) $startM = date('m'); |
|
822 | + if (!$startD) $startD = date('d'); |
|
823 | + $startDate = mktime(0, 0, 0, $startM, $startD, $startY); |
|
824 | + if (!$endY) $endY = $startY; |
|
825 | + if (!$endM) $endM = $startM; |
|
826 | + if (!$endD) $endD = $startD; |
|
827 | + $endDate = mktime(23, 59, 59, $endM, $endD, $endY); |
|
828 | 828 | /* check component types */ |
829 | - $validTypes = array('vevent', 'vtodo', 'vjournal', 'vfreebusy' ); |
|
830 | - if( is_array( $cType )) { |
|
831 | - foreach( $cType as $cix => $theType ) { |
|
832 | - $cType[$cix] = $theType = strtolower( $theType ); |
|
833 | - if( !in_array( $theType, $validTypes )) |
|
829 | + $validTypes = array('vevent', 'vtodo', 'vjournal', 'vfreebusy'); |
|
830 | + if (is_array($cType)) { |
|
831 | + foreach ($cType as $cix => $theType) { |
|
832 | + $cType[$cix] = $theType = strtolower($theType); |
|
833 | + if (!in_array($theType, $validTypes)) |
|
834 | 834 | $cType[$cix] = 'vevent'; |
835 | 835 | } |
836 | - $cType = array_unique( $cType ); |
|
836 | + $cType = array_unique($cType); |
|
837 | 837 | } |
838 | - elseif( !empty( $cType )) { |
|
839 | - $cType = strtolower( $cType ); |
|
840 | - if( !in_array( $cType, $validTypes )) |
|
841 | - $cType = array( 'vevent' ); |
|
838 | + elseif (!empty($cType)) { |
|
839 | + $cType = strtolower($cType); |
|
840 | + if (!in_array($cType, $validTypes)) |
|
841 | + $cType = array('vevent'); |
|
842 | 842 | else |
843 | - $cType = array( $cType ); |
|
843 | + $cType = array($cType); |
|
844 | 844 | } |
845 | 845 | else |
846 | 846 | $cType = $validTypes; |
847 | - if( 0 >= count( $cType )) |
|
847 | + if (0 >= count($cType)) |
|
848 | 848 | $cType = $validTypes; |
849 | 849 | /* iterate components */ |
850 | 850 | $result = array(); |
851 | - foreach ( $this->components as $cix => $component ) { |
|
852 | - if( empty( $component )) continue; |
|
853 | - unset( $component->propix, $start ); |
|
851 | + foreach ($this->components as $cix => $component) { |
|
852 | + if (empty($component)) continue; |
|
853 | + unset($component->propix, $start); |
|
854 | 854 | /* deselect unvalid type components */ |
855 | - if( !in_array( $component->objName, $cType )) continue; |
|
855 | + if (!in_array($component->objName, $cType)) continue; |
|
856 | 856 | /* deselect components without dtstart set */ |
857 | - if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) continue; |
|
857 | + if (FALSE === ($start = $component->getProperty('dtstart'))) continue; |
|
858 | 858 | $dtendExist = $dueExist = $durationExist = $endAllDayEvent = FALSE; |
859 | - unset( $end, $startWdate, $endWdate, $rdurWsecs, $rdur, $exdatelist, $workstart, $workend ); // clean up |
|
860 | - $startWdate = $component->_date2timestamp( $start ); |
|
861 | - $startDateFormat = ( isset( $start['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d'; |
|
859 | + unset($end, $startWdate, $endWdate, $rdurWsecs, $rdur, $exdatelist, $workstart, $workend); // clean up |
|
860 | + $startWdate = $component->_date2timestamp($start); |
|
861 | + $startDateFormat = (isset($start['hour'])) ? 'Y-m-d H:i:s' : 'Y-m-d'; |
|
862 | 862 | /* get end date from dtend/due/duration properties */ |
863 | - $end = $component->getProperty( 'dtend' ); |
|
864 | - if( !empty( $end )) { |
|
863 | + $end = $component->getProperty('dtend'); |
|
864 | + if (!empty($end)) { |
|
865 | 865 | $dtendExist = TRUE; |
866 | - $endDateFormat = ( isset( $end['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d'; |
|
866 | + $endDateFormat = (isset($end['hour'])) ? 'Y-m-d H:i:s' : 'Y-m-d'; |
|
867 | 867 | } |
868 | 868 | // if( !empty($end)) echo 'selectComp 1 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ### |
869 | - if( empty($end) && ( $component->objName == 'vtodo' )) { |
|
870 | - $end = $component->getProperty( 'due' ); |
|
871 | - if( !empty( $end )) { |
|
869 | + if (empty($end) && ($component->objName == 'vtodo')) { |
|
870 | + $end = $component->getProperty('due'); |
|
871 | + if (!empty($end)) { |
|
872 | 872 | $dueExist = TRUE; |
873 | - $endDateFormat = ( isset( $end['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d'; |
|
873 | + $endDateFormat = (isset($end['hour'])) ? 'Y-m-d H:i:s' : 'Y-m-d'; |
|
874 | 874 | } |
875 | 875 | // if( !empty($end)) echo 'selectComp 2 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ### |
876 | 876 | } |
877 | - if( !empty( $end ) && !isset( $end['hour'] )) { |
|
877 | + if (!empty($end) && !isset($end['hour'])) { |
|
878 | 878 | /* a DTEND without time part regards an event that ends the day before, |
879 | 879 | for an all-day event DTSTART=20071201 DTEND=20071202 (taking place 20071201!!! */ |
880 | 880 | $endAllDayEvent = TRUE; |
881 | - $endWdate = mktime( 23, 59, 59, $end['month'], ($end['day'] - 1), $end['year'] ); |
|
882 | - $end['year'] = date( 'Y', $endWdate ); |
|
883 | - $end['month'] = date( 'm', $endWdate ); |
|
884 | - $end['day'] = date( 'd', $endWdate ); |
|
881 | + $endWdate = mktime(23, 59, 59, $end['month'], ($end['day'] - 1), $end['year']); |
|
882 | + $end['year'] = date('Y', $endWdate); |
|
883 | + $end['month'] = date('m', $endWdate); |
|
884 | + $end['day'] = date('d', $endWdate); |
|
885 | 885 | $end['hour'] = 23; |
886 | 886 | $end['min'] = $end['sec'] = 59; |
887 | 887 | // if( !empty($end)) echo 'selectComp 3 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ### |
888 | 888 | } |
889 | - if( empty( $end )) { |
|
890 | - $end = $component->getProperty( 'duration', FALSE, FALSE, TRUE );// in dtend (array) format |
|
891 | - if( !empty( $end )) |
|
889 | + if (empty($end)) { |
|
890 | + $end = $component->getProperty('duration', FALSE, FALSE, TRUE); // in dtend (array) format |
|
891 | + if (!empty($end)) |
|
892 | 892 | $durationExist = TRUE; |
893 | 893 | // if( !empty($end)) echo 'selectComp 4 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ### |
894 | 894 | } |
895 | - if( empty( $end )) { // assume one day duration if missing end date |
|
896 | - $end = array( 'year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'hour' => 23, 'min' => 59, 'sec' => 59 ); |
|
895 | + if (empty($end)) { // assume one day duration if missing end date |
|
896 | + $end = array('year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'hour' => 23, 'min' => 59, 'sec' => 59); |
|
897 | 897 | // if( isset($end)) echo 'selectComp 5 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ### |
898 | 898 | } |
899 | - $endWdate = $component->_date2timestamp( $end ); |
|
900 | - if( $endWdate < $startWdate ) { // MUST be after start date!! |
|
901 | - $end = array( 'year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'hour' => 23, 'min' => 59, 'sec' => 59 ); |
|
902 | - $endWdate = $component->_date2timestamp( $end ); |
|
899 | + $endWdate = $component->_date2timestamp($end); |
|
900 | + if ($endWdate < $startWdate) { // MUST be after start date!! |
|
901 | + $end = array('year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'hour' => 23, 'min' => 59, 'sec' => 59); |
|
902 | + $endWdate = $component->_date2timestamp($end); |
|
903 | 903 | } |
904 | 904 | $rdurWsecs = $endWdate - $startWdate; // compute component duration in seconds |
905 | - $rdur = $component->_date2duration( $start, $end ); // compute component duration, array |
|
905 | + $rdur = $component->_date2duration($start, $end); // compute component duration, array |
|
906 | 906 | /* make a list of optional exclude dates for component occurence from exrule and exdate */ |
907 | 907 | $exdatelist = array(); |
908 | - $workstart = $component->_timestamp2date(( $startDate - $rdurWsecs ), 6); |
|
909 | - $workend = $component->_timestamp2date(( $endDate + $rdurWsecs ), 6); |
|
910 | - while( FALSE !== ( $exrule = $component->getProperty( 'exrule' ))) // check exrule |
|
911 | - $component->_recur2date( $exdatelist, $exrule, $start, $workstart, $workend ); |
|
912 | - while( FALSE !== ( $exdate = $component->getProperty( 'exdate' ))) { // check exdate |
|
913 | - foreach( $exdate as $theExdate ) { |
|
914 | - $exWdate = $component->_date2timestamp( $theExdate ); |
|
915 | - if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate )) |
|
908 | + $workstart = $component->_timestamp2date(($startDate - $rdurWsecs), 6); |
|
909 | + $workend = $component->_timestamp2date(($endDate + $rdurWsecs), 6); |
|
910 | + while (FALSE !== ($exrule = $component->getProperty('exrule'))) // check exrule |
|
911 | + $component->_recur2date($exdatelist, $exrule, $start, $workstart, $workend); |
|
912 | + while (FALSE !== ($exdate = $component->getProperty('exdate'))) { // check exdate |
|
913 | + foreach ($exdate as $theExdate) { |
|
914 | + $exWdate = $component->_date2timestamp($theExdate); |
|
915 | + if ((($startDate - $rdurWsecs) <= $exWdate) && ($endDate >= $exWdate)) |
|
916 | 916 | $exdatelist[$exWdate] = TRUE; |
917 | 917 | } |
918 | 918 | } |
919 | 919 | /* if 'any' components, check repeating components, removing all excluding dates */ |
920 | - if( TRUE === $any ) { |
|
920 | + if (TRUE === $any) { |
|
921 | 921 | /* make a list of optional repeating dates for component occurence, rrule, rdate */ |
922 | 922 | $recurlist = array(); |
923 | - while( FALSE !== ( $rrule = $component->getProperty( 'rrule' ))) // check rrule |
|
924 | - $component->_recur2date( $recurlist, $rrule, $start, $workstart, $workend ); |
|
925 | - foreach( $recurlist as $recurkey => $recurvalue ) // key=match date as timestamp |
|
923 | + while (FALSE !== ($rrule = $component->getProperty('rrule'))) // check rrule |
|
924 | + $component->_recur2date($recurlist, $rrule, $start, $workstart, $workend); |
|
925 | + foreach ($recurlist as $recurkey => $recurvalue) // key=match date as timestamp |
|
926 | 926 | $recurlist[$recurkey] = $rdurWsecs; // add duration in seconds |
927 | - while( FALSE !== ( $rdate = $component->getProperty( 'rdate' ))) { // check rdate |
|
928 | - foreach( $rdate as $theRdate ) { |
|
929 | - if( is_array( $theRdate ) && ( 2 == count( $theRdate )) && // all days within PERIOD |
|
930 | - array_key_exists( '0', $theRdate ) && array_key_exists( '1', $theRdate )) { |
|
931 | - $rstart = $component->_date2timestamp( $theRdate[0] ); |
|
932 | - if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate )) |
|
927 | + while (FALSE !== ($rdate = $component->getProperty('rdate'))) { // check rdate |
|
928 | + foreach ($rdate as $theRdate) { |
|
929 | + if (is_array($theRdate) && (2 == count($theRdate)) && // all days within PERIOD |
|
930 | + array_key_exists('0', $theRdate) && array_key_exists('1', $theRdate)) { |
|
931 | + $rstart = $component->_date2timestamp($theRdate[0]); |
|
932 | + if (($rstart < ($startDate - $rdurWsecs)) || ($rstart > $endDate)) |
|
933 | 933 | continue; |
934 | - if( isset( $theRdate[1]['year'] )) // date-date period |
|
935 | - $rend = $component->_date2timestamp( $theRdate[1] ); |
|
934 | + if (isset($theRdate[1]['year'])) // date-date period |
|
935 | + $rend = $component->_date2timestamp($theRdate[1]); |
|
936 | 936 | else { // date-duration period |
937 | - $rend = $component->duration2date( $theRdate[0], $theRdate[1] ); |
|
938 | - $rend = $component->_date2timestamp( $rend ); |
|
937 | + $rend = $component->duration2date($theRdate[0], $theRdate[1]); |
|
938 | + $rend = $component->_date2timestamp($rend); |
|
939 | 939 | } |
940 | - if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart )) |
|
941 | - $recurlist[$rstart] = ( $rstart - $rend ); // set start date + rdate duration in seconds |
|
940 | + if ((($startDate - $rdurWsecs) <= $rstart) && ($endDate >= $rstart)) |
|
941 | + $recurlist[$rstart] = ($rstart - $rend); // set start date + rdate duration in seconds |
|
942 | 942 | } // PERIOD end |
943 | 943 | else { // single date |
944 | - $theRdate = $component->_date2timestamp( $theRdate ); |
|
945 | - if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate )) |
|
944 | + $theRdate = $component->_date2timestamp($theRdate); |
|
945 | + if ((($startDate - $rdurWsecs) <= $theRdate) && ($endDate >= $theRdate)) |
|
946 | 946 | $recurlist[$theRdate] = $rdurWsecs; // set start date + event duration in seconds |
947 | 947 | } |
948 | 948 | } |
949 | 949 | } |
950 | - if( 0 < count( $recurlist )) { |
|
951 | - ksort( $recurlist ); |
|
952 | - foreach( $recurlist as $recurkey => $durvalue ) { |
|
953 | - if((( $startDate - $rdurWsecs ) > $recurkey ) || ( $endDate < $recurkey )) // not within period |
|
950 | + if (0 < count($recurlist)) { |
|
951 | + ksort($recurlist); |
|
952 | + foreach ($recurlist as $recurkey => $durvalue) { |
|
953 | + if ((($startDate - $rdurWsecs) > $recurkey) || ($endDate < $recurkey)) // not within period |
|
954 | 954 | continue; |
955 | - if( isset( $exdatelist[$recurkey] )) // check excluded dates |
|
955 | + if (isset($exdatelist[$recurkey])) // check excluded dates |
|
956 | 956 | continue; |
957 | - if( $startWdate >= $recurkey ) // exclude component start date |
|
957 | + if ($startWdate >= $recurkey) // exclude component start date |
|
958 | 958 | continue; |
959 | 959 | $component2 = $component->copy(); |
960 | - $rstart = $component2->_timestamp2date( $recurkey, 6); |
|
960 | + $rstart = $component2->_timestamp2date($recurkey, 6); |
|
961 | 961 | $datevalue = $rstart['month'].'/'.$rstart['day'].'/'.$rstart['year']; |
962 | - if( isset( $start['hour'] ) || isset( $start['min'] ) || isset( $start['sec'] )) { |
|
963 | - $datevalue .= ( isset( $rstart['hour'] )) ? ' '.$rstart['hour'] : ' 00'; |
|
964 | - $datevalue .= ( isset( $rstart['min'] )) ? ':'.$rstart['min'] : ':00'; |
|
965 | - $datevalue .= ( isset( $rstart['sec'] )) ? ':'.$rstart['sec'] : ':00'; |
|
962 | + if (isset($start['hour']) || isset($start['min']) || isset($start['sec'])) { |
|
963 | + $datevalue .= (isset($rstart['hour'])) ? ' '.$rstart['hour'] : ' 00'; |
|
964 | + $datevalue .= (isset($rstart['min'])) ? ':'.$rstart['min'] : ':00'; |
|
965 | + $datevalue .= (isset($rstart['sec'])) ? ':'.$rstart['sec'] : ':00'; |
|
966 | 966 | } |
967 | - $datestring = date( $startDateFormat, strtotime( $datevalue )); |
|
968 | - if( isset( $start['tz'] )) |
|
967 | + $datestring = date($startDateFormat, strtotime($datevalue)); |
|
968 | + if (isset($start['tz'])) |
|
969 | 969 | $datestring .= ' '.$start['tz']; |
970 | - $component2->setProperty( 'X-CURRENT-DTSTART', $datestring ); |
|
971 | - $rend = $component2->_timestamp2date(( $recurkey + $durvalue ), 6); |
|
972 | - if( $dtendExist || $dueExist ) { |
|
973 | - if( $endAllDayEvent ) { |
|
974 | - $rend2 = mktime( 0, 0, 0, $rend['month'], ($rend['day'] + 1), $rend['year'] ); |
|
975 | - $datevalue = date( 'm', $rend2 ).'/'.date( 'd', $rend2 ).'/'.date( 'Y', $rend2 ); |
|
970 | + $component2->setProperty('X-CURRENT-DTSTART', $datestring); |
|
971 | + $rend = $component2->_timestamp2date(($recurkey + $durvalue), 6); |
|
972 | + if ($dtendExist || $dueExist) { |
|
973 | + if ($endAllDayEvent) { |
|
974 | + $rend2 = mktime(0, 0, 0, $rend['month'], ($rend['day'] + 1), $rend['year']); |
|
975 | + $datevalue = date('m', $rend2).'/'.date('d', $rend2).'/'.date('Y', $rend2); |
|
976 | 976 | } |
977 | 977 | else { |
978 | 978 | $datevalue = $rend['month'].'/'.$rend['day'].'/'.$rend['year']; |
979 | - if( isset( $end['hour'] ) || isset( $end['min'] ) || isset( $end['sec'] )) { |
|
980 | - $datevalue .= ( isset( $rend['hour'] )) ? ' '.$rend['hour'] : ' 00'; |
|
981 | - $datevalue .= ( isset( $rend['min'] )) ? ':'.$rend['min'] : ':00'; |
|
982 | - $datevalue .= ( isset( $rend['sec'] )) ? ':'.$rend['sec'] : ':00'; |
|
979 | + if (isset($end['hour']) || isset($end['min']) || isset($end['sec'])) { |
|
980 | + $datevalue .= (isset($rend['hour'])) ? ' '.$rend['hour'] : ' 00'; |
|
981 | + $datevalue .= (isset($rend['min'])) ? ':'.$rend['min'] : ':00'; |
|
982 | + $datevalue .= (isset($rend['sec'])) ? ':'.$rend['sec'] : ':00'; |
|
983 | 983 | } |
984 | 984 | } |
985 | - $datestring = date( $endDateFormat, strtotime( $datevalue )); |
|
986 | - if( isset( $end['tz'] )) |
|
985 | + $datestring = date($endDateFormat, strtotime($datevalue)); |
|
986 | + if (isset($end['tz'])) |
|
987 | 987 | $datestring .= ' '.$end['tz']; |
988 | - if( $dtendExist ) |
|
989 | - $component2->setProperty( 'X-CURRENT-DTEND', $datestring ); |
|
990 | - elseif( $dueExist ) |
|
991 | - $component2->setProperty( 'X-CURRENT-DUE', $datestring ); |
|
988 | + if ($dtendExist) |
|
989 | + $component2->setProperty('X-CURRENT-DTEND', $datestring); |
|
990 | + elseif ($dueExist) |
|
991 | + $component2->setProperty('X-CURRENT-DUE', $datestring); |
|
992 | 992 | } |
993 | - $rend = $component2->_date2timestamp( $rend ); |
|
993 | + $rend = $component2->_date2timestamp($rend); |
|
994 | 994 | $rstart = $recurkey; |
995 | 995 | /* add repeating components within valid dates to output array, only start date */ |
996 | - if( $flat ) |
|
996 | + if ($flat) |
|
997 | 997 | $result[] = $component2->copy(); // copy to output |
998 | - elseif( $split ) { |
|
999 | - if( $rend > $endDate ) |
|
998 | + elseif ($split) { |
|
999 | + if ($rend > $endDate) |
|
1000 | 1000 | $rend = $endDate; |
1001 | - while( $rstart <= $rend ) { // iterate |
|
1002 | - $wd = getdate( $rstart ); |
|
1003 | - if(( $rstart > $startDate ) && // date after dtstart |
|
1004 | - !isset( $exdatelist[$rstart] )) // check exclude date |
|
1001 | + while ($rstart <= $rend) { // iterate |
|
1002 | + $wd = getdate($rstart); |
|
1003 | + if (($rstart > $startDate) && // date after dtstart |
|
1004 | + !isset($exdatelist[$rstart])) // check exclude date |
|
1005 | 1005 | $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output |
1006 | - $rstart += ( 24*60*60 ); // step one day |
|
1006 | + $rstart += (24 * 60 * 60); // step one day |
|
1007 | 1007 | } |
1008 | 1008 | } |
1009 | - elseif(( $rstart >= $startDate ) && // date within period |
|
1010 | - !isset( $exdatelist[$rstart] )) { // check exclude date |
|
1011 | - $wd = getdate( $rstart ); |
|
1009 | + elseif (($rstart >= $startDate) && // date within period |
|
1010 | + !isset($exdatelist[$rstart])) { // check exclude date |
|
1011 | + $wd = getdate($rstart); |
|
1012 | 1012 | $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output |
1013 | 1013 | } |
1014 | 1014 | } |
1015 | 1015 | } |
1016 | 1016 | /* deselect components with startdate/enddate not within period */ |
1017 | - if(( $endWdate < $startDate ) || ( $startWdate > $endDate )) continue; |
|
1017 | + if (($endWdate < $startDate) || ($startWdate > $endDate)) continue; |
|
1018 | 1018 | } |
1019 | 1019 | /* deselect components with startdate not within period */ |
1020 | - elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) continue; |
|
1020 | + elseif (($startWdate < $startDate) || ($startWdate > $endDate)) continue; |
|
1021 | 1021 | /* add selected components within valid dates to output array */ |
1022 | - if( $flat ) |
|
1022 | + if ($flat) |
|
1023 | 1023 | $result[] = $component->copy(); // copy to output; |
1024 | - elseif( $split ) { |
|
1025 | - if( $endWdate > $endDate ) |
|
1026 | - $endWdate = $endDate; // use period end date |
|
1027 | - if( !isset( $exdatelist[$startWdate] )) { // check excluded dates |
|
1028 | - if( $startWdate < $startDate ) |
|
1024 | + elseif ($split) { |
|
1025 | + if ($endWdate > $endDate) |
|
1026 | + $endWdate = $endDate; // use period end date |
|
1027 | + if (!isset($exdatelist[$startWdate])) { // check excluded dates |
|
1028 | + if ($startWdate < $startDate) |
|
1029 | 1029 | $startWdate = $startDate; // use period start date |
1030 | - while( $startWdate <= $endWdate ) { // iterate |
|
1031 | - $wd = getdate( $startWdate ); |
|
1030 | + while ($startWdate <= $endWdate) { // iterate |
|
1031 | + $wd = getdate($startWdate); |
|
1032 | 1032 | $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output |
1033 | - $startWdate += ( 24*60*60 ); // step one day |
|
1033 | + $startWdate += (24 * 60 * 60); // step one day |
|
1034 | 1034 | } |
1035 | 1035 | } |
1036 | 1036 | } // use component date |
1037 | - elseif( !isset( $exdatelist[$startWdate] ) && // check excluded dates |
|
1038 | - ( $startWdate >= $startDate )) { // within period |
|
1039 | - $wd = getdate( $startWdate ); |
|
1037 | + elseif (!isset($exdatelist[$startWdate]) && // check excluded dates |
|
1038 | + ($startWdate >= $startDate)) { // within period |
|
1039 | + $wd = getdate($startWdate); |
|
1040 | 1040 | $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output |
1041 | 1041 | } |
1042 | 1042 | } |
1043 | - if( 0 >= count( $result )) return FALSE; |
|
1044 | - elseif( !$flat ) { |
|
1045 | - foreach( $result as $y => $yeararr ) { |
|
1046 | - foreach( $yeararr as $m => $montharr ) { |
|
1047 | - ksort( $result[$y][$m] ); |
|
1043 | + if (0 >= count($result)) return FALSE; |
|
1044 | + elseif (!$flat) { |
|
1045 | + foreach ($result as $y => $yeararr) { |
|
1046 | + foreach ($yeararr as $m => $montharr) { |
|
1047 | + ksort($result[$y][$m]); |
|
1048 | 1048 | } |
1049 | - ksort( $result[$y] ); |
|
1049 | + ksort($result[$y]); |
|
1050 | 1050 | } |
1051 | - ksort( $result ); |
|
1051 | + ksort($result); |
|
1052 | 1052 | } |
1053 | 1053 | return $result; |
1054 | 1054 | } |
@@ -1062,48 +1062,48 @@ discard block |
||
1062 | 1062 | * @param mixed $arg2 optional, ordno if arg1 = component type |
1063 | 1063 | * @return void |
1064 | 1064 | */ |
1065 | - function setComponent( $component, $arg1=FALSE, $arg2=FALSE ) { |
|
1066 | - if( '' >= $component->getConfig( 'language')) |
|
1067 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
1068 | - $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
|
1069 | - $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
|
1070 | - $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
|
1071 | - $component->setConfig( 'format', $this->getConfig( 'format' )); |
|
1072 | - if( !in_array( $component->objName, array( 'valarm', 'vtimezone' ))) { |
|
1073 | - unset( $component->propix ); |
|
1065 | + function setComponent($component, $arg1 = FALSE, $arg2 = FALSE) { |
|
1066 | + if ('' >= $component->getConfig('language')) |
|
1067 | + $component->setConfig('language', $this->getConfig('language')); |
|
1068 | + $component->setConfig('allowEmpty', $this->getConfig('allowEmpty')); |
|
1069 | + $component->setConfig('nl', $this->getConfig('nl')); |
|
1070 | + $component->setConfig('unique_id', $this->getConfig('unique_id')); |
|
1071 | + $component->setConfig('format', $this->getConfig('format')); |
|
1072 | + if (!in_array($component->objName, array('valarm', 'vtimezone'))) { |
|
1073 | + unset($component->propix); |
|
1074 | 1074 | /* make sure dtstamp and uid is set */ |
1075 | - $dummy1 = $component->getProperty( 'dtstamp' ); |
|
1076 | - $dummy2 = $component->getProperty( 'uid' ); |
|
1075 | + $dummy1 = $component->getProperty('dtstamp'); |
|
1076 | + $dummy2 = $component->getProperty('uid'); |
|
1077 | 1077 | } |
1078 | - if( !$arg1 ) { |
|
1078 | + if (!$arg1) { |
|
1079 | 1079 | $this->components[] = $component->copy(); |
1080 | 1080 | return TRUE; |
1081 | 1081 | } |
1082 | 1082 | $argType = $index = null; |
1083 | - if ( ctype_digit( (string) $arg1 )) { |
|
1083 | + if (ctype_digit((string) $arg1)) { |
|
1084 | 1084 | $argType = 'INDEX'; |
1085 | 1085 | $index = (int) $arg1 - 1; |
1086 | 1086 | } |
1087 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
1088 | - $argType = strtolower( $arg1 ); |
|
1089 | - $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0; |
|
1087 | + elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) { |
|
1088 | + $argType = strtolower($arg1); |
|
1089 | + $index = (ctype_digit((string) $arg2)) ? ((int) $arg2) - 1 : 0; |
|
1090 | 1090 | } |
1091 | 1091 | $cix1sC = 0; |
1092 | - foreach ( $this->components as $cix => $component2) { |
|
1093 | - if( empty( $component2 )) continue; |
|
1094 | - unset( $component2->propix ); |
|
1095 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
|
1092 | + foreach ($this->components as $cix => $component2) { |
|
1093 | + if (empty($component2)) continue; |
|
1094 | + unset($component2->propix); |
|
1095 | + if (('INDEX' == $argType) && ($index == $cix)) { |
|
1096 | 1096 | $this->components[$cix] = $component->copy(); |
1097 | 1097 | return TRUE; |
1098 | 1098 | } |
1099 | - elseif( $argType == $component2->objName ) { |
|
1100 | - if( $index == $cix1sC ) { |
|
1099 | + elseif ($argType == $component2->objName) { |
|
1100 | + if ($index == $cix1sC) { |
|
1101 | 1101 | $this->components[$cix] = $component->copy(); |
1102 | 1102 | return TRUE; |
1103 | 1103 | } |
1104 | 1104 | $cix1sC++; |
1105 | 1105 | } |
1106 | - elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) { |
|
1106 | + elseif (!$argType && ($arg1 == $component2->getProperty('uid'))) { |
|
1107 | 1107 | $this->components[$cix] = $component->copy(); |
1108 | 1108 | return TRUE; |
1109 | 1109 | } |
@@ -1124,79 +1124,79 @@ discard block |
||
1124 | 1124 | * |
1125 | 1125 | */ |
1126 | 1126 | function sort() { |
1127 | - if( is_array( $this->components )) { |
|
1128 | - $this->_sortkeys = array( 'year', 'month', 'day', 'hour', 'min', 'sec' ); |
|
1129 | - usort( $this->components, array( $this, '_cmpfcn' )); |
|
1130 | - } |
|
1131 | - } |
|
1132 | - function _cmpfcn( $a, $b ) { |
|
1133 | - if( empty( $a )) return -1; |
|
1134 | - if( empty( $b )) return 1; |
|
1135 | - if( 'vtimezone' == $a->objName) return -1; |
|
1136 | - if( 'vtimezone' == $b->objName) return 1; |
|
1137 | - $astart = ( isset( $a->xprop['X-CURRENT-DTSTART']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTSTART']['value'] ) : null; |
|
1138 | - if( empty( $astart ) && isset( $a->dtstart['value'] )) |
|
1127 | + if (is_array($this->components)) { |
|
1128 | + $this->_sortkeys = array('year', 'month', 'day', 'hour', 'min', 'sec'); |
|
1129 | + usort($this->components, array($this, '_cmpfcn')); |
|
1130 | + } |
|
1131 | + } |
|
1132 | + function _cmpfcn($a, $b) { |
|
1133 | + if (empty($a)) return -1; |
|
1134 | + if (empty($b)) return 1; |
|
1135 | + if ('vtimezone' == $a->objName) return -1; |
|
1136 | + if ('vtimezone' == $b->objName) return 1; |
|
1137 | + $astart = (isset($a->xprop['X-CURRENT-DTSTART']['value'])) ? $a->_date_time_string($a->xprop['X-CURRENT-DTSTART']['value']) : null; |
|
1138 | + if (empty($astart) && isset($a->dtstart['value'])) |
|
1139 | 1139 | $astart = & $a->dtstart['value']; |
1140 | - $bstart = ( isset( $b->xprop['X-CURRENT-DTSTART']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTSTART']['value'] ) : null; |
|
1141 | - if( empty( $bstart ) && isset( $b->dtstart['value'] )) |
|
1140 | + $bstart = (isset($b->xprop['X-CURRENT-DTSTART']['value'])) ? $b->_date_time_string($b->xprop['X-CURRENT-DTSTART']['value']) : null; |
|
1141 | + if (empty($bstart) && isset($b->dtstart['value'])) |
|
1142 | 1142 | $bstart = & $b->dtstart['value']; |
1143 | - if( empty( $astart )) return -1; |
|
1144 | - elseif( empty( $bstart )) return 1; |
|
1145 | - foreach( $this->_sortkeys as $key ) { |
|
1146 | - if ( empty( $astart[$key] )) return -1; |
|
1147 | - elseif( empty( $bstart[$key] )) return 1; |
|
1148 | - if ( $astart[$key] == $bstart[$key]) continue; |
|
1149 | - if (( (int) $astart[$key] ) < ((int) $bstart[$key] )) |
|
1143 | + if (empty($astart)) return -1; |
|
1144 | + elseif (empty($bstart)) return 1; |
|
1145 | + foreach ($this->_sortkeys as $key) { |
|
1146 | + if (empty($astart[$key])) return -1; |
|
1147 | + elseif (empty($bstart[$key])) return 1; |
|
1148 | + if ($astart[$key] == $bstart[$key]) continue; |
|
1149 | + if (((int) $astart[$key]) < ((int) $bstart[$key])) |
|
1150 | 1150 | return -1; |
1151 | - elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] )) |
|
1151 | + elseif (((int) $astart[$key]) > ((int) $bstart[$key])) |
|
1152 | 1152 | return 1; |
1153 | 1153 | } |
1154 | - $c = ( isset( $a->xprop['X-CURRENT-DTEND']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTEND']['value'] ) : null; |
|
1155 | - if( empty( $c ) && !empty( $a->dtend['value'] )) |
|
1154 | + $c = (isset($a->xprop['X-CURRENT-DTEND']['value'])) ? $a->_date_time_string($a->xprop['X-CURRENT-DTEND']['value']) : null; |
|
1155 | + if (empty($c) && !empty($a->dtend['value'])) |
|
1156 | 1156 | $c = & $a->dtend['value']; |
1157 | - if( empty( $c ) && isset( $a->xprop['X-CURRENT-DUE']['value'] )) |
|
1158 | - $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] ); |
|
1159 | - if( empty( $c ) && !empty( $a->due['value'] )) |
|
1157 | + if (empty($c) && isset($a->xprop['X-CURRENT-DUE']['value'])) |
|
1158 | + $c = $a->_date_time_string($a->xprop['X-CURRENT-DUE']['value']); |
|
1159 | + if (empty($c) && !empty($a->due['value'])) |
|
1160 | 1160 | $c = & $a->due['value']; |
1161 | - if( empty( $c ) && !empty( $a->duration['value'] )) |
|
1161 | + if (empty($c) && !empty($a->duration['value'])) |
|
1162 | 1162 | $c = $a->duration2date(); |
1163 | - $d = ( isset( $b->xprop['X-CURRENT-DTEND']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTEND']['value'] ) : null; |
|
1164 | - if( empty( $d ) && !empty( $b->dtend['value'] )) |
|
1163 | + $d = (isset($b->xprop['X-CURRENT-DTEND']['value'])) ? $b->_date_time_string($b->xprop['X-CURRENT-DTEND']['value']) : null; |
|
1164 | + if (empty($d) && !empty($b->dtend['value'])) |
|
1165 | 1165 | $d = & $b->dtend['value']; |
1166 | - if( empty( $d ) && isset( $b->xprop['X-CURRENT-DUE']['value'] )) |
|
1167 | - $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] ); |
|
1168 | - if( empty( $d ) && !empty( $b->due['value'] )) |
|
1166 | + if (empty($d) && isset($b->xprop['X-CURRENT-DUE']['value'])) |
|
1167 | + $d = $b->_date_time_string($b->xprop['X-CURRENT-DUE']['value']); |
|
1168 | + if (empty($d) && !empty($b->due['value'])) |
|
1169 | 1169 | $d = & $b->due['value']; |
1170 | - if( empty( $d ) && !empty( $b->duration['value'] )) |
|
1170 | + if (empty($d) && !empty($b->duration['value'])) |
|
1171 | 1171 | $d = $b->duration2date(); |
1172 | - if( empty( $c )) return -1; |
|
1173 | - elseif( empty( $d )) return 1; |
|
1174 | - foreach( $this->_sortkeys as $key ) { |
|
1175 | - if ( !isset( $c[$key] )) return -1; |
|
1176 | - elseif( !isset( $d[$key] )) return 1; |
|
1177 | - if ( $c[$key] == $d[$key] ) continue; |
|
1178 | - if (( (int) $c[$key] ) < ((int) $d[$key])) return -1; |
|
1179 | - elseif(( (int) $c[$key] ) > ((int) $d[$key])) return 1; |
|
1180 | - } |
|
1181 | - if( isset( $a->created['value'] )) |
|
1172 | + if (empty($c)) return -1; |
|
1173 | + elseif (empty($d)) return 1; |
|
1174 | + foreach ($this->_sortkeys as $key) { |
|
1175 | + if (!isset($c[$key])) return -1; |
|
1176 | + elseif (!isset($d[$key])) return 1; |
|
1177 | + if ($c[$key] == $d[$key]) continue; |
|
1178 | + if (((int) $c[$key]) < ((int) $d[$key])) return -1; |
|
1179 | + elseif (((int) $c[$key]) > ((int) $d[$key])) return 1; |
|
1180 | + } |
|
1181 | + if (isset($a->created['value'])) |
|
1182 | 1182 | $e = & $a->created['value']; |
1183 | 1183 | else |
1184 | 1184 | $e = & $a->dtstamp['value']; |
1185 | - if( isset( $b->created['value'] )) |
|
1185 | + if (isset($b->created['value'])) |
|
1186 | 1186 | $f = & $b->created['value']; |
1187 | 1187 | else |
1188 | 1188 | $f = & $b->dtstamp['value']; |
1189 | - foreach( $this->_sortkeys as $key ) { |
|
1190 | - if( !isset( $e[$key] )) return -1; |
|
1191 | - elseif( !isset( $f[$key] )) return 1; |
|
1192 | - if ( $e[$key] == $f[$key] ) continue; |
|
1193 | - if (( (int) $e[$key] ) < ((int) $f[$key])) return -1; |
|
1194 | - elseif(( (int) $e[$key] ) > ((int) $f[$key])) return 1; |
|
1195 | - } |
|
1196 | - if (( $a->uid['value'] ) < |
|
1197 | - ( $b->uid['value'] )) return -1; |
|
1198 | - elseif(( $a->uid['value'] ) > |
|
1199 | - ( $b->uid['value'] )) return 1; |
|
1189 | + foreach ($this->_sortkeys as $key) { |
|
1190 | + if (!isset($e[$key])) return -1; |
|
1191 | + elseif (!isset($f[$key])) return 1; |
|
1192 | + if ($e[$key] == $f[$key]) continue; |
|
1193 | + if (((int) $e[$key]) < ((int) $f[$key])) return -1; |
|
1194 | + elseif (((int) $e[$key]) > ((int) $f[$key])) return 1; |
|
1195 | + } |
|
1196 | + if (($a->uid['value']) < |
|
1197 | + ($b->uid['value'])) return -1; |
|
1198 | + elseif (($a->uid['value']) > |
|
1199 | + ($b->uid['value'])) return 1; |
|
1200 | 1200 | return 0; |
1201 | 1201 | } |
1202 | 1202 | /** |
@@ -1208,104 +1208,104 @@ discard block |
||
1208 | 1208 | * @return bool FALSE if error occurs during parsing |
1209 | 1209 | * |
1210 | 1210 | */ |
1211 | - function parse( $filename=FALSE ) { |
|
1212 | - if( !$filename ) { |
|
1211 | + function parse($filename = FALSE) { |
|
1212 | + if (!$filename) { |
|
1213 | 1213 | /* directory/filename previous set via setConfig directory+filename / url */ |
1214 | - if( FALSE === ( $filename = $this->getConfig( 'url' ))) |
|
1215 | - $filename = $this->getConfig( 'dirfile' ); |
|
1214 | + if (FALSE === ($filename = $this->getConfig('url'))) |
|
1215 | + $filename = $this->getConfig('dirfile'); |
|
1216 | 1216 | } |
1217 | - elseif(( 'http://' == strtolower( substr( $filename, 0, 7 ))) || |
|
1218 | - ( 'webcal://' == strtolower( substr( $filename, 0, 9 )))) { |
|
1217 | + elseif (('http://' == strtolower(substr($filename, 0, 7))) || |
|
1218 | + ('webcal://' == strtolower(substr($filename, 0, 9)))) { |
|
1219 | 1219 | /* remote file - URL */ |
1220 | - $this->setConfig( 'URL', $filename ); |
|
1221 | - if( !$filename = $this->getConfig( 'url' )) |
|
1222 | - return FALSE; /* err 2 */ |
|
1220 | + $this->setConfig('URL', $filename); |
|
1221 | + if (!$filename = $this->getConfig('url')) |
|
1222 | + return FALSE; /* err 2 */ |
|
1223 | 1223 | } |
1224 | 1224 | else { |
1225 | 1225 | /* local directory/filename */ |
1226 | - $parts = pathinfo( $filename ); |
|
1227 | - if( !empty( $parts['dirname'] ) && ( '.' != $parts['dirname'] )) { |
|
1228 | - if( !$this->setConfig( 'directory', $parts['dirname'] )) |
|
1229 | - return FALSE; /* err 3 */ |
|
1226 | + $parts = pathinfo($filename); |
|
1227 | + if (!empty($parts['dirname']) && ('.' != $parts['dirname'])) { |
|
1228 | + if (!$this->setConfig('directory', $parts['dirname'])) |
|
1229 | + return FALSE; /* err 3 */ |
|
1230 | 1230 | } |
1231 | - if( !$this->setConfig( 'filename', $parts['basename'] )) |
|
1232 | - return FALSE; /* err 4 */ |
|
1231 | + if (!$this->setConfig('filename', $parts['basename'])) |
|
1232 | + return FALSE; /* err 4 */ |
|
1233 | 1233 | } |
1234 | - if( 'http://' != substr( $filename, 0, 7 )) { |
|
1234 | + if ('http://' != substr($filename, 0, 7)) { |
|
1235 | 1235 | /* local file error tests */ |
1236 | - if( !is_file( $filename )) /* err 5 */ |
|
1236 | + if (!is_file($filename)) /* err 5 */ |
|
1237 | 1237 | return FALSE; |
1238 | - if( !is_readable( $filename )) |
|
1239 | - return FALSE; /* err 6 */ |
|
1240 | - if( !filesize( $filename )) |
|
1241 | - return FALSE; /* err 7 */ |
|
1238 | + if (!is_readable($filename)) |
|
1239 | + return FALSE; /* err 6 */ |
|
1240 | + if (!filesize($filename)) |
|
1241 | + return FALSE; /* err 7 */ |
|
1242 | 1242 | clearstatcache(); |
1243 | 1243 | } |
1244 | 1244 | /* READ FILE */ |
1245 | - if( FALSE === ( $rows = file( $filename ))) |
|
1246 | - return FALSE; /* err 1 */ |
|
1245 | + if (FALSE === ($rows = file($filename))) |
|
1246 | + return FALSE; /* err 1 */ |
|
1247 | 1247 | /* identify BEGIN:VCALENDAR, MUST be first row */ |
1248 | - if( 'BEGIN:VCALENDAR' != strtoupper( trim( $rows[0] ))) |
|
1249 | - return FALSE; /* err 8 */ |
|
1248 | + if ('BEGIN:VCALENDAR' != strtoupper(trim($rows[0]))) |
|
1249 | + return FALSE; /* err 8 */ |
|
1250 | 1250 | /* remove empty trailing lines */ |
1251 | - while( '' == trim( $rows[count( $rows ) - 1] )) { |
|
1252 | - unset( $rows[count( $rows ) - 1] ); |
|
1253 | - $rows = array_values( $rows ); |
|
1251 | + while ('' == trim($rows[count($rows) - 1])) { |
|
1252 | + unset($rows[count($rows) - 1]); |
|
1253 | + $rows = array_values($rows); |
|
1254 | 1254 | } |
1255 | 1255 | /* identify ending END:VCALENDAR row */ |
1256 | - if( 'END:VCALENDAR' != strtoupper( trim( $rows[count( $rows ) - 1] ))) { |
|
1257 | - return FALSE; /* err 9 */ |
|
1256 | + if ('END:VCALENDAR' != strtoupper(trim($rows[count($rows) - 1]))) { |
|
1257 | + return FALSE; /* err 9 */ |
|
1258 | 1258 | } |
1259 | - if( 3 > count( $rows )) |
|
1260 | - return FALSE; /* err 10 */ |
|
1259 | + if (3 > count($rows)) |
|
1260 | + return FALSE; /* err 10 */ |
|
1261 | 1261 | $comp = $subcomp = null; |
1262 | 1262 | $actcomp = & $this; |
1263 | - $nl = $this->getConfig( 'nl' ); |
|
1263 | + $nl = $this->getConfig('nl'); |
|
1264 | 1264 | $calsync = 0; |
1265 | 1265 | /* identify components and update unparsed data within component */ |
1266 | - foreach( $rows as $line ) { |
|
1267 | - if( '' == trim( $line )) |
|
1266 | + foreach ($rows as $line) { |
|
1267 | + if ('' == trim($line)) |
|
1268 | 1268 | continue; |
1269 | - if( $nl == substr( $line, 0 - strlen( $nl ))) |
|
1270 | - $line = substr( $line, 0, ( strlen( $line ) - strlen( $nl ))).'\n'; |
|
1271 | - if( 'BEGIN:VCALENDAR' == strtoupper( substr( $line, 0, 15 ))) { |
|
1269 | + if ($nl == substr($line, 0 - strlen($nl))) |
|
1270 | + $line = substr($line, 0, (strlen($line) - strlen($nl))).'\n'; |
|
1271 | + if ('BEGIN:VCALENDAR' == strtoupper(substr($line, 0, 15))) { |
|
1272 | 1272 | $calsync++; |
1273 | 1273 | continue; |
1274 | 1274 | } |
1275 | - elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) { |
|
1275 | + elseif ('END:VCALENDAR' == strtoupper(substr($line, 0, 13))) { |
|
1276 | 1276 | $calsync--; |
1277 | 1277 | continue; |
1278 | 1278 | } |
1279 | - elseif( 1 != $calsync ) |
|
1280 | - return FALSE; /* err 20 */ |
|
1281 | - if( 'END:' == strtoupper( substr( $line, 0, 4 ))) { |
|
1282 | - if( null != $subcomp ) { |
|
1283 | - $comp->setComponent( $subcomp ); |
|
1279 | + elseif (1 != $calsync) |
|
1280 | + return FALSE; /* err 20 */ |
|
1281 | + if ('END:' == strtoupper(substr($line, 0, 4))) { |
|
1282 | + if (null != $subcomp) { |
|
1283 | + $comp->setComponent($subcomp); |
|
1284 | 1284 | $subcomp = null; |
1285 | 1285 | } |
1286 | 1286 | else { |
1287 | - $this->setComponent( $comp ); |
|
1287 | + $this->setComponent($comp); |
|
1288 | 1288 | $comp = null; |
1289 | 1289 | } |
1290 | 1290 | $actcomp = null; |
1291 | 1291 | continue; |
1292 | 1292 | } // end - if ( 'END:' ==.. . |
1293 | - elseif( 'BEGIN:' == strtoupper( substr( $line, 0, 6 ))) { |
|
1294 | - $line = str_replace( '\n', '', $line ); |
|
1295 | - $compname = trim (strtoupper( substr( $line, 6 ))); |
|
1296 | - if( null != $comp ) { |
|
1297 | - if( 'VALARM' == $compname ) |
|
1293 | + elseif ('BEGIN:' == strtoupper(substr($line, 0, 6))) { |
|
1294 | + $line = str_replace('\n', '', $line); |
|
1295 | + $compname = trim(strtoupper(substr($line, 6))); |
|
1296 | + if (null != $comp) { |
|
1297 | + if ('VALARM' == $compname) |
|
1298 | 1298 | $subcomp = new valarm(); |
1299 | - elseif( 'STANDARD' == $compname ) |
|
1300 | - $subcomp = new vtimezone( 'STANDARD' ); |
|
1301 | - elseif( 'DAYLIGHT' == $compname ) |
|
1302 | - $subcomp = new vtimezone( 'DAYLIGHT' ); |
|
1299 | + elseif ('STANDARD' == $compname) |
|
1300 | + $subcomp = new vtimezone('STANDARD'); |
|
1301 | + elseif ('DAYLIGHT' == $compname) |
|
1302 | + $subcomp = new vtimezone('DAYLIGHT'); |
|
1303 | 1303 | else |
1304 | 1304 | return FALSE; /* err 6 */ |
1305 | 1305 | $actcomp = & $subcomp; |
1306 | 1306 | } |
1307 | 1307 | else { |
1308 | - switch( $compname ) { |
|
1308 | + switch ($compname) { |
|
1309 | 1309 | case 'VALARM': |
1310 | 1310 | $comp = new valarm(); |
1311 | 1311 | break; |
@@ -1336,74 +1336,74 @@ discard block |
||
1336 | 1336 | $actcomp->unparsed[] = $line; |
1337 | 1337 | } // end - foreach( rows.. . |
1338 | 1338 | /* parse data for calendar (this) object */ |
1339 | - if( is_array( $this->unparsed ) && ( 0 < count( $this->unparsed ))) { |
|
1339 | + if (is_array($this->unparsed) && (0 < count($this->unparsed))) { |
|
1340 | 1340 | /* concatenate property values spread over several lines */ |
1341 | 1341 | $lastix = -1; |
1342 | - $propnames = array( 'calscale','method','prodid','version','x-' ); |
|
1342 | + $propnames = array('calscale', 'method', 'prodid', 'version', 'x-'); |
|
1343 | 1343 | $proprows = array(); |
1344 | - foreach( $this->unparsed as $line ) { |
|
1344 | + foreach ($this->unparsed as $line) { |
|
1345 | 1345 | $newProp = FALSE; |
1346 | - foreach ( $propnames as $propname ) { |
|
1347 | - if( $propname == strtolower( substr( $line, 0, strlen( $propname )))) { |
|
1346 | + foreach ($propnames as $propname) { |
|
1347 | + if ($propname == strtolower(substr($line, 0, strlen($propname)))) { |
|
1348 | 1348 | $newProp = TRUE; |
1349 | 1349 | break; |
1350 | 1350 | } |
1351 | 1351 | } |
1352 | - if( $newProp ) { |
|
1352 | + if ($newProp) { |
|
1353 | 1353 | $newProp = FALSE; |
1354 | 1354 | $lastix++; |
1355 | - $proprows[$lastix] = $line; |
|
1355 | + $proprows[$lastix] = $line; |
|
1356 | 1356 | } |
1357 | 1357 | else { |
1358 | 1358 | /* remove line breaks */ |
1359 | - if(( '\n' == substr( $proprows[$lastix], -2 )) && |
|
1360 | - ( ' ' == substr( $line, 0, 1 ))) { |
|
1361 | - $proprows[$lastix] = substr( $proprows[$lastix], 0, strlen( $proprows[$lastix] ) - 2 ); |
|
1362 | - $line = substr( $line, 1 ); |
|
1359 | + if (('\n' == substr($proprows[$lastix], -2)) && |
|
1360 | + (' ' == substr($line, 0, 1))) { |
|
1361 | + $proprows[$lastix] = substr($proprows[$lastix], 0, strlen($proprows[$lastix]) - 2); |
|
1362 | + $line = substr($line, 1); |
|
1363 | 1363 | } |
1364 | 1364 | $proprows[$lastix] .= $line; |
1365 | 1365 | } |
1366 | 1366 | } |
1367 | 1367 | $toolbox = new calendarComponent(); |
1368 | - foreach( $proprows as $line ) { |
|
1369 | - if( '\n' == substr( $line, -2 )) |
|
1370 | - $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
1368 | + foreach ($proprows as $line) { |
|
1369 | + if ('\n' == substr($line, -2)) |
|
1370 | + $line = substr($line, 0, strlen($line) - 2); |
|
1371 | 1371 | /* get propname */ |
1372 | 1372 | $cix = $propname = null; |
1373 | - for( $cix=0; $cix < strlen( $line ); $cix++ ) { |
|
1374 | - if( in_array( $line{$cix}, array( ':', ';' ))) |
|
1373 | + for ($cix = 0; $cix < strlen($line); $cix++) { |
|
1374 | + if (in_array($line{$cix}, array(':', ';'))) |
|
1375 | 1375 | break; |
1376 | 1376 | else |
1377 | 1377 | $propname .= $line{$cix}; |
1378 | 1378 | } |
1379 | 1379 | /* ignore version/prodid properties */ |
1380 | - if( in_array( strtoupper( $propname ), array( 'VERSION', 'PRODID' ))) |
|
1380 | + if (in_array(strtoupper($propname), array('VERSION', 'PRODID'))) |
|
1381 | 1381 | continue; |
1382 | - $line = substr( $line, $cix); |
|
1382 | + $line = substr($line, $cix); |
|
1383 | 1383 | /* separate attributes from value */ |
1384 | 1384 | $attr = array(); |
1385 | 1385 | $attrix = -1; |
1386 | - $strlen = strlen( $line ); |
|
1387 | - for( $cix=0; $cix < $strlen; $cix++ ) { |
|
1388 | - if(( ':' == $line{$cix} ) && |
|
1389 | - ( '://' != substr( $line, $cix, 3 )) && |
|
1390 | - ( 'mailto:' != strtolower( substr( $line, $cix - 6, 7 )))) { |
|
1386 | + $strlen = strlen($line); |
|
1387 | + for ($cix = 0; $cix < $strlen; $cix++) { |
|
1388 | + if ((':' == $line{$cix} ) && |
|
1389 | + ('://' != substr($line, $cix, 3)) && |
|
1390 | + ('mailto:' != strtolower(substr($line, $cix - 6, 7)))) { |
|
1391 | 1391 | $attrEnd = TRUE; |
1392 | - if(( $cix < ( $strlen - 4 )) && |
|
1393 | - ctype_digit( substr( $line, $cix+1, 4 ))) { // an URI with a (4pos) portnr?? |
|
1394 | - for( $c2ix = $cix; 3 < $c2ix; $c2ix-- ) { |
|
1395 | - if( '://' == substr( $line, $c2ix - 2, 3 )) { |
|
1392 | + if (($cix < ($strlen - 4)) && |
|
1393 | + ctype_digit(substr($line, $cix + 1, 4))) { // an URI with a (4pos) portnr?? |
|
1394 | + for ($c2ix = $cix; 3 < $c2ix; $c2ix--) { |
|
1395 | + if ('://' == substr($line, $c2ix - 2, 3)) { |
|
1396 | 1396 | $attrEnd = FALSE; |
1397 | 1397 | break; // an URI with a portnr!! |
1398 | 1398 | } |
1399 | 1399 | } |
1400 | 1400 | } |
1401 | - if( $attrEnd) { |
|
1402 | - $line = substr( $line, $cix + 1 ); |
|
1401 | + if ($attrEnd) { |
|
1402 | + $line = substr($line, $cix + 1); |
|
1403 | 1403 | break; |
1404 | 1404 | } |
1405 | 1405 | } |
1406 | - if( ';' == $line{$cix} ) |
|
1406 | + if (';' == $line{$cix} ) |
|
1407 | 1407 | $attr[++$attrix] = null; |
1408 | 1408 | else |
1409 | 1409 | $attr[$attrix] .= $line{$cix}; |
@@ -1411,46 +1411,46 @@ discard block |
||
1411 | 1411 | |
1412 | 1412 | /* make attributes in array format */ |
1413 | 1413 | $propattr = array(); |
1414 | - foreach( $attr as $attribute ) { |
|
1415 | - $attrsplit = explode( '=', $attribute, 2 ); |
|
1416 | - if( 1 < count( $attrsplit )) |
|
1414 | + foreach ($attr as $attribute) { |
|
1415 | + $attrsplit = explode('=', $attribute, 2); |
|
1416 | + if (1 < count($attrsplit)) |
|
1417 | 1417 | $propattr[$attrsplit[0]] = $attrsplit[1]; |
1418 | 1418 | else |
1419 | 1419 | $propattr[] = $attribute; |
1420 | 1420 | } |
1421 | 1421 | /* update Property */ |
1422 | - if( FALSE !== strpos( $line, ',' )) { |
|
1423 | - $content = explode( ',', $line ); |
|
1424 | - $clen = count( $content ); |
|
1425 | - for( $cix = 0; $cix < $clen; $cix++ ) { |
|
1426 | - if( "\\" == substr( $content[$cix], -1 )) { |
|
1422 | + if (FALSE !== strpos($line, ',')) { |
|
1423 | + $content = explode(',', $line); |
|
1424 | + $clen = count($content); |
|
1425 | + for ($cix = 0; $cix < $clen; $cix++) { |
|
1426 | + if ("\\" == substr($content[$cix], -1)) { |
|
1427 | 1427 | $content[$cix] .= ','.$content[$cix + 1]; |
1428 | - unset( $content[$cix + 1] ); |
|
1428 | + unset($content[$cix + 1]); |
|
1429 | 1429 | $cix++; |
1430 | 1430 | } |
1431 | 1431 | } |
1432 | - if( 1 < count( $content )) { |
|
1433 | - foreach( $content as $cix => $contentPart ) |
|
1434 | - $content[$cix] = $toolbox->_strunrep( $contentPart ); |
|
1435 | - $this->setProperty( $propname, $content, $propattr ); |
|
1432 | + if (1 < count($content)) { |
|
1433 | + foreach ($content as $cix => $contentPart) |
|
1434 | + $content[$cix] = $toolbox->_strunrep($contentPart); |
|
1435 | + $this->setProperty($propname, $content, $propattr); |
|
1436 | 1436 | continue; |
1437 | 1437 | } |
1438 | 1438 | else |
1439 | - $line = reset( $content ); |
|
1440 | - $line = $toolbox->_strunrep( $line ); |
|
1439 | + $line = reset($content); |
|
1440 | + $line = $toolbox->_strunrep($line); |
|
1441 | 1441 | } |
1442 | - $this->setProperty( $propname, trim( $line ), $propattr ); |
|
1442 | + $this->setProperty($propname, trim($line), $propattr); |
|
1443 | 1443 | } // end - foreach( $this->unparsed.. . |
1444 | 1444 | } // end - if( is_array( $this->unparsed.. . |
1445 | 1445 | /* parse Components */ |
1446 | - if( is_array( $this->components ) && ( 0 < count( $this->components ))) { |
|
1447 | - for( $six = 0; $six < count( $this->components ); $six++ ) { |
|
1448 | - if( !empty( $this->components[$six] )) |
|
1446 | + if (is_array($this->components) && (0 < count($this->components))) { |
|
1447 | + for ($six = 0; $six < count($this->components); $six++) { |
|
1448 | + if (!empty($this->components[$six])) |
|
1449 | 1449 | $this->components[$six]->parse(); |
1450 | 1450 | } |
1451 | 1451 | } |
1452 | 1452 | else |
1453 | - return FALSE; /* err 91 or something.. . */ |
|
1453 | + return FALSE; /* err 91 or something.. . */ |
|
1454 | 1454 | return TRUE; |
1455 | 1455 | } |
1456 | 1456 | /*********************************************************************************/ |
@@ -1463,7 +1463,7 @@ discard block |
||
1463 | 1463 | */ |
1464 | 1464 | function createCalendar() { |
1465 | 1465 | $calendarInit1 = $calendarInit2 = $calendarxCaldecl = $calendarStart = $calendar = null; |
1466 | - switch( $this->format ) { |
|
1466 | + switch ($this->format) { |
|
1467 | 1467 | case 'xcal': |
1468 | 1468 | $calendarInit1 = '<?xml version="1.0" encoding="UTF-8"?>'.$this->nl. |
1469 | 1469 | '<!DOCTYPE iCalendar PUBLIC "-//IETF//DTD XCAL/iCalendar XML//EN"'.$this->nl. |
@@ -1479,38 +1479,38 @@ discard block |
||
1479 | 1479 | $calendarStart .= $this->createMethod(); |
1480 | 1480 | $calendarStart .= $this->createProdid(); |
1481 | 1481 | $calendarStart .= $this->createVersion(); |
1482 | - switch( $this->format ) { |
|
1482 | + switch ($this->format) { |
|
1483 | 1483 | case 'xcal': |
1484 | - $nlstrlen = strlen( $this->nl ); |
|
1485 | - if( $this->nl == substr( $calendarStart, ( 0 - $nlstrlen ))) |
|
1486 | - $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen )); |
|
1484 | + $nlstrlen = strlen($this->nl); |
|
1485 | + if ($this->nl == substr($calendarStart, (0 - $nlstrlen))) |
|
1486 | + $calendarStart = substr($calendarStart, 0, (strlen($calendarStart) - $nlstrlen)); |
|
1487 | 1487 | $calendarStart .= '>'.$this->nl; |
1488 | 1488 | break; |
1489 | 1489 | default: |
1490 | 1490 | break; |
1491 | 1491 | } |
1492 | 1492 | $calendar .= $this->createXprop(); |
1493 | - foreach( $this->components as $component ) { |
|
1494 | - if( empty( $component )) continue; |
|
1495 | - if( '' >= $component->getConfig( 'language')) |
|
1496 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
1497 | - $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
|
1498 | - $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
|
1499 | - $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
|
1500 | - $component->setConfig( 'format', $this->getConfig( 'format' )); |
|
1501 | - $calendar .= $component->createComponent( $this->xcaldecl ); |
|
1502 | - } |
|
1503 | - if(( 0 < count( $this->xcaldecl )) && ( 'xcal' == $this->format )) { // xCal only |
|
1493 | + foreach ($this->components as $component) { |
|
1494 | + if (empty($component)) continue; |
|
1495 | + if ('' >= $component->getConfig('language')) |
|
1496 | + $component->setConfig('language', $this->getConfig('language')); |
|
1497 | + $component->setConfig('allowEmpty', $this->getConfig('allowEmpty')); |
|
1498 | + $component->setConfig('nl', $this->getConfig('nl')); |
|
1499 | + $component->setConfig('unique_id', $this->getConfig('unique_id')); |
|
1500 | + $component->setConfig('format', $this->getConfig('format')); |
|
1501 | + $calendar .= $component->createComponent($this->xcaldecl); |
|
1502 | + } |
|
1503 | + if ((0 < count($this->xcaldecl)) && ('xcal' == $this->format)) { // xCal only |
|
1504 | 1504 | $calendarInit1 .= $this->nl.'['.$this->nl; |
1505 | 1505 | $old_xcaldecl = array(); |
1506 | - foreach( $this->xcaldecl as $declix => $declPart ) { |
|
1507 | - if(( 0 < count( $old_xcaldecl)) && |
|
1508 | - ( in_array( $declPart['uri'], $old_xcaldecl['uri'] )) && |
|
1509 | - ( in_array( $declPart['external'], $old_xcaldecl['external'] ))) |
|
1506 | + foreach ($this->xcaldecl as $declix => $declPart) { |
|
1507 | + if ((0 < count($old_xcaldecl)) && |
|
1508 | + (in_array($declPart['uri'], $old_xcaldecl['uri'])) && |
|
1509 | + (in_array($declPart['external'], $old_xcaldecl['external']))) |
|
1510 | 1510 | continue; // no duplicate uri and ext. references |
1511 | 1511 | $calendarxCaldecl .= '<!'; |
1512 | - foreach( $declPart as $declKey => $declValue ) { |
|
1513 | - switch( $declKey ) { // index |
|
1512 | + foreach ($declPart as $declKey => $declValue) { |
|
1513 | + switch ($declKey) { // index |
|
1514 | 1514 | case 'xmldecl': // no 1 |
1515 | 1515 | $calendarxCaldecl .= $declValue.' '; |
1516 | 1516 | break; |
@@ -1537,7 +1537,7 @@ discard block |
||
1537 | 1537 | } |
1538 | 1538 | $calendarInit2 = ']'.$calendarInit2; |
1539 | 1539 | } |
1540 | - switch( $this->format ) { |
|
1540 | + switch ($this->format) { |
|
1541 | 1541 | case 'xcal': |
1542 | 1542 | $calendar .= '</vcalendar>'.$this->nl; |
1543 | 1543 | break; |
@@ -1555,18 +1555,18 @@ discard block |
||
1555 | 1555 | * @return redirect |
1556 | 1556 | */ |
1557 | 1557 | function returnCalendar() { |
1558 | - $filename = $this->getConfig( 'filename' ); |
|
1558 | + $filename = $this->getConfig('filename'); |
|
1559 | 1559 | $output = $this->createCalendar(); |
1560 | - $filesize = strlen( $output ); |
|
1560 | + $filesize = strlen($output); |
|
1561 | 1561 | // if( headers_sent( $filename, $linenum )) |
1562 | 1562 | // die( "Headers already sent in $filename on line $linenum\n" ); |
1563 | - if( 'xcal' == $this->format ) |
|
1564 | - header( 'Content-Type: application/calendar+xml; charset=utf-8' ); |
|
1563 | + if ('xcal' == $this->format) |
|
1564 | + header('Content-Type: application/calendar+xml; charset=utf-8'); |
|
1565 | 1565 | else |
1566 | - header( 'Content-Type: text/calendar; charset=utf-8' ); |
|
1567 | - header( 'Content-Length: '.$filesize ); |
|
1568 | - header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
|
1569 | - header( 'Cache-Control: max-age=10' ); |
|
1566 | + header('Content-Type: text/calendar; charset=utf-8'); |
|
1567 | + header('Content-Length: '.$filesize); |
|
1568 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
1569 | + header('Cache-Control: max-age=10'); |
|
1570 | 1570 | echo $output; |
1571 | 1571 | die(); |
1572 | 1572 | } |
@@ -1580,20 +1580,20 @@ discard block |
||
1580 | 1580 | * @param string $delimiter optional |
1581 | 1581 | * @return bool |
1582 | 1582 | */ |
1583 | - function saveCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE ) { |
|
1584 | - if( $directory ) |
|
1585 | - $this->setConfig( 'directory', $directory ); |
|
1586 | - if( $filename ) |
|
1587 | - $this->setConfig( 'filename', $filename ); |
|
1588 | - if( $delimiter && ($delimiter != DIRECTORY_SEPARATOR )) |
|
1589 | - $this->setConfig( 'delimiter', $delimiter ); |
|
1590 | - if( FALSE === ( $dirfile = $this->getConfig( 'url' ))) |
|
1591 | - $dirfile = $this->getConfig( 'dirfile' ); |
|
1592 | - $iCalFile = @fopen( $dirfile, 'w' ); |
|
1593 | - if( $iCalFile ) { |
|
1594 | - if( FALSE === fwrite( $iCalFile, $this->createCalendar() )) |
|
1583 | + function saveCalendar($directory = FALSE, $filename = FALSE, $delimiter = FALSE) { |
|
1584 | + if ($directory) |
|
1585 | + $this->setConfig('directory', $directory); |
|
1586 | + if ($filename) |
|
1587 | + $this->setConfig('filename', $filename); |
|
1588 | + if ($delimiter && ($delimiter != DIRECTORY_SEPARATOR)) |
|
1589 | + $this->setConfig('delimiter', $delimiter); |
|
1590 | + if (FALSE === ($dirfile = $this->getConfig('url'))) |
|
1591 | + $dirfile = $this->getConfig('dirfile'); |
|
1592 | + $iCalFile = @fopen($dirfile, 'w'); |
|
1593 | + if ($iCalFile) { |
|
1594 | + if (FALSE === fwrite($iCalFile, $this->createCalendar())) |
|
1595 | 1595 | return FALSE; |
1596 | - fclose( $iCalFile ); |
|
1596 | + fclose($iCalFile); |
|
1597 | 1597 | return TRUE; |
1598 | 1598 | } |
1599 | 1599 | else |
@@ -1611,38 +1611,38 @@ discard block |
||
1611 | 1611 | * @param int timeout optional, default 3600 sec |
1612 | 1612 | * @return redirect/FALSE |
1613 | 1613 | */ |
1614 | - function useCachedCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE, $timeout=3600) { |
|
1615 | - if ( $directory && ctype_digit( (string) $directory ) && !$filename ) { |
|
1614 | + function useCachedCalendar($directory = FALSE, $filename = FALSE, $delimiter = FALSE, $timeout = 3600) { |
|
1615 | + if ($directory && ctype_digit((string) $directory) && !$filename) { |
|
1616 | 1616 | $timeout = (int) $directory; |
1617 | 1617 | $directory = FALSE; |
1618 | 1618 | } |
1619 | - if( $directory ) |
|
1620 | - $this->setConfig( 'directory', $directory ); |
|
1621 | - if( $filename ) |
|
1622 | - $this->setConfig( 'filename', $filename ); |
|
1623 | - if( $delimiter && ( $delimiter != DIRECTORY_SEPARATOR )) |
|
1624 | - $this->setConfig( 'delimiter', $delimiter ); |
|
1625 | - $filesize = $this->getConfig( 'filesize' ); |
|
1626 | - if( 0 >= $filesize ) |
|
1619 | + if ($directory) |
|
1620 | + $this->setConfig('directory', $directory); |
|
1621 | + if ($filename) |
|
1622 | + $this->setConfig('filename', $filename); |
|
1623 | + if ($delimiter && ($delimiter != DIRECTORY_SEPARATOR)) |
|
1624 | + $this->setConfig('delimiter', $delimiter); |
|
1625 | + $filesize = $this->getConfig('filesize'); |
|
1626 | + if (0 >= $filesize) |
|
1627 | 1627 | return FALSE; |
1628 | - $dirfile = $this->getConfig( 'dirfile' ); |
|
1629 | - if( time() - filemtime( $dirfile ) < $timeout) { |
|
1628 | + $dirfile = $this->getConfig('dirfile'); |
|
1629 | + if (time() - filemtime($dirfile) < $timeout) { |
|
1630 | 1630 | clearstatcache(); |
1631 | - $dirfile = $this->getConfig( 'dirfile' ); |
|
1632 | - $filename = $this->getConfig( 'filename' ); |
|
1631 | + $dirfile = $this->getConfig('dirfile'); |
|
1632 | + $filename = $this->getConfig('filename'); |
|
1633 | 1633 | // if( headers_sent( $filename, $linenum )) |
1634 | 1634 | // die( "Headers already sent in $filename on line $linenum\n" ); |
1635 | - if( 'xcal' == $this->format ) |
|
1636 | - header( 'Content-Type: application/calendar+xml; charset=utf-8' ); |
|
1635 | + if ('xcal' == $this->format) |
|
1636 | + header('Content-Type: application/calendar+xml; charset=utf-8'); |
|
1637 | 1637 | else |
1638 | - header( 'Content-Type: text/calendar; charset=utf-8' ); |
|
1639 | - header( 'Content-Length: '.$filesize ); |
|
1640 | - header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
|
1641 | - header( 'Cache-Control: max-age=10' ); |
|
1642 | - $fp = @$fopen( $dirfile, 'r' ); |
|
1643 | - if( $fp ) { |
|
1644 | - fpassthru( $fp ); |
|
1645 | - fclose( $fp ); |
|
1638 | + header('Content-Type: text/calendar; charset=utf-8'); |
|
1639 | + header('Content-Length: '.$filesize); |
|
1640 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
1641 | + header('Cache-Control: max-age=10'); |
|
1642 | + $fp = @$fopen($dirfile, 'r'); |
|
1643 | + if ($fp) { |
|
1644 | + fpassthru($fp); |
|
1645 | + fclose($fp); |
|
1646 | 1646 | } |
1647 | 1647 | die(); |
1648 | 1648 | } |
@@ -1691,8 +1691,8 @@ discard block |
||
1691 | 1691 | * @since 2.4.19 - 2008-10-23 |
1692 | 1692 | */ |
1693 | 1693 | function calendarComponent() { |
1694 | - $this->objName = ( isset( $this->timezonetype )) ? |
|
1695 | - strtolower( $this->timezonetype ) : get_class ( $this ); |
|
1694 | + $this->objName = (isset($this->timezonetype)) ? |
|
1695 | + strtolower($this->timezonetype) : get_class($this); |
|
1696 | 1696 | $this->uid = array(); |
1697 | 1697 | $this->dtstamp = array(); |
1698 | 1698 | |
@@ -1718,11 +1718,11 @@ discard block |
||
1718 | 1718 | * @return string |
1719 | 1719 | */ |
1720 | 1720 | function createAction() { |
1721 | - if( empty( $this->action )) return FALSE; |
|
1722 | - if( empty( $this->action['value'] )) |
|
1723 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE; |
|
1724 | - $attributes = $this->_createParams( $this->action['params'] ); |
|
1725 | - return $this->_createElement( 'ACTION', $attributes, $this->action['value'] ); |
|
1721 | + if (empty($this->action)) return FALSE; |
|
1722 | + if (empty($this->action['value'])) |
|
1723 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('ACTION') : FALSE; |
|
1724 | + $attributes = $this->_createParams($this->action['params']); |
|
1725 | + return $this->_createElement('ACTION', $attributes, $this->action['value']); |
|
1726 | 1726 | } |
1727 | 1727 | /** |
1728 | 1728 | * set calendar component property action |
@@ -1733,9 +1733,9 @@ discard block |
||
1733 | 1733 | * @param mixed $params |
1734 | 1734 | * @return bool |
1735 | 1735 | */ |
1736 | - function setAction( $value, $params=FALSE ) { |
|
1737 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1738 | - $this->action = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
1736 | + function setAction($value, $params = FALSE) { |
|
1737 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
1738 | + $this->action = array('value' => $value, 'params' => $this->_setParams($params)); |
|
1739 | 1739 | return TRUE; |
1740 | 1740 | } |
1741 | 1741 | /*********************************************************************************/ |
@@ -1750,14 +1750,14 @@ discard block |
||
1750 | 1750 | * @return string |
1751 | 1751 | */ |
1752 | 1752 | function createAttach() { |
1753 | - if( empty( $this->attach )) return FALSE; |
|
1754 | - $output = null; |
|
1755 | - foreach( $this->attach as $attachPart ) { |
|
1756 | - if(! empty( $attachPart['value'] )) { |
|
1757 | - $attributes = $this->_createParams( $attachPart['params'] ); |
|
1758 | - $output .= $this->_createElement( 'ATTACH', $attributes, $attachPart['value'] ); |
|
1753 | + if (empty($this->attach)) return FALSE; |
|
1754 | + $output = null; |
|
1755 | + foreach ($this->attach as $attachPart) { |
|
1756 | + if (!empty($attachPart['value'])) { |
|
1757 | + $attributes = $this->_createParams($attachPart['params']); |
|
1758 | + $output .= $this->_createElement('ATTACH', $attributes, $attachPart['value']); |
|
1759 | 1759 | } |
1760 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'ATTACH' ); |
|
1760 | + elseif ($this->getConfig('allowEmpty')) $output .= $this->_createElement('ATTACH'); |
|
1761 | 1761 | } |
1762 | 1762 | return $output; |
1763 | 1763 | } |
@@ -1771,9 +1771,9 @@ discard block |
||
1771 | 1771 | * @param integer $index, optional |
1772 | 1772 | * @return bool |
1773 | 1773 | */ |
1774 | - function setAttach( $value, $params=FALSE, $index=FALSE ) { |
|
1775 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1776 | - $this->_setMval( $this->attach, $value, $params, FALSE, $index ); |
|
1774 | + function setAttach($value, $params = FALSE, $index = FALSE) { |
|
1775 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
1776 | + $this->_setMval($this->attach, $value, $params, FALSE, $index); |
|
1777 | 1777 | return TRUE; |
1778 | 1778 | } |
1779 | 1779 | /*********************************************************************************/ |
@@ -1788,26 +1788,26 @@ discard block |
||
1788 | 1788 | * @return string |
1789 | 1789 | */ |
1790 | 1790 | function createAttendee() { |
1791 | - if( empty( $this->attendee )) return FALSE; |
|
1791 | + if (empty($this->attendee)) return FALSE; |
|
1792 | 1792 | $output = null; |
1793 | - foreach( $this->attendee as $attendeePart ) { // start foreach 1 |
|
1794 | - if( empty( $attendeePart['value'] )) { |
|
1795 | - if( $this->getConfig( 'allowEmpty' )) |
|
1796 | - $output .= $this->_createElement( 'ATTENDEE' ); |
|
1793 | + foreach ($this->attendee as $attendeePart) { // start foreach 1 |
|
1794 | + if (empty($attendeePart['value'])) { |
|
1795 | + if ($this->getConfig('allowEmpty')) |
|
1796 | + $output .= $this->_createElement('ATTENDEE'); |
|
1797 | 1797 | continue; |
1798 | 1798 | } |
1799 | 1799 | $attendee1 = $attendee2 = $attendeeLANG = $attendeeCN = null; |
1800 | - foreach( $attendeePart as $paramlabel => $paramvalue ) { // start foreach 2 |
|
1801 | - if( 'value' == $paramlabel ) |
|
1802 | - $attendee2 .= 'MAILTO:'.$paramvalue; |
|
1803 | - elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) { // start elseif |
|
1804 | - foreach( $paramvalue as $optparamlabel => $optparamvalue ) { // start foreach 3 |
|
1800 | + foreach ($attendeePart as $paramlabel => $paramvalue) { // start foreach 2 |
|
1801 | + if ('value' == $paramlabel) |
|
1802 | + $attendee2 .= 'MAILTO:'.$paramvalue; |
|
1803 | + elseif (('params' == $paramlabel) && (is_array($paramvalue))) { // start elseif |
|
1804 | + foreach ($paramvalue as $optparamlabel => $optparamvalue) { // start foreach 3 |
|
1805 | 1805 | $attendee11 = $attendee12 = null; |
1806 | - if( is_int( $optparamlabel )) { |
|
1806 | + if (is_int($optparamlabel)) { |
|
1807 | 1807 | $attendee1 .= $this->intAttrDelimiter.$optparamvalue; |
1808 | 1808 | continue; |
1809 | 1809 | } |
1810 | - switch( $optparamlabel ) { // start switch |
|
1810 | + switch ($optparamlabel) { // start switch |
|
1811 | 1811 | case 'CUTYPE': |
1812 | 1812 | case 'PARTSTAT': |
1813 | 1813 | case 'ROLE': |
@@ -1820,11 +1820,11 @@ discard block |
||
1820 | 1820 | case 'MEMBER': |
1821 | 1821 | $attendee11 = $this->intAttrDelimiter.'MEMBER='; |
1822 | 1822 | case 'DELEGATED-TO': |
1823 | - $attendee11 = ( !$attendee11 ) ? $this->intAttrDelimiter.'DELEGATED-TO=' : $attendee11; |
|
1823 | + $attendee11 = (!$attendee11) ? $this->intAttrDelimiter.'DELEGATED-TO=' : $attendee11; |
|
1824 | 1824 | case 'DELEGATED-FROM': |
1825 | - $attendee11 = ( !$attendee11 ) ? $this->intAttrDelimiter.'DELEGATED-FROM=' : $attendee11; |
|
1826 | - foreach( $optparamvalue as $cix => $calUserAddress ) { |
|
1827 | - $attendee12 .= ( $cix ) ? ',' : null; |
|
1825 | + $attendee11 = (!$attendee11) ? $this->intAttrDelimiter.'DELEGATED-FROM=' : $attendee11; |
|
1826 | + foreach ($optparamvalue as $cix => $calUserAddress) { |
|
1827 | + $attendee12 .= ($cix) ? ',' : null; |
|
1828 | 1828 | $attendee12 .= '"MAILTO:'.$calUserAddress.'"'; |
1829 | 1829 | } |
1830 | 1830 | $attendee1 .= $attendee11.$attendee12; |
@@ -1845,7 +1845,7 @@ discard block |
||
1845 | 1845 | } // end foreach 3 |
1846 | 1846 | } // end elseif |
1847 | 1847 | } // end foreach 2 |
1848 | - $output .= $this->_createElement( 'ATTENDEE', $attendee1.$attendeeLANG.$attendeeCN, $attendee2 ); |
|
1848 | + $output .= $this->_createElement('ATTENDEE', $attendee1.$attendeeLANG.$attendeeCN, $attendee2); |
|
1849 | 1849 | } // end foreach 1 |
1850 | 1850 | return $output; |
1851 | 1851 | } |
@@ -1859,63 +1859,63 @@ discard block |
||
1859 | 1859 | * @param integer $index, optional |
1860 | 1860 | * @return bool |
1861 | 1861 | */ |
1862 | - function setAttendee( $value, $params=FALSE, $index=FALSE ) { |
|
1863 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1864 | - $value = str_replace ( 'MAILTO:', '', $value ); |
|
1865 | - $value = str_replace ( 'mailto:', '', $value ); |
|
1862 | + function setAttendee($value, $params = FALSE, $index = FALSE) { |
|
1863 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
1864 | + $value = str_replace('MAILTO:', '', $value); |
|
1865 | + $value = str_replace('mailto:', '', $value); |
|
1866 | 1866 | $params2 = array(); |
1867 | - if( is_array($params )) { |
|
1867 | + if (is_array($params)) { |
|
1868 | 1868 | $optarrays = array(); |
1869 | - foreach( $params as $optparamlabel => $optparamvalue ) { |
|
1870 | - $optparamlabel = strtoupper( $optparamlabel ); |
|
1871 | - switch( $optparamlabel ) { |
|
1869 | + foreach ($params as $optparamlabel => $optparamvalue) { |
|
1870 | + $optparamlabel = strtoupper($optparamlabel); |
|
1871 | + switch ($optparamlabel) { |
|
1872 | 1872 | case 'MEMBER': |
1873 | 1873 | case 'DELEGATED-TO': |
1874 | 1874 | case 'DELEGATED-FROM': |
1875 | - if( is_array( $optparamvalue )) { |
|
1876 | - foreach( $optparamvalue as $part ) { |
|
1877 | - $part = str_replace( 'MAILTO:', '', $part ); |
|
1878 | - $part = str_replace( 'mailto:', '', $part ); |
|
1879 | - if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) |
|
1880 | - $part = substr( $part, 1, ( strlen($part)-2 )); |
|
1875 | + if (is_array($optparamvalue)) { |
|
1876 | + foreach ($optparamvalue as $part) { |
|
1877 | + $part = str_replace('MAILTO:', '', $part); |
|
1878 | + $part = str_replace('mailto:', '', $part); |
|
1879 | + if (('"' == $part{0} ) && ('"' == $part{strlen($part) - 1} )) |
|
1880 | + $part = substr($part, 1, (strlen($part) - 2)); |
|
1881 | 1881 | $optarrays[$optparamlabel][] = $part; |
1882 | 1882 | } |
1883 | 1883 | } |
1884 | 1884 | else { |
1885 | - $part = str_replace( 'MAILTO:', '', $optparamvalue ); |
|
1886 | - $part = str_replace( 'mailto:', '', $part ); |
|
1887 | - if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) |
|
1888 | - $part = substr( $part, 1, ( strlen($part)-2 )); |
|
1885 | + $part = str_replace('MAILTO:', '', $optparamvalue); |
|
1886 | + $part = str_replace('mailto:', '', $part); |
|
1887 | + if (('"' == $part{0} ) && ('"' == $part{strlen($part) - 1} )) |
|
1888 | + $part = substr($part, 1, (strlen($part) - 2)); |
|
1889 | 1889 | $optarrays[$optparamlabel][] = $part; |
1890 | 1890 | } |
1891 | 1891 | break; |
1892 | 1892 | default: |
1893 | - if( 'SENT-BY' == $optparamlabel ) { |
|
1894 | - $optparamvalue = str_replace( 'MAILTO:', '', $optparamvalue ); |
|
1895 | - $optparamvalue = str_replace( 'mailto:', '', $optparamvalue ); |
|
1893 | + if ('SENT-BY' == $optparamlabel) { |
|
1894 | + $optparamvalue = str_replace('MAILTO:', '', $optparamvalue); |
|
1895 | + $optparamvalue = str_replace('mailto:', '', $optparamvalue); |
|
1896 | 1896 | } |
1897 | - if(( '"' == substr( $optparamvalue, 0, 1 )) && |
|
1898 | - ( '"' == substr( $optparamvalue, -1 ))) |
|
1899 | - $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 )); |
|
1897 | + if (('"' == substr($optparamvalue, 0, 1)) && |
|
1898 | + ('"' == substr($optparamvalue, -1))) |
|
1899 | + $optparamvalue = substr($optparamvalue, 1, (strlen($optparamvalue) - 2)); |
|
1900 | 1900 | $params2[$optparamlabel] = $optparamvalue; |
1901 | 1901 | break; |
1902 | 1902 | } // end switch( $optparamlabel.. . |
1903 | 1903 | } // end foreach( $optparam.. . |
1904 | - foreach( $optarrays as $optparamlabel => $optparams ) |
|
1904 | + foreach ($optarrays as $optparamlabel => $optparams) |
|
1905 | 1905 | $params2[$optparamlabel] = $optparams; |
1906 | 1906 | } |
1907 | 1907 | // remove defaults |
1908 | - $this->_existRem( $params2, 'CUTYPE', 'INDIVIDUAL' ); |
|
1909 | - $this->_existRem( $params2, 'PARTSTAT', 'NEEDS-ACTION' ); |
|
1910 | - $this->_existRem( $params2, 'ROLE', 'REQ-PARTICIPANT' ); |
|
1911 | - $this->_existRem( $params2, 'RSVP', 'FALSE' ); |
|
1908 | + $this->_existRem($params2, 'CUTYPE', 'INDIVIDUAL'); |
|
1909 | + $this->_existRem($params2, 'PARTSTAT', 'NEEDS-ACTION'); |
|
1910 | + $this->_existRem($params2, 'ROLE', 'REQ-PARTICIPANT'); |
|
1911 | + $this->_existRem($params2, 'RSVP', 'FALSE'); |
|
1912 | 1912 | // check language setting |
1913 | - if( isset( $params2['CN' ] )) { |
|
1914 | - $lang = $this->getConfig( 'language' ); |
|
1915 | - if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang )) |
|
1916 | - $params2['LANGUAGE' ] = $lang; |
|
1913 | + if (isset($params2['CN'])) { |
|
1914 | + $lang = $this->getConfig('language'); |
|
1915 | + if (!isset($params2['LANGUAGE']) && !empty($lang)) |
|
1916 | + $params2['LANGUAGE'] = $lang; |
|
1917 | 1917 | } |
1918 | - $this->_setMval( $this->attendee, $value, $params2, FALSE, $index ); |
|
1918 | + $this->_setMval($this->attendee, $value, $params2, FALSE, $index); |
|
1919 | 1919 | return TRUE; |
1920 | 1920 | } |
1921 | 1921 | /*********************************************************************************/ |
@@ -1930,23 +1930,23 @@ discard block |
||
1930 | 1930 | * @return string |
1931 | 1931 | */ |
1932 | 1932 | function createCategories() { |
1933 | - if( empty( $this->categories )) return FALSE; |
|
1933 | + if (empty($this->categories)) return FALSE; |
|
1934 | 1934 | $output = null; |
1935 | - foreach( $this->categories as $category ) { |
|
1936 | - if( empty( $category['value'] )) { |
|
1937 | - if ( $this->getConfig( 'allowEmpty' )) |
|
1938 | - $output .= $this->_createElement( 'CATEGORIES' ); |
|
1935 | + foreach ($this->categories as $category) { |
|
1936 | + if (empty($category['value'])) { |
|
1937 | + if ($this->getConfig('allowEmpty')) |
|
1938 | + $output .= $this->_createElement('CATEGORIES'); |
|
1939 | 1939 | continue; |
1940 | 1940 | } |
1941 | - $attributes = $this->_createParams( $category['params'], array( 'LANGUAGE' )); |
|
1942 | - if( is_array( $category['value'] )) { |
|
1943 | - foreach( $category['value'] as $cix => $categoryPart ) |
|
1944 | - $category['value'][$cix] = $this->_strrep( $categoryPart ); |
|
1945 | - $content = implode( ',', $category['value'] ); |
|
1941 | + $attributes = $this->_createParams($category['params'], array('LANGUAGE')); |
|
1942 | + if (is_array($category['value'])) { |
|
1943 | + foreach ($category['value'] as $cix => $categoryPart) |
|
1944 | + $category['value'][$cix] = $this->_strrep($categoryPart); |
|
1945 | + $content = implode(',', $category['value']); |
|
1946 | 1946 | } |
1947 | 1947 | else |
1948 | - $content = $this->_strrep( $category['value'] ); |
|
1949 | - $output .= $this->_createElement( 'CATEGORIES', $attributes, $content ); |
|
1948 | + $content = $this->_strrep($category['value']); |
|
1949 | + $output .= $this->_createElement('CATEGORIES', $attributes, $content); |
|
1950 | 1950 | } |
1951 | 1951 | return $output; |
1952 | 1952 | } |
@@ -1960,9 +1960,9 @@ discard block |
||
1960 | 1960 | * @param integer $index, optional |
1961 | 1961 | * @return bool |
1962 | 1962 | */ |
1963 | - function setCategories( $value, $params=FALSE, $index=FALSE ) { |
|
1964 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1965 | - $this->_setMval( $this->categories, $value, $params, FALSE, $index ); |
|
1963 | + function setCategories($value, $params = FALSE, $index = FALSE) { |
|
1964 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
1965 | + $this->_setMval($this->categories, $value, $params, FALSE, $index); |
|
1966 | 1966 | return TRUE; |
1967 | 1967 | } |
1968 | 1968 | /*********************************************************************************/ |
@@ -1977,11 +1977,11 @@ discard block |
||
1977 | 1977 | * @return string |
1978 | 1978 | */ |
1979 | 1979 | function createClass() { |
1980 | - if( empty( $this->class )) return FALSE; |
|
1981 | - if( empty( $this->class['value'] )) |
|
1982 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE; |
|
1983 | - $attributes = $this->_createParams( $this->class['params'] ); |
|
1984 | - return $this->_createElement( 'CLASS', $attributes, $this->class['value'] ); |
|
1980 | + if (empty($this->class)) return FALSE; |
|
1981 | + if (empty($this->class['value'])) |
|
1982 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('CLASS') : FALSE; |
|
1983 | + $attributes = $this->_createParams($this->class['params']); |
|
1984 | + return $this->_createElement('CLASS', $attributes, $this->class['value']); |
|
1985 | 1985 | } |
1986 | 1986 | /** |
1987 | 1987 | * set calendar component property class |
@@ -1992,9 +1992,9 @@ discard block |
||
1992 | 1992 | * @param array $params optional |
1993 | 1993 | * @return bool |
1994 | 1994 | */ |
1995 | - function setClass( $value, $params=FALSE ) { |
|
1996 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1997 | - $this->class = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
1995 | + function setClass($value, $params = FALSE) { |
|
1996 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
1997 | + $this->class = array('value' => $value, 'params' => $this->_setParams($params)); |
|
1998 | 1998 | return TRUE; |
1999 | 1999 | } |
2000 | 2000 | /*********************************************************************************/ |
@@ -2009,16 +2009,16 @@ discard block |
||
2009 | 2009 | * @return string |
2010 | 2010 | */ |
2011 | 2011 | function createComment() { |
2012 | - if( empty( $this->comment )) return FALSE; |
|
2012 | + if (empty($this->comment)) return FALSE; |
|
2013 | 2013 | $output = null; |
2014 | - foreach( $this->comment as $commentPart ) { |
|
2015 | - if( empty( $commentPart['value'] )) { |
|
2016 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'COMMENT' ); |
|
2014 | + foreach ($this->comment as $commentPart) { |
|
2015 | + if (empty($commentPart['value'])) { |
|
2016 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('COMMENT'); |
|
2017 | 2017 | continue; |
2018 | 2018 | } |
2019 | - $attributes = $this->_createParams( $commentPart['params'], array( 'ALTREP', 'LANGUAGE' )); |
|
2020 | - $content = $this->_strrep( $commentPart['value'] ); |
|
2021 | - $output .= $this->_createElement( 'COMMENT', $attributes, $content ); |
|
2019 | + $attributes = $this->_createParams($commentPart['params'], array('ALTREP', 'LANGUAGE')); |
|
2020 | + $content = $this->_strrep($commentPart['value']); |
|
2021 | + $output .= $this->_createElement('COMMENT', $attributes, $content); |
|
2022 | 2022 | } |
2023 | 2023 | return $output; |
2024 | 2024 | } |
@@ -2032,9 +2032,9 @@ discard block |
||
2032 | 2032 | * @param integer $index, optional |
2033 | 2033 | * @return bool |
2034 | 2034 | */ |
2035 | - function setComment( $value, $params=FALSE, $index=FALSE ) { |
|
2036 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2037 | - $this->_setMval( $this->comment, $value, $params, FALSE, $index ); |
|
2035 | + function setComment($value, $params = FALSE, $index = FALSE) { |
|
2036 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
2037 | + $this->_setMval($this->comment, $value, $params, FALSE, $index); |
|
2038 | 2038 | return TRUE; |
2039 | 2039 | } |
2040 | 2040 | /*********************************************************************************/ |
@@ -2049,19 +2049,19 @@ discard block |
||
2049 | 2049 | * @return string |
2050 | 2050 | */ |
2051 | 2051 | function createCompleted( ) { |
2052 | - if( empty( $this->completed )) return FALSE; |
|
2053 | - if( !isset( $this->completed['value']['year'] ) && |
|
2054 | - !isset( $this->completed['value']['month'] ) && |
|
2055 | - !isset( $this->completed['value']['day'] ) && |
|
2056 | - !isset( $this->completed['value']['hour'] ) && |
|
2057 | - !isset( $this->completed['value']['min'] ) && |
|
2058 | - !isset( $this->completed['value']['sec'] )) |
|
2059 | - if( $this->getConfig( 'allowEmpty' )) |
|
2060 | - return $this->_createElement( 'COMPLETED' ); |
|
2052 | + if (empty($this->completed)) return FALSE; |
|
2053 | + if (!isset($this->completed['value']['year']) && |
|
2054 | + !isset($this->completed['value']['month']) && |
|
2055 | + !isset($this->completed['value']['day']) && |
|
2056 | + !isset($this->completed['value']['hour']) && |
|
2057 | + !isset($this->completed['value']['min']) && |
|
2058 | + !isset($this->completed['value']['sec'])) |
|
2059 | + if ($this->getConfig('allowEmpty')) |
|
2060 | + return $this->_createElement('COMPLETED'); |
|
2061 | 2061 | else return FALSE; |
2062 | - $formatted = $this->_format_date_time( $this->completed['value'], 7 ); |
|
2063 | - $attributes = $this->_createParams( $this->completed['params'] ); |
|
2064 | - return $this->_createElement( 'COMPLETED', $attributes, $formatted ); |
|
2062 | + $formatted = $this->_format_date_time($this->completed['value'], 7); |
|
2063 | + $attributes = $this->_createParams($this->completed['params']); |
|
2064 | + return $this->_createElement('COMPLETED', $attributes, $formatted); |
|
2065 | 2065 | } |
2066 | 2066 | /** |
2067 | 2067 | * set calendar component property completed |
@@ -2077,16 +2077,16 @@ discard block |
||
2077 | 2077 | * @param array $params optional |
2078 | 2078 | * @return bool |
2079 | 2079 | */ |
2080 | - function setCompleted( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
|
2081 | - if( empty( $year )) { |
|
2082 | - if( $this->getConfig( 'allowEmpty' )) { |
|
2083 | - $this->completed = array( 'value' => null, 'params' => $this->_setParams( $params )); |
|
2080 | + function setCompleted($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) { |
|
2081 | + if (empty($year)) { |
|
2082 | + if ($this->getConfig('allowEmpty')) { |
|
2083 | + $this->completed = array('value' => null, 'params' => $this->_setParams($params)); |
|
2084 | 2084 | return TRUE; |
2085 | 2085 | } |
2086 | 2086 | else |
2087 | 2087 | return FALSE; |
2088 | 2088 | } |
2089 | - $this->completed = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
|
2089 | + $this->completed = $this->_setDate2($year, $month, $day, $hour, $min, $sec, $params); |
|
2090 | 2090 | return TRUE; |
2091 | 2091 | } |
2092 | 2092 | /*********************************************************************************/ |
@@ -2101,15 +2101,15 @@ discard block |
||
2101 | 2101 | * @return string |
2102 | 2102 | */ |
2103 | 2103 | function createContact() { |
2104 | - if( empty( $this->contact )) return FALSE; |
|
2104 | + if (empty($this->contact)) return FALSE; |
|
2105 | 2105 | $output = null; |
2106 | - foreach( $this->contact as $contact ) { |
|
2107 | - if( !empty( $contact['value'] )) { |
|
2108 | - $attributes = $this->_createParams( $contact['params'], array( 'ALTREP', 'LANGUAGE' )); |
|
2109 | - $content = $this->_strrep( $contact['value'] ); |
|
2110 | - $output .= $this->_createElement( 'CONTACT', $attributes, $content ); |
|
2106 | + foreach ($this->contact as $contact) { |
|
2107 | + if (!empty($contact['value'])) { |
|
2108 | + $attributes = $this->_createParams($contact['params'], array('ALTREP', 'LANGUAGE')); |
|
2109 | + $content = $this->_strrep($contact['value']); |
|
2110 | + $output .= $this->_createElement('CONTACT', $attributes, $content); |
|
2111 | 2111 | } |
2112 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'CONTACT' ); |
|
2112 | + elseif ($this->getConfig('allowEmpty')) $output .= $this->_createElement('CONTACT'); |
|
2113 | 2113 | } |
2114 | 2114 | return $output; |
2115 | 2115 | } |
@@ -2123,9 +2123,9 @@ discard block |
||
2123 | 2123 | * @param integer $index, optional |
2124 | 2124 | * @return bool |
2125 | 2125 | */ |
2126 | - function setContact( $value, $params=FALSE, $index=FALSE ) { |
|
2127 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2128 | - $this->_setMval( $this->contact, $value, $params, FALSE, $index ); |
|
2126 | + function setContact($value, $params = FALSE, $index = FALSE) { |
|
2127 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
2128 | + $this->_setMval($this->contact, $value, $params, FALSE, $index); |
|
2129 | 2129 | return TRUE; |
2130 | 2130 | } |
2131 | 2131 | /*********************************************************************************/ |
@@ -2140,10 +2140,10 @@ discard block |
||
2140 | 2140 | * @return string |
2141 | 2141 | */ |
2142 | 2142 | function createCreated() { |
2143 | - if( empty( $this->created )) return FALSE; |
|
2144 | - $formatted = $this->_format_date_time( $this->created['value'], 7 ); |
|
2145 | - $attributes = $this->_createParams( $this->created['params'] ); |
|
2146 | - return $this->_createElement( 'CREATED', $attributes, $formatted ); |
|
2143 | + if (empty($this->created)) return FALSE; |
|
2144 | + $formatted = $this->_format_date_time($this->created['value'], 7); |
|
2145 | + $attributes = $this->_createParams($this->created['params']); |
|
2146 | + return $this->_createElement('CREATED', $attributes, $formatted); |
|
2147 | 2147 | } |
2148 | 2148 | /** |
2149 | 2149 | * set calendar component property created |
@@ -2159,11 +2159,11 @@ discard block |
||
2159 | 2159 | * @param mixed $params optional |
2160 | 2160 | * @return bool |
2161 | 2161 | */ |
2162 | - function setCreated( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
|
2163 | - if( !isset( $year )) { |
|
2164 | - $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' ))); |
|
2162 | + function setCreated($year = FALSE, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) { |
|
2163 | + if (!isset($year)) { |
|
2164 | + $year = date('Ymd\THis', mktime(date('H'), date('i'), date('s') - date('Z'), date('m'), date('d'), date('Y'))); |
|
2165 | 2165 | } |
2166 | - $this->created = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
|
2166 | + $this->created = $this->_setDate2($year, $month, $day, $hour, $min, $sec, $params); |
|
2167 | 2167 | return TRUE; |
2168 | 2168 | } |
2169 | 2169 | /*********************************************************************************/ |
@@ -2178,15 +2178,15 @@ discard block |
||
2178 | 2178 | * @return string |
2179 | 2179 | */ |
2180 | 2180 | function createDescription() { |
2181 | - if( empty( $this->description )) return FALSE; |
|
2182 | - $output = null; |
|
2183 | - foreach( $this->description as $description ) { |
|
2184 | - if( !empty( $description['value'] )) { |
|
2185 | - $attributes = $this->_createParams( $description['params'], array( 'ALTREP', 'LANGUAGE' )); |
|
2186 | - $content = $this->_strrep( $description['value'] ); |
|
2187 | - $output .= $this->_createElement( 'DESCRIPTION', $attributes, $content ); |
|
2181 | + if (empty($this->description)) return FALSE; |
|
2182 | + $output = null; |
|
2183 | + foreach ($this->description as $description) { |
|
2184 | + if (!empty($description['value'])) { |
|
2185 | + $attributes = $this->_createParams($description['params'], array('ALTREP', 'LANGUAGE')); |
|
2186 | + $content = $this->_strrep($description['value']); |
|
2187 | + $output .= $this->_createElement('DESCRIPTION', $attributes, $content); |
|
2188 | 2188 | } |
2189 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'DESCRIPTION' ); |
|
2189 | + elseif ($this->getConfig('allowEmpty')) $output .= $this->_createElement('DESCRIPTION'); |
|
2190 | 2190 | } |
2191 | 2191 | return $output; |
2192 | 2192 | } |
@@ -2200,9 +2200,9 @@ discard block |
||
2200 | 2200 | * @param integer $index, optional |
2201 | 2201 | * @return bool |
2202 | 2202 | */ |
2203 | - function setDescription( $value, $params=FALSE, $index=FALSE ) { |
|
2204 | - if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; } |
|
2205 | - $this->_setMval( $this->description, $value, $params, FALSE, $index ); |
|
2203 | + function setDescription($value, $params = FALSE, $index = FALSE) { |
|
2204 | + if (empty($value)) { if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; } |
|
2205 | + $this->_setMval($this->description, $value, $params, FALSE, $index); |
|
2206 | 2206 | return TRUE; |
2207 | 2207 | } |
2208 | 2208 | /*********************************************************************************/ |
@@ -2217,19 +2217,19 @@ discard block |
||
2217 | 2217 | * @return string |
2218 | 2218 | */ |
2219 | 2219 | function createDtend() { |
2220 | - if( empty( $this->dtend )) return FALSE; |
|
2221 | - if( !isset( $this->dtend['value']['year'] ) && |
|
2222 | - !isset( $this->dtend['value']['month'] ) && |
|
2223 | - !isset( $this->dtend['value']['day'] ) && |
|
2224 | - !isset( $this->dtend['value']['hour'] ) && |
|
2225 | - !isset( $this->dtend['value']['min'] ) && |
|
2226 | - !isset( $this->dtend['value']['sec'] )) |
|
2227 | - if( $this->getConfig( 'allowEmpty' )) |
|
2228 | - return $this->_createElement( 'DTEND' ); |
|
2220 | + if (empty($this->dtend)) return FALSE; |
|
2221 | + if (!isset($this->dtend['value']['year']) && |
|
2222 | + !isset($this->dtend['value']['month']) && |
|
2223 | + !isset($this->dtend['value']['day']) && |
|
2224 | + !isset($this->dtend['value']['hour']) && |
|
2225 | + !isset($this->dtend['value']['min']) && |
|
2226 | + !isset($this->dtend['value']['sec'])) |
|
2227 | + if ($this->getConfig('allowEmpty')) |
|
2228 | + return $this->_createElement('DTEND'); |
|
2229 | 2229 | else return FALSE; |
2230 | - $formatted = $this->_format_date_time( $this->dtend['value'] ); |
|
2231 | - $attributes = $this->_createParams( $this->dtend['params'] ); |
|
2232 | - return $this->_createElement( 'DTEND', $attributes, $formatted ); |
|
2230 | + $formatted = $this->_format_date_time($this->dtend['value']); |
|
2231 | + $attributes = $this->_createParams($this->dtend['params']); |
|
2232 | + return $this->_createElement('DTEND', $attributes, $formatted); |
|
2233 | 2233 | } |
2234 | 2234 | /** |
2235 | 2235 | * set calendar component property dtend |
@@ -2246,16 +2246,16 @@ discard block |
||
2246 | 2246 | * @param array params optional |
2247 | 2247 | * @return bool |
2248 | 2248 | */ |
2249 | - function setDtend( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) { |
|
2250 | - if( empty( $year )) { |
|
2251 | - if( $this->getConfig( 'allowEmpty' )) { |
|
2252 | - $this->dtend = array( 'value' => null, 'params' => $this->_setParams( $params )); |
|
2249 | + function setDtend($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE) { |
|
2250 | + if (empty($year)) { |
|
2251 | + if ($this->getConfig('allowEmpty')) { |
|
2252 | + $this->dtend = array('value' => null, 'params' => $this->_setParams($params)); |
|
2253 | 2253 | return TRUE; |
2254 | 2254 | } |
2255 | 2255 | else |
2256 | 2256 | return FALSE; |
2257 | 2257 | } |
2258 | - $this->dtend = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
|
2258 | + $this->dtend = $this->_setDate($year, $month, $day, $hour, $min, $sec, $tz, $params); |
|
2259 | 2259 | return TRUE; |
2260 | 2260 | } |
2261 | 2261 | /*********************************************************************************/ |
@@ -2270,16 +2270,16 @@ discard block |
||
2270 | 2270 | * @return string |
2271 | 2271 | */ |
2272 | 2272 | function createDtstamp() { |
2273 | - if( !isset( $this->dtstamp['value']['year'] ) && |
|
2274 | - !isset( $this->dtstamp['value']['month'] ) && |
|
2275 | - !isset( $this->dtstamp['value']['day'] ) && |
|
2276 | - !isset( $this->dtstamp['value']['hour'] ) && |
|
2277 | - !isset( $this->dtstamp['value']['min'] ) && |
|
2278 | - !isset( $this->dtstamp['value']['sec'] )) |
|
2273 | + if (!isset($this->dtstamp['value']['year']) && |
|
2274 | + !isset($this->dtstamp['value']['month']) && |
|
2275 | + !isset($this->dtstamp['value']['day']) && |
|
2276 | + !isset($this->dtstamp['value']['hour']) && |
|
2277 | + !isset($this->dtstamp['value']['min']) && |
|
2278 | + !isset($this->dtstamp['value']['sec'])) |
|
2279 | 2279 | $this->_makeDtstamp(); |
2280 | - $formatted = $this->_format_date_time( $this->dtstamp['value'], 7 ); |
|
2281 | - $attributes = $this->_createParams( $this->dtstamp['params'] ); |
|
2282 | - return $this->_createElement( 'DTSTAMP', $attributes, $formatted ); |
|
2280 | + $formatted = $this->_format_date_time($this->dtstamp['value'], 7); |
|
2281 | + $attributes = $this->_createParams($this->dtstamp['params']); |
|
2282 | + return $this->_createElement('DTSTAMP', $attributes, $formatted); |
|
2283 | 2283 | } |
2284 | 2284 | /** |
2285 | 2285 | * computes datestamp for calendar component object instance dtstamp |
@@ -2289,12 +2289,12 @@ discard block |
||
2289 | 2289 | * @return void |
2290 | 2290 | */ |
2291 | 2291 | function _makeDtstamp() { |
2292 | - $this->dtstamp['value'] = array( 'year' => date( 'Y' ) |
|
2293 | - , 'month' => date( 'm' ) |
|
2294 | - , 'day' => date( 'd' ) |
|
2295 | - , 'hour' => date( 'H' ) |
|
2296 | - , 'min' => date( 'i' ) |
|
2297 | - , 'sec' => date( 's' ) - date( 'Z' )); |
|
2292 | + $this->dtstamp['value'] = array('year' => date('Y') |
|
2293 | + , 'month' => date('m') |
|
2294 | + , 'day' => date('d') |
|
2295 | + , 'hour' => date('H') |
|
2296 | + , 'min' => date('i') |
|
2297 | + , 'sec' => date('s') - date('Z')); |
|
2298 | 2298 | $this->dtstamp['params'] = null; |
2299 | 2299 | } |
2300 | 2300 | /** |
@@ -2311,11 +2311,11 @@ discard block |
||
2311 | 2311 | * @param array $params optional |
2312 | 2312 | * @return TRUE |
2313 | 2313 | */ |
2314 | - function setDtstamp( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
|
2315 | - if( empty( $year )) |
|
2314 | + function setDtstamp($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) { |
|
2315 | + if (empty($year)) |
|
2316 | 2316 | $this->_makeDtstamp(); |
2317 | 2317 | else |
2318 | - $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
|
2318 | + $this->dtstamp = $this->_setDate2($year, $month, $day, $hour, $min, $sec, $params); |
|
2319 | 2319 | return TRUE; |
2320 | 2320 | } |
2321 | 2321 | /*********************************************************************************/ |
@@ -2330,21 +2330,21 @@ discard block |
||
2330 | 2330 | * @return string |
2331 | 2331 | */ |
2332 | 2332 | function createDtstart() { |
2333 | - if( empty( $this->dtstart )) return FALSE; |
|
2334 | - if( !isset( $this->dtstart['value']['year'] ) && |
|
2335 | - !isset( $this->dtstart['value']['month'] ) && |
|
2336 | - !isset( $this->dtstart['value']['day'] ) && |
|
2337 | - !isset( $this->dtstart['value']['hour'] ) && |
|
2338 | - !isset( $this->dtstart['value']['min'] ) && |
|
2339 | - !isset( $this->dtstart['value']['sec'] )) |
|
2340 | - if( $this->getConfig( 'allowEmpty' )) |
|
2341 | - return $this->_createElement( 'DTSTART' ); |
|
2333 | + if (empty($this->dtstart)) return FALSE; |
|
2334 | + if (!isset($this->dtstart['value']['year']) && |
|
2335 | + !isset($this->dtstart['value']['month']) && |
|
2336 | + !isset($this->dtstart['value']['day']) && |
|
2337 | + !isset($this->dtstart['value']['hour']) && |
|
2338 | + !isset($this->dtstart['value']['min']) && |
|
2339 | + !isset($this->dtstart['value']['sec'])) |
|
2340 | + if ($this->getConfig('allowEmpty')) |
|
2341 | + return $this->_createElement('DTSTART'); |
|
2342 | 2342 | else return FALSE; |
2343 | - if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) |
|
2344 | - unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] ); |
|
2345 | - $formatted = $this->_format_date_time( $this->dtstart['value'] ); |
|
2346 | - $attributes = $this->_createParams( $this->dtstart['params'] ); |
|
2347 | - return $this->_createElement( 'DTSTART', $attributes, $formatted ); |
|
2343 | + if (in_array($this->objName, array('vtimezone', 'standard', 'daylight'))) |
|
2344 | + unset($this->dtstart['value']['tz'], $this->dtstart['params']['TZID']); |
|
2345 | + $formatted = $this->_format_date_time($this->dtstart['value']); |
|
2346 | + $attributes = $this->_createParams($this->dtstart['params']); |
|
2347 | + return $this->_createElement('DTSTART', $attributes, $formatted); |
|
2348 | 2348 | } |
2349 | 2349 | /** |
2350 | 2350 | * set calendar component property dtstart |
@@ -2361,16 +2361,16 @@ discard block |
||
2361 | 2361 | * @param array $params optional |
2362 | 2362 | * @return bool |
2363 | 2363 | */ |
2364 | - function setDtstart( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) { |
|
2365 | - if( empty( $year )) { |
|
2366 | - if( $this->getConfig( 'allowEmpty' )) { |
|
2367 | - $this->dtstart = array( 'value' => null, 'params' => $this->_setParams( $params )); |
|
2364 | + function setDtstart($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE) { |
|
2365 | + if (empty($year)) { |
|
2366 | + if ($this->getConfig('allowEmpty')) { |
|
2367 | + $this->dtstart = array('value' => null, 'params' => $this->_setParams($params)); |
|
2368 | 2368 | return TRUE; |
2369 | 2369 | } |
2370 | 2370 | else |
2371 | 2371 | return FALSE; |
2372 | 2372 | } |
2373 | - $this->dtstart = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params, 'dtstart' ); |
|
2373 | + $this->dtstart = $this->_setDate($year, $month, $day, $hour, $min, $sec, $tz, $params, 'dtstart'); |
|
2374 | 2374 | return TRUE; |
2375 | 2375 | } |
2376 | 2376 | /*********************************************************************************/ |
@@ -2385,19 +2385,19 @@ discard block |
||
2385 | 2385 | * @return string |
2386 | 2386 | */ |
2387 | 2387 | function createDue() { |
2388 | - if( empty( $this->due )) return FALSE; |
|
2389 | - if( !isset( $this->due['value']['year'] ) && |
|
2390 | - !isset( $this->due['value']['month'] ) && |
|
2391 | - !isset( $this->due['value']['day'] ) && |
|
2392 | - !isset( $this->due['value']['hour'] ) && |
|
2393 | - !isset( $this->due['value']['min'] ) && |
|
2394 | - !isset( $this->due['value']['sec'] )) |
|
2395 | - if( $this->getConfig( 'allowEmpty' )) |
|
2396 | - return $this->_createElement( 'DUE' ); |
|
2388 | + if (empty($this->due)) return FALSE; |
|
2389 | + if (!isset($this->due['value']['year']) && |
|
2390 | + !isset($this->due['value']['month']) && |
|
2391 | + !isset($this->due['value']['day']) && |
|
2392 | + !isset($this->due['value']['hour']) && |
|
2393 | + !isset($this->due['value']['min']) && |
|
2394 | + !isset($this->due['value']['sec'])) |
|
2395 | + if ($this->getConfig('allowEmpty')) |
|
2396 | + return $this->_createElement('DUE'); |
|
2397 | 2397 | else return FALSE; |
2398 | - $formatted = $this->_format_date_time( $this->due['value'] ); |
|
2399 | - $attributes = $this->_createParams( $this->due['params'] ); |
|
2400 | - return $this->_createElement( 'DUE', $attributes, $formatted ); |
|
2398 | + $formatted = $this->_format_date_time($this->due['value']); |
|
2399 | + $attributes = $this->_createParams($this->due['params']); |
|
2400 | + return $this->_createElement('DUE', $attributes, $formatted); |
|
2401 | 2401 | } |
2402 | 2402 | /** |
2403 | 2403 | * set calendar component property due |
@@ -2413,16 +2413,16 @@ discard block |
||
2413 | 2413 | * @param array $params optional |
2414 | 2414 | * @return bool |
2415 | 2415 | */ |
2416 | - function setDue( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) { |
|
2417 | - if( empty( $year )) { |
|
2418 | - if( $this->getConfig( 'allowEmpty' )) { |
|
2419 | - $this->due = array( 'value' => null, 'params' => $this->_setParams( $params )); |
|
2416 | + function setDue($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE) { |
|
2417 | + if (empty($year)) { |
|
2418 | + if ($this->getConfig('allowEmpty')) { |
|
2419 | + $this->due = array('value' => null, 'params' => $this->_setParams($params)); |
|
2420 | 2420 | return TRUE; |
2421 | 2421 | } |
2422 | 2422 | else |
2423 | 2423 | return FALSE; |
2424 | 2424 | } |
2425 | - $this->due = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
|
2425 | + $this->due = $this->_setDate($year, $month, $day, $hour, $min, $sec, $tz, $params); |
|
2426 | 2426 | return TRUE; |
2427 | 2427 | } |
2428 | 2428 | /*********************************************************************************/ |
@@ -2437,17 +2437,17 @@ discard block |
||
2437 | 2437 | * @return string |
2438 | 2438 | */ |
2439 | 2439 | function createDuration() { |
2440 | - if( empty( $this->duration )) return FALSE; |
|
2441 | - if( !isset( $this->duration['value']['week'] ) && |
|
2442 | - !isset( $this->duration['value']['day'] ) && |
|
2443 | - !isset( $this->duration['value']['hour'] ) && |
|
2444 | - !isset( $this->duration['value']['min'] ) && |
|
2445 | - !isset( $this->duration['value']['sec'] )) |
|
2446 | - if( $this->getConfig( 'allowEmpty' )) |
|
2447 | - return $this->_createElement( 'DURATION', array(), null ); |
|
2440 | + if (empty($this->duration)) return FALSE; |
|
2441 | + if (!isset($this->duration['value']['week']) && |
|
2442 | + !isset($this->duration['value']['day']) && |
|
2443 | + !isset($this->duration['value']['hour']) && |
|
2444 | + !isset($this->duration['value']['min']) && |
|
2445 | + !isset($this->duration['value']['sec'])) |
|
2446 | + if ($this->getConfig('allowEmpty')) |
|
2447 | + return $this->_createElement('DURATION', array(), null); |
|
2448 | 2448 | else return FALSE; |
2449 | - $attributes = $this->_createParams( $this->duration['params'] ); |
|
2450 | - return $this->_createElement( 'DURATION', $attributes, $this->_format_duration( $this->duration['value'] )); |
|
2449 | + $attributes = $this->_createParams($this->duration['params']); |
|
2450 | + return $this->_createElement('DURATION', $attributes, $this->_format_duration($this->duration['value'])); |
|
2451 | 2451 | } |
2452 | 2452 | /** |
2453 | 2453 | * set calendar component property duration |
@@ -2462,20 +2462,20 @@ discard block |
||
2462 | 2462 | * @param array $params optional |
2463 | 2463 | * @return bool |
2464 | 2464 | */ |
2465 | - function setDuration( $week, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
|
2466 | - if( empty( $week )) if( $this->getConfig( 'allowEmpty' )) $week = null; else return FALSE; |
|
2467 | - if( is_array( $week ) && ( 1 <= count( $week ))) |
|
2468 | - $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day )); |
|
2469 | - elseif( is_string( $week ) && ( 3 <= strlen( trim( $week )))) { |
|
2470 | - $week = trim( $week ); |
|
2471 | - if( in_array( substr( $week, 0, 1 ), array( '+', '-' ))) |
|
2472 | - $week = substr( $week, 1 ); |
|
2473 | - $this->duration = array( 'value' => $this->_duration_string( $week ), 'params' => $this->_setParams( $day )); |
|
2474 | - } |
|
2475 | - elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec )) |
|
2465 | + function setDuration($week, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) { |
|
2466 | + if (empty($week)) if ($this->getConfig('allowEmpty')) $week = null; else return FALSE; |
|
2467 | + if (is_array($week) && (1 <= count($week))) |
|
2468 | + $this->duration = array('value' => $this->_duration_array($week), 'params' => $this->_setParams($day)); |
|
2469 | + elseif (is_string($week) && (3 <= strlen(trim($week)))) { |
|
2470 | + $week = trim($week); |
|
2471 | + if (in_array(substr($week, 0, 1), array('+', '-'))) |
|
2472 | + $week = substr($week, 1); |
|
2473 | + $this->duration = array('value' => $this->_duration_string($week), 'params' => $this->_setParams($day)); |
|
2474 | + } |
|
2475 | + elseif (empty($week) && empty($day) && empty($hour) && empty($min) && empty($sec)) |
|
2476 | 2476 | return FALSE; |
2477 | 2477 | else |
2478 | - $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params )); |
|
2478 | + $this->duration = array('value' => $this->_duration_array(array($week, $day, $hour, $min, $sec)), 'params' => $this->_setParams($params)); |
|
2479 | 2479 | return TRUE; |
2480 | 2480 | } |
2481 | 2481 | /*********************************************************************************/ |
@@ -2490,36 +2490,36 @@ discard block |
||
2490 | 2490 | * @return string |
2491 | 2491 | */ |
2492 | 2492 | function createExdate() { |
2493 | - if( empty( $this->exdate )) return FALSE; |
|
2493 | + if (empty($this->exdate)) return FALSE; |
|
2494 | 2494 | $output = null; |
2495 | - foreach( $this->exdate as $ex => $theExdate ) { |
|
2496 | - if( empty( $theExdate['value'] )) { |
|
2497 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'EXDATE' ); |
|
2495 | + foreach ($this->exdate as $ex => $theExdate) { |
|
2496 | + if (empty($theExdate['value'])) { |
|
2497 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('EXDATE'); |
|
2498 | 2498 | continue; |
2499 | 2499 | } |
2500 | 2500 | $content = $attributes = null; |
2501 | - foreach( $theExdate['value'] as $eix => $exdatePart ) { |
|
2502 | - $parno = count( $exdatePart ); |
|
2503 | - $formatted = $this->_format_date_time( $exdatePart, $parno ); |
|
2504 | - if( isset( $theExdate['params']['TZID'] )) |
|
2505 | - $formatted = str_replace( 'Z', '', $formatted); |
|
2506 | - if( 0 < $eix ) { |
|
2507 | - if( isset( $theExdate['value'][0]['tz'] )) { |
|
2508 | - if( ctype_digit( substr( $theExdate['value'][0]['tz'], -4 )) || |
|
2509 | - ( 'Z' == $theExdate['value'][0]['tz'] )) { |
|
2510 | - if( 'Z' != substr( $formatted, -1 )) |
|
2501 | + foreach ($theExdate['value'] as $eix => $exdatePart) { |
|
2502 | + $parno = count($exdatePart); |
|
2503 | + $formatted = $this->_format_date_time($exdatePart, $parno); |
|
2504 | + if (isset($theExdate['params']['TZID'])) |
|
2505 | + $formatted = str_replace('Z', '', $formatted); |
|
2506 | + if (0 < $eix) { |
|
2507 | + if (isset($theExdate['value'][0]['tz'])) { |
|
2508 | + if (ctype_digit(substr($theExdate['value'][0]['tz'], -4)) || |
|
2509 | + ('Z' == $theExdate['value'][0]['tz'])) { |
|
2510 | + if ('Z' != substr($formatted, -1)) |
|
2511 | 2511 | $formatted .= 'Z'; |
2512 | 2512 | } |
2513 | 2513 | else |
2514 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2514 | + $formatted = str_replace('Z', '', $formatted); |
|
2515 | 2515 | } |
2516 | 2516 | else |
2517 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2517 | + $formatted = str_replace('Z', '', $formatted); |
|
2518 | 2518 | } |
2519 | - $content .= ( 0 < $eix ) ? ','.$formatted : $formatted; |
|
2519 | + $content .= (0 < $eix) ? ','.$formatted : $formatted; |
|
2520 | 2520 | } |
2521 | - $attributes .= $this->_createParams( $theExdate['params'] ); |
|
2522 | - $output .= $this->_createElement( 'EXDATE', $attributes, $content ); |
|
2521 | + $attributes .= $this->_createParams($theExdate['params']); |
|
2522 | + $output .= $this->_createElement('EXDATE', $attributes, $content); |
|
2523 | 2523 | } |
2524 | 2524 | return $output; |
2525 | 2525 | } |
@@ -2533,44 +2533,44 @@ discard block |
||
2533 | 2533 | * @param integer $index, optional |
2534 | 2534 | * @return bool |
2535 | 2535 | */ |
2536 | - function setExdate( $exdates, $params=FALSE, $index=FALSE ) { |
|
2537 | - if( empty( $exdates )) { |
|
2538 | - if( $this->getConfig( 'allowEmpty' )) { |
|
2539 | - $this->_setMval( $this->exdate, null, $params, FALSE, $index ); |
|
2536 | + function setExdate($exdates, $params = FALSE, $index = FALSE) { |
|
2537 | + if (empty($exdates)) { |
|
2538 | + if ($this->getConfig('allowEmpty')) { |
|
2539 | + $this->_setMval($this->exdate, null, $params, FALSE, $index); |
|
2540 | 2540 | return TRUE; |
2541 | 2541 | } |
2542 | 2542 | else |
2543 | 2543 | return FALSE; |
2544 | 2544 | } |
2545 | - $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ))); |
|
2545 | + $input = array('params' => $this->_setParams($params, array('VALUE' => 'DATE-TIME'))); |
|
2546 | 2546 | /* ev. check 1:st date and save ev. timezone **/ |
2547 | - $this->_chkdatecfg( reset( $exdates ), $parno, $input['params'] ); |
|
2548 | - $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default parameter |
|
2549 | - foreach( $exdates as $eix => $theExdate ) { |
|
2550 | - if( $this->_isArrayTimestampDate( $theExdate )) |
|
2551 | - $exdatea = $this->_timestamp2date( $theExdate, $parno ); |
|
2552 | - elseif( is_array( $theExdate )) |
|
2553 | - $exdatea = $this->_date_time_array( $theExdate, $parno ); |
|
2554 | - elseif( 8 <= strlen( trim( $theExdate ))) // ex. 2006-08-03 10:12:18 |
|
2555 | - $exdatea = $this->_date_time_string( $theExdate, $parno ); |
|
2556 | - if( 3 == $parno ) |
|
2557 | - unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] ); |
|
2558 | - elseif( isset( $exdatea['tz'] )) |
|
2547 | + $this->_chkdatecfg(reset($exdates), $parno, $input['params']); |
|
2548 | + $this->_existRem($input['params'], 'VALUE', 'DATE-TIME'); // remove default parameter |
|
2549 | + foreach ($exdates as $eix => $theExdate) { |
|
2550 | + if ($this->_isArrayTimestampDate($theExdate)) |
|
2551 | + $exdatea = $this->_timestamp2date($theExdate, $parno); |
|
2552 | + elseif (is_array($theExdate)) |
|
2553 | + $exdatea = $this->_date_time_array($theExdate, $parno); |
|
2554 | + elseif (8 <= strlen(trim($theExdate))) // ex. 2006-08-03 10:12:18 |
|
2555 | + $exdatea = $this->_date_time_string($theExdate, $parno); |
|
2556 | + if (3 == $parno) |
|
2557 | + unset($exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz']); |
|
2558 | + elseif (isset($exdatea['tz'])) |
|
2559 | 2559 | $exdatea['tz'] = (string) $exdatea['tz']; |
2560 | - if( isset( $input['params']['TZID'] ) || |
|
2561 | - ( isset( $exdatea['tz'] ) && !$this->_isOffset( $exdatea['tz'] )) || |
|
2562 | - ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) || |
|
2563 | - ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) |
|
2564 | - unset( $exdatea['tz'] ); |
|
2560 | + if (isset($input['params']['TZID']) || |
|
2561 | + (isset($exdatea['tz']) && !$this->_isOffset($exdatea['tz'])) || |
|
2562 | + (isset($input['value'][0]) && (!isset($input['value'][0]['tz']))) || |
|
2563 | + (isset($input['value'][0]['tz']) && !$this->_isOffset($input['value'][0]['tz']))) |
|
2564 | + unset($exdatea['tz']); |
|
2565 | 2565 | $input['value'][] = $exdatea; |
2566 | 2566 | } |
2567 | - if( 0 >= count( $input['value'] )) |
|
2567 | + if (0 >= count($input['value'])) |
|
2568 | 2568 | return FALSE; |
2569 | - if( 3 == $parno ) { |
|
2569 | + if (3 == $parno) { |
|
2570 | 2570 | $input['params']['VALUE'] = 'DATE'; |
2571 | - unset( $input['params']['TZID'] ); |
|
2571 | + unset($input['params']['TZID']); |
|
2572 | 2572 | } |
2573 | - $this->_setMval( $this->exdate, $input['value'], $input['params'], FALSE, $index ); |
|
2573 | + $this->_setMval($this->exdate, $input['value'], $input['params'], FALSE, $index); |
|
2574 | 2574 | return TRUE; |
2575 | 2575 | } |
2576 | 2576 | /*********************************************************************************/ |
@@ -2585,8 +2585,8 @@ discard block |
||
2585 | 2585 | * @return string |
2586 | 2586 | */ |
2587 | 2587 | function createExrule() { |
2588 | - if( empty( $this->exrule )) return FALSE; |
|
2589 | - return $this->_format_recur( 'EXRULE', $this->exrule ); |
|
2588 | + if (empty($this->exrule)) return FALSE; |
|
2589 | + return $this->_format_recur('EXRULE', $this->exrule); |
|
2590 | 2590 | } |
2591 | 2591 | /** |
2592 | 2592 | * set calendar component property exdate |
@@ -2598,9 +2598,9 @@ discard block |
||
2598 | 2598 | * @param integer $index, optional |
2599 | 2599 | * @return bool |
2600 | 2600 | */ |
2601 | - function setExrule( $exruleset, $params=FALSE, $index=FALSE ) { |
|
2602 | - if( empty( $exruleset )) if( $this->getConfig( 'allowEmpty' )) $exruleset = null; else return FALSE; |
|
2603 | - $this->_setMval( $this->exrule, $this->_setRexrule( $exruleset ), $params, FALSE, $index ); |
|
2601 | + function setExrule($exruleset, $params = FALSE, $index = FALSE) { |
|
2602 | + if (empty($exruleset)) if ($this->getConfig('allowEmpty')) $exruleset = null; else return FALSE; |
|
2603 | + $this->_setMval($this->exrule, $this->_setRexrule($exruleset), $params, FALSE, $index); |
|
2604 | 2604 | return TRUE; |
2605 | 2605 | } |
2606 | 2606 | /*********************************************************************************/ |
@@ -2615,47 +2615,47 @@ discard block |
||
2615 | 2615 | * @return string |
2616 | 2616 | */ |
2617 | 2617 | function createFreebusy() { |
2618 | - if( empty( $this->freebusy )) return FALSE; |
|
2618 | + if (empty($this->freebusy)) return FALSE; |
|
2619 | 2619 | $output = null; |
2620 | - foreach( $this->freebusy as $freebusyPart ) { |
|
2621 | - if( empty( $freebusyPart['value'] )) { |
|
2622 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'FREEBUSY' ); |
|
2620 | + foreach ($this->freebusy as $freebusyPart) { |
|
2621 | + if (empty($freebusyPart['value'])) { |
|
2622 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('FREEBUSY'); |
|
2623 | 2623 | continue; |
2624 | 2624 | } |
2625 | 2625 | $attributes = $content = null; |
2626 | - if( isset( $freebusyPart['value']['fbtype'] )) { |
|
2626 | + if (isset($freebusyPart['value']['fbtype'])) { |
|
2627 | 2627 | $attributes .= $this->intAttrDelimiter.'FBTYPE='.$freebusyPart['value']['fbtype']; |
2628 | - unset( $freebusyPart['value']['fbtype'] ); |
|
2629 | - $freebusyPart['value'] = array_values( $freebusyPart['value'] ); |
|
2628 | + unset($freebusyPart['value']['fbtype']); |
|
2629 | + $freebusyPart['value'] = array_values($freebusyPart['value']); |
|
2630 | 2630 | } |
2631 | 2631 | else |
2632 | 2632 | $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY'; |
2633 | - $attributes .= $this->_createParams( $freebusyPart['params'] ); |
|
2633 | + $attributes .= $this->_createParams($freebusyPart['params']); |
|
2634 | 2634 | $fno = 1; |
2635 | - $cnt = count( $freebusyPart['value']); |
|
2636 | - foreach( $freebusyPart['value'] as $periodix => $freebusyPeriod ) { |
|
2637 | - $formatted = $this->_format_date_time( $freebusyPeriod[0] ); |
|
2635 | + $cnt = count($freebusyPart['value']); |
|
2636 | + foreach ($freebusyPart['value'] as $periodix => $freebusyPeriod) { |
|
2637 | + $formatted = $this->_format_date_time($freebusyPeriod[0]); |
|
2638 | 2638 | $content .= $formatted; |
2639 | 2639 | $content .= '/'; |
2640 | - $cnt2 = count( $freebusyPeriod[1]); |
|
2641 | - if( array_key_exists( 'year', $freebusyPeriod[1] )) // date-time |
|
2640 | + $cnt2 = count($freebusyPeriod[1]); |
|
2641 | + if (array_key_exists('year', $freebusyPeriod[1])) // date-time |
|
2642 | 2642 | $cnt2 = 7; |
2643 | - elseif( array_key_exists( 'week', $freebusyPeriod[1] )) // duration |
|
2643 | + elseif (array_key_exists('week', $freebusyPeriod[1])) // duration |
|
2644 | 2644 | $cnt2 = 5; |
2645 | - if(( 7 == $cnt2 ) && // period= -> date-time |
|
2646 | - isset( $freebusyPeriod[1]['year'] ) && |
|
2647 | - isset( $freebusyPeriod[1]['month'] ) && |
|
2648 | - isset( $freebusyPeriod[1]['day'] )) { |
|
2649 | - $content .= $this->_format_date_time( $freebusyPeriod[1] ); |
|
2645 | + if ((7 == $cnt2) && // period= -> date-time |
|
2646 | + isset($freebusyPeriod[1]['year']) && |
|
2647 | + isset($freebusyPeriod[1]['month']) && |
|
2648 | + isset($freebusyPeriod[1]['day'])) { |
|
2649 | + $content .= $this->_format_date_time($freebusyPeriod[1]); |
|
2650 | 2650 | } |
2651 | 2651 | else { // period= -> dur-time |
2652 | - $content .= $this->_format_duration( $freebusyPeriod[1] ); |
|
2652 | + $content .= $this->_format_duration($freebusyPeriod[1]); |
|
2653 | 2653 | } |
2654 | - if( $fno < $cnt ) |
|
2654 | + if ($fno < $cnt) |
|
2655 | 2655 | $content .= ','; |
2656 | 2656 | $fno++; |
2657 | 2657 | } |
2658 | - $output .= $this->_createElement( 'FREEBUSY', $attributes, $content ); |
|
2658 | + $output .= $this->_createElement('FREEBUSY', $attributes, $content); |
|
2659 | 2659 | } |
2660 | 2660 | return $output; |
2661 | 2661 | } |
@@ -2670,52 +2670,52 @@ discard block |
||
2670 | 2670 | * @param integer $index, optional |
2671 | 2671 | * @return bool |
2672 | 2672 | */ |
2673 | - function setFreebusy( $fbType, $fbValues, $params=FALSE, $index=FALSE ) { |
|
2674 | - if( empty( $fbValues )) { |
|
2675 | - if( $this->getConfig( 'allowEmpty' )) { |
|
2676 | - $this->_setMval( $this->freebusy, null, $params, FALSE, $index ); |
|
2673 | + function setFreebusy($fbType, $fbValues, $params = FALSE, $index = FALSE) { |
|
2674 | + if (empty($fbValues)) { |
|
2675 | + if ($this->getConfig('allowEmpty')) { |
|
2676 | + $this->_setMval($this->freebusy, null, $params, FALSE, $index); |
|
2677 | 2677 | return TRUE; |
2678 | 2678 | } |
2679 | 2679 | else |
2680 | 2680 | return FALSE; |
2681 | 2681 | } |
2682 | - $fbType = strtoupper( $fbType ); |
|
2683 | - if(( !in_array( $fbType, array( 'FREE', 'BUSY', 'BUSY-UNAVAILABLE', 'BUSY-TENTATIVE' ))) && |
|
2684 | - ( 'X-' != substr( $fbType, 0, 2 ))) |
|
2682 | + $fbType = strtoupper($fbType); |
|
2683 | + if ((!in_array($fbType, array('FREE', 'BUSY', 'BUSY-UNAVAILABLE', 'BUSY-TENTATIVE'))) && |
|
2684 | + ('X-' != substr($fbType, 0, 2))) |
|
2685 | 2685 | $fbType = 'BUSY'; |
2686 | - $input = array( 'fbtype' => $fbType ); |
|
2687 | - foreach( $fbValues as $fbPeriod ) { // periods => period |
|
2686 | + $input = array('fbtype' => $fbType); |
|
2687 | + foreach ($fbValues as $fbPeriod) { // periods => period |
|
2688 | 2688 | $freebusyPeriod = array(); |
2689 | - foreach( $fbPeriod as $fbMember ) { // pairs => singlepart |
|
2689 | + foreach ($fbPeriod as $fbMember) { // pairs => singlepart |
|
2690 | 2690 | $freebusyPairMember = array(); |
2691 | - if( is_array( $fbMember )) { |
|
2692 | - if( $this->_isArrayDate( $fbMember )) { // date-time value |
|
2693 | - $freebusyPairMember = $this->_date_time_array( $fbMember, 7 ); |
|
2691 | + if (is_array($fbMember)) { |
|
2692 | + if ($this->_isArrayDate($fbMember)) { // date-time value |
|
2693 | + $freebusyPairMember = $this->_date_time_array($fbMember, 7); |
|
2694 | 2694 | $freebusyPairMember['tz'] = 'Z'; |
2695 | 2695 | } |
2696 | - elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value |
|
2697 | - $freebusyPairMember = $this->_timestamp2date( $fbMember['timestamp'], 7 ); |
|
2696 | + elseif ($this->_isArrayTimestampDate($fbMember)) { // timestamp value |
|
2697 | + $freebusyPairMember = $this->_timestamp2date($fbMember['timestamp'], 7); |
|
2698 | 2698 | $freebusyPairMember['tz'] = 'Z'; |
2699 | 2699 | } |
2700 | 2700 | else { // array format duration |
2701 | - $freebusyPairMember = $this->_duration_array( $fbMember ); |
|
2701 | + $freebusyPairMember = $this->_duration_array($fbMember); |
|
2702 | 2702 | } |
2703 | 2703 | } |
2704 | - elseif(( 3 <= strlen( trim( $fbMember ))) && // string format duration |
|
2705 | - ( in_array( $fbMember{0}, array( 'P', '+', '-' )))) { |
|
2706 | - if( 'P' != $fbMember{0} ) |
|
2707 | - $fbmember = substr( $fbMember, 1 ); |
|
2708 | - $freebusyPairMember = $this->_duration_string( $fbMember ); |
|
2704 | + elseif ((3 <= strlen(trim($fbMember))) && // string format duration |
|
2705 | + (in_array($fbMember{0}, array('P', '+', '-')))) { |
|
2706 | + if ('P' != $fbMember{0} ) |
|
2707 | + $fbmember = substr($fbMember, 1); |
|
2708 | + $freebusyPairMember = $this->_duration_string($fbMember); |
|
2709 | 2709 | } |
2710 | - elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18 |
|
2711 | - $freebusyPairMember = $this->_date_time_string( $fbMember, 7 ); |
|
2710 | + elseif (8 <= strlen(trim($fbMember))) { // text date ex. 2006-08-03 10:12:18 |
|
2711 | + $freebusyPairMember = $this->_date_time_string($fbMember, 7); |
|
2712 | 2712 | $freebusyPairMember['tz'] = 'Z'; |
2713 | 2713 | } |
2714 | 2714 | $freebusyPeriod[] = $freebusyPairMember; |
2715 | 2715 | } |
2716 | 2716 | $input[] = $freebusyPeriod; |
2717 | 2717 | } |
2718 | - $this->_setMval( $this->freebusy, $input, $params, FALSE, $index ); |
|
2718 | + $this->_setMval($this->freebusy, $input, $params, FALSE, $index); |
|
2719 | 2719 | return TRUE; |
2720 | 2720 | } |
2721 | 2721 | /*********************************************************************************/ |
@@ -2730,15 +2730,15 @@ discard block |
||
2730 | 2730 | * @return string |
2731 | 2731 | */ |
2732 | 2732 | function createGeo() { |
2733 | - if( empty( $this->geo )) return FALSE; |
|
2734 | - if( empty( $this->geo['value'] )) |
|
2735 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE; |
|
2736 | - $attributes = $this->_createParams( $this->geo['params'] ); |
|
2733 | + if (empty($this->geo)) return FALSE; |
|
2734 | + if (empty($this->geo['value'])) |
|
2735 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('GEO') : FALSE; |
|
2736 | + $attributes = $this->_createParams($this->geo['params']); |
|
2737 | 2737 | $content = null; |
2738 | - $content .= number_format( (float) $this->geo['value']['latitude'], 6, '.', ''); |
|
2738 | + $content .= number_format((float) $this->geo['value']['latitude'], 6, '.', ''); |
|
2739 | 2739 | $content .= ';'; |
2740 | - $content .= number_format( (float) $this->geo['value']['longitude'], 6, '.', ''); |
|
2741 | - return $this->_createElement( 'GEO', $attributes, $content ); |
|
2740 | + $content .= number_format((float) $this->geo['value']['longitude'], 6, '.', ''); |
|
2741 | + return $this->_createElement('GEO', $attributes, $content); |
|
2742 | 2742 | } |
2743 | 2743 | /** |
2744 | 2744 | * set calendar component property geo |
@@ -2750,15 +2750,15 @@ discard block |
||
2750 | 2750 | * @param array $params optional |
2751 | 2751 | * @return bool |
2752 | 2752 | */ |
2753 | - function setGeo( $latitude, $longitude, $params=FALSE ) { |
|
2754 | - if( !empty( $latitude ) && !empty( $longitude )) { |
|
2755 | - if( !is_array( $this->geo )) $this->geo = array(); |
|
2753 | + function setGeo($latitude, $longitude, $params = FALSE) { |
|
2754 | + if (!empty($latitude) && !empty($longitude)) { |
|
2755 | + if (!is_array($this->geo)) $this->geo = array(); |
|
2756 | 2756 | $this->geo['value']['latitude'] = $latitude; |
2757 | 2757 | $this->geo['value']['longitude'] = $longitude; |
2758 | - $this->geo['params'] = $this->_setParams( $params ); |
|
2758 | + $this->geo['params'] = $this->_setParams($params); |
|
2759 | 2759 | } |
2760 | - elseif( $this->getConfig( 'allowEmpty' )) |
|
2761 | - $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) ); |
|
2760 | + elseif ($this->getConfig('allowEmpty')) |
|
2761 | + $this->geo = array('value' => null, 'params' => $this->_setParams($params)); |
|
2762 | 2762 | else |
2763 | 2763 | return FALSE; |
2764 | 2764 | return TRUE; |
@@ -2775,10 +2775,10 @@ discard block |
||
2775 | 2775 | * @return string |
2776 | 2776 | */ |
2777 | 2777 | function createLastModified() { |
2778 | - if( empty( $this->lastmodified )) return FALSE; |
|
2779 | - $attributes = $this->_createParams( $this->lastmodified['params'] ); |
|
2780 | - $formatted = $this->_format_date_time( $this->lastmodified['value'], 7 ); |
|
2781 | - return $this->_createElement( 'LAST-MODIFIED', $attributes, $formatted ); |
|
2778 | + if (empty($this->lastmodified)) return FALSE; |
|
2779 | + $attributes = $this->_createParams($this->lastmodified['params']); |
|
2780 | + $formatted = $this->_format_date_time($this->lastmodified['value'], 7); |
|
2781 | + return $this->_createElement('LAST-MODIFIED', $attributes, $formatted); |
|
2782 | 2782 | } |
2783 | 2783 | /** |
2784 | 2784 | * set calendar component property completed |
@@ -2794,10 +2794,10 @@ discard block |
||
2794 | 2794 | * @param array $params optional |
2795 | 2795 | * @return boll |
2796 | 2796 | */ |
2797 | - function setLastModified( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
|
2798 | - if( empty( $year )) |
|
2799 | - $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' ))); |
|
2800 | - $this->lastmodified = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
|
2797 | + function setLastModified($year = FALSE, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) { |
|
2798 | + if (empty($year)) |
|
2799 | + $year = date('Ymd\THis', mktime(date('H'), date('i'), date('s') - date('Z'), date('m'), date('d'), date('Y'))); |
|
2800 | + $this->lastmodified = $this->_setDate2($year, $month, $day, $hour, $min, $sec, $params); |
|
2801 | 2801 | return TRUE; |
2802 | 2802 | } |
2803 | 2803 | /*********************************************************************************/ |
@@ -2812,12 +2812,12 @@ discard block |
||
2812 | 2812 | * @return string |
2813 | 2813 | */ |
2814 | 2814 | function createLocation() { |
2815 | - if( empty( $this->location )) return FALSE; |
|
2816 | - if( empty( $this->location['value'] )) |
|
2817 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE; |
|
2818 | - $attributes = $this->_createParams( $this->location['params'], array( 'ALTREP', 'LANGUAGE' )); |
|
2819 | - $content = $this->_strrep( $this->location['value'] ); |
|
2820 | - return $this->_createElement( 'LOCATION', $attributes, $content ); |
|
2815 | + if (empty($this->location)) return FALSE; |
|
2816 | + if (empty($this->location['value'])) |
|
2817 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('LOCATION') : FALSE; |
|
2818 | + $attributes = $this->_createParams($this->location['params'], array('ALTREP', 'LANGUAGE')); |
|
2819 | + $content = $this->_strrep($this->location['value']); |
|
2820 | + return $this->_createElement('LOCATION', $attributes, $content); |
|
2821 | 2821 | } |
2822 | 2822 | /** |
2823 | 2823 | * set calendar component property location |
@@ -2828,9 +2828,9 @@ discard block |
||
2828 | 2828 | * @param array params optional |
2829 | 2829 | * @return bool |
2830 | 2830 | */ |
2831 | - function setLocation( $value, $params=FALSE ) { |
|
2832 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2833 | - $this->location = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
2831 | + function setLocation($value, $params = FALSE) { |
|
2832 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
2833 | + $this->location = array('value' => $value, 'params' => $this->_setParams($params)); |
|
2834 | 2834 | return TRUE; |
2835 | 2835 | } |
2836 | 2836 | /*********************************************************************************/ |
@@ -2845,13 +2845,13 @@ discard block |
||
2845 | 2845 | * @return string |
2846 | 2846 | */ |
2847 | 2847 | function createOrganizer() { |
2848 | - if( empty( $this->organizer )) return FALSE; |
|
2849 | - if( empty( $this->organizer['value'] )) |
|
2850 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE; |
|
2851 | - $attributes = $this->_createParams( $this->organizer['params'] |
|
2852 | - , array( 'CN', 'DIR', 'LANGUAGE', 'SENT-BY' )); |
|
2848 | + if (empty($this->organizer)) return FALSE; |
|
2849 | + if (empty($this->organizer['value'])) |
|
2850 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('ORGANIZER') : FALSE; |
|
2851 | + $attributes = $this->_createParams($this->organizer['params'] |
|
2852 | + , array('CN', 'DIR', 'LANGUAGE', 'SENT-BY')); |
|
2853 | 2853 | $content = 'MAILTO:'.$this->organizer['value']; |
2854 | - return $this->_createElement( 'ORGANIZER', $attributes, $content ); |
|
2854 | + return $this->_createElement('ORGANIZER', $attributes, $content); |
|
2855 | 2855 | } |
2856 | 2856 | /** |
2857 | 2857 | * set calendar component property organizer |
@@ -2862,14 +2862,14 @@ discard block |
||
2862 | 2862 | * @param array params optional |
2863 | 2863 | * @return bool |
2864 | 2864 | */ |
2865 | - function setOrganizer( $value, $params=FALSE ) { |
|
2866 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2867 | - $value = str_replace ( 'MAILTO:', '', $value ); |
|
2868 | - $value = str_replace ( 'mailto:', '', $value ); |
|
2869 | - $this->organizer = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
2870 | - if( isset( $this->organizer['params']['SENT-BY'] )) { |
|
2871 | - if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 ))) |
|
2872 | - $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 ); |
|
2865 | + function setOrganizer($value, $params = FALSE) { |
|
2866 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
2867 | + $value = str_replace('MAILTO:', '', $value); |
|
2868 | + $value = str_replace('mailto:', '', $value); |
|
2869 | + $this->organizer = array('value' => $value, 'params' => $this->_setParams($params)); |
|
2870 | + if (isset($this->organizer['params']['SENT-BY'])) { |
|
2871 | + if ('MAILTO' == strtoupper(substr($this->organizer['params']['SENT-BY'], 0, 6))) |
|
2872 | + $this->organizer['params']['SENT-BY'] = substr($this->organizer['params']['SENT-BY'], 7); |
|
2873 | 2873 | } |
2874 | 2874 | return TRUE; |
2875 | 2875 | } |
@@ -2885,11 +2885,11 @@ discard block |
||
2885 | 2885 | * @return string |
2886 | 2886 | */ |
2887 | 2887 | function createPercentComplete() { |
2888 | - if( empty( $this->percentcomplete )) return FALSE; |
|
2889 | - if( empty( $this->percentcomplete['value'] )) |
|
2890 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE; |
|
2891 | - $attributes = $this->_createParams( $this->percentcomplete['params'] ); |
|
2892 | - return $this->_createElement( 'PERCENT-COMPLETE', $attributes, $this->percentcomplete['value'] ); |
|
2888 | + if (empty($this->percentcomplete)) return FALSE; |
|
2889 | + if (empty($this->percentcomplete['value'])) |
|
2890 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('PERCENT-COMPLETE') : FALSE; |
|
2891 | + $attributes = $this->_createParams($this->percentcomplete['params']); |
|
2892 | + return $this->_createElement('PERCENT-COMPLETE', $attributes, $this->percentcomplete['value']); |
|
2893 | 2893 | } |
2894 | 2894 | /** |
2895 | 2895 | * set calendar component property percent-complete |
@@ -2900,9 +2900,9 @@ discard block |
||
2900 | 2900 | * @param array $params optional |
2901 | 2901 | * @return bool |
2902 | 2902 | */ |
2903 | - function setPercentComplete( $value, $params=FALSE ) { |
|
2904 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2905 | - $this->percentcomplete = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
2903 | + function setPercentComplete($value, $params = FALSE) { |
|
2904 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
2905 | + $this->percentcomplete = array('value' => $value, 'params' => $this->_setParams($params)); |
|
2906 | 2906 | return TRUE; |
2907 | 2907 | } |
2908 | 2908 | /*********************************************************************************/ |
@@ -2917,11 +2917,11 @@ discard block |
||
2917 | 2917 | * @return string |
2918 | 2918 | */ |
2919 | 2919 | function createPriority() { |
2920 | - if( empty( $this->priority )) return FALSE; |
|
2921 | - if( empty( $this->priority['value'] )) |
|
2922 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE; |
|
2923 | - $attributes = $this->_createParams( $this->priority['params'] ); |
|
2924 | - return $this->_createElement( 'PRIORITY', $attributes, $this->priority['value'] ); |
|
2920 | + if (empty($this->priority)) return FALSE; |
|
2921 | + if (empty($this->priority['value'])) |
|
2922 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('PRIORITY') : FALSE; |
|
2923 | + $attributes = $this->_createParams($this->priority['params']); |
|
2924 | + return $this->_createElement('PRIORITY', $attributes, $this->priority['value']); |
|
2925 | 2925 | } |
2926 | 2926 | /** |
2927 | 2927 | * set calendar component property priority |
@@ -2932,9 +2932,9 @@ discard block |
||
2932 | 2932 | * @param array $params optional |
2933 | 2933 | * @return bool |
2934 | 2934 | */ |
2935 | - function setPriority( $value, $params=FALSE ) { |
|
2936 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2937 | - $this->priority = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
2935 | + function setPriority($value, $params = FALSE) { |
|
2936 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
2937 | + $this->priority = array('value' => $value, 'params' => $this->_setParams($params)); |
|
2938 | 2938 | return TRUE; |
2939 | 2939 | } |
2940 | 2940 | /*********************************************************************************/ |
@@ -2949,91 +2949,91 @@ discard block |
||
2949 | 2949 | * @return string |
2950 | 2950 | */ |
2951 | 2951 | function createRdate() { |
2952 | - if( empty( $this->rdate )) return FALSE; |
|
2953 | - $utctime = ( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE; |
|
2952 | + if (empty($this->rdate)) return FALSE; |
|
2953 | + $utctime = (in_array($this->objName, array('vtimezone', 'standard', 'daylight'))) ? TRUE : FALSE; |
|
2954 | 2954 | $output = null; |
2955 | - if( $utctime ) |
|
2956 | - unset( $this->rdate['params']['TZID'] ); |
|
2957 | - foreach( $this->rdate as $theRdate ) { |
|
2958 | - if( empty( $theRdate['value'] )) { |
|
2959 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RDATE' ); |
|
2955 | + if ($utctime) |
|
2956 | + unset($this->rdate['params']['TZID']); |
|
2957 | + foreach ($this->rdate as $theRdate) { |
|
2958 | + if (empty($theRdate['value'])) { |
|
2959 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('RDATE'); |
|
2960 | 2960 | continue; |
2961 | 2961 | } |
2962 | - if( $utctime ) |
|
2963 | - unset( $theRdate['params']['TZID'] ); |
|
2964 | - $attributes = $this->_createParams( $theRdate['params'] ); |
|
2965 | - $cnt = count( $theRdate['value'] ); |
|
2962 | + if ($utctime) |
|
2963 | + unset($theRdate['params']['TZID']); |
|
2964 | + $attributes = $this->_createParams($theRdate['params']); |
|
2965 | + $cnt = count($theRdate['value']); |
|
2966 | 2966 | $content = null; |
2967 | 2967 | $rno = 1; |
2968 | - foreach( $theRdate['value'] as $rpix => $rdatePart ) { |
|
2968 | + foreach ($theRdate['value'] as $rpix => $rdatePart) { |
|
2969 | 2969 | $contentPart = null; |
2970 | - if( is_array( $rdatePart ) && |
|
2971 | - isset( $theRdate['params']['VALUE'] ) && ( 'PERIOD' == $theRdate['params']['VALUE'] )) { // PERIOD |
|
2972 | - if( $utctime ) |
|
2973 | - unset( $rdatePart[0]['tz'] ); |
|
2974 | - $formatted = $this->_format_date_time( $rdatePart[0]); // PERIOD part 1 |
|
2975 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
2976 | - $formatted = str_replace( 'Z', '', $formatted); |
|
2977 | - if( 0 < $rpix ) { |
|
2978 | - if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) { |
|
2979 | - if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z'; |
|
2970 | + if (is_array($rdatePart) && |
|
2971 | + isset($theRdate['params']['VALUE']) && ('PERIOD' == $theRdate['params']['VALUE'])) { // PERIOD |
|
2972 | + if ($utctime) |
|
2973 | + unset($rdatePart[0]['tz']); |
|
2974 | + $formatted = $this->_format_date_time($rdatePart[0]); // PERIOD part 1 |
|
2975 | + if ($utctime || !empty($theRdate['params']['TZID'])) |
|
2976 | + $formatted = str_replace('Z', '', $formatted); |
|
2977 | + if (0 < $rpix) { |
|
2978 | + if (!empty($rdatePart[0]['tz']) && $this->_isOffset($rdatePart[0]['tz'])) { |
|
2979 | + if ('Z' != substr($formatted, -1)) $formatted .= 'Z'; |
|
2980 | 2980 | } |
2981 | 2981 | else |
2982 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2982 | + $formatted = str_replace('Z', '', $formatted); |
|
2983 | 2983 | } |
2984 | 2984 | $contentPart .= $formatted; |
2985 | 2985 | $contentPart .= '/'; |
2986 | - $cnt2 = count( $rdatePart[1]); |
|
2987 | - if( array_key_exists( 'year', $rdatePart[1] )) { |
|
2988 | - if( array_key_exists( 'hour', $rdatePart[1] )) |
|
2989 | - $cnt2 = 7; // date-time |
|
2986 | + $cnt2 = count($rdatePart[1]); |
|
2987 | + if (array_key_exists('year', $rdatePart[1])) { |
|
2988 | + if (array_key_exists('hour', $rdatePart[1])) |
|
2989 | + $cnt2 = 7; // date-time |
|
2990 | 2990 | else |
2991 | - $cnt2 = 3; // date |
|
2991 | + $cnt2 = 3; // date |
|
2992 | 2992 | } |
2993 | - elseif( array_key_exists( 'week', $rdatePart[1] )) // duration |
|
2993 | + elseif (array_key_exists('week', $rdatePart[1])) // duration |
|
2994 | 2994 | $cnt2 = 5; |
2995 | - if(( 7 == $cnt2 ) && // period= -> date-time |
|
2996 | - isset( $rdatePart[1]['year'] ) && |
|
2997 | - isset( $rdatePart[1]['month'] ) && |
|
2998 | - isset( $rdatePart[1]['day'] )) { |
|
2999 | - if( $utctime ) |
|
3000 | - unset( $rdatePart[1]['tz'] ); |
|
3001 | - $formatted = $this->_format_date_time( $rdatePart[1] ); // PERIOD part 2 |
|
3002 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
3003 | - $formatted = str_replace( 'Z', '', $formatted); |
|
3004 | - if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) { |
|
3005 | - if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z'; |
|
2995 | + if ((7 == $cnt2) && // period= -> date-time |
|
2996 | + isset($rdatePart[1]['year']) && |
|
2997 | + isset($rdatePart[1]['month']) && |
|
2998 | + isset($rdatePart[1]['day'])) { |
|
2999 | + if ($utctime) |
|
3000 | + unset($rdatePart[1]['tz']); |
|
3001 | + $formatted = $this->_format_date_time($rdatePart[1]); // PERIOD part 2 |
|
3002 | + if ($utctime || !empty($theRdate['params']['TZID'])) |
|
3003 | + $formatted = str_replace('Z', '', $formatted); |
|
3004 | + if (!empty($rdatePart[0]['tz']) && $this->_isOffset($rdatePart[0]['tz'])) { |
|
3005 | + if ('Z' != substr($formatted, -1)) $formatted .= 'Z'; |
|
3006 | 3006 | } |
3007 | 3007 | else |
3008 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
3008 | + $formatted = str_replace('Z', '', $formatted); |
|
3009 | 3009 | $contentPart .= $formatted; |
3010 | 3010 | } |
3011 | 3011 | else { // period= -> dur-time |
3012 | - $contentPart .= $this->_format_duration( $rdatePart[1] ); |
|
3012 | + $contentPart .= $this->_format_duration($rdatePart[1]); |
|
3013 | 3013 | } |
3014 | 3014 | } // PERIOD end |
3015 | 3015 | else { // SINGLE date start |
3016 | - if( $utctime ) |
|
3017 | - unset( $rdatePart['tz'] ); |
|
3018 | - $formatted = $this->_format_date_time( $rdatePart); |
|
3019 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
3020 | - $formatted = str_replace( 'Z', '', $formatted); |
|
3021 | - if( !$utctime && ( 0 < $rpix )) { |
|
3022 | - if( !empty( $theRdate['value'][0]['tz'] ) && $this->_isOffset( $theRdate['value'][0]['tz'] )) { |
|
3023 | - if( 'Z' != substr( $formatted, -1 )) |
|
3016 | + if ($utctime) |
|
3017 | + unset($rdatePart['tz']); |
|
3018 | + $formatted = $this->_format_date_time($rdatePart); |
|
3019 | + if ($utctime || !empty($theRdate['params']['TZID'])) |
|
3020 | + $formatted = str_replace('Z', '', $formatted); |
|
3021 | + if (!$utctime && (0 < $rpix)) { |
|
3022 | + if (!empty($theRdate['value'][0]['tz']) && $this->_isOffset($theRdate['value'][0]['tz'])) { |
|
3023 | + if ('Z' != substr($formatted, -1)) |
|
3024 | 3024 | $formatted .= 'Z'; |
3025 | 3025 | } |
3026 | 3026 | else |
3027 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
3027 | + $formatted = str_replace('Z', '', $formatted); |
|
3028 | 3028 | } |
3029 | 3029 | $contentPart .= $formatted; |
3030 | 3030 | } |
3031 | 3031 | $content .= $contentPart; |
3032 | - if( $rno < $cnt ) |
|
3032 | + if ($rno < $cnt) |
|
3033 | 3033 | $content .= ','; |
3034 | 3034 | $rno++; |
3035 | 3035 | } |
3036 | - $output .= $this->_createElement( 'RDATE', $attributes, $content ); |
|
3036 | + $output .= $this->_createElement('RDATE', $attributes, $content); |
|
3037 | 3037 | } |
3038 | 3038 | return $output; |
3039 | 3039 | } |
@@ -3047,93 +3047,93 @@ discard block |
||
3047 | 3047 | * @param integer $index, optional |
3048 | 3048 | * @return bool |
3049 | 3049 | */ |
3050 | - function setRdate( $rdates, $params=FALSE, $index=FALSE ) { |
|
3051 | - if( empty( $rdates )) { |
|
3052 | - if( $this->getConfig( 'allowEmpty' )) { |
|
3053 | - $this->_setMval( $this->rdate, null, $params, FALSE, $index ); |
|
3050 | + function setRdate($rdates, $params = FALSE, $index = FALSE) { |
|
3051 | + if (empty($rdates)) { |
|
3052 | + if ($this->getConfig('allowEmpty')) { |
|
3053 | + $this->_setMval($this->rdate, null, $params, FALSE, $index); |
|
3054 | 3054 | return TRUE; |
3055 | 3055 | } |
3056 | 3056 | else |
3057 | 3057 | return FALSE; |
3058 | 3058 | } |
3059 | - $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ))); |
|
3060 | - if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) { |
|
3061 | - unset( $input['params']['TZID'] ); |
|
3059 | + $input = array('params' => $this->_setParams($params, array('VALUE' => 'DATE-TIME'))); |
|
3060 | + if (in_array($this->objName, array('vtimezone', 'standard', 'daylight'))) { |
|
3061 | + unset($input['params']['TZID']); |
|
3062 | 3062 | $input['params']['VALUE'] = 'DATE-TIME'; |
3063 | 3063 | } |
3064 | 3064 | /* check if PERIOD, if not set */ |
3065 | - if((!isset( $input['params']['VALUE'] ) || !in_array( $input['params']['VALUE'], array( 'DATE', 'PERIOD' ))) && |
|
3066 | - isset( $rdates[0] ) && is_array( $rdates[0] ) && ( 2 == count( $rdates[0] )) && |
|
3067 | - isset( $rdates[0][0] ) && isset( $rdates[0][1] ) && !isset( $rdates[0]['timestamp'] ) && |
|
3068 | - (( is_array( $rdates[0][0] ) && ( isset( $rdates[0][0]['timestamp'] ) || |
|
3069 | - $this->_isArrayDate( $rdates[0][0] ))) || |
|
3070 | - ( is_string( $rdates[0][0] ) && ( 8 <= strlen( trim( $rdates[0][0] ))))) && |
|
3071 | - ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] )))))) |
|
3065 | + if ((!isset($input['params']['VALUE']) || !in_array($input['params']['VALUE'], array('DATE', 'PERIOD'))) && |
|
3066 | + isset($rdates[0]) && is_array($rdates[0]) && (2 == count($rdates[0])) && |
|
3067 | + isset($rdates[0][0]) && isset($rdates[0][1]) && !isset($rdates[0]['timestamp']) && |
|
3068 | + ((is_array($rdates[0][0]) && (isset($rdates[0][0]['timestamp']) || |
|
3069 | + $this->_isArrayDate($rdates[0][0]))) || |
|
3070 | + (is_string($rdates[0][0]) && (8 <= strlen(trim($rdates[0][0]))))) && |
|
3071 | + (is_array($rdates[0][1]) || (is_string($rdates[0][1]) && (3 <= strlen(trim($rdates[0][1])))))) |
|
3072 | 3072 | $input['params']['VALUE'] = 'PERIOD'; |
3073 | 3073 | /* check 1:st date, upd. $parno (opt) and save ev. timezone **/ |
3074 | - $date = reset( $rdates ); |
|
3075 | - if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) // PERIOD |
|
3076 | - $date = reset( $date ); |
|
3077 | - $this->_chkdatecfg( $date, $parno, $input['params'] ); |
|
3078 | - if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) |
|
3079 | - unset( $input['params']['TZID'] ); |
|
3080 | - $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default |
|
3081 | - foreach( $rdates as $rpix => $theRdate ) { |
|
3074 | + $date = reset($rdates); |
|
3075 | + if (isset($input['params']['VALUE']) && ('PERIOD' == $input['params']['VALUE'])) // PERIOD |
|
3076 | + $date = reset($date); |
|
3077 | + $this->_chkdatecfg($date, $parno, $input['params']); |
|
3078 | + if (in_array($this->objName, array('vtimezone', 'standard', 'daylight'))) |
|
3079 | + unset($input['params']['TZID']); |
|
3080 | + $this->_existRem($input['params'], 'VALUE', 'DATE-TIME'); // remove default |
|
3081 | + foreach ($rdates as $rpix => $theRdate) { |
|
3082 | 3082 | $inputa = null; |
3083 | - if( is_array( $theRdate )) { |
|
3084 | - if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) { // PERIOD |
|
3085 | - foreach( $theRdate as $rix => $rPeriod ) { |
|
3086 | - if( is_array( $rPeriod )) { |
|
3087 | - if( $this->_isArrayTimestampDate( $rPeriod )) // timestamp |
|
3088 | - $inputab = ( isset( $rPeriod['tz'] )) ? $this->_timestamp2date( $rPeriod, $parno ) : $this->_timestamp2date( $rPeriod, 6 ); |
|
3089 | - elseif( $this->_isArrayDate( $rPeriod )) |
|
3090 | - $inputab = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 ); |
|
3091 | - elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod )))) // text-date |
|
3092 | - $inputab = $this->_date_time_string( reset( $rPeriod ), $parno ); |
|
3083 | + if (is_array($theRdate)) { |
|
3084 | + if (isset($input['params']['VALUE']) && ('PERIOD' == $input['params']['VALUE'])) { // PERIOD |
|
3085 | + foreach ($theRdate as $rix => $rPeriod) { |
|
3086 | + if (is_array($rPeriod)) { |
|
3087 | + if ($this->_isArrayTimestampDate($rPeriod)) // timestamp |
|
3088 | + $inputab = (isset($rPeriod['tz'])) ? $this->_timestamp2date($rPeriod, $parno) : $this->_timestamp2date($rPeriod, 6); |
|
3089 | + elseif ($this->_isArrayDate($rPeriod)) |
|
3090 | + $inputab = (3 < count($rPeriod)) ? $this->_date_time_array($rPeriod, $parno) : $this->_date_time_array($rPeriod, 6); |
|
3091 | + elseif ((1 == count($rPeriod)) && (8 <= strlen(reset($rPeriod)))) // text-date |
|
3092 | + $inputab = $this->_date_time_string(reset($rPeriod), $parno); |
|
3093 | 3093 | else // array format duration |
3094 | - $inputab = $this->_duration_array( $rPeriod ); |
|
3094 | + $inputab = $this->_duration_array($rPeriod); |
|
3095 | 3095 | } |
3096 | - elseif(( 3 <= strlen( trim( $rPeriod ))) && // string format duration |
|
3097 | - ( in_array( $rPeriod{0}, array( 'P', '+', '-' )))) { |
|
3098 | - if( 'P' != $rPeriod{0} ) |
|
3099 | - $rPeriod = substr( $rPeriod, 1 ); |
|
3100 | - $inputab = $this->_duration_string( $rPeriod ); |
|
3096 | + elseif ((3 <= strlen(trim($rPeriod))) && // string format duration |
|
3097 | + (in_array($rPeriod{0}, array('P', '+', '-')))) { |
|
3098 | + if ('P' != $rPeriod{0} ) |
|
3099 | + $rPeriod = substr($rPeriod, 1); |
|
3100 | + $inputab = $this->_duration_string($rPeriod); |
|
3101 | 3101 | } |
3102 | - elseif( 8 <= strlen( trim( $rPeriod ))) // text date ex. 2006-08-03 10:12:18 |
|
3103 | - $inputab = $this->_date_time_string( $rPeriod, $parno ); |
|
3104 | - if( isset( $input['params']['TZID'] ) || |
|
3105 | - ( isset( $inputab['tz'] ) && !$this->_isOffset( $inputab['tz'] )) || |
|
3106 | - ( isset( $inputa[0] ) && ( !isset( $inputa[0]['tz'] ))) || |
|
3107 | - ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] ))) |
|
3108 | - unset( $inputab['tz'] ); |
|
3109 | - $inputa[] = $inputab; |
|
3102 | + elseif (8 <= strlen(trim($rPeriod))) // text date ex. 2006-08-03 10:12:18 |
|
3103 | + $inputab = $this->_date_time_string($rPeriod, $parno); |
|
3104 | + if (isset($input['params']['TZID']) || |
|
3105 | + (isset($inputab['tz']) && !$this->_isOffset($inputab['tz'])) || |
|
3106 | + (isset($inputa[0]) && (!isset($inputa[0]['tz']))) || |
|
3107 | + (isset($inputa[0]['tz']) && !$this->_isOffset($inputa[0]['tz']))) |
|
3108 | + unset($inputab['tz']); |
|
3109 | + $inputa[] = $inputab; |
|
3110 | 3110 | } |
3111 | 3111 | } // PERIOD end |
3112 | - elseif ( $this->_isArrayTimestampDate( $theRdate )) // timestamp |
|
3113 | - $inputa = $this->_timestamp2date( $theRdate, $parno ); |
|
3112 | + elseif ($this->_isArrayTimestampDate($theRdate)) // timestamp |
|
3113 | + $inputa = $this->_timestamp2date($theRdate, $parno); |
|
3114 | 3114 | else // date[-time] |
3115 | - $inputa = $this->_date_time_array( $theRdate, $parno ); |
|
3115 | + $inputa = $this->_date_time_array($theRdate, $parno); |
|
3116 | 3116 | } |
3117 | - elseif( 8 <= strlen( trim( $theRdate ))) // text date ex. 2006-08-03 10:12:18 |
|
3118 | - $inputa = $this->_date_time_string( $theRdate, $parno ); |
|
3119 | - if( !isset( $input['params']['VALUE'] ) || ( 'PERIOD' != $input['params']['VALUE'] )) { // no PERIOD |
|
3120 | - if( 3 == $parno ) |
|
3121 | - unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] ); |
|
3122 | - elseif( isset( $inputa['tz'] )) |
|
3117 | + elseif (8 <= strlen(trim($theRdate))) // text date ex. 2006-08-03 10:12:18 |
|
3118 | + $inputa = $this->_date_time_string($theRdate, $parno); |
|
3119 | + if (!isset($input['params']['VALUE']) || ('PERIOD' != $input['params']['VALUE'])) { // no PERIOD |
|
3120 | + if (3 == $parno) |
|
3121 | + unset($inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz']); |
|
3122 | + elseif (isset($inputa['tz'])) |
|
3123 | 3123 | $inputa['tz'] = (string) $inputa['tz']; |
3124 | - if( isset( $input['params']['TZID'] ) || |
|
3125 | - ( isset( $inputa['tz'] ) && !$this->_isOffset( $inputa['tz'] )) || |
|
3126 | - ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) || |
|
3127 | - ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) |
|
3128 | - unset( $inputa['tz'] ); |
|
3124 | + if (isset($input['params']['TZID']) || |
|
3125 | + (isset($inputa['tz']) && !$this->_isOffset($inputa['tz'])) || |
|
3126 | + (isset($input['value'][0]) && (!isset($input['value'][0]['tz']))) || |
|
3127 | + (isset($input['value'][0]['tz']) && !$this->_isOffset($input['value'][0]['tz']))) |
|
3128 | + unset($inputa['tz']); |
|
3129 | 3129 | } |
3130 | 3130 | $input['value'][] = $inputa; |
3131 | 3131 | } |
3132 | - if( 3 == $parno ) { |
|
3132 | + if (3 == $parno) { |
|
3133 | 3133 | $input['params']['VALUE'] = 'DATE'; |
3134 | - unset( $input['params']['TZID'] ); |
|
3134 | + unset($input['params']['TZID']); |
|
3135 | 3135 | } |
3136 | - $this->_setMval( $this->rdate, $input['value'], $input['params'], FALSE, $index ); |
|
3136 | + $this->_setMval($this->rdate, $input['value'], $input['params'], FALSE, $index); |
|
3137 | 3137 | return TRUE; |
3138 | 3138 | } |
3139 | 3139 | /*********************************************************************************/ |
@@ -3148,12 +3148,12 @@ discard block |
||
3148 | 3148 | * @return string |
3149 | 3149 | */ |
3150 | 3150 | function createRecurrenceid() { |
3151 | - if( empty( $this->recurrenceid )) return FALSE; |
|
3152 | - if( empty( $this->recurrenceid['value'] )) |
|
3153 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE; |
|
3154 | - $formatted = $this->_format_date_time( $this->recurrenceid['value'] ); |
|
3155 | - $attributes = $this->_createParams( $this->recurrenceid['params'] ); |
|
3156 | - return $this->_createElement( 'RECURRENCE-ID', $attributes, $formatted ); |
|
3151 | + if (empty($this->recurrenceid)) return FALSE; |
|
3152 | + if (empty($this->recurrenceid['value'])) |
|
3153 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('RECURRENCE-ID') : FALSE; |
|
3154 | + $formatted = $this->_format_date_time($this->recurrenceid['value']); |
|
3155 | + $attributes = $this->_createParams($this->recurrenceid['params']); |
|
3156 | + return $this->_createElement('RECURRENCE-ID', $attributes, $formatted); |
|
3157 | 3157 | } |
3158 | 3158 | /** |
3159 | 3159 | * set calendar component property recurrence-id |
@@ -3169,16 +3169,16 @@ discard block |
||
3169 | 3169 | * @param array $params optional |
3170 | 3170 | * @return bool |
3171 | 3171 | */ |
3172 | - function setRecurrenceid( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) { |
|
3173 | - if( empty( $year )) { |
|
3174 | - if( $this->getConfig( 'allowEmpty' )) { |
|
3175 | - $this->recurrenceid = array( 'value' => null, 'params' => null ); |
|
3172 | + function setRecurrenceid($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE) { |
|
3173 | + if (empty($year)) { |
|
3174 | + if ($this->getConfig('allowEmpty')) { |
|
3175 | + $this->recurrenceid = array('value' => null, 'params' => null); |
|
3176 | 3176 | return TRUE; |
3177 | 3177 | } |
3178 | 3178 | else |
3179 | 3179 | return FALSE; |
3180 | 3180 | } |
3181 | - $this->recurrenceid = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
|
3181 | + $this->recurrenceid = $this->_setDate($year, $month, $day, $hour, $min, $sec, $tz, $params); |
|
3182 | 3182 | return TRUE; |
3183 | 3183 | } |
3184 | 3184 | /*********************************************************************************/ |
@@ -3193,18 +3193,18 @@ discard block |
||
3193 | 3193 | * @return string |
3194 | 3194 | */ |
3195 | 3195 | function createRelatedTo() { |
3196 | - if( empty( $this->relatedto )) return FALSE; |
|
3196 | + if (empty($this->relatedto)) return FALSE; |
|
3197 | 3197 | $output = null; |
3198 | - foreach( $this->relatedto as $relation ) { |
|
3199 | - if( empty( $relation['value'] )) { |
|
3200 | - if( $this->getConfig( 'allowEmpty' )) $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] )); |
|
3198 | + foreach ($this->relatedto as $relation) { |
|
3199 | + if (empty($relation['value'])) { |
|
3200 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('RELATED-TO', $this->_createParams($relation['params'])); |
|
3201 | 3201 | continue; |
3202 | 3202 | } |
3203 | - $attributes = $this->_createParams( $relation['params'] ); |
|
3204 | - $content = ( 'xcal' != $this->format ) ? '<' : ''; |
|
3205 | - $content .= $this->_strrep( $relation['value'] ); |
|
3206 | - $content .= ( 'xcal' != $this->format ) ? '>' : ''; |
|
3207 | - $output .= $this->_createElement( 'RELATED-TO', $attributes, $content ); |
|
3203 | + $attributes = $this->_createParams($relation['params']); |
|
3204 | + $content = ('xcal' != $this->format) ? '<' : ''; |
|
3205 | + $content .= $this->_strrep($relation['value']); |
|
3206 | + $content .= ('xcal' != $this->format) ? '>' : ''; |
|
3207 | + $output .= $this->_createElement('RELATED-TO', $attributes, $content); |
|
3208 | 3208 | } |
3209 | 3209 | return $output; |
3210 | 3210 | } |
@@ -3218,12 +3218,12 @@ discard block |
||
3218 | 3218 | * @param index $index, optional |
3219 | 3219 | * @return bool |
3220 | 3220 | */ |
3221 | - function setRelatedTo( $value, $params=FALSE, $index=FALSE ) { |
|
3222 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3223 | - if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 ))) |
|
3224 | - $value = substr( $value, 1, ( strlen( $value ) - 2 )); |
|
3225 | - $this->_existRem( $params, 'RELTYPE', 'PARENT', TRUE ); // remove default |
|
3226 | - $this->_setMval( $this->relatedto, $value, $params, FALSE, $index ); |
|
3221 | + function setRelatedTo($value, $params = FALSE, $index = FALSE) { |
|
3222 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3223 | + if (('<' == substr($value, 0, 1)) && ('>' == substr($value, -1))) |
|
3224 | + $value = substr($value, 1, (strlen($value) - 2)); |
|
3225 | + $this->_existRem($params, 'RELTYPE', 'PARENT', TRUE); // remove default |
|
3226 | + $this->_setMval($this->relatedto, $value, $params, FALSE, $index); |
|
3227 | 3227 | return TRUE; |
3228 | 3228 | } |
3229 | 3229 | /*********************************************************************************/ |
@@ -3238,11 +3238,11 @@ discard block |
||
3238 | 3238 | * @return string |
3239 | 3239 | */ |
3240 | 3240 | function createRepeat() { |
3241 | - if( empty( $this->repeat )) return FALSE; |
|
3242 | - if( empty( $this->repeat['value'] )) |
|
3243 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE; |
|
3244 | - $attributes = $this->_createParams( $this->repeat['params'] ); |
|
3245 | - return $this->_createElement( 'REPEAT', $attributes, $this->repeat['value'] ); |
|
3241 | + if (empty($this->repeat)) return FALSE; |
|
3242 | + if (empty($this->repeat['value'])) |
|
3243 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('REPEAT') : FALSE; |
|
3244 | + $attributes = $this->_createParams($this->repeat['params']); |
|
3245 | + return $this->_createElement('REPEAT', $attributes, $this->repeat['value']); |
|
3246 | 3246 | } |
3247 | 3247 | /** |
3248 | 3248 | * set calendar component property transp |
@@ -3253,9 +3253,9 @@ discard block |
||
3253 | 3253 | * @param array $params optional |
3254 | 3254 | * @return void |
3255 | 3255 | */ |
3256 | - function setRepeat( $value, $params=FALSE ) { |
|
3257 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3258 | - $this->repeat = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3256 | + function setRepeat($value, $params = FALSE) { |
|
3257 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3258 | + $this->repeat = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3259 | 3259 | return TRUE; |
3260 | 3260 | } |
3261 | 3261 | /*********************************************************************************/ |
@@ -3269,19 +3269,19 @@ discard block |
||
3269 | 3269 | * @return string |
3270 | 3270 | */ |
3271 | 3271 | function createRequestStatus() { |
3272 | - if( empty( $this->requeststatus )) return FALSE; |
|
3272 | + if (empty($this->requeststatus)) return FALSE; |
|
3273 | 3273 | $output = null; |
3274 | - foreach( $this->requeststatus as $rstat ) { |
|
3275 | - if( empty( $rstat['value']['statcode'] )) { |
|
3276 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'REQUEST-STATUS' ); |
|
3274 | + foreach ($this->requeststatus as $rstat) { |
|
3275 | + if (empty($rstat['value']['statcode'])) { |
|
3276 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('REQUEST-STATUS'); |
|
3277 | 3277 | continue; |
3278 | 3278 | } |
3279 | - $attributes = $this->_createParams( $rstat['params'], array( 'LANGUAGE' )); |
|
3280 | - $content = number_format( (float) $rstat['value']['statcode'], 2, '.', ''); |
|
3281 | - $content .= ';'.$this->_strrep( $rstat['value']['text'] ); |
|
3282 | - if( isset( $rstat['value']['extdata'] )) |
|
3283 | - $content .= ';'.$this->_strrep( $rstat['value']['extdata'] ); |
|
3284 | - $output .= $this->_createElement( 'REQUEST-STATUS', $attributes, $content ); |
|
3279 | + $attributes = $this->_createParams($rstat['params'], array('LANGUAGE')); |
|
3280 | + $content = number_format((float) $rstat['value']['statcode'], 2, '.', ''); |
|
3281 | + $content .= ';'.$this->_strrep($rstat['value']['text']); |
|
3282 | + if (isset($rstat['value']['extdata'])) |
|
3283 | + $content .= ';'.$this->_strrep($rstat['value']['extdata']); |
|
3284 | + $output .= $this->_createElement('REQUEST-STATUS', $attributes, $content); |
|
3285 | 3285 | } |
3286 | 3286 | return $output; |
3287 | 3287 | } |
@@ -3297,12 +3297,12 @@ discard block |
||
3297 | 3297 | * @param integer $index, optional |
3298 | 3298 | * @return bool |
3299 | 3299 | */ |
3300 | - function setRequestStatus( $statcode, $text, $extdata=FALSE, $params=FALSE, $index=FALSE ) { |
|
3301 | - if( empty( $statcode ) || empty( $text )) if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null; else return FALSE; |
|
3302 | - $input = array( 'statcode' => $statcode, 'text' => $text ); |
|
3303 | - if( $extdata ) |
|
3300 | + function setRequestStatus($statcode, $text, $extdata = FALSE, $params = FALSE, $index = FALSE) { |
|
3301 | + if (empty($statcode) || empty($text)) if ($this->getConfig('allowEmpty')) $statcode = $text = null; else return FALSE; |
|
3302 | + $input = array('statcode' => $statcode, 'text' => $text); |
|
3303 | + if ($extdata) |
|
3304 | 3304 | $input['extdata'] = $extdata; |
3305 | - $this->_setMval( $this->requeststatus, $input, $params, FALSE, $index ); |
|
3305 | + $this->_setMval($this->requeststatus, $input, $params, FALSE, $index); |
|
3306 | 3306 | return TRUE; |
3307 | 3307 | } |
3308 | 3308 | /*********************************************************************************/ |
@@ -3317,22 +3317,22 @@ discard block |
||
3317 | 3317 | * @return string |
3318 | 3318 | */ |
3319 | 3319 | function createResources() { |
3320 | - if( empty( $this->resources )) return FALSE; |
|
3320 | + if (empty($this->resources)) return FALSE; |
|
3321 | 3321 | $output = null; |
3322 | - foreach( $this->resources as $resource ) { |
|
3323 | - if( empty( $resource['value'] )) { |
|
3324 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RESOURCES' ); |
|
3322 | + foreach ($this->resources as $resource) { |
|
3323 | + if (empty($resource['value'])) { |
|
3324 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('RESOURCES'); |
|
3325 | 3325 | continue; |
3326 | 3326 | } |
3327 | - $attributes = $this->_createParams( $resource['params'], array( 'ALTREP', 'LANGUAGE' )); |
|
3328 | - if( is_array( $resource['value'] )) { |
|
3329 | - foreach( $resource['value'] as $rix => $resourcePart ) |
|
3330 | - $resource['value'][$rix] = $this->_strrep( $resourcePart ); |
|
3331 | - $content = implode( ',', $resource['value'] ); |
|
3327 | + $attributes = $this->_createParams($resource['params'], array('ALTREP', 'LANGUAGE')); |
|
3328 | + if (is_array($resource['value'])) { |
|
3329 | + foreach ($resource['value'] as $rix => $resourcePart) |
|
3330 | + $resource['value'][$rix] = $this->_strrep($resourcePart); |
|
3331 | + $content = implode(',', $resource['value']); |
|
3332 | 3332 | } |
3333 | 3333 | else |
3334 | - $content = $this->_strrep( $resource['value'] ); |
|
3335 | - $output .= $this->_createElement( 'RESOURCES', $attributes, $content ); |
|
3334 | + $content = $this->_strrep($resource['value']); |
|
3335 | + $output .= $this->_createElement('RESOURCES', $attributes, $content); |
|
3336 | 3336 | } |
3337 | 3337 | return $output; |
3338 | 3338 | } |
@@ -3346,9 +3346,9 @@ discard block |
||
3346 | 3346 | * @param integer $index, optional |
3347 | 3347 | * @return bool |
3348 | 3348 | */ |
3349 | - function setResources( $value, $params=FALSE, $index=FALSE ) { |
|
3350 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3351 | - $this->_setMval( $this->resources, $value, $params, FALSE, $index ); |
|
3349 | + function setResources($value, $params = FALSE, $index = FALSE) { |
|
3350 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3351 | + $this->_setMval($this->resources, $value, $params, FALSE, $index); |
|
3352 | 3352 | return TRUE; |
3353 | 3353 | } |
3354 | 3354 | /*********************************************************************************/ |
@@ -3363,8 +3363,8 @@ discard block |
||
3363 | 3363 | * @return string |
3364 | 3364 | */ |
3365 | 3365 | function createRrule() { |
3366 | - if( empty( $this->rrule )) return FALSE; |
|
3367 | - return $this->_format_recur( 'RRULE', $this->rrule ); |
|
3366 | + if (empty($this->rrule)) return FALSE; |
|
3367 | + return $this->_format_recur('RRULE', $this->rrule); |
|
3368 | 3368 | } |
3369 | 3369 | /** |
3370 | 3370 | * set calendar component property rrule |
@@ -3376,9 +3376,9 @@ discard block |
||
3376 | 3376 | * @param integer $index, optional |
3377 | 3377 | * @return void |
3378 | 3378 | */ |
3379 | - function setRrule( $rruleset, $params=FALSE, $index=FALSE ) { |
|
3380 | - if( empty( $rruleset )) if( $this->getConfig( 'allowEmpty' )) $rruleset = null; else return FALSE; |
|
3381 | - $this->_setMval( $this->rrule, $this->_setRexrule( $rruleset ), $params, FALSE, $index ); |
|
3379 | + function setRrule($rruleset, $params = FALSE, $index = FALSE) { |
|
3380 | + if (empty($rruleset)) if ($this->getConfig('allowEmpty')) $rruleset = null; else return FALSE; |
|
3381 | + $this->_setMval($this->rrule, $this->_setRexrule($rruleset), $params, FALSE, $index); |
|
3382 | 3382 | return TRUE; |
3383 | 3383 | } |
3384 | 3384 | /*********************************************************************************/ |
@@ -3392,11 +3392,11 @@ discard block |
||
3392 | 3392 | * @return string |
3393 | 3393 | */ |
3394 | 3394 | function createSequence() { |
3395 | - if( empty( $this->sequence )) return FALSE; |
|
3396 | - if( empty( $this->sequence['value'] )) |
|
3397 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE; |
|
3398 | - $attributes = $this->_createParams( $this->sequence['params'] ); |
|
3399 | - return $this->_createElement( 'SEQUENCE', $attributes, $this->sequence['value'] ); |
|
3395 | + if (empty($this->sequence)) return FALSE; |
|
3396 | + if (empty($this->sequence['value'])) |
|
3397 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('SEQUENCE') : FALSE; |
|
3398 | + $attributes = $this->_createParams($this->sequence['params']); |
|
3399 | + return $this->_createElement('SEQUENCE', $attributes, $this->sequence['value']); |
|
3400 | 3400 | } |
3401 | 3401 | /** |
3402 | 3402 | * set calendar component property sequence |
@@ -3406,10 +3406,10 @@ discard block |
||
3406 | 3406 | * @param array $params optional |
3407 | 3407 | * @return bool |
3408 | 3408 | */ |
3409 | - function setSequence( $value=FALSE, $params=FALSE ) { |
|
3410 | - if( empty( $value )) |
|
3411 | - $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1; |
|
3412 | - $this->sequence = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3409 | + function setSequence($value = FALSE, $params = FALSE) { |
|
3410 | + if (empty($value)) |
|
3411 | + $value = (isset($this->sequence['value']) && (0 < $this->sequence['value'])) ? $this->sequence['value'] + 1 : 1; |
|
3412 | + $this->sequence = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3413 | 3413 | return TRUE; |
3414 | 3414 | } |
3415 | 3415 | /*********************************************************************************/ |
@@ -3424,11 +3424,11 @@ discard block |
||
3424 | 3424 | * @return string |
3425 | 3425 | */ |
3426 | 3426 | function createStatus() { |
3427 | - if( empty( $this->status )) return FALSE; |
|
3428 | - if( empty( $this->status['value'] )) |
|
3429 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE; |
|
3430 | - $attributes = $this->_createParams( $this->status['params'] ); |
|
3431 | - return $this->_createElement( 'STATUS', $attributes, $this->status['value'] ); |
|
3427 | + if (empty($this->status)) return FALSE; |
|
3428 | + if (empty($this->status['value'])) |
|
3429 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('STATUS') : FALSE; |
|
3430 | + $attributes = $this->_createParams($this->status['params']); |
|
3431 | + return $this->_createElement('STATUS', $attributes, $this->status['value']); |
|
3432 | 3432 | } |
3433 | 3433 | /** |
3434 | 3434 | * set calendar component property status |
@@ -3439,9 +3439,9 @@ discard block |
||
3439 | 3439 | * @param array $params optional |
3440 | 3440 | * @return bool |
3441 | 3441 | */ |
3442 | - function setStatus( $value, $params=FALSE ) { |
|
3443 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3444 | - $this->status = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3442 | + function setStatus($value, $params = FALSE) { |
|
3443 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3444 | + $this->status = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3445 | 3445 | return TRUE; |
3446 | 3446 | } |
3447 | 3447 | /*********************************************************************************/ |
@@ -3456,12 +3456,12 @@ discard block |
||
3456 | 3456 | * @return string |
3457 | 3457 | */ |
3458 | 3458 | function createSummary() { |
3459 | - if( empty( $this->summary )) return FALSE; |
|
3460 | - if( empty( $this->summary['value'] )) |
|
3461 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE; |
|
3462 | - $attributes = $this->_createParams( $this->summary['params'], array( 'ALTREP', 'LANGUAGE' )); |
|
3463 | - $content = $this->_strrep( $this->summary['value'] ); |
|
3464 | - return $this->_createElement( 'SUMMARY', $attributes, $content ); |
|
3459 | + if (empty($this->summary)) return FALSE; |
|
3460 | + if (empty($this->summary['value'])) |
|
3461 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('SUMMARY') : FALSE; |
|
3462 | + $attributes = $this->_createParams($this->summary['params'], array('ALTREP', 'LANGUAGE')); |
|
3463 | + $content = $this->_strrep($this->summary['value']); |
|
3464 | + return $this->_createElement('SUMMARY', $attributes, $content); |
|
3465 | 3465 | } |
3466 | 3466 | /** |
3467 | 3467 | * set calendar component property summary |
@@ -3472,9 +3472,9 @@ discard block |
||
3472 | 3472 | * @param string $params optional |
3473 | 3473 | * @return bool |
3474 | 3474 | */ |
3475 | - function setSummary( $value, $params=FALSE ) { |
|
3476 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3477 | - $this->summary = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3475 | + function setSummary($value, $params = FALSE) { |
|
3476 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3477 | + $this->summary = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3478 | 3478 | return TRUE; |
3479 | 3479 | } |
3480 | 3480 | /*********************************************************************************/ |
@@ -3489,11 +3489,11 @@ discard block |
||
3489 | 3489 | * @return string |
3490 | 3490 | */ |
3491 | 3491 | function createTransp() { |
3492 | - if( empty( $this->transp )) return FALSE; |
|
3493 | - if( empty( $this->transp['value'] )) |
|
3494 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE; |
|
3495 | - $attributes = $this->_createParams( $this->transp['params'] ); |
|
3496 | - return $this->_createElement( 'TRANSP', $attributes, $this->transp['value'] ); |
|
3492 | + if (empty($this->transp)) return FALSE; |
|
3493 | + if (empty($this->transp['value'])) |
|
3494 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('TRANSP') : FALSE; |
|
3495 | + $attributes = $this->_createParams($this->transp['params']); |
|
3496 | + return $this->_createElement('TRANSP', $attributes, $this->transp['value']); |
|
3497 | 3497 | } |
3498 | 3498 | /** |
3499 | 3499 | * set calendar component property transp |
@@ -3504,9 +3504,9 @@ discard block |
||
3504 | 3504 | * @param string $params optional |
3505 | 3505 | * @return bool |
3506 | 3506 | */ |
3507 | - function setTransp( $value, $params=FALSE ) { |
|
3508 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3509 | - $this->transp = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3507 | + function setTransp($value, $params = FALSE) { |
|
3508 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3509 | + $this->transp = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3510 | 3510 | return TRUE; |
3511 | 3511 | } |
3512 | 3512 | /*********************************************************************************/ |
@@ -3521,23 +3521,23 @@ discard block |
||
3521 | 3521 | * @return string |
3522 | 3522 | */ |
3523 | 3523 | function createTrigger() { |
3524 | - if( empty( $this->trigger )) return FALSE; |
|
3525 | - if( empty( $this->trigger['value'] )) |
|
3526 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE; |
|
3524 | + if (empty($this->trigger)) return FALSE; |
|
3525 | + if (empty($this->trigger['value'])) |
|
3526 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('TRIGGER') : FALSE; |
|
3527 | 3527 | $content = $attributes = null; |
3528 | - if( isset( $this->trigger['value']['year'] ) && |
|
3529 | - isset( $this->trigger['value']['month'] ) && |
|
3530 | - isset( $this->trigger['value']['day'] )) |
|
3531 | - $content .= $this->_format_date_time( $this->trigger['value'] ); |
|
3528 | + if (isset($this->trigger['value']['year']) && |
|
3529 | + isset($this->trigger['value']['month']) && |
|
3530 | + isset($this->trigger['value']['day'])) |
|
3531 | + $content .= $this->_format_date_time($this->trigger['value']); |
|
3532 | 3532 | else { |
3533 | - if( TRUE !== $this->trigger['value']['relatedStart'] ) |
|
3533 | + if (TRUE !== $this->trigger['value']['relatedStart']) |
|
3534 | 3534 | $attributes .= $this->intAttrDelimiter.'RELATED=END'; |
3535 | - if( $this->trigger['value']['before'] ) |
|
3535 | + if ($this->trigger['value']['before']) |
|
3536 | 3536 | $content .= '-'; |
3537 | - $content .= $this->_format_duration( $this->trigger['value'] ); |
|
3537 | + $content .= $this->_format_duration($this->trigger['value']); |
|
3538 | 3538 | } |
3539 | - $attributes .= $this->_createParams( $this->trigger['params'] ); |
|
3540 | - return $this->_createElement( 'TRIGGER', $attributes, $content ); |
|
3539 | + $attributes .= $this->_createParams($this->trigger['params']); |
|
3540 | + return $this->_createElement('TRIGGER', $attributes, $content); |
|
3541 | 3541 | } |
3542 | 3542 | /** |
3543 | 3543 | * set calendar component property trigger |
@@ -3556,86 +3556,86 @@ discard block |
||
3556 | 3556 | * @param array $params optional |
3557 | 3557 | * @return bool |
3558 | 3558 | */ |
3559 | - function setTrigger( $year, $month=null, $day=null, $week=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $relatedStart=TRUE, $before=TRUE, $params=FALSE ) { |
|
3560 | - if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec )) |
|
3561 | - if( $this->getConfig( 'allowEmpty' )) { |
|
3562 | - $this->trigger = array( 'value' => null, 'params' => $this->_setParams( $params ) ); |
|
3559 | + function setTrigger($year, $month = null, $day = null, $week = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $relatedStart = TRUE, $before = TRUE, $params = FALSE) { |
|
3560 | + if (empty($year) && empty($month) && empty($day) && empty($week) && empty($hour) && empty($min) && empty($sec)) |
|
3561 | + if ($this->getConfig('allowEmpty')) { |
|
3562 | + $this->trigger = array('value' => null, 'params' => $this->_setParams($params)); |
|
3563 | 3563 | return TRUE; |
3564 | 3564 | } |
3565 | 3565 | else |
3566 | 3566 | return FALSE; |
3567 | - if( $this->_isArrayTimestampDate( $year )) { // timestamp |
|
3568 | - $params = $this->_setParams( $month ); |
|
3569 | - $date = $this->_timestamp2date( $year, 7 ); |
|
3570 | - foreach( $date as $k => $v ) |
|
3567 | + if ($this->_isArrayTimestampDate($year)) { // timestamp |
|
3568 | + $params = $this->_setParams($month); |
|
3569 | + $date = $this->_timestamp2date($year, 7); |
|
3570 | + foreach ($date as $k => $v) |
|
3571 | 3571 | $$k = $v; |
3572 | 3572 | } |
3573 | - elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) { |
|
3574 | - $params = $this->_setParams( $month ); |
|
3575 | - if(!(array_key_exists( 'year', $year ) && // exclude date-time |
|
3576 | - array_key_exists( 'month', $year ) && |
|
3577 | - array_key_exists( 'day', $year ))) { // so this must be a duration |
|
3578 | - if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) |
|
3573 | + elseif (is_array($year) && (is_array($month) || empty($month))) { |
|
3574 | + $params = $this->_setParams($month); |
|
3575 | + if (!(array_key_exists('year', $year) && // exclude date-time |
|
3576 | + array_key_exists('month', $year) && |
|
3577 | + array_key_exists('day', $year))) { // so this must be a duration |
|
3578 | + if (isset($params['RELATED']) && ('END' == $params['RELATED'])) |
|
3579 | 3579 | $relatedStart = FALSE; |
3580 | 3580 | else |
3581 | - $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE; |
|
3582 | - $before = ( array_key_exists( 'before', $year ) && ( TRUE !== $year['before'] )) ? FALSE : TRUE; |
|
3581 | + $relatedStart = (array_key_exists('relatedStart', $year) && (TRUE !== $year['relatedStart'])) ? FALSE : TRUE; |
|
3582 | + $before = (array_key_exists('before', $year) && (TRUE !== $year['before'])) ? FALSE : TRUE; |
|
3583 | 3583 | } |
3584 | - $SSYY = ( array_key_exists( 'year', $year )) ? $year['year'] : null; |
|
3585 | - $month = ( array_key_exists( 'month', $year )) ? $year['month'] : null; |
|
3586 | - $day = ( array_key_exists( 'day', $year )) ? $year['day'] : null; |
|
3587 | - $week = ( array_key_exists( 'week', $year )) ? $year['week'] : null; |
|
3588 | - $hour = ( array_key_exists( 'hour', $year )) ? $year['hour'] : 0; //null; |
|
3589 | - $min = ( array_key_exists( 'min', $year )) ? $year['min'] : 0; //null; |
|
3590 | - $sec = ( array_key_exists( 'sec', $year )) ? $year['sec'] : 0; //null; |
|
3584 | + $SSYY = (array_key_exists('year', $year)) ? $year['year'] : null; |
|
3585 | + $month = (array_key_exists('month', $year)) ? $year['month'] : null; |
|
3586 | + $day = (array_key_exists('day', $year)) ? $year['day'] : null; |
|
3587 | + $week = (array_key_exists('week', $year)) ? $year['week'] : null; |
|
3588 | + $hour = (array_key_exists('hour', $year)) ? $year['hour'] : 0; //null; |
|
3589 | + $min = (array_key_exists('min', $year)) ? $year['min'] : 0; //null; |
|
3590 | + $sec = (array_key_exists('sec', $year)) ? $year['sec'] : 0; //null; |
|
3591 | 3591 | $year = $SSYY; |
3592 | 3592 | } |
3593 | - elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) { // duration or date in a string |
|
3594 | - $params = $this->_setParams( $month ); |
|
3595 | - if( in_array( $year{0}, array( 'P', '+', '-' ))) { // duration |
|
3596 | - $relatedStart = ( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) ? FALSE : TRUE; |
|
3597 | - $before = ( '-' == $year{0} ) ? TRUE : FALSE; |
|
3598 | - if( 'P' != $year{0} ) |
|
3599 | - $year = substr( $year, 1 ); |
|
3600 | - $date = $this->_duration_string( $year); |
|
3593 | + elseif (is_string($year) && (is_array($month) || empty($month))) { // duration or date in a string |
|
3594 | + $params = $this->_setParams($month); |
|
3595 | + if (in_array($year{0}, array('P', '+', '-'))) { // duration |
|
3596 | + $relatedStart = (isset($params['RELATED']) && ('END' == $params['RELATED'])) ? FALSE : TRUE; |
|
3597 | + $before = ('-' == $year{0} ) ? TRUE : FALSE; |
|
3598 | + if ('P' != $year{0} ) |
|
3599 | + $year = substr($year, 1); |
|
3600 | + $date = $this->_duration_string($year); |
|
3601 | 3601 | } |
3602 | 3602 | else // date |
3603 | - $date = $this->_date_time_string( $year, 7 ); |
|
3604 | - unset( $year, $month, $day ); |
|
3605 | - foreach( $date as $k => $v ) |
|
3603 | + $date = $this->_date_time_string($year, 7); |
|
3604 | + unset($year, $month, $day); |
|
3605 | + foreach ($date as $k => $v) |
|
3606 | 3606 | $$k = $v; |
3607 | 3607 | } |
3608 | 3608 | else // single values in function input parameters |
3609 | - $params = $this->_setParams( $params ); |
|
3610 | - if( !empty( $year ) && !empty( $month ) && !empty( $day )) { // date |
|
3609 | + $params = $this->_setParams($params); |
|
3610 | + if (!empty($year) && !empty($month) && !empty($day)) { // date |
|
3611 | 3611 | $params['VALUE'] = 'DATE-TIME'; |
3612 | - $hour = ( $hour ) ? $hour : 0; |
|
3613 | - $min = ( $min ) ? $min : 0; |
|
3614 | - $sec = ( $sec ) ? $sec : 0; |
|
3615 | - $this->trigger = array( 'params' => $params ); |
|
3616 | - $this->trigger['value'] = array( 'year' => $year |
|
3612 | + $hour = ($hour) ? $hour : 0; |
|
3613 | + $min = ($min) ? $min : 0; |
|
3614 | + $sec = ($sec) ? $sec : 0; |
|
3615 | + $this->trigger = array('params' => $params); |
|
3616 | + $this->trigger['value'] = array('year' => $year |
|
3617 | 3617 | , 'month' => $month |
3618 | 3618 | , 'day' => $day |
3619 | 3619 | , 'hour' => $hour |
3620 | 3620 | , 'min' => $min |
3621 | 3621 | , 'sec' => $sec |
3622 | - , 'tz' => 'Z' ); |
|
3622 | + , 'tz' => 'Z'); |
|
3623 | 3623 | return TRUE; |
3624 | 3624 | } |
3625 | - elseif(( empty( $year ) && empty( $month )) && // duration |
|
3626 | - (!empty( $week ) || !empty( $day ) || !empty( $hour ) || !empty( $min ) || !empty( $sec ))) { |
|
3627 | - unset( $params['RELATED'] ); // set at output creation (END only) |
|
3628 | - unset( $params['VALUE'] ); // 'DURATION' default |
|
3629 | - $this->trigger = array( 'params' => $params ); |
|
3630 | - $relatedStart = ( FALSE !== $relatedStart ) ? TRUE : FALSE; |
|
3631 | - $before = ( FALSE !== $before ) ? TRUE : FALSE; |
|
3632 | - $this->trigger['value'] = array( 'relatedStart' => $relatedStart |
|
3633 | - , 'before' => $before ); |
|
3634 | - if( !empty( $week )) $this->trigger['value']['week'] = $week; |
|
3635 | - if( !empty( $day )) $this->trigger['value']['day'] = $day; |
|
3636 | - if( !empty( $hour )) $this->trigger['value']['hour'] = $hour; |
|
3637 | - if( !empty( $min )) $this->trigger['value']['min'] = $min; |
|
3638 | - if( !empty( $sec )) $this->trigger['value']['sec'] = $sec; |
|
3625 | + elseif ((empty($year) && empty($month)) && // duration |
|
3626 | + (!empty($week) || !empty($day) || !empty($hour) || !empty($min) || !empty($sec))) { |
|
3627 | + unset($params['RELATED']); // set at output creation (END only) |
|
3628 | + unset($params['VALUE']); // 'DURATION' default |
|
3629 | + $this->trigger = array('params' => $params); |
|
3630 | + $relatedStart = (FALSE !== $relatedStart) ? TRUE : FALSE; |
|
3631 | + $before = (FALSE !== $before) ? TRUE : FALSE; |
|
3632 | + $this->trigger['value'] = array('relatedStart' => $relatedStart |
|
3633 | + , 'before' => $before); |
|
3634 | + if (!empty($week)) $this->trigger['value']['week'] = $week; |
|
3635 | + if (!empty($day)) $this->trigger['value']['day'] = $day; |
|
3636 | + if (!empty($hour)) $this->trigger['value']['hour'] = $hour; |
|
3637 | + if (!empty($min)) $this->trigger['value']['min'] = $min; |
|
3638 | + if (!empty($sec)) $this->trigger['value']['sec'] = $sec; |
|
3639 | 3639 | return TRUE; |
3640 | 3640 | } |
3641 | 3641 | return FALSE; |
@@ -3652,11 +3652,11 @@ discard block |
||
3652 | 3652 | * @return string |
3653 | 3653 | */ |
3654 | 3654 | function createTzid() { |
3655 | - if( empty( $this->tzid )) return FALSE; |
|
3656 | - if( empty( $this->tzid['value'] )) |
|
3657 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE; |
|
3658 | - $attributes = $this->_createParams( $this->tzid['params'] ); |
|
3659 | - return $this->_createElement( 'TZID', $attributes, $this->_strrep( $this->tzid['value'] )); |
|
3655 | + if (empty($this->tzid)) return FALSE; |
|
3656 | + if (empty($this->tzid['value'])) |
|
3657 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('TZID') : FALSE; |
|
3658 | + $attributes = $this->_createParams($this->tzid['params']); |
|
3659 | + return $this->_createElement('TZID', $attributes, $this->_strrep($this->tzid['value'])); |
|
3660 | 3660 | } |
3661 | 3661 | /** |
3662 | 3662 | * set calendar component property tzid |
@@ -3667,9 +3667,9 @@ discard block |
||
3667 | 3667 | * @param array $params optional |
3668 | 3668 | * @return bool |
3669 | 3669 | */ |
3670 | - function setTzid( $value, $params=FALSE ) { |
|
3671 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3672 | - $this->tzid = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3670 | + function setTzid($value, $params = FALSE) { |
|
3671 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3672 | + $this->tzid = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3673 | 3673 | return TRUE; |
3674 | 3674 | } |
3675 | 3675 | /*********************************************************************************/ |
@@ -3685,14 +3685,14 @@ discard block |
||
3685 | 3685 | * @return string |
3686 | 3686 | */ |
3687 | 3687 | function createTzname() { |
3688 | - if( empty( $this->tzname )) return FALSE; |
|
3688 | + if (empty($this->tzname)) return FALSE; |
|
3689 | 3689 | $output = null; |
3690 | - foreach( $this->tzname as $theName ) { |
|
3691 | - if( !empty( $theName['value'] )) { |
|
3692 | - $attributes = $this->_createParams( $theName['params'], array( 'LANGUAGE' )); |
|
3693 | - $output .= $this->_createElement( 'TZNAME', $attributes, $this->_strrep( $theName['value'] )); |
|
3690 | + foreach ($this->tzname as $theName) { |
|
3691 | + if (!empty($theName['value'])) { |
|
3692 | + $attributes = $this->_createParams($theName['params'], array('LANGUAGE')); |
|
3693 | + $output .= $this->_createElement('TZNAME', $attributes, $this->_strrep($theName['value'])); |
|
3694 | 3694 | } |
3695 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'TZNAME' ); |
|
3695 | + elseif ($this->getConfig('allowEmpty')) $output .= $this->_createElement('TZNAME'); |
|
3696 | 3696 | } |
3697 | 3697 | return $output; |
3698 | 3698 | } |
@@ -3706,9 +3706,9 @@ discard block |
||
3706 | 3706 | * @param integer $index, optional |
3707 | 3707 | * @return bool |
3708 | 3708 | */ |
3709 | - function setTzname( $value, $params=FALSE, $index=FALSE ) { |
|
3710 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3711 | - $this->_setMval( $this->tzname, $value, $params, FALSE, $index ); |
|
3709 | + function setTzname($value, $params = FALSE, $index = FALSE) { |
|
3710 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3711 | + $this->_setMval($this->tzname, $value, $params, FALSE, $index); |
|
3712 | 3712 | return TRUE; |
3713 | 3713 | } |
3714 | 3714 | /*********************************************************************************/ |
@@ -3723,11 +3723,11 @@ discard block |
||
3723 | 3723 | * @return string |
3724 | 3724 | */ |
3725 | 3725 | function createTzoffsetfrom() { |
3726 | - if( empty( $this->tzoffsetfrom )) return FALSE; |
|
3727 | - if( empty( $this->tzoffsetfrom['value'] )) |
|
3728 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE; |
|
3729 | - $attributes = $this->_createParams( $this->tzoffsetfrom['params'] ); |
|
3730 | - return $this->_createElement( 'TZOFFSETFROM', $attributes, $this->tzoffsetfrom['value'] ); |
|
3726 | + if (empty($this->tzoffsetfrom)) return FALSE; |
|
3727 | + if (empty($this->tzoffsetfrom['value'])) |
|
3728 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('TZOFFSETFROM') : FALSE; |
|
3729 | + $attributes = $this->_createParams($this->tzoffsetfrom['params']); |
|
3730 | + return $this->_createElement('TZOFFSETFROM', $attributes, $this->tzoffsetfrom['value']); |
|
3731 | 3731 | } |
3732 | 3732 | /** |
3733 | 3733 | * set calendar component property tzoffsetfrom |
@@ -3738,9 +3738,9 @@ discard block |
||
3738 | 3738 | * @param string $params optional |
3739 | 3739 | * @return bool |
3740 | 3740 | */ |
3741 | - function setTzoffsetfrom( $value, $params=FALSE ) { |
|
3742 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3743 | - $this->tzoffsetfrom = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3741 | + function setTzoffsetfrom($value, $params = FALSE) { |
|
3742 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3743 | + $this->tzoffsetfrom = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3744 | 3744 | return TRUE; |
3745 | 3745 | } |
3746 | 3746 | /*********************************************************************************/ |
@@ -3755,11 +3755,11 @@ discard block |
||
3755 | 3755 | * @return string |
3756 | 3756 | */ |
3757 | 3757 | function createTzoffsetto() { |
3758 | - if( empty( $this->tzoffsetto )) return FALSE; |
|
3759 | - if( empty( $this->tzoffsetto['value'] )) |
|
3760 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE; |
|
3761 | - $attributes = $this->_createParams( $this->tzoffsetto['params'] ); |
|
3762 | - return $this->_createElement( 'TZOFFSETTO', $attributes, $this->tzoffsetto['value'] ); |
|
3758 | + if (empty($this->tzoffsetto)) return FALSE; |
|
3759 | + if (empty($this->tzoffsetto['value'])) |
|
3760 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('TZOFFSETTO') : FALSE; |
|
3761 | + $attributes = $this->_createParams($this->tzoffsetto['params']); |
|
3762 | + return $this->_createElement('TZOFFSETTO', $attributes, $this->tzoffsetto['value']); |
|
3763 | 3763 | } |
3764 | 3764 | /** |
3765 | 3765 | * set calendar component property tzoffsetto |
@@ -3770,9 +3770,9 @@ discard block |
||
3770 | 3770 | * @param string $params optional |
3771 | 3771 | * @return bool |
3772 | 3772 | */ |
3773 | - function setTzoffsetto( $value, $params=FALSE ) { |
|
3774 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3775 | - $this->tzoffsetto = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3773 | + function setTzoffsetto($value, $params = FALSE) { |
|
3774 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3775 | + $this->tzoffsetto = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3776 | 3776 | return TRUE; |
3777 | 3777 | } |
3778 | 3778 | /*********************************************************************************/ |
@@ -3787,11 +3787,11 @@ discard block |
||
3787 | 3787 | * @return string |
3788 | 3788 | */ |
3789 | 3789 | function createTzurl() { |
3790 | - if( empty( $this->tzurl )) return FALSE; |
|
3791 | - if( empty( $this->tzurl['value'] )) |
|
3792 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE; |
|
3793 | - $attributes = $this->_createParams( $this->tzurl['params'] ); |
|
3794 | - return $this->_createElement( 'TZURL', $attributes, $this->tzurl['value'] ); |
|
3790 | + if (empty($this->tzurl)) return FALSE; |
|
3791 | + if (empty($this->tzurl['value'])) |
|
3792 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('TZURL') : FALSE; |
|
3793 | + $attributes = $this->_createParams($this->tzurl['params']); |
|
3794 | + return $this->_createElement('TZURL', $attributes, $this->tzurl['value']); |
|
3795 | 3795 | } |
3796 | 3796 | /** |
3797 | 3797 | * set calendar component property tzurl |
@@ -3802,9 +3802,9 @@ discard block |
||
3802 | 3802 | * @param string $params optional |
3803 | 3803 | * @return boll |
3804 | 3804 | */ |
3805 | - function setTzurl( $value, $params=FALSE ) { |
|
3806 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3807 | - $this->tzurl = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3805 | + function setTzurl($value, $params = FALSE) { |
|
3806 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3807 | + $this->tzurl = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3808 | 3808 | return TRUE; |
3809 | 3809 | } |
3810 | 3810 | /*********************************************************************************/ |
@@ -3819,10 +3819,10 @@ discard block |
||
3819 | 3819 | * @return string |
3820 | 3820 | */ |
3821 | 3821 | function createUid() { |
3822 | - if( 0 >= count( $this->uid )) |
|
3822 | + if (0 >= count($this->uid)) |
|
3823 | 3823 | $this->_makeuid(); |
3824 | - $attributes = $this->_createParams( $this->uid['params'] ); |
|
3825 | - return $this->_createElement( 'UID', $attributes, $this->uid['value'] ); |
|
3824 | + $attributes = $this->_createParams($this->uid['params']); |
|
3825 | + return $this->_createElement('UID', $attributes, $this->uid['value']); |
|
3826 | 3826 | } |
3827 | 3827 | /** |
3828 | 3828 | * create an unique id for this calendar component object instance |
@@ -3836,13 +3836,13 @@ discard block |
||
3836 | 3836 | $unique = substr(microtime(), 2, 4); |
3837 | 3837 | $base = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPrRsStTuUvVxXuUvVwWzZ1234567890'; |
3838 | 3838 | $start = 0; |
3839 | - $end = strlen( $base ) - 1; |
|
3839 | + $end = strlen($base) - 1; |
|
3840 | 3840 | $length = 6; |
3841 | 3841 | $str = null; |
3842 | - for( $p = 0; $p < $length; $p++ ) |
|
3843 | - $unique .= $base{mt_rand( $start, $end )}; |
|
3844 | - $this->uid = array( 'params' => null ); |
|
3845 | - $this->uid['value'] = $date.'-'.$unique.'@'.$this->getConfig( 'unique_id' ); |
|
3842 | + for ($p = 0; $p < $length; $p++) |
|
3843 | + $unique .= $base{mt_rand($start, $end)}; |
|
3844 | + $this->uid = array('params' => null); |
|
3845 | + $this->uid['value'] = $date.'-'.$unique.'@'.$this->getConfig('unique_id'); |
|
3846 | 3846 | } |
3847 | 3847 | /** |
3848 | 3848 | * set calendar component property uid |
@@ -3853,9 +3853,9 @@ discard block |
||
3853 | 3853 | * @param string $params optional |
3854 | 3854 | * @return bool |
3855 | 3855 | */ |
3856 | - function setUid( $value, $params=FALSE ) { |
|
3857 | - if( empty( $value )) return FALSE; // no allowEmpty check here !!!! |
|
3858 | - $this->uid = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3856 | + function setUid($value, $params = FALSE) { |
|
3857 | + if (empty($value)) return FALSE; // no allowEmpty check here !!!! |
|
3858 | + $this->uid = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3859 | 3859 | return TRUE; |
3860 | 3860 | } |
3861 | 3861 | /*********************************************************************************/ |
@@ -3870,11 +3870,11 @@ discard block |
||
3870 | 3870 | * @return string |
3871 | 3871 | */ |
3872 | 3872 | function createUrl() { |
3873 | - if( empty( $this->url )) return FALSE; |
|
3874 | - if( empty( $this->url['value'] )) |
|
3875 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE; |
|
3876 | - $attributes = $this->_createParams( $this->url['params'] ); |
|
3877 | - return $this->_createElement( 'URL', $attributes, $this->url['value'] ); |
|
3873 | + if (empty($this->url)) return FALSE; |
|
3874 | + if (empty($this->url['value'])) |
|
3875 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('URL') : FALSE; |
|
3876 | + $attributes = $this->_createParams($this->url['params']); |
|
3877 | + return $this->_createElement('URL', $attributes, $this->url['value']); |
|
3878 | 3878 | } |
3879 | 3879 | /** |
3880 | 3880 | * set calendar component property url |
@@ -3885,9 +3885,9 @@ discard block |
||
3885 | 3885 | * @param string $params optional |
3886 | 3886 | * @return bool |
3887 | 3887 | */ |
3888 | - function setUrl( $value, $params=FALSE ) { |
|
3889 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3890 | - $this->url = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3888 | + function setUrl($value, $params = FALSE) { |
|
3889 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3890 | + $this->url = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3891 | 3891 | return TRUE; |
3892 | 3892 | } |
3893 | 3893 | /*********************************************************************************/ |
@@ -3902,22 +3902,22 @@ discard block |
||
3902 | 3902 | * @return string |
3903 | 3903 | */ |
3904 | 3904 | function createXprop() { |
3905 | - if( empty( $this->xprop )) return FALSE; |
|
3905 | + if (empty($this->xprop)) return FALSE; |
|
3906 | 3906 | $output = null; |
3907 | - foreach( $this->xprop as $label => $xpropPart ) { |
|
3908 | - if( empty( $xpropPart['value'] )) { |
|
3909 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $label ); |
|
3907 | + foreach ($this->xprop as $label => $xpropPart) { |
|
3908 | + if (empty($xpropPart['value'])) { |
|
3909 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement($label); |
|
3910 | 3910 | continue; |
3911 | 3911 | } |
3912 | - $attributes = $this->_createParams( $xpropPart['params'], array( 'LANGUAGE' )); |
|
3913 | - if( is_array( $xpropPart['value'] )) { |
|
3914 | - foreach( $xpropPart['value'] as $pix => $theXpart ) |
|
3915 | - $xpropPart['value'][$pix] = $this->_strrep( $theXpart ); |
|
3916 | - $xpropPart['value'] = implode( ',', $xpropPart['value'] ); |
|
3912 | + $attributes = $this->_createParams($xpropPart['params'], array('LANGUAGE')); |
|
3913 | + if (is_array($xpropPart['value'])) { |
|
3914 | + foreach ($xpropPart['value'] as $pix => $theXpart) |
|
3915 | + $xpropPart['value'][$pix] = $this->_strrep($theXpart); |
|
3916 | + $xpropPart['value'] = implode(',', $xpropPart['value']); |
|
3917 | 3917 | } |
3918 | 3918 | else |
3919 | - $xpropPart['value'] = $this->_strrep( $xpropPart['value'] ); |
|
3920 | - $output .= $this->_createElement( $label, $attributes, $xpropPart['value'] ); |
|
3919 | + $xpropPart['value'] = $this->_strrep($xpropPart['value']); |
|
3920 | + $output .= $this->_createElement($label, $attributes, $xpropPart['value']); |
|
3921 | 3921 | } |
3922 | 3922 | return $output; |
3923 | 3923 | } |
@@ -3931,14 +3931,14 @@ discard block |
||
3931 | 3931 | * @param array $params optional |
3932 | 3932 | * @return bool |
3933 | 3933 | */ |
3934 | - function setXprop( $label, $value, $params=FALSE ) { |
|
3935 | - if( empty( $label )) return; |
|
3936 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3937 | - $xprop = array( 'value' => $value ); |
|
3934 | + function setXprop($label, $value, $params = FALSE) { |
|
3935 | + if (empty($label)) return; |
|
3936 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3937 | + $xprop = array('value' => $value); |
|
3938 | 3938 | $toolbox = new calendarComponent(); |
3939 | - $xprop['params'] = $toolbox->_setParams( $params ); |
|
3940 | - if( !is_array( $this->xprop )) $this->xprop = array(); |
|
3941 | - $this->xprop[strtoupper( $label )] = $xprop; |
|
3939 | + $xprop['params'] = $toolbox->_setParams($params); |
|
3940 | + if (!is_array($this->xprop)) $this->xprop = array(); |
|
3941 | + $this->xprop[strtoupper($label)] = $xprop; |
|
3942 | 3942 | return TRUE; |
3943 | 3943 | } |
3944 | 3944 | /*********************************************************************************/ |
@@ -3952,10 +3952,10 @@ discard block |
||
3952 | 3952 | */ |
3953 | 3953 | function _createFormat() { |
3954 | 3954 | $objectname = null; |
3955 | - switch( $this->format ) { |
|
3955 | + switch ($this->format) { |
|
3956 | 3956 | case 'xcal': |
3957 | - $objectname = ( isset( $this->timezonetype )) ? |
|
3958 | - strtolower( $this->timezonetype ) : strtolower( $this->objName ); |
|
3957 | + $objectname = (isset($this->timezonetype)) ? |
|
3958 | + strtolower($this->timezonetype) : strtolower($this->objName); |
|
3959 | 3959 | $this->componentStart1 = $this->elementStart1 = '<'; |
3960 | 3960 | $this->componentStart2 = $this->elementStart2 = '>'; |
3961 | 3961 | $this->componentEnd1 = $this->elementEnd1 = '</'; |
@@ -3965,8 +3965,8 @@ discard block |
||
3965 | 3965 | $this->valueInit = null; |
3966 | 3966 | break; |
3967 | 3967 | default: |
3968 | - $objectname = ( isset( $this->timezonetype )) ? |
|
3969 | - strtoupper( $this->timezonetype ) : strtoupper( $this->objName ); |
|
3968 | + $objectname = (isset($this->timezonetype)) ? |
|
3969 | + strtoupper($this->timezonetype) : strtoupper($this->objName); |
|
3970 | 3970 | $this->componentStart1 = 'BEGIN:'; |
3971 | 3971 | $this->componentStart2 = null; |
3972 | 3972 | $this->componentEnd1 = 'END:'; |
@@ -3992,82 +3992,82 @@ discard block |
||
3992 | 3992 | * @param string $content property content (optional) |
3993 | 3993 | * @return string |
3994 | 3994 | */ |
3995 | - function _createElement( $label, $attributes=null, $content=FALSE ) { |
|
3996 | - $label = $this->_formatPropertyName( $label ); |
|
3995 | + function _createElement($label, $attributes = null, $content = FALSE) { |
|
3996 | + $label = $this->_formatPropertyName($label); |
|
3997 | 3997 | $output = $this->elementStart1.$label; |
3998 | 3998 | $categoriesAttrLang = null; |
3999 | 3999 | $attachInlineBinary = FALSE; |
4000 | 4000 | $attachfmttype = null; |
4001 | - if( !empty( $attributes )) { |
|
4002 | - $attributes = trim( $attributes ); |
|
4003 | - if ( 'xcal' == $this->format) { |
|
4004 | - $attributes2 = explode( $this->intAttrDelimiter, $attributes ); |
|
4001 | + if (!empty($attributes)) { |
|
4002 | + $attributes = trim($attributes); |
|
4003 | + if ('xcal' == $this->format) { |
|
4004 | + $attributes2 = explode($this->intAttrDelimiter, $attributes); |
|
4005 | 4005 | $attributes = null; |
4006 | - foreach( $attributes2 as $attribute ) { |
|
4007 | - $attrKVarr = explode( '=', $attribute ); |
|
4008 | - if( empty( $attrKVarr[0] )) |
|
4006 | + foreach ($attributes2 as $attribute) { |
|
4007 | + $attrKVarr = explode('=', $attribute); |
|
4008 | + if (empty($attrKVarr[0])) |
|
4009 | 4009 | continue; |
4010 | - if( !isset( $attrKVarr[1] )) { |
|
4010 | + if (!isset($attrKVarr[1])) { |
|
4011 | 4011 | $attrValue = $attrKVarr[0]; |
4012 | 4012 | $attrKey = null; |
4013 | 4013 | } |
4014 | - elseif( 2 == count( $attrKVarr)) { |
|
4015 | - $attrKey = strtolower( $attrKVarr[0] ); |
|
4014 | + elseif (2 == count($attrKVarr)) { |
|
4015 | + $attrKey = strtolower($attrKVarr[0]); |
|
4016 | 4016 | $attrValue = $attrKVarr[1]; |
4017 | 4017 | } |
4018 | 4018 | else { |
4019 | - $attrKey = strtolower( $attrKVarr[0] ); |
|
4020 | - unset( $attrKVarr[0] ); |
|
4021 | - $attrValue = implode( '=', $attrKVarr ); |
|
4019 | + $attrKey = strtolower($attrKVarr[0]); |
|
4020 | + unset($attrKVarr[0]); |
|
4021 | + $attrValue = implode('=', $attrKVarr); |
|
4022 | 4022 | } |
4023 | - if(( 'attach' == $label ) && ( in_array( $attrKey, array( 'fmttype', 'encoding', 'value' )))) { |
|
4023 | + if (('attach' == $label) && (in_array($attrKey, array('fmttype', 'encoding', 'value')))) { |
|
4024 | 4024 | $attachInlineBinary = TRUE; |
4025 | - if( 'fmttype' == $attrKey ) |
|
4025 | + if ('fmttype' == $attrKey) |
|
4026 | 4026 | $attachfmttype = $attrKey.'='.$attrValue; |
4027 | 4027 | continue; |
4028 | 4028 | } |
4029 | - elseif(( 'categories' == $label ) && ( 'language' == $attrKey )) |
|
4029 | + elseif (('categories' == $label) && ('language' == $attrKey)) |
|
4030 | 4030 | $categoriesAttrLang = $attrKey.'='.$attrValue; |
4031 | 4031 | else { |
4032 | - $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' '; |
|
4033 | - $attributes .= ( !empty( $attrKey )) ? $attrKey.'=' : null; |
|
4034 | - if(( '"' == substr( $attrValue, 0, 1 )) && ( '"' == substr( $attrValue, -1 ))) { |
|
4035 | - $attrValue = substr( $attrValue, 1, ( strlen( $attrValue ) - 2 )); |
|
4036 | - $attrValue = str_replace( '"', '', $attrValue ); |
|
4032 | + $attributes .= (empty($attributes)) ? ' ' : $this->attributeDelimiter.' '; |
|
4033 | + $attributes .= (!empty($attrKey)) ? $attrKey.'=' : null; |
|
4034 | + if (('"' == substr($attrValue, 0, 1)) && ('"' == substr($attrValue, -1))) { |
|
4035 | + $attrValue = substr($attrValue, 1, (strlen($attrValue) - 2)); |
|
4036 | + $attrValue = str_replace('"', '', $attrValue); |
|
4037 | 4037 | } |
4038 | - $attributes .= '"'.htmlspecialchars( $attrValue ).'"'; |
|
4038 | + $attributes .= '"'.htmlspecialchars($attrValue).'"'; |
|
4039 | 4039 | } |
4040 | 4040 | } |
4041 | 4041 | } |
4042 | 4042 | else { |
4043 | - $attributes = str_replace( $this->intAttrDelimiter, $this->attributeDelimiter, $attributes ); |
|
4043 | + $attributes = str_replace($this->intAttrDelimiter, $this->attributeDelimiter, $attributes); |
|
4044 | 4044 | } |
4045 | 4045 | } |
4046 | - if(((( 'attach' == $label ) && !$attachInlineBinary ) || |
|
4047 | - ( in_array( $label, array( 'tzurl', 'url' )))) && ( 'xcal' == $this->format)) { |
|
4046 | + if (((('attach' == $label) && !$attachInlineBinary) || |
|
4047 | + (in_array($label, array('tzurl', 'url')))) && ('xcal' == $this->format)) { |
|
4048 | 4048 | $pos = strrpos($content, "/"); |
4049 | - $docname = ( $pos !== false) ? substr( $content, (1 - strlen( $content ) + $pos )) : $content; |
|
4050 | - $this->xcaldecl[] = array( 'xmldecl' => 'ENTITY' |
|
4049 | + $docname = ($pos !== false) ? substr($content, (1 - strlen($content) + $pos)) : $content; |
|
4050 | + $this->xcaldecl[] = array('xmldecl' => 'ENTITY' |
|
4051 | 4051 | , 'uri' => $docname |
4052 | 4052 | , 'ref' => 'SYSTEM' |
4053 | 4053 | , 'external' => $content |
4054 | 4054 | , 'type' => 'NDATA' |
4055 | - , 'type2' => 'BINERY' ); |
|
4056 | - $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' '; |
|
4055 | + , 'type2' => 'BINERY'); |
|
4056 | + $attributes .= (empty($attributes)) ? ' ' : $this->attributeDelimiter.' '; |
|
4057 | 4057 | $attributes .= 'uri="'.$docname.'"'; |
4058 | 4058 | $content = null; |
4059 | - if( 'attach' == $label ) { |
|
4060 | - $attributes = str_replace( $this->attributeDelimiter, $this->intAttrDelimiter, $attributes ); |
|
4061 | - $content = $this->_createElement( 'extref', $attributes, null ); |
|
4059 | + if ('attach' == $label) { |
|
4060 | + $attributes = str_replace($this->attributeDelimiter, $this->intAttrDelimiter, $attributes); |
|
4061 | + $content = $this->_createElement('extref', $attributes, null); |
|
4062 | 4062 | $attributes = null; |
4063 | 4063 | } |
4064 | 4064 | } |
4065 | - elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) { |
|
4066 | - $content = $this->nl.$this->_createElement( 'b64bin', $attachfmttype, $content ); // max one attribute |
|
4065 | + elseif (('attach' == $label) && $attachInlineBinary && ('xcal' == $this->format)) { |
|
4066 | + $content = $this->nl.$this->_createElement('b64bin', $attachfmttype, $content); // max one attribute |
|
4067 | 4067 | } |
4068 | 4068 | $output .= $attributes; |
4069 | - if( !$content ) { |
|
4070 | - switch( $this->format ) { |
|
4069 | + if (!$content) { |
|
4070 | + switch ($this->format) { |
|
4071 | 4071 | case 'xcal': |
4072 | 4072 | $output .= ' /'; |
4073 | 4073 | $output .= $this->elementStart2; |
@@ -4075,18 +4075,18 @@ discard block |
||
4075 | 4075 | break; |
4076 | 4076 | default: |
4077 | 4077 | $output .= $this->elementStart2.$this->valueInit; |
4078 | - return $this->_size75( $output ); |
|
4078 | + return $this->_size75($output); |
|
4079 | 4079 | break; |
4080 | 4080 | } |
4081 | 4081 | } |
4082 | 4082 | $output .= $this->elementStart2; |
4083 | 4083 | $output .= $this->valueInit.$content; |
4084 | - switch( $this->format ) { |
|
4084 | + switch ($this->format) { |
|
4085 | 4085 | case 'xcal': |
4086 | 4086 | return $output.$this->elementEnd1.$label.$this->elementEnd2; |
4087 | 4087 | break; |
4088 | 4088 | default: |
4089 | - return $this->_size75( $output ); |
|
4089 | + return $this->_size75($output); |
|
4090 | 4090 | break; |
4091 | 4091 | } |
4092 | 4092 | } |
@@ -4099,36 +4099,36 @@ discard block |
||
4099 | 4099 | * @param array $ctrKeys optional |
4100 | 4100 | * @return string |
4101 | 4101 | */ |
4102 | - function _createParams( $params=array(), $ctrKeys=array() ) { |
|
4102 | + function _createParams($params = array(), $ctrKeys = array()) { |
|
4103 | 4103 | $attrLANG = $attr1 = $attr2 = null; |
4104 | - $CNattrKey = ( in_array( 'CN', $ctrKeys )) ? TRUE : FALSE ; |
|
4105 | - $LANGattrKey = ( in_array( 'LANGUAGE', $ctrKeys )) ? TRUE : FALSE ; |
|
4104 | + $CNattrKey = (in_array('CN', $ctrKeys)) ? TRUE : FALSE; |
|
4105 | + $LANGattrKey = (in_array('LANGUAGE', $ctrKeys)) ? TRUE : FALSE; |
|
4106 | 4106 | $CNattrExist = $LANGattrExist = FALSE; |
4107 | - if( is_array( $params )) { |
|
4108 | - foreach( $params as $paramKey => $paramValue ) { |
|
4109 | - if( is_int( $paramKey )) |
|
4107 | + if (is_array($params)) { |
|
4108 | + foreach ($params as $paramKey => $paramValue) { |
|
4109 | + if (is_int($paramKey)) |
|
4110 | 4110 | $attr2 .= $this->intAttrDelimiter.$paramValue; |
4111 | - elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) { |
|
4111 | + elseif (('LANGUAGE' == $paramKey) && $LANGattrKey) { |
|
4112 | 4112 | $attrLANG .= $this->intAttrDelimiter."LANGUAGE=$paramValue"; |
4113 | 4113 | $LANGattrExist = TRUE; |
4114 | 4114 | } |
4115 | - elseif(( 'CN' == $paramKey ) && $CNattrKey ) { |
|
4115 | + elseif (('CN' == $paramKey) && $CNattrKey) { |
|
4116 | 4116 | $attr1 = $this->intAttrDelimiter.'CN="'.$paramValue.'"'; |
4117 | 4117 | $CNattrExist = TRUE; |
4118 | 4118 | } |
4119 | - elseif(( 'ALTREP' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4119 | + elseif (('ALTREP' == $paramKey) && in_array($paramKey, $ctrKeys)) |
|
4120 | 4120 | $attr2 .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"'; |
4121 | - elseif(( 'DIR' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4121 | + elseif (('DIR' == $paramKey) && in_array($paramKey, $ctrKeys)) |
|
4122 | 4122 | $attr2 .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"'; |
4123 | - elseif(( 'SENT-BY' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4123 | + elseif (('SENT-BY' == $paramKey) && in_array($paramKey, $ctrKeys)) |
|
4124 | 4124 | $attr2 .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"'; |
4125 | 4125 | else |
4126 | 4126 | $attr2 .= $this->intAttrDelimiter."$paramKey=$paramValue"; |
4127 | 4127 | } |
4128 | 4128 | } |
4129 | - if( !$LANGattrExist ) { |
|
4130 | - $lang = $this->getConfig( 'language' ); |
|
4131 | - if(( $CNattrExist || $LANGattrKey ) && $lang ) |
|
4129 | + if (!$LANGattrExist) { |
|
4130 | + $lang = $this->getConfig('language'); |
|
4131 | + if (($CNattrExist || $LANGattrKey) && $lang) |
|
4132 | 4132 | $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang; |
4133 | 4133 | } |
4134 | 4134 | return $attrLANG.$attr1.$attr2; |
@@ -4142,47 +4142,47 @@ discard block |
||
4142 | 4142 | * @param int $parno, no of date parts (i.e. year, month.. .) |
4143 | 4143 | * @return array $params, property parameters |
4144 | 4144 | */ |
4145 | - function _chkdatecfg( $theDate, & $parno, & $params ) { |
|
4146 | - if( isset( $params['TZID'] )) |
|
4145 | + function _chkdatecfg($theDate, & $parno, & $params) { |
|
4146 | + if (isset($params['TZID'])) |
|
4147 | 4147 | $parno = 6; |
4148 | - elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )) |
|
4148 | + elseif (isset($params['VALUE']) && ('DATE' == $params['VALUE'])) |
|
4149 | 4149 | $parno = 3; |
4150 | 4150 | else { |
4151 | - if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] )) |
|
4151 | + if (isset($params['VALUE']) && ('PERIOD' == $params['VALUE'])) |
|
4152 | 4152 | $parno = 7; |
4153 | - if( is_array( $theDate )) { |
|
4154 | - if( isset( $theDate['timestamp'] )) |
|
4155 | - $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null; |
|
4153 | + if (is_array($theDate)) { |
|
4154 | + if (isset($theDate['timestamp'])) |
|
4155 | + $tzid = (isset($theDate['tz'])) ? $theDate['tz'] : null; |
|
4156 | 4156 | else |
4157 | - $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null; |
|
4158 | - if( !empty( $tzid )) { |
|
4157 | + $tzid = (isset($theDate['tz'])) ? $theDate['tz'] : (7 == count($theDate)) ? end($theDate) : null; |
|
4158 | + if (!empty($tzid)) { |
|
4159 | 4159 | $parno = 7; |
4160 | - if( !$this->_isOffset( $tzid )) |
|
4160 | + if (!$this->_isOffset($tzid)) |
|
4161 | 4161 | $params['TZID'] = $tzid; // save only timezone |
4162 | 4162 | } |
4163 | - elseif( !$parno && ( 3 == count( $theDate )) && |
|
4164 | - ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))) |
|
4163 | + elseif (!$parno && (3 == count($theDate)) && |
|
4164 | + (isset($params['VALUE']) && ('DATE' == $params['VALUE']))) |
|
4165 | 4165 | $parno = 3; |
4166 | 4166 | else |
4167 | 4167 | $parno = 6; |
4168 | 4168 | } |
4169 | 4169 | else { // string |
4170 | - $date = trim( $theDate ); |
|
4171 | - if( 'Z' == substr( $date, -1 )) |
|
4170 | + $date = trim($theDate); |
|
4171 | + if ('Z' == substr($date, -1)) |
|
4172 | 4172 | $parno = 7; // UTC DATE-TIME |
4173 | - elseif((( 8 == strlen( $date ) && ctype_digit( $date )) || ( 11 >= strlen( $date ))) && |
|
4174 | - ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' )))) |
|
4173 | + elseif (((8 == strlen($date) && ctype_digit($date)) || (11 >= strlen($date))) && |
|
4174 | + (!isset($params['VALUE']) || !in_array($params['VALUE'], array('DATE-TIME', 'PERIOD')))) |
|
4175 | 4175 | $parno = 3; // DATE |
4176 | - $date = $this->_date_time_string( $date, $parno ); |
|
4177 | - if( !empty( $date['tz'] )) { |
|
4176 | + $date = $this->_date_time_string($date, $parno); |
|
4177 | + if (!empty($date['tz'])) { |
|
4178 | 4178 | $parno = 7; |
4179 | - if( !$this->_isOffset( $date['tz'] )) |
|
4179 | + if (!$this->_isOffset($date['tz'])) |
|
4180 | 4180 | $params['TZID'] = $date['tz']; // save only timezone |
4181 | 4181 | } |
4182 | - elseif( empty( $parno )) |
|
4182 | + elseif (empty($parno)) |
|
4183 | 4183 | $parno = 6; |
4184 | 4184 | } |
4185 | - if( isset( $params['TZID'] )) |
|
4185 | + if (isset($params['TZID'])) |
|
4186 | 4186 | $parno = 6; |
4187 | 4187 | } |
4188 | 4188 | } |
@@ -4197,28 +4197,28 @@ discard block |
||
4197 | 4197 | * @param array $duration, optional |
4198 | 4198 | * @return array duration |
4199 | 4199 | */ |
4200 | - function _date2duration( $startdate=FALSE, $enddate=FALSE ) { |
|
4201 | - if( !$startdate || !$enddate ) { |
|
4202 | - if( FALSE === ( $startdate = $this->getProperty( 'dtstart' ))) |
|
4200 | + function _date2duration($startdate = FALSE, $enddate = FALSE) { |
|
4201 | + if (!$startdate || !$enddate) { |
|
4202 | + if (FALSE === ($startdate = $this->getProperty('dtstart'))) |
|
4203 | 4203 | return null; |
4204 | - if( FALSE === ( $enddate = $this->getProperty( 'dtend' ))) // vevent/vfreebusy |
|
4205 | - if( FALSE === ( $enddate = $this->getProperty( 'due' ))) // vtodo |
|
4204 | + if (FALSE === ($enddate = $this->getProperty('dtend'))) // vevent/vfreebusy |
|
4205 | + if (FALSE === ($enddate = $this->getProperty('due'))) // vtodo |
|
4206 | 4206 | return null; |
4207 | 4207 | } |
4208 | - if( !$startdate || !$enddate ) |
|
4208 | + if (!$startdate || !$enddate) |
|
4209 | 4209 | return null; |
4210 | - $startWdate = mktime( 0, 0, 0, $startdate['month'], $startdate['day'], $startdate['year'] ); |
|
4211 | - $endWdate = mktime( 0, 0, 0, $enddate['month'], $enddate['day'], $enddate['year'] ); |
|
4210 | + $startWdate = mktime(0, 0, 0, $startdate['month'], $startdate['day'], $startdate['year']); |
|
4211 | + $endWdate = mktime(0, 0, 0, $enddate['month'], $enddate['day'], $enddate['year']); |
|
4212 | 4212 | $wduration = $endWdate - $startWdate; |
4213 | 4213 | $dur = array(); |
4214 | - $dur['week'] = (int) floor( $wduration / ( 7 * 24 * 60 * 60 )); |
|
4215 | - $wduration = $wduration % ( 7 * 24 * 60 * 60 ); |
|
4216 | - $dur['day'] = (int) floor( $wduration / ( 24 * 60 * 60 )); |
|
4217 | - $wduration = $wduration % ( 24 * 60 * 60 ); |
|
4218 | - $dur['hour'] = (int) floor( $wduration / ( 60 * 60 )); |
|
4219 | - $wduration = $wduration % ( 60 * 60 ); |
|
4220 | - $dur['min'] = (int) floor( $wduration / ( 60 )); |
|
4221 | - $dur['sec'] = (int) $wduration % ( 60 ); |
|
4214 | + $dur['week'] = (int) floor($wduration / (7 * 24 * 60 * 60)); |
|
4215 | + $wduration = $wduration % (7 * 24 * 60 * 60); |
|
4216 | + $dur['day'] = (int) floor($wduration / (24 * 60 * 60)); |
|
4217 | + $wduration = $wduration % (24 * 60 * 60); |
|
4218 | + $dur['hour'] = (int) floor($wduration / (60 * 60)); |
|
4219 | + $wduration = $wduration % (60 * 60); |
|
4220 | + $dur['min'] = (int) floor($wduration / (60)); |
|
4221 | + $dur['sec'] = (int) $wduration % (60); |
|
4222 | 4222 | return $dur; |
4223 | 4223 | } |
4224 | 4224 | /** |
@@ -4230,19 +4230,19 @@ discard block |
||
4230 | 4230 | * @param string $tz timezone |
4231 | 4231 | * @return timestamp |
4232 | 4232 | */ |
4233 | - function _date2timestamp( $datetime, $tz=null ) { |
|
4233 | + function _date2timestamp($datetime, $tz = null) { |
|
4234 | 4234 | $output = null; |
4235 | - if( !isset( $datetime['hour'] )) $datetime['hour'] = '0'; |
|
4236 | - if( !isset( $datetime['min'] )) $datetime['min'] = '0'; |
|
4237 | - if( !isset( $datetime['sec'] )) $datetime['sec'] = '0'; |
|
4238 | - foreach( $datetime as $dkey => $dvalue ) { |
|
4239 | - if( 'tz' != $dkey ) |
|
4235 | + if (!isset($datetime['hour'])) $datetime['hour'] = '0'; |
|
4236 | + if (!isset($datetime['min'])) $datetime['min'] = '0'; |
|
4237 | + if (!isset($datetime['sec'])) $datetime['sec'] = '0'; |
|
4238 | + foreach ($datetime as $dkey => $dvalue) { |
|
4239 | + if ('tz' != $dkey) |
|
4240 | 4240 | $datetime[$dkey] = (integer) $dvalue; |
4241 | 4241 | } |
4242 | - if( $tz ) |
|
4242 | + if ($tz) |
|
4243 | 4243 | $datetime['tz'] = $tz; |
4244 | - $offset = ( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) ? $this->_tz2offset( $datetime['tz'] ) : 0; |
|
4245 | - $output = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year'] ); |
|
4244 | + $offset = (isset($datetime['tz']) && ('' < trim($datetime['tz']))) ? $this->_tz2offset($datetime['tz']) : 0; |
|
4245 | + $output = mktime($datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']); |
|
4246 | 4246 | return $output; |
4247 | 4247 | } |
4248 | 4248 | /** |
@@ -4254,16 +4254,16 @@ discard block |
||
4254 | 4254 | * @param int $parno optional, default FALSE |
4255 | 4255 | * @return array |
4256 | 4256 | */ |
4257 | - function _date_time_array( $datetime, $parno=FALSE ) { |
|
4257 | + function _date_time_array($datetime, $parno = FALSE) { |
|
4258 | 4258 | $output = array(); |
4259 | - foreach( $datetime as $dateKey => $datePart ) { |
|
4260 | - switch ( $dateKey ) { |
|
4259 | + foreach ($datetime as $dateKey => $datePart) { |
|
4260 | + switch ($dateKey) { |
|
4261 | 4261 | case '0': case 'year': $output['year'] = $datePart; break; |
4262 | 4262 | case '1': case 'month': $output['month'] = $datePart; break; |
4263 | 4263 | case '2': case 'day': $output['day'] = $datePart; break; |
4264 | 4264 | } |
4265 | - if( 3 != $parno ) { |
|
4266 | - switch ( $dateKey ) { |
|
4265 | + if (3 != $parno) { |
|
4266 | + switch ($dateKey) { |
|
4267 | 4267 | case '0': |
4268 | 4268 | case '1': |
4269 | 4269 | case '2': break; |
@@ -4274,12 +4274,12 @@ discard block |
||
4274 | 4274 | } |
4275 | 4275 | } |
4276 | 4276 | } |
4277 | - if( 3 != $parno ) { |
|
4278 | - if( !isset( $output['hour'] )) |
|
4277 | + if (3 != $parno) { |
|
4278 | + if (!isset($output['hour'])) |
|
4279 | 4279 | $output['hour'] = 0; |
4280 | - if( !isset( $output['min'] )) |
|
4280 | + if (!isset($output['min'])) |
|
4281 | 4281 | $output['min'] = 0; |
4282 | - if( !isset( $output['sec'] )) |
|
4282 | + if (!isset($output['sec'])) |
|
4283 | 4283 | $output['sec'] = 0; |
4284 | 4284 | } |
4285 | 4285 | return $output; |
@@ -4293,88 +4293,88 @@ discard block |
||
4293 | 4293 | * @param int $parno optional, default FALSE |
4294 | 4294 | * @return array |
4295 | 4295 | */ |
4296 | - function _date_time_string( $datetime, $parno=FALSE ) { |
|
4297 | - $datetime = (string) trim( $datetime ); |
|
4296 | + function _date_time_string($datetime, $parno = FALSE) { |
|
4297 | + $datetime = (string) trim($datetime); |
|
4298 | 4298 | $tz = null; |
4299 | - $len = strlen( $datetime ) - 1; |
|
4300 | - if( 'Z' == substr( $datetime, -1 )) { |
|
4299 | + $len = strlen($datetime) - 1; |
|
4300 | + if ('Z' == substr($datetime, -1)) { |
|
4301 | 4301 | $tz = 'Z'; |
4302 | - $datetime = trim( substr( $datetime, 0, $len )); |
|
4302 | + $datetime = trim(substr($datetime, 0, $len)); |
|
4303 | 4303 | } |
4304 | - elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date |
|
4305 | - ( '-' == substr( $datetime, -3, 1 )) || |
|
4306 | - ( ':' == substr( $datetime, -3, 1 )) || |
|
4307 | - ( '.' == substr( $datetime, -3, 1 ))) { |
|
4304 | + elseif ((ctype_digit(substr($datetime, -2, 2))) && // time or date |
|
4305 | + ('-' == substr($datetime, -3, 1)) || |
|
4306 | + (':' == substr($datetime, -3, 1)) || |
|
4307 | + ('.' == substr($datetime, -3, 1))) { |
|
4308 | 4308 | $continue = TRUE; |
4309 | 4309 | } |
4310 | - elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset |
|
4311 | - ( ' +' == substr( $datetime, -6, 2 )) || |
|
4312 | - ( ' -' == substr( $datetime, -6, 2 ))) { |
|
4313 | - $tz = substr( $datetime, -5, 5 ); |
|
4314 | - $datetime = substr( $datetime, 0, ($len - 5)); |
|
4310 | + elseif ((ctype_digit(substr($datetime, -4, 4))) && // 4 pos offset |
|
4311 | + (' +' == substr($datetime, -6, 2)) || |
|
4312 | + (' -' == substr($datetime, -6, 2))) { |
|
4313 | + $tz = substr($datetime, -5, 5); |
|
4314 | + $datetime = substr($datetime, 0, ($len - 5)); |
|
4315 | 4315 | } |
4316 | - elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset |
|
4317 | - ( ' +' == substr( $datetime, -8, 2 )) || |
|
4318 | - ( ' -' == substr( $datetime, -8, 2 ))) { |
|
4319 | - $tz = substr( $datetime, -7, 7 ); |
|
4320 | - $datetime = substr( $datetime, 0, ($len - 7)); |
|
4316 | + elseif ((ctype_digit(substr($datetime, -6, 6))) && // 6 pos offset |
|
4317 | + (' +' == substr($datetime, -8, 2)) || |
|
4318 | + (' -' == substr($datetime, -8, 2))) { |
|
4319 | + $tz = substr($datetime, -7, 7); |
|
4320 | + $datetime = substr($datetime, 0, ($len - 7)); |
|
4321 | 4321 | } |
4322 | - elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) { |
|
4322 | + elseif ((6 < $len) && (ctype_digit(substr($datetime, -6, 6)))) { |
|
4323 | 4323 | $continue = TRUE; |
4324 | 4324 | } |
4325 | - elseif( 'T' == substr( $datetime, -7, 1 )) { |
|
4325 | + elseif ('T' == substr($datetime, -7, 1)) { |
|
4326 | 4326 | $continue = TRUE; |
4327 | 4327 | } |
4328 | 4328 | else { |
4329 | - $cx = $tx = 0; // 19970415T133000 US-Eastern |
|
4330 | - for( $cx = -1; $cx > ( 9 - $len ); $cx-- ) { |
|
4331 | - if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 ))) |
|
4329 | + $cx = $tx = 0; // 19970415T133000 US-Eastern |
|
4330 | + for ($cx = -1; $cx > (9 - $len); $cx--) { |
|
4331 | + if ((' ' == substr($datetime, $cx, 1)) || ctype_digit(substr($datetime, $cx, 1))) |
|
4332 | 4332 | break; // if exists, tz ends here.. . ? |
4333 | - elseif( ctype_alpha( substr( $datetime, $cx, 1 )) || |
|
4334 | - ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' )))) |
|
4333 | + elseif (ctype_alpha(substr($datetime, $cx, 1)) || |
|
4334 | + (in_array(substr($datetime, $cx, 1), array('-', '/')))) |
|
4335 | 4335 | $tx--; // tz length counter |
4336 | 4336 | } |
4337 | - if( 0 > $tx ) { |
|
4338 | - $tz = substr( $datetime, $tx ); |
|
4339 | - $datetime = trim( substr( $datetime, 0, $len + $tx + 1 )); |
|
4337 | + if (0 > $tx) { |
|
4338 | + $tz = substr($datetime, $tx); |
|
4339 | + $datetime = trim(substr($datetime, 0, $len + $tx + 1)); |
|
4340 | 4340 | } |
4341 | 4341 | } |
4342 | - if( 0 < substr_count( $datetime, '-' )) { |
|
4343 | - $datetime = str_replace( '-', '/', $datetime ); |
|
4344 | - } |
|
4345 | - elseif( ctype_digit( substr( $datetime, 0, 8 )) && |
|
4346 | - ( 'T' == substr( $datetime, 8, 1 )) && |
|
4347 | - ctype_digit( substr( $datetime, 9, 6 ))) { |
|
4348 | - $datetime = substr( $datetime, 4, 2 ) |
|
4349 | - .'/'.substr( $datetime, 6, 2 ) |
|
4350 | - .'/'.substr( $datetime, 0, 4 ) |
|
4351 | - .' '.substr( $datetime, 9, 2 ) |
|
4352 | - .':'.substr( $datetime, 11, 2 ) |
|
4353 | - .':'.substr( $datetime, 13); |
|
4354 | - } |
|
4355 | - $datestring = date( 'Y-m-d H:i:s', strtotime( $datetime )); |
|
4356 | - $tz = trim( $tz ); |
|
4342 | + if (0 < substr_count($datetime, '-')) { |
|
4343 | + $datetime = str_replace('-', '/', $datetime); |
|
4344 | + } |
|
4345 | + elseif (ctype_digit(substr($datetime, 0, 8)) && |
|
4346 | + ('T' == substr($datetime, 8, 1)) && |
|
4347 | + ctype_digit(substr($datetime, 9, 6))) { |
|
4348 | + $datetime = substr($datetime, 4, 2) |
|
4349 | + .'/'.substr($datetime, 6, 2) |
|
4350 | + .'/'.substr($datetime, 0, 4) |
|
4351 | + .' '.substr($datetime, 9, 2) |
|
4352 | + .':'.substr($datetime, 11, 2) |
|
4353 | + .':'.substr($datetime, 13); |
|
4354 | + } |
|
4355 | + $datestring = date('Y-m-d H:i:s', strtotime($datetime)); |
|
4356 | + $tz = trim($tz); |
|
4357 | 4357 | $output = array(); |
4358 | - $output['year'] = substr( $datestring, 0, 4 ); |
|
4359 | - $output['month'] = substr( $datestring, 5, 2 ); |
|
4360 | - $output['day'] = substr( $datestring, 8, 2 ); |
|
4361 | - if(( 6 == $parno ) || ( 7 == $parno )) { |
|
4362 | - $output['hour'] = substr( $datestring, 11, 2 ); |
|
4363 | - $output['min'] = substr( $datestring, 14, 2 ); |
|
4364 | - $output['sec'] = substr( $datestring, 17, 2 ); |
|
4365 | - if( !empty( $tz )) |
|
4358 | + $output['year'] = substr($datestring, 0, 4); |
|
4359 | + $output['month'] = substr($datestring, 5, 2); |
|
4360 | + $output['day'] = substr($datestring, 8, 2); |
|
4361 | + if ((6 == $parno) || (7 == $parno)) { |
|
4362 | + $output['hour'] = substr($datestring, 11, 2); |
|
4363 | + $output['min'] = substr($datestring, 14, 2); |
|
4364 | + $output['sec'] = substr($datestring, 17, 2); |
|
4365 | + if (!empty($tz)) |
|
4366 | 4366 | $output['tz'] = $tz; |
4367 | 4367 | } |
4368 | - elseif( 3 != $parno ) { |
|
4369 | - if(( '00' < substr( $datestring, 11, 2 )) || |
|
4370 | - ( '00' < substr( $datestring, 14, 2 )) || |
|
4371 | - ( '00' < substr( $datestring, 17, 2 ))) { |
|
4372 | - $output['hour'] = substr( $datestring, 11, 2 ); |
|
4373 | - $output['min'] = substr( $datestring, 14, 2 ); |
|
4374 | - $output['sec'] = substr( $datestring, 17, 2 ); |
|
4368 | + elseif (3 != $parno) { |
|
4369 | + if (('00' < substr($datestring, 11, 2)) || |
|
4370 | + ('00' < substr($datestring, 14, 2)) || |
|
4371 | + ('00' < substr($datestring, 17, 2))) { |
|
4372 | + $output['hour'] = substr($datestring, 11, 2); |
|
4373 | + $output['min'] = substr($datestring, 14, 2); |
|
4374 | + $output['sec'] = substr($datestring, 17, 2); |
|
4375 | 4375 | } |
4376 | - if( !empty( $tz )) |
|
4377 | - $output['tz'] = $tz; |
|
4376 | + if (!empty($tz)) |
|
4377 | + $output['tz'] = $tz; |
|
4378 | 4378 | } |
4379 | 4379 | return $output; |
4380 | 4380 | } |
@@ -4386,26 +4386,26 @@ discard block |
||
4386 | 4386 | * @param array $duration |
4387 | 4387 | * @return array |
4388 | 4388 | */ |
4389 | - function _duration_array( $duration ) { |
|
4389 | + function _duration_array($duration) { |
|
4390 | 4390 | $output = array(); |
4391 | - if( is_array( $duration ) && |
|
4392 | - ( 1 == count( $duration )) && |
|
4393 | - isset( $duration['sec'] ) && |
|
4394 | - ( 60 < $duration['sec'] )) { |
|
4391 | + if (is_array($duration) && |
|
4392 | + (1 == count($duration)) && |
|
4393 | + isset($duration['sec']) && |
|
4394 | + (60 < $duration['sec'])) { |
|
4395 | 4395 | $durseconds = $duration['sec']; |
4396 | - $output['week'] = floor( $durseconds / ( 60 * 60 * 24 * 7 )); |
|
4397 | - $durseconds = $durseconds % ( 60 * 60 * 24 * 7 ); |
|
4398 | - $output['day'] = floor( $durseconds / ( 60 * 60 * 24 )); |
|
4399 | - $durseconds = $durseconds % ( 60 * 60 * 24 ); |
|
4400 | - $output['hour'] = floor( $durseconds / ( 60 * 60 )); |
|
4401 | - $durseconds = $durseconds % ( 60 * 60 ); |
|
4402 | - $output['min'] = floor( $durseconds / ( 60 )); |
|
4403 | - $output['sec'] = ( $durseconds % ( 60 )); |
|
4396 | + $output['week'] = floor($durseconds / (60 * 60 * 24 * 7)); |
|
4397 | + $durseconds = $durseconds % (60 * 60 * 24 * 7); |
|
4398 | + $output['day'] = floor($durseconds / (60 * 60 * 24)); |
|
4399 | + $durseconds = $durseconds % (60 * 60 * 24); |
|
4400 | + $output['hour'] = floor($durseconds / (60 * 60)); |
|
4401 | + $durseconds = $durseconds % (60 * 60); |
|
4402 | + $output['min'] = floor($durseconds / (60)); |
|
4403 | + $output['sec'] = ($durseconds % (60)); |
|
4404 | 4404 | } |
4405 | 4405 | else { |
4406 | - foreach( $duration as $durKey => $durValue ) { |
|
4407 | - if( empty( $durValue )) continue; |
|
4408 | - switch ( $durKey ) { |
|
4406 | + foreach ($duration as $durKey => $durValue) { |
|
4407 | + if (empty($durValue)) continue; |
|
4408 | + switch ($durKey) { |
|
4409 | 4409 | case '0': case 'week': $output['week'] = $durValue; break; |
4410 | 4410 | case '1': case 'day': $output['day'] = $durValue; break; |
4411 | 4411 | case '2': case 'hour': $output['hour'] = $durValue; break; |
@@ -4414,19 +4414,19 @@ discard block |
||
4414 | 4414 | } |
4415 | 4415 | } |
4416 | 4416 | } |
4417 | - if( isset( $output['week'] ) && ( 0 < $output['week'] )) { |
|
4418 | - unset( $output['day'], $output['hour'], $output['min'], $output['sec'] ); |
|
4417 | + if (isset($output['week']) && (0 < $output['week'])) { |
|
4418 | + unset($output['day'], $output['hour'], $output['min'], $output['sec']); |
|
4419 | 4419 | return $output; |
4420 | 4420 | } |
4421 | - unset( $output['week'] ); |
|
4422 | - if( empty( $output['day'] )) |
|
4423 | - unset( $output['day'] ); |
|
4424 | - if ( isset( $output['hour'] ) || isset( $output['min'] ) || isset( $output['sec'] )) { |
|
4425 | - if( !isset( $output['hour'] )) $output['hour'] = 0; |
|
4426 | - if( !isset( $output['min'] )) $output['min'] = 0; |
|
4427 | - if( !isset( $output['sec'] )) $output['sec'] = 0; |
|
4428 | - if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] )) |
|
4429 | - unset( $output['hour'], $output['min'], $output['sec'] ); |
|
4421 | + unset($output['week']); |
|
4422 | + if (empty($output['day'])) |
|
4423 | + unset($output['day']); |
|
4424 | + if (isset($output['hour']) || isset($output['min']) || isset($output['sec'])) { |
|
4425 | + if (!isset($output['hour'])) $output['hour'] = 0; |
|
4426 | + if (!isset($output['min'])) $output['min'] = 0; |
|
4427 | + if (!isset($output['sec'])) $output['sec'] = 0; |
|
4428 | + if ((0 == $output['hour']) && (0 == $output['min']) && (0 == $output['sec'])) |
|
4429 | + unset($output['hour'], $output['min'], $output['sec']); |
|
4430 | 4430 | } |
4431 | 4431 | return $output; |
4432 | 4432 | } |
@@ -4439,43 +4439,43 @@ discard block |
||
4439 | 4439 | * @param array $duration, optional |
4440 | 4440 | * @return array, date format |
4441 | 4441 | */ |
4442 | - function duration2date( $startdate=FALSE, $duration=FALSE ) { |
|
4443 | - if( $startdate && $duration ) { |
|
4442 | + function duration2date($startdate = FALSE, $duration = FALSE) { |
|
4443 | + if ($startdate && $duration) { |
|
4444 | 4444 | $d1 = $startdate; |
4445 | 4445 | $dur = $duration; |
4446 | 4446 | } |
4447 | - elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) { |
|
4447 | + elseif (isset($this->dtstart['value']) && isset($this->duration['value'])) { |
|
4448 | 4448 | $d1 = $this->dtstart['value']; |
4449 | 4449 | $dur = $this->duration['value']; |
4450 | 4450 | } |
4451 | 4451 | else |
4452 | 4452 | return null; |
4453 | - $dateOnly = ( isset( $d1['hour'] ) || isset( $d1['min'] ) || isset( $d1['sec'] )) ? FALSE : TRUE; |
|
4454 | - $d1['hour'] = ( isset( $d1['hour'] )) ? $d1['hour'] : 0; |
|
4455 | - $d1['min'] = ( isset( $d1['min'] )) ? $d1['min'] : 0; |
|
4456 | - $d1['sec'] = ( isset( $d1['sec'] )) ? $d1['sec'] : 0; |
|
4457 | - $dtend = mktime( $d1['hour'], $d1['min'], $d1['sec'], $d1['month'], $d1['day'], $d1['year'] ); |
|
4458 | - if( isset( $dur['week'] )) |
|
4459 | - $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 ); |
|
4460 | - if( isset( $dur['day'] )) |
|
4461 | - $dtend += ( $dur['day'] * 24 * 60 * 60 ); |
|
4462 | - if( isset( $dur['hour'] )) |
|
4463 | - $dtend += ( $dur['hour'] * 60 *60 ); |
|
4464 | - if( isset( $dur['min'] )) |
|
4465 | - $dtend += ( $dur['min'] * 60 ); |
|
4466 | - if( isset( $dur['sec'] )) |
|
4467 | - $dtend += $dur['sec']; |
|
4453 | + $dateOnly = (isset($d1['hour']) || isset($d1['min']) || isset($d1['sec'])) ? FALSE : TRUE; |
|
4454 | + $d1['hour'] = (isset($d1['hour'])) ? $d1['hour'] : 0; |
|
4455 | + $d1['min'] = (isset($d1['min'])) ? $d1['min'] : 0; |
|
4456 | + $d1['sec'] = (isset($d1['sec'])) ? $d1['sec'] : 0; |
|
4457 | + $dtend = mktime($d1['hour'], $d1['min'], $d1['sec'], $d1['month'], $d1['day'], $d1['year']); |
|
4458 | + if (isset($dur['week'])) |
|
4459 | + $dtend += ($dur['week'] * 7 * 24 * 60 * 60); |
|
4460 | + if (isset($dur['day'])) |
|
4461 | + $dtend += ($dur['day'] * 24 * 60 * 60); |
|
4462 | + if (isset($dur['hour'])) |
|
4463 | + $dtend += ($dur['hour'] * 60 * 60); |
|
4464 | + if (isset($dur['min'])) |
|
4465 | + $dtend += ($dur['min'] * 60); |
|
4466 | + if (isset($dur['sec'])) |
|
4467 | + $dtend += $dur['sec']; |
|
4468 | 4468 | $dtend2 = array(); |
4469 | - $dtend2['year'] = date('Y', $dtend ); |
|
4470 | - $dtend2['month'] = date('m', $dtend ); |
|
4471 | - $dtend2['day'] = date('d', $dtend ); |
|
4472 | - $dtend2['hour'] = date('H', $dtend ); |
|
4473 | - $dtend2['min'] = date('i', $dtend ); |
|
4474 | - $dtend2['sec'] = date('s', $dtend ); |
|
4475 | - if( isset( $d1['tz'] )) |
|
4469 | + $dtend2['year'] = date('Y', $dtend); |
|
4470 | + $dtend2['month'] = date('m', $dtend); |
|
4471 | + $dtend2['day'] = date('d', $dtend); |
|
4472 | + $dtend2['hour'] = date('H', $dtend); |
|
4473 | + $dtend2['min'] = date('i', $dtend); |
|
4474 | + $dtend2['sec'] = date('s', $dtend); |
|
4475 | + if (isset($d1['tz'])) |
|
4476 | 4476 | $dtend2['tz'] = $d1['tz']; |
4477 | - if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] ))) |
|
4478 | - unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] ); |
|
4477 | + if ($dateOnly && ((0 == $dtend2['hour']) && (0 == $dtend2['min']) && (0 == $dtend2['sec']))) |
|
4478 | + unset($dtend2['hour'], $dtend2['min'], $dtend2['sec']); |
|
4479 | 4479 | return $dtend2; |
4480 | 4480 | } |
4481 | 4481 | /** |
@@ -4486,21 +4486,21 @@ discard block |
||
4486 | 4486 | * @param string $duration |
4487 | 4487 | * @return array |
4488 | 4488 | */ |
4489 | - function _duration_string( $duration ) { |
|
4490 | - $duration = (string) trim( $duration ); |
|
4491 | - while( 'P' != strtoupper( substr( $duration, 0, 1 ))) { |
|
4492 | - if( 0 < strlen( $duration )) |
|
4493 | - $duration = substr( $duration, 1 ); |
|
4489 | + function _duration_string($duration) { |
|
4490 | + $duration = (string) trim($duration); |
|
4491 | + while ('P' != strtoupper(substr($duration, 0, 1))) { |
|
4492 | + if (0 < strlen($duration)) |
|
4493 | + $duration = substr($duration, 1); |
|
4494 | 4494 | else |
4495 | 4495 | return false; // no leading P !?!? |
4496 | 4496 | } |
4497 | - $duration = substr( $duration, 1 ); // skip P |
|
4498 | - $duration = str_replace ( 't', 'T', $duration ); |
|
4499 | - $duration = str_replace ( 'T', '', $duration ); |
|
4497 | + $duration = substr($duration, 1); // skip P |
|
4498 | + $duration = str_replace('t', 'T', $duration); |
|
4499 | + $duration = str_replace('T', '', $duration); |
|
4500 | 4500 | $output = array(); |
4501 | 4501 | $val = null; |
4502 | - for( $ix=0; $ix < strlen( $duration ); $ix++ ) { |
|
4503 | - switch( strtoupper( $duration{$ix} )) { |
|
4502 | + for ($ix = 0; $ix < strlen($duration); $ix++) { |
|
4503 | + switch (strtoupper($duration{$ix} )) { |
|
4504 | 4504 | case 'W': |
4505 | 4505 | $output['week'] = $val; |
4506 | 4506 | $val = null; |
@@ -4522,13 +4522,13 @@ discard block |
||
4522 | 4522 | $val = null; |
4523 | 4523 | break; |
4524 | 4524 | default: |
4525 | - if( !ctype_digit( $duration{$ix} )) |
|
4525 | + if (!ctype_digit($duration{$ix} )) |
|
4526 | 4526 | return false; // unknown duration controll character !?!? |
4527 | 4527 | else |
4528 | 4528 | $val .= $duration{$ix}; |
4529 | 4529 | } |
4530 | 4530 | } |
4531 | - return $this->_duration_array( $output ); |
|
4531 | + return $this->_duration_array($output); |
|
4532 | 4532 | } |
4533 | 4533 | /** |
4534 | 4534 | * if not preSet, if exist, remove key with expected value from array and return hit value else return elseValue |
@@ -4543,15 +4543,15 @@ discard block |
||
4543 | 4543 | * @param int $preSet optional, return value if already preset |
4544 | 4544 | * @return int |
4545 | 4545 | */ |
4546 | - function _existRem( &$array, $expkey, $expval=FALSE, $hitVal=null, $elseVal=null, $preSet=null ) { |
|
4547 | - if( $preSet ) |
|
4546 | + function _existRem(&$array, $expkey, $expval = FALSE, $hitVal = null, $elseVal = null, $preSet = null) { |
|
4547 | + if ($preSet) |
|
4548 | 4548 | return $preSet; |
4549 | - if( !is_array( $array ) || ( 0 == count( $array ))) |
|
4549 | + if (!is_array($array) || (0 == count($array))) |
|
4550 | 4550 | return $elseVal; |
4551 | - foreach( $array as $key => $value ) { |
|
4552 | - if( strtoupper( $expkey ) == strtoupper( $key )) { |
|
4553 | - if( !$expval || ( strtoupper( $expval ) == strtoupper( $array[$key] ))) { |
|
4554 | - unset( $array[$key] ); |
|
4551 | + foreach ($array as $key => $value) { |
|
4552 | + if (strtoupper($expkey) == strtoupper($key)) { |
|
4553 | + if (!$expval || (strtoupper($expval) == strtoupper($array[$key]))) { |
|
4554 | + unset($array[$key]); |
|
4555 | 4555 | return $hitVal; |
4556 | 4556 | } |
4557 | 4557 | } |
@@ -4567,48 +4567,48 @@ discard block |
||
4567 | 4567 | * @param int $parno, optional, default 6 |
4568 | 4568 | * @return string |
4569 | 4569 | */ |
4570 | - function _format_date_time( $datetime, $parno=6 ) { |
|
4571 | - if( !isset( $datetime['year'] ) && |
|
4572 | - !isset( $datetime['month'] ) && |
|
4573 | - !isset( $datetime['day'] ) && |
|
4574 | - !isset( $datetime['hour'] ) && |
|
4575 | - !isset( $datetime['min'] ) && |
|
4576 | - !isset( $datetime['sec'] )) |
|
4577 | - return ; |
|
4570 | + function _format_date_time($datetime, $parno = 6) { |
|
4571 | + if (!isset($datetime['year']) && |
|
4572 | + !isset($datetime['month']) && |
|
4573 | + !isset($datetime['day']) && |
|
4574 | + !isset($datetime['hour']) && |
|
4575 | + !isset($datetime['min']) && |
|
4576 | + !isset($datetime['sec'])) |
|
4577 | + return; |
|
4578 | 4578 | $output = null; |
4579 | 4579 | // if( !isset( $datetime['day'] )) { $o=''; foreach($datetime as $k=>$v) {if(is_array($v)) $v=implode('-',$v);$o.=" $k=>$v";} echo " day SAKNAS : $o <br />\n"; } |
4580 | - foreach( $datetime as $dkey => $dvalue ) { |
|
4581 | - if( 'tz' != $dkey ) |
|
4580 | + foreach ($datetime as $dkey => $dvalue) { |
|
4581 | + if ('tz' != $dkey) |
|
4582 | 4582 | $datetime[$dkey] = (integer) $dvalue; |
4583 | 4583 | } |
4584 | - $output = date('Ymd', mktime( 0, 0, 0, $datetime['month'], $datetime['day'], $datetime['year'])); |
|
4585 | - if( isset( $datetime['hour'] ) || |
|
4586 | - isset( $datetime['min'] ) || |
|
4587 | - isset( $datetime['sec'] ) || |
|
4588 | - isset( $datetime['tz'] )) { |
|
4589 | - if( isset( $datetime['tz'] ) && |
|
4590 | - !isset( $datetime['hour'] )) |
|
4584 | + $output = date('Ymd', mktime(0, 0, 0, $datetime['month'], $datetime['day'], $datetime['year'])); |
|
4585 | + if (isset($datetime['hour']) || |
|
4586 | + isset($datetime['min']) || |
|
4587 | + isset($datetime['sec']) || |
|
4588 | + isset($datetime['tz'])) { |
|
4589 | + if (isset($datetime['tz']) && |
|
4590 | + !isset($datetime['hour'])) |
|
4591 | 4591 | $datetime['hour'] = 0; |
4592 | - if( isset( $datetime['hour'] ) && |
|
4593 | - !isset( $datetime['min'] )) |
|
4592 | + if (isset($datetime['hour']) && |
|
4593 | + !isset($datetime['min'])) |
|
4594 | 4594 | $datetime['min'] = 0; |
4595 | - if( isset( $datetime['hour'] ) && |
|
4596 | - isset( $datetime['min'] ) && |
|
4597 | - !isset( $datetime['sec'] )) |
|
4595 | + if (isset($datetime['hour']) && |
|
4596 | + isset($datetime['min']) && |
|
4597 | + !isset($datetime['sec'])) |
|
4598 | 4598 | $datetime['sec'] = 0; |
4599 | - $date = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']); |
|
4600 | - $output .= date('\THis', $date ); |
|
4601 | - if( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) { |
|
4602 | - $datetime['tz'] = trim( $datetime['tz'] ); |
|
4603 | - if( 'Z' == $datetime['tz'] ) |
|
4599 | + $date = mktime($datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']); |
|
4600 | + $output .= date('\THis', $date); |
|
4601 | + if (isset($datetime['tz']) && ('' < trim($datetime['tz']))) { |
|
4602 | + $datetime['tz'] = trim($datetime['tz']); |
|
4603 | + if ('Z' == $datetime['tz']) |
|
4604 | 4604 | $output .= 'Z'; |
4605 | - $offset = $this->_tz2offset( $datetime['tz'] ); |
|
4606 | - if( 0 != $offset ) { |
|
4607 | - $date = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']); |
|
4608 | - $output = date( 'Ymd\THis\Z', $date ); |
|
4605 | + $offset = $this->_tz2offset($datetime['tz']); |
|
4606 | + if (0 != $offset) { |
|
4607 | + $date = mktime($datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']); |
|
4608 | + $output = date('Ymd\THis\Z', $date); |
|
4609 | 4609 | } |
4610 | 4610 | } |
4611 | - elseif( 7 == $parno ) |
|
4611 | + elseif (7 == $parno) |
|
4612 | 4612 | $output .= 'Z'; |
4613 | 4613 | } |
4614 | 4614 | return $output; |
@@ -4621,26 +4621,26 @@ discard block |
||
4621 | 4621 | * @param array $duration ( week, day, hour, min, sec ) |
4622 | 4622 | * @return string |
4623 | 4623 | */ |
4624 | - function _format_duration( $duration ) { |
|
4625 | - if( !isset( $duration['week'] ) && |
|
4626 | - !isset( $duration['day'] ) && |
|
4627 | - !isset( $duration['hour'] ) && |
|
4628 | - !isset( $duration['min'] ) && |
|
4629 | - !isset( $duration['sec'] )) |
|
4624 | + function _format_duration($duration) { |
|
4625 | + if (!isset($duration['week']) && |
|
4626 | + !isset($duration['day']) && |
|
4627 | + !isset($duration['hour']) && |
|
4628 | + !isset($duration['min']) && |
|
4629 | + !isset($duration['sec'])) |
|
4630 | 4630 | return; |
4631 | 4631 | $output = 'P'; |
4632 | - if( isset( $duration['week'] ) && ( 0 < $duration['week'] )) |
|
4632 | + if (isset($duration['week']) && (0 < $duration['week'])) |
|
4633 | 4633 | $output .= $duration['week'].'W'; |
4634 | 4634 | else { |
4635 | - if( isset($duration['day'] ) && ( 0 < $duration['day'] )) |
|
4635 | + if (isset($duration['day']) && (0 < $duration['day'])) |
|
4636 | 4636 | $output .= $duration['day'].'D'; |
4637 | - if(( isset( $duration['hour']) && ( 0 < $duration['hour'] )) || |
|
4638 | - ( isset( $duration['min']) && ( 0 < $duration['min'] )) || |
|
4639 | - ( isset( $duration['sec']) && ( 0 < $duration['sec'] ))) { |
|
4637 | + if ((isset($duration['hour']) && (0 < $duration['hour'])) || |
|
4638 | + (isset($duration['min']) && (0 < $duration['min'])) || |
|
4639 | + (isset($duration['sec']) && (0 < $duration['sec']))) { |
|
4640 | 4640 | $output .= 'T'; |
4641 | - $output .= ( isset( $duration['hour']) && ( 0 < $duration['hour'] )) ? $duration['hour'].'H' : '0H'; |
|
4642 | - $output .= ( isset( $duration['min']) && ( 0 < $duration['min'] )) ? $duration['min']. 'M' : '0M'; |
|
4643 | - $output .= ( isset( $duration['sec']) && ( 0 < $duration['sec'] )) ? $duration['sec']. 'S' : '0S'; |
|
4641 | + $output .= (isset($duration['hour']) && (0 < $duration['hour'])) ? $duration['hour'].'H' : '0H'; |
|
4642 | + $output .= (isset($duration['min']) && (0 < $duration['min'])) ? $duration['min'].'M' : '0M'; |
|
4643 | + $output .= (isset($duration['sec']) && (0 < $duration['sec'])) ? $duration['sec'].'S' : '0S'; |
|
4644 | 4644 | } |
4645 | 4645 | } |
4646 | 4646 | return $output; |
@@ -4654,24 +4654,24 @@ discard block |
||
4654 | 4654 | * @param array $recurdata |
4655 | 4655 | * @return string |
4656 | 4656 | */ |
4657 | - function _format_recur( $recurlabel, $recurdata ) { |
|
4657 | + function _format_recur($recurlabel, $recurdata) { |
|
4658 | 4658 | $output = null; |
4659 | - foreach( $recurdata as $therule ) { |
|
4660 | - if( empty( $therule['value'] )) { |
|
4661 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $recurlabel ); |
|
4659 | + foreach ($recurdata as $therule) { |
|
4660 | + if (empty($therule['value'])) { |
|
4661 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement($recurlabel); |
|
4662 | 4662 | continue; |
4663 | 4663 | } |
4664 | - $attributes = ( isset( $therule['params'] )) ? $this->_createParams( $therule['params'] ) : null; |
|
4665 | - $content1 = $content2 = null; |
|
4666 | - foreach( $therule['value'] as $rulelabel => $rulevalue ) { |
|
4667 | - switch( $rulelabel ) { |
|
4664 | + $attributes = (isset($therule['params'])) ? $this->_createParams($therule['params']) : null; |
|
4665 | + $content1 = $content2 = null; |
|
4666 | + foreach ($therule['value'] as $rulelabel => $rulevalue) { |
|
4667 | + switch ($rulelabel) { |
|
4668 | 4668 | case 'FREQ': { |
4669 | 4669 | $content1 .= "FREQ=$rulevalue"; |
4670 | 4670 | break; |
4671 | 4671 | } |
4672 | 4672 | case 'UNTIL': { |
4673 | 4673 | $content2 .= ";UNTIL="; |
4674 | - $content2 .= $this->_format_date_time( $rulevalue ); |
|
4674 | + $content2 .= $this->_format_date_time($rulevalue); |
|
4675 | 4675 | break; |
4676 | 4676 | } |
4677 | 4677 | case 'COUNT': |
@@ -4689,9 +4689,9 @@ discard block |
||
4689 | 4689 | case 'BYMONTH': |
4690 | 4690 | case 'BYSETPOS': { |
4691 | 4691 | $content2 .= ";$rulelabel="; |
4692 | - if( is_array( $rulevalue )) { |
|
4693 | - foreach( $rulevalue as $vix => $valuePart ) { |
|
4694 | - $content2 .= ( $vix ) ? ',' : null; |
|
4692 | + if (is_array($rulevalue)) { |
|
4693 | + foreach ($rulevalue as $vix => $valuePart) { |
|
4694 | + $content2 .= ($vix) ? ',' : null; |
|
4695 | 4695 | $content2 .= $valuePart; |
4696 | 4696 | } |
4697 | 4697 | } |
@@ -4702,12 +4702,12 @@ discard block |
||
4702 | 4702 | case 'BYDAY': { |
4703 | 4703 | $content2 .= ";$rulelabel="; |
4704 | 4704 | $bydaycnt = 0; |
4705 | - foreach( $rulevalue as $vix => $valuePart ) { |
|
4705 | + foreach ($rulevalue as $vix => $valuePart) { |
|
4706 | 4706 | $content21 = $content22 = null; |
4707 | - if( is_array( $valuePart )) { |
|
4708 | - $content2 .= ( $bydaycnt ) ? ',' : null; |
|
4709 | - foreach( $valuePart as $vix2 => $valuePart2 ) { |
|
4710 | - if( 'DAY' != strtoupper( $vix2 )) |
|
4707 | + if (is_array($valuePart)) { |
|
4708 | + $content2 .= ($bydaycnt) ? ',' : null; |
|
4709 | + foreach ($valuePart as $vix2 => $valuePart2) { |
|
4710 | + if ('DAY' != strtoupper($vix2)) |
|
4711 | 4711 | $content21 .= $valuePart2; |
4712 | 4712 | else |
4713 | 4713 | $content22 .= $valuePart2; |
@@ -4716,8 +4716,8 @@ discard block |
||
4716 | 4716 | $bydaycnt++; |
4717 | 4717 | } |
4718 | 4718 | else { |
4719 | - $content2 .= ( $bydaycnt ) ? ',' : null; |
|
4720 | - if( 'DAY' != strtoupper( $vix )) |
|
4719 | + $content2 .= ($bydaycnt) ? ',' : null; |
|
4720 | + if ('DAY' != strtoupper($vix)) |
|
4721 | 4721 | $content21 .= $valuePart; |
4722 | 4722 | else { |
4723 | 4723 | $content22 .= $valuePart; |
@@ -4734,7 +4734,7 @@ discard block |
||
4734 | 4734 | } |
4735 | 4735 | } |
4736 | 4736 | } |
4737 | - $output .= $this->_createElement( $recurlabel, $attributes, $content1.$content2 ); |
|
4737 | + $output .= $this->_createElement($recurlabel, $attributes, $content1.$content2); |
|
4738 | 4738 | } |
4739 | 4739 | return $output; |
4740 | 4740 | } |
@@ -4746,13 +4746,13 @@ discard block |
||
4746 | 4746 | * @param string $propertyName |
4747 | 4747 | * @return string |
4748 | 4748 | */ |
4749 | - function _formatPropertyName( $propertyName ) { |
|
4750 | - switch( $this->format ) { |
|
4749 | + function _formatPropertyName($propertyName) { |
|
4750 | + switch ($this->format) { |
|
4751 | 4751 | case 'xcal': |
4752 | - return strtolower( $propertyName ); |
|
4752 | + return strtolower($propertyName); |
|
4753 | 4753 | break; |
4754 | 4754 | default: |
4755 | - return strtoupper( $propertyName ); |
|
4755 | + return strtoupper($propertyName); |
|
4756 | 4756 | break; |
4757 | 4757 | } |
4758 | 4758 | } |
@@ -4764,25 +4764,25 @@ discard block |
||
4764 | 4764 | * @param array $input |
4765 | 4765 | * @return bool |
4766 | 4766 | */ |
4767 | - function _isArrayDate( $input ) { |
|
4768 | - if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 )))) |
|
4767 | + function _isArrayDate($input) { |
|
4768 | + if (isset($input['week']) || (!in_array(count($input), array(3, 6, 7)))) |
|
4769 | 4769 | return FALSE; |
4770 | - if( 7 == count( $input )) |
|
4770 | + if (7 == count($input)) |
|
4771 | 4771 | return TRUE; |
4772 | - if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) |
|
4773 | - return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
4774 | - if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] )) |
|
4772 | + if (isset($input['year']) && isset($input['month']) && isset($input['day'])) |
|
4773 | + return checkdate((int) $input['month'], (int) $input['day'], (int) $input['year']); |
|
4774 | + if (isset($input['day']) || isset($input['hour']) || isset($input['min']) || isset($input['sec'])) |
|
4775 | 4775 | return FALSE; |
4776 | - if( in_array( 0, $input )) |
|
4776 | + if (in_array(0, $input)) |
|
4777 | 4777 | return FALSE; |
4778 | - if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] )) |
|
4778 | + if ((1970 > $input[0]) || (12 < $input[1]) || (31 < $input[2])) |
|
4779 | 4779 | return FALSE; |
4780 | - if(( isset( $input[0] ) && isset( $input[1] ) && isset( $input[2] )) && |
|
4781 | - checkdate( (int) $input[1], (int) $input[2], (int) $input[0] )) |
|
4780 | + if ((isset($input[0]) && isset($input[1]) && isset($input[2])) && |
|
4781 | + checkdate((int) $input[1], (int) $input[2], (int) $input[0])) |
|
4782 | 4782 | return TRUE; |
4783 | - $input = $this->_date_time_string( $input[1].'/'.$input[2].'/'.$input[0], 3 ); // m - d - Y |
|
4784 | - if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) |
|
4785 | - return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
4783 | + $input = $this->_date_time_string($input[1].'/'.$input[2].'/'.$input[0], 3); // m - d - Y |
|
4784 | + if (isset($input['year']) && isset($input['month']) && isset($input['day'])) |
|
4785 | + return checkdate((int) $input['month'], (int) $input['day'], (int) $input['year']); |
|
4786 | 4786 | return FALSE; |
4787 | 4787 | } |
4788 | 4788 | /** |
@@ -4793,8 +4793,8 @@ discard block |
||
4793 | 4793 | * @param array $input |
4794 | 4794 | * @return bool |
4795 | 4795 | */ |
4796 | - function _isArrayTimestampDate( $input ) { |
|
4797 | - return ( is_array( $input ) && isset( $input['timestamp'] )) ? TRUE : FALSE ; |
|
4796 | + function _isArrayTimestampDate($input) { |
|
4797 | + return (is_array($input) && isset($input['timestamp'])) ? TRUE : FALSE; |
|
4798 | 4798 | } |
4799 | 4799 | /** |
4800 | 4800 | * controll if input string contains traling UTC offset |
@@ -4804,17 +4804,17 @@ discard block |
||
4804 | 4804 | * @param string $input |
4805 | 4805 | * @return bool |
4806 | 4806 | */ |
4807 | - function _isOffset( $input ) { |
|
4808 | - $input = trim( (string) $input ); |
|
4809 | - if( 'Z' == substr( $input, -1 )) |
|
4807 | + function _isOffset($input) { |
|
4808 | + $input = trim((string) $input); |
|
4809 | + if ('Z' == substr($input, -1)) |
|
4810 | 4810 | return TRUE; |
4811 | - elseif(( 5 <= strlen( $input )) && |
|
4812 | - ( in_array( substr( $input, -5, 1 ), array( '+', '-' ))) && |
|
4813 | - ( '0000' < substr( $input, -4 )) && ( '9999' >= substr( $input, -4 ))) |
|
4811 | + elseif ((5 <= strlen($input)) && |
|
4812 | + (in_array(substr($input, -5, 1), array('+', '-'))) && |
|
4813 | + ('0000' < substr($input, -4)) && ('9999' >= substr($input, -4))) |
|
4814 | 4814 | return TRUE; |
4815 | - elseif(( 7 <= strlen( $input )) && |
|
4816 | - ( in_array( substr( $input, -7, 1 ), array( '+', '-' ))) && |
|
4817 | - ( '000000' < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 ))) |
|
4815 | + elseif ((7 <= strlen($input)) && |
|
4816 | + (in_array(substr($input, -7, 1), array('+', '-'))) && |
|
4817 | + ('000000' < substr($input, -6)) && ('999999' >= substr($input, -6))) |
|
4818 | 4818 | return TRUE; |
4819 | 4819 | return FALSE; |
4820 | 4820 | |
@@ -4827,15 +4827,15 @@ discard block |
||
4827 | 4827 | * @param string $propName |
4828 | 4828 | * @return bool |
4829 | 4829 | */ |
4830 | - function _notExistProp( $propName ) { |
|
4831 | - if( empty( $propName )) return FALSE; // when deleting x-prop, an empty propName may be used=allowed |
|
4832 | - $propName = strtolower( $propName ); |
|
4833 | - if( 'last-modified' == $propName ) { if( !isset( $this->lastmodified )) return TRUE; } |
|
4834 | - elseif( 'percent-complete' == $propName ) { if( !isset( $this->percentcomplete )) return TRUE; } |
|
4835 | - elseif( 'recurrence-id' == $propName ) { if( !isset( $this->recurrenceid )) return TRUE; } |
|
4836 | - elseif( 'related-to' == $propName ) { if( !isset( $this->relatedto )) return TRUE; } |
|
4837 | - elseif( 'request-status' == $propName ) { if( !isset( $this->requeststatus )) return TRUE; } |
|
4838 | - elseif(( 'x-' != substr($propName,0,2)) && !isset( $this->$propName )) return TRUE; |
|
4830 | + function _notExistProp($propName) { |
|
4831 | + if (empty($propName)) return FALSE; // when deleting x-prop, an empty propName may be used=allowed |
|
4832 | + $propName = strtolower($propName); |
|
4833 | + if ('last-modified' == $propName) { if (!isset($this->lastmodified)) return TRUE; } |
|
4834 | + elseif ('percent-complete' == $propName) { if (!isset($this->percentcomplete)) return TRUE; } |
|
4835 | + elseif ('recurrence-id' == $propName) { if (!isset($this->recurrenceid)) return TRUE; } |
|
4836 | + elseif ('related-to' == $propName) { if (!isset($this->relatedto)) return TRUE; } |
|
4837 | + elseif ('request-status' == $propName) { if (!isset($this->requeststatus)) return TRUE; } |
|
4838 | + elseif (('x-' != substr($propName, 0, 2)) && !isset($this->$propName)) return TRUE; |
|
4839 | 4839 | return FALSE; |
4840 | 4840 | } |
4841 | 4841 | /** |
@@ -4853,101 +4853,101 @@ discard block |
||
4853 | 4853 | * @return array of recurrence (start-)dates as index |
4854 | 4854 | * @todo BYHOUR, BYMINUTE, BYSECOND, ev. BYSETPOS due to ambiguity, WEEKLY at year end/start |
4855 | 4855 | */ |
4856 | - function _recur2date( & $result, $recur, $wdate, $startdate, $enddate=FALSE ) { |
|
4857 | - foreach( $wdate as $k => $v ) if( ctype_digit( $v )) $wdate[$k] = (int) $v; |
|
4858 | - $wdatets = $this->_date2timestamp( $wdate ); |
|
4859 | - $startdatets = $this->_date2timestamp( $startdate ); |
|
4860 | - if( !$enddate ) { |
|
4856 | + function _recur2date(& $result, $recur, $wdate, $startdate, $enddate = FALSE) { |
|
4857 | + foreach ($wdate as $k => $v) if (ctype_digit($v)) $wdate[$k] = (int) $v; |
|
4858 | + $wdatets = $this->_date2timestamp($wdate); |
|
4859 | + $startdatets = $this->_date2timestamp($startdate); |
|
4860 | + if (!$enddate) { |
|
4861 | 4861 | $enddate = $startdate; |
4862 | 4862 | $enddate['year'] += 1; |
4863 | 4863 | // echo "recur __in_ ".implode('-',$startdate)." period start ".implode('-',$wdate)." period end ".implode('-',$enddate)."<br />\n";print_r($recur);echo "<br />\n";//test### |
4864 | 4864 | } |
4865 | - $endDatets = $this->_date2timestamp( $enddate ); // fix break |
|
4866 | - if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] )) |
|
4865 | + $endDatets = $this->_date2timestamp($enddate); // fix break |
|
4866 | + if (!isset($recur['COUNT']) && !isset($recur['UNTIL'])) |
|
4867 | 4867 | $recur['UNTIL'] = $enddate; // create break |
4868 | - if( isset( $recur['UNTIL'] )) { |
|
4869 | - $tdatets = $this->_date2timestamp( $recur['UNTIL'] ); |
|
4870 | - if( $endDatets > $tdatets ) { |
|
4868 | + if (isset($recur['UNTIL'])) { |
|
4869 | + $tdatets = $this->_date2timestamp($recur['UNTIL']); |
|
4870 | + if ($endDatets > $tdatets) { |
|
4871 | 4871 | $endDatets = $tdatets; // emergency break |
4872 | - $enddate = $this->_timestamp2date( $endDatets, 6 ); |
|
4872 | + $enddate = $this->_timestamp2date($endDatets, 6); |
|
4873 | 4873 | } |
4874 | 4874 | else |
4875 | - $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 ); |
|
4875 | + $recur['UNTIL'] = $this->_timestamp2date($endDatets, 6); |
|
4876 | 4876 | } |
4877 | - if( $wdatets > $endDatets ) { |
|
4877 | + if ($wdatets > $endDatets) { |
|
4878 | 4878 | //echo "recur out of date ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test |
4879 | 4879 | return array(); // nothing to do.. . |
4880 | 4880 | } |
4881 | - if( !isset( $recur['FREQ'] )) // "MUST be specified.. ." |
|
4881 | + if (!isset($recur['FREQ'])) // "MUST be specified.. ." |
|
4882 | 4882 | $recur['FREQ'] = 'DAILY'; // ?? |
4883 | - $wkst = ( isset( $recur['WKST'] ) && ( 'SU' == $recur['WKST'] )) ? 24*60*60 : 0; // ?? |
|
4884 | - if( !isset( $recur['INTERVAL'] )) |
|
4883 | + $wkst = (isset($recur['WKST']) && ('SU' == $recur['WKST'])) ? 24 * 60 * 60 : 0; // ?? |
|
4884 | + if (!isset($recur['INTERVAL'])) |
|
4885 | 4885 | $recur['INTERVAL'] = 1; |
4886 | - $countcnt = ( !isset( $recur['BYSETPOS'] )) ? 1 : 0; // DTSTART counts as the first occurrence |
|
4886 | + $countcnt = (!isset($recur['BYSETPOS'])) ? 1 : 0; // DTSTART counts as the first occurrence |
|
4887 | 4887 | /* find out how to step up dates and set index for interval count */ |
4888 | 4888 | $step = array(); |
4889 | - if( 'YEARLY' == $recur['FREQ'] ) |
|
4889 | + if ('YEARLY' == $recur['FREQ']) |
|
4890 | 4890 | $step['year'] = 1; |
4891 | - elseif( 'MONTHLY' == $recur['FREQ'] ) |
|
4891 | + elseif ('MONTHLY' == $recur['FREQ']) |
|
4892 | 4892 | $step['month'] = 1; |
4893 | - elseif( 'WEEKLY' == $recur['FREQ'] ) |
|
4893 | + elseif ('WEEKLY' == $recur['FREQ']) |
|
4894 | 4894 | $step['day'] = 7; |
4895 | 4895 | else |
4896 | 4896 | $step['day'] = 1; |
4897 | - if( isset( $step['year'] ) && isset( $recur['BYMONTH'] )) |
|
4898 | - $step = array( 'month' => 1 ); |
|
4899 | - if( empty( $step ) && isset( $recur['BYWEEKNO'] )) // ?? |
|
4900 | - $step = array( 'day' => 7 ); |
|
4901 | - if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] )) |
|
4902 | - $step = array( 'day' => 1 ); |
|
4897 | + if (isset($step['year']) && isset($recur['BYMONTH'])) |
|
4898 | + $step = array('month' => 1); |
|
4899 | + if (empty($step) && isset($recur['BYWEEKNO'])) // ?? |
|
4900 | + $step = array('day' => 7); |
|
4901 | + if (isset($recur['BYYEARDAY']) || isset($recur['BYMONTHDAY']) || isset($recur['BYDAY'])) |
|
4902 | + $step = array('day' => 1); |
|
4903 | 4903 | $intervalarr = array(); |
4904 | - if( 1 < $recur['INTERVAL'] ) { |
|
4905 | - $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst ); |
|
4906 | - $intervalarr = array( $intervalix => 0 ); |
|
4904 | + if (1 < $recur['INTERVAL']) { |
|
4905 | + $intervalix = $this->_recurIntervalIx($recur['FREQ'], $wdate, $wkst); |
|
4906 | + $intervalarr = array($intervalix => 0); |
|
4907 | 4907 | } |
4908 | - if( isset( $recur['BYSETPOS'] )) { // save start date + weekno |
|
4908 | + if (isset($recur['BYSETPOS'])) { // save start date + weekno |
|
4909 | 4909 | $bysetposymd1 = $bysetposymd2 = $bysetposw1 = $bysetposw2 = array(); |
4910 | - $bysetposWold = (int) date( 'W', ( $wdatets + $wkst )); |
|
4910 | + $bysetposWold = (int) date('W', ($wdatets + $wkst)); |
|
4911 | 4911 | $bysetposYold = $wdate['year']; |
4912 | 4912 | $bysetposMold = $wdate['month']; |
4913 | 4913 | $bysetposDold = $wdate['day']; |
4914 | - if( is_array( $recur['BYSETPOS'] )) { |
|
4915 | - foreach( $recur['BYSETPOS'] as $bix => $bval ) |
|
4914 | + if (is_array($recur['BYSETPOS'])) { |
|
4915 | + foreach ($recur['BYSETPOS'] as $bix => $bval) |
|
4916 | 4916 | $recur['BYSETPOS'][$bix] = (int) $bval; |
4917 | 4917 | } |
4918 | 4918 | else |
4919 | - $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] ); |
|
4920 | - $this->_stepdate( $enddate, $endDatets, $step); // make sure to count whole last period |
|
4919 | + $recur['BYSETPOS'] = array((int) $recur['BYSETPOS']); |
|
4920 | + $this->_stepdate($enddate, $endDatets, $step); // make sure to count whole last period |
|
4921 | 4921 | } |
4922 | - $this->_stepdate( $wdate, $wdatets, $step); |
|
4922 | + $this->_stepdate($wdate, $wdatets, $step); |
|
4923 | 4923 | $year_old = null; |
4924 | - $daynames = array( 'SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA' ); |
|
4924 | + $daynames = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'); |
|
4925 | 4925 | /* MAIN LOOP */ |
4926 | 4926 | // echo "recur start ".implode('-',$wdate)." end ".implode('-',$enddate)."<br />\n";//test |
4927 | - while( TRUE ) { |
|
4928 | - if( isset( $endDatets ) && ( $wdatets > $endDatets )) |
|
4927 | + while (TRUE) { |
|
4928 | + if (isset($endDatets) && ($wdatets > $endDatets)) |
|
4929 | 4929 | break; |
4930 | - if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) |
|
4930 | + if (isset($recur['COUNT']) && ($countcnt >= $recur['COUNT'])) |
|
4931 | 4931 | break; |
4932 | - if( $year_old != $wdate['year'] ) { |
|
4932 | + if ($year_old != $wdate['year']) { |
|
4933 | 4933 | $year_old = $wdate['year']; |
4934 | 4934 | $daycnts = array(); |
4935 | 4935 | $yeardays = $weekno = 0; |
4936 | 4936 | $yeardaycnt = array(); |
4937 | - for( $m = 1; $m <= 12; $m++ ) { // count up and update up-counters |
|
4937 | + for ($m = 1; $m <= 12; $m++) { // count up and update up-counters |
|
4938 | 4938 | $daycnts[$m] = array(); |
4939 | 4939 | $weekdaycnt = array(); |
4940 | - foreach( $daynames as $dn ) |
|
4940 | + foreach ($daynames as $dn) |
|
4941 | 4941 | $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
4942 | - $mcnt = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] )); |
|
4943 | - for( $d = 1; $d <= $mcnt; $d++ ) { |
|
4942 | + $mcnt = date('t', mktime(0, 0, 0, $m, 1, $wdate['year'])); |
|
4943 | + for ($d = 1; $d <= $mcnt; $d++) { |
|
4944 | 4944 | $daycnts[$m][$d] = array(); |
4945 | - if( isset( $recur['BYYEARDAY'] )) { |
|
4945 | + if (isset($recur['BYYEARDAY'])) { |
|
4946 | 4946 | $yeardays++; |
4947 | 4947 | $daycnts[$m][$d]['yearcnt_up'] = $yeardays; |
4948 | 4948 | } |
4949 | - if( isset( $recur['BYDAY'] )) { |
|
4950 | - $day = date( 'w', mktime( 0, 0, 0, $m, $d, $wdate['year'] )); |
|
4949 | + if (isset($recur['BYDAY'])) { |
|
4950 | + $day = date('w', mktime(0, 0, 0, $m, $d, $wdate['year'])); |
|
4951 | 4951 | $day = $daynames[$day]; |
4952 | 4952 | $daycnts[$m][$d]['DAY'] = $day; |
4953 | 4953 | $weekdaycnt[$day]++; |
@@ -4955,64 +4955,64 @@ discard block |
||
4955 | 4955 | $yeardaycnt[$day]++; |
4956 | 4956 | $daycnts[$m][$d]['yeardayno_up'] = $yeardaycnt[$day]; |
4957 | 4957 | } |
4958 | - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) |
|
4959 | - $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year'])); |
|
4958 | + if (isset($recur['BYWEEKNO']) || ($recur['FREQ'] == 'WEEKLY')) |
|
4959 | + $daycnts[$m][$d]['weekno_up'] = (int) date('W', mktime(0, 0, $wkst, $m, $d, $wdate['year'])); |
|
4960 | 4960 | } |
4961 | 4961 | } |
4962 | 4962 | $daycnt = 0; |
4963 | 4963 | $yeardaycnt = array(); |
4964 | - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) { |
|
4964 | + if (isset($recur['BYWEEKNO']) || ($recur['FREQ'] == 'WEEKLY')) { |
|
4965 | 4965 | $weekno = null; |
4966 | - for( $d=31; $d > 25; $d-- ) { // get last weekno for year |
|
4967 | - if( !$weekno ) |
|
4966 | + for ($d = 31; $d > 25; $d--) { // get last weekno for year |
|
4967 | + if (!$weekno) |
|
4968 | 4968 | $weekno = $daycnts[12][$d]['weekno_up']; |
4969 | - elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) { |
|
4969 | + elseif ($weekno < $daycnts[12][$d]['weekno_up']) { |
|
4970 | 4970 | $weekno = $daycnts[12][$d]['weekno_up']; |
4971 | 4971 | break; |
4972 | 4972 | } |
4973 | 4973 | } |
4974 | 4974 | } |
4975 | - for( $m = 12; $m > 0; $m-- ) { // count down and update down-counters |
|
4975 | + for ($m = 12; $m > 0; $m--) { // count down and update down-counters |
|
4976 | 4976 | $weekdaycnt = array(); |
4977 | - foreach( $daynames as $dn ) |
|
4977 | + foreach ($daynames as $dn) |
|
4978 | 4978 | $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
4979 | 4979 | $monthcnt = 0; |
4980 | - $mcnt = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] )); |
|
4981 | - for( $d = $mcnt; $d > 0; $d-- ) { |
|
4982 | - if( isset( $recur['BYYEARDAY'] )) { |
|
4980 | + $mcnt = date('t', mktime(0, 0, 0, $m, 1, $wdate['year'])); |
|
4981 | + for ($d = $mcnt; $d > 0; $d--) { |
|
4982 | + if (isset($recur['BYYEARDAY'])) { |
|
4983 | 4983 | $daycnt -= 1; |
4984 | 4984 | $daycnts[$m][$d]['yearcnt_down'] = $daycnt; |
4985 | 4985 | } |
4986 | - if( isset( $recur['BYMONTHDAY'] )) { |
|
4986 | + if (isset($recur['BYMONTHDAY'])) { |
|
4987 | 4987 | $monthcnt -= 1; |
4988 | 4988 | $daycnts[$m][$d]['monthcnt_down'] = $monthcnt; |
4989 | 4989 | } |
4990 | - if( isset( $recur['BYDAY'] )) { |
|
4991 | - $day = $daycnts[$m][$d]['DAY']; |
|
4990 | + if (isset($recur['BYDAY'])) { |
|
4991 | + $day = $daycnts[$m][$d]['DAY']; |
|
4992 | 4992 | $weekdaycnt[$day] -= 1; |
4993 | 4993 | $daycnts[$m][$d]['monthdayno_down'] = $weekdaycnt[$day]; |
4994 | 4994 | $yeardaycnt[$day] -= 1; |
4995 | 4995 | $daycnts[$m][$d]['yeardayno_down'] = $yeardaycnt[$day]; |
4996 | 4996 | } |
4997 | - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) |
|
4997 | + if (isset($recur['BYWEEKNO']) || ($recur['FREQ'] == 'WEEKLY')) |
|
4998 | 4998 | $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1); |
4999 | 4999 | } |
5000 | 5000 | } |
5001 | 5001 | } |
5002 | 5002 | /* check interval */ |
5003 | - if( 1 < $recur['INTERVAL'] ) { |
|
5003 | + if (1 < $recur['INTERVAL']) { |
|
5004 | 5004 | /* create interval index */ |
5005 | - $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst ); |
|
5005 | + $intervalix = $this->_recurIntervalIx($recur['FREQ'], $wdate, $wkst); |
|
5006 | 5006 | /* check interval */ |
5007 | - $currentKey = array_keys( $intervalarr ); |
|
5008 | - $currentKey = end( $currentKey ); // get last index |
|
5009 | - if( $currentKey != $intervalix ) |
|
5010 | - $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 )); |
|
5011 | - if(( $recur['INTERVAL'] != $intervalarr[$intervalix] ) && |
|
5012 | - ( 0 != $intervalarr[$intervalix] )) { |
|
5007 | + $currentKey = array_keys($intervalarr); |
|
5008 | + $currentKey = end($currentKey); // get last index |
|
5009 | + if ($currentKey != $intervalix) |
|
5010 | + $intervalarr = array($intervalix => ($intervalarr[$currentKey] + 1)); |
|
5011 | + if (($recur['INTERVAL'] != $intervalarr[$intervalix]) && |
|
5012 | + (0 != $intervalarr[$intervalix])) { |
|
5013 | 5013 | /* step up date */ |
5014 | 5014 | //echo "skip: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test |
5015 | - $this->_stepdate( $wdate, $wdatets, $step); |
|
5015 | + $this->_stepdate($wdate, $wdatets, $step); |
|
5016 | 5016 | continue; |
5017 | 5017 | } |
5018 | 5018 | else // continue within the selected interval |
@@ -5020,69 +5020,69 @@ discard block |
||
5020 | 5020 | //echo "cont: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test |
5021 | 5021 | } |
5022 | 5022 | $updateOK = TRUE; |
5023 | - if( $updateOK && isset( $recur['BYMONTH'] )) |
|
5024 | - $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH'] |
|
5023 | + if ($updateOK && isset($recur['BYMONTH'])) |
|
5024 | + $updateOK = $this->_recurBYcntcheck($recur['BYMONTH'] |
|
5025 | 5025 | , $wdate['month'] |
5026 | 5026 | ,($wdate['month'] - 13)); |
5027 | - if( $updateOK && isset( $recur['BYWEEKNO'] )) |
|
5028 | - $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO'] |
|
5027 | + if ($updateOK && isset($recur['BYWEEKNO'])) |
|
5028 | + $updateOK = $this->_recurBYcntcheck($recur['BYWEEKNO'] |
|
5029 | 5029 | , $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] |
5030 | - , $daycnts[$wdate['month']][$wdate['day']]['weekno_down'] ); |
|
5031 | - if( $updateOK && isset( $recur['BYYEARDAY'] )) |
|
5032 | - $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY'] |
|
5030 | + , $daycnts[$wdate['month']][$wdate['day']]['weekno_down']); |
|
5031 | + if ($updateOK && isset($recur['BYYEARDAY'])) |
|
5032 | + $updateOK = $this->_recurBYcntcheck($recur['BYYEARDAY'] |
|
5033 | 5033 | , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_up'] |
5034 | - , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down'] ); |
|
5035 | - if( $updateOK && isset( $recur['BYMONTHDAY'] )) |
|
5036 | - $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY'] |
|
5034 | + , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down']); |
|
5035 | + if ($updateOK && isset($recur['BYMONTHDAY'])) |
|
5036 | + $updateOK = $this->_recurBYcntcheck($recur['BYMONTHDAY'] |
|
5037 | 5037 | , $wdate['day'] |
5038 | - , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down'] ); |
|
5038 | + , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down']); |
|
5039 | 5039 | //echo "efter BYMONTHDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n";//test### |
5040 | - if( $updateOK && isset( $recur['BYDAY'] )) { |
|
5040 | + if ($updateOK && isset($recur['BYDAY'])) { |
|
5041 | 5041 | $updateOK = FALSE; |
5042 | 5042 | $m = $wdate['month']; |
5043 | 5043 | $d = $wdate['day']; |
5044 | - if( isset( $recur['BYDAY']['DAY'] )) { // single day, opt with year/month day order no |
|
5045 | - $daynoexists = $daynosw = $daynamesw = FALSE; |
|
5046 | - if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] ) |
|
5044 | + if (isset($recur['BYDAY']['DAY'])) { // single day, opt with year/month day order no |
|
5045 | + $daynoexists = $daynosw = $daynamesw = FALSE; |
|
5046 | + if ($recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY']) |
|
5047 | 5047 | $daynamesw = TRUE; |
5048 | - if( isset( $recur['BYDAY'][0] )) { |
|
5048 | + if (isset($recur['BYDAY'][0])) { |
|
5049 | 5049 | $daynoexists = TRUE; |
5050 | - if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] )) |
|
5051 | - $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5050 | + if ((isset($recur['FREQ']) && ($recur['FREQ'] == 'MONTHLY')) || isset($recur['BYMONTH'])) |
|
5051 | + $daynosw = $this->_recurBYcntcheck($recur['BYDAY'][0] |
|
5052 | 5052 | , $daycnts[$m][$d]['monthdayno_up'] |
5053 | - , $daycnts[$m][$d]['monthdayno_down'] ); |
|
5054 | - elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) |
|
5055 | - $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5053 | + , $daycnts[$m][$d]['monthdayno_down']); |
|
5054 | + elseif (isset($recur['FREQ']) && ($recur['FREQ'] == 'YEARLY')) |
|
5055 | + $daynosw = $this->_recurBYcntcheck($recur['BYDAY'][0] |
|
5056 | 5056 | , $daycnts[$m][$d]['yeardayno_up'] |
5057 | - , $daycnts[$m][$d]['yeardayno_down'] ); |
|
5057 | + , $daycnts[$m][$d]['yeardayno_down']); |
|
5058 | 5058 | } |
5059 | - if(( $daynoexists && $daynosw && $daynamesw ) || |
|
5060 | - ( !$daynoexists && !$daynosw && $daynamesw )) { |
|
5059 | + if (($daynoexists && $daynosw && $daynamesw) || |
|
5060 | + (!$daynoexists && !$daynosw && $daynamesw)) { |
|
5061 | 5061 | $updateOK = TRUE; |
5062 | 5062 | } |
5063 | 5063 | //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ### |
5064 | 5064 | } |
5065 | 5065 | else { |
5066 | - foreach( $recur['BYDAY'] as $bydayvalue ) { |
|
5066 | + foreach ($recur['BYDAY'] as $bydayvalue) { |
|
5067 | 5067 | $daynoexists = $daynosw = $daynamesw = FALSE; |
5068 | - if( isset( $bydayvalue['DAY'] ) && |
|
5069 | - ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] )) |
|
5068 | + if (isset($bydayvalue['DAY']) && |
|
5069 | + ($bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'])) |
|
5070 | 5070 | $daynamesw = TRUE; |
5071 | - if( isset( $bydayvalue[0] )) { |
|
5071 | + if (isset($bydayvalue[0])) { |
|
5072 | 5072 | $daynoexists = TRUE; |
5073 | - if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || |
|
5074 | - isset( $recur['BYMONTH'] )) |
|
5075 | - $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5073 | + if ((isset($recur['FREQ']) && ($recur['FREQ'] == 'MONTHLY')) || |
|
5074 | + isset($recur['BYMONTH'])) |
|
5075 | + $daynosw = $this->_recurBYcntcheck($bydayvalue['0'] |
|
5076 | 5076 | , $daycnts[$m][$d]['monthdayno_up'] |
5077 | - , $daycnts[$m][$d]['monthdayno_down'] ); |
|
5078 | - elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) |
|
5079 | - $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5077 | + , $daycnts[$m][$d]['monthdayno_down']); |
|
5078 | + elseif (isset($recur['FREQ']) && ($recur['FREQ'] == 'YEARLY')) |
|
5079 | + $daynosw = $this->_recurBYcntcheck($bydayvalue['0'] |
|
5080 | 5080 | , $daycnts[$m][$d]['yeardayno_up'] |
5081 | - , $daycnts[$m][$d]['yeardayno_down'] ); |
|
5081 | + , $daycnts[$m][$d]['yeardayno_down']); |
|
5082 | 5082 | } |
5083 | 5083 | //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ### |
5084 | - if(( $daynoexists && $daynosw && $daynamesw ) || |
|
5085 | - ( !$daynoexists && !$daynosw && $daynamesw )) { |
|
5084 | + if (($daynoexists && $daynosw && $daynamesw) || |
|
5085 | + (!$daynoexists && !$daynosw && $daynamesw)) { |
|
5086 | 5086 | $updateOK = TRUE; |
5087 | 5087 | break; |
5088 | 5088 | } |
@@ -5091,25 +5091,25 @@ discard block |
||
5091 | 5091 | } |
5092 | 5092 | //echo "efter BYDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n"; // test ### |
5093 | 5093 | /* check BYSETPOS */ |
5094 | - if( $updateOK ) { |
|
5095 | - if( isset( $recur['BYSETPOS'] ) && |
|
5096 | - ( in_array( $recur['FREQ'], array( 'YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY' )))) { |
|
5097 | - if( isset( $recur['WEEKLY'] )) { |
|
5098 | - if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] ) |
|
5094 | + if ($updateOK) { |
|
5095 | + if (isset($recur['BYSETPOS']) && |
|
5096 | + (in_array($recur['FREQ'], array('YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY')))) { |
|
5097 | + if (isset($recur['WEEKLY'])) { |
|
5098 | + if ($bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up']) |
|
5099 | 5099 | $bysetposw1[] = $wdatets; |
5100 | 5100 | else |
5101 | 5101 | $bysetposw2[] = $wdatets; |
5102 | 5102 | } |
5103 | 5103 | else { |
5104 | - if(( isset( $recur['FREQ'] ) && ( 'YEARLY' == $recur['FREQ'] ) && |
|
5105 | - ( $bysetposYold == $wdate['year'] )) || |
|
5106 | - ( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] ) && |
|
5107 | - (( $bysetposYold == $wdate['year'] ) && |
|
5108 | - ( $bysetposMold == $wdate['month'] ))) || |
|
5109 | - ( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] ) && |
|
5110 | - (( $bysetposYold == $wdate['year'] ) && |
|
5111 | - ( $bysetposMold == $wdate['month']) && |
|
5112 | - ( $bysetposDold == $wdate['sday'] )))) |
|
5104 | + if ((isset($recur['FREQ']) && ('YEARLY' == $recur['FREQ']) && |
|
5105 | + ($bysetposYold == $wdate['year'])) || |
|
5106 | + (isset($recur['FREQ']) && ('MONTHLY' == $recur['FREQ']) && |
|
5107 | + (($bysetposYold == $wdate['year']) && |
|
5108 | + ($bysetposMold == $wdate['month']))) || |
|
5109 | + (isset($recur['FREQ']) && ('MONTHLY' == $recur['FREQ']) && |
|
5110 | + (($bysetposYold == $wdate['year']) && |
|
5111 | + ($bysetposMold == $wdate['month']) && |
|
5112 | + ($bysetposDold == $wdate['sday'])))) |
|
5113 | 5113 | $bysetposymd1[] = $wdatets; |
5114 | 5114 | else |
5115 | 5115 | $bysetposymd2[] = $wdatets; |
@@ -5118,7 +5118,7 @@ discard block |
||
5118 | 5118 | else { |
5119 | 5119 | /* update result array if BYSETPOS is set */ |
5120 | 5120 | $countcnt++; |
5121 | - if( $startdatets <= $wdatets ) { // only output within period |
|
5121 | + if ($startdatets <= $wdatets) { // only output within period |
|
5122 | 5122 | $result[$wdatets] = TRUE; |
5123 | 5123 | //echo "recur ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test |
5124 | 5124 | } |
@@ -5127,39 +5127,39 @@ discard block |
||
5127 | 5127 | } |
5128 | 5128 | } |
5129 | 5129 | /* step up date */ |
5130 | - $this->_stepdate( $wdate, $wdatets, $step); |
|
5130 | + $this->_stepdate($wdate, $wdatets, $step); |
|
5131 | 5131 | /* check if BYSETPOS is set for updating result array */ |
5132 | - if( $updateOK && isset( $recur['BYSETPOS'] )) { |
|
5132 | + if ($updateOK && isset($recur['BYSETPOS'])) { |
|
5133 | 5133 | $bysetpos = FALSE; |
5134 | - if( isset( $recur['FREQ'] ) && ( 'YEARLY' == $recur['FREQ'] ) && |
|
5135 | - ( $bysetposYold != $wdate['year'] )) { |
|
5134 | + if (isset($recur['FREQ']) && ('YEARLY' == $recur['FREQ']) && |
|
5135 | + ($bysetposYold != $wdate['year'])) { |
|
5136 | 5136 | $bysetpos = TRUE; |
5137 | 5137 | $bysetposYold = $wdate['year']; |
5138 | 5138 | } |
5139 | - elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] && |
|
5140 | - (( $bysetposYold != $wdate['year'] ) || ( $bysetposMold != $wdate['month'] )))) { |
|
5139 | + elseif (isset($recur['FREQ']) && ('MONTHLY' == $recur['FREQ'] && |
|
5140 | + (($bysetposYold != $wdate['year']) || ($bysetposMold != $wdate['month'])))) { |
|
5141 | 5141 | $bysetpos = TRUE; |
5142 | 5142 | $bysetposYold = $wdate['year']; |
5143 | 5143 | $bysetposMold = $wdate['month']; |
5144 | 5144 | } |
5145 | - elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY' == $recur['FREQ'] )) { |
|
5146 | - $weekno = (int) date( 'W', mktime( 0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year'])); |
|
5147 | - if( $bysetposWold != $weekno ) { |
|
5145 | + elseif (isset($recur['FREQ']) && ('WEEKLY' == $recur['FREQ'])) { |
|
5146 | + $weekno = (int) date('W', mktime(0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year'])); |
|
5147 | + if ($bysetposWold != $weekno) { |
|
5148 | 5148 | $bysetposWold = $weekno; |
5149 | 5149 | $bysetpos = TRUE; |
5150 | 5150 | } |
5151 | 5151 | } |
5152 | - elseif( isset( $recur['FREQ'] ) && ( 'DAILY' == $recur['FREQ'] ) && |
|
5153 | - (( $bysetposYold != $wdate['year'] ) || |
|
5154 | - ( $bysetposMold != $wdate['month'] ) || |
|
5155 | - ( $bysetposDold != $wdate['sday'] ))) { |
|
5152 | + elseif (isset($recur['FREQ']) && ('DAILY' == $recur['FREQ']) && |
|
5153 | + (($bysetposYold != $wdate['year']) || |
|
5154 | + ($bysetposMold != $wdate['month']) || |
|
5155 | + ($bysetposDold != $wdate['sday']))) { |
|
5156 | 5156 | $bysetpos = TRUE; |
5157 | 5157 | $bysetposYold = $wdate['year']; |
5158 | 5158 | $bysetposMold = $wdate['month']; |
5159 | 5159 | $bysetposDold = $wdate['day']; |
5160 | 5160 | } |
5161 | - if( $bysetpos ) { |
|
5162 | - if( isset( $recur['BYWEEKNO'] )) { |
|
5161 | + if ($bysetpos) { |
|
5162 | + if (isset($recur['BYWEEKNO'])) { |
|
5163 | 5163 | $bysetposarr1 = & $bysetposw1; |
5164 | 5164 | $bysetposarr2 = & $bysetposw2; |
5165 | 5165 | } |
@@ -5167,18 +5167,18 @@ discard block |
||
5167 | 5167 | $bysetposarr1 = & $bysetposymd1; |
5168 | 5168 | $bysetposarr2 = & $bysetposymd2; |
5169 | 5169 | } |
5170 | - foreach( $recur['BYSETPOS'] as $ix ) { |
|
5171 | - if( 0 > $ix ) // both positive and negative BYSETPOS allowed |
|
5172 | - $ix = ( count( $bysetposarr1 ) + $ix + 1); |
|
5170 | + foreach ($recur['BYSETPOS'] as $ix) { |
|
5171 | + if (0 > $ix) // both positive and negative BYSETPOS allowed |
|
5172 | + $ix = (count($bysetposarr1) + $ix + 1); |
|
5173 | 5173 | $ix--; |
5174 | - if( isset( $bysetposarr1[$ix] )) { |
|
5175 | - if( $startdatets <= $bysetposarr1[$ix] ) { // only output within period |
|
5174 | + if (isset($bysetposarr1[$ix])) { |
|
5175 | + if ($startdatets <= $bysetposarr1[$ix]) { // only output within period |
|
5176 | 5176 | $result[$bysetposarr1[$ix]] = TRUE; |
5177 | 5177 | //echo "recur ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$bysetposarr1[$ix]),6))."<br />\n";//test |
5178 | 5178 | } |
5179 | 5179 | $countcnt++; |
5180 | 5180 | } |
5181 | - if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) |
|
5181 | + if (isset($recur['COUNT']) && ($countcnt >= $recur['COUNT'])) |
|
5182 | 5182 | break; |
5183 | 5183 | } |
5184 | 5184 | $bysetposarr1 = $bysetposarr2; |
@@ -5187,18 +5187,18 @@ discard block |
||
5187 | 5187 | } |
5188 | 5188 | } |
5189 | 5189 | } |
5190 | - function _recurBYcntcheck( $BYvalue, $upValue, $downValue ) { |
|
5191 | - if( is_array( $BYvalue ) && |
|
5192 | - ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue ))) |
|
5190 | + function _recurBYcntcheck($BYvalue, $upValue, $downValue) { |
|
5191 | + if (is_array($BYvalue) && |
|
5192 | + (in_array($upValue, $BYvalue) || in_array($downValue, $BYvalue))) |
|
5193 | 5193 | return TRUE; |
5194 | - elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue )) |
|
5194 | + elseif (($BYvalue == $upValue) || ($BYvalue == $downValue)) |
|
5195 | 5195 | return TRUE; |
5196 | 5196 | else |
5197 | 5197 | return FALSE; |
5198 | 5198 | } |
5199 | - function _recurIntervalIx( $freq, $date, $wkst ) { |
|
5199 | + function _recurIntervalIx($freq, $date, $wkst) { |
|
5200 | 5200 | /* create interval index */ |
5201 | - switch( $freq ) { |
|
5201 | + switch ($freq) { |
|
5202 | 5202 | case 'YEARLY': |
5203 | 5203 | $intervalix = $date['year']; |
5204 | 5204 | break; |
@@ -5206,8 +5206,8 @@ discard block |
||
5206 | 5206 | $intervalix = $date['year'].'-'.$date['month']; |
5207 | 5207 | break; |
5208 | 5208 | case 'WEEKLY': |
5209 | - $wdatets = $this->_date2timestamp( $date ); |
|
5210 | - $intervalix = (int) date( 'W', ( $wdatets + $wkst )); |
|
5209 | + $wdatets = $this->_date2timestamp($date); |
|
5210 | + $intervalix = (int) date('W', ($wdatets + $wkst)); |
|
5211 | 5211 | break; |
5212 | 5212 | case 'DAILY': |
5213 | 5213 | default: |
@@ -5224,22 +5224,22 @@ discard block |
||
5224 | 5224 | * @param array $rexrule |
5225 | 5225 | * @return array |
5226 | 5226 | */ |
5227 | - function _setRexrule( $rexrule ) { |
|
5228 | - $input = array(); |
|
5229 | - if( empty( $rexrule )) |
|
5227 | + function _setRexrule($rexrule) { |
|
5228 | + $input = array(); |
|
5229 | + if (empty($rexrule)) |
|
5230 | 5230 | return $input; |
5231 | - foreach( $rexrule as $rexrulelabel => $rexrulevalue ) { |
|
5232 | - $rexrulelabel = strtoupper( $rexrulelabel ); |
|
5233 | - if( 'UNTIL' != $rexrulelabel ) |
|
5231 | + foreach ($rexrule as $rexrulelabel => $rexrulevalue) { |
|
5232 | + $rexrulelabel = strtoupper($rexrulelabel); |
|
5233 | + if ('UNTIL' != $rexrulelabel) |
|
5234 | 5234 | $input[$rexrulelabel] = $rexrulevalue; |
5235 | 5235 | else { |
5236 | - if( $this->_isArrayTimestampDate( $rexrulevalue )) // timestamp date |
|
5237 | - $input[$rexrulelabel] = $this->_timestamp2date( $rexrulevalue, 6 ); |
|
5238 | - elseif( $this->_isArrayDate( $rexrulevalue )) // date-time |
|
5239 | - $input[$rexrulelabel] = $this->_date_time_array( $rexrulevalue, 6 ); |
|
5240 | - elseif( 8 <= strlen( trim( $rexrulevalue ))) // ex. 2006-08-03 10:12:18 |
|
5241 | - $input[$rexrulelabel] = $this->_date_time_string( $rexrulevalue ); |
|
5242 | - if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] )) |
|
5236 | + if ($this->_isArrayTimestampDate($rexrulevalue)) // timestamp date |
|
5237 | + $input[$rexrulelabel] = $this->_timestamp2date($rexrulevalue, 6); |
|
5238 | + elseif ($this->_isArrayDate($rexrulevalue)) // date-time |
|
5239 | + $input[$rexrulelabel] = $this->_date_time_array($rexrulevalue, 6); |
|
5240 | + elseif (8 <= strlen(trim($rexrulevalue))) // ex. 2006-08-03 10:12:18 |
|
5241 | + $input[$rexrulelabel] = $this->_date_time_string($rexrulevalue); |
|
5242 | + if ((3 < count($input[$rexrulelabel])) && !isset($input[$rexrulelabel]['tz'])) |
|
5243 | 5243 | $input[$rexrulelabel]['tz'] = 'Z'; |
5244 | 5244 | } |
5245 | 5245 | } |
@@ -5260,85 +5260,85 @@ discard block |
||
5260 | 5260 | * @param string $caller optional |
5261 | 5261 | * @return array |
5262 | 5262 | */ |
5263 | - function _setDate( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE, $caller=null ) { |
|
5263 | + function _setDate($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE, $caller = null) { |
|
5264 | 5264 | $input = $parno = null; |
5265 | - $localtime = (( 'dtstart' == $caller ) && in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE; |
|
5266 | - if( $this->_isArrayDate( $year )) { |
|
5267 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5268 | - $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
|
5269 | - if( isset( $input['params']['TZID'] )) { |
|
5265 | + $localtime = (('dtstart' == $caller) && in_array($this->objName, array('vtimezone', 'standard', 'daylight'))) ? TRUE : FALSE; |
|
5266 | + if ($this->_isArrayDate($year)) { |
|
5267 | + if ($localtime) unset ($month['VALUE'], $month['TZID']); |
|
5268 | + $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME')); |
|
5269 | + if (isset($input['params']['TZID'])) { |
|
5270 | 5270 | $input['params']['VALUE'] = 'DATE-TIME'; |
5271 | - unset( $year['tz'] ); |
|
5271 | + unset($year['tz']); |
|
5272 | 5272 | } |
5273 | - $hitval = (( !empty( $year['tz'] ) || !empty( $year[6] ))) ? 7 : 6; |
|
5274 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval ); |
|
5275 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, count( $year ), $parno ); |
|
5276 | - $input['value'] = $this->_date_time_array( $year, $parno ); |
|
5277 | - } |
|
5278 | - elseif( $this->_isArrayTimestampDate( $year )) { |
|
5279 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5280 | - $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
|
5281 | - if( isset( $input['params']['TZID'] )) { |
|
5273 | + $hitval = ((!empty($year['tz']) || !empty($year[6]))) ? 7 : 6; |
|
5274 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', $hitval); |
|
5275 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE', 3, count($year), $parno); |
|
5276 | + $input['value'] = $this->_date_time_array($year, $parno); |
|
5277 | + } |
|
5278 | + elseif ($this->_isArrayTimestampDate($year)) { |
|
5279 | + if ($localtime) unset ($month['VALUE'], $month['TZID']); |
|
5280 | + $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME')); |
|
5281 | + if (isset($input['params']['TZID'])) { |
|
5282 | 5282 | $input['params']['VALUE'] = 'DATE-TIME'; |
5283 | - unset( $year['tz'] ); |
|
5283 | + unset($year['tz']); |
|
5284 | 5284 | } |
5285 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3 ); |
|
5286 | - $hitval = ( isset( $year['tz'] )) ? 7 : 6; |
|
5287 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno ); |
|
5288 | - $input['value'] = $this->_timestamp2date( $year, $parno ); |
|
5289 | - } |
|
5290 | - elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
5291 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5292 | - $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
|
5293 | - if( isset( $input['params']['TZID'] )) { |
|
5285 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE', 3); |
|
5286 | + $hitval = (isset($year['tz'])) ? 7 : 6; |
|
5287 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno); |
|
5288 | + $input['value'] = $this->_timestamp2date($year, $parno); |
|
5289 | + } |
|
5290 | + elseif (8 <= strlen(trim($year))) { // ex. 2006-08-03 10:12:18 |
|
5291 | + if ($localtime) unset ($month['VALUE'], $month['TZID']); |
|
5292 | + $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME')); |
|
5293 | + if (isset($input['params']['TZID'])) { |
|
5294 | 5294 | $input['params']['VALUE'] = 'DATE-TIME'; |
5295 | 5295 | $parno = 6; |
5296 | 5296 | } |
5297 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7, $parno ); |
|
5298 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, $parno, $parno ); |
|
5299 | - $input['value'] = $this->_date_time_string( $year, $parno ); |
|
5297 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', 7, $parno); |
|
5298 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE', 3, $parno, $parno); |
|
5299 | + $input['value'] = $this->_date_time_string($year, $parno); |
|
5300 | 5300 | } |
5301 | 5301 | else { |
5302 | - if( is_array( $params )) { |
|
5303 | - if( $localtime ) unset ( $params['VALUE'], $params['TZID'] ); |
|
5304 | - $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )); |
|
5302 | + if (is_array($params)) { |
|
5303 | + if ($localtime) unset ($params['VALUE'], $params['TZID']); |
|
5304 | + $input['params'] = $this->_setParams($params, array('VALUE' => 'DATE-TIME')); |
|
5305 | 5305 | } |
5306 | - elseif( is_array( $tz )) { |
|
5307 | - $input['params'] = $this->_setParams( $tz, array( 'VALUE' => 'DATE-TIME' )); |
|
5306 | + elseif (is_array($tz)) { |
|
5307 | + $input['params'] = $this->_setParams($tz, array('VALUE' => 'DATE-TIME')); |
|
5308 | 5308 | $tz = FALSE; |
5309 | 5309 | } |
5310 | - elseif( is_array( $hour )) { |
|
5311 | - $input['params'] = $this->_setParams( $hour, array( 'VALUE' => 'DATE-TIME' )); |
|
5310 | + elseif (is_array($hour)) { |
|
5311 | + $input['params'] = $this->_setParams($hour, array('VALUE' => 'DATE-TIME')); |
|
5312 | 5312 | $hour = $min = $sec = $tz = FALSE; |
5313 | 5313 | } |
5314 | - if( isset( $input['params']['TZID'] )) { |
|
5314 | + if (isset($input['params']['TZID'])) { |
|
5315 | 5315 | $tz = null; |
5316 | 5316 | $input['params']['VALUE'] = 'DATE-TIME'; |
5317 | 5317 | } |
5318 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3 ); |
|
5319 | - $hitval = ( !empty( $tz )) ? 7 : 6; |
|
5320 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno, $parno ); |
|
5321 | - $input['value'] = array( 'year' => $year, 'month' => $month, 'day' => $day ); |
|
5322 | - if( 3 != $parno ) { |
|
5323 | - $input['value']['hour'] = ( $hour ) ? $hour : '0'; |
|
5324 | - $input['value']['min'] = ( $min ) ? $min : '0'; |
|
5325 | - $input['value']['sec'] = ( $sec ) ? $sec : '0'; |
|
5326 | - if( !empty( $tz )) |
|
5318 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE', 3); |
|
5319 | + $hitval = (!empty($tz)) ? 7 : 6; |
|
5320 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno, $parno); |
|
5321 | + $input['value'] = array('year' => $year, 'month' => $month, 'day' => $day); |
|
5322 | + if (3 != $parno) { |
|
5323 | + $input['value']['hour'] = ($hour) ? $hour : '0'; |
|
5324 | + $input['value']['min'] = ($min) ? $min : '0'; |
|
5325 | + $input['value']['sec'] = ($sec) ? $sec : '0'; |
|
5326 | + if (!empty($tz)) |
|
5327 | 5327 | $input['value']['tz'] = $tz; |
5328 | 5328 | } |
5329 | 5329 | } |
5330 | - if( 3 == $parno ) { |
|
5330 | + if (3 == $parno) { |
|
5331 | 5331 | $input['params']['VALUE'] = 'DATE'; |
5332 | - unset( $input['value']['tz'] ); |
|
5333 | - unset( $input['params']['TZID'] ); |
|
5332 | + unset($input['value']['tz']); |
|
5333 | + unset($input['params']['TZID']); |
|
5334 | 5334 | } |
5335 | - elseif( isset( $input['params']['TZID'] )) |
|
5336 | - unset( $input['value']['tz'] ); |
|
5337 | - if( $localtime ) unset( $input['value']['tz'], $input['params']['TZID'] ); |
|
5338 | - if( isset( $input['value']['tz'] )) |
|
5335 | + elseif (isset($input['params']['TZID'])) |
|
5336 | + unset($input['value']['tz']); |
|
5337 | + if ($localtime) unset($input['value']['tz'], $input['params']['TZID']); |
|
5338 | + if (isset($input['value']['tz'])) |
|
5339 | 5339 | $input['value']['tz'] = (string) $input['value']['tz']; |
5340 | - if( !empty( $input['value']['tz'] ) && ( 'Z' != $input['value']['tz'] ) && |
|
5341 | - ( !$this->_isOffset( $input['value']['tz'] ))) |
|
5340 | + if (!empty($input['value']['tz']) && ('Z' != $input['value']['tz']) && |
|
5341 | + (!$this->_isOffset($input['value']['tz']))) |
|
5342 | 5342 | $input['params']['TZID'] = $input['value']['tz']; |
5343 | 5343 | return $input; |
5344 | 5344 | } |
@@ -5356,37 +5356,37 @@ discard block |
||
5356 | 5356 | * @param array $params optional |
5357 | 5357 | * @return array |
5358 | 5358 | */ |
5359 | - function _setDate2( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
|
5359 | + function _setDate2($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) { |
|
5360 | 5360 | $input = null; |
5361 | - if( $this->_isArrayDate( $year )) { |
|
5362 | - $input['value'] = $this->_date_time_array( $year, 7 ); |
|
5363 | - $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
|
5361 | + if ($this->_isArrayDate($year)) { |
|
5362 | + $input['value'] = $this->_date_time_array($year, 7); |
|
5363 | + $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME')); |
|
5364 | 5364 | } |
5365 | - elseif( $this->_isArrayTimestampDate( $year )) { |
|
5366 | - $input['value'] = $this->_timestamp2date( $year, 7 ); |
|
5367 | - $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
|
5365 | + elseif ($this->_isArrayTimestampDate($year)) { |
|
5366 | + $input['value'] = $this->_timestamp2date($year, 7); |
|
5367 | + $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME')); |
|
5368 | 5368 | } |
5369 | - elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
5370 | - $input['value'] = $this->_date_time_string( $year, 7 ); |
|
5371 | - $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
|
5369 | + elseif (8 <= strlen(trim($year))) { // ex. 2006-08-03 10:12:18 |
|
5370 | + $input['value'] = $this->_date_time_string($year, 7); |
|
5371 | + $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME')); |
|
5372 | 5372 | } |
5373 | 5373 | else { |
5374 | - $input['value'] = array( 'year' => $year |
|
5374 | + $input['value'] = array('year' => $year |
|
5375 | 5375 | , 'month' => $month |
5376 | 5376 | , 'day' => $day |
5377 | 5377 | , 'hour' => $hour |
5378 | 5378 | , 'min' => $min |
5379 | - , 'sec' => $sec ); |
|
5380 | - $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )); |
|
5379 | + , 'sec' => $sec); |
|
5380 | + $input['params'] = $this->_setParams($params, array('VALUE' => 'DATE-TIME')); |
|
5381 | 5381 | } |
5382 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7 ); // remove default |
|
5383 | - if( !isset( $input['value']['hour'] )) |
|
5382 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', 7); // remove default |
|
5383 | + if (!isset($input['value']['hour'])) |
|
5384 | 5384 | $input['value']['hour'] = 0; |
5385 | - if( !isset( $input['value']['min'] )) |
|
5385 | + if (!isset($input['value']['min'])) |
|
5386 | 5386 | $input['value']['min'] = 0; |
5387 | - if( !isset( $input['value']['sec'] )) |
|
5387 | + if (!isset($input['value']['sec'])) |
|
5388 | 5388 | $input['value']['sec'] = 0; |
5389 | - if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] )) |
|
5389 | + if (!isset($input['value']['tz']) || !$this->_isOffset($input['value']['tz'])) |
|
5390 | 5390 | $input['value']['tz'] = 'Z'; |
5391 | 5391 | return $input; |
5392 | 5392 | } |
@@ -5402,18 +5402,18 @@ discard block |
||
5402 | 5402 | * @param int $index |
5403 | 5403 | * @return void |
5404 | 5404 | */ |
5405 | - function _setMval( & $valArr, $value, $params=FALSE, $defaults=FALSE, $index=FALSE ) { |
|
5406 | - if( !is_array( $valArr )) $valArr = array(); |
|
5407 | - if( $index ) |
|
5405 | + function _setMval(& $valArr, $value, $params = FALSE, $defaults = FALSE, $index = FALSE) { |
|
5406 | + if (!is_array($valArr)) $valArr = array(); |
|
5407 | + if ($index) |
|
5408 | 5408 | $index = $index - 1; |
5409 | - elseif( 0 < count( $valArr )) { |
|
5410 | - $index = end( array_keys( $valArr )); |
|
5409 | + elseif (0 < count($valArr)) { |
|
5410 | + $index = end(array_keys($valArr)); |
|
5411 | 5411 | $index += 1; |
5412 | 5412 | } |
5413 | 5413 | else |
5414 | 5414 | $index = 0; |
5415 | - $valArr[$index] = array( 'value' => $value, 'params' => $this->_setParams( $params, $defaults )); |
|
5416 | - ksort( $valArr ); |
|
5415 | + $valArr[$index] = array('value' => $value, 'params' => $this->_setParams($params, $defaults)); |
|
5416 | + ksort($valArr); |
|
5417 | 5417 | } |
5418 | 5418 | /** |
5419 | 5419 | * set input (formatted) parameters- component property attributes |
@@ -5426,31 +5426,31 @@ discard block |
||
5426 | 5426 | * @param array $defaults |
5427 | 5427 | * @return array |
5428 | 5428 | */ |
5429 | - function _setParams( $params, $defaults=FALSE ) { |
|
5430 | - if( !is_array( $params)) |
|
5429 | + function _setParams($params, $defaults = FALSE) { |
|
5430 | + if (!is_array($params)) |
|
5431 | 5431 | $params = array(); |
5432 | 5432 | $input = array(); |
5433 | - foreach( $params as $paramKey => $paramValue ) { |
|
5434 | - if( is_array( $paramValue )) { |
|
5435 | - foreach( $paramValue as $pkey => $pValue ) { |
|
5436 | - if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 ))) |
|
5437 | - $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 )); |
|
5433 | + foreach ($params as $paramKey => $paramValue) { |
|
5434 | + if (is_array($paramValue)) { |
|
5435 | + foreach ($paramValue as $pkey => $pValue) { |
|
5436 | + if (('"' == substr($pValue, 0, 1)) && ('"' == substr($pValue, -1))) |
|
5437 | + $paramValue[$pkey] = substr($pValue, 1, (strlen($pValue) - 2)); |
|
5438 | 5438 | } |
5439 | 5439 | } |
5440 | - elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 ))) |
|
5441 | - $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 )); |
|
5442 | - if( 'VALUE' == strtoupper( $paramKey )) |
|
5443 | - $input['VALUE'] = strtoupper( $paramValue ); |
|
5440 | + elseif (('"' == substr($paramValue, 0, 1)) && ('"' == substr($paramValue, -1))) |
|
5441 | + $paramValue = substr($paramValue, 1, (strlen($paramValue) - 2)); |
|
5442 | + if ('VALUE' == strtoupper($paramKey)) |
|
5443 | + $input['VALUE'] = strtoupper($paramValue); |
|
5444 | 5444 | else |
5445 | - $input[strtoupper( $paramKey )] = $paramValue; |
|
5445 | + $input[strtoupper($paramKey)] = $paramValue; |
|
5446 | 5446 | } |
5447 | - if( is_array( $defaults )) { |
|
5448 | - foreach( $defaults as $paramKey => $paramValue ) { |
|
5449 | - if( !isset( $input[$paramKey] )) |
|
5447 | + if (is_array($defaults)) { |
|
5448 | + foreach ($defaults as $paramKey => $paramValue) { |
|
5449 | + if (!isset($input[$paramKey])) |
|
5450 | 5450 | $input[$paramKey] = $paramValue; |
5451 | 5451 | } |
5452 | 5452 | } |
5453 | - return (0 < count( $input )) ? $input : null; |
|
5453 | + return (0 < count($input)) ? $input : null; |
|
5454 | 5454 | } |
5455 | 5455 | /** |
5456 | 5456 | * step date, return updated date, array and timpstamp |
@@ -5462,13 +5462,13 @@ discard block |
||
5462 | 5462 | * @param array $step, default array( 'day' => 1 ) |
5463 | 5463 | * @return void |
5464 | 5464 | */ |
5465 | - function _stepdate( &$date, &$timestamp, $step=array( 'day' => 1 )) { |
|
5466 | - foreach( $step as $stepix => $stepvalue ) |
|
5465 | + function _stepdate(&$date, &$timestamp, $step = array('day' => 1)) { |
|
5466 | + foreach ($step as $stepix => $stepvalue) |
|
5467 | 5467 | $date[$stepix] += $stepvalue; |
5468 | - $timestamp = $this->_date2timestamp( $date ); |
|
5469 | - $date = $this->_timestamp2date( $timestamp, 6 ); |
|
5470 | - foreach( $date as $k => $v ) { |
|
5471 | - if( ctype_digit( $v )) |
|
5468 | + $timestamp = $this->_date2timestamp($date); |
|
5469 | + $date = $this->_timestamp2date($timestamp, 6); |
|
5470 | + foreach ($date as $k => $v) { |
|
5471 | + if (ctype_digit($v)) |
|
5472 | 5472 | $date[$k] = (int) $v; |
5473 | 5473 | } |
5474 | 5474 | } |
@@ -5481,20 +5481,20 @@ discard block |
||
5481 | 5481 | * @param int $parno |
5482 | 5482 | * @return array |
5483 | 5483 | */ |
5484 | - function _timestamp2date( $timestamp, $parno=6 ) { |
|
5485 | - if( is_array( $timestamp )) { |
|
5486 | - if(( 7 == $parno ) && !empty( $timestamp['tz'] )) |
|
5484 | + function _timestamp2date($timestamp, $parno = 6) { |
|
5485 | + if (is_array($timestamp)) { |
|
5486 | + if ((7 == $parno) && !empty($timestamp['tz'])) |
|
5487 | 5487 | $tz = $timestamp['tz']; |
5488 | 5488 | $timestamp = $timestamp['timestamp']; |
5489 | 5489 | } |
5490 | - $output = array( 'year' => date( 'Y', $timestamp ) |
|
5491 | - , 'month' => date( 'm', $timestamp ) |
|
5492 | - , 'day' => date( 'd', $timestamp )); |
|
5493 | - if( 3 != $parno ) { |
|
5494 | - $output['hour'] = date( 'H', $timestamp ); |
|
5495 | - $output['min'] = date( 'i', $timestamp ); |
|
5496 | - $output['sec'] = date( 's', $timestamp ); |
|
5497 | - if( isset( $tz )) |
|
5490 | + $output = array('year' => date('Y', $timestamp) |
|
5491 | + , 'month' => date('m', $timestamp) |
|
5492 | + , 'day' => date('d', $timestamp)); |
|
5493 | + if (3 != $parno) { |
|
5494 | + $output['hour'] = date('H', $timestamp); |
|
5495 | + $output['min'] = date('i', $timestamp); |
|
5496 | + $output['sec'] = date('s', $timestamp); |
|
5497 | + if (isset($tz)) |
|
5498 | 5498 | $output['tz'] = $tz; |
5499 | 5499 | } |
5500 | 5500 | return $output; |
@@ -5507,19 +5507,19 @@ discard block |
||
5507 | 5507 | * @param string $offset |
5508 | 5508 | * @return integer |
5509 | 5509 | */ |
5510 | - function _tz2offset( $tz ) { |
|
5511 | - $tz = trim( (string) $tz ); |
|
5510 | + function _tz2offset($tz) { |
|
5511 | + $tz = trim((string) $tz); |
|
5512 | 5512 | $offset = 0; |
5513 | - if((( 5 != strlen( $tz )) && ( 7 != strlen( $tz ))) || |
|
5514 | - (( '+' != substr( $tz, 0, 1 )) && ( '-' != substr( $tz, 0, 1 ))) || |
|
5515 | - (( '0000' >= substr( $tz, 1, 4 )) && ( '9999' < substr( $tz, 1, 4 ))) || |
|
5516 | - (( 7 == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 )))) |
|
5513 | + if (((5 != strlen($tz)) && (7 != strlen($tz))) || |
|
5514 | + (('+' != substr($tz, 0, 1)) && ('-' != substr($tz, 0, 1))) || |
|
5515 | + (('0000' >= substr($tz, 1, 4)) && ('9999' < substr($tz, 1, 4))) || |
|
5516 | + ((7 == strlen($tz)) && ('00' > substr($tz, 5, 2)) && ('99' < substr($tz, 5, 2)))) |
|
5517 | 5517 | return $offset; |
5518 | - $hours2sec = (int) substr( $tz, 1, 2 ) * 3600; |
|
5519 | - $min2sec = (int) substr( $tz, 3, 2 ) * 60; |
|
5520 | - $sec = ( 7 == strlen( $tz )) ? (int) substr( $tz, -2 ) : '00'; |
|
5518 | + $hours2sec = (int) substr($tz, 1, 2) * 3600; |
|
5519 | + $min2sec = (int) substr($tz, 3, 2) * 60; |
|
5520 | + $sec = (7 == strlen($tz)) ? (int) substr($tz, -2) : '00'; |
|
5521 | 5521 | $offset = $hours2sec + $min2sec + $sec; |
5522 | - $offset = ('-' == substr( $tz, 0, 1 )) ? $offset : -1 * $offset; |
|
5522 | + $offset = ('-' == substr($tz, 0, 1)) ? $offset : -1 * $offset; |
|
5523 | 5523 | return $offset; |
5524 | 5524 | } |
5525 | 5525 | /*********************************************************************************/ |
@@ -5532,24 +5532,24 @@ discard block |
||
5532 | 5532 | * @param string $config |
5533 | 5533 | * @return value |
5534 | 5534 | */ |
5535 | - function getConfig( $config ) { |
|
5536 | - switch( strtoupper( $config )) { |
|
5535 | + function getConfig($config) { |
|
5536 | + switch (strtoupper($config)) { |
|
5537 | 5537 | case 'ALLOWEMPTY': |
5538 | 5538 | return $this->allowEmpty; |
5539 | 5539 | break; |
5540 | 5540 | case 'COMPSINFO': |
5541 | - unset( $this->compix ); |
|
5541 | + unset($this->compix); |
|
5542 | 5542 | $info = array(); |
5543 | - if( isset( $this->components )) { |
|
5544 | - foreach( $this->components as $cix => $component ) { |
|
5545 | - if( empty( $component )) continue; |
|
5546 | - unset( $component->propix ); |
|
5543 | + if (isset($this->components)) { |
|
5544 | + foreach ($this->components as $cix => $component) { |
|
5545 | + if (empty($component)) continue; |
|
5546 | + unset($component->propix); |
|
5547 | 5547 | $info[$cix]['ordno'] = $cix + 1; |
5548 | 5548 | $info[$cix]['type'] = $component->objName; |
5549 | - $info[$cix]['uid'] = $component->getProperty( 'uid' ); |
|
5550 | - $info[$cix]['props'] = $component->getConfig( 'propinfo' ); |
|
5551 | - $info[$cix]['sub'] = $component->getConfig( 'compsinfo' ); |
|
5552 | - unset( $component->propix ); |
|
5549 | + $info[$cix]['uid'] = $component->getProperty('uid'); |
|
5550 | + $info[$cix]['props'] = $component->getConfig('propinfo'); |
|
5551 | + $info[$cix]['sub'] = $component->getConfig('compsinfo'); |
|
5552 | + unset($component->propix); |
|
5553 | 5553 | } |
5554 | 5554 | } |
5555 | 5555 | return $info; |
@@ -5567,58 +5567,58 @@ discard block |
||
5567 | 5567 | break; |
5568 | 5568 | case 'PROPINFO': |
5569 | 5569 | $output = array(); |
5570 | - if( !in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
5571 | - if( empty( $this->uid['value'] )) $this->_makeuid(); |
|
5570 | + if (!in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) { |
|
5571 | + if (empty($this->uid['value'])) $this->_makeuid(); |
|
5572 | 5572 | $output['UID'] = 1; |
5573 | 5573 | } |
5574 | - if( !empty( $this->dtstamp )) $output['DTSTAMP'] = 1; |
|
5575 | - if( !empty( $this->summary )) $output['SUMMARY'] = 1; |
|
5576 | - if( !empty( $this->description )) $output['DESCRIPTION'] = count( $this->description ); |
|
5577 | - if( !empty( $this->dtstart )) $output['DTSTART'] = 1; |
|
5578 | - if( !empty( $this->dtend )) $output['DTEND'] = 1; |
|
5579 | - if( !empty( $this->due )) $output['DUE'] = 1; |
|
5580 | - if( !empty( $this->duration )) $output['DURATION'] = 1; |
|
5581 | - if( !empty( $this->rrule )) $output['RRULE'] = count( $this->rrule ); |
|
5582 | - if( !empty( $this->rdate )) $output['RDATE'] = count( $this->rdate ); |
|
5583 | - if( !empty( $this->exdate )) $output['EXDATE'] = count( $this->exdate ); |
|
5584 | - if( !empty( $this->exrule )) $output['EXRULE'] = count( $this->exrule ); |
|
5585 | - if( !empty( $this->action )) $output['ACTION'] = 1; |
|
5586 | - if( !empty( $this->attach )) $output['ATTACH'] = count( $this->attach ); |
|
5587 | - if( !empty( $this->attendee )) $output['ATTENDEE'] = count( $this->attendee ); |
|
5588 | - if( !empty( $this->categories )) $output['CATEGORIES'] = count( $this->categories ); |
|
5589 | - if( !empty( $this->class )) $output['CLASS'] = 1; |
|
5590 | - if( !empty( $this->comment )) $output['COMMENT'] = count( $this->comment ); |
|
5591 | - if( !empty( $this->completed )) $output['COMPLETED'] = 1; |
|
5592 | - if( !empty( $this->contact )) $output['CONTACT'] = count( $this->contact ); |
|
5593 | - if( !empty( $this->created )) $output['CREATED'] = 1; |
|
5594 | - if( !empty( $this->freebusy )) $output['FREEBUSY'] = count( $this->freebusy ); |
|
5595 | - if( !empty( $this->geo )) $output['GEO'] = 1; |
|
5596 | - if( !empty( $this->lastmodified )) $output['LAST-MODIFIED'] = 1; |
|
5597 | - if( !empty( $this->location )) $output['LOCATION'] = 1; |
|
5598 | - if( !empty( $this->organizer )) $output['ORGANIZER'] = 1; |
|
5599 | - if( !empty( $this->percentcomplete )) $output['PERCENT-COMPLETE'] = 1; |
|
5600 | - if( !empty( $this->priority )) $output['PRIORITY'] = 1; |
|
5601 | - if( !empty( $this->recurrenceid )) $output['RECURRENCE-ID'] = 1; |
|
5602 | - if( !empty( $this->relatedto )) $output['RELATED-TO'] = count( $this->relatedto ); |
|
5603 | - if( !empty( $this->repeat )) $output['REPEAT'] = 1; |
|
5604 | - if( !empty( $this->requeststatus )) $output['REQUEST-STATUS'] = count( $this->requeststatus ); |
|
5605 | - if( !empty( $this->resources )) $output['RESOURCES'] = count( $this->resources ); |
|
5606 | - if( !empty( $this->sequence )) $output['SEQUENCE'] = 1; |
|
5607 | - if( !empty( $this->status )) $output['STATUS'] = 1; |
|
5608 | - if( !empty( $this->transp )) $output['TRANSP'] = 1; |
|
5609 | - if( !empty( $this->trigger )) $output['TRIGGER'] = 1; |
|
5610 | - if( !empty( $this->tzid )) $output['TZID'] = 1; |
|
5611 | - if( !empty( $this->tzname )) $output['TZNAME'] = count( $this->tzname ); |
|
5612 | - if( !empty( $this->tzoffsetfrom )) $output['TZOFFSETTFROM'] = 1; |
|
5613 | - if( !empty( $this->tzoffsetto )) $output['TZOFFSETTO'] = 1; |
|
5614 | - if( !empty( $this->tzurl )) $output['TZURL'] = 1; |
|
5615 | - if( !empty( $this->url )) $output['URL'] = 1; |
|
5616 | - if( !empty( $this->xprop )) $output['X-PROP'] = count( $this->xprop ); |
|
5574 | + if (!empty($this->dtstamp)) $output['DTSTAMP'] = 1; |
|
5575 | + if (!empty($this->summary)) $output['SUMMARY'] = 1; |
|
5576 | + if (!empty($this->description)) $output['DESCRIPTION'] = count($this->description); |
|
5577 | + if (!empty($this->dtstart)) $output['DTSTART'] = 1; |
|
5578 | + if (!empty($this->dtend)) $output['DTEND'] = 1; |
|
5579 | + if (!empty($this->due)) $output['DUE'] = 1; |
|
5580 | + if (!empty($this->duration)) $output['DURATION'] = 1; |
|
5581 | + if (!empty($this->rrule)) $output['RRULE'] = count($this->rrule); |
|
5582 | + if (!empty($this->rdate)) $output['RDATE'] = count($this->rdate); |
|
5583 | + if (!empty($this->exdate)) $output['EXDATE'] = count($this->exdate); |
|
5584 | + if (!empty($this->exrule)) $output['EXRULE'] = count($this->exrule); |
|
5585 | + if (!empty($this->action)) $output['ACTION'] = 1; |
|
5586 | + if (!empty($this->attach)) $output['ATTACH'] = count($this->attach); |
|
5587 | + if (!empty($this->attendee)) $output['ATTENDEE'] = count($this->attendee); |
|
5588 | + if (!empty($this->categories)) $output['CATEGORIES'] = count($this->categories); |
|
5589 | + if (!empty($this->class)) $output['CLASS'] = 1; |
|
5590 | + if (!empty($this->comment)) $output['COMMENT'] = count($this->comment); |
|
5591 | + if (!empty($this->completed)) $output['COMPLETED'] = 1; |
|
5592 | + if (!empty($this->contact)) $output['CONTACT'] = count($this->contact); |
|
5593 | + if (!empty($this->created)) $output['CREATED'] = 1; |
|
5594 | + if (!empty($this->freebusy)) $output['FREEBUSY'] = count($this->freebusy); |
|
5595 | + if (!empty($this->geo)) $output['GEO'] = 1; |
|
5596 | + if (!empty($this->lastmodified)) $output['LAST-MODIFIED'] = 1; |
|
5597 | + if (!empty($this->location)) $output['LOCATION'] = 1; |
|
5598 | + if (!empty($this->organizer)) $output['ORGANIZER'] = 1; |
|
5599 | + if (!empty($this->percentcomplete)) $output['PERCENT-COMPLETE'] = 1; |
|
5600 | + if (!empty($this->priority)) $output['PRIORITY'] = 1; |
|
5601 | + if (!empty($this->recurrenceid)) $output['RECURRENCE-ID'] = 1; |
|
5602 | + if (!empty($this->relatedto)) $output['RELATED-TO'] = count($this->relatedto); |
|
5603 | + if (!empty($this->repeat)) $output['REPEAT'] = 1; |
|
5604 | + if (!empty($this->requeststatus)) $output['REQUEST-STATUS'] = count($this->requeststatus); |
|
5605 | + if (!empty($this->resources)) $output['RESOURCES'] = count($this->resources); |
|
5606 | + if (!empty($this->sequence)) $output['SEQUENCE'] = 1; |
|
5607 | + if (!empty($this->status)) $output['STATUS'] = 1; |
|
5608 | + if (!empty($this->transp)) $output['TRANSP'] = 1; |
|
5609 | + if (!empty($this->trigger)) $output['TRIGGER'] = 1; |
|
5610 | + if (!empty($this->tzid)) $output['TZID'] = 1; |
|
5611 | + if (!empty($this->tzname)) $output['TZNAME'] = count($this->tzname); |
|
5612 | + if (!empty($this->tzoffsetfrom)) $output['TZOFFSETTFROM'] = 1; |
|
5613 | + if (!empty($this->tzoffsetto)) $output['TZOFFSETTO'] = 1; |
|
5614 | + if (!empty($this->tzurl)) $output['TZURL'] = 1; |
|
5615 | + if (!empty($this->url)) $output['URL'] = 1; |
|
5616 | + if (!empty($this->xprop)) $output['X-PROP'] = count($this->xprop); |
|
5617 | 5617 | return $output; |
5618 | 5618 | break; |
5619 | 5619 | case 'UNIQUE_ID': |
5620 | - if( empty( $this->unique_id )) |
|
5621 | - $this->unique_id = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost'; |
|
5620 | + if (empty($this->unique_id)) |
|
5621 | + $this->unique_id = (isset($_SERVER['SERVER_NAME'])) ? gethostbyname($_SERVER['SERVER_NAME']) : 'localhost'; |
|
5622 | 5622 | return $this->unique_id; |
5623 | 5623 | break; |
5624 | 5624 | } |
@@ -5632,47 +5632,47 @@ discard block |
||
5632 | 5632 | * @param string $value |
5633 | 5633 | * @return void |
5634 | 5634 | */ |
5635 | - function setConfig( $config, $value ) { |
|
5635 | + function setConfig($config, $value) { |
|
5636 | 5636 | $res = FALSE; |
5637 | - switch( strtoupper( $config )) { |
|
5637 | + switch (strtoupper($config)) { |
|
5638 | 5638 | case 'ALLOWEMPTY': |
5639 | 5639 | $this->allowEmpty = $value; |
5640 | - $subcfg = array( 'ALLOWEMPTY' => $value ); |
|
5640 | + $subcfg = array('ALLOWEMPTY' => $value); |
|
5641 | 5641 | $res = TRUE; |
5642 | 5642 | break; |
5643 | 5643 | case 'FORMAT': |
5644 | - $value = trim( $value ); |
|
5644 | + $value = trim($value); |
|
5645 | 5645 | $this->format = $value; |
5646 | 5646 | $this->_createFormat(); |
5647 | - $subcfg = array( 'FORMAT' => $value ); |
|
5647 | + $subcfg = array('FORMAT' => $value); |
|
5648 | 5648 | $res = TRUE; |
5649 | 5649 | break; |
5650 | 5650 | case 'LANGUAGE': |
5651 | 5651 | // set language for calendar component as defined in [RFC 1766] |
5652 | - $value = trim( $value ); |
|
5652 | + $value = trim($value); |
|
5653 | 5653 | $this->language = $value; |
5654 | - $subcfg = array( 'LANGUAGE' => $value ); |
|
5654 | + $subcfg = array('LANGUAGE' => $value); |
|
5655 | 5655 | $res = TRUE; |
5656 | 5656 | break; |
5657 | 5657 | case 'NL': |
5658 | 5658 | case 'NEWLINECHAR': |
5659 | 5659 | $this->nl = $value; |
5660 | - $subcfg = array( 'NL' => $value ); |
|
5660 | + $subcfg = array('NL' => $value); |
|
5661 | 5661 | $res = TRUE; |
5662 | 5662 | break; |
5663 | 5663 | case 'UNIQUE_ID': |
5664 | - $value = trim( $value ); |
|
5664 | + $value = trim($value); |
|
5665 | 5665 | $this->unique_id = $value; |
5666 | - $subcfg = array( 'UNIQUE_ID' => $value ); |
|
5666 | + $subcfg = array('UNIQUE_ID' => $value); |
|
5667 | 5667 | $res = TRUE; |
5668 | 5668 | break; |
5669 | 5669 | } |
5670 | - if( !$res ) return FALSE; |
|
5671 | - if( isset( $subcfg ) && !empty( $this->components )) { |
|
5672 | - foreach( $subcfg as $cfgkey => $cfgvalue ) { |
|
5673 | - foreach( $this->components as $cix => $component ) { |
|
5674 | - $res = $component->setConfig( $cfgkey, $cfgvalue ); |
|
5675 | - if( !$res ) |
|
5670 | + if (!$res) return FALSE; |
|
5671 | + if (isset($subcfg) && !empty($this->components)) { |
|
5672 | + foreach ($subcfg as $cfgkey => $cfgvalue) { |
|
5673 | + foreach ($this->components as $cix => $component) { |
|
5674 | + $res = $component->setConfig($cfgkey, $cfgvalue); |
|
5675 | + if (!$res) |
|
5676 | 5676 | break 2; |
5677 | 5677 | $this->components[$cix] = $component; // PHP4 compliant |
5678 | 5678 | } |
@@ -5690,248 +5690,248 @@ discard block |
||
5690 | 5690 | * @param int @propix, optional, if specific property is wanted in case of multiply occurences |
5691 | 5691 | * @return bool, if successfull delete TRUE |
5692 | 5692 | */ |
5693 | - function deleteProperty( $propName, $propix=FALSE ) { |
|
5694 | - if( $this->_notExistProp( $propName )) return FALSE; |
|
5695 | - $propName = strtoupper( $propName ); |
|
5696 | - if( in_array( $propName, array( 'ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
|
5697 | - 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP' ))) { |
|
5698 | - if( !$propix ) |
|
5699 | - $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1; |
|
5693 | + function deleteProperty($propName, $propix = FALSE) { |
|
5694 | + if ($this->_notExistProp($propName)) return FALSE; |
|
5695 | + $propName = strtoupper($propName); |
|
5696 | + if (in_array($propName, array('ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
|
5697 | + 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP'))) { |
|
5698 | + if (!$propix) |
|
5699 | + $propix = (isset($this->propdelix[$propName])) ? $this->propdelix[$propName] + 2 : 1; |
|
5700 | 5700 | $this->propdelix[$propName] = --$propix; |
5701 | 5701 | } |
5702 | 5702 | $return = FALSE; |
5703 | - switch( $propName ) { |
|
5703 | + switch ($propName) { |
|
5704 | 5704 | case 'ACTION': |
5705 | - if( !empty( $this->action )) { |
|
5705 | + if (!empty($this->action)) { |
|
5706 | 5706 | $this->action = ''; |
5707 | 5707 | $return = TRUE; |
5708 | 5708 | } |
5709 | 5709 | break; |
5710 | 5710 | case 'ATTACH': |
5711 | - return $this->deletePropertyM( $this->attach, $propix ); |
|
5711 | + return $this->deletePropertyM($this->attach, $propix); |
|
5712 | 5712 | break; |
5713 | 5713 | case 'ATTENDEE': |
5714 | - return $this->deletePropertyM( $this->attendee, $propix ); |
|
5714 | + return $this->deletePropertyM($this->attendee, $propix); |
|
5715 | 5715 | break; |
5716 | 5716 | case 'CATEGORIES': |
5717 | - return $this->deletePropertyM( $this->categories, $propix ); |
|
5717 | + return $this->deletePropertyM($this->categories, $propix); |
|
5718 | 5718 | break; |
5719 | 5719 | case 'CLASS': |
5720 | - if( !empty( $this->class )) { |
|
5720 | + if (!empty($this->class)) { |
|
5721 | 5721 | $this->class = ''; |
5722 | 5722 | $return = TRUE; |
5723 | 5723 | } |
5724 | 5724 | break; |
5725 | 5725 | case 'COMMENT': |
5726 | - return $this->deletePropertyM( $this->comment, $propix ); |
|
5726 | + return $this->deletePropertyM($this->comment, $propix); |
|
5727 | 5727 | break; |
5728 | 5728 | case 'COMPLETED': |
5729 | - if( !empty( $this->completed )) { |
|
5729 | + if (!empty($this->completed)) { |
|
5730 | 5730 | $this->completed = ''; |
5731 | 5731 | $return = TRUE; |
5732 | 5732 | } |
5733 | 5733 | break; |
5734 | 5734 | case 'CONTACT': |
5735 | - return $this->deletePropertyM( $this->contact, $propix ); |
|
5735 | + return $this->deletePropertyM($this->contact, $propix); |
|
5736 | 5736 | break; |
5737 | 5737 | case 'CREATED': |
5738 | - if( !empty( $this->created )) { |
|
5738 | + if (!empty($this->created)) { |
|
5739 | 5739 | $this->created = ''; |
5740 | 5740 | $return = TRUE; |
5741 | 5741 | } |
5742 | 5742 | break; |
5743 | 5743 | case 'DESCRIPTION': |
5744 | - return $this->deletePropertyM( $this->description, $propix ); |
|
5744 | + return $this->deletePropertyM($this->description, $propix); |
|
5745 | 5745 | break; |
5746 | 5746 | case 'DTEND': |
5747 | - if( !empty( $this->dtend )) { |
|
5747 | + if (!empty($this->dtend)) { |
|
5748 | 5748 | $this->dtend = ''; |
5749 | 5749 | $return = TRUE; |
5750 | 5750 | } |
5751 | 5751 | break; |
5752 | 5752 | case 'DTSTAMP': |
5753 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
5753 | + if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) |
|
5754 | 5754 | return FALSE; |
5755 | - if( !empty( $this->dtstamp )) { |
|
5755 | + if (!empty($this->dtstamp)) { |
|
5756 | 5756 | $this->dtstamp = ''; |
5757 | 5757 | $return = TRUE; |
5758 | 5758 | } |
5759 | 5759 | break; |
5760 | 5760 | case 'DTSTART': |
5761 | - if( !empty( $this->dtstart )) { |
|
5761 | + if (!empty($this->dtstart)) { |
|
5762 | 5762 | $this->dtstart = ''; |
5763 | 5763 | $return = TRUE; |
5764 | 5764 | } |
5765 | 5765 | break; |
5766 | 5766 | case 'DUE': |
5767 | - if( !empty( $this->due )) { |
|
5767 | + if (!empty($this->due)) { |
|
5768 | 5768 | $this->due = ''; |
5769 | 5769 | $return = TRUE; |
5770 | 5770 | } |
5771 | 5771 | break; |
5772 | 5772 | case 'DURATION': |
5773 | - if( !empty( $this->duration )) { |
|
5773 | + if (!empty($this->duration)) { |
|
5774 | 5774 | $this->duration = ''; |
5775 | 5775 | $return = TRUE; |
5776 | 5776 | } |
5777 | 5777 | break; |
5778 | 5778 | case 'EXDATE': |
5779 | - return $this->deletePropertyM( $this->exdate, $propix ); |
|
5779 | + return $this->deletePropertyM($this->exdate, $propix); |
|
5780 | 5780 | break; |
5781 | 5781 | case 'EXRULE': |
5782 | - return $this->deletePropertyM( $this->exrule, $propix ); |
|
5782 | + return $this->deletePropertyM($this->exrule, $propix); |
|
5783 | 5783 | break; |
5784 | 5784 | case 'FREEBUSY': |
5785 | - return $this->deletePropertyM( $this->freebusy, $propix ); |
|
5785 | + return $this->deletePropertyM($this->freebusy, $propix); |
|
5786 | 5786 | break; |
5787 | 5787 | case 'GEO': |
5788 | - if( !empty( $this->geo )) { |
|
5788 | + if (!empty($this->geo)) { |
|
5789 | 5789 | $this->geo = ''; |
5790 | 5790 | $return = TRUE; |
5791 | 5791 | } |
5792 | 5792 | break; |
5793 | 5793 | case 'LAST-MODIFIED': |
5794 | - if( !empty( $this->lastmodified )) { |
|
5794 | + if (!empty($this->lastmodified)) { |
|
5795 | 5795 | $this->lastmodified = ''; |
5796 | 5796 | $return = TRUE; |
5797 | 5797 | } |
5798 | 5798 | break; |
5799 | 5799 | case 'LOCATION': |
5800 | - if( !empty( $this->location )) { |
|
5800 | + if (!empty($this->location)) { |
|
5801 | 5801 | $this->location = ''; |
5802 | 5802 | $return = TRUE; |
5803 | 5803 | } |
5804 | 5804 | break; |
5805 | 5805 | case 'ORGANIZER': |
5806 | - if( !empty( $this->organizer )) { |
|
5806 | + if (!empty($this->organizer)) { |
|
5807 | 5807 | $this->organizer = ''; |
5808 | 5808 | $return = TRUE; |
5809 | 5809 | } |
5810 | 5810 | break; |
5811 | 5811 | case 'PERCENT-COMPLETE': |
5812 | - if( !empty( $this->percentcomplete )) { |
|
5812 | + if (!empty($this->percentcomplete)) { |
|
5813 | 5813 | $this->percentcomplete = ''; |
5814 | 5814 | $return = TRUE; |
5815 | 5815 | } |
5816 | 5816 | break; |
5817 | 5817 | case 'PRIORITY': |
5818 | - if( !empty( $this->priority )) { |
|
5818 | + if (!empty($this->priority)) { |
|
5819 | 5819 | $this->priority = ''; |
5820 | 5820 | $return = TRUE; |
5821 | 5821 | } |
5822 | 5822 | break; |
5823 | 5823 | case 'RDATE': |
5824 | - return $this->deletePropertyM( $this->rdate, $propix ); |
|
5824 | + return $this->deletePropertyM($this->rdate, $propix); |
|
5825 | 5825 | break; |
5826 | 5826 | case 'RECURRENCE-ID': |
5827 | - if( !empty( $this->recurrenceid )) { |
|
5827 | + if (!empty($this->recurrenceid)) { |
|
5828 | 5828 | $this->recurrenceid = ''; |
5829 | 5829 | $return = TRUE; |
5830 | 5830 | } |
5831 | 5831 | break; |
5832 | 5832 | case 'RELATED-TO': |
5833 | - return $this->deletePropertyM( $this->relatedto, $propix ); |
|
5833 | + return $this->deletePropertyM($this->relatedto, $propix); |
|
5834 | 5834 | break; |
5835 | 5835 | case 'REPEAT': |
5836 | - if( !empty( $this->repeat )) { |
|
5836 | + if (!empty($this->repeat)) { |
|
5837 | 5837 | $this->repeat = ''; |
5838 | 5838 | $return = TRUE; |
5839 | 5839 | } |
5840 | 5840 | break; |
5841 | 5841 | case 'REQUEST-STATUS': |
5842 | - return $this->deletePropertyM( $this->requeststatus, $propix ); |
|
5842 | + return $this->deletePropertyM($this->requeststatus, $propix); |
|
5843 | 5843 | break; |
5844 | 5844 | case 'RESOURCES': |
5845 | - return $this->deletePropertyM( $this->resources, $propix ); |
|
5845 | + return $this->deletePropertyM($this->resources, $propix); |
|
5846 | 5846 | break; |
5847 | 5847 | case 'RRULE': |
5848 | - return $this->deletePropertyM( $this->rrule, $propix ); |
|
5848 | + return $this->deletePropertyM($this->rrule, $propix); |
|
5849 | 5849 | break; |
5850 | 5850 | case 'SEQUENCE': |
5851 | - if( !empty( $this->sequence )) { |
|
5851 | + if (!empty($this->sequence)) { |
|
5852 | 5852 | $this->sequence = ''; |
5853 | 5853 | $return = TRUE; |
5854 | 5854 | } |
5855 | 5855 | break; |
5856 | 5856 | case 'STATUS': |
5857 | - if( !empty( $this->status )) { |
|
5857 | + if (!empty($this->status)) { |
|
5858 | 5858 | $this->status = ''; |
5859 | 5859 | $return = TRUE; |
5860 | 5860 | } |
5861 | 5861 | break; |
5862 | 5862 | case 'SUMMARY': |
5863 | - if( !empty( $this->summary )) { |
|
5863 | + if (!empty($this->summary)) { |
|
5864 | 5864 | $this->summary = ''; |
5865 | 5865 | $return = TRUE; |
5866 | 5866 | } |
5867 | 5867 | break; |
5868 | 5868 | case 'TRANSP': |
5869 | - if( !empty( $this->transp )) { |
|
5869 | + if (!empty($this->transp)) { |
|
5870 | 5870 | $this->transp = ''; |
5871 | 5871 | $return = TRUE; |
5872 | 5872 | } |
5873 | 5873 | break; |
5874 | 5874 | case 'TRIGGER': |
5875 | - if( !empty( $this->trigger )) { |
|
5875 | + if (!empty($this->trigger)) { |
|
5876 | 5876 | $this->trigger = ''; |
5877 | 5877 | $return = TRUE; |
5878 | 5878 | } |
5879 | 5879 | break; |
5880 | 5880 | case 'TZID': |
5881 | - if( !empty( $this->tzid )) { |
|
5881 | + if (!empty($this->tzid)) { |
|
5882 | 5882 | $this->tzid = ''; |
5883 | 5883 | $return = TRUE; |
5884 | 5884 | } |
5885 | 5885 | break; |
5886 | 5886 | case 'TZNAME': |
5887 | - return $this->deletePropertyM( $this->tzname, $propix ); |
|
5887 | + return $this->deletePropertyM($this->tzname, $propix); |
|
5888 | 5888 | break; |
5889 | 5889 | case 'TZOFFSETFROM': |
5890 | - if( !empty( $this->tzoffsetfrom )) { |
|
5890 | + if (!empty($this->tzoffsetfrom)) { |
|
5891 | 5891 | $this->tzoffsetfrom = ''; |
5892 | 5892 | $return = TRUE; |
5893 | 5893 | } |
5894 | 5894 | break; |
5895 | 5895 | case 'TZOFFSETTO': |
5896 | - if( !empty( $this->tzoffsetto )) { |
|
5896 | + if (!empty($this->tzoffsetto)) { |
|
5897 | 5897 | $this->tzoffsetto = ''; |
5898 | 5898 | $return = TRUE; |
5899 | 5899 | } |
5900 | 5900 | break; |
5901 | 5901 | case 'TZURL': |
5902 | - if( !empty( $this->tzurl )) { |
|
5902 | + if (!empty($this->tzurl)) { |
|
5903 | 5903 | $this->tzurl = ''; |
5904 | 5904 | $return = TRUE; |
5905 | 5905 | } |
5906 | 5906 | break; |
5907 | 5907 | case 'UID': |
5908 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
5908 | + if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) |
|
5909 | 5909 | return FALSE; |
5910 | - if( !empty( $this->uid )) { |
|
5910 | + if (!empty($this->uid)) { |
|
5911 | 5911 | $this->uid = ''; |
5912 | 5912 | $return = TRUE; |
5913 | 5913 | } |
5914 | 5914 | break; |
5915 | 5915 | case 'URL': |
5916 | - if( !empty( $this->url )) { |
|
5916 | + if (!empty($this->url)) { |
|
5917 | 5917 | $this->url = ''; |
5918 | 5918 | $return = TRUE; |
5919 | 5919 | } |
5920 | 5920 | break; |
5921 | 5921 | default: |
5922 | 5922 | $reduced = ''; |
5923 | - if( $propName != 'X-PROP' ) { |
|
5924 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
5925 | - foreach( $this->xprop as $k => $a ) { |
|
5926 | - if(( $k != $propName ) && !empty( $a )) |
|
5923 | + if ($propName != 'X-PROP') { |
|
5924 | + if (!isset($this->xprop[$propName])) return FALSE; |
|
5925 | + foreach ($this->xprop as $k => $a) { |
|
5926 | + if (($k != $propName) && !empty($a)) |
|
5927 | 5927 | $reduced[$k] = $a; |
5928 | 5928 | } |
5929 | 5929 | } |
5930 | 5930 | else { |
5931 | - if( count( $this->xprop ) <= $propix ) return FALSE; |
|
5931 | + if (count($this->xprop) <= $propix) return FALSE; |
|
5932 | 5932 | $xpropno = 0; |
5933 | - foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
|
5934 | - if( $propix != $xpropno ) |
|
5933 | + foreach ($this->xprop as $xpropkey => $xpropvalue) { |
|
5934 | + if ($propix != $xpropno) |
|
5935 | 5935 | $reduced[$xpropkey] = $xpropvalue; |
5936 | 5936 | $xpropno++; |
5937 | 5937 | } |
@@ -5951,11 +5951,11 @@ discard block |
||
5951 | 5951 | * @param int @propix, default 0 |
5952 | 5952 | * @return bool TRUE |
5953 | 5953 | */ |
5954 | - function deletePropertyM( & $multiprop, $propix=0 ) { |
|
5955 | - if( !isset( $multiprop[$propix])) return FALSE; |
|
5956 | - unset( $multiprop[$propix] ); |
|
5957 | - if( empty( $multiprop )) $multiprop = ''; |
|
5958 | - return ( isset( $this->multiprop[$propix] )) ? FALSE : TRUE; |
|
5954 | + function deletePropertyM(& $multiprop, $propix = 0) { |
|
5955 | + if (!isset($multiprop[$propix])) return FALSE; |
|
5956 | + unset($multiprop[$propix]); |
|
5957 | + if (empty($multiprop)) $multiprop = ''; |
|
5958 | + return (isset($this->multiprop[$propix])) ? FALSE : TRUE; |
|
5959 | 5959 | } |
5960 | 5960 | /** |
5961 | 5961 | * get component property value/params |
@@ -5970,183 +5970,183 @@ discard block |
||
5970 | 5970 | * @param bool $specform=FALSE |
5971 | 5971 | * @return mixed |
5972 | 5972 | */ |
5973 | - function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE, $specform=FALSE ) { |
|
5974 | - if( $this->_notExistProp( $propName )) return FALSE; |
|
5975 | - $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP'; |
|
5976 | - if( in_array( $propName, array( 'ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
|
5977 | - 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP' ))) { |
|
5978 | - if( !$propix ) |
|
5979 | - $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; |
|
5973 | + function getProperty($propName = FALSE, $propix = FALSE, $inclParam = FALSE, $specform = FALSE) { |
|
5974 | + if ($this->_notExistProp($propName)) return FALSE; |
|
5975 | + $propName = ($propName) ? strtoupper($propName) : 'X-PROP'; |
|
5976 | + if (in_array($propName, array('ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
|
5977 | + 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP'))) { |
|
5978 | + if (!$propix) |
|
5979 | + $propix = (isset($this->propix[$propName])) ? $this->propix[$propName] + 2 : 1; |
|
5980 | 5980 | $this->propix[$propName] = --$propix; |
5981 | 5981 | } |
5982 | - switch( $propName ) { |
|
5982 | + switch ($propName) { |
|
5983 | 5983 | case 'ACTION': |
5984 | - if( !empty( $this->action['value'] )) return ( $inclParam ) ? $this->action : $this->action['value']; |
|
5984 | + if (!empty($this->action['value'])) return ($inclParam) ? $this->action : $this->action['value']; |
|
5985 | 5985 | break; |
5986 | 5986 | case 'ATTACH': |
5987 | - if( !isset( $this->attach[$propix] )) return FALSE; |
|
5988 | - return ( $inclParam ) ? $this->attach[$propix] : $this->attach[$propix]['value']; |
|
5987 | + if (!isset($this->attach[$propix])) return FALSE; |
|
5988 | + return ($inclParam) ? $this->attach[$propix] : $this->attach[$propix]['value']; |
|
5989 | 5989 | break; |
5990 | 5990 | case 'ATTENDEE': |
5991 | - if( !isset( $this->attendee[$propix] )) return FALSE; |
|
5992 | - return ( $inclParam ) ? $this->attendee[$propix] : $this->attendee[$propix]['value']; |
|
5991 | + if (!isset($this->attendee[$propix])) return FALSE; |
|
5992 | + return ($inclParam) ? $this->attendee[$propix] : $this->attendee[$propix]['value']; |
|
5993 | 5993 | break; |
5994 | 5994 | case 'CATEGORIES': |
5995 | - if( !isset( $this->categories[$propix] )) return FALSE; |
|
5996 | - return ( $inclParam ) ? $this->categories[$propix] : $this->categories[$propix]['value']; |
|
5995 | + if (!isset($this->categories[$propix])) return FALSE; |
|
5996 | + return ($inclParam) ? $this->categories[$propix] : $this->categories[$propix]['value']; |
|
5997 | 5997 | break; |
5998 | 5998 | case 'CLASS': |
5999 | - if( !empty( $this->class['value'] )) return ( $inclParam ) ? $this->class : $this->class['value']; |
|
5999 | + if (!empty($this->class['value'])) return ($inclParam) ? $this->class : $this->class['value']; |
|
6000 | 6000 | break; |
6001 | 6001 | case 'COMMENT': |
6002 | - if( !isset( $this->comment[$propix] )) return FALSE; |
|
6003 | - return ( $inclParam ) ? $this->comment[$propix] : $this->comment[$propix]['value']; |
|
6002 | + if (!isset($this->comment[$propix])) return FALSE; |
|
6003 | + return ($inclParam) ? $this->comment[$propix] : $this->comment[$propix]['value']; |
|
6004 | 6004 | break; |
6005 | 6005 | case 'COMPLETED': |
6006 | - if( !empty( $this->completed['value'] )) return ( $inclParam ) ? $this->completed : $this->completed['value']; |
|
6006 | + if (!empty($this->completed['value'])) return ($inclParam) ? $this->completed : $this->completed['value']; |
|
6007 | 6007 | break; |
6008 | 6008 | case 'CONTACT': |
6009 | - if( !isset( $this->contact[$propix] )) return FALSE; |
|
6010 | - return ( $inclParam ) ? $this->contact[$propix] : $this->contact[$propix]['value']; |
|
6009 | + if (!isset($this->contact[$propix])) return FALSE; |
|
6010 | + return ($inclParam) ? $this->contact[$propix] : $this->contact[$propix]['value']; |
|
6011 | 6011 | break; |
6012 | 6012 | case 'CREATED': |
6013 | - if( !empty( $this->created['value'] )) return ( $inclParam ) ? $this->created : $this->created['value']; |
|
6013 | + if (!empty($this->created['value'])) return ($inclParam) ? $this->created : $this->created['value']; |
|
6014 | 6014 | break; |
6015 | 6015 | case 'DESCRIPTION': |
6016 | - if( !isset( $this->description[$propix] )) return FALSE; |
|
6017 | - return ( $inclParam ) ? $this->description[$propix] : $this->description[$propix]['value']; |
|
6016 | + if (!isset($this->description[$propix])) return FALSE; |
|
6017 | + return ($inclParam) ? $this->description[$propix] : $this->description[$propix]['value']; |
|
6018 | 6018 | break; |
6019 | 6019 | case 'DTEND': |
6020 | - if( !empty( $this->dtend['value'] )) return ( $inclParam ) ? $this->dtend : $this->dtend['value']; |
|
6020 | + if (!empty($this->dtend['value'])) return ($inclParam) ? $this->dtend : $this->dtend['value']; |
|
6021 | 6021 | break; |
6022 | 6022 | case 'DTSTAMP': |
6023 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
6023 | + if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) |
|
6024 | 6024 | return; |
6025 | - if( !isset( $this->dtstamp['value'] )) |
|
6025 | + if (!isset($this->dtstamp['value'])) |
|
6026 | 6026 | $this->_makeDtstamp(); |
6027 | - return ( $inclParam ) ? $this->dtstamp : $this->dtstamp['value']; |
|
6027 | + return ($inclParam) ? $this->dtstamp : $this->dtstamp['value']; |
|
6028 | 6028 | break; |
6029 | 6029 | case 'DTSTART': |
6030 | - if( !empty( $this->dtstart['value'] )) return ( $inclParam ) ? $this->dtstart : $this->dtstart['value']; |
|
6030 | + if (!empty($this->dtstart['value'])) return ($inclParam) ? $this->dtstart : $this->dtstart['value']; |
|
6031 | 6031 | break; |
6032 | 6032 | case 'DUE': |
6033 | - if( !empty( $this->due['value'] )) return ( $inclParam ) ? $this->due : $this->due['value']; |
|
6033 | + if (!empty($this->due['value'])) return ($inclParam) ? $this->due : $this->due['value']; |
|
6034 | 6034 | break; |
6035 | 6035 | case 'DURATION': |
6036 | - if( !isset( $this->duration['value'] )) return FALSE; |
|
6037 | - $value = ( $specform ) ? $this->duration2date() : $this->duration['value']; |
|
6038 | - return ( $inclParam ) ? array( 'value' => $value, 'params' => $this->duration['params'] ) : $value; |
|
6036 | + if (!isset($this->duration['value'])) return FALSE; |
|
6037 | + $value = ($specform) ? $this->duration2date() : $this->duration['value']; |
|
6038 | + return ($inclParam) ? array('value' => $value, 'params' => $this->duration['params']) : $value; |
|
6039 | 6039 | break; |
6040 | 6040 | case 'EXDATE': |
6041 | - if( !isset( $this->exdate[$propix] )) return FALSE; |
|
6042 | - return ( $inclParam ) ? $this->exdate[$propix] : $this->exdate[$propix]['value']; |
|
6041 | + if (!isset($this->exdate[$propix])) return FALSE; |
|
6042 | + return ($inclParam) ? $this->exdate[$propix] : $this->exdate[$propix]['value']; |
|
6043 | 6043 | break; |
6044 | 6044 | case 'EXRULE': |
6045 | - if( !isset( $this->exrule[$propix] )) return FALSE; |
|
6046 | - return ( $inclParam ) ? $this->exrule[$propix] : $this->exrule[$propix]['value']; |
|
6045 | + if (!isset($this->exrule[$propix])) return FALSE; |
|
6046 | + return ($inclParam) ? $this->exrule[$propix] : $this->exrule[$propix]['value']; |
|
6047 | 6047 | break; |
6048 | 6048 | case 'FREEBUSY': |
6049 | - if( !isset( $this->freebusy[$propix] )) return FALSE; |
|
6050 | - return ( $inclParam ) ? $this->freebusy[$propix] : $this->freebusy[$propix]['value']; |
|
6049 | + if (!isset($this->freebusy[$propix])) return FALSE; |
|
6050 | + return ($inclParam) ? $this->freebusy[$propix] : $this->freebusy[$propix]['value']; |
|
6051 | 6051 | break; |
6052 | 6052 | case 'GEO': |
6053 | - if( !empty( $this->geo['value'] )) return ( $inclParam ) ? $this->geo : $this->geo['value']; |
|
6053 | + if (!empty($this->geo['value'])) return ($inclParam) ? $this->geo : $this->geo['value']; |
|
6054 | 6054 | break; |
6055 | 6055 | case 'LAST-MODIFIED': |
6056 | - if( !empty( $this->lastmodified['value'] )) return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value']; |
|
6056 | + if (!empty($this->lastmodified['value'])) return ($inclParam) ? $this->lastmodified : $this->lastmodified['value']; |
|
6057 | 6057 | break; |
6058 | 6058 | case 'LOCATION': |
6059 | - if( !empty( $this->location['value'] )) return ( $inclParam ) ? $this->location : $this->location['value']; |
|
6059 | + if (!empty($this->location['value'])) return ($inclParam) ? $this->location : $this->location['value']; |
|
6060 | 6060 | break; |
6061 | 6061 | case 'ORGANIZER': |
6062 | - if( !empty( $this->organizer['value'] )) return ( $inclParam ) ? $this->organizer : $this->organizer['value']; |
|
6062 | + if (!empty($this->organizer['value'])) return ($inclParam) ? $this->organizer : $this->organizer['value']; |
|
6063 | 6063 | break; |
6064 | 6064 | case 'PERCENT-COMPLETE': |
6065 | - if( !empty( $this->percentcomplete['value'] )) return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value']; |
|
6065 | + if (!empty($this->percentcomplete['value'])) return ($inclParam) ? $this->percentcomplete : $this->percentcomplete['value']; |
|
6066 | 6066 | break; |
6067 | 6067 | case 'PRIORITY': |
6068 | - if( !empty( $this->priority['value'] )) return ( $inclParam ) ? $this->priority : $this->priority['value']; |
|
6068 | + if (!empty($this->priority['value'])) return ($inclParam) ? $this->priority : $this->priority['value']; |
|
6069 | 6069 | break; |
6070 | 6070 | case 'RDATE': |
6071 | - if( !isset( $this->rdate[$propix] )) return FALSE; |
|
6072 | - return ( $inclParam ) ? $this->rdate[$propix] : $this->rdate[$propix]['value']; |
|
6071 | + if (!isset($this->rdate[$propix])) return FALSE; |
|
6072 | + return ($inclParam) ? $this->rdate[$propix] : $this->rdate[$propix]['value']; |
|
6073 | 6073 | break; |
6074 | 6074 | case 'RECURRENCE-ID': |
6075 | - if( !empty( $this->recurrenceid['value'] )) return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value']; |
|
6075 | + if (!empty($this->recurrenceid['value'])) return ($inclParam) ? $this->recurrenceid : $this->recurrenceid['value']; |
|
6076 | 6076 | break; |
6077 | 6077 | case 'RELATED-TO': |
6078 | - if( !isset( $this->relatedto[$propix] )) return FALSE; |
|
6079 | - return ( $inclParam ) ? $this->relatedto[$propix] : $this->relatedto[$propix]['value']; |
|
6078 | + if (!isset($this->relatedto[$propix])) return FALSE; |
|
6079 | + return ($inclParam) ? $this->relatedto[$propix] : $this->relatedto[$propix]['value']; |
|
6080 | 6080 | break; |
6081 | 6081 | case 'REPEAT': |
6082 | - if( !empty( $this->repeat['value'] )) return ( $inclParam ) ? $this->repeat : $this->repeat['value']; |
|
6082 | + if (!empty($this->repeat['value'])) return ($inclParam) ? $this->repeat : $this->repeat['value']; |
|
6083 | 6083 | break; |
6084 | 6084 | case 'REQUEST-STATUS': |
6085 | - if( !isset( $this->requeststatus[$propix] )) return FALSE; |
|
6086 | - return ( $inclParam ) ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value']; |
|
6085 | + if (!isset($this->requeststatus[$propix])) return FALSE; |
|
6086 | + return ($inclParam) ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value']; |
|
6087 | 6087 | break; |
6088 | 6088 | case 'RESOURCES': |
6089 | - if( !isset( $this->resources[$propix] )) return FALSE; |
|
6090 | - return ( $inclParam ) ? $this->resources[$propix] : $this->resources[$propix]['value']; |
|
6089 | + if (!isset($this->resources[$propix])) return FALSE; |
|
6090 | + return ($inclParam) ? $this->resources[$propix] : $this->resources[$propix]['value']; |
|
6091 | 6091 | break; |
6092 | 6092 | case 'RRULE': |
6093 | - if( !isset( $this->rrule[$propix] )) return FALSE; |
|
6094 | - return ( $inclParam ) ? $this->rrule[$propix] : $this->rrule[$propix]['value']; |
|
6093 | + if (!isset($this->rrule[$propix])) return FALSE; |
|
6094 | + return ($inclParam) ? $this->rrule[$propix] : $this->rrule[$propix]['value']; |
|
6095 | 6095 | break; |
6096 | 6096 | case 'SEQUENCE': |
6097 | - if( !empty( $this->sequence['value'] )) return ( $inclParam ) ? $this->sequence : $this->sequence['value']; |
|
6097 | + if (!empty($this->sequence['value'])) return ($inclParam) ? $this->sequence : $this->sequence['value']; |
|
6098 | 6098 | break; |
6099 | 6099 | case 'STATUS': |
6100 | - if( !empty( $this->status['value'] )) return ( $inclParam ) ? $this->status : $this->status['value']; |
|
6100 | + if (!empty($this->status['value'])) return ($inclParam) ? $this->status : $this->status['value']; |
|
6101 | 6101 | break; |
6102 | 6102 | case 'SUMMARY': |
6103 | - if( !empty( $this->summary['value'] )) return ( $inclParam ) ? $this->summary : $this->summary['value']; |
|
6103 | + if (!empty($this->summary['value'])) return ($inclParam) ? $this->summary : $this->summary['value']; |
|
6104 | 6104 | break; |
6105 | 6105 | case 'TRANSP': |
6106 | - if( !empty( $this->transp['value'] )) return ( $inclParam ) ? $this->transp : $this->transp['value']; |
|
6106 | + if (!empty($this->transp['value'])) return ($inclParam) ? $this->transp : $this->transp['value']; |
|
6107 | 6107 | break; |
6108 | 6108 | case 'TRIGGER': |
6109 | - if( !empty( $this->trigger['value'] )) return ( $inclParam ) ? $this->trigger : $this->trigger['value']; |
|
6109 | + if (!empty($this->trigger['value'])) return ($inclParam) ? $this->trigger : $this->trigger['value']; |
|
6110 | 6110 | break; |
6111 | 6111 | case 'TZID': |
6112 | - if( !empty( $this->tzid['value'] )) return ( $inclParam ) ? $this->tzid : $this->tzid['value']; |
|
6112 | + if (!empty($this->tzid['value'])) return ($inclParam) ? $this->tzid : $this->tzid['value']; |
|
6113 | 6113 | break; |
6114 | 6114 | case 'TZNAME': |
6115 | - if( !isset( $this->tzname[$propix] )) return FALSE; |
|
6116 | - return ( $inclParam ) ? $this->tzname[$propix] : $this->tzname[$propix]['value']; |
|
6115 | + if (!isset($this->tzname[$propix])) return FALSE; |
|
6116 | + return ($inclParam) ? $this->tzname[$propix] : $this->tzname[$propix]['value']; |
|
6117 | 6117 | break; |
6118 | 6118 | case 'TZOFFSETFROM': |
6119 | - if( !empty( $this->tzoffsetfrom['value'] )) return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value']; |
|
6119 | + if (!empty($this->tzoffsetfrom['value'])) return ($inclParam) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value']; |
|
6120 | 6120 | break; |
6121 | 6121 | case 'TZOFFSETTO': |
6122 | - if( !empty( $this->tzoffsetto['value'] )) return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value']; |
|
6122 | + if (!empty($this->tzoffsetto['value'])) return ($inclParam) ? $this->tzoffsetto : $this->tzoffsetto['value']; |
|
6123 | 6123 | break; |
6124 | 6124 | case 'TZURL': |
6125 | - if( !empty( $this->tzurl['value'] )) return ( $inclParam ) ? $this->tzurl : $this->tzurl['value']; |
|
6125 | + if (!empty($this->tzurl['value'])) return ($inclParam) ? $this->tzurl : $this->tzurl['value']; |
|
6126 | 6126 | break; |
6127 | 6127 | case 'UID': |
6128 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
6128 | + if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) |
|
6129 | 6129 | return FALSE; |
6130 | - if( empty( $this->uid['value'] )) |
|
6130 | + if (empty($this->uid['value'])) |
|
6131 | 6131 | $this->_makeuid(); |
6132 | - return ( $inclParam ) ? $this->uid : $this->uid['value']; |
|
6132 | + return ($inclParam) ? $this->uid : $this->uid['value']; |
|
6133 | 6133 | break; |
6134 | 6134 | case 'URL': |
6135 | - if( !empty( $this->url['value'] )) return ( $inclParam ) ? $this->url : $this->url['value']; |
|
6135 | + if (!empty($this->url['value'])) return ($inclParam) ? $this->url : $this->url['value']; |
|
6136 | 6136 | break; |
6137 | 6137 | default: |
6138 | - if( $propName != 'X-PROP' ) { |
|
6139 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
6140 | - return ( $inclParam ) ? array( $propName, $this->xprop[$propName] ) |
|
6141 | - : array( $propName, $this->xprop[$propName]['value'] ); |
|
6138 | + if ($propName != 'X-PROP') { |
|
6139 | + if (!isset($this->xprop[$propName])) return FALSE; |
|
6140 | + return ($inclParam) ? array($propName, $this->xprop[$propName]) |
|
6141 | + : array($propName, $this->xprop[$propName]['value']); |
|
6142 | 6142 | } |
6143 | 6143 | else { |
6144 | - if( empty( $this->xprop )) return FALSE; |
|
6144 | + if (empty($this->xprop)) return FALSE; |
|
6145 | 6145 | $xpropno = 0; |
6146 | - foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
|
6147 | - if( $propix == $xpropno ) |
|
6148 | - return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) |
|
6149 | - : array( $xpropkey, $this->xprop[$xpropkey]['value'] ); |
|
6146 | + foreach ($this->xprop as $xpropkey => $xpropvalue) { |
|
6147 | + if ($propix == $xpropno) |
|
6148 | + return ($inclParam) ? array($xpropkey, $this->xprop[$xpropkey]) |
|
6149 | + : array($xpropkey, $this->xprop[$xpropkey]['value']); |
|
6150 | 6150 | else |
6151 | 6151 | $xpropno++; |
6152 | 6152 | } |
@@ -6167,105 +6167,105 @@ discard block |
||
6167 | 6167 | */ |
6168 | 6168 | function setProperty() { |
6169 | 6169 | $numargs = func_num_args(); |
6170 | - if( 1 > $numargs ) return FALSE; |
|
6170 | + if (1 > $numargs) return FALSE; |
|
6171 | 6171 | $arglist = func_get_args(); |
6172 | - if( $this->_notExistProp( $arglist[0] )) return FALSE; |
|
6173 | - if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] ))) |
|
6172 | + if ($this->_notExistProp($arglist[0])) return FALSE; |
|
6173 | + if (!$this->getConfig('allowEmpty') && (!isset($arglist[1]) || empty($arglist[1]))) |
|
6174 | 6174 | return FALSE; |
6175 | - $arglist[0] = strtoupper( $arglist[0] ); |
|
6176 | - for( $argix=$numargs; $argix < 12; $argix++ ) { |
|
6177 | - if( !isset( $arglist[$argix] )) |
|
6175 | + $arglist[0] = strtoupper($arglist[0]); |
|
6176 | + for ($argix = $numargs; $argix < 12; $argix++) { |
|
6177 | + if (!isset($arglist[$argix])) |
|
6178 | 6178 | $arglist[$argix] = null; |
6179 | 6179 | } |
6180 | - switch( $arglist[0] ) { |
|
6180 | + switch ($arglist[0]) { |
|
6181 | 6181 | case 'ACTION': |
6182 | - return $this->setAction( $arglist[1], $arglist[2] ); |
|
6182 | + return $this->setAction($arglist[1], $arglist[2]); |
|
6183 | 6183 | case 'ATTACH': |
6184 | - return $this->setAttach( $arglist[1], $arglist[2], $arglist[3] ); |
|
6184 | + return $this->setAttach($arglist[1], $arglist[2], $arglist[3]); |
|
6185 | 6185 | case 'ATTENDEE': |
6186 | - return $this->setAttendee( $arglist[1], $arglist[2], $arglist[3] ); |
|
6186 | + return $this->setAttendee($arglist[1], $arglist[2], $arglist[3]); |
|
6187 | 6187 | case 'CATEGORIES': |
6188 | - return $this->setCategories( $arglist[1], $arglist[2], $arglist[3] ); |
|
6188 | + return $this->setCategories($arglist[1], $arglist[2], $arglist[3]); |
|
6189 | 6189 | case 'CLASS': |
6190 | - return $this->setClass( $arglist[1], $arglist[2] ); |
|
6190 | + return $this->setClass($arglist[1], $arglist[2]); |
|
6191 | 6191 | case 'COMMENT': |
6192 | - return $this->setComment( $arglist[1], $arglist[2], $arglist[3] ); |
|
6192 | + return $this->setComment($arglist[1], $arglist[2], $arglist[3]); |
|
6193 | 6193 | case 'COMPLETED': |
6194 | - return $this->setCompleted( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] ); |
|
6194 | + return $this->setCompleted($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7]); |
|
6195 | 6195 | case 'CONTACT': |
6196 | - return $this->setContact( $arglist[1], $arglist[2], $arglist[3] ); |
|
6196 | + return $this->setContact($arglist[1], $arglist[2], $arglist[3]); |
|
6197 | 6197 | case 'CREATED': |
6198 | - return $this->setCreated( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] ); |
|
6198 | + return $this->setCreated($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7]); |
|
6199 | 6199 | case 'DESCRIPTION': |
6200 | - return $this->setDescription( $arglist[1], $arglist[2], $arglist[3] ); |
|
6200 | + return $this->setDescription($arglist[1], $arglist[2], $arglist[3]); |
|
6201 | 6201 | case 'DTEND': |
6202 | - return $this->setDtend( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] ); |
|
6202 | + return $this->setDtend($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8]); |
|
6203 | 6203 | case 'DTSTAMP': |
6204 | - return $this->setDtstamp( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] ); |
|
6204 | + return $this->setDtstamp($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7]); |
|
6205 | 6205 | case 'DTSTART': |
6206 | - return $this->setDtstart( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] ); |
|
6206 | + return $this->setDtstart($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8]); |
|
6207 | 6207 | case 'DUE': |
6208 | - return $this->setDue( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] ); |
|
6208 | + return $this->setDue($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8]); |
|
6209 | 6209 | case 'DURATION': |
6210 | - return $this->setDuration( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6] ); |
|
6210 | + return $this->setDuration($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6]); |
|
6211 | 6211 | case 'EXDATE': |
6212 | - return $this->setExdate( $arglist[1], $arglist[2], $arglist[3] ); |
|
6212 | + return $this->setExdate($arglist[1], $arglist[2], $arglist[3]); |
|
6213 | 6213 | case 'EXRULE': |
6214 | - return $this->setExrule( $arglist[1], $arglist[2], $arglist[3] ); |
|
6214 | + return $this->setExrule($arglist[1], $arglist[2], $arglist[3]); |
|
6215 | 6215 | case 'FREEBUSY': |
6216 | - return $this->setFreebusy( $arglist[1], $arglist[2], $arglist[3], $arglist[4] ); |
|
6216 | + return $this->setFreebusy($arglist[1], $arglist[2], $arglist[3], $arglist[4]); |
|
6217 | 6217 | case 'GEO': |
6218 | - return $this->setGeo( $arglist[1], $arglist[2], $arglist[3] ); |
|
6218 | + return $this->setGeo($arglist[1], $arglist[2], $arglist[3]); |
|
6219 | 6219 | case 'LAST-MODIFIED': |
6220 | - return $this->setLastModified( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] ); |
|
6220 | + return $this->setLastModified($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7]); |
|
6221 | 6221 | case 'LOCATION': |
6222 | - return $this->setLocation( $arglist[1], $arglist[2] ); |
|
6222 | + return $this->setLocation($arglist[1], $arglist[2]); |
|
6223 | 6223 | case 'ORGANIZER': |
6224 | - return $this->setOrganizer( $arglist[1], $arglist[2] ); |
|
6224 | + return $this->setOrganizer($arglist[1], $arglist[2]); |
|
6225 | 6225 | case 'PERCENT-COMPLETE': |
6226 | - return $this->setPercentComplete( $arglist[1], $arglist[2] ); |
|
6226 | + return $this->setPercentComplete($arglist[1], $arglist[2]); |
|
6227 | 6227 | case 'PRIORITY': |
6228 | - return $this->setPriority( $arglist[1], $arglist[2] ); |
|
6228 | + return $this->setPriority($arglist[1], $arglist[2]); |
|
6229 | 6229 | case 'RDATE': |
6230 | - return $this->setRdate( $arglist[1], $arglist[2], $arglist[3] ); |
|
6230 | + return $this->setRdate($arglist[1], $arglist[2], $arglist[3]); |
|
6231 | 6231 | case 'RECURRENCE-ID': |
6232 | - return $this->setRecurrenceid( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] ); |
|
6232 | + return $this->setRecurrenceid($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8]); |
|
6233 | 6233 | case 'RELATED-TO': |
6234 | - return $this->setRelatedTo( $arglist[1], $arglist[2], $arglist[3] ); |
|
6234 | + return $this->setRelatedTo($arglist[1], $arglist[2], $arglist[3]); |
|
6235 | 6235 | case 'REPEAT': |
6236 | - return $this->setRepeat( $arglist[1], $arglist[2] ); |
|
6236 | + return $this->setRepeat($arglist[1], $arglist[2]); |
|
6237 | 6237 | case 'REQUEST-STATUS': |
6238 | - return $this->setRequestStatus( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5] ); |
|
6238 | + return $this->setRequestStatus($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5]); |
|
6239 | 6239 | case 'RESOURCES': |
6240 | - return $this->setResources( $arglist[1], $arglist[2], $arglist[3] ); |
|
6240 | + return $this->setResources($arglist[1], $arglist[2], $arglist[3]); |
|
6241 | 6241 | case 'RRULE': |
6242 | - return $this->setRrule( $arglist[1], $arglist[2], $arglist[3] ); |
|
6242 | + return $this->setRrule($arglist[1], $arglist[2], $arglist[3]); |
|
6243 | 6243 | case 'SEQUENCE': |
6244 | - return $this->setSequence( $arglist[1], $arglist[2] ); |
|
6244 | + return $this->setSequence($arglist[1], $arglist[2]); |
|
6245 | 6245 | case 'STATUS': |
6246 | - return $this->setStatus( $arglist[1], $arglist[2] ); |
|
6246 | + return $this->setStatus($arglist[1], $arglist[2]); |
|
6247 | 6247 | case 'SUMMARY': |
6248 | - return $this->setSummary( $arglist[1], $arglist[2] ); |
|
6248 | + return $this->setSummary($arglist[1], $arglist[2]); |
|
6249 | 6249 | case 'TRANSP': |
6250 | - return $this->setTransp( $arglist[1], $arglist[2] ); |
|
6250 | + return $this->setTransp($arglist[1], $arglist[2]); |
|
6251 | 6251 | case 'TRIGGER': |
6252 | - 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] ); |
|
6252 | + 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]); |
|
6253 | 6253 | case 'TZID': |
6254 | - return $this->setTzid( $arglist[1], $arglist[2] ); |
|
6254 | + return $this->setTzid($arglist[1], $arglist[2]); |
|
6255 | 6255 | case 'TZNAME': |
6256 | - return $this->setTzname( $arglist[1], $arglist[2], $arglist[3] ); |
|
6256 | + return $this->setTzname($arglist[1], $arglist[2], $arglist[3]); |
|
6257 | 6257 | case 'TZOFFSETFROM': |
6258 | - return $this->setTzoffsetfrom( $arglist[1], $arglist[2] ); |
|
6258 | + return $this->setTzoffsetfrom($arglist[1], $arglist[2]); |
|
6259 | 6259 | case 'TZOFFSETTO': |
6260 | - return $this->setTzoffsetto( $arglist[1], $arglist[2] ); |
|
6260 | + return $this->setTzoffsetto($arglist[1], $arglist[2]); |
|
6261 | 6261 | case 'TZURL': |
6262 | - return $this->setTzurl( $arglist[1], $arglist[2] ); |
|
6262 | + return $this->setTzurl($arglist[1], $arglist[2]); |
|
6263 | 6263 | case 'UID': |
6264 | - return $this->setUid( $arglist[1], $arglist[2] ); |
|
6264 | + return $this->setUid($arglist[1], $arglist[2]); |
|
6265 | 6265 | case 'URL': |
6266 | - return $this->setUrl( $arglist[1], $arglist[2] ); |
|
6266 | + return $this->setUrl($arglist[1], $arglist[2]); |
|
6267 | 6267 | default: |
6268 | - return $this->setXprop( $arglist[0], $arglist[1], $arglist[2] ); |
|
6268 | + return $this->setXprop($arglist[0], $arglist[1], $arglist[2]); |
|
6269 | 6269 | } |
6270 | 6270 | return FALSE; |
6271 | 6271 | } |
@@ -6279,18 +6279,18 @@ discard block |
||
6279 | 6279 | * @return bool FALSE if error occurs during parsing |
6280 | 6280 | * |
6281 | 6281 | */ |
6282 | - function parse( $unparsedtext=null ) { |
|
6283 | - if( $unparsedtext ) { |
|
6282 | + function parse($unparsedtext = null) { |
|
6283 | + if ($unparsedtext) { |
|
6284 | 6284 | $this->unparsed = array(); |
6285 | - if( is_array( $unparsedtext )) { |
|
6285 | + if (is_array($unparsedtext)) { |
|
6286 | 6286 | $comp = & $this; |
6287 | - foreach ( $unparsedtext as $line ) { |
|
6288 | - if( 'END:VALARM' == strtoupper( substr( $line, 0, 10 ))) { |
|
6289 | - $this->setComponent( $comp ); |
|
6290 | - $comp = & $this; |
|
6287 | + foreach ($unparsedtext as $line) { |
|
6288 | + if ('END:VALARM' == strtoupper(substr($line, 0, 10))) { |
|
6289 | + $this->setComponent($comp); |
|
6290 | + $comp = & $this; |
|
6291 | 6291 | continue; |
6292 | 6292 | } |
6293 | - elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) { |
|
6293 | + elseif ('BEGIN:VALARM' == strtoupper(substr($line, 0, 12))) { |
|
6294 | 6294 | $comp = new valarm(); |
6295 | 6295 | continue; |
6296 | 6296 | } |
@@ -6299,215 +6299,215 @@ discard block |
||
6299 | 6299 | } |
6300 | 6300 | } |
6301 | 6301 | else |
6302 | - $this->unparsed = array( trim( $unparsedtext )); |
|
6302 | + $this->unparsed = array(trim($unparsedtext)); |
|
6303 | 6303 | } |
6304 | - elseif( !isset( $this->unparsed )) |
|
6304 | + elseif (!isset($this->unparsed)) |
|
6305 | 6305 | $this->unparsed = array(); |
6306 | 6306 | /* concatenate property values spread over several lines */ |
6307 | 6307 | $lastix = -1; |
6308 | - $propnames = array( 'action', 'attach', 'attendee', 'categories', 'comment', 'completed' |
|
6308 | + $propnames = array('action', 'attach', 'attendee', 'categories', 'comment', 'completed' |
|
6309 | 6309 | , 'contact', 'class', 'created', 'description', 'dtend', 'dtstart' |
6310 | 6310 | , 'dtstamp', 'due', 'duration', 'exdate', 'exrule', 'freebusy', 'geo' |
6311 | 6311 | , 'last-modified', 'location', 'organizer', 'percent-complete' |
6312 | 6312 | , 'priority', 'rdate', 'recurrence-id', 'related-to', 'repeat' |
6313 | 6313 | , 'request-status', 'resources', 'rrule', 'sequence', 'status' |
6314 | 6314 | , 'summary', 'transp', 'trigger', 'tzid', 'tzname', 'tzoffsetfrom' |
6315 | - , 'tzoffsetto', 'tzurl', 'uid', 'url', 'x-' ); |
|
6315 | + , 'tzoffsetto', 'tzurl', 'uid', 'url', 'x-'); |
|
6316 | 6316 | $proprows = array(); |
6317 | - foreach( $this->unparsed as $line ) { |
|
6317 | + foreach ($this->unparsed as $line) { |
|
6318 | 6318 | $newProp = FALSE; |
6319 | - foreach ( $propnames as $propname ) { |
|
6320 | - if( $propname == strtolower( substr( $line, 0, strlen( $propname )))) { |
|
6319 | + foreach ($propnames as $propname) { |
|
6320 | + if ($propname == strtolower(substr($line, 0, strlen($propname)))) { |
|
6321 | 6321 | $newProp = TRUE; |
6322 | 6322 | break; |
6323 | 6323 | } |
6324 | 6324 | } |
6325 | - if( $newProp ) { |
|
6325 | + if ($newProp) { |
|
6326 | 6326 | $newProp = FALSE; |
6327 | 6327 | $lastix++; |
6328 | - $proprows[$lastix] = $line; |
|
6328 | + $proprows[$lastix] = $line; |
|
6329 | 6329 | } |
6330 | 6330 | else { |
6331 | 6331 | /* remove line breaks */ |
6332 | - if(( '\n' == substr( $proprows[$lastix], -2 )) && |
|
6333 | - ( ' ' == substr( $line, 0, 1 ))) { |
|
6334 | - $proprows[$lastix] = substr( $proprows[$lastix], 0, strlen( $proprows[$lastix] ) - 2 ); |
|
6335 | - $line = substr( $line, 1 ); |
|
6332 | + if (('\n' == substr($proprows[$lastix], -2)) && |
|
6333 | + (' ' == substr($line, 0, 1))) { |
|
6334 | + $proprows[$lastix] = substr($proprows[$lastix], 0, strlen($proprows[$lastix]) - 2); |
|
6335 | + $line = substr($line, 1); |
|
6336 | 6336 | } |
6337 | 6337 | $proprows[$lastix] .= $line; |
6338 | 6338 | } |
6339 | 6339 | } |
6340 | 6340 | /* parse each property 'line' */ |
6341 | - foreach( $proprows as $line ) { |
|
6342 | - $line = str_replace( "\n ", '', $line ); |
|
6343 | - if( '\n' == substr( $line, -2 )) |
|
6344 | - $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
6341 | + foreach ($proprows as $line) { |
|
6342 | + $line = str_replace("\n ", '', $line); |
|
6343 | + if ('\n' == substr($line, -2)) |
|
6344 | + $line = substr($line, 0, strlen($line) - 2); |
|
6345 | 6345 | /* get propname, (problem with x-properties, otherwise in previous loop) */ |
6346 | 6346 | $cix = $propname = null; |
6347 | - for( $cix=0; $cix < strlen( $line ); $cix++ ) { |
|
6348 | - if( in_array( $line{$cix}, array( ':', ';' ))) |
|
6347 | + for ($cix = 0; $cix < strlen($line); $cix++) { |
|
6348 | + if (in_array($line{$cix}, array(':', ';'))) |
|
6349 | 6349 | break; |
6350 | 6350 | else { |
6351 | 6351 | $propname .= $line{$cix}; |
6352 | 6352 | } |
6353 | 6353 | } |
6354 | - if(( 'x-' == substr( $propname, 0, 2 )) || ( 'X-' == substr( $propname, 0, 2 ))) { |
|
6354 | + if (('x-' == substr($propname, 0, 2)) || ('X-' == substr($propname, 0, 2))) { |
|
6355 | 6355 | $propname2 = $propname; |
6356 | 6356 | $propname = 'X-'; |
6357 | 6357 | } |
6358 | 6358 | /* rest of the line is opt.params and value */ |
6359 | - $line = substr( $line, $cix ); |
|
6359 | + $line = substr($line, $cix); |
|
6360 | 6360 | /* separate attributes from value */ |
6361 | 6361 | $attr = array(); |
6362 | 6362 | $attrix = -1; |
6363 | - $strlen = strlen( $line ); |
|
6364 | - for( $cix=0; $cix < $strlen; $cix++ ) { |
|
6365 | - if(( ':' == $line{$cix} ) && |
|
6366 | - ( '://' != substr( $line, $cix, 3 )) && |
|
6367 | - ( 'mailto:' != strtolower( substr( $line, $cix - 6, 7 )))) { |
|
6363 | + $strlen = strlen($line); |
|
6364 | + for ($cix = 0; $cix < $strlen; $cix++) { |
|
6365 | + if ((':' == $line{$cix} ) && |
|
6366 | + ('://' != substr($line, $cix, 3)) && |
|
6367 | + ('mailto:' != strtolower(substr($line, $cix - 6, 7)))) { |
|
6368 | 6368 | $attrEnd = TRUE; |
6369 | - if(( $cix < ( $strlen - 4 )) && |
|
6370 | - ctype_digit( substr( $line, $cix+1, 4 ))) { // an URI with a (4pos) portnr?? |
|
6371 | - for( $c2ix = $cix; 3 < $c2ix; $c2ix-- ) { |
|
6372 | - if( '://' == substr( $line, $c2ix - 2, 3 )) { |
|
6369 | + if (($cix < ($strlen - 4)) && |
|
6370 | + ctype_digit(substr($line, $cix + 1, 4))) { // an URI with a (4pos) portnr?? |
|
6371 | + for ($c2ix = $cix; 3 < $c2ix; $c2ix--) { |
|
6372 | + if ('://' == substr($line, $c2ix - 2, 3)) { |
|
6373 | 6373 | $attrEnd = FALSE; |
6374 | 6374 | break; // an URI with a portnr!! |
6375 | 6375 | } |
6376 | 6376 | } |
6377 | 6377 | } |
6378 | - if( $attrEnd) { |
|
6379 | - $line = substr( $line, $cix + 1 ); |
|
6378 | + if ($attrEnd) { |
|
6379 | + $line = substr($line, $cix + 1); |
|
6380 | 6380 | break; |
6381 | 6381 | } |
6382 | 6382 | } |
6383 | - if( ';' == $line{$cix} ) |
|
6383 | + if (';' == $line{$cix} ) |
|
6384 | 6384 | $attr[++$attrix] = null; |
6385 | 6385 | else |
6386 | 6386 | $attr[$attrix] .= $line{$cix}; |
6387 | 6387 | } |
6388 | 6388 | /* make attributes in array format */ |
6389 | 6389 | $propattr = array(); |
6390 | - foreach( $attr as $attribute ) { |
|
6391 | - $attrsplit = explode( '=', $attribute, 2 ); |
|
6392 | - if( 1 < count( $attrsplit )) |
|
6390 | + foreach ($attr as $attribute) { |
|
6391 | + $attrsplit = explode('=', $attribute, 2); |
|
6392 | + if (1 < count($attrsplit)) |
|
6393 | 6393 | $propattr[$attrsplit[0]] = $attrsplit[1]; |
6394 | 6394 | else |
6395 | 6395 | $propattr[] = $attribute; |
6396 | 6396 | } |
6397 | 6397 | /* call setProperty( $propname.. . */ |
6398 | - switch( $propname ) { |
|
6398 | + switch ($propname) { |
|
6399 | 6399 | case 'ATTENDEE': |
6400 | - foreach( $propattr as $pix => $attr ) { |
|
6401 | - $attr2 = explode( ',', $attr ); |
|
6402 | - if( 1 < count( $attr2 )) |
|
6400 | + foreach ($propattr as $pix => $attr) { |
|
6401 | + $attr2 = explode(',', $attr); |
|
6402 | + if (1 < count($attr2)) |
|
6403 | 6403 | $propattr[$pix] = $attr2; |
6404 | 6404 | } |
6405 | - $this->setProperty( $propname, $line, $propattr ); |
|
6405 | + $this->setProperty($propname, $line, $propattr); |
|
6406 | 6406 | break; |
6407 | 6407 | case 'CATEGORIES': |
6408 | 6408 | case 'RESOURCES': |
6409 | - if( FALSE !== strpos( $line, ',' )) { |
|
6410 | - $content = explode( ',', $line ); |
|
6411 | - $clen = count( $content ); |
|
6412 | - for( $cix = 0; $cix < $clen; $cix++ ) { |
|
6413 | - if( "\\" == substr($content[$cix], -1)) { |
|
6409 | + if (FALSE !== strpos($line, ',')) { |
|
6410 | + $content = explode(',', $line); |
|
6411 | + $clen = count($content); |
|
6412 | + for ($cix = 0; $cix < $clen; $cix++) { |
|
6413 | + if ("\\" == substr($content[$cix], -1)) { |
|
6414 | 6414 | $content[$cix] .= ','.$content[$cix + 1]; |
6415 | 6415 | unset($content[$cix + 1]); |
6416 | 6416 | $cix++; |
6417 | 6417 | } |
6418 | 6418 | } |
6419 | - if( 1 < count( $content )) { |
|
6420 | - $content = array_values( $content ); |
|
6421 | - foreach( $content as $cix => $contentPart ) |
|
6422 | - $content[$cix] = $this->_strunrep( $contentPart ); |
|
6423 | - $this->setProperty( $propname, $content, $propattr ); |
|
6419 | + if (1 < count($content)) { |
|
6420 | + $content = array_values($content); |
|
6421 | + foreach ($content as $cix => $contentPart) |
|
6422 | + $content[$cix] = $this->_strunrep($contentPart); |
|
6423 | + $this->setProperty($propname, $content, $propattr); |
|
6424 | 6424 | break; |
6425 | 6425 | } |
6426 | 6426 | else |
6427 | - $line = reset( $content ); |
|
6427 | + $line = reset($content); |
|
6428 | 6428 | } |
6429 | 6429 | case 'X-': |
6430 | - $propname = ( isset( $propname2 )) ? $propname2 : $propname; |
|
6430 | + $propname = (isset($propname2)) ? $propname2 : $propname; |
|
6431 | 6431 | case 'COMMENT': |
6432 | 6432 | case 'CONTACT': |
6433 | 6433 | case 'DESCRIPTION': |
6434 | 6434 | case 'LOCATION': |
6435 | 6435 | case 'SUMMARY': |
6436 | - if( empty( $line )) |
|
6436 | + if (empty($line)) |
|
6437 | 6437 | $propattr = null; |
6438 | - $this->setProperty( $propname, $this->_strunrep( $line ), $propattr ); |
|
6439 | - unset( $propname2 ); |
|
6438 | + $this->setProperty($propname, $this->_strunrep($line), $propattr); |
|
6439 | + unset($propname2); |
|
6440 | 6440 | break; |
6441 | 6441 | case 'REQUEST-STATUS': |
6442 | - $values = explode( ';', $line, 3 ); |
|
6443 | - $values[1] = ( !isset( $values[1] )) ? null : $this->_strunrep( $values[1] ); |
|
6444 | - $values[2] = ( !isset( $values[2] )) ? null : $this->_strunrep( $values[2] ); |
|
6445 | - $this->setProperty( $propname |
|
6442 | + $values = explode(';', $line, 3); |
|
6443 | + $values[1] = (!isset($values[1])) ? null : $this->_strunrep($values[1]); |
|
6444 | + $values[2] = (!isset($values[2])) ? null : $this->_strunrep($values[2]); |
|
6445 | + $this->setProperty($propname |
|
6446 | 6446 | , $values[0] // statcode |
6447 | 6447 | , $values[1] // statdesc |
6448 | 6448 | , $values[2] // extdata |
6449 | - , $propattr ); |
|
6449 | + , $propattr); |
|
6450 | 6450 | break; |
6451 | 6451 | case 'FREEBUSY': |
6452 | - $fbtype = ( isset( $propattr['FBTYPE'] )) ? $propattr['FBTYPE'] : ''; // force setting default, if missing |
|
6453 | - unset( $propattr['FBTYPE'] ); |
|
6454 | - $values = explode( ',', $line ); |
|
6455 | - foreach( $values as $vix => $value ) { |
|
6456 | - $value2 = explode( '/', $value ); |
|
6457 | - if( 1 < count( $value2 )) |
|
6452 | + $fbtype = (isset($propattr['FBTYPE'])) ? $propattr['FBTYPE'] : ''; // force setting default, if missing |
|
6453 | + unset($propattr['FBTYPE']); |
|
6454 | + $values = explode(',', $line); |
|
6455 | + foreach ($values as $vix => $value) { |
|
6456 | + $value2 = explode('/', $value); |
|
6457 | + if (1 < count($value2)) |
|
6458 | 6458 | $values[$vix] = $value2; |
6459 | 6459 | } |
6460 | - $this->setProperty( $propname, $fbtype, $values, $propattr ); |
|
6460 | + $this->setProperty($propname, $fbtype, $values, $propattr); |
|
6461 | 6461 | break; |
6462 | 6462 | case 'GEO': |
6463 | - $value = explode( ';', $line, 2 ); |
|
6464 | - if( 2 > count( $value )) |
|
6463 | + $value = explode(';', $line, 2); |
|
6464 | + if (2 > count($value)) |
|
6465 | 6465 | $value[1] = null; |
6466 | - $this->setProperty( $propname, $value[0], $value[1], $propattr ); |
|
6466 | + $this->setProperty($propname, $value[0], $value[1], $propattr); |
|
6467 | 6467 | break; |
6468 | 6468 | case 'EXDATE': |
6469 | - $values = ( !empty( $line )) ? explode( ',', $line ) : null; |
|
6470 | - $this->setProperty( $propname, $values, $propattr ); |
|
6469 | + $values = (!empty($line)) ? explode(',', $line) : null; |
|
6470 | + $this->setProperty($propname, $values, $propattr); |
|
6471 | 6471 | break; |
6472 | 6472 | case 'RDATE': |
6473 | - if( empty( $line )) { |
|
6474 | - $this->setProperty( $propname, $line, $propattr ); |
|
6473 | + if (empty($line)) { |
|
6474 | + $this->setProperty($propname, $line, $propattr); |
|
6475 | 6475 | break; |
6476 | 6476 | } |
6477 | - $values = explode( ',', $line ); |
|
6478 | - foreach( $values as $vix => $value ) { |
|
6479 | - $value2 = explode( '/', $value ); |
|
6480 | - if( 1 < count( $value2 )) |
|
6477 | + $values = explode(',', $line); |
|
6478 | + foreach ($values as $vix => $value) { |
|
6479 | + $value2 = explode('/', $value); |
|
6480 | + if (1 < count($value2)) |
|
6481 | 6481 | $values[$vix] = $value2; |
6482 | 6482 | } |
6483 | - $this->setProperty( $propname, $values, $propattr ); |
|
6483 | + $this->setProperty($propname, $values, $propattr); |
|
6484 | 6484 | break; |
6485 | 6485 | case 'EXRULE': |
6486 | 6486 | case 'RRULE': |
6487 | - $values = explode( ';', $line ); |
|
6487 | + $values = explode(';', $line); |
|
6488 | 6488 | $recur = array(); |
6489 | - foreach( $values as $value2 ) { |
|
6490 | - if( empty( $value2 )) |
|
6489 | + foreach ($values as $value2) { |
|
6490 | + if (empty($value2)) |
|
6491 | 6491 | continue; // ;-char in ending position ??? |
6492 | - $value3 = explode( '=', $value2, 2 ); |
|
6493 | - $rulelabel = strtoupper( $value3[0] ); |
|
6494 | - switch( $rulelabel ) { |
|
6492 | + $value3 = explode('=', $value2, 2); |
|
6493 | + $rulelabel = strtoupper($value3[0]); |
|
6494 | + switch ($rulelabel) { |
|
6495 | 6495 | case 'BYDAY': { |
6496 | - $value4 = explode( ',', $value3[1] ); |
|
6497 | - if( 1 < count( $value4 )) { |
|
6498 | - foreach( $value4 as $v5ix => $value5 ) { |
|
6496 | + $value4 = explode(',', $value3[1]); |
|
6497 | + if (1 < count($value4)) { |
|
6498 | + foreach ($value4 as $v5ix => $value5) { |
|
6499 | 6499 | $value6 = array(); |
6500 | 6500 | $dayno = $dayname = null; |
6501 | - $value5 = trim( (string) $value5 ); |
|
6502 | - if(( ctype_alpha( substr( $value5, -1 ))) && |
|
6503 | - ( ctype_alpha( substr( $value5, -2, 1 )))) { |
|
6504 | - $dayname = substr( $value5, -2, 2 ); |
|
6505 | - if( 2 < strlen( $value5 )) |
|
6506 | - $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
6501 | + $value5 = trim((string) $value5); |
|
6502 | + if ((ctype_alpha(substr($value5, -1))) && |
|
6503 | + (ctype_alpha(substr($value5, -2, 1)))) { |
|
6504 | + $dayname = substr($value5, -2, 2); |
|
6505 | + if (2 < strlen($value5)) |
|
6506 | + $dayno = substr($value5, 0, (strlen($value5) - 2)); |
|
6507 | 6507 | } |
6508 | - if( $dayno ) |
|
6508 | + if ($dayno) |
|
6509 | 6509 | $value6[] = $dayno; |
6510 | - if( $dayname ) |
|
6510 | + if ($dayname) |
|
6511 | 6511 | $value6['DAY'] = $dayname; |
6512 | 6512 | $value4[$v5ix] = $value6; |
6513 | 6513 | } |
@@ -6515,41 +6515,41 @@ discard block |
||
6515 | 6515 | else { |
6516 | 6516 | $value4 = array(); |
6517 | 6517 | $dayno = $dayname = null; |
6518 | - $value5 = trim( (string) $value3[1] ); |
|
6519 | - if(( ctype_alpha( substr( $value5, -1 ))) && |
|
6520 | - ( ctype_alpha( substr( $value5, -2, 1 )))) { |
|
6521 | - $dayname = substr( $value5, -2, 2 ); |
|
6522 | - if( 2 < strlen( $value5 )) |
|
6523 | - $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
6518 | + $value5 = trim((string) $value3[1]); |
|
6519 | + if ((ctype_alpha(substr($value5, -1))) && |
|
6520 | + (ctype_alpha(substr($value5, -2, 1)))) { |
|
6521 | + $dayname = substr($value5, -2, 2); |
|
6522 | + if (2 < strlen($value5)) |
|
6523 | + $dayno = substr($value5, 0, (strlen($value5) - 2)); |
|
6524 | 6524 | } |
6525 | - if( $dayno ) |
|
6525 | + if ($dayno) |
|
6526 | 6526 | $value4[] = $dayno; |
6527 | - if( $dayname ) |
|
6527 | + if ($dayname) |
|
6528 | 6528 | $value4['DAY'] = $dayname; |
6529 | 6529 | } |
6530 | 6530 | $recur[$rulelabel] = $value4; |
6531 | 6531 | break; |
6532 | 6532 | } |
6533 | 6533 | default: { |
6534 | - $value4 = explode( ',', $value3[1] ); |
|
6535 | - if( 1 < count( $value4 )) |
|
6534 | + $value4 = explode(',', $value3[1]); |
|
6535 | + if (1 < count($value4)) |
|
6536 | 6536 | $value3[1] = $value4; |
6537 | 6537 | $recur[$rulelabel] = $value3[1]; |
6538 | 6538 | break; |
6539 | 6539 | } |
6540 | 6540 | } // end - switch $rulelabel |
6541 | 6541 | } // end - foreach( $values.. . |
6542 | - $this->setProperty( $propname, $recur, $propattr ); |
|
6542 | + $this->setProperty($propname, $recur, $propattr); |
|
6543 | 6543 | break; |
6544 | 6544 | default: |
6545 | - $this->setProperty( $propname, $line, $propattr ); |
|
6545 | + $this->setProperty($propname, $line, $propattr); |
|
6546 | 6546 | break; |
6547 | 6547 | } // end switch( $propname.. . |
6548 | 6548 | } // end - foreach( $proprows.. . |
6549 | - unset( $this->unparsed, $proprows ); |
|
6550 | - if( isset( $this->components ) && is_array( $this->components ) && ( 0 < count( $this->components ))) { |
|
6551 | - for( $six = 0; $six < count( $this->components ); $six++ ) { |
|
6552 | - if( !empty( $this->components[$six]->unparsed )) |
|
6549 | + unset($this->unparsed, $proprows); |
|
6550 | + if (isset($this->components) && is_array($this->components) && (0 < count($this->components))) { |
|
6551 | + for ($six = 0; $six < count($this->components); $six++) { |
|
6552 | + if (!empty($this->components[$six]->unparsed)) |
|
6553 | 6553 | $this->components[$six]->parse(); |
6554 | 6554 | } |
6555 | 6555 | } |
@@ -6566,7 +6566,7 @@ discard block |
||
6566 | 6566 | function copy() { |
6567 | 6567 | $serialized_contents = serialize($this); |
6568 | 6568 | $copy = unserialize($serialized_contents); |
6569 | - unset( $copy->propix ); |
|
6569 | + unset($copy->propix); |
|
6570 | 6570 | return $copy; |
6571 | 6571 | } |
6572 | 6572 | /*********************************************************************************/ |
@@ -6580,34 +6580,34 @@ discard block |
||
6580 | 6580 | * @param mixed $arg2 optional, ordno if arg1 = component type |
6581 | 6581 | * @return void |
6582 | 6582 | */ |
6583 | - function deleteComponent( $arg1, $arg2=FALSE ) { |
|
6584 | - if( !isset( $this->components )) return FALSE; |
|
6583 | + function deleteComponent($arg1, $arg2 = FALSE) { |
|
6584 | + if (!isset($this->components)) return FALSE; |
|
6585 | 6585 | $argType = $index = null; |
6586 | - if ( ctype_digit( (string) $arg1 )) { |
|
6586 | + if (ctype_digit((string) $arg1)) { |
|
6587 | 6587 | $argType = 'INDEX'; |
6588 | 6588 | $index = (int) $arg1 - 1; |
6589 | 6589 | } |
6590 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6591 | - $argType = strtolower( $arg1 ); |
|
6592 | - $index = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0; |
|
6590 | + elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) { |
|
6591 | + $argType = strtolower($arg1); |
|
6592 | + $index = (!empty($arg2) && ctype_digit((string) $arg2)) ? ((int) $arg2 - 1) : 0; |
|
6593 | 6593 | } |
6594 | 6594 | $cix2dC = 0; |
6595 | - foreach ( $this->components as $cix => $component) { |
|
6596 | - if( empty( $component )) continue; |
|
6597 | - unset( $component->propix ); |
|
6598 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
|
6599 | - unset( $this->components[$cix] ); |
|
6595 | + foreach ($this->components as $cix => $component) { |
|
6596 | + if (empty($component)) continue; |
|
6597 | + unset($component->propix); |
|
6598 | + if (('INDEX' == $argType) && ($index == $cix)) { |
|
6599 | + unset($this->components[$cix]); |
|
6600 | 6600 | return TRUE; |
6601 | 6601 | } |
6602 | - elseif( $argType == $component->objName ) { |
|
6603 | - if( $index == $cix2dC ) { |
|
6604 | - unset( $this->components[$cix] ); |
|
6602 | + elseif ($argType == $component->objName) { |
|
6603 | + if ($index == $cix2dC) { |
|
6604 | + unset($this->components[$cix]); |
|
6605 | 6605 | return TRUE; |
6606 | 6606 | } |
6607 | 6607 | $cix2dC++; |
6608 | 6608 | } |
6609 | - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
6610 | - unset( $this->components[$cix] ); |
|
6609 | + elseif (!$argType && ($arg1 == $component->getProperty('uid'))) { |
|
6610 | + unset($this->components[$cix]); |
|
6611 | 6611 | return TRUE; |
6612 | 6612 | } |
6613 | 6613 | } |
@@ -6622,50 +6622,50 @@ discard block |
||
6622 | 6622 | * @param mixed $arg2 optional, ordno if arg1 = component type |
6623 | 6623 | * @return object |
6624 | 6624 | */ |
6625 | - function getComponent ( $arg1=FALSE, $arg2=FALSE ) { |
|
6626 | - if( !isset( $this->components )) return FALSE; |
|
6625 | + function getComponent($arg1 = FALSE, $arg2 = FALSE) { |
|
6626 | + if (!isset($this->components)) return FALSE; |
|
6627 | 6627 | $index = $argType = null; |
6628 | - if ( !$arg1 ) { |
|
6628 | + if (!$arg1) { |
|
6629 | 6629 | $argType = 'INDEX'; |
6630 | 6630 | $index = $this->compix['INDEX'] = |
6631 | - ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1; |
|
6631 | + (isset($this->compix['INDEX'])) ? $this->compix['INDEX'] + 1 : 1; |
|
6632 | 6632 | } |
6633 | - elseif ( ctype_digit( (string) $arg1 )) { |
|
6633 | + elseif (ctype_digit((string) $arg1)) { |
|
6634 | 6634 | $argType = 'INDEX'; |
6635 | 6635 | $index = (int) $arg1; |
6636 | - unset( $this->compix ); |
|
6636 | + unset($this->compix); |
|
6637 | 6637 | } |
6638 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6639 | - unset( $this->compix['INDEX'] ); |
|
6640 | - $argType = strtolower( $arg1 ); |
|
6641 | - if( !$arg2 ) |
|
6638 | + elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) { |
|
6639 | + unset($this->compix['INDEX']); |
|
6640 | + $argType = strtolower($arg1); |
|
6641 | + if (!$arg2) |
|
6642 | 6642 | $index = $this->compix[$argType] = |
6643 | - ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1; |
|
6643 | + (isset($this->compix[$argType])) ? $this->compix[$argType] + 1 : 1; |
|
6644 | 6644 | else |
6645 | 6645 | $index = (int) $arg2; |
6646 | 6646 | } |
6647 | - $index -= 1; |
|
6648 | - $ckeys = array_keys( $this->components ); |
|
6649 | - if( !empty( $index) && ( $index > end( $ckeys ))) |
|
6647 | + $index -= 1; |
|
6648 | + $ckeys = array_keys($this->components); |
|
6649 | + if (!empty($index) && ($index > end($ckeys))) |
|
6650 | 6650 | return FALSE; |
6651 | 6651 | $cix2gC = 0; |
6652 | - foreach( $this->components as $cix => $component ) { |
|
6653 | - if( empty( $component )) continue; |
|
6654 | - unset( $component->propix ); |
|
6655 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) |
|
6652 | + foreach ($this->components as $cix => $component) { |
|
6653 | + if (empty($component)) continue; |
|
6654 | + unset($component->propix); |
|
6655 | + if (('INDEX' == $argType) && ($index == $cix)) |
|
6656 | 6656 | return $component->copy(); |
6657 | - elseif( $argType == $component->objName ) { |
|
6658 | - if( $index == $cix2gC ) |
|
6657 | + elseif ($argType == $component->objName) { |
|
6658 | + if ($index == $cix2gC) |
|
6659 | 6659 | return $component->copy(); |
6660 | 6660 | $cix2gC++; |
6661 | 6661 | } |
6662 | - elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) { |
|
6663 | - unset( $component->propix ); |
|
6662 | + elseif (!$argType && ($arg1 == $component->getProperty('uid'))) { |
|
6663 | + unset($component->propix); |
|
6664 | 6664 | return $component->copy(); |
6665 | 6665 | } |
6666 | 6666 | } |
6667 | 6667 | /* not found.. . */ |
6668 | - unset( $this->compix ); |
|
6668 | + unset($this->compix); |
|
6669 | 6669 | return false; |
6670 | 6670 | } |
6671 | 6671 | /** |
@@ -6676,8 +6676,8 @@ discard block |
||
6676 | 6676 | * @param object $component calendar component |
6677 | 6677 | * @return void |
6678 | 6678 | */ |
6679 | - function addSubComponent ( $component ) { |
|
6680 | - $this->setComponent( $component ); |
|
6679 | + function addSubComponent($component) { |
|
6680 | + $this->setComponent($component); |
|
6681 | 6681 | } |
6682 | 6682 | /** |
6683 | 6683 | * add calendar component as subcomponent to container for subcomponents |
@@ -6689,49 +6689,49 @@ discard block |
||
6689 | 6689 | * @param mixed $arg2 optional, ordno if arg1 = component type |
6690 | 6690 | * @return bool |
6691 | 6691 | */ |
6692 | - function setComponent( $component, $arg1=FALSE, $arg2=FALSE ) { |
|
6693 | - if( !isset( $this->components )) return FALSE; |
|
6694 | - if( '' >= $component->getConfig( 'language')) |
|
6695 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
6696 | - $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
|
6697 | - $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
|
6698 | - $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
|
6699 | - $component->setConfig( 'format', $this->getConfig( 'format' )); |
|
6700 | - if( !in_array( $component->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
6701 | - unset( $component->propix ); |
|
6692 | + function setComponent($component, $arg1 = FALSE, $arg2 = FALSE) { |
|
6693 | + if (!isset($this->components)) return FALSE; |
|
6694 | + if ('' >= $component->getConfig('language')) |
|
6695 | + $component->setConfig('language', $this->getConfig('language')); |
|
6696 | + $component->setConfig('allowEmpty', $this->getConfig('allowEmpty')); |
|
6697 | + $component->setConfig('nl', $this->getConfig('nl')); |
|
6698 | + $component->setConfig('unique_id', $this->getConfig('unique_id')); |
|
6699 | + $component->setConfig('format', $this->getConfig('format')); |
|
6700 | + if (!in_array($component->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) { |
|
6701 | + unset($component->propix); |
|
6702 | 6702 | /* make sure dtstamp and uid is set */ |
6703 | - $dummy = $component->getProperty( 'dtstamp' ); |
|
6704 | - $dummy = $component->getProperty( 'uid' ); |
|
6703 | + $dummy = $component->getProperty('dtstamp'); |
|
6704 | + $dummy = $component->getProperty('uid'); |
|
6705 | 6705 | } |
6706 | - if( !$arg1 ) { |
|
6706 | + if (!$arg1) { |
|
6707 | 6707 | $this->components[] = $component->copy(); |
6708 | 6708 | return TRUE; |
6709 | 6709 | } |
6710 | 6710 | $argType = $index = null; |
6711 | - if ( ctype_digit( (string) $arg1 )) { |
|
6711 | + if (ctype_digit((string) $arg1)) { |
|
6712 | 6712 | $argType = 'INDEX'; |
6713 | 6713 | $index = (int) $arg1 - 1; |
6714 | 6714 | } |
6715 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6716 | - $argType = strtolower( $arg1 ); |
|
6717 | - $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0; |
|
6715 | + elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) { |
|
6716 | + $argType = strtolower($arg1); |
|
6717 | + $index = (ctype_digit((string) $arg2)) ? ((int) $arg2) - 1 : 0; |
|
6718 | 6718 | } |
6719 | 6719 | $cix2sC = 0; |
6720 | - foreach ( $this->components as $cix => $component2 ) { |
|
6721 | - if( empty( $component2 )) continue; |
|
6722 | - unset( $component2->propix ); |
|
6723 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
|
6720 | + foreach ($this->components as $cix => $component2) { |
|
6721 | + if (empty($component2)) continue; |
|
6722 | + unset($component2->propix); |
|
6723 | + if (('INDEX' == $argType) && ($index == $cix)) { |
|
6724 | 6724 | $this->components[$cix] = $component->copy(); |
6725 | 6725 | return TRUE; |
6726 | 6726 | } |
6727 | - elseif( $argType == $component2->objName ) { |
|
6728 | - if( $index == $cix2sC ) { |
|
6727 | + elseif ($argType == $component2->objName) { |
|
6728 | + if ($index == $cix2sC) { |
|
6729 | 6729 | $this->components[$cix] = $component->copy(); |
6730 | 6730 | return TRUE; |
6731 | 6731 | } |
6732 | 6732 | $cix2sC++; |
6733 | 6733 | } |
6734 | - elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) { |
|
6734 | + elseif (!$argType && ($arg1 == $component2->getProperty('uid'))) { |
|
6735 | 6735 | $this->components[$cix] = $component->copy(); |
6736 | 6736 | return TRUE; |
6737 | 6737 | } |
@@ -6749,15 +6749,15 @@ discard block |
||
6749 | 6749 | */ |
6750 | 6750 | function createSubComponent() { |
6751 | 6751 | $output = null; |
6752 | - foreach( $this->components as $component ) { |
|
6753 | - if( empty( $component )) continue; |
|
6754 | - if( '' >= $component->getConfig( 'language')) |
|
6755 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
6756 | - $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
|
6757 | - $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
|
6758 | - $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
|
6759 | - $component->setConfig( 'format', $this->getConfig( 'format' )); |
|
6760 | - $output .= $component->createComponent( $this->xcaldecl ); |
|
6752 | + foreach ($this->components as $component) { |
|
6753 | + if (empty($component)) continue; |
|
6754 | + if ('' >= $component->getConfig('language')) |
|
6755 | + $component->setConfig('language', $this->getConfig('language')); |
|
6756 | + $component->setConfig('allowEmpty', $this->getConfig('allowEmpty')); |
|
6757 | + $component->setConfig('nl', $this->getConfig('nl')); |
|
6758 | + $component->setConfig('unique_id', $this->getConfig('unique_id')); |
|
6759 | + $component->setConfig('format', $this->getConfig('format')); |
|
6760 | + $output .= $component->createComponent($this->xcaldecl); |
|
6761 | 6761 | } |
6762 | 6762 | return $output; |
6763 | 6763 | } |
@@ -6784,21 +6784,21 @@ discard block |
||
6784 | 6784 | * @param string $value |
6785 | 6785 | * @return string |
6786 | 6786 | */ |
6787 | - function _size75( $string ) { |
|
6788 | - $strlen = strlen( $string ); |
|
6787 | + function _size75($string) { |
|
6788 | + $strlen = strlen($string); |
|
6789 | 6789 | $tmp = $string; |
6790 | 6790 | $string = null; |
6791 | - while( $strlen > 75 ) { |
|
6791 | + while ($strlen > 75) { |
|
6792 | 6792 | $breakAtChar = 75; |
6793 | - if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' ) |
|
6793 | + if (substr($tmp, ($breakAtChar - 1), strlen('\n')) == '\n') |
|
6794 | 6794 | $breakAtChar = $breakAtChar - 1; |
6795 | - $string .= substr( $tmp, 0, $breakAtChar ); |
|
6795 | + $string .= substr($tmp, 0, $breakAtChar); |
|
6796 | 6796 | $string .= $this->nl; |
6797 | - $tmp = ' '.substr( $tmp, $breakAtChar ); |
|
6798 | - $strlen = strlen( $tmp ); |
|
6797 | + $tmp = ' '.substr($tmp, $breakAtChar); |
|
6798 | + $strlen = strlen($tmp); |
|
6799 | 6799 | } // while |
6800 | - $string .= rtrim( $tmp ); // the rest |
|
6801 | - if( $this->nl != substr( $string, ( 0 - strlen( $this->nl )))) |
|
6800 | + $string .= rtrim($tmp); // the rest |
|
6801 | + if ($this->nl != substr($string, (0 - strlen($this->nl)))) |
|
6802 | 6802 | $string .= $this->nl; |
6803 | 6803 | return $string; |
6804 | 6804 | } |
@@ -6810,38 +6810,38 @@ discard block |
||
6810 | 6810 | * @param string $string |
6811 | 6811 | * @return string |
6812 | 6812 | */ |
6813 | - function _strrep( $string ) { |
|
6814 | - switch( $this->format ) { |
|
6813 | + function _strrep($string) { |
|
6814 | + switch ($this->format) { |
|
6815 | 6815 | case 'xcal': |
6816 | - $string = str_replace( '\n', $this->nl, $string); |
|
6817 | - $string = htmlspecialchars( strip_tags( stripslashes( urldecode ( $string )))); |
|
6816 | + $string = str_replace('\n', $this->nl, $string); |
|
6817 | + $string = htmlspecialchars(strip_tags(stripslashes(urldecode($string)))); |
|
6818 | 6818 | break; |
6819 | 6819 | default: |
6820 | 6820 | $pos = 0; |
6821 | - while( $pos <= strlen( $string )) { |
|
6822 | - $pos = strpos( $string, "\\", $pos ); |
|
6823 | - if( FALSE === $pos ) |
|
6821 | + while ($pos <= strlen($string)) { |
|
6822 | + $pos = strpos($string, "\\", $pos); |
|
6823 | + if (FALSE === $pos) |
|
6824 | 6824 | break; |
6825 | - if( !in_array( $string{($pos + 1)}, array( 'n', 'N', 'r', ',', ';' ))) { |
|
6826 | - $string = substr( $string, 0, $pos )."\\".substr( $string, ( $pos + 1 )); |
|
6825 | + if (!in_array($string{($pos + 1)}, array('n', 'N', 'r', ',', ';'))) { |
|
6826 | + $string = substr($string, 0, $pos)."\\".substr($string, ($pos + 1)); |
|
6827 | 6827 | $pos += 1; |
6828 | 6828 | } |
6829 | 6829 | $pos += 1; |
6830 | 6830 | } |
6831 | - if( FALSE !== strpos( $string, '"' )) |
|
6832 | - $string = str_replace('"', "'", $string); |
|
6833 | - if( FALSE !== strpos( $string, ',' )) |
|
6834 | - $string = str_replace(',', '\,', $string); |
|
6835 | - if( FALSE !== strpos( $string, ';' )) |
|
6836 | - $string = str_replace(';', '\;', $string); |
|
6837 | - if( FALSE !== strpos( $string, "\r\n" )) |
|
6838 | - $string = str_replace( "\r\n", '\n', $string); |
|
6839 | - elseif( FALSE !== strpos( $string, "\r" )) |
|
6840 | - $string = str_replace( "\r", '\n', $string); |
|
6841 | - if( FALSE !== strpos( $string, '\N' )) |
|
6842 | - $string = str_replace( '\N', '\n', $string); |
|
6831 | + if (FALSE !== strpos($string, '"')) |
|
6832 | + $string = str_replace('"', "'", $string); |
|
6833 | + if (FALSE !== strpos($string, ',')) |
|
6834 | + $string = str_replace(',', '\,', $string); |
|
6835 | + if (FALSE !== strpos($string, ';')) |
|
6836 | + $string = str_replace(';', '\;', $string); |
|
6837 | + if (FALSE !== strpos($string, "\r\n")) |
|
6838 | + $string = str_replace("\r\n", '\n', $string); |
|
6839 | + elseif (FALSE !== strpos($string, "\r")) |
|
6840 | + $string = str_replace("\r", '\n', $string); |
|
6841 | + if (FALSE !== strpos($string, '\N')) |
|
6842 | + $string = str_replace('\N', '\n', $string); |
|
6843 | 6843 | // if( FALSE !== strpos( $string, $this->nl )) |
6844 | - $string = str_replace( $this->nl, '\n', $string); |
|
6844 | + $string = str_replace($this->nl, '\n', $string); |
|
6845 | 6845 | break; |
6846 | 6846 | } |
6847 | 6847 | return $string; |
@@ -6854,10 +6854,10 @@ discard block |
||
6854 | 6854 | * @param string $string |
6855 | 6855 | * @return string |
6856 | 6856 | */ |
6857 | - function _strunrep( $string ) { |
|
6858 | - $string = str_replace( '\\\\', '\\', $string); |
|
6859 | - $string = str_replace( '\,', ',', $string); |
|
6860 | - $string = str_replace( '\;', ';', $string); |
|
6857 | + function _strunrep($string) { |
|
6858 | + $string = str_replace('\\\\', '\\', $string); |
|
6859 | + $string = str_replace('\,', ',', $string); |
|
6860 | + $string = str_replace('\;', ';', $string); |
|
6861 | 6861 | // $string = str_replace( '\n', $this->nl, $string); // ?? |
6862 | 6862 | return $string; |
6863 | 6863 | } |
@@ -6955,7 +6955,7 @@ discard block |
||
6955 | 6955 | * @param array $xcaldecl |
6956 | 6956 | * @return string |
6957 | 6957 | */ |
6958 | - function createComponent( &$xcaldecl ) { |
|
6958 | + function createComponent(&$xcaldecl) { |
|
6959 | 6959 | $objectname = $this->_createFormat(); |
6960 | 6960 | $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; |
6961 | 6961 | $component .= $this->createUid(); |
@@ -6992,8 +6992,8 @@ discard block |
||
6992 | 6992 | $component .= $this->createXprop(); |
6993 | 6993 | $component .= $this->createSubComponent(); |
6994 | 6994 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
6995 | - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
|
6996 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
6995 | + if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) { |
|
6996 | + foreach ($this->xcaldecl as $localxcaldecl) |
|
6997 | 6997 | $xcaldecl[] = $localxcaldecl; |
6998 | 6998 | } |
6999 | 6999 | return $component; |
@@ -7093,7 +7093,7 @@ discard block |
||
7093 | 7093 | * @param array $xcaldecl |
7094 | 7094 | * @return string |
7095 | 7095 | */ |
7096 | - function createComponent( &$xcaldecl ) { |
|
7096 | + function createComponent(&$xcaldecl) { |
|
7097 | 7097 | $objectname = $this->_createFormat(); |
7098 | 7098 | $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; |
7099 | 7099 | $component .= $this->createUid(); |
@@ -7131,8 +7131,8 @@ discard block |
||
7131 | 7131 | $component .= $this->createXprop(); |
7132 | 7132 | $component .= $this->createSubComponent(); |
7133 | 7133 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7134 | - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
|
7135 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7134 | + if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) { |
|
7135 | + foreach ($this->xcaldecl as $localxcaldecl) |
|
7136 | 7136 | $xcaldecl[] = $localxcaldecl; |
7137 | 7137 | } |
7138 | 7138 | return $component; |
@@ -7212,7 +7212,7 @@ discard block |
||
7212 | 7212 | * @param array $xcaldecl |
7213 | 7213 | * @return string |
7214 | 7214 | */ |
7215 | - function createComponent( &$xcaldecl ) { |
|
7215 | + function createComponent(&$xcaldecl) { |
|
7216 | 7216 | $objectname = $this->_createFormat(); |
7217 | 7217 | $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; |
7218 | 7218 | $component .= $this->createUid(); |
@@ -7241,8 +7241,8 @@ discard block |
||
7241 | 7241 | $component .= $this->createUrl(); |
7242 | 7242 | $component .= $this->createXprop(); |
7243 | 7243 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7244 | - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
|
7245 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7244 | + if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) { |
|
7245 | + foreach ($this->xcaldecl as $localxcaldecl) |
|
7246 | 7246 | $xcaldecl[] = $localxcaldecl; |
7247 | 7247 | } |
7248 | 7248 | return $component; |
@@ -7300,7 +7300,7 @@ discard block |
||
7300 | 7300 | * @param array $xcaldecl |
7301 | 7301 | * @return string |
7302 | 7302 | */ |
7303 | - function createComponent( &$xcaldecl ) { |
|
7303 | + function createComponent(&$xcaldecl) { |
|
7304 | 7304 | $objectname = $this->_createFormat(); |
7305 | 7305 | $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; |
7306 | 7306 | $component .= $this->createUid(); |
@@ -7317,8 +7317,8 @@ discard block |
||
7317 | 7317 | $component .= $this->createUrl(); |
7318 | 7318 | $component .= $this->createXprop(); |
7319 | 7319 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7320 | - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
|
7321 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7320 | + if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) { |
|
7321 | + foreach ($this->xcaldecl as $localxcaldecl) |
|
7322 | 7322 | $xcaldecl[] = $localxcaldecl; |
7323 | 7323 | } |
7324 | 7324 | return $component; |
@@ -7370,7 +7370,7 @@ discard block |
||
7370 | 7370 | * @param array $xcaldecl |
7371 | 7371 | * @return string |
7372 | 7372 | */ |
7373 | - function createComponent( &$xcaldecl ) { |
|
7373 | + function createComponent(&$xcaldecl) { |
|
7374 | 7374 | $objectname = $this->_createFormat(); |
7375 | 7375 | $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; |
7376 | 7376 | $component .= $this->createAction(); |
@@ -7418,11 +7418,11 @@ discard block |
||
7418 | 7418 | * @param string $timezonetype optional, default FALSE ( STANDARD / DAYLIGHT ) |
7419 | 7419 | * @return void |
7420 | 7420 | */ |
7421 | - function vtimezone( $timezonetype=FALSE ) { |
|
7422 | - if( !$timezonetype ) |
|
7421 | + function vtimezone($timezonetype = FALSE) { |
|
7422 | + if (!$timezonetype) |
|
7423 | 7423 | $this->timezonetype = 'VTIMEZONE'; |
7424 | 7424 | else |
7425 | - $this->timezonetype = strtoupper( $timezonetype ); |
|
7425 | + $this->timezonetype = strtoupper($timezonetype); |
|
7426 | 7426 | $this->calendarComponent(); |
7427 | 7427 | |
7428 | 7428 | $this->comment = ''; |
@@ -7447,7 +7447,7 @@ discard block |
||
7447 | 7447 | * @param array $xcaldecl |
7448 | 7448 | * @return string |
7449 | 7449 | */ |
7450 | - function createComponent( &$xcaldecl ) { |
|
7450 | + function createComponent(&$xcaldecl) { |
|
7451 | 7451 | $objectname = $this->_createFormat(); |
7452 | 7452 | $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; |
7453 | 7453 | $component .= $this->createTzid(); |
@@ -7463,8 +7463,8 @@ discard block |
||
7463 | 7463 | $component .= $this->createXprop(); |
7464 | 7464 | $component .= $this->createSubComponent(); |
7465 | 7465 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7466 | - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
|
7467 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7466 | + if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) { |
|
7467 | + foreach ($this->xcaldecl as $localxcaldecl) |
|
7468 | 7468 | $xcaldecl[] = $localxcaldecl; |
7469 | 7469 | } |
7470 | 7470 | return $component; |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * @assert () !== '' |
22 | 22 | * @assert ('abc','single') !== '' |
23 | 23 | */ |
24 | - function search_courses($needle,$type) |
|
24 | + function search_courses($needle, $type) |
|
25 | 25 | { |
26 | 26 | $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
27 | 27 | $xajax_response = new xajaxResponse(); |
28 | 28 | $return = ''; |
29 | - if(!empty($needle) && !empty($type)) { |
|
29 | + if (!empty($needle) && !empty($type)) { |
|
30 | 30 | // xajax send utf8 datas... datas in db can be non-utf8 datas |
31 | 31 | $charset = api_get_system_encoding(); |
32 | 32 | $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | $course_list = array(); |
39 | 39 | |
40 | 40 | $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">'; |
41 | - while($course = Database :: fetch_array($rs)) { |
|
41 | + while ($course = Database :: fetch_array($rs)) { |
|
42 | 42 | $course_list[] = $course['id']; |
43 | - $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
43 | + $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'], ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
44 | 44 | } |
45 | 45 | $return .= '</select>'; |
46 | - $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
46 | + $xajax_response -> addAssign('ajax_list_courses_multiple', 'innerHTML', api_utf8_encode($return)); |
|
47 | 47 | } |
48 | 48 | $_SESSION['course_list'] = $course_list; |
49 | 49 | return $xajax_response; |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | $course_user_table = Database:: get_main_table(TABLE_MAIN_COURSE_USER); |
105 | 105 | $course_table = Database:: get_main_table(TABLE_MAIN_COURSE); |
106 | 106 | $user_table = Database:: get_main_table(TABLE_MAIN_USER); |
107 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
107 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
108 | 108 | $current_url_id = api_get_current_access_url_id(); |
109 | - $active_filter = $onlyActive?' AND active=1':''; |
|
110 | - $status_filter = isset($status)?' AND status = '.intval($status):''; |
|
109 | + $active_filter = $onlyActive ? ' AND active=1' : ''; |
|
110 | + $status_filter = isset($status) ? ' AND status = '.intval($status) : ''; |
|
111 | 111 | |
112 | 112 | if (api_is_multiple_url_enabled()) { |
113 | 113 | $sql = "SELECT COUNT(DISTINCT(u.user_id)) AS number |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | FROM $user_table |
132 | 132 | WHERE 1=1 $status_filter $active_filter"; |
133 | 133 | if (isset ($categoryCode)) { |
134 | - $status_filter = isset($status)?' AND status = '.intval($status):''; |
|
134 | + $status_filter = isset($status) ? ' AND status = '.intval($status) : ''; |
|
135 | 135 | $sql = "SELECT COUNT(DISTINCT(cu.user_id)) AS number |
136 | 136 | FROM $course_user_table cu, $course_table c |
137 | 137 | WHERE |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | public static function countSessions() |
157 | 157 | { |
158 | 158 | $session_table = Database :: get_main_table(TABLE_MAIN_SESSION); |
159 | - $access_url_rel_session_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
|
159 | + $access_url_rel_session_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
|
160 | 160 | if (api_is_multiple_url_enabled()) { |
161 | 161 | $current_url_id = api_get_current_access_url_id(); |
162 | 162 | $sql = "SELECT COUNT(id) AS number |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | public static function getNumberOfActivities() |
180 | 180 | { |
181 | 181 | // Database table definitions |
182 | - $track_e_default = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT); |
|
182 | + $track_e_default = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT); |
|
183 | 183 | $table_user = Database::get_main_table(TABLE_MAIN_USER); |
184 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
184 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
185 | 185 | $current_url_id = api_get_current_access_url_id(); |
186 | 186 | if (api_is_multiple_url_enabled()) { |
187 | 187 | $sql = "SELECT count(default_id) AS total_number_of_items |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $from = intval($from); |
226 | 226 | $numberOfItems = intval($numberOfItems); |
227 | 227 | |
228 | - if (!in_array($direction, array('ASC','DESC'))) { |
|
228 | + if (!in_array($direction, array('ASC', 'DESC'))) { |
|
229 | 229 | $direction = 'DESC'; |
230 | 230 | } |
231 | 231 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $sql .= " LIMIT $from,$numberOfItems "; |
277 | 277 | |
278 | 278 | $res = Database::query($sql); |
279 | - $activities = array (); |
|
279 | + $activities = array(); |
|
280 | 280 | while ($row = Database::fetch_row($res)) { |
281 | 281 | |
282 | 282 | if (strpos($row[1], '_object') === false && strpos($row[1], '_array') === false) { |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | $sql = "SELECT code, name FROM $categoryTable |
344 | 344 | ORDER BY tree_pos"; |
345 | 345 | $res = Database::query($sql); |
346 | - $categories = array (); |
|
346 | + $categories = array(); |
|
347 | 347 | while ($category = Database::fetch_object($res)) { |
348 | 348 | $categories[$category->code] = $category->name; |
349 | 349 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | $data_max = ($data_max < $value ? $value : $data_max); |
365 | 365 | } |
366 | 366 | reset($data); |
367 | - $result = array (); |
|
367 | + $result = array(); |
|
368 | 368 | $delta = $max / $data_max; |
369 | 369 | foreach ($data as $index => $value) { |
370 | 370 | $result[$index] = (int) round($value * $delta); |
@@ -398,9 +398,9 @@ discard block |
||
398 | 398 | } else { |
399 | 399 | $number_label = Statistics::makeSizeString($number); |
400 | 400 | } |
401 | - $percentage = ($total>0?number_format(100*$number/$total, 1, ',', '.'):'0'); |
|
401 | + $percentage = ($total > 0 ? number_format(100 * $number / $total, 1, ',', '.') : '0'); |
|
402 | 402 | |
403 | - echo '<tr class="row_'.($i%2 == 0 ? 'odd' : 'even').'"> |
|
403 | + echo '<tr class="row_'.($i % 2 == 0 ? 'odd' : 'even').'"> |
|
404 | 404 | <td width="150">'.$subtitle.'</td> |
405 | 405 | <td width="550">'.Display::bar_progress($percentage, false).'</td> |
406 | 406 | <td align="right">'.$number_label.'</td>'; |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | echo '<td align="right"> '.$percentage.'%</td>'; |
409 | 409 | } |
410 | 410 | echo '</tr>'; |
411 | - $i ++; |
|
411 | + $i++; |
|
412 | 412 | } |
413 | 413 | if ($showTotal) { |
414 | 414 | if (!$isFileSize) { |
@@ -428,17 +428,17 @@ discard block |
||
428 | 428 | public static function printLoginStats($type) |
429 | 429 | { |
430 | 430 | $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
431 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
431 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
432 | 432 | $current_url_id = api_get_current_access_url_id(); |
433 | 433 | |
434 | 434 | $table_url = null; |
435 | 435 | $where_url = null; |
436 | 436 | $now = api_get_utc_datetime(); |
437 | - $where_url_last = ' WHERE login_date > DATE_SUB("' . $now . '",INTERVAL 1 %s)'; |
|
437 | + $where_url_last = ' WHERE login_date > DATE_SUB("'.$now.'",INTERVAL 1 %s)'; |
|
438 | 438 | if (api_is_multiple_url_enabled()) { |
439 | 439 | $table_url = ", $access_url_rel_user_table"; |
440 | 440 | $where_url = " WHERE login_user_id=user_id AND access_url_id='".$current_url_id."'"; |
441 | - $where_url_last = ' AND login_date > DATE_SUB("' . $now . '",INTERVAL 1 %s)'; |
|
441 | + $where_url_last = ' AND login_date > DATE_SUB("'.$now.'",INTERVAL 1 %s)'; |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | $period = get_lang('PeriodMonth'); |
@@ -453,13 +453,13 @@ discard block |
||
453 | 453 | case 'hour': |
454 | 454 | $period = get_lang('PeriodHour'); |
455 | 455 | $sql = "SELECT DATE_FORMAT( login_date, '%H' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table.$table_url.$where_url." GROUP BY stat_date ORDER BY stat_date "; |
456 | - $sql_last_x = "SELECT DATE_FORMAT( login_date, '%H' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table.$table_url.$where_url.sprintf($where_url_last,'DAY')." GROUP BY stat_date ORDER BY stat_date "; |
|
456 | + $sql_last_x = "SELECT DATE_FORMAT( login_date, '%H' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table.$table_url.$where_url.sprintf($where_url_last, 'DAY')." GROUP BY stat_date ORDER BY stat_date "; |
|
457 | 457 | break; |
458 | 458 | case 'day': |
459 | 459 | $periodCollection = api_get_week_days_long(); |
460 | 460 | $period = get_lang('PeriodDay'); |
461 | 461 | $sql = "SELECT DATE_FORMAT( login_date, '%w' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table.$table_url.$where_url." GROUP BY stat_date ORDER BY DATE_FORMAT( login_date, '%w' ) "; |
462 | - $sql_last_x = "SELECT DATE_FORMAT( login_date, '%w' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table.$table_url.$where_url.sprintf($where_url_last,'WEEK')." GROUP BY stat_date ORDER BY DATE_FORMAT( login_date, '%w' ) "; |
|
462 | + $sql_last_x = "SELECT DATE_FORMAT( login_date, '%w' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table.$table_url.$where_url.sprintf($where_url_last, 'WEEK')." GROUP BY stat_date ORDER BY DATE_FORMAT( login_date, '%w' ) "; |
|
463 | 463 | break; |
464 | 464 | } |
465 | 465 | if ($sql_last_x) { |
@@ -501,14 +501,14 @@ discard block |
||
501 | 501 | { |
502 | 502 | $totalLogin = array(); |
503 | 503 | $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
504 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
504 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
505 | 505 | $current_url_id = api_get_current_access_url_id(); |
506 | 506 | if (api_is_multiple_url_enabled()) { |
507 | 507 | $table_url = ", $access_url_rel_user_table"; |
508 | 508 | $where_url = " AND login_user_id=user_id AND access_url_id='".$current_url_id."'"; |
509 | 509 | } else { |
510 | 510 | $table_url = ''; |
511 | - $where_url=''; |
|
511 | + $where_url = ''; |
|
512 | 512 | } |
513 | 513 | $now = api_get_utc_datetime(); |
514 | 514 | $field = 'login_user_id'; |
@@ -540,14 +540,14 @@ discard block |
||
540 | 540 | { |
541 | 541 | $totalLogin = []; |
542 | 542 | $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
543 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
543 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
544 | 544 | $current_url_id = api_get_current_access_url_id(); |
545 | 545 | if (api_is_multiple_url_enabled()) { |
546 | 546 | $table_url = ", $access_url_rel_user_table"; |
547 | 547 | $where_url = " AND login_user_id=user_id AND access_url_id='".$current_url_id."'"; |
548 | 548 | } else { |
549 | 549 | $table_url = ''; |
550 | - $where_url=''; |
|
550 | + $where_url = ''; |
|
551 | 551 | } |
552 | 552 | $now = api_get_utc_datetime(); |
553 | 553 | $field = 'login_user_id'; |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | $sql = "SELECT count($field) AS number, date(login_date) as login_date FROM $table $table_url WHERE DATE_ADD(login_date, INTERVAL 15 DAY) >= '$now' $where_url GROUP BY date(login_date)"; |
558 | 558 | |
559 | 559 | $res = Database::query($sql); |
560 | - while($row = Database::fetch_array($res,'ASSOC')){ |
|
560 | + while ($row = Database::fetch_array($res, 'ASSOC')) { |
|
561 | 561 | $totalLogin[$row['login_date']] = $row['number']; |
562 | 562 | } |
563 | 563 | |
@@ -652,13 +652,13 @@ discard block |
||
652 | 652 | public static function printUserPicturesStats() |
653 | 653 | { |
654 | 654 | $user_table = Database :: get_main_table(TABLE_MAIN_USER); |
655 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
655 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
656 | 656 | $current_url_id = api_get_current_access_url_id(); |
657 | 657 | $url_condition = null; |
658 | 658 | $url_condition2 = null; |
659 | 659 | $table = null; |
660 | 660 | if (api_is_multiple_url_enabled()) { |
661 | - $url_condition = ", $access_url_rel_user_table as url WHERE url.user_id=u.user_id AND access_url_id='".$current_url_id."'"; |
|
661 | + $url_condition = ", $access_url_rel_user_table as url WHERE url.user_id=u.user_id AND access_url_id='".$current_url_id."'"; |
|
662 | 662 | $url_condition2 = " AND url.user_id=u.user_id AND access_url_id='".$current_url_id."'"; |
663 | 663 | $table = ", $access_url_rel_user_table as url "; |
664 | 664 | } |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | 'width=200px', |
691 | 691 | false |
692 | 692 | ); |
693 | - $renderer =& $form->defaultRenderer(); |
|
693 | + $renderer = & $form->defaultRenderer(); |
|
694 | 694 | $renderer->setCustomElementTemplate('<span>{element}</span> '); |
695 | 695 | $form->addElement('hidden', 'report', 'activities'); |
696 | 696 | $form->addElement('hidden', 'activities_direction', 'DESC'); |
@@ -740,10 +740,10 @@ discard block |
||
740 | 740 | $columns[1] = 'access_date'; |
741 | 741 | $sql_order[SORT_ASC] = 'ASC'; |
742 | 742 | $sql_order[SORT_DESC] = 'DESC'; |
743 | - $per_page = isset($_GET['per_page'])?intval($_GET['per_page']) : 10; |
|
744 | - $page_nr = isset($_GET['page_nr'])?intval($_GET['page_nr']) : 1; |
|
745 | - $column = isset($_GET['column'])?intval($_GET['column']) : 0; |
|
746 | - $date_diff = isset($_GET['date_diff'])?intval($_GET['date_diff']) : 60; |
|
743 | + $per_page = isset($_GET['per_page']) ? intval($_GET['per_page']) : 10; |
|
744 | + $page_nr = isset($_GET['page_nr']) ? intval($_GET['page_nr']) : 1; |
|
745 | + $column = isset($_GET['column']) ? intval($_GET['column']) : 0; |
|
746 | + $date_diff = isset($_GET['date_diff']) ? intval($_GET['date_diff']) : 60; |
|
747 | 747 | |
748 | 748 | $direction = isset($_GET['direction']) ? $_GET['direction'] : SORT_ASC; |
749 | 749 | |
@@ -772,25 +772,25 @@ discard block |
||
772 | 772 | access_url_id='".$current_url_id."' |
773 | 773 | GROUP BY c_id |
774 | 774 | HAVING c_id <> '' |
775 | - AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ". $date_diff; |
|
775 | + AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ".$date_diff; |
|
776 | 776 | } else { |
777 | 777 | $sql = "SELECT * FROM $table |
778 | 778 | GROUP BY c_id |
779 | 779 | HAVING c_id <> '' |
780 | - AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ". $date_diff; |
|
780 | + AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ".$date_diff; |
|
781 | 781 | } |
782 | 782 | $sql .= ' ORDER BY '.$columns[$column].' '.$sql_order[$direction]; |
783 | - $from = ($page_nr -1) * $per_page; |
|
783 | + $from = ($page_nr - 1) * $per_page; |
|
784 | 784 | $sql .= ' LIMIT '.$from.','.$per_page; |
785 | 785 | |
786 | 786 | echo '<p>'.get_lang('LastAccess').' >= '.$date_diff.' '.get_lang('Days').'</p>'; |
787 | 787 | $res = Database::query($sql); |
788 | 788 | if (Database::num_rows($res) > 0) { |
789 | - $courses = array (); |
|
789 | + $courses = array(); |
|
790 | 790 | while ($obj = Database::fetch_object($res)) { |
791 | 791 | $courseInfo = api_get_course_info_by_id($obj->c_id); |
792 | - $course = array (); |
|
793 | - $course[]= '<a href="'.api_get_path(WEB_COURSE_PATH).$courseInfo['code'].'">'.$courseInfo['code'].' <a>'; |
|
792 | + $course = array(); |
|
793 | + $course[] = '<a href="'.api_get_path(WEB_COURSE_PATH).$courseInfo['code'].'">'.$courseInfo['code'].' <a>'; |
|
794 | 794 | // Allow sort by date hiding the numerical date |
795 | 795 | $course[] = '<span style="display:none;">'.$obj->access_date.'</span>'.api_convert_and_format_date($obj->access_date); |
796 | 796 | $courses[] = $course; |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | { |
864 | 864 | $user_friend_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
865 | 865 | $user_table = Database::get_main_table(TABLE_MAIN_USER); |
866 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
866 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
867 | 867 | $current_url_id = api_get_current_access_url_id(); |
868 | 868 | |
869 | 869 | if (api_is_multiple_url_enabled()) { |
@@ -895,7 +895,7 @@ discard block |
||
895 | 895 | { |
896 | 896 | $totalLogin = array(); |
897 | 897 | $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
898 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
898 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
899 | 899 | $current_url_id = api_get_current_access_url_id(); |
900 | 900 | $total = self::countUsers(); |
901 | 901 | if (api_is_multiple_url_enabled()) { |
@@ -903,14 +903,14 @@ discard block |
||
903 | 903 | $where_url = " AND login_user_id=user_id AND access_url_id='".$current_url_id."'"; |
904 | 904 | } else { |
905 | 905 | $table_url = ''; |
906 | - $where_url=''; |
|
906 | + $where_url = ''; |
|
907 | 907 | } |
908 | 908 | $now = api_get_utc_datetime(); |
909 | - $sql[get_lang('ThisDay')] = |
|
909 | + $sql[get_lang('ThisDay')] = |
|
910 | 910 | "SELECT count(distinct(login_user_id)) AS number ". |
911 | 911 | " FROM $table $table_url ". |
912 | 912 | " WHERE DATE_ADD(login_date, INTERVAL 1 DAY) >= '$now' $where_url"; |
913 | - $sql[get_lang('Last7days')] = |
|
913 | + $sql[get_lang('Last7days')] = |
|
914 | 914 | "SELECT count(distinct(login_user_id)) AS number ". |
915 | 915 | " FROM $table $table_url ". |
916 | 916 | " WHERE DATE_ADD(login_date, INTERVAL 7 DAY) >= '$now' $where_url"; |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | "SELECT count(distinct(login_user_id)) AS number ". |
923 | 923 | " FROM $table $table_url ". |
924 | 924 | " WHERE DATE_ADD(login_date, INTERVAL 6 MONTH) >= '$now' $where_url"; |
925 | - $sql[get_lang('NeverConnected')] = |
|
925 | + $sql[get_lang('NeverConnected')] = |
|
926 | 926 | "SELECT count(distinct(login_user_id)) AS number ". |
927 | 927 | " FROM $table $table_url WHERE 1=1 $where_url"; |
928 | 928 | foreach ($sql as $index => $query) { |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | $special_course_list = array(); |
47 | 47 | if (Database::num_rows($result) > 0) { |
48 | 48 | while ($result_row = Database::fetch_array($result)) { |
49 | - $special_course_list[] = '"' . $result_row['item_id'] . '"'; |
|
49 | + $special_course_list[] = '"'.$result_row['item_id'].'"'; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | $without_special_courses = ''; |
53 | 53 | if (!empty($special_course_list)) { |
54 | - $without_special_courses = ' AND course.id NOT IN (' . implode(',', $special_course_list) . ')'; |
|
54 | + $without_special_courses = ' AND course.id NOT IN ('.implode(',', $special_course_list).')'; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | // Secondly we select the courses that are in a category (user_course_cat<>0) and sort these according to the sort of the category |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | FROM $TABLECOURS course, $TABLECOURSUSER course_rel_user |
71 | 71 | WHERE |
72 | 72 | course.id = course_rel_user.c_id AND |
73 | - course_rel_user.relation_type<>" . COURSE_RELATION_TYPE_RRHH . " AND |
|
74 | - course_rel_user.user_id = '" . $user_id . "' $without_special_courses |
|
73 | + course_rel_user.relation_type<>".COURSE_RELATION_TYPE_RRHH." AND |
|
74 | + course_rel_user.user_id = '" . $user_id."' $without_special_courses |
|
75 | 75 | ORDER BY course_rel_user.sort ASC"; |
76 | 76 | $result = Database::query($sql); |
77 | 77 | $courses = array(); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | { |
103 | 103 | $user_id = api_get_user_id(); |
104 | 104 | $table_category = Database::get_main_table(TABLE_USER_COURSE_CATEGORY); |
105 | - $sql = "SELECT * FROM " . $table_category . " |
|
105 | + $sql = "SELECT * FROM ".$table_category." |
|
106 | 106 | WHERE user_id=$user_id |
107 | 107 | ORDER BY sort ASC"; |
108 | 108 | $result = Database::query($sql); |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | $special_course_list = array(); |
145 | 145 | if (Database::num_rows($result) > 0) { |
146 | 146 | while ($result_row = Database::fetch_array($result)) { |
147 | - $special_course_list[] = '"' . $result_row['item_id'] . '"'; |
|
147 | + $special_course_list[] = '"'.$result_row['item_id'].'"'; |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | 151 | $without_special_courses = ''; |
152 | 152 | if (!empty($special_course_list)) { |
153 | - $without_special_courses = ' AND course.id NOT IN (' . implode(',', $special_course_list) . ')'; |
|
153 | + $without_special_courses = ' AND course.id NOT IN ('.implode(',', $special_course_list).')'; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | $sql = "SELECT |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | $TABLECOURSUSER course_rel_user |
162 | 162 | WHERE |
163 | 163 | course.id = course_rel_user.c_id AND |
164 | - course_rel_user.user_id = '" . $user_id . "' AND |
|
165 | - course_rel_user.relation_type <> " . COURSE_RELATION_TYPE_RRHH . " |
|
164 | + course_rel_user.user_id = '".$user_id."' AND |
|
165 | + course_rel_user.relation_type <> " . COURSE_RELATION_TYPE_RRHH." |
|
166 | 166 | $without_special_courses |
167 | 167 | ORDER BY course_rel_user.user_course_cat, course_rel_user.sort ASC"; |
168 | 168 | $result = Database::query($sql); |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | $TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
192 | 192 | $max_sort_value = api_max_sort_value($newcategory, $current_user); |
193 | 193 | $sql = "UPDATE $TABLECOURSUSER SET |
194 | - user_course_cat='" . $newcategory . "', |
|
195 | - sort='" . ($max_sort_value + 1) . "' |
|
194 | + user_course_cat='".$newcategory."', |
|
195 | + sort='" . ($max_sort_value + 1)."' |
|
196 | 196 | WHERE |
197 | - c_id ='" . $courseId . "' AND |
|
198 | - user_id='" . $current_user . "' AND |
|
197 | + c_id ='" . $courseId."' AND |
|
198 | + user_id='" . $current_user."' AND |
|
199 | 199 | relation_type<>" . COURSE_RELATION_TYPE_RRHH; |
200 | 200 | $resultQuery = Database::query($sql); |
201 | 201 | |
@@ -254,18 +254,18 @@ discard block |
||
254 | 254 | $targetCourseId = $targetCourseInfo['real_id']; |
255 | 255 | |
256 | 256 | $sql = "UPDATE $table |
257 | - SET sort='" . $target_course['sort'] . "' |
|
257 | + SET sort='".$target_course['sort']."' |
|
258 | 258 | WHERE |
259 | - c_id = '" . $courseId . "' AND |
|
260 | - user_id = '" . $current_user_id . "' AND |
|
259 | + c_id = '" . $courseId."' AND |
|
260 | + user_id = '" . $current_user_id."' AND |
|
261 | 261 | relation_type<>" . COURSE_RELATION_TYPE_RRHH; |
262 | 262 | |
263 | 263 | $result1 = Database::query($sql); |
264 | 264 | |
265 | - $sql = "UPDATE $table SET sort='" . $source_course['sort'] . "' |
|
265 | + $sql = "UPDATE $table SET sort='".$source_course['sort']."' |
|
266 | 266 | WHERE |
267 | - c_id ='" . $targetCourseId . "' AND |
|
268 | - user_id='" . $current_user_id . "' AND |
|
267 | + c_id ='" . $targetCourseId."' AND |
|
268 | + user_id='" . $current_user_id."' AND |
|
269 | 269 | relation_type<>" . COURSE_RELATION_TYPE_RRHH; |
270 | 270 | |
271 | 271 | $result2 = Database::query($sql); |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | } |
310 | 310 | |
311 | 311 | if (count($target_category) > 0 && count($source_category) > 0) { |
312 | - $sql_update1 = "UPDATE $table_user_defined_category SET sort='" . Database::escape_string($target_category['sort']) . "' |
|
313 | - WHERE id='" . intval($source_category['id']) . "' AND user_id='" . $current_user_id . "'"; |
|
314 | - $sql_update2 = "UPDATE $table_user_defined_category SET sort='" . Database::escape_string($source_category['sort']) . "' |
|
315 | - WHERE id='" . intval($target_category['id']) . "' AND user_id='" . $current_user_id . "'"; |
|
312 | + $sql_update1 = "UPDATE $table_user_defined_category SET sort='".Database::escape_string($target_category['sort'])."' |
|
313 | + WHERE id='" . intval($source_category['id'])."' AND user_id='".$current_user_id."'"; |
|
314 | + $sql_update2 = "UPDATE $table_user_defined_category SET sort='".Database::escape_string($source_category['sort'])."' |
|
315 | + WHERE id='" . intval($target_category['id'])."' AND user_id='".$current_user_id."'"; |
|
316 | 316 | |
317 | 317 | $result1 = Database::query($sql_update2); |
318 | 318 | $result2 = Database::query($sql_update1); |
@@ -331,8 +331,8 @@ discard block |
||
331 | 331 | { |
332 | 332 | $current_user_id = api_get_user_id(); |
333 | 333 | $table_category = Database::get_main_table(TABLE_USER_COURSE_CATEGORY); |
334 | - $sql = "SELECT * FROM " . $table_category . " |
|
335 | - WHERE user_id='" . $current_user_id . "' |
|
334 | + $sql = "SELECT * FROM ".$table_category." |
|
335 | + WHERE user_id='" . $current_user_id."' |
|
336 | 336 | ORDER BY sort ASC"; |
337 | 337 | $result = Database::query($sql); |
338 | 338 | while ($row = Database::fetch_array($result)) { |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | $result = false; |
356 | 356 | $tucc = Database::get_main_table(TABLE_USER_COURSE_CATEGORY); |
357 | 357 | $sql = "UPDATE $tucc |
358 | - SET title='" . api_htmlentities($title, ENT_QUOTES, api_get_system_encoding()) . "' |
|
359 | - WHERE id='" . $category_id . "'"; |
|
358 | + SET title='".api_htmlentities($title, ENT_QUOTES, api_get_system_encoding())."' |
|
359 | + WHERE id='" . $category_id."'"; |
|
360 | 360 | $resultQuery = Database::query($sql); |
361 | 361 | if (Database::affected_rows($resultQuery)) { |
362 | 362 | $result = true; |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | $category_id = intval($category_id); |
378 | 378 | $result = false; |
379 | 379 | $sql_delete = "DELETE FROM $tucc |
380 | - WHERE id='" . $category_id . "' and user_id='" . $current_user_id . "'"; |
|
380 | + WHERE id='".$category_id."' and user_id='".$current_user_id."'"; |
|
381 | 381 | $resultQuery = Database::query($sql_delete); |
382 | 382 | if (Database::affected_rows($resultQuery)) { |
383 | 383 | $result = true; |
@@ -385,9 +385,9 @@ discard block |
||
385 | 385 | $sql = "UPDATE $TABLECOURSUSER |
386 | 386 | SET user_course_cat='0' |
387 | 387 | WHERE |
388 | - user_course_cat='" . $category_id . "' AND |
|
389 | - user_id='" . $current_user_id . "' AND |
|
390 | - relation_type<>" . COURSE_RELATION_TYPE_RRHH . " "; |
|
388 | + user_course_cat='".$category_id."' AND |
|
389 | + user_id='" . $current_user_id."' AND |
|
390 | + relation_type<>" . COURSE_RELATION_TYPE_RRHH." "; |
|
391 | 391 | Database::query($sql); |
392 | 392 | |
393 | 393 | return $result; |
@@ -420,20 +420,20 @@ discard block |
||
420 | 420 | if (Database::num_rows($special_course_result) > 0) { |
421 | 421 | $special_course_list = array(); |
422 | 422 | while ($result_row = Database::fetch_array($special_course_result)) { |
423 | - $special_course_list[] = '"' . $result_row['item_id'] . '"'; |
|
423 | + $special_course_list[] = '"'.$result_row['item_id'].'"'; |
|
424 | 424 | } |
425 | 425 | } |
426 | 426 | $without_special_courses = ''; |
427 | 427 | if (!empty($special_course_list)) { |
428 | - $without_special_courses = ' AND course.code NOT IN (' . implode(',', $special_course_list) . ')'; |
|
428 | + $without_special_courses = ' AND course.code NOT IN ('.implode(',', $special_course_list).')'; |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | $search_term_safe = Database::escape_string($search_term); |
432 | 432 | $sql_find = "SELECT * FROM $courseTable |
433 | 433 | WHERE ( |
434 | - code LIKE '%" . $search_term_safe . "%' OR |
|
435 | - title LIKE '%" . $search_term_safe . "%' OR |
|
436 | - tutor_name LIKE '%" . $search_term_safe . "%' |
|
434 | + code LIKE '%".$search_term_safe."%' OR |
|
435 | + title LIKE '%" . $search_term_safe."%' OR |
|
436 | + tutor_name LIKE '%" . $search_term_safe."%' |
|
437 | 437 | ) |
438 | 438 | $without_special_courses |
439 | 439 | ORDER BY title, visual_code ASC |
@@ -450,9 +450,9 @@ discard block |
||
450 | 450 | ON (url_rel_course.c_id = course.id) |
451 | 451 | WHERE |
452 | 452 | access_url_id = $url_access_id AND ( |
453 | - code LIKE '%" . $search_term_safe . "%' OR |
|
454 | - title LIKE '%" . $search_term_safe . "%' OR |
|
455 | - tutor_name LIKE '%" . $search_term_safe . "%' |
|
453 | + code LIKE '%".$search_term_safe."%' OR |
|
454 | + title LIKE '%" . $search_term_safe."%' OR |
|
455 | + tutor_name LIKE '%" . $search_term_safe."%' |
|
456 | 456 | ) |
457 | 457 | $without_special_courses |
458 | 458 | ORDER BY title, visual_code ASC |
@@ -513,8 +513,8 @@ discard block |
||
513 | 513 | // (s)he can only delete the course |
514 | 514 | $sql = "SELECT * FROM $tbl_course_user |
515 | 515 | WHERE |
516 | - user_id='" . $current_user_id . "' AND |
|
517 | - c_id ='" . $courseId . "' AND |
|
516 | + user_id='".$current_user_id."' AND |
|
517 | + c_id ='" . $courseId."' AND |
|
518 | 518 | status='1' "; |
519 | 519 | $result_check = Database::query($sql); |
520 | 520 | $number_of_rows = Database::num_rows($result_check); |
@@ -541,17 +541,17 @@ discard block |
||
541 | 541 | $result = false; |
542 | 542 | |
543 | 543 | // step 1: we determine the max value of the user defined course categories |
544 | - $sql = "SELECT sort FROM $tucc WHERE user_id='" . $current_user_id . "' ORDER BY sort DESC"; |
|
544 | + $sql = "SELECT sort FROM $tucc WHERE user_id='".$current_user_id."' ORDER BY sort DESC"; |
|
545 | 545 | $rs_sort = Database::query($sql); |
546 | 546 | $maxsort = Database::fetch_array($rs_sort); |
547 | 547 | $nextsort = $maxsort['sort'] + 1; |
548 | 548 | |
549 | 549 | // step 2: we check if there is already a category with this name, if not we store it, else we give an error. |
550 | - $sql = "SELECT * FROM $tucc WHERE user_id='" . $current_user_id . "' AND title='" . $category_title . "'ORDER BY sort DESC"; |
|
550 | + $sql = "SELECT * FROM $tucc WHERE user_id='".$current_user_id."' AND title='".$category_title."'ORDER BY sort DESC"; |
|
551 | 551 | $rs = Database::query($sql); |
552 | 552 | if (Database::num_rows($rs) == 0) { |
553 | 553 | $sql_insert = "INSERT INTO $tucc (user_id, title,sort) |
554 | - VALUES ('" . $current_user_id . "', '" . api_htmlentities($category_title, ENT_QUOTES, api_get_system_encoding()) . "', '" . $nextsort . "')"; |
|
554 | + VALUES ('".$current_user_id."', '".api_htmlentities($category_title, ENT_QUOTES, api_get_system_encoding())."', '".$nextsort."')"; |
|
555 | 555 | $resultQuery = Database::query($sql_insert); |
556 | 556 | if (Database::affected_rows($resultQuery)) { |
557 | 557 | $result = true; |
@@ -628,10 +628,10 @@ discard block |
||
628 | 628 | if (isset($_POST['course_registration_code']) && $_POST['course_registration_code'] != $all_course_information['registration_code']) { |
629 | 629 | return false; |
630 | 630 | } |
631 | - $message = get_lang('CourseRequiresPassword') . '<br />'; |
|
631 | + $message = get_lang('CourseRequiresPassword').'<br />'; |
|
632 | 632 | $message .= $all_course_information['title'].' ('.$all_course_information['visual_code'].') '; |
633 | 633 | |
634 | - $action = api_get_path(WEB_CODE_PATH) . "auth/courses.php?action=subscribe_user_with_password&sec_token=" . $_SESSION['sec_token']; |
|
634 | + $action = api_get_path(WEB_CODE_PATH)."auth/courses.php?action=subscribe_user_with_password&sec_token=".$_SESSION['sec_token']; |
|
635 | 635 | $form = new FormValidator('subscribe_user_with_password', 'post', $action); |
636 | 636 | $form->addElement('hidden', 'sec_token', $_SESSION['sec_token']); |
637 | 637 | $form->addElement('hidden', 'subscribe_user_with_password', $all_course_information['code']); |
@@ -34,8 +34,8 @@ |
||
34 | 34 | $idUserLocal = api_get_user_id(); |
35 | 35 | $userLocal = api_get_user_info($idUserLocal, true); |
36 | 36 | $htmlHeadXtra[] = '<script type="text/javascript" src="' |
37 | - . api_get_path(WEB_PATH) . 'web/assets/SimpleWebRTC/latest.js' |
|
38 | - . '"></script>' . "\n"; |
|
37 | + . api_get_path(WEB_PATH).'web/assets/SimpleWebRTC/latest.js' |
|
38 | + . '"></script>'."\n"; |
|
39 | 39 | |
40 | 40 | $template = new Template(); |
41 | 41 | $template->assign('room_name', $chatVideo->getRoomName()); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | $parentIdCondition = " AND (t1.parent_id IS NULL OR t1.parent_id = '' )"; |
70 | 70 | if (!empty($category)) { |
71 | - $parentIdCondition = " AND t1.parent_id = '$category' "; |
|
71 | + $parentIdCondition = " AND t1.parent_id = '$category' "; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | $sql = "SELECT |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | $categories = Database::store_result($result); |
101 | 101 | foreach ($categories as $category) { |
102 | - $category['nbr_courses'] = 1; |
|
102 | + $category['nbr_courses'] = 1; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $categories; |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | if ($row = Database::fetch_array($result)) { |
197 | 197 | if (!empty($row['parent_id'])) { |
198 | 198 | Database::query("UPDATE $tbl_course SET category_code = '".$row['parent_id']."' WHERE category_code='$node'"); |
199 | - Database::query("UPDATE $tbl_category SET parent_id='" . $row['parent_id'] . "' WHERE parent_id='$node'"); |
|
199 | + Database::query("UPDATE $tbl_category SET parent_id='".$row['parent_id']."' WHERE parent_id='$node'"); |
|
200 | 200 | } else { |
201 | 201 | Database::query("UPDATE $tbl_course SET category_code='' WHERE category_code='$node'"); |
202 | 202 | Database::query("UPDATE $tbl_category SET parent_id=NULL WHERE parent_id='$node'"); |
203 | 203 | } |
204 | 204 | |
205 | - Database::query("UPDATE $tbl_category SET tree_pos=tree_pos-1 WHERE tree_pos > '" . $row['tree_pos'] . "'"); |
|
205 | + Database::query("UPDATE $tbl_category SET tree_pos=tree_pos-1 WHERE tree_pos > '".$row['tree_pos']."'"); |
|
206 | 206 | Database::query("DELETE FROM $tbl_category WHERE code='$node'"); |
207 | 207 | |
208 | 208 | if (!empty($row['parent_id'])) { |
@@ -291,13 +291,13 @@ discard block |
||
291 | 291 | } |
292 | 292 | |
293 | 293 | $sql = "UPDATE $tbl_category |
294 | - SET tree_pos ='" . $row['tree_pos'] . "' |
|
294 | + SET tree_pos ='".$row['tree_pos']."' |
|
295 | 295 | WHERE code='$code'"; |
296 | 296 | Database::query($sql); |
297 | 297 | |
298 | 298 | $sql = "UPDATE $tbl_category |
299 | 299 | SET tree_pos = '$tree_pos' |
300 | - WHERE code= '" . $row['code'] . "'"; |
|
300 | + WHERE code= '".$row['code']."'"; |
|
301 | 301 | Database::query($sql); |
302 | 302 | |
303 | 303 | return true; |
@@ -424,12 +424,12 @@ discard block |
||
424 | 424 | |
425 | 425 | $editIcon = Display::return_icon('edit.png', get_lang('EditNode'), null, ICON_SIZE_SMALL); |
426 | 426 | $deleteIcon = Display::return_icon('delete.png', get_lang('DeleteNode'), null, ICON_SIZE_SMALL); |
427 | - $moveIcon = Display::return_icon('up.png', get_lang('UpInSameLevel'), null, ICON_SIZE_SMALL); |
|
427 | + $moveIcon = Display::return_icon('up.png', get_lang('UpInSameLevel'), null, ICON_SIZE_SMALL); |
|
428 | 428 | |
429 | 429 | foreach ($categories as $category) { |
430 | 430 | |
431 | 431 | $editUrl = $mainUrl.'&id='.$category['code'].'&action=edit'; |
432 | - $moveUrl = $mainUrl.'&id='.$category['code'].'&action=moveUp&tree_pos='.$category['tree_pos']; |
|
432 | + $moveUrl = $mainUrl.'&id='.$category['code'].'&action=moveUp&tree_pos='.$category['tree_pos']; |
|
433 | 433 | $deleteUrl = $mainUrl.'&id='.$category['code'].'&action=delete'; |
434 | 434 | |
435 | 435 | $actions = Display::url($editIcon, $editUrl).Display::url($moveIcon, $moveUrl).Display::url($deleteIcon, $deleteUrl); |
@@ -563,12 +563,12 @@ discard block |
||
563 | 563 | |
564 | 564 | $count_courses = countCoursesInCategory(); |
565 | 565 | |
566 | - $categories[0][count($categories[0])+1] = array( |
|
566 | + $categories[0][count($categories[0]) + 1] = array( |
|
567 | 567 | 'id' =>0, |
568 | 568 | 'name' => get_lang('None'), |
569 | 569 | 'code' => 'NONE', |
570 | 570 | 'parent_id' => null, |
571 | - 'tree_pos' => $row['tree_pos']+1, |
|
571 | + 'tree_pos' => $row['tree_pos'] + 1, |
|
572 | 572 | 'children_count' => 0, |
573 | 573 | 'auth_course_child' => true, |
574 | 574 | 'auth_cat_child' => true, |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | * @param string $searchTerm |
584 | 584 | * @return int |
585 | 585 | */ |
586 | -function countCoursesInCategory($category_code="", $searchTerm = '') |
|
586 | +function countCoursesInCategory($category_code = "", $searchTerm = '') |
|
587 | 587 | { |
588 | 588 | $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); |
589 | 589 | $categoryCode = Database::escape_string($category_code); |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | |
596 | 596 | $without_special_courses = ''; |
597 | 597 | if (!empty($specialCourseList)) { |
598 | - $without_special_courses = ' AND course.code NOT IN ("' . implode('","', $special_course_list) . '")'; |
|
598 | + $without_special_courses = ' AND course.code NOT IN ("'.implode('","', $special_course_list).'")'; |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | $visibilityCondition = null; |
@@ -609,15 +609,15 @@ discard block |
||
609 | 609 | if ($categoryCode == 'ALL') { |
610 | 610 | // Nothing to do |
611 | 611 | } elseif ($categoryCode == 'NONE') { |
612 | - $categoryFilter = ' AND category_code = "" '; |
|
612 | + $categoryFilter = ' AND category_code = "" '; |
|
613 | 613 | } else { |
614 | - $categoryFilter = ' AND category_code = "' . $categoryCode . '" '; |
|
614 | + $categoryFilter = ' AND category_code = "'.$categoryCode.'" '; |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | if (!empty($searchTerm)) { |
618 | - $searchFilter = ' AND (code LIKE "%' . $searchTerm . '%" |
|
619 | - OR title LIKE "%' . $searchTerm . '%" |
|
620 | - OR tutor_name LIKE "%' . $searchTerm . '%") '; |
|
618 | + $searchFilter = ' AND (code LIKE "%'.$searchTerm.'%" |
|
619 | + OR title LIKE "%' . $searchTerm.'%" |
|
620 | + OR tutor_name LIKE "%' . $searchTerm.'%") '; |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | $sql = "SELECT * FROM $tbl_course |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | |
669 | 669 | $without_special_courses = ''; |
670 | 670 | if (!empty($specialCourseList)) { |
671 | - $without_special_courses = ' AND course.code NOT IN ("' . implode('","', $special_course_list) . '")'; |
|
671 | + $without_special_courses = ' AND course.code NOT IN ("'.implode('","', $special_course_list).'")'; |
|
672 | 672 | } |
673 | 673 | $visibilityCondition = null; |
674 | 674 | $hidePrivate = api_get_setting('course_catalog_hide_private'); |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | $id_in = null; |
717 | 717 | while (list($id) = Database::fetch_row($result)) { |
718 | 718 | if ($id_in) { |
719 | - $id_in.=",$id"; |
|
719 | + $id_in .= ",$id"; |
|
720 | 720 | } else { |
721 | 721 | $id_in = "$id"; |
722 | 722 | } |
@@ -937,11 +937,9 @@ discard block |
||
937 | 937 | function getLimitArray() |
938 | 938 | { |
939 | 939 | $pageCurrent = isset($_REQUEST['pageCurrent']) ? |
940 | - intval($_GET['pageCurrent']) : |
|
941 | - 1; |
|
940 | + intval($_GET['pageCurrent']) : 1; |
|
942 | 941 | $pageLength = isset($_REQUEST['pageLength']) ? |
943 | - intval($_GET['pageLength']) : |
|
944 | - 10; |
|
942 | + intval($_GET['pageLength']) : 10; |
|
945 | 943 | return array( |
946 | 944 | 'start' => ($pageCurrent - 1) * $pageLength, |
947 | 945 | 'current' => $pageCurrent, |
@@ -960,7 +958,7 @@ discard block |
||
960 | 958 | if (!empty($limit) && is_array($limit)) { |
961 | 959 | $limitStart = isset($limit['start']) ? $limit['start'] : 0; |
962 | 960 | $limitLength = isset($limit['length']) ? $limit['length'] : 10; |
963 | - $limitFilter = 'LIMIT ' . $limitStart . ', ' . $limitLength; |
|
961 | + $limitFilter = 'LIMIT '.$limitStart.', '.$limitLength; |
|
964 | 962 | } |
965 | 963 | |
966 | 964 | return $limitFilter; |
@@ -977,7 +975,7 @@ discard block |
||
977 | 975 | { |
978 | 976 | // Start empty html |
979 | 977 | $pageDiv = ''; |
980 | - $html=''; |
|
978 | + $html = ''; |
|
981 | 979 | $pageBottom = max(1, $pageCurrent - 3); |
982 | 980 | $pageTop = min($pageTotal, $pageCurrent + 3); |
983 | 981 | |
@@ -1048,21 +1046,21 @@ discard block |
||
1048 | 1046 | $hiddenLinks = isset($hiddenLinks) ? Security::remove_XSS($hiddenLinksRequest) : $categoryCodeRequest; |
1049 | 1047 | |
1050 | 1048 | // Start URL with params |
1051 | - $pageUrl = api_get_self() . |
|
1052 | - '?action=' . $action . |
|
1053 | - '&category_code=' .$categoryCode. |
|
1054 | - '&hidden_links=' .$hiddenLinks. |
|
1055 | - '&pageCurrent=' . $pageCurrent . |
|
1056 | - '&pageLength=' . $pageLength |
|
1049 | + $pageUrl = api_get_self(). |
|
1050 | + '?action='.$action. |
|
1051 | + '&category_code='.$categoryCode. |
|
1052 | + '&hidden_links='.$hiddenLinks. |
|
1053 | + '&pageCurrent='.$pageCurrent. |
|
1054 | + '&pageLength='.$pageLength |
|
1057 | 1055 | ; |
1058 | 1056 | |
1059 | 1057 | switch ($action) { |
1060 | 1058 | case 'subscribe' : |
1061 | 1059 | // for search |
1062 | 1060 | $pageUrl .= |
1063 | - '&search_term=' . $searchTerm . |
|
1064 | - '&search_course=1' . |
|
1065 | - '&sec_token=' . $_SESSION['sec_token']; |
|
1061 | + '&search_term='.$searchTerm. |
|
1062 | + '&search_course=1'. |
|
1063 | + '&sec_token='.$_SESSION['sec_token']; |
|
1066 | 1064 | break; |
1067 | 1065 | case 'display_courses' : |
1068 | 1066 | // No break |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $from = intval($from); |
75 | 75 | $number_of_items = intval($number_of_items); |
76 | 76 | |
77 | - if (!in_array($direction, array('ASC','DESC'))) { |
|
77 | + if (!in_array($direction, array('ASC', 'DESC'))) { |
|
78 | 78 | $direction = 'ASC'; |
79 | 79 | } |
80 | 80 | |
@@ -97,24 +97,24 @@ discard block |
||
97 | 97 | $thematic[1] = '<a href="index.php?'.api_get_cidreq().'&action=thematic_details&thematic_id='.$thematic[0].'">'. |
98 | 98 | Security::remove_XSS($thematic[1], STUDENT).$session_star.'</a>'; |
99 | 99 | if (api_is_allowed_to_edit(null, true)) { |
100 | - $actions = ''; |
|
100 | + $actions = ''; |
|
101 | 101 | |
102 | 102 | if (api_get_session_id()) { |
103 | 103 | if (api_get_session_id() == $thematic[3]) { |
104 | 104 | $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$thematic[0].'">'. |
105 | - Display::return_icon('lesson_plan.png',get_lang('ThematicPlan'),'',ICON_SIZE_SMALL).'</a> '; |
|
105 | + Display::return_icon('lesson_plan.png', get_lang('ThematicPlan'), '', ICON_SIZE_SMALL).'</a> '; |
|
106 | 106 | $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$thematic[0].'">'. |
107 | - Display::return_icon('lesson_plan_calendar.png',get_lang('ThematicAdvance'),'',ICON_SIZE_SMALL).'</a> '; |
|
107 | + Display::return_icon('lesson_plan_calendar.png', get_lang('ThematicAdvance'), '', ICON_SIZE_SMALL).'</a> '; |
|
108 | 108 | |
109 | 109 | $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='.$thematic[0].'">'. |
110 | - Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'; |
|
110 | + Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'; |
|
111 | 111 | $actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_delete&thematic_id='.$thematic[0].'">'. |
112 | - Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
|
112 | + Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'; |
|
113 | 113 | } else { |
114 | - $actions .= Display::return_icon('lesson_plan_na.png',get_lang('ThematicPlan'),'',ICON_SIZE_SMALL).' '; |
|
115 | - $actions .= Display::return_icon('lesson_plan_calendar_na.png',get_lang('ThematicAdvance'),'',ICON_SIZE_SMALL).' '; |
|
116 | - $actions .= Display::return_icon('edit_na.png',get_lang('Edit'),'',ICON_SIZE_SMALL); |
|
117 | - $actions .= Display::return_icon('delete_na.png',get_lang('Delete'),'',ICON_SIZE_SMALL).' '; |
|
114 | + $actions .= Display::return_icon('lesson_plan_na.png', get_lang('ThematicPlan'), '', ICON_SIZE_SMALL).' '; |
|
115 | + $actions .= Display::return_icon('lesson_plan_calendar_na.png', get_lang('ThematicAdvance'), '', ICON_SIZE_SMALL).' '; |
|
116 | + $actions .= Display::return_icon('edit_na.png', get_lang('Edit'), '', ICON_SIZE_SMALL); |
|
117 | + $actions .= Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL).' '; |
|
118 | 118 | $actions .= Display::url( |
119 | 119 | Display::return_icon('cd.gif', get_lang('Copy')), |
120 | 120 | 'index.php?'.api_get_cidreq().'&action=thematic_copy&thematic_id='.$thematic[0] |
@@ -122,26 +122,26 @@ discard block |
||
122 | 122 | } |
123 | 123 | } else { |
124 | 124 | $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$thematic[0].'">'. |
125 | - Display::return_icon('lesson_plan.png',get_lang('ThematicPlan'),'',ICON_SIZE_SMALL).'</a> '; |
|
125 | + Display::return_icon('lesson_plan.png', get_lang('ThematicPlan'), '', ICON_SIZE_SMALL).'</a> '; |
|
126 | 126 | $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$thematic[0].'">'. |
127 | - Display::return_icon('lesson_plan_calendar.png',get_lang('ThematicAdvance'),'',ICON_SIZE_SMALL).'</a> '; |
|
127 | + Display::return_icon('lesson_plan_calendar.png', get_lang('ThematicAdvance'), '', ICON_SIZE_SMALL).'</a> '; |
|
128 | 128 | |
129 | 129 | if ($thematic[2] > 1) { |
130 | 130 | $actions .= '<a href="'.api_get_self().'?action=moveup&'.api_get_cidreq().'&thematic_id='.$thematic[0].'">'. |
131 | - Display::return_icon('up.png', get_lang('Up'),'',ICON_SIZE_SMALL).'</a>'; |
|
131 | + Display::return_icon('up.png', get_lang('Up'), '', ICON_SIZE_SMALL).'</a>'; |
|
132 | 132 | } else { |
133 | - $actions .= Display::return_icon('up_na.png',' ','',ICON_SIZE_SMALL); |
|
133 | + $actions .= Display::return_icon('up_na.png', ' ', '', ICON_SIZE_SMALL); |
|
134 | 134 | } |
135 | 135 | if ($thematic[2] < self::get_max_thematic_item()) { |
136 | 136 | $actions .= '<a href="'.api_get_self().'?action=movedown&a'.api_get_cidreq().'&thematic_id='.$thematic[0].'">'. |
137 | - Display::return_icon('down.png',get_lang('Down'),'',ICON_SIZE_SMALL).'</a>'; |
|
137 | + Display::return_icon('down.png', get_lang('Down'), '', ICON_SIZE_SMALL).'</a>'; |
|
138 | 138 | } else { |
139 | - $actions .= Display::return_icon('down_na.png',' ','',ICON_SIZE_SMALL); |
|
139 | + $actions .= Display::return_icon('down_na.png', ' ', '', ICON_SIZE_SMALL); |
|
140 | 140 | } |
141 | 141 | $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='.$thematic[0].'">'. |
142 | - Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'; |
|
142 | + Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'; |
|
143 | 143 | $actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_delete&thematic_id='.$thematic[0].'">'. |
144 | - Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
|
144 | + Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'; |
|
145 | 145 | } |
146 | 146 | $thematics[] = array($thematic[0], $thematic[1], $actions); |
147 | 147 | } |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | $res = Database::query($sql); |
279 | 279 | if (Database::num_rows($res) > 0) { |
280 | 280 | if (!empty($thematic_id)) { |
281 | - $data = Database::fetch_array($res,'ASSOC'); |
|
281 | + $data = Database::fetch_array($res, 'ASSOC'); |
|
282 | 282 | } else { |
283 | - while ($row = Database::fetch_array($res,'ASSOC')) { |
|
283 | + while ($row = Database::fetch_array($res, 'ASSOC')) { |
|
284 | 284 | $data[$row['id']] = $row; |
285 | 285 | } |
286 | 286 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | |
376 | 376 | if (is_array($thematic_id)) { |
377 | 377 | foreach ($thematic_id as $id) { |
378 | - $id = intval($id); |
|
378 | + $id = intval($id); |
|
379 | 379 | $sql = "UPDATE $tbl_thematic SET active = 0 |
380 | 380 | WHERE c_id = $course_id AND id = $id"; |
381 | 381 | $result = Database::query($sql); |
@@ -391,8 +391,8 @@ discard block |
||
391 | 391 | ); |
392 | 392 | } |
393 | 393 | } |
394 | - } else { |
|
395 | - $thematic_id = intval($thematic_id); |
|
394 | + } else { |
|
395 | + $thematic_id = intval($thematic_id); |
|
396 | 396 | $sql = "UPDATE $tbl_thematic SET active = 0 |
397 | 397 | WHERE c_id = $course_id AND id = $thematic_id"; |
398 | 398 | $result = Database::query($sql); |
@@ -428,8 +428,8 @@ discard block |
||
428 | 428 | $new_thematic_id = $thematic_copy->thematic_save(); |
429 | 429 | if (!empty($new_thematic_id)) { |
430 | 430 | $thematic_advanced = self::get_thematic_advance_by_thematic_id($thematic_id); |
431 | - if(!empty($thematic_advanced)) { |
|
432 | - foreach($thematic_advanced as $item) { |
|
431 | + if (!empty($thematic_advanced)) { |
|
432 | + foreach ($thematic_advanced as $item) { |
|
433 | 433 | $thematic = new Thematic(); |
434 | 434 | $thematic->set_thematic_advance_attributes( |
435 | 435 | 0, |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | $column = intval($column); |
493 | 493 | $from = intval($from); |
494 | 494 | $number_of_items = intval($number_of_items); |
495 | - if (!in_array($direction, array('ASC','DESC'))) { |
|
495 | + if (!in_array($direction, array('ASC', 'DESC'))) { |
|
496 | 496 | $direction = 'ASC'; |
497 | 497 | } |
498 | 498 | $data = array(); |
@@ -525,8 +525,8 @@ discard block |
||
525 | 525 | $thematic_advance[1] = api_get_local_time($thematic_advance[1]); |
526 | 526 | $thematic_advance[1] = api_format_date($thematic_advance[1], DATE_TIME_FORMAT_LONG); |
527 | 527 | $actions = ''; |
528 | - $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_edit&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.Display::return_icon('edit.png',get_lang('Edit'),'',22).'</a>'; |
|
529 | - $actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.Display::return_icon('delete.png',get_lang('Delete'),'',22).'</a></center>'; |
|
528 | + $actions .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_edit&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.Display::return_icon('edit.png', get_lang('Edit'), '', 22).'</a>'; |
|
529 | + $actions .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic_id.'&thematic_advance_id='.$thematic_advance[0].'">'.Display::return_icon('delete.png', get_lang('Delete'), '', 22).'</a></center>'; |
|
530 | 530 | $data[] = array($i, $thematic_advance[1], $thematic_advance[2], $thematic_advance[3], $actions); |
531 | 531 | $i++; |
532 | 532 | } |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | |
591 | 591 | $session_star = ''; |
592 | 592 | if (api_is_allowed_to_edit(null, true)) { |
593 | - if ($thematic_advance['session_id'] !=0) { |
|
593 | + if ($thematic_advance['session_id'] != 0) { |
|
594 | 594 | $session_star = api_get_session_image(api_get_session_id(), $uinfo['status']); |
595 | 595 | } |
596 | 596 | } |
@@ -616,13 +616,13 @@ discard block |
||
616 | 616 | |
617 | 617 | foreach ($data as $thematic_id => $thematic_plan_data) { |
618 | 618 | $new_thematic_plan_data = array(); |
619 | - foreach($thematic_plan_data as $thematic_item) { |
|
619 | + foreach ($thematic_plan_data as $thematic_item) { |
|
620 | 620 | $thematic_simple_list[] = $thematic_item['description_type']; |
621 | 621 | $new_thematic_plan_data[$thematic_item['description_type']] = $thematic_item; |
622 | 622 | } |
623 | 623 | |
624 | 624 | if (!empty($thematic_simple_list)) { |
625 | - foreach($thematic_simple_list as $item) { |
|
625 | + foreach ($thematic_simple_list as $item) { |
|
626 | 626 | $default_thematic_plan_title[$item] = $new_thematic_plan_data[$item]['title']; |
627 | 627 | } |
628 | 628 | } |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | } |
639 | 639 | if (!empty($data[$thematic_id][$id]['title']) && !empty($data[$thematic_id][$id]['description'])) { |
640 | 640 | if (api_is_allowed_to_edit(null, true)) { |
641 | - if ($data[$thematic_id][$id]['session_id'] !=0) { |
|
641 | + if ($data[$thematic_id][$id]['session_id'] != 0) { |
|
642 | 642 | $session_star = api_get_session_image(api_get_session_id(), $uinfo['status']); |
643 | 643 | } |
644 | 644 | } |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | if ($no_data) { |
652 | 652 | $return .= '<div><em>'.get_lang('StillDoNotHaveAThematicPlan').'</em></div>'; |
653 | 653 | } |
654 | - $return .= '</div>'; |
|
654 | + $return .= '</div>'; |
|
655 | 655 | $final_return[$thematic_id] = $return; |
656 | 656 | } |
657 | 657 | return $final_return; |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | api_get_session_id() |
692 | 692 | ); |
693 | 693 | foreach ($list as $value) { |
694 | - $elements[$value['ref']]= $value; |
|
694 | + $elements[$value['ref']] = $value; |
|
695 | 695 | } |
696 | 696 | } |
697 | 697 | |
@@ -865,18 +865,18 @@ discard block |
||
865 | 865 | api_get_session_id() |
866 | 866 | ); |
867 | 867 | |
868 | - $thematic_plan_complete_list = array(); |
|
868 | + $thematic_plan_complete_list = array(); |
|
869 | 869 | $thematic_plan_id_list = array(); |
870 | 870 | |
871 | 871 | if (!empty($items_from_course)) { |
872 | - foreach($items_from_course as $item) { |
|
872 | + foreach ($items_from_course as $item) { |
|
873 | 873 | $thematic_plan_id_list[] = $item['ref']; |
874 | 874 | $thematic_plan_complete_list[$item['ref']] = $item; |
875 | 875 | } |
876 | 876 | } |
877 | 877 | |
878 | 878 | if (!empty($items_from_session)) { |
879 | - foreach($items_from_session as $item) { |
|
879 | + foreach ($items_from_session as $item) { |
|
880 | 880 | $thematic_plan_id_list[] = $item['ref']; |
881 | 881 | $thematic_plan_complete_list[$item['ref']] = $item; |
882 | 882 | } |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | if (!isset($thematic_id) && !isset($description_type)) { |
899 | 899 | // group all data group by thematic id |
900 | 900 | $tmp = array(); |
901 | - while ($row = Database::fetch_array($rs,'ASSOC')) { |
|
901 | + while ($row = Database::fetch_array($rs, 'ASSOC')) { |
|
902 | 902 | $tmp[] = $row['thematic_id']; |
903 | 903 | if (in_array($row['thematic_id'], $tmp)) { |
904 | 904 | $row['session_id'] = $thematic_plan_complete_list[$row['id']]; |
@@ -906,7 +906,7 @@ discard block |
||
906 | 906 | } |
907 | 907 | } |
908 | 908 | } else { |
909 | - while ($row = Database::fetch_array($rs,'ASSOC')) { |
|
909 | + while ($row = Database::fetch_array($rs, 'ASSOC')) { |
|
910 | 910 | $row['session_id'] = $thematic_plan_complete_list[$row['id']]; |
911 | 911 | $data[] = $row; |
912 | 912 | } |
@@ -941,8 +941,8 @@ discard block |
||
941 | 941 | ); |
942 | 942 | |
943 | 943 | $elements_to_show = array(); |
944 | - foreach($list as $value) { |
|
945 | - $elements_to_show[]= $value['ref']; |
|
944 | + foreach ($list as $value) { |
|
945 | + $elements_to_show[] = $value['ref']; |
|
946 | 946 | } |
947 | 947 | $condition = ''; |
948 | 948 | if (!empty($elements_to_show)) { |
@@ -954,7 +954,7 @@ discard block |
||
954 | 954 | c_id = $course_id AND |
955 | 955 | thematic_id = $thematic_id AND |
956 | 956 | description_type = '$description_type'"; |
957 | - $rs = Database::query($sql); |
|
957 | + $rs = Database::query($sql); |
|
958 | 958 | |
959 | 959 | $affected_rows = 0; |
960 | 960 | if (Database::num_rows($rs) > 0) { |
@@ -1190,7 +1190,7 @@ discard block |
||
1190 | 1190 | $diff = array_diff($all, $a_thematic_advance_ids); |
1191 | 1191 | if (!empty($diff)) { |
1192 | 1192 | $upd = "UPDATE $tbl_thematic_advance SET done_advance = 0 |
1193 | - WHERE c_id = $course_id AND id IN(".implode(',',$diff).") "; |
|
1193 | + WHERE c_id = $course_id AND id IN(".implode(',', $diff).") "; |
|
1194 | 1194 | Database::query($upd); |
1195 | 1195 | } |
1196 | 1196 | |
@@ -1304,7 +1304,7 @@ discard block |
||
1304 | 1304 | $course_code = api_get_course_id(); |
1305 | 1305 | } |
1306 | 1306 | if (api_get_session_id()) { |
1307 | - $thematic_data = $this->get_thematic_list(null, $course_code ); |
|
1307 | + $thematic_data = $this->get_thematic_list(null, $course_code); |
|
1308 | 1308 | } else { |
1309 | 1309 | $thematic_data = $this->get_thematic_list(null, $course_code, 0); |
1310 | 1310 | } |
@@ -1356,7 +1356,7 @@ discard block |
||
1356 | 1356 | } |
1357 | 1357 | // calculate average by thematic |
1358 | 1358 | $count_total_advances = count($advances); |
1359 | - $average = round(($count_done_advances*100)/$count_total_advances); |
|
1359 | + $average = round(($count_done_advances * 100) / $count_total_advances); |
|
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | return $average; |
@@ -1447,12 +1447,12 @@ discard block |
||
1447 | 1447 | public function get_default_thematic_plan_title() |
1448 | 1448 | { |
1449 | 1449 | $default_thematic_plan_titles = array(); |
1450 | - $default_thematic_plan_titles[1]= get_lang('Objectives'); |
|
1451 | - $default_thematic_plan_titles[2]= get_lang('SkillToAcquire'); |
|
1452 | - $default_thematic_plan_titles[3]= get_lang('Methodology'); |
|
1453 | - $default_thematic_plan_titles[4]= get_lang('Infrastructure'); |
|
1454 | - $default_thematic_plan_titles[5]= get_lang('Assessment'); |
|
1455 | - $default_thematic_plan_titles[6]= get_lang('Others'); |
|
1450 | + $default_thematic_plan_titles[1] = get_lang('Objectives'); |
|
1451 | + $default_thematic_plan_titles[2] = get_lang('SkillToAcquire'); |
|
1452 | + $default_thematic_plan_titles[3] = get_lang('Methodology'); |
|
1453 | + $default_thematic_plan_titles[4] = get_lang('Infrastructure'); |
|
1454 | + $default_thematic_plan_titles[5] = get_lang('Assessment'); |
|
1455 | + $default_thematic_plan_titles[6] = get_lang('Others'); |
|
1456 | 1456 | |
1457 | 1457 | return $default_thematic_plan_titles; |
1458 | 1458 | } |
@@ -1464,12 +1464,12 @@ discard block |
||
1464 | 1464 | public function get_default_thematic_plan_icon() |
1465 | 1465 | { |
1466 | 1466 | $default_thematic_plan_icon = array(); |
1467 | - $default_thematic_plan_icon[1]= 'icons/32/objective.png'; |
|
1468 | - $default_thematic_plan_icon[2]= 'icons/32/skills.png'; |
|
1469 | - $default_thematic_plan_icon[3]= 'icons/32/strategy.png'; |
|
1470 | - $default_thematic_plan_icon[4]= 'icons/32/laptop.png'; |
|
1471 | - $default_thematic_plan_icon[5]= 'icons/32/assessment.png'; |
|
1472 | - $default_thematic_plan_icon[6]= 'icons/32/wizard.png'; |
|
1467 | + $default_thematic_plan_icon[1] = 'icons/32/objective.png'; |
|
1468 | + $default_thematic_plan_icon[2] = 'icons/32/skills.png'; |
|
1469 | + $default_thematic_plan_icon[3] = 'icons/32/strategy.png'; |
|
1470 | + $default_thematic_plan_icon[4] = 'icons/32/laptop.png'; |
|
1471 | + $default_thematic_plan_icon[5] = 'icons/32/assessment.png'; |
|
1472 | + $default_thematic_plan_icon[6] = 'icons/32/wizard.png'; |
|
1473 | 1473 | |
1474 | 1474 | return $default_thematic_plan_icon; |
1475 | 1475 | } |
@@ -1481,11 +1481,11 @@ discard block |
||
1481 | 1481 | public function get_default_question() |
1482 | 1482 | { |
1483 | 1483 | $question = array(); |
1484 | - $question[1]= get_lang('ObjectivesQuestions'); |
|
1485 | - $question[2]= get_lang('SkillToAcquireQuestions'); |
|
1486 | - $question[3]= get_lang('MethodologyQuestions'); |
|
1487 | - $question[4]= get_lang('InfrastructureQuestions'); |
|
1488 | - $question[5]= get_lang('AssessmentQuestions'); |
|
1484 | + $question[1] = get_lang('ObjectivesQuestions'); |
|
1485 | + $question[2] = get_lang('SkillToAcquireQuestions'); |
|
1486 | + $question[3] = get_lang('MethodologyQuestions'); |
|
1487 | + $question[4] = get_lang('InfrastructureQuestions'); |
|
1488 | + $question[5] = get_lang('AssessmentQuestions'); |
|
1489 | 1489 | |
1490 | 1490 | return $question; |
1491 | 1491 | } |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | * @param int $glossary_id |
40 | 40 | * @return string The glossary description |
41 | 41 | */ |
42 | - public static function get_glossary_term_by_glossary_id ($glossary_id) |
|
42 | + public static function get_glossary_term_by_glossary_id($glossary_id) |
|
43 | 43 | { |
44 | - $glossary_table = Database::get_course_table(TABLE_GLOSSARY); |
|
44 | + $glossary_table = Database::get_course_table(TABLE_GLOSSARY); |
|
45 | 45 | $course_id = api_get_course_int_id(); |
46 | 46 | $sql = "SELECT description FROM $glossary_table |
47 | 47 | WHERE c_id = $course_id AND glossary_id =".intval($glossary_id); |
48 | - $rs=Database::query($sql); |
|
48 | + $rs = Database::query($sql); |
|
49 | 49 | if (Database::num_rows($rs) > 0) { |
50 | 50 | $row = Database::fetch_array($rs); |
51 | 51 | |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | * @param string The glossary term name |
62 | 62 | * @return string The glossary description |
63 | 63 | */ |
64 | - public static function get_glossary_term_by_glossary_name ($glossary_name) |
|
64 | + public static function get_glossary_term_by_glossary_name($glossary_name) |
|
65 | 65 | { |
66 | - $glossary_table = Database::get_course_table(TABLE_GLOSSARY); |
|
66 | + $glossary_table = Database::get_course_table(TABLE_GLOSSARY); |
|
67 | 67 | $session_id = api_get_session_id(); |
68 | 68 | $course_id = api_get_course_int_id(); |
69 | 69 | $sql_filter = api_get_session_condition($session_id); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $course_id = api_get_course_int_id(); |
164 | 164 | |
165 | 165 | // check if the glossary term already exists |
166 | - if (GlossaryManager::glossary_exists($values['glossary_title'],$values['glossary_id'])) { |
|
166 | + if (GlossaryManager::glossary_exists($values['glossary_title'], $values['glossary_id'])) { |
|
167 | 167 | // display the feedback message |
168 | 168 | if ($message) |
169 | 169 | Display::display_error_message(get_lang('GlossaryTermAlreadyExistsYouShouldEditIt')); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $get_max = "SELECT MAX(display_order) FROM $t_glossary |
211 | 211 | WHERE c_id = $course_id "; |
212 | 212 | $res_max = Database::query($get_max); |
213 | - if (Database::num_rows($res_max)==0) { |
|
213 | + if (Database::num_rows($res_max) == 0) { |
|
214 | 214 | return 0; |
215 | 215 | } |
216 | 216 | $row = Database::fetch_array($res_max); |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @author Patrick Cool <[email protected]>, Ghent University, Belgium |
232 | 232 | * @version januari 2009, dokeos 1.8.6 |
233 | 233 | */ |
234 | - public static function glossary_exists($term, $not_id='') |
|
234 | + public static function glossary_exists($term, $not_id = '') |
|
235 | 235 | { |
236 | 236 | // Database table definition |
237 | 237 | $t_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | WHERE |
242 | 242 | c_id = $course_id AND |
243 | 243 | name = '".Database::escape_string($term)."'"; |
244 | - if ($not_id<>'') { |
|
244 | + if ($not_id <> '') { |
|
245 | 245 | $sql .= " AND glossary_id <> '".intval($not_id)."'"; |
246 | 246 | } |
247 | 247 | $result = Database::query($sql); |
@@ -347,27 +347,27 @@ discard block |
||
347 | 347 | // action links |
348 | 348 | echo '<div class="actions">'; |
349 | 349 | |
350 | - if (api_is_allowed_to_edit(null,true)) { |
|
350 | + if (api_is_allowed_to_edit(null, true)) { |
|
351 | 351 | echo '<a href="index.php?'.api_get_cidreq().'&action=addglossary&msg=add?'.api_get_cidreq().'">'. |
352 | - Display::return_icon('new_glossary_term.png',get_lang('TermAddNew'),'', ICON_SIZE_MEDIUM).'</a>'; |
|
352 | + Display::return_icon('new_glossary_term.png', get_lang('TermAddNew'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | echo '<a href="index.php?'.api_get_cidreq().'&action=export">'. |
356 | - Display::return_icon('export_csv.png',get_lang('ExportGlossaryAsCSV'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
357 | - if (api_is_allowed_to_edit(null,true)) { |
|
356 | + Display::return_icon('export_csv.png', get_lang('ExportGlossaryAsCSV'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
357 | + if (api_is_allowed_to_edit(null, true)) { |
|
358 | 358 | echo '<a href="index.php?'.api_get_cidreq().'&action=import">'. |
359 | - Display::return_icon('import_csv.png',get_lang('ImportGlossary'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
359 | + Display::return_icon('import_csv.png', get_lang('ImportGlossary'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | echo '<a href="index.php?'.api_get_cidreq().'&action=export_to_pdf">'. |
363 | - Display::return_icon('pdf.png',get_lang('ExportToPDF'),'', ICON_SIZE_MEDIUM).'</a>'; |
|
363 | + Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
364 | 364 | |
365 | - if ((isset($_SESSION['glossary_view']) && $_SESSION['glossary_view'] == 'table') or (!isset($_SESSION['glossary_view']))){ |
|
365 | + if ((isset($_SESSION['glossary_view']) && $_SESSION['glossary_view'] == 'table') or (!isset($_SESSION['glossary_view']))) { |
|
366 | 366 | echo '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=list">'. |
367 | - Display::return_icon('view_detailed.png',get_lang('ListView'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
367 | + Display::return_icon('view_detailed.png', get_lang('ListView'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
368 | 368 | } else { |
369 | 369 | echo '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=table">'. |
370 | - Display::return_icon('view_text.png',get_lang('TableView'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
370 | + Display::return_icon('view_text.png', get_lang('TableView'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
371 | 371 | } |
372 | 372 | echo '</div>'; |
373 | 373 | if (!$_SESSION['glossary_view'] || $_SESSION['glossary_view'] == 'table') { |
@@ -380,9 +380,9 @@ discard block |
||
380 | 380 | //$table->set_header(0, '', false); |
381 | 381 | $table->set_header(0, get_lang('TermName'), true); |
382 | 382 | $table->set_header(1, get_lang('TermDefinition'), true); |
383 | - if (api_is_allowed_to_edit(null,true)) { |
|
383 | + if (api_is_allowed_to_edit(null, true)) { |
|
384 | 384 | $table->set_header(2, get_lang('Actions'), false, 'width=90px', array('class' => 'td_actions')); |
385 | - $table->set_column_filter(2, array('GlossaryManager','actions_filter')); |
|
385 | + $table->set_column_filter(2, array('GlossaryManager', 'actions_filter')); |
|
386 | 386 | } |
387 | 387 | $table->display(); |
388 | 388 | } |
@@ -399,11 +399,11 @@ discard block |
||
399 | 399 | */ |
400 | 400 | public static function display_glossary_list() |
401 | 401 | { |
402 | - $glossary_data = self::get_glossary_data(0,1000,0,'ASC'); |
|
402 | + $glossary_data = self::get_glossary_data(0, 1000, 0, 'ASC'); |
|
403 | 403 | foreach ($glossary_data as $key => $glossary_item) { |
404 | 404 | $actions = ''; |
405 | - if (api_is_allowed_to_edit(null,true)) { |
|
406 | - $actions = '<div class="pull-right">'.self::actions_filter($glossary_item[2], '',$glossary_item).'</div>'; |
|
405 | + if (api_is_allowed_to_edit(null, true)) { |
|
406 | + $actions = '<div class="pull-right">'.self::actions_filter($glossary_item[2], '', $glossary_item).'</div>'; |
|
407 | 407 | } |
408 | 408 | echo Display::panel($glossary_item[1], $glossary_item[0].' '.$actions); |
409 | 409 | } |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * @author Patrick Cool <[email protected]>, Ghent University, Belgium |
419 | 419 | * @version januari 2009, dokeos 1.8.6 |
420 | 420 | */ |
421 | - public static function get_number_glossary_terms($session_id=0) |
|
421 | + public static function get_number_glossary_terms($session_id = 0) |
|
422 | 422 | { |
423 | 423 | // Database table definition |
424 | 424 | $t_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | $t_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
457 | 457 | $t_item_propery = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
458 | 458 | |
459 | - if (api_is_allowed_to_edit(null,true)) { |
|
459 | + if (api_is_allowed_to_edit(null, true)) { |
|
460 | 460 | $col2 = " glossary.glossary_id as col2, "; |
461 | 461 | } else { |
462 | 462 | $col2 = " "; |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | 'glossary.session_id' |
472 | 472 | ); |
473 | 473 | $column = intval($column); |
474 | - if (!in_array($direction,array('DESC', 'ASC'))) { |
|
475 | - $direction = 'ASC'; |
|
474 | + if (!in_array($direction, array('DESC', 'ASC'))) { |
|
475 | + $direction = 'ASC'; |
|
476 | 476 | } |
477 | 477 | $from = intval($from); |
478 | 478 | $number_of_items = intval($number_of_items); |
@@ -497,15 +497,15 @@ discard block |
||
497 | 497 | while ($data = Database::fetch_array($res)) { |
498 | 498 | // Validation when belongs to a session |
499 | 499 | $session_img = api_get_session_image($data['session_id'], $_user['status']); |
500 | - $array[0] = $data[0] . $session_img; |
|
500 | + $array[0] = $data[0].$session_img; |
|
501 | 501 | |
502 | 502 | if (!$_SESSION['glossary_view'] || $_SESSION['glossary_view'] == 'table') { |
503 | - $array[1] = str_replace(array('<p>','</p>'),array('','<br />'),$data[1]); |
|
503 | + $array[1] = str_replace(array('<p>', '</p>'), array('', '<br />'), $data[1]); |
|
504 | 504 | } else { |
505 | 505 | $array[1] = $data[1]; |
506 | 506 | } |
507 | 507 | |
508 | - if (api_is_allowed_to_edit(null,true)) { |
|
508 | + if (api_is_allowed_to_edit(null, true)) { |
|
509 | 509 | $array[2] = $data[2]; |
510 | 510 | } |
511 | 511 | $return[] = $array; |
@@ -528,14 +528,14 @@ discard block |
||
528 | 528 | public static function actions_filter($glossary_id, $url_params, $row) |
529 | 529 | { |
530 | 530 | $glossary_id = $row[2]; |
531 | - $return = '<a href="'.api_get_self().'?action=edit_glossary&glossary_id='.$glossary_id.'&'.api_get_cidreq().'&msg=edit">'.Display::return_icon('edit.png',get_lang('Edit'),'',22).'</a>'; |
|
531 | + $return = '<a href="'.api_get_self().'?action=edit_glossary&glossary_id='.$glossary_id.'&'.api_get_cidreq().'&msg=edit">'.Display::return_icon('edit.png', get_lang('Edit'), '', 22).'</a>'; |
|
532 | 532 | $glossary_data = GlossaryManager::get_glossary_information($glossary_id); |
533 | 533 | |
534 | 534 | $glossary_term = $glossary_data['glossary_title']; |
535 | 535 | |
536 | 536 | if (api_is_allowed_to_edit(null, true)) { |
537 | 537 | if ($glossary_data['session_id'] == api_get_session_id()) { |
538 | - $return .= '<a href="'.api_get_self().'?action=delete_glossary&glossary_id='.$glossary_id.'&'.api_get_cidreq().'" onclick="return confirmation(\''.$glossary_term.'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',22).'</a>'; |
|
538 | + $return .= '<a href="'.api_get_self().'?action=delete_glossary&glossary_id='.$glossary_id.'&'.api_get_cidreq().'" onclick="return confirmation(\''.$glossary_term.'\');">'.Display::return_icon('delete.png', get_lang('Delete'), '', 22).'</a>'; |
|
539 | 539 | } else { |
540 | 540 | $return = get_lang('EditionNotAvailableFromSession'); |
541 | 541 | } |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | { |
557 | 557 | return "<script type=\"text/javascript\"> |
558 | 558 | function confirmation (name) { |
559 | - if (confirm(\" ". get_lang("TermConfirmDelete") ." \"+ name + \" ?\")) |
|
559 | + if (confirm(\" ". get_lang("TermConfirmDelete")." \"+ name + \" ?\")) |
|
560 | 560 | {return true;} |
561 | 561 | else |
562 | 562 | {return false;} |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | $res = Database::query($sql); |
617 | 617 | $found = false; |
618 | 618 | while ($row = Database::fetch_array($res)) { |
619 | - if ($found && empty($next_id)) { |
|
619 | + if ($found && empty($next_id)) { |
|
620 | 620 | $next_id = $row['glossary_id']; |
621 | 621 | $next_display_order = $row['display_order']; |
622 | 622 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | ) { |
106 | 106 | require_once api_get_path(SYS_CODE_PATH).'/cron/lang/langstats.class.php'; |
107 | 107 | global $langstats; |
108 | - $langstats->add_use($variable,''); |
|
108 | + $langstats->add_use($variable, ''); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | if (!isset($used_lang_vars)) { |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | if ($use_users_timezone == 'true') { |
372 | 372 | $userId = api_get_user_id(); |
373 | 373 | // Get the timezone based on user preference, if it exists |
374 | - $timezone_user = UserManager::get_extra_user_data_by_field($userId,'timezone'); |
|
374 | + $timezone_user = UserManager::get_extra_user_data_by_field($userId, 'timezone'); |
|
375 | 375 | if (isset($timezone_user['timezone']) && $timezone_user['timezone'] != null) { |
376 | 376 | $to_timezone = $timezone_user['timezone']; |
377 | 377 | } |
@@ -636,10 +636,10 @@ discard block |
||
636 | 636 | // We replace %a %A %b %B masks of date format with translated strings |
637 | 637 | $translated = &_api_get_day_month_names($language); |
638 | 638 | $date_format = str_replace(array('%A', '%a', '%B', '%b'), |
639 | - array($translated['days_long'][(int)strftime('%w', $time )], |
|
640 | - $translated['days_short'][(int)strftime('%w', $time)], |
|
641 | - $translated['months_long'][(int)strftime('%m', $time) - 1], |
|
642 | - $translated['months_short'][(int)strftime('%m', $time) - 1]), |
|
639 | + array($translated['days_long'][(int) strftime('%w', $time)], |
|
640 | + $translated['days_short'][(int) strftime('%w', $time)], |
|
641 | + $translated['months_long'][(int) strftime('%m', $time) - 1], |
|
642 | + $translated['months_short'][(int) strftime('%m', $time) - 1]), |
|
643 | 643 | $date_format); |
644 | 644 | $formatted_date = api_to_system_encoding(strftime($date_format, $time), 'UTF-8'); |
645 | 645 | } |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | if ($seconds > $time) { |
738 | 738 | continue; |
739 | 739 | } |
740 | - $current_value = intval($time/$seconds); |
|
740 | + $current_value = intval($time / $seconds); |
|
741 | 741 | |
742 | 742 | if ($current_value != 1) { |
743 | 743 | $date_str = $sec_time_plu[$i]; |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | } |
755 | 755 | |
756 | 756 | if (!empty($key_result)) { |
757 | - if ($key_result[0] == $min_day && $key_result[1]== $min_minute) { |
|
757 | + if ($key_result[0] == $min_day && $key_result[1] == $min_minute) { |
|
758 | 758 | $key_result[1] = ' 0 '.$min_hours; |
759 | 759 | $str_result[0] = $time_result[0].' '.$key_result[0]; |
760 | 760 | $str_result[1] = $key_result[1]; |
@@ -1687,7 +1687,7 @@ discard block |
||
1687 | 1687 | * @return string Returns the encoding identificator modified in suitable for comparison way. |
1688 | 1688 | */ |
1689 | 1689 | function api_refine_encoding_id($encoding) { |
1690 | - if (is_array($encoding)){ |
|
1690 | + if (is_array($encoding)) { |
|
1691 | 1691 | return array_map('api_refine_encoding_id', $encoding); |
1692 | 1692 | } |
1693 | 1693 | return strtoupper(str_replace('_', '-', $encoding)); |