Completed
Push — 16.1 ( 592c74...b502d4 )
by Ralf
43:09 queued 19:16
created
api/src/Etemplate/Widget/Vfs.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -230,6 +230,7 @@
 block discarded – undo
230 230
 	* If the entry is not yet created, the file information is stored into the widget's value.
231 231
 	* When the form is submitted, the information for all files uploaded is available in the returned
232 232
 	* $content array and the application should deal with the file.
233
+	* @return string
233 234
 	*/
234 235
 	public static function store_file($path, $file)
235 236
 	{
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -224,13 +224,13 @@
 block discarded – undo
224 224
 	}
225 225
 
226 226
 	/**
227
-	* Ajax callback to receive an incoming file
228
-	*
229
-	* The incoming file is automatically placed into the appropriate VFS location.
230
-	* If the entry is not yet created, the file information is stored into the widget's value.
231
-	* When the form is submitted, the information for all files uploaded is available in the returned
232
-	* $content array and the application should deal with the file.
233
-	*/
227
+	 * Ajax callback to receive an incoming file
228
+	 *
229
+	 * The incoming file is automatically placed into the appropriate VFS location.
230
+	 * If the entry is not yet created, the file information is stored into the widget's value.
231
+	 * When the form is submitted, the information for all files uploaded is available in the returned
232
+	 * $content array and the application should deal with the file.
233
+	 */
234 234
 	public static function store_file($path, $file)
235 235
 	{
236 236
 		$name = $_REQUEST['widget_id'];
Please login to merge, or discard this patch.
Braces   +40 added lines, -10 removed lines patch added patch discarded remove patch
@@ -27,7 +27,10 @@  discard block
 block discarded – undo
27 27
 
28 28
 	public function __construct($xml='')
29 29
 	{
30
-		if($xml) parent::__construct($xml);
30
+		if($xml)
31
+		{
32
+			parent::__construct($xml);
33
+		}
31 34
 	}
32 35
 
33 36
 	/**
@@ -64,9 +67,15 @@  discard block
 block discarded – undo
64 67
 				}
65 68
 				$value =& self::get_array(self::$request->content, $form_name, true);
66 69
 				$path = Api\Link::vfs_path($app,$id,'',true);
67
-				if (!empty($relpath)) $path .= '/'.$relpath;
70
+				if (!empty($relpath))
71
+				{
72
+					$path .= '/'.$relpath;
73
+				}
68 74
 
69
-				if (true) $value = array();
75
+				if (true)
76
+				{
77
+					$value = array();
78
+				}
70 79
 
71 80
 				// Single file, already existing
72 81
 				if (substr($path,-1) != '/' && Api\Vfs::file_exists($path) && !Api\Vfs::is_dir($path))
@@ -194,7 +203,10 @@  discard block
 block discarded – undo
194 203
 				$replace[substr($link['id']['tmp_name'], strlen(Api\Vfs::PREFIX))] =
195 204
 					Api\Link::vfs_path($app, $id, Api\Vfs::basename($link['id']['tmp_name']), true);
196 205
 
197
-				if (!in_array($matches[1], $remove_dir)) $remove_dir[] = $matches[1];
206
+				if (!in_array($matches[1], $remove_dir))
207
+				{
208
+					$remove_dir[] = $matches[1];
209
+				}
198 210
 			}
199 211
 		}
200 212
 		if ($replace)
@@ -218,7 +230,10 @@  discard block
 block discarded – undo
218 230
 	 */
219 231
 	static function get_temp_dir($app, $postfix=null)
220 232
 	{
221
-		if (!isset($postfix)) $postfix = md5(time().session_id());
233
+		if (!isset($postfix))
234
+		{
235
+			$postfix = md5(time().session_id());
236
+		}
222 237
 
223 238
 		return '/home/'.$GLOBALS['egw_info']['user']['account_lid'].'/.tmp/'.$app.'_'.$postfix;
224 239
 	}
@@ -245,10 +260,13 @@  discard block
 block discarded – undo
245 260
 		{
246 261
 			// add extension to path
247 262
 			$parts = explode('.',$filename);
248
-			if (($extension = array_pop($parts)) && Api\MimeMagic::ext2mime($extension))       // really an extension --> add it to path
263
+			if (($extension = array_pop($parts)) && Api\MimeMagic::ext2mime($extension))
264
+			{
265
+				// really an extension --> add it to path
249 266
 			{
250 267
 				$path .= '.'.$extension;
251 268
 			}
269
+			}
252 270
 		}
253 271
 		else    // multiple upload with dir given (trailing slash)
254 272
 		{
@@ -294,7 +312,10 @@  discard block
 block discarded – undo
294 312
 		switch($this->type)
295 313
 		{
296 314
 			case 'vfs-upload':
297
-				if(!is_array($value)) $value = array();
315
+				if(!is_array($value))
316
+				{
317
+					$value = array();
318
+				}
298 319
 				/* Check & skip files that made it asyncronously
299 320
 				list($app,$id,$relpath) = explode(':',$this->id,3);
300 321
 				//...
@@ -305,7 +326,10 @@  discard block
 block discarded – undo
305 326
 				parent::validate($cname, $content, $validated);
306 327
 				break;
307 328
 		}
308
-		if (true) $valid = $value;
329
+		if (true)
330
+		{
331
+			$valid = $value;
332
+		}
309 333
 	}
310 334
 
311 335
 	/**
@@ -317,14 +341,20 @@  discard block
 block discarded – undo
317 341
 		if (empty($id) || $id == 'undefined')
318 342
 		{
319 343
 			static $tmppath = array();      // static var, so all vfs-uploads get created in the same temporary dir
320
-			if (!isset($tmppath[$app])) $tmppath[$app] = self::get_temp_dir ($app);
344
+			if (!isset($tmppath[$app]))
345
+			{
346
+				$tmppath[$app] = self::get_temp_dir ($app);
347
+			}
321 348
 			$path = $tmppath[$app];
322 349
 		}
323 350
 		else
324 351
 		{
325 352
 			$path = Api\Link::vfs_path($app,$id,'',true);
326 353
 		}
327
-		if (!empty($relpath)) $path .= '/'.$relpath;
354
+		if (!empty($relpath))
355
+		{
356
+			$path .= '/'.$relpath;
357
+		}
328 358
 		return $path;
329 359
 	}
330 360
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -41 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
 	// Legacy option for vfs-upload
26 26
 	protected $legacy_options = "mime";
27 27
 
28
-	public function __construct($xml='')
28
+	public function __construct($xml = '')
29 29
 	{
30
-		if($xml) parent::__construct($xml);
30
+		if ($xml) parent::__construct($xml);
31 31
 	}
32 32
 
33 33
 	/**
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 	 */
37 37
 	public function beforeSendToClient($cname, $expand = array())
38 38
 	{
39
-		if($this->type == 'vfs-upload' || $this->attrs['type'] == 'vfs-upload')
39
+		if ($this->type == 'vfs-upload' || $this->attrs['type'] == 'vfs-upload')
40 40
 		{
41 41
 			$form_name = self::form_name($cname, $this->id, $expand ? $expand : array('cont'=>self::$request->content));
42
-			if($this->attrs['path'])
42
+			if ($this->attrs['path'])
43 43
 			{
44 44
 				$path = $this->attrs['path'];
45 45
 			}
@@ -50,26 +50,26 @@  discard block
 block discarded – undo
50 50
 
51 51
 			$this->setElementAttribute($form_name, 'path', $path);
52 52
 			// ID maps to path - check there for any existing files
53
-			list($app,$id,$relpath) = explode(':',$path,3);
54
-			if($app && $id)
53
+			list($app, $id, $relpath) = explode(':', $path, 3);
54
+			if ($app && $id)
55 55
 			{
56
-				if(!is_numeric($id))
56
+				if (!is_numeric($id))
57 57
 				{
58
-					$_id = self::expand_name($id,0,0,0,0,self::$request->content);
59
-					if($_id != $id)
58
+					$_id = self::expand_name($id, 0, 0, 0, 0, self::$request->content);
59
+					if ($_id != $id)
60 60
 					{
61 61
 						$id = $_id;
62 62
 						$form_name = "$app:$id:$relpath";
63 63
 					}
64 64
 				}
65
-				$value =& self::get_array(self::$request->content, $form_name, true);
66
-				$path = Api\Link::vfs_path($app,$id,'',true);
65
+				$value = & self::get_array(self::$request->content, $form_name, true);
66
+				$path = Api\Link::vfs_path($app, $id, '', true);
67 67
 				if (!empty($relpath)) $path .= '/'.$relpath;
68 68
 
69 69
 				if (true) $value = array();
70 70
 
71 71
 				// Single file, already existing
72
-				if (substr($path,-1) != '/' && Api\Vfs::file_exists($path) && !Api\Vfs::is_dir($path))
72
+				if (substr($path, -1) != '/' && Api\Vfs::file_exists($path) && !Api\Vfs::is_dir($path))
73 73
 				{
74 74
 					$file = Api\Vfs::stat($path);
75 75
 					$file['path'] = $path;
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 					$value = array($file);
79 79
 				}
80 80
 				// Single file, missing extension in path
81
-				else if (substr($path, -1) != '/' && !Api\Vfs::file_exists($path) && $relpath && substr($relpath,-4,1) !== '.')
81
+				else if (substr($path, -1) != '/' && !Api\Vfs::file_exists($path) && $relpath && substr($relpath, -4, 1) !== '.')
82 82
 				{
83
-					$find = Api\Vfs::find(substr($path,0, - strlen($relpath)), array(
83
+					$find = Api\Vfs::find(substr($path, 0, - strlen($relpath)), array(
84 84
 						'type' => 'f',
85 85
 						'maxdepth' => 1,
86
-						'name' => $relpath . '*'
86
+						'name' => $relpath.'*'
87 87
 					));
88
-					foreach($find as $file)
88
+					foreach ($find as $file)
89 89
 					{
90 90
 						$file_info = Api\Vfs::stat($file);
91 91
 						$file_info['path'] = $file;
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 				else if (substr($path, -1) == '/' && Api\Vfs::is_dir($path))
98 98
 				{
99 99
 					$scan = Api\Vfs::scandir($path);
100
-					foreach($scan as $file)
100
+					foreach ($scan as $file)
101 101
 					{
102 102
 						$file_info = Api\Vfs::stat("$path$file");
103 103
 						$file_info['path'] = "$path$file";
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	public static function ajax_upload()
114 114
 	{
115 115
 		parent::ajax_upload();
116
-		foreach($_FILES as $file)
116
+		foreach ($_FILES as $file)
117 117
 		{
118 118
 			self::store_file($_REQUEST['path'] ? $_REQUEST['path'] : $_REQUEST['widget_id'], $file);
119 119
 		}
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	{
127 127
 		$request_id = urldecode($_REQUEST['request_id']);
128 128
 		$widget_id = $_REQUEST['widget_id'];
129
-		if(!self::$request = Etemplate\Request::read($request_id))
129
+		if (!self::$request = Etemplate\Request::read($request_id))
130 130
 		{
131 131
 			$error = lang("Could not read session");
132 132
 		}
@@ -143,8 +143,7 @@  discard block
 block discarded – undo
143 143
 		else
144 144
 		{
145 145
 			$data = self::$request->content[$widget_id];
146
-			$path = self::store_file($path = (!is_array($data) && $data[0] == '/' ? $data :
147
-				self::get_vfs_path($data['to_app'].':'.$data['to_id'])).'/', $_FILES['upload']);
146
+			$path = self::store_file($path = (!is_array($data) && $data[0] == '/' ? $data : self::get_vfs_path($data['to_app'].':'.$data['to_id'])).'/', $_FILES['upload']);
148 147
 
149 148
 			// store temp. vfs-path like links to be able to move it to correct location after entry is stored
150 149
 			if (!$data['to_id'] || is_array($data['to_id']))
@@ -187,10 +186,10 @@  discard block
 block discarded – undo
187 186
 	static function fix_html_dragins($app, $id, array $links, &$html)
188 187
 	{
189 188
 		$replace = $remove_dir = array();
190
-		foreach($links as $link)
189
+		foreach ($links as $link)
191 190
 		{
192 191
 			$matches = null;
193
-			if (is_array($link) && preg_match('|^'.preg_quote(Api\Vfs::PREFIX,'|').'('.preg_quote(self::get_temp_dir($app, ''), '|').'[^/]+)/|', $link['id']['tmp_name'], $matches))
192
+			if (is_array($link) && preg_match('|^'.preg_quote(Api\Vfs::PREFIX, '|').'('.preg_quote(self::get_temp_dir($app, ''), '|').'[^/]+)/|', $link['id']['tmp_name'], $matches))
194 193
 			{
195 194
 				$replace[substr($link['id']['tmp_name'], strlen(Api\Vfs::PREFIX))] =
196 195
 					Api\Link::vfs_path($app, $id, Api\Vfs::basename($link['id']['tmp_name']), true);
@@ -202,7 +201,7 @@  discard block
 block discarded – undo
202 201
 		{
203 202
 			$html = strtr($old = $html, $replace);
204 203
 			// remove all dirs
205
-			foreach($remove_dir as $dir)
204
+			foreach ($remove_dir as $dir)
206 205
 			{
207 206
 				Api\Vfs::remove($dir);
208 207
 			}
@@ -217,7 +216,7 @@  discard block
 block discarded – undo
217 216
 	 * @param string $postfix =null default random id
218 217
 	 * @return string vfs path
219 218
 	 */
220
-	static function get_temp_dir($app, $postfix=null)
219
+	static function get_temp_dir($app, $postfix = null)
221 220
 	{
222 221
 		if (!isset($postfix)) $postfix = md5(time().session_id());
223 222
 
@@ -237,15 +236,15 @@  discard block
 block discarded – undo
237 236
 		$name = $_REQUEST['widget_id'];
238 237
 
239 238
 		// Find real path
240
-		if($path[0] != '/')
239
+		if ($path[0] != '/')
241 240
 		{
242 241
 			$path = self::get_vfs_path($path);
243 242
 		}
244 243
 		$filename = $file['name'];
245
-		if (substr($path,-1) != '/')
244
+		if (substr($path, -1) != '/')
246 245
 		{
247 246
 			// add extension to path
248
-			$parts = explode('.',$filename);
247
+			$parts = explode('.', $filename);
249 248
 			if (($extension = array_pop($parts)) && Api\MimeMagic::ext2mime($extension))       // really an extension --> add it to path
250 249
 			{
251 250
 				$path .= '.'.$extension;
@@ -257,17 +256,17 @@  discard block
 block discarded – undo
257 256
 		}
258 257
 		if (!($dir = Api\Vfs::dirname($path)))
259 258
 		{
260
-			self::set_validation_error($name,lang('Error create parent directory %1!', "dirname('$path') === false"));
259
+			self::set_validation_error($name, lang('Error create parent directory %1!', "dirname('$path') === false"));
261 260
 			return false;
262 261
 		}
263
-		if (!Api\Vfs::file_exists($dir) && !Api\Vfs::mkdir($dir,null,STREAM_MKDIR_RECURSIVE))
262
+		if (!Api\Vfs::file_exists($dir) && !Api\Vfs::mkdir($dir, null, STREAM_MKDIR_RECURSIVE))
264 263
 		{
265
-			self::set_validation_error($name,lang('Error create parent directory %1!',Api\Vfs::decodePath($dir)));
264
+			self::set_validation_error($name, lang('Error create parent directory %1!', Api\Vfs::decodePath($dir)));
266 265
 			return false;
267 266
 		}
268
-		if (!copy($file['tmp_name'],Api\Vfs::PREFIX.$path))
267
+		if (!copy($file['tmp_name'], Api\Vfs::PREFIX.$path))
269 268
 		{
270
-			self::set_validation_error($name,lang('Error copying uploaded file to vfs!'));
269
+			self::set_validation_error($name, lang('Error copying uploaded file to vfs!'));
271 270
 			return false;
272 271
 		}
273 272
 
@@ -286,7 +285,7 @@  discard block
 block discarded – undo
286 285
 	 * @param array $content
287 286
 	 * @param array &$validated=array() validated content
288 287
 	 */
289
-	public function validate($cname, array $expand, array $content, &$validated=array())
288
+	public function validate($cname, array $expand, array $content, &$validated = array())
290 289
 	{
291 290
 		// do not validate, as it would overwrite preserved values with null!
292 291
 		if (in_array($this->type, array('vfs-size', 'vfs-uid', 'vfs-gid', 'vfs', 'vfs-mime')))
@@ -295,12 +294,12 @@  discard block
 block discarded – undo
295 294
 		}
296 295
 		$form_name = self::form_name($cname, $this->id, $expand);
297 296
 		$value = $value_in = self::get_array($content, $form_name);
298
-		$valid =& self::get_array($validated, $form_name, true);
297
+		$valid = & self::get_array($validated, $form_name, true);
299 298
 
300
-		switch($this->type)
299
+		switch ($this->type)
301 300
 		{
302 301
 			case 'vfs-upload':
303
-				if(!is_array($value)) $value = array();
302
+				if (!is_array($value)) $value = array();
304 303
 				/* Check & skip files that made it asyncronously
305 304
 				list($app,$id,$relpath) = explode(':',$this->id,3);
306 305
 				//...
@@ -319,16 +318,16 @@  discard block
 block discarded – undo
319 318
 	 */
320 319
 	public static function get_vfs_path($path)
321 320
 	{
322
-		list($app,$id,$relpath) = explode(':',$path,3);
321
+		list($app, $id, $relpath) = explode(':', $path, 3);
323 322
 		if (empty($id) || $id == 'undefined')
324 323
 		{
325
-			static $tmppath = array();      // static var, so all vfs-uploads get created in the same temporary dir
326
-			if (!isset($tmppath[$app])) $tmppath[$app] = self::get_temp_dir ($app);
324
+			static $tmppath = array(); // static var, so all vfs-uploads get created in the same temporary dir
325
+			if (!isset($tmppath[$app])) $tmppath[$app] = self::get_temp_dir($app);
327 326
 			$path = $tmppath[$app];
328 327
 		}
329 328
 		else
330 329
 		{
331
-			$path = Api\Link::vfs_path($app,$id,'',true);
330
+			$path = Api\Link::vfs_path($app, $id, '', true);
332 331
 		}
333 332
 		if (!empty($relpath)) $path .= '/'.$relpath;
334 333
 		return $path;
Please login to merge, or discard this patch.
api/src/Exception/NoPermission/Admin.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -19,6 +19,9 @@
 block discarded – undo
19 19
  */
20 20
 class Admin extends App
21 21
 {
22
+	/**
23
+	 * @param string $msg
24
+	 */
22 25
 	function __construct($msg=null,$code=102)
23 26
 	{
24 27
 		if (is_null($msg)) $msg = 'admin';
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@
 block discarded – undo
19 19
  */
20 20
 class Admin extends App
21 21
 {
22
-	function __construct($msg=null,$code=102)
22
+	function __construct($msg = null, $code = 102)
23 23
 	{
24 24
 		if (is_null($msg)) $msg = 'admin';
25 25
 
26
-		parent::__construct($msg,$code);
26
+		parent::__construct($msg, $code);
27 27
 	}
28 28
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,10 @@
 block discarded – undo
21 21
 {
22 22
 	function __construct($msg=null,$code=102)
23 23
 	{
24
-		if (is_null($msg)) $msg = 'admin';
24
+		if (is_null($msg))
25
+		{
26
+			$msg = 'admin';
27
+		}
25 28
 
26 29
 		parent::__construct($msg,$code);
27 30
 	}
Please login to merge, or discard this patch.
api/src/Framework/Ajax.php 4 patches
Doc Comments   -5 removed lines patch added patch discarded remove patch
@@ -356,11 +356,6 @@
 block discarded – undo
356 356
 	/**
357 357
 	* Add menu items to the topmenu template class to be displayed
358 358
 	*
359
-	* @param array $app application data
360
-	* @param mixed $alt_label string with alternative menu item label default value = null
361
-	* @param string $urlextra string with alternate additional code inside <a>-tag
362
-	* @access protected
363
-	* @return void
364 359
 	*/
365 360
 	function _add_topmenu_item(array $app_data,$alt_label=null)
366 361
 	{
Please login to merge, or discard this patch.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -337,16 +337,16 @@  discard block
 block discarded – undo
337 337
 	}
338 338
 
339 339
 	/**
340
-	* called by hooks to add an icon in the topmenu info location
341
-	*
342
-	* @param string $id unique element id
343
-	* @param string $icon_src src of the icon image. Make sure this nog height then 18pixels
344
-	* @param string $iconlink where the icon links to
345
-	* @param booleon $blink set true to make the icon blink
346
-	* @param mixed $tooltip string containing the tooltip Api\Html, or null of no tooltip
347
-	* @todo implement in a reasonable way for jdots
348
-	* @return void
349
-	*/
340
+	 * called by hooks to add an icon in the topmenu info location
341
+	 *
342
+	 * @param string $id unique element id
343
+	 * @param string $icon_src src of the icon image. Make sure this nog height then 18pixels
344
+	 * @param string $iconlink where the icon links to
345
+	 * @param booleon $blink set true to make the icon blink
346
+	 * @param mixed $tooltip string containing the tooltip Api\Html, or null of no tooltip
347
+	 * @todo implement in a reasonable way for jdots
348
+	 * @return void
349
+	 */
350 350
 	function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null)
351 351
 	{
352 352
 		unset($id,$icon_src,$iconlink,$blink,$tooltip);	// not used
@@ -354,14 +354,14 @@  discard block
 block discarded – undo
354 354
 	}
355 355
 
356 356
 	/**
357
-	* Add menu items to the topmenu template class to be displayed
358
-	*
359
-	* @param array $app application data
360
-	* @param mixed $alt_label string with alternative menu item label default value = null
361
-	* @param string $urlextra string with alternate additional code inside <a>-tag
362
-	* @access protected
363
-	* @return void
364
-	*/
357
+	 * Add menu items to the topmenu template class to be displayed
358
+	 *
359
+	 * @param array $app application data
360
+	 * @param mixed $alt_label string with alternative menu item label default value = null
361
+	 * @param string $urlextra string with alternate additional code inside <a>-tag
362
+	 * @access protected
363
+	 * @return void
364
+	 */
365 365
 	function _add_topmenu_item(array $app_data,$alt_label=null)
366 366
 	{
367 367
 		switch($app_data['name'])
Please login to merge, or discard this patch.
Braces   +56 added lines, -14 removed lines patch added patch discarded remove patch
@@ -104,7 +104,9 @@  discard block
 block discarded – undo
104 104
 
105 105
 		//Width may not be smaller than MIN_SIDEBAR_WIDTH
106 106
 		if ($width < self::MIN_SIDEBAR_WIDTH)
107
-			$width = self::MIN_SIDEBAR_WIDTH;
107
+		{
108
+					$width = self::MIN_SIDEBAR_WIDTH;
109
+		}
108 110
 
109 111
 		return $width;
110 112
 	}
@@ -156,7 +158,10 @@  discard block
 block discarded – undo
156 158
 	 */
157 159
 	static function link($url = '', $extravars = '', $link_app=null)
158 160
 	{
159
-		if (is_null($link_app)) $link_app = self::$link_app;
161
+		if (is_null($link_app))
162
+		{
163
+			$link_app = self::$link_app;
164
+		}
160 165
 		$link = parent::link($url, $extravars);
161 166
 
162 167
 		// $link_app === true --> detect application, otherwise use given application
@@ -185,7 +190,10 @@  discard block
 block discarded – undo
185 190
 		$srcs = array();
186 191
 		foreach(Api\Hooks::process('csp-frame-src') as $src)
187 192
 		{
188
-			if ($src) $srcs = array_merge($srcs, $src);
193
+			if ($src)
194
+			{
195
+				$srcs = array_merge($srcs, $src);
196
+			}
189 197
 		}
190 198
 		return $srcs;
191 199
 	}
@@ -199,7 +207,10 @@  discard block
 block discarded – undo
199 207
 	function header(array $extra=array())
200 208
 	{
201 209
 		// make sure header is output only once
202
-		if (self::$header_done) return '';
210
+		if (self::$header_done)
211
+		{
212
+			return '';
213
+		}
203 214
 		self::$header_done = true;
204 215
 
205 216
 		$this->send_headers();
@@ -266,7 +277,10 @@  discard block
 block discarded – undo
266 277
 			// for remote manual never check/create framework
267 278
 			if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('manual', 'login', 'logout', 'sitemgr')))
268 279
 			{
269
-				if (empty($GLOBALS['egw_info']['flags']['java_script'])) $GLOBALS['egw_info']['flags']['java_script']='';
280
+				if (empty($GLOBALS['egw_info']['flags']['java_script']))
281
+				{
282
+					$GLOBALS['egw_info']['flags']['java_script']='';
283
+				}
270 284
 				$extra['check-framework'] = $_GET['cd'] !== 'no';
271 285
 			}
272 286
 		}
@@ -539,7 +553,10 @@  discard block
 block discarded – undo
539 553
 	 */
540 554
 	public function sidebox($appname,$menu_title,$file,$type=null)
541 555
 	{
542
-		if (!isset($file['menuOpened'])) $file['menuOpened'] = (boolean)$this->sidebox_menu_opened;
556
+		if (!isset($file['menuOpened']))
557
+		{
558
+			$file['menuOpened'] = (boolean)$this->sidebox_menu_opened;
559
+		}
543 560
 		//error_log(__METHOD__."('$appname', '$menu_title', file[menuOpened]=$file[menuOpened], ...) this->sidebox_menu_opened=$this->sidebox_menu_opened");
544 561
 		$this->sidebox_menu_opened = false;
545 562
 
@@ -680,7 +697,10 @@  discard block
 block discarded – undo
680 697
 		foreach($tablist as $data)
681 698
 		{
682 699
 			$tabs[] = $data['appName'];
683
-			if ($data['active']) $active = $data['appName'];
700
+			if ($data['active'])
701
+			{
702
+				$active = $data['appName'];
703
+			}
684 704
 		}
685 705
 		// send app a notification, that it's tab got closed
686 706
 		// used eg. in phpFreeChat to leave the chat
@@ -807,10 +827,22 @@  discard block
 block discarded – undo
807 827
 		}
808 828
 
809 829
 		unset($apps['logout']);	// never display it
810
-		if (isset($apps['about'])) $apps['about']['noNavbar'] = true;
811
-		if (isset($apps['preferences'])) $apps['preferences']['noNavbar'] = true;
812
-		if (isset($apps['manual'])) $apps['manual']['noNavbar'] = true;
813
-		if (isset($apps['home'])) $apps['home']['noNavbar'] = true;
830
+		if (isset($apps['about']))
831
+		{
832
+			$apps['about']['noNavbar'] = true;
833
+		}
834
+		if (isset($apps['preferences']))
835
+		{
836
+			$apps['preferences']['noNavbar'] = true;
837
+		}
838
+		if (isset($apps['manual']))
839
+		{
840
+			$apps['manual']['noNavbar'] = true;
841
+		}
842
+		if (isset($apps['home']))
843
+		{
844
+			$apps['home']['noNavbar'] = true;
845
+		}
814 846
 
815 847
 		// no need for website icon, if we have sitemgr
816 848
 		if (isset($apps['sitemgr']) && isset($apps['sitemgr-link']))
@@ -872,7 +904,10 @@  discard block
 block discarded – undo
872 904
 		else
873 905
 		{
874 906
 			$active_tab = $GLOBALS['egw_info']['user']['preferences']['common']['active_tab'];
875
-			if (!$active_tab) $active_tab = $default_app;
907
+			if (!$active_tab)
908
+			{
909
+				$active_tab = $default_app;
910
+			}
876 911
 		}
877 912
 
878 913
 		//self::app_from_url might return an application the user has no rights
@@ -915,9 +950,12 @@  discard block
 block discarded – undo
915 950
 		// Restore Tabs
916 951
 		foreach($open_tabs as $n => $app)
917 952
 		{
918
-			if (isset($apps[$app]))		// user might no longer have app rights
953
+			if (isset($apps[$app]))
954
+			{
955
+				// user might no longer have app rights
919 956
 			{
920 957
 				$apps[$app]['opened'] = $n;
958
+			}
921 959
 				if ($app == $active_tab)
922 960
 				{
923 961
 					$apps[$app]['active'] = true;
@@ -943,7 +981,11 @@  discard block
 block discarded – undo
943 981
 	function footer($no_framework=true)
944 982
 	{
945 983
 		//error_log(__METHOD__."($no_framework) footer_done=".array2string(self::$footer_done).' '.function_backtrace());
946
-		if (self::$footer_done) return;	// prevent (multiple) footers
984
+		if (self::$footer_done)
985
+		{
986
+			return;
987
+		}
988
+		// prevent (multiple) footers
947 989
 		self::$footer_done = true;
948 990
 
949 991
 		if (!isset($GLOBALS['egw_info']['flags']['nofooter']) || !$GLOBALS['egw_info']['flags']['nofooter'])
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
 	 *
58 58
 	 * @param string $template = '' name of the template
59 59
 	 */
60
-	function __construct($template=self::APP)
60
+	function __construct($template = self::APP)
61 61
 	{
62
-		parent::__construct($template);		// call the constructor of the extended class
62
+		parent::__construct($template); // call the constructor of the extended class
63 63
 
64
-		$this->template_dir = '/'.$template;		// we are packaged as an application
64
+		$this->template_dir = '/'.$template; // we are packaged as an application
65 65
 	}
66 66
 
67 67
 	/**
@@ -129,16 +129,16 @@  discard block
 block discarded – undo
129 129
 	public static function app_from_url($url)
130 130
 	{
131 131
 		$matches = null;
132
-		if (preg_match('/menuaction=([a-z0-9_-]+)\./i',$url,$matches))
132
+		if (preg_match('/menuaction=([a-z0-9_-]+)\./i', $url, $matches))
133 133
 		{
134 134
 			return $matches[1];
135 135
 		}
136 136
 		if ($GLOBALS['egw_info']['server']['webserver_url'] &&
137
-			($webserver_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'],PHP_URL_PATH)))
137
+			($webserver_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'], PHP_URL_PATH)))
138 138
 		{
139
-			list(,$url) = explode($webserver_path, parse_url($url,PHP_URL_PATH),2);
139
+			list(,$url) = explode($webserver_path, parse_url($url, PHP_URL_PATH), 2);
140 140
 		}
141
-		if (preg_match('/\/([^\/]+)\/([^\/]+\.php)?(\?|\/|$)/',$url,$matches))
141
+		if (preg_match('/\/([^\/]+)\/([^\/]+\.php)?(\?|\/|$)/', $url, $matches))
142 142
 		{
143 143
 			return $matches[1];
144 144
 		}
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 * @param string $link_app = null if appname or true, some templates generate a special link-handler url
155 155
 	 * @return string	The full url after processing
156 156
 	 */
157
-	static function link($url = '', $extravars = '', $link_app=null)
157
+	static function link($url = '', $extravars = '', $link_app = null)
158 158
 	{
159 159
 		if (is_null($link_app)) $link_app = self::$link_app;
160 160
 		$link = parent::link($url, $extravars);
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 			// Link gets handled in JS, so quotes need slashes as well as url-encoded
166 166
 			// encoded ampersands in get parameters (%26) need to be encoded twise,
167 167
 			// so they are still encoded when assigned to window.location
168
-			$link_with_slashes = str_replace(array('%27','%26'), array('\%27','%2526'), $link);
168
+			$link_with_slashes = str_replace(array('%27', '%26'), array('\%27', '%2526'), $link);
169 169
 
170 170
 			//$link = "javascript:window.egw_link_handler?egw_link_handler('$link','$link_app'):parent.egw_link_handler('$link','$link_app');";
171 171
 			$link = "javascript:egw_link_handler('$link_with_slashes','$link_app')";
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	protected function _get_csp_frame_src()
184 184
 	{
185 185
 		$srcs = array();
186
-		foreach(Api\Hooks::process('csp-frame-src') as $src)
186
+		foreach (Api\Hooks::process('csp-frame-src') as $src)
187 187
 		{
188 188
 			if ($src) $srcs = array_merge($srcs, $src);
189 189
 		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 * @param array $extra = array() extra attributes passed as data-attribute to egw.js
197 197
 	 * @return string with Api\Html
198 198
 	 */
199
-	function header(array $extra=array())
199
+	function header(array $extra = array())
200 200
 	{
201 201
 		// make sure header is output only once
202 202
 		if (self::$header_done) return '';
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 		{
222 222
 			$this->tpl->set_file(array('_head' => 'head.tpl'));
223 223
 		}
224
-		$this->tpl->set_block('_head','head');
225
-		$this->tpl->set_block('_head','framework');
224
+		$this->tpl->set_block('_head', 'head');
225
+		$this->tpl->set_block('_head', 'framework');
226 226
 
227 227
 		// should we draw the framework, or just a header
228 228
 		$do_framework = isset($_GET['cd']) && $_GET['cd'] === 'yes';
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 			{
248 248
 				self::includeJS('.', 'fw_'.static::APP, static::JS_INCLUDE_APP);
249 249
 			}
250
-			Api\Cache::unsetSession(__CLASS__,'sidebox_md5');	// sideboxes need to be send again
250
+			Api\Cache::unsetSession(__CLASS__, 'sidebox_md5'); // sideboxes need to be send again
251 251
 
252 252
 			$extra['navbar-apps'] = $this->get_navbar_apps($_SERVER['REQUEST_URI']);
253 253
 		}
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 		// - if not we need to check if we have an opener (are a popup window)
257 257
 		// - as popups can open further popups, we need to decend all the way down until we find a framework
258 258
 		// - only if we cant find a framework in all openers, we redirect to create a new framework
259
-		if(!$do_framework)
259
+		if (!$do_framework)
260 260
 		{
261 261
 			// fetch sidebox from application and set it in extra data, if we are no popup
262 262
 			if (!$GLOBALS['egw_info']['flags']['nonavbar'])
@@ -266,12 +266,12 @@  discard block
 block discarded – undo
266 266
 			// for remote manual never check/create framework
267 267
 			if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('manual', 'login', 'logout', 'sitemgr')))
268 268
 			{
269
-				if (empty($GLOBALS['egw_info']['flags']['java_script'])) $GLOBALS['egw_info']['flags']['java_script']='';
269
+				if (empty($GLOBALS['egw_info']['flags']['java_script'])) $GLOBALS['egw_info']['flags']['java_script'] = '';
270 270
 				$extra['check-framework'] = $_GET['cd'] !== 'no';
271 271
 			}
272 272
 		}
273 273
 		$this->tpl->set_var($this->_get_header($extra));
274
-		$content = $this->tpl->fp('out','head').$content;
274
+		$content = $this->tpl->fp('out', 'head').$content;
275 275
 
276 276
 		if (!$do_framework)
277 277
 		{
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
 
281 281
 		// topmenu
282 282
 		$vars = $this->_get_navbar($apps = $this->_get_navbar_apps());
283
-		$this->tpl->set_var($this->topmenu($vars,$apps));
283
+		$this->tpl->set_var($this->topmenu($vars, $apps));
284 284
 
285 285
 		// hook after_navbar (eg. notifications)
286
-		$this->tpl->set_var('hook_after_navbar',$this->_get_after_navbar());
286
+		$this->tpl->set_var('hook_after_navbar', $this->_get_after_navbar());
287 287
 
288 288
 		//Global sidebar width
289 289
 		$this->tpl->set_var('sidebox_width', self::get_global_sidebar_width());
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 
301 301
 		// add framework div's
302 302
 		$this->tpl->set_var($this->_get_footer());
303
-		$content .= $this->tpl->fp('out','framework');
303
+		$content .= $this->tpl->fp('out', 'framework');
304 304
 		$content .= self::footer(false);
305 305
 
306 306
 		echo $content;
@@ -319,14 +319,14 @@  discard block
 block discarded – undo
319 319
 	 * @param array $apps
320 320
 	 * @return array
321 321
 	 */
322
-	function topmenu(array $vars,array $apps)
322
+	function topmenu(array $vars, array $apps)
323 323
 	{
324 324
 		$this->topmenu_items = $this->topmenu_info_items = array();
325 325
 
326
-		parent::topmenu($vars,$apps);
327
-		$vars['topmenu_items'] = "<ul>\n<li>".implode("</li>\n<li>",$this->topmenu_items)."</li>\n</ul>";
326
+		parent::topmenu($vars, $apps);
327
+		$vars['topmenu_items'] = "<ul>\n<li>".implode("</li>\n<li>", $this->topmenu_items)."</li>\n</ul>";
328 328
 		$vars['topmenu_info_items'] = '';
329
-		foreach($this->topmenu_info_items as $id => $item)
329
+		foreach ($this->topmenu_info_items as $id => $item)
330 330
 		{
331 331
 			$vars['topmenu_info_items'] .= '<div class="topmenu_info_item"'.
332 332
 				(is_numeric($id) ? '' : ' id="topmenu_info_'.$id.'"').'>'.$item."</div>\n";
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 	* @todo implement in a reasonable way for jdots
348 348
 	* @return void
349 349
 	*/
350
-	function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null)
350
+	function topmenu_info_icon($id, $icon_src, $iconlink, $blink = false, $tooltip = null)
351 351
 	{
352
-		unset($id,$icon_src,$iconlink,$blink,$tooltip);	// not used
352
+		unset($id, $icon_src, $iconlink, $blink, $tooltip); // not used
353 353
 		// not yet implemented, only used in admin/inc/hook_topmenu_info.inc.php to notify about pending updates
354 354
 	}
355 355
 
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
 	* @access protected
363 363
 	* @return void
364 364
 	*/
365
-	function _add_topmenu_item(array $app_data,$alt_label=null)
365
+	function _add_topmenu_item(array $app_data, $alt_label = null)
366 366
 	{
367
-		switch($app_data['name'])
367
+		switch ($app_data['name'])
368 368
 		{
369 369
 			case 'logout':
370 370
 				if (Api\Header\UserAgent::mobile() || $GLOBALS['egw_info']['user']['preferences']['common']['theme'] == 'mobile')
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 				}
374 374
 				else
375 375
 				{
376
-					return;	// no need for logout in topmenu on jdots
376
+					return; // no need for logout in topmenu on jdots
377 377
 				}
378 378
 				break;
379 379
 
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 				break;
383 383
 
384 384
 			default:
385
-				if (strpos($app_data['url'],'logout.php') === false && substr($app_data['url'], 0, 11) != 'javascript:')
385
+				if (strpos($app_data['url'], 'logout.php') === false && substr($app_data['url'], 0, 11) != 'javascript:')
386 386
 				{
387 387
 					$app_data['url'] = "javascript:egw_link_handler('".$app_data['url']."','".
388 388
 						(isset($GLOBALS['egw_info']['user']['apps'][$app_data['name']]) ?
@@ -390,8 +390,8 @@  discard block
 block discarded – undo
390 390
 				}
391 391
 		}
392 392
 		$id = $app_data['id'] ? $app_data['id'] : ($app_data['name'] ? $app_data['name'] : $app_data['title']);
393
-		$title =  htmlspecialchars($alt_label ? $alt_label : $app_data['title']);
394
-		$this->topmenu_items[] = '<a id="topmenu_' . $id . '" href="'.htmlspecialchars($app_data['url']).'" title="'.$app_data['title'].'">'.$title.'</a>';
393
+		$title = htmlspecialchars($alt_label ? $alt_label : $app_data['title']);
394
+		$this->topmenu_items[] = '<a id="topmenu_'.$id.'" href="'.htmlspecialchars($app_data['url']).'" title="'.$app_data['title'].'">'.$title.'</a>';
395 395
 	}
396 396
 
397 397
 	/**
@@ -402,11 +402,11 @@  discard block
 block discarded – undo
402 402
 	 * @access protected
403 403
 	 * @return void
404 404
 	 */
405
-	function _add_topmenu_info_item($content, $id=null)
405
+	function _add_topmenu_info_item($content, $id = null)
406 406
 	{
407
-		if(strpos($content,'menuaction=admin.admin_accesslog.sessions') !== false)
407
+		if (strpos($content, 'menuaction=admin.admin_accesslog.sessions') !== false)
408 408
 		{
409
-			$content = preg_replace('/href="([^"]+)"/',"href=\"javascript:egw_link_handler('\\1','admin')\"",$content);
409
+			$content = preg_replace('/href="([^"]+)"/', "href=\"javascript:egw_link_handler('\\1','admin')\"", $content);
410 410
 		}
411 411
 		if ($id)
412 412
 		{
@@ -425,10 +425,10 @@  discard block
 block discarded – undo
425 425
 	 */
426 426
 	static function ajax_tz_selection($tz)
427 427
 	{
428
-		Api\DateTime::setUserPrefs($tz);	// throws exception, if tz is invalid
428
+		Api\DateTime::setUserPrefs($tz); // throws exception, if tz is invalid
429 429
 
430 430
 		$GLOBALS['egw']->preferences->read_repository();
431
-		$GLOBALS['egw']->preferences->add('common','tz',$tz);
431
+		$GLOBALS['egw']->preferences->add('common', 'tz', $tz);
432 432
 		$GLOBALS['egw']->preferences->save_repository();
433 433
 	}
434 434
 
@@ -480,13 +480,13 @@  discard block
 block discarded – undo
480 480
 		// only send admin sidebox, for admin index url (when clicked on admin),
481 481
 		// not for other admin pages, called eg. from sidebox menu of other apps
482 482
 		// --> that way we always stay in the app, and NOT open admin sidebox for an app tab!!!
483
-		if ($app == 'admin' && substr($_SERVER['PHP_SELF'],-16) != '/admin/index.php' &&
483
+		if ($app == 'admin' && substr($_SERVER['PHP_SELF'], -16) != '/admin/index.php' &&
484 484
 			$_GET['menuaction'] != 'admin.admin_ui.index')
485 485
 		{
486 486
 			//error_log(__METHOD__."() app=$app, menuaction=$_GET[menuaction], PHP_SELF=$_SERVER[PHP_SELF] --> sidebox request ignored");
487 487
 			return;
488 488
 		}
489
-		$md5_session =& Api\Cache::getSession(__CLASS__,'sidebox_md5');
489
+		$md5_session = & Api\Cache::getSession(__CLASS__, 'sidebox_md5');
490 490
 
491 491
 		//Set the sidebox content
492 492
 		$sidebox = $this->get_sidebox($app);
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 		if ($md5_session[$app] !== $md5)
496 496
 		{
497 497
 			//error_log(__METHOD__."() header changed md5_session[$app]!=='$md5' --> setting it on self::\$extra[setSidebox]");
498
-			$md5_session[$app] = $md5;	// update md5 in session
498
+			$md5_session[$app] = $md5; // update md5 in session
499 499
 			self::$extra['setSidebox'] = array($app, $sidebox, $md5);
500 500
 		}
501 501
 		//else error_log(__METHOD__."() md5_session[$app]==='$md5' --> nothing to do");
@@ -509,9 +509,9 @@  discard block
 block discarded – undo
509 509
 	 * @return boolean $consider_navbar_not_yet_called_as_true=true ignored by jdots, we only care for cd=yes GET param
510 510
 	 * @return boolean
511 511
 	 */
512
-	public function isTop($consider_navbar_not_yet_called_as_true=true)
512
+	public function isTop($consider_navbar_not_yet_called_as_true = true)
513 513
 	{
514
-		unset($consider_navbar_not_yet_called_as_true);	// not used
514
+		unset($consider_navbar_not_yet_called_as_true); // not used
515 515
 		return isset($_GET['cd']) && $_GET['cd'] === 'yes';
516 516
 	}
517 517
 
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 	 * @param array $file
538 538
 	 * @param string $type = null 'admin', 'preferences', 'favorites', ...
539 539
 	 */
540
-	public function sidebox($appname,$menu_title,$file,$type=null)
540
+	public function sidebox($appname, $menu_title, $file, $type = null)
541 541
 	{
542 542
 		if (!isset($file['menuOpened'])) $file['menuOpened'] = (boolean)$this->sidebox_menu_opened;
543 543
 		//error_log(__METHOD__."('$appname', '$menu_title', file[menuOpened]=$file[menuOpened], ...) this->sidebox_menu_opened=$this->sidebox_menu_opened");
@@ -546,11 +546,11 @@  discard block
 block discarded – undo
546 546
 		// fix app admin menus to use admin.admin_ui.index loader
547 547
 		if (($type == 'admin' || $menu_title == lang('Admin')) && $appname != 'admin')
548 548
 		{
549
-			foreach($file as &$link)
549
+			foreach ($file as &$link)
550 550
 			{
551 551
 				preg_match('/ajax=(true|false)/', $link, $ajax);
552 552
 				$link = preg_replace("/^(javascript:egw_link_handler\(')(.*)menuaction=([^&]+)(.*)(','[^']+'\))$/",
553
-					'$1$2menuaction=admin.admin_ui.index&load=$3$4&ajax=' . ($ajax[1] ? $ajax[1] : 'true') .'\',\'admin\')', $file_was=$link);
553
+					'$1$2menuaction=admin.admin_ui.index&load=$3$4&ajax='.($ajax[1] ? $ajax[1] : 'true').'\',\'admin\')', $file_was = $link);
554 554
 			}
555 555
 
556 556
 		}
@@ -587,15 +587,15 @@  discard block
 block discarded – undo
587 587
 			self::$link_app = $appname;
588 588
 			// allow other apps to hook into sidebox menu of an app, hook-name: sidebox_$appname
589 589
 			$this->sidebox_menu_opened = true;
590
-			Api\Hooks::process('sidebox_'.$appname,array($appname),true);	// true = call independent of app-permissions
590
+			Api\Hooks::process('sidebox_'.$appname, array($appname), true); // true = call independent of app-permissions
591 591
 
592 592
 			// calling the old hook
593 593
 			$this->sidebox_menu_opened = true;
594
-			Api\Hooks::single('sidebox_menu',$appname);
594
+			Api\Hooks::single('sidebox_menu', $appname);
595 595
 			self::$link_app = null;
596 596
 
597 597
 			// allow other apps to hook into sidebox menu of every app: sidebox_all
598
-			Api\Hooks::process('sidebox_all',array($GLOBALS['egw_info']['flags']['currentapp']),true);
598
+			Api\Hooks::process('sidebox_all', array($GLOBALS['egw_info']['flags']['currentapp']), true);
599 599
 		}
600 600
 		//If there still is no sidebox content, return null here
601 601
 		if (!isset($this->sideboxes[$appname]))
@@ -605,17 +605,17 @@  discard block
 block discarded – undo
605 605
 
606 606
 		$data = array();
607 607
 		$sendToBottom = array();
608
-		foreach($this->sideboxes[$appname] as $menu_name => &$file)
608
+		foreach ($this->sideboxes[$appname] as $menu_name => &$file)
609 609
 		{
610 610
 			$current_menu = array(
611
-				'menu_name' => md5($menu_name),	// can contain Api\Html tags and javascript!
611
+				'menu_name' => md5($menu_name), // can contain Api\Html tags and javascript!
612 612
 				'title' => $menu_name,
613 613
 				'entries' => array(),
614 614
 				'opened' => (boolean)$file['menuOpened'],
615 615
 			);
616
-			foreach($file as $item_text => $item_link)
616
+			foreach ($file as $item_text => $item_link)
617 617
 			{
618
-				if ($item_text === 'menuOpened' || $item_text === 'sendToBottom' ||// flag, not menu entry
618
+				if ($item_text === 'menuOpened' || $item_text === 'sendToBottom' || // flag, not menu entry
619 619
 					$item_text === '_NewLine_' || $item_link === '_NewLine_')
620 620
 				{
621 621
 					continue;
@@ -626,14 +626,14 @@  discard block
 block discarded – undo
626 626
 				}
627 627
 
628 628
 				$var = array();
629
-				$var['icon_or_star'] = $GLOBALS['egw_info']['server']['webserver_url'] . $this->template_dir.'/images/bullet.png';
629
+				$var['icon_or_star'] = $GLOBALS['egw_info']['server']['webserver_url'].$this->template_dir.'/images/bullet.png';
630 630
 				$var['target'] = '';
631
-				if(is_array($item_link))
631
+				if (is_array($item_link))
632 632
 				{
633
-					if(isset($item_link['icon']))
633
+					if (isset($item_link['icon']))
634 634
 					{
635 635
 						$app = isset($item_link['app']) ? $item_link['app'] : $appname;
636
-						$var['icon_or_star'] = $item_link['icon'] ? Api\Image::find($app,$item_link['icon']) : False;
636
+						$var['icon_or_star'] = $item_link['icon'] ? Api\Image::find($app, $item_link['icon']) : False;
637 637
 					}
638 638
 					$var['lang_item'] = isset($item_link['no_lang']) && $item_link['no_lang'] ? $item_link['text'] : lang($item_link['text']);
639 639
 					$var['item_link'] = $item_link['link'];
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 	public static function ajax_tab_changed_state($tablist)
678 678
 	{
679 679
 		$tabs = array();
680
-		foreach($tablist as $data)
680
+		foreach ($tablist as $data)
681 681
 		{
682 682
 			$tabs[] = $data['appName'];
683 683
 			if ($data['active']) $active = $data['appName'];
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 		// used eg. in phpFreeChat to leave the chat
687 687
 		if (($old_tabs = Api\Cache::getSession(__CLASS__, 'open_tabs')))
688 688
 		{
689
-			foreach(array_diff(explode(',',$old_tabs),$tabs) as $app)
689
+			foreach (array_diff(explode(',', $old_tabs), $tabs) as $app)
690 690
 			{
691 691
 				//error_log("Tab '$app' closed, old_tabs=$old_tabs");
692 692
 				Api\Hooks::single(array(
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 				), $app);
696 696
 			}
697 697
 		}
698
-		$open = implode(',',$tabs);
698
+		$open = implode(',', $tabs);
699 699
 
700 700
 		if ($open != $GLOBALS['egw_info']['user']['preferences']['common']['open_tabs'] ||
701 701
 			$active != $GLOBALS['egw_info']['user']['preferences']['common']['active_tab'])
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
 		$i = 0;
766 766
 
767 767
 		//Parse the "$apps" array for valid content (security)
768
-		foreach($apps as $app)
768
+		foreach ($apps as $app)
769 769
 		{
770 770
 			//Check whether the app really exists and add it to the $app_arr var
771 771
 			if ($GLOBALS['egw_info']['user']['apps'][$app])
@@ -796,17 +796,17 @@  discard block
 block discarded – undo
796 796
 	 */
797 797
 	public function navbar_apps()
798 798
 	{
799
-		$apps = parent::_get_navbar_apps(Api\Image::svg_usable());	// use svg if usable in browser
799
+		$apps = parent::_get_navbar_apps(Api\Image::svg_usable()); // use svg if usable in browser
800 800
 
801 801
 		//Add its sidebox width to each app
802 802
 		foreach ($apps as $app => &$data)
803 803
 		{
804 804
 			$data['sideboxwidth'] = self::get_sidebar_width($app);
805 805
 			// overwrite icon with svg, if supported by browser
806
-			unset($data['icon_hover']);	// not used in jdots
806
+			unset($data['icon_hover']); // not used in jdots
807 807
 		}
808 808
 
809
-		unset($apps['logout']);	// never display it
809
+		unset($apps['logout']); // never display it
810 810
 		if (isset($apps['about'])) $apps['about']['noNavbar'] = true;
811 811
 		if (isset($apps['preferences'])) $apps['preferences']['noNavbar'] = true;
812 812
 		if (isset($apps['manual'])) $apps['manual']['noNavbar'] = true;
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 		}
857 857
 
858 858
 		// check if user called a specific url --> open it as active tab
859
-		$last_direct_url =& Api\Cache::getSession(__CLASS__, 'last_direct_url');
859
+		$last_direct_url = & Api\Cache::getSession(__CLASS__, 'last_direct_url');
860 860
 		if ($last_direct_url)
861 861
 		{
862 862
 			$url = $last_direct_url;
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 		{
867 867
 			// Coming in with a specific URL, save it and redirect to index.php
868 868
 			// so reloads work nicely, but strip cd=yes or we'll get the framework again
869
-			$last_direct_url = preg_replace('/[&?]cd=yes/','',$url);
869
+			$last_direct_url = preg_replace('/[&?]cd=yes/', '', $url);
870 870
 			Api\Framework::redirect_link('/index.php?cd=yes');
871 871
 		}
872 872
 		else
@@ -881,11 +881,11 @@  discard block
 block discarded – undo
881 881
 		if ($active_tab && array_key_exists($active_tab, $apps))
882 882
 		{
883 883
 			// Do not remove cd=yes if it's an ajax=true app
884
-			if (strpos( $apps[$active_tab]['url'],'ajax=true') !== False)
884
+			if (strpos($apps[$active_tab]['url'], 'ajax=true') !== False)
885 885
 			{
886
-				$url = preg_replace('/[&?]cd=yes/','',$url);
886
+				$url = preg_replace('/[&?]cd=yes/', '', $url);
887 887
 			}
888
-			if($last_direct_url)
888
+			if ($last_direct_url)
889 889
 			{
890 890
 				$apps[$active_tab]['openOnce'] = $url;
891 891
 			}
@@ -897,8 +897,8 @@  discard block
 block discarded – undo
897 897
 		{
898 898
 			$open_tabs = $GLOBALS['egw_info']['user']['preferences']['common']['open_tabs'];
899 899
 		}
900
-		$open_tabs = $open_tabs ? explode(',',$open_tabs) : array();
901
-		if ($active_tab && !in_array($active_tab,$open_tabs))
900
+		$open_tabs = $open_tabs ? explode(',', $open_tabs) : array();
901
+		if ($active_tab && !in_array($active_tab, $open_tabs))
902 902
 		{
903 903
 			$open_tabs[] = $active_tab;
904 904
 			$store_prefs = true;
@@ -906,14 +906,14 @@  discard block
 block discarded – undo
906 906
 		if ($store_prefs)
907 907
 		{
908 908
 			$GLOBALS['egw']->preferences->read_repository();
909
-			$GLOBALS['egw']->preferences->add('common', 'open_tabs', implode(',',$open_tabs));
909
+			$GLOBALS['egw']->preferences->add('common', 'open_tabs', implode(',', $open_tabs));
910 910
 			$GLOBALS['egw']->preferences->add('common', 'active_tab', $active_tab);
911 911
 			$GLOBALS['egw']->preferences->save_repository(true);
912 912
 		}
913 913
 
914 914
 		//error_log(__METHOD__."('$url') url_tab='$url_tab', active_tab=$active_tab, open_tabs=".array2string($open_tabs));
915 915
 		// Restore Tabs
916
-		foreach($open_tabs as $n => $app)
916
+		foreach ($open_tabs as $n => $app)
917 917
 		{
918 918
 			if (isset($apps[$app]))		// user might no longer have app rights
919 919
 			{
@@ -940,10 +940,10 @@  discard block
 block discarded – undo
940 940
 	 * @param boolean $no_framework = true
941 941
 	 * @return string
942 942
 	 */
943
-	function footer($no_framework=true)
943
+	function footer($no_framework = true)
944 944
 	{
945 945
 		//error_log(__METHOD__."($no_framework) footer_done=".array2string(self::$footer_done).' '.function_backtrace());
946
-		if (self::$footer_done) return;	// prevent (multiple) footers
946
+		if (self::$footer_done) return; // prevent (multiple) footers
947 947
 		self::$footer_done = true;
948 948
 
949 949
 		if (!isset($GLOBALS['egw_info']['flags']['nofooter']) || !$GLOBALS['egw_info']['flags']['nofooter'])
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
 			}
956 956
 		}
957 957
 		return $footer.
958
-			$GLOBALS['egw_info']['flags']['need_footer']."\n".	// eg. javascript, which need to be at the end of the page
958
+			$GLOBALS['egw_info']['flags']['need_footer']."\n".// eg. javascript, which need to be at the end of the page
959 959
 			"</body>\n</html>\n";
960 960
 	}
961 961
 
@@ -993,8 +993,8 @@  discard block
 block discarded – undo
993 993
 		if ($parts['query'])
994 994
 		{
995 995
 			$_SERVER['REQUEST_URI'] = '?'.$parts['query'];
996
-			parse_str($parts['query'],$_GET);
997
-			$_REQUEST = $_GET;	// some apps use $_REQUEST to check $_GET or $_POST
996
+			parse_str($parts['query'], $_GET);
997
+			$_REQUEST = $_GET; // some apps use $_REQUEST to check $_GET or $_POST
998 998
 		}
999 999
 
1000 1000
 		if (!isset($_GET['menuaction']))
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
 		// set session action
1005 1005
 		$GLOBALS['egw']->session->set_action('Ajax: '.$_GET['menuaction']);
1006 1006
 
1007
-		list($app,$class,$method) = explode('.',$_GET['menuaction']);
1007
+		list($app, $class, $method) = explode('.', $_GET['menuaction']);
1008 1008
 
1009 1009
 		if (!isset($GLOBALS['egw_info']['user']['apps'][$app]))
1010 1010
 		{
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
 
1017 1017
 		$GLOBALS[$class] = $obj = CreateObject($app.'.'.$class);
1018 1018
 
1019
-		if(!is_array($obj->public_functions) || !$obj->public_functions[$method])
1019
+		if (!is_array($obj->public_functions) || !$obj->public_functions[$method])
1020 1020
 		{
1021 1021
 			throw new Api\Exception\NoPermission("Bad menuaction {$_GET['menuaction']}, not listed in public_functions!");
1022 1022
 		}
Please login to merge, or discard this patch.
api/src/Framework/CssIncludes.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@
 block discarded – undo
145 145
 	 * Parse beginning of given CSS file for /*@import url("...") statements
146 146
 	 *
147 147
 	 * @param string $path EGroupware relative path eg. /phpgwapi/templates/default/some.css
148
-	 * @return array parsed pathes (EGroupware relative) including $path itself
148
+	 * @return string[] parsed pathes (EGroupware relative) including $path itself
149 149
 	 */
150 150
 	protected static function resolve_css_includes($path, &$pathes=array())
151 151
 	{
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -107,14 +107,20 @@
 block discarded – undo
107 107
 		$max_modified = 0;
108 108
 		//no more dynamic minifying: $debug_minify = $GLOBALS['egw_info']['server']['debug_minify'] === 'True';
109 109
 		$base_path = $GLOBALS['egw_info']['server']['webserver_url'];
110
-		if ($base_path[0] != '/') $base_path = parse_url($base_path, PHP_URL_PATH);
110
+		if ($base_path[0] != '/')
111
+		{
112
+			$base_path = parse_url($base_path, PHP_URL_PATH);
113
+		}
111 114
 		$css_files = '';
112 115
 		foreach(self::$files as $path)
113 116
 		{
114 117
 			foreach(self::resolve_css_includes($path) as $path)
115 118
 			{
116 119
 				list($file,$query) = explode('?',$path,2);
117
-				if (($mod = filemtime(EGW_SERVER_ROOT.$file)) > $max_modified) $max_modified = $mod;
120
+				if (($mod = filemtime(EGW_SERVER_ROOT.$file)) > $max_modified)
121
+				{
122
+					$max_modified = $mod;
123
+				}
118 124
 
119 125
 				// do NOT include app.css or categories.php, as it changes from app to app
120 126
 				//no more dynamic minifying: if ($debug_minify || substr($path, -8) == '/app.css' || substr($file,-14) == 'categories.php')
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @param boolean $clear_includes =false true: clear all previous includes
35 35
 	 * @return boolean false: css file not found, true: file found
36 36
 	 */
37
-	public static function add($app, $name=null, $append=true, $clear_includes=false)
37
+	public static function add($app, $name = null, $append = true, $clear_includes = false)
38 38
 	{
39 39
 		if ($clear_includes)
40 40
 		{
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
 		if (!is_null($name))
45 45
 		{
46
-			foreach($GLOBALS['egw']->framework->template_dirs as $dir)
46
+			foreach ($GLOBALS['egw']->framework->template_dirs as $dir)
47 47
 			{
48 48
 				if (file_exists(EGW_SERVER_ROOT.($path = '/'.$app.'/templates/'.$dir.'/'.$name.'.css')))
49 49
 				{
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
 		{
56 56
 			$path = $app;
57 57
 		}
58
-		if (!file_exists(EGW_SERVER_ROOT.$path) && !file_exists(EGW_SERVER_ROOT . parse_url($path,PHP_URL_PATH)))
58
+		if (!file_exists(EGW_SERVER_ROOT.$path) && !file_exists(EGW_SERVER_ROOT.parse_url($path, PHP_URL_PATH)))
59 59
 		{
60 60
 			//error_log(__METHOD__."($app,$name) $path NOT found!");
61 61
 			return false;
62 62
 		}
63
-		if (!in_array($path,self::$files))
63
+		if (!in_array($path, self::$files))
64 64
 		{
65 65
 			if ($append)
66 66
 			{
@@ -79,16 +79,16 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @return string
81 81
 	 */
82
-	public static function get($resolve=false)
82
+	public static function get($resolve = false)
83 83
 	{
84 84
 		if (!$resolve)
85 85
 		{
86 86
 			return self::$files;
87 87
 		}
88 88
 		$files = array();
89
-		foreach(self::$files as $path)
89
+		foreach (self::$files as $path)
90 90
 		{
91
-			foreach(self::resolve_css_includes($path) as $path)
91
+			foreach (self::resolve_css_includes($path) as $path)
92 92
 			{
93 93
 				$files[] = $path;
94 94
 			}
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 		$base_path = $GLOBALS['egw_info']['server']['webserver_url'];
110 110
 		if ($base_path[0] != '/') $base_path = parse_url($base_path, PHP_URL_PATH);
111 111
 		$css_files = '';
112
-		foreach(self::$files as $path)
112
+		foreach (self::$files as $path)
113 113
 		{
114
-			foreach(self::resolve_css_includes($path) as $path)
114
+			foreach (self::resolve_css_includes($path) as $path)
115 115
 			{
116
-				list($file,$query) = explode('?',$path,2);
116
+				list($file, $query) = explode('?', $path, 2);
117 117
 				if (($mod = filemtime(EGW_SERVER_ROOT.$file)) > $max_modified) $max_modified = $mod;
118 118
 
119 119
 				// do NOT include app.css or categories.php, as it changes from app to app
@@ -147,20 +147,20 @@  discard block
 block discarded – undo
147 147
 	 * @param string $path EGroupware relative path eg. /phpgwapi/templates/default/some.css
148 148
 	 * @return array parsed pathes (EGroupware relative) including $path itself
149 149
 	 */
150
-	protected static function resolve_css_includes($path, &$pathes=array())
150
+	protected static function resolve_css_includes($path, &$pathes = array())
151 151
 	{
152 152
 		$matches = null;
153 153
 
154
-		list($file) = explode('?',$path,2);
155
-		if (($to_check = file_get_contents (EGW_SERVER_ROOT.$file, false, null, 0, 1024)) &&
154
+		list($file) = explode('?', $path, 2);
155
+		if (($to_check = file_get_contents(EGW_SERVER_ROOT.$file, false, null, 0, 1024)) &&
156 156
 			stripos($to_check, '/*@import') !== false && preg_match_all('|/\*@import url\("([^"]+)"|i', $to_check, $matches))
157 157
 		{
158
-			foreach($matches[1] as $import_path)
158
+			foreach ($matches[1] as $import_path)
159 159
 			{
160 160
 				if ($import_path[0] != '/')
161 161
 				{
162 162
 					$dir = dirname($path);
163
-					while(substr($import_path,0,3) == '../')
163
+					while (substr($import_path, 0, 3) == '../')
164 164
 					{
165 165
 						$dir = dirname($dir);
166 166
 						$import_path = substr($import_path, 3);
Please login to merge, or discard this patch.
api/src/Framework/Favorites.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -187,7 +187,7 @@
 block discarded – undo
187 187
 	 * @param string $action "add" or "delete"
188 188
 	 * @param boolean|int|String $group ID of the group to create the favorite for, or 'all' for all users
189 189
 	 * @param array $filters key => value pairs for the filter
190
-	 * @return boolean Success
190
+	 * @return boolean|null Success
191 191
 	 */
192 192
 	public static function set_favorite($app, $_name, $action, $group, $filters = array())
193 193
 	{
Please login to merge, or discard this patch.
Braces   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -161,7 +161,11 @@
 block discarded – undo
161 161
 		{
162 162
 			if(strpos($pref_name, $pref_prefix) === 0)
163 163
 			{
164
-				if(!is_array($pref)) continue;	// old favorite
164
+				if(!is_array($pref))
165
+				{
166
+					continue;
167
+				}
168
+				// old favorite
165 169
 
166 170
 				$favorites[(string)substr($pref_name,strlen($pref_prefix))] = $pref;
167 171
 			}
Please login to merge, or discard this patch.
Spacing   +22 added lines, -23 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @return array with a single sidebox menu item (array) containing html for favorites
44 44
 	 */
45
-	public static function list_favorites($app, $default=null)
45
+	public static function list_favorites($app, $default = null)
46 46
 	{
47 47
 		if (!$app)
48 48
 		{
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		$target = 'favorite_sidebox_'.$app;
59 59
 
60 60
 		/* @var $filters array an array of favorites*/
61
-		$filters =  self::get_favorites($app);
61
+		$filters = self::get_favorites($app);
62 62
 		$is_admin = $GLOBALS['egw_info']['user']['apps']['admin'];
63 63
 		$html = "<span id='$target' class='ui-helper-clearfix sidebox-favorites'><ul class='ui-menu ui-widget-content ui-corner-all favorites' role='listbox'>\n";
64 64
 
@@ -69,25 +69,24 @@  discard block
 block discarded – undo
69 69
 		}
70 70
 
71 71
 		// Get link for if there is no nextmatch - this is the fallback
72
-		$registry = Api\Link::get_registry($app,'list');
72
+		$registry = Api\Link::get_registry($app, 'list');
73 73
 		if (!$registry)
74 74
 		{
75 75
 			$registry = Api\Link::get_registry($app, 'index');
76 76
 		}
77
-		foreach($filters as $name => $filter)
77
+		foreach ($filters as $name => $filter)
78 78
 		{
79 79
 			//filter must not be empty if there's one, ignore it at the moment but it need to be checked how it got there in database
80 80
 			if (!$filter)
81 81
 			{
82
-				error_log(__METHOD__.'Favorite filter "'.$name.'" is not supposed to be empty, it should be an array.  Skipping, more investigation needed. filter = '. array2string($filters[$name]));
82
+				error_log(__METHOD__.'Favorite filter "'.$name.'" is not supposed to be empty, it should be an array.  Skipping, more investigation needed. filter = '.array2string($filters[$name]));
83 83
 				continue;
84 84
 			}
85 85
 			$li = "<li data-id='$name' data-group='{$filter['group']}' class='ui-menu-item' role='menuitem'>\n";
86 86
 			$li .= '<a href="#" class="ui-corner-all" tabindex="-1">';
87
-			$li .= "<div class='" . ((string)$name === (string)$default_filter ? 'ui-icon ui-icon-heart' : 'sideboxstar') . "'></div>".
87
+			$li .= "<div class='".((string)$name === (string)$default_filter ? 'ui-icon ui-icon-heart' : 'sideboxstar')."'></div>".
88 88
 				$filter['name'];
89
-			$li .= ($filter['group'] != false && !$is_admin || $name === 'blank' ? "" :
90
-				"<div class='ui-icon ui-icon-trash' title='" . lang('Delete') . "'></div>");
89
+			$li .= ($filter['group'] != false && !$is_admin || $name === 'blank' ? "" : "<div class='ui-icon ui-icon-trash' title='".lang('Delete')."'></div>");
91 90
 			$li .= "</a></li>\n";
92 91
 			//error_log(__METHOD__."() $name, filter=".array2string($filter)." --> ".$li);
93 92
 			$html .= $li;
@@ -95,7 +94,7 @@  discard block
 block discarded – undo
95 94
 
96 95
 		// If were're here, the app supports favorites, so add a 'Add' link too
97 96
 		$html .= "<li data-id='add' class='ui-menu-item' role='menuitem'><a href='javascript:app.$app.add_favorite()' class='ui-corner-all'>";
98
-		$html .= Api\Html::image($app, 'new') . lang('Add current'). '</a></li>';
97
+		$html .= Api\Html::image($app, 'new').lang('Add current').'</a></li>';
99 98
 
100 99
 		$html .= '</ul></span>';
101 100
 
@@ -117,7 +116,7 @@  discard block
 block discarded – undo
117 116
 	 * @return (array|boolean) An array of sorted favorites or False if there's no preferenced sorted list
118 117
 	 *
119 118
 	 */
120
-	public static function get_fav_sort_pref ($app)
119
+	public static function get_fav_sort_pref($app)
121 120
 	{
122 121
 		$fav_sorted_list = array();
123 122
 
@@ -157,13 +156,13 @@  discard block
 block discarded – undo
157 156
 		$fav_sort_pref = self::get_fav_sort_pref($app);
158 157
 
159 158
 		// Look through all preferences & pull out favorites
160
-		foreach((array)$GLOBALS['egw_info']['user']['preferences'][$app] as $pref_name => $pref)
159
+		foreach ((array)$GLOBALS['egw_info']['user']['preferences'][$app] as $pref_name => $pref)
161 160
 		{
162
-			if(strpos($pref_name, $pref_prefix) === 0)
161
+			if (strpos($pref_name, $pref_prefix) === 0)
163 162
 			{
164
-				if(!is_array($pref)) continue;	// old favorite
163
+				if (!is_array($pref)) continue; // old favorite
165 164
 
166
-				$favorites[(string)substr($pref_name,strlen($pref_prefix))] = $pref;
165
+				$favorites[(string)substr($pref_name, strlen($pref_prefix))] = $pref;
167 166
 			}
168 167
 		}
169 168
 		if (is_array($fav_sort_pref))
@@ -172,7 +171,7 @@  discard block
 block discarded – undo
172 171
 			{
173 172
 				$sorted_list[$key] = $favorites[$key];
174 173
 			}
175
-			$favorites = array_merge($sorted_list,$favorites);
174
+			$favorites = array_merge($sorted_list, $favorites);
176 175
 		}
177 176
 		return $favorites;
178 177
 	}
@@ -204,7 +203,7 @@  discard block
 block discarded – undo
204 203
 			}
205 204
 			else
206 205
 			{
207
-				foreach($GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $gid)
206
+				foreach ($GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $gid)
208 207
 				{
209 208
 					$prefs = new Api\Preferences($gid);
210 209
 					$prefs->read_repository();
@@ -216,7 +215,7 @@  discard block
 block discarded – undo
216 215
 				}
217 216
 			}
218 217
 		}
219
-		if($group && $GLOBALS['egw_info']['apps']['admin'] && $group !== 'all')
218
+		if ($group && $GLOBALS['egw_info']['apps']['admin'] && $group !== 'all')
220 219
 		{
221 220
 			$prefs = new Api\Preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']);
222 221
 		}
@@ -227,7 +226,7 @@  discard block
 block discarded – undo
227 226
 		$prefs->read_repository();
228 227
 		$type = $group === "all" ? "default" : "user";
229 228
 		//error_log(__METHOD__."('$app', '$name', '$action', ".array2string($group).", ...) pref_name=$pref_name, type=$type");
230
-		if($action == "add")
229
+		if ($action == "add")
231 230
 		{
232 231
 			$filters = array(
233 232
 				// This is the name as user entered it, minus tags
@@ -235,9 +234,9 @@  discard block
 block discarded – undo
235 234
 				'group' => $group ? $group : false,
236 235
 				'state' => $filters
237 236
 			);
238
-			$pref_name = "favorite_".preg_replace('/[^A-Za-z0-9-_]/u','_',$name);
239
-			$result = $prefs->add($app,$pref_name,$filters,$type);
240
-			$pref = $prefs->save_repository(false,$type);
237
+			$pref_name = "favorite_".preg_replace('/[^A-Za-z0-9-_]/u', '_', $name);
238
+			$result = $prefs->add($app, $pref_name, $filters, $type);
239
+			$pref = $prefs->save_repository(false, $type);
241 240
 
242 241
 			// Update preferences client side, or it could disappear
243 242
 			Api\Json\Response::get()->call('egw.set_preferences', (array)$pref[$app], $app);
@@ -247,8 +246,8 @@  discard block
 block discarded – undo
247 246
 		}
248 247
 		else if ($action == "delete")
249 248
 		{
250
-			$result = $prefs->delete($app,$pref_name, $type);
251
-			$pref = $prefs->save_repository(false,$type);
249
+			$result = $prefs->delete($app, $pref_name, $type);
250
+			$pref = $prefs->save_repository(false, $type);
252 251
 
253 252
 			// Update preferences client side, or it could come back
254 253
 			Api\Json\Response::get()->call('egw.set_preferences', (array)$pref[$app], $app);
Please login to merge, or discard this patch.
api/src/Header/Authenticate.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -234,7 +234,7 @@
 block discarded – undo
234 234
 	 * @param string $realm
235 235
 	 * @param string $username
236 236
 	 * @param string &$password=null password to use or if null, on return stored password
237
-	 * @return string|boolean false if $password not given and can NOT be read
237
+	 * @return false|string false if $password not given and can NOT be read
238 238
 	 */
239 239
 	static private function get_digest_A1($realm,$username,&$password=null)
240 240
 	{
Please login to merge, or discard this patch.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -255,20 +255,20 @@
 block discarded – undo
255 255
 	 */
256 256
 	static public function parse_digest($txt)
257 257
 	{
258
-	    // protect against missing data
259
-	    $needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1);
260
-	    $data = array();
261
-	    $keys = implode('|', array_keys($needed_parts));
258
+		// protect against missing data
259
+		$needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1);
260
+		$data = array();
261
+		$keys = implode('|', array_keys($needed_parts));
262 262
 
263 263
 		$matches = null;
264
-	    preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER);
264
+		preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER);
265 265
 
266
-	    foreach ($matches as $m)
267
-	    {
268
-	        $data[$m[1]] = $m[3] ? $m[3] : $m[4];
269
-	        unset($needed_parts[$m[1]]);
270
-	    }
271
-	    //error_log(__METHOD__."('$txt') returning ".array2string($needed_parts ? false : $data));
272
-	    return $needed_parts ? false : $data;
266
+		foreach ($matches as $m)
267
+		{
268
+			$data[$m[1]] = $m[3] ? $m[3] : $m[4];
269
+			unset($needed_parts[$m[1]]);
270
+		}
271
+		//error_log(__METHOD__."('$txt') returning ".array2string($needed_parts ? false : $data));
272
+		return $needed_parts ? false : $data;
273 273
 	}
274 274
 }
Please login to merge, or discard this patch.
Braces   +38 added lines, -10 removed lines patch added patch discarded remove patch
@@ -82,7 +82,10 @@  discard block
 block discarded – undo
82 82
 			error_log(__METHOD__.'() PHP_AUTH_USER='.array2string($_SERVER['PHP_AUTH_USER']).', PHP_AUTH_PW='.array2string($pw).', PHP_AUTH_DIGEST='.array2string($_SERVER['PHP_AUTH_DIGEST']));
83 83
 		}
84 84
 		$realm = $GLOBALS['egw_info']['flags']['auth_realm'];
85
-		if (empty($realm)) $realm = 'EGroupware';
85
+		if (empty($realm))
86
+		{
87
+			$realm = 'EGroupware';
88
+		}
86 89
 
87 90
 		$username = $_SERVER['PHP_AUTH_USER']; $password = $_SERVER['PHP_AUTH_PW'];
88 91
 		// Support for basic auth when using PHP CGI (what about digest auth?)
@@ -139,7 +142,8 @@  discard block
 block discarded – undo
139 142
 			// replace \x encoded non-ascii chars in password, as they are used eg. by Thunderbird for German umlauts
140 143
 			if (strpos($password, '\\x') !== false)
141 144
 			{
142
-				$password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches){
145
+				$password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches)
146
+				{
143 147
 					return chr(hexdec($matches[1]));
144 148
 				}, $password);
145 149
 			}
@@ -167,7 +171,10 @@  discard block
 block discarded – undo
167 171
 		if (!($GLOBALS['egw_info']['server']['auth_type'] == 'sql' && $GLOBALS['egw_info']['server']['sql_encryption_type'] == 'plain') ||
168 172
 			  $GLOBALS['egw_info']['server']['auth_type'] == 'ldap' && $GLOBALS['egw_info']['server']['ldap_encryption_type'] == 'plain')
169 173
 		{
170
-			if (self::ERROR_LOG) error_log(__METHOD__."('$username') return false (no plaintext passwords used)");
174
+			if (self::ERROR_LOG)
175
+			{
176
+				error_log(__METHOD__."('$username') return false (no plaintext passwords used)");
177
+			}
171 178
 			return false;	// no plain-text passwords used
172 179
 		}
173 180
 		// check for specific user, if given
@@ -175,10 +182,16 @@  discard block
 block discarded – undo
175 182
 			$GLOBALS['egw_info']['server']['auth_type'] == 'sql' && substr($user_pw,0,7) != '{PLAIN}'))
176 183
 		{
177 184
 			unset($user_pw);
178
-			if (self::ERROR_LOG) error_log(__METHOD__."('$realm','$username') return false (unknown user or NO plaintext password for user)");
185
+			if (self::ERROR_LOG)
186
+			{
187
+				error_log(__METHOD__."('$realm','$username') return false (unknown user or NO plaintext password for user)");
188
+			}
179 189
 			return false;	// user does NOT exist, or has no plaintext passwords (ldap server requires real root_dn or special ACL!)
180 190
 		}
181
-		if (substr($user_pw,0,7) == '{PLAIN}') $user_pw = substr($user_pw,7);
191
+		if (substr($user_pw,0,7) == '{PLAIN}')
192
+		{
193
+			$user_pw = substr($user_pw,7);
194
+		}
182 195
 
183 196
 		if (self::ERROR_LOG)
184 197
 		{
@@ -200,7 +213,10 @@  discard block
 block discarded – undo
200 213
 		{
201 214
 			$nonce = uniqid();
202 215
    			header('WWW-Authenticate: Digest realm="'.$realm.'",qop="auth",nonce="'.$nonce.'",opaque="'.md5($realm).'"');
203
-			if (self::ERROR_LOG) error_log(__METHOD__."() offering digest auth for realm '$realm' using nonce='$nonce'");
216
+			if (self::ERROR_LOG)
217
+			{
218
+				error_log(__METHOD__."() offering digest auth for realm '$realm' using nonce='$nonce'");
219
+			}
204 220
 		}
205 221
 	}
206 222
 
@@ -215,7 +231,10 @@  discard block
 block discarded – undo
215 231
 	 */
216 232
 	static public function is_valid($realm,$auth_digest=null,&$username=null,&$password=null)
217 233
 	{
218
-		if (is_null($auth_digest)) $auth_digest = $_SERVER['PHP_AUTH_DIGEST'];
234
+		if (is_null($auth_digest))
235
+		{
236
+			$auth_digest = $_SERVER['PHP_AUTH_DIGEST'];
237
+		}
219 238
 
220 239
 		$data = self::parse_digest($auth_digest);
221 240
 
@@ -228,7 +247,10 @@  discard block
 block discarded – undo
228 247
 
229 248
 		$valid_response = md5($A1.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.$A2);
230 249
 
231
-		if (self::ERROR_LOG) error_log(__METHOD__."('$realm','$auth_digest','$username') response='$data[response]', valid_response='$valid_response' returning ".array2string($data['response'] === $valid_response));
250
+		if (self::ERROR_LOG)
251
+		{
252
+			error_log(__METHOD__."('$realm','$auth_digest','$username') response='$data[response]', valid_response='$valid_response' returning ".array2string($data['response'] === $valid_response));
253
+		}
232 254
 		return $data['response'] === $valid_response;
233 255
 	}
234 256
 
@@ -247,10 +269,16 @@  discard block
 block discarded – undo
247 269
 		{
248 270
 			return false;
249 271
 		}
250
-		if (is_null($password)) $password = $user_pw;
272
+		if (is_null($password))
273
+		{
274
+			$password = $user_pw;
275
+		}
251 276
 
252 277
 		$A1 = md5($username . ':' . $realm . ':' . $password);
253
-		if (self::ERROR_LOG > 1) error_log(__METHOD__."('$realm','$username','$password') returning ".array2string($A1));
278
+		if (self::ERROR_LOG > 1)
279
+		{
280
+			error_log(__METHOD__."('$realm','$username','$password') returning ".array2string($A1));
281
+		}
254 282
 		return $A1;
255 283
 	}
256 284
 
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	static public function autocreate_session_callback(&$account)
77 77
 	{
78
-		unset($account);	// not used, but required by function signature
78
+		unset($account); // not used, but required by function signature
79 79
 		if (self::ERROR_LOG)
80 80
 		{
81 81
 			$pw = self::ERROR_LOG > 1 ? $_SERVER['PHP_AUTH_PW'] : '**********';
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
 
87 87
 		$username = $_SERVER['PHP_AUTH_USER']; $password = $_SERVER['PHP_AUTH_PW'];
88 88
 		// Support for basic auth when using PHP CGI (what about digest auth?)
89
-		if (!isset($username) && !empty($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && strpos($_SERVER['REDIRECT_HTTP_AUTHORIZATION'],'Basic ') === 0)
89
+		if (!isset($username) && !empty($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && strpos($_SERVER['REDIRECT_HTTP_AUTHORIZATION'], 'Basic ') === 0)
90 90
 		{
91
-			$hash = base64_decode(substr($_SERVER['REDIRECT_HTTP_AUTHORIZATION'],6));
91
+			$hash = base64_decode(substr($_SERVER['REDIRECT_HTTP_AUTHORIZATION'], 6));
92 92
 			if (strpos($hash, ':') !== false)
93 93
 			{
94 94
 				list($username, $password) = explode(':', $hash, 2);
95 95
 			}
96 96
 		}
97
-		elseif (isset($_SERVER['PHP_AUTH_DIGEST']) && !self::is_valid($realm,$_SERVER['PHP_AUTH_DIGEST'],$username,$password))
97
+		elseif (isset($_SERVER['PHP_AUTH_DIGEST']) && !self::is_valid($realm, $_SERVER['PHP_AUTH_DIGEST'], $username, $password))
98 98
 		{
99 99
 			unset($password);
100 100
 		}
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 			{
116 116
 				$realm .= ': '.$GLOBALS['egw']->session->reason;
117 117
 			}
118
-			header('WWW-Authenticate: Basic realm="'.$realm.'"');// draft-reschke-basicauth-enc-06 adds, accept-charset="'.translation::charset().'"');
118
+			header('WWW-Authenticate: Basic realm="'.$realm.'"'); // draft-reschke-basicauth-enc-06 adds, accept-charset="'.translation::charset().'"');
119 119
 			self::digest_header($realm);
120 120
 			header('HTTP/1.1 401 Unauthorized');
121 121
 			header('X-WebDAV-Status: 401 Unauthorized', true);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 			// replace \x encoded non-ascii chars in password, as they are used eg. by Thunderbird for German umlauts
140 140
 			if (strpos($password, '\\x') !== false)
141 141
 			{
142
-				$password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches){
142
+				$password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches) {
143 143
 					return chr(hexdec($matches[1]));
144 144
 				}, $password);
145 145
 			}
@@ -161,24 +161,24 @@  discard block
 block discarded – undo
161 161
 	 * @param string &$user_pw =null stored cleartext password, if $username given AND function returns true
162 162
 	 * @return boolean true if digest auth is available, false otherwise
163 163
 	 */
164
-	static public function digest_auth_available($realm,$username=null,&$user_pw=null)
164
+	static public function digest_auth_available($realm, $username = null, &$user_pw = null)
165 165
 	{
166 166
 		// we currently require plaintext passwords!
167 167
 		if (!($GLOBALS['egw_info']['server']['auth_type'] == 'sql' && $GLOBALS['egw_info']['server']['sql_encryption_type'] == 'plain') ||
168 168
 			  $GLOBALS['egw_info']['server']['auth_type'] == 'ldap' && $GLOBALS['egw_info']['server']['ldap_encryption_type'] == 'plain')
169 169
 		{
170 170
 			if (self::ERROR_LOG) error_log(__METHOD__."('$username') return false (no plaintext passwords used)");
171
-			return false;	// no plain-text passwords used
171
+			return false; // no plain-text passwords used
172 172
 		}
173 173
 		// check for specific user, if given
174
-		if (!is_null($username) && !(($user_pw = $GLOBALS['egw']->accounts->id2name($username,'account_pwd','u')) ||
175
-			$GLOBALS['egw_info']['server']['auth_type'] == 'sql' && substr($user_pw,0,7) != '{PLAIN}'))
174
+		if (!is_null($username) && !(($user_pw = $GLOBALS['egw']->accounts->id2name($username, 'account_pwd', 'u')) ||
175
+			$GLOBALS['egw_info']['server']['auth_type'] == 'sql' && substr($user_pw, 0, 7) != '{PLAIN}'))
176 176
 		{
177 177
 			unset($user_pw);
178 178
 			if (self::ERROR_LOG) error_log(__METHOD__."('$realm','$username') return false (unknown user or NO plaintext password for user)");
179
-			return false;	// user does NOT exist, or has no plaintext passwords (ldap server requires real root_dn or special ACL!)
179
+			return false; // user does NOT exist, or has no plaintext passwords (ldap server requires real root_dn or special ACL!)
180 180
 		}
181
-		if (substr($user_pw,0,7) == '{PLAIN}') $user_pw = substr($user_pw,7);
181
+		if (substr($user_pw, 0, 7) == '{PLAIN}') $user_pw = substr($user_pw, 7);
182 182
 
183 183
 		if (self::ERROR_LOG)
184 184
 		{
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 * @param string $realm
195 195
 	 * @param string &$nonce=null on return
196 196
 	 */
197
-	static public function digest_header($realm,&$nonce=null)
197
+	static public function digest_header($realm, &$nonce = null)
198 198
 	{
199 199
 		if (self::digest_auth_available($realm))
200 200
 		{
@@ -213,13 +213,13 @@  discard block
 block discarded – undo
213 213
 	 * @param string &$password on return cleartext password
214 214
 	 * @return boolean true if digest is correct, false otherwise
215 215
 	 */
216
-	static public function is_valid($realm,$auth_digest=null,&$username=null,&$password=null)
216
+	static public function is_valid($realm, $auth_digest = null, &$username = null, &$password = null)
217 217
 	{
218 218
 		if (is_null($auth_digest)) $auth_digest = $_SERVER['PHP_AUTH_DIGEST'];
219 219
 
220 220
 		$data = self::parse_digest($auth_digest);
221 221
 
222
-		if (!$data || !($A1 = self::get_digest_A1($realm,$username=$data['username'],$password=null)))
222
+		if (!$data || !($A1 = self::get_digest_A1($realm, $username = $data['username'], $password = null)))
223 223
 		{
224 224
 			error_log(__METHOD__."('$realm','$auth_digest','$username') returning FALSE");
225 225
 			return false;
@@ -240,16 +240,16 @@  discard block
 block discarded – undo
240 240
 	 * @param string &$password=null password to use or if null, on return stored password
241 241
 	 * @return string|boolean false if $password not given and can NOT be read
242 242
 	 */
243
-	static private function get_digest_A1($realm,$username,&$password=null)
243
+	static private function get_digest_A1($realm, $username, &$password = null)
244 244
 	{
245 245
 		$user_pw = null;
246
-		if (empty($username) || empty($realm) || !self::digest_auth_available($realm,$username,$user_pw))
246
+		if (empty($username) || empty($realm) || !self::digest_auth_available($realm, $username, $user_pw))
247 247
 		{
248 248
 			return false;
249 249
 		}
250 250
 		if (is_null($password)) $password = $user_pw;
251 251
 
252
-		$A1 = md5($username . ':' . $realm . ':' . $password);
252
+		$A1 = md5($username.':'.$realm.':'.$password);
253 253
 		if (self::ERROR_LOG > 1) error_log(__METHOD__."('$realm','$username','$password') returning ".array2string($A1));
254 254
 		return $A1;
255 255
 	}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 	    $keys = implode('|', array_keys($needed_parts));
266 266
 
267 267
 		$matches = null;
268
-	    preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER);
268
+	    preg_match_all('@('.$keys.')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER);
269 269
 
270 270
 	    foreach ($matches as $m)
271 271
 	    {
Please login to merge, or discard this patch.
api/src/Header/ContentSecurityPolicy.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,6 @@
 block discarded – undo
41 41
 	 *
42 42
 	 * Calling this method with an empty array for frame-src, sets no defaults but "'self'"!
43 43
 	 *
44
-	 * @param string|array $set =array() URL (incl. protocol!)
45 44
 	 * @param string $source valid CSP source types like 'script-src', 'style-src', 'connect-src', 'frame-src', ...
46 45
 	 * @param string|array $attrs 'unsafe-eval' and/or 'unsafe-inline' (without quotes!) or URL (incl. protocol!)
47 46
 	 */
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 		'script-src'  => array("'unsafe-eval'"),
34 34
 		'style-src'   => array("'unsafe-inline'"),
35 35
 		'connect-src' => array(),
36
-		'frame-src'   => null,	// NOT array(), to allow setting no default frame-src!
36
+		'frame-src'   => null, // NOT array(), to allow setting no default frame-src!
37 37
 	);
38 38
 
39 39
 	/**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 				$attrs = array('www.egroupware.org');
56 56
 				if (($app_additional = Api\Hooks::process('csp-frame-src')))
57 57
 				{
58
-					foreach($app_additional as $addtional)
58
+					foreach ($app_additional as $addtional)
59 59
 					{
60 60
 						if ($addtional) $attrs = array_unique(array_merge($attrs, $addtional));
61 61
 					}
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 			}
64 64
 			self::$sources[$source] = array();
65 65
 		}
66
-		foreach((array)$attrs as $attr)
66
+		foreach ((array)$attrs as $attr)
67 67
 		{
68 68
 			if (in_array($attr, array('none', 'self', 'unsafe-eval', 'unsafe-inline')))
69 69
 			{
70
-				$attr = "'$attr'";	// automatic add quotes
70
+				$attr = "'$attr'"; // automatic add quotes
71 71
 			}
72 72
 			if (!in_array($attr, self::$sources[$source]))
73 73
 			{
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @param string|array $set =array() 'unsafe-eval' and/or 'unsafe-inline' (without quotes!) or URL (incl. protocol!)
90 90
 	 */
91
-	public static function add_script_src($set=null)
91
+	public static function add_script_src($set = null)
92 92
 	{
93 93
 		self::add('script-src', $set);
94 94
 	}
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 *
101 101
 	 * @param string|array $set =array() 'unsafe-inline' (without quotes!) and/or URL (incl. protocol!)
102 102
 	 */
103
-	public static function add_style_src($set=null)
103
+	public static function add_style_src($set = null)
104 104
 	{
105 105
 		self::add('style-src', $set);
106 106
 	}
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @param string|array $set =array() URL (incl. protocol!)
112 112
 	 */
113
-	public static function add_connect_src($set=null)
113
+	public static function add_connect_src($set = null)
114 114
 	{
115 115
 		self::add('connect-src', $set);
116 116
 	}
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 * @param string|array $set =array() URL (incl. protocol!)
124 124
 	 * @return string with attributes eg. "'unsafe-inline'"
125 125
 	 */
126
-	public static function add_frame_src($set=null)
126
+	public static function add_frame_src($set = null)
127 127
 	{
128 128
 		self::add('frame-src', $set);
129 129
 	}
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	public static function send()
137 137
 	{
138
-		self::add('frame-src', null);	// set defaults for frame-src
138
+		self::add('frame-src', null); // set defaults for frame-src
139 139
 
140 140
 		$policies = array();
141
-		foreach(self::$sources as $source => $urls)
141
+		foreach (self::$sources as $source => $urls)
142 142
 		{
143 143
 			$policies[] = "$source 'self' ".implode(' ', $urls);
144 144
 		}
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 		// recommendaton ist to not send regular AND deprecated headers together, as they can cause unexpected behavior
153 153
 		if ($user_agent == 'chrome' && $version < 25 || $user_agent == 'safari' && $version < 7)
154 154
 		{
155
-			header("X-Webkit-CSP: $csp");	// Chrome: <= 24, Safari incl. iOS
155
+			header("X-Webkit-CSP: $csp"); // Chrome: <= 24, Safari incl. iOS
156 156
 		}
157 157
 		elseif ($user_agent == 'firefox' && $version < 23 || $user_agent == 'msie')	// Edge is reported as 'edge'!
158 158
 		{
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,7 +57,10 @@  discard block
 block discarded – undo
57 57
 				{
58 58
 					foreach($app_additional as $addtional)
59 59
 					{
60
-						if ($addtional) $attrs = array_unique(array_merge($attrs, $addtional));
60
+						if ($addtional)
61
+						{
62
+							$attrs = array_unique(array_merge($attrs, $addtional));
63
+						}
61 64
 					}
62 65
 				}
63 66
 			}
@@ -154,10 +157,13 @@  discard block
 block discarded – undo
154 157
 		{
155 158
 			header("X-Webkit-CSP: $csp");	// Chrome: <= 24, Safari incl. iOS
156 159
 		}
157
-		elseif ($user_agent == 'firefox' && $version < 23 || $user_agent == 'msie')	// Edge is reported as 'edge'!
160
+		elseif ($user_agent == 'firefox' && $version < 23 || $user_agent == 'msie')
161
+		{
162
+			// Edge is reported as 'edge'!
158 163
 		{
159 164
 			header("X-Content-Security-Policy: $csp");
160 165
 		}
166
+		}
161 167
 		else
162 168
 		{
163 169
 			header("Content-Security-Policy: $csp");
Please login to merge, or discard this patch.
api/src/Hooks.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -254,7 +254,7 @@
 block discarded – undo
254 254
 
255 255
 	/**
256 256
 	 * Static function to build pgp encryption sidebox menu
257
-	 * @param type $appname application name
257
+	 * @param string $appname application name
258 258
 	 */
259 259
 	public static function pgp_encryption_menu($appname)
260 260
 	{
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -64,22 +64,22 @@  discard block
 block discarded – undo
64 64
 
65 65
 		if (!isset(self::$locations)) self::read();
66 66
 		$hooks = self::$locations[$location];
67
-		if (!isset($hooks) || empty($hooks)) return array();	// not a single app implements that hook
67
+		if (!isset($hooks) || empty($hooks)) return array(); // not a single app implements that hook
68 68
 
69 69
 		$apps = array_keys($hooks);
70 70
 		if (!$no_permission_check)
71 71
 		{
72 72
 			// on install of a new egroupware both hook-apps and user apps may be empty/not set
73
-			$apps = array_intersect((array)$apps,array_keys((array)$GLOBALS['egw_info']['user']['apps']));
73
+			$apps = array_intersect((array)$apps, array_keys((array)$GLOBALS['egw_info']['user']['apps']));
74 74
 		}
75 75
 		if ($order)
76 76
 		{
77
-			$apps = array_unique(array_merge((array)$order,$apps));
77
+			$apps = array_unique(array_merge((array)$order, $apps));
78 78
 		}
79 79
 		$results = array();
80
-		foreach((array)$apps as $appname)
80
+		foreach ((array)$apps as $appname)
81 81
 		{
82
-			$results[$appname] = self::single($args,$appname,$no_permission_check);
82
+			$results[$appname] = self::single($args, $appname, $no_permission_check);
83 83
 		}
84 84
 		return $results;
85 85
 	}
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		}
116 116
 
117 117
 		$ret = array();
118
-		foreach((array)self::$locations[$location][$appname] as $hook)
118
+		foreach ((array)self::$locations[$location][$appname] as $hook)
119 119
 		{
120 120
 			try {
121 121
 				// old style file hook
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		}
150 150
 
151 151
 		// hooks only existing in filesystem used by setup
152
-		if (!$ret && $try_unregistered && file_exists(EGW_SERVER_ROOT.($hook='/'.$appname.'/inc/hook_'.$location.'.inc.php')))
152
+		if (!$ret && $try_unregistered && file_exists(EGW_SERVER_ROOT.($hook = '/'.$appname.'/inc/hook_'.$location.'.inc.php')))
153 153
 		{
154 154
 			include(EGW_SERVER_ROOT.$hook);
155 155
 			return true;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 * @param boolean $return_methods =false true: return hook-method(s)
182 182
 	 * @return int|array the number of found hooks or for $return_methods array with methods
183 183
 	 */
184
-	public static function exists($location, $app, $return_methods=false)
184
+	public static function exists($location, $app, $return_methods = false)
185 185
 	{
186 186
 		if (!isset(self::$locations)) self::read();
187 187
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 *
209 209
 	 * @param boolan $force_rescan =false true: do not use instance cache
210 210
 	 */
211
-	public static function read($force_rescan=false)
211
+	public static function read($force_rescan = false)
212 212
 	{
213 213
 		//$starttime = microtime(true);
214 214
 		if ($force_rescan) Cache::unsetInstance(__CLASS__, 'locations');
@@ -224,18 +224,18 @@  discard block
 block discarded – undo
224 224
 
225 225
 			// read all apps using just filesystem data
226 226
 			$locations = array();
227
-			foreach(array_merge(array('api'), array_keys($GLOBALS['egw_info']['apps'])) as $appname)
227
+			foreach (array_merge(array('api'), array_keys($GLOBALS['egw_info']['apps'])) as $appname)
228 228
 			{
229 229
 				if ($appname[0] == '.' || !is_dir(EGW_SERVER_ROOT.'/'.$appname)) continue;
230 230
 
231
-				$f = EGW_SERVER_ROOT . '/' . $appname . '/setup/setup.inc.php';
231
+				$f = EGW_SERVER_ROOT.'/'.$appname.'/setup/setup.inc.php';
232 232
 				$setup_info = array($appname => array());
233
-				if(@file_exists($f)) include($f);
233
+				if (@file_exists($f)) include($f);
234 234
 
235 235
 				// some apps have setup_info for more then themselfs (eg. api for groupdav)
236
-				foreach($setup_info as $appname => $data)
236
+				foreach ($setup_info as $appname => $data)
237 237
 				{
238
-					foreach((array)$data['hooks'] as $location => $methods)
238
+					foreach ((array)$data['hooks'] as $location => $methods)
239 239
 					{
240 240
 						if (is_int($location))
241 241
 						{
Please login to merge, or discard this patch.
Braces   +57 added lines, -14 removed lines patch added patch discarded remove patch
@@ -62,9 +62,16 @@  discard block
 block discarded – undo
62 62
 		//echo "<p>".__METHOD__.'('.array2string($args).','.array2string($order).','.array2string($no_permission_check).")</p>\n";
63 63
 		$location = is_array($args) ? (isset($args['hook_location']) ? $args['hook_location'] : $args['location']) : $args;
64 64
 
65
-		if (!isset(self::$locations)) self::read();
65
+		if (!isset(self::$locations))
66
+		{
67
+			self::read();
68
+		}
66 69
 		$hooks = self::$locations[$location];
67
-		if (!isset($hooks) || empty($hooks)) return array();	// not a single app implements that hook
70
+		if (!isset($hooks) || empty($hooks))
71
+		{
72
+			return array();
73
+		}
74
+		// not a single app implements that hook
68 75
 
69 76
 		$apps = array_keys($hooks);
70 77
 		if (!$no_permission_check)
@@ -99,9 +106,15 @@  discard block
 block discarded – undo
99 106
 	{
100 107
 		//error_log(__METHOD__."(".array2string($args).",'$appname','$no_permission_check','$try_unregistered')");
101 108
 
102
-		if (!isset(self::$locations)) self::read();
109
+		if (!isset(self::$locations))
110
+		{
111
+			self::read();
112
+		}
103 113
 
104
-		if (!is_array($args)) $args = array('location' => $args);
114
+		if (!is_array($args))
115
+		{
116
+			$args = array('location' => $args);
117
+		}
105 118
 		$location = isset($args['hook_location']) ? $args['hook_location'] : $args['location'];
106 119
 
107 120
 		if (!$appname)
@@ -135,7 +148,10 @@  discard block
 block discarded – undo
135 148
 				// static method of an autoloadable class
136 149
 				if (isset($method) && class_exists($class))
137 150
 				{
138
-					if (is_callable($hook)) $ret[] = call_user_func($hook, $args);
151
+					if (is_callable($hook))
152
+					{
153
+						$ret[] = call_user_func($hook, $args);
154
+					}
139 155
 				}
140 156
 				// app.class.method or not autoloadable class
141 157
 				else
@@ -155,7 +171,10 @@  discard block
 block discarded – undo
155 171
 			return true;
156 172
 		}
157 173
 
158
-		if (!$ret) return false;
174
+		if (!$ret)
175
+		{
176
+			return false;
177
+		}
159 178
 
160 179
 		return count($ret) == 1 ? $ret[0] : $ret;
161 180
 	}
@@ -168,7 +187,10 @@  discard block
 block discarded – undo
168 187
 	 */
169 188
 	public static function count($location)
170 189
 	{
171
-		if (!isset(self::$locations)) self::read();
190
+		if (!isset(self::$locations))
191
+		{
192
+			self::read();
193
+		}
172 194
 
173 195
 		return count(self::$locations[$location]);
174 196
 	}
@@ -183,7 +205,10 @@  discard block
 block discarded – undo
183 205
 	 */
184 206
 	public static function exists($location, $app, $return_methods=false)
185 207
 	{
186
-		if (!isset(self::$locations)) self::read();
208
+		if (!isset(self::$locations))
209
+		{
210
+			self::read();
211
+		}
187 212
 
188 213
 		//error_log(__METHOD__.__LINE__.array2string(self::$locations[$location]));
189 214
 		return $return_methods ? self::$locations[$location][$app] : count(self::$locations[$location][$app]);
@@ -197,7 +222,10 @@  discard block
 block discarded – undo
197 222
 	 */
198 223
 	public static function implemented($location)
199 224
 	{
200
-		if (!isset(self::$locations)) self::read();
225
+		if (!isset(self::$locations))
226
+		{
227
+			self::read();
228
+		}
201 229
 
202 230
 		//error_log(__METHOD__.__LINE__.array2string(self::$locations[$location]));
203 231
 		return isset(self::$locations[$location]) ? array_keys(self::$locations[$location]) : array();
@@ -211,7 +239,10 @@  discard block
 block discarded – undo
211 239
 	 */
212 240
 	static public function disable($hook)
213 241
 	{
214
-		if (!isset(self::$locations)) self::read();
242
+		if (!isset(self::$locations))
243
+		{
244
+			self::read();
245
+		}
215 246
 
216 247
 		$ret = isset(self::$locations[$hook]);
217 248
 
@@ -228,7 +259,10 @@  discard block
 block discarded – undo
228 259
 	public static function read($force_rescan=false)
229 260
 	{
230 261
 		//$starttime = microtime(true);
231
-		if ($force_rescan) Cache::unsetInstance(__CLASS__, 'locations');
262
+		if ($force_rescan)
263
+		{
264
+			Cache::unsetInstance(__CLASS__, 'locations');
265
+		}
232 266
 
233 267
 		self::$locations = Cache::getInstance(__CLASS__, 'locations', function()
234 268
 		{
@@ -243,11 +277,17 @@  discard block
 block discarded – undo
243 277
 			$locations = array();
244 278
 			foreach(array_merge(array('api'), array_keys($GLOBALS['egw_info']['apps'])) as $appname)
245 279
 			{
246
-				if ($appname[0] == '.' || !is_dir(EGW_SERVER_ROOT.'/'.$appname)) continue;
280
+				if ($appname[0] == '.' || !is_dir(EGW_SERVER_ROOT.'/'.$appname))
281
+				{
282
+					continue;
283
+				}
247 284
 
248 285
 				$f = EGW_SERVER_ROOT . '/' . $appname . '/setup/setup.inc.php';
249 286
 				$setup_info = array($appname => array());
250
-				if(@file_exists($f)) include($f);
287
+				if(@file_exists($f))
288
+				{
289
+					include($f);
290
+				}
251 291
 
252 292
 				// some apps have setup_info for more then themselfs (eg. api for groupdav)
253 293
 				foreach($setup_info as $appname => $data)
@@ -275,7 +315,10 @@  discard block
 block discarded – undo
275 315
 	 */
276 316
 	public static function pgp_encryption_menu($appname)
277 317
 	{
278
-		if (Header\UserAgent::mobile()) return;
318
+		if (Header\UserAgent::mobile())
319
+		{
320
+			return;
321
+		}
279 322
 
280 323
 		// PGP Encryption (Mailvelope plugin) restore/backup menu
281 324
 		$file = Array(
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -278,7 +278,7 @@
 block discarded – undo
278 278
 		if (Header\UserAgent::mobile()) return;
279 279
 
280 280
 		// PGP Encryption (Mailvelope plugin) restore/backup menu
281
-		$file = Array(
281
+		$file = array(
282 282
 			'Backup/Restore ...' => 'javascript:app.'.$appname.'.mailvelopeCreateBackupRestoreDialog();',
283 283
 			'sendToBottom' => true
284 284
 		);
Please login to merge, or discard this patch.
api/src/Html.php 4 patches
Doc Comments   +3 added lines, -5 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	 *
140 140
 	 * @param string $name	string with name of the submitted var which holds the key of the selected item form array
141 141
 	 * @param string|array $key key(s) of already selected item(s) from $arr, eg. '1' or '1,2' or array with keys
142
-	 * @param array $arr array with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' => 'maybe');
142
+	 * @param integer $arr array with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' => 'maybe');
143 143
 	 * @param boolean $no_lang NOT run the labels of the options through lang(), default false=use lang()
144 144
 	 * @param string $options additional options (e.g. 'width')
145 145
 	 * @param int $multiple number of lines for a multiselect, default 0 = no multiselect, < 0 sets size without multiple
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	 *
228 228
 	 * @param string $name	string with name of the submitted var which holds the key of the selected item form array
229 229
 	 * @param string|array $key key(s) of already selected item(s) from $arr, eg. '1' or '1,2' or array with keys
230
-	 * @param array $arr array with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' => 'maybe');
230
+	 * @param integer $arr array with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' => 'maybe');
231 231
 	 * @param boolean $no_lang NOT run the labels of the options through lang(), default false=use lang()
232 232
 	 * @param string $options additional options (e.g. 'width')
233 233
 	 * @param int $multiple number of lines for a multiselect, default 3
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 	 * @param string $value value
314 314
 	 * @param string $label label
315 315
 	 * @param mixed $selected value or array of values of options to mark as selected
316
-	 * @param boolean $no_lang NOT running the label through lang(), default false=use lang()
316
+	 * @param integer $no_lang NOT running the label through lang(), default false=use lang()
317 317
 	 * @param string $extra extra text, e.g.: style="", default: ''
318 318
 	 * @return string html
319 319
 	 */
@@ -386,7 +386,6 @@  discard block
 block discarded – undo
386 386
 	 *
387 387
 	 * @param string $name name attr. of the tag
388 388
 	 * @param string $value default
389
-	 * @param boolean $ignore_empty if true all empty, zero (!) or unset values, plus filer=none
390 389
 	 * @param boolean $double_encoding =false do we want double encoding or not, default no
391 390
 	 * @param string html
392 391
 	 */
@@ -741,7 +740,6 @@  discard block
 block discarded – undo
741 740
 	 * @param array $hidden_vars array with name-value pairs for hidden input fields
742 741
 	 * @param string $url eGW relative URL, will be run through the link function
743 742
 	 * @param string|array $url_vars parameters for the URL, send to link static function too
744
-	 * @param string $options attributes for the tag, default ''=none
745 743
 	 * @param string $form_name name of the form, defaul ''=none
746 744
 	 * @param string $method method of the form, default 'POST'
747 745
 	 * @return string html
Please login to merge, or discard this patch.
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -425,20 +425,20 @@  discard block
 block discarded – undo
425 425
 	}
426 426
 
427 427
 	/**
428
-	* this static function is a wrapper for fckEditor to create some reuseable layouts
429
-	*
430
-	* @param string $_name name and id of the input-field
431
-	* @param string $_content of the tinymce (will be run through htmlspecialchars !!!), default ''
432
-	* @param string $_mode display mode of the tinymce editor can be: simple, extended or advanced
433
-	* @param array  $_options (toolbar_expanded true/false)
434
-	* @param string $_height ='400px'
435
-	* @param string $_width ='100%'
436
-	* @param string $_start_path ='' if passed activates the browser for image at absolute path passed
437
-	* @param boolean $_purify =true run $_content through htmlpurifier before handing it to fckEditor
438
-	* @param mixed (boolean/string) $_focusToBody=false USED only for CKEDIOR true means yes, focus on top, you may specify TOP or BOTTOM (to focus on the end of the editor area)
439
-	* @param string $_executeJSAfterInit ='' Javascript to be executed after InstanceReady of CKEditor
440
-	* @return string the necessary html for the textarea
441
-	*/
428
+	 * this static function is a wrapper for fckEditor to create some reuseable layouts
429
+	 *
430
+	 * @param string $_name name and id of the input-field
431
+	 * @param string $_content of the tinymce (will be run through htmlspecialchars !!!), default ''
432
+	 * @param string $_mode display mode of the tinymce editor can be: simple, extended or advanced
433
+	 * @param array  $_options (toolbar_expanded true/false)
434
+	 * @param string $_height ='400px'
435
+	 * @param string $_width ='100%'
436
+	 * @param string $_start_path ='' if passed activates the browser for image at absolute path passed
437
+	 * @param boolean $_purify =true run $_content through htmlpurifier before handing it to fckEditor
438
+	 * @param mixed (boolean/string) $_focusToBody=false USED only for CKEDIOR true means yes, focus on top, you may specify TOP or BOTTOM (to focus on the end of the editor area)
439
+	 * @param string $_executeJSAfterInit ='' Javascript to be executed after InstanceReady of CKEditor
440
+	 * @return string the necessary html for the textarea
441
+	 */
442 442
 	static function fckEditor($_name, $_content, $_mode, $_options=array('toolbar_expanded' =>'true'),
443 443
 		$_height='400px', $_width='100%',$_start_path='',$_purify=true, $_focusToBody=false, $_executeJSAfterInit='')
444 444
 	{
@@ -509,21 +509,21 @@  discard block
 block discarded – undo
509 509
 	}
510 510
 
511 511
 	/**
512
-	* this static function is a wrapper for tinymce to create some reuseable layouts
513
-	*
514
-	* Please note: if you did not run init_tinymce already you this static function need to be called before the call to phpgw_header() !!!
515
-	*
516
-	* @param string $_name name and id of the input-field
517
-	* @param string $_mode display mode of the tinymce editor can be: simple, extended or advanced
518
-	* @param string $_content ='' of the tinymce (will be run through htmlspecialchars !!!), default ''
519
-	* @param string $_height ='400px'
520
-	* @param string $_width ='100%'
521
-	* @param boolean $_purify =true
522
-	* @param string $_border ='0px' NOT used for CKEditor
523
-	* @param mixed (boolean/string) $_focusToBody=false USED only for CKEDIOR true means yes, focus on top, you may specify TOP or BOTTOM (to focus on the end of the editor area)
524
-	* @param string $_executeJSAfterInit ='' Javascript to be executed after InstanceReady of CKEditor
525
-	* @return string the necessary html for the textarea
526
-	*/
512
+	 * this static function is a wrapper for tinymce to create some reuseable layouts
513
+	 *
514
+	 * Please note: if you did not run init_tinymce already you this static function need to be called before the call to phpgw_header() !!!
515
+	 *
516
+	 * @param string $_name name and id of the input-field
517
+	 * @param string $_mode display mode of the tinymce editor can be: simple, extended or advanced
518
+	 * @param string $_content ='' of the tinymce (will be run through htmlspecialchars !!!), default ''
519
+	 * @param string $_height ='400px'
520
+	 * @param string $_width ='100%'
521
+	 * @param boolean $_purify =true
522
+	 * @param string $_border ='0px' NOT used for CKEditor
523
+	 * @param mixed (boolean/string) $_focusToBody=false USED only for CKEDIOR true means yes, focus on top, you may specify TOP or BOTTOM (to focus on the end of the editor area)
524
+	 * @param string $_executeJSAfterInit ='' Javascript to be executed after InstanceReady of CKEditor
525
+	 * @return string the necessary html for the textarea
526
+	 */
527 527
 	static function fckEditorQuick($_name, $_mode, $_content='', $_height='400px', $_width='100%',$_purify=true, $_border='0px',$_focusToBody=false,$_executeJSAfterInit='')
528 528
 	{
529 529
 		if (!self::htmlarea_availible() || $_mode == 'ascii')
Please login to merge, or discard this patch.
Spacing   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 */
35 35
 	static function activate_links($content)
36 36
 	{
37
-		if (!$content || strlen($content) < 20) return $content;	// performance
37
+		if (!$content || strlen($content) < 20) return $content; // performance
38 38
 
39 39
 		// Exclude everything which is already a link
40 40
 		$NotAnchor = '(?<!"|href=|href\s=\s|href=\s|href\s=)';
@@ -46,73 +46,73 @@  discard block
 block discarded – undo
46 46
 
47 47
 		//  First match things beginning with http:// (or other protocols)
48 48
 		$optBracket0 = '(<|&lt;)';
49
-		$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))';	// only http:// gets removed, other protocolls are shown
49
+		$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))'; // only http:// gets removed, other protocolls are shown
50 50
 		$Domain = '([\w-]+\.[\w-.]+)';
51 51
 		$Subdir = '([\w\-\.,@?^=%&;:\/~\+#]*[\w\-\@?^=%&\/~\+#])?';
52 52
 		$optBracket = '(>|&gt;)';
53
-		$Expr = '/' .$optBracket0. $NotAnchor . $Protocol . $Domain . $Subdir . $optBracket . '/i';
53
+		$Expr = '/'.$optBracket0.$NotAnchor.$Protocol.$Domain.$Subdir.$optBracket.'/i';
54 54
 		// use preg_replace_callback as we experienced problems with https links
55
-		$result2 = preg_replace_callback($Expr, function ($match)
55
+		$result2 = preg_replace_callback($Expr, function($match)
56 56
 		{
57
-			return $match[1]."<a href=\"".($match[2]&&!$match[3]?$match[2]:'').($match[3]?$match[3]:'').$match[4].$match[5]."\" target=\"_blank\">".$match[4].$match[5]."</a>".$match[6];
57
+			return $match[1]."<a href=\"".($match[2] && !$match[3] ? $match[2] : '').($match[3] ? $match[3] : '').$match[4].$match[5]."\" target=\"_blank\">".$match[4].$match[5]."</a>".$match[6];
58 58
 		}, $result);
59 59
 
60 60
 		if (true)	// hack to keep IDE from complaing about double assignments
61 61
 		{
62 62
 			//  First match things beginning with http:// (or other protocols)
63
-			$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))';	// only http:// gets removed, other protocolls are shown
63
+			$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))'; // only http:// gets removed, other protocolls are shown
64 64
 			$Domain = '([\w-]+\.[\w-.]+)';
65 65
 			$Subdir = '([\w\-\.,@?^=%&;:\/~\+#]*[\w\-\@?^=%&\/~\+#])?';
66 66
 			$optStuff = '(&quot;|&quot|;)?';
67
-			$Expr = '/' . $NotAnchor . $Protocol . $Domain . $Subdir . $optStuff . '/i';
67
+			$Expr = '/'.$NotAnchor.$Protocol.$Domain.$Subdir.$optStuff.'/i';
68 68
 			// use preg_replace_callback as we experienced problems with https links
69
-			$result3 = preg_replace_callback($Expr, function ($match)
69
+			$result3 = preg_replace_callback($Expr, function($match)
70 70
 			{
71
-				$additionalQuote="";//at the end, ...
71
+				$additionalQuote = ""; //at the end, ...
72 72
 				// only one &quot at the end is found. chance is, it is not belonging to the URL
73
-				if ($match[5]==';' && (strlen($match[4])-6) >=0 && strpos($match[4],'&quot',strlen($match[4])-6)!==false && strpos(substr($match[4],0,strlen($match[4])-6),'&quot')===false)
73
+				if ($match[5] == ';' && (strlen($match[4]) - 6) >= 0 && strpos($match[4], '&quot', strlen($match[4]) - 6) !== false && strpos(substr($match[4], 0, strlen($match[4]) - 6), '&quot') === false)
74 74
 				{
75
-					$match[4] = substr($match[4],0,strpos($match[4],'&quot',strlen($match[4])-6));
75
+					$match[4] = substr($match[4], 0, strpos($match[4], '&quot', strlen($match[4]) - 6));
76 76
 					$additionalQuote = "&quot;";
77 77
 				}
78 78
 				// if there is quoted stuff within the URL then we have at least one more &quot; in match[4], so chance is the last &quot is matched by the one within
79
-				if ($match[5]==';' && (strlen($match[4])-6) >=0 && strpos($match[4],'&quot',strlen($match[4])-6)!==false && strpos(substr($match[4],0,strlen($match[4])-6),'&quot')!==false)
79
+				if ($match[5] == ';' && (strlen($match[4]) - 6) >= 0 && strpos($match[4], '&quot', strlen($match[4]) - 6) !== false && strpos(substr($match[4], 0, strlen($match[4]) - 6), '&quot') !== false)
80 80
 				{
81 81
 					$match[4] .= $match[5];
82 82
 				}
83
-				if ($match[5]==';'&&$match[4]=="&quot")
83
+				if ($match[5] == ';' && $match[4] == "&quot")
84 84
 				{
85
-					$match[4] ='';
85
+					$match[4] = '';
86 86
 					$additionalQuote = "&quot;";
87 87
 				}
88 88
 				//error_log(__METHOD__.__LINE__.array2string($match));
89
-				return "<a href=\"".($match[1]&&!$match[2]?$match[1]:'').($match[2]?$match[2]:'').$match[3].$match[4]."\" target=\"_blank\">".$match[3].$match[4]."</a>$additionalQuote";
89
+				return "<a href=\"".($match[1] && !$match[2] ? $match[1] : '').($match[2] ? $match[2] : '').$match[3].$match[4]."\" target=\"_blank\">".$match[3].$match[4]."</a>$additionalQuote";
90 90
 			}, $result2);
91 91
 
92 92
 			//  Now match things beginning with www.
93 93
 			$optBracket0 = '(<|&lt;)?';
94
-			$NotHTTP = '(?<!:\/\/|" target=\"_blank\">)';	//	avoid running again on http://www links already handled above
94
+			$NotHTTP = '(?<!:\/\/|" target=\"_blank\">)'; //	avoid running again on http://www links already handled above
95 95
 			$Domain2 = 'www(\.[\w-.]+)';
96 96
 			$Subdir2 = '([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?';
97 97
 			$optBracket = '(>|&gt;|&gt|;)?';
98
-			$Expr = '/' .$optBracket0. $NotAnchor . $NotHTTP . $Domain2 . $Subdir2 .$optBracket. '/i';
98
+			$Expr = '/'.$optBracket0.$NotAnchor.$NotHTTP.$Domain2.$Subdir2.$optBracket.'/i';
99 99
 			//$Expr = '/' . $NotAnchor . $NotHTTP . $Domain . $Subdir . $optBracket . '/i';
100 100
 			// use preg_replace_callback as we experienced problems with links such as <www.example.tld/pfad/zu/einer/pdf-Datei.pdf>
101
-			$result4 = preg_replace_callback( $Expr, function ($match) {
101
+			$result4 = preg_replace_callback($Expr, function($match) {
102 102
 					//error_log(__METHOD__.__LINE__.array2string($match));
103
-					if ($match[4]==';' && (strlen($match[3])-4) >=0 && strpos($match[3],'&gt',strlen($match[3])-4)!==false)
103
+					if ($match[4] == ';' && (strlen($match[3]) - 4) >= 0 && strpos($match[3], '&gt', strlen($match[3]) - 4) !== false)
104 104
 					{
105
-						$match[3] = substr($match[3],0,strpos($match[3],'&gt',strlen($match[3])-4));
105
+						$match[3] = substr($match[3], 0, strpos($match[3], '&gt', strlen($match[3]) - 4));
106 106
 						$match[4] = "&gt;";
107 107
 					}
108
-					if ($match[4]==';'&&$match[3]=="&gt")
108
+					if ($match[4] == ';' && $match[3] == "&gt")
109 109
 					{
110
-						$match[3] ='';
110
+						$match[3] = '';
111 111
 						$match[4] = "&gt;";
112 112
 					}
113 113
 					//error_log(__METHOD__.__LINE__.array2string($match));
114 114
 					return $match[1]."<a href=\"http://www".$match[2].$match[3]."\" target=\"_blank\">"."www".$match[2].$match[3]."</a>".$match[4];
115
-				}, $result3 );
115
+				}, $result3);
116 116
 		}
117 117
 		return $result4;
118 118
 	}
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
 	 * @param boolean $double_encoding =false do we want double encoding or not, default no
130 130
 	 * @return string
131 131
 	 */
132
-	static function htmlspecialchars($str, $double_encoding=false)
132
+	static function htmlspecialchars($str, $double_encoding = false)
133 133
 	{
134
-		return htmlspecialchars($str,ENT_COMPAT,Translation::charset(),$double_encoding);
134
+		return htmlspecialchars($str, ENT_COMPAT, Translation::charset(), $double_encoding);
135 135
 	}
136 136
 
137 137
 	/**
@@ -146,36 +146,36 @@  discard block
 block discarded – undo
146 146
 	 * @param boolean $enhanced Use enhanced selectbox with search.  Null for default yes if more than 12 options.
147 147
 	 * @return string to set for a template or to echo into html page
148 148
 	 */
149
-	static function select($name, $key, $arr=0,$no_lang=false,$options='',$multiple=0,$enhanced=null)
149
+	static function select($name, $key, $arr = 0, $no_lang = false, $options = '', $multiple = 0, $enhanced = null)
150 150
 	{
151
-		if(is_null($enhanced)) $enhanced = false;	//disabled by default (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
151
+		if (is_null($enhanced)) $enhanced = false; //disabled by default (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
152 152
 
153 153
 		if (!is_array($arr))
154 154
 		{
155
-			$arr = array('no','yes');
155
+			$arr = array('no', 'yes');
156 156
 		}
157 157
 		if ((int)$multiple > 0)
158 158
 		{
159 159
 			$options .= ' multiple="1" size="'.(int)$multiple.'"';
160
-			if (substr($name,-2) != '[]')
160
+			if (substr($name, -2) != '[]')
161 161
 			{
162 162
 				$name .= '[]';
163 163
 			}
164 164
 		}
165
-		elseif($multiple < 0)
165
+		elseif ($multiple < 0)
166 166
 		{
167 167
 			$options .= ' size="'.abs($multiple).'"';
168 168
 		}
169 169
 		// fix width for MSIE < 9 in/for selectboxes
170 170
 		if (Header\UserAgent::type() == 'msie' && Header\UserAgent::version() < 9)
171 171
 		{
172
-			if (stripos($options,'onfocus="') === false)
172
+			if (stripos($options, 'onfocus="') === false)
173 173
 			{
174 174
 				$options .= ' onfocus="window.dropdown_menu_hack(this);" ';
175 175
 			}
176 176
 			else
177 177
 			{
178
-				$options = str_ireplace('onfocus="','onfocus="window.dropdown_menu_hack(this);',$options);
178
+				$options = str_ireplace('onfocus="', 'onfocus="window.dropdown_menu_hack(this);', $options);
179 179
 			}
180 180
 		}
181 181
 		$out = "<select name=\"$name\" $options>\n";
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
 		if (!is_array($key))
184 184
 		{
185 185
 			// explode on ',' only if multiple values expected and the key contains just numbers and commas
186
-			$key = $multiple > 0 && preg_match('/^[,0-9]+$/',$key) ? explode(',',$key) : array($key);
186
+			$key = $multiple > 0 && preg_match('/^[,0-9]+$/', $key) ? explode(',', $key) : array($key);
187 187
 		}
188
-		foreach($arr as $k => $data)
188
+		foreach ($arr as $k => $data)
189 189
 		{
190 190
 			if (!is_array($data) || count($data) == 2 && isset($data['label']) && isset($data['title']))
191 191
 			{
192
-				$out .= self::select_option($k,is_array($data)?$data['label']:$data,$key,$no_lang,
193
-					is_array($data)?$data['title']:'');
192
+				$out .= self::select_option($k, is_array($data) ? $data['label'] : $data, $key, $no_lang,
193
+					is_array($data) ? $data['title'] : '');
194 194
 			}
195 195
 			else
196 196
 			{
@@ -201,19 +201,19 @@  discard block
 block discarded – undo
201 201
 				}
202 202
 				$out .= '<optgroup label="'.self::htmlspecialchars($no_lang || $k == '' ? $k : lang($k))."\">\n";
203 203
 
204
-				foreach($data as $k => $label)
204
+				foreach ($data as $k => $label)
205 205
 				{
206
-					$out .= self::select_option($k,is_array($label)?$label['label']:$label,$key,$no_lang,
207
-						is_array($label)?$label['title']:'');
206
+					$out .= self::select_option($k, is_array($label) ? $label['label'] : $label, $key, $no_lang,
207
+						is_array($label) ? $label['title'] : '');
208 208
 				}
209 209
 				$out .= "</optgroup>\n";
210 210
 			}
211 211
 		}
212 212
 		$out .= "</select>\n";
213 213
 
214
-		if($enhanced) {
214
+		if ($enhanced) {
215 215
 			Framework::includeJS('/api/js/jquery/chosen/chosen.jquery.js');
216
-			Framework::includeCSS('/api/js/jquery/chosen/chosen.css',null,false);
216
+			Framework::includeCSS('/api/js/jquery/chosen/chosen.css', null, false);
217 217
 			$out .= "<script>var lab = egw_LAB || \$LAB; lab.wait(function() {jQuery(function() {if(jQuery().chosen) jQuery('select[name=\"$name\"]').chosen({width: '100%'});});})</script>\n";
218 218
 		}
219 219
 		return $out;
@@ -235,39 +235,39 @@  discard block
 block discarded – undo
235 235
 	 * @param string $style ='' extra style settings like "width: 100%", default '' none
236 236
 	 * @return string to set for a template or to echo into html page
237 237
 	 */
238
-	static function checkbox_multiselect($name, $key, $arr=0,$no_lang=false,$options='',$multiple=3,$selected_first=true,$style='',$enhanced = null)
238
+	static function checkbox_multiselect($name, $key, $arr = 0, $no_lang = false, $options = '', $multiple = 3, $selected_first = true, $style = '', $enhanced = null)
239 239
 	{
240 240
 		//echo "<p align=right>checkbox_multiselect('$name',".array2string($key).",".array2string($arr).",$no_lang,'$options',$multiple,$selected_first,'$style')</p>\n";
241
-		if(is_null($enhanced)) $enhanced = (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
241
+		if (is_null($enhanced)) $enhanced = (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
242 242
 
243 243
 		if (!is_array($arr))
244 244
 		{
245
-			$arr = array('no','yes');
245
+			$arr = array('no', 'yes');
246 246
 		}
247 247
 		if ((int)$multiple <= 0) $multiple = 1;
248 248
 
249
-		if (substr($name,-2) != '[]')
249
+		if (substr($name, -2) != '[]')
250 250
 		{
251 251
 			$name .= '[]';
252 252
 		}
253
-		$base_name = substr($name,0,-2);
253
+		$base_name = substr($name, 0, -2);
254 254
 
255
-		if($enhanced) return self::select($name, $key, $arr,$no_lang,$options." style=\"$style\" ",$multiple,$enhanced);
255
+		if ($enhanced) return self::select($name, $key, $arr, $no_lang, $options." style=\"$style\" ", $multiple, $enhanced);
256 256
 
257 257
 		if (!is_array($key))
258 258
 		{
259 259
 			// explode on ',' only if multiple values expected and the key contains just numbers and commas
260
-			$key = preg_match('/^[,0-9]+$/',$key) ? explode(',',$key) : array($key);
260
+			$key = preg_match('/^[,0-9]+$/', $key) ? explode(',', $key) : array($key);
261 261
 		}
262 262
 		$html = '';
263
-		$options_no_id = preg_replace('/id="[^"]+"/i','',$options);
263
+		$options_no_id = preg_replace('/id="[^"]+"/i', '', $options);
264 264
 
265 265
 		if ($selected_first)
266 266
 		{
267 267
 			$selected = $not_selected = array();
268
-			foreach($arr as $val => $label)
268
+			foreach ($arr as $val => $label)
269 269
 			{
270
-				if (in_array((string)$val,$key))
270
+				if (in_array((string)$val, $key))
271 271
 				{
272 272
 					$selected[$val] = $label;
273 273
 				}
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 			$arr = $selected + $not_selected;
280 280
 		}
281 281
 		$max_len = 0;
282
-		foreach($arr as $val => $label)
282
+		foreach ($arr as $val => $label)
283 283
 		{
284 284
 			if (is_array($label))
285 285
 			{
@@ -295,16 +295,16 @@  discard block
 block discarded – undo
295 295
 
296 296
 			if (strlen($label) > $max_len) $max_len = strlen($label);
297 297
 
298
-			$html .= self::label(self::checkbox($name,in_array((string)$val,$key),$val,$options_no_id.
298
+			$html .= self::label(self::checkbox($name, in_array((string)$val, $key), $val, $options_no_id.
299 299
 				' id="'.$base_name.'['.$val.']'.'"').self::htmlspecialchars($label),
300
-				$base_name.'['.$val.']','',($title ? 'title="'.self::htmlspecialchars($title).'" ':''))."<br />\n";
300
+				$base_name.'['.$val.']', '', ($title ? 'title="'.self::htmlspecialchars($title).'" ' : ''))."<br />\n";
301 301
 		}
302
-		if ($style && substr($style,-1) != ';') $style .= '; ';
303
-		if (strpos($style,'height')===false) $style .= 'height: '.(1.7*$multiple).'em; ';
304
-		if (strpos($style,'width')===false)  $style .= 'width: '.(4+$max_len*($max_len < 15 ? 0.65 : 0.6)).'em; ';
302
+		if ($style && substr($style, -1) != ';') $style .= '; ';
303
+		if (strpos($style, 'height') === false) $style .= 'height: '.(1.7 * $multiple).'em; ';
304
+		if (strpos($style, 'width') === false)  $style .= 'width: '.(4 + $max_len * ($max_len < 15 ? 0.65 : 0.6)).'em; ';
305 305
 		$style .= 'background-color: white; overflow: auto; border: lightgray 2px inset; text-align: left;';
306 306
 
307
-		return self::div($html,$options,'',$style);
307
+		return self::div($html, $options, '', $style);
308 308
 	}
309 309
 
310 310
 	/**
@@ -317,23 +317,23 @@  discard block
 block discarded – undo
317 317
 	 * @param string $extra extra text, e.g.: style="", default: ''
318 318
 	 * @return string html
319 319
 	 */
320
-	static function select_option($value,$label,$selected,$no_lang=0,$title='',$extra='')
320
+	static function select_option($value, $label, $selected, $no_lang = 0, $title = '', $extra = '')
321 321
 	{
322 322
 		// the following compares strict as strings, to archive: '0' == 0 != ''
323 323
 		// the first non-strict search via array_search, is for performance reasons, to not always search the whole array with php
324
-		if (($found = ($key = array_search($value,$selected)) !== false) && (string) $value !== (string) $selected[$key])
324
+		if (($found = ($key = array_search($value, $selected)) !== false) && (string)$value !== (string)$selected[$key])
325 325
 		{
326 326
 			$found = false;
327
-			foreach($selected as $sel)
327
+			foreach ($selected as $sel)
328 328
 			{
329
-				if (($found = (((string) $value) === ((string) $selected[$key])))) break;
329
+				if (($found = (((string)$value) === ((string)$selected[$key])))) break;
330 330
 			}
331 331
 			unset($sel);
332 332
 		}
333
-		return '<option value="'.self::htmlspecialchars($value).'"'.($found  ? ' selected="selected"' : '') .
334
-			($title ? ' title="'.self::htmlspecialchars($no_lang ? $title : lang($title)).'"' : '') .
335
-			($extra ? ' ' . $extra : '') . '>'.
336
-			self::htmlspecialchars($no_lang || $label == '' ? $label : lang($label)) . "</option>\n";
333
+		return '<option value="'.self::htmlspecialchars($value).'"'.($found ? ' selected="selected"' : '').
334
+			($title ? ' title="'.self::htmlspecialchars($no_lang ? $title : lang($title)).'"' : '').
335
+			($extra ? ' '.$extra : '').'>'.
336
+			self::htmlspecialchars($no_lang || $label == '' ? $label : lang($label))."</option>\n";
337 337
 	}
338 338
 
339 339
 	/**
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 	 * @param string $style css-styles attribute, default ''=none
346 346
 	 * @return string html
347 347
 	 */
348
-	static function div($content,$options='',$class='',$style='')
348
+	static function div($content, $options = '', $class = '', $style = '')
349 349
 	{
350 350
 		if ($class) $options .= ' class="'.$class.'"';
351 351
 		if ($style) $options .= ' style="'.$style.'"';
@@ -361,13 +361,13 @@  discard block
 block discarded – undo
361 361
 	 * @param boolean $ignore_empty if true all empty, zero (!) or unset values, plus filer=none
362 362
 	 * @param string html
363 363
 	 */
364
-	static function input_hidden($vars,$value='',$ignore_empty=True)
364
+	static function input_hidden($vars, $value = '', $ignore_empty = True)
365 365
 	{
366 366
 		if (!is_array($vars))
367 367
 		{
368
-			$vars = array( $vars => $value );
368
+			$vars = array($vars => $value);
369 369
 		}
370
-		foreach($vars as $name => $value)
370
+		foreach ($vars as $name => $value)
371 371
 		{
372 372
 			if (is_array($value))
373 373
 			{
@@ -390,9 +390,9 @@  discard block
 block discarded – undo
390 390
 	 * @param boolean $double_encoding =false do we want double encoding or not, default no
391 391
 	 * @param string html
392 392
 	 */
393
-	static function textarea($name,$value='',$options='',$double_encoding=false)
393
+	static function textarea($name, $value = '', $options = '', $double_encoding = false)
394 394
 	{
395
-		return "<textarea name=\"$name\" $options>".self::htmlspecialchars($value,$double_encoding)."</textarea>\n";
395
+		return "<textarea name=\"$name\" $options>".self::htmlspecialchars($value, $double_encoding)."</textarea>\n";
396 396
 	}
397 397
 
398 398
 	/**
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 	 *
416 416
 	 * creates a textarea inputfield for the htmlarea js-widget (returns the necessary html and js)
417 417
 	 */
418
-	static function htmlarea($name,$content='',$style='',$base_href=''/*,$plugins='',$custom_toolbar='',$set_width_height_in_config=false*/)
418
+	static function htmlarea($name, $content = '', $style = '', $base_href = ''/*,$plugins='',$custom_toolbar='',$set_width_height_in_config=false*/)
419 419
 	{
420 420
 		/*if (!self::htmlarea_availible())
421 421
 		{
@@ -439,12 +439,12 @@  discard block
 block discarded – undo
439 439
 	* @param string $_executeJSAfterInit ='' Javascript to be executed after InstanceReady of CKEditor
440 440
 	* @return string the necessary html for the textarea
441 441
 	*/
442
-	static function fckEditor($_name, $_content, $_mode, $_options=array('toolbar_expanded' =>'true'),
443
-		$_height='400px', $_width='100%',$_start_path='',$_purify=true, $_focusToBody=false, $_executeJSAfterInit='')
442
+	static function fckEditor($_name, $_content, $_mode, $_options = array('toolbar_expanded' =>'true'),
443
+		$_height = '400px', $_width = '100%', $_start_path = '', $_purify = true, $_focusToBody = false, $_executeJSAfterInit = '')
444 444
 	{
445 445
 		if (!self::htmlarea_availible() || $_mode == 'ascii')
446 446
 		{
447
-			return self::textarea($_name,$_content,'style="width: '.$_width.'; height: '.$_height.';" id="'.htmlspecialchars($_name).'"');
447
+			return self::textarea($_name, $_content, 'style="width: '.$_width.'; height: '.$_height.';" id="'.htmlspecialchars($_name).'"');
448 448
 		}
449 449
 
450 450
 		//include the ckeditor js file
@@ -465,13 +465,13 @@  discard block
 block discarded – undo
465 465
 		// User preferences
466 466
 		$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
467 467
 		$font_size = Html\CkEditorConfig::font_size_from_prefs();
468
-		$font_span = '<span '.($font||$font_size?'style=\"':'').($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'\">';
468
+		$font_span = '<span '.($font || $font_size ? 'style=\"' : '').($font ? 'font-family:'.$font.'; ' : '').($font_size ? 'font-size:'.$font_size.'; ' : '').'\">';
469 469
 		if (empty($font) && empty($font_size)) $font_span = '';
470 470
 
471 471
 		// we need to enable double encoding here, as ckEditor has to undo one level of encoding
472 472
 		// otherwise < and > chars eg. from html markup entered in regular (not source) input, will turn into html!
473 473
 		//error_log(__METHOD__.__LINE__.' '.Header\UserAgent::type().','.Header\UserAgent::version());
474
-		return self::textarea($_name,$_content,'id="'.htmlspecialchars($_name).'"',true).	// true = double encoding
474
+		return self::textarea($_name, $_content, 'id="'.htmlspecialchars($_name).'"', true).// true = double encoding
475 475
 '
476 476
 <script type="text/javascript">
477 477
 window.CKEDITOR_BASEPATH="'.$GLOBALS['egw_info']['server']['webserver_url'].'/vendor/egroupware/ckeditor/";
@@ -484,22 +484,22 @@  discard block
 block discarded – undo
484 484
 		function (ev)
485 485
 		{
486 486
 			//alert("CKEditorLoad:"+"'.$_focusToBody.'");
487
-'.($_focusToBody?'
487
+'.($_focusToBody ? '
488 488
 			ev.editor.focus();':'').'
489 489
 			var d = ev.editor.document;
490 490
 			var r = new CKEDITOR.dom.range(d);
491 491
 			r.collapse(true);
492 492
 			r.selectNodeContents(d.getBody());
493
-			r.collapse('.($_focusToBody==='BOTTOM'?'false':'true').');
494
-			r.select();'.($font_span?'
493
+			r.collapse('.($_focusToBody === 'BOTTOM' ? 'false' : 'true').');
494
+			r.select();'.($font_span ? '
495 495
 			//this stuff is needed, as the above places the caret just before the span tag
496 496
 			var sN = r.startContainer.getNextSourceNode();
497 497
 			//FF is selecting the span with getNextSourceNode, other browsers need to fetch it with getNext
498 498
 			r.selectNodeContents(((typeof sN.getName==="function") && sN.getName()=="span"?r.startContainer.getNextSourceNode():r.startContainer.getNextSourceNode().getNext()));
499 499
 			r.collapse(true);
500
-			r.select();'.'':'').'
500
+			r.select();'.'' : '').'
501 501
 			ev.editor.resize("100%", '.str_replace('px', '', $pxheight).');
502
-'.($_executeJSAfterInit?$_executeJSAfterInit:'').'
502
+'.($_executeJSAfterInit ? $_executeJSAfterInit : '').'
503 503
 		}
504 504
 	);'.
505 505
 	(trim($_content) == '' && $font_span ? 'CKEDITOR.instances["'.$_name.'"].setData("'.$font_span.'&#8203;</span>");' : '').
@@ -524,16 +524,16 @@  discard block
 block discarded – undo
524 524
 	* @param string $_executeJSAfterInit ='' Javascript to be executed after InstanceReady of CKEditor
525 525
 	* @return string the necessary html for the textarea
526 526
 	*/
527
-	static function fckEditorQuick($_name, $_mode, $_content='', $_height='400px', $_width='100%',$_purify=true, $_border='0px',$_focusToBody=false,$_executeJSAfterInit='')
527
+	static function fckEditorQuick($_name, $_mode, $_content = '', $_height = '400px', $_width = '100%', $_purify = true, $_border = '0px', $_focusToBody = false, $_executeJSAfterInit = '')
528 528
 	{
529 529
 		if (!self::htmlarea_availible() || $_mode == 'ascii')
530 530
 		{
531 531
 			//TODO: use self::textarea
532
-			return "<textarea name=\"$_name\" style=\"".($_width?" width:".$_width.';':" width:100%;").($_height?" height:".$_height.';':" height:400px;").($_border?" border:".$_border.';':" border:0px;")."\">$_content</textarea>";
532
+			return "<textarea name=\"$_name\" style=\"".($_width ? " width:".$_width.';' : " width:100%;").($_height ? " height:".$_height.';' : " height:400px;").($_border ? " border:".$_border.';' : " border:0px;")."\">$_content</textarea>";
533 533
 		}
534 534
 		else
535 535
 		{
536
-			return self::fckEditor($_name, $_content, $_mode, array(), $_height, $_width,'',$_purify,$_focusToBody,$_executeJSAfterInit);
536
+			return self::fckEditor($_name, $_content, $_mode, array(), $_height, $_width, '', $_purify, $_focusToBody, $_executeJSAfterInit);
537 537
 		}
538 538
 	}
539 539
 
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 	 * @param string $type type, default ''=not specified = text
546 546
 	 * @param string $options attributes for the tag, default ''=none
547 547
 	 */
548
-	static function input($name,$value='',$type='',$options='' )
548
+	static function input($name, $value = '', $type = '', $options = '')
549 549
 	{
550 550
 		switch ((string)$type)
551 551
 		{
@@ -572,12 +572,12 @@  discard block
 block discarded – undo
572 572
 		'cancelled' => '/no(&|\]|$)/',
573 573
 		'ok'     => '/ok(&|\]|$)/',
574 574
 		'close'  => '/close(&|\]|$)/',
575
-		'add'    => '/(add(&|\]|$)|create)/',	// customfields use create*
575
+		'add'    => '/(add(&|\]|$)|create)/', // customfields use create*
576 576
 	);
577 577
 
578 578
 	static protected $default_classes = array(
579
-		'et2_button_cancel'   => '/cancel(&|\]|$)/',	// yellow
580
-		'et2_button_question' => '/(yes|no)(&|\]|$)/',	// yellow
579
+		'et2_button_cancel'   => '/cancel(&|\]|$)/', // yellow
580
+		'et2_button_question' => '/(yes|no)(&|\]|$)/', // yellow
581 581
 		'et2_button_delete'   => '/delete(&|\]|$)/'		// red
582 582
 	);
583 583
 
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 	 * @param string $buttontype which type of html button (button|submit), default ='submit'
595 595
 	 * @return string html
596 596
 	 */
597
-	static function submit_button($name,$label,$onClick='',$no_lang=false,$options='',$image='',$app='phpgwapi', $buttontype='submit')
597
+	static function submit_button($name, $label, $onClick = '', $no_lang = false, $options = '', $image = '', $app = 'phpgwapi', $buttontype = 'submit')
598 598
 	{
599 599
 		// workaround for idots and IE button problem (wrong cursor-image)
600 600
 		if (Header\UserAgent::type() == 'msie')
@@ -606,11 +606,11 @@  discard block
 block discarded – undo
606 606
 
607 607
 		if ($image != '')
608 608
 		{
609
-			$image = str_replace(array('.gif','.GIF','.png','.PNG'),'',$image);
609
+			$image = str_replace(array('.gif', '.GIF', '.png', '.PNG'), '', $image);
610 610
 
611 611
 			if (!($path = Image::find($app, $image)))
612 612
 			{
613
-				$path = $image;		// name may already contain absolut path
613
+				$path = $image; // name may already contain absolut path
614 614
 			}
615 615
 			$image = ' src="'.$path.'"';
616 616
 			$classes[] = 'image_button';
@@ -619,11 +619,11 @@  discard block
 block discarded – undo
619 619
 		{
620 620
 			$label = lang($label);
621 621
 		}
622
-		if (($accesskey = @strstr($label,'&')) && $accesskey[1] != ' ' &&
623
-			(($pos = strpos($accesskey,';')) === false || $pos > 5))
622
+		if (($accesskey = @strstr($label, '&')) && $accesskey[1] != ' ' &&
623
+			(($pos = strpos($accesskey, ';')) === false || $pos > 5))
624 624
 		{
625
-			$label_u = str_replace('&'.$accesskey[1],'<u>'.$accesskey[1].'</u>',$label);
626
-			$label = str_replace('&','',$label);
625
+			$label_u = str_replace('&'.$accesskey[1], '<u>'.$accesskey[1].'</u>', $label);
626
+			$label = str_replace('&', '', $label);
627 627
 			$options .= ' accesskey="'.$accesskey[1].'" '.$options;
628 628
 		}
629 629
 		else
@@ -631,10 +631,10 @@  discard block
 block discarded – undo
631 631
 			$accesskey = '';
632 632
 			$label_u = $label;
633 633
 		}
634
-		if ($onClick) $options .= ' onclick="'.str_replace('"','\\"',$onClick).'"';
634
+		if ($onClick) $options .= ' onclick="'.str_replace('"', '\\"', $onClick).'"';
635 635
 
636 636
 		// add default background-image to get et2 like buttons
637
-		foreach(self::$default_background_images as $img => $reg_exp)
637
+		foreach (self::$default_background_images as $img => $reg_exp)
638 638
 		{
639 639
 			if (preg_match($reg_exp, $name) && ($url = Image::find($GLOBALS['egw_info']['flags']['currentapp'], $img)))
640 640
 			{
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 			}
645 645
 		}
646 646
 		// add default class for cancel, delete or yes/no buttons
647
-		foreach(self::$default_classes as $class => $reg_exp)
647
+		foreach (self::$default_classes as $class => $reg_exp)
648 648
 		{
649 649
 			if (preg_match($reg_exp, $name))
650 650
 			{
@@ -678,19 +678,19 @@  discard block
 block discarded – undo
678 678
 	 * @param array|string $vars query or array ('name' => 'value', ...) with query
679 679
 	 * @return string absolut link already run through $phpgw->link
680 680
 	 */
681
-	static function link($_url,$vars='')
681
+	static function link($_url, $vars = '')
682 682
 	{
683 683
 		if (!is_array($vars))
684 684
 		{
685
-			parse_str($vars,$vars);
685
+			parse_str($vars, $vars);
686 686
 		}
687
-		list($url,$v) = explode('?', $_url);	// url may contain additional vars
687
+		list($url, $v) = explode('?', $_url); // url may contain additional vars
688 688
 		if ($v)
689 689
 		{
690
-			parse_str($v,$v);
690
+			parse_str($v, $v);
691 691
 			$vars += $v;
692 692
 		}
693
-		return Framework::link($url,$vars);
693
+		return Framework::link($url, $vars);
694 694
 	}
695 695
 
696 696
 	/**
@@ -702,9 +702,9 @@  discard block
 block discarded – undo
702 702
 	 * @param string $options attributes for the tag, default ''=none
703 703
 	 * @return string html
704 704
 	 */
705
-	static function checkbox($name,$checked=false,$value='True',$options='')
705
+	static function checkbox($name, $checked = false, $value = 'True', $options = '')
706 706
 	{
707
-		return '<input type="checkbox" name="'.$name.'" value="'.self::htmlspecialchars($value).'"' .($checked ? ' checked="1"' : '') . "$options />\n";
707
+		return '<input type="checkbox" name="'.$name.'" value="'.self::htmlspecialchars($value).'"'.($checked ? ' checked="1"' : '')."$options />\n";
708 708
 	}
709 709
 
710 710
 	/**
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 	 * @param string $method method of the form, default 'POST'
720 720
 	 * @return string html
721 721
 	 */
722
-	static function form($content,$hidden_vars,$_url,$url_vars='',$name='',$options='',$method='POST')
722
+	static function form($content, $hidden_vars, $_url, $url_vars = '', $name = '', $options = '', $method = 'POST')
723 723
 	{
724 724
 		$url = $_url ? self::link($_url, $url_vars) : $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
725 725
 		$html = "<form method=\"$method\" ".($name != '' ? "name=\"$name\" " : '')."action=\"$url\" $options>\n";
@@ -746,9 +746,9 @@  discard block
 block discarded – undo
746 746
 	 * @param string $method method of the form, default 'POST'
747 747
 	 * @return string html
748 748
 	 */
749
-	static function form_1button($name,$label,$hidden_vars,$url,$url_vars='',$form_name='',$method='POST')
749
+	static function form_1button($name, $label, $hidden_vars, $url, $url_vars = '', $form_name = '', $method = 'POST')
750 750
 	{
751
-		return self::form(self::submit_button($name,$label),$hidden_vars,$url,$url_vars,$form_name,' style="display: inline-block"',$method);
751
+		return self::form(self::submit_button($name, $label), $hidden_vars, $url, $url_vars, $form_name, ' style="display: inline-block"', $method);
752 752
 	}
753 753
 
754 754
 	const THEAD = 1;
@@ -781,34 +781,34 @@  discard block
 block discarded – undo
781 781
 	 * @param boolean $no_table_tr dont return the table- and outmost tr-tabs, default false=return table+tr
782 782
 	 * @return string with html-code of the table
783 783
 	 */
784
-	static function table($rows,$options = '',$no_table_tr=False)
784
+	static function table($rows, $options = '', $no_table_tr = False)
785 785
 	{
786 786
 		$html = $no_table_tr ? '' : "<table $options>\n";
787 787
 
788 788
 		$part = 0;
789
-		foreach($rows as $key => $row)
789
+		foreach ($rows as $key => $row)
790 790
 		{
791 791
 			if (!is_array($row))
792 792
 			{
793
-				continue;					// parameter
793
+				continue; // parameter
794 794
 			}
795 795
 			// get the current part from the optional 'h' or 'f' prefix of the key
796 796
 			$p = $key[0] == 'h' ? self::THEAD : ($key[0] == 'f' ? self::TFOOT : self::TBODY);
797 797
 			if ($part < $p && ($part || $p < self::TBODY))	// add only allowed and neccessary transitions
798 798
 			{
799 799
 				if ($part) $html .= '</'.self::$part2tag[$part].">\n";
800
-				$html .= '<'.self::$part2tag[$part=$p].">\n";
800
+				$html .= '<'.self::$part2tag[$part = $p].">\n";
801 801
 			}
802 802
 			$html .= $no_table_tr && $key == 1 ? '' : "\t<tr ".$rows['.'.$key].">\n";
803 803
 
804
-			foreach($row as $key => $cell)
804
+			foreach ($row as $key => $cell)
805 805
 			{
806 806
 				if ($key[0] == '.')
807 807
 				{
808
-					continue;				// parameter
808
+					continue; // parameter
809 809
 				}
810
-				$table_pos = strpos($cell,'<table');
811
-				$td_pos = strpos($cell,'<td');
810
+				$table_pos = strpos($cell, '<table');
811
+				$td_pos = strpos($cell, '<td');
812 812
 				if ($td_pos !== False && ($table_pos === False || $td_pos < $table_pos))
813 813
 				{
814 814
 					$html .= $cell;
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
 
833 833
 		if ($no_table_tr)
834 834
 		{
835
-			$html = substr($html,0,-16);
835
+			$html = substr($html, 0, -16);
836 836
 		}
837 837
 		return $html;
838 838
 	}
@@ -844,12 +844,12 @@  discard block
 block discarded – undo
844 844
 	 * @param boolean $no_script if true generate a submit-button if javascript is off
845 845
 	 * @return string html
846 846
 	 */
847
-	static function sbox_submit( $sbox,$no_script=false )
847
+	static function sbox_submit($sbox, $no_script = false)
848 848
 	{
849
-		$html = str_replace('<select','<select onchange="this.form.submit()" ',$sbox);
849
+		$html = str_replace('<select', '<select onchange="this.form.submit()" ', $sbox);
850 850
 		if ($no_script)
851 851
 		{
852
-			$html .= '<noscript>'.self::submit_button('send','>').'</noscript>';
852
+			$html .= '<noscript>'.self::submit_button('send', '>').'</noscript>';
853 853
 		}
854 854
 		return $html;
855 855
 	}
@@ -865,17 +865,17 @@  discard block
 block discarded – undo
865 865
 	 * @param string $height height, default 5px
866 866
 	 * @return string html
867 867
 	 */
868
-	static function progressbar($_percent, $_title='',$options='',$width='',$color='',$height='' )
868
+	static function progressbar($_percent, $_title = '', $options = '', $width = '', $color = '', $height = '')
869 869
 	{
870 870
 		$percent = (int)$_percent;
871 871
 		if (!$width) $width = '30px';
872
-		if (!$height)$height= '5px';
872
+		if (!$height)$height = '5px';
873 873
 		if (!$color) $color = '#D00000';
874 874
 		$title = $_title ? self::htmlspecialchars($_title) : $percent.'%';
875 875
 
876 876
 		return '<div class="onlyPrint">'.$title.'</div><div class="noPrint" title="'.$title.'" '.$options.
877 877
 			' style="height: '.$height.'; width: '.$width.'; border: 1px solid black; padding: 1px; text-align: left;'.
878
-			(@stristr($options,'onclick="') ? ' cursor: pointer;' : '').'">'."\n\t".
878
+			(@stristr($options, 'onclick="') ? ' cursor: pointer;' : '').'">'."\n\t".
879 879
 			'<div style="height: '.$height.'; width: '.$percent.'%; background: '.$color.';"></div>'."\n</div>\n";
880 880
 	}
881 881
 
@@ -893,32 +893,32 @@  discard block
 block discarded – undo
893 893
 	 * @param string $options further options for the tag, default '' = none
894 894
 	 * @return string the html
895 895
 	 */
896
-	static function image( $app,$name,$title='',$options='' )
896
+	static function image($app, $name, $title = '', $options = '')
897 897
 	{
898 898
 		if (is_array($name))	// menuaction and other get-vars
899 899
 		{
900
-			$name = $GLOBALS['egw']->link('/index.php',$name);
900
+			$name = $GLOBALS['egw']->link('/index.php', $name);
901 901
 		}
902
-		if (substr($name,0,5) == 'vfs:/')	// vfs pseudo protocoll
902
+		if (substr($name, 0, 5) == 'vfs:/')	// vfs pseudo protocoll
903 903
 		{
904
-			$name = Framework::link(Vfs::download_url(substr($name,4)));
904
+			$name = Framework::link(Vfs::download_url(substr($name, 4)));
905 905
 		}
906
-		if ($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://' || stripos($name,'api/thumbnail.php') )
906
+		if ($name[0] == '/' || substr($name, 0, 7) == 'http://' || substr($name, 0, 8) == 'https://' || stripos($name, 'api/thumbnail.php'))
907 907
 		{
908
-			if (!($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://')) $name = '/'.$name;
908
+			if (!($name[0] == '/' || substr($name, 0, 7) == 'http://' || substr($name, 0, 8) == 'https://')) $name = '/'.$name;
909 909
 			$url = $name;
910 910
 		}
911 911
 		else	// no URL, so try searching the image
912 912
 		{
913
-			$name = str_replace(array('.gif','.GIF','.png','.PNG'),'',$name);
913
+			$name = str_replace(array('.gif', '.GIF', '.png', '.PNG'), '', $name);
914 914
 
915
-			if (!($url = Image::find($app,$name)))
915
+			if (!($url = Image::find($app, $name)))
916 916
 			{
917
-				$url = $name;		// name may already contain absolut path
917
+				$url = $name; // name may already contain absolut path
918 918
 			}
919
-			if($GLOBALS['egw_info']['server']['webserver_url'])
919
+			if ($GLOBALS['egw_info']['server']['webserver_url'])
920 920
 			{
921
-				list(,$path) = explode($GLOBALS['egw_info']['server']['webserver_url'],$url);
921
+				list(,$path) = explode($GLOBALS['egw_info']['server']['webserver_url'], $url);
922 922
 
923 923
 				if (!is_null($path)) $path = EGW_SERVER_ROOT.$path;
924 924
 			}
@@ -927,12 +927,12 @@  discard block
 block discarded – undo
927 927
 				$path = EGW_SERVER_ROOT.$url;
928 928
 			}
929 929
 
930
-			if (is_null($path) || (!@is_readable($path) && stripos($path,'webdav.php')===false))
930
+			if (is_null($path) || (!@is_readable($path) && stripos($path, 'webdav.php') === false))
931 931
 			{
932 932
 				// if the image-name is a percentage, use a progressbar
933
-				if (substr($name,-1) == '%' && is_numeric($percent = substr($name,0,-1)))
933
+				if (substr($name, -1) == '%' && is_numeric($percent = substr($name, 0, -1)))
934 934
 				{
935
-					return self::progressbar($percent,$title);
935
+					return self::progressbar($percent, $title);
936 936
 				}
937 937
 				return $title;
938 938
 			}
@@ -943,12 +943,12 @@  discard block
 block discarded – undo
943 943
 		}
944 944
 
945 945
 		// This block makes pngfix.js useless, adding a check on disable_pngfix to have pngfix.js do its thing
946
-		if (Header\UserAgent::type() == 'msie' && Header\UserAgent::version() < 7.0 && substr($url,-4) == '.png' && ($GLOBALS['egw_info']['user']['preferences']['common']['disable_pngfix'] || !isset($GLOBALS['egw_info']['user']['preferences']['common']['disable_pngfix'])))
946
+		if (Header\UserAgent::type() == 'msie' && Header\UserAgent::version() < 7.0 && substr($url, -4) == '.png' && ($GLOBALS['egw_info']['user']['preferences']['common']['disable_pngfix'] || !isset($GLOBALS['egw_info']['user']['preferences']['common']['disable_pngfix'])))
947 947
 		{
948 948
 			$extra_styles = "display: inline-block; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='$url',sizingMethod='image'); width: 1px; height: 1px;";
949
-			if (false!==strpos($options,'style="'))
949
+			if (false !== strpos($options, 'style="'))
950 950
 			{
951
-				$options = str_replace('style="','style="'.$extra_styles, $options);
951
+				$options = str_replace('style="', 'style="'.$extra_styles, $options);
952 952
 			}
953 953
 			else
954 954
 			{
@@ -968,24 +968,24 @@  discard block
 block discarded – undo
968 968
 	 * @param string $options attributes for the tag, default ''=none
969 969
 	 * @return string the html
970 970
 	 */
971
-	static function a_href( $content,$url,$vars='',$options='')
971
+	static function a_href($content, $url, $vars = '', $options = '')
972 972
 	{
973 973
 		if (is_array($url))
974 974
 		{
975 975
 			$vars = $url;
976 976
 			$url = '/index.php';
977 977
 		}
978
-		elseif (strpos($url,'/')===false &&
979
-			count(explode('.',$url)) >= 3 &&
980
-			!(strpos($url,'mailto:')!==false ||
981
-			strpos($url,'://')!==false ||
982
-			strpos($url,'javascript:')!==false))
978
+		elseif (strpos($url, '/') === false &&
979
+			count(explode('.', $url)) >= 3 &&
980
+			!(strpos($url, 'mailto:') !== false ||
981
+			strpos($url, '://') !== false ||
982
+			strpos($url, 'javascript:') !== false))
983 983
 		{
984 984
 			$url = "/index.php?menuaction=$url";
985 985
 		}
986 986
 		if ($url[0] == '/')		// link relative to eGW
987 987
 		{
988
-			$url = self::link($url,$vars);
988
+			$url = self::link($url, $vars);
989 989
 		}
990 990
 		//echo "<p>self::a_href('".self::htmlspecialchars($content)."','$url',".print_r($vars,True).") = ".self::link($url,$vars)."</p>";
991 991
 		return '<a href="'.self::htmlspecialchars($url).'" '.$options.'>'.$content.'</a>';
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
 	 */
1000 1000
 	static function bold($content)
1001 1001
 	{
1002
-		return '<b>'.($content?$content.'</b>':'');
1002
+		return '<b>'.($content ? $content.'</b>' : '');
1003 1003
 	}
1004 1004
 
1005 1005
 	/**
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
 	 * @param string $options attributes for the tag, default ''=none
1010 1010
 	 * @return string the html
1011 1011
 	 */
1012
-	static function hr($width='',$options='')
1012
+	static function hr($width = '', $options = '')
1013 1013
 	{
1014 1014
 		if ($width) $options .= " width=\"$width\"";
1015 1015
 
@@ -1025,12 +1025,12 @@  discard block
 block discarded – undo
1025 1025
 	 * @param mixed $names String (or Array) with the option-names eg. 'WIDTH,HEIGHT,BORDER'
1026 1026
 	 * @return string with options/attributes
1027 1027
 	 */
1028
-	static function formatOptions($options,$names)
1028
+	static function formatOptions($options, $names)
1029 1029
 	{
1030
-		if (!is_array($options)) $options = explode(',',$options);
1031
-		if (!is_array($names))   $names   = explode(',',$names);
1030
+		if (!is_array($options)) $options = explode(',', $options);
1031
+		if (!is_array($names))   $names   = explode(',', $names);
1032 1032
 
1033
-		foreach($options as $n => $val)
1033
+		foreach ($options as $n => $val)
1034 1034
 		{
1035 1035
 			if ($val != '' && $names[$n] != '')
1036 1036
 			{
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
 	 * @param string $options attributes for the tag, default ''=none
1061 1061
 	 * @return string the html
1062 1062
 	 */
1063
-	static function label($content,$id='',$accesskey='',$options='')
1063
+	static function label($content, $id = '', $accesskey = '', $options = '')
1064 1064
 	{
1065 1065
 		if ($id != '')
1066 1066
 		{
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
 	 * @param string $options attributes for the tag, default ''=none
1082 1082
 	 * @return string the html
1083 1083
 	 */
1084
-	static function fieldset($content,$legend='',$options='')
1084
+	static function fieldset($content, $legend = '', $options = '')
1085 1085
 	{
1086 1086
 		$html = "<fieldset $options>".($legend ? '<legend>'.self::htmlspecialchars($legend).'</legend>' : '')."\n";
1087 1087
 
@@ -1115,9 +1115,9 @@  discard block
 block discarded – undo
1115 1115
 	 *
1116 1116
 	 * @return string the html code, to be added into the template
1117 1117
 	 */
1118
-	static function tree($_folders,$_selected,$_topFolder=false,$_onNodeSelect="null",$tree='foldertree',$_divClass='',
1119
-		$_leafImage='',$_onCheckHandler=false,$delimiter='/',$folderImageDir=null,$autoLoading=null,$dataMode='JSON',
1120
-		$dragndrop=false)
1118
+	static function tree($_folders, $_selected, $_topFolder = false, $_onNodeSelect = "null", $tree = 'foldertree', $_divClass = '',
1119
+		$_leafImage = '', $_onCheckHandler = false, $delimiter = '/', $folderImageDir = null, $autoLoading = null, $dataMode = 'JSON',
1120
+		$dragndrop = false)
1121 1121
 	{
1122 1122
 		$webserver_url = $GLOBALS['egw_info']['server']['webserver_url'];
1123 1123
 		if (empty($folderImageDir))
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
 			//error_log(__METHOD__."() setting templated image-path: $folderImageDir");
1141 1141
 		}
1142 1142
 
1143
-		static $tree_initialised=false;
1143
+		static $tree_initialised = false;
1144 1144
 		if (!$tree_initialised)
1145 1145
 		{
1146 1146
 			Framework::includeCSS('/api/js/dhtmlxtree/codebase/dhtmlxtree.css');
@@ -1150,16 +1150,16 @@  discard block
 block discarded – undo
1150 1150
 			$tree_initialised = true;
1151 1151
 			if (!$_folders && !$autoLoading) return null;
1152 1152
 		}
1153
-		$html = self::div("\n",'id="'.$tree.'"',$_divClass).$html;
1153
+		$html = self::div("\n", 'id="'.$tree.'"', $_divClass).$html;
1154 1154
 		$html .= "<script type='text/javascript'>\n";
1155 1155
 		$html .= "var $tree;";
1156 1156
 		$html .= "egw_LAB.wait(function() {";
1157 1157
 		$html .= "$tree = new"." dhtmlXTreeObject('$tree','100%','100%',0);\n";
1158
-		$html .= "$tree.parentObject.style.overflow='auto';\n";	// dhtmlXTree constructor has hidden hardcoded
1158
+		$html .= "$tree.parentObject.style.overflow='auto';\n"; // dhtmlXTree constructor has hidden hardcoded
1159 1159
 		if (Translation::charset() == 'utf-8') $html .= "if ($tree.setEscapingMode) $tree.setEscapingMode('utf8');\n";
1160 1160
 		$html .= "$tree.setImagePath('$folderImageDir/dhtmlxtree/');\n";
1161 1161
 
1162
-		if($_onCheckHandler)
1162
+		if ($_onCheckHandler)
1163 1163
 		{
1164 1164
 			$html .= "$tree.enableCheckBoxes(1);\n";
1165 1165
 			$html .= "$tree.setOnCheckHandler('$_onCheckHandler');\n";
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
 		if ($autoLoading)
1171 1171
 		{
1172 1172
 			$autoLoading = is_array($autoLoading) ?
1173
-				Framework::link('/index.php',$autoLoading) : Framework::link($autoLoading);
1173
+				Framework::link('/index.php', $autoLoading) : Framework::link($autoLoading);
1174 1174
 			$html .= "$tree.setXMLAutoLoading('$autoLoading');\n";
1175 1175
 			if ($dataMode != 'XML') $html .= "$tree.setDataMode('$dataMode');\n";
1176 1176
 
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 		}
1212 1212
 		if (is_string($_folders))
1213 1213
 		{
1214
-			switch($dataMode)
1214
+			switch ($dataMode)
1215 1215
 			{
1216 1216
 				case 'JSON':
1217 1217
 					$html .= "$tree.loadJSONObject($_folders);\n"; break;
@@ -1222,10 +1222,10 @@  discard block
 block discarded – undo
1222 1222
 		else
1223 1223
 		{
1224 1224
 			// evtl. remove leading delimiter
1225
-			if ($_selected[0] == $delimiter) $_selected = substr($_selected,1);
1225
+			if ($_selected[0] == $delimiter) $_selected = substr($_selected, 1);
1226 1226
 
1227 1227
 			$n = 0;
1228
-			foreach($_folders as $path => $data)
1228
+			foreach ($_folders as $path => $data)
1229 1229
 			{
1230 1230
 				if (!is_array($data))
1231 1231
 				{
@@ -1237,10 +1237,10 @@  discard block
 block discarded – undo
1237 1237
 				if ($_leafImage)
1238 1238
 				{
1239 1239
 					$image1 = $image2 = $image3 = "'".$_leafImage."'";
1240
-					if (($next_item = array_slice($_folders, $n+1, 1, true)))
1240
+					if (($next_item = array_slice($_folders, $n + 1, 1, true)))
1241 1241
 					{
1242 1242
 						list($next_path) = each($next_item);
1243
-						if (substr($next_path,0,strlen($path)+1) == $path.'/')
1243
+						if (substr($next_path, 0, strlen($path) + 1) == $path.'/')
1244 1244
 						{
1245 1245
 							$image1 = $image2 = $image3 = '0';
1246 1246
 						}
@@ -1251,22 +1251,22 @@  discard block
 block discarded – undo
1251 1251
 					$image1 = $image2 = $image3 = "'".$data['image']."'";
1252 1252
 				}
1253 1253
 				// evtl. remove leading delimiter
1254
-				if ($path[0] == $delimiter) $path = substr($path,1);
1255
-				$folderParts = explode($delimiter,$path);
1254
+				if ($path[0] == $delimiter) $path = substr($path, 1);
1255
+				$folderParts = explode($delimiter, $path);
1256 1256
 
1257 1257
 				//get rightmost folderpart
1258 1258
 				$label = array_pop($folderParts);
1259 1259
 				if (isset($data['label'])) $label = $data['label'];
1260 1260
 
1261 1261
 				// the rest of the array is the name of the parent
1262
-				$parentName = implode((array)$folderParts,$delimiter);
1263
-				if(empty($parentName)) $parentName = $top;
1262
+				$parentName = implode((array)$folderParts, $delimiter);
1263
+				if (empty($parentName)) $parentName = $top;
1264 1264
 
1265 1265
 				$entryOptions = !isset($data['child']) || $data['child'] ? 'CHILD' : '';
1266 1266
 				if ($_onCheckHandler && $_selected)	// check selected items on multi selection
1267 1267
 				{
1268
-					if (!is_array($_selected)) $_selected = explode(',',$_selected);
1269
-					if (array_search("$path",$_selected)!==false) $entryOptions .= ',CHECKED';
1268
+					if (!is_array($_selected)) $_selected = explode(',', $_selected);
1269
+					if (array_search("$path", $_selected) !== false) $entryOptions .= ',CHECKED';
1270 1270
 					//echo "<p>path=$path, _selected=".print_r($_selected,true).": $entryOptions</p>\n";
1271 1271
 				}
1272 1272
 				// highlight current item
@@ -1286,7 +1286,7 @@  discard block
 block discarded – undo
1286 1286
 		$html .= "$tree.closeAllItems(0);\n";
1287 1287
 		if ($_selected)
1288 1288
 		{
1289
-			foreach(is_array($_selected)?$_selected:array($_selected) as $path)
1289
+			foreach (is_array($_selected) ? $_selected : array($_selected) as $path)
1290 1290
 			{
1291 1291
 				$html .= "$tree.openItem('".addslashes($path)."');\n";
1292 1292
 			}
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
 	 *		or to restrict the attribute's values
1312 1312
 	 * @param boolean $_force =null - force the config passed to be used without merging to the default
1313 1313
 	 */
1314
-	static function purify($html,$config=null,$spec=array(),$_force=false)
1314
+	static function purify($html, $config = null, $spec = array(), $_force = false)
1315 1315
 	{
1316 1316
 		return Html\HtmLawed::purify($html, $config, $spec, $_force);
1317 1317
 	}
Please login to merge, or discard this patch.
Braces   +183 added lines, -47 removed lines patch added patch discarded remove patch
@@ -34,7 +34,11 @@  discard block
 block discarded – undo
34 34
 	 */
35 35
 	static function activate_links($content)
36 36
 	{
37
-		if (!$content || strlen($content) < 20) return $content;	// performance
37
+		if (!$content || strlen($content) < 20)
38
+		{
39
+			return $content;
40
+		}
41
+		// performance
38 42
 
39 43
 		// Exclude everything which is already a link
40 44
 		$NotAnchor = '(?<!"|href=|href\s=\s|href=\s|href\s=)';
@@ -57,10 +61,14 @@  discard block
 block discarded – undo
57 61
 			return $match[1]."<a href=\"".($match[2]&&!$match[3]?$match[2]:'').($match[3]?$match[3]:'').$match[4].$match[5]."\" target=\"_blank\">".$match[4].$match[5]."</a>".$match[6];
58 62
 		}, $result);
59 63
 
60
-		if (true)	// hack to keep IDE from complaing about double assignments
64
+		if (true)
65
+		{
66
+			// hack to keep IDE from complaing about double assignments
61 67
 		{
62 68
 			//  First match things beginning with http:// (or other protocols)
63
-			$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))';	// only http:// gets removed, other protocolls are shown
69
+			$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))';
70
+		}
71
+		// only http:// gets removed, other protocolls are shown
64 72
 			$Domain = '([\w-]+\.[\w-.]+)';
65 73
 			$Subdir = '([\w\-\.,@?^=%&;:\/~\+#]*[\w\-\@?^=%&\/~\+#])?';
66 74
 			$optStuff = '(&quot;|&quot|;)?';
@@ -98,7 +106,8 @@  discard block
 block discarded – undo
98 106
 			$Expr = '/' .$optBracket0. $NotAnchor . $NotHTTP . $Domain2 . $Subdir2 .$optBracket. '/i';
99 107
 			//$Expr = '/' . $NotAnchor . $NotHTTP . $Domain . $Subdir . $optBracket . '/i';
100 108
 			// use preg_replace_callback as we experienced problems with links such as <www.example.tld/pfad/zu/einer/pdf-Datei.pdf>
101
-			$result4 = preg_replace_callback( $Expr, function ($match) {
109
+			$result4 = preg_replace_callback( $Expr, function ($match)
110
+			{
102 111
 					//error_log(__METHOD__.__LINE__.array2string($match));
103 112
 					if ($match[4]==';' && (strlen($match[3])-4) >=0 && strpos($match[3],'&gt',strlen($match[3])-4)!==false)
104 113
 					{
@@ -148,7 +157,11 @@  discard block
 block discarded – undo
148 157
 	 */
149 158
 	static function select($name, $key, $arr=0,$no_lang=false,$options='',$multiple=0,$enhanced=null)
150 159
 	{
151
-		if(is_null($enhanced)) $enhanced = false;	//disabled by default (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
160
+		if(is_null($enhanced))
161
+		{
162
+			$enhanced = false;
163
+		}
164
+		//disabled by default (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
152 165
 
153 166
 		if (!is_array($arr))
154 167
 		{
@@ -211,7 +224,8 @@  discard block
 block discarded – undo
211 224
 		}
212 225
 		$out .= "</select>\n";
213 226
 
214
-		if($enhanced) {
227
+		if($enhanced)
228
+		{
215 229
 			Framework::includeJS('/api/js/jquery/chosen/chosen.jquery.js');
216 230
 			Framework::includeCSS('/api/js/jquery/chosen/chosen.css',null,false);
217 231
 			$out .= "<script>var lab = egw_LAB || \$LAB; lab.wait(function() {jQuery(function() {if(jQuery().chosen) jQuery('select[name=\"$name\"]').chosen({width: '100%'});});})</script>\n";
@@ -238,13 +252,19 @@  discard block
 block discarded – undo
238 252
 	static function checkbox_multiselect($name, $key, $arr=0,$no_lang=false,$options='',$multiple=3,$selected_first=true,$style='',$enhanced = null)
239 253
 	{
240 254
 		//echo "<p align=right>checkbox_multiselect('$name',".array2string($key).",".array2string($arr).",$no_lang,'$options',$multiple,$selected_first,'$style')</p>\n";
241
-		if(is_null($enhanced)) $enhanced = (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
255
+		if(is_null($enhanced))
256
+		{
257
+			$enhanced = (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
258
+		}
242 259
 
243 260
 		if (!is_array($arr))
244 261
 		{
245 262
 			$arr = array('no','yes');
246 263
 		}
247
-		if ((int)$multiple <= 0) $multiple = 1;
264
+		if ((int)$multiple <= 0)
265
+		{
266
+			$multiple = 1;
267
+		}
248 268
 
249 269
 		if (substr($name,-2) != '[]')
250 270
 		{
@@ -252,7 +272,10 @@  discard block
 block discarded – undo
252 272
 		}
253 273
 		$base_name = substr($name,0,-2);
254 274
 
255
-		if($enhanced) return self::select($name, $key, $arr,$no_lang,$options." style=\"$style\" ",$multiple,$enhanced);
275
+		if($enhanced)
276
+		{
277
+			return self::select($name, $key, $arr,$no_lang,$options." style=\"$style\" ",$multiple,$enhanced);
278
+		}
256 279
 
257 280
 		if (!is_array($key))
258 281
 		{
@@ -290,18 +313,36 @@  discard block
 block discarded – undo
290 313
 			{
291 314
 				$title = '';
292 315
 			}
293
-			if ($label && !$no_lang) $label = lang($label);
294
-			if ($title && !$no_lang) $title = lang($title);
316
+			if ($label && !$no_lang)
317
+			{
318
+				$label = lang($label);
319
+			}
320
+			if ($title && !$no_lang)
321
+			{
322
+				$title = lang($title);
323
+			}
295 324
 
296
-			if (strlen($label) > $max_len) $max_len = strlen($label);
325
+			if (strlen($label) > $max_len)
326
+			{
327
+				$max_len = strlen($label);
328
+			}
297 329
 
298 330
 			$html .= self::label(self::checkbox($name,in_array((string)$val,$key),$val,$options_no_id.
299 331
 				' id="'.$base_name.'['.$val.']'.'"').self::htmlspecialchars($label),
300 332
 				$base_name.'['.$val.']','',($title ? 'title="'.self::htmlspecialchars($title).'" ':''))."<br />\n";
301 333
 		}
302
-		if ($style && substr($style,-1) != ';') $style .= '; ';
303
-		if (strpos($style,'height')===false) $style .= 'height: '.(1.7*$multiple).'em; ';
304
-		if (strpos($style,'width')===false)  $style .= 'width: '.(4+$max_len*($max_len < 15 ? 0.65 : 0.6)).'em; ';
334
+		if ($style && substr($style,-1) != ';')
335
+		{
336
+			$style .= '; ';
337
+		}
338
+		if (strpos($style,'height')===false)
339
+		{
340
+			$style .= 'height: '.(1.7*$multiple).'em; ';
341
+		}
342
+		if (strpos($style,'width')===false)
343
+		{
344
+			$style .= 'width: '.(4+$max_len*($max_len < 15 ? 0.65 : 0.6)).'em; ';
345
+		}
305 346
 		$style .= 'background-color: white; overflow: auto; border: lightgray 2px inset; text-align: left;';
306 347
 
307 348
 		return self::div($html,$options,'',$style);
@@ -326,7 +367,10 @@  discard block
 block discarded – undo
326 367
 			$found = false;
327 368
 			foreach($selected as $sel)
328 369
 			{
329
-				if (($found = (((string) $value) === ((string) $selected[$key])))) break;
370
+				if (($found = (((string) $value) === ((string) $selected[$key]))))
371
+				{
372
+					break;
373
+				}
330 374
 			}
331 375
 			unset($sel);
332 376
 		}
@@ -347,8 +391,14 @@  discard block
 block discarded – undo
347 391
 	 */
348 392
 	static function div($content,$options='',$class='',$style='')
349 393
 	{
350
-		if ($class) $options .= ' class="'.$class.'"';
351
-		if ($style) $options .= ' style="'.$style.'"';
394
+		if ($class)
395
+		{
396
+			$options .= ' class="'.$class.'"';
397
+		}
398
+		if ($style)
399
+		{
400
+			$options .= ' style="'.$style.'"';
401
+		}
352 402
 
353 403
 		return "<div $options>\n".($content ? "$content</div>\n" : '');
354 404
 	}
@@ -373,10 +423,13 @@  discard block
 block discarded – undo
373 423
 			{
374 424
 				$value = json_encode($value);
375 425
 			}
376
-			if (!$ignore_empty || $value && !($name == 'filter' && $value == 'none'))	// dont need to send all the empty vars
426
+			if (!$ignore_empty || $value && !($name == 'filter' && $value == 'none'))
427
+			{
428
+				// dont need to send all the empty vars
377 429
 			{
378 430
 				$html .= "<input type=\"hidden\" name=\"$name\" value=\"".self::htmlspecialchars($value)."\" />\n";
379 431
 			}
432
+			}
380 433
 		}
381 434
 		return $html;
382 435
 	}
@@ -452,7 +505,9 @@  discard block
 block discarded – undo
452 505
 
453 506
 		// run content through htmlpurifier
454 507
 		if ($_purify && !empty($_content))
455
-			$_content = self::purify($_content);
508
+		{
509
+					$_content = self::purify($_content);
510
+		}
456 511
 
457 512
 		// By default the editor start expanded
458 513
 		$expanded = isset($_options['toolbar_expanded']) ?
@@ -466,7 +521,10 @@  discard block
 block discarded – undo
466 521
 		$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
467 522
 		$font_size = Html\CkEditorConfig::font_size_from_prefs();
468 523
 		$font_span = '<span '.($font||$font_size?'style=\"':'').($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'\">';
469
-		if (empty($font) && empty($font_size)) $font_span = '';
524
+		if (empty($font) && empty($font_size))
525
+		{
526
+			$font_span = '';
527
+		}
470 528
 
471 529
 		// we need to enable double encoding here, as ckEditor has to undo one level of encoding
472 530
 		// otherwise < and > chars eg. from html markup entered in regular (not source) input, will turn into html!
@@ -631,7 +689,10 @@  discard block
 block discarded – undo
631 689
 			$accesskey = '';
632 690
 			$label_u = $label;
633 691
 		}
634
-		if ($onClick) $options .= ' onclick="'.str_replace('"','\\"',$onClick).'"';
692
+		if ($onClick)
693
+		{
694
+			$options .= ' onclick="'.str_replace('"','\\"',$onClick).'"';
695
+		}
635 696
 
636 697
 		// add default background-image to get et2 like buttons
637 698
 		foreach(self::$default_background_images as $img => $reg_exp)
@@ -794,9 +855,12 @@  discard block
 block discarded – undo
794 855
 			}
795 856
 			// get the current part from the optional 'h' or 'f' prefix of the key
796 857
 			$p = $key[0] == 'h' ? self::THEAD : ($key[0] == 'f' ? self::TFOOT : self::TBODY);
797
-			if ($part < $p && ($part || $p < self::TBODY))	// add only allowed and neccessary transitions
858
+			if ($part < $p && ($part || $p < self::TBODY))
859
+			{
860
+				// add only allowed and neccessary transitions
798 861
 			{
799 862
 				if ($part) $html .= '</'.self::$part2tag[$part].">\n";
863
+			}
800 864
 				$html .= '<'.self::$part2tag[$part=$p].">\n";
801 865
 			}
802 866
 			$html .= $no_table_tr && $key == 1 ? '' : "\t<tr ".$rows['.'.$key].">\n";
@@ -824,10 +888,13 @@  discard block
 block discarded – undo
824 888
 		{
825 889
 			echo "<p>".function_backtrace()."</p>\n";
826 890
 		}
827
-		if ($part)	// close current part
891
+		if ($part)
892
+		{
893
+			// close current part
828 894
 		{
829 895
 			$html .= "</".self::$part2tag[$part].">\n";
830 896
 		}
897
+		}
831 898
 		$html .= "</table>\n";
832 899
 
833 900
 		if ($no_table_tr)
@@ -868,9 +935,18 @@  discard block
 block discarded – undo
868 935
 	static function progressbar($_percent, $_title='',$options='',$width='',$color='',$height='' )
869 936
 	{
870 937
 		$percent = (int)$_percent;
871
-		if (!$width) $width = '30px';
872
-		if (!$height)$height= '5px';
873
-		if (!$color) $color = '#D00000';
938
+		if (!$width)
939
+		{
940
+			$width = '30px';
941
+		}
942
+		if (!$height)
943
+		{
944
+			$height= '5px';
945
+		}
946
+		if (!$color)
947
+		{
948
+			$color = '#D00000';
949
+		}
874 950
 		$title = $_title ? self::htmlspecialchars($_title) : $percent.'%';
875 951
 
876 952
 		return '<div class="onlyPrint">'.$title.'</div><div class="noPrint" title="'.$title.'" '.$options.
@@ -895,17 +971,26 @@  discard block
 block discarded – undo
895 971
 	 */
896 972
 	static function image( $app,$name,$title='',$options='' )
897 973
 	{
898
-		if (is_array($name))	// menuaction and other get-vars
974
+		if (is_array($name))
975
+		{
976
+			// menuaction and other get-vars
899 977
 		{
900 978
 			$name = $GLOBALS['egw']->link('/index.php',$name);
901 979
 		}
902
-		if (substr($name,0,5) == 'vfs:/')	// vfs pseudo protocoll
980
+		}
981
+		if (substr($name,0,5) == 'vfs:/')
982
+		{
983
+			// vfs pseudo protocoll
903 984
 		{
904 985
 			$name = Framework::link(Vfs::download_url(substr($name,4)));
905 986
 		}
987
+		}
906 988
 		if ($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://' || stripos($name,'api/thumbnail.php') )
907 989
 		{
908
-			if (!($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://')) $name = '/'.$name;
990
+			if (!($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://'))
991
+			{
992
+				$name = '/'.$name;
993
+			}
909 994
 			$url = $name;
910 995
 		}
911 996
 		else	// no URL, so try searching the image
@@ -920,7 +1005,10 @@  discard block
 block discarded – undo
920 1005
 			{
921 1006
 				list(,$path) = explode($GLOBALS['egw_info']['server']['webserver_url'],$url);
922 1007
 
923
-				if (!is_null($path)) $path = EGW_SERVER_ROOT.$path;
1008
+				if (!is_null($path))
1009
+				{
1010
+					$path = EGW_SERVER_ROOT.$path;
1011
+				}
924 1012
 			}
925 1013
 			else
926 1014
 			{
@@ -983,10 +1071,13 @@  discard block
 block discarded – undo
983 1071
 		{
984 1072
 			$url = "/index.php?menuaction=$url";
985 1073
 		}
986
-		if ($url[0] == '/')		// link relative to eGW
1074
+		if ($url[0] == '/')
1075
+		{
1076
+			// link relative to eGW
987 1077
 		{
988 1078
 			$url = self::link($url,$vars);
989 1079
 		}
1080
+		}
990 1081
 		//echo "<p>self::a_href('".self::htmlspecialchars($content)."','$url',".print_r($vars,True).") = ".self::link($url,$vars)."</p>";
991 1082
 		return '<a href="'.self::htmlspecialchars($url).'" '.$options.'>'.$content.'</a>';
992 1083
 	}
@@ -1011,7 +1102,10 @@  discard block
 block discarded – undo
1011 1102
 	 */
1012 1103
 	static function hr($width='',$options='')
1013 1104
 	{
1014
-		if ($width) $options .= " width=\"$width\"";
1105
+		if ($width)
1106
+		{
1107
+			$options .= " width=\"$width\"";
1108
+		}
1015 1109
 
1016 1110
 		return "<hr $options />\n";
1017 1111
 	}
@@ -1027,8 +1121,14 @@  discard block
 block discarded – undo
1027 1121
 	 */
1028 1122
 	static function formatOptions($options,$names)
1029 1123
 	{
1030
-		if (!is_array($options)) $options = explode(',',$options);
1031
-		if (!is_array($names))   $names   = explode(',',$names);
1124
+		if (!is_array($options))
1125
+		{
1126
+			$options = explode(',',$options);
1127
+		}
1128
+		if (!is_array($names))
1129
+		{
1130
+			$names   = explode(',',$names);
1131
+		}
1032 1132
 
1033 1133
 		foreach($options as $n => $val)
1034 1134
 		{
@@ -1146,9 +1246,15 @@  discard block
 block discarded – undo
1146 1246
 			Framework::includeCSS('/api/js/dhtmlxtree/codebase/dhtmlxtree.css');
1147 1247
 			Framework::includeJS('/api/js/dhtmlxtree/codebase/dhtmlxcommon.js');
1148 1248
 			Framework::includeJS('/api/js/dhtmlxtree/sources/dhtmlxtree.js');
1149
-			if ($autoLoading && $dataMode != 'XML') Framework::includeJS('/api/js/dhtmlxtree/sources/ext/dhtmlxtree_json.js');
1249
+			if ($autoLoading && $dataMode != 'XML')
1250
+			{
1251
+				Framework::includeJS('/api/js/dhtmlxtree/sources/ext/dhtmlxtree_json.js');
1252
+			}
1150 1253
 			$tree_initialised = true;
1151
-			if (!$_folders && !$autoLoading) return null;
1254
+			if (!$_folders && !$autoLoading)
1255
+			{
1256
+				return null;
1257
+			}
1152 1258
 		}
1153 1259
 		$html = self::div("\n",'id="'.$tree.'"',$_divClass).$html;
1154 1260
 		$html .= "<script type='text/javascript'>\n";
@@ -1156,7 +1262,10 @@  discard block
 block discarded – undo
1156 1262
 		$html .= "egw_LAB.wait(function() {";
1157 1263
 		$html .= "$tree = new"." dhtmlXTreeObject('$tree','100%','100%',0);\n";
1158 1264
 		$html .= "$tree.parentObject.style.overflow='auto';\n";	// dhtmlXTree constructor has hidden hardcoded
1159
-		if (Translation::charset() == 'utf-8') $html .= "if ($tree.setEscapingMode) $tree.setEscapingMode('utf8');\n";
1265
+		if (Translation::charset() == 'utf-8')
1266
+		{
1267
+			$html .= "if ($tree.setEscapingMode) $tree.setEscapingMode('utf8');\n";
1268
+		}
1160 1269
 		$html .= "$tree.setImagePath('$folderImageDir/dhtmlxtree/');\n";
1161 1270
 
1162 1271
 		if($_onCheckHandler)
@@ -1165,19 +1274,28 @@  discard block
 block discarded – undo
1165 1274
 			$html .= "$tree.setOnCheckHandler('$_onCheckHandler');\n";
1166 1275
 		}
1167 1276
 
1168
-		if ($dragndrop) $html .= "$tree.enableDragAndDrop(true);\n";
1277
+		if ($dragndrop)
1278
+		{
1279
+			$html .= "$tree.enableDragAndDrop(true);\n";
1280
+		}
1169 1281
 
1170 1282
 		if ($autoLoading)
1171 1283
 		{
1172 1284
 			$autoLoading = is_array($autoLoading) ?
1173 1285
 				Framework::link('/index.php',$autoLoading) : Framework::link($autoLoading);
1174 1286
 			$html .= "$tree.setXMLAutoLoading('$autoLoading');\n";
1175
-			if ($dataMode != 'XML') $html .= "$tree.setDataMode('$dataMode');\n";
1287
+			if ($dataMode != 'XML')
1288
+			{
1289
+				$html .= "$tree.setDataMode('$dataMode');\n";
1290
+			}
1176 1291
 
1177 1292
 			// if no folders given, use xml url to load root, incl. setting of selected folder
1178 1293
 			if (!$_folders)
1179 1294
 			{
1180
-				if ($_selected) $autoLoading .= '&selected='.urlencode($_selected);
1295
+				if ($_selected)
1296
+				{
1297
+					$autoLoading .= '&selected='.urlencode($_selected);
1298
+				}
1181 1299
 				unset($_selected);
1182 1300
 				$html .= "$tree.loadXML('$autoLoading');\n";
1183 1301
 				$html .= "});";
@@ -1222,7 +1340,10 @@  discard block
 block discarded – undo
1222 1340
 		else
1223 1341
 		{
1224 1342
 			// evtl. remove leading delimiter
1225
-			if ($_selected[0] == $delimiter) $_selected = substr($_selected,1);
1343
+			if ($_selected[0] == $delimiter)
1344
+			{
1345
+				$_selected = substr($_selected,1);
1346
+			}
1226 1347
 
1227 1348
 			$n = 0;
1228 1349
 			foreach($_folders as $path => $data)
@@ -1251,22 +1372,37 @@  discard block
 block discarded – undo
1251 1372
 					$image1 = $image2 = $image3 = "'".$data['image']."'";
1252 1373
 				}
1253 1374
 				// evtl. remove leading delimiter
1254
-				if ($path[0] == $delimiter) $path = substr($path,1);
1375
+				if ($path[0] == $delimiter)
1376
+				{
1377
+					$path = substr($path,1);
1378
+				}
1255 1379
 				$folderParts = explode($delimiter,$path);
1256 1380
 
1257 1381
 				//get rightmost folderpart
1258 1382
 				$label = array_pop($folderParts);
1259
-				if (isset($data['label'])) $label = $data['label'];
1383
+				if (isset($data['label']))
1384
+				{
1385
+					$label = $data['label'];
1386
+				}
1260 1387
 
1261 1388
 				// the rest of the array is the name of the parent
1262 1389
 				$parentName = implode((array)$folderParts,$delimiter);
1263
-				if(empty($parentName)) $parentName = $top;
1390
+				if(empty($parentName))
1391
+				{
1392
+					$parentName = $top;
1393
+				}
1264 1394
 
1265 1395
 				$entryOptions = !isset($data['child']) || $data['child'] ? 'CHILD' : '';
1266
-				if ($_onCheckHandler && $_selected)	// check selected items on multi selection
1396
+				if ($_onCheckHandler && $_selected)
1397
+				{
1398
+					// check selected items on multi selection
1267 1399
 				{
1268 1400
 					if (!is_array($_selected)) $_selected = explode(',',$_selected);
1269
-					if (array_search("$path",$_selected)!==false) $entryOptions .= ',CHECKED';
1401
+				}
1402
+					if (array_search("$path",$_selected)!==false)
1403
+					{
1404
+						$entryOptions .= ',CHECKED';
1405
+					}
1270 1406
 					//echo "<p>path=$path, _selected=".print_r($_selected,true).": $entryOptions</p>\n";
1271 1407
 				}
1272 1408
 				// highlight current item
Please login to merge, or discard this patch.