Completed
Push — 14.2 ( e07840...cec2da )
by Ralf
83:18 queued 52:04
created
etemplate/inc/class.bo_merge.inc.php 5 patches
Doc Comments   +18 added lines, -16 removed lines patch added patch discarded remove patch
@@ -353,9 +353,9 @@  discard block
 block discarded – undo
353 353
 	 *
354 354
 	 * Calls get_links() repeatedly to get all the combinations for the content.
355 355
 	 *
356
-	 * @param $app String appname
356
+	 * @param string $app String appname
357 357
 	 * @param $id String ID of record
358
-	 * @param $prefix
358
+	 * @param string $prefix
359 359
 	 * @param $content String document content
360 360
 	 */
361 361
 	protected function get_all_links($app, $id, $prefix, &$content)
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 	 * Format a datetime
429 429
 	 *
430 430
 	 * @param int|string|DateTime $time unix timestamp or Y-m-d H:i:s string (in user time!)
431
-	 * @param string $format=null format string, default $this->datetime_format
431
+	 * @param string $format format string, default $this->datetime_format
432 432
 	 * @deprecated use egw_time::to($time='now',$format='')
433 433
 	 * @return string
434 434
 	 */
@@ -470,7 +470,6 @@  discard block
 block discarded – undo
470 470
 	/**
471 471
 	 * getExportLimit
472 472
 	 * checks if there is an exportlimit set, and returns
473
-	 * @param mixed $app_limit checks and validates app_limit, if not set returns the global limit
474 473
 	 *
475 474
 	 * @return mixed - no if no export is allowed, false if there is no restriction and int as there is a valid restriction
476 475
 	 *		you may have to cast the returned value to int, if you want to use it as number
@@ -517,7 +516,7 @@  discard block
 block discarded – undo
517 516
 	 * @param mixed $app_limit app_limit, if not set checks the global limit
518 517
 	 * @param string $checkas [AND|ISALLOWED], AND default; if set to ISALLOWED it is checked if Export is allowed
519 518
 	 *
520
-	 * @return bool - true if no export is allowed or a limit is set, false if there is no restriction
519
+	 * @return boolean|null - true if no export is allowed or a limit is set, false if there is no restriction
521 520
 	 */
522 521
 	public static function hasExportLimit($app_limit,$checkas='AND')
523 522
 	{
@@ -534,7 +533,6 @@  discard block
 block discarded – undo
534 533
 	 * @param array $ids array with contact id(s)
535 534
 	 * @param string &$err error-message on error
536 535
 	 * @param string $mimetype mimetype of complete document, eg. text/*, application/vnd.oasis.opendocument.text, application/rtf
537
-	 * @param array $fix=null regular expression => replacement pairs eg. to fix garbled placeholders
538 536
 	 * @return string|boolean merged document or false on error
539 537
 	 */
540 538
 	public function &merge($document,$ids,&$err,$mimetype,array $fix=null)
@@ -566,6 +564,9 @@  discard block
 block discarded – undo
566 564
 		return $content;
567 565
 	}
568 566
 
567
+	/**
568
+	 * @param string $mimetype
569
+	 */
569 570
 	protected function apply_styles (&$content, $mimetype, $mso_application_progid=null)
570 571
 	{
571 572
 		if (!isset($mso_application_progid))
@@ -666,8 +667,7 @@  discard block
 block discarded – undo
666 667
 	 * @param array $ids array with contact id(s)
667 668
 	 * @param string &$err error-message on error
668 669
 	 * @param string $mimetype mimetype of complete document, eg. text/*, application/vnd.oasis.opendocument.text, application/rtf
669
-	 * @param array $fix=null regular expression => replacement pairs eg. to fix garbled placeholders
670
-	 * @param string $charset=null charset to override default set by mimetype or export charset
670
+	 * @param string $charset charset to override default set by mimetype or export charset
671 671
 	 * @return string|boolean merged document or false on error
672 672
 	 */
673 673
 	public function &merge_string($content,$ids,&$err,$mimetype,array $fix=null,$charset=null)
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
 	 * @param array $replacements name => replacement pairs
905 905
 	 * @param string $mimetype mimetype of content
906 906
 	 * @param string $mso_application_progid='' MS Office 2003: 'Excel.Sheet' or 'Word.Document'
907
-	 * @param string $charset=null charset to override default set by mimetype or export charset
907
+	 * @param string $charset charset to override default set by mimetype or export charset
908 908
 	 * @return string
909 909
 	 */
910 910
 	protected function replace($content,array $replacements,$mimetype,$mso_application_progid='',$charset=null)
@@ -1123,6 +1123,8 @@  discard block
 block discarded – undo
1123 1123
 
1124 1124
 	/**
1125 1125
 	 * Convert numeric values in spreadsheets into actual numeric values
1126
+	 * @param string $content
1127
+	 * @param string $mimetype
1126 1128
 	 */
1127 1129
 	protected function format_spreadsheet_numbers(&$content, $names, $mimetype)
1128 1130
 	{
@@ -1192,6 +1194,7 @@  discard block
 block discarded – undo
1192 1194
 
1193 1195
 	/**
1194 1196
 	 * Convert date / timestamp values in spreadsheets into actual date / timestamp values
1197
+	 * @param string $mimetype
1195 1198
 	 */
1196 1199
 	protected function format_spreadsheet_dates(&$content, $names, &$values, $mimetype)
1197 1200
 	{
@@ -1296,6 +1299,7 @@  discard block
 block discarded – undo
1296 1299
 	/**
1297 1300
 	 * Expand link_to custom fields with the merge replacements from the app
1298 1301
 	 * but only if the template uses them.
1302
+	 * @param string $app
1299 1303
 	 */
1300 1304
 	public function cf_link_to_expand($values, $content, &$replacements, $app = null)
1301 1305
 	{
@@ -1360,7 +1364,7 @@  discard block
 block discarded – undo
1360 1364
 	/**
1361 1365
 	 * Process special flags, such as IF or NELF
1362 1366
 	 *
1363
-	 * @param content Text to be examined and changed
1367
+	 * @param content string to be examined and changed
1364 1368
 	 * @param replacements array of markers => replacement
1365 1369
 	 *
1366 1370
 	 * @return changed content
@@ -1672,8 +1676,7 @@  discard block
 block discarded – undo
1672 1676
 	 * Get a list of document actions / files from the given directory
1673 1677
 	 *
1674 1678
 	 * @param string $dirs Directory(s comma or space separated) to search
1675
-	 * @param string $prefix='document_' prefix for array keys
1676
-	 * @param array|string $mime_filter=null allowed mime type(s), default all, negative filter if $mime_filter[0] === '!'
1679
+	 * @param array|string $mime_filter allowed mime type(s), default all, negative filter if $mime_filter[0] === '!'
1677 1680
 	 * @return array List of documents, suitable for a selectbox.  The key is document_<filename>.
1678 1681
 	 */
1679 1682
 	public static function get_documents($dirs, $prefix='document_', $mime_filter=null, $app='')
@@ -1728,10 +1731,8 @@  discard block
 block discarded – undo
1728 1731
 	 *
1729 1732
 	 * @param string $dirs Directory(s comma or space separated) to search
1730 1733
 	 * @param int $group see nextmatch_widget::egw_actions
1731
-	 * @param string $caption='Insert in document'
1732
-	 * @param string $prefix='document_'
1733 1734
 	 * @param string $default_doc='' full path to default document to show on top with action == 'document'!
1734
-	 * @param int|string $export_limit=null export-limit, default $GLOBALS['egw_info']['server']['export_limit']
1735
+	 * @param int|string $export_limit export-limit, default $GLOBALS['egw_info']['server']['export_limit']
1735 1736
 	 * @return array see nextmatch_widget::egw_actions
1736 1737
 	 */
1737 1738
 	public static function document_action($dirs, $group=0, $caption='Insert in document', $prefix='document_', $default_doc='',
@@ -1934,6 +1935,7 @@  discard block
 block discarded – undo
1934 1935
 	 *
1935 1936
 	 * @param string &$document maybe relative path of document, on return true absolute path to existing document
1936 1937
 	 * @param string $dirs comma or whitespace separated directories
1938
+	 * @param string $document
1937 1939
 	 * @return string|boolean false if document exists, otherwise string with error-message
1938 1940
 	 */
1939 1941
 	public static function check_document(&$document, $dirs)
@@ -1977,7 +1979,7 @@  discard block
 block discarded – undo
1977 1979
 	 * Reimplemented from etemplate to NOT use user prefs for Excel 2003, which gives an xml error
1978 1980
 	 *
1979 1981
 	 * @param int|float|string $number
1980
-	 * @param int $num_decimal_places=2
1982
+	 * @param int $num_decimal_places
1981 1983
 	 * @param string $_mimetype=''
1982 1984
 	 * @return string
1983 1985
 	 */
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -417,10 +417,10 @@
 block discarded – undo
417 417
 			}
418 418
 		}
419 419
 		// Need to set each app, to make sure placeholders are removed
420
-                foreach(array_keys($GLOBALS['egw_info']['user']['apps']) as $_app)
421
-                {
422
-                        $array[($prefix?$prefix.'/':'')."links/$app"] = $this->get_links($app,$id,$_app);
423
-                }
420
+				foreach(array_keys($GLOBALS['egw_info']['user']['apps']) as $_app)
421
+				{
422
+						$array[($prefix?$prefix.'/':'')."links/$app"] = $this->get_links($app,$id,$_app);
423
+				}
424 424
 		return $array;
425 425
 	}
426 426
 
Please login to merge, or discard this patch.
Spacing   +355 added lines, -355 removed lines patch added patch discarded remove patch
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
 	 * Configuration for HTML Tidy to clean up any HTML content that is kept
69 69
 	 */
70 70
 	public static $tidy_config = array(
71
-		'output-xml'		=> true,	// Entity encoding
71
+		'output-xml'		=> true, // Entity encoding
72 72
 		'show-body-only'	=> true,
73 73
 		'output-encoding'	=> 'utf-8',
74 74
 		'input-encoding'	=> 'utf-8',
75
-		'quote-ampersand'	=> false,	// Prevent double encoding
76
-		'quote-nbsp'		=> true,	// XSLT can handle spaces easier
75
+		'quote-ampersand'	=> false, // Prevent double encoding
76
+		'quote-nbsp'		=> true, // XSLT can handle spaces easier
77 77
 		'preserve-entities'	=> true,
78
-		'wrap'			=> 0,		// Wrapping can break output
78
+		'wrap'			=> 0, // Wrapping can break output
79 79
 	);
80 80
 
81 81
 	/**
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		$this->contacts = new addressbook_bo();
109 109
 
110 110
 		$this->datetime_format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' '.
111
-			($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']==12 ? 'h:i a' : 'H:i');
111
+			($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i');
112 112
 
113 113
 		$this->export_limit = self::getExportLimit();
114 114
 	}
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		$accountsel = new uiaccountsel();
124 124
 
125 125
 		return '<input type="hidden" value="" name="newsettings[export_limit_excepted]" />'.
126
-			$accountsel->selection('newsettings[export_limit_excepted]','export_limit_excepted',$config['export_limit_excepted'],'both',4);
126
+			$accountsel->selection('newsettings[export_limit_excepted]', 'export_limit_excepted', $config['export_limit_excepted'], 'both', 4);
127 127
 	}
128 128
 
129 129
 	/**
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * @param string &$content=null content to create some replacements only if they are use
138 138
 	 * @return array|boolean array with replacements or false if entry not found
139 139
 	 */
140
-	abstract protected function get_replacements($id,&$content=null);
140
+	abstract protected function get_replacements($id, &$content = null);
141 141
 
142 142
 	/**
143 143
 	 * Return if merge-print is implemented for given mime-type (and/or extension)
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
 	 * @param string $mimetype eg. text/plain
146 146
 	 * @param string $extension only checked for applications/msword and .rtf
147 147
 	 */
148
-	static public function is_implemented($mimetype,$extension=null)
148
+	static public function is_implemented($mimetype, $extension = null)
149 149
 	{
150 150
 		static $zip_available;
151 151
 		if (is_null($zip_available))
152 152
 		{
153 153
 			$zip_available = check_load_extension('zip') &&
154
-				class_exists('ZipArchive');	// some PHP has zip extension, but no ZipArchive (eg. RHEL5!)
154
+				class_exists('ZipArchive'); // some PHP has zip extension, but no ZipArchive (eg. RHEL5!)
155 155
 		}
156 156
 		switch ($mimetype)
157 157
 		{
@@ -159,25 +159,25 @@  discard block
 block discarded – undo
159 159
 				if (strtolower($extension) != '.rtf') break;
160 160
 			case 'application/rtf':
161 161
 			case 'text/rtf':
162
-				return true;	// rtf files
162
+				return true; // rtf files
163 163
 			case 'application/vnd.oasis.opendocument.text':	// oo text
164 164
 			case 'application/vnd.oasis.opendocument.spreadsheet':	// oo spreadsheet
165 165
 				if (!$zip_available) break;
166
-				return true;	// open office write xml files
166
+				return true; // open office write xml files
167 167
 			case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':	// ms word 2007 xml format
168 168
 			case 'application/vnd.openxmlformats-officedocument.wordprocessingml.d':	// mimetypes in vfs are limited to 64 chars
169 169
 			case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':	// ms excel 2007 xml format
170 170
 			case 'application/vnd.openxmlformats-officedocument.spreadsheetml.shee':
171 171
 				if (!$zip_available) break;
172
-				return true;	// ms word xml format
172
+				return true; // ms word xml format
173 173
 			case 'application/xml':
174
-				return true;	// alias for text/xml, eg. ms office 2003 word format
174
+				return true; // alias for text/xml, eg. ms office 2003 word format
175 175
 			case 'message/rfc822':
176 176
 				return true; // ToDo: check if you are theoretical able to send mail
177 177
 			default:
178
-				if (substr($mimetype,0,5) == 'text/')
178
+				if (substr($mimetype, 0, 5) == 'text/')
179 179
 				{
180
-					return true;	// text files
180
+					return true; // text files
181 181
 				}
182 182
 				break;
183 183
 		}
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 * @param boolean $ignore_acl =false true: no acl check
196 196
 	 * @return array
197 197
 	 */
198
-	public function contact_replacements($contact,$prefix='',$ignore_acl=false)
198
+	public function contact_replacements($contact, $prefix = '', $ignore_acl = false)
199 199
 	{
200 200
 		if (!is_array($contact))
201 201
 		{
@@ -204,19 +204,19 @@  discard block
 block discarded – undo
204 204
 		if (!is_array($contact)) return array();
205 205
 		
206 206
 		$replacements = array();
207
-		foreach(array_keys($this->contacts->contact_fields) as $name)
207
+		foreach (array_keys($this->contacts->contact_fields) as $name)
208 208
 		{
209 209
 			$value = $contact[$name];
210
-			switch($name)
210
+			switch ($name)
211 211
 			{
212 212
 				case 'created': case 'modified':
213
-					if($value) $value = egw_time::to($value);
213
+					if ($value) $value = egw_time::to($value);
214 214
 					break;
215 215
 				case 'bday':
216 216
 					if ($value)
217 217
 					{
218
-						list($y,$m,$d) = explode('-',$value);
219
-						$value = common::dateformatorder($y,$m,$d,true);
218
+						list($y, $m, $d) = explode('-', $value);
219
+						$value = common::dateformatorder($y, $m, $d, true);
220 220
 					}
221 221
 					break;
222 222
 				case 'owner': case 'creator': case 'modifier':
@@ -228,11 +228,11 @@  discard block
 block discarded – undo
228 228
 						// if cat-tree is displayed, we return a full category path not just the name of the cat
229 229
 						$use = $GLOBALS['egw_info']['server']['cat_tab'] == 'Tree' ? 'path' : 'name';
230 230
 						$cats = array();
231
-						foreach(is_array($value) ? $value : explode(',',$value) as $cat_id)
231
+						foreach (is_array($value) ? $value : explode(',', $value) as $cat_id)
232 232
 						{
233
-							$cats[] = $GLOBALS['egw']->categories->id2name($cat_id,$use);
233
+							$cats[] = $GLOBALS['egw']->categories->id2name($cat_id, $use);
234 234
 						}
235
-						$value = implode(', ',$cats);
235
+						$value = implode(', ', $cats);
236 236
 					}
237 237
 					break;
238 238
 				case 'jpegphoto':	// returning a link might make more sense then the binary photo
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 					{
241 241
 						$value = ($GLOBALS['egw_info']['server']['webserver_url'][0] == '/' ?
242 242
 							($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'] : '').
243
-							$GLOBALS['egw']->link('/index.php',$contact['photo']);
243
+							$GLOBALS['egw']->link('/index.php', $contact['photo']);
244 244
 					}
245 245
 					break;
246 246
 				case 'tel_prefer':
@@ -252,38 +252,38 @@  discard block
 block discarded – undo
252 252
 				case 'account_id':
253 253
 					if ($value)
254 254
 					{
255
-						$replacements['$$'.($prefix ? $prefix.'/':'').'account_lid$$'] = $GLOBALS['egw']->accounts->id2name($value);
255
+						$replacements['$$'.($prefix ? $prefix.'/' : '').'account_lid$$'] = $GLOBALS['egw']->accounts->id2name($value);
256 256
 					}
257 257
 					break;
258 258
 			}
259
-			if ($name != 'photo') $replacements['$$'.($prefix ? $prefix.'/':'').$name.'$$'] = $value;
259
+			if ($name != 'photo') $replacements['$$'.($prefix ? $prefix.'/' : '').$name.'$$'] = $value;
260 260
 		}
261 261
 		// set custom fields, should probably go to a general method all apps can use
262 262
 		// need to load all cfs for $ignore_acl=true
263
-		foreach($ignore_acl ? egw_customfields::get('addressbook', true) : $this->contacts->customfields as $name => $field)
263
+		foreach ($ignore_acl ? egw_customfields::get('addressbook', true) : $this->contacts->customfields as $name => $field)
264 264
 		{
265 265
 			$name = '#'.$name;
266
-			$replacements['$$'.($prefix ? $prefix.'/':'').$name.'$$'] = egw_customfields::format($field, (string)$contact[$name]);
266
+			$replacements['$$'.($prefix ? $prefix.'/' : '').$name.'$$'] = egw_customfields::format($field, (string)$contact[$name]);
267 267
 		}
268 268
 
269 269
 		// Add in extra cat field
270 270
 		$cats = array();
271
-		foreach(is_array($contact['cat_id']) ? $contact['cat_id'] : explode(',',$contact['cat_id']) as $cat_id)
271
+		foreach (is_array($contact['cat_id']) ? $contact['cat_id'] : explode(',', $contact['cat_id']) as $cat_id)
272 272
 		{
273
-			if(!$cat_id) continue;
274
-			if($GLOBALS['egw']->categories->id2name($cat_id,'main') != $cat_id)
273
+			if (!$cat_id) continue;
274
+			if ($GLOBALS['egw']->categories->id2name($cat_id, 'main') != $cat_id)
275 275
 			{
276
-				$path = $GLOBALS['egw']->categories->id2name($cat_id,'path');
276
+				$path = $GLOBALS['egw']->categories->id2name($cat_id, 'path');
277 277
 				$path = explode(' / ', $path);
278 278
 				unset($path[0]); // Drop main
279
-				$cats[$GLOBALS['egw']->categories->id2name($cat_id,'main')][] = implode(' / ', $path);
280
-			} elseif($cat_id) {
279
+				$cats[$GLOBALS['egw']->categories->id2name($cat_id, 'main')][] = implode(' / ', $path);
280
+			} elseif ($cat_id) {
281 281
 				$cats[$cat_id] = array();
282 282
 			}
283 283
 		}
284
-		foreach($cats as $main => $cat) {
285
-			$replacements['$$'.($prefix ? $prefix.'/':'').'categories$$'] .= $GLOBALS['egw']->categories->id2name($main,'name')
286
-				. (count($cat) > 0 ? ': ' : '') . implode(', ', $cats[$main]) . "\n";
284
+		foreach ($cats as $main => $cat) {
285
+			$replacements['$$'.($prefix ? $prefix.'/' : '').'categories$$'] .= $GLOBALS['egw']->categories->id2name($main, 'name')
286
+				. (count($cat) > 0 ? ': ' : '').implode(', ', $cats[$main])."\n";
287 287
 		}
288 288
 		return $replacements;
289 289
 	}
@@ -302,34 +302,34 @@  discard block
 block discarded – undo
302 302
 	 * 	'link' - URL to the entry
303 303
 	 * 	'href' - HREF tag wrapped around the title
304 304
 	 */
305
-	protected function get_links($app, $id, $only_app='', $exclude = array(), $style = 'title')
305
+	protected function get_links($app, $id, $only_app = '', $exclude = array(), $style = 'title')
306 306
 	{
307 307
 		$links = egw_link::get_links($app, $id, $only_app);
308 308
 		$link_titles = array();
309
-		foreach($links as $link_id => $link_info)
309
+		foreach ($links as $link_id => $link_info)
310 310
 		{
311 311
 			// Using only_app only returns the ID
312
-			if(!is_array($link_info) && $only_app && $only_app[0] !== '!')
312
+			if (!is_array($link_info) && $only_app && $only_app[0] !== '!')
313 313
 			{
314 314
 				$link_info = array(
315 315
 					'app'	=> $only_app,
316 316
 					'id'	=> $link_info
317 317
 				);
318 318
 			}
319
-			if($exclude && in_array($link_info['id'], $exclude)) continue;
319
+			if ($exclude && in_array($link_info['id'], $exclude)) continue;
320 320
 
321 321
 			$title = egw_link::title($link_info['app'], $link_info['id']);
322
-			if(class_exists('stylite_links_stream_wrapper') && $link_info['app'] != egw_link::VFS_APPNAME)
322
+			if (class_exists('stylite_links_stream_wrapper') && $link_info['app'] != egw_link::VFS_APPNAME)
323 323
 			{
324 324
 				$title = stylite_links_stream_wrapper::entry2name($link_info['app'], $link_info['id'], $title);
325 325
 			}
326
-			if($style == 'href' || $style == 'link')
326
+			if ($style == 'href' || $style == 'link')
327 327
 			{
328 328
 				$link = egw_link::view($link_info['app'], $link_info['id'], $link_info);
329
-				if($link_info['app'] != egw_link::VFS_APPNAME)
329
+				if ($link_info['app'] != egw_link::VFS_APPNAME)
330 330
 				{
331 331
 					// Set app to false so we always get an external link
332
-					$link = str_replace(',','%2C',egw::link('/index.php',$link, false));
332
+					$link = str_replace(',', '%2C', egw::link('/index.php', $link, false));
333 333
 				}
334 334
 				else
335 335
 				{
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 			}
346 346
 			$link_titles[] = $title;
347 347
 		}
348
-		return implode("\n",$link_titles);
348
+		return implode("\n", $link_titles);
349 349
 	}
350 350
 
351 351
 	/**
@@ -363,31 +363,31 @@  discard block
 block discarded – undo
363 363
 		$array = array();
364 364
 		$pattern = '@\$(links_attachments|links|attachments|link)\/?(title|href|link)?\/?([a-z]*)\$@';
365 365
 		static $link_cache;
366
-		if(preg_match_all($pattern, $content, $matches))
366
+		if (preg_match_all($pattern, $content, $matches))
367 367
 		{
368
-			foreach($matches[0] as $i => $placeholder)
368
+			foreach ($matches[0] as $i => $placeholder)
369 369
 			{
370 370
 				$placeholder = substr($placeholder, 1, -1);
371
-				if($link_cache[$id][$placeholder])
371
+				if ($link_cache[$id][$placeholder])
372 372
 				{
373 373
 					$array[$placeholder] = $link_cache[$id][$placeholder];
374 374
 					continue;
375 375
 				}
376
-				switch($matches[1][$i])
376
+				switch ($matches[1][$i])
377 377
 				{
378 378
 					case 'link':
379 379
 						// Link to current record
380 380
 						$title = egw_link::title($app, $id);
381
-						if(class_exists('stylite_links_stream_wrapper') && $app != egw_link::VFS_APPNAME)
381
+						if (class_exists('stylite_links_stream_wrapper') && $app != egw_link::VFS_APPNAME)
382 382
 						{
383 383
 							$title = stylite_links_stream_wrapper::entry2name($app, $id, $title);
384 384
 						}
385 385
 
386 386
 						$link = egw_link::view($app, $id);
387
-						if($app != egw_link::VFS_APPNAME)
387
+						if ($app != egw_link::VFS_APPNAME)
388 388
 						{
389 389
 							// Set app to false so we always get an external link
390
-							$link = str_replace(',','%2C',egw::link('/index.php',$link, false));
390
+							$link = str_replace(',', '%2C', egw::link('/index.php', $link, false));
391 391
 						}
392 392
 						else
393 393
 						{
@@ -400,26 +400,26 @@  discard block
 block discarded – undo
400 400
 								($GLOBALS['egw_info']['server']['hostname'] ? $GLOBALS['egw_info']['server']['hostname'] : $_SERVER['HTTP_HOST']).$link;
401 401
 						}
402 402
 						$title = html::a_href(html::htmlspecialchars($title), $link);
403
-						$array[($prefix?$prefix.'/':'').$placeholder] = $title;
403
+						$array[($prefix ? $prefix.'/' : '').$placeholder] = $title;
404 404
 						break;
405 405
 					case 'links':
406
-						$link_app = $matches[3][$i] ? $matches[3][$i] :  '!'.egw_link::VFS_APPNAME;
407
-						$array[($prefix?$prefix.'/':'').$placeholder] = $this->get_links($app, $id, $link_app, array(),$matches[2][$i]);
406
+						$link_app = $matches[3][$i] ? $matches[3][$i] : '!'.egw_link::VFS_APPNAME;
407
+						$array[($prefix ? $prefix.'/' : '').$placeholder] = $this->get_links($app, $id, $link_app, array(), $matches[2][$i]);
408 408
 						break;
409 409
 					case 'attachments':
410
-						$array[($prefix?$prefix.'/':'').$placeholder] = $this->get_links($app, $id, egw_link::VFS_APPNAME,array(),$matches[2][$i]);
410
+						$array[($prefix ? $prefix.'/' : '').$placeholder] = $this->get_links($app, $id, egw_link::VFS_APPNAME, array(), $matches[2][$i]);
411 411
 						break;
412 412
 					default:
413
-						$array[($prefix?$prefix.'/':'').$placeholder] = $this->get_links($app, $id, $matches[3][$i], array(), $matches[2][$i]);
413
+						$array[($prefix ? $prefix.'/' : '').$placeholder] = $this->get_links($app, $id, $matches[3][$i], array(), $matches[2][$i]);
414 414
 						break;
415 415
 				}
416 416
 				$link_cache[$id][$placeholder] = $array[$placeholder];
417 417
 			}
418 418
 		}
419 419
 		// Need to set each app, to make sure placeholders are removed
420
-                foreach(array_keys($GLOBALS['egw_info']['user']['apps']) as $_app)
420
+                foreach (array_keys($GLOBALS['egw_info']['user']['apps']) as $_app)
421 421
                 {
422
-                        $array[($prefix?$prefix.'/':'')."links/$app"] = $this->get_links($app,$id,$_app);
422
+                        $array[($prefix ? $prefix.'/' : '')."links/$app"] = $this->get_links($app, $id, $_app);
423 423
                 }
424 424
 		return $array;
425 425
 	}
@@ -432,12 +432,12 @@  discard block
 block discarded – undo
432 432
 	 * @deprecated use egw_time::to($time='now',$format='')
433 433
 	 * @return string
434 434
 	 */
435
-	protected function format_datetime($time,$format=null)
435
+	protected function format_datetime($time, $format = null)
436 436
 	{
437
-		trigger_error(__METHOD__ . ' is deprecated, use egw_time::to($time, $format)', E_USER_DEPRECATED);
437
+		trigger_error(__METHOD__.' is deprecated, use egw_time::to($time, $format)', E_USER_DEPRECATED);
438 438
 		if (is_null($format)) $format = $this->datetime_format;
439 439
 
440
-		return egw_time::to($time,$format);
440
+		return egw_time::to($time, $format);
441 441
 	}
442 442
 
443 443
 	/**
@@ -459,9 +459,9 @@  discard block
 block discarded – undo
459 459
 			if (!$is_excepted && (is_array($export_limit_excepted = $GLOBALS['egw_info']['server']['export_limit_excepted']) ||
460 460
 				is_array($export_limit_excepted = unserialize($export_limit_excepted))))
461 461
 			{
462
-				$id_and_memberships = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'],true);
462
+				$id_and_memberships = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true);
463 463
 				$id_and_memberships[] = $GLOBALS['egw_info']['user']['account_id'];
464
-				$is_excepted = (bool) array_intersect($id_and_memberships, $export_limit_excepted);
464
+				$is_excepted = (bool)array_intersect($id_and_memberships, $export_limit_excepted);
465 465
 			}
466 466
 		}
467 467
 		return $is_excepted;
@@ -475,19 +475,19 @@  discard block
 block discarded – undo
475 475
 	 * @return mixed - no if no export is allowed, false if there is no restriction and int as there is a valid restriction
476 476
 	 *		you may have to cast the returned value to int, if you want to use it as number
477 477
 	 */
478
-	public static function getExportLimit($app='common')
478
+	public static function getExportLimit($app = 'common')
479 479
 	{
480 480
 		static $exportLimitStore;
481
-		if (is_null($exportLimitStore)) $exportLimitStore=array();
482
-		if (empty($app)) $app='common';
481
+		if (is_null($exportLimitStore)) $exportLimitStore = array();
482
+		if (empty($app)) $app = 'common';
483 483
 		//error_log(__METHOD__.__LINE__.' called with app:'.$app);
484
-		if (!array_key_exists($app,$exportLimitStore))
484
+		if (!array_key_exists($app, $exportLimitStore))
485 485
 		{
486 486
 			//error_log(__METHOD__.__LINE__.' -> '.$app_limit.' '.function_backtrace());
487 487
 			$exportLimitStore[$app] = $GLOBALS['egw_info']['server']['export_limit'];
488
-			if ($app !='common')
488
+			if ($app != 'common')
489 489
 			{
490
-				$app_limit = $GLOBALS['egw']->hooks->single('export_limit',$app);
490
+				$app_limit = $GLOBALS['egw']->hooks->single('export_limit', $app);
491 491
 				if ($app_limit) $exportLimitStore[$app] = $app_limit;
492 492
 			}
493 493
 			//error_log(__METHOD__.__LINE__.' building cache for app:'.$app.' -> '.$exportLimitStore[$app]);
@@ -519,9 +519,9 @@  discard block
 block discarded – undo
519 519
 	 *
520 520
 	 * @return bool - true if no export is allowed or a limit is set, false if there is no restriction
521 521
 	 */
522
-	public static function hasExportLimit($app_limit,$checkas='AND')
522
+	public static function hasExportLimit($app_limit, $checkas = 'AND')
523 523
 	{
524
-		if (strtoupper($checkas) == 'ISALLOWED') return (empty($app_limit) || ($app_limit !='no' && $app_limit > 0) );
524
+		if (strtoupper($checkas) == 'ISALLOWED') return (empty($app_limit) || ($app_limit != 'no' && $app_limit > 0));
525 525
 		if (empty($app_limit)) return false;
526 526
 		if ($app_limit == 'no') return true;
527 527
 		if ($app_limit > 0) return true;
@@ -537,28 +537,28 @@  discard block
 block discarded – undo
537 537
 	 * @param array $fix=null regular expression => replacement pairs eg. to fix garbled placeholders
538 538
 	 * @return string|boolean merged document or false on error
539 539
 	 */
540
-	public function &merge($document,$ids,&$err,$mimetype,array $fix=null)
540
+	public function &merge($document, $ids, &$err, $mimetype, array $fix = null)
541 541
 	{
542 542
 		if (!($content = file_get_contents($document)))
543 543
 		{
544
-			$err = lang("Document '%1' does not exist or is not readable for you!",$document);
544
+			$err = lang("Document '%1' does not exist or is not readable for you!", $document);
545 545
 			return false;
546 546
 		}
547 547
 
548 548
 		if (self::hasExportLimit($this->export_limit) && !self::is_export_limit_excepted() && count($ids) > (int)$this->export_limit)
549 549
 		{
550
-			$err = lang('No rights to export more than %1 entries!',(int)$this->export_limit);
550
+			$err = lang('No rights to export more than %1 entries!', (int)$this->export_limit);
551 551
 			return false;
552 552
 		}
553 553
 
554 554
 		// fix application/msword mimetype for rtf files
555
-		if ($mimetype == 'application/msword' && strtolower(substr($document,-4)) == '.rtf')
555
+		if ($mimetype == 'application/msword' && strtolower(substr($document, -4)) == '.rtf')
556 556
 		{
557 557
 			$mimetype = 'application/rtf';
558 558
 		}
559 559
 
560 560
 		try {
561
-			$content = $this->merge_string($content,$ids,$err,$mimetype,$fix);
561
+			$content = $this->merge_string($content, $ids, $err, $mimetype, $fix);
562 562
 		} catch (Exception $e) {
563 563
 			$err = $e->getMessage();
564 564
 			return false;
@@ -566,17 +566,17 @@  discard block
 block discarded – undo
566 566
 		return $content;
567 567
 	}
568 568
 
569
-	protected function apply_styles (&$content, $mimetype, $mso_application_progid=null)
569
+	protected function apply_styles(&$content, $mimetype, $mso_application_progid = null)
570 570
 	{
571 571
 		if (!isset($mso_application_progid))
572 572
 		{
573 573
 			$mso_application_progid = $mimetype == 'application/xml' &&
574
-				preg_match('/'.preg_quote('<?mso-application progid="').'([^"]+)'.preg_quote('"?>').'/',substr($content,0,200),$matches) ?
574
+				preg_match('/'.preg_quote('<?mso-application progid="').'([^"]+)'.preg_quote('"?>').'/', substr($content, 0, 200), $matches) ?
575 575
 					$matches[1] : '';
576 576
 		}
577 577
 		// Tags we can replace with the target document's version
578 578
 		$replace_tags = array();
579
-		switch($mimetype.$mso_application_progid)
579
+		switch ($mimetype.$mso_application_progid)
580 580
 		{
581 581
 			case 'application/vnd.oasis.opendocument.text':		// open office
582 582
 			case 'application/vnd.oasis.opendocument.spreadsheet':
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 					'/<\/(ol|ul|table)>/' => '</$1><text:p>',
587 587
 					//'/<(li)(.*?)>(.*?)<\/\1>/' => '<$1 $2>$3</$1>',
588 588
 				);
589
-				$content = preg_replace(array_keys($replace_tags),array_values($replace_tags),$content);
589
+				$content = preg_replace(array_keys($replace_tags), array_values($replace_tags), $content);
590 590
 
591 591
 				$doc = new DOMDocument();
592 592
 				$xslt = new XSLTProcessor();
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 					// Remove spans with no attributes, linebreaks inside them cause problems
612 612
 					'/<span>(.*?)<\/span>/' => '$1'
613 613
 				);
614
-				$content = preg_replace(array_keys($replace_tags),array_values($replace_tags),$content, -1, $count);
614
+				$content = preg_replace(array_keys($replace_tags), array_values($replace_tags), $content, -1, $count);
615 615
 
616 616
 				/*
617 617
 				In the case where you have something like <span><span></w:t><w:br/><w:t></span></span> (invalid - mismatched tags),
@@ -621,9 +621,9 @@  discard block
 block discarded – undo
621 621
 				$count = $i = 0;
622 622
 				do
623 623
 				{
624
-					$content = preg_replace('/<span>(.*?)<\/span>/','$1',$content, -1, $count);
624
+					$content = preg_replace('/<span>(.*?)<\/span>/', '$1', $content, -1, $count);
625 625
 					$i++;
626
-				} while($count > 0 && $i < 10);
626
+				} while ($count > 0 && $i < 10);
627 627
 
628 628
 				$doc = new DOMDocument();
629 629
 				$xslt = new XSLTProcessor();
@@ -634,20 +634,20 @@  discard block
 block discarded – undo
634 634
 		}
635 635
 
636 636
 		// XSLT transform known tags
637
-		if($xslt)
637
+		if ($xslt)
638 638
 		{
639 639
 			// does NOT work with php 5.2.6: Catchable fatal error: argument 1 to transformToXml() must be of type DOMDocument
640 640
 			//$element = new SimpleXMLelement($content);
641 641
 			$element = new DOMDocument('1.0', 'utf-8');
642 642
 			$result = $element->loadXML($content);
643
-			if(!$result)
643
+			if (!$result)
644 644
 			{
645 645
 				throw new Exception('Unable to parse merged document for styles.  Check warnings in log for details.');
646 646
 			}
647 647
 			$content = $xslt->transformToXml($element);
648 648
 
649 649
 			// Word 2003 needs two declarations, add extra declaration back in
650
-			if($mimetype == 'application/xml' && $mso_application_progid == 'Word.Document' && strpos($content, '<?xml') !== 0) {
650
+			if ($mimetype == 'application/xml' && $mso_application_progid == 'Word.Document' && strpos($content, '<?xml') !== 0) {
651 651
 				$content = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'.$content;
652 652
 			}
653 653
 			// Validate
@@ -670,10 +670,10 @@  discard block
 block discarded – undo
670 670
 	 * @param string $charset=null charset to override default set by mimetype or export charset
671 671
 	 * @return string|boolean merged document or false on error
672 672
 	 */
673
-	public function &merge_string($content,$ids,&$err,$mimetype,array $fix=null,$charset=null)
673
+	public function &merge_string($content, $ids, &$err, $mimetype, array $fix = null, $charset = null)
674 674
 	{
675 675
 		if ($mimetype == 'application/xml' &&
676
-			preg_match('/'.preg_quote('<?mso-application progid="').'([^"]+)'.preg_quote('"?>').'/',substr($content,0,200),$matches))
676
+			preg_match('/'.preg_quote('<?mso-application progid="').'([^"]+)'.preg_quote('"?>').'/', substr($content, 0, 200), $matches))
677 677
 		{
678 678
 			$mso_application_progid = $matches[1];
679 679
 		}
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 		}
684 684
 		// alternative syntax using double curly brackets (eg. {{cat_id}} instead $$cat_id$$),
685 685
 		// agressivly removing all xml-tags eg. Word adds within placeholders
686
-		$content = preg_replace_callback('/{{[^}]+}}/i',create_function('$p','return \'$$\'.strip_tags(substr($p[0],2,-2)).\'$$\';'),$content);
686
+		$content = preg_replace_callback('/{{[^}]+}}/i', create_function('$p', 'return \'$$\'.strip_tags(substr($p[0],2,-2)).\'$$\';'), $content);
687 687
 
688 688
 		// make currently processed mimetype available to class methods;
689 689
 		$this->mimetype = $mimetype;
@@ -691,16 +691,16 @@  discard block
 block discarded – undo
691 691
 		// fix garbled placeholders
692 692
 		if ($fix && is_array($fix))
693 693
 		{
694
-			$content = preg_replace(array_keys($fix),array_values($fix),$content);
694
+			$content = preg_replace(array_keys($fix), array_values($fix), $content);
695 695
 			//die("<pre>".htmlspecialchars($content)."</pre>\n");
696 696
 		}
697
-		list($contentstart,$contentrepeat,$contentend) = preg_split('/\$\$pagerepeat\$\$/',$content,-1, PREG_SPLIT_NO_EMPTY);  //get differt parts of document, seperatet by Pagerepeat
697
+		list($contentstart, $contentrepeat, $contentend) = preg_split('/\$\$pagerepeat\$\$/', $content, -1, PREG_SPLIT_NO_EMPTY); //get differt parts of document, seperatet by Pagerepeat
698 698
 		if ($mimetype == 'text/plain' && count($ids) > 1)
699 699
 		{
700 700
 			// textdocuments are simple, they do not hold start and end, but they may have content before and after the $$pagerepeat$$ tag
701 701
 			// header and footer should not hold any $$ tags; if we find $$ tags with the header, we assume it is the pagerepeatcontent
702 702
 			$nohead = false;
703
-			if (stripos($contentstart,'$$') !== false) $nohead = true;
703
+			if (stripos($contentstart, '$$') !== false) $nohead = true;
704 704
 			if ($nohead)
705 705
 			{
706 706
 				$contentend = $contentrepeat;
@@ -711,14 +711,14 @@  discard block
 block discarded – undo
711 711
 		}
712 712
 		if ($mimetype == 'application/vnd.oasis.opendocument.text' && count($ids) > 1)
713 713
 		{
714
-			if(strpos($content, '$$pagerepeat') === false)
714
+			if (strpos($content, '$$pagerepeat') === false)
715 715
 			{
716 716
 				//for odt files we have to split the content and add a style for page break to  the style area
717
-				list($contentstart,$contentrepeat,$contentend) = preg_split('/office:body>/',$content,-1, PREG_SPLIT_NO_EMPTY);  //get differt parts of document, seperatet by Pagerepeat
718
-				$contentstart = substr($contentstart,0,strlen($contentstart)-1);  //remove "<"
719
-				$contentrepeat = substr($contentrepeat,0,strlen($contentrepeat)-2);  //remove "</";
717
+				list($contentstart, $contentrepeat, $contentend) = preg_split('/office:body>/', $content, -1, PREG_SPLIT_NO_EMPTY); //get differt parts of document, seperatet by Pagerepeat
718
+				$contentstart = substr($contentstart, 0, strlen($contentstart) - 1); //remove "<"
719
+				$contentrepeat = substr($contentrepeat, 0, strlen($contentrepeat) - 2); //remove "</";
720 720
 				// need to add page-break style to the style list
721
-				list($stylestart,$stylerepeat,$styleend) = preg_split('/<\/office:automatic-styles>/',$content,-1, PREG_SPLIT_NO_EMPTY);  //get differt parts of document style sheets
721
+				list($stylestart, $stylerepeat, $styleend) = preg_split('/<\/office:automatic-styles>/', $content, -1, PREG_SPLIT_NO_EMPTY); //get differt parts of document style sheets
722 722
 				$contentstart = $stylestart.'<style:style style:name="P200" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:break-before="page"/></style:style></office:automatic-styles>';
723 723
 				$contentstart .= '<office:body>';
724 724
 				$contentend = '</office:body></office:document-content>';
@@ -726,22 +726,22 @@  discard block
 block discarded – undo
726 726
 			else
727 727
 			{
728 728
 				// Template specifies where to repeat
729
-				list($contentstart,$contentrepeat,$contentend) = preg_split('/\$\$pagerepeat\$\$/',$content,-1, PREG_SPLIT_NO_EMPTY);  //get different parts of document, seperated by pagerepeat
729
+				list($contentstart, $contentrepeat, $contentend) = preg_split('/\$\$pagerepeat\$\$/', $content, -1, PREG_SPLIT_NO_EMPTY); //get different parts of document, seperated by pagerepeat
730 730
 			}
731 731
 		}
732 732
 		if ($mimetype == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' && count($ids) > 1)
733 733
 		{
734 734
 			//for Word 2007 XML files we have to split the content and add a style for page break to  the style area
735
-			list($contentstart,$contentrepeat,$contentend) = preg_split('/w:body>/',$content,-1, PREG_SPLIT_NO_EMPTY);  //get differt parts of document, seperatet by Pagerepeat
736
-			$contentstart = substr($contentstart,0,strlen($contentstart)-1);  //remove "</"
737
-			$contentrepeat = substr($contentrepeat,0,strlen($contentrepeat)-2);  //remove "</";
735
+			list($contentstart, $contentrepeat, $contentend) = preg_split('/w:body>/', $content, -1, PREG_SPLIT_NO_EMPTY); //get differt parts of document, seperatet by Pagerepeat
736
+			$contentstart = substr($contentstart, 0, strlen($contentstart) - 1); //remove "</"
737
+			$contentrepeat = substr($contentrepeat, 0, strlen($contentrepeat) - 2); //remove "</";
738 738
 			$contentstart .= '<w:body>';
739 739
 			$contentend = '</w:body></w:document>';
740 740
 		}
741
-		list($Labelstart,$Labelrepeat,$Labeltend) = preg_split('/\$\$label\$\$/',$contentrepeat,-1, PREG_SPLIT_NO_EMPTY);  //get the Lable content
742
-		preg_match_all('/\$\$labelplacement\$\$/',$contentrepeat,$countlables, PREG_SPLIT_NO_EMPTY);
741
+		list($Labelstart, $Labelrepeat, $Labeltend) = preg_split('/\$\$label\$\$/', $contentrepeat, -1, PREG_SPLIT_NO_EMPTY); //get the Lable content
742
+		preg_match_all('/\$\$labelplacement\$\$/', $contentrepeat, $countlables, PREG_SPLIT_NO_EMPTY);
743 743
 		$countlables = count($countlables[0]);
744
-		preg_replace('/\$\$labelplacement\$\$/','',$Labelrepeat,1);
744
+		preg_replace('/\$\$labelplacement\$\$/', '', $Labelrepeat, 1);
745 745
 		if ($countlables > 1) $lableprint = true;
746 746
 		if (count($ids) > 1 && !$contentrepeat)
747 747
 		{
@@ -752,10 +752,10 @@  discard block
 block discarded – undo
752 752
 
753 753
 		if ($contentrepeat)
754 754
 		{
755
-			$content_stream = fopen('php://temp','r+');
755
+			$content_stream = fopen('php://temp', 'r+');
756 756
 			fwrite($content_stream, $contentstart);
757 757
 			$joiner = '';
758
-			switch($mimetype)
758
+			switch ($mimetype)
759 759
 			{
760 760
 				case 'application/rtf':
761 761
 				case 'text/rtf':
@@ -775,19 +775,19 @@  discard block
 block discarded – undo
775 775
 					$joiner = "\r\n";
776 776
 					break;
777 777
 				default:
778
-					$err = lang('%1 not implemented for %2!','$$pagerepeat$$',$mimetype);
778
+					$err = lang('%1 not implemented for %2!', '$$pagerepeat$$', $mimetype);
779 779
 					return false;
780 780
 			}
781 781
 		}
782 782
 		foreach ((array)$ids as $n => $id)
783 783
 		{
784
-			if ($contentrepeat) $content = $contentrepeat;   //content to repeat
784
+			if ($contentrepeat) $content = $contentrepeat; //content to repeat
785 785
 			if ($lableprint) $content = $Labelrepeat;
786 786
 
787 787
 			// generate replacements; if exeption is thrown, catch it set error message and return false
788 788
 			try
789 789
 			{
790
-				if(!($replacements = $this->get_replacements($id,$content)))
790
+				if (!($replacements = $this->get_replacements($id, $content)))
791 791
 				{
792 792
 					$err = lang('Entry not found!');
793 793
 					return false;
@@ -801,88 +801,88 @@  discard block
 block discarded – undo
801 801
 			}
802 802
 			if ($this->report_memory_usage) error_log(__METHOD__."() $n: $id ".egw_vfs::hsize(memory_get_usage(true)));
803 803
 			// some general replacements: current user, date and time
804
-			if (strpos($content,'$$user/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')))
804
+			if (strpos($content, '$$user/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id')))
805 805
 			{
806
-				$replacements += $this->contact_replacements($user,'user');
807
-				$replacements['$$user/primary_group$$'] = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'account_primary_group'));
806
+				$replacements += $this->contact_replacements($user, 'user');
807
+				$replacements['$$user/primary_group$$'] = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'account_primary_group'));
808 808
 			}
809
-			$replacements['$$date$$'] = egw_time::to('now',true);
809
+			$replacements['$$date$$'] = egw_time::to('now', true);
810 810
 			$replacements['$$datetime$$'] = egw_time::to('now');
811
-			$replacements['$$time$$'] = egw_time::to('now',false);
811
+			$replacements['$$time$$'] = egw_time::to('now', false);
812 812
 
813 813
 			// does our extending class registered table-plugins AND document contains table tags
814
-			if ($this->table_plugins && preg_match_all('/\\$\\$table\\/([A-Za-z0-9_]+)\\$\\$(.*?)\\$\\$endtable\\$\\$/s',$content,$matches,PREG_SET_ORDER))
814
+			if ($this->table_plugins && preg_match_all('/\\$\\$table\\/([A-Za-z0-9_]+)\\$\\$(.*?)\\$\\$endtable\\$\\$/s', $content, $matches, PREG_SET_ORDER))
815 815
 			{
816 816
 				// process each table
817
-				foreach($matches as $match)
817
+				foreach ($matches as $match)
818 818
 				{
819
-					$plugin   = $match[1];	// plugin name
819
+					$plugin   = $match[1]; // plugin name
820 820
 					$callback = $this->table_plugins[$plugin];
821
-					$repeat   = $match[2];	// line to repeat
821
+					$repeat   = $match[2]; // line to repeat
822 822
 					$repeats = '';
823 823
 					if (isset($callback))
824 824
 					{
825
-						for($n = 0; ($row_replacements = $this->$callback($plugin,$id,$n,$repeat)); ++$n)
825
+						for ($n = 0; ($row_replacements = $this->$callback($plugin, $id, $n, $repeat)); ++$n)
826 826
 						{
827 827
 							$_repeat = $this->process_commands($repeat, $row_replacements);
828
-							$repeats .= $this->replace($_repeat,$row_replacements,$mimetype,$mso_application_progid);
828
+							$repeats .= $this->replace($_repeat, $row_replacements, $mimetype, $mso_application_progid);
829 829
 						}
830 830
 					}
831
-					$content = str_replace($match[0],$repeats,$content);
831
+					$content = str_replace($match[0], $repeats, $content);
832 832
 				}
833 833
 			}
834
-			$content = $this->replace($content,$replacements,$mimetype,$mso_application_progid,$charset);
834
+			$content = $this->replace($content, $replacements, $mimetype, $mso_application_progid, $charset);
835 835
 
836 836
 			$content = $this->process_commands($content, $replacements);
837 837
 
838 838
 			// remove not existing replacements (eg. from calendar array)
839
-			if (strpos($content,'$$') !== null)
839
+			if (strpos($content, '$$') !== null)
840 840
 			{
841
-				$content = preg_replace('/\$\$[a-z0-9_\/]+\$\$/i','',$content);
841
+				$content = preg_replace('/\$\$[a-z0-9_\/]+\$\$/i', '', $content);
842 842
 			}
843 843
 			if ($contentrepeat)
844 844
 			{
845
-				fwrite($content_stream, ($n == 0 ? '' : $joiner) . $content);
845
+				fwrite($content_stream, ($n == 0 ? '' : $joiner).$content);
846 846
 			}
847
-			if($lableprint)
847
+			if ($lableprint)
848 848
 			{
849
-				$contentrep[is_array($id) ? implode(':',$id) : $id] = $content;
849
+				$contentrep[is_array($id) ? implode(':', $id) : $id] = $content;
850 850
 			}
851 851
 		}
852 852
 		if ($Labelrepeat)
853 853
 		{
854
-			$countpage=0;
855
-			$count=0;
854
+			$countpage = 0;
855
+			$count = 0;
856 856
 			$contentrepeatpages[$countpage] = $Labelstart.$Labeltend;
857 857
 
858 858
 			foreach ($contentrep as $Label)
859 859
 			{
860
-				$contentrepeatpages[$countpage] = preg_replace('/\$\$labelplacement\$\$/',$Label,$contentrepeatpages[$countpage],1);
861
-				$count=$count+1;
862
-				if (($count % $countlables) == 0 && count($contentrep)>$count)  //new page
860
+				$contentrepeatpages[$countpage] = preg_replace('/\$\$labelplacement\$\$/', $Label, $contentrepeatpages[$countpage], 1);
861
+				$count = $count + 1;
862
+				if (($count % $countlables) == 0 && count($contentrep) > $count)  //new page
863 863
 				{
864
-					$countpage = $countpage+1;
864
+					$countpage = $countpage + 1;
865 865
 					$contentrepeatpages[$countpage] = $Labelstart.$Labeltend;
866 866
 				}
867 867
 			}
868
-			$contentrepeatpages[$countpage] = preg_replace('/\$\$labelplacement\$\$/','',$contentrepeatpages[$countpage],-1);  //clean empty fields
868
+			$contentrepeatpages[$countpage] = preg_replace('/\$\$labelplacement\$\$/', '', $contentrepeatpages[$countpage], -1); //clean empty fields
869 869
 
870
-			switch($mimetype)
870
+			switch ($mimetype)
871 871
 			{
872 872
 				case 'application/rtf':
873 873
 				case 'text/rtf':
874
-					return $contentstart.implode('\\par \\page\\pard\\plain',$contentrepeatpages).$contentend;
874
+					return $contentstart.implode('\\par \\page\\pard\\plain', $contentrepeatpages).$contentend;
875 875
 				case 'application/vnd.oasis.opendocument.text':
876
-					return $contentstart.implode('<text:line-break />',$contentrepeatpages).$contentend;
876
+					return $contentstart.implode('<text:line-break />', $contentrepeatpages).$contentend;
877 877
 				case 'application/vnd.oasis.opendocument.spreadsheet':
878
-					return $contentstart.implode('</text:p><text:p>',$contentrepeatpages).$contentend;
878
+					return $contentstart.implode('</text:p><text:p>', $contentrepeatpages).$contentend;
879 879
 				case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
880 880
 				case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
881
-					return $contentstart.implode('<w:br w:type="page" />',$contentrepeatpages).$contentend;
881
+					return $contentstart.implode('<w:br w:type="page" />', $contentrepeatpages).$contentend;
882 882
 				case 'text/plain':
883
-					return $contentstart.implode("\r\n",$contentrep).$contentend;
883
+					return $contentstart.implode("\r\n", $contentrep).$contentend;
884 884
 			}
885
-			$err = lang('%1 not implemented for %2!','$$labelplacement$$',$mimetype);
885
+			$err = lang('%1 not implemented for %2!', '$$labelplacement$$', $mimetype);
886 886
 			return false;
887 887
 		}
888 888
 
@@ -907,9 +907,9 @@  discard block
 block discarded – undo
907 907
 	 * @param string $charset=null charset to override default set by mimetype or export charset
908 908
 	 * @return string
909 909
 	 */
910
-	protected function replace($content,array $replacements,$mimetype,$mso_application_progid='',$charset=null)
910
+	protected function replace($content, array $replacements, $mimetype, $mso_application_progid = '', $charset = null)
911 911
 	{
912
-		switch($mimetype)
912
+		switch ($mimetype)
913 913
 		{
914 914
 			case 'application/vnd.oasis.opendocument.text':		// open office
915 915
 			case 'application/vnd.oasis.opendocument.spreadsheet':
@@ -918,12 +918,12 @@  discard block
 block discarded – undo
918 918
 			case 'application/xml':
919 919
 			case 'text/xml':
920 920
 				$is_xml = true;
921
-				$charset = 'utf-8';	// xml files --> always use utf-8
921
+				$charset = 'utf-8'; // xml files --> always use utf-8
922 922
 				break;
923 923
 
924 924
 			case 'text/html':
925 925
 				$is_xml = true;
926
-				if (preg_match('/<meta http-equiv="content-type".*charset=([^;"]+)/i',$content,$matches))
926
+				if (preg_match('/<meta http-equiv="content-type".*charset=([^;"]+)/i', $content, $matches))
927 927
 				{
928 928
 					$charset = $matches[1];
929 929
 				}
@@ -942,18 +942,18 @@  discard block
 block discarded – undo
942 942
 		// do we need to convert charset
943 943
 		if ($charset && $charset != translation::charset())
944 944
 		{
945
-			$replacements = translation::convert($replacements,translation::charset(),$charset);
945
+			$replacements = translation::convert($replacements, translation::charset(), $charset);
946 946
 		}
947 947
 
948 948
 		// Date only placeholders for timestamps
949
-		if(is_array($this->date_fields))
949
+		if (is_array($this->date_fields))
950 950
 		{
951
-			foreach($this->date_fields as $field)
951
+			foreach ($this->date_fields as $field)
952 952
 			{
953
-				if($value = $replacements['$$'.$field.'$$'])
953
+				if ($value = $replacements['$$'.$field.'$$'])
954 954
 				{
955 955
 					$time = egw_time::createFromFormat('+'.egw_time::$user_dateformat.' '.egw_time::$user_timeformat.'*', $value);
956
-					$replacements['$$'.$field.'/date$$'] = $time ? $time->format(egw_time::$user_dateformat)  : '';
956
+					$replacements['$$'.$field.'/date$$'] = $time ? $time->format(egw_time::$user_dateformat) : '';
957 957
 				}
958 958
 			}
959 959
 		}
@@ -967,66 +967,66 @@  discard block
 block discarded – undo
967 967
 			// only keep tags, if we have xsl extension available
968 968
 			if (class_exists(XSLTProcessor) && class_exists(DOMDocument) && $this->parse_html_styles)
969 969
 			{
970
-				switch($mimetype.$mso_application_progid)
970
+				switch ($mimetype.$mso_application_progid)
971 971
 				{
972 972
 					case 'text/html':
973 973
 						$replace_tags = array(
974
-							'<b>','<strong>','<i>','<em>','<u>','<span>','<ol>','<ul>','<li>',
975
-							'<table>','<tr>','<td>','<a>','<style>',
974
+							'<b>', '<strong>', '<i>', '<em>', '<u>', '<span>', '<ol>', '<ul>', '<li>',
975
+							'<table>', '<tr>', '<td>', '<a>', '<style>',
976 976
 						);
977 977
 						break;
978 978
 					case 'application/vnd.oasis.opendocument.text':		// open office
979 979
 					case 'application/vnd.oasis.opendocument.spreadsheet':
980 980
 						$replace_tags = array(
981
-							'<b>','<strong>','<i>','<em>','<u>','<span>','<ol>','<ul>','<li>',
982
-							'<table>','<tr>','<td>','<a>',
981
+							'<b>', '<strong>', '<i>', '<em>', '<u>', '<span>', '<ol>', '<ul>', '<li>',
982
+							'<table>', '<tr>', '<td>', '<a>',
983 983
 						);
984 984
 						break;
985 985
 					case 'application/xmlWord.Document':	// Word 2003*/
986 986
 					case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':	// ms office 2007
987 987
 					case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
988 988
 						$replace_tags = array(
989
-							'<b>','<strong>','<i>','<em>','<u>','<span>','<ol>','<ul>','<li>',
990
-							'<table>','<tr>','<td>',
989
+							'<b>', '<strong>', '<i>', '<em>', '<u>', '<span>', '<ol>', '<ul>', '<li>',
990
+							'<table>', '<tr>', '<td>',
991 991
 						);
992 992
 						break;
993 993
 				}
994 994
 			}
995 995
 			// clean replacements from array values and html or html-entities, which mess up xml
996
-			foreach($replacements as $name => &$value)
996
+			foreach ($replacements as $name => &$value)
997 997
 			{
998 998
 				// set unresolved array values to empty string
999
-				if(is_array($value))
999
+				if (is_array($value))
1000 1000
 				{
1001 1001
 					$value = '';
1002 1002
 					continue;
1003 1003
 				}
1004 1004
 				// decode html entities back to utf-8
1005 1005
 
1006
-				if (is_string($value) && (strpos($value,'&') !== false) && $this->parse_html_styles)
1006
+				if (is_string($value) && (strpos($value, '&') !== false) && $this->parse_html_styles)
1007 1007
 				{
1008
-					$value = html_entity_decode($value,ENT_QUOTES,$charset);
1008
+					$value = html_entity_decode($value, ENT_QUOTES, $charset);
1009 1009
 
1010 1010
 					// remove all non-decodable entities
1011
-					if (strpos($value,'&') !== false)
1011
+					if (strpos($value, '&') !== false)
1012 1012
 					{
1013
-						$value = preg_replace('/&[^; ]+;/','',$value);
1013
+						$value = preg_replace('/&[^; ]+;/', '', $value);
1014 1014
 					}
1015 1015
 				}
1016 1016
 
1017
-				if(!$this->parse_html_styles)
1017
+				if (!$this->parse_html_styles)
1018 1018
 				{
1019 1019
 					// Encode special chars so they don't break the file
1020
-					$value = htmlspecialchars($value,ENT_NOQUOTES);
1020
+					$value = htmlspecialchars($value, ENT_NOQUOTES);
1021 1021
 				}
1022
-				else if (is_string($value) && (strpos($value,'<') !== false))
1022
+				else if (is_string($value) && (strpos($value, '<') !== false))
1023 1023
 				{
1024 1024
 					// Clean HTML, if it's being kept
1025
-					if($replace_tags && extension_loaded('tidy')) {
1025
+					if ($replace_tags && extension_loaded('tidy')) {
1026 1026
 						$tidy = new tidy();
1027 1027
 						$cleaned = $tidy->repairString($value, self::$tidy_config);
1028 1028
 						// Found errors. Strip it all so there's some output
1029
-						if($tidy->getStatus() == 2)
1029
+						if ($tidy->getStatus() == 2)
1030 1030
 						{
1031 1031
 							error_log($tidy->errorBuffer);
1032 1032
 							$value = strip_tags($value);
@@ -1037,51 +1037,51 @@  discard block
 block discarded – undo
1037 1037
 						}
1038 1038
 					}
1039 1039
 					// replace </p> and <br /> with CRLF (remove <p> and CRLF)
1040
-					$value = str_replace(array("\r","\n",'<p>','</p>','<div>','</div>','<br />'),array('','','',"\r\n",'',"\r\n","\r\n"),$value);
1041
-					$value = strip_tags($value,implode('',$replace_tags));
1040
+					$value = str_replace(array("\r", "\n", '<p>', '</p>', '<div>', '</div>', '<br />'), array('', '', '', "\r\n", '', "\r\n", "\r\n"), $value);
1041
+					$value = strip_tags($value, implode('', $replace_tags));
1042 1042
 
1043 1043
 					// Change <tag>...\r\n</tag> to <tag>...</tag>\r\n or simplistic line break below will mangle it
1044 1044
 					// Loop to catch things like <b><span>Break:\r\n</span></b>
1045
-					if($mso_application_progid)
1045
+					if ($mso_application_progid)
1046 1046
 					{
1047 1047
 						$count = $i = 0;
1048 1048
 						do
1049 1049
 						{
1050
-							$value = preg_replace('/<(b|strong|i|em|u|span)\b([^>]*?)>(.*?)'."\r\n".'<\/\1>/u', '<$1$2>$3</$1>'."\r\n",$value,-1,$count);
1050
+							$value = preg_replace('/<(b|strong|i|em|u|span)\b([^>]*?)>(.*?)'."\r\n".'<\/\1>/u', '<$1$2>$3</$1>'."\r\n", $value, -1, $count);
1051 1051
 							$i++;
1052
-						} while($count > 0 && $i < 10); // Limit of 10 chosen arbitrarily just in case
1052
+						} while ($count > 0 && $i < 10); // Limit of 10 chosen arbitrarily just in case
1053 1053
 					}
1054 1054
 				}
1055 1055
 				// replace all control chars (C0+C1) but CR (\015), LF (\012) and TAB (\011) (eg. vertical tabulators) with space
1056 1056
 				// as they are not allowed in xml
1057
-				$value = preg_replace('/[\000-\010\013\014\016-\037\177-\237]/u',' ',$value);
1058
-				if(is_numeric($value) && $name != '$$user/account_id$$') // account_id causes problems with the preg_replace below
1057
+				$value = preg_replace('/[\000-\010\013\014\016-\037\177-\237]/u', ' ', $value);
1058
+				if (is_numeric($value) && $name != '$$user/account_id$$') // account_id causes problems with the preg_replace below
1059 1059
 				{
1060
-					$names[] = preg_quote($name,'/');
1060
+					$names[] = preg_quote($name, '/');
1061 1061
 				}
1062 1062
 			}
1063 1063
 
1064 1064
 			// Look for numbers, set their value if needed
1065
-			if($this->numeric_fields || count($names))
1065
+			if ($this->numeric_fields || count($names))
1066 1066
 			{
1067
-				foreach((array)$this->numeric_fields as $fieldname) {
1068
-					$names[] = preg_quote($fieldname,'/');
1067
+				foreach ((array)$this->numeric_fields as $fieldname) {
1068
+					$names[] = preg_quote($fieldname, '/');
1069 1069
 				}
1070 1070
 				$this->format_spreadsheet_numbers($content, $names, $mimetype.$mso_application_progid);
1071 1071
 			}
1072 1072
 
1073 1073
 			// Look for dates, set their value if needed
1074
-			if($this->date_fields || count($names))
1074
+			if ($this->date_fields || count($names))
1075 1075
 			{
1076 1076
 				$names = array();
1077
-				foreach((array)$this->date_fields as $fieldname) {
1077
+				foreach ((array)$this->date_fields as $fieldname) {
1078 1078
 					$names[] = $fieldname;
1079 1079
 				}
1080 1080
 				$this->format_spreadsheet_dates($content, $names, $replacements, $mimetype.$mso_application_progid);
1081 1081
 			}
1082 1082
 
1083 1083
 			// replace CRLF with linebreak tag of given type
1084
-			switch($mimetype.$mso_application_progid)
1084
+			switch ($mimetype.$mso_application_progid)
1085 1085
 			{
1086 1086
 				case 'application/vnd.oasis.opendocument.text':		// open office writer
1087 1087
 					$break = '<text:line-break/>';
@@ -1108,17 +1108,17 @@  discard block
 block discarded – undo
1108 1108
 			}
1109 1109
 			// now decode &, < and >, which need to be encoded as entities in xml
1110 1110
 			// Check for encoded >< getting double-encoded
1111
-			if($this->parse_html_styles)
1111
+			if ($this->parse_html_styles)
1112 1112
 			{
1113
-				$replacements = str_replace(array('&',"\r","\n",'&amp;lt;','&amp;gt;'),array('&amp;','',$break,'&lt;','&gt;'),$replacements);
1113
+				$replacements = str_replace(array('&', "\r", "\n", '&amp;lt;', '&amp;gt;'), array('&amp;', '', $break, '&lt;', '&gt;'), $replacements);
1114 1114
 			}
1115 1115
 			else
1116 1116
 			{
1117 1117
 				// Need to at least handle new lines, or it'll be run together on one line
1118
-				$replacements = str_replace(array("\r","\n"),array('',$break),$replacements);
1118
+				$replacements = str_replace(array("\r", "\n"), array('', $break), $replacements);
1119 1119
 			}
1120 1120
 		}
1121
-		return str_replace(array_keys($replacements),array_values($replacements),$content);
1121
+		return str_replace(array_keys($replacements), array_values($replacements), $content);
1122 1122
 	}
1123 1123
 
1124 1124
 	/**
@@ -1126,36 +1126,36 @@  discard block
 block discarded – undo
1126 1126
 	 */
1127 1127
 	protected function format_spreadsheet_numbers(&$content, $names, $mimetype)
1128 1128
 	{
1129
-		foreach((array)$this->numeric_fields as $fieldname) {
1130
-			$names[] = preg_quote($fieldname,'/');
1129
+		foreach ((array)$this->numeric_fields as $fieldname) {
1130
+			$names[] = preg_quote($fieldname, '/');
1131 1131
 		}
1132
-		switch($mimetype)
1132
+		switch ($mimetype)
1133 1133
 		{
1134 1134
 			case 'application/vnd.oasis.opendocument.spreadsheet':		// open office calc
1135
-				$format = '/<table:table-cell([^>]+?)office:value-type="[^"]+"([^>]*?)(?:calcext:value-type="[^"]+")?>.?<([a-z].*?)[^>]*>('.implode('|',$names).')<\/\3>.?<\/table:table-cell>/s';
1135
+				$format = '/<table:table-cell([^>]+?)office:value-type="[^"]+"([^>]*?)(?:calcext:value-type="[^"]+")?>.?<([a-z].*?)[^>]*>('.implode('|', $names).')<\/\3>.?<\/table:table-cell>/s';
1136 1136
 				$replacement = '<table:table-cell$1office:value-type="float" office:value="$4"$2 calcext:value-type="float"><$3>$4</$3></table:table-cell>';
1137 1137
 				break;
1138 1138
 			case 'application/vnd.oasis.opendocument.text':		// tables in open office writer
1139
-				$format = '/<table:table-cell([^>]+?)office:value-type="[^"]+"([^>]*?)>.?<([a-z].*?)[^>]*>('.implode('|',$names).')<\/\3>.?<\/table:table-cell>/s';
1139
+				$format = '/<table:table-cell([^>]+?)office:value-type="[^"]+"([^>]*?)>.?<([a-z].*?)[^>]*>('.implode('|', $names).')<\/\3>.?<\/table:table-cell>/s';
1140 1140
 				$replacement = '<table:table-cell$1office:value-type="float" office:value="$4"$2><text:p text:style-name="Standard">$4</text:p></table:table-cell>';
1141 1141
 				break;
1142 1142
 			case 'application/vnd.oasis.opendocument.text':		// open office writer
1143 1143
 			case 'application/xmlExcel.Sheet':	// Excel 2003
1144
-				$format = '/'.preg_quote('<Data ss:Type="String">','/').'('.implode('|',$names).')'.preg_quote('</Data>','/').'/';
1144
+				$format = '/'.preg_quote('<Data ss:Type="String">', '/').'('.implode('|', $names).')'.preg_quote('</Data>', '/').'/';
1145 1145
 				$replacement = '<Data ss:Type="Number">$1</Data>';
1146 1146
 
1147 1147
 				break;
1148 1148
 		}
1149
-		if($format && $names)
1149
+		if ($format && $names)
1150 1150
 		{
1151 1151
 			// Dealing with backtrack limit per AmigoJack 10-Jul-2010 comment on php.net preg-replace docs
1152 1152
 			do {
1153 1153
 				$result = preg_replace($format, $replacement, $content, -1);
1154 1154
 			}
1155 1155
 			// try to increase/double pcre.backtrack_limit failure
1156
-			while(preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR && self::increase_backtrack_limit());
1156
+			while (preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR && self::increase_backtrack_limit());
1157 1157
 
1158
-			if ($result) $content = $result;  // On failure $result would be NULL
1158
+			if ($result) $content = $result; // On failure $result would be NULL
1159 1159
 		}
1160 1160
 	}
1161 1161
 
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 	 */
1167 1167
 	protected static function increase_backtrack_limit()
1168 1168
 	{
1169
-		static $backtrack_limit=null,$memory_limit=null;
1169
+		static $backtrack_limit = null, $memory_limit = null;
1170 1170
 		if (!isset($backtrack_limit))
1171 1171
 		{
1172 1172
 			$backtrack_limit = ini_get('pcre.backtrack_limit');
@@ -1174,16 +1174,16 @@  discard block
 block discarded – undo
1174 1174
 		if (!isset($memory_limit))
1175 1175
 		{
1176 1176
 			$memory_limit = ini_get('memory_limit');
1177
-			switch(strtoupper(substr($memory_limit, -1)))
1177
+			switch (strtoupper(substr($memory_limit, -1)))
1178 1178
 			{
1179 1179
 				case 'G': $memory_limit *= 1024;
1180 1180
 				case 'M': $memory_limit *= 1024;
1181 1181
 				case 'K': $memory_limit *= 1024;
1182 1182
 			}
1183 1183
 		}
1184
-		if ($backtrack_limit < $memory_limit/8)
1184
+		if ($backtrack_limit < $memory_limit / 8)
1185 1185
 		{
1186
-			ini_set( 'pcre.backtrack_limit', $backtrack_limit*=2);
1186
+			ini_set('pcre.backtrack_limit', $backtrack_limit *= 2);
1187 1187
 			return true;
1188 1188
 		}
1189 1189
 		error_log("pcre.backtrack_limit exceeded @ $backtrack_limit, some cells left as text.");
@@ -1195,32 +1195,32 @@  discard block
 block discarded – undo
1195 1195
 	 */
1196 1196
 	protected function format_spreadsheet_dates(&$content, $names, &$values, $mimetype)
1197 1197
 	{
1198
-		if(!in_array($mimetype, array(
1199
-			'application/vnd.oasis.opendocument.spreadsheet',		// open office calc
1200
-			'application/xmlExcel.Sheet',					// Excel 2003
1198
+		if (!in_array($mimetype, array(
1199
+			'application/vnd.oasis.opendocument.spreadsheet', // open office calc
1200
+			'application/xmlExcel.Sheet', // Excel 2003
1201 1201
 			//'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'//Excel WTF
1202 1202
 		))) return;
1203 1203
 
1204 1204
 		// Some different formats dates could be in, depending what they've been through
1205 1205
 		$formats = array(
1206
-			'!'.egw_time::$user_dateformat . ' ' .egw_time::$user_timeformat.':s',
1207
-			'!'.egw_time::$user_dateformat . '*' .egw_time::$user_timeformat.':s',
1208
-			'!'.egw_time::$user_dateformat . '* ' .egw_time::$user_timeformat,
1209
-			'!'.egw_time::$user_dateformat . '*',
1206
+			'!'.egw_time::$user_dateformat.' '.egw_time::$user_timeformat.':s',
1207
+			'!'.egw_time::$user_dateformat.'*'.egw_time::$user_timeformat.':s',
1208
+			'!'.egw_time::$user_dateformat.'* '.egw_time::$user_timeformat,
1209
+			'!'.egw_time::$user_dateformat.'*',
1210 1210
 			'!'.egw_time::$user_dateformat,
1211 1211
 		);
1212 1212
 
1213 1213
 		// Properly format values for spreadsheet
1214
-		foreach($names as $idx => &$field)
1214
+		foreach ($names as $idx => &$field)
1215 1215
 		{
1216 1216
 			$key = '$$'.$field.'$$';
1217 1217
 			$field = preg_quote($field, '/');
1218
-			if($values[$key])
1218
+			if ($values[$key])
1219 1219
 			{
1220
-				if(!is_numeric($values[$key]))
1220
+				if (!is_numeric($values[$key]))
1221 1221
 				{
1222 1222
 					// Try the different formats, stop when one works
1223
-					foreach($formats as $f)
1223
+					foreach ($formats as $f)
1224 1224
 					{
1225 1225
 						try {
1226 1226
 							$date = egw_time::createFromFormat(
@@ -1228,12 +1228,12 @@  discard block
 block discarded – undo
1228 1228
 								$values[$key],
1229 1229
 								egw_time::$user_timezone
1230 1230
 							);
1231
-							if($date) break;
1231
+							if ($date) break;
1232 1232
 						} catch (Exception $e) {
1233 1233
 
1234 1234
 						}
1235 1235
 					}
1236
-					if(!$date)
1236
+					if (!$date)
1237 1237
 					{
1238 1238
 						// Couldn't get a date out of it... skip it
1239 1239
 						trigger_error("Unable to parse date $key = '{$values[$key]}' - left as text", E_USER_NOTICE);
@@ -1245,16 +1245,16 @@  discard block
 block discarded – undo
1245 1245
 				{
1246 1246
 					$date = new egw_time($values[$key]);
1247 1247
 				}
1248
-				if($mimetype == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')//Excel WTF
1248
+				if ($mimetype == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')//Excel WTF
1249 1249
 				{
1250 1250
 					$interval = $date->diff(new egw_time('1900-01-00 0:00'));
1251
-					$values[$key] = $interval->format('%a')+1;// 1900-02-29 did not exist
1251
+					$values[$key] = $interval->format('%a') + 1; // 1900-02-29 did not exist
1252 1252
 					// 1440 minutes in a day - fractional part
1253
-					$values[$key] += ($date->format('H') * 60 + $date->format('i'))/1440;
1253
+					$values[$key] += ($date->format('H') * 60 + $date->format('i')) / 1440;
1254 1254
 				}
1255 1255
 				else
1256 1256
 				{
1257
-					$values[$key] = date('Y-m-d\TH:i:s',egw_time::to($date,'ts'));
1257
+					$values[$key] = date('Y-m-d\TH:i:s', egw_time::to($date, 'ts'));
1258 1258
 				}
1259 1259
 			}
1260 1260
 			else
@@ -1263,33 +1263,33 @@  discard block
 block discarded – undo
1263 1263
 			}
1264 1264
 		}
1265 1265
 
1266
-		switch($mimetype)
1266
+		switch ($mimetype)
1267 1267
 		{
1268 1268
 			case 'application/vnd.oasis.opendocument.spreadsheet':		// open office calc
1269 1269
 				// Removing these forces calc to respect our set value-type
1270
-				$content = str_ireplace('calcext:value-type="string"','',$content);
1270
+				$content = str_ireplace('calcext:value-type="string"', '', $content);
1271 1271
 
1272
-				$format = '/<table:table-cell([^>]+?)office:value-type="[^"]+"([^>]*?)>.?<([a-z].*?)[^>]*>\$\$('.implode('|',$names).')\$\$<\/\3>.?<\/table:table-cell>/s';
1272
+				$format = '/<table:table-cell([^>]+?)office:value-type="[^"]+"([^>]*?)>.?<([a-z].*?)[^>]*>\$\$('.implode('|', $names).')\$\$<\/\3>.?<\/table:table-cell>/s';
1273 1273
 				$replacement = '<table:table-cell$1office:value-type="date" office:date-value="\$\$$4\$\$"$2><$3>\$\$$4\$\$</$3></table:table-cell>';
1274 1274
 				break;
1275 1275
 			case 'application/xmlExcel.Sheet':	// Excel 2003
1276
-				$format = '/'.preg_quote('<Data ss:Type="String">','/').'..('.implode('|',$names).')..'.preg_quote('</Data>','/').'/';
1276
+				$format = '/'.preg_quote('<Data ss:Type="String">', '/').'..('.implode('|', $names).')..'.preg_quote('</Data>', '/').'/';
1277 1277
 				$replacement = '<Data ss:Type="DateTime">\$\$$1\$\$</Data>';
1278 1278
 
1279 1279
 				break;
1280 1280
 			case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
1281 1281
 				break;
1282 1282
 		}
1283
-		if($format && $names)
1283
+		if ($format && $names)
1284 1284
 		{
1285 1285
 			// Dealing with backtrack limit per AmigoJack 10-Jul-2010 comment on php.net preg-replace docs
1286 1286
 			do {
1287 1287
 				$result = preg_replace($format, $replacement, $content, -1);
1288 1288
 			}
1289 1289
 			// try to increase/double pcre.backtrack_limit failure
1290
-			while(preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR && self::increase_backtrack_limit());
1290
+			while (preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR && self::increase_backtrack_limit());
1291 1291
 
1292
-			if ($result) $content = $result;  // On failure $result would be NULL
1292
+			if ($result) $content = $result; // On failure $result would be NULL
1293 1293
 		}
1294 1294
 	}
1295 1295
 
@@ -1299,9 +1299,9 @@  discard block
 block discarded – undo
1299 1299
 	 */
1300 1300
 	public function cf_link_to_expand($values, $content, &$replacements, $app = null)
1301 1301
 	{
1302
-		if($app == null)
1302
+		if ($app == null)
1303 1303
 		{
1304
-			$app = str_replace('_merge','',get_class($this));
1304
+			$app = str_replace('_merge', '', get_class($this));
1305 1305
 		}
1306 1306
 		$cfs = config::get_customfields($app);
1307 1307
 
@@ -1313,11 +1313,11 @@  discard block
 block discarded – undo
1313 1313
 		preg_match_all('/\${2}(([^\/#]*?\/)?)#([^$\/]+)\/(.*?)[$}]{2}/', $content, $matches);
1314 1314
 		list($placeholders, $prefixes, $pre, $cf, $sub) = $matches;
1315 1315
 
1316
-		foreach($cf as $index => $field)
1316
+		foreach ($cf as $index => $field)
1317 1317
 		{
1318
-			if($cfs[$field])
1318
+			if ($cfs[$field])
1319 1319
 			{
1320
-				if(in_array($cfs[$field]['type'],array_keys($GLOBALS['egw_info']['apps'])))
1320
+				if (in_array($cfs[$field]['type'], array_keys($GLOBALS['egw_info']['apps'])))
1321 1321
 				{
1322 1322
 					$field_app = $cfs[$field]['type'];
1323 1323
 				}
@@ -1328,7 +1328,7 @@  discard block
 block discarded – undo
1328 1328
 					$account = $GLOBALS['egw']->accounts->read($values['#'.$field]);
1329 1329
 					$app_replacements[$field] = $this->contact_replacements($account['person_id']);
1330 1330
 				}
1331
-				else if ($list = explode('-',$cfs[$field]['type']) && in_array($list[0], array_keys($GLOBALS['egw_info']['apps'])))
1331
+				else if ($list = explode('-', $cfs[$field]['type']) && in_array($list[0], array_keys($GLOBALS['egw_info']['apps'])))
1332 1332
 				{
1333 1333
 					// Sub-type - use app
1334 1334
 					$field_app = $list[0];
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
 				}
1340 1340
 
1341 1341
 				// Get replacements for that application
1342
-				if(!$app_replacements[$field])
1342
+				if (!$app_replacements[$field])
1343 1343
 				{
1344 1344
 					$classname = "{$field_app}_merge";
1345 1345
 					$class = new $classname();
@@ -1367,33 +1367,33 @@  discard block
 block discarded – undo
1367 1367
 	 */
1368 1368
 	private function process_commands($content, $replacements)
1369 1369
 	{
1370
-		if (strpos($content,'$$IF') !== false)
1370
+		if (strpos($content, '$$IF') !== false)
1371 1371
 		{	//Example use to use: $$IF n_prefix~Herr~Sehr geehrter~Sehr geehrte$$
1372
-			$this->replacements =& $replacements;
1373
-			$content = preg_replace_callback('/\$\$IF ([#0-9a-z_\/-]+)~(.*)~(.*)~(.*)\$\$/imU',Array($this,'replace_callback'),$content);
1372
+			$this->replacements = & $replacements;
1373
+			$content = preg_replace_callback('/\$\$IF ([#0-9a-z_\/-]+)~(.*)~(.*)~(.*)\$\$/imU', Array($this, 'replace_callback'), $content);
1374 1374
 			unset($this->replacements);
1375 1375
 		}
1376
-		if (strpos($content,'$$NELF') !== false)
1376
+		if (strpos($content, '$$NELF') !== false)
1377 1377
 		{	//Example: $$NEPBR org_unit$$ sets a LF and value of org_unit, only if there is a value
1378
-			$this->replacements =& $replacements;
1379
-			$content = preg_replace_callback('/\$\$NELF ([#0-9a-z_\/-]+)\$\$/imU',Array($this,'replace_callback'),$content);
1378
+			$this->replacements = & $replacements;
1379
+			$content = preg_replace_callback('/\$\$NELF ([#0-9a-z_\/-]+)\$\$/imU', Array($this, 'replace_callback'), $content);
1380 1380
 			unset($this->replacements);
1381 1381
 		}
1382
-		if (strpos($content,'$$NENVLF') !== false)
1382
+		if (strpos($content, '$$NENVLF') !== false)
1383 1383
 		{	//Example: $$NEPBRNV org_unit$$ sets only a LF if there is a value for org_units, but did not add any value
1384
-			$this->replacements =& $replacements;
1385
-			$content = preg_replace_callback('/\$\$NENVLF ([#0-9a-z_\/-]+)\$\$/imU',Array($this,'replace_callback'),$content);
1384
+			$this->replacements = & $replacements;
1385
+			$content = preg_replace_callback('/\$\$NENVLF ([#0-9a-z_\/-]+)\$\$/imU', Array($this, 'replace_callback'), $content);
1386 1386
 			unset($this->replacements);
1387 1387
 		}
1388
-		if (strpos($content,'$$LETTERPREFIX$$') !== false)
1388
+		if (strpos($content, '$$LETTERPREFIX$$') !== false)
1389 1389
 		{	//Example use to use: $$LETTERPREFIX$$
1390 1390
 			$LETTERPREFIXCUSTOM = '$$LETTERPREFIXCUSTOM n_prefix title n_family$$';
1391
-			$content = str_replace('$$LETTERPREFIX$$',$LETTERPREFIXCUSTOM,$content);
1391
+			$content = str_replace('$$LETTERPREFIX$$', $LETTERPREFIXCUSTOM, $content);
1392 1392
 		}
1393
-		if (strpos($content,'$$LETTERPREFIXCUSTOM') !== false)
1393
+		if (strpos($content, '$$LETTERPREFIXCUSTOM') !== false)
1394 1394
 		{	//Example use to use for a custom Letter Prefix: $$LETTERPREFIX n_prefix title n_family$$
1395
-			$this->replacements =& $replacements;
1396
-			$content = preg_replace_callback('/\$\$LETTERPREFIXCUSTOM ([#0-9a-z_-]+)(.*)\$\$/imU',Array($this,'replace_callback'),$content);
1395
+			$this->replacements = & $replacements;
1396
+			$content = preg_replace_callback('/\$\$LETTERPREFIXCUSTOM ([#0-9a-z_-]+)(.*)\$\$/imU', Array($this, 'replace_callback'), $content);
1397 1397
 			unset($this->replacements);
1398 1398
 		}
1399 1399
 		return $content;
@@ -1407,16 +1407,16 @@  discard block
 block discarded – undo
1407 1407
 	 */
1408 1408
 	private function replace_callback($param)
1409 1409
 	{
1410
-		if (array_key_exists('$$'.$param[4].'$$',$this->replacements)) $param[4] = $this->replacements['$$'.$param[4].'$$'];
1411
-		if (array_key_exists('$$'.$param[3].'$$',$this->replacements)) $param[3] = $this->replacements['$$'.$param[3].'$$'];
1410
+		if (array_key_exists('$$'.$param[4].'$$', $this->replacements)) $param[4] = $this->replacements['$$'.$param[4].'$$'];
1411
+		if (array_key_exists('$$'.$param[3].'$$', $this->replacements)) $param[3] = $this->replacements['$$'.$param[3].'$$'];
1412 1412
 		
1413 1413
 		$pattern = '/'.preg_quote($param[2], '/').'/';
1414
-		if (strpos($param[0],'$$IF') === 0 && (trim($param[2]) == "EMPTY" || $param[2] === ''))
1414
+		if (strpos($param[0], '$$IF') === 0 && (trim($param[2]) == "EMPTY" || $param[2] === ''))
1415 1415
 		{
1416 1416
 			$pattern = '/^$/';
1417 1417
 		}
1418
-		$replace = preg_match($pattern,$this->replacements['$$'.$param[1].'$$']) ? $param[3] : $param[4];
1419
-		switch($this->mimetype)
1418
+		$replace = preg_match($pattern, $this->replacements['$$'.$param[1].'$$']) ? $param[3] : $param[4];
1419
+		switch ($this->mimetype)
1420 1420
 		{
1421 1421
 			case 'application/vnd.oasis.opendocument.text':		// open office
1422 1422
 			case 'application/vnd.oasis.opendocument.spreadsheet':
@@ -1429,14 +1429,14 @@  discard block
 block discarded – undo
1429 1429
 				break;
1430 1430
 		}
1431 1431
 
1432
-		switch($this->mimetype)
1432
+		switch ($this->mimetype)
1433 1433
 			{
1434 1434
 				case 'application/rtf':
1435 1435
 				case 'text/rtf':
1436 1436
 					$LF = '}\par \pard\plain{';
1437 1437
 					break;
1438 1438
 				case 'application/vnd.oasis.opendocument.text':
1439
-					$LF ='<text:line-break/>';
1439
+					$LF = '<text:line-break/>';
1440 1440
 					break;
1441 1441
 				case 'application/vnd.oasis.opendocument.spreadsheet':		// open office calc
1442 1442
 					$LF = '</text:p><text:p>';
@@ -1446,35 +1446,35 @@  discard block
 block discarded – undo
1446 1446
 					break;
1447 1447
 				case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
1448 1448
 				case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
1449
-					$LF ='</w:t></w:r></w:p><w:p><w:r><w:t>';
1449
+					$LF = '</w:t></w:r></w:p><w:p><w:r><w:t>';
1450 1450
 					break;
1451 1451
 				case 'application/xml';
1452
-					$LF ='</w:t></w:r><w:r><w:br w:type="text-wrapping" w:clear="all"/></w:r><w:r><w:t>';
1452
+					$LF = '</w:t></w:r><w:r><w:br w:type="text-wrapping" w:clear="all"/></w:r><w:r><w:t>';
1453 1453
 					break;
1454 1454
 				default:
1455 1455
 					$LF = "\n";
1456 1456
 			}
1457
-		if($is_xml) {
1458
-			$this->replacements = str_replace(array('&','&amp;amp;','<','>',"\r","\n"),array('&amp;','&amp;','&lt;','&gt;','',$LF),$this->replacements);
1457
+		if ($is_xml) {
1458
+			$this->replacements = str_replace(array('&', '&amp;amp;', '<', '>', "\r", "\n"), array('&amp;', '&amp;', '&lt;', '&gt;', '', $LF), $this->replacements);
1459 1459
 		}
1460
-		if (strpos($param[0],'$$NELF') === 0)
1460
+		if (strpos($param[0], '$$NELF') === 0)
1461 1461
 		{	//sets a Pagebreak and value, only if the field has a value
1462
-			if ($this->replacements['$$'.$param[1].'$$'] !='') $replace = $LF.$this->replacements['$$'.$param[1].'$$'];
1462
+			if ($this->replacements['$$'.$param[1].'$$'] != '') $replace = $LF.$this->replacements['$$'.$param[1].'$$'];
1463 1463
 		}
1464
-		if (strpos($param[0],'$$NENVLF') === 0)
1464
+		if (strpos($param[0], '$$NENVLF') === 0)
1465 1465
 		{	//sets a Pagebreak without any value, only if the field has a value
1466
-			if ($this->replacements['$$'.$param[1].'$$'] !='') $replace = $LF;
1466
+			if ($this->replacements['$$'.$param[1].'$$'] != '') $replace = $LF;
1467 1467
 		}
1468
-		if (strpos($param[0],'$$LETTERPREFIXCUSTOM') === 0)
1468
+		if (strpos($param[0], '$$LETTERPREFIXCUSTOM') === 0)
1469 1469
 		{	//sets a Letterprefix
1470 1470
 			$replaceprefixsort = array();
1471 1471
 			// ToDo Stefan: $contentstart is NOT defined here!!!
1472
-			$replaceprefix = explode(' ',substr($param[0],21,-2));
1472
+			$replaceprefix = explode(' ', substr($param[0], 21, -2));
1473 1473
 			foreach ($replaceprefix as $key => $nameprefix)
1474 1474
 			{
1475
-				if ($this->replacements['$$'.$nameprefix.'$$'] !='') $replaceprefixsort[] = $this->replacements['$$'.$nameprefix.'$$'];
1475
+				if ($this->replacements['$$'.$nameprefix.'$$'] != '') $replaceprefixsort[] = $this->replacements['$$'.$nameprefix.'$$'];
1476 1476
 			}
1477
-			$replace = implode($replaceprefixsort,' ');
1477
+			$replace = implode($replaceprefixsort, ' ');
1478 1478
 		}
1479 1479
 		return $replace;
1480 1480
 	}
@@ -1488,7 +1488,7 @@  discard block
 block discarded – undo
1488 1488
 	 * @param string $dirs comma or whitespace separated directories, used if $document is a relative path
1489 1489
 	 * @return string with error-message on error, otherwise it does NOT return
1490 1490
 	 */
1491
-	public function download($document, $ids, $name='', $dirs='')
1491
+	public function download($document, $ids, $name = '', $dirs = '')
1492 1492
 	{
1493 1493
 		//error_log(__METHOD__."('$document', ".array2string($ids).", '$name', dirs='$dirs') ->".function_backtrace());
1494 1494
 		if (($error = $this->check_document($document, $dirs)))
@@ -1504,7 +1504,7 @@  discard block
 block discarded – undo
1504 1504
 				$mail_bo->openConnection();
1505 1505
 				try
1506 1506
 				{
1507
-					$msgs = $mail_bo->importMessageToMergeAndSend($this, $content_url, $ids, $_folder='', $importID='');
1507
+					$msgs = $mail_bo->importMessageToMergeAndSend($this, $content_url, $ids, $_folder = '', $importID = '');
1508 1508
 				}
1509 1509
 				catch (egw_exception_wrong_userinput $e)
1510 1510
 				{
@@ -1513,39 +1513,39 @@  discard block
 block discarded – undo
1513 1513
 				}
1514 1514
 				//error_log(__METHOD__.__LINE__.' Message after importMessageToMergeAndSend:'.array2string($msgs));
1515 1515
 				$retString = '';
1516
-				if (count($msgs['success'])>0) $retString .= count($msgs['success']).' '.(count($msgs['success'])+count($msgs['failed'])==1?lang('Message prepared for sending.'):lang('Message(s) send ok.'));//implode('<br />',$msgs['success']);
1516
+				if (count($msgs['success']) > 0) $retString .= count($msgs['success']).' '.(count($msgs['success']) + count($msgs['failed']) == 1 ? lang('Message prepared for sending.') : lang('Message(s) send ok.')); //implode('<br />',$msgs['success']);
1517 1517
 				//if (strlen($retString)>0) $retString .= '<br />';
1518
-				foreach($msgs['failed'] as $c =>$e)
1518
+				foreach ($msgs['failed'] as $c =>$e)
1519 1519
 				{
1520 1520
 					$errorString .= lang('contact').' '.lang('id').':'.$c.'->'.$e.'.';
1521 1521
 				}
1522
-				if (count($msgs['failed'])>0) $retString .= count($msgs['failed']).' '.lang('Message(s) send failed!').'=>'.$errorString;
1522
+				if (count($msgs['failed']) > 0) $retString .= count($msgs['failed']).' '.lang('Message(s) send failed!').'=>'.$errorString;
1523 1523
 				return $retString;
1524 1524
 				break;
1525 1525
 			case 'application/vnd.oasis.opendocument.text':
1526 1526
 			case 'application/vnd.oasis.opendocument.spreadsheet':
1527 1527
 				$ext = $mimetype == 'application/vnd.oasis.opendocument.text' ? '.odt' : '.ods';
1528
-				$archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($document,$ext).'-').$ext;
1529
-				copy($content_url,$archive);
1528
+				$archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($document, $ext).'-').$ext;
1529
+				copy($content_url, $archive);
1530 1530
 				$content_url = 'zip://'.$archive.'#'.($content_file = 'content.xml');
1531 1531
 				break;
1532 1532
 			case 'application/vnd.openxmlformats-officedocument.wordprocessingml.d':	// mimetypes in vfs are limited to 64 chars
1533 1533
 				$mimetype = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
1534 1534
 			case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
1535
-				$archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($document,'.docx').'-').'.docx';
1536
-				copy($content_url,$archive);
1535
+				$archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($document, '.docx').'-').'.docx';
1536
+				copy($content_url, $archive);
1537 1537
 				$content_url = 'zip://'.$archive.'#'.($content_file = 'word/document.xml');
1538 1538
 				$fix = array(		// regular expression to fix garbled placeholders
1539
-					'/'.preg_quote('$$</w:t></w:r><w:proofErr w:type="spellStart"/><w:r><w:t>','/').'([a-z0-9_]+)'.
1540
-						preg_quote('</w:t></w:r><w:proofErr w:type="spellEnd"/><w:r><w:t>','/').'/i' => '$$\\1$$',
1541
-					'/'.preg_quote('$$</w:t></w:r><w:proofErr w:type="spellStart"/><w:r><w:rPr><w:lang w:val="','/').
1542
-						'([a-z]{2}-[A-Z]{2})'.preg_quote('"/></w:rPr><w:t>','/').'([a-z0-9_]+)'.
1543
-						preg_quote('</w:t></w:r><w:proofErr w:type="spellEnd"/><w:r><w:rPr><w:lang w:val="','/').
1544
-						'([a-z]{2}-[A-Z]{2})'.preg_quote('"/></w:rPr><w:t>$$','/').'/i' => '$$\\2$$',
1545
-					'/'.preg_quote('$</w:t></w:r><w:proofErr w:type="spellStart"/><w:r><w:t>','/').'([a-z0-9_]+)'.
1546
-						preg_quote('</w:t></w:r><w:proofErr w:type="spellEnd"/><w:r><w:t>','/').'/i' => '$\\1$',
1547
-					'/'.preg_quote('$ $</w:t></w:r><w:proofErr w:type="spellStart"/><w:r><w:t>','/').'([a-z0-9_]+)'.
1548
-						preg_quote('</w:t></w:r><w:proofErr w:type="spellEnd"/><w:r><w:t>','/').'/i' => '$ $\\1$ $',
1539
+					'/'.preg_quote('$$</w:t></w:r><w:proofErr w:type="spellStart"/><w:r><w:t>', '/').'([a-z0-9_]+)'.
1540
+						preg_quote('</w:t></w:r><w:proofErr w:type="spellEnd"/><w:r><w:t>', '/').'/i' => '$$\\1$$',
1541
+					'/'.preg_quote('$$</w:t></w:r><w:proofErr w:type="spellStart"/><w:r><w:rPr><w:lang w:val="', '/').
1542
+						'([a-z]{2}-[A-Z]{2})'.preg_quote('"/></w:rPr><w:t>', '/').'([a-z0-9_]+)'.
1543
+						preg_quote('</w:t></w:r><w:proofErr w:type="spellEnd"/><w:r><w:rPr><w:lang w:val="', '/').
1544
+						'([a-z]{2}-[A-Z]{2})'.preg_quote('"/></w:rPr><w:t>$$', '/').'/i' => '$$\\2$$',
1545
+					'/'.preg_quote('$</w:t></w:r><w:proofErr w:type="spellStart"/><w:r><w:t>', '/').'([a-z0-9_]+)'.
1546
+						preg_quote('</w:t></w:r><w:proofErr w:type="spellEnd"/><w:r><w:t>', '/').'/i' => '$\\1$',
1547
+					'/'.preg_quote('$ $</w:t></w:r><w:proofErr w:type="spellStart"/><w:r><w:t>', '/').'([a-z0-9_]+)'.
1548
+						preg_quote('</w:t></w:r><w:proofErr w:type="spellEnd"/><w:r><w:t>', '/').'/i' => '$ $\\1$ $',
1549 1549
 				);
1550 1550
 				break;
1551 1551
 			case 'application/xml':
@@ -1559,12 +1559,12 @@  discard block
 block discarded – undo
1559 1559
 				$fix = array(	// hack to get Excel 2007 to display additional rows in tables
1560 1560
 					'/ss:ExpandedRowCount="\d+"/' => 'ss:ExpandedRowCount="9999"',
1561 1561
 				);
1562
-				$archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($document,'.xlsx').'-').'.xlsx';
1563
-				copy($content_url,$archive);
1562
+				$archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($document, '.xlsx').'-').'.xlsx';
1563
+				copy($content_url, $archive);
1564 1564
 				$content_url = 'zip://'.$archive.'#'.($content_file = 'xl/sharedStrings.xml');
1565 1565
 				break;
1566 1566
 		}
1567
-		if (!($merged =& $this->merge($content_url,$ids,$err,$mimetype,$fix)))
1567
+		if (!($merged = & $this->merge($content_url, $ids, $err, $mimetype, $fix)))
1568 1568
 		{
1569 1569
 			//error_log(__METHOD__."() !this->merge() err=$err");
1570 1570
 			return $err;
@@ -1581,22 +1581,22 @@  discard block
 block discarded – undo
1581 1581
 			{
1582 1582
 				// Error converting HTML styles over
1583 1583
 				error_log($e->getMessage());
1584
-				error_log("Target document: $content_url, IDs: ". array2string($ids));
1584
+				error_log("Target document: $content_url, IDs: ".array2string($ids));
1585 1585
 
1586 1586
 				// Try again, but strip HTML so user gets something
1587 1587
 				$this->parse_html_styles = false;
1588
-				if (!($merged =& $this->merge($content_url,$ids,$err,$mimetype,$fix)))
1588
+				if (!($merged = & $this->merge($content_url, $ids, $err, $mimetype, $fix)))
1589 1589
 				{
1590 1590
 					return $err;
1591 1591
 				}
1592 1592
 			}
1593 1593
 			if ($this->report_memory_usage) error_log(__METHOD__."() after HTML processing ".egw_vfs::hsize(memory_get_peak_usage(true)));
1594 1594
 		}
1595
-		if(!empty($name))
1595
+		if (!empty($name))
1596 1596
 		{
1597
-			if(empty($ext))
1597
+			if (empty($ext))
1598 1598
 			{
1599
-				$ext = '.'.pathinfo($document,PATHINFO_EXTENSION);
1599
+				$ext = '.'.pathinfo($document, PATHINFO_EXTENSION);
1600 1600
 			}
1601 1601
 			$name .= $ext;
1602 1602
 		}
@@ -1607,38 +1607,38 @@  discard block
 block discarded – undo
1607 1607
 		if (isset($archive))
1608 1608
 		{
1609 1609
 			$zip = new ZipArchive;
1610
-			if ($zip->open($archive,ZIPARCHIVE::CHECKCONS) !== true)
1610
+			if ($zip->open($archive, ZIPARCHIVE::CHECKCONS) !== true)
1611 1611
 			{
1612 1612
 				error_log(__METHOD__.__LINE__." !ZipArchive::open('$archive',ZIPARCHIVE::CHECKCONS) failed. Trying open without validating");
1613 1613
 				if ($zip->open($archive) !== true) throw new Exception("!ZipArchive::open('$archive',|ZIPARCHIVE::CHECKCONS)");
1614 1614
 			}
1615
-			if ($zip->addFromString($content_file,$merged) !== true) throw new Exception("!ZipArchive::addFromString('$content_file',\$merged)");
1615
+			if ($zip->addFromString($content_file, $merged) !== true) throw new Exception("!ZipArchive::addFromString('$content_file',\$merged)");
1616 1616
 			if ($zip->close() !== true) throw new Exception("!ZipArchive::close()");
1617 1617
 			unset($zip);
1618 1618
 			unset($merged);
1619
-			if (substr($mimetype,0,35) == 'application/vnd.oasis.opendocument.' && 			// only open office archives need that, ms word files brake
1620
-				file_exists('/usr/bin/zip') && version_compare(PHP_VERSION,'5.3.1','<'))	// fix broken zip archives generated by current php
1619
+			if (substr($mimetype, 0, 35) == 'application/vnd.oasis.opendocument.' && // only open office archives need that, ms word files brake
1620
+				file_exists('/usr/bin/zip') && version_compare(PHP_VERSION, '5.3.1', '<'))	// fix broken zip archives generated by current php
1621 1621
 			{
1622 1622
 				exec('/usr/bin/zip -F '.escapeshellarg($archive));
1623 1623
 			}
1624 1624
 			if ($this->report_memory_usage) error_log(__METHOD__."() after ZIP processing ".egw_vfs::hsize(memory_get_peak_usage(true)));
1625
-			html::content_header($name,$mimetype,filesize($archive));
1626
-			readfile($archive,'r');
1625
+			html::content_header($name, $mimetype, filesize($archive));
1626
+			readfile($archive, 'r');
1627 1627
 		}
1628 1628
 		else
1629 1629
 		{
1630 1630
 			if ($mimetype == 'application/xml')
1631 1631
 			{
1632
-				if (strpos($merged,'<?mso-application progid="Word.Document"?>') !== false)
1632
+				if (strpos($merged, '<?mso-application progid="Word.Document"?>') !== false)
1633 1633
 				{
1634
-					$mimetype = 'application/msword';	// to open it automatically in word or oowriter
1634
+					$mimetype = 'application/msword'; // to open it automatically in word or oowriter
1635 1635
 				}
1636
-				elseif (strpos($merged,'<?mso-application progid="Excel.Sheet"?>') !== false)
1636
+				elseif (strpos($merged, '<?mso-application progid="Excel.Sheet"?>') !== false)
1637 1637
 				{
1638
-					$mimetype = 'application/vnd.ms-excel';	// to open it automatically in excel or oocalc
1638
+					$mimetype = 'application/vnd.ms-excel'; // to open it automatically in excel or oocalc
1639 1639
 				}
1640 1640
 			}
1641
-			html::content_header($name,$mimetype);
1641
+			html::content_header($name, $mimetype);
1642 1642
 			echo $merged;
1643 1643
 		}
1644 1644
 		common::egw_exit();
@@ -1656,13 +1656,13 @@  discard block
 block discarded – undo
1656 1656
 	 */
1657 1657
 	public function download_by_request()
1658 1658
 	{
1659
-		if(empty($_POST['data_document_name'])) return false;
1660
-		if(empty($_POST['data_document_dir'])) return false;
1661
-		if(empty($_POST['data_checked'])) return false;
1659
+		if (empty($_POST['data_document_name'])) return false;
1660
+		if (empty($_POST['data_document_dir'])) return false;
1661
+		if (empty($_POST['data_checked'])) return false;
1662 1662
 
1663 1663
 		return $this->download(
1664 1664
 			$_POST['data_document_name'],
1665
-			explode(',',$_POST['data_checked']),
1665
+			explode(',', $_POST['data_checked']),
1666 1666
 			'',
1667 1667
 			$_POST['data_document_dir']
1668 1668
 		);
@@ -1676,16 +1676,16 @@  discard block
 block discarded – undo
1676 1676
 	 * @param array|string $mime_filter=null allowed mime type(s), default all, negative filter if $mime_filter[0] === '!'
1677 1677
 	 * @return array List of documents, suitable for a selectbox.  The key is document_<filename>.
1678 1678
 	 */
1679
-	public static function get_documents($dirs, $prefix='document_', $mime_filter=null, $app='')
1679
+	public static function get_documents($dirs, $prefix = 'document_', $mime_filter = null, $app = '')
1680 1680
 	{
1681
-		$export_limit=self::getExportLimit($app);
1682
-		if (!$dirs || (!self::hasExportLimit($export_limit,'ISALLOWED') && !self::is_export_limit_excepted())) return array();
1681
+		$export_limit = self::getExportLimit($app);
1682
+		if (!$dirs || (!self::hasExportLimit($export_limit, 'ISALLOWED') && !self::is_export_limit_excepted())) return array();
1683 1683
 
1684 1684
 		// split multiple comma or whitespace separated directories
1685 1685
 		// to still allow space or comma in dirnames, we also use the trailing slash of all pathes to split
1686 1686
 		if (count($dirs = preg_split('/[,\s]+\//', $dirs)) > 1)
1687 1687
 		{
1688
-			foreach($dirs as $n => &$d) if ($n) $d = '/'.$d;	// re-adding trailing slash removed by split
1688
+			foreach ($dirs as $n => &$d) if ($n) $d = '/'.$d; // re-adding trailing slash removed by split
1689 1689
 		}
1690 1690
 		if ($mime_filter && ($negativ_filter = $mime_filter[0] === '!'))
1691 1691
 		{
@@ -1699,15 +1699,15 @@  discard block
 block discarded – undo
1699 1699
 			}
1700 1700
 		}
1701 1701
 		$list = array();
1702
-		foreach($dirs as $dir)
1702
+		foreach ($dirs as $dir)
1703 1703
 		{
1704
-			if (($files = egw_vfs::find($dir,array('need_mime'=>true),true)))
1704
+			if (($files = egw_vfs::find($dir, array('need_mime'=>true), true)))
1705 1705
 			{
1706
-				foreach($files as $file)
1706
+				foreach ($files as $file)
1707 1707
 				{
1708 1708
 					// return only the mime-types we support
1709
-					$parts = explode('.',$file['name']);
1710
-					if (!self::is_implemented($file['mime'],'.'.array_pop($parts))) continue;
1709
+					$parts = explode('.', $file['name']);
1710
+					if (!self::is_implemented($file['mime'], '.'.array_pop($parts))) continue;
1711 1711
 					if ($mime_filter && $negativ_filter === in_array($file['mime'], (array)$mime_filter)) continue;
1712 1712
 					$list[$prefix.$file['name']] = egw_vfs::decodePath($file['name']);
1713 1713
 				}
@@ -1734,14 +1734,14 @@  discard block
 block discarded – undo
1734 1734
 	 * @param int|string $export_limit=null export-limit, default $GLOBALS['egw_info']['server']['export_limit']
1735 1735
 	 * @return array see nextmatch_widget::egw_actions
1736 1736
 	 */
1737
-	public static function document_action($dirs, $group=0, $caption='Insert in document', $prefix='document_', $default_doc='',
1738
-		$export_limit=null)
1737
+	public static function document_action($dirs, $group = 0, $caption = 'Insert in document', $prefix = 'document_', $default_doc = '',
1738
+		$export_limit = null)
1739 1739
 	{
1740 1740
 		$documents = array();
1741 1741
 		if ($export_limit == null) $export_limit = self::getExportLimit(); // check if there is a globalsetting
1742 1742
 		if ($default_doc && ($file = egw_vfs::stat($default_doc)))	// put default document on top
1743 1743
 		{
1744
-			if(!$file['mime'])
1744
+			if (!$file['mime'])
1745 1745
 			{
1746 1746
 				$file['mime'] = egw_vfs::mime_content_type($default_doc);
1747 1747
 				$file['path'] = $default_doc;
@@ -1750,7 +1750,7 @@  discard block
 block discarded – undo
1750 1750
 				'icon' => egw_vfs::mime_icon($file['mime']),
1751 1751
 				'caption' => egw_vfs::decodePath(egw_vfs::basename($default_doc)),
1752 1752
 				'group' => 1,
1753
-				'postSubmit' => true,	// download needs post submit (not Ajax) to work
1753
+				'postSubmit' => true, // download needs post submit (not Ajax) to work
1754 1754
 			);
1755 1755
 			if ($file['mime'] == 'message/rfc822')
1756 1756
 			{
@@ -1765,25 +1765,25 @@  discard block
 block discarded – undo
1765 1765
 			// to still allow space or comma in dirnames, we also use the trailing slash of all pathes to split
1766 1766
 			if (count($dirs = preg_split('/[,\s]+\//', $dirs)) > 1)
1767 1767
 			{
1768
-				foreach($dirs as $n => &$d) if ($n) $d = '/'.$d;	// re-adding trailing slash removed by split
1768
+				foreach ($dirs as $n => &$d) if ($n) $d = '/'.$d; // re-adding trailing slash removed by split
1769 1769
 			}
1770
-			foreach($dirs as $dir)
1770
+			foreach ($dirs as $dir)
1771 1771
 			{
1772
-				$files += egw_vfs::find($dir,array(
1772
+				$files += egw_vfs::find($dir, array(
1773 1773
 					'need_mime' => true,
1774 1774
 					'order' => 'fs_name',
1775 1775
 					'sort' => 'ASC',
1776
-				),true);
1776
+				), true);
1777 1777
 			}
1778 1778
 		}
1779 1779
 
1780 1780
 		$dircount = array();
1781
-		foreach($files as $key => $file)
1781
+		foreach ($files as $key => $file)
1782 1782
 		{
1783 1783
 			// use only the mime-types we support
1784
-			$parts = explode('.',$file['name']);
1785
-			if (!self::is_implemented($file['mime'],'.'.array_pop($parts)) ||
1786
-				!egw_vfs::check_access($file['path'], egw_vfs::READABLE, $file) ||	// remove files not readable by user
1784
+			$parts = explode('.', $file['name']);
1785
+			if (!self::is_implemented($file['mime'], '.'.array_pop($parts)) ||
1786
+				!egw_vfs::check_access($file['path'], egw_vfs::READABLE, $file) || // remove files not readable by user
1787 1787
 				$file['path'] === $default_doc)	// default doc already added
1788 1788
 			{
1789 1789
 				unset($files[$key]);
@@ -1791,40 +1791,40 @@  discard block
 block discarded – undo
1791 1791
 			else
1792 1792
 			{
1793 1793
 				$dirname = egw_vfs::dirname($file['path']);
1794
-				if(!isset($dircount[$dirname]))
1794
+				if (!isset($dircount[$dirname]))
1795 1795
 				{
1796 1796
 					$dircount[$dirname] = 1;
1797 1797
 				}
1798 1798
 				else
1799 1799
 				{
1800
-					$dircount[$dirname] ++;
1800
+					$dircount[$dirname]++;
1801 1801
 				}
1802 1802
 			}
1803 1803
 		}
1804
-		foreach($files as $file)
1804
+		foreach ($files as $file)
1805 1805
 		{
1806 1806
 			if (count($dircount) > 1)
1807 1807
 			{
1808 1808
 				$name_arr = explode('/', $file['name']);
1809 1809
 				$current_level = &$documents;
1810
-				for($count = 0; $count < count($name_arr); $count++)
1810
+				for ($count = 0; $count < count($name_arr); $count++)
1811 1811
 				{
1812
-					if($count == 0)
1812
+					if ($count == 0)
1813 1813
 					{
1814 1814
 						$current_level = &$documents;
1815 1815
 					}
1816 1816
 					else
1817 1817
 					{
1818
-						$current_level = &$current_level[$prefix.$name_arr[($count-1)]]['children'];
1818
+						$current_level = &$current_level[$prefix.$name_arr[($count - 1)]]['children'];
1819 1819
 					}
1820
-					switch($count)
1820
+					switch ($count)
1821 1821
 					{
1822
-						case (count($name_arr)-1):
1822
+						case (count($name_arr) - 1):
1823 1823
 							$current_level[$prefix.$file['name']] = array(
1824 1824
 								'icon'		=> egw_vfs::mime_icon($file['mime']),
1825 1825
 								'caption'	=> egw_vfs::decodePath($name_arr[$count]),
1826 1826
 								'group'		=> 2,
1827
-								'postSubmit' => true,	// download needs post submit (not Ajax) to work
1827
+								'postSubmit' => true, // download needs post submit (not Ajax) to work
1828 1828
 							);
1829 1829
 							if ($file['mime'] == 'message/rfc822')
1830 1830
 							{
@@ -1833,7 +1833,7 @@  discard block
 block discarded – undo
1833 1833
 							break;
1834 1834
 
1835 1835
 						default:
1836
-							if(!is_array($current_level[$prefix.$name_arr[$count]]))
1836
+							if (!is_array($current_level[$prefix.$name_arr[$count]]))
1837 1837
 							{
1838 1838
 								// create parent folder
1839 1839
 								$current_level[$prefix.$name_arr[$count]] = array(
@@ -1860,7 +1860,7 @@  discard block
 block discarded – undo
1860 1860
 				}
1861 1861
 				$documents[$file['mime']]['children'][$prefix.$file['name']] = array(
1862 1862
 					'caption' => egw_vfs::decodePath($file['name']),
1863
-					'postSubmit' => true,	// download needs post submit (not Ajax) to work
1863
+					'postSubmit' => true, // download needs post submit (not Ajax) to work
1864 1864
 				);
1865 1865
 				if ($file['mime'] == 'message/rfc822')
1866 1866
 				{
@@ -1873,7 +1873,7 @@  discard block
 block discarded – undo
1873 1873
 					'icon' => egw_vfs::mime_icon($file['mime']),
1874 1874
 					'caption' => egw_vfs::decodePath($file['name']),
1875 1875
 					'group' => 2,
1876
-					'postSubmit' => true,	// download needs post submit (not Ajax) to work
1876
+					'postSubmit' => true, // download needs post submit (not Ajax) to work
1877 1877
 				);
1878 1878
 				if ($file['mime'] == 'message/rfc822')
1879 1879
 				{
@@ -1887,8 +1887,8 @@  discard block
 block discarded – undo
1887 1887
 			'caption' => $caption,
1888 1888
 			'children' => $documents,
1889 1889
 			// disable action if no document or export completly forbidden for non-admins
1890
-			'enabled' => (boolean)$documents && (self::hasExportLimit($export_limit,'ISALLOWED') || self::is_export_limit_excepted()),
1891
-			'hideOnDisabled' => true,	// do not show 'Insert in document', if no documents defined or no export allowed
1890
+			'enabled' => (boolean)$documents && (self::hasExportLimit($export_limit, 'ISALLOWED') || self::is_export_limit_excepted()),
1891
+			'hideOnDisabled' => true, // do not show 'Insert in document', if no documents defined or no export allowed
1892 1892
 			'group' => $group,
1893 1893
 		);
1894 1894
 	}
@@ -1919,14 +1919,14 @@  discard block
 block discarded – undo
1919 1919
 		);
1920 1920
 
1921 1921
 		// egw.open() used if only 1 row selected
1922
-		$action['egw_open'] = 'edit-mail--'.implode('&',$extra);
1923
-		$action['target'] = 'compose_' .$file['path'];
1922
+		$action['egw_open'] = 'edit-mail--'.implode('&', $extra);
1923
+		$action['target'] = 'compose_'.$file['path'];
1924 1924
 
1925 1925
 		// long_task runs menuaction once for each selected row
1926 1926
 		$action['nm_action'] = 'long_task';
1927 1927
 		$action['popup'] = egw_link::get_registry('mail', 'edit_popup');
1928
-		$action['message'] = lang('insert in %1',egw_vfs::decodePath($file['name']));
1929
-		$action['menuaction'] = 'mail.mail_compose.ajax_merge&document='.$file['path'].'&merge='. get_called_class();
1928
+		$action['message'] = lang('insert in %1', egw_vfs::decodePath($file['name']));
1929
+		$action['menuaction'] = 'mail.mail_compose.ajax_merge&document='.$file['path'].'&merge='.get_called_class();
1930 1930
 	}
1931 1931
 
1932 1932
 	/**
@@ -1938,15 +1938,15 @@  discard block
 block discarded – undo
1938 1938
 	 */
1939 1939
 	public static function check_document(&$document, $dirs)
1940 1940
 	{
1941
-		if($document[0] !== '/')
1941
+		if ($document[0] !== '/')
1942 1942
 		{
1943 1943
 			// split multiple comma or whitespace separated directories
1944 1944
 			// to still allow space or comma in dirnames, we also use the trailing slash of all pathes to split
1945 1945
 			if ($dirs && ($dirs = preg_split('/[,\s]+\//', $dirs)))
1946 1946
 			{
1947
-				foreach($dirs as $n => $dir)
1947
+				foreach ($dirs as $n => $dir)
1948 1948
 				{
1949
-					if ($n) $dir = '/'.$dir;	// re-adding trailing slash removed by split
1949
+					if ($n) $dir = '/'.$dir; // re-adding trailing slash removed by split
1950 1950
 					if (egw_vfs::stat($dir.'/'.$document) && egw_vfs::is_readable($dir.'/'.$document))
1951 1951
 					{
1952 1952
 						$document = $dir.'/'.$document;
@@ -1960,7 +1960,7 @@  discard block
 block discarded – undo
1960 1960
 			return false;
1961 1961
 		}
1962 1962
 		//error_log(__METHOD__."('$document', dirs='$dirs') returning 'Document '$document' does not exist or is not readable for you!'");
1963
-		return lang("Document '%1' does not exist or is not readable for you!",$document);
1963
+		return lang("Document '%1' does not exist or is not readable for you!", $document);
1964 1964
 	}
1965 1965
 
1966 1966
 	/**
@@ -1981,16 +1981,16 @@  discard block
 block discarded – undo
1981 1981
 	 * @param string $_mimetype=''
1982 1982
 	 * @return string
1983 1983
 	 */
1984
-	static public function number_format($number,$num_decimal_places=2,$_mimetype='')
1984
+	static public function number_format($number, $num_decimal_places = 2, $_mimetype = '')
1985 1985
 	{
1986 1986
 		if ((string)$number === '') return '';
1987 1987
 		//error_log(__METHOD__.$_mimetype);
1988
-		switch($_mimetype)
1988
+		switch ($_mimetype)
1989 1989
 		{
1990 1990
 			case 'application/xml':	// Excel 2003
1991 1991
 			case 'application/vnd.oasis.opendocument.spreadsheet': // OO.o spreadsheet
1992
-				return number_format(str_replace(' ','',$number),$num_decimal_places,'.','');
1992
+				return number_format(str_replace(' ', '', $number), $num_decimal_places, '.', '');
1993 1993
 		}
1994
-		return etemplate::number_format($number,$num_decimal_places);
1994
+		return etemplate::number_format($number, $num_decimal_places);
1995 1995
 	}
1996 1996
 }
Please login to merge, or discard this patch.
Braces   +282 added lines, -78 removed lines patch added patch discarded remove patch
@@ -156,19 +156,28 @@  discard block
 block discarded – undo
156 156
 		switch ($mimetype)
157 157
 		{
158 158
 			case 'application/msword':
159
-				if (strtolower($extension) != '.rtf') break;
159
+				if (strtolower($extension) != '.rtf')
160
+				{
161
+					break;
162
+				}
160 163
 			case 'application/rtf':
161 164
 			case 'text/rtf':
162 165
 				return true;	// rtf files
163 166
 			case 'application/vnd.oasis.opendocument.text':	// oo text
164 167
 			case 'application/vnd.oasis.opendocument.spreadsheet':	// oo spreadsheet
165
-				if (!$zip_available) break;
168
+				if (!$zip_available)
169
+				{
170
+					break;
171
+				}
166 172
 				return true;	// open office write xml files
167 173
 			case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':	// ms word 2007 xml format
168 174
 			case 'application/vnd.openxmlformats-officedocument.wordprocessingml.d':	// mimetypes in vfs are limited to 64 chars
169 175
 			case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':	// ms excel 2007 xml format
170 176
 			case 'application/vnd.openxmlformats-officedocument.spreadsheetml.shee':
171
-				if (!$zip_available) break;
177
+				if (!$zip_available)
178
+				{
179
+					break;
180
+				}
172 181
 				return true;	// ms word xml format
173 182
 			case 'application/xml':
174 183
 				return true;	// alias for text/xml, eg. ms office 2003 word format
@@ -201,7 +210,10 @@  discard block
 block discarded – undo
201 210
 		{
202 211
 			$contact = $this->contacts->read($contact, $ignore_acl);
203 212
 		}
204
-		if (!is_array($contact)) return array();
213
+		if (!is_array($contact))
214
+		{
215
+			return array();
216
+		}
205 217
 		
206 218
 		$replacements = array();
207 219
 		foreach(array_keys($this->contacts->contact_fields) as $name)
@@ -210,7 +222,10 @@  discard block
 block discarded – undo
210 222
 			switch($name)
211 223
 			{
212 224
 				case 'created': case 'modified':
213
-					if($value) $value = egw_time::to($value);
225
+					if($value)
226
+					{
227
+						$value = egw_time::to($value);
228
+					}
214 229
 					break;
215 230
 				case 'bday':
216 231
 					if ($value)
@@ -256,7 +271,10 @@  discard block
 block discarded – undo
256 271
 					}
257 272
 					break;
258 273
 			}
259
-			if ($name != 'photo') $replacements['$$'.($prefix ? $prefix.'/':'').$name.'$$'] = $value;
274
+			if ($name != 'photo')
275
+			{
276
+				$replacements['$$'.($prefix ? $prefix.'/':'').$name.'$$'] = $value;
277
+			}
260 278
 		}
261 279
 		// set custom fields, should probably go to a general method all apps can use
262 280
 		// need to load all cfs for $ignore_acl=true
@@ -270,18 +288,24 @@  discard block
 block discarded – undo
270 288
 		$cats = array();
271 289
 		foreach(is_array($contact['cat_id']) ? $contact['cat_id'] : explode(',',$contact['cat_id']) as $cat_id)
272 290
 		{
273
-			if(!$cat_id) continue;
291
+			if(!$cat_id)
292
+			{
293
+				continue;
294
+			}
274 295
 			if($GLOBALS['egw']->categories->id2name($cat_id,'main') != $cat_id)
275 296
 			{
276 297
 				$path = $GLOBALS['egw']->categories->id2name($cat_id,'path');
277 298
 				$path = explode(' / ', $path);
278 299
 				unset($path[0]); // Drop main
279 300
 				$cats[$GLOBALS['egw']->categories->id2name($cat_id,'main')][] = implode(' / ', $path);
280
-			} elseif($cat_id) {
301
+			}
302
+			elseif($cat_id)
303
+			{
281 304
 				$cats[$cat_id] = array();
282 305
 			}
283 306
 		}
284
-		foreach($cats as $main => $cat) {
307
+		foreach($cats as $main => $cat)
308
+		{
285 309
 			$replacements['$$'.($prefix ? $prefix.'/':'').'categories$$'] .= $GLOBALS['egw']->categories->id2name($main,'name')
286 310
 				. (count($cat) > 0 ? ': ' : '') . implode(', ', $cats[$main]) . "\n";
287 311
 		}
@@ -316,7 +340,10 @@  discard block
 block discarded – undo
316 340
 					'id'	=> $link_info
317 341
 				);
318 342
 			}
319
-			if($exclude && in_array($link_info['id'], $exclude)) continue;
343
+			if($exclude && in_array($link_info['id'], $exclude))
344
+			{
345
+				continue;
346
+			}
320 347
 
321 348
 			$title = egw_link::title($link_info['app'], $link_info['id']);
322 349
 			if(class_exists('stylite_links_stream_wrapper') && $link_info['app'] != egw_link::VFS_APPNAME)
@@ -435,7 +462,10 @@  discard block
 block discarded – undo
435 462
 	protected function format_datetime($time,$format=null)
436 463
 	{
437 464
 		trigger_error(__METHOD__ . ' is deprecated, use egw_time::to($time, $format)', E_USER_DEPRECATED);
438
-		if (is_null($format)) $format = $this->datetime_format;
465
+		if (is_null($format))
466
+		{
467
+			$format = $this->datetime_format;
468
+		}
439 469
 
440 470
 		return egw_time::to($time,$format);
441 471
 	}
@@ -478,8 +508,14 @@  discard block
 block discarded – undo
478 508
 	public static function getExportLimit($app='common')
479 509
 	{
480 510
 		static $exportLimitStore;
481
-		if (is_null($exportLimitStore)) $exportLimitStore=array();
482
-		if (empty($app)) $app='common';
511
+		if (is_null($exportLimitStore))
512
+		{
513
+			$exportLimitStore=array();
514
+		}
515
+		if (empty($app))
516
+		{
517
+			$app='common';
518
+		}
483 519
 		//error_log(__METHOD__.__LINE__.' called with app:'.$app);
484 520
 		if (!array_key_exists($app,$exportLimitStore))
485 521
 		{
@@ -488,7 +524,10 @@  discard block
 block discarded – undo
488 524
 			if ($app !='common')
489 525
 			{
490 526
 				$app_limit = $GLOBALS['egw']->hooks->single('export_limit',$app);
491
-				if ($app_limit) $exportLimitStore[$app] = $app_limit;
527
+				if ($app_limit)
528
+				{
529
+					$exportLimitStore[$app] = $app_limit;
530
+				}
492 531
 			}
493 532
 			//error_log(__METHOD__.__LINE__.' building cache for app:'.$app.' -> '.$exportLimitStore[$app]);
494 533
 			if (empty($exportLimitStore[$app]))
@@ -521,10 +560,22 @@  discard block
 block discarded – undo
521 560
 	 */
522 561
 	public static function hasExportLimit($app_limit,$checkas='AND')
523 562
 	{
524
-		if (strtoupper($checkas) == 'ISALLOWED') return (empty($app_limit) || ($app_limit !='no' && $app_limit > 0) );
525
-		if (empty($app_limit)) return false;
526
-		if ($app_limit == 'no') return true;
527
-		if ($app_limit > 0) return true;
563
+		if (strtoupper($checkas) == 'ISALLOWED')
564
+		{
565
+			return (empty($app_limit) || ($app_limit !='no' && $app_limit > 0) );
566
+		}
567
+		if (empty($app_limit))
568
+		{
569
+			return false;
570
+		}
571
+		if ($app_limit == 'no')
572
+		{
573
+			return true;
574
+		}
575
+		if ($app_limit > 0)
576
+		{
577
+			return true;
578
+		}
528 579
 	}
529 580
 
530 581
 	/**
@@ -559,7 +610,8 @@  discard block
 block discarded – undo
559 610
 
560 611
 		try {
561 612
 			$content = $this->merge_string($content,$ids,$err,$mimetype,$fix);
562
-		} catch (Exception $e) {
613
+		}
614
+		catch (Exception $e) {
563 615
 			$err = $e->getMessage();
564 616
 			return false;
565 617
 		}
@@ -647,7 +699,8 @@  discard block
 block discarded – undo
647 699
 			$content = $xslt->transformToXml($element);
648 700
 
649 701
 			// Word 2003 needs two declarations, add extra declaration back in
650
-			if($mimetype == 'application/xml' && $mso_application_progid == 'Word.Document' && strpos($content, '<?xml') !== 0) {
702
+			if($mimetype == 'application/xml' && $mso_application_progid == 'Word.Document' && strpos($content, '<?xml') !== 0)
703
+			{
651 704
 				$content = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'.$content;
652 705
 			}
653 706
 			// Validate
@@ -700,7 +753,10 @@  discard block
 block discarded – undo
700 753
 			// textdocuments are simple, they do not hold start and end, but they may have content before and after the $$pagerepeat$$ tag
701 754
 			// header and footer should not hold any $$ tags; if we find $$ tags with the header, we assume it is the pagerepeatcontent
702 755
 			$nohead = false;
703
-			if (stripos($contentstart,'$$') !== false) $nohead = true;
756
+			if (stripos($contentstart,'$$') !== false)
757
+			{
758
+				$nohead = true;
759
+			}
704 760
 			if ($nohead)
705 761
 			{
706 762
 				$contentend = $contentrepeat;
@@ -742,13 +798,19 @@  discard block
 block discarded – undo
742 798
 		preg_match_all('/\$\$labelplacement\$\$/',$contentrepeat,$countlables, PREG_SPLIT_NO_EMPTY);
743 799
 		$countlables = count($countlables[0]);
744 800
 		preg_replace('/\$\$labelplacement\$\$/','',$Labelrepeat,1);
745
-		if ($countlables > 1) $lableprint = true;
801
+		if ($countlables > 1)
802
+		{
803
+			$lableprint = true;
804
+		}
746 805
 		if (count($ids) > 1 && !$contentrepeat)
747 806
 		{
748 807
 			$err = lang('for more than one contact in a document use the tag pagerepeat!');
749 808
 			return false;
750 809
 		}
751
-		if ($this->report_memory_usage) error_log(__METHOD__."(count(ids)=".count($ids).") strlen(contentrepeat)=".strlen($contentrepeat).', strlen(labelrepeat)='.strlen($Labelrepeat));
810
+		if ($this->report_memory_usage)
811
+		{
812
+			error_log(__METHOD__."(count(ids)=".count($ids).") strlen(contentrepeat)=".strlen($contentrepeat).', strlen(labelrepeat)='.strlen($Labelrepeat));
813
+		}
752 814
 
753 815
 		if ($contentrepeat)
754 816
 		{
@@ -781,8 +843,15 @@  discard block
 block discarded – undo
781 843
 		}
782 844
 		foreach ((array)$ids as $n => $id)
783 845
 		{
784
-			if ($contentrepeat) $content = $contentrepeat;   //content to repeat
785
-			if ($lableprint) $content = $Labelrepeat;
846
+			if ($contentrepeat)
847
+			{
848
+				$content = $contentrepeat;
849
+			}
850
+			//content to repeat
851
+			if ($lableprint)
852
+			{
853
+				$content = $Labelrepeat;
854
+			}
786 855
 
787 856
 			// generate replacements; if exeption is thrown, catch it set error message and return false
788 857
 			try
@@ -799,7 +868,10 @@  discard block
 block discarded – undo
799 868
 				$err = $e->getMessage();
800 869
 				return false;
801 870
 			}
802
-			if ($this->report_memory_usage) error_log(__METHOD__."() $n: $id ".egw_vfs::hsize(memory_get_usage(true)));
871
+			if ($this->report_memory_usage)
872
+			{
873
+				error_log(__METHOD__."() $n: $id ".egw_vfs::hsize(memory_get_usage(true)));
874
+			}
803 875
 			// some general replacements: current user, date and time
804 876
 			if (strpos($content,'$$user/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')))
805 877
 			{
@@ -859,9 +931,12 @@  discard block
 block discarded – undo
859 931
 			{
860 932
 				$contentrepeatpages[$countpage] = preg_replace('/\$\$labelplacement\$\$/',$Label,$contentrepeatpages[$countpage],1);
861 933
 				$count=$count+1;
862
-				if (($count % $countlables) == 0 && count($contentrep)>$count)  //new page
934
+				if (($count % $countlables) == 0 && count($contentrep)>$count)
935
+				{
936
+					//new page
863 937
 				{
864 938
 					$countpage = $countpage+1;
939
+				}
865 940
 					$contentrepeatpages[$countpage] = $Labelstart.$Labeltend;
866 941
 				}
867 942
 			}
@@ -892,7 +967,10 @@  discard block
 block discarded – undo
892 967
 			rewind($content_stream);
893 968
 			return stream_get_contents($content_stream);
894 969
 		}
895
-		if ($this->report_memory_usage) error_log(__METHOD__."() returning ".egw_vfs::hsize(memory_get_peak_usage(true)));
970
+		if ($this->report_memory_usage)
971
+		{
972
+			error_log(__METHOD__."() returning ".egw_vfs::hsize(memory_get_peak_usage(true)));
973
+		}
896 974
 
897 975
 		return $content;
898 976
 	}
@@ -934,7 +1012,10 @@  discard block
 block discarded – undo
934 1012
 				break;
935 1013
 
936 1014
 			default:	// div. text files --> use our export-charset, defined in addressbook prefs
937
-				if (empty($charset)) $charset = $this->contacts->prefs['csv_charset'];
1015
+				if (empty($charset))
1016
+				{
1017
+					$charset = $this->contacts->prefs['csv_charset'];
1018
+				}
938 1019
 				break;
939 1020
 		}
940 1021
 		//error_log(__METHOD__."('$document', ... ,$mimetype) --> $charset (egw=".translation::charset().', export='.$this->contacts->prefs['csv_charset'].')');
@@ -957,10 +1038,13 @@  discard block
 block discarded – undo
957 1038
 				}
958 1039
 			}
959 1040
 		}
960
-		if ($is_xml)	// zip'ed xml document (eg. OO)
1041
+		if ($is_xml)
1042
+		{
1043
+			// zip'ed xml document (eg. OO)
961 1044
 		{
962 1045
 			// Numeric fields
963 1046
 			$names = array();
1047
+		}
964 1048
 
965 1049
 			// Tags we can replace with the target document's version
966 1050
 			$replace_tags = array();
@@ -1022,7 +1106,8 @@  discard block
 block discarded – undo
1022 1106
 				else if (is_string($value) && (strpos($value,'<') !== false))
1023 1107
 				{
1024 1108
 					// Clean HTML, if it's being kept
1025
-					if($replace_tags && extension_loaded('tidy')) {
1109
+					if($replace_tags && extension_loaded('tidy'))
1110
+					{
1026 1111
 						$tidy = new tidy();
1027 1112
 						$cleaned = $tidy->repairString($value, self::$tidy_config);
1028 1113
 						// Found errors. Strip it all so there's some output
@@ -1055,16 +1140,20 @@  discard block
 block discarded – undo
1055 1140
 				// replace all control chars (C0+C1) but CR (\015), LF (\012) and TAB (\011) (eg. vertical tabulators) with space
1056 1141
 				// as they are not allowed in xml
1057 1142
 				$value = preg_replace('/[\000-\010\013\014\016-\037\177-\237]/u',' ',$value);
1058
-				if(is_numeric($value) && $name != '$$user/account_id$$') // account_id causes problems with the preg_replace below
1143
+				if(is_numeric($value) && $name != '$$user/account_id$$')
1144
+				{
1145
+					// account_id causes problems with the preg_replace below
1059 1146
 				{
1060 1147
 					$names[] = preg_quote($name,'/');
1061 1148
 				}
1149
+				}
1062 1150
 			}
1063 1151
 
1064 1152
 			// Look for numbers, set their value if needed
1065 1153
 			if($this->numeric_fields || count($names))
1066 1154
 			{
1067
-				foreach((array)$this->numeric_fields as $fieldname) {
1155
+				foreach((array)$this->numeric_fields as $fieldname)
1156
+				{
1068 1157
 					$names[] = preg_quote($fieldname,'/');
1069 1158
 				}
1070 1159
 				$this->format_spreadsheet_numbers($content, $names, $mimetype.$mso_application_progid);
@@ -1074,7 +1163,8 @@  discard block
 block discarded – undo
1074 1163
 			if($this->date_fields || count($names))
1075 1164
 			{
1076 1165
 				$names = array();
1077
-				foreach((array)$this->date_fields as $fieldname) {
1166
+				foreach((array)$this->date_fields as $fieldname)
1167
+				{
1078 1168
 					$names[] = $fieldname;
1079 1169
 				}
1080 1170
 				$this->format_spreadsheet_dates($content, $names, $replacements, $mimetype.$mso_application_progid);
@@ -1126,7 +1216,8 @@  discard block
 block discarded – undo
1126 1216
 	 */
1127 1217
 	protected function format_spreadsheet_numbers(&$content, $names, $mimetype)
1128 1218
 	{
1129
-		foreach((array)$this->numeric_fields as $fieldname) {
1219
+		foreach((array)$this->numeric_fields as $fieldname)
1220
+		{
1130 1221
 			$names[] = preg_quote($fieldname,'/');
1131 1222
 		}
1132 1223
 		switch($mimetype)
@@ -1155,7 +1246,11 @@  discard block
 block discarded – undo
1155 1246
 			// try to increase/double pcre.backtrack_limit failure
1156 1247
 			while(preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR && self::increase_backtrack_limit());
1157 1248
 
1158
-			if ($result) $content = $result;  // On failure $result would be NULL
1249
+			if ($result)
1250
+			{
1251
+				$content = $result;
1252
+			}
1253
+			// On failure $result would be NULL
1159 1254
 		}
1160 1255
 	}
1161 1256
 
@@ -1199,7 +1294,10 @@  discard block
 block discarded – undo
1199 1294
 			'application/vnd.oasis.opendocument.spreadsheet',		// open office calc
1200 1295
 			'application/xmlExcel.Sheet',					// Excel 2003
1201 1296
 			//'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'//Excel WTF
1202
-		))) return;
1297
+		)))
1298
+		{
1299
+			return;
1300
+		}
1203 1301
 
1204 1302
 		// Some different formats dates could be in, depending what they've been through
1205 1303
 		$formats = array(
@@ -1228,8 +1326,12 @@  discard block
 block discarded – undo
1228 1326
 								$values[$key],
1229 1327
 								egw_time::$user_timezone
1230 1328
 							);
1231
-							if($date) break;
1232
-						} catch (Exception $e) {
1329
+							if($date)
1330
+							{
1331
+								break;
1332
+							}
1333
+						}
1334
+						catch (Exception $e) {
1233 1335
 
1234 1336
 						}
1235 1337
 					}
@@ -1245,9 +1347,12 @@  discard block
 block discarded – undo
1245 1347
 				{
1246 1348
 					$date = new egw_time($values[$key]);
1247 1349
 				}
1248
-				if($mimetype == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')//Excel WTF
1350
+				if($mimetype == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
1351
+				{
1352
+					//Excel WTF
1249 1353
 				{
1250 1354
 					$interval = $date->diff(new egw_time('1900-01-00 0:00'));
1355
+				}
1251 1356
 					$values[$key] = $interval->format('%a')+1;// 1900-02-29 did not exist
1252 1357
 					// 1440 minutes in a day - fractional part
1253 1358
 					$values[$key] += ($date->format('H') * 60 + $date->format('i'))/1440;
@@ -1289,7 +1394,11 @@  discard block
 block discarded – undo
1289 1394
 			// try to increase/double pcre.backtrack_limit failure
1290 1395
 			while(preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR && self::increase_backtrack_limit());
1291 1396
 
1292
-			if ($result) $content = $result;  // On failure $result would be NULL
1397
+			if ($result)
1398
+			{
1399
+				$content = $result;
1400
+			}
1401
+			// On failure $result would be NULL
1293 1402
 		}
1294 1403
 	}
1295 1404
 
@@ -1352,7 +1461,10 @@  discard block
 block discarded – undo
1352 1461
 			}
1353 1462
 			else
1354 1463
 			{
1355
-				if ($cfs[$field]['type'] == 'date' || $cfs[$field]['type'] == 'date-time') $this->date_fields[] = '#'.$field;
1464
+				if ($cfs[$field]['type'] == 'date' || $cfs[$field]['type'] == 'date-time')
1465
+				{
1466
+					$this->date_fields[] = '#'.$field;
1467
+				}
1356 1468
 			}
1357 1469
 		}
1358 1470
 	}
@@ -1368,30 +1480,35 @@  discard block
 block discarded – undo
1368 1480
 	private function process_commands($content, $replacements)
1369 1481
 	{
1370 1482
 		if (strpos($content,'$$IF') !== false)
1371
-		{	//Example use to use: $$IF n_prefix~Herr~Sehr geehrter~Sehr geehrte$$
1483
+		{
1484
+//Example use to use: $$IF n_prefix~Herr~Sehr geehrter~Sehr geehrte$$
1372 1485
 			$this->replacements =& $replacements;
1373 1486
 			$content = preg_replace_callback('/\$\$IF ([#0-9a-z_\/-]+)~(.*)~(.*)~(.*)\$\$/imU',Array($this,'replace_callback'),$content);
1374 1487
 			unset($this->replacements);
1375 1488
 		}
1376 1489
 		if (strpos($content,'$$NELF') !== false)
1377
-		{	//Example: $$NEPBR org_unit$$ sets a LF and value of org_unit, only if there is a value
1490
+		{
1491
+//Example: $$NEPBR org_unit$$ sets a LF and value of org_unit, only if there is a value
1378 1492
 			$this->replacements =& $replacements;
1379 1493
 			$content = preg_replace_callback('/\$\$NELF ([#0-9a-z_\/-]+)\$\$/imU',Array($this,'replace_callback'),$content);
1380 1494
 			unset($this->replacements);
1381 1495
 		}
1382 1496
 		if (strpos($content,'$$NENVLF') !== false)
1383
-		{	//Example: $$NEPBRNV org_unit$$ sets only a LF if there is a value for org_units, but did not add any value
1497
+		{
1498
+//Example: $$NEPBRNV org_unit$$ sets only a LF if there is a value for org_units, but did not add any value
1384 1499
 			$this->replacements =& $replacements;
1385 1500
 			$content = preg_replace_callback('/\$\$NENVLF ([#0-9a-z_\/-]+)\$\$/imU',Array($this,'replace_callback'),$content);
1386 1501
 			unset($this->replacements);
1387 1502
 		}
1388 1503
 		if (strpos($content,'$$LETTERPREFIX$$') !== false)
1389
-		{	//Example use to use: $$LETTERPREFIX$$
1504
+		{
1505
+//Example use to use: $$LETTERPREFIX$$
1390 1506
 			$LETTERPREFIXCUSTOM = '$$LETTERPREFIXCUSTOM n_prefix title n_family$$';
1391 1507
 			$content = str_replace('$$LETTERPREFIX$$',$LETTERPREFIXCUSTOM,$content);
1392 1508
 		}
1393 1509
 		if (strpos($content,'$$LETTERPREFIXCUSTOM') !== false)
1394
-		{	//Example use to use for a custom Letter Prefix: $$LETTERPREFIX n_prefix title n_family$$
1510
+		{
1511
+//Example use to use for a custom Letter Prefix: $$LETTERPREFIX n_prefix title n_family$$
1395 1512
 			$this->replacements =& $replacements;
1396 1513
 			$content = preg_replace_callback('/\$\$LETTERPREFIXCUSTOM ([#0-9a-z_-]+)(.*)\$\$/imU',Array($this,'replace_callback'),$content);
1397 1514
 			unset($this->replacements);
@@ -1407,8 +1524,14 @@  discard block
 block discarded – undo
1407 1524
 	 */
1408 1525
 	private function replace_callback($param)
1409 1526
 	{
1410
-		if (array_key_exists('$$'.$param[4].'$$',$this->replacements)) $param[4] = $this->replacements['$$'.$param[4].'$$'];
1411
-		if (array_key_exists('$$'.$param[3].'$$',$this->replacements)) $param[3] = $this->replacements['$$'.$param[3].'$$'];
1527
+		if (array_key_exists('$$'.$param[4].'$$',$this->replacements))
1528
+		{
1529
+			$param[4] = $this->replacements['$$'.$param[4].'$$'];
1530
+		}
1531
+		if (array_key_exists('$$'.$param[3].'$$',$this->replacements))
1532
+		{
1533
+			$param[3] = $this->replacements['$$'.$param[3].'$$'];
1534
+		}
1412 1535
 		
1413 1536
 		$pattern = '/'.preg_quote($param[2], '/').'/';
1414 1537
 		if (strpos($param[0],'$$IF') === 0 && (trim($param[2]) == "EMPTY" || $param[2] === ''))
@@ -1430,7 +1553,7 @@  discard block
 block discarded – undo
1430 1553
 		}
1431 1554
 
1432 1555
 		switch($this->mimetype)
1433
-			{
1556
+		{
1434 1557
 				case 'application/rtf':
1435 1558
 				case 'text/rtf':
1436 1559
 					$LF = '}\par \pard\plain{';
@@ -1454,25 +1577,38 @@  discard block
 block discarded – undo
1454 1577
 				default:
1455 1578
 					$LF = "\n";
1456 1579
 			}
1457
-		if($is_xml) {
1580
+		if($is_xml)
1581
+		{
1458 1582
 			$this->replacements = str_replace(array('&','&amp;amp;','<','>',"\r","\n"),array('&amp;','&amp;','&lt;','&gt;','',$LF),$this->replacements);
1459 1583
 		}
1460 1584
 		if (strpos($param[0],'$$NELF') === 0)
1461
-		{	//sets a Pagebreak and value, only if the field has a value
1462
-			if ($this->replacements['$$'.$param[1].'$$'] !='') $replace = $LF.$this->replacements['$$'.$param[1].'$$'];
1585
+		{
1586
+//sets a Pagebreak and value, only if the field has a value
1587
+			if ($this->replacements['$$'.$param[1].'$$'] !='')
1588
+			{
1589
+				$replace = $LF.$this->replacements['$$'.$param[1].'$$'];
1590
+			}
1463 1591
 		}
1464 1592
 		if (strpos($param[0],'$$NENVLF') === 0)
1465
-		{	//sets a Pagebreak without any value, only if the field has a value
1466
-			if ($this->replacements['$$'.$param[1].'$$'] !='') $replace = $LF;
1593
+		{
1594
+//sets a Pagebreak without any value, only if the field has a value
1595
+			if ($this->replacements['$$'.$param[1].'$$'] !='')
1596
+			{
1597
+				$replace = $LF;
1598
+			}
1467 1599
 		}
1468 1600
 		if (strpos($param[0],'$$LETTERPREFIXCUSTOM') === 0)
1469
-		{	//sets a Letterprefix
1601
+		{
1602
+//sets a Letterprefix
1470 1603
 			$replaceprefixsort = array();
1471 1604
 			// ToDo Stefan: $contentstart is NOT defined here!!!
1472 1605
 			$replaceprefix = explode(' ',substr($param[0],21,-2));
1473 1606
 			foreach ($replaceprefix as $key => $nameprefix)
1474 1607
 			{
1475
-				if ($this->replacements['$$'.$nameprefix.'$$'] !='') $replaceprefixsort[] = $this->replacements['$$'.$nameprefix.'$$'];
1608
+				if ($this->replacements['$$'.$nameprefix.'$$'] !='')
1609
+				{
1610
+					$replaceprefixsort[] = $this->replacements['$$'.$nameprefix.'$$'];
1611
+				}
1476 1612
 			}
1477 1613
 			$replace = implode($replaceprefixsort,' ');
1478 1614
 		}
@@ -1513,13 +1649,20 @@  discard block
 block discarded – undo
1513 1649
 				}
1514 1650
 				//error_log(__METHOD__.__LINE__.' Message after importMessageToMergeAndSend:'.array2string($msgs));
1515 1651
 				$retString = '';
1516
-				if (count($msgs['success'])>0) $retString .= count($msgs['success']).' '.(count($msgs['success'])+count($msgs['failed'])==1?lang('Message prepared for sending.'):lang('Message(s) send ok.'));//implode('<br />',$msgs['success']);
1652
+				if (count($msgs['success'])>0)
1653
+				{
1654
+					$retString .= count($msgs['success']).' '.(count($msgs['success'])+count($msgs['failed'])==1?lang('Message prepared for sending.'):lang('Message(s) send ok.'));
1655
+				}
1656
+				//implode('<br />',$msgs['success']);
1517 1657
 				//if (strlen($retString)>0) $retString .= '<br />';
1518 1658
 				foreach($msgs['failed'] as $c =>$e)
1519 1659
 				{
1520 1660
 					$errorString .= lang('contact').' '.lang('id').':'.$c.'->'.$e.'.';
1521 1661
 				}
1522
-				if (count($msgs['failed'])>0) $retString .= count($msgs['failed']).' '.lang('Message(s) send failed!').'=>'.$errorString;
1662
+				if (count($msgs['failed'])>0)
1663
+				{
1664
+					$retString .= count($msgs['failed']).' '.lang('Message(s) send failed!').'=>'.$errorString;
1665
+				}
1523 1666
 				return $retString;
1524 1667
 				break;
1525 1668
 			case 'application/vnd.oasis.opendocument.text':
@@ -1590,7 +1733,10 @@  discard block
 block discarded – undo
1590 1733
 					return $err;
1591 1734
 				}
1592 1735
 			}
1593
-			if ($this->report_memory_usage) error_log(__METHOD__."() after HTML processing ".egw_vfs::hsize(memory_get_peak_usage(true)));
1736
+			if ($this->report_memory_usage)
1737
+			{
1738
+				error_log(__METHOD__."() after HTML processing ".egw_vfs::hsize(memory_get_peak_usage(true)));
1739
+			}
1594 1740
 		}
1595 1741
 		if(!empty($name))
1596 1742
 		{
@@ -1610,18 +1756,33 @@  discard block
 block discarded – undo
1610 1756
 			if ($zip->open($archive,ZIPARCHIVE::CHECKCONS) !== true)
1611 1757
 			{
1612 1758
 				error_log(__METHOD__.__LINE__." !ZipArchive::open('$archive',ZIPARCHIVE::CHECKCONS) failed. Trying open without validating");
1613
-				if ($zip->open($archive) !== true) throw new Exception("!ZipArchive::open('$archive',|ZIPARCHIVE::CHECKCONS)");
1759
+				if ($zip->open($archive) !== true)
1760
+				{
1761
+					throw new Exception("!ZipArchive::open('$archive',|ZIPARCHIVE::CHECKCONS)");
1762
+				}
1763
+			}
1764
+			if ($zip->addFromString($content_file,$merged) !== true)
1765
+			{
1766
+				throw new Exception("!ZipArchive::addFromString('$content_file',\$merged)");
1767
+			}
1768
+			if ($zip->close() !== true)
1769
+			{
1770
+				throw new Exception("!ZipArchive::close()");
1614 1771
 			}
1615
-			if ($zip->addFromString($content_file,$merged) !== true) throw new Exception("!ZipArchive::addFromString('$content_file',\$merged)");
1616
-			if ($zip->close() !== true) throw new Exception("!ZipArchive::close()");
1617 1772
 			unset($zip);
1618 1773
 			unset($merged);
1619 1774
 			if (substr($mimetype,0,35) == 'application/vnd.oasis.opendocument.' && 			// only open office archives need that, ms word files brake
1620
-				file_exists('/usr/bin/zip') && version_compare(PHP_VERSION,'5.3.1','<'))	// fix broken zip archives generated by current php
1775
+				file_exists('/usr/bin/zip') && version_compare(PHP_VERSION,'5.3.1','<'))
1776
+			{
1777
+				// fix broken zip archives generated by current php
1621 1778
 			{
1622 1779
 				exec('/usr/bin/zip -F '.escapeshellarg($archive));
1623 1780
 			}
1624
-			if ($this->report_memory_usage) error_log(__METHOD__."() after ZIP processing ".egw_vfs::hsize(memory_get_peak_usage(true)));
1781
+			}
1782
+			if ($this->report_memory_usage)
1783
+			{
1784
+				error_log(__METHOD__."() after ZIP processing ".egw_vfs::hsize(memory_get_peak_usage(true)));
1785
+			}
1625 1786
 			html::content_header($name,$mimetype,filesize($archive));
1626 1787
 			readfile($archive,'r');
1627 1788
 		}
@@ -1656,9 +1817,18 @@  discard block
 block discarded – undo
1656 1817
 	 */
1657 1818
 	public function download_by_request()
1658 1819
 	{
1659
-		if(empty($_POST['data_document_name'])) return false;
1660
-		if(empty($_POST['data_document_dir'])) return false;
1661
-		if(empty($_POST['data_checked'])) return false;
1820
+		if(empty($_POST['data_document_name']))
1821
+		{
1822
+			return false;
1823
+		}
1824
+		if(empty($_POST['data_document_dir']))
1825
+		{
1826
+			return false;
1827
+		}
1828
+		if(empty($_POST['data_checked']))
1829
+		{
1830
+			return false;
1831
+		}
1662 1832
 
1663 1833
 		return $this->download(
1664 1834
 			$_POST['data_document_name'],
@@ -1679,13 +1849,20 @@  discard block
 block discarded – undo
1679 1849
 	public static function get_documents($dirs, $prefix='document_', $mime_filter=null, $app='')
1680 1850
 	{
1681 1851
 		$export_limit=self::getExportLimit($app);
1682
-		if (!$dirs || (!self::hasExportLimit($export_limit,'ISALLOWED') && !self::is_export_limit_excepted())) return array();
1852
+		if (!$dirs || (!self::hasExportLimit($export_limit,'ISALLOWED') && !self::is_export_limit_excepted()))
1853
+		{
1854
+			return array();
1855
+		}
1683 1856
 
1684 1857
 		// split multiple comma or whitespace separated directories
1685 1858
 		// to still allow space or comma in dirnames, we also use the trailing slash of all pathes to split
1686 1859
 		if (count($dirs = preg_split('/[,\s]+\//', $dirs)) > 1)
1687 1860
 		{
1688
-			foreach($dirs as $n => &$d) if ($n) $d = '/'.$d;	// re-adding trailing slash removed by split
1861
+			foreach($dirs as $n => &$d)
1862
+			{
1863
+				if ($n) $d = '/'.$d;
1864
+			}
1865
+			// re-adding trailing slash removed by split
1689 1866
 		}
1690 1867
 		if ($mime_filter && ($negativ_filter = $mime_filter[0] === '!'))
1691 1868
 		{
@@ -1707,8 +1884,14 @@  discard block
 block discarded – undo
1707 1884
 				{
1708 1885
 					// return only the mime-types we support
1709 1886
 					$parts = explode('.',$file['name']);
1710
-					if (!self::is_implemented($file['mime'],'.'.array_pop($parts))) continue;
1711
-					if ($mime_filter && $negativ_filter === in_array($file['mime'], (array)$mime_filter)) continue;
1887
+					if (!self::is_implemented($file['mime'],'.'.array_pop($parts)))
1888
+					{
1889
+						continue;
1890
+					}
1891
+					if ($mime_filter && $negativ_filter === in_array($file['mime'], (array)$mime_filter))
1892
+					{
1893
+						continue;
1894
+					}
1712 1895
 					$list[$prefix.$file['name']] = egw_vfs::decodePath($file['name']);
1713 1896
 				}
1714 1897
 			}
@@ -1738,12 +1921,19 @@  discard block
 block discarded – undo
1738 1921
 		$export_limit=null)
1739 1922
 	{
1740 1923
 		$documents = array();
1741
-		if ($export_limit == null) $export_limit = self::getExportLimit(); // check if there is a globalsetting
1742
-		if ($default_doc && ($file = egw_vfs::stat($default_doc)))	// put default document on top
1924
+		if ($export_limit == null)
1925
+		{
1926
+			$export_limit = self::getExportLimit();
1927
+		}
1928
+		// check if there is a globalsetting
1929
+		if ($default_doc && ($file = egw_vfs::stat($default_doc)))
1930
+		{
1931
+			// put default document on top
1743 1932
 		{
1744 1933
 			if(!$file['mime'])
1745 1934
 			{
1746 1935
 				$file['mime'] = egw_vfs::mime_content_type($default_doc);
1936
+		}
1747 1937
 				$file['path'] = $default_doc;
1748 1938
 			}
1749 1939
 			$documents['document'] = array(
@@ -1765,7 +1955,11 @@  discard block
 block discarded – undo
1765 1955
 			// to still allow space or comma in dirnames, we also use the trailing slash of all pathes to split
1766 1956
 			if (count($dirs = preg_split('/[,\s]+\//', $dirs)) > 1)
1767 1957
 			{
1768
-				foreach($dirs as $n => &$d) if ($n) $d = '/'.$d;	// re-adding trailing slash removed by split
1958
+				foreach($dirs as $n => &$d)
1959
+				{
1960
+					if ($n) $d = '/'.$d;
1961
+				}
1962
+				// re-adding trailing slash removed by split
1769 1963
 			}
1770 1964
 			foreach($dirs as $dir)
1771 1965
 			{
@@ -1784,10 +1978,13 @@  discard block
 block discarded – undo
1784 1978
 			$parts = explode('.',$file['name']);
1785 1979
 			if (!self::is_implemented($file['mime'],'.'.array_pop($parts)) ||
1786 1980
 				!egw_vfs::check_access($file['path'], egw_vfs::READABLE, $file) ||	// remove files not readable by user
1787
-				$file['path'] === $default_doc)	// default doc already added
1981
+				$file['path'] === $default_doc)
1982
+			{
1983
+				// default doc already added
1788 1984
 			{
1789 1985
 				unset($files[$key]);
1790 1986
 			}
1987
+			}
1791 1988
 			else
1792 1989
 			{
1793 1990
 				$dirname = egw_vfs::dirname($file['path']);
@@ -1946,7 +2143,11 @@  discard block
 block discarded – undo
1946 2143
 			{
1947 2144
 				foreach($dirs as $n => $dir)
1948 2145
 				{
1949
-					if ($n) $dir = '/'.$dir;	// re-adding trailing slash removed by split
2146
+					if ($n)
2147
+					{
2148
+						$dir = '/'.$dir;
2149
+					}
2150
+					// re-adding trailing slash removed by split
1950 2151
 					if (egw_vfs::stat($dir.'/'.$document) && egw_vfs::is_readable($dir.'/'.$document))
1951 2152
 					{
1952 2153
 						$document = $dir.'/'.$document;
@@ -1983,7 +2184,10 @@  discard block
 block discarded – undo
1983 2184
 	 */
1984 2185
 	static public function number_format($number,$num_decimal_places=2,$_mimetype='')
1985 2186
 	{
1986
-		if ((string)$number === '') return '';
2187
+		if ((string)$number === '')
2188
+		{
2189
+			return '';
2190
+		}
1987 2191
 		//error_log(__METHOD__.$_mimetype);
1988 2192
 		switch($_mimetype)
1989 2193
 		{
Please login to merge, or discard this patch.
Upper-Lower-Casing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1417,19 +1417,19 @@  discard block
 block discarded – undo
1417 1417
 		if (strpos($content,'$$IF') !== false)
1418 1418
 		{	//Example use to use: $$IF n_prefix~Herr~Sehr geehrter~Sehr geehrte$$
1419 1419
 			$this->replacements =& $replacements;
1420
-			$content = preg_replace_callback('/\$\$IF ([#0-9a-z_\/-]+)~(.*)~(.*)~(.*)\$\$/imU',Array($this,'replace_callback'),$content);
1420
+			$content = preg_replace_callback('/\$\$IF ([#0-9a-z_\/-]+)~(.*)~(.*)~(.*)\$\$/imU',array($this,'replace_callback'),$content);
1421 1421
 			unset($this->replacements);
1422 1422
 		}
1423 1423
 		if (strpos($content,'$$NELF') !== false)
1424 1424
 		{	//Example: $$NEPBR org_unit$$ sets a LF and value of org_unit, only if there is a value
1425 1425
 			$this->replacements =& $replacements;
1426
-			$content = preg_replace_callback('/\$\$NELF ([#0-9a-z_\/-]+)\$\$/imU',Array($this,'replace_callback'),$content);
1426
+			$content = preg_replace_callback('/\$\$NELF ([#0-9a-z_\/-]+)\$\$/imU',array($this,'replace_callback'),$content);
1427 1427
 			unset($this->replacements);
1428 1428
 		}
1429 1429
 		if (strpos($content,'$$NENVLF') !== false)
1430 1430
 		{	//Example: $$NEPBRNV org_unit$$ sets only a LF if there is a value for org_units, but did not add any value
1431 1431
 			$this->replacements =& $replacements;
1432
-			$content = preg_replace_callback('/\$\$NENVLF ([#0-9a-z_\/-]+)\$\$/imU',Array($this,'replace_callback'),$content);
1432
+			$content = preg_replace_callback('/\$\$NENVLF ([#0-9a-z_\/-]+)\$\$/imU',array($this,'replace_callback'),$content);
1433 1433
 			unset($this->replacements);
1434 1434
 		}
1435 1435
 		if (strpos($content,'$$LETTERPREFIX$$') !== false)
@@ -1440,7 +1440,7 @@  discard block
 block discarded – undo
1440 1440
 		if (strpos($content,'$$LETTERPREFIXCUSTOM') !== false)
1441 1441
 		{	//Example use to use for a custom Letter Prefix: $$LETTERPREFIX n_prefix title n_family$$
1442 1442
 			$this->replacements =& $replacements;
1443
-			$content = preg_replace_callback('/\$\$LETTERPREFIXCUSTOM ([#0-9a-z_-]+)(.*)\$\$/imU',Array($this,'replace_callback'),$content);
1443
+			$content = preg_replace_callback('/\$\$LETTERPREFIXCUSTOM ([#0-9a-z_-]+)(.*)\$\$/imU',array($this,'replace_callback'),$content);
1444 1444
 			unset($this->replacements);
1445 1445
 		}
1446 1446
 		return $content;
@@ -1958,7 +1958,7 @@  discard block
 block discarded – undo
1958 1958
 	 * @param Array $file Array of information about the document from Api\Vfs::find
1959 1959
 	 * @return void
1960 1960
 	 */
1961
-	private static function document_mail_action(Array &$action, $file)
1961
+	private static function document_mail_action(array &$action, $file)
1962 1962
 	{
1963 1963
 		unset($action['postSubmit']);
1964 1964
 
Please login to merge, or discard this patch.
etemplate/inc/class.bo_tracking.inc.php 3 patches
Doc Comments   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 	 * @param array $data current entry
522 522
 	 * @param array $old = null old/last state of the entry or null for a new entry
523 523
 	 * @param boolean $deleted = null can be set to true to let the tracking know the item got deleted or undelted
524
-	 * @param array $email_notified=null if present will return the emails notified, if given emails in that list will not be notified
524
+	 * @param array $email_notified if present will return the emails notified, if given emails in that list will not be notified
525 525
 	 * @return boolean true on success, false on error (error messages are in $this->errors)
526 526
 	 */
527 527
 	public function do_notifications($data,$old,$deleted=null,&$email_notified=null)
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 	 * Return date+time formatted for the currently notified user (prefs in $GLOBALS['egw_info']['user']['preferences'])
790 790
 	 *
791 791
 	 * @param int|string|DateTime $timestamp in server-time
792
-	 * @param boolean $do_time=true true=allways (default), false=never print the time, null=print time if != 00:00
792
+	 * @param boolean $do_time true=allways (default), false=never print the time, null=print time if != 00:00
793 793
 	 *
794 794
 	 * @return string
795 795
 	 */
@@ -816,7 +816,6 @@  discard block
 block discarded – undo
816 816
 	 * The default implementation prefers depending on the prefer_user_as_sender class-var the user over
817 817
 	 * what is returned by get_config('sender').
818 818
 	 *
819
-	 * @param int $user account_lid of user
820 819
 	 * @param array $data
821 820
 	 * @param array $old
822 821
 	 * @param bool $prefer_id returns the userid rather than email
@@ -866,7 +865,7 @@  discard block
 block discarded – undo
866 865
 	 *
867 866
 	 * @param array $data
868 867
 	 * @param array $old
869
-	 * @param boolean $deleted=null can be set to true to let the tracking know the item got deleted or undelted
868
+	 * @param boolean $deleted can be set to true to let the tracking know the item got deleted or undelted
870 869
 	 * @param int|string $receiver nummeric account_id or email address
871 870
 	 * @return string
872 871
 	 */
Please login to merge, or discard this patch.
Spacing   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -188,12 +188,12 @@  discard block
 block discarded – undo
188 188
 	{
189 189
 		if ($cf_app)
190 190
 		{
191
-			$linkable_cf_types = array('link-entry')+array_keys(egw_link::app_list());
192
-			foreach(egw_customfields::get($cf_app, true) as $cf_name => $cf_data)
191
+			$linkable_cf_types = array('link-entry') + array_keys(egw_link::app_list());
192
+			foreach (egw_customfields::get($cf_app, true) as $cf_name => $cf_data)
193 193
 			{
194 194
 				$this->field2history['#'.$cf_name] = '#'.$cf_name;
195 195
 
196
-				if (in_array($cf_data['type'],$linkable_cf_types))
196
+				if (in_array($cf_data['type'], $linkable_cf_types))
197 197
 				{
198 198
 					$this->cf_link_fields['#'.$cf_name] = $cf_data['type'] == 'link-entry' ? '' : $cf_data['type'];
199 199
 				}
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 * @param int|string $receiver nummeric account_id or email address
216 216
 	 * @return array of details as array with values for keys 'label','value','type'
217 217
 	 */
218
-	function get_details($data,$receiver=null)
218
+	function get_details($data, $receiver = null)
219 219
 	{
220 220
 		return array();
221 221
 	}
@@ -227,14 +227,14 @@  discard block
 block discarded – undo
227 227
 	 * @param string $only_type2 = null if given only return fields of type2 == $only_type2
228 228
 	 * @return array of details as array with values for keys 'label','value','type'
229 229
 	 */
230
-	function get_customfields($data, $only_type2=null)
230
+	function get_customfields($data, $only_type2 = null)
231 231
 	{
232 232
 		$details = array();
233 233
 
234
-		if (($cfs = egw_customfields::get($this->app, $all_private_too=false, $only_type2)))
234
+		if (($cfs = egw_customfields::get($this->app, $all_private_too = false, $only_type2)))
235 235
 		{
236 236
 			$header_done = false;
237
-			foreach($cfs as $name => $field)
237
+			foreach ($cfs as $name => $field)
238 238
 			{
239 239
 				if (in_array($field['type'], egw_customfields::$non_printable_fields)) continue;
240 240
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	 * @param array $old = null old/last state of the entry or null for a new entry
276 276
 	 * @return mixed
277 277
 	 */
278
-	protected function get_config($name,$data,$old=null)
278
+	protected function get_config($name, $data, $old = null)
279 279
 	{
280 280
 		return null;
281 281
 	}
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	 * @param boolean $skip_notification = false do NOT send any notification
292 292
 	 * @return int|boolean false on error, integer number of changes logged or true for new entries ($old == null)
293 293
 	 */
294
-	public function track(array $data,array $old=null,$user=null,$deleted=null,array $changed_fields=null,$skip_notification=false)
294
+	public function track(array $data, array $old = null, $user = null, $deleted = null, array $changed_fields = null, $skip_notification = false)
295 295
 	{
296 296
 		$this->user = !is_null($user) ? $user : $GLOBALS['egw_info']['user']['account_id'];
297 297
 
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 		if ($old && $this->field2history)
301 301
 		{
302 302
 			//error_log(__METHOD__.__LINE__.' Changedfields:'.print_r($changed_fields,true));
303
-			$changes = $this->save_history($data,$old,$deleted,$changed_fields);
303
+			$changes = $this->save_history($data, $old, $deleted, $changed_fields);
304 304
 			//error_log(__METHOD__.__LINE__.' Changedfields:'.print_r($changed_fields,true));
305 305
 			//error_log(__METHOD__.__LINE__.' Changes:'.print_r($changes,true));
306 306
 		}
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
 		//error_log(__METHOD__.__LINE__.' LinkFields:'.array2string($this->cf_link_fields));
309 309
 		if ($changes && $this->cf_link_fields)
310 310
 		{
311
-			$this->update_links($data,(array)$old);
311
+			$this->update_links($data, (array)$old);
312 312
 		}
313 313
 		// do not run do_notifications if we have no changes
314
-		if ($changes && !$skip_notification && !$this->do_notifications($data,$old,$deleted))
314
+		if ($changes && !$skip_notification && !$this->do_notifications($data, $old, $deleted))
315 315
 		{
316 316
 			$changes = false;
317 317
 		}
@@ -328,45 +328,45 @@  discard block
 block discarded – undo
328 328
 	{
329 329
 		//error_log(__METHOD__.__LINE__.array2string($data).function_backtrace());
330 330
 		//error_log(__METHOD__.__LINE__.array2string($this->cf_link_fields));
331
-		foreach((array)$this->cf_link_fields as $name => $val)
331
+		foreach ((array)$this->cf_link_fields as $name => $val)
332 332
 		{
333 333
 			//error_log(__METHOD__.__LINE__.' Field:'.$name. ' Value (new):'.array2string($data[$name]));
334 334
 			//error_log(__METHOD__.__LINE__.' Field:'.$name. ' Value (old):'.array2string($old[$name]));
335
-			if (is_array($data[$name]) && array_key_exists('id',$data[$name])) $data[$name] = $data[$name]['id'];
336
-			if (is_array($old[$name]) && array_key_exists('id',$old[$name])) $old[$name] = $old[$name]['id'];
335
+			if (is_array($data[$name]) && array_key_exists('id', $data[$name])) $data[$name] = $data[$name]['id'];
336
+			if (is_array($old[$name]) && array_key_exists('id', $old[$name])) $old[$name] = $old[$name]['id'];
337 337
 			//error_log(__METHOD__.__LINE__.'(After processing) Field:'.$name. ' Value (new):'.array2string($data[$name]));
338 338
 			//error_log(__METHOD__.__LINE__.'(After processing) Field:'.$name. ' Value (old):'.array2string($old[$name]));
339 339
 		}
340
-		$current_ids = array_unique(array_diff(array_intersect_key($data,$this->cf_link_fields),array('',0,NULL)));
341
-		$old_ids = $old ? array_unique(array_diff(array_intersect_key($old,$this->cf_link_fields),array('',0,NULL))) : array();
340
+		$current_ids = array_unique(array_diff(array_intersect_key($data, $this->cf_link_fields), array('', 0, NULL)));
341
+		$old_ids = $old ? array_unique(array_diff(array_intersect_key($old, $this->cf_link_fields), array('', 0, NULL))) : array();
342 342
 		//error_log(__METHOD__.__LINE__.array2string($current_ids));
343 343
 		//error_log(__METHOD__.__LINE__.array2string($old_ids));
344 344
 		// create links for added application entry
345
-		foreach(array_diff($current_ids,$old_ids) as $name => $id)
345
+		foreach (array_diff($current_ids, $old_ids) as $name => $id)
346 346
 		{
347 347
 			if (!($app = $this->cf_link_fields[$name]))
348 348
 			{
349
-				list($app,$id) = explode(':',$id);
350
-				if (!$id) continue;	// can be eg. 'addressbook:', if no contact selected
349
+				list($app, $id) = explode(':', $id);
350
+				if (!$id) continue; // can be eg. 'addressbook:', if no contact selected
351 351
 			}
352 352
 			$source_id = $data[$this->id_field];
353 353
 			//error_log(__METHOD__.__LINE__.array2string($source_id));
354
-			if ($source_id) egw_link::link($this->app,$source_id,$app,$id);
354
+			if ($source_id) egw_link::link($this->app, $source_id, $app, $id);
355 355
 			//error_log(__METHOD__.__LINE__."egw_link::link('$this->app',".array2string($source_id).",'$app',$id);");
356 356
 			//echo "<p>egw_link::link('$this->app',{$data[$this->id_field]},'$app',$id);</p>\n";
357 357
 		}
358 358
 
359 359
 		// unlink removed application entries
360
-		foreach(array_diff($old_ids,$current_ids) as $name => $id)
360
+		foreach (array_diff($old_ids, $current_ids) as $name => $id)
361 361
 		{
362
-			if (!isset($data[$name])) continue;	// ignore not set link cf's, eg. from sync clients
362
+			if (!isset($data[$name])) continue; // ignore not set link cf's, eg. from sync clients
363 363
 			if (!($app = $this->cf_link_fields[$name]))
364 364
 			{
365
-				list($app,$id) = explode(':',$id);
365
+				list($app, $id) = explode(':', $id);
366 366
 				if (!$id) continue;
367 367
 			}
368 368
 			$source_id = $data[$this->id_field];
369
-			if ($source_id) egw_link::unlink(null,$this->app,$source_id,0,$app,$id);
369
+			if ($source_id) egw_link::unlink(null, $this->app, $source_id, 0, $app, $id);
370 370
 			//echo "<p>egw_link::unlink(NULL,'$this->app',{$data[$this->id_field]},0,'$app',$id);</p>\n";
371 371
 		}
372 372
 	}
@@ -381,19 +381,19 @@  discard block
 block discarded – undo
381 381
 	 * @param array $changed_fields = null changed fields from ealier call to $this->changed_fields($data,$old), to not compute it again
382 382
 	 * @return int number of log-entries made
383 383
 	 */
384
-	protected function save_history(array $data,array $old=null,$deleted=null,array $changed_fields=null)
384
+	protected function save_history(array $data, array $old = null, $deleted = null, array $changed_fields = null)
385 385
 	{
386 386
 		//error_log(__METHOD__.__LINE__.' Changedfields:'.array2string($changed_fields));
387 387
 		if (is_null($changed_fields))
388 388
 		{
389
-			$changed_fields = self::changed_fields($data,$old);
389
+			$changed_fields = self::changed_fields($data, $old);
390 390
 			//error_log(__METHOD__.__LINE__.' Changedfields:'.array2string($changed_fields));
391 391
 		}
392 392
 		if (!$changed_fields && ($old || !$GLOBALS['egw_info']['server']['log_user_agent_action'])) return 0;
393 393
 
394 394
 		if (!is_object($this->historylog) || $this->historylog->user != $this->user)
395 395
 		{
396
-			$this->historylog = new historylog($this->app,$this->user);
396
+			$this->historylog = new historylog($this->app, $this->user);
397 397
 		}
398 398
 		// log user-agent and session-action
399 399
 		if ($GLOBALS['egw_info']['server']['log_user_agent_action'] && ($changed_fields || !$old))
@@ -401,30 +401,30 @@  discard block
 block discarded – undo
401 401
 			$this->historylog->add('user_agent_action', $data[$this->id_field],
402 402
 				$_SERVER['HTTP_USER_AGENT'], $_SESSION[egw_session::EGW_SESSION_VAR]['session_action']);
403 403
 		}
404
-		foreach($changed_fields as $name)
404
+		foreach ($changed_fields as $name)
405 405
 		{
406 406
 			$status = isset($this->field2history[$name]) ? $this->field2history[$name] : $name;
407 407
 			//error_log(__METHOD__.__LINE__." Name $name,".' Status:'.array2string($status));
408 408
 			if (is_array($status))	// 1:N relation --> remove common rows
409 409
 			{
410 410
 				//error_log(__METHOD__.__LINE__.' is Array');
411
-				self::compact_1_N_relation($data[$name],$status);
412
-				self::compact_1_N_relation($old[$name],$status);
413
-				$added = array_values(array_diff($data[$name],$old[$name]));
414
-				$removed = array_values(array_diff($old[$name],$data[$name]));
415
-				$n = max(array(count($added),count($removed)));
416
-				for($i = 0; $i < $n; ++$i)
411
+				self::compact_1_N_relation($data[$name], $status);
412
+				self::compact_1_N_relation($old[$name], $status);
413
+				$added = array_values(array_diff($data[$name], $old[$name]));
414
+				$removed = array_values(array_diff($old[$name], $data[$name]));
415
+				$n = max(array(count($added), count($removed)));
416
+				for ($i = 0; $i < $n; ++$i)
417 417
 				{
418 418
 					//error_log(__METHOD__."() $i: historylog->add('$name',data['$this->id_field']={$data[$this->id_field]},".array2string($added[$i]).','.array2string($removed[$i]));
419
-					$this->historylog->add($name,$data[$this->id_field],$added[$i],$removed[$i]);
419
+					$this->historylog->add($name, $data[$this->id_field], $added[$i], $removed[$i]);
420 420
 				}
421 421
 			}
422 422
 			else
423 423
 			{
424 424
 				//error_log(__METHOD__.__LINE__.' IDField:'.array2string($this->id_field).' ->'.$data[$this->id_field].' New:'.$data[$name].' Old:'.$old[$name]);
425
-				$this->historylog->add($status,$data[$this->id_field],
426
-					is_array($data[$name]) ? implode(',',$data[$name]) : $data[$name],
427
-					is_array($old[$name]) ? implode(',',$old[$name]) : $old[$name]);
425
+				$this->historylog->add($status, $data[$this->id_field],
426
+					is_array($data[$name]) ? implode(',', $data[$name]) : $data[$name],
427
+					is_array($old[$name]) ? implode(',', $old[$name]) : $old[$name]);
428 428
 			}
429 429
 		}
430 430
 		//error_log(__METHOD__.__LINE__.' return:'.count($changed_fields));
@@ -440,28 +440,28 @@  discard block
 block discarded – undo
440 440
 	 * @param array $old = null
441 441
 	 * @return array of keys with different values in $data and $old
442 442
 	 */
443
-	public function changed_fields(array $data,array $old=null)
443
+	public function changed_fields(array $data, array $old = null)
444 444
 	{
445 445
 		if (is_null($old)) return array_keys($data);
446 446
 		$changed_fields = array();
447
-		foreach($this->field2history as $name => $status)
447
+		foreach ($this->field2history as $name => $status)
448 448
 		{
449
-			if (!$old[$name] && !$data[$name]) continue;	// treat all sorts of empty equally
449
+			if (!$old[$name] && !$data[$name]) continue; // treat all sorts of empty equally
450 450
 
451
-			if ($name[0] == '#' && !isset($data[$name])) continue;	// no set customfields are not stored, therefore not changed
451
+			if ($name[0] == '#' && !isset($data[$name])) continue; // no set customfields are not stored, therefore not changed
452 452
 
453 453
 			if (is_array($status))	// 1:N relation
454 454
 			{
455
-				self::compact_1_N_relation($data[$name],$status);
456
-				self::compact_1_N_relation($old[$name],$status);
455
+				self::compact_1_N_relation($data[$name], $status);
456
+				self::compact_1_N_relation($old[$name], $status);
457 457
 			}
458 458
 			if ($old[$name] != $data[$name])
459 459
 			{
460 460
 				// normalize arrays, we do NOT care for the order of multiselections
461 461
 				if (is_array($data[$name]) || is_array($old[$name]))
462 462
 				{
463
-					if (!is_array($data[$name])) $data[$name] = explode(',',$data[$name]);
464
-					if (!is_array($old[$name])) $old[$name] = explode(',',$old[$name]);
463
+					if (!is_array($data[$name])) $data[$name] = explode(',', $data[$name]);
464
+					if (!is_array($old[$name])) $old[$name] = explode(',', $old[$name]);
465 465
 					if (count($data[$name]) == count($old[$name]))
466 466
 					{
467 467
 						sort($data[$name]);
@@ -471,13 +471,13 @@  discard block
 block discarded – undo
471 471
 				}
472 472
 				elseif (str_replace("\r", '', $old[$name]) == str_replace("\r", '', $data[$name]))
473 473
 				{
474
-					continue;	// change only in CR (eg. different OS) --> ignore
474
+					continue; // change only in CR (eg. different OS) --> ignore
475 475
 				}
476 476
 				$changed_fields[] = $name;
477 477
 				//echo "<p>$name: ".array2string($data[$name]).' != '.array2string($old[$name])."</p>\n";
478 478
 			}
479 479
 		}
480
-		foreach($data as $name => $value)
480
+		foreach ($data as $name => $value)
481 481
 		{
482 482
 			if ($name[0] == '#' && $name[1] == '#' && $value !== $old[$name])
483 483
 			{
@@ -494,18 +494,18 @@  discard block
 block discarded – undo
494 494
 	 * @param array &$rows rows of the 1:N relation
495 495
 	 * @param array $cols field names as values
496 496
 	 */
497
-	private static function compact_1_N_relation(&$rows,array $cols)
497
+	private static function compact_1_N_relation(&$rows, array $cols)
498 498
 	{
499 499
 		if (is_array($rows))
500 500
 		{
501
-			foreach($rows as $key => &$row)
501
+			foreach ($rows as $key => &$row)
502 502
 			{
503 503
 				$values = array();
504
-				foreach($cols as $col)
504
+				foreach ($cols as $col)
505 505
 				{
506 506
 					$values[] = $row[$col];
507 507
 				}
508
-				$row = implode(self::ONE2N_SEPERATOR,$values);
508
+				$row = implode(self::ONE2N_SEPERATOR, $values);
509 509
 			}
510 510
 		}
511 511
 		else
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 	 * @param array $email_notified=null if present will return the emails notified, if given emails in that list will not be notified
525 525
 	 * @return boolean true on success, false on error (error messages are in $this->errors)
526 526
 	 */
527
-	public function do_notifications($data,$old,$deleted=null,&$email_notified=null)
527
+	public function do_notifications($data, $old, $deleted = null, &$email_notified = null)
528 528
 	{
529 529
 		$this->errors = $email_sent = array();
530 530
 		if (!empty($email_notified) && is_array($email_notified)) $email_sent = $email_notified;
@@ -532,19 +532,19 @@  discard block
 block discarded – undo
532 532
 		if (!$this->notify_current_user && $this->user)		// do we have a current user and should we notify the current user about his own changes
533 533
 		{
534 534
 			//error_log("do_notificaton() adding user=$this->user to email_sent, to not notify him");
535
-			$email_sent[] = $GLOBALS['egw']->accounts->id2name($this->user,'account_email');
535
+			$email_sent[] = $GLOBALS['egw']->accounts->id2name($this->user, 'account_email');
536 536
 		}
537
-		$skip_notify = $this->get_config('skip_notify',$data,$old);
538
-		if($skip_notify && is_array($skip_notify))
537
+		$skip_notify = $this->get_config('skip_notify', $data, $old);
538
+		if ($skip_notify && is_array($skip_notify))
539 539
 		{
540 540
 			$email_sent = array_merge($email_sent, $skip_notify);
541 541
 		}
542 542
 
543 543
 		// entry creator
544
-		if ($this->creator_field && ($email = $GLOBALS['egw']->accounts->id2name($data[$this->creator_field],'account_email')) &&
544
+		if ($this->creator_field && ($email = $GLOBALS['egw']->accounts->id2name($data[$this->creator_field], 'account_email')) &&
545 545
 			!in_array($email, $email_sent))
546 546
 		{
547
-			if ($this->send_notification($data,$old,$email,$data[$this->creator_field],'notify_creator'))
547
+			if ($this->send_notification($data, $old, $email, $data[$this->creator_field], 'notify_creator'))
548 548
 			{
549 549
 				$email_sent[] = $email;
550 550
 			}
@@ -553,12 +553,12 @@  discard block
 block discarded – undo
553 553
 		// members of group when entry owned by group
554 554
 		if ($this->creator_field && $GLOBALS['egw']->accounts->get_type($data[$this->creator_field]) == 'g')
555 555
 		{
556
-			foreach($GLOBALS['egw']->accounts->members($data[$this->creator_field],true) as $u)
556
+			foreach ($GLOBALS['egw']->accounts->members($data[$this->creator_field], true) as $u)
557 557
 			{
558
-				if (($email = $GLOBALS['egw']->accounts->id2name($u,'account_email')) &&
558
+				if (($email = $GLOBALS['egw']->accounts->id2name($u, 'account_email')) &&
559 559
 					!in_array($email, $email_sent))
560 560
 				{
561
-					if ($this->send_notification($data,$old,$email,$u,'notify_owner_group_member'))
561
+					if ($this->send_notification($data, $old, $email, $u, 'notify_owner_group_member'))
562 562
 					{
563 563
 						$email_sent[] = $email;
564 564
 					}
@@ -575,14 +575,14 @@  discard block
 block discarded – undo
575 575
 			if ($data[$this->assigned_field])	// current assignments
576 576
 			{
577 577
 				$assignees = is_array($data[$this->assigned_field]) ?
578
-					$data[$this->assigned_field] : explode(',',$data[$this->assigned_field]);
578
+					$data[$this->assigned_field] : explode(',', $data[$this->assigned_field]);
579 579
 			}
580 580
 			if ($old && $old[$this->assigned_field])
581 581
 			{
582 582
 				$old_assignees = is_array($old[$this->assigned_field]) ?
583
-					$old[$this->assigned_field] : explode(',',$old[$this->assigned_field]);
583
+					$old[$this->assigned_field] : explode(',', $old[$this->assigned_field]);
584 584
 			}
585
-			foreach(array_unique(array_merge($assignees,$old_assignees)) as $assignee)
585
+			foreach (array_unique(array_merge($assignees, $old_assignees)) as $assignee)
586 586
 			{
587 587
 				//error_log("bo_tracking::do_notifications() assignee=$assignee, type=".$GLOBALS['egw']->accounts->get_type($assignee).", email=".$GLOBALS['egw']->accounts->id2name($assignee,'account_email'));
588 588
 				if (!$assignee) continue;
@@ -590,10 +590,10 @@  discard block
 block discarded – undo
590 590
 				// item assignee is a user
591 591
 				if ($GLOBALS['egw']->accounts->get_type($assignee) == 'u')
592 592
 				{
593
-					if (($email = $GLOBALS['egw']->accounts->id2name($assignee,'account_email')) && !in_array($email, $email_sent))
593
+					if (($email = $GLOBALS['egw']->accounts->id2name($assignee, 'account_email')) && !in_array($email, $email_sent))
594 594
 					{
595
-						if ($this->send_notification($data,$old,$email,$assignee,'notify_assigned',
596
-							in_array($assignee,$assignees) !== in_array($assignee,$old_assignees) || $deleted))	// assignment changed
595
+						if ($this->send_notification($data, $old, $email, $assignee, 'notify_assigned',
596
+							in_array($assignee, $assignees) !== in_array($assignee, $old_assignees) || $deleted))	// assignment changed
597 597
 						{
598 598
 							$email_sent[] = $email;
599 599
 						}
@@ -601,12 +601,12 @@  discard block
 block discarded – undo
601 601
 				}
602 602
 				else	// item assignee is a group
603 603
 				{
604
-					foreach($GLOBALS['egw']->accounts->members($assignee,true) as $u)
604
+					foreach ($GLOBALS['egw']->accounts->members($assignee, true) as $u)
605 605
 					{
606
-						if (($email = $GLOBALS['egw']->accounts->id2name($u,'account_email')) && !in_array($email, $email_sent))
606
+						if (($email = $GLOBALS['egw']->accounts->id2name($u, 'account_email')) && !in_array($email, $email_sent))
607 607
 						{
608
-							if ($this->send_notification($data,$old,$email,$u,'notify_assigned',
609
-								in_array($u,$assignees) !== in_array($u,$old_assignees) || $deleted))	// assignment changed
608
+							if ($this->send_notification($data, $old, $email, $u, 'notify_assigned',
609
+								in_array($u, $assignees) !== in_array($u, $old_assignees) || $deleted))	// assignment changed
610 610
 							{
611 611
 								$email_sent[] = $email;
612 612
 							}
@@ -617,14 +617,14 @@  discard block
 block discarded – undo
617 617
 		}
618 618
 
619 619
 		// notification copies
620
-		if (($copies = $this->get_config('copy',$data,$old)))
620
+		if (($copies = $this->get_config('copy', $data, $old)))
621 621
 		{
622
-			$lang = $this->get_config('lang',$data,$old);
623
-			foreach($copies as $email)
622
+			$lang = $this->get_config('lang', $data, $old);
623
+			foreach ($copies as $email)
624 624
 			{
625
-				if (strchr($email,'@') !== false && !in_array($email, $email_sent))
625
+				if (strchr($email, '@') !== false && !in_array($email, $email_sent))
626 626
 				{
627
-					if ($this->send_notification($data,$old,$email,$lang,'notify_copy'))
627
+					if ($this->send_notification($data, $old, $email, $lang, 'notify_copy'))
628 628
 					{
629 629
 						$email_sent[] = $email;
630 630
 					}
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 	 * @param boolean $deleted = null can be set to true to let the tracking know the item got deleted or undelted
670 670
 	 * @return boolean true on success or false if notification not requested or error (error-message is in $this->errors)
671 671
 	 */
672
-	public function send_notification($data,$old,$email,$user_or_lang,$check=null,$assignment_changed=true,$deleted=null)
672
+	public function send_notification($data, $old, $email, $user_or_lang, $check = null, $assignment_changed = true, $deleted = null)
673 673
 	{
674 674
 		//error_log(__METHOD__."(,,'$email',$user_or_lang,$check,$assignment_changed,$deleted)");
675 675
 		if (!$email) return false;
@@ -681,16 +681,16 @@  discard block
 block discarded – undo
681 681
 		{
682 682
 			$GLOBALS['egw_info']['user']['account_id'] = $user_or_lang;
683 683
 			$GLOBALS['egw']->preferences->__construct($user_or_lang);
684
-			$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository(false);	// no session prefs!
684
+			$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository(false); // no session prefs!
685 685
 
686 686
 			if ($check && $this->check2pref) $check = $this->check2pref[$check];
687 687
 
688
-			if ($check && !$GLOBALS['egw_info']['user']['preferences'][$this->app][$check] ||	// no notification requested
688
+			if ($check && !$GLOBALS['egw_info']['user']['preferences'][$this->app][$check] || // no notification requested
689 689
 				// only notification about changed assignment requested
690 690
 				$check && $GLOBALS['egw_info']['user']['preferences'][$this->app][$check] === 'assignment' && !$assignment_changed ||
691 691
 				$this->user == $user_or_lang && !$this->notify_current_user)  // no popup for own actions
692 692
 			{
693
-				$do_notify = false;	// no notification requested / necessary
693
+				$do_notify = false; // no notification requested / necessary
694 694
 			}
695 695
 		}
696 696
 		else
@@ -711,33 +711,33 @@  discard block
 block discarded – undo
711 711
 
712 712
 			// Cache message body to not have to re-generate it every time
713 713
 			$lang = translation::$userlang;
714
-			$date_format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] .
714
+			$date_format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].
715 715
 				$GLOBALS['egw_info']['user']['preferences']['common']['timeformat'];
716 716
 
717 717
 			// Cache text body
718
-			$body_cache =& $this->body_cache[$data[$this->id_field]][$lang][$date_format];
719
-			if(empty($data[$this->id_field]) || !isset($body_cache['text']))
718
+			$body_cache = & $this->body_cache[$data[$this->id_field]][$lang][$date_format];
719
+			if (empty($data[$this->id_field]) || !isset($body_cache['text']))
720 720
 			{
721
-				$body_cache['text'] = $this->get_body(false,$data,$old,false,$receiver);
721
+				$body_cache['text'] = $this->get_body(false, $data, $old, false, $receiver);
722 722
 			}
723 723
 			// Cache HTML body
724
-			if(empty($data[$this->id_field]) || !isset($body_cache['html']))
724
+			if (empty($data[$this->id_field]) || !isset($body_cache['html']))
725 725
 			{
726
-				$body_cache['html'] = $this->get_body(true,$data,$old,false,$receiver);
726
+				$body_cache['html'] = $this->get_body(true, $data, $old, false, $receiver);
727 727
 			}
728 728
 
729 729
 			// get rest of notification message
730
-			$sender = $this->get_sender($data,$old,true,$receiver);
731
-			$subject = $this->get_subject($data,$old,$deleted,$receiver);
732
-			$link = $this->get_notification_link($data,$old,$receiver);
733
-			$attachments = $this->get_attachments($data,$old,$receiver);
730
+			$sender = $this->get_sender($data, $old, true, $receiver);
731
+			$subject = $this->get_subject($data, $old, $deleted, $receiver);
732
+			$link = $this->get_notification_link($data, $old, $receiver);
733
+			$attachments = $this->get_attachments($data, $old, $receiver);
734 734
 		}
735 735
 
736 736
 		// restore user enviroment BEFORE calling notification class or returning
737 737
 		$GLOBALS['egw_info']['user'] = $save_user;
738 738
 		// need to call preferences constructor and read_repository, to set user timezone again
739 739
 		$GLOBALS['egw']->preferences->__construct($GLOBALS['egw_info']['user']['account_id']);
740
-		$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository(false);	// no session prefs!
740
+		$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository(false); // no session prefs!
741 741
 
742 742
 		// Re-load date/time preferences
743 743
 		egw_time::init();
@@ -793,11 +793,11 @@  discard block
 block discarded – undo
793 793
 	 *
794 794
 	 * @return string
795 795
 	 */
796
-	public function datetime($timestamp,$do_time=true)
796
+	public function datetime($timestamp, $do_time = true)
797 797
 	{
798
-		if (!is_a($timestamp,'DateTime'))
798
+		if (!is_a($timestamp, 'DateTime'))
799 799
 		{
800
-			$timestamp = new egw_time($timestamp,egw_time::$server_timezone);
800
+			$timestamp = new egw_time($timestamp, egw_time::$server_timezone);
801 801
 		}
802 802
 		$timestamp->setTimezone(egw_time::$user_timezone);
803 803
 		if (is_null($do_time))
@@ -823,23 +823,23 @@  discard block
 block discarded – undo
823 823
 	 * @param int|string $receiver nummeric account_id or email address
824 824
 	 * @return string or userid
825 825
 	 */
826
-	protected function get_sender($data,$old,$prefer_id=false,$receiver=null)
826
+	protected function get_sender($data, $old, $prefer_id = false, $receiver = null)
827 827
 	{
828
-		$sender = $this->get_config('sender',$data,$old);
828
+		$sender = $this->get_config('sender', $data, $old);
829 829
 		//echo "<p>bo_tracking::get_sender() get_config('sender',...)='".htmlspecialchars($sender)."'</p>\n";
830 830
 
831 831
 		if (($this->prefer_user_as_sender || !$sender) && $this->user &&
832
-			($email = $GLOBALS['egw']->accounts->id2name($this->user,'account_email')))
832
+			($email = $GLOBALS['egw']->accounts->id2name($this->user, 'account_email')))
833 833
 		{
834
-			$name = $GLOBALS['egw']->accounts->id2name($this->user,'account_fullname');
834
+			$name = $GLOBALS['egw']->accounts->id2name($this->user, 'account_fullname');
835 835
 
836
-			if($prefer_id) {
836
+			if ($prefer_id) {
837 837
 				$sender = $this->user;
838 838
 			} else {
839 839
 				$sender = $name ? $name.' <'.$email.'>' : $email;
840 840
 			}
841 841
 		}
842
-		elseif(!$sender)
842
+		elseif (!$sender)
843 843
 		{
844 844
 			$sender = 'eGroupWare '.lang($this->app).' <noreply@'.$GLOBALS['egw_info']['server']['mail_suffix'].'>';
845 845
 		}
@@ -854,9 +854,9 @@  discard block
 block discarded – undo
854 854
 	 * @param array $old
855 855
 	 * @return string
856 856
 	 */
857
-	protected function get_title($data,$old)
857
+	protected function get_title($data, $old)
858 858
 	{
859
-		return egw_link::title($this->app,$data[$this->id_field]);
859
+		return egw_link::title($this->app, $data[$this->id_field]);
860 860
 	}
861 861
 
862 862
 	/**
@@ -870,9 +870,9 @@  discard block
 block discarded – undo
870 870
 	 * @param int|string $receiver nummeric account_id or email address
871 871
 	 * @return string
872 872
 	 */
873
-	protected function get_subject($data,$old,$deleted=null,$receiver=null)
873
+	protected function get_subject($data, $old, $deleted = null, $receiver = null)
874 874
 	{
875
-		return egw_link::title($this->app,$data[$this->id_field]);
875
+		return egw_link::title($this->app, $data[$this->id_field]);
876 876
 	}
877 877
 
878 878
 	/**
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
 	 * @param int|string $receiver nummeric account_id or email address
886 886
 	 * @return string
887 887
 	 */
888
-	protected function get_message($data,$old,$receiver=null)
888
+	protected function get_message($data, $old, $receiver = null)
889 889
 	{
890 890
 		return '';
891 891
 	}
@@ -901,22 +901,22 @@  discard block
 block discarded – undo
901 901
 	 * @param int|string $receiver nummeric account_id or email address
902 902
 	 * @return string|array string with link (!$allow_popup) or array(link,popup-size), popup size is something like '640x480'
903 903
 	 */
904
-	protected function get_link($data,$old,$allow_popup=false,$receiver=null)
904
+	protected function get_link($data, $old, $allow_popup = false, $receiver = null)
905 905
 	{
906
-		if (($link = $this->get_config('link',$data,$old)))
906
+		if (($link = $this->get_config('link', $data, $old)))
907 907
 		{
908
-			if (!$this->get_config('link_no_id', $data) && strpos($link,$this->id_field.'=') === false && isset($data[$this->id_field]))
908
+			if (!$this->get_config('link_no_id', $data) && strpos($link, $this->id_field.'=') === false && isset($data[$this->id_field]))
909 909
 			{
910
-				$link .= strpos($link,'?') === false ? '?' : '&';
910
+				$link .= strpos($link, '?') === false ? '?' : '&';
911 911
 				$link .= $this->id_field.'='.$data[$this->id_field];
912 912
 			}
913 913
 		}
914 914
 		else
915 915
 		{
916
-			if (($view = egw_link::view($this->app,$data[$this->id_field])))
916
+			if (($view = egw_link::view($this->app, $data[$this->id_field])))
917 917
 			{
918
-				$link = $GLOBALS['egw']->link('/index.php',$view);
919
-				$popup = egw_link::is_popup($this->app,'view');
918
+				$link = $GLOBALS['egw']->link('/index.php', $view);
919
+				$popup = egw_link::is_popup($this->app, 'view');
920 920
 			}
921 921
 		}
922 922
 		if ($link[0] == '/')
@@ -927,12 +927,12 @@  discard block
 block discarded – undo
927 927
 		if (!$allow_popup)
928 928
 		{
929 929
 			// remove the session-id in the notification mail!
930
-			$link = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',$link);
930
+			$link = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/', '', $link);
931 931
 
932 932
 			if ($popup) $link .= '&nopopup=1';
933 933
 		}
934 934
 		//error_log(__METHOD__."(..., $allow_popup, $receiver) returning ".array2string($allow_popup ? array($link,$popup) : $link));
935
-		return $allow_popup ? array($link,$popup) : $link;
935
+		return $allow_popup ? array($link, $popup) : $link;
936 936
 	}
937 937
 
938 938
 	/**
@@ -943,16 +943,16 @@  discard block
 block discarded – undo
943 943
 	 * @param int|string $receiver nummeric account_id or email address
944 944
 	 * @return array with link
945 945
 	 */
946
-	protected function get_notification_link($data,$old,$receiver=null)
946
+	protected function get_notification_link($data, $old, $receiver = null)
947 947
 	{
948
-		if (($view = egw_link::view($this->app,$data[$this->id_field])))
948
+		if (($view = egw_link::view($this->app, $data[$this->id_field])))
949 949
 		{
950 950
 			return array(
951
-				'text' 	=> $this->get_title($data,$old),
951
+				'text' 	=> $this->get_title($data, $old),
952 952
 				'app'	=> $this->app,
953 953
 				'id'	=> $data[$this->id_field],
954 954
 				'view' 	=> $view,
955
-				'popup'	=> egw_link::is_popup($this->app,'view'),
955
+				'popup'	=> egw_link::is_popup($this->app, 'view'),
956 956
 			);
957 957
 		}
958 958
 		return false;
@@ -968,15 +968,15 @@  discard block
 block discarded – undo
968 968
 	 * @param int|string $receiver nummeric account_id or email address
969 969
 	 * @return string
970 970
 	 */
971
-	public function get_body($html_email,$data,$old,$integrate_link = true,$receiver=null)
971
+	public function get_body($html_email, $data, $old, $integrate_link = true, $receiver = null)
972 972
 	{
973 973
 		$body = '';
974
-		if($this->get_config(self::CUSTOM_NOTIFICATION, $data, $old))
974
+		if ($this->get_config(self::CUSTOM_NOTIFICATION, $data, $old))
975 975
 		{
976
-			$body = $this->get_custom_message($data,$old);
977
-			if(($sig = $this->get_signature($data,$old,$receiver)))
976
+			$body = $this->get_custom_message($data, $old);
977
+			if (($sig = $this->get_signature($data, $old, $receiver)))
978 978
 			{
979
-				$body .= ($html_email ? '<br />':'') . "\n$sig";
979
+				$body .= ($html_email ? '<br />' : '')."\n$sig";
980 980
 			}
981 981
 			return $body;
982 982
 		}
@@ -985,35 +985,35 @@  discard block
 block discarded – undo
985 985
 			$body = '<table cellspacing="2" cellpadding="0" border="0" width="100%">'."\n";
986 986
 		}
987 987
 		// new or modified message
988
-		if (($message = $this->get_message($data,$old,$receiver)))
988
+		if (($message = $this->get_message($data, $old, $receiver)))
989 989
 		{
990 990
 			foreach ((array)$message as $k => $_message)
991 991
 			{
992
-				$body .= $this->format_line($html_email,'message',false,($_message=='---'?($html_email?'<hr/>':$_message):$_message));
992
+				$body .= $this->format_line($html_email, 'message', false, ($_message == '---' ? ($html_email ? '<hr/>' : $_message) : $_message));
993 993
 			}
994 994
 		}
995
-		if ($integrate_link && ($link = $this->get_link($data,$old,false,$receiver)))
995
+		if ($integrate_link && ($link = $this->get_link($data, $old, false, $receiver)))
996 996
 		{
997
-			$body .= $this->format_line($html_email,'link',false,$integrate_link === true ? lang('You can respond by visiting:') : $integrate_link,$link);
997
+			$body .= $this->format_line($html_email, 'link', false, $integrate_link === true ? lang('You can respond by visiting:') : $integrate_link, $link);
998 998
 		}
999
-		foreach($this->get_details($data,$receiver) as $name => $detail)
999
+		foreach ($this->get_details($data, $receiver) as $name => $detail)
1000 1000
 		{
1001 1001
 			// if there's no old entry, the entry is not modified by definition
1002 1002
 			// if both values are '', 0 or null, we count them as equal too
1003 1003
 			$modified = $old && $data[$name] != $old[$name] && !(!$data[$name] && !$old[$name]);
1004 1004
 			//if ($modified) error_log("data[$name]=".print_r($data[$name],true).", old[$name]=".print_r($old[$name],true)." --> modified=".(int)$modified);
1005
-			if (empty($detail['value']) && !$modified) continue;	// skip unchanged, empty values
1005
+			if (empty($detail['value']) && !$modified) continue; // skip unchanged, empty values
1006 1006
 
1007
-			$body .= $this->format_line($html_email,$detail['type'],$modified,
1007
+			$body .= $this->format_line($html_email, $detail['type'], $modified,
1008 1008
 				$detail['label'] ? $detail['label'] : '', $detail['value']);
1009 1009
 		}
1010 1010
 		if ($html_email)
1011 1011
 		{
1012 1012
 			$body .= "</table>\n";
1013 1013
 		}
1014
-		if(($sig = $this->get_signature($data,$old,$receiver)))
1014
+		if (($sig = $this->get_signature($data, $old, $receiver)))
1015 1015
 		{
1016
-			$body .= ($html_email ? '<br />':'') . "\n$sig";
1016
+			$body .= ($html_email ? '<br />' : '')."\n$sig";
1017 1017
 		}
1018 1018
 		return $body;
1019 1019
 	}
@@ -1029,20 +1029,20 @@  discard block
 block discarded – undo
1029 1029
 	 * @param string $data = null data or null to display just $line over 2 columns
1030 1030
 	 * @return string
1031 1031
 	 */
1032
-	protected function format_line($html_mail,$type,$modified,$line,$data=null)
1032
+	protected function format_line($html_mail, $type, $modified, $line, $data = null)
1033 1033
 	{
1034 1034
 		//error_log(__METHOD__.'('.array2string($html_mail).",'$type',".array2string($modified).",'$line',".array2string($data).')');
1035 1035
 		$content = '';
1036 1036
 
1037 1037
 		if ($html_mail)
1038 1038
 		{
1039
-			if (!$this->html_content_allow) $line = html::htmlspecialchars($line);	// XSS
1039
+			if (!$this->html_content_allow) $line = html::htmlspecialchars($line); // XSS
1040 1040
 
1041 1041
 			$color = $modified ? 'red' : false;
1042 1042
 			$size  = '110%';
1043 1043
 			$bold = false;
1044 1044
 			$background = '#FFFFF1';
1045
-			switch($type)
1045
+			switch ($type)
1046 1046
 			{
1047 1047
 				case 'message':
1048 1048
 					$background = '#D3DCE3;';
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
 					if (strpos($data, '<br') === false)
1061 1061
 					{
1062 1062
 						$data = nl2br($this->html_content_allow ? $data : html::htmlspecialchars($data));
1063
-						$this->html_content_allow = true;	// to NOT do htmlspecialchars again
1063
+						$this->html_content_allow = true; // to NOT do htmlspecialchars again
1064 1064
 					}
1065 1065
 					break;
1066 1066
 				case 'reply':
@@ -1069,13 +1069,13 @@  discard block
 block discarded – undo
1069 1069
 				default:
1070 1070
 					$size = false;
1071 1071
 			}
1072
-			$style = ($bold ? 'font-weight:bold;' : '').($size ? 'font-size:'.$size.';' : '').($color?'color:'.$color:'');
1072
+			$style = ($bold ? 'font-weight:bold;' : '').($size ? 'font-size:'.$size.';' : '').($color ? 'color:'.$color : '');
1073 1073
 
1074
-			$content = '<tr style="background-color: '.$background.';"><td style="'.$style.($line && $data?'" width="20%':'" colspan="2').'">';
1074
+			$content = '<tr style="background-color: '.$background.';"><td style="'.$style.($line && $data ? '" width="20%' : '" colspan="2').'">';
1075 1075
 		}
1076 1076
 		else	// text-mail
1077 1077
 		{
1078
-			if ($type == 'reply') $content = str_repeat('-',64)."\n";
1078
+			if ($type == 'reply') $content = str_repeat('-', 64)."\n";
1079 1079
 
1080 1080
 			if ($modified) $content .= '> ';
1081 1081
 		}
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
 			if ($type == 'link')
1088 1088
 			{
1089 1089
 				// the link is often too long for html boxes chunk-split allows to break lines if needed
1090
-				$content .= html::a_href(chunk_split(rawurldecode($data),40,'&#8203;'),$data,'','target="_blank"');
1090
+				$content .= html::a_href(chunk_split(rawurldecode($data), 40, '&#8203;'), $data, '', 'target="_blank"');
1091 1091
 			}
1092 1092
 			elseif ($this->html_content_allow)
1093 1093
 			{
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 		}
1101 1101
 		else
1102 1102
 		{
1103
-			$content .= ($content&&$data?': ':'').$data;
1103
+			$content .= ($content && $data ? ': ' : '').$data;
1104 1104
 		}
1105 1105
 		if ($html_mail) $content .= '</td></tr>';
1106 1106
 
@@ -1117,7 +1117,7 @@  discard block
 block discarded – undo
1117 1117
 	 * @param int|string $receiver nummeric account_id or email address
1118 1118
 	 * @return array or array with values for either 'string' or 'path' and optionally (mime-)'type', 'filename' and 'encoding'
1119 1119
 	 */
1120
-	protected function get_attachments($data,$old,$receiver=null)
1120
+	protected function get_attachments($data, $old, $receiver = null)
1121 1121
 	{
1122 1122
 	 	return array();
1123 1123
 	}
@@ -1131,16 +1131,16 @@  discard block
 block discarded – undo
1131 1131
 	protected function get_signature($data, $old, $receiver)
1132 1132
 	{
1133 1133
 		$config = config::read('notifications');
1134
-		if(!isset($data[$this->id_field]))
1134
+		if (!isset($data[$this->id_field]))
1135 1135
 		{
1136
-			error_log($this->app . ' did not properly implement bo_tracking->id_field.  Merge skipped.');
1136
+			error_log($this->app.' did not properly implement bo_tracking->id_field.  Merge skipped.');
1137 1137
 		}
1138
-		elseif(class_exists($this->app. '_merge'))
1138
+		elseif (class_exists($this->app.'_merge'))
1139 1139
 		{
1140 1140
 			$merge_class = $this->app.'_merge';
1141 1141
 			$merge = new $merge_class();
1142 1142
 			$sig = $merge->merge_string($config['signature'], array($data[$this->id_field]), $error, 'text/html');
1143
-			if($error)
1143
+			if ($error)
1144 1144
 			{
1145 1145
 				error_log($error);
1146 1146
 				return $config['signature'];
@@ -1157,26 +1157,26 @@  discard block
 block discarded – undo
1157 1157
 	protected function get_custom_message($data, $old, $merge_class = null)
1158 1158
 	{
1159 1159
 		$message = $this->get_config(self::CUSTOM_NOTIFICATION, $data, $old);
1160
-		if(!$message)
1160
+		if (!$message)
1161 1161
 		{
1162 1162
 			return '';
1163 1163
 		}
1164 1164
 
1165 1165
 		// Automatically set merge class from naming conventions
1166
-		if($merge_class == null)
1166
+		if ($merge_class == null)
1167 1167
 		{
1168 1168
 			$merge_class = $this->app.'_merge';
1169 1169
 		}
1170
-		if(!isset($data[$this->id_field]))
1170
+		if (!isset($data[$this->id_field]))
1171 1171
 		{
1172
-			error_log($this->app . ' did not properly implement bo_tracking->id_field.  Merge skipped.');
1172
+			error_log($this->app.' did not properly implement bo_tracking->id_field.  Merge skipped.');
1173 1173
 			return $message;
1174 1174
 		}
1175
-		elseif(class_exists($merge_class))
1175
+		elseif (class_exists($merge_class))
1176 1176
 		{
1177 1177
 			$merge = new $merge_class();
1178 1178
 			$merged_message = $merge->merge_string($message, array($data[$this->id_field]), $error, 'text/html');
1179
-			if($error)
1179
+			if ($error)
1180 1180
 			{
1181 1181
 				error_log($error);
1182 1182
 				return $message;
Please login to merge, or discard this patch.
Braces   +157 added lines, -39 removed lines patch added patch discarded remove patch
@@ -236,7 +236,10 @@  discard block
 block discarded – undo
236 236
 			$header_done = false;
237 237
 			foreach($cfs as $name => $field)
238 238
 			{
239
-				if (in_array($field['type'], egw_customfields::$non_printable_fields)) continue;
239
+				if (in_array($field['type'], egw_customfields::$non_printable_fields))
240
+				{
241
+					continue;
242
+				}
240 243
 
241 244
 				if (!$header_done)
242 245
 				{
@@ -332,8 +335,14 @@  discard block
 block discarded – undo
332 335
 		{
333 336
 			//error_log(__METHOD__.__LINE__.' Field:'.$name. ' Value (new):'.array2string($data[$name]));
334 337
 			//error_log(__METHOD__.__LINE__.' Field:'.$name. ' Value (old):'.array2string($old[$name]));
335
-			if (is_array($data[$name]) && array_key_exists('id',$data[$name])) $data[$name] = $data[$name]['id'];
336
-			if (is_array($old[$name]) && array_key_exists('id',$old[$name])) $old[$name] = $old[$name]['id'];
338
+			if (is_array($data[$name]) && array_key_exists('id',$data[$name]))
339
+			{
340
+				$data[$name] = $data[$name]['id'];
341
+			}
342
+			if (is_array($old[$name]) && array_key_exists('id',$old[$name]))
343
+			{
344
+				$old[$name] = $old[$name]['id'];
345
+			}
337 346
 			//error_log(__METHOD__.__LINE__.'(After processing) Field:'.$name. ' Value (new):'.array2string($data[$name]));
338 347
 			//error_log(__METHOD__.__LINE__.'(After processing) Field:'.$name. ' Value (old):'.array2string($old[$name]));
339 348
 		}
@@ -347,11 +356,18 @@  discard block
 block discarded – undo
347 356
 			if (!($app = $this->cf_link_fields[$name]))
348 357
 			{
349 358
 				list($app,$id) = explode(':',$id);
350
-				if (!$id) continue;	// can be eg. 'addressbook:', if no contact selected
359
+				if (!$id)
360
+				{
361
+					continue;
362
+				}
363
+				// can be eg. 'addressbook:', if no contact selected
351 364
 			}
352 365
 			$source_id = $data[$this->id_field];
353 366
 			//error_log(__METHOD__.__LINE__.array2string($source_id));
354
-			if ($source_id) egw_link::link($this->app,$source_id,$app,$id);
367
+			if ($source_id)
368
+			{
369
+				egw_link::link($this->app,$source_id,$app,$id);
370
+			}
355 371
 			//error_log(__METHOD__.__LINE__."egw_link::link('$this->app',".array2string($source_id).",'$app',$id);");
356 372
 			//echo "<p>egw_link::link('$this->app',{$data[$this->id_field]},'$app',$id);</p>\n";
357 373
 		}
@@ -359,14 +375,24 @@  discard block
 block discarded – undo
359 375
 		// unlink removed application entries
360 376
 		foreach(array_diff($old_ids,$current_ids) as $name => $id)
361 377
 		{
362
-			if (!isset($data[$name])) continue;	// ignore not set link cf's, eg. from sync clients
378
+			if (!isset($data[$name]))
379
+			{
380
+				continue;
381
+			}
382
+			// ignore not set link cf's, eg. from sync clients
363 383
 			if (!($app = $this->cf_link_fields[$name]))
364 384
 			{
365 385
 				list($app,$id) = explode(':',$id);
366
-				if (!$id) continue;
386
+				if (!$id)
387
+				{
388
+					continue;
389
+				}
367 390
 			}
368 391
 			$source_id = $data[$this->id_field];
369
-			if ($source_id) egw_link::unlink(null,$this->app,$source_id,0,$app,$id);
392
+			if ($source_id)
393
+			{
394
+				egw_link::unlink(null,$this->app,$source_id,0,$app,$id);
395
+			}
370 396
 			//echo "<p>egw_link::unlink(NULL,'$this->app',{$data[$this->id_field]},0,'$app',$id);</p>\n";
371 397
 		}
372 398
 	}
@@ -389,7 +415,10 @@  discard block
 block discarded – undo
389 415
 			$changed_fields = self::changed_fields($data,$old);
390 416
 			//error_log(__METHOD__.__LINE__.' Changedfields:'.array2string($changed_fields));
391 417
 		}
392
-		if (!$changed_fields && ($old || !$GLOBALS['egw_info']['server']['log_user_agent_action'])) return 0;
418
+		if (!$changed_fields && ($old || !$GLOBALS['egw_info']['server']['log_user_agent_action']))
419
+		{
420
+			return 0;
421
+		}
393 422
 
394 423
 		if (!is_object($this->historylog) || $this->historylog->user != $this->user)
395 424
 		{
@@ -405,10 +434,13 @@  discard block
 block discarded – undo
405 434
 		{
406 435
 			$status = isset($this->field2history[$name]) ? $this->field2history[$name] : $name;
407 436
 			//error_log(__METHOD__.__LINE__." Name $name,".' Status:'.array2string($status));
408
-			if (is_array($status))	// 1:N relation --> remove common rows
437
+			if (is_array($status))
438
+			{
439
+				// 1:N relation --> remove common rows
409 440
 			{
410 441
 				//error_log(__METHOD__.__LINE__.' is Array');
411 442
 				self::compact_1_N_relation($data[$name],$status);
443
+			}
412 444
 				self::compact_1_N_relation($old[$name],$status);
413 445
 				$added = array_values(array_diff($data[$name],$old[$name]));
414 446
 				$removed = array_values(array_diff($old[$name],$data[$name]));
@@ -442,17 +474,31 @@  discard block
 block discarded – undo
442 474
 	 */
443 475
 	public function changed_fields(array $data,array $old=null)
444 476
 	{
445
-		if (is_null($old)) return array_keys($data);
477
+		if (is_null($old))
478
+		{
479
+			return array_keys($data);
480
+		}
446 481
 		$changed_fields = array();
447 482
 		foreach($this->field2history as $name => $status)
448 483
 		{
449
-			if (!$old[$name] && !$data[$name]) continue;	// treat all sorts of empty equally
484
+			if (!$old[$name] && !$data[$name])
485
+			{
486
+				continue;
487
+			}
488
+			// treat all sorts of empty equally
450 489
 
451
-			if ($name[0] == '#' && !isset($data[$name])) continue;	// no set customfields are not stored, therefore not changed
490
+			if ($name[0] == '#' && !isset($data[$name]))
491
+			{
492
+				continue;
493
+			}
494
+			// no set customfields are not stored, therefore not changed
452 495
 
453
-			if (is_array($status))	// 1:N relation
496
+			if (is_array($status))
497
+			{
498
+				// 1:N relation
454 499
 			{
455 500
 				self::compact_1_N_relation($data[$name],$status);
501
+			}
456 502
 				self::compact_1_N_relation($old[$name],$status);
457 503
 			}
458 504
 			if ($old[$name] != $data[$name])
@@ -460,13 +506,22 @@  discard block
 block discarded – undo
460 506
 				// normalize arrays, we do NOT care for the order of multiselections
461 507
 				if (is_array($data[$name]) || is_array($old[$name]))
462 508
 				{
463
-					if (!is_array($data[$name])) $data[$name] = explode(',',$data[$name]);
464
-					if (!is_array($old[$name])) $old[$name] = explode(',',$old[$name]);
509
+					if (!is_array($data[$name]))
510
+					{
511
+						$data[$name] = explode(',',$data[$name]);
512
+					}
513
+					if (!is_array($old[$name]))
514
+					{
515
+						$old[$name] = explode(',',$old[$name]);
516
+					}
465 517
 					if (count($data[$name]) == count($old[$name]))
466 518
 					{
467 519
 						sort($data[$name]);
468 520
 						sort($old[$name]);
469
-						if ($data[$name] == $old[$name]) continue;
521
+						if ($data[$name] == $old[$name])
522
+						{
523
+							continue;
524
+						}
470 525
 					}
471 526
 				}
472 527
 				elseif (str_replace("\r", '', $old[$name]) == str_replace("\r", '', $data[$name]))
@@ -527,13 +582,19 @@  discard block
 block discarded – undo
527 582
 	public function do_notifications($data,$old,$deleted=null,&$email_notified=null)
528 583
 	{
529 584
 		$this->errors = $email_sent = array();
530
-		if (!empty($email_notified) && is_array($email_notified)) $email_sent = $email_notified;
585
+		if (!empty($email_notified) && is_array($email_notified))
586
+		{
587
+			$email_sent = $email_notified;
588
+		}
531 589
 
532
-		if (!$this->notify_current_user && $this->user)		// do we have a current user and should we notify the current user about his own changes
590
+		if (!$this->notify_current_user && $this->user)
591
+		{
592
+			// do we have a current user and should we notify the current user about his own changes
533 593
 		{
534 594
 			//error_log("do_notificaton() adding user=$this->user to email_sent, to not notify him");
535 595
 			$email_sent[] = $GLOBALS['egw']->accounts->id2name($this->user,'account_email');
536 596
 		}
597
+		}
537 598
 		$skip_notify = $this->get_config('skip_notify',$data,$old);
538 599
 		if($skip_notify && is_array($skip_notify))
539 600
 		{
@@ -572,11 +633,14 @@  discard block
 block discarded – undo
572 633
 			//error_log("bo_tracking::do_notifications() data[$this->assigned_field]=".print_r($data[$this->assigned_field],true).", old[$this->assigned_field]=".print_r($old[$this->assigned_field],true));
573 634
 			$assignees = $old_assignees = array();
574 635
 			$assignees = $assigned ? $assigned : $assignees;
575
-			if ($data[$this->assigned_field])	// current assignments
636
+			if ($data[$this->assigned_field])
637
+			{
638
+				// current assignments
576 639
 			{
577 640
 				$assignees = is_array($data[$this->assigned_field]) ?
578 641
 					$data[$this->assigned_field] : explode(',',$data[$this->assigned_field]);
579 642
 			}
643
+			}
580 644
 			if ($old && $old[$this->assigned_field])
581 645
 			{
582 646
 				$old_assignees = is_array($old[$this->assigned_field]) ?
@@ -585,7 +649,10 @@  discard block
 block discarded – undo
585 649
 			foreach(array_unique(array_merge($assignees,$old_assignees)) as $assignee)
586 650
 			{
587 651
 				//error_log("bo_tracking::do_notifications() assignee=$assignee, type=".$GLOBALS['egw']->accounts->get_type($assignee).", email=".$GLOBALS['egw']->accounts->id2name($assignee,'account_email'));
588
-				if (!$assignee) continue;
652
+				if (!$assignee)
653
+				{
654
+					continue;
655
+				}
589 656
 
590 657
 				// item assignee is a user
591 658
 				if ($GLOBALS['egw']->accounts->get_type($assignee) == 'u')
@@ -593,10 +660,13 @@  discard block
 block discarded – undo
593 660
 					if (($email = $GLOBALS['egw']->accounts->id2name($assignee,'account_email')) && !in_array($email, $email_sent))
594 661
 					{
595 662
 						if ($this->send_notification($data,$old,$email,$assignee,'notify_assigned',
596
-							in_array($assignee,$assignees) !== in_array($assignee,$old_assignees) || $deleted))	// assignment changed
663
+							in_array($assignee,$assignees) !== in_array($assignee,$old_assignees) || $deleted))
664
+						{
665
+							// assignment changed
597 666
 						{
598 667
 							$email_sent[] = $email;
599 668
 						}
669
+						}
600 670
 					}
601 671
 				}
602 672
 				else	// item assignee is a group
@@ -606,10 +676,13 @@  discard block
 block discarded – undo
606 676
 						if (($email = $GLOBALS['egw']->accounts->id2name($u,'account_email')) && !in_array($email, $email_sent))
607 677
 						{
608 678
 							if ($this->send_notification($data,$old,$email,$u,'notify_assigned',
609
-								in_array($u,$assignees) !== in_array($u,$old_assignees) || $deleted))	// assignment changed
679
+								in_array($u,$assignees) !== in_array($u,$old_assignees) || $deleted))
680
+							{
681
+								// assignment changed
610 682
 							{
611 683
 								$email_sent[] = $email;
612 684
 							}
685
+							}
613 686
 						}
614 687
 					}
615 688
 				}
@@ -672,25 +745,38 @@  discard block
 block discarded – undo
672 745
 	public function send_notification($data,$old,$email,$user_or_lang,$check=null,$assignment_changed=true,$deleted=null)
673 746
 	{
674 747
 		//error_log(__METHOD__."(,,'$email',$user_or_lang,$check,$assignment_changed,$deleted)");
675
-		if (!$email) return false;
748
+		if (!$email)
749
+		{
750
+			return false;
751
+		}
676 752
 
677 753
 		$save_user = $GLOBALS['egw_info']['user'];
678 754
 		$do_notify = true;
679 755
 
680
-		if (is_numeric($user_or_lang))	// user --> read everything from his prefs
756
+		if (is_numeric($user_or_lang))
757
+		{
758
+			// user --> read everything from his prefs
681 759
 		{
682 760
 			$GLOBALS['egw_info']['user']['account_id'] = $user_or_lang;
761
+		}
683 762
 			$GLOBALS['egw']->preferences->__construct($user_or_lang);
684 763
 			$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository(false);	// no session prefs!
685 764
 
686
-			if ($check && $this->check2pref) $check = $this->check2pref[$check];
765
+			if ($check && $this->check2pref)
766
+			{
767
+				$check = $this->check2pref[$check];
768
+			}
687 769
 
688 770
 			if ($check && !$GLOBALS['egw_info']['user']['preferences'][$this->app][$check] ||	// no notification requested
689 771
 				// only notification about changed assignment requested
690 772
 				$check && $GLOBALS['egw_info']['user']['preferences'][$this->app][$check] === 'assignment' && !$assignment_changed ||
691
-				$this->user == $user_or_lang && !$this->notify_current_user)  // no popup for own actions
773
+				$this->user == $user_or_lang && !$this->notify_current_user)
692 774
 			{
693
-				$do_notify = false;	// no notification requested / necessary
775
+				// no popup for own actions
776
+			{
777
+				$do_notify = false;
778
+			}
779
+			// no notification requested / necessary
694 780
 			}
695 781
 		}
696 782
 		else
@@ -699,10 +785,13 @@  discard block
 block discarded – undo
699 785
 			$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->default_prefs();
700 786
 			$GLOBALS['egw_info']['user']['preferences']['common']['lang'] = $user_or_lang;
701 787
 		}
702
-		if ($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != translation::$userlang)	// load the right language if needed
788
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != translation::$userlang)
789
+		{
790
+			// load the right language if needed
703 791
 		{
704 792
 			translation::init();
705 793
 		}
794
+		}
706 795
 
707 796
 		if ($do_notify)
708 797
 		{
@@ -805,7 +894,10 @@  discard block
 block discarded – undo
805 894
 			$do_time = ($timestamp->format('Hi') != '0000');
806 895
 		}
807 896
 		$format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
808
-		if ($do_time) $format .= ' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] != 12 ? 'H:i' : 'h:i a');
897
+		if ($do_time)
898
+		{
899
+			$format .= ' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] != 12 ? 'H:i' : 'h:i a');
900
+		}
809 901
 
810 902
 		return $timestamp->format($format);
811 903
 	}
@@ -833,9 +925,12 @@  discard block
 block discarded – undo
833 925
 		{
834 926
 			$name = $GLOBALS['egw']->accounts->id2name($this->user,'account_fullname');
835 927
 
836
-			if($prefer_id) {
928
+			if($prefer_id)
929
+			{
837 930
 				$sender = $this->user;
838
-			} else {
931
+			}
932
+			else
933
+			{
839 934
 				$sender = $name ? $name.' <'.$email.'>' : $email;
840 935
 			}
841 936
 		}
@@ -929,7 +1024,10 @@  discard block
 block discarded – undo
929 1024
 			// remove the session-id in the notification mail!
930 1025
 			$link = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',$link);
931 1026
 
932
-			if ($popup) $link .= '&nopopup=1';
1027
+			if ($popup)
1028
+			{
1029
+				$link .= '&nopopup=1';
1030
+			}
933 1031
 		}
934 1032
 		//error_log(__METHOD__."(..., $allow_popup, $receiver) returning ".array2string($allow_popup ? array($link,$popup) : $link));
935 1033
 		return $allow_popup ? array($link,$popup) : $link;
@@ -1002,7 +1100,11 @@  discard block
 block discarded – undo
1002 1100
 			// if both values are '', 0 or null, we count them as equal too
1003 1101
 			$modified = $old && $data[$name] != $old[$name] && !(!$data[$name] && !$old[$name]);
1004 1102
 			//if ($modified) error_log("data[$name]=".print_r($data[$name],true).", old[$name]=".print_r($old[$name],true)." --> modified=".(int)$modified);
1005
-			if (empty($detail['value']) && !$modified) continue;	// skip unchanged, empty values
1103
+			if (empty($detail['value']) && !$modified)
1104
+			{
1105
+				continue;
1106
+			}
1107
+			// skip unchanged, empty values
1006 1108
 
1007 1109
 			$body .= $this->format_line($html_email,$detail['type'],$modified,
1008 1110
 				$detail['label'] ? $detail['label'] : '', $detail['value']);
@@ -1036,7 +1138,11 @@  discard block
 block discarded – undo
1036 1138
 
1037 1139
 		if ($html_mail)
1038 1140
 		{
1039
-			if (!$this->html_content_allow) $line = html::htmlspecialchars($line);	// XSS
1141
+			if (!$this->html_content_allow)
1142
+			{
1143
+				$line = html::htmlspecialchars($line);
1144
+			}
1145
+			// XSS
1040 1146
 
1041 1147
 			$color = $modified ? 'red' : false;
1042 1148
 			$size  = '110%';
@@ -1075,15 +1181,24 @@  discard block
 block discarded – undo
1075 1181
 		}
1076 1182
 		else	// text-mail
1077 1183
 		{
1078
-			if ($type == 'reply') $content = str_repeat('-',64)."\n";
1184
+			if ($type == 'reply')
1185
+			{
1186
+				$content = str_repeat('-',64)."\n";
1187
+			}
1079 1188
 
1080
-			if ($modified) $content .= '> ';
1189
+			if ($modified)
1190
+			{
1191
+				$content .= '> ';
1192
+			}
1081 1193
 		}
1082 1194
 		$content .= $line;
1083 1195
 
1084 1196
 		if ($html_mail)
1085 1197
 		{
1086
-			if ($line && $data) $content .= '</td><td style="'.$style.'">';
1198
+			if ($line && $data)
1199
+			{
1200
+				$content .= '</td><td style="'.$style.'">';
1201
+			}
1087 1202
 			if ($type == 'link')
1088 1203
 			{
1089 1204
 				// the link is often too long for html boxes chunk-split allows to break lines if needed
@@ -1102,7 +1217,10 @@  discard block
 block discarded – undo
1102 1217
 		{
1103 1218
 			$content .= ($content&&$data?': ':'').$data;
1104 1219
 		}
1105
-		if ($html_mail) $content .= '</td></tr>';
1220
+		if ($html_mail)
1221
+		{
1222
+			$content .= '</td></tr>';
1223
+		}
1106 1224
 
1107 1225
 		$content .= "\n";
1108 1226
 
Please login to merge, or discard this patch.
etemplate/inc/class.boetemplate.inc.php 4 patches
Doc Comments   +14 added lines, -25 removed lines patch added patch discarded remove patch
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @param string $disabled expression to check, eg. "!@var" for !$content['var']
105 105
 	 * @param array $content the content-array in the context of the grid
106
-	 * @param int $row=null to be able to use $row or $row_content in value of checks
107
-	 * @param int $c=null to be able to use $row or $row_content in value of checks
106
+	 * @param integer $row
107
+	 * @param integer $c
108 108
 	 * @return boolean true if the row/col is disabled or false if not
109 109
 	 */
110 110
 	protected function check_disabled($disabled,$content,$row=null,$c=null)
@@ -263,7 +263,6 @@  discard block
 block discarded – undo
263 263
 	 * As you usually have col- and row-headers, data-cells start with '1' or 'A' !!!
264 264
 	 *
265 265
 	 * @param array $cell with data of cell: name, type, size, ...
266
-	 * @param int $c,$r col/row index starting from 0
267 266
 	 * @param string &$idx returns the index in $content and $readonlys (NOT $sel_options !!!)
268 267
 	 * @param string &$idx_cname returns the basename for the form-name: is $idx if only one value
269 268
 	 *		(no ',') is given in size (name (not template-fields) are always only one value)
@@ -346,7 +345,7 @@  discard block
 block discarded – undo
346 345
 	 *  disables all cells with name == $name
347 346
 	 *
348 347
 	 * @param sting $name cell-name
349
-	 * @param boolean $disabled=true disable or enable a cell, default true=disable
348
+	 * @param boolean $disabled disable or enable a cell, default true=disable
350 349
 	 * @return mixed number of changed cells or False, if none changed
351 350
 	 */
352 351
 	function disableElement($name,$disabled=True)
@@ -387,8 +386,8 @@  discard block
 block discarded – undo
387 386
 	/**
388 387
 	 *  disables all cells with name == $name
389 388
 	 *
390
-	 * @param sting $name cell-name
391
-	 * @param boolean $disabled=true disable or enable a cell, default true=disable
389
+	 * @param string $name cell-name
390
+	 * @param boolean $disabled disable or enable a cell, default true=disable
392 391
 	 * @return reference to attribute
393 392
 	 * @deprecated use disableElement($name, $disabled=true)
394 393
 	 */
@@ -401,11 +400,10 @@  discard block
 block discarded – undo
401 400
 	 * set one or more attibutes for row $n
402 401
 	 *
403 402
 	 * @param int $n numerical row-number starting with 1 (!)
404
-	 * @param string $height percent or pixel or '' for no height
405
-	 * @param string $class name of css class (without the leading '.') or '' for no class
406
-	 * @param string $valign alignment (top,middle,bottom) or '' for none
407
-	 * @param boolean $disabled True or expression or False to disable or enable the row (Only the number 0 means dont change the attribute !!!)
408
-	 * @param string $path='/0' default is the first widget in the tree of children
403
+	 * @param integer $height percent or pixel or '' for no height
404
+	 * @param integer $class name of css class (without the leading '.') or '' for no class
405
+	 * @param integer $valign alignment (top,middle,bottom) or '' for none
406
+	 * @param integer $disabled True or expression or False to disable or enable the row (Only the number 0 means dont change the attribute !!!)
409 407
 	 * @return false if $path is no grid or array(height,class,valign,disabled) otherwise
410 408
 	 */
411 409
 	function set_row_attributes($n,$height=0,$class=0,$valign=0,$disabled=0,$path='/0')
@@ -432,8 +430,6 @@  discard block
 block discarded – undo
432 430
 	 * disables row $n
433 431
 	 *
434 432
 	 * @param int $n numerical row-number starting with 1 (!)
435
-	 * @param boolean $enable=false can be used to re-enable a row if set to True
436
-	 * @param string $path='/0' default is the first widget in the tree of children
437 433
 	 */
438 434
 	function disable_row($n,$enable=False,$path='/0')
439 435
 	{
@@ -444,9 +440,8 @@  discard block
 block discarded – undo
444 440
 	 * set one or more attibutes for column $c
445 441
 	 *
446 442
 	 * @param int|string $c numerical column-number starting with 0 (!), or the char-code starting with 'A'
447
-	 * @param string $width percent or pixel or '' for no height
448
-	 * @param mixed $disabled=0 True or expression or False to disable or enable the column (Only the number 0 means dont change the attribute !!!)
449
-	 * @param string $path='/0' default is the first widget in the tree of children
443
+	 * @param integer $width percent or pixel or '' for no height
444
+	 * @param mixed $disabled True or expression or False to disable or enable the column (Only the number 0 means dont change the attribute !!!)
450 445
 	 * @return false if $path specifies no grid or array(width,disabled) otherwise
451 446
 	 */
452 447
 	function set_column_attributes($c,$width=0,$disabled=0,$path='/0')
@@ -473,7 +468,6 @@  discard block
 block discarded – undo
473 468
 	 *
474 469
 	 * @param int|string $c numerical column-number starting with 0 (!), or the char-code starting with 'A'
475 470
 	 * @param boolean $enable can be used to re-enable a column if set to True
476
-	 * @param string $path='/0' default is the first widget in the tree of children
477 471
 	 */
478 472
 	function disable_column($c,$enable=False,$path='/0')
479 473
 	{
@@ -490,8 +484,6 @@  discard block
 block discarded – undo
490 484
 	/**
491 485
 	 * trys to load the Extension / Widget-class from the app or etemplate
492 486
 	 *
493
-	 * @param string $name name of the extension, the classname should be class.${name}_widget.inc.php
494
-	 *	the $name might be "$name.$app" to give a app-name (default is the current app,or template-name)
495 487
 	 * @return string|boolean human readable name or false if not found/loadable
496 488
 	 */
497 489
 	function loadExtension($type)
@@ -527,8 +519,6 @@  discard block
 block discarded – undo
527 519
 	/**
528 520
 	 * checks if extension is loaded (load it if it isnt) and optional checks if it has a given method
529 521
 	 *
530
-	 * @param string $name name of the extension, the classname should be class.${name}_widget.inc.php
531
-	 *	the $name might be "$name.$app" to give a app-name (default is the current app,or template-name)
532 522
 	 * @param string $function 'pre_process', 'post_process' or 'render'
533 523
 	 * @return boolean true if the extension (incl. method) exists, else false
534 524
 	 */
@@ -782,7 +772,7 @@  discard block
 block discarded – undo
782 772
 	 * For the 3. Column in the 2. row of a grid which is the only widget in the children-tree it is eg.: "/0/2C"
783 773
 	 *
784 774
 	 * @param string $path path in the widget tree
785
-	 * @param int $ancestor=0 0: widget itself, 1: parent, 2: grand-parent, ...
775
+	 * @param int $ancestor 0: widget itself, 1: parent, 2: grand-parent, ...
786 776
 	 * @return array referenz to the widget spezified or null, if it's not found
787 777
 	 */
788 778
 	function &get_widget_by_path($path,$ancestor=0)
@@ -838,9 +828,9 @@  discard block
 block discarded – undo
838 828
 	 * - csv_split('"a""b,c",d') === array('a"b,c','d')	// to escape enclosures double them!
839 829
 	 *
840 830
 	 * @param string $str
841
-	 * @param int $num=null in how many parts to split maximal, parts over this number end up (unseparated) in the last part
842 831
 	 * @param string $delimiter=','
843 832
 	 * @param string $enclosure='"'
833
+	 * @param integer $num
844 834
 	 * @return array
845 835
 	 */
846 836
 	static function csv_split($str,$num=null,$delimiter=',',$enclosure='"')
@@ -908,8 +898,7 @@  discard block
 block discarded – undo
908 898
 	/**
909 899
 	 * stores the etemplate in the cache in egw_info
910 900
 	 *
911
-	 * @param boetemplate $tpl=null required parameter for static use!
912
-	 * @param boolean $only_update_older=false true only update cache, if it contains an older template
901
+	 * @param boolean $only_update_older true only update cache, if it contains an older template
913 902
 	 */
914 903
 	public /*static*/ function store_in_cache(boetemplate $tpl=null, $only_update_older=false)
915 904
 	{
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -927,8 +927,8 @@
 block discarded – undo
927 927
 	}
928 928
 
929 929
 	/**
930
-	* deletes the etemplate in the cache
931
-	*/
930
+	 * deletes the etemplate in the cache
931
+	 */
932 932
 	private function delete_in_cache()
933 933
 	{
934 934
 		//echo "<p>".__METHOD__."('$this->name','$this->template','$this->lang','$this->version')</p>\n";
Please login to merge, or discard this patch.
Spacing   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -22,34 +22,34 @@  discard block
 block discarded – undo
22 22
 	 * @var array intern name => label
23 23
 	 */
24 24
 	static public $types = array(
25
-		'label'	=> 'Label',			// Label $cell['label'] is (to be translated) textual content
26
-		'text'	=> 'Text',			// Textfield 1 Line (size = [length][,maxlength])
27
-		'int'	=> 'Integer',		// like text, but only numbers (size = [min][,max])
25
+		'label'	=> 'Label', // Label $cell['label'] is (to be translated) textual content
26
+		'text'	=> 'Text', // Textfield 1 Line (size = [length][,maxlength])
27
+		'int'	=> 'Integer', // like text, but only numbers (size = [min][,max])
28 28
 		'float'	=> 'Floating Point', // --------------- " --------------------------
29
-		'textarea'=> 'Textarea',	// Multiline Text Input (size = [rows][,cols])
29
+		'textarea'=> 'Textarea', // Multiline Text Input (size = [rows][,cols])
30 30
 		'htmlarea' => 'Formatted Text (HTML)',
31 31
 		'checkbox'=> 'Checkbox',
32
-		'radio'	=> 'Radiobutton',	// Radiobutton (size = value if checked)
32
+		'radio'	=> 'Radiobutton', // Radiobutton (size = value if checked)
33 33
 		'button'=> 'Submitbutton',
34
-		'buttononly' => 'Button',	// input type="button"
34
+		'buttononly' => 'Button', // input type="button"
35 35
 		'hrule'	=> 'Horizontal Rule',
36
-		'template' => 'Template',	// $cell['name'] contains template-name, $cell['size'] index into $content,$cname,$readonlys
37
-		'image'	=> 'Image',			// label = url, name=link or method, help=alt or title
38
-		'progress' => 'Progressbar',// for BC, identical to image with percent value
39
-		'date'	=> '', 				// Datefield, size='' timestamp or size=format like 'm/d/Y'
40
-		'select'=>	'Selectbox',	// Selectbox ($sel_options[$name] or $content[options-$name] is array with options)
36
+		'template' => 'Template', // $cell['name'] contains template-name, $cell['size'] index into $content,$cname,$readonlys
37
+		'image'	=> 'Image', // label = url, name=link or method, help=alt or title
38
+		'progress' => 'Progressbar', // for BC, identical to image with percent value
39
+		'date'	=> '', // Datefield, size='' timestamp or size=format like 'm/d/Y'
40
+		'select'=>	'Selectbox', // Selectbox ($sel_options[$name] or $content[options-$name] is array with options)
41 41
 									// if size > 1 then multiple selections, size lines showed
42
-		'html'	=> 'Html',			// Raw html in $content[$cell['name']]
43
-		'file'	=> 'FileUpload',	// show an input type='file', set the local name as ${name}_path
44
-		'vbox'	=> 'VBox',			// a (vertical) box to contain widgets in rows, size = # of rows
45
-		'hbox'	=> 'HBox',			// a (horizontal) box to contain widgets in cols, size = # of cols
46
-		'groupbox' => 'GroupBox',	// a box with a label containing other elements to group them (html: fieldset)
47
-		'box'	=> 'Box',			// just a container for widgets (html: div)
48
-		'grid'	=> 'Grid',			// tabular widget containing rows with columns of widgets
49
-		'deck'	=> 'Deck',			// a container of elements where only one is visible, size = # of elem.
50
-		'passwd' => 'Password',		// a text of type password
51
-		'colorpicker' => 'Colorpicker',	// input for a color (eg. #123456)
52
-		'hidden'=> 'Hidden input',	// a hidden input eg. to submit javascript computed values back
42
+		'html'	=> 'Html', // Raw html in $content[$cell['name']]
43
+		'file'	=> 'FileUpload', // show an input type='file', set the local name as ${name}_path
44
+		'vbox'	=> 'VBox', // a (vertical) box to contain widgets in rows, size = # of rows
45
+		'hbox'	=> 'HBox', // a (horizontal) box to contain widgets in cols, size = # of cols
46
+		'groupbox' => 'GroupBox', // a box with a label containing other elements to group them (html: fieldset)
47
+		'box'	=> 'Box', // just a container for widgets (html: div)
48
+		'grid'	=> 'Grid', // tabular widget containing rows with columns of widgets
49
+		'deck'	=> 'Deck', // a container of elements where only one is visible, size = # of elem.
50
+		'passwd' => 'Password', // a text of type password
51
+		'colorpicker' => 'Colorpicker', // input for a color (eg. #123456)
52
+		'hidden'=> 'Hidden input', // a hidden input eg. to submit javascript computed values back
53 53
 	);
54 54
 
55 55
 	/**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @param string|array $name name of etemplate or array with name and other keys
77 77
 	 * @param string|array $load_via name or array with keys of other etemplate to load in order to get $name
78 78
 	 */
79
-	function __construct($name='',$load_via='')
79
+	function __construct($name = '', $load_via = '')
80 80
 	{
81 81
 		parent::__construct();
82 82
 
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
 		{
86 86
 			$tname = &$name['name'];
87 87
 		}
88
-		$tname = (strpos($tname,'.') === false && !empty($tname) ?
89
-			(is_array($load_via) ? $load_via['name'] : $load_via).'.':'').$tname;
88
+		$tname = (strpos($tname, '.') === false && !empty($tname) ?
89
+			(is_array($load_via) ? $load_via['name'] : $load_via).'.' : '').$tname;
90 90
 
91
-		if (empty($tname) || !$this->read($name,'','',0,'',$load_via))
91
+		if (empty($tname) || !$this->read($name, '', '', 0, '', $load_via))
92 92
 		{
93 93
 			$this->init($name);
94 94
 		}
@@ -107,22 +107,22 @@  discard block
 block discarded – undo
107 107
 	 * @param int $c=null to be able to use $row or $row_content in value of checks
108 108
 	 * @return boolean true if the row/col is disabled or false if not
109 109
 	 */
110
-	protected function check_disabled($disabled,$content,$row=null,$c=null)
110
+	protected function check_disabled($disabled, $content, $row = null, $c = null)
111 111
 	{
112 112
 		if ($this->onclick_handler && !$this->no_onclick)
113 113
 		{
114
-			return false;	// we have an onclick handler
114
+			return false; // we have an onclick handler
115 115
 		}
116 116
 		if ($not = $disabled[0] == '!')
117 117
 		{
118
-			$disabled = substr($disabled,1);
118
+			$disabled = substr($disabled, 1);
119 119
 		}
120
-		list($val,$check_val) = $vals = explode('=',$disabled);
120
+		list($val, $check_val) = $vals = explode('=', $disabled);
121 121
 
122 122
 		// use expand_name to be able to use @ or $
123
-		$val = $this->expand_name($val,$c,$row,'','',$content);
124
-		$check_val = $this->expand_name($check_val,$c,$row,'','',$content);
125
-		$result = count($vals) == 1 ? $val != '' : ($check_val[0] == '/' ? preg_match($check_val,$val) : $val == $check_val);
123
+		$val = $this->expand_name($val, $c, $row, '', '', $content);
124
+		$check_val = $this->expand_name($check_val, $c, $row, '', '', $content);
125
+		$result = count($vals) == 1 ? $val != '' : ($check_val[0] == '/' ? preg_match($check_val, $val) : $val == $check_val);
126 126
 		if ($not) $result = !$result;
127 127
 		//echo "<p>check_disabled: '".($not?'!':'')."$disabled' = '$val' ".(count($vals) == 1 ? '' : ($not?'!':'=')."= '$check_val'")." = ".($result?'True':'False')."</p>\n";
128 128
 		return $result;
@@ -163,69 +163,69 @@  discard block
 block discarded – undo
163 163
 	 * 	"del[$cont[id]]" expands to "del[123]" if $cont = array('id' => 123)
164 164
 	 * @return string the expanded name
165 165
 	 */
166
-	static function expand_name($name,$c,$row,$c_='',$row_='',$cont='')
166
+	static function expand_name($name, $c, $row, $c_ = '', $row_ = '', $cont = '')
167 167
 	{
168 168
 		$is_index_in_content = $name[0] == '@';
169
-		if (($pos_var=strpos($name,'$')) !== false)
169
+		if (($pos_var = strpos($name, '$')) !== false)
170 170
 		{
171 171
 			if (!$cont)
172 172
 			{
173 173
 				$cont = array();
174 174
 			}
175 175
 			if (!is_numeric($c)) $c = boetemplate::chrs2num($c);
176
-			$col = boetemplate::num2chrs($c-1);	// $c-1 to get: 0:'@', 1:'A', ...
177
-			$col_ = boetemplate::num2chrs($c_-1);
176
+			$col = boetemplate::num2chrs($c - 1); // $c-1 to get: 0:'@', 1:'A', ...
177
+			$col_ = boetemplate::num2chrs($c_ - 1);
178 178
 			$row_cont = $cont[$row];
179 179
 			$col_row_cont = $cont[$col.$row];
180 180
 
181 181
 			// check if name is enclosed in single quotes as argument eg. to an event handler or
182 182
 			// variable name is contained in quotes and curly brackets, eg. "'{$cont[nm][path]}'" or
183 183
 			// used as name for a button like "delete[$row_cont[something]]" --> quote contained quotes (' or ")
184
-			if (in_array($name[$pos_var-1],array('[',"'",'{')) && preg_match('/[\'\[]{?('.self::PHP_VAR_PREG.')}?[\'\]]+/',$name,$matches))
184
+			if (in_array($name[$pos_var - 1], array('[', "'", '{')) && preg_match('/[\'\[]{?('.self::PHP_VAR_PREG.')}?[\'\]]+/', $name, $matches))
185 185
 			{
186
-				if (eval($code='$value = '.$matches[1].';') === false)
186
+				if (eval($code = '$value = '.$matches[1].';') === false)
187 187
 				{
188 188
 					error_log(__METHOD__."(name='$name', c='$c', row=$row, c_='$c_', row_=$row_, ...) line ".__LINE__." ERROR parsing: $code");
189 189
 					error_log(function_backtrace());
190 190
 				}
191
-				if (is_array($value) && $name[$pos_var-1] == "'")	// arrays are only supported for '
191
+				if (is_array($value) && $name[$pos_var - 1] == "'")	// arrays are only supported for '
192 192
 				{
193
-					foreach($value as &$val)
193
+					foreach ($value as &$val)
194 194
 					{
195
-						$val = "'".str_replace(array("'",'"'),array('\\\'','&quot;'),$val)."'";
195
+						$val = "'".str_replace(array("'", '"'), array('\\\'', '&quot;'), $val)."'";
196 196
 					}
197
-					$value = '[ '.implode(', ',$value).' ]';
198
-					$name = str_replace("'".$matches[1]."'",$value,$name);
197
+					$value = '[ '.implode(', ', $value).' ]';
198
+					$name = str_replace("'".$matches[1]."'", $value, $name);
199 199
 				}
200 200
 				else
201 201
 				{
202
-					$value = str_replace(array("'",'"','[',']'),array('\\\'','&quot;','&#x5B;','&#x5D;'),$value);
203
-					$name = str_replace(array('{'.$matches[1].'}',$matches[1]),$value,$name);
202
+					$value = str_replace(array("'", '"', '[', ']'), array('\\\'', '&quot;', '&#x5B;', '&#x5D;'), $value);
203
+					$name = str_replace(array('{'.$matches[1].'}', $matches[1]), $value, $name);
204 204
 				}
205 205
 			}
206 206
 			// check if name is assigned in an url --> urlendcode contained & as %26, as egw::link explodes it on &
207
-			if ($name[$pos_var-1] == '=' && preg_match('/[&?]([A-Za-z0-9_]+(\[[A-Za-z0-9_]+\])*)=('.self::PHP_VAR_PREG.')/',$name,$matches))
207
+			if ($name[$pos_var - 1] == '=' && preg_match('/[&?]([A-Za-z0-9_]+(\[[A-Za-z0-9_]+\])*)=('.self::PHP_VAR_PREG.')/', $name, $matches))
208 208
 			{
209
-				if (eval($code='$value = '.$matches[3].';') === false)
209
+				if (eval($code = '$value = '.$matches[3].';') === false)
210 210
 				{
211 211
 					error_log(__METHOD__."(name='$name', c='$c', row=$row, c_='$c_', row_=$row_, ...) line ".__LINE__." ERROR parsing: $code");
212 212
 					error_log(function_backtrace());
213 213
 				}
214 214
 				if (is_array($value))	// works only reasonable, if get-parameter uses array notation, eg. &file[]=$cont[filenames]
215 215
 				{
216
-					foreach($value as &$val)
216
+					foreach ($value as &$val)
217 217
 					{
218
-						$val = str_replace('&',urlencode('&'),$val);
218
+						$val = str_replace('&', urlencode('&'), $val);
219 219
 					}
220
-					$name = str_replace($matches[3],implode('&'.$matches[1].'=',$value),$name);
220
+					$name = str_replace($matches[3], implode('&'.$matches[1].'=', $value), $name);
221 221
 				}
222 222
 				else
223 223
 				{
224
-					$value = str_replace('&',urlencode('&'),$value);
225
-					$name = str_replace($matches[3],$value,$name);
224
+					$value = str_replace('&', urlencode('&'), $value);
225
+					$name = str_replace($matches[3], $value, $name);
226 226
 				}
227 227
 			}
228
-			if (eval($code='$name = "'.str_replace(array('\\', '"'), array('\\\\', '\\"'),
228
+			if (eval($code = '$name = "'.str_replace(array('\\', '"'), array('\\\\', '\\"'),
229 229
 				// fix non-fatal PHP Parse error, when $j was used eg. in onload
230 230
 				str_replace(array('$j.', '$j('), array('jQuery.', 'jQuery('), $name)).'";') === false)
231 231
 			{
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
 		{
238 238
 			if ($name[1] == '@')
239 239
 			{
240
-				$name = self::get_array(self::$request->content,substr($name,2));
240
+				$name = self::get_array(self::$request->content, substr($name, 2));
241 241
 			}
242 242
 			else
243 243
 			{
244
-				$name = self::get_array($cont,substr($name,1));
244
+				$name = self::get_array($cont, substr($name, 1));
245 245
 			}
246 246
 		}
247 247
 		return $name;
@@ -270,40 +270,40 @@  discard block
 block discarded – undo
270 270
 	 * @param boolean $check_col to check for col- or row-autorepeat
271 271
 	 * @return boolean true if cell is autorepeat (has index with vars / '$') or false otherwise
272 272
 	 */
273
-	function autorepeat_idx($cell,$c,$r,&$idx,&$idx_cname,$check_col=False,$cont=null)
273
+	function autorepeat_idx($cell, $c, $r, &$idx, &$idx_cname, $check_col = False, $cont = null)
274 274
 	{
275
-		$org_idx = $idx = $cell[ $cell['type'] == 'template' ? 'size' : 'name' ];
275
+		$org_idx = $idx = $cell[$cell['type'] == 'template' ? 'size' : 'name'];
276 276
 
277
-		$idx = $this->expand_name($idx,$c,$r,'','',$cont);
278
-		if (!($komma = strpos($idx,',')))
277
+		$idx = $this->expand_name($idx, $c, $r, '', '', $cont);
278
+		if (!($komma = strpos($idx, ',')))
279 279
 		{
280 280
 			$idx_cname = $idx;
281 281
 		}
282 282
 		else
283 283
 		{
284
-			$idx_cname = substr($idx,1+$komma);
285
-			$idx = substr($idx,0,$komma);
284
+			$idx_cname = substr($idx, 1 + $komma);
285
+			$idx = substr($idx, 0, $komma);
286 286
 		}
287 287
 		$Ok = False;
288 288
 		$pat = $org_idx;
289
-		while (!$Ok && ($pat = @strstr($pat,'$')))
289
+		while (!$Ok && ($pat = @strstr($pat, '$')))
290 290
 		{
291
-			$pat = substr($pat,$pat[1] == '{' ? 2 : 1);
291
+			$pat = substr($pat, $pat[1] == '{' ? 2 : 1);
292 292
 
293 293
 			if ($check_col)
294 294
 			{
295
-				$Ok = $pat[0] == 'c' && !(substr($pat,0,4) == 'cont' ||
296
-						substr($pat,0,2) == 'c_' || substr($pat,0,4) == 'col_');
295
+				$Ok = $pat[0] == 'c' && !(substr($pat, 0, 4) == 'cont' ||
296
+						substr($pat, 0, 2) == 'c_' || substr($pat, 0, 4) == 'col_');
297 297
 			}
298 298
 			else
299 299
 			{
300
-				$Ok = $pat[0] == 'r' && !(substr($pat,0,2) == 'r_' ||
301
-					substr($pat,0,4) == 'row_');
300
+				$Ok = $pat[0] == 'r' && !(substr($pat, 0, 2) == 'r_' ||
301
+					substr($pat, 0, 4) == 'row_');
302 302
 			}
303 303
 		}
304 304
 		if ($this->name && $this->name == $this->debug)
305 305
 		{
306
-			echo "$this->name ".($check_col ? 'col' : 'row')."-check: c=$c, r=$r, idx='$org_idx'='$idx' idx_cname='$idx_cname' ==> ".($Ok?'True':'False')."<p>\n";
306
+			echo "$this->name ".($check_col ? 'col' : 'row')."-check: c=$c, r=$r, idx='$org_idx'='$idx' idx_cname='$idx_cname' ==> ".($Ok ? 'True' : 'False')."<p>\n";
307 307
 		}
308 308
 		return $Ok;
309 309
 	}
@@ -315,9 +315,9 @@  discard block
 block discarded – undo
315 315
 	 * @param string $attr attribute-name
316 316
 	 * @return mixed the attribute or False if named cell not found
317 317
 	 */
318
-	function &getElementAttribute($name,$attr)
318
+	function &getElementAttribute($name, $attr)
319 319
 	{
320
-		return $this->setElementAttribute($name,$attr,NULL);
320
+		return $this->setElementAttribute($name, $attr, NULL);
321 321
 	}
322 322
 
323 323
 	/**
@@ -328,12 +328,12 @@  discard block
 block discarded – undo
328 328
 	 * @param mixed $val if not NULL sets attribute else returns it
329 329
 	 * @return mixed number of changed cells or False, if none changed
330 330
 	 */
331
-	function &setElementAttribute($name,$attr,$val)
331
+	function &setElementAttribute($name, $attr, $val)
332 332
 	{
333 333
 		//echo "<p>set_cell_attribute(tpl->name=$this->name, name='$name', attr='$attr',val='$val')</p>\n";
334 334
 
335
-		$extra = array(false,$name,$attr,$val);
336
-		$result =& $this->widget_tree_walk('set_cell_attribute_helper',$extra);
335
+		$extra = array(false, $name, $attr, $val);
336
+		$result = & $this->widget_tree_walk('set_cell_attribute_helper', $extra);
337 337
 
338 338
 		if (is_null($val))
339 339
 		{
@@ -349,9 +349,9 @@  discard block
 block discarded – undo
349 349
 	 * @param boolean $disabled=true disable or enable a cell, default true=disable
350 350
 	 * @return mixed number of changed cells or False, if none changed
351 351
 	 */
352
-	function disableElement($name,$disabled=True)
352
+	function disableElement($name, $disabled = True)
353 353
 	{
354
-		return $this->set_cell_attribute($name,'disabled',$disabled);
354
+		return $this->set_cell_attribute($name, 'disabled', $disabled);
355 355
 	}
356 356
 
357 357
 	/**
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	 * @return mixed reference to attribute, usually NULL
366 366
 	 * @deprecated use getElementAttribute($name, $attr)
367 367
 	 */
368
-	public function &get_cell_attribute($name,$attr)
368
+	public function &get_cell_attribute($name, $attr)
369 369
 	{
370 370
 		return self::getElementAttribute($name, $attr);
371 371
 	}
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 	 * @return reference to attribute
380 380
 	 * @deprecated use setElementAttribute($name, $attr, $val)
381 381
 	 */
382
-	public function &set_cell_attribute($name,$attr,$val)
382
+	public function &set_cell_attribute($name, $attr, $val)
383 383
 	{
384 384
 		return self::setElementAttribute($name, $attr, $val);
385 385
 	}
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 	 * @return reference to attribute
393 393
 	 * @deprecated use disableElement($name, $disabled=true)
394 394
 	 */
395
-	public function disable_cells($name,$disabled=True)
395
+	public function disable_cells($name, $disabled = True)
396 396
 	{
397 397
 		return self::disableElement($name, $disabled);
398 398
 	}
@@ -408,24 +408,24 @@  discard block
 block discarded – undo
408 408
 	 * @param string $path='/0' default is the first widget in the tree of children
409 409
 	 * @return false if $path is no grid or array(height,class,valign,disabled) otherwise
410 410
 	 */
411
-	function set_row_attributes($n,$height=0,$class=0,$valign=0,$disabled=0,$path='/0')
411
+	function set_row_attributes($n, $height = 0, $class = 0, $valign = 0, $disabled = 0, $path = '/0')
412 412
 	{
413
-		$grid =& $this->get_widget_by_path($path);
413
+		$grid = & $this->get_widget_by_path($path);
414 414
 		if (is_null($grid) || $grid['type'] != 'grid') return false;
415
-		$grid_attr =& $grid['data'][0];
415
+		$grid_attr = & $grid['data'][0];
416 416
 
417
-		list($old_height,$old_disabled) = explode(',',$grid_attr["h$n"]);
417
+		list($old_height, $old_disabled) = explode(',', $grid_attr["h$n"]);
418 418
 		$disabled = $disabled !== 0 ? $disabled : $old_disabled;
419 419
 		$grid_attr["h$n"] = ($height !== 0 ? $height : $old_height).
420 420
 			($disabled ? ','.$disabled : '');
421
-		list($old_class,$old_valign) = explode(',',$grid_attr["c$n"]);
421
+		list($old_class, $old_valign) = explode(',', $grid_attr["c$n"]);
422 422
 		$valign = $valign !== 0 ? $valign : $old_valign;
423 423
 		$grid_attr["c$n"] = ($class !== 0 ? $class : $old_class).
424 424
 			($valign ? ','.$valign : '');
425 425
 
426
-		list($height,$disabled) = explode(',',$grid_attr["h$n"]);
427
-		list($class,$valign) = explode(',',$grid_attr["c$n"]);
428
-		return array($height,$class,$valign,$disabled);
426
+		list($height, $disabled) = explode(',', $grid_attr["h$n"]);
427
+		list($class, $valign) = explode(',', $grid_attr["c$n"]);
428
+		return array($height, $class, $valign, $disabled);
429 429
 	}
430 430
 
431 431
 	/**
@@ -435,9 +435,9 @@  discard block
 block discarded – undo
435 435
 	 * @param boolean $enable=false can be used to re-enable a row if set to True
436 436
 	 * @param string $path='/0' default is the first widget in the tree of children
437 437
 	 */
438
-	function disable_row($n,$enable=False,$path='/0')
438
+	function disable_row($n, $enable = False, $path = '/0')
439 439
 	{
440
-		$this->set_row_attributes($n,0,0,0,!$enable,$path);
440
+		$this->set_row_attributes($n, 0, 0, 0, !$enable, $path);
441 441
 	}
442 442
 
443 443
 	/**
@@ -449,23 +449,23 @@  discard block
 block discarded – undo
449 449
 	 * @param string $path='/0' default is the first widget in the tree of children
450 450
 	 * @return false if $path specifies no grid or array(width,disabled) otherwise
451 451
 	 */
452
-	function set_column_attributes($c,$width=0,$disabled=0,$path='/0')
452
+	function set_column_attributes($c, $width = 0, $disabled = 0, $path = '/0')
453 453
 	{
454 454
 		if (is_numeric($c))
455 455
 		{
456 456
 			$c = $this->num2chrs($c);
457 457
 		}
458
-		$grid =& $this->get_widget_by_path($path);
458
+		$grid = & $this->get_widget_by_path($path);
459 459
 		if (is_null($grid) || $grid['type'] != 'grid') return false;
460
-		$grid_attr =& $grid['data'][0];
460
+		$grid_attr = & $grid['data'][0];
461 461
 
462
-		list($old_width,$old_disabled) = explode(',',$grid_attr[$c]);
462
+		list($old_width, $old_disabled) = explode(',', $grid_attr[$c]);
463 463
 		$disabled = $disabled !== 0 ? $disabled : $old_disabled;
464 464
 		$grid_attr[$c] = ($width !== 0 ? $width : $old_width).
465 465
 			($disabled ? ','.$disabled : '');
466 466
 
467 467
 		//echo "set_column_attributes('$c',,'$path'): ".$grid_attr[$c]."</p>\n"; _debug_array($grid_attr);
468
-		return explode(',',$grid_attr[$c]);
468
+		return explode(',', $grid_attr[$c]);
469 469
 	}
470 470
 
471 471
 	/**
@@ -475,9 +475,9 @@  discard block
 block discarded – undo
475 475
 	 * @param boolean $enable can be used to re-enable a column if set to True
476 476
 	 * @param string $path='/0' default is the first widget in the tree of children
477 477
 	 */
478
-	function disable_column($c,$enable=False,$path='/0')
478
+	function disable_column($c, $enable = False, $path = '/0')
479 479
 	{
480
-		$this->set_column_attributes($c,0,!$enable,$path);
480
+		$this->set_column_attributes($c, 0, !$enable, $path);
481 481
 	}
482 482
 
483 483
 	/**
@@ -496,18 +496,18 @@  discard block
 block discarded – undo
496 496
 	 */
497 497
 	function loadExtension($type)
498 498
 	{
499
-		list($class,$app) = explode('.',$type);
499
+		list($class, $app) = explode('.', $type);
500 500
 		$class .= '_widget';
501 501
 
502 502
 		if (!$app) $app = $GLOBALS['egw_info']['flags']['current_app'];
503 503
 
504 504
 		if (!file_exists(EGW_SERVER_ROOT."/$app/inc/class.$class.inc.php"))
505 505
 		{
506
-			list($app) = explode('_',$type);
506
+			list($app) = explode('_', $type);
507 507
 		}
508 508
 		if (!file_exists(EGW_SERVER_ROOT."/$app/inc/class.$class.inc.php"))
509 509
 		{
510
-			list($app) = explode('.',$this->name);
510
+			list($app) = explode('.', $this->name);
511 511
 		}
512 512
 		if (!file_exists(EGW_SERVER_ROOT."/$app/inc/class.$class.inc.php"))
513 513
 		{
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 			//echo "<p>boetemplate::loadExtension($type) extension not found</p>\n";
519 519
 			return self::$extensions[$type] = False;
520 520
 		}
521
-		self::$extensions[$type] =& CreateObject($app.'.'.$class,$ui='html');
521
+		self::$extensions[$type] = & CreateObject($app.'.'.$class, $ui = 'html');
522 522
 
523 523
 		//echo "<p>boetemplate::loadExtension($type) extension found in App. $app</p>\n";
524 524
 		return self::$extensions[$type]->human_name;
@@ -532,9 +532,9 @@  discard block
 block discarded – undo
532 532
 	 * @param string $function 'pre_process', 'post_process' or 'render'
533 533
 	 * @return boolean true if the extension (incl. method) exists, else false
534 534
 	 */
535
-	protected function haveExtension($type,$function='')
535
+	protected function haveExtension($type, $function = '')
536 536
 	{
537
-		return (self::$extensions[$type] || $this->loadExtension($type,$ui)) &&
537
+		return (self::$extensions[$type] || $this->loadExtension($type, $ui)) &&
538 538
 						($function == '' || self::$extensions[$type]->public_functions[$function]);
539 539
 	}
540 540
 
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 	{
549 549
 		if (isset(self::$types[$type])) return true;
550 550
 
551
-		list($main,$sub) = explode('-',$type);
551
+		list($main, $sub) = explode('-', $type);
552 552
 
553 553
 		if ($this->haveExtension($main) && $this->loadExtension($main) && ($extension = self::$extensions[$main]))
554 554
 		{
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 	 * @param array &$readonlys value of the extensions readonly-setting(-array)
568 568
 	 * @return mixed the return-value of the extensions preprocess function
569 569
 	 */
570
-	protected function extensionPreProcess($type,&$name,&$value,&$cell,&$readonlys)
570
+	protected function extensionPreProcess($type, &$name, &$value, &$cell, &$readonlys)
571 571
 	{
572 572
 		if (!$this->haveExtension($type))
573 573
 		{
@@ -577,9 +577,9 @@  discard block
 block discarded – undo
577 577
 		// otherwise lists store >10k unnecessary data in each etemplate-session
578 578
 		if (!($cell['readonly'] || $readonlys && !is_array($readonlys)) || isset(self::$request->extension_data[$name]))
579 579
 		{
580
-			$extension_data =& self::$request->extension_data[$name];
580
+			$extension_data = & self::$request->extension_data[$name];
581 581
 		}
582
-		return self::$extensions[$type]->pre_process($name,$value,$cell,$readonlys,$extension_data,$this);
582
+		return self::$extensions[$type]->pre_process($name, $value, $cell, $readonlys, $extension_data, $this);
583 583
 	}
584 584
 
585 585
 	/**
@@ -591,15 +591,15 @@  discard block
 block discarded – undo
591 591
 	 * @param mixed $value_in unprocessed value, eg. as posted by the browser
592 592
 	 * @return boolean True if a value should be returned (default for no postprocess fkt.), else False
593 593
 	 */
594
-	protected function extensionPostProcess($type,$name,&$value,$value_in)
594
+	protected function extensionPostProcess($type, $name, &$value, $value_in)
595 595
 	{
596
-		if (!$this->haveExtension($type,'post_process'))
596
+		if (!$this->haveExtension($type, 'post_process'))
597 597
 		{
598 598
 			return True;
599 599
 		}
600
-		return self::$extensions[$type]->post_process($name,$value,
600
+		return self::$extensions[$type]->post_process($name, $value,
601 601
 			self::$request->extension_data[$name],
602
-			self::$loop,$this,$value_in);
602
+			self::$loop, $this, $value_in);
603 603
 	}
604 604
 
605 605
 	/**
@@ -612,14 +612,14 @@  discard block
 block discarded – undo
612 612
 	 * @param array &$readonlys value of the extensions readonly-setting(-array)
613 613
 	 * @return mixed return-value of the render function
614 614
 	 */
615
-	protected function extensionRender($type,$name,&$value,&$cell,$readonly)
615
+	protected function extensionRender($type, $name, &$value, &$cell, $readonly)
616 616
 	{
617
-		if (!$this->haveExtension($type,'render'))
617
+		if (!$this->haveExtension($type, 'render'))
618 618
 		{
619 619
 			return False;
620 620
 		}
621
-		return self::$extensions[$type]->render($cell,$name,$value,$readonly,
622
-			self::$request->extension_data[$name],$this);
621
+		return self::$extensions[$type]->render($cell, $name, $value, $readonly,
622
+			self::$request->extension_data[$name], $this);
623 623
 	}
624 624
 
625 625
 	/**
@@ -631,15 +631,15 @@  discard block
 block discarded – undo
631 631
 	 * @param string $idx may contain multiple subindex (eg.'x[y][z]')
632 632
 	 * @return boolean true if set, else false
633 633
 	 */
634
-	static function isset_array($arr,$idx)
634
+	static function isset_array($arr, $idx)
635 635
 	{
636 636
 		if (count($idxs = explode('[', $idx, 2)) > 1)
637 637
 		{
638
-			$idxs = array_merge(array($idxs[0]), explode('][', substr($idxs[1],0,-1)));
638
+			$idxs = array_merge(array($idxs[0]), explode('][', substr($idxs[1], 0, -1)));
639 639
 		}
640 640
 		$last_idx = array_pop($idxs);
641 641
 		$pos = &$arr;
642
-		foreach($idxs as $idx)
642
+		foreach ($idxs as $idx)
643 643
 		{
644 644
 			if (!is_array($pos))
645 645
 			{
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
 		}
650 650
 		// was return isset($pos[$last_idx]);
651 651
 		// array_key_exists also returns true for keys with value null, which fixes some problems with autorepeating rows
652
-		return is_array($pos) && array_key_exists($last_idx,$pos);
652
+		return is_array($pos) && array_key_exists($last_idx, $pos);
653 653
 	}
654 654
 
655 655
 	/**
@@ -661,16 +661,16 @@  discard block
 block discarded – undo
661 661
 	 * @param string $idx the index, may contain sub-indices like a[b], see example below
662 662
 	 * @param mixed $val value to set
663 663
 	 */
664
-	static function set_array(&$arr,$idx,$val)
664
+	static function set_array(&$arr, $idx, $val)
665 665
 	{
666 666
 		if (count($idxs = explode('[', $idx, 2)) > 1)
667 667
 		{
668
-			$idxs = array_merge(array($idxs[0]), explode('][', substr($idxs[1],0,-1)));
668
+			$idxs = array_merge(array($idxs[0]), explode('][', substr($idxs[1], 0, -1)));
669 669
 		}
670 670
 		$pos = &$arr;
671
-		foreach($idxs as $idx)
671
+		foreach ($idxs as $idx)
672 672
 		{
673
-			if (!is_array($pos) && !is_null($pos)) return;	// gives fatal error under PHP5.3
673
+			if (!is_array($pos) && !is_null($pos)) return; // gives fatal error under PHP5.3
674 674
 
675 675
 			$pos = &$pos[$idx];
676 676
 		}
@@ -689,26 +689,26 @@  discard block
 block discarded – undo
689 689
 	 * @param bool $skip_empty returns false if $idx is not present in $arr
690 690
 	 * @return mixed reference to $arr[$idx] or false if $idx is not set and not $reference_into
691 691
 	 */
692
-	static function &get_array(&$arr,$idx,$reference_into=False,$skip_empty=False)
692
+	static function &get_array(&$arr, $idx, $reference_into = False, $skip_empty = False)
693 693
 	{
694 694
 		if (!is_array($arr))
695 695
 		{
696 696
 			throw new egw_exception_assertion_failed(__METHOD__."(\$arr,'$idx',$reference_into,$skip_empty) \$arr is no array!");
697 697
 		}
698
-		if (is_object($idx)) return false;	// given an error in php5.2
698
+		if (is_object($idx)) return false; // given an error in php5.2
699 699
 
700 700
 		if (count($idxs = explode('[', $idx, 2)) > 1)
701 701
 		{
702
-			$idxs = array_merge(array($idxs[0]), explode('][', substr($idxs[1],0,-1)));
702
+			$idxs = array_merge(array($idxs[0]), explode('][', substr($idxs[1], 0, -1)));
703 703
 		}
704 704
 		$pos = &$arr;
705
-		foreach($idxs as $idx)
705
+		foreach ($idxs as $idx)
706 706
 		{
707 707
 			if (!is_array($pos) && !$reference_into)
708 708
 			{
709 709
 				return False;
710 710
 			}
711
-			if($skip_empty && (!is_array($pos) || !isset($pos[$idx]))) return false;
711
+			if ($skip_empty && (!is_array($pos) || !isset($pos[$idx]))) return false;
712 712
 			$pos = &$pos[$idx];
713 713
 		}
714 714
 		return $pos;
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	 * @param array $arr the array to search, referenz as a referenz gets returned
724 724
 	 * @param string $idx the index, may contain sub-indices like a[b], see example below
725 725
 	 */
726
-	static function unset_array(&$arr,$idx)
726
+	static function unset_array(&$arr, $idx)
727 727
 	{
728 728
 		if (!is_array($arr))
729 729
 		{
@@ -731,11 +731,11 @@  discard block
 block discarded – undo
731 731
 		}
732 732
 		if (count($idxs = explode('[', $idx, 2)) > 1)
733 733
 		{
734
-			$idxs = array_merge(array($idxs[0]), explode('][', substr($idxs[1],0,-1)));
734
+			$idxs = array_merge(array($idxs[0]), explode('][', substr($idxs[1], 0, -1)));
735 735
 		}
736 736
 		$last_idx = array_pop($idxs);
737 737
 		$pos = &$arr;
738
-		foreach($idxs as $idx)
738
+		foreach ($idxs as $idx)
739 739
 		{
740 740
 			$pos = &$pos[$idx];
741 741
 		}
@@ -753,22 +753,22 @@  discard block
 block discarded – undo
753 753
 	 * @param array $new
754 754
 	 * @return array the merged array
755 755
 	 */
756
-	static function complete_array_merge($old,$new)
756
+	static function complete_array_merge($old, $new)
757 757
 	{
758 758
 		if (is_array($new))
759 759
 		{
760
-			if (!is_array($old)) $old = (array) $old;
760
+			if (!is_array($old)) $old = (array)$old;
761 761
 
762
-			foreach($new as $k => $v)
762
+			foreach ($new as $k => $v)
763 763
 			{
764
-				if (!is_array($v) || !isset($old[$k]) || 	// no array or a new array
765
-					isset($v[0]) && !is_array($v[0]) && isset($v[count($v)-1]))	// or no associative array, eg. selecting multiple accounts
764
+				if (!is_array($v) || !isset($old[$k]) || // no array or a new array
765
+					isset($v[0]) && !is_array($v[0]) && isset($v[count($v) - 1]))	// or no associative array, eg. selecting multiple accounts
766 766
 				{
767 767
 					$old[$k] = $v;
768 768
 				}
769 769
 				else
770 770
 				{
771
-					$old[$k] = self::complete_array_merge($old[$k],$v);
771
+					$old[$k] = self::complete_array_merge($old[$k], $v);
772 772
 				}
773 773
 			}
774 774
 		}
@@ -785,19 +785,19 @@  discard block
 block discarded – undo
785 785
 	 * @param int $ancestor=0 0: widget itself, 1: parent, 2: grand-parent, ...
786 786
 	 * @return array referenz to the widget spezified or null, if it's not found
787 787
 	 */
788
-	function &get_widget_by_path($path,$ancestor=0)
788
+	function &get_widget_by_path($path, $ancestor = 0)
789 789
 	{
790 790
 		//echo "<p>boetemplate::get_widget_by_path('$path',$ancestor)</p>\n";
791
-		$path_parts = explode('/',$path);
792
-		while($ancestor-- > 0)
791
+		$path_parts = explode('/', $path);
792
+		while ($ancestor-- > 0)
793 793
 		{
794 794
 			if (array_pop($path_parts) === '') return null;
795 795
 		}
796
-		$path = implode('/',$path_parts);
796
+		$path = implode('/', $path_parts);
797 797
 		if ($path == '/' || $path === '') return $this->children;
798 798
 		if (count($path_parts) == 2) return $this->children[$path_parts[1]];
799 799
 
800
-		return $this->widget_tree_walk('get_widget_by_path_helper',$path);
800
+		return $this->widget_tree_walk('get_widget_by_path_helper', $path);
801 801
 	}
802 802
 
803 803
 	/**
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 	 */
811 811
 	function &get_widget_by_name($name)
812 812
 	{
813
-		return $this->widget_tree_walk('get_widget_by_name_helper',$name);
813
+		return $this->widget_tree_walk('get_widget_by_name_helper', $name);
814 814
 	}
815 815
 
816 816
 	/**
@@ -843,32 +843,32 @@  discard block
 block discarded – undo
843 843
 	 * @param string $enclosure='"'
844 844
 	 * @return array
845 845
 	 */
846
-	static function csv_split($str,$num=null,$delimiter=',',$enclosure='"')
846
+	static function csv_split($str, $num = null, $delimiter = ',', $enclosure = '"')
847 847
 	{
848
-		if (strpos($str,$enclosure) === false)
848
+		if (strpos($str, $enclosure) === false)
849 849
 		{
850
-			return is_null($num) ? explode($delimiter,$str) : explode($delimiter,$str,$num);	// no need to run this more expensive code
850
+			return is_null($num) ? explode($delimiter, $str) : explode($delimiter, $str, $num); // no need to run this more expensive code
851 851
 		}
852
-		$parts = explode($delimiter,$str);
853
-		for($n = 0; isset($parts[$n]); ++$n)
852
+		$parts = explode($delimiter, $str);
853
+		for ($n = 0; isset($parts[$n]); ++$n)
854 854
 		{
855
-			$part =& $parts[$n];
855
+			$part = & $parts[$n];
856 856
 			if ($part[0] === $enclosure)
857 857
 			{
858
-				while (isset($parts[$n+1]) && substr($part,-1) !== $enclosure)
858
+				while (isset($parts[$n + 1]) && substr($part, -1) !== $enclosure)
859 859
 				{
860 860
 					$part .= $delimiter.$parts[++$n];
861 861
 					unset($parts[$n]);
862 862
 				}
863
-				$part = substr(str_replace($enclosure.$enclosure,$enclosure,$part),1,-1);
863
+				$part = substr(str_replace($enclosure.$enclosure, $enclosure, $part), 1, -1);
864 864
 			}
865 865
 		}
866
-		$parts = array_values($parts);	// renumber the parts (in case we had to concat them)
866
+		$parts = array_values($parts); // renumber the parts (in case we had to concat them)
867 867
 
868 868
 		if ($num > 0 && count($parts) > $num)
869 869
 		{
870
-			$parts[$num-1] = implode($delimiter,array_slice($parts,$num-1,count($parts)-$num+1));
871
-			$parts = array_slice($parts,0,$num);
870
+			$parts[$num - 1] = implode($delimiter, array_slice($parts, $num - 1, count($parts) - $num + 1));
871
+			$parts = array_slice($parts, 0, $num);
872 872
 		}
873 873
 		return $parts;
874 874
 	}
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 	 * @param string $lang language to use
882 882
 	 * @return string
883 883
 	 */
884
-	private /* static */ function cache_name($name='',$template='default',$lang='default')
884
+	private /* static */ function cache_name($name = '', $template = 'default', $lang = 'default')
885 885
 	{
886 886
 		if (empty($name))
887 887
 		{
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 		{
900 900
 			$template = 'default';
901 901
 		}
902
-		$cname = $template . '/' . $name . (!empty($lang) && $lang != 'default' ? '.' . $lang : '');
902
+		$cname = $template.'/'.$name.(!empty($lang) && $lang != 'default' ? '.'.$lang : '');
903 903
 		//echo "<p>".__METHOD__."('$name','$template','$lang') = '$cname'</p>";
904 904
 
905 905
 		return $cname;
@@ -911,18 +911,18 @@  discard block
 block discarded – undo
911 911
 	 * @param boetemplate $tpl=null required parameter for static use!
912 912
 	 * @param boolean $only_update_older=false true only update cache, if it contains an older template
913 913
 	 */
914
-	public /*static*/ function store_in_cache(boetemplate $tpl=null, $only_update_older=false)
914
+	public /*static*/ function store_in_cache(boetemplate $tpl = null, $only_update_older = false)
915 915
 	{
916 916
 		if (is_null($tpl)) $tpl = $this;
917 917
 
918 918
 		$cname = $tpl->cache_name();
919
-		$old = egw_cache::getInstance('etemplate',$cname);
919
+		$old = egw_cache::getInstance('etemplate', $cname);
920 920
 
921 921
 		// only cache newest versions (currently cached one is older or same version)
922
-		if (is_null($old) && !$only_update_older || !is_null($old) && version_compare($old['version'],$tpl->version,'<='))
922
+		if (is_null($old) && !$only_update_older || !is_null($old) && version_compare($old['version'], $tpl->version, '<='))
923 923
 		{
924 924
 			//error_log(__METHOD__."('$tpl->name','$tpl->template','$tpl->lang','$tpl->version') cached=".array2string($old).", modified=$tpl->modified, time()=".time());
925
-			egw_cache::setInstance('etemplate',$cname,$tpl->as_array(1));
925
+			egw_cache::setInstance('etemplate', $cname, $tpl->as_array(1));
926 926
 		}
927 927
 	}
928 928
 
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
 	private function delete_in_cache()
933 933
 	{
934 934
 		//echo "<p>".__METHOD__."('$this->name','$this->template','$this->lang','$this->version')</p>\n";
935
-		egw_cache::unsetInstance('etemplate',$this->cache_name());
935
+		egw_cache::unsetInstance('etemplate', $this->cache_name());
936 936
 	}
937 937
 
938 938
 	static private $import_tested;
@@ -949,33 +949,33 @@  discard block
 block discarded – undo
949 949
 	static function test_import($app)	// should be done from the setup-App
950 950
 	{
951 951
 		if (is_array($app)) $app = $app['name'];
952
-		list($app) = explode('.',$app);
952
+		list($app) = explode('.', $app);
953 953
 
954 954
 		if (is_null(self::$import_tested))
955 955
 		{
956
-			self::$import_tested =& egw_cache::getSession('etemplate','import_tested');
956
+			self::$import_tested = & egw_cache::getSession('etemplate', 'import_tested');
957 957
 			if (is_null(self::$import_tested)) self::$import_tested = array();
958 958
 		}
959 959
 		if (!$app || self::$import_tested[$app])
960 960
 		{
961
-			return '';	// ensure test is done only once per session and app
961
+			return ''; // ensure test is done only once per session and app
962 962
 		}
963
-		self::$import_tested[$app] = True;	// need to be done before new ...
963
+		self::$import_tested[$app] = True; // need to be done before new ...
964 964
 
965 965
 		$path = EGW_SERVER_ROOT."/$app/setup/etemplates.inc.php";
966 966
 
967 967
 		if (($time = @filemtime($path)))
968 968
 		{
969
-			$templ = new boetemplate(array('name' => '.'.$app,'lang' => '##'));
969
+			$templ = new boetemplate(array('name' => '.'.$app, 'lang' => '##'));
970 970
 			if ($templ->lang != '##' || $templ->version != $GLOBALS['egw_info']['apps'][$app]['version'] ||
971 971
 				$templ->modified < $time) // need to import
972 972
 			{
973
-				$templ->delete();	// delete old timestamp
973
+				$templ->delete(); // delete old timestamp
974 974
 				//echo "<p>".__METHOD__."($app) import necessary, as app-modified=$templ->modified < filemtime($path)=$time test-tpl=".array2string($templ->as_array(1))."</p>\n";
975 975
 				$ret = self::import_dump($app);
976 976
 				$templ->modified = $time;
977 977
 				// store new timestamp incl. app version
978
-				$templ->save('.'.$app,'','##',0,$GLOBALS['egw_info']['apps'][$app]['version']);
978
+				$templ->save('.'.$app, '', '##', 0, $GLOBALS['egw_info']['apps'][$app]['version']);
979 979
 			}
980 980
 		}
981 981
 		return $ret;
@@ -989,12 +989,12 @@  discard block
 block discarded – undo
989 989
 	 */
990 990
 	static function import_dump($app)
991 991
 	{
992
-		$templ_version=0;
992
+		$templ_version = 0;
993 993
 
994 994
 		include($path = EGW_SERVER_ROOT."/$app/setup/etemplates.inc.php");
995 995
 		$templ = new boetemplate($app);
996 996
 
997
-		foreach($templ_data as $data)
997
+		foreach ($templ_data as $data)
998 998
 		{
999 999
 			if ((int)$templ_version < 1)	// we need to stripslashes
1000 1000
 			{
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
 
1011 1011
 			$n++;
1012 1012
 		}
1013
-		return lang("%1 new eTemplates imported for Application '%2'",$n,$app);
1013
+		return lang("%1 new eTemplates imported for Application '%2'", $n, $app);
1014 1014
 	}
1015 1015
 
1016 1016
 	/**
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 	 * @param string $version of the template
1026 1026
 	 * @return boolean true if the eTemplate was found in the cache
1027 1027
 	 */
1028
-	private function read_from_cache($name,$template='default',$lang='default',$group=0,$version='')
1028
+	private function read_from_cache($name, $template = 'default', $lang = 'default', $group = 0, $version = '')
1029 1029
 	{
1030 1030
 		// check if new import necessary, currently on every request
1031 1031
 		$msg = self::test_import($name);
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 		// templates starting with . (as the import timestamp) never use the cache
1042 1042
 		if ($name[0] == '.') return false;
1043 1043
 
1044
-		$data = egw_cache::getInstance('etemplate',$cname=self::cache_name($name,$template,$lang));
1044
+		$data = egw_cache::getInstance('etemplate', $cname = self::cache_name($name, $template, $lang));
1045 1045
 		//echo "<p>".__METHOD__.'('.array2string($name).",$template,$lang,$group,$version) egw_cache::getInstance('etemplate','$cname')=".array2string(array('name'=>$data['name'],'version'=>$data['version'],'modified'=>$data['modified']))."</p>\n";
1046 1046
 
1047 1047
 		if (!is_null($data) && (empty($version) || $data['version'] == $version))
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 	 * @param mixed $load_via name/array of keys of etemplate to load in order to get $name (only as second try!)
1069 1069
 	 * @return boolean True if a fitting template is found, else False
1070 1070
 	 */
1071
-	function read($name,$template='default',$lang='default',$group=0,$version='',$load_via='')
1071
+	function read($name, $template = 'default', $lang = 'default', $group = 0, $version = '', $load_via = '')
1072 1072
 	{
1073 1073
 		if (is_array($name))
1074 1074
 		{
@@ -1084,23 +1084,23 @@  discard block
 block discarded – undo
1084 1084
 		}
1085 1085
 		$parent = is_array($load_via) ? $load_via['name'] : $load_via;
1086 1086
 
1087
-		if (strstr($pname,'.') === False && !empty($parent))
1087
+		if (strstr($pname, '.') === False && !empty($parent))
1088 1088
 		{
1089
-			$pname = $parent . '.' . $pname;
1089
+			$pname = $parent.'.'.$pname;
1090 1090
 		}
1091
-		if (!$this->read_from_cache($name,$template,$lang,$group,$version))
1091
+		if (!$this->read_from_cache($name, $template, $lang, $group, $version))
1092 1092
 		{
1093
-			if (!parent::read($name,$template,$lang,$group,$version))
1093
+			if (!parent::read($name, $template, $lang, $group, $version))
1094 1094
 			{
1095 1095
 				if ($load_via && (is_string($load_via) ||
1096 1096
 					!isset($load_via['tpls_in_file']) || $load_via['tpls_in_file'] > 1))
1097 1097
 				{
1098 1098
 					parent::read($load_via);
1099
-					return $this->read_from_cache($name,$template,$lang,$group,$version);
1099
+					return $this->read_from_cache($name, $template, $lang, $group, $version);
1100 1100
 				}
1101 1101
 				return False;
1102 1102
 			}
1103
-			if (!$version) $this->store_in_cache();	// only store default version (none given)
1103
+			if (!$version) $this->store_in_cache(); // only store default version (none given)
1104 1104
 		}
1105 1105
 		return True;
1106 1106
 	}
@@ -1120,11 +1120,11 @@  discard block
 block discarded – undo
1120 1120
 	 * @param string $version version of the eTemplate
1121 1121
 	 * @return the number of affected rows, 1 should be ok, 0 somethings wrong
1122 1122
 	 */
1123
-	function save($name='',$template='.',$lang='.',$group=0,$version='.')
1123
+	function save($name = '', $template = '.', $lang = '.', $group = 0, $version = '.')
1124 1124
 	{
1125
-		if ($result = parent::save($name,$template,$lang,$group,$version))
1125
+		if ($result = parent::save($name, $template, $lang, $group, $version))
1126 1126
 		{
1127
-			$this->store_in_cache(null, true);	// true = only update older (smaller version) copies
1127
+			$this->store_in_cache(null, true); // true = only update older (smaller version) copies
1128 1128
 		}
1129 1129
 		return $result;
1130 1130
 	}
@@ -1154,14 +1154,14 @@  discard block
 block discarded – undo
1154 1154
 
1155 1155
 if (!function_exists('set_cell_attribute_helper'))
1156 1156
 {
1157
-	function &set_cell_attribute_helper(&$widget,&$extra)
1157
+	function &set_cell_attribute_helper(&$widget, &$extra)
1158 1158
 	{
1159 1159
 		// extra = array(0=>n,1=>name,2=>attr,3=>value)
1160 1160
 		if ($widget['name'] == $extra[1] || $widget['type'] == 'tab' && strpos($widget['name'], $extra[1].'=') === 0)
1161 1161
 		{
1162 1162
 			if (is_null($extra[3]))
1163 1163
 			{
1164
-				$extra['__RETURN_NOW__'] = true;	// wouldnt work otherwise, if attr is not yet set == null
1164
+				$extra['__RETURN_NOW__'] = true; // wouldnt work otherwise, if attr is not yet set == null
1165 1165
 				return $widget[$extra[2]];
1166 1166
 			}
1167 1167
 			$widget[$extra[2]] = $extra[3];
@@ -1169,12 +1169,12 @@  discard block
 block discarded – undo
1169 1169
 		}
1170 1170
 	}
1171 1171
 
1172
-	function &get_widget_by_name_helper(&$widget,$extra)
1172
+	function &get_widget_by_name_helper(&$widget, $extra)
1173 1173
 	{
1174 1174
 		if ($widget['name'] == $extra) return $widget;
1175 1175
 	}
1176 1176
 
1177
-	function &get_widget_by_path_helper(&$widget,$extra,$path)
1177
+	function &get_widget_by_path_helper(&$widget, $extra, $path)
1178 1178
 	{
1179 1179
 		//echo "<p>path_searched='$extra', widget-path($widget[type]:$widget[name])='$path'</p>\n";
1180 1180
 		if ($path == $extra) return $widget;
@@ -1183,12 +1183,12 @@  discard block
 block discarded – undo
1183 1183
 	function &get_widgets_by_type_helper(&$widget, &$extra)
1184 1184
 	{
1185 1185
 		//echo '<br />get_widgets_by_type_helper(' . $widget['name'] . ',' . $extra['type'] . ')<br />';
1186
-		if($widget['type'] == $extra['type'])
1186
+		if ($widget['type'] == $extra['type'])
1187 1187
 		{
1188
-			$extra['widgets'][] =& $widget;
1188
+			$extra['widgets'][] = & $widget;
1189 1189
 		}
1190 1190
 	}
1191 1191
 }
1192 1192
 // just in case someone still uses the old var
1193 1193
 if (!is_array($GLOBALS['egw_info']['flags']['etemplate'])) $GLOBALS['egw_info']['flags']['etemplate'] = array();
1194
-$GLOBALS['egw_info']['flags']['etemplate']['loop'] =& boetemplate::$loop;
1194
+$GLOBALS['egw_info']['flags']['etemplate']['loop'] = & boetemplate::$loop;
Please login to merge, or discard this patch.
Braces   +109 added lines, -27 removed lines patch added patch discarded remove patch
@@ -123,7 +123,10 @@  discard block
 block discarded – undo
123 123
 		$val = $this->expand_name($val,$c,$row,'','',$content);
124 124
 		$check_val = $this->expand_name($check_val,$c,$row,'','',$content);
125 125
 		$result = count($vals) == 1 ? $val != '' : ($check_val[0] == '/' ? preg_match($check_val,$val) : $val == $check_val);
126
-		if ($not) $result = !$result;
126
+		if ($not)
127
+		{
128
+			$result = !$result;
129
+		}
127 130
 		//echo "<p>check_disabled: '".($not?'!':'')."$disabled' = '$val' ".(count($vals) == 1 ? '' : ($not?'!':'=')."= '$check_val'")." = ".($result?'True':'False')."</p>\n";
128 131
 		return $result;
129 132
 	}
@@ -172,7 +175,10 @@  discard block
 block discarded – undo
172 175
 			{
173 176
 				$cont = array();
174 177
 			}
175
-			if (!is_numeric($c)) $c = boetemplate::chrs2num($c);
178
+			if (!is_numeric($c))
179
+			{
180
+				$c = boetemplate::chrs2num($c);
181
+			}
176 182
 			$col = boetemplate::num2chrs($c-1);	// $c-1 to get: 0:'@', 1:'A', ...
177 183
 			$col_ = boetemplate::num2chrs($c_-1);
178 184
 			$row_cont = $cont[$row];
@@ -188,11 +194,14 @@  discard block
 block discarded – undo
188 194
 					error_log(__METHOD__."(name='$name', c='$c', row=$row, c_='$c_', row_=$row_, ...) line ".__LINE__." ERROR parsing: $code");
189 195
 					error_log(function_backtrace());
190 196
 				}
191
-				if (is_array($value) && $name[$pos_var-1] == "'")	// arrays are only supported for '
197
+				if (is_array($value) && $name[$pos_var-1] == "'")
198
+				{
199
+					// arrays are only supported for '
192 200
 				{
193 201
 					foreach($value as &$val)
194 202
 					{
195 203
 						$val = "'".str_replace(array("'",'"'),array('\\\'','&quot;'),$val)."'";
204
+				}
196 205
 					}
197 206
 					$value = '[ '.implode(', ',$value).' ]';
198 207
 					$name = str_replace("'".$matches[1]."'",$value,$name);
@@ -211,11 +220,14 @@  discard block
 block discarded – undo
211 220
 					error_log(__METHOD__."(name='$name', c='$c', row=$row, c_='$c_', row_=$row_, ...) line ".__LINE__." ERROR parsing: $code");
212 221
 					error_log(function_backtrace());
213 222
 				}
214
-				if (is_array($value))	// works only reasonable, if get-parameter uses array notation, eg. &file[]=$cont[filenames]
223
+				if (is_array($value))
224
+				{
225
+					// works only reasonable, if get-parameter uses array notation, eg. &file[]=$cont[filenames]
215 226
 				{
216 227
 					foreach($value as &$val)
217 228
 					{
218 229
 						$val = str_replace('&',urlencode('&'),$val);
230
+				}
219 231
 					}
220 232
 					$name = str_replace($matches[3],implode('&'.$matches[1].'=',$value),$name);
221 233
 				}
@@ -411,7 +423,10 @@  discard block
 block discarded – undo
411 423
 	function set_row_attributes($n,$height=0,$class=0,$valign=0,$disabled=0,$path='/0')
412 424
 	{
413 425
 		$grid =& $this->get_widget_by_path($path);
414
-		if (is_null($grid) || $grid['type'] != 'grid') return false;
426
+		if (is_null($grid) || $grid['type'] != 'grid')
427
+		{
428
+			return false;
429
+		}
415 430
 		$grid_attr =& $grid['data'][0];
416 431
 
417 432
 		list($old_height,$old_disabled) = explode(',',$grid_attr["h$n"]);
@@ -456,7 +471,10 @@  discard block
 block discarded – undo
456 471
 			$c = $this->num2chrs($c);
457 472
 		}
458 473
 		$grid =& $this->get_widget_by_path($path);
459
-		if (is_null($grid) || $grid['type'] != 'grid') return false;
474
+		if (is_null($grid) || $grid['type'] != 'grid')
475
+		{
476
+			return false;
477
+		}
460 478
 		$grid_attr =& $grid['data'][0];
461 479
 
462 480
 		list($old_width,$old_disabled) = explode(',',$grid_attr[$c]);
@@ -499,7 +517,10 @@  discard block
 block discarded – undo
499 517
 		list($class,$app) = explode('.',$type);
500 518
 		$class .= '_widget';
501 519
 
502
-		if (!$app) $app = $GLOBALS['egw_info']['flags']['current_app'];
520
+		if (!$app)
521
+		{
522
+			$app = $GLOBALS['egw_info']['flags']['current_app'];
523
+		}
503 524
 
504 525
 		if (!file_exists(EGW_SERVER_ROOT."/$app/inc/class.$class.inc.php"))
505 526
 		{
@@ -546,7 +567,10 @@  discard block
 block discarded – undo
546 567
 	 */
547 568
 	public function widgetExists($type)
548 569
 	{
549
-		if (isset(self::$types[$type])) return true;
570
+		if (isset(self::$types[$type]))
571
+		{
572
+			return true;
573
+		}
550 574
 
551 575
 		list($main,$sub) = explode('-',$type);
552 576
 
@@ -670,7 +694,11 @@  discard block
 block discarded – undo
670 694
 		$pos = &$arr;
671 695
 		foreach($idxs as $idx)
672 696
 		{
673
-			if (!is_array($pos) && !is_null($pos)) return;	// gives fatal error under PHP5.3
697
+			if (!is_array($pos) && !is_null($pos))
698
+			{
699
+				return;
700
+			}
701
+			// gives fatal error under PHP5.3
674 702
 
675 703
 			$pos = &$pos[$idx];
676 704
 		}
@@ -695,7 +723,11 @@  discard block
 block discarded – undo
695 723
 		{
696 724
 			throw new egw_exception_assertion_failed(__METHOD__."(\$arr,'$idx',$reference_into,$skip_empty) \$arr is no array!");
697 725
 		}
698
-		if (is_object($idx)) return false;	// given an error in php5.2
726
+		if (is_object($idx))
727
+		{
728
+			return false;
729
+		}
730
+		// given an error in php5.2
699 731
 
700 732
 		if (count($idxs = explode('[', $idx, 2)) > 1)
701 733
 		{
@@ -708,7 +740,10 @@  discard block
 block discarded – undo
708 740
 			{
709 741
 				return False;
710 742
 			}
711
-			if($skip_empty && (!is_array($pos) || !isset($pos[$idx]))) return false;
743
+			if($skip_empty && (!is_array($pos) || !isset($pos[$idx])))
744
+			{
745
+				return false;
746
+			}
712 747
 			$pos = &$pos[$idx];
713 748
 		}
714 749
 		return $pos;
@@ -757,15 +792,21 @@  discard block
 block discarded – undo
757 792
 	{
758 793
 		if (is_array($new))
759 794
 		{
760
-			if (!is_array($old)) $old = (array) $old;
795
+			if (!is_array($old))
796
+			{
797
+				$old = (array) $old;
798
+			}
761 799
 
762 800
 			foreach($new as $k => $v)
763 801
 			{
764 802
 				if (!is_array($v) || !isset($old[$k]) || 	// no array or a new array
765
-					isset($v[0]) && !is_array($v[0]) && isset($v[count($v)-1]))	// or no associative array, eg. selecting multiple accounts
803
+					isset($v[0]) && !is_array($v[0]) && isset($v[count($v)-1]))
804
+				{
805
+					// or no associative array, eg. selecting multiple accounts
766 806
 				{
767 807
 					$old[$k] = $v;
768 808
 				}
809
+				}
769 810
 				else
770 811
 				{
771 812
 					$old[$k] = self::complete_array_merge($old[$k],$v);
@@ -791,11 +832,20 @@  discard block
 block discarded – undo
791 832
 		$path_parts = explode('/',$path);
792 833
 		while($ancestor-- > 0)
793 834
 		{
794
-			if (array_pop($path_parts) === '') return null;
835
+			if (array_pop($path_parts) === '')
836
+			{
837
+				return null;
838
+			}
795 839
 		}
796 840
 		$path = implode('/',$path_parts);
797
-		if ($path == '/' || $path === '') return $this->children;
798
-		if (count($path_parts) == 2) return $this->children[$path_parts[1]];
841
+		if ($path == '/' || $path === '')
842
+		{
843
+			return $this->children;
844
+		}
845
+		if (count($path_parts) == 2)
846
+		{
847
+			return $this->children[$path_parts[1]];
848
+		}
799 849
 
800 850
 		return $this->widget_tree_walk('get_widget_by_path_helper',$path);
801 851
 	}
@@ -913,7 +963,10 @@  discard block
 block discarded – undo
913 963
 	 */
914 964
 	public /*static*/ function store_in_cache(boetemplate $tpl=null, $only_update_older=false)
915 965
 	{
916
-		if (is_null($tpl)) $tpl = $this;
966
+		if (is_null($tpl))
967
+		{
968
+			$tpl = $this;
969
+		}
917 970
 
918 971
 		$cname = $tpl->cache_name();
919 972
 		$old = egw_cache::getInstance('etemplate',$cname);
@@ -948,13 +1001,19 @@  discard block
 block discarded – undo
948 1001
 	 */
949 1002
 	static function test_import($app)	// should be done from the setup-App
950 1003
 	{
951
-		if (is_array($app)) $app = $app['name'];
1004
+		if (is_array($app))
1005
+		{
1006
+			$app = $app['name'];
1007
+		}
952 1008
 		list($app) = explode('.',$app);
953 1009
 
954 1010
 		if (is_null(self::$import_tested))
955 1011
 		{
956 1012
 			self::$import_tested =& egw_cache::getSession('etemplate','import_tested');
957
-			if (is_null(self::$import_tested)) self::$import_tested = array();
1013
+			if (is_null(self::$import_tested))
1014
+			{
1015
+				self::$import_tested = array();
1016
+			}
958 1017
 		}
959 1018
 		if (!$app || self::$import_tested[$app])
960 1019
 		{
@@ -968,9 +1027,13 @@  discard block
 block discarded – undo
968 1027
 		{
969 1028
 			$templ = new boetemplate(array('name' => '.'.$app,'lang' => '##'));
970 1029
 			if ($templ->lang != '##' || $templ->version != $GLOBALS['egw_info']['apps'][$app]['version'] ||
971
-				$templ->modified < $time) // need to import
1030
+				$templ->modified < $time)
1031
+			{
1032
+				// need to import
972 1033
 			{
973
-				$templ->delete();	// delete old timestamp
1034
+				$templ->delete();
1035
+			}
1036
+			// delete old timestamp
974 1037
 				//echo "<p>".__METHOD__."($app) import necessary, as app-modified=$templ->modified < filemtime($path)=$time test-tpl=".array2string($templ->as_array(1))."</p>\n";
975 1038
 				$ret = self::import_dump($app);
976 1039
 				$templ->modified = $time;
@@ -996,10 +1059,13 @@  discard block
 block discarded – undo
996 1059
 
997 1060
 		foreach($templ_data as $data)
998 1061
 		{
999
-			if ((int)$templ_version < 1)	// we need to stripslashes
1062
+			if ((int)$templ_version < 1)
1063
+			{
1064
+				// we need to stripslashes
1000 1065
 			{
1001 1066
 				$data['data'] = stripslashes($data['data']);
1002 1067
 			}
1068
+			}
1003 1069
 			$templ->init($data);
1004 1070
 
1005 1071
 			if (!$templ->modified)
@@ -1039,7 +1105,10 @@  discard block
 block discarded – undo
1039 1105
 			$name = $name['name'];
1040 1106
 		}
1041 1107
 		// templates starting with . (as the import timestamp) never use the cache
1042
-		if ($name[0] == '.') return false;
1108
+		if ($name[0] == '.')
1109
+		{
1110
+			return false;
1111
+		}
1043 1112
 
1044 1113
 		$data = egw_cache::getInstance('etemplate',$cname=self::cache_name($name,$template,$lang));
1045 1114
 		//echo "<p>".__METHOD__.'('.array2string($name).",$template,$lang,$group,$version) egw_cache::getInstance('etemplate','$cname')=".array2string(array('name'=>$data['name'],'version'=>$data['version'],'modified'=>$data['modified']))."</p>\n";
@@ -1100,7 +1169,11 @@  discard block
 block discarded – undo
1100 1169
 				}
1101 1170
 				return False;
1102 1171
 			}
1103
-			if (!$version) $this->store_in_cache();	// only store default version (none given)
1172
+			if (!$version)
1173
+			{
1174
+				$this->store_in_cache();
1175
+			}
1176
+			// only store default version (none given)
1104 1177
 		}
1105 1178
 		return True;
1106 1179
 	}
@@ -1171,13 +1244,19 @@  discard block
 block discarded – undo
1171 1244
 
1172 1245
 	function &get_widget_by_name_helper(&$widget,$extra)
1173 1246
 	{
1174
-		if ($widget['name'] == $extra) return $widget;
1247
+		if ($widget['name'] == $extra)
1248
+		{
1249
+			return $widget;
1250
+		}
1175 1251
 	}
1176 1252
 
1177 1253
 	function &get_widget_by_path_helper(&$widget,$extra,$path)
1178 1254
 	{
1179 1255
 		//echo "<p>path_searched='$extra', widget-path($widget[type]:$widget[name])='$path'</p>\n";
1180
-		if ($path == $extra) return $widget;
1256
+		if ($path == $extra)
1257
+		{
1258
+			return $widget;
1259
+		}
1181 1260
 	}
1182 1261
 
1183 1262
 	function &get_widgets_by_type_helper(&$widget, &$extra)
@@ -1190,5 +1269,8 @@  discard block
 block discarded – undo
1190 1269
 	}
1191 1270
 }
1192 1271
 // just in case someone still uses the old var
1193
-if (!is_array($GLOBALS['egw_info']['flags']['etemplate'])) $GLOBALS['egw_info']['flags']['etemplate'] = array();
1272
+if (!is_array($GLOBALS['egw_info']['flags']['etemplate']))
1273
+{
1274
+	$GLOBALS['egw_info']['flags']['etemplate'] = array();
1275
+}
1194 1276
 $GLOBALS['egw_info']['flags']['etemplate']['loop'] =& boetemplate::$loop;
Please login to merge, or discard this patch.
etemplate/inc/class.bolangfile.inc.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -218,6 +218,9 @@
 block discarded – undo
218 218
 		return $this->target_langarray;
219 219
 	}
220 220
 
221
+	/**
222
+	 * @param string $which
223
+	 */
221 224
 	function write_file($which,$app_name,$userlang)
222 225
 	{
223 226
 		switch ($which)
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 
34 34
 	function __construct()
35 35
 	{
36
-		$this->so = new solangfile();	// is now in etemplate, to not doublicate it
36
+		$this->so = new solangfile(); // is now in etemplate, to not doublicate it
37 37
 	}
38 38
 
39 39
 	/* Sessions used to save state and not reread the langfile between adding/deleting phrases */
40
-	function save_sessiondata($source='##unset##',$target='##unset##')
40
+	function save_sessiondata($source = '##unset##', $target = '##unset##')
41 41
 	{
42 42
 		if ($source == '##unset##')
43 43
 		{
@@ -47,37 +47,37 @@  discard block
 block discarded – undo
47 47
 		{
48 48
 			$target = &$this->target_langarray;
49 49
 		}
50
-		if($this->debug) { echo '<br>Save:'; _debug_array($source); }
51
-		$GLOBALS['egw']->session->appsession('developer_source_lang','developer_tools',$source);
52
-		if($this->debug) { echo '<br>Save:'; _debug_array($target); }
53
-		$GLOBALS['egw']->session->appsession('developer_target_lang','developer_tools',$target);
54
-		$GLOBALS['egw']->session->appsession('developer_source_file','developer_tools',$this->src_file);
55
-		$GLOBALS['egw']->session->appsession('developer_target_file','developer_tools',$this->tgt_file);
56
-		$GLOBALS['egw']->session->appsession('developer_t_lang','developer_tools',$this->tgt_lang);
57
-		$GLOBALS['egw']->session->appsession('developer_loaded_apps','developer_tools',$this->loaded_apps);
58
-		$GLOBALS['egw']->session->appsession('developer_src_apps','developer_tools',$this->src_apps);
59
-		$GLOBALS['egw']->session->appsession('developer_missing_lang','developer_tools',$this->missing_langarray);
50
+		if ($this->debug) { echo '<br>Save:'; _debug_array($source); }
51
+		$GLOBALS['egw']->session->appsession('developer_source_lang', 'developer_tools', $source);
52
+		if ($this->debug) { echo '<br>Save:'; _debug_array($target); }
53
+		$GLOBALS['egw']->session->appsession('developer_target_lang', 'developer_tools', $target);
54
+		$GLOBALS['egw']->session->appsession('developer_source_file', 'developer_tools', $this->src_file);
55
+		$GLOBALS['egw']->session->appsession('developer_target_file', 'developer_tools', $this->tgt_file);
56
+		$GLOBALS['egw']->session->appsession('developer_t_lang', 'developer_tools', $this->tgt_lang);
57
+		$GLOBALS['egw']->session->appsession('developer_loaded_apps', 'developer_tools', $this->loaded_apps);
58
+		$GLOBALS['egw']->session->appsession('developer_src_apps', 'developer_tools', $this->src_apps);
59
+		$GLOBALS['egw']->session->appsession('developer_missing_lang', 'developer_tools', $this->missing_langarray);
60 60
 	}
61 61
 
62 62
 	function read_sessiondata()
63 63
 	{
64
-		$source = $GLOBALS['egw']->session->appsession('developer_source_lang','developer_tools');
65
-		if($this->debug) { echo '<br>Read:'; _debug_array($source); }
64
+		$source = $GLOBALS['egw']->session->appsession('developer_source_lang', 'developer_tools');
65
+		if ($this->debug) { echo '<br>Read:'; _debug_array($source); }
66 66
 
67
-		$target = $GLOBALS['egw']->session->appsession('developer_target_lang','developer_tools');
68
-		if($this->debug) { echo '<br>Read:'; _debug_array($target); }
67
+		$target = $GLOBALS['egw']->session->appsession('developer_target_lang', 'developer_tools');
68
+		if ($this->debug) { echo '<br>Read:'; _debug_array($target); }
69 69
 
70
-		$src_file = $GLOBALS['egw']->session->appsession('developer_source_file','developer_tools');
71
-		$tgt_file = $GLOBALS['egw']->session->appsession('developer_target_file','developer_tools');
72
-		$tgt_lang = $GLOBALS['egw']->session->appsession('developer_t_lang','developer_tools');
73
-		$loaded_apps = $GLOBALS['egw']->session->appsession('developer_loaded_apps','developer_tools');
74
-		$src_apps = $GLOBALS['egw']->session->appsession('developer_src_apps','developer_tools');
75
-		$missing = $GLOBALS['egw']->session->appsession('developer_missing_lang','developer_tools');
70
+		$src_file = $GLOBALS['egw']->session->appsession('developer_source_file', 'developer_tools');
71
+		$tgt_file = $GLOBALS['egw']->session->appsession('developer_target_file', 'developer_tools');
72
+		$tgt_lang = $GLOBALS['egw']->session->appsession('developer_t_lang', 'developer_tools');
73
+		$loaded_apps = $GLOBALS['egw']->session->appsession('developer_loaded_apps', 'developer_tools');
74
+		$src_apps = $GLOBALS['egw']->session->appsession('developer_src_apps', 'developer_tools');
75
+		$missing = $GLOBALS['egw']->session->appsession('developer_missing_lang', 'developer_tools');
76 76
 
77
-		$this->set_sessiondata($source,$target,$src_file,$tgt_file,$tgt_lang,$loaded_apps,$src_apps,$missing);
77
+		$this->set_sessiondata($source, $target, $src_file, $tgt_file, $tgt_lang, $loaded_apps, $src_apps, $missing);
78 78
 	}
79 79
 
80
-	function set_sessiondata($source,$target,$src_file,$tgt_file,$tgt_lang,$loaded_apps,$src_apps,$missing)
80
+	function set_sessiondata($source, $target, $src_file, $tgt_file, $tgt_lang, $loaded_apps, $src_apps, $missing)
81 81
 	{
82 82
 		$this->source_langarray = $source;
83 83
 		$this->target_langarray = $target;
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
 
92 92
 	function clear_sessiondata()
93 93
 	{
94
-		$GLOBALS['egw']->session->appsession('developer_source_lang','developer_tools','');
95
-		$GLOBALS['egw']->session->appsession('developer_target_lang','developer_tools','');
96
-		$GLOBALS['egw']->session->appsession('developer_source_file','developer_tools','');
97
-		$GLOBALS['egw']->session->appsession('developer_target_file','developer_tools','');
98
-		$GLOBALS['egw']->session->appsession('developer_t_lang','developer_tools','');
99
-		$GLOBALS['egw']->session->appsession('developer_loaded_apps','developer_tools','');
94
+		$GLOBALS['egw']->session->appsession('developer_source_lang', 'developer_tools', '');
95
+		$GLOBALS['egw']->session->appsession('developer_target_lang', 'developer_tools', '');
96
+		$GLOBALS['egw']->session->appsession('developer_source_file', 'developer_tools', '');
97
+		$GLOBALS['egw']->session->appsession('developer_target_file', 'developer_tools', '');
98
+		$GLOBALS['egw']->session->appsession('developer_t_lang', 'developer_tools', '');
99
+		$GLOBALS['egw']->session->appsession('developer_loaded_apps', 'developer_tools', '');
100 100
 	}
101 101
 
102 102
 	function addphrase($entry)
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 		}
125 125
 	}
126 126
 
127
-	function movephrase($mess='')
127
+	function movephrase($mess = '')
128 128
 	{
129
-		if ($mess !='' && ($this->missing_langarray[$mess]['message_id']))
129
+		if ($mess != '' && ($this->missing_langarray[$mess]['message_id']))
130 130
 		{
131 131
 			$this->source_langarray[$mess] = $m = array(
132 132
 				'message_id' => $this->missing_langarray[$mess]['message_id'],
@@ -148,24 +148,24 @@  discard block
 block discarded – undo
148 148
 		//else echo "'$mess' not found in missing_langarray !!!<br>\n";
149 149
 	}
150 150
 
151
-	function missing_app($app,$userlang='en')
151
+	function missing_app($app, $userlang = 'en')
152 152
 	{
153 153
 		$this->missing_langarray = array();
154 154
 
155 155
 		if (!is_array($this->extra_langarray['common']))
156 156
 		{
157
-			$this->extra_langarray['common'] = $this->so->load_app('phpgwapi',$userlang);
157
+			$this->extra_langarray['common'] = $this->so->load_app('phpgwapi', $userlang);
158 158
 		}
159
-		$plist = $this->so->missing_app($app = trim($app),$userlang);
159
+		$plist = $this->so->missing_app($app = trim($app), $userlang);
160 160
 
161
-		foreach($plist as $p => $loc)
161
+		foreach ($plist as $p => $loc)
162 162
 		{
163 163
 			$_mess_id = strtolower(trim($p));
164 164
 			if ($loc != $app)
165 165
 			{
166 166
 				if (!is_array($this->extra_langarray[$loc]))
167 167
 				{
168
-					$this->extra_langarray[$loc] = $this->so->load_app($loc,$userlang);
168
+					$this->extra_langarray[$loc] = $this->so->load_app($loc, $userlang);
169 169
 					//echo "<p>loading translations for '$loc'</p>\n";
170 170
 				}
171 171
 			}
@@ -183,57 +183,57 @@  discard block
 block discarded – undo
183 183
 		}
184 184
 		if (is_array($this->missing_langarray))
185 185
 		{
186
-			reset ($this->missing_langarray);
186
+			reset($this->missing_langarray);
187 187
 			@ksort($this->missing_langarray);
188 188
 		}
189 189
 		return $this->missing_langarray;
190 190
 	}
191 191
 
192
-	function add_app($app,$userlang='en')
192
+	function add_app($app, $userlang = 'en')
193 193
 	{
194
-		if(gettype($this->source_langarray) == 'array')
194
+		if (gettype($this->source_langarray) == 'array')
195 195
 		{
196 196
 			return $this->source_langarray;
197 197
 		}
198
-		$this->source_langarray = $this->so->load_app($app,$userlang,False);
198
+		$this->source_langarray = $this->so->load_app($app, $userlang, False);
199 199
 		$this->src_file = $this->so->src_file;
200 200
 		$this->loaded_apps = $this->so->loaded_apps;
201 201
 		$this->src_apps = $this->so->src_apps;
202 202
 		return $this->source_langarray;
203 203
 	}
204 204
 
205
-	function load_app($app,$userlang='en')
205
+	function load_app($app, $userlang = 'en')
206 206
 	{
207
-		if(gettype($this->target_langarray) == 'array')
207
+		if (gettype($this->target_langarray) == 'array')
208 208
 		{
209 209
 			if ($this->tgt_lang == $userlang)
210 210
 			{
211 211
 				return $this->target_langarray;
212 212
 			}
213 213
 		}
214
-		$this->target_langarray = $this->so->load_app($app,$userlang);
214
+		$this->target_langarray = $this->so->load_app($app, $userlang);
215 215
 		$this->tgt_file = $this->so->tgt_file;
216 216
 		$this->tgt_lang = $userlang;
217 217
 		$this->loaded_apps = $this->so->loaded_apps;
218 218
 		return $this->target_langarray;
219 219
 	}
220 220
 
221
-	function write_file($which,$app_name,$userlang)
221
+	function write_file($which, $app_name, $userlang)
222 222
 	{
223 223
 		switch ($which)
224 224
 		{
225 225
 			case 'source':
226
-				$this->src_file = $this->so->write_file($app_name,$this->source_langarray,$userlang,$which);
226
+				$this->src_file = $this->so->write_file($app_name, $this->source_langarray, $userlang, $which);
227 227
 				break;
228 228
 			case 'target':
229 229
 				// removing phrases not in the source language
230 230
 				$before = count($this->target_langarray);
231
-				$this->target_langarray = array_intersect_assoc($this->target_langarray,$this->source_langarray);
231
+				$this->target_langarray = array_intersect_assoc($this->target_langarray, $this->source_langarray);
232 232
 				if ($before > ($after = count($this->target_langarray)))
233 233
 				{
234
-					echo '<br />'. lang('Removed %1 phrases from the target language, as they are not present in the source language!',$before-$after)."\n";
234
+					echo '<br />'.lang('Removed %1 phrases from the target language, as they are not present in the source language!', $before - $after)."\n";
235 235
 				}
236
-				$this->tgt_file = $this->so->write_file($app_name,$this->target_langarray,$userlang,$which);
236
+				$this->tgt_file = $this->so->write_file($app_name, $this->target_langarray, $userlang, $which);
237 237
 				break;
238 238
 			default:
239 239
 				break;
Please login to merge, or discard this patch.
Braces   +16 added lines, -5 removed lines patch added patch discarded remove patch
@@ -47,9 +47,13 @@  discard block
 block discarded – undo
47 47
 		{
48 48
 			$target = &$this->target_langarray;
49 49
 		}
50
-		if($this->debug) { echo '<br>Save:'; _debug_array($source); }
50
+		if($this->debug)
51
+		{
52
+echo '<br>Save:'; _debug_array($source); }
51 53
 		$GLOBALS['egw']->session->appsession('developer_source_lang','developer_tools',$source);
52
-		if($this->debug) { echo '<br>Save:'; _debug_array($target); }
54
+		if($this->debug)
55
+		{
56
+echo '<br>Save:'; _debug_array($target); }
53 57
 		$GLOBALS['egw']->session->appsession('developer_target_lang','developer_tools',$target);
54 58
 		$GLOBALS['egw']->session->appsession('developer_source_file','developer_tools',$this->src_file);
55 59
 		$GLOBALS['egw']->session->appsession('developer_target_file','developer_tools',$this->tgt_file);
@@ -62,10 +66,14 @@  discard block
 block discarded – undo
62 66
 	function read_sessiondata()
63 67
 	{
64 68
 		$source = $GLOBALS['egw']->session->appsession('developer_source_lang','developer_tools');
65
-		if($this->debug) { echo '<br>Read:'; _debug_array($source); }
69
+		if($this->debug)
70
+		{
71
+echo '<br>Read:'; _debug_array($source); }
66 72
 
67 73
 		$target = $GLOBALS['egw']->session->appsession('developer_target_lang','developer_tools');
68
-		if($this->debug) { echo '<br>Read:'; _debug_array($target); }
74
+		if($this->debug)
75
+		{
76
+echo '<br>Read:'; _debug_array($target); }
69 77
 
70 78
 		$src_file = $GLOBALS['egw']->session->appsession('developer_source_file','developer_tools');
71 79
 		$tgt_file = $GLOBALS['egw']->session->appsession('developer_target_file','developer_tools');
@@ -102,7 +110,10 @@  discard block
 block discarded – undo
102 110
 	function addphrase($entry)
103 111
 	{
104 112
 		/* _debug_array($this->source_langarray);exit; */
105
-		if (empty($entry['content'])) $entry['content'] = $entry['message_id'];
113
+		if (empty($entry['content']))
114
+		{
115
+			$entry['content'] = $entry['message_id'];
116
+		}
106 117
 
107 118
 		$mess_id = strtolower(trim($entry['message_id']));
108 119
 		$this->source_langarray[$mess_id] = array(
Please login to merge, or discard this patch.
etemplate/inc/class.contact_widget.inc.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -125,7 +125,6 @@
 block discarded – undo
125 125
 
126 126
 	/**
127 127
 	 * Legacy support for putting the template name in 'label' param
128
-	 * @param string $label
129 128
 	 * @param array $attrs
130 129
 	 */
131 130
 	public function parse_template($template, &$attrs)
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		translation::add_app('addressbook');
144 144
 		$this->contacts->__construct();
145 145
 		$options = $this->contacts->contact_fields;
146
-		foreach($this->contacts->customfields as $name => $data)
146
+		foreach ($this->contacts->customfields as $name => $data)
147 147
 		{
148 148
 			$options['#'.$name] = $data['label'];
149 149
 		}
@@ -164,28 +164,28 @@  discard block
 block discarded – undo
164 164
 	public function get_contact($value, array $attrs)
165 165
 	{
166 166
 		$field = $attrs['field'] ? $attrs['field'] : '';
167
-		if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) return $value;
167
+		if (is_array($value) && !(array_key_exists('app', $value) && array_key_exists('id', $value))) return $value;
168 168
 
169
-		if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) $value = $value['id'];
170
-		switch($attrs['type'])
169
+		if (is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) $value = $value['id'];
170
+		switch ($attrs['type'])
171 171
 		{
172 172
 			case 'contact-account':
173 173
 			case 'contact-template':
174
-				if (substr($value,0,8) != 'account:')
174
+				if (substr($value, 0, 8) != 'account:')
175 175
 				{
176 176
 					$value = 'account:'.($attrs['name'] != 'account:' ? $value : $GLOBALS['egw_info']['user']['account_id']);
177 177
 				}
178 178
 				// fall-through
179 179
 			case 'contact-value':
180 180
 			default:
181
-				if (substr($value,0,12) == 'addressbook:') $value = substr($value,12);	// link-entry syntax
181
+				if (substr($value, 0, 12) == 'addressbook:') $value = substr($value, 12); // link-entry syntax
182 182
 				if (!($contact = $this->contacts->read($value)))
183 183
 				{
184 184
 					$contact = array();
185 185
 				}
186 186
 				break;
187 187
 		}
188
-		unset($contact['jpegphoto']);	// makes no sense to return binary image
188
+		unset($contact['jpegphoto']); // makes no sense to return binary image
189 189
 
190 190
 		//error_log(__METHOD__."('$value') returning ".array2string($contact));
191 191
 		return $contact;
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
 	 * @param etemplate &$tmpl reference to the template we belong too
205 205
 	 * @return boolean true if extra label is allowed, false otherwise
206 206
 	 */
207
- 	function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
207
+ 	function pre_process($name, &$value, &$cell, &$readonlys, &$extension_data, &$tmpl)
208 208
 	{
209 209
 		//echo "<p>contact_widget::pre_process('$name','$value',".print_r($cell,true).",...)</p>\n";
210
-		switch($type = $cell['type'])
210
+		switch ($type = $cell['type'])
211 211
 		{
212 212
 			case 'contact-fields':
213 213
 				$cell['sel_options'] = $this->get_contact_fields();
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 
219 219
 			case 'contact-account':
220 220
 			case 'contact-template':
221
-				if (substr($value,0,8) != 'account:')
221
+				if (substr($value, 0, 8) != 'account:')
222 222
 				{
223 223
 					$value = 'account:'.($cell['name'] != 'account:' ? $value : $GLOBALS['egw_info']['user']['account_id']);
224 224
 				}
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 				// fall-throught
227 227
 			case 'contact-value':
228 228
 			default:
229
-				if (substr($value,0,12) == 'addressbook:') $value = substr($value,12);	// link-entry syntax
229
+				if (substr($value, 0, 12) == 'addressbook:') $value = substr($value, 12); // link-entry syntax
230 230
 				if (!$value || !$cell['size'] || (!is_array($this->contact) ||
231 231
 					!($this->contact['id'] == $value || 'account:'.$this->contact['account_id'] == $value)) &&
232 232
 					!($this->contact = $this->contacts->read($value)))
@@ -242,15 +242,15 @@  discard block
 block discarded – undo
242 242
 				{
243 243
 					$name = $this->contact[$type];
244 244
 					$cell['type'] = 'template';
245
-					if (($prefix = $cell['label'])) $name = strpos($prefix,'%s') !== false ? str_replace('%s',$name,$prefix) : $prefix.$name;
246
-					$cell['obj'] = new etemplate($name,$tmpl->as_array());
245
+					if (($prefix = $cell['label'])) $name = strpos($prefix, '%s') !== false ? str_replace('%s', $name, $prefix) : $prefix.$name;
246
+					$cell['obj'] = new etemplate($name, $tmpl->as_array());
247 247
 					return false;
248 248
 				}
249 249
 				$value = $this->contact[$type];
250 250
 				$cell['no_lang'] = 1;
251 251
 				$cell['readonly'] = true;
252 252
 
253
-				switch($type)
253
+				switch ($type)
254 254
 				{
255 255
 					// ToDo: pseudo types like address-label
256 256
 
@@ -282,8 +282,8 @@  discard block
 block discarded – undo
282 282
 		}
283 283
 		$cell['id'] = ($cell['id'] ? $cell['id'] : $cell['name'])."[$type]";
284 284
 
285
-		return True;	// extra label ok
285
+		return True; // extra label ok
286 286
 	}
287 287
 }
288 288
 // register widgets for etemplate2
289
-etemplate_widget::registerWidget('contact_widget',array('contact-value', 'contact-account', 'contact-template', 'contact-fields'));
289
+etemplate_widget::registerWidget('contact_widget', array('contact-value', 'contact-account', 'contact-template', 'contact-fields'));
Please login to merge, or discard this patch.
Braces   +23 added lines, -6 removed lines patch added patch discarded remove patch
@@ -164,9 +164,15 @@  discard block
 block discarded – undo
164 164
 	public function get_contact($value, array $attrs)
165 165
 	{
166 166
 		$field = $attrs['field'] ? $attrs['field'] : '';
167
-		if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) return $value;
167
+		if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value)))
168
+		{
169
+			return $value;
170
+		}
168 171
 
169
-		if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) $value = $value['id'];
172
+		if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value))
173
+		{
174
+			$value = $value['id'];
175
+		}
170 176
 		switch($attrs['type'])
171 177
 		{
172 178
 			case 'contact-account':
@@ -178,7 +184,11 @@  discard block
 block discarded – undo
178 184
 				// fall-through
179 185
 			case 'contact-value':
180 186
 			default:
181
-				if (substr($value,0,12) == 'addressbook:') $value = substr($value,12);	// link-entry syntax
187
+				if (substr($value,0,12) == 'addressbook:')
188
+				{
189
+					$value = substr($value,12);
190
+				}
191
+				// link-entry syntax
182 192
 				if (!($contact = $this->contacts->read($value)))
183 193
 				{
184 194
 					$contact = array();
@@ -205,7 +215,7 @@  discard block
 block discarded – undo
205 215
 	 * @return boolean true if extra label is allowed, false otherwise
206 216
 	 */
207 217
  	function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
208
-	{
218
+ 	{
209 219
 		//echo "<p>contact_widget::pre_process('$name','$value',".print_r($cell,true).",...)</p>\n";
210 220
 		switch($type = $cell['type'])
211 221
 		{
@@ -226,7 +236,11 @@  discard block
 block discarded – undo
226 236
 				// fall-throught
227 237
 			case 'contact-value':
228 238
 			default:
229
-				if (substr($value,0,12) == 'addressbook:') $value = substr($value,12);	// link-entry syntax
239
+				if (substr($value,0,12) == 'addressbook:')
240
+				{
241
+					$value = substr($value,12);
242
+				}
243
+				// link-entry syntax
230 244
 				if (!$value || !$cell['size'] || (!is_array($this->contact) ||
231 245
 					!($this->contact['id'] == $value || 'account:'.$this->contact['account_id'] == $value)) &&
232 246
 					!($this->contact = $this->contacts->read($value)))
@@ -242,7 +256,10 @@  discard block
 block discarded – undo
242 256
 				{
243 257
 					$name = $this->contact[$type];
244 258
 					$cell['type'] = 'template';
245
-					if (($prefix = $cell['label'])) $name = strpos($prefix,'%s') !== false ? str_replace('%s',$name,$prefix) : $prefix.$name;
259
+					if (($prefix = $cell['label']))
260
+					{
261
+						$name = strpos($prefix,'%s') !== false ? str_replace('%s',$name,$prefix) : $prefix.$name;
262
+					}
246 263
 					$cell['obj'] = new etemplate($name,$tmpl->as_array());
247 264
 					return false;
248 265
 				}
Please login to merge, or discard this patch.
etemplate/inc/class.db_tools.inc.php 4 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -110,8 +110,7 @@  discard block
 block discarded – undo
110 110
 	/**
111 111
 	 * table editor (and the callback/submit-method too)
112 112
 	 *
113
-	 * @param array $content=null
114
-	 * @param string $msg=''
113
+	 * @param array $content
115 114
 	 */
116 115
 	function edit(array $content=null,$msg = '')
117 116
 	{
@@ -390,7 +389,7 @@  discard block
 block discarded – undo
390 389
 	 * @param string $col column name
391 390
 	 * @param array $index ix or uc array of table-defintion
392 391
 	 * @param string &$options db specific options
393
-	 * @return True if $col has a single index
392
+	 * @return boolean if $col has a single index
394 393
 	 */
395 394
 	function has_single_index($col,$index,&$options)
396 395
 	{
@@ -942,7 +941,7 @@  discard block
 block discarded – undo
942 941
 	 * unsets all keys in an array which have a given value
943 942
 	 *
944 943
 	 * @param array &$arr
945
-	 * @param mixed $val value to check against
944
+	 * @param mixed $value value to check against
946 945
 	 */
947 946
 	function remove_from_array(&$arr,$value)
948 947
 	{
@@ -1138,6 +1137,7 @@  discard block
 block discarded – undo
1138 1137
 	/**
1139 1138
 	 * creates file header
1140 1139
 	 *
1140
+	 * @param string $app
1141 1141
 	 */
1142 1142
 	function setup_header($app)
1143 1143
 	{
Please login to merge, or discard this patch.
Spacing   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 * @param array $content=null
114 114
 	 * @param string $msg=''
115 115
 	 */
116
-	function edit(array $content=null,$msg = '')
116
+	function edit(array $content = null, $msg = '')
117 117
 	{
118 118
 		if (is_array($content))
119 119
 		{
@@ -121,15 +121,15 @@  discard block
 block discarded – undo
121 121
 			{
122 122
 				echo "content ="; _debug_array($content);
123 123
 			}
124
-			$this->app = $content['app'];	// this is what the user selected
124
+			$this->app = $content['app']; // this is what the user selected
125 125
 			$this->table = $content['table_name'];
126
-			$posted_app = $content['posted_app'];	// this is the old selection
126
+			$posted_app = $content['posted_app']; // this is the old selection
127 127
 			$posted_table = $content['posted_table'];
128 128
 		}
129
-		if ($posted_app && $posted_table &&		// user changed app or table
129
+		if ($posted_app && $posted_table && // user changed app or table
130 130
 			 ($posted_app != $this->app || $posted_table != $this->table))
131 131
 		{
132
-			if ($this->needs_save('',$posted_app,$posted_table,$this->content2table($content)))
132
+			if ($this->needs_save('', $posted_app, $posted_table, $this->content2table($content)))
133 133
 			{
134 134
 				return;
135 135
 			}
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
 		}
143 143
 		else
144 144
 		{
145
-			$this->read($this->app,$this->data);
145
+			$this->read($this->app, $this->data);
146 146
 
147
-			foreach($this->data as $name => $table)
147
+			foreach ($this->data as $name => $table)
148 148
 			{
149 149
 				$table_names[$name] = $name;
150 150
 			}
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 		if (!$this->table || $this->app != $posted_app)
153 153
 		{
154 154
 			reset($this->data);
155
-			list($this->table) = each($this->data);	// use first table
155
+			list($this->table) = each($this->data); // use first table
156 156
 		}
157 157
 		elseif ($this->app == $posted_app && $posted_table)
158 158
 		{
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		}
161 161
 		if ($content['write_tables'])
162 162
 		{
163
-			if ($this->needs_save('',$this->app,$this->table,$this->data[$posted_table]))
163
+			if ($this->needs_save('', $this->app, $this->table, $this->data[$posted_table]))
164 164
 			{
165 165
 				return;
166 166
 			}
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		{
171 171
 			list($col) = each($content['delete']);
172 172
 			@reset($this->data[$posted_table]['fd']);
173
-			while ($col-- > 0 && list($key) = @each($this->data[$posted_table]['fd'])) ;
173
+			while ($col-- > 0 && list($key) = @each($this->data[$posted_table]['fd']));
174 174
 			unset($this->data[$posted_table]['fd'][$key]);
175 175
 			$this->changes[$posted_table][$key] = '**deleted**';
176 176
 		}
@@ -191,26 +191,26 @@  discard block
 block discarded – undo
191 191
 			elseif ($content['add_table'])
192 192
 			{
193 193
 				$this->table = $content['new_table_name'];
194
-				$this->data[$this->table] = array('fd' => array(),'pk' =>array(),'ix' => array(),'uc' => array(),'fk' => array());
194
+				$this->data[$this->table] = array('fd' => array(), 'pk' =>array(), 'ix' => array(), 'uc' => array(), 'fk' => array());
195 195
 				$msg .= lang('New table created');
196 196
 			}
197 197
 			else // import
198 198
 			{
199
-				$oProc =& CreateObject('phpgwapi.schema_proc',$GLOBALS['egw_info']['server']['db_type']);
200
-				if (method_exists($oProc,'GetTableDefinition'))
199
+				$oProc = & CreateObject('phpgwapi.schema_proc', $GLOBALS['egw_info']['server']['db_type']);
200
+				if (method_exists($oProc, 'GetTableDefinition'))
201 201
 				{
202 202
 					$this->data[$this->table = $content['new_table_name']] = $oProc->GetTableDefinition($content['new_table_name']);
203 203
 				}
204 204
 				else	// to support eGW 1.0
205 205
 				{
206 206
 					$oProc->m_odb = clone($GLOBALS['egw']->db);
207
-					$oProc->m_oTranslator->_GetColumns($oProc,$content['new_table_name'],$nul);
207
+					$oProc->m_oTranslator->_GetColumns($oProc, $content['new_table_name'], $nul);
208 208
 
209
-					while (list($key,$tbldata) = each ($oProc->m_oTranslator->sCol))
209
+					while (list($key, $tbldata) = each($oProc->m_oTranslator->sCol))
210 210
 					{
211 211
 						$cols .= $tbldata;
212 212
 					}
213
-					eval('$cols = array('. $cols . ');');
213
+					eval('$cols = array('.$cols.');');
214 214
 
215 215
 					$this->data[$this->table = $content['new_table_name']] = array(
216 216
 						'fd' => $cols,
@@ -243,14 +243,14 @@  discard block
 block discarded – undo
243 243
 			'table_name' => $table_names,
244 244
 			'type' => $this->types,
245 245
 		);
246
-		foreach(self::$meta_types as $value => $title)
246
+		foreach (self::$meta_types as $value => $title)
247 247
 		{
248 248
 			$sel_options['meta'][$value] = $value ? array(
249 249
 				'label' => $value,
250 250
 				'title' => $title,
251 251
 			) : $title;
252 252
 		}
253
-		foreach($this->data[$this->table]['fd'] as $col => $data)
253
+		foreach ($this->data[$this->table]['fd'] as $col => $data)
254 254
 		{
255 255
 			$meta = $title = $data['meta'];
256 256
 			if (empty($meta)) continue;
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 		}
270 270
 		if ($this->table != '' && isset($this->data[$this->table]))
271 271
 		{
272
-			$content += $this->table2content($this->data[$this->table],$sel_options['Index'],$add_index);
272
+			$content += $this->table2content($this->data[$this->table], $sel_options['Index'], $add_index);
273 273
 		}
274 274
 		$no_button = array( );
275 275
 		if (!$this->app || !$this->table)
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 			echo 'editor.edit: content ='; _debug_array($content);
282 282
 		}
283 283
 		$tpl = new etemplate('etemplate.db-tools.edit');
284
-		$tpl->exec('etemplate.db_tools.edit',$content,$sel_options,$no_button,
285
-			array('posted_table' => $this->table,'posted_app' => $this->app,'changes' => $this->changes));
284
+		$tpl->exec('etemplate.db_tools.edit', $content, $sel_options, $no_button,
285
+			array('posted_table' => $this->table, 'posted_app' => $this->app, 'changes' => $this->changes));
286 286
 	}
287 287
 
288 288
 	/**
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	 * @param array $edited_table the edited table-definitions
295 295
 	 * @return only if no changes
296 296
 	 */
297
-	function needs_save($cont='',$posted_app='',$posted_table='',$edited_table='',$msg='')
297
+	function needs_save($cont = '', $posted_app = '', $posted_table = '', $edited_table = '', $msg = '')
298 298
 	{
299 299
 		//echo "<p>db_tools::needs_save(cont,'$posted_app','$posted_table',edited_table,'$msg')</p> cont=\n"; _debug_array($cont); echo "edited_table="; _debug_array($edited_table);
300 300
 		if (!$posted_app && is_array($cont))
@@ -303,27 +303,27 @@  discard block
 block discarded – undo
303 303
 			{
304 304
 				$this->app   = $cont['app'];
305 305
 				$this->table = $cont['table'];
306
-				$this->read($this->app,$this->data);
306
+				$this->read($this->app, $this->data);
307 307
 				$this->data[$this->table] = $cont['edited_table'];
308 308
 				$this->changes = $cont['changes'];
309 309
 				if ($cont['new_version'])
310 310
 				{
311
-					$this->update($this->app,$this->data,$cont['new_version']);
311
+					$this->update($this->app, $this->data, $cont['new_version']);
312 312
 				}
313 313
 				else
314 314
 				{
315
-					foreach($this->data as $tname => $tinfo)
315
+					foreach ($this->data as $tname => $tinfo)
316 316
 					{
317
-						$tables .= ($tables ? ',' : '') . "'$tname'";
317
+						$tables .= ($tables ? ',' : '')."'$tname'";
318 318
 					}
319
-					$this->setup_version($this->app,'',$tables);
319
+					$this->setup_version($this->app, '', $tables);
320 320
 				}
321
-				if (!$this->write($this->app,$this->data))
321
+				if (!$this->write($this->app, $this->data))
322 322
 				{
323
-					$this->app = $cont['new_app'];	// these are the ones, the users whiches to change too
323
+					$this->app = $cont['new_app']; // these are the ones, the users whiches to change too
324 324
 					$this->table = $cont['new_table'];
325 325
 
326
-					return $this->needs_save('',$cont['app'],$cont['table'],$cont['edited_table'],
326
+					return $this->needs_save('', $cont['app'], $cont['table'], $cont['edited_table'],
327 327
 						lang('Error: writing file (no write-permission for the webserver) !!!'));
328 328
 				}
329 329
 				$msg = lang('File writen');
@@ -332,28 +332,28 @@  discard block
 block discarded – undo
332 332
 			// return to edit with everything set, so the user gets the table he asked for
333 333
 			$this->edit(array(
334 334
 				'app' => $cont['new_app'],
335
-				'table_name' => $cont['app']==$cont['new_app'] ? $cont['new_table'] : '',
335
+				'table_name' => $cont['app'] == $cont['new_app'] ? $cont['new_table'] : '',
336 336
 				'posted_app' => $cont['new_app']
337
-			),$msg);
337
+			), $msg);
338 338
 
339 339
 			return True;
340 340
 		}
341
-		$new_app   = $this->app;	// these are the ones, the users whiches to change too
341
+		$new_app   = $this->app; // these are the ones, the users whiches to change too
342 342
 		$new_table = $this->table;
343 343
 
344 344
 		$this->app = $posted_app;
345 345
 		$this->data = array();
346
-		$this->read($posted_app,$this->data);
346
+		$this->read($posted_app, $this->data);
347 347
 
348 348
 		if (isset($this->data[$posted_table]) &&
349
-			 $this->tables_identical($this->data[$posted_table],$edited_table))
349
+			 $this->tables_identical($this->data[$posted_table], $edited_table))
350 350
 		{
351 351
 			if ($new_app != $this->app)	// are we changeing the app, or hit the user just write
352 352
 			{
353
-				$this->app = $new_app;	// if we change init the data empty
353
+				$this->app = $new_app; // if we change init the data empty
354 354
 				$this->data = array();
355 355
 			}
356
-			return False;	// continue edit
356
+			return False; // continue edit
357 357
 		}
358 358
 		$content = array(
359 359
 			'msg' => $msg,
@@ -367,10 +367,10 @@  discard block
 block discarded – undo
367 367
 			'edited_table' => $edited_table,
368 368
 			'changes' => $this->changes
369 369
 		);
370
-		$new_version = explode('.',$content['version']);
371
-		$minor = count($new_version)-1;
372
-		$new_version[$minor] = sprintf('%03d',1+$new_version[$minor]);
373
-		$content['new_version'] = implode('.',$new_version);
370
+		$new_version = explode('.', $content['version']);
371
+		$minor = count($new_version) - 1;
372
+		$new_version[$minor] = sprintf('%03d', 1 + $new_version[$minor]);
373
+		$content['new_version'] = implode('.', $new_version);
374 374
 
375 375
 		$tmpl = new etemplate('etemplate.db-tools.ask_save');
376 376
 
@@ -379,9 +379,9 @@  discard block
 block discarded – undo
379 379
 			$tmpl->disable_cells('version');
380 380
 			$tmpl->disable_cells('new_version');
381 381
 		}
382
-		$tmpl->exec('etemplate.db_tools.needs_save',$content,array(),array(),$preserv);
382
+		$tmpl->exec('etemplate.db_tools.needs_save', $content, array(), array(), $preserv);
383 383
 
384
-		return True;	// dont continue in edit
384
+		return True; // dont continue in edit
385 385
 	}
386 386
 
387 387
 	/**
@@ -392,19 +392,19 @@  discard block
 block discarded – undo
392 392
 	 * @param string &$options db specific options
393 393
 	 * @return True if $col has a single index
394 394
 	 */
395
-	function has_single_index($col,$index,&$options)
395
+	function has_single_index($col, $index, &$options)
396 396
 	{
397
-		foreach($index as $in)
397
+		foreach ($index as $in)
398 398
 		{
399 399
 			if ($in == $col || is_array($in) && $in[0] == $col && !isset($in[1]))
400 400
 			{
401 401
 				if ($in != $col && isset($in['options']))
402 402
 				{
403
-					foreach($in['options'] as $db => $opts)
403
+					foreach ($in['options'] as $db => $opts)
404 404
 					{
405
-						$options[] = $db.'('.(is_array($opts)?implode(',',$opts):$opts).')';
405
+						$options[] = $db.'('.(is_array($opts) ? implode(',', $opts) : $opts).')';
406 406
 					}
407
-					$options = implode(', ',$options);
407
+					$options = implode(', ', $options);
408 408
 				}
409 409
 				return True;
410 410
 			}
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 	 * @param bool $extra_index add an additional index-row
421 421
 	 * @return array content-array to call exec with
422 422
 	 */
423
-	function table2content($table,&$columns,$extra_index=False)
423
+	function table2content($table, &$columns, $extra_index = False)
424 424
 	{
425 425
 		if ($this->debug >= 3)
426 426
 		{
@@ -428,16 +428,16 @@  discard block
 block discarded – undo
428 428
 		}
429 429
 		$content = $columns = array();
430 430
 		$n = 1;
431
-		foreach($table['fd'] as $col_name => $col_defs)
431
+		foreach ($table['fd'] as $col_name => $col_defs)
432 432
 		{
433 433
 			$col_defs['name'] = $col_name;
434
-			$col_defs['pk'] = in_array($col_name,$table['pk']);
435
-			$col_defs['uc']  = $this->has_single_index($col_name,$table['uc'],$col_defs['options']);
436
-			$col_defs['ix'] = $this->has_single_index($col_name,$table['ix'],$col_defs['options']);
434
+			$col_defs['pk'] = in_array($col_name, $table['pk']);
435
+			$col_defs['uc'] = $this->has_single_index($col_name, $table['uc'], $col_defs['options']);
436
+			$col_defs['ix'] = $this->has_single_index($col_name, $table['ix'], $col_defs['options']);
437 437
 			$col_defs['fk'] = $table['fk'][$col_name];
438 438
 			if (isset($col_defs['default']) && $col_defs['default'] == '')
439 439
 			{
440
-				$col_defs['default'] = is_int($col_defs['default']) ? '0' : "''";	// spezial value for empty, but set, default
440
+				$col_defs['default'] = is_int($col_defs['default']) ? '0' : "''"; // spezial value for empty, but set, default
441 441
 			}
442 442
 			$col_defs['notnull'] = isset($col_defs['nullable']) && !$col_defs['nullable'];
443 443
 
@@ -448,17 +448,17 @@  discard block
 block discarded – undo
448 448
 			$columns[$n++] = $col_name;
449 449
 		}
450 450
 		$n = 2;
451
-		foreach(array('uc','ix') as $type)
451
+		foreach (array('uc', 'ix') as $type)
452 452
 		{
453
-			foreach($table[$type] as $index)
453
+			foreach ($table[$type] as $index)
454 454
 			{
455 455
 				if (is_array($index) && isset($index[1]))	// multicolum index
456 456
 				{
457 457
 					$content['Index'][$n]['unique'] = $type == 'uc';
458 458
 					$content['Index'][$n]['n'] = $n - 1;
459
-					foreach($index as $col)
459
+					foreach ($index as $col)
460 460
 					{
461
-						$content['Index'][$n][] = array_search($col,$columns);
461
+						$content['Index'][$n][] = array_search($col, $columns);
462 462
 					}
463 463
 					++$n;
464 464
 				}
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 		}
467 467
 		if ($extra_index)
468 468
 		{
469
-			$content['Index'][$n]['n'] = $n-1;
469
+			$content['Index'][$n]['n'] = $n - 1;
470 470
 		}
471 471
 		if ($this->debug >= 3)
472 472
 		{
@@ -488,28 +488,28 @@  discard block
 block discarded – undo
488 488
 	{
489 489
 		if (!is_array($this->data))
490 490
 		{
491
-			$this->read($content['posted_app'],$this->data);
491
+			$this->read($content['posted_app'], $this->data);
492 492
 		}
493 493
 		$old_cols = $this->data[$posted_table = $content['posted_table']]['fd'];
494 494
 		$this->changes = $content['changes'];
495 495
 
496 496
 		$table = array();
497
-		$table['fd'] = array();	// do it in the default order of tables_*
497
+		$table['fd'] = array(); // do it in the default order of tables_*
498 498
 		$table['pk'] = array();
499 499
 		$table['fk'] = array();
500 500
 		$table['ix'] = array();
501 501
 		$table['uc'] = array();
502
-		for (reset($content),$n = 1; isset($content["Row$n"]); ++$n)
502
+		for (reset($content), $n = 1; isset($content["Row$n"]); ++$n)
503 503
 		{
504 504
 			$col = $content["Row$n"];
505 505
 
506 506
 			if ($col['type'] == 'auto')	// auto columns are the primary key and not null!
507 507
 			{
508
-				$col['pk'] = $col['notnull'] = true;	// set it, in case the user forgot
508
+				$col['pk'] = $col['notnull'] = true; // set it, in case the user forgot
509 509
 			}
510 510
 
511
-			while ((list($old_name,$old_col) = @each($old_cols)) &&
512
-						 $this->changes[$posted_table][$old_name] == '**deleted**') ;
511
+			while ((list($old_name, $old_col) = @each($old_cols)) &&
512
+						 $this->changes[$posted_table][$old_name] == '**deleted**');
513 513
 
514 514
 			if (($name = $col['name']) != '')		// ignoring lines without column-name
515 515
 			{
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 						case 'varchar': $col['precision'] = 255; break;
529 529
 					}
530 530
 				}
531
-				foreach($col as $prop => $val)
531
+				foreach ($col as $prop => $val)
532 532
 				{
533 533
 					switch ($prop)
534 534
 					{
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 						case 'comment':
541 541
 							if ($val != '')
542 542
 							{
543
-								$table['fd'][$name][$prop] = $prop=='default'&& $val=="''" ? '' : $val;
543
+								$table['fd'][$name][$prop] = $prop == 'default' && $val == "''" ? '' : $val;
544 544
 							}
545 545
 							break;
546 546
 						case 'notnull':
@@ -557,9 +557,9 @@  discard block
 block discarded – undo
557 557
 								if ($col['options'])
558 558
 								{
559 559
 									$opts = array();
560
-									foreach(explode(',',$col['options']) as $opt)
560
+									foreach (explode(',', $col['options']) as $opt)
561 561
 									{
562
-										list($db,$opt) = preg_split('/[(:)]/',$opt);
562
+										list($db, $opt) = preg_split('/[(:)]/', $opt);
563 563
 										$opts[$db] = is_numeric($opt) ? intval($opt) : $opt;
564 564
 									}
565 565
 									$table[$prop][] = array(
@@ -584,10 +584,10 @@  discard block
 block discarded – undo
584 584
 				$num2col[$n] = $col['name'];
585 585
 			}
586 586
 		}
587
-		foreach($content['Index'] as $n => $index)
587
+		foreach ($content['Index'] as $n => $index)
588 588
 		{
589 589
 			$idx_arr = array();
590
-			foreach($index as $key => $num)
590
+			foreach ($index as $key => $num)
591 591
 			{
592 592
 				if (is_numeric($key) && $num && @$num2col[$num])
593 593
 				{
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 	 * @param array &$phpgw_baseline where to return the data
621 621
 	 * @return boolean True if file found, False else
622 622
 	 */
623
-	function read($app,&$phpgw_baseline)
623
+	function read($app, &$phpgw_baseline)
624 624
 	{
625 625
 		$file = EGW_SERVER_ROOT."/$app/setup/tables_current.inc.php";
626 626
 
@@ -650,21 +650,21 @@  discard block
 block discarded – undo
650 650
 	 * @param string $parent
651 651
 	 * @return string
652 652
 	 */
653
-	function write_array($arr,$depth,$parent='')
653
+	function write_array($arr, $depth, $parent = '')
654 654
 	{
655
-		if (in_array($parent,array('pk','fk','ix','uc')))
655
+		if (in_array($parent, array('pk', 'fk', 'ix', 'uc')))
656 656
 		{
657 657
 			$depth = 0;
658 658
 		}
659 659
 		if ($depth)
660 660
 		{
661
-			$tabs = "\n".str_repeat("\t",$depth-1);
661
+			$tabs = "\n".str_repeat("\t", $depth - 1);
662 662
 			++$depth;
663 663
 		}
664 664
 		$def = 'array('.$tabs.($tabs ? "\t" : '');
665 665
 
666 666
 		$n = 0;
667
-		foreach($arr as $key => $val)
667
+		foreach ($arr as $key => $val)
668 668
 		{
669 669
 			if (!is_int($key))
670 670
 			{
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
 			}
686 686
 			if (is_array($val))
687 687
 			{
688
-				$def .= $this->write_array($val,$parent == 'fd' ? 0 : $depth,$key);
688
+				$def .= $this->write_array($val, $parent == 'fd' ? 0 : $depth, $key);
689 689
 			}
690 690
 			else
691 691
 			{
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 					$def .= "'".addslashes($val)."'";
703 703
 				}
704 704
 			}
705
-			if ($n < count($arr)-1)
705
+			if ($n < count($arr) - 1)
706 706
 			{
707 707
 				$def .= ','.$tabs.($tabs ? "\t" : '');
708 708
 			}
@@ -720,47 +720,47 @@  discard block
 block discarded – undo
720 720
 	 * @param array $phpgw_baseline tabledefinitions
721 721
 	 * @return boolean True if file writen else False
722 722
 	 */
723
-	function write($app,$phpgw_baseline)
723
+	function write($app, $phpgw_baseline)
724 724
 	{
725 725
 		$file = EGW_SERVER_ROOT."/$app/setup/tables_current.inc.php";
726 726
 
727
-		if (file_exists($file) && ($f = fopen($file,'r')))
727
+		if (file_exists($file) && ($f = fopen($file, 'r')))
728 728
 		{
729
-			$header = fread($f,filesize($file));
730
-			if ($end = strpos($header,');'))
729
+			$header = fread($f, filesize($file));
730
+			if ($end = strpos($header, ');'))
731 731
 			{
732
-				$footer = substr($header,$end+3);	// this preservs other stuff, which should not be there
732
+				$footer = substr($header, $end + 3); // this preservs other stuff, which should not be there
733 733
 			}
734
-			$header = substr($header,0,strpos($header,'$phpgw_baseline'));
734
+			$header = substr($header, 0, strpos($header, '$phpgw_baseline'));
735 735
 			fclose($f);
736 736
 
737 737
 			if (is_writable(EGW_SERVER_ROOT."/$app/setup"))
738 738
 			{
739
-				$old_file = EGW_SERVER_ROOT . "/$app/setup/tables_current.old.inc.php";
739
+				$old_file = EGW_SERVER_ROOT."/$app/setup/tables_current.old.inc.php";
740 740
 				if (file_exists($old_file))
741 741
 				{
742 742
 					unlink($old_file);
743 743
 				}
744
-				rename($file,$old_file);
744
+				rename($file, $old_file);
745 745
 			}
746
-			while ($header[strlen($header)-1] == "\t")
746
+			while ($header[strlen($header) - 1] == "\t")
747 747
 			{
748
-				$header = substr($header,0,strlen($header)-1);
748
+				$header = substr($header, 0, strlen($header) - 1);
749 749
 			}
750 750
 		}
751 751
 		if (!$header)
752 752
 		{
753
-			$header = $this->setup_header($this->app) . "\n\n";
753
+			$header = $this->setup_header($this->app)."\n\n";
754 754
 		}
755
-		if (!is_writeable(EGW_SERVER_ROOT."/$app/setup") || !($f = fopen($file,'w')))
755
+		if (!is_writeable(EGW_SERVER_ROOT."/$app/setup") || !($f = fopen($file, 'w')))
756 756
 		{
757 757
 			return False;
758 758
 		}
759 759
 		$def .= "\$phpgw_baseline = ";
760
-		$def .= $this->write_array($phpgw_baseline,1);
760
+		$def .= $this->write_array($phpgw_baseline, 1);
761 761
 		$def .= ";\n";
762 762
 
763
-		fwrite($f,$header . $def . $footer);
763
+		fwrite($f, $header.$def.$footer);
764 764
 		fclose($f);
765 765
 
766 766
 		return True;
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
 	 * @param string $tables new tables to include (comma delimited), if != ''
774 774
 	 * @return the version or False if the file could not be read or written
775 775
 	 */
776
-	function setup_version($app,$new = '',$tables='')
776
+	function setup_version($app, $new = '', $tables = '')
777 777
 	{
778 778
 		//echo "<p>etemplate.db_tools.setup_version('$app','$new','$tables')</p>\n";
779 779
 
@@ -787,51 +787,51 @@  discard block
 block discarded – undo
787 787
 			return False;
788 788
 		}
789 789
 		if (($new == '' || $setup_info[$app]['version'] == $new) &&
790
-				(!$tables || $setup_info[$app]['tables'] && "'".implode("','",$setup_info[$app]['tables'])."'" == $tables))
790
+				(!$tables || $setup_info[$app]['tables'] && "'".implode("','", $setup_info[$app]['tables'])."'" == $tables))
791 791
 		{
792
-			return $setup_info[$app]['version'];	// no change requested or not necessary
792
+			return $setup_info[$app]['version']; // no change requested or not necessary
793 793
 		}
794 794
 		if ($new == '')
795 795
 		{
796 796
 			$new = $setup_info[$app]['version'];
797 797
 		}
798
-		if (!($f = fopen($file,'r')))
798
+		if (!($f = fopen($file, 'r')))
799 799
 		{
800 800
 			return False;
801 801
 		}
802
-		$fcontent = fread($f,filesize($file));
803
-		fclose ($f);
802
+		$fcontent = fread($f, filesize($file));
803
+		fclose($f);
804 804
 
805 805
 		$app_pattern = "'$app'";
806
-		if (preg_match("/define\('([^']+)',$app_pattern\)/",$fcontent,$matches))
806
+		if (preg_match("/define\('([^']+)',$app_pattern\)/", $fcontent, $matches))
807 807
 		{
808 808
 			$app_pattern = $matches[1];
809 809
 		}
810 810
 		if (is_writable(EGW_SERVER_ROOT."/$app/setup"))
811 811
 		{
812
-			$old_file = EGW_SERVER_ROOT . "/$app/setup/setup.old.inc.php";
812
+			$old_file = EGW_SERVER_ROOT."/$app/setup/setup.old.inc.php";
813 813
 			if (file_exists($old_file))
814 814
 			{
815 815
 				unlink($old_file);
816 816
 			}
817
-			rename($file,$old_file);
817
+			rename($file, $old_file);
818 818
 		}
819
-		$fnew = preg_replace('/(.*\\$'."setup_info\\[$app_pattern\\]\\['version'\\][ \\t]*=[ \\t]*)'[^']*'(.*)/i","\\1'$new'\\2",$fcontent);
819
+		$fnew = preg_replace('/(.*\\$'."setup_info\\[$app_pattern\\]\\['version'\\][ \\t]*=[ \\t]*)'[^']*'(.*)/i", "\\1'$new'\\2", $fcontent);
820 820
 
821 821
 		if ($tables != '')
822 822
 		{
823 823
 			if (isset($setup_info[$app]['tables']))	// if there is already tables array, update it
824 824
 			{
825
-				$fnew = preg_replace('/(.*\\$'."setup_info\\[$app_pattern\\]\\['tables'\\][ \\t]*=[ \\t]*array\()[^)]*/i","\\1$tables",$fwas=$fnew);
825
+				$fnew = preg_replace('/(.*\\$'."setup_info\\[$app_pattern\\]\\['tables'\\][ \\t]*=[ \\t]*array\()[^)]*/i", "\\1$tables", $fwas = $fnew);
826 826
 
827 827
 				if ($fwas == $fnew)	// nothing changed => tables are in single lines
828 828
 				{
829
-					$fwas = explode("\n",$fwas);
829
+					$fwas = explode("\n", $fwas);
830 830
 					$fnew = $prefix = '';
831
-					$stage = 0;	// 0 = before, 1 = in, 2 = after tables section
832
-					foreach($fwas as $line)
831
+					$stage = 0; // 0 = before, 1 = in, 2 = after tables section
832
+					foreach ($fwas as $line)
833 833
 					{
834
-						if (preg_match('/(.*\\$'."setup_info\\[$app_pattern\\]\\['tables'\\]\\[[ \\t]*\\][ \\t]*=[ \\t]*)'/i",$line,$parts))
834
+						if (preg_match('/(.*\\$'."setup_info\\[$app_pattern\\]\\['tables'\\]\\[[ \\t]*\\][ \\t]*=[ \\t]*)'/i", $line, $parts))
835 835
 						{
836 836
 							if ($stage == 0)	// first line of tables-section
837 837
 							{
@@ -843,16 +843,16 @@  discard block
 block discarded – undo
843 843
 						{
844 844
 							if ($stage == 1)	// first line after tables-section ==> add it
845 845
 							{
846
-								$tables = explode(',',$tables);
846
+								$tables = explode(',', $tables);
847 847
 								foreach ($tables as $table)
848 848
 								{
849
-									$fnew .= $prefix . $table . ";\n";
849
+									$fnew .= $prefix.$table.";\n";
850 850
 								}
851 851
 								$stage = 2;
852 852
 							}
853
-							if (strpos($line,'?>') === False)	// dont write the closeing tag
853
+							if (strpos($line, '?>') === False)	// dont write the closeing tag
854 854
 							{
855
-								$fnew .= $line . "\n";
855
+								$fnew .= $line."\n";
856 856
 							}
857 857
 						}
858 858
 					}
@@ -860,18 +860,18 @@  discard block
 block discarded – undo
860 860
 			}
861 861
 			else	// add the tables array
862 862
 			{
863
-				if (strpos($fnew,'?>') !== false)	// remove a closeing tag
863
+				if (strpos($fnew, '?>') !== false)	// remove a closeing tag
864 864
 				{
865
-					$fnew = str_replace('?>','',$fnew);
865
+					$fnew = str_replace('?>', '', $fnew);
866 866
 				}
867 867
 				$fnew .= "\t\$setup_info[$app_pattern]['tables'] = array($tables);\n";
868 868
 			}
869 869
 		}
870
-		if (!is_writeable(EGW_SERVER_ROOT."/$app/setup") || !($f = fopen($file,'w')))
870
+		if (!is_writeable(EGW_SERVER_ROOT."/$app/setup") || !($f = fopen($file, 'w')))
871 871
 		{
872 872
 			return False;
873 873
 		}
874
-		fwrite($f,$fnew);
874
+		fwrite($f, $fnew);
875 875
 		fclose($f);
876 876
 
877 877
 		return $new;
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
 	 * @param string $version new version
886 886
 	 * @return boolean True if file writen else False
887 887
 	 */
888
-	function update($app,$current,$version)
888
+	function update($app, $current, $version)
889 889
 	{
890 890
 		//echo "<p>etemplate.db_tools.update('$app',...,'$version')</p>\n";
891 891
 		if (!is_writable(EGW_SERVER_ROOT."/$app/setup"))
@@ -896,20 +896,20 @@  discard block
 block discarded – undo
896 896
 		$file_update   = EGW_SERVER_ROOT."/$app/setup/tables_update.inc.php";
897 897
 
898 898
 		$old_version = $this->setup_version($app);
899
-		$old_version_ = str_replace('.','_',$old_version);
899
+		$old_version_ = str_replace('.', '_', $old_version);
900 900
 
901 901
 		if (file_exists($file_update))
902 902
 		{
903
-			$f = fopen($file_update,'r');
904
-			$update = fread($f,filesize($file_update));
905
-			$update = str_replace('?>','',$update);
903
+			$f = fopen($file_update, 'r');
904
+			$update = fread($f, filesize($file_update));
905
+			$update = str_replace('?>', '', $update);
906 906
 			fclose($f);
907
-			$old_file = EGW_SERVER_ROOT . "/$app/setup/tables_update.old.inc.php";
907
+			$old_file = EGW_SERVER_ROOT."/$app/setup/tables_update.old.inc.php";
908 908
 			if (file_exists($old_file))
909 909
 			{
910 910
 				unlink($old_file);
911 911
 			}
912
-			rename($file_update,$old_file);
912
+			rename($file_update, $old_file);
913 913
 		}
914 914
 		else
915 915
 		{
@@ -919,21 +919,21 @@  discard block
 block discarded – undo
919 919
 function $app"."_upgrade$old_version_()
920 920
 {\n";
921 921
 
922
-			$update .= $this->update_schema($app,$current,$tables);
922
+			$update .= $this->update_schema($app, $current, $tables);
923 923
 
924 924
 			$update .= "
925 925
 	return \$GLOBALS['setup_info']['$app']['currentver'] = '$version';
926 926
 }
927 927
 \n";
928
-		if (!($f = fopen($file_update,'w')))
928
+		if (!($f = fopen($file_update, 'w')))
929 929
 		{
930 930
 			//echo "<p>Cant open '$update' for writing !!!</p>\n";
931 931
 			return False;
932 932
 		}
933
-		fwrite($f,$update);
933
+		fwrite($f, $update);
934 934
 		fclose($f);
935 935
 
936
-		$this->setup_version($app,$version,$tables);
936
+		$this->setup_version($app, $version, $tables);
937 937
 
938 938
 		return True;
939 939
 	}
@@ -944,9 +944,9 @@  discard block
 block discarded – undo
944 944
 	 * @param array &$arr
945 945
 	 * @param mixed $val value to check against
946 946
 	 */
947
-	function remove_from_array(&$arr,$value)
947
+	function remove_from_array(&$arr, $value)
948 948
 	{
949
-		foreach($arr as $key => $val)
949
+		foreach ($arr as $key => $val)
950 950
 		{
951 951
 			if ($val == $value)
952 952
 			{
@@ -963,12 +963,12 @@  discard block
 block discarded – undo
963 963
 	 * @param string &$tables returns comma delimited list of new table-names
964 964
 	 * @return string the update-script
965 965
 	 */
966
-	function update_schema($app,$current,&$tables)
966
+	function update_schema($app, $current, &$tables)
967 967
 	{
968
-		$this->read($app,$old);
968
+		$this->read($app, $old);
969 969
 
970 970
 		$tables = '';
971
-		foreach($old as $name => $table_def)
971
+		foreach ($old as $name => $table_def)
972 972
 		{
973 973
 			if (!isset($current[$name]))	// table $name droped
974 974
 			{
@@ -976,22 +976,22 @@  discard block
 block discarded – undo
976 976
 			}
977 977
 			else
978 978
 			{
979
-				$tables .= ($tables ? ',' : '') . "'$name'";
979
+				$tables .= ($tables ? ',' : '')."'$name'";
980 980
 
981 981
 				$new_table_def = $table_def;
982
-				foreach($table_def['fd'] as $col => $col_def)
982
+				foreach ($table_def['fd'] as $col => $col_def)
983 983
 				{
984 984
 					if (!isset($current[$name]['fd'][$col]))	// column $col droped
985 985
 					{
986 986
 						if (!isset($this->changes[$name][$col]) || $this->changes[$name][$col] == '**deleted**')
987 987
 						{
988 988
 							unset($new_table_def['fd'][$col]);
989
-							$this->remove_from_array($new_table_def['pk'],$col);
990
-							$this->remove_from_array($new_table_def['fk'],$col);
991
-							$this->remove_from_array($new_table_def['ix'],$col);
992
-							$this->remove_from_array($new_table_def['uc'],$col);
989
+							$this->remove_from_array($new_table_def['pk'], $col);
990
+							$this->remove_from_array($new_table_def['fk'], $col);
991
+							$this->remove_from_array($new_table_def['ix'], $col);
992
+							$this->remove_from_array($new_table_def['uc'], $col);
993 993
 							$update .= "\t\$GLOBALS['egw_setup']->oProc->DropColumn('$name',";
994
-							$update .= $this->write_array($new_table_def,2).",'$col');\n";
994
+							$update .= $this->write_array($new_table_def, 2).",'$col');\n";
995 995
 						}
996 996
 						else	// column $col renamed
997 997
 						{
@@ -1002,25 +1002,25 @@  discard block
 block discarded – undo
1002 1002
 				}
1003 1003
 				if (is_array($this->changes[$name]))
1004 1004
 				{
1005
-					foreach($this->changes[$name] as $col => $new_col)
1005
+					foreach ($this->changes[$name] as $col => $new_col)
1006 1006
 					{
1007 1007
 						if ($new_col != '**deleted**')
1008 1008
 						{
1009
-							$old[$name]['fd'][$new_col] = $old[$name]['fd'][$col];	// to be able to detect further changes of the definition
1009
+							$old[$name]['fd'][$new_col] = $old[$name]['fd'][$col]; // to be able to detect further changes of the definition
1010 1010
 							unset($old[$name]['fd'][$col]);
1011 1011
 						}
1012 1012
 					}
1013 1013
 				}
1014 1014
 			}
1015 1015
 		}
1016
-		foreach($current as $name => $table_def)
1016
+		foreach ($current as $name => $table_def)
1017 1017
 		{
1018 1018
 			if (!isset($old[$name]))	// table $name added
1019 1019
 			{
1020
-				$tables .= ($tables ? ',' : '') . "'$name'";
1020
+				$tables .= ($tables ? ',' : '')."'$name'";
1021 1021
 
1022 1022
 				$update .= "\t\$GLOBALS['egw_setup']->oProc->CreateTable('$name',";
1023
-				$update .= $this->write_array($table_def,2).");\n";
1023
+				$update .= $this->write_array($table_def, 2).");\n";
1024 1024
 			}
1025 1025
 			else
1026 1026
 			{
@@ -1032,20 +1032,20 @@  discard block
 block discarded – undo
1032 1032
 				// check if the indices are changed and refresh the table if so
1033 1033
 				$do_refresh = serialize($old_norm) != serialize($new_norm);
1034 1034
 				// we comment out the Add or AlterColumn code as it is not needed, but might be useful for more complex updates
1035
-				foreach($table_def['fd'] as $col => $col_def)
1035
+				foreach ($table_def['fd'] as $col => $col_def)
1036 1036
 				{
1037
-					if (($add = !isset($old[$name]['fd'][$col])) ||	// column $col added
1037
+					if (($add = !isset($old[$name]['fd'][$col])) || // column $col added
1038 1038
 						 serialize($old_norm_fd[$col]) != serialize($new_norm_fd[$col])) // column definition altered
1039 1039
 					{
1040 1040
 						$update .= "\t".($do_refresh ? "/* done by RefreshTable() anyway\n\t" : '').
1041 1041
 							"\$GLOBALS['egw_setup']->oProc->".($add ? 'Add' : 'Alter')."Column('$name','$col',";
1042
-						$update .= $this->write_array($col_def,2) . ');' . ($do_refresh ? '*/' : '') . "\n";
1042
+						$update .= $this->write_array($col_def, 2).');'.($do_refresh ? '*/' : '')."\n";
1043 1043
 					}
1044 1044
 				}
1045 1045
 				if ($do_refresh)
1046 1046
 				{
1047 1047
 					$update .= "\t\$GLOBALS['egw_setup']->oProc->RefreshTable('$name',";
1048
-					$update .= $this->write_array($table_def,2).");\n";
1048
+					$update .= $this->write_array($table_def, 2).");\n";
1049 1049
 				}
1050 1050
 			}
1051 1051
 		}
@@ -1063,12 +1063,12 @@  discard block
 block discarded – undo
1063 1063
 	 * @param array $cols array with column-defs (col-name is the key)
1064 1064
 	 * @return array the new array of indices
1065 1065
 	 */
1066
-	function normalize_index($index,$cols)
1066
+	function normalize_index($index, $cols)
1067 1067
 	{
1068 1068
 		$normalized = array();
1069
-		foreach($cols as $col => $data)
1069
+		foreach ($cols as $col => $data)
1070 1070
 		{
1071
-			foreach($index as $n => $idx)
1071
+			foreach ($index as $n => $idx)
1072 1072
 			{
1073 1073
 				if ($idx == $col || is_array($idx) && $idx[0] == $col && !isset($idx[1]))
1074 1074
 				{
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
 				}
1079 1079
 			}
1080 1080
 		}
1081
-		foreach($index as $idx)
1081
+		foreach ($index as $idx)
1082 1082
 		{
1083 1083
 			$normalized[] = $idx;
1084 1084
 		}
@@ -1095,12 +1095,12 @@  discard block
 block discarded – undo
1095 1095
 	 */
1096 1096
 	function normalize($table)
1097 1097
 	{
1098
-		foreach($table['fd'] as $col => $props)
1098
+		foreach ($table['fd'] as $col => $props)
1099 1099
 		{
1100 1100
 			$table['fd'][$col] = array(
1101 1101
 				'type' => (string)$props['type'],
1102
-				'precision' => 0+$props['precision'],
1103
-				'scale' => 0+$props['scale'],
1102
+				'precision' => 0 + $props['precision'],
1103
+				'scale' => 0 + $props['scale'],
1104 1104
 				'nullable' => !isset($props['nullable']) || !!$props['nullable'],
1105 1105
 				'default' => (string)$props['default'],
1106 1106
 				'comment' => (string)$props['comment'],
@@ -1111,8 +1111,8 @@  discard block
 block discarded – undo
1111 1111
 			'fd' => $table['fd'],
1112 1112
 			'pk' => $table['pk'],
1113 1113
 			'fk' => $table['fk'],
1114
-			'ix' => $this->normalize_index($table['ix'],$table['fd']),
1115
-			'uc' => $this->normalize_index($table['uc'],$table['fd'])
1114
+			'ix' => $this->normalize_index($table['ix'], $table['fd']),
1115
+			'uc' => $this->normalize_index($table['uc'], $table['fd'])
1116 1116
 		);
1117 1117
 	}
1118 1118
 
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 	 * @return boolean true if they are identical (would create an identical schema), false otherwise
1125 1125
 	 *
1126 1126
 	 */
1127
-	function tables_identical($a,$b)
1127
+	function tables_identical($a, $b)
1128 1128
 	{
1129 1129
 		$a = serialize($this->normalize($a));
1130 1130
 		$b = serialize($this->normalize($b));
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
  * Created by eTemplates DB-Tools written by [email protected]
1149 1149
  *
1150 1150
  * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
1151
- * @package '. $app. '
1151
+ * @package '. $app.'
1152 1152
  * @subpackage setup
1153 1153
  * @version $Id'.'$
1154 1154
  */
Please login to merge, or discard this patch.
Braces   +68 added lines, -18 removed lines patch added patch discarded remove patch
@@ -235,10 +235,13 @@  discard block
 block discarded – undo
235 235
 			'table_name' => $this->table,
236 236
 			'app' => $this->app,
237 237
 		);
238
-		if (!isset($table_names[$this->table]))	// table is not jet written
238
+		if (!isset($table_names[$this->table]))
239
+		{
240
+			// table is not jet written
239 241
 		{
240 242
 			$table_names[$this->table] = $this->table;
241 243
 		}
244
+		}
242 245
 		$sel_options = array(
243 246
 			'table_name' => $table_names,
244 247
 			'type' => $this->types,
@@ -253,7 +256,10 @@  discard block
 block discarded – undo
253 256
 		foreach($this->data[$this->table]['fd'] as $col => $data)
254 257
 		{
255 258
 			$meta = $title = $data['meta'];
256
-			if (empty($meta)) continue;
259
+			if (empty($meta))
260
+			{
261
+				continue;
262
+			}
257 263
 			if (is_array($meta))
258 264
 			{
259 265
 				$this->data[$this->table]['fd'][$col]['meta'] = $meta = serialize($meta);
@@ -348,9 +354,13 @@  discard block
 block discarded – undo
348 354
 		if (isset($this->data[$posted_table]) &&
349 355
 			 $this->tables_identical($this->data[$posted_table],$edited_table))
350 356
 		{
351
-			if ($new_app != $this->app)	// are we changeing the app, or hit the user just write
357
+			if ($new_app != $this->app)
352 358
 			{
353
-				$this->app = $new_app;	// if we change init the data empty
359
+				// are we changeing the app, or hit the user just write
360
+			{
361
+				$this->app = $new_app;
362
+			}
363
+			// if we change init the data empty
354 364
 				$this->data = array();
355 365
 			}
356 366
 			return False;	// continue edit
@@ -452,9 +462,12 @@  discard block
 block discarded – undo
452 462
 		{
453 463
 			foreach($table[$type] as $index)
454 464
 			{
455
-				if (is_array($index) && isset($index[1]))	// multicolum index
465
+				if (is_array($index) && isset($index[1]))
466
+				{
467
+					// multicolum index
456 468
 				{
457 469
 					$content['Index'][$n]['unique'] = $type == 'uc';
470
+				}
458 471
 					$content['Index'][$n]['n'] = $n - 1;
459 472
 					foreach($index as $col)
460 473
 					{
@@ -503,19 +516,26 @@  discard block
 block discarded – undo
503 516
 		{
504 517
 			$col = $content["Row$n"];
505 518
 
506
-			if ($col['type'] == 'auto')	// auto columns are the primary key and not null!
519
+			if ($col['type'] == 'auto')
507 520
 			{
508
-				$col['pk'] = $col['notnull'] = true;	// set it, in case the user forgot
521
+				// auto columns are the primary key and not null!
522
+			{
523
+				$col['pk'] = $col['notnull'] = true;
524
+			}
525
+			// set it, in case the user forgot
509 526
 			}
510 527
 
511 528
 			while ((list($old_name,$old_col) = @each($old_cols)) &&
512 529
 						 $this->changes[$posted_table][$old_name] == '**deleted**') ;
513 530
 
514
-			if (($name = $col['name']) != '')		// ignoring lines without column-name
531
+			if (($name = $col['name']) != '')
532
+			{
533
+				// ignoring lines without column-name
515 534
 			{
516 535
 				if ($col['name'] != $old_name && $n <= count($old_cols))	// column renamed --> remeber it
517 536
 				{
518 537
 					$this->changes[$posted_table][$old_name] = $col['name'];
538
+			}
519 539
 					//echo "<p>content2table: $posted_table.$old_name renamed to $col[name]</p>\n";
520 540
 				}
521 541
 				if ($col['precision'] <= 0)
@@ -820,50 +840,68 @@  discard block
 block discarded – undo
820 840
 
821 841
 		if ($tables != '')
822 842
 		{
823
-			if (isset($setup_info[$app]['tables']))	// if there is already tables array, update it
843
+			if (isset($setup_info[$app]['tables']))
844
+			{
845
+				// if there is already tables array, update it
824 846
 			{
825 847
 				$fnew = preg_replace('/(.*\\$'."setup_info\\[$app_pattern\\]\\['tables'\\][ \\t]*=[ \\t]*array\()[^)]*/i","\\1$tables",$fwas=$fnew);
848
+			}
826 849
 
827
-				if ($fwas == $fnew)	// nothing changed => tables are in single lines
850
+				if ($fwas == $fnew)
851
+				{
852
+					// nothing changed => tables are in single lines
828 853
 				{
829 854
 					$fwas = explode("\n",$fwas);
855
+				}
830 856
 					$fnew = $prefix = '';
831 857
 					$stage = 0;	// 0 = before, 1 = in, 2 = after tables section
832 858
 					foreach($fwas as $line)
833 859
 					{
834 860
 						if (preg_match('/(.*\\$'."setup_info\\[$app_pattern\\]\\['tables'\\]\\[[ \\t]*\\][ \\t]*=[ \\t]*)'/i",$line,$parts))
835 861
 						{
836
-							if ($stage == 0)	// first line of tables-section
862
+							if ($stage == 0)
863
+							{
864
+								// first line of tables-section
837 865
 							{
838 866
 								$stage = 1;
867
+							}
839 868
 								$prefix = $parts[1];
840 869
 							}
841 870
 						}
842 871
 						else					// not in table-section
843 872
 						{
844
-							if ($stage == 1)	// first line after tables-section ==> add it
873
+							if ($stage == 1)
874
+							{
875
+								// first line after tables-section ==> add it
845 876
 							{
846 877
 								$tables = explode(',',$tables);
878
+							}
847 879
 								foreach ($tables as $table)
848 880
 								{
849 881
 									$fnew .= $prefix . $table . ";\n";
850 882
 								}
851 883
 								$stage = 2;
852 884
 							}
853
-							if (strpos($line,'?>') === False)	// dont write the closeing tag
885
+							if (strpos($line,'?>') === False)
886
+							{
887
+								// dont write the closeing tag
854 888
 							{
855 889
 								$fnew .= $line . "\n";
856 890
 							}
891
+							}
857 892
 						}
858 893
 					}
859 894
 				}
860 895
 			}
861 896
 			else	// add the tables array
862 897
 			{
863
-				if (strpos($fnew,'?>') !== false)	// remove a closeing tag
898
+				if (strpos($fnew,'?>') !== false)
899
+				{
900
+					// remove a closeing tag
864 901
 				{
865 902
 					$fnew = str_replace('?>','',$fnew);
866 903
 				}
904
+				}
867 905
 				$fnew .= "\t\$setup_info[$app_pattern]['tables'] = array($tables);\n";
868 906
 			}
869 907
 		}
@@ -970,10 +1008,13 @@  discard block
 block discarded – undo
970 1008
 		$tables = '';
971 1009
 		foreach($old as $name => $table_def)
972 1010
 		{
973
-			if (!isset($current[$name]))	// table $name droped
1011
+			if (!isset($current[$name]))
1012
+			{
1013
+				// table $name droped
974 1014
 			{
975 1015
 				$update .= "\t\$GLOBALS['egw_setup']->oProc->DropTable('$name');\n";
976 1016
 			}
1017
+			}
977 1018
 			else
978 1019
 			{
979 1020
 				$tables .= ($tables ? ',' : '') . "'$name'";
@@ -981,11 +1022,14 @@  discard block
 block discarded – undo
981 1022
 				$new_table_def = $table_def;
982 1023
 				foreach($table_def['fd'] as $col => $col_def)
983 1024
 				{
984
-					if (!isset($current[$name]['fd'][$col]))	// column $col droped
1025
+					if (!isset($current[$name]['fd'][$col]))
1026
+					{
1027
+						// column $col droped
985 1028
 					{
986 1029
 						if (!isset($this->changes[$name][$col]) || $this->changes[$name][$col] == '**deleted**')
987 1030
 						{
988 1031
 							unset($new_table_def['fd'][$col]);
1032
+					}
989 1033
 							$this->remove_from_array($new_table_def['pk'],$col);
990 1034
 							$this->remove_from_array($new_table_def['fk'],$col);
991 1035
 							$this->remove_from_array($new_table_def['ix'],$col);
@@ -1015,9 +1059,12 @@  discard block
 block discarded – undo
1015 1059
 		}
1016 1060
 		foreach($current as $name => $table_def)
1017 1061
 		{
1018
-			if (!isset($old[$name]))	// table $name added
1062
+			if (!isset($old[$name]))
1063
+			{
1064
+				// table $name added
1019 1065
 			{
1020 1066
 				$tables .= ($tables ? ',' : '') . "'$name'";
1067
+			}
1021 1068
 
1022 1069
 				$update .= "\t\$GLOBALS['egw_setup']->oProc->CreateTable('$name',";
1023 1070
 				$update .= $this->write_array($table_def,2).");\n";
@@ -1035,10 +1082,13 @@  discard block
 block discarded – undo
1035 1082
 				foreach($table_def['fd'] as $col => $col_def)
1036 1083
 				{
1037 1084
 					if (($add = !isset($old[$name]['fd'][$col])) ||	// column $col added
1038
-						 serialize($old_norm_fd[$col]) != serialize($new_norm_fd[$col])) // column definition altered
1085
+						 serialize($old_norm_fd[$col]) != serialize($new_norm_fd[$col]))
1086
+					{
1087
+						// column definition altered
1039 1088
 					{
1040 1089
 						$update .= "\t".($do_refresh ? "/* done by RefreshTable() anyway\n\t" : '').
1041 1090
 							"\$GLOBALS['egw_setup']->oProc->".($add ? 'Add' : 'Alter')."Column('$name','$col',";
1091
+					}
1042 1092
 						$update .= $this->write_array($col_def,2) . ');' . ($do_refresh ? '*/' : '') . "\n";
1043 1093
 					}
1044 1094
 				}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 
444 444
 			$col_defs['n'] = $n;
445 445
 
446
-			$content["Row$n"] = $col_defs;
446
+			$content["row$n"] = $col_defs;
447 447
 
448 448
 			$columns[$n++] = $col_name;
449 449
 		}
@@ -499,9 +499,9 @@  discard block
 block discarded – undo
499 499
 		$table['fk'] = array();
500 500
 		$table['ix'] = array();
501 501
 		$table['uc'] = array();
502
-		for (reset($content),$n = 1; isset($content["Row$n"]); ++$n)
502
+		for (reset($content),$n = 1; isset($content["row$n"]); ++$n)
503 503
 		{
504
-			$col = $content["Row$n"];
504
+			$col = $content["row$n"];
505 505
 
506 506
 			if ($col['type'] == 'auto')	// auto columns are the primary key and not null!
507 507
 			{
Please login to merge, or discard this patch.
etemplate/inc/class.editor.inc.php 4 patches
Doc Comments   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
 	 *
1040 1040
 	 * @param array &$widget reference into the widget-tree
1041 1041
 	 * @param array &$cell_content cell array in content
1042
-	 * @param boolean $widget2content=true copy from widget to content or other direction
1042
+	 * @param boolean $widget2content copy from widget to content or other direction
1043 1043
 	 */
1044 1044
 	function fix_set_onclick(&$widget,&$cell_content,$widget2content=true)
1045 1045
 	{
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
 	 *
1117 1117
 	 * @param array &$widget reference into the widget-tree
1118 1118
 	 * @param array &$cell_content cell array in content
1119
-	 * @param boolean $widget2content=true copy from widget to content or other direction
1119
+	 * @param boolean $widget2content copy from widget to content or other direction
1120 1120
 	 */
1121 1121
 	function fix_set_onchange(&$widget,&$cell_content,$widget2content=true)
1122 1122
 	{
@@ -1586,7 +1586,6 @@  discard block
 block discarded – undo
1586 1586
 	 * extensions are class-files in $app/inc/class.${name}_widget.inc.php
1587 1587
 	 * the extensions found will be saved in a class-var and in the session
1588 1588
 	 *
1589
-	 * @param string $app='etemplate' app to scan
1590 1589
 	 * @return string comma delimited list of new found extensions
1591 1590
 	 */
1592 1591
 	function scan_for_extensions($app='etemplate')
Please login to merge, or discard this patch.
Spacing   +261 added lines, -262 removed lines patch added patch discarded remove patch
@@ -97,8 +97,7 @@  discard block
 block discarded – undo
97 97
 	);
98 98
 	var $extensions = '';
99 99
 
100
-	var $public_functions = array
101
-	(
100
+	var $public_functions = array(
102 101
 		'edit'         => True,
103 102
 		'widget'       => True,
104 103
 		'styles'       => True,
@@ -108,15 +107,15 @@  discard block
 block discarded – undo
108 107
 	{
109 108
 		$this->etemplate = new etemplate();
110 109
 
111
-		$this->extensions = $GLOBALS['egw']->session->appsession('extensions','etemplate');
110
+		$this->extensions = $GLOBALS['egw']->session->appsession('extensions', 'etemplate');
112 111
 	}
113 112
 
114
-	function export_xml(&$xml,&$xml_label)
113
+	function export_xml(&$xml, &$xml_label)
115 114
 	{
116 115
 		$name = $this->etemplate->name;
117 116
 		$template = $this->etemplate->template != '' ? $this->etemplate->template : 'default';
118 117
 
119
-		list($app) = explode('.',$name);
118
+		list($app) = explode('.', $name);
120 119
 
121 120
 		if (!is_object($this->etemplate->xul_io))
122 121
 		{
@@ -124,15 +123,15 @@  discard block
 block discarded – undo
124 123
 		}
125 124
 		$xml = $this->etemplate->xul_io->export($this->etemplate);
126 125
 
127
-		$dir = EGW_SERVER_ROOT . "/$app/templates/$template";
126
+		$dir = EGW_SERVER_ROOT."/$app/templates/$template";
128 127
 		if (($create_it = !is_dir($dir)))
129 128
 		{
130
-			$dir = EGW_SERVER_ROOT . "/$app/templates";
129
+			$dir = EGW_SERVER_ROOT."/$app/templates";
131 130
 		}
132 131
 		if (!is_writeable($dir))
133 132
 		{
134 133
 			// if dir is not writable, download file
135
-			html::content_header($name.'.xet','application/xml',bytes($xml));
134
+			html::content_header($name.'.xet', 'application/xml', bytes($xml));
136 135
 			echo $xml;
137 136
 			common::egw_exit();
138 137
 			//return lang("Error: webserver is not allowed to write into '%1' !!!",$dir);
@@ -141,12 +140,12 @@  discard block
 block discarded – undo
141 140
 		{
142 141
 			mkdir($dir .= "/$template");
143 142
 		}
144
-		$file = $dir . '/' . substr($name,strlen($app)+1);
143
+		$file = $dir.'/'.substr($name, strlen($app) + 1);
145 144
 		if ($this->etemplate->lang)
146 145
 		{
147
-			$file .= '.' . $this->etemplate->lang;
146
+			$file .= '.'.$this->etemplate->lang;
148 147
 		}
149
-		$old_file = $file . '.old.xet';
148
+		$old_file = $file.'.old.xet';
150 149
 		$file .= '.xet';
151 150
 		if (file_exists($file))
152 151
 		{
@@ -154,10 +153,10 @@  discard block
 block discarded – undo
154 153
 			{
155 154
 				unlink($old_file);
156 155
 			}
157
-			rename($file,$old_file);
156
+			rename($file, $old_file);
158 157
 		}
159 158
 
160
-		if (!($f = fopen($xml_label=$file,'w')))
159
+		if (!($f = fopen($xml_label = $file, 'w')))
161 160
 		{
162 161
 			return 0;
163 162
 		}
@@ -167,26 +166,26 @@  discard block
 block discarded – undo
167 166
 		}
168 167
 		$xml = $this->etemplate->xul_io->export($this->etemplate);
169 168
 
170
-		fwrite($f,$xml);
169
+		fwrite($f, $xml);
171 170
 		fclose($f);
172 171
 
173
-		return lang("eTemplate '%1' written to '%2'",$name,$file);
172
+		return lang("eTemplate '%1' written to '%2'", $name, $file);
174 173
 	}
175 174
 
176
-	function import_xml($file,&$xml)
175
+	function import_xml($file, &$xml)
177 176
 	{
178
-		if ($file == 'none' || $file == '' || !($f = fopen($file,'r')))
177
+		if ($file == 'none' || $file == '' || !($f = fopen($file, 'r')))
179 178
 		{
180 179
 			return lang('no filename given or selected via Browse...')."file='$file'";
181 180
 		}
182
-		$xml = fread ($f, filesize ($file));
181
+		$xml = fread($f, filesize($file));
183 182
 		fclose($f);
184 183
 
185 184
 		if (!is_object($this->etemplate->xul_io))
186 185
 		{
187 186
 			$this->etemplate->xul_io = new xul_io();
188 187
 		}
189
-		$imported = $this->etemplate->xul_io->import($this->etemplate,$xml);
188
+		$imported = $this->etemplate->xul_io->import($this->etemplate, $xml);
190 189
 		$this->etemplate->modified = @filemtime($f);
191 190
 		$this->etemplate->modified_set = 'xul-import';
192 191
 
@@ -194,7 +193,7 @@  discard block
 block discarded – undo
194 193
 		{
195 194
 			if (count($imported) == 1)
196 195
 			{
197
-				$imported = lang("eTemplate '%1' imported, use Save to put it in the database",$this->etemplate->name);
196
+				$imported = lang("eTemplate '%1' imported, use Save to put it in the database", $this->etemplate->name);
198 197
 			}
199 198
 			else
200 199
 			{
@@ -204,7 +203,7 @@  discard block
 block discarded – undo
204 203
 		return $imported;
205 204
 	}
206 205
 
207
-	function list_result($cont='',$msg='')
206
+	function list_result($cont = '', $msg = '')
208 207
 	{
209 208
 		if ($this->debug)
210 209
 		{
@@ -223,11 +222,11 @@  discard block
 block discarded – undo
223 222
 		if (isset($cont['delete']))
224 223
 		{
225 224
 			list($delete) = each($cont['delete']);
226
-			$this->etemplate->init($result[$delete-1]);
225
+			$this->etemplate->init($result[$delete - 1]);
227 226
 			if ($this->etemplate->delete())
228 227
 			{
229 228
 				$msg = lang('Template deleted');
230
-				unset($result[$delete-1]);
229
+				unset($result[$delete - 1]);
231 230
 				$result = array_values($result);
232 231
 			}
233 232
 			else
@@ -237,21 +236,21 @@  discard block
 block discarded – undo
237 236
 		}
238 237
 		if (isset($cont['delete_selected']))
239 238
 		{
240
-			foreach($cont['selected'] as $row => $sel)
239
+			foreach ($cont['selected'] as $row => $sel)
241 240
 			{
242 241
 				if ($sel)
243 242
 				{
244
-					$this->etemplate->init($result[$row-1]);
243
+					$this->etemplate->init($result[$row - 1]);
245 244
 					if ($this->etemplate->delete())
246 245
 					{
247
-						unset($result[$row-1]);
246
+						unset($result[$row - 1]);
248 247
 						++$n;
249 248
 					}
250 249
 				}
251 250
 			}
252 251
 			if ($n)
253 252
 			{
254
-				$msg = lang('%1 eTemplates deleted',$n);
253
+				$msg = lang('%1 eTemplates deleted', $n);
255 254
 			}
256 255
 			unset($cont['selected']);
257 256
 			unset($cont['delete_selected']);
@@ -260,13 +259,13 @@  discard block
 block discarded – undo
260 259
 		if (isset($cont['read']))
261 260
 		{
262 261
 			list($read) = each($cont['read']);
263
-			$this->etemplate->read($result[$read-1]);
262
+			$this->etemplate->read($result[$read - 1]);
264 263
 			$this->edit();
265 264
 			return;
266 265
 		}
267 266
 		if (!$msg)
268 267
 		{
269
-			$msg = lang('%1 eTemplates found',count($result));
268
+			$msg = lang('%1 eTemplates found', count($result));
270 269
 		}
271 270
 		unset($cont['result']);
272 271
 		if (!isset($cont['name']))
@@ -276,15 +275,15 @@  discard block
 block discarded – undo
276 275
 		$content = $cont + array('msg' => $msg);
277 276
 
278 277
 		reset($result);
279
-		for ($row=1; list(,$param) = each($result); ++$row)
278
+		for ($row = 1; list(,$param) = each($result); ++$row)
280 279
 		{
281 280
 			$content[$row] = $param;
282 281
 		}
283 282
 		$list_result = new etemplate('etemplate.editor.list_result');
284 283
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Editable Templates - Search');
285
-		$list_result->exec('etemplate.editor.list_result',$content,'','',array(
284
+		$list_result->exec('etemplate.editor.list_result', $content, '', '', array(
286 285
 			'result' => $result,
287
-		),'');
286
+		), '');
288 287
 	}
289 288
 
290 289
 	/**
@@ -293,7 +292,7 @@  discard block
 block discarded – undo
293 292
 	 * @param array $content content from the process_exec call
294 293
 	 * @param string $msg message to show
295 294
 	 */
296
-	function edit($content=null,$msg = '')
295
+	function edit($content = null, $msg = '')
297 296
 	{
298 297
 		if ($this->debug)
299 298
 		{
@@ -304,7 +303,7 @@  discard block
 block discarded – undo
304 303
 
305 304
 		if ($content['import_xml'])
306 305
 		{
307
-			$msg .= $this->import_xml($content['file']['tmp_name'],$xml);
306
+			$msg .= $this->import_xml($content['file']['tmp_name'], $xml);
308 307
 			//$this->etemplate->echo_tmpl();
309 308
 			$xml_label = $content['file']['name'];
310 309
 			$preserv['import'] = $this->etemplate->as_array(1);
@@ -322,7 +321,7 @@  discard block
 block discarded – undo
322 321
 			{
323 322
 				$this->etemplate->modified = time();
324 323
 			}
325
-			$ok = $this->etemplate->save(trim($content['name']),trim($content['template']),trim($content['lang']),(int) $content['group'],trim($content['version']));
324
+			$ok = $this->etemplate->save(trim($content['name']), trim($content['template']), trim($content['lang']), (int)$content['group'], trim($content['version']));
326 325
 			$msg = $ok ? lang('Template saved') : lang('Error: while saving !!!');
327 326
 			if ($ok) unset($preserv['import']);
328 327
 		}
@@ -330,7 +329,7 @@  discard block
 block discarded – undo
330 329
 		{
331 330
 			if ($_GET['name'])
332 331
 			{
333
-				foreach(boetemplate::$db_key_cols as $var)
332
+				foreach (boetemplate::$db_key_cols as $var)
334 333
 				{
335 334
 					$content[$var] = $_GET[$var];
336 335
 				}
@@ -348,7 +347,7 @@  discard block
 block discarded – undo
348 347
 				if (isset($content['name']))
349 348
 				{
350 349
 					$version_backup = $content['version'];
351
-					$content['version'] = '';	// trying it without version
350
+					$content['version'] = ''; // trying it without version
352 351
 					if ($this->etemplate->read($content))
353 352
 					{
354 353
 						$msg = lang('only an other Version found !!!');
@@ -381,36 +380,36 @@  discard block
 block discarded – undo
381 380
 				$link = $this->etemplate->as_array(-1);
382 381
 				$link['menuaction'] = 'etemplate.editor.edit';
383 382
 				$link['version'] = $newest_version;
384
-				$msg = lang("newer version '%1' exists !!!",html::a_href($newest_version,$link));
383
+				$msg = lang("newer version '%1' exists !!!", html::a_href($newest_version, $link));
385 384
 			}
386 385
 		}
387 386
 		if (!is_array($this->extensions))
388 387
 		{
389 388
 			if (($extensions = $this->scan_for_extensions()))
390 389
 			{
391
-				$msg .= lang('Extensions loaded:') . ' ' . $extensions."\n";
390
+				$msg .= lang('Extensions loaded:').' '.$extensions."\n";
392 391
 				$msg_ext_loaded = True;
393 392
 			}
394 393
 		}
395
-		list($app) = explode('.',$this->etemplate->name?$this->etemplate->name:$content['name']);
394
+		list($app) = explode('.', $this->etemplate->name ? $this->etemplate->name : $content['name']);
396 395
 		if ($app && $app != 'etemplate')
397 396
 		{
398
-			translation::add_app($app);	// load translations for app
397
+			translation::add_app($app); // load translations for app
399 398
 
400 399
 			if (($extensions = $this->scan_for_extensions($app)))
401 400
 			{
402
-				$msg .= (!$msg_ext_loaded?lang('Extensions loaded:').' ':', ') . $extensions."\n";
401
+				$msg .= (!$msg_ext_loaded ? lang('Extensions loaded:').' ' : ', ').$extensions."\n";
403 402
 			}
404 403
 		}
405 404
 		if (!$msg && $content['delete'])
406 405
 		{
407 406
 			if (!$content['version'] && $this->etemplate->version)
408 407
 			{
409
-				$this->etemplate->version = '';	// else the newest would get deleted and not the one without version
408
+				$this->etemplate->version = ''; // else the newest would get deleted and not the one without version
410 409
 			}
411 410
 			$ok = $this->etemplate->delete();
412 411
 			$msg = $ok ? lang('Template deleted') : lang('Error: Template not found !!!');
413
-			$preserv['import'] = $this->etemplate->as_array(1);	// that way the content can be saved again
412
+			$preserv['import'] = $this->etemplate->as_array(1); // that way the content can be saved again
414 413
 		}
415 414
 		elseif ($content['restore'])
416 415
 		{
@@ -418,9 +417,9 @@  discard block
 block discarded – undo
418 417
 			{
419 418
 				$msg .= lang('Application name needed to restore eTemplates!');
420 419
 			}
421
-			elseif (!@file_exists(EGW_SERVER_ROOT.'/'.($file=$app.'/setup/etemplates.inc.php')))
420
+			elseif (!@file_exists(EGW_SERVER_ROOT.'/'.($file = $app.'/setup/etemplates.inc.php')))
422 421
 			{
423
-				$msg .= lang('Application has no eTemplates (no file %1) to restore!',$file);
422
+				$msg .= lang('Application has no eTemplates (no file %1) to restore!', $file);
424 423
 			}
425 424
 			else
426 425
 			{
@@ -454,10 +453,10 @@  discard block
 block discarded – undo
454 453
 				}
455 454
 				else	// try to call the writeLangFile function of the app's ui-layer
456 455
 				{
457
-					foreach(array('ui'.$name,'ui',$name,'bo'.$name) as $class)
456
+					foreach (array('ui'.$name, 'ui', $name, 'bo'.$name) as $class)
458 457
 					{
459 458
 						if (file_exists(EGW_INCLUDE_ROOT.'/'.$name.'/inc/class.'.$class.'.inc.php') &&
460
-							($ui =& CreateObject($name.'.'.$class)) && is_object($ui))
459
+							($ui = & CreateObject($name.'.'.$class)) && is_object($ui))
461 460
 						{
462 461
 							break;
463 462
 						}
@@ -470,13 +469,13 @@  discard block
 block discarded – undo
470 469
 				}
471 470
 				//if (empty($msg))
472 471
 				{
473
-					$msg = $this->etemplate->writeLangFile($app,'en',$additional);
472
+					$msg = $this->etemplate->writeLangFile($app, 'en', $additional);
474 473
 				}
475 474
 			}
476 475
 		}
477 476
 		elseif ($content['export_xml'])
478 477
 		{
479
-			$msg .= $this->export_xml($xml,$xml_label);
478
+			$msg .= $this->export_xml($xml, $xml_label);
480 479
 		}
481 480
 		$new_content = $this->etemplate->as_array() + array(
482 481
 			'msg' => $msg,
@@ -488,7 +487,7 @@  discard block
 block discarded – undo
488 487
 		if (isset($content['values']) && !isset($content['vals']))
489 488
 		{
490 489
 			$r = 1;
491
-			foreach((array)$content['cont'] as $key => $val)
490
+			foreach ((array)$content['cont'] as $key => $val)
492 491
 			{
493 492
 				$vals["@$r"] = $key;
494 493
 				$vals["A$r"] = is_array($val) ? serialize($val).'#SeR#' : $val;
@@ -507,7 +506,7 @@  discard block
 block discarded – undo
507 506
 			<script language="javascript">
508 507
 				function edit_widget(path)
509 508
 				{
510
-					var url = "'.$GLOBALS['egw']->link('/index.php',$this->etemplate->as_array(-1)+array(
509
+					var url = "'.$GLOBALS['egw']->link('/index.php', $this->etemplate->as_array(-1) + array(
511 510
 						'menuaction' => 'etemplate.editor.widget',
512 511
 					)).'";
513 512
 					url = url.replace(/index.php\\?/,"index.php?path="+path+"&");
@@ -521,7 +520,7 @@  discard block
 block discarded – undo
521 520
 			// check if application of template has a app.js file --> load it
522 521
 			if (file_exists(EGW_SERVER_ROOT.'/'.$app.'/js/app.js'))
523 522
 			{
524
-				$GLOBALS['egw']->js->validate_file('.','app',$app,false);
523
+				$GLOBALS['egw']->js->validate_file('.', 'app', $app, false);
525 524
 			}
526 525
 			$editor->data[$editor->rows]['A']['obj'] = &$this->etemplate;
527 526
 			$vals = $content['vals'];
@@ -529,22 +528,22 @@  discard block
 block discarded – undo
529 528
 
530 529
 			for ($r = 1; isset($vals["A$r"]); ++$r)
531 530
 			{
532
-				$new_content['cont'][$olds["@$r"]] = substr($vals["A$r"],-5)=='#SeR#' ?
533
-					unserialize(substr($vals["A$r"],0,-5)) : $vals["A$r"];
531
+				$new_content['cont'][$olds["@$r"]] = substr($vals["A$r"], -5) == '#SeR#' ?
532
+					unserialize(substr($vals["A$r"], 0, -5)) : $vals["A$r"];
534 533
 			}
535 534
 		}
536 535
 		// check if bo class of $app exists and has a labels method --> add labels to content to display them in the editor
537
-		if(class_exists($app.'_bo') && method_exists($app.'_bo','labels'))
536
+		if (class_exists($app.'_bo') && method_exists($app.'_bo', 'labels'))
538 537
 		{
539
-			$new_content['labels'] = ExecMethod($acm=$app.'.'.$app.'_bo.labels');
540
-			$new_content['cont']['labels'] =& $new_content['labels'];
538
+			$new_content['labels'] = ExecMethod($acm = $app.'.'.$app.'_bo.labels');
539
+			$new_content['cont']['labels'] = & $new_content['labels'];
541 540
 			//echo $acm; _debug_array($new_content['labels']);
542 541
 		}
543 542
 		$preserv['olds'] = $vals;
544
-		$preserv['old_keys'] = $this->etemplate->as_array(-1);	// in case we do a save as
543
+		$preserv['old_keys'] = $this->etemplate->as_array(-1); // in case we do a save as
545 544
 
546 545
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Editable Templates - Show Template');
547
-		$editor->exec('etemplate.editor.edit',$new_content,array(),'',$preserv,0,'/^cont/');
546
+		$editor->exec('etemplate.editor.edit', $new_content, array(), '', $preserv, 0, '/^cont/');
548 547
 	}
549 548
 
550 549
 	/**
@@ -554,7 +553,7 @@  discard block
 block discarded – undo
554 553
 	 * @param array &$widget reference to the new widget data
555 554
 	 * @param array $old the old widget data
556 555
 	 */
557
-	function change_widget_type(&$widget,$old)
556
+	function change_widget_type(&$widget, $old)
558 557
 	{
559 558
 		//echo "<p>editor::change_widget_type($widget[type]=$old[type])</p>\n";
560 559
 		$old_type = $old['type'];
@@ -565,13 +564,13 @@  discard block
 block discarded – undo
565 564
 		{
566 565
 			if (boetemplate::$widgets_with_children[$widget['type']] == 'box')	// box
567 566
 			{
568
-				if ((int) $widget['size'] < 1)	// min. 1 child
567
+				if ((int)$widget['size'] < 1)	// min. 1 child
569 568
 				{
570
-					list(,$options) = explode(',',$widget['size'],2);
569
+					list(,$options) = explode(',', $widget['size'], 2);
571 570
 					$widget['size'] = '1'.($options ? ','.$options : '');
572 571
 				}
573 572
 				// create the needed cells, if they dont exist
574
-				for ($n = 1; $n <= (int) $widget['size']; ++$n)
573
+				for ($n = 1; $n <= (int)$widget['size']; ++$n)
575 574
 				{
576 575
 					if (!is_array($widget[$n])) $widget[$n] = $n == 1 ? $old : boetemplate::empty_cell();
577 576
 				}
@@ -586,19 +585,19 @@  discard block
 block discarded – undo
586 585
 
587 586
 				if ($old_had_children)	// box --> grid: hbox --> 1 row, other boxes --> 1 column
588 587
 				{
589
-					list($num) = explode(',',$old['size']);
588
+					list($num) = explode(',', $old['size']);
590 589
 					for ($n = 1; is_array($old[$n]) && $n <= $num; ++$n)
591 590
 					{
592 591
 						$new_line = null;
593
-						if ($old_type != 'hbox') boetemplate::add_child($widget,$new_line);
594
-						boetemplate::add_child($widget,$old[$n]);
592
+						if ($old_type != 'hbox') boetemplate::add_child($widget, $new_line);
593
+						boetemplate::add_child($widget, $old[$n]);
595 594
 						unset($widget[$n]);
596 595
 					}
597 596
 					$widget['size'] = '';
598 597
 				}
599 598
 				else	// 1 row with 1 column/child
600 599
 				{
601
-					boetemplate::add_child($widget,$cell=boetemplate::empty_cell());
600
+					boetemplate::add_child($widget, $cell = boetemplate::empty_cell());
602 601
 				}
603 602
 				break;
604 603
 
@@ -607,7 +606,7 @@  discard block
 block discarded – undo
607 606
 
608 607
 				if ($old_type == 'grid')
609 608
 				{
610
-					if (preg_match('/,(vertical|horizontal)/',$widget['size'],$matches))
609
+					if (preg_match('/,(vertical|horizontal)/', $widget['size'], $matches))
611 610
 					{
612 611
 						$orient = $matches[1];
613 612
 					}
@@ -617,12 +616,12 @@  discard block
 block discarded – undo
617 616
 					}
618 617
 					if ($orient == 'horizontal')	// ==> use first row
619 618
 					{
620
-						$row =& $old['data'][1];
619
+						$row = & $old['data'][1];
621 620
 						for ($n = 0; $n < $old['cols']; ++$n)
622 621
 						{
623
-							$cell =& $row[boetemplate::num2chrs($n)];
624
-							boetemplate::add_child($widget,$cell);
625
-							list($span) = (int)explode(',',$cell['span']);
622
+							$cell = & $row[boetemplate::num2chrs($n)];
623
+							boetemplate::add_child($widget, $cell);
624
+							list($span) = (int)explode(',', $cell['span']);
626 625
 							if ($span == 'all') break;
627 626
 							while ($span-- > 1) ++$n;
628 627
 						}
@@ -631,13 +630,13 @@  discard block
 block discarded – undo
631 630
 					{
632 631
 						for ($n = 1; $n <= $old['rows']; ++$n)
633 632
 						{
634
-							boetemplate::add_child($widget,$old['data'][$n][boetemplate::num2chrs(0)]);
633
+							boetemplate::add_child($widget, $old['data'][$n][boetemplate::num2chrs(0)]);
635 634
 						}
636 635
 					}
637 636
 				}
638 637
 				if (!$widget['size']) // minimum one child
639 638
 				{
640
-					boetemplate::add_child($widget,boetemplate::empty_cell());
639
+					boetemplate::add_child($widget, boetemplate::empty_cell());
641 640
 				}
642 641
 				break;
643 642
 		}
@@ -652,16 +651,16 @@  discard block
 block discarded – undo
652 651
 	 */
653 652
 	function path_components($path)
654 653
 	{
655
-		$path_parts = explode('/',$path);
656
-		array_pop($path_parts);		// removed the widget itself
657
-		array_shift($path_parts);	// removed the leading empty string
654
+		$path_parts = explode('/', $path);
655
+		array_pop($path_parts); // removed the widget itself
656
+		array_shift($path_parts); // removed the leading empty string
658 657
 
659 658
 		$components = array();
660 659
 		$part_path = '';
661
-		foreach($path_parts as $part)
660
+		foreach ($path_parts as $part)
662 661
 		{
663 662
 			$part_path .= '/'.$part;
664
-			$parent =& $this->etemplate->get_widget_by_path($part_path);
663
+			$parent = & $this->etemplate->get_widget_by_path($part_path);
665 664
 			$components[$part_path] = $parent['type'];
666 665
 		}
667 666
 		return $components;
@@ -675,33 +674,33 @@  discard block
 block discarded – undo
675 674
 	 * @param string $parent_path path of the parent
676 675
 	 * @return array with keys left, right, up and down and their pathes set (if applicable)
677 676
 	 */
678
-	function parent_navigation($parent,$parent_path,$child_id,$widget)
677
+	function parent_navigation($parent, $parent_path, $child_id, $widget)
679 678
 	{
680
-		if ($parent['type'] == 'grid' && preg_match('/^([0-9]+)([A-Z]+)$/',$child_id,$matches))
679
+		if ($parent['type'] == 'grid' && preg_match('/^([0-9]+)([A-Z]+)$/', $child_id, $matches))
681 680
 		{
682
-			list(,$r,$c) = $matches;
681
+			list(,$r, $c) = $matches;
683 682
 			// find the column-number (base 0) for $c (A, B, C, ...)
684
-			for($col = 0; boetemplate::num2chrs($col) != $c && $col < 100; ++$col) ;
683
+			for ($col = 0; boetemplate::num2chrs($col) != $c && $col < 100; ++$col);
685 684
 
686
-			if ($col > 0) $left = $parent_path.'/'.$r.boetemplate::num2chrs($col-1);
685
+			if ($col > 0) $left = $parent_path.'/'.$r.boetemplate::num2chrs($col - 1);
687 686
 
688
-			if ($col < $parent['cols']-1) $right = $parent_path.'/'.$r.boetemplate::num2chrs($col+1);
687
+			if ($col < $parent['cols'] - 1) $right = $parent_path.'/'.$r.boetemplate::num2chrs($col + 1);
689 688
 
690
-			if ($r > 1) $up = $parent_path.'/'.($r-1).$c;
689
+			if ($r > 1) $up = $parent_path.'/'.($r - 1).$c;
691 690
 
692
-			if ($r < $parent['rows']) $down = $parent_path.'/'.($r+1).$c;
691
+			if ($r < $parent['rows']) $down = $parent_path.'/'.($r + 1).$c;
693 692
 		}
694 693
 		elseif ($parent['type']) // any box
695 694
 		{
696
-			if ($child_id > 1) $previous = $parent_path.'/'.($child_id-1);
695
+			if ($child_id > 1) $previous = $parent_path.'/'.($child_id - 1);
697 696
 
698
-			if ($child_id < (int) $parent['size'])  $next = $parent_path.'/'.($child_id+1);
697
+			if ($child_id < (int)$parent['size'])  $next = $parent_path.'/'.($child_id + 1);
699 698
 		}
700 699
 		else // template
701 700
 		{
702
-			if ($child_id > 0) $previous = '/'.($child_id-1);
701
+			if ($child_id > 0) $previous = '/'.($child_id - 1);
703 702
 
704
-			if ($child_id < count($this->etemplate->children)-1)  $next = '/'.($child_id+1);
703
+			if ($child_id < count($this->etemplate->children) - 1)  $next = '/'.($child_id + 1);
705 704
 		}
706 705
 		if ($widget['type'] == 'grid')
707 706
 		{
@@ -719,8 +718,8 @@  discard block
 block discarded – undo
719 718
 			}
720 719
 		}
721 720
 		$navi = array();
722
-		foreach(array('left'=>'&larr;','up'=>'&nbsp;&uarr;&nbsp;','down'=>'&nbsp;&darr;&nbsp;',
723
-			'right'=>'&rarr;','previous'=>'&larr;&uarr;','next'=>'&darr;&rarr;','in'=>'&times;') as $var => $dir)
721
+		foreach (array('left'=>'&larr;', 'up'=>'&nbsp;&uarr;&nbsp;', 'down'=>'&nbsp;&darr;&nbsp;',
722
+			'right'=>'&rarr;', 'previous'=>'&larr;&uarr;', 'next'=>'&darr;&rarr;', 'in'=>'&times;') as $var => $dir)
724 723
 		{
725 724
 			if ($$var) $navi[$$var] = $dir;
726 725
 		}
@@ -737,27 +736,27 @@  discard block
 block discarded – undo
737 736
 	 * @param string $child_id id of a cell
738 737
 	 * @return string msg to display
739 738
 	 */
740
-	function edit_actions(&$action,&$parent,&$content,$child_id)
739
+	function edit_actions(&$action, &$parent, &$content, $child_id)
741 740
 	{
742 741
 		switch ($action)
743 742
 		{
744 743
 			case 'paste':
745 744
 			case 'swap':
746
-				$clipboard = $GLOBALS['egw']->session->appsession('clipboard','etemplate');
745
+				$clipboard = $GLOBALS['egw']->session->appsession('clipboard', 'etemplate');
747 746
 				if (!is_array($clipboard))
748 747
 				{
749 748
 					return lang('nothing in clipboard to paste !!!');
750 749
 				}
751 750
 				if ($action == 'swap')
752 751
 				{
753
-					$GLOBALS['egw']->session->appsession('clipboard','etemplate',$content['cell']);
752
+					$GLOBALS['egw']->session->appsession('clipboard', 'etemplate', $content['cell']);
754 753
 				}
755 754
 				$content['cell'] = $clipboard;
756 755
 				break;
757 756
 
758 757
 			case 'copy':
759 758
 			case 'cut':
760
-				$GLOBALS['egw']->session->appsession('clipboard','etemplate',$content['cell']);
759
+				$GLOBALS['egw']->session->appsession('clipboard', 'etemplate', $content['cell']);
761 760
 				if ($action != 'cut')
762 761
 				{
763 762
 					return lang('widget copied into clipboard');
@@ -769,20 +768,20 @@  discard block
 block discarded – undo
769 768
 					// delete widget from parent
770 769
 					if ($parent['type'])	// box
771 770
 					{
772
-						list($num,$options) = explode(',',$parent['size'],2);
771
+						list($num, $options) = explode(',', $parent['size'], 2);
773 772
 						if ($num <= 1)	// cant delete last child --> only empty it
774 773
 						{
775
-							$parent[$num=1] = boetemplate::empty_cell();
774
+							$parent[$num = 1] = boetemplate::empty_cell();
776 775
 						}
777 776
 						else
778 777
 						{
779
-							for($n = $child_id; $n < $num; ++$n)
778
+							for ($n = $child_id; $n < $num; ++$n)
780 779
 							{
781
-								$parent[$n] = $parent[1+$n];
780
+								$parent[$n] = $parent[1 + $n];
782 781
 							}
783 782
 							unset($parent[$num--]);
784 783
 						}
785
-						$parent['size'] = $num . ($options ? ','.$options : '');
784
+						$parent['size'] = $num.($options ? ','.$options : '');
786 785
 					}
787 786
 					else	// template itself
788 787
 					{
@@ -819,7 +818,7 @@  discard block
 block discarded – undo
819 818
 	 * @param string $parent_path path of parent
820 819
 	 * @return string msg to display
821 820
 	 */
822
-	function box_actions(&$action,&$parent,&$content,&$child_id,$parent_path)
821
+	function box_actions(&$action, &$parent, &$content, &$child_id, $parent_path)
823 822
 	{
824 823
 		switch ($action)
825 824
 		{
@@ -828,38 +827,38 @@  discard block
 block discarded – undo
828 827
 				$n = $child_id + (int)($action == 'box_insert_behind');
829 828
 				if (!$parent['type'])	// template
830 829
 				{
831
-					$num = count($parent)-1;	// 0..count()-1
830
+					$num = count($parent) - 1; // 0..count()-1
832 831
 				}
833 832
 				else // boxes
834 833
 				{
835
-					list($num,$options) = explode(',',$parent['size'],2);
834
+					list($num, $options) = explode(',', $parent['size'], 2);
836 835
 				}
837
-				for($i = $num; $i >= $n; --$i)
836
+				for ($i = $num; $i >= $n; --$i)
838 837
 				{
839
-					$parent[1+$i] = $parent[$i];
838
+					$parent[1 + $i] = $parent[$i];
840 839
 				}
841 840
 				$parent[$n] = $content['cell'] = boetemplate::empty_cell();
842 841
 				$child_id = $n;
843
-				if ($parent['type']) $parent['size'] = (1+$num) . ($options ? ','.$options : '');
842
+				if ($parent['type']) $parent['size'] = (1 + $num).($options ? ','.$options : '');
844 843
 				break;
845 844
 
846 845
 			case 'box_swap_next':
847 846
 				if (!$parent['type'])	// template
848 847
 				{
849
-					$num = count($parent)-1;	// 0..count()-1
848
+					$num = count($parent) - 1; // 0..count()-1
850 849
 				}
851 850
 				else // boxes
852 851
 				{
853
-					list($num) = explode(',',$parent['size'],2);
852
+					list($num) = explode(',', $parent['size'], 2);
854 853
 				}
855 854
 				if ($child_id == $num)	// if on last cell, swap with the one before
856 855
 				{
857
-					$this->swap($parent[$child_id],$parent[$child_id-1]);
856
+					$this->swap($parent[$child_id], $parent[$child_id - 1]);
858 857
 					--$child_id;
859 858
 				}
860 859
 				else
861 860
 				{
862
-					$this->swap($parent[$child_id],$parent[$child_id+1]);
861
+					$this->swap($parent[$child_id], $parent[$child_id + 1]);
863 862
 					++$child_id;
864 863
 				}
865 864
 				break;
@@ -878,28 +877,28 @@  discard block
 block discarded – undo
878 877
 	 * @param string $child_id id of a cell
879 878
 	 * @return string msg to display
880 879
 	 */
881
-	function row_actions(&$action,&$grid,$child_id)
880
+	function row_actions(&$action, &$grid, $child_id)
882 881
 	{
883
-		$data =& $grid['data'];
884
-		$rows =& $grid['rows'];
885
-		$cols =& $grid['cols'];
886
-		$opts =& $data[0];
882
+		$data = & $grid['data'];
883
+		$rows = & $grid['rows'];
884
+		$cols = & $grid['cols'];
885
+		$opts = & $data[0];
887 886
 
888
-		if (preg_match('/^([0-9]+)([A-Z]+)$/',$child_id,$matches)) list(,$r,$c) = $matches;
887
+		if (preg_match('/^([0-9]+)([A-Z]+)$/', $child_id, $matches)) list(,$r, $c) = $matches;
889 888
 
890 889
 		if (!$c || !$r || $r > $rows) return "wrong child_id='$child_id' => r='$r', c='$c'";
891 890
 
892
-		switch($action)
891
+		switch ($action)
893 892
 		{
894 893
 			case 'row_swap_next':
895
-				if ($r > $rows-1)
894
+				if ($r > $rows - 1)
896 895
 				{
897 896
 					if ($r != $rows) return lang('no row to swap with !!!');
898
-					--$r;	// in last row swap with row above
897
+					--$r; // in last row swap with row above
899 898
 				}
900
-				$this->swap($data[$r],$data[1+$r]);
901
-				$this->swap($opts['c'.$r],$opts['c'.(1+$r)]);
902
-				$this->swap($opts['h'.$r],$opts['h'.(1+$r)]);
899
+				$this->swap($data[$r], $data[1 + $r]);
900
+				$this->swap($opts['c'.$r], $opts['c'.(1 + $r)]);
901
+				$this->swap($opts['h'.$r], $opts['h'.(1 + $r)]);
903 902
 				break;
904 903
 
905 904
 			case 'row_delete':
@@ -908,11 +907,11 @@  discard block
 block discarded – undo
908 907
 					return lang('cant delete the only row in a grid !!!');
909 908
 					// todo: delete whole grid instead
910 909
 				}
911
-				for($i = $r; $i < $rows; ++$i)
910
+				for ($i = $r; $i < $rows; ++$i)
912 911
 				{
913
-					$opts['c'.$i] = $opts['c'.(1+$i)];
914
-					$opts['h'.$i] = $opts['h'.(1+$i)];
915
-					$data[$i] = $data[1+$i];
912
+					$opts['c'.$i] = $opts['c'.(1 + $i)];
913
+					$opts['h'.$i] = $opts['h'.(1 + $i)];
914
+					$data[$i] = $data[1 + $i];
916 915
 				}
917 916
 				unset($opts['c'.$rows]);
918 917
 				unset($opts['h'.$rows]);
@@ -925,19 +924,19 @@  discard block
 block discarded – undo
925 924
 			case 'row_insert_below':
926 925
 				//echo "row_insert_below($r) rows=$rows, cols=$cols"; _debug_array($grid);
927 926
 				// move height + class options of rows
928
-				for($i = $rows; $i > $r; --$i)
927
+				for ($i = $rows; $i > $r; --$i)
929 928
 				{
930
-					echo ($i+1)."=$i<br>\n";
931
-					$data[1+$i] = $data[$i];
932
-					$opts['c'.(1+$i)] = $opts['c'.$i];
933
-					$opts['h'.(1+$i)] = $opts['h'.$i];
929
+					echo ($i + 1)."=$i<br>\n";
930
+					$data[1 + $i] = $data[$i];
931
+					$opts['c'.(1 + $i)] = $opts['c'.$i];
932
+					$opts['h'.(1 + $i)] = $opts['h'.$i];
934 933
 				}
935
-				for($i = 0; $i < $cols; ++$i)
934
+				for ($i = 0; $i < $cols; ++$i)
936 935
 				{
937
-					echo (1+$r).":$i=".boetemplate::num2chrs($i)."=empty_cell()<br>\n";
938
-					$data[1+$r][boetemplate::num2chrs($i)] = boetemplate::empty_cell();
936
+					echo (1 + $r).":$i=".boetemplate::num2chrs($i)."=empty_cell()<br>\n";
937
+					$data[1 + $r][boetemplate::num2chrs($i)] = boetemplate::empty_cell();
939 938
 				}
940
-				$opts['c'.(1+$r)] = $opts['h'.(1+$r)] = '';
939
+				$opts['c'.(1 + $r)] = $opts['h'.(1 + $r)] = '';
941 940
 				++$rows;
942 941
 				//_debug_array($grid); return '';
943 942
 				break;
@@ -956,33 +955,33 @@  discard block
 block discarded – undo
956 955
 	 * @param string $child_id id of a cell
957 956
 	 * @return string msg to display
958 957
 	 */
959
-	function column_actions(&$action,&$grid,$child_id)
958
+	function column_actions(&$action, &$grid, $child_id)
960 959
 	{
961
-		$data =& $grid['data'];
962
-		$rows =& $grid['rows'];
963
-		$cols =& $grid['cols'];
964
-		$opts =& $data[0];
960
+		$data = & $grid['data'];
961
+		$rows = & $grid['rows'];
962
+		$cols = & $grid['cols'];
963
+		$opts = & $data[0];
965 964
 
966
-		if (preg_match('/^([0-9]+)([A-Z]+)$/',$child_id,$matches)) list(,$r,$c) = $matches;
965
+		if (preg_match('/^([0-9]+)([A-Z]+)$/', $child_id, $matches)) list(,$r, $c) = $matches;
967 966
 		// find the column-number (base 0) for $c (A, B, C, ...)
968
-		for($col = 0; boetemplate::num2chrs($col) != $c && $col < 100; ++$col) ;
967
+		for ($col = 0; boetemplate::num2chrs($col) != $c && $col < 100; ++$col);
969 968
 
970 969
 		if (!$c || !$r || $r > $rows || $col >= $cols) return "wrong child_id='$child_id' => r='$r', c='$c', col=$col";
971 970
 
972
-		switch($action)
971
+		switch ($action)
973 972
 		{
974 973
 			case 'column_swap_next':
975
-				if ($col >= $cols-1)
974
+				if ($col >= $cols - 1)
976 975
 				{
977
-					if ($col != $cols-1) return lang('no column to swap with !!!');
976
+					if ($col != $cols - 1) return lang('no column to swap with !!!');
978 977
 					$c = boetemplate::num2chrs(--$col); // in last column swap with the one before
979 978
 				}
980
-				$c_next = boetemplate::num2chrs(1+$col);
981
-				for($row = 1; $row <= $rows; ++$row)
979
+				$c_next = boetemplate::num2chrs(1 + $col);
980
+				for ($row = 1; $row <= $rows; ++$row)
982 981
 				{
983
-					$this->swap($data[$row][$c],$data[$row][$c_next]);
982
+					$this->swap($data[$row][$c], $data[$row][$c_next]);
984 983
 				}
985
-				$this->swap($opts[$c],$opts[$c_next]);
984
+				$this->swap($opts[$c], $opts[$c_next]);
986 985
 				//_debug_array($grid); return '';
987 986
 				break;
988 987
 
@@ -995,13 +994,13 @@  discard block
 block discarded – undo
995 994
 				{
996 995
 					for ($i = $cols; $i > $col; --$i)
997 996
 					{
998
-						$data[$row][boetemplate::num2chrs($i)] = $data[$row][boetemplate::num2chrs($i-1)];
997
+						$data[$row][boetemplate::num2chrs($i)] = $data[$row][boetemplate::num2chrs($i - 1)];
999 998
 					}
1000 999
 					$data[$row][boetemplate::num2chrs($col)] = boetemplate::empty_cell();
1001 1000
 				}
1002 1001
 				for ($i = $cols; $i > $col; --$i)
1003 1002
 				{
1004
-					$opts[boetemplate::num2chrs($i)] = $opts[boetemplate::num2chrs($i-1)];
1003
+					$opts[boetemplate::num2chrs($i)] = $opts[boetemplate::num2chrs($i - 1)];
1005 1004
 				}
1006 1005
 				unset($opts[boetemplate::num2chrs($col)]);
1007 1006
 				++$cols;
@@ -1016,15 +1015,15 @@  discard block
 block discarded – undo
1016 1015
 				}
1017 1016
 				for ($row = 1; $row <= $rows; ++$row)
1018 1017
 				{
1019
-					for ($i = $col; $i < $cols-1; ++$i)
1018
+					for ($i = $col; $i < $cols - 1; ++$i)
1020 1019
 					{
1021
-						$data[$row][boetemplate::num2chrs($i)] = $data[$row][boetemplate::num2chrs($i+1)];
1020
+						$data[$row][boetemplate::num2chrs($i)] = $data[$row][boetemplate::num2chrs($i + 1)];
1022 1021
 					}
1023
-					unset($data[$row][boetemplate::num2chrs($cols-1)]);
1022
+					unset($data[$row][boetemplate::num2chrs($cols - 1)]);
1024 1023
 				}
1025
-				for ($i = $col; $i < $cols-1; ++$i)
1024
+				for ($i = $col; $i < $cols - 1; ++$i)
1026 1025
 				{
1027
-					$opts[boetemplate::num2chrs($i)] = $opts[boetemplate::num2chrs($i+1)];
1026
+					$opts[boetemplate::num2chrs($i)] = $opts[boetemplate::num2chrs($i + 1)];
1028 1027
 				}
1029 1028
 				unset($opts[boetemplate::num2chrs(--$cols)]);
1030 1029
 				break;
@@ -1041,29 +1040,29 @@  discard block
 block discarded – undo
1041 1040
 	 * @param array &$cell_content cell array in content
1042 1041
 	 * @param boolean $widget2content=true copy from widget to content or other direction
1043 1042
 	 */
1044
-	function fix_set_onclick(&$widget,&$cell_content,$widget2content=true)
1043
+	function fix_set_onclick(&$widget, &$cell_content, $widget2content = true)
1045 1044
 	{
1046 1045
 		if ($widget2content)
1047 1046
 		{
1048
-			if (preg_match('/^return confirm\(["\']{1}?(.*)["\']{1}\);?$/',$widget['onclick'],$matches))
1047
+			if (preg_match('/^return confirm\(["\']{1}?(.*)["\']{1}\);?$/', $widget['onclick'], $matches))
1049 1048
 			{
1050 1049
 				$cell_content['onclick'] = $matches[1];
1051 1050
 				$cell_content['onclick_type'] = 'confirm';
1052 1051
 			}
1053
-			elseif (preg_match('/^window.open\(egw::link\(\'\/index.php\',\'([^\']+)\'\)(\+values2url\(.*\))?,\'([^\']+)\',\'dependent=yes,width=([0-9]+),height=([0-9]+),scrollbars=yes,status=yes\'\); return false;$/',$widget['onclick'],$matches))
1052
+			elseif (preg_match('/^window.open\(egw::link\(\'\/index.php\',\'([^\']+)\'\)(\+values2url\(.*\))?,\'([^\']+)\',\'dependent=yes,width=([0-9]+),height=([0-9]+),scrollbars=yes,status=yes\'\); return false;$/', $widget['onclick'], $matches))
1054 1053
 			{
1055
-				$cell_content['onclick'] = $matches[1].($matches[2] ? str_replace('+values2url(this.form,','&values2url(',$matches[2]) : '');
1054
+				$cell_content['onclick'] = $matches[1].($matches[2] ? str_replace('+values2url(this.form,', '&values2url(', $matches[2]) : '');
1056 1055
 				if ($matches[3] != '_blank')
1057 1056
 				{
1058 1057
 					$cell_content['onclick'] .= ','.$matches[3];
1059 1058
 				}
1060 1059
 				if ($matches[4] != '600')
1061 1060
 				{
1062
-					$cell_content['onclick'] .= ($matches[3]=='_blank' ? ',':'').','.$matches[4];
1061
+					$cell_content['onclick'] .= ($matches[3] == '_blank' ? ',' : '').','.$matches[4];
1063 1062
 				}
1064 1063
 				if ($matches[5] != '450')
1065 1064
 				{
1066
-					$cell_content['onclick'] .= ($matches[4]=='600' ? ','.($matches[3]=='_blank' ? ',':'') : '').
1065
+					$cell_content['onclick'] .= ($matches[4] == '600' ? ','.($matches[3] == '_blank' ? ',' : '') : '').
1067 1066
 						','.$matches[5];
1068 1067
 				}
1069 1068
 				$cell_content['onclick_type'] = 'popup';
@@ -1075,7 +1074,7 @@  discard block
 block discarded – undo
1075 1074
 		}
1076 1075
 		else	// content --> widget
1077 1076
 		{
1078
-			if (preg_match('/^return confirm\(["\']{1}?(.*)["\']{1}\);?$/',$cell_content['onclick'],$matches) ||
1077
+			if (preg_match('/^return confirm\(["\']{1}?(.*)["\']{1}\);?$/', $cell_content['onclick'], $matches) ||
1079 1078
 				$cell_content['onclick_type'] == 'confirm' && $cell_content['onclick'])
1080 1079
 			{
1081 1080
 				$cell_content['onclick_type'] = 'confirm';
@@ -1085,12 +1084,12 @@  discard block
 block discarded – undo
1085 1084
 			elseif ($cell_content['onclick_type'] == 'popup' && $cell_content['onclick'])
1086 1085
 			{
1087 1086
 				// eg: menuaction=calendar.uiforms.freetimesearch&values2url('start,end,participants'),ft_search,700,500
1088
-				if  (($values2url = preg_match('/&values2url\((\'[^\']+\')\)/',$cell_content['onclick'],$matches)))
1087
+				if (($values2url = preg_match('/&values2url\((\'[^\']+\')\)/', $cell_content['onclick'], $matches)))
1089 1088
 				{
1090 1089
 					$values2url = $matches[1];
1091
-					$onclick = str_replace('&values2url('.$values2url.')','',$cell_content['onclick']);
1090
+					$onclick = str_replace('&values2url('.$values2url.')', '', $cell_content['onclick']);
1092 1091
 				}
1093
-				list($get,$target,$width,$height) = explode(',',$values2url ? $onclick : $cell_content['onclick']);
1092
+				list($get, $target, $width, $height) = explode(',', $values2url ? $onclick : $cell_content['onclick']);
1094 1093
 				if (!$target) $target = '_blank';
1095 1094
 				if (!$width)  $width  = 600;
1096 1095
 				if (!$height) $height = 450;
@@ -1118,7 +1117,7 @@  discard block
 block discarded – undo
1118 1117
 	 * @param array &$cell_content cell array in content
1119 1118
 	 * @param boolean $widget2content=true copy from widget to content or other direction
1120 1119
 	 */
1121
-	function fix_set_onchange(&$widget,&$cell_content,$widget2content=true)
1120
+	function fix_set_onchange(&$widget, &$cell_content, $widget2content = true)
1122 1121
 	{
1123 1122
 		if ($widget2content)
1124 1123
 		{
@@ -1142,7 +1141,7 @@  discard block
 block discarded – undo
1142 1141
 			{
1143 1142
 				$widget['onchange'] = 1;
1144 1143
 			}
1145
-			elseif(!$cell_content['onchange'])
1144
+			elseif (!$cell_content['onchange'])
1146 1145
 			{
1147 1146
 				$widget['onchange'] = 0;
1148 1147
 			}
@@ -1157,12 +1156,12 @@  discard block
 block discarded – undo
1157 1156
 	 * @param array $content the submitted content of the etemplate::exec function, default null
1158 1157
 	 * @param string $msg msg to display, default ''
1159 1158
 	 */
1160
-	function widget($content=null,$msg='')
1159
+	function widget($content = null, $msg = '')
1161 1160
 	{
1162 1161
 		if (is_array($content))
1163 1162
 		{
1164 1163
 			$path = $content['goto'] ? $content['goto'] : ($content['goto2'] ? $content['goto2'] : $content['path']);
1165
-			$Ok = $this->etemplate->read($content['name'],$content['template'],$content['lang'],0,$content['goto'] || $content['goto2'] ? $content['version'] : $content['old_version']);
1164
+			$Ok = $this->etemplate->read($content['name'], $content['template'], $content['lang'], 0, $content['goto'] || $content['goto2'] ? $content['version'] : $content['old_version']);
1166 1165
 
1167 1166
 			// build size from options array, if applicable
1168 1167
 			if (is_array($content['cell']['options']))
@@ -1181,7 +1180,7 @@  discard block
 block discarded – undo
1181 1180
 		else
1182 1181
 		{
1183 1182
 			//echo "<p><b>".($_GET['path']).":</b></p>\n";
1184
-			list($name,$version,$path) = explode(':',$_GET['path'],3);	// <name>:<version>:<path>
1183
+			list($name, $version, $path) = explode(':', $_GET['path'], 3); // <name>:<version>:<path>
1185 1184
 			$Ok = $this->etemplate->read(array(
1186 1185
 				'name'    => $name,
1187 1186
 				'version' => $version,
@@ -1191,15 +1190,15 @@  discard block
 block discarded – undo
1191 1190
 		{
1192 1191
 			$msg .= lang('Error: Template not found !!!');
1193 1192
 		}
1194
-		$path_parts = explode('/',$path);
1193
+		$path_parts = explode('/', $path);
1195 1194
 		$child_id = array_pop($path_parts);
1196
-		$parent_path = implode('/',$path_parts);
1195
+		$parent_path = implode('/', $path_parts);
1197 1196
 		//echo "<p>path='$path': child_id='$child_id', parent_path='$parent_path'</p>\n";
1198
-		$parent =& $this->etemplate->get_widget_by_path($parent_path);
1197
+		$parent = & $this->etemplate->get_widget_by_path($parent_path);
1199 1198
 
1200 1199
 		if (is_array($content))
1201 1200
 		{
1202
-			foreach(array('save','apply','cancel','goto','goto2','edit_menu','box_menu','row_menu','column_menu') as $n => $name)
1201
+			foreach (array('save', 'apply', 'cancel', 'goto', 'goto2', 'edit_menu', 'box_menu', 'row_menu', 'column_menu') as $n => $name)
1203 1202
 			{
1204 1203
 				if (($action = $content[$name] ? ($n < 5 ? $name : $content[$name]) : false)) break;
1205 1204
 				$name = '';
@@ -1210,25 +1209,25 @@  discard block
 block discarded – undo
1210 1209
 			if (($name == 'row_menu' || $name == 'column_menu') && $parent['type'] != 'grid' ||
1211 1210
 				$name == 'box_menu' && $parent['type'] == 'grid')
1212 1211
 			{
1213
-				$msg .= lang("parent is a '%1' !!!",lang($parent['type'] ? $parent['type'] : 'template'));
1212
+				$msg .= lang("parent is a '%1' !!!", lang($parent['type'] ? $parent['type'] : 'template'));
1214 1213
 				$action = false;
1215 1214
 			}
1216
-			switch($name)
1215
+			switch ($name)
1217 1216
 			{
1218 1217
 				case 'edit_menu':
1219
-					$msg .= $this->edit_actions($action,$parent,$content,$child_id);
1218
+					$msg .= $this->edit_actions($action, $parent, $content, $child_id);
1220 1219
 					break;
1221 1220
 
1222 1221
 				case 'box_menu':
1223
-					$msg .= $this->box_actions($action,$parent,$content,$child_id,$parent_path);
1222
+					$msg .= $this->box_actions($action, $parent, $content, $child_id, $parent_path);
1224 1223
 					break;
1225 1224
 
1226 1225
 				case 'row_menu':
1227
-					$msg .= $this->row_actions($action,$parent,$child_id);
1226
+					$msg .= $this->row_actions($action, $parent, $child_id);
1228 1227
 					break;
1229 1228
 
1230 1229
 				case 'column_menu':
1231
-					$msg .= $this->column_actions($action,$parent,$child_id);
1230
+					$msg .= $this->column_actions($action, $parent, $child_id);
1232 1231
 					break;
1233 1232
 
1234 1233
 				case '':	// reload, eg. by changing the type
@@ -1238,7 +1237,7 @@  discard block
 block discarded – undo
1238 1237
 				default:
1239 1238
 					// all menu's are (only) working on the parent, referencing widget is unnecessary
1240 1239
 					// and gives unexpected results, if parent is changed (eg. content gets copied)
1241
-					$widget =& $this->etemplate->get_widget_by_path($path);
1240
+					$widget = & $this->etemplate->get_widget_by_path($path);
1242 1241
 					break;
1243 1242
 			}
1244 1243
 			switch ($action)
@@ -1246,8 +1245,8 @@  discard block
 block discarded – undo
1246 1245
 				case 'goto':
1247 1246
 				case 'goto2':
1248 1247
 					$content['cell'] = $widget;
1249
-					$this->fix_set_onclick($widget,$content['cell'],true);
1250
-					$this->fix_set_onchange($widget,$content['cell'],true);
1248
+					$this->fix_set_onclick($widget, $content['cell'], true);
1249
+					$this->fix_set_onchange($widget, $content['cell'], true);
1251 1250
 					break;
1252 1251
 
1253 1252
 				case '':
@@ -1256,30 +1255,30 @@  discard block
 block discarded – undo
1256 1255
 					//echo "<p>$content[path]: $widget[type] --> ".$content['cell']['type']."</p>\n";
1257 1256
 					if (isset(boetemplate::$widgets_with_children[$content['cell']['type']]))
1258 1257
 					{
1259
-						$this->change_widget_type($content['cell'],$widget);
1258
+						$this->change_widget_type($content['cell'], $widget);
1260 1259
 					}
1261 1260
 					if (!$action) break;
1262 1261
 					// save+apply only
1263 1262
 					$widget = $content['cell'];
1264 1263
 					if ($content['cell']['onclick_type'] || $content['cell']['onclick'])
1265 1264
 					{
1266
-						$this->fix_set_onclick($widget,$content['cell'],false);
1265
+						$this->fix_set_onclick($widget, $content['cell'], false);
1267 1266
 					}
1268 1267
 					if ($content['cell']['onchange_type'] || $content['cell']['onchange'])
1269 1268
 					{
1270
-						$this->fix_set_onchange($widget,$content['cell'],false);
1269
+						$this->fix_set_onchange($widget, $content['cell'], false);
1271 1270
 					}
1272 1271
 					// row- and column-attr for a grid
1273
-					if ($parent['type'] == 'grid' && preg_match('/^([0-9]+)([A-Z]+)$/',$child_id,$matches))
1272
+					if ($parent['type'] == 'grid' && preg_match('/^([0-9]+)([A-Z]+)$/', $child_id, $matches))
1274 1273
 					{
1275
-						list(,$row,$col) = $matches;
1274
+						list(,$row, $col) = $matches;
1276 1275
 						$parent['data'][0]['h'.$row] = $content['grid_row']['height'].
1277
-							($content['grid_row']['disabled']||$content['grid_row']['part']?','.$content['grid_row']['disabled']:'').
1278
-							($content['grid_row']['part']?','.$content['grid_row']['part']:'');
1276
+							($content['grid_row']['disabled'] || $content['grid_row']['part'] ? ','.$content['grid_row']['disabled'] : '').
1277
+							($content['grid_row']['part'] ? ','.$content['grid_row']['part'] : '');
1279 1278
 						$parent['data'][0]['c'.$row] = $content['grid_row']['class'].
1280
-							($content['grid_row']['valign']?','.$content['grid_row']['valign']:'');
1279
+							($content['grid_row']['valign'] ? ','.$content['grid_row']['valign'] : '');
1281 1280
 						$parent['data'][0][$col] = $content['grid_column']['width'].
1282
-							($content['grid_column']['disabled']?','.$content['grid_column']['disabled']:'');
1281
+							($content['grid_column']['disabled'] ? ','.$content['grid_column']['disabled'] : '');
1283 1282
 					}
1284 1283
 					// fall-through
1285 1284
 				case 'save-no-merge':
@@ -1296,9 +1295,9 @@  discard block
 block discarded – undo
1296 1295
 					{
1297 1296
 						$content['opener']['version'] = $content['version'];
1298 1297
 					}
1299
-					$js = "opener.location.href='".$GLOBALS['egw']->link('/index.php',array(
1298
+					$js = "opener.location.href='".$GLOBALS['egw']->link('/index.php', array(
1300 1299
 							'menuaction' => 'etemplate.editor.edit',
1301
-						)+$content['opener'])."';";
1300
+						) + $content['opener'])."';";
1302 1301
 					if ($action == 'apply' || $action == 'apply-no-merge') break;
1303 1302
 					// fall through
1304 1303
 				case 'cancel':
@@ -1314,14 +1313,14 @@  discard block
 block discarded – undo
1314 1313
 		}
1315 1314
 		else
1316 1315
 		{
1317
-			$widget =& $this->etemplate->get_widget_by_path($path);
1316
+			$widget = & $this->etemplate->get_widget_by_path($path);
1318 1317
 
1319 1318
 			$content = $this->etemplate->as_array(-1);
1320 1319
 			$content['cell'] = $widget;
1321
-			$this->fix_set_onclick($widget,$content['cell'],true);
1322
-			$this->fix_set_onchange($widget,$content['cell'],true);
1320
+			$this->fix_set_onclick($widget, $content['cell'], true);
1321
+			$this->fix_set_onchange($widget, $content['cell'], true);
1323 1322
 
1324
-			foreach(boetemplate::$db_key_cols as $var)
1323
+			foreach (boetemplate::$db_key_cols as $var)
1325 1324
 			{
1326 1325
 				if (isset($_GET[$var]))
1327 1326
 				{
@@ -1329,23 +1328,23 @@  discard block
 block discarded – undo
1329 1328
 				}
1330 1329
 			}
1331 1330
 		}
1332
-		unset($content['cell']['obj']);	// just in case it contains a template-object
1331
+		unset($content['cell']['obj']); // just in case it contains a template-object
1333 1332
 
1334
-		if ($parent['type'] == 'grid' && preg_match('/^([0-9]+)([A-Z]+)$/',$child_id,$matches))
1333
+		if ($parent['type'] == 'grid' && preg_match('/^([0-9]+)([A-Z]+)$/', $child_id, $matches))
1335 1334
 		{
1336
-			list(,$row,$col) = $matches;
1335
+			list(,$row, $col) = $matches;
1337 1336
 
1338
-			$grid_row =& $content['grid_row'];
1339
-			list($grid_row['height'],$grid_row['disabled'],$grid_row['part']) = explode(',',$parent['data'][0]['h'.$row]);
1340
-			list($grid_row['class'],$grid_row['valign']) = explode(',',$parent['data'][0]['c'.$row]);
1337
+			$grid_row = & $content['grid_row'];
1338
+			list($grid_row['height'], $grid_row['disabled'], $grid_row['part']) = explode(',', $parent['data'][0]['h'.$row]);
1339
+			list($grid_row['class'], $grid_row['valign']) = explode(',', $parent['data'][0]['c'.$row]);
1341 1340
 
1342
-			$grid_column =& $content['grid_column'];
1343
-			list($grid_column['width'],$grid_column['disabled']) = explode(',',$parent['data'][0][$col]);
1341
+			$grid_column = & $content['grid_column'];
1342
+			list($grid_column['width'], $grid_column['disabled']) = explode(',', $parent['data'][0][$col]);
1344 1343
 			//echo "<p>grid_row($row)=".print_r($grid_row,true).", grid_column($col)=".print_r($grid_column,true)."</p>\n";
1345 1344
 
1346
-			list(,,$previous_part) = explode(',',$parent['data'][0]['h'.($row-1)]);
1347
-			list(,,$next_part) = explode(',',$parent['data'][0]['h'.($row+1)]);
1348
-			$allowed_parts = $this->get_allowed_parts($row,$previous_part,$next_part);
1345
+			list(,, $previous_part) = explode(',', $parent['data'][0]['h'.($row - 1)]);
1346
+			list(,, $next_part) = explode(',', $parent['data'][0]['h'.($row + 1)]);
1347
+			$allowed_parts = $this->get_allowed_parts($row, $previous_part, $next_part);
1349 1348
 			//echo "<p>$row: previous=$previous_part, current={$grid_row['part']}, next=$next_part".(!isset($allowed_parts[$grid_row['part']])?': current part is NOT allowed!!!':'')."</p>\n"; _debug_array($allowed_parts);
1350 1349
 		}
1351 1350
 		else
@@ -1353,23 +1352,23 @@  discard block
 block discarded – undo
1353 1352
 			unset($content['grid_row']);
1354 1353
 			unset($content['grid_column']);
1355 1354
 		}
1356
-		$content['path'] = ($parent_path!='/'?$parent_path:'').'/'.$child_id;
1355
+		$content['path'] = ($parent_path != '/' ? $parent_path : '').'/'.$child_id;
1357 1356
 		$content['msg'] = $msg;
1358 1357
 		$content['goto'] = $this->path_components($content['path']);
1359
-		$content['goto2'] = $this->parent_navigation($parent,$parent_path,$child_id,$widget);
1358
+		$content['goto2'] = $this->parent_navigation($parent, $parent_path, $child_id, $widget);
1360 1359
 
1361
-		$content['cell']['options'] = explode(',',$content['cell']['size']);
1360
+		$content['cell']['options'] = explode(',', $content['cell']['size']);
1362 1361
 
1363 1362
 		$editor = new etemplate('etemplate.editor.widget');
1364 1363
 		$type_tmpl = new etemplate;
1365 1364
 
1366
-		list($ext_type) = explode('-',$widget['type']);
1365
+		list($ext_type) = explode('-', $widget['type']);
1367 1366
 		// allow to read template of app-specific widgets from their app: eg. "infolog-value" --> "infolog.widget.infolog-value"
1368 1367
 		if (isset($GLOBALS['egw_info']['apps'][$ext_type]) && $type_tmpl->read($ext_type.'.widget.'.$widget['type']) ||
1369 1368
 			$type_tmpl->read('etemplate.editor.widget.'.$widget['type']) ||
1370 1369
 			$type_tmpl->read('etemplate.editor.widget.'.$ext_type))
1371 1370
 		{
1372
-			$editor->set_cell_attribute('etemplate.editor.widget.generic','obj',$type_tmpl);
1371
+			$editor->set_cell_attribute('etemplate.editor.widget.generic', 'obj', $type_tmpl);
1373 1372
 		}
1374 1373
 		/*
1375 1374
 		Not a known type, use a generic attribute thing to at least allow working
@@ -1377,27 +1376,27 @@  discard block
 block discarded – undo
1377 1376
 		*/
1378 1377
 		if ($widget['type'] && !boetemplate::$types[$widget['type']] && !$this->extensions[$widget['type']])
1379 1378
 		{
1380
-			$grid =& $editor->get_widget_by_name('etemplate.editor.widget.generic');
1379
+			$grid = & $editor->get_widget_by_name('etemplate.editor.widget.generic');
1381 1380
 			$grid['type'] = 'grid';
1382 1381
 			$grid['name'] = 'cell';
1383 1382
 			$grid['data'] = array(array());
1384
-			$grid['data'][] = array('A'=>boetemplate::empty_cell('label','',array('label' => 'Type')), 'B' => boetemplate::empty_cell('select','type'));
1385
-			$attributes = array('type'=>$widget_type,'name'=>'');
1386
-			if(is_array($widget))
1383
+			$grid['data'][] = array('A'=>boetemplate::empty_cell('label', '', array('label' => 'Type')), 'B' => boetemplate::empty_cell('select', 'type'));
1384
+			$attributes = array('type'=>$widget_type, 'name'=>'');
1385
+			if (is_array($widget))
1387 1386
 			{
1388 1387
 				$attributes += $widget;
1389 1388
 			}
1390
-			foreach($attributes as $attr_name => $attr_value)
1389
+			foreach ($attributes as $attr_name => $attr_value)
1391 1390
 			{
1392
-				if(is_array($attr_value) || in_array($attr_value, array('type','options')))
1391
+				if (is_array($attr_value) || in_array($attr_value, array('type', 'options')))
1393 1392
 				{
1394 1393
 					continue;
1395 1394
 				}
1396 1395
 				else
1397 1396
 				{
1398
-					$attr = boetemplate::empty_cell('text',$attr_name,array());
1397
+					$attr = boetemplate::empty_cell('text', $attr_name, array());
1399 1398
 				}
1400
-				$grid['data'][] = array('A' => boetemplate::empty_cell('label','',array('label' => $attr_name)),'B'=>$attr);
1399
+				$grid['data'][] = array('A' => boetemplate::empty_cell('label', '', array('label' => $attr_name)), 'B'=>$attr);
1401 1400
 				//boetemplate::add_child($grid,$attr);
1402 1401
 				unset($attr);
1403 1402
 			}
@@ -1411,7 +1410,7 @@  discard block
 block discarded – undo
1411 1410
 			$editor->disable_cells('row_menu');
1412 1411
 			$editor->disable_cells('column_menu');
1413 1412
 		}
1414
-		$preserv = $this->etemplate->as_array()+array(
1413
+		$preserv = $this->etemplate->as_array() + array(
1415 1414
 			'path'        => $content['path'],
1416 1415
 			'type'        => $content['type'],
1417 1416
 			'old_version' => $this->etemplate->version,
@@ -1419,13 +1418,13 @@  discard block
 block discarded – undo
1419 1418
 			'cell'        => $content['cell'],
1420 1419
 			'goto'        => $content['goto'],
1421 1420
 		);
1422
-		unset($preserv['cell']['options']);	// otherwise we never know if content is returned via options array or size
1421
+		unset($preserv['cell']['options']); // otherwise we never know if content is returned via options array or size
1423 1422
 
1424 1423
 		$GLOBALS['egw_info']['flags']['java_script'] = "<script>window.focus();</script>\n";
1425 1424
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Editable Templates - Editor');
1426
-		$editor->exec('etemplate.editor.widget',$content,array(
1427
-				'type'       => array_merge(array($widget['type'] => $widget['type'] . ' (?)'),
1428
-					boetemplate::$types,$this->extensions
1425
+		$editor->exec('etemplate.editor.widget', $content, array(
1426
+				'type'       => array_merge(array($widget['type'] => $widget['type'].' (?)'),
1427
+					boetemplate::$types, $this->extensions
1429 1428
 				),
1430 1429
 				'align'      => &$this->aligns,
1431 1430
 				'valign'     => &$this->valigns,
@@ -1437,7 +1436,7 @@  discard block
 block discarded – undo
1437 1436
 				'onclick_type'=>&$this->onclick_types,
1438 1437
 				'onchange_type'=>&$this->onchange_types,
1439 1438
 				'options[6]' => &$this->overflows,
1440
-			),'',$preserv,2);
1439
+			), '', $preserv, 2);
1441 1440
 	}
1442 1441
 
1443 1442
 	/**
@@ -1448,10 +1447,10 @@  discard block
 block discarded – undo
1448 1447
 	 * @param string $next_part see above
1449 1448
 	 * @return array
1450 1449
 	 */
1451
-	private function get_allowed_parts($row,$previous_part,$next_part)
1450
+	private function get_allowed_parts($row, $previous_part, $next_part)
1452 1451
 	{
1453 1452
 		$allowed_parts = $this->parts;
1454
-		switch((string)$previous_part)
1453
+		switch ((string)$previous_part)
1455 1454
 		{
1456 1455
 			case 'footer':
1457 1456
 				unset($allowed_parts['header']);
@@ -1460,7 +1459,7 @@  discard block
 block discarded – undo
1460 1459
 				if ($row > 1) $allowed_parts = array('' => $allowed_parts['']);
1461 1460
 				break;
1462 1461
 		}
1463
-		switch($next_part)
1462
+		switch ($next_part)
1464 1463
 		{
1465 1464
 			case 'header':
1466 1465
 				$allowed_parts = array('header' => $allowed_parts['header']);
@@ -1478,20 +1477,20 @@  discard block
 block discarded – undo
1478 1477
 	 * @param array $content the submitted content of the etemplate::exec function, default null
1479 1478
 	 * @param string $msg msg to display, default ''
1480 1479
 	 */
1481
-	function styles($content=null,$msg='')
1480
+	function styles($content = null, $msg = '')
1482 1481
 	{
1483 1482
 		if (!is_array($content))
1484 1483
 		{
1485
-			foreach(boetemplate::$db_key_cols as $var)
1484
+			foreach (boetemplate::$db_key_cols as $var)
1486 1485
 			{
1487 1486
 				if (isset($_GET[$var])) $content[$var] = $_GET[$var];
1488 1487
 			}
1489 1488
 		}
1490 1489
 		//_debug_array($content);
1491 1490
 		// security check for content[from]
1492
-		if ($content['from'] && !preg_match('/^[A-Za-z0-9_-]+\/templates\/[A-Za-z0-9_-]+\/app.css$/',$content['from']))
1491
+		if ($content['from'] && !preg_match('/^[A-Za-z0-9_-]+\/templates\/[A-Za-z0-9_-]+\/app.css$/', $content['from']))
1493 1492
 		{
1494
-			$content['from'] = '';	// someone tried to trick us reading a file we are not suppost to read
1493
+			$content['from'] = ''; // someone tried to trick us reading a file we are not suppost to read
1495 1494
 		}
1496 1495
 		if (!$this->etemplate->read($content))
1497 1496
 		{
@@ -1504,22 +1503,22 @@  discard block
 block discarded – undo
1504 1503
 				$path = EGW_SERVER_ROOT.'/'.$content['from'];
1505 1504
 				if (is_writable(dirname($path)) && file_exists($path))
1506 1505
 				{
1507
-					rename($path,str_replace('.css','.old.css',$path));
1506
+					rename($path, str_replace('.css', '.old.css', $path));
1508 1507
 				}
1509 1508
 				if (file_exists($path) && !is_writable(dirname($path)))
1510 1509
 				{
1511
-					$msg .= lang("Error: webserver is not allowed to write into '%1' !!!",dirname($path));
1510
+					$msg .= lang("Error: webserver is not allowed to write into '%1' !!!", dirname($path));
1512 1511
 				}
1513 1512
 				else
1514 1513
 				{
1515
-					$fp = fopen($path,'w');
1516
-					if (!$fp || !fwrite($fp,$content['styles']))
1514
+					$fp = fopen($path, 'w');
1515
+					if (!$fp || !fwrite($fp, $content['styles']))
1517 1516
 					{
1518 1517
 						$msg .= lang('Error: while saving !!!');
1519 1518
 					}
1520 1519
 					else
1521 1520
 					{
1522
-						$msg .= lang("File writen",$path);
1521
+						$msg .= lang("File writen", $path);
1523 1522
 					}
1524 1523
 					@fclose($fp);
1525 1524
 				}
@@ -1530,9 +1529,9 @@  discard block
 block discarded – undo
1530 1529
 				$ok = $this->etemplate->save();
1531 1530
 				$msg = $ok ? lang('Template saved') : lang('Error: while saving !!!');
1532 1531
 			}
1533
-			$js = "opener.location.href='".$GLOBALS['egw']->link('/index.php',array(
1532
+			$js = "opener.location.href='".$GLOBALS['egw']->link('/index.php', array(
1534 1533
 					'menuaction' => 'etemplate.editor.edit',
1535
-				)+$this->etemplate->as_array(-1))."';";
1534
+				) + $this->etemplate->as_array(-1))."';";
1536 1535
 		}
1537 1536
 		if ($content['save'] || $content['cancel'])
1538 1537
 		{
@@ -1550,10 +1549,10 @@  discard block
 block discarded – undo
1550 1549
 		if ($content['from'])
1551 1550
 		{
1552 1551
 			$path = EGW_SERVER_ROOT.'/'.$content['from'];
1553
-			$content['styles'] = file_exists($path) && is_readable($path) ? implode('',file($path)) : '';
1552
+			$content['styles'] = file_exists($path) && is_readable($path) ? implode('', file($path)) : '';
1554 1553
 			if (!is_writable(dirname($path)) && (!file_exists($path) || !is_writable($path)))
1555 1554
 			{
1556
-				$tmpl->set_cell_attribute('styles','readonly',true);
1555
+				$tmpl->set_cell_attribute('styles', 'readonly', true);
1557 1556
 			}
1558 1557
 		}
1559 1558
 		else
@@ -1562,22 +1561,22 @@  discard block
 block discarded – undo
1562 1561
 		}
1563 1562
 		// generate list of style-sources
1564 1563
 		$keys = $this->etemplate->as_array(-1); unset($keys['group']);
1565
-		$sources[''] = lang('eTemplate').': '.implode(':',$keys);
1566
-		list($app) = explode('.',$this->etemplate->name);
1564
+		$sources[''] = lang('eTemplate').': '.implode(':', $keys);
1565
+		list($app) = explode('.', $this->etemplate->name);
1567 1566
 		$app_templates = @opendir(EGW_SERVER_ROOT.'/'.$app.'/templates');
1568 1567
 		while (($template = @readdir($app_templates)) !== false)
1569 1568
 		{
1570 1569
 			$dir = EGW_SERVER_ROOT.'/'.$app.'/templates/'.$template;
1571
-			if ($template[0] == '.' || $template == 'CVS' || !is_dir($dir.'/images')) continue;	// not a template-dir
1570
+			if ($template[0] == '.' || $template == 'CVS' || !is_dir($dir.'/images')) continue; // not a template-dir
1572 1571
 			$exists = file_exists($dir.'/app.css');
1573 1572
 			$writable = is_writable($dir) || $exists && is_writable($dir.'/app.css');
1574
-			if (!$exists && !$writable) continue;	// nothing to show
1573
+			if (!$exists && !$writable) continue; // nothing to show
1575 1574
 			$rel_path = $app.'/templates/'.$template.'/app.css';
1576 1575
 			$sources[$rel_path] = lang('file').': '.$rel_path.($exists && !$writable ? ' ('.lang('readonly').')' : '');
1577 1576
 		}
1578 1577
 		$GLOBALS['egw_info']['flags']['java_script'] = "<script>window.focus();</script>\n";
1579 1578
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('etemplate').' - '.lang('CSS-styles');
1580
-		$tmpl->exec('etemplate.editor.styles',$content,array('from'=>$sources),'',$keys,2);
1579
+		$tmpl->exec('etemplate.editor.styles', $content, array('from'=>$sources), '', $keys, 2);
1581 1580
 	}
1582 1581
 
1583 1582
 	/**
@@ -1589,11 +1588,11 @@  discard block
 block discarded – undo
1589 1588
 	 * @param string $app='etemplate' app to scan
1590 1589
 	 * @return string comma delimited list of new found extensions
1591 1590
 	 */
1592
-	function scan_for_extensions($app='etemplate')
1591
+	function scan_for_extensions($app = 'etemplate')
1593 1592
 	{
1594 1593
 		if (!is_array($this->extensions)) $this->extensions = array();
1595 1594
 
1596
-		if (isset($this->extensions['**loaded**'][$app])) return '';	// already loaded
1595
+		if (isset($this->extensions['**loaded**'][$app])) return ''; // already loaded
1597 1596
 
1598 1597
 		$labels = array();
1599 1598
 		$dir = @opendir(EGW_SERVER_ROOT.'/'.$app.'/inc');
@@ -1602,9 +1601,9 @@  discard block
 block discarded – undo
1602 1601
 			// ignore et2 base widget matching name-schema of old eTemplate
1603 1602
 			if ($file == 'class.etemplate_widget.inc.php') continue;
1604 1603
 
1605
-			if (preg_match('/class\\.([a-zA-Z0-9_]*)_widget.inc.php/',$file,$regs) &&
1604
+			if (preg_match('/class\\.([a-zA-Z0-9_]*)_widget.inc.php/', $file, $regs) &&
1606 1605
 				($regs[1] != 'xslt' || $this->etemplate->xslt) &&
1607
-				($ext = $this->etemplate->loadExtension($regs[1].'.'.$app,$this->etemplate)))
1606
+				($ext = $this->etemplate->loadExtension($regs[1].'.'.$app, $this->etemplate)))
1608 1607
 			{
1609 1608
 				if (is_array($ext))
1610 1609
 				{
@@ -1619,13 +1618,13 @@  discard block
 block discarded – undo
1619 1618
 			}
1620 1619
 		}
1621 1620
 		// store the information in the session, our constructor loads it from there
1622
-		$GLOBALS['egw']->session->appsession('extensions','etemplate',$this->extensions);
1623
-		$apps_loaded = $GLOBALS['egw']->session->appsession('apps_loaded','etemplate');
1621
+		$GLOBALS['egw']->session->appsession('extensions', 'etemplate', $this->extensions);
1622
+		$apps_loaded = $GLOBALS['egw']->session->appsession('apps_loaded', 'etemplate');
1624 1623
 		$apps_loaded[$app] = true;
1625
-		$GLOBALS['egw']->session->appsession('apps_loaded','etemplate',$apps_loaded);
1624
+		$GLOBALS['egw']->session->appsession('apps_loaded', 'etemplate', $apps_loaded);
1626 1625
 		//_debug_array($this->extensions); _debug_array($apps_loaded);
1627 1626
 
1628
-		return implode(', ',$labels);
1627
+		return implode(', ', $labels);
1629 1628
 	}
1630 1629
 
1631 1630
 	/**
@@ -1634,7 +1633,7 @@  discard block
 block discarded – undo
1634 1633
 	 * @param mixed &$a
1635 1634
 	 * @param mixed &$b
1636 1635
 	 */
1637
-	function swap(&$a,&$b)
1636
+	function swap(&$a, &$b)
1638 1637
 	{
1639 1638
 		$h = $a;
1640 1639
 		$a = $b;
Please login to merge, or discard this patch.
Braces   +203 added lines, -51 removed lines patch added patch discarded remove patch
@@ -299,7 +299,10 @@  discard block
 block discarded – undo
299 299
 		{
300 300
 			echo "<p>etemplate.editor.edit: content="; _debug_array($content);
301 301
 		}
302
-		if (!is_array($content)) $content = array();
302
+		if (!is_array($content))
303
+		{
304
+			$content = array();
305
+		}
303 306
 		$preserv = array();
304 307
 
305 308
 		if ($content['import_xml'])
@@ -309,14 +312,20 @@  discard block
 block discarded – undo
309 312
 			$xml_label = $content['file']['name'];
310 313
 			$preserv['import'] = $this->etemplate->as_array(1);
311 314
 		}
312
-		elseif (is_array($content['import']) && !$content['read'])	// imported not yet saved tmpl
315
+		elseif (is_array($content['import']) && !$content['read'])
316
+		{
317
+			// imported not yet saved tmpl
313 318
 		{
314 319
 			$this->etemplate->init($content['import']);
320
+		}
315 321
 			$preserv['import'] = $content['import'];
316 322
 		}
317 323
 		if ($content['save'])
318 324
 		{
319
-			if (!is_array($content['import'])) $this->etemplate->read($content['old_keys']);
325
+			if (!is_array($content['import']))
326
+			{
327
+				$this->etemplate->read($content['old_keys']);
328
+			}
320 329
 
321 330
 			if (!$this->etemplate->modified_set || !$this->etemplate->modified)
322 331
 			{
@@ -324,7 +333,10 @@  discard block
 block discarded – undo
324 333
 			}
325 334
 			$ok = $this->etemplate->save(trim($content['name']),trim($content['template']),trim($content['lang']),(int) $content['group'],trim($content['version']));
326 335
 			$msg = $ok ? lang('Template saved') : lang('Error: while saving !!!');
327
-			if ($ok) unset($preserv['import']);
336
+			if ($ok)
337
+			{
338
+				unset($preserv['import']);
339
+			}
328 340
 		}
329 341
 		elseif (!$content['import_xml'] && (isset($_GET['name']) || isset($content['name'])) && !$content['restore'])
330 342
 		{
@@ -563,17 +575,23 @@  discard block
 block discarded – undo
563 575
 		if (!isset(boetemplate::$widgets_with_children[$widget['type']]) ||
564 576
 			($old_type == 'grid') == ($widget['type'] == 'grid'))
565 577
 		{
566
-			if (boetemplate::$widgets_with_children[$widget['type']] == 'box')	// box
578
+			if (boetemplate::$widgets_with_children[$widget['type']] == 'box')
579
+			{
580
+				// box
567 581
 			{
568 582
 				if ((int) $widget['size'] < 1)	// min. 1 child
569 583
 				{
570 584
 					list(,$options) = explode(',',$widget['size'],2);
585
+			}
571 586
 					$widget['size'] = '1'.($options ? ','.$options : '');
572 587
 				}
573 588
 				// create the needed cells, if they dont exist
574 589
 				for ($n = 1; $n <= (int) $widget['size']; ++$n)
575 590
 				{
576
-					if (!is_array($widget[$n])) $widget[$n] = $n == 1 ? $old : boetemplate::empty_cell();
591
+					if (!is_array($widget[$n]))
592
+					{
593
+						$widget[$n] = $n == 1 ? $old : boetemplate::empty_cell();
594
+					}
577 595
 				}
578 596
 			}
579 597
 			return; // no change necessary, eg. between different box-types
@@ -584,13 +602,19 @@  discard block
 block discarded – undo
584 602
 				$widget['data'] = array(array());
585 603
 				$widget['cols'] = $widget['rows'] = 0;
586 604
 
587
-				if ($old_had_children)	// box --> grid: hbox --> 1 row, other boxes --> 1 column
605
+				if ($old_had_children)
606
+				{
607
+					// box --> grid: hbox --> 1 row, other boxes --> 1 column
588 608
 				{
589 609
 					list($num) = explode(',',$old['size']);
610
+				}
590 611
 					for ($n = 1; is_array($old[$n]) && $n <= $num; ++$n)
591 612
 					{
592 613
 						$new_line = null;
593
-						if ($old_type != 'hbox') boetemplate::add_child($widget,$new_line);
614
+						if ($old_type != 'hbox')
615
+						{
616
+							boetemplate::add_child($widget,$new_line);
617
+						}
594 618
 						boetemplate::add_child($widget,$old[$n]);
595 619
 						unset($widget[$n]);
596 620
 					}
@@ -615,16 +639,25 @@  discard block
 block discarded – undo
615 639
 					{
616 640
 						$orient = $widget['type'] == 'hbox' ? 'horizontal' : 'vertical';
617 641
 					}
618
-					if ($orient == 'horizontal')	// ==> use first row
642
+					if ($orient == 'horizontal')
643
+					{
644
+						// ==> use first row
619 645
 					{
620 646
 						$row =& $old['data'][1];
647
+					}
621 648
 						for ($n = 0; $n < $old['cols']; ++$n)
622 649
 						{
623 650
 							$cell =& $row[boetemplate::num2chrs($n)];
624 651
 							boetemplate::add_child($widget,$cell);
625 652
 							list($span) = (int)explode(',',$cell['span']);
626
-							if ($span == 'all') break;
627
-							while ($span-- > 1) ++$n;
653
+							if ($span == 'all')
654
+							{
655
+								break;
656
+							}
657
+							while ($span-- > 1)
658
+							{
659
+								++$n;
660
+							}
628 661
 						}
629 662
 					}
630 663
 					else	// vertical ==> use 1 column
@@ -635,10 +668,13 @@  discard block
 block discarded – undo
635 668
 						}
636 669
 					}
637 670
 				}
638
-				if (!$widget['size']) // minimum one child
671
+				if (!$widget['size'])
672
+				{
673
+					// minimum one child
639 674
 				{
640 675
 					boetemplate::add_child($widget,boetemplate::empty_cell());
641 676
 				}
677
+				}
642 678
 				break;
643 679
 		}
644 680
 		//_debug_array($widget);
@@ -683,25 +719,49 @@  discard block
 block discarded – undo
683 719
 			// find the column-number (base 0) for $c (A, B, C, ...)
684 720
 			for($col = 0; boetemplate::num2chrs($col) != $c && $col < 100; ++$col) ;
685 721
 
686
-			if ($col > 0) $left = $parent_path.'/'.$r.boetemplate::num2chrs($col-1);
722
+			if ($col > 0)
723
+			{
724
+				$left = $parent_path.'/'.$r.boetemplate::num2chrs($col-1);
725
+			}
687 726
 
688
-			if ($col < $parent['cols']-1) $right = $parent_path.'/'.$r.boetemplate::num2chrs($col+1);
727
+			if ($col < $parent['cols']-1)
728
+			{
729
+				$right = $parent_path.'/'.$r.boetemplate::num2chrs($col+1);
730
+			}
689 731
 
690
-			if ($r > 1) $up = $parent_path.'/'.($r-1).$c;
732
+			if ($r > 1)
733
+			{
734
+				$up = $parent_path.'/'.($r-1).$c;
735
+			}
691 736
 
692
-			if ($r < $parent['rows']) $down = $parent_path.'/'.($r+1).$c;
737
+			if ($r < $parent['rows'])
738
+			{
739
+				$down = $parent_path.'/'.($r+1).$c;
740
+			}
693 741
 		}
694
-		elseif ($parent['type']) // any box
742
+		elseif ($parent['type'])
743
+		{
744
+			// any box
695 745
 		{
696 746
 			if ($child_id > 1) $previous = $parent_path.'/'.($child_id-1);
747
+		}
697 748
 
698
-			if ($child_id < (int) $parent['size'])  $next = $parent_path.'/'.($child_id+1);
749
+			if ($child_id < (int) $parent['size'])
750
+			{
751
+				$next = $parent_path.'/'.($child_id+1);
752
+			}
699 753
 		}
700 754
 		else // template
701 755
 		{
702
-			if ($child_id > 0) $previous = '/'.($child_id-1);
756
+			if ($child_id > 0)
757
+			{
758
+				$previous = '/'.($child_id-1);
759
+			}
703 760
 
704
-			if ($child_id < count($this->etemplate->children)-1)  $next = '/'.($child_id+1);
761
+			if ($child_id < count($this->etemplate->children)-1)
762
+			{
763
+				$next = '/'.($child_id+1);
764
+			}
705 765
 		}
706 766
 		if ($widget['type'] == 'grid')
707 767
 		{
@@ -709,10 +769,13 @@  discard block
 block discarded – undo
709 769
 		}
710 770
 		elseif (isset(boetemplate::$widgets_with_children[$widget['type']]) && $widget['type'] != 'template')
711 771
 		{
712
-			if ($widget['type'])	// box
772
+			if ($widget['type'])
773
+			{
774
+				// box
713 775
 			{
714 776
 				$in = $parent_path.'/'.$child_id.'/1';
715 777
 			}
778
+			}
716 779
 			else
717 780
 			{
718 781
 				$in = '/0';
@@ -722,7 +785,10 @@  discard block
 block discarded – undo
722 785
 		foreach(array('left'=>'&larr;','up'=>'&nbsp;&uarr;&nbsp;','down'=>'&nbsp;&darr;&nbsp;',
723 786
 			'right'=>'&rarr;','previous'=>'&larr;&uarr;','next'=>'&darr;&rarr;','in'=>'&times;') as $var => $dir)
724 787
 		{
725
-			if ($$var) $navi[$$var] = $dir;
788
+			if ($$var)
789
+			{
790
+				$navi[$$var] = $dir;
791
+			}
726 792
 		}
727 793
 		return $navi;
728 794
 	}
@@ -767,13 +833,19 @@  discard block
 block discarded – undo
767 833
 				if ($parent['type'] != 'grid')
768 834
 				{
769 835
 					// delete widget from parent
770
-					if ($parent['type'])	// box
836
+					if ($parent['type'])
837
+					{
838
+						// box
771 839
 					{
772 840
 						list($num,$options) = explode(',',$parent['size'],2);
773
-						if ($num <= 1)	// cant delete last child --> only empty it
841
+					}
842
+						if ($num <= 1)
843
+						{
844
+							// cant delete last child --> only empty it
774 845
 						{
775 846
 							$parent[$num=1] = boetemplate::empty_cell();
776 847
 						}
848
+						}
777 849
 						else
778 850
 						{
779 851
 							for($n = $child_id; $n < $num; ++$n)
@@ -786,10 +858,13 @@  discard block
 block discarded – undo
786 858
 					}
787 859
 					else	// template itself
788 860
 					{
789
-						if (count($this->etemplate->children) <= 1)	// cant delete last child
861
+						if (count($this->etemplate->children) <= 1)
862
+						{
863
+							// cant delete last child
790 864
 						{
791 865
 							$this->etemplate->children[0] = boetemplate::empty_cell();
792 866
 						}
867
+						}
793 868
 						else
794 869
 						{
795 870
 							unset($parent[$child_id]);
@@ -826,9 +901,13 @@  discard block
 block discarded – undo
826 901
 			case 'box_insert_before':
827 902
 			case 'box_insert_behind':
828 903
 				$n = $child_id + (int)($action == 'box_insert_behind');
829
-				if (!$parent['type'])	// template
904
+				if (!$parent['type'])
905
+				{
906
+					// template
830 907
 				{
831
-					$num = count($parent)-1;	// 0..count()-1
908
+					$num = count($parent)-1;
909
+				}
910
+				// 0..count()-1
832 911
 				}
833 912
 				else // boxes
834 913
 				{
@@ -840,21 +919,31 @@  discard block
 block discarded – undo
840 919
 				}
841 920
 				$parent[$n] = $content['cell'] = boetemplate::empty_cell();
842 921
 				$child_id = $n;
843
-				if ($parent['type']) $parent['size'] = (1+$num) . ($options ? ','.$options : '');
922
+				if ($parent['type'])
923
+				{
924
+					$parent['size'] = (1+$num) . ($options ? ','.$options : '');
925
+				}
844 926
 				break;
845 927
 
846 928
 			case 'box_swap_next':
847
-				if (!$parent['type'])	// template
929
+				if (!$parent['type'])
848 930
 				{
849
-					$num = count($parent)-1;	// 0..count()-1
931
+					// template
932
+				{
933
+					$num = count($parent)-1;
934
+				}
935
+				// 0..count()-1
850 936
 				}
851 937
 				else // boxes
852 938
 				{
853 939
 					list($num) = explode(',',$parent['size'],2);
854 940
 				}
855
-				if ($child_id == $num)	// if on last cell, swap with the one before
941
+				if ($child_id == $num)
942
+				{
943
+					// if on last cell, swap with the one before
856 944
 				{
857 945
 					$this->swap($parent[$child_id],$parent[$child_id-1]);
946
+				}
858 947
 					--$child_id;
859 948
 				}
860 949
 				else
@@ -885,16 +974,25 @@  discard block
 block discarded – undo
885 974
 		$cols =& $grid['cols'];
886 975
 		$opts =& $data[0];
887 976
 
888
-		if (preg_match('/^([0-9]+)([A-Z]+)$/',$child_id,$matches)) list(,$r,$c) = $matches;
977
+		if (preg_match('/^([0-9]+)([A-Z]+)$/',$child_id,$matches))
978
+		{
979
+			list(,$r,$c) = $matches;
980
+		}
889 981
 
890
-		if (!$c || !$r || $r > $rows) return "wrong child_id='$child_id' => r='$r', c='$c'";
982
+		if (!$c || !$r || $r > $rows)
983
+		{
984
+			return "wrong child_id='$child_id' => r='$r', c='$c'";
985
+		}
891 986
 
892 987
 		switch($action)
893 988
 		{
894 989
 			case 'row_swap_next':
895 990
 				if ($r > $rows-1)
896 991
 				{
897
-					if ($r != $rows) return lang('no row to swap with !!!');
992
+					if ($r != $rows)
993
+					{
994
+						return lang('no row to swap with !!!');
995
+					}
898 996
 					--$r;	// in last row swap with row above
899 997
 				}
900 998
 				$this->swap($data[$r],$data[1+$r]);
@@ -903,9 +1001,12 @@  discard block
 block discarded – undo
903 1001
 				break;
904 1002
 
905 1003
 			case 'row_delete':
906
-				if ($rows <= 1)	// one row only => delete whole grid
1004
+				if ($rows <= 1)
1005
+				{
1006
+					// one row only => delete whole grid
907 1007
 				{
908 1008
 					return lang('cant delete the only row in a grid !!!');
1009
+				}
909 1010
 					// todo: delete whole grid instead
910 1011
 				}
911 1012
 				for($i = $r; $i < $rows; ++$i)
@@ -963,18 +1064,27 @@  discard block
 block discarded – undo
963 1064
 		$cols =& $grid['cols'];
964 1065
 		$opts =& $data[0];
965 1066
 
966
-		if (preg_match('/^([0-9]+)([A-Z]+)$/',$child_id,$matches)) list(,$r,$c) = $matches;
1067
+		if (preg_match('/^([0-9]+)([A-Z]+)$/',$child_id,$matches))
1068
+		{
1069
+			list(,$r,$c) = $matches;
1070
+		}
967 1071
 		// find the column-number (base 0) for $c (A, B, C, ...)
968 1072
 		for($col = 0; boetemplate::num2chrs($col) != $c && $col < 100; ++$col) ;
969 1073
 
970
-		if (!$c || !$r || $r > $rows || $col >= $cols) return "wrong child_id='$child_id' => r='$r', c='$c', col=$col";
1074
+		if (!$c || !$r || $r > $rows || $col >= $cols)
1075
+		{
1076
+			return "wrong child_id='$child_id' => r='$r', c='$c', col=$col";
1077
+		}
971 1078
 
972 1079
 		switch($action)
973 1080
 		{
974 1081
 			case 'column_swap_next':
975 1082
 				if ($col >= $cols-1)
976 1083
 				{
977
-					if ($col != $cols-1) return lang('no column to swap with !!!');
1084
+					if ($col != $cols-1)
1085
+					{
1086
+						return lang('no column to swap with !!!');
1087
+					}
978 1088
 					$c = boetemplate::num2chrs(--$col); // in last column swap with the one before
979 1089
 				}
980 1090
 				$c_next = boetemplate::num2chrs(1+$col);
@@ -1091,9 +1201,18 @@  discard block
 block discarded – undo
1091 1201
 					$onclick = str_replace('&values2url('.$values2url.')','',$cell_content['onclick']);
1092 1202
 				}
1093 1203
 				list($get,$target,$width,$height) = explode(',',$values2url ? $onclick : $cell_content['onclick']);
1094
-				if (!$target) $target = '_blank';
1095
-				if (!$width)  $width  = 600;
1096
-				if (!$height) $height = 450;
1204
+				if (!$target)
1205
+				{
1206
+					$target = '_blank';
1207
+				}
1208
+				if (!$width)
1209
+				{
1210
+					$width  = 600;
1211
+				}
1212
+				if (!$height)
1213
+				{
1214
+					$height = 450;
1215
+				}
1097 1216
 				$widget['onclick'] = "window.open(egw::link('/index.php','$get')".($values2url ? "+values2url(this.form,$values2url)" : '').
1098 1217
 					",'$target','dependent=yes,width=$width,height=$height,scrollbars=yes,status=yes'); return false;";
1099 1218
 			}
@@ -1201,7 +1320,10 @@  discard block
 block discarded – undo
1201 1320
 		{
1202 1321
 			foreach(array('save','apply','cancel','goto','goto2','edit_menu','box_menu','row_menu','column_menu') as $n => $name)
1203 1322
 			{
1204
-				if (($action = $content[$name] ? ($n < 5 ? $name : $content[$name]) : false)) break;
1323
+				if (($action = $content[$name] ? ($n < 5 ? $name : $content[$name]) : false))
1324
+				{
1325
+					break;
1326
+				}
1205 1327
 				$name = '';
1206 1328
 			}
1207 1329
 			unset($content[$name]);
@@ -1258,7 +1380,10 @@  discard block
 block discarded – undo
1258 1380
 					{
1259 1381
 						$this->change_widget_type($content['cell'],$widget);
1260 1382
 					}
1261
-					if (!$action) break;
1383
+					if (!$action)
1384
+					{
1385
+						break;
1386
+					}
1262 1387
 					// save+apply only
1263 1388
 					$widget = $content['cell'];
1264 1389
 					if ($content['cell']['onclick_type'] || $content['cell']['onclick'])
@@ -1299,7 +1424,10 @@  discard block
 block discarded – undo
1299 1424
 					$js = "opener.location.href='".$GLOBALS['egw']->link('/index.php',array(
1300 1425
 							'menuaction' => 'etemplate.editor.edit',
1301 1426
 						)+$content['opener'])."';";
1302
-					if ($action == 'apply' || $action == 'apply-no-merge') break;
1427
+					if ($action == 'apply' || $action == 'apply-no-merge')
1428
+					{
1429
+						break;
1430
+					}
1303 1431
 					// fall through
1304 1432
 				case 'cancel':
1305 1433
 					$js .= 'window.close();';
@@ -1457,7 +1585,10 @@  discard block
 block discarded – undo
1457 1585
 				unset($allowed_parts['header']);
1458 1586
 				break;
1459 1587
 			case '':
1460
-				if ($row > 1) $allowed_parts = array('' => $allowed_parts['']);
1588
+				if ($row > 1)
1589
+				{
1590
+					$allowed_parts = array('' => $allowed_parts['']);
1591
+				}
1461 1592
 				break;
1462 1593
 		}
1463 1594
 		switch($next_part)
@@ -1484,7 +1615,10 @@  discard block
 block discarded – undo
1484 1615
 		{
1485 1616
 			foreach(boetemplate::$db_key_cols as $var)
1486 1617
 			{
1487
-				if (isset($_GET[$var])) $content[$var] = $_GET[$var];
1618
+				if (isset($_GET[$var]))
1619
+				{
1620
+					$content[$var] = $_GET[$var];
1621
+				}
1488 1622
 			}
1489 1623
 		}
1490 1624
 		//_debug_array($content);
@@ -1568,10 +1702,18 @@  discard block
 block discarded – undo
1568 1702
 		while (($template = @readdir($app_templates)) !== false)
1569 1703
 		{
1570 1704
 			$dir = EGW_SERVER_ROOT.'/'.$app.'/templates/'.$template;
1571
-			if ($template[0] == '.' || $template == 'CVS' || !is_dir($dir.'/images')) continue;	// not a template-dir
1705
+			if ($template[0] == '.' || $template == 'CVS' || !is_dir($dir.'/images'))
1706
+			{
1707
+				continue;
1708
+			}
1709
+			// not a template-dir
1572 1710
 			$exists = file_exists($dir.'/app.css');
1573 1711
 			$writable = is_writable($dir) || $exists && is_writable($dir.'/app.css');
1574
-			if (!$exists && !$writable) continue;	// nothing to show
1712
+			if (!$exists && !$writable)
1713
+			{
1714
+				continue;
1715
+			}
1716
+			// nothing to show
1575 1717
 			$rel_path = $app.'/templates/'.$template.'/app.css';
1576 1718
 			$sources[$rel_path] = lang('file').': '.$rel_path.($exists && !$writable ? ' ('.lang('readonly').')' : '');
1577 1719
 		}
@@ -1591,16 +1733,26 @@  discard block
 block discarded – undo
1591 1733
 	 */
1592 1734
 	function scan_for_extensions($app='etemplate')
1593 1735
 	{
1594
-		if (!is_array($this->extensions)) $this->extensions = array();
1736
+		if (!is_array($this->extensions))
1737
+		{
1738
+			$this->extensions = array();
1739
+		}
1595 1740
 
1596
-		if (isset($this->extensions['**loaded**'][$app])) return '';	// already loaded
1741
+		if (isset($this->extensions['**loaded**'][$app]))
1742
+		{
1743
+			return '';
1744
+		}
1745
+		// already loaded
1597 1746
 
1598 1747
 		$labels = array();
1599 1748
 		$dir = @opendir(EGW_SERVER_ROOT.'/'.$app.'/inc');
1600 1749
 		while ($dir && ($file = readdir($dir)))
1601 1750
 		{
1602 1751
 			// ignore et2 base widget matching name-schema of old eTemplate
1603
-			if ($file == 'class.etemplate_widget.inc.php') continue;
1752
+			if ($file == 'class.etemplate_widget.inc.php')
1753
+			{
1754
+				continue;
1755
+			}
1604 1756
 
1605 1757
 			if (preg_match('/class\\.([a-zA-Z0-9_]*)_widget.inc.php/',$file,$regs) &&
1606 1758
 				($regs[1] != 'xslt' || $this->etemplate->xslt) &&
Please login to merge, or discard this patch.
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 			foreach((array)$content['cont'] as $key => $val)
492 492
 			{
493 493
 				$vals["@$r"] = $key;
494
-				$vals["A$r"] = is_array($val) ? serialize($val).'#SeR#' : $val;
494
+				$vals["a$r"] = is_array($val) ? serialize($val).'#SeR#' : $val;
495 495
 				++$r;
496 496
 			}
497 497
 			$editor->data[$editor->rows]['A']['name'] = 'etemplate.editor.values';
@@ -527,10 +527,10 @@  discard block
 block discarded – undo
527 527
 			$vals = $content['vals'];
528 528
 			$olds = $content['olds'];
529 529
 
530
-			for ($r = 1; isset($vals["A$r"]); ++$r)
530
+			for ($r = 1; isset($vals["a$r"]); ++$r)
531 531
 			{
532
-				$new_content['cont'][$olds["@$r"]] = substr($vals["A$r"],-5)=='#SeR#' ?
533
-					unserialize(substr($vals["A$r"],0,-5)) : $vals["A$r"];
532
+				$new_content['cont'][$olds["@$r"]] = substr($vals["a$r"],-5)=='#SeR#' ?
533
+					unserialize(substr($vals["a$r"],0,-5)) : $vals["a$r"];
534 534
 			}
535 535
 		}
536 536
 		// check if bo class of $app exists and has a labels method --> add labels to content to display them in the editor
Please login to merge, or discard this patch.
etemplate/inc/class.etemplate.inc.php 4 patches
Doc Comments   +7 added lines, -16 removed lines patch added patch discarded remove patch
@@ -357,8 +357,6 @@  discard block
 block discarded – undo
357 357
 	* Check if we have not ignored validation errors
358 358
 	*
359 359
 	* @param string $ignore_validation='' if not empty regular expression for validation-errors to ignore
360
-	* @param string $cname=null name-prefix, which need to be ignored, default self::$name_vars
361
-	* @return boolean true if there are not ignored validation errors, false otherwise
362 360
 	*/
363 361
 	static function validation_errors($ignore_validation='',$cname=null)
364 362
 	{
@@ -382,7 +380,6 @@  discard block
 block discarded – undo
382 380
 	 * Check if given form-name matches ai ignore-validation rule
383 381
 	 *
384 382
 	 * @param string $ignore_validation='' if not empty regular expression for validation-errors to ignore
385
-	 * @param string $cname=null name-prefix, which need to be ignored, default self::$name_vars
386 383
 	 * @param string $cname
387 384
 	 * @return boolean
388 385
 	 */
@@ -651,8 +648,8 @@  discard block
 block discarded – undo
651 648
 	* 		This is to facilitate complex ACL's which denies access on field-level !!!
652 649
 	* @param string $cname basename of names for form-elements, means index in $_POST
653 650
 	* 		eg. $cname='cont', element-name = 'name' returned content in $_POST['cont']['name']
654
-	* @param string $show_c name/index for name expansion
655
-	* @param string $show_row name/index for name expansion
651
+	* @param integer $show_c name/index for name expansion
652
+	* @param integer $show_row name/index for name expansion
656 653
 	* @return string the generated HTML
657 654
 	*/
658 655
 	function show($content,$sel_options='',$readonlys='',$cname='',$show_c=0,$show_row=0)
@@ -755,8 +752,8 @@  discard block
 block discarded – undo
755 752
 	* 		This is to facilitate complex ACL's which denies access on field-level !!!
756 753
 	* @param string $cname basename of names for form-elements, means index in $_POST
757 754
 	*		eg. $cname='cont', element-name = 'name' returned content in $_POST['cont']['name']
758
-	* @param string $show_c name/index for name expansion
759
-	* @param string $show_row name/index for name expansion
755
+	* @param integer $show_c name/index for name expansion
756
+	* @param integer $show_row name/index for name expansion
760 757
 	* @param string $path path in the widget tree
761 758
 	* @return string the generated HTML
762 759
 	*/
@@ -2009,8 +2006,6 @@  discard block
 block discarded – undo
2009 2006
 	 * (If no id is directly supplied internally.)
2010 2007
 	 *
2011 2008
 	 * @param string $form_name
2012
-	 * @param string $name=null
2013
-	 * @param string $id=null
2014 2009
 	 * @return string ' id="..."' or '' if no id found
2015 2010
 	 */
2016 2011
 	static public function get_id($form_name,$name=null,$id=null)
@@ -2038,8 +2033,8 @@  discard block
 block discarded – undo
2038 2033
 	 * --> use . as decimal separator for browser supporting html5 input type=number
2039 2034
 	 *
2040 2035
 	 * @param int|float|string $number
2041
-	 * @param int $num_decimal_places=2
2042
-	 * @param boolean $readonly=true
2036
+	 * @param int $num_decimal_places
2037
+	 * @param boolean $readonly
2043 2038
 	 * @return string
2044 2039
 	 */
2045 2040
 	static public function number_format($number,$num_decimal_places=2,$readonly=true)
@@ -2067,8 +2062,6 @@  discard block
 block discarded – undo
2067 2062
 	*
2068 2063
 	* @param array $cell
2069 2064
 	* @param string $name
2070
-	* @param array $content=array();
2071
-	* @return array
2072 2065
 	*/
2073 2066
 	function _sel_options($cell,$name,$content=array())
2074 2067
 	{
@@ -2236,8 +2229,6 @@  discard block
 block discarded – undo
2236 2229
 	* @param array $content $_POST[$cname], on return the adjusted content
2237 2230
 	* @param array $to_process list of widgets/form-fields to process
2238 2231
 	* @param string $cname='' basename of our returnt content (same as in call to show)
2239
-	* @param string $_type='regular' type of request
2240
-	* @return array with validation errors
2241 2232
 	*/
2242 2233
 	function process_show(&$content,$to_process,$cname='',$_type='regular')
2243 2234
 	{
@@ -2484,7 +2475,7 @@  discard block
 block discarded – undo
2484 2475
 	*
2485 2476
 	* @param string $name (complete) name of the widget causing the error
2486 2477
 	* @param string|boolean $error error-message already translated or false to reset all existing error for given name
2487
-	* @param string $cname=null set it to '', if the name is already a form-name, defaults to self::$name_vars
2478
+	* @param string $cname
2488 2479
 	*/
2489 2480
 	static function set_validation_error($name,$error,$cname=null)
2490 2481
 	{
Please login to merge, or discard this patch.
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -28,55 +28,55 @@  discard block
 block discarded – undo
28 28
 class etemplate extends boetemplate
29 29
 {
30 30
 	/**
31
-	* integer debug-level or template-name or cell-type or '' = off
32
-	* 1=calls to show and process_show, 2=content after process_show,
33
-	* 3=calls to show_cell and process_show_cell
34
-	*
35
-	* @public int/string
36
-	*/
31
+	 * integer debug-level or template-name or cell-type or '' = off
32
+	 * 1=calls to show and process_show, 2=content after process_show,
33
+	 * 3=calls to show_cell and process_show_cell
34
+	 *
35
+	 * @public int/string
36
+	 */
37 37
 	public $debug;
38 38
 	/**
39
-	* Inner width of browser window
40
-	*
41
-	* @public int
42
-	*/
39
+	 * Inner width of browser window
40
+	 *
41
+	 * @public int
42
+	 */
43 43
 	public $innerWidth;
44 44
 	/**
45
-	* Reference to the content-param of the last call to show, for extensions to use
46
-	*
47
-	* @public array
48
-	*/
45
+	 * Reference to the content-param of the last call to show, for extensions to use
46
+	 *
47
+	 * @public array
48
+	 */
49 49
 	public $content;
50 50
 	/**
51
-	* Reference to the sel_options-param of the last call to show, for extensions to use
52
-	*
53
-	* @public array
54
-	*/
51
+	 * Reference to the sel_options-param of the last call to show, for extensions to use
52
+	 *
53
+	 * @public array
54
+	 */
55 55
 	public $sel_options;
56 56
 	/**
57
-	* Name of the form of the currently processed etemplate
58
-	*
59
-	* @public string
60
-	*/
57
+	 * Name of the form of the currently processed etemplate
58
+	 *
59
+	 * @public string
60
+	 */
61 61
 	static $name_form='eTemplate';
62 62
 	/**
63
-	* Used form-names in this request
64
-	*
65
-	* @public array
66
-	*/
63
+	 * Used form-names in this request
64
+	 *
65
+	 * @public array
66
+	 */
67 67
 	static $name_forms=array();
68 68
 	/**
69
-	* Basename of the variables (content) in $_POST and id's, usually 'exec',
70
-	* if there's not more then one eTemplate on the page (then it will be exec, exec2, exec3, ...
71
-	*
72
-	* @public string
73
-	*/
69
+	 * Basename of the variables (content) in $_POST and id's, usually 'exec',
70
+	 * if there's not more then one eTemplate on the page (then it will be exec, exec2, exec3, ...
71
+	 *
72
+	 * @public string
73
+	 */
74 74
 	static $name_vars='exec';
75 75
 	/**
76
-	* Are we running as sitemgr module or not
77
-	*
78
-	* @public boolean
79
-	*/
76
+	 * Are we running as sitemgr module or not
77
+	 *
78
+	 * @public boolean
79
+	 */
80 80
 	public $sitemgr=false;
81 81
 	/**
82 82
 	 * Javascript to be called, when a widget get's double-clicked (used only by the editor)
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
 	static private $hook_app;
130 130
 
131 131
 	/**
132
-	* constructor of etemplate class, reads an eTemplate if $name is given
133
-	*
134
-	* @param string $name of etemplate or array with name and other keys
135
-	* @param string/array $load_via with keys of other etemplate to load in order to get $name
136
-	*/
132
+	 * constructor of etemplate class, reads an eTemplate if $name is given
133
+	 *
134
+	 * @param string $name of etemplate or array with name and other keys
135
+	 * @param string/array $load_via with keys of other etemplate to load in order to get $name
136
+	 */
137 137
 	function __construct($name='',$load_via='')
138 138
 	{
139 139
 		// tell framework old eTemplate apps needs eval and inline javascript :(
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
 	}
156 156
 
157 157
 	/**
158
-	* Abstracts a html-location-header call
159
-	*
160
-	* In other UI's than html this needs to call the methode, defined by menuaction or
161
-	* open a browser-window for any other links.
162
-	*
163
-	* @param string/array $params url or array with get-params incl. menuaction
164
-	*/
158
+	 * Abstracts a html-location-header call
159
+	 *
160
+	 * In other UI's than html this needs to call the methode, defined by menuaction or
161
+	 * open a browser-window for any other links.
162
+	 *
163
+	 * @param string/array $params url or array with get-params incl. menuaction
164
+	 */
165 165
 	static function location($params='')
166 166
 	{
167 167
 		egw::redirect_link(is_array($params) ? '/index.php' : $params,
@@ -169,33 +169,33 @@  discard block
 block discarded – undo
169 169
 	}
170 170
 
171 171
 	/**
172
-	* Generats a Dialog from an eTemplate - abstract the UI-layer
173
-	*
174
-	* This is the only function an application should use, all other are INTERNAL and
175
-	* do NOT abstract the UI-layer, because they return HTML.
176
-	* Generates a webpage with a form from the template and puts process_exec in the
177
-	* form as submit-url to call process_show for the template before it
178
-	* ExecuteMethod's the given $method of the caller.
179
-	*
180
-	* @param string $method Methode (e.g. 'etemplate.editor.edit') to be called if form is submitted
181
-	* @param array $content with content to fill the input-fields of template, eg. the text-field
182
-	* 		with name 'name' gets its content from $content['name']
183
-	* @param $sel_options array or arrays with the options for each select-field, keys are the
184
-	* 		field-names, eg. array('name' => array(1 => 'one',2 => 'two')) set the
185
-	* 		options for field 'name'. ($content['options-name'] is possible too !!!)
186
-	* @param array $readonlys with field-names as keys for fields with should be readonly
187
-	* 		(eg. to implement ACL grants on field-level or to remove buttons not applicable)
188
-	* @param array $preserv with vars which should be transported to the $method-call (eg. an id) array('id' => $id) sets $_POST['id'] for the $method-call
189
-	* @param int $output_mode
190
-	*	 0 = echo incl. navbar
191
-	*	 1 = return html
192
-	*	-1 = first time return html, after use 0 (echo html incl. navbar), eg. for home
193
-	*	 2 = echo without navbar (eg. for popups)
194
-	*	 3 = return eGW independent html site
195
-	* @param string $ignore_validation if not empty regular expression for validation-errors to ignore
196
-	* @param array $changes change made in the last call if looping, only used internaly by process_exec
197
-	* @return string html for $output_mode == 1, else nothing
198
-	*/
172
+	 * Generats a Dialog from an eTemplate - abstract the UI-layer
173
+	 *
174
+	 * This is the only function an application should use, all other are INTERNAL and
175
+	 * do NOT abstract the UI-layer, because they return HTML.
176
+	 * Generates a webpage with a form from the template and puts process_exec in the
177
+	 * form as submit-url to call process_show for the template before it
178
+	 * ExecuteMethod's the given $method of the caller.
179
+	 *
180
+	 * @param string $method Methode (e.g. 'etemplate.editor.edit') to be called if form is submitted
181
+	 * @param array $content with content to fill the input-fields of template, eg. the text-field
182
+	 * 		with name 'name' gets its content from $content['name']
183
+	 * @param $sel_options array or arrays with the options for each select-field, keys are the
184
+	 * 		field-names, eg. array('name' => array(1 => 'one',2 => 'two')) set the
185
+	 * 		options for field 'name'. ($content['options-name'] is possible too !!!)
186
+	 * @param array $readonlys with field-names as keys for fields with should be readonly
187
+	 * 		(eg. to implement ACL grants on field-level or to remove buttons not applicable)
188
+	 * @param array $preserv with vars which should be transported to the $method-call (eg. an id) array('id' => $id) sets $_POST['id'] for the $method-call
189
+	 * @param int $output_mode
190
+	 *	 0 = echo incl. navbar
191
+	 *	 1 = return html
192
+	 *	-1 = first time return html, after use 0 (echo html incl. navbar), eg. for home
193
+	 *	 2 = echo without navbar (eg. for popups)
194
+	 *	 3 = return eGW independent html site
195
+	 * @param string $ignore_validation if not empty regular expression for validation-errors to ignore
196
+	 * @param array $changes change made in the last call if looping, only used internaly by process_exec
197
+	 * @return string html for $output_mode == 1, else nothing
198
+	 */
199 199
 	function exec($method,$content,$sel_options='',$readonlys='',$preserv='',$output_mode=0,$ignore_validation='',$changes='')
200 200
 	{
201 201
 		if (!$sel_options)
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 	}
355 355
 
356 356
 	/**
357
-	* Check if we have not ignored validation errors
358
-	*
359
-	* @param string $ignore_validation='' if not empty regular expression for validation-errors to ignore
360
-	* @param string $cname=null name-prefix, which need to be ignored, default self::$name_vars
361
-	* @return boolean true if there are not ignored validation errors, false otherwise
362
-	*/
357
+	 * Check if we have not ignored validation errors
358
+	 *
359
+	 * @param string $ignore_validation='' if not empty regular expression for validation-errors to ignore
360
+	 * @param string $cname=null name-prefix, which need to be ignored, default self::$name_vars
361
+	 * @return boolean true if there are not ignored validation errors, false otherwise
362
+	 */
363 363
 	static function validation_errors($ignore_validation='',$cname=null)
364 364
 	{
365 365
 		if (is_null($cname)) $cname = self::$name_vars;
@@ -397,17 +397,17 @@  discard block
 block discarded – undo
397 397
 	}
398 398
 
399 399
 	/**
400
-	* Makes the necessary adjustments to _POST before it calls the app's method
401
-	*
402
-	* This function is only to submit forms to, create with exec.
403
-	* All eTemplates / forms executed with exec are submited to this function
404
-	* via /etemplate/process_exec.php?menuaction=<callback>. We cant use the global index.php as
405
-	* it would set some constants to etemplate instead of the calling app.
406
-	* process_exec then calls process_show for the eTemplate (to adjust the content of the _POST) and
407
-	* ExecMethod's the given callback from the app with the content of the form as first argument.
408
-	*
409
-	* @return mixed false if no sessiondata and $this->sitemgr, else the returnvalue of exec of the method-calls
410
-	*/
400
+	 * Makes the necessary adjustments to _POST before it calls the app's method
401
+	 *
402
+	 * This function is only to submit forms to, create with exec.
403
+	 * All eTemplates / forms executed with exec are submited to this function
404
+	 * via /etemplate/process_exec.php?menuaction=<callback>. We cant use the global index.php as
405
+	 * it would set some constants to etemplate instead of the calling app.
406
+	 * process_exec then calls process_show for the eTemplate (to adjust the content of the _POST) and
407
+	 * ExecMethod's the given callback from the app with the content of the form as first argument.
408
+	 *
409
+	 * @return mixed false if no sessiondata and $this->sitemgr, else the returnvalue of exec of the method-calls
410
+	 */
411 411
 	function process_exec($etemplate_exec_id = null, $submit_button = null, $exec = null, $type = 'regular' )
412 412
 	{
413 413
 		if(!$etemplate_exec_id) $etemplate_exec_id = $_POST['etemplate_exec_id'];
@@ -603,12 +603,12 @@  discard block
 block discarded – undo
603 603
 	}
604 604
 
605 605
 	/**
606
-	* process the values transfered with the javascript function values2url
607
-	*
608
-	* The returned array contains the preserved values overwritten (only!) with the variables named in values2url
609
-	*
610
-	* @return array/boolean content array or false on error
611
-	*/
606
+	 * process the values transfered with the javascript function values2url
607
+	 *
608
+	 * The returned array contains the preserved values overwritten (only!) with the variables named in values2url
609
+	 *
610
+	 * @return array/boolean content array or false on error
611
+	 */
612 612
 	function process_values2url()
613 613
 	{
614 614
 		//echo "process_exec: _GET ="; _debug_array($_GET);
@@ -636,25 +636,25 @@  discard block
 block discarded – undo
636 636
 	static private $styles_included = array();
637 637
 
638 638
 	/**
639
-	* creates HTML from an eTemplate
640
-	*
641
-	* This is done by calling show_cell for each cell in the form. show_cell itself
642
-	* calls show recursivly for each included eTemplate.
643
-	* You could use it in the UI-layer of an app, just make shure to call process_show !!!
644
-	* This is intended as internal function and should NOT be called by new app's direct,
645
-	* as it deals with HTML and is so UI-dependent, use exec instead.
646
-	*
647
-	* @internal
648
-	* @param array $content with content for the cells, keys are the names given in the cells/form elements
649
-	* @param array $sel_options with options for the selectboxes, keys are the name of the selectbox
650
-	* @param array $readonlys with names of cells/form-elements to be not allowed to change
651
-	* 		This is to facilitate complex ACL's which denies access on field-level !!!
652
-	* @param string $cname basename of names for form-elements, means index in $_POST
653
-	* 		eg. $cname='cont', element-name = 'name' returned content in $_POST['cont']['name']
654
-	* @param string $show_c name/index for name expansion
655
-	* @param string $show_row name/index for name expansion
656
-	* @return string the generated HTML
657
-	*/
639
+	 * creates HTML from an eTemplate
640
+	 *
641
+	 * This is done by calling show_cell for each cell in the form. show_cell itself
642
+	 * calls show recursivly for each included eTemplate.
643
+	 * You could use it in the UI-layer of an app, just make shure to call process_show !!!
644
+	 * This is intended as internal function and should NOT be called by new app's direct,
645
+	 * as it deals with HTML and is so UI-dependent, use exec instead.
646
+	 *
647
+	 * @internal
648
+	 * @param array $content with content for the cells, keys are the names given in the cells/form elements
649
+	 * @param array $sel_options with options for the selectboxes, keys are the name of the selectbox
650
+	 * @param array $readonlys with names of cells/form-elements to be not allowed to change
651
+	 * 		This is to facilitate complex ACL's which denies access on field-level !!!
652
+	 * @param string $cname basename of names for form-elements, means index in $_POST
653
+	 * 		eg. $cname='cont', element-name = 'name' returned content in $_POST['cont']['name']
654
+	 * @param string $show_c name/index for name expansion
655
+	 * @param string $show_row name/index for name expansion
656
+	 * @return string the generated HTML
657
+	 */
658 658
 	function show($content,$sel_options='',$readonlys='',$cname='',$show_c=0,$show_row=0)
659 659
 	{
660 660
 		if (!$sel_options)
@@ -701,13 +701,13 @@  discard block
 block discarded – undo
701 701
 	}
702 702
 
703 703
 	/**
704
-	* Get the color of a category
705
-	*
706
-	* For multiple cats, the first with a color is used
707
-	*
708
-	* @param int/string $cats multiple comma-separated cat_id's
709
-	* @return string
710
-	*/
704
+	 * Get the color of a category
705
+	 *
706
+	 * For multiple cats, the first with a color is used
707
+	 *
708
+	 * @param int/string $cats multiple comma-separated cat_id's
709
+	 * @return string
710
+	 */
711 711
 	static function cats2color($cats)
712 712
 	{
713 713
 		static $cat2color;
@@ -740,26 +740,26 @@  discard block
 block discarded – undo
740 740
 	}
741 741
 
742 742
 	/**
743
-	* creates HTML from an eTemplate
744
-	*
745
-	* This is done by calling show_cell for each cell in the form. show_cell itself
746
-	* calls show recursivly for each included eTemplate.
747
-	* You can use it in the UI-layer of an app, just make shure to call process_show !!!
748
-	* This is intended as internal function and should NOT be called by new app's direct,
749
-	* as it deals with HTML and is so UI-dependent, use exec instead.
750
-	*
751
-	* @internal
752
-	* @param array $grid representing a grid
753
-	* @param array $content with content for the cells, keys are the names given in the cells/form elements
754
-	* @param array $readonlys with names of cells/form-elements to be not allowed to change
755
-	* 		This is to facilitate complex ACL's which denies access on field-level !!!
756
-	* @param string $cname basename of names for form-elements, means index in $_POST
757
-	*		eg. $cname='cont', element-name = 'name' returned content in $_POST['cont']['name']
758
-	* @param string $show_c name/index for name expansion
759
-	* @param string $show_row name/index for name expansion
760
-	* @param string $path path in the widget tree
761
-	* @return string the generated HTML
762
-	*/
743
+	 * creates HTML from an eTemplate
744
+	 *
745
+	 * This is done by calling show_cell for each cell in the form. show_cell itself
746
+	 * calls show recursivly for each included eTemplate.
747
+	 * You can use it in the UI-layer of an app, just make shure to call process_show !!!
748
+	 * This is intended as internal function and should NOT be called by new app's direct,
749
+	 * as it deals with HTML and is so UI-dependent, use exec instead.
750
+	 *
751
+	 * @internal
752
+	 * @param array $grid representing a grid
753
+	 * @param array $content with content for the cells, keys are the names given in the cells/form elements
754
+	 * @param array $readonlys with names of cells/form-elements to be not allowed to change
755
+	 * 		This is to facilitate complex ACL's which denies access on field-level !!!
756
+	 * @param string $cname basename of names for form-elements, means index in $_POST
757
+	 *		eg. $cname='cont', element-name = 'name' returned content in $_POST['cont']['name']
758
+	 * @param string $show_c name/index for name expansion
759
+	 * @param string $show_row name/index for name expansion
760
+	 * @param string $path path in the widget tree
761
+	 * @return string the generated HTML
762
+	 */
763 763
 	private function show_grid(&$grid,$content,$readonlys='',$cname='',$show_c=0,$show_row=0,$path='')
764 764
 	{
765 765
 		if (!$readonlys)
@@ -978,15 +978,15 @@  discard block
 block discarded – undo
978 978
 	}
979 979
 
980 980
 	/**
981
-	* build the name of a form-element from a basename and name
982
-	*
983
-	* name and basename can contain sub-indices in square bracets, eg. basename="base[basesub1][basesub2]"
984
-	* and name = "name[sub]" gives "base[basesub1][basesub2][name][sub]"
985
-	*
986
-	* @param string $cname basename
987
-	* @param string $name name
988
-	* @return string complete form-name
989
-	*/
981
+	 * build the name of a form-element from a basename and name
982
+	 *
983
+	 * name and basename can contain sub-indices in square bracets, eg. basename="base[basesub1][basesub2]"
984
+	 * and name = "name[sub]" gives "base[basesub1][basesub2][name][sub]"
985
+	 *
986
+	 * @param string $cname basename
987
+	 * @param string $name name
988
+	 * @return string complete form-name
989
+	 */
990 990
 	static function form_name($cname,$name)
991 991
 	{
992 992
 		if(is_object($name)) return '';
@@ -1005,13 +1005,13 @@  discard block
 block discarded – undo
1005 1005
 	}
1006 1006
 
1007 1007
 	/**
1008
-	* strip the prefix of a form-element from a form_name
1009
-	* This function removes the prefix of form_name().  It takes a name like base[basesub1][basesub2][name][sub]
1010
-	* and gives basesub1[basesub2][name][sub]
1011
-	*
1012
-	* @param string form_name
1013
-	* @return string name without prefix
1014
-	*/
1008
+	 * strip the prefix of a form-element from a form_name
1009
+	 * This function removes the prefix of form_name().  It takes a name like base[basesub1][basesub2][name][sub]
1010
+	 * and gives basesub1[basesub2][name][sub]
1011
+	 *
1012
+	 * @param string form_name
1013
+	 * @return string name without prefix
1014
+	 */
1015 1015
 	static private function template_name($form_name)
1016 1016
 	{
1017 1017
 		$parts = explode('[',str_replace(']','',$form_name));
@@ -1028,24 +1028,24 @@  discard block
 block discarded – undo
1028 1028
 	static private $class_conf = array('nmh' => 'th','nmr0' => 'row_on','nmr1' => 'row_off');
1029 1029
 
1030 1030
 	/**
1031
-	* generates HTML for one widget (input-field / cell)
1032
-	*
1033
-	* calls show to generate included eTemplates. Again only an INTERMAL function.
1034
-	*
1035
-	* @internal
1036
-	* @param array $cell with data of the cell: name, type, ...
1037
-	* @param array $content with content for the cells, keys are the names given in the cells/form elements
1038
-	* @param array $readonlys with names of cells/form-elements to be not allowed to change
1039
-	* 		This is to facilitate complex ACL's which denies access on field-level !!!
1040
-	* @param string $cname basename of names for form-elements, means index in $_POST
1041
-	*		eg. $cname='cont', element-name = 'name' returned content in $_POST['cont']['name']
1042
-	* @param string $show_c name/index for name expansion
1043
-	* @param string $show_row name/index for name expansion
1044
-	* @param string &$span on return number of cells to span or 'all' for the rest (only used for grids)
1045
-	* @param string &$class on return the css class of the cell, to be set in the <td> tag
1046
-	* @param string $path path in the widget tree
1047
-	* @return string the generated HTML
1048
-	*/
1031
+	 * generates HTML for one widget (input-field / cell)
1032
+	 *
1033
+	 * calls show to generate included eTemplates. Again only an INTERMAL function.
1034
+	 *
1035
+	 * @internal
1036
+	 * @param array $cell with data of the cell: name, type, ...
1037
+	 * @param array $content with content for the cells, keys are the names given in the cells/form elements
1038
+	 * @param array $readonlys with names of cells/form-elements to be not allowed to change
1039
+	 * 		This is to facilitate complex ACL's which denies access on field-level !!!
1040
+	 * @param string $cname basename of names for form-elements, means index in $_POST
1041
+	 *		eg. $cname='cont', element-name = 'name' returned content in $_POST['cont']['name']
1042
+	 * @param string $show_c name/index for name expansion
1043
+	 * @param string $show_row name/index for name expansion
1044
+	 * @param string &$span on return number of cells to span or 'all' for the rest (only used for grids)
1045
+	 * @param string &$class on return the css class of the cell, to be set in the <td> tag
1046
+	 * @param string $path path in the widget tree
1047
+	 * @return string the generated HTML
1048
+	 */
1049 1049
 	private function show_cell(&$cell,$content,$readonlys,$cname,$show_c,$show_row,&$span,&$class,$path='')
1050 1050
 	{
1051 1051
 		if ($this->debug && (is_int($this->debug) && $this->debug >= 3 || $this->debug == $cell['type']))
@@ -2063,13 +2063,13 @@  discard block
 block discarded – undo
2063 2063
 	}
2064 2064
 
2065 2065
 	/**
2066
-	* Retrive options for selectboxes and similar widgets (eg. the tree)
2067
-	*
2068
-	* @param array $cell
2069
-	* @param string $name
2070
-	* @param array $content=array();
2071
-	* @return array
2072
-	*/
2066
+	 * Retrive options for selectboxes and similar widgets (eg. the tree)
2067
+	 *
2068
+	 * @param array $cell
2069
+	 * @param string $name
2070
+	 * @param array $content=array();
2071
+	 * @return array
2072
+	 */
2073 2073
 	function _sel_options($cell,$name,$content=array())
2074 2074
 	{
2075 2075
 		$sels = array();
@@ -2129,18 +2129,18 @@  discard block
 block discarded – undo
2129 2129
 	}
2130 2130
 
2131 2131
 	/**
2132
-	* Resolve javascript pseudo functions in onclick or onchange:
2133
-	* - egw::link('$l','$p') calls $egw->link($l,$p)
2134
-	* - form::name('name') returns expanded name/id taking into account the name at that point of the template hierarchy
2135
-	* - egw::lang('Message ...') translate the message
2136
-	* - confirm('message') translates 'message' and adds a '?' if not present
2137
-	* - window.open() replaces it with egw(window).openPopup()
2138
-	* - xajax_doXMLHTTP('etemplate. replace ajax calls in widgets with special handler not requiring etemplate run rights
2139
-	*
2140
-	* @param string $on onclick, onchange, ... action
2141
-	* @param string $cname name-prefix / name-space
2142
-	* @return string
2143
-	*/
2132
+	 * Resolve javascript pseudo functions in onclick or onchange:
2133
+	 * - egw::link('$l','$p') calls $egw->link($l,$p)
2134
+	 * - form::name('name') returns expanded name/id taking into account the name at that point of the template hierarchy
2135
+	 * - egw::lang('Message ...') translate the message
2136
+	 * - confirm('message') translates 'message' and adds a '?' if not present
2137
+	 * - window.open() replaces it with egw(window).openPopup()
2138
+	 * - xajax_doXMLHTTP('etemplate. replace ajax calls in widgets with special handler not requiring etemplate run rights
2139
+	 *
2140
+	 * @param string $on onclick, onchange, ... action
2141
+	 * @param string $cname name-prefix / name-space
2142
+	 * @return string
2143
+	 */
2144 2144
 	function js_pseudo_funcs($on,$cname)
2145 2145
 	{
2146 2146
 		if (strpos($on,'::') !== false)	// avoid the expensive regular expresions, for performance reasons
@@ -2208,11 +2208,11 @@  discard block
 block discarded – undo
2208 2208
 	}
2209 2209
 
2210 2210
 	/**
2211
-	* applies stripslashes recursivly on each element of an array
2212
-	*
2213
-	* @param array &$var
2214
-	* @return array
2215
-	*/
2211
+	 * applies stripslashes recursivly on each element of an array
2212
+	 *
2213
+	 * @param array &$var
2214
+	 * @return array
2215
+	 */
2216 2216
 	static function array_stripslashes($var)
2217 2217
 	{
2218 2218
 		if (!is_array($var))
@@ -2227,18 +2227,18 @@  discard block
 block discarded – undo
2227 2227
 	}
2228 2228
 
2229 2229
 	/**
2230
-	* makes necessary adjustments on $_POST after a eTemplate / form gots submitted
2231
-	*
2232
-	* This is only an internal function, dont call it direct use only exec
2233
-	* Process_show uses a list of input-fields/widgets generated by show.
2234
-	*
2235
-	* @internal
2236
-	* @param array $content $_POST[$cname], on return the adjusted content
2237
-	* @param array $to_process list of widgets/form-fields to process
2238
-	* @param string $cname='' basename of our returnt content (same as in call to show)
2239
-	* @param string $_type='regular' type of request
2240
-	* @return array with validation errors
2241
-	*/
2230
+	 * makes necessary adjustments on $_POST after a eTemplate / form gots submitted
2231
+	 *
2232
+	 * This is only an internal function, dont call it direct use only exec
2233
+	 * Process_show uses a list of input-fields/widgets generated by show.
2234
+	 *
2235
+	 * @internal
2236
+	 * @param array $content $_POST[$cname], on return the adjusted content
2237
+	 * @param array $to_process list of widgets/form-fields to process
2238
+	 * @param string $cname='' basename of our returnt content (same as in call to show)
2239
+	 * @param string $_type='regular' type of request
2240
+	 * @return array with validation errors
2241
+	 */
2242 2242
 	function process_show(&$content,$to_process,$cname='',$_type='regular')
2243 2243
 	{
2244 2244
 		if (!isset($content) || !is_array($content) || !is_array($to_process))
@@ -2480,12 +2480,12 @@  discard block
 block discarded – undo
2480 2480
 	}
2481 2481
 
2482 2482
 	/**
2483
-	* Sets a validation error, to be displayed in the next exec
2484
-	*
2485
-	* @param string $name (complete) name of the widget causing the error
2486
-	* @param string|boolean $error error-message already translated or false to reset all existing error for given name
2487
-	* @param string $cname=null set it to '', if the name is already a form-name, defaults to self::$name_vars
2488
-	*/
2483
+	 * Sets a validation error, to be displayed in the next exec
2484
+	 *
2485
+	 * @param string $name (complete) name of the widget causing the error
2486
+	 * @param string|boolean $error error-message already translated or false to reset all existing error for given name
2487
+	 * @param string $cname=null set it to '', if the name is already a form-name, defaults to self::$name_vars
2488
+	 */
2489 2489
 	static function set_validation_error($name,$error,$cname=null)
2490 2490
 	{
2491 2491
 		if (is_null($cname)) $cname = self::$name_vars;
Please login to merge, or discard this patch.
Spacing   +458 added lines, -460 removed lines patch added patch discarded remove patch
@@ -58,26 +58,26 @@  discard block
 block discarded – undo
58 58
 	*
59 59
 	* @public string
60 60
 	*/
61
-	static $name_form='eTemplate';
61
+	static $name_form = 'eTemplate';
62 62
 	/**
63 63
 	* Used form-names in this request
64 64
 	*
65 65
 	* @public array
66 66
 	*/
67
-	static $name_forms=array();
67
+	static $name_forms = array();
68 68
 	/**
69 69
 	* Basename of the variables (content) in $_POST and id's, usually 'exec',
70 70
 	* if there's not more then one eTemplate on the page (then it will be exec, exec2, exec3, ...
71 71
 	*
72 72
 	* @public string
73 73
 	*/
74
-	static $name_vars='exec';
74
+	static $name_vars = 'exec';
75 75
 	/**
76 76
 	* Are we running as sitemgr module or not
77 77
 	*
78 78
 	* @public boolean
79 79
 	*/
80
-	public $sitemgr=false;
80
+	public $sitemgr = false;
81 81
 	/**
82 82
 	 * Javascript to be called, when a widget get's double-clicked (used only by the editor)
83 83
 	 * A '%p' gets replace with the colon ':' separated template-name, -version and path of the clicked widget.
@@ -134,22 +134,22 @@  discard block
 block discarded – undo
134 134
 	* @param string $name of etemplate or array with name and other keys
135 135
 	* @param string/array $load_via with keys of other etemplate to load in order to get $name
136 136
 	*/
137
-	function __construct($name='',$load_via='')
137
+	function __construct($name = '', $load_via = '')
138 138
 	{
139 139
 		// tell framework old eTemplate apps needs eval and inline javascript :(
140 140
 		egw_framework::csp_script_src_attrs(array('unsafe-eval', 'unsafe-inline'));
141 141
 
142
-		parent::__construct($name,$load_via);
142
+		parent::__construct($name, $load_via);
143 143
 
144 144
 		$this->sitemgr = isset($GLOBALS['Common_BO']) && is_object($GLOBALS['Common_BO']);
145 145
 
146
-		if (($this->innerWidth = (int) $_POST['innerWidth']))
146
+		if (($this->innerWidth = (int)$_POST['innerWidth']))
147 147
 		{
148
-			$GLOBALS['egw']->session->appsession('innerWidth','etemplate',$this->innerWidth);
148
+			$GLOBALS['egw']->session->appsession('innerWidth', 'etemplate', $this->innerWidth);
149 149
 		}
150
-		elseif (!($this->innerWidth = (int) $GLOBALS['egw']->session->appsession('innerWidth','etemplate')))
150
+		elseif (!($this->innerWidth = (int)$GLOBALS['egw']->session->appsession('innerWidth', 'etemplate')))
151 151
 		{
152
-			$this->innerWidth = 1018;	// default width for an assumed screen-resolution of 1024x768
152
+			$this->innerWidth = 1018; // default width for an assumed screen-resolution of 1024x768
153 153
 		}
154 154
 		//echo "<p>_POST[innerWidth]='$_POST[innerWidth]', innerWidth=$this->innerWidth</p>\n";
155 155
 	}
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	*
163 163
 	* @param string/array $params url or array with get-params incl. menuaction
164 164
 	*/
165
-	static function location($params='')
165
+	static function location($params = '')
166 166
 	{
167 167
 		egw::redirect_link(is_array($params) ? '/index.php' : $params,
168 168
 			is_array($params) ? $params : '');
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	* @param array $changes change made in the last call if looping, only used internaly by process_exec
197 197
 	* @return string html for $output_mode == 1, else nothing
198 198
 	*/
199
-	function exec($method,$content,$sel_options='',$readonlys='',$preserv='',$output_mode=0,$ignore_validation='',$changes='')
199
+	function exec($method, $content, $sel_options = '', $readonlys = '', $preserv = '', $output_mode = 0, $ignore_validation = '', $changes = '')
200 200
 	{
201 201
 		if (!$sel_options)
202 202
 		{
@@ -220,19 +220,19 @@  discard block
 block discarded – undo
220 220
 		}
221 221
 		if ($GLOBALS['egw_info']['flags']['currentapp'] != 'etemplate')
222 222
 		{
223
-			translation::add_app('etemplate');	// some extensions have own texts
223
+			translation::add_app('etemplate'); // some extensions have own texts
224 224
 		}
225 225
 		// use different form-names to allows multiple eTemplates in one page, eg. addressbook-view
226 226
 		self::$name_form = 'eTemplate';
227
-		if (in_array(self::$name_form,self::$name_forms))
227
+		if (in_array(self::$name_form, self::$name_forms))
228 228
 		{
229
-			self::$name_form .= 1+count(self::$name_forms);
230
-			self::$name_vars .= 1+count(self::$name_forms);
229
+			self::$name_form .= 1 + count(self::$name_forms);
230
+			self::$name_vars .= 1 + count(self::$name_forms);
231 231
 		}
232 232
 		self::$name_forms[] = self::$name_form;
233 233
 
234 234
 		self::$request = etemplate_request::read();
235
-		self::$request->output_mode = $output_mode;	// let extensions "know" they are run eg. in a popup
235
+		self::$request->output_mode = $output_mode; // let extensions "know" they are run eg. in a popup
236 236
 		self::$request->readonlys = $readonlys;
237 237
 		self::$request->content = $content;
238 238
 		self::$request->changes = $changes;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 		// tell html5 form validation NOT to validate
246 246
 		if ($ignore_validation) self::$form_options .= ' novalidate="novalidate"';
247 247
 
248
-		if((int) $output_mode == 3)
248
+		if ((int)$output_mode == 3)
249 249
 		{
250 250
 			self::$styles_included[$this->name] = True;
251 251
 			return "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n"
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 				."<body>\n".$this->show($content)."\n</body>\n</html>";
254 254
 		}
255 255
 
256
-		$html = $this->show(self::complete_array_merge($content,$changes),$sel_options,$readonlys,self::$name_vars);
256
+		$html = $this->show(self::complete_array_merge($content, $changes), $sel_options, $readonlys, self::$name_vars);
257 257
 
258 258
 		self::$request->java_script_from_flags = $GLOBALS['egw_info']['flags']['java_script'];
259 259
 		self::$request->java_script_body_tags = array(
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 		self::$request->include_xajax = $GLOBALS['egw_info']['flags']['include_xajax'];
266 266
 
267 267
 		// check if application of template has a app.js file --> load it
268
-		list($app) = explode('.',$this->name);
268
+		list($app) = explode('.', $this->name);
269 269
 		if (file_exists(EGW_SERVER_ROOT.'/'.$app.'/js/app.js'))
270 270
 		{
271
-			egw_framework::validate_file('.','app',$app,false);
271
+			egw_framework::validate_file('.', 'app', $app, false);
272 272
 		}
273 273
 
274 274
 		if (!$this->sitemgr)
@@ -282,12 +282,12 @@  discard block
 block discarded – undo
282 282
 		if (self::$request->output_mode == -1) self::$request->output_mode = 0;
283 283
 		self::$request->template = $this->as_array(2);
284 284
 
285
-		$html = html::form(html::input('etemplate_exec_id',self::$request->id(),'hidden',' id="etemplate_exec_id"').$html.
285
+		$html = html::form(html::input('etemplate_exec_id', self::$request->id(), 'hidden', ' id="etemplate_exec_id"').$html.
286 286
 			html::input_hidden(array(
287 287
 				'submit_button' => '',
288 288
 				'innerWidth'    => '',
289
-			),'',false),array(),$this->sitemgr ? '' : '/etemplate/process_exec.php?menuaction='.$method,
290
-			'',self::$name_form,self::$form_options.
289
+			), '', false), array(), $this->sitemgr ? '' : '/etemplate/process_exec.php?menuaction='.$method,
290
+			'', self::$name_form, self::$form_options.
291 291
 			// dont set the width of popups!
292 292
 			($output_mode != 0 ? '' : ' onsubmit="this.innerWidth.value=window.innerWidth ? window.innerWidth : document.body.clientWidth;"'));
293 293
 			//echo "to_process="; _debug_array(self::$request->to_process);
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 			// support the old global var, in case old apps like 1.6 infolog use it
301 301
 			if (isset($GLOBALS['egw_info']['etemplate']['hooked'])) self::$hooked = $GLOBALS['egw_info']['etemplate']['hooked'];
302 302
 
303
-			if (!@self::$hooked && (int) $output_mode != 1 && (int) $output_mode != -1)	// not just returning the html
303
+			if (!@self::$hooked && (int)$output_mode != 1 && (int)$output_mode != -1)	// not just returning the html
304 304
 			{
305 305
 				if ($GLOBALS['egw_info']['flags']['currentapp'] != 'etemplate')
306 306
 				{
@@ -308,17 +308,17 @@  discard block
 block discarded – undo
308 308
 				}
309 309
 			}
310 310
 			// saving the etemplate content for other hooked etemplate apps (atm. infolog hooked into addressbook)
311
-			self::$previous_content =& $html;
311
+			self::$previous_content = & $html;
312 312
 		}
313 313
 		//echo '<p>'.__METHOD__."($method,...) after show: sitemgr=$this->sitemgr, hooked=".(int)$hooked.", output_mode=$output_mode</p>\n";
314 314
 
315
-		if (!$this->sitemgr && (int) $output_mode != 1 && (int) $output_mode != -1)	// NOT returning html
315
+		if (!$this->sitemgr && (int)$output_mode != 1 && (int)$output_mode != -1)	// NOT returning html
316 316
 		{
317 317
 			if (!@self::$hooked)
318 318
 			{
319 319
 				// let framework know, if we are a popup or not ('popup' not true, which is allways used by index.php!)
320 320
 				$GLOBALS['egw_info']['flags']['nonavbar'] = $output_mode == 2 ? 'popup' : false;
321
-				if((int) $output_mode != 2)
321
+				if ((int)$output_mode != 2)
322 322
 				{
323 323
 					echo $GLOBALS['egw']->framework->navbar();
324 324
 				}
@@ -332,22 +332,22 @@  discard block
 block discarded – undo
332 332
 						echo $manual->show(array());
333 333
 						unset($manual);
334 334
 						echo '<style type="text/css">.ajax-loader { position: absolute; right: 27px; top: 24px; display: none; }</style>'."\n";
335
-						echo '<div class="ajax-loader">'.html::image('phpgwapi','ajax-loader') . '</div>';
335
+						echo '<div class="ajax-loader">'.html::image('phpgwapi', 'ajax-loader').'</div>';
336 336
 					}
337 337
 				}
338 338
 			}
339 339
 			echo self::$hook_content.$html;
340 340
 
341
-			if (!self::$hooked && (!isset($_GET['menuaction']) || strpos($_SERVER['PHP_SELF'],'process_exec.php') !== false))
341
+			if (!self::$hooked && (!isset($_GET['menuaction']) || strpos($_SERVER['PHP_SELF'], 'process_exec.php') !== false))
342 342
 			{
343
-				if((int) $output_mode == 2)
343
+				if ((int)$output_mode == 2)
344 344
 				{
345 345
 					echo "</div>\n";
346 346
 				}
347 347
 				common::egw_footer();
348 348
 			}
349 349
 		}
350
-		if ($this->sitemgr || (int) $output_mode == 1 || (int) $output_mode == -1)	// return html
350
+		if ($this->sitemgr || (int)$output_mode == 1 || (int)$output_mode == -1)	// return html
351 351
 		{
352 352
 			return $html;
353 353
 		}
@@ -360,13 +360,13 @@  discard block
 block discarded – undo
360 360
 	* @param string $cname=null name-prefix, which need to be ignored, default self::$name_vars
361 361
 	* @return boolean true if there are not ignored validation errors, false otherwise
362 362
 	*/
363
-	static function validation_errors($ignore_validation='',$cname=null)
363
+	static function validation_errors($ignore_validation = '', $cname = null)
364 364
 	{
365 365
 		if (is_null($cname)) $cname = self::$name_vars;
366 366
 		//echo "<p>uiself::validation_errors('$ignore_validation','$cname') validation_error="; _debug_array(self::$validation_errors);
367 367
 		if (!$ignore_validation) return count(self::$validation_errors) > 0;
368 368
 
369
-		foreach(self::$validation_errors as $name => $error)
369
+		foreach (self::$validation_errors as $name => $error)
370 370
 		{
371 371
 			if (!self::ignore_validation_match($name, $ignore_validation))
372 372
 			{
@@ -386,10 +386,10 @@  discard block
 block discarded – undo
386 386
 	 * @param string $cname
387 387
 	 * @return boolean
388 388
 	 */
389
-	static function ignore_validation_match($form_name, $ignore_validation, $cname=null)
389
+	static function ignore_validation_match($form_name, $ignore_validation, $cname = null)
390 390
 	{
391 391
 		if (is_null($cname)) $cname = self::$name_vars;
392
-		if ($cname) $form_name = preg_replace('/^'.$cname.'\[([^\]]+)\](.*)$/','\\1\\2', $form_name);
392
+		if ($cname) $form_name = preg_replace('/^'.$cname.'\[([^\]]+)\](.*)$/', '\\1\\2', $form_name);
393 393
 
394 394
 		return empty($ignore_validation) ||
395 395
 			$ignore_validation[0] == '/' && preg_match($ignore_validation, $form_name) ||
@@ -408,11 +408,11 @@  discard block
 block discarded – undo
408 408
 	*
409 409
 	* @return mixed false if no sessiondata and $this->sitemgr, else the returnvalue of exec of the method-calls
410 410
 	*/
411
-	function process_exec($etemplate_exec_id = null, $submit_button = null, $exec = null, $type = 'regular' )
411
+	function process_exec($etemplate_exec_id = null, $submit_button = null, $exec = null, $type = 'regular')
412 412
 	{
413
-		if(!$etemplate_exec_id) $etemplate_exec_id = $_POST['etemplate_exec_id'];
414
-		if(!$submit_button) $submit_button = $_POST['submit_button'];
415
-		if(!$exec) $exec = $_POST;
413
+		if (!$etemplate_exec_id) $etemplate_exec_id = $_POST['etemplate_exec_id'];
414
+		if (!$submit_button) $submit_button = $_POST['submit_button'];
415
+		if (!$exec) $exec = $_POST;
416 416
 
417 417
 		//echo "process_exec: _POST ="; _debug_array($_POST);
418 418
 		if (!$etemplate_exec_id || !(self::$request = etemplate_request::read($etemplate_exec_id)))
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 				// check if we have a failed upload, because user tried to uploaded a file
430 430
 				// bigger then php.ini setting post_max_size
431 431
 				// in that case the webserver calls PHP with $_POST === array()
432
-				if (substr($_SERVER['CONTENT_TYPE'],0,19) == 'multipart/form-data' &&
432
+				if (substr($_SERVER['CONTENT_TYPE'], 0, 19) == 'multipart/form-data' &&
433 433
 					$_SERVER['CONTENT_LENGTH'] > self::km2int(ini_get('post_max_size')))
434 434
 				{
435 435
 					$redirect['failed_upload'] = 1;
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 		self::$name_vars = self::$request->name_vars;
445 445
 		if (isset($submit_button) && !empty($submit_button))
446 446
 		{
447
-			self::set_array($exec,$submit_button,'pressed');
447
+			self::set_array($exec, $submit_button, 'pressed');
448 448
 		}
449 449
 		$content = $exec[self::$name_vars];
450 450
 		if (!is_array($content))
@@ -455,35 +455,35 @@  discard block
 block discarded – undo
455 455
 		//echo "process_exec($this->name) content ="; _debug_array($content);
456 456
 		if ($GLOBALS['egw_info']['flags']['currentapp'] != 'etemplate')
457 457
 		{
458
-			$GLOBALS['egw']->translation->add_app('etemplate');	// some extensions have own texts
458
+			$GLOBALS['egw']->translation->add_app('etemplate'); // some extensions have own texts
459 459
 		}
460
-		$this->process_show($content,self::$request->to_process,self::$name_vars,$type);
460
+		$this->process_show($content, self::$request->to_process, self::$name_vars, $type);
461 461
 
462 462
 		self::$loop |= !$this->canceled && $this->button_pressed &&
463
-			$this->validation_errors(self::$request->ignore_validation);	// set by process_show
463
+			$this->validation_errors(self::$request->ignore_validation); // set by process_show
464 464
 
465 465
 		// If a tab has an error on it, change to that tab
466
-		foreach(self::$validation_errors as $form_name => $msg)
466
+		foreach (self::$validation_errors as $form_name => $msg)
467 467
 		{
468 468
 			$name = $this->template_name($form_name);
469 469
 			if (!$this->get_widget_by_name($name))
470 470
 			{
471
-				foreach($this->get_widgets_by_type('tab') as $widget)
471
+				foreach ($this->get_widgets_by_type('tab') as $widget)
472 472
 				{
473 473
 					$tab_name = $tabs = $widget['name'];
474
-					if (strpos($tabs,'=') !== false) list($tab_name,$tabs) = explode('=',$tabs,2);
475
-					foreach(explode('|',$tabs) as $tab)
474
+					if (strpos($tabs, '=') !== false) list($tab_name, $tabs) = explode('=', $tabs, 2);
475
+					foreach (explode('|', $tabs) as $tab)
476 476
 					{
477
-						if (strpos('.',$tab) === false) $tab = $this->name.'.'.$tab;
477
+						if (strpos('.', $tab) === false) $tab = $this->name.'.'.$tab;
478 478
 						$tab_tpl = new etemplate($tab);
479 479
 						if ($tab_tpl->get_widget_by_name($name))
480 480
 						{
481 481
 							$content[$tab_name] = $tab;
482 482
 							break 3;
483 483
 						}
484
-						elseif($name[0] == '#')
484
+						elseif ($name[0] == '#')
485 485
 						{
486
-							foreach($tab_tpl->get_widgets_by_type('customfields') as $cf_widget)
486
+							foreach ($tab_tpl->get_widgets_by_type('customfields') as $cf_widget)
487 487
 							{
488 488
 								if (empty($cf_widget['name']))
489 489
 								{
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 
502 502
 		//echo "process_exec($this->name) process_show(content) ="; _debug_array($content);
503 503
 		//echo "process_exec($this->name) session_data[changes] ="; _debug_array(self::$request->changes);
504
-		$content = self::complete_array_merge(self::$request->changes,$content);
504
+		$content = self::complete_array_merge(self::$request->changes, $content);
505 505
 		//echo "process_exec($this->name) merge(changes,content) ="; _debug_array($content);
506 506
 
507 507
 		if (self::$loop && $type == 'regular')	// only loop for regular (not ajax_submit) requests
@@ -512,13 +512,13 @@  discard block
 block discarded – undo
512 512
 				$GLOBALS['egw_info']['flags']['currentapp'] = self::$hook_app = self::$request->hook_app;
513 513
 
514 514
 				// Prevent previous content form names from being used again in exec()
515
-				preg_match_all('/<form .+name="('. self::$name_form . '[\d]*)"/',self::$request->hooked, $used);
516
-				if(is_array($used[1]) && count($used[1]))
515
+				preg_match_all('/<form .+name="('.self::$name_form.'[\d]*)"/', self::$request->hooked, $used);
516
+				if (is_array($used[1]) && count($used[1]))
517 517
 				{
518 518
 					self::$name_forms += $used[1];
519 519
 				}
520 520
 			}
521
-			if(self::$request->include_xajax) $GLOBALS['egw_info']['flags']['include_xajax'] = true;
521
+			if (self::$request->include_xajax) $GLOBALS['egw_info']['flags']['include_xajax'] = true;
522 522
 
523 523
 			if (!empty(self::$request->app_header))
524 524
 			{
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 			{
531 531
 				foreach (self::$request->java_script_body_tags as $tag => $code)
532 532
 				{
533
-					call_user_func('egw_framework::set_'.$tag,$code);
533
+					call_user_func('egw_framework::set_'.$tag, $code);
534 534
 				}
535 535
 			}
536 536
 			if (is_array(self::$request->java_script_files))
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 				$files = egw_framework::js_files();
539 539
 				if (is_array($files))
540 540
 				{
541
-					$files = array_unique(array_merge($files,self::$request->java_script_files));
541
+					$files = array_unique(array_merge($files, self::$request->java_script_files));
542 542
 				}
543 543
 				else
544 544
 				{
@@ -548,15 +548,15 @@  discard block
 block discarded – undo
548 548
 			}
549 549
 
550 550
 			//echo "<p>process_exec($this->name): <font color=red>loop is set</font>, content=</p>\n"; _debug_array(self::complete_array_merge(self::$request->content,$content));
551
-			return $this->exec(self::$request->method,self::complete_array_merge(self::$request->content,$content),
552
-				self::$request->sel_options,self::$request->readonlys,self::$request->preserv,
553
-				self::$request->output_mode,self::$request->ignore_validation,$content);
551
+			return $this->exec(self::$request->method, self::complete_array_merge(self::$request->content, $content),
552
+				self::$request->sel_options, self::$request->readonlys, self::$request->preserv,
553
+				self::$request->output_mode, self::$request->ignore_validation, $content);
554 554
 		}
555 555
 		else
556 556
 		{
557 557
 			//echo "<p>process_exec($this->name): calling ".($type == 'regular' ? self::$request->method : $_GET['menuaction'])."</p>\n";
558 558
 			return ExecMethod($type == 'regular' ? self::$request->method : $_GET['menuaction'],
559
-				self::complete_array_merge(self::$request->preserv,$content));
559
+				self::complete_array_merge(self::$request->preserv, $content));
560 560
 		}
561 561
 	}
562 562
 
@@ -569,11 +569,11 @@  discard block
 block discarded – undo
569 569
 	 * @param int &$max_upload=null on return max. upload size in byte
570 570
 	 * @return string
571 571
 	 */
572
-	static function max_upload_size_message(&$max_upload=null)
572
+	static function max_upload_size_message(&$max_upload = null)
573 573
 	{
574 574
 		$upload_max_filesize = ini_get('upload_max_filesize');
575 575
 		$post_max_size = ini_get('post_max_size');
576
-		$max_upload = min(self::km2int($upload_max_filesize),self::km2int($post_max_size)-2800);
576
+		$max_upload = min(self::km2int($upload_max_filesize), self::km2int($post_max_size) - 2800);
577 577
 
578 578
 		return lang('Maximum size for uploads').': '.egw_vfs::hsize($max_upload).
579 579
 			" (php.ini: upload_max_filesize=$upload_max_filesize, post_max_size=$post_max_size)";
@@ -589,13 +589,13 @@  discard block
 block discarded – undo
589 589
 	{
590 590
 		if (!is_numeric($size))
591 591
 		{
592
-			switch(strtolower(substr($size,-1)))
592
+			switch (strtolower(substr($size, -1)))
593 593
 			{
594 594
 				case 'm':
595
-					$size = 1024*1024*(int)$size;
595
+					$size = 1024 * 1024 * (int)$size;
596 596
 					break;
597 597
 				case 'k':
598
-					$size = 1024*(int)$size;
598
+					$size = 1024 * (int)$size;
599 599
 					break;
600 600
 			}
601 601
 		}
@@ -623,9 +623,9 @@  discard block
 block discarded – undo
623 623
 		{
624 624
 			$content = array();
625 625
 		}
626
-		$this->process_show($content,$request->to_process,self::$name_vars);
626
+		$this->process_show($content, $request->to_process, self::$name_vars);
627 627
 
628
-		return self::complete_array_merge($request->preserv,$content);
628
+		return self::complete_array_merge($request->preserv, $content);
629 629
 	}
630 630
 
631 631
 	/**
@@ -655,20 +655,20 @@  discard block
 block discarded – undo
655 655
 	* @param string $show_row name/index for name expansion
656 656
 	* @return string the generated HTML
657 657
 	*/
658
-	function show($content,$sel_options='',$readonlys='',$cname='',$show_c=0,$show_row=0)
658
+	function show($content, $sel_options = '', $readonlys = '', $cname = '', $show_c = 0, $show_row = 0)
659 659
 	{
660 660
 		if (!$sel_options)
661 661
 		{
662 662
 			$sel_options = array();
663 663
 		}
664 664
 		// make it globaly availible for show_cell and show_grid, or extensions
665
-		$this->sel_options =& $sel_options;
665
+		$this->sel_options = & $sel_options;
666 666
 
667 667
 		if (!$readonlys)
668 668
 		{
669 669
 			$readonlys = array();
670 670
 		}
671
-		if (++$this->already_showed > 1) return '';	// prefens infinit self-inclusion
671
+		if (++$this->already_showed > 1) return ''; // prefens infinit self-inclusion
672 672
 
673 673
 		if (is_int($this->debug) && $this->debug >= 1 || $this->name && $this->debug == $this->name)
674 674
 		{
@@ -677,12 +677,12 @@  discard block
 block discarded – undo
677 677
 		}
678 678
 		if (!is_array($content))
679 679
 		{
680
-			$content = array();	// happens if incl. template has no content
680
+			$content = array(); // happens if incl. template has no content
681 681
 		}
682 682
 		// make the content availible as class-public for extensions
683
-		$this->content =& $content;
683
+		$this->content = & $content;
684 684
 
685
-		$html = "\n\n<!-- BEGIN eTemplate $this->name -->\n<div id=\"".str_replace('"','&quot;',$this->name)."\">\n\n";
685
+		$html = "\n\n<!-- BEGIN eTemplate $this->name -->\n<div id=\"".str_replace('"', '&quot;', $this->name)."\">\n\n";
686 686
 		if (!self::$styles_included[$this->name])
687 687
 		{
688 688
 			self::$styles_included[$this->name] = True;
@@ -691,11 +691,11 @@  discard block
 block discarded – undo
691 691
 		$path = '/';
692 692
 		foreach ($this->children as $n => $child)
693 693
 		{
694
-			$h = $this->show_cell($child,$content,$readonlys,$cname,$show_c,$show_row,$nul,$class,$path.$n);
695
-			$html .= $class || $child['align'] ? html::div($h,html::formatOptions(array(
694
+			$h = $this->show_cell($child, $content, $readonlys, $cname, $show_c, $show_row, $nul, $class, $path.$n);
695
+			$html .= $class || $child['align'] ? html::div($h, html::formatOptions(array(
696 696
 				$class,
697 697
 				$child['align'],
698
-			),'class,align')) : $h;
698
+			), 'class,align')) : $h;
699 699
 		}
700 700
 		return $html."\n</div>\n<!-- END eTemplate $this->name -->\n\n";
701 701
 	}
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 		static $cat2color;
714 714
 
715 715
 		// ACL check
716
-		$cats = $GLOBALS['egw']->categories->check_list(EGW_ACL_READ,$cats);
716
+		$cats = $GLOBALS['egw']->categories->check_list(EGW_ACL_READ, $cats);
717 717
 
718 718
 		if (!$cats) return null;
719 719
 
@@ -722,13 +722,13 @@  discard block
 block discarded – undo
722 722
 			return $cat2color[$cats];
723 723
 		}
724 724
 
725
-		foreach(explode(',',$cats) as $cat)
725
+		foreach (explode(',', $cats) as $cat)
726 726
 		{
727 727
 			if (isset($cat2color[$cat]))
728 728
 			{
729 729
 				return $cat2color[$cat];
730 730
 			}
731
-			$data = categories::id2name($cat,'data');
731
+			$data = categories::id2name($cat, 'data');
732 732
 
733 733
 			if (is_array($data) && ($color = $data['color']))
734 734
 			{
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 	* @param string $path path in the widget tree
761 761
 	* @return string the generated HTML
762 762
 	*/
763
-	private function show_grid(&$grid,$content,$readonlys='',$cname='',$show_c=0,$show_row=0,$path='')
763
+	private function show_grid(&$grid, $content, $readonlys = '', $cname = '', $show_c = 0, $show_row = 0, $path = '')
764 764
 	{
765 765
 		if (!$readonlys)
766 766
 		{
@@ -773,11 +773,11 @@  discard block
 block discarded – undo
773 773
 		}
774 774
 		if (!is_array($content))
775 775
 		{
776
-			$content = array();	// happens if incl. template has no content
776
+			$content = array(); // happens if incl. template has no content
777 777
 		}
778 778
 		$content += array(	// for var-expansion in names in show_cell
779 779
 			'.c' => $show_c,
780
-			'.col' => $this->num2chrs($show_c-1),
780
+			'.col' => $this->num2chrs($show_c - 1),
781 781
 			'.row' => $show_row
782 782
 		);
783 783
 		$rows = array();
@@ -795,57 +795,57 @@  discard block
 block discarded – undo
795 795
 		$row_id = $content['_row_id'];
796 796
 
797 797
 		$max_cols = $grid['cols'];
798
-		for ($r = 0; $row = 1+$r /*list($row,$cols) = each($data)*/; ++$r)
798
+		for ($r = 0; $row = 1 + $r /*list($row,$cols) = each($data)*/; ++$r)
799 799
 		{
800 800
 			if (!(list($r_key) = each($data)))	// no further row
801 801
 			{
802
-				if (!(($this->autorepeat_idx($cols['A'],0,$r,$idx,$idx_cname,false,$content) && $idx_cname) ||
803
-						(in_array($cols['A']['type'], array('vbox','hbox','box')) && $this->autorepeat_idx($cols['A'][1],0,$r,$idx,$idx_cname,false,$content) && $idx_cname) ||
804
-					($this->autorepeat_idx($cols['B'],1,$r,$idx,$idx_cname,false,$content) && $idx_cname)) ||
805
-					!$this->isset_array($content,$idx_cname))
802
+				if (!(($this->autorepeat_idx($cols['A'], 0, $r, $idx, $idx_cname, false, $content) && $idx_cname) ||
803
+						(in_array($cols['A']['type'], array('vbox', 'hbox', 'box')) && $this->autorepeat_idx($cols['A'][1], 0, $r, $idx, $idx_cname, false, $content) && $idx_cname) ||
804
+					($this->autorepeat_idx($cols['B'], 1, $r, $idx, $idx_cname, false, $content) && $idx_cname)) ||
805
+					!$this->isset_array($content, $idx_cname))
806 806
 				{
807
-					break;                     	// no auto-row-repeat
807
+					break; // no auto-row-repeat
808 808
 				}
809 809
 			}
810 810
 			else
811 811
 			{
812 812
 				$cols = &$data[$r_key];
813
-				$part = '';	// '' = body-prefix
814
-				list($height,$disabled,$part) = explode(',',$opts["h$row"]);
813
+				$part = ''; // '' = body-prefix
814
+				list($height, $disabled, $part) = explode(',', $opts["h$row"]);
815 815
 				$class = $opts["c$row"];
816 816
 			}
817
-			if ($disabled != '' && $this->check_disabled($disabled,$content,$r))
817
+			if ($disabled != '' && $this->check_disabled($disabled, $content, $r))
818 818
 			{
819
-				continue;	// row is disabled
819
+				continue; // row is disabled
820 820
 			}
821
-			if ($part) $row = $part[0].$row;	// add part prefix
822
-			$rows[".$row"] .= html::formatOptions($height,'height');
823
-			list($cl) = explode(',',$class);
824
-			if ($cl == '@' || $cl && strpos($cl,'$') !== false)
821
+			if ($part) $row = $part[0].$row; // add part prefix
822
+			$rows[".$row"] .= html::formatOptions($height, 'height');
823
+			list($cl) = explode(',', $class);
824
+			if ($cl == '@' || $cl && strpos($cl, '$') !== false)
825 825
 			{
826
-				$cl = $this->expand_name($cl,0,$r,$content['.c'],$content['.row'],$content);
827
-				if (!$cl || preg_match('/(^| )([0-9,]+)( |$)/',$cl,$matches))
826
+				$cl = $this->expand_name($cl, 0, $r, $content['.c'], $content['.row'], $content);
827
+				if (!$cl || preg_match('/(^| )([0-9,]+)( |$)/', $cl, $matches))
828 828
 				{
829 829
 					if (($color = $this->cats2color($matches[2])))
830 830
 					{
831 831
 						$rows[".$row"] .= ' style="background-color: '.$color.';"';
832 832
 					}
833
-					$cl = str_replace($matches[2],'row',$cl);
833
+					$cl = str_replace($matches[2], 'row', $cl);
834 834
 				}
835 835
 			}
836
-			if ($cl == 'nmr' || substr($cl,0,3) == 'row')	// allow to have further classes behind row
836
+			if ($cl == 'nmr' || substr($cl, 0, 3) == 'row')	// allow to have further classes behind row
837 837
 			{
838
-				$cl = 'row_'.($nmr_alternate++ & 1 ? 'off' : 'on').substr($cl,3); // alternate color
838
+				$cl = 'row_'.($nmr_alternate++ & 1 ? 'off' : 'on').substr($cl, 3); // alternate color
839 839
 			}
840 840
 			$cl = isset(self::$class_conf[$cl]) ? self::$class_conf[$cl] : $cl;
841
-			$rows[".$row"] .= html::formatOptions($cl,'class');
842
-			$rows[".$row"] .= html::formatOptions($class,',valign');
841
+			$rows[".$row"] .= html::formatOptions($cl, 'class');
842
+			$rows[".$row"] .= html::formatOptions($class, ',valign');
843 843
 			// set row-id, if requested
844 844
 			if ($row_id && isset($content[$r][$row_id]))
845 845
 			{
846 846
 				$rows[".$row"] .= ' id="'.htmlspecialchars($content[$r][$row_id]).'"';
847 847
 			}
848
-			reset ($cols);
848
+			reset($cols);
849 849
 			$row_data = array();
850 850
 			for ($c = 0; True /*list($col,$cell) = each($cols)*/; ++$c)
851 851
 			{
@@ -856,18 +856,18 @@  discard block
 block discarded – undo
856 856
 					// otherwise the rows have a differen number of cells and it saved a lot checks
857 857
 					if ($c >= $max_cols)
858 858
 					{
859
-						if (!$this->autorepeat_idx($cell,$c,$r,$idx,$idx_cname,True,$content) ||
860
-							!$this->isset_array($content,$idx))
859
+						if (!$this->autorepeat_idx($cell, $c, $r, $idx, $idx_cname, True, $content) ||
860
+							!$this->isset_array($content, $idx))
861 861
 						{
862
-							break;	// no auto-col-repeat
862
+							break; // no auto-col-repeat
863 863
 						}
864
-						$max_cols = $c+1;
864
+						$max_cols = $c + 1;
865 865
 					}
866 866
 				}
867 867
 				else
868 868
 				{
869 869
 					$cell = $cols[$c_key];
870
-					list($col_width,$col_disabled) = explode(',',$opts[$col]);
870
+					list($col_width, $col_disabled) = explode(',', $opts[$col]);
871 871
 
872 872
 					if (!$cell['height'])	// if not set, cell-height = height of row
873 873
 					{
@@ -875,10 +875,10 @@  discard block
 block discarded – undo
875 875
 					}
876 876
 					if (!$cell['width'])	// if not set, cell-width = width of column or table
877 877
 					{
878
-						list($col_span) = explode(',',$cell['span']);
878
+						list($col_span) = explode(',', $cell['span']);
879 879
 						if ($col_span == 'all' && !$c)
880 880
 						{
881
-							list($cell['width']) = explode(',',$this->size);
881
+							list($cell['width']) = explode(',', $this->size);
882 882
 						}
883 883
 						else
884 884
 						{
@@ -886,50 +886,50 @@  discard block
 block discarded – undo
886 886
 						}
887 887
 					}
888 888
 				}
889
-				if ($col_disabled != '' && $this->check_disabled($col_disabled,$content,$r,$c))
889
+				if ($col_disabled != '' && $this->check_disabled($col_disabled, $content, $r, $c))
890 890
 				{
891
-					continue;	// col is disabled
891
+					continue; // col is disabled
892 892
 				}
893 893
 				$align_was = $cell['align'];
894
-				$row_data[$col] = $this->show_cell($cell,$content,$readonlys,$cname,$c,$r,$span,$cl,$path.'/'.$r_key.$c_key);
894
+				$row_data[$col] = $this->show_cell($cell, $content, $readonlys, $cname, $c, $r, $span, $cl, $path.'/'.$r_key.$c_key);
895 895
 
896 896
 				if ($row_data[$col] == '' && $this->rows == 1)
897 897
 				{
898
-					unset($row_data[$col]);	// omit empty/disabled cells if only one row
898
+					unset($row_data[$col]); // omit empty/disabled cells if only one row
899 899
 					continue;
900 900
 				}
901 901
 				if (strlen($cell['onclick']) > 1)
902 902
 				{
903 903
 					$onclick = $cell['onclick'];
904
-					if (strpos($onclick,'$') !== false || $onclick[0] == '@')
904
+					if (strpos($onclick, '$') !== false || $onclick[0] == '@')
905 905
 					{
906
-						$onclick = $this->expand_name($onclick,$c,$r,$content['.c'],$content['.row'],$content);
906
+						$onclick = $this->expand_name($onclick, $c, $r, $content['.c'], $content['.row'], $content);
907 907
 					}
908
-					$row_data[".$col"] .= ' onclick="'.$this->js_pseudo_funcs($onclick,$cname).'"' .self::get_id('',$cell['name'],$cell['id']);
908
+					$row_data[".$col"] .= ' onclick="'.$this->js_pseudo_funcs($onclick, $cname).'"'.self::get_id('', $cell['name'], $cell['id']);
909 909
 				}
910
-				$colspan = $span == 'all' ? $grid['cols']-$c : 0+$span;
910
+				$colspan = $span == 'all' ? $grid['cols'] - $c : 0 + $span;
911 911
 				if ($colspan > 1)
912 912
 				{
913 913
 					$row_data[".$col"] .= " colspan=\"$colspan\"";
914
-					for ($i = 1; $i < $colspan; ++$i,++$c)
914
+					for ($i = 1; $i < $colspan; ++$i, ++$c)
915 915
 					{
916
-						each($cols);	// skip next cell(s)
916
+						each($cols); // skip next cell(s)
917 917
 					}
918 918
 				}
919 919
 				else
920 920
 				{
921
-					list($width,$disable) = explode(',',$opts[$col]);
921
+					list($width, $disable) = explode(',', $opts[$col]);
922 922
 					if ($width)		// width only once for a non colspan cell
923 923
 					{
924 924
 						$row_data[".$col"] .= " width=\"$width\"";
925 925
 						$opts[$col] = "0,$disable";
926 926
 					}
927 927
 				}
928
-				$row_data[".$col"] .= html::formatOptions($cell['align']?$cell['align']:($align_was?$align_was:'left'),'align');
928
+				$row_data[".$col"] .= html::formatOptions($cell['align'] ? $cell['align'] : ($align_was ? $align_was : 'left'), 'align');
929 929
 				// allow to set further attributes in the tablecell, beside the class
930 930
 				if (is_array($cl))
931 931
 				{
932
-					foreach($cl as $attr => $val)
932
+					foreach ($cl as $attr => $val)
933 933
 					{
934 934
 						if ($attr != 'class' && $val)
935 935
 						{
@@ -939,33 +939,33 @@  discard block
 block discarded – undo
939 939
 					$cl = $cl['class'];
940 940
 				}
941 941
 				$cl = $this->expand_name(isset(self::$class_conf[$cl]) ? self::$class_conf[$cl] : $cl,
942
-					$c,$r,$show_c,$show_row,$content);
942
+					$c, $r, $show_c, $show_row, $content);
943 943
 				// else the class is set twice, in the table and the table-cell, which is not good for borders
944 944
 				if ($cl && $cell['type'] != 'template' && $cell['type'] != 'grid')
945 945
 				{
946
-					$row_data[".$col"] .= html::formatOptions($cl,'class');
946
+					$row_data[".$col"] .= html::formatOptions($cl, 'class');
947 947
 				}
948 948
 			}
949 949
 			$rows[$row] = $row_data;
950 950
 		}
951 951
 		if (!$rows) return '';
952 952
 
953
-		list($width,$height,,,,,$overflow) = $options = explode(',',$grid['size']);
953
+		list($width, $height,,,,, $overflow) = $options = explode(',', $grid['size']);
954 954
 		if ($overflow && $height)
955 955
 		{
956
-			$options[1] = '';	// set height in div only
956
+			$options[1] = ''; // set height in div only
957 957
 		}
958
-		$html = html::table($rows,html::formatOptions($options,'width,height,border,class,cellspacing,cellpadding').
959
-			html::formatOptions($grid['span'],',class').
960
-			html::formatOptions($grid['name']?self::form_name($cname,$grid['name']):'','id'));
958
+		$html = html::table($rows, html::formatOptions($options, 'width,height,border,class,cellspacing,cellpadding').
959
+			html::formatOptions($grid['span'], ',class').
960
+			html::formatOptions($grid['name'] ? self::form_name($cname, $grid['name']) : '', 'id'));
961 961
 
962 962
 		if (!empty($overflow))
963 963
 		{
964 964
 			if (is_numeric($height)) $height .= 'px';
965 965
 			if (is_numeric($width)) $width .= 'px';
966
-			if ($width == '100%') $overflow .= '; overflow-x: hidden';	// no horizontal scrollbar
967
-			$div_style=' style="'.($width?"width: $width; ":'').($height ? "height: $height; ":'')."overflow: $overflow;\"";
968
-			$html = html::div($html,$div_style);
966
+			if ($width == '100%') $overflow .= '; overflow-x: hidden'; // no horizontal scrollbar
967
+			$div_style = ' style="'.($width ? "width: $width; " : '').($height ? "height: $height; " : '')."overflow: $overflow;\"";
968
+			$html = html::div($html, $div_style);
969 969
 		}
970 970
 
971 971
 		// initialise egw_actions for nextmatch widget, if egwGridView_grid CSS class set
@@ -987,19 +987,19 @@  discard block
 block discarded – undo
987 987
 	* @param string $name name
988 988
 	* @return string complete form-name
989 989
 	*/
990
-	static function form_name($cname,$name)
990
+	static function form_name($cname, $name)
991 991
 	{
992
-		if(is_object($name)) return '';
992
+		if (is_object($name)) return '';
993 993
 
994
-		$name_parts = explode('[',str_replace(']','',$name));
994
+		$name_parts = explode('[', str_replace(']', '', $name));
995 995
 		if (!empty($cname))
996 996
 		{
997
-			array_unshift($name_parts,$cname);
997
+			array_unshift($name_parts, $cname);
998 998
 		}
999 999
 		$form_name = array_shift($name_parts);
1000 1000
 		if (count($name_parts))
1001 1001
 		{
1002
-			$form_name .= '['.implode('][',$name_parts).']';
1002
+			$form_name .= '['.implode('][', $name_parts).']';
1003 1003
 		}
1004 1004
 		return $form_name;
1005 1005
 	}
@@ -1014,18 +1014,18 @@  discard block
 block discarded – undo
1014 1014
 	*/
1015 1015
 	static private function template_name($form_name)
1016 1016
 	{
1017
-		$parts = explode('[',str_replace(']','',$form_name));
1017
+		$parts = explode('[', str_replace(']', '', $form_name));
1018 1018
 
1019
-		array_shift($parts);	// remove exec
1019
+		array_shift($parts); // remove exec
1020 1020
 
1021 1021
 		$name = array_shift($parts);
1022 1022
 
1023
-		if ($parts) $name .= '['.implode('][',$parts).']';
1023
+		if ($parts) $name .= '['.implode('][', $parts).']';
1024 1024
 
1025 1025
 		return $name;
1026 1026
 	}
1027 1027
 
1028
-	static private $class_conf = array('nmh' => 'th','nmr0' => 'row_on','nmr1' => 'row_off');
1028
+	static private $class_conf = array('nmh' => 'th', 'nmr0' => 'row_on', 'nmr1' => 'row_off');
1029 1029
 
1030 1030
 	/**
1031 1031
 	* generates HTML for one widget (input-field / cell)
@@ -1046,124 +1046,123 @@  discard block
 block discarded – undo
1046 1046
 	* @param string $path path in the widget tree
1047 1047
 	* @return string the generated HTML
1048 1048
 	*/
1049
-	private function show_cell(&$cell,$content,$readonlys,$cname,$show_c,$show_row,&$span,&$class,$path='')
1049
+	private function show_cell(&$cell, $content, $readonlys, $cname, $show_c, $show_row, &$span, &$class, $path = '')
1050 1050
 	{
1051 1051
 		if ($this->debug && (is_int($this->debug) && $this->debug >= 3 || $this->debug == $cell['type']))
1052 1052
 		{
1053 1053
 			echo "<p>etemplate.show_cell($this->name,name='${cell['name']}',type='${cell['type']}',cname='$cname',...,'$path')</p>\n";
1054 1054
 		}
1055
-		list($span) = explode(',',$cell['span']);	// evtl. overriten later for type template
1055
+		list($span) = explode(',', $cell['span']); // evtl. overriten later for type template
1056 1056
 
1057 1057
 		if ($cell['name'][0] == '@' && $cell['type'] != 'template')
1058 1058
 		{
1059
-			$cell['name'] = $this->get_array($content,$this->expand_name(substr($cell['name'],1),
1060
-				$show_c,$show_row,$content['.c'],$content['.row'],$content));
1059
+			$cell['name'] = $this->get_array($content, $this->expand_name(substr($cell['name'], 1),
1060
+				$show_c, $show_row, $content['.c'], $content['.row'], $content));
1061 1061
 		}
1062
-		$name = $this->expand_name($cell['name'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
1062
+		$name = $this->expand_name($cell['name'], $show_c, $show_row, $content['.c'], $content['.row'], $content);
1063 1063
 		// allow names like "tabs=one|two|three", which will be equal to just "tabs"
1064 1064
 		// eg. for tabs to use a name independent of the tabs contained
1065
-		if (is_string($name) && strpos($name,'=') !== false)
1065
+		if (is_string($name) && strpos($name, '=') !== false)
1066 1066
 		{
1067
-			list($name) = explode('=',$name);
1067
+			list($name) = explode('=', $name);
1068 1068
 		}
1069
-		$form_name = self::form_name($cname,$name);
1069
+		$form_name = self::form_name($cname, $name);
1070 1070
 
1071
-		$value = $this->get_array($content,$name);
1071
+		$value = $this->get_array($content, $name);
1072 1072
 
1073 1073
 		$options = '';
1074
-		if ($readonly = $cell['readonly'] && $readonlys[$name] !== false || 	// allow to overwrite readonly settings of a cell
1074
+		if ($readonly = $cell['readonly'] && $readonlys[$name] !== false || // allow to overwrite readonly settings of a cell
1075 1075
 			@$readonlys[$name] && !is_array($readonlys[$name]) || $readonlys['__ALL__'] && (!is_string($name) || $readonlys[$name] !== false) ||
1076
-			!empty($name) && is_string($name) && ($p = strrpos($name,'[')) !== false && ($parent=substr($name,0,$p)) && $readonlys[$parent])	// allow also set parent readonly (instead each child)
1076
+			!empty($name) && is_string($name) && ($p = strrpos($name, '[')) !== false && ($parent = substr($name, 0, $p)) && $readonlys[$parent])	// allow also set parent readonly (instead each child)
1077 1077
 		{
1078 1078
 			$options .= ' readonly="readonly"';
1079 1079
 		}
1080
-		if ((int) $cell['tabindex']) $options .= ' tabindex="'.(int)$cell['tabindex'].'"';
1080
+		if ((int)$cell['tabindex']) $options .= ' tabindex="'.(int)$cell['tabindex'].'"';
1081 1081
 		if ($cell['accesskey']) $options .= ' accesskey="'.html::htmlspecialchars($cell['accesskey']).'"';
1082 1082
 
1083
-		if (is_string($cell['size']) && (strchr($cell['size'],'$') || $cell['size'][0] == '@'))	// expand cell['size'] for the button-disabled-check now
1083
+		if (is_string($cell['size']) && (strchr($cell['size'], '$') || $cell['size'][0] == '@'))	// expand cell['size'] for the button-disabled-check now
1084 1084
 		{
1085
-			$cell['size'] = $this->expand_name($cell['size'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
1085
+			$cell['size'] = $this->expand_name($cell['size'], $show_c, $show_row, $content['.c'], $content['.row'], $content);
1086 1086
 		}
1087 1087
 		if ($cell['type'] == 'template' && !$this->check_disabled($cell['disabled'], $content))
1088 1088
 		{
1089 1089
 			// template is NOT disabled (eg. in editor)
1090 1090
 		}
1091
-		elseif ($cell['disabled'] && $readonlys[$name] !== false || $readonly && in_array($cell['type'],array('button','buttononly','image','progress')) && strpos($cell['size'],',') === false)
1091
+		elseif ($cell['disabled'] && $readonlys[$name] !== false || $readonly && in_array($cell['type'], array('button', 'buttononly', 'image', 'progress')) && strpos($cell['size'], ',') === false)
1092 1092
 		{
1093 1093
 			if ($this->rows == 1)
1094 1094
 			{
1095
-				return '';	// if only one row omit cell
1095
+				return ''; // if only one row omit cell
1096 1096
 			}
1097
-			$cell = $this->empty_cell('label','',array('span' => $cell['span'])); // show nothing (keep the css class!)
1097
+			$cell = $this->empty_cell('label', '', array('span' => $cell['span'])); // show nothing (keep the css class!)
1098 1098
 			$name = $value = '';
1099 1099
 		}
1100 1100
 		$extra_label = True;
1101 1101
 
1102
-		if (strchr($cell['onchange'],'$') || $cell['onchange'][0] == '@')
1102
+		if (strchr($cell['onchange'], '$') || $cell['onchange'][0] == '@')
1103 1103
 		{
1104
-			$cell['onchange'] = $this->expand_name($cell['onchange'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
1104
+			$cell['onchange'] = $this->expand_name($cell['onchange'], $show_c, $show_row, $content['.c'], $content['.row'], $content);
1105 1105
 		}
1106 1106
 		if ($cell['type'][0] == '@')
1107 1107
 		{
1108
-			$cell['type'] = $this->expand_name($t=$cell['type'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
1108
+			$cell['type'] = $this->expand_name($t = $cell['type'], $show_c, $show_row, $content['.c'], $content['.row'], $content);
1109 1109
 		}
1110 1110
 		// the while loop allows to build extensions from other extensions
1111 1111
 		// please note: only the first extension's post_process function is called !!!
1112
-		list($type,$sub_type) = explode('-',$cell['type']);
1113
-		while ((!self::$types[$cell['type']] || !empty($sub_type)) && $this->haveExtension($type,'pre_process'))
1112
+		list($type, $sub_type) = explode('-', $cell['type']);
1113
+		while ((!self::$types[$cell['type']] || !empty($sub_type)) && $this->haveExtension($type, 'pre_process'))
1114 1114
 		{
1115 1115
 			//echo "<p>pre_process($cell[name]/$cell[type])</p>\n";
1116
-			if (is_string($cell['size']) && (strchr($cell['size'],'$') || $cell['size'][0] == '@'))
1116
+			if (is_string($cell['size']) && (strchr($cell['size'], '$') || $cell['size'][0] == '@'))
1117 1117
 			{
1118
-				$cell['size'] = $this->expand_name($cell['size'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
1118
+				$cell['size'] = $this->expand_name($cell['size'], $show_c, $show_row, $content['.c'], $content['.row'], $content);
1119 1119
 			}
1120
-			if (strchr($cell['onchange'],'$') || $cell['onchange'][0] == '@')
1120
+			if (strchr($cell['onchange'], '$') || $cell['onchange'][0] == '@')
1121 1121
 			{
1122
-				$cell['onchange'] = $this->expand_name($cell['onchange'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
1122
+				$cell['onchange'] = $this->expand_name($cell['onchange'], $show_c, $show_row, $content['.c'], $content['.row'], $content);
1123 1123
 			}
1124 1124
 			if (!$ext_type) $ext_type = $type;
1125 1125
 			// if readonlys[__ALL__] is set, also set readonlys[$name] (extensions can mark themselfs as 'noReadonlysALL', eg. tab-widget!)
1126
-			if ($readonlys['__ALL__'] && $readonlys[$name] !== false && !$this->haveExtension($type,'noReadonlysALL'))
1126
+			if ($readonlys['__ALL__'] && $readonlys[$name] !== false && !$this->haveExtension($type, 'noReadonlysALL'))
1127 1127
 			{
1128 1128
 				$readonlys[$name] = true;
1129 1129
 			}
1130
-			$extra_label = $this->extensionPreProcess($type,$form_name,$value,$cell,$readonlys[$name]);
1130
+			$extra_label = $this->extensionPreProcess($type, $form_name, $value, $cell, $readonlys[$name]);
1131 1131
 
1132
-			$readonly = $cell['readonly'] !== false && ($readonly || $cell['readonly']);	// might be set or unset (===false) by extension
1132
+			$readonly = $cell['readonly'] !== false && ($readonly || $cell['readonly']); // might be set or unset (===false) by extension
1133 1133
 
1134
-			self::set_array($content,$name,$value);
1134
+			self::set_array($content, $name, $value);
1135 1135
 
1136
-			if ($cell['type'] == $type.'-'.$sub_type) break;	// stop if no further type-change
1136
+			if ($cell['type'] == $type.'-'.$sub_type) break; // stop if no further type-change
1137 1137
 
1138
-			list($type,$sub_type) = explode('-',$cell['type']);
1138
+			list($type, $sub_type) = explode('-', $cell['type']);
1139 1139
 		}
1140
-		list(,$class) = explode(',',$cell['span']);	// might be set by extension
1141
-		if (strchr($class,'$') || $class[0] == '@')
1140
+		list(,$class) = explode(',', $cell['span']); // might be set by extension
1141
+		if (strchr($class, '$') || $class[0] == '@')
1142 1142
 		{
1143
-			$class = $this->expand_name($class,$show_c,$show_row,$content['.c'],$content['.row'],$content);
1143
+			$class = $this->expand_name($class, $show_c, $show_row, $content['.c'], $content['.row'], $content);
1144 1144
 		}
1145
-		if ($cell['needed'] && !in_array($cell['type'],array('button','buttononly')))
1145
+		if ($cell['needed'] && !in_array($cell['type'], array('button', 'buttononly')))
1146 1146
 		{
1147 1147
 			$class .= ' inputRequired';
1148 1148
 		}
1149 1149
 		$cell_options = $cell['size'];
1150
-		if (strchr($cell_options,'$') || $cell_options[0] == '@')
1150
+		if (strchr($cell_options, '$') || $cell_options[0] == '@')
1151 1151
 		{
1152
-			$cell_options = $this->expand_name($cell_options,$show_c,$show_row,$content['.c'],$content['.row'],$content);
1152
+			$cell_options = $this->expand_name($cell_options, $show_c, $show_row, $content['.c'], $content['.row'], $content);
1153 1153
 		}
1154 1154
 		$label = $cell['label'];
1155
-		if (strchr($label,'$') || $label[0] == '@')
1155
+		if (strchr($label, '$') || $label[0] == '@')
1156 1156
 		{
1157
-			$label = $this->expand_name($label,$show_c,$show_row,$content['.c'],$content['.row'],$content);
1157
+			$label = $this->expand_name($label, $show_c, $show_row, $content['.c'], $content['.row'], $content);
1158 1158
 		}
1159 1159
 		$help = $cell['help'];
1160
-		if (strchr($help,'$') || $help[0] == '@')
1160
+		if (strchr($help, '$') || $help[0] == '@')
1161 1161
 		{
1162 1162
 			$no_lang_on_help = true;
1163
-			$help = $this->expand_name($help,$show_c,$show_row,$content['.c'],$content['.row'],$content);
1163
+			$help = $this->expand_name($help, $show_c, $show_row, $content['.c'], $content['.row'], $content);
1164 1164
 		}
1165
-		$blur = $cell['blur'][0] == '@' ? $this->get_array($content,substr($cell['blur'],1)) :
1166
-			(strlen($cell['blur']) <= 1 ? $cell['blur'] : lang($cell['blur']));
1165
+		$blur = $cell['blur'][0] == '@' ? $this->get_array($content, substr($cell['blur'], 1)) : (strlen($cell['blur']) <= 1 ? $cell['blur'] : lang($cell['blur']));
1167 1166
 
1168 1167
 		if ($blur)
1169 1168
 		{
@@ -1178,14 +1177,14 @@  discard block
 block discarded – undo
1178 1177
 		{
1179 1178
 			if ((int)$cell['no_lang'] < 2 && !$no_lang_on_help)
1180 1179
 			{
1181
-				if (($use_tooltip_for_help = $help[0] == '|')) $help = substr($help,1);
1180
+				if (($use_tooltip_for_help = $help[0] == '|')) $help = substr($help, 1);
1182 1181
 				$help = lang($help);
1183 1182
 			}
1184
-			if (substr($help,0,5) == 'call:')
1183
+			if (substr($help, 0, 5) == 'call:')
1185 1184
 			{
1186
-				$options .= ' onMouseOver="'.html::htmlspecialchars(substr($help,5)).'"';
1185
+				$options .= ' onMouseOver="'.html::htmlspecialchars(substr($help, 5)).'"';
1187 1186
 			}
1188
-			elseif (($use_tooltip_for_help = $use_tooltip_for_help || strpos($help,'<') !== false && strip_tags($help) != $help))	// helptext is html => use a tooltip
1187
+			elseif (($use_tooltip_for_help = $use_tooltip_for_help || strpos($help, '<') !== false && strip_tags($help) != $help))	// helptext is html => use a tooltip
1189 1188
 			{
1190 1189
 				$options .= html::tooltip($help);
1191 1190
 			}
@@ -1193,7 +1192,7 @@  discard block
 block discarded – undo
1193 1192
 			{
1194 1193
 				$onFocus .= "self.status='".addslashes(html::htmlspecialchars($help))."'; return true;";
1195 1194
 				$onBlur  .= "self.status=''; return true;";
1196
-				if (in_array($cell['type'],array('button','buttononly','file')))	// for button additionally when mouse over button
1195
+				if (in_array($cell['type'], array('button', 'buttononly', 'file')))	// for button additionally when mouse over button
1197 1196
 				{
1198 1197
 					$options .= " onMouseOver=\"self.status='".addslashes(html::htmlspecialchars($help))."'; return true;\"";
1199 1198
 					$options .= " onMouseOut=\"self.status=''; return true;\"";
@@ -1206,7 +1205,7 @@  discard block
 block discarded – undo
1206 1205
 		}
1207 1206
 		if ($cell['onchange'] && !($cell['type'] == 'button' || $cell['type'] == 'buttononly'))
1208 1207
 		{
1209
-			$onchange = $cell['onchange'] == '1' ? 'this.form.submit();' : $this->js_pseudo_funcs($cell['onchange'],$cname);
1208
+			$onchange = $cell['onchange'] == '1' ? 'this.form.submit();' : $this->js_pseudo_funcs($cell['onchange'], $cname);
1210 1209
 			// rewriting onchange for checkboxes for IE to an onclick
1211 1210
 			if ($cell['type'] == 'checkbox' && html::$user_agent == 'msie')
1212 1211
 			{
@@ -1220,15 +1219,15 @@  discard block
 block discarded – undo
1220 1219
 
1221 1220
 		if ($form_name != '')
1222 1221
 		{
1223
-			$options = self::get_id($form_name,$cell['name'],$cell['id']).' '.$options;
1222
+			$options = self::get_id($form_name, $cell['name'], $cell['id']).' '.$options;
1224 1223
 		}
1225 1224
 		switch ($type)
1226 1225
 		{
1227 1226
 			case 'label':	//  size: [b[old]][i[talic]],[link],[activate_links],[label_for],[link_target],[link_popup_size],[link_title]
1228 1227
 				if (is_array($value)) break;
1229
-				if($cell_options)
1228
+				if ($cell_options)
1230 1229
 				{
1231
-					list($style,$extra_link,$activate_links,$label_for,$extra_link_target,$extra_link_popup,$extra_link_title) = self::csv_split($cell_options,7);
1230
+					list($style, $extra_link, $activate_links, $label_for, $extra_link_target, $extra_link_popup, $extra_link_title) = self::csv_split($cell_options, 7);
1232 1231
 				}
1233 1232
 				else
1234 1233
 				{
@@ -1243,44 +1242,44 @@  discard block
 block discarded – undo
1243 1242
 				$value = strlen($value) > 1 && !$cell['no_lang'] ? lang($value) : $value;
1244 1243
 				$value = nl2br(html::htmlspecialchars($value));
1245 1244
 				if ($activate_links) $value = html::activate_links($value);
1246
-				if ($value != '' && $style && strpos($style,'b')!==false) $value = html::bold($value);
1247
-				if ($value != '' && $style && strpos($style,'i')!==false) $value = html::italic($value);
1245
+				if ($value != '' && $style && strpos($style, 'b') !== false) $value = html::bold($value);
1246
+				if ($value != '' && $style && strpos($style, 'i') !== false) $value = html::italic($value);
1248 1247
 				// if the label has a name, use it as id in a span, to allow addressing it via javascript
1249
-				$html .= ($name ? '<span id="'.($cell['id']?$cell['id']:$name).'">' : '').$value.($name ? '</span>' : '');
1248
+				$html .= ($name ? '<span id="'.($cell['id'] ? $cell['id'] : $name).'">' : '').$value.($name ? '</span>' : '');
1250 1249
 				if ($help)
1251 1250
 				{
1252 1251
 					$class = array(
1253 1252
 						'class'       => $class,
1254 1253
 					);
1255
-					list($class['onmouseover'],$class['onmouseout']) = html::tooltip($help, False, False,  true);
1254
+					list($class['onmouseover'], $class['onmouseout']) = html::tooltip($help, False, False, true);
1256 1255
 				}
1257 1256
 				break;
1258 1257
 			case 'html':	//  size: [link],[link_target],[link_popup_size],[link_title],[activate_links]
1259
-				list($extra_link,$extra_link_target,$extra_link_popup,$extra_link_title,$activate_links) = explode(',',$cell_options);
1258
+				list($extra_link, $extra_link_target, $extra_link_popup, $extra_link_title, $activate_links) = explode(',', $cell_options);
1260 1259
 				if ($activate_links) $value = html::activate_links($value);
1261 1260
 				$html .= $value;
1262 1261
 				break;
1263 1262
 			case 'int':		// size: [min],[max],[len],[precision/sprint format],[step]
1264 1263
 			case 'integer':
1265 1264
 			case 'float':
1266
-				list($min,$max,$cell_options,$pre,$step) = explode(',',$cell_options);
1265
+				list($min, $max, $cell_options, $pre, $step) = explode(',', $cell_options);
1267 1266
 				// a few html5 options
1268 1267
 				if ((string)$min !== '') $options .= ' min="'.htmlspecialchars($min).'"';
1269 1268
 				if ((string)$max !== '') $options .= ' max="'.htmlspecialchars($max).'"';
1270 1269
 				//  default step="any" for float, as not setting it limits value to integer as step defaults to 1 in html5!
1271 1270
 				if (is_numeric($step) || $type == 'float')
1272 1271
 				{
1273
-					$options .= ' step="'.(is_numeric($step)?$step:'any').'"';
1272
+					$options .= ' step="'.(is_numeric($step) ? $step : 'any').'"';
1274 1273
 				}
1275 1274
 				if ($cell_options == '' && !$readonly)
1276 1275
 				{
1277 1276
 					$cell_options = $cell['type'] != 'float' ? 5 : 8;
1278 1277
 				}
1279 1278
 				// html5 input type=nummeric seems to ignore size, setting a width instead
1280
-				$options .= ' style="width: '.(3+abs($cell_options)).'ex"';
1279
+				$options .= ' style="width: '.(3 + abs($cell_options)).'ex"';
1281 1280
 				if (($type == 'float' || !is_numeric($pre)) && $value && $pre)
1282 1281
 				{
1283
-					$value = is_numeric($pre) ? self::number_format($value,$pre,$readonly) : sprintf($pre,$value);
1282
+					$value = is_numeric($pre) ? self::number_format($value, $pre, $readonly) : sprintf($pre, $value);
1284 1283
 				}
1285 1284
 				$cell_options .= ',,'.($cell['type'] != 'float' ? '/^-?[0-9]*$/' : '"/^-?[0-9]*[,.]?[0-9]*$/"').',number';
1286 1285
 				// fall-through
@@ -1288,16 +1287,16 @@  discard block
 block discarded – undo
1288 1287
 			case 'passwd':
1289 1288
 			case 'text':		// size: [length][,maxLength[,preg[,html5type]]]
1290 1289
 			case 'textbox':
1291
-				$cell_opts = $c = self::csv_split($cell_options);	// allows to enclose preg in quote to allow comma
1290
+				$cell_opts = $c = self::csv_split($cell_options); // allows to enclose preg in quote to allow comma
1292 1291
 				// fix preg, in case it contains a comma (html5type is only letters and always last option!)
1293
-				if (count($cell_opts) > 3 && ($cell_opts2 = explode(',',$cell_options)) && $cell_opts2[2][0] != '"')
1292
+				if (count($cell_opts) > 3 && ($cell_opts2 = explode(',', $cell_options)) && $cell_opts2[2][0] != '"')
1294 1293
 				{
1295 1294
 					$html5type = array_pop($cell_opts);
1296
-					$cell_opts = explode(',',$cell_options,3);
1297
-					if (preg_match('/^[a-z]+$/i',$html5type))
1295
+					$cell_opts = explode(',', $cell_options, 3);
1296
+					if (preg_match('/^[a-z]+$/i', $html5type))
1298 1297
 					{
1299
-						$cell_opts[2] = substr($cell_opts[2],0,-strlen($html5type)-1);
1300
-						if ($cell_opts[2][0] == ',') $cell_opts[2] = '';	// happens in link-entry under some condition
1298
+						$cell_opts[2] = substr($cell_opts[2], 0, -strlen($html5type) - 1);
1299
+						if ($cell_opts[2][0] == ',') $cell_opts[2] = ''; // happens in link-entry under some condition
1301 1300
 						$cell_opts[] = $html5type;
1302 1301
 					}
1303 1302
 				}
@@ -1317,17 +1316,17 @@  discard block
 block discarded – undo
1317 1316
 					{
1318 1317
 						$required = ' required';
1319 1318
 					}
1320
-					$html .= html::input($form_name,$value,$type == 'passwd' ? 'password' : ($type == 'hidden' ? 'hidden' : $cell_opts[3]),
1321
-						$options.html::formatOptions($cell_opts,'SIZE,MAXLENGTH').
1322
-						$required.($type == 'passwd'?' autocomplete="off"':''));
1319
+					$html .= html::input($form_name, $value, $type == 'passwd' ? 'password' : ($type == 'hidden' ? 'hidden' : $cell_opts[3]),
1320
+						$options.html::formatOptions($cell_opts, 'SIZE,MAXLENGTH').
1321
+						$required.($type == 'passwd' ? ' autocomplete="off"' : ''));
1323 1322
 
1324 1323
 					if (!$readonly)
1325 1324
 					{
1326
-						self::$request->set_to_process($form_name,$cell['type'],array(
1325
+						self::$request->set_to_process($form_name, $cell['type'], array(
1327 1326
 							'maxlength' => $cell_opts[1],
1328 1327
 							'needed'    => $cell['needed'],
1329 1328
 							'preg'      => $cell_opts[2],
1330
-							'min'       => $min,	// int and float only
1329
+							'min'       => $min, // int and float only
1331 1330
 							'max'       => $max,
1332 1331
 						));
1333 1332
 					}
@@ -1344,18 +1343,18 @@  discard block
 block discarded – undo
1344 1343
 					// if textarea is readonly, but form_name is already used by an other widget, dont use it
1345 1344
 					// browser would only send the content of the readonly (and therefore unchanged) field
1346 1345
 					if ($readonly && self::$request->isset_to_process($form_name)) $form_name = '';
1347
-					$html .= html::textarea($form_name,$value,
1348
-						$options.html::formatOptions($cell_options,'ROWS,COLS').($cell['needed']?' required="required"':''));
1346
+					$html .= html::textarea($form_name, $value,
1347
+						$options.html::formatOptions($cell_options, 'ROWS,COLS').($cell['needed'] ? ' required="required"' : ''));
1349 1348
 				}
1350 1349
 				if (!$readonly)
1351 1350
 				{
1352
-					self::$request->set_to_process($form_name,$cell['type'],array(
1351
+					self::$request->set_to_process($form_name, $cell['type'], array(
1353 1352
 						'needed'    => $cell['needed'],
1354 1353
 					));
1355 1354
 				}
1356 1355
 				break;
1357 1356
 			case 'htmlarea':	// Multiline formatted Text Input, size: {simple|extended|advanced},height,width,toolbar-expanded,upload-path
1358
-				list($mode,$height,$width,$toolbar,$baseref,$convertnl) = explode(',',$cell_options);
1357
+				list($mode, $height, $width, $toolbar, $baseref, $convertnl) = explode(',', $cell_options);
1359 1358
 
1360 1359
 				if ($convertnl)
1361 1360
 				{
@@ -1369,33 +1368,33 @@  discard block
 block discarded – undo
1369 1368
 						'toolbar_expanded' => $toolbar,
1370 1369
 					);
1371 1370
 					// html::fckEditor runs everything through html::purify
1372
-					$html .= html::fckEditor($form_name,$value,$mode,$fckoptions,$height,$width,$baseref);
1371
+					$html .= html::fckEditor($form_name, $value, $mode, $fckoptions, $height, $width, $baseref);
1373 1372
 
1374
-					self::$request->set_to_process($form_name,$cell['type'],array(
1373
+					self::$request->set_to_process($form_name, $cell['type'], array(
1375 1374
 						'needed'    => $cell['needed'],
1376
-						'mode'      => $mode,	// need mode to not run purify for $mode=='ascii'
1375
+						'mode'      => $mode, // need mode to not run purify for $mode=='ascii'
1377 1376
 					));
1378 1377
 				}
1379 1378
 				else
1380 1379
 				{
1381
-					$html .= html::div(html::purify(html::activate_links($value)),'style="overflow: auto; width='. $width. '; height='. $height. '"');
1380
+					$html .= html::div(html::purify(html::activate_links($value)), 'style="overflow: auto; width='.$width.'; height='.$height.'"');
1382 1381
 				}
1383 1382
 				break;
1384 1383
 			case 'checkbox':
1385 1384
 				$set_val = 1; $unset_val = 0;
1386 1385
 				if (!empty($cell_options))
1387 1386
 				{
1388
-					list($set_val,$unset_val,$ro_true,$ro_false) = self::csv_split($cell_options);
1387
+					list($set_val, $unset_val, $ro_true, $ro_false) = self::csv_split($cell_options);
1389 1388
 					if (!$set_val && !$unset_val) $set_val = 1;
1390 1389
 					$value = $value == $set_val;
1391 1390
 				}
1392
-				if (($multiple = substr($cell['name'],-2) == '[]') && !$readonly)
1391
+				if (($multiple = substr($cell['name'], -2) == '[]') && !$readonly)
1393 1392
 				{
1394
-					$readonly = $readonlys[substr($cell['name'],0,-1).$set_val.']'];
1393
+					$readonly = $readonlys[substr($cell['name'], 0, -1).$set_val.']'];
1395 1394
 				}
1396 1395
 				if ($readonly)
1397 1396
 				{
1398
-					if (count(explode(',',$cell_options)) < 3)
1397
+					if (count(explode(',', $cell_options)) < 3)
1399 1398
 					{
1400 1399
 						$ro_true = 'x';
1401 1400
 						$ro_false = '';
@@ -1412,27 +1411,27 @@  discard block
 block discarded – undo
1412 1411
 					{
1413 1412
 						// add the set_val to the id to make it unique
1414 1413
 						$options = str_replace(self::get_id($form_name),
1415
-							self::get_id(substr($form_name,0,-2)."[$set_val]"), $options);
1414
+							self::get_id(substr($form_name, 0, -2)."[$set_val]"), $options);
1416 1415
 					}
1417
-					$html .= html::input($form_name,$set_val,'checkbox',$options);
1416
+					$html .= html::input($form_name, $set_val, 'checkbox', $options);
1418 1417
 
1419
-					if ($multiple) $form_name = self::form_name($cname,substr($cell['name'],0,-2));
1418
+					if ($multiple) $form_name = self::form_name($cname, substr($cell['name'], 0, -2));
1420 1419
 
1421 1420
 					if (!self::$request->isset_to_process($form_name))
1422 1421
 					{
1423
-						self::$request->set_to_process($form_name,$cell['type'],array(
1422
+						self::$request->set_to_process($form_name, $cell['type'], array(
1424 1423
 							'unset_value' => $unset_val,
1425 1424
 							'multiple'    => $multiple,
1426 1425
 							'needed'      => $cell['needed'],
1427 1426
 						));
1428 1427
 					}
1429
-					self::$request->set_to_process_attribute($form_name,'values',$set_val,true);
1430
-					if (!$multiple) unset($set_val);	// otherwise it will be added to the label
1428
+					self::$request->set_to_process_attribute($form_name, 'values', $set_val, true);
1429
+					if (!$multiple) unset($set_val); // otherwise it will be added to the label
1431 1430
 				}
1432 1431
 				break;
1433 1432
 			case 'radio':		// size: value if checked, readonly set, readonly unset
1434
-				list($set_val,$ro_true,$ro_false) = self::csv_split($cell_options);
1435
-				$set_val = $this->expand_name($set_val,$show_c,$show_row,$content['.c'],$content['.row'],$content);
1433
+				list($set_val, $ro_true, $ro_false) = self::csv_split($cell_options);
1434
+				$set_val = $this->expand_name($set_val, $show_c, $show_row, $content['.c'], $content['.row'], $content);
1436 1435
 
1437 1436
 				if ($value == $set_val)
1438 1437
 				{
@@ -1449,8 +1448,8 @@  discard block
 block discarded – undo
1449 1448
 				}
1450 1449
 				else
1451 1450
 				{
1452
-					$html .= html::input($form_name,$set_val,'RADIO',$options);
1453
-					self::$request->set_to_process($form_name,$cell['type'],array(
1451
+					$html .= html::input($form_name, $set_val, 'RADIO', $options);
1452
+					self::$request->set_to_process($form_name, $cell['type'], array(
1454 1453
 						'needed' => $cell['needed'],
1455 1454
 					));
1456 1455
 				}
@@ -1458,34 +1457,34 @@  discard block
 block discarded – undo
1458 1457
 			case 'button':
1459 1458
 			case 'buttononly':
1460 1459
 			case 'cancel':	// cancel button
1461
-				if ($name == 'cancel' || stripos($name,'[cancel]') !== false) $type = 'cancel';
1462
-				list($app) = explode('.',$this->name);
1463
-				list($img,$ro_img) = explode(',',$cell_options);
1464
-				if ($img[0] != '/' && strpos($img,'/') !== false && count($img_parts = explode('/',$img)) == 2)
1460
+				if ($name == 'cancel' || stripos($name, '[cancel]') !== false) $type = 'cancel';
1461
+				list($app) = explode('.', $this->name);
1462
+				list($img, $ro_img) = explode(',', $cell_options);
1463
+				if ($img[0] != '/' && strpos($img, '/') !== false && count($img_parts = explode('/', $img)) == 2)
1465 1464
 				{
1466
-					list($app,$img) = $img_parts;	// allow to specify app in image name (eg. img='addressbook/navbar')
1465
+					list($app, $img) = $img_parts; // allow to specify app in image name (eg. img='addressbook/navbar')
1467 1466
 				}
1468 1467
 				$title = strlen($label) <= 1 || $cell['no_lang'] ? $label : lang($label);
1469 1468
 				if ($cell['onclick'] &&
1470
-					($onclick = $this->expand_name($cell['onclick'],$show_c,$show_row,$content['.c'],$content['.row'],$content)))
1469
+					($onclick = $this->expand_name($cell['onclick'], $show_c, $show_row, $content['.c'], $content['.row'], $content)))
1471 1470
 				{
1472
-					$onclick = $this->js_pseudo_funcs($onclick,$cname);
1471
+					$onclick = $this->js_pseudo_funcs($onclick, $cname);
1473 1472
 				}
1474
-				unset($cell['onclick']);	// otherwise the grid will handle it
1473
+				unset($cell['onclick']); // otherwise the grid will handle it
1475 1474
 				if (($cell['onchange'] != '' || $img && !$readonly) && !$cell['needed']) // use a link instead of a button
1476 1475
 				{
1477
-					$onclick = ($onclick ? preg_replace('/^return(.*);$/','if (\\1) ',$onclick) : '').
1476
+					$onclick = ($onclick ? preg_replace('/^return(.*);$/', 'if (\\1) ', $onclick) : '').
1478 1477
 						(((string)$cell['onchange'] === '1' || $img) ?
1479 1478
 						'return submitit('.self::$name_form.",'".$form_name."');" : $cell['onchange']).'; return false;';
1480 1479
 
1481
-					if (!html::$netscape4 && substr($img,-1) == '%' && is_numeric($percent = substr($img,0,-1)))
1480
+					if (!html::$netscape4 && substr($img, -1) == '%' && is_numeric($percent = substr($img, 0, -1)))
1482 1481
 					{
1483
-						$html .= html::progressbar($percent,$title,'onclick="'.$onclick.'" '.$options);
1482
+						$html .= html::progressbar($percent, $title, 'onclick="'.$onclick.'" '.$options);
1484 1483
 					}
1485 1484
 					else
1486 1485
 					{
1487
-						$html .= '<a href="" onClick="'.$onclick.'" '.$options.'>' .
1488
-							($img ? html::image($app,$img,$title,'border="0"') : $title) . '</a>';
1486
+						$html .= '<a href="" onClick="'.$onclick.'" '.$options.'>'.
1487
+							($img ? html::image($app, $img, $title, 'border="0"') : $title).'</a>';
1489 1488
 					}
1490 1489
 				}
1491 1490
 				else
@@ -1496,17 +1495,16 @@  discard block
 block discarded – undo
1496 1495
 					}
1497 1496
 					if ($cell['onchange'] && $cell['onchange'] != 1)
1498 1497
 					{
1499
-						$onclick = ($onclick ? preg_replace('/^return(.*);$/','if (\\1) ',$onclick) : '').$cell['onchange'];
1498
+						$onclick = ($onclick ? preg_replace('/^return(.*);$/', 'if (\\1) ', $onclick) : '').$cell['onchange'];
1500 1499
 					}
1501
-					if ($type == 'cancel') $options .= ' novalidate="novalidate"';	// tell html5 form validation NOT to validate
1502
-					$html .= !$readonly ? html::submit_button($form_name,$label,$onclick,
1503
-						strlen($label) <= 1 || $cell['no_lang'],$options,$img,$app,$type == 'buttononly' ? 'button' : 'submit') :
1504
-						html::image($app,$ro_img,'',$options);
1500
+					if ($type == 'cancel') $options .= ' novalidate="novalidate"'; // tell html5 form validation NOT to validate
1501
+					$html .= !$readonly ? html::submit_button($form_name, $label, $onclick,
1502
+						strlen($label) <= 1 || $cell['no_lang'], $options, $img, $app, $type == 'buttononly' ? 'button' : 'submit') : html::image($app, $ro_img, '', $options);
1505 1503
 				}
1506 1504
 				$extra_label = False;
1507 1505
 				if (!$readonly && $type != 'buttononly')	// input button, are never submitted back!
1508 1506
 				{
1509
-					self::$request->set_to_process($form_name,$type);
1507
+					self::$request->set_to_process($form_name, $type);
1510 1508
 				}
1511 1509
 				break;
1512 1510
 			case 'hrule':
@@ -1520,9 +1518,9 @@  discard block
 block discarded – undo
1520 1518
 				}
1521 1519
 				if ($name != '')
1522 1520
 				{
1523
-					$cname .= $cname == '' ? $name : '['.str_replace('[','][',str_replace(']','',$name)).']';
1521
+					$cname .= $cname == '' ? $name : '['.str_replace('[', '][', str_replace(']', '', $name)).']';
1524 1522
 				}
1525
-				$html .= $this->show_grid($cell,$name ? $value : $content,$readonlys+(array)$readonlys[$name],$cname,$show_c,$show_row,$path);
1523
+				$html .= $this->show_grid($cell, $name ? $value : $content, $readonlys + (array)$readonlys[$name], $cname, $show_c, $show_row, $path);
1526 1524
 				if ($set_readonlys_all) unset($readonlys['__ALL__']);
1527 1525
 				break;
1528 1526
 			case 'template':	// size: index in content-array (if not full content is past further on)
@@ -1538,44 +1536,44 @@  discard block
 block discarded – undo
1538 1536
 				{
1539 1537
 					$obj = new etemplate();
1540 1538
 					$obj->init($cell['obj']);
1541
-					$cell['obj'] =& $obj;
1539
+					$cell['obj'] = & $obj;
1542 1540
 					unset($obj);
1543 1541
 				}
1544 1542
 				if (!is_object($cell['obj']))
1545 1543
 				{
1546 1544
 					if ($cell['name'][0] == '@')
1547 1545
 					{
1548
-						$cell['obj'] = $this->get_array($content,substr($cell['name'],1));
1546
+						$cell['obj'] = $this->get_array($content, substr($cell['name'], 1));
1549 1547
 						$obj_read = is_object($cell['obj']) ? 'obj from content' : 'obj read, obj-name from content';
1550 1548
 						if (!is_object($cell['obj']))
1551 1549
 						{
1552
-							$cell['obj'] = new etemplate($cell['obj'],$this->as_array());
1550
+							$cell['obj'] = new etemplate($cell['obj'], $this->as_array());
1553 1551
 						}
1554 1552
 					}
1555 1553
 					else
1556 1554
 					{  $obj_read = 'obj read';
1557
-						$cell['obj'] = new etemplate($name,$this->as_array());
1555
+						$cell['obj'] = new etemplate($name, $this->as_array());
1558 1556
 					}
1559 1557
 				}
1560 1558
 				if (is_int($this->debug) && $this->debug >= 3 || $this->debug == $cell['type'])
1561 1559
 				{
1562 1560
 					echo "<p>show_cell::template(tpl=$this->name,name=$cell[name]): $obj_read, readonly=$readonly</p>\n";
1563 1561
 				}
1564
-				if ($this->autorepeat_idx($cell,$show_c,$show_row,$idx,$idx_cname,false,$content) || $cell_options != '')
1562
+				if ($this->autorepeat_idx($cell, $show_c, $show_row, $idx, $idx_cname, false, $content) || $cell_options != '')
1565 1563
 				{
1566 1564
 					if ($span == '' && isset($content[$idx]['span']))
1567 1565
 					{	// this allows a colspan in autorepeated cells like the editor
1568
-						list($span) = explode(',',$content[$idx]['span']);
1566
+						list($span) = explode(',', $content[$idx]['span']);
1569 1567
 						if ($span == 'all')
1570 1568
 						{
1571 1569
 							$span = 1 + $content['cols'] - $show_c;
1572 1570
 						}
1573 1571
 					}
1574
-					$readonlys = $this->get_array($readonlys,$idx);
1575
-					$content = $this->get_array($content,$idx);
1572
+					$readonlys = $this->get_array($readonlys, $idx);
1573
+					$content = $this->get_array($content, $idx);
1576 1574
 					if ($idx_cname != '')
1577 1575
 					{
1578
-						$cname .= $cname == '' ? $idx_cname : '['.str_replace('[','][',str_replace(']','',$idx_cname)).']';
1576
+						$cname .= $cname == '' ? $idx_cname : '['.str_replace('[', '][', str_replace(']', '', $idx_cname)).']';
1579 1577
 					}
1580 1578
 					//echo "<p>show_cell-autorepeat($name,$show_c,$show_row,cname='$cname',idx='$idx',idx_cname='$idx_cname',span='$span'): content ="; _debug_array($content);
1581 1579
 				}
@@ -1593,21 +1591,21 @@  discard block
 block discarded – undo
1593 1591
 				// propagate the CSS class to the template
1594 1592
 				if ($class)
1595 1593
 				{
1596
-					$grid_size = array_pad(explode(',',$cell['obj']->size),4,'');
1597
-					$grid_size[3] = ($grid_size[3] ? $grid_size[3].' ' : '') . $class;
1598
-					$cell['obj']->size = implode(',',$grid_size);
1594
+					$grid_size = array_pad(explode(',', $cell['obj']->size), 4, '');
1595
+					$grid_size[3] = ($grid_size[3] ? $grid_size[3].' ' : '').$class;
1596
+					$cell['obj']->size = implode(',', $grid_size);
1599 1597
 				}
1600
-				$html = $cell['obj']->show($content,$this->sel_options,$readonlys,$cname,$show_c,$show_row);
1598
+				$html = $cell['obj']->show($content, $this->sel_options, $readonlys, $cname, $show_c, $show_row);
1601 1599
 
1602 1600
 				if ($set_readonlys_all) unset($readonlys['__ALL__']);
1603 1601
 				break;
1604 1602
 			case 'select':	// size:[linesOnMultiselect|emptyLabel,extraStyleMulitselect, [<varies>,]{5} enhance]
1605 1603
 				$sels = array();
1606
-				list($multiple,$extraStyleMultiselect) = explode(',',$cell_options,2);
1604
+				list($multiple, $extraStyleMultiselect) = explode(',', $cell_options, 2);
1607 1605
 
1608 1606
 				// Allow widget to specify using enhanced select or not
1609
-				$c_options = explode(',',$cell_options);
1610
-				if(array_key_exists('enhance', $cell))
1607
+				$c_options = explode(',', $cell_options);
1608
+				if (array_key_exists('enhance', $cell))
1611 1609
 				{
1612 1610
 					$enhance = $cell['enhance'];
1613 1611
 				}
@@ -1617,21 +1615,21 @@  discard block
 block discarded – undo
1617 1615
 					$enhance = ($c_options[7] == '1' || $c_options[7] == 'true');
1618 1616
 				}
1619 1617
 
1620
-				if (!empty($multiple) && 0+$multiple <= 0)
1618
+				if (!empty($multiple) && 0 + $multiple <= 0)
1621 1619
 				{
1622 1620
 					$sels[''] = $multiple < 0 ? 'all' : $multiple;
1623 1621
 					// extra-option: no_lang=0 gets translated later and no_lang=1 gets translated too (now), only no_lang>1 gets not translated
1624 1622
 					if ((int)$cell['no_lang'] == 1)
1625 1623
 					{
1626
-						$sels[''] = substr($sels[''],-3) == '...' ? lang(substr($sels[''],0,-3)).'...' : lang($sels['']);
1624
+						$sels[''] = substr($sels[''], -3) == '...' ? lang(substr($sels[''], 0, -3)).'...' : lang($sels['']);
1627 1625
 					}
1628 1626
 					$multiple = 0;
1629 1627
 				}
1630
-				$sels += $this->_sel_options($cell,$name,$content);
1631
-				if ($multiple && !is_array($value)) $value = explode(',',$value);
1628
+				$sels += $this->_sel_options($cell, $name, $content);
1629
+				if ($multiple && !is_array($value)) $value = explode(',', $value);
1632 1630
 				if ($readonly || $cell['noprint'])
1633 1631
 				{
1634
-					foreach($multiple || is_array($value) ? $value : array($value) as $val)
1632
+					foreach ($multiple || is_array($value) ? $value : array($value) as $val)
1635 1633
 					{
1636 1634
 						if (is_array($sels[$val]))
1637 1635
 						{
@@ -1640,7 +1638,7 @@  discard block
 block discarded – undo
1640 1638
 						}
1641 1639
 						else
1642 1640
 						{
1643
-							$option_label = ($sels[$val]?$sels[$val]:$val);
1641
+							$option_label = ($sels[$val] ? $sels[$val] : $val);
1644 1642
 							$option_title = '';
1645 1643
 						}
1646 1644
 						if (!$cell['no_lang']) $option_label = lang($option_label);
@@ -1666,33 +1664,33 @@  discard block
 block discarded – undo
1666 1664
 					}
1667 1665
 					if ($multiple && is_numeric($multiple))	// eg. "3+" would give a regular multiselectbox
1668 1666
 					{
1669
-						$html .= html::checkbox_multiselect($form_name.($multiple > 1 ? '[]' : ''),$value,$sels,
1670
-							$cell['no_lang'],$options,$multiple,$multiple[0]!=='0',
1671
-							$extraStyleMultiselect,$enhance);
1667
+						$html .= html::checkbox_multiselect($form_name.($multiple > 1 ? '[]' : ''), $value, $sels,
1668
+							$cell['no_lang'], $options, $multiple, $multiple[0] !== '0',
1669
+							$extraStyleMultiselect, $enhance);
1672 1670
 					}
1673 1671
 					else
1674 1672
 					{
1675
-						$html .= html::select($form_name.($multiple > 1 ? '[]' : ''),$value,$sels,
1676
-							$cell['no_lang'],$options,$multiple,$enhance);
1673
+						$html .= html::select($form_name.($multiple > 1 ? '[]' : ''), $value, $sels,
1674
+							$cell['no_lang'], $options, $multiple, $enhance);
1677 1675
 					}
1678 1676
 					if (!self::$request->isset_to_process($form_name))
1679 1677
 					{
1680 1678
 						// fix for optgroup's
1681
-						$options=array();
1682
-						foreach($sels as $key => $val)
1679
+						$options = array();
1680
+						foreach ($sels as $key => $val)
1683 1681
 						{
1684 1682
 							# we want the key anyway, even if this allowes more values than wanted (the name/key of the optgroup if there is one,
1685 1683
 							# the keys of the arrays in case you have key/value pair(s) as value for the value of your option ).
1686
-							$options[$key]=$key;
1684
+							$options[$key] = $key;
1687 1685
 							if (is_array($val))
1688 1686
 							{
1689
-								foreach(array_keys($val) as $key2)
1687
+								foreach (array_keys($val) as $key2)
1690 1688
 								{
1691
-									$options[$key2]=$key2;
1689
+									$options[$key2] = $key2;
1692 1690
 								}
1693 1691
 							}
1694 1692
 						}
1695
-						self::$request->set_to_process($form_name,$cell['type'],array(
1693
+						self::$request->set_to_process($form_name, $cell['type'], array(
1696 1694
 							'needed'  => $cell['needed'],
1697 1695
 							'allowed' => array_keys($options),
1698 1696
 							'multiple'=> $multiple,
@@ -1703,50 +1701,50 @@  discard block
 block discarded – undo
1703 1701
 			case 'image':	// size: [link],[link_target],[imagemap],[link_popup],[id]
1704 1702
 			case 'progress':
1705 1703
 				if (is_string($value) && $value !== '' &&
1706
-					($is_progress = substr($value,-1) == '%' && is_numeric(substr($value,0,-1))) !== ($type == 'progress'))
1704
+					($is_progress = substr($value, -1) == '%' && is_numeric(substr($value, 0, -1))) !== ($type == 'progress'))
1707 1705
 				{
1708
-					error_log("Please use correct widget-type '".($is_progress?'progress':'image')."' in eTemplate '$this->name'!");
1706
+					error_log("Please use correct widget-type '".($is_progress ? 'progress' : 'image')."' in eTemplate '$this->name'!");
1709 1707
 				}
1710 1708
 				$image = $value != '' ? $value : $name;
1711
-				if (is_string($image)) list($app,$img) = explode('/',$image,2);
1712
-				if (!$app || !$img || !is_dir(EGW_SERVER_ROOT.'/'.$app) || strpos($img,'/')!==false)
1709
+				if (is_string($image)) list($app, $img) = explode('/', $image, 2);
1710
+				if (!$app || !$img || !is_dir(EGW_SERVER_ROOT.'/'.$app) || strpos($img, '/') !== false)
1713 1711
 				{
1714 1712
 					$img = $image;
1715
-					list($app) = explode('.',$this->name);
1713
+					list($app) = explode('.', $this->name);
1716 1714
 				}
1717 1715
 				if (!$readonly)
1718 1716
 				{
1719
-					list($extra_link,$extra_link_target,$imagemap,$extra_link_popup,$id) = self::csv_split($cell['size']);
1717
+					list($extra_link, $extra_link_target, $imagemap, $extra_link_popup, $id) = self::csv_split($cell['size']);
1720 1718
 				}
1721
-				$html .= html::image($app,$img,strlen($label) > 1 && !$cell['no_lang'] ? lang($label) : $label,
1722
-					'border="0"'.($imagemap?' usemap="#'.html::htmlspecialchars($imagemap).'"':'').
1723
-					($id || $value ? self::get_id($name,$cell['name'],$id) : ''));
1719
+				$html .= html::image($app, $img, strlen($label) > 1 && !$cell['no_lang'] ? lang($label) : $label,
1720
+					'border="0"'.($imagemap ? ' usemap="#'.html::htmlspecialchars($imagemap).'"' : '').
1721
+					($id || $value ? self::get_id($name, $cell['name'], $id) : ''));
1724 1722
 				$extra_label = False;
1725 1723
 				break;
1726 1724
 			case 'file':	// size: size of the filename field
1727 1725
 				if (!$readonly)
1728 1726
 				{
1729
-					if ((int) $cell_options) $options .= ' size="'.(int)$cell_options.'"';
1730
-					if (substr($name,-2) == '[]')
1727
+					if ((int)$cell_options) $options .= ' size="'.(int)$cell_options.'"';
1728
+					if (substr($name, -2) == '[]')
1731 1729
 					{
1732 1730
 						self::$form_options .= ' enctype="multipart/form-data"';
1733
-						if (strpos($options,'onChange="') !== false)
1731
+						if (strpos($options, 'onChange="') !== false)
1734 1732
 						{
1735
-							$options = preg_replace('/onChange="([^"]+)"/i','onChange="\\1; if (!this.multiple) add_upload(this);"',$options);
1733
+							$options = preg_replace('/onChange="([^"]+)"/i', 'onChange="\\1; if (!this.multiple) add_upload(this);"', $options);
1736 1734
 						}
1737 1735
 						else
1738 1736
 						{
1739 1737
 							$options .= ' onChange="if (!this.multiple) add_upload(this);"';
1740 1738
 						}
1741
-						$options .= ' multiple="multiple"';	// allow html5 browsers to select more then one file
1739
+						$options .= ' multiple="multiple"'; // allow html5 browsers to select more then one file
1742 1740
 					}
1743 1741
 					else
1744 1742
 					{
1745
-						$html .= html::input_hidden($path_name = str_replace($name,$name.'_path',$form_name),'.');
1743
+						$html .= html::input_hidden($path_name = str_replace($name, $name.'_path', $form_name), '.');
1746 1744
 						self::$form_options = " enctype=\"multipart/form-data\" onsubmit=\"set_element2(this,'$path_name','$form_name')\"";
1747 1745
 					}
1748
-					$html .= html::input($form_name,'','file',$options);
1749
-					self::$request->set_to_process($form_name,$cell['type'],array(
1746
+					$html .= html::input($form_name, '', 'file', $options);
1747
+					self::$request->set_to_process($form_name, $cell['type'], array(
1750 1748
 						'needed' => $cell['needed'],
1751 1749
 					));
1752 1750
 				}
@@ -1762,12 +1760,12 @@  discard block
 block discarded – undo
1762 1760
 				$box_row = 1;
1763 1761
 				$box_col = 'A';
1764 1762
 				$box_anz = 0;
1765
-				list($num,$orient,,,$keep_empty) = explode(',',$cell_options);
1763
+				list($num, $orient,,, $keep_empty) = explode(',', $cell_options);
1766 1764
 				if (!$orient) $orient = $type == 'hbox' ? 'horizontal' : ($type == 'box' ? false : 'vertical');
1767
-				for ($n = 1; $n <= (int) $num; ++$n)
1765
+				for ($n = 1; $n <= (int)$num; ++$n)
1768 1766
 				{
1769
-					$child = $cell[$n];	// first param is a var_param now!
1770
-					$h = $this->show_cell($child,$content,$readonlys,$cname,$show_c,$show_row,$nul,$cl,$path.'/'.$n);
1767
+					$child = $cell[$n]; // first param is a var_param now!
1768
+					$h = $this->show_cell($child, $content, $readonlys, $cname, $show_c, $show_row, $nul, $cl, $path.'/'.$n);
1771 1769
 					if ($h != '' && $h != '&nbsp;' || $keep_empty)
1772 1770
 					{
1773 1771
 						if ($orient != 'horizontal')
@@ -1780,7 +1778,7 @@  discard block
 block discarded – undo
1780 1778
 						}
1781 1779
 						if (!$orient)
1782 1780
 						{
1783
-							$html .= $cl ? html::div($h," class=\"$cl\"") : $h;
1781
+							$html .= $cl ? html::div($h, " class=\"$cl\"") : $h;
1784 1782
 						}
1785 1783
 						else
1786 1784
 						{
@@ -1789,18 +1787,18 @@  discard block
 block discarded – undo
1789 1787
 						$box_anz++;
1790 1788
 						if ($cell[$n]['align'])
1791 1789
 						{
1792
-							$rows[$box_row]['.'.$box_col] = html::formatOptions($child['align'],'align');
1790
+							$rows[$box_row]['.'.$box_col] = html::formatOptions($child['align'], 'align');
1793 1791
 							$sub_cell_has_align = true;
1794 1792
 						}
1795 1793
 						if (strlen($child['onclick']) > 1)
1796 1794
 						{
1797
-							$rows[$box_row]['.'.$box_col] .= ' onclick="'.$this->js_pseudo_funcs($child['onclick'],$cname).'"'.
1798
-								self::get_id('',$child['name'],$child['id']);
1795
+							$rows[$box_row]['.'.$box_col] .= ' onclick="'.$this->js_pseudo_funcs($child['onclick'], $cname).'"'.
1796
+								self::get_id('', $child['name'], $child['id']);
1799 1797
 						}
1800 1798
 						// allow to set further attributes in the tablecell, beside the class
1801 1799
 						if (is_array($cl))
1802 1800
 						{
1803
-							foreach($cl as $attr => $val)
1801
+							foreach ($cl as $attr => $val)
1804 1802
 							{
1805 1803
 								if ($attr != 'class' && $val)
1806 1804
 								{
@@ -1810,22 +1808,22 @@  discard block
 block discarded – undo
1810 1808
 							$cl = $cl['class'];
1811 1809
 						}
1812 1810
 						$box_item_class = $this->expand_name(isset(self::$class_conf[$cl]) ? self::$class_conf[$cl] : $cl,
1813
-							$show_c,$show_row,$content['.c'],$content['.row'],$content);
1814
-						$rows[$box_row]['.'.$box_col] .= html::formatOptions($box_item_class,'class');
1811
+							$show_c, $show_row, $content['.c'], $content['.row'], $content);
1812
+						$rows[$box_row]['.'.$box_col] .= html::formatOptions($box_item_class, 'class');
1815 1813
 					}
1816 1814
 				}
1817 1815
 				if ($box_anz > 1 && $orient)	// a single cell is NOT placed into a table
1818 1816
 				{
1819
-					$html = html::table($rows,html::formatOptions($cell_options,',,cellpadding,cellspacing').
1820
-						($type != 'groupbox' ? html::formatOptions($class,'class').
1821
-							 ($cell['name'] ? self::get_id($form_name,$cell['name'],$cell['id']) : '') : '').
1822
-						($cell['align'] && $orient != 'horizontal' || $sub_cell_has_align ? ' width="100%"' : ''));	// alignment only works if table has full width
1823
-					if ($type != 'groupbox') $class = '';	// otherwise we create an extra div
1817
+					$html = html::table($rows, html::formatOptions($cell_options, ',,cellpadding,cellspacing').
1818
+						($type != 'groupbox' ? html::formatOptions($class, 'class').
1819
+							 ($cell['name'] ? self::get_id($form_name, $cell['name'], $cell['id']) : '') : '').
1820
+						($cell['align'] && $orient != 'horizontal' || $sub_cell_has_align ? ' width="100%"' : '')); // alignment only works if table has full width
1821
+					if ($type != 'groupbox') $class = ''; // otherwise we create an extra div
1824 1822
 				}
1825 1823
 				// put the class of the box-cell, into the the class of this cell
1826 1824
 				elseif ($box_item_class && $box_anz == 1)
1827 1825
 				{
1828
-					$class = ($class ? $class . ' ' : '') . $box_item_class;
1826
+					$class = ($class ? $class.' ' : '').$box_item_class;
1829 1827
 					// if we have onclick or tooltip, add it to an extra div around single cell
1830 1828
 					if (!empty($rows[$box_row]['.'.$box_col])) $html = html::div($html, $rows[$box_row]['.'.$box_col]);
1831 1829
 				}
@@ -1835,19 +1833,19 @@  discard block
 block discarded – undo
1835 1833
 					{
1836 1834
 						$label = lang($label);
1837 1835
 					}
1838
-					$html = html::fieldset($html,$label,self::get_id($form_name,$cell['name'],$cell['id']).
1836
+					$html = html::fieldset($html, $label, self::get_id($form_name, $cell['name'], $cell['id']).
1839 1837
 						($class ? ' class="'.$class.'"' : ''));
1840
-					$class = '';	// otherwise we create an extra div
1838
+					$class = ''; // otherwise we create an extra div
1841 1839
 				}
1842 1840
 				elseif (!$orient)
1843 1841
 				{
1844
-					if (strpos($html,'class="'.$class)) $class = '';	// dont add class a 2. time
1845
-					$html = html::div($html,html::formatOptions(array(
1842
+					if (strpos($html, 'class="'.$class)) $class = ''; // dont add class a 2. time
1843
+					$html = html::div($html, html::formatOptions(array(
1846 1844
 							$cell['height'],
1847 1845
 							$cell['width'],
1848 1846
 							$class,
1849
-						),'height,width,class').self::get_id($form_name,$cell['name'],$cell['id'])). ($html ? '' : '</div>');
1850
-					$class = '';	// otherwise we create an extra div
1847
+						), 'height,width,class').self::get_id($form_name, $cell['name'], $cell['id'])).($html ? '' : '</div>');
1848
+					$class = ''; // otherwise we create an extra div
1851 1849
 				}
1852 1850
 				if ($box_anz > 1)	// small docu in the html-source
1853 1851
 				{
@@ -1858,30 +1856,30 @@  discard block
 block discarded – undo
1858 1856
 				$extra_label = False;
1859 1857
 				break;
1860 1858
 			case 'deck':
1861
-				for ($n = 1; $n <= $cell_options && (empty($value) || $value != $cell[$n]['name']); ++$n) ;
1859
+				for ($n = 1; $n <= $cell_options && (empty($value) || $value != $cell[$n]['name']); ++$n);
1862 1860
 				if ($n > $cell_options)
1863 1861
 				{
1864 1862
 					$value = $cell[1]['name'];
1865 1863
 				}
1866 1864
 				if ($s_width = $cell['width'])
1867 1865
 				{
1868
-					$s_width = "width: $s_width".(substr($s_width,-1) != '%' ? 'px' : '').';';
1866
+					$s_width = "width: $s_width".(substr($s_width, -1) != '%' ? 'px' : '').';';
1869 1867
 				}
1870 1868
 				if ($s_height = $cell['height'])
1871 1869
 				{
1872
-					$s_height = "height: $s_height".(substr($s_height,-1) != '%' ? 'px' : '').';';
1870
+					$s_height = "height: $s_height".(substr($s_height, -1) != '%' ? 'px' : '').';';
1873 1871
 				}
1874
-				$html = html::input_hidden($form_name,$value);
1875
-				self::$request->set_to_process($form_name,$cell['type']);
1872
+				$html = html::input_hidden($form_name, $value);
1873
+				self::$request->set_to_process($form_name, $cell['type']);
1876 1874
 
1877 1875
 				for ($n = 1; $n <= $cell_options; ++$n)
1878 1876
 				{
1879
-					$child = $cell[$n];	// first param is a var_param now!
1880
-					$html .= html::div($this->show_cell($child,$content,$readonlys,$cname,$show_c,
1881
-						$show_row,$nul,$cl,$path.'/'.$n),html::formatOptions(array(
1877
+					$child = $cell[$n]; // first param is a var_param now!
1878
+					$html .= html::div($this->show_cell($child, $content, $readonlys, $cname, $show_c,
1879
+						$show_row, $nul, $cl, $path.'/'.$n), html::formatOptions(array(
1882 1880
 						'display: '.($value == $child['name'] ? 'inline' : 'none').';',
1883 1881
 						$child['name']
1884
-					),'style,id'));
1882
+					), 'style,id'));
1885 1883
 				}
1886 1884
 				break;
1887 1885
 			case 'colorpicker':
@@ -1891,9 +1889,9 @@  discard block
 block discarded – undo
1891 1889
 				}
1892 1890
 				else
1893 1891
 				{
1894
-					$html = html::inputColor($form_name,$value,$cell['help']);
1892
+					$html = html::inputColor($form_name, $value, $cell['help']);
1895 1893
 
1896
-					self::$request->set_to_process($form_name,$cell['type'],array(
1894
+					self::$request->set_to_process($form_name, $cell['type'], array(
1897 1895
 							'maxlength' => 7,
1898 1896
 							'needed'    => $cell['needed'],
1899 1897
 							'preg'      => '/^(#[0-9a-f]{6}|)$/i',
@@ -1901,9 +1899,9 @@  discard block
 block discarded – undo
1901 1899
 				}
1902 1900
 				break;
1903 1901
 			default:
1904
-				if ($ext_type && $this->haveExtension($ext_type,'render'))
1902
+				if ($ext_type && $this->haveExtension($ext_type, 'render'))
1905 1903
 				{
1906
-					$html .= $this->extensionRender($ext_type,$form_name,$value,$cell,$readonly);
1904
+					$html .= $this->extensionRender($ext_type, $form_name, $value, $cell, $readonly);
1907 1905
 				}
1908 1906
 				else
1909 1907
 				{
@@ -1912,16 +1910,16 @@  discard block
 block discarded – undo
1912 1910
 				break;
1913 1911
 		}
1914 1912
 		// extension-processing need to be after all other and only with diff. name
1915
-		if ($ext_type && !$readonly && $this->haveExtension($ext_type,'post_process'))
1913
+		if ($ext_type && !$readonly && $this->haveExtension($ext_type, 'post_process'))
1916 1914
 		{	// unset it first, if it is already set, to be after the other widgets of the ext.
1917 1915
 			$to_process = self::$request->get_to_process($form_name);
1918 1916
 			self::$request->unset_to_process($form_name);
1919
-			self::$request->set_to_process($form_name,'ext-'.$ext_type,$to_process);
1917
+			self::$request->set_to_process($form_name, 'ext-'.$ext_type, $to_process);
1920 1918
 		}
1921 1919
 		// save blur-value to strip it in process_exec
1922 1920
 		if (!empty($blur) && self::$request->isset_to_process($form_name))
1923 1921
 		{
1924
-			self::$request->set_to_process_attribute($form_name,'blur',$blur);
1922
+			self::$request->set_to_process_attribute($form_name, 'blur', $blur);
1925 1923
 		}
1926 1924
 		if ($extra_label && ($label != '' || $html == ''))
1927 1925
 		{
@@ -1930,52 +1928,52 @@  discard block
 block discarded – undo
1930 1928
 				$label = lang($label);
1931 1929
 			}
1932 1930
 			$accesskey = false;
1933
-			if (($accesskey = $label && strpos($label,'&')!==false) && $accesskey[1] != ' ' && $form_name != '' &&
1934
-					(($pos = strpos($accesskey,';')) === false || $pos > 5))
1931
+			if (($accesskey = $label && strpos($label, '&') !== false) && $accesskey[1] != ' ' && $form_name != '' &&
1932
+					(($pos = strpos($accesskey, ';')) === false || $pos > 5))
1935 1933
 			{
1936
-				$label = str_replace('&'.$accesskey[1],'<u>'.$accesskey[1].'</u>',$label);
1934
+				$label = str_replace('&'.$accesskey[1], '<u>'.$accesskey[1].'</u>', $label);
1937 1935
 				$accesskey = $accesskey[1];
1938 1936
 			}
1939 1937
 			if ($label && !$readonly && ($accesskey || $label_for || $type != 'label' && $cell['name']))
1940 1938
 			{
1941 1939
 				if ($label_for)		// if label_for starts with a '#', it is already an id - no need to create default id from it
1942 1940
 				{
1943
-					$label_for = $label_for[0] == '#' ? substr($label_for,1) : self::form_name($cname,$label_for);
1941
+					$label_for = $label_for[0] == '#' ? substr($label_for, 1) : self::form_name($cname, $label_for);
1944 1942
 				}
1945 1943
 				else
1946 1944
 				{
1947
-					$label_for = $form_name.($set_val?"[$set_val]":'');
1945
+					$label_for = $form_name.($set_val ? "[$set_val]" : '');
1948 1946
 				}
1949
-				$label = html::label($label,$label_for,$accesskey);
1947
+				$label = html::label($label, $label_for, $accesskey);
1950 1948
 			}
1951
-			if ($type == 'radio' || $type == 'checkbox' || $label && strpos($label,'%s')!==false)	// default for radio is label after the button
1949
+			if ($type == 'radio' || $type == 'checkbox' || $label && strpos($label, '%s') !== false)	// default for radio is label after the button
1952 1950
 			{
1953
-				$html = strpos($label,'%s')!==false ? str_replace('%s',$html,$label) : $html.' '.$label;
1951
+				$html = strpos($label, '%s') !== false ? str_replace('%s', $html, $label) : $html.' '.$label;
1954 1952
 			}
1955
-			elseif (($html = $label . ' ' . $html) == ' ')
1953
+			elseif (($html = $label.' '.$html) == ' ')
1956 1954
 			{
1957 1955
 				$html = '&nbsp;';
1958 1956
 			}
1959 1957
 		}
1960
-		if ($extra_link && (($extra_link = $this->expand_name($extra_link,$show_c,$show_row,$content['.c'],$content['.row'],$content))))
1958
+		if ($extra_link && (($extra_link = $this->expand_name($extra_link, $show_c, $show_row, $content['.c'], $content['.row'], $content))))
1961 1959
 		{
1962
-			$options = $help ? ' onmouseover="self.status=\''.addslashes(html::htmlspecialchars($help)).'\'; return true;"' .
1960
+			$options = $help ? ' onmouseover="self.status=\''.addslashes(html::htmlspecialchars($help)).'\'; return true;"'.
1963 1961
 				' onmouseout="self.status=\'\'; return true;"' : '';
1964 1962
 
1965
-			if ($extra_link_target && (($extra_link_target = $this->expand_name($extra_link_target,$show_c,$show_row,$content['.c'],$content['.row'],$content))))
1963
+			if ($extra_link_target && (($extra_link_target = $this->expand_name($extra_link_target, $show_c, $show_row, $content['.c'], $content['.row'], $content))))
1966 1964
 			{
1967 1965
 				$options .= ' target="'.addslashes($extra_link_target).'"';
1968 1966
 			}
1969
-			if ($extra_link_popup && (($extra_link_popup = $this->expand_name($extra_link_popup,$show_c,$show_row,$content['.c'],$content['.row'],$content))))
1967
+			if ($extra_link_popup && (($extra_link_popup = $this->expand_name($extra_link_popup, $show_c, $show_row, $content['.c'], $content['.row'], $content))))
1970 1968
 			{
1971
-				list($w,$h) = explode('x',$extra_link_popup);
1969
+				list($w, $h) = explode('x', $extra_link_popup);
1972 1970
 				$options .= ' onclick="egw(window).openPopup(this,'.(int)$w.','.(int)$h.',this.target); return false;"';
1973 1971
 			}
1974 1972
 			if ($extra_link_title)
1975 1973
 			{
1976 1974
 				$options .= ' title="'.addslashes($extra_link_title).'"';
1977 1975
 			}
1978
-			return html::a_href($html,$extra_link,'',$options);
1976
+			return html::a_href($html, $extra_link, '', $options);
1979 1977
 		}
1980 1978
 		// if necessary show validation-error behind field
1981 1979
 		if (isset(self::$validation_errors[$form_name]))
@@ -1986,13 +1984,13 @@  discard block
 block discarded – undo
1986 1984
 		//echo "<p>$this->name($this->onclick_handler:$this->no_onclick:$this->onclick_proxy): $cell[type]/$cell[name]</p>\n";
1987 1985
 		if ($this->onclick_handler && !isset(self::$widgets_with_children[$cell['type']]))
1988 1986
 		{
1989
-			$handler = str_replace('%p',$this->no_onclick ? $this->onclick_proxy : $this->name.':'.$this->version.':'.$path,
1987
+			$handler = str_replace('%p', $this->no_onclick ? $this->onclick_proxy : $this->name.':'.$this->version.':'.$path,
1990 1988
 				$this->onclick_handler);
1991 1989
 			if ($type == 'button' || $type == 'buttononly' || !$label)	// add something to click on
1992 1990
 			{
1993
-				$html = (substr($html,-1) == "\n" ? substr($html,0,-1) : $html).'&nbsp;';
1991
+				$html = (substr($html, -1) == "\n" ? substr($html, 0, -1) : $html).'&nbsp;';
1994 1992
 			}
1995
-			return html::div($html,' ondblclick="'.$handler.'"','clickWidgetToEdit');
1993
+			return html::div($html, ' ondblclick="'.$handler.'"', 'clickWidgetToEdit');
1996 1994
 		}
1997 1995
 		return $html;
1998 1996
 	}
@@ -2013,13 +2011,13 @@  discard block
 block discarded – undo
2013 2011
 	 * @param string $id=null
2014 2012
 	 * @return string ' id="..."' or '' if no id found
2015 2013
 	 */
2016
-	static public function get_id($form_name,$name=null,$id=null)
2014
+	static public function get_id($form_name, $name = null, $id = null)
2017 2015
 	{
2018 2016
 		if (empty($id))
2019 2017
 		{
2020 2018
 			if ($name[0] == '#')
2021 2019
 			{
2022
-				$id = substr($name,1);
2020
+				$id = substr($name, 1);
2023 2021
 			}
2024 2022
 			else
2025 2023
 			{
@@ -2042,9 +2040,9 @@  discard block
 block discarded – undo
2042 2040
 	 * @param boolean $readonly=true
2043 2041
 	 * @return string
2044 2042
 	 */
2045
-	static public function number_format($number,$num_decimal_places=2,$readonly=true)
2043
+	static public function number_format($number, $num_decimal_places = 2, $readonly = true)
2046 2044
 	{
2047
-		static $dec_separator,$thousands_separator;
2045
+		static $dec_separator, $thousands_separator;
2048 2046
 		if (is_null($dec_separator))
2049 2047
 		{
2050 2048
 			$dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0];
@@ -2053,9 +2051,9 @@  discard block
 block discarded – undo
2053 2051
 		}
2054 2052
 		if ((string)$number === '') return '';
2055 2053
 
2056
-		$ret = number_format(str_replace(' ','',$number), $num_decimal_places,
2054
+		$ret = number_format(str_replace(' ', '', $number), $num_decimal_places,
2057 2055
 			// need to use '.' as decimal separator for all browser supporting html5 input type=number
2058
-			$dec_sep_used=$readonly || !in_array(html::$user_agent, array('chrome', 'safari', 'opera')) ?
2056
+			$dec_sep_used = $readonly || !in_array(html::$user_agent, array('chrome', 'safari', 'opera')) ?
2059 2057
 				$dec_separator : '.',
2060 2058
 			$readonly ? $thousands_separator : '');
2061 2059
 		//error_log(__METHOD__."($number, $num_decimal_places, $readonly) html::user_agent=".html::$user_agent.", dec_sep='$dec_separator' --> '$dec_sep_used', thousands_sep='$thousands_separator' returning '$ret'");
@@ -2070,7 +2068,7 @@  discard block
 block discarded – undo
2070 2068
 	* @param array $content=array();
2071 2069
 	* @return array
2072 2070
 	*/
2073
-	function _sel_options($cell,$name,$content=array())
2071
+	function _sel_options($cell, $name, $content = array())
2074 2072
 	{
2075 2073
 		$sels = array();
2076 2074
 
@@ -2078,10 +2076,10 @@  discard block
 block discarded – undo
2078 2076
 		{
2079 2077
 			if (!is_array($cell['sel_options']))
2080 2078
 			{
2081
-				$opts = explode(',',$cell['sel_options']);
2079
+				$opts = explode(',', $cell['sel_options']);
2082 2080
 				while (list(,$opt) = each($opts))
2083 2081
 				{
2084
-					list($k,$v) = explode('=',$opt);
2082
+					list($k, $v) = explode('=', $opt);
2085 2083
 					$sels[$k] = $v;
2086 2084
 				}
2087 2085
 			}
@@ -2094,7 +2092,7 @@  discard block
 block discarded – undo
2094 2092
 		if (($options = $this->sel_options[$name]) && is_array($options) ||
2095 2093
 			($options = self::get_array($this->sel_options, $name)) && is_array($options))
2096 2094
 		{
2097
-			if(count($options) == 2 && $options['label'] && $options['title'])
2095
+			if (count($options) == 2 && $options['label'] && $options['title'])
2098 2096
 			{
2099 2097
 				// In too far - need to back up
2100 2098
 			}
@@ -2104,12 +2102,12 @@  discard block
 block discarded – undo
2104 2102
 				$explode_needed = false;
2105 2103
 			}
2106 2104
 		}
2107
-		if($explode_needed)
2105
+		if ($explode_needed)
2108 2106
 		{
2109
-			$name_parts = explode('[',str_replace(']','',$name));
2107
+			$name_parts = explode('[', str_replace(']', '', $name));
2110 2108
 			if (count($name_parts))
2111 2109
 			{
2112
-				$org_name = $name_parts[count($name_parts)-1];
2110
+				$org_name = $name_parts[count($name_parts) - 1];
2113 2111
 				if (isset($this->sel_options[$org_name]) && is_array($this->sel_options[$org_name]))
2114 2112
 				{
2115 2113
 					$sels += $this->sel_options[$org_name];
@@ -2141,67 +2139,67 @@  discard block
 block discarded – undo
2141 2139
 	* @param string $cname name-prefix / name-space
2142 2140
 	* @return string
2143 2141
 	*/
2144
-	function js_pseudo_funcs($on,$cname)
2142
+	function js_pseudo_funcs($on, $cname)
2145 2143
 	{
2146
-		if (strpos($on,'::') !== false)	// avoid the expensive regular expresions, for performance reasons
2144
+		if (strpos($on, '::') !== false)	// avoid the expensive regular expresions, for performance reasons
2147 2145
 		{
2148
-			if (preg_match_all("/egw::link\\('([^']+)','(.+?)'(?:,'(.+?)')?\\)/",$on,$matches))	// the ? alters the expression to shortest match
2146
+			if (preg_match_all("/egw::link\\('([^']+)','(.+?)'(?:,'(.+?)')?\\)/", $on, $matches))	// the ? alters the expression to shortest match
2149 2147
 			{
2150
-				foreach(array_keys($matches[1]) as $n)                         	// this way we can correctly parse ' in the 2. argument
2148
+				foreach (array_keys($matches[1]) as $n)                         	// this way we can correctly parse ' in the 2. argument
2151 2149
 				{
2152
-					$url = $GLOBALS['egw']->link($matches[1][$n],$matches[2][$n],$matches[3][$n]);
2153
-					$on = str_replace($matches[0][$n],'\''.addslashes($url).'\'',$on);
2150
+					$url = $GLOBALS['egw']->link($matches[1][$n], $matches[2][$n], $matches[3][$n]);
2151
+					$on = str_replace($matches[0][$n], '\''.addslashes($url).'\'', $on);
2154 2152
 				}
2155 2153
 			}
2156 2154
 
2157
-			if (preg_match_all("/form::name\\('([^']+)'\\)/",$on,$matches))
2155
+			if (preg_match_all("/form::name\\('([^']+)'\\)/", $on, $matches))
2158 2156
 			{
2159
-				foreach($matches[1] as $n => $matche_name)
2157
+				foreach ($matches[1] as $n => $matche_name)
2160 2158
 				{
2161
-					$matches[1][$n] = '\''.self::form_name($cname,$matche_name).'\'';
2159
+					$matches[1][$n] = '\''.self::form_name($cname, $matche_name).'\'';
2162 2160
 				}
2163
-				$on = str_replace($matches[0],$matches[1],$on);
2161
+				$on = str_replace($matches[0], $matches[1], $on);
2164 2162
 			}
2165 2163
 			// we need to search ungready (shortest possible match), to avoid catching to much
2166
-			if (preg_match_all('/egw::lang\(["\']{1}(.*)["\']{1}\)/U',$on,$matches)) {
2167
-				foreach($matches[1] as $n => $string) {
2164
+			if (preg_match_all('/egw::lang\(["\']{1}(.*)["\']{1}\)/U', $on, $matches)) {
2165
+				foreach ($matches[1] as $n => $string) {
2168 2166
 					$str = lang($string);
2169
-					$on = str_replace($matches[0][$n],'\''.addslashes($str).'\'',$on);
2167
+					$on = str_replace($matches[0][$n], '\''.addslashes($str).'\'', $on);
2170 2168
 				}
2171 2169
 			}
2172 2170
 
2173 2171
 			// inserts the styles of a named template
2174
-			if (preg_match('/template::styles\(["\']{1}(.*)["\']{1}\)/U',$on,$matches))
2172
+			if (preg_match('/template::styles\(["\']{1}(.*)["\']{1}\)/U', $on, $matches))
2175 2173
 			{
2176 2174
 				$tpl = $matches[1] == $this->name ? $this : new etemplate($matches[1]);
2177
-				$on = str_replace($matches[0],"'<style>".str_replace(array("\n","\r"),'',$tpl->style)."</style>'",$on);
2175
+				$on = str_replace($matches[0], "'<style>".str_replace(array("\n", "\r"), '', $tpl->style)."</style>'", $on);
2178 2176
 			}
2179 2177
 		}
2180 2178
 
2181 2179
 		// translate messages in confirm()
2182
-		if (strpos($on,'confirm(') !== false && preg_match('/confirm\(["\']{1}(.*)["\']{1}\)/U',$on,$matches))
2180
+		if (strpos($on, 'confirm(') !== false && preg_match('/confirm\(["\']{1}(.*)["\']{1}\)/U', $on, $matches))
2183 2181
 		{
2184
-			$question = lang($matches[1]).(substr($matches[1],-1) != '?' ? '?' : '');	// add ? if not there, saves extra phrase
2185
-			$on = str_replace($matches[0],'confirm(\''.str_replace("'","\\'",$question).'\')',$on);
2182
+			$question = lang($matches[1]).(substr($matches[1], -1) != '?' ? '?' : ''); // add ? if not there, saves extra phrase
2183
+			$on = str_replace($matches[0], 'confirm(\''.str_replace("'", "\\'", $question).'\')', $on);
2186 2184
 		}
2187 2185
 
2188 2186
 		// replace window.open() with EGw's egw(window).openPopup()
2189
-		if (strpos($on,'window.open(') !== false && preg_match("/window.open\('(.*)','(.*)','dependent=yes,width=([^,]*),height=([^,]*),scrollbars=yes,status=(.*)'\)/",$on,$matches))
2187
+		if (strpos($on, 'window.open(') !== false && preg_match("/window.open\('(.*)','(.*)','dependent=yes,width=([^,]*),height=([^,]*),scrollbars=yes,status=(.*)'\)/", $on, $matches))
2190 2188
 		{
2191 2189
 			$on = str_replace($matches[0], "egw(window).openPopup('$matches[1]', $matches[3], $matches[4], '$matches[2]', false, false, '$matches[5]')", $on);
2192 2190
 		}
2193 2191
 
2194 2192
 		// replace window.close() with EGw's egw.close()
2195
-		if (strpos($on,'window.close(') !== false)
2193
+		if (strpos($on, 'window.close(') !== false)
2196 2194
 		{
2197 2195
 			$on = str_replace('window.close(', 'egw(window).close(', $on);
2198 2196
 		}
2199 2197
 
2200 2198
 		// replace xajax calls to code in widgets, with the "etemplate" handler,
2201 2199
 		// this allows to call widgets with the current app, otherwise everyone would need etemplate run rights
2202
-		if (strpos($on,"xajax_doXMLHTTP('etemplate.") !== false)
2200
+		if (strpos($on, "xajax_doXMLHTTP('etemplate.") !== false)
2203 2201
 		{
2204
-			$on = preg_replace("/^xajax_doXMLHTTP\('etemplate\.([a-z]+_widget\.[a-zA-Z0-9_]+)\'/",'xajax_doXMLHTTP(\''.$GLOBALS['egw_info']['flags']['currentapp'].'.\\1.etemplate\'',$on);
2202
+			$on = preg_replace("/^xajax_doXMLHTTP\('etemplate\.([a-z]+_widget\.[a-zA-Z0-9_]+)\'/", 'xajax_doXMLHTTP(\''.$GLOBALS['egw_info']['flags']['currentapp'].'.\\1.etemplate\'', $on);
2205 2203
 		}
2206 2204
 
2207 2205
 		return $on;
@@ -2219,7 +2217,7 @@  discard block
 block discarded – undo
2219 2217
 		{
2220 2218
 			return stripslashes($var);
2221 2219
 		}
2222
-		foreach($var as $key => $val)
2220
+		foreach ($var as $key => $val)
2223 2221
 		{
2224 2222
 			$var[$key] = is_array($val) ? self::array_stripslashes($val) : stripslashes($val);
2225 2223
 		}
@@ -2239,7 +2237,7 @@  discard block
 block discarded – undo
2239 2237
 	* @param string $_type='regular' type of request
2240 2238
 	* @return array with validation errors
2241 2239
 	*/
2242
-	function process_show(&$content,$to_process,$cname='',$_type='regular')
2240
+	function process_show(&$content, $to_process, $cname = '', $_type = 'regular')
2243 2241
 	{
2244 2242
 		if (!isset($content) || !is_array($content) || !is_array($to_process))
2245 2243
 		{
@@ -2258,7 +2256,7 @@  discard block
 block discarded – undo
2258 2256
 		self::$validation_errors = array();
2259 2257
 		$this->canceled = $this->button_pressed = False;
2260 2258
 
2261
-		foreach($to_process as $form_name => $type)
2259
+		foreach ($to_process as $form_name => $type)
2262 2260
 		{
2263 2261
 			if (is_array($type))
2264 2262
 			{
@@ -2269,45 +2267,45 @@  discard block
 block discarded – undo
2269 2267
 			{
2270 2268
 				$attr = array();
2271 2269
 			}
2272
-			$form_name = str_replace(array('&#x5B;','&#x5D;'), array('[',']'), $form_name);
2273
-			$value = self::get_array($content_in,$form_name,True,$GLOBALS['egw_info']['flags']['currentapp'] == 'etemplate' ? false : true );
2270
+			$form_name = str_replace(array('&#x5B;', '&#x5D;'), array('[', ']'), $form_name);
2271
+			$value = self::get_array($content_in, $form_name, True, $GLOBALS['egw_info']['flags']['currentapp'] == 'etemplate' ? false : true);
2274 2272
 			// The comment below does only aplay to normal posts, not for xajax. Files are not supported anyway by xajax atm.
2275 2273
 			// not checked checboxes are not returned in HTML and file is in $_FILES and not in $content_in
2276
-			if($value === false && $_type == 'xajaxResponse' /*!in_array($type,array('checkbox','file'))*/) continue;
2274
+			if ($value === false && $_type == 'xajaxResponse' /*!in_array($type,array('checkbox','file'))*/) continue;
2277 2275
 
2278 2276
 			if (isset($attr['blur']) && $attr['blur'] == $value)
2279 2277
 			{
2280
-				$value = '';	// blur-values is equal to emtpy
2278
+				$value = ''; // blur-values is equal to emtpy
2281 2279
 			}
2282 2280
 			//echo "<p>process_show($this->name) loop was ".self::$loop.", $type: $form_name = ".array2string($value)."</p>\n";
2283
-			if (is_string($type)) list($type,$sub) = explode('-',$type);
2281
+			if (is_string($type)) list($type, $sub) = explode('-', $type);
2284 2282
 			switch ($type)
2285 2283
 			{
2286 2284
 				case 'ext':
2287
-					$_cont = &self::get_array($content,$form_name,True);
2288
-					if (!$this->extensionPostProcess($sub,$form_name,$_cont,$value))
2285
+					$_cont = &self::get_array($content, $form_name, True);
2286
+					if (!$this->extensionPostProcess($sub, $form_name, $_cont, $value))
2289 2287
 					{
2290 2288
 						//echo "\n<p><b>unsetting content[$form_name] !!!</b></p>\n";
2291
-						$this->unset_array($content,$form_name);
2289
+						$this->unset_array($content, $form_name);
2292 2290
 					}
2293 2291
 					// this else should NOT be unnecessary as $_cont is a reference to the index
2294 2292
 					// $form_name of $content, but under some circumstances a set/changed $_cont
2295 2293
 					// does not result in a change in $content -- RalfBecker 2004/09/18
2296 2294
 					// seems to depend on the number of (not existing) dimensions of the array -- -- RalfBecker 2005/04/06
2297
-					elseif (!self::isset_array($content,$form_name))
2295
+					elseif (!self::isset_array($content, $form_name))
2298 2296
 					{
2299 2297
 						//echo "<p>setting content[$form_name]='$_cont' because is was unset !!!</p>\n";
2300
-						self::set_array($content,$form_name,$_cont);
2298
+						self::set_array($content, $form_name, $_cont);
2301 2299
 					}
2302 2300
 					if ($_cont === '' && $attr['needed'] && !$attr['blur'])
2303 2301
 					{
2304
-						self::set_validation_error($form_name,lang('Field must not be empty !!!'),'');
2302
+						self::set_validation_error($form_name, lang('Field must not be empty !!!'), '');
2305 2303
 					}
2306 2304
 					break;
2307 2305
 				case 'htmlarea':
2308 2306
 					if ($attr['mode'] !== 'ascii')
2309 2307
 					{
2310
-						self::set_array($content,$form_name,html::purify($value));
2308
+						self::set_array($content, $form_name, html::purify($value));
2311 2309
 						break;
2312 2310
 					}
2313 2311
 					// fall-throught for mode 'ascii', which is identical to textarea
@@ -2322,25 +2320,25 @@  discard block
 block discarded – undo
2322 2320
 				case 'colorpicker':
2323 2321
 					if ((string)$value === '' && $attr['needed'] && !$attr['blur'])
2324 2322
 					{
2325
-						self::set_validation_error($form_name,lang('Field must not be empty !!!'),'');
2323
+						self::set_validation_error($form_name, lang('Field must not be empty !!!'), '');
2326 2324
 					}
2327
-					if ((int) $attr['maxlength'] > 0 && mb_strlen($value) > (int) $attr['maxlength'])
2325
+					if ((int)$attr['maxlength'] > 0 && mb_strlen($value) > (int)$attr['maxlength'])
2328 2326
 					{
2329
-						$value = mb_substr($value,0,(int) $attr['maxlength']);
2327
+						$value = mb_substr($value, 0, (int)$attr['maxlength']);
2330 2328
 					}
2331
-					if ($attr['preg'] && !preg_match($attr['preg'],$value))
2329
+					if ($attr['preg'] && !preg_match($attr['preg'], $value))
2332 2330
 					{
2333
-						switch($type)
2331
+						switch ($type)
2334 2332
 						{
2335 2333
 							case 'int':
2336 2334
 							case 'integer':
2337
-								self::set_validation_error($form_name,lang("'%1' is not a valid integer !!!",$value),'');
2335
+								self::set_validation_error($form_name, lang("'%1' is not a valid integer !!!", $value), '');
2338 2336
 								break;
2339 2337
 							case 'float':
2340
-								self::set_validation_error($form_name,lang("'%1' is not a valid floatingpoint number !!!",$value),'');
2338
+								self::set_validation_error($form_name, lang("'%1' is not a valid floatingpoint number !!!", $value), '');
2341 2339
 								break;
2342 2340
 							default:
2343
-								self::set_validation_error($form_name,lang("'%1' has an invalid format !!!",$value)/*." !preg_match('$attr[preg]', '$value')"*/,'');
2341
+								self::set_validation_error($form_name, lang("'%1' has an invalid format !!!", $value)/*." !preg_match('$attr[preg]', '$value')"*/, '');
2344 2342
 								break;
2345 2343
 						}
2346 2344
 					}
@@ -2348,101 +2346,101 @@  discard block
 block discarded – undo
2348 2346
 					{
2349 2347
 						if ((string)$value !== '' || $attr['needed'])	// empty values are Ok if needed is not set
2350 2348
 						{
2351
-							$value = $type != 'float' ? (int) $value : (float) str_replace(',','.',$value);	// allow for german (and maybe other) format
2349
+							$value = $type != 'float' ? (int)$value : (float)str_replace(',', '.', $value); // allow for german (and maybe other) format
2352 2350
 
2353 2351
 							if (!empty($attr['min']) && $value < $attr['min'])
2354 2352
 							{
2355
-								self::set_validation_error($form_name,lang("Value has to be at least '%1' !!!",$attr['min']),'');
2356
-								$value = $type != 'float' ? (int) $attr['min'] : (float) $attr['min'];
2353
+								self::set_validation_error($form_name, lang("Value has to be at least '%1' !!!", $attr['min']), '');
2354
+								$value = $type != 'float' ? (int)$attr['min'] : (float)$attr['min'];
2357 2355
 							}
2358 2356
 							if (!empty($attr['max']) && $value > $attr['max'])
2359 2357
 							{
2360
-								self::set_validation_error($form_name,lang("Value has to be at maximum '%1' !!!",$attr['max']),'');
2361
-								$value = $type != 'float' ? (int) $attr['max'] : (float) $attr['max'];
2358
+								self::set_validation_error($form_name, lang("Value has to be at maximum '%1' !!!", $attr['max']), '');
2359
+								$value = $type != 'float' ? (int)$attr['max'] : (float)$attr['max'];
2362 2360
 							}
2363 2361
 						}
2364 2362
 					}
2365
-					self::set_array($content,$form_name,$value);
2363
+					self::set_array($content, $form_name, $value);
2366 2364
 					break;
2367 2365
 				case 'cancel':	// cancel button ==> dont care for validation errors
2368 2366
 					if ($value)
2369 2367
 					{
2370 2368
 						$this->canceled = True;
2371
-						self::set_array($content,$form_name,$value);
2369
+						self::set_array($content, $form_name, $value);
2372 2370
 					}
2373 2371
 					break;
2374 2372
 				case 'button':
2375 2373
 					if ($value)
2376 2374
 					{
2377 2375
 						$this->button_pressed = True;
2378
-						self::set_array($content,$form_name,$value);
2376
+						self::set_array($content, $form_name, $value);
2379 2377
 					}
2380 2378
 					break;
2381 2379
 				case 'select':
2382 2380
 					if ($attr['allowed'])	// only check for $value is allowed, if allowed values are set
2383 2381
 					{
2384
-						foreach(is_array($value) ? $value : array($value) as $val)
2382
+						foreach (is_array($value) ? $value : array($value) as $val)
2385 2383
 						{
2386
-							if (!($attr['multiple'] && !$val) && !in_array($val,$attr['allowed']))
2384
+							if (!($attr['multiple'] && !$val) && !in_array($val, $attr['allowed']))
2387 2385
 							{
2388
-								self::set_validation_error($form_name,lang("'%1' is NOT allowed ('%2')!",$val,implode("','",$attr['allowed'])),'');
2386
+								self::set_validation_error($form_name, lang("'%1' is NOT allowed ('%2')!", $val, implode("','", $attr['allowed'])), '');
2389 2387
 								$value = '';
2390 2388
 								break;
2391 2389
 							}
2392 2390
 						}
2393 2391
 					}
2394
-					if (is_array($value)) $value = implode(',',$value);
2392
+					if (is_array($value)) $value = implode(',', $value);
2395 2393
 					if ($value === '' && $attr['needed'])
2396 2394
 					{
2397
-						self::set_validation_error($form_name,lang('Field must not be empty !!!',$value),'');
2395
+						self::set_validation_error($form_name, lang('Field must not be empty !!!', $value), '');
2398 2396
 					}
2399
-					self::set_array($content,$form_name,$value);
2397
+					self::set_array($content, $form_name, $value);
2400 2398
 					break;
2401 2399
 				case 'checkbox':
2402 2400
 					if (!$value && $attr['needed'])
2403 2401
 					{
2404
-						self::set_validation_error($form_name,lang('Field must not be empty !!!',$value),'');
2402
+						self::set_validation_error($form_name, lang('Field must not be empty !!!', $value), '');
2405 2403
 					}
2406 2404
 					if ($value === false)
2407 2405
 					{
2408
-						self::set_array($content,$form_name,$attr['multiple'] ? array() : $attr['unset_value']);	// need to be reported too
2406
+						self::set_array($content, $form_name, $attr['multiple'] ? array() : $attr['unset_value']); // need to be reported too
2409 2407
 					}
2410 2408
 					else
2411 2409
 					{
2412
-						$value = array_intersect(is_array($value) ? $value : array($value),$attr['values']); // return only allowed values
2413
-						self::set_array($content,$form_name,$attr['multiple'] ? $value : $value[0]);
2410
+						$value = array_intersect(is_array($value) ? $value : array($value), $attr['values']); // return only allowed values
2411
+						self::set_array($content, $form_name, $attr['multiple'] ? $value : $value[0]);
2414 2412
 					}
2415 2413
 					break;
2416 2414
 				case 'file':
2417
-					if (($multiple = substr($form_name,-2) == '[]'))
2415
+					if (($multiple = substr($form_name, -2) == '[]'))
2418 2416
 					{
2419
-						$form_name = substr($form_name,0,-2);
2417
+						$form_name = substr($form_name, 0, -2);
2420 2418
 					}
2421
-					$parts = explode('[',str_replace(']','',$form_name));
2419
+					$parts = explode('[', str_replace(']', '', $form_name));
2422 2420
 					$name = array_shift($parts);
2423
-					$index  = count($parts) ? '['.implode('][',$parts).']' : '';
2421
+					$index = count($parts) ? '['.implode('][', $parts).']' : '';
2424 2422
 					$value = array();
2425
-					for($i=0; $i < 100; ++$i)
2423
+					for ($i = 0; $i < 100; ++$i)
2426 2424
 					{
2427 2425
 						$file = array();
2428
-						foreach(array('tmp_name','type','size','name','error') as $part)
2426
+						foreach (array('tmp_name', 'type', 'size', 'name', 'error') as $part)
2429 2427
 						{
2430
-							if (!is_array($_FILES[$name])) break 2;	// happens eg. in forms set via xajax, which do not upload files
2431
-							$file[$part] = $this->get_array($_FILES[$name],$part.$index.($multiple ? "[$i]" : ''));
2428
+							if (!is_array($_FILES[$name])) break 2; // happens eg. in forms set via xajax, which do not upload files
2429
+							$file[$part] = $this->get_array($_FILES[$name], $part.$index.($multiple ? "[$i]" : ''));
2432 2430
 						}
2433
-						if (!$multiple) $file['path'] = $this->get_array($content_in,substr($form_name,0,-1).'_path]');
2431
+						if (!$multiple) $file['path'] = $this->get_array($content_in, substr($form_name, 0, -1).'_path]');
2434 2432
 						$file['ip'] = $_SERVER['REMOTE_ADDR'];
2435 2433
 						// check if we have an upload error
2436 2434
 						if ($file['error'] && $file['name'] !== '' && !$file['size'])	// ignore empty upload boxes
2437 2435
 						{
2438
-							self::set_validation_error($form_name.($multiple?'[]':''),
2439
-								lang('Error uploading file!')."\n".self::max_upload_size_message(),'');
2436
+							self::set_validation_error($form_name.($multiple ? '[]' : ''),
2437
+								lang('Error uploading file!')."\n".self::max_upload_size_message(), '');
2440 2438
 						}
2441 2439
 						if ((string)$file['name'] === '' || $file['tmp_name'] && function_exists('is_uploaded_file') && !is_uploaded_file($file['tmp_name']))
2442 2440
 						{
2443 2441
 							if ($multiple && ($file['name'] === '' || $file['error']))
2444 2442
 							{
2445
-								continue;	// ignore empty upload box
2443
+								continue; // ignore empty upload box
2446 2444
 							}
2447 2445
 							break;
2448 2446
 						}
@@ -2458,9 +2456,9 @@  discard block
 block discarded – undo
2458 2456
 				default:
2459 2457
 					if ($attr['needed'] && !$value)
2460 2458
 					{
2461
-						self::set_validation_error($form_name,lang('Field must not be empty !!!',$value),'');
2459
+						self::set_validation_error($form_name, lang('Field must not be empty !!!', $value), '');
2462 2460
 					}
2463
-					self::set_array($content,$form_name,$value);
2461
+					self::set_array($content, $form_name, $value);
2464 2462
 					break;
2465 2463
 			}
2466 2464
 		}
@@ -2486,11 +2484,11 @@  discard block
 block discarded – undo
2486 2484
 	* @param string|boolean $error error-message already translated or false to reset all existing error for given name
2487 2485
 	* @param string $cname=null set it to '', if the name is already a form-name, defaults to self::$name_vars
2488 2486
 	*/
2489
-	static function set_validation_error($name,$error,$cname=null)
2487
+	static function set_validation_error($name, $error, $cname = null)
2490 2488
 	{
2491 2489
 		if (is_null($cname)) $cname = self::$name_vars;
2492 2490
 		//echo "<p>self::set_validation_error('$name','$error','$cname');</p>\n";
2493
-		if ($cname) $name = self::form_name($cname,$name);
2491
+		if ($cname) $name = self::form_name($cname, $name);
2494 2492
 
2495 2493
 		if ($error === false)
2496 2494
 		{
Please login to merge, or discard this patch.
Braces   +417 added lines, -107 removed lines patch added patch discarded remove patch
@@ -243,7 +243,10 @@  discard block
 block discarded – undo
243 243
 		self::$request->name_vars = self::$name_vars;
244 244
 
245 245
 		// tell html5 form validation NOT to validate
246
-		if ($ignore_validation) self::$form_options .= ' novalidate="novalidate"';
246
+		if ($ignore_validation)
247
+		{
248
+			self::$form_options .= ' novalidate="novalidate"';
249
+		}
247 250
 
248 251
 		if((int) $output_mode == 3)
249 252
 		{
@@ -279,7 +282,10 @@  discard block
 block discarded – undo
279 282
 		self::$request->hooked = $hooked ? $hooked : self::$hook_content;
280 283
 		self::$request->hook_app = $hooked ? $GLOBALS['egw_info']['flags']['currentapp'] : self::$hook_app;
281 284
 		self::$request->app_header = $GLOBALS['egw_info']['flags']['app_header'];
282
-		if (self::$request->output_mode == -1) self::$request->output_mode = 0;
285
+		if (self::$request->output_mode == -1)
286
+		{
287
+			self::$request->output_mode = 0;
288
+		}
283 289
 		self::$request->template = $this->as_array(2);
284 290
 
285 291
 		$html = html::form(html::input('etemplate_exec_id',self::$request->id(),'hidden',' id="etemplate_exec_id"').$html.
@@ -298,13 +304,19 @@  discard block
 block discarded – undo
298 304
 		if (!$this->sitemgr)
299 305
 		{
300 306
 			// support the old global var, in case old apps like 1.6 infolog use it
301
-			if (isset($GLOBALS['egw_info']['etemplate']['hooked'])) self::$hooked = $GLOBALS['egw_info']['etemplate']['hooked'];
307
+			if (isset($GLOBALS['egw_info']['etemplate']['hooked']))
308
+			{
309
+				self::$hooked = $GLOBALS['egw_info']['etemplate']['hooked'];
310
+			}
302 311
 
303
-			if (!@self::$hooked && (int) $output_mode != 1 && (int) $output_mode != -1)	// not just returning the html
312
+			if (!@self::$hooked && (int) $output_mode != 1 && (int) $output_mode != -1)
313
+			{
314
+				// not just returning the html
304 315
 			{
305 316
 				if ($GLOBALS['egw_info']['flags']['currentapp'] != 'etemplate')
306 317
 				{
307 318
 					egw_framework::includeCSS('etemplate', 'app');
319
+			}
308 320
 				}
309 321
 			}
310 322
 			// saving the etemplate content for other hooked etemplate apps (atm. infolog hooked into addressbook)
@@ -312,12 +324,15 @@  discard block
 block discarded – undo
312 324
 		}
313 325
 		//echo '<p>'.__METHOD__."($method,...) after show: sitemgr=$this->sitemgr, hooked=".(int)$hooked.", output_mode=$output_mode</p>\n";
314 326
 
315
-		if (!$this->sitemgr && (int) $output_mode != 1 && (int) $output_mode != -1)	// NOT returning html
327
+		if (!$this->sitemgr && (int) $output_mode != 1 && (int) $output_mode != -1)
328
+		{
329
+			// NOT returning html
316 330
 		{
317 331
 			if (!@self::$hooked)
318 332
 			{
319 333
 				// let framework know, if we are a popup or not ('popup' not true, which is allways used by index.php!)
320 334
 				$GLOBALS['egw_info']['flags']['nonavbar'] = $output_mode == 2 ? 'popup' : false;
335
+		}
321 336
 				if((int) $output_mode != 2)
322 337
 				{
323 338
 					echo $GLOBALS['egw']->framework->navbar();
@@ -326,9 +341,12 @@  discard block
 block discarded – undo
326 341
 				{
327 342
 					echo $GLOBALS['egw']->framework->header();
328 343
 					echo '<div id="popupMainDiv">'."\n";
329
-					if ($GLOBALS['egw_info']['user']['apps']['manual'])	// adding a manual icon to every popup
344
+					if ($GLOBALS['egw_info']['user']['apps']['manual'])
345
+					{
346
+						// adding a manual icon to every popup
330 347
 					{
331 348
 						$manual = new etemplate('etemplate.popup.manual');
349
+					}
332 350
 						echo $manual->show(array());
333 351
 						unset($manual);
334 352
 						echo '<style type="text/css">.ajax-loader { position: absolute; right: 27px; top: 24px; display: none; }</style>'."\n";
@@ -347,10 +365,13 @@  discard block
 block discarded – undo
347 365
 				common::egw_footer();
348 366
 			}
349 367
 		}
350
-		if ($this->sitemgr || (int) $output_mode == 1 || (int) $output_mode == -1)	// return html
368
+		if ($this->sitemgr || (int) $output_mode == 1 || (int) $output_mode == -1)
369
+		{
370
+			// return html
351 371
 		{
352 372
 			return $html;
353 373
 		}
374
+		}
354 375
 	}
355 376
 
356 377
 	/**
@@ -362,9 +383,15 @@  discard block
 block discarded – undo
362 383
 	*/
363 384
 	static function validation_errors($ignore_validation='',$cname=null)
364 385
 	{
365
-		if (is_null($cname)) $cname = self::$name_vars;
386
+		if (is_null($cname))
387
+		{
388
+			$cname = self::$name_vars;
389
+		}
366 390
 		//echo "<p>uiself::validation_errors('$ignore_validation','$cname') validation_error="; _debug_array(self::$validation_errors);
367
-		if (!$ignore_validation) return count(self::$validation_errors) > 0;
391
+		if (!$ignore_validation)
392
+		{
393
+			return count(self::$validation_errors) > 0;
394
+		}
368 395
 
369 396
 		foreach(self::$validation_errors as $name => $error)
370 397
 		{
@@ -388,8 +415,14 @@  discard block
 block discarded – undo
388 415
 	 */
389 416
 	static function ignore_validation_match($form_name, $ignore_validation, $cname=null)
390 417
 	{
391
-		if (is_null($cname)) $cname = self::$name_vars;
392
-		if ($cname) $form_name = preg_replace('/^'.$cname.'\[([^\]]+)\](.*)$/','\\1\\2', $form_name);
418
+		if (is_null($cname))
419
+		{
420
+			$cname = self::$name_vars;
421
+		}
422
+		if ($cname)
423
+		{
424
+			$form_name = preg_replace('/^'.$cname.'\[([^\]]+)\](.*)$/','\\1\\2', $form_name);
425
+		}
393 426
 
394 427
 		return empty($ignore_validation) ||
395 428
 			$ignore_validation[0] == '/' && preg_match($ignore_validation, $form_name) ||
@@ -410,14 +443,26 @@  discard block
 block discarded – undo
410 443
 	*/
411 444
 	function process_exec($etemplate_exec_id = null, $submit_button = null, $exec = null, $type = 'regular' )
412 445
 	{
413
-		if(!$etemplate_exec_id) $etemplate_exec_id = $_POST['etemplate_exec_id'];
414
-		if(!$submit_button) $submit_button = $_POST['submit_button'];
415
-		if(!$exec) $exec = $_POST;
446
+		if(!$etemplate_exec_id)
447
+		{
448
+			$etemplate_exec_id = $_POST['etemplate_exec_id'];
449
+		}
450
+		if(!$submit_button)
451
+		{
452
+			$submit_button = $_POST['submit_button'];
453
+		}
454
+		if(!$exec)
455
+		{
456
+			$exec = $_POST;
457
+		}
416 458
 
417 459
 		//echo "process_exec: _POST ="; _debug_array($_POST);
418 460
 		if (!$etemplate_exec_id || !(self::$request = etemplate_request::read($etemplate_exec_id)))
419 461
 		{
420
-			if ($this->sitemgr) return false;
462
+			if ($this->sitemgr)
463
+			{
464
+				return false;
465
+			}
421 466
 			//echo "uitemplate::process_exec() id='$_POST[etemplate_exec_id]' invalid session-data !!!"; _debug_array($_SESSION);
422 467
 			// this prevents an empty screen, if the sessiondata gets lost somehow
423 468
 			$redirect = array(
@@ -435,7 +480,9 @@  discard block
 block discarded – undo
435 480
 					$redirect['failed_upload'] = 1;
436 481
 					$redirect['msg'] = lang('Error uploading file!')."\n".self::max_upload_size_message();
437 482
 				}
438
-			} else if ($_SERVER['REQUEST_METHOD'] == 'GET') {
483
+			}
484
+			else if ($_SERVER['REQUEST_METHOD'] == 'GET')
485
+			{
439 486
 				// Pass along any parameters
440 487
 				$redirect = $_GET;
441 488
 			}
@@ -471,10 +518,16 @@  discard block
 block discarded – undo
471 518
 				foreach($this->get_widgets_by_type('tab') as $widget)
472 519
 				{
473 520
 					$tab_name = $tabs = $widget['name'];
474
-					if (strpos($tabs,'=') !== false) list($tab_name,$tabs) = explode('=',$tabs,2);
521
+					if (strpos($tabs,'=') !== false)
522
+					{
523
+						list($tab_name,$tabs) = explode('=',$tabs,2);
524
+					}
475 525
 					foreach(explode('|',$tabs) as $tab)
476 526
 					{
477
-						if (strpos('.',$tab) === false) $tab = $this->name.'.'.$tab;
527
+						if (strpos('.',$tab) === false)
528
+						{
529
+							$tab = $this->name.'.'.$tab;
530
+						}
478 531
 						$tab_tpl = new etemplate($tab);
479 532
 						if ($tab_tpl->get_widget_by_name($name))
480 533
 						{
@@ -504,11 +557,14 @@  discard block
 block discarded – undo
504 557
 		$content = self::complete_array_merge(self::$request->changes,$content);
505 558
 		//echo "process_exec($this->name) merge(changes,content) ="; _debug_array($content);
506 559
 
507
-		if (self::$loop && $type == 'regular')	// only loop for regular (not ajax_submit) requests
560
+		if (self::$loop && $type == 'regular')
561
+		{
562
+			// only loop for regular (not ajax_submit) requests
508 563
 		{
509 564
 			if (self::$request->hooked != '')	// set previous phpgw_body if we are called as hook
510 565
 			{
511 566
 				self::$hook_content = self::$request->hooked;
567
+		}
512 568
 				$GLOBALS['egw_info']['flags']['currentapp'] = self::$hook_app = self::$request->hook_app;
513 569
 
514 570
 				// Prevent previous content form names from being used again in exec()
@@ -518,7 +574,10 @@  discard block
 block discarded – undo
518 574
 					self::$name_forms += $used[1];
519 575
 				}
520 576
 			}
521
-			if(self::$request->include_xajax) $GLOBALS['egw_info']['flags']['include_xajax'] = true;
577
+			if(self::$request->include_xajax)
578
+			{
579
+				$GLOBALS['egw_info']['flags']['include_xajax'] = true;
580
+			}
522 581
 
523 582
 			if (!empty(self::$request->app_header))
524 583
 			{
@@ -668,7 +727,11 @@  discard block
 block discarded – undo
668 727
 		{
669 728
 			$readonlys = array();
670 729
 		}
671
-		if (++$this->already_showed > 1) return '';	// prefens infinit self-inclusion
730
+		if (++$this->already_showed > 1)
731
+		{
732
+			return '';
733
+		}
734
+		// prefens infinit self-inclusion
672 735
 
673 736
 		if (is_int($this->debug) && $this->debug >= 1 || $this->name && $this->debug == $this->name)
674 737
 		{
@@ -715,7 +778,10 @@  discard block
 block discarded – undo
715 778
 		// ACL check
716 779
 		$cats = $GLOBALS['egw']->categories->check_list(EGW_ACL_READ,$cats);
717 780
 
718
-		if (!$cats) return null;
781
+		if (!$cats)
782
+		{
783
+			return null;
784
+		}
719 785
 
720 786
 		if (isset($cat2color[$cats]))
721 787
 		{
@@ -797,14 +863,18 @@  discard block
 block discarded – undo
797 863
 		$max_cols = $grid['cols'];
798 864
 		for ($r = 0; $row = 1+$r /*list($row,$cols) = each($data)*/; ++$r)
799 865
 		{
800
-			if (!(list($r_key) = each($data)))	// no further row
866
+			if (!(list($r_key) = each($data)))
867
+			{
868
+				// no further row
801 869
 			{
802 870
 				if (!(($this->autorepeat_idx($cols['A'],0,$r,$idx,$idx_cname,false,$content) && $idx_cname) ||
803 871
 						(in_array($cols['A']['type'], array('vbox','hbox','box')) && $this->autorepeat_idx($cols['A'][1],0,$r,$idx,$idx_cname,false,$content) && $idx_cname) ||
804 872
 					($this->autorepeat_idx($cols['B'],1,$r,$idx,$idx_cname,false,$content) && $idx_cname)) ||
805 873
 					!$this->isset_array($content,$idx_cname))
806 874
 				{
807
-					break;                     	// no auto-row-repeat
875
+					break;
876
+			}
877
+			// no auto-row-repeat
808 878
 				}
809 879
 			}
810 880
 			else
@@ -818,7 +888,11 @@  discard block
 block discarded – undo
818 888
 			{
819 889
 				continue;	// row is disabled
820 890
 			}
821
-			if ($part) $row = $part[0].$row;	// add part prefix
891
+			if ($part)
892
+			{
893
+				$row = $part[0].$row;
894
+			}
895
+			// add part prefix
822 896
 			$rows[".$row"] .= html::formatOptions($height,'height');
823 897
 			list($cl) = explode(',',$class);
824 898
 			if ($cl == '@' || $cl && strpos($cl,'$') !== false)
@@ -833,9 +907,13 @@  discard block
 block discarded – undo
833 907
 					$cl = str_replace($matches[2],'row',$cl);
834 908
 				}
835 909
 			}
836
-			if ($cl == 'nmr' || substr($cl,0,3) == 'row')	// allow to have further classes behind row
910
+			if ($cl == 'nmr' || substr($cl,0,3) == 'row')
837 911
 			{
838
-				$cl = 'row_'.($nmr_alternate++ & 1 ? 'off' : 'on').substr($cl,3); // alternate color
912
+				// allow to have further classes behind row
913
+			{
914
+				$cl = 'row_'.($nmr_alternate++ & 1 ? 'off' : 'on').substr($cl,3);
915
+			}
916
+			// alternate color
839 917
 			}
840 918
 			$cl = isset(self::$class_conf[$cl]) ? self::$class_conf[$cl] : $cl;
841 919
 			$rows[".$row"] .= html::formatOptions($cl,'class');
@@ -850,7 +928,9 @@  discard block
 block discarded – undo
850 928
 			for ($c = 0; True /*list($col,$cell) = each($cols)*/; ++$c)
851 929
 			{
852 930
 				$col = $this->num2chrs($c);
853
-				if (!(list($c_key) = each($cols)))		// no further cols
931
+				if (!(list($c_key) = each($cols)))
932
+				{
933
+					// no further cols
854 934
 				{
855 935
 					// only check if the max. column-number reached so far is exeeded
856 936
 					// otherwise the rows have a differen number of cells and it saved a lot checks
@@ -859,7 +939,9 @@  discard block
 block discarded – undo
859 939
 						if (!$this->autorepeat_idx($cell,$c,$r,$idx,$idx_cname,True,$content) ||
860 940
 							!$this->isset_array($content,$idx))
861 941
 						{
862
-							break;	// no auto-col-repeat
942
+							break;
943
+				}
944
+				// no auto-col-repeat
863 945
 						}
864 946
 						$max_cols = $c+1;
865 947
 					}
@@ -869,13 +951,19 @@  discard block
 block discarded – undo
869 951
 					$cell = $cols[$c_key];
870 952
 					list($col_width,$col_disabled) = explode(',',$opts[$col]);
871 953
 
872
-					if (!$cell['height'])	// if not set, cell-height = height of row
954
+					if (!$cell['height'])
955
+					{
956
+						// if not set, cell-height = height of row
873 957
 					{
874 958
 						$cell['height'] = $height;
875 959
 					}
876
-					if (!$cell['width'])	// if not set, cell-width = width of column or table
960
+					}
961
+					if (!$cell['width'])
962
+					{
963
+						// if not set, cell-width = width of column or table
877 964
 					{
878 965
 						list($col_span) = explode(',',$cell['span']);
966
+					}
879 967
 						if ($col_span == 'all' && !$c)
880 968
 						{
881 969
 							list($cell['width']) = explode(',',$this->size);
@@ -919,9 +1007,12 @@  discard block
 block discarded – undo
919 1007
 				else
920 1008
 				{
921 1009
 					list($width,$disable) = explode(',',$opts[$col]);
922
-					if ($width)		// width only once for a non colspan cell
1010
+					if ($width)
1011
+					{
1012
+						// width only once for a non colspan cell
923 1013
 					{
924 1014
 						$row_data[".$col"] .= " width=\"$width\"";
1015
+					}
925 1016
 						$opts[$col] = "0,$disable";
926 1017
 					}
927 1018
 				}
@@ -948,7 +1039,10 @@  discard block
 block discarded – undo
948 1039
 			}
949 1040
 			$rows[$row] = $row_data;
950 1041
 		}
951
-		if (!$rows) return '';
1042
+		if (!$rows)
1043
+		{
1044
+			return '';
1045
+		}
952 1046
 
953 1047
 		list($width,$height,,,,,$overflow) = $options = explode(',',$grid['size']);
954 1048
 		if ($overflow && $height)
@@ -961,9 +1055,19 @@  discard block
 block discarded – undo
961 1055
 
962 1056
 		if (!empty($overflow))
963 1057
 		{
964
-			if (is_numeric($height)) $height .= 'px';
965
-			if (is_numeric($width)) $width .= 'px';
966
-			if ($width == '100%') $overflow .= '; overflow-x: hidden';	// no horizontal scrollbar
1058
+			if (is_numeric($height))
1059
+			{
1060
+				$height .= 'px';
1061
+			}
1062
+			if (is_numeric($width))
1063
+			{
1064
+				$width .= 'px';
1065
+			}
1066
+			if ($width == '100%')
1067
+			{
1068
+				$overflow .= '; overflow-x: hidden';
1069
+			}
1070
+			// no horizontal scrollbar
967 1071
 			$div_style=' style="'.($width?"width: $width; ":'').($height ? "height: $height; ":'')."overflow: $overflow;\"";
968 1072
 			$html = html::div($html,$div_style);
969 1073
 		}
@@ -989,7 +1093,10 @@  discard block
 block discarded – undo
989 1093
 	*/
990 1094
 	static function form_name($cname,$name)
991 1095
 	{
992
-		if(is_object($name)) return '';
1096
+		if(is_object($name))
1097
+		{
1098
+			return '';
1099
+		}
993 1100
 
994 1101
 		$name_parts = explode('[',str_replace(']','',$name));
995 1102
 		if (!empty($cname))
@@ -1020,7 +1127,10 @@  discard block
 block discarded – undo
1020 1127
 
1021 1128
 		$name = array_shift($parts);
1022 1129
 
1023
-		if ($parts) $name .= '['.implode('][',$parts).']';
1130
+		if ($parts)
1131
+		{
1132
+			$name .= '['.implode('][',$parts).']';
1133
+		}
1024 1134
 
1025 1135
 		return $name;
1026 1136
 	}
@@ -1073,17 +1183,29 @@  discard block
 block discarded – undo
1073 1183
 		$options = '';
1074 1184
 		if ($readonly = $cell['readonly'] && $readonlys[$name] !== false || 	// allow to overwrite readonly settings of a cell
1075 1185
 			@$readonlys[$name] && !is_array($readonlys[$name]) || $readonlys['__ALL__'] && (!is_string($name) || $readonlys[$name] !== false) ||
1076
-			!empty($name) && is_string($name) && ($p = strrpos($name,'[')) !== false && ($parent=substr($name,0,$p)) && $readonlys[$parent])	// allow also set parent readonly (instead each child)
1186
+			!empty($name) && is_string($name) && ($p = strrpos($name,'[')) !== false && ($parent=substr($name,0,$p)) && $readonlys[$parent])
1187
+		{
1188
+			// allow also set parent readonly (instead each child)
1077 1189
 		{
1078 1190
 			$options .= ' readonly="readonly"';
1079 1191
 		}
1080
-		if ((int) $cell['tabindex']) $options .= ' tabindex="'.(int)$cell['tabindex'].'"';
1081
-		if ($cell['accesskey']) $options .= ' accesskey="'.html::htmlspecialchars($cell['accesskey']).'"';
1192
+		}
1193
+		if ((int) $cell['tabindex'])
1194
+		{
1195
+			$options .= ' tabindex="'.(int)$cell['tabindex'].'"';
1196
+		}
1197
+		if ($cell['accesskey'])
1198
+		{
1199
+			$options .= ' accesskey="'.html::htmlspecialchars($cell['accesskey']).'"';
1200
+		}
1082 1201
 
1083
-		if (is_string($cell['size']) && (strchr($cell['size'],'$') || $cell['size'][0] == '@'))	// expand cell['size'] for the button-disabled-check now
1202
+		if (is_string($cell['size']) && (strchr($cell['size'],'$') || $cell['size'][0] == '@'))
1203
+		{
1204
+			// expand cell['size'] for the button-disabled-check now
1084 1205
 		{
1085 1206
 			$cell['size'] = $this->expand_name($cell['size'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
1086 1207
 		}
1208
+		}
1087 1209
 		if ($cell['type'] == 'template' && !$this->check_disabled($cell['disabled'], $content))
1088 1210
 		{
1089 1211
 			// template is NOT disabled (eg. in editor)
@@ -1121,7 +1243,10 @@  discard block
 block discarded – undo
1121 1243
 			{
1122 1244
 				$cell['onchange'] = $this->expand_name($cell['onchange'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
1123 1245
 			}
1124
-			if (!$ext_type) $ext_type = $type;
1246
+			if (!$ext_type)
1247
+			{
1248
+				$ext_type = $type;
1249
+			}
1125 1250
 			// if readonlys[__ALL__] is set, also set readonlys[$name] (extensions can mark themselfs as 'noReadonlysALL', eg. tab-widget!)
1126 1251
 			if ($readonlys['__ALL__'] && $readonlys[$name] !== false && !$this->haveExtension($type,'noReadonlysALL'))
1127 1252
 			{
@@ -1133,7 +1258,11 @@  discard block
 block discarded – undo
1133 1258
 
1134 1259
 			self::set_array($content,$name,$value);
1135 1260
 
1136
-			if ($cell['type'] == $type.'-'.$sub_type) break;	// stop if no further type-change
1261
+			if ($cell['type'] == $type.'-'.$sub_type)
1262
+			{
1263
+				break;
1264
+			}
1265
+			// stop if no further type-change
1137 1266
 
1138 1267
 			list($type,$sub_type) = explode('-',$cell['type']);
1139 1268
 		}
@@ -1178,24 +1307,33 @@  discard block
 block discarded – undo
1178 1307
 		{
1179 1308
 			if ((int)$cell['no_lang'] < 2 && !$no_lang_on_help)
1180 1309
 			{
1181
-				if (($use_tooltip_for_help = $help[0] == '|')) $help = substr($help,1);
1310
+				if (($use_tooltip_for_help = $help[0] == '|'))
1311
+				{
1312
+					$help = substr($help,1);
1313
+				}
1182 1314
 				$help = lang($help);
1183 1315
 			}
1184 1316
 			if (substr($help,0,5) == 'call:')
1185 1317
 			{
1186 1318
 				$options .= ' onMouseOver="'.html::htmlspecialchars(substr($help,5)).'"';
1187 1319
 			}
1188
-			elseif (($use_tooltip_for_help = $use_tooltip_for_help || strpos($help,'<') !== false && strip_tags($help) != $help))	// helptext is html => use a tooltip
1320
+			elseif (($use_tooltip_for_help = $use_tooltip_for_help || strpos($help,'<') !== false && strip_tags($help) != $help))
1321
+			{
1322
+				// helptext is html => use a tooltip
1189 1323
 			{
1190 1324
 				$options .= html::tooltip($help);
1191 1325
 			}
1326
+			}
1192 1327
 			else	// "regular" help-text in the statusline
1193 1328
 			{
1194 1329
 				$onFocus .= "self.status='".addslashes(html::htmlspecialchars($help))."'; return true;";
1195 1330
 				$onBlur  .= "self.status=''; return true;";
1196
-				if (in_array($cell['type'],array('button','buttononly','file')))	// for button additionally when mouse over button
1331
+				if (in_array($cell['type'],array('button','buttononly','file')))
1332
+				{
1333
+					// for button additionally when mouse over button
1197 1334
 				{
1198 1335
 					$options .= " onMouseOver=\"self.status='".addslashes(html::htmlspecialchars($help))."'; return true;\"";
1336
+				}
1199 1337
 					$options .= " onMouseOut=\"self.status=''; return true;\"";
1200 1338
 				}
1201 1339
 			}
@@ -1225,7 +1363,10 @@  discard block
 block discarded – undo
1225 1363
 		switch ($type)
1226 1364
 		{
1227 1365
 			case 'label':	//  size: [b[old]][i[talic]],[link],[activate_links],[label_for],[link_target],[link_popup_size],[link_title]
1228
-				if (is_array($value)) break;
1366
+				if (is_array($value))
1367
+				{
1368
+					break;
1369
+				}
1229 1370
 				if($cell_options)
1230 1371
 				{
1231 1372
 					list($style,$extra_link,$activate_links,$label_for,$extra_link_target,$extra_link_popup,$extra_link_title) = self::csv_split($cell_options,7);
@@ -1242,9 +1383,18 @@  discard block
 block discarded – undo
1242 1383
 				}
1243 1384
 				$value = strlen($value) > 1 && !$cell['no_lang'] ? lang($value) : $value;
1244 1385
 				$value = nl2br(html::htmlspecialchars($value));
1245
-				if ($activate_links) $value = html::activate_links($value);
1246
-				if ($value != '' && $style && strpos($style,'b')!==false) $value = html::bold($value);
1247
-				if ($value != '' && $style && strpos($style,'i')!==false) $value = html::italic($value);
1386
+				if ($activate_links)
1387
+				{
1388
+					$value = html::activate_links($value);
1389
+				}
1390
+				if ($value != '' && $style && strpos($style,'b')!==false)
1391
+				{
1392
+					$value = html::bold($value);
1393
+				}
1394
+				if ($value != '' && $style && strpos($style,'i')!==false)
1395
+				{
1396
+					$value = html::italic($value);
1397
+				}
1248 1398
 				// if the label has a name, use it as id in a span, to allow addressing it via javascript
1249 1399
 				$html .= ($name ? '<span id="'.($cell['id']?$cell['id']:$name).'">' : '').$value.($name ? '</span>' : '');
1250 1400
 				if ($help)
@@ -1257,7 +1407,10 @@  discard block
 block discarded – undo
1257 1407
 				break;
1258 1408
 			case 'html':	//  size: [link],[link_target],[link_popup_size],[link_title],[activate_links]
1259 1409
 				list($extra_link,$extra_link_target,$extra_link_popup,$extra_link_title,$activate_links) = explode(',',$cell_options);
1260
-				if ($activate_links) $value = html::activate_links($value);
1410
+				if ($activate_links)
1411
+				{
1412
+					$value = html::activate_links($value);
1413
+				}
1261 1414
 				$html .= $value;
1262 1415
 				break;
1263 1416
 			case 'int':		// size: [min],[max],[len],[precision/sprint format],[step]
@@ -1265,8 +1418,14 @@  discard block
 block discarded – undo
1265 1418
 			case 'float':
1266 1419
 				list($min,$max,$cell_options,$pre,$step) = explode(',',$cell_options);
1267 1420
 				// a few html5 options
1268
-				if ((string)$min !== '') $options .= ' min="'.htmlspecialchars($min).'"';
1269
-				if ((string)$max !== '') $options .= ' max="'.htmlspecialchars($max).'"';
1421
+				if ((string)$min !== '')
1422
+				{
1423
+					$options .= ' min="'.htmlspecialchars($min).'"';
1424
+				}
1425
+				if ((string)$max !== '')
1426
+				{
1427
+					$options .= ' max="'.htmlspecialchars($max).'"';
1428
+				}
1270 1429
 				//  default step="any" for float, as not setting it limits value to integer as step defaults to 1 in html5!
1271 1430
 				if (is_numeric($step) || $type == 'float')
1272 1431
 				{
@@ -1297,7 +1456,11 @@  discard block
 block discarded – undo
1297 1456
 					if (preg_match('/^[a-z]+$/i',$html5type))
1298 1457
 					{
1299 1458
 						$cell_opts[2] = substr($cell_opts[2],0,-strlen($html5type)-1);
1300
-						if ($cell_opts[2][0] == ',') $cell_opts[2] = '';	// happens in link-entry under some condition
1459
+						if ($cell_opts[2][0] == ',')
1460
+						{
1461
+							$cell_opts[2] = '';
1462
+						}
1463
+						// happens in link-entry under some condition
1301 1464
 						$cell_opts[] = $html5type;
1302 1465
 					}
1303 1466
 				}
@@ -1343,7 +1506,10 @@  discard block
 block discarded – undo
1343 1506
 				{
1344 1507
 					// if textarea is readonly, but form_name is already used by an other widget, dont use it
1345 1508
 					// browser would only send the content of the readonly (and therefore unchanged) field
1346
-					if ($readonly && self::$request->isset_to_process($form_name)) $form_name = '';
1509
+					if ($readonly && self::$request->isset_to_process($form_name))
1510
+					{
1511
+						$form_name = '';
1512
+					}
1347 1513
 					$html .= html::textarea($form_name,$value,
1348 1514
 						$options.html::formatOptions($cell_options,'ROWS,COLS').($cell['needed']?' required="required"':''));
1349 1515
 				}
@@ -1386,7 +1552,10 @@  discard block
 block discarded – undo
1386 1552
 				if (!empty($cell_options))
1387 1553
 				{
1388 1554
 					list($set_val,$unset_val,$ro_true,$ro_false) = self::csv_split($cell_options);
1389
-					if (!$set_val && !$unset_val) $set_val = 1;
1555
+					if (!$set_val && !$unset_val)
1556
+					{
1557
+						$set_val = 1;
1558
+					}
1390 1559
 					$value = $value == $set_val;
1391 1560
 				}
1392 1561
 				if (($multiple = substr($cell['name'],-2) == '[]') && !$readonly)
@@ -1400,13 +1569,19 @@  discard block
 block discarded – undo
1400 1569
 						$ro_true = 'x';
1401 1570
 						$ro_false = '';
1402 1571
 					}
1403
-					if (!$value && $ro_false == 'disable') return '';
1572
+					if (!$value && $ro_false == 'disable')
1573
+					{
1574
+						return '';
1575
+					}
1404 1576
 
1405 1577
 					$html .= $value ? html::bold($ro_true) : $ro_false;
1406 1578
 				}
1407 1579
 				else
1408 1580
 				{
1409
-					if ($value) $options .= ' checked="checked"';
1581
+					if ($value)
1582
+					{
1583
+						$options .= ' checked="checked"';
1584
+					}
1410 1585
 
1411 1586
 					if ($multiple)
1412 1587
 					{
@@ -1416,7 +1591,10 @@  discard block
 block discarded – undo
1416 1591
 					}
1417 1592
 					$html .= html::input($form_name,$set_val,'checkbox',$options);
1418 1593
 
1419
-					if ($multiple) $form_name = self::form_name($cname,substr($cell['name'],0,-2));
1594
+					if ($multiple)
1595
+					{
1596
+						$form_name = self::form_name($cname,substr($cell['name'],0,-2));
1597
+					}
1420 1598
 
1421 1599
 					if (!self::$request->isset_to_process($form_name))
1422 1600
 					{
@@ -1427,7 +1605,11 @@  discard block
 block discarded – undo
1427 1605
 						));
1428 1606
 					}
1429 1607
 					self::$request->set_to_process_attribute($form_name,'values',$set_val,true);
1430
-					if (!$multiple) unset($set_val);	// otherwise it will be added to the label
1608
+					if (!$multiple)
1609
+					{
1610
+						unset($set_val);
1611
+					}
1612
+					// otherwise it will be added to the label
1431 1613
 				}
1432 1614
 				break;
1433 1615
 			case 'radio':		// size: value if checked, readonly set, readonly unset
@@ -1444,7 +1626,10 @@  discard block
 block discarded – undo
1444 1626
 
1445 1627
 				if ($readonly)
1446 1628
 				{
1447
-					if (!$ro_true && !$ro_false) $ro_true = 'x';
1629
+					if (!$ro_true && !$ro_false)
1630
+					{
1631
+						$ro_true = 'x';
1632
+					}
1448 1633
 					$html .= $value == $set_val ? html::bold($ro_true) : $ro_false;
1449 1634
 				}
1450 1635
 				else
@@ -1458,7 +1643,10 @@  discard block
 block discarded – undo
1458 1643
 			case 'button':
1459 1644
 			case 'buttononly':
1460 1645
 			case 'cancel':	// cancel button
1461
-				if ($name == 'cancel' || stripos($name,'[cancel]') !== false) $type = 'cancel';
1646
+				if ($name == 'cancel' || stripos($name,'[cancel]') !== false)
1647
+				{
1648
+					$type = 'cancel';
1649
+				}
1462 1650
 				list($app) = explode('.',$this->name);
1463 1651
 				list($img,$ro_img) = explode(',',$cell_options);
1464 1652
 				if ($img[0] != '/' && strpos($img,'/') !== false && count($img_parts = explode('/',$img)) == 2)
@@ -1472,11 +1660,14 @@  discard block
 block discarded – undo
1472 1660
 					$onclick = $this->js_pseudo_funcs($onclick,$cname);
1473 1661
 				}
1474 1662
 				unset($cell['onclick']);	// otherwise the grid will handle it
1475
-				if (($cell['onchange'] != '' || $img && !$readonly) && !$cell['needed']) // use a link instead of a button
1663
+				if (($cell['onchange'] != '' || $img && !$readonly) && !$cell['needed'])
1664
+				{
1665
+					// use a link instead of a button
1476 1666
 				{
1477 1667
 					$onclick = ($onclick ? preg_replace('/^return(.*);$/','if (\\1) ',$onclick) : '').
1478 1668
 						(((string)$cell['onchange'] === '1' || $img) ?
1479 1669
 						'return submitit('.self::$name_form.",'".$form_name."');" : $cell['onchange']).'; return false;';
1670
+				}
1480 1671
 
1481 1672
 					if (!html::$netscape4 && substr($img,-1) == '%' && is_numeric($percent = substr($img,0,-1)))
1482 1673
 					{
@@ -1498,16 +1689,23 @@  discard block
 block discarded – undo
1498 1689
 					{
1499 1690
 						$onclick = ($onclick ? preg_replace('/^return(.*);$/','if (\\1) ',$onclick) : '').$cell['onchange'];
1500 1691
 					}
1501
-					if ($type == 'cancel') $options .= ' novalidate="novalidate"';	// tell html5 form validation NOT to validate
1692
+					if ($type == 'cancel')
1693
+					{
1694
+						$options .= ' novalidate="novalidate"';
1695
+					}
1696
+					// tell html5 form validation NOT to validate
1502 1697
 					$html .= !$readonly ? html::submit_button($form_name,$label,$onclick,
1503 1698
 						strlen($label) <= 1 || $cell['no_lang'],$options,$img,$app,$type == 'buttononly' ? 'button' : 'submit') :
1504 1699
 						html::image($app,$ro_img,'',$options);
1505 1700
 				}
1506 1701
 				$extra_label = False;
1507
-				if (!$readonly && $type != 'buttononly')	// input button, are never submitted back!
1702
+				if (!$readonly && $type != 'buttononly')
1703
+				{
1704
+					// input button, are never submitted back!
1508 1705
 				{
1509 1706
 					self::$request->set_to_process($form_name,$type);
1510 1707
 				}
1708
+				}
1511 1709
 				break;
1512 1710
 			case 'hrule':
1513 1711
 				$html .= html::hr($cell_options);
@@ -1515,7 +1713,10 @@  discard block
 block discarded – undo
1515 1713
 			case 'grid':
1516 1714
 				if ($readonly && !$readonlys['__ALL__'])
1517 1715
 				{
1518
-					if (!is_array($readonlys)) $readonlys = array();
1716
+					if (!is_array($readonlys))
1717
+					{
1718
+						$readonlys = array();
1719
+					}
1519 1720
 					$set_readonlys_all = $readonlys['__ALL__'] = True;
1520 1721
 				}
1521 1722
 				if ($name != '')
@@ -1523,7 +1724,10 @@  discard block
 block discarded – undo
1523 1724
 					$cname .= $cname == '' ? $name : '['.str_replace('[','][',str_replace(']','',$name)).']';
1524 1725
 				}
1525 1726
 				$html .= $this->show_grid($cell,$name ? $value : $content,$readonlys+(array)$readonlys[$name],$cname,$show_c,$show_row,$path);
1526
-				if ($set_readonlys_all) unset($readonlys['__ALL__']);
1727
+				if ($set_readonlys_all)
1728
+				{
1729
+					unset($readonlys['__ALL__']);
1730
+				}
1527 1731
 				break;
1528 1732
 			case 'template':	// size: index in content-array (if not full content is past further on)
1529 1733
 				if (is_object($cell['name']))
@@ -1553,7 +1757,8 @@  discard block
 block discarded – undo
1553 1757
 						}
1554 1758
 					}
1555 1759
 					else
1556
-					{  $obj_read = 'obj read';
1760
+					{
1761
+$obj_read = 'obj read';
1557 1762
 						$cell['obj'] = new etemplate($name,$this->as_array());
1558 1763
 					}
1559 1764
 				}
@@ -1564,7 +1769,8 @@  discard block
 block discarded – undo
1564 1769
 				if ($this->autorepeat_idx($cell,$show_c,$show_row,$idx,$idx_cname,false,$content) || $cell_options != '')
1565 1770
 				{
1566 1771
 					if ($span == '' && isset($content[$idx]['span']))
1567
-					{	// this allows a colspan in autorepeated cells like the editor
1772
+					{
1773
+// this allows a colspan in autorepeated cells like the editor
1568 1774
 						list($span) = explode(',',$content[$idx]['span']);
1569 1775
 						if ($span == 'all')
1570 1776
 						{
@@ -1581,11 +1787,17 @@  discard block
 block discarded – undo
1581 1787
 				}
1582 1788
 				if ($readonly && !$readonlys['__ALL__'])
1583 1789
 				{
1584
-					if (!is_array($readonlys)) $readonlys = array();
1790
+					if (!is_array($readonlys))
1791
+					{
1792
+						$readonlys = array();
1793
+					}
1585 1794
 					$set_readonlys_all = $readonlys['__ALL__'] = True;
1586 1795
 				}
1587 1796
 				// propagate our onclick handler to embeded templates, if they dont have their own
1588
-				if (!isset($cell['obj']->onclick_handler)) $cell['obj']->onclick_handler = $this->onclick_handler;
1797
+				if (!isset($cell['obj']->onclick_handler))
1798
+				{
1799
+					$cell['obj']->onclick_handler = $this->onclick_handler;
1800
+				}
1589 1801
 				if ($cell['obj']->no_onclick)
1590 1802
 				{
1591 1803
 					$cell['obj']->onclick_proxy = $this->onclick_proxy ? $this->onclick_proxy : $this->name.':'.$this->version.':'.$path;
@@ -1599,7 +1811,10 @@  discard block
 block discarded – undo
1599 1811
 				}
1600 1812
 				$html = $cell['obj']->show($content,$this->sel_options,$readonlys,$cname,$show_c,$show_row);
1601 1813
 
1602
-				if ($set_readonlys_all) unset($readonlys['__ALL__']);
1814
+				if ($set_readonlys_all)
1815
+				{
1816
+					unset($readonlys['__ALL__']);
1817
+				}
1603 1818
 				break;
1604 1819
 			case 'select':	// size:[linesOnMultiselect|emptyLabel,extraStyleMulitselect, [<varies>,]{5} enhance]
1605 1820
 				$sels = array();
@@ -1628,7 +1843,10 @@  discard block
 block discarded – undo
1628 1843
 					$multiple = 0;
1629 1844
 				}
1630 1845
 				$sels += $this->_sel_options($cell,$name,$content);
1631
-				if ($multiple && !is_array($value)) $value = explode(',',$value);
1846
+				if ($multiple && !is_array($value))
1847
+				{
1848
+					$value = explode(',',$value);
1849
+				}
1632 1850
 				if ($readonly || $cell['noprint'])
1633 1851
 				{
1634 1852
 					foreach($multiple || is_array($value) ? $value : array($value) as $val)
@@ -1643,9 +1861,15 @@  discard block
 block discarded – undo
1643 1861
 							$option_label = ($sels[$val]?$sels[$val]:$val);
1644 1862
 							$option_title = '';
1645 1863
 						}
1646
-						if (!$cell['no_lang']) $option_label = lang($option_label);
1864
+						if (!$cell['no_lang'])
1865
+						{
1866
+							$option_label = lang($option_label);
1867
+						}
1647 1868
 
1648
-						if ($html) $html .= "<br>\n";
1869
+						if ($html)
1870
+						{
1871
+							$html .= "<br>\n";
1872
+						}
1649 1873
 
1650 1874
 						if ($option_title)
1651 1875
 						{
@@ -1664,12 +1888,15 @@  discard block
 block discarded – undo
1664 1888
 						$html = '<span class="onlyPrint">'.$html.'</span>';
1665 1889
 						$options .= ' class="noPrint"';
1666 1890
 					}
1667
-					if ($multiple && is_numeric($multiple))	// eg. "3+" would give a regular multiselectbox
1891
+					if ($multiple && is_numeric($multiple))
1892
+					{
1893
+						// eg. "3+" would give a regular multiselectbox
1668 1894
 					{
1669 1895
 						$html .= html::checkbox_multiselect($form_name.($multiple > 1 ? '[]' : ''),$value,$sels,
1670 1896
 							$cell['no_lang'],$options,$multiple,$multiple[0]!=='0',
1671 1897
 							$extraStyleMultiselect,$enhance);
1672 1898
 					}
1899
+					}
1673 1900
 					else
1674 1901
 					{
1675 1902
 						$html .= html::select($form_name.($multiple > 1 ? '[]' : ''),$value,$sels,
@@ -1708,7 +1935,10 @@  discard block
 block discarded – undo
1708 1935
 					error_log("Please use correct widget-type '".($is_progress?'progress':'image')."' in eTemplate '$this->name'!");
1709 1936
 				}
1710 1937
 				$image = $value != '' ? $value : $name;
1711
-				if (is_string($image)) list($app,$img) = explode('/',$image,2);
1938
+				if (is_string($image))
1939
+				{
1940
+					list($app,$img) = explode('/',$image,2);
1941
+				}
1712 1942
 				if (!$app || !$img || !is_dir(EGW_SERVER_ROOT.'/'.$app) || strpos($img,'/')!==false)
1713 1943
 				{
1714 1944
 					$img = $image;
@@ -1726,7 +1956,10 @@  discard block
 block discarded – undo
1726 1956
 			case 'file':	// size: size of the filename field
1727 1957
 				if (!$readonly)
1728 1958
 				{
1729
-					if ((int) $cell_options) $options .= ' size="'.(int)$cell_options.'"';
1959
+					if ((int) $cell_options)
1960
+					{
1961
+						$options .= ' size="'.(int)$cell_options.'"';
1962
+					}
1730 1963
 					if (substr($name,-2) == '[]')
1731 1964
 					{
1732 1965
 						self::$form_options .= ' enctype="multipart/form-data"';
@@ -1763,7 +1996,10 @@  discard block
 block discarded – undo
1763 1996
 				$box_col = 'A';
1764 1997
 				$box_anz = 0;
1765 1998
 				list($num,$orient,,,$keep_empty) = explode(',',$cell_options);
1766
-				if (!$orient) $orient = $type == 'hbox' ? 'horizontal' : ($type == 'box' ? false : 'vertical');
1999
+				if (!$orient)
2000
+				{
2001
+					$orient = $type == 'hbox' ? 'horizontal' : ($type == 'box' ? false : 'vertical');
2002
+				}
1767 2003
 				for ($n = 1; $n <= (int) $num; ++$n)
1768 2004
 				{
1769 2005
 					$child = $cell[$n];	// first param is a var_param now!
@@ -1814,20 +2050,31 @@  discard block
 block discarded – undo
1814 2050
 						$rows[$box_row]['.'.$box_col] .= html::formatOptions($box_item_class,'class');
1815 2051
 					}
1816 2052
 				}
1817
-				if ($box_anz > 1 && $orient)	// a single cell is NOT placed into a table
2053
+				if ($box_anz > 1 && $orient)
2054
+				{
2055
+					// a single cell is NOT placed into a table
1818 2056
 				{
1819 2057
 					$html = html::table($rows,html::formatOptions($cell_options,',,cellpadding,cellspacing').
1820 2058
 						($type != 'groupbox' ? html::formatOptions($class,'class').
1821 2059
 							 ($cell['name'] ? self::get_id($form_name,$cell['name'],$cell['id']) : '') : '').
1822
-						($cell['align'] && $orient != 'horizontal' || $sub_cell_has_align ? ' width="100%"' : ''));	// alignment only works if table has full width
1823
-					if ($type != 'groupbox') $class = '';	// otherwise we create an extra div
2060
+						($cell['align'] && $orient != 'horizontal' || $sub_cell_has_align ? ' width="100%"' : ''));
2061
+				}
2062
+				// alignment only works if table has full width
2063
+					if ($type != 'groupbox')
2064
+					{
2065
+						$class = '';
2066
+					}
2067
+					// otherwise we create an extra div
1824 2068
 				}
1825 2069
 				// put the class of the box-cell, into the the class of this cell
1826 2070
 				elseif ($box_item_class && $box_anz == 1)
1827 2071
 				{
1828 2072
 					$class = ($class ? $class . ' ' : '') . $box_item_class;
1829 2073
 					// if we have onclick or tooltip, add it to an extra div around single cell
1830
-					if (!empty($rows[$box_row]['.'.$box_col])) $html = html::div($html, $rows[$box_row]['.'.$box_col]);
2074
+					if (!empty($rows[$box_row]['.'.$box_col]))
2075
+					{
2076
+						$html = html::div($html, $rows[$box_row]['.'.$box_col]);
2077
+					}
1831 2078
 				}
1832 2079
 				if ($type == 'groupbox')
1833 2080
 				{
@@ -1841,7 +2088,11 @@  discard block
 block discarded – undo
1841 2088
 				}
1842 2089
 				elseif (!$orient)
1843 2090
 				{
1844
-					if (strpos($html,'class="'.$class)) $class = '';	// dont add class a 2. time
2091
+					if (strpos($html,'class="'.$class))
2092
+					{
2093
+						$class = '';
2094
+					}
2095
+					// dont add class a 2. time
1845 2096
 					$html = html::div($html,html::formatOptions(array(
1846 2097
 							$cell['height'],
1847 2098
 							$cell['width'],
@@ -1849,12 +2100,18 @@  discard block
 block discarded – undo
1849 2100
 						),'height,width,class').self::get_id($form_name,$cell['name'],$cell['id'])). ($html ? '' : '</div>');
1850 2101
 					$class = '';	// otherwise we create an extra div
1851 2102
 				}
1852
-				if ($box_anz > 1)	// small docu in the html-source
2103
+				if ($box_anz > 1)
2104
+				{
2105
+					// small docu in the html-source
1853 2106
 				{
1854 2107
 					$html = "\n\n<!-- BEGIN $cell[type] -->\n\n".$html."\n\n<!-- END $cell[type] -->\n\n";
1855 2108
 				}
2109
+				}
1856 2110
 				// we need noPrint on td
1857
-				if (strpos($cell['span'], 'noPrint')) $class .= ' noPrint';
2111
+				if (strpos($cell['span'], 'noPrint'))
2112
+				{
2113
+					$class .= ' noPrint';
2114
+				}
1858 2115
 				$extra_label = False;
1859 2116
 				break;
1860 2117
 			case 'deck':
@@ -1913,7 +2170,8 @@  discard block
 block discarded – undo
1913 2170
 		}
1914 2171
 		// extension-processing need to be after all other and only with diff. name
1915 2172
 		if ($ext_type && !$readonly && $this->haveExtension($ext_type,'post_process'))
1916
-		{	// unset it first, if it is already set, to be after the other widgets of the ext.
2173
+		{
2174
+// unset it first, if it is already set, to be after the other widgets of the ext.
1917 2175
 			$to_process = self::$request->get_to_process($form_name);
1918 2176
 			self::$request->unset_to_process($form_name);
1919 2177
 			self::$request->set_to_process($form_name,'ext-'.$ext_type,$to_process);
@@ -1938,20 +2196,26 @@  discard block
 block discarded – undo
1938 2196
 			}
1939 2197
 			if ($label && !$readonly && ($accesskey || $label_for || $type != 'label' && $cell['name']))
1940 2198
 			{
1941
-				if ($label_for)		// if label_for starts with a '#', it is already an id - no need to create default id from it
2199
+				if ($label_for)
2200
+				{
2201
+					// if label_for starts with a '#', it is already an id - no need to create default id from it
1942 2202
 				{
1943 2203
 					$label_for = $label_for[0] == '#' ? substr($label_for,1) : self::form_name($cname,$label_for);
1944 2204
 				}
2205
+				}
1945 2206
 				else
1946 2207
 				{
1947 2208
 					$label_for = $form_name.($set_val?"[$set_val]":'');
1948 2209
 				}
1949 2210
 				$label = html::label($label,$label_for,$accesskey);
1950 2211
 			}
1951
-			if ($type == 'radio' || $type == 'checkbox' || $label && strpos($label,'%s')!==false)	// default for radio is label after the button
2212
+			if ($type == 'radio' || $type == 'checkbox' || $label && strpos($label,'%s')!==false)
2213
+			{
2214
+				// default for radio is label after the button
1952 2215
 			{
1953 2216
 				$html = strpos($label,'%s')!==false ? str_replace('%s',$html,$label) : $html.' '.$label;
1954 2217
 			}
2218
+			}
1955 2219
 			elseif (($html = $label . ' ' . $html) == ' ')
1956 2220
 			{
1957 2221
 				$html = '&nbsp;';
@@ -1988,10 +2252,13 @@  discard block
 block discarded – undo
1988 2252
 		{
1989 2253
 			$handler = str_replace('%p',$this->no_onclick ? $this->onclick_proxy : $this->name.':'.$this->version.':'.$path,
1990 2254
 				$this->onclick_handler);
1991
-			if ($type == 'button' || $type == 'buttononly' || !$label)	// add something to click on
2255
+			if ($type == 'button' || $type == 'buttononly' || !$label)
2256
+			{
2257
+				// add something to click on
1992 2258
 			{
1993 2259
 				$html = (substr($html,-1) == "\n" ? substr($html,0,-1) : $html).'&nbsp;';
1994 2260
 			}
2261
+			}
1995 2262
 			return html::div($html,' ondblclick="'.$handler.'"','clickWidgetToEdit');
1996 2263
 		}
1997 2264
 		return $html;
@@ -2048,10 +2315,16 @@  discard block
 block discarded – undo
2048 2315
 		if (is_null($dec_separator))
2049 2316
 		{
2050 2317
 			$dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0];
2051
-			if (empty($dec_separator)) $dec_separator = '.';
2318
+			if (empty($dec_separator))
2319
+			{
2320
+				$dec_separator = '.';
2321
+			}
2052 2322
 			$thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1];
2053 2323
 		}
2054
-		if ((string)$number === '') return '';
2324
+		if ((string)$number === '')
2325
+		{
2326
+			return '';
2327
+		}
2055 2328
 
2056 2329
 		$ret = number_format(str_replace(' ','',$number), $num_decimal_places,
2057 2330
 			// need to use '.' as decimal separator for all browser supporting html5 input type=number
@@ -2143,13 +2416,16 @@  discard block
 block discarded – undo
2143 2416
 	*/
2144 2417
 	function js_pseudo_funcs($on,$cname)
2145 2418
 	{
2146
-		if (strpos($on,'::') !== false)	// avoid the expensive regular expresions, for performance reasons
2419
+		if (strpos($on,'::') !== false)
2420
+		{
2421
+			// avoid the expensive regular expresions, for performance reasons
2147 2422
 		{
2148 2423
 			if (preg_match_all("/egw::link\\('([^']+)','(.+?)'(?:,'(.+?)')?\\)/",$on,$matches))	// the ? alters the expression to shortest match
2149 2424
 			{
2150 2425
 				foreach(array_keys($matches[1]) as $n)                         	// this way we can correctly parse ' in the 2. argument
2151 2426
 				{
2152 2427
 					$url = $GLOBALS['egw']->link($matches[1][$n],$matches[2][$n],$matches[3][$n]);
2428
+		}
2153 2429
 					$on = str_replace($matches[0][$n],'\''.addslashes($url).'\'',$on);
2154 2430
 				}
2155 2431
 			}
@@ -2163,8 +2439,10 @@  discard block
 block discarded – undo
2163 2439
 				$on = str_replace($matches[0],$matches[1],$on);
2164 2440
 			}
2165 2441
 			// we need to search ungready (shortest possible match), to avoid catching to much
2166
-			if (preg_match_all('/egw::lang\(["\']{1}(.*)["\']{1}\)/U',$on,$matches)) {
2167
-				foreach($matches[1] as $n => $string) {
2442
+			if (preg_match_all('/egw::lang\(["\']{1}(.*)["\']{1}\)/U',$on,$matches))
2443
+			{
2444
+				foreach($matches[1] as $n => $string)
2445
+				{
2168 2446
 					$str = lang($string);
2169 2447
 					$on = str_replace($matches[0][$n],'\''.addslashes($str).'\'',$on);
2170 2448
 				}
@@ -2273,14 +2551,20 @@  discard block
 block discarded – undo
2273 2551
 			$value = self::get_array($content_in,$form_name,True,$GLOBALS['egw_info']['flags']['currentapp'] == 'etemplate' ? false : true );
2274 2552
 			// The comment below does only aplay to normal posts, not for xajax. Files are not supported anyway by xajax atm.
2275 2553
 			// not checked checboxes are not returned in HTML and file is in $_FILES and not in $content_in
2276
-			if($value === false && $_type == 'xajaxResponse' /*!in_array($type,array('checkbox','file'))*/) continue;
2554
+			if($value === false && $_type == 'xajaxResponse' /*!in_array($type,array('checkbox','file'))*/)
2555
+			{
2556
+				continue;
2557
+			}
2277 2558
 
2278 2559
 			if (isset($attr['blur']) && $attr['blur'] == $value)
2279 2560
 			{
2280 2561
 				$value = '';	// blur-values is equal to emtpy
2281 2562
 			}
2282 2563
 			//echo "<p>process_show($this->name) loop was ".self::$loop.", $type: $form_name = ".array2string($value)."</p>\n";
2283
-			if (is_string($type)) list($type,$sub) = explode('-',$type);
2564
+			if (is_string($type))
2565
+			{
2566
+				list($type,$sub) = explode('-',$type);
2567
+			}
2284 2568
 			switch ($type)
2285 2569
 			{
2286 2570
 				case 'ext':
@@ -2344,11 +2628,15 @@  discard block
 block discarded – undo
2344 2628
 								break;
2345 2629
 						}
2346 2630
 					}
2347
-					elseif (in_array($type, array('int', 'integer', 'float')))	// cast int and float and check range
2631
+					elseif (in_array($type, array('int', 'integer', 'float')))
2632
+					{
2633
+						// cast int and float and check range
2348 2634
 					{
2349 2635
 						if ((string)$value !== '' || $attr['needed'])	// empty values are Ok if needed is not set
2350 2636
 						{
2351
-							$value = $type != 'float' ? (int) $value : (float) str_replace(',','.',$value);	// allow for german (and maybe other) format
2637
+							$value = $type != 'float' ? (int) $value : (float) str_replace(',','.',$value);
2638
+					}
2639
+					// allow for german (and maybe other) format
2352 2640
 
2353 2641
 							if (!empty($attr['min']) && $value < $attr['min'])
2354 2642
 							{
@@ -2379,19 +2667,25 @@  discard block
 block discarded – undo
2379 2667
 					}
2380 2668
 					break;
2381 2669
 				case 'select':
2382
-					if ($attr['allowed'])	// only check for $value is allowed, if allowed values are set
2670
+					if ($attr['allowed'])
2671
+					{
2672
+						// only check for $value is allowed, if allowed values are set
2383 2673
 					{
2384 2674
 						foreach(is_array($value) ? $value : array($value) as $val)
2385 2675
 						{
2386 2676
 							if (!($attr['multiple'] && !$val) && !in_array($val,$attr['allowed']))
2387 2677
 							{
2388 2678
 								self::set_validation_error($form_name,lang("'%1' is NOT allowed ('%2')!",$val,implode("','",$attr['allowed'])),'');
2679
+					}
2389 2680
 								$value = '';
2390 2681
 								break;
2391 2682
 							}
2392 2683
 						}
2393 2684
 					}
2394
-					if (is_array($value)) $value = implode(',',$value);
2685
+					if (is_array($value))
2686
+					{
2687
+						$value = implode(',',$value);
2688
+					}
2395 2689
 					if ($value === '' && $attr['needed'])
2396 2690
 					{
2397 2691
 						self::set_validation_error($form_name,lang('Field must not be empty !!!',$value),'');
@@ -2427,17 +2721,27 @@  discard block
 block discarded – undo
2427 2721
 						$file = array();
2428 2722
 						foreach(array('tmp_name','type','size','name','error') as $part)
2429 2723
 						{
2430
-							if (!is_array($_FILES[$name])) break 2;	// happens eg. in forms set via xajax, which do not upload files
2724
+							if (!is_array($_FILES[$name]))
2725
+							{
2726
+								break 2;
2727
+							}
2728
+							// happens eg. in forms set via xajax, which do not upload files
2431 2729
 							$file[$part] = $this->get_array($_FILES[$name],$part.$index.($multiple ? "[$i]" : ''));
2432 2730
 						}
2433
-						if (!$multiple) $file['path'] = $this->get_array($content_in,substr($form_name,0,-1).'_path]');
2731
+						if (!$multiple)
2732
+						{
2733
+							$file['path'] = $this->get_array($content_in,substr($form_name,0,-1).'_path]');
2734
+						}
2434 2735
 						$file['ip'] = $_SERVER['REMOTE_ADDR'];
2435 2736
 						// check if we have an upload error
2436
-						if ($file['error'] && $file['name'] !== '' && !$file['size'])	// ignore empty upload boxes
2737
+						if ($file['error'] && $file['name'] !== '' && !$file['size'])
2738
+						{
2739
+							// ignore empty upload boxes
2437 2740
 						{
2438 2741
 							self::set_validation_error($form_name.($multiple?'[]':''),
2439 2742
 								lang('Error uploading file!')."\n".self::max_upload_size_message(),'');
2440 2743
 						}
2744
+						}
2441 2745
 						if ((string)$file['name'] === '' || $file['tmp_name'] && function_exists('is_uploaded_file') && !is_uploaded_file($file['tmp_name']))
2442 2746
 						{
2443 2747
 							if ($multiple && ($file['name'] === '' || $file['error']))
@@ -2488,9 +2792,15 @@  discard block
 block discarded – undo
2488 2792
 	*/
2489 2793
 	static function set_validation_error($name,$error,$cname=null)
2490 2794
 	{
2491
-		if (is_null($cname)) $cname = self::$name_vars;
2795
+		if (is_null($cname))
2796
+		{
2797
+			$cname = self::$name_vars;
2798
+		}
2492 2799
 		//echo "<p>self::set_validation_error('$name','$error','$cname');</p>\n";
2493
-		if ($cname) $name = self::form_name($cname,$name);
2800
+		if ($cname)
2801
+		{
2802
+			$name = self::form_name($cname,$name);
2803
+		}
2494 2804
 
2495 2805
 		if ($error === false)
2496 2806
 		{
Please login to merge, or discard this patch.
etemplate/inc/class.etemplate_new.inc.php 4 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 	 * Reads an eTemplate from filesystem or DB (not yet supported)
494 494
 	 *
495 495
 	 * @param string $name name of the eTemplate or array with the values for all keys
496
-	 * @param string $template_set=null default try template-set from user and if not found "default"
496
+	 * @param string $template_set default try template-set from user and if not found "default"
497 497
 	 * @param string $lang language, '' loads the pref. lang of the user, 'default' loads the default one '' in the db
498 498
 	 * @param int $group id of the (primary) group of the user or 0 for none, not used at the moment !!!
499 499
 	 * @param string $version version of the eTemplate
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 	 *  disables all cells with name == $name
573 573
 	 *
574 574
 	 * @param sting $name cell-name
575
-	 * @param boolean $disabled=true disable or enable a cell, default true=disable
575
+	 * @param boolean $disabled disable or enable a cell, default true=disable
576 576
 	 * @return reference to attribute
577 577
 	 * @deprecated use disableElement($name, $disabled=true)
578 578
 	 */
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 	 *
591 591
 	 * @param array $old
592 592
 	 * @param array $new
593
-	 * @return array the merged array
593
+	 * @return string the merged array
594 594
 	 */
595 595
 	public static function complete_array_merge($old,$new)
596 596
 	{
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 	/**
619 619
 	 * Debug callback just outputting content
620 620
 	 *
621
-	 * @param array $content=null
621
+	 * @param array $content
622 622
 	 */
623 623
 	public function debug(array $content=null)
624 624
 	{
@@ -650,8 +650,8 @@  discard block
 block discarded – undo
650 650
 	 * Format a number according to user prefs with decimal and thousands separator (later only for readonly)
651 651
 	 *
652 652
 	 * @param int|float|string $number
653
-	 * @param int $num_decimal_places=2
654
-	 * @param boolean $readonly=true
653
+	 * @param int $num_decimal_places
654
+	 * @param boolean $readonly
655 655
 	 * @return string
656 656
 	 */
657 657
 	static public function number_format($number,$num_decimal_places=2,$readonly=true)
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @public boolean
31 31
 	 */
32
-	public $sitemgr=false;
32
+	public $sitemgr = false;
33 33
 
34 34
 	/**
35 35
 	 * Tell egw framework it's ok to call this
@@ -44,17 +44,17 @@  discard block
 block discarded – undo
44 44
 	 * @param string $name of etemplate or array with name and other keys
45 45
 	 * @param string|array $load_via with keys of other etemplate to load in order to get $name
46 46
 	 */
47
-	function __construct($name='',$load_via='')
47
+	function __construct($name = '', $load_via = '')
48 48
 	{
49 49
 		// we do NOT call parent consturctor, as we only want to enherit it's (static) methods
50
-		if (false) parent::__construct ($name);	// satisfy IDE, as we dont call parent constructor
50
+		if (false) parent::__construct($name); // satisfy IDE, as we dont call parent constructor
51 51
 
52 52
 		$this->sitemgr = isset($GLOBALS['Common_BO']) && is_object($GLOBALS['Common_BO']);
53 53
 
54
-		if ($name) $this->read($name,$template='default','default',0,'',$load_via);
54
+		if ($name) $this->read($name, $template = 'default', 'default', 0, '', $load_via);
55 55
 
56 56
 		// generate new etemplate request object, if not already existing
57
-		if(!isset(self::$request)) self::$request = etemplate_request::read();
57
+		if (!isset(self::$request)) self::$request = etemplate_request::read();
58 58
 	}
59 59
 
60 60
 	/**
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @param string|array $params url or array with get-params incl. menuaction
67 67
 	 */
68
-	static function location($params='')
68
+	static function location($params = '')
69 69
 	{
70 70
 		egw::redirect_link(is_array($params) ? '/index.php' : $params,
71 71
 			is_array($params) ? $params : '');
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @param array $changes change made in the last call if looping, only used internaly by process_exec
101 101
 	 * @return string html for $output_mode == 1, else nothing
102 102
 	 */
103
-	function exec($method,array $content,array $sel_options=null,array $readonlys=null,array $preserv=null,$output_mode=0,$ignore_validation='',array $changes=null)
103
+	function exec($method, array $content, array $sel_options = null, array $readonlys = null, array $preserv = null, $output_mode = 0, $ignore_validation = '', array $changes = null)
104 104
 	{
105 105
 		$hook_data = $GLOBALS['egw']->hooks->process(
106 106
 			array('hook_location'   => 'etemplate2_before_exec') +
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
 			$content
110 110
 		);
111 111
 
112
-		foreach($hook_data as $extras) {
112
+		foreach ($hook_data as $extras) {
113 113
 			if (!$extras) continue;
114 114
 
115
-			foreach(isset($extras[0]) ? $extras : array($extras) as $extra) {
115
+			foreach (isset($extras[0]) ? $extras : array($extras) as $extra) {
116 116
 				if ($extra['data'] && is_array($extra['data'])) {
117 117
 					$content = array_merge($content, $extra['data']);
118 118
 				}
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 			$output_mode = 0;
139 139
 			self::$response = egw_json_response::get();
140 140
 		}
141
-		self::$request->output_mode = $output_mode;	// let extensions "know" they are run eg. in a popup
141
+		self::$request->output_mode = $output_mode; // let extensions "know" they are run eg. in a popup
142 142
 		self::$request->content = self::$cont = $content;
143 143
 		self::$request->changes = $changes;
144 144
 		self::$request->sel_options = is_array($sel_options) ? self::fix_sel_options($sel_options) : array();
@@ -162,15 +162,15 @@  discard block
 block discarded – undo
162 162
 		// compile required translations translations
163 163
 		translation::add_app('etemplate');
164 164
 		$currentapp = $GLOBALS['egw_info']['flags']['currentapp'];
165
-		$langRequire = array('common' => array(), 'etemplate' => array());	// keep that order
166
-		foreach(translation::$loaded_apps as $l_app => $lang)
165
+		$langRequire = array('common' => array(), 'etemplate' => array()); // keep that order
166
+		foreach (translation::$loaded_apps as $l_app => $lang)
167 167
 		{
168 168
 			if (!in_array($l_app, array($currentapp, 'custom')))
169 169
 			{
170 170
 				$langRequire[$l_app] = array('app' => $l_app, 'lang' => $lang, 'etag' => translation::etag($l_app, $lang));
171 171
 			}
172 172
 		}
173
-		foreach(array($currentapp, 'custom') as $l_app)
173
+		foreach (array($currentapp, 'custom') as $l_app)
174 174
 		{
175 175
 			if (isset(translation::$loaded_apps[$l_app]))
176 176
 			{
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 		);
192 192
 
193 193
 		// Info required to load the etemplate client-side
194
-		$dom_id = str_replace('.','-',$this->dom_id);
194
+		$dom_id = str_replace('.', '-', $this->dom_id);
195 195
 		$load_array = array(
196 196
 			'name' => $this->name,
197 197
 			'url' => etemplate_widget_template::rel2url($this->rel_path),
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
 		if (self::$response)	// call is within an ajax event / form submit
202 202
 		{
203 203
 			//error_log("Ajax " . __LINE__);
204
-			self::$response->generic('et2_load', $load_array+egw_framework::get_extra());
205
-			egw_framework::clear_extra();	// to not send/set it twice for multiple etemplates (eg. CRM view)
204
+			self::$response->generic('et2_load', $load_array + egw_framework::get_extra());
205
+			egw_framework::clear_extra(); // to not send/set it twice for multiple etemplates (eg. CRM view)
206 206
 		}
207 207
 		else	// first call
208 208
 		{
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
 			egw_framework::includeCSS('/etemplate/templates/default/etemplate2.css');
217 217
 
218 218
 			// check if application of template has a app.js file --> load it
219
-			list($app) = explode('.',$this->name);
219
+			list($app) = explode('.', $this->name);
220 220
 			if (file_exists(EGW_SERVER_ROOT.'/'.$app.'/js/app.js'))
221 221
 			{
222
-				egw_framework::validate_file('.','app',$app,false);
222
+				egw_framework::validate_file('.', 'app', $app, false);
223 223
 			}
224 224
 			// Category styles
225 225
 			categories::css($app);
@@ -235,14 +235,14 @@  discard block
 block discarded – undo
235 235
 				$content = '<form target="egw_iframe_autocomplete_helper" action="'.$form_action.'" id="'.$dom_id.'" class="et2_container"></form>'."\n".
236 236
 					'<iframe name="egw_iframe_autocomplete_helper" style="width:0;height:0;position: absolute;visibility:hidden;"></iframe>';
237 237
 				// add server-side page-generation times
238
-				if($GLOBALS['egw_info']['user']['preferences']['common']['show_generation_time'])
238
+				if ($GLOBALS['egw_info']['user']['preferences']['common']['show_generation_time'])
239 239
 				{
240 240
 					$vars = $GLOBALS['egw']->framework->_get_footer();
241 241
 					$content .= "\n".$vars['page_generation_time'];
242 242
 				}
243 243
 				$GLOBALS['egw']->framework->response->generic("data", array($content));
244
-				$GLOBALS['egw']->framework->response->generic('et2_load',$load_array+egw_framework::get_extra());
245
-				egw_framework::clear_extra();	// to not send/set it twice for multiple etemplates (eg. CRM view)
244
+				$GLOBALS['egw']->framework->response->generic('et2_load', $load_array + egw_framework::get_extra());
245
+				egw_framework::clear_extra(); // to not send/set it twice for multiple etemplates (eg. CRM view)
246 246
 				self::$request = null;
247 247
 				return;
248 248
 			}
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 				echo '<div id="popupMainDiv">'."\n";
262 262
 			}
263 263
 			// Send any accumulated json responses - after flush to avoid sending the buffer as a response
264
-			if(egw_json_response::isJSONResponse())
264
+			if (egw_json_response::isJSONResponse())
265 265
 			{
266 266
 				$load_array['response'] = egw_json_response::get()->returnResult();
267 267
 			}
@@ -286,10 +286,10 @@  discard block
 block discarded – undo
286 286
 	 */
287 287
 	static protected function fix_sel_options(array $sel_options)
288 288
 	{
289
-		foreach($sel_options as &$options)
289
+		foreach ($sel_options as &$options)
290 290
 		{
291
-			if (!is_array($options)||empty($options)) continue;
292
-			foreach($options as $key => $value)
291
+			if (!is_array($options) || empty($options)) continue;
292
+			foreach ($options as $key => $value)
293 293
 			{
294 294
 				if (is_numeric($key) && (!is_array($value) || !isset($value['value'])))
295 295
 				{
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
 		}
326 326
 
327 327
 		// Set current app for validation
328
-		list($app) = explode('.',self::$request->method);
329
-		if(!$app) list($app) = explode('::',self::$request->method);
330
-		if($app)
328
+		list($app) = explode('.', self::$request->method);
329
+		if (!$app) list($app) = explode('::', self::$request->method);
330
+		if ($app)
331 331
 		{
332 332
 			translation::add_app($app);
333 333
 			$GLOBALS['egw_info']['flags']['currentapp'] = $app;
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 		$expand = array(
337 337
 			'cont' => &self::$request->content,
338 338
 		);
339
-		$template->run('validate', array('', $expand, $content, &$validated), true);	// $respect_disabled=true: do NOT validate disabled widgets and children
339
+		$template->run('validate', array('', $expand, $content, &$validated), true); // $respect_disabled=true: do NOT validate disabled widgets and children
340 340
 
341 341
 		if ($no_validation)
342 342
 		{
@@ -359,10 +359,10 @@  discard block
 block discarded – undo
359 359
 				self::complete_array_merge(self::$request->preserv, $validated)
360 360
 			);
361 361
 
362
-		foreach($hook_data as $extras) {
362
+		foreach ($hook_data as $extras) {
363 363
 			if (!$extras) continue;
364 364
 
365
-			foreach(isset($extras[0]) ? $extras : array($extras) as $extra) {
365
+			foreach (isset($extras[0]) ? $extras : array($extras) as $extra) {
366 366
 				if ($extra['data'] && is_array($extra['data'])) {
367 367
 					$validated = array_merge($validated, $extra['data']);
368 368
 				}
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 
377 377
 		$tcontent = array();
378 378
 
379
-		if( is_array($content) ) {
379
+		if (is_array($content)) {
380 380
 			$tcontent = $content;
381 381
 		}
382 382
 		else {
@@ -394,11 +394,11 @@  discard block
 block discarded – undo
394 394
 			);
395 395
 		unset($tcontent);
396 396
 
397
-		if( is_array($content) ) {
398
-			foreach($hook_data as $extras) {
397
+		if (is_array($content)) {
398
+			foreach ($hook_data as $extras) {
399 399
 				if (!$extras) continue;
400 400
 
401
-				foreach(isset($extras[0]) ? $extras : array($extras) as $extra) {
401
+				foreach (isset($extras[0]) ? $extras : array($extras) as $extra) {
402 402
 					if ($extra['data'] && is_array($extra['data'])) {
403 403
 						$content = array_merge($content, $extra['data']);
404 404
 					}
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 		if (isset($GLOBALS['egw_info']['flags']['java_script']))
411 411
 		{
412 412
 			// Strip out any script tags
413
-			$GLOBALS['egw_info']['flags']['java_script'] = preg_replace(array('/(<script[^>]*>)([^<]*)/is','/<\/script>/'),array('$2',''),$GLOBALS['egw_info']['flags']['java_script']);
413
+			$GLOBALS['egw_info']['flags']['java_script'] = preg_replace(array('/(<script[^>]*>)([^<]*)/is', '/<\/script>/'), array('$2', ''), $GLOBALS['egw_info']['flags']['java_script']);
414 414
 			self::$response->script($GLOBALS['egw_info']['flags']['java_script']);
415 415
 			//error_log($app .' added javascript to $GLOBALS[egw_info][flags][java_script] - use egw_json_response->script() instead.');
416 416
 		}
@@ -439,8 +439,8 @@  discard block
 block discarded – undo
439 439
 	static public function process_exec()
440 440
 	{
441 441
 		if (get_magic_quotes_gpc()) $_POST['value'] = stripslashes($_POST['value']);
442
-		$content = json_decode($_POST['value'],true);
443
-		if($content == null && $_POST['exec'])
442
+		$content = json_decode($_POST['value'], true);
443
+		if ($content == null && $_POST['exec'])
444 444
 		{
445 445
 			// Old etemplate submit
446 446
 			error_log("Old etemplate submitted");
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 		$expand = array(
460 460
 			'cont' => &self::$request->content,
461 461
 		);
462
-		$template->run('validate', array('', $expand, $content, &$validated), true);	// $respect_disabled=true: do NOT validate disabled widgets and children
462
+		$template->run('validate', array('', $expand, $content, &$validated), true); // $respect_disabled=true: do NOT validate disabled widgets and children
463 463
 		if (self::validation_errors(self::$request->ignore_validation))
464 464
 		{
465 465
 			error_log(__METHOD__."(,".array2string($content).') validation_errors='.array2string(self::$validation_errors));
@@ -502,11 +502,11 @@  discard block
 block discarded – undo
502 502
 	 *
503 503
 	 * @ToDo supported customized templates stored in DB
504 504
 	 */
505
-	public function read($name,$template_set=null,$lang='default',$group=0,$version='',$load_via='')
505
+	public function read($name, $template_set = null, $lang = 'default', $group = 0, $version = '', $load_via = '')
506 506
 	{
507
-		unset($lang); unset($group);	// not used, but in old signature
508
-		$this->rel_path = self::relPath($this->name=$name, $this->template_set=$template_set,
509
-			$this->version=$version, $this->laod_via = $load_via);
507
+		unset($lang); unset($group); // not used, but in old signature
508
+		$this->rel_path = self::relPath($this->name = $name, $this->template_set = $template_set,
509
+			$this->version = $version, $this->laod_via = $load_via);
510 510
 		//error_log(__METHOD__."('$name', '$template_set', '$lang', $group, '$version', '$load_via') rel_path=".array2string($this->rel_path));
511 511
 
512 512
 		$this->dom_id = $name;
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 	 * @return mixed reference to attribute, usually NULL
550 550
 	 * @deprecated use getElementAttribute($name, $attr)
551 551
 	 */
552
-	public function &get_cell_attribute($name,$attr)
552
+	public function &get_cell_attribute($name, $attr)
553 553
 	{
554 554
 		return self::getElementAttribute($name, $attr);
555 555
 	}
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 	 * @return reference to attribute
564 564
 	 * @deprecated use setElementAttribute($name, $attr, $val)
565 565
 	 */
566
-	public function &set_cell_attribute($name,$attr,$val)
566
+	public function &set_cell_attribute($name, $attr, $val)
567 567
 	{
568 568
 		return self::setElementAttribute($name, $attr, $val);
569 569
 	}
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 	 * @return reference to attribute
577 577
 	 * @deprecated use disableElement($name, $disabled=true)
578 578
 	 */
579
-	public function disable_cells($name,$disabled=True)
579
+	public function disable_cells($name, $disabled = True)
580 580
 	{
581 581
 		return self::disableElement($name, $disabled);
582 582
 	}
@@ -592,23 +592,23 @@  discard block
 block discarded – undo
592 592
 	 * @param array $new
593 593
 	 * @return array the merged array
594 594
 	 */
595
-	public static function complete_array_merge($old,$new)
595
+	public static function complete_array_merge($old, $new)
596 596
 	{
597 597
 		if (is_array($new))
598 598
 		{
599
-			if (!is_array($old)) $old = (array) $old;
599
+			if (!is_array($old)) $old = (array)$old;
600 600
 
601
-			foreach($new as $k => $v)
601
+			foreach ($new as $k => $v)
602 602
 			{
603
-				if (!is_array($v) || !isset($old[$k]) || 	// no array or a new array
604
-					isset($v[0]) && !is_array($v[0]) && isset($v[count($v)-1])	|| // or no associative array, eg. selecting multiple accounts
603
+				if (!is_array($v) || !isset($old[$k]) || // no array or a new array
604
+					isset($v[0]) && !is_array($v[0]) && isset($v[count($v) - 1]) || // or no associative array, eg. selecting multiple accounts
605 605
 					is_array($v) && count($v) == 0)			// Empty array replacing non-empty
606 606
 				{
607 607
 					$old[$k] = $v;
608 608
 				}
609 609
 				else
610 610
 				{
611
-					$old[$k] = self::complete_array_merge($old[$k],$v);
611
+					$old[$k] = self::complete_array_merge($old[$k], $v);
612 612
 				}
613 613
 			}
614 614
 		}
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 	 *
621 621
 	 * @param array $content=null
622 622
 	 */
623
-	public function debug(array $content=null)
623
+	public function debug(array $content = null)
624 624
 	{
625 625
 		common::egw_header();
626 626
 		_debug_array($content);
@@ -636,11 +636,11 @@  discard block
 block discarded – undo
636 636
 	 * @param int &$max_upload=null on return max. upload size in byte
637 637
 	 * @return string
638 638
 	 */
639
-	static function max_upload_size_message(&$max_upload=null)
639
+	static function max_upload_size_message(&$max_upload = null)
640 640
 	{
641 641
 		$upload_max_filesize = ini_get('upload_max_filesize');
642 642
 		$post_max_size = ini_get('post_max_size');
643
-		$max_upload = min(self::km2int($upload_max_filesize),self::km2int($post_max_size)-2800);
643
+		$max_upload = min(self::km2int($upload_max_filesize), self::km2int($post_max_size) - 2800);
644 644
 
645 645
 		return lang('Maximum size for uploads').': '.egw_vfs::hsize($max_upload).
646 646
 			" (php.ini: upload_max_filesize=$upload_max_filesize, post_max_size=$post_max_size)";
@@ -654,9 +654,9 @@  discard block
 block discarded – undo
654 654
 	 * @param boolean $readonly=true
655 655
 	 * @return string
656 656
 	 */
657
-	static public function number_format($number,$num_decimal_places=2,$readonly=true)
657
+	static public function number_format($number, $num_decimal_places = 2, $readonly = true)
658 658
 	{
659
-		static $dec_separator=null,$thousands_separator=null;
659
+		static $dec_separator = null, $thousands_separator = null;
660 660
 		if (is_null($dec_separator))
661 661
 		{
662 662
 			$dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0];
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
 		}
666 666
 		if ((string)$number === '') return '';
667 667
 
668
-		return number_format(str_replace(' ','',$number),$num_decimal_places,$dec_separator,$readonly ? $thousands_separator : '');
668
+		return number_format(str_replace(' ', '', $number), $num_decimal_places, $dec_separator, $readonly ? $thousands_separator : '');
669 669
 	}
670 670
 
671 671
 	/**
@@ -678,13 +678,13 @@  discard block
 block discarded – undo
678 678
 	{
679 679
 		if (!is_numeric($size))
680 680
 		{
681
-			switch(strtolower(substr($size,-1)))
681
+			switch (strtolower(substr($size, -1)))
682 682
 			{
683 683
 				case 'm':
684
-					$size = 1024*1024*(int)$size;
684
+					$size = 1024 * 1024 * (int)$size;
685 685
 					break;
686 686
 				case 'k':
687
-					$size = 1024*(int)$size;
687
+					$size = 1024 * (int)$size;
688 688
 					break;
689 689
 			}
690 690
 		}
@@ -693,16 +693,16 @@  discard block
 block discarded – undo
693 693
 }
694 694
 
695 695
 // Try to discover all widgets, as names don't always match tags (eg: listbox is in menupopup)
696
-$files = scandir(EGW_INCLUDE_ROOT . '/etemplate/inc');
697
-foreach($files as $filename)
696
+$files = scandir(EGW_INCLUDE_ROOT.'/etemplate/inc');
697
+foreach ($files as $filename)
698 698
 {
699
-	if(strpos($filename, 'class.etemplate_widget') === 0)
699
+	if (strpos($filename, 'class.etemplate_widget') === 0)
700 700
 	{
701 701
 		try
702 702
 		{
703 703
 			include_once($filename);
704 704
 		}
705
-		catch(Exception $e)
705
+		catch (Exception $e)
706 706
 		{
707 707
 			error_log($e->getMessage());
708 708
 		}
@@ -711,17 +711,17 @@  discard block
 block discarded – undo
711 711
 
712 712
 // Use hook to load custom widgets from other apps
713 713
 $widgets = $GLOBALS['egw']->hooks->process('etemplate2_register_widgets');
714
-foreach($widgets as $app => $list)
714
+foreach ($widgets as $app => $list)
715 715
 {
716 716
 	if (is_array($list))
717 717
 	{
718
-		foreach($list as $class)
718
+		foreach ($list as $class)
719 719
 		{
720 720
 			try
721 721
 			{
722
-				class_exists($class);	// trigger autoloader
722
+				class_exists($class); // trigger autoloader
723 723
 			}
724
-			catch(Exception $e)
724
+			catch (Exception $e)
725 725
 			{
726 726
 				error_log($e->getMessage());
727 727
 			}
Please login to merge, or discard this patch.
Braces   +105 added lines, -33 removed lines patch added patch discarded remove patch
@@ -47,14 +47,24 @@  discard block
 block discarded – undo
47 47
 	function __construct($name='',$load_via='')
48 48
 	{
49 49
 		// we do NOT call parent consturctor, as we only want to enherit it's (static) methods
50
-		if (false) parent::__construct ($name);	// satisfy IDE, as we dont call parent constructor
50
+		if (false)
51
+		{
52
+			parent::__construct ($name);
53
+		}
54
+		// satisfy IDE, as we dont call parent constructor
51 55
 
52 56
 		$this->sitemgr = isset($GLOBALS['Common_BO']) && is_object($GLOBALS['Common_BO']);
53 57
 
54
-		if ($name) $this->read($name,$template='default','default',0,'',$load_via);
58
+		if ($name)
59
+		{
60
+			$this->read($name,$template='default','default',0,'',$load_via);
61
+		}
55 62
 
56 63
 		// generate new etemplate request object, if not already existing
57
-		if(!isset(self::$request)) self::$request = etemplate_request::read();
64
+		if(!isset(self::$request))
65
+		{
66
+			self::$request = etemplate_request::read();
67
+		}
58 68
 	}
59 69
 
60 70
 	/**
@@ -109,19 +119,27 @@  discard block
 block discarded – undo
109 119
 			$content
110 120
 		);
111 121
 
112
-		foreach($hook_data as $extras) {
113
-			if (!$extras) continue;
122
+		foreach($hook_data as $extras)
123
+		{
124
+			if (!$extras)
125
+			{
126
+				continue;
127
+			}
114 128
 
115
-			foreach(isset($extras[0]) ? $extras : array($extras) as $extra) {
116
-				if ($extra['data'] && is_array($extra['data'])) {
129
+			foreach(isset($extras[0]) ? $extras : array($extras) as $extra)
130
+			{
131
+				if ($extra['data'] && is_array($extra['data']))
132
+				{
117 133
 					$content = array_merge($content, $extra['data']);
118 134
 				}
119 135
 
120
-				if ($extra['preserve'] && is_array($extra['preserve'])) {
136
+				if ($extra['preserve'] && is_array($extra['preserve']))
137
+				{
121 138
 					$preserv = array_merge($preserv, $extra['preserve']);
122 139
 				}
123 140
 
124
-				if ($extra['readonlys'] && is_array($extra['readonlys'])) {
141
+				if ($extra['readonlys'] && is_array($extra['readonlys']))
142
+				{
125 143
 					$readonlys = array_merge($readonlys, $extra['readonlys']);
126 144
 				}
127 145
 			}
@@ -131,7 +149,10 @@  discard block
 block discarded – undo
131 149
 		// Include the etemplate2 javascript code
132 150
 		egw_framework::validate_file('.', 'etemplate2', 'etemplate');
133 151
 
134
-		if (!$this->rel_path) throw new egw_exception_assertion_failed("No (valid) template '$this->name' found!");
152
+		if (!$this->rel_path)
153
+		{
154
+			throw new egw_exception_assertion_failed("No (valid) template '$this->name' found!");
155
+		}
135 156
 
136 157
 		if ($output_mode == 4)
137 158
 		{
@@ -146,14 +167,23 @@  discard block
 block discarded – undo
146 167
 		self::$request->preserv = $preserv ? $preserv : array();
147 168
 		self::$request->method = $method;
148 169
 		self::$request->ignore_validation = $ignore_validation;
149
-		if (self::$request->output_mode == -1) self::$request->output_mode = 0;
170
+		if (self::$request->output_mode == -1)
171
+		{
172
+			self::$request->output_mode = 0;
173
+		}
150 174
 		self::$request->template = $this->as_array();
151 175
 
152
-		if (empty($this->name)) throw new egw_exception_assertion_failed("Template  name is not set '$this->name' !");
176
+		if (empty($this->name))
177
+		{
178
+			throw new egw_exception_assertion_failed("Template  name is not set '$this->name' !");
179
+		}
153 180
 		// instanciate template to fill self::$request->sel_options for select-* widgets
154 181
 		// not sure if we want to handle it this way, thought otherwise we will have a few ajax request for each dialog fetching predefined selectboxes
155 182
 		$template = etemplate_widget_template::instance($this->name, $this->template_set, $this->version, $this->laod_via);
156
-		if (!$template) throw new egw_exception_assertion_failed("Template $this->name not instanciable! Maybe you forgot to rename template id.");
183
+		if (!$template)
184
+		{
185
+			throw new egw_exception_assertion_failed("Template $this->name not instanciable! Maybe you forgot to rename template id.");
186
+		}
157 187
 		$template->run('beforeSendToClient', array('', array('cont'=>$content)));
158 188
 
159 189
 		// some apps (eg. InfoLog) set app_header only in get_rows depending on filter settings
@@ -198,10 +228,13 @@  discard block
 block discarded – undo
198 228
 			'data' => $data,
199 229
 			'DOMNodeID' => $dom_id,
200 230
 		);
201
-		if (self::$response)	// call is within an ajax event / form submit
231
+		if (self::$response)
232
+		{
233
+			// call is within an ajax event / form submit
202 234
 		{
203 235
 			//error_log("Ajax " . __LINE__);
204 236
 			self::$response->generic('et2_load', $load_array+egw_framework::get_extra());
237
+		}
205 238
 			egw_framework::clear_extra();	// to not send/set it twice for multiple etemplates (eg. CRM view)
206 239
 		}
207 240
 		else	// first call
@@ -227,7 +260,10 @@  discard block
 block discarded – undo
227 260
 			// set action attribute for autocomplete form tag
228 261
 			// as firefox complains on about:balnk action, thus we have to literaly submit the form to a blank html
229 262
 			$form_action = "about:blank";
230
-			if (html::$user_agent == 'firefox') $form_action = $GLOBALS['egw_info']['server']['webserver_url'].'/etemplate/empty.html';
263
+			if (html::$user_agent == 'firefox')
264
+			{
265
+				$form_action = $GLOBALS['egw_info']['server']['webserver_url'].'/etemplate/empty.html';
266
+			}
231 267
 
232 268
 			// check if we are in an ajax-exec call from jdots template (or future other tabbed templates)
233 269
 			if (isset($GLOBALS['egw']->framework->response))
@@ -288,7 +324,10 @@  discard block
 block discarded – undo
288 324
 	{
289 325
 		foreach($sel_options as &$options)
290 326
 		{
291
-			if (!is_array($options)||empty($options)) continue;
327
+			if (!is_array($options)||empty($options))
328
+			{
329
+				continue;
330
+			}
292 331
 			foreach($options as $key => $value)
293 332
 			{
294 333
 				if (is_numeric($key) && (!is_array($value) || !isset($value['value'])))
@@ -326,7 +365,10 @@  discard block
 block discarded – undo
326 365
 
327 366
 		// Set current app for validation
328 367
 		list($app) = explode('.',self::$request->method);
329
-		if(!$app) list($app) = explode('::',self::$request->method);
368
+		if(!$app)
369
+		{
370
+			list($app) = explode('::',self::$request->method);
371
+		}
330 372
 		if($app)
331 373
 		{
332 374
 			translation::add_app($app);
@@ -359,11 +401,17 @@  discard block
 block discarded – undo
359 401
 				self::complete_array_merge(self::$request->preserv, $validated)
360 402
 			);
361 403
 
362
-		foreach($hook_data as $extras) {
363
-			if (!$extras) continue;
404
+		foreach($hook_data as $extras)
405
+		{
406
+			if (!$extras)
407
+			{
408
+				continue;
409
+			}
364 410
 
365
-			foreach(isset($extras[0]) ? $extras : array($extras) as $extra) {
366
-				if ($extra['data'] && is_array($extra['data'])) {
411
+			foreach(isset($extras[0]) ? $extras : array($extras) as $extra)
412
+			{
413
+				if ($extra['data'] && is_array($extra['data']))
414
+				{
367 415
 					$validated = array_merge($validated, $extra['data']);
368 416
 				}
369 417
 			}
@@ -376,10 +424,12 @@  discard block
 block discarded – undo
376 424
 
377 425
 		$tcontent = array();
378 426
 
379
-		if( is_array($content) ) {
427
+		if( is_array($content) )
428
+		{
380 429
 			$tcontent = $content;
381 430
 		}
382
-		else {
431
+		else
432
+		{
383 433
 			$tcontent = self::complete_array_merge(
384 434
 				self::$request->preserv,
385 435
 				$validated
@@ -394,12 +444,19 @@  discard block
 block discarded – undo
394 444
 			);
395 445
 		unset($tcontent);
396 446
 
397
-		if( is_array($content) ) {
398
-			foreach($hook_data as $extras) {
399
-				if (!$extras) continue;
447
+		if( is_array($content) )
448
+		{
449
+			foreach($hook_data as $extras)
450
+			{
451
+				if (!$extras)
452
+				{
453
+					continue;
454
+				}
400 455
 
401
-				foreach(isset($extras[0]) ? $extras : array($extras) as $extra) {
402
-					if ($extra['data'] && is_array($extra['data'])) {
456
+				foreach(isset($extras[0]) ? $extras : array($extras) as $extra)
457
+				{
458
+					if ($extra['data'] && is_array($extra['data']))
459
+					{
403 460
 						$content = array_merge($content, $extra['data']);
404 461
 					}
405 462
 				}
@@ -438,7 +495,10 @@  discard block
 block discarded – undo
438 495
 	 */
439 496
 	static public function process_exec()
440 497
 	{
441
-		if (get_magic_quotes_gpc()) $_POST['value'] = stripslashes($_POST['value']);
498
+		if (get_magic_quotes_gpc())
499
+		{
500
+			$_POST['value'] = stripslashes($_POST['value']);
501
+		}
442 502
 		$content = json_decode($_POST['value'],true);
443 503
 		if($content == null && $_POST['exec'])
444 504
 		{
@@ -596,16 +656,22 @@  discard block
 block discarded – undo
596 656
 	{
597 657
 		if (is_array($new))
598 658
 		{
599
-			if (!is_array($old)) $old = (array) $old;
659
+			if (!is_array($old))
660
+			{
661
+				$old = (array) $old;
662
+			}
600 663
 
601 664
 			foreach($new as $k => $v)
602 665
 			{
603 666
 				if (!is_array($v) || !isset($old[$k]) || 	// no array or a new array
604 667
 					isset($v[0]) && !is_array($v[0]) && isset($v[count($v)-1])	|| // or no associative array, eg. selecting multiple accounts
605
-					is_array($v) && count($v) == 0)			// Empty array replacing non-empty
668
+					is_array($v) && count($v) == 0)
669
+				{
670
+					// Empty array replacing non-empty
606 671
 				{
607 672
 					$old[$k] = $v;
608 673
 				}
674
+				}
609 675
 				else
610 676
 				{
611 677
 					$old[$k] = self::complete_array_merge($old[$k],$v);
@@ -660,10 +726,16 @@  discard block
 block discarded – undo
660 726
 		if (is_null($dec_separator))
661 727
 		{
662 728
 			$dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0];
663
-			if (empty($dec_separator)) $dec_separator = '.';
729
+			if (empty($dec_separator))
730
+			{
731
+				$dec_separator = '.';
732
+			}
664 733
 			$thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1];
665 734
 		}
666
-		if ((string)$number === '') return '';
735
+		if ((string)$number === '')
736
+		{
737
+			return '';
738
+		}
667 739
 
668 740
 		return number_format(str_replace(' ','',$number),$num_decimal_places,$dec_separator,$readonly ? $thousands_separator : '');
669 741
 	}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -153,7 +153,7 @@
 block discarded – undo
153 153
 		// instanciate template to fill self::$request->sel_options for select-* widgets
154 154
 		// not sure if we want to handle it this way, thought otherwise we will have a few ajax request for each dialog fetching predefined selectboxes
155 155
 		$template = etemplate_widget_template::instance($this->name, $this->template_set, $this->version, $this->laod_via);
156
-		if (!$template) throw new egw_exception_assertion_failed("Template $this->name not instanciable! Maybe you forgot to rename template id.");
156
+		if (!$template) throw new egw_exception_assertion_failed("template $this->name not instanciable! Maybe you forgot to rename template id.");
157 157
 		$template->run('beforeSendToClient', array('', array('cont'=>$content)));
158 158
 
159 159
 		// some apps (eg. InfoLog) set app_header only in get_rows depending on filter settings
Please login to merge, or discard this patch.