Completed
Push — 16.1 ( da3266...d5e8cd )
by Klaus
19:17
created
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.
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-_]/','_',$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-_]/', '_', $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.
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.
api/src/Framework/Minimal.php 4 patches
Doc Comments   -5 removed lines patch added patch discarded remove patch
@@ -103,11 +103,6 @@
 block discarded – undo
103 103
 	/**
104 104
 	* Add menu items to the topmenu template class to be displayed
105 105
 	*
106
-	* @param array $app application data
107
-	* @param mixed $alt_label string with alternative menu item label default value = null
108
-	* @param string $urlextra string with alternate additional code inside <a>-tag
109
-	* @access protected
110
-	* @return void
111 106
 	*/
112 107
 	function _add_topmenu_item(array $app_data,$alt_label=null)
113 108
 	{
Please login to merge, or discard this patch.
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -21,29 +21,29 @@  discard block
 block discarded – undo
21 21
 class Minimal extends Api\Framework
22 22
 {
23 23
 	/**
24
-	* Instance of the phplib Template class for the API's template dir (EGW_TEMPLATE_DIR)
25
-	*
26
-	* @var Template
27
-	*/
24
+	 * Instance of the phplib Template class for the API's template dir (EGW_TEMPLATE_DIR)
25
+	 *
26
+	 * @var Template
27
+	 */
28 28
 	var $tpl;
29 29
 
30 30
 	/**
31
-	* Constructor
32
-	*
33
-	* @param string $template ='default' name of the template
34
-	* @return idots_framework
35
-	*/
31
+	 * Constructor
32
+	 *
33
+	 * @param string $template ='default' name of the template
34
+	 * @return idots_framework
35
+	 */
36 36
 	function __construct($template='default')
37 37
 	{
38 38
 		parent::__construct($template);		// call the constructor of the extended class
39 39
 	}
40 40
 
41 41
 	/**
42
-	* Returns the html-header incl. the opening body tag
43
-	*
44
-	* @param array $extra =array() extra attributes passed as data-attribute to egw.js
45
-	* @return string with html
46
-	*/
42
+	 * Returns the html-header incl. the opening body tag
43
+	 *
44
+	 * @param array $extra =array() extra attributes passed as data-attribute to egw.js
45
+	 * @return string with html
46
+	 */
47 47
 	function header(array $extra=array())
48 48
 	{
49 49
 		// make sure header is output only once
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 	}
77 77
 
78 78
 	/**
79
-	* Returns the html from the body-tag til the main application area (incl. opening div tag)
80
-	*
81
-	* @return string with html
82
-	*/
79
+	 * Returns the html from the body-tag til the main application area (incl. opening div tag)
80
+	 *
81
+	 * @return string with html
82
+	 */
83 83
 	function navbar()
84 84
 	{
85 85
 		return '';
@@ -101,37 +101,37 @@  discard block
 block discarded – undo
101 101
 	}
102 102
 
103 103
 	/**
104
-	* Add menu items to the topmenu template class to be displayed
105
-	*
106
-	* @param array $app application data
107
-	* @param mixed $alt_label string with alternative menu item label default value = null
108
-	* @param string $urlextra string with alternate additional code inside <a>-tag
109
-	* @access protected
110
-	* @return void
111
-	*/
104
+	 * Add menu items to the topmenu template class to be displayed
105
+	 *
106
+	 * @param array $app application data
107
+	 * @param mixed $alt_label string with alternative menu item label default value = null
108
+	 * @param string $urlextra string with alternate additional code inside <a>-tag
109
+	 * @access protected
110
+	 * @return void
111
+	 */
112 112
 	function _add_topmenu_item(array $app_data,$alt_label=null)
113 113
 	{
114 114
 		unset($app_data, $alt_label);
115 115
 	}
116 116
 
117 117
 	/**
118
-	* Add info items to the topmenu template class to be displayed
119
-	*
120
-	* @param string $content html of item
121
-	* @param string $id =null
122
-	* @access protected
123
-	* @return void
124
-	*/
118
+	 * Add info items to the topmenu template class to be displayed
119
+	 *
120
+	 * @param string $content html of item
121
+	 * @param string $id =null
122
+	 * @access protected
123
+	 * @return void
124
+	 */
125 125
 	function _add_topmenu_info_item($content, $id=null)
126 126
 	{
127 127
 		unset($content, $id);
128 128
 	}
129 129
 
130 130
 	/**
131
-	* Returns the html from the closing div of the main application area to the closing html-tag
132
-	*
133
-	* @return string html or null if no footer needed/wanted
134
-	*/
131
+	 * Returns the html from the closing div of the main application area to the closing html-tag
132
+	 *
133
+	 * @return string html or null if no footer needed/wanted
134
+	 */
135 135
 	function footer()
136 136
 	{
137 137
 		static $footer_done=0;
@@ -141,29 +141,29 @@  discard block
 block discarded – undo
141 141
 	}
142 142
 
143 143
 	/**
144
-	* Parses one sidebox menu and add's the html to $this->sidebox_content for later use by $this->navbar
145
-	*
146
-	* @param string $appname
147
-	* @param string $menu_title
148
-	* @param array $file
149
-	* @param string $type =null 'admin', 'preferences', 'favorites', ...
150
-	*/
144
+	 * Parses one sidebox menu and add's the html to $this->sidebox_content for later use by $this->navbar
145
+	 *
146
+	 * @param string $appname
147
+	 * @param string $menu_title
148
+	 * @param array $file
149
+	 * @param string $type =null 'admin', 'preferences', 'favorites', ...
150
+	 */
151 151
 	function sidebox($appname,$menu_title,$file,$type=null)
152 152
 	{
153 153
 		unset($appname, $menu_title, $file, $type);
154 154
 	}
155 155
 
156 156
 	/**
157
-	* called by hooks to add an icon in the topmenu info location
158
-	*
159
-	* @param string $id unique element id
160
-	* @param string $icon_src src of the icon image. Make sure this nog height then 18pixels
161
-	* @param string $iconlink where the icon links to
162
-	* @param booleon $blink set true to make the icon blink
163
-	* @param mixed $tooltip string containing the tooltip html, or null of no tooltip
164
-	* @access public
165
-	* @return void
166
-	*/
157
+	 * called by hooks to add an icon in the topmenu info location
158
+	 *
159
+	 * @param string $id unique element id
160
+	 * @param string $icon_src src of the icon image. Make sure this nog height then 18pixels
161
+	 * @param string $iconlink where the icon links to
162
+	 * @param booleon $blink set true to make the icon blink
163
+	 * @param mixed $tooltip string containing the tooltip html, or null of no tooltip
164
+	 * @access public
165
+	 * @return void
166
+	 */
167 167
 	function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null)
168 168
 	{
169 169
 		unset($id, $icon_src, $iconlink, $blink, $tooltip);
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 	* @param string $template ='default' name of the template
34 34
 	* @return idots_framework
35 35
 	*/
36
-	function __construct($template='default')
36
+	function __construct($template = 'default')
37 37
 	{
38
-		parent::__construct($template);		// call the constructor of the extended class
38
+		parent::__construct($template); // call the constructor of the extended class
39 39
 	}
40 40
 
41 41
 	/**
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	* @param array $extra =array() extra attributes passed as data-attribute to egw.js
45 45
 	* @return string with html
46 46
 	*/
47
-	function header(array $extra=array())
47
+	function header(array $extra = array())
48 48
 	{
49 49
 		// make sure header is output only once
50 50
 		if (self::$header_done) return '';
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
 		// as the old Template class has problems if restored from the session (php-restore)
67 67
 		$this->tpl = new Template(EGW_SERVER_ROOT.$this->template_dir, 'keep');
68 68
 		$this->tpl->set_file(array('_head' => 'head.tpl'));
69
-		$this->tpl->set_block('_head','head');
69
+		$this->tpl->set_block('_head', 'head');
70 70
 
71 71
 		$this->tpl->set_var($this->_get_header($extra));
72 72
 
73
-		$content .= $this->tpl->fp('out','head');
73
+		$content .= $this->tpl->fp('out', 'head');
74 74
 
75 75
 		return $content;
76 76
 	}
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @return boolean $consider_navbar_not_yet_called_as_true=true
94 94
 	 * @return boolean
95 95
 	 */
96
-	public function isTop($consider_navbar_not_yet_called_as_true=true)
96
+	public function isTop($consider_navbar_not_yet_called_as_true = true)
97 97
 	{
98 98
 		unset($consider_navbar_not_yet_called_as_true);
99 99
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	* @access protected
110 110
 	* @return void
111 111
 	*/
112
-	function _add_topmenu_item(array $app_data,$alt_label=null)
112
+	function _add_topmenu_item(array $app_data, $alt_label = null)
113 113
 	{
114 114
 		unset($app_data, $alt_label);
115 115
 	}
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	* @access protected
123 123
 	* @return void
124 124
 	*/
125
-	function _add_topmenu_info_item($content, $id=null)
125
+	function _add_topmenu_info_item($content, $id = null)
126 126
 	{
127 127
 		unset($content, $id);
128 128
 	}
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
 	*/
135 135
 	function footer()
136 136
 	{
137
-		static $footer_done=0;
138
-		if ($footer_done++) return;	// prevent multiple footers, not sure we still need this (RalfBecker)
137
+		static $footer_done = 0;
138
+		if ($footer_done++) return; // prevent multiple footers, not sure we still need this (RalfBecker)
139 139
 
140
-		return "</body>\n</html>\n";	// close body and html tag, eg. for popups
140
+		return "</body>\n</html>\n"; // close body and html tag, eg. for popups
141 141
 	}
142 142
 
143 143
 	/**
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	* @param array $file
149 149
 	* @param string $type =null 'admin', 'preferences', 'favorites', ...
150 150
 	*/
151
-	function sidebox($appname,$menu_title,$file,$type=null)
151
+	function sidebox($appname, $menu_title, $file, $type = null)
152 152
 	{
153 153
 		unset($appname, $menu_title, $file, $type);
154 154
 	}
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	* @access public
165 165
 	* @return void
166 166
 	*/
167
-	function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null)
167
+	function topmenu_info_icon($id, $icon_src, $iconlink, $blink = false, $tooltip = null)
168 168
 	{
169 169
 		unset($id, $icon_src, $iconlink, $blink, $tooltip);
170 170
 	}
Please login to merge, or discard this patch.
Braces   +9 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,7 +47,10 @@  discard block
 block discarded – undo
47 47
 	function header(array $extra=array())
48 48
 	{
49 49
 		// make sure header is output only once
50
-		if (self::$header_done) return '';
50
+		if (self::$header_done)
51
+		{
52
+			return '';
53
+		}
51 54
 		self::$header_done = true;
52 55
 
53 56
 		// js stuff is not needed by login page or in popups
@@ -135,7 +138,11 @@  discard block
 block discarded – undo
135 138
 	function footer()
136 139
 	{
137 140
 		static $footer_done=0;
138
-		if ($footer_done++) return;	// prevent multiple footers, not sure we still need this (RalfBecker)
141
+		if ($footer_done++)
142
+		{
143
+			return;
144
+		}
145
+		// prevent multiple footers, not sure we still need this (RalfBecker)
139 146
 
140 147
 		return "</body>\n</html>\n";	// close body and html tag, eg. for popups
141 148
 	}
Please login to merge, or discard this patch.
api/src/Framework/Updates.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 	/**
39 39
 	 * Get versions of available updates
40 40
 	 *
41
-	 * @return array verions for keys "current" and "security"
41
+	 * @return string verions for keys "current" and "security"
42 42
 	 */
43 43
 	public static function available()
44 44
 	{
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 				list($current, $security) = explode("\n", $remote);
52 52
 				if (empty($security)) $security = $current;
53 53
 				$versions = array(
54
-					'current'  => $current,		// last maintenance update
55
-					'security' => $security,	// last security update
54
+					'current'  => $current, // last maintenance update
55
+					'security' => $security, // last security update
56 56
 				);
57 57
 			}
58 58
 			return $versions;
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	protected static function update_older($version, $days)
115 115
 	{
116
-		list(,,$date) = explode('.', $version);
116
+		list(,, $date) = explode('.', $version);
117 117
 		if ($date < 20140000) return false;
118 118
 		$version_timestamp = mktime(0, 0, 0, (int)substr($date, 4, 2), (int)substr($date, -2), (int)substr($date, 0, 4));
119 119
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @param string &$changelog on return path to changelog
127 127
 	 * @return string
128 128
 	 */
129
-	public static function api_version(&$changelog=null)
129
+	public static function api_version(&$changelog = null)
130 130
 	{
131 131
 		$changelog = EGW_SERVER_ROOT.'/doc/rpm-build/debian.changes';
132 132
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,7 +49,10 @@  discard block
 block discarded – undo
49 49
 			if (($remote = file_get_contents(self::CURRENT_VERSION_URL, false, Api\Framework::proxy_context())))
50 50
 			{
51 51
 				list($current, $security) = explode("\n", $remote);
52
-				if (empty($security)) $security = $current;
52
+				if (empty($security))
53
+				{
54
+					$security = $current;
55
+				}
53 56
 				$versions = array(
54 57
 					'current'  => $current,		// last maintenance update
55 58
 					'security' => $security,	// last security update
@@ -114,7 +117,10 @@  discard block
 block discarded – undo
114 117
 	protected static function update_older($version, $days)
115 118
 	{
116 119
 		list(,,$date) = explode('.', $version);
117
-		if ($date < 20140000) return false;
120
+		if ($date < 20140000)
121
+		{
122
+			return false;
123
+		}
118 124
 		$version_timestamp = mktime(0, 0, 0, (int)substr($date, 4, 2), (int)substr($date, -2), (int)substr($date, 0, 4));
119 125
 
120 126
 		return (time() - $version_timestamp) / 86400 > $days;
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.
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
 		}
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 			// if the session class gives a reason why the login failed --> append it to the REALM
112 112
 			if ($GLOBALS['egw']->session->reason) $realm .= ': '.$GLOBALS['egw']->session->reason;
113 113
 
114
-			header('WWW-Authenticate: Basic realm="'.$realm.'"');// draft-reschke-basicauth-enc-06 adds, accept-charset="'.translation::charset().'"');
114
+			header('WWW-Authenticate: Basic realm="'.$realm.'"'); // draft-reschke-basicauth-enc-06 adds, accept-charset="'.translation::charset().'"');
115 115
 			self::digest_header($realm);
116 116
 			header('HTTP/1.1 401 Unauthorized');
117 117
 			header('X-WebDAV-Status: 401 Unauthorized', true);
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 			// replace \x encoded non-ascii chars in password, as they are used eg. by Thunderbird for German umlauts
136 136
 			if (strpos($password, '\\x') !== false)
137 137
 			{
138
-				$password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches){
138
+				$password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches) {
139 139
 					return chr(hexdec($matches[1]));
140 140
 				}, $password);
141 141
 			}
@@ -157,24 +157,24 @@  discard block
 block discarded – undo
157 157
 	 * @param string &$user_pw =null stored cleartext password, if $username given AND function returns true
158 158
 	 * @return boolean true if digest auth is available, false otherwise
159 159
 	 */
160
-	static public function digest_auth_available($realm,$username=null,&$user_pw=null)
160
+	static public function digest_auth_available($realm, $username = null, &$user_pw = null)
161 161
 	{
162 162
 		// we currently require plaintext passwords!
163 163
 		if (!($GLOBALS['egw_info']['server']['auth_type'] == 'sql' && $GLOBALS['egw_info']['server']['sql_encryption_type'] == 'plain') ||
164 164
 			  $GLOBALS['egw_info']['server']['auth_type'] == 'ldap' && $GLOBALS['egw_info']['server']['ldap_encryption_type'] == 'plain')
165 165
 		{
166 166
 			if (self::ERROR_LOG) error_log(__METHOD__."('$username') return false (no plaintext passwords used)");
167
-			return false;	// no plain-text passwords used
167
+			return false; // no plain-text passwords used
168 168
 		}
169 169
 		// check for specific user, if given
170
-		if (!is_null($username) && !(($user_pw = $GLOBALS['egw']->accounts->id2name($username,'account_pwd','u')) ||
171
-			$GLOBALS['egw_info']['server']['auth_type'] == 'sql' && substr($user_pw,0,7) != '{PLAIN}'))
170
+		if (!is_null($username) && !(($user_pw = $GLOBALS['egw']->accounts->id2name($username, 'account_pwd', 'u')) ||
171
+			$GLOBALS['egw_info']['server']['auth_type'] == 'sql' && substr($user_pw, 0, 7) != '{PLAIN}'))
172 172
 		{
173 173
 			unset($user_pw);
174 174
 			if (self::ERROR_LOG) error_log(__METHOD__."('$realm','$username') return false (unknown user or NO plaintext password for user)");
175
-			return false;	// user does NOT exist, or has no plaintext passwords (ldap server requires real root_dn or special ACL!)
175
+			return false; // user does NOT exist, or has no plaintext passwords (ldap server requires real root_dn or special ACL!)
176 176
 		}
177
-		if (substr($user_pw,0,7) == '{PLAIN}') $user_pw = substr($user_pw,7);
177
+		if (substr($user_pw, 0, 7) == '{PLAIN}') $user_pw = substr($user_pw, 7);
178 178
 
179 179
 		if (self::ERROR_LOG)
180 180
 		{
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * @param string $realm
191 191
 	 * @param string &$nonce=null on return
192 192
 	 */
193
-	static public function digest_header($realm,&$nonce=null)
193
+	static public function digest_header($realm, &$nonce = null)
194 194
 	{
195 195
 		if (self::digest_auth_available($realm))
196 196
 		{
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
 	 * @param string &$password on return cleartext password
210 210
 	 * @return boolean true if digest is correct, false otherwise
211 211
 	 */
212
-	static public function is_valid($realm,$auth_digest=null,&$username=null,&$password=null)
212
+	static public function is_valid($realm, $auth_digest = null, &$username = null, &$password = null)
213 213
 	{
214 214
 		if (is_null($auth_digest)) $auth_digest = $_SERVER['PHP_AUTH_DIGEST'];
215 215
 
216 216
 		$data = self::parse_digest($auth_digest);
217 217
 
218
-		if (!$data || !($A1 = self::get_digest_A1($realm,$username=$data['username'],$password=null)))
218
+		if (!$data || !($A1 = self::get_digest_A1($realm, $username = $data['username'], $password = null)))
219 219
 		{
220 220
 			error_log(__METHOD__."('$realm','$auth_digest','$username') returning FALSE");
221 221
 			return false;
@@ -236,16 +236,16 @@  discard block
 block discarded – undo
236 236
 	 * @param string &$password=null password to use or if null, on return stored password
237 237
 	 * @return string|boolean false if $password not given and can NOT be read
238 238
 	 */
239
-	static private function get_digest_A1($realm,$username,&$password=null)
239
+	static private function get_digest_A1($realm, $username, &$password = null)
240 240
 	{
241 241
 		$user_pw = null;
242
-		if (empty($username) || empty($realm) || !self::digest_auth_available($realm,$username,$user_pw))
242
+		if (empty($username) || empty($realm) || !self::digest_auth_available($realm, $username, $user_pw))
243 243
 		{
244 244
 			return false;
245 245
 		}
246 246
 		if (is_null($password)) $password = $user_pw;
247 247
 
248
-		$A1 = md5($username . ':' . $realm . ':' . $password);
248
+		$A1 = md5($username.':'.$realm.':'.$password);
249 249
 		if (self::ERROR_LOG > 1) error_log(__METHOD__."('$realm','$username','$password') returning ".array2string($A1));
250 250
 		return $A1;
251 251
 	}
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 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 266
 	    foreach ($matches as $m)
267 267
 	    {
Please login to merge, or discard this patch.
Braces   +42 added lines, -11 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?)
@@ -109,7 +112,10 @@  discard block
 block discarded – undo
109 112
 		if (!isset($username) || !($sessionid = $GLOBALS['egw']->session->create($username, $password, 'text', true)))
110 113
 		{
111 114
 			// if the session class gives a reason why the login failed --> append it to the REALM
112
-			if ($GLOBALS['egw']->session->reason) $realm .= ': '.$GLOBALS['egw']->session->reason;
115
+			if ($GLOBALS['egw']->session->reason)
116
+			{
117
+				$realm .= ': '.$GLOBALS['egw']->session->reason;
118
+			}
113 119
 
114 120
 			header('WWW-Authenticate: Basic realm="'.$realm.'"');// draft-reschke-basicauth-enc-06 adds, accept-charset="'.translation::charset().'"');
115 121
 			self::digest_header($realm);
@@ -135,7 +141,8 @@  discard block
 block discarded – undo
135 141
 			// replace \x encoded non-ascii chars in password, as they are used eg. by Thunderbird for German umlauts
136 142
 			if (strpos($password, '\\x') !== false)
137 143
 			{
138
-				$password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches){
144
+				$password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches)
145
+				{
139 146
 					return chr(hexdec($matches[1]));
140 147
 				}, $password);
141 148
 			}
@@ -163,7 +170,10 @@  discard block
 block discarded – undo
163 170
 		if (!($GLOBALS['egw_info']['server']['auth_type'] == 'sql' && $GLOBALS['egw_info']['server']['sql_encryption_type'] == 'plain') ||
164 171
 			  $GLOBALS['egw_info']['server']['auth_type'] == 'ldap' && $GLOBALS['egw_info']['server']['ldap_encryption_type'] == 'plain')
165 172
 		{
166
-			if (self::ERROR_LOG) error_log(__METHOD__."('$username') return false (no plaintext passwords used)");
173
+			if (self::ERROR_LOG)
174
+			{
175
+				error_log(__METHOD__."('$username') return false (no plaintext passwords used)");
176
+			}
167 177
 			return false;	// no plain-text passwords used
168 178
 		}
169 179
 		// check for specific user, if given
@@ -171,10 +181,16 @@  discard block
 block discarded – undo
171 181
 			$GLOBALS['egw_info']['server']['auth_type'] == 'sql' && substr($user_pw,0,7) != '{PLAIN}'))
172 182
 		{
173 183
 			unset($user_pw);
174
-			if (self::ERROR_LOG) error_log(__METHOD__."('$realm','$username') return false (unknown user or NO plaintext password for user)");
184
+			if (self::ERROR_LOG)
185
+			{
186
+				error_log(__METHOD__."('$realm','$username') return false (unknown user or NO plaintext password for user)");
187
+			}
175 188
 			return false;	// user does NOT exist, or has no plaintext passwords (ldap server requires real root_dn or special ACL!)
176 189
 		}
177
-		if (substr($user_pw,0,7) == '{PLAIN}') $user_pw = substr($user_pw,7);
190
+		if (substr($user_pw,0,7) == '{PLAIN}')
191
+		{
192
+			$user_pw = substr($user_pw,7);
193
+		}
178 194
 
179 195
 		if (self::ERROR_LOG)
180 196
 		{
@@ -196,7 +212,10 @@  discard block
 block discarded – undo
196 212
 		{
197 213
 			$nonce = uniqid();
198 214
    			header('WWW-Authenticate: Digest realm="'.$realm.'",qop="auth",nonce="'.$nonce.'",opaque="'.md5($realm).'"');
199
-			if (self::ERROR_LOG) error_log(__METHOD__."() offering digest auth for realm '$realm' using nonce='$nonce'");
215
+			if (self::ERROR_LOG)
216
+			{
217
+				error_log(__METHOD__."() offering digest auth for realm '$realm' using nonce='$nonce'");
218
+			}
200 219
 		}
201 220
 	}
202 221
 
@@ -211,7 +230,10 @@  discard block
 block discarded – undo
211 230
 	 */
212 231
 	static public function is_valid($realm,$auth_digest=null,&$username=null,&$password=null)
213 232
 	{
214
-		if (is_null($auth_digest)) $auth_digest = $_SERVER['PHP_AUTH_DIGEST'];
233
+		if (is_null($auth_digest))
234
+		{
235
+			$auth_digest = $_SERVER['PHP_AUTH_DIGEST'];
236
+		}
215 237
 
216 238
 		$data = self::parse_digest($auth_digest);
217 239
 
@@ -224,7 +246,10 @@  discard block
 block discarded – undo
224 246
 
225 247
 		$valid_response = md5($A1.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.$A2);
226 248
 
227
-		if (self::ERROR_LOG) error_log(__METHOD__."('$realm','$auth_digest','$username') response='$data[response]', valid_response='$valid_response' returning ".array2string($data['response'] === $valid_response));
249
+		if (self::ERROR_LOG)
250
+		{
251
+			error_log(__METHOD__."('$realm','$auth_digest','$username') response='$data[response]', valid_response='$valid_response' returning ".array2string($data['response'] === $valid_response));
252
+		}
228 253
 		return $data['response'] === $valid_response;
229 254
 	}
230 255
 
@@ -243,10 +268,16 @@  discard block
 block discarded – undo
243 268
 		{
244 269
 			return false;
245 270
 		}
246
-		if (is_null($password)) $password = $user_pw;
271
+		if (is_null($password))
272
+		{
273
+			$password = $user_pw;
274
+		}
247 275
 
248 276
 		$A1 = md5($username . ':' . $realm . ':' . $password);
249
-		if (self::ERROR_LOG > 1) error_log(__METHOD__."('$realm','$username','$password') returning ".array2string($A1));
277
+		if (self::ERROR_LOG > 1)
278
+		{
279
+			error_log(__METHOD__."('$realm','$username','$password') returning ".array2string($A1));
280
+		}
250 281
 		return $A1;
251 282
 	}
252 283
 
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   +53 added lines, -13 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
 	public static function read($force_rescan=false)
212 240
 	{
213 241
 		//$starttime = microtime(true);
214
-		if ($force_rescan) Cache::unsetInstance(__CLASS__, 'locations');
242
+		if ($force_rescan)
243
+		{
244
+			Cache::unsetInstance(__CLASS__, 'locations');
245
+		}
215 246
 
216 247
 		self::$locations = Cache::getInstance(__CLASS__, 'locations', function()
217 248
 		{
@@ -226,11 +257,17 @@  discard block
 block discarded – undo
226 257
 			$locations = array();
227 258
 			foreach(array_merge(array('api'), array_keys($GLOBALS['egw_info']['apps'])) as $appname)
228 259
 			{
229
-				if ($appname[0] == '.' || !is_dir(EGW_SERVER_ROOT.'/'.$appname)) continue;
260
+				if ($appname[0] == '.' || !is_dir(EGW_SERVER_ROOT.'/'.$appname))
261
+				{
262
+					continue;
263
+				}
230 264
 
231 265
 				$f = EGW_SERVER_ROOT . '/' . $appname . '/setup/setup.inc.php';
232 266
 				$setup_info = array($appname => array());
233
-				if(@file_exists($f)) include($f);
267
+				if(@file_exists($f))
268
+				{
269
+					include($f);
270
+				}
234 271
 
235 272
 				// some apps have setup_info for more then themselfs (eg. api for groupdav)
236 273
 				foreach($setup_info as $appname => $data)
@@ -258,7 +295,10 @@  discard block
 block discarded – undo
258 295
 	 */
259 296
 	public static function pgp_encryption_menu($appname)
260 297
 	{
261
-		if (Header\UserAgent::mobile()) return;
298
+		if (Header\UserAgent::mobile())
299
+		{
300
+			return;
301
+		}
262 302
 
263 303
 		// PGP Encryption (Mailvelope plugin) restore/backup menu
264 304
 		$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
@@ -464,7 +464,7 @@
 block discarded – undo
464 464
 	{
465 465
 		unset($args);	// unused, but required by function signature
466 466
 		$appname = 'preferences';
467
-		$file = Array(
467
+		$file = array(
468 468
 			'Site configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname=' . $appname.'&ajax=true'),
469 469
 		);
470 470
 		display_section($appname, $file);
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.
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() {\$j(function() {if(\$j().chosen) \$j('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
 		if (self::$netscape4)
@@ -899,17 +975,26 @@  discard block
 block discarded – undo
899 975
 	 */
900 976
 	static function image( $app,$name,$title='',$options='' )
901 977
 	{
902
-		if (is_array($name))	// menuaction and other get-vars
978
+		if (is_array($name))
979
+		{
980
+			// menuaction and other get-vars
903 981
 		{
904 982
 			$name = $GLOBALS['egw']->link('/index.php',$name);
905 983
 		}
906
-		if (substr($name,0,5) == 'vfs:/')	// vfs pseudo protocoll
984
+		}
985
+		if (substr($name,0,5) == 'vfs:/')
986
+		{
987
+			// vfs pseudo protocoll
907 988
 		{
908 989
 			$name = Framework::link(Vfs::download_url(substr($name,4)));
909 990
 		}
991
+		}
910 992
 		if ($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://' || stripos($name,'api/thumbnail.php') )
911 993
 		{
912
-			if (!($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://')) $name = '/'.$name;
994
+			if (!($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://'))
995
+			{
996
+				$name = '/'.$name;
997
+			}
913 998
 			$url = $name;
914 999
 		}
915 1000
 		else	// no URL, so try searching the image
@@ -924,7 +1009,10 @@  discard block
 block discarded – undo
924 1009
 			{
925 1010
 				list(,$path) = explode($GLOBALS['egw_info']['server']['webserver_url'],$url);
926 1011
 
927
-				if (!is_null($path)) $path = EGW_SERVER_ROOT.$path;
1012
+				if (!is_null($path))
1013
+				{
1014
+					$path = EGW_SERVER_ROOT.$path;
1015
+				}
928 1016
 			}
929 1017
 			else
930 1018
 			{
@@ -987,10 +1075,13 @@  discard block
 block discarded – undo
987 1075
 		{
988 1076
 			$url = "/index.php?menuaction=$url";
989 1077
 		}
990
-		if ($url[0] == '/')		// link relative to eGW
1078
+		if ($url[0] == '/')
1079
+		{
1080
+			// link relative to eGW
991 1081
 		{
992 1082
 			$url = self::link($url,$vars);
993 1083
 		}
1084
+		}
994 1085
 		//echo "<p>self::a_href('".self::htmlspecialchars($content)."','$url',".print_r($vars,True).") = ".self::link($url,$vars)."</p>";
995 1086
 		return '<a href="'.self::htmlspecialchars($url).'" '.$options.'>'.$content.'</a>';
996 1087
 	}
@@ -1015,7 +1106,10 @@  discard block
 block discarded – undo
1015 1106
 	 */
1016 1107
 	static function hr($width='',$options='')
1017 1108
 	{
1018
-		if ($width) $options .= " width=\"$width\"";
1109
+		if ($width)
1110
+		{
1111
+			$options .= " width=\"$width\"";
1112
+		}
1019 1113
 
1020 1114
 		return "<hr $options />\n";
1021 1115
 	}
@@ -1031,8 +1125,14 @@  discard block
 block discarded – undo
1031 1125
 	 */
1032 1126
 	static function formatOptions($options,$names)
1033 1127
 	{
1034
-		if (!is_array($options)) $options = explode(',',$options);
1035
-		if (!is_array($names))   $names   = explode(',',$names);
1128
+		if (!is_array($options))
1129
+		{
1130
+			$options = explode(',',$options);
1131
+		}
1132
+		if (!is_array($names))
1133
+		{
1134
+			$names   = explode(',',$names);
1135
+		}
1036 1136
 
1037 1137
 		foreach($options as $n => $val)
1038 1138
 		{
@@ -1150,9 +1250,15 @@  discard block
 block discarded – undo
1150 1250
 			Framework::includeCSS('/api/js/dhtmlxtree/codebase/dhtmlxtree.css');
1151 1251
 			Framework::includeJS('/api/js/dhtmlxtree/codebase/dhtmlxcommon.js');
1152 1252
 			Framework::includeJS('/api/js/dhtmlxtree/sources/dhtmlxtree.js');
1153
-			if ($autoLoading && $dataMode != 'XML') Framework::includeJS('/api/js/dhtmlxtree/sources/ext/dhtmlxtree_json.js');
1253
+			if ($autoLoading && $dataMode != 'XML')
1254
+			{
1255
+				Framework::includeJS('/api/js/dhtmlxtree/sources/ext/dhtmlxtree_json.js');
1256
+			}
1154 1257
 			$tree_initialised = true;
1155
-			if (!$_folders && !$autoLoading) return null;
1258
+			if (!$_folders && !$autoLoading)
1259
+			{
1260
+				return null;
1261
+			}
1156 1262
 		}
1157 1263
 		$html = self::div("\n",'id="'.$tree.'"',$_divClass).$html;
1158 1264
 		$html .= "<script type='text/javascript'>\n";
@@ -1160,7 +1266,10 @@  discard block
 block discarded – undo
1160 1266
 		$html .= "egw_LAB.wait(function() {";
1161 1267
 		$html .= "$tree = new"." dhtmlXTreeObject('$tree','100%','100%',0);\n";
1162 1268
 		$html .= "$tree.parentObject.style.overflow='auto';\n";	// dhtmlXTree constructor has hidden hardcoded
1163
-		if (Translation::charset() == 'utf-8') $html .= "if ($tree.setEscapingMode) $tree.setEscapingMode('utf8');\n";
1269
+		if (Translation::charset() == 'utf-8')
1270
+		{
1271
+			$html .= "if ($tree.setEscapingMode) $tree.setEscapingMode('utf8');\n";
1272
+		}
1164 1273
 		$html .= "$tree.setImagePath('$folderImageDir/dhtmlxtree/');\n";
1165 1274
 
1166 1275
 		if($_onCheckHandler)
@@ -1169,19 +1278,28 @@  discard block
 block discarded – undo
1169 1278
 			$html .= "$tree.setOnCheckHandler('$_onCheckHandler');\n";
1170 1279
 		}
1171 1280
 
1172
-		if ($dragndrop) $html .= "$tree.enableDragAndDrop(true);\n";
1281
+		if ($dragndrop)
1282
+		{
1283
+			$html .= "$tree.enableDragAndDrop(true);\n";
1284
+		}
1173 1285
 
1174 1286
 		if ($autoLoading)
1175 1287
 		{
1176 1288
 			$autoLoading = is_array($autoLoading) ?
1177 1289
 				Framework::link('/index.php',$autoLoading) : Framework::link($autoLoading);
1178 1290
 			$html .= "$tree.setXMLAutoLoading('$autoLoading');\n";
1179
-			if ($dataMode != 'XML') $html .= "$tree.setDataMode('$dataMode');\n";
1291
+			if ($dataMode != 'XML')
1292
+			{
1293
+				$html .= "$tree.setDataMode('$dataMode');\n";
1294
+			}
1180 1295
 
1181 1296
 			// if no folders given, use xml url to load root, incl. setting of selected folder
1182 1297
 			if (!$_folders)
1183 1298
 			{
1184
-				if ($_selected) $autoLoading .= '&selected='.urlencode($_selected);
1299
+				if ($_selected)
1300
+				{
1301
+					$autoLoading .= '&selected='.urlencode($_selected);
1302
+				}
1185 1303
 				unset($_selected);
1186 1304
 				$html .= "$tree.loadXML('$autoLoading');\n";
1187 1305
 				$html .= "});";
@@ -1226,7 +1344,10 @@  discard block
 block discarded – undo
1226 1344
 		else
1227 1345
 		{
1228 1346
 			// evtl. remove leading delimiter
1229
-			if ($_selected[0] == $delimiter) $_selected = substr($_selected,1);
1347
+			if ($_selected[0] == $delimiter)
1348
+			{
1349
+				$_selected = substr($_selected,1);
1350
+			}
1230 1351
 
1231 1352
 			$n = 0;
1232 1353
 			foreach($_folders as $path => $data)
@@ -1255,22 +1376,37 @@  discard block
 block discarded – undo
1255 1376
 					$image1 = $image2 = $image3 = "'".$data['image']."'";
1256 1377
 				}
1257 1378
 				// evtl. remove leading delimiter
1258
-				if ($path[0] == $delimiter) $path = substr($path,1);
1379
+				if ($path[0] == $delimiter)
1380
+				{
1381
+					$path = substr($path,1);
1382
+				}
1259 1383
 				$folderParts = explode($delimiter,$path);
1260 1384
 
1261 1385
 				//get rightmost folderpart
1262 1386
 				$label = array_pop($folderParts);
1263
-				if (isset($data['label'])) $label = $data['label'];
1387
+				if (isset($data['label']))
1388
+				{
1389
+					$label = $data['label'];
1390
+				}
1264 1391
 
1265 1392
 				// the rest of the array is the name of the parent
1266 1393
 				$parentName = implode((array)$folderParts,$delimiter);
1267
-				if(empty($parentName)) $parentName = $top;
1394
+				if(empty($parentName))
1395
+				{
1396
+					$parentName = $top;
1397
+				}
1268 1398
 
1269 1399
 				$entryOptions = !isset($data['child']) || $data['child'] ? 'CHILD' : '';
1270
-				if ($_onCheckHandler && $_selected)	// check selected items on multi selection
1400
+				if ($_onCheckHandler && $_selected)
1401
+				{
1402
+					// check selected items on multi selection
1271 1403
 				{
1272 1404
 					if (!is_array($_selected)) $_selected = explode(',',$_selected);
1273
-					if (array_search("$path",$_selected)!==false) $entryOptions .= ',CHECKED';
1405
+				}
1406
+					if (array_search("$path",$_selected)!==false)
1407
+					{
1408
+						$entryOptions .= ',CHECKED';
1409
+					}
1274 1410
 					//echo "<p>path=$path, _selected=".print_r($_selected,true).": $entryOptions</p>\n";
1275 1411
 				}
1276 1412
 				// highlight current item
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,11 +865,11 @@  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
 
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
 		}
880 880
 		return '<div class="onlyPrint">'.$title.'</div><div class="noPrint" title="'.$title.'" '.$options.
881 881
 			' style="height: '.$height.'; width: '.$width.'; border: 1px solid black; padding: 1px; text-align: left;'.
882
-			(@stristr($options,'onclick="') ? ' cursor: pointer;' : '').'">'."\n\t".
882
+			(@stristr($options, 'onclick="') ? ' cursor: pointer;' : '').'">'."\n\t".
883 883
 			'<div style="height: '.$height.'; width: '.$percent.'%; background: '.$color.';"></div>'."\n</div>\n";
884 884
 	}
885 885
 
@@ -897,32 +897,32 @@  discard block
 block discarded – undo
897 897
 	 * @param string $options further options for the tag, default '' = none
898 898
 	 * @return string the html
899 899
 	 */
900
-	static function image( $app,$name,$title='',$options='' )
900
+	static function image($app, $name, $title = '', $options = '')
901 901
 	{
902 902
 		if (is_array($name))	// menuaction and other get-vars
903 903
 		{
904
-			$name = $GLOBALS['egw']->link('/index.php',$name);
904
+			$name = $GLOBALS['egw']->link('/index.php', $name);
905 905
 		}
906
-		if (substr($name,0,5) == 'vfs:/')	// vfs pseudo protocoll
906
+		if (substr($name, 0, 5) == 'vfs:/')	// vfs pseudo protocoll
907 907
 		{
908
-			$name = Framework::link(Vfs::download_url(substr($name,4)));
908
+			$name = Framework::link(Vfs::download_url(substr($name, 4)));
909 909
 		}
910
-		if ($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://' || stripos($name,'api/thumbnail.php') )
910
+		if ($name[0] == '/' || substr($name, 0, 7) == 'http://' || substr($name, 0, 8) == 'https://' || stripos($name, 'api/thumbnail.php'))
911 911
 		{
912
-			if (!($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://')) $name = '/'.$name;
912
+			if (!($name[0] == '/' || substr($name, 0, 7) == 'http://' || substr($name, 0, 8) == 'https://')) $name = '/'.$name;
913 913
 			$url = $name;
914 914
 		}
915 915
 		else	// no URL, so try searching the image
916 916
 		{
917
-			$name = str_replace(array('.gif','.GIF','.png','.PNG'),'',$name);
917
+			$name = str_replace(array('.gif', '.GIF', '.png', '.PNG'), '', $name);
918 918
 
919
-			if (!($url = Image::find($app,$name)))
919
+			if (!($url = Image::find($app, $name)))
920 920
 			{
921
-				$url = $name;		// name may already contain absolut path
921
+				$url = $name; // name may already contain absolut path
922 922
 			}
923
-			if($GLOBALS['egw_info']['server']['webserver_url'])
923
+			if ($GLOBALS['egw_info']['server']['webserver_url'])
924 924
 			{
925
-				list(,$path) = explode($GLOBALS['egw_info']['server']['webserver_url'],$url);
925
+				list(,$path) = explode($GLOBALS['egw_info']['server']['webserver_url'], $url);
926 926
 
927 927
 				if (!is_null($path)) $path = EGW_SERVER_ROOT.$path;
928 928
 			}
@@ -931,12 +931,12 @@  discard block
 block discarded – undo
931 931
 				$path = EGW_SERVER_ROOT.$url;
932 932
 			}
933 933
 
934
-			if (is_null($path) || (!@is_readable($path) && stripos($path,'webdav.php')===false))
934
+			if (is_null($path) || (!@is_readable($path) && stripos($path, 'webdav.php') === false))
935 935
 			{
936 936
 				// if the image-name is a percentage, use a progressbar
937
-				if (substr($name,-1) == '%' && is_numeric($percent = substr($name,0,-1)))
937
+				if (substr($name, -1) == '%' && is_numeric($percent = substr($name, 0, -1)))
938 938
 				{
939
-					return self::progressbar($percent,$title);
939
+					return self::progressbar($percent, $title);
940 940
 				}
941 941
 				return $title;
942 942
 			}
@@ -947,12 +947,12 @@  discard block
 block discarded – undo
947 947
 		}
948 948
 
949 949
 		// This block makes pngfix.js useless, adding a check on disable_pngfix to have pngfix.js do its thing
950
-		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'])))
950
+		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'])))
951 951
 		{
952 952
 			$extra_styles = "display: inline-block; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='$url',sizingMethod='image'); width: 1px; height: 1px;";
953
-			if (false!==strpos($options,'style="'))
953
+			if (false !== strpos($options, 'style="'))
954 954
 			{
955
-				$options = str_replace('style="','style="'.$extra_styles, $options);
955
+				$options = str_replace('style="', 'style="'.$extra_styles, $options);
956 956
 			}
957 957
 			else
958 958
 			{
@@ -972,24 +972,24 @@  discard block
 block discarded – undo
972 972
 	 * @param string $options attributes for the tag, default ''=none
973 973
 	 * @return string the html
974 974
 	 */
975
-	static function a_href( $content,$url,$vars='',$options='')
975
+	static function a_href($content, $url, $vars = '', $options = '')
976 976
 	{
977 977
 		if (is_array($url))
978 978
 		{
979 979
 			$vars = $url;
980 980
 			$url = '/index.php';
981 981
 		}
982
-		elseif (strpos($url,'/')===false &&
983
-			count(explode('.',$url)) >= 3 &&
984
-			!(strpos($url,'mailto:')!==false ||
985
-			strpos($url,'://')!==false ||
986
-			strpos($url,'javascript:')!==false))
982
+		elseif (strpos($url, '/') === false &&
983
+			count(explode('.', $url)) >= 3 &&
984
+			!(strpos($url, 'mailto:') !== false ||
985
+			strpos($url, '://') !== false ||
986
+			strpos($url, 'javascript:') !== false))
987 987
 		{
988 988
 			$url = "/index.php?menuaction=$url";
989 989
 		}
990 990
 		if ($url[0] == '/')		// link relative to eGW
991 991
 		{
992
-			$url = self::link($url,$vars);
992
+			$url = self::link($url, $vars);
993 993
 		}
994 994
 		//echo "<p>self::a_href('".self::htmlspecialchars($content)."','$url',".print_r($vars,True).") = ".self::link($url,$vars)."</p>";
995 995
 		return '<a href="'.self::htmlspecialchars($url).'" '.$options.'>'.$content.'</a>';
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 	 */
1004 1004
 	static function bold($content)
1005 1005
 	{
1006
-		return '<b>'.($content?$content.'</b>':'');
1006
+		return '<b>'.($content ? $content.'</b>' : '');
1007 1007
 	}
1008 1008
 
1009 1009
 	/**
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
 	 * @param string $options attributes for the tag, default ''=none
1014 1014
 	 * @return string the html
1015 1015
 	 */
1016
-	static function hr($width='',$options='')
1016
+	static function hr($width = '', $options = '')
1017 1017
 	{
1018 1018
 		if ($width) $options .= " width=\"$width\"";
1019 1019
 
@@ -1029,12 +1029,12 @@  discard block
 block discarded – undo
1029 1029
 	 * @param mixed $names String (or Array) with the option-names eg. 'WIDTH,HEIGHT,BORDER'
1030 1030
 	 * @return string with options/attributes
1031 1031
 	 */
1032
-	static function formatOptions($options,$names)
1032
+	static function formatOptions($options, $names)
1033 1033
 	{
1034
-		if (!is_array($options)) $options = explode(',',$options);
1035
-		if (!is_array($names))   $names   = explode(',',$names);
1034
+		if (!is_array($options)) $options = explode(',', $options);
1035
+		if (!is_array($names))   $names   = explode(',', $names);
1036 1036
 
1037
-		foreach($options as $n => $val)
1037
+		foreach ($options as $n => $val)
1038 1038
 		{
1039 1039
 			if ($val != '' && $names[$n] != '')
1040 1040
 			{
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
 	 * @param string $options attributes for the tag, default ''=none
1065 1065
 	 * @return string the html
1066 1066
 	 */
1067
-	static function label($content,$id='',$accesskey='',$options='')
1067
+	static function label($content, $id = '', $accesskey = '', $options = '')
1068 1068
 	{
1069 1069
 		if ($id != '')
1070 1070
 		{
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
 	 * @param string $options attributes for the tag, default ''=none
1086 1086
 	 * @return string the html
1087 1087
 	 */
1088
-	static function fieldset($content,$legend='',$options='')
1088
+	static function fieldset($content, $legend = '', $options = '')
1089 1089
 	{
1090 1090
 		$html = "<fieldset $options>".($legend ? '<legend>'.self::htmlspecialchars($legend).'</legend>' : '')."\n";
1091 1091
 
@@ -1119,9 +1119,9 @@  discard block
 block discarded – undo
1119 1119
 	 *
1120 1120
 	 * @return string the html code, to be added into the template
1121 1121
 	 */
1122
-	static function tree($_folders,$_selected,$_topFolder=false,$_onNodeSelect="null",$tree='foldertree',$_divClass='',
1123
-		$_leafImage='',$_onCheckHandler=false,$delimiter='/',$folderImageDir=null,$autoLoading=null,$dataMode='JSON',
1124
-		$dragndrop=false)
1122
+	static function tree($_folders, $_selected, $_topFolder = false, $_onNodeSelect = "null", $tree = 'foldertree', $_divClass = '',
1123
+		$_leafImage = '', $_onCheckHandler = false, $delimiter = '/', $folderImageDir = null, $autoLoading = null, $dataMode = 'JSON',
1124
+		$dragndrop = false)
1125 1125
 	{
1126 1126
 		$webserver_url = $GLOBALS['egw_info']['server']['webserver_url'];
1127 1127
 		if (empty($folderImageDir))
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
 			//error_log(__METHOD__."() setting templated image-path: $folderImageDir");
1145 1145
 		}
1146 1146
 
1147
-		static $tree_initialised=false;
1147
+		static $tree_initialised = false;
1148 1148
 		if (!$tree_initialised)
1149 1149
 		{
1150 1150
 			Framework::includeCSS('/api/js/dhtmlxtree/codebase/dhtmlxtree.css');
@@ -1154,16 +1154,16 @@  discard block
 block discarded – undo
1154 1154
 			$tree_initialised = true;
1155 1155
 			if (!$_folders && !$autoLoading) return null;
1156 1156
 		}
1157
-		$html = self::div("\n",'id="'.$tree.'"',$_divClass).$html;
1157
+		$html = self::div("\n", 'id="'.$tree.'"', $_divClass).$html;
1158 1158
 		$html .= "<script type='text/javascript'>\n";
1159 1159
 		$html .= "var $tree;";
1160 1160
 		$html .= "egw_LAB.wait(function() {";
1161 1161
 		$html .= "$tree = new"." dhtmlXTreeObject('$tree','100%','100%',0);\n";
1162
-		$html .= "$tree.parentObject.style.overflow='auto';\n";	// dhtmlXTree constructor has hidden hardcoded
1162
+		$html .= "$tree.parentObject.style.overflow='auto';\n"; // dhtmlXTree constructor has hidden hardcoded
1163 1163
 		if (Translation::charset() == 'utf-8') $html .= "if ($tree.setEscapingMode) $tree.setEscapingMode('utf8');\n";
1164 1164
 		$html .= "$tree.setImagePath('$folderImageDir/dhtmlxtree/');\n";
1165 1165
 
1166
-		if($_onCheckHandler)
1166
+		if ($_onCheckHandler)
1167 1167
 		{
1168 1168
 			$html .= "$tree.enableCheckBoxes(1);\n";
1169 1169
 			$html .= "$tree.setOnCheckHandler('$_onCheckHandler');\n";
@@ -1174,7 +1174,7 @@  discard block
 block discarded – undo
1174 1174
 		if ($autoLoading)
1175 1175
 		{
1176 1176
 			$autoLoading = is_array($autoLoading) ?
1177
-				Framework::link('/index.php',$autoLoading) : Framework::link($autoLoading);
1177
+				Framework::link('/index.php', $autoLoading) : Framework::link($autoLoading);
1178 1178
 			$html .= "$tree.setXMLAutoLoading('$autoLoading');\n";
1179 1179
 			if ($dataMode != 'XML') $html .= "$tree.setDataMode('$dataMode');\n";
1180 1180
 
@@ -1215,7 +1215,7 @@  discard block
 block discarded – undo
1215 1215
 		}
1216 1216
 		if (is_string($_folders))
1217 1217
 		{
1218
-			switch($dataMode)
1218
+			switch ($dataMode)
1219 1219
 			{
1220 1220
 				case 'JSON':
1221 1221
 					$html .= "$tree.loadJSONObject($_folders);\n"; break;
@@ -1226,10 +1226,10 @@  discard block
 block discarded – undo
1226 1226
 		else
1227 1227
 		{
1228 1228
 			// evtl. remove leading delimiter
1229
-			if ($_selected[0] == $delimiter) $_selected = substr($_selected,1);
1229
+			if ($_selected[0] == $delimiter) $_selected = substr($_selected, 1);
1230 1230
 
1231 1231
 			$n = 0;
1232
-			foreach($_folders as $path => $data)
1232
+			foreach ($_folders as $path => $data)
1233 1233
 			{
1234 1234
 				if (!is_array($data))
1235 1235
 				{
@@ -1241,10 +1241,10 @@  discard block
 block discarded – undo
1241 1241
 				if ($_leafImage)
1242 1242
 				{
1243 1243
 					$image1 = $image2 = $image3 = "'".$_leafImage."'";
1244
-					if (($next_item = array_slice($_folders, $n+1, 1, true)))
1244
+					if (($next_item = array_slice($_folders, $n + 1, 1, true)))
1245 1245
 					{
1246 1246
 						list($next_path) = each($next_item);
1247
-						if (substr($next_path,0,strlen($path)+1) == $path.'/')
1247
+						if (substr($next_path, 0, strlen($path) + 1) == $path.'/')
1248 1248
 						{
1249 1249
 							$image1 = $image2 = $image3 = '0';
1250 1250
 						}
@@ -1255,22 +1255,22 @@  discard block
 block discarded – undo
1255 1255
 					$image1 = $image2 = $image3 = "'".$data['image']."'";
1256 1256
 				}
1257 1257
 				// evtl. remove leading delimiter
1258
-				if ($path[0] == $delimiter) $path = substr($path,1);
1259
-				$folderParts = explode($delimiter,$path);
1258
+				if ($path[0] == $delimiter) $path = substr($path, 1);
1259
+				$folderParts = explode($delimiter, $path);
1260 1260
 
1261 1261
 				//get rightmost folderpart
1262 1262
 				$label = array_pop($folderParts);
1263 1263
 				if (isset($data['label'])) $label = $data['label'];
1264 1264
 
1265 1265
 				// the rest of the array is the name of the parent
1266
-				$parentName = implode((array)$folderParts,$delimiter);
1267
-				if(empty($parentName)) $parentName = $top;
1266
+				$parentName = implode((array)$folderParts, $delimiter);
1267
+				if (empty($parentName)) $parentName = $top;
1268 1268
 
1269 1269
 				$entryOptions = !isset($data['child']) || $data['child'] ? 'CHILD' : '';
1270 1270
 				if ($_onCheckHandler && $_selected)	// check selected items on multi selection
1271 1271
 				{
1272
-					if (!is_array($_selected)) $_selected = explode(',',$_selected);
1273
-					if (array_search("$path",$_selected)!==false) $entryOptions .= ',CHECKED';
1272
+					if (!is_array($_selected)) $_selected = explode(',', $_selected);
1273
+					if (array_search("$path", $_selected) !== false) $entryOptions .= ',CHECKED';
1274 1274
 					//echo "<p>path=$path, _selected=".print_r($_selected,true).": $entryOptions</p>\n";
1275 1275
 				}
1276 1276
 				// highlight current item
@@ -1290,7 +1290,7 @@  discard block
 block discarded – undo
1290 1290
 		$html .= "$tree.closeAllItems(0);\n";
1291 1291
 		if ($_selected)
1292 1292
 		{
1293
-			foreach(is_array($_selected)?$_selected:array($_selected) as $path)
1293
+			foreach (is_array($_selected) ? $_selected : array($_selected) as $path)
1294 1294
 			{
1295 1295
 				$html .= "$tree.openItem('".addslashes($path)."');\n";
1296 1296
 			}
@@ -1315,7 +1315,7 @@  discard block
 block discarded – undo
1315 1315
 	 *		or to restrict the attribute's values
1316 1316
 	 * @param boolean $_force =null - force the config passed to be used without merging to the default
1317 1317
 	 */
1318
-	static function purify($html,$config=null,$spec=array(),$_force=false)
1318
+	static function purify($html, $config = null, $spec = array(), $_force = false)
1319 1319
 	{
1320 1320
 		return Html\HtmLawed::purify($html, $config, $spec, $_force);
1321 1321
 	}
Please login to merge, or discard this patch.
api/src/Html/CkEditorConfig.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * Only return skins existing in filesystem, as we disable / remove them if not compatible with supported browsers.
67 67
 	 *
68
-	 * @return array skin => label pairs alphabetical sorted with default moono first
68
+	 * @return string skin => label pairs alphabetical sorted with default moono first
69 69
 	 */
70 70
 	public static function getAvailableCKEditorSkins()
71 71
 	{
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 * Adds all "easy to write" options to the configuration
260 260
 	 *
261 261
 	 * @param array& $config array were config get's added to
262
-	 * @param int|string $height integer height in pixel or string with css unit
262
+	 * @param integer $height integer height in pixel or string with css unit
263 263
 	 * @param boolean|string $expanded_toolbar show toolbar expanded, boolean value, string "false", or string casted to boolean
264 264
 	 * @param string $start_path start path for file browser
265 265
 	 */
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	/**
452 452
 	 * Adds extra
453 453
 	 * @param array $config
454
-	 * @param array $plugins plugins name which needs to be appended into extraPlugins
454
+	 * @param string[] $plugins plugins name which needs to be appended into extraPlugins
455 455
 	 */
456 456
 	public static function append_extraPlugins_config_array (&$config, $plugins)
457 457
 	{
Please login to merge, or discard this patch.
Braces   +64 added lines, -19 removed lines patch added patch discarded remove patch
@@ -77,7 +77,10 @@  discard block
 block discarded – undo
77 77
 
78 78
 		foreach(scandir(EGW_SERVER_ROOT.'/api/js/ckeditor/skins') as $skin)
79 79
 		{
80
-			if ($skin[0] == '.') continue;
80
+			if ($skin[0] == '.')
81
+			{
82
+				continue;
83
+			}
81 84
 
82 85
 			if (isset($labels[$skin]))
83 86
 			{
@@ -92,7 +95,10 @@  discard block
 block discarded – undo
92 95
 		
93 96
 		// flat skin is reserved for mobile template, although we are not
94 97
 		// supporting it on desktop (becuase FF has problem with action icons)
95
-		if (!\EGroupware\Api\Header\UserAgent::mobile()) unset($skins['flat']);
98
+		if (!\EGroupware\Api\Header\UserAgent::mobile())
99
+		{
100
+			unset($skins['flat']);
101
+		}
96 102
 
97 103
 		// return our default "moono" first
98 104
 		return isset($skins['moono']) ? array('moono' => $skins['moono'])+$skins : $skins;
@@ -108,7 +114,10 @@  discard block
 block discarded – undo
108 114
 	 */
109 115
 	public static function font_size_from_prefs(array $prefs=null, &$size=null, &$unit=null)
110 116
 	{
111
-		if (is_null($prefs)) $prefs = $GLOBALS['egw_info']['user']['preferences'];
117
+		if (is_null($prefs))
118
+		{
119
+			$prefs = $GLOBALS['egw_info']['user']['preferences'];
120
+		}
112 121
 
113 122
 		$size = $prefs['common']['rte_font_size'];
114 123
 		$unit = $prefs['common']['rte_font_unit'];
@@ -134,7 +143,9 @@  discard block
 block discarded – undo
134 143
 		self::$country = $GLOBALS['egw_info']['user']['preferences']['common']['country'];
135 144
 
136 145
 		if (!(strpos(self::$lang, '-')===false))
137
-			list(self::$lang, self::$country) = explode('-', self::$lang);
146
+		{
147
+					list(self::$lang, self::$country) = explode('-', self::$lang);
148
+		}
138 149
 	}
139 150
 
140 151
 	/**
@@ -143,7 +154,9 @@  discard block
 block discarded – undo
143 154
 	private static function get_lang()
144 155
 	{
145 156
 		if (self::$lang == null || self::$country == null)
146
-			self::read_lang_country();
157
+		{
158
+					self::read_lang_country();
159
+		}
147 160
 
148 161
 		return self::$lang;
149 162
 	}
@@ -154,7 +167,9 @@  discard block
 block discarded – undo
154 167
 	private static function get_country()
155 168
 	{
156 169
 		if (self::$lang == null || self::$country == null)
157
-			self::read_lang_country();
170
+		{
171
+					self::read_lang_country();
172
+		}
158 173
 
159 174
 		return strtoupper(self::$country);
160 175
 	}
@@ -292,7 +307,10 @@  discard block
 block discarded – undo
292 307
 
293 308
 		$config['fontSize_sizes'] = '';
294 309
 		$unit = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font_unit'];
295
-		if (empty($unit)) $unit = 'px';
310
+		if (empty($unit))
311
+		{
312
+			$unit = 'px';
313
+		}
296 314
 		foreach(self::$font_size_options as $k => $v)
297 315
 		{
298 316
 			$config['fontSize_sizes'] .= $v.$unit.'/'.$k.$unit.';';
@@ -361,8 +379,14 @@  discard block
 block discarded – undo
361 379
 				if ($spellchecker_button||$scayt_button)
362 380
 				{
363 381
 					$configArray = array();
364
-					if ($spellchecker_button) $configArray[] = $spellchecker_button;
365
-					if ($scayt_button) $configArray[] = $scayt_button;
382
+					if ($spellchecker_button)
383
+					{
384
+						$configArray[] = $spellchecker_button;
385
+					}
386
+					if ($scayt_button)
387
+					{
388
+						$configArray[] = $scayt_button;
389
+					}
366 390
 					$config['toolbar'][] = array('name' => 'tools', 'items' => $configArray);
367 391
 				}
368 392
 				$config['toolbar'][] = array('name' => 'edit', 'items' => array('Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'));
@@ -394,12 +418,20 @@  discard block
 block discarded – undo
394 418
 					if ($spellchecker_button||$scayt_button)
395 419
 					{
396 420
 						$configArray = array('Maximize');
397
-						if ($spellchecker_button) $configArray[] = $spellchecker_button;
398
-						if ($scayt_button) $configArray[] = $scayt_button;
421
+						if ($spellchecker_button)
422
+						{
423
+							$configArray[] = $spellchecker_button;
424
+						}
425
+						if ($scayt_button)
426
+						{
427
+							$configArray[] = $scayt_button;
428
+						}
399 429
 						$config['toolbar'][] = array('name' => 'tools', 'items' => $configArray);
400 430
 					}
401
-					else
402
-						$config['toolbar'][] = array('name' => 'insert', 'items' => array('Maximize'));//, 'Image', 'Table');
431
+					else {
432
+											$config['toolbar'][] = array('name' => 'insert', 'items' => array('Maximize'));
433
+					}
434
+					//, 'Image', 'Table');
403 435
 
404 436
 					$config['toolbar'][count($config['toolbar']) - 1][] = array('name' => 'insert', 'items' => array('Image', 'Table'));
405 437
 				}
@@ -408,17 +440,27 @@  discard block
 block discarded – undo
408 440
 					if ($spellchecker_button||$scayt_button)
409 441
 					{
410 442
 						$configArray = array('Maximize');
411
-						if ($spellchecker_button) $configArray[] = $spellchecker_button;
412
-						if ($scayt_button) $configArray[] = $scayt_button;
443
+						if ($spellchecker_button)
444
+						{
445
+							$configArray[] = $spellchecker_button;
446
+						}
447
+						if ($scayt_button)
448
+						{
449
+							$configArray[] = $scayt_button;
450
+						}
413 451
 						$config['toolbar'][] = array('name' => 'tools', 'items' => $configArray);
414 452
 					}
415
-					else
416
-						$config['toolbar'][] = array('name' => 'tools', 'items' => array('Maximize'));
453
+					else {
454
+											$config['toolbar'][] = array('name' => 'tools', 'items' => array('Maximize'));
455
+					}
417 456
 				}
418 457
 
419 458
 				$config['toolbar'][] = '/';
420 459
 				$config['toolbar'][] = array('name' => 'edit', 'items' => array('Find','Replace','-','SelectAll','RemoveFormat'));
421
-				if ($mode == 'simple-withimage') $config['toolbar'][] = array('name' => 'links', 'items' => array('Image','Link','Unlink'));
460
+				if ($mode == 'simple-withimage')
461
+				{
462
+					$config['toolbar'][] = array('name' => 'links', 'items' => array('Image','Link','Unlink'));
463
+				}
422 464
 				$config['toolbar'][] = array('name' => 'styles', 'items' => array('Format','Font','FontSize'));
423 465
 				$config['toolbar'][] = array('name' => 'colors', 'items' => array('TextColor','BGColor'));
424 466
 				$config['toolbar'][] = array('name' => 'tools', 'items' => array('ShowBlocks','-','About'));
@@ -434,7 +476,10 @@  discard block
 block discarded – undo
434 476
 		self::set_csp_script_src_attrs();
435 477
 
436 478
 		// If not explicitly set, use preference for toolbar mode
437
-		if(!$mode || trim($mode) == '') $mode = $GLOBALS['egw_info']['user']['preferences']['common']['rte_features'];
479
+		if(!$mode || trim($mode) == '')
480
+		{
481
+			$mode = $GLOBALS['egw_info']['user']['preferences']['common']['rte_features'];
482
+		}
438 483
 		$config = array();
439 484
 		$spellchecker_button = null;
440 485
 
Please login to merge, or discard this patch.
Spacing   +38 added lines, -39 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 		);
76 76
 		$skins = array();
77 77
 
78
-		foreach(scandir(EGW_SERVER_ROOT.'/vendor/egroupware/ckeditor/skins') as $skin)
78
+		foreach (scandir(EGW_SERVER_ROOT.'/vendor/egroupware/ckeditor/skins') as $skin)
79 79
 		{
80 80
 			if ($skin[0] == '.') continue;
81 81
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		if (!\EGroupware\Api\Header\UserAgent::mobile()) unset($skins['flat']);
96 96
 
97 97
 		// return our default "moono" first
98
-		return isset($skins['moono']) ? array('moono' => $skins['moono'])+$skins : $skins;
98
+		return isset($skins['moono']) ? array('moono' => $skins['moono']) + $skins : $skins;
99 99
 	}
100 100
 
101 101
 	/**
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @param string &$unit =null on return just unit
107 107
 	 * @return string font-size including unit
108 108
 	 */
109
-	public static function font_size_from_prefs(array $prefs=null, &$size=null, &$unit=null)
109
+	public static function font_size_from_prefs(array $prefs = null, &$size = null, &$unit = null)
110 110
 	{
111 111
 		if (is_null($prefs)) $prefs = $GLOBALS['egw_info']['user']['preferences'];
112 112
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 			$unit = 'px';
118 118
 			$size = (string)(int)$size;
119 119
 		}
120
-		return $size.($size?$unit:'');
120
+		return $size.($size ? $unit : '');
121 121
 	}
122 122
 
123 123
 	/**
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
 		self::$country = $GLOBALS['egw_info']['user']['preferences']['common']['country'];
133 133
 
134
-		if (!(strpos(self::$lang, '-')===false))
134
+		if (!(strpos(self::$lang, '-') === false))
135 135
 			list(self::$lang, self::$country) = explode('-', self::$lang);
136 136
 	}
137 137
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 				$skin = "moono"; //this is the basic skin for ckeditor
237 237
 			}
238 238
 			// Skin used for mobile template
239
-			self::$skin = \EGroupware\Api\Header\UserAgent::mobile()?'flat':$skin;
239
+			self::$skin = \EGroupware\Api\Header\UserAgent::mobile() ? 'flat' : $skin;
240 240
 		}
241 241
 
242 242
 		return self::$skin;
@@ -277,8 +277,7 @@  discard block
 block discarded – undo
277 277
 		$config['removePlugins'] = 'elementspath';
278 278
 
279 279
 		$config['toolbarCanCollapse'] = true;
280
-		$config['toolbarStartupExpanded'] = is_bool($expanded_toolbar) ? $expanded_toolbar :
281
-			($expanded_toolbar === 'false' ? false : (boolean)$expanded_toolbar);
280
+		$config['toolbarStartupExpanded'] = is_bool($expanded_toolbar) ? $expanded_toolbar : ($expanded_toolbar === 'false' ? false : (boolean)$expanded_toolbar);
282 281
 
283 282
 		$config['filebrowserBrowseUrl'] = self::get_filebrowserBrowseUrl($start_path);
284 283
 		$config['filebrowserWindowHeight'] = 640;
@@ -291,7 +290,7 @@  discard block
 block discarded – undo
291 290
 		$config['fontSize_sizes'] = '';
292 291
 		$unit = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font_unit'];
293 292
 		if (empty($unit)) $unit = 'px';
294
-		foreach(self::$font_size_options as $k => $v)
293
+		foreach (self::$font_size_options as $k => $v)
295 294
 		{
296 295
 			$config['fontSize_sizes'] .= $v.$unit.'/'.$k.$unit.';';
297 296
 		}
@@ -348,48 +347,48 @@  discard block
 block discarded – undo
348 347
 	 * Writes the toolbar configuration to the options which depends on the chosen
349 348
 	 * mode and the spellchecker_button written by the add_spellchecker_options button
350 349
 	 */
351
-	private static function add_toolbar_options(&$config, $mode, $spellchecker_button, $scayt_button=false)
350
+	private static function add_toolbar_options(&$config, $mode, $spellchecker_button, $scayt_button = false)
352 351
 	{
353 352
 		$config['toolbar'] = array();
354 353
 		switch ($mode)
355 354
 		{
356 355
 			case 'advanced':
357
-				$config['toolbar'][] = array('name' => 'document', 'items' => array('Source','DocProps','-','Preview','-','Templates'));
358
-				$config['toolbar'][] = array('name' => 'clipboard', 'items' => array('Cut','Copy','Paste','PasteText','PasteFromWord','-','Print'));
359
-				if ($spellchecker_button||$scayt_button)
356
+				$config['toolbar'][] = array('name' => 'document', 'items' => array('Source', 'DocProps', '-', 'Preview', '-', 'Templates'));
357
+				$config['toolbar'][] = array('name' => 'clipboard', 'items' => array('Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Print'));
358
+				if ($spellchecker_button || $scayt_button)
360 359
 				{
361 360
 					$configArray = array();
362 361
 					if ($spellchecker_button) $configArray[] = $spellchecker_button;
363 362
 					if ($scayt_button) $configArray[] = $scayt_button;
364 363
 					$config['toolbar'][] = array('name' => 'tools', 'items' => $configArray);
365 364
 				}
366
-				$config['toolbar'][] = array('name' => 'edit', 'items' => array('Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'));
365
+				$config['toolbar'][] = array('name' => 'edit', 'items' => array('Undo', 'Redo', '-', 'Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'));
367 366
 
368 367
 				$config['toolbar'][] = '/';
369 368
 
370
-				$config['toolbar'][] = array('name' => 'basicstyles', 'items' => array('Bold','Italic','Underline','Strike','-','Subscript','Superscript'));
371
-				$config['toolbar'][] = array('name' => 'justify', 'items' => array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'));
372
-				$config['toolbar'][] = array('name' => 'paragraph', 'items' => array('BulletedList','NumberedList','-','Outdent','Indent'));
373
-				$config['toolbar'][] = array('name' => 'links', 'items' => array('Link','Unlink','Anchor'));
374
-				$config['toolbar'][] = array('name' => 'insert', 'items' => array('Maximize','Image','Table','HorizontalRule','SpecialChar'/*,'Smiley'*/));
369
+				$config['toolbar'][] = array('name' => 'basicstyles', 'items' => array('Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript'));
370
+				$config['toolbar'][] = array('name' => 'justify', 'items' => array('JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'));
371
+				$config['toolbar'][] = array('name' => 'paragraph', 'items' => array('BulletedList', 'NumberedList', '-', 'Outdent', 'Indent'));
372
+				$config['toolbar'][] = array('name' => 'links', 'items' => array('Link', 'Unlink', 'Anchor'));
373
+				$config['toolbar'][] = array('name' => 'insert', 'items' => array('Maximize', 'Image', 'Table', 'HorizontalRule', 'SpecialChar'/*,'Smiley'*/));
375 374
 
376 375
 				$config['toolbar'][] = '/';
377 376
 
378
-				$config['toolbar'][] = array('name' => 'styles', 'items' => array('Style','Format','Font','FontSize'));
379
-				$config['toolbar'][] = array('name' => 'colors', 'items' => array('TextColor','BGColor'));
380
-				$config['toolbar'][] = array('name' => 'tools', 'items' => array('ShowBlocks','-','About'));
377
+				$config['toolbar'][] = array('name' => 'styles', 'items' => array('Style', 'Format', 'Font', 'FontSize'));
378
+				$config['toolbar'][] = array('name' => 'colors', 'items' => array('TextColor', 'BGColor'));
379
+				$config['toolbar'][] = array('name' => 'tools', 'items' => array('ShowBlocks', '-', 'About'));
381 380
 				break;
382 381
 
383 382
 			case 'extended': default:
384
-				$config['toolbar'][] = array('name' => 'clipboard', 'items' => array('Bold','Italic','Underline'));
385
-				$config['toolbar'][] = array('name' => 'justify', 'items' => array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'));
386
-				$config['toolbar'][] = array('name' => 'paragraph', 'items' => array('BulletedList','NumberedList'/*,'Smiley'*/,'Outdent','Indent','Undo','Redo'));
387
-				$config['toolbar'][] = array('name' => 'clipboard', 'items' => array('Cut','Copy','Paste','PasteText','PasteFromWord','-','Print'));
383
+				$config['toolbar'][] = array('name' => 'clipboard', 'items' => array('Bold', 'Italic', 'Underline'));
384
+				$config['toolbar'][] = array('name' => 'justify', 'items' => array('JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'));
385
+				$config['toolbar'][] = array('name' => 'paragraph', 'items' => array('BulletedList', 'NumberedList'/*,'Smiley'*/, 'Outdent', 'Indent', 'Undo', 'Redo'));
386
+				$config['toolbar'][] = array('name' => 'clipboard', 'items' => array('Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Print'));
388 387
 
389 388
 				if ($mode == 'extended')
390 389
 				{
391
-					$config['toolbar'][] = array('name' => 'insert', 'items' => array('Image','Link','Unlink','Anchor'));
392
-					if ($spellchecker_button||$scayt_button)
390
+					$config['toolbar'][] = array('name' => 'insert', 'items' => array('Image', 'Link', 'Unlink', 'Anchor'));
391
+					if ($spellchecker_button || $scayt_button)
393 392
 					{
394 393
 						$configArray = array('Maximize');
395 394
 						if ($spellchecker_button) $configArray[] = $spellchecker_button;
@@ -397,13 +396,13 @@  discard block
 block discarded – undo
397 396
 						$config['toolbar'][] = array('name' => 'tools', 'items' => $configArray);
398 397
 					}
399 398
 					else
400
-						$config['toolbar'][] = array('name' => 'insert', 'items' => array('Maximize'));//, 'Image', 'Table');
399
+						$config['toolbar'][] = array('name' => 'insert', 'items' => array('Maximize')); //, 'Image', 'Table');
401 400
 
402 401
 					$config['toolbar'][count($config['toolbar']) - 1][] = array('name' => 'insert', 'items' => array('Image', 'Table'));
403 402
 				}
404 403
 				else
405 404
 				{
406
-					if ($spellchecker_button||$scayt_button)
405
+					if ($spellchecker_button || $scayt_button)
407 406
 					{
408 407
 						$configArray = array('Maximize');
409 408
 						if ($spellchecker_button) $configArray[] = $spellchecker_button;
@@ -415,11 +414,11 @@  discard block
 block discarded – undo
415 414
 				}
416 415
 
417 416
 				$config['toolbar'][] = '/';
418
-				$config['toolbar'][] = array('name' => 'edit', 'items' => array('Find','Replace','-','SelectAll','RemoveFormat'));
419
-				if ($mode == 'simple-withimage') $config['toolbar'][] = array('name' => 'links', 'items' => array('Image','Link','Unlink'));
420
-				$config['toolbar'][] = array('name' => 'styles', 'items' => array('Format','Font','FontSize'));
421
-				$config['toolbar'][] = array('name' => 'colors', 'items' => array('TextColor','BGColor'));
422
-				$config['toolbar'][] = array('name' => 'tools', 'items' => array('ShowBlocks','-','About'));
417
+				$config['toolbar'][] = array('name' => 'edit', 'items' => array('Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'));
418
+				if ($mode == 'simple-withimage') $config['toolbar'][] = array('name' => 'links', 'items' => array('Image', 'Link', 'Unlink'));
419
+				$config['toolbar'][] = array('name' => 'styles', 'items' => array('Format', 'Font', 'FontSize'));
420
+				$config['toolbar'][] = array('name' => 'colors', 'items' => array('TextColor', 'BGColor'));
421
+				$config['toolbar'][] = array('name' => 'tools', 'items' => array('ShowBlocks', '-', 'About'));
423 422
 		}
424 423
 	}
425 424
 
@@ -432,7 +431,7 @@  discard block
 block discarded – undo
432 431
 		self::set_csp_script_src_attrs();
433 432
 
434 433
 		// If not explicitly set, use preference for toolbar mode
435
-		if(!$mode || trim($mode) == '') $mode = $GLOBALS['egw_info']['user']['preferences']['common']['rte_features'];
434
+		if (!$mode || trim($mode) == '') $mode = $GLOBALS['egw_info']['user']['preferences']['common']['rte_features'];
436 435
 		$config = array();
437 436
 		$spellchecker_button = null;
438 437
 
@@ -442,7 +441,7 @@  discard block
 block discarded – undo
442 441
 		self::add_toolbar_options($config, $mode, $spellchecker_button, $scayt_button);
443 442
 		//error_log(__METHOD__."('$mode', $height, ".array2string($expanded_toolbar).") returning ".array2string($config));
444 443
 		// Add extra plugins
445
-		self::append_extraPlugins_config_array($config, array('uploadimage','uploadwidget','widget','notification','notificationaggregator','lineutils'));
444
+		self::append_extraPlugins_config_array($config, array('uploadimage', 'uploadwidget', 'widget', 'notification', 'notificationaggregator', 'lineutils'));
446 445
 		return $config;
447 446
 	}
448 447
 
@@ -451,7 +450,7 @@  discard block
 block discarded – undo
451 450
 	 * @param array $config
452 451
 	 * @param array $plugins plugins name which needs to be appended into extraPlugins
453 452
 	 */
454
-	public static function append_extraPlugins_config_array (&$config, $plugins)
453
+	public static function append_extraPlugins_config_array(&$config, $plugins)
455 454
 	{
456 455
 		if (is_array($plugins))
457 456
 		{
@@ -459,7 +458,7 @@  discard block
 block discarded – undo
459 458
 			{
460 459
 				if (!empty($config['extraPlugins']) && $config['extraPlugins'] !== '')
461 460
 				{
462
-					$config['extraPlugins'] .= ',' . $plugin;
461
+					$config['extraPlugins'] .= ','.$plugin;
463 462
 				}
464 463
 				else
465 464
 				{
Please login to merge, or discard this patch.
api/src/Html/HtmLawed.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@
 block discarded – undo
104 104
 	 * @param varchar $html2check =text input Text to check
105 105
 	 * @param mixed $Config = text or array
106 106
 	 * @param mixed $Spec =text or array; The '$spec' argument can be used to disallow an otherwise legal attribute for an element
107
-	 * @return varchar cleaned/fixed html
107
+	 * @return string cleaned/fixed html
108 108
 	 */
109 109
 	function run($html2check, $Config=null, $Spec=array())
110 110
 	{
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 		*/
86 86
 
87 87
 		$this->Configuration = array('comment'=>1, //remove comments
88
-			'make_tag_strict'=>3,//3 is a new own config value, to indicate that transformation is to be performed, but don't transform font, as size transformation of numeric sizes to keywords alters the intended result too much
89
-			'balance'=>0,//turn off tag-balancing (config['balance']=>0). That will not introduce any security risk; only standards-compliant tag nesting check/filtering will be turned off (basic tag-balance will remain; i.e., there won't be any unclosed tag, etc., after filtering)
88
+			'make_tag_strict'=>3, //3 is a new own config value, to indicate that transformation is to be performed, but don't transform font, as size transformation of numeric sizes to keywords alters the intended result too much
89
+			'balance'=>0, //turn off tag-balancing (config['balance']=>0). That will not introduce any security risk; only standards-compliant tag nesting check/filtering will be turned off (basic tag-balance will remain; i.e., there won't be any unclosed tag, etc., after filtering)
90 90
 			// tidy eats away even some wanted whitespace, so we switch it off;
91 91
 			// we used it for its compacting and beautifying capabilities, which resulted in better html for further processing
92 92
 			'tidy'=>0,
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @param mixed $Spec =text or array; The '$spec' argument can be used to disallow an otherwise legal attribute for an element
107 107
 	 * @return varchar cleaned/fixed html
108 108
 	 */
109
-	function run($html2check, $Config=null, $Spec=array())
109
+	function run($html2check, $Config = null, $Spec = array())
110 110
 	{
111 111
 		//error_log(__METHOD__.__LINE__.' Input:'.$html2check);
112 112
 		if (is_array($Config) && is_array($this->Configuration)) $Config = array_merge($this->Configuration, $Config);
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
 		//error_log(__METHOD__.__LINE__.' Config:'.array2string($Config));
122 122
 
123 123
 		// mind our namespace when defining a function as hook. we handle our own defined hooks here.
124
-		if ($Config['hook_tag']=="hl_my_tag_transform" || $Config['hook_tag']=="hl_email_tag_transform")
124
+		if ($Config['hook_tag'] == "hl_my_tag_transform" || $Config['hook_tag'] == "hl_email_tag_transform")
125 125
 		{
126
-			$Config['hook_tag']=__NAMESPACE__.'\\'.$Config['hook_tag'];
126
+			$Config['hook_tag'] = __NAMESPACE__.'\\'.$Config['hook_tag'];
127 127
 		}
128
-		return ($styles?$styles:'').htmLawed($html2check, $Config, $Spec);
128
+		return ($styles ? $styles : '').htmLawed($html2check, $Config, $Spec);
129 129
 	}
130 130
 
131 131
 	/**
@@ -137,16 +137,16 @@  discard block
 block discarded – undo
137 137
 	 */
138 138
 	static function getStyles(&$html)
139 139
 	{
140
-		$ct=0;
140
+		$ct = 0;
141 141
 		$newStyle = null;
142
-		if (stripos($html,'<style')!==false)  $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $html, $newStyle);
143
-		if ($ct>0)
142
+		if (stripos($html, '<style') !== false)  $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $html, $newStyle);
143
+		if ($ct > 0)
144 144
 		{
145 145
 			//error_log(__METHOD__.__LINE__.array2string($newStyle[0]));
146
-			$style2buffer = implode('',$newStyle[0]);
146
+			$style2buffer = implode('', $newStyle[0]);
147 147
 			// only replace what we have found, we use it here, as we use the same routine in Api\Mail\Html::replaceTagsCompletley
148 148
 			// no need to do the extra routine
149
-			$html = str_ireplace($newStyle[0],'',$html);
149
+			$html = str_ireplace($newStyle[0], '', $html);
150 150
 		}
151 151
 		if ($style2buffer)
152 152
 		{
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 			$test = json_encode($style2buffer);
155 155
 			//error_log(__METHOD__.__LINE__.'#'.$test.'# ->'.strlen($style2buffer).' Error:'.json_last_error());
156 156
 			//if (json_last_error() != JSON_ERROR_NONE && strlen($style2buffer)>0)
157
-			if ($test=="null" && strlen($style2buffer)>0)
157
+			if ($test == "null" && strlen($style2buffer) > 0)
158 158
 			{
159 159
 				// this should not be needed, unless something fails with charset detection/ wrong charset passed
160 160
 				error_log(__METHOD__.__LINE__.' Found Invalid sequence for utf-8 in CSS:'.$style2buffer.' Carset Detected:'.Api\Translation::detect_encoding($style2buffer));
@@ -164,19 +164,19 @@  discard block
 block discarded – undo
164 164
 		$style .= $style2buffer;
165 165
 		// clean out comments and stuff
166 166
 		$search = array(
167
-			'@url\(http:\/\/[^\)].*?\)@si',  // url calls e.g. in style definitions
167
+			'@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions
168 168
 //			'@<!--[\s\S]*?[ \t\n\r]*-->@',   // Strip multi-line comments including CDATA
169 169
 //			'@<!--[\s\S]*?[ \t\n\r]*--@',    // Strip broken multi-line comments including CDATA
170 170
 		);
171
-		$style = preg_replace($search,"",$style);
171
+		$style = preg_replace($search, "", $style);
172 172
 
173 173
 		// CSS Security
174 174
 		// http://code.google.com/p/browsersec/wiki/Part1#Cascading_stylesheets
175
-		$css = preg_replace('/(javascript|expession|-moz-binding)/i','',$style);
176
-		if (stripos($css,'script')!==false) Api\Mail\Html::replaceTagsCompletley($css,'script'); // Strip out script that may be included
175
+		$css = preg_replace('/(javascript|expession|-moz-binding)/i', '', $style);
176
+		if (stripos($css, 'script') !== false) Api\Mail\Html::replaceTagsCompletley($css, 'script'); // Strip out script that may be included
177 177
 		// we need this, as styledefinitions are enclosed with curly brackets; and template stuff tries to replace everything between curly brackets that is having no horizontal whitespace
178 178
 		// as the comments as <!-- styledefinition --> in stylesheet are outdated, and ck-editor does not understand it, we remove it
179
-		$css_no_comment = str_replace(array(':','<!--','-->'),array(': ','',''),$css);
179
+		$css_no_comment = str_replace(array(':', '<!--', '-->'), array(': ', '', ''), $css);
180 180
 		//error_log(__METHOD__.__LINE__.$css);
181 181
 		// we already removed what we have found, above, as we used pretty much the same routine as in Api\Mail\Html::replaceTagsCompletley
182 182
 		// no need to do the extra routine
@@ -195,15 +195,15 @@  discard block
 block discarded – undo
195 195
 	 *		or to restrict the attribute's values
196 196
 	 * @param boolean $_force =null - force the config passed to be used without merging to the default
197 197
 	 */
198
-	static function purify($html,$config=null,$spec=array(),$_force=false)
198
+	static function purify($html, $config = null, $spec = array(), $_force = false)
199 199
 	{
200
-		$defaultConfig = array('valid_xhtml'=>1,'safe'=>1);
200
+		$defaultConfig = array('valid_xhtml'=>1, 'safe'=>1);
201 201
 
202
-		if (empty($html)) return $html;	// no need to process further
202
+		if (empty($html)) return $html; // no need to process further
203 203
 		if (!empty($config) && is_string($config))
204 204
 		{
205 205
 			//error_log(__METHOD__.__LINE__.$config);
206
-			$config = json_decode($config,true);
206
+			$config = json_decode($config, true);
207 207
 			if (is_null($config)) error_log(__METHOD__.__LINE__." decoding of config failed; standard will be applied");
208 208
 		}
209 209
 
@@ -213,15 +213,15 @@  discard block
 block discarded – undo
213 213
 
214 214
 		// Check for "blank" = just user preference span - for some reason we can't match on the entity, so approximate
215 215
 		$regex = '#^<span style="font-family:'.$font.';font-size:'.$font_size.';">.?</span>$#us';
216
-		if(preg_match($regex,$html))
216
+		if (preg_match($regex, $html))
217 217
 		{
218 218
 			return '';
219 219
 		}
220 220
 		$htmLawed = new HtmLawed();
221
-		if (is_array($config) && $_force===false) $config = array_merge($defaultConfig, $config);
221
+		if (is_array($config) && $_force === false) $config = array_merge($defaultConfig, $config);
222 222
 		if (empty($config)) $config = $defaultConfig;
223 223
 		//error_log(__METHOD__.__LINE__.array2string($config));
224
-		return $htmLawed->run($html,$config,$spec);
224
+		return $htmLawed->run($html, $config, $spec);
225 225
 	}
226 226
 }
227 227
 
@@ -233,17 +233,17 @@  discard block
 block discarded – undo
233 233
  * 						a checking for title, replacing @
234 234
  * 						blockquote checking for cite, replacing @
235 235
  */
236
-function hl_my_tag_transform($element, $attribute_array=0)
236
+function hl_my_tag_transform($element, $attribute_array = 0)
237 237
 {
238 238
 	// If second argument is not received, it means a closing tag is being handled
239
-	if(is_numeric($attribute_array)){
239
+	if (is_numeric($attribute_array)) {
240 240
 		return "</$element>";
241 241
 	}
242 242
 
243 243
 	//if ($element=='img') error_log(__METHOD__.__LINE__." ".$element.'->'.array2string($attribute_array));
244
-	if ($element=='td' && isset($attribute_array['background']))
244
+	if ($element == 'td' && isset($attribute_array['background']))
245 245
 	{
246
-		if (is_object($GLOBALS['egw']) && stripos($attribute_array['background'],$GLOBALS['egw']->link('/index.php'))!==false)
246
+		if (is_object($GLOBALS['egw']) && stripos($attribute_array['background'], $GLOBALS['egw']->link('/index.php')) !== false)
247 247
 		{
248 248
 			//error_log(__METHOD__.__LINE__.array2string($attribute_array));
249 249
 			//$attribute_array['background'] = 'url('.$attribute_array['background'].');';
@@ -251,25 +251,25 @@  discard block
 block discarded – undo
251 251
 		else
252 252
 		{
253 253
 			// $attribute_array['background']='denied:'.$attribute_array['background'];
254
-			unset($attribute_array['background']);// only internal background images are allowed
254
+			unset($attribute_array['background']); // only internal background images are allowed
255 255
 		}
256 256
 	}
257 257
 	// Elements other than 'img' or 'img' without a 'img' attribute are returned unchanged
258
-	if($element == 'img')
258
+	if ($element == 'img')
259 259
 	{
260 260
 		// Re-build 'alt'
261
-		if (isset($attribute_array['alt'])) $attribute_array['alt'] = ($attribute_array['alt']=='image'?'':$attribute_array['alt']);
262
-		if (isset($attribute_array['alt'])&&strpos($attribute_array['alt'],'@')!==false) $attribute_array['alt']=str_replace('@','(at)',$attribute_array['alt']);
261
+		if (isset($attribute_array['alt'])) $attribute_array['alt'] = ($attribute_array['alt'] == 'image' ? '' : $attribute_array['alt']);
262
+		if (isset($attribute_array['alt']) && strpos($attribute_array['alt'], '@') !== false) $attribute_array['alt'] = str_replace('@', '(at)', $attribute_array['alt']);
263 263
 	}
264 264
 	if (isset($attribute_array['title']))
265 265
 	{
266
-		if (strpos($attribute_array['title'],'@')!==false) $attribute_array['title']=str_replace('@','(at)',$attribute_array['title']);
266
+		if (strpos($attribute_array['title'], '@') !== false) $attribute_array['title'] = str_replace('@', '(at)', $attribute_array['title']);
267 267
 	}
268 268
 	if ($element == 'blockquote')
269 269
 	{
270 270
 		if (isset($attribute_array['cite']))
271 271
 		{
272
-			if (strpos($attribute_array['cite'],'@')!==false) $attribute_array['cite']=str_replace('@','(at)',$attribute_array['cite']);
272
+			if (strpos($attribute_array['cite'], '@') !== false) $attribute_array['cite'] = str_replace('@', '(at)', $attribute_array['cite']);
273 273
 		}
274 274
 	}
275 275
 	/*
@@ -301,31 +301,31 @@  discard block
 block discarded – undo
301 301
 		$attribute_array['style'] = implode('; ', $style);
302 302
 	}
303 303
 	*/
304
-	if (isset($attribute_array['style']) && stripos($attribute_array['style'],'script')!==false) $attribute_array['style'] = str_ireplace('script','',$attribute_array['style']);
305
-	if($element == 'a')
304
+	if (isset($attribute_array['style']) && stripos($attribute_array['style'], 'script') !== false) $attribute_array['style'] = str_ireplace('script', '', $attribute_array['style']);
305
+	if ($element == 'a')
306 306
 	{
307 307
 		//error_log(__METHOD__.__LINE__.array2string($attribute_array));
308 308
 		// rebuild Anchors, if processed by hl_email_tag_transform
309
-		if (strpos($attribute_array['href'],"denied:javascript:GoToAnchor('")===0)
309
+		if (strpos($attribute_array['href'], "denied:javascript:GoToAnchor('") === 0)
310 310
 		{
311
-			$attribute_array['href']=str_ireplace("');",'',str_ireplace("denied:javascript:GoToAnchor('","#",$attribute_array['href']));
311
+			$attribute_array['href'] = str_ireplace("');", '', str_ireplace("denied:javascript:GoToAnchor('", "#", $attribute_array['href']));
312 312
 		}
313
-		if (strpos($attribute_array['href'],"javascript:GoToAnchor('")===0)
313
+		if (strpos($attribute_array['href'], "javascript:GoToAnchor('") === 0)
314 314
 		{
315
-			$attribute_array['href']=str_ireplace("');",'',str_ireplace("javascript:GoToAnchor('","#",$attribute_array['href']));
315
+			$attribute_array['href'] = str_ireplace("');", '', str_ireplace("javascript:GoToAnchor('", "#", $attribute_array['href']));
316 316
 		}
317
-		if (strpos($attribute_array['href'],'denied:javascript')===0) $attribute_array['href']='';
317
+		if (strpos($attribute_array['href'], 'denied:javascript') === 0) $attribute_array['href'] = '';
318 318
 	}
319 319
 
320 320
 	// Build the attributes string
321 321
 	$attributes = '';
322
-	foreach($attribute_array as $k=>$v){
322
+	foreach ($attribute_array as $k=>$v) {
323 323
 		$attributes .= " {$k}=\"{$v}\"";
324 324
 	}
325 325
 
326 326
 	// Return the opening tag with attributes
327 327
 	static $empty_elements = array('area'=>1, 'br'=>1, 'col'=>1, 'embed'=>1, 'hr'=>1, 'img'=>1, 'input'=>1, 'isindex'=>1, 'param'=>1);
328
-	return "<{$element}{$attributes}". (isset($empty_elements[$element]) ? ' /' : ''). '>';
328
+	return "<{$element}{$attributes}".(isset($empty_elements[$element]) ? ' /' : '').'>';
329 329
 }
330 330
 
331 331
 /**
@@ -339,22 +339,22 @@  discard block
 block discarded – undo
339 339
  * 						blockquote -checking for cite, replacing @
340 340
  * 						throwing away excess div elements, that carry no style or class or id info
341 341
  */
342
-function hl_email_tag_transform($element, $attribute_array=0)
342
+function hl_email_tag_transform($element, $attribute_array = 0)
343 343
 {
344 344
 	//error_log(__METHOD__.__LINE__.$element.'=>'.array2string($attribute_array));
345 345
 	static $lastelement = null;
346 346
 	static $throwawaycounter = null;
347
-	if (is_null($lastelement)) $lastelement='';
347
+	if (is_null($lastelement)) $lastelement = '';
348 348
 	if (is_null($throwawaycounter)) $throwawaycounter = 0;
349 349
 	//if ($throwawaycounter>1) error_log(__METHOD__.__LINE__.' '.$throwawaycounter.$element.array2string($attribute_array));
350
-	if ($element=='div' && $element==$lastelement && ($attribute_array==0 || empty($attribute_array)))
350
+	if ($element == 'div' && $element == $lastelement && ($attribute_array == 0 || empty($attribute_array)))
351 351
 	{
352 352
 		if (is_array($attribute_array)) $throwawaycounter++;
353
-		if ($attribute_array==0 && $throwawaycounter>0) $throwawaycounter--;
354
-		if ($throwawaycounter>1) return '';
353
+		if ($attribute_array == 0 && $throwawaycounter > 0) $throwawaycounter--;
354
+		if ($throwawaycounter > 1) return '';
355 355
 	}
356
-	if ($lastelement=='div' && $element!=$lastelement && is_array($attribute_array)) $throwawaycounter = 0;
357
-	if (is_array($attribute_array) && !empty($attribute_array) && $element=='div')
356
+	if ($lastelement == 'div' && $element != $lastelement && is_array($attribute_array)) $throwawaycounter = 0;
357
+	if (is_array($attribute_array) && !empty($attribute_array) && $element == 'div')
358 358
 	{
359 359
 		$lastelement = 'div_with_attr';
360 360
 	}
@@ -363,15 +363,15 @@  discard block
 block discarded – undo
363 363
 		if (is_array($attribute_array)) $lastelement = $element;
364 364
 	}
365 365
 	// If second argument is not received, it means a closing tag is being handled
366
-	if(is_numeric($attribute_array)){
367
-		if($element==$lastelement) $lastelement='';
366
+	if (is_numeric($attribute_array)) {
367
+		if ($element == $lastelement) $lastelement = '';
368 368
 		return "</$element>";
369 369
 	}
370 370
 
371 371
 	//if ($element=='a') error_log(__METHOD__.__LINE__." ".$element.'->'.array2string($attribute_array));
372
-	if ($element=='td' && isset($attribute_array['background']))
372
+	if ($element == 'td' && isset($attribute_array['background']))
373 373
 	{
374
-		if (stripos($attribute_array['background'],'cid:')!==false)
374
+		if (stripos($attribute_array['background'], 'cid:') !== false)
375 375
 		{
376 376
 			//error_log(__METHOD__.__LINE__.array2string($attribute_array));
377 377
 			//$attribute_array['background'] = 'url('.$attribute_array['background'].');';
@@ -379,77 +379,77 @@  discard block
 block discarded – undo
379 379
 		else
380 380
 		{
381 381
 			// $attribute_array['background']='denied:'.$attribute_array['background'];
382
-			unset($attribute_array['background']);// only cid style background images are allowed
382
+			unset($attribute_array['background']); // only cid style background images are allowed
383 383
 		}
384 384
 	}
385 385
 	// Elements other than 'img' or 'img' without a 'img' attribute are returned unchanged
386
-	if($element == 'img')
386
+	if ($element == 'img')
387 387
 	{
388 388
 		// Re-build 'alt'
389
-		if (isset($attribute_array['alt'])) $attribute_array['alt'] = ($attribute_array['alt']=='image'?'':$attribute_array['alt']);
390
-		if (isset($attribute_array['alt'])&&strpos($attribute_array['alt'],'@')!==false) $attribute_array['alt']=str_replace('@','(at)',$attribute_array['alt']);
389
+		if (isset($attribute_array['alt'])) $attribute_array['alt'] = ($attribute_array['alt'] == 'image' ? '' : $attribute_array['alt']);
390
+		if (isset($attribute_array['alt']) && strpos($attribute_array['alt'], '@') !== false) $attribute_array['alt'] = str_replace('@', '(at)', $attribute_array['alt']);
391 391
 		// $GLOBALS['egw_info']['user']['preferences']['mail']['allowExternalIMGs'] ? '' : 'match' => '/^cid:.*/'),
392 392
 		if (isset($attribute_array['src']))
393 393
 		{
394
-			if (!(strlen($attribute_array['src'])>4 && strlen($attribute_array['src']<400)))
394
+			if (!(strlen($attribute_array['src']) > 4 && strlen($attribute_array['src'] < 400)))
395 395
 			{
396
-					$attribute_array['alt']= $attribute_array['alt'].' [blocked (reason: url length):'.$attribute_array['src'].']';
397
-					if (!isset($attribute_array['title'])) $attribute_array['title']=$attribute_array['alt'];
398
-					$attribute_array['src']=Api\Image::find('phpgwapi','dialog_error');
396
+					$attribute_array['alt'] = $attribute_array['alt'].' [blocked (reason: url length):'.$attribute_array['src'].']';
397
+					if (!isset($attribute_array['title'])) $attribute_array['title'] = $attribute_array['alt'];
398
+					$attribute_array['src'] = Api\Image::find('phpgwapi', 'dialog_error');
399 399
 			}
400
-			if (!preg_match('/^cid:.*/',$attribute_array['src']))
400
+			if (!preg_match('/^cid:.*/', $attribute_array['src']))
401 401
 			{
402 402
 				if (!$GLOBALS['egw_info']['user']['preferences']['mail']['allowExternalIMGs'])
403 403
 				{
404 404
 					//the own webserver url is not external, so it should be allowed
405
-					if (empty($GLOBALS['egw_info']['server']['webserver_url'])||!preg_match("$^".$GLOBALS['egw_info']['server']['webserver_url'].".*$",$attribute_array['src']))
405
+					if (empty($GLOBALS['egw_info']['server']['webserver_url']) || !preg_match("$^".$GLOBALS['egw_info']['server']['webserver_url'].".*$", $attribute_array['src']))
406 406
 					{
407
-						$attribute_array['alt']= $attribute_array['alt'].' [blocked external image:'.$attribute_array['src'].']';
408
-						if (!isset($attribute_array['title'])) $attribute_array['title']=$attribute_array['alt'];
409
-						$attribute_array['src']=Api\Image::find('mail','no-image-shown');
407
+						$attribute_array['alt'] = $attribute_array['alt'].' [blocked external image:'.$attribute_array['src'].']';
408
+						if (!isset($attribute_array['title'])) $attribute_array['title'] = $attribute_array['alt'];
409
+						$attribute_array['src'] = Api\Image::find('mail', 'no-image-shown');
410 410
 						$attribute_array['border'] = 1;
411 411
 						if ($attribute_array['style'])
412 412
 						{
413
-							if (stripos($attribute_array['style'],'border')!==false) $attribute_array['style'] = preg_replace('~border(:|-left:|-right:|-bottom:|-top:)+ (0px)+ (none)+;~si','',$attribute_array['style']);
413
+							if (stripos($attribute_array['style'], 'border') !== false) $attribute_array['style'] = preg_replace('~border(:|-left:|-right:|-bottom:|-top:)+ (0px)+ (none)+;~si', '', $attribute_array['style']);
414 414
 						}
415 415
 					}
416 416
 				}
417 417
 			}
418 418
 		}
419 419
 	}
420
-	if (isset($attribute_array['style']) && stripos($attribute_array['style'],'script')!==false) $attribute_array['style'] = str_ireplace('script','',$attribute_array['style']);
420
+	if (isset($attribute_array['style']) && stripos($attribute_array['style'], 'script') !== false) $attribute_array['style'] = str_ireplace('script', '', $attribute_array['style']);
421 421
 	if (isset($attribute_array['title']))
422 422
 	{
423
-		if (strpos($attribute_array['title'],'@')!==false) $attribute_array['title']=str_replace('@','(at)',$attribute_array['title']);
423
+		if (strpos($attribute_array['title'], '@') !== false) $attribute_array['title'] = str_replace('@', '(at)', $attribute_array['title']);
424 424
 	}
425 425
 	if ($element == 'blockquote')
426 426
 	{
427 427
 		if (isset($attribute_array['cite']))
428 428
 		{
429
-			if (strpos($attribute_array['cite'],'@')!==false) $attribute_array['cite']=str_replace('@','(at)',$attribute_array['cite']);
429
+			if (strpos($attribute_array['cite'], '@') !== false) $attribute_array['cite'] = str_replace('@', '(at)', $attribute_array['cite']);
430 430
 		}
431 431
 	}
432
-	if($element == 'a')
432
+	if ($element == 'a')
433 433
 	{
434 434
 		//error_log(__METHOD__.__LINE__.array2string($attribute_array));
435
-		if (strpos($attribute_array['href'],'denied:javascript')===0) $attribute_array['href']='';
435
+		if (strpos($attribute_array['href'], 'denied:javascript') === 0) $attribute_array['href'] = '';
436 436
 		if (isset($attribute_array['name']) && isset($attribute_array['id'])) $attribute_array['id'] = $attribute_array['name'];
437
-		if (strpos($attribute_array['href'],'@')!==false) $attribute_array['href'] = str_replace('@','%40',$attribute_array['href']);
438
-		if (strpos($attribute_array['href'],'#')===0 && (isset(Api\Mail::$htmLawed_config['transform_anchor']) && Api\Mail::$htmLawed_config['transform_anchor']===true))
437
+		if (strpos($attribute_array['href'], '@') !== false) $attribute_array['href'] = str_replace('@', '%40', $attribute_array['href']);
438
+		if (strpos($attribute_array['href'], '#') === 0 && (isset(Api\Mail::$htmLawed_config['transform_anchor']) && Api\Mail::$htmLawed_config['transform_anchor'] === true))
439 439
 		{
440
-			$attribute_array['href'] = "javascript:GoToAnchor('".trim(substr($attribute_array['href'],1))."');";
440
+			$attribute_array['href'] = "javascript:GoToAnchor('".trim(substr($attribute_array['href'], 1))."');";
441 441
 		}
442 442
 
443 443
 	}
444 444
 
445 445
 	// Build the attributes string
446 446
 	$attributes = '';
447
-	foreach($attribute_array as $k=>$v){
447
+	foreach ($attribute_array as $k=>$v) {
448 448
 		$attributes .= " {$k}=\"{$v}\"";
449 449
 	}
450 450
 
451 451
 	// Return the opening tag with attributes
452 452
 	static $empty_elements = array('area'=>1, 'br'=>1, 'col'=>1, 'embed'=>1, 'hr'=>1, 'img'=>1, 'input'=>1, 'isindex'=>1, 'param'=>1);
453
-	return "<{$element}{$attributes}". (isset($empty_elements[$element]) ? ' /' : ''). '>';
453
+	return "<{$element}{$attributes}".(isset($empty_elements[$element]) ? ' /' : '').'>';
454 454
 }
455 455
 
Please login to merge, or discard this patch.
Braces   +146 added lines, -38 removed lines patch added patch discarded remove patch
@@ -109,9 +109,18 @@  discard block
 block discarded – undo
109 109
 	function run($html2check, $Config=null, $Spec=array())
110 110
 	{
111 111
 		//error_log(__METHOD__.__LINE__.' Input:'.$html2check);
112
-		if (is_array($Config) && is_array($this->Configuration)) $Config = array_merge($this->Configuration, $Config);
113
-		if (empty($Config)) $Config = $this->Configuration;
114
-		if (empty($Spec)) $Spec = $this->Spec;
112
+		if (is_array($Config) && is_array($this->Configuration))
113
+		{
114
+			$Config = array_merge($this->Configuration, $Config);
115
+		}
116
+		if (empty($Config))
117
+		{
118
+			$Config = $this->Configuration;
119
+		}
120
+		if (empty($Spec))
121
+		{
122
+			$Spec = $this->Spec;
123
+		}
115 124
 		// If we are processing mails, we take out stuff in <style> stuff </style> tags and
116 125
 		// put it back in after purifying; styles are processed for known security risks
117 126
 		// in self::getStyles
@@ -139,7 +148,10 @@  discard block
 block discarded – undo
139 148
 	{
140 149
 		$ct=0;
141 150
 		$newStyle = null;
142
-		if (stripos($html,'<style')!==false)  $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $html, $newStyle);
151
+		if (stripos($html,'<style')!==false)
152
+		{
153
+			$ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $html, $newStyle);
154
+		}
143 155
 		if ($ct>0)
144 156
 		{
145 157
 			//error_log(__METHOD__.__LINE__.array2string($newStyle[0]));
@@ -173,7 +185,11 @@  discard block
 block discarded – undo
173 185
 		// CSS Security
174 186
 		// http://code.google.com/p/browsersec/wiki/Part1#Cascading_stylesheets
175 187
 		$css = preg_replace('/(javascript|expession|-moz-binding)/i','',$style);
176
-		if (stripos($css,'script')!==false) Api\Mail\Html::replaceTagsCompletley($css,'script'); // Strip out script that may be included
188
+		if (stripos($css,'script')!==false)
189
+		{
190
+			Api\Mail\Html::replaceTagsCompletley($css,'script');
191
+		}
192
+		// Strip out script that may be included
177 193
 		// we need this, as styledefinitions are enclosed with curly brackets; and template stuff tries to replace everything between curly brackets that is having no horizontal whitespace
178 194
 		// as the comments as <!-- styledefinition --> in stylesheet are outdated, and ck-editor does not understand it, we remove it
179 195
 		$css_no_comment = str_replace(array(':','<!--','-->'),array(': ','',''),$css);
@@ -199,12 +215,19 @@  discard block
 block discarded – undo
199 215
 	{
200 216
 		$defaultConfig = array('valid_xhtml'=>1,'safe'=>1);
201 217
 
202
-		if (empty($html)) return $html;	// no need to process further
218
+		if (empty($html))
219
+		{
220
+			return $html;
221
+		}
222
+		// no need to process further
203 223
 		if (!empty($config) && is_string($config))
204 224
 		{
205 225
 			//error_log(__METHOD__.__LINE__.$config);
206 226
 			$config = json_decode($config,true);
207
-			if (is_null($config)) error_log(__METHOD__.__LINE__." decoding of config failed; standard will be applied");
227
+			if (is_null($config))
228
+			{
229
+				error_log(__METHOD__.__LINE__." decoding of config failed; standard will be applied");
230
+			}
208 231
 		}
209 232
 
210 233
 		// User preferences
@@ -218,8 +241,14 @@  discard block
 block discarded – undo
218 241
 			return '';
219 242
 		}
220 243
 		$htmLawed = new HtmLawed();
221
-		if (is_array($config) && $_force===false) $config = array_merge($defaultConfig, $config);
222
-		if (empty($config)) $config = $defaultConfig;
244
+		if (is_array($config) && $_force===false)
245
+		{
246
+			$config = array_merge($defaultConfig, $config);
247
+		}
248
+		if (empty($config))
249
+		{
250
+			$config = $defaultConfig;
251
+		}
223 252
 		//error_log(__METHOD__.__LINE__.array2string($config));
224 253
 		return $htmLawed->run($html,$config,$spec);
225 254
 	}
@@ -236,7 +265,8 @@  discard block
 block discarded – undo
236 265
 function hl_my_tag_transform($element, $attribute_array=0)
237 266
 {
238 267
 	// If second argument is not received, it means a closing tag is being handled
239
-	if(is_numeric($attribute_array)){
268
+	if(is_numeric($attribute_array))
269
+	{
240 270
 		return "</$element>";
241 271
 	}
242 272
 
@@ -258,18 +288,30 @@  discard block
 block discarded – undo
258 288
 	if($element == 'img')
259 289
 	{
260 290
 		// Re-build 'alt'
261
-		if (isset($attribute_array['alt'])) $attribute_array['alt'] = ($attribute_array['alt']=='image'?'':$attribute_array['alt']);
262
-		if (isset($attribute_array['alt'])&&strpos($attribute_array['alt'],'@')!==false) $attribute_array['alt']=str_replace('@','(at)',$attribute_array['alt']);
291
+		if (isset($attribute_array['alt']))
292
+		{
293
+			$attribute_array['alt'] = ($attribute_array['alt']=='image'?'':$attribute_array['alt']);
294
+		}
295
+		if (isset($attribute_array['alt'])&&strpos($attribute_array['alt'],'@')!==false)
296
+		{
297
+			$attribute_array['alt']=str_replace('@','(at)',$attribute_array['alt']);
298
+		}
263 299
 	}
264 300
 	if (isset($attribute_array['title']))
265 301
 	{
266
-		if (strpos($attribute_array['title'],'@')!==false) $attribute_array['title']=str_replace('@','(at)',$attribute_array['title']);
302
+		if (strpos($attribute_array['title'],'@')!==false)
303
+		{
304
+			$attribute_array['title']=str_replace('@','(at)',$attribute_array['title']);
305
+		}
267 306
 	}
268 307
 	if ($element == 'blockquote')
269 308
 	{
270 309
 		if (isset($attribute_array['cite']))
271 310
 		{
272
-			if (strpos($attribute_array['cite'],'@')!==false) $attribute_array['cite']=str_replace('@','(at)',$attribute_array['cite']);
311
+			if (strpos($attribute_array['cite'],'@')!==false)
312
+			{
313
+				$attribute_array['cite']=str_replace('@','(at)',$attribute_array['cite']);
314
+			}
273 315
 		}
274 316
 	}
275 317
 	/*
@@ -301,7 +343,10 @@  discard block
 block discarded – undo
301 343
 		$attribute_array['style'] = implode('; ', $style);
302 344
 	}
303 345
 	*/
304
-	if (isset($attribute_array['style']) && stripos($attribute_array['style'],'script')!==false) $attribute_array['style'] = str_ireplace('script','',$attribute_array['style']);
346
+	if (isset($attribute_array['style']) && stripos($attribute_array['style'],'script')!==false)
347
+	{
348
+		$attribute_array['style'] = str_ireplace('script','',$attribute_array['style']);
349
+	}
305 350
 	if($element == 'a')
306 351
 	{
307 352
 		//error_log(__METHOD__.__LINE__.array2string($attribute_array));
@@ -314,12 +359,16 @@  discard block
 block discarded – undo
314 359
 		{
315 360
 			$attribute_array['href']=str_ireplace("');",'',str_ireplace("javascript:GoToAnchor('","#",$attribute_array['href']));
316 361
 		}
317
-		if (strpos($attribute_array['href'],'denied:javascript')===0) $attribute_array['href']='';
362
+		if (strpos($attribute_array['href'],'denied:javascript')===0)
363
+		{
364
+			$attribute_array['href']='';
365
+		}
318 366
 	}
319 367
 
320 368
 	// Build the attributes string
321 369
 	$attributes = '';
322
-	foreach($attribute_array as $k=>$v){
370
+	foreach($attribute_array as $k=>$v)
371
+	{
323 372
 		$attributes .= " {$k}=\"{$v}\"";
324 373
 	}
325 374
 
@@ -344,27 +393,52 @@  discard block
 block discarded – undo
344 393
 	//error_log(__METHOD__.__LINE__.$element.'=>'.array2string($attribute_array));
345 394
 	static $lastelement = null;
346 395
 	static $throwawaycounter = null;
347
-	if (is_null($lastelement)) $lastelement='';
348
-	if (is_null($throwawaycounter)) $throwawaycounter = 0;
396
+	if (is_null($lastelement))
397
+	{
398
+		$lastelement='';
399
+	}
400
+	if (is_null($throwawaycounter))
401
+	{
402
+		$throwawaycounter = 0;
403
+	}
349 404
 	//if ($throwawaycounter>1) error_log(__METHOD__.__LINE__.' '.$throwawaycounter.$element.array2string($attribute_array));
350 405
 	if ($element=='div' && $element==$lastelement && ($attribute_array==0 || empty($attribute_array)))
351 406
 	{
352
-		if (is_array($attribute_array)) $throwawaycounter++;
353
-		if ($attribute_array==0 && $throwawaycounter>0) $throwawaycounter--;
354
-		if ($throwawaycounter>1) return '';
407
+		if (is_array($attribute_array))
408
+		{
409
+			$throwawaycounter++;
410
+		}
411
+		if ($attribute_array==0 && $throwawaycounter>0)
412
+		{
413
+			$throwawaycounter--;
414
+		}
415
+		if ($throwawaycounter>1)
416
+		{
417
+			return '';
418
+		}
419
+	}
420
+	if ($lastelement=='div' && $element!=$lastelement && is_array($attribute_array))
421
+	{
422
+		$throwawaycounter = 0;
355 423
 	}
356
-	if ($lastelement=='div' && $element!=$lastelement && is_array($attribute_array)) $throwawaycounter = 0;
357 424
 	if (is_array($attribute_array) && !empty($attribute_array) && $element=='div')
358 425
 	{
359 426
 		$lastelement = 'div_with_attr';
360 427
 	}
361 428
 	else
362 429
 	{
363
-		if (is_array($attribute_array)) $lastelement = $element;
430
+		if (is_array($attribute_array))
431
+		{
432
+			$lastelement = $element;
433
+		}
364 434
 	}
365 435
 	// If second argument is not received, it means a closing tag is being handled
366
-	if(is_numeric($attribute_array)){
367
-		if($element==$lastelement) $lastelement='';
436
+	if(is_numeric($attribute_array))
437
+	{
438
+		if($element==$lastelement)
439
+		{
440
+			$lastelement='';
441
+		}
368 442
 		return "</$element>";
369 443
 	}
370 444
 
@@ -386,15 +460,24 @@  discard block
 block discarded – undo
386 460
 	if($element == 'img')
387 461
 	{
388 462
 		// Re-build 'alt'
389
-		if (isset($attribute_array['alt'])) $attribute_array['alt'] = ($attribute_array['alt']=='image'?'':$attribute_array['alt']);
390
-		if (isset($attribute_array['alt'])&&strpos($attribute_array['alt'],'@')!==false) $attribute_array['alt']=str_replace('@','(at)',$attribute_array['alt']);
463
+		if (isset($attribute_array['alt']))
464
+		{
465
+			$attribute_array['alt'] = ($attribute_array['alt']=='image'?'':$attribute_array['alt']);
466
+		}
467
+		if (isset($attribute_array['alt'])&&strpos($attribute_array['alt'],'@')!==false)
468
+		{
469
+			$attribute_array['alt']=str_replace('@','(at)',$attribute_array['alt']);
470
+		}
391 471
 		// $GLOBALS['egw_info']['user']['preferences']['mail']['allowExternalIMGs'] ? '' : 'match' => '/^cid:.*/'),
392 472
 		if (isset($attribute_array['src']))
393 473
 		{
394 474
 			if (!(strlen($attribute_array['src'])>4 && strlen($attribute_array['src']<400)))
395 475
 			{
396 476
 					$attribute_array['alt']= $attribute_array['alt'].' [blocked (reason: url length):'.$attribute_array['src'].']';
397
-					if (!isset($attribute_array['title'])) $attribute_array['title']=$attribute_array['alt'];
477
+					if (!isset($attribute_array['title']))
478
+					{
479
+						$attribute_array['title']=$attribute_array['alt'];
480
+					}
398 481
 					$attribute_array['src']=Api\Image::find('phpgwapi','dialog_error');
399 482
 			}
400 483
 			if (!preg_match('/^cid:.*/',$attribute_array['src']))
@@ -405,36 +488,60 @@  discard block
 block discarded – undo
405 488
 					if (empty($GLOBALS['egw_info']['server']['webserver_url'])||!preg_match("$^".$GLOBALS['egw_info']['server']['webserver_url'].".*$",$attribute_array['src']))
406 489
 					{
407 490
 						$attribute_array['alt']= $attribute_array['alt'].' [blocked external image:'.$attribute_array['src'].']';
408
-						if (!isset($attribute_array['title'])) $attribute_array['title']=$attribute_array['alt'];
491
+						if (!isset($attribute_array['title']))
492
+						{
493
+							$attribute_array['title']=$attribute_array['alt'];
494
+						}
409 495
 						$attribute_array['src']=Api\Image::find('mail','no-image-shown');
410 496
 						$attribute_array['border'] = 1;
411 497
 						if ($attribute_array['style'])
412 498
 						{
413
-							if (stripos($attribute_array['style'],'border')!==false) $attribute_array['style'] = preg_replace('~border(:|-left:|-right:|-bottom:|-top:)+ (0px)+ (none)+;~si','',$attribute_array['style']);
499
+							if (stripos($attribute_array['style'],'border')!==false)
500
+							{
501
+								$attribute_array['style'] = preg_replace('~border(:|-left:|-right:|-bottom:|-top:)+ (0px)+ (none)+;~si','',$attribute_array['style']);
502
+							}
414 503
 						}
415 504
 					}
416 505
 				}
417 506
 			}
418 507
 		}
419 508
 	}
420
-	if (isset($attribute_array['style']) && stripos($attribute_array['style'],'script')!==false) $attribute_array['style'] = str_ireplace('script','',$attribute_array['style']);
509
+	if (isset($attribute_array['style']) && stripos($attribute_array['style'],'script')!==false)
510
+	{
511
+		$attribute_array['style'] = str_ireplace('script','',$attribute_array['style']);
512
+	}
421 513
 	if (isset($attribute_array['title']))
422 514
 	{
423
-		if (strpos($attribute_array['title'],'@')!==false) $attribute_array['title']=str_replace('@','(at)',$attribute_array['title']);
515
+		if (strpos($attribute_array['title'],'@')!==false)
516
+		{
517
+			$attribute_array['title']=str_replace('@','(at)',$attribute_array['title']);
518
+		}
424 519
 	}
425 520
 	if ($element == 'blockquote')
426 521
 	{
427 522
 		if (isset($attribute_array['cite']))
428 523
 		{
429
-			if (strpos($attribute_array['cite'],'@')!==false) $attribute_array['cite']=str_replace('@','(at)',$attribute_array['cite']);
524
+			if (strpos($attribute_array['cite'],'@')!==false)
525
+			{
526
+				$attribute_array['cite']=str_replace('@','(at)',$attribute_array['cite']);
527
+			}
430 528
 		}
431 529
 	}
432 530
 	if($element == 'a')
433 531
 	{
434 532
 		//error_log(__METHOD__.__LINE__.array2string($attribute_array));
435
-		if (strpos($attribute_array['href'],'denied:javascript')===0) $attribute_array['href']='';
436
-		if (isset($attribute_array['name']) && isset($attribute_array['id'])) $attribute_array['id'] = $attribute_array['name'];
437
-		if (strpos($attribute_array['href'],'@')!==false) $attribute_array['href'] = str_replace('@','%40',$attribute_array['href']);
533
+		if (strpos($attribute_array['href'],'denied:javascript')===0)
534
+		{
535
+			$attribute_array['href']='';
536
+		}
537
+		if (isset($attribute_array['name']) && isset($attribute_array['id']))
538
+		{
539
+			$attribute_array['id'] = $attribute_array['name'];
540
+		}
541
+		if (strpos($attribute_array['href'],'@')!==false)
542
+		{
543
+			$attribute_array['href'] = str_replace('@','%40',$attribute_array['href']);
544
+		}
438 545
 		if (strpos($attribute_array['href'],'#')===0 && (isset(Api\Mail::$htmLawed_config['transform_anchor']) && Api\Mail::$htmLawed_config['transform_anchor']===true))
439 546
 		{
440 547
 			$attribute_array['href'] = "javascript:GoToAnchor('".trim(substr($attribute_array['href'],1))."');";
@@ -444,7 +551,8 @@  discard block
 block discarded – undo
444 551
 
445 552
 	// Build the attributes string
446 553
 	$attributes = '';
447
-	foreach($attribute_array as $k=>$v){
554
+	foreach($attribute_array as $k=>$v)
555
+	{
448 556
 		$attributes .= " {$k}=\"{$v}\"";
449 557
 	}
450 558
 
Please login to merge, or discard this patch.