Completed
Push — master ( aa44e9...fa84e5 )
by Ralf
90:14 queued 73:21
created
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.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
 	 *
28 28
 	 * @param string $xml
29 29
 	 */
30
-	public function __construct($xml='')
30
+	public function __construct($xml = '')
31 31
 	{
32
-		if($xml) parent::__construct($xml);
32
+		if ($xml) parent::__construct($xml);
33 33
 
34 34
 		// Legacy multiple - id ends in []
35
-		if(substr($this->id,-2) == '[]')
35
+		if (substr($this->id, -2) == '[]')
36 36
 		{
37 37
 			$this->setElementAttribute($this->id, 'multiple', true);
38 38
 		}
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 		$response = Api\Json\Response::get();
53 53
 		$request_id = str_replace(' ', '+', rawurldecode($_REQUEST['request_id']));
54 54
 		$widget_id = $_REQUEST['widget_id'];
55
-		if(!self::$request = Etemplate\Request::read($request_id)) {
55
+		if (!self::$request = Etemplate\Request::read($request_id)) {
56 56
 			$response->error("Could not read session");
57 57
 			return;
58 58
 		}
@@ -70,20 +70,20 @@  discard block
 block discarded – undo
70 70
 		foreach ($_FILES as $field => &$files)
71 71
 		{
72 72
 			$widget = $template->getElementById($widget_id ? $widget_id : $field);
73
-			if($widget && $widget->attrs['mime']) {
73
+			if ($widget && $widget->attrs['mime']) {
74 74
 				$mime = $widget->attrs['mime'];
75 75
 			}
76 76
 
77 77
 			// Check for legacy [] in id to indicate multiple - it changes format
78
-			if(is_array($files['name'])) {
78
+			if (is_array($files['name'])) {
79 79
 				$file_list = array();
80
-				foreach($files as $f_field => $values)
80
+				foreach ($files as $f_field => $values)
81 81
 				{
82
-					foreach($values as $key => $f_value) {
82
+					foreach ($values as $key => $f_value) {
83 83
 						$file_list[$key][$f_field] = $f_value;
84 84
 					}
85 85
 				}
86
-				foreach($file_list as $file)
86
+				foreach ($file_list as $file)
87 87
 				{
88 88
 					self::process_uploaded_file($field, $file, $mime, $file_data);
89 89
 				}
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
 		$response->data($file_data);
100 100
 
101 101
 		// Check for a callback, call it if there is one
102
-		foreach($_FILES as $field => $file)
102
+		foreach ($_FILES as $field => $file)
103 103
 		{
104
-			if(($element = $template->getElementById($field)))
104
+			if (($element = $template->getElementById($field)))
105 105
 			{
106 106
 				$callback = $element->attrs['callback'];
107
-				if(!$callback) $callback = $template->getElementAttribute($field, 'callback');
108
-				if($callback)
107
+				if (!$callback) $callback = $template->getElementAttribute($field, 'callback');
108
+				if ($callback)
109 109
 				{
110 110
 					ExecMethod($callback, $_FILES[$field]);
111 111
 				}
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	protected static function process_uploaded_file($field, Array &$file, $mime, Array &$file_data)
120 120
 	{
121
-		unset($field);	// not used
121
+		unset($field); // not used
122 122
 
123 123
 		// Chunks get mangled a little
124
-		if($file['name'] == 'blob')
124
+		if ($file['name'] == 'blob')
125 125
 		{
126 126
 			$file['name'] = $_POST['resumableFilename'];
127 127
 			$file['type'] = $_POST['resumableType'];
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 
130 130
 		if ($file['error'] == UPLOAD_ERR_OK && trim($file['name']) != '' && $file['size'] > 0 && is_uploaded_file($file['tmp_name'])) {
131 131
 			// Mime check
132
-			if($mime)
132
+			if ($mime)
133 133
 			{
134 134
 				$type = $file['type'];
135 135
 				$is_preg = $mime[0] == '/';
136
-				if (!$is_preg && strcasecmp($mime,$type) ||
137
-					$is_preg && !preg_match($mime,$type))
136
+				if (!$is_preg && strcasecmp($mime, $type) ||
137
+					$is_preg && !preg_match($mime, $type))
138 138
 				{
139
-					$file_data[$file['name']] = $file['name'].':'.lang('File is of wrong type (%1 != %2)!',$type,$mime);
139
+					$file_data[$file['name']] = $file['name'].':'.lang('File is of wrong type (%1 != %2)!', $type, $mime);
140 140
 					//error_log(__METHOD__.__LINE__.array2string($file_data[$file['name']]));
141 141
 					return false;
142 142
 				}
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 			// Resumable / chunked uploads
146 146
 			// init the destination file (format <filename.ext>.part<#chunk>
147 147
 			// the file is stored in a temporary directory
148
-			$temp_dir = $GLOBALS['egw_info']['server']['temp_dir'].'/'.str_replace('/','_',$_POST['resumableIdentifier']);
149
-			$dest_file = $temp_dir.'/'.str_replace('/','_',$_POST['resumableFilename']).'.part'.(int)$_POST['resumableChunkNumber'];
148
+			$temp_dir = $GLOBALS['egw_info']['server']['temp_dir'].'/'.str_replace('/', '_', $_POST['resumableIdentifier']);
149
+			$dest_file = $temp_dir.'/'.str_replace('/', '_', $_POST['resumableFilename']).'.part'.(int)$_POST['resumableChunkNumber'];
150 150
 
151 151
 			// create the temporary directory
152 152
 			if (!is_dir($temp_dir))
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
 			else
163 163
 			{
164 164
 				// check if all the parts present, and create the final destination file
165
-				$new_file = self::createFileFromChunks($temp_dir, str_replace('/','_',$_POST['resumableFilename']),
165
+				$new_file = self::createFileFromChunks($temp_dir, str_replace('/', '_', $_POST['resumableFilename']),
166 166
 						$_POST['resumableChunkSize'], $_POST['resumableTotalSize']);
167 167
 			}
168
-			if( $new_file) {
168
+			if ($new_file) {
169 169
 				$file['tmp_name'] = $new_file;
170 170
 
171 171
 				// Data to send back to client
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 
195 195
 		// count all the parts of this file
196 196
 		$total_files = 0;
197
-		foreach(scandir($temp_dir) as $file) {
197
+		foreach (scandir($temp_dir) as $file) {
198 198
 			if (stripos($file, $fileName) !== false) {
199 199
 				$total_files++;
200 200
 			}
@@ -202,10 +202,10 @@  discard block
 block discarded – undo
202 202
 
203 203
 		// check that all the parts are present
204 204
 		// the size of the last part is between chunkSize and 2*$chunkSize
205
-		if ($total_files * $chunkSize >=  ($totalSize - $chunkSize + 1)) {
205
+		if ($total_files * $chunkSize >= ($totalSize - $chunkSize + 1)) {
206 206
 			if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
207 207
 			{
208
-				$new_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'egw_');
208
+				$new_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'egw_');
209 209
 			}
210 210
 			else
211 211
 			{
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 
215 215
 			// create the final destination file
216 216
 			if (($fp = fopen($new_file, 'w')) !== false) {
217
-				for ($i=1; $i<=$total_files; $i++) {
217
+				for ($i = 1; $i <= $total_files; $i++) {
218 218
 					fwrite($fp, file_get_contents($temp_dir.'/'.$fileName.'.part'.$i));
219 219
 				}
220 220
 				fclose($fp);
@@ -250,13 +250,13 @@  discard block
 block discarded – undo
250 250
 			{
251 251
 				if ($object != "." && $object != "..")
252 252
 				{
253
-					if (filetype($dir . "/" . $object) == "dir")
253
+					if (filetype($dir."/".$object) == "dir")
254 254
 					{
255
-						self::rrmdir($dir . "/" . $object);
255
+						self::rrmdir($dir."/".$object);
256 256
 					}
257 257
 					else
258 258
 					{
259
-						unlink($dir . "/" . $object);
259
+						unlink($dir."/".$object);
260 260
 					}
261 261
 				}
262 262
 			}
@@ -273,23 +273,23 @@  discard block
 block discarded – undo
273 273
 	 * @param array $content
274 274
 	 * @param array &$validated=array() validated content
275 275
 	 */
276
-	public function validate($cname, array $expand, array $content, &$validated=array())
276
+	public function validate($cname, array $expand, array $content, &$validated = array())
277 277
 	{
278 278
 		$form_name = self::form_name($cname, $this->id, $expand);
279 279
 
280 280
 		if (!$this->is_readonly($cname, $form_name))
281 281
 		{
282 282
 			$value = $value_in = self::get_array($content, $form_name);
283
-			$valid =& self::get_array($validated, $form_name, true);
283
+			$valid = & self::get_array($validated, $form_name, true);
284 284
 
285
-			if(!is_array($value)) $value = array();
285
+			if (!is_array($value)) $value = array();
286 286
 
287 287
 			// Incoming values indexed by temp name
288
-			if($value[0]) $value = $value[0];
288
+			if ($value[0]) $value = $value[0];
289 289
 
290
-			foreach($value as $tmp => $file)
290
+			foreach ($value as $tmp => $file)
291 291
 			{
292
-				if(!$file) continue;
292
+				if (!$file) continue;
293 293
 				if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
294 294
 				{
295 295
 					$path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmp;
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 				);
310 310
 			}
311 311
 
312
-			if($valid && !$this->attrs['multiple']) $valid = $valid[0];
312
+			if ($valid && !$this->attrs['multiple']) $valid = $valid[0];
313 313
 		}
314 314
 	}
315 315
 }
Please login to merge, or discard this patch.
Braces   +58 added lines, -22 removed lines patch added patch discarded remove patch
@@ -29,7 +29,10 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function __construct($xml='')
31 31
 	{
32
-		if($xml) parent::__construct($xml);
32
+		if($xml)
33
+		{
34
+			parent::__construct($xml);
35
+		}
33 36
 
34 37
 		// Legacy multiple - id ends in []
35 38
 		if(substr($this->id,-2) == '[]')
@@ -48,11 +51,13 @@  discard block
 block discarded – undo
48 51
 	 *
49 52
 	 * @note Currently, no attempt is made to clean up files automatically.
50 53
 	 */
51
-	public static function ajax_upload() {
54
+	public static function ajax_upload()
55
+	{
52 56
 		$response = Api\Json\Response::get();
53 57
 		$request_id = str_replace(' ', '+', rawurldecode($_REQUEST['request_id']));
54 58
 		$widget_id = $_REQUEST['widget_id'];
55
-		if(!self::$request = Etemplate\Request::read($request_id)) {
59
+		if(!self::$request = Etemplate\Request::read($request_id))
60
+		{
56 61
 			$response->error("Could not read session");
57 62
 			return;
58 63
 		}
@@ -70,16 +75,19 @@  discard block
 block discarded – undo
70 75
 		foreach ($_FILES as $field => &$files)
71 76
 		{
72 77
 			$widget = $template->getElementById($widget_id ? $widget_id : $field);
73
-			if($widget && $widget->attrs['mime']) {
78
+			if($widget && $widget->attrs['mime'])
79
+			{
74 80
 				$mime = $widget->attrs['mime'];
75 81
 			}
76 82
 
77 83
 			// Check for legacy [] in id to indicate multiple - it changes format
78
-			if(is_array($files['name'])) {
84
+			if(is_array($files['name']))
85
+			{
79 86
 				$file_list = array();
80 87
 				foreach($files as $f_field => $values)
81 88
 				{
82
-					foreach($values as $key => $f_value) {
89
+					foreach($values as $key => $f_value)
90
+					{
83 91
 						$file_list[$key][$f_field] = $f_value;
84 92
 					}
85 93
 				}
@@ -104,7 +112,10 @@  discard block
 block discarded – undo
104 112
 			if(($element = $template->getElementById($field)))
105 113
 			{
106 114
 				$callback = $element->attrs['callback'];
107
-				if(!$callback) $callback = $template->getElementAttribute($field, 'callback');
115
+				if(!$callback)
116
+				{
117
+					$callback = $template->getElementAttribute($field, 'callback');
118
+				}
108 119
 				if($callback)
109 120
 				{
110 121
 					ExecMethod($callback, $_FILES[$field]);
@@ -127,7 +138,8 @@  discard block
 block discarded – undo
127 138
 			$file['type'] = $_POST['resumableType'];
128 139
 		}
129 140
 
130
-		if ($file['error'] == UPLOAD_ERR_OK && trim($file['name']) != '' && $file['size'] > 0 && is_uploaded_file($file['tmp_name'])) {
141
+		if ($file['error'] == UPLOAD_ERR_OK && trim($file['name']) != '' && $file['size'] > 0 && is_uploaded_file($file['tmp_name']))
142
+		{
131 143
 			// Mime check
132 144
 			if($mime)
133 145
 			{
@@ -165,7 +177,8 @@  discard block
 block discarded – undo
165 177
 				$new_file = self::createFileFromChunks($temp_dir, str_replace('/','_',$_POST['resumableFilename']),
166 178
 						$_POST['resumableChunkSize'], $_POST['resumableTotalSize']);
167 179
 			}
168
-			if( $new_file) {
180
+			if( $new_file)
181
+			{
169 182
 				$file['tmp_name'] = $new_file;
170 183
 
171 184
 				// Data to send back to client
@@ -190,19 +203,23 @@  discard block
 block discarded – undo
190 203
 	 * @param string $chunkSize - each chunk size (in bytes)
191 204
 	 * @param string $totalSize - original file size (in bytes)
192 205
 	 */
193
-	private static function createFileFromChunks($temp_dir, $fileName, $chunkSize, $totalSize) {
206
+	private static function createFileFromChunks($temp_dir, $fileName, $chunkSize, $totalSize)
207
+	{
194 208
 
195 209
 		// count all the parts of this file
196 210
 		$total_files = 0;
197
-		foreach(scandir($temp_dir) as $file) {
198
-			if (stripos($file, $fileName) !== false) {
211
+		foreach(scandir($temp_dir) as $file)
212
+		{
213
+			if (stripos($file, $fileName) !== false)
214
+			{
199 215
 				$total_files++;
200 216
 			}
201 217
 		}
202 218
 
203 219
 		// check that all the parts are present
204 220
 		// the size of the last part is between chunkSize and 2*$chunkSize
205
-		if ($total_files * $chunkSize >=  ($totalSize - $chunkSize + 1)) {
221
+		if ($total_files * $chunkSize >=  ($totalSize - $chunkSize + 1))
222
+		{
206 223
 			if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
207 224
 			{
208 225
 				$new_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'egw_');
@@ -213,21 +230,28 @@  discard block
 block discarded – undo
213 230
 			}
214 231
 
215 232
 			// create the final destination file
216
-			if (($fp = fopen($new_file, 'w')) !== false) {
217
-				for ($i=1; $i<=$total_files; $i++) {
233
+			if (($fp = fopen($new_file, 'w')) !== false)
234
+			{
235
+				for ($i=1; $i<=$total_files; $i++)
236
+				{
218 237
 					fwrite($fp, file_get_contents($temp_dir.'/'.$fileName.'.part'.$i));
219 238
 				}
220 239
 				fclose($fp);
221
-			} else {
240
+			}
241
+			else
242
+			{
222 243
 				_log('cannot create the destination file');
223 244
 				return false;
224 245
 			}
225 246
 
226 247
 			// rename the temporary directory (to avoid access from other
227 248
 			// concurrent chunks uploads) and than delete it
228
-			if (rename($temp_dir, $temp_dir.'_UNUSED')) {
249
+			if (rename($temp_dir, $temp_dir.'_UNUSED'))
250
+			{
229 251
 				self::rrmdir($temp_dir.'_UNUSED');
230
-			} else {
252
+			}
253
+			else
254
+			{
231 255
 				self::rrmdir($temp_dir);
232 256
 			}
233 257
 
@@ -282,14 +306,23 @@  discard block
 block discarded – undo
282 306
 			$value = $value_in = self::get_array($content, $form_name);
283 307
 			$valid =& self::get_array($validated, $form_name, true);
284 308
 
285
-			if(!is_array($value)) $value = array();
309
+			if(!is_array($value))
310
+			{
311
+				$value = array();
312
+			}
286 313
 
287 314
 			// Incoming values indexed by temp name
288
-			if($value[0]) $value = $value[0];
315
+			if($value[0])
316
+			{
317
+				$value = $value[0];
318
+			}
289 319
 
290 320
 			foreach($value as $tmp => $file)
291 321
 			{
292
-				if(!$file) continue;
322
+				if(!$file)
323
+				{
324
+					continue;
325
+				}
293 326
 				if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
294 327
 				{
295 328
 					$path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmp;
@@ -309,7 +342,10 @@  discard block
 block discarded – undo
309 342
 				);
310 343
 			}
311 344
 
312
-			if($valid && !$this->attrs['multiple']) $valid = $valid[0];
345
+			if($valid && !$this->attrs['multiple'])
346
+			{
347
+				$valid = $valid[0];
348
+			}
313 349
 		}
314 350
 	}
315 351
 }
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.
api/src/Etemplate/Widget/Button.php 3 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.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
 	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
43 43
 	 * @param array $content
44 44
 	 * @param array &$validated=array() validated content
45
-	 * @return boolean true if no validation error, false otherwise
45
+	 * @return boolean|null true if no validation error, false otherwise
46 46
 	 */
47 47
 	public function validate($cname, array $expand, array $content, &$validated=array())
48 48
 	{
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/HtmlArea.php 3 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
 		$form_name = self::form_name($cname, $this->id);
39 39
 
40 40
 		$config = Api\Html\CkEditorConfig::get_ckeditor_config_array($this->attrs['mode'], $this->attrs['height'],
41
-			$this->attrs['expand_toolbar'],$this->attrs['base_href']
41
+			$this->attrs['expand_toolbar'], $this->attrs['base_href']
42 42
 		);
43 43
 		// User preferences
44 44
 		$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
45 45
 		$font_size = Api\Html\CkEditorConfig::font_size_from_prefs();
46 46
 		$font_span = '<span style="width: 100%; display: inline; '.
47
-			($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').
47
+			($font ? 'font-family:'.$font.'; ' : '').($font_size ? 'font-size:'.$font_size.'; ' : '').
48 48
 			'">&#8203;</span>';
49 49
 		if (empty($font) && empty($font_size)) $font_span = '';
50
-		if($font_span)
50
+		if ($font_span)
51 51
 		{
52 52
 			$config['preference_style'] = $font_span;
53 53
 		}
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 * @param array &$validated=array() validated content
66 66
 	 * @return boolean true if no validation error, false otherwise
67 67
 	 */
68
-	public function validate($cname, array $expand, array $content, &$validated=array())
68
+	public function validate($cname, array $expand, array $content, &$validated = array())
69 69
 	{
70 70
 		$form_name = self::form_name($cname, $this->id, $expand);
71 71
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			{
78 78
 				$value = Api\Html\HtmLawed::purify($value, $this->attrs['validation_rules']);
79 79
 			}
80
-			$valid =& self::get_array($validated, $form_name, true);
80
+			$valid = & self::get_array($validated, $form_name, true);
81 81
 			if (true) $valid = $value;
82 82
 		}
83 83
 	}
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
 	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
43 43
 	 * @param array $content
44 44
 	 * @param array &$validated=array() validated content
45
-	 * @return boolean true if no validation error, false otherwise
45
+	 * @return boolean|null true if no validation error, false otherwise
46 46
 	 */
47 47
 	public function validate($cname, array $expand, array $content, &$validated=array())
48 48
 	{
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,7 +46,10 @@  discard block
 block discarded – undo
46 46
 		$font_span = '<span style="width: 100%; display: inline; '.
47 47
 			($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').
48 48
 			'">&#8203;</span>';
49
-		if (empty($font) && empty($font_size)) $font_span = '';
49
+		if (empty($font) && empty($font_size))
50
+		{
51
+			$font_span = '';
52
+		}
50 53
 		if($font_span)
51 54
 		{
52 55
 			$config['preference_style'] = $font_span;
@@ -78,7 +81,10 @@  discard block
 block discarded – undo
78 81
 				$value = Api\Html\HtmLawed::purify($value, $this->attrs['validation_rules']);
79 82
 			}
80 83
 			$valid =& self::get_array($validated, $form_name, true);
81
-			if (true) $valid = $value;
84
+			if (true)
85
+			{
86
+				$valid = $value;
87
+			}
82 88
 		}
83 89
 	}
84 90
 }
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/Nextmatch.php 2 patches
Spacing   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	const ICON_PATH = '/api/images';
92 92
 
93
-	public function __construct($xml='')
93
+	public function __construct($xml = '')
94 94
 	{
95
-		if($xml) {
95
+		if ($xml) {
96 96
 			parent::__construct($xml);
97 97
 		}
98 98
 	}
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
 	 * @param string $cname
116 116
 	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
117 117
 	 */
118
-	public function beforeSendToClient($cname, array $expand=null)
118
+	public function beforeSendToClient($cname, array $expand = null)
119 119
 	{
120 120
 		$form_name = self::form_name($cname, $this->id, $expand);
121 121
 		$value = self::get_array(self::$request->content, $form_name, true);
122 122
 
123 123
 		$value['start'] = 0;
124
-		if(!array_key_exists('num_rows',$value))
124
+		if (!array_key_exists('num_rows', $value))
125 125
 		{
126 126
 			$value['num_rows'] = self::INITIAL_ROWS;
127 127
 		}
@@ -130,40 +130,40 @@  discard block
 block discarded – undo
130 130
 
131 131
 		$send_value = $value;
132 132
 
133
-		list($app) = explode('.',$value['get_rows']);
134
-		if(!$GLOBALS['egw_info']['apps'][$app])
133
+		list($app) = explode('.', $value['get_rows']);
134
+		if (!$GLOBALS['egw_info']['apps'][$app])
135 135
 		{
136
-			list($app) = explode('.',$this->attrs['template']);
136
+			list($app) = explode('.', $this->attrs['template']);
137 137
 		}
138 138
 
139 139
 		// Check for a favorite in URL
140
-		if($_GET['favorite'] && $value['favorites'])
140
+		if ($_GET['favorite'] && $value['favorites'])
141 141
 		{
142
-			$safe_name = preg_replace('/[^A-Za-z0-9-_]/','_',strip_tags($_GET['favorite']));
143
-			$pref_name = "favorite_" .$safe_name;
142
+			$safe_name = preg_replace('/[^A-Za-z0-9-_]/', '_', strip_tags($_GET['favorite']));
143
+			$pref_name = "favorite_".$safe_name;
144 144
 
145 145
 			// Do some easy applying of filters server side
146 146
 			$favorite = $GLOBALS['egw_info']['user']['preferences'][$app][$pref_name];
147
-			if(!$favorite && $_GET['favorite'] == 'blank')
147
+			if (!$favorite && $_GET['favorite'] == 'blank')
148 148
 			{
149 149
 				// Have to go through each of these
150
-				foreach(array('search','cat_id','filter','filter2') as $filter)
150
+				foreach (array('search', 'cat_id', 'filter', 'filter2') as $filter)
151 151
 				{
152 152
 					$send_value[$filter] = '';
153 153
 				}
154 154
 				unset($send_value['col_filter']);
155 155
 			}
156 156
 			// Old type
157
-			if($favorite && $favorite['filter'])
157
+			if ($favorite && $favorite['filter'])
158 158
 			{
159 159
 				$favorite['state'] = $favorite['filter'];
160 160
 			}
161
-			if($favorite && $favorite['state'])
161
+			if ($favorite && $favorite['state'])
162 162
 			{
163 163
 				$send_value = array_merge($value, $favorite['state']);
164 164
 
165 165
 				// Ajax call can handle the saved sort here, but this can't
166
-				if($favorite['state']['sort'])
166
+				if ($favorite['state']['sort'])
167 167
 				{
168 168
 					unset($send_value['sort']);
169 169
 					$send_value['order'] = $favorite['state']['sort']['id'];
@@ -175,19 +175,19 @@  discard block
 block discarded – undo
175 175
 		unset($send_value['favorite']);
176 176
 
177 177
 		// Parse sort into something that get_rows functions are expecting: db_field in order, ASC/DESC in sort
178
-		if(is_array($send_value['sort']))
178
+		if (is_array($send_value['sort']))
179 179
 		{
180 180
 			$send_value['order'] = $send_value['sort']['id'];
181 181
 			$send_value['sort'] = $send_value['sort']['asc'] ? 'ASC' : 'DESC';
182 182
 		}
183
-		if($value['num_rows'] != 0)
183
+		if ($value['num_rows'] != 0)
184 184
 		{
185 185
 			$total = self::call_get_rows($send_value, $send_value['rows'], self::$request->readonlys, null, null, $this);
186 186
 		}
187
-		if (true) $value =& self::get_array(self::$request->content, $form_name, true);
187
+		if (true) $value = & self::get_array(self::$request->content, $form_name, true);
188 188
 
189 189
 		// Add favorite here so app doesn't save it in the session
190
-		if($_GET['favorite'])
190
+		if ($_GET['favorite'])
191 191
 		{
192 192
 			$send_value['favorite'] = $safe_name;
193 193
 		}
@@ -195,32 +195,32 @@  discard block
 block discarded – undo
195 195
 		$value['total'] = $total;
196 196
 
197 197
 		// Send categories
198
-		if(!$value['no_cat'] && !$value['cat_is_select'])
198
+		if (!$value['no_cat'] && !$value['cat_is_select'])
199 199
 		{
200 200
 			$cat_app = $value['cat_app'] ? $value['cat_app'] : $GLOBALS['egw_info']['flags']['current_app'];
201 201
 			$value['options-cat_id'] = self::$request->sel_options['cat_id'] ? self::$request->sel_options['cat_id'] : array();
202 202
 
203 203
 			// Add 'All', if not already there
204
-			if(!$value['options-cat_id'][''] && !$value['options-cat_id'][0])
204
+			if (!$value['options-cat_id'][''] && !$value['options-cat_id'][0])
205 205
 			{
206 206
 				$value['options-cat_id'][''] = lang('All categories');
207 207
 			}
208
-			$value['options-cat_id'] += Select::typeOptions('select-cat', ',,'.$cat_app,$no_lang=true,false,$value['cat_id']);
208
+			$value['options-cat_id'] += Select::typeOptions('select-cat', ',,'.$cat_app, $no_lang = true, false, $value['cat_id']);
209 209
 			Select::fix_encoded_options($value['options-cat_id']);
210 210
 		}
211 211
 
212 212
 		// Favorite group for admins
213
-		if($GLOBALS['egw_info']['apps']['admin'] && $value['favorites'])
213
+		if ($GLOBALS['egw_info']['apps']['admin'] && $value['favorites'])
214 214
 		{
215 215
 			self::$request->sel_options[$form_name]['favorite']['group'] = array('all' => lang('All users')) +
216
-				Select::typeOptions('select-account',',groups');
216
+				Select::typeOptions('select-account', ',groups');
217 217
 		}
218
-		foreach($value as $name => &$_value)
218
+		foreach ($value as $name => &$_value)
219 219
 		{
220
-			if(strpos($name, 'options-') !== false && $_value)
220
+			if (strpos($name, 'options-') !== false && $_value)
221 221
 			{
222 222
 				$select = substr($name, 8);
223
-				if(!self::$request->sel_options[$select])
223
+				if (!self::$request->sel_options[$select])
224 224
 				{
225 225
 					self::$request->sel_options[$select] = array();
226 226
 				}
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
 				//unset($value[$name]);
232 232
 			}
233 233
 		}
234
-		if($value['rows']['sel_options'])
234
+		if ($value['rows']['sel_options'])
235 235
 		{
236
-			self::$request->sel_options = array_merge(self::$request->sel_options,$value['rows']['sel_options']);
236
+			self::$request->sel_options = array_merge(self::$request->sel_options, $value['rows']['sel_options']);
237 237
 			unset($value['rows']['sel_options']);
238 238
 		}
239 239
 
240 240
 		// If column selection preference is forced, set a flag to turn off UI
241
-		$pref_name = 'nextmatch-' . (isset($value['columnselection_pref']) ? $value['columnselection_pref'] : $this->attrs['template']);
241
+		$pref_name = 'nextmatch-'.(isset($value['columnselection_pref']) ? $value['columnselection_pref'] : $this->attrs['template']);
242 242
 		$value['no_columnselection'] = $value['no_columnselection'] || (
243 243
 			$GLOBALS['egw']->preferences->forced[$app][$pref_name] &&
244 244
 			// Need to check admin too, or it will be impossible to turn off
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
 	 * @todo for $queriedRange[refresh] first check if there's any modification since $lastModified, return $result[order]===null
279 279
 	 * @return array with values for keys 'total', 'rows', 'readonlys', 'order', 'data' and 'lastModification'
280 280
 	 */
281
-	static public function ajax_get_rows($exec_id, array $queriedRange, array $filters = array(), $form_name='nm',
282
-		array $knownUids=null, $lastModified=null)
281
+	static public function ajax_get_rows($exec_id, array $queriedRange, array $filters = array(), $form_name = 'nm',
282
+		array $knownUids = null, $lastModified = null)
283 283
 	{
284 284
 		self::$request = Etemplate\Request::read($exec_id);
285 285
 		// fix for somehow empty etemplate request content
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 		self::$response = Api\Json\Response::get();
291 291
 
292 292
 		$value = self::get_array(self::$request->content, $form_name, true);
293
-		if(!is_array($value))
293
+		if (!is_array($value))
294 294
 		{
295 295
 			$value = ($value) ? array($value) : array();
296 296
 		}
@@ -305,15 +305,15 @@  discard block
 block discarded – undo
305 305
 			);
306 306
 			$valid_filters = array();
307 307
 
308
-			if($template)
308
+			if ($template)
309 309
 			{
310
-				$template->run('validate', array('', $expand, $expand['cont'], &$valid_filters), false);	// $respect_disabled=false: as client may disable things, here we validate everything and leave it to the get_rows to interpret
310
+				$template->run('validate', array('', $expand, $expand['cont'], &$valid_filters), false); // $respect_disabled=false: as client may disable things, here we validate everything and leave it to the get_rows to interpret
311 311
 				$filters = $valid_filters[$form_name];
312 312
 			}
313 313
 			// Avoid empty arrays, they cause problems with db filtering
314
-			foreach($filters['col_filter'] as $col => &$val)
314
+			foreach ($filters['col_filter'] as $col => &$val)
315 315
 			{
316
-				if(is_array($val) && count($val) == 0)
316
+				if (is_array($val) && count($val) == 0)
317 317
 				{
318 318
 					unset($filters['col_filter'][$col]);
319 319
 				}
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 		$result = array();
329 329
 
330 330
 		// Parse sort into something that get_rows functions are expecting: db_field in order, ASC/DESC in sort
331
-		if(is_array($value['sort']))
331
+		if (is_array($value['sort']))
332 332
 		{
333 333
 			$value['order'] = $value['sort']['id'];
334 334
 			$value['sort'] = $value['sort']['asc'] ? 'ASC' : 'DESC';
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 
337 337
 		$value['start'] = (int)$queriedRange['start'];
338 338
 		$value['num_rows'] = (int)$queriedRange['num_rows'];
339
-		if($value['num_rows'] == 0) $value['num_rows'] = self::INITIAL_ROWS;
339
+		if ($value['num_rows'] == 0) $value['num_rows'] = self::INITIAL_ROWS;
340 340
 		// if app supports parent_id / hierarchy ($value['parent_id'] not empty), set parent_id as filter
341 341
 		if (($parent_id = $value['parent_id']))
342 342
 		{
@@ -346,9 +346,9 @@  discard block
 block discarded – undo
346 346
 		}
347 347
 
348 348
 		// Set current app for get_rows
349
-		list($app) = explode('.',self::$request->method);
350
-		if(!$app) list($app) = explode('::',self::$request->method);
351
-		if($app)
349
+		list($app) = explode('.', self::$request->method);
350
+		if (!$app) list($app) = explode('::', self::$request->method);
351
+		if ($app)
352 352
 		{
353 353
 			$GLOBALS['egw_info']['flags']['currentapp'] = $app;
354 354
 			Api\Translation::add_app($app);
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 		}
362 362
 		$rows = $result['data'] = $result['order'] = array();
363 363
 		$result['total'] = self::call_get_rows($value, $rows, $result['readonlys'], null, null, $template);
364
-		$result['lastModification'] = Api\DateTime::to('now', 'ts')-1;
364
+		$result['lastModification'] = Api\DateTime::to('now', 'ts') - 1;
365 365
 
366 366
 		if (isset($GLOBALS['egw_info']['flags']['app_header']) && self::$request->app_header != $GLOBALS['egw_info']['flags']['app_header'])
367 367
 		{
@@ -372,12 +372,12 @@  discard block
 block discarded – undo
372 372
 		$row_id = isset($value['row_id']) ? $value['row_id'] : 'id';
373 373
 		$row_modified = $value['row_modified'];
374 374
 
375
-		foreach($rows as $n => $row)
375
+		foreach ($rows as $n => $row)
376 376
 		{
377 377
 			$kUkey = false;
378 378
 			if (is_int($n) && $row)
379 379
 			{
380
-				if (!isset($row[$row_id])) unset($row_id);	// unset default row_id of 'id', if not used
380
+				if (!isset($row[$row_id])) unset($row_id); // unset default row_id of 'id', if not used
381 381
 				if (!isset($row[$row_modified])) unset($row_modified);
382 382
 
383 383
 				$id = $row_id ? $row[$row_id] : $n;
@@ -405,11 +405,11 @@  discard block
 block discarded – undo
405 405
 			{
406 406
 				// Encode all select options and re-index to avoid Firefox's problem with
407 407
 				// '' => 'All'
408
-				if($n == 'sel_options')
408
+				if ($n == 'sel_options')
409 409
 				{
410
-					foreach($row as &$options)
410
+					foreach ($row as &$options)
411 411
 					{
412
-						Select::fix_encoded_options($options,true);
412
+						Select::fix_encoded_options($options, true);
413 413
 					}
414 414
 				}
415 415
 				$result['rows'][$n] = $row;
@@ -481,23 +481,23 @@  discard block
 block discarded – undo
481 481
 
482 482
 		// Check for anything changed in the query
483 483
 		// Tell the client about the changes
484
-		$request_value =& self::get_array(self::$request->content, $form_name,true);
484
+		$request_value = & self::get_array(self::$request->content, $form_name, true);
485 485
 		$changes = $no_rows = false;
486 486
 
487
-		foreach($value_in as $key => $original_value)
487
+		foreach ($value_in as $key => $original_value)
488 488
 		{
489 489
 			// These keys are ignored
490
-			if(in_array($key, array('col_filter','start','num_rows','total','order','sort')))
490
+			if (in_array($key, array('col_filter', 'start', 'num_rows', 'total', 'order', 'sort')))
491 491
 			{
492 492
 				continue;
493 493
 			}
494
-			if($original_value == $value[$key]) continue;
494
+			if ($original_value == $value[$key]) continue;
495 495
 
496 496
 			// These keys we don't send row data back, as they cause a partial reload
497
-			if(in_array($key, array('template'))) $no_rows = true;
497
+			if (in_array($key, array('template'))) $no_rows = true;
498 498
 
499 499
 			// Actions still need extra handling
500
-			if($key == 'actions' && !isset($value['actions'][0]))
500
+			if ($key == 'actions' && !isset($value['actions'][0]))
501 501
 			{
502 502
 				$value['action_links'] = array();
503 503
 				$template_name = isset($value['template']) ? $value['template'] : '';
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 			));
517 517
 		}
518 518
 		// Request doesn't handle changing by reference, so force it
519
-		if($changes)
519
+		if ($changes)
520 520
 		{
521 521
 			$content = self::$request->content;
522 522
 			self::$request->content = array();
@@ -556,27 +556,27 @@  discard block
 block discarded – undo
556 556
 	 * @param Etemplate\Widget $widget =null instanciated nextmatch widget to let it's widgets transform each row
557 557
 	 * @return int|boolean total items found of false on error ($value['get_rows'] not callable)
558 558
 	 */
559
-	private static function call_get_rows(array &$value,array &$rows,array &$readonlys=null,$obj=null,$method=null, Etemplate\Widget $widget=null)
559
+	private static function call_get_rows(array &$value, array &$rows, array &$readonlys = null, $obj = null, $method = null, Etemplate\Widget $widget = null)
560 560
 	{
561 561
 		if (is_null($method)) $method = $value['get_rows'];
562 562
 
563 563
 		if (is_null($obj))
564 564
 		{
565 565
 			// allow static callbacks
566
-			if(strpos($method,'::') !== false)
566
+			if (strpos($method, '::') !== false)
567 567
 			{
568
-				list($class,$method) = explode('::',$method);
568
+				list($class, $method) = explode('::', $method);
569 569
 
570 570
 				//  workaround for php < 5.2.3: do NOT call it static, but allow application code to specify static callbacks
571
-				if (version_compare(PHP_VERSION,'5.2.3','>='))
571
+				if (version_compare(PHP_VERSION, '5.2.3', '>='))
572 572
 				{
573
-					$method = array($class,$method);
573
+					$method = array($class, $method);
574 574
 					unset($class);
575 575
 				}
576 576
 			}
577 577
 			else
578 578
 			{
579
-				list($app,$class,$method) = explode('.',$value['get_rows']);
579
+				list($app, $class, $method) = explode('.', $value['get_rows']);
580 580
 			}
581 581
 			if ($class)
582 582
 			{
@@ -596,23 +596,23 @@  discard block
 block discarded – undo
596 596
 		}
597 597
 		$raw_rows = array();
598 598
 		if (!is_array($readonlys)) $readonlys = array();
599
-		if(is_callable($method))	// php5.2.3+ static call (value is always a var param!)
599
+		if (is_callable($method))	// php5.2.3+ static call (value is always a var param!)
600 600
 		{
601
-			$total = call_user_func_array($method,array(&$value,&$raw_rows,&$readonlys));
601
+			$total = call_user_func_array($method, array(&$value, &$raw_rows, &$readonlys));
602 602
 		}
603
-		elseif(is_object($obj) && method_exists($obj,$method))
603
+		elseif (is_object($obj) && method_exists($obj, $method))
604 604
 		{
605
-			$total = $obj->$method($value,$raw_rows,$readonlys);
605
+			$total = $obj->$method($value, $raw_rows, $readonlys);
606 606
 		}
607 607
 		else
608 608
 		{
609
-			$total = false;	// method not callable
609
+			$total = false; // method not callable
610 610
 		}
611 611
 		// if we have a nextmatch widget, find the repeating row
612 612
 		if ($widget && $widget->attrs['template'])
613 613
 		{
614 614
 			$row_template = $widget->getElementById($widget->attrs['template']);
615
-			if(!$row_template)
615
+			if (!$row_template)
616 616
 			{
617 617
 				$row_template = Template::instance($widget->attrs['template']);
618 618
 			}
@@ -620,9 +620,9 @@  discard block
 block discarded – undo
620 620
 			// Try to find just the repeating part
621 621
 			$repeating_row = null;
622 622
 			// First child should be a grid, we want last row
623
-			foreach($row_template->children[0]->children[1]->children as $child)
623
+			foreach ($row_template->children[0]->children[1]->children as $child)
624 624
 			{
625
-				if($child->type == 'row') $repeating_row = $child;
625
+				if ($child->type == 'row') $repeating_row = $child;
626 626
 			}
627 627
 		}
628 628
 		// otherwise we might get stoped by max_excutiontime
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 
635 635
 		// remove empty rows required by old etemplate to compensate for header rows
636 636
 		$first = $total ? null : 0;
637
-		foreach($raw_rows as $n => $row)
637
+		foreach ($raw_rows as $n => $row)
638 638
 		{
639 639
 			// skip empty rows inserted for each header-line in old etemplate
640 640
 			if (is_int($n) && is_array($rows))
@@ -645,14 +645,14 @@  discard block
 block discarded – undo
645 645
 				{
646 646
 					$row['is_parent'] = isset($is_parent_value) ?
647 647
 						$row[$is_parent] == $is_parent_value : (boolean)$row[$is_parent];
648
-					$row['parent_id'] = $row[$parent_id];	// seems NOT used on client!
648
+					$row['parent_id'] = $row[$parent_id]; // seems NOT used on client!
649 649
 				}
650 650
 				// run beforeSendToClient methods of widgets in row on row-data
651
-				if($repeating_row)
651
+				if ($repeating_row)
652 652
 				{
653 653
 					// Change anything by widget for each row ($row set to 1)
654 654
 					$_row = array(1 => &$row);
655
-					$repeating_row->run('set_row_value', array('',array('row' => 1), &$_row), true);
655
+					$repeating_row->run('set_row_value', array('', array('row' => 1), &$_row), true);
656 656
 				}
657 657
 				else if (!$widget || get_class($widget) != __NAMESPACE__.'\\HistoryLog')
658 658
 				{
@@ -660,13 +660,13 @@  discard block
 block discarded – undo
660 660
 					//error_log(self::$request->template['name'] . ' had to fallback to run_beforeSendToClient() because it could not find the row');
661 661
 					$row = self::run_beforeSendToClient($row);
662 662
 				}
663
-				$rows[$n-$first+$value['start']] = $row;
663
+				$rows[$n - $first + $value['start']] = $row;
664 664
 			}
665
-			elseif(!is_numeric($n))	// rows with string-keys, after numeric rows
665
+			elseif (!is_numeric($n))	// rows with string-keys, after numeric rows
666 666
 			{
667
-				if($n == 'sel_options')
667
+				if ($n == 'sel_options')
668 668
 				{
669
-					foreach($row as $name => &$options)
669
+					foreach ($row as $name => &$options)
670 670
 					{
671 671
 						// remember newly set options for validation of nextmatch filters
672 672
 						self::$request->sel_options[$name] = $options;
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 	{
696 696
 		$timestamps = self::get_timestamps();
697 697
 
698
-		foreach($row as $name => &$value)
698
+		foreach ($row as $name => &$value)
699 699
 		{
700 700
 			if ($name[0] != '#' && in_array($name, $timestamps) && $value &&
701 701
 				(is_int($value) || is_string($value) && is_numeric($value)) &&
@@ -717,15 +717,15 @@  discard block
 block discarded – undo
717 717
 		return Api\Cache::getTree(__CLASS__, 'timestamps', function()
718 718
 		{
719 719
 			$timestamps = array();
720
-			foreach(scandir(EGW_SERVER_ROOT) as $app)
720
+			foreach (scandir(EGW_SERVER_ROOT) as $app)
721 721
 			{
722 722
 				$dir = EGW_SERVER_ROOT.'/'.$app;
723 723
 				if (is_dir($dir) && file_exists($dir.'/setup/tables_current.inc.php') &&
724 724
 					($tables_defs = $GLOBALS['egw']->db->get_table_definitions($app)))
725 725
 				{
726
-					foreach($tables_defs as $defintion)
726
+					foreach ($tables_defs as $defintion)
727 727
 					{
728
-						foreach($defintion['fd'] as $col => $data)
728
+						foreach ($defintion['fd'] as $col => $data)
729 729
 						{
730 730
 							if ($data['type'] == 'timestamp' || $data['meta'] == 'timestamp')
731 731
 							{
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
 			}
744 744
 			//error_log(__METHOD__."() returning ".array2string($timestamps));
745 745
 			return $timestamps;
746
-		}, array(), 86400);	// cache for 1 day
746
+		}, array(), 86400); // cache for 1 day
747 747
 	}
748 748
 
749 749
 	/**
@@ -795,18 +795,18 @@  discard block
 block discarded – undo
795 795
 	 * @param array $default_attrs =null default attributes
796 796
 	 * @return array
797 797
 	 */
798
-	public static function egw_actions(array $actions=null, $template_name='', $prefix='', array &$action_links=array(),
799
-		$max_length=self::DEFAULT_MAX_MENU_LENGTH, array $default_attrs=null)
798
+	public static function egw_actions(array $actions = null, $template_name = '', $prefix = '', array &$action_links = array(),
799
+		$max_length = self::DEFAULT_MAX_MENU_LENGTH, array $default_attrs = null)
800 800
 	{
801 801
 		//echo "<p>".__METHOD__."(\$actions, '$template_name', '$prefix', \$action_links, $max_length) \$actions="; _debug_array($actions);
802
-		$first_level = !$action_links;	// add all first level actions
802
+		$first_level = !$action_links; // add all first level actions
803 803
 
804 804
 		//echo "actions="; _debug_array($actions);
805 805
 		$egw_actions = array();
806 806
 		$n = 1;
807 807
 		$group = false;
808 808
 
809
-		foreach((array)$actions as $id => $action)
809
+		foreach ((array)$actions as $id => $action)
810 810
 		{
811 811
 			// in case it's only selectbox  id => label pairs
812 812
 			if (!is_array($action)) $action = array('caption' => $action);
@@ -834,12 +834,12 @@  discard block
 block discarded – undo
834 834
 
835 835
 			if (!$first_level && $n == $max_length && count($actions) > $max_length)
836 836
 			{
837
-				$id = 'more_'.count($actions);	// we need a new unique id
837
+				$id = 'more_'.count($actions); // we need a new unique id
838 838
 				$action = array(
839 839
 					'caption' => 'More',
840 840
 					'prefix' => $prefix,
841 841
 					// display rest of actions incl. current one as children
842
-					'children' => array_slice($actions, $max_length-1, count($actions)-$max_length+1, true),
842
+					'children' => array_slice($actions, $max_length - 1, count($actions) - $max_length + 1, true),
843 843
 				);
844 844
 				//echo "*** Inserting id=$prefix$id"; _debug_array($action);
845 845
 				// we break at end of foreach loop, as rest of actions is already dealt with
@@ -847,8 +847,8 @@  discard block
 block discarded – undo
847 847
 			}
848 848
 
849 849
 			// add all first level popup actions plus ones with enabled = 'javaScript:...' to action_links
850
-			if ((!isset($action['type']) || in_array($action['type'],array('popup','drag','drop'))) &&	// popup is the default
851
-				($first_level || substr($action['enabled'],0,11) == 'javaScript:'))
850
+			if ((!isset($action['type']) || in_array($action['type'], array('popup', 'drag', 'drop'))) && // popup is the default
851
+				($first_level || substr($action['enabled'], 0, 11) == 'javaScript:'))
852 852
 			{
853 853
 				$action_links[] = $prefix.$id;
854 854
 			}
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 			// add sub-menues
857 857
 			if ($action['children'])
858 858
 			{
859
-				static $inherit_attrs = array('url','popup','nm_action','onExecute','type','egw_open','allowOnMultiple','confirm','confirm_multiple');
859
+				static $inherit_attrs = array('url', 'popup', 'nm_action', 'onExecute', 'type', 'egw_open', 'allowOnMultiple', 'confirm', 'confirm_multiple');
860 860
 				$inherit_keys = array_flip($inherit_attrs);
861 861
 				$action['children'] = self::egw_actions($action['children'], $template_name, $action['prefix'], $action_links, $max_length,
862 862
 					array_intersect_key($action, $inherit_keys));
@@ -864,28 +864,28 @@  discard block
 block discarded – undo
864 864
 				unset($action['prefix']);
865 865
 
866 866
 				// Allow default actions to keep their onExecute
867
-				if($action['default']) unset($inherit_keys['onExecute']);
867
+				if ($action['default']) unset($inherit_keys['onExecute']);
868 868
 				$action = array_diff_key($action, $inherit_keys);
869 869
 			}
870 870
 
871 871
 			// link or popup action
872 872
 			if ($action['url'])
873 873
 			{
874
-				$action['url'] = Api\Framework::link('/index.php',str_replace('$action',$id,$action['url']));
874
+				$action['url'] = Api\Framework::link('/index.php', str_replace('$action', $id, $action['url']));
875 875
 				if ($action['popup'])
876 876
 				{
877
-					list($action['data']['width'],$action['data']['height']) = explode('x',$action['popup']);
877
+					list($action['data']['width'], $action['data']['height']) = explode('x', $action['popup']);
878 878
 					unset($action['popup']);
879 879
 					$action['data']['nm_action'] = 'popup';
880 880
 				}
881 881
 				else
882 882
 				{
883 883
 					$action['data']['nm_action'] = 'location';
884
-					if(!$action['target'] && strpos($action['url'],'menuaction') > 0)
884
+					if (!$action['target'] && strpos($action['url'], 'menuaction') > 0)
885 885
 					{
886 886
 						// It would be better if app set target, but we'll auto-detect if not
887
-						list(,$menuaction) = explode('=',$action['url']);
888
-						list($app) = explode('.',$menuaction);
887
+						list(,$menuaction) = explode('=', $action['url']);
888
+						list($app) = explode('.', $menuaction);
889 889
 						$action['data']['target'] = $app;
890 890
 					}
891 891
 				}
@@ -901,12 +901,12 @@  discard block
 block discarded – undo
901 901
 		}
902 902
 
903 903
 		// Make sure select all is in a group by itself
904
-		foreach($egw_actions as $id => &$_action)
904
+		foreach ($egw_actions as $id => &$_action)
905 905
 		{
906
-			if($id == $prefix . 'select_all') continue;
907
-			if($_action['group'] >= $egw_actions[$prefix.'select_all']['group'] )
906
+			if ($id == $prefix.'select_all') continue;
907
+			if ($_action['group'] >= $egw_actions[$prefix.'select_all']['group'])
908 908
 			{
909
-				$egw_actions[$id]['group']+=1;
909
+				$egw_actions[$id]['group'] += 1;
910 910
 			}
911 911
 		}
912 912
 		//echo "egw_actions="; _debug_array($egw_actions);
@@ -927,11 +927,11 @@  discard block
 block discarded – undo
927 927
 	 * @param int $max_cats_flat =self::DEFAULT_MAX_MENU_LENGTH use hierarchical display if more cats
928 928
 	 * @return array like self::egw_actions
929 929
 	 */
930
-	public static function category_action($app, $group=0, $caption='Change category',
931
-		$prefix='cat_', $globals=true, $parent_id=0, $max_cats_flat=self::DEFAULT_MAX_MENU_LENGTH)
930
+	public static function category_action($app, $group = 0, $caption = 'Change category',
931
+		$prefix = 'cat_', $globals = true, $parent_id = 0, $max_cats_flat = self::DEFAULT_MAX_MENU_LENGTH)
932 932
 	{
933
-		$cat = new Api\Categories(null,$app);
934
-		$cats = $cat->return_sorted_array($start=0, false, '', 'ASC', 'cat_name', $globals, $parent_id, true);
933
+		$cat = new Api\Categories(null, $app);
934
+		$cats = $cat->return_sorted_array($start = 0, false, '', 'ASC', 'cat_name', $globals, $parent_id, true);
935 935
 
936 936
 		// if more then max_length cats, switch automatically to hierarchical display
937 937
 		if (count($cats) > $max_cats_flat)
@@ -941,9 +941,9 @@  discard block
 block discarded – undo
941 941
 		else	// flat, indented categories
942 942
 		{
943 943
 			$cat_actions = array();
944
-			foreach((array)$cats as $cat)
944
+			foreach ((array)$cats as $cat)
945 945
 			{
946
-				$name = str_repeat('&nbsp;',2*$cat['level']) . stripslashes($cat['name']);
946
+				$name = str_repeat('&nbsp;', 2 * $cat['level']).stripslashes($cat['name']);
947 947
 
948 948
 				$cat_actions[$cat['id']] = array(
949 949
 					'caption' => $name,
@@ -973,10 +973,10 @@  discard block
 block discarded – undo
973 973
 	 * @param int $parent_id =0 only returns cats of a certain parent
974 974
 	 * @return array
975 975
 	 */
976
-	private static function category_hierarchy(array $cats, $prefix, $parent_id=0)
976
+	private static function category_hierarchy(array $cats, $prefix, $parent_id = 0)
977 977
 	{
978 978
 		$cat_actions = array();
979
-		foreach($cats as $key => $cat)
979
+		foreach ($cats as $key => $cat)
980 980
 		{
981 981
 			// current hierarchy level
982 982
 			if ($cat['parent'] == $parent_id)
@@ -996,14 +996,14 @@  discard block
 block discarded – undo
996 996
 				unset($cats[$key]);
997 997
 			}
998 998
 			// direct children
999
-			elseif(isset($cat_actions[$cat['parent']]))
999
+			elseif (isset($cat_actions[$cat['parent']]))
1000 1000
 			{
1001 1001
 				$cat_actions['sub_'.$cat['parent']] = $cat_actions[$cat['parent']];
1002 1002
 				// have to add category itself to children, to be able to select it!
1003
-				$cat_actions[$cat['parent']]['group'] = -1;	// own group on top
1003
+				$cat_actions[$cat['parent']]['group'] = -1; // own group on top
1004 1004
 				$cat_actions['sub_'.$cat['parent']]['children'] = array(
1005 1005
 					$cat['parent'] => $cat_actions[$cat['parent']],
1006
-				)+self::category_hierarchy($cats, $prefix, $cat['parent']);
1006
+				) + self::category_hierarchy($cats, $prefix, $cat['parent']);
1007 1007
 				unset($cat_actions[$cat['parent']]);
1008 1008
 			}
1009 1009
 		}
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 	 * @param array $content
1027 1027
 	 * @param array &$validated =array() validated content
1028 1028
 	 */
1029
-	public function validate($cname, array $expand, array $content, &$validated=array())
1029
+	public function validate($cname, array $expand, array $content, &$validated = array())
1030 1030
 	{
1031 1031
 		$form_name = self::form_name($cname, $this->id, $expand);
1032 1032
 		$value = self::get_array($content, $form_name);
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 		// $content.  Fetch them from the request, so we actually have them.
1036 1036
 		$content_value = self::get_array(self::$request->content, $form_name);
1037 1037
 
1038
-		list($app) = explode('.',$this->attrs['template']);
1038
+		list($app) = explode('.', $this->attrs['template']);
1039 1039
 
1040 1040
 		unset($value['favorite']);
1041 1041
 
@@ -1044,18 +1044,18 @@  discard block
 block discarded – undo
1044 1044
 
1045 1045
 		// Legacy support - action popups were not properly namespaced
1046 1046
 		$preserve = self::get_array(self::$request->preserv, $form_name);
1047
-		if($value[$preserve['action_var']] && $content[$value[$preserve['action_var']].'_popup'])
1047
+		if ($value[$preserve['action_var']] && $content[$value[$preserve['action_var']].'_popup'])
1048 1048
 		{
1049 1049
 			$validated += $content[$value[$preserve['action_var']].'_popup'];
1050 1050
 		}
1051 1051
 
1052 1052
 
1053 1053
 		// Save current column settings as default, clear, or force (admins only)
1054
-		if($GLOBALS['egw_info']['user']['apps']['admin'] && $app && $value['selectcols'])
1054
+		if ($GLOBALS['egw_info']['user']['apps']['admin'] && $app && $value['selectcols'])
1055 1055
 		{
1056
-			$pref_name = 'nextmatch-' . (isset($content_value['columnselection_pref']) ? $content_value['columnselection_pref'] : $this->attrs['template']);
1056
+			$pref_name = 'nextmatch-'.(isset($content_value['columnselection_pref']) ? $content_value['columnselection_pref'] : $this->attrs['template']);
1057 1057
 			$refresh_pref_name = $pref_name.'-autorefresh';
1058
-			switch($value['nm_col_preference']) {
1058
+			switch ($value['nm_col_preference']) {
1059 1059
 				case 'force':
1060 1060
 					$pref_level = 'forced';
1061 1061
 					break;
@@ -1068,39 +1068,39 @@  discard block
 block discarded – undo
1068 1068
 			}
1069 1069
 
1070 1070
 			// Clear forced pref before setting default
1071
-			if($pref_level != 'forced')
1071
+			if ($pref_level != 'forced')
1072 1072
 			{
1073
-				$GLOBALS['egw']->preferences->delete($app,$pref_name,'forced');
1074
-				$GLOBALS['egw']->preferences->delete($app,$refresh_pref_name,'forced');
1075
-				$GLOBALS['egw']->preferences->delete($app,$pref_name.'-size','forced');
1076
-				$GLOBALS['egw']->preferences->delete($app,$pref_name.'-lettersearch','forced');
1077
-				$GLOBALS['egw']->preferences->save_repository(true,'forced');
1073
+				$GLOBALS['egw']->preferences->delete($app, $pref_name, 'forced');
1074
+				$GLOBALS['egw']->preferences->delete($app, $refresh_pref_name, 'forced');
1075
+				$GLOBALS['egw']->preferences->delete($app, $pref_name.'-size', 'forced');
1076
+				$GLOBALS['egw']->preferences->delete($app, $pref_name.'-lettersearch', 'forced');
1077
+				$GLOBALS['egw']->preferences->save_repository(true, 'forced');
1078 1078
 			}
1079 1079
 
1080 1080
 			// Set columns + refresh as default for all users
1081 1081
 			// Columns included in submit, preference might not be updated yet
1082 1082
 			$cols = $value['selectcols'];
1083 1083
 			$GLOBALS['egw']->preferences->read_repository(true);
1084
-			$GLOBALS['egw']->preferences->add($app,$pref_name,is_array($cols) ? implode(',',$cols) : $cols, $pref_level);
1084
+			$GLOBALS['egw']->preferences->add($app, $pref_name, is_array($cols) ? implode(',', $cols) : $cols, $pref_level);
1085 1085
 
1086 1086
 			// Autorefresh
1087 1087
 			$refresh = $value['nm_autorefresh'];
1088
-			$GLOBALS['egw']->preferences->add($app,$refresh_pref_name,(int)$refresh,$pref_level);
1088
+			$GLOBALS['egw']->preferences->add($app, $refresh_pref_name, (int)$refresh, $pref_level);
1089 1089
 
1090 1090
 			// Lettersearch
1091 1091
 			$lettersearch = is_array($cols) && in_array('lettersearch', $cols);
1092
-			$GLOBALS['egw']->preferences->add($app,$pref_name.'-lettersearch',(int)$lettersearch,$pref_level);
1092
+			$GLOBALS['egw']->preferences->add($app, $pref_name.'-lettersearch', (int)$lettersearch, $pref_level);
1093 1093
 
1094
-			$GLOBALS['egw']->preferences->save_repository(true,$pref_level);
1094
+			$GLOBALS['egw']->preferences->save_repository(true, $pref_level);
1095 1095
 			$GLOBALS['egw']->preferences->read(true);
1096 1096
 
1097
-			if($value['nm_col_preference'] == 'reset')
1097
+			if ($value['nm_col_preference'] == 'reset')
1098 1098
 			{
1099 1099
 				// Clear column + refresh preference so users go back to default
1100
-				$GLOBALS['egw']->preferences->delete_preference($app,$pref_name);
1101
-				$GLOBALS['egw']->preferences->delete_preference($app,$pref_name.'-size');
1102
-				$GLOBALS['egw']->preferences->delete_preference($app,$pref_name.'-lettersearch');
1103
-				$GLOBALS['egw']->preferences->delete_preference($app,$refresh_pref_name);
1100
+				$GLOBALS['egw']->preferences->delete_preference($app, $pref_name);
1101
+				$GLOBALS['egw']->preferences->delete_preference($app, $pref_name.'-size');
1102
+				$GLOBALS['egw']->preferences->delete_preference($app, $pref_name.'-lettersearch');
1103
+				$GLOBALS['egw']->preferences->delete_preference($app, $refresh_pref_name);
1104 1104
 			}
1105 1105
 		}
1106 1106
 		unset($value['nm_col_preference']);
@@ -1117,20 +1117,20 @@  discard block
 block discarded – undo
1117 1117
 	 * @param array $params =array('') parameter(s) first parameter has to be cname, second $expand!
1118 1118
 	 * @param boolean $respect_disabled =false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children
1119 1119
 	 */
1120
-	public function run($method_name, $params=array(''), $respect_disabled=false)
1120
+	public function run($method_name, $params = array(''), $respect_disabled = false)
1121 1121
 	{
1122 1122
 		$old_param0 = $params[0];
1123
-		$cname =& $params[0];
1123
+		$cname = & $params[0];
1124 1124
 		// Need this check or the headers will get involved too
1125
-		if($this->type == 'nextmatch')
1125
+		if ($this->type == 'nextmatch')
1126 1126
 		{
1127 1127
 			parent::run($method_name, $params, $respect_disabled);
1128 1128
 			if ($this->id) $cname = self::form_name($cname, $this->id, $params[1]);
1129 1129
 
1130 1130
 			// Run on all the sub-templates
1131
-			foreach(array('template', 'header_left', 'header_right', 'header_row') as $sub_template)
1131
+			foreach (array('template', 'header_left', 'header_right', 'header_row') as $sub_template)
1132 1132
 			{
1133
-				if($this->attrs[$sub_template])
1133
+				if ($this->attrs[$sub_template])
1134 1134
 				{
1135 1135
 					$row_template = Template::instance($this->attrs[$sub_template]);
1136 1136
 					$row_template->run($method_name, $params, $respect_disabled);
@@ -1141,10 +1141,10 @@  discard block
 block discarded – undo
1141 1141
 
1142 1142
 		// Prevent troublesome keys from breaking the nextmatch
1143 1143
 		// TODO: Figure out where these come from
1144
-		foreach(array('$row','${row}', '$', '0','1','2') as $key)
1144
+		foreach (array('$row', '${row}', '$', '0', '1', '2') as $key)
1145 1145
 		{
1146
-			if(is_array(self::$request->content[$cname])) unset(self::$request->content[$cname][$key]);
1147
-			if(is_array(self::$request->preserve[$cname])) unset(self::$request->preserve[$cname][$key]);
1146
+			if (is_array(self::$request->content[$cname])) unset(self::$request->content[$cname][$key]);
1147
+			if (is_array(self::$request->preserve[$cname])) unset(self::$request->preserve[$cname][$key]);
1148 1148
 		}
1149 1149
 	}
1150 1150
 
@@ -1159,9 +1159,9 @@  discard block
 block discarded – undo
1159 1159
 	 * @param array|string $row_ids rows to refresh
1160 1160
 	 * @param string $type ='edit' "edit" (default), "delete" or "add"
1161 1161
 	 */
1162
-	public function refresh($row_ids, $type='edit')
1162
+	public function refresh($row_ids, $type = 'edit')
1163 1163
 	{
1164
-		unset($row_ids, $type);	// not used, but required by function signature
1164
+		unset($row_ids, $type); // not used, but required by function signature
1165 1165
 
1166 1166
 		throw new Api\Exception('Not yet implemented');
1167 1167
 	}
Please login to merge, or discard this patch.
Braces   +126 added lines, -34 removed lines patch added patch discarded remove patch
@@ -92,7 +92,8 @@  discard block
 block discarded – undo
92 92
 
93 93
 	public function __construct($xml='')
94 94
 	{
95
-		if($xml) {
95
+		if($xml)
96
+		{
96 97
 			parent::__construct($xml);
97 98
 		}
98 99
 	}
@@ -184,14 +185,20 @@  discard block
 block discarded – undo
184 185
 		{
185 186
 			$total = self::call_get_rows($send_value, $send_value['rows'], self::$request->readonlys, null, null, $this);
186 187
 		}
187
-		if (true) $value =& self::get_array(self::$request->content, $form_name, true);
188
+		if (true)
189
+		{
190
+			$value =& self::get_array(self::$request->content, $form_name, true);
191
+		}
188 192
 
189 193
 		// Add favorite here so app doesn't save it in the session
190 194
 		if($_GET['favorite'])
191 195
 		{
192 196
 			$send_value['favorite'] = $safe_name;
193 197
 		}
194
-		if (true) $value = $send_value;
198
+		if (true)
199
+		{
200
+			$value = $send_value;
201
+		}
195 202
 		$value['total'] = $total;
196 203
 
197 204
 		// Send categories
@@ -257,7 +264,10 @@  discard block
 block discarded – undo
257 264
 		{
258 265
 			$value['action_links'] = array();
259 266
 			$template_name = isset($value['template']) ? $value['template'] : $this->attrs['options'];
260
-			if (!is_array($value['action_links'])) $value['action_links'] = array();
267
+			if (!is_array($value['action_links']))
268
+			{
269
+				$value['action_links'] = array();
270
+			}
261 271
 			$value['actions'] = self::egw_actions($value['actions'], $template_name, '', $value['action_links']);
262 272
 		}
263 273
 	}
@@ -321,7 +331,10 @@  discard block
 block discarded – undo
321 331
 			//error_log($this . " Valid filters: " . array2string($filters));
322 332
 		}
323 333
 
324
-		if (true) $value = $value_in = array_merge($value, $filters);
334
+		if (true)
335
+		{
336
+			$value = $value_in = array_merge($value, $filters);
337
+		}
325 338
 
326 339
 		//error_log(__METHOD__."('".substr($exec_id,0,10)."...', range=".array2string($queriedRange).', filters='.array2string($filters).", '$form_name', knownUids=".array2string($knownUids).", lastModified=$lastModified) parent_id=$value[parent_id], is_parent=$value[is_parent]");
327 340
 
@@ -336,18 +349,27 @@  discard block
 block discarded – undo
336 349
 
337 350
 		$value['start'] = (int)$queriedRange['start'];
338 351
 		$value['num_rows'] = (int)$queriedRange['num_rows'];
339
-		if($value['num_rows'] == 0) $value['num_rows'] = self::INITIAL_ROWS;
352
+		if($value['num_rows'] == 0)
353
+		{
354
+			$value['num_rows'] = self::INITIAL_ROWS;
355
+		}
340 356
 		// if app supports parent_id / hierarchy ($value['parent_id'] not empty), set parent_id as filter
341 357
 		if (($parent_id = $value['parent_id']))
342 358
 		{
343 359
 			// Infolog at least wants 'parent_id' instead of $parent_id
344 360
 			$value['col_filter'][$parent_id] = $queriedRange['parent_id'];
345
-			if ($queriedRange['parent_id']) $value['csv_export'] = 'children';
361
+			if ($queriedRange['parent_id'])
362
+			{
363
+				$value['csv_export'] = 'children';
364
+			}
346 365
 		}
347 366
 
348 367
 		// Set current app for get_rows
349 368
 		list($app) = explode('.',self::$request->method);
350
-		if(!$app) list($app) = explode('::',self::$request->method);
369
+		if(!$app)
370
+		{
371
+			list($app) = explode('::',self::$request->method);
372
+		}
351 373
 		if($app)
352 374
 		{
353 375
 			$GLOBALS['egw_info']['flags']['currentapp'] = $app;
@@ -377,8 +399,15 @@  discard block
 block discarded – undo
377 399
 			$kUkey = false;
378 400
 			if (is_int($n) && $row)
379 401
 			{
380
-				if (!isset($row[$row_id])) unset($row_id);	// unset default row_id of 'id', if not used
381
-				if (!isset($row[$row_modified])) unset($row_modified);
402
+				if (!isset($row[$row_id]))
403
+				{
404
+					unset($row_id);
405
+				}
406
+				// unset default row_id of 'id', if not used
407
+				if (!isset($row[$row_modified]))
408
+				{
409
+					unset($row_modified);
410
+				}
382 411
 
383 412
 				$id = $row_id ? $row[$row_id] : $n;
384 413
 				$result['order'][] = $id;
@@ -394,12 +423,14 @@  discard block
 block discarded – undo
394 423
 				if (!$row_id || !$knownUids || ($kUkey = array_search($id, $knownUids)) === false ||
395 424
 					!$lastModified || !isset($modified) || $modified > $lastModified ||
396 425
 					$queriedRange['refresh'] && $id == $queriedRange['refresh']
397
-				)
398
-				{
426
+				) {
399 427
 					$result['data'][$id] = $row;
400 428
 				}
401 429
 
402
-				if ($kUkey !== false) unset($knownUids[$kUkey]);
430
+				if ($kUkey !== false)
431
+				{
432
+					unset($knownUids[$kUkey]);
433
+				}
403 434
 			}
404 435
 			else	// non-row data set by get_rows method
405 436
 			{
@@ -491,17 +522,26 @@  discard block
 block discarded – undo
491 522
 			{
492 523
 				continue;
493 524
 			}
494
-			if($original_value == $value[$key]) continue;
525
+			if($original_value == $value[$key])
526
+			{
527
+				continue;
528
+			}
495 529
 
496 530
 			// These keys we don't send row data back, as they cause a partial reload
497
-			if(in_array($key, array('template'))) $no_rows = true;
531
+			if(in_array($key, array('template')))
532
+			{
533
+				$no_rows = true;
534
+			}
498 535
 
499 536
 			// Actions still need extra handling
500 537
 			if($key == 'actions' && !isset($value['actions'][0]))
501 538
 			{
502 539
 				$value['action_links'] = array();
503 540
 				$template_name = isset($value['template']) ? $value['template'] : '';
504
-				if (!is_array($value['action_links'])) $value['action_links'] = array();
541
+				if (!is_array($value['action_links']))
542
+				{
543
+					$value['action_links'] = array();
544
+				}
505 545
 				$value['actions'] = self::egw_actions($value['actions'], $template_name, '', $value['action_links']);
506 546
 			}
507 547
 
@@ -558,7 +598,10 @@  discard block
 block discarded – undo
558 598
 	 */
559 599
 	private static function call_get_rows(array &$value,array &$rows,array &$readonlys=null,$obj=null,$method=null, Etemplate\Widget $widget=null)
560 600
 	{
561
-		if (is_null($method)) $method = $value['get_rows'];
601
+		if (is_null($method))
602
+		{
603
+			$method = $value['get_rows'];
604
+		}
562 605
 
563 606
 		if (is_null($obj))
564 607
 		{
@@ -584,10 +627,13 @@  discard block
 block discarded – undo
584 627
 				{
585 628
 					$GLOBALS[$class] = new $class();
586 629
 				}
587
-				if (is_object($GLOBALS[$class]))	// use existing instance (put there by a previous CreateObject)
630
+				if (is_object($GLOBALS[$class]))
631
+				{
632
+					// use existing instance (put there by a previous CreateObject)
588 633
 				{
589 634
 					$obj = $GLOBALS[$class];
590 635
 				}
636
+				}
591 637
 				else
592 638
 				{
593 639
 					$obj = CreateObject($app.'.'.$class);
@@ -595,11 +641,17 @@  discard block
 block discarded – undo
595 641
 			}
596 642
 		}
597 643
 		$raw_rows = array();
598
-		if (!is_array($readonlys)) $readonlys = array();
599
-		if(is_callable($method))	// php5.2.3+ static call (value is always a var param!)
644
+		if (!is_array($readonlys))
645
+		{
646
+			$readonlys = array();
647
+		}
648
+		if(is_callable($method))
649
+		{
650
+			// php5.2.3+ static call (value is always a var param!)
600 651
 		{
601 652
 			$total = call_user_func_array($method,array(&$value,&$raw_rows,&$readonlys));
602 653
 		}
654
+		}
603 655
 		elseif(is_object($obj) && method_exists($obj,$method))
604 656
 		{
605 657
 			$total = $obj->$method($value,$raw_rows,$readonlys);
@@ -622,11 +674,17 @@  discard block
 block discarded – undo
622 674
 			// First child should be a grid, we want last row
623 675
 			foreach($row_template->children[0]->children[1]->children as $child)
624 676
 			{
625
-				if($child->type == 'row') $repeating_row = $child;
677
+				if($child->type == 'row')
678
+				{
679
+					$repeating_row = $child;
680
+				}
626 681
 			}
627 682
 		}
628 683
 		// otherwise we might get stoped by max_excutiontime
629
-		if ($total > 200) @set_time_limit(0);
684
+		if ($total > 200)
685
+		{
686
+			@set_time_limit(0);
687
+		}
630 688
 
631 689
 		$is_parent = $value['is_parent'];
632 690
 		$is_parent_value = $value['is_parent_value'];
@@ -639,12 +697,18 @@  discard block
 block discarded – undo
639 697
 			// skip empty rows inserted for each header-line in old etemplate
640 698
 			if (is_int($n) && is_array($rows))
641 699
 			{
642
-				if (is_null($first)) $first = $n;
700
+				if (is_null($first))
701
+				{
702
+					$first = $n;
703
+				}
643 704
 
644
-				if ($row[$is_parent])	// if app supports parent_id / hierarchy, set parent_id and is_parent
705
+				if ($row[$is_parent])
706
+				{
707
+					// if app supports parent_id / hierarchy, set parent_id and is_parent
645 708
 				{
646 709
 					$row['is_parent'] = isset($is_parent_value) ?
647 710
 						$row[$is_parent] == $is_parent_value : (boolean)$row[$is_parent];
711
+				}
648 712
 					$row['parent_id'] = $row[$parent_id];	// seems NOT used on client!
649 713
 				}
650 714
 				// run beforeSendToClient methods of widgets in row on row-data
@@ -662,7 +726,9 @@  discard block
 block discarded – undo
662 726
 				}
663 727
 				$rows[$n-$first+$value['start']] = $row;
664 728
 			}
665
-			elseif(!is_numeric($n))	// rows with string-keys, after numeric rows
729
+			elseif(!is_numeric($n))
730
+			{
731
+				// rows with string-keys, after numeric rows
666 732
 			{
667 733
 				if($n == 'sel_options')
668 734
 				{
@@ -670,6 +736,7 @@  discard block
 block discarded – undo
670 736
 					{
671 737
 						// remember newly set options for validation of nextmatch filters
672 738
 						self::$request->sel_options[$name] = $options;
739
+			}
673 740
 
674 741
 						Select::fix_encoded_options($options, true);
675 742
 					}
@@ -809,8 +876,14 @@  discard block
 block discarded – undo
809 876
 		foreach((array)$actions as $id => $action)
810 877
 		{
811 878
 			// in case it's only selectbox  id => label pairs
812
-			if (!is_array($action)) $action = array('caption' => $action);
813
-			if ($default_attrs) $action += $default_attrs;
879
+			if (!is_array($action))
880
+			{
881
+				$action = array('caption' => $action);
882
+			}
883
+			if ($default_attrs)
884
+			{
885
+				$action += $default_attrs;
886
+			}
814 887
 
815 888
 			// Add 'Select All' after first group
816 889
 			if ($first_level && $group !== false && $action['group'] != $group && !$egw_actions[$prefix.'select_all'])
@@ -864,7 +937,10 @@  discard block
 block discarded – undo
864 937
 				unset($action['prefix']);
865 938
 
866 939
 				// Allow default actions to keep their onExecute
867
-				if($action['default']) unset($inherit_keys['onExecute']);
940
+				if($action['default'])
941
+				{
942
+					unset($inherit_keys['onExecute']);
943
+				}
868 944
 				$action = array_diff_key($action, $inherit_keys);
869 945
 			}
870 946
 
@@ -897,13 +973,19 @@  discard block
 block discarded – undo
897 973
 
898 974
 			$egw_actions[$prefix.$id] = $action;
899 975
 
900
-			if (!$first_level && $n++ == $max_length) break;
976
+			if (!$first_level && $n++ == $max_length)
977
+			{
978
+				break;
979
+			}
901 980
 		}
902 981
 
903 982
 		// Make sure select all is in a group by itself
904 983
 		foreach($egw_actions as $id => &$_action)
905 984
 		{
906
-			if($id == $prefix . 'select_all') continue;
985
+			if($id == $prefix . 'select_all')
986
+			{
987
+				continue;
988
+			}
907 989
 			if($_action['group'] >= $egw_actions[$prefix.'select_all']['group'] )
908 990
 			{
909 991
 				$egw_actions[$id]['group']+=1;
@@ -1055,7 +1137,8 @@  discard block
 block discarded – undo
1055 1137
 		{
1056 1138
 			$pref_name = 'nextmatch-' . (isset($content_value['columnselection_pref']) ? $content_value['columnselection_pref'] : $this->attrs['template']);
1057 1139
 			$refresh_pref_name = $pref_name.'-autorefresh';
1058
-			switch($value['nm_col_preference']) {
1140
+			switch($value['nm_col_preference'])
1141
+			{
1059 1142
 				case 'force':
1060 1143
 					$pref_level = 'forced';
1061 1144
 					break;
@@ -1125,7 +1208,10 @@  discard block
 block discarded – undo
1125 1208
 		if($this->type == 'nextmatch')
1126 1209
 		{
1127 1210
 			parent::run($method_name, $params, $respect_disabled);
1128
-			if ($this->id) $cname = self::form_name($cname, $this->id, $params[1]);
1211
+			if ($this->id)
1212
+			{
1213
+				$cname = self::form_name($cname, $this->id, $params[1]);
1214
+			}
1129 1215
 
1130 1216
 			// Run on all the sub-templates
1131 1217
 			foreach(array('template', 'header_left', 'header_right', 'header_row') as $sub_template)
@@ -1143,8 +1229,14 @@  discard block
 block discarded – undo
1143 1229
 		// TODO: Figure out where these come from
1144 1230
 		foreach(array('$row','${row}', '$', '0','1','2') as $key)
1145 1231
 		{
1146
-			if(is_array(self::$request->content[$cname])) unset(self::$request->content[$cname][$key]);
1147
-			if(is_array(self::$request->preserve[$cname])) unset(self::$request->preserve[$cname][$key]);
1232
+			if(is_array(self::$request->content[$cname]))
1233
+			{
1234
+				unset(self::$request->content[$cname][$key]);
1235
+			}
1236
+			if(is_array(self::$request->preserve[$cname]))
1237
+			{
1238
+				unset(self::$request->preserve[$cname][$key]);
1239
+			}
1148 1240
 		}
1149 1241
 	}
1150 1242
 
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Toolbar.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,14 +29,14 @@
 block discarded – undo
29 29
 	 * @param array &$validated=array() validated content
30 30
 	 * @return boolean true if no validation error, false otherwise
31 31
 	 */
32
-	public function validate($cname, array $expand, array $content, &$validated=array())
32
+	public function validate($cname, array $expand, array $content, &$validated = array())
33 33
 	{
34 34
 		$form_name = self::form_name($cname, $this->id, $expand);
35 35
 
36 36
 		if (!$this->is_readonly($cname, $form_name))
37 37
 		{
38 38
 			$value = self::get_array($content, $form_name);
39
-			$valid =& self::get_array($validated, $form_name, true);
39
+			$valid = & self::get_array($validated, $form_name, true);
40 40
 			if (true) $valid = $value;
41 41
 		}
42 42
 	}
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
 	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
43 43
 	 * @param array $content
44 44
 	 * @param array &$validated=array() validated content
45
-	 * @return boolean true if no validation error, false otherwise
45
+	 * @return boolean|null true if no validation error, false otherwise
46 46
 	 */
47 47
 	public function validate($cname, array $expand, array $content, &$validated=array())
48 48
 	{
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,10 @@
 block discarded – undo
37 37
 		{
38 38
 			$value = self::get_array($content, $form_name);
39 39
 			$valid =& self::get_array($validated, $form_name, true);
40
-			if (true) $valid = $value;
40
+			if (true)
41
+			{
42
+				$valid = $value;
43
+			}
41 44
 		}
42 45
 	}
43 46
 }
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Taglist.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	{
37 37
 		$this->attrs['allowFreeEntries'] = true;
38 38
 
39
-		if($xml) {
39
+		if ($xml) {
40 40
 			parent::__construct($xml);
41 41
 		}
42 42
 	}
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		if ($type == "account")
57 57
 		{
58 58
 			// Only search if a query was provided - don't search for all accounts
59
-			if($query)
59
+			if ($query)
60 60
 			{
61 61
 				$options['account_type'] = $_REQUEST['account_type'];
62 62
 				$links = Api\Accounts::link_query($query, $options);
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 			$links = Api\Link::query($app, $query, $options);
68 68
 		}
69 69
 		$results = array();
70
-		foreach($links as $id => $name)
70
+		foreach ($links as $id => $name)
71 71
 		{
72 72
 			$results[] = array('id' => $id, 'label' => $name);
73 73
 		}
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	public static function ajax_email()
88 88
 	{
89 89
 		// If no mail app access, use link system -> addressbook
90
-		if(!$GLOBALS['egw_info']['apps']['mail'])
90
+		if (!$GLOBALS['egw_info']['apps']['mail'])
91 91
 		{
92 92
 			$_REQUEST['app'] = 'addressbook-email';
93 93
 			return self::ajax_search();
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * @param array $content
106 106
 	 * @param array &$validated=array() validated content
107 107
 	 */
108
-	public function validate($cname, array $expand, array $content, &$validated=array())
108
+	public function validate($cname, array $expand, array $content, &$validated = array())
109 109
 	{
110 110
 		$form_name = self::form_name($cname, $this->id, $expand);
111 111
 
@@ -115,38 +115,38 @@  discard block
 block discarded – undo
115 115
 			$value = $value_in = self::get_array($content, $form_name);
116 116
 			$allowed = Select::selOptions($form_name);
117 117
 
118
-			foreach((array) $value as $key => $val)
118
+			foreach ((array)$value as $key => $val)
119 119
 			{
120
-				if(count($allowed) && !$this->attrs['allowFreeEntries'] && !array_key_exists($val,$allowed))
120
+				if (count($allowed) && !$this->attrs['allowFreeEntries'] && !array_key_exists($val, $allowed))
121 121
 				{
122
-					self::set_validation_error($form_name,lang("'%1' is NOT allowed ('%2')!",$val,implode("','",array_keys($allowed))),'');
122
+					self::set_validation_error($form_name, lang("'%1' is NOT allowed ('%2')!", $val, implode("','", array_keys($allowed))), '');
123 123
 					unset($value[$key]);
124 124
 				}
125
-				if($this->type == 'taglist-email' && $this->attrs['include_lists'] && is_numeric($val))
125
+				if ($this->type == 'taglist-email' && $this->attrs['include_lists'] && is_numeric($val))
126 126
 				{
127 127
 					$lists = $GLOBALS['egw']->contacts->get_lists(Api\Acl::READ);
128
-					if(!array_key_exists($val, $lists))
128
+					if (!array_key_exists($val, $lists))
129 129
 					{
130
-						self::set_validation_error($form_name,lang("'%1' is NOT allowed ('%2')!",$val,implode("','",array_keys($lists))),'');
130
+						self::set_validation_error($form_name, lang("'%1' is NOT allowed ('%2')!", $val, implode("','", array_keys($lists))), '');
131 131
 					}
132 132
 				}
133
-				else if($this->type == 'taglist-email' && !preg_match(Url::EMAIL_PREG, $val) &&
133
+				else if ($this->type == 'taglist-email' && !preg_match(Url::EMAIL_PREG, $val) &&
134 134
 					// Allow merge placeholders.  Might be a better way to do this though.
135
-					!preg_match('/{{.+}}|\$\$.+\$\$/',$val)
135
+					!preg_match('/{{.+}}|\$\$.+\$\$/', $val)
136 136
 				)
137 137
 				{
138
-					self::set_validation_error($form_name,lang("'%1' has an invalid format",$val),'');
138
+					self::set_validation_error($form_name, lang("'%1' has an invalid format", $val), '');
139 139
 				}
140 140
 			}
141 141
 			if ($ok && $value === '' && $this->attrs['needed'])
142 142
 			{
143
-				self::set_validation_error($form_name,lang('Field must not be empty !!!',$value),'');
143
+				self::set_validation_error($form_name, lang('Field must not be empty !!!', $value), '');
144 144
 			}
145
-			if(array_key_exists('multiple', $this->attrs) && $this->attrs['multiple'] == false)
145
+			if (array_key_exists('multiple', $this->attrs) && $this->attrs['multiple'] == false)
146 146
 			{
147 147
 				$value = array_shift($value);
148 148
 			}
149
-			$valid =& self::get_array($validated, $form_name, true);
149
+			$valid = & self::get_array($validated, $form_name, true);
150 150
 			// returning null instead of array(), as array() will be overwritten by etemplate_new::complete_array_merge()
151 151
 			// with preserved old content and therefore user can not empty a taglist
152 152
 			if (true) $valid = $value ? $value : null;
Please login to merge, or discard this patch.
Braces   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,7 +36,8 @@  discard block
 block discarded – undo
36 36
 	{
37 37
 		$this->attrs['allowFreeEntries'] = true;
38 38
 
39
-		if($xml) {
39
+		if($xml)
40
+		{
40 41
 			parent::__construct($xml);
41 42
 		}
42 43
 	}
@@ -133,8 +134,7 @@  discard block
 block discarded – undo
133 134
 				else if($this->type == 'taglist-email' && !preg_match(Url::EMAIL_PREG, $val) &&
134 135
 					// Allow merge placeholders.  Might be a better way to do this though.
135 136
 					!preg_match('/{{.+}}|\$\$.+\$\$/',$val)
136
-				)
137
-				{
137
+				) {
138 138
 					self::set_validation_error($form_name,lang("'%1' has an invalid format",$val),'');
139 139
 				}
140 140
 			}
@@ -149,7 +149,10 @@  discard block
 block discarded – undo
149 149
 			$valid =& self::get_array($validated, $form_name, true);
150 150
 			// returning null instead of array(), as array() will be overwritten by etemplate_new::complete_array_merge()
151 151
 			// with preserved old content and therefore user can not empty a taglist
152
-			if (true) $valid = $value ? $value : null;
152
+			if (true)
153
+			{
154
+				$valid = $value ? $value : null;
155
+			}
153 156
 			//error_log(__METHOD__."() $form_name: ".array2string($value_in).' --> '.array2string($value).', allowed='.array2string($allowed));
154 157
 		}
155 158
 	}
Please login to merge, or discard this patch.