Passed
Push — 1.10.x ( 04397c...5e25f1 )
by Angel Fernando Quiroz
181:14 queued 130:00
created
main/inc/lib/nusoap/class.soap_val.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -15,90 +15,90 @@
 block discarded – undo
15 15
 * @access   public
16 16
 */
17 17
 class soapval extends nusoap_base {
18
-	/**
19
-	 * The XML element name
20
-	 *
21
-	 * @var string
22
-	 * @access private
23
-	 */
24
-	var $name;
25
-	/**
26
-	 * The XML type name (string or false)
27
-	 *
28
-	 * @var mixed
29
-	 * @access private
30
-	 */
31
-	var $type;
32
-	/**
33
-	 * The PHP value
34
-	 *
35
-	 * @var mixed
36
-	 * @access private
37
-	 */
38
-	var $value;
39
-	/**
40
-	 * The XML element namespace (string or false)
41
-	 *
42
-	 * @var mixed
43
-	 * @access private
44
-	 */
45
-	var $element_ns;
46
-	/**
47
-	 * The XML type namespace (string or false)
48
-	 *
49
-	 * @var mixed
50
-	 * @access private
51
-	 */
52
-	var $type_ns;
53
-	/**
54
-	 * The XML element attributes (array or false)
55
-	 *
56
-	 * @var mixed
57
-	 * @access private
58
-	 */
59
-	var $attributes;
18
+    /**
19
+     * The XML element name
20
+     *
21
+     * @var string
22
+     * @access private
23
+     */
24
+    var $name;
25
+    /**
26
+     * The XML type name (string or false)
27
+     *
28
+     * @var mixed
29
+     * @access private
30
+     */
31
+    var $type;
32
+    /**
33
+     * The PHP value
34
+     *
35
+     * @var mixed
36
+     * @access private
37
+     */
38
+    var $value;
39
+    /**
40
+     * The XML element namespace (string or false)
41
+     *
42
+     * @var mixed
43
+     * @access private
44
+     */
45
+    var $element_ns;
46
+    /**
47
+     * The XML type namespace (string or false)
48
+     *
49
+     * @var mixed
50
+     * @access private
51
+     */
52
+    var $type_ns;
53
+    /**
54
+     * The XML element attributes (array or false)
55
+     *
56
+     * @var mixed
57
+     * @access private
58
+     */
59
+    var $attributes;
60 60
 
61
-	/**
62
-	* constructor
63
-	*
64
-	* @param    string $name optional name
65
-	* @param    mixed $type optional type name
66
-	* @param	mixed $value optional value
67
-	* @param	mixed $element_ns optional namespace of value
68
-	* @param	mixed $type_ns optional namespace of type
69
-	* @param	mixed $attributes associative array of attributes to add to element serialization
70
-	* @access   public
71
-	*/
72
-  	function soapval($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) {
73
-		parent::nusoap_base();
74
-		$this->name = $name;
75
-		$this->type = $type;
76
-		$this->value = $value;
77
-		$this->element_ns = $element_ns;
78
-		$this->type_ns = $type_ns;
79
-		$this->attributes = $attributes;
61
+    /**
62
+     * constructor
63
+     *
64
+     * @param    string $name optional name
65
+     * @param    mixed $type optional type name
66
+     * @param	mixed $value optional value
67
+     * @param	mixed $element_ns optional namespace of value
68
+     * @param	mixed $type_ns optional namespace of type
69
+     * @param	mixed $attributes associative array of attributes to add to element serialization
70
+     * @access   public
71
+     */
72
+        function soapval($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) {
73
+        parent::nusoap_base();
74
+        $this->name = $name;
75
+        $this->type = $type;
76
+        $this->value = $value;
77
+        $this->element_ns = $element_ns;
78
+        $this->type_ns = $type_ns;
79
+        $this->attributes = $attributes;
80 80
     }
81 81
 
82
-	/**
83
-	* return serialized value
84
-	*
85
-	* @param	string $use The WSDL use value (encoded|literal)
86
-	* @return	string XML data
87
-	* @access   public
88
-	*/
89
-	function serialize($use='encoded') {
90
-		return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true);
82
+    /**
83
+     * return serialized value
84
+     *
85
+     * @param	string $use The WSDL use value (encoded|literal)
86
+     * @return	string XML data
87
+     * @access   public
88
+     */
89
+    function serialize($use='encoded') {
90
+        return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true);
91 91
     }
92 92
 
93
-	/**
94
-	* decodes a soapval object into a PHP native type
95
-	*
96
-	* @return	mixed
97
-	* @access   public
98
-	*/
99
-	function decode(){
100
-		return $this->value;
101
-	}
93
+    /**
94
+     * decodes a soapval object into a PHP native type
95
+     *
96
+     * @return	mixed
97
+     * @access   public
98
+     */
99
+    function decode(){
100
+        return $this->value;
101
+    }
102 102
 }
103 103
 
104 104
 
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.soap_transport_http.php 1 patch
Indentation   +1168 added lines, -1168 removed lines patch added patch discarded remove patch
@@ -14,171 +14,171 @@  discard block
 block discarded – undo
14 14
 */
15 15
 class soap_transport_http extends nusoap_base {
16 16
 
17
-	var $url = '';
18
-	var $uri = '';
19
-	var $digest_uri = '';
20
-	var $scheme = '';
21
-	var $host = '';
22
-	var $port = '';
23
-	var $path = '';
24
-	var $request_method = 'POST';
25
-	var $protocol_version = '1.0';
26
-	var $encoding = '';
27
-	var $outgoing_headers = array();
28
-	var $incoming_headers = array();
29
-	var $incoming_cookies = array();
30
-	var $outgoing_payload = '';
31
-	var $incoming_payload = '';
32
-	var $response_status_line;	// HTTP response status line
33
-	var $useSOAPAction = true;
34
-	var $persistentConnection = false;
35
-	var $ch = false;	// cURL handle
36
-	var $ch_options = array();	// cURL custom options
37
-	var $use_curl = false;		// force cURL use
38
-	var $proxy = null;			// proxy information (associative array)
39
-	var $username = '';
40
-	var $password = '';
41
-	var $authtype = '';
42
-	var $digestRequest = array();
43
-	var $certRequest = array();	// keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional)
44
-								// cainfofile: certificate authority file, e.g. '$pathToPemFiles/rootca.pem'
45
-								// sslcertfile: SSL certificate file, e.g. '$pathToPemFiles/mycert.pem'
46
-								// sslkeyfile: SSL key file, e.g. '$pathToPemFiles/mykey.pem'
47
-								// passphrase: SSL key password/passphrase
48
-								// certpassword: SSL certificate password
49
-								// verifypeer: default is 1
50
-								// verifyhost: default is 1
17
+    var $url = '';
18
+    var $uri = '';
19
+    var $digest_uri = '';
20
+    var $scheme = '';
21
+    var $host = '';
22
+    var $port = '';
23
+    var $path = '';
24
+    var $request_method = 'POST';
25
+    var $protocol_version = '1.0';
26
+    var $encoding = '';
27
+    var $outgoing_headers = array();
28
+    var $incoming_headers = array();
29
+    var $incoming_cookies = array();
30
+    var $outgoing_payload = '';
31
+    var $incoming_payload = '';
32
+    var $response_status_line;	// HTTP response status line
33
+    var $useSOAPAction = true;
34
+    var $persistentConnection = false;
35
+    var $ch = false;	// cURL handle
36
+    var $ch_options = array();	// cURL custom options
37
+    var $use_curl = false;		// force cURL use
38
+    var $proxy = null;			// proxy information (associative array)
39
+    var $username = '';
40
+    var $password = '';
41
+    var $authtype = '';
42
+    var $digestRequest = array();
43
+    var $certRequest = array();	// keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional)
44
+                                // cainfofile: certificate authority file, e.g. '$pathToPemFiles/rootca.pem'
45
+                                // sslcertfile: SSL certificate file, e.g. '$pathToPemFiles/mycert.pem'
46
+                                // sslkeyfile: SSL key file, e.g. '$pathToPemFiles/mykey.pem'
47
+                                // passphrase: SSL key password/passphrase
48
+                                // certpassword: SSL certificate password
49
+                                // verifypeer: default is 1
50
+                                // verifyhost: default is 1
51 51
 
52
-	/**
53
-	* constructor
54
-	*
55
-	* @param string $url The URL to which to connect
56
-	* @param array $curl_options User-specified cURL options
57
-	* @param boolean $use_curl Whether to try to force cURL use
58
-	* @access public
59
-	*/
60
-	function soap_transport_http($url, $curl_options = NULL, $use_curl = false){
61
-		parent::nusoap_base();
62
-		$this->debug("ctor url=$url use_curl=$use_curl curl_options:");
63
-		$this->appendDebug($this->varDump($curl_options));
64
-		$this->setURL($url);
65
-		if (is_array($curl_options)) {
66
-			$this->ch_options = $curl_options;
67
-		}
68
-		$this->use_curl = $use_curl;
69
-		preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
70
-		$this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
71
-	}
52
+    /**
53
+     * constructor
54
+     *
55
+     * @param string $url The URL to which to connect
56
+     * @param array $curl_options User-specified cURL options
57
+     * @param boolean $use_curl Whether to try to force cURL use
58
+     * @access public
59
+     */
60
+    function soap_transport_http($url, $curl_options = NULL, $use_curl = false){
61
+        parent::nusoap_base();
62
+        $this->debug("ctor url=$url use_curl=$use_curl curl_options:");
63
+        $this->appendDebug($this->varDump($curl_options));
64
+        $this->setURL($url);
65
+        if (is_array($curl_options)) {
66
+            $this->ch_options = $curl_options;
67
+        }
68
+        $this->use_curl = $use_curl;
69
+        preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
70
+        $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
71
+    }
72 72
 
73
-	/**
74
-	* sets a cURL option
75
-	*
76
-	* @param	mixed $option The cURL option (always integer?)
77
-	* @param	mixed $value The cURL option value
78
-	* @access   private
79
-	*/
80
-	function setCurlOption($option, $value) {
81
-		$this->debug("setCurlOption option=$option, value=");
82
-		$this->appendDebug($this->varDump($value));
83
-		curl_setopt($this->ch, $option, $value);
84
-	}
73
+    /**
74
+     * sets a cURL option
75
+     *
76
+     * @param	mixed $option The cURL option (always integer?)
77
+     * @param	mixed $value The cURL option value
78
+     * @access   private
79
+     */
80
+    function setCurlOption($option, $value) {
81
+        $this->debug("setCurlOption option=$option, value=");
82
+        $this->appendDebug($this->varDump($value));
83
+        curl_setopt($this->ch, $option, $value);
84
+    }
85 85
 
86
-	/**
87
-	* sets an HTTP header
88
-	*
89
-	* @param string $name The name of the header
90
-	* @param string $value The value of the header
91
-	* @access private
92
-	*/
93
-	function setHeader($name, $value) {
94
-		$this->outgoing_headers[$name] = $value;
95
-		$this->debug("set header $name: $value");
96
-	}
86
+    /**
87
+     * sets an HTTP header
88
+     *
89
+     * @param string $name The name of the header
90
+     * @param string $value The value of the header
91
+     * @access private
92
+     */
93
+    function setHeader($name, $value) {
94
+        $this->outgoing_headers[$name] = $value;
95
+        $this->debug("set header $name: $value");
96
+    }
97 97
 
98
-	/**
99
-	* unsets an HTTP header
100
-	*
101
-	* @param string $name The name of the header
102
-	* @access private
103
-	*/
104
-	function unsetHeader($name) {
105
-		if (isset($this->outgoing_headers[$name])) {
106
-			$this->debug("unset header $name");
107
-			unset($this->outgoing_headers[$name]);
108
-		}
109
-	}
98
+    /**
99
+     * unsets an HTTP header
100
+     *
101
+     * @param string $name The name of the header
102
+     * @access private
103
+     */
104
+    function unsetHeader($name) {
105
+        if (isset($this->outgoing_headers[$name])) {
106
+            $this->debug("unset header $name");
107
+            unset($this->outgoing_headers[$name]);
108
+        }
109
+    }
110 110
 
111
-	/**
112
-	* sets the URL to which to connect
113
-	*
114
-	* @param string $url The URL to which to connect
115
-	* @access private
116
-	*/
117
-	function setURL($url) {
118
-		$this->url = $url;
111
+    /**
112
+     * sets the URL to which to connect
113
+     *
114
+     * @param string $url The URL to which to connect
115
+     * @access private
116
+     */
117
+    function setURL($url) {
118
+        $this->url = $url;
119 119
 
120
-		$u = parse_url($url);
121
-		foreach($u as $k => $v){
122
-			$this->debug("parsed URL $k = $v");
123
-			$this->$k = $v;
124
-		}
120
+        $u = parse_url($url);
121
+        foreach($u as $k => $v){
122
+            $this->debug("parsed URL $k = $v");
123
+            $this->$k = $v;
124
+        }
125 125
 		
126
-		// add any GET params to path
127
-		if(isset($u['query']) && $u['query'] != ''){
126
+        // add any GET params to path
127
+        if(isset($u['query']) && $u['query'] != ''){
128 128
             $this->path .= '?' . $u['query'];
129
-		}
129
+        }
130 130
 		
131
-		// set default port
132
-		if(!isset($u['port'])){
133
-			if($u['scheme'] == 'https'){
134
-				$this->port = 443;
135
-			} else {
136
-				$this->port = 80;
137
-			}
138
-		}
131
+        // set default port
132
+        if(!isset($u['port'])){
133
+            if($u['scheme'] == 'https'){
134
+                $this->port = 443;
135
+            } else {
136
+                $this->port = 80;
137
+            }
138
+        }
139 139
 		
140
-		$this->uri = $this->path;
141
-		$this->digest_uri = $this->uri;
140
+        $this->uri = $this->path;
141
+        $this->digest_uri = $this->uri;
142 142
 		
143
-		// build headers
144
-		if (!isset($u['port'])) {
145
-			$this->setHeader('Host', $this->host);
146
-		} else {
147
-			$this->setHeader('Host', $this->host.':'.$this->port);
148
-		}
143
+        // build headers
144
+        if (!isset($u['port'])) {
145
+            $this->setHeader('Host', $this->host);
146
+        } else {
147
+            $this->setHeader('Host', $this->host.':'.$this->port);
148
+        }
149 149
 
150
-		if (isset($u['user']) && $u['user'] != '') {
151
-			$this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : '');
152
-		}
153
-	}
150
+        if (isset($u['user']) && $u['user'] != '') {
151
+            $this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : '');
152
+        }
153
+    }
154 154
 
155
-	/**
156
-	* gets the I/O method to use
157
-	*
158
-	* @return	string	I/O method to use (socket|curl|unknown)
159
-	* @access	private
160
-	*/
161
-	function io_method() {
162
-		if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm'))
163
-			return 'curl';
164
-		if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm'))
165
-			return 'socket';
166
-		return 'unknown';
167
-	}
155
+    /**
156
+     * gets the I/O method to use
157
+     *
158
+     * @return	string	I/O method to use (socket|curl|unknown)
159
+     * @access	private
160
+     */
161
+    function io_method() {
162
+        if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm'))
163
+            return 'curl';
164
+        if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm'))
165
+            return 'socket';
166
+        return 'unknown';
167
+    }
168 168
 
169
-	/**
170
-	* establish an HTTP connection
171
-	*
172
-	* @param    integer $timeout set connection timeout in seconds
173
-	* @param	integer $response_timeout set response timeout in seconds
174
-	* @return	boolean true if connected, false if not
175
-	* @access   private
176
-	*/
177
-	function connect($connection_timeout=0,$response_timeout=30){
178
-	  	// For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like
179
-	  	// "regular" socket.
180
-	  	// TODO: disabled for now because OpenSSL must be *compiled* in (not just
181
-	  	//       loaded), and until PHP5 stream_get_wrappers is not available.
169
+    /**
170
+     * establish an HTTP connection
171
+     *
172
+     * @param    integer $timeout set connection timeout in seconds
173
+     * @param	integer $response_timeout set response timeout in seconds
174
+     * @return	boolean true if connected, false if not
175
+     * @access   private
176
+     */
177
+    function connect($connection_timeout=0,$response_timeout=30){
178
+            // For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like
179
+            // "regular" socket.
180
+            // TODO: disabled for now because OpenSSL must be *compiled* in (not just
181
+            //       loaded), and until PHP5 stream_get_wrappers is not available.
182 182
 //	  	if ($this->scheme == 'https') {
183 183
 //		  	if (version_compare(phpversion(), '4.3.0') >= 0) {
184 184
 //		  		if (extension_loaded('openssl')) {
@@ -187,1120 +187,1120 @@  discard block
 block discarded – undo
187 187
 //		  		}
188 188
 //		  	}
189 189
 //		}
190
-		$this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port");
191
-	  if ($this->io_method() == 'socket') {
192
-		if (!is_array($this->proxy)) {
193
-			$host = $this->host;
194
-			$port = $this->port;
195
-		} else {
196
-			$host = $this->proxy['host'];
197
-			$port = $this->proxy['port'];
198
-		}
190
+        $this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port");
191
+        if ($this->io_method() == 'socket') {
192
+        if (!is_array($this->proxy)) {
193
+            $host = $this->host;
194
+            $port = $this->port;
195
+        } else {
196
+            $host = $this->proxy['host'];
197
+            $port = $this->proxy['port'];
198
+        }
199 199
 
200
-		// use persistent connection
201
-		if($this->persistentConnection && isset($this->fp) && is_resource($this->fp)){
202
-			if (!feof($this->fp)) {
203
-				$this->debug('Re-use persistent connection');
204
-				return true;
205
-			}
206
-			fclose($this->fp);
207
-			$this->debug('Closed persistent connection at EOF');
208
-		}
200
+        // use persistent connection
201
+        if($this->persistentConnection && isset($this->fp) && is_resource($this->fp)){
202
+            if (!feof($this->fp)) {
203
+                $this->debug('Re-use persistent connection');
204
+                return true;
205
+            }
206
+            fclose($this->fp);
207
+            $this->debug('Closed persistent connection at EOF');
208
+        }
209 209
 
210
-		// munge host if using OpenSSL
211
-		if ($this->scheme == 'ssl') {
212
-			$host = 'ssl://' . $host;
213
-		}
214
-		$this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout);
210
+        // munge host if using OpenSSL
211
+        if ($this->scheme == 'ssl') {
212
+            $host = 'ssl://' . $host;
213
+        }
214
+        $this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout);
215 215
 
216
-		// open socket
217
-		if($connection_timeout > 0){
218
-			$this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str, $connection_timeout);
219
-		} else {
220
-			$this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str);
221
-		}
216
+        // open socket
217
+        if($connection_timeout > 0){
218
+            $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str, $connection_timeout);
219
+        } else {
220
+            $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str);
221
+        }
222 222
 		
223
-		// test pointer
224
-		if(!$this->fp) {
225
-			$msg = 'Couldn\'t open socket connection to server ' . $this->url;
226
-			if ($this->errno) {
227
-				$msg .= ', Error ('.$this->errno.'): '.$this->error_str;
228
-			} else {
229
-				$msg .= ' prior to connect().  This is often a problem looking up the host name.';
230
-			}
231
-			$this->debug($msg);
232
-			$this->setError($msg);
233
-			return false;
234
-		}
223
+        // test pointer
224
+        if(!$this->fp) {
225
+            $msg = 'Couldn\'t open socket connection to server ' . $this->url;
226
+            if ($this->errno) {
227
+                $msg .= ', Error ('.$this->errno.'): '.$this->error_str;
228
+            } else {
229
+                $msg .= ' prior to connect().  This is often a problem looking up the host name.';
230
+            }
231
+            $this->debug($msg);
232
+            $this->setError($msg);
233
+            return false;
234
+        }
235 235
 		
236
-		// set response timeout
237
-		$this->debug('set response timeout to ' . $response_timeout);
238
-		socket_set_timeout( $this->fp, $response_timeout);
236
+        // set response timeout
237
+        $this->debug('set response timeout to ' . $response_timeout);
238
+        socket_set_timeout( $this->fp, $response_timeout);
239 239
 
240
-		$this->debug('socket connected');
241
-		return true;
242
-	  } else if ($this->io_method() == 'curl') {
243
-		if (!extension_loaded('curl')) {
240
+        $this->debug('socket connected');
241
+        return true;
242
+        } else if ($this->io_method() == 'curl') {
243
+        if (!extension_loaded('curl')) {
244 244
 //			$this->setError('cURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS');
245
-			$this->setError('The PHP cURL Extension is required for HTTPS or NLTM.  You will need to re-build or update your PHP to include cURL or change php.ini to load the PHP cURL extension.');
246
-			return false;
247
-		}
248
-		// Avoid warnings when PHP does not have these options
249
-		if (defined('CURLOPT_CONNECTIONTIMEOUT'))
250
-			$CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
251
-		else
252
-			$CURLOPT_CONNECTIONTIMEOUT = 78;
253
-		if (defined('CURLOPT_HTTPAUTH'))
254
-			$CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
255
-		else
256
-			$CURLOPT_HTTPAUTH = 107;
257
-		if (defined('CURLOPT_PROXYAUTH'))
258
-			$CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
259
-		else
260
-			$CURLOPT_PROXYAUTH = 111;
261
-		if (defined('CURLAUTH_BASIC'))
262
-			$CURLAUTH_BASIC = CURLAUTH_BASIC;
263
-		else
264
-			$CURLAUTH_BASIC = 1;
265
-		if (defined('CURLAUTH_DIGEST'))
266
-			$CURLAUTH_DIGEST = CURLAUTH_DIGEST;
267
-		else
268
-			$CURLAUTH_DIGEST = 2;
269
-		if (defined('CURLAUTH_NTLM'))
270
-			$CURLAUTH_NTLM = CURLAUTH_NTLM;
271
-		else
272
-			$CURLAUTH_NTLM = 8;
245
+            $this->setError('The PHP cURL Extension is required for HTTPS or NLTM.  You will need to re-build or update your PHP to include cURL or change php.ini to load the PHP cURL extension.');
246
+            return false;
247
+        }
248
+        // Avoid warnings when PHP does not have these options
249
+        if (defined('CURLOPT_CONNECTIONTIMEOUT'))
250
+            $CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
251
+        else
252
+            $CURLOPT_CONNECTIONTIMEOUT = 78;
253
+        if (defined('CURLOPT_HTTPAUTH'))
254
+            $CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
255
+        else
256
+            $CURLOPT_HTTPAUTH = 107;
257
+        if (defined('CURLOPT_PROXYAUTH'))
258
+            $CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
259
+        else
260
+            $CURLOPT_PROXYAUTH = 111;
261
+        if (defined('CURLAUTH_BASIC'))
262
+            $CURLAUTH_BASIC = CURLAUTH_BASIC;
263
+        else
264
+            $CURLAUTH_BASIC = 1;
265
+        if (defined('CURLAUTH_DIGEST'))
266
+            $CURLAUTH_DIGEST = CURLAUTH_DIGEST;
267
+        else
268
+            $CURLAUTH_DIGEST = 2;
269
+        if (defined('CURLAUTH_NTLM'))
270
+            $CURLAUTH_NTLM = CURLAUTH_NTLM;
271
+        else
272
+            $CURLAUTH_NTLM = 8;
273 273
 
274
-		$this->debug('connect using cURL');
275
-		// init CURL
276
-		$this->ch = curl_init();
277
-		// set url
278
-		$hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host";
279
-		// add path
280
-		$hostURL .= $this->path;
281
-		$this->setCurlOption(CURLOPT_URL, $hostURL);
282
-		// follow location headers (re-directs)
283
-		if (ini_get('safe_mode') || ini_get('open_basedir')) {
284
-			$this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION');
285
-			$this->debug('safe_mode = ');
286
-			$this->appendDebug($this->varDump(ini_get('safe_mode')));
287
-			$this->debug('open_basedir = ');
288
-			$this->appendDebug($this->varDump(ini_get('open_basedir')));
289
-		} else {
290
-			$this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1);
291
-		}
292
-		// ask for headers in the response output
293
-		$this->setCurlOption(CURLOPT_HEADER, 1);
294
-		// ask for the response output as the return value
295
-		$this->setCurlOption(CURLOPT_RETURNTRANSFER, 1);
296
-		// encode
297
-		// We manage this ourselves through headers and encoding
274
+        $this->debug('connect using cURL');
275
+        // init CURL
276
+        $this->ch = curl_init();
277
+        // set url
278
+        $hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host";
279
+        // add path
280
+        $hostURL .= $this->path;
281
+        $this->setCurlOption(CURLOPT_URL, $hostURL);
282
+        // follow location headers (re-directs)
283
+        if (ini_get('safe_mode') || ini_get('open_basedir')) {
284
+            $this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION');
285
+            $this->debug('safe_mode = ');
286
+            $this->appendDebug($this->varDump(ini_get('safe_mode')));
287
+            $this->debug('open_basedir = ');
288
+            $this->appendDebug($this->varDump(ini_get('open_basedir')));
289
+        } else {
290
+            $this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1);
291
+        }
292
+        // ask for headers in the response output
293
+        $this->setCurlOption(CURLOPT_HEADER, 1);
294
+        // ask for the response output as the return value
295
+        $this->setCurlOption(CURLOPT_RETURNTRANSFER, 1);
296
+        // encode
297
+        // We manage this ourselves through headers and encoding
298 298
 //		if(function_exists('gzuncompress')){
299 299
 //			$this->setCurlOption(CURLOPT_ENCODING, 'deflate');
300 300
 //		}
301
-		// persistent connection
302
-		if ($this->persistentConnection) {
303
-			// I believe the following comment is now bogus, having applied to
304
-			// the code when it used CURLOPT_CUSTOMREQUEST to send the request.
305
-			// The way we send data, we cannot use persistent connections, since
306
-			// there will be some "junk" at the end of our request.
307
-			//$this->setCurlOption(CURL_HTTP_VERSION_1_1, true);
308
-			$this->persistentConnection = false;
309
-			$this->setHeader('Connection', 'close');
310
-		}
311
-		// set timeouts
312
-		if ($connection_timeout != 0) {
313
-			$this->setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout);
314
-		}
315
-		if ($response_timeout != 0) {
316
-			$this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout);
317
-		}
301
+        // persistent connection
302
+        if ($this->persistentConnection) {
303
+            // I believe the following comment is now bogus, having applied to
304
+            // the code when it used CURLOPT_CUSTOMREQUEST to send the request.
305
+            // The way we send data, we cannot use persistent connections, since
306
+            // there will be some "junk" at the end of our request.
307
+            //$this->setCurlOption(CURL_HTTP_VERSION_1_1, true);
308
+            $this->persistentConnection = false;
309
+            $this->setHeader('Connection', 'close');
310
+        }
311
+        // set timeouts
312
+        if ($connection_timeout != 0) {
313
+            $this->setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout);
314
+        }
315
+        if ($response_timeout != 0) {
316
+            $this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout);
317
+        }
318 318
 
319
-		if ($this->scheme == 'https') {
320
-			$this->debug('set cURL SSL verify options');
321
-			// recent versions of cURL turn on peer/host checking by default,
322
-			// while PHP binaries are not compiled with a default location for the
323
-			// CA cert bundle, so disable peer/host checking.
324
-			//$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt');		
325
-			$this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
326
-			$this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
319
+        if ($this->scheme == 'https') {
320
+            $this->debug('set cURL SSL verify options');
321
+            // recent versions of cURL turn on peer/host checking by default,
322
+            // while PHP binaries are not compiled with a default location for the
323
+            // CA cert bundle, so disable peer/host checking.
324
+            //$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt');		
325
+            $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
326
+            $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
327 327
 	
328
-			// support client certificates (thanks Tobias Boes, Doug Anarino, Eryan Ariobowo)
329
-			if ($this->authtype == 'certificate') {
330
-				$this->debug('set cURL certificate options');
331
-				if (isset($this->certRequest['cainfofile'])) {
332
-					$this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']);
333
-				}
334
-				if (isset($this->certRequest['verifypeer'])) {
335
-					$this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']);
336
-				} else {
337
-					$this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1);
338
-				}
339
-				if (isset($this->certRequest['verifyhost'])) {
340
-					$this->setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']);
341
-				} else {
342
-					$this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1);
343
-				}
344
-				if (isset($this->certRequest['sslcertfile'])) {
345
-					$this->setCurlOption(CURLOPT_SSLCERT, $this->certRequest['sslcertfile']);
346
-				}
347
-				if (isset($this->certRequest['sslkeyfile'])) {
348
-					$this->setCurlOption(CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']);
349
-				}
350
-				if (isset($this->certRequest['passphrase'])) {
351
-					$this->setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest['passphrase']);
352
-				}
353
-				if (isset($this->certRequest['certpassword'])) {
354
-					$this->setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest['certpassword']);
355
-				}
356
-			}
357
-		}
358
-		if ($this->authtype && ($this->authtype != 'certificate')) {
359
-			if ($this->username) {
360
-				$this->debug('set cURL username/password');
361
-				$this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password");
362
-			}
363
-			if ($this->authtype == 'basic') {
364
-				$this->debug('set cURL for Basic authentication');
365
-				$this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC);
366
-			}
367
-			if ($this->authtype == 'digest') {
368
-				$this->debug('set cURL for digest authentication');
369
-				$this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST);
370
-			}
371
-			if ($this->authtype == 'ntlm') {
372
-				$this->debug('set cURL for NTLM authentication');
373
-				$this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM);
374
-			}
375
-		}
376
-		if (is_array($this->proxy)) {
377
-			$this->debug('set cURL proxy options');
378
-			if ($this->proxy['port'] != '') {
379
-				$this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'].':'.$this->proxy['port']);
380
-			} else {
381
-				$this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']);
382
-			}
383
-			if ($this->proxy['username'] || $this->proxy['password']) {
384
-				$this->debug('set cURL proxy authentication options');
385
-				$this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'].':'.$this->proxy['password']);
386
-				if ($this->proxy['authtype'] == 'basic') {
387
-					$this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC);
388
-				}
389
-				if ($this->proxy['authtype'] == 'ntlm') {
390
-					$this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM);
391
-				}
392
-			}
393
-		}
394
-		$this->debug('cURL connection set up');
395
-		return true;
396
-	  } else {
397
-		$this->setError('Unknown scheme ' . $this->scheme);
398
-		$this->debug('Unknown scheme ' . $this->scheme);
399
-		return false;
400
-	  }
401
-	}
328
+            // support client certificates (thanks Tobias Boes, Doug Anarino, Eryan Ariobowo)
329
+            if ($this->authtype == 'certificate') {
330
+                $this->debug('set cURL certificate options');
331
+                if (isset($this->certRequest['cainfofile'])) {
332
+                    $this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']);
333
+                }
334
+                if (isset($this->certRequest['verifypeer'])) {
335
+                    $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']);
336
+                } else {
337
+                    $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1);
338
+                }
339
+                if (isset($this->certRequest['verifyhost'])) {
340
+                    $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']);
341
+                } else {
342
+                    $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1);
343
+                }
344
+                if (isset($this->certRequest['sslcertfile'])) {
345
+                    $this->setCurlOption(CURLOPT_SSLCERT, $this->certRequest['sslcertfile']);
346
+                }
347
+                if (isset($this->certRequest['sslkeyfile'])) {
348
+                    $this->setCurlOption(CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']);
349
+                }
350
+                if (isset($this->certRequest['passphrase'])) {
351
+                    $this->setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest['passphrase']);
352
+                }
353
+                if (isset($this->certRequest['certpassword'])) {
354
+                    $this->setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest['certpassword']);
355
+                }
356
+            }
357
+        }
358
+        if ($this->authtype && ($this->authtype != 'certificate')) {
359
+            if ($this->username) {
360
+                $this->debug('set cURL username/password');
361
+                $this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password");
362
+            }
363
+            if ($this->authtype == 'basic') {
364
+                $this->debug('set cURL for Basic authentication');
365
+                $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC);
366
+            }
367
+            if ($this->authtype == 'digest') {
368
+                $this->debug('set cURL for digest authentication');
369
+                $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST);
370
+            }
371
+            if ($this->authtype == 'ntlm') {
372
+                $this->debug('set cURL for NTLM authentication');
373
+                $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM);
374
+            }
375
+        }
376
+        if (is_array($this->proxy)) {
377
+            $this->debug('set cURL proxy options');
378
+            if ($this->proxy['port'] != '') {
379
+                $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'].':'.$this->proxy['port']);
380
+            } else {
381
+                $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']);
382
+            }
383
+            if ($this->proxy['username'] || $this->proxy['password']) {
384
+                $this->debug('set cURL proxy authentication options');
385
+                $this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'].':'.$this->proxy['password']);
386
+                if ($this->proxy['authtype'] == 'basic') {
387
+                    $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC);
388
+                }
389
+                if ($this->proxy['authtype'] == 'ntlm') {
390
+                    $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM);
391
+                }
392
+            }
393
+        }
394
+        $this->debug('cURL connection set up');
395
+        return true;
396
+        } else {
397
+        $this->setError('Unknown scheme ' . $this->scheme);
398
+        $this->debug('Unknown scheme ' . $this->scheme);
399
+        return false;
400
+        }
401
+    }
402 402
 
403
-	/**
404
-	* sends the SOAP request and gets the SOAP response via HTTP[S]
405
-	*
406
-	* @param    string $data message data
407
-	* @param    integer $timeout set connection timeout in seconds
408
-	* @param	integer $response_timeout set response timeout in seconds
409
-	* @param	array $cookies cookies to send
410
-	* @return	string data
411
-	* @access   public
412
-	*/
413
-	function send($data, $timeout=0, $response_timeout=30, $cookies=NULL) {
403
+    /**
404
+     * sends the SOAP request and gets the SOAP response via HTTP[S]
405
+     *
406
+     * @param    string $data message data
407
+     * @param    integer $timeout set connection timeout in seconds
408
+     * @param	integer $response_timeout set response timeout in seconds
409
+     * @param	array $cookies cookies to send
410
+     * @return	string data
411
+     * @access   public
412
+     */
413
+    function send($data, $timeout=0, $response_timeout=30, $cookies=NULL) {
414 414
 		
415
-		$this->debug('entered send() with data of length: '.strlen($data));
415
+        $this->debug('entered send() with data of length: '.strlen($data));
416 416
 
417
-		$this->tryagain = true;
418
-		$tries = 0;
419
-		while ($this->tryagain) {
420
-			$this->tryagain = false;
421
-			if ($tries++ < 2) {
422
-				// make connnection
423
-				if (!$this->connect($timeout, $response_timeout)){
424
-					return false;
425
-				}
417
+        $this->tryagain = true;
418
+        $tries = 0;
419
+        while ($this->tryagain) {
420
+            $this->tryagain = false;
421
+            if ($tries++ < 2) {
422
+                // make connnection
423
+                if (!$this->connect($timeout, $response_timeout)){
424
+                    return false;
425
+                }
426 426
 				
427
-				// send request
428
-				if (!$this->sendRequest($data, $cookies)){
429
-					return false;
430
-				}
427
+                // send request
428
+                if (!$this->sendRequest($data, $cookies)){
429
+                    return false;
430
+                }
431 431
 				
432
-				// get response
433
-				$respdata = $this->getResponse();
434
-			} else {
435
-				$this->setError("Too many tries to get an OK response ($this->response_status_line)");
436
-			}
437
-		}		
438
-		$this->debug('end of send()');
439
-		return $respdata;
440
-	}
432
+                // get response
433
+                $respdata = $this->getResponse();
434
+            } else {
435
+                $this->setError("Too many tries to get an OK response ($this->response_status_line)");
436
+            }
437
+        }		
438
+        $this->debug('end of send()');
439
+        return $respdata;
440
+    }
441 441
 
442 442
 
443
-	/**
444
-	* sends the SOAP request and gets the SOAP response via HTTPS using CURL
445
-	*
446
-	* @param    string $data message data
447
-	* @param    integer $timeout set connection timeout in seconds
448
-	* @param	integer $response_timeout set response timeout in seconds
449
-	* @param	array $cookies cookies to send
450
-	* @return	string data
451
-	* @access   public
452
-	* @deprecated
453
-	*/
454
-	function sendHTTPS($data, $timeout=0, $response_timeout=30, $cookies) {
455
-		return $this->send($data, $timeout, $response_timeout, $cookies);
456
-	}
443
+    /**
444
+     * sends the SOAP request and gets the SOAP response via HTTPS using CURL
445
+     *
446
+     * @param    string $data message data
447
+     * @param    integer $timeout set connection timeout in seconds
448
+     * @param	integer $response_timeout set response timeout in seconds
449
+     * @param	array $cookies cookies to send
450
+     * @return	string data
451
+     * @access   public
452
+     * @deprecated
453
+     */
454
+    function sendHTTPS($data, $timeout=0, $response_timeout=30, $cookies) {
455
+        return $this->send($data, $timeout, $response_timeout, $cookies);
456
+    }
457 457
 	
458
-	/**
459
-	* if authenticating, set user credentials here
460
-	*
461
-	* @param    string $username
462
-	* @param    string $password
463
-	* @param	string $authtype (basic|digest|certificate|ntlm)
464
-	* @param	array $digestRequest (keys must be nonce, nc, realm, qop)
465
-	* @param	array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
466
-	* @access   public
467
-	*/
468
-	function setCredentials($username, $password, $authtype = 'basic', $digestRequest = array(), $certRequest = array()) {
469
-		$this->debug("setCredentials username=$username authtype=$authtype digestRequest=");
470
-		$this->appendDebug($this->varDump($digestRequest));
471
-		$this->debug("certRequest=");
472
-		$this->appendDebug($this->varDump($certRequest));
473
-		// cf. RFC 2617
474
-		if ($authtype == 'basic') {
475
-			$this->setHeader('Authorization', 'Basic '.base64_encode(str_replace(':','',$username).':'.$password));
476
-		} elseif ($authtype == 'digest') {
477
-			if (isset($digestRequest['nonce'])) {
478
-				$digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1;
458
+    /**
459
+     * if authenticating, set user credentials here
460
+     *
461
+     * @param    string $username
462
+     * @param    string $password
463
+     * @param	string $authtype (basic|digest|certificate|ntlm)
464
+     * @param	array $digestRequest (keys must be nonce, nc, realm, qop)
465
+     * @param	array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
466
+     * @access   public
467
+     */
468
+    function setCredentials($username, $password, $authtype = 'basic', $digestRequest = array(), $certRequest = array()) {
469
+        $this->debug("setCredentials username=$username authtype=$authtype digestRequest=");
470
+        $this->appendDebug($this->varDump($digestRequest));
471
+        $this->debug("certRequest=");
472
+        $this->appendDebug($this->varDump($certRequest));
473
+        // cf. RFC 2617
474
+        if ($authtype == 'basic') {
475
+            $this->setHeader('Authorization', 'Basic '.base64_encode(str_replace(':','',$username).':'.$password));
476
+        } elseif ($authtype == 'digest') {
477
+            if (isset($digestRequest['nonce'])) {
478
+                $digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1;
479 479
 				
480
-				// calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html)
480
+                // calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html)
481 481
 	
482
-				// A1 = unq(username-value) ":" unq(realm-value) ":" passwd
483
-				$A1 = $username. ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password;
482
+                // A1 = unq(username-value) ":" unq(realm-value) ":" passwd
483
+                $A1 = $username. ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password;
484 484
 	
485
-				// H(A1) = MD5(A1)
486
-				$HA1 = md5($A1);
485
+                // H(A1) = MD5(A1)
486
+                $HA1 = md5($A1);
487 487
 	
488
-				// A2 = Method ":" digest-uri-value
489
-				$A2 = $this->request_method . ':' . $this->digest_uri;
488
+                // A2 = Method ":" digest-uri-value
489
+                $A2 = $this->request_method . ':' . $this->digest_uri;
490 490
 	
491
-				// H(A2)
492
-				$HA2 =  md5($A2);
491
+                // H(A2)
492
+                $HA2 =  md5($A2);
493 493
 	
494
-				// KD(secret, data) = H(concat(secret, ":", data))
495
-				// if qop == auth:
496
-				// request-digest  = <"> < KD ( H(A1),     unq(nonce-value)
497
-				//                              ":" nc-value
498
-				//                              ":" unq(cnonce-value)
499
-				//                              ":" unq(qop-value)
500
-				//                              ":" H(A2)
501
-				//                            ) <">
502
-				// if qop is missing,
503
-				// request-digest  = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <">
494
+                // KD(secret, data) = H(concat(secret, ":", data))
495
+                // if qop == auth:
496
+                // request-digest  = <"> < KD ( H(A1),     unq(nonce-value)
497
+                //                              ":" nc-value
498
+                //                              ":" unq(cnonce-value)
499
+                //                              ":" unq(qop-value)
500
+                //                              ":" H(A2)
501
+                //                            ) <">
502
+                // if qop is missing,
503
+                // request-digest  = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <">
504 504
 	
505
-				$unhashedDigest = '';
506
-				$nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : '';
507
-				$cnonce = $nonce;
508
-				if ($digestRequest['qop'] != '') {
509
-					$unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2;
510
-				} else {
511
-					$unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2;
512
-				}
505
+                $unhashedDigest = '';
506
+                $nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : '';
507
+                $cnonce = $nonce;
508
+                if ($digestRequest['qop'] != '') {
509
+                    $unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2;
510
+                } else {
511
+                    $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2;
512
+                }
513 513
 	
514
-				$hashedDigest = md5($unhashedDigest);
514
+                $hashedDigest = md5($unhashedDigest);
515 515
 	
516
-				$opaque = '';	
517
-				if (isset($digestRequest['opaque'])) {
518
-					$opaque = ', opaque="' . $digestRequest['opaque'] . '"';
519
-				}
516
+                $opaque = '';	
517
+                if (isset($digestRequest['opaque'])) {
518
+                    $opaque = ', opaque="' . $digestRequest['opaque'] . '"';
519
+                }
520 520
 
521
-				$this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf("%08x", $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"');
522
-			}
523
-		} elseif ($authtype == 'certificate') {
524
-			$this->certRequest = $certRequest;
525
-			$this->debug('Authorization header not set for certificate');
526
-		} elseif ($authtype == 'ntlm') {
527
-			// do nothing
528
-			$this->debug('Authorization header not set for ntlm');
529
-		}
530
-		$this->username = $username;
531
-		$this->password = $password;
532
-		$this->authtype = $authtype;
533
-		$this->digestRequest = $digestRequest;
534
-	}
521
+                $this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf("%08x", $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"');
522
+            }
523
+        } elseif ($authtype == 'certificate') {
524
+            $this->certRequest = $certRequest;
525
+            $this->debug('Authorization header not set for certificate');
526
+        } elseif ($authtype == 'ntlm') {
527
+            // do nothing
528
+            $this->debug('Authorization header not set for ntlm');
529
+        }
530
+        $this->username = $username;
531
+        $this->password = $password;
532
+        $this->authtype = $authtype;
533
+        $this->digestRequest = $digestRequest;
534
+    }
535 535
 	
536
-	/**
537
-	* set the soapaction value
538
-	*
539
-	* @param    string $soapaction
540
-	* @access   public
541
-	*/
542
-	function setSOAPAction($soapaction) {
543
-		$this->setHeader('SOAPAction', '"' . $soapaction . '"');
544
-	}
536
+    /**
537
+     * set the soapaction value
538
+     *
539
+     * @param    string $soapaction
540
+     * @access   public
541
+     */
542
+    function setSOAPAction($soapaction) {
543
+        $this->setHeader('SOAPAction', '"' . $soapaction . '"');
544
+    }
545 545
 	
546
-	/**
547
-	* use http encoding
548
-	*
549
-	* @param    string $enc encoding style. supported values: gzip, deflate, or both
550
-	* @access   public
551
-	*/
552
-	function setEncoding($enc='gzip, deflate') {
553
-		if (function_exists('gzdeflate')) {
554
-			$this->protocol_version = '1.1';
555
-			$this->setHeader('Accept-Encoding', $enc);
556
-			if (!isset($this->outgoing_headers['Connection'])) {
557
-				$this->setHeader('Connection', 'close');
558
-				$this->persistentConnection = false;
559
-			}
560
-			// deprecated as of PHP 5.3.0
561
-			//set_magic_quotes_runtime(0);
562
-			$this->encoding = $enc;
563
-		}
564
-	}
546
+    /**
547
+     * use http encoding
548
+     *
549
+     * @param    string $enc encoding style. supported values: gzip, deflate, or both
550
+     * @access   public
551
+     */
552
+    function setEncoding($enc='gzip, deflate') {
553
+        if (function_exists('gzdeflate')) {
554
+            $this->protocol_version = '1.1';
555
+            $this->setHeader('Accept-Encoding', $enc);
556
+            if (!isset($this->outgoing_headers['Connection'])) {
557
+                $this->setHeader('Connection', 'close');
558
+                $this->persistentConnection = false;
559
+            }
560
+            // deprecated as of PHP 5.3.0
561
+            //set_magic_quotes_runtime(0);
562
+            $this->encoding = $enc;
563
+        }
564
+    }
565 565
 	
566
-	/**
567
-	* set proxy info here
568
-	*
569
-	* @param    string $proxyhost use an empty string to remove proxy
570
-	* @param    string $proxyport
571
-	* @param	string $proxyusername
572
-	* @param	string $proxypassword
573
-	* @param	string $proxyauthtype (basic|ntlm)
574
-	* @access   public
575
-	*/
576
-	function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 'basic') {
577
-		if ($proxyhost) {
578
-			$this->proxy = array(
579
-				'host' => $proxyhost,
580
-				'port' => $proxyport,
581
-				'username' => $proxyusername,
582
-				'password' => $proxypassword,
583
-				'authtype' => $proxyauthtype
584
-			);
585
-			if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype = 'basic') {
586
-				$this->setHeader('Proxy-Authorization', ' Basic '.base64_encode($proxyusername.':'.$proxypassword));
587
-			}
588
-		} else {
589
-			$this->debug('remove proxy');
590
-			$proxy = null;
591
-			unsetHeader('Proxy-Authorization');
592
-		}
593
-	}
566
+    /**
567
+     * set proxy info here
568
+     *
569
+     * @param    string $proxyhost use an empty string to remove proxy
570
+     * @param    string $proxyport
571
+     * @param	string $proxyusername
572
+     * @param	string $proxypassword
573
+     * @param	string $proxyauthtype (basic|ntlm)
574
+     * @access   public
575
+     */
576
+    function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 'basic') {
577
+        if ($proxyhost) {
578
+            $this->proxy = array(
579
+                'host' => $proxyhost,
580
+                'port' => $proxyport,
581
+                'username' => $proxyusername,
582
+                'password' => $proxypassword,
583
+                'authtype' => $proxyauthtype
584
+            );
585
+            if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype = 'basic') {
586
+                $this->setHeader('Proxy-Authorization', ' Basic '.base64_encode($proxyusername.':'.$proxypassword));
587
+            }
588
+        } else {
589
+            $this->debug('remove proxy');
590
+            $proxy = null;
591
+            unsetHeader('Proxy-Authorization');
592
+        }
593
+    }
594 594
 	
595 595
 
596
-	/**
597
-	 * Test if the given string starts with a header that is to be skipped.
598
-	 * Skippable headers result from chunked transfer and proxy requests.
599
-	 *
600
-	 * @param	string $data The string to check.
601
-	 * @returns	boolean	Whether a skippable header was found.
602
-	 * @access	private
603
-	 */
604
-	function isSkippableCurlHeader(&$data) {
605
-		$skipHeaders = array(	'HTTP/1.1 100',
606
-								'HTTP/1.0 301',
607
-								'HTTP/1.1 301',
608
-								'HTTP/1.0 302',
609
-								'HTTP/1.1 302',
610
-								'HTTP/1.0 401',
611
-								'HTTP/1.1 401',
612
-								'HTTP/1.0 200 Connection established');
613
-		foreach ($skipHeaders as $hd) {
614
-			$prefix = substr($data, 0, strlen($hd));
615
-			if ($prefix == $hd) return true;
616
-		}
596
+    /**
597
+     * Test if the given string starts with a header that is to be skipped.
598
+     * Skippable headers result from chunked transfer and proxy requests.
599
+     *
600
+     * @param	string $data The string to check.
601
+     * @returns	boolean	Whether a skippable header was found.
602
+     * @access	private
603
+     */
604
+    function isSkippableCurlHeader(&$data) {
605
+        $skipHeaders = array(	'HTTP/1.1 100',
606
+                                'HTTP/1.0 301',
607
+                                'HTTP/1.1 301',
608
+                                'HTTP/1.0 302',
609
+                                'HTTP/1.1 302',
610
+                                'HTTP/1.0 401',
611
+                                'HTTP/1.1 401',
612
+                                'HTTP/1.0 200 Connection established');
613
+        foreach ($skipHeaders as $hd) {
614
+            $prefix = substr($data, 0, strlen($hd));
615
+            if ($prefix == $hd) return true;
616
+        }
617 617
 
618
-		return false;
619
-	}
618
+        return false;
619
+    }
620 620
 
621
-	/**
622
-	* decode a string that is encoded w/ "chunked' transfer encoding
623
- 	* as defined in RFC2068 19.4.6
624
-	*
625
-	* @param    string $buffer
626
-	* @param    string $lb
627
-	* @returns	string
628
-	* @access   public
629
-	* @deprecated
630
-	*/
631
-	function decodeChunked($buffer, $lb){
632
-		// length := 0
633
-		$length = 0;
634
-		$new = '';
621
+    /**
622
+     * decode a string that is encoded w/ "chunked' transfer encoding
623
+     * as defined in RFC2068 19.4.6
624
+     *
625
+     * @param    string $buffer
626
+     * @param    string $lb
627
+     * @returns	string
628
+     * @access   public
629
+     * @deprecated
630
+     */
631
+    function decodeChunked($buffer, $lb){
632
+        // length := 0
633
+        $length = 0;
634
+        $new = '';
635 635
 		
636
-		// read chunk-size, chunk-extension (if any) and CRLF
637
-		// get the position of the linebreak
638
-		$chunkend = strpos($buffer, $lb);
639
-		if ($chunkend == FALSE) {
640
-			$this->debug('no linebreak found in decodeChunked');
641
-			return $new;
642
-		}
643
-		$temp = substr($buffer,0,$chunkend);
644
-		$chunk_size = hexdec( trim($temp) );
645
-		$chunkstart = $chunkend + strlen($lb);
646
-		// while (chunk-size > 0) {
647
-		while ($chunk_size > 0) {
648
-			$this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
649
-			$chunkend = strpos( $buffer, $lb, $chunkstart + $chunk_size);
636
+        // read chunk-size, chunk-extension (if any) and CRLF
637
+        // get the position of the linebreak
638
+        $chunkend = strpos($buffer, $lb);
639
+        if ($chunkend == FALSE) {
640
+            $this->debug('no linebreak found in decodeChunked');
641
+            return $new;
642
+        }
643
+        $temp = substr($buffer,0,$chunkend);
644
+        $chunk_size = hexdec( trim($temp) );
645
+        $chunkstart = $chunkend + strlen($lb);
646
+        // while (chunk-size > 0) {
647
+        while ($chunk_size > 0) {
648
+            $this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
649
+            $chunkend = strpos( $buffer, $lb, $chunkstart + $chunk_size);
650 650
 		  	
651
-			// Just in case we got a broken connection
652
-		  	if ($chunkend == FALSE) {
653
-		  	    $chunk = substr($buffer,$chunkstart);
654
-				// append chunk-data to entity-body
655
-		    	$new .= $chunk;
656
-		  	    $length += strlen($chunk);
657
-		  	    break;
658
-			}
651
+            // Just in case we got a broken connection
652
+                if ($chunkend == FALSE) {
653
+                    $chunk = substr($buffer,$chunkstart);
654
+                // append chunk-data to entity-body
655
+                $new .= $chunk;
656
+                    $length += strlen($chunk);
657
+                    break;
658
+            }
659 659
 			
660
-		  	// read chunk-data and CRLF
661
-		  	$chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart);
662
-		  	// append chunk-data to entity-body
663
-		  	$new .= $chunk;
664
-		  	// length := length + chunk-size
665
-		  	$length += strlen($chunk);
666
-		  	// read chunk-size and CRLF
667
-		  	$chunkstart = $chunkend + strlen($lb);
660
+                // read chunk-data and CRLF
661
+                $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart);
662
+                // append chunk-data to entity-body
663
+                $new .= $chunk;
664
+                // length := length + chunk-size
665
+                $length += strlen($chunk);
666
+                // read chunk-size and CRLF
667
+                $chunkstart = $chunkend + strlen($lb);
668 668
 			
669
-		  	$chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb);
670
-			if ($chunkend == FALSE) {
671
-				break; //Just in case we got a broken connection
672
-			}
673
-			$temp = substr($buffer,$chunkstart,$chunkend-$chunkstart);
674
-			$chunk_size = hexdec( trim($temp) );
675
-			$chunkstart = $chunkend;
676
-		}
677
-		return $new;
678
-	}
669
+                $chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb);
670
+            if ($chunkend == FALSE) {
671
+                break; //Just in case we got a broken connection
672
+            }
673
+            $temp = substr($buffer,$chunkstart,$chunkend-$chunkstart);
674
+            $chunk_size = hexdec( trim($temp) );
675
+            $chunkstart = $chunkend;
676
+        }
677
+        return $new;
678
+    }
679 679
 	
680
-	/**
681
-	 * Writes the payload, including HTTP headers, to $this->outgoing_payload.
682
-	 *
683
-	 * @param	string $data HTTP body
684
-	 * @param	string $cookie_str data for HTTP Cookie header
685
-	 * @return	void
686
-	 * @access	private
687
-	 */
688
-	function buildPayload($data, $cookie_str = '') {
689
-		// Note: for cURL connections, $this->outgoing_payload is ignored,
690
-		// as is the Content-Length header, but these are still created as
691
-		// debugging guides.
680
+    /**
681
+     * Writes the payload, including HTTP headers, to $this->outgoing_payload.
682
+     *
683
+     * @param	string $data HTTP body
684
+     * @param	string $cookie_str data for HTTP Cookie header
685
+     * @return	void
686
+     * @access	private
687
+     */
688
+    function buildPayload($data, $cookie_str = '') {
689
+        // Note: for cURL connections, $this->outgoing_payload is ignored,
690
+        // as is the Content-Length header, but these are still created as
691
+        // debugging guides.
692 692
 
693
-		// add content-length header
694
-		if ($this->request_method != 'GET') {
695
-			$this->setHeader('Content-Length', strlen($data));
696
-		}
693
+        // add content-length header
694
+        if ($this->request_method != 'GET') {
695
+            $this->setHeader('Content-Length', strlen($data));
696
+        }
697 697
 
698
-		// start building outgoing payload:
699
-		if ($this->proxy) {
700
-			$uri = $this->url;
701
-		} else {
702
-			$uri = $this->uri;
703
-		}
704
-		$req = "$this->request_method $uri HTTP/$this->protocol_version";
705
-		$this->debug("HTTP request: $req");
706
-		$this->outgoing_payload = "$req\r\n";
698
+        // start building outgoing payload:
699
+        if ($this->proxy) {
700
+            $uri = $this->url;
701
+        } else {
702
+            $uri = $this->uri;
703
+        }
704
+        $req = "$this->request_method $uri HTTP/$this->protocol_version";
705
+        $this->debug("HTTP request: $req");
706
+        $this->outgoing_payload = "$req\r\n";
707 707
 
708
-		// loop thru headers, serializing
709
-		foreach($this->outgoing_headers as $k => $v){
710
-			$hdr = $k.': '.$v;
711
-			$this->debug("HTTP header: $hdr");
712
-			$this->outgoing_payload .= "$hdr\r\n";
713
-		}
708
+        // loop thru headers, serializing
709
+        foreach($this->outgoing_headers as $k => $v){
710
+            $hdr = $k.': '.$v;
711
+            $this->debug("HTTP header: $hdr");
712
+            $this->outgoing_payload .= "$hdr\r\n";
713
+        }
714 714
 
715
-		// add any cookies
716
-		if ($cookie_str != '') {
717
-			$hdr = 'Cookie: '.$cookie_str;
718
-			$this->debug("HTTP header: $hdr");
719
-			$this->outgoing_payload .= "$hdr\r\n";
720
-		}
715
+        // add any cookies
716
+        if ($cookie_str != '') {
717
+            $hdr = 'Cookie: '.$cookie_str;
718
+            $this->debug("HTTP header: $hdr");
719
+            $this->outgoing_payload .= "$hdr\r\n";
720
+        }
721 721
 
722
-		// header/body separator
723
-		$this->outgoing_payload .= "\r\n";
722
+        // header/body separator
723
+        $this->outgoing_payload .= "\r\n";
724 724
 		
725
-		// add data
726
-		$this->outgoing_payload .= $data;
727
-	}
725
+        // add data
726
+        $this->outgoing_payload .= $data;
727
+    }
728 728
 
729
-	/**
730
-	* sends the SOAP request via HTTP[S]
731
-	*
732
-	* @param    string $data message data
733
-	* @param	array $cookies cookies to send
734
-	* @return	boolean	true if OK, false if problem
735
-	* @access   private
736
-	*/
737
-	function sendRequest($data, $cookies = NULL) {
738
-		// build cookie string
739
-		$cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https')));
729
+    /**
730
+     * sends the SOAP request via HTTP[S]
731
+     *
732
+     * @param    string $data message data
733
+     * @param	array $cookies cookies to send
734
+     * @return	boolean	true if OK, false if problem
735
+     * @access   private
736
+     */
737
+    function sendRequest($data, $cookies = NULL) {
738
+        // build cookie string
739
+        $cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https')));
740 740
 
741
-		// build payload
742
-		$this->buildPayload($data, $cookie_str);
741
+        // build payload
742
+        $this->buildPayload($data, $cookie_str);
743 743
 
744
-	  if ($this->io_method() == 'socket') {
745
-		// send payload
746
-		if(!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
747
-			$this->setError('couldn\'t write message data to socket');
748
-			$this->debug('couldn\'t write message data to socket');
749
-			return false;
750
-		}
751
-		$this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
752
-		return true;
753
-	  } else if ($this->io_method() == 'curl') {
754
-		// set payload
755
-		// cURL does say this should only be the verb, and in fact it
756
-		// turns out that the URI and HTTP version are appended to this, which
757
-		// some servers refuse to work with (so we no longer use this method!)
758
-		//$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
759
-		$curl_headers = array();
760
-		foreach($this->outgoing_headers as $k => $v){
761
-			if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
762
-				$this->debug("Skip cURL header $k: $v");
763
-			} else {
764
-				$curl_headers[] = "$k: $v";
765
-			}
766
-		}
767
-		if ($cookie_str != '') {
768
-			$curl_headers[] = 'Cookie: ' . $cookie_str;
769
-		}
770
-		$this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers);
771
-		$this->debug('set cURL HTTP headers');
772
-		if ($this->request_method == "POST") {
773
-	  		$this->setCurlOption(CURLOPT_POST, 1);
774
-	  		$this->setCurlOption(CURLOPT_POSTFIELDS, $data);
775
-			$this->debug('set cURL POST data');
776
-	  	} else {
777
-	  	}
778
-		// insert custom user-set cURL options
779
-		foreach ($this->ch_options as $key => $val) {
780
-			$this->setCurlOption($key, $val);
781
-		}
744
+        if ($this->io_method() == 'socket') {
745
+        // send payload
746
+        if(!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
747
+            $this->setError('couldn\'t write message data to socket');
748
+            $this->debug('couldn\'t write message data to socket');
749
+            return false;
750
+        }
751
+        $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
752
+        return true;
753
+        } else if ($this->io_method() == 'curl') {
754
+        // set payload
755
+        // cURL does say this should only be the verb, and in fact it
756
+        // turns out that the URI and HTTP version are appended to this, which
757
+        // some servers refuse to work with (so we no longer use this method!)
758
+        //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
759
+        $curl_headers = array();
760
+        foreach($this->outgoing_headers as $k => $v){
761
+            if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
762
+                $this->debug("Skip cURL header $k: $v");
763
+            } else {
764
+                $curl_headers[] = "$k: $v";
765
+            }
766
+        }
767
+        if ($cookie_str != '') {
768
+            $curl_headers[] = 'Cookie: ' . $cookie_str;
769
+        }
770
+        $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers);
771
+        $this->debug('set cURL HTTP headers');
772
+        if ($this->request_method == "POST") {
773
+                $this->setCurlOption(CURLOPT_POST, 1);
774
+                $this->setCurlOption(CURLOPT_POSTFIELDS, $data);
775
+            $this->debug('set cURL POST data');
776
+            } else {
777
+            }
778
+        // insert custom user-set cURL options
779
+        foreach ($this->ch_options as $key => $val) {
780
+            $this->setCurlOption($key, $val);
781
+        }
782 782
 
783
-		$this->debug('set cURL payload');
784
-		return true;
785
-	  }
786
-	}
783
+        $this->debug('set cURL payload');
784
+        return true;
785
+        }
786
+    }
787 787
 
788
-	/**
789
-	* gets the SOAP response via HTTP[S]
790
-	*
791
-	* @return	string the response (also sets member variables like incoming_payload)
792
-	* @access   private
793
-	*/
794
-	function getResponse(){
795
-		$this->incoming_payload = '';
788
+    /**
789
+     * gets the SOAP response via HTTP[S]
790
+     *
791
+     * @return	string the response (also sets member variables like incoming_payload)
792
+     * @access   private
793
+     */
794
+    function getResponse(){
795
+        $this->incoming_payload = '';
796 796
 	    
797
-	  if ($this->io_method() == 'socket') {
798
-	    // loop until headers have been retrieved
799
-	    $data = '';
800
-	    while (!isset($lb)){
797
+        if ($this->io_method() == 'socket') {
798
+        // loop until headers have been retrieved
799
+        $data = '';
800
+        while (!isset($lb)){
801 801
 
802
-			// We might EOF during header read.
803
-			if(feof($this->fp)) {
804
-				$this->incoming_payload = $data;
805
-				$this->debug('found no headers before EOF after length ' . strlen($data));
806
-				$this->debug("received before EOF:\n" . $data);
807
-				$this->setError('server failed to send headers');
808
-				return false;
809
-			}
802
+            // We might EOF during header read.
803
+            if(feof($this->fp)) {
804
+                $this->incoming_payload = $data;
805
+                $this->debug('found no headers before EOF after length ' . strlen($data));
806
+                $this->debug("received before EOF:\n" . $data);
807
+                $this->setError('server failed to send headers');
808
+                return false;
809
+            }
810 810
 
811
-			$tmp = fgets($this->fp, 256);
812
-			$tmplen = strlen($tmp);
813
-			$this->debug("read line of $tmplen bytes: " . trim($tmp));
811
+            $tmp = fgets($this->fp, 256);
812
+            $tmplen = strlen($tmp);
813
+            $this->debug("read line of $tmplen bytes: " . trim($tmp));
814 814
 
815
-			if ($tmplen == 0) {
816
-				$this->incoming_payload = $data;
817
-				$this->debug('socket read of headers timed out after length ' . strlen($data));
818
-				$this->debug("read before timeout: " . $data);
819
-				$this->setError('socket read of headers timed out');
820
-				return false;
821
-			}
815
+            if ($tmplen == 0) {
816
+                $this->incoming_payload = $data;
817
+                $this->debug('socket read of headers timed out after length ' . strlen($data));
818
+                $this->debug("read before timeout: " . $data);
819
+                $this->setError('socket read of headers timed out');
820
+                return false;
821
+            }
822 822
 
823
-			$data .= $tmp;
824
-			$pos = strpos($data,"\r\n\r\n");
825
-			if($pos > 1){
826
-				$lb = "\r\n";
827
-			} else {
828
-				$pos = strpos($data,"\n\n");
829
-				if($pos > 1){
830
-					$lb = "\n";
831
-				}
832
-			}
833
-			// remove 100 headers
834
-			if (isset($lb) && preg_match('/^HTTP\/1.1 100/',$data)) {
835
-				unset($lb);
836
-				$data = '';
837
-			}//
838
-		}
839
-		// store header data
840
-		$this->incoming_payload .= $data;
841
-		$this->debug('found end of headers after length ' . strlen($data));
842
-		// process headers
843
-		$header_data = trim(substr($data,0,$pos));
844
-		$header_array = explode($lb,$header_data);
845
-		$this->incoming_headers = array();
846
-		$this->incoming_cookies = array();
847
-		foreach($header_array as $header_line){
848
-			$arr = explode(':',$header_line, 2);
849
-			if(count($arr) > 1){
850
-				$header_name = strtolower(trim($arr[0]));
851
-				$this->incoming_headers[$header_name] = trim($arr[1]);
852
-				if ($header_name == 'set-cookie') {
853
-					// TODO: allow multiple cookies from parseCookie
854
-					$cookie = $this->parseCookie(trim($arr[1]));
855
-					if ($cookie) {
856
-						$this->incoming_cookies[] = $cookie;
857
-						$this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
858
-					} else {
859
-						$this->debug('did not find cookie in ' . trim($arr[1]));
860
-					}
861
-    			}
862
-			} else if (isset($header_name)) {
863
-				// append continuation line to previous header
864
-				$this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
865
-			}
866
-		}
823
+            $data .= $tmp;
824
+            $pos = strpos($data,"\r\n\r\n");
825
+            if($pos > 1){
826
+                $lb = "\r\n";
827
+            } else {
828
+                $pos = strpos($data,"\n\n");
829
+                if($pos > 1){
830
+                    $lb = "\n";
831
+                }
832
+            }
833
+            // remove 100 headers
834
+            if (isset($lb) && preg_match('/^HTTP\/1.1 100/',$data)) {
835
+                unset($lb);
836
+                $data = '';
837
+            }//
838
+        }
839
+        // store header data
840
+        $this->incoming_payload .= $data;
841
+        $this->debug('found end of headers after length ' . strlen($data));
842
+        // process headers
843
+        $header_data = trim(substr($data,0,$pos));
844
+        $header_array = explode($lb,$header_data);
845
+        $this->incoming_headers = array();
846
+        $this->incoming_cookies = array();
847
+        foreach($header_array as $header_line){
848
+            $arr = explode(':',$header_line, 2);
849
+            if(count($arr) > 1){
850
+                $header_name = strtolower(trim($arr[0]));
851
+                $this->incoming_headers[$header_name] = trim($arr[1]);
852
+                if ($header_name == 'set-cookie') {
853
+                    // TODO: allow multiple cookies from parseCookie
854
+                    $cookie = $this->parseCookie(trim($arr[1]));
855
+                    if ($cookie) {
856
+                        $this->incoming_cookies[] = $cookie;
857
+                        $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
858
+                    } else {
859
+                        $this->debug('did not find cookie in ' . trim($arr[1]));
860
+                    }
861
+                }
862
+            } else if (isset($header_name)) {
863
+                // append continuation line to previous header
864
+                $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
865
+            }
866
+        }
867 867
 		
868
-		// loop until msg has been received
869
-		if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
870
-			$content_length =  2147483647;	// ignore any content-length header
871
-			$chunked = true;
872
-			$this->debug("want to read chunked content");
873
-		} elseif (isset($this->incoming_headers['content-length'])) {
874
-			$content_length = $this->incoming_headers['content-length'];
875
-			$chunked = false;
876
-			$this->debug("want to read content of length $content_length");
877
-		} else {
878
-			$content_length =  2147483647;
879
-			$chunked = false;
880
-			$this->debug("want to read content to EOF");
881
-		}
882
-		$data = '';
883
-		do {
884
-			if ($chunked) {
885
-				$tmp = fgets($this->fp, 256);
886
-				$tmplen = strlen($tmp);
887
-				$this->debug("read chunk line of $tmplen bytes");
888
-				if ($tmplen == 0) {
889
-					$this->incoming_payload = $data;
890
-					$this->debug('socket read of chunk length timed out after length ' . strlen($data));
891
-					$this->debug("read before timeout:\n" . $data);
892
-					$this->setError('socket read of chunk length timed out');
893
-					return false;
894
-				}
895
-				$content_length = hexdec(trim($tmp));
896
-				$this->debug("chunk length $content_length");
897
-			}
898
-			$strlen = 0;
899
-		    while (($strlen < $content_length) && (!feof($this->fp))) {
900
-		    	$readlen = min(8192, $content_length - $strlen);
901
-				$tmp = fread($this->fp, $readlen);
902
-				$tmplen = strlen($tmp);
903
-				$this->debug("read buffer of $tmplen bytes");
904
-				if (($tmplen == 0) && (!feof($this->fp))) {
905
-					$this->incoming_payload = $data;
906
-					$this->debug('socket read of body timed out after length ' . strlen($data));
907
-					$this->debug("read before timeout:\n" . $data);
908
-					$this->setError('socket read of body timed out');
909
-					return false;
910
-				}
911
-				$strlen += $tmplen;
912
-				$data .= $tmp;
913
-			}
914
-			if ($chunked && ($content_length > 0)) {
915
-				$tmp = fgets($this->fp, 256);
916
-				$tmplen = strlen($tmp);
917
-				$this->debug("read chunk terminator of $tmplen bytes");
918
-				if ($tmplen == 0) {
919
-					$this->incoming_payload = $data;
920
-					$this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
921
-					$this->debug("read before timeout:\n" . $data);
922
-					$this->setError('socket read of chunk terminator timed out');
923
-					return false;
924
-				}
925
-			}
926
-		} while ($chunked && ($content_length > 0) && (!feof($this->fp)));
927
-		if (feof($this->fp)) {
928
-			$this->debug('read to EOF');
929
-		}
930
-		$this->debug('read body of length ' . strlen($data));
931
-		$this->incoming_payload .= $data;
932
-		$this->debug('received a total of '.strlen($this->incoming_payload).' bytes of data from server');
868
+        // loop until msg has been received
869
+        if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
870
+            $content_length =  2147483647;	// ignore any content-length header
871
+            $chunked = true;
872
+            $this->debug("want to read chunked content");
873
+        } elseif (isset($this->incoming_headers['content-length'])) {
874
+            $content_length = $this->incoming_headers['content-length'];
875
+            $chunked = false;
876
+            $this->debug("want to read content of length $content_length");
877
+        } else {
878
+            $content_length =  2147483647;
879
+            $chunked = false;
880
+            $this->debug("want to read content to EOF");
881
+        }
882
+        $data = '';
883
+        do {
884
+            if ($chunked) {
885
+                $tmp = fgets($this->fp, 256);
886
+                $tmplen = strlen($tmp);
887
+                $this->debug("read chunk line of $tmplen bytes");
888
+                if ($tmplen == 0) {
889
+                    $this->incoming_payload = $data;
890
+                    $this->debug('socket read of chunk length timed out after length ' . strlen($data));
891
+                    $this->debug("read before timeout:\n" . $data);
892
+                    $this->setError('socket read of chunk length timed out');
893
+                    return false;
894
+                }
895
+                $content_length = hexdec(trim($tmp));
896
+                $this->debug("chunk length $content_length");
897
+            }
898
+            $strlen = 0;
899
+            while (($strlen < $content_length) && (!feof($this->fp))) {
900
+                $readlen = min(8192, $content_length - $strlen);
901
+                $tmp = fread($this->fp, $readlen);
902
+                $tmplen = strlen($tmp);
903
+                $this->debug("read buffer of $tmplen bytes");
904
+                if (($tmplen == 0) && (!feof($this->fp))) {
905
+                    $this->incoming_payload = $data;
906
+                    $this->debug('socket read of body timed out after length ' . strlen($data));
907
+                    $this->debug("read before timeout:\n" . $data);
908
+                    $this->setError('socket read of body timed out');
909
+                    return false;
910
+                }
911
+                $strlen += $tmplen;
912
+                $data .= $tmp;
913
+            }
914
+            if ($chunked && ($content_length > 0)) {
915
+                $tmp = fgets($this->fp, 256);
916
+                $tmplen = strlen($tmp);
917
+                $this->debug("read chunk terminator of $tmplen bytes");
918
+                if ($tmplen == 0) {
919
+                    $this->incoming_payload = $data;
920
+                    $this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
921
+                    $this->debug("read before timeout:\n" . $data);
922
+                    $this->setError('socket read of chunk terminator timed out');
923
+                    return false;
924
+                }
925
+            }
926
+        } while ($chunked && ($content_length > 0) && (!feof($this->fp)));
927
+        if (feof($this->fp)) {
928
+            $this->debug('read to EOF');
929
+        }
930
+        $this->debug('read body of length ' . strlen($data));
931
+        $this->incoming_payload .= $data;
932
+        $this->debug('received a total of '.strlen($this->incoming_payload).' bytes of data from server');
933 933
 		
934
-		// close filepointer
935
-		if(
936
-			(isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') || 
937
-			(! $this->persistentConnection) || feof($this->fp)){
938
-			fclose($this->fp);
939
-			$this->fp = false;
940
-			$this->debug('closed socket');
941
-		}
934
+        // close filepointer
935
+        if(
936
+            (isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') || 
937
+            (! $this->persistentConnection) || feof($this->fp)){
938
+            fclose($this->fp);
939
+            $this->fp = false;
940
+            $this->debug('closed socket');
941
+        }
942 942
 		
943
-		// connection was closed unexpectedly
944
-		if($this->incoming_payload == ''){
945
-			$this->setError('no response from server');
946
-			return false;
947
-		}
943
+        // connection was closed unexpectedly
944
+        if($this->incoming_payload == ''){
945
+            $this->setError('no response from server');
946
+            return false;
947
+        }
948 948
 		
949
-		// decode transfer-encoding
949
+        // decode transfer-encoding
950 950
 //		if(isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked'){
951 951
 //			if(!$data = $this->decodeChunked($data, $lb)){
952 952
 //				$this->setError('Decoding of chunked data failed');
953 953
 //				return false;
954 954
 //			}
955
-			//print "<pre>\nde-chunked:\n---------------\n$data\n\n---------------\n</pre>";
956
-			// set decoded payload
955
+            //print "<pre>\nde-chunked:\n---------------\n$data\n\n---------------\n</pre>";
956
+            // set decoded payload
957 957
 //			$this->incoming_payload = $header_data.$lb.$lb.$data;
958 958
 //		}
959 959
 	
960
-	  } else if ($this->io_method() == 'curl') {
961
-		// send and receive
962
-		$this->debug('send and receive with cURL');
963
-		$this->incoming_payload = curl_exec($this->ch);
964
-		$data = $this->incoming_payload;
960
+        } else if ($this->io_method() == 'curl') {
961
+        // send and receive
962
+        $this->debug('send and receive with cURL');
963
+        $this->incoming_payload = curl_exec($this->ch);
964
+        $data = $this->incoming_payload;
965 965
 
966 966
         $cErr = curl_error($this->ch);
967
-		if ($cErr != '') {
968
-        	$err = 'cURL ERROR: '.curl_errno($this->ch).': '.$cErr.'<br>';
969
-        	// TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE
970
-			foreach(curl_getinfo($this->ch) as $k => $v){
971
-				$err .= "$k: $v<br>";
972
-			}
973
-			$this->debug($err);
974
-			$this->setError($err);
975
-			curl_close($this->ch);
976
-	    	return false;
977
-		} else {
978
-			//echo '<pre>';
979
-			//var_dump(curl_getinfo($this->ch));
980
-			//echo '</pre>';
981
-		}
982
-		// close curl
983
-		$this->debug('No cURL error, closing cURL');
984
-		curl_close($this->ch);
967
+        if ($cErr != '') {
968
+            $err = 'cURL ERROR: '.curl_errno($this->ch).': '.$cErr.'<br>';
969
+            // TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE
970
+            foreach(curl_getinfo($this->ch) as $k => $v){
971
+                $err .= "$k: $v<br>";
972
+            }
973
+            $this->debug($err);
974
+            $this->setError($err);
975
+            curl_close($this->ch);
976
+            return false;
977
+        } else {
978
+            //echo '<pre>';
979
+            //var_dump(curl_getinfo($this->ch));
980
+            //echo '</pre>';
981
+        }
982
+        // close curl
983
+        $this->debug('No cURL error, closing cURL');
984
+        curl_close($this->ch);
985 985
 		
986
-		// try removing skippable headers
987
-		$savedata = $data;
988
-		while ($this->isSkippableCurlHeader($data)) {
989
-			$this->debug("Found HTTP header to skip");
990
-			if ($pos = strpos($data,"\r\n\r\n")) {
991
-				$data = ltrim(substr($data,$pos));
992
-			} elseif($pos = strpos($data,"\n\n") ) {
993
-				$data = ltrim(substr($data,$pos));
994
-			}
995
-		}
986
+        // try removing skippable headers
987
+        $savedata = $data;
988
+        while ($this->isSkippableCurlHeader($data)) {
989
+            $this->debug("Found HTTP header to skip");
990
+            if ($pos = strpos($data,"\r\n\r\n")) {
991
+                $data = ltrim(substr($data,$pos));
992
+            } elseif($pos = strpos($data,"\n\n") ) {
993
+                $data = ltrim(substr($data,$pos));
994
+            }
995
+        }
996 996
 
997
-		if ($data == '') {
998
-			// have nothing left; just remove 100 header(s)
999
-			$data = $savedata;
1000
-			while (preg_match('/^HTTP\/1.1 100/',$data)) {
1001
-				if ($pos = strpos($data,"\r\n\r\n")) {
1002
-					$data = ltrim(substr($data,$pos));
1003
-				} elseif($pos = strpos($data,"\n\n") ) {
1004
-					$data = ltrim(substr($data,$pos));
1005
-				}
1006
-			}
1007
-		}
997
+        if ($data == '') {
998
+            // have nothing left; just remove 100 header(s)
999
+            $data = $savedata;
1000
+            while (preg_match('/^HTTP\/1.1 100/',$data)) {
1001
+                if ($pos = strpos($data,"\r\n\r\n")) {
1002
+                    $data = ltrim(substr($data,$pos));
1003
+                } elseif($pos = strpos($data,"\n\n") ) {
1004
+                    $data = ltrim(substr($data,$pos));
1005
+                }
1006
+            }
1007
+        }
1008 1008
 		
1009
-		// separate content from HTTP headers
1010
-		if ($pos = strpos($data,"\r\n\r\n")) {
1011
-			$lb = "\r\n";
1012
-		} elseif( $pos = strpos($data,"\n\n")) {
1013
-			$lb = "\n";
1014
-		} else {
1015
-			$this->debug('no proper separation of headers and document');
1016
-			$this->setError('no proper separation of headers and document');
1017
-			return false;
1018
-		}
1019
-		$header_data = trim(substr($data,0,$pos));
1020
-		$header_array = explode($lb,$header_data);
1021
-		$data = ltrim(substr($data,$pos));
1022
-		$this->debug('found proper separation of headers and document');
1023
-		$this->debug('cleaned data, stringlen: '.strlen($data));
1024
-		// clean headers
1025
-		foreach ($header_array as $header_line) {
1026
-			$arr = explode(':',$header_line,2);
1027
-			if(count($arr) > 1){
1028
-				$header_name = strtolower(trim($arr[0]));
1029
-				$this->incoming_headers[$header_name] = trim($arr[1]);
1030
-				if ($header_name == 'set-cookie') {
1031
-					// TODO: allow multiple cookies from parseCookie
1032
-					$cookie = $this->parseCookie(trim($arr[1]));
1033
-					if ($cookie) {
1034
-						$this->incoming_cookies[] = $cookie;
1035
-						$this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
1036
-					} else {
1037
-						$this->debug('did not find cookie in ' . trim($arr[1]));
1038
-					}
1039
-    			}
1040
-			} else if (isset($header_name)) {
1041
-				// append continuation line to previous header
1042
-				$this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
1043
-			}
1044
-		}
1045
-	  }
1009
+        // separate content from HTTP headers
1010
+        if ($pos = strpos($data,"\r\n\r\n")) {
1011
+            $lb = "\r\n";
1012
+        } elseif( $pos = strpos($data,"\n\n")) {
1013
+            $lb = "\n";
1014
+        } else {
1015
+            $this->debug('no proper separation of headers and document');
1016
+            $this->setError('no proper separation of headers and document');
1017
+            return false;
1018
+        }
1019
+        $header_data = trim(substr($data,0,$pos));
1020
+        $header_array = explode($lb,$header_data);
1021
+        $data = ltrim(substr($data,$pos));
1022
+        $this->debug('found proper separation of headers and document');
1023
+        $this->debug('cleaned data, stringlen: '.strlen($data));
1024
+        // clean headers
1025
+        foreach ($header_array as $header_line) {
1026
+            $arr = explode(':',$header_line,2);
1027
+            if(count($arr) > 1){
1028
+                $header_name = strtolower(trim($arr[0]));
1029
+                $this->incoming_headers[$header_name] = trim($arr[1]);
1030
+                if ($header_name == 'set-cookie') {
1031
+                    // TODO: allow multiple cookies from parseCookie
1032
+                    $cookie = $this->parseCookie(trim($arr[1]));
1033
+                    if ($cookie) {
1034
+                        $this->incoming_cookies[] = $cookie;
1035
+                        $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
1036
+                    } else {
1037
+                        $this->debug('did not find cookie in ' . trim($arr[1]));
1038
+                    }
1039
+                }
1040
+            } else if (isset($header_name)) {
1041
+                // append continuation line to previous header
1042
+                $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
1043
+            }
1044
+        }
1045
+        }
1046 1046
 
1047
-		$this->response_status_line = $header_array[0];
1048
-		$arr = explode(' ', $this->response_status_line, 3);
1049
-		$http_version = $arr[0];
1050
-		$http_status = intval($arr[1]);
1051
-		$http_reason = count($arr) > 2 ? $arr[2] : '';
1047
+        $this->response_status_line = $header_array[0];
1048
+        $arr = explode(' ', $this->response_status_line, 3);
1049
+        $http_version = $arr[0];
1050
+        $http_status = intval($arr[1]);
1051
+        $http_reason = count($arr) > 2 ? $arr[2] : '';
1052 1052
 
1053
- 		// see if we need to resend the request with http digest authentication
1054
- 		if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
1055
- 			$this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
1056
- 			$this->setURL($this->incoming_headers['location']);
1057
-			$this->tryagain = true;
1058
-			return false;
1059
-		}
1053
+            // see if we need to resend the request with http digest authentication
1054
+            if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
1055
+                $this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
1056
+                $this->setURL($this->incoming_headers['location']);
1057
+            $this->tryagain = true;
1058
+            return false;
1059
+        }
1060 1060
 
1061
- 		// see if we need to resend the request with http digest authentication
1062
- 		if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
1063
- 			$this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']);
1064
- 			if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
1065
- 				$this->debug('Server wants digest authentication');
1066
- 				// remove "Digest " from our elements
1067
- 				$digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']);
1061
+            // see if we need to resend the request with http digest authentication
1062
+            if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
1063
+                $this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']);
1064
+                if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
1065
+                    $this->debug('Server wants digest authentication');
1066
+                    // remove "Digest " from our elements
1067
+                    $digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']);
1068 1068
  				
1069
- 				// parse elements into array
1070
- 				$digestElements = explode(',', $digestString);
1071
- 				foreach ($digestElements as $val) {
1072
- 					$tempElement = explode('=', trim($val), 2);
1073
- 					$digestRequest[$tempElement[0]] = str_replace("\"", '', $tempElement[1]);
1074
- 				}
1069
+                    // parse elements into array
1070
+                    $digestElements = explode(',', $digestString);
1071
+                    foreach ($digestElements as $val) {
1072
+                        $tempElement = explode('=', trim($val), 2);
1073
+                        $digestRequest[$tempElement[0]] = str_replace("\"", '', $tempElement[1]);
1074
+                    }
1075 1075
 
1076
-				// should have (at least) qop, realm, nonce
1077
- 				if (isset($digestRequest['nonce'])) {
1078
- 					$this->setCredentials($this->username, $this->password, 'digest', $digestRequest);
1079
- 					$this->tryagain = true;
1080
- 					return false;
1081
- 				}
1082
- 			}
1083
-			$this->debug('HTTP authentication failed');
1084
-			$this->setError('HTTP authentication failed');
1085
-			return false;
1086
- 		}
1076
+                // should have (at least) qop, realm, nonce
1077
+                    if (isset($digestRequest['nonce'])) {
1078
+                        $this->setCredentials($this->username, $this->password, 'digest', $digestRequest);
1079
+                        $this->tryagain = true;
1080
+                        return false;
1081
+                    }
1082
+                }
1083
+            $this->debug('HTTP authentication failed');
1084
+            $this->setError('HTTP authentication failed');
1085
+            return false;
1086
+            }
1087 1087
 		
1088
-		if (
1089
-			($http_status >= 300 && $http_status <= 307) ||
1090
-			($http_status >= 400 && $http_status <= 417) ||
1091
-			($http_status >= 501 && $http_status <= 505)
1092
-		   ) {
1093
-			$this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)");
1094
-			return false;
1095
-		}
1088
+        if (
1089
+            ($http_status >= 300 && $http_status <= 307) ||
1090
+            ($http_status >= 400 && $http_status <= 417) ||
1091
+            ($http_status >= 501 && $http_status <= 505)
1092
+            ) {
1093
+            $this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)");
1094
+            return false;
1095
+        }
1096 1096
 
1097
-		// decode content-encoding
1098
-		if(isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != ''){
1099
-			if(strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip'){
1100
-    			// if decoding works, use it. else assume data wasn't gzencoded
1101
-    			if(function_exists('gzinflate')){
1102
-					//$timer->setMarker('starting decoding of gzip/deflated content');
1103
-					// IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress)
1104
-					// this means there are no Zlib headers, although there should be
1105
-					$this->debug('The gzinflate function exists');
1106
-					$datalen = strlen($data);
1107
-					if ($this->incoming_headers['content-encoding'] == 'deflate') {
1108
-						if ($degzdata = @gzinflate($data)) {
1109
-	    					$data = $degzdata;
1110
-	    					$this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
1111
-	    					if (strlen($data) < $datalen) {
1112
-	    						// test for the case that the payload has been compressed twice
1113
-		    					$this->debug('The inflated payload is smaller than the gzipped one; try again');
1114
-								if ($degzdata = @gzinflate($data)) {
1115
-			    					$data = $degzdata;
1116
-			    					$this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
1117
-								}
1118
-	    					}
1119
-	    				} else {
1120
-	    					$this->debug('Error using gzinflate to inflate the payload');
1121
-	    					$this->setError('Error using gzinflate to inflate the payload');
1122
-	    				}
1123
-					} elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
1124
-						if ($degzdata = @gzinflate(substr($data, 10))) {	// do our best
1125
-							$data = $degzdata;
1126
-	    					$this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
1127
-	    					if (strlen($data) < $datalen) {
1128
-	    						// test for the case that the payload has been compressed twice
1129
-		    					$this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
1130
-								if ($degzdata = @gzinflate(substr($data, 10))) {
1131
-			    					$data = $degzdata;
1132
-			    					$this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
1133
-								}
1134
-	    					}
1135
-	    				} else {
1136
-	    					$this->debug('Error using gzinflate to un-gzip the payload');
1137
-							$this->setError('Error using gzinflate to un-gzip the payload');
1138
-	    				}
1139
-					}
1140
-					//$timer->setMarker('finished decoding of gzip/deflated content');
1141
-					//print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>";
1142
-					// set decoded payload
1143
-					$this->incoming_payload = $header_data.$lb.$lb.$data;
1144
-    			} else {
1145
-					$this->debug('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
1146
-					$this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
1147
-				}
1148
-			} else {
1149
-				$this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
1150
-				$this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
1151
-			}
1152
-		} else {
1153
-			$this->debug('No Content-Encoding header');
1154
-		}
1097
+        // decode content-encoding
1098
+        if(isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != ''){
1099
+            if(strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip'){
1100
+                // if decoding works, use it. else assume data wasn't gzencoded
1101
+                if(function_exists('gzinflate')){
1102
+                    //$timer->setMarker('starting decoding of gzip/deflated content');
1103
+                    // IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress)
1104
+                    // this means there are no Zlib headers, although there should be
1105
+                    $this->debug('The gzinflate function exists');
1106
+                    $datalen = strlen($data);
1107
+                    if ($this->incoming_headers['content-encoding'] == 'deflate') {
1108
+                        if ($degzdata = @gzinflate($data)) {
1109
+                            $data = $degzdata;
1110
+                            $this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
1111
+                            if (strlen($data) < $datalen) {
1112
+                                // test for the case that the payload has been compressed twice
1113
+                                $this->debug('The inflated payload is smaller than the gzipped one; try again');
1114
+                                if ($degzdata = @gzinflate($data)) {
1115
+                                    $data = $degzdata;
1116
+                                    $this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
1117
+                                }
1118
+                            }
1119
+                        } else {
1120
+                            $this->debug('Error using gzinflate to inflate the payload');
1121
+                            $this->setError('Error using gzinflate to inflate the payload');
1122
+                        }
1123
+                    } elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
1124
+                        if ($degzdata = @gzinflate(substr($data, 10))) {	// do our best
1125
+                            $data = $degzdata;
1126
+                            $this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
1127
+                            if (strlen($data) < $datalen) {
1128
+                                // test for the case that the payload has been compressed twice
1129
+                                $this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
1130
+                                if ($degzdata = @gzinflate(substr($data, 10))) {
1131
+                                    $data = $degzdata;
1132
+                                    $this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
1133
+                                }
1134
+                            }
1135
+                        } else {
1136
+                            $this->debug('Error using gzinflate to un-gzip the payload');
1137
+                            $this->setError('Error using gzinflate to un-gzip the payload');
1138
+                        }
1139
+                    }
1140
+                    //$timer->setMarker('finished decoding of gzip/deflated content');
1141
+                    //print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>";
1142
+                    // set decoded payload
1143
+                    $this->incoming_payload = $header_data.$lb.$lb.$data;
1144
+                } else {
1145
+                    $this->debug('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
1146
+                    $this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
1147
+                }
1148
+            } else {
1149
+                $this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
1150
+                $this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
1151
+            }
1152
+        } else {
1153
+            $this->debug('No Content-Encoding header');
1154
+        }
1155 1155
 		
1156
-		if(strlen($data) == 0){
1157
-			$this->debug('no data after headers!');
1158
-			$this->setError('no data present after HTTP headers');
1159
-			return false;
1160
-		}
1156
+        if(strlen($data) == 0){
1157
+            $this->debug('no data after headers!');
1158
+            $this->setError('no data present after HTTP headers');
1159
+            return false;
1160
+        }
1161 1161
 		
1162
-		return $data;
1163
-	}
1162
+        return $data;
1163
+    }
1164 1164
 
1165
-	/**
1166
-	 * sets the content-type for the SOAP message to be sent
1167
-	 *
1168
-	 * @param	string $type the content type, MIME style
1169
-	 * @param	mixed $charset character set used for encoding (or false)
1170
-	 * @access	public
1171
-	 */
1172
-	function setContentType($type, $charset = false) {
1173
-		$this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
1174
-	}
1165
+    /**
1166
+     * sets the content-type for the SOAP message to be sent
1167
+     *
1168
+     * @param	string $type the content type, MIME style
1169
+     * @param	mixed $charset character set used for encoding (or false)
1170
+     * @access	public
1171
+     */
1172
+    function setContentType($type, $charset = false) {
1173
+        $this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
1174
+    }
1175 1175
 
1176
-	/**
1177
-	 * specifies that an HTTP persistent connection should be used
1178
-	 *
1179
-	 * @return	boolean whether the request was honored by this method.
1180
-	 * @access	public
1181
-	 */
1182
-	function usePersistentConnection(){
1183
-		if (isset($this->outgoing_headers['Accept-Encoding'])) {
1184
-			return false;
1185
-		}
1186
-		$this->protocol_version = '1.1';
1187
-		$this->persistentConnection = true;
1188
-		$this->setHeader('Connection', 'Keep-Alive');
1189
-		return true;
1190
-	}
1176
+    /**
1177
+     * specifies that an HTTP persistent connection should be used
1178
+     *
1179
+     * @return	boolean whether the request was honored by this method.
1180
+     * @access	public
1181
+     */
1182
+    function usePersistentConnection(){
1183
+        if (isset($this->outgoing_headers['Accept-Encoding'])) {
1184
+            return false;
1185
+        }
1186
+        $this->protocol_version = '1.1';
1187
+        $this->persistentConnection = true;
1188
+        $this->setHeader('Connection', 'Keep-Alive');
1189
+        return true;
1190
+    }
1191 1191
 
1192
-	/**
1193
-	 * parse an incoming Cookie into it's parts
1194
-	 *
1195
-	 * @param	string $cookie_str content of cookie
1196
-	 * @return	array with data of that cookie
1197
-	 * @access	private
1198
-	 */
1199
-	/*
1192
+    /**
1193
+     * parse an incoming Cookie into it's parts
1194
+     *
1195
+     * @param	string $cookie_str content of cookie
1196
+     * @return	array with data of that cookie
1197
+     * @access	private
1198
+     */
1199
+    /*
1200 1200
 	 * TODO: allow a Set-Cookie string to be parsed into multiple cookies
1201 1201
 	 */
1202
-	function parseCookie($cookie_str) {
1203
-		$cookie_str = str_replace('; ', ';', $cookie_str) . ';';
1204
-		$data = preg_split('/;/', $cookie_str);
1205
-		$value_str = $data[0];
1202
+    function parseCookie($cookie_str) {
1203
+        $cookie_str = str_replace('; ', ';', $cookie_str) . ';';
1204
+        $data = preg_split('/;/', $cookie_str);
1205
+        $value_str = $data[0];
1206 1206
 
1207
-		$cookie_param = 'domain=';
1208
-		$start = strpos($cookie_str, $cookie_param);
1209
-		if ($start > 0) {
1210
-			$domain = substr($cookie_str, $start + strlen($cookie_param));
1211
-			$domain = substr($domain, 0, strpos($domain, ';'));
1212
-		} else {
1213
-			$domain = '';
1214
-		}
1207
+        $cookie_param = 'domain=';
1208
+        $start = strpos($cookie_str, $cookie_param);
1209
+        if ($start > 0) {
1210
+            $domain = substr($cookie_str, $start + strlen($cookie_param));
1211
+            $domain = substr($domain, 0, strpos($domain, ';'));
1212
+        } else {
1213
+            $domain = '';
1214
+        }
1215 1215
 
1216
-		$cookie_param = 'expires=';
1217
-		$start = strpos($cookie_str, $cookie_param);
1218
-		if ($start > 0) {
1219
-			$expires = substr($cookie_str, $start + strlen($cookie_param));
1220
-			$expires = substr($expires, 0, strpos($expires, ';'));
1221
-		} else {
1222
-			$expires = '';
1223
-		}
1216
+        $cookie_param = 'expires=';
1217
+        $start = strpos($cookie_str, $cookie_param);
1218
+        if ($start > 0) {
1219
+            $expires = substr($cookie_str, $start + strlen($cookie_param));
1220
+            $expires = substr($expires, 0, strpos($expires, ';'));
1221
+        } else {
1222
+            $expires = '';
1223
+        }
1224 1224
 
1225
-		$cookie_param = 'path=';
1226
-		$start = strpos($cookie_str, $cookie_param);
1227
-		if ( $start > 0 ) {
1228
-			$path = substr($cookie_str, $start + strlen($cookie_param));
1229
-			$path = substr($path, 0, strpos($path, ';'));
1230
-		} else {
1231
-			$path = '/';
1232
-		}
1225
+        $cookie_param = 'path=';
1226
+        $start = strpos($cookie_str, $cookie_param);
1227
+        if ( $start > 0 ) {
1228
+            $path = substr($cookie_str, $start + strlen($cookie_param));
1229
+            $path = substr($path, 0, strpos($path, ';'));
1230
+        } else {
1231
+            $path = '/';
1232
+        }
1233 1233
 						
1234
-		$cookie_param = ';secure;';
1235
-		if (strpos($cookie_str, $cookie_param) !== FALSE) {
1236
-			$secure = true;
1237
-		} else {
1238
-			$secure = false;
1239
-		}
1234
+        $cookie_param = ';secure;';
1235
+        if (strpos($cookie_str, $cookie_param) !== FALSE) {
1236
+            $secure = true;
1237
+        } else {
1238
+            $secure = false;
1239
+        }
1240 1240
 
1241
-		$sep_pos = strpos($value_str, '=');
1241
+        $sep_pos = strpos($value_str, '=');
1242 1242
 
1243
-		if ($sep_pos) {
1244
-			$name = substr($value_str, 0, $sep_pos);
1245
-			$value = substr($value_str, $sep_pos + 1);
1246
-			$cookie= array(	'name' => $name,
1247
-			                'value' => $value,
1248
-							'domain' => $domain,
1249
-							'path' => $path,
1250
-							'expires' => $expires,
1251
-							'secure' => $secure
1252
-							);		
1253
-			return $cookie;
1254
-		}
1255
-		return false;
1256
-	}
1243
+        if ($sep_pos) {
1244
+            $name = substr($value_str, 0, $sep_pos);
1245
+            $value = substr($value_str, $sep_pos + 1);
1246
+            $cookie= array(	'name' => $name,
1247
+                            'value' => $value,
1248
+                            'domain' => $domain,
1249
+                            'path' => $path,
1250
+                            'expires' => $expires,
1251
+                            'secure' => $secure
1252
+                            );		
1253
+            return $cookie;
1254
+        }
1255
+        return false;
1256
+    }
1257 1257
   
1258
-	/**
1259
-	 * sort out cookies for the current request
1260
-	 *
1261
-	 * @param	array $cookies array with all cookies
1262
-	 * @param	boolean $secure is the send-content secure or not?
1263
-	 * @return	string for Cookie-HTTP-Header
1264
-	 * @access	private
1265
-	 */
1266
-	function getCookiesForRequest($cookies, $secure=false) {
1267
-		$cookie_str = '';
1268
-		if ((! is_null($cookies)) && (is_array($cookies))) {
1269
-			foreach ($cookies as $cookie) {
1270
-				if (! is_array($cookie)) {
1271
-					continue;
1272
-				}
1273
-	    		$this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']);
1274
-				if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
1275
-					if (strtotime($cookie['expires']) <= time()) {
1276
-						$this->debug('cookie has expired');
1277
-						continue;
1278
-					}
1279
-				}
1280
-				if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) {
1281
-					$domain = preg_quote($cookie['domain']);
1282
-					if (! preg_match("'.*$domain$'i", $this->host)) {
1283
-						$this->debug('cookie has different domain');
1284
-						continue;
1285
-					}
1286
-				}
1287
-				if ((isset($cookie['path'])) && (! empty($cookie['path']))) {
1288
-					$path = preg_quote($cookie['path']);
1289
-					if (! preg_match("'^$path.*'i", $this->path)) {
1290
-						$this->debug('cookie is for a different path');
1291
-						continue;
1292
-					}
1293
-				}
1294
-				if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
1295
-					$this->debug('cookie is secure, transport is not');
1296
-					continue;
1297
-				}
1298
-				$cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
1299
-	    		$this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
1300
-			}
1301
-		}
1302
-		return $cookie_str;
1303
-  }
1258
+    /**
1259
+     * sort out cookies for the current request
1260
+     *
1261
+     * @param	array $cookies array with all cookies
1262
+     * @param	boolean $secure is the send-content secure or not?
1263
+     * @return	string for Cookie-HTTP-Header
1264
+     * @access	private
1265
+     */
1266
+    function getCookiesForRequest($cookies, $secure=false) {
1267
+        $cookie_str = '';
1268
+        if ((! is_null($cookies)) && (is_array($cookies))) {
1269
+            foreach ($cookies as $cookie) {
1270
+                if (! is_array($cookie)) {
1271
+                    continue;
1272
+                }
1273
+                $this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']);
1274
+                if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
1275
+                    if (strtotime($cookie['expires']) <= time()) {
1276
+                        $this->debug('cookie has expired');
1277
+                        continue;
1278
+                    }
1279
+                }
1280
+                if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) {
1281
+                    $domain = preg_quote($cookie['domain']);
1282
+                    if (! preg_match("'.*$domain$'i", $this->host)) {
1283
+                        $this->debug('cookie has different domain');
1284
+                        continue;
1285
+                    }
1286
+                }
1287
+                if ((isset($cookie['path'])) && (! empty($cookie['path']))) {
1288
+                    $path = preg_quote($cookie['path']);
1289
+                    if (! preg_match("'^$path.*'i", $this->path)) {
1290
+                        $this->debug('cookie is for a different path');
1291
+                        continue;
1292
+                    }
1293
+                }
1294
+                if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
1295
+                    $this->debug('cookie is secure, transport is not');
1296
+                    continue;
1297
+                }
1298
+                $cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
1299
+                $this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
1300
+            }
1301
+        }
1302
+        return $cookie_str;
1303
+    }
1304 1304
 }
1305 1305
 
1306 1306
 
Please login to merge, or discard this patch.
main/inc/lib/nusoap/nusoapmime.php 1 patch
Indentation   +396 added lines, -396 removed lines patch added patch discarded remove patch
@@ -52,224 +52,224 @@  discard block
 block discarded – undo
52 52
 * @access   public
53 53
 */
54 54
 class nusoap_client_mime extends nusoap_client {
55
-	/**
56
-	 * @var array Each array element in the return is an associative array with keys
57
-	 * data, filename, contenttype, cid
58
-	 * @access private
59
-	 */
60
-	var $requestAttachments = array();
61
-	/**
62
-	 * @var array Each array element in the return is an associative array with keys
63
-	 * data, filename, contenttype, cid
64
-	 * @access private
65
-	 */
66
-	var $responseAttachments;
67
-	/**
68
-	 * @var string
69
-	 * @access private
70
-	 */
71
-	var $mimeContentType;
55
+    /**
56
+     * @var array Each array element in the return is an associative array with keys
57
+     * data, filename, contenttype, cid
58
+     * @access private
59
+     */
60
+    var $requestAttachments = array();
61
+    /**
62
+     * @var array Each array element in the return is an associative array with keys
63
+     * data, filename, contenttype, cid
64
+     * @access private
65
+     */
66
+    var $responseAttachments;
67
+    /**
68
+     * @var string
69
+     * @access private
70
+     */
71
+    var $mimeContentType;
72 72
 	
73
-	/**
74
-	* adds a MIME attachment to the current request.
75
-	*
76
-	* If the $data parameter contains an empty string, this method will read
77
-	* the contents of the file named by the $filename parameter.
78
-	*
79
-	* If the $cid parameter is false, this method will generate the cid.
80
-	*
81
-	* @param string $data The data of the attachment
82
-	* @param string $filename The filename of the attachment (default is empty string)
83
-	* @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream)
84
-	* @param string $cid The content-id (cid) of the attachment (default is false)
85
-	* @return string The content-id (cid) of the attachment
86
-	* @access public
87
-	*/
88
-	function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
89
-		if (! $cid) {
90
-			$cid = md5(uniqid(time()));
91
-		}
92
-
93
-		$info['data'] = $data;
94
-		$info['filename'] = $filename;
95
-		$info['contenttype'] = $contenttype;
96
-		$info['cid'] = $cid;
73
+    /**
74
+     * adds a MIME attachment to the current request.
75
+     *
76
+     * If the $data parameter contains an empty string, this method will read
77
+     * the contents of the file named by the $filename parameter.
78
+     *
79
+     * If the $cid parameter is false, this method will generate the cid.
80
+     *
81
+     * @param string $data The data of the attachment
82
+     * @param string $filename The filename of the attachment (default is empty string)
83
+     * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream)
84
+     * @param string $cid The content-id (cid) of the attachment (default is false)
85
+     * @return string The content-id (cid) of the attachment
86
+     * @access public
87
+     */
88
+    function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
89
+        if (! $cid) {
90
+            $cid = md5(uniqid(time()));
91
+        }
92
+
93
+        $info['data'] = $data;
94
+        $info['filename'] = $filename;
95
+        $info['contenttype'] = $contenttype;
96
+        $info['cid'] = $cid;
97 97
 		
98
-		$this->requestAttachments[] = $info;
99
-
100
-		return $cid;
101
-	}
102
-
103
-	/**
104
-	* clears the MIME attachments for the current request.
105
-	*
106
-	* @access public
107
-	*/
108
-	function clearAttachments() {
109
-		$this->requestAttachments = array();
110
-	}
111
-
112
-	/**
113
-	* gets the MIME attachments from the current response.
114
-	*
115
-	* Each array element in the return is an associative array with keys
116
-	* data, filename, contenttype, cid.  These keys correspond to the parameters
117
-	* for addAttachment.
118
-	*
119
-	* @return array The attachments.
120
-	* @access public
121
-	*/
122
-	function getAttachments() {
123
-		return $this->responseAttachments;
124
-	}
125
-
126
-	/**
127
-	* gets the HTTP body for the current request.
128
-	*
129
-	* @param string $soapmsg The SOAP payload
130
-	* @return string The HTTP body, which includes the SOAP payload
131
-	* @access private
132
-	*/
133
-	function getHTTPBody($soapmsg) {
134
-		if (count($this->requestAttachments) > 0) {
135
-			$params['content_type'] = 'multipart/related; type="text/xml"';
136
-			$mimeMessage = new Mail_mimePart('', $params);
137
-			unset($params);
138
-
139
-			$params['content_type'] = 'text/xml';
140
-			$params['encoding']     = '8bit';
141
-			$params['charset']      = $this->soap_defencoding;
142
-			$mimeMessage->addSubpart($soapmsg, $params);
98
+        $this->requestAttachments[] = $info;
99
+
100
+        return $cid;
101
+    }
102
+
103
+    /**
104
+     * clears the MIME attachments for the current request.
105
+     *
106
+     * @access public
107
+     */
108
+    function clearAttachments() {
109
+        $this->requestAttachments = array();
110
+    }
111
+
112
+    /**
113
+     * gets the MIME attachments from the current response.
114
+     *
115
+     * Each array element in the return is an associative array with keys
116
+     * data, filename, contenttype, cid.  These keys correspond to the parameters
117
+     * for addAttachment.
118
+     *
119
+     * @return array The attachments.
120
+     * @access public
121
+     */
122
+    function getAttachments() {
123
+        return $this->responseAttachments;
124
+    }
125
+
126
+    /**
127
+     * gets the HTTP body for the current request.
128
+     *
129
+     * @param string $soapmsg The SOAP payload
130
+     * @return string The HTTP body, which includes the SOAP payload
131
+     * @access private
132
+     */
133
+    function getHTTPBody($soapmsg) {
134
+        if (count($this->requestAttachments) > 0) {
135
+            $params['content_type'] = 'multipart/related; type="text/xml"';
136
+            $mimeMessage = new Mail_mimePart('', $params);
137
+            unset($params);
138
+
139
+            $params['content_type'] = 'text/xml';
140
+            $params['encoding']     = '8bit';
141
+            $params['charset']      = $this->soap_defencoding;
142
+            $mimeMessage->addSubpart($soapmsg, $params);
143 143
 			
144
-			foreach ($this->requestAttachments as $att) {
145
-				unset($params);
146
-
147
-				$params['content_type'] = $att['contenttype'];
148
-				$params['encoding']     = 'base64';
149
-				$params['disposition']  = 'attachment';
150
-				$params['dfilename']    = $att['filename'];
151
-				$params['cid']          = $att['cid'];
152
-
153
-				if ($att['data'] == '' && $att['filename'] <> '') {
154
-					if ($fd = fopen($att['filename'], 'rb')) {
155
-						$data = fread($fd, filesize($att['filename']));
156
-						fclose($fd);
157
-					} else {
158
-						$data = '';
159
-					}
160
-					$mimeMessage->addSubpart($data, $params);
161
-				} else {
162
-					$mimeMessage->addSubpart($att['data'], $params);
163
-				}
164
-			}
165
-
166
-			$output = $mimeMessage->encode();
167
-			$mimeHeaders = $output['headers'];
144
+            foreach ($this->requestAttachments as $att) {
145
+                unset($params);
146
+
147
+                $params['content_type'] = $att['contenttype'];
148
+                $params['encoding']     = 'base64';
149
+                $params['disposition']  = 'attachment';
150
+                $params['dfilename']    = $att['filename'];
151
+                $params['cid']          = $att['cid'];
152
+
153
+                if ($att['data'] == '' && $att['filename'] <> '') {
154
+                    if ($fd = fopen($att['filename'], 'rb')) {
155
+                        $data = fread($fd, filesize($att['filename']));
156
+                        fclose($fd);
157
+                    } else {
158
+                        $data = '';
159
+                    }
160
+                    $mimeMessage->addSubpart($data, $params);
161
+                } else {
162
+                    $mimeMessage->addSubpart($att['data'], $params);
163
+                }
164
+            }
165
+
166
+            $output = $mimeMessage->encode();
167
+            $mimeHeaders = $output['headers'];
168 168
 	
169
-			foreach ($mimeHeaders as $k => $v) {
170
-				$this->debug("MIME header $k: $v");
171
-				if (strtolower($k) == 'content-type') {
172
-					// PHP header() seems to strip leading whitespace starting
173
-					// the second line, so force everything to one line
174
-					$this->mimeContentType = str_replace("\r\n", " ", $v);
175
-				}
176
-			}
169
+            foreach ($mimeHeaders as $k => $v) {
170
+                $this->debug("MIME header $k: $v");
171
+                if (strtolower($k) == 'content-type') {
172
+                    // PHP header() seems to strip leading whitespace starting
173
+                    // the second line, so force everything to one line
174
+                    $this->mimeContentType = str_replace("\r\n", " ", $v);
175
+                }
176
+            }
177 177
 	
178
-			return $output['body'];
179
-		}
178
+            return $output['body'];
179
+        }
180 180
 
181
-		return parent::getHTTPBody($soapmsg);
182
-	}
181
+        return parent::getHTTPBody($soapmsg);
182
+    }
183 183
 	
184
-	/**
185
-	* gets the HTTP content type for the current request.
186
-	*
187
-	* Note: getHTTPBody must be called before this.
188
-	*
189
-	* @return string the HTTP content type for the current request.
190
-	* @access private
191
-	*/
192
-	function getHTTPContentType() {
193
-		if (count($this->requestAttachments) > 0) {
194
-			return $this->mimeContentType;
195
-		}
196
-		return parent::getHTTPContentType();
197
-	}
184
+    /**
185
+     * gets the HTTP content type for the current request.
186
+     *
187
+     * Note: getHTTPBody must be called before this.
188
+     *
189
+     * @return string the HTTP content type for the current request.
190
+     * @access private
191
+     */
192
+    function getHTTPContentType() {
193
+        if (count($this->requestAttachments) > 0) {
194
+            return $this->mimeContentType;
195
+        }
196
+        return parent::getHTTPContentType();
197
+    }
198 198
 	
199
-	/**
200
-	* gets the HTTP content type charset for the current request.
201
-	* returns false for non-text content types.
202
-	*
203
-	* Note: getHTTPBody must be called before this.
204
-	*
205
-	* @return string the HTTP content type charset for the current request.
206
-	* @access private
207
-	*/
208
-	function getHTTPContentTypeCharset() {
209
-		if (count($this->requestAttachments) > 0) {
210
-			return false;
211
-		}
212
-		return parent::getHTTPContentTypeCharset();
213
-	}
214
-
215
-	/**
216
-	* processes SOAP message returned from server
217
-	*
218
-	* @param	array	$headers	The HTTP headers
219
-	* @param	string	$data		unprocessed response data from server
220
-	* @return	mixed	value of the message, decoded into a PHP type
221
-	* @access   private
222
-	*/
199
+    /**
200
+     * gets the HTTP content type charset for the current request.
201
+     * returns false for non-text content types.
202
+     *
203
+     * Note: getHTTPBody must be called before this.
204
+     *
205
+     * @return string the HTTP content type charset for the current request.
206
+     * @access private
207
+     */
208
+    function getHTTPContentTypeCharset() {
209
+        if (count($this->requestAttachments) > 0) {
210
+            return false;
211
+        }
212
+        return parent::getHTTPContentTypeCharset();
213
+    }
214
+
215
+    /**
216
+     * processes SOAP message returned from server
217
+     *
218
+     * @param	array	$headers	The HTTP headers
219
+     * @param	string	$data		unprocessed response data from server
220
+     * @return	mixed	value of the message, decoded into a PHP type
221
+     * @access   private
222
+     */
223 223
     function parseResponse($headers, $data) {
224
-		$this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
225
-		$this->responseAttachments = array();
226
-		if (strstr($headers['content-type'], 'multipart/related')) {
227
-			$this->debug('Decode multipart/related');
228
-			$input = '';
229
-			foreach ($headers as $k => $v) {
230
-				$input .= "$k: $v\r\n";
231
-			}
232
-			$params['input'] = $input . "\r\n" . $data;
233
-			$params['include_bodies'] = true;
234
-			$params['decode_bodies'] = true;
235
-			$params['decode_headers'] = true;
224
+        $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
225
+        $this->responseAttachments = array();
226
+        if (strstr($headers['content-type'], 'multipart/related')) {
227
+            $this->debug('Decode multipart/related');
228
+            $input = '';
229
+            foreach ($headers as $k => $v) {
230
+                $input .= "$k: $v\r\n";
231
+            }
232
+            $params['input'] = $input . "\r\n" . $data;
233
+            $params['include_bodies'] = true;
234
+            $params['decode_bodies'] = true;
235
+            $params['decode_headers'] = true;
236 236
 			
237
-			$structure = Mail_mimeDecode::decode($params);
238
-
239
-			foreach ($structure->parts as $part) {
240
-				if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
241
-					$this->debug('Have root part of type ' . $part->headers['content-type']);
242
-					$root = $part->body;
243
-					$return = parent::parseResponse($part->headers, $part->body);
244
-				} else {
245
-					$this->debug('Have an attachment of type ' . $part->headers['content-type']);
246
-					$info['data'] = $part->body;
247
-					$info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
248
-					$info['contenttype'] = $part->headers['content-type'];
249
-					$info['cid'] = $part->headers['content-id'];
250
-					$this->responseAttachments[] = $info;
251
-				}
252
-			}
237
+            $structure = Mail_mimeDecode::decode($params);
238
+
239
+            foreach ($structure->parts as $part) {
240
+                if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
241
+                    $this->debug('Have root part of type ' . $part->headers['content-type']);
242
+                    $root = $part->body;
243
+                    $return = parent::parseResponse($part->headers, $part->body);
244
+                } else {
245
+                    $this->debug('Have an attachment of type ' . $part->headers['content-type']);
246
+                    $info['data'] = $part->body;
247
+                    $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
248
+                    $info['contenttype'] = $part->headers['content-type'];
249
+                    $info['cid'] = $part->headers['content-id'];
250
+                    $this->responseAttachments[] = $info;
251
+                }
252
+            }
253 253
 		
254
-			if (isset($return)) {
255
-				$this->responseData = $root;
256
-				return $return;
257
-			}
254
+            if (isset($return)) {
255
+                $this->responseData = $root;
256
+                return $return;
257
+            }
258 258
 			
259
-			$this->setError('No root part found in multipart/related content');
260
-			return '';
261
-		}
262
-		$this->debug('Not multipart/related');
263
-		return parent::parseResponse($headers, $data);
264
-	}
259
+            $this->setError('No root part found in multipart/related content');
260
+            return '';
261
+        }
262
+        $this->debug('Not multipart/related');
263
+        return parent::parseResponse($headers, $data);
264
+    }
265 265
 }
266 266
 
267 267
 /*
268 268
  *	For backwards compatiblity, define soapclientmime unless the PHP SOAP extension is loaded.
269 269
  */
270 270
 if (!extension_loaded('soap')) {
271
-	class soapclientmime extends nusoap_client_mime {
272
-	}
271
+    class soapclientmime extends nusoap_client_mime {
272
+    }
273 273
 }
274 274
 
275 275
 /**
@@ -282,214 +282,214 @@  discard block
 block discarded – undo
282 282
 * @access   public
283 283
 */
284 284
 class nusoap_server_mime extends nusoap_server {
285
-	/**
286
-	 * @var array Each array element in the return is an associative array with keys
287
-	 * data, filename, contenttype, cid
288
-	 * @access private
289
-	 */
290
-	var $requestAttachments = array();
291
-	/**
292
-	 * @var array Each array element in the return is an associative array with keys
293
-	 * data, filename, contenttype, cid
294
-	 * @access private
295
-	 */
296
-	var $responseAttachments;
297
-	/**
298
-	 * @var string
299
-	 * @access private
300
-	 */
301
-	var $mimeContentType;
285
+    /**
286
+     * @var array Each array element in the return is an associative array with keys
287
+     * data, filename, contenttype, cid
288
+     * @access private
289
+     */
290
+    var $requestAttachments = array();
291
+    /**
292
+     * @var array Each array element in the return is an associative array with keys
293
+     * data, filename, contenttype, cid
294
+     * @access private
295
+     */
296
+    var $responseAttachments;
297
+    /**
298
+     * @var string
299
+     * @access private
300
+     */
301
+    var $mimeContentType;
302 302
 	
303
-	/**
304
-	* adds a MIME attachment to the current response.
305
-	*
306
-	* If the $data parameter contains an empty string, this method will read
307
-	* the contents of the file named by the $filename parameter.
308
-	*
309
-	* If the $cid parameter is false, this method will generate the cid.
310
-	*
311
-	* @param string $data The data of the attachment
312
-	* @param string $filename The filename of the attachment (default is empty string)
313
-	* @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream)
314
-	* @param string $cid The content-id (cid) of the attachment (default is false)
315
-	* @return string The content-id (cid) of the attachment
316
-	* @access public
317
-	*/
318
-	function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
319
-		if (! $cid) {
320
-			$cid = md5(uniqid(time()));
321
-		}
322
-
323
-		$info['data'] = $data;
324
-		$info['filename'] = $filename;
325
-		$info['contenttype'] = $contenttype;
326
-		$info['cid'] = $cid;
303
+    /**
304
+     * adds a MIME attachment to the current response.
305
+     *
306
+     * If the $data parameter contains an empty string, this method will read
307
+     * the contents of the file named by the $filename parameter.
308
+     *
309
+     * If the $cid parameter is false, this method will generate the cid.
310
+     *
311
+     * @param string $data The data of the attachment
312
+     * @param string $filename The filename of the attachment (default is empty string)
313
+     * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream)
314
+     * @param string $cid The content-id (cid) of the attachment (default is false)
315
+     * @return string The content-id (cid) of the attachment
316
+     * @access public
317
+     */
318
+    function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
319
+        if (! $cid) {
320
+            $cid = md5(uniqid(time()));
321
+        }
322
+
323
+        $info['data'] = $data;
324
+        $info['filename'] = $filename;
325
+        $info['contenttype'] = $contenttype;
326
+        $info['cid'] = $cid;
327 327
 		
328
-		$this->responseAttachments[] = $info;
329
-
330
-		return $cid;
331
-	}
332
-
333
-	/**
334
-	* clears the MIME attachments for the current response.
335
-	*
336
-	* @access public
337
-	*/
338
-	function clearAttachments() {
339
-		$this->responseAttachments = array();
340
-	}
341
-
342
-	/**
343
-	* gets the MIME attachments from the current request.
344
-	*
345
-	* Each array element in the return is an associative array with keys
346
-	* data, filename, contenttype, cid.  These keys correspond to the parameters
347
-	* for addAttachment.
348
-	*
349
-	* @return array The attachments.
350
-	* @access public
351
-	*/
352
-	function getAttachments() {
353
-		return $this->requestAttachments;
354
-	}
355
-
356
-	/**
357
-	* gets the HTTP body for the current response.
358
-	*
359
-	* @param string $soapmsg The SOAP payload
360
-	* @return string The HTTP body, which includes the SOAP payload
361
-	* @access private
362
-	*/
363
-	function getHTTPBody($soapmsg) {
364
-		if (count($this->responseAttachments) > 0) {
365
-			$params['content_type'] = 'multipart/related; type="text/xml"';
366
-			$mimeMessage = new Mail_mimePart('', $params);
367
-			unset($params);
368
-
369
-			$params['content_type'] = 'text/xml';
370
-			$params['encoding']     = '8bit';
371
-			$params['charset']      = $this->soap_defencoding;
372
-			$mimeMessage->addSubpart($soapmsg, $params);
328
+        $this->responseAttachments[] = $info;
329
+
330
+        return $cid;
331
+    }
332
+
333
+    /**
334
+     * clears the MIME attachments for the current response.
335
+     *
336
+     * @access public
337
+     */
338
+    function clearAttachments() {
339
+        $this->responseAttachments = array();
340
+    }
341
+
342
+    /**
343
+     * gets the MIME attachments from the current request.
344
+     *
345
+     * Each array element in the return is an associative array with keys
346
+     * data, filename, contenttype, cid.  These keys correspond to the parameters
347
+     * for addAttachment.
348
+     *
349
+     * @return array The attachments.
350
+     * @access public
351
+     */
352
+    function getAttachments() {
353
+        return $this->requestAttachments;
354
+    }
355
+
356
+    /**
357
+     * gets the HTTP body for the current response.
358
+     *
359
+     * @param string $soapmsg The SOAP payload
360
+     * @return string The HTTP body, which includes the SOAP payload
361
+     * @access private
362
+     */
363
+    function getHTTPBody($soapmsg) {
364
+        if (count($this->responseAttachments) > 0) {
365
+            $params['content_type'] = 'multipart/related; type="text/xml"';
366
+            $mimeMessage = new Mail_mimePart('', $params);
367
+            unset($params);
368
+
369
+            $params['content_type'] = 'text/xml';
370
+            $params['encoding']     = '8bit';
371
+            $params['charset']      = $this->soap_defencoding;
372
+            $mimeMessage->addSubpart($soapmsg, $params);
373 373
 			
374
-			foreach ($this->responseAttachments as $att) {
375
-				unset($params);
376
-
377
-				$params['content_type'] = $att['contenttype'];
378
-				$params['encoding']     = 'base64';
379
-				$params['disposition']  = 'attachment';
380
-				$params['dfilename']    = $att['filename'];
381
-				$params['cid']          = $att['cid'];
382
-
383
-				if ($att['data'] == '' && $att['filename'] <> '') {
384
-					if ($fd = fopen($att['filename'], 'rb')) {
385
-						$data = fread($fd, filesize($att['filename']));
386
-						fclose($fd);
387
-					} else {
388
-						$data = '';
389
-					}
390
-					$mimeMessage->addSubpart($data, $params);
391
-				} else {
392
-					$mimeMessage->addSubpart($att['data'], $params);
393
-				}
394
-			}
395
-
396
-			$output = $mimeMessage->encode();
397
-			$mimeHeaders = $output['headers'];
374
+            foreach ($this->responseAttachments as $att) {
375
+                unset($params);
376
+
377
+                $params['content_type'] = $att['contenttype'];
378
+                $params['encoding']     = 'base64';
379
+                $params['disposition']  = 'attachment';
380
+                $params['dfilename']    = $att['filename'];
381
+                $params['cid']          = $att['cid'];
382
+
383
+                if ($att['data'] == '' && $att['filename'] <> '') {
384
+                    if ($fd = fopen($att['filename'], 'rb')) {
385
+                        $data = fread($fd, filesize($att['filename']));
386
+                        fclose($fd);
387
+                    } else {
388
+                        $data = '';
389
+                    }
390
+                    $mimeMessage->addSubpart($data, $params);
391
+                } else {
392
+                    $mimeMessage->addSubpart($att['data'], $params);
393
+                }
394
+            }
395
+
396
+            $output = $mimeMessage->encode();
397
+            $mimeHeaders = $output['headers'];
398 398
 	
399
-			foreach ($mimeHeaders as $k => $v) {
400
-				$this->debug("MIME header $k: $v");
401
-				if (strtolower($k) == 'content-type') {
402
-					// PHP header() seems to strip leading whitespace starting
403
-					// the second line, so force everything to one line
404
-					$this->mimeContentType = str_replace("\r\n", " ", $v);
405
-				}
406
-			}
399
+            foreach ($mimeHeaders as $k => $v) {
400
+                $this->debug("MIME header $k: $v");
401
+                if (strtolower($k) == 'content-type') {
402
+                    // PHP header() seems to strip leading whitespace starting
403
+                    // the second line, so force everything to one line
404
+                    $this->mimeContentType = str_replace("\r\n", " ", $v);
405
+                }
406
+            }
407 407
 	
408
-			return $output['body'];
409
-		}
408
+            return $output['body'];
409
+        }
410 410
 
411
-		return parent::getHTTPBody($soapmsg);
412
-	}
411
+        return parent::getHTTPBody($soapmsg);
412
+    }
413 413
 	
414
-	/**
415
-	* gets the HTTP content type for the current response.
416
-	*
417
-	* Note: getHTTPBody must be called before this.
418
-	*
419
-	* @return string the HTTP content type for the current response.
420
-	* @access private
421
-	*/
422
-	function getHTTPContentType() {
423
-		if (count($this->responseAttachments) > 0) {
424
-			return $this->mimeContentType;
425
-		}
426
-		return parent::getHTTPContentType();
427
-	}
414
+    /**
415
+     * gets the HTTP content type for the current response.
416
+     *
417
+     * Note: getHTTPBody must be called before this.
418
+     *
419
+     * @return string the HTTP content type for the current response.
420
+     * @access private
421
+     */
422
+    function getHTTPContentType() {
423
+        if (count($this->responseAttachments) > 0) {
424
+            return $this->mimeContentType;
425
+        }
426
+        return parent::getHTTPContentType();
427
+    }
428 428
 	
429
-	/**
430
-	* gets the HTTP content type charset for the current response.
431
-	* returns false for non-text content types.
432
-	*
433
-	* Note: getHTTPBody must be called before this.
434
-	*
435
-	* @return string the HTTP content type charset for the current response.
436
-	* @access private
437
-	*/
438
-	function getHTTPContentTypeCharset() {
439
-		if (count($this->responseAttachments) > 0) {
440
-			return false;
441
-		}
442
-		return parent::getHTTPContentTypeCharset();
443
-	}
444
-
445
-	/**
446
-	* processes SOAP message received from client
447
-	*
448
-	* @param	array	$headers	The HTTP headers
449
-	* @param	string	$data		unprocessed request data from client
450
-	* @return	mixed	value of the message, decoded into a PHP type
451
-	* @access   private
452
-	*/
429
+    /**
430
+     * gets the HTTP content type charset for the current response.
431
+     * returns false for non-text content types.
432
+     *
433
+     * Note: getHTTPBody must be called before this.
434
+     *
435
+     * @return string the HTTP content type charset for the current response.
436
+     * @access private
437
+     */
438
+    function getHTTPContentTypeCharset() {
439
+        if (count($this->responseAttachments) > 0) {
440
+            return false;
441
+        }
442
+        return parent::getHTTPContentTypeCharset();
443
+    }
444
+
445
+    /**
446
+     * processes SOAP message received from client
447
+     *
448
+     * @param	array	$headers	The HTTP headers
449
+     * @param	string	$data		unprocessed request data from client
450
+     * @return	mixed	value of the message, decoded into a PHP type
451
+     * @access   private
452
+     */
453 453
     function parseRequest($headers, $data) {
454
-		$this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
455
-		$this->requestAttachments = array();
456
-		if (strstr($headers['content-type'], 'multipart/related')) {
457
-			$this->debug('Decode multipart/related');
458
-			$input = '';
459
-			foreach ($headers as $k => $v) {
460
-				$input .= "$k: $v\r\n";
461
-			}
462
-			$params['input'] = $input . "\r\n" . $data;
463
-			$params['include_bodies'] = true;
464
-			$params['decode_bodies'] = true;
465
-			$params['decode_headers'] = true;
454
+        $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
455
+        $this->requestAttachments = array();
456
+        if (strstr($headers['content-type'], 'multipart/related')) {
457
+            $this->debug('Decode multipart/related');
458
+            $input = '';
459
+            foreach ($headers as $k => $v) {
460
+                $input .= "$k: $v\r\n";
461
+            }
462
+            $params['input'] = $input . "\r\n" . $data;
463
+            $params['include_bodies'] = true;
464
+            $params['decode_bodies'] = true;
465
+            $params['decode_headers'] = true;
466 466
 			
467
-			$structure = Mail_mimeDecode::decode($params);
468
-
469
-			foreach ($structure->parts as $part) {
470
-				if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
471
-					$this->debug('Have root part of type ' . $part->headers['content-type']);
472
-					$return = parent::parseRequest($part->headers, $part->body);
473
-				} else {
474
-					$this->debug('Have an attachment of type ' . $part->headers['content-type']);
475
-					$info['data'] = $part->body;
476
-					$info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
477
-					$info['contenttype'] = $part->headers['content-type'];
478
-					$info['cid'] = $part->headers['content-id'];
479
-					$this->requestAttachments[] = $info;
480
-				}
481
-			}
467
+            $structure = Mail_mimeDecode::decode($params);
468
+
469
+            foreach ($structure->parts as $part) {
470
+                if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
471
+                    $this->debug('Have root part of type ' . $part->headers['content-type']);
472
+                    $return = parent::parseRequest($part->headers, $part->body);
473
+                } else {
474
+                    $this->debug('Have an attachment of type ' . $part->headers['content-type']);
475
+                    $info['data'] = $part->body;
476
+                    $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
477
+                    $info['contenttype'] = $part->headers['content-type'];
478
+                    $info['cid'] = $part->headers['content-id'];
479
+                    $this->requestAttachments[] = $info;
480
+                }
481
+            }
482 482
 		
483
-			if (isset($return)) {
484
-				return $return;
485
-			}
483
+            if (isset($return)) {
484
+                return $return;
485
+            }
486 486
 			
487
-			$this->setError('No root part found in multipart/related content');
488
-			return;
489
-		}
490
-		$this->debug('Not multipart/related');
491
-		return parent::parseRequest($headers, $data);
492
-	}
487
+            $this->setError('No root part found in multipart/related content');
488
+            return;
489
+        }
490
+        $this->debug('Not multipart/related');
491
+        return parent::parseRequest($headers, $data);
492
+    }
493 493
 }
494 494
 
495 495
 /*
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.wsdl.php 1 patch
Indentation   +1576 added lines, -1576 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 * @access public
14 14
 */
15 15
 class wsdl extends nusoap_base {
16
-	// URL or filename of the root of this WSDL
16
+    // URL or filename of the root of this WSDL
17 17
     var $wsdl;
18 18
     // define internal arrays of bindings, ports, operations, messages, etc.
19 19
     var $schemas = array();
@@ -40,142 +40,142 @@  discard block
 block discarded – undo
40 40
     var $position = 0;
41 41
     var $depth = 0;
42 42
     var $depth_array = array();
43
-	// for getting wsdl
44
-	var $proxyhost = '';
43
+    // for getting wsdl
44
+    var $proxyhost = '';
45 45
     var $proxyport = '';
46
-	var $proxyusername = '';
47
-	var $proxypassword = '';
48
-	var $timeout = 0;
49
-	var $response_timeout = 30;
50
-	var $curl_options = array();	// User-specified cURL options
51
-	var $use_curl = false;			// whether to always try to use cURL
52
-	// for HTTP authentication
53
-	var $username = '';				// Username for HTTP authentication
54
-	var $password = '';				// Password for HTTP authentication
55
-	var $authtype = '';				// Type of HTTP authentication
56
-	var $certRequest = array();		// Certificate for HTTP SSL authentication
46
+    var $proxyusername = '';
47
+    var $proxypassword = '';
48
+    var $timeout = 0;
49
+    var $response_timeout = 30;
50
+    var $curl_options = array();	// User-specified cURL options
51
+    var $use_curl = false;			// whether to always try to use cURL
52
+    // for HTTP authentication
53
+    var $username = '';				// Username for HTTP authentication
54
+    var $password = '';				// Password for HTTP authentication
55
+    var $authtype = '';				// Type of HTTP authentication
56
+    var $certRequest = array();		// Certificate for HTTP SSL authentication
57 57
 
58 58
     /**
59 59
      * constructor
60 60
      *
61 61
      * @param string $wsdl WSDL document URL
62
-	 * @param string $proxyhost
63
-	 * @param string $proxyport
64
-	 * @param string $proxyusername
65
-	 * @param string $proxypassword
66
-	 * @param integer $timeout set the connection timeout
67
-	 * @param integer $response_timeout set the response timeout
68
-	 * @param array $curl_options user-specified cURL options
69
-	 * @param boolean $use_curl try to use cURL
62
+     * @param string $proxyhost
63
+     * @param string $proxyport
64
+     * @param string $proxyusername
65
+     * @param string $proxypassword
66
+     * @param integer $timeout set the connection timeout
67
+     * @param integer $response_timeout set the response timeout
68
+     * @param array $curl_options user-specified cURL options
69
+     * @param boolean $use_curl try to use cURL
70 70
      * @access public
71 71
      */
72 72
     function wsdl($wsdl = '',$proxyhost=false,$proxyport=false,$proxyusername=false,$proxypassword=false,$timeout=0,$response_timeout=30,$curl_options=null,$use_curl=false){
73
-		parent::nusoap_base();
74
-		$this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
73
+        parent::nusoap_base();
74
+        $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
75 75
         $this->proxyhost = $proxyhost;
76 76
         $this->proxyport = $proxyport;
77
-		$this->proxyusername = $proxyusername;
78
-		$this->proxypassword = $proxypassword;
79
-		$this->timeout = $timeout;
80
-		$this->response_timeout = $response_timeout;
81
-		if (is_array($curl_options))
82
-			$this->curl_options = $curl_options;
83
-		$this->use_curl = $use_curl;
84
-		$this->fetchWSDL($wsdl);
77
+        $this->proxyusername = $proxyusername;
78
+        $this->proxypassword = $proxypassword;
79
+        $this->timeout = $timeout;
80
+        $this->response_timeout = $response_timeout;
81
+        if (is_array($curl_options))
82
+            $this->curl_options = $curl_options;
83
+        $this->use_curl = $use_curl;
84
+        $this->fetchWSDL($wsdl);
85 85
     }
86 86
 
87
-	/**
88
-	 * fetches the WSDL document and parses it
89
-	 *
90
-	 * @access public
91
-	 */
92
-	function fetchWSDL($wsdl) {
93
-		$this->debug("parse and process WSDL path=$wsdl");
94
-		$this->wsdl = $wsdl;
87
+    /**
88
+     * fetches the WSDL document and parses it
89
+     *
90
+     * @access public
91
+     */
92
+    function fetchWSDL($wsdl) {
93
+        $this->debug("parse and process WSDL path=$wsdl");
94
+        $this->wsdl = $wsdl;
95 95
         // parse wsdl file
96 96
         if ($this->wsdl != "") {
97 97
             $this->parseWSDL($this->wsdl);
98 98
         }
99 99
         // imports
100 100
         // TODO: handle imports more properly, grabbing them in-line and nesting them
101
-    	$imported_urls = array();
102
-    	$imported = 1;
103
-    	while ($imported > 0) {
104
-    		$imported = 0;
105
-    		// Schema imports
106
-    		foreach ($this->schemas as $ns => $list) {
107
-    			foreach ($list as $xs) {
108
-					$wsdlparts = parse_url($this->wsdl);	// this is bogusly simple!
109
-		            foreach ($xs->imports as $ns2 => $list2) {
110
-		                for ($ii = 0; $ii < count($list2); $ii++) {
111
-		                	if (! $list2[$ii]['loaded']) {
112
-		                		$this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true;
113
-		                		$url = $list2[$ii]['location'];
114
-								if ($url != '') {
115
-									$urlparts = parse_url($url);
116
-									if (!isset($urlparts['host'])) {
117
-										$url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' .$wsdlparts['port'] : '') .
118
-												substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
119
-									}
120
-									if (! in_array($url, $imported_urls)) {
121
-					                	$this->parseWSDL($url);
122
-				                		$imported++;
123
-				                		$imported_urls[] = $url;
124
-				                	}
125
-								} else {
126
-									$this->debug("Unexpected scenario: empty URL for unloaded import");
127
-								}
128
-							}
129
-						}
130
-		            }
131
-    			}
132
-    		}
133
-    		// WSDL imports
134
-			$wsdlparts = parse_url($this->wsdl);	// this is bogusly simple!
101
+        $imported_urls = array();
102
+        $imported = 1;
103
+        while ($imported > 0) {
104
+            $imported = 0;
105
+            // Schema imports
106
+            foreach ($this->schemas as $ns => $list) {
107
+                foreach ($list as $xs) {
108
+                    $wsdlparts = parse_url($this->wsdl);	// this is bogusly simple!
109
+                    foreach ($xs->imports as $ns2 => $list2) {
110
+                        for ($ii = 0; $ii < count($list2); $ii++) {
111
+                            if (! $list2[$ii]['loaded']) {
112
+                                $this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true;
113
+                                $url = $list2[$ii]['location'];
114
+                                if ($url != '') {
115
+                                    $urlparts = parse_url($url);
116
+                                    if (!isset($urlparts['host'])) {
117
+                                        $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' .$wsdlparts['port'] : '') .
118
+                                                substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
119
+                                    }
120
+                                    if (! in_array($url, $imported_urls)) {
121
+                                        $this->parseWSDL($url);
122
+                                        $imported++;
123
+                                        $imported_urls[] = $url;
124
+                                    }
125
+                                } else {
126
+                                    $this->debug("Unexpected scenario: empty URL for unloaded import");
127
+                                }
128
+                            }
129
+                        }
130
+                    }
131
+                }
132
+            }
133
+            // WSDL imports
134
+            $wsdlparts = parse_url($this->wsdl);	// this is bogusly simple!
135 135
             foreach ($this->import as $ns => $list) {
136 136
                 for ($ii = 0; $ii < count($list); $ii++) {
137
-                	if (! $list[$ii]['loaded']) {
138
-                		$this->import[$ns][$ii]['loaded'] = true;
139
-                		$url = $list[$ii]['location'];
140
-						if ($url != '') {
141
-							$urlparts = parse_url($url);
142
-							if (!isset($urlparts['host'])) {
143
-								$url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') .
144
-										substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
145
-							}
146
-							if (! in_array($url, $imported_urls)) {
147
-			                	$this->parseWSDL($url);
148
-		                		$imported++;
149
-		                		$imported_urls[] = $url;
150
-		                	}
151
-						} else {
152
-							$this->debug("Unexpected scenario: empty URL for unloaded import");
153
-						}
154
-					}
155
-				}
137
+                    if (! $list[$ii]['loaded']) {
138
+                        $this->import[$ns][$ii]['loaded'] = true;
139
+                        $url = $list[$ii]['location'];
140
+                        if ($url != '') {
141
+                            $urlparts = parse_url($url);
142
+                            if (!isset($urlparts['host'])) {
143
+                                $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') .
144
+                                        substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
145
+                            }
146
+                            if (! in_array($url, $imported_urls)) {
147
+                                $this->parseWSDL($url);
148
+                                $imported++;
149
+                                $imported_urls[] = $url;
150
+                            }
151
+                        } else {
152
+                            $this->debug("Unexpected scenario: empty URL for unloaded import");
153
+                        }
154
+                    }
155
+                }
156 156
             }
157
-		}
157
+        }
158 158
         // add new data to operation data
159 159
         foreach($this->bindings as $binding => $bindingData) {
160 160
             if (isset($bindingData['operations']) && is_array($bindingData['operations'])) {
161 161
                 foreach($bindingData['operations'] as $operation => $data) {
162 162
                     $this->debug('post-parse data gathering for ' . $operation);
163 163
                     $this->bindings[$binding]['operations'][$operation]['input'] =
164
-						isset($this->bindings[$binding]['operations'][$operation]['input']) ?
165
-						array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) :
166
-						$this->portTypes[ $bindingData['portType'] ][$operation]['input'];
164
+                        isset($this->bindings[$binding]['operations'][$operation]['input']) ?
165
+                        array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) :
166
+                        $this->portTypes[ $bindingData['portType'] ][$operation]['input'];
167 167
                     $this->bindings[$binding]['operations'][$operation]['output'] =
168
-						isset($this->bindings[$binding]['operations'][$operation]['output']) ?
169
-						array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) :
170
-						$this->portTypes[ $bindingData['portType'] ][$operation]['output'];
168
+                        isset($this->bindings[$binding]['operations'][$operation]['output']) ?
169
+                        array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) :
170
+                        $this->portTypes[ $bindingData['portType'] ][$operation]['output'];
171 171
                     if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ])){
172
-						$this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ];
173
-					}
174
-					if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])){
175
-                   		$this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ];
172
+                        $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ];
173
+                    }
174
+                    if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])){
175
+                            $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ];
176 176
                     }
177 177
                     // Set operation style if necessary, but do not override one already provided
178
-					if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) {
178
+                    if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) {
179 179
                         $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style'];
180 180
                     }
181 181
                     $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : '';
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                 }
185 185
             }
186 186
         }
187
-	}
187
+    }
188 188
 
189 189
     /**
190 190
      * parses the wsdl document
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      * @access private
194 194
      */
195 195
     function parseWSDL($wsdl = '') {
196
-		$this->debug("parse WSDL at path=$wsdl");
196
+        $this->debug("parse WSDL at path=$wsdl");
197 197
 
198 198
         if ($wsdl == '') {
199 199
             $this->debug('no wsdl passed to parseWSDL()!!');
@@ -206,38 +206,38 @@  discard block
 block discarded – undo
206 206
 
207 207
         if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) {
208 208
             $this->debug('getting WSDL http(s) URL ' . $wsdl);
209
-        	// get wsdl
210
-	        $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl);
211
-			$tr->request_method = 'GET';
212
-			$tr->useSOAPAction = false;
213
-			if($this->proxyhost && $this->proxyport){
214
-				$tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
215
-			}
216
-			if ($this->authtype != '') {
217
-				$tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
218
-			}
219
-			$tr->setEncoding('gzip, deflate');
220
-			$wsdl_string = $tr->send('', $this->timeout, $this->response_timeout);
221
-			//$this->debug("WSDL request\n" . $tr->outgoing_payload);
222
-			//$this->debug("WSDL response\n" . $tr->incoming_payload);
223
-			$this->appendDebug($tr->getDebug());
224
-			// catch errors
225
-			if($err = $tr->getError() ){
226
-				$errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: '.$err;
227
-				$this->debug($errstr);
228
-	            $this->setError($errstr);
229
-				unset($tr);
230
-	            return false;
231
-			}
232
-			unset($tr);
233
-			$this->debug("got WSDL URL");
209
+            // get wsdl
210
+            $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl);
211
+            $tr->request_method = 'GET';
212
+            $tr->useSOAPAction = false;
213
+            if($this->proxyhost && $this->proxyport){
214
+                $tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
215
+            }
216
+            if ($this->authtype != '') {
217
+                $tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
218
+            }
219
+            $tr->setEncoding('gzip, deflate');
220
+            $wsdl_string = $tr->send('', $this->timeout, $this->response_timeout);
221
+            //$this->debug("WSDL request\n" . $tr->outgoing_payload);
222
+            //$this->debug("WSDL response\n" . $tr->incoming_payload);
223
+            $this->appendDebug($tr->getDebug());
224
+            // catch errors
225
+            if($err = $tr->getError() ){
226
+                $errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: '.$err;
227
+                $this->debug($errstr);
228
+                $this->setError($errstr);
229
+                unset($tr);
230
+                return false;
231
+            }
232
+            unset($tr);
233
+            $this->debug("got WSDL URL");
234 234
         } else {
235 235
             // $wsdl is not http(s), so treat it as a file URL or plain file path
236
-        	if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) {
237
-        		$path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path'];
238
-        	} else {
239
-        		$path = $wsdl;
240
-        	}
236
+            if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) {
237
+                $path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path'];
238
+            } else {
239
+                $path = $wsdl;
240
+            }
241 241
             $this->debug('getting WSDL file ' . $path);
242 242
             if ($fp = @fopen($path, 'r')) {
243 243
                 $wsdl_string = '';
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
                 }
247 247
                 fclose($fp);
248 248
             } else {
249
-            	$errstr = "Bad path to WSDL file $path";
250
-            	$this->debug($errstr);
249
+                $errstr = "Bad path to WSDL file $path";
250
+                $this->debug($errstr);
251 251
                 $this->setError($errstr);
252 252
                 return false;
253 253
             }
@@ -268,23 +268,23 @@  discard block
 block discarded – undo
268 268
         if (!xml_parse($this->parser, $wsdl_string, true)) {
269 269
             // Display an error message.
270 270
             $errstr = sprintf(
271
-				'XML error parsing WSDL from %s on line %d: %s',
272
-				$wsdl,
271
+                'XML error parsing WSDL from %s on line %d: %s',
272
+                $wsdl,
273 273
                 xml_get_current_line_number($this->parser),
274 274
                 xml_error_string(xml_get_error_code($this->parser))
275 275
                 );
276 276
             $this->debug($errstr);
277
-			$this->debug("XML payload:\n" . $wsdl_string);
277
+            $this->debug("XML payload:\n" . $wsdl_string);
278 278
             $this->setError($errstr);
279 279
             return false;
280 280
         }
281
-		// free the parser
281
+        // free the parser
282 282
         xml_parser_free($this->parser);
283 283
         $this->debug('Parsing WSDL done');
284
-		// catch wsdl parse errors
285
-		if($this->getError()){
286
-			return false;
287
-		}
284
+        // catch wsdl parse errors
285
+        if($this->getError()){
286
+            return false;
287
+        }
288 288
         return true;
289 289
     }
290 290
 
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
             $this->appendDebug($this->currentSchema->getDebug());
304 304
             $this->currentSchema->clearDebug();
305 305
         } elseif (preg_match('/schema$/', $name)) {
306
-        	$this->debug('Parsing WSDL schema');
306
+            $this->debug('Parsing WSDL schema');
307 307
             // $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")");
308 308
             $this->status = 'schema';
309 309
             $this->currentSchema = new nusoap_xmlschema('', '', $this->namespaces);
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
             $this->message[$pos] = array('cdata' => '');
320 320
             // process attributes
321 321
             if (count($attrs) > 0) {
322
-				// register namespace declarations
322
+                // register namespace declarations
323 323
                 foreach($attrs as $k => $v) {
324 324
                     if (preg_match('/^xmlns/',$k)) {
325 325
                         if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
@@ -354,417 +354,417 @@  discard block
 block discarded – undo
354 354
                 // get unqualified name
355 355
                 $name = substr(strstr($name, ':'), 1);
356 356
             }
357
-			// process attributes, expanding any prefixes to namespaces
357
+            // process attributes, expanding any prefixes to namespaces
358 358
             // find status, register data
359 359
             switch ($this->status) {
360 360
                 case 'message':
361 361
                     if ($name == 'part') {
362
-			            if (isset($attrs['type'])) {
363
-		                    $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs));
364
-		                    $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
365
-            			}
366
-			            if (isset($attrs['element'])) {
367
-		                    $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs));
368
-			                $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^';
369
-			            }
370
-        			}
371
-        			break;
372
-			    case 'portType':
373
-			        switch ($name) {
374
-			            case 'operation':
375
-			                $this->currentPortOperation = $attrs['name'];
376
-			                $this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
377
-			                if (isset($attrs['parameterOrder'])) {
378
-			                	$this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder'];
379
-			        		}
380
-			        		break;
381
-					    case 'documentation':
382
-					        $this->documentation = true;
383
-					        break;
384
-					    // merge input/output data
385
-					    default:
386
-					        $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : '';
387
-					        $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m;
388
-					        break;
389
-					}
390
-			    	break;
391
-				case 'binding':
392
-				    switch ($name) {
393
-				        case 'binding':
394
-				            // get ns prefix
395
-				            if (isset($attrs['style'])) {
396
-				            $this->bindings[$this->currentBinding]['prefix'] = $prefix;
397
-					    	}
398
-					    	$this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs);
399
-					    	break;
400
-						case 'header':
401
-						    $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs;
402
-						    break;
403
-						case 'operation':
404
-						    if (isset($attrs['soapAction'])) {
405
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction'];
406
-						    }
407
-						    if (isset($attrs['style'])) {
408
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style'];
409
-						    }
410
-						    if (isset($attrs['name'])) {
411
-						        $this->currentOperation = $attrs['name'];
412
-						        $this->debug("current binding operation: $this->currentOperation");
413
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name'];
414
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding;
415
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : '';
416
-						    }
417
-						    break;
418
-						case 'input':
419
-						    $this->opStatus = 'input';
420
-						    break;
421
-						case 'output':
422
-						    $this->opStatus = 'output';
423
-						    break;
424
-						case 'body':
425
-						    if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) {
426
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs);
427
-						    } else {
428
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs;
429
-						    }
430
-						    break;
431
-					}
432
-					break;
433
-				case 'service':
434
-					switch ($name) {
435
-					    case 'port':
436
-					        $this->currentPort = $attrs['name'];
437
-					        $this->debug('current port: ' . $this->currentPort);
438
-					        $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);
362
+                        if (isset($attrs['type'])) {
363
+                            $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs));
364
+                            $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
365
+                        }
366
+                        if (isset($attrs['element'])) {
367
+                            $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs));
368
+                            $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^';
369
+                        }
370
+                    }
371
+                    break;
372
+                case 'portType':
373
+                    switch ($name) {
374
+                        case 'operation':
375
+                            $this->currentPortOperation = $attrs['name'];
376
+                            $this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
377
+                            if (isset($attrs['parameterOrder'])) {
378
+                                $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder'];
379
+                            }
380
+                            break;
381
+                        case 'documentation':
382
+                            $this->documentation = true;
383
+                            break;
384
+                        // merge input/output data
385
+                        default:
386
+                            $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : '';
387
+                            $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m;
388
+                            break;
389
+                    }
390
+                    break;
391
+                case 'binding':
392
+                    switch ($name) {
393
+                        case 'binding':
394
+                            // get ns prefix
395
+                            if (isset($attrs['style'])) {
396
+                            $this->bindings[$this->currentBinding]['prefix'] = $prefix;
397
+                            }
398
+                            $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs);
399
+                            break;
400
+                        case 'header':
401
+                            $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs;
402
+                            break;
403
+                        case 'operation':
404
+                            if (isset($attrs['soapAction'])) {
405
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction'];
406
+                            }
407
+                            if (isset($attrs['style'])) {
408
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style'];
409
+                            }
410
+                            if (isset($attrs['name'])) {
411
+                                $this->currentOperation = $attrs['name'];
412
+                                $this->debug("current binding operation: $this->currentOperation");
413
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name'];
414
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding;
415
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : '';
416
+                            }
417
+                            break;
418
+                        case 'input':
419
+                            $this->opStatus = 'input';
420
+                            break;
421
+                        case 'output':
422
+                            $this->opStatus = 'output';
423
+                            break;
424
+                        case 'body':
425
+                            if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) {
426
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs);
427
+                            } else {
428
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs;
429
+                            }
430
+                            break;
431
+                    }
432
+                    break;
433
+                case 'service':
434
+                    switch ($name) {
435
+                        case 'port':
436
+                            $this->currentPort = $attrs['name'];
437
+                            $this->debug('current port: ' . $this->currentPort);
438
+                            $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);
439 439
 
440
-					        break;
441
-					    case 'address':
442
-					        $this->ports[$this->currentPort]['location'] = $attrs['location'];
443
-					        $this->ports[$this->currentPort]['bindingType'] = $namespace;
444
-					        $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace;
445
-					        $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location'];
446
-					        break;
447
-					}
448
-					break;
449
-			}
450
-		// set status
451
-		switch ($name) {
452
-			case 'import':
453
-			    if (isset($attrs['location'])) {
440
+                            break;
441
+                        case 'address':
442
+                            $this->ports[$this->currentPort]['location'] = $attrs['location'];
443
+                            $this->ports[$this->currentPort]['bindingType'] = $namespace;
444
+                            $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace;
445
+                            $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location'];
446
+                            break;
447
+                    }
448
+                    break;
449
+            }
450
+        // set status
451
+        switch ($name) {
452
+            case 'import':
453
+                if (isset($attrs['location'])) {
454 454
                     $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false);
455 455
                     $this->debug('parsing import ' . $attrs['namespace']. ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]).')');
456
-				} else {
456
+                } else {
457 457
                     $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
458
-					if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
459
-						$this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
460
-					}
458
+                    if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
459
+                        $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
460
+                    }
461 461
                     $this->debug('parsing import ' . $attrs['namespace']. ' - [no location] (' . count($this->import[$attrs['namespace']]).')');
462
-				}
463
-				break;
464
-			//wait for schema
465
-			//case 'types':
466
-			//	$this->status = 'schema';
467
-			//	break;
468
-			case 'message':
469
-				$this->status = 'message';
470
-				$this->messages[$attrs['name']] = array();
471
-				$this->currentMessage = $attrs['name'];
472
-				break;
473
-			case 'portType':
474
-				$this->status = 'portType';
475
-				$this->portTypes[$attrs['name']] = array();
476
-				$this->currentPortType = $attrs['name'];
477
-				break;
478
-			case "binding":
479
-				if (isset($attrs['name'])) {
480
-				// get binding name
481
-					if (strpos($attrs['name'], ':')) {
482
-			    		$this->currentBinding = $this->getLocalPart($attrs['name']);
483
-					} else {
484
-			    		$this->currentBinding = $attrs['name'];
485
-					}
486
-					$this->status = 'binding';
487
-					$this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
488
-					$this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
489
-				}
490
-				break;
491
-			case 'service':
492
-				$this->serviceName = $attrs['name'];
493
-				$this->status = 'service';
494
-				$this->debug('current service: ' . $this->serviceName);
495
-				break;
496
-			case 'definitions':
497
-				foreach ($attrs as $name => $value) {
498
-					$this->wsdl_info[$name] = $value;
499
-				}
500
-				break;
501
-			}
502
-		}
503
-	}
462
+                }
463
+                break;
464
+            //wait for schema
465
+            //case 'types':
466
+            //	$this->status = 'schema';
467
+            //	break;
468
+            case 'message':
469
+                $this->status = 'message';
470
+                $this->messages[$attrs['name']] = array();
471
+                $this->currentMessage = $attrs['name'];
472
+                break;
473
+            case 'portType':
474
+                $this->status = 'portType';
475
+                $this->portTypes[$attrs['name']] = array();
476
+                $this->currentPortType = $attrs['name'];
477
+                break;
478
+            case "binding":
479
+                if (isset($attrs['name'])) {
480
+                // get binding name
481
+                    if (strpos($attrs['name'], ':')) {
482
+                        $this->currentBinding = $this->getLocalPart($attrs['name']);
483
+                    } else {
484
+                        $this->currentBinding = $attrs['name'];
485
+                    }
486
+                    $this->status = 'binding';
487
+                    $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
488
+                    $this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
489
+                }
490
+                break;
491
+            case 'service':
492
+                $this->serviceName = $attrs['name'];
493
+                $this->status = 'service';
494
+                $this->debug('current service: ' . $this->serviceName);
495
+                break;
496
+            case 'definitions':
497
+                foreach ($attrs as $name => $value) {
498
+                    $this->wsdl_info[$name] = $value;
499
+                }
500
+                break;
501
+            }
502
+        }
503
+    }
504 504
 
505
-	/**
506
-	* end-element handler
507
-	*
508
-	* @param string $parser XML parser object
509
-	* @param string $name element name
510
-	* @access private
511
-	*/
512
-	function end_element($parser, $name){
513
-		// unset schema status
514
-		if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) {
515
-			$this->status = "";
505
+    /**
506
+     * end-element handler
507
+     *
508
+     * @param string $parser XML parser object
509
+     * @param string $name element name
510
+     * @access private
511
+     */
512
+    function end_element($parser, $name){
513
+        // unset schema status
514
+        if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) {
515
+            $this->status = "";
516 516
             $this->appendDebug($this->currentSchema->getDebug());
517 517
             $this->currentSchema->clearDebug();
518
-			$this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema;
519
-        	$this->debug('Parsing WSDL schema done');
520
-		}
521
-		if ($this->status == 'schema') {
522
-			$this->currentSchema->schemaEndElement($parser, $name);
523
-		} else {
524
-			// bring depth down a notch
525
-			$this->depth--;
526
-		}
527
-		// end documentation
528
-		if ($this->documentation) {
529
-			//TODO: track the node to which documentation should be assigned; it can be a part, message, etc.
530
-			//$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation;
531
-			$this->documentation = false;
532
-		}
533
-	}
518
+            $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema;
519
+            $this->debug('Parsing WSDL schema done');
520
+        }
521
+        if ($this->status == 'schema') {
522
+            $this->currentSchema->schemaEndElement($parser, $name);
523
+        } else {
524
+            // bring depth down a notch
525
+            $this->depth--;
526
+        }
527
+        // end documentation
528
+        if ($this->documentation) {
529
+            //TODO: track the node to which documentation should be assigned; it can be a part, message, etc.
530
+            //$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation;
531
+            $this->documentation = false;
532
+        }
533
+    }
534 534
 
535
-	/**
536
-	 * element content handler
537
-	 *
538
-	 * @param string $parser XML parser object
539
-	 * @param string $data element content
540
-	 * @access private
541
-	 */
542
-	function character_data($parser, $data)
543
-	{
544
-		$pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0;
545
-		if (isset($this->message[$pos]['cdata'])) {
546
-			$this->message[$pos]['cdata'] .= $data;
547
-		}
548
-		if ($this->documentation) {
549
-			$this->documentation .= $data;
550
-		}
551
-	}
535
+    /**
536
+     * element content handler
537
+     *
538
+     * @param string $parser XML parser object
539
+     * @param string $data element content
540
+     * @access private
541
+     */
542
+    function character_data($parser, $data)
543
+    {
544
+        $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0;
545
+        if (isset($this->message[$pos]['cdata'])) {
546
+            $this->message[$pos]['cdata'] .= $data;
547
+        }
548
+        if ($this->documentation) {
549
+            $this->documentation .= $data;
550
+        }
551
+    }
552 552
 
553
-	/**
554
-	* if authenticating, set user credentials here
555
-	*
556
-	* @param    string $username
557
-	* @param    string $password
558
-	* @param	string $authtype (basic|digest|certificate|ntlm)
559
-	* @param	array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
560
-	* @access   public
561
-	*/
562
-	function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
563
-		$this->debug("setCredentials username=$username authtype=$authtype certRequest=");
564
-		$this->appendDebug($this->varDump($certRequest));
565
-		$this->username = $username;
566
-		$this->password = $password;
567
-		$this->authtype = $authtype;
568
-		$this->certRequest = $certRequest;
569
-	}
553
+    /**
554
+     * if authenticating, set user credentials here
555
+     *
556
+     * @param    string $username
557
+     * @param    string $password
558
+     * @param	string $authtype (basic|digest|certificate|ntlm)
559
+     * @param	array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
560
+     * @access   public
561
+     */
562
+    function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
563
+        $this->debug("setCredentials username=$username authtype=$authtype certRequest=");
564
+        $this->appendDebug($this->varDump($certRequest));
565
+        $this->username = $username;
566
+        $this->password = $password;
567
+        $this->authtype = $authtype;
568
+        $this->certRequest = $certRequest;
569
+    }
570 570
 
571
-	function getBindingData($binding)
572
-	{
573
-		if (is_array($this->bindings[$binding])) {
574
-			return $this->bindings[$binding];
575
-		}
576
-	}
571
+    function getBindingData($binding)
572
+    {
573
+        if (is_array($this->bindings[$binding])) {
574
+            return $this->bindings[$binding];
575
+        }
576
+    }
577 577
 
578
-	/**
579
-	 * returns an assoc array of operation names => operation data
580
-	 *
581
-	 * @param string $portName WSDL port name
582
-	 * @param string $bindingType eg: soap, smtp, dime (only soap and soap12 are currently supported)
583
-	 * @return array
584
-	 * @access public
585
-	 */
586
-	function getOperations($portName = '', $bindingType = 'soap') {
587
-		$ops = array();
588
-		if ($bindingType == 'soap') {
589
-			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
590
-		} elseif ($bindingType == 'soap12') {
591
-			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
592
-		} else {
593
-			$this->debug("getOperations bindingType $bindingType may not be supported");
594
-		}
595
-		$this->debug("getOperations for port '$portName' bindingType $bindingType");
596
-		// loop thru ports
597
-		foreach($this->ports as $port => $portData) {
598
-			$this->debug("getOperations checking port $port bindingType " . $portData['bindingType']);
599
-			if ($portName == '' || $port == $portName) {
600
-				// binding type of port matches parameter
601
-				if ($portData['bindingType'] == $bindingType) {
602
-					$this->debug("getOperations found port $port bindingType $bindingType");
603
-					//$this->debug("port data: " . $this->varDump($portData));
604
-					//$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
605
-					// merge bindings
606
-					if (isset($this->bindings[ $portData['binding'] ]['operations'])) {
607
-						$ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']);
608
-					}
609
-				}
610
-			}
611
-		}
612
-		if (count($ops) == 0) {
613
-			$this->debug("getOperations found no operations for port '$portName' bindingType $bindingType");
614
-		}
615
-		return $ops;
616
-	}
578
+    /**
579
+     * returns an assoc array of operation names => operation data
580
+     *
581
+     * @param string $portName WSDL port name
582
+     * @param string $bindingType eg: soap, smtp, dime (only soap and soap12 are currently supported)
583
+     * @return array
584
+     * @access public
585
+     */
586
+    function getOperations($portName = '', $bindingType = 'soap') {
587
+        $ops = array();
588
+        if ($bindingType == 'soap') {
589
+            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
590
+        } elseif ($bindingType == 'soap12') {
591
+            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
592
+        } else {
593
+            $this->debug("getOperations bindingType $bindingType may not be supported");
594
+        }
595
+        $this->debug("getOperations for port '$portName' bindingType $bindingType");
596
+        // loop thru ports
597
+        foreach($this->ports as $port => $portData) {
598
+            $this->debug("getOperations checking port $port bindingType " . $portData['bindingType']);
599
+            if ($portName == '' || $port == $portName) {
600
+                // binding type of port matches parameter
601
+                if ($portData['bindingType'] == $bindingType) {
602
+                    $this->debug("getOperations found port $port bindingType $bindingType");
603
+                    //$this->debug("port data: " . $this->varDump($portData));
604
+                    //$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
605
+                    // merge bindings
606
+                    if (isset($this->bindings[ $portData['binding'] ]['operations'])) {
607
+                        $ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']);
608
+                    }
609
+                }
610
+            }
611
+        }
612
+        if (count($ops) == 0) {
613
+            $this->debug("getOperations found no operations for port '$portName' bindingType $bindingType");
614
+        }
615
+        return $ops;
616
+    }
617 617
 
618
-	/**
619
-	 * returns an associative array of data necessary for calling an operation
620
-	 *
621
-	 * @param string $operation name of operation
622
-	 * @param string $bindingType type of binding eg: soap, soap12
623
-	 * @return array
624
-	 * @access public
625
-	 */
626
-	function getOperationData($operation, $bindingType = 'soap')
627
-	{
628
-		if ($bindingType == 'soap') {
629
-			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
630
-		} elseif ($bindingType == 'soap12') {
631
-			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
632
-		}
633
-		// loop thru ports
634
-		foreach($this->ports as $port => $portData) {
635
-			// binding type of port matches parameter
636
-			if ($portData['bindingType'] == $bindingType) {
637
-				// get binding
638
-				//foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
639
-				foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) {
640
-					// note that we could/should also check the namespace here
641
-					if ($operation == $bOperation) {
642
-						$opData = $this->bindings[ $portData['binding'] ]['operations'][$operation];
643
-					    return $opData;
644
-					}
645
-				}
646
-			}
647
-		}
648
-	}
618
+    /**
619
+     * returns an associative array of data necessary for calling an operation
620
+     *
621
+     * @param string $operation name of operation
622
+     * @param string $bindingType type of binding eg: soap, soap12
623
+     * @return array
624
+     * @access public
625
+     */
626
+    function getOperationData($operation, $bindingType = 'soap')
627
+    {
628
+        if ($bindingType == 'soap') {
629
+            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
630
+        } elseif ($bindingType == 'soap12') {
631
+            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
632
+        }
633
+        // loop thru ports
634
+        foreach($this->ports as $port => $portData) {
635
+            // binding type of port matches parameter
636
+            if ($portData['bindingType'] == $bindingType) {
637
+                // get binding
638
+                //foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
639
+                foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) {
640
+                    // note that we could/should also check the namespace here
641
+                    if ($operation == $bOperation) {
642
+                        $opData = $this->bindings[ $portData['binding'] ]['operations'][$operation];
643
+                        return $opData;
644
+                    }
645
+                }
646
+            }
647
+        }
648
+    }
649 649
 
650
-	/**
651
-	 * returns an associative array of data necessary for calling an operation
652
-	 *
653
-	 * @param string $soapAction soapAction for operation
654
-	 * @param string $bindingType type of binding eg: soap, soap12
655
-	 * @return array
656
-	 * @access public
657
-	 */
658
-	function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') {
659
-		if ($bindingType == 'soap') {
660
-			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
661
-		} elseif ($bindingType == 'soap12') {
662
-			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
663
-		}
664
-		// loop thru ports
665
-		foreach($this->ports as $port => $portData) {
666
-			// binding type of port matches parameter
667
-			if ($portData['bindingType'] == $bindingType) {
668
-				// loop through operations for the binding
669
-				foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
670
-					if ($opData['soapAction'] == $soapAction) {
671
-					    return $opData;
672
-					}
673
-				}
674
-			}
675
-		}
676
-	}
650
+    /**
651
+     * returns an associative array of data necessary for calling an operation
652
+     *
653
+     * @param string $soapAction soapAction for operation
654
+     * @param string $bindingType type of binding eg: soap, soap12
655
+     * @return array
656
+     * @access public
657
+     */
658
+    function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') {
659
+        if ($bindingType == 'soap') {
660
+            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
661
+        } elseif ($bindingType == 'soap12') {
662
+            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
663
+        }
664
+        // loop thru ports
665
+        foreach($this->ports as $port => $portData) {
666
+            // binding type of port matches parameter
667
+            if ($portData['bindingType'] == $bindingType) {
668
+                // loop through operations for the binding
669
+                foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
670
+                    if ($opData['soapAction'] == $soapAction) {
671
+                        return $opData;
672
+                    }
673
+                }
674
+            }
675
+        }
676
+    }
677 677
 
678
-	/**
679
-    * returns an array of information about a given type
680
-    * returns false if no type exists by the given name
681
-    *
682
-	*	 typeDef = array(
683
-	*	 'elements' => array(), // refs to elements array
684
-	*	'restrictionBase' => '',
685
-	*	'phpType' => '',
686
-	*	'order' => '(sequence|all)',
687
-	*	'attrs' => array() // refs to attributes array
688
-	*	)
689
-    *
690
-    * @param string $type the type
691
-    * @param string $ns namespace (not prefix) of the type
692
-    * @return mixed
693
-    * @access public
694
-    * @see nusoap_xmlschema
695
-    */
696
-	function getTypeDef($type, $ns) {
697
-		$this->debug("in getTypeDef: type=$type, ns=$ns");
698
-		if ((! $ns) && isset($this->namespaces['tns'])) {
699
-			$ns = $this->namespaces['tns'];
700
-			$this->debug("in getTypeDef: type namespace forced to $ns");
701
-		}
702
-		if (!isset($this->schemas[$ns])) {
703
-			foreach ($this->schemas as $ns0 => $schema0) {
704
-				if (strcasecmp($ns, $ns0) == 0) {
705
-					$this->debug("in getTypeDef: replacing schema namespace $ns with $ns0");
706
-					$ns = $ns0;
707
-					break;
708
-				}
709
-			}
710
-		}
711
-		if (isset($this->schemas[$ns])) {
712
-			$this->debug("in getTypeDef: have schema for namespace $ns");
713
-			for ($i = 0; $i < count($this->schemas[$ns]); $i++) {
714
-				$xs = &$this->schemas[$ns][$i];
715
-				$t = $xs->getTypeDef($type);
716
-				$this->appendDebug($xs->getDebug());
717
-				$xs->clearDebug();
718
-				if ($t) {
719
-					$this->debug("in getTypeDef: found type $type");
720
-					if (!isset($t['phpType'])) {
721
-						// get info for type to tack onto the element
722
-						$uqType = substr($t['type'], strrpos($t['type'], ':') + 1);
723
-						$ns = substr($t['type'], 0, strrpos($t['type'], ':'));
724
-						$etype = $this->getTypeDef($uqType, $ns);
725
-						if ($etype) {
726
-							$this->debug("found type for [element] $type:");
727
-							$this->debug($this->varDump($etype));
728
-							if (isset($etype['phpType'])) {
729
-								$t['phpType'] = $etype['phpType'];
730
-							}
731
-							if (isset($etype['elements'])) {
732
-								$t['elements'] = $etype['elements'];
733
-							}
734
-							if (isset($etype['attrs'])) {
735
-								$t['attrs'] = $etype['attrs'];
736
-							}
737
-						} else {
738
-							$this->debug("did not find type for [element] $type");
739
-						}
740
-					}
741
-					return $t;
742
-				}
743
-			}
744
-			$this->debug("in getTypeDef: did not find type $type");
745
-		} else {
746
-			$this->debug("in getTypeDef: do not have schema for namespace $ns");
747
-		}
748
-		return false;
749
-	}
678
+    /**
679
+     * returns an array of information about a given type
680
+     * returns false if no type exists by the given name
681
+     *
682
+     *	 typeDef = array(
683
+     *	 'elements' => array(), // refs to elements array
684
+     *	'restrictionBase' => '',
685
+     *	'phpType' => '',
686
+     *	'order' => '(sequence|all)',
687
+     *	'attrs' => array() // refs to attributes array
688
+     *	)
689
+     *
690
+     * @param string $type the type
691
+     * @param string $ns namespace (not prefix) of the type
692
+     * @return mixed
693
+     * @access public
694
+     * @see nusoap_xmlschema
695
+     */
696
+    function getTypeDef($type, $ns) {
697
+        $this->debug("in getTypeDef: type=$type, ns=$ns");
698
+        if ((! $ns) && isset($this->namespaces['tns'])) {
699
+            $ns = $this->namespaces['tns'];
700
+            $this->debug("in getTypeDef: type namespace forced to $ns");
701
+        }
702
+        if (!isset($this->schemas[$ns])) {
703
+            foreach ($this->schemas as $ns0 => $schema0) {
704
+                if (strcasecmp($ns, $ns0) == 0) {
705
+                    $this->debug("in getTypeDef: replacing schema namespace $ns with $ns0");
706
+                    $ns = $ns0;
707
+                    break;
708
+                }
709
+            }
710
+        }
711
+        if (isset($this->schemas[$ns])) {
712
+            $this->debug("in getTypeDef: have schema for namespace $ns");
713
+            for ($i = 0; $i < count($this->schemas[$ns]); $i++) {
714
+                $xs = &$this->schemas[$ns][$i];
715
+                $t = $xs->getTypeDef($type);
716
+                $this->appendDebug($xs->getDebug());
717
+                $xs->clearDebug();
718
+                if ($t) {
719
+                    $this->debug("in getTypeDef: found type $type");
720
+                    if (!isset($t['phpType'])) {
721
+                        // get info for type to tack onto the element
722
+                        $uqType = substr($t['type'], strrpos($t['type'], ':') + 1);
723
+                        $ns = substr($t['type'], 0, strrpos($t['type'], ':'));
724
+                        $etype = $this->getTypeDef($uqType, $ns);
725
+                        if ($etype) {
726
+                            $this->debug("found type for [element] $type:");
727
+                            $this->debug($this->varDump($etype));
728
+                            if (isset($etype['phpType'])) {
729
+                                $t['phpType'] = $etype['phpType'];
730
+                            }
731
+                            if (isset($etype['elements'])) {
732
+                                $t['elements'] = $etype['elements'];
733
+                            }
734
+                            if (isset($etype['attrs'])) {
735
+                                $t['attrs'] = $etype['attrs'];
736
+                            }
737
+                        } else {
738
+                            $this->debug("did not find type for [element] $type");
739
+                        }
740
+                    }
741
+                    return $t;
742
+                }
743
+            }
744
+            $this->debug("in getTypeDef: did not find type $type");
745
+        } else {
746
+            $this->debug("in getTypeDef: do not have schema for namespace $ns");
747
+        }
748
+        return false;
749
+    }
750 750
 
751 751
     /**
752
-    * prints html description of services
753
-    *
754
-    * @access private
755
-    */
752
+     * prints html description of services
753
+     *
754
+     * @access private
755
+     */
756 756
     function webDescription(){
757
-    	global $HTTP_SERVER_VARS;
757
+        global $HTTP_SERVER_VARS;
758 758
 
759
-		if (isset($_SERVER)) {
760
-			$PHP_SELF = $_SERVER['PHP_SELF'];
761
-		} elseif (isset($HTTP_SERVER_VARS)) {
762
-			$PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
763
-		} else {
764
-			$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
765
-		}
759
+        if (isset($_SERVER)) {
760
+            $PHP_SELF = $_SERVER['PHP_SELF'];
761
+        } elseif (isset($HTTP_SERVER_VARS)) {
762
+            $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
763
+        } else {
764
+            $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
765
+        }
766 766
 
767
-		$b = '
767
+        $b = '
768 768
 		<html><head><title>NuSOAP: '.$this->serviceName.'</title>
769 769
 		<style type="text/css">
770 770
 		    body    { font-family: arial; color: #000000; background-color: #ffffff; margin: 0px 0px 0px 0px; }
@@ -847,1092 +847,1092 @@  discard block
 block discarded – undo
847 847
 				<p>View the <a href="'.$PHP_SELF.'?wsdl">WSDL</a> for the service.
848 848
 				Click on an operation name to view it&apos;s details.</p>
849 849
 				<ul>';
850
-				foreach($this->getOperations() as $op => $data){
851
-				    $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
852
-				    // create hidden div
853
-				    $b .= "<div id='$op' class='hidden'>
850
+                foreach($this->getOperations() as $op => $data){
851
+                    $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
852
+                    // create hidden div
853
+                    $b .= "<div id='$op' class='hidden'>
854 854
 				    <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>";
855
-				    foreach($data as $donnie => $marie){ // loop through opdata
856
-						if($donnie == 'input' || $donnie == 'output'){ // show input/output data
857
-						    $b .= "<font color='white'>".ucfirst($donnie).':</font><br>';
858
-						    foreach($marie as $captain => $tenille){ // loop through data
859
-								if($captain == 'parts'){ // loop thru parts
860
-								    $b .= "&nbsp;&nbsp;$captain:<br>";
861
-					                //if(is_array($tenille)){
862
-								    	foreach($tenille as $joanie => $chachi){
863
-											$b .= "&nbsp;&nbsp;&nbsp;&nbsp;$joanie: $chachi<br>";
864
-								    	}
865
-					        		//}
866
-								} else {
867
-								    $b .= "&nbsp;&nbsp;$captain: $tenille<br>";
868
-								}
869
-						    }
870
-						} else {
871
-						    $b .= "<font color='white'>".ucfirst($donnie).":</font> $marie<br>";
872
-						}
873
-				    }
874
-					$b .= '</div>';
875
-				}
876
-				$b .= '
855
+                    foreach($data as $donnie => $marie){ // loop through opdata
856
+                        if($donnie == 'input' || $donnie == 'output'){ // show input/output data
857
+                            $b .= "<font color='white'>".ucfirst($donnie).':</font><br>';
858
+                            foreach($marie as $captain => $tenille){ // loop through data
859
+                                if($captain == 'parts'){ // loop thru parts
860
+                                    $b .= "&nbsp;&nbsp;$captain:<br>";
861
+                                    //if(is_array($tenille)){
862
+                                        foreach($tenille as $joanie => $chachi){
863
+                                            $b .= "&nbsp;&nbsp;&nbsp;&nbsp;$joanie: $chachi<br>";
864
+                                        }
865
+                                    //}
866
+                                } else {
867
+                                    $b .= "&nbsp;&nbsp;$captain: $tenille<br>";
868
+                                }
869
+                            }
870
+                        } else {
871
+                            $b .= "<font color='white'>".ucfirst($donnie).":</font> $marie<br>";
872
+                        }
873
+                    }
874
+                    $b .= '</div>';
875
+                }
876
+                $b .= '
877 877
 				<ul>
878 878
 			</div>
879 879
 		</div></body></html>';
880
-		return $b;
880
+        return $b;
881 881
     }
882 882
 
883
-	/**
884
-	* serialize the parsed wsdl
885
-	*
886
-	* @param mixed $debug whether to put debug=1 in endpoint URL
887
-	* @return string serialization of WSDL
888
-	* @access public
889
-	*/
890
-	function serialize($debug = 0)
891
-	{
892
-		$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>';
893
-		$xml .= "\n<definitions";
894
-		foreach($this->namespaces as $k => $v) {
895
-			$xml .= " xmlns:$k=\"$v\"";
896
-		}
897
-		// 10.9.02 - add poulter fix for wsdl and tns declarations
898
-		if (isset($this->namespaces['wsdl'])) {
899
-			$xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\"";
900
-		}
901
-		if (isset($this->namespaces['tns'])) {
902
-			$xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\"";
903
-		}
904
-		$xml .= '>';
905
-		// imports
906
-		if (sizeof($this->import) > 0) {
907
-			foreach($this->import as $ns => $list) {
908
-				foreach ($list as $ii) {
909
-					if ($ii['location'] != '') {
910
-						$xml .= '<import location="' . $ii['location'] . '" namespace="' . $ns . '" />';
911
-					} else {
912
-						$xml .= '<import namespace="' . $ns . '" />';
913
-					}
914
-				}
915
-			}
916
-		}
917
-		// types
918
-		if (count($this->schemas)>=1) {
919
-			$xml .= "\n<types>\n";
920
-			foreach ($this->schemas as $ns => $list) {
921
-				foreach ($list as $xs) {
922
-					$xml .= $xs->serializeSchema();
923
-				}
924
-			}
925
-			$xml .= '</types>';
926
-		}
927
-		// messages
928
-		if (count($this->messages) >= 1) {
929
-			foreach($this->messages as $msgName => $msgParts) {
930
-				$xml .= "\n<message name=\"" . $msgName . '">';
931
-				if(is_array($msgParts)){
932
-					foreach($msgParts as $partName => $partType) {
933
-						// print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>';
934
-						if (strpos($partType, ':')) {
935
-						    $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType));
936
-						} elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) {
937
-						    // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>';
938
-						    $typePrefix = 'xsd';
939
-						} else {
940
-						    foreach($this->typemap as $ns => $types) {
941
-						        if (isset($types[$partType])) {
942
-						            $typePrefix = $this->getPrefixFromNamespace($ns);
943
-						        }
944
-						    }
945
-						    if (!isset($typePrefix)) {
946
-						        die("$partType has no namespace!");
947
-						    }
948
-						}
949
-						$ns = $this->getNamespaceFromPrefix($typePrefix);
950
-						$localPart = $this->getLocalPart($partType);
951
-						$typeDef = $this->getTypeDef($localPart, $ns);
952
-						if ($typeDef['typeClass'] == 'element') {
953
-							$elementortype = 'element';
954
-							if (substr($localPart, -1) == '^') {
955
-								$localPart = substr($localPart, 0, -1);
956
-							}
957
-						} else {
958
-							$elementortype = 'type';
959
-						}
960
-						$xml .= "\n" . '  <part name="' . $partName . '" ' . $elementortype . '="' . $typePrefix . ':' . $localPart . '" />';
961
-					}
962
-				}
963
-				$xml .= '</message>';
964
-			}
965
-		}
966
-		// bindings & porttypes
967
-		if (count($this->bindings) >= 1) {
968
-			$binding_xml = '';
969
-			$portType_xml = '';
970
-			foreach($this->bindings as $bindingName => $attrs) {
971
-				$binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">';
972
-				$binding_xml .= "\n" . '  <soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>';
973
-				$portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">';
974
-				foreach($attrs['operations'] as $opName => $opParts) {
975
-					$binding_xml .= "\n" . '  <operation name="' . $opName . '">';
976
-					$binding_xml .= "\n" . '    <soap:operation soapAction="' . $opParts['soapAction'] . '" style="'. $opParts['style'] . '"/>';
977
-					if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') {
978
-						$enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"';
979
-					} else {
980
-						$enc_style = '';
981
-					}
982
-					$binding_xml .= "\n" . '    <input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '"' . $enc_style . '/></input>';
983
-					if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') {
984
-						$enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"';
985
-					} else {
986
-						$enc_style = '';
987
-					}
988
-					$binding_xml .= "\n" . '    <output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '"' . $enc_style . '/></output>';
989
-					$binding_xml .= "\n" . '  </operation>';
990
-					$portType_xml .= "\n" . '  <operation name="' . $opParts['name'] . '"';
991
-					if (isset($opParts['parameterOrder'])) {
992
-					    $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"';
993
-					}
994
-					$portType_xml .= '>';
995
-					if(isset($opParts['documentation']) && $opParts['documentation'] != '') {
996
-						$portType_xml .= "\n" . '    <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>';
997
-					}
998
-					$portType_xml .= "\n" . '    <input message="tns:' . $opParts['input']['message'] . '"/>';
999
-					$portType_xml .= "\n" . '    <output message="tns:' . $opParts['output']['message'] . '"/>';
1000
-					$portType_xml .= "\n" . '  </operation>';
1001
-				}
1002
-				$portType_xml .= "\n" . '</portType>';
1003
-				$binding_xml .= "\n" . '</binding>';
1004
-			}
1005
-			$xml .= $portType_xml . $binding_xml;
1006
-		}
1007
-		// services
1008
-		$xml .= "\n<service name=\"" . $this->serviceName . '">';
1009
-		if (count($this->ports) >= 1) {
1010
-			foreach($this->ports as $pName => $attrs) {
1011
-				$xml .= "\n" . '  <port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">';
1012
-				$xml .= "\n" . '    <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>';
1013
-				$xml .= "\n" . '  </port>';
1014
-			}
1015
-		}
1016
-		$xml .= "\n" . '</service>';
1017
-		return $xml . "\n</definitions>";
1018
-	}
883
+    /**
884
+     * serialize the parsed wsdl
885
+     *
886
+     * @param mixed $debug whether to put debug=1 in endpoint URL
887
+     * @return string serialization of WSDL
888
+     * @access public
889
+     */
890
+    function serialize($debug = 0)
891
+    {
892
+        $xml = '<?xml version="1.0" encoding="ISO-8859-1"?>';
893
+        $xml .= "\n<definitions";
894
+        foreach($this->namespaces as $k => $v) {
895
+            $xml .= " xmlns:$k=\"$v\"";
896
+        }
897
+        // 10.9.02 - add poulter fix for wsdl and tns declarations
898
+        if (isset($this->namespaces['wsdl'])) {
899
+            $xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\"";
900
+        }
901
+        if (isset($this->namespaces['tns'])) {
902
+            $xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\"";
903
+        }
904
+        $xml .= '>';
905
+        // imports
906
+        if (sizeof($this->import) > 0) {
907
+            foreach($this->import as $ns => $list) {
908
+                foreach ($list as $ii) {
909
+                    if ($ii['location'] != '') {
910
+                        $xml .= '<import location="' . $ii['location'] . '" namespace="' . $ns . '" />';
911
+                    } else {
912
+                        $xml .= '<import namespace="' . $ns . '" />';
913
+                    }
914
+                }
915
+            }
916
+        }
917
+        // types
918
+        if (count($this->schemas)>=1) {
919
+            $xml .= "\n<types>\n";
920
+            foreach ($this->schemas as $ns => $list) {
921
+                foreach ($list as $xs) {
922
+                    $xml .= $xs->serializeSchema();
923
+                }
924
+            }
925
+            $xml .= '</types>';
926
+        }
927
+        // messages
928
+        if (count($this->messages) >= 1) {
929
+            foreach($this->messages as $msgName => $msgParts) {
930
+                $xml .= "\n<message name=\"" . $msgName . '">';
931
+                if(is_array($msgParts)){
932
+                    foreach($msgParts as $partName => $partType) {
933
+                        // print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>';
934
+                        if (strpos($partType, ':')) {
935
+                            $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType));
936
+                        } elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) {
937
+                            // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>';
938
+                            $typePrefix = 'xsd';
939
+                        } else {
940
+                            foreach($this->typemap as $ns => $types) {
941
+                                if (isset($types[$partType])) {
942
+                                    $typePrefix = $this->getPrefixFromNamespace($ns);
943
+                                }
944
+                            }
945
+                            if (!isset($typePrefix)) {
946
+                                die("$partType has no namespace!");
947
+                            }
948
+                        }
949
+                        $ns = $this->getNamespaceFromPrefix($typePrefix);
950
+                        $localPart = $this->getLocalPart($partType);
951
+                        $typeDef = $this->getTypeDef($localPart, $ns);
952
+                        if ($typeDef['typeClass'] == 'element') {
953
+                            $elementortype = 'element';
954
+                            if (substr($localPart, -1) == '^') {
955
+                                $localPart = substr($localPart, 0, -1);
956
+                            }
957
+                        } else {
958
+                            $elementortype = 'type';
959
+                        }
960
+                        $xml .= "\n" . '  <part name="' . $partName . '" ' . $elementortype . '="' . $typePrefix . ':' . $localPart . '" />';
961
+                    }
962
+                }
963
+                $xml .= '</message>';
964
+            }
965
+        }
966
+        // bindings & porttypes
967
+        if (count($this->bindings) >= 1) {
968
+            $binding_xml = '';
969
+            $portType_xml = '';
970
+            foreach($this->bindings as $bindingName => $attrs) {
971
+                $binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">';
972
+                $binding_xml .= "\n" . '  <soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>';
973
+                $portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">';
974
+                foreach($attrs['operations'] as $opName => $opParts) {
975
+                    $binding_xml .= "\n" . '  <operation name="' . $opName . '">';
976
+                    $binding_xml .= "\n" . '    <soap:operation soapAction="' . $opParts['soapAction'] . '" style="'. $opParts['style'] . '"/>';
977
+                    if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') {
978
+                        $enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"';
979
+                    } else {
980
+                        $enc_style = '';
981
+                    }
982
+                    $binding_xml .= "\n" . '    <input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '"' . $enc_style . '/></input>';
983
+                    if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') {
984
+                        $enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"';
985
+                    } else {
986
+                        $enc_style = '';
987
+                    }
988
+                    $binding_xml .= "\n" . '    <output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '"' . $enc_style . '/></output>';
989
+                    $binding_xml .= "\n" . '  </operation>';
990
+                    $portType_xml .= "\n" . '  <operation name="' . $opParts['name'] . '"';
991
+                    if (isset($opParts['parameterOrder'])) {
992
+                        $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"';
993
+                    }
994
+                    $portType_xml .= '>';
995
+                    if(isset($opParts['documentation']) && $opParts['documentation'] != '') {
996
+                        $portType_xml .= "\n" . '    <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>';
997
+                    }
998
+                    $portType_xml .= "\n" . '    <input message="tns:' . $opParts['input']['message'] . '"/>';
999
+                    $portType_xml .= "\n" . '    <output message="tns:' . $opParts['output']['message'] . '"/>';
1000
+                    $portType_xml .= "\n" . '  </operation>';
1001
+                }
1002
+                $portType_xml .= "\n" . '</portType>';
1003
+                $binding_xml .= "\n" . '</binding>';
1004
+            }
1005
+            $xml .= $portType_xml . $binding_xml;
1006
+        }
1007
+        // services
1008
+        $xml .= "\n<service name=\"" . $this->serviceName . '">';
1009
+        if (count($this->ports) >= 1) {
1010
+            foreach($this->ports as $pName => $attrs) {
1011
+                $xml .= "\n" . '  <port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">';
1012
+                $xml .= "\n" . '    <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>';
1013
+                $xml .= "\n" . '  </port>';
1014
+            }
1015
+        }
1016
+        $xml .= "\n" . '</service>';
1017
+        return $xml . "\n</definitions>";
1018
+    }
1019 1019
 
1020
-	/**
1021
-	 * determine whether a set of parameters are unwrapped
1022
-	 * when they are expect to be wrapped, Microsoft-style.
1023
-	 *
1024
-	 * @param string $type the type (element name) of the wrapper
1025
-	 * @param array $parameters the parameter values for the SOAP call
1026
-	 * @return boolean whether they parameters are unwrapped (and should be wrapped)
1027
-	 * @access private
1028
-	 */
1029
-	function parametersMatchWrapped($type, &$parameters) {
1030
-		$this->debug("in parametersMatchWrapped type=$type, parameters=");
1031
-		$this->appendDebug($this->varDump($parameters));
1020
+    /**
1021
+     * determine whether a set of parameters are unwrapped
1022
+     * when they are expect to be wrapped, Microsoft-style.
1023
+     *
1024
+     * @param string $type the type (element name) of the wrapper
1025
+     * @param array $parameters the parameter values for the SOAP call
1026
+     * @return boolean whether they parameters are unwrapped (and should be wrapped)
1027
+     * @access private
1028
+     */
1029
+    function parametersMatchWrapped($type, &$parameters) {
1030
+        $this->debug("in parametersMatchWrapped type=$type, parameters=");
1031
+        $this->appendDebug($this->varDump($parameters));
1032 1032
 
1033
-		// split type into namespace:unqualified-type
1034
-		if (strpos($type, ':')) {
1035
-			$uqType = substr($type, strrpos($type, ':') + 1);
1036
-			$ns = substr($type, 0, strrpos($type, ':'));
1037
-			$this->debug("in parametersMatchWrapped: got a prefixed type: $uqType, $ns");
1038
-			if ($this->getNamespaceFromPrefix($ns)) {
1039
-				$ns = $this->getNamespaceFromPrefix($ns);
1040
-				$this->debug("in parametersMatchWrapped: expanded prefixed type: $uqType, $ns");
1041
-			}
1042
-		} else {
1043
-			// TODO: should the type be compared to types in XSD, and the namespace
1044
-			// set to XSD if the type matches?
1045
-			$this->debug("in parametersMatchWrapped: No namespace for type $type");
1046
-			$ns = '';
1047
-			$uqType = $type;
1048
-		}
1033
+        // split type into namespace:unqualified-type
1034
+        if (strpos($type, ':')) {
1035
+            $uqType = substr($type, strrpos($type, ':') + 1);
1036
+            $ns = substr($type, 0, strrpos($type, ':'));
1037
+            $this->debug("in parametersMatchWrapped: got a prefixed type: $uqType, $ns");
1038
+            if ($this->getNamespaceFromPrefix($ns)) {
1039
+                $ns = $this->getNamespaceFromPrefix($ns);
1040
+                $this->debug("in parametersMatchWrapped: expanded prefixed type: $uqType, $ns");
1041
+            }
1042
+        } else {
1043
+            // TODO: should the type be compared to types in XSD, and the namespace
1044
+            // set to XSD if the type matches?
1045
+            $this->debug("in parametersMatchWrapped: No namespace for type $type");
1046
+            $ns = '';
1047
+            $uqType = $type;
1048
+        }
1049 1049
 
1050
-		// get the type information
1051
-		if (!$typeDef = $this->getTypeDef($uqType, $ns)) {
1052
-			$this->debug("in parametersMatchWrapped: $type ($uqType) is not a supported type.");
1053
-			return false;
1054
-		}
1055
-		$this->debug("in parametersMatchWrapped: found typeDef=");
1056
-		$this->appendDebug($this->varDump($typeDef));
1057
-		if (substr($uqType, -1) == '^') {
1058
-			$uqType = substr($uqType, 0, -1);
1059
-		}
1060
-		$phpType = $typeDef['phpType'];
1061
-		$arrayType = (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '');
1062
-		$this->debug("in parametersMatchWrapped: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: $arrayType");
1050
+        // get the type information
1051
+        if (!$typeDef = $this->getTypeDef($uqType, $ns)) {
1052
+            $this->debug("in parametersMatchWrapped: $type ($uqType) is not a supported type.");
1053
+            return false;
1054
+        }
1055
+        $this->debug("in parametersMatchWrapped: found typeDef=");
1056
+        $this->appendDebug($this->varDump($typeDef));
1057
+        if (substr($uqType, -1) == '^') {
1058
+            $uqType = substr($uqType, 0, -1);
1059
+        }
1060
+        $phpType = $typeDef['phpType'];
1061
+        $arrayType = (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '');
1062
+        $this->debug("in parametersMatchWrapped: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: $arrayType");
1063 1063
 
1064
-		// we expect a complexType or element of complexType
1065
-		if ($phpType != 'struct') {
1066
-			$this->debug("in parametersMatchWrapped: not a struct");
1067
-			return false;
1068
-		}
1064
+        // we expect a complexType or element of complexType
1065
+        if ($phpType != 'struct') {
1066
+            $this->debug("in parametersMatchWrapped: not a struct");
1067
+            return false;
1068
+        }
1069 1069
 
1070
-		// see whether the parameter names match the elements
1071
-		if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
1072
-			$elements = 0;
1073
-			$matches = 0;
1074
-			foreach ($typeDef['elements'] as $name => $attrs) {
1075
-				if (isset($parameters[$name])) {
1076
-					$this->debug("in parametersMatchWrapped: have parameter named $name");
1077
-					$matches++;
1078
-				} else {
1079
-					$this->debug("in parametersMatchWrapped: do not have parameter named $name");
1080
-				}
1081
-				$elements++;
1082
-			}
1070
+        // see whether the parameter names match the elements
1071
+        if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
1072
+            $elements = 0;
1073
+            $matches = 0;
1074
+            foreach ($typeDef['elements'] as $name => $attrs) {
1075
+                if (isset($parameters[$name])) {
1076
+                    $this->debug("in parametersMatchWrapped: have parameter named $name");
1077
+                    $matches++;
1078
+                } else {
1079
+                    $this->debug("in parametersMatchWrapped: do not have parameter named $name");
1080
+                }
1081
+                $elements++;
1082
+            }
1083 1083
 
1084
-			$this->debug("in parametersMatchWrapped: $matches parameter names match $elements wrapped parameter names");
1085
-			if ($matches == 0) {
1086
-				return false;
1087
-			}
1088
-			return true;
1089
-		}
1084
+            $this->debug("in parametersMatchWrapped: $matches parameter names match $elements wrapped parameter names");
1085
+            if ($matches == 0) {
1086
+                return false;
1087
+            }
1088
+            return true;
1089
+        }
1090 1090
 
1091
-		// since there are no elements for the type, if the user passed no
1092
-		// parameters, the parameters match wrapped.
1093
-		$this->debug("in parametersMatchWrapped: no elements type $ns:$uqType");
1094
-		return count($parameters) == 0;
1095
-	}
1091
+        // since there are no elements for the type, if the user passed no
1092
+        // parameters, the parameters match wrapped.
1093
+        $this->debug("in parametersMatchWrapped: no elements type $ns:$uqType");
1094
+        return count($parameters) == 0;
1095
+    }
1096 1096
 
1097
-	/**
1098
-	 * serialize PHP values according to a WSDL message definition
1099
-	 * contrary to the method name, this is not limited to RPC
1100
-	 *
1101
-	 * TODO
1102
-	 * - multi-ref serialization
1103
-	 * - validate PHP values against type definitions, return errors if invalid
1104
-	 *
1105
-	 * @param string $operation operation name
1106
-	 * @param string $direction (input|output)
1107
-	 * @param mixed $parameters parameter value(s)
1108
-	 * @param string $bindingType (soap|soap12)
1109
-	 * @return mixed parameters serialized as XML or false on error (e.g. operation not found)
1110
-	 * @access public
1111
-	 */
1112
-	function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') {
1113
-		$this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
1114
-		$this->appendDebug('parameters=' . $this->varDump($parameters));
1097
+    /**
1098
+     * serialize PHP values according to a WSDL message definition
1099
+     * contrary to the method name, this is not limited to RPC
1100
+     *
1101
+     * TODO
1102
+     * - multi-ref serialization
1103
+     * - validate PHP values against type definitions, return errors if invalid
1104
+     *
1105
+     * @param string $operation operation name
1106
+     * @param string $direction (input|output)
1107
+     * @param mixed $parameters parameter value(s)
1108
+     * @param string $bindingType (soap|soap12)
1109
+     * @return mixed parameters serialized as XML or false on error (e.g. operation not found)
1110
+     * @access public
1111
+     */
1112
+    function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') {
1113
+        $this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
1114
+        $this->appendDebug('parameters=' . $this->varDump($parameters));
1115 1115
 
1116
-		if ($direction != 'input' && $direction != 'output') {
1117
-			$this->debug('The value of the \$direction argument needs to be either "input" or "output"');
1118
-			$this->setError('The value of the \$direction argument needs to be either "input" or "output"');
1119
-			return false;
1120
-		}
1121
-		if (!$opData = $this->getOperationData($operation, $bindingType)) {
1122
-			$this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1123
-			$this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1124
-			return false;
1125
-		}
1126
-		$this->debug('in serializeRPCParameters: opData:');
1127
-		$this->appendDebug($this->varDump($opData));
1116
+        if ($direction != 'input' && $direction != 'output') {
1117
+            $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
1118
+            $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
1119
+            return false;
1120
+        }
1121
+        if (!$opData = $this->getOperationData($operation, $bindingType)) {
1122
+            $this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1123
+            $this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1124
+            return false;
1125
+        }
1126
+        $this->debug('in serializeRPCParameters: opData:');
1127
+        $this->appendDebug($this->varDump($opData));
1128 1128
 
1129
-		// Get encoding style for output and set to current
1130
-		$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1131
-		if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1132
-			$encodingStyle = $opData['output']['encodingStyle'];
1133
-			$enc_style = $encodingStyle;
1134
-		}
1129
+        // Get encoding style for output and set to current
1130
+        $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1131
+        if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1132
+            $encodingStyle = $opData['output']['encodingStyle'];
1133
+            $enc_style = $encodingStyle;
1134
+        }
1135 1135
 
1136
-		// set input params
1137
-		$xml = '';
1138
-		if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
1139
-			$parts = &$opData[$direction]['parts'];
1140
-			$part_count = sizeof($parts);
1141
-			$style = $opData['style'];
1142
-			$use = $opData[$direction]['use'];
1143
-			$this->debug("have $part_count part(s) to serialize using $style/$use");
1144
-			if (is_array($parameters)) {
1145
-				$parametersArrayType = $this->isArraySimpleOrStruct($parameters);
1146
-				$parameter_count = count($parameters);
1147
-				$this->debug("have $parameter_count parameter(s) provided as $parametersArrayType to serialize");
1148
-				// check for Microsoft-style wrapped parameters
1149
-				if ($style == 'document' && $use == 'literal' && $part_count == 1 && isset($parts['parameters'])) {
1150
-					$this->debug('check whether the caller has wrapped the parameters');
1151
-					if ($direction == 'output' && $parametersArrayType == 'arraySimple' && $parameter_count == 1) {
1152
-						// TODO: consider checking here for double-wrapping, when
1153
-						// service function wraps, then NuSOAP wraps again
1154
-						$this->debug("change simple array to associative with 'parameters' element");
1155
-						$parameters['parameters'] = $parameters[0];
1156
-						unset($parameters[0]);
1157
-					}
1158
-					if (($parametersArrayType == 'arrayStruct' || $parameter_count == 0) && !isset($parameters['parameters'])) {
1159
-						$this->debug('check whether caller\'s parameters match the wrapped ones');
1160
-						if ($this->parametersMatchWrapped($parts['parameters'], $parameters)) {
1161
-							$this->debug('wrap the parameters for the caller');
1162
-							$parameters = array('parameters' => $parameters);
1163
-							$parameter_count = 1;
1164
-						}
1165
-					}
1166
-				}
1167
-				foreach ($parts as $name => $type) {
1168
-					$this->debug("serializing part $name of type $type");
1169
-					// Track encoding style
1170
-					if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1171
-						$encodingStyle = $opData[$direction]['encodingStyle'];
1172
-						$enc_style = $encodingStyle;
1173
-					} else {
1174
-						$enc_style = false;
1175
-					}
1176
-					// NOTE: add error handling here
1177
-					// if serializeType returns false, then catch global error and fault
1178
-					if ($parametersArrayType == 'arraySimple') {
1179
-						$p = array_shift($parameters);
1180
-						$this->debug('calling serializeType w/indexed param');
1181
-						$xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
1182
-					} elseif (isset($parameters[$name])) {
1183
-						$this->debug('calling serializeType w/named param');
1184
-						$xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
1185
-					} else {
1186
-						// TODO: only send nillable
1187
-						$this->debug('calling serializeType w/null param');
1188
-						$xml .= $this->serializeType($name, $type, null, $use, $enc_style);
1189
-					}
1190
-				}
1191
-			} else {
1192
-				$this->debug('no parameters passed.');
1193
-			}
1194
-		}
1195
-		$this->debug("serializeRPCParameters returning: $xml");
1196
-		return $xml;
1197
-	}
1136
+        // set input params
1137
+        $xml = '';
1138
+        if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
1139
+            $parts = &$opData[$direction]['parts'];
1140
+            $part_count = sizeof($parts);
1141
+            $style = $opData['style'];
1142
+            $use = $opData[$direction]['use'];
1143
+            $this->debug("have $part_count part(s) to serialize using $style/$use");
1144
+            if (is_array($parameters)) {
1145
+                $parametersArrayType = $this->isArraySimpleOrStruct($parameters);
1146
+                $parameter_count = count($parameters);
1147
+                $this->debug("have $parameter_count parameter(s) provided as $parametersArrayType to serialize");
1148
+                // check for Microsoft-style wrapped parameters
1149
+                if ($style == 'document' && $use == 'literal' && $part_count == 1 && isset($parts['parameters'])) {
1150
+                    $this->debug('check whether the caller has wrapped the parameters');
1151
+                    if ($direction == 'output' && $parametersArrayType == 'arraySimple' && $parameter_count == 1) {
1152
+                        // TODO: consider checking here for double-wrapping, when
1153
+                        // service function wraps, then NuSOAP wraps again
1154
+                        $this->debug("change simple array to associative with 'parameters' element");
1155
+                        $parameters['parameters'] = $parameters[0];
1156
+                        unset($parameters[0]);
1157
+                    }
1158
+                    if (($parametersArrayType == 'arrayStruct' || $parameter_count == 0) && !isset($parameters['parameters'])) {
1159
+                        $this->debug('check whether caller\'s parameters match the wrapped ones');
1160
+                        if ($this->parametersMatchWrapped($parts['parameters'], $parameters)) {
1161
+                            $this->debug('wrap the parameters for the caller');
1162
+                            $parameters = array('parameters' => $parameters);
1163
+                            $parameter_count = 1;
1164
+                        }
1165
+                    }
1166
+                }
1167
+                foreach ($parts as $name => $type) {
1168
+                    $this->debug("serializing part $name of type $type");
1169
+                    // Track encoding style
1170
+                    if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1171
+                        $encodingStyle = $opData[$direction]['encodingStyle'];
1172
+                        $enc_style = $encodingStyle;
1173
+                    } else {
1174
+                        $enc_style = false;
1175
+                    }
1176
+                    // NOTE: add error handling here
1177
+                    // if serializeType returns false, then catch global error and fault
1178
+                    if ($parametersArrayType == 'arraySimple') {
1179
+                        $p = array_shift($parameters);
1180
+                        $this->debug('calling serializeType w/indexed param');
1181
+                        $xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
1182
+                    } elseif (isset($parameters[$name])) {
1183
+                        $this->debug('calling serializeType w/named param');
1184
+                        $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
1185
+                    } else {
1186
+                        // TODO: only send nillable
1187
+                        $this->debug('calling serializeType w/null param');
1188
+                        $xml .= $this->serializeType($name, $type, null, $use, $enc_style);
1189
+                    }
1190
+                }
1191
+            } else {
1192
+                $this->debug('no parameters passed.');
1193
+            }
1194
+        }
1195
+        $this->debug("serializeRPCParameters returning: $xml");
1196
+        return $xml;
1197
+    }
1198 1198
 
1199
-	/**
1200
-	 * serialize a PHP value according to a WSDL message definition
1201
-	 *
1202
-	 * TODO
1203
-	 * - multi-ref serialization
1204
-	 * - validate PHP values against type definitions, return errors if invalid
1205
-	 *
1206
-	 * @param string $operation operation name
1207
-	 * @param string $direction (input|output)
1208
-	 * @param mixed $parameters parameter value(s)
1209
-	 * @return mixed parameters serialized as XML or false on error (e.g. operation not found)
1210
-	 * @access public
1211
-	 * @deprecated
1212
-	 */
1213
-	function serializeParameters($operation, $direction, $parameters)
1214
-	{
1215
-		$this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
1216
-		$this->appendDebug('parameters=' . $this->varDump($parameters));
1199
+    /**
1200
+     * serialize a PHP value according to a WSDL message definition
1201
+     *
1202
+     * TODO
1203
+     * - multi-ref serialization
1204
+     * - validate PHP values against type definitions, return errors if invalid
1205
+     *
1206
+     * @param string $operation operation name
1207
+     * @param string $direction (input|output)
1208
+     * @param mixed $parameters parameter value(s)
1209
+     * @return mixed parameters serialized as XML or false on error (e.g. operation not found)
1210
+     * @access public
1211
+     * @deprecated
1212
+     */
1213
+    function serializeParameters($operation, $direction, $parameters)
1214
+    {
1215
+        $this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
1216
+        $this->appendDebug('parameters=' . $this->varDump($parameters));
1217 1217
 
1218
-		if ($direction != 'input' && $direction != 'output') {
1219
-			$this->debug('The value of the \$direction argument needs to be either "input" or "output"');
1220
-			$this->setError('The value of the \$direction argument needs to be either "input" or "output"');
1221
-			return false;
1222
-		}
1223
-		if (!$opData = $this->getOperationData($operation)) {
1224
-			$this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
1225
-			$this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
1226
-			return false;
1227
-		}
1228
-		$this->debug('opData:');
1229
-		$this->appendDebug($this->varDump($opData));
1218
+        if ($direction != 'input' && $direction != 'output') {
1219
+            $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
1220
+            $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
1221
+            return false;
1222
+        }
1223
+        if (!$opData = $this->getOperationData($operation)) {
1224
+            $this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
1225
+            $this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
1226
+            return false;
1227
+        }
1228
+        $this->debug('opData:');
1229
+        $this->appendDebug($this->varDump($opData));
1230 1230
 
1231
-		// Get encoding style for output and set to current
1232
-		$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1233
-		if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1234
-			$encodingStyle = $opData['output']['encodingStyle'];
1235
-			$enc_style = $encodingStyle;
1236
-		}
1231
+        // Get encoding style for output and set to current
1232
+        $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1233
+        if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1234
+            $encodingStyle = $opData['output']['encodingStyle'];
1235
+            $enc_style = $encodingStyle;
1236
+        }
1237 1237
 
1238
-		// set input params
1239
-		$xml = '';
1240
-		if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
1238
+        // set input params
1239
+        $xml = '';
1240
+        if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
1241 1241
 
1242
-			$use = $opData[$direction]['use'];
1243
-			$this->debug("use=$use");
1244
-			$this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
1245
-			if (is_array($parameters)) {
1246
-				$parametersArrayType = $this->isArraySimpleOrStruct($parameters);
1247
-				$this->debug('have ' . $parametersArrayType . ' parameters');
1248
-				foreach($opData[$direction]['parts'] as $name => $type) {
1249
-					$this->debug('serializing part "'.$name.'" of type "'.$type.'"');
1250
-					// Track encoding style
1251
-					if(isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1252
-						$encodingStyle = $opData[$direction]['encodingStyle'];
1253
-						$enc_style = $encodingStyle;
1254
-					} else {
1255
-						$enc_style = false;
1256
-					}
1257
-					// NOTE: add error handling here
1258
-					// if serializeType returns false, then catch global error and fault
1259
-					if ($parametersArrayType == 'arraySimple') {
1260
-						$p = array_shift($parameters);
1261
-						$this->debug('calling serializeType w/indexed param');
1262
-						$xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
1263
-					} elseif (isset($parameters[$name])) {
1264
-						$this->debug('calling serializeType w/named param');
1265
-						$xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
1266
-					} else {
1267
-						// TODO: only send nillable
1268
-						$this->debug('calling serializeType w/null param');
1269
-						$xml .= $this->serializeType($name, $type, null, $use, $enc_style);
1270
-					}
1271
-				}
1272
-			} else {
1273
-				$this->debug('no parameters passed.');
1274
-			}
1275
-		}
1276
-		$this->debug("serializeParameters returning: $xml");
1277
-		return $xml;
1278
-	}
1242
+            $use = $opData[$direction]['use'];
1243
+            $this->debug("use=$use");
1244
+            $this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
1245
+            if (is_array($parameters)) {
1246
+                $parametersArrayType = $this->isArraySimpleOrStruct($parameters);
1247
+                $this->debug('have ' . $parametersArrayType . ' parameters');
1248
+                foreach($opData[$direction]['parts'] as $name => $type) {
1249
+                    $this->debug('serializing part "'.$name.'" of type "'.$type.'"');
1250
+                    // Track encoding style
1251
+                    if(isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1252
+                        $encodingStyle = $opData[$direction]['encodingStyle'];
1253
+                        $enc_style = $encodingStyle;
1254
+                    } else {
1255
+                        $enc_style = false;
1256
+                    }
1257
+                    // NOTE: add error handling here
1258
+                    // if serializeType returns false, then catch global error and fault
1259
+                    if ($parametersArrayType == 'arraySimple') {
1260
+                        $p = array_shift($parameters);
1261
+                        $this->debug('calling serializeType w/indexed param');
1262
+                        $xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
1263
+                    } elseif (isset($parameters[$name])) {
1264
+                        $this->debug('calling serializeType w/named param');
1265
+                        $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
1266
+                    } else {
1267
+                        // TODO: only send nillable
1268
+                        $this->debug('calling serializeType w/null param');
1269
+                        $xml .= $this->serializeType($name, $type, null, $use, $enc_style);
1270
+                    }
1271
+                }
1272
+            } else {
1273
+                $this->debug('no parameters passed.');
1274
+            }
1275
+        }
1276
+        $this->debug("serializeParameters returning: $xml");
1277
+        return $xml;
1278
+    }
1279 1279
 
1280
-	/**
1281
-	 * serializes a PHP value according a given type definition
1282
-	 *
1283
-	 * @param string $name name of value (part or element)
1284
-	 * @param string $type XML schema type of value (type or element)
1285
-	 * @param mixed $value a native PHP value (parameter value)
1286
-	 * @param string $use use for part (encoded|literal)
1287
-	 * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
1288
-	 * @param boolean $unqualified a kludge for what should be XML namespace form handling
1289
-	 * @return string value serialized as an XML string
1290
-	 * @access private
1291
-	 */
1292
-	function serializeType($name, $type, $value, $use='encoded', $encodingStyle=false, $unqualified=false)
1293
-	{
1294
-		$this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified"));
1295
-		$this->appendDebug("value=" . $this->varDump($value));
1296
-		if($use == 'encoded' && $encodingStyle) {
1297
-			$encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"';
1298
-		}
1280
+    /**
1281
+     * serializes a PHP value according a given type definition
1282
+     *
1283
+     * @param string $name name of value (part or element)
1284
+     * @param string $type XML schema type of value (type or element)
1285
+     * @param mixed $value a native PHP value (parameter value)
1286
+     * @param string $use use for part (encoded|literal)
1287
+     * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
1288
+     * @param boolean $unqualified a kludge for what should be XML namespace form handling
1289
+     * @return string value serialized as an XML string
1290
+     * @access private
1291
+     */
1292
+    function serializeType($name, $type, $value, $use='encoded', $encodingStyle=false, $unqualified=false)
1293
+    {
1294
+        $this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified"));
1295
+        $this->appendDebug("value=" . $this->varDump($value));
1296
+        if($use == 'encoded' && $encodingStyle) {
1297
+            $encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"';
1298
+        }
1299 1299
 
1300
-		// if a soapval has been supplied, let its type override the WSDL
1301
-    	if (is_object($value) && get_class($value) == 'soapval') {
1302
-    		if ($value->type_ns) {
1303
-    			$type = $value->type_ns . ':' . $value->type;
1304
-		    	$forceType = true;
1305
-		    	$this->debug("in serializeType: soapval overrides type to $type");
1306
-    		} elseif ($value->type) {
1307
-	    		$type = $value->type;
1308
-		    	$forceType = true;
1309
-		    	$this->debug("in serializeType: soapval overrides type to $type");
1310
-	    	} else {
1311
-	    		$forceType = false;
1312
-		    	$this->debug("in serializeType: soapval does not override type");
1313
-	    	}
1314
-	    	$attrs = $value->attributes;
1315
-	    	$value = $value->value;
1316
-	    	$this->debug("in serializeType: soapval overrides value to $value");
1317
-	    	if ($attrs) {
1318
-	    		if (!is_array($value)) {
1319
-	    			$value['!'] = $value;
1320
-	    		}
1321
-	    		foreach ($attrs as $n => $v) {
1322
-	    			$value['!' . $n] = $v;
1323
-	    		}
1324
-		    	$this->debug("in serializeType: soapval provides attributes");
1325
-		    }
1300
+        // if a soapval has been supplied, let its type override the WSDL
1301
+        if (is_object($value) && get_class($value) == 'soapval') {
1302
+            if ($value->type_ns) {
1303
+                $type = $value->type_ns . ':' . $value->type;
1304
+                $forceType = true;
1305
+                $this->debug("in serializeType: soapval overrides type to $type");
1306
+            } elseif ($value->type) {
1307
+                $type = $value->type;
1308
+                $forceType = true;
1309
+                $this->debug("in serializeType: soapval overrides type to $type");
1310
+            } else {
1311
+                $forceType = false;
1312
+                $this->debug("in serializeType: soapval does not override type");
1313
+            }
1314
+            $attrs = $value->attributes;
1315
+            $value = $value->value;
1316
+            $this->debug("in serializeType: soapval overrides value to $value");
1317
+            if ($attrs) {
1318
+                if (!is_array($value)) {
1319
+                    $value['!'] = $value;
1320
+                }
1321
+                foreach ($attrs as $n => $v) {
1322
+                    $value['!' . $n] = $v;
1323
+                }
1324
+                $this->debug("in serializeType: soapval provides attributes");
1325
+            }
1326 1326
         } else {
1327
-        	$forceType = false;
1327
+            $forceType = false;
1328 1328
         }
1329 1329
 
1330
-		$xml = '';
1331
-		if (strpos($type, ':')) {
1332
-			$uqType = substr($type, strrpos($type, ':') + 1);
1333
-			$ns = substr($type, 0, strrpos($type, ':'));
1334
-			$this->debug("in serializeType: got a prefixed type: $uqType, $ns");
1335
-			if ($this->getNamespaceFromPrefix($ns)) {
1336
-				$ns = $this->getNamespaceFromPrefix($ns);
1337
-				$this->debug("in serializeType: expanded prefixed type: $uqType, $ns");
1338
-			}
1330
+        $xml = '';
1331
+        if (strpos($type, ':')) {
1332
+            $uqType = substr($type, strrpos($type, ':') + 1);
1333
+            $ns = substr($type, 0, strrpos($type, ':'));
1334
+            $this->debug("in serializeType: got a prefixed type: $uqType, $ns");
1335
+            if ($this->getNamespaceFromPrefix($ns)) {
1336
+                $ns = $this->getNamespaceFromPrefix($ns);
1337
+                $this->debug("in serializeType: expanded prefixed type: $uqType, $ns");
1338
+            }
1339 1339
 
1340
-			if($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/'){
1341
-				$this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
1342
-				if ($unqualified && $use == 'literal') {
1343
-					$elementNS = " xmlns=\"\"";
1344
-				} else {
1345
-					$elementNS = '';
1346
-				}
1347
-				if (is_null($value)) {
1348
-					if ($use == 'literal') {
1349
-						// TODO: depends on minOccurs
1350
-						$xml = "<$name$elementNS/>";
1351
-					} else {
1352
-						// TODO: depends on nillable, which should be checked before calling this method
1353
-						$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1354
-					}
1355
-					$this->debug("in serializeType: returning: $xml");
1356
-					return $xml;
1357
-				}
1358
-				if ($uqType == 'Array') {
1359
-					// JBoss/Axis does this sometimes
1360
-					return $this->serialize_val($value, $name, false, false, false, false, $use);
1361
-				}
1362
-		    	if ($uqType == 'boolean') {
1363
-		    		if ((is_string($value) && $value == 'false') || (! $value)) {
1364
-						$value = 'false';
1365
-					} else {
1366
-						$value = 'true';
1367
-					}
1368
-				}
1369
-				if ($uqType == 'string' && gettype($value) == 'string') {
1370
-					$value = $this->expandEntities($value);
1371
-				}
1372
-				if (($uqType == 'long' || $uqType == 'unsignedLong') && gettype($value) == 'double') {
1373
-					$value = sprintf("%.0lf", $value);
1374
-				}
1375
-				// it's a scalar
1376
-				// TODO: what about null/nil values?
1377
-				// check type isn't a custom type extending xmlschema namespace
1378
-				if (!$this->getTypeDef($uqType, $ns)) {
1379
-					if ($use == 'literal') {
1380
-						if ($forceType) {
1381
-							$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1382
-						} else {
1383
-							$xml = "<$name$elementNS>$value</$name>";
1384
-						}
1385
-					} else {
1386
-						$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1387
-					}
1388
-					$this->debug("in serializeType: returning: $xml");
1389
-					return $xml;
1390
-				}
1391
-				$this->debug('custom type extends XML Schema or SOAP Encoding namespace (yuck)');
1392
-			} else if ($ns == 'http://xml.apache.org/xml-soap') {
1393
-				$this->debug('in serializeType: appears to be Apache SOAP type');
1394
-				if ($uqType == 'Map') {
1395
-					$tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1396
-					if (! $tt_prefix) {
1397
-						$this->debug('in serializeType: Add namespace for Apache SOAP type');
1398
-						$tt_prefix = 'ns' . rand(1000, 9999);
1399
-						$this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap';
1400
-						// force this to be added to usedNamespaces
1401
-						$tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1402
-					}
1403
-					$contents = '';
1404
-					foreach($value as $k => $v) {
1405
-						$this->debug("serializing map element: key $k, value $v");
1406
-						$contents .= '<item>';
1407
-						$contents .= $this->serialize_val($k,'key',false,false,false,false,$use);
1408
-						$contents .= $this->serialize_val($v,'value',false,false,false,false,$use);
1409
-						$contents .= '</item>';
1410
-					}
1411
-					if ($use == 'literal') {
1412
-						if ($forceType) {
1413
-							$xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\">$contents</$name>";
1414
-						} else {
1415
-							$xml = "<$name>$contents</$name>";
1416
-						}
1417
-					} else {
1418
-						$xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\"$encodingStyle>$contents</$name>";
1419
-					}
1420
-					$this->debug("in serializeType: returning: $xml");
1421
-					return $xml;
1422
-				}
1423
-				$this->debug('in serializeType: Apache SOAP type, but only support Map');
1424
-			}
1425
-		} else {
1426
-			// TODO: should the type be compared to types in XSD, and the namespace
1427
-			// set to XSD if the type matches?
1428
-			$this->debug("in serializeType: No namespace for type $type");
1429
-			$ns = '';
1430
-			$uqType = $type;
1431
-		}
1432
-		if(!$typeDef = $this->getTypeDef($uqType, $ns)){
1433
-			$this->setError("$type ($uqType) is not a supported type.");
1434
-			$this->debug("in serializeType: $type ($uqType) is not a supported type.");
1435
-			return false;
1436
-		} else {
1437
-			$this->debug("in serializeType: found typeDef");
1438
-			$this->appendDebug('typeDef=' . $this->varDump($typeDef));
1439
-			if (substr($uqType, -1) == '^') {
1440
-				$uqType = substr($uqType, 0, -1);
1441
-			}
1442
-		}
1443
-		if (!isset($typeDef['phpType'])) {
1444
-			$this->setError("$type ($uqType) has no phpType.");
1445
-			$this->debug("in serializeType: $type ($uqType) has no phpType.");
1446
-			return false;
1447
-		}
1448
-		$phpType = $typeDef['phpType'];
1449
-		$this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') );
1450
-		// if php type == struct, map value to the <all> element names
1451
-		if ($phpType == 'struct') {
1452
-			if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
1453
-				$elementName = $uqType;
1454
-				if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1455
-					$elementNS = " xmlns=\"$ns\"";
1456
-				} else {
1457
-					$elementNS = " xmlns=\"\"";
1458
-				}
1459
-			} else {
1460
-				$elementName = $name;
1461
-				if ($unqualified) {
1462
-					$elementNS = " xmlns=\"\"";
1463
-				} else {
1464
-					$elementNS = '';
1465
-				}
1466
-			}
1467
-			if (is_null($value)) {
1468
-				if ($use == 'literal') {
1469
-					// TODO: depends on minOccurs and nillable
1470
-					$xml = "<$elementName$elementNS/>";
1471
-				} else {
1472
-					$xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1473
-				}
1474
-				$this->debug("in serializeType: returning: $xml");
1475
-				return $xml;
1476
-			}
1477
-			if (is_object($value)) {
1478
-				$value = get_object_vars($value);
1479
-			}
1480
-			if (is_array($value)) {
1481
-				$elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
1482
-				if ($use == 'literal') {
1483
-					if ($forceType) {
1484
-						$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">";
1485
-					} else {
1486
-						$xml = "<$elementName$elementNS$elementAttrs>";
1487
-					}
1488
-				} else {
1489
-					$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>";
1490
-				}
1340
+            if($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/'){
1341
+                $this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
1342
+                if ($unqualified && $use == 'literal') {
1343
+                    $elementNS = " xmlns=\"\"";
1344
+                } else {
1345
+                    $elementNS = '';
1346
+                }
1347
+                if (is_null($value)) {
1348
+                    if ($use == 'literal') {
1349
+                        // TODO: depends on minOccurs
1350
+                        $xml = "<$name$elementNS/>";
1351
+                    } else {
1352
+                        // TODO: depends on nillable, which should be checked before calling this method
1353
+                        $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1354
+                    }
1355
+                    $this->debug("in serializeType: returning: $xml");
1356
+                    return $xml;
1357
+                }
1358
+                if ($uqType == 'Array') {
1359
+                    // JBoss/Axis does this sometimes
1360
+                    return $this->serialize_val($value, $name, false, false, false, false, $use);
1361
+                }
1362
+                if ($uqType == 'boolean') {
1363
+                    if ((is_string($value) && $value == 'false') || (! $value)) {
1364
+                        $value = 'false';
1365
+                    } else {
1366
+                        $value = 'true';
1367
+                    }
1368
+                }
1369
+                if ($uqType == 'string' && gettype($value) == 'string') {
1370
+                    $value = $this->expandEntities($value);
1371
+                }
1372
+                if (($uqType == 'long' || $uqType == 'unsignedLong') && gettype($value) == 'double') {
1373
+                    $value = sprintf("%.0lf", $value);
1374
+                }
1375
+                // it's a scalar
1376
+                // TODO: what about null/nil values?
1377
+                // check type isn't a custom type extending xmlschema namespace
1378
+                if (!$this->getTypeDef($uqType, $ns)) {
1379
+                    if ($use == 'literal') {
1380
+                        if ($forceType) {
1381
+                            $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1382
+                        } else {
1383
+                            $xml = "<$name$elementNS>$value</$name>";
1384
+                        }
1385
+                    } else {
1386
+                        $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1387
+                    }
1388
+                    $this->debug("in serializeType: returning: $xml");
1389
+                    return $xml;
1390
+                }
1391
+                $this->debug('custom type extends XML Schema or SOAP Encoding namespace (yuck)');
1392
+            } else if ($ns == 'http://xml.apache.org/xml-soap') {
1393
+                $this->debug('in serializeType: appears to be Apache SOAP type');
1394
+                if ($uqType == 'Map') {
1395
+                    $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1396
+                    if (! $tt_prefix) {
1397
+                        $this->debug('in serializeType: Add namespace for Apache SOAP type');
1398
+                        $tt_prefix = 'ns' . rand(1000, 9999);
1399
+                        $this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap';
1400
+                        // force this to be added to usedNamespaces
1401
+                        $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1402
+                    }
1403
+                    $contents = '';
1404
+                    foreach($value as $k => $v) {
1405
+                        $this->debug("serializing map element: key $k, value $v");
1406
+                        $contents .= '<item>';
1407
+                        $contents .= $this->serialize_val($k,'key',false,false,false,false,$use);
1408
+                        $contents .= $this->serialize_val($v,'value',false,false,false,false,$use);
1409
+                        $contents .= '</item>';
1410
+                    }
1411
+                    if ($use == 'literal') {
1412
+                        if ($forceType) {
1413
+                            $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\">$contents</$name>";
1414
+                        } else {
1415
+                            $xml = "<$name>$contents</$name>";
1416
+                        }
1417
+                    } else {
1418
+                        $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\"$encodingStyle>$contents</$name>";
1419
+                    }
1420
+                    $this->debug("in serializeType: returning: $xml");
1421
+                    return $xml;
1422
+                }
1423
+                $this->debug('in serializeType: Apache SOAP type, but only support Map');
1424
+            }
1425
+        } else {
1426
+            // TODO: should the type be compared to types in XSD, and the namespace
1427
+            // set to XSD if the type matches?
1428
+            $this->debug("in serializeType: No namespace for type $type");
1429
+            $ns = '';
1430
+            $uqType = $type;
1431
+        }
1432
+        if(!$typeDef = $this->getTypeDef($uqType, $ns)){
1433
+            $this->setError("$type ($uqType) is not a supported type.");
1434
+            $this->debug("in serializeType: $type ($uqType) is not a supported type.");
1435
+            return false;
1436
+        } else {
1437
+            $this->debug("in serializeType: found typeDef");
1438
+            $this->appendDebug('typeDef=' . $this->varDump($typeDef));
1439
+            if (substr($uqType, -1) == '^') {
1440
+                $uqType = substr($uqType, 0, -1);
1441
+            }
1442
+        }
1443
+        if (!isset($typeDef['phpType'])) {
1444
+            $this->setError("$type ($uqType) has no phpType.");
1445
+            $this->debug("in serializeType: $type ($uqType) has no phpType.");
1446
+            return false;
1447
+        }
1448
+        $phpType = $typeDef['phpType'];
1449
+        $this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') );
1450
+        // if php type == struct, map value to the <all> element names
1451
+        if ($phpType == 'struct') {
1452
+            if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
1453
+                $elementName = $uqType;
1454
+                if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1455
+                    $elementNS = " xmlns=\"$ns\"";
1456
+                } else {
1457
+                    $elementNS = " xmlns=\"\"";
1458
+                }
1459
+            } else {
1460
+                $elementName = $name;
1461
+                if ($unqualified) {
1462
+                    $elementNS = " xmlns=\"\"";
1463
+                } else {
1464
+                    $elementNS = '';
1465
+                }
1466
+            }
1467
+            if (is_null($value)) {
1468
+                if ($use == 'literal') {
1469
+                    // TODO: depends on minOccurs and nillable
1470
+                    $xml = "<$elementName$elementNS/>";
1471
+                } else {
1472
+                    $xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1473
+                }
1474
+                $this->debug("in serializeType: returning: $xml");
1475
+                return $xml;
1476
+            }
1477
+            if (is_object($value)) {
1478
+                $value = get_object_vars($value);
1479
+            }
1480
+            if (is_array($value)) {
1481
+                $elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
1482
+                if ($use == 'literal') {
1483
+                    if ($forceType) {
1484
+                        $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">";
1485
+                    } else {
1486
+                        $xml = "<$elementName$elementNS$elementAttrs>";
1487
+                    }
1488
+                } else {
1489
+                    $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>";
1490
+                }
1491 1491
 
1492
-				if (isset($typeDef['simpleContent']) && $typeDef['simpleContent'] == 'true') {
1493
-					if (isset($value['!'])) {
1494
-						$xml .= $value['!'];
1495
-						$this->debug("in serializeType: serialized simpleContent for type $type");
1496
-					} else {
1497
-						$this->debug("in serializeType: no simpleContent to serialize for type $type");
1498
-					}
1499
-				} else {
1500
-					// complexContent
1501
-					$xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
1502
-				}
1503
-				$xml .= "</$elementName>";
1504
-			} else {
1505
-				$this->debug("in serializeType: phpType is struct, but value is not an array");
1506
-				$this->setError("phpType is struct, but value is not an array: see debug output for details");
1507
-				$xml = '';
1508
-			}
1509
-		} elseif ($phpType == 'array') {
1510
-			if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1511
-				$elementNS = " xmlns=\"$ns\"";
1512
-			} else {
1513
-				if ($unqualified) {
1514
-					$elementNS = " xmlns=\"\"";
1515
-				} else {
1516
-					$elementNS = '';
1517
-				}
1518
-			}
1519
-			if (is_null($value)) {
1520
-				if ($use == 'literal') {
1521
-					// TODO: depends on minOccurs
1522
-					$xml = "<$name$elementNS/>";
1523
-				} else {
1524
-					$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" .
1525
-						$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1526
-						":Array\" " .
1527
-						$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1528
-						':arrayType="' .
1529
-						$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) .
1530
-						':' .
1531
-						$this->getLocalPart($typeDef['arrayType'])."[0]\"/>";
1532
-				}
1533
-				$this->debug("in serializeType: returning: $xml");
1534
-				return $xml;
1535
-			}
1536
-			if (isset($typeDef['multidimensional'])) {
1537
-				$nv = array();
1538
-				foreach($value as $v) {
1539
-					$cols = ',' . sizeof($v);
1540
-					$nv = array_merge($nv, $v);
1541
-				}
1542
-				$value = $nv;
1543
-			} else {
1544
-				$cols = '';
1545
-			}
1546
-			if (is_array($value) && sizeof($value) >= 1) {
1547
-				$rows = sizeof($value);
1548
-				$contents = '';
1549
-				foreach($value as $k => $v) {
1550
-					//$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
1551
-					//if (strpos($typeDef['arrayType'], ':') ) {
1552
-					if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
1553
-					    $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
1554
-					} else {
1555
-					    $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use);
1556
-					}
1557
-				}
1558
-			} else {
1559
-				$rows = 0;
1560
-				$contents = null;
1561
-			}
1562
-			// TODO: for now, an empty value will be serialized as a zero element
1563
-			// array.  Revisit this when coding the handling of null/nil values.
1564
-			if ($use == 'literal') {
1565
-				$xml = "<$name$elementNS>"
1566
-					.$contents
1567
-					."</$name>";
1568
-			} else {
1569
-				$xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').':Array" '.
1570
-					$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/')
1571
-					.':arrayType="'
1572
-					.$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType']))
1573
-					.":".$this->getLocalPart($typeDef['arrayType'])."[$rows$cols]\">"
1574
-					.$contents
1575
-					."</$name>";
1576
-			}
1577
-		} elseif ($phpType == 'scalar') {
1578
-			if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1579
-				$elementNS = " xmlns=\"$ns\"";
1580
-			} else {
1581
-				if ($unqualified) {
1582
-					$elementNS = " xmlns=\"\"";
1583
-				} else {
1584
-					$elementNS = '';
1585
-				}
1586
-			}
1587
-			if ($use == 'literal') {
1588
-				if ($forceType) {
1589
-					$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1590
-				} else {
1591
-					$xml = "<$name$elementNS>$value</$name>";
1592
-				}
1593
-			} else {
1594
-				$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1595
-			}
1596
-		}
1597
-		$this->debug("in serializeType: returning: $xml");
1598
-		return $xml;
1599
-	}
1492
+                if (isset($typeDef['simpleContent']) && $typeDef['simpleContent'] == 'true') {
1493
+                    if (isset($value['!'])) {
1494
+                        $xml .= $value['!'];
1495
+                        $this->debug("in serializeType: serialized simpleContent for type $type");
1496
+                    } else {
1497
+                        $this->debug("in serializeType: no simpleContent to serialize for type $type");
1498
+                    }
1499
+                } else {
1500
+                    // complexContent
1501
+                    $xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
1502
+                }
1503
+                $xml .= "</$elementName>";
1504
+            } else {
1505
+                $this->debug("in serializeType: phpType is struct, but value is not an array");
1506
+                $this->setError("phpType is struct, but value is not an array: see debug output for details");
1507
+                $xml = '';
1508
+            }
1509
+        } elseif ($phpType == 'array') {
1510
+            if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1511
+                $elementNS = " xmlns=\"$ns\"";
1512
+            } else {
1513
+                if ($unqualified) {
1514
+                    $elementNS = " xmlns=\"\"";
1515
+                } else {
1516
+                    $elementNS = '';
1517
+                }
1518
+            }
1519
+            if (is_null($value)) {
1520
+                if ($use == 'literal') {
1521
+                    // TODO: depends on minOccurs
1522
+                    $xml = "<$name$elementNS/>";
1523
+                } else {
1524
+                    $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" .
1525
+                        $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1526
+                        ":Array\" " .
1527
+                        $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1528
+                        ':arrayType="' .
1529
+                        $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) .
1530
+                        ':' .
1531
+                        $this->getLocalPart($typeDef['arrayType'])."[0]\"/>";
1532
+                }
1533
+                $this->debug("in serializeType: returning: $xml");
1534
+                return $xml;
1535
+            }
1536
+            if (isset($typeDef['multidimensional'])) {
1537
+                $nv = array();
1538
+                foreach($value as $v) {
1539
+                    $cols = ',' . sizeof($v);
1540
+                    $nv = array_merge($nv, $v);
1541
+                }
1542
+                $value = $nv;
1543
+            } else {
1544
+                $cols = '';
1545
+            }
1546
+            if (is_array($value) && sizeof($value) >= 1) {
1547
+                $rows = sizeof($value);
1548
+                $contents = '';
1549
+                foreach($value as $k => $v) {
1550
+                    //$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
1551
+                    //if (strpos($typeDef['arrayType'], ':') ) {
1552
+                    if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
1553
+                        $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
1554
+                    } else {
1555
+                        $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use);
1556
+                    }
1557
+                }
1558
+            } else {
1559
+                $rows = 0;
1560
+                $contents = null;
1561
+            }
1562
+            // TODO: for now, an empty value will be serialized as a zero element
1563
+            // array.  Revisit this when coding the handling of null/nil values.
1564
+            if ($use == 'literal') {
1565
+                $xml = "<$name$elementNS>"
1566
+                    .$contents
1567
+                    ."</$name>";
1568
+            } else {
1569
+                $xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').':Array" '.
1570
+                    $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/')
1571
+                    .':arrayType="'
1572
+                    .$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType']))
1573
+                    .":".$this->getLocalPart($typeDef['arrayType'])."[$rows$cols]\">"
1574
+                    .$contents
1575
+                    ."</$name>";
1576
+            }
1577
+        } elseif ($phpType == 'scalar') {
1578
+            if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1579
+                $elementNS = " xmlns=\"$ns\"";
1580
+            } else {
1581
+                if ($unqualified) {
1582
+                    $elementNS = " xmlns=\"\"";
1583
+                } else {
1584
+                    $elementNS = '';
1585
+                }
1586
+            }
1587
+            if ($use == 'literal') {
1588
+                if ($forceType) {
1589
+                    $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1590
+                } else {
1591
+                    $xml = "<$name$elementNS>$value</$name>";
1592
+                }
1593
+            } else {
1594
+                $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1595
+            }
1596
+        }
1597
+        $this->debug("in serializeType: returning: $xml");
1598
+        return $xml;
1599
+    }
1600 1600
 
1601
-	/**
1602
-	 * serializes the attributes for a complexType
1603
-	 *
1604
-	 * @param array $typeDef our internal representation of an XML schema type (or element)
1605
-	 * @param mixed $value a native PHP value (parameter value)
1606
-	 * @param string $ns the namespace of the type
1607
-	 * @param string $uqType the local part of the type
1608
-	 * @return string value serialized as an XML string
1609
-	 * @access private
1610
-	 */
1611
-	function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) {
1612
-		$this->debug("serializeComplexTypeAttributes for XML Schema type $ns:$uqType");
1613
-		$xml = '';
1614
-		if (isset($typeDef['extensionBase'])) {
1615
-			$nsx = $this->getPrefix($typeDef['extensionBase']);
1616
-			$uqTypex = $this->getLocalPart($typeDef['extensionBase']);
1617
-			if ($this->getNamespaceFromPrefix($nsx)) {
1618
-				$nsx = $this->getNamespaceFromPrefix($nsx);
1619
-			}
1620
-			if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
1621
-				$this->debug("serialize attributes for extension base $nsx:$uqTypex");
1622
-				$xml .= $this->serializeComplexTypeAttributes($typeDefx, $value, $nsx, $uqTypex);
1623
-			} else {
1624
-				$this->debug("extension base $nsx:$uqTypex is not a supported type");
1625
-			}
1626
-		}
1627
-		if (isset($typeDef['attrs']) && is_array($typeDef['attrs'])) {
1628
-			$this->debug("serialize attributes for XML Schema type $ns:$uqType");
1629
-			if (is_array($value)) {
1630
-				$xvalue = $value;
1631
-			} elseif (is_object($value)) {
1632
-				$xvalue = get_object_vars($value);
1633
-			} else {
1634
-				$this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
1635
-				$xvalue = array();
1636
-			}
1637
-			foreach ($typeDef['attrs'] as $aName => $attrs) {
1638
-				if (isset($xvalue['!' . $aName])) {
1639
-					$xname = '!' . $aName;
1640
-					$this->debug("value provided for attribute $aName with key $xname");
1641
-				} elseif (isset($xvalue[$aName])) {
1642
-					$xname = $aName;
1643
-					$this->debug("value provided for attribute $aName with key $xname");
1644
-				} elseif (isset($attrs['default'])) {
1645
-					$xname = '!' . $aName;
1646
-					$xvalue[$xname] = $attrs['default'];
1647
-					$this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
1648
-				} else {
1649
-					$xname = '';
1650
-					$this->debug("no value provided for attribute $aName");
1651
-				}
1652
-				if ($xname) {
1653
-					$xml .=  " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\"";
1654
-				}
1655
-			}
1656
-		} else {
1657
-			$this->debug("no attributes to serialize for XML Schema type $ns:$uqType");
1658
-		}
1659
-		return $xml;
1660
-	}
1601
+    /**
1602
+     * serializes the attributes for a complexType
1603
+     *
1604
+     * @param array $typeDef our internal representation of an XML schema type (or element)
1605
+     * @param mixed $value a native PHP value (parameter value)
1606
+     * @param string $ns the namespace of the type
1607
+     * @param string $uqType the local part of the type
1608
+     * @return string value serialized as an XML string
1609
+     * @access private
1610
+     */
1611
+    function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) {
1612
+        $this->debug("serializeComplexTypeAttributes for XML Schema type $ns:$uqType");
1613
+        $xml = '';
1614
+        if (isset($typeDef['extensionBase'])) {
1615
+            $nsx = $this->getPrefix($typeDef['extensionBase']);
1616
+            $uqTypex = $this->getLocalPart($typeDef['extensionBase']);
1617
+            if ($this->getNamespaceFromPrefix($nsx)) {
1618
+                $nsx = $this->getNamespaceFromPrefix($nsx);
1619
+            }
1620
+            if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
1621
+                $this->debug("serialize attributes for extension base $nsx:$uqTypex");
1622
+                $xml .= $this->serializeComplexTypeAttributes($typeDefx, $value, $nsx, $uqTypex);
1623
+            } else {
1624
+                $this->debug("extension base $nsx:$uqTypex is not a supported type");
1625
+            }
1626
+        }
1627
+        if (isset($typeDef['attrs']) && is_array($typeDef['attrs'])) {
1628
+            $this->debug("serialize attributes for XML Schema type $ns:$uqType");
1629
+            if (is_array($value)) {
1630
+                $xvalue = $value;
1631
+            } elseif (is_object($value)) {
1632
+                $xvalue = get_object_vars($value);
1633
+            } else {
1634
+                $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
1635
+                $xvalue = array();
1636
+            }
1637
+            foreach ($typeDef['attrs'] as $aName => $attrs) {
1638
+                if (isset($xvalue['!' . $aName])) {
1639
+                    $xname = '!' . $aName;
1640
+                    $this->debug("value provided for attribute $aName with key $xname");
1641
+                } elseif (isset($xvalue[$aName])) {
1642
+                    $xname = $aName;
1643
+                    $this->debug("value provided for attribute $aName with key $xname");
1644
+                } elseif (isset($attrs['default'])) {
1645
+                    $xname = '!' . $aName;
1646
+                    $xvalue[$xname] = $attrs['default'];
1647
+                    $this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
1648
+                } else {
1649
+                    $xname = '';
1650
+                    $this->debug("no value provided for attribute $aName");
1651
+                }
1652
+                if ($xname) {
1653
+                    $xml .=  " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\"";
1654
+                }
1655
+            }
1656
+        } else {
1657
+            $this->debug("no attributes to serialize for XML Schema type $ns:$uqType");
1658
+        }
1659
+        return $xml;
1660
+    }
1661 1661
 
1662
-	/**
1663
-	 * serializes the elements for a complexType
1664
-	 *
1665
-	 * @param array $typeDef our internal representation of an XML schema type (or element)
1666
-	 * @param mixed $value a native PHP value (parameter value)
1667
-	 * @param string $ns the namespace of the type
1668
-	 * @param string $uqType the local part of the type
1669
-	 * @param string $use use for part (encoded|literal)
1670
-	 * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
1671
-	 * @return string value serialized as an XML string
1672
-	 * @access private
1673
-	 */
1674
-	function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false) {
1675
-		$this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType");
1676
-		$xml = '';
1677
-		if (isset($typeDef['extensionBase'])) {
1678
-			$nsx = $this->getPrefix($typeDef['extensionBase']);
1679
-			$uqTypex = $this->getLocalPart($typeDef['extensionBase']);
1680
-			if ($this->getNamespaceFromPrefix($nsx)) {
1681
-				$nsx = $this->getNamespaceFromPrefix($nsx);
1682
-			}
1683
-			if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
1684
-				$this->debug("serialize elements for extension base $nsx:$uqTypex");
1685
-				$xml .= $this->serializeComplexTypeElements($typeDefx, $value, $nsx, $uqTypex, $use, $encodingStyle);
1686
-			} else {
1687
-				$this->debug("extension base $nsx:$uqTypex is not a supported type");
1688
-			}
1689
-		}
1690
-		if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
1691
-			$this->debug("in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType");
1692
-			if (is_array($value)) {
1693
-				$xvalue = $value;
1694
-			} elseif (is_object($value)) {
1695
-				$xvalue = get_object_vars($value);
1696
-			} else {
1697
-				$this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
1698
-				$xvalue = array();
1699
-			}
1700
-			// toggle whether all elements are present - ideally should validate against schema
1701
-			if (count($typeDef['elements']) != count($xvalue)){
1702
-				$optionals = true;
1703
-			}
1704
-			foreach ($typeDef['elements'] as $eName => $attrs) {
1705
-				if (!isset($xvalue[$eName])) {
1706
-					if (isset($attrs['default'])) {
1707
-						$xvalue[$eName] = $attrs['default'];
1708
-						$this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
1709
-					}
1710
-				}
1711
-				// if user took advantage of a minOccurs=0, then only serialize named parameters
1712
-				if (isset($optionals)
1713
-				    && (!isset($xvalue[$eName]))
1714
-					&& ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true')
1715
-					){
1716
-					if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
1717
-						$this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']);
1718
-					}
1719
-					// do nothing
1720
-					$this->debug("no value provided for complexType element $eName and element is not nillable, so serialize nothing");
1721
-				} else {
1722
-					// get value
1723
-					if (isset($xvalue[$eName])) {
1724
-					    $v = $xvalue[$eName];
1725
-					} else {
1726
-					    $v = null;
1727
-					}
1728
-					if (isset($attrs['form'])) {
1729
-						$unqualified = ($attrs['form'] == 'unqualified');
1730
-					} else {
1731
-						$unqualified = false;
1732
-					}
1733
-					if (isset($attrs['maxOccurs']) && ($attrs['maxOccurs'] == 'unbounded' || $attrs['maxOccurs'] > 1) && isset($v) && is_array($v) && $this->isArraySimpleOrStruct($v) == 'arraySimple') {
1734
-						$vv = $v;
1735
-						foreach ($vv as $k => $v) {
1736
-							if (isset($attrs['type']) || isset($attrs['ref'])) {
1737
-								// serialize schema-defined type
1738
-							    $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1739
-							} else {
1740
-								// serialize generic type (can this ever really happen?)
1741
-							    $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
1742
-							    $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
1743
-							}
1744
-						}
1745
-					} else {
1746
-						if (is_null($v) && isset($attrs['minOccurs']) && $attrs['minOccurs'] == '0') {
1747
-							// do nothing
1748
-						} elseif (is_null($v) && isset($attrs['nillable']) && $attrs['nillable'] == 'true') {
1749
-							// TODO: serialize a nil correctly, but for now serialize schema-defined type
1750
-						    $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1751
-						} elseif (isset($attrs['type']) || isset($attrs['ref'])) {
1752
-							// serialize schema-defined type
1753
-						    $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1754
-						} else {
1755
-							// serialize generic type (can this ever really happen?)
1756
-						    $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
1757
-						    $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
1758
-						}
1759
-					}
1760
-				}
1761
-			}
1762
-		} else {
1763
-			$this->debug("no elements to serialize for XML Schema type $ns:$uqType");
1764
-		}
1765
-		return $xml;
1766
-	}
1662
+    /**
1663
+     * serializes the elements for a complexType
1664
+     *
1665
+     * @param array $typeDef our internal representation of an XML schema type (or element)
1666
+     * @param mixed $value a native PHP value (parameter value)
1667
+     * @param string $ns the namespace of the type
1668
+     * @param string $uqType the local part of the type
1669
+     * @param string $use use for part (encoded|literal)
1670
+     * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
1671
+     * @return string value serialized as an XML string
1672
+     * @access private
1673
+     */
1674
+    function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false) {
1675
+        $this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType");
1676
+        $xml = '';
1677
+        if (isset($typeDef['extensionBase'])) {
1678
+            $nsx = $this->getPrefix($typeDef['extensionBase']);
1679
+            $uqTypex = $this->getLocalPart($typeDef['extensionBase']);
1680
+            if ($this->getNamespaceFromPrefix($nsx)) {
1681
+                $nsx = $this->getNamespaceFromPrefix($nsx);
1682
+            }
1683
+            if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
1684
+                $this->debug("serialize elements for extension base $nsx:$uqTypex");
1685
+                $xml .= $this->serializeComplexTypeElements($typeDefx, $value, $nsx, $uqTypex, $use, $encodingStyle);
1686
+            } else {
1687
+                $this->debug("extension base $nsx:$uqTypex is not a supported type");
1688
+            }
1689
+        }
1690
+        if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
1691
+            $this->debug("in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType");
1692
+            if (is_array($value)) {
1693
+                $xvalue = $value;
1694
+            } elseif (is_object($value)) {
1695
+                $xvalue = get_object_vars($value);
1696
+            } else {
1697
+                $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
1698
+                $xvalue = array();
1699
+            }
1700
+            // toggle whether all elements are present - ideally should validate against schema
1701
+            if (count($typeDef['elements']) != count($xvalue)){
1702
+                $optionals = true;
1703
+            }
1704
+            foreach ($typeDef['elements'] as $eName => $attrs) {
1705
+                if (!isset($xvalue[$eName])) {
1706
+                    if (isset($attrs['default'])) {
1707
+                        $xvalue[$eName] = $attrs['default'];
1708
+                        $this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
1709
+                    }
1710
+                }
1711
+                // if user took advantage of a minOccurs=0, then only serialize named parameters
1712
+                if (isset($optionals)
1713
+                    && (!isset($xvalue[$eName]))
1714
+                    && ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true')
1715
+                    ){
1716
+                    if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
1717
+                        $this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']);
1718
+                    }
1719
+                    // do nothing
1720
+                    $this->debug("no value provided for complexType element $eName and element is not nillable, so serialize nothing");
1721
+                } else {
1722
+                    // get value
1723
+                    if (isset($xvalue[$eName])) {
1724
+                        $v = $xvalue[$eName];
1725
+                    } else {
1726
+                        $v = null;
1727
+                    }
1728
+                    if (isset($attrs['form'])) {
1729
+                        $unqualified = ($attrs['form'] == 'unqualified');
1730
+                    } else {
1731
+                        $unqualified = false;
1732
+                    }
1733
+                    if (isset($attrs['maxOccurs']) && ($attrs['maxOccurs'] == 'unbounded' || $attrs['maxOccurs'] > 1) && isset($v) && is_array($v) && $this->isArraySimpleOrStruct($v) == 'arraySimple') {
1734
+                        $vv = $v;
1735
+                        foreach ($vv as $k => $v) {
1736
+                            if (isset($attrs['type']) || isset($attrs['ref'])) {
1737
+                                // serialize schema-defined type
1738
+                                $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1739
+                            } else {
1740
+                                // serialize generic type (can this ever really happen?)
1741
+                                $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
1742
+                                $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
1743
+                            }
1744
+                        }
1745
+                    } else {
1746
+                        if (is_null($v) && isset($attrs['minOccurs']) && $attrs['minOccurs'] == '0') {
1747
+                            // do nothing
1748
+                        } elseif (is_null($v) && isset($attrs['nillable']) && $attrs['nillable'] == 'true') {
1749
+                            // TODO: serialize a nil correctly, but for now serialize schema-defined type
1750
+                            $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1751
+                        } elseif (isset($attrs['type']) || isset($attrs['ref'])) {
1752
+                            // serialize schema-defined type
1753
+                            $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1754
+                        } else {
1755
+                            // serialize generic type (can this ever really happen?)
1756
+                            $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
1757
+                            $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
1758
+                        }
1759
+                    }
1760
+                }
1761
+            }
1762
+        } else {
1763
+            $this->debug("no elements to serialize for XML Schema type $ns:$uqType");
1764
+        }
1765
+        return $xml;
1766
+    }
1767 1767
 
1768
-	/**
1769
-	* adds an XML Schema complex type to the WSDL types
1770
-	*
1771
-	* @param string	$name
1772
-	* @param string $typeClass (complexType|simpleType|attribute)
1773
-	* @param string $phpType currently supported are array and struct (php assoc array)
1774
-	* @param string $compositor (all|sequence|choice)
1775
-	* @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
1776
-	* @param array $elements e.g. array ( name => array(name=>'',type=>'') )
1777
-	* @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]'))
1778
-	* @param string $arrayType as namespace:name (xsd:string)
1779
-	* @see nusoap_xmlschema
1780
-	* @access public
1781
-	*/
1782
-	function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType='') {
1783
-		if (count($elements) > 0) {
1784
-			$eElements = array();
1785
-	    	foreach($elements as $n => $e){
1786
-	            // expand each element
1787
-	            $ee = array();
1788
-	            foreach ($e as $k => $v) {
1789
-		            $k = strpos($k,':') ? $this->expandQname($k) : $k;
1790
-		            $v = strpos($v,':') ? $this->expandQname($v) : $v;
1791
-		            $ee[$k] = $v;
1792
-		    	}
1793
-	    		$eElements[$n] = $ee;
1794
-	    	}
1795
-	    	$elements = $eElements;
1796
-		}
1768
+    /**
1769
+     * adds an XML Schema complex type to the WSDL types
1770
+     *
1771
+     * @param string	$name
1772
+     * @param string $typeClass (complexType|simpleType|attribute)
1773
+     * @param string $phpType currently supported are array and struct (php assoc array)
1774
+     * @param string $compositor (all|sequence|choice)
1775
+     * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
1776
+     * @param array $elements e.g. array ( name => array(name=>'',type=>'') )
1777
+     * @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]'))
1778
+     * @param string $arrayType as namespace:name (xsd:string)
1779
+     * @see nusoap_xmlschema
1780
+     * @access public
1781
+     */
1782
+    function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType='') {
1783
+        if (count($elements) > 0) {
1784
+            $eElements = array();
1785
+            foreach($elements as $n => $e){
1786
+                // expand each element
1787
+                $ee = array();
1788
+                foreach ($e as $k => $v) {
1789
+                    $k = strpos($k,':') ? $this->expandQname($k) : $k;
1790
+                    $v = strpos($v,':') ? $this->expandQname($v) : $v;
1791
+                    $ee[$k] = $v;
1792
+                }
1793
+                $eElements[$n] = $ee;
1794
+            }
1795
+            $elements = $eElements;
1796
+        }
1797 1797
 
1798
-		if (count($attrs) > 0) {
1799
-	    	foreach($attrs as $n => $a){
1800
-	            // expand each attribute
1801
-	            foreach ($a as $k => $v) {
1802
-		            $k = strpos($k,':') ? $this->expandQname($k) : $k;
1803
-		            $v = strpos($v,':') ? $this->expandQname($v) : $v;
1804
-		            $aa[$k] = $v;
1805
-		    	}
1806
-	    		$eAttrs[$n] = $aa;
1807
-	    	}
1808
-	    	$attrs = $eAttrs;
1809
-		}
1798
+        if (count($attrs) > 0) {
1799
+            foreach($attrs as $n => $a){
1800
+                // expand each attribute
1801
+                foreach ($a as $k => $v) {
1802
+                    $k = strpos($k,':') ? $this->expandQname($k) : $k;
1803
+                    $v = strpos($v,':') ? $this->expandQname($v) : $v;
1804
+                    $aa[$k] = $v;
1805
+                }
1806
+                $eAttrs[$n] = $aa;
1807
+            }
1808
+            $attrs = $eAttrs;
1809
+        }
1810 1810
 
1811
-		$restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1812
-		$arrayType = strpos($arrayType,':') ? $this->expandQname($arrayType) : $arrayType;
1811
+        $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1812
+        $arrayType = strpos($arrayType,':') ? $this->expandQname($arrayType) : $arrayType;
1813 1813
 
1814
-		$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1815
-		$this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,$elements,$attrs,$arrayType);
1816
-	}
1814
+        $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1815
+        $this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,$elements,$attrs,$arrayType);
1816
+    }
1817 1817
 
1818
-	/**
1819
-	* adds an XML Schema simple type to the WSDL types
1820
-	*
1821
-	* @param string $name
1822
-	* @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
1823
-	* @param string $typeClass (should always be simpleType)
1824
-	* @param string $phpType (should always be scalar)
1825
-	* @param array $enumeration array of values
1826
-	* @see nusoap_xmlschema
1827
-	* @access public
1828
-	*/
1829
-	function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
1830
-		$restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1818
+    /**
1819
+     * adds an XML Schema simple type to the WSDL types
1820
+     *
1821
+     * @param string $name
1822
+     * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
1823
+     * @param string $typeClass (should always be simpleType)
1824
+     * @param string $phpType (should always be scalar)
1825
+     * @param array $enumeration array of values
1826
+     * @see nusoap_xmlschema
1827
+     * @access public
1828
+     */
1829
+    function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
1830
+        $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1831 1831
 
1832
-		$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1833
-		$this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration);
1834
-	}
1832
+        $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1833
+        $this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration);
1834
+    }
1835 1835
 
1836
-	/**
1837
-	* adds an element to the WSDL types
1838
-	*
1839
-	* @param array $attrs attributes that must include name and type
1840
-	* @see nusoap_xmlschema
1841
-	* @access public
1842
-	*/
1843
-	function addElement($attrs) {
1844
-		$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1845
-		$this->schemas[$typens][0]->addElement($attrs);
1846
-	}
1836
+    /**
1837
+     * adds an element to the WSDL types
1838
+     *
1839
+     * @param array $attrs attributes that must include name and type
1840
+     * @see nusoap_xmlschema
1841
+     * @access public
1842
+     */
1843
+    function addElement($attrs) {
1844
+        $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1845
+        $this->schemas[$typens][0]->addElement($attrs);
1846
+    }
1847 1847
 
1848
-	/**
1849
-	* register an operation with the server
1850
-	*
1851
-	* @param string $name operation (method) name
1852
-	* @param array $in assoc array of input values: key = param name, value = param type
1853
-	* @param array $out assoc array of output values: key = param name, value = param type
1854
-	* @param string $namespace optional The namespace for the operation
1855
-	* @param string $soapaction optional The soapaction for the operation
1856
-	* @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically
1857
-	* @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now)
1858
-	* @param string $documentation optional The description to include in the WSDL
1859
-	* @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
1860
-	* @access public
1861
-	*/
1862
-	function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){
1863
-		if ($use == 'encoded' && $encodingStyle == '') {
1864
-			$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1865
-		}
1848
+    /**
1849
+     * register an operation with the server
1850
+     *
1851
+     * @param string $name operation (method) name
1852
+     * @param array $in assoc array of input values: key = param name, value = param type
1853
+     * @param array $out assoc array of output values: key = param name, value = param type
1854
+     * @param string $namespace optional The namespace for the operation
1855
+     * @param string $soapaction optional The soapaction for the operation
1856
+     * @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically
1857
+     * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now)
1858
+     * @param string $documentation optional The description to include in the WSDL
1859
+     * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
1860
+     * @access public
1861
+     */
1862
+    function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){
1863
+        if ($use == 'encoded' && $encodingStyle == '') {
1864
+            $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1865
+        }
1866 1866
 
1867
-		if ($style == 'document') {
1868
-			$elements = array();
1869
-			foreach ($in as $n => $t) {
1870
-				$elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1871
-			}
1872
-			$this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements);
1873
-			$this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
1874
-			$in = array('parameters' => 'tns:' . $name . '^');
1867
+        if ($style == 'document') {
1868
+            $elements = array();
1869
+            foreach ($in as $n => $t) {
1870
+                $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1871
+            }
1872
+            $this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements);
1873
+            $this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
1874
+            $in = array('parameters' => 'tns:' . $name . '^');
1875 1875
 
1876
-			$elements = array();
1877
-			foreach ($out as $n => $t) {
1878
-				$elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1879
-			}
1880
-			$this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements);
1881
-			$this->addElement(array('name' => $name . 'Response', 'type' => $name . 'ResponseType', 'form' => 'qualified'));
1882
-			$out = array('parameters' => 'tns:' . $name . 'Response' . '^');
1883
-		}
1876
+            $elements = array();
1877
+            foreach ($out as $n => $t) {
1878
+                $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1879
+            }
1880
+            $this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements);
1881
+            $this->addElement(array('name' => $name . 'Response', 'type' => $name . 'ResponseType', 'form' => 'qualified'));
1882
+            $out = array('parameters' => 'tns:' . $name . 'Response' . '^');
1883
+        }
1884 1884
 
1885
-		// get binding
1886
-		$this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] =
1887
-		array(
1888
-		'name' => $name,
1889
-		'binding' => $this->serviceName . 'Binding',
1890
-		'endpoint' => $this->endpoint,
1891
-		'soapAction' => $soapaction,
1892
-		'style' => $style,
1893
-		'input' => array(
1894
-			'use' => $use,
1895
-			'namespace' => $namespace,
1896
-			'encodingStyle' => $encodingStyle,
1897
-			'message' => $name . 'Request',
1898
-			'parts' => $in),
1899
-		'output' => array(
1900
-			'use' => $use,
1901
-			'namespace' => $namespace,
1902
-			'encodingStyle' => $encodingStyle,
1903
-			'message' => $name . 'Response',
1904
-			'parts' => $out),
1905
-		'namespace' => $namespace,
1906
-		'transport' => 'http://schemas.xmlsoap.org/soap/http',
1907
-		'documentation' => $documentation);
1908
-		// add portTypes
1909
-		// add messages
1910
-		if($in)
1911
-		{
1912
-			foreach($in as $pName => $pType)
1913
-			{
1914
-				if(strpos($pType,':')) {
1915
-					$pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1916
-				}
1917
-				$this->messages[$name.'Request'][$pName] = $pType;
1918
-			}
1919
-		} else {
1885
+        // get binding
1886
+        $this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] =
1887
+        array(
1888
+        'name' => $name,
1889
+        'binding' => $this->serviceName . 'Binding',
1890
+        'endpoint' => $this->endpoint,
1891
+        'soapAction' => $soapaction,
1892
+        'style' => $style,
1893
+        'input' => array(
1894
+            'use' => $use,
1895
+            'namespace' => $namespace,
1896
+            'encodingStyle' => $encodingStyle,
1897
+            'message' => $name . 'Request',
1898
+            'parts' => $in),
1899
+        'output' => array(
1900
+            'use' => $use,
1901
+            'namespace' => $namespace,
1902
+            'encodingStyle' => $encodingStyle,
1903
+            'message' => $name . 'Response',
1904
+            'parts' => $out),
1905
+        'namespace' => $namespace,
1906
+        'transport' => 'http://schemas.xmlsoap.org/soap/http',
1907
+        'documentation' => $documentation);
1908
+        // add portTypes
1909
+        // add messages
1910
+        if($in)
1911
+        {
1912
+            foreach($in as $pName => $pType)
1913
+            {
1914
+                if(strpos($pType,':')) {
1915
+                    $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1916
+                }
1917
+                $this->messages[$name.'Request'][$pName] = $pType;
1918
+            }
1919
+        } else {
1920 1920
             $this->messages[$name.'Request']= '0';
1921 1921
         }
1922
-		if($out)
1923
-		{
1924
-			foreach($out as $pName => $pType)
1925
-			{
1926
-				if(strpos($pType,':')) {
1927
-					$pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1928
-				}
1929
-				$this->messages[$name.'Response'][$pName] = $pType;
1930
-			}
1931
-		} else {
1922
+        if($out)
1923
+        {
1924
+            foreach($out as $pName => $pType)
1925
+            {
1926
+                if(strpos($pType,':')) {
1927
+                    $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1928
+                }
1929
+                $this->messages[$name.'Response'][$pName] = $pType;
1930
+            }
1931
+        } else {
1932 1932
             $this->messages[$name.'Response']= '0';
1933 1933
         }
1934
-		return true;
1935
-	}
1934
+        return true;
1935
+    }
1936 1936
 }
1937 1937
 
1938 1938
 ?>
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.nusoap_base.php 1 patch
Indentation   +846 added lines, -846 removed lines patch added patch discarded remove patch
@@ -83,810 +83,810 @@  discard block
 block discarded – undo
83 83
 * @access   public
84 84
 */
85 85
 class nusoap_base {
86
-	/**
87
-	 * Identification for HTTP headers.
88
-	 *
89
-	 * @var string
90
-	 * @access private
91
-	 */
92
-	var $title = 'NuSOAP';
93
-	/**
94
-	 * Version for HTTP headers.
95
-	 *
96
-	 * @var string
97
-	 * @access private
98
-	 */
99
-	var $version = '0.9.5';
100
-	/**
101
-	 * CVS revision for HTTP headers.
102
-	 *
103
-	 * @var string
104
-	 * @access private
105
-	 */
106
-	var $revision = '$Revision: 1.56 $';
86
+    /**
87
+     * Identification for HTTP headers.
88
+     *
89
+     * @var string
90
+     * @access private
91
+     */
92
+    var $title = 'NuSOAP';
93
+    /**
94
+     * Version for HTTP headers.
95
+     *
96
+     * @var string
97
+     * @access private
98
+     */
99
+    var $version = '0.9.5';
100
+    /**
101
+     * CVS revision for HTTP headers.
102
+     *
103
+     * @var string
104
+     * @access private
105
+     */
106
+    var $revision = '$Revision: 1.56 $';
107 107
     /**
108 108
      * Current error string (manipulated by getError/setError)
109
-	 *
110
-	 * @var string
111
-	 * @access private
112
-	 */
113
-	var $error_str = '';
109
+     *
110
+     * @var string
111
+     * @access private
112
+     */
113
+    var $error_str = '';
114 114
     /**
115 115
      * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment)
116
-	 *
117
-	 * @var string
118
-	 * @access private
119
-	 */
116
+     *
117
+     * @var string
118
+     * @access private
119
+     */
120 120
     var $debug_str = '';
121 121
     /**
122
-	 * toggles automatic encoding of special characters as entities
123
-	 * (should always be true, I think)
124
-	 *
125
-	 * @var boolean
126
-	 * @access private
127
-	 */
128
-	var $charencoding = true;
129
-	/**
130
-	 * the debug level for this instance
131
-	 *
132
-	 * @var	integer
133
-	 * @access private
134
-	 */
135
-	var $debugLevel;
136
-
137
-    /**
138
-	* set schema version
139
-	*
140
-	* @var      string
141
-	* @access   public
142
-	*/
143
-	var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema';
144
-
145
-    /**
146
-	* charset encoding for outgoing messages
147
-	*
148
-	* @var      string
149
-	* @access   public
150
-	*/
122
+     * toggles automatic encoding of special characters as entities
123
+     * (should always be true, I think)
124
+     *
125
+     * @var boolean
126
+     * @access private
127
+     */
128
+    var $charencoding = true;
129
+    /**
130
+     * the debug level for this instance
131
+     *
132
+     * @var	integer
133
+     * @access private
134
+     */
135
+    var $debugLevel;
136
+
137
+    /**
138
+     * set schema version
139
+     *
140
+     * @var      string
141
+     * @access   public
142
+     */
143
+    var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema';
144
+
145
+    /**
146
+     * charset encoding for outgoing messages
147
+     *
148
+     * @var      string
149
+     * @access   public
150
+     */
151 151
     var $soap_defencoding = 'ISO-8859-1';
152
-	//var $soap_defencoding = 'UTF-8';
153
-
154
-	/**
155
-	* namespaces in an array of prefix => uri
156
-	*
157
-	* this is "seeded" by a set of constants, but it may be altered by code
158
-	*
159
-	* @var      array
160
-	* @access   public
161
-	*/
162
-	var $namespaces = array(
163
-		'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
164
-		'xsd' => 'http://www.w3.org/2001/XMLSchema',
165
-		'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
166
-		'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/'
167
-		);
168
-
169
-	/**
170
-	* namespaces used in the current context, e.g. during serialization
171
-	*
172
-	* @var      array
173
-	* @access   private
174
-	*/
175
-	var $usedNamespaces = array();
176
-
177
-	/**
178
-	* XML Schema types in an array of uri => (array of xml type => php type)
179
-	* is this legacy yet?
180
-	* no, this is used by the nusoap_xmlschema class to verify type => namespace mappings.
181
-	* @var      array
182
-	* @access   public
183
-	*/
184
-	var $typemap = array(
185
-	'http://www.w3.org/2001/XMLSchema' => array(
186
-		'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double',
187
-		'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'',
188
-		'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string',
189
-		// abstract "any" types
190
-		'anyType'=>'string','anySimpleType'=>'string',
191
-		// derived datatypes
192
-		'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'',
193
-		'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer',
194
-		'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer',
195
-		'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''),
196
-	'http://www.w3.org/2000/10/XMLSchema' => array(
197
-		'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
198
-		'float'=>'double','dateTime'=>'string',
199
-		'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
200
-	'http://www.w3.org/1999/XMLSchema' => array(
201
-		'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
202
-		'float'=>'double','dateTime'=>'string',
203
-		'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
204
-	'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'),
205
-	'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'),
152
+    //var $soap_defencoding = 'UTF-8';
153
+
154
+    /**
155
+     * namespaces in an array of prefix => uri
156
+     *
157
+     * this is "seeded" by a set of constants, but it may be altered by code
158
+     *
159
+     * @var      array
160
+     * @access   public
161
+     */
162
+    var $namespaces = array(
163
+        'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
164
+        'xsd' => 'http://www.w3.org/2001/XMLSchema',
165
+        'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
166
+        'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/'
167
+        );
168
+
169
+    /**
170
+     * namespaces used in the current context, e.g. during serialization
171
+     *
172
+     * @var      array
173
+     * @access   private
174
+     */
175
+    var $usedNamespaces = array();
176
+
177
+    /**
178
+     * XML Schema types in an array of uri => (array of xml type => php type)
179
+     * is this legacy yet?
180
+     * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings.
181
+     * @var      array
182
+     * @access   public
183
+     */
184
+    var $typemap = array(
185
+    'http://www.w3.org/2001/XMLSchema' => array(
186
+        'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double',
187
+        'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'',
188
+        'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string',
189
+        // abstract "any" types
190
+        'anyType'=>'string','anySimpleType'=>'string',
191
+        // derived datatypes
192
+        'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'',
193
+        'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer',
194
+        'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer',
195
+        'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''),
196
+    'http://www.w3.org/2000/10/XMLSchema' => array(
197
+        'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
198
+        'float'=>'double','dateTime'=>'string',
199
+        'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
200
+    'http://www.w3.org/1999/XMLSchema' => array(
201
+        'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
202
+        'float'=>'double','dateTime'=>'string',
203
+        'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
204
+    'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'),
205
+    'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'),
206 206
     'http://xml.apache.org/xml-soap' => array('Map')
207
-	);
208
-
209
-	/**
210
-	* XML entities to convert
211
-	*
212
-	* @var      array
213
-	* @access   public
214
-	* @deprecated
215
-	* @see	expandEntities
216
-	*/
217
-	var $xmlEntities = array('quot' => '"','amp' => '&',
218
-		'lt' => '<','gt' => '>','apos' => "'");
219
-
220
-	/**
221
-	* constructor
222
-	*
223
-	* @access	public
224
-	*/
225
-	function nusoap_base() {
226
-		$this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
227
-	}
228
-
229
-	/**
230
-	* gets the global debug level, which applies to future instances
231
-	*
232
-	* @return	integer	Debug level 0-9, where 0 turns off
233
-	* @access	public
234
-	*/
235
-	function getGlobalDebugLevel() {
236
-		return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
237
-	}
238
-
239
-	/**
240
-	* sets the global debug level, which applies to future instances
241
-	*
242
-	* @param	int	$level	Debug level 0-9, where 0 turns off
243
-	* @access	public
244
-	*/
245
-	function setGlobalDebugLevel($level) {
246
-		$GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level;
247
-	}
248
-
249
-	/**
250
-	* gets the debug level for this instance
251
-	*
252
-	* @return	int	Debug level 0-9, where 0 turns off
253
-	* @access	public
254
-	*/
255
-	function getDebugLevel() {
256
-		return $this->debugLevel;
257
-	}
258
-
259
-	/**
260
-	* sets the debug level for this instance
261
-	*
262
-	* @param	int	$level	Debug level 0-9, where 0 turns off
263
-	* @access	public
264
-	*/
265
-	function setDebugLevel($level) {
266
-		$this->debugLevel = $level;
267
-	}
268
-
269
-	/**
270
-	* adds debug data to the instance debug string with formatting
271
-	*
272
-	* @param    string $string debug data
273
-	* @access   private
274
-	*/
275
-	function debug($string){
276
-		if ($this->debugLevel > 0) {
277
-			$this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n");
278
-		}
279
-	}
280
-
281
-	/**
282
-	* adds debug data to the instance debug string without formatting
283
-	*
284
-	* @param    string $string debug data
285
-	* @access   public
286
-	*/
287
-	function appendDebug($string){
288
-		if ($this->debugLevel > 0) {
289
-			// it would be nice to use a memory stream here to use
290
-			// memory more efficiently
291
-			$this->debug_str .= $string;
292
-		}
293
-	}
294
-
295
-	/**
296
-	* clears the current debug data for this instance
297
-	*
298
-	* @access   public
299
-	*/
300
-	function clearDebug() {
301
-		// it would be nice to use a memory stream here to use
302
-		// memory more efficiently
303
-		$this->debug_str = '';
304
-	}
305
-
306
-	/**
307
-	* gets the current debug data for this instance
308
-	*
309
-	* @return   debug data
310
-	* @access   public
311
-	*/
312
-	function &getDebug() {
313
-		// it would be nice to use a memory stream here to use
314
-		// memory more efficiently
315
-		return $this->debug_str;
316
-	}
317
-
318
-	/**
319
-	* gets the current debug data for this instance as an XML comment
320
-	* this may change the contents of the debug data
321
-	*
322
-	* @return   debug data as an XML comment
323
-	* @access   public
324
-	*/
325
-	function &getDebugAsXMLComment() {
326
-		// it would be nice to use a memory stream here to use
327
-		// memory more efficiently
328
-		while (strpos($this->debug_str, '--')) {
329
-			$this->debug_str = str_replace('--', '- -', $this->debug_str);
330
-		}
331
-		$ret = "<!--\n" . $this->debug_str . "\n-->";
332
-    	return $ret;
333
-	}
334
-
335
-	/**
336
-	* expands entities, e.g. changes '<' to '&lt;'.
337
-	*
338
-	* @param	string	$val	The string in which to expand entities.
339
-	* @access	private
340
-	*/
341
-	function expandEntities($val) {
342
-		if ($this->charencoding) {
343
-	    	$val = str_replace('&', '&amp;', $val);
344
-	    	$val = str_replace("'", '&apos;', $val);
345
-	    	$val = str_replace('"', '&quot;', $val);
346
-	    	$val = str_replace('<', '&lt;', $val);
347
-	    	$val = str_replace('>', '&gt;', $val);
348
-	    }
349
-	    return $val;
350
-	}
351
-
352
-	/**
353
-	* returns error string if present
354
-	*
355
-	* @return   mixed error string or false
356
-	* @access   public
357
-	*/
358
-	function getError(){
359
-		if($this->error_str != ''){
360
-			return $this->error_str;
361
-		}
362
-		return false;
363
-	}
364
-
365
-	/**
366
-	* sets error string
367
-	*
368
-	* @return   boolean $string error string
369
-	* @access   private
370
-	*/
371
-	function setError($str){
372
-		$this->error_str = $str;
373
-	}
374
-
375
-	/**
376
-	* detect if array is a simple array or a struct (associative array)
377
-	*
378
-	* @param	mixed	$val	The PHP array
379
-	* @return	string	(arraySimple|arrayStruct)
380
-	* @access	private
381
-	*/
382
-	function isArraySimpleOrStruct($val) {
207
+    );
208
+
209
+    /**
210
+     * XML entities to convert
211
+     *
212
+     * @var      array
213
+     * @access   public
214
+     * @deprecated
215
+     * @see	expandEntities
216
+     */
217
+    var $xmlEntities = array('quot' => '"','amp' => '&',
218
+        'lt' => '<','gt' => '>','apos' => "'");
219
+
220
+    /**
221
+     * constructor
222
+     *
223
+     * @access	public
224
+     */
225
+    function nusoap_base() {
226
+        $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
227
+    }
228
+
229
+    /**
230
+     * gets the global debug level, which applies to future instances
231
+     *
232
+     * @return	integer	Debug level 0-9, where 0 turns off
233
+     * @access	public
234
+     */
235
+    function getGlobalDebugLevel() {
236
+        return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
237
+    }
238
+
239
+    /**
240
+     * sets the global debug level, which applies to future instances
241
+     *
242
+     * @param	int	$level	Debug level 0-9, where 0 turns off
243
+     * @access	public
244
+     */
245
+    function setGlobalDebugLevel($level) {
246
+        $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level;
247
+    }
248
+
249
+    /**
250
+     * gets the debug level for this instance
251
+     *
252
+     * @return	int	Debug level 0-9, where 0 turns off
253
+     * @access	public
254
+     */
255
+    function getDebugLevel() {
256
+        return $this->debugLevel;
257
+    }
258
+
259
+    /**
260
+     * sets the debug level for this instance
261
+     *
262
+     * @param	int	$level	Debug level 0-9, where 0 turns off
263
+     * @access	public
264
+     */
265
+    function setDebugLevel($level) {
266
+        $this->debugLevel = $level;
267
+    }
268
+
269
+    /**
270
+     * adds debug data to the instance debug string with formatting
271
+     *
272
+     * @param    string $string debug data
273
+     * @access   private
274
+     */
275
+    function debug($string){
276
+        if ($this->debugLevel > 0) {
277
+            $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n");
278
+        }
279
+    }
280
+
281
+    /**
282
+     * adds debug data to the instance debug string without formatting
283
+     *
284
+     * @param    string $string debug data
285
+     * @access   public
286
+     */
287
+    function appendDebug($string){
288
+        if ($this->debugLevel > 0) {
289
+            // it would be nice to use a memory stream here to use
290
+            // memory more efficiently
291
+            $this->debug_str .= $string;
292
+        }
293
+    }
294
+
295
+    /**
296
+     * clears the current debug data for this instance
297
+     *
298
+     * @access   public
299
+     */
300
+    function clearDebug() {
301
+        // it would be nice to use a memory stream here to use
302
+        // memory more efficiently
303
+        $this->debug_str = '';
304
+    }
305
+
306
+    /**
307
+     * gets the current debug data for this instance
308
+     *
309
+     * @return   debug data
310
+     * @access   public
311
+     */
312
+    function &getDebug() {
313
+        // it would be nice to use a memory stream here to use
314
+        // memory more efficiently
315
+        return $this->debug_str;
316
+    }
317
+
318
+    /**
319
+     * gets the current debug data for this instance as an XML comment
320
+     * this may change the contents of the debug data
321
+     *
322
+     * @return   debug data as an XML comment
323
+     * @access   public
324
+     */
325
+    function &getDebugAsXMLComment() {
326
+        // it would be nice to use a memory stream here to use
327
+        // memory more efficiently
328
+        while (strpos($this->debug_str, '--')) {
329
+            $this->debug_str = str_replace('--', '- -', $this->debug_str);
330
+        }
331
+        $ret = "<!--\n" . $this->debug_str . "\n-->";
332
+        return $ret;
333
+    }
334
+
335
+    /**
336
+     * expands entities, e.g. changes '<' to '&lt;'.
337
+     *
338
+     * @param	string	$val	The string in which to expand entities.
339
+     * @access	private
340
+     */
341
+    function expandEntities($val) {
342
+        if ($this->charencoding) {
343
+            $val = str_replace('&', '&amp;', $val);
344
+            $val = str_replace("'", '&apos;', $val);
345
+            $val = str_replace('"', '&quot;', $val);
346
+            $val = str_replace('<', '&lt;', $val);
347
+            $val = str_replace('>', '&gt;', $val);
348
+        }
349
+        return $val;
350
+    }
351
+
352
+    /**
353
+     * returns error string if present
354
+     *
355
+     * @return   mixed error string or false
356
+     * @access   public
357
+     */
358
+    function getError(){
359
+        if($this->error_str != ''){
360
+            return $this->error_str;
361
+        }
362
+        return false;
363
+    }
364
+
365
+    /**
366
+     * sets error string
367
+     *
368
+     * @return   boolean $string error string
369
+     * @access   private
370
+     */
371
+    function setError($str){
372
+        $this->error_str = $str;
373
+    }
374
+
375
+    /**
376
+     * detect if array is a simple array or a struct (associative array)
377
+     *
378
+     * @param	mixed	$val	The PHP array
379
+     * @return	string	(arraySimple|arrayStruct)
380
+     * @access	private
381
+     */
382
+    function isArraySimpleOrStruct($val) {
383 383
         $keyList = array_keys($val);
384
-		foreach ($keyList as $keyListValue) {
385
-			if (!is_int($keyListValue)) {
386
-				return 'arrayStruct';
387
-			}
388
-		}
389
-		return 'arraySimple';
390
-	}
391
-
392
-	/**
393
-	* serializes PHP values in accordance w/ section 5. Type information is
394
-	* not serialized if $use == 'literal'.
395
-	*
396
-	* @param	mixed	$val	The value to serialize
397
-	* @param	string	$name	The name (local part) of the XML element
398
-	* @param	string	$type	The XML schema type (local part) for the element
399
-	* @param	string	$name_ns	The namespace for the name of the XML element
400
-	* @param	string	$type_ns	The namespace for the type of the element
401
-	* @param	array	$attributes	The attributes to serialize as name=>value pairs
402
-	* @param	string	$use	The WSDL "use" (encoded|literal)
403
-	* @param	boolean	$soapval	Whether this is called from soapval.
404
-	* @return	string	The serialized element, possibly with child elements
405
-    * @access	public
406
-	*/
407
-	function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) {
408
-		$this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
409
-		$this->appendDebug('value=' . $this->varDump($val));
410
-		$this->appendDebug('attributes=' . $this->varDump($attributes));
411
-
412
-    	if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) {
413
-    		$this->debug("serialize_val: serialize soapval");
414
-        	$xml = $val->serialize($use);
415
-			$this->appendDebug($val->getDebug());
416
-			$val->clearDebug();
417
-			$this->debug("serialize_val of soapval returning $xml");
418
-			return $xml;
384
+        foreach ($keyList as $keyListValue) {
385
+            if (!is_int($keyListValue)) {
386
+                return 'arrayStruct';
387
+            }
419 388
         }
420
-		// force valid name if necessary
421
-		if (is_numeric($name)) {
422
-			$name = '__numeric_' . $name;
423
-		} elseif (! $name) {
424
-			$name = 'noname';
425
-		}
426
-		// if name has ns, add ns prefix to name
427
-		$xmlns = '';
389
+        return 'arraySimple';
390
+    }
391
+
392
+    /**
393
+     * serializes PHP values in accordance w/ section 5. Type information is
394
+     * not serialized if $use == 'literal'.
395
+     *
396
+     * @param	mixed	$val	The value to serialize
397
+     * @param	string	$name	The name (local part) of the XML element
398
+     * @param	string	$type	The XML schema type (local part) for the element
399
+     * @param	string	$name_ns	The namespace for the name of the XML element
400
+     * @param	string	$type_ns	The namespace for the type of the element
401
+     * @param	array	$attributes	The attributes to serialize as name=>value pairs
402
+     * @param	string	$use	The WSDL "use" (encoded|literal)
403
+     * @param	boolean	$soapval	Whether this is called from soapval.
404
+     * @return	string	The serialized element, possibly with child elements
405
+     * @access	public
406
+     */
407
+    function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) {
408
+        $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
409
+        $this->appendDebug('value=' . $this->varDump($val));
410
+        $this->appendDebug('attributes=' . $this->varDump($attributes));
411
+
412
+        if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) {
413
+            $this->debug("serialize_val: serialize soapval");
414
+            $xml = $val->serialize($use);
415
+            $this->appendDebug($val->getDebug());
416
+            $val->clearDebug();
417
+            $this->debug("serialize_val of soapval returning $xml");
418
+            return $xml;
419
+        }
420
+        // force valid name if necessary
421
+        if (is_numeric($name)) {
422
+            $name = '__numeric_' . $name;
423
+        } elseif (! $name) {
424
+            $name = 'noname';
425
+        }
426
+        // if name has ns, add ns prefix to name
427
+        $xmlns = '';
428 428
         if($name_ns){
429
-			$prefix = 'nu'.rand(1000,9999);
430
-			$name = $prefix.':'.$name;
431
-			$xmlns .= " xmlns:$prefix=\"$name_ns\"";
432
-		}
433
-		// if type is prefixed, create type prefix
434
-		if($type_ns != '' && $type_ns == $this->namespaces['xsd']){
435
-			// need to fix this. shouldn't default to xsd if no ns specified
436
-		    // w/o checking against typemap
437
-			$type_prefix = 'xsd';
438
-		} elseif($type_ns){
439
-			$type_prefix = 'ns'.rand(1000,9999);
440
-			$xmlns .= " xmlns:$type_prefix=\"$type_ns\"";
441
-		}
442
-		// serialize attributes if present
443
-		$atts = '';
444
-		if($attributes){
445
-			foreach($attributes as $k => $v){
446
-				$atts .= " $k=\"".$this->expandEntities($v).'"';
447
-			}
448
-		}
449
-		// serialize null value
450
-		if (is_null($val)) {
451
-    		$this->debug("serialize_val: serialize null");
452
-			if ($use == 'literal') {
453
-				// TODO: depends on minOccurs
454
-				$xml = "<$name$xmlns$atts/>";
455
-				$this->debug("serialize_val returning $xml");
456
-	        	return $xml;
457
-        	} else {
458
-				if (isset($type) && isset($type_prefix)) {
459
-					$type_str = " xsi:type=\"$type_prefix:$type\"";
460
-				} else {
461
-					$type_str = '';
462
-				}
463
-				$xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>";
464
-				$this->debug("serialize_val returning $xml");
465
-	        	return $xml;
466
-        	}
467
-		}
429
+            $prefix = 'nu'.rand(1000,9999);
430
+            $name = $prefix.':'.$name;
431
+            $xmlns .= " xmlns:$prefix=\"$name_ns\"";
432
+        }
433
+        // if type is prefixed, create type prefix
434
+        if($type_ns != '' && $type_ns == $this->namespaces['xsd']){
435
+            // need to fix this. shouldn't default to xsd if no ns specified
436
+            // w/o checking against typemap
437
+            $type_prefix = 'xsd';
438
+        } elseif($type_ns){
439
+            $type_prefix = 'ns'.rand(1000,9999);
440
+            $xmlns .= " xmlns:$type_prefix=\"$type_ns\"";
441
+        }
442
+        // serialize attributes if present
443
+        $atts = '';
444
+        if($attributes){
445
+            foreach($attributes as $k => $v){
446
+                $atts .= " $k=\"".$this->expandEntities($v).'"';
447
+            }
448
+        }
449
+        // serialize null value
450
+        if (is_null($val)) {
451
+            $this->debug("serialize_val: serialize null");
452
+            if ($use == 'literal') {
453
+                // TODO: depends on minOccurs
454
+                $xml = "<$name$xmlns$atts/>";
455
+                $this->debug("serialize_val returning $xml");
456
+                return $xml;
457
+            } else {
458
+                if (isset($type) && isset($type_prefix)) {
459
+                    $type_str = " xsi:type=\"$type_prefix:$type\"";
460
+                } else {
461
+                    $type_str = '';
462
+                }
463
+                $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>";
464
+                $this->debug("serialize_val returning $xml");
465
+                return $xml;
466
+            }
467
+        }
468 468
         // serialize if an xsd built-in primitive type
469 469
         if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){
470
-    		$this->debug("serialize_val: serialize xsd built-in primitive type");
471
-        	if (is_bool($val)) {
472
-        		if ($type == 'boolean') {
473
-	        		$val = $val ? 'true' : 'false';
474
-	        	} elseif (! $val) {
475
-	        		$val = 0;
476
-	        	}
477
-			} else if (is_string($val)) {
478
-				$val = $this->expandEntities($val);
479
-			}
480
-			if ($use == 'literal') {
481
-				$xml = "<$name$xmlns$atts>$val</$name>";
482
-				$this->debug("serialize_val returning $xml");
483
-	        	return $xml;
484
-        	} else {
485
-				$xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>";
486
-				$this->debug("serialize_val returning $xml");
487
-	        	return $xml;
488
-        	}
470
+            $this->debug("serialize_val: serialize xsd built-in primitive type");
471
+            if (is_bool($val)) {
472
+                if ($type == 'boolean') {
473
+                    $val = $val ? 'true' : 'false';
474
+                } elseif (! $val) {
475
+                    $val = 0;
476
+                }
477
+            } else if (is_string($val)) {
478
+                $val = $this->expandEntities($val);
479
+            }
480
+            if ($use == 'literal') {
481
+                $xml = "<$name$xmlns$atts>$val</$name>";
482
+                $this->debug("serialize_val returning $xml");
483
+                return $xml;
484
+            } else {
485
+                $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>";
486
+                $this->debug("serialize_val returning $xml");
487
+                return $xml;
488
+            }
489 489
         }
490
-		// detect type and serialize
491
-		$xml = '';
492
-		switch(true) {
493
-			case (is_bool($val) || $type == 'boolean'):
494
-		   		$this->debug("serialize_val: serialize boolean");
495
-        		if ($type == 'boolean') {
496
-	        		$val = $val ? 'true' : 'false';
497
-	        	} elseif (! $val) {
498
-	        		$val = 0;
499
-	        	}
500
-				if ($use == 'literal') {
501
-					$xml .= "<$name$xmlns$atts>$val</$name>";
502
-				} else {
503
-					$xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>";
504
-				}
505
-				break;
506
-			case (is_int($val) || is_long($val) || $type == 'int'):
507
-		   		$this->debug("serialize_val: serialize int");
508
-				if ($use == 'literal') {
509
-					$xml .= "<$name$xmlns$atts>$val</$name>";
510
-				} else {
511
-					$xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>";
512
-				}
513
-				break;
514
-			case (is_float($val)|| is_double($val) || $type == 'float'):
515
-		   		$this->debug("serialize_val: serialize float");
516
-				if ($use == 'literal') {
517
-					$xml .= "<$name$xmlns$atts>$val</$name>";
518
-				} else {
519
-					$xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>";
520
-				}
521
-				break;
522
-			case (is_string($val) || $type == 'string'):
523
-		   		$this->debug("serialize_val: serialize string");
524
-				$val = $this->expandEntities($val);
525
-				if ($use == 'literal') {
526
-					$xml .= "<$name$xmlns$atts>$val</$name>";
527
-				} else {
528
-					$xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>";
529
-				}
530
-				break;
531
-			case is_object($val):
532
-		   		$this->debug("serialize_val: serialize object");
533
-		    	if (get_class($val) == 'soapval') {
534
-		    		$this->debug("serialize_val: serialize soapval object");
535
-		        	$pXml = $val->serialize($use);
536
-					$this->appendDebug($val->getDebug());
537
-					$val->clearDebug();
538
-		        } else {
539
-					if (! $name) {
540
-						$name = get_class($val);
541
-						$this->debug("In serialize_val, used class name $name as element name");
542
-					} else {
543
-						$this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
544
-					}
545
-					foreach(get_object_vars($val) as $k => $v){
546
-						$pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use);
547
-					}
548
-				}
549
-				if(isset($type) && isset($type_prefix)){
550
-					$type_str = " xsi:type=\"$type_prefix:$type\"";
551
-				} else {
552
-					$type_str = '';
553
-				}
554
-				if ($use == 'literal') {
555
-					$xml .= "<$name$xmlns$atts>$pXml</$name>";
556
-				} else {
557
-					$xml .= "<$name$xmlns$type_str$atts>$pXml</$name>";
558
-				}
559
-				break;
560
-			break;
561
-			case (is_array($val) || $type):
562
-				// detect if struct or array
563
-				$valueType = $this->isArraySimpleOrStruct($val);
490
+        // detect type and serialize
491
+        $xml = '';
492
+        switch(true) {
493
+            case (is_bool($val) || $type == 'boolean'):
494
+                   $this->debug("serialize_val: serialize boolean");
495
+                if ($type == 'boolean') {
496
+                    $val = $val ? 'true' : 'false';
497
+                } elseif (! $val) {
498
+                    $val = 0;
499
+                }
500
+                if ($use == 'literal') {
501
+                    $xml .= "<$name$xmlns$atts>$val</$name>";
502
+                } else {
503
+                    $xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>";
504
+                }
505
+                break;
506
+            case (is_int($val) || is_long($val) || $type == 'int'):
507
+                   $this->debug("serialize_val: serialize int");
508
+                if ($use == 'literal') {
509
+                    $xml .= "<$name$xmlns$atts>$val</$name>";
510
+                } else {
511
+                    $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>";
512
+                }
513
+                break;
514
+            case (is_float($val)|| is_double($val) || $type == 'float'):
515
+                   $this->debug("serialize_val: serialize float");
516
+                if ($use == 'literal') {
517
+                    $xml .= "<$name$xmlns$atts>$val</$name>";
518
+                } else {
519
+                    $xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>";
520
+                }
521
+                break;
522
+            case (is_string($val) || $type == 'string'):
523
+                   $this->debug("serialize_val: serialize string");
524
+                $val = $this->expandEntities($val);
525
+                if ($use == 'literal') {
526
+                    $xml .= "<$name$xmlns$atts>$val</$name>";
527
+                } else {
528
+                    $xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>";
529
+                }
530
+                break;
531
+            case is_object($val):
532
+                   $this->debug("serialize_val: serialize object");
533
+                if (get_class($val) == 'soapval') {
534
+                    $this->debug("serialize_val: serialize soapval object");
535
+                    $pXml = $val->serialize($use);
536
+                    $this->appendDebug($val->getDebug());
537
+                    $val->clearDebug();
538
+                } else {
539
+                    if (! $name) {
540
+                        $name = get_class($val);
541
+                        $this->debug("In serialize_val, used class name $name as element name");
542
+                    } else {
543
+                        $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
544
+                    }
545
+                    foreach(get_object_vars($val) as $k => $v){
546
+                        $pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use);
547
+                    }
548
+                }
549
+                if(isset($type) && isset($type_prefix)){
550
+                    $type_str = " xsi:type=\"$type_prefix:$type\"";
551
+                } else {
552
+                    $type_str = '';
553
+                }
554
+                if ($use == 'literal') {
555
+                    $xml .= "<$name$xmlns$atts>$pXml</$name>";
556
+                } else {
557
+                    $xml .= "<$name$xmlns$type_str$atts>$pXml</$name>";
558
+                }
559
+                break;
560
+            break;
561
+            case (is_array($val) || $type):
562
+                // detect if struct or array
563
+                $valueType = $this->isArraySimpleOrStruct($val);
564 564
                 if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){
565
-			   		$this->debug("serialize_val: serialize array");
566
-					$i = 0;
567
-					if(is_array($val) && count($val)> 0){
568
-						foreach($val as $v){
569
-	                    	if(is_object($v) && get_class($v) ==  'soapval'){
570
-								$tt_ns = $v->type_ns;
571
-								$tt = $v->type;
572
-							} elseif (is_array($v)) {
573
-								$tt = $this->isArraySimpleOrStruct($v);
574
-							} else {
575
-								$tt = gettype($v);
576
-	                        }
577
-							$array_types[$tt] = 1;
578
-							// TODO: for literal, the name should be $name
579
-							$xml .= $this->serialize_val($v,'item',false,false,false,false,$use);
580
-							++$i;
581
-						}
582
-						if(count($array_types) > 1){
583
-							$array_typename = 'xsd:anyType';
584
-						} elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
585
-							if ($tt == 'integer') {
586
-								$tt = 'int';
587
-							}
588
-							$array_typename = 'xsd:'.$tt;
589
-						} elseif(isset($tt) && $tt == 'arraySimple'){
590
-							$array_typename = 'SOAP-ENC:Array';
591
-						} elseif(isset($tt) && $tt == 'arrayStruct'){
592
-							$array_typename = 'unnamed_struct_use_soapval';
593
-						} else {
594
-							// if type is prefixed, create type prefix
595
-							if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){
596
-								 $array_typename = 'xsd:' . $tt;
597
-							} elseif ($tt_ns) {
598
-								$tt_prefix = 'ns' . rand(1000, 9999);
599
-								$array_typename = "$tt_prefix:$tt";
600
-								$xmlns .= " xmlns:$tt_prefix=\"$tt_ns\"";
601
-							} else {
602
-								$array_typename = $tt;
603
-							}
604
-						}
605
-						$array_type = $i;
606
-						if ($use == 'literal') {
607
-							$type_str = '';
608
-						} else if (isset($type) && isset($type_prefix)) {
609
-							$type_str = " xsi:type=\"$type_prefix:$type\"";
610
-						} else {
611
-							$type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\"";
612
-						}
613
-					// empty array
614
-					} else {
615
-						if ($use == 'literal') {
616
-							$type_str = '';
617
-						} else if (isset($type) && isset($type_prefix)) {
618
-							$type_str = " xsi:type=\"$type_prefix:$type\"";
619
-						} else {
620
-							$type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\"";
621
-						}
622
-					}
623
-					// TODO: for array in literal, there is no wrapper here
624
-					$xml = "<$name$xmlns$type_str$atts>".$xml."</$name>";
625
-				} else {
626
-					// got a struct
627
-			   		$this->debug("serialize_val: serialize struct");
628
-					if(isset($type) && isset($type_prefix)){
629
-						$type_str = " xsi:type=\"$type_prefix:$type\"";
630
-					} else {
631
-						$type_str = '';
632
-					}
633
-					if ($use == 'literal') {
634
-						$xml .= "<$name$xmlns$atts>";
635
-					} else {
636
-						$xml .= "<$name$xmlns$type_str$atts>";
637
-					}
638
-					foreach($val as $k => $v){
639
-						// Apache Map
640
-						if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
641
-							$xml .= '<item>';
642
-							$xml .= $this->serialize_val($k,'key',false,false,false,false,$use);
643
-							$xml .= $this->serialize_val($v,'value',false,false,false,false,$use);
644
-							$xml .= '</item>';
645
-						} else {
646
-							$xml .= $this->serialize_val($v,$k,false,false,false,false,$use);
647
-						}
648
-					}
649
-					$xml .= "</$name>";
650
-				}
651
-				break;
652
-			default:
653
-		   		$this->debug("serialize_val: serialize unknown");
654
-				$xml .= 'not detected, got '.gettype($val).' for '.$val;
655
-				break;
656
-		}
657
-		$this->debug("serialize_val returning $xml");
658
-		return $xml;
659
-	}
660
-
661
-    /**
662
-    * serializes a message
663
-    *
664
-    * @param string $body the XML of the SOAP body
665
-    * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
666
-    * @param array $namespaces optional the namespaces used in generating the body and headers
667
-    * @param string $style optional (rpc|document)
668
-    * @param string $use optional (encoded|literal)
669
-    * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
670
-    * @return string the message
671
-    * @access public
672
-    */
565
+                        $this->debug("serialize_val: serialize array");
566
+                    $i = 0;
567
+                    if(is_array($val) && count($val)> 0){
568
+                        foreach($val as $v){
569
+                            if(is_object($v) && get_class($v) ==  'soapval'){
570
+                                $tt_ns = $v->type_ns;
571
+                                $tt = $v->type;
572
+                            } elseif (is_array($v)) {
573
+                                $tt = $this->isArraySimpleOrStruct($v);
574
+                            } else {
575
+                                $tt = gettype($v);
576
+                            }
577
+                            $array_types[$tt] = 1;
578
+                            // TODO: for literal, the name should be $name
579
+                            $xml .= $this->serialize_val($v,'item',false,false,false,false,$use);
580
+                            ++$i;
581
+                        }
582
+                        if(count($array_types) > 1){
583
+                            $array_typename = 'xsd:anyType';
584
+                        } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
585
+                            if ($tt == 'integer') {
586
+                                $tt = 'int';
587
+                            }
588
+                            $array_typename = 'xsd:'.$tt;
589
+                        } elseif(isset($tt) && $tt == 'arraySimple'){
590
+                            $array_typename = 'SOAP-ENC:Array';
591
+                        } elseif(isset($tt) && $tt == 'arrayStruct'){
592
+                            $array_typename = 'unnamed_struct_use_soapval';
593
+                        } else {
594
+                            // if type is prefixed, create type prefix
595
+                            if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){
596
+                                    $array_typename = 'xsd:' . $tt;
597
+                            } elseif ($tt_ns) {
598
+                                $tt_prefix = 'ns' . rand(1000, 9999);
599
+                                $array_typename = "$tt_prefix:$tt";
600
+                                $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\"";
601
+                            } else {
602
+                                $array_typename = $tt;
603
+                            }
604
+                        }
605
+                        $array_type = $i;
606
+                        if ($use == 'literal') {
607
+                            $type_str = '';
608
+                        } else if (isset($type) && isset($type_prefix)) {
609
+                            $type_str = " xsi:type=\"$type_prefix:$type\"";
610
+                        } else {
611
+                            $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\"";
612
+                        }
613
+                    // empty array
614
+                    } else {
615
+                        if ($use == 'literal') {
616
+                            $type_str = '';
617
+                        } else if (isset($type) && isset($type_prefix)) {
618
+                            $type_str = " xsi:type=\"$type_prefix:$type\"";
619
+                        } else {
620
+                            $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\"";
621
+                        }
622
+                    }
623
+                    // TODO: for array in literal, there is no wrapper here
624
+                    $xml = "<$name$xmlns$type_str$atts>".$xml."</$name>";
625
+                } else {
626
+                    // got a struct
627
+                        $this->debug("serialize_val: serialize struct");
628
+                    if(isset($type) && isset($type_prefix)){
629
+                        $type_str = " xsi:type=\"$type_prefix:$type\"";
630
+                    } else {
631
+                        $type_str = '';
632
+                    }
633
+                    if ($use == 'literal') {
634
+                        $xml .= "<$name$xmlns$atts>";
635
+                    } else {
636
+                        $xml .= "<$name$xmlns$type_str$atts>";
637
+                    }
638
+                    foreach($val as $k => $v){
639
+                        // Apache Map
640
+                        if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
641
+                            $xml .= '<item>';
642
+                            $xml .= $this->serialize_val($k,'key',false,false,false,false,$use);
643
+                            $xml .= $this->serialize_val($v,'value',false,false,false,false,$use);
644
+                            $xml .= '</item>';
645
+                        } else {
646
+                            $xml .= $this->serialize_val($v,$k,false,false,false,false,$use);
647
+                        }
648
+                    }
649
+                    $xml .= "</$name>";
650
+                }
651
+                break;
652
+            default:
653
+                   $this->debug("serialize_val: serialize unknown");
654
+                $xml .= 'not detected, got '.gettype($val).' for '.$val;
655
+                break;
656
+        }
657
+        $this->debug("serialize_val returning $xml");
658
+        return $xml;
659
+    }
660
+
661
+    /**
662
+     * serializes a message
663
+     *
664
+     * @param string $body the XML of the SOAP body
665
+     * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
666
+     * @param array $namespaces optional the namespaces used in generating the body and headers
667
+     * @param string $style optional (rpc|document)
668
+     * @param string $use optional (encoded|literal)
669
+     * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
670
+     * @return string the message
671
+     * @access public
672
+     */
673 673
     function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){
674 674
     // TODO: add an option to automatically run utf8_encode on $body and $headers
675 675
     // if $this->soap_defencoding is UTF-8.  Not doing this automatically allows
676 676
     // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1
677 677
 
678
-	$this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
679
-	$this->debug("headers:");
680
-	$this->appendDebug($this->varDump($headers));
681
-	$this->debug("namespaces:");
682
-	$this->appendDebug($this->varDump($namespaces));
678
+    $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
679
+    $this->debug("headers:");
680
+    $this->appendDebug($this->varDump($headers));
681
+    $this->debug("namespaces:");
682
+    $this->appendDebug($this->varDump($namespaces));
683 683
 
684
-	// serialize namespaces
684
+    // serialize namespaces
685 685
     $ns_string = '';
686
-	foreach(array_merge($this->namespaces,$namespaces) as $k => $v){
687
-		$ns_string .= " xmlns:$k=\"$v\"";
688
-	}
689
-	if($encodingStyle) {
690
-		$ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string";
691
-	}
692
-
693
-	// serialize headers
694
-	if($headers){
695
-		if (is_array($headers)) {
696
-			$xml = '';
697
-			foreach ($headers as $k => $v) {
698
-				if (is_object($v) && get_class($v) == 'soapval') {
699
-					$xml .= $this->serialize_val($v, false, false, false, false, false, $use);
700
-				} else {
701
-					$xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
702
-				}
703
-			}
704
-			$headers = $xml;
705
-			$this->debug("In serializeEnvelope, serialized array of headers to $headers");
706
-		}
707
-		$headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>";
708
-	}
709
-	// serialize envelope
710
-	return
711
-	'<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">".
712
-	'<SOAP-ENV:Envelope'.$ns_string.">".
713
-	$headers.
714
-	"<SOAP-ENV:Body>".
715
-		$body.
716
-	"</SOAP-ENV:Body>".
717
-	"</SOAP-ENV:Envelope>";
718
-    }
719
-
720
-	/**
721
-	 * formats a string to be inserted into an HTML stream
722
-	 *
723
-	 * @param string $str The string to format
724
-	 * @return string The formatted string
725
-	 * @access public
726
-	 * @deprecated
727
-	 */
686
+    foreach(array_merge($this->namespaces,$namespaces) as $k => $v){
687
+        $ns_string .= " xmlns:$k=\"$v\"";
688
+    }
689
+    if($encodingStyle) {
690
+        $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string";
691
+    }
692
+
693
+    // serialize headers
694
+    if($headers){
695
+        if (is_array($headers)) {
696
+            $xml = '';
697
+            foreach ($headers as $k => $v) {
698
+                if (is_object($v) && get_class($v) == 'soapval') {
699
+                    $xml .= $this->serialize_val($v, false, false, false, false, false, $use);
700
+                } else {
701
+                    $xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
702
+                }
703
+            }
704
+            $headers = $xml;
705
+            $this->debug("In serializeEnvelope, serialized array of headers to $headers");
706
+        }
707
+        $headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>";
708
+    }
709
+    // serialize envelope
710
+    return
711
+    '<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">".
712
+    '<SOAP-ENV:Envelope'.$ns_string.">".
713
+    $headers.
714
+    "<SOAP-ENV:Body>".
715
+        $body.
716
+    "</SOAP-ENV:Body>".
717
+    "</SOAP-ENV:Envelope>";
718
+    }
719
+
720
+    /**
721
+     * formats a string to be inserted into an HTML stream
722
+     *
723
+     * @param string $str The string to format
724
+     * @return string The formatted string
725
+     * @access public
726
+     * @deprecated
727
+     */
728 728
     function formatDump($str){
729
-		$str = htmlspecialchars($str);
730
-		return nl2br($str);
731
-    }
732
-
733
-	/**
734
-	* contracts (changes namespace to prefix) a qualified name
735
-	*
736
-	* @param    string $qname qname
737
-	* @return	string contracted qname
738
-	* @access   private
739
-	*/
740
-	function contractQname($qname){
741
-		// get element namespace
742
-		//$this->xdebug("Contract $qname");
743
-		if (strrpos($qname, ':')) {
744
-			// get unqualified name
745
-			$name = substr($qname, strrpos($qname, ':') + 1);
746
-			// get ns
747
-			$ns = substr($qname, 0, strrpos($qname, ':'));
748
-			$p = $this->getPrefixFromNamespace($ns);
749
-			if ($p) {
750
-				return $p . ':' . $name;
751
-			}
752
-			return $qname;
753
-		} else {
754
-			return $qname;
755
-		}
756
-	}
757
-
758
-	/**
759
-	* expands (changes prefix to namespace) a qualified name
760
-	*
761
-	* @param    string $qname qname
762
-	* @return	string expanded qname
763
-	* @access   private
764
-	*/
765
-	function expandQname($qname){
766
-		// get element prefix
767
-		if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){
768
-			// get unqualified name
769
-			$name = substr(strstr($qname,':'),1);
770
-			// get ns prefix
771
-			$prefix = substr($qname,0,strpos($qname,':'));
772
-			if(isset($this->namespaces[$prefix])){
773
-				return $this->namespaces[$prefix].':'.$name;
774
-			} else {
775
-				return $qname;
776
-			}
777
-		} else {
778
-			return $qname;
779
-		}
780
-	}
781
-
782
-    /**
783
-    * returns the local part of a prefixed string
784
-    * returns the original string, if not prefixed
785
-    *
786
-    * @param string $str The prefixed string
787
-    * @return string The local part
788
-    * @access public
789
-    */
790
-	function getLocalPart($str){
791
-		if($sstr = strrchr($str,':')){
792
-			// get unqualified name
793
-			return substr( $sstr, 1 );
794
-		} else {
795
-			return $str;
796
-		}
797
-	}
798
-
799
-	/**
800
-    * returns the prefix part of a prefixed string
801
-    * returns false, if not prefixed
802
-    *
803
-    * @param string $str The prefixed string
804
-    * @return mixed The prefix or false if there is no prefix
805
-    * @access public
806
-    */
807
-	function getPrefix($str){
808
-		if($pos = strrpos($str,':')){
809
-			// get prefix
810
-			return substr($str,0,$pos);
811
-		}
812
-		return false;
813
-	}
814
-
815
-	/**
816
-    * pass it a prefix, it returns a namespace
817
-    *
818
-    * @param string $prefix The prefix
819
-    * @return mixed The namespace, false if no namespace has the specified prefix
820
-    * @access public
821
-    */
822
-	function getNamespaceFromPrefix($prefix){
823
-		if (isset($this->namespaces[$prefix])) {
824
-			return $this->namespaces[$prefix];
825
-		}
826
-		//$this->setError("No namespace registered for prefix '$prefix'");
827
-		return false;
828
-	}
829
-
830
-	/**
831
-    * returns the prefix for a given namespace (or prefix)
832
-    * or false if no prefixes registered for the given namespace
833
-    *
834
-    * @param string $ns The namespace
835
-    * @return mixed The prefix, false if the namespace has no prefixes
836
-    * @access public
837
-    */
838
-	function getPrefixFromNamespace($ns) {
839
-		foreach ($this->namespaces as $p => $n) {
840
-			if ($ns == $n || $ns == $p) {
841
-			    $this->usedNamespaces[$p] = $n;
842
-				return $p;
843
-			}
844
-		}
845
-		return false;
846
-	}
847
-
848
-	/**
849
-    * returns the time in ODBC canonical form with microseconds
850
-    *
851
-    * @return string The time in ODBC canonical form with microseconds
852
-    * @access public
853
-    */
854
-	function getmicrotime() {
855
-		if (function_exists('gettimeofday')) {
856
-			$tod = gettimeofday();
857
-			$sec = $tod['sec'];
858
-			$usec = $tod['usec'];
859
-		} else {
860
-			$sec = time();
861
-			$usec = 0;
862
-		}
863
-		return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
864
-	}
865
-
866
-	/**
867
-	 * Returns a string with the output of var_dump
868
-	 *
869
-	 * @param mixed $data The variable to var_dump
870
-	 * @return string The output of var_dump
871
-	 * @access public
872
-	 */
729
+        $str = htmlspecialchars($str);
730
+        return nl2br($str);
731
+    }
732
+
733
+    /**
734
+     * contracts (changes namespace to prefix) a qualified name
735
+     *
736
+     * @param    string $qname qname
737
+     * @return	string contracted qname
738
+     * @access   private
739
+     */
740
+    function contractQname($qname){
741
+        // get element namespace
742
+        //$this->xdebug("Contract $qname");
743
+        if (strrpos($qname, ':')) {
744
+            // get unqualified name
745
+            $name = substr($qname, strrpos($qname, ':') + 1);
746
+            // get ns
747
+            $ns = substr($qname, 0, strrpos($qname, ':'));
748
+            $p = $this->getPrefixFromNamespace($ns);
749
+            if ($p) {
750
+                return $p . ':' . $name;
751
+            }
752
+            return $qname;
753
+        } else {
754
+            return $qname;
755
+        }
756
+    }
757
+
758
+    /**
759
+     * expands (changes prefix to namespace) a qualified name
760
+     *
761
+     * @param    string $qname qname
762
+     * @return	string expanded qname
763
+     * @access   private
764
+     */
765
+    function expandQname($qname){
766
+        // get element prefix
767
+        if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){
768
+            // get unqualified name
769
+            $name = substr(strstr($qname,':'),1);
770
+            // get ns prefix
771
+            $prefix = substr($qname,0,strpos($qname,':'));
772
+            if(isset($this->namespaces[$prefix])){
773
+                return $this->namespaces[$prefix].':'.$name;
774
+            } else {
775
+                return $qname;
776
+            }
777
+        } else {
778
+            return $qname;
779
+        }
780
+    }
781
+
782
+    /**
783
+     * returns the local part of a prefixed string
784
+     * returns the original string, if not prefixed
785
+     *
786
+     * @param string $str The prefixed string
787
+     * @return string The local part
788
+     * @access public
789
+     */
790
+    function getLocalPart($str){
791
+        if($sstr = strrchr($str,':')){
792
+            // get unqualified name
793
+            return substr( $sstr, 1 );
794
+        } else {
795
+            return $str;
796
+        }
797
+    }
798
+
799
+    /**
800
+     * returns the prefix part of a prefixed string
801
+     * returns false, if not prefixed
802
+     *
803
+     * @param string $str The prefixed string
804
+     * @return mixed The prefix or false if there is no prefix
805
+     * @access public
806
+     */
807
+    function getPrefix($str){
808
+        if($pos = strrpos($str,':')){
809
+            // get prefix
810
+            return substr($str,0,$pos);
811
+        }
812
+        return false;
813
+    }
814
+
815
+    /**
816
+     * pass it a prefix, it returns a namespace
817
+     *
818
+     * @param string $prefix The prefix
819
+     * @return mixed The namespace, false if no namespace has the specified prefix
820
+     * @access public
821
+     */
822
+    function getNamespaceFromPrefix($prefix){
823
+        if (isset($this->namespaces[$prefix])) {
824
+            return $this->namespaces[$prefix];
825
+        }
826
+        //$this->setError("No namespace registered for prefix '$prefix'");
827
+        return false;
828
+    }
829
+
830
+    /**
831
+     * returns the prefix for a given namespace (or prefix)
832
+     * or false if no prefixes registered for the given namespace
833
+     *
834
+     * @param string $ns The namespace
835
+     * @return mixed The prefix, false if the namespace has no prefixes
836
+     * @access public
837
+     */
838
+    function getPrefixFromNamespace($ns) {
839
+        foreach ($this->namespaces as $p => $n) {
840
+            if ($ns == $n || $ns == $p) {
841
+                $this->usedNamespaces[$p] = $n;
842
+                return $p;
843
+            }
844
+        }
845
+        return false;
846
+    }
847
+
848
+    /**
849
+     * returns the time in ODBC canonical form with microseconds
850
+     *
851
+     * @return string The time in ODBC canonical form with microseconds
852
+     * @access public
853
+     */
854
+    function getmicrotime() {
855
+        if (function_exists('gettimeofday')) {
856
+            $tod = gettimeofday();
857
+            $sec = $tod['sec'];
858
+            $usec = $tod['usec'];
859
+        } else {
860
+            $sec = time();
861
+            $usec = 0;
862
+        }
863
+        return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
864
+    }
865
+
866
+    /**
867
+     * Returns a string with the output of var_dump
868
+     *
869
+     * @param mixed $data The variable to var_dump
870
+     * @return string The output of var_dump
871
+     * @access public
872
+     */
873 873
     function varDump($data) {
874
-		ob_start();
875
-		var_dump($data);
876
-		$ret_val = ob_get_contents();
877
-		ob_end_clean();
878
-		return $ret_val;
879
-	}
880
-
881
-	/**
882
-	* represents the object as a string
883
-	*
884
-	* @return	string
885
-	* @access   public
886
-	*/
887
-	function __toString() {
888
-		return $this->varDump($this);
889
-	}
874
+        ob_start();
875
+        var_dump($data);
876
+        $ret_val = ob_get_contents();
877
+        ob_end_clean();
878
+        return $ret_val;
879
+    }
880
+
881
+    /**
882
+     * represents the object as a string
883
+     *
884
+     * @return	string
885
+     * @access   public
886
+     */
887
+    function __toString() {
888
+        return $this->varDump($this);
889
+    }
890 890
 }
891 891
 
892 892
 // XML Schema Datatype Helper Functions
@@ -902,35 +902,35 @@  discard block
 block discarded – undo
902 902
 * @access   public
903 903
 */
904 904
 function timestamp_to_iso8601($timestamp,$utc=true){
905
-	$datestr = date('Y-m-d\TH:i:sO',$timestamp);
906
-	$pos = strrpos($datestr, "+");
907
-	if ($pos === FALSE) {
908
-		$pos = strrpos($datestr, "-");
909
-	}
910
-	if ($pos !== FALSE) {
911
-		if (strlen($datestr) == $pos + 5) {
912
-			$datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2);
913
-		}
914
-	}
915
-	if($utc){
916
-		$pattern = '/'.
917
-		'([0-9]{4})-'.	// centuries & years CCYY-
918
-		'([0-9]{2})-'.	// months MM-
919
-		'([0-9]{2})'.	// days DD
920
-		'T'.			// separator T
921
-		'([0-9]{2}):'.	// hours hh:
922
-		'([0-9]{2}):'.	// minutes mm:
923
-		'([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
924
-		'(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
925
-		'/';
926
-
927
-		if(preg_match($pattern,$datestr,$regs)){
928
-			return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
929
-		}
930
-		return false;
931
-	} else {
932
-		return $datestr;
933
-	}
905
+    $datestr = date('Y-m-d\TH:i:sO',$timestamp);
906
+    $pos = strrpos($datestr, "+");
907
+    if ($pos === FALSE) {
908
+        $pos = strrpos($datestr, "-");
909
+    }
910
+    if ($pos !== FALSE) {
911
+        if (strlen($datestr) == $pos + 5) {
912
+            $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2);
913
+        }
914
+    }
915
+    if($utc){
916
+        $pattern = '/'.
917
+        '([0-9]{4})-'.	// centuries & years CCYY-
918
+        '([0-9]{2})-'.	// months MM-
919
+        '([0-9]{2})'.	// days DD
920
+        'T'.			// separator T
921
+        '([0-9]{2}):'.	// hours hh:
922
+        '([0-9]{2}):'.	// minutes mm:
923
+        '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
924
+        '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
925
+        '/';
926
+
927
+        if(preg_match($pattern,$datestr,$regs)){
928
+            return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
929
+        }
930
+        return false;
931
+    } else {
932
+        return $datestr;
933
+    }
934 934
 }
935 935
 
936 936
 /**
@@ -941,35 +941,35 @@  discard block
 block discarded – undo
941 941
 * @access   public
942 942
 */
943 943
 function iso8601_to_timestamp($datestr){
944
-	$pattern = '/'.
945
-	'([0-9]{4})-'.	// centuries & years CCYY-
946
-	'([0-9]{2})-'.	// months MM-
947
-	'([0-9]{2})'.	// days DD
948
-	'T'.			// separator T
949
-	'([0-9]{2}):'.	// hours hh:
950
-	'([0-9]{2}):'.	// minutes mm:
951
-	'([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
952
-	'(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
953
-	'/';
954
-	if(preg_match($pattern,$datestr,$regs)){
955
-		// not utc
956
-		if($regs[8] != 'Z'){
957
-			$op = substr($regs[8],0,1);
958
-			$h = substr($regs[8],1,2);
959
-			$m = substr($regs[8],strlen($regs[8])-2,2);
960
-			if($op == '-'){
961
-				$regs[4] = $regs[4] + $h;
962
-				$regs[5] = $regs[5] + $m;
963
-			} elseif($op == '+'){
964
-				$regs[4] = $regs[4] - $h;
965
-				$regs[5] = $regs[5] - $m;
966
-			}
967
-		}
968
-		return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
944
+    $pattern = '/'.
945
+    '([0-9]{4})-'.	// centuries & years CCYY-
946
+    '([0-9]{2})-'.	// months MM-
947
+    '([0-9]{2})'.	// days DD
948
+    'T'.			// separator T
949
+    '([0-9]{2}):'.	// hours hh:
950
+    '([0-9]{2}):'.	// minutes mm:
951
+    '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
952
+    '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
953
+    '/';
954
+    if(preg_match($pattern,$datestr,$regs)){
955
+        // not utc
956
+        if($regs[8] != 'Z'){
957
+            $op = substr($regs[8],0,1);
958
+            $h = substr($regs[8],1,2);
959
+            $m = substr($regs[8],strlen($regs[8])-2,2);
960
+            if($op == '-'){
961
+                $regs[4] = $regs[4] + $h;
962
+                $regs[5] = $regs[5] + $m;
963
+            } elseif($op == '+'){
964
+                $regs[4] = $regs[4] - $h;
965
+                $regs[5] = $regs[5] - $m;
966
+            }
967
+        }
968
+        return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
969 969
 //		return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z");
970
-	} else {
971
-		return false;
972
-	}
970
+    } else {
971
+        return false;
972
+    }
973 973
 }
974 974
 
975 975
 /**
@@ -981,15 +981,15 @@  discard block
 block discarded – undo
981 981
 */
982 982
 function usleepWindows($usec)
983 983
 {
984
-	$start = gettimeofday();
985
-
986
-	do
987
-	{
988
-		$stop = gettimeofday();
989
-		$timePassed = 1000000 * ($stop['sec'] - $start['sec'])
990
-		+ $stop['usec'] - $start['usec'];
991
-	}
992
-	while ($timePassed < $usec);
984
+    $start = gettimeofday();
985
+
986
+    do
987
+    {
988
+        $stop = gettimeofday();
989
+        $timePassed = 1000000 * ($stop['sec'] - $start['sec'])
990
+        + $stop['usec'] - $start['usec'];
991
+    }
992
+    while ($timePassed < $usec);
993 993
 }
994 994
 
995 995
 
Please login to merge, or discard this patch.
main/inc/lib/icalcreator/iCalcreator.class.php 1 patch
Indentation   +3920 added lines, -3921 removed lines patch added patch discarded remove patch
@@ -1,28 +1,28 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /*********************************************************************************/
3 3
 /**
4
- * iCalcreator class v2.6
5
- * copyright (c) 2007-2008 Kjell-Inge Gustafsson kigkonsult
6
- * www.kigkonsult.se/iCalcreator/index.php
7
- * [email protected]
8
- *
9
- * Description:
10
- * This file is a PHP implementation of RFC 2445.
11
- *
12
- * This library is free software; you can redistribute it and/or
13
- * modify it under the terms of the GNU Lesser General Public
14
- * License as published by the Free Software Foundation; either
15
- * version 2.1 of the License, or (at your option) any later version.
16
- *
17
- * This library is distributed in the hope that it will be useful,
18
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20
- * Lesser General Public License for more details.
21
- *
22
- * You should have received a copy of the GNU Lesser General Public
23
- * License along with this library; if not, write to the Free Software
24
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
- */
4
+     * iCalcreator class v2.6
5
+     * copyright (c) 2007-2008 Kjell-Inge Gustafsson kigkonsult
6
+     * www.kigkonsult.se/iCalcreator/index.php
7
+     * [email protected]
8
+     *
9
+     * Description:
10
+     * This file is a PHP implementation of RFC 2445.
11
+     *
12
+     * This library is free software; you can redistribute it and/or
13
+     * modify it under the terms of the GNU Lesser General Public
14
+     * License as published by the Free Software Foundation; either
15
+     * version 2.1 of the License, or (at your option) any later version.
16
+     *
17
+     * This library is distributed in the hope that it will be useful,
18
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20
+     * Lesser General Public License for more details.
21
+     *
22
+     * You should have received a copy of the GNU Lesser General Public
23
+     * License along with this library; if not, write to the Free Software
24
+     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
+     */
26 26
 /*********************************************************************************/
27 27
 /*********************************************************************************/
28 28
 /*         A little setup                                                        */
@@ -45,41 +45,41 @@  discard block
 block discarded – undo
45 45
 */
46 46
             /* only for phpversion 5.x, date management, default timezone setting */
47 47
 if( substr( phpversion(), 0, 1) >= '5' ) // && ( 'UTC' == date_default_timezone_get() )) {
48
-  date_default_timezone_set( 'Europe/Stockholm' );
48
+    date_default_timezone_set( 'Europe/Stockholm' );
49 49
             /* version string, do NOT remove!! */
50 50
 define( 'ICALCREATOR_VERSION', 'iCalcreator 2.6' );
51 51
 /*********************************************************************************/
52 52
 /*********************************************************************************/
53 53
 /**
54
- * vcalendar class
55
- *
56
- * @author Kjell-Inge Gustafsson <[email protected]>
57
- * @since 2.2.13 - 2007-12-30
58
- */
54
+             * vcalendar class
55
+             *
56
+             * @author Kjell-Inge Gustafsson <[email protected]>
57
+             * @since 2.2.13 - 2007-12-30
58
+             */
59 59
 class vcalendar {
60 60
             //  calendar property variables
61
-  var $calscale;
62
-  var $method;
63
-  var $prodid;
64
-  var $version;
65
-  var $xprop;
61
+    var $calscale;
62
+    var $method;
63
+    var $prodid;
64
+    var $version;
65
+    var $xprop;
66 66
             //  container for calendar components
67
-  var $components;
67
+    var $components;
68 68
             //  component config variables
69
-  var $allowEmpty;
70
-  var $unique_id;
71
-  var $language;
72
-  var $directory;
73
-  var $filename;
74
-  var $url;
75
-  var $delimiter;
76
-  var $nl;
77
-  var $format;
69
+    var $allowEmpty;
70
+    var $unique_id;
71
+    var $language;
72
+    var $directory;
73
+    var $filename;
74
+    var $url;
75
+    var $delimiter;
76
+    var $nl;
77
+    var $format;
78 78
             //  component internal variables
79
-  var $attributeDelimiter;
80
-  var $valueInit;
79
+    var $attributeDelimiter;
80
+    var $valueInit;
81 81
             //  component xCal declaration container
82
-  var $xcaldecl;
82
+    var $xcaldecl;
83 83
 /*
84 84
  * constructor for calendar object
85 85
  *
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
  * @since 2.2.13 - 2007-12-30
88 88
  * @return void
89 89
  */
90
-  function vcalendar () {
90
+    function vcalendar () {
91 91
     $this->_makeVersion();
92 92
     $this->calscale   = null;
93 93
     $this->method     = null;
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
     $this->prodid     = null;
96 96
     $this->xprop      = array();
97 97
 /**
98
- *   language = <Text identifying a language, as defined in [RFC 1766]>
99
- */
98
+     *   language = <Text identifying a language, as defined in [RFC 1766]>
99
+     */
100 100
     if( defined( 'ICAL_LANG' ))
101
-      $this->setConfig( 'language', ICAL_LANG );
101
+        $this->setConfig( 'language', ICAL_LANG );
102 102
     $this->setConfig( 'allowEmpty', TRUE );
103 103
     $this->setConfig( 'nl',         "\n" );
104 104
     $this->setConfig( 'format',     'iCal');
@@ -108,227 +108,226 @@  discard block
 block discarded – undo
108 108
     $this->setConfig( 'delimiter',  DIRECTORY_SEPARATOR );
109 109
     $this->xcaldecl   = array();
110 110
     $this->components = array();
111
-  }
111
+    }
112 112
 /*********************************************************************************/
113 113
 /**
114
- * Property Name: CALSCALE
115
- */
114
+     * Property Name: CALSCALE
115
+     */
116 116
 /**
117
- * creates formatted output for calendar property calscale
118
- *
119
- * @author Kjell-Inge Gustafsson <[email protected]>
120
- * @since 2.4.8 - 2008-10-21
121
- * @return string
122
- */
123
-  function createCalscale() {
117
+     * creates formatted output for calendar property calscale
118
+     *
119
+     * @author Kjell-Inge Gustafsson <[email protected]>
120
+     * @since 2.4.8 - 2008-10-21
121
+     * @return string
122
+     */
123
+    function createCalscale() {
124 124
     if( empty( $this->calscale )) return FALSE;
125 125
     switch( $this->format ) {
126
-      case 'xcal':
126
+        case 'xcal':
127 127
         return ' calscale="'.$this->calscale.'"'.$this->nl;
128 128
         break;
129
-      default:
129
+        default:
130 130
         return 'CALSCALE:'.$this->calscale.$this->nl;
131 131
         break;
132 132
     }
133
-  }
133
+    }
134 134
 /**
135
- * set calendar property calscale
136
- *
137
- * @author Kjell-Inge Gustafsson <[email protected]>
138
- * @since 2.4.8 - 2008-10-21
139
- * @param string $value
140
- * @return void
141
- */
142
-  function setCalscale( $value ) {
135
+     * set calendar property calscale
136
+     *
137
+     * @author Kjell-Inge Gustafsson <[email protected]>
138
+     * @since 2.4.8 - 2008-10-21
139
+     * @param string $value
140
+     * @return void
141
+     */
142
+    function setCalscale( $value ) {
143 143
     if( empty( $value )) return FALSE;
144 144
     $this->calscale = $value;
145
-  }
145
+    }
146 146
 /*********************************************************************************/
147 147
 /**
148
- * Property Name: METHOD
149
- */
148
+     * Property Name: METHOD
149
+     */
150 150
 /**
151
- * creates formatted output for calendar property method
152
- *
153
- * @author Kjell-Inge Gustafsson <[email protected]>
154
- * @since 0.9.7 - 2006-11-20
155
- * @return string
156
- */
157
-  function createMethod() {
151
+     * creates formatted output for calendar property method
152
+     *
153
+     * @author Kjell-Inge Gustafsson <[email protected]>
154
+     * @since 0.9.7 - 2006-11-20
155
+     * @return string
156
+     */
157
+    function createMethod() {
158 158
     if( empty( $this->method )) return FALSE;
159 159
     switch( $this->format ) {
160
-      case 'xcal':
160
+        case 'xcal':
161 161
         return ' method="'.$this->method.'"'.$this->nl;
162 162
         break;
163
-      default:
163
+        default:
164 164
         return 'METHOD:'.$this->method.$this->nl;
165 165
         break;
166 166
     }
167
-  }
167
+    }
168 168
 /**
169
- * set calendar property method
170
- *
171
- * @author Kjell-Inge Gustafsson <[email protected]>
172
- * @since 2.4.8 - 2008-20-23
173
- * @param string $value
174
- * @return bool
175
- */
176
-  function setMethod( $value ) {
169
+     * set calendar property method
170
+     *
171
+     * @author Kjell-Inge Gustafsson <[email protected]>
172
+     * @since 2.4.8 - 2008-20-23
173
+     * @param string $value
174
+     * @return bool
175
+     */
176
+    function setMethod( $value ) {
177 177
     if( empty( $value )) return FALSE;
178 178
     $this->method = $value;
179 179
     return TRUE;
180
-  }
180
+    }
181 181
 /*********************************************************************************/
182 182
 /**
183
- * Property Name: PRODID
184
- *
185
- *  The identifier is RECOMMENDED to be the identical syntax to the
186
- * [RFC 822] addr-spec. A good method to assure uniqueness is to put the
187
- * domain name or a domain literal IP address of the host on which.. .
188
- */
189
-/**
190
- * creates formatted output for calendar property prodid
191
- *
192
- * @author Kjell-Inge Gustafsson <[email protected]>
193
- * @since 0.9.7 - 2006-11-20
194
- * @return string
195
- */
196
-  function createProdid() {
183
+     * Property Name: PRODID
184
+     *
185
+     *  The identifier is RECOMMENDED to be the identical syntax to the
186
+     * [RFC 822] addr-spec. A good method to assure uniqueness is to put the
187
+     * domain name or a domain literal IP address of the host on which.. .
188
+     */
189
+/**
190
+     * creates formatted output for calendar property prodid
191
+     *
192
+     * @author Kjell-Inge Gustafsson <[email protected]>
193
+     * @since 0.9.7 - 2006-11-20
194
+     * @return string
195
+     */
196
+    function createProdid() {
197 197
     if( !isset( $this->prodid ))
198
-      $this->_makeProdid();
198
+        $this->_makeProdid();
199 199
     switch( $this->format ) {
200
-      case 'xcal':
200
+        case 'xcal':
201 201
         return ' prodid="'.$this->prodid.'"'.$this->nl;
202 202
         break;
203
-      default:
203
+        default:
204 204
         return 'PRODID:'.$this->prodid.$this->nl;
205 205
         break;
206 206
     }
207
-  }
207
+    }
208 208
 /**
209
- * make default value for calendar prodid
210
- *
211
- * @author Kjell-Inge Gustafsson <[email protected]>
212
- * @since 0.3.0 - 2006-08-10
213
- * @return void
214
- */
215
-  function _makeProdid() {
209
+     * make default value for calendar prodid
210
+     *
211
+     * @author Kjell-Inge Gustafsson <[email protected]>
212
+     * @since 0.3.0 - 2006-08-10
213
+     * @return void
214
+     */
215
+    function _makeProdid() {
216 216
     $this->prodid  = '-//'.$this->unique_id.'//NONSGML '.ICALCREATOR_VERSION.'//'.strtoupper( $this->language );
217
-  }
217
+    }
218 218
 /**
219
- * Conformance: The property MUST be specified once in an iCalendar object.
220
- * Description: The vendor of the implementation SHOULD assure that this
221
- * is a globally unique identifier; using some technique such as an FPI
222
- * value, as defined in [ISO 9070].
223
- */
219
+     * Conformance: The property MUST be specified once in an iCalendar object.
220
+     * Description: The vendor of the implementation SHOULD assure that this
221
+     * is a globally unique identifier; using some technique such as an FPI
222
+     * value, as defined in [ISO 9070].
223
+     */
224 224
 /**
225
- * make default unique_id for calendar prodid
226
- *
227
- * @author Kjell-Inge Gustafsson <[email protected]>
228
- * @since 0.3.0 - 2006-08-10
229
- * @return void
230
- */
231
-  function _makeUnique_id() {
225
+     * make default unique_id for calendar prodid
226
+     *
227
+     * @author Kjell-Inge Gustafsson <[email protected]>
228
+     * @since 0.3.0 - 2006-08-10
229
+     * @return void
230
+     */
231
+    function _makeUnique_id() {
232 232
     $this->unique_id  = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost';
233
-  }
233
+    }
234 234
 /*********************************************************************************/
235 235
 /**
236
- * Property Name: VERSION
237
- *
238
- * Description: A value of "2.0" corresponds to this memo.
239
- */
240
-/**
241
- * creates formatted output for calendar property version
242
-
243
- *
244
- * @author Kjell-Inge Gustafsson <[email protected]>
245
- * @since 0.9.7 - 2006-11-20
246
- * @return string
247
- */
248
-  function createVersion() {
236
+     * Property Name: VERSION
237
+     *
238
+     * Description: A value of "2.0" corresponds to this memo.
239
+     */
240
+/**
241
+     * creates formatted output for calendar property version
242
+     *
243
+     * @author Kjell-Inge Gustafsson <[email protected]>
244
+     * @since 0.9.7 - 2006-11-20
245
+     * @return string
246
+     */
247
+    function createVersion() {
249 248
     if( empty( $this->version ))
250
-      $this->_makeVersion();
249
+        $this->_makeVersion();
251 250
     switch( $this->format ) {
252
-      case 'xcal':
251
+        case 'xcal':
253 252
         return ' version="'.$this->version.'"'.$this->nl;
254 253
         break;
255
-      default:
254
+        default:
256 255
         return 'VERSION:'.$this->version.$this->nl;
257 256
         break;
258 257
     }
259
-  }
258
+    }
260 259
 /**
261
- * set default calendar version
262
- *
263
- * @author Kjell-Inge Gustafsson <[email protected]>
264
- * @since 0.3.0 - 2006-08-10
265
- * @return void
266
- */
267
-  function _makeVersion() {
260
+     * set default calendar version
261
+     *
262
+     * @author Kjell-Inge Gustafsson <[email protected]>
263
+     * @since 0.3.0 - 2006-08-10
264
+     * @return void
265
+     */
266
+    function _makeVersion() {
268 267
     $this->version = '2.0';
269
-  }
268
+    }
270 269
 /**
271
- * set calendar version
272
- *
273
- * @author Kjell-Inge Gustafsson <[email protected]>
274
- * @since 2.4.8 - 2008-10-23
275
- * @param string $value
276
- * @return void
277
- */
278
-  function setVersion( $value ) {
270
+     * set calendar version
271
+     *
272
+     * @author Kjell-Inge Gustafsson <[email protected]>
273
+     * @since 2.4.8 - 2008-10-23
274
+     * @param string $value
275
+     * @return void
276
+     */
277
+    function setVersion( $value ) {
279 278
     if( empty( $value )) return FALSE;
280 279
     $this->version = $value;
281 280
     return TRUE;
282
-  }
281
+    }
283 282
 /*********************************************************************************/
284 283
 /**
285
- * Property Name: x-prop
286
- */
284
+     * Property Name: x-prop
285
+     */
287 286
 /**
288
- * creates formatted output for calendar property x-prop, iCal format only
289
- *
290
- * @author Kjell-Inge Gustafsson <[email protected]>
291
- * @since 2.4.11 - 2008-11-03
292
- * @return string
293
- */
294
-  function createXprop() {
287
+     * creates formatted output for calendar property x-prop, iCal format only
288
+     *
289
+     * @author Kjell-Inge Gustafsson <[email protected]>
290
+     * @since 2.4.11 - 2008-11-03
291
+     * @return string
292
+     */
293
+    function createXprop() {
295 294
     if( 'xcal' == $this->format )
296
-      return false;
295
+        return false;
297 296
     if( 0 >= count( $this->xprop ))
298
-      return;
297
+        return;
299 298
     $output = null;
300 299
     $toolbox = new calendarComponent();
301 300
     $toolbox->setConfig( 'language', $this->getConfig( 'language' ));
302 301
     $toolbox->setConfig( 'nl',       $this->getConfig( 'nl' ));
303 302
     $toolbox->_createFormat(         $this->getConfig( 'format' ));
304 303
     foreach( $this->xprop as $label => $xpropPart ) {
305
-      if( empty( $xpropPart['value'] )) {
304
+        if( empty( $xpropPart['value'] )) {
306 305
         $output  .= $toolbox->_createElement( $label );
307 306
         continue;
308
-      }
309
-      $attributes = $toolbox->_createParams( $xpropPart['params'], array( 'LANGUAGE' ));
310
-      if( is_array( $xpropPart['value'] )) {
307
+        }
308
+        $attributes = $toolbox->_createParams( $xpropPart['params'], array( 'LANGUAGE' ));
309
+        if( is_array( $xpropPart['value'] )) {
311 310
         foreach( $xpropPart['value'] as $pix => $theXpart )
312
-          $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart );
311
+            $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart );
313 312
         $xpropPart['value']  = implode( ',', $xpropPart['value'] );
314
-      }
315
-      else
313
+        }
314
+        else
316 315
         $xpropPart['value'] = $toolbox->_strrep( $xpropPart['value'] );
317
-      $output    .= $toolbox->_createElement( $label, $attributes, $xpropPart['value'] );
316
+        $output    .= $toolbox->_createElement( $label, $attributes, $xpropPart['value'] );
318 317
     }
319 318
     return $output;
320
-  }
319
+    }
321 320
 /**
322
- * set calendar property x-prop
323
- *
324
- * @author Kjell-Inge Gustafsson <[email protected]>
325
- * @since 2.4.11 - 2008-11-04
326
- * @param string $label
327
- * @param string $value
328
- * @param array $params optional
329
- * @return bool
330
- */
331
-  function setXprop( $label, $value, $params=FALSE ) {
321
+     * set calendar property x-prop
322
+     *
323
+     * @author Kjell-Inge Gustafsson <[email protected]>
324
+     * @since 2.4.11 - 2008-11-04
325
+     * @param string $label
326
+     * @param string $value
327
+     * @param array $params optional
328
+     * @return bool
329
+     */
330
+    function setXprop( $label, $value, $params=FALSE ) {
332 331
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
333 332
     if( empty( $label )) return FALSE;
334 333
     $xprop           = array( 'value' => $value );
@@ -337,325 +336,325 @@  discard block
 block discarded – undo
337 336
     if( !is_array( $this->xprop )) $this->xprop = array();
338 337
     $this->xprop[strtoupper( $label )] = $xprop;
339 338
     return TRUE;
340
-  }
339
+    }
341 340
 /*********************************************************************************/
342 341
 /**
343
- * delete calendar property value
344
- *
345
- * @author Kjell-Inge Gustafsson <[email protected]>
346
- * @since 2.4.5 - 2008-11-14
347
- * @param mixed $propName, bool FALSE => X-property
348
- * @param int @propix, optional, if specific property is wanted in case of multiply occurences
349
- * @return bool, if successfull delete
350
- */
351
-  function deleteProperty( $propName, $propix=FALSE ) {
342
+     * delete calendar property value
343
+     *
344
+     * @author Kjell-Inge Gustafsson <[email protected]>
345
+     * @since 2.4.5 - 2008-11-14
346
+     * @param mixed $propName, bool FALSE => X-property
347
+     * @param int @propix, optional, if specific property is wanted in case of multiply occurences
348
+     * @return bool, if successfull delete
349
+     */
350
+    function deleteProperty( $propName, $propix=FALSE ) {
352 351
     $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';
353 352
     if( !$propix )
354
-      $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
353
+        $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
355 354
     $this->propdelix[$propName] = --$propix;
356 355
     $return = FALSE;
357 356
     switch( $propName ) {
358
-      case 'CALSCALE':
357
+        case 'CALSCALE':
359 358
         if( isset( $this->calscale )) {
360
-          $this->calscale = null;
361
-          $return = TRUE;
359
+            $this->calscale = null;
360
+            $return = TRUE;
362 361
         }
363 362
         break;
364
-      case 'METHOD':
363
+        case 'METHOD':
365 364
         if( isset( $this->method )) {
366
-          $this->method   = null;
367
-          $return = TRUE;
365
+            $this->method   = null;
366
+            $return = TRUE;
368 367
         }
369 368
         break;
370
-      default:
369
+        default:
371 370
         $reduced = array();
372 371
         if( $propName != 'X-PROP' ) {
373
-          if( !isset( $this->xprop[$propName] )) return FALSE;
374
-          foreach( $this->xprop as $k => $a ) {
372
+            if( !isset( $this->xprop[$propName] )) return FALSE;
373
+            foreach( $this->xprop as $k => $a ) {
375 374
             if(( $k != $propName ) && !empty( $a ))
376
-              $reduced[$k] = $a;
377
-          }
375
+                $reduced[$k] = $a;
376
+            }
378 377
         }
379 378
         else {
380
-          if( count( $this->xprop ) <= $propix )  return FALSE;
381
-          $xpropno = 0;
382
-          foreach( $this->xprop as $xpropkey => $xpropvalue ) {
379
+            if( count( $this->xprop ) <= $propix )  return FALSE;
380
+            $xpropno = 0;
381
+            foreach( $this->xprop as $xpropkey => $xpropvalue ) {
383 382
             if( $propix != $xpropno )
384
-              $reduced[$xpropkey] = $xpropvalue;
383
+                $reduced[$xpropkey] = $xpropvalue;
385 384
             $xpropno++;
386
-          }
385
+            }
387 386
         }
388 387
         $this->xprop = $reduced;
389 388
         return TRUE;
390 389
     }
391 390
     return $return;
392
-  }
391
+    }
393 392
 /**
394
- * get calendar property value/params
395
- *
396
- * @author Kjell-Inge Gustafsson <[email protected]>
397
- * @since 2.5.1 - 2008-11-02
398
- * @param string $propName, optional
399
- * @param int @propix, optional, if specific property is wanted in case of multiply occurences
400
- * @param bool $inclParam=FALSE
401
- * @return mixed
402
- */
403
-  function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE ) {
393
+     * get calendar property value/params
394
+     *
395
+     * @author Kjell-Inge Gustafsson <[email protected]>
396
+     * @since 2.5.1 - 2008-11-02
397
+     * @param string $propName, optional
398
+     * @param int @propix, optional, if specific property is wanted in case of multiply occurences
399
+     * @param bool $inclParam=FALSE
400
+     * @return mixed
401
+     */
402
+    function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE ) {
404 403
     $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';
405 404
     if( 'X-PROP' == $propName ) {
406
-      if( !$propix )
405
+        if( !$propix )
407 406
         $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;
408
-      $this->propix[$propName] = --$propix;
407
+        $this->propix[$propName] = --$propix;
409 408
     }
410 409
     switch( $propName ) {
411
-      case 'CALSCALE':
410
+        case 'CALSCALE':
412 411
         return ( !empty( $this->calscale )) ? $this->calscale : null;
413 412
         break;
414
-      case 'METHOD':
413
+        case 'METHOD':
415 414
         return ( !empty( $this->method )) ? $this->method : null;
416 415
         break;
417
-      case 'PRODID':
416
+        case 'PRODID':
418 417
         if( empty( $this->prodid ))
419
-          $this->_makeProdid();
418
+            $this->_makeProdid();
420 419
         return $this->prodid;
421 420
         break;
422
-      case 'VERSION':
421
+        case 'VERSION':
423 422
         return ( !empty( $this->version )) ? $this->version : null;
424 423
         break;
425
-      default:
424
+        default:
426 425
         if( $propName != 'X-PROP' ) {
427
-          if( !isset( $this->xprop[$propName] )) return FALSE;
428
-          return ( $inclParam ) ? array( $propName, $this->xprop[$propName] )
426
+            if( !isset( $this->xprop[$propName] )) return FALSE;
427
+            return ( $inclParam ) ? array( $propName, $this->xprop[$propName] )
429 428
                                 : array( $propName, $this->xprop[$propName]['value'] );
430 429
         }
431 430
         else {
432
-          if( empty( $this->xprop )) return FALSE;
433
-          $xpropno = 0;
434
-          foreach( $this->xprop as $xpropkey => $xpropvalue ) {
431
+            if( empty( $this->xprop )) return FALSE;
432
+            $xpropno = 0;
433
+            foreach( $this->xprop as $xpropkey => $xpropvalue ) {
435 434
             if( $propix == $xpropno )
436
-              return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
435
+                return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
437 436
                                     : array( $xpropkey, $this->xprop[$xpropkey]['value'] );
438 437
             else
439
-              $xpropno++;
440
-          }
441
-          return FALSE; // not found ??
438
+                $xpropno++;
439
+            }
440
+            return FALSE; // not found ??
442 441
         }
443 442
     }
444 443
     return FALSE;
445
-  }
444
+    }
446 445
 /**
447
- * general vcalendar property setting
448
- *
449
- * @author Kjell-Inge Gustafsson <[email protected]>
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
- * @return bool
455
- */
456
-  function setProperty () {
446
+     * general vcalendar property setting
447
+     *
448
+     * @author Kjell-Inge Gustafsson <[email protected]>
449
+     * @since 2.2.13 - 2007-11-04
450
+     * @param mixed $args variable number of function arguments,
451
+     *                    first argument is ALWAYS component name,
452
+     *                    second ALWAYS component value!
453
+     * @return bool
454
+     */
455
+    function setProperty () {
457 456
     $numargs    = func_num_args();
458 457
     if( 1 > $numargs )
459
-      return FALSE;
458
+        return FALSE;
460 459
     $arglist    = func_get_args();
461 460
     $arglist[0] = strtoupper( $arglist[0] );
462 461
     switch( $arglist[0] ) {
463
-      case 'CALSCALE':
462
+        case 'CALSCALE':
464 463
         return $this->setCalscale( $arglist[1] );
465
-      case 'METHOD':
464
+        case 'METHOD':
466 465
         return $this->setMethod( $arglist[1] );
467
-      case 'VERSION':
466
+        case 'VERSION':
468 467
         return $this->setVersion( $arglist[1] );
469
-      default:
468
+        default:
470 469
         if( !isset( $arglist[1] )) $arglist[1] = null;
471 470
         if( !isset( $arglist[2] )) $arglist[2] = null;
472 471
         return $this->setXprop( $arglist[0], $arglist[1], $arglist[2] );
473 472
     }
474 473
     return FALSE;
475
-  }
474
+    }
476 475
 /*********************************************************************************/
477 476
 /**
478
- * get vcalendar config values or * calendar components
479
- *
480
- * @author Kjell-Inge Gustafsson <[email protected]>
481
- * @since 2.4.10 - 2008-10-23
482
- * @param string $config
483
- * @return value
484
- */
485
-  function getConfig( $config ) {
477
+     * get vcalendar config values or * calendar components
478
+     *
479
+     * @author Kjell-Inge Gustafsson <[email protected]>
480
+     * @since 2.4.10 - 2008-10-23
481
+     * @param string $config
482
+     * @return value
483
+     */
484
+    function getConfig( $config ) {
486 485
     switch( strtoupper( $config )) {
487
-      case 'ALLOWEMPTY':
486
+        case 'ALLOWEMPTY':
488 487
         return $this->allowEmpty;
489 488
         break;
490
-      case 'COMPSINFO':
489
+        case 'COMPSINFO':
491 490
         unset( $this->compix );
492 491
         $info = array();
493 492
         foreach( $this->components as $cix => $component ) {
494
-          if( empty( $component )) continue;
495
-          unset( $component->propix );
496
-          $info[$cix]['ordno'] = $cix + 1;
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 );
493
+            if( empty( $component )) continue;
494
+            unset( $component->propix );
495
+            $info[$cix]['ordno'] = $cix + 1;
496
+            $info[$cix]['type']  = $component->objName;
497
+            $info[$cix]['uid']   = $component->getProperty( 'uid' );
498
+            $info[$cix]['props'] = $component->getConfig( 'propinfo' );
499
+            $info[$cix]['sub']   = $component->getConfig( 'compsinfo' );
500
+            unset( $component->propix );
502 501
         }
503 502
         return $info;
504 503
         break;
505
-      case 'DELIMITER':
504
+        case 'DELIMITER':
506 505
         return $this->delimiter;
507 506
         break;
508
-      case 'DIRECTORY':
507
+        case 'DIRECTORY':
509 508
         if( empty( $this->directory ))
510
-          $this->directory = '.';
509
+            $this->directory = '.';
511 510
         return $this->directory;
512 511
         break;
513
-      case 'DIRFILE':
512
+        case 'DIRFILE':
514 513
         return $this->getConfig( 'directory' ).$this->getConfig( 'delimiter' ).$this->getConfig( 'filename' );
515 514
         break;
516
-      case 'FILEINFO':
515
+        case 'FILEINFO':
517 516
         return array( $this->getConfig( 'directory' )
518 517
                     , $this->getConfig( 'filename' )
519 518
                     , $this->getConfig( 'filesize' ));
520 519
         break;
521
-      case 'FILENAME':
520
+        case 'FILENAME':
522 521
         if( empty( $this->filename )) {
523
-          if( 'xcal' == $this->format )
522
+            if( 'xcal' == $this->format )
524 523
             $this->filename = date( 'YmdHis' ).'.xml'; // recommended xcs.. .
525
-          else
524
+            else
526 525
             $this->filename = date( 'YmdHis' ).'.ics';
527 526
         }
528 527
         return $this->filename;
529 528
         break;
530
-      case 'FILESIZE':
529
+        case 'FILESIZE':
531 530
         $size    = 0;
532 531
         if( empty( $this->url )) {
533
-          $dirfile = $this->getConfig( 'dirfile' );
534
-          if( FALSE === ( $size = filesize( $dirfile )))
532
+            $dirfile = $this->getConfig( 'dirfile' );
533
+            if( FALSE === ( $size = filesize( $dirfile )))
535 534
             $size = 0;
536
-          clearstatcache();
535
+            clearstatcache();
537 536
         }
538 537
         return $size;
539 538
         break;
540
-      case 'FORMAT':
539
+        case 'FORMAT':
541 540
         return $this->format;
542 541
         break;
543
-      case 'LANGUAGE':
542
+        case 'LANGUAGE':
544 543
          /* get language for calendar component as defined in [RFC 1766] */
545 544
         return $this->language;
546 545
         break;
547
-      case 'NL':
546
+        case 'NL':
548 547
       case 'NEWLINECHAR':
549 548
         return $this->nl;
550 549
         break;
551
-      case 'UNIQUE_ID':
550
+        case 'UNIQUE_ID':
552 551
         return $this->unique_id;
553 552
         break;
554
-      case 'URL':
553
+        case 'URL':
555 554
         if( !empty( $this->url ))
556
-          return $this->url;
555
+            return $this->url;
557 556
         else
558
-          return FALSE;
557
+            return FALSE;
559 558
         break;
560 559
     }
561
-  }
560
+    }
562 561
 /**
563
- * general vcalendar config setting
564
- *
565
- * @author Kjell-Inge Gustafsson <[email protected]>
566
- * @since 2.4.8 - 2008-10-24
567
- * @param string $config
568
- * @param string $value
569
- * @return void
570
- */
571
-  function setConfig( $config, $value ) {
562
+     * general vcalendar config setting
563
+     *
564
+     * @author Kjell-Inge Gustafsson <[email protected]>
565
+     * @since 2.4.8 - 2008-10-24
566
+     * @param string $config
567
+     * @param string $value
568
+     * @return void
569
+     */
570
+    function setConfig( $config, $value ) {
572 571
     $res = FALSE;
573 572
     switch( strtoupper( $config )) {
574
-      case 'ALLOWEMPTY':
573
+        case 'ALLOWEMPTY':
575 574
         $this->allowEmpty = $value;
576 575
         $subcfg  = array( 'ALLOWEMPTY' => $value );
577 576
         $res = TRUE;
578 577
         break;
579
-      case 'DELIMITER':
578
+        case 'DELIMITER':
580 579
         $this->delimiter = $value;
581 580
         return TRUE;
582 581
         break;
583
-      case 'DIRECTORY':
582
+        case 'DIRECTORY':
584 583
         $value   = trim( $value );
585 584
         $nl      = $this->getConfig('delimiter');
586 585
         if( $nl == substr( $value, ( 0 - strlen( $nl ))))
587
-          $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl )));
586
+            $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl )));
588 587
         if( is_dir( $value )) {
589 588
             /* local directory */
590
-          clearstatcache();
591
-          $this->directory = $value;
592
-          $this->url       = null;
593
-          return TRUE;
589
+            clearstatcache();
590
+            $this->directory = $value;
591
+            $this->url       = null;
592
+            return TRUE;
594 593
         }
595 594
         else
596
-          return FALSE;
595
+            return FALSE;
597 596
         break;
598
-      case 'FILENAME':
597
+        case 'FILENAME':
599 598
         $value   = trim( $value );
600 599
         if( !empty( $this->url )) {
601 600
             /* remote directory+file - URL */
602
-          $this->filename = $value;
603
-          return TRUE;
601
+            $this->filename = $value;
602
+            return TRUE;
604 603
         }
605 604
         $dirfile = $this->getConfig( 'directory' ).$this->getConfig( 'delimiter' ).$value;
606 605
         if( file_exists( $dirfile )) {
607 606
             /* local existing file */
608
-          if( is_readable( $dirfile ) || is_writable( $dirfile )) {
607
+            if( is_readable( $dirfile ) || is_writable( $dirfile )) {
609 608
             clearstatcache();
610 609
             $this->filename = $value;
611 610
             return TRUE;
612
-          }
613
-          else
611
+            }
612
+            else
614 613
             return FALSE;
615 614
         }
616 615
         elseif( FALSE !== touch( $dirfile )) {
617 616
             /* new local file created */
618
-          $this->filename = $value;
619
-          return TRUE;
617
+            $this->filename = $value;
618
+            return TRUE;
620 619
         }
621 620
         else
622
-          return FALSE;
621
+            return FALSE;
623 622
         break;
624
-      case 'FORMAT':
623
+        case 'FORMAT':
625 624
         $value   = trim( $value );
626 625
         if( 'xcal' == strtolower( $value )) {
627
-          $this->format             = 'xcal';
628
-          $this->attributeDelimiter = $this->nl;
629
-          $this->valueInit          = null;
626
+            $this->format             = 'xcal';
627
+            $this->attributeDelimiter = $this->nl;
628
+            $this->valueInit          = null;
630 629
         }
631 630
         else {
632
-          $this->format             = null;
633
-          $this->attributeDelimiter = ';';
634
-          $this->valueInit          = ':';
631
+            $this->format             = null;
632
+            $this->attributeDelimiter = ';';
633
+            $this->valueInit          = ':';
635 634
         }
636 635
         $subcfg  = array( 'FORMAT' => $value );
637 636
         $res = TRUE;
638 637
         break;
639
-      case 'LANGUAGE':
638
+        case 'LANGUAGE':
640 639
          // set language for calendar component as defined in [RFC 1766]
641 640
         $value   = trim( $value );
642 641
         $this->language = $value;
643 642
         $subcfg  = array( 'LANGUAGE' => $value );
644 643
         $res = TRUE;
645 644
         break;
646
-      case 'NL':
645
+        case 'NL':
647 646
       case 'NEWLINECHAR':
648 647
         $this->nl = $value;
649 648
         $subcfg  = array( 'NL' => $value );
650 649
         $res = TRUE;
651 650
         break;
652
-      case 'UNIQUE_ID':
651
+        case 'UNIQUE_ID':
653 652
         $value   = trim( $value );
654 653
         $this->unique_id = $value;
655 654
         $subcfg  = array( 'UNIQUE_ID' => $value );
656 655
         $res = TRUE;
657 656
         break;
658
-      case 'URL':
657
+        case 'URL':
659 658
             /* remote file - URL */
660 659
         $value     = trim( $value );
661 660
         $value     = str_replace( 'HTTP://',   'http://', $value );
@@ -669,151 +668,151 @@  discard block
 block discarded – undo
669 668
     }
670 669
     if( !$res ) return FALSE;
671 670
     if( isset( $subcfg ) && !empty( $this->components )) {
672
-      foreach( $subcfg as $cfgkey => $cfgvalue ) {
671
+        foreach( $subcfg as $cfgkey => $cfgvalue ) {
673 672
         foreach( $this->components as $cix => $component ) {
674
-          $res = $component->setConfig( $cfgkey, $cfgvalue );
675
-          if( !$res )
673
+            $res = $component->setConfig( $cfgkey, $cfgvalue );
674
+            if( !$res )
676 675
             break 2;
677
-          $this->components[$cix] = $component->copy(); // PHP4 compliant
676
+            $this->components[$cix] = $component->copy(); // PHP4 compliant
677
+        }
678 678
         }
679
-      }
680 679
     }
681 680
     return $res;
682
-  }
681
+    }
683 682
 /*********************************************************************************/
684 683
 /**
685
- * add calendar component to container
686
- *
687
- * alias to setComponent
688
- *
689
- * @author Kjell-Inge Gustafsson <[email protected]>
690
- * @since 1.x.x - 2007-04-24
691
- * @param object $component calendar component
692
- * @return void
693
- */
694
-  function addComponent( $component ) {
684
+     * add calendar component to container
685
+     *
686
+     * alias to setComponent
687
+     *
688
+     * @author Kjell-Inge Gustafsson <[email protected]>
689
+     * @since 1.x.x - 2007-04-24
690
+     * @param object $component calendar component
691
+     * @return void
692
+     */
693
+    function addComponent( $component ) {
695 694
     $this->setComponent( $component );
696
-  }
695
+    }
697 696
 /**
698
- * delete calendar component from container
699
- *
700
- * @author Kjell-Inge Gustafsson <[email protected]>
701
- * @since 2.4.10 - 2008-08-05
702
- * @param mixed $arg1 ordno / component type / component uid
703
- * @param mixed $arg2 optional, ordno if arg1 = component type
704
- * @return void
705
- */
706
-  function deleteComponent( $arg1, $arg2=FALSE  ) {
697
+     * delete calendar component from container
698
+     *
699
+     * @author Kjell-Inge Gustafsson <[email protected]>
700
+     * @since 2.4.10 - 2008-08-05
701
+     * @param mixed $arg1 ordno / component type / component uid
702
+     * @param mixed $arg2 optional, ordno if arg1 = component type
703
+     * @return void
704
+     */
705
+    function deleteComponent( $arg1, $arg2=FALSE  ) {
707 706
     $argType = $index = null;
708 707
     if ( ctype_digit( (string) $arg1 )) {
709
-      $argType = 'INDEX';
710
-      $index   = (int) $arg1 - 1;
708
+        $argType = 'INDEX';
709
+        $index   = (int) $arg1 - 1;
711 710
     }
712 711
     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
+        $argType = strtolower( $arg1 );
713
+        $index   = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0;
715 714
     }
716 715
     $cix1dC = 0;
717 716
     foreach ( $this->components as $cix => $component) {
718
-      if( empty( $component )) continue;
719
-      unset( $component->propix );
720
-      if(( 'INDEX' == $argType ) && ( $index == $cix )) {
717
+        if( empty( $component )) continue;
718
+        unset( $component->propix );
719
+        if(( 'INDEX' == $argType ) && ( $index == $cix )) {
721 720
         unset( $this->components[$cix] );
722 721
         return TRUE;
723
-      }
724
-      elseif( $argType == $component->objName ) {
722
+        }
723
+        elseif( $argType == $component->objName ) {
725 724
         if( $index == $cix1dC ) {
726
-          unset( $this->components[$cix] );
727
-          return TRUE;
725
+            unset( $this->components[$cix] );
726
+            return TRUE;
728 727
         }
729 728
         $cix1dC++;
730
-      }
731
-      elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
729
+        }
730
+        elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
732 731
         unset( $this->components[$cix] );
733 732
         return TRUE;
734
-      }
733
+        }
735 734
     }
736 735
     return FALSE;
737
-  }
736
+    }
738 737
 /**
739
- * get calendar component from container
740
- *
741
- * @author Kjell-Inge Gustafsson <[email protected]>
742
- * @since 2.4.10 - 2008-08-06
743
- * @param mixed $arg1 optional, ordno/component type/ component uid
744
- * @param mixed $arg2 optional, ordno if arg1 = component type
745
- * @return object
746
- */
747
-  function getComponent( $arg1=FALSE, $arg2=FALSE ) {
738
+     * get calendar component from container
739
+     *
740
+     * @author Kjell-Inge Gustafsson <[email protected]>
741
+     * @since 2.4.10 - 2008-08-06
742
+     * @param mixed $arg1 optional, ordno/component type/ component uid
743
+     * @param mixed $arg2 optional, ordno if arg1 = component type
744
+     * @return object
745
+     */
746
+    function getComponent( $arg1=FALSE, $arg2=FALSE ) {
748 747
     $index = $argType = null;
749 748
     if ( !$arg1 ) {
750
-      $argType = 'INDEX';
751
-      $index   = $this->compix['INDEX'] =
749
+        $argType = 'INDEX';
750
+        $index   = $this->compix['INDEX'] =
752 751
         ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1;
753 752
     }
754 753
     elseif ( ctype_digit( (string) $arg1 )) {
755
-      $argType = 'INDEX';
756
-      $index   = (int) $arg1;
757
-      unset( $this->compix );
754
+        $argType = 'INDEX';
755
+        $index   = (int) $arg1;
756
+        unset( $this->compix );
758 757
     }
759 758
     elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
760
-      unset( $this->compix['INDEX'] );
761
-      $argType = strtolower( $arg1 );
762
-      if( !$arg2 )
759
+        unset( $this->compix['INDEX'] );
760
+        $argType = strtolower( $arg1 );
761
+        if( !$arg2 )
763 762
         $index = $this->compix[$argType] =
764 763
         ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1;
765
-      else
764
+        else
766 765
         $index = (int) $arg2;
767 766
     }
768 767
     $index  -= 1;
769 768
     $ckeys =  array_keys( $this->components );
770 769
     if( !empty( $index) && ( $index > end(  $ckeys )))
771
-      return FALSE;
770
+        return FALSE;
772 771
     $cix1gC = 0;
773 772
     foreach ( $this->components as $cix => $component) {
774
-      if( empty( $component )) continue;
775
-      unset( $component->propix );
776
-      if(( 'INDEX' == $argType ) && ( $index == $cix ))
773
+        if( empty( $component )) continue;
774
+        unset( $component->propix );
775
+        if(( 'INDEX' == $argType ) && ( $index == $cix ))
777 776
         return $component->copy();
778
-      elseif( $argType == $component->objName ) {
779
-         if( $index == $cix1gC )
780
-           return $component->copy();
781
-         $cix1gC++;
782
-      }
783
-      elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
777
+        elseif( $argType == $component->objName ) {
778
+            if( $index == $cix1gC )
779
+            return $component->copy();
780
+            $cix1gC++;
781
+        }
782
+        elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
784 783
         unset( $component->propix );
785 784
         return $component->copy();
786
-      }
785
+        }
787 786
     }
788 787
             /* not found.. . */
789 788
     unset( $this->compix );
790 789
     return FALSE;
791
-  }
790
+    }
792 791
 /**
793
- * select components from calendar on date basis
794
- *
795
- * Ensure DTSTART is set for every component.
796
- * No date controls occurs.
797
- *
798
- * @author Kjell-Inge Gustafsson <[email protected]>
799
- * @since 2.4.16 - 2008-10-18
800
- * @param int $startY optional,  start Year, default current Year
801
- * @param int $startM optional,  start Month, default current Month
802
- * @param int $startD optional,  start Day, default current Day
803
- * @param int $endY optional,    end Year, default $startY
804
- * @param int $endY optional,    end Month, default $startM
805
- * @param int $endY optional,    end Day, default $startD
806
- * @param mixed $cType optional, calendar component type(-s), default FALSE=all else string/array type(-s)
807
- * @param bool $flat optional,   FALSE (default) => output : array[Year][Month][Day][]
808
- *                               TRUE => output : array[] (ignores split)
809
- * @param bool $any optional,    TRUE (default) - select component that take place within period
810
- *                               FALSE - only components that starts within period
811
- * @param bool $split optional,  TRUE (default) - one component copy every day it take place during the
812
- *                                       period (implies flat=FALSE)
813
- *                               FALSE - one occurance of component only in output array</tr>
814
- * @return array or FALSE
815
- */
816
-  function selectComponents( $startY=FALSE, $startM=FALSE, $startD=FALSE, $endY=FALSE, $endM=FALSE, $endD=FALSE, $cType=FALSE, $flat=FALSE, $any=TRUE, $split=TRUE ) {
792
+     * select components from calendar on date basis
793
+     *
794
+     * Ensure DTSTART is set for every component.
795
+     * No date controls occurs.
796
+     *
797
+     * @author Kjell-Inge Gustafsson <[email protected]>
798
+     * @since 2.4.16 - 2008-10-18
799
+     * @param int $startY optional,  start Year, default current Year
800
+     * @param int $startM optional,  start Month, default current Month
801
+     * @param int $startD optional,  start Day, default current Day
802
+     * @param int $endY optional,    end Year, default $startY
803
+     * @param int $endY optional,    end Month, default $startM
804
+     * @param int $endY optional,    end Day, default $startD
805
+     * @param mixed $cType optional, calendar component type(-s), default FALSE=all else string/array type(-s)
806
+     * @param bool $flat optional,   FALSE (default) => output : array[Year][Month][Day][]
807
+     *                               TRUE => output : array[] (ignores split)
808
+     * @param bool $any optional,    TRUE (default) - select component that take place within period
809
+     *                               FALSE - only components that starts within period
810
+     * @param bool $split optional,  TRUE (default) - one component copy every day it take place during the
811
+     *                                       period (implies flat=FALSE)
812
+     *                               FALSE - one occurance of component only in output array</tr>
813
+     * @return array or FALSE
814
+     */
815
+    function selectComponents( $startY=FALSE, $startM=FALSE, $startD=FALSE, $endY=FALSE, $endM=FALSE, $endD=FALSE, $cType=FALSE, $flat=FALSE, $any=TRUE, $split=TRUE ) {
817 816
             /* check  if empty calendar */
818 817
     if( 0 >= count( $this->components )) return FALSE;
819 818
             /* check default dates */
@@ -828,54 +827,54 @@  discard block
 block discarded – undo
828 827
             /* check component types */
829 828
     $validTypes = array('vevent', 'vtodo', 'vjournal', 'vfreebusy' );
830 829
     if( is_array( $cType )) {
831
-      foreach( $cType as $cix => $theType ) {
830
+        foreach( $cType as $cix => $theType ) {
832 831
         $cType[$cix] = $theType = strtolower( $theType );
833 832
         if( !in_array( $theType, $validTypes ))
834
-          $cType[$cix] = 'vevent';
835
-      }
836
-      $cType = array_unique( $cType );
833
+            $cType[$cix] = 'vevent';
834
+        }
835
+        $cType = array_unique( $cType );
837 836
     }
838 837
     elseif( !empty( $cType )) {
839
-      $cType = strtolower( $cType );
840
-      if( !in_array( $cType, $validTypes ))
838
+        $cType = strtolower( $cType );
839
+        if( !in_array( $cType, $validTypes ))
841 840
         $cType = array( 'vevent' );
842
-      else
841
+        else
843 842
         $cType = array( $cType );
844 843
     }
845 844
     else
846
-      $cType = $validTypes;
845
+        $cType = $validTypes;
847 846
     if( 0 >= count( $cType ))
848
-      $cType = $validTypes;
847
+        $cType = $validTypes;
849 848
             /* iterate components */
850 849
     $result = array();
851 850
     foreach ( $this->components as $cix => $component ) {
852
-      if( empty( $component )) continue;
853
-      unset( $component->propix, $start );
851
+        if( empty( $component )) continue;
852
+        unset( $component->propix, $start );
854 853
             /* deselect unvalid type components */
855
-      if( !in_array( $component->objName, $cType )) continue;
854
+        if( !in_array( $component->objName, $cType )) continue;
856 855
             /* deselect components without dtstart set */
857
-      if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) continue;
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';
856
+        if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) continue;
857
+        $dtendExist = $dueExist = $durationExist = $endAllDayEvent = FALSE;
858
+        unset( $end, $startWdate, $endWdate, $rdurWsecs, $rdur, $exdatelist, $workstart, $workend ); // clean up
859
+        $startWdate = $component->_date2timestamp( $start );
860
+        $startDateFormat = ( isset( $start['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d';
862 861
             /* get end date from dtend/due/duration properties */
863
-      $end = $component->getProperty( 'dtend' );
864
-      if( !empty( $end )) {
862
+        $end = $component->getProperty( 'dtend' );
863
+        if( !empty( $end )) {
865 864
         $dtendExist = TRUE;
866 865
         $endDateFormat = ( isset( $end['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d';
867
-      }
868
-   // if( !empty($end))  echo 'selectComp 1 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
869
-      if( empty($end) && ( $component->objName == 'vtodo' )) {
866
+        }
867
+    // if( !empty($end))  echo 'selectComp 1 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
868
+        if( empty($end) && ( $component->objName == 'vtodo' )) {
870 869
         $end = $component->getProperty( 'due' );
871 870
         if( !empty( $end )) {
872
-          $dueExist = TRUE;
873
-          $endDateFormat = ( isset( $end['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d';
871
+            $dueExist = TRUE;
872
+            $endDateFormat = ( isset( $end['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d';
874 873
         }
875
-   // if( !empty($end))  echo 'selectComp 2 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
876
-      }
877
-      if( !empty( $end ) && !isset( $end['hour'] )) {
878
-          /* a DTEND without time part regards an event that ends the day before,
874
+    // if( !empty($end))  echo 'selectComp 2 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
875
+        }
876
+        if( !empty( $end ) && !isset( $end['hour'] )) {
877
+            /* a DTEND without time part regards an event that ends the day before,
879 878
              for an all-day event DTSTART=20071201 DTEND=20071202 (taking place 20071201!!! */
880 879
         $endAllDayEvent = TRUE;
881 880
         $endWdate = mktime( 23, 59, 59, $end['month'], ($end['day'] - 1), $end['year'] );
@@ -884,594 +883,594 @@  discard block
 block discarded – undo
884 883
         $end['day']   = date( 'd', $endWdate );
885 884
         $end['hour']  = 23;
886 885
         $end['min']   = $end['sec'] = 59;
887
-   // if( !empty($end))  echo 'selectComp 3 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
888
-      }
889
-      if( empty( $end )) {
886
+    // if( !empty($end))  echo 'selectComp 3 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
887
+        }
888
+        if( empty( $end )) {
890 889
         $end = $component->getProperty( 'duration', FALSE, FALSE, TRUE );// in dtend (array) format
891 890
         if( !empty( $end ))
892
-          $durationExist = TRUE;
893
-   // if( !empty($end))  echo 'selectComp 4 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
894
-      }
895
-      if( empty( $end )) { // assume one day duration if missing end date
891
+            $durationExist = TRUE;
892
+    // if( !empty($end))  echo 'selectComp 4 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
893
+        }
894
+        if( empty( $end )) { // assume one day duration if missing end date
896 895
         $end = array( 'year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'hour' => 23, 'min' => 59, 'sec' => 59 );
897
-   // if( isset($end))  echo 'selectComp 5 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
898
-      }
899
-      $endWdate = $component->_date2timestamp( $end );
900
-      if( $endWdate < $startWdate ) { // MUST be after start date!!
896
+    // if( isset($end))  echo 'selectComp 5 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
897
+        }
898
+        $endWdate = $component->_date2timestamp( $end );
899
+        if( $endWdate < $startWdate ) { // MUST be after start date!!
901 900
         $end = array( 'year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'hour' => 23, 'min' => 59, 'sec' => 59 );
902 901
         $endWdate = $component->_date2timestamp( $end );
903
-      }
904
-      $rdurWsecs  = $endWdate - $startWdate; // compute component duration in seconds
905
-      $rdur       = $component->_date2duration( $start, $end ); // compute component duration, array
902
+        }
903
+        $rdurWsecs  = $endWdate - $startWdate; // compute component duration in seconds
904
+        $rdur       = $component->_date2duration( $start, $end ); // compute component duration, array
906 905
             /* make a list of optional exclude dates for component occurence from exrule and exdate */
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
906
+        $exdatelist = array();
907
+        $workstart  = $component->_timestamp2date(( $startDate - $rdurWsecs ), 6);
908
+        $workend    = $component->_timestamp2date(( $endDate + $rdurWsecs ), 6);
909
+        while( FALSE !== ( $exrule = $component->getProperty( 'exrule' )))    // check exrule
911 910
         $component->_recur2date( $exdatelist, $exrule, $start, $workstart, $workend );
912
-      while( FALSE !== ( $exdate = $component->getProperty( 'exdate' ))) {  // check exdate
911
+        while( FALSE !== ( $exdate = $component->getProperty( 'exdate' ))) {  // check exdate
913 912
         foreach( $exdate as $theExdate ) {
914
-          $exWdate = $component->_date2timestamp( $theExdate );
915
-          if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate ))
913
+            $exWdate = $component->_date2timestamp( $theExdate );
914
+            if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate ))
916 915
             $exdatelist[$exWdate] = TRUE;
917 916
         }
918
-      }
917
+        }
919 918
             /* if 'any' components, check repeating components, removing all excluding dates */
920
-      if( TRUE === $any ) {
919
+        if( TRUE === $any ) {
921 920
             /* make a list of optional repeating dates for component occurence, rrule, rdate */
922 921
         $recurlist = array();
923 922
         while( FALSE !== ( $rrule = $component->getProperty( 'rrule' )))    // check rrule
924
-          $component->_recur2date( $recurlist, $rrule, $start, $workstart, $workend );
923
+            $component->_recur2date( $recurlist, $rrule, $start, $workstart, $workend );
925 924
         foreach( $recurlist as $recurkey => $recurvalue ) // key=match date as timestamp
926
-          $recurlist[$recurkey] = $rdurWsecs; // add duration in seconds
925
+            $recurlist[$recurkey] = $rdurWsecs; // add duration in seconds
927 926
         while( FALSE !== ( $rdate = $component->getProperty( 'rdate' ))) {  // check rdate
928
-          foreach( $rdate as $theRdate ) {
927
+            foreach( $rdate as $theRdate ) {
929 928
             if( is_array( $theRdate ) && ( 2 == count( $theRdate )) &&  // all days within PERIOD
930 929
                    array_key_exists( '0', $theRdate ) &&  array_key_exists( '1', $theRdate )) {
931
-              $rstart = $component->_date2timestamp( $theRdate[0] );
932
-              if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate ))
930
+                $rstart = $component->_date2timestamp( $theRdate[0] );
931
+                if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate ))
933 932
                 continue;
934
-              if( isset( $theRdate[1]['year'] )) // date-date period
933
+                if( isset( $theRdate[1]['year'] )) // date-date period
935 934
                 $rend = $component->_date2timestamp( $theRdate[1] );
936
-              else {                             // date-duration period
935
+                else {                             // date-duration period
937 936
                 $rend = $component->duration2date( $theRdate[0], $theRdate[1] );
938 937
                 $rend = $component->_date2timestamp( $rend );
939
-              }
940
-              if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart ))
938
+                }
939
+                if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart ))
941 940
                 $recurlist[$rstart] = ( $rstart - $rend ); // set start date + rdate duration in seconds
942 941
             } // PERIOD end
943 942
             else { // single date
944
-              $theRdate = $component->_date2timestamp( $theRdate );
945
-              if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate ))
943
+                $theRdate = $component->_date2timestamp( $theRdate );
944
+                if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate ))
946 945
                 $recurlist[$theRdate] = $rdurWsecs; // set start date + event duration in seconds
947 946
             }
948
-          }
947
+            }
949 948
         }
950 949
         if( 0 < count( $recurlist )) {
951
-          ksort( $recurlist );
952
-          foreach( $recurlist as $recurkey => $durvalue ) {
950
+            ksort( $recurlist );
951
+            foreach( $recurlist as $recurkey => $durvalue ) {
953 952
             if((( $startDate - $rdurWsecs ) > $recurkey ) || ( $endDate < $recurkey )) // not within period
954
-              continue;
953
+                continue;
955 954
             if( isset( $exdatelist[$recurkey] )) // check excluded dates
956
-              continue;
955
+                continue;
957 956
             if( $startWdate >= $recurkey ) // exclude component start date
958
-              continue;
957
+                continue;
959 958
             $component2   = $component->copy();
960 959
             $rstart       = $component2->_timestamp2date( $recurkey, 6);
961 960
             $datevalue    = $rstart['month'].'/'.$rstart['day'].'/'.$rstart['year'];
962 961
             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
+                $datevalue .= ( isset( $rstart['hour'] )) ? ' '.$rstart['hour'] : ' 00';
963
+                $datevalue .= ( isset( $rstart['min'] ))  ? ':'.$rstart['min']  : ':00';
964
+                $datevalue .= ( isset( $rstart['sec'] ))  ? ':'.$rstart['sec']  : ':00';
966 965
             }
967 966
             $datestring = date( $startDateFormat, strtotime( $datevalue ));
968 967
             if( isset( $start['tz'] ))
969
-              $datestring .= ' '.$start['tz'];
968
+                $datestring .= ' '.$start['tz'];
970 969
             $component2->setProperty( 'X-CURRENT-DTSTART', $datestring );
971 970
             $rend   = $component2->_timestamp2date(( $recurkey + $durvalue ), 6);
972 971
             if( $dtendExist || $dueExist ) {
973
-              if( $endAllDayEvent ) {
972
+                if( $endAllDayEvent ) {
974 973
                 $rend2 = mktime( 0, 0, 0, $rend['month'], ($rend['day'] + 1), $rend['year'] );
975 974
                 $datevalue  = date( 'm', $rend2 ).'/'.date( 'd', $rend2 ).'/'.date( 'Y', $rend2 );
976
-              }
977
-              else {
975
+                }
976
+                else {
978 977
                 $datevalue  = $rend['month'].'/'.$rend['day'].'/'.$rend['year'];
979 978
                 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
+                    $datevalue .= ( isset( $rend['hour'] )) ? ' '.$rend['hour'] : ' 00';
980
+                    $datevalue .= ( isset( $rend['min'] ))  ? ':'.$rend['min']  : ':00';
981
+                    $datevalue .= ( isset( $rend['sec'] ))  ? ':'.$rend['sec']  : ':00';
983 982
                 }
984
-              }
985
-              $datestring = date( $endDateFormat, strtotime( $datevalue ));
986
-              if( isset( $end['tz'] ))
983
+                }
984
+                $datestring = date( $endDateFormat, strtotime( $datevalue ));
985
+                if( isset( $end['tz'] ))
987 986
                 $datestring .= ' '.$end['tz'];
988
-              if( $dtendExist )
987
+                if( $dtendExist )
989 988
                 $component2->setProperty( 'X-CURRENT-DTEND', $datestring );
990
-              elseif( $dueExist )
989
+                elseif( $dueExist )
991 990
                 $component2->setProperty( 'X-CURRENT-DUE', $datestring );
992 991
             }
993 992
             $rend   = $component2->_date2timestamp( $rend );
994 993
             $rstart = $recurkey;
995 994
             /* add repeating components within valid dates to output array, only start date */
996 995
             if( $flat )
997
-              $result[] = $component2->copy(); // copy to output
996
+                $result[] = $component2->copy(); // copy to output
998 997
             elseif( $split ) {
999
-              if( $rend > $endDate )
998
+                if( $rend > $endDate )
1000 999
                 $rend = $endDate;
1001
-              while( $rstart <= $rend ) { // iterate
1000
+                while( $rstart <= $rend ) { // iterate
1002 1001
                 $wd = getdate( $rstart );
1003 1002
                 if(( $rstart > $startDate ) &&      // date after dtstart
1004 1003
                     !isset( $exdatelist[$rstart] )) // check exclude date
1005
-                  $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output
1004
+                    $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output
1006 1005
                 $rstart += ( 24*60*60 ); // step one day
1007
-              }
1006
+                }
1008 1007
             }
1009 1008
             elseif(( $rstart >= $startDate ) &&     // date within period
1010 1009
                   !isset( $exdatelist[$rstart] )) { // check exclude date
1011
-              $wd = getdate( $rstart );
1012
-              $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output
1010
+                $wd = getdate( $rstart );
1011
+                $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output
1012
+            }
1013 1013
             }
1014
-          }
1015 1014
         }
1016 1015
             /* deselect components with startdate/enddate not within period */
1017 1016
         if(( $endWdate < $startDate ) || ( $startWdate > $endDate )) continue;
1018
-      }
1017
+        }
1019 1018
             /* deselect components with startdate not within period */
1020
-      elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) continue;
1019
+        elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) continue;
1021 1020
             /* add selected components within valid dates to output array */
1022
-      if( $flat )
1021
+        if( $flat )
1023 1022
         $result[] = $component->copy(); // copy to output;
1024
-      elseif( $split ) {
1023
+        elseif( $split ) {
1025 1024
         if( $endWdate > $endDate )
1026
-          $endWdate = $endDate;     // use period end date
1025
+            $endWdate = $endDate;     // use period end date
1027 1026
         if( !isset( $exdatelist[$startWdate] ))  { // check excluded dates
1028
-          if( $startWdate < $startDate )
1027
+            if( $startWdate < $startDate )
1029 1028
             $startWdate = $startDate; // use period start date
1030
-          while( $startWdate <= $endWdate ) { // iterate
1029
+            while( $startWdate <= $endWdate ) { // iterate
1031 1030
             $wd = getdate( $startWdate );
1032 1031
             $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output
1033 1032
             $startWdate += ( 24*60*60 ); // step one day
1034
-          }
1033
+            }
1035 1034
         }
1036
-      } // use component date
1037
-      elseif( !isset( $exdatelist[$startWdate] ) &&   // check excluded dates
1035
+        } // use component date
1036
+        elseif( !isset( $exdatelist[$startWdate] ) &&   // check excluded dates
1038 1037
             ( $startWdate >= $startDate )) {          // within period
1039 1038
         $wd = getdate( $startWdate );
1040 1039
         $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output
1041
-      }
1040
+        }
1042 1041
     }
1043 1042
     if( 0 >= count( $result )) return FALSE;
1044 1043
     elseif( !$flat ) {
1045
-      foreach( $result as $y => $yeararr ) {
1044
+        foreach( $result as $y => $yeararr ) {
1046 1045
         foreach( $yeararr as $m => $montharr ) {
1047
-          ksort( $result[$y][$m] );
1046
+            ksort( $result[$y][$m] );
1048 1047
         }
1049 1048
         ksort( $result[$y] );
1050
-      }
1051
-      ksort( $result );
1049
+        }
1050
+        ksort( $result );
1052 1051
     }
1053 1052
     return $result;
1054
-  }
1053
+    }
1055 1054
 /**
1056
- * add calendar component to container
1057
- *
1058
- * @author Kjell-Inge Gustafsson <[email protected]>
1059
- * @since 2.4.10 - 2008-08-06
1060
- * @param object $component calendar component
1061
- * @param mixed $arg1 optional, ordno/component type/ component uid
1062
- * @param mixed $arg2 optional, ordno if arg1 = component type
1063
- * @return void
1064
- */
1065
-  function setComponent( $component, $arg1=FALSE, $arg2=FALSE  ) {
1055
+     * add calendar component to container
1056
+     *
1057
+     * @author Kjell-Inge Gustafsson <[email protected]>
1058
+     * @since 2.4.10 - 2008-08-06
1059
+     * @param object $component calendar component
1060
+     * @param mixed $arg1 optional, ordno/component type/ component uid
1061
+     * @param mixed $arg2 optional, ordno if arg1 = component type
1062
+     * @return void
1063
+     */
1064
+    function setComponent( $component, $arg1=FALSE, $arg2=FALSE  ) {
1066 1065
     if( '' >= $component->getConfig( 'language'))
1067
-      $component->setConfig( 'language',  $this->getConfig( 'language' ));
1066
+        $component->setConfig( 'language',  $this->getConfig( 'language' ));
1068 1067
     $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
1069 1068
     $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
1070 1069
     $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
1071 1070
     $component->setConfig( 'format',      $this->getConfig( 'format' ));
1072 1071
     if( !in_array( $component->objName, array( 'valarm', 'vtimezone' ))) {
1073
-      unset( $component->propix );
1072
+        unset( $component->propix );
1074 1073
             /* make sure dtstamp and uid is set */
1075
-      $dummy1 = $component->getProperty( 'dtstamp' );
1076
-      $dummy2 = $component->getProperty( 'uid' );
1074
+        $dummy1 = $component->getProperty( 'dtstamp' );
1075
+        $dummy2 = $component->getProperty( 'uid' );
1077 1076
     }
1078 1077
     if( !$arg1 ) {
1079
-      $this->components[] = $component->copy();
1080
-      return TRUE;
1078
+        $this->components[] = $component->copy();
1079
+        return TRUE;
1081 1080
     }
1082 1081
     $argType = $index = null;
1083 1082
     if ( ctype_digit( (string) $arg1 )) {
1084
-      $argType = 'INDEX';
1085
-      $index   = (int) $arg1 - 1;
1083
+        $argType = 'INDEX';
1084
+        $index   = (int) $arg1 - 1;
1086 1085
     }
1087 1086
     elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
1088
-      $argType = strtolower( $arg1 );
1089
-      $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0;
1087
+        $argType = strtolower( $arg1 );
1088
+        $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0;
1090 1089
     }
1091 1090
     $cix1sC = 0;
1092 1091
     foreach ( $this->components as $cix => $component2) {
1093
-      if( empty( $component2 )) continue;
1094
-      unset( $component2->propix );
1095
-      if(( 'INDEX' == $argType ) && ( $index == $cix )) {
1092
+        if( empty( $component2 )) continue;
1093
+        unset( $component2->propix );
1094
+        if(( 'INDEX' == $argType ) && ( $index == $cix )) {
1096 1095
         $this->components[$cix] = $component->copy();
1097 1096
         return TRUE;
1098
-      }
1099
-      elseif( $argType == $component2->objName ) {
1097
+        }
1098
+        elseif( $argType == $component2->objName ) {
1100 1099
         if( $index == $cix1sC ) {
1101
-          $this->components[$cix] = $component->copy();
1102
-          return TRUE;
1100
+            $this->components[$cix] = $component->copy();
1101
+            return TRUE;
1103 1102
         }
1104 1103
         $cix1sC++;
1105
-      }
1106
-      elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) {
1104
+        }
1105
+        elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) {
1107 1106
         $this->components[$cix] = $component->copy();
1108 1107
         return TRUE;
1109
-      }
1108
+        }
1110 1109
     }
1111 1110
             /* not found.. . insert last in chain anyway .. .*/
1112 1111
     $this->components[] = $component->copy();
1113 1112
     return TRUE;
1114
-  }
1113
+    }
1115 1114
 /**
1116
- * sort iCal compoments, only local date sort
1117
- *
1118
- * ascending sort on properties (if exist) x-current-dtstart, dtstart,
1119
- * x-current-dtend, dtend, x-current-due, due, duration, created, dtstamp, uid
1120
- *
1121
- * @author Kjell-Inge Gustafsson <[email protected]>
1122
- * @since 2.4.10 - 2008-09-24
1123
- * @return sort param
1124
- *
1125
- */
1126
-  function sort() {
1115
+     * sort iCal compoments, only local date sort
1116
+     *
1117
+     * ascending sort on properties (if exist) x-current-dtstart, dtstart,
1118
+     * x-current-dtend, dtend, x-current-due, due, duration, created, dtstamp, uid
1119
+     *
1120
+     * @author Kjell-Inge Gustafsson <[email protected]>
1121
+     * @since 2.4.10 - 2008-09-24
1122
+     * @return sort param
1123
+     *
1124
+     */
1125
+    function sort() {
1127 1126
     if( is_array( $this->components )) {
1128
-      $this->_sortkeys = array( 'year', 'month', 'day', 'hour', 'min', 'sec' );
1129
-      usort( $this->components, array( $this, '_cmpfcn' ));
1127
+        $this->_sortkeys = array( 'year', 'month', 'day', 'hour', 'min', 'sec' );
1128
+        usort( $this->components, array( $this, '_cmpfcn' ));
1130 1129
     }
1131
-  }
1132
-  function _cmpfcn( $a, $b ) {
1130
+    }
1131
+    function _cmpfcn( $a, $b ) {
1133 1132
     if( empty( $a ))                                   return -1;
1134 1133
     if( empty( $b ))                                   return  1;
1135 1134
     if(  'vtimezone' == $a->objName)                   return -1;
1136 1135
     if(  'vtimezone' == $b->objName)                   return  1;
1137 1136
     $astart = ( isset( $a->xprop['X-CURRENT-DTSTART']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTSTART']['value'] ) : null;
1138 1137
     if( empty( $astart ) && isset( $a->dtstart['value'] ))
1139
-      $astart = & $a->dtstart['value'];
1138
+        $astart = & $a->dtstart['value'];
1140 1139
     $bstart = ( isset( $b->xprop['X-CURRENT-DTSTART']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTSTART']['value'] ) : null;
1141 1140
     if( empty( $bstart ) && isset( $b->dtstart['value'] ))
1142
-      $bstart = & $b->dtstart['value'];
1141
+        $bstart = & $b->dtstart['value'];
1143 1142
     if(     empty( $astart ))                          return -1;
1144 1143
     elseif( empty( $bstart ))                          return  1;
1145 1144
     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
-                                                       return -1;
1151
-      elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] ))
1152
-                                                       return  1;
1145
+        if    ( empty( $astart[$key] ))                  return -1;
1146
+        elseif( empty( $bstart[$key] ))                  return  1;
1147
+        if    (        $astart[$key] == $bstart[$key])   continue;
1148
+        if    (( (int) $astart[$key] ) < ((int) $bstart[$key] ))
1149
+                                                        return -1;
1150
+        elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] ))
1151
+                                                        return  1;
1153 1152
     }
1154 1153
     $c   = ( isset( $a->xprop['X-CURRENT-DTEND']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTEND']['value'] ) : null;
1155 1154
     if(     empty( $c ) && !empty( $a->dtend['value'] ))
1156
-      $c = & $a->dtend['value'];
1155
+        $c = & $a->dtend['value'];
1157 1156
     if(     empty( $c ) && isset( $a->xprop['X-CURRENT-DUE']['value'] ))
1158
-      $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] );
1157
+        $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] );
1159 1158
     if(     empty( $c ) && !empty( $a->due['value'] ))
1160
-      $c = & $a->due['value'];
1159
+        $c = & $a->due['value'];
1161 1160
     if(     empty( $c ) && !empty( $a->duration['value'] ))
1162
-      $c = $a->duration2date();
1161
+        $c = $a->duration2date();
1163 1162
     $d   = ( isset( $b->xprop['X-CURRENT-DTEND']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTEND']['value'] ) : null;
1164 1163
     if(     empty( $d ) && !empty( $b->dtend['value'] ))
1165
-      $d = & $b->dtend['value'];
1164
+        $d = & $b->dtend['value'];
1166 1165
     if(     empty( $d ) && isset( $b->xprop['X-CURRENT-DUE']['value'] ))
1167
-      $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] );
1166
+        $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] );
1168 1167
     if(     empty( $d ) && !empty( $b->due['value'] ))
1169
-      $d = & $b->due['value'];
1168
+        $d = & $b->due['value'];
1170 1169
     if(     empty( $d ) && !empty( $b->duration['value'] ))
1171
-      $d = $b->duration2date();
1170
+        $d = $b->duration2date();
1172 1171
     if(     empty( $c ))                               return -1;
1173 1172
     elseif( empty( $d ))                               return  1;
1174 1173
     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;
1174
+        if    ( !isset( $c[$key] ))                      return -1;
1175
+        elseif( !isset( $d[$key] ))                      return  1;
1176
+        if    (         $c[$key] == $d[$key] )           continue;
1177
+        if    ((  (int) $c[$key] ) < ((int) $d[$key]))   return -1;
1178
+        elseif((  (int) $c[$key] ) > ((int) $d[$key]))   return  1;
1180 1179
     }
1181 1180
     if( isset( $a->created['value'] ))
1182
-     $e = & $a->created['value'];
1181
+        $e = & $a->created['value'];
1183 1182
     else
1184
-     $e = & $a->dtstamp['value'];
1183
+        $e = & $a->dtstamp['value'];
1185 1184
     if( isset( $b->created['value'] ))
1186
-      $f = & $b->created['value'];
1185
+        $f = & $b->created['value'];
1187 1186
     else
1188
-      $f = & $b->dtstamp['value'];
1187
+        $f = & $b->dtstamp['value'];
1189 1188
     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;
1189
+        if(       !isset( $e[$key] ))                    return -1;
1190
+        elseif(   !isset( $f[$key] ))                    return  1;
1191
+        if    (           $e[$key] == $f[$key] )         continue;
1192
+        if    ((    (int) $e[$key] ) < ((int) $f[$key])) return -1;
1193
+        elseif((    (int) $e[$key] ) > ((int) $f[$key])) return  1;
1195 1194
     }
1196 1195
     if    ((            $a->uid['value'] ) <
1197
-           (            $b->uid['value'] ))            return -1;
1196
+            (            $b->uid['value'] ))            return -1;
1198 1197
     elseif((            $a->uid['value'] ) >
1199
-           (            $b->uid['value'] ))            return  1;
1198
+            (            $b->uid['value'] ))            return  1;
1200 1199
     return 0;
1201
-  }
1200
+    }
1202 1201
 /**
1203
- * parse iCal file into vcalendar, components, properties and parameters
1204
- *
1205
- * @author Kjell-Inge Gustafsson <[email protected]>
1206
- * @since 2.4.10 - 2008-08-06
1207
- * @param string $filename optional filname (incl. opt. directory/path) or URL
1208
- * @return bool FALSE if error occurs during parsing
1209
- *
1210
- */
1211
-  function parse( $filename=FALSE ) {
1202
+     * parse iCal file into vcalendar, components, properties and parameters
1203
+     *
1204
+     * @author Kjell-Inge Gustafsson <[email protected]>
1205
+     * @since 2.4.10 - 2008-08-06
1206
+     * @param string $filename optional filname (incl. opt. directory/path) or URL
1207
+     * @return bool FALSE if error occurs during parsing
1208
+     *
1209
+     */
1210
+    function parse( $filename=FALSE ) {
1212 1211
     if( !$filename ) {
1213 1212
             /* directory/filename previous set via setConfig directory+filename / url */
1214
-      if( FALSE === ( $filename = $this->getConfig( 'url' )))
1213
+        if( FALSE === ( $filename = $this->getConfig( 'url' )))
1215 1214
         $filename = $this->getConfig( 'dirfile' );
1216 1215
     }
1217 1216
     elseif(( 'http://'   == strtolower( substr( $filename, 0, 7 ))) ||
1218 1217
            ( 'webcal://' == strtolower( substr( $filename, 0, 9 ))))  {
1219 1218
             /* remote file - URL */
1220
-      $this->setConfig( 'URL', $filename );
1221
-      if( !$filename = $this->getConfig( 'url' ))
1219
+        $this->setConfig( 'URL', $filename );
1220
+        if( !$filename = $this->getConfig( 'url' ))
1222 1221
         return FALSE;                 /* err 2 */
1223 1222
     }
1224 1223
     else {
1225 1224
             /* local directory/filename */
1226
-      $parts = pathinfo( $filename );
1227
-      if( !empty( $parts['dirname'] ) && ( '.' != $parts['dirname'] )) {
1225
+        $parts = pathinfo( $filename );
1226
+        if( !empty( $parts['dirname'] ) && ( '.' != $parts['dirname'] )) {
1228 1227
         if( !$this->setConfig( 'directory', $parts['dirname'] ))
1229
-          return FALSE;               /* err 3 */
1230
-      }
1231
-      if( !$this->setConfig( 'filename', $parts['basename'] ))
1228
+            return FALSE;               /* err 3 */
1229
+        }
1230
+        if( !$this->setConfig( 'filename', $parts['basename'] ))
1232 1231
         return FALSE;                 /* err 4 */
1233 1232
     }
1234 1233
     if( 'http://' != substr( $filename, 0, 7 )) {
1235 1234
             /* local file error tests */
1236
-      if( !is_file( $filename ))      /* err 5 */
1235
+        if( !is_file( $filename ))      /* err 5 */
1237 1236
         return FALSE;
1238
-      if( !is_readable( $filename ))
1237
+        if( !is_readable( $filename ))
1239 1238
         return FALSE;                 /* err 6 */
1240
-      if( !filesize( $filename ))
1239
+        if( !filesize( $filename ))
1241 1240
         return FALSE;                 /* err 7 */
1242
-      clearstatcache();
1241
+        clearstatcache();
1243 1242
     }
1244 1243
             /* READ FILE */
1245 1244
     if( FALSE === ( $rows = file( $filename )))
1246
-      return FALSE;                   /* err 1 */
1245
+        return FALSE;                   /* err 1 */
1247 1246
             /* identify BEGIN:VCALENDAR, MUST be first row */
1248 1247
     if( 'BEGIN:VCALENDAR' != strtoupper( trim( $rows[0] )))
1249
-      return FALSE;                   /* err 8 */
1248
+        return FALSE;                   /* err 8 */
1250 1249
             /* remove empty trailing lines */
1251 1250
     while( '' == trim( $rows[count( $rows ) - 1] )) {
1252
-      unset( $rows[count( $rows ) - 1] );
1253
-      $rows  = array_values( $rows );
1251
+        unset( $rows[count( $rows ) - 1] );
1252
+        $rows  = array_values( $rows );
1254 1253
     }
1255 1254
             /* identify ending END:VCALENDAR row */
1256 1255
     if( 'END:VCALENDAR'   != strtoupper( trim( $rows[count( $rows ) - 1] ))) {
1257
-      return FALSE;                   /* err 9 */
1256
+        return FALSE;                   /* err 9 */
1258 1257
     }
1259 1258
     if( 3 > count( $rows ))
1260
-      return FALSE;                   /* err 10 */
1259
+        return FALSE;                   /* err 10 */
1261 1260
     $comp    = $subcomp = null;
1262 1261
     $actcomp = & $this;
1263 1262
     $nl      = $this->getConfig( 'nl' );
1264 1263
     $calsync = 0;
1265 1264
             /* identify components and update unparsed data within component */
1266 1265
     foreach( $rows as $line ) {
1267
-      if( '' == trim( $line ))
1266
+        if( '' == trim( $line ))
1268 1267
         continue;
1269
-      if( $nl == substr( $line, 0 - strlen( $nl )))
1268
+        if( $nl == substr( $line, 0 - strlen( $nl )))
1270 1269
         $line = substr( $line, 0, ( strlen( $line ) - strlen( $nl ))).'\n';
1271
-      if( 'BEGIN:VCALENDAR' == strtoupper( substr( $line, 0, 15 ))) {
1270
+        if( 'BEGIN:VCALENDAR' == strtoupper( substr( $line, 0, 15 ))) {
1272 1271
         $calsync++;
1273 1272
         continue;
1274
-      }
1275
-      elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) {
1273
+        }
1274
+        elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) {
1276 1275
         $calsync--;
1277 1276
         continue;
1278
-      }
1279
-      elseif( 1 != $calsync )
1277
+        }
1278
+        elseif( 1 != $calsync )
1280 1279
         return FALSE;                 /* err 20 */
1281
-      if( 'END:' == strtoupper( substr( $line, 0, 4 ))) {
1280
+        if( 'END:' == strtoupper( substr( $line, 0, 4 ))) {
1282 1281
         if( null != $subcomp ) {
1283
-          $comp->setComponent( $subcomp );
1284
-          $subcomp = null;
1282
+            $comp->setComponent( $subcomp );
1283
+            $subcomp = null;
1285 1284
         }
1286 1285
         else {
1287
-          $this->setComponent( $comp );
1288
-          $comp = null;
1286
+            $this->setComponent( $comp );
1287
+            $comp = null;
1289 1288
         }
1290 1289
         $actcomp = null;
1291 1290
         continue;
1292
-      } // end - if ( 'END:' ==.. .
1293
-      elseif( 'BEGIN:' == strtoupper( substr( $line, 0, 6 ))) {
1291
+        } // end - if ( 'END:' ==.. .
1292
+        elseif( 'BEGIN:' == strtoupper( substr( $line, 0, 6 ))) {
1294 1293
         $line = str_replace( '\n', '', $line );
1295 1294
         $compname = trim (strtoupper( substr( $line, 6 )));
1296 1295
         if( null != $comp ) {
1297
-          if( 'VALARM' == $compname )
1296
+            if( 'VALARM' == $compname )
1298 1297
             $subcomp = new valarm();
1299
-          elseif( 'STANDARD' == $compname )
1298
+            elseif( 'STANDARD' == $compname )
1300 1299
             $subcomp = new vtimezone( 'STANDARD' );
1301
-          elseif( 'DAYLIGHT' == $compname )
1300
+            elseif( 'DAYLIGHT' == $compname )
1302 1301
             $subcomp = new vtimezone( 'DAYLIGHT' );
1303
-          else
1302
+            else
1304 1303
             return FALSE; /* err 6 */
1305
-          $actcomp = & $subcomp;
1304
+            $actcomp = & $subcomp;
1306 1305
         }
1307 1306
         else {
1308
-          switch( $compname ) {
1307
+            switch( $compname ) {
1309 1308
             case 'VALARM':
1310 1309
               $comp = new valarm();
1311
-              break;
1310
+                break;
1312 1311
             case 'VEVENT':
1313 1312
               $comp = new vevent();
1314
-              break;
1313
+                break;
1315 1314
             case 'VFREEBUSY';
1316
-              $comp = new vfreebusy();
1317
-              break;
1315
+                $comp = new vfreebusy();
1316
+                break;
1318 1317
             case 'VJOURNAL':
1319 1318
               $comp = new vjournal();
1320
-              break;
1319
+                break;
1321 1320
             case 'VTODO':
1322 1321
               $comp = new vtodo();
1323
-              break;
1322
+                break;
1324 1323
             case 'VTIMEZONE':
1325 1324
               $comp = new vtimezone();
1326
-              break;
1325
+                break;
1327 1326
             default:
1328 1327
               return FALSE; // err 7
1329
-              break;
1330
-          } // end - switch
1331
-          $actcomp = & $comp;
1328
+                break;
1329
+            } // end - switch
1330
+            $actcomp = & $comp;
1332 1331
         }
1333 1332
         continue;
1334
-      } // end - elsif ( 'BEGIN:'.. .
1333
+        } // end - elsif ( 'BEGIN:'.. .
1335 1334
             /* update selected component with unparsed data */
1336
-      $actcomp->unparsed[] = $line;
1335
+        $actcomp->unparsed[] = $line;
1337 1336
     } // end - foreach( rows.. .
1338 1337
             /* parse data for calendar (this) object */
1339 1338
     if( is_array( $this->unparsed ) && ( 0 < count( $this->unparsed ))) {
1340 1339
             /* concatenate property values spread over several lines */
1341
-      $lastix    = -1;
1342
-      $propnames = array( 'calscale','method','prodid','version','x-' );
1343
-      $proprows  = array();
1344
-      foreach( $this->unparsed as $line ) {
1340
+        $lastix    = -1;
1341
+        $propnames = array( 'calscale','method','prodid','version','x-' );
1342
+        $proprows  = array();
1343
+        foreach( $this->unparsed as $line ) {
1345 1344
         $newProp = FALSE;
1346 1345
         foreach ( $propnames as $propname ) {
1347
-          if( $propname == strtolower( substr( $line, 0, strlen( $propname )))) {
1346
+            if( $propname == strtolower( substr( $line, 0, strlen( $propname )))) {
1348 1347
             $newProp = TRUE;
1349 1348
             break;
1350
-          }
1349
+            }
1351 1350
         }
1352 1351
         if( $newProp ) {
1353
-          $newProp = FALSE;
1354
-          $lastix++;
1355
-          $proprows[$lastix]  = $line;
1352
+            $newProp = FALSE;
1353
+            $lastix++;
1354
+            $proprows[$lastix]  = $line;
1356 1355
         }
1357 1356
         else {
1358 1357
             /* remove line breaks */
1359
-          if(( '\n' == substr( $proprows[$lastix], -2 )) &&
1358
+            if(( '\n' == substr( $proprows[$lastix], -2 )) &&
1360 1359
              (  ' ' == substr( $line, 0, 1 ))) {
1361 1360
             $proprows[$lastix] = substr( $proprows[$lastix], 0, strlen( $proprows[$lastix] ) - 2 );
1362 1361
             $line = substr( $line, 1 );
1363
-          }
1364
-          $proprows[$lastix] .= $line;
1362
+            }
1363
+            $proprows[$lastix] .= $line;
1365 1364
         }
1366
-      }
1367
-      $toolbox = new calendarComponent();
1368
-      foreach( $proprows as $line ) {
1365
+        }
1366
+        $toolbox = new calendarComponent();
1367
+        foreach( $proprows as $line ) {
1369 1368
         if( '\n' == substr( $line, -2 ))
1370
-          $line = substr( $line, 0, strlen( $line ) - 2 );
1369
+            $line = substr( $line, 0, strlen( $line ) - 2 );
1371 1370
             /* get propname */
1372 1371
         $cix = $propname = null;
1373 1372
         for( $cix=0; $cix < strlen( $line ); $cix++ ) {
1374
-          if( in_array( $line{$cix}, array( ':', ';' )))
1373
+            if( in_array( $line{$cix}, array( ':', ';' )))
1375 1374
             break;
1376
-          else
1375
+            else
1377 1376
             $propname .= $line{$cix};
1378 1377
         }
1379 1378
             /* ignore version/prodid properties */
1380 1379
         if( in_array( strtoupper( $propname ), array( 'VERSION', 'PRODID' )))
1381
-          continue;
1380
+            continue;
1382 1381
         $line = substr( $line, $cix);
1383 1382
             /* separate attributes from value */
1384 1383
         $attr   = array();
1385 1384
         $attrix = -1;
1386 1385
         $strlen = strlen( $line );
1387 1386
         for( $cix=0; $cix < $strlen; $cix++ ) {
1388
-          if((       ':'   == $line{$cix} )             &&
1387
+            if((       ':'   == $line{$cix} )             &&
1389 1388
                    ( '://' != substr( $line, $cix, 3 )) &&
1390 1389
              ( 'mailto:'   != strtolower( substr( $line, $cix - 6, 7 )))) {
1391 1390
             $attrEnd = TRUE;
1392 1391
             if(( $cix < ( $strlen - 4 )) &&
1393 1392
                  ctype_digit( substr( $line, $cix+1, 4 ))) { // an URI with a (4pos) portnr??
1394
-              for( $c2ix = $cix; 3 < $c2ix; $c2ix-- ) {
1393
+                for( $c2ix = $cix; 3 < $c2ix; $c2ix-- ) {
1395 1394
                 if( '://' == substr( $line, $c2ix - 2, 3 )) {
1396
-                  $attrEnd = FALSE;
1397
-                  break; // an URI with a portnr!!
1395
+                    $attrEnd = FALSE;
1396
+                    break; // an URI with a portnr!!
1397
+                }
1398 1398
                 }
1399
-              }
1400 1399
             }
1401 1400
             if( $attrEnd) {
1402
-              $line = substr( $line, $cix + 1 );
1403
-              break;
1401
+                $line = substr( $line, $cix + 1 );
1402
+                break;
1403
+            }
1404 1404
             }
1405
-          }
1406
-          if( ';' == $line{$cix} )
1405
+            if( ';' == $line{$cix} )
1407 1406
             $attr[++$attrix] = null;
1408
-          else
1407
+            else
1409 1408
             $attr[$attrix] .= $line{$cix};
1410 1409
         }
1411 1410
 
1412 1411
             /* make attributes in array format */
1413 1412
         $propattr = array();
1414 1413
         foreach( $attr as $attribute ) {
1415
-          $attrsplit = explode( '=', $attribute, 2 );
1416
-          if( 1 < count( $attrsplit ))
1414
+            $attrsplit = explode( '=', $attribute, 2 );
1415
+            if( 1 < count( $attrsplit ))
1417 1416
             $propattr[$attrsplit[0]] = $attrsplit[1];
1418
-          else
1417
+            else
1419 1418
             $propattr[] = $attribute;
1420 1419
         }
1421 1420
             /* update Property */
1422 1421
         if( FALSE !== strpos( $line, ',' )) {
1423
-          $content  = explode( ',', $line );
1424
-          $clen     = count( $content );
1425
-          for( $cix = 0; $cix < $clen; $cix++ ) {
1422
+            $content  = explode( ',', $line );
1423
+            $clen     = count( $content );
1424
+            for( $cix = 0; $cix < $clen; $cix++ ) {
1426 1425
             if( "\\" == substr( $content[$cix], -1 )) {
1427
-              $content[$cix] .= ','.$content[$cix + 1];
1428
-              unset( $content[$cix + 1] );
1429
-              $cix++;
1426
+                $content[$cix] .= ','.$content[$cix + 1];
1427
+                unset( $content[$cix + 1] );
1428
+                $cix++;
1429
+            }
1430 1430
             }
1431
-          }
1432
-          if( 1 < count( $content )) {
1431
+            if( 1 < count( $content )) {
1433 1432
             foreach( $content as $cix => $contentPart )
1434
-              $content[$cix] = $toolbox->_strunrep( $contentPart );
1433
+                $content[$cix] = $toolbox->_strunrep( $contentPart );
1435 1434
             $this->setProperty( $propname, $content, $propattr );
1436 1435
             continue;
1437
-          }
1438
-          else
1436
+            }
1437
+            else
1439 1438
             $line = reset( $content );
1440
-          $line = $toolbox->_strunrep( $line );
1439
+            $line = $toolbox->_strunrep( $line );
1441 1440
         }
1442 1441
         $this->setProperty( $propname, trim( $line ), $propattr );
1443
-      } // end - foreach( $this->unparsed.. .
1442
+        } // end - foreach( $this->unparsed.. .
1444 1443
     } // end - if( is_array( $this->unparsed.. .
1445 1444
             /* parse Components */
1446 1445
     if( is_array( $this->components ) && ( 0 < count( $this->components ))) {
1447
-      for( $six = 0; $six < count( $this->components ); $six++ ) {
1446
+        for( $six = 0; $six < count( $this->components ); $six++ ) {
1448 1447
         if( !empty( $this->components[$six] ))
1449
-          $this->components[$six]->parse();
1450
-      }
1448
+            $this->components[$six]->parse();
1449
+        }
1451 1450
     }
1452 1451
     else
1453
-      return FALSE;                   /* err 91 or something.. . */
1452
+        return FALSE;                   /* err 91 or something.. . */
1454 1453
     return TRUE;
1455
-  }
1454
+    }
1456 1455
 /*********************************************************************************/
1457 1456
 /**
1458
- * creates formatted output for calendar object instance
1459
- *
1460
- * @author Kjell-Inge Gustafsson <[email protected]>
1461
- * @since 2.4.10 - 2008-08-06
1462
- * @return string
1463
- */
1464
-  function createCalendar() {
1457
+     * creates formatted output for calendar object instance
1458
+     *
1459
+     * @author Kjell-Inge Gustafsson <[email protected]>
1460
+     * @since 2.4.10 - 2008-08-06
1461
+     * @return string
1462
+     */
1463
+    function createCalendar() {
1465 1464
     $calendarInit1 = $calendarInit2 = $calendarxCaldecl = $calendarStart = $calendar = null;
1466 1465
     switch( $this->format ) {
1467
-      case 'xcal':
1466
+        case 'xcal':
1468 1467
         $calendarInit1 = '<?xml version="1.0" encoding="UTF-8"?>'.$this->nl.
1469
-                         '<!DOCTYPE iCalendar PUBLIC "-//IETF//DTD XCAL/iCalendar XML//EN"'.$this->nl.
1470
-                         '"http://www.ietf.org/internet-drafts/draft-ietf-calsch-many-xcal-01.txt"';
1468
+                            '<!DOCTYPE iCalendar PUBLIC "-//IETF//DTD XCAL/iCalendar XML//EN"'.$this->nl.
1469
+                            '"http://www.ietf.org/internet-drafts/draft-ietf-calsch-many-xcal-01.txt"';
1471 1470
         $calendarInit2 = '>'.$this->nl;
1472 1471
         $calendarStart = '<vcalendar';
1473 1472
         break;
1474
-      default:
1473
+        default:
1475 1474
         $calendarStart = 'BEGIN:VCALENDAR'.$this->nl;
1476 1475
         break;
1477 1476
     }
@@ -1480,217 +1479,217 @@  discard block
 block discarded – undo
1480 1479
     $calendarStart .= $this->createProdid();
1481 1480
     $calendarStart .= $this->createVersion();
1482 1481
     switch( $this->format ) {
1483
-      case 'xcal':
1482
+        case 'xcal':
1484 1483
         $nlstrlen = strlen( $this->nl );
1485 1484
         if( $this->nl == substr( $calendarStart, ( 0 - $nlstrlen )))
1486
-          $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen ));
1485
+            $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen ));
1487 1486
         $calendarStart .= '>'.$this->nl;
1488 1487
         break;
1489
-      default:
1488
+        default:
1490 1489
         break;
1491 1490
     }
1492 1491
     $calendar .= $this->createXprop();
1493 1492
     foreach( $this->components as $component ) {
1494
-      if( empty( $component )) continue;
1495
-      if( '' >= $component->getConfig( 'language'))
1493
+        if( empty( $component )) continue;
1494
+        if( '' >= $component->getConfig( 'language'))
1496 1495
         $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 );
1496
+        $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
1497
+        $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
1498
+        $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
1499
+        $component->setConfig( 'format',      $this->getConfig( 'format' ));
1500
+        $calendar .= $component->createComponent( $this->xcaldecl );
1502 1501
     }
1503 1502
     if(( 0 < count( $this->xcaldecl )) && ( 'xcal' == $this->format )) { // xCal only
1504
-      $calendarInit1 .= $this->nl.'['.$this->nl;
1505
-      $old_xcaldecl = array();
1506
-      foreach( $this->xcaldecl as $declix => $declPart ) {
1503
+        $calendarInit1 .= $this->nl.'['.$this->nl;
1504
+        $old_xcaldecl = array();
1505
+        foreach( $this->xcaldecl as $declix => $declPart ) {
1507 1506
         if(( 0 < count( $old_xcaldecl)) &&
1508 1507
            ( in_array( $declPart['uri'],      $old_xcaldecl['uri'] )) &&
1509 1508
            ( in_array( $declPart['external'], $old_xcaldecl['external'] )))
1510
-          continue; // no duplicate uri and ext. references
1509
+            continue; // no duplicate uri and ext. references
1511 1510
         $calendarxCaldecl .= '<!';
1512 1511
         foreach( $declPart as $declKey => $declValue ) {
1513
-          switch( $declKey ) {                    // index
1512
+            switch( $declKey ) {                    // index
1514 1513
             case 'xmldecl':                       // no 1
1515 1514
               $calendarxCaldecl .= $declValue.' ';
1516
-              break;
1515
+                break;
1517 1516
             case 'uri':                           // no 2
1518 1517
               $calendarxCaldecl .= $declValue.' ';
1519
-              $old_xcaldecl['uri'][] = $declValue;
1520
-              break;
1518
+                $old_xcaldecl['uri'][] = $declValue;
1519
+                break;
1521 1520
             case 'ref':                           // no 3
1522 1521
               $calendarxCaldecl .= $declValue.' ';
1523
-              break;
1522
+                break;
1524 1523
             case 'external':                      // no 4
1525 1524
               $calendarxCaldecl .= '"'.$declValue.'" ';
1526
-              $old_xcaldecl['external'][] = $declValue;
1527
-              break;
1525
+                $old_xcaldecl['external'][] = $declValue;
1526
+                break;
1528 1527
             case 'type':                          // no 5
1529 1528
               $calendarxCaldecl .= $declValue.' ';
1530
-              break;
1529
+                break;
1531 1530
             case 'type2':                         // no 6
1532 1531
               $calendarxCaldecl .= $declValue;
1533
-              break;
1534
-          }
1532
+                break;
1533
+            }
1535 1534
         }
1536 1535
         $calendarxCaldecl .= '>'.$this->nl;
1537
-      }
1538
-      $calendarInit2 = ']'.$calendarInit2;
1536
+        }
1537
+        $calendarInit2 = ']'.$calendarInit2;
1539 1538
     }
1540 1539
     switch( $this->format ) {
1541
-      case 'xcal':
1540
+        case 'xcal':
1542 1541
         $calendar .= '</vcalendar>'.$this->nl;
1543 1542
         break;
1544
-      default:
1543
+        default:
1545 1544
         $calendar .= 'END:VCALENDAR'.$this->nl;
1546 1545
         break;
1547 1546
     }
1548 1547
     return $calendarInit1.$calendarxCaldecl.$calendarInit2.$calendarStart.$calendar;
1549
-  }
1548
+    }
1550 1549
 /**
1551
- * a HTTP redirect header is sent with created, updated and/or parsed calendar
1552
- *
1553
- * @author Kjell-Inge Gustafsson <[email protected]>
1554
- * @since 2.2.12 - 2007-10-23
1555
- * @return redirect
1556
- */
1557
-  function returnCalendar() {
1550
+     * a HTTP redirect header is sent with created, updated and/or parsed calendar
1551
+     *
1552
+     * @author Kjell-Inge Gustafsson <[email protected]>
1553
+     * @since 2.2.12 - 2007-10-23
1554
+     * @return redirect
1555
+     */
1556
+    function returnCalendar() {
1558 1557
     $filename = $this->getConfig( 'filename' );
1559 1558
     $output   = $this->createCalendar();
1560 1559
     $filesize = strlen( $output );
1561 1560
 //    if( headers_sent( $filename, $linenum ))
1562 1561
 //      die( "Headers already sent in $filename on line $linenum\n" );
1563 1562
     if( 'xcal' == $this->format )
1564
-      header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1563
+        header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1565 1564
     else
1566
-      header( 'Content-Type: text/calendar; charset=utf-8' );
1565
+        header( 'Content-Type: text/calendar; charset=utf-8' );
1567 1566
     header( 'Content-Length: '.$filesize );
1568 1567
     header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
1569 1568
     header( 'Cache-Control: max-age=10' );
1570 1569
     echo $output;
1571 1570
     die();
1572
-  }
1571
+    }
1573 1572
 /**
1574
- * save content in a file
1575
- *
1576
- * @author Kjell-Inge Gustafsson <[email protected]>
1577
- * @since 2.2.12 - 2007-12-30
1578
- * @param string $directory optional
1579
- * @param string $filename optional
1580
- * @param string $delimiter optional
1581
- * @return bool
1582
- */
1583
-  function saveCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE ) {
1573
+     * save content in a file
1574
+     *
1575
+     * @author Kjell-Inge Gustafsson <[email protected]>
1576
+     * @since 2.2.12 - 2007-12-30
1577
+     * @param string $directory optional
1578
+     * @param string $filename optional
1579
+     * @param string $delimiter optional
1580
+     * @return bool
1581
+     */
1582
+    function saveCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE ) {
1584 1583
     if( $directory )
1585
-      $this->setConfig( 'directory', $directory );
1584
+        $this->setConfig( 'directory', $directory );
1586 1585
     if( $filename )
1587
-      $this->setConfig( 'filename',  $filename );
1586
+        $this->setConfig( 'filename',  $filename );
1588 1587
     if( $delimiter && ($delimiter != DIRECTORY_SEPARATOR ))
1589
-      $this->setConfig( 'delimiter', $delimiter );
1588
+        $this->setConfig( 'delimiter', $delimiter );
1590 1589
     if( FALSE === ( $dirfile = $this->getConfig( 'url' )))
1591
-      $dirfile = $this->getConfig( 'dirfile' );
1590
+        $dirfile = $this->getConfig( 'dirfile' );
1592 1591
     $iCalFile = @fopen( $dirfile, 'w' );
1593 1592
     if( $iCalFile ) {
1594
-      if( FALSE === fwrite( $iCalFile, $this->createCalendar() ))
1593
+        if( FALSE === fwrite( $iCalFile, $this->createCalendar() ))
1595 1594
         return FALSE;
1596
-      fclose( $iCalFile );
1597
-      return TRUE;
1595
+        fclose( $iCalFile );
1596
+        return TRUE;
1598 1597
     }
1599 1598
     else
1600
-      return FALSE;
1601
-  }
1599
+        return FALSE;
1600
+    }
1602 1601
 /**
1603
- * if recent version of calendar file exists (default one hour), an HTTP redirect header is sent
1604
- * else FALSE is returned
1605
- *
1606
- * @author Kjell-Inge Gustafsson <[email protected]>
1607
- * @since 2.2.12 - 2007-10-28
1608
- * @param string $directory optional alt. int timeout
1609
- * @param string $filename optional
1610
- * @param string $delimiter optional
1611
- * @param int timeout optional, default 3600 sec
1612
- * @return redirect/FALSE
1613
- */
1614
-  function useCachedCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE, $timeout=3600) {
1602
+     * if recent version of calendar file exists (default one hour), an HTTP redirect header is sent
1603
+     * else FALSE is returned
1604
+     *
1605
+     * @author Kjell-Inge Gustafsson <[email protected]>
1606
+     * @since 2.2.12 - 2007-10-28
1607
+     * @param string $directory optional alt. int timeout
1608
+     * @param string $filename optional
1609
+     * @param string $delimiter optional
1610
+     * @param int timeout optional, default 3600 sec
1611
+     * @return redirect/FALSE
1612
+     */
1613
+    function useCachedCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE, $timeout=3600) {
1615 1614
     if ( $directory && ctype_digit( (string) $directory ) && !$filename ) {
1616
-      $timeout   = (int) $directory;
1617
-      $directory = FALSE;
1615
+        $timeout   = (int) $directory;
1616
+        $directory = FALSE;
1618 1617
     }
1619 1618
     if( $directory )
1620
-      $this->setConfig( 'directory', $directory );
1619
+        $this->setConfig( 'directory', $directory );
1621 1620
     if( $filename )
1622
-      $this->setConfig( 'filename',  $filename );
1621
+        $this->setConfig( 'filename',  $filename );
1623 1622
     if( $delimiter && ( $delimiter != DIRECTORY_SEPARATOR ))
1624
-      $this->setConfig( 'delimiter', $delimiter );
1623
+        $this->setConfig( 'delimiter', $delimiter );
1625 1624
     $filesize    = $this->getConfig( 'filesize' );
1626 1625
     if( 0 >= $filesize )
1627
-      return FALSE;
1626
+        return FALSE;
1628 1627
     $dirfile     = $this->getConfig( 'dirfile' );
1629 1628
     if( time() - filemtime( $dirfile ) < $timeout) {
1630
-      clearstatcache();
1631
-      $dirfile   = $this->getConfig( 'dirfile' );
1632
-      $filename  = $this->getConfig( 'filename' );
1629
+        clearstatcache();
1630
+        $dirfile   = $this->getConfig( 'dirfile' );
1631
+        $filename  = $this->getConfig( 'filename' );
1633 1632
 //    if( headers_sent( $filename, $linenum ))
1634 1633
 //      die( "Headers already sent in $filename on line $linenum\n" );
1635
-      if( 'xcal' == $this->format )
1634
+        if( 'xcal' == $this->format )
1636 1635
         header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1637
-      else
1636
+        else
1638 1637
         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 ) {
1638
+        header( 'Content-Length: '.$filesize );
1639
+        header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
1640
+        header( 'Cache-Control: max-age=10' );
1641
+        $fp = @$fopen( $dirfile, 'r' );
1642
+        if( $fp ) {
1644 1643
         fpassthru( $fp );
1645 1644
         fclose( $fp );
1646
-      }
1647
-      die();
1645
+        }
1646
+        die();
1648 1647
     }
1649 1648
     else
1650
-      return FALSE;
1651
-  }
1649
+        return FALSE;
1650
+    }
1652 1651
 }
1653 1652
 /*********************************************************************************/
1654 1653
 /*********************************************************************************/
1655 1654
 /**
1656
- *  abstract class for calendar components
1657
- *
1658
- * @author Kjell-Inge Gustafsson <[email protected]>
1659
- * @since 2.4.19 - 2008-10-12
1660
- */
1655
+     *  abstract class for calendar components
1656
+     *
1657
+     * @author Kjell-Inge Gustafsson <[email protected]>
1658
+     * @since 2.4.19 - 2008-10-12
1659
+     */
1661 1660
 class calendarComponent {
1662 1661
             //  component property variables
1663
-  var $uid;
1664
-  var $dtstamp;
1662
+    var $uid;
1663
+    var $dtstamp;
1665 1664
 
1666 1665
             //  component config variables
1667
-  var $allowEmpty;
1668
-  var $language;
1669
-  var $nl;
1670
-  var $unique_id;
1671
-  var $format;
1672
-  var $objName; // created automatically at instance creation
1666
+    var $allowEmpty;
1667
+    var $language;
1668
+    var $nl;
1669
+    var $unique_id;
1670
+    var $format;
1671
+    var $objName; // created automatically at instance creation
1673 1672
             //  component internal variables
1674
-  var $componentStart1;
1675
-  var $componentStart2;
1676
-  var $componentEnd1;
1677
-  var $componentEnd2;
1678
-  var $elementStart1;
1679
-  var $elementStart2;
1680
-  var $elementEnd1;
1681
-  var $elementEnd2;
1682
-  var $intAttrDelimiter;
1683
-  var $attributeDelimiter;
1684
-  var $valueInit;
1673
+    var $componentStart1;
1674
+    var $componentStart2;
1675
+    var $componentEnd1;
1676
+    var $componentEnd2;
1677
+    var $elementStart1;
1678
+    var $elementStart2;
1679
+    var $elementEnd1;
1680
+    var $elementEnd2;
1681
+    var $intAttrDelimiter;
1682
+    var $attributeDelimiter;
1683
+    var $valueInit;
1685 1684
             //  component xCal declaration container
1686
-  var $xcaldecl;
1687
-/**
1688
- * constructor for calendar component object
1689
- *
1690
- * @author Kjell-Inge Gustafsson <[email protected]>
1691
- * @since 2.4.19 - 2008-10-23
1692
- */
1693
-  function calendarComponent() {
1685
+    var $xcaldecl;
1686
+/**
1687
+     * constructor for calendar component object
1688
+     *
1689
+     * @author Kjell-Inge Gustafsson <[email protected]>
1690
+     * @since 2.4.19 - 2008-10-23
1691
+     */
1692
+    function calendarComponent() {
1694 1693
     $this->objName         = ( isset( $this->timezonetype )) ?
1695 1694
                           strtolower( $this->timezonetype )  :  get_class ( $this );
1696 1695
     $this->uid             = array();
@@ -1705,203 +1704,203 @@  discard block
 block discarded – undo
1705 1704
 
1706 1705
     $this->_createFormat();
1707 1706
     $this->_makeDtstamp();
1708
-  }
1707
+    }
1709 1708
 /*********************************************************************************/
1710 1709
 /**
1711
- * Property Name: ACTION
1712
- */
1710
+     * Property Name: ACTION
1711
+     */
1713 1712
 /**
1714
- * creates formatted output for calendar component property action
1715
- *
1716
- * @author Kjell-Inge Gustafsson <[email protected]>
1717
- * @since 2.4.8 - 2008-10-22
1718
- * @return string
1719
- */
1720
-  function createAction() {
1713
+     * creates formatted output for calendar component property action
1714
+     *
1715
+     * @author Kjell-Inge Gustafsson <[email protected]>
1716
+     * @since 2.4.8 - 2008-10-22
1717
+     * @return string
1718
+     */
1719
+    function createAction() {
1721 1720
     if( empty( $this->action )) return FALSE;
1722 1721
     if( empty( $this->action['value'] ))
1723
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE;
1722
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE;
1724 1723
     $attributes = $this->_createParams( $this->action['params'] );
1725 1724
     return $this->_createElement( 'ACTION', $attributes, $this->action['value'] );
1726
-  }
1725
+    }
1727 1726
 /**
1728
- * set calendar component property action
1729
- *
1730
- * @author Kjell-Inge Gustafsson <[email protected]>
1731
- * @since 2.4.8 - 2008-11-04
1732
- * @param string $value  "AUDIO" / "DISPLAY" / "EMAIL" / "PROCEDURE"
1733
- * @param mixed $params
1734
- * @return bool
1735
- */
1736
-  function setAction( $value, $params=FALSE ) {
1727
+     * set calendar component property action
1728
+     *
1729
+     * @author Kjell-Inge Gustafsson <[email protected]>
1730
+     * @since 2.4.8 - 2008-11-04
1731
+     * @param string $value  "AUDIO" / "DISPLAY" / "EMAIL" / "PROCEDURE"
1732
+     * @param mixed $params
1733
+     * @return bool
1734
+     */
1735
+    function setAction( $value, $params=FALSE ) {
1737 1736
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1738 1737
     $this->action = array( 'value' => $value, 'params' => $this->_setParams( $params ));
1739 1738
     return TRUE;
1740
-  }
1739
+    }
1741 1740
 /*********************************************************************************/
1742 1741
 /**
1743
- * Property Name: ATTACH
1744
- */
1742
+     * Property Name: ATTACH
1743
+     */
1745 1744
 /**
1746
- * creates formatted output for calendar component property attach
1747
- *
1748
- * @author Kjell-Inge Gustafsson <[email protected]>
1749
- * @since 0.9.7 - 2006-11-23
1750
- * @return string
1751
- */
1752
-  function createAttach() {
1745
+     * creates formatted output for calendar component property attach
1746
+     *
1747
+     * @author Kjell-Inge Gustafsson <[email protected]>
1748
+     * @since 0.9.7 - 2006-11-23
1749
+     * @return string
1750
+     */
1751
+    function createAttach() {
1753 1752
     if( empty( $this->attach )) return FALSE;
1754 1753
     $output       = null;
1755 1754
     foreach( $this->attach as $attachPart ) {
1756
-      if(! empty( $attachPart['value'] )) {
1755
+        if(! empty( $attachPart['value'] )) {
1757 1756
         $attributes = $this->_createParams( $attachPart['params'] );
1758 1757
         $output    .= $this->_createElement( 'ATTACH', $attributes, $attachPart['value'] );
1759
-      }
1760
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'ATTACH' );
1758
+        }
1759
+        elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'ATTACH' );
1761 1760
     }
1762 1761
     return $output;
1763
-  }
1762
+    }
1764 1763
 /**
1765
- * set calendar component property attach
1766
- *
1767
- * @author Kjell-Inge Gustafsson <[email protected]>
1768
- * @since 2.5.1 - 2008-11-06
1769
- * @param string $value
1770
- * @param array $params, optional
1771
- * @param integer $index, optional
1772
- * @return bool
1773
- */
1774
-  function setAttach( $value, $params=FALSE, $index=FALSE ) {
1764
+     * set calendar component property attach
1765
+     *
1766
+     * @author Kjell-Inge Gustafsson <[email protected]>
1767
+     * @since 2.5.1 - 2008-11-06
1768
+     * @param string $value
1769
+     * @param array $params, optional
1770
+     * @param integer $index, optional
1771
+     * @return bool
1772
+     */
1773
+    function setAttach( $value, $params=FALSE, $index=FALSE ) {
1775 1774
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1776 1775
     $this->_setMval( $this->attach, $value, $params, FALSE, $index );
1777 1776
     return TRUE;
1778
-  }
1777
+    }
1779 1778
 /*********************************************************************************/
1780 1779
 /**
1781
- * Property Name: ATTENDEE
1782
- */
1780
+     * Property Name: ATTENDEE
1781
+     */
1783 1782
 /**
1784
- * creates formatted output for calendar component property attendee
1785
- *
1786
- * @author Kjell-Inge Gustafsson <[email protected]>
1787
- * @since 2.4.8 - 2008-09-23
1788
- * @return string
1789
- */
1790
-  function createAttendee() {
1783
+     * creates formatted output for calendar component property attendee
1784
+     *
1785
+     * @author Kjell-Inge Gustafsson <[email protected]>
1786
+     * @since 2.4.8 - 2008-09-23
1787
+     * @return string
1788
+     */
1789
+    function createAttendee() {
1791 1790
     if( empty( $this->attendee )) return FALSE;
1792 1791
     $output = null;
1793 1792
     foreach( $this->attendee as $attendeePart ) {                      // start foreach 1
1794
-      if( empty( $attendeePart['value'] )) {
1793
+        if( empty( $attendeePart['value'] )) {
1795 1794
         if( $this->getConfig( 'allowEmpty' ))
1796
-          $output .= $this->_createElement( 'ATTENDEE' );
1795
+            $output .= $this->_createElement( 'ATTENDEE' );
1797 1796
         continue;
1798
-      }
1799
-      $attendee1 = $attendee2 = $attendeeLANG = $attendeeCN = null;
1800
-      foreach( $attendeePart as $paramlabel => $paramvalue ) {         // start foreach 2
1797
+        }
1798
+        $attendee1 = $attendee2 = $attendeeLANG = $attendeeCN = null;
1799
+        foreach( $attendeePart as $paramlabel => $paramvalue ) {         // start foreach 2
1801 1800
         if( 'value' == $paramlabel )
1802
-          $attendee2  .= 'MAILTO:'.$paramvalue;
1801
+            $attendee2  .= 'MAILTO:'.$paramvalue;
1803 1802
         elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) { // start elseif
1804
-          foreach( $paramvalue as $optparamlabel => $optparamvalue ) { // start foreach 3
1803
+            foreach( $paramvalue as $optparamlabel => $optparamvalue ) { // start foreach 3
1805 1804
             $attendee11 = $attendee12 = null;
1806 1805
             if( is_int( $optparamlabel )) {
1807
-              $attendee1 .= $this->intAttrDelimiter.$optparamvalue;
1808
-              continue;
1806
+                $attendee1 .= $this->intAttrDelimiter.$optparamvalue;
1807
+                continue;
1809 1808
             }
1810 1809
             switch( $optparamlabel ) {                                 // start switch
1811
-              case 'CUTYPE':
1810
+                case 'CUTYPE':
1812 1811
               case 'PARTSTAT':
1813 1812
               case 'ROLE':
1814 1813
               case 'RSVP':
1815 1814
                 $attendee1 .= $this->intAttrDelimiter.$optparamlabel.'="'.$optparamvalue.'"';
1816 1815
                 break;
1817
-              case 'SENT-BY':
1816
+                case 'SENT-BY':
1818 1817
                 $attendee1 .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$optparamvalue.'"';
1819 1818
                 break;
1820
-              case 'MEMBER':
1819
+                case 'MEMBER':
1821 1820
                 $attendee11 = $this->intAttrDelimiter.'MEMBER=';
1822
-              case 'DELEGATED-TO':
1821
+                case 'DELEGATED-TO':
1823 1822
                 $attendee11 = ( !$attendee11 ) ? $this->intAttrDelimiter.'DELEGATED-TO='   : $attendee11;
1824
-              case 'DELEGATED-FROM':
1823
+                case 'DELEGATED-FROM':
1825 1824
                 $attendee11 = ( !$attendee11 ) ? $this->intAttrDelimiter.'DELEGATED-FROM=' : $attendee11;
1826 1825
                 foreach( $optparamvalue  as $cix => $calUserAddress ) {
1827
-                  $attendee12 .= ( $cix ) ? ',' : null;
1828
-                  $attendee12 .= '"MAILTO:'.$calUserAddress.'"';
1826
+                    $attendee12 .= ( $cix ) ? ',' : null;
1827
+                    $attendee12 .= '"MAILTO:'.$calUserAddress.'"';
1829 1828
                 }
1830 1829
                 $attendee1  .= $attendee11.$attendee12;
1831 1830
                 break;
1832
-              case 'CN':
1831
+                case 'CN':
1833 1832
                 $attendeeCN .= $this->intAttrDelimiter.'CN="'.$optparamvalue.'"';
1834 1833
                 break;
1835
-              case 'DIR':
1834
+                case 'DIR':
1836 1835
                 $attendee1 .= $this->intAttrDelimiter.'DIR="'.$optparamvalue.'"';
1837 1836
                 break;
1838
-              case 'LANGUAGE':
1837
+                case 'LANGUAGE':
1839 1838
                 $attendeeLANG .= $this->intAttrDelimiter.'LANGUAGE='.$optparamvalue;
1840 1839
                 break;
1841
-              default:
1840
+                default:
1842 1841
                 $attendee1 .= $this->intAttrDelimiter."$optparamlabel=$optparamvalue";
1843 1842
                 break;
1844 1843
             }    // end switch
1845
-          }      // end foreach 3
1844
+            }      // end foreach 3
1846 1845
         }        // end elseif
1847
-      }          // end foreach 2
1848
-      $output .= $this->_createElement( 'ATTENDEE', $attendee1.$attendeeLANG.$attendeeCN, $attendee2 );
1846
+        }          // end foreach 2
1847
+        $output .= $this->_createElement( 'ATTENDEE', $attendee1.$attendeeLANG.$attendeeCN, $attendee2 );
1849 1848
     }              // end foreach 1
1850 1849
     return $output;
1851
-  }
1850
+    }
1852 1851
 /**
1853
- * set calendar component property attach
1854
- *
1855
- * @author Kjell-Inge Gustafsson <[email protected]>
1856
- * @since 2.5.1 - 2008-11-05
1857
- * @param string $value
1858
- * @param array $params, optional
1859
- * @param integer $index, optional
1860
- * @return bool
1861
- */
1862
-  function setAttendee( $value, $params=FALSE, $index=FALSE ) {
1852
+     * set calendar component property attach
1853
+     *
1854
+     * @author Kjell-Inge Gustafsson <[email protected]>
1855
+     * @since 2.5.1 - 2008-11-05
1856
+     * @param string $value
1857
+     * @param array $params, optional
1858
+     * @param integer $index, optional
1859
+     * @return bool
1860
+     */
1861
+    function setAttendee( $value, $params=FALSE, $index=FALSE ) {
1863 1862
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1864 1863
     $value = str_replace ( 'MAILTO:', '', $value );
1865 1864
     $value = str_replace ( 'mailto:', '', $value );
1866 1865
     $params2 = array();
1867 1866
     if( is_array($params )) {
1868
-      $optarrays = array();
1869
-      foreach( $params as $optparamlabel => $optparamvalue ) {
1867
+        $optarrays = array();
1868
+        foreach( $params as $optparamlabel => $optparamvalue ) {
1870 1869
         $optparamlabel = strtoupper( $optparamlabel );
1871 1870
         switch( $optparamlabel ) {
1872
-          case 'MEMBER':
1871
+            case 'MEMBER':
1873 1872
           case 'DELEGATED-TO':
1874 1873
           case 'DELEGATED-FROM':
1875 1874
             if( is_array( $optparamvalue )) {
1876
-              foreach( $optparamvalue as $part ) {
1875
+                foreach( $optparamvalue as $part ) {
1877 1876
                 $part = str_replace( 'MAILTO:', '', $part );
1878 1877
                 $part = str_replace( 'mailto:', '', $part );
1879 1878
                 if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} ))
1880
-                  $part = substr( $part, 1, ( strlen($part)-2 ));
1879
+                    $part = substr( $part, 1, ( strlen($part)-2 ));
1881 1880
                 $optarrays[$optparamlabel][] = $part;
1882
-              }
1881
+                }
1883 1882
             }
1884 1883
             else {
1885
-              $part = str_replace( 'MAILTO:', '', $optparamvalue );
1886
-              $part = str_replace( 'mailto:', '', $part );
1887
-              if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} ))
1884
+                $part = str_replace( 'MAILTO:', '', $optparamvalue );
1885
+                $part = str_replace( 'mailto:', '', $part );
1886
+                if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} ))
1888 1887
                 $part = substr( $part, 1, ( strlen($part)-2 ));
1889
-              $optarrays[$optparamlabel][] = $part;
1888
+                $optarrays[$optparamlabel][] = $part;
1890 1889
             }
1891 1890
             break;
1892
-          default:
1891
+            default:
1893 1892
             if( 'SENT-BY' ==  $optparamlabel ) {
1894
-              $optparamvalue = str_replace( 'MAILTO:', '', $optparamvalue );
1895
-              $optparamvalue = str_replace( 'mailto:', '', $optparamvalue );
1893
+                $optparamvalue = str_replace( 'MAILTO:', '', $optparamvalue );
1894
+                $optparamvalue = str_replace( 'mailto:', '', $optparamvalue );
1896 1895
             }
1897 1896
             if(( '"' == substr( $optparamvalue, 0, 1 )) &&
1898 1897
                ( '"' == substr( $optparamvalue, -1 )))
1899
-              $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 ));
1898
+                $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 ));
1900 1899
             $params2[$optparamlabel] = $optparamvalue;
1901 1900
             break;
1902 1901
         } // end switch( $optparamlabel.. .
1903
-      } // end foreach( $optparam.. .
1904
-      foreach( $optarrays as $optparamlabel => $optparams )
1902
+        } // end foreach( $optparam.. .
1903
+        foreach( $optarrays as $optparamlabel => $optparams )
1905 1904
         $params2[$optparamlabel] = $optparams;
1906 1905
     }
1907 1906
         // remove defaults
@@ -1911,144 +1910,144 @@  discard block
 block discarded – undo
1911 1910
     $this->_existRem( $params2, 'RSVP',     'FALSE' );
1912 1911
         // check language setting
1913 1912
     if( isset( $params2['CN' ] )) {
1914
-      $lang = $this->getConfig( 'language' );
1915
-      if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang ))
1913
+        $lang = $this->getConfig( 'language' );
1914
+        if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang ))
1916 1915
         $params2['LANGUAGE' ] = $lang;
1917 1916
     }
1918 1917
     $this->_setMval( $this->attendee, $value, $params2, FALSE, $index );
1919 1918
     return TRUE;
1920
-  }
1919
+    }
1921 1920
 /*********************************************************************************/
1922 1921
 /**
1923
- * Property Name: CATEGORIES
1924
- */
1922
+     * Property Name: CATEGORIES
1923
+     */
1925 1924
 /**
1926
- * creates formatted output for calendar component property categories
1927
- *
1928
- * @author Kjell-Inge Gustafsson <[email protected]>
1929
- * @since 2.4.8 - 2008-10-22
1930
- * @return string
1931
- */
1932
-  function createCategories() {
1925
+     * creates formatted output for calendar component property categories
1926
+     *
1927
+     * @author Kjell-Inge Gustafsson <[email protected]>
1928
+     * @since 2.4.8 - 2008-10-22
1929
+     * @return string
1930
+     */
1931
+    function createCategories() {
1933 1932
     if( empty( $this->categories )) return FALSE;
1934 1933
     $output = null;
1935 1934
     foreach( $this->categories as $category ) {
1936
-      if( empty( $category['value'] )) {
1935
+        if( empty( $category['value'] )) {
1937 1936
         if ( $this->getConfig( 'allowEmpty' ))
1938
-          $output .= $this->_createElement( 'CATEGORIES' );
1937
+            $output .= $this->_createElement( 'CATEGORIES' );
1939 1938
         continue;
1940
-      }
1941
-      $attributes = $this->_createParams( $category['params'], array( 'LANGUAGE' ));
1942
-      if( is_array( $category['value'] )) {
1939
+        }
1940
+        $attributes = $this->_createParams( $category['params'], array( 'LANGUAGE' ));
1941
+        if( is_array( $category['value'] )) {
1943 1942
         foreach( $category['value'] as $cix => $categoryPart )
1944
-          $category['value'][$cix] = $this->_strrep( $categoryPart );
1943
+            $category['value'][$cix] = $this->_strrep( $categoryPart );
1945 1944
         $content  = implode( ',', $category['value'] );
1946
-      }
1947
-      else
1945
+        }
1946
+        else
1948 1947
         $content  = $this->_strrep( $category['value'] );
1949
-      $output    .= $this->_createElement( 'CATEGORIES', $attributes, $content );
1948
+        $output    .= $this->_createElement( 'CATEGORIES', $attributes, $content );
1950 1949
     }
1951 1950
     return $output;
1952
-  }
1951
+    }
1953 1952
 /**
1954
- * set calendar component property categories
1955
- *
1956
- * @author Kjell-Inge Gustafsson <[email protected]>
1957
- * @since 2.5.1 - 2008-11-06
1958
- * @param mixed $value
1959
- * @param array $params, optional
1960
- * @param integer $index, optional
1961
- * @return bool
1962
- */
1963
-  function setCategories( $value, $params=FALSE, $index=FALSE ) {
1953
+     * set calendar component property categories
1954
+     *
1955
+     * @author Kjell-Inge Gustafsson <[email protected]>
1956
+     * @since 2.5.1 - 2008-11-06
1957
+     * @param mixed $value
1958
+     * @param array $params, optional
1959
+     * @param integer $index, optional
1960
+     * @return bool
1961
+     */
1962
+    function setCategories( $value, $params=FALSE, $index=FALSE ) {
1964 1963
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1965 1964
     $this->_setMval( $this->categories, $value, $params, FALSE, $index );
1966 1965
     return TRUE;
1967
- }
1966
+    }
1968 1967
 /*********************************************************************************/
1969 1968
 /**
1970
- * Property Name: CLASS
1971
- */
1969
+     * Property Name: CLASS
1970
+     */
1972 1971
 /**
1973
- * creates formatted output for calendar component property class
1974
- *
1975
- * @author Kjell-Inge Gustafsson <[email protected]>
1976
- * @since 0.9.7 - 2006-11-20
1977
- * @return string
1978
- */
1979
-  function createClass() {
1972
+     * creates formatted output for calendar component property class
1973
+     *
1974
+     * @author Kjell-Inge Gustafsson <[email protected]>
1975
+     * @since 0.9.7 - 2006-11-20
1976
+     * @return string
1977
+     */
1978
+    function createClass() {
1980 1979
     if( empty( $this->class )) return FALSE;
1981 1980
     if( empty( $this->class['value'] ))
1982
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE;
1981
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE;
1983 1982
     $attributes = $this->_createParams( $this->class['params'] );
1984 1983
     return $this->_createElement( 'CLASS', $attributes, $this->class['value'] );
1985
-  }
1984
+    }
1986 1985
 /**
1987
- * set calendar component property class
1988
- *
1989
- * @author Kjell-Inge Gustafsson <[email protected]>
1990
- * @since 2.4.8 - 2008-11-04
1991
- * @param string $value "PUBLIC" / "PRIVATE" / "CONFIDENTIAL" / iana-token / x-name
1992
- * @param array $params optional
1993
- * @return bool
1994
- */
1995
-  function setClass( $value, $params=FALSE ) {
1986
+     * set calendar component property class
1987
+     *
1988
+     * @author Kjell-Inge Gustafsson <[email protected]>
1989
+     * @since 2.4.8 - 2008-11-04
1990
+     * @param string $value "PUBLIC" / "PRIVATE" / "CONFIDENTIAL" / iana-token / x-name
1991
+     * @param array $params optional
1992
+     * @return bool
1993
+     */
1994
+    function setClass( $value, $params=FALSE ) {
1996 1995
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1997 1996
     $this->class = array( 'value' => $value, 'params' => $this->_setParams( $params ));
1998 1997
     return TRUE;
1999
-  }
1998
+    }
2000 1999
 /*********************************************************************************/
2001 2000
 /**
2002
- * Property Name: COMMENT
2003
- */
2001
+     * Property Name: COMMENT
2002
+     */
2004 2003
 /**
2005
- * creates formatted output for calendar component property comment
2006
- *
2007
- * @author Kjell-Inge Gustafsson <[email protected]>
2008
- * @since 2.4.8 - 2008-10-22
2009
- * @return string
2010
- */
2011
-  function createComment() {
2004
+     * creates formatted output for calendar component property comment
2005
+     *
2006
+     * @author Kjell-Inge Gustafsson <[email protected]>
2007
+     * @since 2.4.8 - 2008-10-22
2008
+     * @return string
2009
+     */
2010
+    function createComment() {
2012 2011
     if( empty( $this->comment )) return FALSE;
2013 2012
     $output = null;
2014 2013
     foreach( $this->comment as $commentPart ) {
2015
-      if( empty( $commentPart['value'] )) {
2014
+        if( empty( $commentPart['value'] )) {
2016 2015
         if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'COMMENT' );
2017 2016
         continue;
2018
-      }
2019
-      $attributes = $this->_createParams( $commentPart['params'], array( 'ALTREP', 'LANGUAGE' ));
2020
-      $content    = $this->_strrep( $commentPart['value'] );
2021
-      $output    .= $this->_createElement( 'COMMENT', $attributes, $content );
2017
+        }
2018
+        $attributes = $this->_createParams( $commentPart['params'], array( 'ALTREP', 'LANGUAGE' ));
2019
+        $content    = $this->_strrep( $commentPart['value'] );
2020
+        $output    .= $this->_createElement( 'COMMENT', $attributes, $content );
2022 2021
     }
2023 2022
     return $output;
2024
-  }
2023
+    }
2025 2024
 /**
2026
- * set calendar component property comment
2027
- *
2028
- * @author Kjell-Inge Gustafsson <[email protected]>
2029
- * @since 2.5.1 - 2008-11-06
2030
- * @param string $value
2031
- * @param array $params, optional
2032
- * @param integer $index, optional
2033
- * @return bool
2034
- */
2035
-  function setComment( $value, $params=FALSE, $index=FALSE ) {
2025
+     * set calendar component property comment
2026
+     *
2027
+     * @author Kjell-Inge Gustafsson <[email protected]>
2028
+     * @since 2.5.1 - 2008-11-06
2029
+     * @param string $value
2030
+     * @param array $params, optional
2031
+     * @param integer $index, optional
2032
+     * @return bool
2033
+     */
2034
+    function setComment( $value, $params=FALSE, $index=FALSE ) {
2036 2035
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2037 2036
     $this->_setMval( $this->comment, $value, $params, FALSE, $index );
2038 2037
     return TRUE;
2039
-  }
2038
+    }
2040 2039
 /*********************************************************************************/
2041 2040
 /**
2042
- * Property Name: COMPLETED
2043
- */
2041
+     * Property Name: COMPLETED
2042
+     */
2044 2043
 /**
2045
- * creates formatted output for calendar component property completed
2046
- *
2047
- * @author Kjell-Inge Gustafsson <[email protected]>
2048
- * @since 2.4.8 - 2008-10-22
2049
- * @return string
2050
- */
2051
-  function createCompleted( ) {
2044
+     * creates formatted output for calendar component property completed
2045
+     *
2046
+     * @author Kjell-Inge Gustafsson <[email protected]>
2047
+     * @since 2.4.8 - 2008-10-22
2048
+     * @return string
2049
+     */
2050
+    function createCompleted( ) {
2052 2051
     if( empty( $this->completed )) return FALSE;
2053 2052
     if( !isset( $this->completed['value']['year'] )  &&
2054 2053
         !isset( $this->completed['value']['month'] ) &&
@@ -2056,167 +2055,167 @@  discard block
 block discarded – undo
2056 2055
         !isset( $this->completed['value']['hour'] )  &&
2057 2056
         !isset( $this->completed['value']['min'] )   &&
2058 2057
         !isset( $this->completed['value']['sec'] ))
2059
-      if( $this->getConfig( 'allowEmpty' ))
2058
+        if( $this->getConfig( 'allowEmpty' ))
2060 2059
         return $this->_createElement( 'COMPLETED' );
2061
-      else return FALSE;
2060
+        else return FALSE;
2062 2061
     $formatted  = $this->_format_date_time( $this->completed['value'], 7 );
2063 2062
     $attributes = $this->_createParams( $this->completed['params'] );
2064 2063
     return $this->_createElement( 'COMPLETED', $attributes, $formatted );
2065
-  }
2064
+    }
2066 2065
 /**
2067
- * set calendar component property completed
2068
- *
2069
- * @author Kjell-Inge Gustafsson <[email protected]>
2070
- * @since 2.4.8 - 2008-10-23
2071
- * @param mixed $year
2072
- * @param mixed $month optional
2073
- * @param int $day optional
2074
- * @param int $hour optional
2075
- * @param int $min optional
2076
- * @param int $sec optional
2077
- * @param array $params optional
2078
- * @return bool
2079
- */
2080
-  function setCompleted( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2066
+     * set calendar component property completed
2067
+     *
2068
+     * @author Kjell-Inge Gustafsson <[email protected]>
2069
+     * @since 2.4.8 - 2008-10-23
2070
+     * @param mixed $year
2071
+     * @param mixed $month optional
2072
+     * @param int $day optional
2073
+     * @param int $hour optional
2074
+     * @param int $min optional
2075
+     * @param int $sec optional
2076
+     * @param array $params optional
2077
+     * @return bool
2078
+     */
2079
+    function setCompleted( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2081 2080
     if( empty( $year )) {
2082
-      if( $this->getConfig( 'allowEmpty' )) {
2081
+        if( $this->getConfig( 'allowEmpty' )) {
2083 2082
         $this->completed = array( 'value' => null, 'params' => $this->_setParams( $params ));
2084 2083
         return TRUE;
2085
-      }
2086
-      else
2084
+        }
2085
+        else
2087 2086
         return FALSE;
2088 2087
     }
2089 2088
     $this->completed = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2090 2089
     return TRUE;
2091
-  }
2090
+    }
2092 2091
 /*********************************************************************************/
2093 2092
 /**
2094
- * Property Name: CONTACT
2095
- */
2093
+     * Property Name: CONTACT
2094
+     */
2096 2095
 /**
2097
- * creates formatted output for calendar component property contact
2098
- *
2099
- * @author Kjell-Inge Gustafsson <[email protected]>
2100
- * @since 2.4.8 - 2008-10-23
2101
- * @return string
2102
- */
2103
-  function createContact() {
2096
+     * creates formatted output for calendar component property contact
2097
+     *
2098
+     * @author Kjell-Inge Gustafsson <[email protected]>
2099
+     * @since 2.4.8 - 2008-10-23
2100
+     * @return string
2101
+     */
2102
+    function createContact() {
2104 2103
     if( empty( $this->contact )) return FALSE;
2105 2104
     $output = null;
2106 2105
     foreach( $this->contact as $contact ) {
2107
-      if( !empty( $contact['value'] )) {
2106
+        if( !empty( $contact['value'] )) {
2108 2107
         $attributes = $this->_createParams( $contact['params'], array( 'ALTREP', 'LANGUAGE' ));
2109 2108
         $content    = $this->_strrep( $contact['value'] );
2110 2109
         $output    .= $this->_createElement( 'CONTACT', $attributes, $content );
2111
-      }
2112
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'CONTACT' );
2110
+        }
2111
+        elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'CONTACT' );
2113 2112
     }
2114 2113
     return $output;
2115
-  }
2114
+    }
2116 2115
 /**
2117
- * set calendar component property contact
2118
- *
2119
- * @author Kjell-Inge Gustafsson <[email protected]>
2120
- * @since 2.5.1 - 2008-11-05
2121
- * @param string $value
2122
- * @param array $params, optional
2123
- * @param integer $index, optional
2124
- * @return bool
2125
- */
2126
-  function setContact( $value, $params=FALSE, $index=FALSE ) {
2116
+     * set calendar component property contact
2117
+     *
2118
+     * @author Kjell-Inge Gustafsson <[email protected]>
2119
+     * @since 2.5.1 - 2008-11-05
2120
+     * @param string $value
2121
+     * @param array $params, optional
2122
+     * @param integer $index, optional
2123
+     * @return bool
2124
+     */
2125
+    function setContact( $value, $params=FALSE, $index=FALSE ) {
2127 2126
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2128 2127
     $this->_setMval( $this->contact, $value, $params, FALSE, $index );
2129 2128
     return TRUE;
2130
-  }
2129
+    }
2131 2130
 /*********************************************************************************/
2132 2131
 /**
2133
- * Property Name: CREATED
2134
- */
2132
+     * Property Name: CREATED
2133
+     */
2135 2134
 /**
2136
- * creates formatted output for calendar component property created
2137
- *
2138
- * @author Kjell-Inge Gustafsson <[email protected]>
2139
- * @since 2.4.8 - 2008-10-21
2140
- * @return string
2141
- */
2142
-  function createCreated() {
2135
+     * creates formatted output for calendar component property created
2136
+     *
2137
+     * @author Kjell-Inge Gustafsson <[email protected]>
2138
+     * @since 2.4.8 - 2008-10-21
2139
+     * @return string
2140
+     */
2141
+    function createCreated() {
2143 2142
     if( empty( $this->created )) return FALSE;
2144 2143
     $formatted  = $this->_format_date_time( $this->created['value'], 7 );
2145 2144
     $attributes = $this->_createParams( $this->created['params'] );
2146 2145
     return $this->_createElement( 'CREATED', $attributes, $formatted );
2147
-  }
2146
+    }
2148 2147
 /**
2149
- * set calendar component property created
2150
- *
2151
- * @author Kjell-Inge Gustafsson <[email protected]>
2152
- * @since 2.4.8 - 2008-10-23
2153
- * @param mixed $year optional
2154
- * @param mixed $month optional
2155
- * @param int $day optional
2156
- * @param int $hour optional
2157
- * @param int $min optional
2158
- * @param int $sec optional
2159
- * @param mixed $params optional
2160
- * @return bool
2161
- */
2162
-  function setCreated( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2148
+     * set calendar component property created
2149
+     *
2150
+     * @author Kjell-Inge Gustafsson <[email protected]>
2151
+     * @since 2.4.8 - 2008-10-23
2152
+     * @param mixed $year optional
2153
+     * @param mixed $month optional
2154
+     * @param int $day optional
2155
+     * @param int $hour optional
2156
+     * @param int $min optional
2157
+     * @param int $sec optional
2158
+     * @param mixed $params optional
2159
+     * @return bool
2160
+     */
2161
+    function setCreated( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2163 2162
     if( !isset( $year )) {
2164
-      $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' )));
2163
+        $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' )));
2165 2164
     }
2166 2165
     $this->created = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2167 2166
     return TRUE;
2168
-  }
2167
+    }
2169 2168
 /*********************************************************************************/
2170 2169
 /**
2171
- * Property Name: DESCRIPTION
2172
- */
2170
+     * Property Name: DESCRIPTION
2171
+     */
2173 2172
 /**
2174
- * creates formatted output for calendar component property description
2175
- *
2176
- * @author Kjell-Inge Gustafsson <[email protected]>
2177
- * @since 2.4.8 - 2008-10-22
2178
- * @return string
2179
- */
2180
-  function createDescription() {
2173
+     * creates formatted output for calendar component property description
2174
+     *
2175
+     * @author Kjell-Inge Gustafsson <[email protected]>
2176
+     * @since 2.4.8 - 2008-10-22
2177
+     * @return string
2178
+     */
2179
+    function createDescription() {
2181 2180
     if( empty( $this->description )) return FALSE;
2182 2181
     $output       = null;
2183 2182
     foreach( $this->description as $description ) {
2184
-      if( !empty( $description['value'] )) {
2183
+        if( !empty( $description['value'] )) {
2185 2184
         $attributes = $this->_createParams( $description['params'], array( 'ALTREP', 'LANGUAGE' ));
2186 2185
         $content    = $this->_strrep( $description['value'] );
2187 2186
         $output    .= $this->_createElement( 'DESCRIPTION', $attributes, $content );
2188
-      }
2189
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'DESCRIPTION' );
2187
+        }
2188
+        elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'DESCRIPTION' );
2190 2189
     }
2191 2190
     return $output;
2192
-  }
2191
+    }
2193 2192
 /**
2194
- * set calendar component property description
2195
- *
2196
- * @author Kjell-Inge Gustafsson <[email protected]>
2197
- * @since 2.5.1 - 2008-11-05
2198
- * @param string $value
2199
- * @param array $params, optional
2200
- * @param integer $index, optional
2201
- * @return bool
2202
- */
2203
-  function setDescription( $value, $params=FALSE, $index=FALSE ) {
2193
+     * set calendar component property description
2194
+     *
2195
+     * @author Kjell-Inge Gustafsson <[email protected]>
2196
+     * @since 2.5.1 - 2008-11-05
2197
+     * @param string $value
2198
+     * @param array $params, optional
2199
+     * @param integer $index, optional
2200
+     * @return bool
2201
+     */
2202
+    function setDescription( $value, $params=FALSE, $index=FALSE ) {
2204 2203
     if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; }
2205 2204
     $this->_setMval( $this->description, $value, $params, FALSE, $index );
2206 2205
     return TRUE;
2207
-  }
2206
+    }
2208 2207
 /*********************************************************************************/
2209 2208
 /**
2210
- * Property Name: DTEND
2211
- */
2209
+     * Property Name: DTEND
2210
+     */
2212 2211
 /**
2213
- * creates formatted output for calendar component property dtend
2214
- *
2215
- * @author Kjell-Inge Gustafsson <[email protected]>
2216
- * @since 2.4.8 - 2008-10-21
2217
- * @return string
2218
- */
2219
-  function createDtend() {
2212
+     * creates formatted output for calendar component property dtend
2213
+     *
2214
+     * @author Kjell-Inge Gustafsson <[email protected]>
2215
+     * @since 2.4.8 - 2008-10-21
2216
+     * @return string
2217
+     */
2218
+    function createDtend() {
2220 2219
     if( empty( $this->dtend )) return FALSE;
2221 2220
     if( !isset( $this->dtend['value']['year'] )  &&
2222 2221
         !isset( $this->dtend['value']['month'] ) &&
@@ -2224,112 +2223,112 @@  discard block
 block discarded – undo
2224 2223
         !isset( $this->dtend['value']['hour'] )  &&
2225 2224
         !isset( $this->dtend['value']['min'] )   &&
2226 2225
         !isset( $this->dtend['value']['sec'] ))
2227
-      if( $this->getConfig( 'allowEmpty' ))
2226
+        if( $this->getConfig( 'allowEmpty' ))
2228 2227
         return $this->_createElement( 'DTEND' );
2229
-      else return FALSE;
2228
+        else return FALSE;
2230 2229
     $formatted  = $this->_format_date_time( $this->dtend['value'] );
2231 2230
     $attributes = $this->_createParams( $this->dtend['params'] );
2232 2231
     return $this->_createElement( 'DTEND', $attributes, $formatted );
2233
-  }
2232
+    }
2234 2233
 /**
2235
- * set calendar component property dtend
2236
- *
2237
- * @author Kjell-Inge Gustafsson <[email protected]>
2238
- * @since 2.4.8 - 2008-10-23
2239
- * @param mixed $year
2240
- * @param mixed $month optional
2241
- * @param int $day optional
2242
- * @param int $hour optional
2243
- * @param int $min optional
2244
- * @param int $sec optional
2245
- * @param string $tz optional
2246
- * @param array params optional
2247
- * @return bool
2248
- */
2249
-  function setDtend( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
2234
+     * set calendar component property dtend
2235
+     *
2236
+     * @author Kjell-Inge Gustafsson <[email protected]>
2237
+     * @since 2.4.8 - 2008-10-23
2238
+     * @param mixed $year
2239
+     * @param mixed $month optional
2240
+     * @param int $day optional
2241
+     * @param int $hour optional
2242
+     * @param int $min optional
2243
+     * @param int $sec optional
2244
+     * @param string $tz optional
2245
+     * @param array params optional
2246
+     * @return bool
2247
+     */
2248
+    function setDtend( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
2250 2249
     if( empty( $year )) {
2251
-      if( $this->getConfig( 'allowEmpty' )) {
2250
+        if( $this->getConfig( 'allowEmpty' )) {
2252 2251
         $this->dtend = array( 'value' => null, 'params' => $this->_setParams( $params ));
2253 2252
         return TRUE;
2254
-      }
2255
-      else
2253
+        }
2254
+        else
2256 2255
         return FALSE;
2257 2256
     }
2258 2257
     $this->dtend = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params );
2259 2258
     return TRUE;
2260
-  }
2259
+    }
2261 2260
 /*********************************************************************************/
2262 2261
 /**
2263
- * Property Name: DTSTAMP
2264
- */
2262
+     * Property Name: DTSTAMP
2263
+     */
2265 2264
 /**
2266
- * creates formatted output for calendar component property dtstamp
2267
- *
2268
- * @author Kjell-Inge Gustafsson <[email protected]>
2269
- * @since 2.4.4 - 2008-03-07
2270
- * @return string
2271
- */
2272
-  function createDtstamp() {
2265
+     * creates formatted output for calendar component property dtstamp
2266
+     *
2267
+     * @author Kjell-Inge Gustafsson <[email protected]>
2268
+     * @since 2.4.4 - 2008-03-07
2269
+     * @return string
2270
+     */
2271
+    function createDtstamp() {
2273 2272
     if( !isset( $this->dtstamp['value']['year'] )  &&
2274 2273
         !isset( $this->dtstamp['value']['month'] ) &&
2275 2274
         !isset( $this->dtstamp['value']['day'] )   &&
2276 2275
         !isset( $this->dtstamp['value']['hour'] )  &&
2277 2276
         !isset( $this->dtstamp['value']['min'] )   &&
2278 2277
         !isset( $this->dtstamp['value']['sec'] ))
2279
-      $this->_makeDtstamp();
2278
+        $this->_makeDtstamp();
2280 2279
     $formatted  = $this->_format_date_time( $this->dtstamp['value'], 7 );
2281 2280
     $attributes = $this->_createParams( $this->dtstamp['params'] );
2282 2281
     return $this->_createElement( 'DTSTAMP', $attributes, $formatted );
2283
-  }
2282
+    }
2284 2283
 /**
2285
- * computes datestamp for calendar component object instance dtstamp
2286
- *
2287
- * @author Kjell-Inge Gustafsson <[email protected]>
2288
- * @since 1.x.x - 2007-05-13
2289
- * @return void
2290
- */
2291
-  function _makeDtstamp() {
2284
+     * computes datestamp for calendar component object instance dtstamp
2285
+     *
2286
+     * @author Kjell-Inge Gustafsson <[email protected]>
2287
+     * @since 1.x.x - 2007-05-13
2288
+     * @return void
2289
+     */
2290
+    function _makeDtstamp() {
2292 2291
     $this->dtstamp['value'] = array( 'year'  => date( 'Y' )
2293
-                                   , 'month' => date( 'm' )
2294
-                                   , 'day'   => date( 'd' )
2295
-                                   , 'hour'  => date( 'H' )
2296
-                                   , 'min'   => date( 'i' )
2297
-                                   , 'sec'   => date( 's' ) - date( 'Z' ));
2292
+                                    , 'month' => date( 'm' )
2293
+                                    , 'day'   => date( 'd' )
2294
+                                    , 'hour'  => date( 'H' )
2295
+                                    , 'min'   => date( 'i' )
2296
+                                    , 'sec'   => date( 's' ) - date( 'Z' ));
2298 2297
     $this->dtstamp['params'] = null;
2299
-  }
2298
+    }
2300 2299
 /**
2301
- * set calendar component property dtstamp
2302
- *
2303
- * @author Kjell-Inge Gustafsson <[email protected]>
2304
- * @since 2.4.8 - 2008-10-23
2305
- * @param mixed $year
2306
- * @param mixed $month optional
2307
- * @param int $day optional
2308
- * @param int $hour optional
2309
- * @param int $min optional
2310
- * @param int $sec optional
2311
- * @param array $params optional
2312
- * @return TRUE
2313
- */
2314
-  function setDtstamp( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2300
+     * set calendar component property dtstamp
2301
+     *
2302
+     * @author Kjell-Inge Gustafsson <[email protected]>
2303
+     * @since 2.4.8 - 2008-10-23
2304
+     * @param mixed $year
2305
+     * @param mixed $month optional
2306
+     * @param int $day optional
2307
+     * @param int $hour optional
2308
+     * @param int $min optional
2309
+     * @param int $sec optional
2310
+     * @param array $params optional
2311
+     * @return TRUE
2312
+     */
2313
+    function setDtstamp( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2315 2314
     if( empty( $year ))
2316
-      $this->_makeDtstamp();
2315
+        $this->_makeDtstamp();
2317 2316
     else
2318
-      $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2317
+        $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2319 2318
     return TRUE;
2320
-  }
2319
+    }
2321 2320
 /*********************************************************************************/
2322 2321
 /**
2323
- * Property Name: DTSTART
2324
- */
2322
+     * Property Name: DTSTART
2323
+     */
2325 2324
 /**
2326
- * creates formatted output for calendar component property dtstart
2327
- *
2328
- * @author Kjell-Inge Gustafsson <[email protected]>
2329
- * @since 2.4.16 - 2008-10-26
2330
- * @return string
2331
- */
2332
-  function createDtstart() {
2325
+     * creates formatted output for calendar component property dtstart
2326
+     *
2327
+     * @author Kjell-Inge Gustafsson <[email protected]>
2328
+     * @since 2.4.16 - 2008-10-26
2329
+     * @return string
2330
+     */
2331
+    function createDtstart() {
2333 2332
     if( empty( $this->dtstart )) return FALSE;
2334 2333
     if( !isset( $this->dtstart['value']['year'] )  &&
2335 2334
         !isset( $this->dtstart['value']['month'] ) &&
@@ -2338,53 +2337,53 @@  discard block
 block discarded – undo
2338 2337
         !isset( $this->dtstart['value']['min'] )   &&
2339 2338
         !isset( $this->dtstart['value']['sec'] ))
2340 2339
     if( $this->getConfig( 'allowEmpty' ))
2341
-      return $this->_createElement( 'DTSTART' );
2340
+        return $this->_createElement( 'DTSTART' );
2342 2341
     else return FALSE;
2343 2342
     if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' )))
2344
-      unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] );
2343
+        unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] );
2345 2344
     $formatted  = $this->_format_date_time( $this->dtstart['value'] );
2346 2345
     $attributes = $this->_createParams( $this->dtstart['params'] );
2347 2346
     return $this->_createElement( 'DTSTART', $attributes, $formatted );
2348
-  }
2347
+    }
2349 2348
 /**
2350
- * set calendar component property dtstart
2351
- *
2352
- * @author Kjell-Inge Gustafsson <[email protected]>
2353
- * @since 2.4.16 - 2008-11-04
2354
- * @param mixed $year
2355
- * @param mixed $month optional
2356
- * @param int $day optional
2357
- * @param int $hour optional
2358
- * @param int $min optional
2359
- * @param int $sec optional
2360
- * @param string $tz optional
2361
- * @param array $params optional
2362
- * @return bool
2363
- */
2364
-  function setDtstart( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
2349
+     * set calendar component property dtstart
2350
+     *
2351
+     * @author Kjell-Inge Gustafsson <[email protected]>
2352
+     * @since 2.4.16 - 2008-11-04
2353
+     * @param mixed $year
2354
+     * @param mixed $month optional
2355
+     * @param int $day optional
2356
+     * @param int $hour optional
2357
+     * @param int $min optional
2358
+     * @param int $sec optional
2359
+     * @param string $tz optional
2360
+     * @param array $params optional
2361
+     * @return bool
2362
+     */
2363
+    function setDtstart( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
2365 2364
     if( empty( $year )) {
2366
-      if( $this->getConfig( 'allowEmpty' )) {
2365
+        if( $this->getConfig( 'allowEmpty' )) {
2367 2366
         $this->dtstart = array( 'value' => null, 'params' => $this->_setParams( $params ));
2368 2367
         return TRUE;
2369
-      }
2370
-      else
2368
+        }
2369
+        else
2371 2370
         return FALSE;
2372 2371
     }
2373 2372
     $this->dtstart = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params, 'dtstart' );
2374 2373
     return TRUE;
2375
-  }
2374
+    }
2376 2375
 /*********************************************************************************/
2377 2376
 /**
2378
- * Property Name: DUE
2379
- */
2377
+     * Property Name: DUE
2378
+     */
2380 2379
 /**
2381
- * creates formatted output for calendar component property due
2382
- *
2383
- * @author Kjell-Inge Gustafsson <[email protected]>
2384
- * @since 2.4.8 - 2008-10-22
2385
- * @return string
2386
- */
2387
-  function createDue() {
2380
+     * creates formatted output for calendar component property due
2381
+     *
2382
+     * @author Kjell-Inge Gustafsson <[email protected]>
2383
+     * @since 2.4.8 - 2008-10-22
2384
+     * @return string
2385
+     */
2386
+    function createDue() {
2388 2387
     if( empty( $this->due )) return FALSE;
2389 2388
     if( !isset( $this->due['value']['year'] )  &&
2390 2389
         !isset( $this->due['value']['month'] ) &&
@@ -2392,154 +2391,154 @@  discard block
 block discarded – undo
2392 2391
         !isset( $this->due['value']['hour'] )  &&
2393 2392
         !isset( $this->due['value']['min'] )   &&
2394 2393
         !isset( $this->due['value']['sec'] ))
2395
-      if( $this->getConfig( 'allowEmpty' ))
2394
+        if( $this->getConfig( 'allowEmpty' ))
2396 2395
         return $this->_createElement( 'DUE' );
2397
-      else return FALSE;
2396
+        else return FALSE;
2398 2397
     $formatted  = $this->_format_date_time( $this->due['value'] );
2399 2398
     $attributes = $this->_createParams( $this->due['params'] );
2400 2399
     return $this->_createElement( 'DUE', $attributes, $formatted );
2401
-  }
2400
+    }
2402 2401
 /**
2403
- * set calendar component property due
2404
- *
2405
- * @author Kjell-Inge Gustafsson <[email protected]>
2406
- * @since 2.4.8 - 2008-11-04
2407
- * @param mixed $year
2408
- * @param mixed $month optional
2409
- * @param int $day optional
2410
- * @param int $hour optional
2411
- * @param int $min optional
2412
- * @param int $sec optional
2413
- * @param array $params optional
2414
- * @return bool
2415
- */
2416
-  function setDue( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
2402
+     * set calendar component property due
2403
+     *
2404
+     * @author Kjell-Inge Gustafsson <[email protected]>
2405
+     * @since 2.4.8 - 2008-11-04
2406
+     * @param mixed $year
2407
+     * @param mixed $month optional
2408
+     * @param int $day optional
2409
+     * @param int $hour optional
2410
+     * @param int $min optional
2411
+     * @param int $sec optional
2412
+     * @param array $params optional
2413
+     * @return bool
2414
+     */
2415
+    function setDue( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
2417 2416
     if( empty( $year )) {
2418
-      if( $this->getConfig( 'allowEmpty' )) {
2417
+        if( $this->getConfig( 'allowEmpty' )) {
2419 2418
         $this->due = array( 'value' => null, 'params' => $this->_setParams( $params ));
2420 2419
         return TRUE;
2421
-      }
2422
-      else
2420
+        }
2421
+        else
2423 2422
         return FALSE;
2424 2423
     }
2425 2424
     $this->due = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params );
2426 2425
     return TRUE;
2427
-  }
2426
+    }
2428 2427
 /*********************************************************************************/
2429 2428
 /**
2430
- * Property Name: DURATION
2431
- */
2429
+     * Property Name: DURATION
2430
+     */
2432 2431
 /**
2433
- * creates formatted output for calendar component property duration
2434
- *
2435
- * @author Kjell-Inge Gustafsson <[email protected]>
2436
- * @since 2.4.8 - 2008-10-21
2437
- * @return string
2438
- */
2439
-  function createDuration() {
2432
+     * creates formatted output for calendar component property duration
2433
+     *
2434
+     * @author Kjell-Inge Gustafsson <[email protected]>
2435
+     * @since 2.4.8 - 2008-10-21
2436
+     * @return string
2437
+     */
2438
+    function createDuration() {
2440 2439
     if( empty( $this->duration )) return FALSE;
2441 2440
     if( !isset( $this->duration['value']['week'] ) &&
2442 2441
         !isset( $this->duration['value']['day'] )  &&
2443 2442
         !isset( $this->duration['value']['hour'] ) &&
2444 2443
         !isset( $this->duration['value']['min'] )  &&
2445 2444
         !isset( $this->duration['value']['sec'] ))
2446
-      if( $this->getConfig( 'allowEmpty' ))
2445
+        if( $this->getConfig( 'allowEmpty' ))
2447 2446
         return $this->_createElement( 'DURATION', array(), null );
2448
-      else return FALSE;
2447
+        else return FALSE;
2449 2448
     $attributes = $this->_createParams( $this->duration['params'] );
2450 2449
     return $this->_createElement( 'DURATION', $attributes, $this->_format_duration( $this->duration['value'] ));
2451
-  }
2450
+    }
2452 2451
 /**
2453
- * set calendar component property duration
2454
- *
2455
- * @author Kjell-Inge Gustafsson <[email protected]>
2456
- * @since 2.4.8 - 2008-11-04
2457
- * @param mixed $week
2458
- * @param mixed $day optional
2459
- * @param int $hour optional
2460
- * @param int $min optional
2461
- * @param int $sec optional
2462
- * @param array $params optional
2463
- * @return bool
2464
- */
2465
-  function setDuration( $week, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2452
+     * set calendar component property duration
2453
+     *
2454
+     * @author Kjell-Inge Gustafsson <[email protected]>
2455
+     * @since 2.4.8 - 2008-11-04
2456
+     * @param mixed $week
2457
+     * @param mixed $day optional
2458
+     * @param int $hour optional
2459
+     * @param int $min optional
2460
+     * @param int $sec optional
2461
+     * @param array $params optional
2462
+     * @return bool
2463
+     */
2464
+    function setDuration( $week, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2466 2465
     if( empty( $week )) if( $this->getConfig( 'allowEmpty' )) $week = null; else return FALSE;
2467 2466
     if( is_array( $week ) && ( 1 <= count( $week )))
2468
-      $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day ));
2467
+        $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day ));
2469 2468
     elseif( is_string( $week ) && ( 3 <= strlen( trim( $week )))) {
2470
-      $week = trim( $week );
2471
-      if( in_array( substr( $week, 0, 1 ), array( '+', '-' )))
2469
+        $week = trim( $week );
2470
+        if( in_array( substr( $week, 0, 1 ), array( '+', '-' )))
2472 2471
         $week = substr( $week, 1 );
2473
-      $this->duration = array( 'value' => $this->_duration_string( $week ), 'params' => $this->_setParams( $day ));
2472
+        $this->duration = array( 'value' => $this->_duration_string( $week ), 'params' => $this->_setParams( $day ));
2474 2473
     }
2475 2474
     elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec ))
2476
-      return FALSE;
2475
+        return FALSE;
2477 2476
     else
2478
-      $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params ));
2477
+        $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params ));
2479 2478
     return TRUE;
2480
-  }
2479
+    }
2481 2480
 /*********************************************************************************/
2482 2481
 /**
2483
- * Property Name: EXDATE
2484
- */
2482
+     * Property Name: EXDATE
2483
+     */
2485 2484
 /**
2486
- * creates formatted output for calendar component property exdate
2487
- *
2488
- * @author Kjell-Inge Gustafsson <[email protected]>
2489
- * @since 2.4.8 - 2008-10-22
2490
- * @return string
2491
- */
2492
-  function createExdate() {
2485
+     * creates formatted output for calendar component property exdate
2486
+     *
2487
+     * @author Kjell-Inge Gustafsson <[email protected]>
2488
+     * @since 2.4.8 - 2008-10-22
2489
+     * @return string
2490
+     */
2491
+    function createExdate() {
2493 2492
     if( empty( $this->exdate )) return FALSE;
2494 2493
     $output = null;
2495 2494
     foreach( $this->exdate as $ex => $theExdate ) {
2496
-      if( empty( $theExdate['value'] )) {
2495
+        if( empty( $theExdate['value'] )) {
2497 2496
         if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'EXDATE' );
2498 2497
         continue;
2499
-      }
2500
-      $content = $attributes = null;
2501
-      foreach( $theExdate['value'] as $eix => $exdatePart ) {
2498
+        }
2499
+        $content = $attributes = null;
2500
+        foreach( $theExdate['value'] as $eix => $exdatePart ) {
2502 2501
         $parno = count( $exdatePart );
2503 2502
         $formatted = $this->_format_date_time( $exdatePart, $parno );
2504 2503
         if( isset( $theExdate['params']['TZID'] ))
2505
-          $formatted = str_replace( 'Z', '', $formatted);
2504
+            $formatted = str_replace( 'Z', '', $formatted);
2506 2505
         if( 0 < $eix ) {
2507
-          if( isset( $theExdate['value'][0]['tz'] )) {
2506
+            if( isset( $theExdate['value'][0]['tz'] )) {
2508 2507
             if( ctype_digit( substr( $theExdate['value'][0]['tz'], -4 )) ||
2509 2508
                ( 'Z' == $theExdate['value'][0]['tz'] )) {
2510
-              if( 'Z' != substr( $formatted, -1 ))
2509
+                if( 'Z' != substr( $formatted, -1 ))
2511 2510
                 $formatted .= 'Z';
2512 2511
             }
2513 2512
             else
2514
-              $formatted = str_replace( 'Z', '', $formatted );
2515
-          }
2516
-          else
2513
+                $formatted = str_replace( 'Z', '', $formatted );
2514
+            }
2515
+            else
2517 2516
             $formatted = str_replace( 'Z', '', $formatted );
2518 2517
         }
2519 2518
         $content .= ( 0 < $eix ) ? ','.$formatted : $formatted;
2520
-      }
2521
-      $attributes .= $this->_createParams( $theExdate['params'] );
2522
-      $output .= $this->_createElement( 'EXDATE', $attributes, $content );
2519
+        }
2520
+        $attributes .= $this->_createParams( $theExdate['params'] );
2521
+        $output .= $this->_createElement( 'EXDATE', $attributes, $content );
2523 2522
     }
2524 2523
     return $output;
2525
-  }
2524
+    }
2526 2525
 /**
2527
- * set calendar component property exdate
2528
- *
2529
- * @author Kjell-Inge Gustafsson <[email protected]>
2530
- * @since 2.5.1 - 2008-11-05
2531
- * @param array exdates
2532
- * @param array $params, optional
2533
- * @param integer $index, optional
2534
- * @return bool
2535
- */
2536
-  function setExdate( $exdates, $params=FALSE, $index=FALSE ) {
2526
+     * set calendar component property exdate
2527
+     *
2528
+     * @author Kjell-Inge Gustafsson <[email protected]>
2529
+     * @since 2.5.1 - 2008-11-05
2530
+     * @param array exdates
2531
+     * @param array $params, optional
2532
+     * @param integer $index, optional
2533
+     * @return bool
2534
+     */
2535
+    function setExdate( $exdates, $params=FALSE, $index=FALSE ) {
2537 2536
     if( empty( $exdates )) {
2538
-      if( $this->getConfig( 'allowEmpty' )) {
2537
+        if( $this->getConfig( 'allowEmpty' )) {
2539 2538
         $this->_setMval( $this->exdate, null, $params, FALSE, $index );
2540 2539
         return TRUE;
2541
-      }
2542
-      else
2540
+        }
2541
+        else
2543 2542
         return FALSE;
2544 2543
     }
2545 2544
     $input  = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )));
@@ -2547,519 +2546,519 @@  discard block
 block discarded – undo
2547 2546
     $this->_chkdatecfg( reset( $exdates ), $parno, $input['params'] );
2548 2547
     $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default parameter
2549 2548
     foreach( $exdates as $eix => $theExdate ) {
2550
-      if( $this->_isArrayTimestampDate( $theExdate ))
2549
+        if( $this->_isArrayTimestampDate( $theExdate ))
2551 2550
         $exdatea = $this->_timestamp2date( $theExdate, $parno );
2552
-      elseif(  is_array( $theExdate ))
2551
+        elseif(  is_array( $theExdate ))
2553 2552
         $exdatea = $this->_date_time_array( $theExdate, $parno );
2554
-      elseif( 8 <= strlen( trim( $theExdate ))) // ex. 2006-08-03 10:12:18
2553
+        elseif( 8 <= strlen( trim( $theExdate ))) // ex. 2006-08-03 10:12:18
2555 2554
         $exdatea = $this->_date_time_string( $theExdate, $parno );
2556
-      if( 3 == $parno )
2555
+        if( 3 == $parno )
2557 2556
         unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] );
2558
-      elseif( isset( $exdatea['tz'] ))
2557
+        elseif( isset( $exdatea['tz'] ))
2559 2558
         $exdatea['tz'] = (string) $exdatea['tz'];
2560
-      if(  isset( $input['params']['TZID'] ) ||
2559
+        if(  isset( $input['params']['TZID'] ) ||
2561 2560
          ( isset( $exdatea['tz'] ) && !$this->_isOffset( $exdatea['tz'] )) ||
2562 2561
          ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) ||
2563 2562
          ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] )))
2564 2563
         unset( $exdatea['tz'] );
2565
-      $input['value'][] = $exdatea;
2564
+        $input['value'][] = $exdatea;
2566 2565
     }
2567 2566
     if( 0 >= count( $input['value'] ))
2568
-      return FALSE;
2567
+        return FALSE;
2569 2568
     if( 3 == $parno ) {
2570
-      $input['params']['VALUE'] = 'DATE';
2571
-      unset( $input['params']['TZID'] );
2569
+        $input['params']['VALUE'] = 'DATE';
2570
+        unset( $input['params']['TZID'] );
2572 2571
     }
2573 2572
     $this->_setMval( $this->exdate, $input['value'], $input['params'], FALSE, $index );
2574 2573
     return TRUE;
2575
-  }
2574
+    }
2576 2575
 /*********************************************************************************/
2577 2576
 /**
2578
- * Property Name: EXRULE
2579
- */
2577
+     * Property Name: EXRULE
2578
+     */
2580 2579
 /**
2581
- * creates formatted output for calendar component property exrule
2582
- *
2583
- * @author Kjell-Inge Gustafsson <[email protected]>
2584
- * @since 2.4.8 - 2008-10-22
2585
- * @return string
2586
- */
2587
-  function createExrule() {
2580
+     * creates formatted output for calendar component property exrule
2581
+     *
2582
+     * @author Kjell-Inge Gustafsson <[email protected]>
2583
+     * @since 2.4.8 - 2008-10-22
2584
+     * @return string
2585
+     */
2586
+    function createExrule() {
2588 2587
     if( empty( $this->exrule )) return FALSE;
2589 2588
     return $this->_format_recur( 'EXRULE', $this->exrule );
2590
-  }
2589
+    }
2591 2590
 /**
2592
- * set calendar component property exdate
2593
- *
2594
- * @author Kjell-Inge Gustafsson <[email protected]>
2595
- * @since 2.5.1 - 2008-11-05
2596
- * @param array $exruleset
2597
- * @param array $params, optional
2598
- * @param integer $index, optional
2599
- * @return bool
2600
- */
2601
-  function setExrule( $exruleset, $params=FALSE, $index=FALSE ) {
2591
+     * set calendar component property exdate
2592
+     *
2593
+     * @author Kjell-Inge Gustafsson <[email protected]>
2594
+     * @since 2.5.1 - 2008-11-05
2595
+     * @param array $exruleset
2596
+     * @param array $params, optional
2597
+     * @param integer $index, optional
2598
+     * @return bool
2599
+     */
2600
+    function setExrule( $exruleset, $params=FALSE, $index=FALSE ) {
2602 2601
     if( empty( $exruleset )) if( $this->getConfig( 'allowEmpty' )) $exruleset = null; else return FALSE;
2603 2602
     $this->_setMval( $this->exrule, $this->_setRexrule( $exruleset ), $params, FALSE, $index );
2604 2603
     return TRUE;
2605
-  }
2604
+    }
2606 2605
 /*********************************************************************************/
2607 2606
 /**
2608
- * Property Name: FREEBUSY
2609
- */
2607
+     * Property Name: FREEBUSY
2608
+     */
2610 2609
 /**
2611
- * creates formatted output for calendar component property freebusy
2612
- *
2613
- * @author Kjell-Inge Gustafsson <[email protected]>
2614
- * @since 2.4.8 - 2008-10-22
2615
- * @return string
2616
- */
2617
-  function createFreebusy() {
2610
+     * creates formatted output for calendar component property freebusy
2611
+     *
2612
+     * @author Kjell-Inge Gustafsson <[email protected]>
2613
+     * @since 2.4.8 - 2008-10-22
2614
+     * @return string
2615
+     */
2616
+    function createFreebusy() {
2618 2617
     if( empty( $this->freebusy )) return FALSE;
2619 2618
     $output = null;
2620 2619
     foreach( $this->freebusy as $freebusyPart ) {
2621
-      if( empty( $freebusyPart['value'] )) {
2620
+        if( empty( $freebusyPart['value'] )) {
2622 2621
         if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'FREEBUSY' );
2623 2622
         continue;
2624
-      }
2625
-      $attributes = $content = null;
2626
-      if( isset( $freebusyPart['value']['fbtype'] )) {
2623
+        }
2624
+        $attributes = $content = null;
2625
+        if( isset( $freebusyPart['value']['fbtype'] )) {
2627 2626
         $attributes .= $this->intAttrDelimiter.'FBTYPE='.$freebusyPart['value']['fbtype'];
2628 2627
         unset( $freebusyPart['value']['fbtype'] );
2629 2628
         $freebusyPart['value'] = array_values( $freebusyPart['value'] );
2630
-      }
2631
-      else
2629
+        }
2630
+        else
2632 2631
         $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY';
2633
-      $attributes .= $this->_createParams( $freebusyPart['params'] );
2634
-      $fno = 1;
2635
-      $cnt = count( $freebusyPart['value']);
2636
-      foreach( $freebusyPart['value'] as $periodix => $freebusyPeriod ) {
2632
+        $attributes .= $this->_createParams( $freebusyPart['params'] );
2633
+        $fno = 1;
2634
+        $cnt = count( $freebusyPart['value']);
2635
+        foreach( $freebusyPart['value'] as $periodix => $freebusyPeriod ) {
2637 2636
         $formatted   = $this->_format_date_time( $freebusyPeriod[0] );
2638 2637
         $content .= $formatted;
2639 2638
         $content .= '/';
2640 2639
         $cnt2 = count( $freebusyPeriod[1]);
2641 2640
         if( array_key_exists( 'year', $freebusyPeriod[1] ))      // date-time
2642
-          $cnt2 = 7;
2641
+            $cnt2 = 7;
2643 2642
         elseif( array_key_exists( 'week', $freebusyPeriod[1] ))  // duration
2644
-          $cnt2 = 5;
2643
+            $cnt2 = 5;
2645 2644
         if(( 7 == $cnt2 )   &&    // period=  -> date-time
2646 2645
             isset( $freebusyPeriod[1]['year'] )  &&
2647 2646
             isset( $freebusyPeriod[1]['month'] ) &&
2648 2647
             isset( $freebusyPeriod[1]['day'] )) {
2649
-          $content .= $this->_format_date_time( $freebusyPeriod[1] );
2648
+            $content .= $this->_format_date_time( $freebusyPeriod[1] );
2650 2649
         }
2651 2650
         else {                                  // period=  -> dur-time
2652
-          $content .= $this->_format_duration( $freebusyPeriod[1] );
2651
+            $content .= $this->_format_duration( $freebusyPeriod[1] );
2653 2652
         }
2654 2653
         if( $fno < $cnt )
2655
-          $content .= ',';
2654
+            $content .= ',';
2656 2655
         $fno++;
2657
-      }
2658
-      $output .= $this->_createElement( 'FREEBUSY', $attributes, $content );
2656
+        }
2657
+        $output .= $this->_createElement( 'FREEBUSY', $attributes, $content );
2659 2658
     }
2660 2659
     return $output;
2661
-  }
2660
+    }
2662 2661
 /**
2663
- * set calendar component property freebusy
2664
- *
2665
- * @author Kjell-Inge Gustafsson <[email protected]>
2666
- * @since 2.5.1 - 2008-11-05
2667
- * @param string $fbType
2668
- * @param array $fbValues
2669
- * @param array $params, optional
2670
- * @param integer $index, optional
2671
- * @return bool
2672
- */
2673
-  function setFreebusy( $fbType, $fbValues, $params=FALSE, $index=FALSE ) {
2662
+     * set calendar component property freebusy
2663
+     *
2664
+     * @author Kjell-Inge Gustafsson <[email protected]>
2665
+     * @since 2.5.1 - 2008-11-05
2666
+     * @param string $fbType
2667
+     * @param array $fbValues
2668
+     * @param array $params, optional
2669
+     * @param integer $index, optional
2670
+     * @return bool
2671
+     */
2672
+    function setFreebusy( $fbType, $fbValues, $params=FALSE, $index=FALSE ) {
2674 2673
     if( empty( $fbValues )) {
2675
-      if( $this->getConfig( 'allowEmpty' )) {
2674
+        if( $this->getConfig( 'allowEmpty' )) {
2676 2675
         $this->_setMval( $this->freebusy, null, $params, FALSE, $index );
2677 2676
         return TRUE;
2678
-      }
2679
-      else
2677
+        }
2678
+        else
2680 2679
         return FALSE;
2681 2680
     }
2682 2681
     $fbType = strtoupper( $fbType );
2683 2682
     if(( !in_array( $fbType, array( 'FREE', 'BUSY', 'BUSY-UNAVAILABLE', 'BUSY-TENTATIVE' ))) &&
2684 2683
        ( 'X-' != substr( $fbType, 0, 2 )))
2685
-      $fbType = 'BUSY';
2684
+        $fbType = 'BUSY';
2686 2685
     $input = array( 'fbtype' => $fbType );
2687 2686
     foreach( $fbValues as $fbPeriod ) {   // periods => period
2688
-      $freebusyPeriod = array();
2689
-      foreach( $fbPeriod as $fbMember ) { // pairs => singlepart
2687
+        $freebusyPeriod = array();
2688
+        foreach( $fbPeriod as $fbMember ) { // pairs => singlepart
2690 2689
         $freebusyPairMember = array();
2691 2690
         if( is_array( $fbMember )) {
2692
-          if( $this->_isArrayDate( $fbMember )) { // date-time value
2691
+            if( $this->_isArrayDate( $fbMember )) { // date-time value
2693 2692
             $freebusyPairMember       = $this->_date_time_array( $fbMember, 7 );
2694 2693
             $freebusyPairMember['tz'] = 'Z';
2695
-          }
2696
-          elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value
2694
+            }
2695
+            elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value
2697 2696
             $freebusyPairMember       = $this->_timestamp2date( $fbMember['timestamp'], 7 );
2698 2697
             $freebusyPairMember['tz'] = 'Z';
2699
-          }
2700
-          else {                                         // array format duration
2698
+            }
2699
+            else {                                         // array format duration
2701 2700
             $freebusyPairMember = $this->_duration_array( $fbMember );
2702
-          }
2701
+            }
2703 2702
         }
2704 2703
         elseif(( 3 <= strlen( trim( $fbMember ))) &&    // string format duration
2705 2704
                ( in_array( $fbMember{0}, array( 'P', '+', '-' )))) {
2706
-          if( 'P' != $fbMember{0} )
2705
+            if( 'P' != $fbMember{0} )
2707 2706
             $fbmember = substr( $fbMember, 1 );
2708
-          $freebusyPairMember = $this->_duration_string( $fbMember );
2707
+            $freebusyPairMember = $this->_duration_string( $fbMember );
2709 2708
         }
2710 2709
         elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18
2711
-          $freebusyPairMember       = $this->_date_time_string( $fbMember, 7 );
2712
-          $freebusyPairMember['tz'] = 'Z';
2710
+            $freebusyPairMember       = $this->_date_time_string( $fbMember, 7 );
2711
+            $freebusyPairMember['tz'] = 'Z';
2713 2712
         }
2714 2713
         $freebusyPeriod[]   = $freebusyPairMember;
2715
-      }
2716
-      $input[]              = $freebusyPeriod;
2714
+        }
2715
+        $input[]              = $freebusyPeriod;
2717 2716
     }
2718 2717
     $this->_setMval( $this->freebusy, $input, $params, FALSE, $index );
2719 2718
     return TRUE;
2720
-  }
2719
+    }
2721 2720
 /*********************************************************************************/
2722 2721
 /**
2723
- * Property Name: GEO
2724
- */
2722
+     * Property Name: GEO
2723
+     */
2725 2724
 /**
2726
- * creates formatted output for calendar component property geo
2727
- *
2728
- * @author Kjell-Inge Gustafsson <[email protected]>
2729
- * @since 2.4.8 - 2008-10-21
2730
- * @return string
2731
- */
2732
-  function createGeo() {
2725
+     * creates formatted output for calendar component property geo
2726
+     *
2727
+     * @author Kjell-Inge Gustafsson <[email protected]>
2728
+     * @since 2.4.8 - 2008-10-21
2729
+     * @return string
2730
+     */
2731
+    function createGeo() {
2733 2732
     if( empty( $this->geo )) return FALSE;
2734 2733
     if( empty( $this->geo['value'] ))
2735
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE;
2734
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE;
2736 2735
     $attributes = $this->_createParams( $this->geo['params'] );
2737 2736
     $content    = null;
2738 2737
     $content   .= number_format( (float) $this->geo['value']['latitude'], 6, '.', '');
2739 2738
     $content   .= ';';
2740 2739
     $content   .= number_format( (float) $this->geo['value']['longitude'], 6, '.', '');
2741 2740
     return $this->_createElement( 'GEO', $attributes, $content );
2742
-  }
2741
+    }
2743 2742
 /**
2744
- * set calendar component property geo
2745
- *
2746
- * @author Kjell-Inge Gustafsson <[email protected]>
2747
- * @since 2.4.8 - 2008-11-04
2748
- * @param float $latitude
2749
- * @param float $longitude
2750
- * @param array $params optional
2751
- * @return bool
2752
- */
2753
-  function setGeo( $latitude, $longitude, $params=FALSE ) {
2743
+     * set calendar component property geo
2744
+     *
2745
+     * @author Kjell-Inge Gustafsson <[email protected]>
2746
+     * @since 2.4.8 - 2008-11-04
2747
+     * @param float $latitude
2748
+     * @param float $longitude
2749
+     * @param array $params optional
2750
+     * @return bool
2751
+     */
2752
+    function setGeo( $latitude, $longitude, $params=FALSE ) {
2754 2753
     if( !empty( $latitude ) && !empty( $longitude )) {
2755
-      if( !is_array( $this->geo )) $this->geo = array();
2756
-      $this->geo['value']['latitude']  = $latitude;
2757
-      $this->geo['value']['longitude'] = $longitude;
2758
-      $this->geo['params'] = $this->_setParams( $params );
2754
+        if( !is_array( $this->geo )) $this->geo = array();
2755
+        $this->geo['value']['latitude']  = $latitude;
2756
+        $this->geo['value']['longitude'] = $longitude;
2757
+        $this->geo['params'] = $this->_setParams( $params );
2759 2758
     }
2760 2759
     elseif( $this->getConfig( 'allowEmpty' ))
2761
-      $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) );
2760
+        $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) );
2762 2761
     else
2763
-      return FALSE;
2762
+        return FALSE;
2764 2763
     return TRUE;
2765
-  }
2764
+    }
2766 2765
 /*********************************************************************************/
2767 2766
 /**
2768
- * Property Name: LAST-MODIFIED
2769
- */
2767
+     * Property Name: LAST-MODIFIED
2768
+     */
2770 2769
 /**
2771
- * creates formatted output for calendar component property last-modified
2772
- *
2773
- * @author Kjell-Inge Gustafsson <[email protected]>
2774
- * @since 2.4.8 - 2008-10-21
2775
- * @return string
2776
- */
2777
-  function createLastModified() {
2770
+     * creates formatted output for calendar component property last-modified
2771
+     *
2772
+     * @author Kjell-Inge Gustafsson <[email protected]>
2773
+     * @since 2.4.8 - 2008-10-21
2774
+     * @return string
2775
+     */
2776
+    function createLastModified() {
2778 2777
     if( empty( $this->lastmodified )) return FALSE;
2779 2778
     $attributes = $this->_createParams( $this->lastmodified['params'] );
2780 2779
     $formatted  = $this->_format_date_time( $this->lastmodified['value'], 7 );
2781 2780
     return $this->_createElement( 'LAST-MODIFIED', $attributes, $formatted );
2782
-  }
2781
+    }
2783 2782
 /**
2784
- * set calendar component property completed
2785
- *
2786
- * @author Kjell-Inge Gustafsson <[email protected]>
2787
- * @since 2.4.8 - 2008-10-23
2788
- * @param mixed $year optional
2789
- * @param mixed $month optional
2790
- * @param int $day optional
2791
- * @param int $hour optional
2792
- * @param int $min optional
2793
- * @param int $sec optional
2794
- * @param array $params optional
2795
- * @return boll
2796
- */
2797
-  function setLastModified( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2783
+     * set calendar component property completed
2784
+     *
2785
+     * @author Kjell-Inge Gustafsson <[email protected]>
2786
+     * @since 2.4.8 - 2008-10-23
2787
+     * @param mixed $year optional
2788
+     * @param mixed $month optional
2789
+     * @param int $day optional
2790
+     * @param int $hour optional
2791
+     * @param int $min optional
2792
+     * @param int $sec optional
2793
+     * @param array $params optional
2794
+     * @return boll
2795
+     */
2796
+    function setLastModified( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2798 2797
     if( empty( $year ))
2799
-      $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' )));
2798
+        $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' )));
2800 2799
     $this->lastmodified = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2801 2800
     return TRUE;
2802
-  }
2801
+    }
2803 2802
 /*********************************************************************************/
2804 2803
 /**
2805
- * Property Name: LOCATION
2806
- */
2804
+     * Property Name: LOCATION
2805
+     */
2807 2806
 /**
2808
- * creates formatted output for calendar component property location
2809
- *
2810
- * @author Kjell-Inge Gustafsson <[email protected]>
2811
- * @since 2.4.8 - 2008-10-22
2812
- * @return string
2813
- */
2814
-  function createLocation() {
2807
+     * creates formatted output for calendar component property location
2808
+     *
2809
+     * @author Kjell-Inge Gustafsson <[email protected]>
2810
+     * @since 2.4.8 - 2008-10-22
2811
+     * @return string
2812
+     */
2813
+    function createLocation() {
2815 2814
     if( empty( $this->location )) return FALSE;
2816 2815
     if( empty( $this->location['value'] ))
2817
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE;
2816
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE;
2818 2817
     $attributes = $this->_createParams( $this->location['params'], array( 'ALTREP', 'LANGUAGE' ));
2819 2818
     $content    = $this->_strrep( $this->location['value'] );
2820 2819
     return $this->_createElement( 'LOCATION', $attributes, $content );
2821
-  }
2820
+    }
2822 2821
 /**
2823
- * set calendar component property location
2822
+     * set calendar component property location
2824 2823
  '
2825
- * @author Kjell-Inge Gustafsson <[email protected]>
2826
- * @since 2.4.8 - 2008-11-04
2827
- * @param string $value
2828
- * @param array params optional
2829
- * @return bool
2830
- */
2831
-  function setLocation( $value, $params=FALSE ) {
2824
+     * @author Kjell-Inge Gustafsson <[email protected]>
2825
+     * @since 2.4.8 - 2008-11-04
2826
+     * @param string $value
2827
+     * @param array params optional
2828
+     * @return bool
2829
+     */
2830
+    function setLocation( $value, $params=FALSE ) {
2832 2831
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2833 2832
     $this->location = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2834 2833
     return TRUE;
2835
-  }
2834
+    }
2836 2835
 /*********************************************************************************/
2837 2836
 /**
2838
- * Property Name: ORGANIZER
2839
- */
2837
+     * Property Name: ORGANIZER
2838
+     */
2840 2839
 /**
2841
- * creates formatted output for calendar component property organizer
2842
- *
2843
- * @author Kjell-Inge Gustafsson <[email protected]>
2844
- * @since 2.4.8 - 2008-10-21
2845
- * @return string
2846
- */
2847
-  function createOrganizer() {
2840
+     * creates formatted output for calendar component property organizer
2841
+     *
2842
+     * @author Kjell-Inge Gustafsson <[email protected]>
2843
+     * @since 2.4.8 - 2008-10-21
2844
+     * @return string
2845
+     */
2846
+    function createOrganizer() {
2848 2847
     if( empty( $this->organizer )) return FALSE;
2849 2848
     if( empty( $this->organizer['value'] ))
2850
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE;
2849
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE;
2851 2850
     $attributes = $this->_createParams( $this->organizer['params']
2852
-                                      , array( 'CN', 'DIR', 'LANGUAGE', 'SENT-BY' ));
2851
+                                        , array( 'CN', 'DIR', 'LANGUAGE', 'SENT-BY' ));
2853 2852
     $content    = 'MAILTO:'.$this->organizer['value'];
2854 2853
     return $this->_createElement( 'ORGANIZER', $attributes, $content );
2855
-  }
2854
+    }
2856 2855
 /**
2857
- * set calendar component property organizer
2858
- *
2859
- * @author Kjell-Inge Gustafsson <[email protected]>
2860
- * @since 2.4.8 - 2008-11-04
2861
- * @param string $value
2862
- * @param array params optional
2863
- * @return bool
2864
- */
2865
-  function setOrganizer( $value, $params=FALSE ) {
2856
+     * set calendar component property organizer
2857
+     *
2858
+     * @author Kjell-Inge Gustafsson <[email protected]>
2859
+     * @since 2.4.8 - 2008-11-04
2860
+     * @param string $value
2861
+     * @param array params optional
2862
+     * @return bool
2863
+     */
2864
+    function setOrganizer( $value, $params=FALSE ) {
2866 2865
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2867 2866
     $value = str_replace ( 'MAILTO:', '', $value );
2868 2867
     $value = str_replace ( 'mailto:', '', $value );
2869 2868
     $this->organizer = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2870 2869
     if( isset( $this->organizer['params']['SENT-BY'] )) {
2871
-      if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 )))
2870
+        if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 )))
2872 2871
         $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 );
2873 2872
     }
2874 2873
     return TRUE;
2875
-  }
2874
+    }
2876 2875
 /*********************************************************************************/
2877 2876
 /**
2878
- * Property Name: PERCENT-COMPLETE
2879
- */
2877
+     * Property Name: PERCENT-COMPLETE
2878
+     */
2880 2879
 /**
2881
- * creates formatted output for calendar component property percent-complete
2882
- *
2883
- * @author Kjell-Inge Gustafsson <[email protected]>
2884
- * @since 2.4.8 - 2008-10-22
2885
- * @return string
2886
- */
2887
-  function createPercentComplete() {
2880
+     * creates formatted output for calendar component property percent-complete
2881
+     *
2882
+     * @author Kjell-Inge Gustafsson <[email protected]>
2883
+     * @since 2.4.8 - 2008-10-22
2884
+     * @return string
2885
+     */
2886
+    function createPercentComplete() {
2888 2887
     if( empty( $this->percentcomplete )) return FALSE;
2889 2888
     if( empty( $this->percentcomplete['value'] ))
2890
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE;
2889
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE;
2891 2890
     $attributes = $this->_createParams( $this->percentcomplete['params'] );
2892 2891
     return $this->_createElement( 'PERCENT-COMPLETE', $attributes, $this->percentcomplete['value'] );
2893
-  }
2892
+    }
2894 2893
 /**
2895
- * set calendar component property percent-complete
2896
- *
2897
- * @author Kjell-Inge Gustafsson <[email protected]>
2898
- * @since 2.4.8 - 2008-11-04
2899
- * @param int $value
2900
- * @param array $params optional
2901
- * @return bool
2902
- */
2903
-  function setPercentComplete( $value, $params=FALSE ) {
2894
+     * set calendar component property percent-complete
2895
+     *
2896
+     * @author Kjell-Inge Gustafsson <[email protected]>
2897
+     * @since 2.4.8 - 2008-11-04
2898
+     * @param int $value
2899
+     * @param array $params optional
2900
+     * @return bool
2901
+     */
2902
+    function setPercentComplete( $value, $params=FALSE ) {
2904 2903
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2905 2904
     $this->percentcomplete = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2906 2905
     return TRUE;
2907
-  }
2906
+    }
2908 2907
 /*********************************************************************************/
2909 2908
 /**
2910
- * Property Name: PRIORITY
2911
- */
2909
+     * Property Name: PRIORITY
2910
+     */
2912 2911
 /**
2913
- * creates formatted output for calendar component property priority
2914
- *
2915
- * @author Kjell-Inge Gustafsson <[email protected]>
2916
- * @since 2.4.8 - 2008-10-21
2917
- * @return string
2918
- */
2919
-  function createPriority() {
2912
+     * creates formatted output for calendar component property priority
2913
+     *
2914
+     * @author Kjell-Inge Gustafsson <[email protected]>
2915
+     * @since 2.4.8 - 2008-10-21
2916
+     * @return string
2917
+     */
2918
+    function createPriority() {
2920 2919
     if( empty( $this->priority )) return FALSE;
2921 2920
     if( empty( $this->priority['value'] ))
2922
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE;
2921
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE;
2923 2922
     $attributes = $this->_createParams( $this->priority['params'] );
2924 2923
     return $this->_createElement( 'PRIORITY', $attributes, $this->priority['value'] );
2925
-  }
2924
+    }
2926 2925
 /**
2927
- * set calendar component property priority
2928
- *
2929
- * @author Kjell-Inge Gustafsson <[email protected]>
2930
- * @since 2.4.8 - 2008-11-04
2931
- * @param int $value
2932
- * @param array $params optional
2933
- * @return bool
2934
- */
2935
-  function setPriority( $value, $params=FALSE  ) {
2926
+     * set calendar component property priority
2927
+     *
2928
+     * @author Kjell-Inge Gustafsson <[email protected]>
2929
+     * @since 2.4.8 - 2008-11-04
2930
+     * @param int $value
2931
+     * @param array $params optional
2932
+     * @return bool
2933
+     */
2934
+    function setPriority( $value, $params=FALSE  ) {
2936 2935
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2937 2936
     $this->priority = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2938 2937
     return TRUE;
2939
-  }
2938
+    }
2940 2939
 /*********************************************************************************/
2941 2940
 /**
2942
- * Property Name: RDATE
2943
- */
2941
+     * Property Name: RDATE
2942
+     */
2944 2943
 /**
2945
- * creates formatted output for calendar component property rdate
2946
- *
2947
- * @author Kjell-Inge Gustafsson <[email protected]>
2948
- * @since 2.4.16 - 2008-10-26
2949
- * @return string
2950
- */
2951
-  function createRdate() {
2944
+     * creates formatted output for calendar component property rdate
2945
+     *
2946
+     * @author Kjell-Inge Gustafsson <[email protected]>
2947
+     * @since 2.4.16 - 2008-10-26
2948
+     * @return string
2949
+     */
2950
+    function createRdate() {
2952 2951
     if( empty( $this->rdate )) return FALSE;
2953 2952
     $utctime = ( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE;
2954 2953
     $output = null;
2955 2954
     if( $utctime  )
2956
-      unset( $this->rdate['params']['TZID'] );
2955
+        unset( $this->rdate['params']['TZID'] );
2957 2956
     foreach( $this->rdate as $theRdate ) {
2958
-      if( empty( $theRdate['value'] )) {
2957
+        if( empty( $theRdate['value'] )) {
2959 2958
         if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RDATE' );
2960 2959
         continue;
2961
-      }
2962
-      if( $utctime  )
2960
+        }
2961
+        if( $utctime  )
2963 2962
         unset( $theRdate['params']['TZID'] );
2964
-      $attributes = $this->_createParams( $theRdate['params'] );
2965
-      $cnt = count( $theRdate['value'] );
2966
-      $content = null;
2967
-      $rno = 1;
2968
-      foreach( $theRdate['value'] as $rpix => $rdatePart ) {
2963
+        $attributes = $this->_createParams( $theRdate['params'] );
2964
+        $cnt = count( $theRdate['value'] );
2965
+        $content = null;
2966
+        $rno = 1;
2967
+        foreach( $theRdate['value'] as $rpix => $rdatePart ) {
2969 2968
         $contentPart = null;
2970 2969
         if( is_array( $rdatePart ) &&
2971 2970
             isset( $theRdate['params']['VALUE'] ) && ( 'PERIOD' == $theRdate['params']['VALUE'] )) { // PERIOD
2972
-          if( $utctime )
2971
+            if( $utctime )
2973 2972
             unset( $rdatePart[0]['tz'] );
2974
-          $formatted = $this->_format_date_time( $rdatePart[0]); // PERIOD part 1
2975
-          if( $utctime || !empty( $theRdate['params']['TZID'] ))
2973
+            $formatted = $this->_format_date_time( $rdatePart[0]); // PERIOD part 1
2974
+            if( $utctime || !empty( $theRdate['params']['TZID'] ))
2976 2975
             $formatted = str_replace( 'Z', '', $formatted);
2977
-          if( 0 < $rpix ) {
2976
+            if( 0 < $rpix ) {
2978 2977
             if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) {
2979
-              if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z';
2978
+                if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z';
2980 2979
             }
2981 2980
             else
2982
-              $formatted = str_replace( 'Z', '', $formatted );
2983
-          }
2984
-          $contentPart .= $formatted;
2985
-          $contentPart .= '/';
2986
-          $cnt2 = count( $rdatePart[1]);
2987
-          if( array_key_exists( 'year', $rdatePart[1] )) {
2981
+                $formatted = str_replace( 'Z', '', $formatted );
2982
+            }
2983
+            $contentPart .= $formatted;
2984
+            $contentPart .= '/';
2985
+            $cnt2 = count( $rdatePart[1]);
2986
+            if( array_key_exists( 'year', $rdatePart[1] )) {
2988 2987
             if( array_key_exists( 'hour', $rdatePart[1] ))
2989
-              $cnt2 = 7;                                      // date-time
2988
+                $cnt2 = 7;                                      // date-time
2990 2989
             else
2991
-              $cnt2 = 3;                                      // date
2992
-          }
2993
-          elseif( array_key_exists( 'week', $rdatePart[1] ))  // duration
2990
+                $cnt2 = 3;                                      // date
2991
+            }
2992
+            elseif( array_key_exists( 'week', $rdatePart[1] ))  // duration
2994 2993
             $cnt2 = 5;
2995
-          if(( 7 == $cnt2 )   &&    // period=  -> date-time
2994
+            if(( 7 == $cnt2 )   &&    // period=  -> date-time
2996 2995
               isset( $rdatePart[1]['year'] )  &&
2997 2996
               isset( $rdatePart[1]['month'] ) &&
2998 2997
               isset( $rdatePart[1]['day'] )) {
2999 2998
             if( $utctime )
3000
-              unset( $rdatePart[1]['tz'] );
2999
+                unset( $rdatePart[1]['tz'] );
3001 3000
             $formatted = $this->_format_date_time( $rdatePart[1] ); // PERIOD part 2
3002 3001
             if( $utctime || !empty( $theRdate['params']['TZID'] ))
3003
-              $formatted = str_replace( 'Z', '', $formatted);
3002
+                $formatted = str_replace( 'Z', '', $formatted);
3004 3003
             if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) {
3005
-              if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z';
3004
+                if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z';
3006 3005
             }
3007 3006
             else
3008
-              $formatted = str_replace( 'Z', '', $formatted );
3009
-           $contentPart .= $formatted;
3010
-          }
3011
-          else {                                  // period=  -> dur-time
3007
+                $formatted = str_replace( 'Z', '', $formatted );
3008
+            $contentPart .= $formatted;
3009
+            }
3010
+            else {                                  // period=  -> dur-time
3012 3011
             $contentPart .= $this->_format_duration( $rdatePart[1] );
3013
-          }
3012
+            }
3014 3013
         } // PERIOD end
3015 3014
         else { // SINGLE date start
3016
-          if( $utctime )
3015
+            if( $utctime )
3017 3016
             unset( $rdatePart['tz'] );
3018
-          $formatted = $this->_format_date_time( $rdatePart);
3019
-          if( $utctime || !empty( $theRdate['params']['TZID'] ))
3017
+            $formatted = $this->_format_date_time( $rdatePart);
3018
+            if( $utctime || !empty( $theRdate['params']['TZID'] ))
3020 3019
             $formatted = str_replace( 'Z', '', $formatted);
3021
-          if( !$utctime && ( 0 < $rpix )) {
3020
+            if( !$utctime && ( 0 < $rpix )) {
3022 3021
             if( !empty( $theRdate['value'][0]['tz'] ) && $this->_isOffset( $theRdate['value'][0]['tz'] )) {
3023
-              if( 'Z' != substr( $formatted, -1 ))
3022
+                if( 'Z' != substr( $formatted, -1 ))
3024 3023
                 $formatted .= 'Z';
3025 3024
             }
3026 3025
             else
3027
-              $formatted = str_replace( 'Z', '', $formatted );
3028
-          }
3029
-          $contentPart .= $formatted;
3026
+                $formatted = str_replace( 'Z', '', $formatted );
3027
+            }
3028
+            $contentPart .= $formatted;
3030 3029
         }
3031 3030
         $content .= $contentPart;
3032 3031
         if( $rno < $cnt )
3033
-          $content .= ',';
3032
+            $content .= ',';
3034 3033
         $rno++;
3035
-      }
3036
-      $output    .= $this->_createElement( 'RDATE', $attributes, $content );
3034
+        }
3035
+        $output    .= $this->_createElement( 'RDATE', $attributes, $content );
3037 3036
     }
3038 3037
     return $output;
3039
-  }
3038
+    }
3040 3039
 /**
3041
- * set calendar component property rdate
3042
- *
3043
- * @author Kjell-Inge Gustafsson <[email protected]>
3044
- * @since 2.5.1 - 2008-11-07
3045
- * @param array $rdates
3046
- * @param array $params, optional
3047
- * @param integer $index, optional
3048
- * @return bool
3049
- */
3050
-  function setRdate( $rdates, $params=FALSE, $index=FALSE ) {
3040
+     * set calendar component property rdate
3041
+     *
3042
+     * @author Kjell-Inge Gustafsson <[email protected]>
3043
+     * @since 2.5.1 - 2008-11-07
3044
+     * @param array $rdates
3045
+     * @param array $params, optional
3046
+     * @param integer $index, optional
3047
+     * @return bool
3048
+     */
3049
+    function setRdate( $rdates, $params=FALSE, $index=FALSE ) {
3051 3050
     if( empty( $rdates )) {
3052
-      if( $this->getConfig( 'allowEmpty' )) {
3051
+        if( $this->getConfig( 'allowEmpty' )) {
3053 3052
         $this->_setMval( $this->rdate, null, $params, FALSE, $index );
3054 3053
         return TRUE;
3055
-      }
3056
-      else
3054
+        }
3055
+        else
3057 3056
         return FALSE;
3058 3057
     }
3059 3058
     $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )));
3060 3059
     if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) {
3061
-      unset( $input['params']['TZID'] );
3062
-      $input['params']['VALUE'] = 'DATE-TIME';
3060
+        unset( $input['params']['TZID'] );
3061
+        $input['params']['VALUE'] = 'DATE-TIME';
3063 3062
     }
3064 3063
             /*  check if PERIOD, if not set */
3065 3064
     if((!isset( $input['params']['VALUE'] ) || !in_array( $input['params']['VALUE'], array( 'DATE', 'PERIOD' ))) &&
@@ -3069,769 +3068,769 @@  discard block
 block discarded – undo
3069 3068
                                       $this->_isArrayDate( $rdates[0][0] ))) ||
3070 3069
                                     ( is_string( $rdates[0][0] ) && ( 8 <= strlen( trim( $rdates[0][0] )))))  &&
3071 3070
      ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] ))))))
3072
-      $input['params']['VALUE'] = 'PERIOD';
3071
+        $input['params']['VALUE'] = 'PERIOD';
3073 3072
             /* check 1:st date, upd. $parno (opt) and save ev. timezone **/
3074 3073
     $date  = reset( $rdates );
3075 3074
     if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) // PERIOD
3076
-      $date  = reset( $date );
3075
+        $date  = reset( $date );
3077 3076
     $this->_chkdatecfg( $date, $parno, $input['params'] );
3078 3077
     if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' )))
3079
-      unset( $input['params']['TZID'] );
3078
+        unset( $input['params']['TZID'] );
3080 3079
     $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default
3081 3080
     foreach( $rdates as $rpix => $theRdate ) {
3082
-      $inputa = null;
3083
-      if( is_array( $theRdate )) {
3081
+        $inputa = null;
3082
+        if( is_array( $theRdate )) {
3084 3083
         if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) { // PERIOD
3085
-          foreach( $theRdate as $rix => $rPeriod ) {
3084
+            foreach( $theRdate as $rix => $rPeriod ) {
3086 3085
             if( is_array( $rPeriod )) {
3087
-              if( $this->_isArrayTimestampDate( $rPeriod ))      // timestamp
3086
+                if( $this->_isArrayTimestampDate( $rPeriod ))      // timestamp
3088 3087
                 $inputab  = ( isset( $rPeriod['tz'] )) ? $this->_timestamp2date( $rPeriod, $parno ) : $this->_timestamp2date( $rPeriod, 6 );
3089
-              elseif( $this->_isArrayDate( $rPeriod ))
3088
+                elseif( $this->_isArrayDate( $rPeriod ))
3090 3089
                 $inputab  = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 );
3091
-              elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod ))))  // text-date
3090
+                elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod ))))  // text-date
3092 3091
                 $inputab  = $this->_date_time_string( reset( $rPeriod ), $parno );
3093
-              else                                               // array format duration
3092
+                else                                               // array format duration
3094 3093
                 $inputab  = $this->_duration_array( $rPeriod );
3095 3094
             }
3096 3095
             elseif(( 3 <= strlen( trim( $rPeriod ))) &&          // string format duration
3097 3096
                    ( in_array( $rPeriod{0}, array( 'P', '+', '-' )))) {
3098
-              if( 'P' != $rPeriod{0} )
3097
+                if( 'P' != $rPeriod{0} )
3099 3098
                 $rPeriod  = substr( $rPeriod, 1 );
3100
-              $inputab    = $this->_duration_string( $rPeriod );
3099
+                $inputab    = $this->_duration_string( $rPeriod );
3101 3100
             }
3102 3101
             elseif( 8 <= strlen( trim( $rPeriod )))              // text date ex. 2006-08-03 10:12:18
3103
-              $inputab    = $this->_date_time_string( $rPeriod, $parno );
3102
+                $inputab    = $this->_date_time_string( $rPeriod, $parno );
3104 3103
             if(  isset( $input['params']['TZID'] ) ||
3105 3104
                ( isset( $inputab['tz'] )   && !$this->_isOffset( $inputab['tz'] )) ||
3106 3105
                ( isset( $inputa[0] )       && ( !isset( $inputa[0]['tz'] )))       ||
3107 3106
                ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] )))
3108
-              unset( $inputab['tz'] );
3107
+                unset( $inputab['tz'] );
3109 3108
             $inputa[]     = $inputab;
3110
-          }
3109
+            }
3111 3110
         } // PERIOD end
3112 3111
         elseif ( $this->_isArrayTimestampDate( $theRdate ))      // timestamp
3113
-          $inputa = $this->_timestamp2date( $theRdate, $parno );
3112
+            $inputa = $this->_timestamp2date( $theRdate, $parno );
3114 3113
         else                                                     // date[-time]
3115
-          $inputa = $this->_date_time_array( $theRdate, $parno );
3116
-      }
3117
-      elseif( 8 <= strlen( trim( $theRdate )))                   // text date ex. 2006-08-03 10:12:18
3114
+            $inputa = $this->_date_time_array( $theRdate, $parno );
3115
+        }
3116
+        elseif( 8 <= strlen( trim( $theRdate )))                   // text date ex. 2006-08-03 10:12:18
3118 3117
         $inputa       = $this->_date_time_string( $theRdate, $parno );
3119
-      if( !isset( $input['params']['VALUE'] ) || ( 'PERIOD' != $input['params']['VALUE'] )) { // no PERIOD
3118
+        if( !isset( $input['params']['VALUE'] ) || ( 'PERIOD' != $input['params']['VALUE'] )) { // no PERIOD
3120 3119
         if( 3 == $parno )
3121
-          unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] );
3120
+            unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] );
3122 3121
         elseif( isset( $inputa['tz'] ))
3123
-          $inputa['tz'] = (string) $inputa['tz'];
3122
+            $inputa['tz'] = (string) $inputa['tz'];
3124 3123
         if(  isset( $input['params']['TZID'] ) ||
3125 3124
            ( isset( $inputa['tz'] )            && !$this->_isOffset( $inputa['tz'] ))     ||
3126 3125
            ( isset( $input['value'][0] )       && ( !isset( $input['value'][0]['tz'] )))  ||
3127 3126
            ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] )))
3128
-          unset( $inputa['tz'] );
3129
-      }
3130
-      $input['value'][] = $inputa;
3127
+            unset( $inputa['tz'] );
3128
+        }
3129
+        $input['value'][] = $inputa;
3131 3130
     }
3132 3131
     if( 3 == $parno ) {
3133
-      $input['params']['VALUE'] = 'DATE';
3134
-      unset( $input['params']['TZID'] );
3132
+        $input['params']['VALUE'] = 'DATE';
3133
+        unset( $input['params']['TZID'] );
3135 3134
     }
3136 3135
     $this->_setMval( $this->rdate, $input['value'], $input['params'], FALSE, $index );
3137 3136
     return TRUE;
3138
-  }
3137
+    }
3139 3138
 /*********************************************************************************/
3140 3139
 /**
3141
- * Property Name: RECURRENCE-ID
3142
- */
3140
+     * Property Name: RECURRENCE-ID
3141
+     */
3143 3142
 /**
3144
- * creates formatted output for calendar component property recurrence-id
3145
- *
3146
- * @author Kjell-Inge Gustafsson <[email protected]>
3147
- * @since 2.4.8 - 2008-10-21
3148
- * @return string
3149
- */
3150
-  function createRecurrenceid() {
3143
+     * creates formatted output for calendar component property recurrence-id
3144
+     *
3145
+     * @author Kjell-Inge Gustafsson <[email protected]>
3146
+     * @since 2.4.8 - 2008-10-21
3147
+     * @return string
3148
+     */
3149
+    function createRecurrenceid() {
3151 3150
     if( empty( $this->recurrenceid )) return FALSE;
3152 3151
     if( empty( $this->recurrenceid['value'] ))
3153
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE;
3152
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE;
3154 3153
     $formatted  = $this->_format_date_time( $this->recurrenceid['value'] );
3155 3154
     $attributes = $this->_createParams( $this->recurrenceid['params'] );
3156 3155
     return $this->_createElement( 'RECURRENCE-ID', $attributes, $formatted );
3157
-  }
3156
+    }
3158 3157
 /**
3159
- * set calendar component property recurrence-id
3160
- *
3161
- * @author Kjell-Inge Gustafsson <[email protected]>
3162
- * @since 2.4.8 - 2008-10-23
3163
- * @param mixed $year
3164
- * @param mixed $month optional
3165
- * @param int $day optional
3166
- * @param int $hour optional
3167
- * @param int $min optional
3168
- * @param int $sec optional
3169
- * @param array $params optional
3170
- * @return bool
3171
- */
3172
-  function setRecurrenceid( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
3158
+     * set calendar component property recurrence-id
3159
+     *
3160
+     * @author Kjell-Inge Gustafsson <[email protected]>
3161
+     * @since 2.4.8 - 2008-10-23
3162
+     * @param mixed $year
3163
+     * @param mixed $month optional
3164
+     * @param int $day optional
3165
+     * @param int $hour optional
3166
+     * @param int $min optional
3167
+     * @param int $sec optional
3168
+     * @param array $params optional
3169
+     * @return bool
3170
+     */
3171
+    function setRecurrenceid( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) {
3173 3172
     if( empty( $year )) {
3174
-      if( $this->getConfig( 'allowEmpty' )) {
3173
+        if( $this->getConfig( 'allowEmpty' )) {
3175 3174
         $this->recurrenceid = array( 'value' => null, 'params' => null );
3176 3175
         return TRUE;
3177
-      }
3178
-      else
3176
+        }
3177
+        else
3179 3178
         return FALSE;
3180 3179
     }
3181 3180
     $this->recurrenceid = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params );
3182 3181
     return TRUE;
3183
-  }
3182
+    }
3184 3183
 /*********************************************************************************/
3185 3184
 /**
3186
- * Property Name: RELATED-TO
3187
- */
3185
+     * Property Name: RELATED-TO
3186
+     */
3188 3187
 /**
3189
- * creates formatted output for calendar component property related-to
3190
- *
3191
- * @author Kjell-Inge Gustafsson <[email protected]>
3192
- * @since 2.4.8 - 2008-10-23
3193
- * @return string
3194
- */
3195
-  function createRelatedTo() {
3188
+     * creates formatted output for calendar component property related-to
3189
+     *
3190
+     * @author Kjell-Inge Gustafsson <[email protected]>
3191
+     * @since 2.4.8 - 2008-10-23
3192
+     * @return string
3193
+     */
3194
+    function createRelatedTo() {
3196 3195
     if( empty( $this->relatedto )) return FALSE;
3197 3196
     $output = null;
3198 3197
     foreach( $this->relatedto as $relation ) {
3199
-      if( empty( $relation['value'] )) {
3198
+        if( empty( $relation['value'] )) {
3200 3199
         if( $this->getConfig( 'allowEmpty' )) $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] ));
3201 3200
         continue;
3202
-      }
3203
-      $attributes = $this->_createParams( $relation['params'] );
3204
-      $content    = ( 'xcal' != $this->format ) ? '<' : '';
3205
-      $content   .= $this->_strrep( $relation['value'] );
3206
-      $content   .= ( 'xcal' != $this->format ) ? '>' : '';
3207
-      $output    .= $this->_createElement( 'RELATED-TO', $attributes, $content );
3201
+        }
3202
+        $attributes = $this->_createParams( $relation['params'] );
3203
+        $content    = ( 'xcal' != $this->format ) ? '<' : '';
3204
+        $content   .= $this->_strrep( $relation['value'] );
3205
+        $content   .= ( 'xcal' != $this->format ) ? '>' : '';
3206
+        $output    .= $this->_createElement( 'RELATED-TO', $attributes, $content );
3208 3207
     }
3209 3208
     return $output;
3210
-  }
3209
+    }
3211 3210
 /**
3212
- * set calendar component property related-to
3213
- *
3214
- * @author Kjell-Inge Gustafsson <[email protected]>
3215
- * @since 2.5.1 - 2008-11-07
3216
- * @param float $relid
3217
- * @param array $params, optional
3218
- * @param index $index, optional
3219
- * @return bool
3220
- */
3221
-  function setRelatedTo( $value, $params=FALSE, $index=FALSE ) {
3211
+     * set calendar component property related-to
3212
+     *
3213
+     * @author Kjell-Inge Gustafsson <[email protected]>
3214
+     * @since 2.5.1 - 2008-11-07
3215
+     * @param float $relid
3216
+     * @param array $params, optional
3217
+     * @param index $index, optional
3218
+     * @return bool
3219
+     */
3220
+    function setRelatedTo( $value, $params=FALSE, $index=FALSE ) {
3222 3221
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3223 3222
     if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 )))
3224
-      $value = substr( $value, 1, ( strlen( $value ) - 2 ));
3223
+        $value = substr( $value, 1, ( strlen( $value ) - 2 ));
3225 3224
     $this->_existRem( $params, 'RELTYPE', 'PARENT', TRUE ); // remove default
3226 3225
     $this->_setMval( $this->relatedto, $value, $params, FALSE, $index );
3227 3226
     return TRUE;
3228
-  }
3227
+    }
3229 3228
 /*********************************************************************************/
3230 3229
 /**
3231
- * Property Name: REPEAT
3232
- */
3230
+     * Property Name: REPEAT
3231
+     */
3233 3232
 /**
3234
- * creates formatted output for calendar component property repeat
3235
- *
3236
- * @author Kjell-Inge Gustafsson <[email protected]>
3237
- * @since 2.4.8 - 2008-10-21
3238
- * @return string
3239
- */
3240
-  function createRepeat() {
3233
+     * creates formatted output for calendar component property repeat
3234
+     *
3235
+     * @author Kjell-Inge Gustafsson <[email protected]>
3236
+     * @since 2.4.8 - 2008-10-21
3237
+     * @return string
3238
+     */
3239
+    function createRepeat() {
3241 3240
     if( empty( $this->repeat )) return FALSE;
3242 3241
     if( empty( $this->repeat['value'] ))
3243
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE;
3242
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE;
3244 3243
     $attributes = $this->_createParams( $this->repeat['params'] );
3245 3244
     return $this->_createElement( 'REPEAT', $attributes, $this->repeat['value'] );
3246
-  }
3245
+    }
3247 3246
 /**
3248
- * set calendar component property transp
3249
- *
3250
- * @author Kjell-Inge Gustafsson <[email protected]>
3251
- * @since 2.4.8 - 2008-11-04
3252
- * @param string $value
3253
- * @param array $params optional
3254
- * @return void
3255
- */
3256
-  function setRepeat( $value, $params=FALSE ) {
3247
+     * set calendar component property transp
3248
+     *
3249
+     * @author Kjell-Inge Gustafsson <[email protected]>
3250
+     * @since 2.4.8 - 2008-11-04
3251
+     * @param string $value
3252
+     * @param array $params optional
3253
+     * @return void
3254
+     */
3255
+    function setRepeat( $value, $params=FALSE ) {
3257 3256
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3258 3257
     $this->repeat = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3259 3258
     return TRUE;
3260
-  }
3259
+    }
3261 3260
 /*********************************************************************************/
3262 3261
 /**
3263
- * Property Name: REQUEST-STATUS
3264
- */
3262
+     * Property Name: REQUEST-STATUS
3263
+     */
3265 3264
 /**
3266
- * creates formatted output for calendar component property request-status
3267
- * @author Kjell-Inge Gustafsson <[email protected]>
3268
- * @since 2.4.8 - 2008-10-23
3269
- * @return string
3270
- */
3271
-  function createRequestStatus() {
3265
+     * creates formatted output for calendar component property request-status
3266
+     * @author Kjell-Inge Gustafsson <[email protected]>
3267
+     * @since 2.4.8 - 2008-10-23
3268
+     * @return string
3269
+     */
3270
+    function createRequestStatus() {
3272 3271
     if( empty( $this->requeststatus )) return FALSE;
3273 3272
     $output = null;
3274 3273
     foreach( $this->requeststatus as $rstat ) {
3275
-      if( empty( $rstat['value']['statcode'] )) {
3274
+        if( empty( $rstat['value']['statcode'] )) {
3276 3275
         if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'REQUEST-STATUS' );
3277 3276
         continue;
3278
-      }
3279
-      $attributes  = $this->_createParams( $rstat['params'], array( 'LANGUAGE' ));
3280
-      $content     = number_format( (float) $rstat['value']['statcode'], 2, '.', '');
3281
-      $content    .= ';'.$this->_strrep( $rstat['value']['text'] );
3282
-      if( isset( $rstat['value']['extdata'] ))
3277
+        }
3278
+        $attributes  = $this->_createParams( $rstat['params'], array( 'LANGUAGE' ));
3279
+        $content     = number_format( (float) $rstat['value']['statcode'], 2, '.', '');
3280
+        $content    .= ';'.$this->_strrep( $rstat['value']['text'] );
3281
+        if( isset( $rstat['value']['extdata'] ))
3283 3282
         $content  .= ';'.$this->_strrep( $rstat['value']['extdata'] );
3284
-      $output     .= $this->_createElement( 'REQUEST-STATUS', $attributes, $content );
3283
+        $output     .= $this->_createElement( 'REQUEST-STATUS', $attributes, $content );
3285 3284
     }
3286 3285
     return $output;
3287
-  }
3286
+    }
3288 3287
 /**
3289
- * set calendar component property request-status
3290
- *
3291
- * @author Kjell-Inge Gustafsson <[email protected]>
3292
- * @since 2.5.1 - 2008-11-05
3293
- * @param float $statcode
3294
- * @param string $text
3295
- * @param string $extdata, optional
3296
- * @param array $params, optional
3297
- * @param integer $index, optional
3298
- * @return bool
3299
- */
3300
-  function setRequestStatus( $statcode, $text, $extdata=FALSE, $params=FALSE, $index=FALSE ) {
3288
+     * set calendar component property request-status
3289
+     *
3290
+     * @author Kjell-Inge Gustafsson <[email protected]>
3291
+     * @since 2.5.1 - 2008-11-05
3292
+     * @param float $statcode
3293
+     * @param string $text
3294
+     * @param string $extdata, optional
3295
+     * @param array $params, optional
3296
+     * @param integer $index, optional
3297
+     * @return bool
3298
+     */
3299
+    function setRequestStatus( $statcode, $text, $extdata=FALSE, $params=FALSE, $index=FALSE ) {
3301 3300
     if( empty( $statcode ) || empty( $text )) if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null; else return FALSE;
3302 3301
     $input              = array( 'statcode' => $statcode, 'text' => $text );
3303 3302
     if( $extdata )
3304
-      $input['extdata'] = $extdata;
3303
+        $input['extdata'] = $extdata;
3305 3304
     $this->_setMval( $this->requeststatus, $input, $params, FALSE, $index );
3306 3305
     return TRUE;
3307
-  }
3306
+    }
3308 3307
 /*********************************************************************************/
3309 3308
 /**
3310
- * Property Name: RESOURCES
3311
- */
3309
+     * Property Name: RESOURCES
3310
+     */
3312 3311
 /**
3313
- * creates formatted output for calendar component property resources
3314
- *
3315
- * @author Kjell-Inge Gustafsson <[email protected]>
3316
- * @since 2.4.8 - 2008-10-23
3317
- * @return string
3318
- */
3319
-  function createResources() {
3312
+     * creates formatted output for calendar component property resources
3313
+     *
3314
+     * @author Kjell-Inge Gustafsson <[email protected]>
3315
+     * @since 2.4.8 - 2008-10-23
3316
+     * @return string
3317
+     */
3318
+    function createResources() {
3320 3319
     if( empty( $this->resources )) return FALSE;
3321 3320
     $output = null;
3322 3321
     foreach( $this->resources as $resource ) {
3323
-      if( empty( $resource['value'] )) {
3322
+        if( empty( $resource['value'] )) {
3324 3323
         if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RESOURCES' );
3325 3324
         continue;
3326
-      }
3327
-      $attributes  = $this->_createParams( $resource['params'], array( 'ALTREP', 'LANGUAGE' ));
3328
-      if( is_array( $resource['value'] )) {
3325
+        }
3326
+        $attributes  = $this->_createParams( $resource['params'], array( 'ALTREP', 'LANGUAGE' ));
3327
+        if( is_array( $resource['value'] )) {
3329 3328
         foreach( $resource['value'] as $rix => $resourcePart )
3330
-          $resource['value'][$rix] = $this->_strrep( $resourcePart );
3329
+            $resource['value'][$rix] = $this->_strrep( $resourcePart );
3331 3330
         $content   = implode( ',', $resource['value'] );
3332
-      }
3333
-      else
3331
+        }
3332
+        else
3334 3333
         $content   = $this->_strrep( $resource['value'] );
3335
-      $output     .= $this->_createElement( 'RESOURCES', $attributes, $content );
3334
+        $output     .= $this->_createElement( 'RESOURCES', $attributes, $content );
3336 3335
     }
3337 3336
     return $output;
3338
-  }
3337
+    }
3339 3338
 /**
3340
- * set calendar component property recources
3341
- *
3342
- * @author Kjell-Inge Gustafsson <[email protected]>
3343
- * @since 2.5.1 - 2008-11-05
3344
- * @param mixed $value
3345
- * @param array $params, optional
3346
- * @param integer $index, optional
3347
- * @return bool
3348
- */
3349
-  function setResources( $value, $params=FALSE, $index=FALSE ) {
3339
+     * set calendar component property recources
3340
+     *
3341
+     * @author Kjell-Inge Gustafsson <[email protected]>
3342
+     * @since 2.5.1 - 2008-11-05
3343
+     * @param mixed $value
3344
+     * @param array $params, optional
3345
+     * @param integer $index, optional
3346
+     * @return bool
3347
+     */
3348
+    function setResources( $value, $params=FALSE, $index=FALSE ) {
3350 3349
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3351 3350
     $this->_setMval( $this->resources, $value, $params, FALSE, $index );
3352 3351
     return TRUE;
3353
-  }
3352
+    }
3354 3353
 /*********************************************************************************/
3355 3354
 /**
3356
- * Property Name: RRULE
3357
- */
3355
+     * Property Name: RRULE
3356
+     */
3358 3357
 /**
3359
- * creates formatted output for calendar component property rrule
3360
- *
3361
- * @author Kjell-Inge Gustafsson <[email protected]>
3362
- * @since 2.4.8 - 2008-10-21
3363
- * @return string
3364
- */
3365
-  function createRrule() {
3358
+     * creates formatted output for calendar component property rrule
3359
+     *
3360
+     * @author Kjell-Inge Gustafsson <[email protected]>
3361
+     * @since 2.4.8 - 2008-10-21
3362
+     * @return string
3363
+     */
3364
+    function createRrule() {
3366 3365
     if( empty( $this->rrule )) return FALSE;
3367 3366
     return $this->_format_recur( 'RRULE', $this->rrule );
3368
-  }
3367
+    }
3369 3368
 /**
3370
- * set calendar component property rrule
3371
- *
3372
- * @author Kjell-Inge Gustafsson <[email protected]>
3373
- * @since 2.5.1 - 2008-11-05
3374
- * @param array $rruleset
3375
- * @param array $params, optional
3376
- * @param integer $index, optional
3377
- * @return void
3378
- */
3379
-  function setRrule( $rruleset, $params=FALSE, $index=FALSE ) {
3369
+     * set calendar component property rrule
3370
+     *
3371
+     * @author Kjell-Inge Gustafsson <[email protected]>
3372
+     * @since 2.5.1 - 2008-11-05
3373
+     * @param array $rruleset
3374
+     * @param array $params, optional
3375
+     * @param integer $index, optional
3376
+     * @return void
3377
+     */
3378
+    function setRrule( $rruleset, $params=FALSE, $index=FALSE ) {
3380 3379
     if( empty( $rruleset )) if( $this->getConfig( 'allowEmpty' )) $rruleset = null; else return FALSE;
3381 3380
     $this->_setMval( $this->rrule, $this->_setRexrule( $rruleset ), $params, FALSE, $index );
3382 3381
     return TRUE;
3383
-  }
3382
+    }
3384 3383
 /*********************************************************************************/
3385 3384
 /**
3386
- * Property Name: SEQUENCE
3387
- */
3385
+     * Property Name: SEQUENCE
3386
+     */
3388 3387
 /**
3389
- * creates formatted output for calendar component property sequence
3390
- * @author Kjell-Inge Gustafsson <[email protected]>
3391
- * @since 0.9.7 - 2006-11-20
3392
- * @return string
3393
- */
3394
-  function createSequence() {
3388
+     * creates formatted output for calendar component property sequence
3389
+     * @author Kjell-Inge Gustafsson <[email protected]>
3390
+     * @since 0.9.7 - 2006-11-20
3391
+     * @return string
3392
+     */
3393
+    function createSequence() {
3395 3394
     if( empty( $this->sequence )) return FALSE;
3396 3395
     if( empty( $this->sequence['value'] ))
3397
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE;
3396
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE;
3398 3397
     $attributes = $this->_createParams( $this->sequence['params'] );
3399 3398
     return $this->_createElement( 'SEQUENCE', $attributes, $this->sequence['value'] );
3400
-  }
3399
+    }
3401 3400
 /**
3402
- * set calendar component property sequence
3403
- * @author Kjell-Inge Gustafsson <[email protected]>
3404
- * @since 2.4.8 - 2008-11-04
3405
- * @param int $value optional
3406
- * @param array $params optional
3407
- * @return bool
3408
- */
3409
-  function setSequence( $value=FALSE, $params=FALSE ) {
3401
+     * set calendar component property sequence
3402
+     * @author Kjell-Inge Gustafsson <[email protected]>
3403
+     * @since 2.4.8 - 2008-11-04
3404
+     * @param int $value optional
3405
+     * @param array $params optional
3406
+     * @return bool
3407
+     */
3408
+    function setSequence( $value=FALSE, $params=FALSE ) {
3410 3409
     if( empty( $value ))
3411
-      $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1;
3410
+        $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1;
3412 3411
     $this->sequence = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3413 3412
     return TRUE;
3414
-  }
3413
+    }
3415 3414
 /*********************************************************************************/
3416 3415
 /**
3417
- * Property Name: STATUS
3418
- */
3416
+     * Property Name: STATUS
3417
+     */
3419 3418
 /**
3420
- * creates formatted output for calendar component property status
3421
- *
3422
- * @author Kjell-Inge Gustafsson <[email protected]>
3423
- * @since 2.4.8 - 2008-10-21
3424
- * @return string
3425
- */
3426
-  function createStatus() {
3419
+     * creates formatted output for calendar component property status
3420
+     *
3421
+     * @author Kjell-Inge Gustafsson <[email protected]>
3422
+     * @since 2.4.8 - 2008-10-21
3423
+     * @return string
3424
+     */
3425
+    function createStatus() {
3427 3426
     if( empty( $this->status )) return FALSE;
3428 3427
     if( empty( $this->status['value'] ))
3429
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE;
3428
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE;
3430 3429
     $attributes = $this->_createParams( $this->status['params'] );
3431 3430
     return $this->_createElement( 'STATUS', $attributes, $this->status['value'] );
3432
-  }
3431
+    }
3433 3432
 /**
3434
- * set calendar component property status
3435
- *
3436
- * @author Kjell-Inge Gustafsson <[email protected]>
3437
- * @since 2.4.8 - 2008-11-04
3438
- * @param string $value
3439
- * @param array $params optional
3440
- * @return bool
3441
- */
3442
-  function setStatus( $value, $params=FALSE ) {
3433
+     * set calendar component property status
3434
+     *
3435
+     * @author Kjell-Inge Gustafsson <[email protected]>
3436
+     * @since 2.4.8 - 2008-11-04
3437
+     * @param string $value
3438
+     * @param array $params optional
3439
+     * @return bool
3440
+     */
3441
+    function setStatus( $value, $params=FALSE ) {
3443 3442
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3444 3443
     $this->status = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3445 3444
     return TRUE;
3446
-  }
3445
+    }
3447 3446
 /*********************************************************************************/
3448 3447
 /**
3449
- * Property Name: SUMMARY
3450
- */
3448
+     * Property Name: SUMMARY
3449
+     */
3451 3450
 /**
3452
- * creates formatted output for calendar component property summary
3453
- *
3454
- * @author Kjell-Inge Gustafsson <[email protected]>
3455
- * @since 2.4.8 - 2008-10-21
3456
- * @return string
3457
- */
3458
-  function createSummary() {
3451
+     * creates formatted output for calendar component property summary
3452
+     *
3453
+     * @author Kjell-Inge Gustafsson <[email protected]>
3454
+     * @since 2.4.8 - 2008-10-21
3455
+     * @return string
3456
+     */
3457
+    function createSummary() {
3459 3458
     if( empty( $this->summary )) return FALSE;
3460 3459
     if( empty( $this->summary['value'] ))
3461
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE;
3460
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE;
3462 3461
     $attributes = $this->_createParams( $this->summary['params'], array( 'ALTREP', 'LANGUAGE' ));
3463 3462
     $content    = $this->_strrep( $this->summary['value'] );
3464 3463
     return $this->_createElement( 'SUMMARY', $attributes, $content );
3465
-  }
3464
+    }
3466 3465
 /**
3467
- * set calendar component property summary
3468
- *
3469
- * @author Kjell-Inge Gustafsson <[email protected]>
3470
- * @since 2.4.8 - 2008-11-04
3471
- * @param string $value
3472
- * @param string $params optional
3473
- * @return bool
3474
- */
3475
-  function setSummary( $value, $params=FALSE ) {
3466
+     * set calendar component property summary
3467
+     *
3468
+     * @author Kjell-Inge Gustafsson <[email protected]>
3469
+     * @since 2.4.8 - 2008-11-04
3470
+     * @param string $value
3471
+     * @param string $params optional
3472
+     * @return bool
3473
+     */
3474
+    function setSummary( $value, $params=FALSE ) {
3476 3475
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3477 3476
     $this->summary = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3478 3477
     return TRUE;
3479
-  }
3478
+    }
3480 3479
 /*********************************************************************************/
3481 3480
 /**
3482
- * Property Name: TRANSP
3483
- */
3481
+     * Property Name: TRANSP
3482
+     */
3484 3483
 /**
3485
- * creates formatted output for calendar component property transp
3486
- *
3487
- * @author Kjell-Inge Gustafsson <[email protected]>
3488
- * @since 2.4.8 - 2008-10-21
3489
- * @return string
3490
- */
3491
-  function createTransp() {
3484
+     * creates formatted output for calendar component property transp
3485
+     *
3486
+     * @author Kjell-Inge Gustafsson <[email protected]>
3487
+     * @since 2.4.8 - 2008-10-21
3488
+     * @return string
3489
+     */
3490
+    function createTransp() {
3492 3491
     if( empty( $this->transp )) return FALSE;
3493 3492
     if( empty( $this->transp['value'] ))
3494
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE;
3493
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE;
3495 3494
     $attributes = $this->_createParams( $this->transp['params'] );
3496 3495
     return $this->_createElement( 'TRANSP', $attributes, $this->transp['value'] );
3497
-  }
3496
+    }
3498 3497
 /**
3499
- * set calendar component property transp
3500
- *
3501
- * @author Kjell-Inge Gustafsson <[email protected]>
3502
- * @since 2.4.8 - 2008-11-04
3503
- * @param string $value
3504
- * @param string $params optional
3505
- * @return bool
3506
- */
3507
-  function setTransp( $value, $params=FALSE ) {
3498
+     * set calendar component property transp
3499
+     *
3500
+     * @author Kjell-Inge Gustafsson <[email protected]>
3501
+     * @since 2.4.8 - 2008-11-04
3502
+     * @param string $value
3503
+     * @param string $params optional
3504
+     * @return bool
3505
+     */
3506
+    function setTransp( $value, $params=FALSE ) {
3508 3507
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3509 3508
     $this->transp = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3510 3509
     return TRUE;
3511
-  }
3510
+    }
3512 3511
 /*********************************************************************************/
3513 3512
 /**
3514
- * Property Name: TRIGGER
3515
- */
3513
+     * Property Name: TRIGGER
3514
+     */
3516 3515
 /**
3517
- * creates formatted output for calendar component property trigger
3518
- *
3519
- * @author Kjell-Inge Gustafsson <[email protected]>
3520
- * @since 2.4.16 - 2008-10-21
3521
- * @return string
3522
- */
3523
-  function createTrigger() {
3516
+     * creates formatted output for calendar component property trigger
3517
+     *
3518
+     * @author Kjell-Inge Gustafsson <[email protected]>
3519
+     * @since 2.4.16 - 2008-10-21
3520
+     * @return string
3521
+     */
3522
+    function createTrigger() {
3524 3523
     if( empty( $this->trigger )) return FALSE;
3525 3524
     if( empty( $this->trigger['value'] ))
3526
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE;
3525
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE;
3527 3526
     $content = $attributes = null;
3528 3527
     if( isset( $this->trigger['value']['year'] )   &&
3529 3528
         isset( $this->trigger['value']['month'] )  &&
3530 3529
         isset( $this->trigger['value']['day'] ))
3531
-      $content      .= $this->_format_date_time( $this->trigger['value'] );
3530
+        $content      .= $this->_format_date_time( $this->trigger['value'] );
3532 3531
     else {
3533
-      if( TRUE !== $this->trigger['value']['relatedStart'] )
3532
+        if( TRUE !== $this->trigger['value']['relatedStart'] )
3534 3533
         $attributes .= $this->intAttrDelimiter.'RELATED=END';
3535
-      if( $this->trigger['value']['before'] )
3534
+        if( $this->trigger['value']['before'] )
3536 3535
         $content    .= '-';
3537
-      $content      .= $this->_format_duration( $this->trigger['value'] );
3536
+        $content      .= $this->_format_duration( $this->trigger['value'] );
3538 3537
     }
3539 3538
     $attributes     .= $this->_createParams( $this->trigger['params'] );
3540 3539
     return $this->_createElement( 'TRIGGER', $attributes, $content );
3541
-  }
3540
+    }
3542 3541
 /**
3543
- * set calendar component property trigger
3544
- *
3545
- * @author Kjell-Inge Gustafsson <[email protected]>
3546
- * @since 2.4.16 - 2008-11-04
3547
- * @param mixed $year
3548
- * @param mixed $month optional
3549
- * @param int $day optional
3550
- * @param int $week optional
3551
- * @param int $hour optional
3552
- * @param int $min optional
3553
- * @param int $sec optional
3554
- * @param bool $relatedStart optional
3555
- * @param bool $before optional
3556
- * @param array $params optional
3557
- * @return bool
3558
- */
3559
-  function setTrigger( $year, $month=null, $day=null, $week=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $relatedStart=TRUE, $before=TRUE, $params=FALSE ) {
3542
+     * set calendar component property trigger
3543
+     *
3544
+     * @author Kjell-Inge Gustafsson <[email protected]>
3545
+     * @since 2.4.16 - 2008-11-04
3546
+     * @param mixed $year
3547
+     * @param mixed $month optional
3548
+     * @param int $day optional
3549
+     * @param int $week optional
3550
+     * @param int $hour optional
3551
+     * @param int $min optional
3552
+     * @param int $sec optional
3553
+     * @param bool $relatedStart optional
3554
+     * @param bool $before optional
3555
+     * @param array $params optional
3556
+     * @return bool
3557
+     */
3558
+    function setTrigger( $year, $month=null, $day=null, $week=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $relatedStart=TRUE, $before=TRUE, $params=FALSE ) {
3560 3559
     if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec ))
3561
-      if( $this->getConfig( 'allowEmpty' )) {
3560
+        if( $this->getConfig( 'allowEmpty' )) {
3562 3561
         $this->trigger = array( 'value' => null, 'params' => $this->_setParams( $params ) );
3563 3562
         return TRUE;
3564
-      }
3565
-      else
3563
+        }
3564
+        else
3566 3565
         return FALSE;
3567 3566
     if( $this->_isArrayTimestampDate( $year )) { // timestamp
3568
-      $params = $this->_setParams( $month );
3569
-      $date   = $this->_timestamp2date( $year, 7 );
3570
-      foreach( $date as $k => $v )
3567
+        $params = $this->_setParams( $month );
3568
+        $date   = $this->_timestamp2date( $year, 7 );
3569
+        foreach( $date as $k => $v )
3571 3570
         $$k = $v;
3572 3571
     }
3573 3572
     elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) {
3574
-      $params = $this->_setParams( $month );
3575
-      if(!(array_key_exists( 'year',  $year ) &&   // exclude date-time
3573
+        $params = $this->_setParams( $month );
3574
+        if(!(array_key_exists( 'year',  $year ) &&   // exclude date-time
3576 3575
            array_key_exists( 'month', $year ) &&
3577 3576
            array_key_exists( 'day',   $year ))) {  // so this must be a duration
3578 3577
         if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] ))
3579
-          $relatedStart = FALSE;
3578
+            $relatedStart = FALSE;
3580 3579
         else
3581
-          $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE;
3580
+            $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE;
3582 3581
         $before         = ( array_key_exists( 'before', $year )       && ( TRUE !== $year['before'] ))       ? FALSE : TRUE;
3583
-      }
3584
-      $SSYY  = ( array_key_exists( 'year',  $year )) ? $year['year']  : null;
3585
-      $month = ( array_key_exists( 'month', $year )) ? $year['month'] : null;
3586
-      $day   = ( array_key_exists( 'day',   $year )) ? $year['day']   : null;
3587
-      $week  = ( array_key_exists( 'week',  $year )) ? $year['week']  : null;
3588
-      $hour  = ( array_key_exists( 'hour',  $year )) ? $year['hour']  : 0; //null;
3589
-      $min   = ( array_key_exists( 'min',   $year )) ? $year['min']   : 0; //null;
3590
-      $sec   = ( array_key_exists( 'sec',   $year )) ? $year['sec']   : 0; //null;
3591
-      $year  = $SSYY;
3582
+        }
3583
+        $SSYY  = ( array_key_exists( 'year',  $year )) ? $year['year']  : null;
3584
+        $month = ( array_key_exists( 'month', $year )) ? $year['month'] : null;
3585
+        $day   = ( array_key_exists( 'day',   $year )) ? $year['day']   : null;
3586
+        $week  = ( array_key_exists( 'week',  $year )) ? $year['week']  : null;
3587
+        $hour  = ( array_key_exists( 'hour',  $year )) ? $year['hour']  : 0; //null;
3588
+        $min   = ( array_key_exists( 'min',   $year )) ? $year['min']   : 0; //null;
3589
+        $sec   = ( array_key_exists( 'sec',   $year )) ? $year['sec']   : 0; //null;
3590
+        $year  = $SSYY;
3592 3591
     }
3593 3592
     elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) {  // duration or date in a string
3594
-      $params = $this->_setParams( $month );
3595
-      if( in_array( $year{0}, array( 'P', '+', '-' ))) { // duration
3593
+        $params = $this->_setParams( $month );
3594
+        if( in_array( $year{0}, array( 'P', '+', '-' ))) { // duration
3596 3595
         $relatedStart = ( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) ? FALSE : TRUE;
3597 3596
         $before       = ( '-'  == $year{0} ) ? TRUE : FALSE;
3598 3597
         if(     'P'  != $year{0} )
3599
-          $year       = substr( $year, 1 );
3598
+            $year       = substr( $year, 1 );
3600 3599
         $date         = $this->_duration_string( $year);
3601
-      }
3602
-      else   // date
3600
+        }
3601
+        else   // date
3603 3602
         $date    = $this->_date_time_string( $year, 7 );
3604
-      unset( $year, $month, $day );
3605
-      foreach( $date as $k => $v )
3603
+        unset( $year, $month, $day );
3604
+        foreach( $date as $k => $v )
3606 3605
         $$k = $v;
3607 3606
     }
3608 3607
     else // single values in function input parameters
3609
-      $params = $this->_setParams( $params );
3608
+        $params = $this->_setParams( $params );
3610 3609
     if( !empty( $year ) && !empty( $month ) && !empty( $day )) { // date
3611
-      $params['VALUE'] = 'DATE-TIME';
3612
-      $hour = ( $hour ) ? $hour : 0;
3613
-      $min  = ( $min  ) ? $min  : 0;
3614
-      $sec  = ( $sec  ) ? $sec  : 0;
3615
-      $this->trigger = array( 'params' => $params );
3616
-      $this->trigger['value'] = array( 'year'  => $year
3617
-                                     , 'month' => $month
3618
-                                     , 'day'   => $day
3619
-                                     , 'hour'  => $hour
3620
-                                     , 'min'   => $min
3621
-                                     , 'sec'   => $sec
3622
-                                     , 'tz'    => 'Z' );
3623
-      return TRUE;
3610
+        $params['VALUE'] = 'DATE-TIME';
3611
+        $hour = ( $hour ) ? $hour : 0;
3612
+        $min  = ( $min  ) ? $min  : 0;
3613
+        $sec  = ( $sec  ) ? $sec  : 0;
3614
+        $this->trigger = array( 'params' => $params );
3615
+        $this->trigger['value'] = array( 'year'  => $year
3616
+                                        , 'month' => $month
3617
+                                        , 'day'   => $day
3618
+                                        , 'hour'  => $hour
3619
+                                        , 'min'   => $min
3620
+                                        , 'sec'   => $sec
3621
+                                        , 'tz'    => 'Z' );
3622
+        return TRUE;
3624 3623
     }
3625 3624
     elseif(( empty( $year ) && empty( $month )) &&    // duration
3626 3625
            (!empty( $week ) || !empty( $day ) || !empty( $hour ) || !empty( $min ) || !empty( $sec ))) {
3627
-      unset( $params['RELATED'] ); // set at output creation (END only)
3628
-      unset( $params['VALUE'] );   // 'DURATION' default
3629
-      $this->trigger = array( 'params' => $params );
3630
-      $relatedStart = ( FALSE !== $relatedStart ) ? TRUE : FALSE;
3631
-      $before       = ( FALSE !== $before )       ? TRUE : FALSE;
3632
-      $this->trigger['value']  = array( 'relatedStart' => $relatedStart
3633
-                                      , 'before'       => $before );
3634
-      if( !empty( $week )) $this->trigger['value']['week'] = $week;
3635
-      if( !empty( $day  )) $this->trigger['value']['day']  = $day;
3636
-      if( !empty( $hour )) $this->trigger['value']['hour'] = $hour;
3637
-      if( !empty( $min  )) $this->trigger['value']['min']  = $min;
3638
-      if( !empty( $sec  )) $this->trigger['value']['sec']  = $sec;
3639
-      return TRUE;
3626
+        unset( $params['RELATED'] ); // set at output creation (END only)
3627
+        unset( $params['VALUE'] );   // 'DURATION' default
3628
+        $this->trigger = array( 'params' => $params );
3629
+        $relatedStart = ( FALSE !== $relatedStart ) ? TRUE : FALSE;
3630
+        $before       = ( FALSE !== $before )       ? TRUE : FALSE;
3631
+        $this->trigger['value']  = array( 'relatedStart' => $relatedStart
3632
+                                        , 'before'       => $before );
3633
+        if( !empty( $week )) $this->trigger['value']['week'] = $week;
3634
+        if( !empty( $day  )) $this->trigger['value']['day']  = $day;
3635
+        if( !empty( $hour )) $this->trigger['value']['hour'] = $hour;
3636
+        if( !empty( $min  )) $this->trigger['value']['min']  = $min;
3637
+        if( !empty( $sec  )) $this->trigger['value']['sec']  = $sec;
3638
+        return TRUE;
3640 3639
     }
3641 3640
     return FALSE;
3642
-  }
3641
+    }
3643 3642
 /*********************************************************************************/
3644 3643
 /**
3645
- * Property Name: TZID
3646
- */
3644
+     * Property Name: TZID
3645
+     */
3647 3646
 /**
3648
- * creates formatted output for calendar component property tzid
3649
- *
3650
- * @author Kjell-Inge Gustafsson <[email protected]>
3651
- * @since 2.4.8 - 2008-10-21
3652
- * @return string
3653
- */
3654
-  function createTzid() {
3647
+     * creates formatted output for calendar component property tzid
3648
+     *
3649
+     * @author Kjell-Inge Gustafsson <[email protected]>
3650
+     * @since 2.4.8 - 2008-10-21
3651
+     * @return string
3652
+     */
3653
+    function createTzid() {
3655 3654
     if( empty( $this->tzid )) return FALSE;
3656 3655
     if( empty( $this->tzid['value'] ))
3657
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE;
3656
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE;
3658 3657
     $attributes = $this->_createParams( $this->tzid['params'] );
3659 3658
     return $this->_createElement( 'TZID', $attributes, $this->_strrep( $this->tzid['value'] ));
3660
-  }
3659
+    }
3661 3660
 /**
3662
- * set calendar component property tzid
3663
- *
3664
- * @author Kjell-Inge Gustafsson <[email protected]>
3665
- * @since 2.4.8 - 2008-11-04
3666
- * @param string $value
3667
- * @param array $params optional
3668
- * @return bool
3669
- */
3670
-  function setTzid( $value, $params=FALSE ) {
3661
+     * set calendar component property tzid
3662
+     *
3663
+     * @author Kjell-Inge Gustafsson <[email protected]>
3664
+     * @since 2.4.8 - 2008-11-04
3665
+     * @param string $value
3666
+     * @param array $params optional
3667
+     * @return bool
3668
+     */
3669
+    function setTzid( $value, $params=FALSE ) {
3671 3670
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3672 3671
     $this->tzid = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3673 3672
     return TRUE;
3674
-  }
3673
+    }
3675 3674
 /*********************************************************************************/
3676 3675
 /**
3677
- * .. .
3678
- * Property Name: TZNAME
3679
- */
3680
-/**
3681
- * creates formatted output for calendar component property tzname
3682
- *
3683
- * @author Kjell-Inge Gustafsson <[email protected]>
3684
- * @since 2.4.8 - 2008-10-21
3685
- * @return string
3686
- */
3687
-  function createTzname() {
3676
+     * .. .
3677
+     * Property Name: TZNAME
3678
+     */
3679
+/**
3680
+     * creates formatted output for calendar component property tzname
3681
+     *
3682
+     * @author Kjell-Inge Gustafsson <[email protected]>
3683
+     * @since 2.4.8 - 2008-10-21
3684
+     * @return string
3685
+     */
3686
+    function createTzname() {
3688 3687
     if( empty( $this->tzname )) return FALSE;
3689 3688
     $output = null;
3690 3689
     foreach( $this->tzname as $theName ) {
3691
-      if( !empty( $theName['value'] )) {
3690
+        if( !empty( $theName['value'] )) {
3692 3691
         $attributes = $this->_createParams( $theName['params'], array( 'LANGUAGE' ));
3693 3692
         $output    .= $this->_createElement( 'TZNAME', $attributes, $this->_strrep( $theName['value'] ));
3694
-      }
3695
-      elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'TZNAME' );
3693
+        }
3694
+        elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'TZNAME' );
3696 3695
     }
3697 3696
     return $output;
3698
-  }
3697
+    }
3699 3698
 /**
3700
- * set calendar component property tzname
3701
- *
3702
- * @author Kjell-Inge Gustafsson <[email protected]>
3703
- * @since 2.5.1 - 2008-11-05
3704
- * @param string $value
3705
- * @param string $params, optional
3706
- * @param integer $index, optional
3707
- * @return bool
3708
- */
3709
-  function setTzname( $value, $params=FALSE, $index=FALSE ) {
3699
+     * set calendar component property tzname
3700
+     *
3701
+     * @author Kjell-Inge Gustafsson <[email protected]>
3702
+     * @since 2.5.1 - 2008-11-05
3703
+     * @param string $value
3704
+     * @param string $params, optional
3705
+     * @param integer $index, optional
3706
+     * @return bool
3707
+     */
3708
+    function setTzname( $value, $params=FALSE, $index=FALSE ) {
3710 3709
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3711 3710
     $this->_setMval( $this->tzname, $value, $params, FALSE, $index );
3712 3711
     return TRUE;
3713
-  }
3712
+    }
3714 3713
 /*********************************************************************************/
3715 3714
 /**
3716
- * Property Name: TZOFFSETFROM
3717
- */
3715
+     * Property Name: TZOFFSETFROM
3716
+     */
3718 3717
 /**
3719
- * creates formatted output for calendar component property tzoffsetfrom
3720
- *
3721
- * @author Kjell-Inge Gustafsson <[email protected]>
3722
- * @since 2.4.8 - 2008-10-21
3723
- * @return string
3724
- */
3725
-  function createTzoffsetfrom() {
3718
+     * creates formatted output for calendar component property tzoffsetfrom
3719
+     *
3720
+     * @author Kjell-Inge Gustafsson <[email protected]>
3721
+     * @since 2.4.8 - 2008-10-21
3722
+     * @return string
3723
+     */
3724
+    function createTzoffsetfrom() {
3726 3725
     if( empty( $this->tzoffsetfrom )) return FALSE;
3727 3726
     if( empty( $this->tzoffsetfrom['value'] ))
3728
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE;
3727
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE;
3729 3728
     $attributes = $this->_createParams( $this->tzoffsetfrom['params'] );
3730 3729
     return $this->_createElement( 'TZOFFSETFROM', $attributes, $this->tzoffsetfrom['value'] );
3731
-  }
3730
+    }
3732 3731
 /**
3733
- * set calendar component property tzoffsetfrom
3734
- *
3735
- * @author Kjell-Inge Gustafsson <[email protected]>
3736
- * @since 2.4.8 - 2008-11-04
3737
- * @param string $value
3738
- * @param string $params optional
3739
- * @return bool
3740
- */
3741
-  function setTzoffsetfrom( $value, $params=FALSE ) {
3732
+     * set calendar component property tzoffsetfrom
3733
+     *
3734
+     * @author Kjell-Inge Gustafsson <[email protected]>
3735
+     * @since 2.4.8 - 2008-11-04
3736
+     * @param string $value
3737
+     * @param string $params optional
3738
+     * @return bool
3739
+     */
3740
+    function setTzoffsetfrom( $value, $params=FALSE ) {
3742 3741
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3743 3742
     $this->tzoffsetfrom = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3744 3743
     return TRUE;
3745
-  }
3744
+    }
3746 3745
 /*********************************************************************************/
3747 3746
 /**
3748
- * Property Name: TZOFFSETTO
3749
- */
3747
+     * Property Name: TZOFFSETTO
3748
+     */
3750 3749
 /**
3751
- * creates formatted output for calendar component property tzoffsetto
3752
- *
3753
- * @author Kjell-Inge Gustafsson <[email protected]>
3754
- * @since 2.4.8 - 2008-10-21
3755
- * @return string
3756
- */
3757
-  function createTzoffsetto() {
3750
+     * creates formatted output for calendar component property tzoffsetto
3751
+     *
3752
+     * @author Kjell-Inge Gustafsson <[email protected]>
3753
+     * @since 2.4.8 - 2008-10-21
3754
+     * @return string
3755
+     */
3756
+    function createTzoffsetto() {
3758 3757
     if( empty( $this->tzoffsetto )) return FALSE;
3759 3758
     if( empty( $this->tzoffsetto['value'] ))
3760
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE;
3759
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE;
3761 3760
     $attributes = $this->_createParams( $this->tzoffsetto['params'] );
3762 3761
     return $this->_createElement( 'TZOFFSETTO', $attributes, $this->tzoffsetto['value'] );
3763
-  }
3762
+    }
3764 3763
 /**
3765
- * set calendar component property tzoffsetto
3766
- *
3767
- * @author Kjell-Inge Gustafsson <[email protected]>
3768
- * @since 2.4.8 - 2008-11-04
3769
- * @param string $value
3770
- * @param string $params optional
3771
- * @return bool
3772
- */
3773
-  function setTzoffsetto( $value, $params=FALSE ) {
3764
+     * set calendar component property tzoffsetto
3765
+     *
3766
+     * @author Kjell-Inge Gustafsson <[email protected]>
3767
+     * @since 2.4.8 - 2008-11-04
3768
+     * @param string $value
3769
+     * @param string $params optional
3770
+     * @return bool
3771
+     */
3772
+    function setTzoffsetto( $value, $params=FALSE ) {
3774 3773
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3775 3774
     $this->tzoffsetto = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3776 3775
     return TRUE;
3777
-  }
3776
+    }
3778 3777
 /*********************************************************************************/
3779 3778
 /**
3780
- * Property Name: TZURL
3781
- */
3779
+     * Property Name: TZURL
3780
+     */
3782 3781
 /**
3783
- * creates formatted output for calendar component property tzurl
3784
- *
3785
- * @author Kjell-Inge Gustafsson <[email protected]>
3786
- * @since 2.4.8 - 2008-10-21
3787
- * @return string
3788
- */
3789
-  function createTzurl() {
3782
+     * creates formatted output for calendar component property tzurl
3783
+     *
3784
+     * @author Kjell-Inge Gustafsson <[email protected]>
3785
+     * @since 2.4.8 - 2008-10-21
3786
+     * @return string
3787
+     */
3788
+    function createTzurl() {
3790 3789
     if( empty( $this->tzurl )) return FALSE;
3791 3790
     if( empty( $this->tzurl['value'] ))
3792
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE;
3791
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE;
3793 3792
     $attributes = $this->_createParams( $this->tzurl['params'] );
3794 3793
     return $this->_createElement( 'TZURL', $attributes, $this->tzurl['value'] );
3795
-  }
3794
+    }
3796 3795
 /**
3797
- * set calendar component property tzurl
3798
- *
3799
- * @author Kjell-Inge Gustafsson <[email protected]>
3800
- * @since 2.4.8 - 2008-11-04
3801
- * @param string $value
3802
- * @param string $params optional
3803
- * @return boll
3804
- */
3805
-  function setTzurl( $value, $params=FALSE ) {
3796
+     * set calendar component property tzurl
3797
+     *
3798
+     * @author Kjell-Inge Gustafsson <[email protected]>
3799
+     * @since 2.4.8 - 2008-11-04
3800
+     * @param string $value
3801
+     * @param string $params optional
3802
+     * @return boll
3803
+     */
3804
+    function setTzurl( $value, $params=FALSE ) {
3806 3805
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3807 3806
     $this->tzurl = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3808 3807
     return TRUE;
3809
-  }
3808
+    }
3810 3809
 /*********************************************************************************/
3811 3810
 /**
3812
- * Property Name: UID
3813
- */
3811
+     * Property Name: UID
3812
+     */
3814 3813
 /**
3815
- * creates formatted output for calendar component property uid
3816
- *
3817
- * @author Kjell-Inge Gustafsson <[email protected]>
3818
- * @since 0.9.7 - 2006-11-20
3819
- * @return string
3820
- */
3821
-  function createUid() {
3814
+     * creates formatted output for calendar component property uid
3815
+     *
3816
+     * @author Kjell-Inge Gustafsson <[email protected]>
3817
+     * @since 0.9.7 - 2006-11-20
3818
+     * @return string
3819
+     */
3820
+    function createUid() {
3822 3821
     if( 0 >= count( $this->uid ))
3823
-      $this->_makeuid();
3822
+        $this->_makeuid();
3824 3823
     $attributes = $this->_createParams( $this->uid['params'] );
3825 3824
     return $this->_createElement( 'UID', $attributes, $this->uid['value'] );
3826
-  }
3825
+    }
3827 3826
 /**
3828
- * create an unique id for this calendar component object instance
3829
- *
3830
- * @author Kjell-Inge Gustafsson <[email protected]>
3831
- * @since 2.2.7 - 2007-09-04
3832
- * @return void
3833
- */
3834
-  function _makeUid() {
3827
+     * create an unique id for this calendar component object instance
3828
+     *
3829
+     * @author Kjell-Inge Gustafsson <[email protected]>
3830
+     * @since 2.2.7 - 2007-09-04
3831
+     * @return void
3832
+     */
3833
+    function _makeUid() {
3835 3834
     $date   = date('Ymd\THisT');
3836 3835
     $unique = substr(microtime(), 2, 4);
3837 3836
     $base   = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPrRsStTuUvVxXuUvVwWzZ1234567890';
@@ -3840,98 +3839,98 @@  discard block
 block discarded – undo
3840 3839
     $length = 6;
3841 3840
     $str    = null;
3842 3841
     for( $p = 0; $p < $length; $p++ )
3843
-      $unique .= $base{mt_rand( $start, $end )};
3842
+        $unique .= $base{mt_rand( $start, $end )};
3844 3843
     $this->uid = array( 'params' => null );
3845 3844
     $this->uid['value']  = $date.'-'.$unique.'@'.$this->getConfig( 'unique_id' );
3846
-  }
3845
+    }
3847 3846
 /**
3848
- * set calendar component property uid
3849
- *
3850
- * @author Kjell-Inge Gustafsson <[email protected]>
3851
- * @since 2.4.8 - 2008-11-04
3852
- * @param string $value
3853
- * @param string $params optional
3854
- * @return bool
3855
- */
3856
-  function setUid( $value, $params=FALSE ) {
3847
+     * set calendar component property uid
3848
+     *
3849
+     * @author Kjell-Inge Gustafsson <[email protected]>
3850
+     * @since 2.4.8 - 2008-11-04
3851
+     * @param string $value
3852
+     * @param string $params optional
3853
+     * @return bool
3854
+     */
3855
+    function setUid( $value, $params=FALSE ) {
3857 3856
     if( empty( $value )) return FALSE; // no allowEmpty check here !!!!
3858 3857
     $this->uid = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3859 3858
     return TRUE;
3860
-  }
3859
+    }
3861 3860
 /*********************************************************************************/
3862 3861
 /**
3863
- * Property Name: URL
3864
- */
3862
+     * Property Name: URL
3863
+     */
3865 3864
 /**
3866
- * creates formatted output for calendar component property url
3867
- *
3868
- * @author Kjell-Inge Gustafsson <[email protected]>
3869
- * @since 2.4.8 - 2008-10-21
3870
- * @return string
3871
- */
3872
-  function createUrl() {
3865
+     * creates formatted output for calendar component property url
3866
+     *
3867
+     * @author Kjell-Inge Gustafsson <[email protected]>
3868
+     * @since 2.4.8 - 2008-10-21
3869
+     * @return string
3870
+     */
3871
+    function createUrl() {
3873 3872
     if( empty( $this->url )) return FALSE;
3874 3873
     if( empty( $this->url['value'] ))
3875
-      return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE;
3874
+        return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE;
3876 3875
     $attributes = $this->_createParams( $this->url['params'] );
3877 3876
     return $this->_createElement( 'URL', $attributes, $this->url['value'] );
3878
-  }
3877
+    }
3879 3878
 /**
3880
- * set calendar component property url
3881
- *
3882
- * @author Kjell-Inge Gustafsson <[email protected]>
3883
- * @since 2.4.8 - 2008-11-04
3884
- * @param string $value
3885
- * @param string $params optional
3886
- * @return bool
3887
- */
3888
-  function setUrl( $value, $params=FALSE ) {
3879
+     * set calendar component property url
3880
+     *
3881
+     * @author Kjell-Inge Gustafsson <[email protected]>
3882
+     * @since 2.4.8 - 2008-11-04
3883
+     * @param string $value
3884
+     * @param string $params optional
3885
+     * @return bool
3886
+     */
3887
+    function setUrl( $value, $params=FALSE ) {
3889 3888
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3890 3889
     $this->url = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3891 3890
     return TRUE;
3892
-  }
3891
+    }
3893 3892
 /*********************************************************************************/
3894 3893
 /**
3895
- * Property Name: x-prop
3896
- */
3894
+     * Property Name: x-prop
3895
+     */
3897 3896
 /**
3898
- * creates formatted output for calendar component property x-prop
3899
- *
3900
- * @author Kjell-Inge Gustafsson <[email protected]>
3901
- * @since 2.4.11 - 2008-10-22
3902
- * @return string
3903
- */
3904
-  function createXprop() {
3897
+     * creates formatted output for calendar component property x-prop
3898
+     *
3899
+     * @author Kjell-Inge Gustafsson <[email protected]>
3900
+     * @since 2.4.11 - 2008-10-22
3901
+     * @return string
3902
+     */
3903
+    function createXprop() {
3905 3904
     if( empty( $this->xprop )) return FALSE;
3906 3905
     $output = null;
3907 3906
     foreach( $this->xprop as $label => $xpropPart ) {
3908
-      if( empty( $xpropPart['value'] )) {
3907
+        if( empty( $xpropPart['value'] )) {
3909 3908
         if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $label );
3910 3909
         continue;
3911
-      }
3912
-      $attributes = $this->_createParams( $xpropPart['params'], array( 'LANGUAGE' ));
3913
-      if( is_array( $xpropPart['value'] )) {
3910
+        }
3911
+        $attributes = $this->_createParams( $xpropPart['params'], array( 'LANGUAGE' ));
3912
+        if( is_array( $xpropPart['value'] )) {
3914 3913
         foreach( $xpropPart['value'] as $pix => $theXpart )
3915
-          $xpropPart['value'][$pix] = $this->_strrep( $theXpart );
3914
+            $xpropPart['value'][$pix] = $this->_strrep( $theXpart );
3916 3915
         $xpropPart['value']  = implode( ',', $xpropPart['value'] );
3917
-      }
3918
-      else
3916
+        }
3917
+        else
3919 3918
         $xpropPart['value'] = $this->_strrep( $xpropPart['value'] );
3920
-      $output    .= $this->_createElement( $label, $attributes, $xpropPart['value'] );
3919
+        $output    .= $this->_createElement( $label, $attributes, $xpropPart['value'] );
3921 3920
     }
3922 3921
     return $output;
3923
-  }
3922
+    }
3924 3923
 /**
3925
- * set calendar component property x-prop
3926
- *
3927
- * @author Kjell-Inge Gustafsson <[email protected]>
3928
-	* @since 2.4.11 - 2008-11-04
3929
- * @param string $label
3930
- * @param mixed $value
3931
- * @param array $params optional
3932
- * @return bool
3933
- */
3934
-  function setXprop( $label, $value, $params=FALSE ) {
3924
+     * set calendar component property x-prop
3925
+     *
3926
+     * @author Kjell-Inge Gustafsson <[email protected]>
3927
+     * @since 2.4.11 - 2008-11-04
3928
+     * @param string $label
3929
+     * @param mixed $value
3930
+     * @param array $params optional
3931
+     * @return bool
3932
+     */
3933
+    function setXprop( $label, $value, $params=FALSE ) {
3935 3934
     if( empty( $label )) return;
3936 3935
     if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3937 3936
     $xprop           = array( 'value' => $value );
@@ -3940,20 +3939,20 @@  discard block
 block discarded – undo
3940 3939
     if( !is_array( $this->xprop )) $this->xprop = array();
3941 3940
     $this->xprop[strtoupper( $label )] = $xprop;
3942 3941
     return TRUE;
3943
-  }
3942
+    }
3944 3943
 /*********************************************************************************/
3945 3944
 /*********************************************************************************/
3946 3945
 /**
3947
- * create element format parts
3948
- *
3949
- * @author Kjell-Inge Gustafsson <[email protected]>
3950
- * @since 2.0.6 - 2006-06-20
3951
- * @return string
3952
- */
3953
-  function _createFormat() {
3946
+     * create element format parts
3947
+     *
3948
+     * @author Kjell-Inge Gustafsson <[email protected]>
3949
+     * @since 2.0.6 - 2006-06-20
3950
+     * @return string
3951
+     */
3952
+    function _createFormat() {
3954 3953
     $objectname                   = null;
3955 3954
     switch( $this->format ) {
3956
-      case 'xcal':
3955
+        case 'xcal':
3957 3956
         $objectname               = ( isset( $this->timezonetype )) ?
3958 3957
                                  strtolower( $this->timezonetype )  :  strtolower( $this->objName );
3959 3958
         $this->componentStart1    = $this->elementStart1 = '<';
@@ -3964,7 +3963,7 @@  discard block
 block discarded – undo
3964 3963
         $this->attributeDelimiter = $this->nl;
3965 3964
         $this->valueInit          = null;
3966 3965
         break;
3967
-      default:
3966
+        default:
3968 3967
         $objectname               = ( isset( $this->timezonetype )) ?
3969 3968
                                  strtoupper( $this->timezonetype )  :  strtoupper( $this->objName );
3970 3969
         $this->componentStart1    = 'BEGIN:';
@@ -3981,232 +3980,232 @@  discard block
 block discarded – undo
3981 3980
         break;
3982 3981
     }
3983 3982
     return $objectname;
3984
-  }
3983
+    }
3985 3984
 /**
3986
- * creates formatted output for calendar component property
3987
- *
3988
- * @author Kjell-Inge Gustafsson <[email protected]>
3989
- * @since 2.4.8 - 2008-10-23
3990
- * @param string $label property name
3991
- * @param string $attributes property attributes
3992
- * @param string $content property content (optional)
3993
- * @return string
3994
- */
3995
-  function _createElement( $label, $attributes=null, $content=FALSE ) {
3985
+     * creates formatted output for calendar component property
3986
+     *
3987
+     * @author Kjell-Inge Gustafsson <[email protected]>
3988
+     * @since 2.4.8 - 2008-10-23
3989
+     * @param string $label property name
3990
+     * @param string $attributes property attributes
3991
+     * @param string $content property content (optional)
3992
+     * @return string
3993
+     */
3994
+    function _createElement( $label, $attributes=null, $content=FALSE ) {
3996 3995
     $label  = $this->_formatPropertyName( $label );
3997 3996
     $output = $this->elementStart1.$label;
3998 3997
     $categoriesAttrLang = null;
3999 3998
     $attachInlineBinary = FALSE;
4000 3999
     $attachfmttype      = null;
4001 4000
     if( !empty( $attributes ))  {
4002
-      $attributes  = trim( $attributes );
4003
-      if ( 'xcal' == $this->format) {
4001
+        $attributes  = trim( $attributes );
4002
+        if ( 'xcal' == $this->format) {
4004 4003
         $attributes2 = explode( $this->intAttrDelimiter, $attributes );
4005 4004
         $attributes  = null;
4006 4005
         foreach( $attributes2 as $attribute ) {
4007
-          $attrKVarr = explode( '=', $attribute );
4008
-          if( empty( $attrKVarr[0] ))
4006
+            $attrKVarr = explode( '=', $attribute );
4007
+            if( empty( $attrKVarr[0] ))
4009 4008
             continue;
4010
-          if( !isset( $attrKVarr[1] )) {
4009
+            if( !isset( $attrKVarr[1] )) {
4011 4010
             $attrValue = $attrKVarr[0];
4012 4011
             $attrKey   = null;
4013
-          }
4014
-          elseif( 2 == count( $attrKVarr)) {
4012
+            }
4013
+            elseif( 2 == count( $attrKVarr)) {
4015 4014
             $attrKey   = strtolower( $attrKVarr[0] );
4016 4015
             $attrValue = $attrKVarr[1];
4017
-          }
4018
-          else {
4016
+            }
4017
+            else {
4019 4018
             $attrKey   = strtolower( $attrKVarr[0] );
4020 4019
             unset( $attrKVarr[0] );
4021 4020
             $attrValue = implode( '=', $attrKVarr );
4022
-          }
4023
-          if(( 'attach' == $label ) && ( in_array( $attrKey, array( 'fmttype', 'encoding', 'value' )))) {
4021
+            }
4022
+            if(( 'attach' == $label ) && ( in_array( $attrKey, array( 'fmttype', 'encoding', 'value' )))) {
4024 4023
             $attachInlineBinary = TRUE;
4025 4024
             if( 'fmttype' == $attrKey )
4026
-              $attachfmttype = $attrKey.'='.$attrValue;
4025
+                $attachfmttype = $attrKey.'='.$attrValue;
4027 4026
             continue;
4028
-          }
4029
-          elseif(( 'categories' == $label ) && ( 'language' == $attrKey ))
4027
+            }
4028
+            elseif(( 'categories' == $label ) && ( 'language' == $attrKey ))
4030 4029
             $categoriesAttrLang = $attrKey.'='.$attrValue;
4031
-          else {
4030
+            else {
4032 4031
             $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' ';
4033 4032
             $attributes .= ( !empty( $attrKey )) ? $attrKey.'=' : null;
4034 4033
             if(( '"' == substr( $attrValue, 0, 1 )) && ( '"' == substr( $attrValue, -1 ))) {
4035
-              $attrValue = substr( $attrValue, 1, ( strlen( $attrValue ) - 2 ));
4036
-              $attrValue = str_replace( '"', '', $attrValue );
4034
+                $attrValue = substr( $attrValue, 1, ( strlen( $attrValue ) - 2 ));
4035
+                $attrValue = str_replace( '"', '', $attrValue );
4037 4036
             }
4038 4037
             $attributes .= '"'.htmlspecialchars( $attrValue ).'"';
4039
-          }
4038
+            }
4039
+        }
4040 4040
         }
4041
-      }
4042
-      else {
4041
+        else {
4043 4042
         $attributes = str_replace( $this->intAttrDelimiter, $this->attributeDelimiter, $attributes );
4044
-      }
4043
+        }
4045 4044
     }
4046 4045
     if(((( 'attach' == $label ) && !$attachInlineBinary ) ||
4047 4046
          ( in_array( $label, array( 'tzurl', 'url' ))))      && ( 'xcal' == $this->format)) {
4048
-      $pos = strrpos($content, "/");
4049
-      $docname = ( $pos !== false) ? substr( $content, (1 - strlen( $content ) + $pos )) : $content;
4050
-      $this->xcaldecl[] = array( 'xmldecl'  => 'ENTITY'
4051
-                               , 'uri'      => $docname
4052
-                               , 'ref'      => 'SYSTEM'
4053
-                               , 'external' => $content
4054
-                               , 'type'     => 'NDATA'
4055
-                               , 'type2'    => 'BINERY' );
4056
-      $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' ';
4057
-      $attributes .= 'uri="'.$docname.'"';
4058
-      $content = null;
4059
-      if( 'attach' == $label ) {
4047
+        $pos = strrpos($content, "/");
4048
+        $docname = ( $pos !== false) ? substr( $content, (1 - strlen( $content ) + $pos )) : $content;
4049
+        $this->xcaldecl[] = array( 'xmldecl'  => 'ENTITY'
4050
+                                , 'uri'      => $docname
4051
+                                , 'ref'      => 'SYSTEM'
4052
+                                , 'external' => $content
4053
+                                , 'type'     => 'NDATA'
4054
+                                , 'type2'    => 'BINERY' );
4055
+        $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' ';
4056
+        $attributes .= 'uri="'.$docname.'"';
4057
+        $content = null;
4058
+        if( 'attach' == $label ) {
4060 4059
         $attributes = str_replace( $this->attributeDelimiter, $this->intAttrDelimiter, $attributes );
4061 4060
         $content = $this->_createElement( 'extref', $attributes, null );
4062 4061
         $attributes = null;
4063
-      }
4062
+        }
4064 4063
     }
4065 4064
     elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) {
4066
-      $content = $this->nl.$this->_createElement( 'b64bin', $attachfmttype, $content ); // max one attribute
4065
+        $content = $this->nl.$this->_createElement( 'b64bin', $attachfmttype, $content ); // max one attribute
4067 4066
     }
4068 4067
     $output .= $attributes;
4069 4068
     if( !$content ) {
4070
-      switch( $this->format ) {
4069
+        switch( $this->format ) {
4071 4070
         case 'xcal':
4072 4071
           $output .= ' /';
4073
-          $output .= $this->elementStart2;
4074
-          return $output;
4075
-          break;
4072
+            $output .= $this->elementStart2;
4073
+            return $output;
4074
+            break;
4076 4075
         default:
4077 4076
           $output .= $this->elementStart2.$this->valueInit;
4078
-          return $this->_size75( $output );
4079
-          break;
4080
-      }
4077
+            return $this->_size75( $output );
4078
+            break;
4079
+        }
4081 4080
     }
4082 4081
     $output .= $this->elementStart2;
4083 4082
     $output .= $this->valueInit.$content;
4084 4083
     switch( $this->format ) {
4085
-      case 'xcal':
4084
+        case 'xcal':
4086 4085
         return $output.$this->elementEnd1.$label.$this->elementEnd2;
4087 4086
         break;
4088
-      default:
4087
+        default:
4089 4088
         return $this->_size75( $output );
4090 4089
         break;
4091 4090
     }
4092
-  }
4091
+    }
4093 4092
 /**
4094
- * creates formatted output for calendar component property parameters
4095
- *
4096
- * @author Kjell-Inge Gustafsson <[email protected]>
4097
- * @since 0.9.22 - 2007-04-10
4098
- * @param array $params  optional
4099
- * @param array $ctrKeys optional
4100
- * @return string
4101
- */
4102
-  function _createParams( $params=array(), $ctrKeys=array() ) {
4093
+     * creates formatted output for calendar component property parameters
4094
+     *
4095
+     * @author Kjell-Inge Gustafsson <[email protected]>
4096
+     * @since 0.9.22 - 2007-04-10
4097
+     * @param array $params  optional
4098
+     * @param array $ctrKeys optional
4099
+     * @return string
4100
+     */
4101
+    function _createParams( $params=array(), $ctrKeys=array() ) {
4103 4102
     $attrLANG = $attr1 = $attr2 = null;
4104 4103
     $CNattrKey   = ( in_array( 'CN',       $ctrKeys )) ? TRUE : FALSE ;
4105 4104
     $LANGattrKey = ( in_array( 'LANGUAGE', $ctrKeys )) ? TRUE : FALSE ;
4106 4105
     $CNattrExist = $LANGattrExist = FALSE;
4107 4106
     if( is_array( $params )) {
4108
-      foreach( $params as $paramKey => $paramValue ) {
4107
+        foreach( $params as $paramKey => $paramValue ) {
4109 4108
         if( is_int( $paramKey ))
4110
-          $attr2            .= $this->intAttrDelimiter.$paramValue;
4109
+            $attr2            .= $this->intAttrDelimiter.$paramValue;
4111 4110
         elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) {
4112
-          $attrLANG         .= $this->intAttrDelimiter."LANGUAGE=$paramValue";
4113
-          $LANGattrExist     = TRUE;
4111
+            $attrLANG         .= $this->intAttrDelimiter."LANGUAGE=$paramValue";
4112
+            $LANGattrExist     = TRUE;
4114 4113
         }
4115 4114
         elseif(( 'CN'       == $paramKey ) && $CNattrKey ) {
4116
-          $attr1             = $this->intAttrDelimiter.'CN="'.$paramValue.'"';
4117
-          $CNattrExist       = TRUE;
4115
+            $attr1             = $this->intAttrDelimiter.'CN="'.$paramValue.'"';
4116
+            $CNattrExist       = TRUE;
4118 4117
         }
4119 4118
         elseif(( 'ALTREP'   == $paramKey ) && in_array( $paramKey, $ctrKeys ))
4120
-          $attr2            .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"';
4119
+            $attr2            .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"';
4121 4120
         elseif(( 'DIR'      == $paramKey ) && in_array( $paramKey, $ctrKeys ))
4122
-          $attr2            .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"';
4121
+            $attr2            .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"';
4123 4122
         elseif(( 'SENT-BY'  == $paramKey ) && in_array( $paramKey, $ctrKeys ))
4124
-          $attr2            .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"';
4123
+            $attr2            .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"';
4125 4124
         else
4126
-          $attr2            .= $this->intAttrDelimiter."$paramKey=$paramValue";
4127
-      }
4125
+            $attr2            .= $this->intAttrDelimiter."$paramKey=$paramValue";
4126
+        }
4128 4127
     }
4129 4128
     if( !$LANGattrExist ) {
4130
-      $lang = $this->getConfig( 'language' );
4131
-      if(( $CNattrExist || $LANGattrKey ) && $lang )
4129
+        $lang = $this->getConfig( 'language' );
4130
+        if(( $CNattrExist || $LANGattrKey ) && $lang )
4132 4131
         $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang;
4133 4132
     }
4134 4133
     return $attrLANG.$attr1.$attr2;
4135
-  }
4134
+    }
4136 4135
 /**
4137
- * check a date(-time) for an opt. timezone and if it is a DATE-TIME or DATE
4138
- *
4139
- * @author Kjell-Inge Gustafsson <[email protected]>
4140
- * @since 2.4.16 - 2008-10-25
4141
- * @param array $date, date to check
4142
- * @param int $parno, no of date parts (i.e. year, month.. .)
4143
- * @return array $params, property parameters
4144
- */
4145
-  function _chkdatecfg( $theDate, & $parno, & $params ) {
4136
+     * check a date(-time) for an opt. timezone and if it is a DATE-TIME or DATE
4137
+     *
4138
+     * @author Kjell-Inge Gustafsson <[email protected]>
4139
+     * @since 2.4.16 - 2008-10-25
4140
+     * @param array $date, date to check
4141
+     * @param int $parno, no of date parts (i.e. year, month.. .)
4142
+     * @return array $params, property parameters
4143
+     */
4144
+    function _chkdatecfg( $theDate, & $parno, & $params ) {
4146 4145
     if( isset( $params['TZID'] ))
4147
-      $parno = 6;
4146
+        $parno = 6;
4148 4147
     elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))
4149
-      $parno = 3;
4148
+        $parno = 3;
4150 4149
     else {
4151
-      if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] ))
4150
+        if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] ))
4152 4151
         $parno = 7;
4153
-      if( is_array( $theDate )) {
4152
+        if( is_array( $theDate )) {
4154 4153
         if( isset( $theDate['timestamp'] ))
4155
-          $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null;
4154
+            $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null;
4156 4155
         else
4157
-          $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null;
4156
+            $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null;
4158 4157
         if( !empty( $tzid )) {
4159
-          $parno = 7;
4160
-          if( !$this->_isOffset( $tzid ))
4158
+            $parno = 7;
4159
+            if( !$this->_isOffset( $tzid ))
4161 4160
             $params['TZID'] = $tzid; // save only timezone
4162 4161
         }
4163 4162
         elseif( !$parno && ( 3 == count( $theDate )) && 
4164 4163
           ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )))
4165
-          $parno = 3;
4164
+            $parno = 3;
4166 4165
         else
4167
-          $parno = 6;
4168
-      }
4169
-      else { // string
4166
+            $parno = 6;
4167
+        }
4168
+        else { // string
4170 4169
         $date = trim( $theDate );
4171 4170
         if( 'Z' == substr( $date, -1 ))
4172
-          $parno = 7; // UTC DATE-TIME
4171
+            $parno = 7; // UTC DATE-TIME
4173 4172
         elseif((( 8 == strlen( $date ) && ctype_digit( $date )) || ( 11 >= strlen( $date ))) && 
4174 4173
           ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' ))))
4175
-          $parno = 3; // DATE
4174
+            $parno = 3; // DATE
4176 4175
         $date = $this->_date_time_string( $date, $parno );
4177 4176
         if( !empty( $date['tz'] )) {
4178
-          $parno = 7;
4179
-          if( !$this->_isOffset( $date['tz'] ))
4177
+            $parno = 7;
4178
+            if( !$this->_isOffset( $date['tz'] ))
4180 4179
             $params['TZID'] = $date['tz']; // save only timezone
4181 4180
         }
4182 4181
         elseif( empty( $parno ))
4183
-          $parno = 6;
4184
-      }
4185
-      if( isset( $params['TZID'] ))
4182
+            $parno = 6;
4183
+        }
4184
+        if( isset( $params['TZID'] ))
4186 4185
         $parno = 6;
4187 4186
     }
4188
-  }
4187
+    }
4189 4188
 /**
4190
- * convert local startdate/enddate (Ymd[His]) to duration
4191
- *
4192
- * uses this component dates if missing input dates
4193
- *
4194
- * @author Kjell-Inge Gustafsson <[email protected]>
4195
- * @since 2.2.11 - 2007-11-03
4196
- * @param array $startdate, optional
4197
- * @param array $duration, optional
4198
- * @return array duration
4199
- */
4200
-  function _date2duration( $startdate=FALSE, $enddate=FALSE ) {
4189
+     * convert local startdate/enddate (Ymd[His]) to duration
4190
+     *
4191
+     * uses this component dates if missing input dates
4192
+     *
4193
+     * @author Kjell-Inge Gustafsson <[email protected]>
4194
+     * @since 2.2.11 - 2007-11-03
4195
+     * @param array $startdate, optional
4196
+     * @param array $duration, optional
4197
+     * @return array duration
4198
+     */
4199
+    function _date2duration( $startdate=FALSE, $enddate=FALSE ) {
4201 4200
     if( !$startdate || !$enddate ) {
4202
-      if(   FALSE === ( $startdate = $this->getProperty( 'dtstart' )))
4201
+        if(   FALSE === ( $startdate = $this->getProperty( 'dtstart' )))
4203 4202
         return null;
4204
-      if(   FALSE === ( $enddate   = $this->getProperty( 'dtend' )))    // vevent/vfreebusy
4203
+        if(   FALSE === ( $enddate   = $this->getProperty( 'dtend' )))    // vevent/vfreebusy
4205 4204
         if( FALSE === ( $enddate   = $this->getProperty( 'due' )))      // vtodo
4206
-          return null;
4205
+            return null;
4207 4206
     }
4208 4207
     if( !$startdate || !$enddate )
4209
-      return null;
4208
+        return null;
4210 4209
     $startWdate  = mktime( 0, 0, 0, $startdate['month'], $startdate['day'], $startdate['year'] );
4211 4210
     $endWdate    = mktime( 0, 0, 0, $enddate['month'],   $enddate['day'],   $enddate['year'] );
4212 4211
     $wduration   = $endWdate - $startWdate;
@@ -4220,137 +4219,137 @@  discard block
 block discarded – undo
4220 4219
     $dur['min']  = (int) floor( $wduration / ( 60 ));
4221 4220
     $dur['sec']  = (int)        $wduration % ( 60 );
4222 4221
     return $dur;
4223
-  }
4222
+    }
4224 4223
 /**
4225
- * convert date/datetime to timestamp
4226
- *
4227
- * @author Kjell-Inge Gustafsson <[email protected]>
4228
- * @since 2.4.8 - 2008-10-30
4229
- * @param array  $datetime  datetime/(date)
4230
- * @param string $tz        timezone
4231
- * @return timestamp
4232
- */
4233
-  function _date2timestamp( $datetime, $tz=null ) {
4224
+     * convert date/datetime to timestamp
4225
+     *
4226
+     * @author Kjell-Inge Gustafsson <[email protected]>
4227
+     * @since 2.4.8 - 2008-10-30
4228
+     * @param array  $datetime  datetime/(date)
4229
+     * @param string $tz        timezone
4230
+     * @return timestamp
4231
+     */
4232
+    function _date2timestamp( $datetime, $tz=null ) {
4234 4233
     $output = null;
4235 4234
     if( !isset( $datetime['hour'] )) $datetime['hour'] = '0';
4236 4235
     if( !isset( $datetime['min'] ))  $datetime['min']  = '0';
4237 4236
     if( !isset( $datetime['sec'] ))  $datetime['sec']  = '0';
4238 4237
     foreach( $datetime as $dkey => $dvalue ) {
4239
-      if( 'tz' != $dkey )
4238
+        if( 'tz' != $dkey )
4240 4239
         $datetime[$dkey] = (integer) $dvalue;
4241 4240
     }
4242 4241
     if( $tz )
4243
-      $datetime['tz'] = $tz;
4242
+        $datetime['tz'] = $tz;
4244 4243
     $offset = ( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) ? $this->_tz2offset( $datetime['tz'] ) : 0;
4245 4244
     $output = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year'] );
4246 4245
     return $output;
4247
-  }
4246
+    }
4248 4247
 /**
4249
- * ensures internal date-time/date format for input date-time/date in array format
4250
- *
4251
- * @author Kjell-Inge Gustafsson <[email protected]>
4252
- * @since 0.3.0 - 2006-08-15
4253
- * @param array $datetime
4254
- * @param int $parno optional, default FALSE
4255
- * @return array
4256
- */
4257
-  function _date_time_array( $datetime, $parno=FALSE ) {
4248
+     * ensures internal date-time/date format for input date-time/date in array format
4249
+     *
4250
+     * @author Kjell-Inge Gustafsson <[email protected]>
4251
+     * @since 0.3.0 - 2006-08-15
4252
+     * @param array $datetime
4253
+     * @param int $parno optional, default FALSE
4254
+     * @return array
4255
+     */
4256
+    function _date_time_array( $datetime, $parno=FALSE ) {
4258 4257
     $output = array();
4259 4258
     foreach( $datetime as $dateKey => $datePart ) {
4260
-      switch ( $dateKey ) {
4259
+        switch ( $dateKey ) {
4261 4260
         case '0': case 'year':   $output['year']  = $datePart; break;
4262 4261
         case '1': case 'month':  $output['month'] = $datePart; break;
4263 4262
         case '2': case 'day':    $output['day']   = $datePart; break;
4264
-      }
4265
-      if( 3 != $parno ) {
4263
+        }
4264
+        if( 3 != $parno ) {
4266 4265
         switch ( $dateKey ) {
4267
-          case '0':
4266
+            case '0':
4268 4267
           case '1':
4269 4268
           case '2': break;
4270
-          case '3': case 'hour': $output['hour']  = $datePart; break;
4271
-          case '4': case 'min' : $output['min']   = $datePart; break;
4272
-          case '5': case 'sec' : $output['sec']   = $datePart; break;
4273
-          case '6': case 'tz'  : $output['tz']    = $datePart; break;
4269
+            case '3': case 'hour': $output['hour']  = $datePart; break;
4270
+            case '4': case 'min' : $output['min']   = $datePart; break;
4271
+            case '5': case 'sec' : $output['sec']   = $datePart; break;
4272
+            case '6': case 'tz'  : $output['tz']    = $datePart; break;
4273
+        }
4274 4274
         }
4275
-      }
4276 4275
     }
4277 4276
     if( 3 != $parno ) {
4278
-      if( !isset( $output['hour'] ))
4277
+        if( !isset( $output['hour'] ))
4279 4278
         $output['hour'] = 0;
4280
-      if( !isset( $output['min']  ))
4279
+        if( !isset( $output['min']  ))
4281 4280
         $output['min'] = 0;
4282
-      if( !isset( $output['sec']  ))
4281
+        if( !isset( $output['sec']  ))
4283 4282
         $output['sec'] = 0;
4284 4283
     }
4285 4284
     return $output;
4286
-  }
4285
+    }
4287 4286
 /**
4288
- * ensures internal date-time/date format for input date-time/date in string fromat
4289
- *
4290
- * @author Kjell-Inge Gustafsson <[email protected]>
4291
- * @since 2.2.10 - 2007-10-19
4292
- * @param array $datetime
4293
- * @param int $parno optional, default FALSE
4294
- * @return array
4295
- */
4296
-  function _date_time_string( $datetime, $parno=FALSE ) {
4287
+     * ensures internal date-time/date format for input date-time/date in string fromat
4288
+     *
4289
+     * @author Kjell-Inge Gustafsson <[email protected]>
4290
+     * @since 2.2.10 - 2007-10-19
4291
+     * @param array $datetime
4292
+     * @param int $parno optional, default FALSE
4293
+     * @return array
4294
+     */
4295
+    function _date_time_string( $datetime, $parno=FALSE ) {
4297 4296
     $datetime = (string) trim( $datetime );
4298 4297
     $tz  = null;
4299 4298
     $len = strlen( $datetime ) - 1;
4300 4299
     if( 'Z' == substr( $datetime, -1 )) {
4301
-      $tz = 'Z';
4302
-      $datetime = trim( substr( $datetime, 0, $len ));
4300
+        $tz = 'Z';
4301
+        $datetime = trim( substr( $datetime, 0, $len ));
4303 4302
     }
4304 4303
     elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date
4305 4304
                   ( '-' == substr( $datetime, -3, 1 )) ||
4306 4305
                   ( ':' == substr( $datetime, -3, 1 )) ||
4307 4306
                   ( '.' == substr( $datetime, -3, 1 ))) {
4308
-      $continue = TRUE;
4307
+        $continue = TRUE;
4309 4308
     }
4310 4309
     elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset
4311 4310
             ( ' +' == substr( $datetime, -6, 2 )) ||
4312 4311
             ( ' -' == substr( $datetime, -6, 2 ))) {
4313
-      $tz = substr( $datetime, -5, 5 );
4314
-      $datetime = substr( $datetime, 0, ($len - 5));
4312
+        $tz = substr( $datetime, -5, 5 );
4313
+        $datetime = substr( $datetime, 0, ($len - 5));
4315 4314
     }
4316 4315
     elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset
4317 4316
             ( ' +' == substr( $datetime, -8, 2 )) ||
4318 4317
             ( ' -' == substr( $datetime, -8, 2 ))) {
4319
-      $tz = substr( $datetime, -7, 7 );
4320
-      $datetime = substr( $datetime, 0, ($len - 7));
4318
+        $tz = substr( $datetime, -7, 7 );
4319
+        $datetime = substr( $datetime, 0, ($len - 7));
4321 4320
     }
4322 4321
     elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) {
4323
-      $continue = TRUE;
4322
+        $continue = TRUE;
4324 4323
     }
4325 4324
     elseif( 'T' ==  substr( $datetime, -7, 1 )) {
4326
-      $continue = TRUE;
4325
+        $continue = TRUE;
4327 4326
     }
4328 4327
     else {
4329
-      $cx  = $tx = 0;    //  19970415T133000 US-Eastern
4330
-      for( $cx = -1; $cx > ( 9 - $len ); $cx-- ) {
4328
+        $cx  = $tx = 0;    //  19970415T133000 US-Eastern
4329
+        for( $cx = -1; $cx > ( 9 - $len ); $cx-- ) {
4331 4330
         if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 )))
4332
-          break; // if exists, tz ends here.. . ?
4331
+            break; // if exists, tz ends here.. . ?
4333 4332
         elseif( ctype_alpha( substr( $datetime, $cx, 1 )) ||
4334 4333
              ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' ))))
4335
-          $tx--; // tz length counter
4336
-      }
4337
-      if( 0 > $tx ) {
4334
+            $tx--; // tz length counter
4335
+        }
4336
+        if( 0 > $tx ) {
4338 4337
         $tz = substr( $datetime, $tx );
4339 4338
         $datetime = trim( substr( $datetime, 0, $len + $tx + 1 ));
4340
-      }
4339
+        }
4341 4340
     }
4342 4341
     if( 0 < substr_count( $datetime, '-' )) {
4343
-      $datetime = str_replace( '-', '/', $datetime );
4342
+        $datetime = str_replace( '-', '/', $datetime );
4344 4343
     }
4345 4344
     elseif( ctype_digit( substr( $datetime, 0, 8 )) &&
4346 4345
            ( 'T' ==      substr( $datetime, 8, 1 )) &&
4347 4346
             ctype_digit( substr( $datetime, 9, 6 ))) {
4348
-      $datetime = substr( $datetime,  4, 2 )
4349
-             .'/'.substr( $datetime,  6, 2 )
4350
-             .'/'.substr( $datetime,  0, 4 )
4351
-             .' '.substr( $datetime,  9, 2 )
4352
-             .':'.substr( $datetime, 11, 2 )
4353
-             .':'.substr( $datetime, 13);
4347
+        $datetime = substr( $datetime,  4, 2 )
4348
+                .'/'.substr( $datetime,  6, 2 )
4349
+                .'/'.substr( $datetime,  0, 4 )
4350
+                .' '.substr( $datetime,  9, 2 )
4351
+                .':'.substr( $datetime, 11, 2 )
4352
+                .':'.substr( $datetime, 13);
4354 4353
     }
4355 4354
     $datestring = date( 'Y-m-d H:i:s', strtotime( $datetime ));
4356 4355
     $tz                = trim( $tz );
@@ -4359,112 +4358,112 @@  discard block
 block discarded – undo
4359 4358
     $output['month']   = substr( $datestring, 5, 2 );
4360 4359
     $output['day']     = substr( $datestring, 8, 2 );
4361 4360
     if(( 6 == $parno ) || ( 7 == $parno )) {
4362
-      $output['hour']  = substr( $datestring, 11, 2 );
4363
-      $output['min']   = substr( $datestring, 14, 2 );
4364
-      $output['sec']   = substr( $datestring, 17, 2 );
4365
-      if( !empty( $tz ))
4361
+        $output['hour']  = substr( $datestring, 11, 2 );
4362
+        $output['min']   = substr( $datestring, 14, 2 );
4363
+        $output['sec']   = substr( $datestring, 17, 2 );
4364
+        if( !empty( $tz ))
4366 4365
         $output['tz']  = $tz;
4367 4366
     }
4368 4367
     elseif( 3 != $parno ) {
4369
-      if(( '00' < substr( $datestring, 11, 2 )) ||
4368
+        if(( '00' < substr( $datestring, 11, 2 )) ||
4370 4369
          ( '00' < substr( $datestring, 14, 2 )) ||
4371 4370
          ( '00' < substr( $datestring, 17, 2 ))) {
4372 4371
         $output['hour']  = substr( $datestring, 11, 2 );
4373 4372
         $output['min']   = substr( $datestring, 14, 2 );
4374 4373
         $output['sec']   = substr( $datestring, 17, 2 );
4375
-      }
4376
-      if( !empty( $tz ))
4374
+        }
4375
+        if( !empty( $tz ))
4377 4376
         $output['tz']  = $tz;
4378 4377
     }
4379 4378
     return $output;
4380
-  }
4379
+    }
4381 4380
 /**
4382
- * ensures internal duration format for input in array format
4383
- *
4384
- * @author Kjell-Inge Gustafsson <[email protected]>
4385
- * @since 2.1.1 - 2007-06-24
4386
- * @param array $duration
4387
- * @return array
4388
- */
4389
-  function _duration_array( $duration ) {
4381
+     * ensures internal duration format for input in array format
4382
+     *
4383
+     * @author Kjell-Inge Gustafsson <[email protected]>
4384
+     * @since 2.1.1 - 2007-06-24
4385
+     * @param array $duration
4386
+     * @return array
4387
+     */
4388
+    function _duration_array( $duration ) {
4390 4389
     $output = array();
4391 4390
     if(    is_array( $duration )        &&
4392 4391
        ( 1 == count( $duration ))       &&
4393 4392
               isset( $duration['sec'] ) &&
4394 4393
               ( 60 < $duration['sec'] )) {
4395
-      $durseconds  = $duration['sec'];
4396
-      $output['week'] = floor( $durseconds / ( 60 * 60 * 24 * 7 ));
4397
-      $durseconds  =           $durseconds % ( 60 * 60 * 24 * 7 );
4398
-      $output['day']  = floor( $durseconds / ( 60 * 60 * 24 ));
4399
-      $durseconds  =           $durseconds % ( 60 * 60 * 24 );
4400
-      $output['hour'] = floor( $durseconds / ( 60 * 60 ));
4401
-      $durseconds  =           $durseconds % ( 60 * 60 );
4402
-      $output['min']  = floor( $durseconds / ( 60 ));
4403
-      $output['sec']  =      ( $durseconds % ( 60 ));
4394
+        $durseconds  = $duration['sec'];
4395
+        $output['week'] = floor( $durseconds / ( 60 * 60 * 24 * 7 ));
4396
+        $durseconds  =           $durseconds % ( 60 * 60 * 24 * 7 );
4397
+        $output['day']  = floor( $durseconds / ( 60 * 60 * 24 ));
4398
+        $durseconds  =           $durseconds % ( 60 * 60 * 24 );
4399
+        $output['hour'] = floor( $durseconds / ( 60 * 60 ));
4400
+        $durseconds  =           $durseconds % ( 60 * 60 );
4401
+        $output['min']  = floor( $durseconds / ( 60 ));
4402
+        $output['sec']  =      ( $durseconds % ( 60 ));
4404 4403
     }
4405 4404
     else {
4406
-      foreach( $duration as $durKey => $durValue ) {
4405
+        foreach( $duration as $durKey => $durValue ) {
4407 4406
         if( empty( $durValue )) continue;
4408 4407
         switch ( $durKey ) {
4409
-          case '0': case 'week': $output['week']  = $durValue; break;
4410
-          case '1': case 'day':  $output['day']   = $durValue; break;
4411
-          case '2': case 'hour': $output['hour']  = $durValue; break;
4412
-          case '3': case 'min':  $output['min']   = $durValue; break;
4413
-          case '4': case 'sec':  $output['sec']   = $durValue; break;
4408
+            case '0': case 'week': $output['week']  = $durValue; break;
4409
+            case '1': case 'day':  $output['day']   = $durValue; break;
4410
+            case '2': case 'hour': $output['hour']  = $durValue; break;
4411
+            case '3': case 'min':  $output['min']   = $durValue; break;
4412
+            case '4': case 'sec':  $output['sec']   = $durValue; break;
4413
+        }
4414 4414
         }
4415
-      }
4416 4415
     }
4417 4416
     if( isset( $output['week'] ) && ( 0 < $output['week'] )) {
4418
-      unset( $output['day'], $output['hour'], $output['min'], $output['sec'] );
4419
-      return $output;
4417
+        unset( $output['day'], $output['hour'], $output['min'], $output['sec'] );
4418
+        return $output;
4420 4419
     }
4421 4420
     unset( $output['week'] );
4422 4421
     if( empty( $output['day'] ))
4423
-      unset( $output['day'] );
4422
+        unset( $output['day'] );
4424 4423
     if ( isset( $output['hour'] ) || isset( $output['min'] ) || isset( $output['sec'] )) {
4425
-      if( !isset( $output['hour'] )) $output['hour'] = 0;
4426
-      if( !isset( $output['min']  )) $output['min']  = 0;
4427
-      if( !isset( $output['sec']  )) $output['sec']  = 0;
4428
-      if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] ))
4424
+        if( !isset( $output['hour'] )) $output['hour'] = 0;
4425
+        if( !isset( $output['min']  )) $output['min']  = 0;
4426
+        if( !isset( $output['sec']  )) $output['sec']  = 0;
4427
+        if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] ))
4429 4428
         unset( $output['hour'], $output['min'], $output['sec'] );
4430 4429
     }
4431 4430
     return $output;
4432
-  }
4431
+    }
4433 4432
 /**
4434
- * convert duration to date in array format based on input or dtstart value
4435
- *
4436
- * @author Kjell-Inge Gustafsson <[email protected]>
4437
- * @since 2.4.8 - 2008-10-30
4438
- * @param array $startdate, optional
4439
- * @param array $duration, optional
4440
- * @return array, date format
4441
- */
4442
-  function duration2date( $startdate=FALSE, $duration=FALSE ) {
4433
+     * convert duration to date in array format based on input or dtstart value
4434
+     *
4435
+     * @author Kjell-Inge Gustafsson <[email protected]>
4436
+     * @since 2.4.8 - 2008-10-30
4437
+     * @param array $startdate, optional
4438
+     * @param array $duration, optional
4439
+     * @return array, date format
4440
+     */
4441
+    function duration2date( $startdate=FALSE, $duration=FALSE ) {
4443 4442
     if( $startdate && $duration ) {
4444
-      $d1               = $startdate;
4445
-      $dur              = $duration;
4443
+        $d1               = $startdate;
4444
+        $dur              = $duration;
4446 4445
     }
4447 4446
     elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) {
4448
-      $d1               = $this->dtstart['value'];
4449
-      $dur              = $this->duration['value'];
4447
+        $d1               = $this->dtstart['value'];
4448
+        $dur              = $this->duration['value'];
4450 4449
     }
4451 4450
     else
4452
-      return null;
4451
+        return null;
4453 4452
     $dateOnly         = ( isset( $d1['hour'] ) || isset( $d1['min'] ) || isset( $d1['sec'] )) ? FALSE : TRUE;
4454 4453
     $d1['hour']       = ( isset( $d1['hour'] )) ? $d1['hour'] : 0;
4455 4454
     $d1['min']        = ( isset( $d1['min'] ))  ? $d1['min']  : 0;
4456 4455
     $d1['sec']        = ( isset( $d1['sec'] ))  ? $d1['sec']  : 0;
4457 4456
     $dtend = mktime( $d1['hour'], $d1['min'], $d1['sec'], $d1['month'], $d1['day'], $d1['year'] );
4458 4457
     if( isset( $dur['week'] ))
4459
-      $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 );
4458
+        $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 );
4460 4459
     if( isset( $dur['day'] ))
4461
-      $dtend += ( $dur['day'] * 24 * 60 * 60 );
4460
+        $dtend += ( $dur['day'] * 24 * 60 * 60 );
4462 4461
     if( isset( $dur['hour'] ))
4463
-      $dtend += ( $dur['hour'] * 60 *60 );
4462
+        $dtend += ( $dur['hour'] * 60 *60 );
4464 4463
     if( isset( $dur['min'] ))
4465
-      $dtend += ( $dur['min'] * 60 );
4464
+        $dtend += ( $dur['min'] * 60 );
4466 4465
     if( isset( $dur['sec'] ))
4467
-      $dtend +=   $dur['sec'];
4466
+        $dtend +=   $dur['sec'];
4468 4467
     $dtend2 = array();
4469 4468
     $dtend2['year']   = date('Y', $dtend );
4470 4469
     $dtend2['month']  = date('m', $dtend );
@@ -4473,112 +4472,112 @@  discard block
 block discarded – undo
4473 4472
     $dtend2['min']    = date('i', $dtend );
4474 4473
     $dtend2['sec']    = date('s', $dtend );
4475 4474
     if( isset( $d1['tz'] ))
4476
-      $dtend2['tz']   = $d1['tz'];
4475
+        $dtend2['tz']   = $d1['tz'];
4477 4476
     if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] )))
4478
-      unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] );
4477
+        unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] );
4479 4478
     return $dtend2;
4480
-  }
4479
+    }
4481 4480
 /**
4482
- * ensures internal duration format for input in string format
4483
- *
4484
- * @author Kjell-Inge Gustafsson <[email protected]>
4485
- * @since 2.0.5 - 2007-03-14
4486
- * @param string $duration
4487
- * @return array
4488
- */
4489
-  function _duration_string( $duration ) {
4490
-   $duration = (string) trim( $duration );
4491
-   while( 'P' != strtoupper( substr( $duration, 0, 1 ))) {
4492
-     if( 0 < strlen( $duration ))
4493
-       $duration = substr( $duration, 1 );
4494
-     else
4495
-       return false; // no leading P !?!?
4496
-   }
4497
-   $duration = substr( $duration, 1 ); // skip P
4498
-   $duration = str_replace ( 't', 'T', $duration );
4499
-   $duration = str_replace ( 'T', '', $duration );
4500
-   $output = array();
4501
-   $val    = null;
4502
-   for( $ix=0; $ix < strlen( $duration ); $ix++ ) {
4503
-     switch( strtoupper( $duration{$ix} )) {
4504
-      case 'W':
4481
+     * ensures internal duration format for input in string format
4482
+     *
4483
+     * @author Kjell-Inge Gustafsson <[email protected]>
4484
+     * @since 2.0.5 - 2007-03-14
4485
+     * @param string $duration
4486
+     * @return array
4487
+     */
4488
+    function _duration_string( $duration ) {
4489
+    $duration = (string) trim( $duration );
4490
+    while( 'P' != strtoupper( substr( $duration, 0, 1 ))) {
4491
+        if( 0 < strlen( $duration ))
4492
+        $duration = substr( $duration, 1 );
4493
+        else
4494
+        return false; // no leading P !?!?
4495
+    }
4496
+    $duration = substr( $duration, 1 ); // skip P
4497
+    $duration = str_replace ( 't', 'T', $duration );
4498
+    $duration = str_replace ( 'T', '', $duration );
4499
+    $output = array();
4500
+    $val    = null;
4501
+    for( $ix=0; $ix < strlen( $duration ); $ix++ ) {
4502
+        switch( strtoupper( $duration{$ix} )) {
4503
+        case 'W':
4505 4504
         $output['week'] = $val;
4506 4505
         $val            = null;
4507 4506
         break;
4508
-      case 'D':
4507
+        case 'D':
4509 4508
         $output['day']  = $val;
4510 4509
         $val            = null;
4511 4510
         break;
4512
-      case 'H':
4511
+        case 'H':
4513 4512
         $output['hour'] = $val;
4514 4513
         $val            = null;
4515 4514
         break;
4516
-      case 'M':
4515
+        case 'M':
4517 4516
         $output['min']  = $val;
4518 4517
         $val            = null;
4519 4518
         break;
4520
-      case 'S':
4519
+        case 'S':
4521 4520
         $output['sec']  = $val;
4522 4521
         $val            = null;
4523 4522
         break;
4524
-      default:
4523
+        default:
4525 4524
         if( !ctype_digit( $duration{$ix} ))
4526
-          return false; // unknown duration controll character  !?!?
4525
+            return false; // unknown duration controll character  !?!?
4527 4526
         else
4528
-          $val .= $duration{$ix};
4529
-     }
4530
-   }
4531
-   return $this->_duration_array( $output );
4532
-  }
4533
-/**
4534
- * if not preSet, if exist, remove key with expected value from array and return hit value else return elseValue
4535
- *
4536
- * @author Kjell-Inge Gustafsson <[email protected]>
4537
- * @since 2.4.16 - 2008-11-08
4538
- * @param array $array
4539
- * @param string $expkey, expected key
4540
- * @param string $expval, expected value
4541
- * @param int $hitVal optional, return value if found
4542
- * @param int $elseVal optional, return value if not found
4543
- * @param int $preSet optional, return value if already preset
4544
- * @return int
4545
- */
4546
-  function _existRem( &$array, $expkey, $expval=FALSE, $hitVal=null, $elseVal=null, $preSet=null ) {
4527
+            $val .= $duration{$ix};
4528
+        }
4529
+    }
4530
+    return $this->_duration_array( $output );
4531
+    }
4532
+/**
4533
+     * if not preSet, if exist, remove key with expected value from array and return hit value else return elseValue
4534
+     *
4535
+     * @author Kjell-Inge Gustafsson <[email protected]>
4536
+     * @since 2.4.16 - 2008-11-08
4537
+     * @param array $array
4538
+     * @param string $expkey, expected key
4539
+     * @param string $expval, expected value
4540
+     * @param int $hitVal optional, return value if found
4541
+     * @param int $elseVal optional, return value if not found
4542
+     * @param int $preSet optional, return value if already preset
4543
+     * @return int
4544
+     */
4545
+    function _existRem( &$array, $expkey, $expval=FALSE, $hitVal=null, $elseVal=null, $preSet=null ) {
4547 4546
     if( $preSet )
4548
-      return $preSet;
4547
+        return $preSet;
4549 4548
     if( !is_array( $array ) || ( 0 == count( $array )))
4550
-      return $elseVal;
4549
+        return $elseVal;
4551 4550
     foreach( $array as $key => $value ) {
4552
-      if( strtoupper( $expkey ) == strtoupper( $key )) {
4551
+        if( strtoupper( $expkey ) == strtoupper( $key )) {
4553 4552
         if( !$expval || ( strtoupper( $expval ) == strtoupper( $array[$key] ))) {
4554
-          unset( $array[$key] );
4555
-          return $hitVal;
4553
+            unset( $array[$key] );
4554
+            return $hitVal;
4555
+        }
4556 4556
         }
4557
-      }
4558 4557
     }
4559 4558
     return $elseVal;
4560
-  }
4559
+    }
4561 4560
 /**
4562
- * creates formatted output for calendar component property data value type date/date-time
4563
- *
4564
- * @author Kjell-Inge Gustafsson <[email protected]>
4565
- * @since 2.4.8 - 2008-10-30
4566
- * @param array   $datetime
4567
- * @param int     $parno, optional, default 6
4568
- * @return string
4569
- */
4570
-  function _format_date_time( $datetime, $parno=6 ) {
4561
+     * creates formatted output for calendar component property data value type date/date-time
4562
+     *
4563
+     * @author Kjell-Inge Gustafsson <[email protected]>
4564
+     * @since 2.4.8 - 2008-10-30
4565
+     * @param array   $datetime
4566
+     * @param int     $parno, optional, default 6
4567
+     * @return string
4568
+     */
4569
+    function _format_date_time( $datetime, $parno=6 ) {
4571 4570
     if( !isset( $datetime['year'] )  &&
4572 4571
         !isset( $datetime['month'] ) &&
4573 4572
         !isset( $datetime['day'] )   &&
4574 4573
         !isset( $datetime['hour'] )  &&
4575 4574
         !isset( $datetime['min'] )   &&
4576 4575
         !isset( $datetime['sec'] ))
4577
-      return ;
4576
+        return ;
4578 4577
     $output = null;
4579 4578
     // if( !isset( $datetime['day'] )) { $o=''; foreach($datetime as $k=>$v) {if(is_array($v)) $v=implode('-',$v);$o.=" $k=>$v";} echo " day SAKNAS : $o <br />\n"; }
4580 4579
     foreach( $datetime as $dkey => $dvalue ) {
4581
-      if( 'tz' != $dkey )
4580
+        if( 'tz' != $dkey )
4582 4581
         $datetime[$dkey] = (integer) $dvalue;
4583 4582
     }
4584 4583
     $output = date('Ymd', mktime( 0, 0, 0, $datetime['month'], $datetime['day'], $datetime['year']));
@@ -4586,101 +4585,101 @@  discard block
 block discarded – undo
4586 4585
         isset( $datetime['min'] )   ||
4587 4586
         isset( $datetime['sec'] )   ||
4588 4587
         isset( $datetime['tz'] )) {
4589
-      if( isset( $datetime['tz'] )  &&
4588
+        if( isset( $datetime['tz'] )  &&
4590 4589
          !isset( $datetime['hour'] ))
4591 4590
         $datetime['hour'] = 0;
4592
-      if( isset( $datetime['hour'] )  &&
4591
+        if( isset( $datetime['hour'] )  &&
4593 4592
          !isset( $datetime['min'] ))
4594 4593
         $datetime['min'] = 0;
4595
-      if( isset( $datetime['hour'] )  &&
4594
+        if( isset( $datetime['hour'] )  &&
4596 4595
           isset( $datetime['min'] )   &&
4597 4596
          !isset( $datetime['sec'] ))
4598 4597
         $datetime['sec'] = 0;
4599
-      $date = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']);
4600
-      $output .= date('\THis', $date );
4601
-      if( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) {
4598
+        $date = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']);
4599
+        $output .= date('\THis', $date );
4600
+        if( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) {
4602 4601
         $datetime['tz'] = trim( $datetime['tz'] );
4603 4602
         if( 'Z' == $datetime['tz'] )
4604
-          $output .= 'Z';
4603
+            $output .= 'Z';
4605 4604
         $offset = $this->_tz2offset( $datetime['tz'] );
4606 4605
         if( 0 != $offset ) {
4607
-          $date = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']);
4608
-          $output    = date( 'Ymd\THis\Z', $date );
4606
+            $date = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']);
4607
+            $output    = date( 'Ymd\THis\Z', $date );
4609 4608
         }
4610
-      }
4611
-      elseif( 7 == $parno )
4609
+        }
4610
+        elseif( 7 == $parno )
4612 4611
         $output .= 'Z';
4613 4612
     }
4614 4613
     return $output;
4615
-  }
4614
+    }
4616 4615
 /**
4617
- * creates formatted output for calendar component property data value type duration
4618
- *
4619
- * @author Kjell-Inge Gustafsson <[email protected]>
4620
- * @since 2.4.16 - 2008-10-10
4621
- * @param array $duration ( week, day, hour, min, sec )
4622
- * @return string
4623
- */
4624
-  function _format_duration( $duration ) {
4616
+     * creates formatted output for calendar component property data value type duration
4617
+     *
4618
+     * @author Kjell-Inge Gustafsson <[email protected]>
4619
+     * @since 2.4.16 - 2008-10-10
4620
+     * @param array $duration ( week, day, hour, min, sec )
4621
+     * @return string
4622
+     */
4623
+    function _format_duration( $duration ) {
4625 4624
     if( !isset( $duration['week'] ) &&
4626 4625
         !isset( $duration['day'] )  &&
4627 4626
         !isset( $duration['hour'] ) &&
4628 4627
         !isset( $duration['min'] )  &&
4629 4628
         !isset( $duration['sec'] ))
4630
-      return;
4629
+        return;
4631 4630
     $output = 'P';
4632 4631
     if( isset( $duration['week'] ) && ( 0 < $duration['week'] ))
4633
-      $output   .= $duration['week'].'W';
4632
+        $output   .= $duration['week'].'W';
4634 4633
     else {
4635
-      if( isset($duration['day'] ) && ( 0 < $duration['day'] ))
4634
+        if( isset($duration['day'] ) && ( 0 < $duration['day'] ))
4636 4635
         $output .= $duration['day'].'D';
4637
-      if(( isset( $duration['hour']) && ( 0 < $duration['hour'] )) ||
4636
+        if(( isset( $duration['hour']) && ( 0 < $duration['hour'] )) ||
4638 4637
          ( isset( $duration['min'])  && ( 0 < $duration['min'] ))  ||
4639 4638
          ( isset( $duration['sec'])  && ( 0 < $duration['sec'] ))) {
4640 4639
         $output .= 'T';
4641 4640
         $output .= ( isset( $duration['hour']) && ( 0 < $duration['hour'] )) ? $duration['hour'].'H' : '0H';
4642 4641
         $output .= ( isset( $duration['min'])  && ( 0 < $duration['min'] ))  ? $duration['min']. 'M' : '0M';
4643 4642
         $output .= ( isset( $duration['sec'])  && ( 0 < $duration['sec'] ))  ? $duration['sec']. 'S' : '0S';
4644
-      }
4643
+        }
4645 4644
     }
4646 4645
     return $output;
4647
-  }
4646
+    }
4648 4647
 /**
4649
- * creates formatted output for calendar component property data value type recur
4650
- *
4651
- * @author Kjell-Inge Gustafsson <[email protected]>
4652
- * @since 2.4.8 - 2008-10-22
4653
- * @param array $recurlabel
4654
- * @param array $recurdata
4655
- * @return string
4656
- */
4657
-  function _format_recur( $recurlabel, $recurdata ) {
4648
+     * creates formatted output for calendar component property data value type recur
4649
+     *
4650
+     * @author Kjell-Inge Gustafsson <[email protected]>
4651
+     * @since 2.4.8 - 2008-10-22
4652
+     * @param array $recurlabel
4653
+     * @param array $recurdata
4654
+     * @return string
4655
+     */
4656
+    function _format_recur( $recurlabel, $recurdata ) {
4658 4657
     $output = null;
4659 4658
     foreach( $recurdata as $therule ) {
4660
-      if( empty( $therule['value'] )) {
4659
+        if( empty( $therule['value'] )) {
4661 4660
         if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $recurlabel );
4662 4661
         continue;
4663
-      }
4664
-      $attributes = ( isset( $therule['params'] )) ? $this->_createParams( $therule['params'] ) : null;
4665
-      $content1  = $content2  = null;
4666
-      foreach( $therule['value'] as $rulelabel => $rulevalue ) {
4662
+        }
4663
+        $attributes = ( isset( $therule['params'] )) ? $this->_createParams( $therule['params'] ) : null;
4664
+        $content1  = $content2  = null;
4665
+        foreach( $therule['value'] as $rulelabel => $rulevalue ) {
4667 4666
         switch( $rulelabel ) {
4668
-          case 'FREQ': {
4667
+            case 'FREQ': {
4669 4668
             $content1 .= "FREQ=$rulevalue";
4670 4669
             break;
4671
-          }
4672
-          case 'UNTIL': {
4670
+            }
4671
+            case 'UNTIL': {
4673 4672
             $content2 .= ";UNTIL=";
4674 4673
             $content2 .= $this->_format_date_time( $rulevalue );
4675 4674
             break;
4676
-          }
4677
-          case 'COUNT':
4675
+            }
4676
+            case 'COUNT':
4678 4677
           case 'INTERVAL':
4679 4678
           case 'WKST': {
4680 4679
             $content2 .= ";$rulelabel=$rulevalue";
4681 4680
             break;
4682
-          }
4683
-          case 'BYSECOND':
4681
+            }
4682
+            case 'BYSECOND':
4684 4683
           case 'BYMINUTE':
4685 4684
           case 'BYHOUR':
4686 4685
           case 'BYMONTHDAY':
@@ -4690,144 +4689,144 @@  discard block
 block discarded – undo
4690 4689
           case 'BYSETPOS': {
4691 4690
             $content2 .= ";$rulelabel=";
4692 4691
             if( is_array( $rulevalue )) {
4693
-              foreach( $rulevalue as $vix => $valuePart ) {
4692
+                foreach( $rulevalue as $vix => $valuePart ) {
4694 4693
                 $content2 .= ( $vix ) ? ',' : null;
4695 4694
                 $content2 .= $valuePart;
4696
-              }
4695
+                }
4697 4696
             }
4698 4697
             else
4699
-             $content2 .= $rulevalue;
4698
+                $content2 .= $rulevalue;
4700 4699
             break;
4701
-          }
4702
-          case 'BYDAY': {
4700
+            }
4701
+            case 'BYDAY': {
4703 4702
             $content2 .= ";$rulelabel=";
4704 4703
             $bydaycnt = 0;
4705 4704
             foreach( $rulevalue as $vix => $valuePart ) {
4706
-              $content21 = $content22 = null;
4707
-              if( is_array( $valuePart )) {
4705
+                $content21 = $content22 = null;
4706
+                if( is_array( $valuePart )) {
4708 4707
                 $content2 .= ( $bydaycnt ) ? ',' : null;
4709 4708
                 foreach( $valuePart as $vix2 => $valuePart2 ) {
4710
-                  if( 'DAY' != strtoupper( $vix2 ))
4711
-                      $content21 .= $valuePart2;
4712
-                  else
4709
+                    if( 'DAY' != strtoupper( $vix2 ))
4710
+                        $content21 .= $valuePart2;
4711
+                    else
4713 4712
                     $content22 .= $valuePart2;
4714 4713
                 }
4715 4714
                 $content2 .= $content21.$content22;
4716 4715
                 $bydaycnt++;
4717
-              }
4718
-              else {
4716
+                }
4717
+                else {
4719 4718
                 $content2 .= ( $bydaycnt ) ? ',' : null;
4720 4719
                 if( 'DAY' != strtoupper( $vix ))
4721 4720
                     $content21 .= $valuePart;
4722 4721
                 else {
4723
-                  $content22 .= $valuePart;
4724
-                  $bydaycnt++;
4722
+                    $content22 .= $valuePart;
4723
+                    $bydaycnt++;
4725 4724
                 }
4726 4725
                 $content2 .= $content21.$content22;
4727
-              }
4726
+                }
4728 4727
             }
4729 4728
             break;
4730
-          }
4731
-          default: {
4729
+            }
4730
+            default: {
4732 4731
             $content2 .= ";$rulelabel=$rulevalue";
4733 4732
             break;
4734
-          }
4733
+            }
4734
+        }
4735 4735
         }
4736
-      }
4737
-      $output .= $this->_createElement( $recurlabel, $attributes, $content1.$content2 );
4736
+        $output .= $this->_createElement( $recurlabel, $attributes, $content1.$content2 );
4738 4737
     }
4739 4738
     return $output;
4740
-  }
4739
+    }
4741 4740
 /**
4742
- * create property name case - lower/upper
4743
- *
4744
- * @author Kjell-Inge Gustafsson <[email protected]>
4745
- * @since 0.9.7 - 2006-11-20
4746
- * @param string $propertyName
4747
- * @return string
4748
- */
4749
-  function _formatPropertyName( $propertyName ) {
4741
+     * create property name case - lower/upper
4742
+     *
4743
+     * @author Kjell-Inge Gustafsson <[email protected]>
4744
+     * @since 0.9.7 - 2006-11-20
4745
+     * @param string $propertyName
4746
+     * @return string
4747
+     */
4748
+    function _formatPropertyName( $propertyName ) {
4750 4749
     switch( $this->format ) {
4751
-      case 'xcal':
4750
+        case 'xcal':
4752 4751
         return strtolower( $propertyName );
4753 4752
         break;
4754
-      default:
4753
+        default:
4755 4754
         return strtoupper( $propertyName );
4756 4755
         break;
4757 4756
     }
4758
-  }
4757
+    }
4759 4758
 /**
4760
- * checks if input array contains a date
4761
- *
4762
- * @author Kjell-Inge Gustafsson <[email protected]>
4763
- * @since 2.4.16 - 2008-10-25
4764
- * @param array $input
4765
- * @return bool
4766
- */
4767
-  function _isArrayDate( $input ) {
4759
+     * checks if input array contains a date
4760
+     *
4761
+     * @author Kjell-Inge Gustafsson <[email protected]>
4762
+     * @since 2.4.16 - 2008-10-25
4763
+     * @param array $input
4764
+     * @return bool
4765
+     */
4766
+    function _isArrayDate( $input ) {
4768 4767
     if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 ))))
4769
-      return FALSE;
4768
+        return FALSE;
4770 4769
     if( 7 == count( $input ))
4771
-      return TRUE;
4770
+        return TRUE;
4772 4771
     if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] ))
4773
-      return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
4772
+        return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
4774 4773
     if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] ))
4775
-      return FALSE;
4774
+        return FALSE;
4776 4775
     if( in_array( 0, $input ))
4777
-      return FALSE;
4776
+        return FALSE;
4778 4777
     if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] ))
4779
-      return FALSE;
4778
+        return FALSE;
4780 4779
     if(( isset( $input[0] ) && isset( $input[1] ) && isset( $input[2] )) &&
4781 4780
          checkdate( (int) $input[1], (int) $input[2], (int) $input[0] ))
4782
-      return TRUE;
4781
+        return TRUE;
4783 4782
     $input = $this->_date_time_string( $input[1].'/'.$input[2].'/'.$input[0], 3 ); //  m - d - Y
4784 4783
     if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] ))
4785
-      return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
4784
+        return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
4786 4785
     return FALSE;
4787
-  }
4786
+    }
4788 4787
 /**
4789
- * checks if input array contains a timestamp date
4790
- *
4791
- * @author Kjell-Inge Gustafsson <[email protected]>
4792
- * @since 2.4.16 - 2008-10-18
4793
- * @param array $input
4794
- * @return bool
4795
- */
4796
-  function _isArrayTimestampDate( $input ) {
4788
+     * checks if input array contains a timestamp date
4789
+     *
4790
+     * @author Kjell-Inge Gustafsson <[email protected]>
4791
+     * @since 2.4.16 - 2008-10-18
4792
+     * @param array $input
4793
+     * @return bool
4794
+     */
4795
+    function _isArrayTimestampDate( $input ) {
4797 4796
     return ( is_array( $input ) && isset( $input['timestamp'] )) ? TRUE : FALSE ;
4798
-  }
4797
+    }
4799 4798
 /**
4800
- * controll if input string contains traling UTC offset
4801
- *
4802
- * @author Kjell-Inge Gustafsson <[email protected]>
4803
- * @since 2.4.16 - 2008-10-19
4804
- * @param string $input
4805
- * @return bool
4806
- */
4807
-  function _isOffset( $input ) {
4799
+     * controll if input string contains traling UTC offset
4800
+     *
4801
+     * @author Kjell-Inge Gustafsson <[email protected]>
4802
+     * @since 2.4.16 - 2008-10-19
4803
+     * @param string $input
4804
+     * @return bool
4805
+     */
4806
+    function _isOffset( $input ) {
4808 4807
     $input         = trim( (string) $input );
4809 4808
     if( 'Z' == substr( $input, -1 ))
4810
-      return TRUE;
4809
+        return TRUE;
4811 4810
     elseif((   5 <= strlen( $input )) &&
4812 4811
        ( in_array( substr( $input, -5, 1 ), array( '+', '-' ))) &&
4813 4812
        (   '0000'  < substr( $input, -4 )) && (   '9999' >= substr( $input, -4 )))
4814
-      return TRUE;
4813
+        return TRUE;
4815 4814
     elseif((    7 <= strlen( $input )) &&
4816 4815
        ( in_array( substr( $input, -7, 1 ), array( '+', '-' ))) &&
4817 4816
        ( '000000'  < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 )))
4818
-      return TRUE;
4817
+        return TRUE;
4819 4818
     return FALSE;
4820 4819
 
4821
-  }
4820
+    }
4822 4821
 /**
4823
- * check if property not exists within component
4824
- *
4825
- * @author Kjell-Inge Gustafsson <[email protected]>
4826
- * @since 2.5.1 - 2008-10-15
4827
- * @param string $propName
4828
- * @return bool
4829
- */
4830
-  function _notExistProp( $propName ) {
4822
+     * check if property not exists within component
4823
+     *
4824
+     * @author Kjell-Inge Gustafsson <[email protected]>
4825
+     * @since 2.5.1 - 2008-10-15
4826
+     * @param string $propName
4827
+     * @return bool
4828
+     */
4829
+    function _notExistProp( $propName ) {
4831 4830
     if( empty( $propName )) return FALSE; // when deleting x-prop, an empty propName may be used=allowed
4832 4831
     $propName = strtolower( $propName );
4833 4832
     if(     'last-modified'    == $propName )  { if( !isset( $this->lastmodified ))    return TRUE; }
@@ -4837,270 +4836,270 @@  discard block
 block discarded – undo
4837 4836
     elseif( 'request-status'   == $propName )  { if( !isset( $this->requeststatus ))   return TRUE; }
4838 4837
     elseif((       'x-' != substr($propName,0,2)) && !isset( $this->$propName ))       return TRUE;
4839 4838
     return FALSE;
4840
-  }
4839
+    }
4841 4840
 /**
4842
- * remakes a recur pattern to an array of dates
4843
- *
4844
- * if missing, UNTIL is set 1 year from startdate (emergency break)
4845
- *
4846
- * @author Kjell-Inge Gustafsson <[email protected]>
4847
- * @since 2.4.16 - 2008-10-18
4848
- * @param array $result, array to update, array([timestamp] => timestamp)
4849
- * @param array $recur, pattern for recurrency (only value part, params ignored)
4850
- * @param array $wdate, component start date
4851
- * @param array $startdate, start date
4852
- * @param array $enddate, optional
4853
- * @return array of recurrence (start-)dates as index
4854
- * @todo BYHOUR, BYMINUTE, BYSECOND, ev. BYSETPOS due to ambiguity, WEEKLY at year end/start
4855
- */
4856
-  function _recur2date( & $result, $recur, $wdate, $startdate, $enddate=FALSE ) {
4841
+     * remakes a recur pattern to an array of dates
4842
+     *
4843
+     * if missing, UNTIL is set 1 year from startdate (emergency break)
4844
+     *
4845
+     * @author Kjell-Inge Gustafsson <[email protected]>
4846
+     * @since 2.4.16 - 2008-10-18
4847
+     * @param array $result, array to update, array([timestamp] => timestamp)
4848
+     * @param array $recur, pattern for recurrency (only value part, params ignored)
4849
+     * @param array $wdate, component start date
4850
+     * @param array $startdate, start date
4851
+     * @param array $enddate, optional
4852
+     * @return array of recurrence (start-)dates as index
4853
+     * @todo BYHOUR, BYMINUTE, BYSECOND, ev. BYSETPOS due to ambiguity, WEEKLY at year end/start
4854
+     */
4855
+    function _recur2date( & $result, $recur, $wdate, $startdate, $enddate=FALSE ) {
4857 4856
     foreach( $wdate as $k => $v ) if( ctype_digit( $v )) $wdate[$k] = (int) $v;
4858 4857
     $wdatets     = $this->_date2timestamp( $wdate );
4859 4858
     $startdatets = $this->_date2timestamp( $startdate );
4860 4859
     if( !$enddate ) {
4861
-      $enddate = $startdate;
4862
-      $enddate['year'] += 1;
4860
+        $enddate = $startdate;
4861
+        $enddate['year'] += 1;
4863 4862
 // echo "recur __in_ ".implode('-',$startdate)." period start ".implode('-',$wdate)." period end ".implode('-',$enddate)."<br />\n";print_r($recur);echo "<br />\n";//test###
4864 4863
     }
4865 4864
     $endDatets = $this->_date2timestamp( $enddate ); // fix break
4866 4865
     if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] ))
4867
-      $recur['UNTIL'] = $enddate; // create break
4866
+        $recur['UNTIL'] = $enddate; // create break
4868 4867
     if( isset( $recur['UNTIL'] )) {
4869
-      $tdatets = $this->_date2timestamp( $recur['UNTIL'] );
4870
-      if( $endDatets > $tdatets ) {
4868
+        $tdatets = $this->_date2timestamp( $recur['UNTIL'] );
4869
+        if( $endDatets > $tdatets ) {
4871 4870
         $endDatets = $tdatets; // emergency break
4872 4871
         $enddate   = $this->_timestamp2date( $endDatets, 6 );
4873
-      }
4874
-      else
4872
+        }
4873
+        else
4875 4874
         $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 );
4876 4875
     }
4877 4876
     if( $wdatets > $endDatets ) {
4878
-     //echo "recur out of date ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test
4879
-      return array(); // nothing to do.. .
4877
+        //echo "recur out of date ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test
4878
+        return array(); // nothing to do.. .
4880 4879
     }
4881 4880
     if( !isset( $recur['FREQ'] )) // "MUST be specified.. ."
4882
-      $recur['FREQ'] = 'DAILY'; // ??
4881
+        $recur['FREQ'] = 'DAILY'; // ??
4883 4882
     $wkst = ( isset( $recur['WKST'] ) && ( 'SU' == $recur['WKST'] )) ? 24*60*60 : 0; // ??
4884 4883
     if( !isset( $recur['INTERVAL'] ))
4885
-      $recur['INTERVAL'] = 1;
4884
+        $recur['INTERVAL'] = 1;
4886 4885
     $countcnt = ( !isset( $recur['BYSETPOS'] )) ? 1 : 0; // DTSTART counts as the first occurrence
4887 4886
             /* find out how to step up dates and set index for interval count */
4888 4887
     $step = array();
4889 4888
     if( 'YEARLY' == $recur['FREQ'] )
4890
-      $step['year']  = 1;
4889
+        $step['year']  = 1;
4891 4890
     elseif( 'MONTHLY' == $recur['FREQ'] )
4892
-      $step['month'] = 1;
4891
+        $step['month'] = 1;
4893 4892
     elseif( 'WEEKLY' == $recur['FREQ'] )
4894
-      $step['day']   = 7;
4893
+        $step['day']   = 7;
4895 4894
     else
4896
-      $step['day']   = 1;
4895
+        $step['day']   = 1;
4897 4896
     if( isset( $step['year'] ) && isset( $recur['BYMONTH'] ))
4898
-      $step = array( 'month' => 1 );
4897
+        $step = array( 'month' => 1 );
4899 4898
     if( empty( $step ) && isset( $recur['BYWEEKNO'] )) // ??
4900
-      $step = array( 'day' => 7 );
4899
+        $step = array( 'day' => 7 );
4901 4900
     if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] ))
4902
-      $step = array( 'day' => 1 );
4901
+        $step = array( 'day' => 1 );
4903 4902
     $intervalarr = array();
4904 4903
     if( 1 < $recur['INTERVAL'] ) {
4905
-      $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst );
4906
-      $intervalarr = array( $intervalix => 0 );
4904
+        $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst );
4905
+        $intervalarr = array( $intervalix => 0 );
4907 4906
     }
4908 4907
     if( isset( $recur['BYSETPOS'] )) { // save start date + weekno
4909
-      $bysetposymd1 = $bysetposymd2 = $bysetposw1 = $bysetposw2 = array();
4910
-      $bysetposWold = (int) date( 'W', ( $wdatets + $wkst ));
4911
-      $bysetposYold = $wdate['year'];
4912
-      $bysetposMold = $wdate['month'];
4913
-      $bysetposDold = $wdate['day'];
4914
-      if( is_array( $recur['BYSETPOS'] )) {
4908
+        $bysetposymd1 = $bysetposymd2 = $bysetposw1 = $bysetposw2 = array();
4909
+        $bysetposWold = (int) date( 'W', ( $wdatets + $wkst ));
4910
+        $bysetposYold = $wdate['year'];
4911
+        $bysetposMold = $wdate['month'];
4912
+        $bysetposDold = $wdate['day'];
4913
+        if( is_array( $recur['BYSETPOS'] )) {
4915 4914
         foreach( $recur['BYSETPOS'] as $bix => $bval )
4916
-          $recur['BYSETPOS'][$bix] = (int) $bval;
4917
-      }
4918
-      else
4915
+            $recur['BYSETPOS'][$bix] = (int) $bval;
4916
+        }
4917
+        else
4919 4918
         $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] );
4920
-      $this->_stepdate( $enddate, $endDatets, $step); // make sure to count whole last period
4919
+        $this->_stepdate( $enddate, $endDatets, $step); // make sure to count whole last period
4921 4920
     }
4922 4921
     $this->_stepdate( $wdate, $wdatets, $step);
4923 4922
     $year_old     = null;
4924 4923
     $daynames     = array( 'SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA' );
4925
-             /* MAIN LOOP */
4926
-     // echo "recur start ".implode('-',$wdate)." end ".implode('-',$enddate)."<br />\n";//test
4924
+                /* MAIN LOOP */
4925
+        // echo "recur start ".implode('-',$wdate)." end ".implode('-',$enddate)."<br />\n";//test
4927 4926
     while( TRUE ) {
4928
-      if( isset( $endDatets ) && ( $wdatets > $endDatets ))
4927
+        if( isset( $endDatets ) && ( $wdatets > $endDatets ))
4929 4928
         break;
4930
-      if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] ))
4929
+        if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] ))
4931 4930
         break;
4932
-      if( $year_old != $wdate['year'] ) {
4931
+        if( $year_old != $wdate['year'] ) {
4933 4932
         $year_old   = $wdate['year'];
4934 4933
         $daycnts    = array();
4935 4934
         $yeardays   = $weekno = 0;
4936 4935
         $yeardaycnt = array();
4937 4936
         for( $m = 1; $m <= 12; $m++ ) { // count up and update up-counters
4938
-          $daycnts[$m] = array();
4939
-          $weekdaycnt = array();
4940
-          foreach( $daynames as $dn )
4937
+            $daycnts[$m] = array();
4938
+            $weekdaycnt = array();
4939
+            foreach( $daynames as $dn )
4941 4940
             $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0;
4942
-          $mcnt     = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] ));
4943
-          for( $d   = 1; $d <= $mcnt; $d++ ) {
4941
+            $mcnt     = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] ));
4942
+            for( $d   = 1; $d <= $mcnt; $d++ ) {
4944 4943
             $daycnts[$m][$d] = array();
4945 4944
             if( isset( $recur['BYYEARDAY'] )) {
4946
-              $yeardays++;
4947
-              $daycnts[$m][$d]['yearcnt_up'] = $yeardays;
4945
+                $yeardays++;
4946
+                $daycnts[$m][$d]['yearcnt_up'] = $yeardays;
4948 4947
             }
4949 4948
             if( isset( $recur['BYDAY'] )) {
4950
-              $day    = date( 'w', mktime( 0, 0, 0, $m, $d, $wdate['year'] ));
4951
-              $day    = $daynames[$day];
4952
-              $daycnts[$m][$d]['DAY'] = $day;
4953
-              $weekdaycnt[$day]++;
4954
-              $daycnts[$m][$d]['monthdayno_up'] = $weekdaycnt[$day];
4955
-              $yeardaycnt[$day]++;
4956
-              $daycnts[$m][$d]['yeardayno_up'] = $yeardaycnt[$day];
4949
+                $day    = date( 'w', mktime( 0, 0, 0, $m, $d, $wdate['year'] ));
4950
+                $day    = $daynames[$day];
4951
+                $daycnts[$m][$d]['DAY'] = $day;
4952
+                $weekdaycnt[$day]++;
4953
+                $daycnts[$m][$d]['monthdayno_up'] = $weekdaycnt[$day];
4954
+                $yeardaycnt[$day]++;
4955
+                $daycnts[$m][$d]['yeardayno_up'] = $yeardaycnt[$day];
4957 4956
             }
4958 4957
             if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' ))
4959
-              $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year']));
4960
-          }
4958
+                $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year']));
4959
+            }
4961 4960
         }
4962 4961
         $daycnt = 0;
4963 4962
         $yeardaycnt = array();
4964 4963
         if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) {
4965
-          $weekno = null;
4966
-          for( $d=31; $d > 25; $d-- ) { // get last weekno for year
4964
+            $weekno = null;
4965
+            for( $d=31; $d > 25; $d-- ) { // get last weekno for year
4967 4966
             if( !$weekno )
4968
-              $weekno = $daycnts[12][$d]['weekno_up'];
4967
+                $weekno = $daycnts[12][$d]['weekno_up'];
4969 4968
             elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) {
4970
-              $weekno = $daycnts[12][$d]['weekno_up'];
4971
-              break;
4969
+                $weekno = $daycnts[12][$d]['weekno_up'];
4970
+                break;
4971
+            }
4972 4972
             }
4973
-          }
4974 4973
         }
4975 4974
         for( $m = 12; $m > 0; $m-- ) { // count down and update down-counters
4976
-          $weekdaycnt = array();
4977
-          foreach( $daynames as $dn )
4975
+            $weekdaycnt = array();
4976
+            foreach( $daynames as $dn )
4978 4977
             $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0;
4979
-          $monthcnt = 0;
4980
-          $mcnt     = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] ));
4981
-          for( $d   = $mcnt; $d > 0; $d-- ) {
4978
+            $monthcnt = 0;
4979
+            $mcnt     = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] ));
4980
+            for( $d   = $mcnt; $d > 0; $d-- ) {
4982 4981
             if( isset( $recur['BYYEARDAY'] )) {
4983
-              $daycnt -= 1;
4984
-              $daycnts[$m][$d]['yearcnt_down'] = $daycnt;
4982
+                $daycnt -= 1;
4983
+                $daycnts[$m][$d]['yearcnt_down'] = $daycnt;
4985 4984
             }
4986 4985
             if( isset( $recur['BYMONTHDAY'] )) {
4987
-              $monthcnt -= 1;
4988
-              $daycnts[$m][$d]['monthcnt_down'] = $monthcnt;
4986
+                $monthcnt -= 1;
4987
+                $daycnts[$m][$d]['monthcnt_down'] = $monthcnt;
4989 4988
             }
4990 4989
             if( isset( $recur['BYDAY'] )) {
4991
-              $day  = $daycnts[$m][$d]['DAY'];
4992
-              $weekdaycnt[$day] -= 1;
4993
-              $daycnts[$m][$d]['monthdayno_down'] = $weekdaycnt[$day];
4994
-              $yeardaycnt[$day] -= 1;
4995
-              $daycnts[$m][$d]['yeardayno_down'] = $yeardaycnt[$day];
4990
+                $day  = $daycnts[$m][$d]['DAY'];
4991
+                $weekdaycnt[$day] -= 1;
4992
+                $daycnts[$m][$d]['monthdayno_down'] = $weekdaycnt[$day];
4993
+                $yeardaycnt[$day] -= 1;
4994
+                $daycnts[$m][$d]['yeardayno_down'] = $yeardaycnt[$day];
4996 4995
             }
4997 4996
             if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' ))
4998
-              $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1);
4999
-          }
4997
+                $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1);
4998
+            }
4999
+        }
5000 5000
         }
5001
-      }
5002 5001
             /* check interval */
5003
-      if( 1 < $recur['INTERVAL'] ) {
5002
+        if( 1 < $recur['INTERVAL'] ) {
5004 5003
             /* create interval index */
5005 5004
         $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst );
5006 5005
             /* check interval */
5007 5006
         $currentKey = array_keys( $intervalarr );
5008 5007
         $currentKey = end( $currentKey ); // get last index
5009 5008
         if( $currentKey != $intervalix )
5010
-          $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 ));
5009
+            $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 ));
5011 5010
         if(( $recur['INTERVAL'] != $intervalarr[$intervalix] ) &&
5012 5011
            ( 0 != $intervalarr[$intervalix] )) {
5013 5012
             /* step up date */
5014 5013
     //echo "skip: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test
5015
-          $this->_stepdate( $wdate, $wdatets, $step);
5016
-          continue;
5014
+            $this->_stepdate( $wdate, $wdatets, $step);
5015
+            continue;
5017 5016
         }
5018 5017
         else // continue within the selected interval
5019
-          $intervalarr[$intervalix] = 0;
5020
-   //echo "cont: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test
5021
-      }
5022
-      $updateOK = TRUE;
5023
-      if( $updateOK && isset( $recur['BYMONTH'] ))
5018
+            $intervalarr[$intervalix] = 0;
5019
+    //echo "cont: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test
5020
+        }
5021
+        $updateOK = TRUE;
5022
+        if( $updateOK && isset( $recur['BYMONTH'] ))
5024 5023
         $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH']
5025
-                                           , $wdate['month']
5026
-                                           ,($wdate['month'] - 13));
5027
-      if( $updateOK && isset( $recur['BYWEEKNO'] ))
5024
+                                            , $wdate['month']
5025
+                                            ,($wdate['month'] - 13));
5026
+        if( $updateOK && isset( $recur['BYWEEKNO'] ))
5028 5027
         $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO']
5029
-                                           , $daycnts[$wdate['month']][$wdate['day']]['weekno_up']
5030
-                                           , $daycnts[$wdate['month']][$wdate['day']]['weekno_down'] );
5031
-      if( $updateOK && isset( $recur['BYYEARDAY'] ))
5028
+                                            , $daycnts[$wdate['month']][$wdate['day']]['weekno_up']
5029
+                                            , $daycnts[$wdate['month']][$wdate['day']]['weekno_down'] );
5030
+        if( $updateOK && isset( $recur['BYYEARDAY'] ))
5032 5031
         $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY']
5033
-                                           , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_up']
5034
-                                           , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down'] );
5035
-      if( $updateOK && isset( $recur['BYMONTHDAY'] ))
5032
+                                            , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_up']
5033
+                                            , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down'] );
5034
+        if( $updateOK && isset( $recur['BYMONTHDAY'] ))
5036 5035
         $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY']
5037
-                                           , $wdate['day']
5038
-                                           , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down'] );
5036
+                                            , $wdate['day']
5037
+                                            , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down'] );
5039 5038
     //echo "efter BYMONTHDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n";//test###
5040
-      if( $updateOK && isset( $recur['BYDAY'] )) {
5039
+        if( $updateOK && isset( $recur['BYDAY'] )) {
5041 5040
         $updateOK = FALSE;
5042 5041
         $m = $wdate['month'];
5043 5042
         $d = $wdate['day'];
5044 5043
         if( isset( $recur['BYDAY']['DAY'] )) { // single day, opt with year/month day order no
5045
-          $daynoexists = $daynosw = $daynamesw =  FALSE;
5046
-          if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] )
5044
+            $daynoexists = $daynosw = $daynamesw =  FALSE;
5045
+            if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] )
5047 5046
             $daynamesw = TRUE;
5048
-          if( isset( $recur['BYDAY'][0] )) {
5047
+            if( isset( $recur['BYDAY'][0] )) {
5049 5048
             $daynoexists = TRUE;
5050 5049
             if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] ))
5051
-              $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5050
+                $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5052 5051
                                                 , $daycnts[$m][$d]['monthdayno_up']
5053 5052
                                                 , $daycnts[$m][$d]['monthdayno_down'] );
5054 5053
             elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' ))
5055
-              $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5054
+                $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5056 5055
                                                 , $daycnts[$m][$d]['yeardayno_up']
5057 5056
                                                 , $daycnts[$m][$d]['yeardayno_down'] );
5058
-          }
5059
-          if((  $daynoexists &&  $daynosw && $daynamesw ) ||
5057
+            }
5058
+            if((  $daynoexists &&  $daynosw && $daynamesw ) ||
5060 5059
              ( !$daynoexists && !$daynosw && $daynamesw )) {
5061 5060
             $updateOK = TRUE;
5062
-          }
5061
+            }
5063 5062
         //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ###
5064 5063
         }
5065 5064
         else {
5066
-          foreach( $recur['BYDAY'] as $bydayvalue ) {
5065
+            foreach( $recur['BYDAY'] as $bydayvalue ) {
5067 5066
             $daynoexists = $daynosw = $daynamesw = FALSE;
5068 5067
             if( isset( $bydayvalue['DAY'] ) &&
5069 5068
                      ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] ))
5070
-              $daynamesw = TRUE;
5069
+                $daynamesw = TRUE;
5071 5070
             if( isset( $bydayvalue[0] )) {
5072
-              $daynoexists = TRUE;
5073
-              if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) ||
5071
+                $daynoexists = TRUE;
5072
+                if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) ||
5074 5073
                    isset( $recur['BYMONTH'] ))
5075 5074
                 $daynosw = $this->_recurBYcntcheck( $bydayvalue['0']
5076
-                                                  , $daycnts[$m][$d]['monthdayno_up']
5077
-                                                  , $daycnts[$m][$d]['monthdayno_down'] );
5078
-              elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' ))
5075
+                                                    , $daycnts[$m][$d]['monthdayno_up']
5076
+                                                    , $daycnts[$m][$d]['monthdayno_down'] );
5077
+                elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' ))
5079 5078
                 $daynosw = $this->_recurBYcntcheck( $bydayvalue['0']
5080
-                                                  , $daycnts[$m][$d]['yeardayno_up']
5081
-                                                  , $daycnts[$m][$d]['yeardayno_down'] );
5079
+                                                    , $daycnts[$m][$d]['yeardayno_up']
5080
+                                                    , $daycnts[$m][$d]['yeardayno_down'] );
5082 5081
             }
5083 5082
         //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ###
5084 5083
             if((  $daynoexists &&  $daynosw && $daynamesw ) ||
5085 5084
                ( !$daynoexists && !$daynosw && $daynamesw )) {
5086
-              $updateOK = TRUE;
5087
-              break;
5085
+                $updateOK = TRUE;
5086
+                break;
5088 5087
             }
5089
-          }
5088
+            }
5089
+        }
5090 5090
         }
5091
-      }
5092
-      //echo "efter BYDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n"; // test ###
5091
+        //echo "efter BYDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n"; // test ###
5093 5092
             /* check BYSETPOS */
5094
-      if( $updateOK ) {
5093
+        if( $updateOK ) {
5095 5094
         if( isset( $recur['BYSETPOS'] ) &&
5096 5095
           ( in_array( $recur['FREQ'], array( 'YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY' )))) {
5097
-          if( isset( $recur['WEEKLY'] )) {
5096
+            if( isset( $recur['WEEKLY'] )) {
5098 5097
             if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] )
5099
-              $bysetposw1[] = $wdatets;
5098
+                $bysetposw1[] = $wdatets;
5100 5099
             else
5101
-              $bysetposw2[] = $wdatets;
5102
-          }
5103
-          else {
5100
+                $bysetposw2[] = $wdatets;
5101
+            }
5102
+            else {
5104 5103
             if(( isset( $recur['FREQ'] ) && ( 'YEARLY'      == $recur['FREQ'] )  &&
5105 5104
                                             ( $bysetposYold == $wdate['year'] ))   ||
5106 5105
                ( isset( $recur['FREQ'] ) && ( 'MONTHLY'     == $recur['FREQ'] )  &&
@@ -5110,438 +5109,438 @@  discard block
 block discarded – undo
5110 5109
                                            (( $bysetposYold == $wdate['year'] )  &&
5111 5110
                                             ( $bysetposMold == $wdate['month'])  &&
5112 5111
                                             ( $bysetposDold == $wdate['sday'] ))))
5113
-              $bysetposymd1[] = $wdatets;
5112
+                $bysetposymd1[] = $wdatets;
5114 5113
             else
5115
-              $bysetposymd2[] = $wdatets;
5116
-          }
5114
+                $bysetposymd2[] = $wdatets;
5115
+            }
5117 5116
         }
5118 5117
         else {
5119 5118
             /* update result array if BYSETPOS is set */
5120
-          $countcnt++;
5121
-          if( $startdatets <= $wdatets ) { // only output within period
5119
+            $countcnt++;
5120
+            if( $startdatets <= $wdatets ) { // only output within period
5122 5121
             $result[$wdatets] = TRUE;
5123
-          //echo "recur ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test
5124
-          }
5125
-         //else echo "recur undate ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))." okdatstart ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$startdatets),6))."<br />\n";//test
5126
-          $updateOK = FALSE;
5122
+            //echo "recur ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test
5123
+            }
5124
+            //else echo "recur undate ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))." okdatstart ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$startdatets),6))."<br />\n";//test
5125
+            $updateOK = FALSE;
5126
+        }
5127 5127
         }
5128
-      }
5129 5128
             /* step up date */
5130
-      $this->_stepdate( $wdate, $wdatets, $step);
5129
+        $this->_stepdate( $wdate, $wdatets, $step);
5131 5130
             /* check if BYSETPOS is set for updating result array */
5132
-      if( $updateOK && isset( $recur['BYSETPOS'] )) {
5131
+        if( $updateOK && isset( $recur['BYSETPOS'] )) {
5133 5132
         $bysetpos       = FALSE;
5134 5133
         if( isset( $recur['FREQ'] ) && ( 'YEARLY'  == $recur['FREQ'] ) &&
5135 5134
           ( $bysetposYold != $wdate['year'] )) {
5136
-          $bysetpos     = TRUE;
5137
-          $bysetposYold = $wdate['year'];
5135
+            $bysetpos     = TRUE;
5136
+            $bysetposYold = $wdate['year'];
5138 5137
         }
5139 5138
         elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] &&
5140 5139
          (( $bysetposYold != $wdate['year'] ) || ( $bysetposMold != $wdate['month'] )))) {
5141
-          $bysetpos     = TRUE;
5142
-          $bysetposYold = $wdate['year'];
5143
-          $bysetposMold = $wdate['month'];
5140
+            $bysetpos     = TRUE;
5141
+            $bysetposYold = $wdate['year'];
5142
+            $bysetposMold = $wdate['month'];
5144 5143
         }
5145 5144
         elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY'  == $recur['FREQ'] )) {
5146
-          $weekno = (int) date( 'W', mktime( 0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year']));
5147
-          if( $bysetposWold != $weekno ) {
5145
+            $weekno = (int) date( 'W', mktime( 0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year']));
5146
+            if( $bysetposWold != $weekno ) {
5148 5147
             $bysetposWold = $weekno;
5149 5148
             $bysetpos     = TRUE;
5150
-          }
5149
+            }
5151 5150
         }
5152 5151
         elseif( isset( $recur['FREQ'] ) && ( 'DAILY'   == $recur['FREQ'] ) &&
5153 5152
          (( $bysetposYold != $wdate['year'] )  ||
5154 5153
           ( $bysetposMold != $wdate['month'] ) ||
5155 5154
           ( $bysetposDold != $wdate['sday'] ))) {
5156
-          $bysetpos     = TRUE;
5157
-          $bysetposYold = $wdate['year'];
5158
-          $bysetposMold = $wdate['month'];
5159
-          $bysetposDold = $wdate['day'];
5155
+            $bysetpos     = TRUE;
5156
+            $bysetposYold = $wdate['year'];
5157
+            $bysetposMold = $wdate['month'];
5158
+            $bysetposDold = $wdate['day'];
5160 5159
         }
5161 5160
         if( $bysetpos ) {
5162
-          if( isset( $recur['BYWEEKNO'] )) {
5161
+            if( isset( $recur['BYWEEKNO'] )) {
5163 5162
             $bysetposarr1 = & $bysetposw1;
5164 5163
             $bysetposarr2 = & $bysetposw2;
5165
-          }
5166
-          else {
5164
+            }
5165
+            else {
5167 5166
             $bysetposarr1 = & $bysetposymd1;
5168 5167
             $bysetposarr2 = & $bysetposymd2;
5169
-          }
5170
-          foreach( $recur['BYSETPOS'] as $ix ) {
5168
+            }
5169
+            foreach( $recur['BYSETPOS'] as $ix ) {
5171 5170
             if( 0 > $ix ) // both positive and negative BYSETPOS allowed
5172
-              $ix = ( count( $bysetposarr1 ) + $ix + 1);
5171
+                $ix = ( count( $bysetposarr1 ) + $ix + 1);
5173 5172
             $ix--;
5174 5173
             if( isset( $bysetposarr1[$ix] )) {
5175
-              if( $startdatets <= $bysetposarr1[$ix] ) { // only output within period
5174
+                if( $startdatets <= $bysetposarr1[$ix] ) { // only output within period
5176 5175
                 $result[$bysetposarr1[$ix]] = TRUE;
5177
-       //echo "recur ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$bysetposarr1[$ix]),6))."<br />\n";//test
5178
-              }
5179
-              $countcnt++;
5176
+        //echo "recur ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$bysetposarr1[$ix]),6))."<br />\n";//test
5177
+                }
5178
+                $countcnt++;
5180 5179
             }
5181 5180
             if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] ))
5182
-              break;
5183
-          }
5184
-          $bysetposarr1 = $bysetposarr2;
5185
-          $bysetposarr2 = array();
5181
+                break;
5182
+            }
5183
+            $bysetposarr1 = $bysetposarr2;
5184
+            $bysetposarr2 = array();
5185
+        }
5186 5186
         }
5187
-      }
5188 5187
     }
5189
-  }
5190
-  function _recurBYcntcheck( $BYvalue, $upValue, $downValue ) {
5188
+    }
5189
+    function _recurBYcntcheck( $BYvalue, $upValue, $downValue ) {
5191 5190
     if( is_array( $BYvalue ) &&
5192 5191
       ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue )))
5193
-      return TRUE;
5192
+        return TRUE;
5194 5193
     elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue ))
5195
-      return TRUE;
5194
+        return TRUE;
5196 5195
     else
5197
-      return FALSE;
5198
-  }
5199
-  function _recurIntervalIx( $freq, $date, $wkst ) {
5196
+        return FALSE;
5197
+    }
5198
+    function _recurIntervalIx( $freq, $date, $wkst ) {
5200 5199
             /* create interval index */
5201 5200
     switch( $freq ) {
5202
-      case 'YEARLY':
5201
+        case 'YEARLY':
5203 5202
         $intervalix = $date['year'];
5204 5203
         break;
5205
-      case 'MONTHLY':
5204
+        case 'MONTHLY':
5206 5205
         $intervalix = $date['year'].'-'.$date['month'];
5207 5206
         break;
5208
-      case 'WEEKLY':
5207
+        case 'WEEKLY':
5209 5208
         $wdatets    = $this->_date2timestamp( $date );
5210 5209
         $intervalix = (int) date( 'W', ( $wdatets + $wkst ));
5211
-       break;
5212
-      case 'DAILY':
5210
+        break;
5211
+        case 'DAILY':
5213 5212
            default:
5214 5213
         $intervalix = $date['year'].'-'.$date['month'].'-'.$date['day'];
5215 5214
         break;
5216 5215
     }
5217 5216
     return $intervalix;
5218
-  }
5217
+    }
5219 5218
 /**
5220
- * convert input format for exrule and rrule to internal format
5221
- *
5222
- * @author Kjell-Inge Gustafsson <[email protected]>
5223
- * @since 2.4.16 - 2008-10-19
5224
- * @param array $rexrule
5225
- * @return array
5226
- */
5227
-  function _setRexrule( $rexrule ) {
5219
+     * convert input format for exrule and rrule to internal format
5220
+     *
5221
+     * @author Kjell-Inge Gustafsson <[email protected]>
5222
+     * @since 2.4.16 - 2008-10-19
5223
+     * @param array $rexrule
5224
+     * @return array
5225
+     */
5226
+    function _setRexrule( $rexrule ) {
5228 5227
     $input          = array();
5229 5228
     if( empty( $rexrule ))
5230
-      return $input;
5229
+        return $input;
5231 5230
     foreach( $rexrule as $rexrulelabel => $rexrulevalue ) {
5232
-      $rexrulelabel = strtoupper( $rexrulelabel );
5233
-      if( 'UNTIL'  != $rexrulelabel )
5231
+        $rexrulelabel = strtoupper( $rexrulelabel );
5232
+        if( 'UNTIL'  != $rexrulelabel )
5234 5233
         $input[$rexrulelabel]   = $rexrulevalue;
5235
-      else {
5234
+        else {
5236 5235
         if( $this->_isArrayTimestampDate( $rexrulevalue )) // timestamp date
5237
-          $input[$rexrulelabel] = $this->_timestamp2date( $rexrulevalue, 6 );
5236
+            $input[$rexrulelabel] = $this->_timestamp2date( $rexrulevalue, 6 );
5238 5237
         elseif( $this->_isArrayDate( $rexrulevalue )) // date-time
5239
-          $input[$rexrulelabel] = $this->_date_time_array( $rexrulevalue, 6 );
5238
+            $input[$rexrulelabel] = $this->_date_time_array( $rexrulevalue, 6 );
5240 5239
         elseif( 8 <= strlen( trim( $rexrulevalue ))) // ex. 2006-08-03 10:12:18
5241
-          $input[$rexrulelabel] = $this->_date_time_string( $rexrulevalue );
5240
+            $input[$rexrulelabel] = $this->_date_time_string( $rexrulevalue );
5242 5241
         if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] ))
5243
-          $input[$rexrulelabel]['tz'] = 'Z';
5244
-      }
5242
+            $input[$rexrulelabel]['tz'] = 'Z';
5243
+        }
5245 5244
     }
5246 5245
     return $input;
5247
-  }
5246
+    }
5248 5247
 /**
5249
- * convert format for input date to internal date with parameters
5250
- *
5251
- * @author Kjell-Inge Gustafsson <[email protected]>
5252
- * @since 2.4.17 - 2008-10-31
5253
- * @param mixed $year
5254
- * @param mixed $month optional
5255
- * @param int $day optional
5256
- * @param int $hour optional
5257
- * @param int $min optional
5258
- * @param int $sec optional
5259
- * @param array $params optional
5260
- * @param string $caller optional
5261
- * @return array
5262
- */
5263
-  function _setDate( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE, $caller=null ) {
5248
+     * convert format for input date to internal date with parameters
5249
+     *
5250
+     * @author Kjell-Inge Gustafsson <[email protected]>
5251
+     * @since 2.4.17 - 2008-10-31
5252
+     * @param mixed $year
5253
+     * @param mixed $month optional
5254
+     * @param int $day optional
5255
+     * @param int $hour optional
5256
+     * @param int $min optional
5257
+     * @param int $sec optional
5258
+     * @param array $params optional
5259
+     * @param string $caller optional
5260
+     * @return array
5261
+     */
5262
+    function _setDate( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE, $caller=null ) {
5264 5263
     $input = $parno = null;
5265 5264
     $localtime = (( 'dtstart' == $caller ) && in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE;
5266 5265
     if( $this->_isArrayDate( $year )) {
5267
-      if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5268
-      $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5269
-      if( isset( $input['params']['TZID'] )) {
5266
+        if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5267
+        $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5268
+        if( isset( $input['params']['TZID'] )) {
5270 5269
         $input['params']['VALUE'] = 'DATE-TIME';
5271 5270
         unset( $year['tz'] );
5272
-      }
5273
-      $hitval          = (( !empty( $year['tz'] ) || !empty( $year[6] ))) ? 7 : 6;
5274
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval );
5275
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, count( $year ), $parno );
5276
-      $input['value']  = $this->_date_time_array( $year, $parno );
5271
+        }
5272
+        $hitval          = (( !empty( $year['tz'] ) || !empty( $year[6] ))) ? 7 : 6;
5273
+        $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval );
5274
+        $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, count( $year ), $parno );
5275
+        $input['value']  = $this->_date_time_array( $year, $parno );
5277 5276
     }
5278 5277
     elseif( $this->_isArrayTimestampDate( $year )) {
5279
-      if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5280
-      $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5281
-      if( isset( $input['params']['TZID'] )) {
5278
+        if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5279
+        $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5280
+        if( isset( $input['params']['TZID'] )) {
5282 5281
         $input['params']['VALUE'] = 'DATE-TIME';
5283 5282
         unset( $year['tz'] );
5284
-      }
5285
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3 );
5286
-      $hitval          = ( isset( $year['tz'] )) ? 7 : 6;
5287
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno );
5288
-      $input['value']  = $this->_timestamp2date( $year, $parno );
5283
+        }
5284
+        $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3 );
5285
+        $hitval          = ( isset( $year['tz'] )) ? 7 : 6;
5286
+        $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno );
5287
+        $input['value']  = $this->_timestamp2date( $year, $parno );
5289 5288
     }
5290 5289
     elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18
5291
-      if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5292
-      $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5293
-      if( isset( $input['params']['TZID'] )) {
5290
+        if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5291
+        $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5292
+        if( isset( $input['params']['TZID'] )) {
5294 5293
         $input['params']['VALUE'] = 'DATE-TIME';
5295 5294
         $parno = 6;
5296
-      }
5297
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7, $parno );
5298
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, $parno, $parno );
5299
-      $input['value']  = $this->_date_time_string( $year, $parno );
5295
+        }
5296
+        $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7, $parno );
5297
+        $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, $parno, $parno );
5298
+        $input['value']  = $this->_date_time_string( $year, $parno );
5300 5299
     }
5301 5300
     else {
5302
-      if( is_array( $params )) {
5301
+        if( is_array( $params )) {
5303 5302
         if( $localtime ) unset ( $params['VALUE'], $params['TZID'] );
5304 5303
         $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ));
5305
-      }
5306
-      elseif( is_array( $tz )) {
5304
+        }
5305
+        elseif( is_array( $tz )) {
5307 5306
         $input['params'] = $this->_setParams( $tz,     array( 'VALUE' => 'DATE-TIME' ));
5308 5307
         $tz = FALSE;
5309
-      }
5310
-      elseif( is_array( $hour )) {
5308
+        }
5309
+        elseif( is_array( $hour )) {
5311 5310
         $input['params'] = $this->_setParams( $hour,   array( 'VALUE' => 'DATE-TIME' ));
5312 5311
         $hour = $min = $sec = $tz = FALSE;
5313
-      }
5314
-      if( isset( $input['params']['TZID'] )) {
5312
+        }
5313
+        if( isset( $input['params']['TZID'] )) {
5315 5314
         $tz            = null;
5316 5315
         $input['params']['VALUE'] = 'DATE-TIME';
5317
-      }
5318
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3 );
5319
-      $hitval          = ( !empty( $tz )) ? 7 : 6;
5320
-      $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno, $parno );
5321
-      $input['value']  = array( 'year'  => $year, 'month' => $month, 'day'   => $day );
5322
-      if( 3 != $parno ) {
5316
+        }
5317
+        $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3 );
5318
+        $hitval          = ( !empty( $tz )) ? 7 : 6;
5319
+        $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno, $parno );
5320
+        $input['value']  = array( 'year'  => $year, 'month' => $month, 'day'   => $day );
5321
+        if( 3 != $parno ) {
5323 5322
         $input['value']['hour'] = ( $hour ) ? $hour : '0';
5324 5323
         $input['value']['min']  = ( $min )  ? $min  : '0';
5325 5324
         $input['value']['sec']  = ( $sec )  ? $sec  : '0';
5326 5325
         if( !empty( $tz ))
5327
-          $input['value']['tz'] = $tz;
5328
-      }
5326
+            $input['value']['tz'] = $tz;
5327
+        }
5329 5328
     }
5330 5329
     if( 3 == $parno ) {
5331
-      $input['params']['VALUE'] = 'DATE';
5332
-      unset( $input['value']['tz'] );
5333
-      unset( $input['params']['TZID'] );
5330
+        $input['params']['VALUE'] = 'DATE';
5331
+        unset( $input['value']['tz'] );
5332
+        unset( $input['params']['TZID'] );
5334 5333
     }
5335 5334
     elseif( isset( $input['params']['TZID'] ))
5336
-      unset( $input['value']['tz'] );
5335
+        unset( $input['value']['tz'] );
5337 5336
     if( $localtime ) unset( $input['value']['tz'], $input['params']['TZID'] );
5338 5337
     if( isset( $input['value']['tz'] ))
5339
-      $input['value']['tz'] = (string) $input['value']['tz'];
5338
+        $input['value']['tz'] = (string) $input['value']['tz'];
5340 5339
     if( !empty( $input['value']['tz'] ) && ( 'Z' != $input['value']['tz'] ) &&
5341 5340
       ( !$this->_isOffset( $input['value']['tz'] )))
5342
-      $input['params']['TZID'] = $input['value']['tz'];
5341
+        $input['params']['TZID'] = $input['value']['tz'];
5343 5342
     return $input;
5344
-  }
5343
+    }
5345 5344
 /**
5346
- * convert format for input date (UTC) to internal date with parameters
5347
- *
5348
- * @author Kjell-Inge Gustafsson <[email protected]>
5349
- * @since 2.4.17 - 2008-10-31
5350
- * @param mixed $year
5351
- * @param mixed $month optional
5352
- * @param int $day optional
5353
- * @param int $hour optional
5354
- * @param int $min optional
5355
- * @param int $sec optional
5356
- * @param array $params optional
5357
- * @return array
5358
- */
5359
-  function _setDate2( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
5345
+     * convert format for input date (UTC) to internal date with parameters
5346
+     *
5347
+     * @author Kjell-Inge Gustafsson <[email protected]>
5348
+     * @since 2.4.17 - 2008-10-31
5349
+     * @param mixed $year
5350
+     * @param mixed $month optional
5351
+     * @param int $day optional
5352
+     * @param int $hour optional
5353
+     * @param int $min optional
5354
+     * @param int $sec optional
5355
+     * @param array $params optional
5356
+     * @return array
5357
+     */
5358
+    function _setDate2( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
5360 5359
     $input = null;
5361 5360
     if( $this->_isArrayDate( $year )) {
5362
-      $input['value']  = $this->_date_time_array( $year, 7 );
5363
-      $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5361
+        $input['value']  = $this->_date_time_array( $year, 7 );
5362
+        $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5364 5363
     }
5365 5364
     elseif( $this->_isArrayTimestampDate( $year )) {
5366
-      $input['value']  = $this->_timestamp2date( $year, 7 );
5367
-      $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5365
+        $input['value']  = $this->_timestamp2date( $year, 7 );
5366
+        $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5368 5367
     }
5369 5368
     elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18
5370
-      $input['value']  = $this->_date_time_string( $year, 7 );
5371
-      $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5369
+        $input['value']  = $this->_date_time_string( $year, 7 );
5370
+        $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5372 5371
     }
5373 5372
     else {
5374
-      $input['value']  = array( 'year'  => $year
5375
-                              , 'month' => $month
5376
-                              , 'day'   => $day
5377
-                              , 'hour'  => $hour
5378
-                              , 'min'   => $min
5379
-                              , 'sec'   => $sec );
5380
-      $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ));
5373
+        $input['value']  = array( 'year'  => $year
5374
+                                , 'month' => $month
5375
+                                , 'day'   => $day
5376
+                                , 'hour'  => $hour
5377
+                                , 'min'   => $min
5378
+                                , 'sec'   => $sec );
5379
+        $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ));
5381 5380
     }
5382 5381
     $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7 ); // remove default
5383 5382
     if( !isset( $input['value']['hour'] ))
5384
-      $input['value']['hour'] = 0;
5383
+        $input['value']['hour'] = 0;
5385 5384
     if( !isset( $input['value']['min'] ))
5386
-      $input['value']['min'] = 0;
5385
+        $input['value']['min'] = 0;
5387 5386
     if( !isset( $input['value']['sec'] ))
5388
-      $input['value']['sec'] = 0;
5387
+        $input['value']['sec'] = 0;
5389 5388
     if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] ))
5390
-      $input['value']['tz'] = 'Z';
5389
+        $input['value']['tz'] = 'Z';
5391 5390
     return $input;
5392
-  }
5391
+    }
5393 5392
 /**
5394
- * check index and set (an indexed) content in multiple value array
5395
- *
5396
- * @author Kjell-Inge Gustafsson <[email protected]>
5397
- * @since 2.5.1 - 2008-11-06
5398
- * @param array $valArr
5399
- * @param mixed $value
5400
- * @param array $params
5401
- * @param array $defaults
5402
- * @param int $index
5403
- * @return void
5404
- */
5405
-  function _setMval( & $valArr, $value, $params=FALSE, $defaults=FALSE, $index=FALSE ) {
5393
+     * check index and set (an indexed) content in multiple value array
5394
+     *
5395
+     * @author Kjell-Inge Gustafsson <[email protected]>
5396
+     * @since 2.5.1 - 2008-11-06
5397
+     * @param array $valArr
5398
+     * @param mixed $value
5399
+     * @param array $params
5400
+     * @param array $defaults
5401
+     * @param int $index
5402
+     * @return void
5403
+     */
5404
+    function _setMval( & $valArr, $value, $params=FALSE, $defaults=FALSE, $index=FALSE ) {
5406 5405
     if( !is_array( $valArr )) $valArr = array();
5407 5406
     if( $index )
5408
-      $index = $index - 1;
5407
+        $index = $index - 1;
5409 5408
     elseif( 0 < count( $valArr )) {
5410
-      $index = end( array_keys( $valArr ));
5411
-      $index += 1;
5409
+        $index = end( array_keys( $valArr ));
5410
+        $index += 1;
5412 5411
     }
5413 5412
     else
5414
-      $index = 0;
5413
+        $index = 0;
5415 5414
     $valArr[$index] = array( 'value' => $value, 'params' => $this->_setParams( $params, $defaults ));
5416 5415
     ksort( $valArr );
5417
-  }
5416
+    }
5418 5417
 /**
5419
- * set input (formatted) parameters- component property attributes
5420
- *
5421
- * default parameters can be set, if missing
5422
- *
5423
- * @author Kjell-Inge Gustafsson <[email protected]>
5424
- * @since 1.x.x - 2007-05-01
5425
- * @param array $params
5426
- * @param array $defaults
5427
- * @return array
5428
- */
5429
-  function _setParams( $params, $defaults=FALSE ) {
5418
+     * set input (formatted) parameters- component property attributes
5419
+     *
5420
+     * default parameters can be set, if missing
5421
+     *
5422
+     * @author Kjell-Inge Gustafsson <[email protected]>
5423
+     * @since 1.x.x - 2007-05-01
5424
+     * @param array $params
5425
+     * @param array $defaults
5426
+     * @return array
5427
+     */
5428
+    function _setParams( $params, $defaults=FALSE ) {
5430 5429
     if( !is_array( $params))
5431
-      $params = array();
5430
+        $params = array();
5432 5431
     $input = array();
5433 5432
     foreach( $params as $paramKey => $paramValue ) {
5434
-      if( is_array( $paramValue )) {
5433
+        if( is_array( $paramValue )) {
5435 5434
         foreach( $paramValue as $pkey => $pValue ) {
5436
-          if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 )))
5435
+            if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 )))
5437 5436
             $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 ));
5438 5437
         }
5439
-      }
5440
-      elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 )))
5438
+        }
5439
+        elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 )))
5441 5440
         $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 ));
5442
-      if( 'VALUE' == strtoupper( $paramKey ))
5441
+        if( 'VALUE' == strtoupper( $paramKey ))
5443 5442
         $input['VALUE']                 = strtoupper( $paramValue );
5444
-      else
5443
+        else
5445 5444
         $input[strtoupper( $paramKey )] = $paramValue;
5446 5445
     }
5447 5446
     if( is_array( $defaults )) {
5448
-      foreach( $defaults as $paramKey => $paramValue ) {
5447
+        foreach( $defaults as $paramKey => $paramValue ) {
5449 5448
         if( !isset( $input[$paramKey] ))
5450
-          $input[$paramKey] = $paramValue;
5451
-      }
5449
+            $input[$paramKey] = $paramValue;
5450
+        }
5452 5451
     }
5453 5452
     return (0 < count( $input )) ? $input : null;
5454
-  }
5453
+    }
5455 5454
 /**
5456
- * step date, return updated date, array and timpstamp
5457
- *
5458
- * @author Kjell-Inge Gustafsson <[email protected]>
5459
- * @since 2.4.16 - 2008-10-18
5460
- * @param array $date, date to step
5461
- * @param int $timestamp
5462
- * @param array $step, default array( 'day' => 1 )
5463
- * @return void
5464
- */
5465
-  function _stepdate( &$date, &$timestamp, $step=array( 'day' => 1 )) {
5455
+     * step date, return updated date, array and timpstamp
5456
+     *
5457
+     * @author Kjell-Inge Gustafsson <[email protected]>
5458
+     * @since 2.4.16 - 2008-10-18
5459
+     * @param array $date, date to step
5460
+     * @param int $timestamp
5461
+     * @param array $step, default array( 'day' => 1 )
5462
+     * @return void
5463
+     */
5464
+    function _stepdate( &$date, &$timestamp, $step=array( 'day' => 1 )) {
5466 5465
     foreach( $step as $stepix => $stepvalue )
5467
-      $date[$stepix] += $stepvalue;
5466
+        $date[$stepix] += $stepvalue;
5468 5467
     $timestamp  = $this->_date2timestamp( $date );
5469 5468
     $date       = $this->_timestamp2date( $timestamp, 6 );
5470 5469
     foreach( $date as $k => $v ) {
5471
-      if( ctype_digit( $v ))
5470
+        if( ctype_digit( $v ))
5472 5471
         $date[$k] = (int) $v;
5473 5472
     }
5474
-  }
5473
+    }
5475 5474
 /**
5476
- * convert timestamp to date array
5477
- *
5478
- * @author Kjell-Inge Gustafsson <[email protected]>
5479
- * @since 2.4.16 - 2008-11-01
5480
- * @param mixed $timestamp
5481
- * @param int $parno
5482
- * @return array
5483
- */
5484
-  function _timestamp2date( $timestamp, $parno=6 ) {
5475
+     * convert timestamp to date array
5476
+     *
5477
+     * @author Kjell-Inge Gustafsson <[email protected]>
5478
+     * @since 2.4.16 - 2008-11-01
5479
+     * @param mixed $timestamp
5480
+     * @param int $parno
5481
+     * @return array
5482
+     */
5483
+    function _timestamp2date( $timestamp, $parno=6 ) {
5485 5484
     if( is_array( $timestamp )) {
5486
-      if(( 7 == $parno ) && !empty( $timestamp['tz'] ))
5485
+        if(( 7 == $parno ) && !empty( $timestamp['tz'] ))
5487 5486
         $tz = $timestamp['tz'];
5488
-      $timestamp = $timestamp['timestamp'];
5487
+        $timestamp = $timestamp['timestamp'];
5489 5488
     }
5490 5489
     $output = array( 'year'  => date( 'Y', $timestamp )
5491
-                   , 'month' => date( 'm', $timestamp )
5492
-                   , 'day'   => date( 'd', $timestamp ));
5490
+                    , 'month' => date( 'm', $timestamp )
5491
+                    , 'day'   => date( 'd', $timestamp ));
5493 5492
     if( 3 != $parno ) {
5494
-             $output['hour'] =  date( 'H', $timestamp );
5495
-             $output['min']  =  date( 'i', $timestamp );
5496
-             $output['sec']  =  date( 's', $timestamp );
5497
-      if( isset( $tz ))
5493
+                $output['hour'] =  date( 'H', $timestamp );
5494
+                $output['min']  =  date( 'i', $timestamp );
5495
+                $output['sec']  =  date( 's', $timestamp );
5496
+        if( isset( $tz ))
5498 5497
         $output['tz'] = $tz;
5499 5498
     }
5500 5499
     return $output;
5501
-  }
5500
+    }
5502 5501
 /**
5503
- * convert (numeric) local time offset to seconds correcting localtime to GMT
5504
- *
5505
- * @author Kjell-Inge Gustafsson <[email protected]>
5506
- * @since 2.4.16 - 2008-10-19
5507
- * @param string $offset
5508
- * @return integer
5509
- */
5510
-  function _tz2offset( $tz ) {
5502
+     * convert (numeric) local time offset to seconds correcting localtime to GMT
5503
+     *
5504
+     * @author Kjell-Inge Gustafsson <[email protected]>
5505
+     * @since 2.4.16 - 2008-10-19
5506
+     * @param string $offset
5507
+     * @return integer
5508
+     */
5509
+    function _tz2offset( $tz ) {
5511 5510
     $tz           = trim( (string) $tz );
5512 5511
     $offset       = 0;
5513 5512
     if(((     5  != strlen( $tz )) && ( 7  != strlen( $tz ))) ||
5514 5513
        ((    '+' != substr( $tz, 0, 1 )) && ( '-' != substr( $tz, 0, 1 ))) ||
5515 5514
        (( '0000' >= substr( $tz, 1, 4 )) && ( '9999' < substr( $tz, 1, 4 ))) ||
5516 5515
            (( 7  == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 ))))
5517
-      return $offset;
5516
+        return $offset;
5518 5517
     $hours2sec    = (int) substr( $tz, 1, 2 ) * 3600;
5519 5518
     $min2sec      = (int) substr( $tz, 3, 2 ) *   60;
5520 5519
     $sec          = ( 7  == strlen( $tz )) ? (int) substr( $tz, -2 ) : '00';
5521 5520
     $offset       = $hours2sec + $min2sec + $sec;
5522 5521
     $offset       = ('-' == substr( $tz, 0, 1 )) ? $offset : -1 * $offset;
5523 5522
     return $offset;
5524
-  }
5523
+    }
5525 5524
 /*********************************************************************************/
5526 5525
 /*********************************************************************************/
5527 5526
 /**
5528
- * get general component config variables or info about subcomponents
5529
- *
5530
- * @author Kjell-Inge Gustafsson <[email protected]>
5531
- * @since 2.5.1 - 2008-11-02
5532
- * @param string $config
5533
- * @return value
5534
- */
5535
-  function getConfig( $config ) {
5527
+     * get general component config variables or info about subcomponents
5528
+     *
5529
+     * @author Kjell-Inge Gustafsson <[email protected]>
5530
+     * @since 2.5.1 - 2008-11-02
5531
+     * @param string $config
5532
+     * @return value
5533
+     */
5534
+    function getConfig( $config ) {
5536 5535
     switch( strtoupper( $config )) {
5537
-      case 'ALLOWEMPTY':
5536
+        case 'ALLOWEMPTY':
5538 5537
         return $this->allowEmpty;
5539 5538
         break;
5540
-      case 'COMPSINFO':
5539
+        case 'COMPSINFO':
5541 5540
         unset( $this->compix );
5542 5541
         $info = array();
5543 5542
         if( isset( $this->components )) {
5544
-          foreach( $this->components as $cix => $component ) {
5543
+            foreach( $this->components as $cix => $component ) {
5545 5544
             if( empty( $component )) continue;
5546 5545
             unset( $component->propix );
5547 5546
             $info[$cix]['ordno'] = $cix + 1;
@@ -5550,26 +5549,26 @@  discard block
 block discarded – undo
5550 5549
             $info[$cix]['props'] = $component->getConfig( 'propinfo' );
5551 5550
             $info[$cix]['sub']   = $component->getConfig( 'compsinfo' );
5552 5551
             unset( $component->propix );
5553
-          }
5552
+            }
5554 5553
         }
5555 5554
         return $info;
5556 5555
         break;
5557
-      case 'FORMAT':
5556
+        case 'FORMAT':
5558 5557
         return $this->format;
5559 5558
         break;
5560
-      case 'LANGUAGE':
5559
+        case 'LANGUAGE':
5561 5560
          // get language for calendar component as defined in [RFC 1766]
5562 5561
         return $this->language;
5563 5562
         break;
5564
-      case 'NL':
5563
+        case 'NL':
5565 5564
       case 'NEWLINECHAR':
5566 5565
         return $this->nl;
5567 5566
         break;
5568
-      case 'PROPINFO':
5567
+        case 'PROPINFO':
5569 5568
         $output = array();
5570 5569
         if( !in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
5571
-          if( empty( $this->uid['value'] )) $this->_makeuid();
5572
-                                              $output['UID']              = 1;
5570
+            if( empty( $this->uid['value'] )) $this->_makeuid();
5571
+                                                $output['UID']              = 1;
5573 5572
         }
5574 5573
         if( !empty( $this->dtstamp ))         $output['DTSTAMP']          = 1;
5575 5574
         if( !empty( $this->summary ))         $output['SUMMARY']          = 1;
@@ -5616,51 +5615,51 @@  discard block
 block discarded – undo
5616 5615
         if( !empty( $this->xprop ))           $output['X-PROP']           = count( $this->xprop );
5617 5616
         return $output;
5618 5617
         break;
5619
-      case 'UNIQUE_ID':
5618
+        case 'UNIQUE_ID':
5620 5619
         if( empty( $this->unique_id ))
5621
-          $this->unique_id  = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost';
5620
+            $this->unique_id  = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost';
5622 5621
         return $this->unique_id;
5623 5622
         break;
5624 5623
     }
5625
-  }
5624
+    }
5626 5625
 /**
5627
- * general component config setting
5628
- *
5629
- * @author Kjell-Inge Gustafsson <[email protected]>
5630
- * @since 2.4.8 - 2008-10-24
5631
- * @param string $config
5632
- * @param string $value
5633
- * @return void
5634
- */
5635
-  function setConfig( $config, $value ) {
5626
+     * general component config setting
5627
+     *
5628
+     * @author Kjell-Inge Gustafsson <[email protected]>
5629
+     * @since 2.4.8 - 2008-10-24
5630
+     * @param string $config
5631
+     * @param string $value
5632
+     * @return void
5633
+     */
5634
+    function setConfig( $config, $value ) {
5636 5635
     $res = FALSE;
5637 5636
     switch( strtoupper( $config )) {
5638
-      case 'ALLOWEMPTY':
5637
+        case 'ALLOWEMPTY':
5639 5638
         $this->allowEmpty = $value;
5640 5639
         $subcfg = array( 'ALLOWEMPTY' => $value );
5641 5640
         $res    = TRUE;
5642 5641
         break;
5643
-      case 'FORMAT':
5642
+        case 'FORMAT':
5644 5643
         $value  = trim( $value );
5645 5644
         $this->format = $value;
5646 5645
         $this->_createFormat();
5647 5646
         $subcfg = array( 'FORMAT' => $value );
5648 5647
         $res    = TRUE;
5649 5648
         break;
5650
-      case 'LANGUAGE':
5649
+        case 'LANGUAGE':
5651 5650
          // set language for calendar component as defined in [RFC 1766]
5652 5651
         $value  = trim( $value );
5653 5652
         $this->language = $value;
5654 5653
         $subcfg = array( 'LANGUAGE' => $value );
5655 5654
         $res    = TRUE;
5656 5655
         break;
5657
-      case 'NL':
5656
+        case 'NL':
5658 5657
       case 'NEWLINECHAR':
5659 5658
         $this->nl = $value;
5660 5659
         $subcfg = array( 'NL' => $value );
5661 5660
         $res    = TRUE;
5662 5661
         break;
5663
-      case 'UNIQUE_ID':
5662
+        case 'UNIQUE_ID':
5664 5663
         $value  = trim( $value );
5665 5664
         $this->unique_id = $value;
5666 5665
         $subcfg = array( 'UNIQUE_ID' => $value );
@@ -5669,763 +5668,763 @@  discard block
 block discarded – undo
5669 5668
     }
5670 5669
     if( !$res ) return FALSE;
5671 5670
     if( isset( $subcfg ) && !empty( $this->components )) {
5672
-      foreach( $subcfg as $cfgkey => $cfgvalue ) {
5671
+        foreach( $subcfg as $cfgkey => $cfgvalue ) {
5673 5672
         foreach( $this->components as $cix => $component ) {
5674
-          $res = $component->setConfig( $cfgkey, $cfgvalue );
5675
-          if( !$res )
5673
+            $res = $component->setConfig( $cfgkey, $cfgvalue );
5674
+            if( !$res )
5676 5675
             break 2;
5677
-          $this->components[$cix] = $component; // PHP4 compliant
5676
+            $this->components[$cix] = $component; // PHP4 compliant
5677
+        }
5678 5678
         }
5679
-      }
5680 5679
     }
5681 5680
     return $res;
5682
-  }
5681
+    }
5683 5682
 /*********************************************************************************/
5684 5683
 /**
5685
- * delete component property value
5686
- *
5687
- * @author Kjell-Inge Gustafsson <[email protected]>
5688
- * @since 2.5.1 - 2008-11-14
5689
- * @param string $propName
5690
- * @param int @propix, optional, if specific property is wanted in case of multiply occurences
5691
- * @return bool, if successfull delete TRUE
5692
- */
5693
-  function deleteProperty( $propName, $propix=FALSE ) {
5684
+     * delete component property value
5685
+     *
5686
+     * @author Kjell-Inge Gustafsson <[email protected]>
5687
+     * @since 2.5.1 - 2008-11-14
5688
+     * @param string $propName
5689
+     * @param int @propix, optional, if specific property is wanted in case of multiply occurences
5690
+     * @return bool, if successfull delete TRUE
5691
+     */
5692
+    function deleteProperty( $propName, $propix=FALSE ) {
5694 5693
     if( $this->_notExistProp( $propName )) return FALSE;
5695 5694
     $propName = strtoupper( $propName );
5696 5695
     if( in_array( $propName, array( 'ATTACH',   'ATTENDEE', 'CATEGORIES', 'COMMENT',   'CONTACT', 'DESCRIPTION',    'EXDATE', 'EXRULE',
5697 5696
                                     'FREEBUSY', 'RDATE',    'RELATED-TO', 'RESOURCES', 'RRULE',   'REQUEST-STATUS', 'TZNAME', 'X-PROP'  ))) {
5698
-      if( !$propix )
5697
+        if( !$propix )
5699 5698
         $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
5700
-      $this->propdelix[$propName] = --$propix;
5699
+        $this->propdelix[$propName] = --$propix;
5701 5700
     }
5702 5701
     $return = FALSE;
5703 5702
     switch( $propName ) {
5704
-      case 'ACTION':
5703
+        case 'ACTION':
5705 5704
         if( !empty( $this->action )) {
5706
-          $this->action = '';
5707
-          $return = TRUE;
5705
+            $this->action = '';
5706
+            $return = TRUE;
5708 5707
         }
5709 5708
         break;
5710
-      case 'ATTACH':
5709
+        case 'ATTACH':
5711 5710
         return $this->deletePropertyM( $this->attach, $propix );
5712 5711
         break;
5713
-      case 'ATTENDEE':
5712
+        case 'ATTENDEE':
5714 5713
         return $this->deletePropertyM( $this->attendee, $propix );
5715 5714
         break;
5716
-      case 'CATEGORIES':
5715
+        case 'CATEGORIES':
5717 5716
         return $this->deletePropertyM( $this->categories, $propix );
5718 5717
         break;
5719
-      case 'CLASS':
5718
+        case 'CLASS':
5720 5719
         if( !empty( $this->class )) {
5721
-          $this->class = '';
5722
-          $return = TRUE;
5720
+            $this->class = '';
5721
+            $return = TRUE;
5723 5722
         }
5724 5723
         break;
5725
-      case 'COMMENT':
5724
+        case 'COMMENT':
5726 5725
         return $this->deletePropertyM( $this->comment, $propix );
5727 5726
         break;
5728
-      case 'COMPLETED':
5727
+        case 'COMPLETED':
5729 5728
         if( !empty( $this->completed )) {
5730
-          $this->completed = '';
5731
-          $return = TRUE;
5729
+            $this->completed = '';
5730
+            $return = TRUE;
5732 5731
         }
5733 5732
         break;
5734
-      case 'CONTACT':
5733
+        case 'CONTACT':
5735 5734
         return $this->deletePropertyM( $this->contact, $propix );
5736 5735
         break;
5737
-      case 'CREATED':
5736
+        case 'CREATED':
5738 5737
         if( !empty( $this->created )) {
5739
-          $this->created = '';
5740
-          $return = TRUE;
5738
+            $this->created = '';
5739
+            $return = TRUE;
5741 5740
         }
5742 5741
         break;
5743
-      case 'DESCRIPTION':
5742
+        case 'DESCRIPTION':
5744 5743
         return $this->deletePropertyM( $this->description, $propix );
5745 5744
         break;
5746
-      case 'DTEND':
5745
+        case 'DTEND':
5747 5746
         if( !empty( $this->dtend )) {
5748
-          $this->dtend = '';
5749
-          $return = TRUE;
5747
+            $this->dtend = '';
5748
+            $return = TRUE;
5750 5749
         }
5751 5750
         break;
5752
-      case 'DTSTAMP':
5751
+        case 'DTSTAMP':
5753 5752
         if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
5754
-          return FALSE;
5753
+            return FALSE;
5755 5754
         if( !empty( $this->dtstamp )) {
5756
-          $this->dtstamp = '';
5757
-          $return = TRUE;
5755
+            $this->dtstamp = '';
5756
+            $return = TRUE;
5758 5757
         }
5759 5758
         break;
5760
-      case 'DTSTART':
5759
+        case 'DTSTART':
5761 5760
         if( !empty( $this->dtstart )) {
5762
-          $this->dtstart = '';
5763
-          $return = TRUE;
5761
+            $this->dtstart = '';
5762
+            $return = TRUE;
5764 5763
         }
5765 5764
         break;
5766
-      case 'DUE':
5765
+        case 'DUE':
5767 5766
         if( !empty( $this->due )) {
5768
-          $this->due = '';
5769
-          $return = TRUE;
5767
+            $this->due = '';
5768
+            $return = TRUE;
5770 5769
         }
5771 5770
         break;
5772
-      case 'DURATION':
5771
+        case 'DURATION':
5773 5772
         if( !empty( $this->duration )) {
5774
-          $this->duration = '';
5775
-          $return = TRUE;
5773
+            $this->duration = '';
5774
+            $return = TRUE;
5776 5775
         }
5777 5776
         break;
5778
-      case 'EXDATE':
5777
+        case 'EXDATE':
5779 5778
         return $this->deletePropertyM( $this->exdate, $propix );
5780 5779
         break;
5781
-      case 'EXRULE':
5780
+        case 'EXRULE':
5782 5781
         return $this->deletePropertyM( $this->exrule, $propix );
5783 5782
         break;
5784
-      case 'FREEBUSY':
5783
+        case 'FREEBUSY':
5785 5784
         return $this->deletePropertyM( $this->freebusy, $propix );
5786 5785
         break;
5787
-      case 'GEO':
5786
+        case 'GEO':
5788 5787
         if( !empty( $this->geo )) {
5789
-          $this->geo = '';
5790
-          $return = TRUE;
5788
+            $this->geo = '';
5789
+            $return = TRUE;
5791 5790
         }
5792 5791
         break;
5793
-      case 'LAST-MODIFIED':
5792
+        case 'LAST-MODIFIED':
5794 5793
         if( !empty( $this->lastmodified )) {
5795
-          $this->lastmodified = '';
5796
-          $return = TRUE;
5794
+            $this->lastmodified = '';
5795
+            $return = TRUE;
5797 5796
         }
5798 5797
         break;
5799
-      case 'LOCATION':
5798
+        case 'LOCATION':
5800 5799
         if( !empty( $this->location )) {
5801
-          $this->location = '';
5802
-          $return = TRUE;
5800
+            $this->location = '';
5801
+            $return = TRUE;
5803 5802
         }
5804 5803
         break;
5805
-      case 'ORGANIZER':
5804
+        case 'ORGANIZER':
5806 5805
         if( !empty( $this->organizer )) {
5807
-          $this->organizer = '';
5808
-          $return = TRUE;
5806
+            $this->organizer = '';
5807
+            $return = TRUE;
5809 5808
         }
5810 5809
         break;
5811
-      case 'PERCENT-COMPLETE':
5810
+        case 'PERCENT-COMPLETE':
5812 5811
         if( !empty( $this->percentcomplete )) {
5813
-          $this->percentcomplete = '';
5814
-          $return = TRUE;
5812
+            $this->percentcomplete = '';
5813
+            $return = TRUE;
5815 5814
         }
5816 5815
         break;
5817
-      case 'PRIORITY':
5816
+        case 'PRIORITY':
5818 5817
         if( !empty( $this->priority )) {
5819
-          $this->priority = '';
5820
-          $return = TRUE;
5818
+            $this->priority = '';
5819
+            $return = TRUE;
5821 5820
         }
5822 5821
         break;
5823
-      case 'RDATE':
5822
+        case 'RDATE':
5824 5823
         return $this->deletePropertyM( $this->rdate, $propix );
5825 5824
         break;
5826
-      case 'RECURRENCE-ID':
5825
+        case 'RECURRENCE-ID':
5827 5826
         if( !empty( $this->recurrenceid )) {
5828
-          $this->recurrenceid = '';
5829
-          $return = TRUE;
5827
+            $this->recurrenceid = '';
5828
+            $return = TRUE;
5830 5829
         }
5831 5830
         break;
5832
-      case 'RELATED-TO':
5831
+        case 'RELATED-TO':
5833 5832
         return $this->deletePropertyM( $this->relatedto, $propix );
5834 5833
         break;
5835
-      case 'REPEAT':
5834
+        case 'REPEAT':
5836 5835
         if( !empty( $this->repeat )) {
5837
-          $this->repeat = '';
5838
-          $return = TRUE;
5836
+            $this->repeat = '';
5837
+            $return = TRUE;
5839 5838
         }
5840 5839
         break;
5841
-      case 'REQUEST-STATUS':
5840
+        case 'REQUEST-STATUS':
5842 5841
         return $this->deletePropertyM( $this->requeststatus, $propix );
5843 5842
         break;
5844
-      case 'RESOURCES':
5843
+        case 'RESOURCES':
5845 5844
         return $this->deletePropertyM( $this->resources, $propix );
5846 5845
         break;
5847
-      case 'RRULE':
5846
+        case 'RRULE':
5848 5847
         return $this->deletePropertyM( $this->rrule, $propix );
5849 5848
         break;
5850
-      case 'SEQUENCE':
5849
+        case 'SEQUENCE':
5851 5850
         if( !empty( $this->sequence )) {
5852
-          $this->sequence = '';
5853
-          $return = TRUE;
5851
+            $this->sequence = '';
5852
+            $return = TRUE;
5854 5853
         }
5855 5854
         break;
5856
-      case 'STATUS':
5855
+        case 'STATUS':
5857 5856
         if( !empty( $this->status )) {
5858
-          $this->status = '';
5859
-          $return = TRUE;
5857
+            $this->status = '';
5858
+            $return = TRUE;
5860 5859
         }
5861 5860
         break;
5862
-      case 'SUMMARY':
5861
+        case 'SUMMARY':
5863 5862
         if( !empty( $this->summary )) {
5864
-          $this->summary = '';
5865
-          $return = TRUE;
5863
+            $this->summary = '';
5864
+            $return = TRUE;
5866 5865
         }
5867 5866
         break;
5868
-      case 'TRANSP':
5867
+        case 'TRANSP':
5869 5868
         if( !empty( $this->transp )) {
5870
-          $this->transp = '';
5871
-          $return = TRUE;
5869
+            $this->transp = '';
5870
+            $return = TRUE;
5872 5871
         }
5873 5872
         break;
5874
-      case 'TRIGGER':
5873
+        case 'TRIGGER':
5875 5874
         if( !empty( $this->trigger )) {
5876
-          $this->trigger = '';
5877
-          $return = TRUE;
5875
+            $this->trigger = '';
5876
+            $return = TRUE;
5878 5877
         }
5879 5878
         break;
5880
-      case 'TZID':
5879
+        case 'TZID':
5881 5880
         if( !empty( $this->tzid )) {
5882
-          $this->tzid = '';
5883
-          $return = TRUE;
5881
+            $this->tzid = '';
5882
+            $return = TRUE;
5884 5883
         }
5885 5884
         break;
5886
-      case 'TZNAME':
5885
+        case 'TZNAME':
5887 5886
         return $this->deletePropertyM( $this->tzname, $propix );
5888 5887
         break;
5889
-      case 'TZOFFSETFROM':
5888
+        case 'TZOFFSETFROM':
5890 5889
         if( !empty( $this->tzoffsetfrom )) {
5891
-          $this->tzoffsetfrom = '';
5892
-          $return = TRUE;
5890
+            $this->tzoffsetfrom = '';
5891
+            $return = TRUE;
5893 5892
         }
5894 5893
         break;
5895
-      case 'TZOFFSETTO':
5894
+        case 'TZOFFSETTO':
5896 5895
         if( !empty( $this->tzoffsetto )) {
5897
-          $this->tzoffsetto = '';
5898
-          $return = TRUE;
5896
+            $this->tzoffsetto = '';
5897
+            $return = TRUE;
5899 5898
         }
5900 5899
         break;
5901
-      case 'TZURL':
5900
+        case 'TZURL':
5902 5901
         if( !empty( $this->tzurl )) {
5903
-          $this->tzurl = '';
5904
-          $return = TRUE;
5902
+            $this->tzurl = '';
5903
+            $return = TRUE;
5905 5904
         }
5906 5905
         break;
5907
-      case 'UID':
5906
+        case 'UID':
5908 5907
         if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
5909
-          return FALSE;
5908
+            return FALSE;
5910 5909
         if( !empty( $this->uid )) {
5911
-          $this->uid = '';
5912
-          $return = TRUE;
5910
+            $this->uid = '';
5911
+            $return = TRUE;
5913 5912
         }
5914 5913
         break;
5915
-      case 'URL':
5914
+        case 'URL':
5916 5915
         if( !empty( $this->url )) {
5917
-          $this->url = '';
5918
-          $return = TRUE;
5916
+            $this->url = '';
5917
+            $return = TRUE;
5919 5918
         }
5920 5919
         break;
5921
-      default:
5920
+        default:
5922 5921
         $reduced = '';
5923 5922
         if( $propName != 'X-PROP' ) {
5924
-          if( !isset( $this->xprop[$propName] )) return FALSE;
5925
-          foreach( $this->xprop as $k => $a ) {
5923
+            if( !isset( $this->xprop[$propName] )) return FALSE;
5924
+            foreach( $this->xprop as $k => $a ) {
5926 5925
             if(( $k != $propName ) && !empty( $a ))
5927
-              $reduced[$k] = $a;
5928
-          }
5926
+                $reduced[$k] = $a;
5927
+            }
5929 5928
         }
5930 5929
         else {
5931
-          if( count( $this->xprop ) <= $propix )  return FALSE;
5932
-          $xpropno = 0;
5933
-          foreach( $this->xprop as $xpropkey => $xpropvalue ) {
5930
+            if( count( $this->xprop ) <= $propix )  return FALSE;
5931
+            $xpropno = 0;
5932
+            foreach( $this->xprop as $xpropkey => $xpropvalue ) {
5934 5933
             if( $propix != $xpropno )
5935
-              $reduced[$xpropkey] = $xpropvalue;
5934
+                $reduced[$xpropkey] = $xpropvalue;
5936 5935
             $xpropno++;
5937
-          }
5936
+            }
5938 5937
         }
5939 5938
         $this->xprop = $reduced;
5940 5939
         return TRUE;
5941 5940
     }
5942 5941
     return $return;
5943
-  }
5942
+    }
5944 5943
 /*********************************************************************************/
5945 5944
 /**
5946
- * delete component property value, fixing components with multiple occurencies
5947
- *
5948
- * @author Kjell-Inge Gustafsson <[email protected]>
5949
- * @since 2.4.5 - 2008-11-07
5950
- * @param array $multiprop, reference to a component property
5951
- * @param int @propix, default 0
5952
- * @return bool TRUE
5953
- */
5954
-  function deletePropertyM( & $multiprop, $propix=0 ) {
5945
+     * delete component property value, fixing components with multiple occurencies
5946
+     *
5947
+     * @author Kjell-Inge Gustafsson <[email protected]>
5948
+     * @since 2.4.5 - 2008-11-07
5949
+     * @param array $multiprop, reference to a component property
5950
+     * @param int @propix, default 0
5951
+     * @return bool TRUE
5952
+     */
5953
+    function deletePropertyM( & $multiprop, $propix=0 ) {
5955 5954
     if( !isset( $multiprop[$propix])) return FALSE;
5956 5955
     unset( $multiprop[$propix] );
5957 5956
     if( empty( $multiprop )) $multiprop = '';
5958 5957
     return ( isset( $this->multiprop[$propix] )) ? FALSE : TRUE;
5959
-  }
5958
+    }
5960 5959
 /**
5961
- * get component property value/params
5962
- *
5963
- * if property has multiply values, consequtive function calls are needed
5964
- *
5965
- * @author Kjell-Inge Gustafsson <[email protected]>
5966
- * @since 2.5.1 - 2008-11-02
5967
- * @param string $propName, optional
5968
- * @param int @propix, optional, if specific property is wanted in case of multiply occurences
5969
- * @param bool $inclParam=FALSE
5970
- * @param bool $specform=FALSE
5971
- * @return mixed
5972
- */
5973
-  function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE, $specform=FALSE ) {
5960
+     * get component property value/params
5961
+     *
5962
+     * if property has multiply values, consequtive function calls are needed
5963
+     *
5964
+     * @author Kjell-Inge Gustafsson <[email protected]>
5965
+     * @since 2.5.1 - 2008-11-02
5966
+     * @param string $propName, optional
5967
+     * @param int @propix, optional, if specific property is wanted in case of multiply occurences
5968
+     * @param bool $inclParam=FALSE
5969
+     * @param bool $specform=FALSE
5970
+     * @return mixed
5971
+     */
5972
+    function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE, $specform=FALSE ) {
5974 5973
     if( $this->_notExistProp( $propName )) return FALSE;
5975 5974
     $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';
5976 5975
     if( in_array( $propName, array( 'ATTACH',   'ATTENDEE', 'CATEGORIES', 'COMMENT',   'CONTACT', 'DESCRIPTION',    'EXDATE', 'EXRULE',
5977 5976
                                     'FREEBUSY', 'RDATE',    'RELATED-TO', 'RESOURCES', 'RRULE',   'REQUEST-STATUS', 'TZNAME', 'X-PROP'  ))) {
5978
-      if( !$propix )
5977
+        if( !$propix )
5979 5978
         $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;
5980
-      $this->propix[$propName] = --$propix;
5979
+        $this->propix[$propName] = --$propix;
5981 5980
     }
5982 5981
     switch( $propName ) {
5983
-      case 'ACTION':
5982
+        case 'ACTION':
5984 5983
         if( !empty( $this->action['value'] )) return ( $inclParam ) ? $this->action : $this->action['value'];
5985 5984
         break;
5986
-      case 'ATTACH':
5985
+        case 'ATTACH':
5987 5986
         if( !isset( $this->attach[$propix] )) return FALSE;
5988 5987
         return ( $inclParam ) ? $this->attach[$propix] : $this->attach[$propix]['value'];
5989 5988
         break;
5990
-      case 'ATTENDEE':
5989
+        case 'ATTENDEE':
5991 5990
         if( !isset( $this->attendee[$propix] )) return FALSE;
5992 5991
         return ( $inclParam ) ? $this->attendee[$propix] : $this->attendee[$propix]['value'];
5993 5992
         break;
5994
-      case 'CATEGORIES':
5993
+        case 'CATEGORIES':
5995 5994
         if( !isset( $this->categories[$propix] )) return FALSE;
5996 5995
         return ( $inclParam ) ? $this->categories[$propix] : $this->categories[$propix]['value'];
5997 5996
         break;
5998
-      case 'CLASS':
5997
+        case 'CLASS':
5999 5998
         if( !empty( $this->class['value'] )) return ( $inclParam ) ? $this->class : $this->class['value'];
6000 5999
         break;
6001
-      case 'COMMENT':
6000
+        case 'COMMENT':
6002 6001
         if( !isset( $this->comment[$propix] )) return FALSE;
6003 6002
         return ( $inclParam ) ? $this->comment[$propix] : $this->comment[$propix]['value'];
6004 6003
         break;
6005
-      case 'COMPLETED':
6004
+        case 'COMPLETED':
6006 6005
         if( !empty( $this->completed['value'] )) return ( $inclParam ) ? $this->completed : $this->completed['value'];
6007 6006
         break;
6008
-      case 'CONTACT':
6007
+        case 'CONTACT':
6009 6008
         if( !isset( $this->contact[$propix] )) return FALSE;
6010 6009
         return ( $inclParam ) ? $this->contact[$propix] : $this->contact[$propix]['value'];
6011 6010
         break;
6012
-      case 'CREATED':
6011
+        case 'CREATED':
6013 6012
         if( !empty( $this->created['value'] )) return ( $inclParam ) ? $this->created : $this->created['value'];
6014 6013
         break;
6015
-      case 'DESCRIPTION':
6014
+        case 'DESCRIPTION':
6016 6015
         if( !isset( $this->description[$propix] )) return FALSE;
6017 6016
         return ( $inclParam ) ? $this->description[$propix] : $this->description[$propix]['value'];
6018 6017
         break;
6019
-      case 'DTEND':
6018
+        case 'DTEND':
6020 6019
         if( !empty( $this->dtend['value'] )) return ( $inclParam ) ? $this->dtend : $this->dtend['value'];
6021 6020
         break;
6022
-      case 'DTSTAMP':
6021
+        case 'DTSTAMP':
6023 6022
         if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
6024
-          return;
6023
+            return;
6025 6024
         if( !isset( $this->dtstamp['value'] ))
6026
-          $this->_makeDtstamp();
6025
+            $this->_makeDtstamp();
6027 6026
         return ( $inclParam ) ? $this->dtstamp : $this->dtstamp['value'];
6028 6027
         break;
6029
-      case 'DTSTART':
6028
+        case 'DTSTART':
6030 6029
         if( !empty( $this->dtstart['value'] )) return ( $inclParam ) ? $this->dtstart : $this->dtstart['value'];
6031 6030
         break;
6032
-      case 'DUE':
6031
+        case 'DUE':
6033 6032
         if( !empty( $this->due['value'] )) return ( $inclParam ) ? $this->due : $this->due['value'];
6034 6033
         break;
6035
-      case 'DURATION':
6034
+        case 'DURATION':
6036 6035
         if( !isset( $this->duration['value'] )) return FALSE;
6037 6036
         $value = ( $specform ) ? $this->duration2date() : $this->duration['value'];
6038 6037
         return ( $inclParam ) ? array( 'value' => $value, 'params' =>  $this->duration['params'] ) : $value;
6039 6038
         break;
6040
-      case 'EXDATE':
6039
+        case 'EXDATE':
6041 6040
         if( !isset( $this->exdate[$propix] )) return FALSE;
6042 6041
         return ( $inclParam ) ? $this->exdate[$propix] : $this->exdate[$propix]['value'];
6043 6042
         break;
6044
-      case 'EXRULE':
6043
+        case 'EXRULE':
6045 6044
         if( !isset( $this->exrule[$propix] )) return FALSE;
6046 6045
         return ( $inclParam ) ? $this->exrule[$propix] : $this->exrule[$propix]['value'];
6047 6046
         break;
6048
-      case 'FREEBUSY':
6047
+        case 'FREEBUSY':
6049 6048
         if( !isset( $this->freebusy[$propix] )) return FALSE;
6050 6049
         return ( $inclParam ) ? $this->freebusy[$propix] : $this->freebusy[$propix]['value'];
6051 6050
         break;
6052
-      case 'GEO':
6051
+        case 'GEO':
6053 6052
         if( !empty( $this->geo['value'] )) return ( $inclParam ) ? $this->geo : $this->geo['value'];
6054 6053
         break;
6055
-      case 'LAST-MODIFIED':
6054
+        case 'LAST-MODIFIED':
6056 6055
         if( !empty( $this->lastmodified['value'] )) return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value'];
6057 6056
         break;
6058
-      case 'LOCATION':
6057
+        case 'LOCATION':
6059 6058
         if( !empty( $this->location['value'] )) return ( $inclParam ) ? $this->location : $this->location['value'];
6060 6059
         break;
6061
-      case 'ORGANIZER':
6060
+        case 'ORGANIZER':
6062 6061
         if( !empty( $this->organizer['value'] )) return ( $inclParam ) ? $this->organizer : $this->organizer['value'];
6063 6062
         break;
6064
-      case 'PERCENT-COMPLETE':
6063
+        case 'PERCENT-COMPLETE':
6065 6064
         if( !empty( $this->percentcomplete['value'] )) return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value'];
6066 6065
         break;
6067
-      case 'PRIORITY':
6066
+        case 'PRIORITY':
6068 6067
         if( !empty( $this->priority['value'] )) return ( $inclParam ) ? $this->priority : $this->priority['value'];
6069 6068
         break;
6070
-      case 'RDATE':
6069
+        case 'RDATE':
6071 6070
         if( !isset( $this->rdate[$propix] )) return FALSE;
6072 6071
         return ( $inclParam ) ? $this->rdate[$propix] : $this->rdate[$propix]['value'];
6073 6072
         break;
6074
-      case 'RECURRENCE-ID':
6073
+        case 'RECURRENCE-ID':
6075 6074
         if( !empty( $this->recurrenceid['value'] )) return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value'];
6076 6075
         break;
6077
-      case 'RELATED-TO':
6076
+        case 'RELATED-TO':
6078 6077
         if( !isset( $this->relatedto[$propix] )) return FALSE;
6079 6078
         return ( $inclParam ) ? $this->relatedto[$propix] : $this->relatedto[$propix]['value'];
6080 6079
         break;
6081
-      case 'REPEAT':
6080
+        case 'REPEAT':
6082 6081
         if( !empty( $this->repeat['value'] )) return ( $inclParam ) ? $this->repeat : $this->repeat['value'];
6083 6082
         break;
6084
-      case 'REQUEST-STATUS':
6083
+        case 'REQUEST-STATUS':
6085 6084
         if( !isset( $this->requeststatus[$propix] )) return FALSE;
6086 6085
         return ( $inclParam ) ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value'];
6087 6086
         break;
6088
-      case 'RESOURCES':
6087
+        case 'RESOURCES':
6089 6088
         if( !isset( $this->resources[$propix] )) return FALSE;
6090 6089
         return ( $inclParam ) ? $this->resources[$propix] : $this->resources[$propix]['value'];
6091 6090
         break;
6092
-      case 'RRULE':
6091
+        case 'RRULE':
6093 6092
         if( !isset( $this->rrule[$propix] )) return FALSE;
6094 6093
         return ( $inclParam ) ? $this->rrule[$propix] : $this->rrule[$propix]['value'];
6095 6094
         break;
6096
-      case 'SEQUENCE':
6095
+        case 'SEQUENCE':
6097 6096
         if( !empty( $this->sequence['value'] )) return ( $inclParam ) ? $this->sequence : $this->sequence['value'];
6098 6097
         break;
6099
-      case 'STATUS':
6098
+        case 'STATUS':
6100 6099
         if( !empty( $this->status['value'] )) return ( $inclParam ) ? $this->status : $this->status['value'];
6101 6100
         break;
6102
-      case 'SUMMARY':
6101
+        case 'SUMMARY':
6103 6102
         if( !empty( $this->summary['value'] )) return ( $inclParam ) ? $this->summary : $this->summary['value'];
6104 6103
         break;
6105
-      case 'TRANSP':
6104
+        case 'TRANSP':
6106 6105
         if( !empty( $this->transp['value'] )) return ( $inclParam ) ? $this->transp : $this->transp['value'];
6107 6106
         break;
6108
-      case 'TRIGGER':
6107
+        case 'TRIGGER':
6109 6108
         if( !empty( $this->trigger['value'] )) return ( $inclParam ) ? $this->trigger : $this->trigger['value'];
6110 6109
         break;
6111
-      case 'TZID':
6110
+        case 'TZID':
6112 6111
         if( !empty( $this->tzid['value'] )) return ( $inclParam ) ? $this->tzid : $this->tzid['value'];
6113 6112
         break;
6114
-      case 'TZNAME':
6113
+        case 'TZNAME':
6115 6114
         if( !isset( $this->tzname[$propix] )) return FALSE;
6116 6115
         return ( $inclParam ) ? $this->tzname[$propix] : $this->tzname[$propix]['value'];
6117 6116
         break;
6118
-      case 'TZOFFSETFROM':
6117
+        case 'TZOFFSETFROM':
6119 6118
         if( !empty( $this->tzoffsetfrom['value'] )) return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value'];
6120 6119
         break;
6121
-      case 'TZOFFSETTO':
6120
+        case 'TZOFFSETTO':
6122 6121
         if( !empty( $this->tzoffsetto['value'] )) return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value'];
6123 6122
         break;
6124
-      case 'TZURL':
6123
+        case 'TZURL':
6125 6124
         if( !empty( $this->tzurl['value'] )) return ( $inclParam ) ? $this->tzurl : $this->tzurl['value'];
6126 6125
         break;
6127
-      case 'UID':
6126
+        case 'UID':
6128 6127
         if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
6129
-          return FALSE;
6128
+            return FALSE;
6130 6129
         if( empty( $this->uid['value'] ))
6131
-          $this->_makeuid();
6130
+            $this->_makeuid();
6132 6131
         return ( $inclParam ) ? $this->uid : $this->uid['value'];
6133 6132
         break;
6134
-      case 'URL':
6133
+        case 'URL':
6135 6134
         if( !empty( $this->url['value'] )) return ( $inclParam ) ? $this->url : $this->url['value'];
6136 6135
         break;
6137
-      default:
6136
+        default:
6138 6137
         if( $propName != 'X-PROP' ) {
6139
-          if( !isset( $this->xprop[$propName] )) return FALSE;
6140
-          return ( $inclParam ) ? array( $propName, $this->xprop[$propName] )
6138
+            if( !isset( $this->xprop[$propName] )) return FALSE;
6139
+            return ( $inclParam ) ? array( $propName, $this->xprop[$propName] )
6141 6140
                                 : array( $propName, $this->xprop[$propName]['value'] );
6142 6141
         }
6143 6142
         else {
6144
-          if( empty( $this->xprop )) return FALSE;
6145
-          $xpropno = 0;
6146
-          foreach( $this->xprop as $xpropkey => $xpropvalue ) {
6143
+            if( empty( $this->xprop )) return FALSE;
6144
+            $xpropno = 0;
6145
+            foreach( $this->xprop as $xpropkey => $xpropvalue ) {
6147 6146
             if( $propix == $xpropno )
6148
-              return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
6147
+                return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
6149 6148
                                     : array( $xpropkey, $this->xprop[$xpropkey]['value'] );
6150 6149
             else
6151
-              $xpropno++;
6152
-          }
6153
-          return FALSE; // not found ??
6150
+                $xpropno++;
6151
+            }
6152
+            return FALSE; // not found ??
6154 6153
         }
6155 6154
     }
6156 6155
     return FALSE;
6157
-  }
6156
+    }
6158 6157
 /**
6159
- * general component property setting
6160
- *
6161
- * @author Kjell-Inge Gustafsson <[email protected]>
6162
- * @since 2.5.1 - 2008-11-05
6163
- * @param mixed $args variable number of function arguments,
6164
- *                    first argument is ALWAYS component name,
6165
- *                    second ALWAYS component value!
6166
- * @return void
6167
- */
6168
-  function setProperty() {
6158
+     * general component property setting
6159
+     *
6160
+     * @author Kjell-Inge Gustafsson <[email protected]>
6161
+     * @since 2.5.1 - 2008-11-05
6162
+     * @param mixed $args variable number of function arguments,
6163
+     *                    first argument is ALWAYS component name,
6164
+     *                    second ALWAYS component value!
6165
+     * @return void
6166
+     */
6167
+    function setProperty() {
6169 6168
     $numargs    = func_num_args();
6170 6169
     if( 1 > $numargs ) return FALSE;
6171 6170
     $arglist    = func_get_args();
6172 6171
     if( $this->_notExistProp( $arglist[0] )) return FALSE;
6173 6172
     if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] )))
6174
-      return FALSE;
6173
+        return FALSE;
6175 6174
     $arglist[0] = strtoupper( $arglist[0] );
6176 6175
     for( $argix=$numargs; $argix < 12; $argix++ ) {
6177
-      if( !isset( $arglist[$argix] ))
6176
+        if( !isset( $arglist[$argix] ))
6178 6177
         $arglist[$argix] = null;
6179 6178
     }
6180 6179
     switch( $arglist[0] ) {
6181
-      case 'ACTION':
6180
+        case 'ACTION':
6182 6181
         return $this->setAction( $arglist[1], $arglist[2] );
6183
-      case 'ATTACH':
6182
+        case 'ATTACH':
6184 6183
         return $this->setAttach( $arglist[1], $arglist[2], $arglist[3] );
6185
-      case 'ATTENDEE':
6184
+        case 'ATTENDEE':
6186 6185
         return $this->setAttendee( $arglist[1], $arglist[2], $arglist[3] );
6187
-      case 'CATEGORIES':
6186
+        case 'CATEGORIES':
6188 6187
         return $this->setCategories( $arglist[1], $arglist[2], $arglist[3] );
6189
-      case 'CLASS':
6188
+        case 'CLASS':
6190 6189
         return $this->setClass( $arglist[1], $arglist[2] );
6191
-      case 'COMMENT':
6190
+        case 'COMMENT':
6192 6191
         return $this->setComment( $arglist[1], $arglist[2], $arglist[3] );
6193
-      case 'COMPLETED':
6192
+        case 'COMPLETED':
6194 6193
         return $this->setCompleted( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] );
6195
-      case 'CONTACT':
6194
+        case 'CONTACT':
6196 6195
         return $this->setContact( $arglist[1], $arglist[2], $arglist[3] );
6197
-      case 'CREATED':
6196
+        case 'CREATED':
6198 6197
         return $this->setCreated( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] );
6199
-      case 'DESCRIPTION':
6198
+        case 'DESCRIPTION':
6200 6199
         return $this->setDescription( $arglist[1], $arglist[2], $arglist[3] );
6201
-      case 'DTEND':
6200
+        case 'DTEND':
6202 6201
         return $this->setDtend( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] );
6203
-      case 'DTSTAMP':
6202
+        case 'DTSTAMP':
6204 6203
         return $this->setDtstamp( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] );
6205
-      case 'DTSTART':
6204
+        case 'DTSTART':
6206 6205
         return $this->setDtstart( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] );
6207
-      case 'DUE':
6206
+        case 'DUE':
6208 6207
         return $this->setDue( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] );
6209
-      case 'DURATION':
6208
+        case 'DURATION':
6210 6209
         return $this->setDuration( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6] );
6211
-      case 'EXDATE':
6210
+        case 'EXDATE':
6212 6211
         return $this->setExdate( $arglist[1], $arglist[2], $arglist[3] );
6213
-      case 'EXRULE':
6212
+        case 'EXRULE':
6214 6213
         return $this->setExrule( $arglist[1], $arglist[2], $arglist[3] );
6215
-      case 'FREEBUSY':
6214
+        case 'FREEBUSY':
6216 6215
         return $this->setFreebusy( $arglist[1], $arglist[2], $arglist[3], $arglist[4] );
6217
-      case 'GEO':
6216
+        case 'GEO':
6218 6217
         return $this->setGeo( $arglist[1], $arglist[2], $arglist[3] );
6219
-      case 'LAST-MODIFIED':
6218
+        case 'LAST-MODIFIED':
6220 6219
         return $this->setLastModified( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] );
6221
-      case 'LOCATION':
6220
+        case 'LOCATION':
6222 6221
         return $this->setLocation( $arglist[1], $arglist[2] );
6223
-      case 'ORGANIZER':
6222
+        case 'ORGANIZER':
6224 6223
         return $this->setOrganizer( $arglist[1], $arglist[2] );
6225
-      case 'PERCENT-COMPLETE':
6224
+        case 'PERCENT-COMPLETE':
6226 6225
         return $this->setPercentComplete( $arglist[1], $arglist[2] );
6227
-      case 'PRIORITY':
6226
+        case 'PRIORITY':
6228 6227
         return $this->setPriority( $arglist[1], $arglist[2] );
6229
-      case 'RDATE':
6228
+        case 'RDATE':
6230 6229
         return $this->setRdate( $arglist[1], $arglist[2], $arglist[3] );
6231
-      case 'RECURRENCE-ID':
6230
+        case 'RECURRENCE-ID':
6232 6231
        return $this->setRecurrenceid( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] );
6233
-      case 'RELATED-TO':
6232
+        case 'RELATED-TO':
6234 6233
         return $this->setRelatedTo( $arglist[1], $arglist[2], $arglist[3] );
6235
-      case 'REPEAT':
6234
+        case 'REPEAT':
6236 6235
         return $this->setRepeat( $arglist[1], $arglist[2] );
6237
-      case 'REQUEST-STATUS':
6236
+        case 'REQUEST-STATUS':
6238 6237
         return $this->setRequestStatus( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5] );
6239
-      case 'RESOURCES':
6238
+        case 'RESOURCES':
6240 6239
         return $this->setResources( $arglist[1], $arglist[2], $arglist[3] );
6241
-      case 'RRULE':
6240
+        case 'RRULE':
6242 6241
         return $this->setRrule( $arglist[1], $arglist[2], $arglist[3] );
6243
-      case 'SEQUENCE':
6242
+        case 'SEQUENCE':
6244 6243
         return $this->setSequence( $arglist[1], $arglist[2] );
6245
-      case 'STATUS':
6244
+        case 'STATUS':
6246 6245
         return $this->setStatus( $arglist[1], $arglist[2] );
6247
-      case 'SUMMARY':
6246
+        case 'SUMMARY':
6248 6247
         return $this->setSummary( $arglist[1], $arglist[2] );
6249
-      case 'TRANSP':
6248
+        case 'TRANSP':
6250 6249
         return $this->setTransp( $arglist[1], $arglist[2] );
6251
-      case 'TRIGGER':
6250
+        case 'TRIGGER':
6252 6251
         return $this->setTrigger( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8], $arglist[9], $arglist[10], $arglist[11] );
6253
-      case 'TZID':
6252
+        case 'TZID':
6254 6253
         return $this->setTzid( $arglist[1], $arglist[2] );
6255
-      case 'TZNAME':
6254
+        case 'TZNAME':
6256 6255
         return $this->setTzname( $arglist[1], $arglist[2], $arglist[3] );
6257
-      case 'TZOFFSETFROM':
6256
+        case 'TZOFFSETFROM':
6258 6257
         return $this->setTzoffsetfrom( $arglist[1], $arglist[2] );
6259
-      case 'TZOFFSETTO':
6258
+        case 'TZOFFSETTO':
6260 6259
         return $this->setTzoffsetto( $arglist[1], $arglist[2] );
6261
-      case 'TZURL':
6260
+        case 'TZURL':
6262 6261
         return $this->setTzurl( $arglist[1], $arglist[2] );
6263
-      case 'UID':
6262
+        case 'UID':
6264 6263
         return $this->setUid( $arglist[1], $arglist[2] );
6265
-      case 'URL':
6264
+        case 'URL':
6266 6265
         return $this->setUrl( $arglist[1], $arglist[2] );
6267
-      default:
6266
+        default:
6268 6267
         return $this->setXprop( $arglist[0], $arglist[1], $arglist[2] );
6269 6268
     }
6270 6269
     return FALSE;
6271
-  }
6270
+    }
6272 6271
 /*********************************************************************************/
6273 6272
 /**
6274
- * parse component unparsed data into properties
6275
- *
6276
- * @author Kjell-Inge Gustafsson <[email protected]>
6277
- * @since 2.5.2 - 2008-10-23
6278
- * @param mixed $unparsedtext, optional, strict rfc2445 formatted, single property string or array of property strings
6279
- * @return bool FALSE if error occurs during parsing
6280
- *
6281
- */
6282
-  function parse( $unparsedtext=null ) {
6273
+     * parse component unparsed data into properties
6274
+     *
6275
+     * @author Kjell-Inge Gustafsson <[email protected]>
6276
+     * @since 2.5.2 - 2008-10-23
6277
+     * @param mixed $unparsedtext, optional, strict rfc2445 formatted, single property string or array of property strings
6278
+     * @return bool FALSE if error occurs during parsing
6279
+     *
6280
+     */
6281
+    function parse( $unparsedtext=null ) {
6283 6282
     if( $unparsedtext ) {
6284
-      $this->unparsed = array();
6285
-      if( is_array( $unparsedtext )) {
6283
+        $this->unparsed = array();
6284
+        if( is_array( $unparsedtext )) {
6286 6285
         $comp = & $this;
6287 6286
         foreach ( $unparsedtext as $line ) {
6288
-          if( 'END:VALARM' == strtoupper( substr( $line, 0, 10 ))) {
6287
+            if( 'END:VALARM' == strtoupper( substr( $line, 0, 10 ))) {
6289 6288
             $this->setComponent( $comp );
6290 6289
             $comp =  & $this;
6291 6290
             continue;
6292
-          }
6293
-          elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) {
6291
+            }
6292
+            elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) {
6294 6293
             $comp = new valarm();
6295 6294
             continue;
6296
-          }
6297
-          else
6295
+            }
6296
+            else
6298 6297
             $comp->unparsed[] = $line;
6299 6298
         }
6300
-      }
6301
-      else
6299
+        }
6300
+        else
6302 6301
         $this->unparsed = array( trim( $unparsedtext ));
6303 6302
     }
6304 6303
     elseif( !isset( $this->unparsed ))
6305
-      $this->unparsed = array();
6304
+        $this->unparsed = array();
6306 6305
             /* concatenate property values spread over several lines */
6307 6306
     $lastix    = -1;
6308 6307
     $propnames = array( 'action', 'attach', 'attendee', 'categories', 'comment', 'completed'
6309
-                      , 'contact', 'class', 'created', 'description', 'dtend', 'dtstart'
6310
-                      , 'dtstamp', 'due', 'duration', 'exdate', 'exrule', 'freebusy', 'geo'
6311
-                      , 'last-modified', 'location', 'organizer', 'percent-complete'
6312
-                      , 'priority', 'rdate', 'recurrence-id', 'related-to', 'repeat'
6313
-                      , 'request-status', 'resources', 'rrule', 'sequence', 'status'
6314
-                      , 'summary', 'transp', 'trigger', 'tzid', 'tzname', 'tzoffsetfrom'
6315
-                      , 'tzoffsetto', 'tzurl', 'uid', 'url', 'x-' );
6308
+                        , 'contact', 'class', 'created', 'description', 'dtend', 'dtstart'
6309
+                        , 'dtstamp', 'due', 'duration', 'exdate', 'exrule', 'freebusy', 'geo'
6310
+                        , 'last-modified', 'location', 'organizer', 'percent-complete'
6311
+                        , 'priority', 'rdate', 'recurrence-id', 'related-to', 'repeat'
6312
+                        , 'request-status', 'resources', 'rrule', 'sequence', 'status'
6313
+                        , 'summary', 'transp', 'trigger', 'tzid', 'tzname', 'tzoffsetfrom'
6314
+                        , 'tzoffsetto', 'tzurl', 'uid', 'url', 'x-' );
6316 6315
     $proprows  = array();
6317 6316
     foreach( $this->unparsed as $line ) {
6318
-      $newProp = FALSE;
6319
-      foreach ( $propnames as $propname ) {
6317
+        $newProp = FALSE;
6318
+        foreach ( $propnames as $propname ) {
6320 6319
         if( $propname == strtolower( substr( $line, 0, strlen( $propname )))) {
6321
-          $newProp = TRUE;
6322
-          break;
6320
+            $newProp = TRUE;
6321
+            break;
6323 6322
         }
6324
-      }
6325
-      if( $newProp ) {
6323
+        }
6324
+        if( $newProp ) {
6326 6325
         $newProp = FALSE;
6327 6326
         $lastix++;
6328 6327
         $proprows[$lastix]  = $line;
6329
-      }
6330
-      else {
6328
+        }
6329
+        else {
6331 6330
             /* remove line breaks */
6332 6331
         if(( '\n' == substr( $proprows[$lastix], -2 )) &&
6333 6332
            (  ' ' == substr( $line, 0, 1 ))) {
6334
-          $proprows[$lastix] = substr( $proprows[$lastix], 0, strlen( $proprows[$lastix] ) - 2 );
6335
-          $line = substr( $line, 1 );
6333
+            $proprows[$lastix] = substr( $proprows[$lastix], 0, strlen( $proprows[$lastix] ) - 2 );
6334
+            $line = substr( $line, 1 );
6336 6335
         }
6337 6336
         $proprows[$lastix] .= $line;
6338
-      }
6337
+        }
6339 6338
     }
6340 6339
             /* parse each property 'line' */
6341 6340
     foreach( $proprows as $line ) {
6342
-      $line = str_replace( "\n ", '', $line );
6343
-      if( '\n' == substr( $line, -2 ))
6341
+        $line = str_replace( "\n ", '', $line );
6342
+        if( '\n' == substr( $line, -2 ))
6344 6343
         $line = substr( $line, 0, strlen( $line ) - 2 );
6345 6344
             /* get propname, (problem with x-properties, otherwise in previous loop) */
6346
-      $cix = $propname = null;
6347
-      for( $cix=0; $cix < strlen( $line ); $cix++ ) {
6345
+        $cix = $propname = null;
6346
+        for( $cix=0; $cix < strlen( $line ); $cix++ ) {
6348 6347
         if( in_array( $line{$cix}, array( ':', ';' )))
6349
-          break;
6348
+            break;
6350 6349
         else {
6351
-          $propname .= $line{$cix};
6350
+            $propname .= $line{$cix};
6352 6351
         }
6353
-      }
6354
-      if(( 'x-' == substr( $propname, 0, 2 )) || ( 'X-' == substr( $propname, 0, 2 ))) {
6352
+        }
6353
+        if(( 'x-' == substr( $propname, 0, 2 )) || ( 'X-' == substr( $propname, 0, 2 ))) {
6355 6354
         $propname2 = $propname;
6356 6355
         $propname  = 'X-';
6357
-      }
6356
+        }
6358 6357
             /* rest of the line is opt.params and value */
6359
-      $line = substr( $line, $cix );
6358
+        $line = substr( $line, $cix );
6360 6359
             /* separate attributes from value */
6361
-      $attr   = array();
6362
-      $attrix = -1;
6363
-      $strlen = strlen( $line );
6364
-      for( $cix=0; $cix < $strlen; $cix++ ) {
6360
+        $attr   = array();
6361
+        $attrix = -1;
6362
+        $strlen = strlen( $line );
6363
+        for( $cix=0; $cix < $strlen; $cix++ ) {
6365 6364
         if((       ':'   == $line{$cix} )             &&
6366 6365
                  ( '://' != substr( $line, $cix, 3 )) &&
6367 6366
            ( 'mailto:'   != strtolower( substr( $line, $cix - 6, 7 )))) {
6368
-          $attrEnd = TRUE;
6369
-          if(( $cix < ( $strlen - 4 )) &&
6367
+            $attrEnd = TRUE;
6368
+            if(( $cix < ( $strlen - 4 )) &&
6370 6369
                ctype_digit( substr( $line, $cix+1, 4 ))) { // an URI with a (4pos) portnr??
6371 6370
             for( $c2ix = $cix; 3 < $c2ix; $c2ix-- ) {
6372
-              if( '://' == substr( $line, $c2ix - 2, 3 )) {
6371
+                if( '://' == substr( $line, $c2ix - 2, 3 )) {
6373 6372
                 $attrEnd = FALSE;
6374 6373
                 break; // an URI with a portnr!!
6375
-              }
6374
+                }
6376 6375
             }
6377
-          }
6378
-          if( $attrEnd) {
6376
+            }
6377
+            if( $attrEnd) {
6379 6378
             $line = substr( $line, $cix + 1 );
6380 6379
             break;
6381
-          }
6380
+            }
6382 6381
         }
6383 6382
         if( ';' == $line{$cix} )
6384
-          $attr[++$attrix] = null;
6383
+            $attr[++$attrix] = null;
6385 6384
         else
6386
-          $attr[$attrix] .= $line{$cix};
6387
-      }
6385
+            $attr[$attrix] .= $line{$cix};
6386
+        }
6388 6387
             /* make attributes in array format */
6389
-      $propattr = array();
6390
-      foreach( $attr as $attribute ) {
6388
+        $propattr = array();
6389
+        foreach( $attr as $attribute ) {
6391 6390
         $attrsplit = explode( '=', $attribute, 2 );
6392 6391
         if( 1 < count( $attrsplit ))
6393
-          $propattr[$attrsplit[0]] = $attrsplit[1];
6392
+            $propattr[$attrsplit[0]] = $attrsplit[1];
6394 6393
         else
6395
-          $propattr[] = $attribute;
6396
-      }
6394
+            $propattr[] = $attribute;
6395
+        }
6397 6396
             /* call setProperty( $propname.. . */
6398
-      switch( $propname ) {
6397
+        switch( $propname ) {
6399 6398
         case 'ATTENDEE':
6400 6399
           foreach( $propattr as $pix => $attr ) {
6401 6400
             $attr2 = explode( ',', $attr );
6402
-              if( 1 < count( $attr2 ))
6401
+                if( 1 < count( $attr2 ))
6403 6402
                 $propattr[$pix] = $attr2;
6404
-          }
6405
-          $this->setProperty( $propname, $line, $propattr );
6406
-          break;
6403
+            }
6404
+            $this->setProperty( $propname, $line, $propattr );
6405
+            break;
6407 6406
         case 'CATEGORIES':
6408 6407
         case 'RESOURCES':
6409 6408
           if( FALSE !== strpos( $line, ',' )) {
6410 6409
             $content  = explode( ',', $line );
6411 6410
             $clen     = count( $content );
6412 6411
             for( $cix = 0; $cix < $clen; $cix++ ) {
6413
-              if( "\\" == substr($content[$cix], -1)) {
6412
+                if( "\\" == substr($content[$cix], -1)) {
6414 6413
                 $content[$cix] .= ','.$content[$cix + 1];
6415 6414
                 unset($content[$cix + 1]);
6416 6415
                 $cix++;
6417
-              }
6416
+                }
6418 6417
             }
6419 6418
             if( 1 < count( $content )) {
6420
-              $content = array_values( $content );
6421
-              foreach( $content as $cix => $contentPart )
6419
+                $content = array_values( $content );
6420
+                foreach( $content as $cix => $contentPart )
6422 6421
                 $content[$cix] = $this->_strunrep( $contentPart );
6423
-              $this->setProperty( $propname, $content, $propattr );
6424
-              break;
6422
+                $this->setProperty( $propname, $content, $propattr );
6423
+                break;
6425 6424
             }
6426 6425
             else
6427
-              $line = reset( $content );
6428
-          }
6426
+                $line = reset( $content );
6427
+            }
6429 6428
         case 'X-':
6430 6429
           $propname = ( isset( $propname2 )) ? $propname2 : $propname;
6431 6430
         case 'COMMENT':
@@ -6435,482 +6434,482 @@  discard block
 block discarded – undo
6435 6434
         case 'SUMMARY':
6436 6435
           if( empty( $line ))
6437 6436
             $propattr = null;
6438
-          $this->setProperty( $propname, $this->_strunrep( $line ), $propattr );
6439
-          unset( $propname2 );
6440
-          break;
6437
+            $this->setProperty( $propname, $this->_strunrep( $line ), $propattr );
6438
+            unset( $propname2 );
6439
+            break;
6441 6440
         case 'REQUEST-STATUS':
6442 6441
           $values    = explode( ';', $line, 3 );
6443
-          $values[1] = ( !isset( $values[1] )) ? null : $this->_strunrep( $values[1] );
6444
-          $values[2] = ( !isset( $values[2] )) ? null : $this->_strunrep( $values[2] );
6445
-          $this->setProperty( $propname
6442
+            $values[1] = ( !isset( $values[1] )) ? null : $this->_strunrep( $values[1] );
6443
+            $values[2] = ( !isset( $values[2] )) ? null : $this->_strunrep( $values[2] );
6444
+            $this->setProperty( $propname
6446 6445
                             , $values[0]  // statcode
6447 6446
                             , $values[1]  // statdesc
6448 6447
                             , $values[2]  // extdata
6449 6448
                             , $propattr );
6450
-          break;
6449
+            break;
6451 6450
         case 'FREEBUSY':
6452 6451
           $fbtype = ( isset( $propattr['FBTYPE'] )) ? $propattr['FBTYPE'] : ''; // force setting default, if missing
6453
-          unset( $propattr['FBTYPE'] );
6454
-          $values = explode( ',', $line );
6455
-          foreach( $values as $vix => $value ) {
6452
+            unset( $propattr['FBTYPE'] );
6453
+            $values = explode( ',', $line );
6454
+            foreach( $values as $vix => $value ) {
6456 6455
             $value2 = explode( '/', $value );
6457 6456
             if( 1 < count( $value2 ))
6458
-              $values[$vix] = $value2;
6459
-          }
6460
-          $this->setProperty( $propname, $fbtype, $values, $propattr );
6461
-          break;
6457
+                $values[$vix] = $value2;
6458
+            }
6459
+            $this->setProperty( $propname, $fbtype, $values, $propattr );
6460
+            break;
6462 6461
         case 'GEO':
6463 6462
           $value = explode( ';', $line, 2 );
6464
-          if( 2 > count( $value ))
6463
+            if( 2 > count( $value ))
6465 6464
             $value[1] = null;
6466
-          $this->setProperty( $propname, $value[0], $value[1], $propattr );
6467
-          break;
6465
+            $this->setProperty( $propname, $value[0], $value[1], $propattr );
6466
+            break;
6468 6467
         case 'EXDATE':
6469 6468
           $values = ( !empty( $line )) ? explode( ',', $line ) : null;
6470
-          $this->setProperty( $propname, $values, $propattr );
6471
-          break;
6469
+            $this->setProperty( $propname, $values, $propattr );
6470
+            break;
6472 6471
         case 'RDATE':
6473 6472
           if( empty( $line )) {
6474 6473
             $this->setProperty( $propname, $line, $propattr );
6475 6474
             break;
6476
-          }
6477
-          $values = explode( ',', $line );
6478
-          foreach( $values as $vix => $value ) {
6475
+            }
6476
+            $values = explode( ',', $line );
6477
+            foreach( $values as $vix => $value ) {
6479 6478
             $value2 = explode( '/', $value );
6480 6479
             if( 1 < count( $value2 ))
6481
-              $values[$vix] = $value2;
6482
-          }
6483
-          $this->setProperty( $propname, $values, $propattr );
6484
-          break;
6480
+                $values[$vix] = $value2;
6481
+            }
6482
+            $this->setProperty( $propname, $values, $propattr );
6483
+            break;
6485 6484
         case 'EXRULE':
6486 6485
         case 'RRULE':
6487 6486
           $values = explode( ';', $line );
6488
-          $recur = array();
6489
-          foreach( $values as $value2 ) {
6487
+            $recur = array();
6488
+            foreach( $values as $value2 ) {
6490 6489
             if( empty( $value2 ))
6491
-              continue; // ;-char in ending position ???
6490
+                continue; // ;-char in ending position ???
6492 6491
             $value3 = explode( '=', $value2, 2 );
6493 6492
             $rulelabel = strtoupper( $value3[0] );
6494 6493
             switch( $rulelabel ) {
6495
-              case 'BYDAY': {
6494
+                case 'BYDAY': {
6496 6495
                 $value4 = explode( ',', $value3[1] );
6497 6496
                 if( 1 < count( $value4 )) {
6498
-                  foreach( $value4 as $v5ix => $value5 ) {
6497
+                    foreach( $value4 as $v5ix => $value5 ) {
6499 6498
                     $value6 = array();
6500 6499
                     $dayno = $dayname = null;
6501 6500
                     $value5 = trim( (string) $value5 );
6502 6501
                     if(( ctype_alpha( substr( $value5, -1 ))) &&
6503 6502
                        ( ctype_alpha( substr( $value5, -2, 1 )))) {
6504
-                      $dayname = substr( $value5, -2, 2 );
6505
-                      if( 2 < strlen( $value5 ))
6503
+                        $dayname = substr( $value5, -2, 2 );
6504
+                        if( 2 < strlen( $value5 ))
6506 6505
                         $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
6507 6506
                     }
6508 6507
                     if( $dayno )
6509
-                      $value6[] = $dayno;
6508
+                        $value6[] = $dayno;
6510 6509
                     if( $dayname )
6511
-                      $value6['DAY'] = $dayname;
6510
+                        $value6['DAY'] = $dayname;
6512 6511
                     $value4[$v5ix] = $value6;
6513
-                  }
6512
+                    }
6514 6513
                 }
6515 6514
                 else {
6516
-                  $value4 = array();
6517
-                  $dayno  = $dayname = null;
6518
-                  $value5 = trim( (string) $value3[1] );
6519
-                  if(( ctype_alpha( substr( $value5, -1 ))) &&
6515
+                    $value4 = array();
6516
+                    $dayno  = $dayname = null;
6517
+                    $value5 = trim( (string) $value3[1] );
6518
+                    if(( ctype_alpha( substr( $value5, -1 ))) &&
6520 6519
                      ( ctype_alpha( substr( $value5, -2, 1 )))) {
6521
-                      $dayname = substr( $value5, -2, 2 );
6520
+                        $dayname = substr( $value5, -2, 2 );
6522 6521
                     if( 2 < strlen( $value5 ))
6523
-                      $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
6524
-                  }
6525
-                  if( $dayno )
6522
+                        $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
6523
+                    }
6524
+                    if( $dayno )
6526 6525
                     $value4[] = $dayno;
6527
-                  if( $dayname )
6526
+                    if( $dayname )
6528 6527
                     $value4['DAY'] = $dayname;
6529 6528
                 }
6530 6529
                 $recur[$rulelabel] = $value4;
6531 6530
                 break;
6532
-              }
6533
-              default: {
6531
+                }
6532
+                default: {
6534 6533
                 $value4 = explode( ',', $value3[1] );
6535 6534
                 if( 1 < count( $value4 ))
6536
-                  $value3[1] = $value4;
6535
+                    $value3[1] = $value4;
6537 6536
                 $recur[$rulelabel] = $value3[1];
6538 6537
                 break;
6539
-              }
6538
+                }
6540 6539
             } // end - switch $rulelabel
6541
-          } // end - foreach( $values.. .
6542
-          $this->setProperty( $propname, $recur, $propattr );
6543
-          break;
6540
+            } // end - foreach( $values.. .
6541
+            $this->setProperty( $propname, $recur, $propattr );
6542
+            break;
6544 6543
         default:
6545 6544
           $this->setProperty( $propname, $line, $propattr );
6546
-          break;
6547
-      } // end  switch( $propname.. .
6545
+            break;
6546
+        } // end  switch( $propname.. .
6548 6547
     } // end - foreach( $proprows.. .
6549 6548
     unset( $this->unparsed, $proprows );
6550 6549
     if( isset( $this->components ) && is_array( $this->components ) && ( 0 < count( $this->components ))) {
6551
-      for( $six = 0; $six < count( $this->components ); $six++ ) {
6550
+        for( $six = 0; $six < count( $this->components ); $six++ ) {
6552 6551
         if( !empty( $this->components[$six]->unparsed ))
6553
-          $this->components[$six]->parse();
6554
-      }
6552
+            $this->components[$six]->parse();
6553
+        }
6554
+    }
6555 6555
     }
6556
-  }
6557 6556
 /*********************************************************************************/
6558 6557
 /*********************************************************************************/
6559 6558
 /**
6560
- * return a copy of this component
6561
- *
6562
- * @author Kjell-Inge Gustafsson <[email protected]>
6563
- * @since 2.2.16 - 2007-11-07
6564
- * @return object
6565
- */
6566
-  function copy() {
6559
+     * return a copy of this component
6560
+     *
6561
+     * @author Kjell-Inge Gustafsson <[email protected]>
6562
+     * @since 2.2.16 - 2007-11-07
6563
+     * @return object
6564
+     */
6565
+    function copy() {
6567 6566
     $serialized_contents = serialize($this);
6568 6567
     $copy = unserialize($serialized_contents);
6569 6568
     unset( $copy->propix );
6570 6569
     return $copy;
6571
- }
6570
+    }
6572 6571
 /*********************************************************************************/
6573 6572
 /*********************************************************************************/
6574 6573
 /**
6575
- * delete calendar subcomponent from component container
6576
- *
6577
- * @author Kjell-Inge Gustafsson <[email protected]>
6578
- * @since 2.5.1 - 2008-10-15
6579
- * @param mixed $arg1 ordno / component type / component uid
6580
- * @param mixed $arg2 optional, ordno if arg1 = component type
6581
- * @return void
6582
- */
6583
-  function deleteComponent( $arg1, $arg2=FALSE  ) {
6574
+     * delete calendar subcomponent from component container
6575
+     *
6576
+     * @author Kjell-Inge Gustafsson <[email protected]>
6577
+     * @since 2.5.1 - 2008-10-15
6578
+     * @param mixed $arg1 ordno / component type / component uid
6579
+     * @param mixed $arg2 optional, ordno if arg1 = component type
6580
+     * @return void
6581
+     */
6582
+    function deleteComponent( $arg1, $arg2=FALSE  ) {
6584 6583
     if( !isset( $this->components )) return FALSE;
6585 6584
     $argType = $index = null;
6586 6585
     if ( ctype_digit( (string) $arg1 )) {
6587
-      $argType = 'INDEX';
6588
-      $index   = (int) $arg1 - 1;
6586
+        $argType = 'INDEX';
6587
+        $index   = (int) $arg1 - 1;
6589 6588
     }
6590 6589
     elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6591
-      $argType = strtolower( $arg1 );
6592
-      $index   = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0;
6590
+        $argType = strtolower( $arg1 );
6591
+        $index   = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0;
6593 6592
     }
6594 6593
     $cix2dC = 0;
6595 6594
     foreach ( $this->components as $cix => $component) {
6596
-      if( empty( $component )) continue;
6597
-      unset( $component->propix );
6598
-      if(( 'INDEX' == $argType ) && ( $index == $cix )) {
6595
+        if( empty( $component )) continue;
6596
+        unset( $component->propix );
6597
+        if(( 'INDEX' == $argType ) && ( $index == $cix )) {
6599 6598
         unset( $this->components[$cix] );
6600 6599
         return TRUE;
6601
-      }
6602
-      elseif( $argType == $component->objName ) {
6600
+        }
6601
+        elseif( $argType == $component->objName ) {
6603 6602
         if( $index == $cix2dC ) {
6604
-          unset( $this->components[$cix] );
6605
-          return TRUE;
6603
+            unset( $this->components[$cix] );
6604
+            return TRUE;
6606 6605
         }
6607 6606
         $cix2dC++;
6608
-      }
6609
-      elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
6607
+        }
6608
+        elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
6610 6609
         unset( $this->components[$cix] );
6611 6610
         return TRUE;
6612
-      }
6611
+        }
6613 6612
     }
6614 6613
     return FALSE;
6615
-  }
6614
+    }
6616 6615
 /**
6617
- * get calendar component subcomponent from component container
6618
- *
6619
- * @author Kjell-Inge Gustafsson <[email protected]>
6620
- * @since 2.5.1 - 2008-10-15
6621
- * @param mixed $arg1 optional, ordno/component type/ component uid
6622
- * @param mixed $arg2 optional, ordno if arg1 = component type
6623
- * @return object
6624
- */
6625
-  function getComponent ( $arg1=FALSE, $arg2=FALSE ) {
6616
+     * get calendar component subcomponent from component container
6617
+     *
6618
+     * @author Kjell-Inge Gustafsson <[email protected]>
6619
+     * @since 2.5.1 - 2008-10-15
6620
+     * @param mixed $arg1 optional, ordno/component type/ component uid
6621
+     * @param mixed $arg2 optional, ordno if arg1 = component type
6622
+     * @return object
6623
+     */
6624
+    function getComponent ( $arg1=FALSE, $arg2=FALSE ) {
6626 6625
     if( !isset( $this->components )) return FALSE;
6627 6626
     $index = $argType = null;
6628 6627
     if ( !$arg1 ) {
6629
-      $argType = 'INDEX';
6630
-      $index   = $this->compix['INDEX'] =
6628
+        $argType = 'INDEX';
6629
+        $index   = $this->compix['INDEX'] =
6631 6630
         ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1;
6632 6631
     }
6633 6632
     elseif ( ctype_digit( (string) $arg1 )) {
6634
-      $argType = 'INDEX';
6635
-      $index   = (int) $arg1;
6636
-      unset( $this->compix );
6633
+        $argType = 'INDEX';
6634
+        $index   = (int) $arg1;
6635
+        unset( $this->compix );
6637 6636
     }
6638 6637
     elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6639
-      unset( $this->compix['INDEX'] );
6640
-      $argType = strtolower( $arg1 );
6641
-      if( !$arg2 )
6638
+        unset( $this->compix['INDEX'] );
6639
+        $argType = strtolower( $arg1 );
6640
+        if( !$arg2 )
6642 6641
         $index = $this->compix[$argType] =
6643 6642
         ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1;
6644
-      else
6643
+        else
6645 6644
         $index = (int) $arg2;
6646 6645
     }
6647 6646
     $index  -= 1;
6648 6647
     $ckeys = array_keys( $this->components );
6649 6648
     if( !empty( $index) && ( $index > end( $ckeys )))
6650
-      return FALSE;
6649
+        return FALSE;
6651 6650
     $cix2gC = 0;
6652 6651
     foreach( $this->components as $cix => $component ) {
6653
-      if( empty( $component )) continue;
6654
-      unset( $component->propix );
6655
-      if(( 'INDEX' == $argType ) && ( $index == $cix ))
6652
+        if( empty( $component )) continue;
6653
+        unset( $component->propix );
6654
+        if(( 'INDEX' == $argType ) && ( $index == $cix ))
6656 6655
         return $component->copy();
6657
-      elseif( $argType == $component->objName ) {
6658
-         if( $index == $cix2gC )
6659
-           return $component->copy();
6660
-         $cix2gC++;
6661
-      }
6662
-      elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) {
6656
+        elseif( $argType == $component->objName ) {
6657
+            if( $index == $cix2gC )
6658
+            return $component->copy();
6659
+            $cix2gC++;
6660
+        }
6661
+        elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) {
6663 6662
         unset( $component->propix );
6664 6663
         return $component->copy();
6665
-      }
6664
+        }
6666 6665
     }
6667 6666
             /* not found.. . */
6668 6667
     unset( $this->compix );
6669 6668
     return false;
6670
-  }
6669
+    }
6671 6670
 /**
6672
- * add calendar component as subcomponent to container for subcomponents
6673
- *
6674
- * @author Kjell-Inge Gustafsson <[email protected]>
6675
- * @since 1.x.x - 2007-04-24
6676
- * @param object $component calendar component
6677
- * @return void
6678
- */
6679
-  function addSubComponent ( $component ) {
6671
+     * add calendar component as subcomponent to container for subcomponents
6672
+     *
6673
+     * @author Kjell-Inge Gustafsson <[email protected]>
6674
+     * @since 1.x.x - 2007-04-24
6675
+     * @param object $component calendar component
6676
+     * @return void
6677
+     */
6678
+    function addSubComponent ( $component ) {
6680 6679
     $this->setComponent( $component );
6681
-  }
6680
+    }
6682 6681
 /**
6683
- * add calendar component as subcomponent to container for subcomponents
6684
- *
6685
- * @author Kjell-Inge Gustafsson <[email protected]>
6686
- * @since 2.4.13 - 2008-09-24
6687
- * @param object $component calendar component
6688
- * @param mixed $arg1 optional, ordno/component type/ component uid
6689
- * @param mixed $arg2 optional, ordno if arg1 = component type
6690
- * @return bool
6691
- */
6692
-  function setComponent( $component, $arg1=FALSE, $arg2=FALSE  ) {
6682
+     * add calendar component as subcomponent to container for subcomponents
6683
+     *
6684
+     * @author Kjell-Inge Gustafsson <[email protected]>
6685
+     * @since 2.4.13 - 2008-09-24
6686
+     * @param object $component calendar component
6687
+     * @param mixed $arg1 optional, ordno/component type/ component uid
6688
+     * @param mixed $arg2 optional, ordno if arg1 = component type
6689
+     * @return bool
6690
+     */
6691
+    function setComponent( $component, $arg1=FALSE, $arg2=FALSE  ) {
6693 6692
     if( !isset( $this->components )) return FALSE;
6694 6693
     if( '' >= $component->getConfig( 'language'))
6695
-      $component->setConfig( 'language',  $this->getConfig( 'language' ));
6694
+        $component->setConfig( 'language',  $this->getConfig( 'language' ));
6696 6695
     $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
6697 6696
     $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
6698 6697
     $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
6699 6698
     $component->setConfig( 'format',      $this->getConfig( 'format' ));
6700 6699
     if( !in_array( $component->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
6701
-      unset( $component->propix );
6700
+        unset( $component->propix );
6702 6701
             /* make sure dtstamp and uid is set */
6703
-      $dummy = $component->getProperty( 'dtstamp' );
6704
-      $dummy = $component->getProperty( 'uid' );
6702
+        $dummy = $component->getProperty( 'dtstamp' );
6703
+        $dummy = $component->getProperty( 'uid' );
6705 6704
     }
6706 6705
     if( !$arg1 ) {
6707
-      $this->components[] = $component->copy();
6708
-      return TRUE;
6706
+        $this->components[] = $component->copy();
6707
+        return TRUE;
6709 6708
     }
6710 6709
     $argType = $index = null;
6711 6710
     if ( ctype_digit( (string) $arg1 )) {
6712
-      $argType = 'INDEX';
6713
-      $index   = (int) $arg1 - 1;
6711
+        $argType = 'INDEX';
6712
+        $index   = (int) $arg1 - 1;
6714 6713
     }
6715 6714
     elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6716
-      $argType = strtolower( $arg1 );
6717
-      $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0;
6715
+        $argType = strtolower( $arg1 );
6716
+        $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0;
6718 6717
     }
6719 6718
     $cix2sC = 0;
6720 6719
     foreach ( $this->components as $cix => $component2 ) {
6721
-      if( empty( $component2 )) continue;
6722
-      unset( $component2->propix );
6723
-      if(( 'INDEX' == $argType ) && ( $index == $cix )) {
6720
+        if( empty( $component2 )) continue;
6721
+        unset( $component2->propix );
6722
+        if(( 'INDEX' == $argType ) && ( $index == $cix )) {
6724 6723
         $this->components[$cix] = $component->copy();
6725 6724
         return TRUE;
6726
-      }
6727
-      elseif( $argType == $component2->objName ) {
6725
+        }
6726
+        elseif( $argType == $component2->objName ) {
6728 6727
         if( $index == $cix2sC ) {
6729
-          $this->components[$cix] = $component->copy();
6730
-          return TRUE;
6728
+            $this->components[$cix] = $component->copy();
6729
+            return TRUE;
6731 6730
         }
6732 6731
         $cix2sC++;
6733
-      }
6734
-      elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) {
6732
+        }
6733
+        elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) {
6735 6734
         $this->components[$cix] = $component->copy();
6736 6735
         return TRUE;
6737
-      }
6736
+        }
6738 6737
     }
6739 6738
             /* not found.. . insert anyway.. .*/
6740 6739
     $this->components[] = $component->copy();
6741 6740
     return TRUE;
6742
-  }
6741
+    }
6743 6742
 /**
6744
- * creates formatted output for subcomponents
6745
- *
6746
- * @author Kjell-Inge Gustafsson <[email protected]>
6747
- * @since 2.4.10 - 2008-08-06
6748
- * @return string
6749
- */
6750
-  function createSubComponent() {
6743
+     * creates formatted output for subcomponents
6744
+     *
6745
+     * @author Kjell-Inge Gustafsson <[email protected]>
6746
+     * @since 2.4.10 - 2008-08-06
6747
+     * @return string
6748
+     */
6749
+    function createSubComponent() {
6751 6750
     $output = null;
6752 6751
     foreach( $this->components as $component ) {
6753
-      if( empty( $component )) continue;
6754
-      if( '' >= $component->getConfig( 'language'))
6752
+        if( empty( $component )) continue;
6753
+        if( '' >= $component->getConfig( 'language'))
6755 6754
         $component->setConfig( 'language',  $this->getConfig( 'language' ));
6756
-      $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
6757
-      $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
6758
-      $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
6759
-      $component->setConfig( 'format',      $this->getConfig( 'format' ));
6760
-      $output .= $component->createComponent( $this->xcaldecl );
6755
+        $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
6756
+        $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
6757
+        $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
6758
+        $component->setConfig( 'format',      $this->getConfig( 'format' ));
6759
+        $output .= $component->createComponent( $this->xcaldecl );
6761 6760
     }
6762 6761
     return $output;
6763
-  }
6762
+    }
6764 6763
 /********************************************************************************/
6765 6764
 /**
6766
- * break lines at pos 75
6767
- *
6768
- * Lines of text SHOULD NOT be longer than 75 octets, excluding the line
6769
- * break. Long content lines SHOULD be split into a multiple line
6770
- * representations using a line "folding" technique. That is, a long
6771
- * line can be split between any two characters by inserting a CRLF
6772
- * immediately followed by a single linear white space character (i.e.,
6773
- * SPACE, US-ASCII decimal 32 or HTAB, US-ASCII decimal 9). Any sequence
6774
- * of CRLF followed immediately by a single linear white space character
6775
- * is ignored (i.e., removed) when processing the content type.
6776
- *
6777
- * Edited 2007-08-26 by Anders Litzell, [email protected] to fix bug where
6778
- * the reserved expression "\n" in the arg $string could be broken up by the
6779
- * folding of lines, causing ambiguity in the return string.
6780
- * Fix uses var $breakAtChar=75 and breaks the line at $breakAtChar-1 if need be.
6781
- *
6782
- * @author Kjell-Inge Gustafsson <[email protected]>
6783
- * @since 2.2.8 - 2006-09-03
6784
- * @param string $value
6785
- * @return string
6786
- */
6787
-  function _size75( $string ) {
6765
+     * break lines at pos 75
6766
+     *
6767
+     * Lines of text SHOULD NOT be longer than 75 octets, excluding the line
6768
+     * break. Long content lines SHOULD be split into a multiple line
6769
+     * representations using a line "folding" technique. That is, a long
6770
+     * line can be split between any two characters by inserting a CRLF
6771
+     * immediately followed by a single linear white space character (i.e.,
6772
+     * SPACE, US-ASCII decimal 32 or HTAB, US-ASCII decimal 9). Any sequence
6773
+     * of CRLF followed immediately by a single linear white space character
6774
+     * is ignored (i.e., removed) when processing the content type.
6775
+     *
6776
+     * Edited 2007-08-26 by Anders Litzell, [email protected] to fix bug where
6777
+     * the reserved expression "\n" in the arg $string could be broken up by the
6778
+     * folding of lines, causing ambiguity in the return string.
6779
+     * Fix uses var $breakAtChar=75 and breaks the line at $breakAtChar-1 if need be.
6780
+     *
6781
+     * @author Kjell-Inge Gustafsson <[email protected]>
6782
+     * @since 2.2.8 - 2006-09-03
6783
+     * @param string $value
6784
+     * @return string
6785
+     */
6786
+    function _size75( $string ) {
6788 6787
     $strlen = strlen( $string );
6789 6788
     $tmp    = $string;
6790 6789
     $string = null;
6791 6790
     while( $strlen > 75 ) {
6792
-       $breakAtChar = 75;
6793
-       if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' )
6794
-         $breakAtChar = $breakAtChar - 1;
6795
-       $string .= substr( $tmp, 0, $breakAtChar );
6796
-       $string .= $this->nl;
6797
-       $tmp     = ' '.substr( $tmp, $breakAtChar );
6798
-       $strlen  = strlen( $tmp );
6791
+        $breakAtChar = 75;
6792
+        if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' )
6793
+            $breakAtChar = $breakAtChar - 1;
6794
+        $string .= substr( $tmp, 0, $breakAtChar );
6795
+        $string .= $this->nl;
6796
+        $tmp     = ' '.substr( $tmp, $breakAtChar );
6797
+        $strlen  = strlen( $tmp );
6799 6798
     } // while
6800 6799
     $string .= rtrim( $tmp ); // the rest
6801 6800
     if( $this->nl != substr( $string, ( 0 - strlen( $this->nl ))))
6802
-      $string .= $this->nl;
6801
+        $string .= $this->nl;
6803 6802
     return $string;
6804
-  }
6803
+    }
6805 6804
 /**
6806
- * special characters management output
6807
- *
6808
- * @author Kjell-Inge Gustafsson <[email protected]>
6809
- * @since 2.3.3 - 2007-12-20
6810
- * @param string $string
6811
- * @return string
6812
- */
6813
-  function _strrep( $string ) {
6805
+     * special characters management output
6806
+     *
6807
+     * @author Kjell-Inge Gustafsson <[email protected]>
6808
+     * @since 2.3.3 - 2007-12-20
6809
+     * @param string $string
6810
+     * @return string
6811
+     */
6812
+    function _strrep( $string ) {
6814 6813
     switch( $this->format ) {
6815
-      case 'xcal':
6814
+        case 'xcal':
6816 6815
         $string = str_replace( '\n',  $this->nl, $string);
6817 6816
         $string = htmlspecialchars( strip_tags( stripslashes( urldecode ( $string ))));
6818 6817
         break;
6819
-      default:
6818
+        default:
6820 6819
         $pos = 0;
6821 6820
         while( $pos <= strlen( $string )) {
6822
-          $pos = strpos( $string, "\\", $pos );
6823
-          if( FALSE === $pos )
6821
+            $pos = strpos( $string, "\\", $pos );
6822
+            if( FALSE === $pos )
6824 6823
             break;
6825
-          if( !in_array( $string{($pos + 1)}, array( 'n', 'N', 'r', ',', ';' ))) {
6824
+            if( !in_array( $string{($pos + 1)}, array( 'n', 'N', 'r', ',', ';' ))) {
6826 6825
             $string = substr( $string, 0, $pos )."\\".substr( $string, ( $pos + 1 ));
6827 6826
             $pos += 1;
6828
-          }
6829
-          $pos += 1;
6827
+            }
6828
+            $pos += 1;
6830 6829
         }
6831 6830
         if( FALSE !== strpos( $string, '"' ))
6832
-          $string = str_replace('"',   "'",       $string);
6831
+            $string = str_replace('"',   "'",       $string);
6833 6832
         if( FALSE !== strpos( $string, ',' ))
6834
-          $string = str_replace(',',   '\,',      $string);
6833
+            $string = str_replace(',',   '\,',      $string);
6835 6834
         if( FALSE !== strpos( $string, ';' ))
6836
-          $string = str_replace(';',   '\;',      $string);
6835
+            $string = str_replace(';',   '\;',      $string);
6837 6836
         if( FALSE !== strpos( $string, "\r\n" ))
6838
-          $string = str_replace( "\r\n", '\n',    $string);
6837
+            $string = str_replace( "\r\n", '\n',    $string);
6839 6838
         elseif( FALSE !== strpos( $string, "\r" ))
6840
-          $string = str_replace( "\r", '\n',      $string);
6839
+            $string = str_replace( "\r", '\n',      $string);
6841 6840
         if( FALSE !== strpos( $string, '\N' ))
6842
-          $string = str_replace( '\N', '\n',      $string);
6841
+            $string = str_replace( '\N', '\n',      $string);
6843 6842
 //        if( FALSE !== strpos( $string, $this->nl ))
6844
-          $string = str_replace( $this->nl, '\n', $string);
6843
+            $string = str_replace( $this->nl, '\n', $string);
6845 6844
         break;
6846 6845
     }
6847 6846
     return $string;
6848
-  }
6847
+    }
6849 6848
 /**
6850
- * special characters management input (from iCal file)
6851
- *
6852
- * @author Kjell-Inge Gustafsson <[email protected]>
6853
- * @since 2.3.3 - 2007-11-23
6854
- * @param string $string
6855
- * @return string
6856
- */
6857
-  function _strunrep( $string ) {
6849
+     * special characters management input (from iCal file)
6850
+     *
6851
+     * @author Kjell-Inge Gustafsson <[email protected]>
6852
+     * @since 2.3.3 - 2007-11-23
6853
+     * @param string $string
6854
+     * @return string
6855
+     */
6856
+    function _strunrep( $string ) {
6858 6857
     $string = str_replace( '\\\\', '\\',     $string);
6859 6858
     $string = str_replace( '\,',   ',',      $string);
6860 6859
     $string = str_replace( '\;',   ';',      $string);
6861 6860
 //    $string = str_replace( '\n',  $this->nl, $string); // ??
6862 6861
     return $string;
6863
-  }
6862
+    }
6864 6863
 }
6865 6864
 /*********************************************************************************/
6866 6865
 /*********************************************************************************/
6867 6866
 /**
6868
- * class for calendar component VEVENT
6869
- *
6870
- * @author Kjell-Inge Gustafsson <[email protected]>
6871
- * @since 2.5.1 - 2008-10-12
6872
- */
6867
+     * class for calendar component VEVENT
6868
+     *
6869
+     * @author Kjell-Inge Gustafsson <[email protected]>
6870
+     * @since 2.5.1 - 2008-10-12
6871
+     */
6873 6872
 class vevent extends calendarComponent {
6874
-  var $attach;
6875
-  var $attendee;
6876
-  var $categories;
6877
-  var $comment;
6878
-  var $contact;
6879
-  var $class;
6880
-  var $created;
6881
-  var $description;
6882
-  var $dtend;
6883
-  var $dtstart;
6884
-  var $duration;
6885
-  var $exdate;
6886
-  var $exrule;
6887
-  var $geo;
6888
-  var $lastmodified;
6889
-  var $location;
6890
-  var $organizer;
6891
-  var $priority;
6892
-  var $rdate;
6893
-  var $recurrenceid;
6894
-  var $relatedto;
6895
-  var $requeststatus;
6896
-  var $resources;
6897
-  var $rrule;
6898
-  var $sequence;
6899
-  var $status;
6900
-  var $summary;
6901
-  var $transp;
6902
-  var $url;
6903
-  var $xprop;
6873
+    var $attach;
6874
+    var $attendee;
6875
+    var $categories;
6876
+    var $comment;
6877
+    var $contact;
6878
+    var $class;
6879
+    var $created;
6880
+    var $description;
6881
+    var $dtend;
6882
+    var $dtstart;
6883
+    var $duration;
6884
+    var $exdate;
6885
+    var $exrule;
6886
+    var $geo;
6887
+    var $lastmodified;
6888
+    var $location;
6889
+    var $organizer;
6890
+    var $priority;
6891
+    var $rdate;
6892
+    var $recurrenceid;
6893
+    var $relatedto;
6894
+    var $requeststatus;
6895
+    var $resources;
6896
+    var $rrule;
6897
+    var $sequence;
6898
+    var $status;
6899
+    var $summary;
6900
+    var $transp;
6901
+    var $url;
6902
+    var $xprop;
6904 6903
             //  component subcomponents container
6905
-  var $components;
6906
-/**
6907
- * constructor for calendar component VEVENT object
6908
- *
6909
- * @author Kjell-Inge Gustafsson <[email protected]>
6910
- * @since 2.5.1 - 2008-10-31
6911
- * @return void
6912
- */
6913
-  function vevent() {
6904
+    var $components;
6905
+/**
6906
+     * constructor for calendar component VEVENT object
6907
+     *
6908
+     * @author Kjell-Inge Gustafsson <[email protected]>
6909
+     * @since 2.5.1 - 2008-10-31
6910
+     * @return void
6911
+     */
6912
+    function vevent() {
6914 6913
     $this->calendarComponent();
6915 6914
 
6916 6915
     $this->attach          = '';
@@ -6946,16 +6945,16 @@  discard block
 block discarded – undo
6946 6945
 
6947 6946
     $this->components      = array();
6948 6947
 
6949
-  }
6948
+    }
6950 6949
 /**
6951
- * create formatted output for calendar component VEVENT object instance
6952
- *
6953
- * @author Kjell-Inge Gustafsson <[email protected]>
6954
- * @since 2.5.1 - 2008-11-07
6955
- * @param array $xcaldecl
6956
- * @return string
6957
- */
6958
-  function createComponent( &$xcaldecl ) {
6950
+     * create formatted output for calendar component VEVENT object instance
6951
+     *
6952
+     * @author Kjell-Inge Gustafsson <[email protected]>
6953
+     * @since 2.5.1 - 2008-11-07
6954
+     * @param array $xcaldecl
6955
+     * @return string
6956
+     */
6957
+    function createComponent( &$xcaldecl ) {
6959 6958
     $objectname    = $this->_createFormat();
6960 6959
     $component     = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
6961 6960
     $component    .= $this->createUid();
@@ -6993,62 +6992,62 @@  discard block
 block discarded – undo
6993 6992
     $component    .= $this->createSubComponent();
6994 6993
     $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
6995 6994
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
6996
-      foreach( $this->xcaldecl as $localxcaldecl )
6995
+        foreach( $this->xcaldecl as $localxcaldecl )
6997 6996
         $xcaldecl[] = $localxcaldecl;
6998 6997
     }
6999 6998
     return $component;
7000
-  }
6999
+    }
7001 7000
 }
7002 7001
 /*********************************************************************************/
7003 7002
 /*********************************************************************************/
7004 7003
 /**
7005
- * class for calendar component VTODO
7006
- *
7007
- * @author Kjell-Inge Gustafsson <[email protected]>
7008
- * @since 2.5.1 - 2008-10-12
7009
- */
7004
+     * class for calendar component VTODO
7005
+     *
7006
+     * @author Kjell-Inge Gustafsson <[email protected]>
7007
+     * @since 2.5.1 - 2008-10-12
7008
+     */
7010 7009
 class vtodo extends calendarComponent {
7011
-  var $attach;
7012
-  var $attendee;
7013
-  var $categories;
7014
-  var $comment;
7015
-  var $completed;
7016
-  var $contact;
7017
-  var $class;
7018
-  var $created;
7019
-  var $description;
7020
-  var $dtstart;
7021
-  var $due;
7022
-  var $duration;
7023
-  var $exdate;
7024
-  var $exrule;
7025
-  var $geo;
7026
-  var $lastmodified;
7027
-  var $location;
7028
-  var $organizer;
7029
-  var $percentcomplete;
7030
-  var $priority;
7031
-  var $rdate;
7032
-  var $recurrenceid;
7033
-  var $relatedto;
7034
-  var $requeststatus;
7035
-  var $resources;
7036
-  var $rrule;
7037
-  var $sequence;
7038
-  var $status;
7039
-  var $summary;
7040
-  var $url;
7041
-  var $xprop;
7010
+    var $attach;
7011
+    var $attendee;
7012
+    var $categories;
7013
+    var $comment;
7014
+    var $completed;
7015
+    var $contact;
7016
+    var $class;
7017
+    var $created;
7018
+    var $description;
7019
+    var $dtstart;
7020
+    var $due;
7021
+    var $duration;
7022
+    var $exdate;
7023
+    var $exrule;
7024
+    var $geo;
7025
+    var $lastmodified;
7026
+    var $location;
7027
+    var $organizer;
7028
+    var $percentcomplete;
7029
+    var $priority;
7030
+    var $rdate;
7031
+    var $recurrenceid;
7032
+    var $relatedto;
7033
+    var $requeststatus;
7034
+    var $resources;
7035
+    var $rrule;
7036
+    var $sequence;
7037
+    var $status;
7038
+    var $summary;
7039
+    var $url;
7040
+    var $xprop;
7042 7041
             //  component subcomponents container
7043
-  var $components;
7044
-/**
7045
- * constructor for calendar component VTODO object
7046
- *
7047
- * @author Kjell-Inge Gustafsson <[email protected]>
7048
- * @since 2.5.1 - 2008-10-31
7049
- * @return void
7050
- */
7051
-  function vtodo() {
7042
+    var $components;
7043
+/**
7044
+     * constructor for calendar component VTODO object
7045
+     *
7046
+     * @author Kjell-Inge Gustafsson <[email protected]>
7047
+     * @since 2.5.1 - 2008-10-31
7048
+     * @return void
7049
+     */
7050
+    function vtodo() {
7052 7051
     $this->calendarComponent();
7053 7052
 
7054 7053
     $this->attach          = '';
@@ -7084,16 +7083,16 @@  discard block
 block discarded – undo
7084 7083
     $this->xprop           = '';
7085 7084
 
7086 7085
     $this->components      = array();
7087
-  }
7086
+    }
7088 7087
 /**
7089
- * create formatted output for calendar component VTODO object instance
7090
- *
7091
- * @author Kjell-Inge Gustafsson <[email protected]>
7092
- * @since 2.5.1 - 2008-11-07
7093
- * @param array $xcaldecl
7094
- * @return string
7095
- */
7096
-  function createComponent( &$xcaldecl ) {
7088
+     * create formatted output for calendar component VTODO object instance
7089
+     *
7090
+     * @author Kjell-Inge Gustafsson <[email protected]>
7091
+     * @since 2.5.1 - 2008-11-07
7092
+     * @param array $xcaldecl
7093
+     * @return string
7094
+     */
7095
+    function createComponent( &$xcaldecl ) {
7097 7096
     $objectname    = $this->_createFormat();
7098 7097
     $component     = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
7099 7098
     $component    .= $this->createUid();
@@ -7132,52 +7131,52 @@  discard block
 block discarded – undo
7132 7131
     $component    .= $this->createSubComponent();
7133 7132
     $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
7134 7133
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7135
-      foreach( $this->xcaldecl as $localxcaldecl )
7134
+        foreach( $this->xcaldecl as $localxcaldecl )
7136 7135
         $xcaldecl[] = $localxcaldecl;
7137 7136
     }
7138 7137
     return $component;
7139
-  }
7138
+    }
7140 7139
 }
7141 7140
 /*********************************************************************************/
7142 7141
 /*********************************************************************************/
7143 7142
 /**
7144
- * class for calendar component VJOURNAL
7145
- *
7146
- * @author Kjell-Inge Gustafsson <[email protected]>
7147
- * @since 2.5.1 - 2008-10-12
7148
- */
7143
+     * class for calendar component VJOURNAL
7144
+     *
7145
+     * @author Kjell-Inge Gustafsson <[email protected]>
7146
+     * @since 2.5.1 - 2008-10-12
7147
+     */
7149 7148
 class vjournal extends calendarComponent {
7150
-  var $attach;
7151
-  var $attendee;
7152
-  var $categories;
7153
-  var $comment;
7154
-  var $contact;
7155
-  var $class;
7156
-  var $created;
7157
-  var $description;
7158
-  var $dtstart;
7159
-  var $exdate;
7160
-  var $exrule;
7161
-  var $lastmodified;
7162
-  var $organizer;
7163
-  var $rdate;
7164
-  var $recurrenceid;
7165
-  var $relatedto;
7166
-  var $requeststatus;
7167
-  var $rrule;
7168
-  var $sequence;
7169
-  var $status;
7170
-  var $summary;
7171
-  var $url;
7172
-  var $xprop;
7173
-/**
7174
- * constructor for calendar component VJOURNAL object
7175
- *
7176
- * @author Kjell-Inge Gustafsson <[email protected]>
7177
- * @since 2.5.1 - 2008-10-31
7178
- * @return void
7179
- */
7180
-  function vjournal() {
7149
+    var $attach;
7150
+    var $attendee;
7151
+    var $categories;
7152
+    var $comment;
7153
+    var $contact;
7154
+    var $class;
7155
+    var $created;
7156
+    var $description;
7157
+    var $dtstart;
7158
+    var $exdate;
7159
+    var $exrule;
7160
+    var $lastmodified;
7161
+    var $organizer;
7162
+    var $rdate;
7163
+    var $recurrenceid;
7164
+    var $relatedto;
7165
+    var $requeststatus;
7166
+    var $rrule;
7167
+    var $sequence;
7168
+    var $status;
7169
+    var $summary;
7170
+    var $url;
7171
+    var $xprop;
7172
+/**
7173
+     * constructor for calendar component VJOURNAL object
7174
+     *
7175
+     * @author Kjell-Inge Gustafsson <[email protected]>
7176
+     * @since 2.5.1 - 2008-10-31
7177
+     * @return void
7178
+     */
7179
+    function vjournal() {
7181 7180
     $this->calendarComponent();
7182 7181
 
7183 7182
     $this->attach          = '';
@@ -7203,16 +7202,16 @@  discard block
 block discarded – undo
7203 7202
     $this->summary         = '';
7204 7203
     $this->url             = '';
7205 7204
     $this->xprop           = '';
7206
-  }
7205
+    }
7207 7206
 /**
7208
- * create formatted output for calendar component VJOURNAL object instance
7209
- *
7210
- * @author Kjell-Inge Gustafsson <[email protected]>
7211
- * @since 2.5.1 - 2008-10-12
7212
- * @param array $xcaldecl
7213
- * @return string
7214
- */
7215
-  function createComponent( &$xcaldecl ) {
7207
+     * create formatted output for calendar component VJOURNAL object instance
7208
+     *
7209
+     * @author Kjell-Inge Gustafsson <[email protected]>
7210
+     * @since 2.5.1 - 2008-10-12
7211
+     * @param array $xcaldecl
7212
+     * @return string
7213
+     */
7214
+    function createComponent( &$xcaldecl ) {
7216 7215
     $objectname = $this->_createFormat();
7217 7216
     $component  = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
7218 7217
     $component .= $this->createUid();
@@ -7242,42 +7241,42 @@  discard block
 block discarded – undo
7242 7241
     $component .= $this->createXprop();
7243 7242
     $component .= $this->componentEnd1.$objectname.$this->componentEnd2;
7244 7243
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7245
-      foreach( $this->xcaldecl as $localxcaldecl )
7244
+        foreach( $this->xcaldecl as $localxcaldecl )
7246 7245
         $xcaldecl[] = $localxcaldecl;
7247 7246
     }
7248 7247
     return $component;
7249
-  }
7248
+    }
7250 7249
 }
7251 7250
 /*********************************************************************************/
7252 7251
 /*********************************************************************************/
7253 7252
 /**
7254
- * class for calendar component VFREEBUSY
7255
- *
7256
- * @author Kjell-Inge Gustafsson <[email protected]>
7257
- * @since 2.5.1 - 2008-10-12
7258
- */
7253
+     * class for calendar component VFREEBUSY
7254
+     *
7255
+     * @author Kjell-Inge Gustafsson <[email protected]>
7256
+     * @since 2.5.1 - 2008-10-12
7257
+     */
7259 7258
 class vfreebusy extends calendarComponent {
7260
-  var $attendee;
7261
-  var $comment;
7262
-  var $contact;
7263
-  var $dtend;
7264
-  var $dtstart;
7265
-  var $duration;
7266
-  var $freebusy;
7267
-  var $organizer;
7268
-  var $requeststatus;
7269
-  var $url;
7270
-  var $xprop;
7259
+    var $attendee;
7260
+    var $comment;
7261
+    var $contact;
7262
+    var $dtend;
7263
+    var $dtstart;
7264
+    var $duration;
7265
+    var $freebusy;
7266
+    var $organizer;
7267
+    var $requeststatus;
7268
+    var $url;
7269
+    var $xprop;
7271 7270
             //  component subcomponents container
7272
-  var $components;
7273
-/**
7274
- * constructor for calendar component VFREEBUSY object
7275
- *
7276
- * @author Kjell-Inge Gustafsson <[email protected]>
7277
- * @since 2.5.1 - 2008-10-31
7278
- * @return void
7279
- */
7280
-  function vfreebusy() {
7271
+    var $components;
7272
+/**
7273
+     * constructor for calendar component VFREEBUSY object
7274
+     *
7275
+     * @author Kjell-Inge Gustafsson <[email protected]>
7276
+     * @since 2.5.1 - 2008-10-31
7277
+     * @return void
7278
+     */
7279
+    function vfreebusy() {
7281 7280
     $this->calendarComponent();
7282 7281
 
7283 7282
     $this->attendee        = '';
@@ -7291,16 +7290,16 @@  discard block
 block discarded – undo
7291 7290
     $this->requeststatus   = '';
7292 7291
     $this->url             = '';
7293 7292
     $this->xprop           = '';
7294
-  }
7293
+    }
7295 7294
 /**
7296
- * create formatted output for calendar component VFREEBUSY object instance
7297
- *
7298
- * @author Kjell-Inge Gustafsson <[email protected]>
7299
- * @since 2.3.1 - 2007-11-19
7300
- * @param array $xcaldecl
7301
- * @return string
7302
- */
7303
-  function createComponent( &$xcaldecl ) {
7295
+     * create formatted output for calendar component VFREEBUSY object instance
7296
+     *
7297
+     * @author Kjell-Inge Gustafsson <[email protected]>
7298
+     * @since 2.3.1 - 2007-11-19
7299
+     * @param array $xcaldecl
7300
+     * @return string
7301
+     */
7302
+    function createComponent( &$xcaldecl ) {
7304 7303
     $objectname = $this->_createFormat();
7305 7304
     $component  = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
7306 7305
     $component .= $this->createUid();
@@ -7318,38 +7317,38 @@  discard block
 block discarded – undo
7318 7317
     $component .= $this->createXprop();
7319 7318
     $component .= $this->componentEnd1.$objectname.$this->componentEnd2;
7320 7319
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7321
-      foreach( $this->xcaldecl as $localxcaldecl )
7320
+        foreach( $this->xcaldecl as $localxcaldecl )
7322 7321
         $xcaldecl[] = $localxcaldecl;
7323 7322
     }
7324 7323
     return $component;
7325
-  }
7324
+    }
7326 7325
 }
7327 7326
 /*********************************************************************************/
7328 7327
 /*********************************************************************************/
7329 7328
 /**
7330
- * class for calendar component VALARM
7331
- *
7332
- * @author Kjell-Inge Gustafsson <[email protected]>
7333
- * @since 2.5.1 - 2008-10-12
7334
- */
7329
+     * class for calendar component VALARM
7330
+     *
7331
+     * @author Kjell-Inge Gustafsson <[email protected]>
7332
+     * @since 2.5.1 - 2008-10-12
7333
+     */
7335 7334
 class valarm extends calendarComponent {
7336
-  var $action;
7337
-  var $attach;
7338
-  var $attendee;
7339
-  var $description;
7340
-  var $duration;
7341
-  var $repeat;
7342
-  var $summary;
7343
-  var $trigger;
7344
-  var $xprop;
7345
-/**
7346
- * constructor for calendar component VALARM object
7347
- *
7348
- * @author Kjell-Inge Gustafsson <[email protected]>
7349
- * @since 2.5.1 - 2008-10-31
7350
- * @return void
7351
- */
7352
-  function valarm() {
7335
+    var $action;
7336
+    var $attach;
7337
+    var $attendee;
7338
+    var $description;
7339
+    var $duration;
7340
+    var $repeat;
7341
+    var $summary;
7342
+    var $trigger;
7343
+    var $xprop;
7344
+/**
7345
+     * constructor for calendar component VALARM object
7346
+     *
7347
+     * @author Kjell-Inge Gustafsson <[email protected]>
7348
+     * @since 2.5.1 - 2008-10-31
7349
+     * @return void
7350
+     */
7351
+    function valarm() {
7353 7352
     $this->calendarComponent();
7354 7353
 
7355 7354
     $this->action          = '';
@@ -7361,16 +7360,16 @@  discard block
 block discarded – undo
7361 7360
     $this->summary         = '';
7362 7361
     $this->trigger         = '';
7363 7362
     $this->xprop           = '';
7364
-  }
7363
+    }
7365 7364
 /**
7366
- * create formatted output for calendar component VALARM object instance
7367
- *
7368
- * @author Kjell-Inge Gustafsson <[email protected]>
7369
- * @since 2.5.1 - 2008-10-22
7370
- * @param array $xcaldecl
7371
- * @return string
7372
- */
7373
-  function createComponent( &$xcaldecl ) {
7365
+     * create formatted output for calendar component VALARM object instance
7366
+     *
7367
+     * @author Kjell-Inge Gustafsson <[email protected]>
7368
+     * @since 2.5.1 - 2008-10-22
7369
+     * @param array $xcaldecl
7370
+     * @return string
7371
+     */
7372
+    function createComponent( &$xcaldecl ) {
7374 7373
     $objectname    = $this->_createFormat();
7375 7374
     $component     = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
7376 7375
     $component    .= $this->createAction();
@@ -7384,45 +7383,45 @@  discard block
 block discarded – undo
7384 7383
     $component    .= $this->createXprop();
7385 7384
     $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
7386 7385
     return $component;
7387
-  }
7386
+    }
7388 7387
 }
7389 7388
 /**********************************************************************************
7390 7389
 /*********************************************************************************/
7391 7390
 /**
7392
- * class for calendar component VTIMEZONE
7393
- *
7394
- * @author Kjell-Inge Gustafsson <[email protected]>
7395
- * @since 2.5.1 - 2008-10-12
7396
- */
7391
+     * class for calendar component VTIMEZONE
7392
+     *
7393
+     * @author Kjell-Inge Gustafsson <[email protected]>
7394
+     * @since 2.5.1 - 2008-10-12
7395
+     */
7397 7396
 class vtimezone extends calendarComponent {
7398
-  var $timezonetype;
7397
+    var $timezonetype;
7399 7398
 
7400
-  var $comment;
7401
-  var $dtstart;
7402
-  var $lastmodified;
7403
-  var $rdate;
7404
-  var $rrule;
7405
-  var $tzid;
7406
-  var $tzname;
7407
-  var $tzoffsetfrom;
7408
-  var $tzoffsetto;
7409
-  var $tzurl;
7410
-  var $xprop;
7399
+    var $comment;
7400
+    var $dtstart;
7401
+    var $lastmodified;
7402
+    var $rdate;
7403
+    var $rrule;
7404
+    var $tzid;
7405
+    var $tzname;
7406
+    var $tzoffsetfrom;
7407
+    var $tzoffsetto;
7408
+    var $tzurl;
7409
+    var $xprop;
7411 7410
             //  component subcomponents container
7412
-  var $components;
7413
-/**
7414
- * constructor for calendar component VTIMEZONE object
7415
- *
7416
- * @author Kjell-Inge Gustafsson <[email protected]>
7417
- * @since 2.5.1 - 2008-10-31
7418
- * @param string $timezonetype optional, default FALSE ( STANDARD / DAYLIGHT )
7419
- * @return void
7420
- */
7421
-  function vtimezone( $timezonetype=FALSE ) {
7411
+    var $components;
7412
+/**
7413
+     * constructor for calendar component VTIMEZONE object
7414
+     *
7415
+     * @author Kjell-Inge Gustafsson <[email protected]>
7416
+     * @since 2.5.1 - 2008-10-31
7417
+     * @param string $timezonetype optional, default FALSE ( STANDARD / DAYLIGHT )
7418
+     * @return void
7419
+     */
7420
+    function vtimezone( $timezonetype=FALSE ) {
7422 7421
     if( !$timezonetype )
7423
-      $this->timezonetype = 'VTIMEZONE';
7422
+        $this->timezonetype = 'VTIMEZONE';
7424 7423
     else
7425
-      $this->timezonetype = strtoupper( $timezonetype );
7424
+        $this->timezonetype = strtoupper( $timezonetype );
7426 7425
     $this->calendarComponent();
7427 7426
 
7428 7427
     $this->comment         = '';
@@ -7438,16 +7437,16 @@  discard block
 block discarded – undo
7438 7437
     $this->xprop           = '';
7439 7438
 
7440 7439
     $this->components      = array();
7441
-  }
7440
+    }
7442 7441
 /**
7443
- * create formatted output for calendar component VTIMEZONE object instance
7444
- *
7445
- * @author Kjell-Inge Gustafsson <[email protected]>
7446
- * @since 2.5.1 - 2008-10-25
7447
- * @param array $xcaldecl
7448
- * @return string
7449
- */
7450
-  function createComponent( &$xcaldecl ) {
7442
+     * create formatted output for calendar component VTIMEZONE object instance
7443
+     *
7444
+     * @author Kjell-Inge Gustafsson <[email protected]>
7445
+     * @since 2.5.1 - 2008-10-25
7446
+     * @param array $xcaldecl
7447
+     * @return string
7448
+     */
7449
+    function createComponent( &$xcaldecl ) {
7451 7450
     $objectname    = $this->_createFormat();
7452 7451
     $component     = $this->componentStart1.$objectname.$this->componentStart2.$this->nl;
7453 7452
     $component    .= $this->createTzid();
@@ -7464,10 +7463,10 @@  discard block
 block discarded – undo
7464 7463
     $component    .= $this->createSubComponent();
7465 7464
     $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
7466 7465
     if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7467
-      foreach( $this->xcaldecl as $localxcaldecl )
7466
+        foreach( $this->xcaldecl as $localxcaldecl )
7468 7467
         $xcaldecl[] = $localxcaldecl;
7469 7468
     }
7470 7469
     return $component;
7471
-  }
7470
+    }
7472 7471
 }
7473 7472
 ?>
7474 7473
\ No newline at end of file
Please login to merge, or discard this patch.
main/inc/lib/add_many_session_to_category_functions.lib.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 /**
4
- * Definition of the AddManySessionToCategoryFunctions class
5
- * @package chamilo.library
6
- */
4
+     * Definition of the AddManySessionToCategoryFunctions class
5
+     * @package chamilo.library
6
+     */
7 7
 /**
8
- * Requires
9
- */
8
+     * Requires
9
+     */
10 10
 require_once ('xajax/xajax.inc.php');
11 11
 /**
12
- * AddManySessionToCategoryFunctions class
13
- */
12
+     * AddManySessionToCategoryFunctions class
13
+     */
14 14
 class AddManySessionToCategoryFunctions
15 15
 {
16 16
     /**
@@ -24,28 +24,28 @@  discard block
 block discarded – undo
24 24
     function search_courses($needle,$type)
25 25
     {
26 26
         $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
27
-		$xajax_response = new xajaxResponse();
28
-		$return = '';
29
-		if(!empty($needle) && !empty($type)) {
30
-			// xajax send utf8 datas... datas in db can be non-utf8 datas
31
-			$charset = api_get_system_encoding();
32
-			$needle = api_convert_encoding($needle, $charset, 'utf-8');
33
-			$needle = Database::escape_string($needle);
27
+        $xajax_response = new xajaxResponse();
28
+        $return = '';
29
+        if(!empty($needle) && !empty($type)) {
30
+            // xajax send utf8 datas... datas in db can be non-utf8 datas
31
+            $charset = api_get_system_encoding();
32
+            $needle = api_convert_encoding($needle, $charset, 'utf-8');
33
+            $needle = Database::escape_string($needle);
34 34
 
35
-			$sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id';
35
+            $sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id';
36 36
 
37
-			$rs = Database::query($sql);
38
-			$course_list = array();
37
+            $rs = Database::query($sql);
38
+            $course_list = array();
39 39
 
40
-			$return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">';
41
-			while($course = Database :: fetch_array($rs)) {
42
-				$course_list[] = $course['id'];
43
-				$return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>';
44
-			}
45
-			$return .= '</select>';
46
-			$xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return));
47
-		}
48
-		$_SESSION['course_list'] = $course_list;
49
-		return $xajax_response;
50
-	}
40
+            $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">';
41
+            while($course = Database :: fetch_array($rs)) {
42
+                $course_list[] = $course['id'];
43
+                $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>';
44
+            }
45
+            $return .= '</select>';
46
+            $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return));
47
+        }
48
+        $_SESSION['course_list'] = $course_list;
49
+        return $xajax_response;
50
+    }
51 51
 }
Please login to merge, or discard this patch.
main/inc/lib/statistics.lib.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -666,7 +666,7 @@
 block discarded – undo
666 666
         $res = Database::query($sql);
667 667
         $count1 = Database::fetch_object($res);
668 668
         $sql = "SELECT COUNT(*) AS n FROM $user_table as u $table ".
669
-               "WHERE LENGTH(picture_uri) > 0 $url_condition2";
669
+                "WHERE LENGTH(picture_uri) > 0 $url_condition2";
670 670
         $res = Database::query($sql);
671 671
         $count2 = Database::fetch_object($res);
672 672
         // #users without picture
Please login to merge, or discard this patch.
main/inc/lib/opengraph/OpenGraph.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
 
19 19
 class OpenGraph implements Iterator
20 20
 {
21
-  /**
22
-   * There are base schema's based on type, this is just
23
-   * a map so that the schema can be obtained
24
-   *
25
-   */
21
+    /**
22
+     * There are base schema's based on type, this is just
23
+     * a map so that the schema can be obtained
24
+     *
25
+     */
26 26
     public static $TYPES = array(
27 27
         'activity' => array('activity', 'sport'),
28 28
         'business' => array('bar', 'company', 'cafe', 'hotel', 'restaurant'),
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
         'website' => array('blog', 'website'),
35 35
     );
36 36
 
37
-  /**
38
-   * Holds all the Open Graph values we've parsed from a page
39
-   *
40
-   */
37
+    /**
38
+     * Holds all the Open Graph values we've parsed from a page
39
+     *
40
+     */
41 41
     private $_values = array();
42 42
 
43
-  /**
44
-   * Fetches a URI and parses it for Open Graph data, returns
45
-   * false on error.
46
-   *
47
-   * @param $URI    URI to page to parse for Open Graph data
48
-   * @return OpenGraph
49
-   */
43
+    /**
44
+     * Fetches a URI and parses it for Open Graph data, returns
45
+     * false on error.
46
+     *
47
+     * @param $URI    URI to page to parse for Open Graph data
48
+     * @return OpenGraph
49
+     */
50 50
     static public function fetch($URI) {
51 51
         $curl = curl_init($URI);
52 52
 
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
         }
70 70
     }
71 71
 
72
-  /**
73
-   * Parses HTML and extracts Open Graph data, this assumes
74
-   * the document is at least well formed.
75
-   *
76
-   * @param $HTML    HTML to parse
77
-   * @return OpenGraph
78
-   */
72
+    /**
73
+     * Parses HTML and extracts Open Graph data, this assumes
74
+     * the document is at least well formed.
75
+     *
76
+     * @param $HTML    HTML to parse
77
+     * @return OpenGraph
78
+     */
79 79
     static private function _parse($HTML) {
80 80
         $old_libxml_error = libxml_use_internal_errors(true);
81 81
 
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
         return $page;
141 141
     }
142 142
 
143
-  /**
144
-   * Helper method to access attributes directly
145
-   * Example:
146
-   * $graph->title
147
-   *
148
-   * @param $key    Key to fetch from the lookup
149
-   */
143
+    /**
144
+     * Helper method to access attributes directly
145
+     * Example:
146
+     * $graph->title
147
+     *
148
+     * @param $key    Key to fetch from the lookup
149
+     */
150 150
     public function __get($key) {
151 151
         if (array_key_exists($key, $this->_values)) {
152 152
             return $this->_values[$key];
@@ -161,29 +161,29 @@  discard block
 block discarded – undo
161 161
         }
162 162
     }
163 163
 
164
-  /**
165
-   * Return all the keys found on the page
166
-   *
167
-   * @return array
168
-   */
164
+    /**
165
+     * Return all the keys found on the page
166
+     *
167
+     * @return array
168
+     */
169 169
     public function keys() {
170 170
         return array_keys($this->_values);
171 171
     }
172 172
 
173
-  /**
174
-   * Helper method to check an attribute exists
175
-   *
176
-   * @param $key
177
-   */
173
+    /**
174
+     * Helper method to check an attribute exists
175
+     *
176
+     * @param $key
177
+     */
178 178
     public function __isset($key) {
179 179
         return array_key_exists($key, $this->_values);
180 180
     }
181 181
 
182
-  /**
183
-   * Will return true if the page has location data embedded
184
-   *
185
-   * @return boolean Check if the page has location data
186
-   */
182
+    /**
183
+     * Will return true if the page has location data embedded
184
+     *
185
+     * @return boolean Check if the page has location data
186
+     */
187 187
     public function hasLocation() {
188 188
         if (array_key_exists('latitude', $this->_values) && array_key_exists('longitude', $this->_values)) {
189 189
             return true;
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
         return $valid_address;
198 198
     }
199 199
 
200
-  /**
201
-   * Iterator code
202
-   */
200
+    /**
201
+     * Iterator code
202
+     */
203 203
     private $_position = 0;
204 204
     public function rewind() { reset($this->_values); $this->_position = 0; }
205 205
     public function current() { return current($this->_values); }
Please login to merge, or discard this patch.