Test Setup Failed
Push — master ( 12c298...4a14e0 )
by Ralf
22:03
created
api/src/Etemplate/Widget/Nextmatch/Customfilter.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
 	 * @param string $cname
30 30
 	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
31 31
 	 */
32
-	public function beforeSendToClient($cname, array $expand=null)
32
+	public function beforeSendToClient($cname, array $expand = null)
33 33
 	{
34
-		switch($this->attrs['type'])
34
+		switch ($this->attrs['type'])
35 35
 		{
36 36
 			case "link-entry":
37 37
 				self::$transformation['type'] = $this->attrs['type'] = 'nextmatch-entryheader';
38 38
 				break;
39 39
 			default:
40
-				list($type) = explode('-',$this->attrs['type']);
41
-				if($type == 'select')
40
+				list($type) = explode('-', $this->attrs['type']);
41
+				if ($type == 'select')
42 42
 				{
43
-					if(in_array($this->attrs['type'], Widget\Select::$cached_types))
43
+					if (in_array($this->attrs['type'], Widget\Select::$cached_types))
44 44
 					{
45 45
 						$widget_type = $this->attrs['type'];
46 46
 					}
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		$this->setElementAttribute($form_name, 'options', trim($this->attrs['widget_options']) != '' ? $this->attrs['widget_options'] : '');
54 54
 
55 55
 		$this->setElementAttribute($form_name, 'type', $this->attrs['type']);
56
-		if($widget_type)
56
+		if ($widget_type)
57 57
 		{
58 58
 			$this->setElementAttribute($form_name, 'widget_type', $widget_type);
59 59
 		}
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
 	 * @param array $content
70 70
 	 * @param array &$validated=array() validated content
71 71
 	 */
72
-	public function validate($cname, array $expand, array $content, &$validated=array())
72
+	public function validate($cname, array $expand, array $content, &$validated = array())
73 73
 	{
74 74
 		$value = $value_in = self::get_array($content, $form_name);
75 75
 
76
-		$valid =& self::get_array($validated, $form_name, true);
76
+		$valid = & self::get_array($validated, $form_name, true);
77 77
 		// returning null instead of array(), as array() will be overwritten by etemplate_new::complete_array_merge()
78 78
 		// with preserved old content and therefore user can not empty a taglist
79 79
 		$valid = $value ? $value : null;
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/File.php 4 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -238,10 +238,10 @@
 block discarded – undo
238 238
 	}
239 239
 
240 240
 	/**
241
-	* Delete a directory RECURSIVELY
242
-	* @param string $dir - directory path
243
-	* @link http://php.net/manual/en/function.rmdir.php
244
-	*/
241
+	 * Delete a directory RECURSIVELY
242
+	 * @param string $dir - directory path
243
+	 * @link http://php.net/manual/en/function.rmdir.php
244
+	 */
245 245
 	private static function rrmdir($dir)
246 246
 	{
247 247
 		if (is_dir($dir))
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@
 block discarded – undo
116 116
 	/**
117 117
 	 * Process one uploaded file.  There should only be one per request...
118 118
 	 */
119
-	protected static function process_uploaded_file($field, Array &$file, $mime, Array &$file_data)
119
+	protected static function process_uploaded_file($field, array &$file, $mime, array &$file_data)
120 120
 	{
121 121
 		unset($field);	// not used
122 122
 
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -39,16 +39,16 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @param string $xml
41 41
 	 */
42
-	public function __construct($xml='')
42
+	public function __construct($xml = '')
43 43
 	{
44 44
 		$this->bool_attr_default += array(
45 45
 			'multiple' => false,
46 46
 		);
47 47
 
48
-		if($xml) parent::__construct($xml);
48
+		if ($xml) parent::__construct($xml);
49 49
 
50 50
 		// Legacy multiple - id ends in []
51
-		if(substr($this->id,-2) == '[]')
51
+		if (substr($this->id, -2) == '[]')
52 52
 		{
53 53
 			$this->setElementAttribute($this->id, 'multiple', true);
54 54
 		}
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		$response = Api\Json\Response::get();
70 70
 		$request_id = str_replace(' ', '+', rawurldecode($_REQUEST['request_id']));
71 71
 		$widget_id = $_REQUEST['widget_id'];
72
-		if(!self::$request = Etemplate\Request::read($request_id))
72
+		if (!self::$request = Etemplate\Request::read($request_id))
73 73
 		{
74 74
 			$response->error("Could not read session");
75 75
 			return;
@@ -94,22 +94,22 @@  discard block
 block discarded – undo
94 94
 			{
95 95
 				$widget = $template->getElementById($matches[1].':$cont[id]:'.$matches[3]);
96 96
 			}
97
-			if($widget && $widget->attrs['mime'])
97
+			if ($widget && $widget->attrs['mime'])
98 98
 			{
99 99
 				$mime = $widget->attrs['mime'];
100 100
 			}
101 101
 
102 102
 			// Check for legacy [] in id to indicate multiple - it changes format
103
-			if(is_array($files['name']))
103
+			if (is_array($files['name']))
104 104
 			{
105 105
 				$file_list = array();
106
-				foreach($files as $f_field => $values)
106
+				foreach ($files as $f_field => $values)
107 107
 				{
108
-					foreach($values as $key => $f_value) {
108
+					foreach ($values as $key => $f_value) {
109 109
 						$file_list[$key][$f_field] = $f_value;
110 110
 					}
111 111
 				}
112
-				foreach($file_list as $file)
112
+				foreach ($file_list as $file)
113 113
 				{
114 114
 					static::process_uploaded_file($field, $file, $mime, $file_data);
115 115
 				}
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 			if ($widget)
124 124
 			{
125 125
 				$callback = $widget->attrs['callback'];
126
-				if(!$callback) $callback = $template->getElementAttribute($field, 'callback');
127
-				if($callback)
126
+				if (!$callback) $callback = $template->getElementAttribute($field, 'callback');
127
+				if ($callback)
128 128
 				{
129 129
 					ExecMethod2($callback, $_FILES[$field], $widget_id, self::$request, $response);
130 130
 				}
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
 	 */
141 141
 	protected static function process_uploaded_file($field, Array &$file, $mime, Array &$file_data)
142 142
 	{
143
-		unset($field);	// not used
143
+		unset($field); // not used
144 144
 
145 145
 		// Chunks get mangled a little
146
-		if($file['name'] == 'blob')
146
+		if ($file['name'] == 'blob')
147 147
 		{
148 148
 			$file['name'] = $_POST['resumableFilename'];
149 149
 			$file['type'] = $_POST['resumableType'];
@@ -151,19 +151,19 @@  discard block
 block discarded – undo
151 151
 
152 152
 		if ($file['error'] == UPLOAD_ERR_OK && trim($file['name']) != '' && $file['size'] > 0 && is_uploaded_file($file['tmp_name'])) {
153 153
 			// Don't trust what the browser tells us for mime
154
-			if(function_exists('mime_content_type'))
154
+			if (function_exists('mime_content_type'))
155 155
 			{
156 156
 				$file['type'] = $type = Api\MimeMagic::analyze_file($file['tmp_name']);
157 157
 			}
158 158
 
159 159
 			// Mime check
160
-			if($mime)
160
+			if ($mime)
161 161
 			{
162 162
 				$is_preg = $mime[0] == '/';
163
-				if (!$is_preg && strcasecmp($mime,$type) ||
164
-					$is_preg && !preg_match($mime,$type))
163
+				if (!$is_preg && strcasecmp($mime, $type) ||
164
+					$is_preg && !preg_match($mime, $type))
165 165
 				{
166
-					$file_data[$file['name']] = $file['name'].':'.lang('File is of wrong type (%1 != %2)!',$type,$mime);
166
+					$file_data[$file['name']] = $file['name'].':'.lang('File is of wrong type (%1 != %2)!', $type, $mime);
167 167
 					//error_log(__METHOD__.__LINE__.array2string($file_data[$file['name']]));
168 168
 					return false;
169 169
 				}
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 			// Resumable / chunked uploads
173 173
 			// init the destination file (format <filename.ext>.part<#chunk>
174 174
 			// the file is stored in a temporary directory
175
-			$temp_dir = $GLOBALS['egw_info']['server']['temp_dir'].'/'.str_replace('/','_',$_POST['resumableIdentifier']);
176
-			$dest_file = $temp_dir.'/'.str_replace('/','_',$_POST['resumableFilename']).'.part'.(int)$_POST['resumableChunkNumber'];
175
+			$temp_dir = $GLOBALS['egw_info']['server']['temp_dir'].'/'.str_replace('/', '_', $_POST['resumableIdentifier']);
176
+			$dest_file = $temp_dir.'/'.str_replace('/', '_', $_POST['resumableFilename']).'.part'.(int)$_POST['resumableChunkNumber'];
177 177
 
178 178
 			// create the temporary directory
179 179
 			if (!is_dir($temp_dir))
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
 			else
190 190
 			{
191 191
 				// check if all the parts present, and create the final destination file
192
-				$new_file = self::createFileFromChunks($temp_dir, str_replace('/','_',$_POST['resumableFilename']),
192
+				$new_file = self::createFileFromChunks($temp_dir, str_replace('/', '_', $_POST['resumableFilename']),
193 193
 						$_POST['resumableTotalSize']);
194 194
 			}
195
-			if( $new_file) {
195
+			if ($new_file) {
196 196
 				$file['tmp_name'] = $new_file;
197 197
 
198 198
 				// Data to send back to client
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 
221 221
 		// count all the parts of this file
222 222
 		$total_files = $sum_size = 0;
223
-		foreach(scandir($temp_dir) as $file) {
223
+		foreach (scandir($temp_dir) as $file) {
224 224
 			if (stripos($file, $fileName) !== false) {
225 225
 				$total_files++;
226 226
 				$sum_size += filesize($temp_dir.'/'.$file);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 		{
234 234
 			if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
235 235
 			{
236
-				$new_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'egw_');
236
+				$new_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'egw_');
237 237
 			}
238 238
 			else
239 239
 			{
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
 			// create the final destination file
244 244
 			if (($fp = fopen($new_file, 'w')) !== false) {
245
-				for ($i=1; $i<=$total_files; $i++) {
245
+				for ($i = 1; $i <= $total_files; $i++) {
246 246
 					fwrite($fp, file_get_contents($temp_dir.'/'.$fileName.'.part'.$i));
247 247
 				}
248 248
 				fclose($fp);
@@ -278,13 +278,13 @@  discard block
 block discarded – undo
278 278
 			{
279 279
 				if ($object != "." && $object != "..")
280 280
 				{
281
-					if (filetype($dir . "/" . $object) == "dir")
281
+					if (filetype($dir."/".$object) == "dir")
282 282
 					{
283
-						self::rrmdir($dir . "/" . $object);
283
+						self::rrmdir($dir."/".$object);
284 284
 					}
285 285
 					else
286 286
 					{
287
-						unlink($dir . "/" . $object);
287
+						unlink($dir."/".$object);
288 288
 					}
289 289
 				}
290 290
 			}
@@ -301,23 +301,23 @@  discard block
 block discarded – undo
301 301
 	 * @param array $content
302 302
 	 * @param array &$validated=array() validated content
303 303
 	 */
304
-	public function validate($cname, array $expand, array $content, &$validated=array())
304
+	public function validate($cname, array $expand, array $content, &$validated = array())
305 305
 	{
306 306
 		$form_name = self::form_name($cname, $this->id, $expand);
307 307
 
308 308
 		if (!$this->is_readonly($cname, $form_name))
309 309
 		{
310 310
 			$value = $value_in = self::get_array($content, $form_name);
311
-			$valid =& self::get_array($validated, $form_name, true);
311
+			$valid = & self::get_array($validated, $form_name, true);
312 312
 
313
-			if(!is_array($value)) $value = array();
313
+			if (!is_array($value)) $value = array();
314 314
 
315 315
 			// Incoming values indexed by temp name
316
-			if($value[0]) $value = $value[0];
316
+			if ($value[0]) $value = $value[0];
317 317
 
318
-			foreach($value as $tmp => $file)
318
+			foreach ($value as $tmp => $file)
319 319
 			{
320
-				if(!$file) continue;
320
+				if (!$file) continue;
321 321
 				if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
322 322
 				{
323 323
 					$path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmp;
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 				);
338 338
 			}
339 339
 
340
-			if($valid && !$this->attrs['multiple']) $valid = $valid[0];
340
+			if ($valid && !$this->attrs['multiple']) $valid = $valid[0];
341 341
 		}
342 342
 	}
343 343
 
@@ -350,16 +350,16 @@  discard block
 block discarded – undo
350 350
 	 * @param string $cname
351 351
 	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
352 352
 	 */
353
-	public function beforeSendToClient($cname, array $expand=null)
353
+	public function beforeSendToClient($cname, array $expand = null)
354 354
 	{
355 355
 		$form_name = self::form_name($cname, $this->id, $expand);
356 356
 
357 357
 		$upload_max_filesize = ini_get('upload_max_filesize');
358 358
 		$unit = strtolower(substr($upload_max_filesize, -1));
359
-		if (!is_numeric($unit)) $upload_max_filesize *= $unit == 'm' ? 1024*1024 : 1024;
360
-		if ($upload_max_filesize > 1024*1024)
359
+		if (!is_numeric($unit)) $upload_max_filesize *= $unit == 'm' ? 1024 * 1024 : 1024;
360
+		if ($upload_max_filesize > 1024 * 1024)
361 361
 		{
362
-			self::setElementAttribute($form_name, 'chunk_size', ($upload_max_filesize-1024*1024)/2);
362
+			self::setElementAttribute($form_name, 'chunk_size', ($upload_max_filesize - 1024 * 1024) / 2);
363 363
 		}
364 364
 	}
365 365
 }
Please login to merge, or discard this patch.
Braces   +52 added lines, -18 removed lines patch added patch discarded remove patch
@@ -45,7 +45,10 @@  discard block
 block discarded – undo
45 45
 			'multiple' => false,
46 46
 		);
47 47
 
48
-		if($xml) parent::__construct($xml);
48
+		if($xml)
49
+		{
50
+			parent::__construct($xml);
51
+		}
49 52
 
50 53
 		// Legacy multiple - id ends in []
51 54
 		if(substr($this->id,-2) == '[]')
@@ -105,7 +108,8 @@  discard block
 block discarded – undo
105 108
 				$file_list = array();
106 109
 				foreach($files as $f_field => $values)
107 110
 				{
108
-					foreach($values as $key => $f_value) {
111
+					foreach($values as $key => $f_value)
112
+					{
109 113
 						$file_list[$key][$f_field] = $f_value;
110 114
 					}
111 115
 				}
@@ -123,7 +127,10 @@  discard block
 block discarded – undo
123 127
 			if ($widget)
124 128
 			{
125 129
 				$callback = $widget->attrs['callback'];
126
-				if(!$callback) $callback = $template->getElementAttribute($field, 'callback');
130
+				if(!$callback)
131
+				{
132
+					$callback = $template->getElementAttribute($field, 'callback');
133
+				}
127 134
 				if($callback)
128 135
 				{
129 136
 					ExecMethod2($callback, $_FILES[$field], $widget_id, self::$request, $response);
@@ -149,7 +156,8 @@  discard block
 block discarded – undo
149 156
 			$file['type'] = $_POST['resumableType'];
150 157
 		}
151 158
 
152
-		if ($file['error'] == UPLOAD_ERR_OK && trim($file['name']) != '' && $file['size'] > 0 && is_uploaded_file($file['tmp_name'])) {
159
+		if ($file['error'] == UPLOAD_ERR_OK && trim($file['name']) != '' && $file['size'] > 0 && is_uploaded_file($file['tmp_name']))
160
+		{
153 161
 			// Don't trust what the browser tells us for mime
154 162
 			if(function_exists('mime_content_type'))
155 163
 			{
@@ -192,7 +200,8 @@  discard block
 block discarded – undo
192 200
 				$new_file = self::createFileFromChunks($temp_dir, str_replace('/','_',$_POST['resumableFilename']),
193 201
 						$_POST['resumableTotalSize']);
194 202
 			}
195
-			if( $new_file) {
203
+			if( $new_file)
204
+			{
196 205
 				$file['tmp_name'] = $new_file;
197 206
 
198 207
 				// Data to send back to client
@@ -216,12 +225,15 @@  discard block
 block discarded – undo
216 225
 	 * @param string $fileName - the original file name
217 226
 	 * @param string $totalSize - original file size (in bytes)
218 227
 	 */
219
-	private static function createFileFromChunks($temp_dir, $fileName, $totalSize) {
228
+	private static function createFileFromChunks($temp_dir, $fileName, $totalSize)
229
+	{
220 230
 
221 231
 		// count all the parts of this file
222 232
 		$total_files = $sum_size = 0;
223
-		foreach(scandir($temp_dir) as $file) {
224
-			if (stripos($file, $fileName) !== false) {
233
+		foreach(scandir($temp_dir) as $file)
234
+		{
235
+			if (stripos($file, $fileName) !== false)
236
+			{
225 237
 				$total_files++;
226 238
 				$sum_size += filesize($temp_dir.'/'.$file);
227 239
 			}
@@ -241,21 +253,28 @@  discard block
 block discarded – undo
241 253
 			}
242 254
 
243 255
 			// create the final destination file
244
-			if (($fp = fopen($new_file, 'w')) !== false) {
245
-				for ($i=1; $i<=$total_files; $i++) {
256
+			if (($fp = fopen($new_file, 'w')) !== false)
257
+			{
258
+				for ($i=1; $i<=$total_files; $i++)
259
+				{
246 260
 					fwrite($fp, file_get_contents($temp_dir.'/'.$fileName.'.part'.$i));
247 261
 				}
248 262
 				fclose($fp);
249
-			} else {
263
+			}
264
+			else
265
+			{
250 266
 				_log('cannot create the destination file');
251 267
 				return false;
252 268
 			}
253 269
 
254 270
 			// rename the temporary directory (to avoid access from other
255 271
 			// concurrent chunks uploads) and than delete it
256
-			if (rename($temp_dir, $temp_dir.'_UNUSED')) {
272
+			if (rename($temp_dir, $temp_dir.'_UNUSED'))
273
+			{
257 274
 				self::rrmdir($temp_dir.'_UNUSED');
258
-			} else {
275
+			}
276
+			else
277
+			{
259 278
 				self::rrmdir($temp_dir);
260 279
 			}
261 280
 
@@ -310,14 +329,23 @@  discard block
 block discarded – undo
310 329
 			$value = $value_in = self::get_array($content, $form_name);
311 330
 			$valid =& self::get_array($validated, $form_name, true);
312 331
 
313
-			if(!is_array($value)) $value = array();
332
+			if(!is_array($value))
333
+			{
334
+				$value = array();
335
+			}
314 336
 
315 337
 			// Incoming values indexed by temp name
316
-			if($value[0]) $value = $value[0];
338
+			if($value[0])
339
+			{
340
+				$value = $value[0];
341
+			}
317 342
 
318 343
 			foreach($value as $tmp => $file)
319 344
 			{
320
-				if(!$file) continue;
345
+				if(!$file)
346
+				{
347
+					continue;
348
+				}
321 349
 				if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
322 350
 				{
323 351
 					$path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmp;
@@ -337,7 +365,10 @@  discard block
 block discarded – undo
337 365
 				);
338 366
 			}
339 367
 
340
-			if($valid && !$this->attrs['multiple']) $valid = $valid[0];
368
+			if($valid && !$this->attrs['multiple'])
369
+			{
370
+				$valid = $valid[0];
371
+			}
341 372
 		}
342 373
 	}
343 374
 
@@ -356,7 +387,10 @@  discard block
 block discarded – undo
356 387
 
357 388
 		$upload_max_filesize = ini_get('upload_max_filesize');
358 389
 		$unit = strtolower(substr($upload_max_filesize, -1));
359
-		if (!is_numeric($unit)) $upload_max_filesize *= $unit == 'm' ? 1024*1024 : 1024;
390
+		if (!is_numeric($unit))
391
+		{
392
+			$upload_max_filesize *= $unit == 'm' ? 1024*1024 : 1024;
393
+		}
360 394
 		if ($upload_max_filesize > 1024*1024)
361 395
 		{
362 396
 			self::setElementAttribute($form_name, 'chunk_size', ($upload_max_filesize-1024*1024)/2);
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Button.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param array &$validated=array() validated content
45 45
 	 * @return boolean true if no validation error, false otherwise
46 46
 	 */
47
-	public function validate($cname, array $expand, array $content, &$validated=array())
47
+	public function validate($cname, array $expand, array $content, &$validated = array())
48 48
 	{
49 49
 		$form_name = self::form_name($cname, $this->id, $expand);
50 50
 		//error_log(__METHOD__."('$cname', ".array2string($expand).", ...) $this: get_array(\$content, '$form_name')=".array2string(self::get_array($content, $form_name)));
@@ -53,18 +53,18 @@  discard block
 block discarded – undo
53 53
 		{
54 54
 			$value = self::get_array($content, $form_name);
55 55
 
56
-			if(
56
+			if (
57 57
 				// Handle case of not existing $row_cont[id], eg: create[]
58 58
 				is_array($value) && count($value) == 1 ||
59 59
 				// check === true, as get_array() ignores a "[]" postfix and returns array() eg. for a not existing $row_cont[id] in "delete[$row_cont[id]]"
60 60
 				$value == true
61 61
 			)
62 62
 			{
63
-				$valid =& self::get_array($validated, $form_name, true);
63
+				$valid = & self::get_array($validated, $form_name, true);
64 64
 				if (true) $valid = is_array($value) ? $value : 'pressed';
65 65
 
66 66
 				// recorded pressed button globally, was in the template object before, put now as static on this object
67
-				if ($this->type == 'cancel' || $form_name == 'cancel' || substr($form_name,-10) == '[cancel]')
67
+				if ($this->type == 'cancel' || $form_name == 'cancel' || substr($form_name, -10) == '[cancel]')
68 68
 				{
69 69
 					self::$canceled = true;
70 70
 				}
@@ -76,4 +76,4 @@  discard block
 block discarded – undo
76 76
 		}
77 77
 	}
78 78
 }
79
-Etemplate\Widget::registerWidget(__NAMESPACE__.'\\Button', array('button','buttononly'));
79
+Etemplate\Widget::registerWidget(__NAMESPACE__.'\\Button', array('button', 'buttononly'));
Please login to merge, or discard this patch.
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -58,10 +58,12 @@
 block discarded – undo
58 58
 				is_array($value) && count($value) == 1 ||
59 59
 				// check === true, as get_array() ignores a "[]" postfix and returns array() eg. for a not existing $row_cont[id] in "delete[$row_cont[id]]"
60 60
 				$value == true
61
-			)
62
-			{
61
+			) {
63 62
 				$valid =& self::get_array($validated, $form_name, true);
64
-				if (true) $valid = is_array($value) ? $value : 'pressed';
63
+				if (true)
64
+				{
65
+					$valid = is_array($value) ? $value : 'pressed';
66
+				}
65 67
 
66 68
 				// recorded pressed button globally, was in the template object before, put now as static on this object
67 69
 				if ($this->type == 'cancel' || $form_name == 'cancel' || substr($form_name,-10) == '[cancel]')
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Grid.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
 	 * @param boolean $respect_disabled =false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children
66 66
 	 * @param array $columns_disabled=array() disabled columns
67 67
 	 */
68
-	public function run($method_name, $params=array(''), $respect_disabled=false, &$columns_disabled=array())
68
+	public function run($method_name, $params = array(''), $respect_disabled = false, &$columns_disabled = array())
69 69
 	{
70 70
 		// maintain $expand array name-expansion
71
-		$cname =& $params[0];
72
-		$expand =& $params[1];
71
+		$cname = & $params[0];
72
+		$expand = & $params[1];
73 73
 		$old_cname = $params[0];
74 74
 		$old_expand = $params[1];
75 75
 
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 			//error_log(__METHOD__."('$method_name', ".array2string($params).', '.array2string($respect_disabled).") $this disabled='{$this->attrs['disabled']}'=".array2string($disabled).": NOT running");
86 86
 			$params[0] = $old_cname;
87 87
 			$params[1] = $old_expand;
88
-			return false;	// return
88
+			return false; // return
89 89
 		}
90 90
 
91 91
 		if ($this->id) $cname = self::form_name($cname, $this->id, $expand);
92 92
 		if ($expand['cname'] !== $cname && $cname)
93 93
 		{
94
-			$expand['cont'] =& self::get_array(self::$request->content, $cname);
94
+			$expand['cont'] = & self::get_array(self::$request->content, $cname);
95 95
 			$expand['cname'] = $cname;
96 96
 		}
97 97
 
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
 		}
102 102
 		//foreach($this->children as $n => $child)
103 103
 		$repeat_child = null;
104
-		for($n = 0; ; ++$n)
104
+		for ($n = 0; ; ++$n)
105 105
 		{
106 106
 			// maintain $expand array name-expansion
107
-			switch($this->type)
107
+			switch ($this->type)
108 108
 			{
109 109
 				case 'rows':
110 110
 					$expand['row'] = $n;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 			if (isset($this->children[$n]))
117 117
 			{
118 118
 				$child = $this->children[$n];
119
-				if($this->type == 'rows' || $this->type == 'columns')
119
+				if ($this->type == 'rows' || $this->type == 'columns')
120 120
 				{
121 121
 					/*
122 122
 					 * We store a clone of the repeated child, because at the end
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 				if (in_array($n, $columns_disabled))
144 144
 				{
145 145
 					//error_log(__METHOD__."('$method_name', ".array2string($params).', '.array2string($respect_disabled).") $this column $n is disabled: NOT running");
146
-					continue;	// do NOT run $method_name on disabled columns
146
+					continue; // do NOT run $method_name on disabled columns
147 147
 				}
148 148
 			}
149 149
 			//error_log('Running ' . $method_name . ' on child ' . $n . '(' . $child . ') ['.$expand['row'] . ','.$expand['c'] . ']');
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 
152 152
 			if ($this->type == 'columns' && $disabled)
153 153
 			{
154
-				$columns_disabled[] = $n;	// mark column as disabled
154
+				$columns_disabled[] = $n; // mark column as disabled
155 155
 			}
156 156
 		}
157 157
 		if ($this->type == 'grid')
@@ -175,34 +175,34 @@  discard block
 block discarded – undo
175 175
 	private function need_autorepeat($cname, array $expand)
176 176
 	{
177 177
 		// check id's of children
178
-		foreach($this->children as $n => $direct_child)
178
+		foreach ($this->children as $n => $direct_child)
179 179
 		{
180
-			foreach(array_merge(array($direct_child), $n ? array() : $direct_child->children) as $child)
180
+			foreach (array_merge(array($direct_child), $n ? array() : $direct_child->children) as $child)
181 181
 			{
182 182
 				$pat = $child->id;
183
-				while(($patstr = strstr($pat, '$')))
183
+				while (($patstr = strstr($pat, '$')))
184 184
 				{
185
-					$pat = substr($patstr,$patstr[1] == '{' ? 2 : 1);
185
+					$pat = substr($patstr, $patstr[1] == '{' ? 2 : 1);
186 186
 
187 187
 					switch ($this->type)
188 188
 					{
189 189
 						case 'column':
190
-							$Ok = $pat[0] == 'c' && !(substr($pat,0,4) == 'cont' || substr($pat,0,2) == 'c_' ||
191
-								substr($pat,0,4) == 'col_');
190
+							$Ok = $pat[0] == 'c' && !(substr($pat, 0, 4) == 'cont' || substr($pat, 0, 2) == 'c_' ||
191
+								substr($pat, 0, 4) == 'col_');
192 192
 							break;
193 193
 						case 'row':
194
-							$Ok = $pat[0] == 'r' && !(substr($pat,0,2) == 'r_' ||
195
-								substr($pat,0,4) == 'row_' && substr($pat,0,8) != 'row_cont');
194
+							$Ok = $pat[0] == 'r' && !(substr($pat, 0, 2) == 'r_' ||
195
+								substr($pat, 0, 4) == 'row_' && substr($pat, 0, 8) != 'row_cont');
196 196
 							//error_log(__METHOD__."() pat='$pat' --> Ok=".array2string($Ok));
197 197
 							break;
198 198
 						default:
199 199
 							return false;
200 200
 					}
201
-					if ($Ok && ($fname=self::form_name($cname, $child->id, $expand)) &&
201
+					if ($Ok && ($fname = self::form_name($cname, $child->id, $expand)) &&
202 202
 						// need to break if fname ends in [] as get_array() will ignore it and returns whole array
203 203
 						// for an id like "run[$row_cont[appname]]"
204 204
 						substr($fname, -2) != '[]' &&
205
-						($value = self::get_array(self::$request->content,$fname)) !== null)	// null = not found (can be false!)
205
+						($value = self::get_array(self::$request->content, $fname)) !== null)	// null = not found (can be false!)
206 206
 					{
207 207
 						//error_log(__METHOD__."('$cname', ) $this autorepeating row $expand[row] because of $child->id = '$fname' is ".array2string($value));
208 208
 						unset($value);
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -88,7 +88,10 @@  discard block
 block discarded – undo
88 88
 			return false;	// return
89 89
 		}
90 90
 
91
-		if ($this->id) $cname = self::form_name($cname, $this->id, $expand);
91
+		if ($this->id)
92
+		{
93
+			$cname = self::form_name($cname, $this->id, $expand);
94
+		}
92 95
 		if ($expand['cname'] !== $cname && $cname)
93 96
 		{
94 97
 			$expand['cont'] =& self::get_array(self::$request->content, $cname);
@@ -202,10 +205,13 @@  discard block
 block discarded – undo
202 205
 						// need to break if fname ends in [] as get_array() will ignore it and returns whole array
203 206
 						// for an id like "run[$row_cont[appname]]"
204 207
 						substr($fname, -2) != '[]' &&
205
-						($value = self::get_array(self::$request->content,$fname)) !== null)	// null = not found (can be false!)
208
+						($value = self::get_array(self::$request->content,$fname)) !== null)
209
+					{
210
+						// null = not found (can be false!)
206 211
 					{
207 212
 						//error_log(__METHOD__."('$cname', ) $this autorepeating row $expand[row] because of $child->id = '$fname' is ".array2string($value));
208 213
 						unset($value);
214
+					}
209 215
 						return true;
210 216
 					}
211 217
 				}
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/ItemPicker.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	public function __construct($xml = '')
33 33
 	{
34
-		if($xml) {
34
+		if ($xml) {
35 35
 			parent::__construct($xml);
36 36
 		}
37 37
 	}
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * Find items that match the given parameters
41 41
 	 * using the egw_link class
42 42
 	 */
43
-	public static function ajax_item_search($app, $type, $pattern, $options=array())
43
+	public static function ajax_item_search($app, $type, $pattern, $options = array())
44 44
 	{
45 45
 		$options['type'] = $type ? $type : $options['type'];
46 46
 		$items = Api\Link::query($app, $pattern, $options);
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,8 @@
 block discarded – undo
31 31
 	 */
32 32
 	public function __construct($xml = '')
33 33
 	{
34
-		if($xml) {
34
+		if($xml)
35
+		{
35 36
 			parent::__construct($xml);
36 37
 		}
37 38
 	}
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/HistoryLog.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 	 * while it uses select-account for owner in historylog (containing all users).
34 34
 	 *
35 35
 	 * @param string $cname
36
-	*/
36
+	 */
37 37
 	public function beforeSendToClient($cname)
38 38
 	{
39 39
 		$form_name = self::form_name($cname, $this->id);
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -38,19 +38,19 @@  discard block
 block discarded – undo
38 38
 	{
39 39
 		$form_name = self::form_name($cname, $this->id);
40 40
 
41
-		if(is_array(self::$request->content[$form_name]['status-widgets']))
41
+		if (is_array(self::$request->content[$form_name]['status-widgets']))
42 42
 		{
43
-			foreach(self::$request->content[$form_name]['status-widgets'] as $key => $type)
43
+			foreach (self::$request->content[$form_name]['status-widgets'] as $key => $type)
44 44
 			{
45
-				if(!is_array($type))
45
+				if (!is_array($type))
46 46
 				{
47
-					list($basetype) = explode('-',$type);
47
+					list($basetype) = explode('-', $type);
48 48
 					$widget = @self::factory($basetype, '<?xml version="1.0"?><'.$type.' type="'.$type.'"/>', $key);
49 49
 					$widget->id = $key;
50 50
 					$widget->attrs['type'] = $type;
51 51
 					$widget->type = $type;
52 52
 
53
-					if(method_exists($widget, 'beforeSendToClient'))
53
+					if (method_exists($widget, 'beforeSendToClient'))
54 54
 					{
55 55
 						// need to use $form_name as $cname see comment in header
56 56
 						$widget->beforeSendToClient($form_name, array());
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 				else
60 60
 				{
61 61
 					// need to use self::form_name($form_name, $key) as index into sel_options see comment in header
62
-					$options =& self::get_array(self::$request->sel_options, self::form_name($form_name, $key), true);
62
+					$options = & self::get_array(self::$request->sel_options, self::form_name($form_name, $key), true);
63 63
 					if (!is_array($options)) $options = array();
64 64
 					$options += $type;
65 65
 				}
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 	 * @param array &$validated=array() validated content
83 83
 	 * @return boolean true if no validation error, false otherwise
84 84
 	 */
85
-	public function validate($cname, array $expand, array $content, &$validated=array())
85
+	public function validate($cname, array $expand, array $content, &$validated = array())
86 86
 	{
87 87
 		$form_name = self::form_name($cname, $this->id, $expand);
88 88
 		$value = self::get_array($content, $form_name);
89
-		$valid =& self::get_array($validated, $form_name, true);
89
+		$valid = & self::get_array($validated, $form_name, true);
90 90
 		if (true) $valid = $value;
91 91
 		return true;
92 92
 	}
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,7 +60,10 @@  discard block
 block discarded – undo
60 60
 				{
61 61
 					// need to use self::form_name($form_name, $key) as index into sel_options see comment in header
62 62
 					$options =& self::get_array(self::$request->sel_options, self::form_name($form_name, $key), true);
63
-					if (!is_array($options)) $options = array();
63
+					if (!is_array($options))
64
+					{
65
+						$options = array();
66
+					}
64 67
 					$options += $type;
65 68
 				}
66 69
 
@@ -87,7 +90,10 @@  discard block
 block discarded – undo
87 90
 		$form_name = self::form_name($cname, $this->id, $expand);
88 91
 		$value = self::get_array($content, $form_name);
89 92
 		$valid =& self::get_array($validated, $form_name, true);
90
-		if (true) $valid = $value;
93
+		if (true)
94
+		{
95
+			$valid = $value;
96
+		}
91 97
 		return true;
92 98
 	}
93 99
 }
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Image.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,21 +29,21 @@
 block discarded – undo
29 29
 	 * @param string $cname
30 30
 	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
31 31
 	 */
32
-	public function beforeSendToClient($cname, array $expand=null)
32
+	public function beforeSendToClient($cname, array $expand = null)
33 33
 	{
34 34
 		$form_name = self::form_name($cname, $this->id, $expand);
35
-		$value =& self::get_array(self::$request->content, $form_name);
35
+		$value = & self::get_array(self::$request->content, $form_name);
36 36
 
37 37
 		$image = $value != '' ? $value : $this->attrs['src'];
38 38
 
39
-		if (is_string($image)) list($app,$img) = explode('/',$image,2);
40
-		if (!$app || !$img || !is_dir(EGW_SERVER_ROOT.'/'.$app) || strpos($img,'/')!==false)
39
+		if (is_string($image)) list($app, $img) = explode('/', $image, 2);
40
+		if (!$app || !$img || !is_dir(EGW_SERVER_ROOT.'/'.$app) || strpos($img, '/') !== false)
41 41
 		{
42 42
 			$img = $image;
43
-			list($app) = explode('.',$form_name);
43
+			list($app) = explode('.', $form_name);
44 44
 		}
45 45
 		$src = Api\Image::find($app, $img);
46
-		if(!$this->id)
46
+		if (!$this->id)
47 47
 		{
48 48
 //			self::setElementAttribute($this->attrs['src'], 'id', $this->attrs['src']);
49 49
 		}
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,10 @@
 block discarded – undo
36 36
 
37 37
 		$image = $value != '' ? $value : $this->attrs['src'];
38 38
 
39
-		if (is_string($image)) list($app,$img) = explode('/',$image,2);
39
+		if (is_string($image))
40
+		{
41
+			list($app,$img) = explode('/',$image,2);
42
+		}
40 43
 		if (!$app || !$img || !is_dir(EGW_SERVER_ROOT.'/'.$app) || strpos($img,'/')!==false)
41 44
 		{
42 45
 			$img = $image;
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Checkbox.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param array &$validated=array() validated content
45 45
 	 * @return boolean true if no validation error, false otherwise
46 46
 	 */
47
-	public function validate($cname, array $expand, array $content, &$validated=array())
47
+	public function validate($cname, array $expand, array $content, &$validated = array())
48 48
 	{
49 49
 		$form_name = self::form_name($cname, $this->id, $expand);
50 50
 
@@ -56,28 +56,28 @@  discard block
 block discarded – undo
56 56
 		if (!$this->is_readonly($cname, $form_name))
57 57
 		{
58 58
 			$value = self::get_array($content, $form_name);
59
-			if (!isset($value))	return;	// value not transmitted --> nothing to validate
60
-			$valid =& self::get_array($validated, $form_name, true);
59
+			if (!isset($value))	return; // value not transmitted --> nothing to validate
60
+			$valid = & self::get_array($validated, $form_name, true);
61 61
 
62 62
 			if (!$value && $this->attrs['needed'])
63 63
 			{
64
-				self::set_validation_error($form_name,lang('Field must not be empty !!!'),'');
64
+				self::set_validation_error($form_name, lang('Field must not be empty !!!'), '');
65 65
 			}
66 66
 			$type = $this->type ? $this->type : $this->attrs['type'];
67 67
 			$value_attr = $type == 'radio' ? 'set_value' : 'selected_value';
68 68
 			// defaults for set and unset values
69 69
 			$selected_value = true;
70 70
 			$unselected_value = false;
71
-			if (array_key_exists($value_attr, $this->attrs) || array_key_exists('unselected_value',$this->attrs))
71
+			if (array_key_exists($value_attr, $this->attrs) || array_key_exists('unselected_value', $this->attrs))
72 72
 			{
73
-				if(array_key_exists($value_attr, $this->attrs))
73
+				if (array_key_exists($value_attr, $this->attrs))
74 74
 				{
75 75
 					// Expand any content stuff
76
-					$selected_value = self::expand_name($this->attrs[$value_attr], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'],$expand['cont']);
76
+					$selected_value = self::expand_name($this->attrs[$value_attr], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']);
77 77
 				}
78
-				if(array_key_exists('unselected_value',$this->attrs))
78
+				if (array_key_exists('unselected_value', $this->attrs))
79 79
 				{
80
-					$unselected_value = self::expand_name($this->attrs['unselected_value'], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'],$expand['cont']);
80
+					$unselected_value = self::expand_name($this->attrs['unselected_value'], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']);
81 81
 				}
82 82
 			}
83 83
 			if ($type == 'radio')
@@ -87,14 +87,14 @@  discard block
 block discarded – undo
87 87
 				{
88 88
 					$valid = $value;
89 89
 				}
90
-				elseif ( !$options && $selected_value && $value == $selected_value)
90
+				elseif (!$options && $selected_value && $value == $selected_value)
91 91
 				{
92 92
 					// Options set in template, not in sel_options
93 93
 					$valid = $selected_value;
94 94
 				}
95 95
 				elseif (!isset($valid))
96 96
 				{
97
-					$valid = '';	// do not overwrite value of an other radio-button of the same group (identical name)!
97
+					$valid = ''; // do not overwrite value of an other radio-button of the same group (identical name)!
98 98
 				}
99 99
 			}
100 100
 			elseif (in_array((string)$selected_value, (array)$value))
Please login to merge, or discard this patch.
Braces   +13 added lines, -3 removed lines patch added patch discarded remove patch
@@ -56,7 +56,11 @@  discard block
 block discarded – undo
56 56
 		if (!$this->is_readonly($cname, $form_name))
57 57
 		{
58 58
 			$value = self::get_array($content, $form_name);
59
-			if (!isset($value))	return;	// value not transmitted --> nothing to validate
59
+			if (!isset($value))
60
+			{
61
+				return;
62
+			}
63
+			// value not transmitted --> nothing to validate
60 64
 			$valid =& self::get_array($validated, $form_name, true);
61 65
 
62 66
 			if (!$value && $this->attrs['needed'])
@@ -101,7 +105,10 @@  discard block
 block discarded – undo
101 105
 			{
102 106
 				if ($multiple)
103 107
 				{
104
-					if (!isset($valid)) $valid = array();
108
+					if (!isset($valid))
109
+					{
110
+						$valid = array();
111
+					}
105 112
 					$valid[] = $selected_value;
106 113
 				}
107 114
 				else
@@ -113,7 +120,10 @@  discard block
 block discarded – undo
113 120
 			{
114 121
 				if ($multiple)
115 122
 				{
116
-					if (!isset($valid)) $valid = array();
123
+					if (!isset($valid))
124
+					{
125
+						$valid = array();
126
+					}
117 127
 				}
118 128
 				elseif ($value === 'true')
119 129
 				{
Please login to merge, or discard this patch.
api/src/Etemplate/Widget.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -903,12 +903,12 @@
 block discarded – undo
903 903
 	}
904 904
 
905 905
 	/**
906
-	* Check if we have not ignored validation errors
907
-	*
908
-	* @param string $ignore_validation ='' if not empty regular expression for validation-errors to ignore
909
-	* @param string $cname =null name-prefix, which need to be ignored, default self::$name_vars
910
-	* @return boolean true if there are not ignored validation errors, false otherwise
911
-	*/
906
+	 * Check if we have not ignored validation errors
907
+	 *
908
+	 * @param string $ignore_validation ='' if not empty regular expression for validation-errors to ignore
909
+	 * @param string $cname =null name-prefix, which need to be ignored, default self::$name_vars
910
+	 * @return boolean true if there are not ignored validation errors, false otherwise
911
+	 */
912 912
 	public static function validation_errors($ignore_validation='',$cname='')
913 913
 	{
914 914
 		// not yet used: if (is_null($cname)) $cname = self::$name_vars;
Please login to merge, or discard this patch.
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
 	 * @var array
49 49
 	 */
50 50
 	public $bool_attr_default = array(
51
-		'disabled' => null,	// null = no default
51
+		'disabled' => null, // null = no default
52 52
 		'statustext_html' => false,
53 53
 		'no_lang' => false,
54 54
 		// strictly speeding only for input widgets, but server-side input-widgets have a validation method, but no shared parent
55
-		'readonly' => null,	// null = no default
55
+		'readonly' => null, // null = no default
56 56
 		'needed' => false,
57 57
 	);
58 58
 
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 		$this->id = $reader->getAttribute('id');
113 113
 
114 114
 		// Update content?
115
-		if(self::$cont == null)
115
+		if (self::$cont == null)
116 116
 			self::$cont = is_array(self::$request->content) ? self::$request->content : array();
117
-		if($this->id && is_array(self::$cont[$this->id]))
117
+		if ($this->id && is_array(self::$cont[$this->id]))
118 118
 		{
119 119
 			$old_cont = self::$cont;
120 120
 			self::$cont = self::$cont[$this->id];
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		// read all attributes
124 124
 		$this->set_attrs($reader);
125 125
 
126
-		while($reader->read() && $reader->depth > $depth)
126
+		while ($reader->read() && $reader->depth > $depth)
127 127
 		{
128 128
 			if ($reader->nodeType == XMLReader::ELEMENT && $reader->depth > $depth)
129 129
 			{
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 		}
138 138
 
139 139
 		// Reset content as we leave
140
-		if($old_cont) {
140
+		if ($old_cont) {
141 141
 			self::$cont = $old_cont;
142 142
 		}
143 143
 	}
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 * @param boolean $cloned =true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object
177 177
 	 * @return Template current object or clone, if any attribute was set
178 178
 	 */
179
-	public function set_attrs($xml, $cloned=true)
179
+	public function set_attrs($xml, $cloned = true)
180 180
 	{
181 181
 		$reader = self::get_reader($xml);
182 182
 
@@ -193,14 +193,14 @@  discard block
 block discarded – undo
193 193
 
194 194
 		// read and set all attributes
195 195
 		$template = $this;
196
-		while($reader->moveToNextAttribute())
196
+		while ($reader->moveToNextAttribute())
197 197
 		{
198 198
 			if ($reader->name != 'id' && $template->attr[$reader->name] != $reader->value)
199 199
 			{
200 200
 				if (!$cloned)
201 201
 				{
202 202
 					$template = clone($this);
203
-					$cloned = true;	// only clone it once, otherwise we loose attributes!
203
+					$cloned = true; // only clone it once, otherwise we loose attributes!
204 204
 				}
205 205
 				// $reader->value is an object and therefore assigned by reference
206 206
 				// this is important to not loose content when validating dynamic generated tabs as in settings!
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 				if ($legacy_options && $reader->name == 'options')
218 218
 				{
219 219
 					$legacy_options = explode(',', $legacy_options);
220
-					foreach(self::csv_split($value, count($legacy_options)) as $n => $val)
220
+					foreach (self::csv_split($value, count($legacy_options)) as $n => $val)
221 221
 					{
222 222
 						if ($legacy_options[$n] && (string)$val !== '') $template->attrs[$legacy_options[$n]] = $val;
223 223
 					}
@@ -226,14 +226,14 @@  discard block
 block discarded – undo
226 226
 		}
227 227
 
228 228
 		// Add in anything in the modification array
229
-		if(is_array(self::$request->modifications[$this->id]))
229
+		if (is_array(self::$request->modifications[$this->id]))
230 230
 		{
231
-			$this->attrs = array_merge($this->attrs,self::$request->modifications[$this->id]);
231
+			$this->attrs = array_merge($this->attrs, self::$request->modifications[$this->id]);
232 232
 		}
233 233
 
234 234
 		// cast boolean attributes to boolean and set their defaults, if they have one
235 235
 		//$old_attrs = $this->attrs;
236
-		foreach($this->bool_attr_default as $name => $default_value)
236
+		foreach ($this->bool_attr_default as $name => $default_value)
237 237
 		{
238 238
 			if (!isset($this->attrs[$name]))
239 239
 			{
@@ -268,32 +268,32 @@  discard block
 block discarded – undo
268 268
 	 * @param string $enclosure ='"'
269 269
 	 * @return array
270 270
 	 */
271
-	public static function csv_split($str,$num=null,$delimiter=',',$enclosure='"')
271
+	public static function csv_split($str, $num = null, $delimiter = ',', $enclosure = '"')
272 272
 	{
273
-		if (strpos($str,$enclosure) === false)
273
+		if (strpos($str, $enclosure) === false)
274 274
 		{
275
-			return is_null($num) ? explode($delimiter,$str) : explode($delimiter,$str,$num);	// no need to run this more expensive code
275
+			return is_null($num) ? explode($delimiter, $str) : explode($delimiter, $str, $num); // no need to run this more expensive code
276 276
 		}
277
-		$parts = explode($delimiter,$str);
278
-		for($n = 0; isset($parts[$n]); ++$n)
277
+		$parts = explode($delimiter, $str);
278
+		for ($n = 0; isset($parts[$n]); ++$n)
279 279
 		{
280
-			$part =& $parts[$n];
280
+			$part = & $parts[$n];
281 281
 			if ($part[0] === $enclosure)
282 282
 			{
283
-				while (isset($parts[$n+1]) && substr($part,-1) !== $enclosure)
283
+				while (isset($parts[$n + 1]) && substr($part, -1) !== $enclosure)
284 284
 				{
285 285
 					$part .= $delimiter.$parts[++$n];
286 286
 					unset($parts[$n]);
287 287
 				}
288
-				$part = substr(str_replace($enclosure.$enclosure,$enclosure,$part),1,-1);
288
+				$part = substr(str_replace($enclosure.$enclosure, $enclosure, $part), 1, -1);
289 289
 			}
290 290
 		}
291
-		$parts_renum = array_values($parts);	// renumber the parts (in case we had to concat them)
291
+		$parts_renum = array_values($parts); // renumber the parts (in case we had to concat them)
292 292
 
293 293
 		if ($num > 0 && count($parts_renum) > $num)
294 294
 		{
295
-			$parts_renum[$num-1] = implode($delimiter,array_slice($parts_renum,$num-1,count($parts_renum)-$num+1));
296
-			$parts_renum = array_slice($parts_renum,0,$num);
295
+			$parts_renum[$num - 1] = implode($delimiter, array_slice($parts_renum, $num - 1, count($parts_renum) - $num + 1));
296
+			$parts_renum = array_slice($parts_renum, 0, $num);
297 297
 		}
298 298
 		return $parts_renum;
299 299
 	}
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 		{
321 321
 			throw new Api\Exception\WrongParameter(__METHOD__."('$class', ".array2string($widgets).") $class is no subclass of ".__CLASS__.'!');
322 322
 		}
323
-		foreach((array)$widgets as $widget)
323
+		foreach ((array)$widgets as $widget)
324 324
 		{
325 325
 			self::$widget_registry[$widget] = $class;
326 326
 		}
@@ -344,19 +344,19 @@  discard block
 block discarded – undo
344 344
 
345 345
 		if (!$widget_registry)	// not in instance cache --> rescan from filesystem
346 346
 		{
347
-			foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__.'/Widget')) as $path)
347
+			foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__.'/Widget')) as $path)
348 348
 			{
349
-				if(strpos($path, 'tests/') !== FALSE)
349
+				if (strpos($path, 'tests/') !== FALSE)
350 350
 				{
351 351
 					continue;
352 352
 				}
353
-				if(substr($path, -4) == '.php')
353
+				if (substr($path, -4) == '.php')
354 354
 				{
355 355
 					try
356 356
 					{
357 357
 						include_once($path);
358 358
 					}
359
-					catch(\Exception $e)
359
+					catch (\Exception $e)
360 360
 					{
361 361
 						error_log($e->getMessage());
362 362
 					}
@@ -364,18 +364,18 @@  discard block
 block discarded – undo
364 364
 			}
365 365
 
366 366
 			// Use hook to load custom widgets from other apps
367
-			$widgets = Api\Hooks::process('etemplate2_register_widgets',array(),true);
368
-			foreach($widgets as $list)
367
+			$widgets = Api\Hooks::process('etemplate2_register_widgets', array(), true);
368
+			foreach ($widgets as $list)
369 369
 			{
370 370
 				if (is_array($list))
371 371
 				{
372
-					foreach($list as $class)
372
+					foreach ($list as $class)
373 373
 					{
374 374
 						try
375 375
 						{
376
-							class_exists($class);	// trigger autoloader
376
+							class_exists($class); // trigger autoloader
377 377
 						}
378
-						catch(\Exception $e)
378
+						catch (\Exception $e)
379 379
 						{
380 380
 							error_log($e->getMessage());
381 381
 						}
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 			}
385 385
 			if (self::$widget_registry['htmlarea'] === Api\Etemplate\Widget\HtmlArea::class)
386 386
 			Api\Cache::setInstance('etemplate', 'widget_registry', self::$widget_registry, 3600);
387
-			else error_log(__METHOD__."() wrong class for Htmlarea: ".function_backtrace ());
387
+			else error_log(__METHOD__."() wrong class for Htmlarea: ".function_backtrace());
388 388
 		}
389 389
 		else
390 390
 		{
@@ -400,22 +400,22 @@  discard block
 block discarded – undo
400 400
 	 * @param string|XMLReader $xml
401 401
 	 * @param string $id =null
402 402
 	 */
403
-	public static function factory($type, $xml, $id=null)
403
+	public static function factory($type, $xml, $id = null)
404 404
 	{
405
-		$class_name =& self::$widget_registry[$type];
405
+		$class_name = & self::$widget_registry[$type];
406 406
 
407 407
 		if (!isset($class_name))
408 408
 		{
409
-			list($basetype) = explode('-',$type);
409
+			list($basetype) = explode('-', $type);
410 410
 			if (//dont think this is used: !class_exists($class_name = 'etemplate_widget_'.str_replace('-','_',$type)) &&
411 411
 				!class_exists($class_name = __CLASS__.'\\'.ucfirst($basetype)) &&
412 412
 				// widgets supplied by application in class ${app}_widget_etemplate or ${app}_${subtype}_widget_etemplate
413 413
 				!(isset($GLOBALS['egw_info']['apps'][$basetype]) &&
414
-					(class_exists($class_name = str_replace('-','_',$type).'_etemplate_widget') ||
414
+					(class_exists($class_name = str_replace('-', '_', $type).'_etemplate_widget') ||
415 415
 					 class_exists($class_name = $basetype.'_etemplate_widget'))))
416 416
 			{
417 417
 				// Try for base type, it's probably better than the root
418
-				if(self::$widget_registry[$basetype] && self::$widget_registry[$basetype] != $class_name)
418
+				if (self::$widget_registry[$basetype] && self::$widget_registry[$basetype] != $class_name)
419 419
 				{
420 420
 					$class_name = self::$widget_registry[$basetype];
421 421
 				}
@@ -436,22 +436,22 @@  discard block
 block discarded – undo
436 436
 		{
437 437
 			// Class in widget registry, but not loaded
438 438
 			// Try for a base class
439
-			$subtypes = explode('-',$type);
439
+			$subtypes = explode('-', $type);
440 440
 			$basetype = $subtypes[0];
441
-			$class_name = __CLASS__.'\\'.implode('\\',array_map('ucfirst',$subtypes));
442
-			if(!class_exists($class_name) && self::$widget_registry[$basetype] && self::$widget_registry[$basetype] != $class_name)
441
+			$class_name = __CLASS__.'\\'.implode('\\', array_map('ucfirst', $subtypes));
442
+			if (!class_exists($class_name) && self::$widget_registry[$basetype] && self::$widget_registry[$basetype] != $class_name)
443 443
 			{
444 444
 				// Try for base type, it's probably better than the root
445 445
 				$class_name = self::$widget_registry[$basetype];
446 446
 			}
447
-			if(!class_exists($class_name))
447
+			if (!class_exists($class_name))
448 448
 			{
449 449
 				// Fall back to widget class, we can not ignore it, as the widget may contain other widgets
450 450
 				$class_name = __CLASS__;
451 451
 			}
452 452
 		}
453 453
 
454
-		if(!$xml)
454
+		if (!$xml)
455 455
 		{
456 456
 			if (empty($type)) $type = 'widget';
457 457
 			$xml = "<$type id=\"$id\"/>";
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 		if ($type == 'template' && $id && ($template = Widget\Template::instance($id)))
463 463
 		{
464 464
 			// references can set different attributes like: class, span, content (namespace)
465
-			return $template->set_attrs($xml, false);	// false = need to clone template, if attributs are set!
465
+			return $template->set_attrs($xml, false); // false = need to clone template, if attributs are set!
466 466
 		}
467 467
 		return new $class_name($xml);
468 468
 	}
@@ -474,9 +474,9 @@  discard block
 block discarded – undo
474 474
 	 * @param string $type =null
475 475
 	 * @return Widget|NULL
476 476
 	 */
477
-	public function getElementById($id, $type=null)
477
+	public function getElementById($id, $type = null)
478 478
 	{
479
-		foreach($this->children as $child)
479
+		foreach ($this->children as $child)
480 480
 		{
481 481
 			if ($child->id === $id && (is_null($type) || $child->type === $type))
482 482
 			{
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 	public function getElementsByType($type)
500 500
 	{
501 501
 		$elements = array();
502
-		foreach($this->children as $child)
502
+		foreach ($this->children as $child)
503 503
 		{
504 504
 			if ($child->type === $type)
505 505
 			{
@@ -519,14 +519,14 @@  discard block
 block discarded – undo
519 519
 	 * @param array $params =array('') parameter(s) first parameter has to be the cname, second $expand!
520 520
 	 * @param boolean $respect_disabled =false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children
521 521
 	 */
522
-	public function run($method_name, $params=array(''), $respect_disabled=false)
522
+	public function run($method_name, $params = array(''), $respect_disabled = false)
523 523
 	{
524 524
 		// maintain $expand array name-expansion
525 525
 		$cname = $params[0];
526
-		$expand =& $params[1];
526
+		$expand = & $params[1];
527 527
 		if ($expand['cname'] && $expand['cname'] !== $cname)
528 528
 		{
529
-			$expand['cont'] =& self::get_array(self::$request->content, $cname);
529
+			$expand['cont'] = & self::get_array(self::$request->content, $cname);
530 530
 			$expand['cname'] = $cname;
531 531
 		}
532 532
 		if ($respect_disabled && ($disabled = $this->attrs['disabled'] && self::check_disabled($this->attrs['disabled'], $expand)))
@@ -539,20 +539,20 @@  discard block
 block discarded – undo
539 539
 			// Some parameter checking to avoid fatal errors
540 540
 			$call = true;
541 541
 			$method = new ReflectionMethod($this, $method_name);
542
-			foreach($method->getParameters() as $index => $param)
542
+			foreach ($method->getParameters() as $index => $param)
543 543
 			{
544
-				if(!$param->isOptional() && !array_key_exists($index,$params))
544
+				if (!$param->isOptional() && !array_key_exists($index, $params))
545 545
 				{
546 546
 					error_log("Missing required parameter {$param->getPosition()}: {$param->getName()}");
547 547
 					$call = false;
548 548
 				}
549
-				if($param->isArray() && !is_array($params[$index]))
549
+				if ($param->isArray() && !is_array($params[$index]))
550 550
 				{
551 551
 					error_log("$method_name expects an array for {$param->getPosition()}: {$param->getName()}");
552 552
 					$params[$index] = (array)$params[$index];
553 553
 				}
554 554
 			}
555
-			if($call) call_user_func_array(array($this, $method_name), $params);
555
+			if ($call) call_user_func_array(array($this, $method_name), $params);
556 556
 		}
557 557
 		// allow calling with a function or closure --> call it with widget as first param
558 558
 		elseif (is_callable($method_name))
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 			$params[2] = $this;
561 561
 			call_user_func_array($method_name, $params);
562 562
 		}
563
-		foreach($this->children as $child)
563
+		foreach ($this->children as $child)
564 564
 		{
565 565
 			// If type has something that can be expanded, we need to expand it so the correct method is run
566 566
 			$this->expand_widget($child, $expand);
@@ -577,13 +577,13 @@  discard block
 block discarded – undo
577 577
 	 */
578 578
 	protected function expand_widget(Widget &$child, array &$expand)
579 579
 	{
580
-		if(strpos($child->attrs['type'], '@') !== false || strpos($child->attrs['type'], '$') !== false)
580
+		if (strpos($child->attrs['type'], '@') !== false || strpos($child->attrs['type'], '$') !== false)
581 581
 		{
582
-			$type = self::expand_name($child->attrs['type'],$expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']);
583
-			$id = self::expand_name($child->id,$expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']);
582
+			$type = self::expand_name($child->attrs['type'], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']);
583
+			$id = self::expand_name($child->id, $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']);
584 584
 			$attrs = $child->attrs;
585 585
 			unset($attrs['type']);
586
-			$expanded_child = self::factory($type, false,$id);
586
+			$expanded_child = self::factory($type, false, $id);
587 587
 			$expanded_child->id = $id;
588 588
 			$expanded_child->type = $type;
589 589
 			$expanded_child->attrs = $attrs + array('type' => $type);
@@ -606,14 +606,14 @@  discard block
 block discarded – undo
606 606
 	{
607 607
 		if (($not = $disabled[0] == '!'))
608 608
 		{
609
-			$disabled = substr($disabled,1);
609
+			$disabled = substr($disabled, 1);
610 610
 		}
611
-		list($value,$check) = $vals = explode('=',$disabled);
611
+		list($value, $check) = $vals = explode('=', $disabled);
612 612
 
613 613
 		// use expand_name to be able to use @ or $
614 614
 		$val = self::expand_name($value, $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']);
615 615
 		$check_val = self::expand_name($check, $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']);
616
-		$result = count($vals) == 1 ? $val != '' : ($check_val[0] == '/' ? preg_match($check_val,$val) : $val == $check_val);
616
+		$result = count($vals) == 1 ? $val != '' : ($check_val[0] == '/' ? preg_match($check_val, $val) : $val == $check_val);
617 617
 		if ($not) $result = !$result;
618 618
 
619 619
 		//error_log(__METHOD__."('".($not?'!':'')."$disabled' = '$val' ".(count($vals) == 1 ? '' : ($not?'!':'=')."= '$check_val'")." = ".($result?'True':'False'));
@@ -655,33 +655,33 @@  discard block
 block discarded – undo
655 655
 	 * 	"del[$cont[id]]" expands to "del[123]" if $cont = array('id' => 123)
656 656
 	 * @return string the expanded name
657 657
 	 */
658
-	protected static function expand_name($name,$c,$row,$c_=0,$row_=0,$cont=array())
658
+	protected static function expand_name($name, $c, $row, $c_ = 0, $row_ = 0, $cont = array())
659 659
 	{
660 660
 		$is_index_in_content = $name[0] == '@';
661
-		if (($pos_var=strpos($name,'$')) !== false)
661
+		if (($pos_var = strpos($name, '$')) !== false)
662 662
 		{
663 663
 			if (!$cont)
664 664
 			{
665 665
 				$cont = array();
666 666
 			}
667 667
 			if (!is_numeric($c)) $c = self::chrs2num($c);
668
-			$col = self::num2chrs($c-1);	// $c-1 to get: 0:'@', 1:'A', ...
669
-			if (is_numeric($c_)) $col_ = self::num2chrs($c_-1);
668
+			$col = self::num2chrs($c - 1); // $c-1 to get: 0:'@', 1:'A', ...
669
+			if (is_numeric($c_)) $col_ = self::num2chrs($c_ - 1);
670 670
 			$row_cont = $cont[$row];
671 671
 			$col_row_cont = $cont[$col.$row];
672 672
 
673
-			eval('$name = "'.str_replace('"','\\"',$name).'";');
674
-			unset($col_, $row_, $row_cont, $col_row_cont);	// quiten IDE warning about used vars, they might be used in above eval!
673
+			eval('$name = "'.str_replace('"', '\\"', $name).'";');
674
+			unset($col_, $row_, $row_cont, $col_row_cont); // quiten IDE warning about used vars, they might be used in above eval!
675 675
 		}
676 676
 		if ($is_index_in_content)
677 677
 		{
678 678
 			if ($name[1] == '@' && is_array(self::$request->content))
679 679
 			{
680
-				$name = self::get_array(self::$request->content,substr($name,2));
680
+				$name = self::get_array(self::$request->content, substr($name, 2));
681 681
 			}
682
-			elseif(is_array($cont))
682
+			elseif (is_array($cont))
683 683
 			{
684
-				$name = self::get_array($cont,substr($name,1));
684
+				$name = self::get_array($cont, substr($name, 1));
685 685
 			}
686 686
 			else
687 687
 			{
@@ -703,11 +703,11 @@  discard block
 block discarded – undo
703 703
 		$min = ord('A');
704 704
 		$max = ord('Z') - $min + 1;
705 705
 
706
-		$num = 1+ord($chrs{0})-$min;
706
+		$num = 1 + ord($chrs{0}) - $min;
707 707
 		if (strlen($chrs) > 1)
708 708
 		{
709 709
 			$num *= 1 + $max - $min;
710
-			$num += 1+ord($chrs{1})-$min;
710
+			$num += 1 + ord($chrs{1}) - $min;
711 711
 		}
712 712
 		return $num;
713 713
 	}
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 	 */
739 739
 	public function __toString()
740 740
 	{
741
-		return '['.get_class($this).'] ' .
741
+		return '['.get_class($this).'] '.
742 742
 			$this->type.($this->attrs['type'] && $this->attrs['type'] != $this->type ? '('.$this->attrs['type'].')' : '').'#'.$this->id;
743 743
 	}
744 744
 
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 	 */
748 748
 	public function __clone()
749 749
 	{
750
-		foreach($this->children as $child_num => $child) {
750
+		foreach ($this->children as $child_num => $child) {
751 751
 			$this->children[$child_num] = clone $child;
752 752
 		}
753 753
 	}
@@ -758,16 +758,16 @@  discard block
 block discarded – undo
758 758
 	 * @param string $indent =''
759 759
 	 * @return string
760 760
 	 */
761
-	public function toXml($indent='')
761
+	public function toXml($indent = '')
762 762
 	{
763 763
 		echo "$indent<$this->type";
764 764
 		if ($this->id) echo ' id="'.htmlspecialchars($this->id).'"';
765
-		foreach($this->attrs as $name => $value)
765
+		foreach ($this->attrs as $name => $value)
766 766
 		{
767 767
 			if ($name == 'options' && $this->legacy_options && (!is_array($this->legacy_options) ||
768 768
 				isset($this->legacy_options[$this->attrs['type'] ? $this->attrs['type'] : $this->type])))
769 769
 			{
770
-				continue;	// do NOT output already converted legacy options
770
+				continue; // do NOT output already converted legacy options
771 771
 			}
772 772
 			echo ' '.$name.'="'.htmlspecialchars($value).'"';
773 773
 		}
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 		if ($this->children)
777 777
 		{
778 778
 			echo ">\n";
779
-			foreach($this->children as $child)
779
+			foreach ($this->children as $child)
780 780
 			{
781 781
 				$child->toXml($indent."\t");
782 782
 			}
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 	 * @param array $expand =null values for keys 'c', 'row', 'c_', 'row_', 'cont'
800 800
 	 * @return string complete form-name
801 801
 	 */
802
-	static function form_name($cname,$name,array $expand=null)
802
+	static function form_name($cname, $name, array $expand = null)
803 803
 	{
804 804
 		if ($expand && !empty($name))
805 805
 		{
@@ -807,18 +807,18 @@  discard block
 block discarded – undo
807 807
 		}
808 808
 		if (count($name_parts = explode('[', $name, 2)) > 1)
809 809
 		{
810
-			$name_parts = array_merge(array($name_parts[0]), explode('][', substr($name_parts[1],0,-1)));
810
+			$name_parts = array_merge(array($name_parts[0]), explode('][', substr($name_parts[1], 0, -1)));
811 811
 		}
812 812
 		if (!empty($cname))
813 813
 		{
814
-			array_unshift($name_parts,$cname);
814
+			array_unshift($name_parts, $cname);
815 815
 		}
816 816
 		$form_name = array_shift($name_parts);
817 817
 		if (count($name_parts))
818 818
 		{
819 819
 			// RB: not sure why this business with entity encoding for square brakets, it messes up validation
820 820
 			//$form_name .= '&#x5B;'.implode('&#x5D;&#x5B;',$name_parts).'&#x5D;';
821
-			$form_name .= '['.implode('][',$name_parts).']';
821
+			$form_name .= '['.implode('][', $name_parts).']';
822 822
 		}
823 823
 		return $form_name;
824 824
 	}
@@ -835,36 +835,36 @@  discard block
 block discarded – undo
835 835
 	 * @param bool $skip_empty returns false if $idx is not present in $arr
836 836
 	 * @return mixed reference to $arr[$idx] or null if $idx is not set and not $reference_into
837 837
 	 */
838
-	static function &get_array(&$arr,$_idx,$reference_into=False,$skip_empty=False)
838
+	static function &get_array(&$arr, $_idx, $reference_into = False, $skip_empty = False)
839 839
 	{
840 840
 		if (!is_array($arr))
841 841
 		{
842 842
 			throw new Api\Exception\AssertionFailed(__METHOD__."(\$arr,'$_idx',$reference_into,$skip_empty) \$arr is no array!");
843 843
 		}
844
-		if (is_object($_idx)) return false;	// given an error in php5.2
844
+		if (is_object($_idx)) return false; // given an error in php5.2
845 845
 
846 846
 		// Make sure none of these are left
847
-		$idx = str_replace(array('&#x5B;','&#x5D;'), array('[',']'), $_idx);
847
+		$idx = str_replace(array('&#x5B;', '&#x5D;'), array('[', ']'), $_idx);
848 848
 
849 849
 		// Handle things expecting arrays - ends in []
850
-		if(substr($idx,-2) == "[]")
850
+		if (substr($idx, -2) == "[]")
851 851
 		{
852
-			$idx = substr($idx,0,-2);
852
+			$idx = substr($idx, 0, -2);
853 853
 		}
854 854
 
855 855
 		if (count($idxs = explode('[', $idx, 2)) > 1)
856 856
 		{
857
-			$idxs = array_merge(array($idxs[0]), explode('][', substr($idxs[1],0,-1)));
857
+			$idxs = array_merge(array($idxs[0]), explode('][', substr($idxs[1], 0, -1)));
858 858
 		}
859 859
 		$pos = &$arr;
860
-		foreach($idxs as $idx)
860
+		foreach ($idxs as $idx)
861 861
 		{
862 862
 			if (!is_array($pos) && (!$reference_into || $reference_into && isset($pos)))
863 863
 			{
864 864
 				//if ($reference_into) error_log(__METHOD__."(".(strlen($s=array2string($arr))>512?substr($s,0,512).'...':$s).", '$idx', ".array2string($reference_into).", ".array2string($skip_empty).") ".function_backtrace());
865 865
 				return null;
866 866
 			}
867
-			if($skip_empty && (!is_array($pos) || !isset($pos[$idx]))) return null;
867
+			if ($skip_empty && (!is_array($pos) || !isset($pos[$idx]))) return null;
868 868
 			$pos = &$pos[$idx];
869 869
 		}
870 870
 		return $pos;
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 	 */
883 883
 	static function set_array(&$_arr, $_idx, $_value)
884 884
 	{
885
-		$ref =& self::get_array($_arr, $_idx, true);
885
+		$ref = & self::get_array($_arr, $_idx, true);
886 886
 		if (true) $ref = $_value;
887 887
 	}
888 888
 
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 	 * @param string $form_name =null form_name, to not calculate him again
897 897
 	 * @return boolean
898 898
 	 */
899
-	public function is_readonly($cname='', $form_name=null)
899
+	public function is_readonly($cname = '', $form_name = null)
900 900
 	{
901 901
 		if (!isset($form_name))
902 902
 		{
@@ -906,11 +906,11 @@  discard block
 block discarded – undo
906 906
 			$form_name = self::form_name($cname, $this->id, $expand);
907 907
 		}
908 908
 		$readonly = $this->attrs['readonly'] || self::$request->readonlys[$form_name] ||
909
-			self::get_array(self::$request->readonlys,$form_name) === true ||
909
+			self::get_array(self::$request->readonlys, $form_name) === true ||
910 910
 			isset(self::$request->readonlys['__ALL__']) && (
911 911
 				// Exceptions to all
912 912
 				self::$request->readonlys[$form_name] !== false &&
913
-				self::get_array(self::$request->readonlys,$form_name) !== false
913
+				self::get_array(self::$request->readonlys, $form_name) !== false
914 914
 			);
915 915
 
916 916
 		//error_log(__METHOD__."('$cname') this->id='$this->id' --> form_name='$form_name': attrs[readonly]=".array2string($this->attrs['readonly']).", readonlys['$form_name']=".array2string(self::$request->readonlys[$form_name]).", readonlys[$form_name]=".array2string(self::get_array(self::$request->readonlys,$form_name)).", readonlys['__ALL__']=".array2string(self::$request->readonlys['__ALL__'])." returning ".array2string($readonly));
@@ -930,12 +930,12 @@  discard block
 block discarded – undo
930 930
 	 * @param string|boolean $error error-message already translated or false to reset all existing error for given name
931 931
 	 * @param string $cname =null set it to '', if the name is already a form-name, defaults to self::$name_vars
932 932
 	 */
933
-	public static function set_validation_error($name,$error,$cname=null)
933
+	public static function set_validation_error($name, $error, $cname = null)
934 934
 	{
935 935
 		// not yet used: if (is_null($cname)) $cname = self::$name_vars;
936 936
 		//error_log(__METHOD__."('$name','$error','$cname') ".function_backtrace());
937 937
 
938
-		if ($cname) $name = self::form_name($cname,$name);
938
+		if ($cname) $name = self::form_name($cname, $name);
939 939
 
940 940
 		if ($error === false)
941 941
 		{
@@ -958,18 +958,18 @@  discard block
 block discarded – undo
958 958
 	* @param string $cname =null name-prefix, which need to be ignored, default self::$name_vars
959 959
 	* @return boolean true if there are not ignored validation errors, false otherwise
960 960
 	*/
961
-	public static function validation_errors($ignore_validation='',$cname='')
961
+	public static function validation_errors($ignore_validation = '', $cname = '')
962 962
 	{
963 963
 		// not yet used: if (is_null($cname)) $cname = self::$name_vars;
964 964
 		//echo "<p>uietemplate::validation_errors('$ignore_validation','$cname') validation_error="; _debug_array(self::$validation_errors);
965 965
 		if (!$ignore_validation) return count(self::$validation_errors) > 0;
966 966
 
967
-		foreach(array_values(self::$validation_errors) as $name)
967
+		foreach (array_values(self::$validation_errors) as $name)
968 968
 		{
969
-			if ($cname) $name = preg_replace('/^'.$cname.'\[([^\]]+)\](.*)$/','\\1\\2',$name);
969
+			if ($cname) $name = preg_replace('/^'.$cname.'\[([^\]]+)\](.*)$/', '\\1\\2', $name);
970 970
 
971 971
 			// treat $ignoare_validation only as regular expression, if it starts with a slash
972
-			if ($ignore_validation[0] == '/' && !preg_match($ignore_validation,$name) ||
972
+			if ($ignore_validation[0] == '/' && !preg_match($ignore_validation, $name) ||
973 973
 				$ignore_validation[0] != '/' && $ignore_validation != $name)
974 974
 			{
975 975
 				//echo "<p>uietemplate::validation_errors('$ignore_validation','$cname') name='$name' ($error) not ignored!!!</p>\n";
@@ -1006,14 +1006,14 @@  discard block
 block discarded – undo
1006 1006
 	 * @param mixed $val if not NULL sets attribute else returns it
1007 1007
 	 * @return reference to attribute
1008 1008
 	 */
1009
-	public static function &setElementAttribute($name,$attr,$val)
1009
+	public static function &setElementAttribute($name, $attr, $val)
1010 1010
 	{
1011 1011
 		//error_log(__METHOD__."('$name', '$attr', ...) request=".get_class(self::$request).", response=".get_class(self::$response).function_backtrace());
1012
-		$ref =& self::$request->modifications[$name][$attr];
1013
-		if(self::$request && self::$response)
1012
+		$ref = & self::$request->modifications[$name][$attr];
1013
+		if (self::$request && self::$response)
1014 1014
 		{
1015 1015
 			// In an AJAX response - automatically add
1016
-			self::$response->generic('assign',array(
1016
+			self::$response->generic('assign', array(
1017 1017
 				'etemplate_exec_id' => self::$request->id(),
1018 1018
 				'id' => $name,
1019 1019
 				'key' => $attr,
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
 	 * @param boolean $disabled =true disable or enable a cell, default true=disable
1037 1037
 	 * @return reference to attribute
1038 1038
 	 */
1039
-	public function disableElement($name,$disabled=True)
1039
+	public function disableElement($name, $disabled = True)
1040 1040
 	{
1041 1041
 		return self::setElementAttribute($name, 'disabled', $disabled);
1042 1042
 	}
Please login to merge, or discard this patch.
Braces   +78 added lines, -21 removed lines patch added patch discarded remove patch
@@ -113,7 +113,9 @@  discard block
 block discarded – undo
113 113
 
114 114
 		// Update content?
115 115
 		if(self::$cont == null)
116
-			self::$cont = is_array(self::$request->content) ? self::$request->content : array();
116
+		{
117
+					self::$cont = is_array(self::$request->content) ? self::$request->content : array();
118
+		}
117 119
 		if($this->id && is_array(self::$cont[$this->id]))
118 120
 		{
119 121
 			$old_cont = self::$cont;
@@ -137,7 +139,8 @@  discard block
 block discarded – undo
137 139
 		}
138 140
 
139 141
 		// Reset content as we leave
140
-		if($old_cont) {
142
+		if($old_cont)
143
+		{
141 144
 			self::$cont = $old_cont;
142 145
 		}
143 146
 	}
@@ -219,7 +222,10 @@  discard block
 block discarded – undo
219 222
 					$legacy_options = explode(',', $legacy_options);
220 223
 					foreach(self::csv_split($value, count($legacy_options)) as $n => $val)
221 224
 					{
222
-						if ($legacy_options[$n] && (string)$val !== '') $template->attrs[$legacy_options[$n]] = $val;
225
+						if ($legacy_options[$n] && (string)$val !== '')
226
+						{
227
+							$template->attrs[$legacy_options[$n]] = $val;
228
+						}
223 229
 					}
224 230
 				}
225 231
 			}
@@ -237,7 +243,10 @@  discard block
 block discarded – undo
237 243
 		{
238 244
 			if (!isset($this->attrs[$name]))
239 245
 			{
240
-				if (isset($default_value)) $this->attrs[$name] = $default_value;
246
+				if (isset($default_value))
247
+				{
248
+					$this->attrs[$name] = $default_value;
249
+				}
241 250
 			}
242 251
 			// cast to bool, only if NOT containing variables
243 252
 			elseif (!is_bool($this->attrs[$name]) && strpos($this->attrs[$name], '@') === false &&
@@ -342,13 +351,16 @@  discard block
 block discarded – undo
342 351
 	{
343 352
 		$widget_registry = Api\Cache::getInstance('etemplate', 'widget_registry');
344 353
 
345
-		if (!$widget_registry)	// not in instance cache --> rescan from filesystem
354
+		if (!$widget_registry)
355
+		{
356
+			// not in instance cache --> rescan from filesystem
346 357
 		{
347 358
 			foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__.'/Widget')) as $path)
348 359
 			{
349 360
 				if(strpos($path, 'tests/') !== FALSE)
350 361
 				{
351 362
 					continue;
363
+		}
352 364
 				}
353 365
 				if(substr($path, -4) == '.php')
354 366
 				{
@@ -383,8 +395,12 @@  discard block
 block discarded – undo
383 395
 				}
384 396
 			}
385 397
 			if (self::$widget_registry['htmlarea'] === Api\Etemplate\Widget\HtmlArea::class)
386
-			Api\Cache::setInstance('etemplate', 'widget_registry', self::$widget_registry, 3600);
387
-			else error_log(__METHOD__."() wrong class for Htmlarea: ".function_backtrace ());
398
+			{
399
+						Api\Cache::setInstance('etemplate', 'widget_registry', self::$widget_registry, 3600);
400
+			}
401
+			else {
402
+				error_log(__METHOD__."() wrong class for Htmlarea: ".function_backtrace ());
403
+			}
388 404
 		}
389 405
 		else
390 406
 		{
@@ -453,7 +469,10 @@  discard block
 block discarded – undo
453 469
 
454 470
 		if(!$xml)
455 471
 		{
456
-			if (empty($type)) $type = 'widget';
472
+			if (empty($type))
473
+			{
474
+				$type = 'widget';
475
+			}
457 476
 			$xml = "<$type id=\"$id\"/>";
458 477
 		}
459 478
 		//error_log(__METHOD__."('$type', ..., '$id') using $class_name");
@@ -552,7 +571,10 @@  discard block
 block discarded – undo
552 571
 					$params[$index] = (array)$params[$index];
553 572
 				}
554 573
 			}
555
-			if($call) call_user_func_array(array($this, $method_name), $params);
574
+			if($call)
575
+			{
576
+				call_user_func_array(array($this, $method_name), $params);
577
+			}
556 578
 		}
557 579
 		// allow calling with a function or closure --> call it with widget as first param
558 580
 		elseif (is_callable($method_name))
@@ -614,7 +636,10 @@  discard block
 block discarded – undo
614 636
 		$val = self::expand_name($value, $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']);
615 637
 		$check_val = self::expand_name($check, $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']);
616 638
 		$result = count($vals) == 1 ? $val != '' : ($check_val[0] == '/' ? preg_match($check_val,$val) : $val == $check_val);
617
-		if ($not) $result = !$result;
639
+		if ($not)
640
+		{
641
+			$result = !$result;
642
+		}
618 643
 
619 644
 		//error_log(__METHOD__."('".($not?'!':'')."$disabled' = '$val' ".(count($vals) == 1 ? '' : ($not?'!':'=')."= '$check_val'")." = ".($result?'True':'False'));
620 645
 		return $result;
@@ -664,9 +689,15 @@  discard block
 block discarded – undo
664 689
 			{
665 690
 				$cont = array();
666 691
 			}
667
-			if (!is_numeric($c)) $c = self::chrs2num($c);
692
+			if (!is_numeric($c))
693
+			{
694
+				$c = self::chrs2num($c);
695
+			}
668 696
 			$col = self::num2chrs($c-1);	// $c-1 to get: 0:'@', 1:'A', ...
669
-			if (is_numeric($c_)) $col_ = self::num2chrs($c_-1);
697
+			if (is_numeric($c_))
698
+			{
699
+				$col_ = self::num2chrs($c_-1);
700
+			}
670 701
 			$row_cont = $cont[$row];
671 702
 			$col_row_cont = $cont[$col.$row];
672 703
 
@@ -747,7 +778,8 @@  discard block
 block discarded – undo
747 778
 	 */
748 779
 	public function __clone()
749 780
 	{
750
-		foreach($this->children as $child_num => $child) {
781
+		foreach($this->children as $child_num => $child)
782
+		{
751 783
 			$this->children[$child_num] = clone $child;
752 784
 		}
753 785
 	}
@@ -761,7 +793,10 @@  discard block
 block discarded – undo
761 793
 	public function toXml($indent='')
762 794
 	{
763 795
 		echo "$indent<$this->type";
764
-		if ($this->id) echo ' id="'.htmlspecialchars($this->id).'"';
796
+		if ($this->id)
797
+		{
798
+			echo ' id="'.htmlspecialchars($this->id).'"';
799
+		}
765 800
 		foreach($this->attrs as $name => $value)
766 801
 		{
767 802
 			if ($name == 'options' && $this->legacy_options && (!is_array($this->legacy_options) ||
@@ -841,7 +876,11 @@  discard block
 block discarded – undo
841 876
 		{
842 877
 			throw new Api\Exception\AssertionFailed(__METHOD__."(\$arr,'$_idx',$reference_into,$skip_empty) \$arr is no array!");
843 878
 		}
844
-		if (is_object($_idx)) return false;	// given an error in php5.2
879
+		if (is_object($_idx))
880
+		{
881
+			return false;
882
+		}
883
+		// given an error in php5.2
845 884
 
846 885
 		// Make sure none of these are left
847 886
 		$idx = str_replace(array('&#x5B;','&#x5D;'), array('[',']'), $_idx);
@@ -864,7 +903,10 @@  discard block
 block discarded – undo
864 903
 				//if ($reference_into) error_log(__METHOD__."(".(strlen($s=array2string($arr))>512?substr($s,0,512).'...':$s).", '$idx', ".array2string($reference_into).", ".array2string($skip_empty).") ".function_backtrace());
865 904
 				return null;
866 905
 			}
867
-			if($skip_empty && (!is_array($pos) || !isset($pos[$idx]))) return null;
906
+			if($skip_empty && (!is_array($pos) || !isset($pos[$idx])))
907
+			{
908
+				return null;
909
+			}
868 910
 			$pos = &$pos[$idx];
869 911
 		}
870 912
 		return $pos;
@@ -883,7 +925,10 @@  discard block
 block discarded – undo
883 925
 	static function set_array(&$_arr, $_idx, $_value)
884 926
 	{
885 927
 		$ref =& self::get_array($_arr, $_idx, true);
886
-		if (true) $ref = $_value;
928
+		if (true)
929
+		{
930
+			$ref = $_value;
931
+		}
887 932
 	}
888 933
 
889 934
 	/**
@@ -935,7 +980,10 @@  discard block
 block discarded – undo
935 980
 		// not yet used: if (is_null($cname)) $cname = self::$name_vars;
936 981
 		//error_log(__METHOD__."('$name','$error','$cname') ".function_backtrace());
937 982
 
938
-		if ($cname) $name = self::form_name($cname,$name);
983
+		if ($cname)
984
+		{
985
+			$name = self::form_name($cname,$name);
986
+		}
939 987
 
940 988
 		if ($error === false)
941 989
 		{
@@ -962,11 +1010,17 @@  discard block
 block discarded – undo
962 1010
 	{
963 1011
 		// not yet used: if (is_null($cname)) $cname = self::$name_vars;
964 1012
 		//echo "<p>uietemplate::validation_errors('$ignore_validation','$cname') validation_error="; _debug_array(self::$validation_errors);
965
-		if (!$ignore_validation) return count(self::$validation_errors) > 0;
1013
+		if (!$ignore_validation)
1014
+		{
1015
+			return count(self::$validation_errors) > 0;
1016
+		}
966 1017
 
967 1018
 		foreach(array_values(self::$validation_errors) as $name)
968 1019
 		{
969
-			if ($cname) $name = preg_replace('/^'.$cname.'\[([^\]]+)\](.*)$/','\\1\\2',$name);
1020
+			if ($cname)
1021
+			{
1022
+				$name = preg_replace('/^'.$cname.'\[([^\]]+)\](.*)$/','\\1\\2',$name);
1023
+			}
970 1024
 
971 1025
 			// treat $ignoare_validation only as regular expression, if it starts with a slash
972 1026
 			if ($ignore_validation[0] == '/' && !preg_match($ignore_validation,$name) ||
@@ -1023,7 +1077,10 @@  discard block
 block discarded – undo
1023 1077
 			self::$request->unset_to_process('');
1024 1078
 			//error_log(__METHOD__."('$name', '$attr', ...) ".function_backtrace());
1025 1079
 		}
1026
-		if (!is_null($val)) $ref = $val;
1080
+		if (!is_null($val))
1081
+		{
1082
+			$ref = $val;
1083
+		}
1027 1084
 
1028 1085
 		//error_log(__METHOD__."('$name', '$attr', ".array2string($val).')');
1029 1086
 		return $ref;
Please login to merge, or discard this patch.