@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @author Kjell-Inge Gustafsson <[email protected]> |
138 | 138 | * @since 2.4.8 - 2008-10-21 |
139 | 139 | * @param string $value |
140 | - * @return void |
|
140 | + * @return false|null |
|
141 | 141 | */ |
142 | 142 | function setCalscale( $value ) { |
143 | 143 | if( empty( $value )) return FALSE; |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @author Kjell-Inge Gustafsson <[email protected]> |
274 | 274 | * @since 2.4.8 - 2008-10-23 |
275 | 275 | * @param string $value |
276 | - * @return void |
|
276 | + * @return boolean |
|
277 | 277 | */ |
278 | 278 | function setVersion( $value ) { |
279 | 279 | if( empty( $value )) return FALSE; |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | * @since 2.5.1 - 2008-11-02 |
398 | 398 | * @param string $propName, optional |
399 | 399 | * @param int @propix, optional, if specific property is wanted in case of multiply occurences |
400 | - * @param bool $inclParam=FALSE |
|
400 | + * @param bool $inclParam |
|
401 | 401 | * @return mixed |
402 | 402 | */ |
403 | 403 | function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE ) { |
@@ -448,9 +448,6 @@ discard block |
||
448 | 448 | * |
449 | 449 | * @author Kjell-Inge Gustafsson <[email protected]> |
450 | 450 | * @since 2.2.13 - 2007-11-04 |
451 | - * @param mixed $args variable number of function arguments, |
|
452 | - * first argument is ALWAYS component name, |
|
453 | - * second ALWAYS component value! |
|
454 | 451 | * @return bool |
455 | 452 | */ |
456 | 453 | function setProperty () { |
@@ -480,7 +477,7 @@ discard block |
||
480 | 477 | * @author Kjell-Inge Gustafsson <[email protected]> |
481 | 478 | * @since 2.4.10 - 2008-10-23 |
482 | 479 | * @param string $config |
483 | - * @return value |
|
480 | + * @return string |
|
484 | 481 | */ |
485 | 482 | function getConfig( $config ) { |
486 | 483 | switch( strtoupper( $config )) { |
@@ -701,7 +698,7 @@ discard block |
||
701 | 698 | * @since 2.4.10 - 2008-08-05 |
702 | 699 | * @param mixed $arg1 ordno / component type / component uid |
703 | 700 | * @param mixed $arg2 optional, ordno if arg1 = component type |
704 | - * @return void |
|
701 | + * @return boolean |
|
705 | 702 | */ |
706 | 703 | function deleteComponent( $arg1, $arg2=FALSE ) { |
707 | 704 | $argType = $index = null; |
@@ -1060,7 +1057,7 @@ discard block |
||
1060 | 1057 | * @param object $component calendar component |
1061 | 1058 | * @param mixed $arg1 optional, ordno/component type/ component uid |
1062 | 1059 | * @param mixed $arg2 optional, ordno if arg1 = component type |
1063 | - * @return void |
|
1060 | + * @return boolean |
|
1064 | 1061 | */ |
1065 | 1062 | function setComponent( $component, $arg1=FALSE, $arg2=FALSE ) { |
1066 | 1063 | if( '' >= $component->getConfig( 'language')) |
@@ -2311,7 +2308,7 @@ discard block |
||
2311 | 2308 | * @param int $min optional |
2312 | 2309 | * @param int $sec optional |
2313 | 2310 | * @param array $params optional |
2314 | - * @return TRUE |
|
2311 | + * @return boolean |
|
2315 | 2312 | */ |
2316 | 2313 | function setDtstamp( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
2317 | 2314 | if( empty( $year )) |
@@ -2794,7 +2791,7 @@ discard block |
||
2794 | 2791 | * @param int $min optional |
2795 | 2792 | * @param int $sec optional |
2796 | 2793 | * @param array $params optional |
2797 | - * @return boll |
|
2794 | + * @return boolean |
|
2798 | 2795 | */ |
2799 | 2796 | function setLastModified( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
2800 | 2797 | if( empty( $year )) |
@@ -3215,7 +3212,6 @@ discard block |
||
3215 | 3212 | * |
3216 | 3213 | * @author Kjell-Inge Gustafsson <[email protected]> |
3217 | 3214 | * @since 2.5.1 - 2008-11-07 |
3218 | - * @param float $relid |
|
3219 | 3215 | * @param array $params, optional |
3220 | 3216 | * @param index $index, optional |
3221 | 3217 | * @return bool |
@@ -3253,7 +3249,7 @@ discard block |
||
3253 | 3249 | * @since 2.4.8 - 2008-11-04 |
3254 | 3250 | * @param string $value |
3255 | 3251 | * @param array $params optional |
3256 | - * @return void |
|
3252 | + * @return boolean |
|
3257 | 3253 | */ |
3258 | 3254 | function setRepeat( $value, $params=FALSE ) { |
3259 | 3255 | if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
@@ -3376,7 +3372,7 @@ discard block |
||
3376 | 3372 | * @param array $rruleset |
3377 | 3373 | * @param array $params, optional |
3378 | 3374 | * @param integer $index, optional |
3379 | - * @return void |
|
3375 | + * @return boolean |
|
3380 | 3376 | */ |
3381 | 3377 | function setRrule( $rruleset, $params=FALSE, $index=FALSE ) { |
3382 | 3378 | if( empty( $rruleset )) if( $this->getConfig( 'allowEmpty' )) $rruleset = null; else return FALSE; |
@@ -3802,7 +3798,7 @@ discard block |
||
3802 | 3798 | * @since 2.4.8 - 2008-11-04 |
3803 | 3799 | * @param string $value |
3804 | 3800 | * @param string $params optional |
3805 | - * @return boll |
|
3801 | + * @return boolean |
|
3806 | 3802 | */ |
3807 | 3803 | function setTzurl( $value, $params=FALSE ) { |
3808 | 3804 | if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
@@ -3931,7 +3927,7 @@ discard block |
||
3931 | 3927 | * @param string $label |
3932 | 3928 | * @param mixed $value |
3933 | 3929 | * @param array $params optional |
3934 | - * @return bool |
|
3930 | + * @return null|boolean |
|
3935 | 3931 | */ |
3936 | 3932 | function setXprop( $label, $value, $params=FALSE ) { |
3937 | 3933 | if( empty( $label )) return; |
@@ -4098,7 +4094,7 @@ discard block |
||
4098 | 4094 | * @author Kjell-Inge Gustafsson <[email protected]> |
4099 | 4095 | * @since 0.9.22 - 2007-04-10 |
4100 | 4096 | * @param array $params optional |
4101 | - * @param array $ctrKeys optional |
|
4097 | + * @param string[] $ctrKeys optional |
|
4102 | 4098 | * @return string |
4103 | 4099 | */ |
4104 | 4100 | function _createParams( $params=array(), $ctrKeys=array() ) { |
@@ -4140,7 +4136,6 @@ discard block |
||
4140 | 4136 | * |
4141 | 4137 | * @author Kjell-Inge Gustafsson <[email protected]> |
4142 | 4138 | * @since 2.4.16 - 2008-10-25 |
4143 | - * @param array $date, date to check |
|
4144 | 4139 | * @param int $parno, no of date parts (i.e. year, month.. .) |
4145 | 4140 | * @return array $params, property parameters |
4146 | 4141 | */ |
@@ -4196,7 +4191,6 @@ discard block |
||
4196 | 4191 | * @author Kjell-Inge Gustafsson <[email protected]> |
4197 | 4192 | * @since 2.2.11 - 2007-11-03 |
4198 | 4193 | * @param array $startdate, optional |
4199 | - * @param array $duration, optional |
|
4200 | 4194 | * @return array duration |
4201 | 4195 | */ |
4202 | 4196 | function _date2duration( $startdate=FALSE, $enddate=FALSE ) { |
@@ -4230,7 +4224,7 @@ discard block |
||
4230 | 4224 | * @since 2.4.8 - 2008-10-30 |
4231 | 4225 | * @param array $datetime datetime/(date) |
4232 | 4226 | * @param string $tz timezone |
4233 | - * @return timestamp |
|
4227 | + * @return integer |
|
4234 | 4228 | */ |
4235 | 4229 | function _date2timestamp( $datetime, $tz=null ) { |
4236 | 4230 | $output = null; |
@@ -4580,6 +4574,7 @@ discard block |
||
4580 | 4574 | * @param int $hitVal optional, return value if found |
4581 | 4575 | * @param int $elseVal optional, return value if not found |
4582 | 4576 | * @param int $preSet optional, return value if already preset |
4577 | + * @param string $expkey |
|
4583 | 4578 | * @return int |
4584 | 4579 | */ |
4585 | 4580 | function _existRem( &$array, $expkey, $expval=FALSE, $hitVal=null, $elseVal=null, $preSet=null ) { |
@@ -4689,7 +4684,7 @@ discard block |
||
4689 | 4684 | * |
4690 | 4685 | * @author Kjell-Inge Gustafsson <[email protected]> |
4691 | 4686 | * @since 2.4.8 - 2008-10-22 |
4692 | - * @param array $recurlabel |
|
4687 | + * @param string $recurlabel |
|
4693 | 4688 | * @param array $recurdata |
4694 | 4689 | * @return string |
4695 | 4690 | */ |
@@ -5229,6 +5224,10 @@ discard block |
||
5229 | 5224 | else |
5230 | 5225 | return FALSE; |
5231 | 5226 | } |
5227 | + |
|
5228 | + /** |
|
5229 | + * @param integer $wkst |
|
5230 | + */ |
|
5232 | 5231 | function _recurIntervalIx( $freq, $date, $wkst ) { |
5233 | 5232 | /* create interval index */ |
5234 | 5233 | switch( $freq ) { |
@@ -5537,7 +5536,6 @@ discard block |
||
5537 | 5536 | * |
5538 | 5537 | * @author Kjell-Inge Gustafsson <[email protected]> |
5539 | 5538 | * @since 2.4.16 - 2008-10-19 |
5540 | - * @param string $offset |
|
5541 | 5539 | * @return integer |
5542 | 5540 | */ |
5543 | 5541 | function _tz2offset( $tz ) { |
@@ -5999,8 +5997,8 @@ discard block |
||
5999 | 5997 | * @since 2.5.1 - 2008-11-02 |
6000 | 5998 | * @param string $propName, optional |
6001 | 5999 | * @param int @propix, optional, if specific property is wanted in case of multiply occurences |
6002 | - * @param bool $inclParam=FALSE |
|
6003 | - * @param bool $specform=FALSE |
|
6000 | + * @param bool $inclParam |
|
6001 | + * @param bool $specform |
|
6004 | 6002 | * @return mixed |
6005 | 6003 | */ |
6006 | 6004 | function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE, $specform=FALSE ) { |
@@ -6193,9 +6191,6 @@ discard block |
||
6193 | 6191 | * |
6194 | 6192 | * @author Kjell-Inge Gustafsson <[email protected]> |
6195 | 6193 | * @since 2.5.1 - 2008-11-05 |
6196 | - * @param mixed $args variable number of function arguments, |
|
6197 | - * first argument is ALWAYS component name, |
|
6198 | - * second ALWAYS component value! |
|
6199 | 6194 | * @return void |
6200 | 6195 | */ |
6201 | 6196 | function setProperty() { |
@@ -6309,7 +6304,7 @@ discard block |
||
6309 | 6304 | * @author Kjell-Inge Gustafsson <[email protected]> |
6310 | 6305 | * @since 2.5.2 - 2008-10-23 |
6311 | 6306 | * @param mixed $unparsedtext, optional, strict rfc2445 formatted, single property string or array of property strings |
6312 | - * @return bool FALSE if error occurs during parsing |
|
6307 | + * @return boolean|null FALSE if error occurs during parsing |
|
6313 | 6308 | * |
6314 | 6309 | */ |
6315 | 6310 | function parse( $unparsedtext=null ) { |
@@ -6611,7 +6606,7 @@ discard block |
||
6611 | 6606 | * @since 2.5.1 - 2008-10-15 |
6612 | 6607 | * @param mixed $arg1 ordno / component type / component uid |
6613 | 6608 | * @param mixed $arg2 optional, ordno if arg1 = component type |
6614 | - * @return void |
|
6609 | + * @return boolean |
|
6615 | 6610 | */ |
6616 | 6611 | function deleteComponent( $arg1, $arg2=FALSE ) { |
6617 | 6612 | if( !isset( $this->components )) return FALSE; |
@@ -6814,7 +6809,7 @@ discard block |
||
6814 | 6809 | * |
6815 | 6810 | * @author Kjell-Inge Gustafsson <[email protected]> |
6816 | 6811 | * @since 2.2.8 - 2006-09-03 |
6817 | - * @param string $value |
|
6812 | + * @param string $string |
|
6818 | 6813 | * @return string |
6819 | 6814 | */ |
6820 | 6815 | function _size75( $string ) { |
@@ -16,7 +16,6 @@ |
||
16 | 16 | * @author Patrick Cool |
17 | 17 | * @author René Haentjens, added CSV file import (October 2004) |
18 | 18 | * @package chamilo.link |
19 | - |
|
20 | 19 | */ |
21 | 20 | |
22 | 21 | // Including libraries |
@@ -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 | /** |
@@ -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 __construct() { |
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': |
@@ -1821,12 +1821,12 @@ discard block |
||
1821 | 1821 | $attendee11 = $this->intAttrDelimiter.'MEMBER='; |
1822 | 1822 | //no break |
1823 | 1823 | case 'DELEGATED-TO': |
1824 | - $attendee11 = ( !$attendee11 ) ? $this->intAttrDelimiter.'DELEGATED-TO=' : $attendee11; |
|
1824 | + $attendee11 = (!$attendee11) ? $this->intAttrDelimiter.'DELEGATED-TO=' : $attendee11; |
|
1825 | 1825 | //no break |
1826 | 1826 | case 'DELEGATED-FROM': |
1827 | - $attendee11 = ( !$attendee11 ) ? $this->intAttrDelimiter.'DELEGATED-FROM=' : $attendee11; |
|
1828 | - foreach( $optparamvalue as $cix => $calUserAddress ) { |
|
1829 | - $attendee12 .= ( $cix ) ? ',' : null; |
|
1827 | + $attendee11 = (!$attendee11) ? $this->intAttrDelimiter.'DELEGATED-FROM=' : $attendee11; |
|
1828 | + foreach ($optparamvalue as $cix => $calUserAddress) { |
|
1829 | + $attendee12 .= ($cix) ? ',' : null; |
|
1830 | 1830 | $attendee12 .= '"MAILTO:'.$calUserAddress.'"'; |
1831 | 1831 | } |
1832 | 1832 | $attendee1 .= $attendee11.$attendee12; |
@@ -1847,7 +1847,7 @@ discard block |
||
1847 | 1847 | } // end foreach 3 |
1848 | 1848 | } // end elseif |
1849 | 1849 | } // end foreach 2 |
1850 | - $output .= $this->_createElement( 'ATTENDEE', $attendee1.$attendeeLANG.$attendeeCN, $attendee2 ); |
|
1850 | + $output .= $this->_createElement('ATTENDEE', $attendee1.$attendeeLANG.$attendeeCN, $attendee2); |
|
1851 | 1851 | } // end foreach 1 |
1852 | 1852 | return $output; |
1853 | 1853 | } |
@@ -1861,63 +1861,63 @@ discard block |
||
1861 | 1861 | * @param integer $index, optional |
1862 | 1862 | * @return bool |
1863 | 1863 | */ |
1864 | - function setAttendee( $value, $params=FALSE, $index=FALSE ) { |
|
1865 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1866 | - $value = str_replace ( 'MAILTO:', '', $value ); |
|
1867 | - $value = str_replace ( 'mailto:', '', $value ); |
|
1864 | + function setAttendee($value, $params = FALSE, $index = FALSE) { |
|
1865 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
1866 | + $value = str_replace('MAILTO:', '', $value); |
|
1867 | + $value = str_replace('mailto:', '', $value); |
|
1868 | 1868 | $params2 = array(); |
1869 | - if( is_array($params )) { |
|
1869 | + if (is_array($params)) { |
|
1870 | 1870 | $optarrays = array(); |
1871 | - foreach( $params as $optparamlabel => $optparamvalue ) { |
|
1872 | - $optparamlabel = strtoupper( $optparamlabel ); |
|
1873 | - switch( $optparamlabel ) { |
|
1871 | + foreach ($params as $optparamlabel => $optparamvalue) { |
|
1872 | + $optparamlabel = strtoupper($optparamlabel); |
|
1873 | + switch ($optparamlabel) { |
|
1874 | 1874 | case 'MEMBER': |
1875 | 1875 | case 'DELEGATED-TO': |
1876 | 1876 | case 'DELEGATED-FROM': |
1877 | - if( is_array( $optparamvalue )) { |
|
1878 | - foreach( $optparamvalue as $part ) { |
|
1879 | - $part = str_replace( 'MAILTO:', '', $part ); |
|
1880 | - $part = str_replace( 'mailto:', '', $part ); |
|
1881 | - if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) |
|
1882 | - $part = substr( $part, 1, ( strlen($part)-2 )); |
|
1877 | + if (is_array($optparamvalue)) { |
|
1878 | + foreach ($optparamvalue as $part) { |
|
1879 | + $part = str_replace('MAILTO:', '', $part); |
|
1880 | + $part = str_replace('mailto:', '', $part); |
|
1881 | + if (('"' == $part{0} ) && ('"' == $part{strlen($part) - 1} )) |
|
1882 | + $part = substr($part, 1, (strlen($part) - 2)); |
|
1883 | 1883 | $optarrays[$optparamlabel][] = $part; |
1884 | 1884 | } |
1885 | 1885 | } |
1886 | 1886 | else { |
1887 | - $part = str_replace( 'MAILTO:', '', $optparamvalue ); |
|
1888 | - $part = str_replace( 'mailto:', '', $part ); |
|
1889 | - if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) |
|
1890 | - $part = substr( $part, 1, ( strlen($part)-2 )); |
|
1887 | + $part = str_replace('MAILTO:', '', $optparamvalue); |
|
1888 | + $part = str_replace('mailto:', '', $part); |
|
1889 | + if (('"' == $part{0} ) && ('"' == $part{strlen($part) - 1} )) |
|
1890 | + $part = substr($part, 1, (strlen($part) - 2)); |
|
1891 | 1891 | $optarrays[$optparamlabel][] = $part; |
1892 | 1892 | } |
1893 | 1893 | break; |
1894 | 1894 | default: |
1895 | - if( 'SENT-BY' == $optparamlabel ) { |
|
1896 | - $optparamvalue = str_replace( 'MAILTO:', '', $optparamvalue ); |
|
1897 | - $optparamvalue = str_replace( 'mailto:', '', $optparamvalue ); |
|
1895 | + if ('SENT-BY' == $optparamlabel) { |
|
1896 | + $optparamvalue = str_replace('MAILTO:', '', $optparamvalue); |
|
1897 | + $optparamvalue = str_replace('mailto:', '', $optparamvalue); |
|
1898 | 1898 | } |
1899 | - if(( '"' == substr( $optparamvalue, 0, 1 )) && |
|
1900 | - ( '"' == substr( $optparamvalue, -1 ))) |
|
1901 | - $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 )); |
|
1899 | + if (('"' == substr($optparamvalue, 0, 1)) && |
|
1900 | + ('"' == substr($optparamvalue, -1))) |
|
1901 | + $optparamvalue = substr($optparamvalue, 1, (strlen($optparamvalue) - 2)); |
|
1902 | 1902 | $params2[$optparamlabel] = $optparamvalue; |
1903 | 1903 | break; |
1904 | 1904 | } // end switch( $optparamlabel.. . |
1905 | 1905 | } // end foreach( $optparam.. . |
1906 | - foreach( $optarrays as $optparamlabel => $optparams ) |
|
1906 | + foreach ($optarrays as $optparamlabel => $optparams) |
|
1907 | 1907 | $params2[$optparamlabel] = $optparams; |
1908 | 1908 | } |
1909 | 1909 | // remove defaults |
1910 | - $this->_existRem( $params2, 'CUTYPE', 'INDIVIDUAL' ); |
|
1911 | - $this->_existRem( $params2, 'PARTSTAT', 'NEEDS-ACTION' ); |
|
1912 | - $this->_existRem( $params2, 'ROLE', 'REQ-PARTICIPANT' ); |
|
1913 | - $this->_existRem( $params2, 'RSVP', 'FALSE' ); |
|
1910 | + $this->_existRem($params2, 'CUTYPE', 'INDIVIDUAL'); |
|
1911 | + $this->_existRem($params2, 'PARTSTAT', 'NEEDS-ACTION'); |
|
1912 | + $this->_existRem($params2, 'ROLE', 'REQ-PARTICIPANT'); |
|
1913 | + $this->_existRem($params2, 'RSVP', 'FALSE'); |
|
1914 | 1914 | // check language setting |
1915 | - if( isset( $params2['CN' ] )) { |
|
1916 | - $lang = $this->getConfig( 'language' ); |
|
1917 | - if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang )) |
|
1918 | - $params2['LANGUAGE' ] = $lang; |
|
1915 | + if (isset($params2['CN'])) { |
|
1916 | + $lang = $this->getConfig('language'); |
|
1917 | + if (!isset($params2['LANGUAGE']) && !empty($lang)) |
|
1918 | + $params2['LANGUAGE'] = $lang; |
|
1919 | 1919 | } |
1920 | - $this->_setMval( $this->attendee, $value, $params2, FALSE, $index ); |
|
1920 | + $this->_setMval($this->attendee, $value, $params2, FALSE, $index); |
|
1921 | 1921 | return TRUE; |
1922 | 1922 | } |
1923 | 1923 | /*********************************************************************************/ |
@@ -1932,23 +1932,23 @@ discard block |
||
1932 | 1932 | * @return string |
1933 | 1933 | */ |
1934 | 1934 | function createCategories() { |
1935 | - if( empty( $this->categories )) return FALSE; |
|
1935 | + if (empty($this->categories)) return FALSE; |
|
1936 | 1936 | $output = null; |
1937 | - foreach( $this->categories as $category ) { |
|
1938 | - if( empty( $category['value'] )) { |
|
1939 | - if ( $this->getConfig( 'allowEmpty' )) |
|
1940 | - $output .= $this->_createElement( 'CATEGORIES' ); |
|
1937 | + foreach ($this->categories as $category) { |
|
1938 | + if (empty($category['value'])) { |
|
1939 | + if ($this->getConfig('allowEmpty')) |
|
1940 | + $output .= $this->_createElement('CATEGORIES'); |
|
1941 | 1941 | continue; |
1942 | 1942 | } |
1943 | - $attributes = $this->_createParams( $category['params'], array( 'LANGUAGE' )); |
|
1944 | - if( is_array( $category['value'] )) { |
|
1945 | - foreach( $category['value'] as $cix => $categoryPart ) |
|
1946 | - $category['value'][$cix] = $this->_strrep( $categoryPart ); |
|
1947 | - $content = implode( ',', $category['value'] ); |
|
1943 | + $attributes = $this->_createParams($category['params'], array('LANGUAGE')); |
|
1944 | + if (is_array($category['value'])) { |
|
1945 | + foreach ($category['value'] as $cix => $categoryPart) |
|
1946 | + $category['value'][$cix] = $this->_strrep($categoryPart); |
|
1947 | + $content = implode(',', $category['value']); |
|
1948 | 1948 | } |
1949 | 1949 | else |
1950 | - $content = $this->_strrep( $category['value'] ); |
|
1951 | - $output .= $this->_createElement( 'CATEGORIES', $attributes, $content ); |
|
1950 | + $content = $this->_strrep($category['value']); |
|
1951 | + $output .= $this->_createElement('CATEGORIES', $attributes, $content); |
|
1952 | 1952 | } |
1953 | 1953 | return $output; |
1954 | 1954 | } |
@@ -1962,9 +1962,9 @@ discard block |
||
1962 | 1962 | * @param integer $index, optional |
1963 | 1963 | * @return bool |
1964 | 1964 | */ |
1965 | - function setCategories( $value, $params=FALSE, $index=FALSE ) { |
|
1966 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1967 | - $this->_setMval( $this->categories, $value, $params, FALSE, $index ); |
|
1965 | + function setCategories($value, $params = FALSE, $index = FALSE) { |
|
1966 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
1967 | + $this->_setMval($this->categories, $value, $params, FALSE, $index); |
|
1968 | 1968 | return TRUE; |
1969 | 1969 | } |
1970 | 1970 | /*********************************************************************************/ |
@@ -1979,11 +1979,11 @@ discard block |
||
1979 | 1979 | * @return string |
1980 | 1980 | */ |
1981 | 1981 | function createClass() { |
1982 | - if( empty( $this->class )) return FALSE; |
|
1983 | - if( empty( $this->class['value'] )) |
|
1984 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE; |
|
1985 | - $attributes = $this->_createParams( $this->class['params'] ); |
|
1986 | - return $this->_createElement( 'CLASS', $attributes, $this->class['value'] ); |
|
1982 | + if (empty($this->class)) return FALSE; |
|
1983 | + if (empty($this->class['value'])) |
|
1984 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('CLASS') : FALSE; |
|
1985 | + $attributes = $this->_createParams($this->class['params']); |
|
1986 | + return $this->_createElement('CLASS', $attributes, $this->class['value']); |
|
1987 | 1987 | } |
1988 | 1988 | /** |
1989 | 1989 | * set calendar component property class |
@@ -1994,9 +1994,9 @@ discard block |
||
1994 | 1994 | * @param array $params optional |
1995 | 1995 | * @return bool |
1996 | 1996 | */ |
1997 | - function setClass( $value, $params=FALSE ) { |
|
1998 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1999 | - $this->class = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
1997 | + function setClass($value, $params = FALSE) { |
|
1998 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
1999 | + $this->class = array('value' => $value, 'params' => $this->_setParams($params)); |
|
2000 | 2000 | return TRUE; |
2001 | 2001 | } |
2002 | 2002 | /*********************************************************************************/ |
@@ -2011,16 +2011,16 @@ discard block |
||
2011 | 2011 | * @return string |
2012 | 2012 | */ |
2013 | 2013 | function createComment() { |
2014 | - if( empty( $this->comment )) return FALSE; |
|
2014 | + if (empty($this->comment)) return FALSE; |
|
2015 | 2015 | $output = null; |
2016 | - foreach( $this->comment as $commentPart ) { |
|
2017 | - if( empty( $commentPart['value'] )) { |
|
2018 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'COMMENT' ); |
|
2016 | + foreach ($this->comment as $commentPart) { |
|
2017 | + if (empty($commentPart['value'])) { |
|
2018 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('COMMENT'); |
|
2019 | 2019 | continue; |
2020 | 2020 | } |
2021 | - $attributes = $this->_createParams( $commentPart['params'], array( 'ALTREP', 'LANGUAGE' )); |
|
2022 | - $content = $this->_strrep( $commentPart['value'] ); |
|
2023 | - $output .= $this->_createElement( 'COMMENT', $attributes, $content ); |
|
2021 | + $attributes = $this->_createParams($commentPart['params'], array('ALTREP', 'LANGUAGE')); |
|
2022 | + $content = $this->_strrep($commentPart['value']); |
|
2023 | + $output .= $this->_createElement('COMMENT', $attributes, $content); |
|
2024 | 2024 | } |
2025 | 2025 | return $output; |
2026 | 2026 | } |
@@ -2034,9 +2034,9 @@ discard block |
||
2034 | 2034 | * @param integer $index, optional |
2035 | 2035 | * @return bool |
2036 | 2036 | */ |
2037 | - function setComment( $value, $params=FALSE, $index=FALSE ) { |
|
2038 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2039 | - $this->_setMval( $this->comment, $value, $params, FALSE, $index ); |
|
2037 | + function setComment($value, $params = FALSE, $index = FALSE) { |
|
2038 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
2039 | + $this->_setMval($this->comment, $value, $params, FALSE, $index); |
|
2040 | 2040 | return TRUE; |
2041 | 2041 | } |
2042 | 2042 | /*********************************************************************************/ |
@@ -2051,19 +2051,19 @@ discard block |
||
2051 | 2051 | * @return string |
2052 | 2052 | */ |
2053 | 2053 | function createCompleted( ) { |
2054 | - if( empty( $this->completed )) return FALSE; |
|
2055 | - if( !isset( $this->completed['value']['year'] ) && |
|
2056 | - !isset( $this->completed['value']['month'] ) && |
|
2057 | - !isset( $this->completed['value']['day'] ) && |
|
2058 | - !isset( $this->completed['value']['hour'] ) && |
|
2059 | - !isset( $this->completed['value']['min'] ) && |
|
2060 | - !isset( $this->completed['value']['sec'] )) |
|
2061 | - if( $this->getConfig( 'allowEmpty' )) |
|
2062 | - return $this->_createElement( 'COMPLETED' ); |
|
2054 | + if (empty($this->completed)) return FALSE; |
|
2055 | + if (!isset($this->completed['value']['year']) && |
|
2056 | + !isset($this->completed['value']['month']) && |
|
2057 | + !isset($this->completed['value']['day']) && |
|
2058 | + !isset($this->completed['value']['hour']) && |
|
2059 | + !isset($this->completed['value']['min']) && |
|
2060 | + !isset($this->completed['value']['sec'])) |
|
2061 | + if ($this->getConfig('allowEmpty')) |
|
2062 | + return $this->_createElement('COMPLETED'); |
|
2063 | 2063 | else return FALSE; |
2064 | - $formatted = $this->_format_date_time( $this->completed['value'], 7 ); |
|
2065 | - $attributes = $this->_createParams( $this->completed['params'] ); |
|
2066 | - return $this->_createElement( 'COMPLETED', $attributes, $formatted ); |
|
2064 | + $formatted = $this->_format_date_time($this->completed['value'], 7); |
|
2065 | + $attributes = $this->_createParams($this->completed['params']); |
|
2066 | + return $this->_createElement('COMPLETED', $attributes, $formatted); |
|
2067 | 2067 | } |
2068 | 2068 | /** |
2069 | 2069 | * set calendar component property completed |
@@ -2079,16 +2079,16 @@ discard block |
||
2079 | 2079 | * @param array $params optional |
2080 | 2080 | * @return bool |
2081 | 2081 | */ |
2082 | - function setCompleted( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
|
2083 | - if( empty( $year )) { |
|
2084 | - if( $this->getConfig( 'allowEmpty' )) { |
|
2085 | - $this->completed = array( 'value' => null, 'params' => $this->_setParams( $params )); |
|
2082 | + function setCompleted($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) { |
|
2083 | + if (empty($year)) { |
|
2084 | + if ($this->getConfig('allowEmpty')) { |
|
2085 | + $this->completed = array('value' => null, 'params' => $this->_setParams($params)); |
|
2086 | 2086 | return TRUE; |
2087 | 2087 | } |
2088 | 2088 | else |
2089 | 2089 | return FALSE; |
2090 | 2090 | } |
2091 | - $this->completed = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
|
2091 | + $this->completed = $this->_setDate2($year, $month, $day, $hour, $min, $sec, $params); |
|
2092 | 2092 | return TRUE; |
2093 | 2093 | } |
2094 | 2094 | /*********************************************************************************/ |
@@ -2103,15 +2103,15 @@ discard block |
||
2103 | 2103 | * @return string |
2104 | 2104 | */ |
2105 | 2105 | function createContact() { |
2106 | - if( empty( $this->contact )) return FALSE; |
|
2106 | + if (empty($this->contact)) return FALSE; |
|
2107 | 2107 | $output = null; |
2108 | - foreach( $this->contact as $contact ) { |
|
2109 | - if( !empty( $contact['value'] )) { |
|
2110 | - $attributes = $this->_createParams( $contact['params'], array( 'ALTREP', 'LANGUAGE' )); |
|
2111 | - $content = $this->_strrep( $contact['value'] ); |
|
2112 | - $output .= $this->_createElement( 'CONTACT', $attributes, $content ); |
|
2108 | + foreach ($this->contact as $contact) { |
|
2109 | + if (!empty($contact['value'])) { |
|
2110 | + $attributes = $this->_createParams($contact['params'], array('ALTREP', 'LANGUAGE')); |
|
2111 | + $content = $this->_strrep($contact['value']); |
|
2112 | + $output .= $this->_createElement('CONTACT', $attributes, $content); |
|
2113 | 2113 | } |
2114 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'CONTACT' ); |
|
2114 | + elseif ($this->getConfig('allowEmpty')) $output .= $this->_createElement('CONTACT'); |
|
2115 | 2115 | } |
2116 | 2116 | return $output; |
2117 | 2117 | } |
@@ -2125,9 +2125,9 @@ discard block |
||
2125 | 2125 | * @param integer $index, optional |
2126 | 2126 | * @return bool |
2127 | 2127 | */ |
2128 | - function setContact( $value, $params=FALSE, $index=FALSE ) { |
|
2129 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2130 | - $this->_setMval( $this->contact, $value, $params, FALSE, $index ); |
|
2128 | + function setContact($value, $params = FALSE, $index = FALSE) { |
|
2129 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
2130 | + $this->_setMval($this->contact, $value, $params, FALSE, $index); |
|
2131 | 2131 | return TRUE; |
2132 | 2132 | } |
2133 | 2133 | /*********************************************************************************/ |
@@ -2142,10 +2142,10 @@ discard block |
||
2142 | 2142 | * @return string |
2143 | 2143 | */ |
2144 | 2144 | function createCreated() { |
2145 | - if( empty( $this->created )) return FALSE; |
|
2146 | - $formatted = $this->_format_date_time( $this->created['value'], 7 ); |
|
2147 | - $attributes = $this->_createParams( $this->created['params'] ); |
|
2148 | - return $this->_createElement( 'CREATED', $attributes, $formatted ); |
|
2145 | + if (empty($this->created)) return FALSE; |
|
2146 | + $formatted = $this->_format_date_time($this->created['value'], 7); |
|
2147 | + $attributes = $this->_createParams($this->created['params']); |
|
2148 | + return $this->_createElement('CREATED', $attributes, $formatted); |
|
2149 | 2149 | } |
2150 | 2150 | /** |
2151 | 2151 | * set calendar component property created |
@@ -2161,11 +2161,11 @@ discard block |
||
2161 | 2161 | * @param mixed $params optional |
2162 | 2162 | * @return bool |
2163 | 2163 | */ |
2164 | - function setCreated( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
|
2165 | - if( !isset( $year )) { |
|
2166 | - $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' ))); |
|
2164 | + function setCreated($year = FALSE, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) { |
|
2165 | + if (!isset($year)) { |
|
2166 | + $year = date('Ymd\THis', mktime(date('H'), date('i'), date('s') - date('Z'), date('m'), date('d'), date('Y'))); |
|
2167 | 2167 | } |
2168 | - $this->created = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
|
2168 | + $this->created = $this->_setDate2($year, $month, $day, $hour, $min, $sec, $params); |
|
2169 | 2169 | return TRUE; |
2170 | 2170 | } |
2171 | 2171 | /*********************************************************************************/ |
@@ -2180,15 +2180,15 @@ discard block |
||
2180 | 2180 | * @return string |
2181 | 2181 | */ |
2182 | 2182 | function createDescription() { |
2183 | - if( empty( $this->description )) return FALSE; |
|
2184 | - $output = null; |
|
2185 | - foreach( $this->description as $description ) { |
|
2186 | - if( !empty( $description['value'] )) { |
|
2187 | - $attributes = $this->_createParams( $description['params'], array( 'ALTREP', 'LANGUAGE' )); |
|
2188 | - $content = $this->_strrep( $description['value'] ); |
|
2189 | - $output .= $this->_createElement( 'DESCRIPTION', $attributes, $content ); |
|
2183 | + if (empty($this->description)) return FALSE; |
|
2184 | + $output = null; |
|
2185 | + foreach ($this->description as $description) { |
|
2186 | + if (!empty($description['value'])) { |
|
2187 | + $attributes = $this->_createParams($description['params'], array('ALTREP', 'LANGUAGE')); |
|
2188 | + $content = $this->_strrep($description['value']); |
|
2189 | + $output .= $this->_createElement('DESCRIPTION', $attributes, $content); |
|
2190 | 2190 | } |
2191 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'DESCRIPTION' ); |
|
2191 | + elseif ($this->getConfig('allowEmpty')) $output .= $this->_createElement('DESCRIPTION'); |
|
2192 | 2192 | } |
2193 | 2193 | return $output; |
2194 | 2194 | } |
@@ -2202,9 +2202,9 @@ discard block |
||
2202 | 2202 | * @param integer $index, optional |
2203 | 2203 | * @return bool |
2204 | 2204 | */ |
2205 | - function setDescription( $value, $params=FALSE, $index=FALSE ) { |
|
2206 | - if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; } |
|
2207 | - $this->_setMval( $this->description, $value, $params, FALSE, $index ); |
|
2205 | + function setDescription($value, $params = FALSE, $index = FALSE) { |
|
2206 | + if (empty($value)) { if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; } |
|
2207 | + $this->_setMval($this->description, $value, $params, FALSE, $index); |
|
2208 | 2208 | return TRUE; |
2209 | 2209 | } |
2210 | 2210 | /*********************************************************************************/ |
@@ -2219,19 +2219,19 @@ discard block |
||
2219 | 2219 | * @return string |
2220 | 2220 | */ |
2221 | 2221 | function createDtend() { |
2222 | - if( empty( $this->dtend )) return FALSE; |
|
2223 | - if( !isset( $this->dtend['value']['year'] ) && |
|
2224 | - !isset( $this->dtend['value']['month'] ) && |
|
2225 | - !isset( $this->dtend['value']['day'] ) && |
|
2226 | - !isset( $this->dtend['value']['hour'] ) && |
|
2227 | - !isset( $this->dtend['value']['min'] ) && |
|
2228 | - !isset( $this->dtend['value']['sec'] )) |
|
2229 | - if( $this->getConfig( 'allowEmpty' )) |
|
2230 | - return $this->_createElement( 'DTEND' ); |
|
2222 | + if (empty($this->dtend)) return FALSE; |
|
2223 | + if (!isset($this->dtend['value']['year']) && |
|
2224 | + !isset($this->dtend['value']['month']) && |
|
2225 | + !isset($this->dtend['value']['day']) && |
|
2226 | + !isset($this->dtend['value']['hour']) && |
|
2227 | + !isset($this->dtend['value']['min']) && |
|
2228 | + !isset($this->dtend['value']['sec'])) |
|
2229 | + if ($this->getConfig('allowEmpty')) |
|
2230 | + return $this->_createElement('DTEND'); |
|
2231 | 2231 | else return FALSE; |
2232 | - $formatted = $this->_format_date_time( $this->dtend['value'] ); |
|
2233 | - $attributes = $this->_createParams( $this->dtend['params'] ); |
|
2234 | - return $this->_createElement( 'DTEND', $attributes, $formatted ); |
|
2232 | + $formatted = $this->_format_date_time($this->dtend['value']); |
|
2233 | + $attributes = $this->_createParams($this->dtend['params']); |
|
2234 | + return $this->_createElement('DTEND', $attributes, $formatted); |
|
2235 | 2235 | } |
2236 | 2236 | /** |
2237 | 2237 | * set calendar component property dtend |
@@ -2248,16 +2248,16 @@ discard block |
||
2248 | 2248 | * @param array params optional |
2249 | 2249 | * @return bool |
2250 | 2250 | */ |
2251 | - function setDtend( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) { |
|
2252 | - if( empty( $year )) { |
|
2253 | - if( $this->getConfig( 'allowEmpty' )) { |
|
2254 | - $this->dtend = array( 'value' => null, 'params' => $this->_setParams( $params )); |
|
2251 | + function setDtend($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE) { |
|
2252 | + if (empty($year)) { |
|
2253 | + if ($this->getConfig('allowEmpty')) { |
|
2254 | + $this->dtend = array('value' => null, 'params' => $this->_setParams($params)); |
|
2255 | 2255 | return TRUE; |
2256 | 2256 | } |
2257 | 2257 | else |
2258 | 2258 | return FALSE; |
2259 | 2259 | } |
2260 | - $this->dtend = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
|
2260 | + $this->dtend = $this->_setDate($year, $month, $day, $hour, $min, $sec, $tz, $params); |
|
2261 | 2261 | return TRUE; |
2262 | 2262 | } |
2263 | 2263 | /*********************************************************************************/ |
@@ -2272,16 +2272,16 @@ discard block |
||
2272 | 2272 | * @return string |
2273 | 2273 | */ |
2274 | 2274 | function createDtstamp() { |
2275 | - if( !isset( $this->dtstamp['value']['year'] ) && |
|
2276 | - !isset( $this->dtstamp['value']['month'] ) && |
|
2277 | - !isset( $this->dtstamp['value']['day'] ) && |
|
2278 | - !isset( $this->dtstamp['value']['hour'] ) && |
|
2279 | - !isset( $this->dtstamp['value']['min'] ) && |
|
2280 | - !isset( $this->dtstamp['value']['sec'] )) |
|
2275 | + if (!isset($this->dtstamp['value']['year']) && |
|
2276 | + !isset($this->dtstamp['value']['month']) && |
|
2277 | + !isset($this->dtstamp['value']['day']) && |
|
2278 | + !isset($this->dtstamp['value']['hour']) && |
|
2279 | + !isset($this->dtstamp['value']['min']) && |
|
2280 | + !isset($this->dtstamp['value']['sec'])) |
|
2281 | 2281 | $this->_makeDtstamp(); |
2282 | - $formatted = $this->_format_date_time( $this->dtstamp['value'], 7 ); |
|
2283 | - $attributes = $this->_createParams( $this->dtstamp['params'] ); |
|
2284 | - return $this->_createElement( 'DTSTAMP', $attributes, $formatted ); |
|
2282 | + $formatted = $this->_format_date_time($this->dtstamp['value'], 7); |
|
2283 | + $attributes = $this->_createParams($this->dtstamp['params']); |
|
2284 | + return $this->_createElement('DTSTAMP', $attributes, $formatted); |
|
2285 | 2285 | } |
2286 | 2286 | /** |
2287 | 2287 | * computes datestamp for calendar component object instance dtstamp |
@@ -2291,12 +2291,12 @@ discard block |
||
2291 | 2291 | * @return void |
2292 | 2292 | */ |
2293 | 2293 | function _makeDtstamp() { |
2294 | - $this->dtstamp['value'] = array( 'year' => date( 'Y' ) |
|
2295 | - , 'month' => date( 'm' ) |
|
2296 | - , 'day' => date( 'd' ) |
|
2297 | - , 'hour' => date( 'H' ) |
|
2298 | - , 'min' => date( 'i' ) |
|
2299 | - , 'sec' => date( 's' ) - date( 'Z' )); |
|
2294 | + $this->dtstamp['value'] = array('year' => date('Y') |
|
2295 | + , 'month' => date('m') |
|
2296 | + , 'day' => date('d') |
|
2297 | + , 'hour' => date('H') |
|
2298 | + , 'min' => date('i') |
|
2299 | + , 'sec' => date('s') - date('Z')); |
|
2300 | 2300 | $this->dtstamp['params'] = null; |
2301 | 2301 | } |
2302 | 2302 | /** |
@@ -2313,11 +2313,11 @@ discard block |
||
2313 | 2313 | * @param array $params optional |
2314 | 2314 | * @return TRUE |
2315 | 2315 | */ |
2316 | - function setDtstamp( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
|
2317 | - if( empty( $year )) |
|
2316 | + function setDtstamp($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) { |
|
2317 | + if (empty($year)) |
|
2318 | 2318 | $this->_makeDtstamp(); |
2319 | 2319 | else |
2320 | - $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
|
2320 | + $this->dtstamp = $this->_setDate2($year, $month, $day, $hour, $min, $sec, $params); |
|
2321 | 2321 | return TRUE; |
2322 | 2322 | } |
2323 | 2323 | /*********************************************************************************/ |
@@ -2332,21 +2332,21 @@ discard block |
||
2332 | 2332 | * @return string |
2333 | 2333 | */ |
2334 | 2334 | function createDtstart() { |
2335 | - if( empty( $this->dtstart )) return FALSE; |
|
2336 | - if( !isset( $this->dtstart['value']['year'] ) && |
|
2337 | - !isset( $this->dtstart['value']['month'] ) && |
|
2338 | - !isset( $this->dtstart['value']['day'] ) && |
|
2339 | - !isset( $this->dtstart['value']['hour'] ) && |
|
2340 | - !isset( $this->dtstart['value']['min'] ) && |
|
2341 | - !isset( $this->dtstart['value']['sec'] )) |
|
2342 | - if( $this->getConfig( 'allowEmpty' )) |
|
2343 | - return $this->_createElement( 'DTSTART' ); |
|
2335 | + if (empty($this->dtstart)) return FALSE; |
|
2336 | + if (!isset($this->dtstart['value']['year']) && |
|
2337 | + !isset($this->dtstart['value']['month']) && |
|
2338 | + !isset($this->dtstart['value']['day']) && |
|
2339 | + !isset($this->dtstart['value']['hour']) && |
|
2340 | + !isset($this->dtstart['value']['min']) && |
|
2341 | + !isset($this->dtstart['value']['sec'])) |
|
2342 | + if ($this->getConfig('allowEmpty')) |
|
2343 | + return $this->_createElement('DTSTART'); |
|
2344 | 2344 | else return FALSE; |
2345 | - if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) |
|
2346 | - unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] ); |
|
2347 | - $formatted = $this->_format_date_time( $this->dtstart['value'] ); |
|
2348 | - $attributes = $this->_createParams( $this->dtstart['params'] ); |
|
2349 | - return $this->_createElement( 'DTSTART', $attributes, $formatted ); |
|
2345 | + if (in_array($this->objName, array('vtimezone', 'standard', 'daylight'))) |
|
2346 | + unset($this->dtstart['value']['tz'], $this->dtstart['params']['TZID']); |
|
2347 | + $formatted = $this->_format_date_time($this->dtstart['value']); |
|
2348 | + $attributes = $this->_createParams($this->dtstart['params']); |
|
2349 | + return $this->_createElement('DTSTART', $attributes, $formatted); |
|
2350 | 2350 | } |
2351 | 2351 | /** |
2352 | 2352 | * set calendar component property dtstart |
@@ -2363,16 +2363,16 @@ discard block |
||
2363 | 2363 | * @param array $params optional |
2364 | 2364 | * @return bool |
2365 | 2365 | */ |
2366 | - function setDtstart( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) { |
|
2367 | - if( empty( $year )) { |
|
2368 | - if( $this->getConfig( 'allowEmpty' )) { |
|
2369 | - $this->dtstart = array( 'value' => null, 'params' => $this->_setParams( $params )); |
|
2366 | + function setDtstart($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE) { |
|
2367 | + if (empty($year)) { |
|
2368 | + if ($this->getConfig('allowEmpty')) { |
|
2369 | + $this->dtstart = array('value' => null, 'params' => $this->_setParams($params)); |
|
2370 | 2370 | return TRUE; |
2371 | 2371 | } |
2372 | 2372 | else |
2373 | 2373 | return FALSE; |
2374 | 2374 | } |
2375 | - $this->dtstart = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params, 'dtstart' ); |
|
2375 | + $this->dtstart = $this->_setDate($year, $month, $day, $hour, $min, $sec, $tz, $params, 'dtstart'); |
|
2376 | 2376 | return TRUE; |
2377 | 2377 | } |
2378 | 2378 | /*********************************************************************************/ |
@@ -2387,19 +2387,19 @@ discard block |
||
2387 | 2387 | * @return string |
2388 | 2388 | */ |
2389 | 2389 | function createDue() { |
2390 | - if( empty( $this->due )) return FALSE; |
|
2391 | - if( !isset( $this->due['value']['year'] ) && |
|
2392 | - !isset( $this->due['value']['month'] ) && |
|
2393 | - !isset( $this->due['value']['day'] ) && |
|
2394 | - !isset( $this->due['value']['hour'] ) && |
|
2395 | - !isset( $this->due['value']['min'] ) && |
|
2396 | - !isset( $this->due['value']['sec'] )) |
|
2397 | - if( $this->getConfig( 'allowEmpty' )) |
|
2398 | - return $this->_createElement( 'DUE' ); |
|
2390 | + if (empty($this->due)) return FALSE; |
|
2391 | + if (!isset($this->due['value']['year']) && |
|
2392 | + !isset($this->due['value']['month']) && |
|
2393 | + !isset($this->due['value']['day']) && |
|
2394 | + !isset($this->due['value']['hour']) && |
|
2395 | + !isset($this->due['value']['min']) && |
|
2396 | + !isset($this->due['value']['sec'])) |
|
2397 | + if ($this->getConfig('allowEmpty')) |
|
2398 | + return $this->_createElement('DUE'); |
|
2399 | 2399 | else return FALSE; |
2400 | - $formatted = $this->_format_date_time( $this->due['value'] ); |
|
2401 | - $attributes = $this->_createParams( $this->due['params'] ); |
|
2402 | - return $this->_createElement( 'DUE', $attributes, $formatted ); |
|
2400 | + $formatted = $this->_format_date_time($this->due['value']); |
|
2401 | + $attributes = $this->_createParams($this->due['params']); |
|
2402 | + return $this->_createElement('DUE', $attributes, $formatted); |
|
2403 | 2403 | } |
2404 | 2404 | /** |
2405 | 2405 | * set calendar component property due |
@@ -2415,16 +2415,16 @@ discard block |
||
2415 | 2415 | * @param array $params optional |
2416 | 2416 | * @return bool |
2417 | 2417 | */ |
2418 | - function setDue( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) { |
|
2419 | - if( empty( $year )) { |
|
2420 | - if( $this->getConfig( 'allowEmpty' )) { |
|
2421 | - $this->due = array( 'value' => null, 'params' => $this->_setParams( $params )); |
|
2418 | + function setDue($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE) { |
|
2419 | + if (empty($year)) { |
|
2420 | + if ($this->getConfig('allowEmpty')) { |
|
2421 | + $this->due = array('value' => null, 'params' => $this->_setParams($params)); |
|
2422 | 2422 | return TRUE; |
2423 | 2423 | } |
2424 | 2424 | else |
2425 | 2425 | return FALSE; |
2426 | 2426 | } |
2427 | - $this->due = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
|
2427 | + $this->due = $this->_setDate($year, $month, $day, $hour, $min, $sec, $tz, $params); |
|
2428 | 2428 | return TRUE; |
2429 | 2429 | } |
2430 | 2430 | /*********************************************************************************/ |
@@ -2439,17 +2439,17 @@ discard block |
||
2439 | 2439 | * @return string |
2440 | 2440 | */ |
2441 | 2441 | function createDuration() { |
2442 | - if( empty( $this->duration )) return FALSE; |
|
2443 | - if( !isset( $this->duration['value']['week'] ) && |
|
2444 | - !isset( $this->duration['value']['day'] ) && |
|
2445 | - !isset( $this->duration['value']['hour'] ) && |
|
2446 | - !isset( $this->duration['value']['min'] ) && |
|
2447 | - !isset( $this->duration['value']['sec'] )) |
|
2448 | - if( $this->getConfig( 'allowEmpty' )) |
|
2449 | - return $this->_createElement( 'DURATION', array(), null ); |
|
2442 | + if (empty($this->duration)) return FALSE; |
|
2443 | + if (!isset($this->duration['value']['week']) && |
|
2444 | + !isset($this->duration['value']['day']) && |
|
2445 | + !isset($this->duration['value']['hour']) && |
|
2446 | + !isset($this->duration['value']['min']) && |
|
2447 | + !isset($this->duration['value']['sec'])) |
|
2448 | + if ($this->getConfig('allowEmpty')) |
|
2449 | + return $this->_createElement('DURATION', array(), null); |
|
2450 | 2450 | else return FALSE; |
2451 | - $attributes = $this->_createParams( $this->duration['params'] ); |
|
2452 | - return $this->_createElement( 'DURATION', $attributes, $this->_format_duration( $this->duration['value'] )); |
|
2451 | + $attributes = $this->_createParams($this->duration['params']); |
|
2452 | + return $this->_createElement('DURATION', $attributes, $this->_format_duration($this->duration['value'])); |
|
2453 | 2453 | } |
2454 | 2454 | /** |
2455 | 2455 | * set calendar component property duration |
@@ -2464,20 +2464,20 @@ discard block |
||
2464 | 2464 | * @param array $params optional |
2465 | 2465 | * @return bool |
2466 | 2466 | */ |
2467 | - function setDuration( $week, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
|
2468 | - if( empty( $week )) if( $this->getConfig( 'allowEmpty' )) $week = null; else return FALSE; |
|
2469 | - if( is_array( $week ) && ( 1 <= count( $week ))) |
|
2470 | - $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day )); |
|
2471 | - elseif( is_string( $week ) && ( 3 <= strlen( trim( $week )))) { |
|
2472 | - $week = trim( $week ); |
|
2473 | - if( in_array( substr( $week, 0, 1 ), array( '+', '-' ))) |
|
2474 | - $week = substr( $week, 1 ); |
|
2475 | - $this->duration = array( 'value' => $this->_duration_string( $week ), 'params' => $this->_setParams( $day )); |
|
2476 | - } |
|
2477 | - elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec )) |
|
2467 | + function setDuration($week, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) { |
|
2468 | + if (empty($week)) if ($this->getConfig('allowEmpty')) $week = null; else return FALSE; |
|
2469 | + if (is_array($week) && (1 <= count($week))) |
|
2470 | + $this->duration = array('value' => $this->_duration_array($week), 'params' => $this->_setParams($day)); |
|
2471 | + elseif (is_string($week) && (3 <= strlen(trim($week)))) { |
|
2472 | + $week = trim($week); |
|
2473 | + if (in_array(substr($week, 0, 1), array('+', '-'))) |
|
2474 | + $week = substr($week, 1); |
|
2475 | + $this->duration = array('value' => $this->_duration_string($week), 'params' => $this->_setParams($day)); |
|
2476 | + } |
|
2477 | + elseif (empty($week) && empty($day) && empty($hour) && empty($min) && empty($sec)) |
|
2478 | 2478 | return FALSE; |
2479 | 2479 | else |
2480 | - $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params )); |
|
2480 | + $this->duration = array('value' => $this->_duration_array(array($week, $day, $hour, $min, $sec)), 'params' => $this->_setParams($params)); |
|
2481 | 2481 | return TRUE; |
2482 | 2482 | } |
2483 | 2483 | /*********************************************************************************/ |
@@ -2492,36 +2492,36 @@ discard block |
||
2492 | 2492 | * @return string |
2493 | 2493 | */ |
2494 | 2494 | function createExdate() { |
2495 | - if( empty( $this->exdate )) return FALSE; |
|
2495 | + if (empty($this->exdate)) return FALSE; |
|
2496 | 2496 | $output = null; |
2497 | - foreach( $this->exdate as $ex => $theExdate ) { |
|
2498 | - if( empty( $theExdate['value'] )) { |
|
2499 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'EXDATE' ); |
|
2497 | + foreach ($this->exdate as $ex => $theExdate) { |
|
2498 | + if (empty($theExdate['value'])) { |
|
2499 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('EXDATE'); |
|
2500 | 2500 | continue; |
2501 | 2501 | } |
2502 | 2502 | $content = $attributes = null; |
2503 | - foreach( $theExdate['value'] as $eix => $exdatePart ) { |
|
2504 | - $parno = count( $exdatePart ); |
|
2505 | - $formatted = $this->_format_date_time( $exdatePart, $parno ); |
|
2506 | - if( isset( $theExdate['params']['TZID'] )) |
|
2507 | - $formatted = str_replace( 'Z', '', $formatted); |
|
2508 | - if( 0 < $eix ) { |
|
2509 | - if( isset( $theExdate['value'][0]['tz'] )) { |
|
2510 | - if( ctype_digit( substr( $theExdate['value'][0]['tz'], -4 )) || |
|
2511 | - ( 'Z' == $theExdate['value'][0]['tz'] )) { |
|
2512 | - if( 'Z' != substr( $formatted, -1 )) |
|
2503 | + foreach ($theExdate['value'] as $eix => $exdatePart) { |
|
2504 | + $parno = count($exdatePart); |
|
2505 | + $formatted = $this->_format_date_time($exdatePart, $parno); |
|
2506 | + if (isset($theExdate['params']['TZID'])) |
|
2507 | + $formatted = str_replace('Z', '', $formatted); |
|
2508 | + if (0 < $eix) { |
|
2509 | + if (isset($theExdate['value'][0]['tz'])) { |
|
2510 | + if (ctype_digit(substr($theExdate['value'][0]['tz'], -4)) || |
|
2511 | + ('Z' == $theExdate['value'][0]['tz'])) { |
|
2512 | + if ('Z' != substr($formatted, -1)) |
|
2513 | 2513 | $formatted .= 'Z'; |
2514 | 2514 | } |
2515 | 2515 | else |
2516 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2516 | + $formatted = str_replace('Z', '', $formatted); |
|
2517 | 2517 | } |
2518 | 2518 | else |
2519 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2519 | + $formatted = str_replace('Z', '', $formatted); |
|
2520 | 2520 | } |
2521 | - $content .= ( 0 < $eix ) ? ','.$formatted : $formatted; |
|
2521 | + $content .= (0 < $eix) ? ','.$formatted : $formatted; |
|
2522 | 2522 | } |
2523 | - $attributes .= $this->_createParams( $theExdate['params'] ); |
|
2524 | - $output .= $this->_createElement( 'EXDATE', $attributes, $content ); |
|
2523 | + $attributes .= $this->_createParams($theExdate['params']); |
|
2524 | + $output .= $this->_createElement('EXDATE', $attributes, $content); |
|
2525 | 2525 | } |
2526 | 2526 | return $output; |
2527 | 2527 | } |
@@ -2535,44 +2535,44 @@ discard block |
||
2535 | 2535 | * @param integer $index, optional |
2536 | 2536 | * @return bool |
2537 | 2537 | */ |
2538 | - function setExdate( $exdates, $params=FALSE, $index=FALSE ) { |
|
2539 | - if( empty( $exdates )) { |
|
2540 | - if( $this->getConfig( 'allowEmpty' )) { |
|
2541 | - $this->_setMval( $this->exdate, null, $params, FALSE, $index ); |
|
2538 | + function setExdate($exdates, $params = FALSE, $index = FALSE) { |
|
2539 | + if (empty($exdates)) { |
|
2540 | + if ($this->getConfig('allowEmpty')) { |
|
2541 | + $this->_setMval($this->exdate, null, $params, FALSE, $index); |
|
2542 | 2542 | return TRUE; |
2543 | 2543 | } |
2544 | 2544 | else |
2545 | 2545 | return FALSE; |
2546 | 2546 | } |
2547 | - $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ))); |
|
2547 | + $input = array('params' => $this->_setParams($params, array('VALUE' => 'DATE-TIME'))); |
|
2548 | 2548 | /* ev. check 1:st date and save ev. timezone **/ |
2549 | - $this->_chkdatecfg( reset( $exdates ), $parno, $input['params'] ); |
|
2550 | - $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default parameter |
|
2551 | - foreach( $exdates as $eix => $theExdate ) { |
|
2552 | - if( $this->_isArrayTimestampDate( $theExdate )) |
|
2553 | - $exdatea = $this->_timestamp2date( $theExdate, $parno ); |
|
2554 | - elseif( is_array( $theExdate )) |
|
2555 | - $exdatea = $this->_date_time_array( $theExdate, $parno ); |
|
2556 | - elseif( 8 <= strlen( trim( $theExdate ))) // ex. 2006-08-03 10:12:18 |
|
2557 | - $exdatea = $this->_date_time_string( $theExdate, $parno ); |
|
2558 | - if( 3 == $parno ) |
|
2559 | - unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] ); |
|
2560 | - elseif( isset( $exdatea['tz'] )) |
|
2549 | + $this->_chkdatecfg(reset($exdates), $parno, $input['params']); |
|
2550 | + $this->_existRem($input['params'], 'VALUE', 'DATE-TIME'); // remove default parameter |
|
2551 | + foreach ($exdates as $eix => $theExdate) { |
|
2552 | + if ($this->_isArrayTimestampDate($theExdate)) |
|
2553 | + $exdatea = $this->_timestamp2date($theExdate, $parno); |
|
2554 | + elseif (is_array($theExdate)) |
|
2555 | + $exdatea = $this->_date_time_array($theExdate, $parno); |
|
2556 | + elseif (8 <= strlen(trim($theExdate))) // ex. 2006-08-03 10:12:18 |
|
2557 | + $exdatea = $this->_date_time_string($theExdate, $parno); |
|
2558 | + if (3 == $parno) |
|
2559 | + unset($exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz']); |
|
2560 | + elseif (isset($exdatea['tz'])) |
|
2561 | 2561 | $exdatea['tz'] = (string) $exdatea['tz']; |
2562 | - if( isset( $input['params']['TZID'] ) || |
|
2563 | - ( isset( $exdatea['tz'] ) && !$this->_isOffset( $exdatea['tz'] )) || |
|
2564 | - ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) || |
|
2565 | - ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) |
|
2566 | - unset( $exdatea['tz'] ); |
|
2562 | + if (isset($input['params']['TZID']) || |
|
2563 | + (isset($exdatea['tz']) && !$this->_isOffset($exdatea['tz'])) || |
|
2564 | + (isset($input['value'][0]) && (!isset($input['value'][0]['tz']))) || |
|
2565 | + (isset($input['value'][0]['tz']) && !$this->_isOffset($input['value'][0]['tz']))) |
|
2566 | + unset($exdatea['tz']); |
|
2567 | 2567 | $input['value'][] = $exdatea; |
2568 | 2568 | } |
2569 | - if( 0 >= count( $input['value'] )) |
|
2569 | + if (0 >= count($input['value'])) |
|
2570 | 2570 | return FALSE; |
2571 | - if( 3 == $parno ) { |
|
2571 | + if (3 == $parno) { |
|
2572 | 2572 | $input['params']['VALUE'] = 'DATE'; |
2573 | - unset( $input['params']['TZID'] ); |
|
2573 | + unset($input['params']['TZID']); |
|
2574 | 2574 | } |
2575 | - $this->_setMval( $this->exdate, $input['value'], $input['params'], FALSE, $index ); |
|
2575 | + $this->_setMval($this->exdate, $input['value'], $input['params'], FALSE, $index); |
|
2576 | 2576 | return TRUE; |
2577 | 2577 | } |
2578 | 2578 | /*********************************************************************************/ |
@@ -2587,8 +2587,8 @@ discard block |
||
2587 | 2587 | * @return string |
2588 | 2588 | */ |
2589 | 2589 | function createExrule() { |
2590 | - if( empty( $this->exrule )) return FALSE; |
|
2591 | - return $this->_format_recur( 'EXRULE', $this->exrule ); |
|
2590 | + if (empty($this->exrule)) return FALSE; |
|
2591 | + return $this->_format_recur('EXRULE', $this->exrule); |
|
2592 | 2592 | } |
2593 | 2593 | /** |
2594 | 2594 | * set calendar component property exdate |
@@ -2600,9 +2600,9 @@ discard block |
||
2600 | 2600 | * @param integer $index, optional |
2601 | 2601 | * @return bool |
2602 | 2602 | */ |
2603 | - function setExrule( $exruleset, $params=FALSE, $index=FALSE ) { |
|
2604 | - if( empty( $exruleset )) if( $this->getConfig( 'allowEmpty' )) $exruleset = null; else return FALSE; |
|
2605 | - $this->_setMval( $this->exrule, $this->_setRexrule( $exruleset ), $params, FALSE, $index ); |
|
2603 | + function setExrule($exruleset, $params = FALSE, $index = FALSE) { |
|
2604 | + if (empty($exruleset)) if ($this->getConfig('allowEmpty')) $exruleset = null; else return FALSE; |
|
2605 | + $this->_setMval($this->exrule, $this->_setRexrule($exruleset), $params, FALSE, $index); |
|
2606 | 2606 | return TRUE; |
2607 | 2607 | } |
2608 | 2608 | /*********************************************************************************/ |
@@ -2617,47 +2617,47 @@ discard block |
||
2617 | 2617 | * @return string |
2618 | 2618 | */ |
2619 | 2619 | function createFreebusy() { |
2620 | - if( empty( $this->freebusy )) return FALSE; |
|
2620 | + if (empty($this->freebusy)) return FALSE; |
|
2621 | 2621 | $output = null; |
2622 | - foreach( $this->freebusy as $freebusyPart ) { |
|
2623 | - if( empty( $freebusyPart['value'] )) { |
|
2624 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'FREEBUSY' ); |
|
2622 | + foreach ($this->freebusy as $freebusyPart) { |
|
2623 | + if (empty($freebusyPart['value'])) { |
|
2624 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('FREEBUSY'); |
|
2625 | 2625 | continue; |
2626 | 2626 | } |
2627 | 2627 | $attributes = $content = null; |
2628 | - if( isset( $freebusyPart['value']['fbtype'] )) { |
|
2628 | + if (isset($freebusyPart['value']['fbtype'])) { |
|
2629 | 2629 | $attributes .= $this->intAttrDelimiter.'FBTYPE='.$freebusyPart['value']['fbtype']; |
2630 | - unset( $freebusyPart['value']['fbtype'] ); |
|
2631 | - $freebusyPart['value'] = array_values( $freebusyPart['value'] ); |
|
2630 | + unset($freebusyPart['value']['fbtype']); |
|
2631 | + $freebusyPart['value'] = array_values($freebusyPart['value']); |
|
2632 | 2632 | } |
2633 | 2633 | else |
2634 | 2634 | $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY'; |
2635 | - $attributes .= $this->_createParams( $freebusyPart['params'] ); |
|
2635 | + $attributes .= $this->_createParams($freebusyPart['params']); |
|
2636 | 2636 | $fno = 1; |
2637 | - $cnt = count( $freebusyPart['value']); |
|
2638 | - foreach( $freebusyPart['value'] as $periodix => $freebusyPeriod ) { |
|
2639 | - $formatted = $this->_format_date_time( $freebusyPeriod[0] ); |
|
2637 | + $cnt = count($freebusyPart['value']); |
|
2638 | + foreach ($freebusyPart['value'] as $periodix => $freebusyPeriod) { |
|
2639 | + $formatted = $this->_format_date_time($freebusyPeriod[0]); |
|
2640 | 2640 | $content .= $formatted; |
2641 | 2641 | $content .= '/'; |
2642 | - $cnt2 = count( $freebusyPeriod[1]); |
|
2643 | - if( array_key_exists( 'year', $freebusyPeriod[1] )) // date-time |
|
2642 | + $cnt2 = count($freebusyPeriod[1]); |
|
2643 | + if (array_key_exists('year', $freebusyPeriod[1])) // date-time |
|
2644 | 2644 | $cnt2 = 7; |
2645 | - elseif( array_key_exists( 'week', $freebusyPeriod[1] )) // duration |
|
2645 | + elseif (array_key_exists('week', $freebusyPeriod[1])) // duration |
|
2646 | 2646 | $cnt2 = 5; |
2647 | - if(( 7 == $cnt2 ) && // period= -> date-time |
|
2648 | - isset( $freebusyPeriod[1]['year'] ) && |
|
2649 | - isset( $freebusyPeriod[1]['month'] ) && |
|
2650 | - isset( $freebusyPeriod[1]['day'] )) { |
|
2651 | - $content .= $this->_format_date_time( $freebusyPeriod[1] ); |
|
2647 | + if ((7 == $cnt2) && // period= -> date-time |
|
2648 | + isset($freebusyPeriod[1]['year']) && |
|
2649 | + isset($freebusyPeriod[1]['month']) && |
|
2650 | + isset($freebusyPeriod[1]['day'])) { |
|
2651 | + $content .= $this->_format_date_time($freebusyPeriod[1]); |
|
2652 | 2652 | } |
2653 | 2653 | else { // period= -> dur-time |
2654 | - $content .= $this->_format_duration( $freebusyPeriod[1] ); |
|
2654 | + $content .= $this->_format_duration($freebusyPeriod[1]); |
|
2655 | 2655 | } |
2656 | - if( $fno < $cnt ) |
|
2656 | + if ($fno < $cnt) |
|
2657 | 2657 | $content .= ','; |
2658 | 2658 | $fno++; |
2659 | 2659 | } |
2660 | - $output .= $this->_createElement( 'FREEBUSY', $attributes, $content ); |
|
2660 | + $output .= $this->_createElement('FREEBUSY', $attributes, $content); |
|
2661 | 2661 | } |
2662 | 2662 | return $output; |
2663 | 2663 | } |
@@ -2672,52 +2672,52 @@ discard block |
||
2672 | 2672 | * @param integer $index, optional |
2673 | 2673 | * @return bool |
2674 | 2674 | */ |
2675 | - function setFreebusy( $fbType, $fbValues, $params=FALSE, $index=FALSE ) { |
|
2676 | - if( empty( $fbValues )) { |
|
2677 | - if( $this->getConfig( 'allowEmpty' )) { |
|
2678 | - $this->_setMval( $this->freebusy, null, $params, FALSE, $index ); |
|
2675 | + function setFreebusy($fbType, $fbValues, $params = FALSE, $index = FALSE) { |
|
2676 | + if (empty($fbValues)) { |
|
2677 | + if ($this->getConfig('allowEmpty')) { |
|
2678 | + $this->_setMval($this->freebusy, null, $params, FALSE, $index); |
|
2679 | 2679 | return TRUE; |
2680 | 2680 | } |
2681 | 2681 | else |
2682 | 2682 | return FALSE; |
2683 | 2683 | } |
2684 | - $fbType = strtoupper( $fbType ); |
|
2685 | - if(( !in_array( $fbType, array( 'FREE', 'BUSY', 'BUSY-UNAVAILABLE', 'BUSY-TENTATIVE' ))) && |
|
2686 | - ( 'X-' != substr( $fbType, 0, 2 ))) |
|
2684 | + $fbType = strtoupper($fbType); |
|
2685 | + if ((!in_array($fbType, array('FREE', 'BUSY', 'BUSY-UNAVAILABLE', 'BUSY-TENTATIVE'))) && |
|
2686 | + ('X-' != substr($fbType, 0, 2))) |
|
2687 | 2687 | $fbType = 'BUSY'; |
2688 | - $input = array( 'fbtype' => $fbType ); |
|
2689 | - foreach( $fbValues as $fbPeriod ) { // periods => period |
|
2688 | + $input = array('fbtype' => $fbType); |
|
2689 | + foreach ($fbValues as $fbPeriod) { // periods => period |
|
2690 | 2690 | $freebusyPeriod = array(); |
2691 | - foreach( $fbPeriod as $fbMember ) { // pairs => singlepart |
|
2691 | + foreach ($fbPeriod as $fbMember) { // pairs => singlepart |
|
2692 | 2692 | $freebusyPairMember = array(); |
2693 | - if( is_array( $fbMember )) { |
|
2694 | - if( $this->_isArrayDate( $fbMember )) { // date-time value |
|
2695 | - $freebusyPairMember = $this->_date_time_array( $fbMember, 7 ); |
|
2693 | + if (is_array($fbMember)) { |
|
2694 | + if ($this->_isArrayDate($fbMember)) { // date-time value |
|
2695 | + $freebusyPairMember = $this->_date_time_array($fbMember, 7); |
|
2696 | 2696 | $freebusyPairMember['tz'] = 'Z'; |
2697 | 2697 | } |
2698 | - elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value |
|
2699 | - $freebusyPairMember = $this->_timestamp2date( $fbMember['timestamp'], 7 ); |
|
2698 | + elseif ($this->_isArrayTimestampDate($fbMember)) { // timestamp value |
|
2699 | + $freebusyPairMember = $this->_timestamp2date($fbMember['timestamp'], 7); |
|
2700 | 2700 | $freebusyPairMember['tz'] = 'Z'; |
2701 | 2701 | } |
2702 | 2702 | else { // array format duration |
2703 | - $freebusyPairMember = $this->_duration_array( $fbMember ); |
|
2703 | + $freebusyPairMember = $this->_duration_array($fbMember); |
|
2704 | 2704 | } |
2705 | 2705 | } |
2706 | - elseif(( 3 <= strlen( trim( $fbMember ))) && // string format duration |
|
2707 | - ( in_array( $fbMember{0}, array( 'P', '+', '-' )))) { |
|
2708 | - if( 'P' != $fbMember{0} ) |
|
2709 | - $fbmember = substr( $fbMember, 1 ); |
|
2710 | - $freebusyPairMember = $this->_duration_string( $fbMember ); |
|
2706 | + elseif ((3 <= strlen(trim($fbMember))) && // string format duration |
|
2707 | + (in_array($fbMember{0}, array('P', '+', '-')))) { |
|
2708 | + if ('P' != $fbMember{0} ) |
|
2709 | + $fbmember = substr($fbMember, 1); |
|
2710 | + $freebusyPairMember = $this->_duration_string($fbMember); |
|
2711 | 2711 | } |
2712 | - elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18 |
|
2713 | - $freebusyPairMember = $this->_date_time_string( $fbMember, 7 ); |
|
2712 | + elseif (8 <= strlen(trim($fbMember))) { // text date ex. 2006-08-03 10:12:18 |
|
2713 | + $freebusyPairMember = $this->_date_time_string($fbMember, 7); |
|
2714 | 2714 | $freebusyPairMember['tz'] = 'Z'; |
2715 | 2715 | } |
2716 | - $freebusyPeriod[] = $freebusyPairMember; |
|
2716 | + $freebusyPeriod[] = $freebusyPairMember; |
|
2717 | 2717 | } |
2718 | - $input[] = $freebusyPeriod; |
|
2718 | + $input[] = $freebusyPeriod; |
|
2719 | 2719 | } |
2720 | - $this->_setMval( $this->freebusy, $input, $params, FALSE, $index ); |
|
2720 | + $this->_setMval($this->freebusy, $input, $params, FALSE, $index); |
|
2721 | 2721 | return TRUE; |
2722 | 2722 | } |
2723 | 2723 | /*********************************************************************************/ |
@@ -2732,15 +2732,15 @@ discard block |
||
2732 | 2732 | * @return string |
2733 | 2733 | */ |
2734 | 2734 | function createGeo() { |
2735 | - if( empty( $this->geo )) return FALSE; |
|
2736 | - if( empty( $this->geo['value'] )) |
|
2737 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE; |
|
2738 | - $attributes = $this->_createParams( $this->geo['params'] ); |
|
2735 | + if (empty($this->geo)) return FALSE; |
|
2736 | + if (empty($this->geo['value'])) |
|
2737 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('GEO') : FALSE; |
|
2738 | + $attributes = $this->_createParams($this->geo['params']); |
|
2739 | 2739 | $content = null; |
2740 | - $content .= number_format( (float) $this->geo['value']['latitude'], 6, '.', ''); |
|
2740 | + $content .= number_format((float) $this->geo['value']['latitude'], 6, '.', ''); |
|
2741 | 2741 | $content .= ';'; |
2742 | - $content .= number_format( (float) $this->geo['value']['longitude'], 6, '.', ''); |
|
2743 | - return $this->_createElement( 'GEO', $attributes, $content ); |
|
2742 | + $content .= number_format((float) $this->geo['value']['longitude'], 6, '.', ''); |
|
2743 | + return $this->_createElement('GEO', $attributes, $content); |
|
2744 | 2744 | } |
2745 | 2745 | /** |
2746 | 2746 | * set calendar component property geo |
@@ -2752,15 +2752,15 @@ discard block |
||
2752 | 2752 | * @param array $params optional |
2753 | 2753 | * @return bool |
2754 | 2754 | */ |
2755 | - function setGeo( $latitude, $longitude, $params=FALSE ) { |
|
2756 | - if( !empty( $latitude ) && !empty( $longitude )) { |
|
2757 | - if( !is_array( $this->geo )) $this->geo = array(); |
|
2755 | + function setGeo($latitude, $longitude, $params = FALSE) { |
|
2756 | + if (!empty($latitude) && !empty($longitude)) { |
|
2757 | + if (!is_array($this->geo)) $this->geo = array(); |
|
2758 | 2758 | $this->geo['value']['latitude'] = $latitude; |
2759 | 2759 | $this->geo['value']['longitude'] = $longitude; |
2760 | - $this->geo['params'] = $this->_setParams( $params ); |
|
2760 | + $this->geo['params'] = $this->_setParams($params); |
|
2761 | 2761 | } |
2762 | - elseif( $this->getConfig( 'allowEmpty' )) |
|
2763 | - $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) ); |
|
2762 | + elseif ($this->getConfig('allowEmpty')) |
|
2763 | + $this->geo = array('value' => null, 'params' => $this->_setParams($params)); |
|
2764 | 2764 | else |
2765 | 2765 | return FALSE; |
2766 | 2766 | return TRUE; |
@@ -2777,10 +2777,10 @@ discard block |
||
2777 | 2777 | * @return string |
2778 | 2778 | */ |
2779 | 2779 | function createLastModified() { |
2780 | - if( empty( $this->lastmodified )) return FALSE; |
|
2781 | - $attributes = $this->_createParams( $this->lastmodified['params'] ); |
|
2782 | - $formatted = $this->_format_date_time( $this->lastmodified['value'], 7 ); |
|
2783 | - return $this->_createElement( 'LAST-MODIFIED', $attributes, $formatted ); |
|
2780 | + if (empty($this->lastmodified)) return FALSE; |
|
2781 | + $attributes = $this->_createParams($this->lastmodified['params']); |
|
2782 | + $formatted = $this->_format_date_time($this->lastmodified['value'], 7); |
|
2783 | + return $this->_createElement('LAST-MODIFIED', $attributes, $formatted); |
|
2784 | 2784 | } |
2785 | 2785 | /** |
2786 | 2786 | * set calendar component property completed |
@@ -2796,10 +2796,10 @@ discard block |
||
2796 | 2796 | * @param array $params optional |
2797 | 2797 | * @return boll |
2798 | 2798 | */ |
2799 | - function setLastModified( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
|
2800 | - if( empty( $year )) |
|
2801 | - $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' ))); |
|
2802 | - $this->lastmodified = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
|
2799 | + function setLastModified($year = FALSE, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) { |
|
2800 | + if (empty($year)) |
|
2801 | + $year = date('Ymd\THis', mktime(date('H'), date('i'), date('s') - date('Z'), date('m'), date('d'), date('Y'))); |
|
2802 | + $this->lastmodified = $this->_setDate2($year, $month, $day, $hour, $min, $sec, $params); |
|
2803 | 2803 | return TRUE; |
2804 | 2804 | } |
2805 | 2805 | /*********************************************************************************/ |
@@ -2814,12 +2814,12 @@ discard block |
||
2814 | 2814 | * @return string |
2815 | 2815 | */ |
2816 | 2816 | function createLocation() { |
2817 | - if( empty( $this->location )) return FALSE; |
|
2818 | - if( empty( $this->location['value'] )) |
|
2819 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE; |
|
2820 | - $attributes = $this->_createParams( $this->location['params'], array( 'ALTREP', 'LANGUAGE' )); |
|
2821 | - $content = $this->_strrep( $this->location['value'] ); |
|
2822 | - return $this->_createElement( 'LOCATION', $attributes, $content ); |
|
2817 | + if (empty($this->location)) return FALSE; |
|
2818 | + if (empty($this->location['value'])) |
|
2819 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('LOCATION') : FALSE; |
|
2820 | + $attributes = $this->_createParams($this->location['params'], array('ALTREP', 'LANGUAGE')); |
|
2821 | + $content = $this->_strrep($this->location['value']); |
|
2822 | + return $this->_createElement('LOCATION', $attributes, $content); |
|
2823 | 2823 | } |
2824 | 2824 | /** |
2825 | 2825 | * set calendar component property location |
@@ -2830,9 +2830,9 @@ discard block |
||
2830 | 2830 | * @param array params optional |
2831 | 2831 | * @return bool |
2832 | 2832 | */ |
2833 | - function setLocation( $value, $params=FALSE ) { |
|
2834 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2835 | - $this->location = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
2833 | + function setLocation($value, $params = FALSE) { |
|
2834 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
2835 | + $this->location = array('value' => $value, 'params' => $this->_setParams($params)); |
|
2836 | 2836 | return TRUE; |
2837 | 2837 | } |
2838 | 2838 | /*********************************************************************************/ |
@@ -2847,13 +2847,13 @@ discard block |
||
2847 | 2847 | * @return string |
2848 | 2848 | */ |
2849 | 2849 | function createOrganizer() { |
2850 | - if( empty( $this->organizer )) return FALSE; |
|
2851 | - if( empty( $this->organizer['value'] )) |
|
2852 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE; |
|
2853 | - $attributes = $this->_createParams( $this->organizer['params'] |
|
2854 | - , array( 'CN', 'DIR', 'LANGUAGE', 'SENT-BY' )); |
|
2850 | + if (empty($this->organizer)) return FALSE; |
|
2851 | + if (empty($this->organizer['value'])) |
|
2852 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('ORGANIZER') : FALSE; |
|
2853 | + $attributes = $this->_createParams($this->organizer['params'] |
|
2854 | + , array('CN', 'DIR', 'LANGUAGE', 'SENT-BY')); |
|
2855 | 2855 | $content = 'MAILTO:'.$this->organizer['value']; |
2856 | - return $this->_createElement( 'ORGANIZER', $attributes, $content ); |
|
2856 | + return $this->_createElement('ORGANIZER', $attributes, $content); |
|
2857 | 2857 | } |
2858 | 2858 | /** |
2859 | 2859 | * set calendar component property organizer |
@@ -2864,14 +2864,14 @@ discard block |
||
2864 | 2864 | * @param array params optional |
2865 | 2865 | * @return bool |
2866 | 2866 | */ |
2867 | - function setOrganizer( $value, $params=FALSE ) { |
|
2868 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2869 | - $value = str_replace ( 'MAILTO:', '', $value ); |
|
2870 | - $value = str_replace ( 'mailto:', '', $value ); |
|
2871 | - $this->organizer = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
2872 | - if( isset( $this->organizer['params']['SENT-BY'] )) { |
|
2873 | - if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 ))) |
|
2874 | - $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 ); |
|
2867 | + function setOrganizer($value, $params = FALSE) { |
|
2868 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
2869 | + $value = str_replace('MAILTO:', '', $value); |
|
2870 | + $value = str_replace('mailto:', '', $value); |
|
2871 | + $this->organizer = array('value' => $value, 'params' => $this->_setParams($params)); |
|
2872 | + if (isset($this->organizer['params']['SENT-BY'])) { |
|
2873 | + if ('MAILTO' == strtoupper(substr($this->organizer['params']['SENT-BY'], 0, 6))) |
|
2874 | + $this->organizer['params']['SENT-BY'] = substr($this->organizer['params']['SENT-BY'], 7); |
|
2875 | 2875 | } |
2876 | 2876 | return TRUE; |
2877 | 2877 | } |
@@ -2887,11 +2887,11 @@ discard block |
||
2887 | 2887 | * @return string |
2888 | 2888 | */ |
2889 | 2889 | function createPercentComplete() { |
2890 | - if( empty( $this->percentcomplete )) return FALSE; |
|
2891 | - if( empty( $this->percentcomplete['value'] )) |
|
2892 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE; |
|
2893 | - $attributes = $this->_createParams( $this->percentcomplete['params'] ); |
|
2894 | - return $this->_createElement( 'PERCENT-COMPLETE', $attributes, $this->percentcomplete['value'] ); |
|
2890 | + if (empty($this->percentcomplete)) return FALSE; |
|
2891 | + if (empty($this->percentcomplete['value'])) |
|
2892 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('PERCENT-COMPLETE') : FALSE; |
|
2893 | + $attributes = $this->_createParams($this->percentcomplete['params']); |
|
2894 | + return $this->_createElement('PERCENT-COMPLETE', $attributes, $this->percentcomplete['value']); |
|
2895 | 2895 | } |
2896 | 2896 | /** |
2897 | 2897 | * set calendar component property percent-complete |
@@ -2902,9 +2902,9 @@ discard block |
||
2902 | 2902 | * @param array $params optional |
2903 | 2903 | * @return bool |
2904 | 2904 | */ |
2905 | - function setPercentComplete( $value, $params=FALSE ) { |
|
2906 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2907 | - $this->percentcomplete = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
2905 | + function setPercentComplete($value, $params = FALSE) { |
|
2906 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
2907 | + $this->percentcomplete = array('value' => $value, 'params' => $this->_setParams($params)); |
|
2908 | 2908 | return TRUE; |
2909 | 2909 | } |
2910 | 2910 | /*********************************************************************************/ |
@@ -2919,11 +2919,11 @@ discard block |
||
2919 | 2919 | * @return string |
2920 | 2920 | */ |
2921 | 2921 | function createPriority() { |
2922 | - if( empty( $this->priority )) return FALSE; |
|
2923 | - if( empty( $this->priority['value'] )) |
|
2924 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE; |
|
2925 | - $attributes = $this->_createParams( $this->priority['params'] ); |
|
2926 | - return $this->_createElement( 'PRIORITY', $attributes, $this->priority['value'] ); |
|
2922 | + if (empty($this->priority)) return FALSE; |
|
2923 | + if (empty($this->priority['value'])) |
|
2924 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('PRIORITY') : FALSE; |
|
2925 | + $attributes = $this->_createParams($this->priority['params']); |
|
2926 | + return $this->_createElement('PRIORITY', $attributes, $this->priority['value']); |
|
2927 | 2927 | } |
2928 | 2928 | /** |
2929 | 2929 | * set calendar component property priority |
@@ -2934,9 +2934,9 @@ discard block |
||
2934 | 2934 | * @param array $params optional |
2935 | 2935 | * @return bool |
2936 | 2936 | */ |
2937 | - function setPriority( $value, $params=FALSE ) { |
|
2938 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2939 | - $this->priority = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
2937 | + function setPriority($value, $params = FALSE) { |
|
2938 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
2939 | + $this->priority = array('value' => $value, 'params' => $this->_setParams($params)); |
|
2940 | 2940 | return TRUE; |
2941 | 2941 | } |
2942 | 2942 | /*********************************************************************************/ |
@@ -2951,91 +2951,91 @@ discard block |
||
2951 | 2951 | * @return string |
2952 | 2952 | */ |
2953 | 2953 | function createRdate() { |
2954 | - if( empty( $this->rdate )) return FALSE; |
|
2955 | - $utctime = ( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE; |
|
2954 | + if (empty($this->rdate)) return FALSE; |
|
2955 | + $utctime = (in_array($this->objName, array('vtimezone', 'standard', 'daylight'))) ? TRUE : FALSE; |
|
2956 | 2956 | $output = null; |
2957 | - if( $utctime ) |
|
2958 | - unset( $this->rdate['params']['TZID'] ); |
|
2959 | - foreach( $this->rdate as $theRdate ) { |
|
2960 | - if( empty( $theRdate['value'] )) { |
|
2961 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RDATE' ); |
|
2957 | + if ($utctime) |
|
2958 | + unset($this->rdate['params']['TZID']); |
|
2959 | + foreach ($this->rdate as $theRdate) { |
|
2960 | + if (empty($theRdate['value'])) { |
|
2961 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('RDATE'); |
|
2962 | 2962 | continue; |
2963 | 2963 | } |
2964 | - if( $utctime ) |
|
2965 | - unset( $theRdate['params']['TZID'] ); |
|
2966 | - $attributes = $this->_createParams( $theRdate['params'] ); |
|
2967 | - $cnt = count( $theRdate['value'] ); |
|
2964 | + if ($utctime) |
|
2965 | + unset($theRdate['params']['TZID']); |
|
2966 | + $attributes = $this->_createParams($theRdate['params']); |
|
2967 | + $cnt = count($theRdate['value']); |
|
2968 | 2968 | $content = null; |
2969 | 2969 | $rno = 1; |
2970 | - foreach( $theRdate['value'] as $rpix => $rdatePart ) { |
|
2970 | + foreach ($theRdate['value'] as $rpix => $rdatePart) { |
|
2971 | 2971 | $contentPart = null; |
2972 | - if( is_array( $rdatePart ) && |
|
2973 | - isset( $theRdate['params']['VALUE'] ) && ( 'PERIOD' == $theRdate['params']['VALUE'] )) { // PERIOD |
|
2974 | - if( $utctime ) |
|
2975 | - unset( $rdatePart[0]['tz'] ); |
|
2976 | - $formatted = $this->_format_date_time( $rdatePart[0]); // PERIOD part 1 |
|
2977 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
2978 | - $formatted = str_replace( 'Z', '', $formatted); |
|
2979 | - if( 0 < $rpix ) { |
|
2980 | - if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) { |
|
2981 | - if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z'; |
|
2972 | + if (is_array($rdatePart) && |
|
2973 | + isset($theRdate['params']['VALUE']) && ('PERIOD' == $theRdate['params']['VALUE'])) { // PERIOD |
|
2974 | + if ($utctime) |
|
2975 | + unset($rdatePart[0]['tz']); |
|
2976 | + $formatted = $this->_format_date_time($rdatePart[0]); // PERIOD part 1 |
|
2977 | + if ($utctime || !empty($theRdate['params']['TZID'])) |
|
2978 | + $formatted = str_replace('Z', '', $formatted); |
|
2979 | + if (0 < $rpix) { |
|
2980 | + if (!empty($rdatePart[0]['tz']) && $this->_isOffset($rdatePart[0]['tz'])) { |
|
2981 | + if ('Z' != substr($formatted, -1)) $formatted .= 'Z'; |
|
2982 | 2982 | } |
2983 | 2983 | else |
2984 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2984 | + $formatted = str_replace('Z', '', $formatted); |
|
2985 | 2985 | } |
2986 | 2986 | $contentPart .= $formatted; |
2987 | 2987 | $contentPart .= '/'; |
2988 | - $cnt2 = count( $rdatePart[1]); |
|
2989 | - if( array_key_exists( 'year', $rdatePart[1] )) { |
|
2990 | - if( array_key_exists( 'hour', $rdatePart[1] )) |
|
2991 | - $cnt2 = 7; // date-time |
|
2988 | + $cnt2 = count($rdatePart[1]); |
|
2989 | + if (array_key_exists('year', $rdatePart[1])) { |
|
2990 | + if (array_key_exists('hour', $rdatePart[1])) |
|
2991 | + $cnt2 = 7; // date-time |
|
2992 | 2992 | else |
2993 | - $cnt2 = 3; // date |
|
2993 | + $cnt2 = 3; // date |
|
2994 | 2994 | } |
2995 | - elseif( array_key_exists( 'week', $rdatePart[1] )) // duration |
|
2995 | + elseif (array_key_exists('week', $rdatePart[1])) // duration |
|
2996 | 2996 | $cnt2 = 5; |
2997 | - if(( 7 == $cnt2 ) && // period= -> date-time |
|
2998 | - isset( $rdatePart[1]['year'] ) && |
|
2999 | - isset( $rdatePart[1]['month'] ) && |
|
3000 | - isset( $rdatePart[1]['day'] )) { |
|
3001 | - if( $utctime ) |
|
3002 | - unset( $rdatePart[1]['tz'] ); |
|
3003 | - $formatted = $this->_format_date_time( $rdatePart[1] ); // PERIOD part 2 |
|
3004 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
3005 | - $formatted = str_replace( 'Z', '', $formatted); |
|
3006 | - if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) { |
|
3007 | - if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z'; |
|
2997 | + if ((7 == $cnt2) && // period= -> date-time |
|
2998 | + isset($rdatePart[1]['year']) && |
|
2999 | + isset($rdatePart[1]['month']) && |
|
3000 | + isset($rdatePart[1]['day'])) { |
|
3001 | + if ($utctime) |
|
3002 | + unset($rdatePart[1]['tz']); |
|
3003 | + $formatted = $this->_format_date_time($rdatePart[1]); // PERIOD part 2 |
|
3004 | + if ($utctime || !empty($theRdate['params']['TZID'])) |
|
3005 | + $formatted = str_replace('Z', '', $formatted); |
|
3006 | + if (!empty($rdatePart[0]['tz']) && $this->_isOffset($rdatePart[0]['tz'])) { |
|
3007 | + if ('Z' != substr($formatted, -1)) $formatted .= 'Z'; |
|
3008 | 3008 | } |
3009 | 3009 | else |
3010 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
3010 | + $formatted = str_replace('Z', '', $formatted); |
|
3011 | 3011 | $contentPart .= $formatted; |
3012 | 3012 | } |
3013 | 3013 | else { // period= -> dur-time |
3014 | - $contentPart .= $this->_format_duration( $rdatePart[1] ); |
|
3014 | + $contentPart .= $this->_format_duration($rdatePart[1]); |
|
3015 | 3015 | } |
3016 | 3016 | } // PERIOD end |
3017 | 3017 | else { // SINGLE date start |
3018 | - if( $utctime ) |
|
3019 | - unset( $rdatePart['tz'] ); |
|
3020 | - $formatted = $this->_format_date_time( $rdatePart); |
|
3021 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
3022 | - $formatted = str_replace( 'Z', '', $formatted); |
|
3023 | - if( !$utctime && ( 0 < $rpix )) { |
|
3024 | - if( !empty( $theRdate['value'][0]['tz'] ) && $this->_isOffset( $theRdate['value'][0]['tz'] )) { |
|
3025 | - if( 'Z' != substr( $formatted, -1 )) |
|
3018 | + if ($utctime) |
|
3019 | + unset($rdatePart['tz']); |
|
3020 | + $formatted = $this->_format_date_time($rdatePart); |
|
3021 | + if ($utctime || !empty($theRdate['params']['TZID'])) |
|
3022 | + $formatted = str_replace('Z', '', $formatted); |
|
3023 | + if (!$utctime && (0 < $rpix)) { |
|
3024 | + if (!empty($theRdate['value'][0]['tz']) && $this->_isOffset($theRdate['value'][0]['tz'])) { |
|
3025 | + if ('Z' != substr($formatted, -1)) |
|
3026 | 3026 | $formatted .= 'Z'; |
3027 | 3027 | } |
3028 | 3028 | else |
3029 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
3029 | + $formatted = str_replace('Z', '', $formatted); |
|
3030 | 3030 | } |
3031 | 3031 | $contentPart .= $formatted; |
3032 | 3032 | } |
3033 | 3033 | $content .= $contentPart; |
3034 | - if( $rno < $cnt ) |
|
3034 | + if ($rno < $cnt) |
|
3035 | 3035 | $content .= ','; |
3036 | 3036 | $rno++; |
3037 | 3037 | } |
3038 | - $output .= $this->_createElement( 'RDATE', $attributes, $content ); |
|
3038 | + $output .= $this->_createElement('RDATE', $attributes, $content); |
|
3039 | 3039 | } |
3040 | 3040 | return $output; |
3041 | 3041 | } |
@@ -3049,93 +3049,93 @@ discard block |
||
3049 | 3049 | * @param integer $index, optional |
3050 | 3050 | * @return bool |
3051 | 3051 | */ |
3052 | - function setRdate( $rdates, $params=FALSE, $index=FALSE ) { |
|
3053 | - if( empty( $rdates )) { |
|
3054 | - if( $this->getConfig( 'allowEmpty' )) { |
|
3055 | - $this->_setMval( $this->rdate, null, $params, FALSE, $index ); |
|
3052 | + function setRdate($rdates, $params = FALSE, $index = FALSE) { |
|
3053 | + if (empty($rdates)) { |
|
3054 | + if ($this->getConfig('allowEmpty')) { |
|
3055 | + $this->_setMval($this->rdate, null, $params, FALSE, $index); |
|
3056 | 3056 | return TRUE; |
3057 | 3057 | } |
3058 | 3058 | else |
3059 | 3059 | return FALSE; |
3060 | 3060 | } |
3061 | - $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ))); |
|
3062 | - if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) { |
|
3063 | - unset( $input['params']['TZID'] ); |
|
3061 | + $input = array('params' => $this->_setParams($params, array('VALUE' => 'DATE-TIME'))); |
|
3062 | + if (in_array($this->objName, array('vtimezone', 'standard', 'daylight'))) { |
|
3063 | + unset($input['params']['TZID']); |
|
3064 | 3064 | $input['params']['VALUE'] = 'DATE-TIME'; |
3065 | 3065 | } |
3066 | 3066 | /* check if PERIOD, if not set */ |
3067 | - if((!isset( $input['params']['VALUE'] ) || !in_array( $input['params']['VALUE'], array( 'DATE', 'PERIOD' ))) && |
|
3068 | - isset( $rdates[0] ) && is_array( $rdates[0] ) && ( 2 == count( $rdates[0] )) && |
|
3069 | - isset( $rdates[0][0] ) && isset( $rdates[0][1] ) && !isset( $rdates[0]['timestamp'] ) && |
|
3070 | - (( is_array( $rdates[0][0] ) && ( isset( $rdates[0][0]['timestamp'] ) || |
|
3071 | - $this->_isArrayDate( $rdates[0][0] ))) || |
|
3072 | - ( is_string( $rdates[0][0] ) && ( 8 <= strlen( trim( $rdates[0][0] ))))) && |
|
3073 | - ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] )))))) |
|
3067 | + if ((!isset($input['params']['VALUE']) || !in_array($input['params']['VALUE'], array('DATE', 'PERIOD'))) && |
|
3068 | + isset($rdates[0]) && is_array($rdates[0]) && (2 == count($rdates[0])) && |
|
3069 | + isset($rdates[0][0]) && isset($rdates[0][1]) && !isset($rdates[0]['timestamp']) && |
|
3070 | + ((is_array($rdates[0][0]) && (isset($rdates[0][0]['timestamp']) || |
|
3071 | + $this->_isArrayDate($rdates[0][0]))) || |
|
3072 | + (is_string($rdates[0][0]) && (8 <= strlen(trim($rdates[0][0]))))) && |
|
3073 | + (is_array($rdates[0][1]) || (is_string($rdates[0][1]) && (3 <= strlen(trim($rdates[0][1])))))) |
|
3074 | 3074 | $input['params']['VALUE'] = 'PERIOD'; |
3075 | 3075 | /* check 1:st date, upd. $parno (opt) and save ev. timezone **/ |
3076 | - $date = reset( $rdates ); |
|
3077 | - if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) // PERIOD |
|
3078 | - $date = reset( $date ); |
|
3079 | - $this->_chkdatecfg( $date, $parno, $input['params'] ); |
|
3080 | - if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) |
|
3081 | - unset( $input['params']['TZID'] ); |
|
3082 | - $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default |
|
3083 | - foreach( $rdates as $rpix => $theRdate ) { |
|
3076 | + $date = reset($rdates); |
|
3077 | + if (isset($input['params']['VALUE']) && ('PERIOD' == $input['params']['VALUE'])) // PERIOD |
|
3078 | + $date = reset($date); |
|
3079 | + $this->_chkdatecfg($date, $parno, $input['params']); |
|
3080 | + if (in_array($this->objName, array('vtimezone', 'standard', 'daylight'))) |
|
3081 | + unset($input['params']['TZID']); |
|
3082 | + $this->_existRem($input['params'], 'VALUE', 'DATE-TIME'); // remove default |
|
3083 | + foreach ($rdates as $rpix => $theRdate) { |
|
3084 | 3084 | $inputa = null; |
3085 | - if( is_array( $theRdate )) { |
|
3086 | - if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) { // PERIOD |
|
3087 | - foreach( $theRdate as $rix => $rPeriod ) { |
|
3088 | - if( is_array( $rPeriod )) { |
|
3089 | - if( $this->_isArrayTimestampDate( $rPeriod )) // timestamp |
|
3090 | - $inputab = ( isset( $rPeriod['tz'] )) ? $this->_timestamp2date( $rPeriod, $parno ) : $this->_timestamp2date( $rPeriod, 6 ); |
|
3091 | - elseif( $this->_isArrayDate( $rPeriod )) |
|
3092 | - $inputab = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 ); |
|
3093 | - elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod )))) // text-date |
|
3094 | - $inputab = $this->_date_time_string( reset( $rPeriod ), $parno ); |
|
3085 | + if (is_array($theRdate)) { |
|
3086 | + if (isset($input['params']['VALUE']) && ('PERIOD' == $input['params']['VALUE'])) { // PERIOD |
|
3087 | + foreach ($theRdate as $rix => $rPeriod) { |
|
3088 | + if (is_array($rPeriod)) { |
|
3089 | + if ($this->_isArrayTimestampDate($rPeriod)) // timestamp |
|
3090 | + $inputab = (isset($rPeriod['tz'])) ? $this->_timestamp2date($rPeriod, $parno) : $this->_timestamp2date($rPeriod, 6); |
|
3091 | + elseif ($this->_isArrayDate($rPeriod)) |
|
3092 | + $inputab = (3 < count($rPeriod)) ? $this->_date_time_array($rPeriod, $parno) : $this->_date_time_array($rPeriod, 6); |
|
3093 | + elseif ((1 == count($rPeriod)) && (8 <= strlen(reset($rPeriod)))) // text-date |
|
3094 | + $inputab = $this->_date_time_string(reset($rPeriod), $parno); |
|
3095 | 3095 | else // array format duration |
3096 | - $inputab = $this->_duration_array( $rPeriod ); |
|
3096 | + $inputab = $this->_duration_array($rPeriod); |
|
3097 | 3097 | } |
3098 | - elseif(( 3 <= strlen( trim( $rPeriod ))) && // string format duration |
|
3099 | - ( in_array( $rPeriod{0}, array( 'P', '+', '-' )))) { |
|
3100 | - if( 'P' != $rPeriod{0} ) |
|
3101 | - $rPeriod = substr( $rPeriod, 1 ); |
|
3102 | - $inputab = $this->_duration_string( $rPeriod ); |
|
3098 | + elseif ((3 <= strlen(trim($rPeriod))) && // string format duration |
|
3099 | + (in_array($rPeriod{0}, array('P', '+', '-')))) { |
|
3100 | + if ('P' != $rPeriod{0} ) |
|
3101 | + $rPeriod = substr($rPeriod, 1); |
|
3102 | + $inputab = $this->_duration_string($rPeriod); |
|
3103 | 3103 | } |
3104 | - elseif( 8 <= strlen( trim( $rPeriod ))) // text date ex. 2006-08-03 10:12:18 |
|
3105 | - $inputab = $this->_date_time_string( $rPeriod, $parno ); |
|
3106 | - if( isset( $input['params']['TZID'] ) || |
|
3107 | - ( isset( $inputab['tz'] ) && !$this->_isOffset( $inputab['tz'] )) || |
|
3108 | - ( isset( $inputa[0] ) && ( !isset( $inputa[0]['tz'] ))) || |
|
3109 | - ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] ))) |
|
3110 | - unset( $inputab['tz'] ); |
|
3111 | - $inputa[] = $inputab; |
|
3104 | + elseif (8 <= strlen(trim($rPeriod))) // text date ex. 2006-08-03 10:12:18 |
|
3105 | + $inputab = $this->_date_time_string($rPeriod, $parno); |
|
3106 | + if (isset($input['params']['TZID']) || |
|
3107 | + (isset($inputab['tz']) && !$this->_isOffset($inputab['tz'])) || |
|
3108 | + (isset($inputa[0]) && (!isset($inputa[0]['tz']))) || |
|
3109 | + (isset($inputa[0]['tz']) && !$this->_isOffset($inputa[0]['tz']))) |
|
3110 | + unset($inputab['tz']); |
|
3111 | + $inputa[] = $inputab; |
|
3112 | 3112 | } |
3113 | 3113 | } // PERIOD end |
3114 | - elseif ( $this->_isArrayTimestampDate( $theRdate )) // timestamp |
|
3115 | - $inputa = $this->_timestamp2date( $theRdate, $parno ); |
|
3114 | + elseif ($this->_isArrayTimestampDate($theRdate)) // timestamp |
|
3115 | + $inputa = $this->_timestamp2date($theRdate, $parno); |
|
3116 | 3116 | else // date[-time] |
3117 | - $inputa = $this->_date_time_array( $theRdate, $parno ); |
|
3117 | + $inputa = $this->_date_time_array($theRdate, $parno); |
|
3118 | 3118 | } |
3119 | - elseif( 8 <= strlen( trim( $theRdate ))) // text date ex. 2006-08-03 10:12:18 |
|
3120 | - $inputa = $this->_date_time_string( $theRdate, $parno ); |
|
3121 | - if( !isset( $input['params']['VALUE'] ) || ( 'PERIOD' != $input['params']['VALUE'] )) { // no PERIOD |
|
3122 | - if( 3 == $parno ) |
|
3123 | - unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] ); |
|
3124 | - elseif( isset( $inputa['tz'] )) |
|
3119 | + elseif (8 <= strlen(trim($theRdate))) // text date ex. 2006-08-03 10:12:18 |
|
3120 | + $inputa = $this->_date_time_string($theRdate, $parno); |
|
3121 | + if (!isset($input['params']['VALUE']) || ('PERIOD' != $input['params']['VALUE'])) { // no PERIOD |
|
3122 | + if (3 == $parno) |
|
3123 | + unset($inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz']); |
|
3124 | + elseif (isset($inputa['tz'])) |
|
3125 | 3125 | $inputa['tz'] = (string) $inputa['tz']; |
3126 | - if( isset( $input['params']['TZID'] ) || |
|
3127 | - ( isset( $inputa['tz'] ) && !$this->_isOffset( $inputa['tz'] )) || |
|
3128 | - ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) || |
|
3129 | - ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) |
|
3130 | - unset( $inputa['tz'] ); |
|
3126 | + if (isset($input['params']['TZID']) || |
|
3127 | + (isset($inputa['tz']) && !$this->_isOffset($inputa['tz'])) || |
|
3128 | + (isset($input['value'][0]) && (!isset($input['value'][0]['tz']))) || |
|
3129 | + (isset($input['value'][0]['tz']) && !$this->_isOffset($input['value'][0]['tz']))) |
|
3130 | + unset($inputa['tz']); |
|
3131 | 3131 | } |
3132 | 3132 | $input['value'][] = $inputa; |
3133 | 3133 | } |
3134 | - if( 3 == $parno ) { |
|
3134 | + if (3 == $parno) { |
|
3135 | 3135 | $input['params']['VALUE'] = 'DATE'; |
3136 | - unset( $input['params']['TZID'] ); |
|
3136 | + unset($input['params']['TZID']); |
|
3137 | 3137 | } |
3138 | - $this->_setMval( $this->rdate, $input['value'], $input['params'], FALSE, $index ); |
|
3138 | + $this->_setMval($this->rdate, $input['value'], $input['params'], FALSE, $index); |
|
3139 | 3139 | return TRUE; |
3140 | 3140 | } |
3141 | 3141 | /*********************************************************************************/ |
@@ -3150,12 +3150,12 @@ discard block |
||
3150 | 3150 | * @return string |
3151 | 3151 | */ |
3152 | 3152 | function createRecurrenceid() { |
3153 | - if( empty( $this->recurrenceid )) return FALSE; |
|
3154 | - if( empty( $this->recurrenceid['value'] )) |
|
3155 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE; |
|
3156 | - $formatted = $this->_format_date_time( $this->recurrenceid['value'] ); |
|
3157 | - $attributes = $this->_createParams( $this->recurrenceid['params'] ); |
|
3158 | - return $this->_createElement( 'RECURRENCE-ID', $attributes, $formatted ); |
|
3153 | + if (empty($this->recurrenceid)) return FALSE; |
|
3154 | + if (empty($this->recurrenceid['value'])) |
|
3155 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('RECURRENCE-ID') : FALSE; |
|
3156 | + $formatted = $this->_format_date_time($this->recurrenceid['value']); |
|
3157 | + $attributes = $this->_createParams($this->recurrenceid['params']); |
|
3158 | + return $this->_createElement('RECURRENCE-ID', $attributes, $formatted); |
|
3159 | 3159 | } |
3160 | 3160 | /** |
3161 | 3161 | * set calendar component property recurrence-id |
@@ -3171,16 +3171,16 @@ discard block |
||
3171 | 3171 | * @param array $params optional |
3172 | 3172 | * @return bool |
3173 | 3173 | */ |
3174 | - function setRecurrenceid( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) { |
|
3175 | - if( empty( $year )) { |
|
3176 | - if( $this->getConfig( 'allowEmpty' )) { |
|
3177 | - $this->recurrenceid = array( 'value' => null, 'params' => null ); |
|
3174 | + function setRecurrenceid($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE) { |
|
3175 | + if (empty($year)) { |
|
3176 | + if ($this->getConfig('allowEmpty')) { |
|
3177 | + $this->recurrenceid = array('value' => null, 'params' => null); |
|
3178 | 3178 | return TRUE; |
3179 | 3179 | } |
3180 | 3180 | else |
3181 | 3181 | return FALSE; |
3182 | 3182 | } |
3183 | - $this->recurrenceid = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
|
3183 | + $this->recurrenceid = $this->_setDate($year, $month, $day, $hour, $min, $sec, $tz, $params); |
|
3184 | 3184 | return TRUE; |
3185 | 3185 | } |
3186 | 3186 | /*********************************************************************************/ |
@@ -3195,18 +3195,18 @@ discard block |
||
3195 | 3195 | * @return string |
3196 | 3196 | */ |
3197 | 3197 | function createRelatedTo() { |
3198 | - if( empty( $this->relatedto )) return FALSE; |
|
3198 | + if (empty($this->relatedto)) return FALSE; |
|
3199 | 3199 | $output = null; |
3200 | - foreach( $this->relatedto as $relation ) { |
|
3201 | - if( empty( $relation['value'] )) { |
|
3202 | - if( $this->getConfig( 'allowEmpty' )) $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] )); |
|
3200 | + foreach ($this->relatedto as $relation) { |
|
3201 | + if (empty($relation['value'])) { |
|
3202 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('RELATED-TO', $this->_createParams($relation['params'])); |
|
3203 | 3203 | continue; |
3204 | 3204 | } |
3205 | - $attributes = $this->_createParams( $relation['params'] ); |
|
3206 | - $content = ( 'xcal' != $this->format ) ? '<' : ''; |
|
3207 | - $content .= $this->_strrep( $relation['value'] ); |
|
3208 | - $content .= ( 'xcal' != $this->format ) ? '>' : ''; |
|
3209 | - $output .= $this->_createElement( 'RELATED-TO', $attributes, $content ); |
|
3205 | + $attributes = $this->_createParams($relation['params']); |
|
3206 | + $content = ('xcal' != $this->format) ? '<' : ''; |
|
3207 | + $content .= $this->_strrep($relation['value']); |
|
3208 | + $content .= ('xcal' != $this->format) ? '>' : ''; |
|
3209 | + $output .= $this->_createElement('RELATED-TO', $attributes, $content); |
|
3210 | 3210 | } |
3211 | 3211 | return $output; |
3212 | 3212 | } |
@@ -3220,12 +3220,12 @@ discard block |
||
3220 | 3220 | * @param index $index, optional |
3221 | 3221 | * @return bool |
3222 | 3222 | */ |
3223 | - function setRelatedTo( $value, $params=FALSE, $index=FALSE ) { |
|
3224 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3225 | - if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 ))) |
|
3226 | - $value = substr( $value, 1, ( strlen( $value ) - 2 )); |
|
3227 | - $this->_existRem( $params, 'RELTYPE', 'PARENT', TRUE ); // remove default |
|
3228 | - $this->_setMval( $this->relatedto, $value, $params, FALSE, $index ); |
|
3223 | + function setRelatedTo($value, $params = FALSE, $index = FALSE) { |
|
3224 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3225 | + if (('<' == substr($value, 0, 1)) && ('>' == substr($value, -1))) |
|
3226 | + $value = substr($value, 1, (strlen($value) - 2)); |
|
3227 | + $this->_existRem($params, 'RELTYPE', 'PARENT', TRUE); // remove default |
|
3228 | + $this->_setMval($this->relatedto, $value, $params, FALSE, $index); |
|
3229 | 3229 | return TRUE; |
3230 | 3230 | } |
3231 | 3231 | /*********************************************************************************/ |
@@ -3240,11 +3240,11 @@ discard block |
||
3240 | 3240 | * @return string |
3241 | 3241 | */ |
3242 | 3242 | function createRepeat() { |
3243 | - if( empty( $this->repeat )) return FALSE; |
|
3244 | - if( empty( $this->repeat['value'] )) |
|
3245 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE; |
|
3246 | - $attributes = $this->_createParams( $this->repeat['params'] ); |
|
3247 | - return $this->_createElement( 'REPEAT', $attributes, $this->repeat['value'] ); |
|
3243 | + if (empty($this->repeat)) return FALSE; |
|
3244 | + if (empty($this->repeat['value'])) |
|
3245 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('REPEAT') : FALSE; |
|
3246 | + $attributes = $this->_createParams($this->repeat['params']); |
|
3247 | + return $this->_createElement('REPEAT', $attributes, $this->repeat['value']); |
|
3248 | 3248 | } |
3249 | 3249 | /** |
3250 | 3250 | * set calendar component property transp |
@@ -3255,9 +3255,9 @@ discard block |
||
3255 | 3255 | * @param array $params optional |
3256 | 3256 | * @return void |
3257 | 3257 | */ |
3258 | - function setRepeat( $value, $params=FALSE ) { |
|
3259 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3260 | - $this->repeat = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3258 | + function setRepeat($value, $params = FALSE) { |
|
3259 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3260 | + $this->repeat = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3261 | 3261 | return TRUE; |
3262 | 3262 | } |
3263 | 3263 | /*********************************************************************************/ |
@@ -3271,19 +3271,19 @@ discard block |
||
3271 | 3271 | * @return string |
3272 | 3272 | */ |
3273 | 3273 | function createRequestStatus() { |
3274 | - if( empty( $this->requeststatus )) return FALSE; |
|
3274 | + if (empty($this->requeststatus)) return FALSE; |
|
3275 | 3275 | $output = null; |
3276 | - foreach( $this->requeststatus as $rstat ) { |
|
3277 | - if( empty( $rstat['value']['statcode'] )) { |
|
3278 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'REQUEST-STATUS' ); |
|
3276 | + foreach ($this->requeststatus as $rstat) { |
|
3277 | + if (empty($rstat['value']['statcode'])) { |
|
3278 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('REQUEST-STATUS'); |
|
3279 | 3279 | continue; |
3280 | 3280 | } |
3281 | - $attributes = $this->_createParams( $rstat['params'], array( 'LANGUAGE' )); |
|
3282 | - $content = number_format( (float) $rstat['value']['statcode'], 2, '.', ''); |
|
3283 | - $content .= ';'.$this->_strrep( $rstat['value']['text'] ); |
|
3284 | - if( isset( $rstat['value']['extdata'] )) |
|
3285 | - $content .= ';'.$this->_strrep( $rstat['value']['extdata'] ); |
|
3286 | - $output .= $this->_createElement( 'REQUEST-STATUS', $attributes, $content ); |
|
3281 | + $attributes = $this->_createParams($rstat['params'], array('LANGUAGE')); |
|
3282 | + $content = number_format((float) $rstat['value']['statcode'], 2, '.', ''); |
|
3283 | + $content .= ';'.$this->_strrep($rstat['value']['text']); |
|
3284 | + if (isset($rstat['value']['extdata'])) |
|
3285 | + $content .= ';'.$this->_strrep($rstat['value']['extdata']); |
|
3286 | + $output .= $this->_createElement('REQUEST-STATUS', $attributes, $content); |
|
3287 | 3287 | } |
3288 | 3288 | return $output; |
3289 | 3289 | } |
@@ -3299,12 +3299,12 @@ discard block |
||
3299 | 3299 | * @param integer $index, optional |
3300 | 3300 | * @return bool |
3301 | 3301 | */ |
3302 | - function setRequestStatus( $statcode, $text, $extdata=FALSE, $params=FALSE, $index=FALSE ) { |
|
3303 | - if( empty( $statcode ) || empty( $text )) if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null; else return FALSE; |
|
3304 | - $input = array( 'statcode' => $statcode, 'text' => $text ); |
|
3305 | - if( $extdata ) |
|
3302 | + function setRequestStatus($statcode, $text, $extdata = FALSE, $params = FALSE, $index = FALSE) { |
|
3303 | + if (empty($statcode) || empty($text)) if ($this->getConfig('allowEmpty')) $statcode = $text = null; else return FALSE; |
|
3304 | + $input = array('statcode' => $statcode, 'text' => $text); |
|
3305 | + if ($extdata) |
|
3306 | 3306 | $input['extdata'] = $extdata; |
3307 | - $this->_setMval( $this->requeststatus, $input, $params, FALSE, $index ); |
|
3307 | + $this->_setMval($this->requeststatus, $input, $params, FALSE, $index); |
|
3308 | 3308 | return TRUE; |
3309 | 3309 | } |
3310 | 3310 | /*********************************************************************************/ |
@@ -3319,22 +3319,22 @@ discard block |
||
3319 | 3319 | * @return string |
3320 | 3320 | */ |
3321 | 3321 | function createResources() { |
3322 | - if( empty( $this->resources )) return FALSE; |
|
3322 | + if (empty($this->resources)) return FALSE; |
|
3323 | 3323 | $output = null; |
3324 | - foreach( $this->resources as $resource ) { |
|
3325 | - if( empty( $resource['value'] )) { |
|
3326 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RESOURCES' ); |
|
3324 | + foreach ($this->resources as $resource) { |
|
3325 | + if (empty($resource['value'])) { |
|
3326 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement('RESOURCES'); |
|
3327 | 3327 | continue; |
3328 | 3328 | } |
3329 | - $attributes = $this->_createParams( $resource['params'], array( 'ALTREP', 'LANGUAGE' )); |
|
3330 | - if( is_array( $resource['value'] )) { |
|
3331 | - foreach( $resource['value'] as $rix => $resourcePart ) |
|
3332 | - $resource['value'][$rix] = $this->_strrep( $resourcePart ); |
|
3333 | - $content = implode( ',', $resource['value'] ); |
|
3329 | + $attributes = $this->_createParams($resource['params'], array('ALTREP', 'LANGUAGE')); |
|
3330 | + if (is_array($resource['value'])) { |
|
3331 | + foreach ($resource['value'] as $rix => $resourcePart) |
|
3332 | + $resource['value'][$rix] = $this->_strrep($resourcePart); |
|
3333 | + $content = implode(',', $resource['value']); |
|
3334 | 3334 | } |
3335 | 3335 | else |
3336 | - $content = $this->_strrep( $resource['value'] ); |
|
3337 | - $output .= $this->_createElement( 'RESOURCES', $attributes, $content ); |
|
3336 | + $content = $this->_strrep($resource['value']); |
|
3337 | + $output .= $this->_createElement('RESOURCES', $attributes, $content); |
|
3338 | 3338 | } |
3339 | 3339 | return $output; |
3340 | 3340 | } |
@@ -3348,9 +3348,9 @@ discard block |
||
3348 | 3348 | * @param integer $index, optional |
3349 | 3349 | * @return bool |
3350 | 3350 | */ |
3351 | - function setResources( $value, $params=FALSE, $index=FALSE ) { |
|
3352 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3353 | - $this->_setMval( $this->resources, $value, $params, FALSE, $index ); |
|
3351 | + function setResources($value, $params = FALSE, $index = FALSE) { |
|
3352 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3353 | + $this->_setMval($this->resources, $value, $params, FALSE, $index); |
|
3354 | 3354 | return TRUE; |
3355 | 3355 | } |
3356 | 3356 | /*********************************************************************************/ |
@@ -3365,8 +3365,8 @@ discard block |
||
3365 | 3365 | * @return string |
3366 | 3366 | */ |
3367 | 3367 | function createRrule() { |
3368 | - if( empty( $this->rrule )) return FALSE; |
|
3369 | - return $this->_format_recur( 'RRULE', $this->rrule ); |
|
3368 | + if (empty($this->rrule)) return FALSE; |
|
3369 | + return $this->_format_recur('RRULE', $this->rrule); |
|
3370 | 3370 | } |
3371 | 3371 | /** |
3372 | 3372 | * set calendar component property rrule |
@@ -3378,9 +3378,9 @@ discard block |
||
3378 | 3378 | * @param integer $index, optional |
3379 | 3379 | * @return void |
3380 | 3380 | */ |
3381 | - function setRrule( $rruleset, $params=FALSE, $index=FALSE ) { |
|
3382 | - if( empty( $rruleset )) if( $this->getConfig( 'allowEmpty' )) $rruleset = null; else return FALSE; |
|
3383 | - $this->_setMval( $this->rrule, $this->_setRexrule( $rruleset ), $params, FALSE, $index ); |
|
3381 | + function setRrule($rruleset, $params = FALSE, $index = FALSE) { |
|
3382 | + if (empty($rruleset)) if ($this->getConfig('allowEmpty')) $rruleset = null; else return FALSE; |
|
3383 | + $this->_setMval($this->rrule, $this->_setRexrule($rruleset), $params, FALSE, $index); |
|
3384 | 3384 | return TRUE; |
3385 | 3385 | } |
3386 | 3386 | /*********************************************************************************/ |
@@ -3394,11 +3394,11 @@ discard block |
||
3394 | 3394 | * @return string |
3395 | 3395 | */ |
3396 | 3396 | function createSequence() { |
3397 | - if( empty( $this->sequence )) return FALSE; |
|
3398 | - if( empty( $this->sequence['value'] )) |
|
3399 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE; |
|
3400 | - $attributes = $this->_createParams( $this->sequence['params'] ); |
|
3401 | - return $this->_createElement( 'SEQUENCE', $attributes, $this->sequence['value'] ); |
|
3397 | + if (empty($this->sequence)) return FALSE; |
|
3398 | + if (empty($this->sequence['value'])) |
|
3399 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('SEQUENCE') : FALSE; |
|
3400 | + $attributes = $this->_createParams($this->sequence['params']); |
|
3401 | + return $this->_createElement('SEQUENCE', $attributes, $this->sequence['value']); |
|
3402 | 3402 | } |
3403 | 3403 | /** |
3404 | 3404 | * set calendar component property sequence |
@@ -3408,10 +3408,10 @@ discard block |
||
3408 | 3408 | * @param array $params optional |
3409 | 3409 | * @return bool |
3410 | 3410 | */ |
3411 | - function setSequence( $value=FALSE, $params=FALSE ) { |
|
3412 | - if( empty( $value )) |
|
3413 | - $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1; |
|
3414 | - $this->sequence = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3411 | + function setSequence($value = FALSE, $params = FALSE) { |
|
3412 | + if (empty($value)) |
|
3413 | + $value = (isset($this->sequence['value']) && (0 < $this->sequence['value'])) ? $this->sequence['value'] + 1 : 1; |
|
3414 | + $this->sequence = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3415 | 3415 | return TRUE; |
3416 | 3416 | } |
3417 | 3417 | /*********************************************************************************/ |
@@ -3426,11 +3426,11 @@ discard block |
||
3426 | 3426 | * @return string |
3427 | 3427 | */ |
3428 | 3428 | function createStatus() { |
3429 | - if( empty( $this->status )) return FALSE; |
|
3430 | - if( empty( $this->status['value'] )) |
|
3431 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE; |
|
3432 | - $attributes = $this->_createParams( $this->status['params'] ); |
|
3433 | - return $this->_createElement( 'STATUS', $attributes, $this->status['value'] ); |
|
3429 | + if (empty($this->status)) return FALSE; |
|
3430 | + if (empty($this->status['value'])) |
|
3431 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('STATUS') : FALSE; |
|
3432 | + $attributes = $this->_createParams($this->status['params']); |
|
3433 | + return $this->_createElement('STATUS', $attributes, $this->status['value']); |
|
3434 | 3434 | } |
3435 | 3435 | /** |
3436 | 3436 | * set calendar component property status |
@@ -3441,9 +3441,9 @@ discard block |
||
3441 | 3441 | * @param mixed $params optional (array or false) |
3442 | 3442 | * @return bool |
3443 | 3443 | */ |
3444 | - function setStatus( $value, $params=FALSE ) { |
|
3445 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3446 | - $this->status = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3444 | + function setStatus($value, $params = FALSE) { |
|
3445 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3446 | + $this->status = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3447 | 3447 | return TRUE; |
3448 | 3448 | } |
3449 | 3449 | /*********************************************************************************/ |
@@ -3458,12 +3458,12 @@ discard block |
||
3458 | 3458 | * @return string |
3459 | 3459 | */ |
3460 | 3460 | function createSummary() { |
3461 | - if( empty( $this->summary )) return FALSE; |
|
3462 | - if( empty( $this->summary['value'] )) |
|
3463 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE; |
|
3464 | - $attributes = $this->_createParams( $this->summary['params'], array( 'ALTREP', 'LANGUAGE' )); |
|
3465 | - $content = $this->_strrep( $this->summary['value'] ); |
|
3466 | - return $this->_createElement( 'SUMMARY', $attributes, $content ); |
|
3461 | + if (empty($this->summary)) return FALSE; |
|
3462 | + if (empty($this->summary['value'])) |
|
3463 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('SUMMARY') : FALSE; |
|
3464 | + $attributes = $this->_createParams($this->summary['params'], array('ALTREP', 'LANGUAGE')); |
|
3465 | + $content = $this->_strrep($this->summary['value']); |
|
3466 | + return $this->_createElement('SUMMARY', $attributes, $content); |
|
3467 | 3467 | } |
3468 | 3468 | /** |
3469 | 3469 | * set calendar component property summary |
@@ -3474,9 +3474,9 @@ discard block |
||
3474 | 3474 | * @param string $params optional |
3475 | 3475 | * @return bool |
3476 | 3476 | */ |
3477 | - function setSummary( $value, $params=FALSE ) { |
|
3478 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3479 | - $this->summary = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3477 | + function setSummary($value, $params = FALSE) { |
|
3478 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3479 | + $this->summary = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3480 | 3480 | return TRUE; |
3481 | 3481 | } |
3482 | 3482 | /*********************************************************************************/ |
@@ -3491,11 +3491,11 @@ discard block |
||
3491 | 3491 | * @return string |
3492 | 3492 | */ |
3493 | 3493 | function createTransp() { |
3494 | - if( empty( $this->transp )) return FALSE; |
|
3495 | - if( empty( $this->transp['value'] )) |
|
3496 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE; |
|
3497 | - $attributes = $this->_createParams( $this->transp['params'] ); |
|
3498 | - return $this->_createElement( 'TRANSP', $attributes, $this->transp['value'] ); |
|
3494 | + if (empty($this->transp)) return FALSE; |
|
3495 | + if (empty($this->transp['value'])) |
|
3496 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('TRANSP') : FALSE; |
|
3497 | + $attributes = $this->_createParams($this->transp['params']); |
|
3498 | + return $this->_createElement('TRANSP', $attributes, $this->transp['value']); |
|
3499 | 3499 | } |
3500 | 3500 | /** |
3501 | 3501 | * set calendar component property transp |
@@ -3506,9 +3506,9 @@ discard block |
||
3506 | 3506 | * @param string $params optional |
3507 | 3507 | * @return bool |
3508 | 3508 | */ |
3509 | - function setTransp( $value, $params=FALSE ) { |
|
3510 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3511 | - $this->transp = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3509 | + function setTransp($value, $params = FALSE) { |
|
3510 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3511 | + $this->transp = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3512 | 3512 | return TRUE; |
3513 | 3513 | } |
3514 | 3514 | /*********************************************************************************/ |
@@ -3523,23 +3523,23 @@ discard block |
||
3523 | 3523 | * @return string |
3524 | 3524 | */ |
3525 | 3525 | function createTrigger() { |
3526 | - if( empty( $this->trigger )) return FALSE; |
|
3527 | - if( empty( $this->trigger['value'] )) |
|
3528 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE; |
|
3526 | + if (empty($this->trigger)) return FALSE; |
|
3527 | + if (empty($this->trigger['value'])) |
|
3528 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('TRIGGER') : FALSE; |
|
3529 | 3529 | $content = $attributes = null; |
3530 | - if( isset( $this->trigger['value']['year'] ) && |
|
3531 | - isset( $this->trigger['value']['month'] ) && |
|
3532 | - isset( $this->trigger['value']['day'] )) |
|
3533 | - $content .= $this->_format_date_time( $this->trigger['value'] ); |
|
3530 | + if (isset($this->trigger['value']['year']) && |
|
3531 | + isset($this->trigger['value']['month']) && |
|
3532 | + isset($this->trigger['value']['day'])) |
|
3533 | + $content .= $this->_format_date_time($this->trigger['value']); |
|
3534 | 3534 | else { |
3535 | - if( TRUE !== $this->trigger['value']['relatedStart'] ) |
|
3535 | + if (TRUE !== $this->trigger['value']['relatedStart']) |
|
3536 | 3536 | $attributes .= $this->intAttrDelimiter.'RELATED=END'; |
3537 | - if( $this->trigger['value']['before'] ) |
|
3537 | + if ($this->trigger['value']['before']) |
|
3538 | 3538 | $content .= '-'; |
3539 | - $content .= $this->_format_duration( $this->trigger['value'] ); |
|
3539 | + $content .= $this->_format_duration($this->trigger['value']); |
|
3540 | 3540 | } |
3541 | - $attributes .= $this->_createParams( $this->trigger['params'] ); |
|
3542 | - return $this->_createElement( 'TRIGGER', $attributes, $content ); |
|
3541 | + $attributes .= $this->_createParams($this->trigger['params']); |
|
3542 | + return $this->_createElement('TRIGGER', $attributes, $content); |
|
3543 | 3543 | } |
3544 | 3544 | /** |
3545 | 3545 | * set calendar component property trigger |
@@ -3558,86 +3558,86 @@ discard block |
||
3558 | 3558 | * @param array $params optional |
3559 | 3559 | * @return bool |
3560 | 3560 | */ |
3561 | - function setTrigger( $year, $month=null, $day=null, $week=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $relatedStart=TRUE, $before=TRUE, $params=FALSE ) { |
|
3562 | - if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec )) |
|
3563 | - if( $this->getConfig( 'allowEmpty' )) { |
|
3564 | - $this->trigger = array( 'value' => null, 'params' => $this->_setParams( $params ) ); |
|
3561 | + function setTrigger($year, $month = null, $day = null, $week = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $relatedStart = TRUE, $before = TRUE, $params = FALSE) { |
|
3562 | + if (empty($year) && empty($month) && empty($day) && empty($week) && empty($hour) && empty($min) && empty($sec)) |
|
3563 | + if ($this->getConfig('allowEmpty')) { |
|
3564 | + $this->trigger = array('value' => null, 'params' => $this->_setParams($params)); |
|
3565 | 3565 | return TRUE; |
3566 | 3566 | } |
3567 | 3567 | else |
3568 | 3568 | return FALSE; |
3569 | - if( $this->_isArrayTimestampDate( $year )) { // timestamp |
|
3570 | - $params = $this->_setParams( $month ); |
|
3571 | - $date = $this->_timestamp2date( $year, 7 ); |
|
3572 | - foreach( $date as $k => $v ) |
|
3569 | + if ($this->_isArrayTimestampDate($year)) { // timestamp |
|
3570 | + $params = $this->_setParams($month); |
|
3571 | + $date = $this->_timestamp2date($year, 7); |
|
3572 | + foreach ($date as $k => $v) |
|
3573 | 3573 | $$k = $v; |
3574 | 3574 | } |
3575 | - elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) { |
|
3576 | - $params = $this->_setParams( $month ); |
|
3577 | - if(!(array_key_exists( 'year', $year ) && // exclude date-time |
|
3578 | - array_key_exists( 'month', $year ) && |
|
3579 | - array_key_exists( 'day', $year ))) { // so this must be a duration |
|
3580 | - if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) |
|
3575 | + elseif (is_array($year) && (is_array($month) || empty($month))) { |
|
3576 | + $params = $this->_setParams($month); |
|
3577 | + if (!(array_key_exists('year', $year) && // exclude date-time |
|
3578 | + array_key_exists('month', $year) && |
|
3579 | + array_key_exists('day', $year))) { // so this must be a duration |
|
3580 | + if (isset($params['RELATED']) && ('END' == $params['RELATED'])) |
|
3581 | 3581 | $relatedStart = FALSE; |
3582 | 3582 | else |
3583 | - $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE; |
|
3584 | - $before = ( array_key_exists( 'before', $year ) && ( TRUE !== $year['before'] )) ? FALSE : TRUE; |
|
3583 | + $relatedStart = (array_key_exists('relatedStart', $year) && (TRUE !== $year['relatedStart'])) ? FALSE : TRUE; |
|
3584 | + $before = (array_key_exists('before', $year) && (TRUE !== $year['before'])) ? FALSE : TRUE; |
|
3585 | 3585 | } |
3586 | - $SSYY = ( array_key_exists( 'year', $year )) ? $year['year'] : null; |
|
3587 | - $month = ( array_key_exists( 'month', $year )) ? $year['month'] : null; |
|
3588 | - $day = ( array_key_exists( 'day', $year )) ? $year['day'] : null; |
|
3589 | - $week = ( array_key_exists( 'week', $year )) ? $year['week'] : null; |
|
3590 | - $hour = ( array_key_exists( 'hour', $year )) ? $year['hour'] : 0; //null; |
|
3591 | - $min = ( array_key_exists( 'min', $year )) ? $year['min'] : 0; //null; |
|
3592 | - $sec = ( array_key_exists( 'sec', $year )) ? $year['sec'] : 0; //null; |
|
3586 | + $SSYY = (array_key_exists('year', $year)) ? $year['year'] : null; |
|
3587 | + $month = (array_key_exists('month', $year)) ? $year['month'] : null; |
|
3588 | + $day = (array_key_exists('day', $year)) ? $year['day'] : null; |
|
3589 | + $week = (array_key_exists('week', $year)) ? $year['week'] : null; |
|
3590 | + $hour = (array_key_exists('hour', $year)) ? $year['hour'] : 0; //null; |
|
3591 | + $min = (array_key_exists('min', $year)) ? $year['min'] : 0; //null; |
|
3592 | + $sec = (array_key_exists('sec', $year)) ? $year['sec'] : 0; //null; |
|
3593 | 3593 | $year = $SSYY; |
3594 | 3594 | } |
3595 | - elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) { // duration or date in a string |
|
3596 | - $params = $this->_setParams( $month ); |
|
3597 | - if( in_array( $year{0}, array( 'P', '+', '-' ))) { // duration |
|
3598 | - $relatedStart = ( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) ? FALSE : TRUE; |
|
3599 | - $before = ( '-' == $year{0} ) ? TRUE : FALSE; |
|
3600 | - if( 'P' != $year{0} ) |
|
3601 | - $year = substr( $year, 1 ); |
|
3602 | - $date = $this->_duration_string( $year); |
|
3595 | + elseif (is_string($year) && (is_array($month) || empty($month))) { // duration or date in a string |
|
3596 | + $params = $this->_setParams($month); |
|
3597 | + if (in_array($year{0}, array('P', '+', '-'))) { // duration |
|
3598 | + $relatedStart = (isset($params['RELATED']) && ('END' == $params['RELATED'])) ? FALSE : TRUE; |
|
3599 | + $before = ('-' == $year{0} ) ? TRUE : FALSE; |
|
3600 | + if ('P' != $year{0} ) |
|
3601 | + $year = substr($year, 1); |
|
3602 | + $date = $this->_duration_string($year); |
|
3603 | 3603 | } |
3604 | 3604 | else // date |
3605 | - $date = $this->_date_time_string( $year, 7 ); |
|
3606 | - unset( $year, $month, $day ); |
|
3607 | - foreach( $date as $k => $v ) |
|
3605 | + $date = $this->_date_time_string($year, 7); |
|
3606 | + unset($year, $month, $day); |
|
3607 | + foreach ($date as $k => $v) |
|
3608 | 3608 | $$k = $v; |
3609 | 3609 | } |
3610 | 3610 | else // single values in function input parameters |
3611 | - $params = $this->_setParams( $params ); |
|
3612 | - if( !empty( $year ) && !empty( $month ) && !empty( $day )) { // date |
|
3611 | + $params = $this->_setParams($params); |
|
3612 | + if (!empty($year) && !empty($month) && !empty($day)) { // date |
|
3613 | 3613 | $params['VALUE'] = 'DATE-TIME'; |
3614 | - $hour = ( $hour ) ? $hour : 0; |
|
3615 | - $min = ( $min ) ? $min : 0; |
|
3616 | - $sec = ( $sec ) ? $sec : 0; |
|
3617 | - $this->trigger = array( 'params' => $params ); |
|
3618 | - $this->trigger['value'] = array( 'year' => $year |
|
3614 | + $hour = ($hour) ? $hour : 0; |
|
3615 | + $min = ($min) ? $min : 0; |
|
3616 | + $sec = ($sec) ? $sec : 0; |
|
3617 | + $this->trigger = array('params' => $params); |
|
3618 | + $this->trigger['value'] = array('year' => $year |
|
3619 | 3619 | , 'month' => $month |
3620 | 3620 | , 'day' => $day |
3621 | 3621 | , 'hour' => $hour |
3622 | 3622 | , 'min' => $min |
3623 | 3623 | , 'sec' => $sec |
3624 | - , 'tz' => 'Z' ); |
|
3624 | + , 'tz' => 'Z'); |
|
3625 | 3625 | return TRUE; |
3626 | 3626 | } |
3627 | - elseif(( empty( $year ) && empty( $month )) && // duration |
|
3628 | - (!empty( $week ) || !empty( $day ) || !empty( $hour ) || !empty( $min ) || !empty( $sec ))) { |
|
3629 | - unset( $params['RELATED'] ); // set at output creation (END only) |
|
3630 | - unset( $params['VALUE'] ); // 'DURATION' default |
|
3631 | - $this->trigger = array( 'params' => $params ); |
|
3632 | - $relatedStart = ( FALSE !== $relatedStart ) ? TRUE : FALSE; |
|
3633 | - $before = ( FALSE !== $before ) ? TRUE : FALSE; |
|
3634 | - $this->trigger['value'] = array( 'relatedStart' => $relatedStart |
|
3635 | - , 'before' => $before ); |
|
3636 | - if( !empty( $week )) $this->trigger['value']['week'] = $week; |
|
3637 | - if( !empty( $day )) $this->trigger['value']['day'] = $day; |
|
3638 | - if( !empty( $hour )) $this->trigger['value']['hour'] = $hour; |
|
3639 | - if( !empty( $min )) $this->trigger['value']['min'] = $min; |
|
3640 | - if( !empty( $sec )) $this->trigger['value']['sec'] = $sec; |
|
3627 | + elseif ((empty($year) && empty($month)) && // duration |
|
3628 | + (!empty($week) || !empty($day) || !empty($hour) || !empty($min) || !empty($sec))) { |
|
3629 | + unset($params['RELATED']); // set at output creation (END only) |
|
3630 | + unset($params['VALUE']); // 'DURATION' default |
|
3631 | + $this->trigger = array('params' => $params); |
|
3632 | + $relatedStart = (FALSE !== $relatedStart) ? TRUE : FALSE; |
|
3633 | + $before = (FALSE !== $before) ? TRUE : FALSE; |
|
3634 | + $this->trigger['value'] = array('relatedStart' => $relatedStart |
|
3635 | + , 'before' => $before); |
|
3636 | + if (!empty($week)) $this->trigger['value']['week'] = $week; |
|
3637 | + if (!empty($day)) $this->trigger['value']['day'] = $day; |
|
3638 | + if (!empty($hour)) $this->trigger['value']['hour'] = $hour; |
|
3639 | + if (!empty($min)) $this->trigger['value']['min'] = $min; |
|
3640 | + if (!empty($sec)) $this->trigger['value']['sec'] = $sec; |
|
3641 | 3641 | return TRUE; |
3642 | 3642 | } |
3643 | 3643 | return FALSE; |
@@ -3654,11 +3654,11 @@ discard block |
||
3654 | 3654 | * @return string |
3655 | 3655 | */ |
3656 | 3656 | function createTzid() { |
3657 | - if( empty( $this->tzid )) return FALSE; |
|
3658 | - if( empty( $this->tzid['value'] )) |
|
3659 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE; |
|
3660 | - $attributes = $this->_createParams( $this->tzid['params'] ); |
|
3661 | - return $this->_createElement( 'TZID', $attributes, $this->_strrep( $this->tzid['value'] )); |
|
3657 | + if (empty($this->tzid)) return FALSE; |
|
3658 | + if (empty($this->tzid['value'])) |
|
3659 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('TZID') : FALSE; |
|
3660 | + $attributes = $this->_createParams($this->tzid['params']); |
|
3661 | + return $this->_createElement('TZID', $attributes, $this->_strrep($this->tzid['value'])); |
|
3662 | 3662 | } |
3663 | 3663 | /** |
3664 | 3664 | * set calendar component property tzid |
@@ -3669,9 +3669,9 @@ discard block |
||
3669 | 3669 | * @param array $params optional |
3670 | 3670 | * @return bool |
3671 | 3671 | */ |
3672 | - function setTzid( $value, $params=FALSE ) { |
|
3673 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3674 | - $this->tzid = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3672 | + function setTzid($value, $params = FALSE) { |
|
3673 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3674 | + $this->tzid = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3675 | 3675 | return TRUE; |
3676 | 3676 | } |
3677 | 3677 | /*********************************************************************************/ |
@@ -3687,14 +3687,14 @@ discard block |
||
3687 | 3687 | * @return string |
3688 | 3688 | */ |
3689 | 3689 | function createTzname() { |
3690 | - if( empty( $this->tzname )) return FALSE; |
|
3690 | + if (empty($this->tzname)) return FALSE; |
|
3691 | 3691 | $output = null; |
3692 | - foreach( $this->tzname as $theName ) { |
|
3693 | - if( !empty( $theName['value'] )) { |
|
3694 | - $attributes = $this->_createParams( $theName['params'], array( 'LANGUAGE' )); |
|
3695 | - $output .= $this->_createElement( 'TZNAME', $attributes, $this->_strrep( $theName['value'] )); |
|
3692 | + foreach ($this->tzname as $theName) { |
|
3693 | + if (!empty($theName['value'])) { |
|
3694 | + $attributes = $this->_createParams($theName['params'], array('LANGUAGE')); |
|
3695 | + $output .= $this->_createElement('TZNAME', $attributes, $this->_strrep($theName['value'])); |
|
3696 | 3696 | } |
3697 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'TZNAME' ); |
|
3697 | + elseif ($this->getConfig('allowEmpty')) $output .= $this->_createElement('TZNAME'); |
|
3698 | 3698 | } |
3699 | 3699 | return $output; |
3700 | 3700 | } |
@@ -3708,9 +3708,9 @@ discard block |
||
3708 | 3708 | * @param integer $index, optional |
3709 | 3709 | * @return bool |
3710 | 3710 | */ |
3711 | - function setTzname( $value, $params=FALSE, $index=FALSE ) { |
|
3712 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3713 | - $this->_setMval( $this->tzname, $value, $params, FALSE, $index ); |
|
3711 | + function setTzname($value, $params = FALSE, $index = FALSE) { |
|
3712 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3713 | + $this->_setMval($this->tzname, $value, $params, FALSE, $index); |
|
3714 | 3714 | return TRUE; |
3715 | 3715 | } |
3716 | 3716 | /*********************************************************************************/ |
@@ -3725,11 +3725,11 @@ discard block |
||
3725 | 3725 | * @return string |
3726 | 3726 | */ |
3727 | 3727 | function createTzoffsetfrom() { |
3728 | - if( empty( $this->tzoffsetfrom )) return FALSE; |
|
3729 | - if( empty( $this->tzoffsetfrom['value'] )) |
|
3730 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE; |
|
3731 | - $attributes = $this->_createParams( $this->tzoffsetfrom['params'] ); |
|
3732 | - return $this->_createElement( 'TZOFFSETFROM', $attributes, $this->tzoffsetfrom['value'] ); |
|
3728 | + if (empty($this->tzoffsetfrom)) return FALSE; |
|
3729 | + if (empty($this->tzoffsetfrom['value'])) |
|
3730 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('TZOFFSETFROM') : FALSE; |
|
3731 | + $attributes = $this->_createParams($this->tzoffsetfrom['params']); |
|
3732 | + return $this->_createElement('TZOFFSETFROM', $attributes, $this->tzoffsetfrom['value']); |
|
3733 | 3733 | } |
3734 | 3734 | /** |
3735 | 3735 | * set calendar component property tzoffsetfrom |
@@ -3740,9 +3740,9 @@ discard block |
||
3740 | 3740 | * @param string $params optional |
3741 | 3741 | * @return bool |
3742 | 3742 | */ |
3743 | - function setTzoffsetfrom( $value, $params=FALSE ) { |
|
3744 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3745 | - $this->tzoffsetfrom = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3743 | + function setTzoffsetfrom($value, $params = FALSE) { |
|
3744 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3745 | + $this->tzoffsetfrom = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3746 | 3746 | return TRUE; |
3747 | 3747 | } |
3748 | 3748 | /*********************************************************************************/ |
@@ -3757,11 +3757,11 @@ discard block |
||
3757 | 3757 | * @return string |
3758 | 3758 | */ |
3759 | 3759 | function createTzoffsetto() { |
3760 | - if( empty( $this->tzoffsetto )) return FALSE; |
|
3761 | - if( empty( $this->tzoffsetto['value'] )) |
|
3762 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE; |
|
3763 | - $attributes = $this->_createParams( $this->tzoffsetto['params'] ); |
|
3764 | - return $this->_createElement( 'TZOFFSETTO', $attributes, $this->tzoffsetto['value'] ); |
|
3760 | + if (empty($this->tzoffsetto)) return FALSE; |
|
3761 | + if (empty($this->tzoffsetto['value'])) |
|
3762 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('TZOFFSETTO') : FALSE; |
|
3763 | + $attributes = $this->_createParams($this->tzoffsetto['params']); |
|
3764 | + return $this->_createElement('TZOFFSETTO', $attributes, $this->tzoffsetto['value']); |
|
3765 | 3765 | } |
3766 | 3766 | /** |
3767 | 3767 | * set calendar component property tzoffsetto |
@@ -3772,9 +3772,9 @@ discard block |
||
3772 | 3772 | * @param string $params optional |
3773 | 3773 | * @return bool |
3774 | 3774 | */ |
3775 | - function setTzoffsetto( $value, $params=FALSE ) { |
|
3776 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3777 | - $this->tzoffsetto = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3775 | + function setTzoffsetto($value, $params = FALSE) { |
|
3776 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3777 | + $this->tzoffsetto = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3778 | 3778 | return TRUE; |
3779 | 3779 | } |
3780 | 3780 | /*********************************************************************************/ |
@@ -3789,11 +3789,11 @@ discard block |
||
3789 | 3789 | * @return string |
3790 | 3790 | */ |
3791 | 3791 | function createTzurl() { |
3792 | - if( empty( $this->tzurl )) return FALSE; |
|
3793 | - if( empty( $this->tzurl['value'] )) |
|
3794 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE; |
|
3795 | - $attributes = $this->_createParams( $this->tzurl['params'] ); |
|
3796 | - return $this->_createElement( 'TZURL', $attributes, $this->tzurl['value'] ); |
|
3792 | + if (empty($this->tzurl)) return FALSE; |
|
3793 | + if (empty($this->tzurl['value'])) |
|
3794 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('TZURL') : FALSE; |
|
3795 | + $attributes = $this->_createParams($this->tzurl['params']); |
|
3796 | + return $this->_createElement('TZURL', $attributes, $this->tzurl['value']); |
|
3797 | 3797 | } |
3798 | 3798 | /** |
3799 | 3799 | * set calendar component property tzurl |
@@ -3804,9 +3804,9 @@ discard block |
||
3804 | 3804 | * @param string $params optional |
3805 | 3805 | * @return boll |
3806 | 3806 | */ |
3807 | - function setTzurl( $value, $params=FALSE ) { |
|
3808 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3809 | - $this->tzurl = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3807 | + function setTzurl($value, $params = FALSE) { |
|
3808 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3809 | + $this->tzurl = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3810 | 3810 | return TRUE; |
3811 | 3811 | } |
3812 | 3812 | /*********************************************************************************/ |
@@ -3821,10 +3821,10 @@ discard block |
||
3821 | 3821 | * @return string |
3822 | 3822 | */ |
3823 | 3823 | function createUid() { |
3824 | - if( 0 >= count( $this->uid )) |
|
3824 | + if (0 >= count($this->uid)) |
|
3825 | 3825 | $this->_makeuid(); |
3826 | - $attributes = $this->_createParams( $this->uid['params'] ); |
|
3827 | - return $this->_createElement( 'UID', $attributes, $this->uid['value'] ); |
|
3826 | + $attributes = $this->_createParams($this->uid['params']); |
|
3827 | + return $this->_createElement('UID', $attributes, $this->uid['value']); |
|
3828 | 3828 | } |
3829 | 3829 | /** |
3830 | 3830 | * create an unique id for this calendar component object instance |
@@ -3838,13 +3838,13 @@ discard block |
||
3838 | 3838 | $unique = substr(microtime(), 2, 4); |
3839 | 3839 | $base = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPrRsStTuUvVxXuUvVwWzZ1234567890'; |
3840 | 3840 | $start = 0; |
3841 | - $end = strlen( $base ) - 1; |
|
3841 | + $end = strlen($base) - 1; |
|
3842 | 3842 | $length = 6; |
3843 | 3843 | $str = null; |
3844 | - for( $p = 0; $p < $length; $p++ ) |
|
3845 | - $unique .= $base{mt_rand( $start, $end )}; |
|
3846 | - $this->uid = array( 'params' => null ); |
|
3847 | - $this->uid['value'] = $date.'-'.$unique.'@'.$this->getConfig( 'unique_id' ); |
|
3844 | + for ($p = 0; $p < $length; $p++) |
|
3845 | + $unique .= $base{mt_rand($start, $end)}; |
|
3846 | + $this->uid = array('params' => null); |
|
3847 | + $this->uid['value'] = $date.'-'.$unique.'@'.$this->getConfig('unique_id'); |
|
3848 | 3848 | } |
3849 | 3849 | /** |
3850 | 3850 | * set calendar component property uid |
@@ -3855,9 +3855,9 @@ discard block |
||
3855 | 3855 | * @param string $params optional |
3856 | 3856 | * @return bool |
3857 | 3857 | */ |
3858 | - function setUid( $value, $params=FALSE ) { |
|
3859 | - if( empty( $value )) return FALSE; // no allowEmpty check here !!!! |
|
3860 | - $this->uid = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3858 | + function setUid($value, $params = FALSE) { |
|
3859 | + if (empty($value)) return FALSE; // no allowEmpty check here !!!! |
|
3860 | + $this->uid = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3861 | 3861 | return TRUE; |
3862 | 3862 | } |
3863 | 3863 | /*********************************************************************************/ |
@@ -3872,11 +3872,11 @@ discard block |
||
3872 | 3872 | * @return string |
3873 | 3873 | */ |
3874 | 3874 | function createUrl() { |
3875 | - if( empty( $this->url )) return FALSE; |
|
3876 | - if( empty( $this->url['value'] )) |
|
3877 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE; |
|
3878 | - $attributes = $this->_createParams( $this->url['params'] ); |
|
3879 | - return $this->_createElement( 'URL', $attributes, $this->url['value'] ); |
|
3875 | + if (empty($this->url)) return FALSE; |
|
3876 | + if (empty($this->url['value'])) |
|
3877 | + return ($this->getConfig('allowEmpty')) ? $this->_createElement('URL') : FALSE; |
|
3878 | + $attributes = $this->_createParams($this->url['params']); |
|
3879 | + return $this->_createElement('URL', $attributes, $this->url['value']); |
|
3880 | 3880 | } |
3881 | 3881 | /** |
3882 | 3882 | * set calendar component property url |
@@ -3887,9 +3887,9 @@ discard block |
||
3887 | 3887 | * @param string $params optional |
3888 | 3888 | * @return bool |
3889 | 3889 | */ |
3890 | - function setUrl( $value, $params=FALSE ) { |
|
3891 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3892 | - $this->url = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
|
3890 | + function setUrl($value, $params = FALSE) { |
|
3891 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3892 | + $this->url = array('value' => $value, 'params' => $this->_setParams($params)); |
|
3893 | 3893 | return TRUE; |
3894 | 3894 | } |
3895 | 3895 | /*********************************************************************************/ |
@@ -3904,22 +3904,22 @@ discard block |
||
3904 | 3904 | * @return string |
3905 | 3905 | */ |
3906 | 3906 | function createXprop() { |
3907 | - if( empty( $this->xprop )) return FALSE; |
|
3907 | + if (empty($this->xprop)) return FALSE; |
|
3908 | 3908 | $output = null; |
3909 | - foreach( $this->xprop as $label => $xpropPart ) { |
|
3910 | - if( empty( $xpropPart['value'] )) { |
|
3911 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $label ); |
|
3909 | + foreach ($this->xprop as $label => $xpropPart) { |
|
3910 | + if (empty($xpropPart['value'])) { |
|
3911 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement($label); |
|
3912 | 3912 | continue; |
3913 | 3913 | } |
3914 | - $attributes = $this->_createParams( $xpropPart['params'], array( 'LANGUAGE' )); |
|
3915 | - if( is_array( $xpropPart['value'] )) { |
|
3916 | - foreach( $xpropPart['value'] as $pix => $theXpart ) |
|
3917 | - $xpropPart['value'][$pix] = $this->_strrep( $theXpart ); |
|
3918 | - $xpropPart['value'] = implode( ',', $xpropPart['value'] ); |
|
3914 | + $attributes = $this->_createParams($xpropPart['params'], array('LANGUAGE')); |
|
3915 | + if (is_array($xpropPart['value'])) { |
|
3916 | + foreach ($xpropPart['value'] as $pix => $theXpart) |
|
3917 | + $xpropPart['value'][$pix] = $this->_strrep($theXpart); |
|
3918 | + $xpropPart['value'] = implode(',', $xpropPart['value']); |
|
3919 | 3919 | } |
3920 | 3920 | else |
3921 | - $xpropPart['value'] = $this->_strrep( $xpropPart['value'] ); |
|
3922 | - $output .= $this->_createElement( $label, $attributes, $xpropPart['value'] ); |
|
3921 | + $xpropPart['value'] = $this->_strrep($xpropPart['value']); |
|
3922 | + $output .= $this->_createElement($label, $attributes, $xpropPart['value']); |
|
3923 | 3923 | } |
3924 | 3924 | return $output; |
3925 | 3925 | } |
@@ -3933,14 +3933,14 @@ discard block |
||
3933 | 3933 | * @param array $params optional |
3934 | 3934 | * @return bool |
3935 | 3935 | */ |
3936 | - function setXprop( $label, $value, $params=FALSE ) { |
|
3937 | - if( empty( $label )) return; |
|
3938 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3939 | - $xprop = array( 'value' => $value ); |
|
3936 | + function setXprop($label, $value, $params = FALSE) { |
|
3937 | + if (empty($label)) return; |
|
3938 | + if (empty($value)) if ($this->getConfig('allowEmpty')) $value = null; else return FALSE; |
|
3939 | + $xprop = array('value' => $value); |
|
3940 | 3940 | $toolbox = new calendarComponent(); |
3941 | - $xprop['params'] = $toolbox->_setParams( $params ); |
|
3942 | - if( !is_array( $this->xprop )) $this->xprop = array(); |
|
3943 | - $this->xprop[strtoupper( $label )] = $xprop; |
|
3941 | + $xprop['params'] = $toolbox->_setParams($params); |
|
3942 | + if (!is_array($this->xprop)) $this->xprop = array(); |
|
3943 | + $this->xprop[strtoupper($label)] = $xprop; |
|
3944 | 3944 | return TRUE; |
3945 | 3945 | } |
3946 | 3946 | /*********************************************************************************/ |
@@ -3953,11 +3953,11 @@ discard block |
||
3953 | 3953 | * @return string |
3954 | 3954 | */ |
3955 | 3955 | function _createFormat() { |
3956 | - $objectname = null; |
|
3957 | - switch( $this->format ) { |
|
3956 | + $objectname = null; |
|
3957 | + switch ($this->format) { |
|
3958 | 3958 | case 'xcal': |
3959 | - $objectname = ( isset( $this->timezonetype )) ? |
|
3960 | - strtolower( $this->timezonetype ) : strtolower( $this->objName ); |
|
3959 | + $objectname = (isset($this->timezonetype)) ? |
|
3960 | + strtolower($this->timezonetype) : strtolower($this->objName); |
|
3961 | 3961 | $this->componentStart1 = $this->elementStart1 = '<'; |
3962 | 3962 | $this->componentStart2 = $this->elementStart2 = '>'; |
3963 | 3963 | $this->componentEnd1 = $this->elementEnd1 = '</'; |
@@ -3967,8 +3967,8 @@ discard block |
||
3967 | 3967 | $this->valueInit = null; |
3968 | 3968 | break; |
3969 | 3969 | default: |
3970 | - $objectname = ( isset( $this->timezonetype )) ? |
|
3971 | - strtoupper( $this->timezonetype ) : strtoupper( $this->objName ); |
|
3970 | + $objectname = (isset($this->timezonetype)) ? |
|
3971 | + strtoupper($this->timezonetype) : strtoupper($this->objName); |
|
3972 | 3972 | $this->componentStart1 = 'BEGIN:'; |
3973 | 3973 | $this->componentStart2 = null; |
3974 | 3974 | $this->componentEnd1 = 'END:'; |
@@ -3994,82 +3994,82 @@ discard block |
||
3994 | 3994 | * @param string $content property content (optional) |
3995 | 3995 | * @return string |
3996 | 3996 | */ |
3997 | - function _createElement( $label, $attributes=null, $content=FALSE ) { |
|
3998 | - $label = $this->_formatPropertyName( $label ); |
|
3997 | + function _createElement($label, $attributes = null, $content = FALSE) { |
|
3998 | + $label = $this->_formatPropertyName($label); |
|
3999 | 3999 | $output = $this->elementStart1.$label; |
4000 | 4000 | $categoriesAttrLang = null; |
4001 | 4001 | $attachInlineBinary = FALSE; |
4002 | 4002 | $attachfmttype = null; |
4003 | - if( !empty( $attributes )) { |
|
4004 | - $attributes = trim( $attributes ); |
|
4005 | - if ( 'xcal' == $this->format) { |
|
4006 | - $attributes2 = explode( $this->intAttrDelimiter, $attributes ); |
|
4003 | + if (!empty($attributes)) { |
|
4004 | + $attributes = trim($attributes); |
|
4005 | + if ('xcal' == $this->format) { |
|
4006 | + $attributes2 = explode($this->intAttrDelimiter, $attributes); |
|
4007 | 4007 | $attributes = null; |
4008 | - foreach( $attributes2 as $attribute ) { |
|
4009 | - $attrKVarr = explode( '=', $attribute ); |
|
4010 | - if( empty( $attrKVarr[0] )) |
|
4008 | + foreach ($attributes2 as $attribute) { |
|
4009 | + $attrKVarr = explode('=', $attribute); |
|
4010 | + if (empty($attrKVarr[0])) |
|
4011 | 4011 | continue; |
4012 | - if( !isset( $attrKVarr[1] )) { |
|
4012 | + if (!isset($attrKVarr[1])) { |
|
4013 | 4013 | $attrValue = $attrKVarr[0]; |
4014 | 4014 | $attrKey = null; |
4015 | 4015 | } |
4016 | - elseif( 2 == count( $attrKVarr)) { |
|
4017 | - $attrKey = strtolower( $attrKVarr[0] ); |
|
4016 | + elseif (2 == count($attrKVarr)) { |
|
4017 | + $attrKey = strtolower($attrKVarr[0]); |
|
4018 | 4018 | $attrValue = $attrKVarr[1]; |
4019 | 4019 | } |
4020 | 4020 | else { |
4021 | - $attrKey = strtolower( $attrKVarr[0] ); |
|
4022 | - unset( $attrKVarr[0] ); |
|
4023 | - $attrValue = implode( '=', $attrKVarr ); |
|
4021 | + $attrKey = strtolower($attrKVarr[0]); |
|
4022 | + unset($attrKVarr[0]); |
|
4023 | + $attrValue = implode('=', $attrKVarr); |
|
4024 | 4024 | } |
4025 | - if(( 'attach' == $label ) && ( in_array( $attrKey, array( 'fmttype', 'encoding', 'value' )))) { |
|
4025 | + if (('attach' == $label) && (in_array($attrKey, array('fmttype', 'encoding', 'value')))) { |
|
4026 | 4026 | $attachInlineBinary = TRUE; |
4027 | - if( 'fmttype' == $attrKey ) |
|
4027 | + if ('fmttype' == $attrKey) |
|
4028 | 4028 | $attachfmttype = $attrKey.'='.$attrValue; |
4029 | 4029 | continue; |
4030 | 4030 | } |
4031 | - elseif(( 'categories' == $label ) && ( 'language' == $attrKey )) |
|
4031 | + elseif (('categories' == $label) && ('language' == $attrKey)) |
|
4032 | 4032 | $categoriesAttrLang = $attrKey.'='.$attrValue; |
4033 | 4033 | else { |
4034 | - $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' '; |
|
4035 | - $attributes .= ( !empty( $attrKey )) ? $attrKey.'=' : null; |
|
4036 | - if(( '"' == substr( $attrValue, 0, 1 )) && ( '"' == substr( $attrValue, -1 ))) { |
|
4037 | - $attrValue = substr( $attrValue, 1, ( strlen( $attrValue ) - 2 )); |
|
4038 | - $attrValue = str_replace( '"', '', $attrValue ); |
|
4034 | + $attributes .= (empty($attributes)) ? ' ' : $this->attributeDelimiter.' '; |
|
4035 | + $attributes .= (!empty($attrKey)) ? $attrKey.'=' : null; |
|
4036 | + if (('"' == substr($attrValue, 0, 1)) && ('"' == substr($attrValue, -1))) { |
|
4037 | + $attrValue = substr($attrValue, 1, (strlen($attrValue) - 2)); |
|
4038 | + $attrValue = str_replace('"', '', $attrValue); |
|
4039 | 4039 | } |
4040 | - $attributes .= '"'.htmlspecialchars( $attrValue ).'"'; |
|
4040 | + $attributes .= '"'.htmlspecialchars($attrValue).'"'; |
|
4041 | 4041 | } |
4042 | 4042 | } |
4043 | 4043 | } |
4044 | 4044 | else { |
4045 | - $attributes = str_replace( $this->intAttrDelimiter, $this->attributeDelimiter, $attributes ); |
|
4045 | + $attributes = str_replace($this->intAttrDelimiter, $this->attributeDelimiter, $attributes); |
|
4046 | 4046 | } |
4047 | 4047 | } |
4048 | - if(((( 'attach' == $label ) && !$attachInlineBinary ) || |
|
4049 | - ( in_array( $label, array( 'tzurl', 'url' )))) && ( 'xcal' == $this->format)) { |
|
4048 | + if (((('attach' == $label) && !$attachInlineBinary) || |
|
4049 | + (in_array($label, array('tzurl', 'url')))) && ('xcal' == $this->format)) { |
|
4050 | 4050 | $pos = strrpos($content, "/"); |
4051 | - $docname = ( $pos !== false) ? substr( $content, (1 - strlen( $content ) + $pos )) : $content; |
|
4052 | - $this->xcaldecl[] = array( 'xmldecl' => 'ENTITY' |
|
4051 | + $docname = ($pos !== false) ? substr($content, (1 - strlen($content) + $pos)) : $content; |
|
4052 | + $this->xcaldecl[] = array('xmldecl' => 'ENTITY' |
|
4053 | 4053 | , 'uri' => $docname |
4054 | 4054 | , 'ref' => 'SYSTEM' |
4055 | 4055 | , 'external' => $content |
4056 | 4056 | , 'type' => 'NDATA' |
4057 | - , 'type2' => 'BINERY' ); |
|
4058 | - $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' '; |
|
4057 | + , 'type2' => 'BINERY'); |
|
4058 | + $attributes .= (empty($attributes)) ? ' ' : $this->attributeDelimiter.' '; |
|
4059 | 4059 | $attributes .= 'uri="'.$docname.'"'; |
4060 | 4060 | $content = null; |
4061 | - if( 'attach' == $label ) { |
|
4062 | - $attributes = str_replace( $this->attributeDelimiter, $this->intAttrDelimiter, $attributes ); |
|
4063 | - $content = $this->_createElement( 'extref', $attributes, null ); |
|
4061 | + if ('attach' == $label) { |
|
4062 | + $attributes = str_replace($this->attributeDelimiter, $this->intAttrDelimiter, $attributes); |
|
4063 | + $content = $this->_createElement('extref', $attributes, null); |
|
4064 | 4064 | $attributes = null; |
4065 | 4065 | } |
4066 | 4066 | } |
4067 | - elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) { |
|
4068 | - $content = $this->nl.$this->_createElement( 'b64bin', $attachfmttype, $content ); // max one attribute |
|
4067 | + elseif (('attach' == $label) && $attachInlineBinary && ('xcal' == $this->format)) { |
|
4068 | + $content = $this->nl.$this->_createElement('b64bin', $attachfmttype, $content); // max one attribute |
|
4069 | 4069 | } |
4070 | 4070 | $output .= $attributes; |
4071 | - if( !$content ) { |
|
4072 | - switch( $this->format ) { |
|
4071 | + if (!$content) { |
|
4072 | + switch ($this->format) { |
|
4073 | 4073 | case 'xcal': |
4074 | 4074 | $output .= ' /'; |
4075 | 4075 | $output .= $this->elementStart2; |
@@ -4077,18 +4077,18 @@ discard block |
||
4077 | 4077 | break; |
4078 | 4078 | default: |
4079 | 4079 | $output .= $this->elementStart2.$this->valueInit; |
4080 | - return $this->_size75( $output ); |
|
4080 | + return $this->_size75($output); |
|
4081 | 4081 | break; |
4082 | 4082 | } |
4083 | 4083 | } |
4084 | 4084 | $output .= $this->elementStart2; |
4085 | 4085 | $output .= $this->valueInit.$content; |
4086 | - switch( $this->format ) { |
|
4086 | + switch ($this->format) { |
|
4087 | 4087 | case 'xcal': |
4088 | 4088 | return $output.$this->elementEnd1.$label.$this->elementEnd2; |
4089 | 4089 | break; |
4090 | 4090 | default: |
4091 | - return $this->_size75( $output ); |
|
4091 | + return $this->_size75($output); |
|
4092 | 4092 | break; |
4093 | 4093 | } |
4094 | 4094 | } |
@@ -4101,36 +4101,36 @@ discard block |
||
4101 | 4101 | * @param array $ctrKeys optional |
4102 | 4102 | * @return string |
4103 | 4103 | */ |
4104 | - function _createParams( $params=array(), $ctrKeys=array() ) { |
|
4104 | + function _createParams($params = array(), $ctrKeys = array()) { |
|
4105 | 4105 | $attrLANG = $attr1 = $attr2 = null; |
4106 | - $CNattrKey = ( in_array( 'CN', $ctrKeys )) ? TRUE : FALSE ; |
|
4107 | - $LANGattrKey = ( in_array( 'LANGUAGE', $ctrKeys )) ? TRUE : FALSE ; |
|
4106 | + $CNattrKey = (in_array('CN', $ctrKeys)) ? TRUE : FALSE; |
|
4107 | + $LANGattrKey = (in_array('LANGUAGE', $ctrKeys)) ? TRUE : FALSE; |
|
4108 | 4108 | $CNattrExist = $LANGattrExist = FALSE; |
4109 | - if( is_array( $params )) { |
|
4110 | - foreach( $params as $paramKey => $paramValue ) { |
|
4111 | - if( is_int( $paramKey )) |
|
4109 | + if (is_array($params)) { |
|
4110 | + foreach ($params as $paramKey => $paramValue) { |
|
4111 | + if (is_int($paramKey)) |
|
4112 | 4112 | $attr2 .= $this->intAttrDelimiter.$paramValue; |
4113 | - elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) { |
|
4113 | + elseif (('LANGUAGE' == $paramKey) && $LANGattrKey) { |
|
4114 | 4114 | $attrLANG .= $this->intAttrDelimiter."LANGUAGE=$paramValue"; |
4115 | 4115 | $LANGattrExist = TRUE; |
4116 | 4116 | } |
4117 | - elseif(( 'CN' == $paramKey ) && $CNattrKey ) { |
|
4117 | + elseif (('CN' == $paramKey) && $CNattrKey) { |
|
4118 | 4118 | $attr1 = $this->intAttrDelimiter.'CN="'.$paramValue.'"'; |
4119 | 4119 | $CNattrExist = TRUE; |
4120 | 4120 | } |
4121 | - elseif(( 'ALTREP' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4121 | + elseif (('ALTREP' == $paramKey) && in_array($paramKey, $ctrKeys)) |
|
4122 | 4122 | $attr2 .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"'; |
4123 | - elseif(( 'DIR' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4123 | + elseif (('DIR' == $paramKey) && in_array($paramKey, $ctrKeys)) |
|
4124 | 4124 | $attr2 .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"'; |
4125 | - elseif(( 'SENT-BY' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4125 | + elseif (('SENT-BY' == $paramKey) && in_array($paramKey, $ctrKeys)) |
|
4126 | 4126 | $attr2 .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"'; |
4127 | 4127 | else |
4128 | 4128 | $attr2 .= $this->intAttrDelimiter."$paramKey=$paramValue"; |
4129 | 4129 | } |
4130 | 4130 | } |
4131 | - if( !$LANGattrExist ) { |
|
4132 | - $lang = $this->getConfig( 'language' ); |
|
4133 | - if(( $CNattrExist || $LANGattrKey ) && $lang ) |
|
4131 | + if (!$LANGattrExist) { |
|
4132 | + $lang = $this->getConfig('language'); |
|
4133 | + if (($CNattrExist || $LANGattrKey) && $lang) |
|
4134 | 4134 | $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang; |
4135 | 4135 | } |
4136 | 4136 | return $attrLANG.$attr1.$attr2; |
@@ -4144,47 +4144,47 @@ discard block |
||
4144 | 4144 | * @param int $parno, no of date parts (i.e. year, month.. .) |
4145 | 4145 | * @return array $params, property parameters |
4146 | 4146 | */ |
4147 | - function _chkdatecfg( $theDate, & $parno, & $params ) { |
|
4148 | - if( isset( $params['TZID'] )) |
|
4147 | + function _chkdatecfg($theDate, & $parno, & $params) { |
|
4148 | + if (isset($params['TZID'])) |
|
4149 | 4149 | $parno = 6; |
4150 | - elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )) |
|
4150 | + elseif (isset($params['VALUE']) && ('DATE' == $params['VALUE'])) |
|
4151 | 4151 | $parno = 3; |
4152 | 4152 | else { |
4153 | - if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] )) |
|
4153 | + if (isset($params['VALUE']) && ('PERIOD' == $params['VALUE'])) |
|
4154 | 4154 | $parno = 7; |
4155 | - if( is_array( $theDate )) { |
|
4156 | - if( isset( $theDate['timestamp'] )) |
|
4157 | - $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null; |
|
4155 | + if (is_array($theDate)) { |
|
4156 | + if (isset($theDate['timestamp'])) |
|
4157 | + $tzid = (isset($theDate['tz'])) ? $theDate['tz'] : null; |
|
4158 | 4158 | else |
4159 | - $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null; |
|
4160 | - if( !empty( $tzid )) { |
|
4159 | + $tzid = (isset($theDate['tz'])) ? $theDate['tz'] : (7 == count($theDate)) ? end($theDate) : null; |
|
4160 | + if (!empty($tzid)) { |
|
4161 | 4161 | $parno = 7; |
4162 | - if( !$this->_isOffset( $tzid )) |
|
4162 | + if (!$this->_isOffset($tzid)) |
|
4163 | 4163 | $params['TZID'] = $tzid; // save only timezone |
4164 | 4164 | } |
4165 | - elseif( !$parno && ( 3 == count( $theDate )) && |
|
4166 | - ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))) |
|
4165 | + elseif (!$parno && (3 == count($theDate)) && |
|
4166 | + (isset($params['VALUE']) && ('DATE' == $params['VALUE']))) |
|
4167 | 4167 | $parno = 3; |
4168 | 4168 | else |
4169 | 4169 | $parno = 6; |
4170 | 4170 | } |
4171 | 4171 | else { // string |
4172 | - $date = trim( $theDate ); |
|
4173 | - if( 'Z' == substr( $date, -1 )) |
|
4172 | + $date = trim($theDate); |
|
4173 | + if ('Z' == substr($date, -1)) |
|
4174 | 4174 | $parno = 7; // UTC DATE-TIME |
4175 | - elseif((( 8 == strlen( $date ) && ctype_digit( $date )) || ( 11 >= strlen( $date ))) && |
|
4176 | - ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' )))) |
|
4175 | + elseif (((8 == strlen($date) && ctype_digit($date)) || (11 >= strlen($date))) && |
|
4176 | + (!isset($params['VALUE']) || !in_array($params['VALUE'], array('DATE-TIME', 'PERIOD')))) |
|
4177 | 4177 | $parno = 3; // DATE |
4178 | - $date = $this->_date_time_string( $date, $parno ); |
|
4179 | - if( !empty( $date['tz'] )) { |
|
4178 | + $date = $this->_date_time_string($date, $parno); |
|
4179 | + if (!empty($date['tz'])) { |
|
4180 | 4180 | $parno = 7; |
4181 | - if( !$this->_isOffset( $date['tz'] )) |
|
4181 | + if (!$this->_isOffset($date['tz'])) |
|
4182 | 4182 | $params['TZID'] = $date['tz']; // save only timezone |
4183 | 4183 | } |
4184 | - elseif( empty( $parno )) |
|
4184 | + elseif (empty($parno)) |
|
4185 | 4185 | $parno = 6; |
4186 | 4186 | } |
4187 | - if( isset( $params['TZID'] )) |
|
4187 | + if (isset($params['TZID'])) |
|
4188 | 4188 | $parno = 6; |
4189 | 4189 | } |
4190 | 4190 | } |
@@ -4199,28 +4199,28 @@ discard block |
||
4199 | 4199 | * @param array $duration, optional |
4200 | 4200 | * @return array duration |
4201 | 4201 | */ |
4202 | - function _date2duration( $startdate=FALSE, $enddate=FALSE ) { |
|
4203 | - if( !$startdate || !$enddate ) { |
|
4204 | - if( FALSE === ( $startdate = $this->getProperty( 'dtstart' ))) |
|
4202 | + function _date2duration($startdate = FALSE, $enddate = FALSE) { |
|
4203 | + if (!$startdate || !$enddate) { |
|
4204 | + if (FALSE === ($startdate = $this->getProperty('dtstart'))) |
|
4205 | 4205 | return null; |
4206 | - if( FALSE === ( $enddate = $this->getProperty( 'dtend' ))) // vevent/vfreebusy |
|
4207 | - if( FALSE === ( $enddate = $this->getProperty( 'due' ))) // vtodo |
|
4206 | + if (FALSE === ($enddate = $this->getProperty('dtend'))) // vevent/vfreebusy |
|
4207 | + if (FALSE === ($enddate = $this->getProperty('due'))) // vtodo |
|
4208 | 4208 | return null; |
4209 | 4209 | } |
4210 | - if( !$startdate || !$enddate ) |
|
4210 | + if (!$startdate || !$enddate) |
|
4211 | 4211 | return null; |
4212 | - $startWdate = mktime( 0, 0, 0, $startdate['month'], $startdate['day'], $startdate['year'] ); |
|
4213 | - $endWdate = mktime( 0, 0, 0, $enddate['month'], $enddate['day'], $enddate['year'] ); |
|
4212 | + $startWdate = mktime(0, 0, 0, $startdate['month'], $startdate['day'], $startdate['year']); |
|
4213 | + $endWdate = mktime(0, 0, 0, $enddate['month'], $enddate['day'], $enddate['year']); |
|
4214 | 4214 | $wduration = $endWdate - $startWdate; |
4215 | 4215 | $dur = array(); |
4216 | - $dur['week'] = (int) floor( $wduration / ( 7 * 24 * 60 * 60 )); |
|
4217 | - $wduration = $wduration % ( 7 * 24 * 60 * 60 ); |
|
4218 | - $dur['day'] = (int) floor( $wduration / ( 24 * 60 * 60 )); |
|
4219 | - $wduration = $wduration % ( 24 * 60 * 60 ); |
|
4220 | - $dur['hour'] = (int) floor( $wduration / ( 60 * 60 )); |
|
4221 | - $wduration = $wduration % ( 60 * 60 ); |
|
4222 | - $dur['min'] = (int) floor( $wduration / ( 60 )); |
|
4223 | - $dur['sec'] = (int) $wduration % ( 60 ); |
|
4216 | + $dur['week'] = (int) floor($wduration / (7 * 24 * 60 * 60)); |
|
4217 | + $wduration = $wduration % (7 * 24 * 60 * 60); |
|
4218 | + $dur['day'] = (int) floor($wduration / (24 * 60 * 60)); |
|
4219 | + $wduration = $wduration % (24 * 60 * 60); |
|
4220 | + $dur['hour'] = (int) floor($wduration / (60 * 60)); |
|
4221 | + $wduration = $wduration % (60 * 60); |
|
4222 | + $dur['min'] = (int) floor($wduration / (60)); |
|
4223 | + $dur['sec'] = (int) $wduration % (60); |
|
4224 | 4224 | return $dur; |
4225 | 4225 | } |
4226 | 4226 | /** |
@@ -4232,19 +4232,19 @@ discard block |
||
4232 | 4232 | * @param string $tz timezone |
4233 | 4233 | * @return timestamp |
4234 | 4234 | */ |
4235 | - function _date2timestamp( $datetime, $tz=null ) { |
|
4235 | + function _date2timestamp($datetime, $tz = null) { |
|
4236 | 4236 | $output = null; |
4237 | - if( !isset( $datetime['hour'] )) $datetime['hour'] = '0'; |
|
4238 | - if( !isset( $datetime['min'] )) $datetime['min'] = '0'; |
|
4239 | - if( !isset( $datetime['sec'] )) $datetime['sec'] = '0'; |
|
4240 | - foreach( $datetime as $dkey => $dvalue ) { |
|
4241 | - if( 'tz' != $dkey ) |
|
4237 | + if (!isset($datetime['hour'])) $datetime['hour'] = '0'; |
|
4238 | + if (!isset($datetime['min'])) $datetime['min'] = '0'; |
|
4239 | + if (!isset($datetime['sec'])) $datetime['sec'] = '0'; |
|
4240 | + foreach ($datetime as $dkey => $dvalue) { |
|
4241 | + if ('tz' != $dkey) |
|
4242 | 4242 | $datetime[$dkey] = (integer) $dvalue; |
4243 | 4243 | } |
4244 | - if( $tz ) |
|
4244 | + if ($tz) |
|
4245 | 4245 | $datetime['tz'] = $tz; |
4246 | - $offset = ( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) ? $this->_tz2offset( $datetime['tz'] ) : 0; |
|
4247 | - $output = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year'] ); |
|
4246 | + $offset = (isset($datetime['tz']) && ('' < trim($datetime['tz']))) ? $this->_tz2offset($datetime['tz']) : 0; |
|
4247 | + $output = mktime($datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']); |
|
4248 | 4248 | return $output; |
4249 | 4249 | } |
4250 | 4250 | /** |
@@ -4256,13 +4256,13 @@ discard block |
||
4256 | 4256 | * @param int $parno optional, default FALSE |
4257 | 4257 | * @return array |
4258 | 4258 | */ |
4259 | - function _date_time_array( $datetime, $parno=FALSE ) { |
|
4259 | + function _date_time_array($datetime, $parno = FALSE) { |
|
4260 | 4260 | $output = array(); |
4261 | - foreach( $datetime as $dateKey => $datePart ) { |
|
4262 | - switch ( $dateKey ) { |
|
4261 | + foreach ($datetime as $dateKey => $datePart) { |
|
4262 | + switch ($dateKey) { |
|
4263 | 4263 | case '0': |
4264 | 4264 | case 'year': |
4265 | - $output['year'] = $datePart; |
|
4265 | + $output['year'] = $datePart; |
|
4266 | 4266 | break; |
4267 | 4267 | case '1': |
4268 | 4268 | case 'month': |
@@ -4270,40 +4270,40 @@ discard block |
||
4270 | 4270 | break; |
4271 | 4271 | case '2': |
4272 | 4272 | case 'day': |
4273 | - $output['day'] = $datePart; |
|
4273 | + $output['day'] = $datePart; |
|
4274 | 4274 | break; |
4275 | 4275 | } |
4276 | - if( 3 != $parno ) { |
|
4277 | - switch ( $dateKey ) { |
|
4276 | + if (3 != $parno) { |
|
4277 | + switch ($dateKey) { |
|
4278 | 4278 | case '0': |
4279 | 4279 | case '1': |
4280 | 4280 | case '2': |
4281 | 4281 | break; |
4282 | 4282 | case '3': |
4283 | 4283 | case 'hour': |
4284 | - $output['hour'] = $datePart; |
|
4284 | + $output['hour'] = $datePart; |
|
4285 | 4285 | break; |
4286 | 4286 | case '4': |
4287 | 4287 | case 'min': |
4288 | - $output['min'] = $datePart; |
|
4288 | + $output['min'] = $datePart; |
|
4289 | 4289 | break; |
4290 | 4290 | case '5': |
4291 | 4291 | case 'sec': |
4292 | - $output['sec'] = $datePart; |
|
4292 | + $output['sec'] = $datePart; |
|
4293 | 4293 | break; |
4294 | 4294 | case '6': |
4295 | 4295 | case 'tz': |
4296 | - $output['tz'] = $datePart; |
|
4296 | + $output['tz'] = $datePart; |
|
4297 | 4297 | break; |
4298 | 4298 | } |
4299 | 4299 | } |
4300 | 4300 | } |
4301 | - if( 3 != $parno ) { |
|
4302 | - if( !isset( $output['hour'] )) |
|
4301 | + if (3 != $parno) { |
|
4302 | + if (!isset($output['hour'])) |
|
4303 | 4303 | $output['hour'] = 0; |
4304 | - if( !isset( $output['min'] )) |
|
4304 | + if (!isset($output['min'])) |
|
4305 | 4305 | $output['min'] = 0; |
4306 | - if( !isset( $output['sec'] )) |
|
4306 | + if (!isset($output['sec'])) |
|
4307 | 4307 | $output['sec'] = 0; |
4308 | 4308 | } |
4309 | 4309 | return $output; |
@@ -4317,88 +4317,88 @@ discard block |
||
4317 | 4317 | * @param int $parno optional, default FALSE |
4318 | 4318 | * @return array |
4319 | 4319 | */ |
4320 | - function _date_time_string( $datetime, $parno=FALSE ) { |
|
4321 | - $datetime = (string) trim( $datetime ); |
|
4320 | + function _date_time_string($datetime, $parno = FALSE) { |
|
4321 | + $datetime = (string) trim($datetime); |
|
4322 | 4322 | $tz = null; |
4323 | - $len = strlen( $datetime ) - 1; |
|
4324 | - if( 'Z' == substr( $datetime, -1 )) { |
|
4323 | + $len = strlen($datetime) - 1; |
|
4324 | + if ('Z' == substr($datetime, -1)) { |
|
4325 | 4325 | $tz = 'Z'; |
4326 | - $datetime = trim( substr( $datetime, 0, $len )); |
|
4326 | + $datetime = trim(substr($datetime, 0, $len)); |
|
4327 | 4327 | } |
4328 | - elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date |
|
4329 | - ( '-' == substr( $datetime, -3, 1 )) || |
|
4330 | - ( ':' == substr( $datetime, -3, 1 )) || |
|
4331 | - ( '.' == substr( $datetime, -3, 1 ))) { |
|
4328 | + elseif ((ctype_digit(substr($datetime, -2, 2))) && // time or date |
|
4329 | + ('-' == substr($datetime, -3, 1)) || |
|
4330 | + (':' == substr($datetime, -3, 1)) || |
|
4331 | + ('.' == substr($datetime, -3, 1))) { |
|
4332 | 4332 | $continue = TRUE; |
4333 | 4333 | } |
4334 | - elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset |
|
4335 | - ( ' +' == substr( $datetime, -6, 2 )) || |
|
4336 | - ( ' -' == substr( $datetime, -6, 2 ))) { |
|
4337 | - $tz = substr( $datetime, -5, 5 ); |
|
4338 | - $datetime = substr( $datetime, 0, ($len - 5)); |
|
4334 | + elseif ((ctype_digit(substr($datetime, -4, 4))) && // 4 pos offset |
|
4335 | + (' +' == substr($datetime, -6, 2)) || |
|
4336 | + (' -' == substr($datetime, -6, 2))) { |
|
4337 | + $tz = substr($datetime, -5, 5); |
|
4338 | + $datetime = substr($datetime, 0, ($len - 5)); |
|
4339 | 4339 | } |
4340 | - elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset |
|
4341 | - ( ' +' == substr( $datetime, -8, 2 )) || |
|
4342 | - ( ' -' == substr( $datetime, -8, 2 ))) { |
|
4343 | - $tz = substr( $datetime, -7, 7 ); |
|
4344 | - $datetime = substr( $datetime, 0, ($len - 7)); |
|
4340 | + elseif ((ctype_digit(substr($datetime, -6, 6))) && // 6 pos offset |
|
4341 | + (' +' == substr($datetime, -8, 2)) || |
|
4342 | + (' -' == substr($datetime, -8, 2))) { |
|
4343 | + $tz = substr($datetime, -7, 7); |
|
4344 | + $datetime = substr($datetime, 0, ($len - 7)); |
|
4345 | 4345 | } |
4346 | - elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) { |
|
4346 | + elseif ((6 < $len) && (ctype_digit(substr($datetime, -6, 6)))) { |
|
4347 | 4347 | $continue = TRUE; |
4348 | 4348 | } |
4349 | - elseif( 'T' == substr( $datetime, -7, 1 )) { |
|
4349 | + elseif ('T' == substr($datetime, -7, 1)) { |
|
4350 | 4350 | $continue = TRUE; |
4351 | 4351 | } |
4352 | 4352 | else { |
4353 | - $cx = $tx = 0; // 19970415T133000 US-Eastern |
|
4354 | - for( $cx = -1; $cx > ( 9 - $len ); $cx-- ) { |
|
4355 | - if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 ))) |
|
4353 | + $cx = $tx = 0; // 19970415T133000 US-Eastern |
|
4354 | + for ($cx = -1; $cx > (9 - $len); $cx--) { |
|
4355 | + if ((' ' == substr($datetime, $cx, 1)) || ctype_digit(substr($datetime, $cx, 1))) |
|
4356 | 4356 | break; // if exists, tz ends here.. . ? |
4357 | - elseif( ctype_alpha( substr( $datetime, $cx, 1 )) || |
|
4358 | - ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' )))) |
|
4357 | + elseif (ctype_alpha(substr($datetime, $cx, 1)) || |
|
4358 | + (in_array(substr($datetime, $cx, 1), array('-', '/')))) |
|
4359 | 4359 | $tx--; // tz length counter |
4360 | 4360 | } |
4361 | - if( 0 > $tx ) { |
|
4362 | - $tz = substr( $datetime, $tx ); |
|
4363 | - $datetime = trim( substr( $datetime, 0, $len + $tx + 1 )); |
|
4361 | + if (0 > $tx) { |
|
4362 | + $tz = substr($datetime, $tx); |
|
4363 | + $datetime = trim(substr($datetime, 0, $len + $tx + 1)); |
|
4364 | 4364 | } |
4365 | 4365 | } |
4366 | - if( 0 < substr_count( $datetime, '-' )) { |
|
4367 | - $datetime = str_replace( '-', '/', $datetime ); |
|
4368 | - } |
|
4369 | - elseif( ctype_digit( substr( $datetime, 0, 8 )) && |
|
4370 | - ( 'T' == substr( $datetime, 8, 1 )) && |
|
4371 | - ctype_digit( substr( $datetime, 9, 6 ))) { |
|
4372 | - $datetime = substr( $datetime, 4, 2 ) |
|
4373 | - .'/'.substr( $datetime, 6, 2 ) |
|
4374 | - .'/'.substr( $datetime, 0, 4 ) |
|
4375 | - .' '.substr( $datetime, 9, 2 ) |
|
4376 | - .':'.substr( $datetime, 11, 2 ) |
|
4377 | - .':'.substr( $datetime, 13); |
|
4378 | - } |
|
4379 | - $datestring = date( 'Y-m-d H:i:s', strtotime( $datetime )); |
|
4380 | - $tz = trim( $tz ); |
|
4366 | + if (0 < substr_count($datetime, '-')) { |
|
4367 | + $datetime = str_replace('-', '/', $datetime); |
|
4368 | + } |
|
4369 | + elseif (ctype_digit(substr($datetime, 0, 8)) && |
|
4370 | + ('T' == substr($datetime, 8, 1)) && |
|
4371 | + ctype_digit(substr($datetime, 9, 6))) { |
|
4372 | + $datetime = substr($datetime, 4, 2) |
|
4373 | + .'/'.substr($datetime, 6, 2) |
|
4374 | + .'/'.substr($datetime, 0, 4) |
|
4375 | + .' '.substr($datetime, 9, 2) |
|
4376 | + .':'.substr($datetime, 11, 2) |
|
4377 | + .':'.substr($datetime, 13); |
|
4378 | + } |
|
4379 | + $datestring = date('Y-m-d H:i:s', strtotime($datetime)); |
|
4380 | + $tz = trim($tz); |
|
4381 | 4381 | $output = array(); |
4382 | - $output['year'] = substr( $datestring, 0, 4 ); |
|
4383 | - $output['month'] = substr( $datestring, 5, 2 ); |
|
4384 | - $output['day'] = substr( $datestring, 8, 2 ); |
|
4385 | - if(( 6 == $parno ) || ( 7 == $parno )) { |
|
4386 | - $output['hour'] = substr( $datestring, 11, 2 ); |
|
4387 | - $output['min'] = substr( $datestring, 14, 2 ); |
|
4388 | - $output['sec'] = substr( $datestring, 17, 2 ); |
|
4389 | - if( !empty( $tz )) |
|
4390 | - $output['tz'] = $tz; |
|
4391 | - } |
|
4392 | - elseif( 3 != $parno ) { |
|
4393 | - if(( '00' < substr( $datestring, 11, 2 )) || |
|
4394 | - ( '00' < substr( $datestring, 14, 2 )) || |
|
4395 | - ( '00' < substr( $datestring, 17, 2 ))) { |
|
4396 | - $output['hour'] = substr( $datestring, 11, 2 ); |
|
4397 | - $output['min'] = substr( $datestring, 14, 2 ); |
|
4398 | - $output['sec'] = substr( $datestring, 17, 2 ); |
|
4382 | + $output['year'] = substr($datestring, 0, 4); |
|
4383 | + $output['month'] = substr($datestring, 5, 2); |
|
4384 | + $output['day'] = substr($datestring, 8, 2); |
|
4385 | + if ((6 == $parno) || (7 == $parno)) { |
|
4386 | + $output['hour'] = substr($datestring, 11, 2); |
|
4387 | + $output['min'] = substr($datestring, 14, 2); |
|
4388 | + $output['sec'] = substr($datestring, 17, 2); |
|
4389 | + if (!empty($tz)) |
|
4390 | + $output['tz'] = $tz; |
|
4391 | + } |
|
4392 | + elseif (3 != $parno) { |
|
4393 | + if (('00' < substr($datestring, 11, 2)) || |
|
4394 | + ('00' < substr($datestring, 14, 2)) || |
|
4395 | + ('00' < substr($datestring, 17, 2))) { |
|
4396 | + $output['hour'] = substr($datestring, 11, 2); |
|
4397 | + $output['min'] = substr($datestring, 14, 2); |
|
4398 | + $output['sec'] = substr($datestring, 17, 2); |
|
4399 | 4399 | } |
4400 | - if( !empty( $tz )) |
|
4401 | - $output['tz'] = $tz; |
|
4400 | + if (!empty($tz)) |
|
4401 | + $output['tz'] = $tz; |
|
4402 | 4402 | } |
4403 | 4403 | return $output; |
4404 | 4404 | } |
@@ -4410,62 +4410,62 @@ discard block |
||
4410 | 4410 | * @param array $duration |
4411 | 4411 | * @return array |
4412 | 4412 | */ |
4413 | - function _duration_array( $duration ) { |
|
4413 | + function _duration_array($duration) { |
|
4414 | 4414 | $output = array(); |
4415 | - if( is_array( $duration ) && |
|
4416 | - ( 1 == count( $duration )) && |
|
4417 | - isset( $duration['sec'] ) && |
|
4418 | - ( 60 < $duration['sec'] )) { |
|
4415 | + if (is_array($duration) && |
|
4416 | + (1 == count($duration)) && |
|
4417 | + isset($duration['sec']) && |
|
4418 | + (60 < $duration['sec'])) { |
|
4419 | 4419 | $durseconds = $duration['sec']; |
4420 | - $output['week'] = floor( $durseconds / ( 60 * 60 * 24 * 7 )); |
|
4421 | - $durseconds = $durseconds % ( 60 * 60 * 24 * 7 ); |
|
4422 | - $output['day'] = floor( $durseconds / ( 60 * 60 * 24 )); |
|
4423 | - $durseconds = $durseconds % ( 60 * 60 * 24 ); |
|
4424 | - $output['hour'] = floor( $durseconds / ( 60 * 60 )); |
|
4425 | - $durseconds = $durseconds % ( 60 * 60 ); |
|
4426 | - $output['min'] = floor( $durseconds / ( 60 )); |
|
4427 | - $output['sec'] = ( $durseconds % ( 60 )); |
|
4420 | + $output['week'] = floor($durseconds / (60 * 60 * 24 * 7)); |
|
4421 | + $durseconds = $durseconds % (60 * 60 * 24 * 7); |
|
4422 | + $output['day'] = floor($durseconds / (60 * 60 * 24)); |
|
4423 | + $durseconds = $durseconds % (60 * 60 * 24); |
|
4424 | + $output['hour'] = floor($durseconds / (60 * 60)); |
|
4425 | + $durseconds = $durseconds % (60 * 60); |
|
4426 | + $output['min'] = floor($durseconds / (60)); |
|
4427 | + $output['sec'] = ($durseconds % (60)); |
|
4428 | 4428 | } |
4429 | 4429 | else { |
4430 | - foreach( $duration as $durKey => $durValue ) { |
|
4431 | - if( empty( $durValue )) continue; |
|
4432 | - switch ( $durKey ) { |
|
4430 | + foreach ($duration as $durKey => $durValue) { |
|
4431 | + if (empty($durValue)) continue; |
|
4432 | + switch ($durKey) { |
|
4433 | 4433 | case '0': |
4434 | 4434 | case 'week': |
4435 | - $output['week'] = $durValue; |
|
4435 | + $output['week'] = $durValue; |
|
4436 | 4436 | break; |
4437 | 4437 | case '1': |
4438 | 4438 | case 'day': |
4439 | - $output['day'] = $durValue; |
|
4439 | + $output['day'] = $durValue; |
|
4440 | 4440 | break; |
4441 | 4441 | case '2': |
4442 | 4442 | case 'hour': |
4443 | - $output['hour'] = $durValue; |
|
4443 | + $output['hour'] = $durValue; |
|
4444 | 4444 | break; |
4445 | 4445 | case '3': |
4446 | 4446 | case 'min': |
4447 | - $output['min'] = $durValue; |
|
4447 | + $output['min'] = $durValue; |
|
4448 | 4448 | break; |
4449 | 4449 | case '4': |
4450 | 4450 | case 'sec': |
4451 | - $output['sec'] = $durValue; |
|
4451 | + $output['sec'] = $durValue; |
|
4452 | 4452 | break; |
4453 | 4453 | } |
4454 | 4454 | } |
4455 | 4455 | } |
4456 | - if( isset( $output['week'] ) && ( 0 < $output['week'] )) { |
|
4457 | - unset( $output['day'], $output['hour'], $output['min'], $output['sec'] ); |
|
4456 | + if (isset($output['week']) && (0 < $output['week'])) { |
|
4457 | + unset($output['day'], $output['hour'], $output['min'], $output['sec']); |
|
4458 | 4458 | return $output; |
4459 | 4459 | } |
4460 | - unset( $output['week'] ); |
|
4461 | - if( empty( $output['day'] )) |
|
4462 | - unset( $output['day'] ); |
|
4463 | - if ( isset( $output['hour'] ) || isset( $output['min'] ) || isset( $output['sec'] )) { |
|
4464 | - if( !isset( $output['hour'] )) $output['hour'] = 0; |
|
4465 | - if( !isset( $output['min'] )) $output['min'] = 0; |
|
4466 | - if( !isset( $output['sec'] )) $output['sec'] = 0; |
|
4467 | - if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] )) |
|
4468 | - unset( $output['hour'], $output['min'], $output['sec'] ); |
|
4460 | + unset($output['week']); |
|
4461 | + if (empty($output['day'])) |
|
4462 | + unset($output['day']); |
|
4463 | + if (isset($output['hour']) || isset($output['min']) || isset($output['sec'])) { |
|
4464 | + if (!isset($output['hour'])) $output['hour'] = 0; |
|
4465 | + if (!isset($output['min'])) $output['min'] = 0; |
|
4466 | + if (!isset($output['sec'])) $output['sec'] = 0; |
|
4467 | + if ((0 == $output['hour']) && (0 == $output['min']) && (0 == $output['sec'])) |
|
4468 | + unset($output['hour'], $output['min'], $output['sec']); |
|
4469 | 4469 | } |
4470 | 4470 | return $output; |
4471 | 4471 | } |
@@ -4478,43 +4478,43 @@ discard block |
||
4478 | 4478 | * @param array $duration, optional |
4479 | 4479 | * @return array, date format |
4480 | 4480 | */ |
4481 | - function duration2date( $startdate=FALSE, $duration=FALSE ) { |
|
4482 | - if( $startdate && $duration ) { |
|
4481 | + function duration2date($startdate = FALSE, $duration = FALSE) { |
|
4482 | + if ($startdate && $duration) { |
|
4483 | 4483 | $d1 = $startdate; |
4484 | 4484 | $dur = $duration; |
4485 | 4485 | } |
4486 | - elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) { |
|
4486 | + elseif (isset($this->dtstart['value']) && isset($this->duration['value'])) { |
|
4487 | 4487 | $d1 = $this->dtstart['value']; |
4488 | 4488 | $dur = $this->duration['value']; |
4489 | 4489 | } |
4490 | 4490 | else |
4491 | 4491 | return null; |
4492 | - $dateOnly = ( isset( $d1['hour'] ) || isset( $d1['min'] ) || isset( $d1['sec'] )) ? FALSE : TRUE; |
|
4493 | - $d1['hour'] = ( isset( $d1['hour'] )) ? $d1['hour'] : 0; |
|
4494 | - $d1['min'] = ( isset( $d1['min'] )) ? $d1['min'] : 0; |
|
4495 | - $d1['sec'] = ( isset( $d1['sec'] )) ? $d1['sec'] : 0; |
|
4496 | - $dtend = mktime( $d1['hour'], $d1['min'], $d1['sec'], $d1['month'], $d1['day'], $d1['year'] ); |
|
4497 | - if( isset( $dur['week'] )) |
|
4498 | - $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 ); |
|
4499 | - if( isset( $dur['day'] )) |
|
4500 | - $dtend += ( $dur['day'] * 24 * 60 * 60 ); |
|
4501 | - if( isset( $dur['hour'] )) |
|
4502 | - $dtend += ( $dur['hour'] * 60 *60 ); |
|
4503 | - if( isset( $dur['min'] )) |
|
4504 | - $dtend += ( $dur['min'] * 60 ); |
|
4505 | - if( isset( $dur['sec'] )) |
|
4506 | - $dtend += $dur['sec']; |
|
4492 | + $dateOnly = (isset($d1['hour']) || isset($d1['min']) || isset($d1['sec'])) ? FALSE : TRUE; |
|
4493 | + $d1['hour'] = (isset($d1['hour'])) ? $d1['hour'] : 0; |
|
4494 | + $d1['min'] = (isset($d1['min'])) ? $d1['min'] : 0; |
|
4495 | + $d1['sec'] = (isset($d1['sec'])) ? $d1['sec'] : 0; |
|
4496 | + $dtend = mktime($d1['hour'], $d1['min'], $d1['sec'], $d1['month'], $d1['day'], $d1['year']); |
|
4497 | + if (isset($dur['week'])) |
|
4498 | + $dtend += ($dur['week'] * 7 * 24 * 60 * 60); |
|
4499 | + if (isset($dur['day'])) |
|
4500 | + $dtend += ($dur['day'] * 24 * 60 * 60); |
|
4501 | + if (isset($dur['hour'])) |
|
4502 | + $dtend += ($dur['hour'] * 60 * 60); |
|
4503 | + if (isset($dur['min'])) |
|
4504 | + $dtend += ($dur['min'] * 60); |
|
4505 | + if (isset($dur['sec'])) |
|
4506 | + $dtend += $dur['sec']; |
|
4507 | 4507 | $dtend2 = array(); |
4508 | - $dtend2['year'] = date('Y', $dtend ); |
|
4509 | - $dtend2['month'] = date('m', $dtend ); |
|
4510 | - $dtend2['day'] = date('d', $dtend ); |
|
4511 | - $dtend2['hour'] = date('H', $dtend ); |
|
4512 | - $dtend2['min'] = date('i', $dtend ); |
|
4513 | - $dtend2['sec'] = date('s', $dtend ); |
|
4514 | - if( isset( $d1['tz'] )) |
|
4515 | - $dtend2['tz'] = $d1['tz']; |
|
4516 | - if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] ))) |
|
4517 | - unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] ); |
|
4508 | + $dtend2['year'] = date('Y', $dtend); |
|
4509 | + $dtend2['month'] = date('m', $dtend); |
|
4510 | + $dtend2['day'] = date('d', $dtend); |
|
4511 | + $dtend2['hour'] = date('H', $dtend); |
|
4512 | + $dtend2['min'] = date('i', $dtend); |
|
4513 | + $dtend2['sec'] = date('s', $dtend); |
|
4514 | + if (isset($d1['tz'])) |
|
4515 | + $dtend2['tz'] = $d1['tz']; |
|
4516 | + if ($dateOnly && ((0 == $dtend2['hour']) && (0 == $dtend2['min']) && (0 == $dtend2['sec']))) |
|
4517 | + unset($dtend2['hour'], $dtend2['min'], $dtend2['sec']); |
|
4518 | 4518 | return $dtend2; |
4519 | 4519 | } |
4520 | 4520 | /** |
@@ -4525,21 +4525,21 @@ discard block |
||
4525 | 4525 | * @param string $duration |
4526 | 4526 | * @return array |
4527 | 4527 | */ |
4528 | - function _duration_string( $duration ) { |
|
4529 | - $duration = (string) trim( $duration ); |
|
4530 | - while( 'P' != strtoupper( substr( $duration, 0, 1 ))) { |
|
4531 | - if( 0 < strlen( $duration )) |
|
4532 | - $duration = substr( $duration, 1 ); |
|
4528 | + function _duration_string($duration) { |
|
4529 | + $duration = (string) trim($duration); |
|
4530 | + while ('P' != strtoupper(substr($duration, 0, 1))) { |
|
4531 | + if (0 < strlen($duration)) |
|
4532 | + $duration = substr($duration, 1); |
|
4533 | 4533 | else |
4534 | 4534 | return false; // no leading P !?!? |
4535 | 4535 | } |
4536 | - $duration = substr( $duration, 1 ); // skip P |
|
4537 | - $duration = str_replace ( 't', 'T', $duration ); |
|
4538 | - $duration = str_replace ( 'T', '', $duration ); |
|
4536 | + $duration = substr($duration, 1); // skip P |
|
4537 | + $duration = str_replace('t', 'T', $duration); |
|
4538 | + $duration = str_replace('T', '', $duration); |
|
4539 | 4539 | $output = array(); |
4540 | 4540 | $val = null; |
4541 | - for( $ix=0; $ix < strlen( $duration ); $ix++ ) { |
|
4542 | - switch( strtoupper( $duration{$ix} )) { |
|
4541 | + for ($ix = 0; $ix < strlen($duration); $ix++) { |
|
4542 | + switch (strtoupper($duration{$ix} )) { |
|
4543 | 4543 | case 'W': |
4544 | 4544 | $output['week'] = $val; |
4545 | 4545 | $val = null; |
@@ -4561,13 +4561,13 @@ discard block |
||
4561 | 4561 | $val = null; |
4562 | 4562 | break; |
4563 | 4563 | default: |
4564 | - if( !ctype_digit( $duration{$ix} )) |
|
4564 | + if (!ctype_digit($duration{$ix} )) |
|
4565 | 4565 | return false; // unknown duration controll character !?!? |
4566 | 4566 | else |
4567 | 4567 | $val .= $duration{$ix}; |
4568 | 4568 | } |
4569 | 4569 | } |
4570 | - return $this->_duration_array( $output ); |
|
4570 | + return $this->_duration_array($output); |
|
4571 | 4571 | } |
4572 | 4572 | /** |
4573 | 4573 | * if not preSet, if exist, remove key with expected value from array and return hit value else return elseValue |
@@ -4582,15 +4582,15 @@ discard block |
||
4582 | 4582 | * @param int $preSet optional, return value if already preset |
4583 | 4583 | * @return int |
4584 | 4584 | */ |
4585 | - function _existRem( &$array, $expkey, $expval=FALSE, $hitVal=null, $elseVal=null, $preSet=null ) { |
|
4586 | - if( $preSet ) |
|
4585 | + function _existRem(&$array, $expkey, $expval = FALSE, $hitVal = null, $elseVal = null, $preSet = null) { |
|
4586 | + if ($preSet) |
|
4587 | 4587 | return $preSet; |
4588 | - if( !is_array( $array ) || ( 0 == count( $array ))) |
|
4588 | + if (!is_array($array) || (0 == count($array))) |
|
4589 | 4589 | return $elseVal; |
4590 | - foreach( $array as $key => $value ) { |
|
4591 | - if( strtoupper( $expkey ) == strtoupper( $key )) { |
|
4592 | - if( !$expval || ( strtoupper( $expval ) == strtoupper( $array[$key] ))) { |
|
4593 | - unset( $array[$key] ); |
|
4590 | + foreach ($array as $key => $value) { |
|
4591 | + if (strtoupper($expkey) == strtoupper($key)) { |
|
4592 | + if (!$expval || (strtoupper($expval) == strtoupper($array[$key]))) { |
|
4593 | + unset($array[$key]); |
|
4594 | 4594 | return $hitVal; |
4595 | 4595 | } |
4596 | 4596 | } |
@@ -4606,48 +4606,48 @@ discard block |
||
4606 | 4606 | * @param int $parno, optional, default 6 |
4607 | 4607 | * @return string |
4608 | 4608 | */ |
4609 | - function _format_date_time( $datetime, $parno=6 ) { |
|
4610 | - if( !isset( $datetime['year'] ) && |
|
4611 | - !isset( $datetime['month'] ) && |
|
4612 | - !isset( $datetime['day'] ) && |
|
4613 | - !isset( $datetime['hour'] ) && |
|
4614 | - !isset( $datetime['min'] ) && |
|
4615 | - !isset( $datetime['sec'] )) |
|
4616 | - return ; |
|
4609 | + function _format_date_time($datetime, $parno = 6) { |
|
4610 | + if (!isset($datetime['year']) && |
|
4611 | + !isset($datetime['month']) && |
|
4612 | + !isset($datetime['day']) && |
|
4613 | + !isset($datetime['hour']) && |
|
4614 | + !isset($datetime['min']) && |
|
4615 | + !isset($datetime['sec'])) |
|
4616 | + return; |
|
4617 | 4617 | $output = null; |
4618 | 4618 | // if( !isset( $datetime['day'] )) { $o=''; foreach($datetime as $k=>$v) {if(is_array($v)) $v=implode('-',$v);$o.=" $k=>$v";} echo " day SAKNAS : $o <br />\n"; } |
4619 | - foreach( $datetime as $dkey => $dvalue ) { |
|
4620 | - if( 'tz' != $dkey ) |
|
4619 | + foreach ($datetime as $dkey => $dvalue) { |
|
4620 | + if ('tz' != $dkey) |
|
4621 | 4621 | $datetime[$dkey] = (integer) $dvalue; |
4622 | 4622 | } |
4623 | - $output = date('Ymd', mktime( 0, 0, 0, $datetime['month'], $datetime['day'], $datetime['year'])); |
|
4624 | - if( isset( $datetime['hour'] ) || |
|
4625 | - isset( $datetime['min'] ) || |
|
4626 | - isset( $datetime['sec'] ) || |
|
4627 | - isset( $datetime['tz'] )) { |
|
4628 | - if( isset( $datetime['tz'] ) && |
|
4629 | - !isset( $datetime['hour'] )) |
|
4623 | + $output = date('Ymd', mktime(0, 0, 0, $datetime['month'], $datetime['day'], $datetime['year'])); |
|
4624 | + if (isset($datetime['hour']) || |
|
4625 | + isset($datetime['min']) || |
|
4626 | + isset($datetime['sec']) || |
|
4627 | + isset($datetime['tz'])) { |
|
4628 | + if (isset($datetime['tz']) && |
|
4629 | + !isset($datetime['hour'])) |
|
4630 | 4630 | $datetime['hour'] = 0; |
4631 | - if( isset( $datetime['hour'] ) && |
|
4632 | - !isset( $datetime['min'] )) |
|
4631 | + if (isset($datetime['hour']) && |
|
4632 | + !isset($datetime['min'])) |
|
4633 | 4633 | $datetime['min'] = 0; |
4634 | - if( isset( $datetime['hour'] ) && |
|
4635 | - isset( $datetime['min'] ) && |
|
4636 | - !isset( $datetime['sec'] )) |
|
4634 | + if (isset($datetime['hour']) && |
|
4635 | + isset($datetime['min']) && |
|
4636 | + !isset($datetime['sec'])) |
|
4637 | 4637 | $datetime['sec'] = 0; |
4638 | - $date = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']); |
|
4639 | - $output .= date('\THis', $date ); |
|
4640 | - if( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) { |
|
4641 | - $datetime['tz'] = trim( $datetime['tz'] ); |
|
4642 | - if( 'Z' == $datetime['tz'] ) |
|
4638 | + $date = mktime($datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']); |
|
4639 | + $output .= date('\THis', $date); |
|
4640 | + if (isset($datetime['tz']) && ('' < trim($datetime['tz']))) { |
|
4641 | + $datetime['tz'] = trim($datetime['tz']); |
|
4642 | + if ('Z' == $datetime['tz']) |
|
4643 | 4643 | $output .= 'Z'; |
4644 | - $offset = $this->_tz2offset( $datetime['tz'] ); |
|
4645 | - if( 0 != $offset ) { |
|
4646 | - $date = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']); |
|
4647 | - $output = date( 'Ymd\THis\Z', $date ); |
|
4644 | + $offset = $this->_tz2offset($datetime['tz']); |
|
4645 | + if (0 != $offset) { |
|
4646 | + $date = mktime($datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']); |
|
4647 | + $output = date('Ymd\THis\Z', $date); |
|
4648 | 4648 | } |
4649 | 4649 | } |
4650 | - elseif( 7 == $parno ) |
|
4650 | + elseif (7 == $parno) |
|
4651 | 4651 | $output .= 'Z'; |
4652 | 4652 | } |
4653 | 4653 | return $output; |
@@ -4660,26 +4660,26 @@ discard block |
||
4660 | 4660 | * @param array $duration ( week, day, hour, min, sec ) |
4661 | 4661 | * @return string |
4662 | 4662 | */ |
4663 | - function _format_duration( $duration ) { |
|
4664 | - if( !isset( $duration['week'] ) && |
|
4665 | - !isset( $duration['day'] ) && |
|
4666 | - !isset( $duration['hour'] ) && |
|
4667 | - !isset( $duration['min'] ) && |
|
4668 | - !isset( $duration['sec'] )) |
|
4663 | + function _format_duration($duration) { |
|
4664 | + if (!isset($duration['week']) && |
|
4665 | + !isset($duration['day']) && |
|
4666 | + !isset($duration['hour']) && |
|
4667 | + !isset($duration['min']) && |
|
4668 | + !isset($duration['sec'])) |
|
4669 | 4669 | return; |
4670 | 4670 | $output = 'P'; |
4671 | - if( isset( $duration['week'] ) && ( 0 < $duration['week'] )) |
|
4672 | - $output .= $duration['week'].'W'; |
|
4671 | + if (isset($duration['week']) && (0 < $duration['week'])) |
|
4672 | + $output .= $duration['week'].'W'; |
|
4673 | 4673 | else { |
4674 | - if( isset($duration['day'] ) && ( 0 < $duration['day'] )) |
|
4674 | + if (isset($duration['day']) && (0 < $duration['day'])) |
|
4675 | 4675 | $output .= $duration['day'].'D'; |
4676 | - if(( isset( $duration['hour']) && ( 0 < $duration['hour'] )) || |
|
4677 | - ( isset( $duration['min']) && ( 0 < $duration['min'] )) || |
|
4678 | - ( isset( $duration['sec']) && ( 0 < $duration['sec'] ))) { |
|
4676 | + if ((isset($duration['hour']) && (0 < $duration['hour'])) || |
|
4677 | + (isset($duration['min']) && (0 < $duration['min'])) || |
|
4678 | + (isset($duration['sec']) && (0 < $duration['sec']))) { |
|
4679 | 4679 | $output .= 'T'; |
4680 | - $output .= ( isset( $duration['hour']) && ( 0 < $duration['hour'] )) ? $duration['hour'].'H' : '0H'; |
|
4681 | - $output .= ( isset( $duration['min']) && ( 0 < $duration['min'] )) ? $duration['min']. 'M' : '0M'; |
|
4682 | - $output .= ( isset( $duration['sec']) && ( 0 < $duration['sec'] )) ? $duration['sec']. 'S' : '0S'; |
|
4680 | + $output .= (isset($duration['hour']) && (0 < $duration['hour'])) ? $duration['hour'].'H' : '0H'; |
|
4681 | + $output .= (isset($duration['min']) && (0 < $duration['min'])) ? $duration['min'].'M' : '0M'; |
|
4682 | + $output .= (isset($duration['sec']) && (0 < $duration['sec'])) ? $duration['sec'].'S' : '0S'; |
|
4683 | 4683 | } |
4684 | 4684 | } |
4685 | 4685 | return $output; |
@@ -4693,23 +4693,23 @@ discard block |
||
4693 | 4693 | * @param array $recurdata |
4694 | 4694 | * @return string |
4695 | 4695 | */ |
4696 | - function _format_recur( $recurlabel, $recurdata ) { |
|
4696 | + function _format_recur($recurlabel, $recurdata) { |
|
4697 | 4697 | $output = null; |
4698 | - foreach( $recurdata as $therule ) { |
|
4699 | - if( empty( $therule['value'] )) { |
|
4700 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $recurlabel ); |
|
4698 | + foreach ($recurdata as $therule) { |
|
4699 | + if (empty($therule['value'])) { |
|
4700 | + if ($this->getConfig('allowEmpty')) $output .= $this->_createElement($recurlabel); |
|
4701 | 4701 | continue; |
4702 | 4702 | } |
4703 | - $attributes = ( isset( $therule['params'] )) ? $this->_createParams( $therule['params'] ) : null; |
|
4704 | - $content1 = $content2 = null; |
|
4705 | - foreach( $therule['value'] as $rulelabel => $rulevalue ) { |
|
4706 | - switch( $rulelabel ) { |
|
4703 | + $attributes = (isset($therule['params'])) ? $this->_createParams($therule['params']) : null; |
|
4704 | + $content1 = $content2 = null; |
|
4705 | + foreach ($therule['value'] as $rulelabel => $rulevalue) { |
|
4706 | + switch ($rulelabel) { |
|
4707 | 4707 | case 'FREQ': |
4708 | 4708 | $content1 .= "FREQ=$rulevalue"; |
4709 | 4709 | break; |
4710 | 4710 | case 'UNTIL': |
4711 | 4711 | $content2 .= ";UNTIL="; |
4712 | - $content2 .= $this->_format_date_time( $rulevalue ); |
|
4712 | + $content2 .= $this->_format_date_time($rulevalue); |
|
4713 | 4713 | break; |
4714 | 4714 | case 'COUNT': |
4715 | 4715 | case 'INTERVAL': |
@@ -4725,9 +4725,9 @@ discard block |
||
4725 | 4725 | case 'BYMONTH': |
4726 | 4726 | case 'BYSETPOS': |
4727 | 4727 | $content2 .= ";$rulelabel="; |
4728 | - if (is_array( $rulevalue )) { |
|
4729 | - foreach( $rulevalue as $vix => $valuePart ) { |
|
4730 | - $content2 .= ( $vix ) ? ',' : null; |
|
4728 | + if (is_array($rulevalue)) { |
|
4729 | + foreach ($rulevalue as $vix => $valuePart) { |
|
4730 | + $content2 .= ($vix) ? ',' : null; |
|
4731 | 4731 | $content2 .= $valuePart; |
4732 | 4732 | } |
4733 | 4733 | } else { |
@@ -4737,12 +4737,12 @@ discard block |
||
4737 | 4737 | case 'BYDAY': |
4738 | 4738 | $content2 .= ";$rulelabel="; |
4739 | 4739 | $bydaycnt = 0; |
4740 | - foreach( $rulevalue as $vix => $valuePart ) { |
|
4740 | + foreach ($rulevalue as $vix => $valuePart) { |
|
4741 | 4741 | $content21 = $content22 = null; |
4742 | - if( is_array( $valuePart )) { |
|
4743 | - $content2 .= ( $bydaycnt ) ? ',' : null; |
|
4744 | - foreach( $valuePart as $vix2 => $valuePart2 ) { |
|
4745 | - if( 'DAY' != strtoupper( $vix2 )) |
|
4742 | + if (is_array($valuePart)) { |
|
4743 | + $content2 .= ($bydaycnt) ? ',' : null; |
|
4744 | + foreach ($valuePart as $vix2 => $valuePart2) { |
|
4745 | + if ('DAY' != strtoupper($vix2)) |
|
4746 | 4746 | $content21 .= $valuePart2; |
4747 | 4747 | else |
4748 | 4748 | $content22 .= $valuePart2; |
@@ -4751,8 +4751,8 @@ discard block |
||
4751 | 4751 | $bydaycnt++; |
4752 | 4752 | } |
4753 | 4753 | else { |
4754 | - $content2 .= ( $bydaycnt ) ? ',' : null; |
|
4755 | - if( 'DAY' != strtoupper( $vix )) |
|
4754 | + $content2 .= ($bydaycnt) ? ',' : null; |
|
4755 | + if ('DAY' != strtoupper($vix)) |
|
4756 | 4756 | $content21 .= $valuePart; |
4757 | 4757 | else { |
4758 | 4758 | $content22 .= $valuePart; |
@@ -4767,7 +4767,7 @@ discard block |
||
4767 | 4767 | break; |
4768 | 4768 | } |
4769 | 4769 | } |
4770 | - $output .= $this->_createElement( $recurlabel, $attributes, $content1.$content2 ); |
|
4770 | + $output .= $this->_createElement($recurlabel, $attributes, $content1.$content2); |
|
4771 | 4771 | } |
4772 | 4772 | return $output; |
4773 | 4773 | } |
@@ -4779,13 +4779,13 @@ discard block |
||
4779 | 4779 | * @param string $propertyName |
4780 | 4780 | * @return string |
4781 | 4781 | */ |
4782 | - function _formatPropertyName( $propertyName ) { |
|
4783 | - switch( $this->format ) { |
|
4782 | + function _formatPropertyName($propertyName) { |
|
4783 | + switch ($this->format) { |
|
4784 | 4784 | case 'xcal': |
4785 | - return strtolower( $propertyName ); |
|
4785 | + return strtolower($propertyName); |
|
4786 | 4786 | break; |
4787 | 4787 | default: |
4788 | - return strtoupper( $propertyName ); |
|
4788 | + return strtoupper($propertyName); |
|
4789 | 4789 | break; |
4790 | 4790 | } |
4791 | 4791 | } |
@@ -4797,25 +4797,25 @@ discard block |
||
4797 | 4797 | * @param array $input |
4798 | 4798 | * @return bool |
4799 | 4799 | */ |
4800 | - function _isArrayDate( $input ) { |
|
4801 | - if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 )))) |
|
4800 | + function _isArrayDate($input) { |
|
4801 | + if (isset($input['week']) || (!in_array(count($input), array(3, 6, 7)))) |
|
4802 | 4802 | return FALSE; |
4803 | - if( 7 == count( $input )) |
|
4803 | + if (7 == count($input)) |
|
4804 | 4804 | return TRUE; |
4805 | - if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) |
|
4806 | - return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
4807 | - if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] )) |
|
4805 | + if (isset($input['year']) && isset($input['month']) && isset($input['day'])) |
|
4806 | + return checkdate((int) $input['month'], (int) $input['day'], (int) $input['year']); |
|
4807 | + if (isset($input['day']) || isset($input['hour']) || isset($input['min']) || isset($input['sec'])) |
|
4808 | 4808 | return FALSE; |
4809 | - if( in_array( 0, $input )) |
|
4809 | + if (in_array(0, $input)) |
|
4810 | 4810 | return FALSE; |
4811 | - if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] )) |
|
4811 | + if ((1970 > $input[0]) || (12 < $input[1]) || (31 < $input[2])) |
|
4812 | 4812 | return FALSE; |
4813 | - if(( isset( $input[0] ) && isset( $input[1] ) && isset( $input[2] )) && |
|
4814 | - checkdate( (int) $input[1], (int) $input[2], (int) $input[0] )) |
|
4813 | + if ((isset($input[0]) && isset($input[1]) && isset($input[2])) && |
|
4814 | + checkdate((int) $input[1], (int) $input[2], (int) $input[0])) |
|
4815 | 4815 | return TRUE; |
4816 | - $input = $this->_date_time_string( $input[1].'/'.$input[2].'/'.$input[0], 3 ); // m - d - Y |
|
4817 | - if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) |
|
4818 | - return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
4816 | + $input = $this->_date_time_string($input[1].'/'.$input[2].'/'.$input[0], 3); // m - d - Y |
|
4817 | + if (isset($input['year']) && isset($input['month']) && isset($input['day'])) |
|
4818 | + return checkdate((int) $input['month'], (int) $input['day'], (int) $input['year']); |
|
4819 | 4819 | return FALSE; |
4820 | 4820 | } |
4821 | 4821 | /** |
@@ -4826,8 +4826,8 @@ discard block |
||
4826 | 4826 | * @param array $input |
4827 | 4827 | * @return bool |
4828 | 4828 | */ |
4829 | - function _isArrayTimestampDate( $input ) { |
|
4830 | - return ( is_array( $input ) && isset( $input['timestamp'] )) ? TRUE : FALSE ; |
|
4829 | + function _isArrayTimestampDate($input) { |
|
4830 | + return (is_array($input) && isset($input['timestamp'])) ? TRUE : FALSE; |
|
4831 | 4831 | } |
4832 | 4832 | /** |
4833 | 4833 | * controll if input string contains traling UTC offset |
@@ -4837,17 +4837,17 @@ discard block |
||
4837 | 4837 | * @param string $input |
4838 | 4838 | * @return bool |
4839 | 4839 | */ |
4840 | - function _isOffset( $input ) { |
|
4841 | - $input = trim( (string) $input ); |
|
4842 | - if( 'Z' == substr( $input, -1 )) |
|
4840 | + function _isOffset($input) { |
|
4841 | + $input = trim((string) $input); |
|
4842 | + if ('Z' == substr($input, -1)) |
|
4843 | 4843 | return TRUE; |
4844 | - elseif(( 5 <= strlen( $input )) && |
|
4845 | - ( in_array( substr( $input, -5, 1 ), array( '+', '-' ))) && |
|
4846 | - ( '0000' < substr( $input, -4 )) && ( '9999' >= substr( $input, -4 ))) |
|
4844 | + elseif ((5 <= strlen($input)) && |
|
4845 | + (in_array(substr($input, -5, 1), array('+', '-'))) && |
|
4846 | + ('0000' < substr($input, -4)) && ('9999' >= substr($input, -4))) |
|
4847 | 4847 | return TRUE; |
4848 | - elseif(( 7 <= strlen( $input )) && |
|
4849 | - ( in_array( substr( $input, -7, 1 ), array( '+', '-' ))) && |
|
4850 | - ( '000000' < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 ))) |
|
4848 | + elseif ((7 <= strlen($input)) && |
|
4849 | + (in_array(substr($input, -7, 1), array('+', '-'))) && |
|
4850 | + ('000000' < substr($input, -6)) && ('999999' >= substr($input, -6))) |
|
4851 | 4851 | return TRUE; |
4852 | 4852 | return FALSE; |
4853 | 4853 | |
@@ -4860,15 +4860,15 @@ discard block |
||
4860 | 4860 | * @param string $propName |
4861 | 4861 | * @return bool |
4862 | 4862 | */ |
4863 | - function _notExistProp( $propName ) { |
|
4864 | - if( empty( $propName )) return FALSE; // when deleting x-prop, an empty propName may be used=allowed |
|
4865 | - $propName = strtolower( $propName ); |
|
4866 | - if( 'last-modified' == $propName ) { if( !isset( $this->lastmodified )) return TRUE; } |
|
4867 | - elseif( 'percent-complete' == $propName ) { if( !isset( $this->percentcomplete )) return TRUE; } |
|
4868 | - elseif( 'recurrence-id' == $propName ) { if( !isset( $this->recurrenceid )) return TRUE; } |
|
4869 | - elseif( 'related-to' == $propName ) { if( !isset( $this->relatedto )) return TRUE; } |
|
4870 | - elseif( 'request-status' == $propName ) { if( !isset( $this->requeststatus )) return TRUE; } |
|
4871 | - elseif(( 'x-' != substr($propName,0,2)) && !isset( $this->$propName )) return TRUE; |
|
4863 | + function _notExistProp($propName) { |
|
4864 | + if (empty($propName)) return FALSE; // when deleting x-prop, an empty propName may be used=allowed |
|
4865 | + $propName = strtolower($propName); |
|
4866 | + if ('last-modified' == $propName) { if (!isset($this->lastmodified)) return TRUE; } |
|
4867 | + elseif ('percent-complete' == $propName) { if (!isset($this->percentcomplete)) return TRUE; } |
|
4868 | + elseif ('recurrence-id' == $propName) { if (!isset($this->recurrenceid)) return TRUE; } |
|
4869 | + elseif ('related-to' == $propName) { if (!isset($this->relatedto)) return TRUE; } |
|
4870 | + elseif ('request-status' == $propName) { if (!isset($this->requeststatus)) return TRUE; } |
|
4871 | + elseif (('x-' != substr($propName, 0, 2)) && !isset($this->$propName)) return TRUE; |
|
4872 | 4872 | return FALSE; |
4873 | 4873 | } |
4874 | 4874 | /** |
@@ -4886,101 +4886,101 @@ discard block |
||
4886 | 4886 | * @return array of recurrence (start-)dates as index |
4887 | 4887 | * @todo BYHOUR, BYMINUTE, BYSECOND, ev. BYSETPOS due to ambiguity, WEEKLY at year end/start |
4888 | 4888 | */ |
4889 | - function _recur2date( & $result, $recur, $wdate, $startdate, $enddate=FALSE ) { |
|
4890 | - foreach( $wdate as $k => $v ) if( ctype_digit( $v )) $wdate[$k] = (int) $v; |
|
4891 | - $wdatets = $this->_date2timestamp( $wdate ); |
|
4892 | - $startdatets = $this->_date2timestamp( $startdate ); |
|
4893 | - if( !$enddate ) { |
|
4889 | + function _recur2date(& $result, $recur, $wdate, $startdate, $enddate = FALSE) { |
|
4890 | + foreach ($wdate as $k => $v) if (ctype_digit($v)) $wdate[$k] = (int) $v; |
|
4891 | + $wdatets = $this->_date2timestamp($wdate); |
|
4892 | + $startdatets = $this->_date2timestamp($startdate); |
|
4893 | + if (!$enddate) { |
|
4894 | 4894 | $enddate = $startdate; |
4895 | 4895 | $enddate['year'] += 1; |
4896 | 4896 | // echo "recur __in_ ".implode('-',$startdate)." period start ".implode('-',$wdate)." period end ".implode('-',$enddate)."<br />\n";print_r($recur);echo "<br />\n";//test### |
4897 | 4897 | } |
4898 | - $endDatets = $this->_date2timestamp( $enddate ); // fix break |
|
4899 | - if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] )) |
|
4898 | + $endDatets = $this->_date2timestamp($enddate); // fix break |
|
4899 | + if (!isset($recur['COUNT']) && !isset($recur['UNTIL'])) |
|
4900 | 4900 | $recur['UNTIL'] = $enddate; // create break |
4901 | - if( isset( $recur['UNTIL'] )) { |
|
4902 | - $tdatets = $this->_date2timestamp( $recur['UNTIL'] ); |
|
4903 | - if( $endDatets > $tdatets ) { |
|
4901 | + if (isset($recur['UNTIL'])) { |
|
4902 | + $tdatets = $this->_date2timestamp($recur['UNTIL']); |
|
4903 | + if ($endDatets > $tdatets) { |
|
4904 | 4904 | $endDatets = $tdatets; // emergency break |
4905 | - $enddate = $this->_timestamp2date( $endDatets, 6 ); |
|
4905 | + $enddate = $this->_timestamp2date($endDatets, 6); |
|
4906 | 4906 | } |
4907 | 4907 | else |
4908 | - $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 ); |
|
4908 | + $recur['UNTIL'] = $this->_timestamp2date($endDatets, 6); |
|
4909 | 4909 | } |
4910 | - if( $wdatets > $endDatets ) { |
|
4910 | + if ($wdatets > $endDatets) { |
|
4911 | 4911 | //echo "recur out of date ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test |
4912 | 4912 | return array(); // nothing to do.. . |
4913 | 4913 | } |
4914 | - if( !isset( $recur['FREQ'] )) // "MUST be specified.. ." |
|
4914 | + if (!isset($recur['FREQ'])) // "MUST be specified.. ." |
|
4915 | 4915 | $recur['FREQ'] = 'DAILY'; // ?? |
4916 | - $wkst = ( isset( $recur['WKST'] ) && ( 'SU' == $recur['WKST'] )) ? 24*60*60 : 0; // ?? |
|
4917 | - if( !isset( $recur['INTERVAL'] )) |
|
4916 | + $wkst = (isset($recur['WKST']) && ('SU' == $recur['WKST'])) ? 24 * 60 * 60 : 0; // ?? |
|
4917 | + if (!isset($recur['INTERVAL'])) |
|
4918 | 4918 | $recur['INTERVAL'] = 1; |
4919 | - $countcnt = ( !isset( $recur['BYSETPOS'] )) ? 1 : 0; // DTSTART counts as the first occurrence |
|
4919 | + $countcnt = (!isset($recur['BYSETPOS'])) ? 1 : 0; // DTSTART counts as the first occurrence |
|
4920 | 4920 | /* find out how to step up dates and set index for interval count */ |
4921 | 4921 | $step = array(); |
4922 | - if( 'YEARLY' == $recur['FREQ'] ) |
|
4922 | + if ('YEARLY' == $recur['FREQ']) |
|
4923 | 4923 | $step['year'] = 1; |
4924 | - elseif( 'MONTHLY' == $recur['FREQ'] ) |
|
4924 | + elseif ('MONTHLY' == $recur['FREQ']) |
|
4925 | 4925 | $step['month'] = 1; |
4926 | - elseif( 'WEEKLY' == $recur['FREQ'] ) |
|
4926 | + elseif ('WEEKLY' == $recur['FREQ']) |
|
4927 | 4927 | $step['day'] = 7; |
4928 | 4928 | else |
4929 | 4929 | $step['day'] = 1; |
4930 | - if( isset( $step['year'] ) && isset( $recur['BYMONTH'] )) |
|
4931 | - $step = array( 'month' => 1 ); |
|
4932 | - if( empty( $step ) && isset( $recur['BYWEEKNO'] )) // ?? |
|
4933 | - $step = array( 'day' => 7 ); |
|
4934 | - if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] )) |
|
4935 | - $step = array( 'day' => 1 ); |
|
4930 | + if (isset($step['year']) && isset($recur['BYMONTH'])) |
|
4931 | + $step = array('month' => 1); |
|
4932 | + if (empty($step) && isset($recur['BYWEEKNO'])) // ?? |
|
4933 | + $step = array('day' => 7); |
|
4934 | + if (isset($recur['BYYEARDAY']) || isset($recur['BYMONTHDAY']) || isset($recur['BYDAY'])) |
|
4935 | + $step = array('day' => 1); |
|
4936 | 4936 | $intervalarr = array(); |
4937 | - if( 1 < $recur['INTERVAL'] ) { |
|
4938 | - $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst ); |
|
4939 | - $intervalarr = array( $intervalix => 0 ); |
|
4937 | + if (1 < $recur['INTERVAL']) { |
|
4938 | + $intervalix = $this->_recurIntervalIx($recur['FREQ'], $wdate, $wkst); |
|
4939 | + $intervalarr = array($intervalix => 0); |
|
4940 | 4940 | } |
4941 | - if( isset( $recur['BYSETPOS'] )) { // save start date + weekno |
|
4941 | + if (isset($recur['BYSETPOS'])) { // save start date + weekno |
|
4942 | 4942 | $bysetposymd1 = $bysetposymd2 = $bysetposw1 = $bysetposw2 = array(); |
4943 | - $bysetposWold = (int) date( 'W', ( $wdatets + $wkst )); |
|
4943 | + $bysetposWold = (int) date('W', ($wdatets + $wkst)); |
|
4944 | 4944 | $bysetposYold = $wdate['year']; |
4945 | 4945 | $bysetposMold = $wdate['month']; |
4946 | 4946 | $bysetposDold = $wdate['day']; |
4947 | - if( is_array( $recur['BYSETPOS'] )) { |
|
4948 | - foreach( $recur['BYSETPOS'] as $bix => $bval ) |
|
4947 | + if (is_array($recur['BYSETPOS'])) { |
|
4948 | + foreach ($recur['BYSETPOS'] as $bix => $bval) |
|
4949 | 4949 | $recur['BYSETPOS'][$bix] = (int) $bval; |
4950 | 4950 | } |
4951 | 4951 | else |
4952 | - $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] ); |
|
4953 | - $this->_stepdate( $enddate, $endDatets, $step); // make sure to count whole last period |
|
4952 | + $recur['BYSETPOS'] = array((int) $recur['BYSETPOS']); |
|
4953 | + $this->_stepdate($enddate, $endDatets, $step); // make sure to count whole last period |
|
4954 | 4954 | } |
4955 | - $this->_stepdate( $wdate, $wdatets, $step); |
|
4955 | + $this->_stepdate($wdate, $wdatets, $step); |
|
4956 | 4956 | $year_old = null; |
4957 | - $daynames = array( 'SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA' ); |
|
4957 | + $daynames = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'); |
|
4958 | 4958 | /* MAIN LOOP */ |
4959 | 4959 | // echo "recur start ".implode('-',$wdate)." end ".implode('-',$enddate)."<br />\n";//test |
4960 | - while( TRUE ) { |
|
4961 | - if( isset( $endDatets ) && ( $wdatets > $endDatets )) |
|
4960 | + while (TRUE) { |
|
4961 | + if (isset($endDatets) && ($wdatets > $endDatets)) |
|
4962 | 4962 | break; |
4963 | - if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) |
|
4963 | + if (isset($recur['COUNT']) && ($countcnt >= $recur['COUNT'])) |
|
4964 | 4964 | break; |
4965 | - if( $year_old != $wdate['year'] ) { |
|
4965 | + if ($year_old != $wdate['year']) { |
|
4966 | 4966 | $year_old = $wdate['year']; |
4967 | 4967 | $daycnts = array(); |
4968 | 4968 | $yeardays = $weekno = 0; |
4969 | 4969 | $yeardaycnt = array(); |
4970 | - for( $m = 1; $m <= 12; $m++ ) { // count up and update up-counters |
|
4970 | + for ($m = 1; $m <= 12; $m++) { // count up and update up-counters |
|
4971 | 4971 | $daycnts[$m] = array(); |
4972 | 4972 | $weekdaycnt = array(); |
4973 | - foreach( $daynames as $dn ) |
|
4973 | + foreach ($daynames as $dn) |
|
4974 | 4974 | $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
4975 | - $mcnt = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] )); |
|
4976 | - for( $d = 1; $d <= $mcnt; $d++ ) { |
|
4975 | + $mcnt = date('t', mktime(0, 0, 0, $m, 1, $wdate['year'])); |
|
4976 | + for ($d = 1; $d <= $mcnt; $d++) { |
|
4977 | 4977 | $daycnts[$m][$d] = array(); |
4978 | - if( isset( $recur['BYYEARDAY'] )) { |
|
4978 | + if (isset($recur['BYYEARDAY'])) { |
|
4979 | 4979 | $yeardays++; |
4980 | 4980 | $daycnts[$m][$d]['yearcnt_up'] = $yeardays; |
4981 | 4981 | } |
4982 | - if( isset( $recur['BYDAY'] )) { |
|
4983 | - $day = date( 'w', mktime( 0, 0, 0, $m, $d, $wdate['year'] )); |
|
4982 | + if (isset($recur['BYDAY'])) { |
|
4983 | + $day = date('w', mktime(0, 0, 0, $m, $d, $wdate['year'])); |
|
4984 | 4984 | $day = $daynames[$day]; |
4985 | 4985 | $daycnts[$m][$d]['DAY'] = $day; |
4986 | 4986 | $weekdaycnt[$day]++; |
@@ -4988,64 +4988,64 @@ discard block |
||
4988 | 4988 | $yeardaycnt[$day]++; |
4989 | 4989 | $daycnts[$m][$d]['yeardayno_up'] = $yeardaycnt[$day]; |
4990 | 4990 | } |
4991 | - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) |
|
4992 | - $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year'])); |
|
4991 | + if (isset($recur['BYWEEKNO']) || ($recur['FREQ'] == 'WEEKLY')) |
|
4992 | + $daycnts[$m][$d]['weekno_up'] = (int) date('W', mktime(0, 0, $wkst, $m, $d, $wdate['year'])); |
|
4993 | 4993 | } |
4994 | 4994 | } |
4995 | 4995 | $daycnt = 0; |
4996 | 4996 | $yeardaycnt = array(); |
4997 | - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) { |
|
4997 | + if (isset($recur['BYWEEKNO']) || ($recur['FREQ'] == 'WEEKLY')) { |
|
4998 | 4998 | $weekno = null; |
4999 | - for( $d=31; $d > 25; $d-- ) { // get last weekno for year |
|
5000 | - if( !$weekno ) |
|
4999 | + for ($d = 31; $d > 25; $d--) { // get last weekno for year |
|
5000 | + if (!$weekno) |
|
5001 | 5001 | $weekno = $daycnts[12][$d]['weekno_up']; |
5002 | - elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) { |
|
5002 | + elseif ($weekno < $daycnts[12][$d]['weekno_up']) { |
|
5003 | 5003 | $weekno = $daycnts[12][$d]['weekno_up']; |
5004 | 5004 | break; |
5005 | 5005 | } |
5006 | 5006 | } |
5007 | 5007 | } |
5008 | - for( $m = 12; $m > 0; $m-- ) { // count down and update down-counters |
|
5008 | + for ($m = 12; $m > 0; $m--) { // count down and update down-counters |
|
5009 | 5009 | $weekdaycnt = array(); |
5010 | - foreach( $daynames as $dn ) |
|
5010 | + foreach ($daynames as $dn) |
|
5011 | 5011 | $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
5012 | 5012 | $monthcnt = 0; |
5013 | - $mcnt = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] )); |
|
5014 | - for( $d = $mcnt; $d > 0; $d-- ) { |
|
5015 | - if( isset( $recur['BYYEARDAY'] )) { |
|
5013 | + $mcnt = date('t', mktime(0, 0, 0, $m, 1, $wdate['year'])); |
|
5014 | + for ($d = $mcnt; $d > 0; $d--) { |
|
5015 | + if (isset($recur['BYYEARDAY'])) { |
|
5016 | 5016 | $daycnt -= 1; |
5017 | 5017 | $daycnts[$m][$d]['yearcnt_down'] = $daycnt; |
5018 | 5018 | } |
5019 | - if( isset( $recur['BYMONTHDAY'] )) { |
|
5019 | + if (isset($recur['BYMONTHDAY'])) { |
|
5020 | 5020 | $monthcnt -= 1; |
5021 | 5021 | $daycnts[$m][$d]['monthcnt_down'] = $monthcnt; |
5022 | 5022 | } |
5023 | - if( isset( $recur['BYDAY'] )) { |
|
5024 | - $day = $daycnts[$m][$d]['DAY']; |
|
5023 | + if (isset($recur['BYDAY'])) { |
|
5024 | + $day = $daycnts[$m][$d]['DAY']; |
|
5025 | 5025 | $weekdaycnt[$day] -= 1; |
5026 | 5026 | $daycnts[$m][$d]['monthdayno_down'] = $weekdaycnt[$day]; |
5027 | 5027 | $yeardaycnt[$day] -= 1; |
5028 | 5028 | $daycnts[$m][$d]['yeardayno_down'] = $yeardaycnt[$day]; |
5029 | 5029 | } |
5030 | - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) |
|
5030 | + if (isset($recur['BYWEEKNO']) || ($recur['FREQ'] == 'WEEKLY')) |
|
5031 | 5031 | $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1); |
5032 | 5032 | } |
5033 | 5033 | } |
5034 | 5034 | } |
5035 | 5035 | /* check interval */ |
5036 | - if( 1 < $recur['INTERVAL'] ) { |
|
5036 | + if (1 < $recur['INTERVAL']) { |
|
5037 | 5037 | /* create interval index */ |
5038 | - $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst ); |
|
5038 | + $intervalix = $this->_recurIntervalIx($recur['FREQ'], $wdate, $wkst); |
|
5039 | 5039 | /* check interval */ |
5040 | - $currentKey = array_keys( $intervalarr ); |
|
5041 | - $currentKey = end( $currentKey ); // get last index |
|
5042 | - if( $currentKey != $intervalix ) |
|
5043 | - $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 )); |
|
5044 | - if(( $recur['INTERVAL'] != $intervalarr[$intervalix] ) && |
|
5045 | - ( 0 != $intervalarr[$intervalix] )) { |
|
5040 | + $currentKey = array_keys($intervalarr); |
|
5041 | + $currentKey = end($currentKey); // get last index |
|
5042 | + if ($currentKey != $intervalix) |
|
5043 | + $intervalarr = array($intervalix => ($intervalarr[$currentKey] + 1)); |
|
5044 | + if (($recur['INTERVAL'] != $intervalarr[$intervalix]) && |
|
5045 | + (0 != $intervalarr[$intervalix])) { |
|
5046 | 5046 | /* step up date */ |
5047 | 5047 | //echo "skip: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test |
5048 | - $this->_stepdate( $wdate, $wdatets, $step); |
|
5048 | + $this->_stepdate($wdate, $wdatets, $step); |
|
5049 | 5049 | continue; |
5050 | 5050 | } |
5051 | 5051 | else // continue within the selected interval |
@@ -5053,69 +5053,69 @@ discard block |
||
5053 | 5053 | //echo "cont: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test |
5054 | 5054 | } |
5055 | 5055 | $updateOK = TRUE; |
5056 | - if( $updateOK && isset( $recur['BYMONTH'] )) |
|
5057 | - $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH'] |
|
5056 | + if ($updateOK && isset($recur['BYMONTH'])) |
|
5057 | + $updateOK = $this->_recurBYcntcheck($recur['BYMONTH'] |
|
5058 | 5058 | , $wdate['month'] |
5059 | 5059 | ,($wdate['month'] - 13)); |
5060 | - if( $updateOK && isset( $recur['BYWEEKNO'] )) |
|
5061 | - $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO'] |
|
5060 | + if ($updateOK && isset($recur['BYWEEKNO'])) |
|
5061 | + $updateOK = $this->_recurBYcntcheck($recur['BYWEEKNO'] |
|
5062 | 5062 | , $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] |
5063 | - , $daycnts[$wdate['month']][$wdate['day']]['weekno_down'] ); |
|
5064 | - if( $updateOK && isset( $recur['BYYEARDAY'] )) |
|
5065 | - $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY'] |
|
5063 | + , $daycnts[$wdate['month']][$wdate['day']]['weekno_down']); |
|
5064 | + if ($updateOK && isset($recur['BYYEARDAY'])) |
|
5065 | + $updateOK = $this->_recurBYcntcheck($recur['BYYEARDAY'] |
|
5066 | 5066 | , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_up'] |
5067 | - , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down'] ); |
|
5068 | - if( $updateOK && isset( $recur['BYMONTHDAY'] )) |
|
5069 | - $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY'] |
|
5067 | + , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down']); |
|
5068 | + if ($updateOK && isset($recur['BYMONTHDAY'])) |
|
5069 | + $updateOK = $this->_recurBYcntcheck($recur['BYMONTHDAY'] |
|
5070 | 5070 | , $wdate['day'] |
5071 | - , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down'] ); |
|
5071 | + , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down']); |
|
5072 | 5072 | //echo "efter BYMONTHDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n";//test### |
5073 | - if( $updateOK && isset( $recur['BYDAY'] )) { |
|
5073 | + if ($updateOK && isset($recur['BYDAY'])) { |
|
5074 | 5074 | $updateOK = FALSE; |
5075 | 5075 | $m = $wdate['month']; |
5076 | 5076 | $d = $wdate['day']; |
5077 | - if( isset( $recur['BYDAY']['DAY'] )) { // single day, opt with year/month day order no |
|
5078 | - $daynoexists = $daynosw = $daynamesw = FALSE; |
|
5079 | - if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] ) |
|
5077 | + if (isset($recur['BYDAY']['DAY'])) { // single day, opt with year/month day order no |
|
5078 | + $daynoexists = $daynosw = $daynamesw = FALSE; |
|
5079 | + if ($recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY']) |
|
5080 | 5080 | $daynamesw = TRUE; |
5081 | - if( isset( $recur['BYDAY'][0] )) { |
|
5081 | + if (isset($recur['BYDAY'][0])) { |
|
5082 | 5082 | $daynoexists = TRUE; |
5083 | - if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] )) |
|
5084 | - $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5083 | + if ((isset($recur['FREQ']) && ($recur['FREQ'] == 'MONTHLY')) || isset($recur['BYMONTH'])) |
|
5084 | + $daynosw = $this->_recurBYcntcheck($recur['BYDAY'][0] |
|
5085 | 5085 | , $daycnts[$m][$d]['monthdayno_up'] |
5086 | - , $daycnts[$m][$d]['monthdayno_down'] ); |
|
5087 | - elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) |
|
5088 | - $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5086 | + , $daycnts[$m][$d]['monthdayno_down']); |
|
5087 | + elseif (isset($recur['FREQ']) && ($recur['FREQ'] == 'YEARLY')) |
|
5088 | + $daynosw = $this->_recurBYcntcheck($recur['BYDAY'][0] |
|
5089 | 5089 | , $daycnts[$m][$d]['yeardayno_up'] |
5090 | - , $daycnts[$m][$d]['yeardayno_down'] ); |
|
5090 | + , $daycnts[$m][$d]['yeardayno_down']); |
|
5091 | 5091 | } |
5092 | - if(( $daynoexists && $daynosw && $daynamesw ) || |
|
5093 | - ( !$daynoexists && !$daynosw && $daynamesw )) { |
|
5092 | + if (($daynoexists && $daynosw && $daynamesw) || |
|
5093 | + (!$daynoexists && !$daynosw && $daynamesw)) { |
|
5094 | 5094 | $updateOK = TRUE; |
5095 | 5095 | } |
5096 | 5096 | //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ### |
5097 | 5097 | } |
5098 | 5098 | else { |
5099 | - foreach( $recur['BYDAY'] as $bydayvalue ) { |
|
5099 | + foreach ($recur['BYDAY'] as $bydayvalue) { |
|
5100 | 5100 | $daynoexists = $daynosw = $daynamesw = FALSE; |
5101 | - if( isset( $bydayvalue['DAY'] ) && |
|
5102 | - ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] )) |
|
5101 | + if (isset($bydayvalue['DAY']) && |
|
5102 | + ($bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'])) |
|
5103 | 5103 | $daynamesw = TRUE; |
5104 | - if( isset( $bydayvalue[0] )) { |
|
5104 | + if (isset($bydayvalue[0])) { |
|
5105 | 5105 | $daynoexists = TRUE; |
5106 | - if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || |
|
5107 | - isset( $recur['BYMONTH'] )) |
|
5108 | - $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5106 | + if ((isset($recur['FREQ']) && ($recur['FREQ'] == 'MONTHLY')) || |
|
5107 | + isset($recur['BYMONTH'])) |
|
5108 | + $daynosw = $this->_recurBYcntcheck($bydayvalue['0'] |
|
5109 | 5109 | , $daycnts[$m][$d]['monthdayno_up'] |
5110 | - , $daycnts[$m][$d]['monthdayno_down'] ); |
|
5111 | - elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) |
|
5112 | - $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5110 | + , $daycnts[$m][$d]['monthdayno_down']); |
|
5111 | + elseif (isset($recur['FREQ']) && ($recur['FREQ'] == 'YEARLY')) |
|
5112 | + $daynosw = $this->_recurBYcntcheck($bydayvalue['0'] |
|
5113 | 5113 | , $daycnts[$m][$d]['yeardayno_up'] |
5114 | - , $daycnts[$m][$d]['yeardayno_down'] ); |
|
5114 | + , $daycnts[$m][$d]['yeardayno_down']); |
|
5115 | 5115 | } |
5116 | 5116 | //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ### |
5117 | - if(( $daynoexists && $daynosw && $daynamesw ) || |
|
5118 | - ( !$daynoexists && !$daynosw && $daynamesw )) { |
|
5117 | + if (($daynoexists && $daynosw && $daynamesw) || |
|
5118 | + (!$daynoexists && !$daynosw && $daynamesw)) { |
|
5119 | 5119 | $updateOK = TRUE; |
5120 | 5120 | break; |
5121 | 5121 | } |
@@ -5124,25 +5124,25 @@ discard block |
||
5124 | 5124 | } |
5125 | 5125 | //echo "efter BYDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n"; // test ### |
5126 | 5126 | /* check BYSETPOS */ |
5127 | - if( $updateOK ) { |
|
5128 | - if( isset( $recur['BYSETPOS'] ) && |
|
5129 | - ( in_array( $recur['FREQ'], array( 'YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY' )))) { |
|
5130 | - if( isset( $recur['WEEKLY'] )) { |
|
5131 | - if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] ) |
|
5127 | + if ($updateOK) { |
|
5128 | + if (isset($recur['BYSETPOS']) && |
|
5129 | + (in_array($recur['FREQ'], array('YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY')))) { |
|
5130 | + if (isset($recur['WEEKLY'])) { |
|
5131 | + if ($bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up']) |
|
5132 | 5132 | $bysetposw1[] = $wdatets; |
5133 | 5133 | else |
5134 | 5134 | $bysetposw2[] = $wdatets; |
5135 | 5135 | } |
5136 | 5136 | else { |
5137 | - if(( isset( $recur['FREQ'] ) && ( 'YEARLY' == $recur['FREQ'] ) && |
|
5138 | - ( $bysetposYold == $wdate['year'] )) || |
|
5139 | - ( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] ) && |
|
5140 | - (( $bysetposYold == $wdate['year'] ) && |
|
5141 | - ( $bysetposMold == $wdate['month'] ))) || |
|
5142 | - ( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] ) && |
|
5143 | - (( $bysetposYold == $wdate['year'] ) && |
|
5144 | - ( $bysetposMold == $wdate['month']) && |
|
5145 | - ( $bysetposDold == $wdate['sday'] )))) |
|
5137 | + if ((isset($recur['FREQ']) && ('YEARLY' == $recur['FREQ']) && |
|
5138 | + ($bysetposYold == $wdate['year'])) || |
|
5139 | + (isset($recur['FREQ']) && ('MONTHLY' == $recur['FREQ']) && |
|
5140 | + (($bysetposYold == $wdate['year']) && |
|
5141 | + ($bysetposMold == $wdate['month']))) || |
|
5142 | + (isset($recur['FREQ']) && ('MONTHLY' == $recur['FREQ']) && |
|
5143 | + (($bysetposYold == $wdate['year']) && |
|
5144 | + ($bysetposMold == $wdate['month']) && |
|
5145 | + ($bysetposDold == $wdate['sday'])))) |
|
5146 | 5146 | $bysetposymd1[] = $wdatets; |
5147 | 5147 | else |
5148 | 5148 | $bysetposymd2[] = $wdatets; |
@@ -5151,7 +5151,7 @@ discard block |
||
5151 | 5151 | else { |
5152 | 5152 | /* update result array if BYSETPOS is set */ |
5153 | 5153 | $countcnt++; |
5154 | - if( $startdatets <= $wdatets ) { // only output within period |
|
5154 | + if ($startdatets <= $wdatets) { // only output within period |
|
5155 | 5155 | $result[$wdatets] = TRUE; |
5156 | 5156 | //echo "recur ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test |
5157 | 5157 | } |
@@ -5160,39 +5160,39 @@ discard block |
||
5160 | 5160 | } |
5161 | 5161 | } |
5162 | 5162 | /* step up date */ |
5163 | - $this->_stepdate( $wdate, $wdatets, $step); |
|
5163 | + $this->_stepdate($wdate, $wdatets, $step); |
|
5164 | 5164 | /* check if BYSETPOS is set for updating result array */ |
5165 | - if( $updateOK && isset( $recur['BYSETPOS'] )) { |
|
5166 | - $bysetpos = FALSE; |
|
5167 | - if( isset( $recur['FREQ'] ) && ( 'YEARLY' == $recur['FREQ'] ) && |
|
5168 | - ( $bysetposYold != $wdate['year'] )) { |
|
5165 | + if ($updateOK && isset($recur['BYSETPOS'])) { |
|
5166 | + $bysetpos = FALSE; |
|
5167 | + if (isset($recur['FREQ']) && ('YEARLY' == $recur['FREQ']) && |
|
5168 | + ($bysetposYold != $wdate['year'])) { |
|
5169 | 5169 | $bysetpos = TRUE; |
5170 | 5170 | $bysetposYold = $wdate['year']; |
5171 | 5171 | } |
5172 | - elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] && |
|
5173 | - (( $bysetposYold != $wdate['year'] ) || ( $bysetposMold != $wdate['month'] )))) { |
|
5172 | + elseif (isset($recur['FREQ']) && ('MONTHLY' == $recur['FREQ'] && |
|
5173 | + (($bysetposYold != $wdate['year']) || ($bysetposMold != $wdate['month'])))) { |
|
5174 | 5174 | $bysetpos = TRUE; |
5175 | 5175 | $bysetposYold = $wdate['year']; |
5176 | 5176 | $bysetposMold = $wdate['month']; |
5177 | 5177 | } |
5178 | - elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY' == $recur['FREQ'] )) { |
|
5179 | - $weekno = (int) date( 'W', mktime( 0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year'])); |
|
5180 | - if( $bysetposWold != $weekno ) { |
|
5178 | + elseif (isset($recur['FREQ']) && ('WEEKLY' == $recur['FREQ'])) { |
|
5179 | + $weekno = (int) date('W', mktime(0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year'])); |
|
5180 | + if ($bysetposWold != $weekno) { |
|
5181 | 5181 | $bysetposWold = $weekno; |
5182 | 5182 | $bysetpos = TRUE; |
5183 | 5183 | } |
5184 | 5184 | } |
5185 | - elseif( isset( $recur['FREQ'] ) && ( 'DAILY' == $recur['FREQ'] ) && |
|
5186 | - (( $bysetposYold != $wdate['year'] ) || |
|
5187 | - ( $bysetposMold != $wdate['month'] ) || |
|
5188 | - ( $bysetposDold != $wdate['sday'] ))) { |
|
5185 | + elseif (isset($recur['FREQ']) && ('DAILY' == $recur['FREQ']) && |
|
5186 | + (($bysetposYold != $wdate['year']) || |
|
5187 | + ($bysetposMold != $wdate['month']) || |
|
5188 | + ($bysetposDold != $wdate['sday']))) { |
|
5189 | 5189 | $bysetpos = TRUE; |
5190 | 5190 | $bysetposYold = $wdate['year']; |
5191 | 5191 | $bysetposMold = $wdate['month']; |
5192 | 5192 | $bysetposDold = $wdate['day']; |
5193 | 5193 | } |
5194 | - if( $bysetpos ) { |
|
5195 | - if( isset( $recur['BYWEEKNO'] )) { |
|
5194 | + if ($bysetpos) { |
|
5195 | + if (isset($recur['BYWEEKNO'])) { |
|
5196 | 5196 | $bysetposarr1 = & $bysetposw1; |
5197 | 5197 | $bysetposarr2 = & $bysetposw2; |
5198 | 5198 | } |
@@ -5200,18 +5200,18 @@ discard block |
||
5200 | 5200 | $bysetposarr1 = & $bysetposymd1; |
5201 | 5201 | $bysetposarr2 = & $bysetposymd2; |
5202 | 5202 | } |
5203 | - foreach( $recur['BYSETPOS'] as $ix ) { |
|
5204 | - if( 0 > $ix ) // both positive and negative BYSETPOS allowed |
|
5205 | - $ix = ( count( $bysetposarr1 ) + $ix + 1); |
|
5203 | + foreach ($recur['BYSETPOS'] as $ix) { |
|
5204 | + if (0 > $ix) // both positive and negative BYSETPOS allowed |
|
5205 | + $ix = (count($bysetposarr1) + $ix + 1); |
|
5206 | 5206 | $ix--; |
5207 | - if( isset( $bysetposarr1[$ix] )) { |
|
5208 | - if( $startdatets <= $bysetposarr1[$ix] ) { // only output within period |
|
5207 | + if (isset($bysetposarr1[$ix])) { |
|
5208 | + if ($startdatets <= $bysetposarr1[$ix]) { // only output within period |
|
5209 | 5209 | $result[$bysetposarr1[$ix]] = TRUE; |
5210 | 5210 | //echo "recur ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$bysetposarr1[$ix]),6))."<br />\n";//test |
5211 | 5211 | } |
5212 | 5212 | $countcnt++; |
5213 | 5213 | } |
5214 | - if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) |
|
5214 | + if (isset($recur['COUNT']) && ($countcnt >= $recur['COUNT'])) |
|
5215 | 5215 | break; |
5216 | 5216 | } |
5217 | 5217 | $bysetposarr1 = $bysetposarr2; |
@@ -5220,18 +5220,18 @@ discard block |
||
5220 | 5220 | } |
5221 | 5221 | } |
5222 | 5222 | } |
5223 | - function _recurBYcntcheck( $BYvalue, $upValue, $downValue ) { |
|
5224 | - if( is_array( $BYvalue ) && |
|
5225 | - ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue ))) |
|
5223 | + function _recurBYcntcheck($BYvalue, $upValue, $downValue) { |
|
5224 | + if (is_array($BYvalue) && |
|
5225 | + (in_array($upValue, $BYvalue) || in_array($downValue, $BYvalue))) |
|
5226 | 5226 | return TRUE; |
5227 | - elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue )) |
|
5227 | + elseif (($BYvalue == $upValue) || ($BYvalue == $downValue)) |
|
5228 | 5228 | return TRUE; |
5229 | 5229 | else |
5230 | 5230 | return FALSE; |
5231 | 5231 | } |
5232 | - function _recurIntervalIx( $freq, $date, $wkst ) { |
|
5232 | + function _recurIntervalIx($freq, $date, $wkst) { |
|
5233 | 5233 | /* create interval index */ |
5234 | - switch( $freq ) { |
|
5234 | + switch ($freq) { |
|
5235 | 5235 | case 'YEARLY': |
5236 | 5236 | $intervalix = $date['year']; |
5237 | 5237 | break; |
@@ -5239,8 +5239,8 @@ discard block |
||
5239 | 5239 | $intervalix = $date['year'].'-'.$date['month']; |
5240 | 5240 | break; |
5241 | 5241 | case 'WEEKLY': |
5242 | - $wdatets = $this->_date2timestamp( $date ); |
|
5243 | - $intervalix = (int) date( 'W', ( $wdatets + $wkst )); |
|
5242 | + $wdatets = $this->_date2timestamp($date); |
|
5243 | + $intervalix = (int) date('W', ($wdatets + $wkst)); |
|
5244 | 5244 | break; |
5245 | 5245 | case 'DAILY': |
5246 | 5246 | default: |
@@ -5257,22 +5257,22 @@ discard block |
||
5257 | 5257 | * @param array $rexrule |
5258 | 5258 | * @return array |
5259 | 5259 | */ |
5260 | - function _setRexrule( $rexrule ) { |
|
5261 | - $input = array(); |
|
5262 | - if( empty( $rexrule )) |
|
5260 | + function _setRexrule($rexrule) { |
|
5261 | + $input = array(); |
|
5262 | + if (empty($rexrule)) |
|
5263 | 5263 | return $input; |
5264 | - foreach( $rexrule as $rexrulelabel => $rexrulevalue ) { |
|
5265 | - $rexrulelabel = strtoupper( $rexrulelabel ); |
|
5266 | - if( 'UNTIL' != $rexrulelabel ) |
|
5267 | - $input[$rexrulelabel] = $rexrulevalue; |
|
5264 | + foreach ($rexrule as $rexrulelabel => $rexrulevalue) { |
|
5265 | + $rexrulelabel = strtoupper($rexrulelabel); |
|
5266 | + if ('UNTIL' != $rexrulelabel) |
|
5267 | + $input[$rexrulelabel] = $rexrulevalue; |
|
5268 | 5268 | else { |
5269 | - if( $this->_isArrayTimestampDate( $rexrulevalue )) // timestamp date |
|
5270 | - $input[$rexrulelabel] = $this->_timestamp2date( $rexrulevalue, 6 ); |
|
5271 | - elseif( $this->_isArrayDate( $rexrulevalue )) // date-time |
|
5272 | - $input[$rexrulelabel] = $this->_date_time_array( $rexrulevalue, 6 ); |
|
5273 | - elseif( 8 <= strlen( trim( $rexrulevalue ))) // ex. 2006-08-03 10:12:18 |
|
5274 | - $input[$rexrulelabel] = $this->_date_time_string( $rexrulevalue ); |
|
5275 | - if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] )) |
|
5269 | + if ($this->_isArrayTimestampDate($rexrulevalue)) // timestamp date |
|
5270 | + $input[$rexrulelabel] = $this->_timestamp2date($rexrulevalue, 6); |
|
5271 | + elseif ($this->_isArrayDate($rexrulevalue)) // date-time |
|
5272 | + $input[$rexrulelabel] = $this->_date_time_array($rexrulevalue, 6); |
|
5273 | + elseif (8 <= strlen(trim($rexrulevalue))) // ex. 2006-08-03 10:12:18 |
|
5274 | + $input[$rexrulelabel] = $this->_date_time_string($rexrulevalue); |
|
5275 | + if ((3 < count($input[$rexrulelabel])) && !isset($input[$rexrulelabel]['tz'])) |
|
5276 | 5276 | $input[$rexrulelabel]['tz'] = 'Z'; |
5277 | 5277 | } |
5278 | 5278 | } |
@@ -5293,85 +5293,85 @@ discard block |
||
5293 | 5293 | * @param string $caller optional |
5294 | 5294 | * @return array |
5295 | 5295 | */ |
5296 | - function _setDate( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE, $caller=null ) { |
|
5296 | + function _setDate($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $tz = FALSE, $params = FALSE, $caller = null) { |
|
5297 | 5297 | $input = $parno = null; |
5298 | - $localtime = (( 'dtstart' == $caller ) && in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE; |
|
5299 | - if( $this->_isArrayDate( $year )) { |
|
5300 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5301 | - $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
|
5302 | - if( isset( $input['params']['TZID'] )) { |
|
5298 | + $localtime = (('dtstart' == $caller) && in_array($this->objName, array('vtimezone', 'standard', 'daylight'))) ? TRUE : FALSE; |
|
5299 | + if ($this->_isArrayDate($year)) { |
|
5300 | + if ($localtime) unset ($month['VALUE'], $month['TZID']); |
|
5301 | + $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME')); |
|
5302 | + if (isset($input['params']['TZID'])) { |
|
5303 | 5303 | $input['params']['VALUE'] = 'DATE-TIME'; |
5304 | - unset( $year['tz'] ); |
|
5304 | + unset($year['tz']); |
|
5305 | 5305 | } |
5306 | - $hitval = (( !empty( $year['tz'] ) || !empty( $year[6] ))) ? 7 : 6; |
|
5307 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval ); |
|
5308 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, count( $year ), $parno ); |
|
5309 | - $input['value'] = $this->_date_time_array( $year, $parno ); |
|
5310 | - } |
|
5311 | - elseif( $this->_isArrayTimestampDate( $year )) { |
|
5312 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5313 | - $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
|
5314 | - if( isset( $input['params']['TZID'] )) { |
|
5306 | + $hitval = ((!empty($year['tz']) || !empty($year[6]))) ? 7 : 6; |
|
5307 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', $hitval); |
|
5308 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE', 3, count($year), $parno); |
|
5309 | + $input['value'] = $this->_date_time_array($year, $parno); |
|
5310 | + } |
|
5311 | + elseif ($this->_isArrayTimestampDate($year)) { |
|
5312 | + if ($localtime) unset ($month['VALUE'], $month['TZID']); |
|
5313 | + $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME')); |
|
5314 | + if (isset($input['params']['TZID'])) { |
|
5315 | 5315 | $input['params']['VALUE'] = 'DATE-TIME'; |
5316 | - unset( $year['tz'] ); |
|
5316 | + unset($year['tz']); |
|
5317 | 5317 | } |
5318 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3 ); |
|
5319 | - $hitval = ( isset( $year['tz'] )) ? 7 : 6; |
|
5320 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno ); |
|
5321 | - $input['value'] = $this->_timestamp2date( $year, $parno ); |
|
5322 | - } |
|
5323 | - elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
5324 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5325 | - $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
|
5326 | - if( isset( $input['params']['TZID'] )) { |
|
5318 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE', 3); |
|
5319 | + $hitval = (isset($year['tz'])) ? 7 : 6; |
|
5320 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno); |
|
5321 | + $input['value'] = $this->_timestamp2date($year, $parno); |
|
5322 | + } |
|
5323 | + elseif (8 <= strlen(trim($year))) { // ex. 2006-08-03 10:12:18 |
|
5324 | + if ($localtime) unset ($month['VALUE'], $month['TZID']); |
|
5325 | + $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME')); |
|
5326 | + if (isset($input['params']['TZID'])) { |
|
5327 | 5327 | $input['params']['VALUE'] = 'DATE-TIME'; |
5328 | 5328 | $parno = 6; |
5329 | 5329 | } |
5330 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7, $parno ); |
|
5331 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, $parno, $parno ); |
|
5332 | - $input['value'] = $this->_date_time_string( $year, $parno ); |
|
5330 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', 7, $parno); |
|
5331 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE', 3, $parno, $parno); |
|
5332 | + $input['value'] = $this->_date_time_string($year, $parno); |
|
5333 | 5333 | } |
5334 | 5334 | else { |
5335 | - if( is_array( $params )) { |
|
5336 | - if( $localtime ) unset ( $params['VALUE'], $params['TZID'] ); |
|
5337 | - $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )); |
|
5335 | + if (is_array($params)) { |
|
5336 | + if ($localtime) unset ($params['VALUE'], $params['TZID']); |
|
5337 | + $input['params'] = $this->_setParams($params, array('VALUE' => 'DATE-TIME')); |
|
5338 | 5338 | } |
5339 | - elseif( is_array( $tz )) { |
|
5340 | - $input['params'] = $this->_setParams( $tz, array( 'VALUE' => 'DATE-TIME' )); |
|
5339 | + elseif (is_array($tz)) { |
|
5340 | + $input['params'] = $this->_setParams($tz, array('VALUE' => 'DATE-TIME')); |
|
5341 | 5341 | $tz = FALSE; |
5342 | 5342 | } |
5343 | - elseif( is_array( $hour )) { |
|
5344 | - $input['params'] = $this->_setParams( $hour, array( 'VALUE' => 'DATE-TIME' )); |
|
5343 | + elseif (is_array($hour)) { |
|
5344 | + $input['params'] = $this->_setParams($hour, array('VALUE' => 'DATE-TIME')); |
|
5345 | 5345 | $hour = $min = $sec = $tz = FALSE; |
5346 | 5346 | } |
5347 | - if( isset( $input['params']['TZID'] )) { |
|
5348 | - $tz = null; |
|
5347 | + if (isset($input['params']['TZID'])) { |
|
5348 | + $tz = null; |
|
5349 | 5349 | $input['params']['VALUE'] = 'DATE-TIME'; |
5350 | 5350 | } |
5351 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3 ); |
|
5352 | - $hitval = ( !empty( $tz )) ? 7 : 6; |
|
5353 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno, $parno ); |
|
5354 | - $input['value'] = array( 'year' => $year, 'month' => $month, 'day' => $day ); |
|
5355 | - if( 3 != $parno ) { |
|
5356 | - $input['value']['hour'] = ( $hour ) ? $hour : '0'; |
|
5357 | - $input['value']['min'] = ( $min ) ? $min : '0'; |
|
5358 | - $input['value']['sec'] = ( $sec ) ? $sec : '0'; |
|
5359 | - if( !empty( $tz )) |
|
5351 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE', 3); |
|
5352 | + $hitval = (!empty($tz)) ? 7 : 6; |
|
5353 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno, $parno); |
|
5354 | + $input['value'] = array('year' => $year, 'month' => $month, 'day' => $day); |
|
5355 | + if (3 != $parno) { |
|
5356 | + $input['value']['hour'] = ($hour) ? $hour : '0'; |
|
5357 | + $input['value']['min'] = ($min) ? $min : '0'; |
|
5358 | + $input['value']['sec'] = ($sec) ? $sec : '0'; |
|
5359 | + if (!empty($tz)) |
|
5360 | 5360 | $input['value']['tz'] = $tz; |
5361 | 5361 | } |
5362 | 5362 | } |
5363 | - if( 3 == $parno ) { |
|
5363 | + if (3 == $parno) { |
|
5364 | 5364 | $input['params']['VALUE'] = 'DATE'; |
5365 | - unset( $input['value']['tz'] ); |
|
5366 | - unset( $input['params']['TZID'] ); |
|
5365 | + unset($input['value']['tz']); |
|
5366 | + unset($input['params']['TZID']); |
|
5367 | 5367 | } |
5368 | - elseif( isset( $input['params']['TZID'] )) |
|
5369 | - unset( $input['value']['tz'] ); |
|
5370 | - if( $localtime ) unset( $input['value']['tz'], $input['params']['TZID'] ); |
|
5371 | - if( isset( $input['value']['tz'] )) |
|
5368 | + elseif (isset($input['params']['TZID'])) |
|
5369 | + unset($input['value']['tz']); |
|
5370 | + if ($localtime) unset($input['value']['tz'], $input['params']['TZID']); |
|
5371 | + if (isset($input['value']['tz'])) |
|
5372 | 5372 | $input['value']['tz'] = (string) $input['value']['tz']; |
5373 | - if( !empty( $input['value']['tz'] ) && ( 'Z' != $input['value']['tz'] ) && |
|
5374 | - ( !$this->_isOffset( $input['value']['tz'] ))) |
|
5373 | + if (!empty($input['value']['tz']) && ('Z' != $input['value']['tz']) && |
|
5374 | + (!$this->_isOffset($input['value']['tz']))) |
|
5375 | 5375 | $input['params']['TZID'] = $input['value']['tz']; |
5376 | 5376 | return $input; |
5377 | 5377 | } |
@@ -5389,37 +5389,37 @@ discard block |
||
5389 | 5389 | * @param array $params optional |
5390 | 5390 | * @return array |
5391 | 5391 | */ |
5392 | - function _setDate2( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
|
5392 | + function _setDate2($year, $month = FALSE, $day = FALSE, $hour = FALSE, $min = FALSE, $sec = FALSE, $params = FALSE) { |
|
5393 | 5393 | $input = null; |
5394 | - if( $this->_isArrayDate( $year )) { |
|
5395 | - $input['value'] = $this->_date_time_array( $year, 7 ); |
|
5396 | - $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
|
5394 | + if ($this->_isArrayDate($year)) { |
|
5395 | + $input['value'] = $this->_date_time_array($year, 7); |
|
5396 | + $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME')); |
|
5397 | 5397 | } |
5398 | - elseif( $this->_isArrayTimestampDate( $year )) { |
|
5399 | - $input['value'] = $this->_timestamp2date( $year, 7 ); |
|
5400 | - $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
|
5398 | + elseif ($this->_isArrayTimestampDate($year)) { |
|
5399 | + $input['value'] = $this->_timestamp2date($year, 7); |
|
5400 | + $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME')); |
|
5401 | 5401 | } |
5402 | - elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
5403 | - $input['value'] = $this->_date_time_string( $year, 7 ); |
|
5404 | - $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
|
5402 | + elseif (8 <= strlen(trim($year))) { // ex. 2006-08-03 10:12:18 |
|
5403 | + $input['value'] = $this->_date_time_string($year, 7); |
|
5404 | + $input['params'] = $this->_setParams($month, array('VALUE' => 'DATE-TIME')); |
|
5405 | 5405 | } |
5406 | 5406 | else { |
5407 | - $input['value'] = array( 'year' => $year |
|
5407 | + $input['value'] = array('year' => $year |
|
5408 | 5408 | , 'month' => $month |
5409 | 5409 | , 'day' => $day |
5410 | 5410 | , 'hour' => $hour |
5411 | 5411 | , 'min' => $min |
5412 | - , 'sec' => $sec ); |
|
5413 | - $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )); |
|
5412 | + , 'sec' => $sec); |
|
5413 | + $input['params'] = $this->_setParams($params, array('VALUE' => 'DATE-TIME')); |
|
5414 | 5414 | } |
5415 | - $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7 ); // remove default |
|
5416 | - if( !isset( $input['value']['hour'] )) |
|
5415 | + $parno = $this->_existRem($input['params'], 'VALUE', 'DATE-TIME', 7); // remove default |
|
5416 | + if (!isset($input['value']['hour'])) |
|
5417 | 5417 | $input['value']['hour'] = 0; |
5418 | - if( !isset( $input['value']['min'] )) |
|
5418 | + if (!isset($input['value']['min'])) |
|
5419 | 5419 | $input['value']['min'] = 0; |
5420 | - if( !isset( $input['value']['sec'] )) |
|
5420 | + if (!isset($input['value']['sec'])) |
|
5421 | 5421 | $input['value']['sec'] = 0; |
5422 | - if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] )) |
|
5422 | + if (!isset($input['value']['tz']) || !$this->_isOffset($input['value']['tz'])) |
|
5423 | 5423 | $input['value']['tz'] = 'Z'; |
5424 | 5424 | return $input; |
5425 | 5425 | } |
@@ -5435,18 +5435,18 @@ discard block |
||
5435 | 5435 | * @param int $index |
5436 | 5436 | * @return void |
5437 | 5437 | */ |
5438 | - function _setMval( & $valArr, $value, $params=FALSE, $defaults=FALSE, $index=FALSE ) { |
|
5439 | - if( !is_array( $valArr )) $valArr = array(); |
|
5440 | - if( $index ) |
|
5438 | + function _setMval(& $valArr, $value, $params = FALSE, $defaults = FALSE, $index = FALSE) { |
|
5439 | + if (!is_array($valArr)) $valArr = array(); |
|
5440 | + if ($index) |
|
5441 | 5441 | $index = $index - 1; |
5442 | - elseif( 0 < count( $valArr )) { |
|
5443 | - $index = end( array_keys( $valArr )); |
|
5442 | + elseif (0 < count($valArr)) { |
|
5443 | + $index = end(array_keys($valArr)); |
|
5444 | 5444 | $index += 1; |
5445 | 5445 | } |
5446 | 5446 | else |
5447 | 5447 | $index = 0; |
5448 | - $valArr[$index] = array( 'value' => $value, 'params' => $this->_setParams( $params, $defaults )); |
|
5449 | - ksort( $valArr ); |
|
5448 | + $valArr[$index] = array('value' => $value, 'params' => $this->_setParams($params, $defaults)); |
|
5449 | + ksort($valArr); |
|
5450 | 5450 | } |
5451 | 5451 | /** |
5452 | 5452 | * set input (formatted) parameters- component property attributes |
@@ -5459,31 +5459,31 @@ discard block |
||
5459 | 5459 | * @param array $defaults |
5460 | 5460 | * @return array |
5461 | 5461 | */ |
5462 | - function _setParams( $params, $defaults=FALSE ) { |
|
5463 | - if( !is_array( $params)) |
|
5462 | + function _setParams($params, $defaults = FALSE) { |
|
5463 | + if (!is_array($params)) |
|
5464 | 5464 | $params = array(); |
5465 | 5465 | $input = array(); |
5466 | - foreach( $params as $paramKey => $paramValue ) { |
|
5467 | - if( is_array( $paramValue )) { |
|
5468 | - foreach( $paramValue as $pkey => $pValue ) { |
|
5469 | - if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 ))) |
|
5470 | - $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 )); |
|
5466 | + foreach ($params as $paramKey => $paramValue) { |
|
5467 | + if (is_array($paramValue)) { |
|
5468 | + foreach ($paramValue as $pkey => $pValue) { |
|
5469 | + if (('"' == substr($pValue, 0, 1)) && ('"' == substr($pValue, -1))) |
|
5470 | + $paramValue[$pkey] = substr($pValue, 1, (strlen($pValue) - 2)); |
|
5471 | 5471 | } |
5472 | 5472 | } |
5473 | - elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 ))) |
|
5474 | - $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 )); |
|
5475 | - if( 'VALUE' == strtoupper( $paramKey )) |
|
5476 | - $input['VALUE'] = strtoupper( $paramValue ); |
|
5473 | + elseif (('"' == substr($paramValue, 0, 1)) && ('"' == substr($paramValue, -1))) |
|
5474 | + $paramValue = substr($paramValue, 1, (strlen($paramValue) - 2)); |
|
5475 | + if ('VALUE' == strtoupper($paramKey)) |
|
5476 | + $input['VALUE'] = strtoupper($paramValue); |
|
5477 | 5477 | else |
5478 | - $input[strtoupper( $paramKey )] = $paramValue; |
|
5478 | + $input[strtoupper($paramKey)] = $paramValue; |
|
5479 | 5479 | } |
5480 | - if( is_array( $defaults )) { |
|
5481 | - foreach( $defaults as $paramKey => $paramValue ) { |
|
5482 | - if( !isset( $input[$paramKey] )) |
|
5480 | + if (is_array($defaults)) { |
|
5481 | + foreach ($defaults as $paramKey => $paramValue) { |
|
5482 | + if (!isset($input[$paramKey])) |
|
5483 | 5483 | $input[$paramKey] = $paramValue; |
5484 | 5484 | } |
5485 | 5485 | } |
5486 | - return (0 < count( $input )) ? $input : null; |
|
5486 | + return (0 < count($input)) ? $input : null; |
|
5487 | 5487 | } |
5488 | 5488 | /** |
5489 | 5489 | * step date, return updated date, array and timpstamp |
@@ -5495,13 +5495,13 @@ discard block |
||
5495 | 5495 | * @param array $step, default array( 'day' => 1 ) |
5496 | 5496 | * @return void |
5497 | 5497 | */ |
5498 | - function _stepdate( &$date, &$timestamp, $step=array( 'day' => 1 )) { |
|
5499 | - foreach( $step as $stepix => $stepvalue ) |
|
5498 | + function _stepdate(&$date, &$timestamp, $step = array('day' => 1)) { |
|
5499 | + foreach ($step as $stepix => $stepvalue) |
|
5500 | 5500 | $date[$stepix] += $stepvalue; |
5501 | - $timestamp = $this->_date2timestamp( $date ); |
|
5502 | - $date = $this->_timestamp2date( $timestamp, 6 ); |
|
5503 | - foreach( $date as $k => $v ) { |
|
5504 | - if( ctype_digit( $v )) |
|
5501 | + $timestamp = $this->_date2timestamp($date); |
|
5502 | + $date = $this->_timestamp2date($timestamp, 6); |
|
5503 | + foreach ($date as $k => $v) { |
|
5504 | + if (ctype_digit($v)) |
|
5505 | 5505 | $date[$k] = (int) $v; |
5506 | 5506 | } |
5507 | 5507 | } |
@@ -5514,20 +5514,20 @@ discard block |
||
5514 | 5514 | * @param int $parno |
5515 | 5515 | * @return array |
5516 | 5516 | */ |
5517 | - function _timestamp2date( $timestamp, $parno=6 ) { |
|
5518 | - if( is_array( $timestamp )) { |
|
5519 | - if(( 7 == $parno ) && !empty( $timestamp['tz'] )) |
|
5517 | + function _timestamp2date($timestamp, $parno = 6) { |
|
5518 | + if (is_array($timestamp)) { |
|
5519 | + if ((7 == $parno) && !empty($timestamp['tz'])) |
|
5520 | 5520 | $tz = $timestamp['tz']; |
5521 | 5521 | $timestamp = $timestamp['timestamp']; |
5522 | 5522 | } |
5523 | - $output = array( 'year' => date( 'Y', $timestamp ) |
|
5524 | - , 'month' => date( 'm', $timestamp ) |
|
5525 | - , 'day' => date( 'd', $timestamp )); |
|
5526 | - if( 3 != $parno ) { |
|
5527 | - $output['hour'] = date( 'H', $timestamp ); |
|
5528 | - $output['min'] = date( 'i', $timestamp ); |
|
5529 | - $output['sec'] = date( 's', $timestamp ); |
|
5530 | - if( isset( $tz )) |
|
5523 | + $output = array('year' => date('Y', $timestamp) |
|
5524 | + , 'month' => date('m', $timestamp) |
|
5525 | + , 'day' => date('d', $timestamp)); |
|
5526 | + if (3 != $parno) { |
|
5527 | + $output['hour'] = date('H', $timestamp); |
|
5528 | + $output['min'] = date('i', $timestamp); |
|
5529 | + $output['sec'] = date('s', $timestamp); |
|
5530 | + if (isset($tz)) |
|
5531 | 5531 | $output['tz'] = $tz; |
5532 | 5532 | } |
5533 | 5533 | return $output; |
@@ -5540,19 +5540,19 @@ discard block |
||
5540 | 5540 | * @param string $offset |
5541 | 5541 | * @return integer |
5542 | 5542 | */ |
5543 | - function _tz2offset( $tz ) { |
|
5544 | - $tz = trim( (string) $tz ); |
|
5543 | + function _tz2offset($tz) { |
|
5544 | + $tz = trim((string) $tz); |
|
5545 | 5545 | $offset = 0; |
5546 | - if((( 5 != strlen( $tz )) && ( 7 != strlen( $tz ))) || |
|
5547 | - (( '+' != substr( $tz, 0, 1 )) && ( '-' != substr( $tz, 0, 1 ))) || |
|
5548 | - (( '0000' >= substr( $tz, 1, 4 )) && ( '9999' < substr( $tz, 1, 4 ))) || |
|
5549 | - (( 7 == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 )))) |
|
5546 | + if (((5 != strlen($tz)) && (7 != strlen($tz))) || |
|
5547 | + (('+' != substr($tz, 0, 1)) && ('-' != substr($tz, 0, 1))) || |
|
5548 | + (('0000' >= substr($tz, 1, 4)) && ('9999' < substr($tz, 1, 4))) || |
|
5549 | + ((7 == strlen($tz)) && ('00' > substr($tz, 5, 2)) && ('99' < substr($tz, 5, 2)))) |
|
5550 | 5550 | return $offset; |
5551 | - $hours2sec = (int) substr( $tz, 1, 2 ) * 3600; |
|
5552 | - $min2sec = (int) substr( $tz, 3, 2 ) * 60; |
|
5553 | - $sec = ( 7 == strlen( $tz )) ? (int) substr( $tz, -2 ) : '00'; |
|
5551 | + $hours2sec = (int) substr($tz, 1, 2) * 3600; |
|
5552 | + $min2sec = (int) substr($tz, 3, 2) * 60; |
|
5553 | + $sec = (7 == strlen($tz)) ? (int) substr($tz, -2) : '00'; |
|
5554 | 5554 | $offset = $hours2sec + $min2sec + $sec; |
5555 | - $offset = ('-' == substr( $tz, 0, 1 )) ? $offset : -1 * $offset; |
|
5555 | + $offset = ('-' == substr($tz, 0, 1)) ? $offset : -1 * $offset; |
|
5556 | 5556 | return $offset; |
5557 | 5557 | } |
5558 | 5558 | /*********************************************************************************/ |
@@ -5565,24 +5565,24 @@ discard block |
||
5565 | 5565 | * @param string $config |
5566 | 5566 | * @return value |
5567 | 5567 | */ |
5568 | - function getConfig( $config ) { |
|
5569 | - switch( strtoupper( $config )) { |
|
5568 | + function getConfig($config) { |
|
5569 | + switch (strtoupper($config)) { |
|
5570 | 5570 | case 'ALLOWEMPTY': |
5571 | 5571 | return $this->allowEmpty; |
5572 | 5572 | break; |
5573 | 5573 | case 'COMPSINFO': |
5574 | - unset( $this->compix ); |
|
5574 | + unset($this->compix); |
|
5575 | 5575 | $info = array(); |
5576 | - if( isset( $this->components )) { |
|
5577 | - foreach( $this->components as $cix => $component ) { |
|
5578 | - if( empty( $component )) continue; |
|
5579 | - unset( $component->propix ); |
|
5576 | + if (isset($this->components)) { |
|
5577 | + foreach ($this->components as $cix => $component) { |
|
5578 | + if (empty($component)) continue; |
|
5579 | + unset($component->propix); |
|
5580 | 5580 | $info[$cix]['ordno'] = $cix + 1; |
5581 | 5581 | $info[$cix]['type'] = $component->objName; |
5582 | - $info[$cix]['uid'] = $component->getProperty( 'uid' ); |
|
5583 | - $info[$cix]['props'] = $component->getConfig( 'propinfo' ); |
|
5584 | - $info[$cix]['sub'] = $component->getConfig( 'compsinfo' ); |
|
5585 | - unset( $component->propix ); |
|
5582 | + $info[$cix]['uid'] = $component->getProperty('uid'); |
|
5583 | + $info[$cix]['props'] = $component->getConfig('propinfo'); |
|
5584 | + $info[$cix]['sub'] = $component->getConfig('compsinfo'); |
|
5585 | + unset($component->propix); |
|
5586 | 5586 | } |
5587 | 5587 | } |
5588 | 5588 | return $info; |
@@ -5600,58 +5600,58 @@ discard block |
||
5600 | 5600 | break; |
5601 | 5601 | case 'PROPINFO': |
5602 | 5602 | $output = array(); |
5603 | - if( !in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
5604 | - if( empty( $this->uid['value'] )) $this->_makeuid(); |
|
5605 | - $output['UID'] = 1; |
|
5603 | + if (!in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) { |
|
5604 | + if (empty($this->uid['value'])) $this->_makeuid(); |
|
5605 | + $output['UID'] = 1; |
|
5606 | 5606 | } |
5607 | - if( !empty( $this->dtstamp )) $output['DTSTAMP'] = 1; |
|
5608 | - if( !empty( $this->summary )) $output['SUMMARY'] = 1; |
|
5609 | - if( !empty( $this->description )) $output['DESCRIPTION'] = count( $this->description ); |
|
5610 | - if( !empty( $this->dtstart )) $output['DTSTART'] = 1; |
|
5611 | - if( !empty( $this->dtend )) $output['DTEND'] = 1; |
|
5612 | - if( !empty( $this->due )) $output['DUE'] = 1; |
|
5613 | - if( !empty( $this->duration )) $output['DURATION'] = 1; |
|
5614 | - if( !empty( $this->rrule )) $output['RRULE'] = count( $this->rrule ); |
|
5615 | - if( !empty( $this->rdate )) $output['RDATE'] = count( $this->rdate ); |
|
5616 | - if( !empty( $this->exdate )) $output['EXDATE'] = count( $this->exdate ); |
|
5617 | - if( !empty( $this->exrule )) $output['EXRULE'] = count( $this->exrule ); |
|
5618 | - if( !empty( $this->action )) $output['ACTION'] = 1; |
|
5619 | - if( !empty( $this->attach )) $output['ATTACH'] = count( $this->attach ); |
|
5620 | - if( !empty( $this->attendee )) $output['ATTENDEE'] = count( $this->attendee ); |
|
5621 | - if( !empty( $this->categories )) $output['CATEGORIES'] = count( $this->categories ); |
|
5622 | - if( !empty( $this->class )) $output['CLASS'] = 1; |
|
5623 | - if( !empty( $this->comment )) $output['COMMENT'] = count( $this->comment ); |
|
5624 | - if( !empty( $this->completed )) $output['COMPLETED'] = 1; |
|
5625 | - if( !empty( $this->contact )) $output['CONTACT'] = count( $this->contact ); |
|
5626 | - if( !empty( $this->created )) $output['CREATED'] = 1; |
|
5627 | - if( !empty( $this->freebusy )) $output['FREEBUSY'] = count( $this->freebusy ); |
|
5628 | - if( !empty( $this->geo )) $output['GEO'] = 1; |
|
5629 | - if( !empty( $this->lastmodified )) $output['LAST-MODIFIED'] = 1; |
|
5630 | - if( !empty( $this->location )) $output['LOCATION'] = 1; |
|
5631 | - if( !empty( $this->organizer )) $output['ORGANIZER'] = 1; |
|
5632 | - if( !empty( $this->percentcomplete )) $output['PERCENT-COMPLETE'] = 1; |
|
5633 | - if( !empty( $this->priority )) $output['PRIORITY'] = 1; |
|
5634 | - if( !empty( $this->recurrenceid )) $output['RECURRENCE-ID'] = 1; |
|
5635 | - if( !empty( $this->relatedto )) $output['RELATED-TO'] = count( $this->relatedto ); |
|
5636 | - if( !empty( $this->repeat )) $output['REPEAT'] = 1; |
|
5637 | - if( !empty( $this->requeststatus )) $output['REQUEST-STATUS'] = count( $this->requeststatus ); |
|
5638 | - if( !empty( $this->resources )) $output['RESOURCES'] = count( $this->resources ); |
|
5639 | - if( !empty( $this->sequence )) $output['SEQUENCE'] = 1; |
|
5640 | - if( !empty( $this->status )) $output['STATUS'] = 1; |
|
5641 | - if( !empty( $this->transp )) $output['TRANSP'] = 1; |
|
5642 | - if( !empty( $this->trigger )) $output['TRIGGER'] = 1; |
|
5643 | - if( !empty( $this->tzid )) $output['TZID'] = 1; |
|
5644 | - if( !empty( $this->tzname )) $output['TZNAME'] = count( $this->tzname ); |
|
5645 | - if( !empty( $this->tzoffsetfrom )) $output['TZOFFSETTFROM'] = 1; |
|
5646 | - if( !empty( $this->tzoffsetto )) $output['TZOFFSETTO'] = 1; |
|
5647 | - if( !empty( $this->tzurl )) $output['TZURL'] = 1; |
|
5648 | - if( !empty( $this->url )) $output['URL'] = 1; |
|
5649 | - if( !empty( $this->xprop )) $output['X-PROP'] = count( $this->xprop ); |
|
5607 | + if (!empty($this->dtstamp)) $output['DTSTAMP'] = 1; |
|
5608 | + if (!empty($this->summary)) $output['SUMMARY'] = 1; |
|
5609 | + if (!empty($this->description)) $output['DESCRIPTION'] = count($this->description); |
|
5610 | + if (!empty($this->dtstart)) $output['DTSTART'] = 1; |
|
5611 | + if (!empty($this->dtend)) $output['DTEND'] = 1; |
|
5612 | + if (!empty($this->due)) $output['DUE'] = 1; |
|
5613 | + if (!empty($this->duration)) $output['DURATION'] = 1; |
|
5614 | + if (!empty($this->rrule)) $output['RRULE'] = count($this->rrule); |
|
5615 | + if (!empty($this->rdate)) $output['RDATE'] = count($this->rdate); |
|
5616 | + if (!empty($this->exdate)) $output['EXDATE'] = count($this->exdate); |
|
5617 | + if (!empty($this->exrule)) $output['EXRULE'] = count($this->exrule); |
|
5618 | + if (!empty($this->action)) $output['ACTION'] = 1; |
|
5619 | + if (!empty($this->attach)) $output['ATTACH'] = count($this->attach); |
|
5620 | + if (!empty($this->attendee)) $output['ATTENDEE'] = count($this->attendee); |
|
5621 | + if (!empty($this->categories)) $output['CATEGORIES'] = count($this->categories); |
|
5622 | + if (!empty($this->class)) $output['CLASS'] = 1; |
|
5623 | + if (!empty($this->comment)) $output['COMMENT'] = count($this->comment); |
|
5624 | + if (!empty($this->completed)) $output['COMPLETED'] = 1; |
|
5625 | + if (!empty($this->contact)) $output['CONTACT'] = count($this->contact); |
|
5626 | + if (!empty($this->created)) $output['CREATED'] = 1; |
|
5627 | + if (!empty($this->freebusy)) $output['FREEBUSY'] = count($this->freebusy); |
|
5628 | + if (!empty($this->geo)) $output['GEO'] = 1; |
|
5629 | + if (!empty($this->lastmodified)) $output['LAST-MODIFIED'] = 1; |
|
5630 | + if (!empty($this->location)) $output['LOCATION'] = 1; |
|
5631 | + if (!empty($this->organizer)) $output['ORGANIZER'] = 1; |
|
5632 | + if (!empty($this->percentcomplete)) $output['PERCENT-COMPLETE'] = 1; |
|
5633 | + if (!empty($this->priority)) $output['PRIORITY'] = 1; |
|
5634 | + if (!empty($this->recurrenceid)) $output['RECURRENCE-ID'] = 1; |
|
5635 | + if (!empty($this->relatedto)) $output['RELATED-TO'] = count($this->relatedto); |
|
5636 | + if (!empty($this->repeat)) $output['REPEAT'] = 1; |
|
5637 | + if (!empty($this->requeststatus)) $output['REQUEST-STATUS'] = count($this->requeststatus); |
|
5638 | + if (!empty($this->resources)) $output['RESOURCES'] = count($this->resources); |
|
5639 | + if (!empty($this->sequence)) $output['SEQUENCE'] = 1; |
|
5640 | + if (!empty($this->status)) $output['STATUS'] = 1; |
|
5641 | + if (!empty($this->transp)) $output['TRANSP'] = 1; |
|
5642 | + if (!empty($this->trigger)) $output['TRIGGER'] = 1; |
|
5643 | + if (!empty($this->tzid)) $output['TZID'] = 1; |
|
5644 | + if (!empty($this->tzname)) $output['TZNAME'] = count($this->tzname); |
|
5645 | + if (!empty($this->tzoffsetfrom)) $output['TZOFFSETTFROM'] = 1; |
|
5646 | + if (!empty($this->tzoffsetto)) $output['TZOFFSETTO'] = 1; |
|
5647 | + if (!empty($this->tzurl)) $output['TZURL'] = 1; |
|
5648 | + if (!empty($this->url)) $output['URL'] = 1; |
|
5649 | + if (!empty($this->xprop)) $output['X-PROP'] = count($this->xprop); |
|
5650 | 5650 | return $output; |
5651 | 5651 | break; |
5652 | 5652 | case 'UNIQUE_ID': |
5653 | - if( empty( $this->unique_id )) |
|
5654 | - $this->unique_id = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost'; |
|
5653 | + if (empty($this->unique_id)) |
|
5654 | + $this->unique_id = (isset($_SERVER['SERVER_NAME'])) ? gethostbyname($_SERVER['SERVER_NAME']) : 'localhost'; |
|
5655 | 5655 | return $this->unique_id; |
5656 | 5656 | break; |
5657 | 5657 | } |
@@ -5665,47 +5665,47 @@ discard block |
||
5665 | 5665 | * @param string $value |
5666 | 5666 | * @return void |
5667 | 5667 | */ |
5668 | - function setConfig( $config, $value ) { |
|
5668 | + function setConfig($config, $value) { |
|
5669 | 5669 | $res = FALSE; |
5670 | - switch( strtoupper( $config )) { |
|
5670 | + switch (strtoupper($config)) { |
|
5671 | 5671 | case 'ALLOWEMPTY': |
5672 | 5672 | $this->allowEmpty = $value; |
5673 | - $subcfg = array( 'ALLOWEMPTY' => $value ); |
|
5673 | + $subcfg = array('ALLOWEMPTY' => $value); |
|
5674 | 5674 | $res = TRUE; |
5675 | 5675 | break; |
5676 | 5676 | case 'FORMAT': |
5677 | - $value = trim( $value ); |
|
5677 | + $value = trim($value); |
|
5678 | 5678 | $this->format = $value; |
5679 | 5679 | $this->_createFormat(); |
5680 | - $subcfg = array( 'FORMAT' => $value ); |
|
5680 | + $subcfg = array('FORMAT' => $value); |
|
5681 | 5681 | $res = TRUE; |
5682 | 5682 | break; |
5683 | 5683 | case 'LANGUAGE': |
5684 | 5684 | // set language for calendar component as defined in [RFC 1766] |
5685 | - $value = trim( $value ); |
|
5685 | + $value = trim($value); |
|
5686 | 5686 | $this->language = $value; |
5687 | - $subcfg = array( 'LANGUAGE' => $value ); |
|
5687 | + $subcfg = array('LANGUAGE' => $value); |
|
5688 | 5688 | $res = TRUE; |
5689 | 5689 | break; |
5690 | 5690 | case 'NL': |
5691 | 5691 | case 'NEWLINECHAR': |
5692 | 5692 | $this->nl = $value; |
5693 | - $subcfg = array( 'NL' => $value ); |
|
5693 | + $subcfg = array('NL' => $value); |
|
5694 | 5694 | $res = TRUE; |
5695 | 5695 | break; |
5696 | 5696 | case 'UNIQUE_ID': |
5697 | - $value = trim( $value ); |
|
5697 | + $value = trim($value); |
|
5698 | 5698 | $this->unique_id = $value; |
5699 | - $subcfg = array( 'UNIQUE_ID' => $value ); |
|
5699 | + $subcfg = array('UNIQUE_ID' => $value); |
|
5700 | 5700 | $res = TRUE; |
5701 | 5701 | break; |
5702 | 5702 | } |
5703 | - if( !$res ) return FALSE; |
|
5704 | - if( isset( $subcfg ) && !empty( $this->components )) { |
|
5705 | - foreach( $subcfg as $cfgkey => $cfgvalue ) { |
|
5706 | - foreach( $this->components as $cix => $component ) { |
|
5707 | - $res = $component->setConfig( $cfgkey, $cfgvalue ); |
|
5708 | - if( !$res ) |
|
5703 | + if (!$res) return FALSE; |
|
5704 | + if (isset($subcfg) && !empty($this->components)) { |
|
5705 | + foreach ($subcfg as $cfgkey => $cfgvalue) { |
|
5706 | + foreach ($this->components as $cix => $component) { |
|
5707 | + $res = $component->setConfig($cfgkey, $cfgvalue); |
|
5708 | + if (!$res) |
|
5709 | 5709 | break 2; |
5710 | 5710 | $this->components[$cix] = $component; // PHP4 compliant |
5711 | 5711 | } |
@@ -5723,248 +5723,248 @@ discard block |
||
5723 | 5723 | * @param int @propix, optional, if specific property is wanted in case of multiply occurences |
5724 | 5724 | * @return bool, if successfull delete TRUE |
5725 | 5725 | */ |
5726 | - function deleteProperty( $propName, $propix=FALSE ) { |
|
5727 | - if( $this->_notExistProp( $propName )) return FALSE; |
|
5728 | - $propName = strtoupper( $propName ); |
|
5729 | - if( in_array( $propName, array( 'ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
|
5730 | - 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP' ))) { |
|
5731 | - if( !$propix ) |
|
5732 | - $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1; |
|
5726 | + function deleteProperty($propName, $propix = FALSE) { |
|
5727 | + if ($this->_notExistProp($propName)) return FALSE; |
|
5728 | + $propName = strtoupper($propName); |
|
5729 | + if (in_array($propName, array('ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
|
5730 | + 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP'))) { |
|
5731 | + if (!$propix) |
|
5732 | + $propix = (isset($this->propdelix[$propName])) ? $this->propdelix[$propName] + 2 : 1; |
|
5733 | 5733 | $this->propdelix[$propName] = --$propix; |
5734 | 5734 | } |
5735 | 5735 | $return = FALSE; |
5736 | - switch( $propName ) { |
|
5736 | + switch ($propName) { |
|
5737 | 5737 | case 'ACTION': |
5738 | - if( !empty( $this->action )) { |
|
5738 | + if (!empty($this->action)) { |
|
5739 | 5739 | $this->action = ''; |
5740 | 5740 | $return = TRUE; |
5741 | 5741 | } |
5742 | 5742 | break; |
5743 | 5743 | case 'ATTACH': |
5744 | - return $this->deletePropertyM( $this->attach, $propix ); |
|
5744 | + return $this->deletePropertyM($this->attach, $propix); |
|
5745 | 5745 | break; |
5746 | 5746 | case 'ATTENDEE': |
5747 | - return $this->deletePropertyM( $this->attendee, $propix ); |
|
5747 | + return $this->deletePropertyM($this->attendee, $propix); |
|
5748 | 5748 | break; |
5749 | 5749 | case 'CATEGORIES': |
5750 | - return $this->deletePropertyM( $this->categories, $propix ); |
|
5750 | + return $this->deletePropertyM($this->categories, $propix); |
|
5751 | 5751 | break; |
5752 | 5752 | case 'CLASS': |
5753 | - if( !empty( $this->class )) { |
|
5753 | + if (!empty($this->class)) { |
|
5754 | 5754 | $this->class = ''; |
5755 | 5755 | $return = TRUE; |
5756 | 5756 | } |
5757 | 5757 | break; |
5758 | 5758 | case 'COMMENT': |
5759 | - return $this->deletePropertyM( $this->comment, $propix ); |
|
5759 | + return $this->deletePropertyM($this->comment, $propix); |
|
5760 | 5760 | break; |
5761 | 5761 | case 'COMPLETED': |
5762 | - if( !empty( $this->completed )) { |
|
5762 | + if (!empty($this->completed)) { |
|
5763 | 5763 | $this->completed = ''; |
5764 | 5764 | $return = TRUE; |
5765 | 5765 | } |
5766 | 5766 | break; |
5767 | 5767 | case 'CONTACT': |
5768 | - return $this->deletePropertyM( $this->contact, $propix ); |
|
5768 | + return $this->deletePropertyM($this->contact, $propix); |
|
5769 | 5769 | break; |
5770 | 5770 | case 'CREATED': |
5771 | - if( !empty( $this->created )) { |
|
5771 | + if (!empty($this->created)) { |
|
5772 | 5772 | $this->created = ''; |
5773 | 5773 | $return = TRUE; |
5774 | 5774 | } |
5775 | 5775 | break; |
5776 | 5776 | case 'DESCRIPTION': |
5777 | - return $this->deletePropertyM( $this->description, $propix ); |
|
5777 | + return $this->deletePropertyM($this->description, $propix); |
|
5778 | 5778 | break; |
5779 | 5779 | case 'DTEND': |
5780 | - if( !empty( $this->dtend )) { |
|
5780 | + if (!empty($this->dtend)) { |
|
5781 | 5781 | $this->dtend = ''; |
5782 | 5782 | $return = TRUE; |
5783 | 5783 | } |
5784 | 5784 | break; |
5785 | 5785 | case 'DTSTAMP': |
5786 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
5786 | + if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) |
|
5787 | 5787 | return FALSE; |
5788 | - if( !empty( $this->dtstamp )) { |
|
5788 | + if (!empty($this->dtstamp)) { |
|
5789 | 5789 | $this->dtstamp = ''; |
5790 | 5790 | $return = TRUE; |
5791 | 5791 | } |
5792 | 5792 | break; |
5793 | 5793 | case 'DTSTART': |
5794 | - if( !empty( $this->dtstart )) { |
|
5794 | + if (!empty($this->dtstart)) { |
|
5795 | 5795 | $this->dtstart = ''; |
5796 | 5796 | $return = TRUE; |
5797 | 5797 | } |
5798 | 5798 | break; |
5799 | 5799 | case 'DUE': |
5800 | - if( !empty( $this->due )) { |
|
5800 | + if (!empty($this->due)) { |
|
5801 | 5801 | $this->due = ''; |
5802 | 5802 | $return = TRUE; |
5803 | 5803 | } |
5804 | 5804 | break; |
5805 | 5805 | case 'DURATION': |
5806 | - if( !empty( $this->duration )) { |
|
5806 | + if (!empty($this->duration)) { |
|
5807 | 5807 | $this->duration = ''; |
5808 | 5808 | $return = TRUE; |
5809 | 5809 | } |
5810 | 5810 | break; |
5811 | 5811 | case 'EXDATE': |
5812 | - return $this->deletePropertyM( $this->exdate, $propix ); |
|
5812 | + return $this->deletePropertyM($this->exdate, $propix); |
|
5813 | 5813 | break; |
5814 | 5814 | case 'EXRULE': |
5815 | - return $this->deletePropertyM( $this->exrule, $propix ); |
|
5815 | + return $this->deletePropertyM($this->exrule, $propix); |
|
5816 | 5816 | break; |
5817 | 5817 | case 'FREEBUSY': |
5818 | - return $this->deletePropertyM( $this->freebusy, $propix ); |
|
5818 | + return $this->deletePropertyM($this->freebusy, $propix); |
|
5819 | 5819 | break; |
5820 | 5820 | case 'GEO': |
5821 | - if( !empty( $this->geo )) { |
|
5821 | + if (!empty($this->geo)) { |
|
5822 | 5822 | $this->geo = ''; |
5823 | 5823 | $return = TRUE; |
5824 | 5824 | } |
5825 | 5825 | break; |
5826 | 5826 | case 'LAST-MODIFIED': |
5827 | - if( !empty( $this->lastmodified )) { |
|
5827 | + if (!empty($this->lastmodified)) { |
|
5828 | 5828 | $this->lastmodified = ''; |
5829 | 5829 | $return = TRUE; |
5830 | 5830 | } |
5831 | 5831 | break; |
5832 | 5832 | case 'LOCATION': |
5833 | - if( !empty( $this->location )) { |
|
5833 | + if (!empty($this->location)) { |
|
5834 | 5834 | $this->location = ''; |
5835 | 5835 | $return = TRUE; |
5836 | 5836 | } |
5837 | 5837 | break; |
5838 | 5838 | case 'ORGANIZER': |
5839 | - if( !empty( $this->organizer )) { |
|
5839 | + if (!empty($this->organizer)) { |
|
5840 | 5840 | $this->organizer = ''; |
5841 | 5841 | $return = TRUE; |
5842 | 5842 | } |
5843 | 5843 | break; |
5844 | 5844 | case 'PERCENT-COMPLETE': |
5845 | - if( !empty( $this->percentcomplete )) { |
|
5845 | + if (!empty($this->percentcomplete)) { |
|
5846 | 5846 | $this->percentcomplete = ''; |
5847 | 5847 | $return = TRUE; |
5848 | 5848 | } |
5849 | 5849 | break; |
5850 | 5850 | case 'PRIORITY': |
5851 | - if( !empty( $this->priority )) { |
|
5851 | + if (!empty($this->priority)) { |
|
5852 | 5852 | $this->priority = ''; |
5853 | 5853 | $return = TRUE; |
5854 | 5854 | } |
5855 | 5855 | break; |
5856 | 5856 | case 'RDATE': |
5857 | - return $this->deletePropertyM( $this->rdate, $propix ); |
|
5857 | + return $this->deletePropertyM($this->rdate, $propix); |
|
5858 | 5858 | break; |
5859 | 5859 | case 'RECURRENCE-ID': |
5860 | - if( !empty( $this->recurrenceid )) { |
|
5860 | + if (!empty($this->recurrenceid)) { |
|
5861 | 5861 | $this->recurrenceid = ''; |
5862 | 5862 | $return = TRUE; |
5863 | 5863 | } |
5864 | 5864 | break; |
5865 | 5865 | case 'RELATED-TO': |
5866 | - return $this->deletePropertyM( $this->relatedto, $propix ); |
|
5866 | + return $this->deletePropertyM($this->relatedto, $propix); |
|
5867 | 5867 | break; |
5868 | 5868 | case 'REPEAT': |
5869 | - if( !empty( $this->repeat )) { |
|
5869 | + if (!empty($this->repeat)) { |
|
5870 | 5870 | $this->repeat = ''; |
5871 | 5871 | $return = TRUE; |
5872 | 5872 | } |
5873 | 5873 | break; |
5874 | 5874 | case 'REQUEST-STATUS': |
5875 | - return $this->deletePropertyM( $this->requeststatus, $propix ); |
|
5875 | + return $this->deletePropertyM($this->requeststatus, $propix); |
|
5876 | 5876 | break; |
5877 | 5877 | case 'RESOURCES': |
5878 | - return $this->deletePropertyM( $this->resources, $propix ); |
|
5878 | + return $this->deletePropertyM($this->resources, $propix); |
|
5879 | 5879 | break; |
5880 | 5880 | case 'RRULE': |
5881 | - return $this->deletePropertyM( $this->rrule, $propix ); |
|
5881 | + return $this->deletePropertyM($this->rrule, $propix); |
|
5882 | 5882 | break; |
5883 | 5883 | case 'SEQUENCE': |
5884 | - if( !empty( $this->sequence )) { |
|
5884 | + if (!empty($this->sequence)) { |
|
5885 | 5885 | $this->sequence = ''; |
5886 | 5886 | $return = TRUE; |
5887 | 5887 | } |
5888 | 5888 | break; |
5889 | 5889 | case 'STATUS': |
5890 | - if( !empty( $this->status )) { |
|
5890 | + if (!empty($this->status)) { |
|
5891 | 5891 | $this->status = ''; |
5892 | 5892 | $return = TRUE; |
5893 | 5893 | } |
5894 | 5894 | break; |
5895 | 5895 | case 'SUMMARY': |
5896 | - if( !empty( $this->summary )) { |
|
5896 | + if (!empty($this->summary)) { |
|
5897 | 5897 | $this->summary = ''; |
5898 | 5898 | $return = TRUE; |
5899 | 5899 | } |
5900 | 5900 | break; |
5901 | 5901 | case 'TRANSP': |
5902 | - if( !empty( $this->transp )) { |
|
5902 | + if (!empty($this->transp)) { |
|
5903 | 5903 | $this->transp = ''; |
5904 | 5904 | $return = TRUE; |
5905 | 5905 | } |
5906 | 5906 | break; |
5907 | 5907 | case 'TRIGGER': |
5908 | - if( !empty( $this->trigger )) { |
|
5908 | + if (!empty($this->trigger)) { |
|
5909 | 5909 | $this->trigger = ''; |
5910 | 5910 | $return = TRUE; |
5911 | 5911 | } |
5912 | 5912 | break; |
5913 | 5913 | case 'TZID': |
5914 | - if( !empty( $this->tzid )) { |
|
5914 | + if (!empty($this->tzid)) { |
|
5915 | 5915 | $this->tzid = ''; |
5916 | 5916 | $return = TRUE; |
5917 | 5917 | } |
5918 | 5918 | break; |
5919 | 5919 | case 'TZNAME': |
5920 | - return $this->deletePropertyM( $this->tzname, $propix ); |
|
5920 | + return $this->deletePropertyM($this->tzname, $propix); |
|
5921 | 5921 | break; |
5922 | 5922 | case 'TZOFFSETFROM': |
5923 | - if( !empty( $this->tzoffsetfrom )) { |
|
5923 | + if (!empty($this->tzoffsetfrom)) { |
|
5924 | 5924 | $this->tzoffsetfrom = ''; |
5925 | 5925 | $return = TRUE; |
5926 | 5926 | } |
5927 | 5927 | break; |
5928 | 5928 | case 'TZOFFSETTO': |
5929 | - if( !empty( $this->tzoffsetto )) { |
|
5929 | + if (!empty($this->tzoffsetto)) { |
|
5930 | 5930 | $this->tzoffsetto = ''; |
5931 | 5931 | $return = TRUE; |
5932 | 5932 | } |
5933 | 5933 | break; |
5934 | 5934 | case 'TZURL': |
5935 | - if( !empty( $this->tzurl )) { |
|
5935 | + if (!empty($this->tzurl)) { |
|
5936 | 5936 | $this->tzurl = ''; |
5937 | 5937 | $return = TRUE; |
5938 | 5938 | } |
5939 | 5939 | break; |
5940 | 5940 | case 'UID': |
5941 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
5941 | + if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) |
|
5942 | 5942 | return FALSE; |
5943 | - if( !empty( $this->uid )) { |
|
5943 | + if (!empty($this->uid)) { |
|
5944 | 5944 | $this->uid = ''; |
5945 | 5945 | $return = TRUE; |
5946 | 5946 | } |
5947 | 5947 | break; |
5948 | 5948 | case 'URL': |
5949 | - if( !empty( $this->url )) { |
|
5949 | + if (!empty($this->url)) { |
|
5950 | 5950 | $this->url = ''; |
5951 | 5951 | $return = TRUE; |
5952 | 5952 | } |
5953 | 5953 | break; |
5954 | 5954 | default: |
5955 | 5955 | $reduced = ''; |
5956 | - if( $propName != 'X-PROP' ) { |
|
5957 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
5958 | - foreach( $this->xprop as $k => $a ) { |
|
5959 | - if(( $k != $propName ) && !empty( $a )) |
|
5956 | + if ($propName != 'X-PROP') { |
|
5957 | + if (!isset($this->xprop[$propName])) return FALSE; |
|
5958 | + foreach ($this->xprop as $k => $a) { |
|
5959 | + if (($k != $propName) && !empty($a)) |
|
5960 | 5960 | $reduced[$k] = $a; |
5961 | 5961 | } |
5962 | 5962 | } |
5963 | 5963 | else { |
5964 | - if( count( $this->xprop ) <= $propix ) return FALSE; |
|
5964 | + if (count($this->xprop) <= $propix) return FALSE; |
|
5965 | 5965 | $xpropno = 0; |
5966 | - foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
|
5967 | - if( $propix != $xpropno ) |
|
5966 | + foreach ($this->xprop as $xpropkey => $xpropvalue) { |
|
5967 | + if ($propix != $xpropno) |
|
5968 | 5968 | $reduced[$xpropkey] = $xpropvalue; |
5969 | 5969 | $xpropno++; |
5970 | 5970 | } |
@@ -5984,11 +5984,11 @@ discard block |
||
5984 | 5984 | * @param int @propix, default 0 |
5985 | 5985 | * @return bool TRUE |
5986 | 5986 | */ |
5987 | - function deletePropertyM( & $multiprop, $propix=0 ) { |
|
5988 | - if( !isset( $multiprop[$propix])) return FALSE; |
|
5989 | - unset( $multiprop[$propix] ); |
|
5990 | - if( empty( $multiprop )) $multiprop = ''; |
|
5991 | - return ( isset( $this->multiprop[$propix] )) ? FALSE : TRUE; |
|
5987 | + function deletePropertyM(& $multiprop, $propix = 0) { |
|
5988 | + if (!isset($multiprop[$propix])) return FALSE; |
|
5989 | + unset($multiprop[$propix]); |
|
5990 | + if (empty($multiprop)) $multiprop = ''; |
|
5991 | + return (isset($this->multiprop[$propix])) ? FALSE : TRUE; |
|
5992 | 5992 | } |
5993 | 5993 | /** |
5994 | 5994 | * get component property value/params |
@@ -6003,183 +6003,183 @@ discard block |
||
6003 | 6003 | * @param bool $specform=FALSE |
6004 | 6004 | * @return mixed |
6005 | 6005 | */ |
6006 | - function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE, $specform=FALSE ) { |
|
6007 | - if( $this->_notExistProp( $propName )) return FALSE; |
|
6008 | - $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP'; |
|
6009 | - if( in_array( $propName, array( 'ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
|
6010 | - 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP' ))) { |
|
6011 | - if( !$propix ) |
|
6012 | - $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; |
|
6006 | + function getProperty($propName = FALSE, $propix = FALSE, $inclParam = FALSE, $specform = FALSE) { |
|
6007 | + if ($this->_notExistProp($propName)) return FALSE; |
|
6008 | + $propName = ($propName) ? strtoupper($propName) : 'X-PROP'; |
|
6009 | + if (in_array($propName, array('ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
|
6010 | + 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP'))) { |
|
6011 | + if (!$propix) |
|
6012 | + $propix = (isset($this->propix[$propName])) ? $this->propix[$propName] + 2 : 1; |
|
6013 | 6013 | $this->propix[$propName] = --$propix; |
6014 | 6014 | } |
6015 | - switch( $propName ) { |
|
6015 | + switch ($propName) { |
|
6016 | 6016 | case 'ACTION': |
6017 | - if( !empty( $this->action['value'] )) return ( $inclParam ) ? $this->action : $this->action['value']; |
|
6017 | + if (!empty($this->action['value'])) return ($inclParam) ? $this->action : $this->action['value']; |
|
6018 | 6018 | break; |
6019 | 6019 | case 'ATTACH': |
6020 | - if( !isset( $this->attach[$propix] )) return FALSE; |
|
6021 | - return ( $inclParam ) ? $this->attach[$propix] : $this->attach[$propix]['value']; |
|
6020 | + if (!isset($this->attach[$propix])) return FALSE; |
|
6021 | + return ($inclParam) ? $this->attach[$propix] : $this->attach[$propix]['value']; |
|
6022 | 6022 | break; |
6023 | 6023 | case 'ATTENDEE': |
6024 | - if( !isset( $this->attendee[$propix] )) return FALSE; |
|
6025 | - return ( $inclParam ) ? $this->attendee[$propix] : $this->attendee[$propix]['value']; |
|
6024 | + if (!isset($this->attendee[$propix])) return FALSE; |
|
6025 | + return ($inclParam) ? $this->attendee[$propix] : $this->attendee[$propix]['value']; |
|
6026 | 6026 | break; |
6027 | 6027 | case 'CATEGORIES': |
6028 | - if( !isset( $this->categories[$propix] )) return FALSE; |
|
6029 | - return ( $inclParam ) ? $this->categories[$propix] : $this->categories[$propix]['value']; |
|
6028 | + if (!isset($this->categories[$propix])) return FALSE; |
|
6029 | + return ($inclParam) ? $this->categories[$propix] : $this->categories[$propix]['value']; |
|
6030 | 6030 | break; |
6031 | 6031 | case 'CLASS': |
6032 | - if( !empty( $this->class['value'] )) return ( $inclParam ) ? $this->class : $this->class['value']; |
|
6032 | + if (!empty($this->class['value'])) return ($inclParam) ? $this->class : $this->class['value']; |
|
6033 | 6033 | break; |
6034 | 6034 | case 'COMMENT': |
6035 | - if( !isset( $this->comment[$propix] )) return FALSE; |
|
6036 | - return ( $inclParam ) ? $this->comment[$propix] : $this->comment[$propix]['value']; |
|
6035 | + if (!isset($this->comment[$propix])) return FALSE; |
|
6036 | + return ($inclParam) ? $this->comment[$propix] : $this->comment[$propix]['value']; |
|
6037 | 6037 | break; |
6038 | 6038 | case 'COMPLETED': |
6039 | - if( !empty( $this->completed['value'] )) return ( $inclParam ) ? $this->completed : $this->completed['value']; |
|
6039 | + if (!empty($this->completed['value'])) return ($inclParam) ? $this->completed : $this->completed['value']; |
|
6040 | 6040 | break; |
6041 | 6041 | case 'CONTACT': |
6042 | - if( !isset( $this->contact[$propix] )) return FALSE; |
|
6043 | - return ( $inclParam ) ? $this->contact[$propix] : $this->contact[$propix]['value']; |
|
6042 | + if (!isset($this->contact[$propix])) return FALSE; |
|
6043 | + return ($inclParam) ? $this->contact[$propix] : $this->contact[$propix]['value']; |
|
6044 | 6044 | break; |
6045 | 6045 | case 'CREATED': |
6046 | - if( !empty( $this->created['value'] )) return ( $inclParam ) ? $this->created : $this->created['value']; |
|
6046 | + if (!empty($this->created['value'])) return ($inclParam) ? $this->created : $this->created['value']; |
|
6047 | 6047 | break; |
6048 | 6048 | case 'DESCRIPTION': |
6049 | - if( !isset( $this->description[$propix] )) return FALSE; |
|
6050 | - return ( $inclParam ) ? $this->description[$propix] : $this->description[$propix]['value']; |
|
6049 | + if (!isset($this->description[$propix])) return FALSE; |
|
6050 | + return ($inclParam) ? $this->description[$propix] : $this->description[$propix]['value']; |
|
6051 | 6051 | break; |
6052 | 6052 | case 'DTEND': |
6053 | - if( !empty( $this->dtend['value'] )) return ( $inclParam ) ? $this->dtend : $this->dtend['value']; |
|
6053 | + if (!empty($this->dtend['value'])) return ($inclParam) ? $this->dtend : $this->dtend['value']; |
|
6054 | 6054 | break; |
6055 | 6055 | case 'DTSTAMP': |
6056 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
6056 | + if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) |
|
6057 | 6057 | return; |
6058 | - if( !isset( $this->dtstamp['value'] )) |
|
6058 | + if (!isset($this->dtstamp['value'])) |
|
6059 | 6059 | $this->_makeDtstamp(); |
6060 | - return ( $inclParam ) ? $this->dtstamp : $this->dtstamp['value']; |
|
6060 | + return ($inclParam) ? $this->dtstamp : $this->dtstamp['value']; |
|
6061 | 6061 | break; |
6062 | 6062 | case 'DTSTART': |
6063 | - if( !empty( $this->dtstart['value'] )) return ( $inclParam ) ? $this->dtstart : $this->dtstart['value']; |
|
6063 | + if (!empty($this->dtstart['value'])) return ($inclParam) ? $this->dtstart : $this->dtstart['value']; |
|
6064 | 6064 | break; |
6065 | 6065 | case 'DUE': |
6066 | - if( !empty( $this->due['value'] )) return ( $inclParam ) ? $this->due : $this->due['value']; |
|
6066 | + if (!empty($this->due['value'])) return ($inclParam) ? $this->due : $this->due['value']; |
|
6067 | 6067 | break; |
6068 | 6068 | case 'DURATION': |
6069 | - if( !isset( $this->duration['value'] )) return FALSE; |
|
6070 | - $value = ( $specform ) ? $this->duration2date() : $this->duration['value']; |
|
6071 | - return ( $inclParam ) ? array( 'value' => $value, 'params' => $this->duration['params'] ) : $value; |
|
6069 | + if (!isset($this->duration['value'])) return FALSE; |
|
6070 | + $value = ($specform) ? $this->duration2date() : $this->duration['value']; |
|
6071 | + return ($inclParam) ? array('value' => $value, 'params' => $this->duration['params']) : $value; |
|
6072 | 6072 | break; |
6073 | 6073 | case 'EXDATE': |
6074 | - if( !isset( $this->exdate[$propix] )) return FALSE; |
|
6075 | - return ( $inclParam ) ? $this->exdate[$propix] : $this->exdate[$propix]['value']; |
|
6074 | + if (!isset($this->exdate[$propix])) return FALSE; |
|
6075 | + return ($inclParam) ? $this->exdate[$propix] : $this->exdate[$propix]['value']; |
|
6076 | 6076 | break; |
6077 | 6077 | case 'EXRULE': |
6078 | - if( !isset( $this->exrule[$propix] )) return FALSE; |
|
6079 | - return ( $inclParam ) ? $this->exrule[$propix] : $this->exrule[$propix]['value']; |
|
6078 | + if (!isset($this->exrule[$propix])) return FALSE; |
|
6079 | + return ($inclParam) ? $this->exrule[$propix] : $this->exrule[$propix]['value']; |
|
6080 | 6080 | break; |
6081 | 6081 | case 'FREEBUSY': |
6082 | - if( !isset( $this->freebusy[$propix] )) return FALSE; |
|
6083 | - return ( $inclParam ) ? $this->freebusy[$propix] : $this->freebusy[$propix]['value']; |
|
6082 | + if (!isset($this->freebusy[$propix])) return FALSE; |
|
6083 | + return ($inclParam) ? $this->freebusy[$propix] : $this->freebusy[$propix]['value']; |
|
6084 | 6084 | break; |
6085 | 6085 | case 'GEO': |
6086 | - if( !empty( $this->geo['value'] )) return ( $inclParam ) ? $this->geo : $this->geo['value']; |
|
6086 | + if (!empty($this->geo['value'])) return ($inclParam) ? $this->geo : $this->geo['value']; |
|
6087 | 6087 | break; |
6088 | 6088 | case 'LAST-MODIFIED': |
6089 | - if( !empty( $this->lastmodified['value'] )) return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value']; |
|
6089 | + if (!empty($this->lastmodified['value'])) return ($inclParam) ? $this->lastmodified : $this->lastmodified['value']; |
|
6090 | 6090 | break; |
6091 | 6091 | case 'LOCATION': |
6092 | - if( !empty( $this->location['value'] )) return ( $inclParam ) ? $this->location : $this->location['value']; |
|
6092 | + if (!empty($this->location['value'])) return ($inclParam) ? $this->location : $this->location['value']; |
|
6093 | 6093 | break; |
6094 | 6094 | case 'ORGANIZER': |
6095 | - if( !empty( $this->organizer['value'] )) return ( $inclParam ) ? $this->organizer : $this->organizer['value']; |
|
6095 | + if (!empty($this->organizer['value'])) return ($inclParam) ? $this->organizer : $this->organizer['value']; |
|
6096 | 6096 | break; |
6097 | 6097 | case 'PERCENT-COMPLETE': |
6098 | - if( !empty( $this->percentcomplete['value'] )) return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value']; |
|
6098 | + if (!empty($this->percentcomplete['value'])) return ($inclParam) ? $this->percentcomplete : $this->percentcomplete['value']; |
|
6099 | 6099 | break; |
6100 | 6100 | case 'PRIORITY': |
6101 | - if( !empty( $this->priority['value'] )) return ( $inclParam ) ? $this->priority : $this->priority['value']; |
|
6101 | + if (!empty($this->priority['value'])) return ($inclParam) ? $this->priority : $this->priority['value']; |
|
6102 | 6102 | break; |
6103 | 6103 | case 'RDATE': |
6104 | - if( !isset( $this->rdate[$propix] )) return FALSE; |
|
6105 | - return ( $inclParam ) ? $this->rdate[$propix] : $this->rdate[$propix]['value']; |
|
6104 | + if (!isset($this->rdate[$propix])) return FALSE; |
|
6105 | + return ($inclParam) ? $this->rdate[$propix] : $this->rdate[$propix]['value']; |
|
6106 | 6106 | break; |
6107 | 6107 | case 'RECURRENCE-ID': |
6108 | - if( !empty( $this->recurrenceid['value'] )) return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value']; |
|
6108 | + if (!empty($this->recurrenceid['value'])) return ($inclParam) ? $this->recurrenceid : $this->recurrenceid['value']; |
|
6109 | 6109 | break; |
6110 | 6110 | case 'RELATED-TO': |
6111 | - if( !isset( $this->relatedto[$propix] )) return FALSE; |
|
6112 | - return ( $inclParam ) ? $this->relatedto[$propix] : $this->relatedto[$propix]['value']; |
|
6111 | + if (!isset($this->relatedto[$propix])) return FALSE; |
|
6112 | + return ($inclParam) ? $this->relatedto[$propix] : $this->relatedto[$propix]['value']; |
|
6113 | 6113 | break; |
6114 | 6114 | case 'REPEAT': |
6115 | - if( !empty( $this->repeat['value'] )) return ( $inclParam ) ? $this->repeat : $this->repeat['value']; |
|
6115 | + if (!empty($this->repeat['value'])) return ($inclParam) ? $this->repeat : $this->repeat['value']; |
|
6116 | 6116 | break; |
6117 | 6117 | case 'REQUEST-STATUS': |
6118 | - if( !isset( $this->requeststatus[$propix] )) return FALSE; |
|
6119 | - return ( $inclParam ) ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value']; |
|
6118 | + if (!isset($this->requeststatus[$propix])) return FALSE; |
|
6119 | + return ($inclParam) ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value']; |
|
6120 | 6120 | break; |
6121 | 6121 | case 'RESOURCES': |
6122 | - if( !isset( $this->resources[$propix] )) return FALSE; |
|
6123 | - return ( $inclParam ) ? $this->resources[$propix] : $this->resources[$propix]['value']; |
|
6122 | + if (!isset($this->resources[$propix])) return FALSE; |
|
6123 | + return ($inclParam) ? $this->resources[$propix] : $this->resources[$propix]['value']; |
|
6124 | 6124 | break; |
6125 | 6125 | case 'RRULE': |
6126 | - if( !isset( $this->rrule[$propix] )) return FALSE; |
|
6127 | - return ( $inclParam ) ? $this->rrule[$propix] : $this->rrule[$propix]['value']; |
|
6126 | + if (!isset($this->rrule[$propix])) return FALSE; |
|
6127 | + return ($inclParam) ? $this->rrule[$propix] : $this->rrule[$propix]['value']; |
|
6128 | 6128 | break; |
6129 | 6129 | case 'SEQUENCE': |
6130 | - if( !empty( $this->sequence['value'] )) return ( $inclParam ) ? $this->sequence : $this->sequence['value']; |
|
6130 | + if (!empty($this->sequence['value'])) return ($inclParam) ? $this->sequence : $this->sequence['value']; |
|
6131 | 6131 | break; |
6132 | 6132 | case 'STATUS': |
6133 | - if( !empty( $this->status['value'] )) return ( $inclParam ) ? $this->status : $this->status['value']; |
|
6133 | + if (!empty($this->status['value'])) return ($inclParam) ? $this->status : $this->status['value']; |
|
6134 | 6134 | break; |
6135 | 6135 | case 'SUMMARY': |
6136 | - if( !empty( $this->summary['value'] )) return ( $inclParam ) ? $this->summary : $this->summary['value']; |
|
6136 | + if (!empty($this->summary['value'])) return ($inclParam) ? $this->summary : $this->summary['value']; |
|
6137 | 6137 | break; |
6138 | 6138 | case 'TRANSP': |
6139 | - if( !empty( $this->transp['value'] )) return ( $inclParam ) ? $this->transp : $this->transp['value']; |
|
6139 | + if (!empty($this->transp['value'])) return ($inclParam) ? $this->transp : $this->transp['value']; |
|
6140 | 6140 | break; |
6141 | 6141 | case 'TRIGGER': |
6142 | - if( !empty( $this->trigger['value'] )) return ( $inclParam ) ? $this->trigger : $this->trigger['value']; |
|
6142 | + if (!empty($this->trigger['value'])) return ($inclParam) ? $this->trigger : $this->trigger['value']; |
|
6143 | 6143 | break; |
6144 | 6144 | case 'TZID': |
6145 | - if( !empty( $this->tzid['value'] )) return ( $inclParam ) ? $this->tzid : $this->tzid['value']; |
|
6145 | + if (!empty($this->tzid['value'])) return ($inclParam) ? $this->tzid : $this->tzid['value']; |
|
6146 | 6146 | break; |
6147 | 6147 | case 'TZNAME': |
6148 | - if( !isset( $this->tzname[$propix] )) return FALSE; |
|
6149 | - return ( $inclParam ) ? $this->tzname[$propix] : $this->tzname[$propix]['value']; |
|
6148 | + if (!isset($this->tzname[$propix])) return FALSE; |
|
6149 | + return ($inclParam) ? $this->tzname[$propix] : $this->tzname[$propix]['value']; |
|
6150 | 6150 | break; |
6151 | 6151 | case 'TZOFFSETFROM': |
6152 | - if( !empty( $this->tzoffsetfrom['value'] )) return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value']; |
|
6152 | + if (!empty($this->tzoffsetfrom['value'])) return ($inclParam) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value']; |
|
6153 | 6153 | break; |
6154 | 6154 | case 'TZOFFSETTO': |
6155 | - if( !empty( $this->tzoffsetto['value'] )) return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value']; |
|
6155 | + if (!empty($this->tzoffsetto['value'])) return ($inclParam) ? $this->tzoffsetto : $this->tzoffsetto['value']; |
|
6156 | 6156 | break; |
6157 | 6157 | case 'TZURL': |
6158 | - if( !empty( $this->tzurl['value'] )) return ( $inclParam ) ? $this->tzurl : $this->tzurl['value']; |
|
6158 | + if (!empty($this->tzurl['value'])) return ($inclParam) ? $this->tzurl : $this->tzurl['value']; |
|
6159 | 6159 | break; |
6160 | 6160 | case 'UID': |
6161 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
6161 | + if (in_array($this->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) |
|
6162 | 6162 | return FALSE; |
6163 | - if( empty( $this->uid['value'] )) |
|
6163 | + if (empty($this->uid['value'])) |
|
6164 | 6164 | $this->_makeuid(); |
6165 | - return ( $inclParam ) ? $this->uid : $this->uid['value']; |
|
6165 | + return ($inclParam) ? $this->uid : $this->uid['value']; |
|
6166 | 6166 | break; |
6167 | 6167 | case 'URL': |
6168 | - if( !empty( $this->url['value'] )) return ( $inclParam ) ? $this->url : $this->url['value']; |
|
6168 | + if (!empty($this->url['value'])) return ($inclParam) ? $this->url : $this->url['value']; |
|
6169 | 6169 | break; |
6170 | 6170 | default: |
6171 | - if( $propName != 'X-PROP' ) { |
|
6172 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
6173 | - return ( $inclParam ) ? array( $propName, $this->xprop[$propName] ) |
|
6174 | - : array( $propName, $this->xprop[$propName]['value'] ); |
|
6171 | + if ($propName != 'X-PROP') { |
|
6172 | + if (!isset($this->xprop[$propName])) return FALSE; |
|
6173 | + return ($inclParam) ? array($propName, $this->xprop[$propName]) |
|
6174 | + : array($propName, $this->xprop[$propName]['value']); |
|
6175 | 6175 | } |
6176 | 6176 | else { |
6177 | - if( empty( $this->xprop )) return FALSE; |
|
6177 | + if (empty($this->xprop)) return FALSE; |
|
6178 | 6178 | $xpropno = 0; |
6179 | - foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
|
6180 | - if( $propix == $xpropno ) |
|
6181 | - return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) |
|
6182 | - : array( $xpropkey, $this->xprop[$xpropkey]['value'] ); |
|
6179 | + foreach ($this->xprop as $xpropkey => $xpropvalue) { |
|
6180 | + if ($propix == $xpropno) |
|
6181 | + return ($inclParam) ? array($xpropkey, $this->xprop[$xpropkey]) |
|
6182 | + : array($xpropkey, $this->xprop[$xpropkey]['value']); |
|
6183 | 6183 | else |
6184 | 6184 | $xpropno++; |
6185 | 6185 | } |
@@ -6200,105 +6200,105 @@ discard block |
||
6200 | 6200 | */ |
6201 | 6201 | function setProperty() { |
6202 | 6202 | $numargs = func_num_args(); |
6203 | - if( 1 > $numargs ) return FALSE; |
|
6203 | + if (1 > $numargs) return FALSE; |
|
6204 | 6204 | $arglist = func_get_args(); |
6205 | - if( $this->_notExistProp( $arglist[0] )) return FALSE; |
|
6206 | - if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] ))) |
|
6205 | + if ($this->_notExistProp($arglist[0])) return FALSE; |
|
6206 | + if (!$this->getConfig('allowEmpty') && (!isset($arglist[1]) || empty($arglist[1]))) |
|
6207 | 6207 | return FALSE; |
6208 | - $arglist[0] = strtoupper( $arglist[0] ); |
|
6209 | - for( $argix=$numargs; $argix < 12; $argix++ ) { |
|
6210 | - if( !isset( $arglist[$argix] )) |
|
6208 | + $arglist[0] = strtoupper($arglist[0]); |
|
6209 | + for ($argix = $numargs; $argix < 12; $argix++) { |
|
6210 | + if (!isset($arglist[$argix])) |
|
6211 | 6211 | $arglist[$argix] = null; |
6212 | 6212 | } |
6213 | - switch( $arglist[0] ) { |
|
6213 | + switch ($arglist[0]) { |
|
6214 | 6214 | case 'ACTION': |
6215 | - return $this->setAction( $arglist[1], $arglist[2] ); |
|
6215 | + return $this->setAction($arglist[1], $arglist[2]); |
|
6216 | 6216 | case 'ATTACH': |
6217 | - return $this->setAttach( $arglist[1], $arglist[2], $arglist[3] ); |
|
6217 | + return $this->setAttach($arglist[1], $arglist[2], $arglist[3]); |
|
6218 | 6218 | case 'ATTENDEE': |
6219 | - return $this->setAttendee( $arglist[1], $arglist[2], $arglist[3] ); |
|
6219 | + return $this->setAttendee($arglist[1], $arglist[2], $arglist[3]); |
|
6220 | 6220 | case 'CATEGORIES': |
6221 | - return $this->setCategories( $arglist[1], $arglist[2], $arglist[3] ); |
|
6221 | + return $this->setCategories($arglist[1], $arglist[2], $arglist[3]); |
|
6222 | 6222 | case 'CLASS': |
6223 | - return $this->setClass( $arglist[1], $arglist[2] ); |
|
6223 | + return $this->setClass($arglist[1], $arglist[2]); |
|
6224 | 6224 | case 'COMMENT': |
6225 | - return $this->setComment( $arglist[1], $arglist[2], $arglist[3] ); |
|
6225 | + return $this->setComment($arglist[1], $arglist[2], $arglist[3]); |
|
6226 | 6226 | case 'COMPLETED': |
6227 | - return $this->setCompleted( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] ); |
|
6227 | + return $this->setCompleted($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7]); |
|
6228 | 6228 | case 'CONTACT': |
6229 | - return $this->setContact( $arglist[1], $arglist[2], $arglist[3] ); |
|
6229 | + return $this->setContact($arglist[1], $arglist[2], $arglist[3]); |
|
6230 | 6230 | case 'CREATED': |
6231 | - return $this->setCreated( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] ); |
|
6231 | + return $this->setCreated($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7]); |
|
6232 | 6232 | case 'DESCRIPTION': |
6233 | - return $this->setDescription( $arglist[1], $arglist[2], $arglist[3] ); |
|
6233 | + return $this->setDescription($arglist[1], $arglist[2], $arglist[3]); |
|
6234 | 6234 | case 'DTEND': |
6235 | - return $this->setDtend( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] ); |
|
6235 | + return $this->setDtend($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8]); |
|
6236 | 6236 | case 'DTSTAMP': |
6237 | - return $this->setDtstamp( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] ); |
|
6237 | + return $this->setDtstamp($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7]); |
|
6238 | 6238 | case 'DTSTART': |
6239 | - return $this->setDtstart( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] ); |
|
6239 | + return $this->setDtstart($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8]); |
|
6240 | 6240 | case 'DUE': |
6241 | - return $this->setDue( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] ); |
|
6241 | + return $this->setDue($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8]); |
|
6242 | 6242 | case 'DURATION': |
6243 | - return $this->setDuration( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6] ); |
|
6243 | + return $this->setDuration($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6]); |
|
6244 | 6244 | case 'EXDATE': |
6245 | - return $this->setExdate( $arglist[1], $arglist[2], $arglist[3] ); |
|
6245 | + return $this->setExdate($arglist[1], $arglist[2], $arglist[3]); |
|
6246 | 6246 | case 'EXRULE': |
6247 | - return $this->setExrule( $arglist[1], $arglist[2], $arglist[3] ); |
|
6247 | + return $this->setExrule($arglist[1], $arglist[2], $arglist[3]); |
|
6248 | 6248 | case 'FREEBUSY': |
6249 | - return $this->setFreebusy( $arglist[1], $arglist[2], $arglist[3], $arglist[4] ); |
|
6249 | + return $this->setFreebusy($arglist[1], $arglist[2], $arglist[3], $arglist[4]); |
|
6250 | 6250 | case 'GEO': |
6251 | - return $this->setGeo( $arglist[1], $arglist[2], $arglist[3] ); |
|
6251 | + return $this->setGeo($arglist[1], $arglist[2], $arglist[3]); |
|
6252 | 6252 | case 'LAST-MODIFIED': |
6253 | - return $this->setLastModified( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] ); |
|
6253 | + return $this->setLastModified($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7]); |
|
6254 | 6254 | case 'LOCATION': |
6255 | - return $this->setLocation( $arglist[1], $arglist[2] ); |
|
6255 | + return $this->setLocation($arglist[1], $arglist[2]); |
|
6256 | 6256 | case 'ORGANIZER': |
6257 | - return $this->setOrganizer( $arglist[1], $arglist[2] ); |
|
6257 | + return $this->setOrganizer($arglist[1], $arglist[2]); |
|
6258 | 6258 | case 'PERCENT-COMPLETE': |
6259 | - return $this->setPercentComplete( $arglist[1], $arglist[2] ); |
|
6259 | + return $this->setPercentComplete($arglist[1], $arglist[2]); |
|
6260 | 6260 | case 'PRIORITY': |
6261 | - return $this->setPriority( $arglist[1], $arglist[2] ); |
|
6261 | + return $this->setPriority($arglist[1], $arglist[2]); |
|
6262 | 6262 | case 'RDATE': |
6263 | - return $this->setRdate( $arglist[1], $arglist[2], $arglist[3] ); |
|
6263 | + return $this->setRdate($arglist[1], $arglist[2], $arglist[3]); |
|
6264 | 6264 | case 'RECURRENCE-ID': |
6265 | - return $this->setRecurrenceid( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] ); |
|
6265 | + return $this->setRecurrenceid($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8]); |
|
6266 | 6266 | case 'RELATED-TO': |
6267 | - return $this->setRelatedTo( $arglist[1], $arglist[2], $arglist[3] ); |
|
6267 | + return $this->setRelatedTo($arglist[1], $arglist[2], $arglist[3]); |
|
6268 | 6268 | case 'REPEAT': |
6269 | - return $this->setRepeat( $arglist[1], $arglist[2] ); |
|
6269 | + return $this->setRepeat($arglist[1], $arglist[2]); |
|
6270 | 6270 | case 'REQUEST-STATUS': |
6271 | - return $this->setRequestStatus( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5] ); |
|
6271 | + return $this->setRequestStatus($arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5]); |
|
6272 | 6272 | case 'RESOURCES': |
6273 | - return $this->setResources( $arglist[1], $arglist[2], $arglist[3] ); |
|
6273 | + return $this->setResources($arglist[1], $arglist[2], $arglist[3]); |
|
6274 | 6274 | case 'RRULE': |
6275 | - return $this->setRrule( $arglist[1], $arglist[2], $arglist[3] ); |
|
6275 | + return $this->setRrule($arglist[1], $arglist[2], $arglist[3]); |
|
6276 | 6276 | case 'SEQUENCE': |
6277 | - return $this->setSequence( $arglist[1], $arglist[2] ); |
|
6277 | + return $this->setSequence($arglist[1], $arglist[2]); |
|
6278 | 6278 | case 'STATUS': |
6279 | - return $this->setStatus( $arglist[1], $arglist[2] ); |
|
6279 | + return $this->setStatus($arglist[1], $arglist[2]); |
|
6280 | 6280 | case 'SUMMARY': |
6281 | - return $this->setSummary( $arglist[1], $arglist[2] ); |
|
6281 | + return $this->setSummary($arglist[1], $arglist[2]); |
|
6282 | 6282 | case 'TRANSP': |
6283 | - return $this->setTransp( $arglist[1], $arglist[2] ); |
|
6283 | + return $this->setTransp($arglist[1], $arglist[2]); |
|
6284 | 6284 | case 'TRIGGER': |
6285 | - return $this->setTrigger( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8], $arglist[9], $arglist[10], $arglist[11] ); |
|
6285 | + 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]); |
|
6286 | 6286 | case 'TZID': |
6287 | - return $this->setTzid( $arglist[1], $arglist[2] ); |
|
6287 | + return $this->setTzid($arglist[1], $arglist[2]); |
|
6288 | 6288 | case 'TZNAME': |
6289 | - return $this->setTzname( $arglist[1], $arglist[2], $arglist[3] ); |
|
6289 | + return $this->setTzname($arglist[1], $arglist[2], $arglist[3]); |
|
6290 | 6290 | case 'TZOFFSETFROM': |
6291 | - return $this->setTzoffsetfrom( $arglist[1], $arglist[2] ); |
|
6291 | + return $this->setTzoffsetfrom($arglist[1], $arglist[2]); |
|
6292 | 6292 | case 'TZOFFSETTO': |
6293 | - return $this->setTzoffsetto( $arglist[1], $arglist[2] ); |
|
6293 | + return $this->setTzoffsetto($arglist[1], $arglist[2]); |
|
6294 | 6294 | case 'TZURL': |
6295 | - return $this->setTzurl( $arglist[1], $arglist[2] ); |
|
6295 | + return $this->setTzurl($arglist[1], $arglist[2]); |
|
6296 | 6296 | case 'UID': |
6297 | - return $this->setUid( $arglist[1], $arglist[2] ); |
|
6297 | + return $this->setUid($arglist[1], $arglist[2]); |
|
6298 | 6298 | case 'URL': |
6299 | - return $this->setUrl( $arglist[1], $arglist[2] ); |
|
6299 | + return $this->setUrl($arglist[1], $arglist[2]); |
|
6300 | 6300 | default: |
6301 | - return $this->setXprop( $arglist[0], $arglist[1], $arglist[2] ); |
|
6301 | + return $this->setXprop($arglist[0], $arglist[1], $arglist[2]); |
|
6302 | 6302 | } |
6303 | 6303 | return FALSE; |
6304 | 6304 | } |
@@ -6312,18 +6312,18 @@ discard block |
||
6312 | 6312 | * @return bool FALSE if error occurs during parsing |
6313 | 6313 | * |
6314 | 6314 | */ |
6315 | - function parse( $unparsedtext=null ) { |
|
6316 | - if( $unparsedtext ) { |
|
6315 | + function parse($unparsedtext = null) { |
|
6316 | + if ($unparsedtext) { |
|
6317 | 6317 | $this->unparsed = array(); |
6318 | - if( is_array( $unparsedtext )) { |
|
6318 | + if (is_array($unparsedtext)) { |
|
6319 | 6319 | $comp = & $this; |
6320 | - foreach ( $unparsedtext as $line ) { |
|
6321 | - if( 'END:VALARM' == strtoupper( substr( $line, 0, 10 ))) { |
|
6322 | - $this->setComponent( $comp ); |
|
6323 | - $comp = & $this; |
|
6320 | + foreach ($unparsedtext as $line) { |
|
6321 | + if ('END:VALARM' == strtoupper(substr($line, 0, 10))) { |
|
6322 | + $this->setComponent($comp); |
|
6323 | + $comp = & $this; |
|
6324 | 6324 | continue; |
6325 | 6325 | } |
6326 | - elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) { |
|
6326 | + elseif ('BEGIN:VALARM' == strtoupper(substr($line, 0, 12))) { |
|
6327 | 6327 | $comp = new valarm(); |
6328 | 6328 | continue; |
6329 | 6329 | } |
@@ -6332,217 +6332,217 @@ discard block |
||
6332 | 6332 | } |
6333 | 6333 | } |
6334 | 6334 | else |
6335 | - $this->unparsed = array( trim( $unparsedtext )); |
|
6335 | + $this->unparsed = array(trim($unparsedtext)); |
|
6336 | 6336 | } |
6337 | - elseif( !isset( $this->unparsed )) |
|
6337 | + elseif (!isset($this->unparsed)) |
|
6338 | 6338 | $this->unparsed = array(); |
6339 | 6339 | /* concatenate property values spread over several lines */ |
6340 | 6340 | $lastix = -1; |
6341 | - $propnames = array( 'action', 'attach', 'attendee', 'categories', 'comment', 'completed' |
|
6341 | + $propnames = array('action', 'attach', 'attendee', 'categories', 'comment', 'completed' |
|
6342 | 6342 | , 'contact', 'class', 'created', 'description', 'dtend', 'dtstart' |
6343 | 6343 | , 'dtstamp', 'due', 'duration', 'exdate', 'exrule', 'freebusy', 'geo' |
6344 | 6344 | , 'last-modified', 'location', 'organizer', 'percent-complete' |
6345 | 6345 | , 'priority', 'rdate', 'recurrence-id', 'related-to', 'repeat' |
6346 | 6346 | , 'request-status', 'resources', 'rrule', 'sequence', 'status' |
6347 | 6347 | , 'summary', 'transp', 'trigger', 'tzid', 'tzname', 'tzoffsetfrom' |
6348 | - , 'tzoffsetto', 'tzurl', 'uid', 'url', 'x-' ); |
|
6349 | - $proprows = array(); |
|
6350 | - foreach( $this->unparsed as $line ) { |
|
6348 | + , 'tzoffsetto', 'tzurl', 'uid', 'url', 'x-'); |
|
6349 | + $proprows = array(); |
|
6350 | + foreach ($this->unparsed as $line) { |
|
6351 | 6351 | $newProp = FALSE; |
6352 | - foreach ( $propnames as $propname ) { |
|
6353 | - if( $propname == strtolower( substr( $line, 0, strlen( $propname )))) { |
|
6352 | + foreach ($propnames as $propname) { |
|
6353 | + if ($propname == strtolower(substr($line, 0, strlen($propname)))) { |
|
6354 | 6354 | $newProp = TRUE; |
6355 | 6355 | break; |
6356 | 6356 | } |
6357 | 6357 | } |
6358 | - if( $newProp ) { |
|
6358 | + if ($newProp) { |
|
6359 | 6359 | $newProp = FALSE; |
6360 | 6360 | $lastix++; |
6361 | - $proprows[$lastix] = $line; |
|
6361 | + $proprows[$lastix] = $line; |
|
6362 | 6362 | } |
6363 | 6363 | else { |
6364 | 6364 | /* remove line breaks */ |
6365 | - if(( '\n' == substr( $proprows[$lastix], -2 )) && |
|
6366 | - ( ' ' == substr( $line, 0, 1 ))) { |
|
6367 | - $proprows[$lastix] = substr( $proprows[$lastix], 0, strlen( $proprows[$lastix] ) - 2 ); |
|
6368 | - $line = substr( $line, 1 ); |
|
6365 | + if (('\n' == substr($proprows[$lastix], -2)) && |
|
6366 | + (' ' == substr($line, 0, 1))) { |
|
6367 | + $proprows[$lastix] = substr($proprows[$lastix], 0, strlen($proprows[$lastix]) - 2); |
|
6368 | + $line = substr($line, 1); |
|
6369 | 6369 | } |
6370 | 6370 | $proprows[$lastix] .= $line; |
6371 | 6371 | } |
6372 | 6372 | } |
6373 | 6373 | /* parse each property 'line' */ |
6374 | - foreach( $proprows as $line ) { |
|
6375 | - $line = str_replace( "\n ", '', $line ); |
|
6376 | - if( '\n' == substr( $line, -2 )) |
|
6377 | - $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
6374 | + foreach ($proprows as $line) { |
|
6375 | + $line = str_replace("\n ", '', $line); |
|
6376 | + if ('\n' == substr($line, -2)) |
|
6377 | + $line = substr($line, 0, strlen($line) - 2); |
|
6378 | 6378 | /* get propname, (problem with x-properties, otherwise in previous loop) */ |
6379 | 6379 | $cix = $propname = null; |
6380 | - for( $cix=0; $cix < strlen( $line ); $cix++ ) { |
|
6381 | - if( in_array( $line{$cix}, array( ':', ';' ))) |
|
6380 | + for ($cix = 0; $cix < strlen($line); $cix++) { |
|
6381 | + if (in_array($line{$cix}, array(':', ';'))) |
|
6382 | 6382 | break; |
6383 | 6383 | else { |
6384 | 6384 | $propname .= $line{$cix}; |
6385 | 6385 | } |
6386 | 6386 | } |
6387 | - if(( 'x-' == substr( $propname, 0, 2 )) || ( 'X-' == substr( $propname, 0, 2 ))) { |
|
6387 | + if (('x-' == substr($propname, 0, 2)) || ('X-' == substr($propname, 0, 2))) { |
|
6388 | 6388 | $propname2 = $propname; |
6389 | 6389 | $propname = 'X-'; |
6390 | 6390 | } |
6391 | 6391 | /* rest of the line is opt.params and value */ |
6392 | - $line = substr( $line, $cix ); |
|
6392 | + $line = substr($line, $cix); |
|
6393 | 6393 | /* separate attributes from value */ |
6394 | 6394 | $attr = array(); |
6395 | 6395 | $attrix = -1; |
6396 | - $strlen = strlen( $line ); |
|
6397 | - for( $cix=0; $cix < $strlen; $cix++ ) { |
|
6398 | - if(( ':' == $line{$cix} ) && |
|
6399 | - ( '://' != substr( $line, $cix, 3 )) && |
|
6400 | - ( 'mailto:' != strtolower( substr( $line, $cix - 6, 7 )))) { |
|
6396 | + $strlen = strlen($line); |
|
6397 | + for ($cix = 0; $cix < $strlen; $cix++) { |
|
6398 | + if ((':' == $line{$cix} ) && |
|
6399 | + ('://' != substr($line, $cix, 3)) && |
|
6400 | + ('mailto:' != strtolower(substr($line, $cix - 6, 7)))) { |
|
6401 | 6401 | $attrEnd = TRUE; |
6402 | - if(( $cix < ( $strlen - 4 )) && |
|
6403 | - ctype_digit( substr( $line, $cix+1, 4 ))) { // an URI with a (4pos) portnr?? |
|
6404 | - for( $c2ix = $cix; 3 < $c2ix; $c2ix-- ) { |
|
6405 | - if( '://' == substr( $line, $c2ix - 2, 3 )) { |
|
6402 | + if (($cix < ($strlen - 4)) && |
|
6403 | + ctype_digit(substr($line, $cix + 1, 4))) { // an URI with a (4pos) portnr?? |
|
6404 | + for ($c2ix = $cix; 3 < $c2ix; $c2ix--) { |
|
6405 | + if ('://' == substr($line, $c2ix - 2, 3)) { |
|
6406 | 6406 | $attrEnd = FALSE; |
6407 | 6407 | break; // an URI with a portnr!! |
6408 | 6408 | } |
6409 | 6409 | } |
6410 | 6410 | } |
6411 | - if( $attrEnd) { |
|
6412 | - $line = substr( $line, $cix + 1 ); |
|
6411 | + if ($attrEnd) { |
|
6412 | + $line = substr($line, $cix + 1); |
|
6413 | 6413 | break; |
6414 | 6414 | } |
6415 | 6415 | } |
6416 | - if( ';' == $line{$cix} ) |
|
6416 | + if (';' == $line{$cix} ) |
|
6417 | 6417 | $attr[++$attrix] = null; |
6418 | 6418 | else |
6419 | 6419 | $attr[$attrix] .= $line{$cix}; |
6420 | 6420 | } |
6421 | 6421 | /* make attributes in array format */ |
6422 | 6422 | $propattr = array(); |
6423 | - foreach( $attr as $attribute ) { |
|
6424 | - $attrsplit = explode( '=', $attribute, 2 ); |
|
6425 | - if( 1 < count( $attrsplit )) |
|
6423 | + foreach ($attr as $attribute) { |
|
6424 | + $attrsplit = explode('=', $attribute, 2); |
|
6425 | + if (1 < count($attrsplit)) |
|
6426 | 6426 | $propattr[$attrsplit[0]] = $attrsplit[1]; |
6427 | 6427 | else |
6428 | 6428 | $propattr[] = $attribute; |
6429 | 6429 | } |
6430 | 6430 | /* call setProperty( $propname.. . */ |
6431 | - switch( $propname ) { |
|
6431 | + switch ($propname) { |
|
6432 | 6432 | case 'ATTENDEE': |
6433 | - foreach( $propattr as $pix => $attr ) { |
|
6434 | - $attr2 = explode( ',', $attr ); |
|
6435 | - if( 1 < count( $attr2 )) |
|
6433 | + foreach ($propattr as $pix => $attr) { |
|
6434 | + $attr2 = explode(',', $attr); |
|
6435 | + if (1 < count($attr2)) |
|
6436 | 6436 | $propattr[$pix] = $attr2; |
6437 | 6437 | } |
6438 | - $this->setProperty( $propname, $line, $propattr ); |
|
6438 | + $this->setProperty($propname, $line, $propattr); |
|
6439 | 6439 | break; |
6440 | 6440 | case 'CATEGORIES': |
6441 | 6441 | case 'RESOURCES': |
6442 | - if( FALSE !== strpos( $line, ',' )) { |
|
6443 | - $content = explode( ',', $line ); |
|
6444 | - $clen = count( $content ); |
|
6445 | - for( $cix = 0; $cix < $clen; $cix++ ) { |
|
6446 | - if( "\\" == substr($content[$cix], -1)) { |
|
6442 | + if (FALSE !== strpos($line, ',')) { |
|
6443 | + $content = explode(',', $line); |
|
6444 | + $clen = count($content); |
|
6445 | + for ($cix = 0; $cix < $clen; $cix++) { |
|
6446 | + if ("\\" == substr($content[$cix], -1)) { |
|
6447 | 6447 | $content[$cix] .= ','.$content[$cix + 1]; |
6448 | 6448 | unset($content[$cix + 1]); |
6449 | 6449 | $cix++; |
6450 | 6450 | } |
6451 | 6451 | } |
6452 | - if( 1 < count( $content )) { |
|
6453 | - $content = array_values( $content ); |
|
6454 | - foreach( $content as $cix => $contentPart ) |
|
6455 | - $content[$cix] = $this->_strunrep( $contentPart ); |
|
6456 | - $this->setProperty( $propname, $content, $propattr ); |
|
6452 | + if (1 < count($content)) { |
|
6453 | + $content = array_values($content); |
|
6454 | + foreach ($content as $cix => $contentPart) |
|
6455 | + $content[$cix] = $this->_strunrep($contentPart); |
|
6456 | + $this->setProperty($propname, $content, $propattr); |
|
6457 | 6457 | break; |
6458 | 6458 | } |
6459 | 6459 | else |
6460 | - $line = reset( $content ); |
|
6460 | + $line = reset($content); |
|
6461 | 6461 | } |
6462 | 6462 | //no break |
6463 | 6463 | case 'X-': |
6464 | - $propname = ( isset( $propname2 )) ? $propname2 : $propname; |
|
6464 | + $propname = (isset($propname2)) ? $propname2 : $propname; |
|
6465 | 6465 | //no break |
6466 | 6466 | case 'COMMENT': |
6467 | 6467 | case 'CONTACT': |
6468 | 6468 | case 'DESCRIPTION': |
6469 | 6469 | case 'LOCATION': |
6470 | 6470 | case 'SUMMARY': |
6471 | - if( empty( $line )) |
|
6471 | + if (empty($line)) |
|
6472 | 6472 | $propattr = null; |
6473 | - $this->setProperty( $propname, $this->_strunrep( $line ), $propattr ); |
|
6474 | - unset( $propname2 ); |
|
6473 | + $this->setProperty($propname, $this->_strunrep($line), $propattr); |
|
6474 | + unset($propname2); |
|
6475 | 6475 | break; |
6476 | 6476 | case 'REQUEST-STATUS': |
6477 | - $values = explode( ';', $line, 3 ); |
|
6478 | - $values[1] = ( !isset( $values[1] )) ? null : $this->_strunrep( $values[1] ); |
|
6479 | - $values[2] = ( !isset( $values[2] )) ? null : $this->_strunrep( $values[2] ); |
|
6480 | - $this->setProperty( $propname |
|
6477 | + $values = explode(';', $line, 3); |
|
6478 | + $values[1] = (!isset($values[1])) ? null : $this->_strunrep($values[1]); |
|
6479 | + $values[2] = (!isset($values[2])) ? null : $this->_strunrep($values[2]); |
|
6480 | + $this->setProperty($propname |
|
6481 | 6481 | , $values[0] // statcode |
6482 | 6482 | , $values[1] // statdesc |
6483 | 6483 | , $values[2] // extdata |
6484 | - , $propattr ); |
|
6484 | + , $propattr); |
|
6485 | 6485 | break; |
6486 | 6486 | case 'FREEBUSY': |
6487 | - $fbtype = ( isset( $propattr['FBTYPE'] )) ? $propattr['FBTYPE'] : ''; // force setting default, if missing |
|
6488 | - unset( $propattr['FBTYPE'] ); |
|
6489 | - $values = explode( ',', $line ); |
|
6490 | - foreach( $values as $vix => $value ) { |
|
6491 | - $value2 = explode( '/', $value ); |
|
6492 | - if( 1 < count( $value2 )) |
|
6487 | + $fbtype = (isset($propattr['FBTYPE'])) ? $propattr['FBTYPE'] : ''; // force setting default, if missing |
|
6488 | + unset($propattr['FBTYPE']); |
|
6489 | + $values = explode(',', $line); |
|
6490 | + foreach ($values as $vix => $value) { |
|
6491 | + $value2 = explode('/', $value); |
|
6492 | + if (1 < count($value2)) |
|
6493 | 6493 | $values[$vix] = $value2; |
6494 | 6494 | } |
6495 | - $this->setProperty( $propname, $fbtype, $values, $propattr ); |
|
6495 | + $this->setProperty($propname, $fbtype, $values, $propattr); |
|
6496 | 6496 | break; |
6497 | 6497 | case 'GEO': |
6498 | - $value = explode( ';', $line, 2 ); |
|
6499 | - if( 2 > count( $value )) |
|
6498 | + $value = explode(';', $line, 2); |
|
6499 | + if (2 > count($value)) |
|
6500 | 6500 | $value[1] = null; |
6501 | - $this->setProperty( $propname, $value[0], $value[1], $propattr ); |
|
6501 | + $this->setProperty($propname, $value[0], $value[1], $propattr); |
|
6502 | 6502 | break; |
6503 | 6503 | case 'EXDATE': |
6504 | - $values = ( !empty( $line )) ? explode( ',', $line ) : null; |
|
6505 | - $this->setProperty( $propname, $values, $propattr ); |
|
6504 | + $values = (!empty($line)) ? explode(',', $line) : null; |
|
6505 | + $this->setProperty($propname, $values, $propattr); |
|
6506 | 6506 | break; |
6507 | 6507 | case 'RDATE': |
6508 | - if( empty( $line )) { |
|
6509 | - $this->setProperty( $propname, $line, $propattr ); |
|
6508 | + if (empty($line)) { |
|
6509 | + $this->setProperty($propname, $line, $propattr); |
|
6510 | 6510 | break; |
6511 | 6511 | } |
6512 | - $values = explode( ',', $line ); |
|
6513 | - foreach( $values as $vix => $value ) { |
|
6514 | - $value2 = explode( '/', $value ); |
|
6515 | - if( 1 < count( $value2 )) |
|
6512 | + $values = explode(',', $line); |
|
6513 | + foreach ($values as $vix => $value) { |
|
6514 | + $value2 = explode('/', $value); |
|
6515 | + if (1 < count($value2)) |
|
6516 | 6516 | $values[$vix] = $value2; |
6517 | 6517 | } |
6518 | - $this->setProperty( $propname, $values, $propattr ); |
|
6518 | + $this->setProperty($propname, $values, $propattr); |
|
6519 | 6519 | break; |
6520 | 6520 | case 'EXRULE': |
6521 | 6521 | case 'RRULE': |
6522 | - $values = explode( ';', $line ); |
|
6522 | + $values = explode(';', $line); |
|
6523 | 6523 | $recur = array(); |
6524 | - foreach( $values as $value2 ) { |
|
6525 | - if( empty( $value2 )) |
|
6524 | + foreach ($values as $value2) { |
|
6525 | + if (empty($value2)) |
|
6526 | 6526 | continue; // ;-char in ending position ??? |
6527 | - $value3 = explode( '=', $value2, 2 ); |
|
6528 | - $rulelabel = strtoupper( $value3[0] ); |
|
6529 | - switch( $rulelabel ) { |
|
6527 | + $value3 = explode('=', $value2, 2); |
|
6528 | + $rulelabel = strtoupper($value3[0]); |
|
6529 | + switch ($rulelabel) { |
|
6530 | 6530 | case 'BYDAY': |
6531 | - $value4 = explode( ',', $value3[1] ); |
|
6532 | - if( 1 < count( $value4 )) { |
|
6533 | - foreach( $value4 as $v5ix => $value5 ) { |
|
6531 | + $value4 = explode(',', $value3[1]); |
|
6532 | + if (1 < count($value4)) { |
|
6533 | + foreach ($value4 as $v5ix => $value5) { |
|
6534 | 6534 | $value6 = array(); |
6535 | 6535 | $dayno = $dayname = null; |
6536 | - $value5 = trim( (string) $value5 ); |
|
6537 | - if(( ctype_alpha( substr( $value5, -1 ))) && |
|
6538 | - ( ctype_alpha( substr( $value5, -2, 1 )))) { |
|
6539 | - $dayname = substr( $value5, -2, 2 ); |
|
6540 | - if( 2 < strlen( $value5 )) |
|
6541 | - $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
6536 | + $value5 = trim((string) $value5); |
|
6537 | + if ((ctype_alpha(substr($value5, -1))) && |
|
6538 | + (ctype_alpha(substr($value5, -2, 1)))) { |
|
6539 | + $dayname = substr($value5, -2, 2); |
|
6540 | + if (2 < strlen($value5)) |
|
6541 | + $dayno = substr($value5, 0, (strlen($value5) - 2)); |
|
6542 | 6542 | } |
6543 | - if( $dayno ) |
|
6543 | + if ($dayno) |
|
6544 | 6544 | $value6[] = $dayno; |
6545 | - if( $dayname ) |
|
6545 | + if ($dayname) |
|
6546 | 6546 | $value6['DAY'] = $dayname; |
6547 | 6547 | $value4[$v5ix] = $value6; |
6548 | 6548 | } |
@@ -6550,39 +6550,39 @@ discard block |
||
6550 | 6550 | else { |
6551 | 6551 | $value4 = array(); |
6552 | 6552 | $dayno = $dayname = null; |
6553 | - $value5 = trim( (string) $value3[1] ); |
|
6554 | - if(( ctype_alpha( substr( $value5, -1 ))) && |
|
6555 | - ( ctype_alpha( substr( $value5, -2, 1 )))) { |
|
6556 | - $dayname = substr( $value5, -2, 2 ); |
|
6557 | - if( 2 < strlen( $value5 )) |
|
6558 | - $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
6553 | + $value5 = trim((string) $value3[1]); |
|
6554 | + if ((ctype_alpha(substr($value5, -1))) && |
|
6555 | + (ctype_alpha(substr($value5, -2, 1)))) { |
|
6556 | + $dayname = substr($value5, -2, 2); |
|
6557 | + if (2 < strlen($value5)) |
|
6558 | + $dayno = substr($value5, 0, (strlen($value5) - 2)); |
|
6559 | 6559 | } |
6560 | - if( $dayno ) |
|
6560 | + if ($dayno) |
|
6561 | 6561 | $value4[] = $dayno; |
6562 | - if( $dayname ) |
|
6562 | + if ($dayname) |
|
6563 | 6563 | $value4['DAY'] = $dayname; |
6564 | 6564 | } |
6565 | 6565 | $recur[$rulelabel] = $value4; |
6566 | 6566 | break; |
6567 | 6567 | default: |
6568 | - $value4 = explode( ',', $value3[1] ); |
|
6569 | - if( 1 < count( $value4 )) |
|
6568 | + $value4 = explode(',', $value3[1]); |
|
6569 | + if (1 < count($value4)) |
|
6570 | 6570 | $value3[1] = $value4; |
6571 | 6571 | $recur[$rulelabel] = $value3[1]; |
6572 | 6572 | break; |
6573 | 6573 | } // end - switch $rulelabel |
6574 | 6574 | } // end - foreach( $values.. . |
6575 | - $this->setProperty( $propname, $recur, $propattr ); |
|
6575 | + $this->setProperty($propname, $recur, $propattr); |
|
6576 | 6576 | break; |
6577 | 6577 | default: |
6578 | - $this->setProperty( $propname, $line, $propattr ); |
|
6578 | + $this->setProperty($propname, $line, $propattr); |
|
6579 | 6579 | break; |
6580 | 6580 | } // end switch( $propname.. . |
6581 | 6581 | } // end - foreach( $proprows.. . |
6582 | - unset( $this->unparsed, $proprows ); |
|
6583 | - if( isset( $this->components ) && is_array( $this->components ) && ( 0 < count( $this->components ))) { |
|
6584 | - for( $six = 0; $six < count( $this->components ); $six++ ) { |
|
6585 | - if( !empty( $this->components[$six]->unparsed )) |
|
6582 | + unset($this->unparsed, $proprows); |
|
6583 | + if (isset($this->components) && is_array($this->components) && (0 < count($this->components))) { |
|
6584 | + for ($six = 0; $six < count($this->components); $six++) { |
|
6585 | + if (!empty($this->components[$six]->unparsed)) |
|
6586 | 6586 | $this->components[$six]->parse(); |
6587 | 6587 | } |
6588 | 6588 | } |
@@ -6599,7 +6599,7 @@ discard block |
||
6599 | 6599 | function copy() { |
6600 | 6600 | $serialized_contents = serialize($this); |
6601 | 6601 | $copy = unserialize($serialized_contents); |
6602 | - unset( $copy->propix ); |
|
6602 | + unset($copy->propix); |
|
6603 | 6603 | return $copy; |
6604 | 6604 | } |
6605 | 6605 | /*********************************************************************************/ |
@@ -6613,34 +6613,34 @@ discard block |
||
6613 | 6613 | * @param mixed $arg2 optional, ordno if arg1 = component type |
6614 | 6614 | * @return void |
6615 | 6615 | */ |
6616 | - function deleteComponent( $arg1, $arg2=FALSE ) { |
|
6617 | - if( !isset( $this->components )) return FALSE; |
|
6616 | + function deleteComponent($arg1, $arg2 = FALSE) { |
|
6617 | + if (!isset($this->components)) return FALSE; |
|
6618 | 6618 | $argType = $index = null; |
6619 | - if ( ctype_digit( (string) $arg1 )) { |
|
6619 | + if (ctype_digit((string) $arg1)) { |
|
6620 | 6620 | $argType = 'INDEX'; |
6621 | 6621 | $index = (int) $arg1 - 1; |
6622 | 6622 | } |
6623 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6624 | - $argType = strtolower( $arg1 ); |
|
6625 | - $index = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0; |
|
6623 | + elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) { |
|
6624 | + $argType = strtolower($arg1); |
|
6625 | + $index = (!empty($arg2) && ctype_digit((string) $arg2)) ? ((int) $arg2 - 1) : 0; |
|
6626 | 6626 | } |
6627 | 6627 | $cix2dC = 0; |
6628 | - foreach ( $this->components as $cix => $component) { |
|
6629 | - if( empty( $component )) continue; |
|
6630 | - unset( $component->propix ); |
|
6631 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
|
6632 | - unset( $this->components[$cix] ); |
|
6628 | + foreach ($this->components as $cix => $component) { |
|
6629 | + if (empty($component)) continue; |
|
6630 | + unset($component->propix); |
|
6631 | + if (('INDEX' == $argType) && ($index == $cix)) { |
|
6632 | + unset($this->components[$cix]); |
|
6633 | 6633 | return TRUE; |
6634 | 6634 | } |
6635 | - elseif( $argType == $component->objName ) { |
|
6636 | - if( $index == $cix2dC ) { |
|
6637 | - unset( $this->components[$cix] ); |
|
6635 | + elseif ($argType == $component->objName) { |
|
6636 | + if ($index == $cix2dC) { |
|
6637 | + unset($this->components[$cix]); |
|
6638 | 6638 | return TRUE; |
6639 | 6639 | } |
6640 | 6640 | $cix2dC++; |
6641 | 6641 | } |
6642 | - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
6643 | - unset( $this->components[$cix] ); |
|
6642 | + elseif (!$argType && ($arg1 == $component->getProperty('uid'))) { |
|
6643 | + unset($this->components[$cix]); |
|
6644 | 6644 | return TRUE; |
6645 | 6645 | } |
6646 | 6646 | } |
@@ -6655,50 +6655,50 @@ discard block |
||
6655 | 6655 | * @param mixed $arg2 optional, ordno if arg1 = component type |
6656 | 6656 | * @return object |
6657 | 6657 | */ |
6658 | - function getComponent ( $arg1=FALSE, $arg2=FALSE ) { |
|
6659 | - if( !isset( $this->components )) return FALSE; |
|
6658 | + function getComponent($arg1 = FALSE, $arg2 = FALSE) { |
|
6659 | + if (!isset($this->components)) return FALSE; |
|
6660 | 6660 | $index = $argType = null; |
6661 | - if ( !$arg1 ) { |
|
6661 | + if (!$arg1) { |
|
6662 | 6662 | $argType = 'INDEX'; |
6663 | 6663 | $index = $this->compix['INDEX'] = |
6664 | - ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1; |
|
6664 | + (isset($this->compix['INDEX'])) ? $this->compix['INDEX'] + 1 : 1; |
|
6665 | 6665 | } |
6666 | - elseif ( ctype_digit( (string) $arg1 )) { |
|
6666 | + elseif (ctype_digit((string) $arg1)) { |
|
6667 | 6667 | $argType = 'INDEX'; |
6668 | 6668 | $index = (int) $arg1; |
6669 | - unset( $this->compix ); |
|
6669 | + unset($this->compix); |
|
6670 | 6670 | } |
6671 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6672 | - unset( $this->compix['INDEX'] ); |
|
6673 | - $argType = strtolower( $arg1 ); |
|
6674 | - if( !$arg2 ) |
|
6671 | + elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) { |
|
6672 | + unset($this->compix['INDEX']); |
|
6673 | + $argType = strtolower($arg1); |
|
6674 | + if (!$arg2) |
|
6675 | 6675 | $index = $this->compix[$argType] = |
6676 | - ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1; |
|
6676 | + (isset($this->compix[$argType])) ? $this->compix[$argType] + 1 : 1; |
|
6677 | 6677 | else |
6678 | 6678 | $index = (int) $arg2; |
6679 | 6679 | } |
6680 | - $index -= 1; |
|
6681 | - $ckeys = array_keys( $this->components ); |
|
6682 | - if( !empty( $index) && ( $index > end( $ckeys ))) |
|
6680 | + $index -= 1; |
|
6681 | + $ckeys = array_keys($this->components); |
|
6682 | + if (!empty($index) && ($index > end($ckeys))) |
|
6683 | 6683 | return FALSE; |
6684 | 6684 | $cix2gC = 0; |
6685 | - foreach( $this->components as $cix => $component ) { |
|
6686 | - if( empty( $component )) continue; |
|
6687 | - unset( $component->propix ); |
|
6688 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) |
|
6685 | + foreach ($this->components as $cix => $component) { |
|
6686 | + if (empty($component)) continue; |
|
6687 | + unset($component->propix); |
|
6688 | + if (('INDEX' == $argType) && ($index == $cix)) |
|
6689 | 6689 | return $component->copy(); |
6690 | - elseif( $argType == $component->objName ) { |
|
6691 | - if( $index == $cix2gC ) |
|
6690 | + elseif ($argType == $component->objName) { |
|
6691 | + if ($index == $cix2gC) |
|
6692 | 6692 | return $component->copy(); |
6693 | 6693 | $cix2gC++; |
6694 | 6694 | } |
6695 | - elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) { |
|
6696 | - unset( $component->propix ); |
|
6695 | + elseif (!$argType && ($arg1 == $component->getProperty('uid'))) { |
|
6696 | + unset($component->propix); |
|
6697 | 6697 | return $component->copy(); |
6698 | 6698 | } |
6699 | 6699 | } |
6700 | 6700 | /* not found.. . */ |
6701 | - unset( $this->compix ); |
|
6701 | + unset($this->compix); |
|
6702 | 6702 | return false; |
6703 | 6703 | } |
6704 | 6704 | /** |
@@ -6709,8 +6709,8 @@ discard block |
||
6709 | 6709 | * @param object $component calendar component |
6710 | 6710 | * @return void |
6711 | 6711 | */ |
6712 | - function addSubComponent ( $component ) { |
|
6713 | - $this->setComponent( $component ); |
|
6712 | + function addSubComponent($component) { |
|
6713 | + $this->setComponent($component); |
|
6714 | 6714 | } |
6715 | 6715 | /** |
6716 | 6716 | * add calendar component as subcomponent to container for subcomponents |
@@ -6722,49 +6722,49 @@ discard block |
||
6722 | 6722 | * @param mixed $arg2 optional, ordno if arg1 = component type |
6723 | 6723 | * @return bool |
6724 | 6724 | */ |
6725 | - function setComponent( $component, $arg1=FALSE, $arg2=FALSE ) { |
|
6726 | - if( !isset( $this->components )) return FALSE; |
|
6727 | - if( '' >= $component->getConfig( 'language')) |
|
6728 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
6729 | - $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
|
6730 | - $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
|
6731 | - $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
|
6732 | - $component->setConfig( 'format', $this->getConfig( 'format' )); |
|
6733 | - if( !in_array( $component->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
6734 | - unset( $component->propix ); |
|
6725 | + function setComponent($component, $arg1 = FALSE, $arg2 = FALSE) { |
|
6726 | + if (!isset($this->components)) return FALSE; |
|
6727 | + if ('' >= $component->getConfig('language')) |
|
6728 | + $component->setConfig('language', $this->getConfig('language')); |
|
6729 | + $component->setConfig('allowEmpty', $this->getConfig('allowEmpty')); |
|
6730 | + $component->setConfig('nl', $this->getConfig('nl')); |
|
6731 | + $component->setConfig('unique_id', $this->getConfig('unique_id')); |
|
6732 | + $component->setConfig('format', $this->getConfig('format')); |
|
6733 | + if (!in_array($component->objName, array('valarm', 'vtimezone', 'standard', 'daylight'))) { |
|
6734 | + unset($component->propix); |
|
6735 | 6735 | /* make sure dtstamp and uid is set */ |
6736 | - $dummy = $component->getProperty( 'dtstamp' ); |
|
6737 | - $dummy = $component->getProperty( 'uid' ); |
|
6736 | + $dummy = $component->getProperty('dtstamp'); |
|
6737 | + $dummy = $component->getProperty('uid'); |
|
6738 | 6738 | } |
6739 | - if( !$arg1 ) { |
|
6739 | + if (!$arg1) { |
|
6740 | 6740 | $this->components[] = $component->copy(); |
6741 | 6741 | return TRUE; |
6742 | 6742 | } |
6743 | 6743 | $argType = $index = null; |
6744 | - if ( ctype_digit( (string) $arg1 )) { |
|
6744 | + if (ctype_digit((string) $arg1)) { |
|
6745 | 6745 | $argType = 'INDEX'; |
6746 | 6746 | $index = (int) $arg1 - 1; |
6747 | 6747 | } |
6748 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6749 | - $argType = strtolower( $arg1 ); |
|
6750 | - $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0; |
|
6748 | + elseif ((strlen($arg1) <= strlen('vfreebusy')) && (FALSE === strpos($arg1, '@'))) { |
|
6749 | + $argType = strtolower($arg1); |
|
6750 | + $index = (ctype_digit((string) $arg2)) ? ((int) $arg2) - 1 : 0; |
|
6751 | 6751 | } |
6752 | 6752 | $cix2sC = 0; |
6753 | - foreach ( $this->components as $cix => $component2 ) { |
|
6754 | - if( empty( $component2 )) continue; |
|
6755 | - unset( $component2->propix ); |
|
6756 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
|
6753 | + foreach ($this->components as $cix => $component2) { |
|
6754 | + if (empty($component2)) continue; |
|
6755 | + unset($component2->propix); |
|
6756 | + if (('INDEX' == $argType) && ($index == $cix)) { |
|
6757 | 6757 | $this->components[$cix] = $component->copy(); |
6758 | 6758 | return TRUE; |
6759 | 6759 | } |
6760 | - elseif( $argType == $component2->objName ) { |
|
6761 | - if( $index == $cix2sC ) { |
|
6760 | + elseif ($argType == $component2->objName) { |
|
6761 | + if ($index == $cix2sC) { |
|
6762 | 6762 | $this->components[$cix] = $component->copy(); |
6763 | 6763 | return TRUE; |
6764 | 6764 | } |
6765 | 6765 | $cix2sC++; |
6766 | 6766 | } |
6767 | - elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) { |
|
6767 | + elseif (!$argType && ($arg1 == $component2->getProperty('uid'))) { |
|
6768 | 6768 | $this->components[$cix] = $component->copy(); |
6769 | 6769 | return TRUE; |
6770 | 6770 | } |
@@ -6782,15 +6782,15 @@ discard block |
||
6782 | 6782 | */ |
6783 | 6783 | function createSubComponent() { |
6784 | 6784 | $output = null; |
6785 | - foreach( $this->components as $component ) { |
|
6786 | - if( empty( $component )) continue; |
|
6787 | - if( '' >= $component->getConfig( 'language')) |
|
6788 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
6789 | - $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
|
6790 | - $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
|
6791 | - $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
|
6792 | - $component->setConfig( 'format', $this->getConfig( 'format' )); |
|
6793 | - $output .= $component->createComponent( $this->xcaldecl ); |
|
6785 | + foreach ($this->components as $component) { |
|
6786 | + if (empty($component)) continue; |
|
6787 | + if ('' >= $component->getConfig('language')) |
|
6788 | + $component->setConfig('language', $this->getConfig('language')); |
|
6789 | + $component->setConfig('allowEmpty', $this->getConfig('allowEmpty')); |
|
6790 | + $component->setConfig('nl', $this->getConfig('nl')); |
|
6791 | + $component->setConfig('unique_id', $this->getConfig('unique_id')); |
|
6792 | + $component->setConfig('format', $this->getConfig('format')); |
|
6793 | + $output .= $component->createComponent($this->xcaldecl); |
|
6794 | 6794 | } |
6795 | 6795 | return $output; |
6796 | 6796 | } |
@@ -6817,21 +6817,21 @@ discard block |
||
6817 | 6817 | * @param string $value |
6818 | 6818 | * @return string |
6819 | 6819 | */ |
6820 | - function _size75( $string ) { |
|
6821 | - $strlen = strlen( $string ); |
|
6820 | + function _size75($string) { |
|
6821 | + $strlen = strlen($string); |
|
6822 | 6822 | $tmp = $string; |
6823 | 6823 | $string = null; |
6824 | - while( $strlen > 75 ) { |
|
6824 | + while ($strlen > 75) { |
|
6825 | 6825 | $breakAtChar = 75; |
6826 | - if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' ) |
|
6826 | + if (substr($tmp, ($breakAtChar - 1), strlen('\n')) == '\n') |
|
6827 | 6827 | $breakAtChar = $breakAtChar - 1; |
6828 | - $string .= substr( $tmp, 0, $breakAtChar ); |
|
6828 | + $string .= substr($tmp, 0, $breakAtChar); |
|
6829 | 6829 | $string .= $this->nl; |
6830 | - $tmp = ' '.substr( $tmp, $breakAtChar ); |
|
6831 | - $strlen = strlen( $tmp ); |
|
6830 | + $tmp = ' '.substr($tmp, $breakAtChar); |
|
6831 | + $strlen = strlen($tmp); |
|
6832 | 6832 | } // while |
6833 | - $string .= rtrim( $tmp ); // the rest |
|
6834 | - if( $this->nl != substr( $string, ( 0 - strlen( $this->nl )))) |
|
6833 | + $string .= rtrim($tmp); // the rest |
|
6834 | + if ($this->nl != substr($string, (0 - strlen($this->nl)))) |
|
6835 | 6835 | $string .= $this->nl; |
6836 | 6836 | return $string; |
6837 | 6837 | } |
@@ -6843,38 +6843,38 @@ discard block |
||
6843 | 6843 | * @param string $string |
6844 | 6844 | * @return string |
6845 | 6845 | */ |
6846 | - function _strrep( $string ) { |
|
6847 | - switch( $this->format ) { |
|
6846 | + function _strrep($string) { |
|
6847 | + switch ($this->format) { |
|
6848 | 6848 | case 'xcal': |
6849 | - $string = str_replace( '\n', $this->nl, $string); |
|
6850 | - $string = htmlspecialchars( strip_tags( stripslashes( urldecode ( $string )))); |
|
6849 | + $string = str_replace('\n', $this->nl, $string); |
|
6850 | + $string = htmlspecialchars(strip_tags(stripslashes(urldecode($string)))); |
|
6851 | 6851 | break; |
6852 | 6852 | default: |
6853 | 6853 | $pos = 0; |
6854 | - while( $pos <= strlen( $string )) { |
|
6855 | - $pos = strpos( $string, "\\", $pos ); |
|
6856 | - if( FALSE === $pos ) |
|
6854 | + while ($pos <= strlen($string)) { |
|
6855 | + $pos = strpos($string, "\\", $pos); |
|
6856 | + if (FALSE === $pos) |
|
6857 | 6857 | break; |
6858 | - if( !in_array( $string{($pos + 1)}, array( 'n', 'N', 'r', ',', ';' ))) { |
|
6859 | - $string = substr( $string, 0, $pos )."\\".substr( $string, ( $pos + 1 )); |
|
6858 | + if (!in_array($string{($pos + 1)}, array('n', 'N', 'r', ',', ';'))) { |
|
6859 | + $string = substr($string, 0, $pos)."\\".substr($string, ($pos + 1)); |
|
6860 | 6860 | $pos += 1; |
6861 | 6861 | } |
6862 | 6862 | $pos += 1; |
6863 | 6863 | } |
6864 | - if( FALSE !== strpos( $string, '"' )) |
|
6865 | - $string = str_replace('"', "'", $string); |
|
6866 | - if( FALSE !== strpos( $string, ',' )) |
|
6867 | - $string = str_replace(',', '\,', $string); |
|
6868 | - if( FALSE !== strpos( $string, ';' )) |
|
6869 | - $string = str_replace(';', '\;', $string); |
|
6870 | - if( FALSE !== strpos( $string, "\r\n" )) |
|
6871 | - $string = str_replace( "\r\n", '\n', $string); |
|
6872 | - elseif( FALSE !== strpos( $string, "\r" )) |
|
6873 | - $string = str_replace( "\r", '\n', $string); |
|
6874 | - if( FALSE !== strpos( $string, '\N' )) |
|
6875 | - $string = str_replace( '\N', '\n', $string); |
|
6864 | + if (FALSE !== strpos($string, '"')) |
|
6865 | + $string = str_replace('"', "'", $string); |
|
6866 | + if (FALSE !== strpos($string, ',')) |
|
6867 | + $string = str_replace(',', '\,', $string); |
|
6868 | + if (FALSE !== strpos($string, ';')) |
|
6869 | + $string = str_replace(';', '\;', $string); |
|
6870 | + if (FALSE !== strpos($string, "\r\n")) |
|
6871 | + $string = str_replace("\r\n", '\n', $string); |
|
6872 | + elseif (FALSE !== strpos($string, "\r")) |
|
6873 | + $string = str_replace("\r", '\n', $string); |
|
6874 | + if (FALSE !== strpos($string, '\N')) |
|
6875 | + $string = str_replace('\N', '\n', $string); |
|
6876 | 6876 | // if( FALSE !== strpos( $string, $this->nl )) |
6877 | - $string = str_replace( $this->nl, '\n', $string); |
|
6877 | + $string = str_replace($this->nl, '\n', $string); |
|
6878 | 6878 | break; |
6879 | 6879 | } |
6880 | 6880 | return $string; |
@@ -6887,10 +6887,10 @@ discard block |
||
6887 | 6887 | * @param string $string |
6888 | 6888 | * @return string |
6889 | 6889 | */ |
6890 | - function _strunrep( $string ) { |
|
6891 | - $string = str_replace( '\\\\', '\\', $string); |
|
6892 | - $string = str_replace( '\,', ',', $string); |
|
6893 | - $string = str_replace( '\;', ';', $string); |
|
6890 | + function _strunrep($string) { |
|
6891 | + $string = str_replace('\\\\', '\\', $string); |
|
6892 | + $string = str_replace('\,', ',', $string); |
|
6893 | + $string = str_replace('\;', ';', $string); |
|
6894 | 6894 | // $string = str_replace( '\n', $this->nl, $string); // ?? |
6895 | 6895 | return $string; |
6896 | 6896 | } |
@@ -6988,7 +6988,7 @@ discard block |
||
6988 | 6988 | * @param array $xcaldecl |
6989 | 6989 | * @return string |
6990 | 6990 | */ |
6991 | - function createComponent( &$xcaldecl ) { |
|
6991 | + function createComponent(&$xcaldecl) { |
|
6992 | 6992 | $objectname = $this->_createFormat(); |
6993 | 6993 | $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; |
6994 | 6994 | $component .= $this->createUid(); |
@@ -7025,8 +7025,8 @@ discard block |
||
7025 | 7025 | $component .= $this->createXprop(); |
7026 | 7026 | $component .= $this->createSubComponent(); |
7027 | 7027 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7028 | - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
|
7029 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7028 | + if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) { |
|
7029 | + foreach ($this->xcaldecl as $localxcaldecl) |
|
7030 | 7030 | $xcaldecl[] = $localxcaldecl; |
7031 | 7031 | } |
7032 | 7032 | return $component; |
@@ -7126,7 +7126,7 @@ discard block |
||
7126 | 7126 | * @param array $xcaldecl |
7127 | 7127 | * @return string |
7128 | 7128 | */ |
7129 | - function createComponent( &$xcaldecl ) { |
|
7129 | + function createComponent(&$xcaldecl) { |
|
7130 | 7130 | $objectname = $this->_createFormat(); |
7131 | 7131 | $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; |
7132 | 7132 | $component .= $this->createUid(); |
@@ -7164,8 +7164,8 @@ discard block |
||
7164 | 7164 | $component .= $this->createXprop(); |
7165 | 7165 | $component .= $this->createSubComponent(); |
7166 | 7166 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7167 | - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
|
7168 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7167 | + if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) { |
|
7168 | + foreach ($this->xcaldecl as $localxcaldecl) |
|
7169 | 7169 | $xcaldecl[] = $localxcaldecl; |
7170 | 7170 | } |
7171 | 7171 | return $component; |
@@ -7245,7 +7245,7 @@ discard block |
||
7245 | 7245 | * @param array $xcaldecl |
7246 | 7246 | * @return string |
7247 | 7247 | */ |
7248 | - function createComponent( &$xcaldecl ) { |
|
7248 | + function createComponent(&$xcaldecl) { |
|
7249 | 7249 | $objectname = $this->_createFormat(); |
7250 | 7250 | $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; |
7251 | 7251 | $component .= $this->createUid(); |
@@ -7274,8 +7274,8 @@ discard block |
||
7274 | 7274 | $component .= $this->createUrl(); |
7275 | 7275 | $component .= $this->createXprop(); |
7276 | 7276 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7277 | - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
|
7278 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7277 | + if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) { |
|
7278 | + foreach ($this->xcaldecl as $localxcaldecl) |
|
7279 | 7279 | $xcaldecl[] = $localxcaldecl; |
7280 | 7280 | } |
7281 | 7281 | return $component; |
@@ -7333,7 +7333,7 @@ discard block |
||
7333 | 7333 | * @param array $xcaldecl |
7334 | 7334 | * @return string |
7335 | 7335 | */ |
7336 | - function createComponent( &$xcaldecl ) { |
|
7336 | + function createComponent(&$xcaldecl) { |
|
7337 | 7337 | $objectname = $this->_createFormat(); |
7338 | 7338 | $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; |
7339 | 7339 | $component .= $this->createUid(); |
@@ -7350,8 +7350,8 @@ discard block |
||
7350 | 7350 | $component .= $this->createUrl(); |
7351 | 7351 | $component .= $this->createXprop(); |
7352 | 7352 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7353 | - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
|
7354 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7353 | + if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) { |
|
7354 | + foreach ($this->xcaldecl as $localxcaldecl) |
|
7355 | 7355 | $xcaldecl[] = $localxcaldecl; |
7356 | 7356 | } |
7357 | 7357 | return $component; |
@@ -7403,7 +7403,7 @@ discard block |
||
7403 | 7403 | * @param array $xcaldecl |
7404 | 7404 | * @return string |
7405 | 7405 | */ |
7406 | - function createComponent( &$xcaldecl ) { |
|
7406 | + function createComponent(&$xcaldecl) { |
|
7407 | 7407 | $objectname = $this->_createFormat(); |
7408 | 7408 | $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; |
7409 | 7409 | $component .= $this->createAction(); |
@@ -7451,11 +7451,11 @@ discard block |
||
7451 | 7451 | * @param string $timezonetype optional, default FALSE ( STANDARD / DAYLIGHT ) |
7452 | 7452 | * @return void |
7453 | 7453 | */ |
7454 | - function __construct( $timezonetype=FALSE ) { |
|
7455 | - if( !$timezonetype ) |
|
7454 | + function __construct($timezonetype = FALSE) { |
|
7455 | + if (!$timezonetype) |
|
7456 | 7456 | $this->timezonetype = 'VTIMEZONE'; |
7457 | 7457 | else |
7458 | - $this->timezonetype = strtoupper( $timezonetype ); |
|
7458 | + $this->timezonetype = strtoupper($timezonetype); |
|
7459 | 7459 | $this->calendarComponent(); |
7460 | 7460 | |
7461 | 7461 | $this->comment = ''; |
@@ -7480,7 +7480,7 @@ discard block |
||
7480 | 7480 | * @param array $xcaldecl |
7481 | 7481 | * @return string |
7482 | 7482 | */ |
7483 | - function createComponent( &$xcaldecl ) { |
|
7483 | + function createComponent(&$xcaldecl) { |
|
7484 | 7484 | $objectname = $this->_createFormat(); |
7485 | 7485 | $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; |
7486 | 7486 | $component .= $this->createTzid(); |
@@ -7496,8 +7496,8 @@ discard block |
||
7496 | 7496 | $component .= $this->createXprop(); |
7497 | 7497 | $component .= $this->createSubComponent(); |
7498 | 7498 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7499 | - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
|
7500 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7499 | + if (is_array($this->xcaldecl) && (0 < count($this->xcaldecl))) { |
|
7500 | + foreach ($this->xcaldecl as $localxcaldecl) |
|
7501 | 7501 | $xcaldecl[] = $localxcaldecl; |
7502 | 7502 | } |
7503 | 7503 | return $component; |
@@ -44,8 +44,10 @@ discard block |
||
44 | 44 | } |
45 | 45 | */ |
46 | 46 | /* only for phpversion 5.x, date management, default timezone setting */ |
47 | -if( substr( phpversion(), 0, 1) >= '5' ) // && ( 'UTC' == date_default_timezone_get() )) { |
|
47 | +if( substr( phpversion(), 0, 1) >= '5' ) { |
|
48 | + // && ( 'UTC' == date_default_timezone_get() )) { |
|
48 | 49 | date_default_timezone_set( 'Europe/Stockholm' ); |
50 | +} |
|
49 | 51 | /* version string, do NOT remove!! */ |
50 | 52 | define( 'ICALCREATOR_VERSION', 'iCalcreator 2.6' ); |
51 | 53 | /*********************************************************************************/ |
@@ -97,8 +99,9 @@ discard block |
||
97 | 99 | /** |
98 | 100 | * language = <Text identifying a language, as defined in [RFC 1766]> |
99 | 101 | */ |
100 | - if( defined( 'ICAL_LANG' )) |
|
101 | - $this->setConfig( 'language', ICAL_LANG ); |
|
102 | + if( defined( 'ICAL_LANG' )) { |
|
103 | + $this->setConfig( 'language', ICAL_LANG ); |
|
104 | + } |
|
102 | 105 | $this->setConfig( 'allowEmpty', TRUE ); |
103 | 106 | $this->setConfig( 'nl', "\n" ); |
104 | 107 | $this->setConfig( 'format', 'iCal'); |
@@ -121,7 +124,9 @@ discard block |
||
121 | 124 | * @return string |
122 | 125 | */ |
123 | 126 | function createCalscale() { |
124 | - if( empty( $this->calscale )) return FALSE; |
|
127 | + if( empty( $this->calscale )) { |
|
128 | + return FALSE; |
|
129 | + } |
|
125 | 130 | switch( $this->format ) { |
126 | 131 | case 'xcal': |
127 | 132 | return ' calscale="'.$this->calscale.'"'.$this->nl; |
@@ -140,7 +145,9 @@ discard block |
||
140 | 145 | * @return void |
141 | 146 | */ |
142 | 147 | function setCalscale( $value ) { |
143 | - if( empty( $value )) return FALSE; |
|
148 | + if( empty( $value )) { |
|
149 | + return FALSE; |
|
150 | + } |
|
144 | 151 | $this->calscale = $value; |
145 | 152 | } |
146 | 153 | /*********************************************************************************/ |
@@ -155,7 +162,9 @@ discard block |
||
155 | 162 | * @return string |
156 | 163 | */ |
157 | 164 | function createMethod() { |
158 | - if( empty( $this->method )) return FALSE; |
|
165 | + if( empty( $this->method )) { |
|
166 | + return FALSE; |
|
167 | + } |
|
159 | 168 | switch( $this->format ) { |
160 | 169 | case 'xcal': |
161 | 170 | return ' method="'.$this->method.'"'.$this->nl; |
@@ -174,7 +183,9 @@ discard block |
||
174 | 183 | * @return bool |
175 | 184 | */ |
176 | 185 | function setMethod( $value ) { |
177 | - if( empty( $value )) return FALSE; |
|
186 | + if( empty( $value )) { |
|
187 | + return FALSE; |
|
188 | + } |
|
178 | 189 | $this->method = $value; |
179 | 190 | return TRUE; |
180 | 191 | } |
@@ -194,8 +205,9 @@ discard block |
||
194 | 205 | * @return string |
195 | 206 | */ |
196 | 207 | function createProdid() { |
197 | - if( !isset( $this->prodid )) |
|
198 | - $this->_makeProdid(); |
|
208 | + if( !isset( $this->prodid )) { |
|
209 | + $this->_makeProdid(); |
|
210 | + } |
|
199 | 211 | switch( $this->format ) { |
200 | 212 | case 'xcal': |
201 | 213 | return ' prodid="'.$this->prodid.'"'.$this->nl; |
@@ -246,8 +258,9 @@ discard block |
||
246 | 258 | * @return string |
247 | 259 | */ |
248 | 260 | function createVersion() { |
249 | - if( empty( $this->version )) |
|
250 | - $this->_makeVersion(); |
|
261 | + if( empty( $this->version )) { |
|
262 | + $this->_makeVersion(); |
|
263 | + } |
|
251 | 264 | switch( $this->format ) { |
252 | 265 | case 'xcal': |
253 | 266 | return ' version="'.$this->version.'"'.$this->nl; |
@@ -276,7 +289,9 @@ discard block |
||
276 | 289 | * @return void |
277 | 290 | */ |
278 | 291 | function setVersion( $value ) { |
279 | - if( empty( $value )) return FALSE; |
|
292 | + if( empty( $value )) { |
|
293 | + return FALSE; |
|
294 | + } |
|
280 | 295 | $this->version = $value; |
281 | 296 | return TRUE; |
282 | 297 | } |
@@ -292,10 +307,12 @@ discard block |
||
292 | 307 | * @return string |
293 | 308 | */ |
294 | 309 | function createXprop() { |
295 | - if( 'xcal' == $this->format ) |
|
296 | - return false; |
|
297 | - if( 0 >= count( $this->xprop )) |
|
298 | - return; |
|
310 | + if( 'xcal' == $this->format ) { |
|
311 | + return false; |
|
312 | + } |
|
313 | + if( 0 >= count( $this->xprop )) { |
|
314 | + return; |
|
315 | + } |
|
299 | 316 | $output = null; |
300 | 317 | $toolbox = new calendarComponent(); |
301 | 318 | $toolbox->setConfig( 'language', $this->getConfig( 'language' )); |
@@ -308,12 +325,13 @@ discard block |
||
308 | 325 | } |
309 | 326 | $attributes = $toolbox->_createParams( $xpropPart['params'], array( 'LANGUAGE' )); |
310 | 327 | if( is_array( $xpropPart['value'] )) { |
311 | - foreach( $xpropPart['value'] as $pix => $theXpart ) |
|
312 | - $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart ); |
|
328 | + foreach( $xpropPart['value'] as $pix => $theXpart ) { |
|
329 | + $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart ); |
|
330 | + } |
|
313 | 331 | $xpropPart['value'] = implode( ',', $xpropPart['value'] ); |
332 | + } else { |
|
333 | + $xpropPart['value'] = $toolbox->_strrep( $xpropPart['value'] ); |
|
314 | 334 | } |
315 | - else |
|
316 | - $xpropPart['value'] = $toolbox->_strrep( $xpropPart['value'] ); |
|
317 | 335 | $output .= $toolbox->_createElement( $label, $attributes, $xpropPart['value'] ); |
318 | 336 | } |
319 | 337 | return $output; |
@@ -329,12 +347,20 @@ discard block |
||
329 | 347 | * @return bool |
330 | 348 | */ |
331 | 349 | function setXprop( $label, $value, $params=FALSE ) { |
332 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
333 | - if( empty( $label )) return FALSE; |
|
350 | + if( empty( $value )) { |
|
351 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
352 | + } else { |
|
353 | + return FALSE; |
|
354 | + } |
|
355 | + if( empty( $label )) { |
|
356 | + return FALSE; |
|
357 | + } |
|
334 | 358 | $xprop = array( 'value' => $value ); |
335 | 359 | $toolbox = new calendarComponent(); |
336 | 360 | $xprop['params'] = $toolbox->_setParams( $params ); |
337 | - if( !is_array( $this->xprop )) $this->xprop = array(); |
|
361 | + if( !is_array( $this->xprop )) { |
|
362 | + $this->xprop = array(); |
|
363 | + } |
|
338 | 364 | $this->xprop[strtoupper( $label )] = $xprop; |
339 | 365 | return TRUE; |
340 | 366 | } |
@@ -350,8 +376,9 @@ discard block |
||
350 | 376 | */ |
351 | 377 | function deleteProperty( $propName, $propix=FALSE ) { |
352 | 378 | $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP'; |
353 | - if( !$propix ) |
|
354 | - $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1; |
|
379 | + if( !$propix ) { |
|
380 | + $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1; |
|
381 | + } |
|
355 | 382 | $this->propdelix[$propName] = --$propix; |
356 | 383 | $return = FALSE; |
357 | 384 | switch( $propName ) { |
@@ -370,18 +397,23 @@ discard block |
||
370 | 397 | default: |
371 | 398 | $reduced = array(); |
372 | 399 | if( $propName != 'X-PROP' ) { |
373 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
400 | + if( !isset( $this->xprop[$propName] )) { |
|
401 | + return FALSE; |
|
402 | + } |
|
374 | 403 | foreach( $this->xprop as $k => $a ) { |
375 | - if(( $k != $propName ) && !empty( $a )) |
|
376 | - $reduced[$k] = $a; |
|
404 | + if(( $k != $propName ) && !empty( $a )) { |
|
405 | + $reduced[$k] = $a; |
|
406 | + } |
|
407 | + } |
|
408 | + } else { |
|
409 | + if( count( $this->xprop ) <= $propix ) { |
|
410 | + return FALSE; |
|
377 | 411 | } |
378 | - } |
|
379 | - else { |
|
380 | - if( count( $this->xprop ) <= $propix ) return FALSE; |
|
381 | 412 | $xpropno = 0; |
382 | 413 | foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
383 | - if( $propix != $xpropno ) |
|
384 | - $reduced[$xpropkey] = $xpropvalue; |
|
414 | + if( $propix != $xpropno ) { |
|
415 | + $reduced[$xpropkey] = $xpropvalue; |
|
416 | + } |
|
385 | 417 | $xpropno++; |
386 | 418 | } |
387 | 419 | } |
@@ -403,8 +435,9 @@ discard block |
||
403 | 435 | function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE ) { |
404 | 436 | $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP'; |
405 | 437 | if( 'X-PROP' == $propName ) { |
406 | - if( !$propix ) |
|
407 | - $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; |
|
438 | + if( !$propix ) { |
|
439 | + $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; |
|
440 | + } |
|
408 | 441 | $this->propix[$propName] = --$propix; |
409 | 442 | } |
410 | 443 | switch( $propName ) { |
@@ -415,8 +448,9 @@ discard block |
||
415 | 448 | return ( !empty( $this->method )) ? $this->method : null; |
416 | 449 | break; |
417 | 450 | case 'PRODID': |
418 | - if( empty( $this->prodid )) |
|
419 | - $this->_makeProdid(); |
|
451 | + if( empty( $this->prodid )) { |
|
452 | + $this->_makeProdid(); |
|
453 | + } |
|
420 | 454 | return $this->prodid; |
421 | 455 | break; |
422 | 456 | case 'VERSION': |
@@ -424,19 +458,23 @@ discard block |
||
424 | 458 | break; |
425 | 459 | default: |
426 | 460 | if( $propName != 'X-PROP' ) { |
427 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
461 | + if( !isset( $this->xprop[$propName] )) { |
|
462 | + return FALSE; |
|
463 | + } |
|
428 | 464 | return ( $inclParam ) ? array( $propName, $this->xprop[$propName] ) |
429 | 465 | : array( $propName, $this->xprop[$propName]['value'] ); |
430 | - } |
|
431 | - else { |
|
432 | - if( empty( $this->xprop )) return FALSE; |
|
466 | + } else { |
|
467 | + if( empty( $this->xprop )) { |
|
468 | + return FALSE; |
|
469 | + } |
|
433 | 470 | $xpropno = 0; |
434 | 471 | foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
435 | - if( $propix == $xpropno ) |
|
436 | - return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) |
|
472 | + if( $propix == $xpropno ) { |
|
473 | + return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) |
|
437 | 474 | : array( $xpropkey, $this->xprop[$xpropkey]['value'] ); |
438 | - else |
|
439 | - $xpropno++; |
|
475 | + } else { |
|
476 | + $xpropno++; |
|
477 | + } |
|
440 | 478 | } |
441 | 479 | return FALSE; // not found ?? |
442 | 480 | } |
@@ -455,8 +493,9 @@ discard block |
||
455 | 493 | */ |
456 | 494 | function setProperty () { |
457 | 495 | $numargs = func_num_args(); |
458 | - if( 1 > $numargs ) |
|
459 | - return FALSE; |
|
496 | + if( 1 > $numargs ) { |
|
497 | + return FALSE; |
|
498 | + } |
|
460 | 499 | $arglist = func_get_args(); |
461 | 500 | $arglist[0] = strtoupper( $arglist[0] ); |
462 | 501 | switch( $arglist[0] ) { |
@@ -467,8 +506,12 @@ discard block |
||
467 | 506 | case 'VERSION': |
468 | 507 | return $this->setVersion( $arglist[1] ); |
469 | 508 | default: |
470 | - if( !isset( $arglist[1] )) $arglist[1] = null; |
|
471 | - if( !isset( $arglist[2] )) $arglist[2] = null; |
|
509 | + if( !isset( $arglist[1] )) { |
|
510 | + $arglist[1] = null; |
|
511 | + } |
|
512 | + if( !isset( $arglist[2] )) { |
|
513 | + $arglist[2] = null; |
|
514 | + } |
|
472 | 515 | return $this->setXprop( $arglist[0], $arglist[1], $arglist[2] ); |
473 | 516 | } |
474 | 517 | return FALSE; |
@@ -491,7 +534,9 @@ discard block |
||
491 | 534 | unset( $this->compix ); |
492 | 535 | $info = array(); |
493 | 536 | foreach( $this->components as $cix => $component ) { |
494 | - if( empty( $component )) continue; |
|
537 | + if( empty( $component )) { |
|
538 | + continue; |
|
539 | + } |
|
495 | 540 | unset( $component->propix ); |
496 | 541 | $info[$cix]['ordno'] = $cix + 1; |
497 | 542 | $info[$cix]['type'] = $component->objName; |
@@ -506,8 +551,9 @@ discard block |
||
506 | 551 | return $this->delimiter; |
507 | 552 | break; |
508 | 553 | case 'DIRECTORY': |
509 | - if( empty( $this->directory )) |
|
510 | - $this->directory = '.'; |
|
554 | + if( empty( $this->directory )) { |
|
555 | + $this->directory = '.'; |
|
556 | + } |
|
511 | 557 | return $this->directory; |
512 | 558 | break; |
513 | 559 | case 'DIRFILE': |
@@ -520,10 +566,13 @@ discard block |
||
520 | 566 | break; |
521 | 567 | case 'FILENAME': |
522 | 568 | if( empty( $this->filename )) { |
523 | - if( 'xcal' == $this->format ) |
|
524 | - $this->filename = date( 'YmdHis' ).'.xml'; // recommended xcs.. . |
|
525 | - else |
|
526 | - $this->filename = date( 'YmdHis' ).'.ics'; |
|
569 | + if( 'xcal' == $this->format ) { |
|
570 | + $this->filename = date( 'YmdHis' ).'.xml'; |
|
571 | + } |
|
572 | + // recommended xcs.. . |
|
573 | + else { |
|
574 | + $this->filename = date( 'YmdHis' ).'.ics'; |
|
575 | + } |
|
527 | 576 | } |
528 | 577 | return $this->filename; |
529 | 578 | break; |
@@ -531,8 +580,9 @@ discard block |
||
531 | 580 | $size = 0; |
532 | 581 | if( empty( $this->url )) { |
533 | 582 | $dirfile = $this->getConfig( 'dirfile' ); |
534 | - if( FALSE === ( $size = filesize( $dirfile ))) |
|
535 | - $size = 0; |
|
583 | + if( FALSE === ( $size = filesize( $dirfile ))) { |
|
584 | + $size = 0; |
|
585 | + } |
|
536 | 586 | clearstatcache(); |
537 | 587 | } |
538 | 588 | return $size; |
@@ -552,10 +602,11 @@ discard block |
||
552 | 602 | return $this->unique_id; |
553 | 603 | break; |
554 | 604 | case 'URL': |
555 | - if( !empty( $this->url )) |
|
556 | - return $this->url; |
|
557 | - else |
|
558 | - return FALSE; |
|
605 | + if( !empty( $this->url )) { |
|
606 | + return $this->url; |
|
607 | + } else { |
|
608 | + return FALSE; |
|
609 | + } |
|
559 | 610 | break; |
560 | 611 | } |
561 | 612 | } |
@@ -583,17 +634,18 @@ discard block |
||
583 | 634 | case 'DIRECTORY': |
584 | 635 | $value = trim( $value ); |
585 | 636 | $nl = $this->getConfig('delimiter'); |
586 | - if( $nl == substr( $value, ( 0 - strlen( $nl )))) |
|
587 | - $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl ))); |
|
637 | + if( $nl == substr( $value, ( 0 - strlen( $nl )))) { |
|
638 | + $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl ))); |
|
639 | + } |
|
588 | 640 | if( is_dir( $value )) { |
589 | 641 | /* local directory */ |
590 | 642 | clearstatcache(); |
591 | 643 | $this->directory = $value; |
592 | 644 | $this->url = null; |
593 | 645 | return TRUE; |
646 | + } else { |
|
647 | + return FALSE; |
|
594 | 648 | } |
595 | - else |
|
596 | - return FALSE; |
|
597 | 649 | break; |
598 | 650 | case 'FILENAME': |
599 | 651 | $value = trim( $value ); |
@@ -609,17 +661,16 @@ discard block |
||
609 | 661 | clearstatcache(); |
610 | 662 | $this->filename = $value; |
611 | 663 | return TRUE; |
664 | + } else { |
|
665 | + return FALSE; |
|
612 | 666 | } |
613 | - else |
|
614 | - return FALSE; |
|
615 | - } |
|
616 | - elseif( FALSE !== touch( $dirfile )) { |
|
667 | + } elseif( FALSE !== touch( $dirfile )) { |
|
617 | 668 | /* new local file created */ |
618 | 669 | $this->filename = $value; |
619 | 670 | return TRUE; |
671 | + } else { |
|
672 | + return FALSE; |
|
620 | 673 | } |
621 | - else |
|
622 | - return FALSE; |
|
623 | 674 | break; |
624 | 675 | case 'FORMAT': |
625 | 676 | $value = trim( $value ); |
@@ -627,8 +678,7 @@ discard block |
||
627 | 678 | $this->format = 'xcal'; |
628 | 679 | $this->attributeDelimiter = $this->nl; |
629 | 680 | $this->valueInit = null; |
630 | - } |
|
631 | - else { |
|
681 | + } else { |
|
632 | 682 | $this->format = null; |
633 | 683 | $this->attributeDelimiter = ';'; |
634 | 684 | $this->valueInit = ':'; |
@@ -667,13 +717,16 @@ discard block |
||
667 | 717 | return $this->setConfig( 'filename', $parts['basename'] ); |
668 | 718 | break; |
669 | 719 | } |
670 | - if( !$res ) return FALSE; |
|
720 | + if( !$res ) { |
|
721 | + return FALSE; |
|
722 | + } |
|
671 | 723 | if( isset( $subcfg ) && !empty( $this->components )) { |
672 | 724 | foreach( $subcfg as $cfgkey => $cfgvalue ) { |
673 | 725 | foreach( $this->components as $cix => $component ) { |
674 | 726 | $res = $component->setConfig( $cfgkey, $cfgvalue ); |
675 | - if( !$res ) |
|
676 | - break 2; |
|
727 | + if( !$res ) { |
|
728 | + break 2; |
|
729 | + } |
|
677 | 730 | $this->components[$cix] = $component->copy(); // PHP4 compliant |
678 | 731 | } |
679 | 732 | } |
@@ -708,27 +761,26 @@ discard block |
||
708 | 761 | if ( ctype_digit( (string) $arg1 )) { |
709 | 762 | $argType = 'INDEX'; |
710 | 763 | $index = (int) $arg1 - 1; |
711 | - } |
|
712 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
764 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
713 | 765 | $argType = strtolower( $arg1 ); |
714 | 766 | $index = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0; |
715 | 767 | } |
716 | 768 | $cix1dC = 0; |
717 | 769 | foreach ( $this->components as $cix => $component) { |
718 | - if( empty( $component )) continue; |
|
770 | + if( empty( $component )) { |
|
771 | + continue; |
|
772 | + } |
|
719 | 773 | unset( $component->propix ); |
720 | 774 | if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
721 | 775 | unset( $this->components[$cix] ); |
722 | 776 | return TRUE; |
723 | - } |
|
724 | - elseif( $argType == $component->objName ) { |
|
777 | + } elseif( $argType == $component->objName ) { |
|
725 | 778 | if( $index == $cix1dC ) { |
726 | 779 | unset( $this->components[$cix] ); |
727 | 780 | return TRUE; |
728 | 781 | } |
729 | 782 | $cix1dC++; |
730 | - } |
|
731 | - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
783 | + } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
732 | 784 | unset( $this->components[$cix] ); |
733 | 785 | return TRUE; |
734 | 786 | } |
@@ -750,37 +802,39 @@ discard block |
||
750 | 802 | $argType = 'INDEX'; |
751 | 803 | $index = $this->compix['INDEX'] = |
752 | 804 | ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1; |
753 | - } |
|
754 | - elseif ( ctype_digit( (string) $arg1 )) { |
|
805 | + } elseif ( ctype_digit( (string) $arg1 )) { |
|
755 | 806 | $argType = 'INDEX'; |
756 | 807 | $index = (int) $arg1; |
757 | 808 | unset( $this->compix ); |
758 | - } |
|
759 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
809 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
760 | 810 | unset( $this->compix['INDEX'] ); |
761 | 811 | $argType = strtolower( $arg1 ); |
762 | - if( !$arg2 ) |
|
763 | - $index = $this->compix[$argType] = |
|
812 | + if( !$arg2 ) { |
|
813 | + $index = $this->compix[$argType] = |
|
764 | 814 | ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1; |
765 | - else |
|
766 | - $index = (int) $arg2; |
|
815 | + } else { |
|
816 | + $index = (int) $arg2; |
|
817 | + } |
|
767 | 818 | } |
768 | 819 | $index -= 1; |
769 | 820 | $ckeys = array_keys( $this->components ); |
770 | - if( !empty( $index) && ( $index > end( $ckeys ))) |
|
771 | - return FALSE; |
|
821 | + if( !empty( $index) && ( $index > end( $ckeys ))) { |
|
822 | + return FALSE; |
|
823 | + } |
|
772 | 824 | $cix1gC = 0; |
773 | 825 | foreach ( $this->components as $cix => $component) { |
774 | - if( empty( $component )) continue; |
|
826 | + if( empty( $component )) { |
|
827 | + continue; |
|
828 | + } |
|
775 | 829 | unset( $component->propix ); |
776 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) |
|
777 | - return $component->copy(); |
|
778 | - elseif( $argType == $component->objName ) { |
|
779 | - if( $index == $cix1gC ) |
|
780 | - return $component->copy(); |
|
830 | + if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
|
831 | + return $component->copy(); |
|
832 | + } elseif( $argType == $component->objName ) { |
|
833 | + if( $index == $cix1gC ) { |
|
834 | + return $component->copy(); |
|
835 | + } |
|
781 | 836 | $cix1gC++; |
782 | - } |
|
783 | - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
837 | + } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
784 | 838 | unset( $component->propix ); |
785 | 839 | return $component->copy(); |
786 | 840 | } |
@@ -815,46 +869,68 @@ discard block |
||
815 | 869 | */ |
816 | 870 | function selectComponents( $startY=FALSE, $startM=FALSE, $startD=FALSE, $endY=FALSE, $endM=FALSE, $endD=FALSE, $cType=FALSE, $flat=FALSE, $any=TRUE, $split=TRUE ) { |
817 | 871 | /* check if empty calendar */ |
818 | - if( 0 >= count( $this->components )) return FALSE; |
|
872 | + if( 0 >= count( $this->components )) { |
|
873 | + return FALSE; |
|
874 | + } |
|
819 | 875 | /* check default dates */ |
820 | - if( !$startY ) $startY = date( 'Y' ); |
|
821 | - if( !$startM ) $startM = date( 'm' ); |
|
822 | - if( !$startD ) $startD = date( 'd' ); |
|
876 | + if( !$startY ) { |
|
877 | + $startY = date( 'Y' ); |
|
878 | + } |
|
879 | + if( !$startM ) { |
|
880 | + $startM = date( 'm' ); |
|
881 | + } |
|
882 | + if( !$startD ) { |
|
883 | + $startD = date( 'd' ); |
|
884 | + } |
|
823 | 885 | $startDate = mktime( 0, 0, 0, $startM, $startD, $startY ); |
824 | - if( !$endY ) $endY = $startY; |
|
825 | - if( !$endM ) $endM = $startM; |
|
826 | - if( !$endD ) $endD = $startD; |
|
886 | + if( !$endY ) { |
|
887 | + $endY = $startY; |
|
888 | + } |
|
889 | + if( !$endM ) { |
|
890 | + $endM = $startM; |
|
891 | + } |
|
892 | + if( !$endD ) { |
|
893 | + $endD = $startD; |
|
894 | + } |
|
827 | 895 | $endDate = mktime( 23, 59, 59, $endM, $endD, $endY ); |
828 | 896 | /* check component types */ |
829 | 897 | $validTypes = array('vevent', 'vtodo', 'vjournal', 'vfreebusy' ); |
830 | 898 | if( is_array( $cType )) { |
831 | 899 | foreach( $cType as $cix => $theType ) { |
832 | 900 | $cType[$cix] = $theType = strtolower( $theType ); |
833 | - if( !in_array( $theType, $validTypes )) |
|
834 | - $cType[$cix] = 'vevent'; |
|
901 | + if( !in_array( $theType, $validTypes )) { |
|
902 | + $cType[$cix] = 'vevent'; |
|
903 | + } |
|
835 | 904 | } |
836 | 905 | $cType = array_unique( $cType ); |
837 | - } |
|
838 | - elseif( !empty( $cType )) { |
|
906 | + } elseif( !empty( $cType )) { |
|
839 | 907 | $cType = strtolower( $cType ); |
840 | - if( !in_array( $cType, $validTypes )) |
|
841 | - $cType = array( 'vevent' ); |
|
842 | - else |
|
843 | - $cType = array( $cType ); |
|
844 | - } |
|
845 | - else |
|
846 | - $cType = $validTypes; |
|
847 | - if( 0 >= count( $cType )) |
|
848 | - $cType = $validTypes; |
|
908 | + if( !in_array( $cType, $validTypes )) { |
|
909 | + $cType = array( 'vevent' ); |
|
910 | + } else { |
|
911 | + $cType = array( $cType ); |
|
912 | + } |
|
913 | + } else { |
|
914 | + $cType = $validTypes; |
|
915 | + } |
|
916 | + if( 0 >= count( $cType )) { |
|
917 | + $cType = $validTypes; |
|
918 | + } |
|
849 | 919 | /* iterate components */ |
850 | 920 | $result = array(); |
851 | 921 | foreach ( $this->components as $cix => $component ) { |
852 | - if( empty( $component )) continue; |
|
922 | + if( empty( $component )) { |
|
923 | + continue; |
|
924 | + } |
|
853 | 925 | unset( $component->propix, $start ); |
854 | 926 | /* deselect unvalid type components */ |
855 | - if( !in_array( $component->objName, $cType )) continue; |
|
927 | + if( !in_array( $component->objName, $cType )) { |
|
928 | + continue; |
|
929 | + } |
|
856 | 930 | /* deselect components without dtstart set */ |
857 | - if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) continue; |
|
931 | + if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) { |
|
932 | + continue; |
|
933 | + } |
|
858 | 934 | $dtendExist = $dueExist = $durationExist = $endAllDayEvent = FALSE; |
859 | 935 | unset( $end, $startWdate, $endWdate, $rdurWsecs, $rdur, $exdatelist, $workstart, $workend ); // clean up |
860 | 936 | $startWdate = $component->_date2timestamp( $start ); |
@@ -888,8 +964,9 @@ discard block |
||
888 | 964 | } |
889 | 965 | if( empty( $end )) { |
890 | 966 | $end = $component->getProperty( 'duration', FALSE, FALSE, TRUE );// in dtend (array) format |
891 | - if( !empty( $end )) |
|
892 | - $durationExist = TRUE; |
|
967 | + if( !empty( $end )) { |
|
968 | + $durationExist = TRUE; |
|
969 | + } |
|
893 | 970 | // if( !empty($end)) echo 'selectComp 4 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ### |
894 | 971 | } |
895 | 972 | if( empty( $end )) { // assume one day duration if missing end date |
@@ -907,55 +984,75 @@ discard block |
||
907 | 984 | $exdatelist = array(); |
908 | 985 | $workstart = $component->_timestamp2date(( $startDate - $rdurWsecs ), 6); |
909 | 986 | $workend = $component->_timestamp2date(( $endDate + $rdurWsecs ), 6); |
910 | - while( FALSE !== ( $exrule = $component->getProperty( 'exrule' ))) // check exrule |
|
987 | + while( FALSE !== ( $exrule = $component->getProperty( 'exrule' ))) { |
|
988 | + // check exrule |
|
911 | 989 | $component->_recur2date( $exdatelist, $exrule, $start, $workstart, $workend ); |
990 | + } |
|
912 | 991 | while( FALSE !== ( $exdate = $component->getProperty( 'exdate' ))) { // check exdate |
913 | 992 | foreach( $exdate as $theExdate ) { |
914 | 993 | $exWdate = $component->_date2timestamp( $theExdate ); |
915 | - if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate )) |
|
916 | - $exdatelist[$exWdate] = TRUE; |
|
994 | + if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate )) { |
|
995 | + $exdatelist[$exWdate] = TRUE; |
|
996 | + } |
|
917 | 997 | } |
918 | 998 | } |
919 | 999 | /* if 'any' components, check repeating components, removing all excluding dates */ |
920 | 1000 | if( TRUE === $any ) { |
921 | 1001 | /* make a list of optional repeating dates for component occurence, rrule, rdate */ |
922 | 1002 | $recurlist = array(); |
923 | - while( FALSE !== ( $rrule = $component->getProperty( 'rrule' ))) // check rrule |
|
1003 | + while( FALSE !== ( $rrule = $component->getProperty( 'rrule' ))) { |
|
1004 | + // check rrule |
|
924 | 1005 | $component->_recur2date( $recurlist, $rrule, $start, $workstart, $workend ); |
925 | - foreach( $recurlist as $recurkey => $recurvalue ) // key=match date as timestamp |
|
926 | - $recurlist[$recurkey] = $rdurWsecs; // add duration in seconds |
|
1006 | + } |
|
1007 | + foreach( $recurlist as $recurkey => $recurvalue ) { |
|
1008 | + // key=match date as timestamp |
|
1009 | + $recurlist[$recurkey] = $rdurWsecs; |
|
1010 | + } |
|
1011 | + // add duration in seconds |
|
927 | 1012 | while( FALSE !== ( $rdate = $component->getProperty( 'rdate' ))) { // check rdate |
928 | 1013 | foreach( $rdate as $theRdate ) { |
929 | 1014 | if( is_array( $theRdate ) && ( 2 == count( $theRdate )) && // all days within PERIOD |
930 | 1015 | array_key_exists( '0', $theRdate ) && array_key_exists( '1', $theRdate )) { |
931 | 1016 | $rstart = $component->_date2timestamp( $theRdate[0] ); |
932 | - if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate )) |
|
933 | - continue; |
|
934 | - if( isset( $theRdate[1]['year'] )) // date-date period |
|
1017 | + if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate )) { |
|
1018 | + continue; |
|
1019 | + } |
|
1020 | + if( isset( $theRdate[1]['year'] )) { |
|
1021 | + // date-date period |
|
935 | 1022 | $rend = $component->_date2timestamp( $theRdate[1] ); |
936 | - else { // date-duration period |
|
1023 | + } else { // date-duration period |
|
937 | 1024 | $rend = $component->duration2date( $theRdate[0], $theRdate[1] ); |
938 | 1025 | $rend = $component->_date2timestamp( $rend ); |
939 | 1026 | } |
940 | - if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart )) |
|
941 | - $recurlist[$rstart] = ( $rstart - $rend ); // set start date + rdate duration in seconds |
|
1027 | + if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart )) { |
|
1028 | + $recurlist[$rstart] = ( $rstart - $rend ); |
|
1029 | + } |
|
1030 | + // set start date + rdate duration in seconds |
|
942 | 1031 | } // PERIOD end |
943 | 1032 | else { // single date |
944 | 1033 | $theRdate = $component->_date2timestamp( $theRdate ); |
945 | - if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate )) |
|
946 | - $recurlist[$theRdate] = $rdurWsecs; // set start date + event duration in seconds |
|
1034 | + if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate )) { |
|
1035 | + $recurlist[$theRdate] = $rdurWsecs; |
|
1036 | + } |
|
1037 | + // set start date + event duration in seconds |
|
947 | 1038 | } |
948 | 1039 | } |
949 | 1040 | } |
950 | 1041 | if( 0 < count( $recurlist )) { |
951 | 1042 | ksort( $recurlist ); |
952 | 1043 | foreach( $recurlist as $recurkey => $durvalue ) { |
953 | - if((( $startDate - $rdurWsecs ) > $recurkey ) || ( $endDate < $recurkey )) // not within period |
|
1044 | + if((( $startDate - $rdurWsecs ) > $recurkey ) || ( $endDate < $recurkey )) { |
|
1045 | + // not within period |
|
954 | 1046 | continue; |
955 | - if( isset( $exdatelist[$recurkey] )) // check excluded dates |
|
1047 | + } |
|
1048 | + if( isset( $exdatelist[$recurkey] )) { |
|
1049 | + // check excluded dates |
|
956 | 1050 | continue; |
957 | - if( $startWdate >= $recurkey ) // exclude component start date |
|
1051 | + } |
|
1052 | + if( $startWdate >= $recurkey ) { |
|
1053 | + // exclude component start date |
|
958 | 1054 | continue; |
1055 | + } |
|
959 | 1056 | $component2 = $component->copy(); |
960 | 1057 | $rstart = $component2->_timestamp2date( $recurkey, 6); |
961 | 1058 | $datevalue = $rstart['month'].'/'.$rstart['day'].'/'.$rstart['year']; |
@@ -965,16 +1062,16 @@ discard block |
||
965 | 1062 | $datevalue .= ( isset( $rstart['sec'] )) ? ':'.$rstart['sec'] : ':00'; |
966 | 1063 | } |
967 | 1064 | $datestring = date( $startDateFormat, strtotime( $datevalue )); |
968 | - if( isset( $start['tz'] )) |
|
969 | - $datestring .= ' '.$start['tz']; |
|
1065 | + if( isset( $start['tz'] )) { |
|
1066 | + $datestring .= ' '.$start['tz']; |
|
1067 | + } |
|
970 | 1068 | $component2->setProperty( 'X-CURRENT-DTSTART', $datestring ); |
971 | 1069 | $rend = $component2->_timestamp2date(( $recurkey + $durvalue ), 6); |
972 | 1070 | if( $dtendExist || $dueExist ) { |
973 | 1071 | if( $endAllDayEvent ) { |
974 | 1072 | $rend2 = mktime( 0, 0, 0, $rend['month'], ($rend['day'] + 1), $rend['year'] ); |
975 | 1073 | $datevalue = date( 'm', $rend2 ).'/'.date( 'd', $rend2 ).'/'.date( 'Y', $rend2 ); |
976 | - } |
|
977 | - else { |
|
1074 | + } else { |
|
978 | 1075 | $datevalue = $rend['month'].'/'.$rend['day'].'/'.$rend['year']; |
979 | 1076 | if( isset( $end['hour'] ) || isset( $end['min'] ) || isset( $end['sec'] )) { |
980 | 1077 | $datevalue .= ( isset( $rend['hour'] )) ? ' '.$rend['hour'] : ' 00'; |
@@ -983,30 +1080,37 @@ discard block |
||
983 | 1080 | } |
984 | 1081 | } |
985 | 1082 | $datestring = date( $endDateFormat, strtotime( $datevalue )); |
986 | - if( isset( $end['tz'] )) |
|
987 | - $datestring .= ' '.$end['tz']; |
|
988 | - if( $dtendExist ) |
|
989 | - $component2->setProperty( 'X-CURRENT-DTEND', $datestring ); |
|
990 | - elseif( $dueExist ) |
|
991 | - $component2->setProperty( 'X-CURRENT-DUE', $datestring ); |
|
1083 | + if( isset( $end['tz'] )) { |
|
1084 | + $datestring .= ' '.$end['tz']; |
|
1085 | + } |
|
1086 | + if( $dtendExist ) { |
|
1087 | + $component2->setProperty( 'X-CURRENT-DTEND', $datestring ); |
|
1088 | + } elseif( $dueExist ) { |
|
1089 | + $component2->setProperty( 'X-CURRENT-DUE', $datestring ); |
|
1090 | + } |
|
992 | 1091 | } |
993 | 1092 | $rend = $component2->_date2timestamp( $rend ); |
994 | 1093 | $rstart = $recurkey; |
995 | 1094 | /* add repeating components within valid dates to output array, only start date */ |
996 | - if( $flat ) |
|
997 | - $result[] = $component2->copy(); // copy to output |
|
1095 | + if( $flat ) { |
|
1096 | + $result[] = $component2->copy(); |
|
1097 | + } |
|
1098 | + // copy to output |
|
998 | 1099 | elseif( $split ) { |
999 | - if( $rend > $endDate ) |
|
1000 | - $rend = $endDate; |
|
1100 | + if( $rend > $endDate ) { |
|
1101 | + $rend = $endDate; |
|
1102 | + } |
|
1001 | 1103 | while( $rstart <= $rend ) { // iterate |
1002 | 1104 | $wd = getdate( $rstart ); |
1003 | 1105 | if(( $rstart > $startDate ) && // date after dtstart |
1004 | - !isset( $exdatelist[$rstart] )) // check exclude date |
|
1005 | - $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output |
|
1106 | + !isset( $exdatelist[$rstart] )) { |
|
1107 | + // check exclude date |
|
1108 | + $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); |
|
1109 | + } |
|
1110 | + // copy to output |
|
1006 | 1111 | $rstart += ( 24*60*60 ); // step one day |
1007 | 1112 | } |
1008 | - } |
|
1009 | - elseif(( $rstart >= $startDate ) && // date within period |
|
1113 | + } elseif(( $rstart >= $startDate ) && // date within period |
|
1010 | 1114 | !isset( $exdatelist[$rstart] )) { // check exclude date |
1011 | 1115 | $wd = getdate( $rstart ); |
1012 | 1116 | $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output |
@@ -1014,19 +1118,29 @@ discard block |
||
1014 | 1118 | } |
1015 | 1119 | } |
1016 | 1120 | /* deselect components with startdate/enddate not within period */ |
1017 | - if(( $endWdate < $startDate ) || ( $startWdate > $endDate )) continue; |
|
1121 | + if(( $endWdate < $startDate ) || ( $startWdate > $endDate )) { |
|
1122 | + continue; |
|
1123 | + } |
|
1018 | 1124 | } |
1019 | 1125 | /* deselect components with startdate not within period */ |
1020 | - elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) continue; |
|
1126 | + elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) { |
|
1127 | + continue; |
|
1128 | + } |
|
1021 | 1129 | /* add selected components within valid dates to output array */ |
1022 | - if( $flat ) |
|
1023 | - $result[] = $component->copy(); // copy to output; |
|
1130 | + if( $flat ) { |
|
1131 | + $result[] = $component->copy(); |
|
1132 | + } |
|
1133 | + // copy to output; |
|
1024 | 1134 | elseif( $split ) { |
1025 | - if( $endWdate > $endDate ) |
|
1026 | - $endWdate = $endDate; // use period end date |
|
1135 | + if( $endWdate > $endDate ) { |
|
1136 | + $endWdate = $endDate; |
|
1137 | + } |
|
1138 | + // use period end date |
|
1027 | 1139 | if( !isset( $exdatelist[$startWdate] )) { // check excluded dates |
1028 | - if( $startWdate < $startDate ) |
|
1029 | - $startWdate = $startDate; // use period start date |
|
1140 | + if( $startWdate < $startDate ) { |
|
1141 | + $startWdate = $startDate; |
|
1142 | + } |
|
1143 | + // use period start date |
|
1030 | 1144 | while( $startWdate <= $endWdate ) { // iterate |
1031 | 1145 | $wd = getdate( $startWdate ); |
1032 | 1146 | $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output |
@@ -1040,8 +1154,9 @@ discard block |
||
1040 | 1154 | $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output |
1041 | 1155 | } |
1042 | 1156 | } |
1043 | - if( 0 >= count( $result )) return FALSE; |
|
1044 | - elseif( !$flat ) { |
|
1157 | + if( 0 >= count( $result )) { |
|
1158 | + return FALSE; |
|
1159 | + } elseif( !$flat ) { |
|
1045 | 1160 | foreach( $result as $y => $yeararr ) { |
1046 | 1161 | foreach( $yeararr as $m => $montharr ) { |
1047 | 1162 | ksort( $result[$y][$m] ); |
@@ -1063,8 +1178,9 @@ discard block |
||
1063 | 1178 | * @return void |
1064 | 1179 | */ |
1065 | 1180 | function setComponent( $component, $arg1=FALSE, $arg2=FALSE ) { |
1066 | - if( '' >= $component->getConfig( 'language')) |
|
1067 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
1181 | + if( '' >= $component->getConfig( 'language')) { |
|
1182 | + $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
1183 | + } |
|
1068 | 1184 | $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
1069 | 1185 | $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
1070 | 1186 | $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
@@ -1083,27 +1199,26 @@ discard block |
||
1083 | 1199 | if ( ctype_digit( (string) $arg1 )) { |
1084 | 1200 | $argType = 'INDEX'; |
1085 | 1201 | $index = (int) $arg1 - 1; |
1086 | - } |
|
1087 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
1202 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
1088 | 1203 | $argType = strtolower( $arg1 ); |
1089 | 1204 | $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0; |
1090 | 1205 | } |
1091 | 1206 | $cix1sC = 0; |
1092 | 1207 | foreach ( $this->components as $cix => $component2) { |
1093 | - if( empty( $component2 )) continue; |
|
1208 | + if( empty( $component2 )) { |
|
1209 | + continue; |
|
1210 | + } |
|
1094 | 1211 | unset( $component2->propix ); |
1095 | 1212 | if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
1096 | 1213 | $this->components[$cix] = $component->copy(); |
1097 | 1214 | return TRUE; |
1098 | - } |
|
1099 | - elseif( $argType == $component2->objName ) { |
|
1215 | + } elseif( $argType == $component2->objName ) { |
|
1100 | 1216 | if( $index == $cix1sC ) { |
1101 | 1217 | $this->components[$cix] = $component->copy(); |
1102 | 1218 | return TRUE; |
1103 | 1219 | } |
1104 | 1220 | $cix1sC++; |
1105 | - } |
|
1106 | - elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) { |
|
1221 | + } elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) { |
|
1107 | 1222 | $this->components[$cix] = $component->copy(); |
1108 | 1223 | return TRUE; |
1109 | 1224 | } |
@@ -1130,73 +1245,124 @@ discard block |
||
1130 | 1245 | } |
1131 | 1246 | } |
1132 | 1247 | function _cmpfcn( $a, $b ) { |
1133 | - if( empty( $a )) return -1; |
|
1134 | - if( empty( $b )) return 1; |
|
1135 | - if( 'vtimezone' == $a->objName) return -1; |
|
1136 | - if( 'vtimezone' == $b->objName) return 1; |
|
1248 | + if( empty( $a )) { |
|
1249 | + return -1; |
|
1250 | + } |
|
1251 | + if( empty( $b )) { |
|
1252 | + return 1; |
|
1253 | + } |
|
1254 | + if( 'vtimezone' == $a->objName) { |
|
1255 | + return -1; |
|
1256 | + } |
|
1257 | + if( 'vtimezone' == $b->objName) { |
|
1258 | + return 1; |
|
1259 | + } |
|
1137 | 1260 | $astart = ( isset( $a->xprop['X-CURRENT-DTSTART']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTSTART']['value'] ) : null; |
1138 | - if( empty( $astart ) && isset( $a->dtstart['value'] )) |
|
1139 | - $astart = & $a->dtstart['value']; |
|
1261 | + if( empty( $astart ) && isset( $a->dtstart['value'] )) { |
|
1262 | + $astart = & $a->dtstart['value']; |
|
1263 | + } |
|
1140 | 1264 | $bstart = ( isset( $b->xprop['X-CURRENT-DTSTART']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTSTART']['value'] ) : null; |
1141 | - if( empty( $bstart ) && isset( $b->dtstart['value'] )) |
|
1142 | - $bstart = & $b->dtstart['value']; |
|
1143 | - if( empty( $astart )) return -1; |
|
1144 | - elseif( empty( $bstart )) return 1; |
|
1265 | + if( empty( $bstart ) && isset( $b->dtstart['value'] )) { |
|
1266 | + $bstart = & $b->dtstart['value']; |
|
1267 | + } |
|
1268 | + if( empty( $astart )) { |
|
1269 | + return -1; |
|
1270 | + } elseif( empty( $bstart )) { |
|
1271 | + return 1; |
|
1272 | + } |
|
1145 | 1273 | foreach( $this->_sortkeys as $key ) { |
1146 | - if ( empty( $astart[$key] )) return -1; |
|
1147 | - elseif( empty( $bstart[$key] )) return 1; |
|
1148 | - if ( $astart[$key] == $bstart[$key]) continue; |
|
1149 | - if (( (int) $astart[$key] ) < ((int) $bstart[$key] )) |
|
1274 | + if ( empty( $astart[$key] )) { |
|
1150 | 1275 | return -1; |
1151 | - elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] )) |
|
1276 | + } elseif( empty( $bstart[$key] )) { |
|
1152 | 1277 | return 1; |
1278 | + } |
|
1279 | + if ( $astart[$key] == $bstart[$key]) { |
|
1280 | + continue; |
|
1281 | + } |
|
1282 | + if (( (int) $astart[$key] ) < ((int) $bstart[$key] )) { |
|
1283 | + return -1; |
|
1284 | + } elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] )) { |
|
1285 | + return 1; |
|
1286 | + } |
|
1153 | 1287 | } |
1154 | 1288 | $c = ( isset( $a->xprop['X-CURRENT-DTEND']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTEND']['value'] ) : null; |
1155 | - if( empty( $c ) && !empty( $a->dtend['value'] )) |
|
1156 | - $c = & $a->dtend['value']; |
|
1157 | - if( empty( $c ) && isset( $a->xprop['X-CURRENT-DUE']['value'] )) |
|
1158 | - $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] ); |
|
1159 | - if( empty( $c ) && !empty( $a->due['value'] )) |
|
1160 | - $c = & $a->due['value']; |
|
1161 | - if( empty( $c ) && !empty( $a->duration['value'] )) |
|
1162 | - $c = $a->duration2date(); |
|
1289 | + if( empty( $c ) && !empty( $a->dtend['value'] )) { |
|
1290 | + $c = & $a->dtend['value']; |
|
1291 | + } |
|
1292 | + if( empty( $c ) && isset( $a->xprop['X-CURRENT-DUE']['value'] )) { |
|
1293 | + $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] ); |
|
1294 | + } |
|
1295 | + if( empty( $c ) && !empty( $a->due['value'] )) { |
|
1296 | + $c = & $a->due['value']; |
|
1297 | + } |
|
1298 | + if( empty( $c ) && !empty( $a->duration['value'] )) { |
|
1299 | + $c = $a->duration2date(); |
|
1300 | + } |
|
1163 | 1301 | $d = ( isset( $b->xprop['X-CURRENT-DTEND']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTEND']['value'] ) : null; |
1164 | - if( empty( $d ) && !empty( $b->dtend['value'] )) |
|
1165 | - $d = & $b->dtend['value']; |
|
1166 | - if( empty( $d ) && isset( $b->xprop['X-CURRENT-DUE']['value'] )) |
|
1167 | - $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] ); |
|
1168 | - if( empty( $d ) && !empty( $b->due['value'] )) |
|
1169 | - $d = & $b->due['value']; |
|
1170 | - if( empty( $d ) && !empty( $b->duration['value'] )) |
|
1171 | - $d = $b->duration2date(); |
|
1172 | - if( empty( $c )) return -1; |
|
1173 | - elseif( empty( $d )) return 1; |
|
1302 | + if( empty( $d ) && !empty( $b->dtend['value'] )) { |
|
1303 | + $d = & $b->dtend['value']; |
|
1304 | + } |
|
1305 | + if( empty( $d ) && isset( $b->xprop['X-CURRENT-DUE']['value'] )) { |
|
1306 | + $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] ); |
|
1307 | + } |
|
1308 | + if( empty( $d ) && !empty( $b->due['value'] )) { |
|
1309 | + $d = & $b->due['value']; |
|
1310 | + } |
|
1311 | + if( empty( $d ) && !empty( $b->duration['value'] )) { |
|
1312 | + $d = $b->duration2date(); |
|
1313 | + } |
|
1314 | + if( empty( $c )) { |
|
1315 | + return -1; |
|
1316 | + } elseif( empty( $d )) { |
|
1317 | + return 1; |
|
1318 | + } |
|
1174 | 1319 | foreach( $this->_sortkeys as $key ) { |
1175 | - if ( !isset( $c[$key] )) return -1; |
|
1176 | - elseif( !isset( $d[$key] )) return 1; |
|
1177 | - if ( $c[$key] == $d[$key] ) continue; |
|
1178 | - if (( (int) $c[$key] ) < ((int) $d[$key])) return -1; |
|
1179 | - elseif(( (int) $c[$key] ) > ((int) $d[$key])) return 1; |
|
1180 | - } |
|
1181 | - if( isset( $a->created['value'] )) |
|
1182 | - $e = & $a->created['value']; |
|
1183 | - else |
|
1184 | - $e = & $a->dtstamp['value']; |
|
1185 | - if( isset( $b->created['value'] )) |
|
1186 | - $f = & $b->created['value']; |
|
1187 | - else |
|
1188 | - $f = & $b->dtstamp['value']; |
|
1320 | + if ( !isset( $c[$key] )) { |
|
1321 | + return -1; |
|
1322 | + } elseif( !isset( $d[$key] )) { |
|
1323 | + return 1; |
|
1324 | + } |
|
1325 | + if ( $c[$key] == $d[$key] ) { |
|
1326 | + continue; |
|
1327 | + } |
|
1328 | + if (( (int) $c[$key] ) < ((int) $d[$key])) { |
|
1329 | + return -1; |
|
1330 | + } elseif(( (int) $c[$key] ) > ((int) $d[$key])) { |
|
1331 | + return 1; |
|
1332 | + } |
|
1333 | + } |
|
1334 | + if( isset( $a->created['value'] )) { |
|
1335 | + $e = & $a->created['value']; |
|
1336 | + } else { |
|
1337 | + $e = & $a->dtstamp['value']; |
|
1338 | + } |
|
1339 | + if( isset( $b->created['value'] )) { |
|
1340 | + $f = & $b->created['value']; |
|
1341 | + } else { |
|
1342 | + $f = & $b->dtstamp['value']; |
|
1343 | + } |
|
1189 | 1344 | foreach( $this->_sortkeys as $key ) { |
1190 | - if( !isset( $e[$key] )) return -1; |
|
1191 | - elseif( !isset( $f[$key] )) return 1; |
|
1192 | - if ( $e[$key] == $f[$key] ) continue; |
|
1193 | - if (( (int) $e[$key] ) < ((int) $f[$key])) return -1; |
|
1194 | - elseif(( (int) $e[$key] ) > ((int) $f[$key])) return 1; |
|
1345 | + if( !isset( $e[$key] )) { |
|
1346 | + return -1; |
|
1347 | + } elseif( !isset( $f[$key] )) { |
|
1348 | + return 1; |
|
1349 | + } |
|
1350 | + if ( $e[$key] == $f[$key] ) { |
|
1351 | + continue; |
|
1352 | + } |
|
1353 | + if (( (int) $e[$key] ) < ((int) $f[$key])) { |
|
1354 | + return -1; |
|
1355 | + } elseif(( (int) $e[$key] ) > ((int) $f[$key])) { |
|
1356 | + return 1; |
|
1357 | + } |
|
1195 | 1358 | } |
1196 | 1359 | if (( $a->uid['value'] ) < |
1197 | - ( $b->uid['value'] )) return -1; |
|
1198 | - elseif(( $a->uid['value'] ) > |
|
1199 | - ( $b->uid['value'] )) return 1; |
|
1360 | + ( $b->uid['value'] )) { |
|
1361 | + return -1; |
|
1362 | + } elseif(( $a->uid['value'] ) > |
|
1363 | + ( $b->uid['value'] )) { |
|
1364 | + return 1; |
|
1365 | + } |
|
1200 | 1366 | return 0; |
1201 | 1367 | } |
1202 | 1368 | /** |
@@ -1211,42 +1377,57 @@ discard block |
||
1211 | 1377 | function parse( $filename=FALSE ) { |
1212 | 1378 | if( !$filename ) { |
1213 | 1379 | /* directory/filename previous set via setConfig directory+filename / url */ |
1214 | - if( FALSE === ( $filename = $this->getConfig( 'url' ))) |
|
1215 | - $filename = $this->getConfig( 'dirfile' ); |
|
1216 | - } |
|
1217 | - elseif(( 'http://' == strtolower( substr( $filename, 0, 7 ))) || |
|
1380 | + if( FALSE === ( $filename = $this->getConfig( 'url' ))) { |
|
1381 | + $filename = $this->getConfig( 'dirfile' ); |
|
1382 | + } |
|
1383 | + } elseif(( 'http://' == strtolower( substr( $filename, 0, 7 ))) || |
|
1218 | 1384 | ( 'webcal://' == strtolower( substr( $filename, 0, 9 )))) { |
1219 | 1385 | /* remote file - URL */ |
1220 | 1386 | $this->setConfig( 'URL', $filename ); |
1221 | - if( !$filename = $this->getConfig( 'url' )) |
|
1222 | - return FALSE; /* err 2 */ |
|
1223 | - } |
|
1224 | - else { |
|
1387 | + if( !$filename = $this->getConfig( 'url' )) { |
|
1388 | + return FALSE; |
|
1389 | + } |
|
1390 | + /* err 2 */ |
|
1391 | + } else { |
|
1225 | 1392 | /* local directory/filename */ |
1226 | 1393 | $parts = pathinfo( $filename ); |
1227 | 1394 | if( !empty( $parts['dirname'] ) && ( '.' != $parts['dirname'] )) { |
1228 | - if( !$this->setConfig( 'directory', $parts['dirname'] )) |
|
1229 | - return FALSE; /* err 3 */ |
|
1395 | + if( !$this->setConfig( 'directory', $parts['dirname'] )) { |
|
1396 | + return FALSE; |
|
1397 | + } |
|
1398 | + /* err 3 */ |
|
1230 | 1399 | } |
1231 | - if( !$this->setConfig( 'filename', $parts['basename'] )) |
|
1232 | - return FALSE; /* err 4 */ |
|
1400 | + if( !$this->setConfig( 'filename', $parts['basename'] )) { |
|
1401 | + return FALSE; |
|
1402 | + } |
|
1403 | + /* err 4 */ |
|
1233 | 1404 | } |
1234 | 1405 | if( 'http://' != substr( $filename, 0, 7 )) { |
1235 | 1406 | /* local file error tests */ |
1236 | - if( !is_file( $filename )) /* err 5 */ |
|
1407 | + if( !is_file( $filename )) { |
|
1408 | + /* err 5 */ |
|
1237 | 1409 | return FALSE; |
1238 | - if( !is_readable( $filename )) |
|
1239 | - return FALSE; /* err 6 */ |
|
1240 | - if( !filesize( $filename )) |
|
1241 | - return FALSE; /* err 7 */ |
|
1410 | + } |
|
1411 | + if( !is_readable( $filename )) { |
|
1412 | + return FALSE; |
|
1413 | + } |
|
1414 | + /* err 6 */ |
|
1415 | + if( !filesize( $filename )) { |
|
1416 | + return FALSE; |
|
1417 | + } |
|
1418 | + /* err 7 */ |
|
1242 | 1419 | clearstatcache(); |
1243 | 1420 | } |
1244 | 1421 | /* READ FILE */ |
1245 | - if( FALSE === ( $rows = file( $filename ))) |
|
1246 | - return FALSE; /* err 1 */ |
|
1422 | + if( FALSE === ( $rows = file( $filename ))) { |
|
1423 | + return FALSE; |
|
1424 | + } |
|
1425 | + /* err 1 */ |
|
1247 | 1426 | /* identify BEGIN:VCALENDAR, MUST be first row */ |
1248 | - if( 'BEGIN:VCALENDAR' != strtoupper( trim( $rows[0] ))) |
|
1249 | - return FALSE; /* err 8 */ |
|
1427 | + if( 'BEGIN:VCALENDAR' != strtoupper( trim( $rows[0] ))) { |
|
1428 | + return FALSE; |
|
1429 | + } |
|
1430 | + /* err 8 */ |
|
1250 | 1431 | /* remove empty trailing lines */ |
1251 | 1432 | while( '' == trim( $rows[count( $rows ) - 1] )) { |
1252 | 1433 | unset( $rows[count( $rows ) - 1] ); |
@@ -1256,34 +1437,37 @@ discard block |
||
1256 | 1437 | if( 'END:VCALENDAR' != strtoupper( trim( $rows[count( $rows ) - 1] ))) { |
1257 | 1438 | return FALSE; /* err 9 */ |
1258 | 1439 | } |
1259 | - if( 3 > count( $rows )) |
|
1260 | - return FALSE; /* err 10 */ |
|
1440 | + if( 3 > count( $rows )) { |
|
1441 | + return FALSE; |
|
1442 | + } |
|
1443 | + /* err 10 */ |
|
1261 | 1444 | $comp = $subcomp = null; |
1262 | 1445 | $actcomp = & $this; |
1263 | 1446 | $nl = $this->getConfig( 'nl' ); |
1264 | 1447 | $calsync = 0; |
1265 | 1448 | /* identify components and update unparsed data within component */ |
1266 | 1449 | foreach( $rows as $line ) { |
1267 | - if( '' == trim( $line )) |
|
1268 | - continue; |
|
1269 | - if( $nl == substr( $line, 0 - strlen( $nl ))) |
|
1270 | - $line = substr( $line, 0, ( strlen( $line ) - strlen( $nl ))).'\n'; |
|
1450 | + if( '' == trim( $line )) { |
|
1451 | + continue; |
|
1452 | + } |
|
1453 | + if( $nl == substr( $line, 0 - strlen( $nl ))) { |
|
1454 | + $line = substr( $line, 0, ( strlen( $line ) - strlen( $nl ))).'\n'; |
|
1455 | + } |
|
1271 | 1456 | if( 'BEGIN:VCALENDAR' == strtoupper( substr( $line, 0, 15 ))) { |
1272 | 1457 | $calsync++; |
1273 | 1458 | continue; |
1274 | - } |
|
1275 | - elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) { |
|
1459 | + } elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) { |
|
1276 | 1460 | $calsync--; |
1277 | 1461 | continue; |
1462 | + } elseif( 1 != $calsync ) { |
|
1463 | + return FALSE; |
|
1278 | 1464 | } |
1279 | - elseif( 1 != $calsync ) |
|
1280 | - return FALSE; /* err 20 */ |
|
1465 | + /* err 20 */ |
|
1281 | 1466 | if( 'END:' == strtoupper( substr( $line, 0, 4 ))) { |
1282 | 1467 | if( null != $subcomp ) { |
1283 | 1468 | $comp->setComponent( $subcomp ); |
1284 | 1469 | $subcomp = null; |
1285 | - } |
|
1286 | - else { |
|
1470 | + } else { |
|
1287 | 1471 | $this->setComponent( $comp ); |
1288 | 1472 | $comp = null; |
1289 | 1473 | } |
@@ -1294,17 +1478,18 @@ discard block |
||
1294 | 1478 | $line = str_replace( '\n', '', $line ); |
1295 | 1479 | $compname = trim (strtoupper( substr( $line, 6 ))); |
1296 | 1480 | if( null != $comp ) { |
1297 | - if( 'VALARM' == $compname ) |
|
1298 | - $subcomp = new valarm(); |
|
1299 | - elseif( 'STANDARD' == $compname ) |
|
1300 | - $subcomp = new vtimezone( 'STANDARD' ); |
|
1301 | - elseif( 'DAYLIGHT' == $compname ) |
|
1302 | - $subcomp = new vtimezone( 'DAYLIGHT' ); |
|
1303 | - else |
|
1304 | - return FALSE; /* err 6 */ |
|
1481 | + if( 'VALARM' == $compname ) { |
|
1482 | + $subcomp = new valarm(); |
|
1483 | + } elseif( 'STANDARD' == $compname ) { |
|
1484 | + $subcomp = new vtimezone( 'STANDARD' ); |
|
1485 | + } elseif( 'DAYLIGHT' == $compname ) { |
|
1486 | + $subcomp = new vtimezone( 'DAYLIGHT' ); |
|
1487 | + } else { |
|
1488 | + return FALSE; |
|
1489 | + } |
|
1490 | + /* err 6 */ |
|
1305 | 1491 | $actcomp = & $subcomp; |
1306 | - } |
|
1307 | - else { |
|
1492 | + } else { |
|
1308 | 1493 | switch( $compname ) { |
1309 | 1494 | case 'VALARM': |
1310 | 1495 | $comp = new valarm(); |
@@ -1353,8 +1538,7 @@ discard block |
||
1353 | 1538 | $newProp = FALSE; |
1354 | 1539 | $lastix++; |
1355 | 1540 | $proprows[$lastix] = $line; |
1356 | - } |
|
1357 | - else { |
|
1541 | + } else { |
|
1358 | 1542 | /* remove line breaks */ |
1359 | 1543 | if(( '\n' == substr( $proprows[$lastix], -2 )) && |
1360 | 1544 | ( ' ' == substr( $line, 0, 1 ))) { |
@@ -1366,19 +1550,22 @@ discard block |
||
1366 | 1550 | } |
1367 | 1551 | $toolbox = new calendarComponent(); |
1368 | 1552 | foreach( $proprows as $line ) { |
1369 | - if( '\n' == substr( $line, -2 )) |
|
1370 | - $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
1553 | + if( '\n' == substr( $line, -2 )) { |
|
1554 | + $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
1555 | + } |
|
1371 | 1556 | /* get propname */ |
1372 | 1557 | $cix = $propname = null; |
1373 | 1558 | for( $cix=0; $cix < strlen( $line ); $cix++ ) { |
1374 | - if( in_array( $line{$cix}, array( ':', ';' ))) |
|
1375 | - break; |
|
1376 | - else |
|
1377 | - $propname .= $line{$cix}; |
|
1559 | + if( in_array( $line{$cix}, array( ':', ';' ))) { |
|
1560 | + break; |
|
1561 | + } else { |
|
1562 | + $propname .= $line{$cix}; |
|
1563 | + } |
|
1378 | 1564 | } |
1379 | 1565 | /* ignore version/prodid properties */ |
1380 | - if( in_array( strtoupper( $propname ), array( 'VERSION', 'PRODID' ))) |
|
1381 | - continue; |
|
1566 | + if( in_array( strtoupper( $propname ), array( 'VERSION', 'PRODID' ))) { |
|
1567 | + continue; |
|
1568 | + } |
|
1382 | 1569 | $line = substr( $line, $cix); |
1383 | 1570 | /* separate attributes from value */ |
1384 | 1571 | $attr = array(); |
@@ -1403,20 +1590,22 @@ discard block |
||
1403 | 1590 | break; |
1404 | 1591 | } |
1405 | 1592 | } |
1406 | - if( ';' == $line{$cix} ) |
|
1407 | - $attr[++$attrix] = null; |
|
1408 | - else |
|
1409 | - $attr[$attrix] .= $line{$cix}; |
|
1593 | + if( ';' == $line{$cix} ) { |
|
1594 | + $attr[++$attrix] = null; |
|
1595 | + } else { |
|
1596 | + $attr[$attrix] .= $line{$cix}; |
|
1597 | + } |
|
1410 | 1598 | } |
1411 | 1599 | |
1412 | 1600 | /* make attributes in array format */ |
1413 | 1601 | $propattr = array(); |
1414 | 1602 | foreach( $attr as $attribute ) { |
1415 | 1603 | $attrsplit = explode( '=', $attribute, 2 ); |
1416 | - if( 1 < count( $attrsplit )) |
|
1417 | - $propattr[$attrsplit[0]] = $attrsplit[1]; |
|
1418 | - else |
|
1419 | - $propattr[] = $attribute; |
|
1604 | + if( 1 < count( $attrsplit )) { |
|
1605 | + $propattr[$attrsplit[0]] = $attrsplit[1]; |
|
1606 | + } else { |
|
1607 | + $propattr[] = $attribute; |
|
1608 | + } |
|
1420 | 1609 | } |
1421 | 1610 | /* update Property */ |
1422 | 1611 | if( FALSE !== strpos( $line, ',' )) { |
@@ -1430,13 +1619,14 @@ discard block |
||
1430 | 1619 | } |
1431 | 1620 | } |
1432 | 1621 | if( 1 < count( $content )) { |
1433 | - foreach( $content as $cix => $contentPart ) |
|
1434 | - $content[$cix] = $toolbox->_strunrep( $contentPart ); |
|
1622 | + foreach( $content as $cix => $contentPart ) { |
|
1623 | + $content[$cix] = $toolbox->_strunrep( $contentPart ); |
|
1624 | + } |
|
1435 | 1625 | $this->setProperty( $propname, $content, $propattr ); |
1436 | 1626 | continue; |
1627 | + } else { |
|
1628 | + $line = reset( $content ); |
|
1437 | 1629 | } |
1438 | - else |
|
1439 | - $line = reset( $content ); |
|
1440 | 1630 | $line = $toolbox->_strunrep( $line ); |
1441 | 1631 | } |
1442 | 1632 | $this->setProperty( $propname, trim( $line ), $propattr ); |
@@ -1445,12 +1635,14 @@ discard block |
||
1445 | 1635 | /* parse Components */ |
1446 | 1636 | if( is_array( $this->components ) && ( 0 < count( $this->components ))) { |
1447 | 1637 | for( $six = 0; $six < count( $this->components ); $six++ ) { |
1448 | - if( !empty( $this->components[$six] )) |
|
1449 | - $this->components[$six]->parse(); |
|
1638 | + if( !empty( $this->components[$six] )) { |
|
1639 | + $this->components[$six]->parse(); |
|
1640 | + } |
|
1450 | 1641 | } |
1642 | + } else { |
|
1643 | + return FALSE; |
|
1451 | 1644 | } |
1452 | - else |
|
1453 | - return FALSE; /* err 91 or something.. . */ |
|
1645 | + /* err 91 or something.. . */ |
|
1454 | 1646 | return TRUE; |
1455 | 1647 | } |
1456 | 1648 | /*********************************************************************************/ |
@@ -1482,8 +1674,9 @@ discard block |
||
1482 | 1674 | switch( $this->format ) { |
1483 | 1675 | case 'xcal': |
1484 | 1676 | $nlstrlen = strlen( $this->nl ); |
1485 | - if( $this->nl == substr( $calendarStart, ( 0 - $nlstrlen ))) |
|
1486 | - $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen )); |
|
1677 | + if( $this->nl == substr( $calendarStart, ( 0 - $nlstrlen ))) { |
|
1678 | + $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen )); |
|
1679 | + } |
|
1487 | 1680 | $calendarStart .= '>'.$this->nl; |
1488 | 1681 | break; |
1489 | 1682 | default: |
@@ -1491,9 +1684,12 @@ discard block |
||
1491 | 1684 | } |
1492 | 1685 | $calendar .= $this->createXprop(); |
1493 | 1686 | foreach( $this->components as $component ) { |
1494 | - if( empty( $component )) continue; |
|
1495 | - if( '' >= $component->getConfig( 'language')) |
|
1496 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
1687 | + if( empty( $component )) { |
|
1688 | + continue; |
|
1689 | + } |
|
1690 | + if( '' >= $component->getConfig( 'language')) { |
|
1691 | + $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
1692 | + } |
|
1497 | 1693 | $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
1498 | 1694 | $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
1499 | 1695 | $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
@@ -1506,8 +1702,10 @@ discard block |
||
1506 | 1702 | foreach( $this->xcaldecl as $declix => $declPart ) { |
1507 | 1703 | if(( 0 < count( $old_xcaldecl)) && |
1508 | 1704 | ( in_array( $declPart['uri'], $old_xcaldecl['uri'] )) && |
1509 | - ( in_array( $declPart['external'], $old_xcaldecl['external'] ))) |
|
1510 | - continue; // no duplicate uri and ext. references |
|
1705 | + ( in_array( $declPart['external'], $old_xcaldecl['external'] ))) { |
|
1706 | + continue; |
|
1707 | + } |
|
1708 | + // no duplicate uri and ext. references |
|
1511 | 1709 | $calendarxCaldecl .= '<!'; |
1512 | 1710 | foreach( $declPart as $declKey => $declValue ) { |
1513 | 1711 | switch( $declKey ) { // index |
@@ -1560,10 +1758,11 @@ discard block |
||
1560 | 1758 | $filesize = strlen( $output ); |
1561 | 1759 | // if( headers_sent( $filename, $linenum )) |
1562 | 1760 | // die( "Headers already sent in $filename on line $linenum\n" ); |
1563 | - if( 'xcal' == $this->format ) |
|
1564 | - header( 'Content-Type: application/calendar+xml; charset=utf-8' ); |
|
1565 | - else |
|
1566 | - header( 'Content-Type: text/calendar; charset=utf-8' ); |
|
1761 | + if( 'xcal' == $this->format ) { |
|
1762 | + header( 'Content-Type: application/calendar+xml; charset=utf-8' ); |
|
1763 | + } else { |
|
1764 | + header( 'Content-Type: text/calendar; charset=utf-8' ); |
|
1765 | + } |
|
1567 | 1766 | header( 'Content-Length: '.$filesize ); |
1568 | 1767 | header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
1569 | 1768 | header( 'Cache-Control: max-age=10' ); |
@@ -1581,23 +1780,28 @@ discard block |
||
1581 | 1780 | * @return bool |
1582 | 1781 | */ |
1583 | 1782 | function saveCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE ) { |
1584 | - if( $directory ) |
|
1585 | - $this->setConfig( 'directory', $directory ); |
|
1586 | - if( $filename ) |
|
1587 | - $this->setConfig( 'filename', $filename ); |
|
1588 | - if( $delimiter && ($delimiter != DIRECTORY_SEPARATOR )) |
|
1589 | - $this->setConfig( 'delimiter', $delimiter ); |
|
1590 | - if( FALSE === ( $dirfile = $this->getConfig( 'url' ))) |
|
1591 | - $dirfile = $this->getConfig( 'dirfile' ); |
|
1783 | + if( $directory ) { |
|
1784 | + $this->setConfig( 'directory', $directory ); |
|
1785 | + } |
|
1786 | + if( $filename ) { |
|
1787 | + $this->setConfig( 'filename', $filename ); |
|
1788 | + } |
|
1789 | + if( $delimiter && ($delimiter != DIRECTORY_SEPARATOR )) { |
|
1790 | + $this->setConfig( 'delimiter', $delimiter ); |
|
1791 | + } |
|
1792 | + if( FALSE === ( $dirfile = $this->getConfig( 'url' ))) { |
|
1793 | + $dirfile = $this->getConfig( 'dirfile' ); |
|
1794 | + } |
|
1592 | 1795 | $iCalFile = @fopen( $dirfile, 'w' ); |
1593 | 1796 | if( $iCalFile ) { |
1594 | - if( FALSE === fwrite( $iCalFile, $this->createCalendar() )) |
|
1595 | - return FALSE; |
|
1797 | + if( FALSE === fwrite( $iCalFile, $this->createCalendar() )) { |
|
1798 | + return FALSE; |
|
1799 | + } |
|
1596 | 1800 | fclose( $iCalFile ); |
1597 | 1801 | return TRUE; |
1802 | + } else { |
|
1803 | + return FALSE; |
|
1598 | 1804 | } |
1599 | - else |
|
1600 | - return FALSE; |
|
1601 | 1805 | } |
1602 | 1806 | /** |
1603 | 1807 | * if recent version of calendar file exists (default one hour), an HTTP redirect header is sent |
@@ -1616,15 +1820,19 @@ discard block |
||
1616 | 1820 | $timeout = (int) $directory; |
1617 | 1821 | $directory = FALSE; |
1618 | 1822 | } |
1619 | - if( $directory ) |
|
1620 | - $this->setConfig( 'directory', $directory ); |
|
1621 | - if( $filename ) |
|
1622 | - $this->setConfig( 'filename', $filename ); |
|
1623 | - if( $delimiter && ( $delimiter != DIRECTORY_SEPARATOR )) |
|
1624 | - $this->setConfig( 'delimiter', $delimiter ); |
|
1823 | + if( $directory ) { |
|
1824 | + $this->setConfig( 'directory', $directory ); |
|
1825 | + } |
|
1826 | + if( $filename ) { |
|
1827 | + $this->setConfig( 'filename', $filename ); |
|
1828 | + } |
|
1829 | + if( $delimiter && ( $delimiter != DIRECTORY_SEPARATOR )) { |
|
1830 | + $this->setConfig( 'delimiter', $delimiter ); |
|
1831 | + } |
|
1625 | 1832 | $filesize = $this->getConfig( 'filesize' ); |
1626 | - if( 0 >= $filesize ) |
|
1627 | - return FALSE; |
|
1833 | + if( 0 >= $filesize ) { |
|
1834 | + return FALSE; |
|
1835 | + } |
|
1628 | 1836 | $dirfile = $this->getConfig( 'dirfile' ); |
1629 | 1837 | if( time() - filemtime( $dirfile ) < $timeout) { |
1630 | 1838 | clearstatcache(); |
@@ -1632,10 +1840,11 @@ discard block |
||
1632 | 1840 | $filename = $this->getConfig( 'filename' ); |
1633 | 1841 | // if( headers_sent( $filename, $linenum )) |
1634 | 1842 | // die( "Headers already sent in $filename on line $linenum\n" ); |
1635 | - if( 'xcal' == $this->format ) |
|
1636 | - header( 'Content-Type: application/calendar+xml; charset=utf-8' ); |
|
1637 | - else |
|
1638 | - header( 'Content-Type: text/calendar; charset=utf-8' ); |
|
1843 | + if( 'xcal' == $this->format ) { |
|
1844 | + header( 'Content-Type: application/calendar+xml; charset=utf-8' ); |
|
1845 | + } else { |
|
1846 | + header( 'Content-Type: text/calendar; charset=utf-8' ); |
|
1847 | + } |
|
1639 | 1848 | header( 'Content-Length: '.$filesize ); |
1640 | 1849 | header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
1641 | 1850 | header( 'Cache-Control: max-age=10' ); |
@@ -1645,9 +1854,9 @@ discard block |
||
1645 | 1854 | fclose( $fp ); |
1646 | 1855 | } |
1647 | 1856 | die(); |
1857 | + } else { |
|
1858 | + return FALSE; |
|
1648 | 1859 | } |
1649 | - else |
|
1650 | - return FALSE; |
|
1651 | 1860 | } |
1652 | 1861 | } |
1653 | 1862 | /*********************************************************************************/ |
@@ -1718,9 +1927,12 @@ discard block |
||
1718 | 1927 | * @return string |
1719 | 1928 | */ |
1720 | 1929 | function createAction() { |
1721 | - if( empty( $this->action )) return FALSE; |
|
1722 | - if( empty( $this->action['value'] )) |
|
1723 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE; |
|
1930 | + if( empty( $this->action )) { |
|
1931 | + return FALSE; |
|
1932 | + } |
|
1933 | + if( empty( $this->action['value'] )) { |
|
1934 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE; |
|
1935 | + } |
|
1724 | 1936 | $attributes = $this->_createParams( $this->action['params'] ); |
1725 | 1937 | return $this->_createElement( 'ACTION', $attributes, $this->action['value'] ); |
1726 | 1938 | } |
@@ -1734,7 +1946,11 @@ discard block |
||
1734 | 1946 | * @return bool |
1735 | 1947 | */ |
1736 | 1948 | function setAction( $value, $params=FALSE ) { |
1737 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1949 | + if( empty( $value )) { |
|
1950 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
1951 | + } else { |
|
1952 | + return FALSE; |
|
1953 | + } |
|
1738 | 1954 | $this->action = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
1739 | 1955 | return TRUE; |
1740 | 1956 | } |
@@ -1750,14 +1966,17 @@ discard block |
||
1750 | 1966 | * @return string |
1751 | 1967 | */ |
1752 | 1968 | function createAttach() { |
1753 | - if( empty( $this->attach )) return FALSE; |
|
1969 | + if( empty( $this->attach )) { |
|
1970 | + return FALSE; |
|
1971 | + } |
|
1754 | 1972 | $output = null; |
1755 | 1973 | foreach( $this->attach as $attachPart ) { |
1756 | 1974 | if(! empty( $attachPart['value'] )) { |
1757 | 1975 | $attributes = $this->_createParams( $attachPart['params'] ); |
1758 | 1976 | $output .= $this->_createElement( 'ATTACH', $attributes, $attachPart['value'] ); |
1977 | + } elseif( $this->getConfig( 'allowEmpty' )) { |
|
1978 | + $output .= $this->_createElement( 'ATTACH' ); |
|
1759 | 1979 | } |
1760 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'ATTACH' ); |
|
1761 | 1980 | } |
1762 | 1981 | return $output; |
1763 | 1982 | } |
@@ -1772,7 +1991,11 @@ discard block |
||
1772 | 1991 | * @return bool |
1773 | 1992 | */ |
1774 | 1993 | function setAttach( $value, $params=FALSE, $index=FALSE ) { |
1775 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
1994 | + if( empty( $value )) { |
|
1995 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
1996 | + } else { |
|
1997 | + return FALSE; |
|
1998 | + } |
|
1776 | 1999 | $this->_setMval( $this->attach, $value, $params, FALSE, $index ); |
1777 | 2000 | return TRUE; |
1778 | 2001 | } |
@@ -1788,19 +2011,22 @@ discard block |
||
1788 | 2011 | * @return string |
1789 | 2012 | */ |
1790 | 2013 | function createAttendee() { |
1791 | - if( empty( $this->attendee )) return FALSE; |
|
2014 | + if( empty( $this->attendee )) { |
|
2015 | + return FALSE; |
|
2016 | + } |
|
1792 | 2017 | $output = null; |
1793 | 2018 | foreach( $this->attendee as $attendeePart ) { // start foreach 1 |
1794 | 2019 | if( empty( $attendeePart['value'] )) { |
1795 | - if( $this->getConfig( 'allowEmpty' )) |
|
1796 | - $output .= $this->_createElement( 'ATTENDEE' ); |
|
2020 | + if( $this->getConfig( 'allowEmpty' )) { |
|
2021 | + $output .= $this->_createElement( 'ATTENDEE' ); |
|
2022 | + } |
|
1797 | 2023 | continue; |
1798 | 2024 | } |
1799 | 2025 | $attendee1 = $attendee2 = $attendeeLANG = $attendeeCN = null; |
1800 | 2026 | foreach( $attendeePart as $paramlabel => $paramvalue ) { // start foreach 2 |
1801 | - if( 'value' == $paramlabel ) |
|
1802 | - $attendee2 .= 'MAILTO:'.$paramvalue; |
|
1803 | - elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) { // start elseif |
|
2027 | + if( 'value' == $paramlabel ) { |
|
2028 | + $attendee2 .= 'MAILTO:'.$paramvalue; |
|
2029 | + } elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) { // start elseif |
|
1804 | 2030 | foreach( $paramvalue as $optparamlabel => $optparamvalue ) { // start foreach 3 |
1805 | 2031 | $attendee11 = $attendee12 = null; |
1806 | 2032 | if( is_int( $optparamlabel )) { |
@@ -1862,7 +2088,11 @@ discard block |
||
1862 | 2088 | * @return bool |
1863 | 2089 | */ |
1864 | 2090 | function setAttendee( $value, $params=FALSE, $index=FALSE ) { |
1865 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2091 | + if( empty( $value )) { |
|
2092 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
2093 | + } else { |
|
2094 | + return FALSE; |
|
2095 | + } |
|
1866 | 2096 | $value = str_replace ( 'MAILTO:', '', $value ); |
1867 | 2097 | $value = str_replace ( 'mailto:', '', $value ); |
1868 | 2098 | $params2 = array(); |
@@ -1878,16 +2108,17 @@ discard block |
||
1878 | 2108 | foreach( $optparamvalue as $part ) { |
1879 | 2109 | $part = str_replace( 'MAILTO:', '', $part ); |
1880 | 2110 | $part = str_replace( 'mailto:', '', $part ); |
1881 | - if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) |
|
1882 | - $part = substr( $part, 1, ( strlen($part)-2 )); |
|
2111 | + if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) { |
|
2112 | + $part = substr( $part, 1, ( strlen($part)-2 )); |
|
2113 | + } |
|
1883 | 2114 | $optarrays[$optparamlabel][] = $part; |
1884 | 2115 | } |
1885 | - } |
|
1886 | - else { |
|
2116 | + } else { |
|
1887 | 2117 | $part = str_replace( 'MAILTO:', '', $optparamvalue ); |
1888 | 2118 | $part = str_replace( 'mailto:', '', $part ); |
1889 | - if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) |
|
1890 | - $part = substr( $part, 1, ( strlen($part)-2 )); |
|
2119 | + if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) { |
|
2120 | + $part = substr( $part, 1, ( strlen($part)-2 )); |
|
2121 | + } |
|
1891 | 2122 | $optarrays[$optparamlabel][] = $part; |
1892 | 2123 | } |
1893 | 2124 | break; |
@@ -1897,14 +2128,16 @@ discard block |
||
1897 | 2128 | $optparamvalue = str_replace( 'mailto:', '', $optparamvalue ); |
1898 | 2129 | } |
1899 | 2130 | if(( '"' == substr( $optparamvalue, 0, 1 )) && |
1900 | - ( '"' == substr( $optparamvalue, -1 ))) |
|
1901 | - $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 )); |
|
2131 | + ( '"' == substr( $optparamvalue, -1 ))) { |
|
2132 | + $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 )); |
|
2133 | + } |
|
1902 | 2134 | $params2[$optparamlabel] = $optparamvalue; |
1903 | 2135 | break; |
1904 | 2136 | } // end switch( $optparamlabel.. . |
1905 | 2137 | } // end foreach( $optparam.. . |
1906 | - foreach( $optarrays as $optparamlabel => $optparams ) |
|
1907 | - $params2[$optparamlabel] = $optparams; |
|
2138 | + foreach( $optarrays as $optparamlabel => $optparams ) { |
|
2139 | + $params2[$optparamlabel] = $optparams; |
|
2140 | + } |
|
1908 | 2141 | } |
1909 | 2142 | // remove defaults |
1910 | 2143 | $this->_existRem( $params2, 'CUTYPE', 'INDIVIDUAL' ); |
@@ -1914,8 +2147,9 @@ discard block |
||
1914 | 2147 | // check language setting |
1915 | 2148 | if( isset( $params2['CN' ] )) { |
1916 | 2149 | $lang = $this->getConfig( 'language' ); |
1917 | - if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang )) |
|
1918 | - $params2['LANGUAGE' ] = $lang; |
|
2150 | + if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang )) { |
|
2151 | + $params2['LANGUAGE' ] = $lang; |
|
2152 | + } |
|
1919 | 2153 | } |
1920 | 2154 | $this->_setMval( $this->attendee, $value, $params2, FALSE, $index ); |
1921 | 2155 | return TRUE; |
@@ -1932,22 +2166,26 @@ discard block |
||
1932 | 2166 | * @return string |
1933 | 2167 | */ |
1934 | 2168 | function createCategories() { |
1935 | - if( empty( $this->categories )) return FALSE; |
|
2169 | + if( empty( $this->categories )) { |
|
2170 | + return FALSE; |
|
2171 | + } |
|
1936 | 2172 | $output = null; |
1937 | 2173 | foreach( $this->categories as $category ) { |
1938 | 2174 | if( empty( $category['value'] )) { |
1939 | - if ( $this->getConfig( 'allowEmpty' )) |
|
1940 | - $output .= $this->_createElement( 'CATEGORIES' ); |
|
2175 | + if ( $this->getConfig( 'allowEmpty' )) { |
|
2176 | + $output .= $this->_createElement( 'CATEGORIES' ); |
|
2177 | + } |
|
1941 | 2178 | continue; |
1942 | 2179 | } |
1943 | 2180 | $attributes = $this->_createParams( $category['params'], array( 'LANGUAGE' )); |
1944 | 2181 | if( is_array( $category['value'] )) { |
1945 | - foreach( $category['value'] as $cix => $categoryPart ) |
|
1946 | - $category['value'][$cix] = $this->_strrep( $categoryPart ); |
|
2182 | + foreach( $category['value'] as $cix => $categoryPart ) { |
|
2183 | + $category['value'][$cix] = $this->_strrep( $categoryPart ); |
|
2184 | + } |
|
1947 | 2185 | $content = implode( ',', $category['value'] ); |
2186 | + } else { |
|
2187 | + $content = $this->_strrep( $category['value'] ); |
|
1948 | 2188 | } |
1949 | - else |
|
1950 | - $content = $this->_strrep( $category['value'] ); |
|
1951 | 2189 | $output .= $this->_createElement( 'CATEGORIES', $attributes, $content ); |
1952 | 2190 | } |
1953 | 2191 | return $output; |
@@ -1963,7 +2201,11 @@ discard block |
||
1963 | 2201 | * @return bool |
1964 | 2202 | */ |
1965 | 2203 | function setCategories( $value, $params=FALSE, $index=FALSE ) { |
1966 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2204 | + if( empty( $value )) { |
|
2205 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
2206 | + } else { |
|
2207 | + return FALSE; |
|
2208 | + } |
|
1967 | 2209 | $this->_setMval( $this->categories, $value, $params, FALSE, $index ); |
1968 | 2210 | return TRUE; |
1969 | 2211 | } |
@@ -1979,9 +2221,12 @@ discard block |
||
1979 | 2221 | * @return string |
1980 | 2222 | */ |
1981 | 2223 | function createClass() { |
1982 | - if( empty( $this->class )) return FALSE; |
|
1983 | - if( empty( $this->class['value'] )) |
|
1984 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE; |
|
2224 | + if( empty( $this->class )) { |
|
2225 | + return FALSE; |
|
2226 | + } |
|
2227 | + if( empty( $this->class['value'] )) { |
|
2228 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE; |
|
2229 | + } |
|
1985 | 2230 | $attributes = $this->_createParams( $this->class['params'] ); |
1986 | 2231 | return $this->_createElement( 'CLASS', $attributes, $this->class['value'] ); |
1987 | 2232 | } |
@@ -1995,7 +2240,11 @@ discard block |
||
1995 | 2240 | * @return bool |
1996 | 2241 | */ |
1997 | 2242 | function setClass( $value, $params=FALSE ) { |
1998 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2243 | + if( empty( $value )) { |
|
2244 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
2245 | + } else { |
|
2246 | + return FALSE; |
|
2247 | + } |
|
1999 | 2248 | $this->class = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
2000 | 2249 | return TRUE; |
2001 | 2250 | } |
@@ -2011,11 +2260,15 @@ discard block |
||
2011 | 2260 | * @return string |
2012 | 2261 | */ |
2013 | 2262 | function createComment() { |
2014 | - if( empty( $this->comment )) return FALSE; |
|
2263 | + if( empty( $this->comment )) { |
|
2264 | + return FALSE; |
|
2265 | + } |
|
2015 | 2266 | $output = null; |
2016 | 2267 | foreach( $this->comment as $commentPart ) { |
2017 | 2268 | if( empty( $commentPart['value'] )) { |
2018 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'COMMENT' ); |
|
2269 | + if( $this->getConfig( 'allowEmpty' )) { |
|
2270 | + $output .= $this->_createElement( 'COMMENT' ); |
|
2271 | + } |
|
2019 | 2272 | continue; |
2020 | 2273 | } |
2021 | 2274 | $attributes = $this->_createParams( $commentPart['params'], array( 'ALTREP', 'LANGUAGE' )); |
@@ -2035,7 +2288,11 @@ discard block |
||
2035 | 2288 | * @return bool |
2036 | 2289 | */ |
2037 | 2290 | function setComment( $value, $params=FALSE, $index=FALSE ) { |
2038 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2291 | + if( empty( $value )) { |
|
2292 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
2293 | + } else { |
|
2294 | + return FALSE; |
|
2295 | + } |
|
2039 | 2296 | $this->_setMval( $this->comment, $value, $params, FALSE, $index ); |
2040 | 2297 | return TRUE; |
2041 | 2298 | } |
@@ -2051,16 +2308,20 @@ discard block |
||
2051 | 2308 | * @return string |
2052 | 2309 | */ |
2053 | 2310 | function createCompleted( ) { |
2054 | - if( empty( $this->completed )) return FALSE; |
|
2311 | + if( empty( $this->completed )) { |
|
2312 | + return FALSE; |
|
2313 | + } |
|
2055 | 2314 | if( !isset( $this->completed['value']['year'] ) && |
2056 | 2315 | !isset( $this->completed['value']['month'] ) && |
2057 | 2316 | !isset( $this->completed['value']['day'] ) && |
2058 | 2317 | !isset( $this->completed['value']['hour'] ) && |
2059 | 2318 | !isset( $this->completed['value']['min'] ) && |
2060 | - !isset( $this->completed['value']['sec'] )) |
|
2061 | - if( $this->getConfig( 'allowEmpty' )) |
|
2319 | + !isset( $this->completed['value']['sec'] )) { |
|
2320 | + if( $this->getConfig( 'allowEmpty' )) |
|
2062 | 2321 | return $this->_createElement( 'COMPLETED' ); |
2063 | - else return FALSE; |
|
2322 | + } else { |
|
2323 | + return FALSE; |
|
2324 | + } |
|
2064 | 2325 | $formatted = $this->_format_date_time( $this->completed['value'], 7 ); |
2065 | 2326 | $attributes = $this->_createParams( $this->completed['params'] ); |
2066 | 2327 | return $this->_createElement( 'COMPLETED', $attributes, $formatted ); |
@@ -2084,9 +2345,9 @@ discard block |
||
2084 | 2345 | if( $this->getConfig( 'allowEmpty' )) { |
2085 | 2346 | $this->completed = array( 'value' => null, 'params' => $this->_setParams( $params )); |
2086 | 2347 | return TRUE; |
2348 | + } else { |
|
2349 | + return FALSE; |
|
2087 | 2350 | } |
2088 | - else |
|
2089 | - return FALSE; |
|
2090 | 2351 | } |
2091 | 2352 | $this->completed = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
2092 | 2353 | return TRUE; |
@@ -2103,15 +2364,18 @@ discard block |
||
2103 | 2364 | * @return string |
2104 | 2365 | */ |
2105 | 2366 | function createContact() { |
2106 | - if( empty( $this->contact )) return FALSE; |
|
2367 | + if( empty( $this->contact )) { |
|
2368 | + return FALSE; |
|
2369 | + } |
|
2107 | 2370 | $output = null; |
2108 | 2371 | foreach( $this->contact as $contact ) { |
2109 | 2372 | if( !empty( $contact['value'] )) { |
2110 | 2373 | $attributes = $this->_createParams( $contact['params'], array( 'ALTREP', 'LANGUAGE' )); |
2111 | 2374 | $content = $this->_strrep( $contact['value'] ); |
2112 | 2375 | $output .= $this->_createElement( 'CONTACT', $attributes, $content ); |
2376 | + } elseif( $this->getConfig( 'allowEmpty' )) { |
|
2377 | + $output .= $this->_createElement( 'CONTACT' ); |
|
2113 | 2378 | } |
2114 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'CONTACT' ); |
|
2115 | 2379 | } |
2116 | 2380 | return $output; |
2117 | 2381 | } |
@@ -2126,7 +2390,11 @@ discard block |
||
2126 | 2390 | * @return bool |
2127 | 2391 | */ |
2128 | 2392 | function setContact( $value, $params=FALSE, $index=FALSE ) { |
2129 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
2393 | + if( empty( $value )) { |
|
2394 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
2395 | + } else { |
|
2396 | + return FALSE; |
|
2397 | + } |
|
2130 | 2398 | $this->_setMval( $this->contact, $value, $params, FALSE, $index ); |
2131 | 2399 | return TRUE; |
2132 | 2400 | } |
@@ -2142,7 +2410,9 @@ discard block |
||
2142 | 2410 | * @return string |
2143 | 2411 | */ |
2144 | 2412 | function createCreated() { |
2145 | - if( empty( $this->created )) return FALSE; |
|
2413 | + if( empty( $this->created )) { |
|
2414 | + return FALSE; |
|
2415 | + } |
|
2146 | 2416 | $formatted = $this->_format_date_time( $this->created['value'], 7 ); |
2147 | 2417 | $attributes = $this->_createParams( $this->created['params'] ); |
2148 | 2418 | return $this->_createElement( 'CREATED', $attributes, $formatted ); |
@@ -2180,15 +2450,18 @@ discard block |
||
2180 | 2450 | * @return string |
2181 | 2451 | */ |
2182 | 2452 | function createDescription() { |
2183 | - if( empty( $this->description )) return FALSE; |
|
2453 | + if( empty( $this->description )) { |
|
2454 | + return FALSE; |
|
2455 | + } |
|
2184 | 2456 | $output = null; |
2185 | 2457 | foreach( $this->description as $description ) { |
2186 | 2458 | if( !empty( $description['value'] )) { |
2187 | 2459 | $attributes = $this->_createParams( $description['params'], array( 'ALTREP', 'LANGUAGE' )); |
2188 | 2460 | $content = $this->_strrep( $description['value'] ); |
2189 | 2461 | $output .= $this->_createElement( 'DESCRIPTION', $attributes, $content ); |
2462 | + } elseif( $this->getConfig( 'allowEmpty' )) { |
|
2463 | + $output .= $this->_createElement( 'DESCRIPTION' ); |
|
2190 | 2464 | } |
2191 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'DESCRIPTION' ); |
|
2192 | 2465 | } |
2193 | 2466 | return $output; |
2194 | 2467 | } |
@@ -2203,7 +2476,12 @@ discard block |
||
2203 | 2476 | * @return bool |
2204 | 2477 | */ |
2205 | 2478 | function setDescription( $value, $params=FALSE, $index=FALSE ) { |
2206 | - if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; } |
|
2479 | + if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) { |
|
2480 | + $value = null; |
|
2481 | + } else { |
|
2482 | + return FALSE; |
|
2483 | + } |
|
2484 | + } |
|
2207 | 2485 | $this->_setMval( $this->description, $value, $params, FALSE, $index ); |
2208 | 2486 | return TRUE; |
2209 | 2487 | } |
@@ -2219,16 +2497,20 @@ discard block |
||
2219 | 2497 | * @return string |
2220 | 2498 | */ |
2221 | 2499 | function createDtend() { |
2222 | - if( empty( $this->dtend )) return FALSE; |
|
2500 | + if( empty( $this->dtend )) { |
|
2501 | + return FALSE; |
|
2502 | + } |
|
2223 | 2503 | if( !isset( $this->dtend['value']['year'] ) && |
2224 | 2504 | !isset( $this->dtend['value']['month'] ) && |
2225 | 2505 | !isset( $this->dtend['value']['day'] ) && |
2226 | 2506 | !isset( $this->dtend['value']['hour'] ) && |
2227 | 2507 | !isset( $this->dtend['value']['min'] ) && |
2228 | - !isset( $this->dtend['value']['sec'] )) |
|
2229 | - if( $this->getConfig( 'allowEmpty' )) |
|
2508 | + !isset( $this->dtend['value']['sec'] )) { |
|
2509 | + if( $this->getConfig( 'allowEmpty' )) |
|
2230 | 2510 | return $this->_createElement( 'DTEND' ); |
2231 | - else return FALSE; |
|
2511 | + } else { |
|
2512 | + return FALSE; |
|
2513 | + } |
|
2232 | 2514 | $formatted = $this->_format_date_time( $this->dtend['value'] ); |
2233 | 2515 | $attributes = $this->_createParams( $this->dtend['params'] ); |
2234 | 2516 | return $this->_createElement( 'DTEND', $attributes, $formatted ); |
@@ -2253,9 +2535,9 @@ discard block |
||
2253 | 2535 | if( $this->getConfig( 'allowEmpty' )) { |
2254 | 2536 | $this->dtend = array( 'value' => null, 'params' => $this->_setParams( $params )); |
2255 | 2537 | return TRUE; |
2538 | + } else { |
|
2539 | + return FALSE; |
|
2256 | 2540 | } |
2257 | - else |
|
2258 | - return FALSE; |
|
2259 | 2541 | } |
2260 | 2542 | $this->dtend = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
2261 | 2543 | return TRUE; |
@@ -2277,8 +2559,9 @@ discard block |
||
2277 | 2559 | !isset( $this->dtstamp['value']['day'] ) && |
2278 | 2560 | !isset( $this->dtstamp['value']['hour'] ) && |
2279 | 2561 | !isset( $this->dtstamp['value']['min'] ) && |
2280 | - !isset( $this->dtstamp['value']['sec'] )) |
|
2281 | - $this->_makeDtstamp(); |
|
2562 | + !isset( $this->dtstamp['value']['sec'] )) { |
|
2563 | + $this->_makeDtstamp(); |
|
2564 | + } |
|
2282 | 2565 | $formatted = $this->_format_date_time( $this->dtstamp['value'], 7 ); |
2283 | 2566 | $attributes = $this->_createParams( $this->dtstamp['params'] ); |
2284 | 2567 | return $this->_createElement( 'DTSTAMP', $attributes, $formatted ); |
@@ -2314,10 +2597,11 @@ discard block |
||
2314 | 2597 | * @return TRUE |
2315 | 2598 | */ |
2316 | 2599 | function setDtstamp( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
2317 | - if( empty( $year )) |
|
2318 | - $this->_makeDtstamp(); |
|
2319 | - else |
|
2320 | - $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
|
2600 | + if( empty( $year )) { |
|
2601 | + $this->_makeDtstamp(); |
|
2602 | + } else { |
|
2603 | + $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
|
2604 | + } |
|
2321 | 2605 | return TRUE; |
2322 | 2606 | } |
2323 | 2607 | /*********************************************************************************/ |
@@ -2332,18 +2616,23 @@ discard block |
||
2332 | 2616 | * @return string |
2333 | 2617 | */ |
2334 | 2618 | function createDtstart() { |
2335 | - if( empty( $this->dtstart )) return FALSE; |
|
2619 | + if( empty( $this->dtstart )) { |
|
2620 | + return FALSE; |
|
2621 | + } |
|
2336 | 2622 | if( !isset( $this->dtstart['value']['year'] ) && |
2337 | 2623 | !isset( $this->dtstart['value']['month'] ) && |
2338 | 2624 | !isset( $this->dtstart['value']['day'] ) && |
2339 | 2625 | !isset( $this->dtstart['value']['hour'] ) && |
2340 | 2626 | !isset( $this->dtstart['value']['min'] ) && |
2341 | - !isset( $this->dtstart['value']['sec'] )) |
|
2342 | - if( $this->getConfig( 'allowEmpty' )) |
|
2627 | + !isset( $this->dtstart['value']['sec'] )) { |
|
2628 | + if( $this->getConfig( 'allowEmpty' )) |
|
2343 | 2629 | return $this->_createElement( 'DTSTART' ); |
2344 | - else return FALSE; |
|
2345 | - if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) |
|
2346 | - unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] ); |
|
2630 | + } else { |
|
2631 | + return FALSE; |
|
2632 | + } |
|
2633 | + if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) { |
|
2634 | + unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] ); |
|
2635 | + } |
|
2347 | 2636 | $formatted = $this->_format_date_time( $this->dtstart['value'] ); |
2348 | 2637 | $attributes = $this->_createParams( $this->dtstart['params'] ); |
2349 | 2638 | return $this->_createElement( 'DTSTART', $attributes, $formatted ); |
@@ -2368,9 +2657,9 @@ discard block |
||
2368 | 2657 | if( $this->getConfig( 'allowEmpty' )) { |
2369 | 2658 | $this->dtstart = array( 'value' => null, 'params' => $this->_setParams( $params )); |
2370 | 2659 | return TRUE; |
2660 | + } else { |
|
2661 | + return FALSE; |
|
2371 | 2662 | } |
2372 | - else |
|
2373 | - return FALSE; |
|
2374 | 2663 | } |
2375 | 2664 | $this->dtstart = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params, 'dtstart' ); |
2376 | 2665 | return TRUE; |
@@ -2387,16 +2676,20 @@ discard block |
||
2387 | 2676 | * @return string |
2388 | 2677 | */ |
2389 | 2678 | function createDue() { |
2390 | - if( empty( $this->due )) return FALSE; |
|
2679 | + if( empty( $this->due )) { |
|
2680 | + return FALSE; |
|
2681 | + } |
|
2391 | 2682 | if( !isset( $this->due['value']['year'] ) && |
2392 | 2683 | !isset( $this->due['value']['month'] ) && |
2393 | 2684 | !isset( $this->due['value']['day'] ) && |
2394 | 2685 | !isset( $this->due['value']['hour'] ) && |
2395 | 2686 | !isset( $this->due['value']['min'] ) && |
2396 | - !isset( $this->due['value']['sec'] )) |
|
2397 | - if( $this->getConfig( 'allowEmpty' )) |
|
2687 | + !isset( $this->due['value']['sec'] )) { |
|
2688 | + if( $this->getConfig( 'allowEmpty' )) |
|
2398 | 2689 | return $this->_createElement( 'DUE' ); |
2399 | - else return FALSE; |
|
2690 | + } else { |
|
2691 | + return FALSE; |
|
2692 | + } |
|
2400 | 2693 | $formatted = $this->_format_date_time( $this->due['value'] ); |
2401 | 2694 | $attributes = $this->_createParams( $this->due['params'] ); |
2402 | 2695 | return $this->_createElement( 'DUE', $attributes, $formatted ); |
@@ -2420,9 +2713,9 @@ discard block |
||
2420 | 2713 | if( $this->getConfig( 'allowEmpty' )) { |
2421 | 2714 | $this->due = array( 'value' => null, 'params' => $this->_setParams( $params )); |
2422 | 2715 | return TRUE; |
2716 | + } else { |
|
2717 | + return FALSE; |
|
2423 | 2718 | } |
2424 | - else |
|
2425 | - return FALSE; |
|
2426 | 2719 | } |
2427 | 2720 | $this->due = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
2428 | 2721 | return TRUE; |
@@ -2439,15 +2732,19 @@ discard block |
||
2439 | 2732 | * @return string |
2440 | 2733 | */ |
2441 | 2734 | function createDuration() { |
2442 | - if( empty( $this->duration )) return FALSE; |
|
2735 | + if( empty( $this->duration )) { |
|
2736 | + return FALSE; |
|
2737 | + } |
|
2443 | 2738 | if( !isset( $this->duration['value']['week'] ) && |
2444 | 2739 | !isset( $this->duration['value']['day'] ) && |
2445 | 2740 | !isset( $this->duration['value']['hour'] ) && |
2446 | 2741 | !isset( $this->duration['value']['min'] ) && |
2447 | - !isset( $this->duration['value']['sec'] )) |
|
2448 | - if( $this->getConfig( 'allowEmpty' )) |
|
2742 | + !isset( $this->duration['value']['sec'] )) { |
|
2743 | + if( $this->getConfig( 'allowEmpty' )) |
|
2449 | 2744 | return $this->_createElement( 'DURATION', array(), null ); |
2450 | - else return FALSE; |
|
2745 | + } else { |
|
2746 | + return FALSE; |
|
2747 | + } |
|
2451 | 2748 | $attributes = $this->_createParams( $this->duration['params'] ); |
2452 | 2749 | return $this->_createElement( 'DURATION', $attributes, $this->_format_duration( $this->duration['value'] )); |
2453 | 2750 | } |
@@ -2465,19 +2762,24 @@ discard block |
||
2465 | 2762 | * @return bool |
2466 | 2763 | */ |
2467 | 2764 | function setDuration( $week, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
2468 | - if( empty( $week )) if( $this->getConfig( 'allowEmpty' )) $week = null; else return FALSE; |
|
2469 | - if( is_array( $week ) && ( 1 <= count( $week ))) |
|
2470 | - $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day )); |
|
2471 | - elseif( is_string( $week ) && ( 3 <= strlen( trim( $week )))) { |
|
2765 | + if( empty( $week )) { |
|
2766 | + if( $this->getConfig( 'allowEmpty' )) $week = null; |
|
2767 | + } else { |
|
2768 | + return FALSE; |
|
2769 | + } |
|
2770 | + if( is_array( $week ) && ( 1 <= count( $week ))) { |
|
2771 | + $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day )); |
|
2772 | + } elseif( is_string( $week ) && ( 3 <= strlen( trim( $week )))) { |
|
2472 | 2773 | $week = trim( $week ); |
2473 | - if( in_array( substr( $week, 0, 1 ), array( '+', '-' ))) |
|
2474 | - $week = substr( $week, 1 ); |
|
2774 | + if( in_array( substr( $week, 0, 1 ), array( '+', '-' ))) { |
|
2775 | + $week = substr( $week, 1 ); |
|
2776 | + } |
|
2475 | 2777 | $this->duration = array( 'value' => $this->_duration_string( $week ), 'params' => $this->_setParams( $day )); |
2778 | + } elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec )) { |
|
2779 | + return FALSE; |
|
2780 | + } else { |
|
2781 | + $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params )); |
|
2476 | 2782 | } |
2477 | - elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec )) |
|
2478 | - return FALSE; |
|
2479 | - else |
|
2480 | - $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params )); |
|
2481 | 2783 | return TRUE; |
2482 | 2784 | } |
2483 | 2785 | /*********************************************************************************/ |
@@ -2492,31 +2794,37 @@ discard block |
||
2492 | 2794 | * @return string |
2493 | 2795 | */ |
2494 | 2796 | function createExdate() { |
2495 | - if( empty( $this->exdate )) return FALSE; |
|
2797 | + if( empty( $this->exdate )) { |
|
2798 | + return FALSE; |
|
2799 | + } |
|
2496 | 2800 | $output = null; |
2497 | 2801 | foreach( $this->exdate as $ex => $theExdate ) { |
2498 | 2802 | if( empty( $theExdate['value'] )) { |
2499 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'EXDATE' ); |
|
2803 | + if( $this->getConfig( 'allowEmpty' )) { |
|
2804 | + $output .= $this->_createElement( 'EXDATE' ); |
|
2805 | + } |
|
2500 | 2806 | continue; |
2501 | 2807 | } |
2502 | 2808 | $content = $attributes = null; |
2503 | 2809 | foreach( $theExdate['value'] as $eix => $exdatePart ) { |
2504 | 2810 | $parno = count( $exdatePart ); |
2505 | 2811 | $formatted = $this->_format_date_time( $exdatePart, $parno ); |
2506 | - if( isset( $theExdate['params']['TZID'] )) |
|
2507 | - $formatted = str_replace( 'Z', '', $formatted); |
|
2812 | + if( isset( $theExdate['params']['TZID'] )) { |
|
2813 | + $formatted = str_replace( 'Z', '', $formatted); |
|
2814 | + } |
|
2508 | 2815 | if( 0 < $eix ) { |
2509 | 2816 | if( isset( $theExdate['value'][0]['tz'] )) { |
2510 | 2817 | if( ctype_digit( substr( $theExdate['value'][0]['tz'], -4 )) || |
2511 | 2818 | ( 'Z' == $theExdate['value'][0]['tz'] )) { |
2512 | - if( 'Z' != substr( $formatted, -1 )) |
|
2513 | - $formatted .= 'Z'; |
|
2819 | + if( 'Z' != substr( $formatted, -1 )) { |
|
2820 | + $formatted .= 'Z'; |
|
2821 | + } |
|
2822 | + } else { |
|
2823 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
2514 | 2824 | } |
2515 | - else |
|
2516 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2825 | + } else { |
|
2826 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
2517 | 2827 | } |
2518 | - else |
|
2519 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2520 | 2828 | } |
2521 | 2829 | $content .= ( 0 < $eix ) ? ','.$formatted : $formatted; |
2522 | 2830 | } |
@@ -2540,34 +2848,39 @@ discard block |
||
2540 | 2848 | if( $this->getConfig( 'allowEmpty' )) { |
2541 | 2849 | $this->_setMval( $this->exdate, null, $params, FALSE, $index ); |
2542 | 2850 | return TRUE; |
2851 | + } else { |
|
2852 | + return FALSE; |
|
2543 | 2853 | } |
2544 | - else |
|
2545 | - return FALSE; |
|
2546 | 2854 | } |
2547 | 2855 | $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ))); |
2548 | 2856 | /* ev. check 1:st date and save ev. timezone **/ |
2549 | 2857 | $this->_chkdatecfg( reset( $exdates ), $parno, $input['params'] ); |
2550 | 2858 | $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default parameter |
2551 | 2859 | foreach( $exdates as $eix => $theExdate ) { |
2552 | - if( $this->_isArrayTimestampDate( $theExdate )) |
|
2553 | - $exdatea = $this->_timestamp2date( $theExdate, $parno ); |
|
2554 | - elseif( is_array( $theExdate )) |
|
2555 | - $exdatea = $this->_date_time_array( $theExdate, $parno ); |
|
2556 | - elseif( 8 <= strlen( trim( $theExdate ))) // ex. 2006-08-03 10:12:18 |
|
2860 | + if( $this->_isArrayTimestampDate( $theExdate )) { |
|
2861 | + $exdatea = $this->_timestamp2date( $theExdate, $parno ); |
|
2862 | + } elseif( is_array( $theExdate )) { |
|
2863 | + $exdatea = $this->_date_time_array( $theExdate, $parno ); |
|
2864 | + } elseif( 8 <= strlen( trim( $theExdate ))) { |
|
2865 | + // ex. 2006-08-03 10:12:18 |
|
2557 | 2866 | $exdatea = $this->_date_time_string( $theExdate, $parno ); |
2558 | - if( 3 == $parno ) |
|
2559 | - unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] ); |
|
2560 | - elseif( isset( $exdatea['tz'] )) |
|
2561 | - $exdatea['tz'] = (string) $exdatea['tz']; |
|
2867 | + } |
|
2868 | + if( 3 == $parno ) { |
|
2869 | + unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] ); |
|
2870 | + } elseif( isset( $exdatea['tz'] )) { |
|
2871 | + $exdatea['tz'] = (string) $exdatea['tz']; |
|
2872 | + } |
|
2562 | 2873 | if( isset( $input['params']['TZID'] ) || |
2563 | 2874 | ( isset( $exdatea['tz'] ) && !$this->_isOffset( $exdatea['tz'] )) || |
2564 | 2875 | ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) || |
2565 | - ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) |
|
2566 | - unset( $exdatea['tz'] ); |
|
2876 | + ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) { |
|
2877 | + unset( $exdatea['tz'] ); |
|
2878 | + } |
|
2567 | 2879 | $input['value'][] = $exdatea; |
2568 | 2880 | } |
2569 | - if( 0 >= count( $input['value'] )) |
|
2570 | - return FALSE; |
|
2881 | + if( 0 >= count( $input['value'] )) { |
|
2882 | + return FALSE; |
|
2883 | + } |
|
2571 | 2884 | if( 3 == $parno ) { |
2572 | 2885 | $input['params']['VALUE'] = 'DATE'; |
2573 | 2886 | unset( $input['params']['TZID'] ); |
@@ -2587,7 +2900,9 @@ discard block |
||
2587 | 2900 | * @return string |
2588 | 2901 | */ |
2589 | 2902 | function createExrule() { |
2590 | - if( empty( $this->exrule )) return FALSE; |
|
2903 | + if( empty( $this->exrule )) { |
|
2904 | + return FALSE; |
|
2905 | + } |
|
2591 | 2906 | return $this->_format_recur( 'EXRULE', $this->exrule ); |
2592 | 2907 | } |
2593 | 2908 | /** |
@@ -2601,7 +2916,11 @@ discard block |
||
2601 | 2916 | * @return bool |
2602 | 2917 | */ |
2603 | 2918 | function setExrule( $exruleset, $params=FALSE, $index=FALSE ) { |
2604 | - if( empty( $exruleset )) if( $this->getConfig( 'allowEmpty' )) $exruleset = null; else return FALSE; |
|
2919 | + if( empty( $exruleset )) { |
|
2920 | + if( $this->getConfig( 'allowEmpty' )) $exruleset = null; |
|
2921 | + } else { |
|
2922 | + return FALSE; |
|
2923 | + } |
|
2605 | 2924 | $this->_setMval( $this->exrule, $this->_setRexrule( $exruleset ), $params, FALSE, $index ); |
2606 | 2925 | return TRUE; |
2607 | 2926 | } |
@@ -2617,11 +2936,15 @@ discard block |
||
2617 | 2936 | * @return string |
2618 | 2937 | */ |
2619 | 2938 | function createFreebusy() { |
2620 | - if( empty( $this->freebusy )) return FALSE; |
|
2939 | + if( empty( $this->freebusy )) { |
|
2940 | + return FALSE; |
|
2941 | + } |
|
2621 | 2942 | $output = null; |
2622 | 2943 | foreach( $this->freebusy as $freebusyPart ) { |
2623 | 2944 | if( empty( $freebusyPart['value'] )) { |
2624 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'FREEBUSY' ); |
|
2945 | + if( $this->getConfig( 'allowEmpty' )) { |
|
2946 | + $output .= $this->_createElement( 'FREEBUSY' ); |
|
2947 | + } |
|
2625 | 2948 | continue; |
2626 | 2949 | } |
2627 | 2950 | $attributes = $content = null; |
@@ -2629,9 +2952,9 @@ discard block |
||
2629 | 2952 | $attributes .= $this->intAttrDelimiter.'FBTYPE='.$freebusyPart['value']['fbtype']; |
2630 | 2953 | unset( $freebusyPart['value']['fbtype'] ); |
2631 | 2954 | $freebusyPart['value'] = array_values( $freebusyPart['value'] ); |
2955 | + } else { |
|
2956 | + $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY'; |
|
2632 | 2957 | } |
2633 | - else |
|
2634 | - $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY'; |
|
2635 | 2958 | $attributes .= $this->_createParams( $freebusyPart['params'] ); |
2636 | 2959 | $fno = 1; |
2637 | 2960 | $cnt = count( $freebusyPart['value']); |
@@ -2640,21 +2963,24 @@ discard block |
||
2640 | 2963 | $content .= $formatted; |
2641 | 2964 | $content .= '/'; |
2642 | 2965 | $cnt2 = count( $freebusyPeriod[1]); |
2643 | - if( array_key_exists( 'year', $freebusyPeriod[1] )) // date-time |
|
2966 | + if( array_key_exists( 'year', $freebusyPeriod[1] )) { |
|
2967 | + // date-time |
|
2644 | 2968 | $cnt2 = 7; |
2645 | - elseif( array_key_exists( 'week', $freebusyPeriod[1] )) // duration |
|
2969 | + } elseif( array_key_exists( 'week', $freebusyPeriod[1] )) { |
|
2970 | + // duration |
|
2646 | 2971 | $cnt2 = 5; |
2972 | + } |
|
2647 | 2973 | if(( 7 == $cnt2 ) && // period= -> date-time |
2648 | 2974 | isset( $freebusyPeriod[1]['year'] ) && |
2649 | 2975 | isset( $freebusyPeriod[1]['month'] ) && |
2650 | 2976 | isset( $freebusyPeriod[1]['day'] )) { |
2651 | 2977 | $content .= $this->_format_date_time( $freebusyPeriod[1] ); |
2652 | - } |
|
2653 | - else { // period= -> dur-time |
|
2978 | + } else { // period= -> dur-time |
|
2654 | 2979 | $content .= $this->_format_duration( $freebusyPeriod[1] ); |
2655 | 2980 | } |
2656 | - if( $fno < $cnt ) |
|
2657 | - $content .= ','; |
|
2981 | + if( $fno < $cnt ) { |
|
2982 | + $content .= ','; |
|
2983 | + } |
|
2658 | 2984 | $fno++; |
2659 | 2985 | } |
2660 | 2986 | $output .= $this->_createElement( 'FREEBUSY', $attributes, $content ); |
@@ -2677,14 +3003,15 @@ discard block |
||
2677 | 3003 | if( $this->getConfig( 'allowEmpty' )) { |
2678 | 3004 | $this->_setMval( $this->freebusy, null, $params, FALSE, $index ); |
2679 | 3005 | return TRUE; |
3006 | + } else { |
|
3007 | + return FALSE; |
|
2680 | 3008 | } |
2681 | - else |
|
2682 | - return FALSE; |
|
2683 | 3009 | } |
2684 | 3010 | $fbType = strtoupper( $fbType ); |
2685 | 3011 | if(( !in_array( $fbType, array( 'FREE', 'BUSY', 'BUSY-UNAVAILABLE', 'BUSY-TENTATIVE' ))) && |
2686 | - ( 'X-' != substr( $fbType, 0, 2 ))) |
|
2687 | - $fbType = 'BUSY'; |
|
3012 | + ( 'X-' != substr( $fbType, 0, 2 ))) { |
|
3013 | + $fbType = 'BUSY'; |
|
3014 | + } |
|
2688 | 3015 | $input = array( 'fbtype' => $fbType ); |
2689 | 3016 | foreach( $fbValues as $fbPeriod ) { // periods => period |
2690 | 3017 | $freebusyPeriod = array(); |
@@ -2694,22 +3021,19 @@ discard block |
||
2694 | 3021 | if( $this->_isArrayDate( $fbMember )) { // date-time value |
2695 | 3022 | $freebusyPairMember = $this->_date_time_array( $fbMember, 7 ); |
2696 | 3023 | $freebusyPairMember['tz'] = 'Z'; |
2697 | - } |
|
2698 | - elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value |
|
3024 | + } elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value |
|
2699 | 3025 | $freebusyPairMember = $this->_timestamp2date( $fbMember['timestamp'], 7 ); |
2700 | 3026 | $freebusyPairMember['tz'] = 'Z'; |
2701 | - } |
|
2702 | - else { // array format duration |
|
3027 | + } else { // array format duration |
|
2703 | 3028 | $freebusyPairMember = $this->_duration_array( $fbMember ); |
2704 | 3029 | } |
2705 | - } |
|
2706 | - elseif(( 3 <= strlen( trim( $fbMember ))) && // string format duration |
|
3030 | + } elseif(( 3 <= strlen( trim( $fbMember ))) && // string format duration |
|
2707 | 3031 | ( in_array( $fbMember{0}, array( 'P', '+', '-' )))) { |
2708 | - if( 'P' != $fbMember{0} ) |
|
2709 | - $fbmember = substr( $fbMember, 1 ); |
|
3032 | + if( 'P' != $fbMember{0} ) { |
|
3033 | + $fbmember = substr( $fbMember, 1 ); |
|
3034 | + } |
|
2710 | 3035 | $freebusyPairMember = $this->_duration_string( $fbMember ); |
2711 | - } |
|
2712 | - elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18 |
|
3036 | + } elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18 |
|
2713 | 3037 | $freebusyPairMember = $this->_date_time_string( $fbMember, 7 ); |
2714 | 3038 | $freebusyPairMember['tz'] = 'Z'; |
2715 | 3039 | } |
@@ -2732,9 +3056,12 @@ discard block |
||
2732 | 3056 | * @return string |
2733 | 3057 | */ |
2734 | 3058 | function createGeo() { |
2735 | - if( empty( $this->geo )) return FALSE; |
|
2736 | - if( empty( $this->geo['value'] )) |
|
2737 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE; |
|
3059 | + if( empty( $this->geo )) { |
|
3060 | + return FALSE; |
|
3061 | + } |
|
3062 | + if( empty( $this->geo['value'] )) { |
|
3063 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE; |
|
3064 | + } |
|
2738 | 3065 | $attributes = $this->_createParams( $this->geo['params'] ); |
2739 | 3066 | $content = null; |
2740 | 3067 | $content .= number_format( (float) $this->geo['value']['latitude'], 6, '.', ''); |
@@ -2754,15 +3081,17 @@ discard block |
||
2754 | 3081 | */ |
2755 | 3082 | function setGeo( $latitude, $longitude, $params=FALSE ) { |
2756 | 3083 | if( !empty( $latitude ) && !empty( $longitude )) { |
2757 | - if( !is_array( $this->geo )) $this->geo = array(); |
|
3084 | + if( !is_array( $this->geo )) { |
|
3085 | + $this->geo = array(); |
|
3086 | + } |
|
2758 | 3087 | $this->geo['value']['latitude'] = $latitude; |
2759 | 3088 | $this->geo['value']['longitude'] = $longitude; |
2760 | 3089 | $this->geo['params'] = $this->_setParams( $params ); |
3090 | + } elseif( $this->getConfig( 'allowEmpty' )) { |
|
3091 | + $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) ); |
|
3092 | + } else { |
|
3093 | + return FALSE; |
|
2761 | 3094 | } |
2762 | - elseif( $this->getConfig( 'allowEmpty' )) |
|
2763 | - $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) ); |
|
2764 | - else |
|
2765 | - return FALSE; |
|
2766 | 3095 | return TRUE; |
2767 | 3096 | } |
2768 | 3097 | /*********************************************************************************/ |
@@ -2777,7 +3106,9 @@ discard block |
||
2777 | 3106 | * @return string |
2778 | 3107 | */ |
2779 | 3108 | function createLastModified() { |
2780 | - if( empty( $this->lastmodified )) return FALSE; |
|
3109 | + if( empty( $this->lastmodified )) { |
|
3110 | + return FALSE; |
|
3111 | + } |
|
2781 | 3112 | $attributes = $this->_createParams( $this->lastmodified['params'] ); |
2782 | 3113 | $formatted = $this->_format_date_time( $this->lastmodified['value'], 7 ); |
2783 | 3114 | return $this->_createElement( 'LAST-MODIFIED', $attributes, $formatted ); |
@@ -2797,8 +3128,9 @@ discard block |
||
2797 | 3128 | * @return boll |
2798 | 3129 | */ |
2799 | 3130 | function setLastModified( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { |
2800 | - if( empty( $year )) |
|
2801 | - $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' ))); |
|
3131 | + if( empty( $year )) { |
|
3132 | + $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' ))); |
|
3133 | + } |
|
2802 | 3134 | $this->lastmodified = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); |
2803 | 3135 | return TRUE; |
2804 | 3136 | } |
@@ -2814,9 +3146,12 @@ discard block |
||
2814 | 3146 | * @return string |
2815 | 3147 | */ |
2816 | 3148 | function createLocation() { |
2817 | - if( empty( $this->location )) return FALSE; |
|
2818 | - if( empty( $this->location['value'] )) |
|
2819 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE; |
|
3149 | + if( empty( $this->location )) { |
|
3150 | + return FALSE; |
|
3151 | + } |
|
3152 | + if( empty( $this->location['value'] )) { |
|
3153 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE; |
|
3154 | + } |
|
2820 | 3155 | $attributes = $this->_createParams( $this->location['params'], array( 'ALTREP', 'LANGUAGE' )); |
2821 | 3156 | $content = $this->_strrep( $this->location['value'] ); |
2822 | 3157 | return $this->_createElement( 'LOCATION', $attributes, $content ); |
@@ -2831,7 +3166,11 @@ discard block |
||
2831 | 3166 | * @return bool |
2832 | 3167 | */ |
2833 | 3168 | function setLocation( $value, $params=FALSE ) { |
2834 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3169 | + if( empty( $value )) { |
|
3170 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3171 | + } else { |
|
3172 | + return FALSE; |
|
3173 | + } |
|
2835 | 3174 | $this->location = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
2836 | 3175 | return TRUE; |
2837 | 3176 | } |
@@ -2847,9 +3186,12 @@ discard block |
||
2847 | 3186 | * @return string |
2848 | 3187 | */ |
2849 | 3188 | function createOrganizer() { |
2850 | - if( empty( $this->organizer )) return FALSE; |
|
2851 | - if( empty( $this->organizer['value'] )) |
|
2852 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE; |
|
3189 | + if( empty( $this->organizer )) { |
|
3190 | + return FALSE; |
|
3191 | + } |
|
3192 | + if( empty( $this->organizer['value'] )) { |
|
3193 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE; |
|
3194 | + } |
|
2853 | 3195 | $attributes = $this->_createParams( $this->organizer['params'] |
2854 | 3196 | , array( 'CN', 'DIR', 'LANGUAGE', 'SENT-BY' )); |
2855 | 3197 | $content = 'MAILTO:'.$this->organizer['value']; |
@@ -2865,13 +3207,18 @@ discard block |
||
2865 | 3207 | * @return bool |
2866 | 3208 | */ |
2867 | 3209 | function setOrganizer( $value, $params=FALSE ) { |
2868 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3210 | + if( empty( $value )) { |
|
3211 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3212 | + } else { |
|
3213 | + return FALSE; |
|
3214 | + } |
|
2869 | 3215 | $value = str_replace ( 'MAILTO:', '', $value ); |
2870 | 3216 | $value = str_replace ( 'mailto:', '', $value ); |
2871 | 3217 | $this->organizer = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
2872 | 3218 | if( isset( $this->organizer['params']['SENT-BY'] )) { |
2873 | - if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 ))) |
|
2874 | - $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 ); |
|
3219 | + if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 ))) { |
|
3220 | + $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 ); |
|
3221 | + } |
|
2875 | 3222 | } |
2876 | 3223 | return TRUE; |
2877 | 3224 | } |
@@ -2887,9 +3234,12 @@ discard block |
||
2887 | 3234 | * @return string |
2888 | 3235 | */ |
2889 | 3236 | function createPercentComplete() { |
2890 | - if( empty( $this->percentcomplete )) return FALSE; |
|
2891 | - if( empty( $this->percentcomplete['value'] )) |
|
2892 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE; |
|
3237 | + if( empty( $this->percentcomplete )) { |
|
3238 | + return FALSE; |
|
3239 | + } |
|
3240 | + if( empty( $this->percentcomplete['value'] )) { |
|
3241 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE; |
|
3242 | + } |
|
2893 | 3243 | $attributes = $this->_createParams( $this->percentcomplete['params'] ); |
2894 | 3244 | return $this->_createElement( 'PERCENT-COMPLETE', $attributes, $this->percentcomplete['value'] ); |
2895 | 3245 | } |
@@ -2903,7 +3253,11 @@ discard block |
||
2903 | 3253 | * @return bool |
2904 | 3254 | */ |
2905 | 3255 | function setPercentComplete( $value, $params=FALSE ) { |
2906 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3256 | + if( empty( $value )) { |
|
3257 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3258 | + } else { |
|
3259 | + return FALSE; |
|
3260 | + } |
|
2907 | 3261 | $this->percentcomplete = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
2908 | 3262 | return TRUE; |
2909 | 3263 | } |
@@ -2919,9 +3273,12 @@ discard block |
||
2919 | 3273 | * @return string |
2920 | 3274 | */ |
2921 | 3275 | function createPriority() { |
2922 | - if( empty( $this->priority )) return FALSE; |
|
2923 | - if( empty( $this->priority['value'] )) |
|
2924 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE; |
|
3276 | + if( empty( $this->priority )) { |
|
3277 | + return FALSE; |
|
3278 | + } |
|
3279 | + if( empty( $this->priority['value'] )) { |
|
3280 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE; |
|
3281 | + } |
|
2925 | 3282 | $attributes = $this->_createParams( $this->priority['params'] ); |
2926 | 3283 | return $this->_createElement( 'PRIORITY', $attributes, $this->priority['value'] ); |
2927 | 3284 | } |
@@ -2935,7 +3292,11 @@ discard block |
||
2935 | 3292 | * @return bool |
2936 | 3293 | */ |
2937 | 3294 | function setPriority( $value, $params=FALSE ) { |
2938 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3295 | + if( empty( $value )) { |
|
3296 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3297 | + } else { |
|
3298 | + return FALSE; |
|
3299 | + } |
|
2939 | 3300 | $this->priority = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
2940 | 3301 | return TRUE; |
2941 | 3302 | } |
@@ -2951,18 +3312,24 @@ discard block |
||
2951 | 3312 | * @return string |
2952 | 3313 | */ |
2953 | 3314 | function createRdate() { |
2954 | - if( empty( $this->rdate )) return FALSE; |
|
3315 | + if( empty( $this->rdate )) { |
|
3316 | + return FALSE; |
|
3317 | + } |
|
2955 | 3318 | $utctime = ( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE; |
2956 | 3319 | $output = null; |
2957 | - if( $utctime ) |
|
2958 | - unset( $this->rdate['params']['TZID'] ); |
|
3320 | + if( $utctime ) { |
|
3321 | + unset( $this->rdate['params']['TZID'] ); |
|
3322 | + } |
|
2959 | 3323 | foreach( $this->rdate as $theRdate ) { |
2960 | 3324 | if( empty( $theRdate['value'] )) { |
2961 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RDATE' ); |
|
3325 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3326 | + $output .= $this->_createElement( 'RDATE' ); |
|
3327 | + } |
|
2962 | 3328 | continue; |
2963 | 3329 | } |
2964 | - if( $utctime ) |
|
2965 | - unset( $theRdate['params']['TZID'] ); |
|
3330 | + if( $utctime ) { |
|
3331 | + unset( $theRdate['params']['TZID'] ); |
|
3332 | + } |
|
2966 | 3333 | $attributes = $this->_createParams( $theRdate['params'] ); |
2967 | 3334 | $cnt = count( $theRdate['value'] ); |
2968 | 3335 | $content = null; |
@@ -2971,68 +3338,84 @@ discard block |
||
2971 | 3338 | $contentPart = null; |
2972 | 3339 | if( is_array( $rdatePart ) && |
2973 | 3340 | isset( $theRdate['params']['VALUE'] ) && ( 'PERIOD' == $theRdate['params']['VALUE'] )) { // PERIOD |
2974 | - if( $utctime ) |
|
2975 | - unset( $rdatePart[0]['tz'] ); |
|
3341 | + if( $utctime ) { |
|
3342 | + unset( $rdatePart[0]['tz'] ); |
|
3343 | + } |
|
2976 | 3344 | $formatted = $this->_format_date_time( $rdatePart[0]); // PERIOD part 1 |
2977 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
2978 | - $formatted = str_replace( 'Z', '', $formatted); |
|
3345 | + if( $utctime || !empty( $theRdate['params']['TZID'] )) { |
|
3346 | + $formatted = str_replace( 'Z', '', $formatted); |
|
3347 | + } |
|
2979 | 3348 | if( 0 < $rpix ) { |
2980 | 3349 | if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) { |
2981 | - if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z'; |
|
3350 | + if( 'Z' != substr( $formatted, -1 )) { |
|
3351 | + $formatted .= 'Z'; |
|
3352 | + } |
|
3353 | + } else { |
|
3354 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
2982 | 3355 | } |
2983 | - else |
|
2984 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
2985 | 3356 | } |
2986 | 3357 | $contentPart .= $formatted; |
2987 | 3358 | $contentPart .= '/'; |
2988 | 3359 | $cnt2 = count( $rdatePart[1]); |
2989 | 3360 | if( array_key_exists( 'year', $rdatePart[1] )) { |
2990 | - if( array_key_exists( 'hour', $rdatePart[1] )) |
|
2991 | - $cnt2 = 7; // date-time |
|
2992 | - else |
|
2993 | - $cnt2 = 3; // date |
|
2994 | - } |
|
2995 | - elseif( array_key_exists( 'week', $rdatePart[1] )) // duration |
|
3361 | + if( array_key_exists( 'hour', $rdatePart[1] )) { |
|
3362 | + $cnt2 = 7; |
|
3363 | + } |
|
3364 | + // date-time |
|
3365 | + else { |
|
3366 | + $cnt2 = 3; |
|
3367 | + } |
|
3368 | + // date |
|
3369 | + } elseif( array_key_exists( 'week', $rdatePart[1] )) { |
|
3370 | + // duration |
|
2996 | 3371 | $cnt2 = 5; |
3372 | + } |
|
2997 | 3373 | if(( 7 == $cnt2 ) && // period= -> date-time |
2998 | 3374 | isset( $rdatePart[1]['year'] ) && |
2999 | 3375 | isset( $rdatePart[1]['month'] ) && |
3000 | 3376 | isset( $rdatePart[1]['day'] )) { |
3001 | - if( $utctime ) |
|
3002 | - unset( $rdatePart[1]['tz'] ); |
|
3377 | + if( $utctime ) { |
|
3378 | + unset( $rdatePart[1]['tz'] ); |
|
3379 | + } |
|
3003 | 3380 | $formatted = $this->_format_date_time( $rdatePart[1] ); // PERIOD part 2 |
3004 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
3005 | - $formatted = str_replace( 'Z', '', $formatted); |
|
3381 | + if( $utctime || !empty( $theRdate['params']['TZID'] )) { |
|
3382 | + $formatted = str_replace( 'Z', '', $formatted); |
|
3383 | + } |
|
3006 | 3384 | if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) { |
3007 | - if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z'; |
|
3385 | + if( 'Z' != substr( $formatted, -1 )) { |
|
3386 | + $formatted .= 'Z'; |
|
3387 | + } |
|
3388 | + } else { |
|
3389 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
3008 | 3390 | } |
3009 | - else |
|
3010 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
3011 | 3391 | $contentPart .= $formatted; |
3012 | - } |
|
3013 | - else { // period= -> dur-time |
|
3392 | + } else { // period= -> dur-time |
|
3014 | 3393 | $contentPart .= $this->_format_duration( $rdatePart[1] ); |
3015 | 3394 | } |
3016 | 3395 | } // PERIOD end |
3017 | 3396 | else { // SINGLE date start |
3018 | - if( $utctime ) |
|
3019 | - unset( $rdatePart['tz'] ); |
|
3397 | + if( $utctime ) { |
|
3398 | + unset( $rdatePart['tz'] ); |
|
3399 | + } |
|
3020 | 3400 | $formatted = $this->_format_date_time( $rdatePart); |
3021 | - if( $utctime || !empty( $theRdate['params']['TZID'] )) |
|
3022 | - $formatted = str_replace( 'Z', '', $formatted); |
|
3401 | + if( $utctime || !empty( $theRdate['params']['TZID'] )) { |
|
3402 | + $formatted = str_replace( 'Z', '', $formatted); |
|
3403 | + } |
|
3023 | 3404 | if( !$utctime && ( 0 < $rpix )) { |
3024 | 3405 | if( !empty( $theRdate['value'][0]['tz'] ) && $this->_isOffset( $theRdate['value'][0]['tz'] )) { |
3025 | - if( 'Z' != substr( $formatted, -1 )) |
|
3026 | - $formatted .= 'Z'; |
|
3406 | + if( 'Z' != substr( $formatted, -1 )) { |
|
3407 | + $formatted .= 'Z'; |
|
3408 | + } |
|
3409 | + } else { |
|
3410 | + $formatted = str_replace( 'Z', '', $formatted ); |
|
3027 | 3411 | } |
3028 | - else |
|
3029 | - $formatted = str_replace( 'Z', '', $formatted ); |
|
3030 | 3412 | } |
3031 | 3413 | $contentPart .= $formatted; |
3032 | 3414 | } |
3033 | 3415 | $content .= $contentPart; |
3034 | - if( $rno < $cnt ) |
|
3035 | - $content .= ','; |
|
3416 | + if( $rno < $cnt ) { |
|
3417 | + $content .= ','; |
|
3418 | + } |
|
3036 | 3419 | $rno++; |
3037 | 3420 | } |
3038 | 3421 | $output .= $this->_createElement( 'RDATE', $attributes, $content ); |
@@ -3054,9 +3437,9 @@ discard block |
||
3054 | 3437 | if( $this->getConfig( 'allowEmpty' )) { |
3055 | 3438 | $this->_setMval( $this->rdate, null, $params, FALSE, $index ); |
3056 | 3439 | return TRUE; |
3440 | + } else { |
|
3441 | + return FALSE; |
|
3057 | 3442 | } |
3058 | - else |
|
3059 | - return FALSE; |
|
3060 | 3443 | } |
3061 | 3444 | $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ))); |
3062 | 3445 | if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) { |
@@ -3070,15 +3453,19 @@ discard block |
||
3070 | 3453 | (( is_array( $rdates[0][0] ) && ( isset( $rdates[0][0]['timestamp'] ) || |
3071 | 3454 | $this->_isArrayDate( $rdates[0][0] ))) || |
3072 | 3455 | ( is_string( $rdates[0][0] ) && ( 8 <= strlen( trim( $rdates[0][0] ))))) && |
3073 | - ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] )))))) |
|
3074 | - $input['params']['VALUE'] = 'PERIOD'; |
|
3456 | + ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] )))))) { |
|
3457 | + $input['params']['VALUE'] = 'PERIOD'; |
|
3458 | + } |
|
3075 | 3459 | /* check 1:st date, upd. $parno (opt) and save ev. timezone **/ |
3076 | 3460 | $date = reset( $rdates ); |
3077 | - if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) // PERIOD |
|
3461 | + if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) { |
|
3462 | + // PERIOD |
|
3078 | 3463 | $date = reset( $date ); |
3464 | + } |
|
3079 | 3465 | $this->_chkdatecfg( $date, $parno, $input['params'] ); |
3080 | - if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) |
|
3081 | - unset( $input['params']['TZID'] ); |
|
3466 | + if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) { |
|
3467 | + unset( $input['params']['TZID'] ); |
|
3468 | + } |
|
3082 | 3469 | $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default |
3083 | 3470 | foreach( $rdates as $rpix => $theRdate ) { |
3084 | 3471 | $inputa = null; |
@@ -3086,48 +3473,60 @@ discard block |
||
3086 | 3473 | if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) { // PERIOD |
3087 | 3474 | foreach( $theRdate as $rix => $rPeriod ) { |
3088 | 3475 | if( is_array( $rPeriod )) { |
3089 | - if( $this->_isArrayTimestampDate( $rPeriod )) // timestamp |
|
3476 | + if( $this->_isArrayTimestampDate( $rPeriod )) { |
|
3477 | + // timestamp |
|
3090 | 3478 | $inputab = ( isset( $rPeriod['tz'] )) ? $this->_timestamp2date( $rPeriod, $parno ) : $this->_timestamp2date( $rPeriod, 6 ); |
3091 | - elseif( $this->_isArrayDate( $rPeriod )) |
|
3092 | - $inputab = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 ); |
|
3093 | - elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod )))) // text-date |
|
3479 | + } elseif( $this->_isArrayDate( $rPeriod )) { |
|
3480 | + $inputab = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 ); |
|
3481 | + } elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod )))) { |
|
3482 | + // text-date |
|
3094 | 3483 | $inputab = $this->_date_time_string( reset( $rPeriod ), $parno ); |
3095 | - else // array format duration |
|
3484 | + } else { |
|
3485 | + // array format duration |
|
3096 | 3486 | $inputab = $this->_duration_array( $rPeriod ); |
3097 | - } |
|
3098 | - elseif(( 3 <= strlen( trim( $rPeriod ))) && // string format duration |
|
3487 | + } |
|
3488 | + } elseif(( 3 <= strlen( trim( $rPeriod ))) && // string format duration |
|
3099 | 3489 | ( in_array( $rPeriod{0}, array( 'P', '+', '-' )))) { |
3100 | - if( 'P' != $rPeriod{0} ) |
|
3101 | - $rPeriod = substr( $rPeriod, 1 ); |
|
3490 | + if( 'P' != $rPeriod{0} ) { |
|
3491 | + $rPeriod = substr( $rPeriod, 1 ); |
|
3492 | + } |
|
3102 | 3493 | $inputab = $this->_duration_string( $rPeriod ); |
3103 | - } |
|
3104 | - elseif( 8 <= strlen( trim( $rPeriod ))) // text date ex. 2006-08-03 10:12:18 |
|
3494 | + } elseif( 8 <= strlen( trim( $rPeriod ))) { |
|
3495 | + // text date ex. 2006-08-03 10:12:18 |
|
3105 | 3496 | $inputab = $this->_date_time_string( $rPeriod, $parno ); |
3497 | + } |
|
3106 | 3498 | if( isset( $input['params']['TZID'] ) || |
3107 | 3499 | ( isset( $inputab['tz'] ) && !$this->_isOffset( $inputab['tz'] )) || |
3108 | 3500 | ( isset( $inputa[0] ) && ( !isset( $inputa[0]['tz'] ))) || |
3109 | - ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] ))) |
|
3110 | - unset( $inputab['tz'] ); |
|
3501 | + ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] ))) { |
|
3502 | + unset( $inputab['tz'] ); |
|
3503 | + } |
|
3111 | 3504 | $inputa[] = $inputab; |
3112 | 3505 | } |
3113 | 3506 | } // PERIOD end |
3114 | - elseif ( $this->_isArrayTimestampDate( $theRdate )) // timestamp |
|
3507 | + elseif ( $this->_isArrayTimestampDate( $theRdate )) { |
|
3508 | + // timestamp |
|
3115 | 3509 | $inputa = $this->_timestamp2date( $theRdate, $parno ); |
3116 | - else // date[-time] |
|
3510 | + } else { |
|
3511 | + // date[-time] |
|
3117 | 3512 | $inputa = $this->_date_time_array( $theRdate, $parno ); |
3118 | - } |
|
3119 | - elseif( 8 <= strlen( trim( $theRdate ))) // text date ex. 2006-08-03 10:12:18 |
|
3513 | + } |
|
3514 | + } elseif( 8 <= strlen( trim( $theRdate ))) { |
|
3515 | + // text date ex. 2006-08-03 10:12:18 |
|
3120 | 3516 | $inputa = $this->_date_time_string( $theRdate, $parno ); |
3517 | + } |
|
3121 | 3518 | if( !isset( $input['params']['VALUE'] ) || ( 'PERIOD' != $input['params']['VALUE'] )) { // no PERIOD |
3122 | - if( 3 == $parno ) |
|
3123 | - unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] ); |
|
3124 | - elseif( isset( $inputa['tz'] )) |
|
3125 | - $inputa['tz'] = (string) $inputa['tz']; |
|
3519 | + if( 3 == $parno ) { |
|
3520 | + unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] ); |
|
3521 | + } elseif( isset( $inputa['tz'] )) { |
|
3522 | + $inputa['tz'] = (string) $inputa['tz']; |
|
3523 | + } |
|
3126 | 3524 | if( isset( $input['params']['TZID'] ) || |
3127 | 3525 | ( isset( $inputa['tz'] ) && !$this->_isOffset( $inputa['tz'] )) || |
3128 | 3526 | ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) || |
3129 | - ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) |
|
3130 | - unset( $inputa['tz'] ); |
|
3527 | + ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) { |
|
3528 | + unset( $inputa['tz'] ); |
|
3529 | + } |
|
3131 | 3530 | } |
3132 | 3531 | $input['value'][] = $inputa; |
3133 | 3532 | } |
@@ -3150,9 +3549,12 @@ discard block |
||
3150 | 3549 | * @return string |
3151 | 3550 | */ |
3152 | 3551 | function createRecurrenceid() { |
3153 | - if( empty( $this->recurrenceid )) return FALSE; |
|
3154 | - if( empty( $this->recurrenceid['value'] )) |
|
3155 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE; |
|
3552 | + if( empty( $this->recurrenceid )) { |
|
3553 | + return FALSE; |
|
3554 | + } |
|
3555 | + if( empty( $this->recurrenceid['value'] )) { |
|
3556 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE; |
|
3557 | + } |
|
3156 | 3558 | $formatted = $this->_format_date_time( $this->recurrenceid['value'] ); |
3157 | 3559 | $attributes = $this->_createParams( $this->recurrenceid['params'] ); |
3158 | 3560 | return $this->_createElement( 'RECURRENCE-ID', $attributes, $formatted ); |
@@ -3176,9 +3578,9 @@ discard block |
||
3176 | 3578 | if( $this->getConfig( 'allowEmpty' )) { |
3177 | 3579 | $this->recurrenceid = array( 'value' => null, 'params' => null ); |
3178 | 3580 | return TRUE; |
3581 | + } else { |
|
3582 | + return FALSE; |
|
3179 | 3583 | } |
3180 | - else |
|
3181 | - return FALSE; |
|
3182 | 3584 | } |
3183 | 3585 | $this->recurrenceid = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params ); |
3184 | 3586 | return TRUE; |
@@ -3195,11 +3597,15 @@ discard block |
||
3195 | 3597 | * @return string |
3196 | 3598 | */ |
3197 | 3599 | function createRelatedTo() { |
3198 | - if( empty( $this->relatedto )) return FALSE; |
|
3600 | + if( empty( $this->relatedto )) { |
|
3601 | + return FALSE; |
|
3602 | + } |
|
3199 | 3603 | $output = null; |
3200 | 3604 | foreach( $this->relatedto as $relation ) { |
3201 | 3605 | if( empty( $relation['value'] )) { |
3202 | - if( $this->getConfig( 'allowEmpty' )) $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] )); |
|
3606 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3607 | + $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] )); |
|
3608 | + } |
|
3203 | 3609 | continue; |
3204 | 3610 | } |
3205 | 3611 | $attributes = $this->_createParams( $relation['params'] ); |
@@ -3221,9 +3627,14 @@ discard block |
||
3221 | 3627 | * @return bool |
3222 | 3628 | */ |
3223 | 3629 | function setRelatedTo( $value, $params=FALSE, $index=FALSE ) { |
3224 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3225 | - if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 ))) |
|
3226 | - $value = substr( $value, 1, ( strlen( $value ) - 2 )); |
|
3630 | + if( empty( $value )) { |
|
3631 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3632 | + } else { |
|
3633 | + return FALSE; |
|
3634 | + } |
|
3635 | + if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 ))) { |
|
3636 | + $value = substr( $value, 1, ( strlen( $value ) - 2 )); |
|
3637 | + } |
|
3227 | 3638 | $this->_existRem( $params, 'RELTYPE', 'PARENT', TRUE ); // remove default |
3228 | 3639 | $this->_setMval( $this->relatedto, $value, $params, FALSE, $index ); |
3229 | 3640 | return TRUE; |
@@ -3240,9 +3651,12 @@ discard block |
||
3240 | 3651 | * @return string |
3241 | 3652 | */ |
3242 | 3653 | function createRepeat() { |
3243 | - if( empty( $this->repeat )) return FALSE; |
|
3244 | - if( empty( $this->repeat['value'] )) |
|
3245 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE; |
|
3654 | + if( empty( $this->repeat )) { |
|
3655 | + return FALSE; |
|
3656 | + } |
|
3657 | + if( empty( $this->repeat['value'] )) { |
|
3658 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE; |
|
3659 | + } |
|
3246 | 3660 | $attributes = $this->_createParams( $this->repeat['params'] ); |
3247 | 3661 | return $this->_createElement( 'REPEAT', $attributes, $this->repeat['value'] ); |
3248 | 3662 | } |
@@ -3256,7 +3670,11 @@ discard block |
||
3256 | 3670 | * @return void |
3257 | 3671 | */ |
3258 | 3672 | function setRepeat( $value, $params=FALSE ) { |
3259 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3673 | + if( empty( $value )) { |
|
3674 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3675 | + } else { |
|
3676 | + return FALSE; |
|
3677 | + } |
|
3260 | 3678 | $this->repeat = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3261 | 3679 | return TRUE; |
3262 | 3680 | } |
@@ -3271,18 +3689,23 @@ discard block |
||
3271 | 3689 | * @return string |
3272 | 3690 | */ |
3273 | 3691 | function createRequestStatus() { |
3274 | - if( empty( $this->requeststatus )) return FALSE; |
|
3692 | + if( empty( $this->requeststatus )) { |
|
3693 | + return FALSE; |
|
3694 | + } |
|
3275 | 3695 | $output = null; |
3276 | 3696 | foreach( $this->requeststatus as $rstat ) { |
3277 | 3697 | if( empty( $rstat['value']['statcode'] )) { |
3278 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'REQUEST-STATUS' ); |
|
3698 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3699 | + $output .= $this->_createElement( 'REQUEST-STATUS' ); |
|
3700 | + } |
|
3279 | 3701 | continue; |
3280 | 3702 | } |
3281 | 3703 | $attributes = $this->_createParams( $rstat['params'], array( 'LANGUAGE' )); |
3282 | 3704 | $content = number_format( (float) $rstat['value']['statcode'], 2, '.', ''); |
3283 | 3705 | $content .= ';'.$this->_strrep( $rstat['value']['text'] ); |
3284 | - if( isset( $rstat['value']['extdata'] )) |
|
3285 | - $content .= ';'.$this->_strrep( $rstat['value']['extdata'] ); |
|
3706 | + if( isset( $rstat['value']['extdata'] )) { |
|
3707 | + $content .= ';'.$this->_strrep( $rstat['value']['extdata'] ); |
|
3708 | + } |
|
3286 | 3709 | $output .= $this->_createElement( 'REQUEST-STATUS', $attributes, $content ); |
3287 | 3710 | } |
3288 | 3711 | return $output; |
@@ -3300,10 +3723,15 @@ discard block |
||
3300 | 3723 | * @return bool |
3301 | 3724 | */ |
3302 | 3725 | function setRequestStatus( $statcode, $text, $extdata=FALSE, $params=FALSE, $index=FALSE ) { |
3303 | - if( empty( $statcode ) || empty( $text )) if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null; else return FALSE; |
|
3726 | + if( empty( $statcode ) || empty( $text )) { |
|
3727 | + if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null; |
|
3728 | + } else { |
|
3729 | + return FALSE; |
|
3730 | + } |
|
3304 | 3731 | $input = array( 'statcode' => $statcode, 'text' => $text ); |
3305 | - if( $extdata ) |
|
3306 | - $input['extdata'] = $extdata; |
|
3732 | + if( $extdata ) { |
|
3733 | + $input['extdata'] = $extdata; |
|
3734 | + } |
|
3307 | 3735 | $this->_setMval( $this->requeststatus, $input, $params, FALSE, $index ); |
3308 | 3736 | return TRUE; |
3309 | 3737 | } |
@@ -3319,21 +3747,26 @@ discard block |
||
3319 | 3747 | * @return string |
3320 | 3748 | */ |
3321 | 3749 | function createResources() { |
3322 | - if( empty( $this->resources )) return FALSE; |
|
3750 | + if( empty( $this->resources )) { |
|
3751 | + return FALSE; |
|
3752 | + } |
|
3323 | 3753 | $output = null; |
3324 | 3754 | foreach( $this->resources as $resource ) { |
3325 | 3755 | if( empty( $resource['value'] )) { |
3326 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RESOURCES' ); |
|
3756 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3757 | + $output .= $this->_createElement( 'RESOURCES' ); |
|
3758 | + } |
|
3327 | 3759 | continue; |
3328 | 3760 | } |
3329 | 3761 | $attributes = $this->_createParams( $resource['params'], array( 'ALTREP', 'LANGUAGE' )); |
3330 | 3762 | if( is_array( $resource['value'] )) { |
3331 | - foreach( $resource['value'] as $rix => $resourcePart ) |
|
3332 | - $resource['value'][$rix] = $this->_strrep( $resourcePart ); |
|
3763 | + foreach( $resource['value'] as $rix => $resourcePart ) { |
|
3764 | + $resource['value'][$rix] = $this->_strrep( $resourcePart ); |
|
3765 | + } |
|
3333 | 3766 | $content = implode( ',', $resource['value'] ); |
3767 | + } else { |
|
3768 | + $content = $this->_strrep( $resource['value'] ); |
|
3334 | 3769 | } |
3335 | - else |
|
3336 | - $content = $this->_strrep( $resource['value'] ); |
|
3337 | 3770 | $output .= $this->_createElement( 'RESOURCES', $attributes, $content ); |
3338 | 3771 | } |
3339 | 3772 | return $output; |
@@ -3349,7 +3782,11 @@ discard block |
||
3349 | 3782 | * @return bool |
3350 | 3783 | */ |
3351 | 3784 | function setResources( $value, $params=FALSE, $index=FALSE ) { |
3352 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3785 | + if( empty( $value )) { |
|
3786 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3787 | + } else { |
|
3788 | + return FALSE; |
|
3789 | + } |
|
3353 | 3790 | $this->_setMval( $this->resources, $value, $params, FALSE, $index ); |
3354 | 3791 | return TRUE; |
3355 | 3792 | } |
@@ -3365,7 +3802,9 @@ discard block |
||
3365 | 3802 | * @return string |
3366 | 3803 | */ |
3367 | 3804 | function createRrule() { |
3368 | - if( empty( $this->rrule )) return FALSE; |
|
3805 | + if( empty( $this->rrule )) { |
|
3806 | + return FALSE; |
|
3807 | + } |
|
3369 | 3808 | return $this->_format_recur( 'RRULE', $this->rrule ); |
3370 | 3809 | } |
3371 | 3810 | /** |
@@ -3379,7 +3818,11 @@ discard block |
||
3379 | 3818 | * @return void |
3380 | 3819 | */ |
3381 | 3820 | function setRrule( $rruleset, $params=FALSE, $index=FALSE ) { |
3382 | - if( empty( $rruleset )) if( $this->getConfig( 'allowEmpty' )) $rruleset = null; else return FALSE; |
|
3821 | + if( empty( $rruleset )) { |
|
3822 | + if( $this->getConfig( 'allowEmpty' )) $rruleset = null; |
|
3823 | + } else { |
|
3824 | + return FALSE; |
|
3825 | + } |
|
3383 | 3826 | $this->_setMval( $this->rrule, $this->_setRexrule( $rruleset ), $params, FALSE, $index ); |
3384 | 3827 | return TRUE; |
3385 | 3828 | } |
@@ -3394,9 +3837,12 @@ discard block |
||
3394 | 3837 | * @return string |
3395 | 3838 | */ |
3396 | 3839 | function createSequence() { |
3397 | - if( empty( $this->sequence )) return FALSE; |
|
3398 | - if( empty( $this->sequence['value'] )) |
|
3399 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE; |
|
3840 | + if( empty( $this->sequence )) { |
|
3841 | + return FALSE; |
|
3842 | + } |
|
3843 | + if( empty( $this->sequence['value'] )) { |
|
3844 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE; |
|
3845 | + } |
|
3400 | 3846 | $attributes = $this->_createParams( $this->sequence['params'] ); |
3401 | 3847 | return $this->_createElement( 'SEQUENCE', $attributes, $this->sequence['value'] ); |
3402 | 3848 | } |
@@ -3409,8 +3855,9 @@ discard block |
||
3409 | 3855 | * @return bool |
3410 | 3856 | */ |
3411 | 3857 | function setSequence( $value=FALSE, $params=FALSE ) { |
3412 | - if( empty( $value )) |
|
3413 | - $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1; |
|
3858 | + if( empty( $value )) { |
|
3859 | + $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1; |
|
3860 | + } |
|
3414 | 3861 | $this->sequence = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3415 | 3862 | return TRUE; |
3416 | 3863 | } |
@@ -3426,9 +3873,12 @@ discard block |
||
3426 | 3873 | * @return string |
3427 | 3874 | */ |
3428 | 3875 | function createStatus() { |
3429 | - if( empty( $this->status )) return FALSE; |
|
3430 | - if( empty( $this->status['value'] )) |
|
3431 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE; |
|
3876 | + if( empty( $this->status )) { |
|
3877 | + return FALSE; |
|
3878 | + } |
|
3879 | + if( empty( $this->status['value'] )) { |
|
3880 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE; |
|
3881 | + } |
|
3432 | 3882 | $attributes = $this->_createParams( $this->status['params'] ); |
3433 | 3883 | return $this->_createElement( 'STATUS', $attributes, $this->status['value'] ); |
3434 | 3884 | } |
@@ -3442,7 +3892,11 @@ discard block |
||
3442 | 3892 | * @return bool |
3443 | 3893 | */ |
3444 | 3894 | function setStatus( $value, $params=FALSE ) { |
3445 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3895 | + if( empty( $value )) { |
|
3896 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3897 | + } else { |
|
3898 | + return FALSE; |
|
3899 | + } |
|
3446 | 3900 | $this->status = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3447 | 3901 | return TRUE; |
3448 | 3902 | } |
@@ -3458,9 +3912,12 @@ discard block |
||
3458 | 3912 | * @return string |
3459 | 3913 | */ |
3460 | 3914 | function createSummary() { |
3461 | - if( empty( $this->summary )) return FALSE; |
|
3462 | - if( empty( $this->summary['value'] )) |
|
3463 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE; |
|
3915 | + if( empty( $this->summary )) { |
|
3916 | + return FALSE; |
|
3917 | + } |
|
3918 | + if( empty( $this->summary['value'] )) { |
|
3919 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE; |
|
3920 | + } |
|
3464 | 3921 | $attributes = $this->_createParams( $this->summary['params'], array( 'ALTREP', 'LANGUAGE' )); |
3465 | 3922 | $content = $this->_strrep( $this->summary['value'] ); |
3466 | 3923 | return $this->_createElement( 'SUMMARY', $attributes, $content ); |
@@ -3475,7 +3932,11 @@ discard block |
||
3475 | 3932 | * @return bool |
3476 | 3933 | */ |
3477 | 3934 | function setSummary( $value, $params=FALSE ) { |
3478 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3935 | + if( empty( $value )) { |
|
3936 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3937 | + } else { |
|
3938 | + return FALSE; |
|
3939 | + } |
|
3479 | 3940 | $this->summary = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3480 | 3941 | return TRUE; |
3481 | 3942 | } |
@@ -3491,9 +3952,12 @@ discard block |
||
3491 | 3952 | * @return string |
3492 | 3953 | */ |
3493 | 3954 | function createTransp() { |
3494 | - if( empty( $this->transp )) return FALSE; |
|
3495 | - if( empty( $this->transp['value'] )) |
|
3496 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE; |
|
3955 | + if( empty( $this->transp )) { |
|
3956 | + return FALSE; |
|
3957 | + } |
|
3958 | + if( empty( $this->transp['value'] )) { |
|
3959 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE; |
|
3960 | + } |
|
3497 | 3961 | $attributes = $this->_createParams( $this->transp['params'] ); |
3498 | 3962 | return $this->_createElement( 'TRANSP', $attributes, $this->transp['value'] ); |
3499 | 3963 | } |
@@ -3507,7 +3971,11 @@ discard block |
||
3507 | 3971 | * @return bool |
3508 | 3972 | */ |
3509 | 3973 | function setTransp( $value, $params=FALSE ) { |
3510 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
3974 | + if( empty( $value )) { |
|
3975 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
3976 | + } else { |
|
3977 | + return FALSE; |
|
3978 | + } |
|
3511 | 3979 | $this->transp = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3512 | 3980 | return TRUE; |
3513 | 3981 | } |
@@ -3523,19 +3991,24 @@ discard block |
||
3523 | 3991 | * @return string |
3524 | 3992 | */ |
3525 | 3993 | function createTrigger() { |
3526 | - if( empty( $this->trigger )) return FALSE; |
|
3527 | - if( empty( $this->trigger['value'] )) |
|
3528 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE; |
|
3994 | + if( empty( $this->trigger )) { |
|
3995 | + return FALSE; |
|
3996 | + } |
|
3997 | + if( empty( $this->trigger['value'] )) { |
|
3998 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE; |
|
3999 | + } |
|
3529 | 4000 | $content = $attributes = null; |
3530 | 4001 | if( isset( $this->trigger['value']['year'] ) && |
3531 | 4002 | isset( $this->trigger['value']['month'] ) && |
3532 | - isset( $this->trigger['value']['day'] )) |
|
3533 | - $content .= $this->_format_date_time( $this->trigger['value'] ); |
|
3534 | - else { |
|
3535 | - if( TRUE !== $this->trigger['value']['relatedStart'] ) |
|
3536 | - $attributes .= $this->intAttrDelimiter.'RELATED=END'; |
|
3537 | - if( $this->trigger['value']['before'] ) |
|
3538 | - $content .= '-'; |
|
4003 | + isset( $this->trigger['value']['day'] )) { |
|
4004 | + $content .= $this->_format_date_time( $this->trigger['value'] ); |
|
4005 | + } else { |
|
4006 | + if( TRUE !== $this->trigger['value']['relatedStart'] ) { |
|
4007 | + $attributes .= $this->intAttrDelimiter.'RELATED=END'; |
|
4008 | + } |
|
4009 | + if( $this->trigger['value']['before'] ) { |
|
4010 | + $content .= '-'; |
|
4011 | + } |
|
3539 | 4012 | $content .= $this->_format_duration( $this->trigger['value'] ); |
3540 | 4013 | } |
3541 | 4014 | $attributes .= $this->_createParams( $this->trigger['params'] ); |
@@ -3559,28 +4032,30 @@ discard block |
||
3559 | 4032 | * @return bool |
3560 | 4033 | */ |
3561 | 4034 | function setTrigger( $year, $month=null, $day=null, $week=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $relatedStart=TRUE, $before=TRUE, $params=FALSE ) { |
3562 | - if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec )) |
|
3563 | - if( $this->getConfig( 'allowEmpty' )) { |
|
4035 | + if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec )) { |
|
4036 | + if( $this->getConfig( 'allowEmpty' )) { |
|
3564 | 4037 | $this->trigger = array( 'value' => null, 'params' => $this->_setParams( $params ) ); |
4038 | + } |
|
3565 | 4039 | return TRUE; |
4040 | + } else { |
|
4041 | + return FALSE; |
|
3566 | 4042 | } |
3567 | - else |
|
3568 | - return FALSE; |
|
3569 | 4043 | if( $this->_isArrayTimestampDate( $year )) { // timestamp |
3570 | 4044 | $params = $this->_setParams( $month ); |
3571 | 4045 | $date = $this->_timestamp2date( $year, 7 ); |
3572 | - foreach( $date as $k => $v ) |
|
3573 | - $$k = $v; |
|
3574 | - } |
|
3575 | - elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) { |
|
4046 | + foreach( $date as $k => $v ) { |
|
4047 | + $$k = $v; |
|
4048 | + } |
|
4049 | + } elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) { |
|
3576 | 4050 | $params = $this->_setParams( $month ); |
3577 | 4051 | if(!(array_key_exists( 'year', $year ) && // exclude date-time |
3578 | 4052 | array_key_exists( 'month', $year ) && |
3579 | 4053 | array_key_exists( 'day', $year ))) { // so this must be a duration |
3580 | - if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) |
|
3581 | - $relatedStart = FALSE; |
|
3582 | - else |
|
3583 | - $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE; |
|
4054 | + if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) { |
|
4055 | + $relatedStart = FALSE; |
|
4056 | + } else { |
|
4057 | + $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE; |
|
4058 | + } |
|
3584 | 4059 | $before = ( array_key_exists( 'before', $year ) && ( TRUE !== $year['before'] )) ? FALSE : TRUE; |
3585 | 4060 | } |
3586 | 4061 | $SSYY = ( array_key_exists( 'year', $year )) ? $year['year'] : null; |
@@ -3591,24 +4066,27 @@ discard block |
||
3591 | 4066 | $min = ( array_key_exists( 'min', $year )) ? $year['min'] : 0; //null; |
3592 | 4067 | $sec = ( array_key_exists( 'sec', $year )) ? $year['sec'] : 0; //null; |
3593 | 4068 | $year = $SSYY; |
3594 | - } |
|
3595 | - elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) { // duration or date in a string |
|
4069 | + } elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) { // duration or date in a string |
|
3596 | 4070 | $params = $this->_setParams( $month ); |
3597 | 4071 | if( in_array( $year{0}, array( 'P', '+', '-' ))) { // duration |
3598 | 4072 | $relatedStart = ( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) ? FALSE : TRUE; |
3599 | 4073 | $before = ( '-' == $year{0} ) ? TRUE : FALSE; |
3600 | - if( 'P' != $year{0} ) |
|
3601 | - $year = substr( $year, 1 ); |
|
4074 | + if( 'P' != $year{0} ) { |
|
4075 | + $year = substr( $year, 1 ); |
|
4076 | + } |
|
3602 | 4077 | $date = $this->_duration_string( $year); |
3603 | - } |
|
3604 | - else // date |
|
4078 | + } else { |
|
4079 | + // date |
|
3605 | 4080 | $date = $this->_date_time_string( $year, 7 ); |
4081 | + } |
|
3606 | 4082 | unset( $year, $month, $day ); |
3607 | - foreach( $date as $k => $v ) |
|
3608 | - $$k = $v; |
|
3609 | - } |
|
3610 | - else // single values in function input parameters |
|
4083 | + foreach( $date as $k => $v ) { |
|
4084 | + $$k = $v; |
|
4085 | + } |
|
4086 | + } else { |
|
4087 | + // single values in function input parameters |
|
3611 | 4088 | $params = $this->_setParams( $params ); |
4089 | + } |
|
3612 | 4090 | if( !empty( $year ) && !empty( $month ) && !empty( $day )) { // date |
3613 | 4091 | $params['VALUE'] = 'DATE-TIME'; |
3614 | 4092 | $hour = ( $hour ) ? $hour : 0; |
@@ -3623,8 +4101,7 @@ discard block |
||
3623 | 4101 | , 'sec' => $sec |
3624 | 4102 | , 'tz' => 'Z' ); |
3625 | 4103 | return TRUE; |
3626 | - } |
|
3627 | - elseif(( empty( $year ) && empty( $month )) && // duration |
|
4104 | + } elseif(( empty( $year ) && empty( $month )) && // duration |
|
3628 | 4105 | (!empty( $week ) || !empty( $day ) || !empty( $hour ) || !empty( $min ) || !empty( $sec ))) { |
3629 | 4106 | unset( $params['RELATED'] ); // set at output creation (END only) |
3630 | 4107 | unset( $params['VALUE'] ); // 'DURATION' default |
@@ -3633,11 +4110,21 @@ discard block |
||
3633 | 4110 | $before = ( FALSE !== $before ) ? TRUE : FALSE; |
3634 | 4111 | $this->trigger['value'] = array( 'relatedStart' => $relatedStart |
3635 | 4112 | , 'before' => $before ); |
3636 | - if( !empty( $week )) $this->trigger['value']['week'] = $week; |
|
3637 | - if( !empty( $day )) $this->trigger['value']['day'] = $day; |
|
3638 | - if( !empty( $hour )) $this->trigger['value']['hour'] = $hour; |
|
3639 | - if( !empty( $min )) $this->trigger['value']['min'] = $min; |
|
3640 | - if( !empty( $sec )) $this->trigger['value']['sec'] = $sec; |
|
4113 | + if( !empty( $week )) { |
|
4114 | + $this->trigger['value']['week'] = $week; |
|
4115 | + } |
|
4116 | + if( !empty( $day )) { |
|
4117 | + $this->trigger['value']['day'] = $day; |
|
4118 | + } |
|
4119 | + if( !empty( $hour )) { |
|
4120 | + $this->trigger['value']['hour'] = $hour; |
|
4121 | + } |
|
4122 | + if( !empty( $min )) { |
|
4123 | + $this->trigger['value']['min'] = $min; |
|
4124 | + } |
|
4125 | + if( !empty( $sec )) { |
|
4126 | + $this->trigger['value']['sec'] = $sec; |
|
4127 | + } |
|
3641 | 4128 | return TRUE; |
3642 | 4129 | } |
3643 | 4130 | return FALSE; |
@@ -3654,9 +4141,12 @@ discard block |
||
3654 | 4141 | * @return string |
3655 | 4142 | */ |
3656 | 4143 | function createTzid() { |
3657 | - if( empty( $this->tzid )) return FALSE; |
|
3658 | - if( empty( $this->tzid['value'] )) |
|
3659 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE; |
|
4144 | + if( empty( $this->tzid )) { |
|
4145 | + return FALSE; |
|
4146 | + } |
|
4147 | + if( empty( $this->tzid['value'] )) { |
|
4148 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE; |
|
4149 | + } |
|
3660 | 4150 | $attributes = $this->_createParams( $this->tzid['params'] ); |
3661 | 4151 | return $this->_createElement( 'TZID', $attributes, $this->_strrep( $this->tzid['value'] )); |
3662 | 4152 | } |
@@ -3670,7 +4160,11 @@ discard block |
||
3670 | 4160 | * @return bool |
3671 | 4161 | */ |
3672 | 4162 | function setTzid( $value, $params=FALSE ) { |
3673 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4163 | + if( empty( $value )) { |
|
4164 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4165 | + } else { |
|
4166 | + return FALSE; |
|
4167 | + } |
|
3674 | 4168 | $this->tzid = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3675 | 4169 | return TRUE; |
3676 | 4170 | } |
@@ -3687,14 +4181,17 @@ discard block |
||
3687 | 4181 | * @return string |
3688 | 4182 | */ |
3689 | 4183 | function createTzname() { |
3690 | - if( empty( $this->tzname )) return FALSE; |
|
4184 | + if( empty( $this->tzname )) { |
|
4185 | + return FALSE; |
|
4186 | + } |
|
3691 | 4187 | $output = null; |
3692 | 4188 | foreach( $this->tzname as $theName ) { |
3693 | 4189 | if( !empty( $theName['value'] )) { |
3694 | 4190 | $attributes = $this->_createParams( $theName['params'], array( 'LANGUAGE' )); |
3695 | 4191 | $output .= $this->_createElement( 'TZNAME', $attributes, $this->_strrep( $theName['value'] )); |
4192 | + } elseif( $this->getConfig( 'allowEmpty' )) { |
|
4193 | + $output .= $this->_createElement( 'TZNAME' ); |
|
3696 | 4194 | } |
3697 | - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'TZNAME' ); |
|
3698 | 4195 | } |
3699 | 4196 | return $output; |
3700 | 4197 | } |
@@ -3709,7 +4206,11 @@ discard block |
||
3709 | 4206 | * @return bool |
3710 | 4207 | */ |
3711 | 4208 | function setTzname( $value, $params=FALSE, $index=FALSE ) { |
3712 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4209 | + if( empty( $value )) { |
|
4210 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4211 | + } else { |
|
4212 | + return FALSE; |
|
4213 | + } |
|
3713 | 4214 | $this->_setMval( $this->tzname, $value, $params, FALSE, $index ); |
3714 | 4215 | return TRUE; |
3715 | 4216 | } |
@@ -3725,9 +4226,12 @@ discard block |
||
3725 | 4226 | * @return string |
3726 | 4227 | */ |
3727 | 4228 | function createTzoffsetfrom() { |
3728 | - if( empty( $this->tzoffsetfrom )) return FALSE; |
|
3729 | - if( empty( $this->tzoffsetfrom['value'] )) |
|
3730 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE; |
|
4229 | + if( empty( $this->tzoffsetfrom )) { |
|
4230 | + return FALSE; |
|
4231 | + } |
|
4232 | + if( empty( $this->tzoffsetfrom['value'] )) { |
|
4233 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE; |
|
4234 | + } |
|
3731 | 4235 | $attributes = $this->_createParams( $this->tzoffsetfrom['params'] ); |
3732 | 4236 | return $this->_createElement( 'TZOFFSETFROM', $attributes, $this->tzoffsetfrom['value'] ); |
3733 | 4237 | } |
@@ -3741,7 +4245,11 @@ discard block |
||
3741 | 4245 | * @return bool |
3742 | 4246 | */ |
3743 | 4247 | function setTzoffsetfrom( $value, $params=FALSE ) { |
3744 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4248 | + if( empty( $value )) { |
|
4249 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4250 | + } else { |
|
4251 | + return FALSE; |
|
4252 | + } |
|
3745 | 4253 | $this->tzoffsetfrom = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3746 | 4254 | return TRUE; |
3747 | 4255 | } |
@@ -3757,9 +4265,12 @@ discard block |
||
3757 | 4265 | * @return string |
3758 | 4266 | */ |
3759 | 4267 | function createTzoffsetto() { |
3760 | - if( empty( $this->tzoffsetto )) return FALSE; |
|
3761 | - if( empty( $this->tzoffsetto['value'] )) |
|
3762 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE; |
|
4268 | + if( empty( $this->tzoffsetto )) { |
|
4269 | + return FALSE; |
|
4270 | + } |
|
4271 | + if( empty( $this->tzoffsetto['value'] )) { |
|
4272 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE; |
|
4273 | + } |
|
3763 | 4274 | $attributes = $this->_createParams( $this->tzoffsetto['params'] ); |
3764 | 4275 | return $this->_createElement( 'TZOFFSETTO', $attributes, $this->tzoffsetto['value'] ); |
3765 | 4276 | } |
@@ -3773,7 +4284,11 @@ discard block |
||
3773 | 4284 | * @return bool |
3774 | 4285 | */ |
3775 | 4286 | function setTzoffsetto( $value, $params=FALSE ) { |
3776 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4287 | + if( empty( $value )) { |
|
4288 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4289 | + } else { |
|
4290 | + return FALSE; |
|
4291 | + } |
|
3777 | 4292 | $this->tzoffsetto = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3778 | 4293 | return TRUE; |
3779 | 4294 | } |
@@ -3789,9 +4304,12 @@ discard block |
||
3789 | 4304 | * @return string |
3790 | 4305 | */ |
3791 | 4306 | function createTzurl() { |
3792 | - if( empty( $this->tzurl )) return FALSE; |
|
3793 | - if( empty( $this->tzurl['value'] )) |
|
3794 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE; |
|
4307 | + if( empty( $this->tzurl )) { |
|
4308 | + return FALSE; |
|
4309 | + } |
|
4310 | + if( empty( $this->tzurl['value'] )) { |
|
4311 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE; |
|
4312 | + } |
|
3795 | 4313 | $attributes = $this->_createParams( $this->tzurl['params'] ); |
3796 | 4314 | return $this->_createElement( 'TZURL', $attributes, $this->tzurl['value'] ); |
3797 | 4315 | } |
@@ -3805,7 +4323,11 @@ discard block |
||
3805 | 4323 | * @return boll |
3806 | 4324 | */ |
3807 | 4325 | function setTzurl( $value, $params=FALSE ) { |
3808 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4326 | + if( empty( $value )) { |
|
4327 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4328 | + } else { |
|
4329 | + return FALSE; |
|
4330 | + } |
|
3809 | 4331 | $this->tzurl = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3810 | 4332 | return TRUE; |
3811 | 4333 | } |
@@ -3821,8 +4343,9 @@ discard block |
||
3821 | 4343 | * @return string |
3822 | 4344 | */ |
3823 | 4345 | function createUid() { |
3824 | - if( 0 >= count( $this->uid )) |
|
3825 | - $this->_makeuid(); |
|
4346 | + if( 0 >= count( $this->uid )) { |
|
4347 | + $this->_makeuid(); |
|
4348 | + } |
|
3826 | 4349 | $attributes = $this->_createParams( $this->uid['params'] ); |
3827 | 4350 | return $this->_createElement( 'UID', $attributes, $this->uid['value'] ); |
3828 | 4351 | } |
@@ -3841,8 +4364,9 @@ discard block |
||
3841 | 4364 | $end = strlen( $base ) - 1; |
3842 | 4365 | $length = 6; |
3843 | 4366 | $str = null; |
3844 | - for( $p = 0; $p < $length; $p++ ) |
|
3845 | - $unique .= $base{mt_rand( $start, $end )}; |
|
4367 | + for( $p = 0; $p < $length; $p++ ) { |
|
4368 | + $unique .= $base{mt_rand( $start, $end )}; |
|
4369 | + } |
|
3846 | 4370 | $this->uid = array( 'params' => null ); |
3847 | 4371 | $this->uid['value'] = $date.'-'.$unique.'@'.$this->getConfig( 'unique_id' ); |
3848 | 4372 | } |
@@ -3856,7 +4380,10 @@ discard block |
||
3856 | 4380 | * @return bool |
3857 | 4381 | */ |
3858 | 4382 | function setUid( $value, $params=FALSE ) { |
3859 | - if( empty( $value )) return FALSE; // no allowEmpty check here !!!! |
|
4383 | + if( empty( $value )) { |
|
4384 | + return FALSE; |
|
4385 | + } |
|
4386 | + // no allowEmpty check here !!!! |
|
3860 | 4387 | $this->uid = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3861 | 4388 | return TRUE; |
3862 | 4389 | } |
@@ -3872,9 +4399,12 @@ discard block |
||
3872 | 4399 | * @return string |
3873 | 4400 | */ |
3874 | 4401 | function createUrl() { |
3875 | - if( empty( $this->url )) return FALSE; |
|
3876 | - if( empty( $this->url['value'] )) |
|
3877 | - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE; |
|
4402 | + if( empty( $this->url )) { |
|
4403 | + return FALSE; |
|
4404 | + } |
|
4405 | + if( empty( $this->url['value'] )) { |
|
4406 | + return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE; |
|
4407 | + } |
|
3878 | 4408 | $attributes = $this->_createParams( $this->url['params'] ); |
3879 | 4409 | return $this->_createElement( 'URL', $attributes, $this->url['value'] ); |
3880 | 4410 | } |
@@ -3888,7 +4418,11 @@ discard block |
||
3888 | 4418 | * @return bool |
3889 | 4419 | */ |
3890 | 4420 | function setUrl( $value, $params=FALSE ) { |
3891 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4421 | + if( empty( $value )) { |
|
4422 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4423 | + } else { |
|
4424 | + return FALSE; |
|
4425 | + } |
|
3892 | 4426 | $this->url = array( 'value' => $value, 'params' => $this->_setParams( $params )); |
3893 | 4427 | return TRUE; |
3894 | 4428 | } |
@@ -3904,21 +4438,26 @@ discard block |
||
3904 | 4438 | * @return string |
3905 | 4439 | */ |
3906 | 4440 | function createXprop() { |
3907 | - if( empty( $this->xprop )) return FALSE; |
|
4441 | + if( empty( $this->xprop )) { |
|
4442 | + return FALSE; |
|
4443 | + } |
|
3908 | 4444 | $output = null; |
3909 | 4445 | foreach( $this->xprop as $label => $xpropPart ) { |
3910 | 4446 | if( empty( $xpropPart['value'] )) { |
3911 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $label ); |
|
4447 | + if( $this->getConfig( 'allowEmpty' )) { |
|
4448 | + $output .= $this->_createElement( $label ); |
|
4449 | + } |
|
3912 | 4450 | continue; |
3913 | 4451 | } |
3914 | 4452 | $attributes = $this->_createParams( $xpropPart['params'], array( 'LANGUAGE' )); |
3915 | 4453 | if( is_array( $xpropPart['value'] )) { |
3916 | - foreach( $xpropPart['value'] as $pix => $theXpart ) |
|
3917 | - $xpropPart['value'][$pix] = $this->_strrep( $theXpart ); |
|
4454 | + foreach( $xpropPart['value'] as $pix => $theXpart ) { |
|
4455 | + $xpropPart['value'][$pix] = $this->_strrep( $theXpart ); |
|
4456 | + } |
|
3918 | 4457 | $xpropPart['value'] = implode( ',', $xpropPart['value'] ); |
4458 | + } else { |
|
4459 | + $xpropPart['value'] = $this->_strrep( $xpropPart['value'] ); |
|
3919 | 4460 | } |
3920 | - else |
|
3921 | - $xpropPart['value'] = $this->_strrep( $xpropPart['value'] ); |
|
3922 | 4461 | $output .= $this->_createElement( $label, $attributes, $xpropPart['value'] ); |
3923 | 4462 | } |
3924 | 4463 | return $output; |
@@ -3934,12 +4473,20 @@ discard block |
||
3934 | 4473 | * @return bool |
3935 | 4474 | */ |
3936 | 4475 | function setXprop( $label, $value, $params=FALSE ) { |
3937 | - if( empty( $label )) return; |
|
3938 | - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; |
|
4476 | + if( empty( $label )) { |
|
4477 | + return; |
|
4478 | + } |
|
4479 | + if( empty( $value )) { |
|
4480 | + if( $this->getConfig( 'allowEmpty' )) $value = null; |
|
4481 | + } else { |
|
4482 | + return FALSE; |
|
4483 | + } |
|
3939 | 4484 | $xprop = array( 'value' => $value ); |
3940 | 4485 | $toolbox = new calendarComponent(); |
3941 | 4486 | $xprop['params'] = $toolbox->_setParams( $params ); |
3942 | - if( !is_array( $this->xprop )) $this->xprop = array(); |
|
4487 | + if( !is_array( $this->xprop )) { |
|
4488 | + $this->xprop = array(); |
|
4489 | + } |
|
3943 | 4490 | $this->xprop[strtoupper( $label )] = $xprop; |
3944 | 4491 | return TRUE; |
3945 | 4492 | } |
@@ -4007,30 +4554,29 @@ discard block |
||
4007 | 4554 | $attributes = null; |
4008 | 4555 | foreach( $attributes2 as $attribute ) { |
4009 | 4556 | $attrKVarr = explode( '=', $attribute ); |
4010 | - if( empty( $attrKVarr[0] )) |
|
4011 | - continue; |
|
4557 | + if( empty( $attrKVarr[0] )) { |
|
4558 | + continue; |
|
4559 | + } |
|
4012 | 4560 | if( !isset( $attrKVarr[1] )) { |
4013 | 4561 | $attrValue = $attrKVarr[0]; |
4014 | 4562 | $attrKey = null; |
4015 | - } |
|
4016 | - elseif( 2 == count( $attrKVarr)) { |
|
4563 | + } elseif( 2 == count( $attrKVarr)) { |
|
4017 | 4564 | $attrKey = strtolower( $attrKVarr[0] ); |
4018 | 4565 | $attrValue = $attrKVarr[1]; |
4019 | - } |
|
4020 | - else { |
|
4566 | + } else { |
|
4021 | 4567 | $attrKey = strtolower( $attrKVarr[0] ); |
4022 | 4568 | unset( $attrKVarr[0] ); |
4023 | 4569 | $attrValue = implode( '=', $attrKVarr ); |
4024 | 4570 | } |
4025 | 4571 | if(( 'attach' == $label ) && ( in_array( $attrKey, array( 'fmttype', 'encoding', 'value' )))) { |
4026 | 4572 | $attachInlineBinary = TRUE; |
4027 | - if( 'fmttype' == $attrKey ) |
|
4028 | - $attachfmttype = $attrKey.'='.$attrValue; |
|
4573 | + if( 'fmttype' == $attrKey ) { |
|
4574 | + $attachfmttype = $attrKey.'='.$attrValue; |
|
4575 | + } |
|
4029 | 4576 | continue; |
4030 | - } |
|
4031 | - elseif(( 'categories' == $label ) && ( 'language' == $attrKey )) |
|
4032 | - $categoriesAttrLang = $attrKey.'='.$attrValue; |
|
4033 | - else { |
|
4577 | + } elseif(( 'categories' == $label ) && ( 'language' == $attrKey )) { |
|
4578 | + $categoriesAttrLang = $attrKey.'='.$attrValue; |
|
4579 | + } else { |
|
4034 | 4580 | $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' '; |
4035 | 4581 | $attributes .= ( !empty( $attrKey )) ? $attrKey.'=' : null; |
4036 | 4582 | if(( '"' == substr( $attrValue, 0, 1 )) && ( '"' == substr( $attrValue, -1 ))) { |
@@ -4040,8 +4586,7 @@ discard block |
||
4040 | 4586 | $attributes .= '"'.htmlspecialchars( $attrValue ).'"'; |
4041 | 4587 | } |
4042 | 4588 | } |
4043 | - } |
|
4044 | - else { |
|
4589 | + } else { |
|
4045 | 4590 | $attributes = str_replace( $this->intAttrDelimiter, $this->attributeDelimiter, $attributes ); |
4046 | 4591 | } |
4047 | 4592 | } |
@@ -4063,8 +4608,7 @@ discard block |
||
4063 | 4608 | $content = $this->_createElement( 'extref', $attributes, null ); |
4064 | 4609 | $attributes = null; |
4065 | 4610 | } |
4066 | - } |
|
4067 | - elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) { |
|
4611 | + } elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) { |
|
4068 | 4612 | $content = $this->nl.$this->_createElement( 'b64bin', $attachfmttype, $content ); // max one attribute |
4069 | 4613 | } |
4070 | 4614 | $output .= $attributes; |
@@ -4108,30 +4652,30 @@ discard block |
||
4108 | 4652 | $CNattrExist = $LANGattrExist = FALSE; |
4109 | 4653 | if( is_array( $params )) { |
4110 | 4654 | foreach( $params as $paramKey => $paramValue ) { |
4111 | - if( is_int( $paramKey )) |
|
4112 | - $attr2 .= $this->intAttrDelimiter.$paramValue; |
|
4113 | - elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) { |
|
4655 | + if( is_int( $paramKey )) { |
|
4656 | + $attr2 .= $this->intAttrDelimiter.$paramValue; |
|
4657 | + } elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) { |
|
4114 | 4658 | $attrLANG .= $this->intAttrDelimiter."LANGUAGE=$paramValue"; |
4115 | 4659 | $LANGattrExist = TRUE; |
4116 | - } |
|
4117 | - elseif(( 'CN' == $paramKey ) && $CNattrKey ) { |
|
4660 | + } elseif(( 'CN' == $paramKey ) && $CNattrKey ) { |
|
4118 | 4661 | $attr1 = $this->intAttrDelimiter.'CN="'.$paramValue.'"'; |
4119 | 4662 | $CNattrExist = TRUE; |
4663 | + } elseif(( 'ALTREP' == $paramKey ) && in_array( $paramKey, $ctrKeys )) { |
|
4664 | + $attr2 .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"'; |
|
4665 | + } elseif(( 'DIR' == $paramKey ) && in_array( $paramKey, $ctrKeys )) { |
|
4666 | + $attr2 .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"'; |
|
4667 | + } elseif(( 'SENT-BY' == $paramKey ) && in_array( $paramKey, $ctrKeys )) { |
|
4668 | + $attr2 .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"'; |
|
4669 | + } else { |
|
4670 | + $attr2 .= $this->intAttrDelimiter."$paramKey=$paramValue"; |
|
4120 | 4671 | } |
4121 | - elseif(( 'ALTREP' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4122 | - $attr2 .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"'; |
|
4123 | - elseif(( 'DIR' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4124 | - $attr2 .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"'; |
|
4125 | - elseif(( 'SENT-BY' == $paramKey ) && in_array( $paramKey, $ctrKeys )) |
|
4126 | - $attr2 .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"'; |
|
4127 | - else |
|
4128 | - $attr2 .= $this->intAttrDelimiter."$paramKey=$paramValue"; |
|
4129 | 4672 | } |
4130 | 4673 | } |
4131 | 4674 | if( !$LANGattrExist ) { |
4132 | 4675 | $lang = $this->getConfig( 'language' ); |
4133 | - if(( $CNattrExist || $LANGattrKey ) && $lang ) |
|
4134 | - $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang; |
|
4676 | + if(( $CNattrExist || $LANGattrKey ) && $lang ) { |
|
4677 | + $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang; |
|
4678 | + } |
|
4135 | 4679 | } |
4136 | 4680 | return $attrLANG.$attr1.$attr2; |
4137 | 4681 | } |
@@ -4145,47 +4689,57 @@ discard block |
||
4145 | 4689 | * @return array $params, property parameters |
4146 | 4690 | */ |
4147 | 4691 | function _chkdatecfg( $theDate, & $parno, & $params ) { |
4148 | - if( isset( $params['TZID'] )) |
|
4149 | - $parno = 6; |
|
4150 | - elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )) |
|
4151 | - $parno = 3; |
|
4152 | - else { |
|
4153 | - if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] )) |
|
4154 | - $parno = 7; |
|
4692 | + if( isset( $params['TZID'] )) { |
|
4693 | + $parno = 6; |
|
4694 | + } elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )) { |
|
4695 | + $parno = 3; |
|
4696 | + } else { |
|
4697 | + if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] )) { |
|
4698 | + $parno = 7; |
|
4699 | + } |
|
4155 | 4700 | if( is_array( $theDate )) { |
4156 | - if( isset( $theDate['timestamp'] )) |
|
4157 | - $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null; |
|
4158 | - else |
|
4159 | - $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null; |
|
4701 | + if( isset( $theDate['timestamp'] )) { |
|
4702 | + $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null; |
|
4703 | + } else { |
|
4704 | + $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null; |
|
4705 | + } |
|
4160 | 4706 | if( !empty( $tzid )) { |
4161 | 4707 | $parno = 7; |
4162 | - if( !$this->_isOffset( $tzid )) |
|
4163 | - $params['TZID'] = $tzid; // save only timezone |
|
4708 | + if( !$this->_isOffset( $tzid )) { |
|
4709 | + $params['TZID'] = $tzid; |
|
4710 | + } |
|
4711 | + // save only timezone |
|
4712 | + } elseif( !$parno && ( 3 == count( $theDate )) && |
|
4713 | + ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))) { |
|
4714 | + $parno = 3; |
|
4715 | + } else { |
|
4716 | + $parno = 6; |
|
4164 | 4717 | } |
4165 | - elseif( !$parno && ( 3 == count( $theDate )) && |
|
4166 | - ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))) |
|
4167 | - $parno = 3; |
|
4168 | - else |
|
4169 | - $parno = 6; |
|
4170 | - } |
|
4171 | - else { // string |
|
4718 | + } else { // string |
|
4172 | 4719 | $date = trim( $theDate ); |
4173 | - if( 'Z' == substr( $date, -1 )) |
|
4174 | - $parno = 7; // UTC DATE-TIME |
|
4720 | + if( 'Z' == substr( $date, -1 )) { |
|
4721 | + $parno = 7; |
|
4722 | + } |
|
4723 | + // UTC DATE-TIME |
|
4175 | 4724 | elseif((( 8 == strlen( $date ) && ctype_digit( $date )) || ( 11 >= strlen( $date ))) && |
4176 | - ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' )))) |
|
4177 | - $parno = 3; // DATE |
|
4725 | + ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' )))) { |
|
4726 | + $parno = 3; |
|
4727 | + } |
|
4728 | + // DATE |
|
4178 | 4729 | $date = $this->_date_time_string( $date, $parno ); |
4179 | 4730 | if( !empty( $date['tz'] )) { |
4180 | 4731 | $parno = 7; |
4181 | - if( !$this->_isOffset( $date['tz'] )) |
|
4182 | - $params['TZID'] = $date['tz']; // save only timezone |
|
4732 | + if( !$this->_isOffset( $date['tz'] )) { |
|
4733 | + $params['TZID'] = $date['tz']; |
|
4734 | + } |
|
4735 | + // save only timezone |
|
4736 | + } elseif( empty( $parno )) { |
|
4737 | + $parno = 6; |
|
4183 | 4738 | } |
4184 | - elseif( empty( $parno )) |
|
4185 | - $parno = 6; |
|
4186 | 4739 | } |
4187 | - if( isset( $params['TZID'] )) |
|
4188 | - $parno = 6; |
|
4740 | + if( isset( $params['TZID'] )) { |
|
4741 | + $parno = 6; |
|
4742 | + } |
|
4189 | 4743 | } |
4190 | 4744 | } |
4191 | 4745 | /** |
@@ -4201,14 +4755,18 @@ discard block |
||
4201 | 4755 | */ |
4202 | 4756 | function _date2duration( $startdate=FALSE, $enddate=FALSE ) { |
4203 | 4757 | if( !$startdate || !$enddate ) { |
4204 | - if( FALSE === ( $startdate = $this->getProperty( 'dtstart' ))) |
|
4205 | - return null; |
|
4206 | - if( FALSE === ( $enddate = $this->getProperty( 'dtend' ))) // vevent/vfreebusy |
|
4758 | + if( FALSE === ( $startdate = $this->getProperty( 'dtstart' ))) { |
|
4759 | + return null; |
|
4760 | + } |
|
4761 | + if( FALSE === ( $enddate = $this->getProperty( 'dtend' ))) { |
|
4762 | + // vevent/vfreebusy |
|
4207 | 4763 | if( FALSE === ( $enddate = $this->getProperty( 'due' ))) // vtodo |
4208 | 4764 | return null; |
4765 | + } |
|
4766 | + } |
|
4767 | + if( !$startdate || !$enddate ) { |
|
4768 | + return null; |
|
4209 | 4769 | } |
4210 | - if( !$startdate || !$enddate ) |
|
4211 | - return null; |
|
4212 | 4770 | $startWdate = mktime( 0, 0, 0, $startdate['month'], $startdate['day'], $startdate['year'] ); |
4213 | 4771 | $endWdate = mktime( 0, 0, 0, $enddate['month'], $enddate['day'], $enddate['year'] ); |
4214 | 4772 | $wduration = $endWdate - $startWdate; |
@@ -4234,15 +4792,23 @@ discard block |
||
4234 | 4792 | */ |
4235 | 4793 | function _date2timestamp( $datetime, $tz=null ) { |
4236 | 4794 | $output = null; |
4237 | - if( !isset( $datetime['hour'] )) $datetime['hour'] = '0'; |
|
4238 | - if( !isset( $datetime['min'] )) $datetime['min'] = '0'; |
|
4239 | - if( !isset( $datetime['sec'] )) $datetime['sec'] = '0'; |
|
4795 | + if( !isset( $datetime['hour'] )) { |
|
4796 | + $datetime['hour'] = '0'; |
|
4797 | + } |
|
4798 | + if( !isset( $datetime['min'] )) { |
|
4799 | + $datetime['min'] = '0'; |
|
4800 | + } |
|
4801 | + if( !isset( $datetime['sec'] )) { |
|
4802 | + $datetime['sec'] = '0'; |
|
4803 | + } |
|
4240 | 4804 | foreach( $datetime as $dkey => $dvalue ) { |
4241 | - if( 'tz' != $dkey ) |
|
4242 | - $datetime[$dkey] = (integer) $dvalue; |
|
4805 | + if( 'tz' != $dkey ) { |
|
4806 | + $datetime[$dkey] = (integer) $dvalue; |
|
4807 | + } |
|
4808 | + } |
|
4809 | + if( $tz ) { |
|
4810 | + $datetime['tz'] = $tz; |
|
4243 | 4811 | } |
4244 | - if( $tz ) |
|
4245 | - $datetime['tz'] = $tz; |
|
4246 | 4812 | $offset = ( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) ? $this->_tz2offset( $datetime['tz'] ) : 0; |
4247 | 4813 | $output = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year'] ); |
4248 | 4814 | return $output; |
@@ -4299,12 +4865,15 @@ discard block |
||
4299 | 4865 | } |
4300 | 4866 | } |
4301 | 4867 | if( 3 != $parno ) { |
4302 | - if( !isset( $output['hour'] )) |
|
4303 | - $output['hour'] = 0; |
|
4304 | - if( !isset( $output['min'] )) |
|
4305 | - $output['min'] = 0; |
|
4306 | - if( !isset( $output['sec'] )) |
|
4307 | - $output['sec'] = 0; |
|
4868 | + if( !isset( $output['hour'] )) { |
|
4869 | + $output['hour'] = 0; |
|
4870 | + } |
|
4871 | + if( !isset( $output['min'] )) { |
|
4872 | + $output['min'] = 0; |
|
4873 | + } |
|
4874 | + if( !isset( $output['sec'] )) { |
|
4875 | + $output['sec'] = 0; |
|
4876 | + } |
|
4308 | 4877 | } |
4309 | 4878 | return $output; |
4310 | 4879 | } |
@@ -4324,39 +4893,37 @@ discard block |
||
4324 | 4893 | if( 'Z' == substr( $datetime, -1 )) { |
4325 | 4894 | $tz = 'Z'; |
4326 | 4895 | $datetime = trim( substr( $datetime, 0, $len )); |
4327 | - } |
|
4328 | - elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date |
|
4896 | + } elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date |
|
4329 | 4897 | ( '-' == substr( $datetime, -3, 1 )) || |
4330 | 4898 | ( ':' == substr( $datetime, -3, 1 )) || |
4331 | 4899 | ( '.' == substr( $datetime, -3, 1 ))) { |
4332 | 4900 | $continue = TRUE; |
4333 | - } |
|
4334 | - elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset |
|
4901 | + } elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset |
|
4335 | 4902 | ( ' +' == substr( $datetime, -6, 2 )) || |
4336 | 4903 | ( ' -' == substr( $datetime, -6, 2 ))) { |
4337 | 4904 | $tz = substr( $datetime, -5, 5 ); |
4338 | 4905 | $datetime = substr( $datetime, 0, ($len - 5)); |
4339 | - } |
|
4340 | - elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset |
|
4906 | + } elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset |
|
4341 | 4907 | ( ' +' == substr( $datetime, -8, 2 )) || |
4342 | 4908 | ( ' -' == substr( $datetime, -8, 2 ))) { |
4343 | 4909 | $tz = substr( $datetime, -7, 7 ); |
4344 | 4910 | $datetime = substr( $datetime, 0, ($len - 7)); |
4345 | - } |
|
4346 | - elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) { |
|
4911 | + } elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) { |
|
4347 | 4912 | $continue = TRUE; |
4348 | - } |
|
4349 | - elseif( 'T' == substr( $datetime, -7, 1 )) { |
|
4913 | + } elseif( 'T' == substr( $datetime, -7, 1 )) { |
|
4350 | 4914 | $continue = TRUE; |
4351 | - } |
|
4352 | - else { |
|
4915 | + } else { |
|
4353 | 4916 | $cx = $tx = 0; // 19970415T133000 US-Eastern |
4354 | 4917 | for( $cx = -1; $cx > ( 9 - $len ); $cx-- ) { |
4355 | - if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 ))) |
|
4356 | - break; // if exists, tz ends here.. . ? |
|
4918 | + if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 ))) { |
|
4919 | + break; |
|
4920 | + } |
|
4921 | + // if exists, tz ends here.. . ? |
|
4357 | 4922 | elseif( ctype_alpha( substr( $datetime, $cx, 1 )) || |
4358 | - ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' )))) |
|
4359 | - $tx--; // tz length counter |
|
4923 | + ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' )))) { |
|
4924 | + $tx--; |
|
4925 | + } |
|
4926 | + // tz length counter |
|
4360 | 4927 | } |
4361 | 4928 | if( 0 > $tx ) { |
4362 | 4929 | $tz = substr( $datetime, $tx ); |
@@ -4365,8 +4932,7 @@ discard block |
||
4365 | 4932 | } |
4366 | 4933 | if( 0 < substr_count( $datetime, '-' )) { |
4367 | 4934 | $datetime = str_replace( '-', '/', $datetime ); |
4368 | - } |
|
4369 | - elseif( ctype_digit( substr( $datetime, 0, 8 )) && |
|
4935 | + } elseif( ctype_digit( substr( $datetime, 0, 8 )) && |
|
4370 | 4936 | ( 'T' == substr( $datetime, 8, 1 )) && |
4371 | 4937 | ctype_digit( substr( $datetime, 9, 6 ))) { |
4372 | 4938 | $datetime = substr( $datetime, 4, 2 ) |
@@ -4386,10 +4952,10 @@ discard block |
||
4386 | 4952 | $output['hour'] = substr( $datestring, 11, 2 ); |
4387 | 4953 | $output['min'] = substr( $datestring, 14, 2 ); |
4388 | 4954 | $output['sec'] = substr( $datestring, 17, 2 ); |
4389 | - if( !empty( $tz )) |
|
4390 | - $output['tz'] = $tz; |
|
4391 | - } |
|
4392 | - elseif( 3 != $parno ) { |
|
4955 | + if( !empty( $tz )) { |
|
4956 | + $output['tz'] = $tz; |
|
4957 | + } |
|
4958 | + } elseif( 3 != $parno ) { |
|
4393 | 4959 | if(( '00' < substr( $datestring, 11, 2 )) || |
4394 | 4960 | ( '00' < substr( $datestring, 14, 2 )) || |
4395 | 4961 | ( '00' < substr( $datestring, 17, 2 ))) { |
@@ -4397,8 +4963,9 @@ discard block |
||
4397 | 4963 | $output['min'] = substr( $datestring, 14, 2 ); |
4398 | 4964 | $output['sec'] = substr( $datestring, 17, 2 ); |
4399 | 4965 | } |
4400 | - if( !empty( $tz )) |
|
4401 | - $output['tz'] = $tz; |
|
4966 | + if( !empty( $tz )) { |
|
4967 | + $output['tz'] = $tz; |
|
4968 | + } |
|
4402 | 4969 | } |
4403 | 4970 | return $output; |
4404 | 4971 | } |
@@ -4425,10 +4992,11 @@ discard block |
||
4425 | 4992 | $durseconds = $durseconds % ( 60 * 60 ); |
4426 | 4993 | $output['min'] = floor( $durseconds / ( 60 )); |
4427 | 4994 | $output['sec'] = ( $durseconds % ( 60 )); |
4428 | - } |
|
4429 | - else { |
|
4995 | + } else { |
|
4430 | 4996 | foreach( $duration as $durKey => $durValue ) { |
4431 | - if( empty( $durValue )) continue; |
|
4997 | + if( empty( $durValue )) { |
|
4998 | + continue; |
|
4999 | + } |
|
4432 | 5000 | switch ( $durKey ) { |
4433 | 5001 | case '0': |
4434 | 5002 | case 'week': |
@@ -4458,14 +5026,22 @@ discard block |
||
4458 | 5026 | return $output; |
4459 | 5027 | } |
4460 | 5028 | unset( $output['week'] ); |
4461 | - if( empty( $output['day'] )) |
|
4462 | - unset( $output['day'] ); |
|
5029 | + if( empty( $output['day'] )) { |
|
5030 | + unset( $output['day'] ); |
|
5031 | + } |
|
4463 | 5032 | if ( isset( $output['hour'] ) || isset( $output['min'] ) || isset( $output['sec'] )) { |
4464 | - if( !isset( $output['hour'] )) $output['hour'] = 0; |
|
4465 | - if( !isset( $output['min'] )) $output['min'] = 0; |
|
4466 | - if( !isset( $output['sec'] )) $output['sec'] = 0; |
|
4467 | - if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] )) |
|
4468 | - unset( $output['hour'], $output['min'], $output['sec'] ); |
|
5033 | + if( !isset( $output['hour'] )) { |
|
5034 | + $output['hour'] = 0; |
|
5035 | + } |
|
5036 | + if( !isset( $output['min'] )) { |
|
5037 | + $output['min'] = 0; |
|
5038 | + } |
|
5039 | + if( !isset( $output['sec'] )) { |
|
5040 | + $output['sec'] = 0; |
|
5041 | + } |
|
5042 | + if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] )) { |
|
5043 | + unset( $output['hour'], $output['min'], $output['sec'] ); |
|
5044 | + } |
|
4469 | 5045 | } |
4470 | 5046 | return $output; |
4471 | 5047 | } |
@@ -4482,28 +5058,32 @@ discard block |
||
4482 | 5058 | if( $startdate && $duration ) { |
4483 | 5059 | $d1 = $startdate; |
4484 | 5060 | $dur = $duration; |
4485 | - } |
|
4486 | - elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) { |
|
5061 | + } elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) { |
|
4487 | 5062 | $d1 = $this->dtstart['value']; |
4488 | 5063 | $dur = $this->duration['value']; |
5064 | + } else { |
|
5065 | + return null; |
|
4489 | 5066 | } |
4490 | - else |
|
4491 | - return null; |
|
4492 | 5067 | $dateOnly = ( isset( $d1['hour'] ) || isset( $d1['min'] ) || isset( $d1['sec'] )) ? FALSE : TRUE; |
4493 | 5068 | $d1['hour'] = ( isset( $d1['hour'] )) ? $d1['hour'] : 0; |
4494 | 5069 | $d1['min'] = ( isset( $d1['min'] )) ? $d1['min'] : 0; |
4495 | 5070 | $d1['sec'] = ( isset( $d1['sec'] )) ? $d1['sec'] : 0; |
4496 | 5071 | $dtend = mktime( $d1['hour'], $d1['min'], $d1['sec'], $d1['month'], $d1['day'], $d1['year'] ); |
4497 | - if( isset( $dur['week'] )) |
|
4498 | - $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 ); |
|
4499 | - if( isset( $dur['day'] )) |
|
4500 | - $dtend += ( $dur['day'] * 24 * 60 * 60 ); |
|
4501 | - if( isset( $dur['hour'] )) |
|
4502 | - $dtend += ( $dur['hour'] * 60 *60 ); |
|
4503 | - if( isset( $dur['min'] )) |
|
4504 | - $dtend += ( $dur['min'] * 60 ); |
|
4505 | - if( isset( $dur['sec'] )) |
|
4506 | - $dtend += $dur['sec']; |
|
5072 | + if( isset( $dur['week'] )) { |
|
5073 | + $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 ); |
|
5074 | + } |
|
5075 | + if( isset( $dur['day'] )) { |
|
5076 | + $dtend += ( $dur['day'] * 24 * 60 * 60 ); |
|
5077 | + } |
|
5078 | + if( isset( $dur['hour'] )) { |
|
5079 | + $dtend += ( $dur['hour'] * 60 *60 ); |
|
5080 | + } |
|
5081 | + if( isset( $dur['min'] )) { |
|
5082 | + $dtend += ( $dur['min'] * 60 ); |
|
5083 | + } |
|
5084 | + if( isset( $dur['sec'] )) { |
|
5085 | + $dtend += $dur['sec']; |
|
5086 | + } |
|
4507 | 5087 | $dtend2 = array(); |
4508 | 5088 | $dtend2['year'] = date('Y', $dtend ); |
4509 | 5089 | $dtend2['month'] = date('m', $dtend ); |
@@ -4511,10 +5091,12 @@ discard block |
||
4511 | 5091 | $dtend2['hour'] = date('H', $dtend ); |
4512 | 5092 | $dtend2['min'] = date('i', $dtend ); |
4513 | 5093 | $dtend2['sec'] = date('s', $dtend ); |
4514 | - if( isset( $d1['tz'] )) |
|
4515 | - $dtend2['tz'] = $d1['tz']; |
|
4516 | - if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] ))) |
|
4517 | - unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] ); |
|
5094 | + if( isset( $d1['tz'] )) { |
|
5095 | + $dtend2['tz'] = $d1['tz']; |
|
5096 | + } |
|
5097 | + if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] ))) { |
|
5098 | + unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] ); |
|
5099 | + } |
|
4518 | 5100 | return $dtend2; |
4519 | 5101 | } |
4520 | 5102 | /** |
@@ -4528,10 +5110,12 @@ discard block |
||
4528 | 5110 | function _duration_string( $duration ) { |
4529 | 5111 | $duration = (string) trim( $duration ); |
4530 | 5112 | while( 'P' != strtoupper( substr( $duration, 0, 1 ))) { |
4531 | - if( 0 < strlen( $duration )) |
|
4532 | - $duration = substr( $duration, 1 ); |
|
4533 | - else |
|
4534 | - return false; // no leading P !?!? |
|
5113 | + if( 0 < strlen( $duration )) { |
|
5114 | + $duration = substr( $duration, 1 ); |
|
5115 | + } else { |
|
5116 | + return false; |
|
5117 | + } |
|
5118 | + // no leading P !?!? |
|
4535 | 5119 | } |
4536 | 5120 | $duration = substr( $duration, 1 ); // skip P |
4537 | 5121 | $duration = str_replace ( 't', 'T', $duration ); |
@@ -4561,10 +5145,13 @@ discard block |
||
4561 | 5145 | $val = null; |
4562 | 5146 | break; |
4563 | 5147 | default: |
4564 | - if( !ctype_digit( $duration{$ix} )) |
|
4565 | - return false; // unknown duration controll character !?!? |
|
4566 | - else |
|
4567 | - $val .= $duration{$ix}; |
|
5148 | + if( !ctype_digit( $duration{$ix} )) { |
|
5149 | + return false; |
|
5150 | + } |
|
5151 | + // unknown duration controll character !?!? |
|
5152 | + else { |
|
5153 | + $val .= $duration{$ix}; |
|
5154 | + } |
|
4568 | 5155 | } |
4569 | 5156 | } |
4570 | 5157 | return $this->_duration_array( $output ); |
@@ -4583,10 +5170,12 @@ discard block |
||
4583 | 5170 | * @return int |
4584 | 5171 | */ |
4585 | 5172 | function _existRem( &$array, $expkey, $expval=FALSE, $hitVal=null, $elseVal=null, $preSet=null ) { |
4586 | - if( $preSet ) |
|
4587 | - return $preSet; |
|
4588 | - if( !is_array( $array ) || ( 0 == count( $array ))) |
|
4589 | - return $elseVal; |
|
5173 | + if( $preSet ) { |
|
5174 | + return $preSet; |
|
5175 | + } |
|
5176 | + if( !is_array( $array ) || ( 0 == count( $array ))) { |
|
5177 | + return $elseVal; |
|
5178 | + } |
|
4590 | 5179 | foreach( $array as $key => $value ) { |
4591 | 5180 | if( strtoupper( $expkey ) == strtoupper( $key )) { |
4592 | 5181 | if( !$expval || ( strtoupper( $expval ) == strtoupper( $array[$key] ))) { |
@@ -4612,13 +5201,15 @@ discard block |
||
4612 | 5201 | !isset( $datetime['day'] ) && |
4613 | 5202 | !isset( $datetime['hour'] ) && |
4614 | 5203 | !isset( $datetime['min'] ) && |
4615 | - !isset( $datetime['sec'] )) |
|
4616 | - return ; |
|
5204 | + !isset( $datetime['sec'] )) { |
|
5205 | + return ; |
|
5206 | + } |
|
4617 | 5207 | $output = null; |
4618 | 5208 | // if( !isset( $datetime['day'] )) { $o=''; foreach($datetime as $k=>$v) {if(is_array($v)) $v=implode('-',$v);$o.=" $k=>$v";} echo " day SAKNAS : $o <br />\n"; } |
4619 | 5209 | foreach( $datetime as $dkey => $dvalue ) { |
4620 | - if( 'tz' != $dkey ) |
|
4621 | - $datetime[$dkey] = (integer) $dvalue; |
|
5210 | + if( 'tz' != $dkey ) { |
|
5211 | + $datetime[$dkey] = (integer) $dvalue; |
|
5212 | + } |
|
4622 | 5213 | } |
4623 | 5214 | $output = date('Ymd', mktime( 0, 0, 0, $datetime['month'], $datetime['day'], $datetime['year'])); |
4624 | 5215 | if( isset( $datetime['hour'] ) || |
@@ -4626,29 +5217,33 @@ discard block |
||
4626 | 5217 | isset( $datetime['sec'] ) || |
4627 | 5218 | isset( $datetime['tz'] )) { |
4628 | 5219 | if( isset( $datetime['tz'] ) && |
4629 | - !isset( $datetime['hour'] )) |
|
4630 | - $datetime['hour'] = 0; |
|
5220 | + !isset( $datetime['hour'] )) { |
|
5221 | + $datetime['hour'] = 0; |
|
5222 | + } |
|
4631 | 5223 | if( isset( $datetime['hour'] ) && |
4632 | - !isset( $datetime['min'] )) |
|
4633 | - $datetime['min'] = 0; |
|
5224 | + !isset( $datetime['min'] )) { |
|
5225 | + $datetime['min'] = 0; |
|
5226 | + } |
|
4634 | 5227 | if( isset( $datetime['hour'] ) && |
4635 | 5228 | isset( $datetime['min'] ) && |
4636 | - !isset( $datetime['sec'] )) |
|
4637 | - $datetime['sec'] = 0; |
|
5229 | + !isset( $datetime['sec'] )) { |
|
5230 | + $datetime['sec'] = 0; |
|
5231 | + } |
|
4638 | 5232 | $date = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']); |
4639 | 5233 | $output .= date('\THis', $date ); |
4640 | 5234 | if( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) { |
4641 | 5235 | $datetime['tz'] = trim( $datetime['tz'] ); |
4642 | - if( 'Z' == $datetime['tz'] ) |
|
4643 | - $output .= 'Z'; |
|
5236 | + if( 'Z' == $datetime['tz'] ) { |
|
5237 | + $output .= 'Z'; |
|
5238 | + } |
|
4644 | 5239 | $offset = $this->_tz2offset( $datetime['tz'] ); |
4645 | 5240 | if( 0 != $offset ) { |
4646 | 5241 | $date = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']); |
4647 | 5242 | $output = date( 'Ymd\THis\Z', $date ); |
4648 | 5243 | } |
5244 | + } elseif( 7 == $parno ) { |
|
5245 | + $output .= 'Z'; |
|
4649 | 5246 | } |
4650 | - elseif( 7 == $parno ) |
|
4651 | - $output .= 'Z'; |
|
4652 | 5247 | } |
4653 | 5248 | return $output; |
4654 | 5249 | } |
@@ -4665,14 +5260,16 @@ discard block |
||
4665 | 5260 | !isset( $duration['day'] ) && |
4666 | 5261 | !isset( $duration['hour'] ) && |
4667 | 5262 | !isset( $duration['min'] ) && |
4668 | - !isset( $duration['sec'] )) |
|
4669 | - return; |
|
5263 | + !isset( $duration['sec'] )) { |
|
5264 | + return; |
|
5265 | + } |
|
4670 | 5266 | $output = 'P'; |
4671 | - if( isset( $duration['week'] ) && ( 0 < $duration['week'] )) |
|
4672 | - $output .= $duration['week'].'W'; |
|
4673 | - else { |
|
4674 | - if( isset($duration['day'] ) && ( 0 < $duration['day'] )) |
|
4675 | - $output .= $duration['day'].'D'; |
|
5267 | + if( isset( $duration['week'] ) && ( 0 < $duration['week'] )) { |
|
5268 | + $output .= $duration['week'].'W'; |
|
5269 | + } else { |
|
5270 | + if( isset($duration['day'] ) && ( 0 < $duration['day'] )) { |
|
5271 | + $output .= $duration['day'].'D'; |
|
5272 | + } |
|
4676 | 5273 | if(( isset( $duration['hour']) && ( 0 < $duration['hour'] )) || |
4677 | 5274 | ( isset( $duration['min']) && ( 0 < $duration['min'] )) || |
4678 | 5275 | ( isset( $duration['sec']) && ( 0 < $duration['sec'] ))) { |
@@ -4697,7 +5294,9 @@ discard block |
||
4697 | 5294 | $output = null; |
4698 | 5295 | foreach( $recurdata as $therule ) { |
4699 | 5296 | if( empty( $therule['value'] )) { |
4700 | - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $recurlabel ); |
|
5297 | + if( $this->getConfig( 'allowEmpty' )) { |
|
5298 | + $output .= $this->_createElement( $recurlabel ); |
|
5299 | + } |
|
4701 | 5300 | continue; |
4702 | 5301 | } |
4703 | 5302 | $attributes = ( isset( $therule['params'] )) ? $this->_createParams( $therule['params'] ) : null; |
@@ -4742,19 +5341,19 @@ discard block |
||
4742 | 5341 | if( is_array( $valuePart )) { |
4743 | 5342 | $content2 .= ( $bydaycnt ) ? ',' : null; |
4744 | 5343 | foreach( $valuePart as $vix2 => $valuePart2 ) { |
4745 | - if( 'DAY' != strtoupper( $vix2 )) |
|
4746 | - $content21 .= $valuePart2; |
|
4747 | - else |
|
4748 | - $content22 .= $valuePart2; |
|
5344 | + if( 'DAY' != strtoupper( $vix2 )) { |
|
5345 | + $content21 .= $valuePart2; |
|
5346 | + } else { |
|
5347 | + $content22 .= $valuePart2; |
|
5348 | + } |
|
4749 | 5349 | } |
4750 | 5350 | $content2 .= $content21.$content22; |
4751 | 5351 | $bydaycnt++; |
4752 | - } |
|
4753 | - else { |
|
5352 | + } else { |
|
4754 | 5353 | $content2 .= ( $bydaycnt ) ? ',' : null; |
4755 | - if( 'DAY' != strtoupper( $vix )) |
|
4756 | - $content21 .= $valuePart; |
|
4757 | - else { |
|
5354 | + if( 'DAY' != strtoupper( $vix )) { |
|
5355 | + $content21 .= $valuePart; |
|
5356 | + } else { |
|
4758 | 5357 | $content22 .= $valuePart; |
4759 | 5358 | $bydaycnt++; |
4760 | 5359 | } |
@@ -4798,24 +5397,32 @@ discard block |
||
4798 | 5397 | * @return bool |
4799 | 5398 | */ |
4800 | 5399 | function _isArrayDate( $input ) { |
4801 | - if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 )))) |
|
4802 | - return FALSE; |
|
4803 | - if( 7 == count( $input )) |
|
4804 | - return TRUE; |
|
4805 | - if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) |
|
4806 | - return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
4807 | - if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] )) |
|
4808 | - return FALSE; |
|
4809 | - if( in_array( 0, $input )) |
|
4810 | - return FALSE; |
|
4811 | - if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] )) |
|
4812 | - return FALSE; |
|
5400 | + if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 )))) { |
|
5401 | + return FALSE; |
|
5402 | + } |
|
5403 | + if( 7 == count( $input )) { |
|
5404 | + return TRUE; |
|
5405 | + } |
|
5406 | + if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) { |
|
5407 | + return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
5408 | + } |
|
5409 | + if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] )) { |
|
5410 | + return FALSE; |
|
5411 | + } |
|
5412 | + if( in_array( 0, $input )) { |
|
5413 | + return FALSE; |
|
5414 | + } |
|
5415 | + if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] )) { |
|
5416 | + return FALSE; |
|
5417 | + } |
|
4813 | 5418 | if(( isset( $input[0] ) && isset( $input[1] ) && isset( $input[2] )) && |
4814 | - checkdate( (int) $input[1], (int) $input[2], (int) $input[0] )) |
|
4815 | - return TRUE; |
|
5419 | + checkdate( (int) $input[1], (int) $input[2], (int) $input[0] )) { |
|
5420 | + return TRUE; |
|
5421 | + } |
|
4816 | 5422 | $input = $this->_date_time_string( $input[1].'/'.$input[2].'/'.$input[0], 3 ); // m - d - Y |
4817 | - if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) |
|
4818 | - return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
5423 | + if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) { |
|
5424 | + return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); |
|
5425 | + } |
|
4819 | 5426 | return FALSE; |
4820 | 5427 | } |
4821 | 5428 | /** |
@@ -4839,16 +5446,17 @@ discard block |
||
4839 | 5446 | */ |
4840 | 5447 | function _isOffset( $input ) { |
4841 | 5448 | $input = trim( (string) $input ); |
4842 | - if( 'Z' == substr( $input, -1 )) |
|
4843 | - return TRUE; |
|
4844 | - elseif(( 5 <= strlen( $input )) && |
|
5449 | + if( 'Z' == substr( $input, -1 )) { |
|
5450 | + return TRUE; |
|
5451 | + } elseif(( 5 <= strlen( $input )) && |
|
4845 | 5452 | ( in_array( substr( $input, -5, 1 ), array( '+', '-' ))) && |
4846 | - ( '0000' < substr( $input, -4 )) && ( '9999' >= substr( $input, -4 ))) |
|
4847 | - return TRUE; |
|
4848 | - elseif(( 7 <= strlen( $input )) && |
|
5453 | + ( '0000' < substr( $input, -4 )) && ( '9999' >= substr( $input, -4 ))) { |
|
5454 | + return TRUE; |
|
5455 | + } elseif(( 7 <= strlen( $input )) && |
|
4849 | 5456 | ( in_array( substr( $input, -7, 1 ), array( '+', '-' ))) && |
4850 | - ( '000000' < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 ))) |
|
4851 | - return TRUE; |
|
5457 | + ( '000000' < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 ))) { |
|
5458 | + return TRUE; |
|
5459 | + } |
|
4852 | 5460 | return FALSE; |
4853 | 5461 | |
4854 | 5462 | } |
@@ -4861,14 +5469,29 @@ discard block |
||
4861 | 5469 | * @return bool |
4862 | 5470 | */ |
4863 | 5471 | function _notExistProp( $propName ) { |
4864 | - if( empty( $propName )) return FALSE; // when deleting x-prop, an empty propName may be used=allowed |
|
5472 | + if( empty( $propName )) { |
|
5473 | + return FALSE; |
|
5474 | + } |
|
5475 | + // when deleting x-prop, an empty propName may be used=allowed |
|
4865 | 5476 | $propName = strtolower( $propName ); |
4866 | - if( 'last-modified' == $propName ) { if( !isset( $this->lastmodified )) return TRUE; } |
|
4867 | - elseif( 'percent-complete' == $propName ) { if( !isset( $this->percentcomplete )) return TRUE; } |
|
4868 | - elseif( 'recurrence-id' == $propName ) { if( !isset( $this->recurrenceid )) return TRUE; } |
|
4869 | - elseif( 'related-to' == $propName ) { if( !isset( $this->relatedto )) return TRUE; } |
|
4870 | - elseif( 'request-status' == $propName ) { if( !isset( $this->requeststatus )) return TRUE; } |
|
4871 | - elseif(( 'x-' != substr($propName,0,2)) && !isset( $this->$propName )) return TRUE; |
|
5477 | + if( 'last-modified' == $propName ) { if( !isset( $this->lastmodified )) { |
|
5478 | + return TRUE; |
|
5479 | + } |
|
5480 | + } elseif( 'percent-complete' == $propName ) { if( !isset( $this->percentcomplete )) { |
|
5481 | + return TRUE; |
|
5482 | + } |
|
5483 | + } elseif( 'recurrence-id' == $propName ) { if( !isset( $this->recurrenceid )) { |
|
5484 | + return TRUE; |
|
5485 | + } |
|
5486 | + } elseif( 'related-to' == $propName ) { if( !isset( $this->relatedto )) { |
|
5487 | + return TRUE; |
|
5488 | + } |
|
5489 | + } elseif( 'request-status' == $propName ) { if( !isset( $this->requeststatus )) { |
|
5490 | + return TRUE; |
|
5491 | + } |
|
5492 | + } elseif(( 'x-' != substr($propName,0,2)) && !isset( $this->$propName )) { |
|
5493 | + return TRUE; |
|
5494 | + } |
|
4872 | 5495 | return FALSE; |
4873 | 5496 | } |
4874 | 5497 | /** |
@@ -4887,7 +5510,9 @@ discard block |
||
4887 | 5510 | * @todo BYHOUR, BYMINUTE, BYSECOND, ev. BYSETPOS due to ambiguity, WEEKLY at year end/start |
4888 | 5511 | */ |
4889 | 5512 | function _recur2date( & $result, $recur, $wdate, $startdate, $enddate=FALSE ) { |
4890 | - foreach( $wdate as $k => $v ) if( ctype_digit( $v )) $wdate[$k] = (int) $v; |
|
5513 | + foreach( $wdate as $k => $v ) { |
|
5514 | + if( ctype_digit( $v )) $wdate[$k] = (int) $v; |
|
5515 | + } |
|
4891 | 5516 | $wdatets = $this->_date2timestamp( $wdate ); |
4892 | 5517 | $startdatets = $this->_date2timestamp( $startdate ); |
4893 | 5518 | if( !$enddate ) { |
@@ -4896,43 +5521,54 @@ discard block |
||
4896 | 5521 | // echo "recur __in_ ".implode('-',$startdate)." period start ".implode('-',$wdate)." period end ".implode('-',$enddate)."<br />\n";print_r($recur);echo "<br />\n";//test### |
4897 | 5522 | } |
4898 | 5523 | $endDatets = $this->_date2timestamp( $enddate ); // fix break |
4899 | - if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] )) |
|
4900 | - $recur['UNTIL'] = $enddate; // create break |
|
5524 | + if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] )) { |
|
5525 | + $recur['UNTIL'] = $enddate; |
|
5526 | + } |
|
5527 | + // create break |
|
4901 | 5528 | if( isset( $recur['UNTIL'] )) { |
4902 | 5529 | $tdatets = $this->_date2timestamp( $recur['UNTIL'] ); |
4903 | 5530 | if( $endDatets > $tdatets ) { |
4904 | 5531 | $endDatets = $tdatets; // emergency break |
4905 | 5532 | $enddate = $this->_timestamp2date( $endDatets, 6 ); |
5533 | + } else { |
|
5534 | + $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 ); |
|
4906 | 5535 | } |
4907 | - else |
|
4908 | - $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 ); |
|
4909 | 5536 | } |
4910 | 5537 | if( $wdatets > $endDatets ) { |
4911 | 5538 | //echo "recur out of date ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test |
4912 | 5539 | return array(); // nothing to do.. . |
4913 | 5540 | } |
4914 | - if( !isset( $recur['FREQ'] )) // "MUST be specified.. ." |
|
4915 | - $recur['FREQ'] = 'DAILY'; // ?? |
|
5541 | + if( !isset( $recur['FREQ'] )) { |
|
5542 | + // "MUST be specified.. ." |
|
5543 | + $recur['FREQ'] = 'DAILY'; |
|
5544 | + } |
|
5545 | + // ?? |
|
4916 | 5546 | $wkst = ( isset( $recur['WKST'] ) && ( 'SU' == $recur['WKST'] )) ? 24*60*60 : 0; // ?? |
4917 | - if( !isset( $recur['INTERVAL'] )) |
|
4918 | - $recur['INTERVAL'] = 1; |
|
5547 | + if( !isset( $recur['INTERVAL'] )) { |
|
5548 | + $recur['INTERVAL'] = 1; |
|
5549 | + } |
|
4919 | 5550 | $countcnt = ( !isset( $recur['BYSETPOS'] )) ? 1 : 0; // DTSTART counts as the first occurrence |
4920 | 5551 | /* find out how to step up dates and set index for interval count */ |
4921 | 5552 | $step = array(); |
4922 | - if( 'YEARLY' == $recur['FREQ'] ) |
|
4923 | - $step['year'] = 1; |
|
4924 | - elseif( 'MONTHLY' == $recur['FREQ'] ) |
|
4925 | - $step['month'] = 1; |
|
4926 | - elseif( 'WEEKLY' == $recur['FREQ'] ) |
|
4927 | - $step['day'] = 7; |
|
4928 | - else |
|
4929 | - $step['day'] = 1; |
|
4930 | - if( isset( $step['year'] ) && isset( $recur['BYMONTH'] )) |
|
4931 | - $step = array( 'month' => 1 ); |
|
4932 | - if( empty( $step ) && isset( $recur['BYWEEKNO'] )) // ?? |
|
5553 | + if( 'YEARLY' == $recur['FREQ'] ) { |
|
5554 | + $step['year'] = 1; |
|
5555 | + } elseif( 'MONTHLY' == $recur['FREQ'] ) { |
|
5556 | + $step['month'] = 1; |
|
5557 | + } elseif( 'WEEKLY' == $recur['FREQ'] ) { |
|
5558 | + $step['day'] = 7; |
|
5559 | + } else { |
|
5560 | + $step['day'] = 1; |
|
5561 | + } |
|
5562 | + if( isset( $step['year'] ) && isset( $recur['BYMONTH'] )) { |
|
5563 | + $step = array( 'month' => 1 ); |
|
5564 | + } |
|
5565 | + if( empty( $step ) && isset( $recur['BYWEEKNO'] )) { |
|
5566 | + // ?? |
|
4933 | 5567 | $step = array( 'day' => 7 ); |
4934 | - if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] )) |
|
4935 | - $step = array( 'day' => 1 ); |
|
5568 | + } |
|
5569 | + if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] )) { |
|
5570 | + $step = array( 'day' => 1 ); |
|
5571 | + } |
|
4936 | 5572 | $intervalarr = array(); |
4937 | 5573 | if( 1 < $recur['INTERVAL'] ) { |
4938 | 5574 | $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst ); |
@@ -4945,11 +5581,12 @@ discard block |
||
4945 | 5581 | $bysetposMold = $wdate['month']; |
4946 | 5582 | $bysetposDold = $wdate['day']; |
4947 | 5583 | if( is_array( $recur['BYSETPOS'] )) { |
4948 | - foreach( $recur['BYSETPOS'] as $bix => $bval ) |
|
4949 | - $recur['BYSETPOS'][$bix] = (int) $bval; |
|
5584 | + foreach( $recur['BYSETPOS'] as $bix => $bval ) { |
|
5585 | + $recur['BYSETPOS'][$bix] = (int) $bval; |
|
5586 | + } |
|
5587 | + } else { |
|
5588 | + $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] ); |
|
4950 | 5589 | } |
4951 | - else |
|
4952 | - $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] ); |
|
4953 | 5590 | $this->_stepdate( $enddate, $endDatets, $step); // make sure to count whole last period |
4954 | 5591 | } |
4955 | 5592 | $this->_stepdate( $wdate, $wdatets, $step); |
@@ -4958,10 +5595,12 @@ discard block |
||
4958 | 5595 | /* MAIN LOOP */ |
4959 | 5596 | // echo "recur start ".implode('-',$wdate)." end ".implode('-',$enddate)."<br />\n";//test |
4960 | 5597 | while( TRUE ) { |
4961 | - if( isset( $endDatets ) && ( $wdatets > $endDatets )) |
|
4962 | - break; |
|
4963 | - if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) |
|
4964 | - break; |
|
5598 | + if( isset( $endDatets ) && ( $wdatets > $endDatets )) { |
|
5599 | + break; |
|
5600 | + } |
|
5601 | + if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) { |
|
5602 | + break; |
|
5603 | + } |
|
4965 | 5604 | if( $year_old != $wdate['year'] ) { |
4966 | 5605 | $year_old = $wdate['year']; |
4967 | 5606 | $daycnts = array(); |
@@ -4970,8 +5609,9 @@ discard block |
||
4970 | 5609 | for( $m = 1; $m <= 12; $m++ ) { // count up and update up-counters |
4971 | 5610 | $daycnts[$m] = array(); |
4972 | 5611 | $weekdaycnt = array(); |
4973 | - foreach( $daynames as $dn ) |
|
4974 | - $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
|
5612 | + foreach( $daynames as $dn ) { |
|
5613 | + $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
|
5614 | + } |
|
4975 | 5615 | $mcnt = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] )); |
4976 | 5616 | for( $d = 1; $d <= $mcnt; $d++ ) { |
4977 | 5617 | $daycnts[$m][$d] = array(); |
@@ -4988,8 +5628,9 @@ discard block |
||
4988 | 5628 | $yeardaycnt[$day]++; |
4989 | 5629 | $daycnts[$m][$d]['yeardayno_up'] = $yeardaycnt[$day]; |
4990 | 5630 | } |
4991 | - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) |
|
4992 | - $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year'])); |
|
5631 | + if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) { |
|
5632 | + $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year'])); |
|
5633 | + } |
|
4993 | 5634 | } |
4994 | 5635 | } |
4995 | 5636 | $daycnt = 0; |
@@ -4997,9 +5638,9 @@ discard block |
||
4997 | 5638 | if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) { |
4998 | 5639 | $weekno = null; |
4999 | 5640 | for( $d=31; $d > 25; $d-- ) { // get last weekno for year |
5000 | - if( !$weekno ) |
|
5001 | - $weekno = $daycnts[12][$d]['weekno_up']; |
|
5002 | - elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) { |
|
5641 | + if( !$weekno ) { |
|
5642 | + $weekno = $daycnts[12][$d]['weekno_up']; |
|
5643 | + } elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) { |
|
5003 | 5644 | $weekno = $daycnts[12][$d]['weekno_up']; |
5004 | 5645 | break; |
5005 | 5646 | } |
@@ -5007,8 +5648,9 @@ discard block |
||
5007 | 5648 | } |
5008 | 5649 | for( $m = 12; $m > 0; $m-- ) { // count down and update down-counters |
5009 | 5650 | $weekdaycnt = array(); |
5010 | - foreach( $daynames as $dn ) |
|
5011 | - $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
|
5651 | + foreach( $daynames as $dn ) { |
|
5652 | + $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; |
|
5653 | + } |
|
5012 | 5654 | $monthcnt = 0; |
5013 | 5655 | $mcnt = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] )); |
5014 | 5656 | for( $d = $mcnt; $d > 0; $d-- ) { |
@@ -5027,8 +5669,9 @@ discard block |
||
5027 | 5669 | $yeardaycnt[$day] -= 1; |
5028 | 5670 | $daycnts[$m][$d]['yeardayno_down'] = $yeardaycnt[$day]; |
5029 | 5671 | } |
5030 | - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) |
|
5031 | - $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1); |
|
5672 | + if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) { |
|
5673 | + $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1); |
|
5674 | + } |
|
5032 | 5675 | } |
5033 | 5676 | } |
5034 | 5677 | } |
@@ -5039,36 +5682,42 @@ discard block |
||
5039 | 5682 | /* check interval */ |
5040 | 5683 | $currentKey = array_keys( $intervalarr ); |
5041 | 5684 | $currentKey = end( $currentKey ); // get last index |
5042 | - if( $currentKey != $intervalix ) |
|
5043 | - $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 )); |
|
5685 | + if( $currentKey != $intervalix ) { |
|
5686 | + $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 )); |
|
5687 | + } |
|
5044 | 5688 | if(( $recur['INTERVAL'] != $intervalarr[$intervalix] ) && |
5045 | 5689 | ( 0 != $intervalarr[$intervalix] )) { |
5046 | 5690 | /* step up date */ |
5047 | 5691 | //echo "skip: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test |
5048 | 5692 | $this->_stepdate( $wdate, $wdatets, $step); |
5049 | 5693 | continue; |
5050 | - } |
|
5051 | - else // continue within the selected interval |
|
5694 | + } else { |
|
5695 | + // continue within the selected interval |
|
5052 | 5696 | $intervalarr[$intervalix] = 0; |
5697 | + } |
|
5053 | 5698 | //echo "cont: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test |
5054 | 5699 | } |
5055 | 5700 | $updateOK = TRUE; |
5056 | - if( $updateOK && isset( $recur['BYMONTH'] )) |
|
5057 | - $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH'] |
|
5701 | + if( $updateOK && isset( $recur['BYMONTH'] )) { |
|
5702 | + $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH'] |
|
5058 | 5703 | , $wdate['month'] |
5059 | 5704 | ,($wdate['month'] - 13)); |
5060 | - if( $updateOK && isset( $recur['BYWEEKNO'] )) |
|
5061 | - $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO'] |
|
5705 | + } |
|
5706 | + if( $updateOK && isset( $recur['BYWEEKNO'] )) { |
|
5707 | + $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO'] |
|
5062 | 5708 | , $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] |
5063 | 5709 | , $daycnts[$wdate['month']][$wdate['day']]['weekno_down'] ); |
5064 | - if( $updateOK && isset( $recur['BYYEARDAY'] )) |
|
5065 | - $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY'] |
|
5710 | + } |
|
5711 | + if( $updateOK && isset( $recur['BYYEARDAY'] )) { |
|
5712 | + $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY'] |
|
5066 | 5713 | , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_up'] |
5067 | 5714 | , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down'] ); |
5068 | - if( $updateOK && isset( $recur['BYMONTHDAY'] )) |
|
5069 | - $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY'] |
|
5715 | + } |
|
5716 | + if( $updateOK && isset( $recur['BYMONTHDAY'] )) { |
|
5717 | + $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY'] |
|
5070 | 5718 | , $wdate['day'] |
5071 | 5719 | , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down'] ); |
5720 | + } |
|
5072 | 5721 | //echo "efter BYMONTHDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n";//test### |
5073 | 5722 | if( $updateOK && isset( $recur['BYDAY'] )) { |
5074 | 5723 | $updateOK = FALSE; |
@@ -5076,42 +5725,45 @@ discard block |
||
5076 | 5725 | $d = $wdate['day']; |
5077 | 5726 | if( isset( $recur['BYDAY']['DAY'] )) { // single day, opt with year/month day order no |
5078 | 5727 | $daynoexists = $daynosw = $daynamesw = FALSE; |
5079 | - if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] ) |
|
5080 | - $daynamesw = TRUE; |
|
5728 | + if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] ) { |
|
5729 | + $daynamesw = TRUE; |
|
5730 | + } |
|
5081 | 5731 | if( isset( $recur['BYDAY'][0] )) { |
5082 | 5732 | $daynoexists = TRUE; |
5083 | - if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] )) |
|
5084 | - $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5733 | + if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] )) { |
|
5734 | + $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5085 | 5735 | , $daycnts[$m][$d]['monthdayno_up'] |
5086 | 5736 | , $daycnts[$m][$d]['monthdayno_down'] ); |
5087 | - elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) |
|
5088 | - $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5737 | + } elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) { |
|
5738 | + $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0] |
|
5089 | 5739 | , $daycnts[$m][$d]['yeardayno_up'] |
5090 | 5740 | , $daycnts[$m][$d]['yeardayno_down'] ); |
5741 | + } |
|
5091 | 5742 | } |
5092 | 5743 | if(( $daynoexists && $daynosw && $daynamesw ) || |
5093 | 5744 | ( !$daynoexists && !$daynosw && $daynamesw )) { |
5094 | 5745 | $updateOK = TRUE; |
5095 | 5746 | } |
5096 | 5747 | //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ### |
5097 | - } |
|
5098 | - else { |
|
5748 | + } else { |
|
5099 | 5749 | foreach( $recur['BYDAY'] as $bydayvalue ) { |
5100 | 5750 | $daynoexists = $daynosw = $daynamesw = FALSE; |
5101 | 5751 | if( isset( $bydayvalue['DAY'] ) && |
5102 | - ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] )) |
|
5103 | - $daynamesw = TRUE; |
|
5752 | + ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] )) { |
|
5753 | + $daynamesw = TRUE; |
|
5754 | + } |
|
5104 | 5755 | if( isset( $bydayvalue[0] )) { |
5105 | 5756 | $daynoexists = TRUE; |
5106 | 5757 | if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || |
5107 | - isset( $recur['BYMONTH'] )) |
|
5108 | - $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5758 | + isset( $recur['BYMONTH'] )) { |
|
5759 | + $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5109 | 5760 | , $daycnts[$m][$d]['monthdayno_up'] |
5110 | 5761 | , $daycnts[$m][$d]['monthdayno_down'] ); |
5111 | - elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) |
|
5112 | - $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5762 | + } elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) { |
|
5763 | + $daynosw = $this->_recurBYcntcheck( $bydayvalue['0'] |
|
5113 | 5764 | , $daycnts[$m][$d]['yeardayno_up'] |
5114 | 5765 | , $daycnts[$m][$d]['yeardayno_down'] ); |
5766 | + } |
|
5115 | 5767 | } |
5116 | 5768 | //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ### |
5117 | 5769 | if(( $daynoexists && $daynosw && $daynamesw ) || |
@@ -5128,12 +5780,12 @@ discard block |
||
5128 | 5780 | if( isset( $recur['BYSETPOS'] ) && |
5129 | 5781 | ( in_array( $recur['FREQ'], array( 'YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY' )))) { |
5130 | 5782 | if( isset( $recur['WEEKLY'] )) { |
5131 | - if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] ) |
|
5132 | - $bysetposw1[] = $wdatets; |
|
5133 | - else |
|
5134 | - $bysetposw2[] = $wdatets; |
|
5135 | - } |
|
5136 | - else { |
|
5783 | + if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] ) { |
|
5784 | + $bysetposw1[] = $wdatets; |
|
5785 | + } else { |
|
5786 | + $bysetposw2[] = $wdatets; |
|
5787 | + } |
|
5788 | + } else { |
|
5137 | 5789 | if(( isset( $recur['FREQ'] ) && ( 'YEARLY' == $recur['FREQ'] ) && |
5138 | 5790 | ( $bysetposYold == $wdate['year'] )) || |
5139 | 5791 | ( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] ) && |
@@ -5142,13 +5794,13 @@ discard block |
||
5142 | 5794 | ( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] ) && |
5143 | 5795 | (( $bysetposYold == $wdate['year'] ) && |
5144 | 5796 | ( $bysetposMold == $wdate['month']) && |
5145 | - ( $bysetposDold == $wdate['sday'] )))) |
|
5146 | - $bysetposymd1[] = $wdatets; |
|
5147 | - else |
|
5148 | - $bysetposymd2[] = $wdatets; |
|
5797 | + ( $bysetposDold == $wdate['sday'] )))) { |
|
5798 | + $bysetposymd1[] = $wdatets; |
|
5799 | + } else { |
|
5800 | + $bysetposymd2[] = $wdatets; |
|
5801 | + } |
|
5149 | 5802 | } |
5150 | - } |
|
5151 | - else { |
|
5803 | + } else { |
|
5152 | 5804 | /* update result array if BYSETPOS is set */ |
5153 | 5805 | $countcnt++; |
5154 | 5806 | if( $startdatets <= $wdatets ) { // only output within period |
@@ -5168,21 +5820,18 @@ discard block |
||
5168 | 5820 | ( $bysetposYold != $wdate['year'] )) { |
5169 | 5821 | $bysetpos = TRUE; |
5170 | 5822 | $bysetposYold = $wdate['year']; |
5171 | - } |
|
5172 | - elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] && |
|
5823 | + } elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] && |
|
5173 | 5824 | (( $bysetposYold != $wdate['year'] ) || ( $bysetposMold != $wdate['month'] )))) { |
5174 | 5825 | $bysetpos = TRUE; |
5175 | 5826 | $bysetposYold = $wdate['year']; |
5176 | 5827 | $bysetposMold = $wdate['month']; |
5177 | - } |
|
5178 | - elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY' == $recur['FREQ'] )) { |
|
5828 | + } elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY' == $recur['FREQ'] )) { |
|
5179 | 5829 | $weekno = (int) date( 'W', mktime( 0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year'])); |
5180 | 5830 | if( $bysetposWold != $weekno ) { |
5181 | 5831 | $bysetposWold = $weekno; |
5182 | 5832 | $bysetpos = TRUE; |
5183 | 5833 | } |
5184 | - } |
|
5185 | - elseif( isset( $recur['FREQ'] ) && ( 'DAILY' == $recur['FREQ'] ) && |
|
5834 | + } elseif( isset( $recur['FREQ'] ) && ( 'DAILY' == $recur['FREQ'] ) && |
|
5186 | 5835 | (( $bysetposYold != $wdate['year'] ) || |
5187 | 5836 | ( $bysetposMold != $wdate['month'] ) || |
5188 | 5837 | ( $bysetposDold != $wdate['sday'] ))) { |
@@ -5195,14 +5844,15 @@ discard block |
||
5195 | 5844 | if( isset( $recur['BYWEEKNO'] )) { |
5196 | 5845 | $bysetposarr1 = & $bysetposw1; |
5197 | 5846 | $bysetposarr2 = & $bysetposw2; |
5198 | - } |
|
5199 | - else { |
|
5847 | + } else { |
|
5200 | 5848 | $bysetposarr1 = & $bysetposymd1; |
5201 | 5849 | $bysetposarr2 = & $bysetposymd2; |
5202 | 5850 | } |
5203 | 5851 | foreach( $recur['BYSETPOS'] as $ix ) { |
5204 | - if( 0 > $ix ) // both positive and negative BYSETPOS allowed |
|
5852 | + if( 0 > $ix ) { |
|
5853 | + // both positive and negative BYSETPOS allowed |
|
5205 | 5854 | $ix = ( count( $bysetposarr1 ) + $ix + 1); |
5855 | + } |
|
5206 | 5856 | $ix--; |
5207 | 5857 | if( isset( $bysetposarr1[$ix] )) { |
5208 | 5858 | if( $startdatets <= $bysetposarr1[$ix] ) { // only output within period |
@@ -5211,8 +5861,9 @@ discard block |
||
5211 | 5861 | } |
5212 | 5862 | $countcnt++; |
5213 | 5863 | } |
5214 | - if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) |
|
5215 | - break; |
|
5864 | + if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) { |
|
5865 | + break; |
|
5866 | + } |
|
5216 | 5867 | } |
5217 | 5868 | $bysetposarr1 = $bysetposarr2; |
5218 | 5869 | $bysetposarr2 = array(); |
@@ -5222,12 +5873,13 @@ discard block |
||
5222 | 5873 | } |
5223 | 5874 | function _recurBYcntcheck( $BYvalue, $upValue, $downValue ) { |
5224 | 5875 | if( is_array( $BYvalue ) && |
5225 | - ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue ))) |
|
5226 | - return TRUE; |
|
5227 | - elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue )) |
|
5228 | - return TRUE; |
|
5229 | - else |
|
5230 | - return FALSE; |
|
5876 | + ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue ))) { |
|
5877 | + return TRUE; |
|
5878 | + } elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue )) { |
|
5879 | + return TRUE; |
|
5880 | + } else { |
|
5881 | + return FALSE; |
|
5882 | + } |
|
5231 | 5883 | } |
5232 | 5884 | function _recurIntervalIx( $freq, $date, $wkst ) { |
5233 | 5885 | /* create interval index */ |
@@ -5259,21 +5911,27 @@ discard block |
||
5259 | 5911 | */ |
5260 | 5912 | function _setRexrule( $rexrule ) { |
5261 | 5913 | $input = array(); |
5262 | - if( empty( $rexrule )) |
|
5263 | - return $input; |
|
5914 | + if( empty( $rexrule )) { |
|
5915 | + return $input; |
|
5916 | + } |
|
5264 | 5917 | foreach( $rexrule as $rexrulelabel => $rexrulevalue ) { |
5265 | 5918 | $rexrulelabel = strtoupper( $rexrulelabel ); |
5266 | - if( 'UNTIL' != $rexrulelabel ) |
|
5267 | - $input[$rexrulelabel] = $rexrulevalue; |
|
5268 | - else { |
|
5269 | - if( $this->_isArrayTimestampDate( $rexrulevalue )) // timestamp date |
|
5919 | + if( 'UNTIL' != $rexrulelabel ) { |
|
5920 | + $input[$rexrulelabel] = $rexrulevalue; |
|
5921 | + } else { |
|
5922 | + if( $this->_isArrayTimestampDate( $rexrulevalue )) { |
|
5923 | + // timestamp date |
|
5270 | 5924 | $input[$rexrulelabel] = $this->_timestamp2date( $rexrulevalue, 6 ); |
5271 | - elseif( $this->_isArrayDate( $rexrulevalue )) // date-time |
|
5925 | + } elseif( $this->_isArrayDate( $rexrulevalue )) { |
|
5926 | + // date-time |
|
5272 | 5927 | $input[$rexrulelabel] = $this->_date_time_array( $rexrulevalue, 6 ); |
5273 | - elseif( 8 <= strlen( trim( $rexrulevalue ))) // ex. 2006-08-03 10:12:18 |
|
5928 | + } elseif( 8 <= strlen( trim( $rexrulevalue ))) { |
|
5929 | + // ex. 2006-08-03 10:12:18 |
|
5274 | 5930 | $input[$rexrulelabel] = $this->_date_time_string( $rexrulevalue ); |
5275 | - if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] )) |
|
5276 | - $input[$rexrulelabel]['tz'] = 'Z'; |
|
5931 | + } |
|
5932 | + if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] )) { |
|
5933 | + $input[$rexrulelabel]['tz'] = 'Z'; |
|
5934 | + } |
|
5277 | 5935 | } |
5278 | 5936 | } |
5279 | 5937 | return $input; |
@@ -5297,7 +5955,9 @@ discard block |
||
5297 | 5955 | $input = $parno = null; |
5298 | 5956 | $localtime = (( 'dtstart' == $caller ) && in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE; |
5299 | 5957 | if( $this->_isArrayDate( $year )) { |
5300 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5958 | + if( $localtime ) { |
|
5959 | + unset ( $month['VALUE'], $month['TZID'] ); |
|
5960 | + } |
|
5301 | 5961 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
5302 | 5962 | if( isset( $input['params']['TZID'] )) { |
5303 | 5963 | $input['params']['VALUE'] = 'DATE-TIME'; |
@@ -5307,9 +5967,10 @@ discard block |
||
5307 | 5967 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval ); |
5308 | 5968 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, count( $year ), $parno ); |
5309 | 5969 | $input['value'] = $this->_date_time_array( $year, $parno ); |
5310 | - } |
|
5311 | - elseif( $this->_isArrayTimestampDate( $year )) { |
|
5312 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5970 | + } elseif( $this->_isArrayTimestampDate( $year )) { |
|
5971 | + if( $localtime ) { |
|
5972 | + unset ( $month['VALUE'], $month['TZID'] ); |
|
5973 | + } |
|
5313 | 5974 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
5314 | 5975 | if( isset( $input['params']['TZID'] )) { |
5315 | 5976 | $input['params']['VALUE'] = 'DATE-TIME'; |
@@ -5319,9 +5980,10 @@ discard block |
||
5319 | 5980 | $hitval = ( isset( $year['tz'] )) ? 7 : 6; |
5320 | 5981 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno ); |
5321 | 5982 | $input['value'] = $this->_timestamp2date( $year, $parno ); |
5322 | - } |
|
5323 | - elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
5324 | - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); |
|
5983 | + } elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
5984 | + if( $localtime ) { |
|
5985 | + unset ( $month['VALUE'], $month['TZID'] ); |
|
5986 | + } |
|
5325 | 5987 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); |
5326 | 5988 | if( isset( $input['params']['TZID'] )) { |
5327 | 5989 | $input['params']['VALUE'] = 'DATE-TIME'; |
@@ -5330,17 +5992,16 @@ discard block |
||
5330 | 5992 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7, $parno ); |
5331 | 5993 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, $parno, $parno ); |
5332 | 5994 | $input['value'] = $this->_date_time_string( $year, $parno ); |
5333 | - } |
|
5334 | - else { |
|
5995 | + } else { |
|
5335 | 5996 | if( is_array( $params )) { |
5336 | - if( $localtime ) unset ( $params['VALUE'], $params['TZID'] ); |
|
5997 | + if( $localtime ) { |
|
5998 | + unset ( $params['VALUE'], $params['TZID'] ); |
|
5999 | + } |
|
5337 | 6000 | $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )); |
5338 | - } |
|
5339 | - elseif( is_array( $tz )) { |
|
6001 | + } elseif( is_array( $tz )) { |
|
5340 | 6002 | $input['params'] = $this->_setParams( $tz, array( 'VALUE' => 'DATE-TIME' )); |
5341 | 6003 | $tz = FALSE; |
5342 | - } |
|
5343 | - elseif( is_array( $hour )) { |
|
6004 | + } elseif( is_array( $hour )) { |
|
5344 | 6005 | $input['params'] = $this->_setParams( $hour, array( 'VALUE' => 'DATE-TIME' )); |
5345 | 6006 | $hour = $min = $sec = $tz = FALSE; |
5346 | 6007 | } |
@@ -5356,23 +6017,28 @@ discard block |
||
5356 | 6017 | $input['value']['hour'] = ( $hour ) ? $hour : '0'; |
5357 | 6018 | $input['value']['min'] = ( $min ) ? $min : '0'; |
5358 | 6019 | $input['value']['sec'] = ( $sec ) ? $sec : '0'; |
5359 | - if( !empty( $tz )) |
|
5360 | - $input['value']['tz'] = $tz; |
|
6020 | + if( !empty( $tz )) { |
|
6021 | + $input['value']['tz'] = $tz; |
|
6022 | + } |
|
5361 | 6023 | } |
5362 | 6024 | } |
5363 | 6025 | if( 3 == $parno ) { |
5364 | 6026 | $input['params']['VALUE'] = 'DATE'; |
5365 | 6027 | unset( $input['value']['tz'] ); |
5366 | 6028 | unset( $input['params']['TZID'] ); |
6029 | + } elseif( isset( $input['params']['TZID'] )) { |
|
6030 | + unset( $input['value']['tz'] ); |
|
6031 | + } |
|
6032 | + if( $localtime ) { |
|
6033 | + unset( $input['value']['tz'], $input['params']['TZID'] ); |
|
6034 | + } |
|
6035 | + if( isset( $input['value']['tz'] )) { |
|
6036 | + $input['value']['tz'] = (string) $input['value']['tz']; |
|
5367 | 6037 | } |
5368 | - elseif( isset( $input['params']['TZID'] )) |
|
5369 | - unset( $input['value']['tz'] ); |
|
5370 | - if( $localtime ) unset( $input['value']['tz'], $input['params']['TZID'] ); |
|
5371 | - if( isset( $input['value']['tz'] )) |
|
5372 | - $input['value']['tz'] = (string) $input['value']['tz']; |
|
5373 | 6038 | if( !empty( $input['value']['tz'] ) && ( 'Z' != $input['value']['tz'] ) && |
5374 | - ( !$this->_isOffset( $input['value']['tz'] ))) |
|
5375 | - $input['params']['TZID'] = $input['value']['tz']; |
|
6039 | + ( !$this->_isOffset( $input['value']['tz'] ))) { |
|
6040 | + $input['params']['TZID'] = $input['value']['tz']; |
|
6041 | + } |
|
5376 | 6042 | return $input; |
5377 | 6043 | } |
5378 | 6044 | /** |
@@ -5394,16 +6060,13 @@ discard block |
||
5394 | 6060 | if( $this->_isArrayDate( $year )) { |
5395 | 6061 | $input['value'] = $this->_date_time_array( $year, 7 ); |
5396 | 6062 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
5397 | - } |
|
5398 | - elseif( $this->_isArrayTimestampDate( $year )) { |
|
6063 | + } elseif( $this->_isArrayTimestampDate( $year )) { |
|
5399 | 6064 | $input['value'] = $this->_timestamp2date( $year, 7 ); |
5400 | 6065 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
5401 | - } |
|
5402 | - elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
6066 | + } elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 |
|
5403 | 6067 | $input['value'] = $this->_date_time_string( $year, 7 ); |
5404 | 6068 | $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); |
5405 | - } |
|
5406 | - else { |
|
6069 | + } else { |
|
5407 | 6070 | $input['value'] = array( 'year' => $year |
5408 | 6071 | , 'month' => $month |
5409 | 6072 | , 'day' => $day |
@@ -5413,14 +6076,18 @@ discard block |
||
5413 | 6076 | $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )); |
5414 | 6077 | } |
5415 | 6078 | $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7 ); // remove default |
5416 | - if( !isset( $input['value']['hour'] )) |
|
5417 | - $input['value']['hour'] = 0; |
|
5418 | - if( !isset( $input['value']['min'] )) |
|
5419 | - $input['value']['min'] = 0; |
|
5420 | - if( !isset( $input['value']['sec'] )) |
|
5421 | - $input['value']['sec'] = 0; |
|
5422 | - if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] )) |
|
5423 | - $input['value']['tz'] = 'Z'; |
|
6079 | + if( !isset( $input['value']['hour'] )) { |
|
6080 | + $input['value']['hour'] = 0; |
|
6081 | + } |
|
6082 | + if( !isset( $input['value']['min'] )) { |
|
6083 | + $input['value']['min'] = 0; |
|
6084 | + } |
|
6085 | + if( !isset( $input['value']['sec'] )) { |
|
6086 | + $input['value']['sec'] = 0; |
|
6087 | + } |
|
6088 | + if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] )) { |
|
6089 | + $input['value']['tz'] = 'Z'; |
|
6090 | + } |
|
5424 | 6091 | return $input; |
5425 | 6092 | } |
5426 | 6093 | /** |
@@ -5436,15 +6103,17 @@ discard block |
||
5436 | 6103 | * @return void |
5437 | 6104 | */ |
5438 | 6105 | function _setMval( & $valArr, $value, $params=FALSE, $defaults=FALSE, $index=FALSE ) { |
5439 | - if( !is_array( $valArr )) $valArr = array(); |
|
5440 | - if( $index ) |
|
5441 | - $index = $index - 1; |
|
5442 | - elseif( 0 < count( $valArr )) { |
|
6106 | + if( !is_array( $valArr )) { |
|
6107 | + $valArr = array(); |
|
6108 | + } |
|
6109 | + if( $index ) { |
|
6110 | + $index = $index - 1; |
|
6111 | + } elseif( 0 < count( $valArr )) { |
|
5443 | 6112 | $index = end( array_keys( $valArr )); |
5444 | 6113 | $index += 1; |
6114 | + } else { |
|
6115 | + $index = 0; |
|
5445 | 6116 | } |
5446 | - else |
|
5447 | - $index = 0; |
|
5448 | 6117 | $valArr[$index] = array( 'value' => $value, 'params' => $this->_setParams( $params, $defaults )); |
5449 | 6118 | ksort( $valArr ); |
5450 | 6119 | } |
@@ -5460,27 +6129,31 @@ discard block |
||
5460 | 6129 | * @return array |
5461 | 6130 | */ |
5462 | 6131 | function _setParams( $params, $defaults=FALSE ) { |
5463 | - if( !is_array( $params)) |
|
5464 | - $params = array(); |
|
6132 | + if( !is_array( $params)) { |
|
6133 | + $params = array(); |
|
6134 | + } |
|
5465 | 6135 | $input = array(); |
5466 | 6136 | foreach( $params as $paramKey => $paramValue ) { |
5467 | 6137 | if( is_array( $paramValue )) { |
5468 | 6138 | foreach( $paramValue as $pkey => $pValue ) { |
5469 | - if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 ))) |
|
5470 | - $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 )); |
|
6139 | + if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 ))) { |
|
6140 | + $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 )); |
|
6141 | + } |
|
5471 | 6142 | } |
6143 | + } elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 ))) { |
|
6144 | + $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 )); |
|
6145 | + } |
|
6146 | + if( 'VALUE' == strtoupper( $paramKey )) { |
|
6147 | + $input['VALUE'] = strtoupper( $paramValue ); |
|
6148 | + } else { |
|
6149 | + $input[strtoupper( $paramKey )] = $paramValue; |
|
5472 | 6150 | } |
5473 | - elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 ))) |
|
5474 | - $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 )); |
|
5475 | - if( 'VALUE' == strtoupper( $paramKey )) |
|
5476 | - $input['VALUE'] = strtoupper( $paramValue ); |
|
5477 | - else |
|
5478 | - $input[strtoupper( $paramKey )] = $paramValue; |
|
5479 | 6151 | } |
5480 | 6152 | if( is_array( $defaults )) { |
5481 | 6153 | foreach( $defaults as $paramKey => $paramValue ) { |
5482 | - if( !isset( $input[$paramKey] )) |
|
5483 | - $input[$paramKey] = $paramValue; |
|
6154 | + if( !isset( $input[$paramKey] )) { |
|
6155 | + $input[$paramKey] = $paramValue; |
|
6156 | + } |
|
5484 | 6157 | } |
5485 | 6158 | } |
5486 | 6159 | return (0 < count( $input )) ? $input : null; |
@@ -5496,13 +6169,15 @@ discard block |
||
5496 | 6169 | * @return void |
5497 | 6170 | */ |
5498 | 6171 | function _stepdate( &$date, &$timestamp, $step=array( 'day' => 1 )) { |
5499 | - foreach( $step as $stepix => $stepvalue ) |
|
5500 | - $date[$stepix] += $stepvalue; |
|
6172 | + foreach( $step as $stepix => $stepvalue ) { |
|
6173 | + $date[$stepix] += $stepvalue; |
|
6174 | + } |
|
5501 | 6175 | $timestamp = $this->_date2timestamp( $date ); |
5502 | 6176 | $date = $this->_timestamp2date( $timestamp, 6 ); |
5503 | 6177 | foreach( $date as $k => $v ) { |
5504 | - if( ctype_digit( $v )) |
|
5505 | - $date[$k] = (int) $v; |
|
6178 | + if( ctype_digit( $v )) { |
|
6179 | + $date[$k] = (int) $v; |
|
6180 | + } |
|
5506 | 6181 | } |
5507 | 6182 | } |
5508 | 6183 | /** |
@@ -5516,8 +6191,9 @@ discard block |
||
5516 | 6191 | */ |
5517 | 6192 | function _timestamp2date( $timestamp, $parno=6 ) { |
5518 | 6193 | if( is_array( $timestamp )) { |
5519 | - if(( 7 == $parno ) && !empty( $timestamp['tz'] )) |
|
5520 | - $tz = $timestamp['tz']; |
|
6194 | + if(( 7 == $parno ) && !empty( $timestamp['tz'] )) { |
|
6195 | + $tz = $timestamp['tz']; |
|
6196 | + } |
|
5521 | 6197 | $timestamp = $timestamp['timestamp']; |
5522 | 6198 | } |
5523 | 6199 | $output = array( 'year' => date( 'Y', $timestamp ) |
@@ -5527,8 +6203,9 @@ discard block |
||
5527 | 6203 | $output['hour'] = date( 'H', $timestamp ); |
5528 | 6204 | $output['min'] = date( 'i', $timestamp ); |
5529 | 6205 | $output['sec'] = date( 's', $timestamp ); |
5530 | - if( isset( $tz )) |
|
5531 | - $output['tz'] = $tz; |
|
6206 | + if( isset( $tz )) { |
|
6207 | + $output['tz'] = $tz; |
|
6208 | + } |
|
5532 | 6209 | } |
5533 | 6210 | return $output; |
5534 | 6211 | } |
@@ -5546,8 +6223,9 @@ discard block |
||
5546 | 6223 | if((( 5 != strlen( $tz )) && ( 7 != strlen( $tz ))) || |
5547 | 6224 | (( '+' != substr( $tz, 0, 1 )) && ( '-' != substr( $tz, 0, 1 ))) || |
5548 | 6225 | (( '0000' >= substr( $tz, 1, 4 )) && ( '9999' < substr( $tz, 1, 4 ))) || |
5549 | - (( 7 == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 )))) |
|
5550 | - return $offset; |
|
6226 | + (( 7 == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 )))) { |
|
6227 | + return $offset; |
|
6228 | + } |
|
5551 | 6229 | $hours2sec = (int) substr( $tz, 1, 2 ) * 3600; |
5552 | 6230 | $min2sec = (int) substr( $tz, 3, 2 ) * 60; |
5553 | 6231 | $sec = ( 7 == strlen( $tz )) ? (int) substr( $tz, -2 ) : '00'; |
@@ -5575,7 +6253,9 @@ discard block |
||
5575 | 6253 | $info = array(); |
5576 | 6254 | if( isset( $this->components )) { |
5577 | 6255 | foreach( $this->components as $cix => $component ) { |
5578 | - if( empty( $component )) continue; |
|
6256 | + if( empty( $component )) { |
|
6257 | + continue; |
|
6258 | + } |
|
5579 | 6259 | unset( $component->propix ); |
5580 | 6260 | $info[$cix]['ordno'] = $cix + 1; |
5581 | 6261 | $info[$cix]['type'] = $component->objName; |
@@ -5601,57 +6281,146 @@ discard block |
||
5601 | 6281 | case 'PROPINFO': |
5602 | 6282 | $output = array(); |
5603 | 6283 | if( !in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
5604 | - if( empty( $this->uid['value'] )) $this->_makeuid(); |
|
6284 | + if( empty( $this->uid['value'] )) { |
|
6285 | + $this->_makeuid(); |
|
6286 | + } |
|
5605 | 6287 | $output['UID'] = 1; |
5606 | 6288 | } |
5607 | - if( !empty( $this->dtstamp )) $output['DTSTAMP'] = 1; |
|
5608 | - if( !empty( $this->summary )) $output['SUMMARY'] = 1; |
|
5609 | - if( !empty( $this->description )) $output['DESCRIPTION'] = count( $this->description ); |
|
5610 | - if( !empty( $this->dtstart )) $output['DTSTART'] = 1; |
|
5611 | - if( !empty( $this->dtend )) $output['DTEND'] = 1; |
|
5612 | - if( !empty( $this->due )) $output['DUE'] = 1; |
|
5613 | - if( !empty( $this->duration )) $output['DURATION'] = 1; |
|
5614 | - if( !empty( $this->rrule )) $output['RRULE'] = count( $this->rrule ); |
|
5615 | - if( !empty( $this->rdate )) $output['RDATE'] = count( $this->rdate ); |
|
5616 | - if( !empty( $this->exdate )) $output['EXDATE'] = count( $this->exdate ); |
|
5617 | - if( !empty( $this->exrule )) $output['EXRULE'] = count( $this->exrule ); |
|
5618 | - if( !empty( $this->action )) $output['ACTION'] = 1; |
|
5619 | - if( !empty( $this->attach )) $output['ATTACH'] = count( $this->attach ); |
|
5620 | - if( !empty( $this->attendee )) $output['ATTENDEE'] = count( $this->attendee ); |
|
5621 | - if( !empty( $this->categories )) $output['CATEGORIES'] = count( $this->categories ); |
|
5622 | - if( !empty( $this->class )) $output['CLASS'] = 1; |
|
5623 | - if( !empty( $this->comment )) $output['COMMENT'] = count( $this->comment ); |
|
5624 | - if( !empty( $this->completed )) $output['COMPLETED'] = 1; |
|
5625 | - if( !empty( $this->contact )) $output['CONTACT'] = count( $this->contact ); |
|
5626 | - if( !empty( $this->created )) $output['CREATED'] = 1; |
|
5627 | - if( !empty( $this->freebusy )) $output['FREEBUSY'] = count( $this->freebusy ); |
|
5628 | - if( !empty( $this->geo )) $output['GEO'] = 1; |
|
5629 | - if( !empty( $this->lastmodified )) $output['LAST-MODIFIED'] = 1; |
|
5630 | - if( !empty( $this->location )) $output['LOCATION'] = 1; |
|
5631 | - if( !empty( $this->organizer )) $output['ORGANIZER'] = 1; |
|
5632 | - if( !empty( $this->percentcomplete )) $output['PERCENT-COMPLETE'] = 1; |
|
5633 | - if( !empty( $this->priority )) $output['PRIORITY'] = 1; |
|
5634 | - if( !empty( $this->recurrenceid )) $output['RECURRENCE-ID'] = 1; |
|
5635 | - if( !empty( $this->relatedto )) $output['RELATED-TO'] = count( $this->relatedto ); |
|
5636 | - if( !empty( $this->repeat )) $output['REPEAT'] = 1; |
|
5637 | - if( !empty( $this->requeststatus )) $output['REQUEST-STATUS'] = count( $this->requeststatus ); |
|
5638 | - if( !empty( $this->resources )) $output['RESOURCES'] = count( $this->resources ); |
|
5639 | - if( !empty( $this->sequence )) $output['SEQUENCE'] = 1; |
|
5640 | - if( !empty( $this->status )) $output['STATUS'] = 1; |
|
5641 | - if( !empty( $this->transp )) $output['TRANSP'] = 1; |
|
5642 | - if( !empty( $this->trigger )) $output['TRIGGER'] = 1; |
|
5643 | - if( !empty( $this->tzid )) $output['TZID'] = 1; |
|
5644 | - if( !empty( $this->tzname )) $output['TZNAME'] = count( $this->tzname ); |
|
5645 | - if( !empty( $this->tzoffsetfrom )) $output['TZOFFSETTFROM'] = 1; |
|
5646 | - if( !empty( $this->tzoffsetto )) $output['TZOFFSETTO'] = 1; |
|
5647 | - if( !empty( $this->tzurl )) $output['TZURL'] = 1; |
|
5648 | - if( !empty( $this->url )) $output['URL'] = 1; |
|
5649 | - if( !empty( $this->xprop )) $output['X-PROP'] = count( $this->xprop ); |
|
6289 | + if( !empty( $this->dtstamp )) { |
|
6290 | + $output['DTSTAMP'] = 1; |
|
6291 | + } |
|
6292 | + if( !empty( $this->summary )) { |
|
6293 | + $output['SUMMARY'] = 1; |
|
6294 | + } |
|
6295 | + if( !empty( $this->description )) { |
|
6296 | + $output['DESCRIPTION'] = count( $this->description ); |
|
6297 | + } |
|
6298 | + if( !empty( $this->dtstart )) { |
|
6299 | + $output['DTSTART'] = 1; |
|
6300 | + } |
|
6301 | + if( !empty( $this->dtend )) { |
|
6302 | + $output['DTEND'] = 1; |
|
6303 | + } |
|
6304 | + if( !empty( $this->due )) { |
|
6305 | + $output['DUE'] = 1; |
|
6306 | + } |
|
6307 | + if( !empty( $this->duration )) { |
|
6308 | + $output['DURATION'] = 1; |
|
6309 | + } |
|
6310 | + if( !empty( $this->rrule )) { |
|
6311 | + $output['RRULE'] = count( $this->rrule ); |
|
6312 | + } |
|
6313 | + if( !empty( $this->rdate )) { |
|
6314 | + $output['RDATE'] = count( $this->rdate ); |
|
6315 | + } |
|
6316 | + if( !empty( $this->exdate )) { |
|
6317 | + $output['EXDATE'] = count( $this->exdate ); |
|
6318 | + } |
|
6319 | + if( !empty( $this->exrule )) { |
|
6320 | + $output['EXRULE'] = count( $this->exrule ); |
|
6321 | + } |
|
6322 | + if( !empty( $this->action )) { |
|
6323 | + $output['ACTION'] = 1; |
|
6324 | + } |
|
6325 | + if( !empty( $this->attach )) { |
|
6326 | + $output['ATTACH'] = count( $this->attach ); |
|
6327 | + } |
|
6328 | + if( !empty( $this->attendee )) { |
|
6329 | + $output['ATTENDEE'] = count( $this->attendee ); |
|
6330 | + } |
|
6331 | + if( !empty( $this->categories )) { |
|
6332 | + $output['CATEGORIES'] = count( $this->categories ); |
|
6333 | + } |
|
6334 | + if( !empty( $this->class )) { |
|
6335 | + $output['CLASS'] = 1; |
|
6336 | + } |
|
6337 | + if( !empty( $this->comment )) { |
|
6338 | + $output['COMMENT'] = count( $this->comment ); |
|
6339 | + } |
|
6340 | + if( !empty( $this->completed )) { |
|
6341 | + $output['COMPLETED'] = 1; |
|
6342 | + } |
|
6343 | + if( !empty( $this->contact )) { |
|
6344 | + $output['CONTACT'] = count( $this->contact ); |
|
6345 | + } |
|
6346 | + if( !empty( $this->created )) { |
|
6347 | + $output['CREATED'] = 1; |
|
6348 | + } |
|
6349 | + if( !empty( $this->freebusy )) { |
|
6350 | + $output['FREEBUSY'] = count( $this->freebusy ); |
|
6351 | + } |
|
6352 | + if( !empty( $this->geo )) { |
|
6353 | + $output['GEO'] = 1; |
|
6354 | + } |
|
6355 | + if( !empty( $this->lastmodified )) { |
|
6356 | + $output['LAST-MODIFIED'] = 1; |
|
6357 | + } |
|
6358 | + if( !empty( $this->location )) { |
|
6359 | + $output['LOCATION'] = 1; |
|
6360 | + } |
|
6361 | + if( !empty( $this->organizer )) { |
|
6362 | + $output['ORGANIZER'] = 1; |
|
6363 | + } |
|
6364 | + if( !empty( $this->percentcomplete )) { |
|
6365 | + $output['PERCENT-COMPLETE'] = 1; |
|
6366 | + } |
|
6367 | + if( !empty( $this->priority )) { |
|
6368 | + $output['PRIORITY'] = 1; |
|
6369 | + } |
|
6370 | + if( !empty( $this->recurrenceid )) { |
|
6371 | + $output['RECURRENCE-ID'] = 1; |
|
6372 | + } |
|
6373 | + if( !empty( $this->relatedto )) { |
|
6374 | + $output['RELATED-TO'] = count( $this->relatedto ); |
|
6375 | + } |
|
6376 | + if( !empty( $this->repeat )) { |
|
6377 | + $output['REPEAT'] = 1; |
|
6378 | + } |
|
6379 | + if( !empty( $this->requeststatus )) { |
|
6380 | + $output['REQUEST-STATUS'] = count( $this->requeststatus ); |
|
6381 | + } |
|
6382 | + if( !empty( $this->resources )) { |
|
6383 | + $output['RESOURCES'] = count( $this->resources ); |
|
6384 | + } |
|
6385 | + if( !empty( $this->sequence )) { |
|
6386 | + $output['SEQUENCE'] = 1; |
|
6387 | + } |
|
6388 | + if( !empty( $this->status )) { |
|
6389 | + $output['STATUS'] = 1; |
|
6390 | + } |
|
6391 | + if( !empty( $this->transp )) { |
|
6392 | + $output['TRANSP'] = 1; |
|
6393 | + } |
|
6394 | + if( !empty( $this->trigger )) { |
|
6395 | + $output['TRIGGER'] = 1; |
|
6396 | + } |
|
6397 | + if( !empty( $this->tzid )) { |
|
6398 | + $output['TZID'] = 1; |
|
6399 | + } |
|
6400 | + if( !empty( $this->tzname )) { |
|
6401 | + $output['TZNAME'] = count( $this->tzname ); |
|
6402 | + } |
|
6403 | + if( !empty( $this->tzoffsetfrom )) { |
|
6404 | + $output['TZOFFSETTFROM'] = 1; |
|
6405 | + } |
|
6406 | + if( !empty( $this->tzoffsetto )) { |
|
6407 | + $output['TZOFFSETTO'] = 1; |
|
6408 | + } |
|
6409 | + if( !empty( $this->tzurl )) { |
|
6410 | + $output['TZURL'] = 1; |
|
6411 | + } |
|
6412 | + if( !empty( $this->url )) { |
|
6413 | + $output['URL'] = 1; |
|
6414 | + } |
|
6415 | + if( !empty( $this->xprop )) { |
|
6416 | + $output['X-PROP'] = count( $this->xprop ); |
|
6417 | + } |
|
5650 | 6418 | return $output; |
5651 | 6419 | break; |
5652 | 6420 | case 'UNIQUE_ID': |
5653 | - if( empty( $this->unique_id )) |
|
5654 | - $this->unique_id = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost'; |
|
6421 | + if( empty( $this->unique_id )) { |
|
6422 | + $this->unique_id = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost'; |
|
6423 | + } |
|
5655 | 6424 | return $this->unique_id; |
5656 | 6425 | break; |
5657 | 6426 | } |
@@ -5700,13 +6469,16 @@ discard block |
||
5700 | 6469 | $res = TRUE; |
5701 | 6470 | break; |
5702 | 6471 | } |
5703 | - if( !$res ) return FALSE; |
|
6472 | + if( !$res ) { |
|
6473 | + return FALSE; |
|
6474 | + } |
|
5704 | 6475 | if( isset( $subcfg ) && !empty( $this->components )) { |
5705 | 6476 | foreach( $subcfg as $cfgkey => $cfgvalue ) { |
5706 | 6477 | foreach( $this->components as $cix => $component ) { |
5707 | 6478 | $res = $component->setConfig( $cfgkey, $cfgvalue ); |
5708 | - if( !$res ) |
|
5709 | - break 2; |
|
6479 | + if( !$res ) { |
|
6480 | + break 2; |
|
6481 | + } |
|
5710 | 6482 | $this->components[$cix] = $component; // PHP4 compliant |
5711 | 6483 | } |
5712 | 6484 | } |
@@ -5724,12 +6496,15 @@ discard block |
||
5724 | 6496 | * @return bool, if successfull delete TRUE |
5725 | 6497 | */ |
5726 | 6498 | function deleteProperty( $propName, $propix=FALSE ) { |
5727 | - if( $this->_notExistProp( $propName )) return FALSE; |
|
6499 | + if( $this->_notExistProp( $propName )) { |
|
6500 | + return FALSE; |
|
6501 | + } |
|
5728 | 6502 | $propName = strtoupper( $propName ); |
5729 | 6503 | if( in_array( $propName, array( 'ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
5730 | 6504 | 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP' ))) { |
5731 | - if( !$propix ) |
|
5732 | - $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1; |
|
6505 | + if( !$propix ) { |
|
6506 | + $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1; |
|
6507 | + } |
|
5733 | 6508 | $this->propdelix[$propName] = --$propix; |
5734 | 6509 | } |
5735 | 6510 | $return = FALSE; |
@@ -5783,8 +6558,9 @@ discard block |
||
5783 | 6558 | } |
5784 | 6559 | break; |
5785 | 6560 | case 'DTSTAMP': |
5786 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
5787 | - return FALSE; |
|
6561 | + if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
6562 | + return FALSE; |
|
6563 | + } |
|
5788 | 6564 | if( !empty( $this->dtstamp )) { |
5789 | 6565 | $this->dtstamp = ''; |
5790 | 6566 | $return = TRUE; |
@@ -5938,8 +6714,9 @@ discard block |
||
5938 | 6714 | } |
5939 | 6715 | break; |
5940 | 6716 | case 'UID': |
5941 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
5942 | - return FALSE; |
|
6717 | + if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
6718 | + return FALSE; |
|
6719 | + } |
|
5943 | 6720 | if( !empty( $this->uid )) { |
5944 | 6721 | $this->uid = ''; |
5945 | 6722 | $return = TRUE; |
@@ -5954,18 +6731,23 @@ discard block |
||
5954 | 6731 | default: |
5955 | 6732 | $reduced = ''; |
5956 | 6733 | if( $propName != 'X-PROP' ) { |
5957 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
6734 | + if( !isset( $this->xprop[$propName] )) { |
|
6735 | + return FALSE; |
|
6736 | + } |
|
5958 | 6737 | foreach( $this->xprop as $k => $a ) { |
5959 | - if(( $k != $propName ) && !empty( $a )) |
|
5960 | - $reduced[$k] = $a; |
|
6738 | + if(( $k != $propName ) && !empty( $a )) { |
|
6739 | + $reduced[$k] = $a; |
|
6740 | + } |
|
6741 | + } |
|
6742 | + } else { |
|
6743 | + if( count( $this->xprop ) <= $propix ) { |
|
6744 | + return FALSE; |
|
5961 | 6745 | } |
5962 | - } |
|
5963 | - else { |
|
5964 | - if( count( $this->xprop ) <= $propix ) return FALSE; |
|
5965 | 6746 | $xpropno = 0; |
5966 | 6747 | foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
5967 | - if( $propix != $xpropno ) |
|
5968 | - $reduced[$xpropkey] = $xpropvalue; |
|
6748 | + if( $propix != $xpropno ) { |
|
6749 | + $reduced[$xpropkey] = $xpropvalue; |
|
6750 | + } |
|
5969 | 6751 | $xpropno++; |
5970 | 6752 | } |
5971 | 6753 | } |
@@ -5985,9 +6767,13 @@ discard block |
||
5985 | 6767 | * @return bool TRUE |
5986 | 6768 | */ |
5987 | 6769 | function deletePropertyM( & $multiprop, $propix=0 ) { |
5988 | - if( !isset( $multiprop[$propix])) return FALSE; |
|
6770 | + if( !isset( $multiprop[$propix])) { |
|
6771 | + return FALSE; |
|
6772 | + } |
|
5989 | 6773 | unset( $multiprop[$propix] ); |
5990 | - if( empty( $multiprop )) $multiprop = ''; |
|
6774 | + if( empty( $multiprop )) { |
|
6775 | + $multiprop = ''; |
|
6776 | + } |
|
5991 | 6777 | return ( isset( $this->multiprop[$propix] )) ? FALSE : TRUE; |
5992 | 6778 | } |
5993 | 6779 | /** |
@@ -6004,184 +6790,277 @@ discard block |
||
6004 | 6790 | * @return mixed |
6005 | 6791 | */ |
6006 | 6792 | function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE, $specform=FALSE ) { |
6007 | - if( $this->_notExistProp( $propName )) return FALSE; |
|
6793 | + if( $this->_notExistProp( $propName )) { |
|
6794 | + return FALSE; |
|
6795 | + } |
|
6008 | 6796 | $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP'; |
6009 | 6797 | if( in_array( $propName, array( 'ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', |
6010 | 6798 | 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP' ))) { |
6011 | - if( !$propix ) |
|
6012 | - $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; |
|
6799 | + if( !$propix ) { |
|
6800 | + $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; |
|
6801 | + } |
|
6013 | 6802 | $this->propix[$propName] = --$propix; |
6014 | 6803 | } |
6015 | 6804 | switch( $propName ) { |
6016 | 6805 | case 'ACTION': |
6017 | - if( !empty( $this->action['value'] )) return ( $inclParam ) ? $this->action : $this->action['value']; |
|
6806 | + if( !empty( $this->action['value'] )) { |
|
6807 | + return ( $inclParam ) ? $this->action : $this->action['value']; |
|
6808 | + } |
|
6018 | 6809 | break; |
6019 | 6810 | case 'ATTACH': |
6020 | - if( !isset( $this->attach[$propix] )) return FALSE; |
|
6811 | + if( !isset( $this->attach[$propix] )) { |
|
6812 | + return FALSE; |
|
6813 | + } |
|
6021 | 6814 | return ( $inclParam ) ? $this->attach[$propix] : $this->attach[$propix]['value']; |
6022 | 6815 | break; |
6023 | 6816 | case 'ATTENDEE': |
6024 | - if( !isset( $this->attendee[$propix] )) return FALSE; |
|
6817 | + if( !isset( $this->attendee[$propix] )) { |
|
6818 | + return FALSE; |
|
6819 | + } |
|
6025 | 6820 | return ( $inclParam ) ? $this->attendee[$propix] : $this->attendee[$propix]['value']; |
6026 | 6821 | break; |
6027 | 6822 | case 'CATEGORIES': |
6028 | - if( !isset( $this->categories[$propix] )) return FALSE; |
|
6823 | + if( !isset( $this->categories[$propix] )) { |
|
6824 | + return FALSE; |
|
6825 | + } |
|
6029 | 6826 | return ( $inclParam ) ? $this->categories[$propix] : $this->categories[$propix]['value']; |
6030 | 6827 | break; |
6031 | 6828 | case 'CLASS': |
6032 | - if( !empty( $this->class['value'] )) return ( $inclParam ) ? $this->class : $this->class['value']; |
|
6829 | + if( !empty( $this->class['value'] )) { |
|
6830 | + return ( $inclParam ) ? $this->class : $this->class['value']; |
|
6831 | + } |
|
6033 | 6832 | break; |
6034 | 6833 | case 'COMMENT': |
6035 | - if( !isset( $this->comment[$propix] )) return FALSE; |
|
6834 | + if( !isset( $this->comment[$propix] )) { |
|
6835 | + return FALSE; |
|
6836 | + } |
|
6036 | 6837 | return ( $inclParam ) ? $this->comment[$propix] : $this->comment[$propix]['value']; |
6037 | 6838 | break; |
6038 | 6839 | case 'COMPLETED': |
6039 | - if( !empty( $this->completed['value'] )) return ( $inclParam ) ? $this->completed : $this->completed['value']; |
|
6840 | + if( !empty( $this->completed['value'] )) { |
|
6841 | + return ( $inclParam ) ? $this->completed : $this->completed['value']; |
|
6842 | + } |
|
6040 | 6843 | break; |
6041 | 6844 | case 'CONTACT': |
6042 | - if( !isset( $this->contact[$propix] )) return FALSE; |
|
6845 | + if( !isset( $this->contact[$propix] )) { |
|
6846 | + return FALSE; |
|
6847 | + } |
|
6043 | 6848 | return ( $inclParam ) ? $this->contact[$propix] : $this->contact[$propix]['value']; |
6044 | 6849 | break; |
6045 | 6850 | case 'CREATED': |
6046 | - if( !empty( $this->created['value'] )) return ( $inclParam ) ? $this->created : $this->created['value']; |
|
6851 | + if( !empty( $this->created['value'] )) { |
|
6852 | + return ( $inclParam ) ? $this->created : $this->created['value']; |
|
6853 | + } |
|
6047 | 6854 | break; |
6048 | 6855 | case 'DESCRIPTION': |
6049 | - if( !isset( $this->description[$propix] )) return FALSE; |
|
6856 | + if( !isset( $this->description[$propix] )) { |
|
6857 | + return FALSE; |
|
6858 | + } |
|
6050 | 6859 | return ( $inclParam ) ? $this->description[$propix] : $this->description[$propix]['value']; |
6051 | 6860 | break; |
6052 | 6861 | case 'DTEND': |
6053 | - if( !empty( $this->dtend['value'] )) return ( $inclParam ) ? $this->dtend : $this->dtend['value']; |
|
6862 | + if( !empty( $this->dtend['value'] )) { |
|
6863 | + return ( $inclParam ) ? $this->dtend : $this->dtend['value']; |
|
6864 | + } |
|
6054 | 6865 | break; |
6055 | 6866 | case 'DTSTAMP': |
6056 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
6057 | - return; |
|
6058 | - if( !isset( $this->dtstamp['value'] )) |
|
6059 | - $this->_makeDtstamp(); |
|
6867 | + if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
6868 | + return; |
|
6869 | + } |
|
6870 | + if( !isset( $this->dtstamp['value'] )) { |
|
6871 | + $this->_makeDtstamp(); |
|
6872 | + } |
|
6060 | 6873 | return ( $inclParam ) ? $this->dtstamp : $this->dtstamp['value']; |
6061 | 6874 | break; |
6062 | 6875 | case 'DTSTART': |
6063 | - if( !empty( $this->dtstart['value'] )) return ( $inclParam ) ? $this->dtstart : $this->dtstart['value']; |
|
6876 | + if( !empty( $this->dtstart['value'] )) { |
|
6877 | + return ( $inclParam ) ? $this->dtstart : $this->dtstart['value']; |
|
6878 | + } |
|
6064 | 6879 | break; |
6065 | 6880 | case 'DUE': |
6066 | - if( !empty( $this->due['value'] )) return ( $inclParam ) ? $this->due : $this->due['value']; |
|
6881 | + if( !empty( $this->due['value'] )) { |
|
6882 | + return ( $inclParam ) ? $this->due : $this->due['value']; |
|
6883 | + } |
|
6067 | 6884 | break; |
6068 | 6885 | case 'DURATION': |
6069 | - if( !isset( $this->duration['value'] )) return FALSE; |
|
6886 | + if( !isset( $this->duration['value'] )) { |
|
6887 | + return FALSE; |
|
6888 | + } |
|
6070 | 6889 | $value = ( $specform ) ? $this->duration2date() : $this->duration['value']; |
6071 | 6890 | return ( $inclParam ) ? array( 'value' => $value, 'params' => $this->duration['params'] ) : $value; |
6072 | 6891 | break; |
6073 | 6892 | case 'EXDATE': |
6074 | - if( !isset( $this->exdate[$propix] )) return FALSE; |
|
6893 | + if( !isset( $this->exdate[$propix] )) { |
|
6894 | + return FALSE; |
|
6895 | + } |
|
6075 | 6896 | return ( $inclParam ) ? $this->exdate[$propix] : $this->exdate[$propix]['value']; |
6076 | 6897 | break; |
6077 | 6898 | case 'EXRULE': |
6078 | - if( !isset( $this->exrule[$propix] )) return FALSE; |
|
6899 | + if( !isset( $this->exrule[$propix] )) { |
|
6900 | + return FALSE; |
|
6901 | + } |
|
6079 | 6902 | return ( $inclParam ) ? $this->exrule[$propix] : $this->exrule[$propix]['value']; |
6080 | 6903 | break; |
6081 | 6904 | case 'FREEBUSY': |
6082 | - if( !isset( $this->freebusy[$propix] )) return FALSE; |
|
6905 | + if( !isset( $this->freebusy[$propix] )) { |
|
6906 | + return FALSE; |
|
6907 | + } |
|
6083 | 6908 | return ( $inclParam ) ? $this->freebusy[$propix] : $this->freebusy[$propix]['value']; |
6084 | 6909 | break; |
6085 | 6910 | case 'GEO': |
6086 | - if( !empty( $this->geo['value'] )) return ( $inclParam ) ? $this->geo : $this->geo['value']; |
|
6911 | + if( !empty( $this->geo['value'] )) { |
|
6912 | + return ( $inclParam ) ? $this->geo : $this->geo['value']; |
|
6913 | + } |
|
6087 | 6914 | break; |
6088 | 6915 | case 'LAST-MODIFIED': |
6089 | - if( !empty( $this->lastmodified['value'] )) return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value']; |
|
6916 | + if( !empty( $this->lastmodified['value'] )) { |
|
6917 | + return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value']; |
|
6918 | + } |
|
6090 | 6919 | break; |
6091 | 6920 | case 'LOCATION': |
6092 | - if( !empty( $this->location['value'] )) return ( $inclParam ) ? $this->location : $this->location['value']; |
|
6921 | + if( !empty( $this->location['value'] )) { |
|
6922 | + return ( $inclParam ) ? $this->location : $this->location['value']; |
|
6923 | + } |
|
6093 | 6924 | break; |
6094 | 6925 | case 'ORGANIZER': |
6095 | - if( !empty( $this->organizer['value'] )) return ( $inclParam ) ? $this->organizer : $this->organizer['value']; |
|
6926 | + if( !empty( $this->organizer['value'] )) { |
|
6927 | + return ( $inclParam ) ? $this->organizer : $this->organizer['value']; |
|
6928 | + } |
|
6096 | 6929 | break; |
6097 | 6930 | case 'PERCENT-COMPLETE': |
6098 | - if( !empty( $this->percentcomplete['value'] )) return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value']; |
|
6931 | + if( !empty( $this->percentcomplete['value'] )) { |
|
6932 | + return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value']; |
|
6933 | + } |
|
6099 | 6934 | break; |
6100 | 6935 | case 'PRIORITY': |
6101 | - if( !empty( $this->priority['value'] )) return ( $inclParam ) ? $this->priority : $this->priority['value']; |
|
6936 | + if( !empty( $this->priority['value'] )) { |
|
6937 | + return ( $inclParam ) ? $this->priority : $this->priority['value']; |
|
6938 | + } |
|
6102 | 6939 | break; |
6103 | 6940 | case 'RDATE': |
6104 | - if( !isset( $this->rdate[$propix] )) return FALSE; |
|
6941 | + if( !isset( $this->rdate[$propix] )) { |
|
6942 | + return FALSE; |
|
6943 | + } |
|
6105 | 6944 | return ( $inclParam ) ? $this->rdate[$propix] : $this->rdate[$propix]['value']; |
6106 | 6945 | break; |
6107 | 6946 | case 'RECURRENCE-ID': |
6108 | - if( !empty( $this->recurrenceid['value'] )) return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value']; |
|
6947 | + if( !empty( $this->recurrenceid['value'] )) { |
|
6948 | + return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value']; |
|
6949 | + } |
|
6109 | 6950 | break; |
6110 | 6951 | case 'RELATED-TO': |
6111 | - if( !isset( $this->relatedto[$propix] )) return FALSE; |
|
6952 | + if( !isset( $this->relatedto[$propix] )) { |
|
6953 | + return FALSE; |
|
6954 | + } |
|
6112 | 6955 | return ( $inclParam ) ? $this->relatedto[$propix] : $this->relatedto[$propix]['value']; |
6113 | 6956 | break; |
6114 | 6957 | case 'REPEAT': |
6115 | - if( !empty( $this->repeat['value'] )) return ( $inclParam ) ? $this->repeat : $this->repeat['value']; |
|
6958 | + if( !empty( $this->repeat['value'] )) { |
|
6959 | + return ( $inclParam ) ? $this->repeat : $this->repeat['value']; |
|
6960 | + } |
|
6116 | 6961 | break; |
6117 | 6962 | case 'REQUEST-STATUS': |
6118 | - if( !isset( $this->requeststatus[$propix] )) return FALSE; |
|
6963 | + if( !isset( $this->requeststatus[$propix] )) { |
|
6964 | + return FALSE; |
|
6965 | + } |
|
6119 | 6966 | return ( $inclParam ) ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value']; |
6120 | 6967 | break; |
6121 | 6968 | case 'RESOURCES': |
6122 | - if( !isset( $this->resources[$propix] )) return FALSE; |
|
6969 | + if( !isset( $this->resources[$propix] )) { |
|
6970 | + return FALSE; |
|
6971 | + } |
|
6123 | 6972 | return ( $inclParam ) ? $this->resources[$propix] : $this->resources[$propix]['value']; |
6124 | 6973 | break; |
6125 | 6974 | case 'RRULE': |
6126 | - if( !isset( $this->rrule[$propix] )) return FALSE; |
|
6975 | + if( !isset( $this->rrule[$propix] )) { |
|
6976 | + return FALSE; |
|
6977 | + } |
|
6127 | 6978 | return ( $inclParam ) ? $this->rrule[$propix] : $this->rrule[$propix]['value']; |
6128 | 6979 | break; |
6129 | 6980 | case 'SEQUENCE': |
6130 | - if( !empty( $this->sequence['value'] )) return ( $inclParam ) ? $this->sequence : $this->sequence['value']; |
|
6981 | + if( !empty( $this->sequence['value'] )) { |
|
6982 | + return ( $inclParam ) ? $this->sequence : $this->sequence['value']; |
|
6983 | + } |
|
6131 | 6984 | break; |
6132 | 6985 | case 'STATUS': |
6133 | - if( !empty( $this->status['value'] )) return ( $inclParam ) ? $this->status : $this->status['value']; |
|
6986 | + if( !empty( $this->status['value'] )) { |
|
6987 | + return ( $inclParam ) ? $this->status : $this->status['value']; |
|
6988 | + } |
|
6134 | 6989 | break; |
6135 | 6990 | case 'SUMMARY': |
6136 | - if( !empty( $this->summary['value'] )) return ( $inclParam ) ? $this->summary : $this->summary['value']; |
|
6991 | + if( !empty( $this->summary['value'] )) { |
|
6992 | + return ( $inclParam ) ? $this->summary : $this->summary['value']; |
|
6993 | + } |
|
6137 | 6994 | break; |
6138 | 6995 | case 'TRANSP': |
6139 | - if( !empty( $this->transp['value'] )) return ( $inclParam ) ? $this->transp : $this->transp['value']; |
|
6996 | + if( !empty( $this->transp['value'] )) { |
|
6997 | + return ( $inclParam ) ? $this->transp : $this->transp['value']; |
|
6998 | + } |
|
6140 | 6999 | break; |
6141 | 7000 | case 'TRIGGER': |
6142 | - if( !empty( $this->trigger['value'] )) return ( $inclParam ) ? $this->trigger : $this->trigger['value']; |
|
7001 | + if( !empty( $this->trigger['value'] )) { |
|
7002 | + return ( $inclParam ) ? $this->trigger : $this->trigger['value']; |
|
7003 | + } |
|
6143 | 7004 | break; |
6144 | 7005 | case 'TZID': |
6145 | - if( !empty( $this->tzid['value'] )) return ( $inclParam ) ? $this->tzid : $this->tzid['value']; |
|
7006 | + if( !empty( $this->tzid['value'] )) { |
|
7007 | + return ( $inclParam ) ? $this->tzid : $this->tzid['value']; |
|
7008 | + } |
|
6146 | 7009 | break; |
6147 | 7010 | case 'TZNAME': |
6148 | - if( !isset( $this->tzname[$propix] )) return FALSE; |
|
7011 | + if( !isset( $this->tzname[$propix] )) { |
|
7012 | + return FALSE; |
|
7013 | + } |
|
6149 | 7014 | return ( $inclParam ) ? $this->tzname[$propix] : $this->tzname[$propix]['value']; |
6150 | 7015 | break; |
6151 | 7016 | case 'TZOFFSETFROM': |
6152 | - if( !empty( $this->tzoffsetfrom['value'] )) return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value']; |
|
7017 | + if( !empty( $this->tzoffsetfrom['value'] )) { |
|
7018 | + return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value']; |
|
7019 | + } |
|
6153 | 7020 | break; |
6154 | 7021 | case 'TZOFFSETTO': |
6155 | - if( !empty( $this->tzoffsetto['value'] )) return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value']; |
|
7022 | + if( !empty( $this->tzoffsetto['value'] )) { |
|
7023 | + return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value']; |
|
7024 | + } |
|
6156 | 7025 | break; |
6157 | 7026 | case 'TZURL': |
6158 | - if( !empty( $this->tzurl['value'] )) return ( $inclParam ) ? $this->tzurl : $this->tzurl['value']; |
|
7027 | + if( !empty( $this->tzurl['value'] )) { |
|
7028 | + return ( $inclParam ) ? $this->tzurl : $this->tzurl['value']; |
|
7029 | + } |
|
6159 | 7030 | break; |
6160 | 7031 | case 'UID': |
6161 | - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) |
|
6162 | - return FALSE; |
|
6163 | - if( empty( $this->uid['value'] )) |
|
6164 | - $this->_makeuid(); |
|
7032 | + if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { |
|
7033 | + return FALSE; |
|
7034 | + } |
|
7035 | + if( empty( $this->uid['value'] )) { |
|
7036 | + $this->_makeuid(); |
|
7037 | + } |
|
6165 | 7038 | return ( $inclParam ) ? $this->uid : $this->uid['value']; |
6166 | 7039 | break; |
6167 | 7040 | case 'URL': |
6168 | - if( !empty( $this->url['value'] )) return ( $inclParam ) ? $this->url : $this->url['value']; |
|
7041 | + if( !empty( $this->url['value'] )) { |
|
7042 | + return ( $inclParam ) ? $this->url : $this->url['value']; |
|
7043 | + } |
|
6169 | 7044 | break; |
6170 | 7045 | default: |
6171 | 7046 | if( $propName != 'X-PROP' ) { |
6172 | - if( !isset( $this->xprop[$propName] )) return FALSE; |
|
7047 | + if( !isset( $this->xprop[$propName] )) { |
|
7048 | + return FALSE; |
|
7049 | + } |
|
6173 | 7050 | return ( $inclParam ) ? array( $propName, $this->xprop[$propName] ) |
6174 | 7051 | : array( $propName, $this->xprop[$propName]['value'] ); |
6175 | - } |
|
6176 | - else { |
|
6177 | - if( empty( $this->xprop )) return FALSE; |
|
7052 | + } else { |
|
7053 | + if( empty( $this->xprop )) { |
|
7054 | + return FALSE; |
|
7055 | + } |
|
6178 | 7056 | $xpropno = 0; |
6179 | 7057 | foreach( $this->xprop as $xpropkey => $xpropvalue ) { |
6180 | - if( $propix == $xpropno ) |
|
6181 | - return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) |
|
7058 | + if( $propix == $xpropno ) { |
|
7059 | + return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) |
|
6182 | 7060 | : array( $xpropkey, $this->xprop[$xpropkey]['value'] ); |
6183 | - else |
|
6184 | - $xpropno++; |
|
7061 | + } else { |
|
7062 | + $xpropno++; |
|
7063 | + } |
|
6185 | 7064 | } |
6186 | 7065 | return FALSE; // not found ?? |
6187 | 7066 | } |
@@ -6200,15 +7079,21 @@ discard block |
||
6200 | 7079 | */ |
6201 | 7080 | function setProperty() { |
6202 | 7081 | $numargs = func_num_args(); |
6203 | - if( 1 > $numargs ) return FALSE; |
|
7082 | + if( 1 > $numargs ) { |
|
7083 | + return FALSE; |
|
7084 | + } |
|
6204 | 7085 | $arglist = func_get_args(); |
6205 | - if( $this->_notExistProp( $arglist[0] )) return FALSE; |
|
6206 | - if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] ))) |
|
7086 | + if( $this->_notExistProp( $arglist[0] )) { |
|
6207 | 7087 | return FALSE; |
7088 | + } |
|
7089 | + if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] ))) { |
|
7090 | + return FALSE; |
|
7091 | + } |
|
6208 | 7092 | $arglist[0] = strtoupper( $arglist[0] ); |
6209 | 7093 | for( $argix=$numargs; $argix < 12; $argix++ ) { |
6210 | - if( !isset( $arglist[$argix] )) |
|
6211 | - $arglist[$argix] = null; |
|
7094 | + if( !isset( $arglist[$argix] )) { |
|
7095 | + $arglist[$argix] = null; |
|
7096 | + } |
|
6212 | 7097 | } |
6213 | 7098 | switch( $arglist[0] ) { |
6214 | 7099 | case 'ACTION': |
@@ -6322,20 +7207,19 @@ discard block |
||
6322 | 7207 | $this->setComponent( $comp ); |
6323 | 7208 | $comp = & $this; |
6324 | 7209 | continue; |
6325 | - } |
|
6326 | - elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) { |
|
7210 | + } elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) { |
|
6327 | 7211 | $comp = new valarm(); |
6328 | 7212 | continue; |
7213 | + } else { |
|
7214 | + $comp->unparsed[] = $line; |
|
6329 | 7215 | } |
6330 | - else |
|
6331 | - $comp->unparsed[] = $line; |
|
6332 | 7216 | } |
7217 | + } else { |
|
7218 | + $this->unparsed = array( trim( $unparsedtext )); |
|
6333 | 7219 | } |
6334 | - else |
|
6335 | - $this->unparsed = array( trim( $unparsedtext )); |
|
7220 | + } elseif( !isset( $this->unparsed )) { |
|
7221 | + $this->unparsed = array(); |
|
6336 | 7222 | } |
6337 | - elseif( !isset( $this->unparsed )) |
|
6338 | - $this->unparsed = array(); |
|
6339 | 7223 | /* concatenate property values spread over several lines */ |
6340 | 7224 | $lastix = -1; |
6341 | 7225 | $propnames = array( 'action', 'attach', 'attendee', 'categories', 'comment', 'completed' |
@@ -6359,8 +7243,7 @@ discard block |
||
6359 | 7243 | $newProp = FALSE; |
6360 | 7244 | $lastix++; |
6361 | 7245 | $proprows[$lastix] = $line; |
6362 | - } |
|
6363 | - else { |
|
7246 | + } else { |
|
6364 | 7247 | /* remove line breaks */ |
6365 | 7248 | if(( '\n' == substr( $proprows[$lastix], -2 )) && |
6366 | 7249 | ( ' ' == substr( $line, 0, 1 ))) { |
@@ -6373,14 +7256,15 @@ discard block |
||
6373 | 7256 | /* parse each property 'line' */ |
6374 | 7257 | foreach( $proprows as $line ) { |
6375 | 7258 | $line = str_replace( "\n ", '', $line ); |
6376 | - if( '\n' == substr( $line, -2 )) |
|
6377 | - $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
7259 | + if( '\n' == substr( $line, -2 )) { |
|
7260 | + $line = substr( $line, 0, strlen( $line ) - 2 ); |
|
7261 | + } |
|
6378 | 7262 | /* get propname, (problem with x-properties, otherwise in previous loop) */ |
6379 | 7263 | $cix = $propname = null; |
6380 | 7264 | for( $cix=0; $cix < strlen( $line ); $cix++ ) { |
6381 | - if( in_array( $line{$cix}, array( ':', ';' ))) |
|
6382 | - break; |
|
6383 | - else { |
|
7265 | + if( in_array( $line{$cix}, array( ':', ';' ))) { |
|
7266 | + break; |
|
7267 | + } else { |
|
6384 | 7268 | $propname .= $line{$cix}; |
6385 | 7269 | } |
6386 | 7270 | } |
@@ -6413,27 +7297,30 @@ discard block |
||
6413 | 7297 | break; |
6414 | 7298 | } |
6415 | 7299 | } |
6416 | - if( ';' == $line{$cix} ) |
|
6417 | - $attr[++$attrix] = null; |
|
6418 | - else |
|
6419 | - $attr[$attrix] .= $line{$cix}; |
|
7300 | + if( ';' == $line{$cix} ) { |
|
7301 | + $attr[++$attrix] = null; |
|
7302 | + } else { |
|
7303 | + $attr[$attrix] .= $line{$cix}; |
|
7304 | + } |
|
6420 | 7305 | } |
6421 | 7306 | /* make attributes in array format */ |
6422 | 7307 | $propattr = array(); |
6423 | 7308 | foreach( $attr as $attribute ) { |
6424 | 7309 | $attrsplit = explode( '=', $attribute, 2 ); |
6425 | - if( 1 < count( $attrsplit )) |
|
6426 | - $propattr[$attrsplit[0]] = $attrsplit[1]; |
|
6427 | - else |
|
6428 | - $propattr[] = $attribute; |
|
7310 | + if( 1 < count( $attrsplit )) { |
|
7311 | + $propattr[$attrsplit[0]] = $attrsplit[1]; |
|
7312 | + } else { |
|
7313 | + $propattr[] = $attribute; |
|
7314 | + } |
|
6429 | 7315 | } |
6430 | 7316 | /* call setProperty( $propname.. . */ |
6431 | 7317 | switch( $propname ) { |
6432 | 7318 | case 'ATTENDEE': |
6433 | 7319 | foreach( $propattr as $pix => $attr ) { |
6434 | 7320 | $attr2 = explode( ',', $attr ); |
6435 | - if( 1 < count( $attr2 )) |
|
6436 | - $propattr[$pix] = $attr2; |
|
7321 | + if( 1 < count( $attr2 )) { |
|
7322 | + $propattr[$pix] = $attr2; |
|
7323 | + } |
|
6437 | 7324 | } |
6438 | 7325 | $this->setProperty( $propname, $line, $propattr ); |
6439 | 7326 | break; |
@@ -6451,13 +7338,14 @@ discard block |
||
6451 | 7338 | } |
6452 | 7339 | if( 1 < count( $content )) { |
6453 | 7340 | $content = array_values( $content ); |
6454 | - foreach( $content as $cix => $contentPart ) |
|
6455 | - $content[$cix] = $this->_strunrep( $contentPart ); |
|
7341 | + foreach( $content as $cix => $contentPart ) { |
|
7342 | + $content[$cix] = $this->_strunrep( $contentPart ); |
|
7343 | + } |
|
6456 | 7344 | $this->setProperty( $propname, $content, $propattr ); |
6457 | 7345 | break; |
7346 | + } else { |
|
7347 | + $line = reset( $content ); |
|
6458 | 7348 | } |
6459 | - else |
|
6460 | - $line = reset( $content ); |
|
6461 | 7349 | } |
6462 | 7350 | //no break |
6463 | 7351 | case 'X-': |
@@ -6468,8 +7356,9 @@ discard block |
||
6468 | 7356 | case 'DESCRIPTION': |
6469 | 7357 | case 'LOCATION': |
6470 | 7358 | case 'SUMMARY': |
6471 | - if( empty( $line )) |
|
6472 | - $propattr = null; |
|
7359 | + if( empty( $line )) { |
|
7360 | + $propattr = null; |
|
7361 | + } |
|
6473 | 7362 | $this->setProperty( $propname, $this->_strunrep( $line ), $propattr ); |
6474 | 7363 | unset( $propname2 ); |
6475 | 7364 | break; |
@@ -6489,15 +7378,17 @@ discard block |
||
6489 | 7378 | $values = explode( ',', $line ); |
6490 | 7379 | foreach( $values as $vix => $value ) { |
6491 | 7380 | $value2 = explode( '/', $value ); |
6492 | - if( 1 < count( $value2 )) |
|
6493 | - $values[$vix] = $value2; |
|
7381 | + if( 1 < count( $value2 )) { |
|
7382 | + $values[$vix] = $value2; |
|
7383 | + } |
|
6494 | 7384 | } |
6495 | 7385 | $this->setProperty( $propname, $fbtype, $values, $propattr ); |
6496 | 7386 | break; |
6497 | 7387 | case 'GEO': |
6498 | 7388 | $value = explode( ';', $line, 2 ); |
6499 | - if( 2 > count( $value )) |
|
6500 | - $value[1] = null; |
|
7389 | + if( 2 > count( $value )) { |
|
7390 | + $value[1] = null; |
|
7391 | + } |
|
6501 | 7392 | $this->setProperty( $propname, $value[0], $value[1], $propattr ); |
6502 | 7393 | break; |
6503 | 7394 | case 'EXDATE': |
@@ -6512,8 +7403,9 @@ discard block |
||
6512 | 7403 | $values = explode( ',', $line ); |
6513 | 7404 | foreach( $values as $vix => $value ) { |
6514 | 7405 | $value2 = explode( '/', $value ); |
6515 | - if( 1 < count( $value2 )) |
|
6516 | - $values[$vix] = $value2; |
|
7406 | + if( 1 < count( $value2 )) { |
|
7407 | + $values[$vix] = $value2; |
|
7408 | + } |
|
6517 | 7409 | } |
6518 | 7410 | $this->setProperty( $propname, $values, $propattr ); |
6519 | 7411 | break; |
@@ -6522,8 +7414,10 @@ discard block |
||
6522 | 7414 | $values = explode( ';', $line ); |
6523 | 7415 | $recur = array(); |
6524 | 7416 | foreach( $values as $value2 ) { |
6525 | - if( empty( $value2 )) |
|
6526 | - continue; // ;-char in ending position ??? |
|
7417 | + if( empty( $value2 )) { |
|
7418 | + continue; |
|
7419 | + } |
|
7420 | + // ;-char in ending position ??? |
|
6527 | 7421 | $value3 = explode( '=', $value2, 2 ); |
6528 | 7422 | $rulelabel = strtoupper( $value3[0] ); |
6529 | 7423 | switch( $rulelabel ) { |
@@ -6537,37 +7431,43 @@ discard block |
||
6537 | 7431 | if(( ctype_alpha( substr( $value5, -1 ))) && |
6538 | 7432 | ( ctype_alpha( substr( $value5, -2, 1 )))) { |
6539 | 7433 | $dayname = substr( $value5, -2, 2 ); |
6540 | - if( 2 < strlen( $value5 )) |
|
6541 | - $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
7434 | + if( 2 < strlen( $value5 )) { |
|
7435 | + $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
7436 | + } |
|
7437 | + } |
|
7438 | + if( $dayno ) { |
|
7439 | + $value6[] = $dayno; |
|
7440 | + } |
|
7441 | + if( $dayname ) { |
|
7442 | + $value6['DAY'] = $dayname; |
|
6542 | 7443 | } |
6543 | - if( $dayno ) |
|
6544 | - $value6[] = $dayno; |
|
6545 | - if( $dayname ) |
|
6546 | - $value6['DAY'] = $dayname; |
|
6547 | 7444 | $value4[$v5ix] = $value6; |
6548 | 7445 | } |
6549 | - } |
|
6550 | - else { |
|
7446 | + } else { |
|
6551 | 7447 | $value4 = array(); |
6552 | 7448 | $dayno = $dayname = null; |
6553 | 7449 | $value5 = trim( (string) $value3[1] ); |
6554 | 7450 | if(( ctype_alpha( substr( $value5, -1 ))) && |
6555 | 7451 | ( ctype_alpha( substr( $value5, -2, 1 )))) { |
6556 | 7452 | $dayname = substr( $value5, -2, 2 ); |
6557 | - if( 2 < strlen( $value5 )) |
|
6558 | - $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
7453 | + if( 2 < strlen( $value5 )) { |
|
7454 | + $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); |
|
7455 | + } |
|
7456 | + } |
|
7457 | + if( $dayno ) { |
|
7458 | + $value4[] = $dayno; |
|
7459 | + } |
|
7460 | + if( $dayname ) { |
|
7461 | + $value4['DAY'] = $dayname; |
|
6559 | 7462 | } |
6560 | - if( $dayno ) |
|
6561 | - $value4[] = $dayno; |
|
6562 | - if( $dayname ) |
|
6563 | - $value4['DAY'] = $dayname; |
|
6564 | 7463 | } |
6565 | 7464 | $recur[$rulelabel] = $value4; |
6566 | 7465 | break; |
6567 | 7466 | default: |
6568 | 7467 | $value4 = explode( ',', $value3[1] ); |
6569 | - if( 1 < count( $value4 )) |
|
6570 | - $value3[1] = $value4; |
|
7468 | + if( 1 < count( $value4 )) { |
|
7469 | + $value3[1] = $value4; |
|
7470 | + } |
|
6571 | 7471 | $recur[$rulelabel] = $value3[1]; |
6572 | 7472 | break; |
6573 | 7473 | } // end - switch $rulelabel |
@@ -6582,8 +7482,9 @@ discard block |
||
6582 | 7482 | unset( $this->unparsed, $proprows ); |
6583 | 7483 | if( isset( $this->components ) && is_array( $this->components ) && ( 0 < count( $this->components ))) { |
6584 | 7484 | for( $six = 0; $six < count( $this->components ); $six++ ) { |
6585 | - if( !empty( $this->components[$six]->unparsed )) |
|
6586 | - $this->components[$six]->parse(); |
|
7485 | + if( !empty( $this->components[$six]->unparsed )) { |
|
7486 | + $this->components[$six]->parse(); |
|
7487 | + } |
|
6587 | 7488 | } |
6588 | 7489 | } |
6589 | 7490 | } |
@@ -6614,32 +7515,33 @@ discard block |
||
6614 | 7515 | * @return void |
6615 | 7516 | */ |
6616 | 7517 | function deleteComponent( $arg1, $arg2=FALSE ) { |
6617 | - if( !isset( $this->components )) return FALSE; |
|
7518 | + if( !isset( $this->components )) { |
|
7519 | + return FALSE; |
|
7520 | + } |
|
6618 | 7521 | $argType = $index = null; |
6619 | 7522 | if ( ctype_digit( (string) $arg1 )) { |
6620 | 7523 | $argType = 'INDEX'; |
6621 | 7524 | $index = (int) $arg1 - 1; |
6622 | - } |
|
6623 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
7525 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6624 | 7526 | $argType = strtolower( $arg1 ); |
6625 | 7527 | $index = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0; |
6626 | 7528 | } |
6627 | 7529 | $cix2dC = 0; |
6628 | 7530 | foreach ( $this->components as $cix => $component) { |
6629 | - if( empty( $component )) continue; |
|
7531 | + if( empty( $component )) { |
|
7532 | + continue; |
|
7533 | + } |
|
6630 | 7534 | unset( $component->propix ); |
6631 | 7535 | if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
6632 | 7536 | unset( $this->components[$cix] ); |
6633 | 7537 | return TRUE; |
6634 | - } |
|
6635 | - elseif( $argType == $component->objName ) { |
|
7538 | + } elseif( $argType == $component->objName ) { |
|
6636 | 7539 | if( $index == $cix2dC ) { |
6637 | 7540 | unset( $this->components[$cix] ); |
6638 | 7541 | return TRUE; |
6639 | 7542 | } |
6640 | 7543 | $cix2dC++; |
6641 | - } |
|
6642 | - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
7544 | + } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { |
|
6643 | 7545 | unset( $this->components[$cix] ); |
6644 | 7546 | return TRUE; |
6645 | 7547 | } |
@@ -6656,43 +7558,47 @@ discard block |
||
6656 | 7558 | * @return object |
6657 | 7559 | */ |
6658 | 7560 | function getComponent ( $arg1=FALSE, $arg2=FALSE ) { |
6659 | - if( !isset( $this->components )) return FALSE; |
|
7561 | + if( !isset( $this->components )) { |
|
7562 | + return FALSE; |
|
7563 | + } |
|
6660 | 7564 | $index = $argType = null; |
6661 | 7565 | if ( !$arg1 ) { |
6662 | 7566 | $argType = 'INDEX'; |
6663 | 7567 | $index = $this->compix['INDEX'] = |
6664 | 7568 | ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1; |
6665 | - } |
|
6666 | - elseif ( ctype_digit( (string) $arg1 )) { |
|
7569 | + } elseif ( ctype_digit( (string) $arg1 )) { |
|
6667 | 7570 | $argType = 'INDEX'; |
6668 | 7571 | $index = (int) $arg1; |
6669 | 7572 | unset( $this->compix ); |
6670 | - } |
|
6671 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
7573 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6672 | 7574 | unset( $this->compix['INDEX'] ); |
6673 | 7575 | $argType = strtolower( $arg1 ); |
6674 | - if( !$arg2 ) |
|
6675 | - $index = $this->compix[$argType] = |
|
7576 | + if( !$arg2 ) { |
|
7577 | + $index = $this->compix[$argType] = |
|
6676 | 7578 | ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1; |
6677 | - else |
|
6678 | - $index = (int) $arg2; |
|
7579 | + } else { |
|
7580 | + $index = (int) $arg2; |
|
7581 | + } |
|
6679 | 7582 | } |
6680 | 7583 | $index -= 1; |
6681 | 7584 | $ckeys = array_keys( $this->components ); |
6682 | - if( !empty( $index) && ( $index > end( $ckeys ))) |
|
6683 | - return FALSE; |
|
7585 | + if( !empty( $index) && ( $index > end( $ckeys ))) { |
|
7586 | + return FALSE; |
|
7587 | + } |
|
6684 | 7588 | $cix2gC = 0; |
6685 | 7589 | foreach( $this->components as $cix => $component ) { |
6686 | - if( empty( $component )) continue; |
|
7590 | + if( empty( $component )) { |
|
7591 | + continue; |
|
7592 | + } |
|
6687 | 7593 | unset( $component->propix ); |
6688 | - if(( 'INDEX' == $argType ) && ( $index == $cix )) |
|
6689 | - return $component->copy(); |
|
6690 | - elseif( $argType == $component->objName ) { |
|
6691 | - if( $index == $cix2gC ) |
|
6692 | - return $component->copy(); |
|
7594 | + if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
|
7595 | + return $component->copy(); |
|
7596 | + } elseif( $argType == $component->objName ) { |
|
7597 | + if( $index == $cix2gC ) { |
|
7598 | + return $component->copy(); |
|
7599 | + } |
|
6693 | 7600 | $cix2gC++; |
6694 | - } |
|
6695 | - elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) { |
|
7601 | + } elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) { |
|
6696 | 7602 | unset( $component->propix ); |
6697 | 7603 | return $component->copy(); |
6698 | 7604 | } |
@@ -6723,9 +7629,12 @@ discard block |
||
6723 | 7629 | * @return bool |
6724 | 7630 | */ |
6725 | 7631 | function setComponent( $component, $arg1=FALSE, $arg2=FALSE ) { |
6726 | - if( !isset( $this->components )) return FALSE; |
|
6727 | - if( '' >= $component->getConfig( 'language')) |
|
6728 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
7632 | + if( !isset( $this->components )) { |
|
7633 | + return FALSE; |
|
7634 | + } |
|
7635 | + if( '' >= $component->getConfig( 'language')) { |
|
7636 | + $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
7637 | + } |
|
6729 | 7638 | $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
6730 | 7639 | $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
6731 | 7640 | $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
@@ -6744,27 +7653,26 @@ discard block |
||
6744 | 7653 | if ( ctype_digit( (string) $arg1 )) { |
6745 | 7654 | $argType = 'INDEX'; |
6746 | 7655 | $index = (int) $arg1 - 1; |
6747 | - } |
|
6748 | - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
7656 | + } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { |
|
6749 | 7657 | $argType = strtolower( $arg1 ); |
6750 | 7658 | $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0; |
6751 | 7659 | } |
6752 | 7660 | $cix2sC = 0; |
6753 | 7661 | foreach ( $this->components as $cix => $component2 ) { |
6754 | - if( empty( $component2 )) continue; |
|
7662 | + if( empty( $component2 )) { |
|
7663 | + continue; |
|
7664 | + } |
|
6755 | 7665 | unset( $component2->propix ); |
6756 | 7666 | if(( 'INDEX' == $argType ) && ( $index == $cix )) { |
6757 | 7667 | $this->components[$cix] = $component->copy(); |
6758 | 7668 | return TRUE; |
6759 | - } |
|
6760 | - elseif( $argType == $component2->objName ) { |
|
7669 | + } elseif( $argType == $component2->objName ) { |
|
6761 | 7670 | if( $index == $cix2sC ) { |
6762 | 7671 | $this->components[$cix] = $component->copy(); |
6763 | 7672 | return TRUE; |
6764 | 7673 | } |
6765 | 7674 | $cix2sC++; |
6766 | - } |
|
6767 | - elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) { |
|
7675 | + } elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) { |
|
6768 | 7676 | $this->components[$cix] = $component->copy(); |
6769 | 7677 | return TRUE; |
6770 | 7678 | } |
@@ -6783,9 +7691,12 @@ discard block |
||
6783 | 7691 | function createSubComponent() { |
6784 | 7692 | $output = null; |
6785 | 7693 | foreach( $this->components as $component ) { |
6786 | - if( empty( $component )) continue; |
|
6787 | - if( '' >= $component->getConfig( 'language')) |
|
6788 | - $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
7694 | + if( empty( $component )) { |
|
7695 | + continue; |
|
7696 | + } |
|
7697 | + if( '' >= $component->getConfig( 'language')) { |
|
7698 | + $component->setConfig( 'language', $this->getConfig( 'language' )); |
|
7699 | + } |
|
6789 | 7700 | $component->setConfig( 'allowEmpty', $this->getConfig( 'allowEmpty' )); |
6790 | 7701 | $component->setConfig( 'nl', $this->getConfig( 'nl' )); |
6791 | 7702 | $component->setConfig( 'unique_id', $this->getConfig( 'unique_id' )); |
@@ -6823,16 +7734,18 @@ discard block |
||
6823 | 7734 | $string = null; |
6824 | 7735 | while( $strlen > 75 ) { |
6825 | 7736 | $breakAtChar = 75; |
6826 | - if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' ) |
|
6827 | - $breakAtChar = $breakAtChar - 1; |
|
7737 | + if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' ) { |
|
7738 | + $breakAtChar = $breakAtChar - 1; |
|
7739 | + } |
|
6828 | 7740 | $string .= substr( $tmp, 0, $breakAtChar ); |
6829 | 7741 | $string .= $this->nl; |
6830 | 7742 | $tmp = ' '.substr( $tmp, $breakAtChar ); |
6831 | 7743 | $strlen = strlen( $tmp ); |
6832 | 7744 | } // while |
6833 | 7745 | $string .= rtrim( $tmp ); // the rest |
6834 | - if( $this->nl != substr( $string, ( 0 - strlen( $this->nl )))) |
|
6835 | - $string .= $this->nl; |
|
7746 | + if( $this->nl != substr( $string, ( 0 - strlen( $this->nl )))) { |
|
7747 | + $string .= $this->nl; |
|
7748 | + } |
|
6836 | 7749 | return $string; |
6837 | 7750 | } |
6838 | 7751 | /** |
@@ -6853,27 +7766,33 @@ discard block |
||
6853 | 7766 | $pos = 0; |
6854 | 7767 | while( $pos <= strlen( $string )) { |
6855 | 7768 | $pos = strpos( $string, "\\", $pos ); |
6856 | - if( FALSE === $pos ) |
|
6857 | - break; |
|
7769 | + if( FALSE === $pos ) { |
|
7770 | + break; |
|
7771 | + } |
|
6858 | 7772 | if( !in_array( $string{($pos + 1)}, array( 'n', 'N', 'r', ',', ';' ))) { |
6859 | 7773 | $string = substr( $string, 0, $pos )."\\".substr( $string, ( $pos + 1 )); |
6860 | 7774 | $pos += 1; |
6861 | 7775 | } |
6862 | 7776 | $pos += 1; |
6863 | 7777 | } |
6864 | - if( FALSE !== strpos( $string, '"' )) |
|
6865 | - $string = str_replace('"', "'", $string); |
|
6866 | - if( FALSE !== strpos( $string, ',' )) |
|
6867 | - $string = str_replace(',', '\,', $string); |
|
6868 | - if( FALSE !== strpos( $string, ';' )) |
|
6869 | - $string = str_replace(';', '\;', $string); |
|
6870 | - if( FALSE !== strpos( $string, "\r\n" )) |
|
6871 | - $string = str_replace( "\r\n", '\n', $string); |
|
6872 | - elseif( FALSE !== strpos( $string, "\r" )) |
|
6873 | - $string = str_replace( "\r", '\n', $string); |
|
6874 | - if( FALSE !== strpos( $string, '\N' )) |
|
6875 | - $string = str_replace( '\N', '\n', $string); |
|
6876 | -// if( FALSE !== strpos( $string, $this->nl )) |
|
7778 | + if( FALSE !== strpos( $string, '"' )) { |
|
7779 | + $string = str_replace('"', "'", $string); |
|
7780 | + } |
|
7781 | + if( FALSE !== strpos( $string, ',' )) { |
|
7782 | + $string = str_replace(',', '\,', $string); |
|
7783 | + } |
|
7784 | + if( FALSE !== strpos( $string, ';' )) { |
|
7785 | + $string = str_replace(';', '\;', $string); |
|
7786 | + } |
|
7787 | + if( FALSE !== strpos( $string, "\r\n" )) { |
|
7788 | + $string = str_replace( "\r\n", '\n', $string); |
|
7789 | + } elseif( FALSE !== strpos( $string, "\r" )) { |
|
7790 | + $string = str_replace( "\r", '\n', $string); |
|
7791 | + } |
|
7792 | + if( FALSE !== strpos( $string, '\N' )) { |
|
7793 | + $string = str_replace( '\N', '\n', $string); |
|
7794 | + } |
|
7795 | + // if( FALSE !== strpos( $string, $this->nl )) |
|
6877 | 7796 | $string = str_replace( $this->nl, '\n', $string); |
6878 | 7797 | break; |
6879 | 7798 | } |
@@ -7026,8 +7945,9 @@ discard block |
||
7026 | 7945 | $component .= $this->createSubComponent(); |
7027 | 7946 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7028 | 7947 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7029 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7030 | - $xcaldecl[] = $localxcaldecl; |
|
7948 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
7949 | + $xcaldecl[] = $localxcaldecl; |
|
7950 | + } |
|
7031 | 7951 | } |
7032 | 7952 | return $component; |
7033 | 7953 | } |
@@ -7165,8 +8085,9 @@ discard block |
||
7165 | 8085 | $component .= $this->createSubComponent(); |
7166 | 8086 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7167 | 8087 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7168 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7169 | - $xcaldecl[] = $localxcaldecl; |
|
8088 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
8089 | + $xcaldecl[] = $localxcaldecl; |
|
8090 | + } |
|
7170 | 8091 | } |
7171 | 8092 | return $component; |
7172 | 8093 | } |
@@ -7275,8 +8196,9 @@ discard block |
||
7275 | 8196 | $component .= $this->createXprop(); |
7276 | 8197 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7277 | 8198 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7278 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7279 | - $xcaldecl[] = $localxcaldecl; |
|
8199 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
8200 | + $xcaldecl[] = $localxcaldecl; |
|
8201 | + } |
|
7280 | 8202 | } |
7281 | 8203 | return $component; |
7282 | 8204 | } |
@@ -7351,8 +8273,9 @@ discard block |
||
7351 | 8273 | $component .= $this->createXprop(); |
7352 | 8274 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7353 | 8275 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7354 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7355 | - $xcaldecl[] = $localxcaldecl; |
|
8276 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
8277 | + $xcaldecl[] = $localxcaldecl; |
|
8278 | + } |
|
7356 | 8279 | } |
7357 | 8280 | return $component; |
7358 | 8281 | } |
@@ -7452,10 +8375,11 @@ discard block |
||
7452 | 8375 | * @return void |
7453 | 8376 | */ |
7454 | 8377 | function __construct( $timezonetype=FALSE ) { |
7455 | - if( !$timezonetype ) |
|
7456 | - $this->timezonetype = 'VTIMEZONE'; |
|
7457 | - else |
|
7458 | - $this->timezonetype = strtoupper( $timezonetype ); |
|
8378 | + if( !$timezonetype ) { |
|
8379 | + $this->timezonetype = 'VTIMEZONE'; |
|
8380 | + } else { |
|
8381 | + $this->timezonetype = strtoupper( $timezonetype ); |
|
8382 | + } |
|
7459 | 8383 | $this->calendarComponent(); |
7460 | 8384 | |
7461 | 8385 | $this->comment = ''; |
@@ -7497,8 +8421,9 @@ discard block |
||
7497 | 8421 | $component .= $this->createSubComponent(); |
7498 | 8422 | $component .= $this->componentEnd1.$objectname.$this->componentEnd2; |
7499 | 8423 | if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { |
7500 | - foreach( $this->xcaldecl as $localxcaldecl ) |
|
7501 | - $xcaldecl[] = $localxcaldecl; |
|
8424 | + foreach( $this->xcaldecl as $localxcaldecl ) { |
|
8425 | + $xcaldecl[] = $localxcaldecl; |
|
8426 | + } |
|
7502 | 8427 | } |
7503 | 8428 | return $component; |
7504 | 8429 | } |