Test Setup Failed
Push — master ( 12c298...4a14e0 )
by Ralf
22:03
created
api/src/Mail/Sieve.php 3 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -37,28 +37,28 @@  discard block
 block discarded – undo
37 37
 	var $icServer;
38 38
 
39 39
 	/**
40
-	* @var string name of active script queried from Sieve server
41
-	*/
40
+	 * @var string name of active script queried from Sieve server
41
+	 */
42 42
 	var $scriptName;
43 43
 
44 44
 	/**
45
-	* @var $rules containing the rules
46
-	*/
45
+	 * @var $rules containing the rules
46
+	 */
47 47
 	var $rules;
48 48
 
49 49
 	/**
50
-	* @var $vacation containing the vacation
51
-	*/
50
+	 * @var $vacation containing the vacation
51
+	 */
52 52
 	var $vacation;
53 53
 
54 54
 	/**
55
-	* @var $emailNotification containing the emailNotification
56
-	*/
55
+	 * @var $emailNotification containing the emailNotification
56
+	 */
57 57
 	var $emailNotification;
58 58
 
59 59
 	/**
60
-	* @var object $error the last PEAR error object
61
-	*/
60
+	 * @var object $error the last PEAR error object
61
+	 */
62 62
 	var $error;
63 63
 
64 64
 	/**
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
 	function setEmailNotification(array $_emailNotification, $_scriptName=null)
171 171
 	{
172 172
 		if ($_emailNotification['externalEmail'] == '' || !preg_match("/\@/",$_emailNotification['externalEmail'])) {
173
-    		$_emailNotification['status'] = 'off';
174
-    		$_emailNotification['externalEmail'] = '';
175
-    	}
173
+			$_emailNotification['status'] = 'off';
174
+			$_emailNotification['externalEmail'] = '';
175
+		}
176 176
 
177
-    	$script = $this->retrieveRules($_scriptName);
177
+		$script = $this->retrieveRules($_scriptName);
178 178
    		$script->emailNotification = $_emailNotification;
179 179
 		$ret = $script->updateScript($this);
180 180
 		$this->error = $script->errstr;
Please login to merge, or discard this patch.
Braces   +14 added lines, -4 removed lines patch added patch discarded remove patch
@@ -104,21 +104,30 @@  discard block
 block discarded – undo
104 104
 
105 105
 	function getRules()
106 106
 	{
107
-		if (!isset($this->rules)) $this->retrieveRules();
107
+		if (!isset($this->rules))
108
+		{
109
+			$this->retrieveRules();
110
+		}
108 111
 
109 112
 		return $this->rules;
110 113
 	}
111 114
 
112 115
 	function getVacation()
113 116
 	{
114
-		if (!isset($this->rules)) $this->retrieveRules();
117
+		if (!isset($this->rules))
118
+		{
119
+			$this->retrieveRules();
120
+		}
115 121
 
116 122
 		return $this->vacation;
117 123
 	}
118 124
 
119 125
 	function getEmailNotification()
120 126
 	{
121
-		if (!isset($this->rules)) $this->retrieveRules();
127
+		if (!isset($this->rules))
128
+		{
129
+			$this->retrieveRules();
130
+		}
122 131
 
123 132
 		return $this->emailNotification;
124 133
 	}
@@ -169,7 +178,8 @@  discard block
 block discarded – undo
169 178
 	 */
170 179
 	function setEmailNotification(array $_emailNotification, $_scriptName=null)
171 180
 	{
172
-		if ($_emailNotification['externalEmail'] == '' || !preg_match("/\@/",$_emailNotification['externalEmail'])) {
181
+		if ($_emailNotification['externalEmail'] == '' || !preg_match("/\@/",$_emailNotification['externalEmail']))
182
+		{
173 183
     		$_emailNotification['status'] = 'off';
174 184
     		$_emailNotification['externalEmail'] = '';
175 185
     	}
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @param array|Imap $params =array()
86 86
 	 */
87
-	function __construct($params=array())
87
+	function __construct($params = array())
88 88
 	{
89 89
 		if (is_a($params, __NAMESPACE__.'\\Imap'))
90 90
 		{
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
 		parent::__construct($params);
105 105
 
106
-		$this->displayCharset	= Translation::charset();
106
+		$this->displayCharset = Translation::charset();
107 107
 	}
108 108
 
109 109
 	function getRules()
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 * @param string $_scriptName
135 135
 	 * @param boolean $utf7imap_fileinto =false true: encode foldernames with utf7imap, default utf8
136 136
 	 */
137
-	function setRules(array $_rules, $_scriptName=null, $utf7imap_fileinto=false)
137
+	function setRules(array $_rules, $_scriptName = null, $utf7imap_fileinto = false)
138 138
 	{
139 139
 		$script = $this->retrieveRules($_scriptName);
140 140
 		$script->debug = $this->debug;
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
 	 * @param array $_vacation
151 151
 	 * @param string $_scriptName
152 152
 	 */
153
-	function setVacation(array $_vacation, $_scriptName=null)
153
+	function setVacation(array $_vacation, $_scriptName = null)
154 154
 	{
155 155
 		if ($this->debug)
156 156
 		{
157
-			error_log(__METHOD__ . "($_scriptName," . print_r($_vacation, true) . ')');
157
+			error_log(__METHOD__."($_scriptName,".print_r($_vacation, true).')');
158 158
 		}
159 159
 		$script = $this->retrieveRules($_scriptName);
160 160
 		$script->debug = $this->debug;
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
 	 * @param string $_scriptName
172 172
 	 * @return Script
173 173
 	 */
174
-	function setEmailNotification(array $_emailNotification, $_scriptName=null)
174
+	function setEmailNotification(array $_emailNotification, $_scriptName = null)
175 175
 	{
176
-		if ($_emailNotification['externalEmail'] == '' || !preg_match("/\@/",$_emailNotification['externalEmail'])) {
176
+		if ($_emailNotification['externalEmail'] == '' || !preg_match("/\@/", $_emailNotification['externalEmail'])) {
177 177
     		$_emailNotification['status'] = 'off';
178 178
     		$_emailNotification['externalEmail'] = '';
179 179
     	}
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 * @param string $_scriptName
192 192
 	 * @return Script
193 193
 	 */
194
-	function retrieveRules($_scriptName=null)
194
+	function retrieveRules($_scriptName = null)
195 195
 	{
196 196
 		if (!$_scriptName)
197 197
 		{
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
 				try {
202 202
 					$this->scriptName = $this->getActive();
203 203
 				}
204
-				catch(Exception $e) {
205
-					unset($e);	// ignore NOTEXISTS exception
204
+				catch (Exception $e) {
205
+					unset($e); // ignore NOTEXISTS exception
206 206
 				}
207 207
 				if (empty($this->scriptName))
208 208
 				{
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 			$script->retrieveRules($this);
218 218
 		}
219 219
 		catch (\Exception $e) {
220
-			unset($e);	// ignore not found script exception
220
+			unset($e); // ignore not found script exception
221 221
 		}
222
-		$this->rules =& $script->rules;
223
-		$this->vacation =& $script->vacation;
224
-		$this->emailNotification =& $script->emailNotification; // Added email notifications
222
+		$this->rules = & $script->rules;
223
+		$this->vacation = & $script->vacation;
224
+		$this->emailNotification = & $script->emailNotification; // Added email notifications
225 225
 
226 226
 		return $script;
227 227
 	}
Please login to merge, or discard this patch.
api/src/Mail/Smtp/Ads.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 */
134 134
 	protected function getLdapConnection()
135 135
 	{
136
-		static $ldap=null;
136
+		static $ldap = null;
137 137
 
138 138
 		if (is_null($ldap))
139 139
 		{
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 *
152 152
 	 * @param string $defaultDomain =null
153 153
 	 */
154
-	function __construct($defaultDomain=null)
154
+	function __construct($defaultDomain = null)
155 155
 	{
156 156
 		parent::__construct($defaultDomain);
157 157
 
Please login to merge, or discard this patch.
api/src/Mail/Smtp/Oldqmailuser.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
 	/**
46 46
 	 * Primary mail address required as an alias too: true or false
47 47
 	 */
48
-	const REQUIRE_MAIL_AS_ALIAS=false;
48
+	const REQUIRE_MAIL_AS_ALIAS = false;
49 49
 
50 50
 	/**
51 51
 	 * Attribute for forwards OR false if not possible
Please login to merge, or discard this patch.
api/src/Mail/Smtp/Univention.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	/**
51 51
 	 * Primary mail address required as an alias too: true or false
52 52
 	 */
53
-	const REQUIRE_MAIL_AS_ALIAS=false;
53
+	const REQUIRE_MAIL_AS_ALIAS = false;
54 54
 
55 55
 	/**
56 56
 	 * Attribute for forwards OR false if not possible
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	function addAccountExtra(array $_hookValues, array $allValues, array &$newData)
97 97
 	{
98
-		unset($_hookValues);	// not used, but required by function signature
98
+		unset($_hookValues); // not used, but required by function signature
99 99
 
100 100
 		if (empty($allValues['univentionmailhomeserver'][0]) && $newData[self::MAIL_ENABLE_ATTR])
101 101
 		{
Please login to merge, or discard this patch.
api/src/Mail/Hooks.php 3 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 		}
33 33
 	}
34 34
 
35
-    /**
36
-     * Hook called before an account get deleted
37
-     *
38
-     * @param array $data
39
-     * @param int $data['account_id'] numerical id
40
-     * @param string $data['account_lid'] account-name
41
-     * @param int $data['new_owner'] account-id of new owner, or false if data should get deleted
42
-     */
35
+	/**
36
+	 * Hook called before an account get deleted
37
+	 *
38
+	 * @param array $data
39
+	 * @param int $data['account_id'] numerical id
40
+	 * @param string $data['account_lid'] account-name
41
+	 * @param int $data['new_owner'] account-id of new owner, or false if data should get deleted
42
+	 */
43 43
 	static function deleteaccount(array $data)
44 44
 	{
45 45
 		self::run_plugin_hooks('deleteAccount', $data);
@@ -48,25 +48,25 @@  discard block
 block discarded – undo
48 48
 		Account::delete(0, $data['account_id']);
49 49
 	}
50 50
 
51
-    /**
52
-     * Hook called before a group get deleted
53
-     *
54
-     * @param array $data
55
-     * @param int $data['account_id'] numerical id
56
-     * @param string $data['account_name'] account-name
57
-     */
51
+	/**
52
+	 * Hook called before a group get deleted
53
+	 *
54
+	 * @param array $data
55
+	 * @param int $data['account_id'] numerical id
56
+	 * @param string $data['account_name'] account-name
57
+	 */
58 58
 	static function deletegroup(array $data)
59 59
 	{
60 60
 		Account::delete(0, $data['account_id']);
61 61
 	}
62 62
 
63 63
 	/**
64
-     * Hook called when an account get added or edited
65
-     *
66
-     * @param array $data
67
-     * @param int $data['account_id'] numerical id
68
-     * @param string $data['account_lid'] account-name
69
-     * @param string $data['account_email'] email
64
+	 * Hook called when an account get added or edited
65
+	 *
66
+	 * @param array $data
67
+	 * @param int $data['account_id'] numerical id
68
+	 * @param string $data['account_lid'] account-name
69
+	 * @param string $data['account_email'] email
70 70
 	 */
71 71
 	static function addaccount(array $data)
72 72
 	{
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	protected static function run_plugin_hooks($method, array $data)
84 84
 	{
85
-		foreach(Account::search((int)$data['account_id'], 'params') as $params)
85
+		foreach (Account::search((int)$data['account_id'], 'params') as $params)
86 86
 		{
87
-			if (!Account::is_multiple($params)) continue;	// no need to waste time on personal accounts
87
+			if (!Account::is_multiple($params)) continue; // no need to waste time on personal accounts
88 88
 
89 89
 			try {
90 90
 				$account = new Account($params);
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 					$imap->$method($data);
101 101
 				}
102 102
 			}
103
-			catch(\Exception $e) {
103
+			catch (\Exception $e) {
104 104
 				_egw_log_exception($e);
105 105
 				// ignore exception, without stalling other hooks
106 106
 			}
Please login to merge, or discard this patch.
Braces   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,11 @@
 block discarded – undo
84 84
 	{
85 85
 		foreach(Account::search((int)$data['account_id'], 'params') as $params)
86 86
 		{
87
-			if (!Account::is_multiple($params)) continue;	// no need to waste time on personal accounts
87
+			if (!Account::is_multiple($params))
88
+			{
89
+				continue;
90
+			}
91
+			// no need to waste time on personal accounts
88 92
 
89 93
 			try {
90 94
 				$account = new Account($params);
Please login to merge, or discard this patch.
api/src/Mail/Types.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
 	 *
26 26
 	 * @return array classname => label pairs
27 27
 	 */
28
-	static public function getSMTPServerTypes($extended=true)
28
+	static public function getSMTPServerTypes($extended = true)
29 29
 	{
30 30
 		$retData = self::server_types(false, $extended);
31
-		foreach(Api\Hooks::process(array(
31
+		foreach (Api\Hooks::process(array(
32 32
 			'location' => 'smtp_server_types',
33 33
 			'extended' => $extended,
34 34
 		), array('managementserver'), true) as $app => $data)
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 	 * @param boolean $extended =true
56 56
 	 * @return array classname => label pairs
57 57
 	 */
58
-	static public function getIMAPServerTypes($extended=true)
58
+	static public function getIMAPServerTypes($extended = true)
59 59
 	{
60 60
 		$retData = self::server_types(true, $extended);
61
-		foreach(Api\Hooks::process(array(
61
+		foreach (Api\Hooks::process(array(
62 62
 			'location' => 'imap_server_types',
63 63
 			'extended' => $extended,
64 64
 		), array('managementserver'), true) as $app => $data)
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 	 * @param boolean $extended =false
85 85
 	 * @return array
86 86
 	 */
87
-	protected static function server_types($imap=true, $extended=false)
87
+	protected static function server_types($imap = true, $extended = false)
88 88
 	{
89 89
 		$types = array();
90 90
 		$prefix = $imap ? 'Imap' : 'Smtp';
91
-		foreach(scandir($dir=__DIR__.'/'.$prefix) as $file)
91
+		foreach (scandir($dir = __DIR__.'/'.$prefix) as $file)
92 92
 		{
93 93
 			if ($file == '..')
94 94
 			{
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 
107 107
 			$type = array(
108 108
 				'classname' => $class_name,
109
-				'description' => is_callable($function=$class_name.'::description') ? call_user_func($function) : $class_name,
109
+				'description' => is_callable($function = $class_name.'::description') ? call_user_func($function) : $class_name,
110 110
 			);
111 111
 			if ($imap) $type['protocol'] = 'imap';
112 112
 
Please login to merge, or discard this patch.
Braces   +20 added lines, -6 removed lines patch added patch discarded remove patch
@@ -33,10 +33,14 @@  discard block
 block discarded – undo
33 33
 			'extended' => $extended,
34 34
 		), array('managementserver'), true) as $app => $data)
35 35
 		{
36
-			if ($data && $app != 'emailadmin') $retData += $data;
36
+			if ($data && $app != 'emailadmin')
37
+			{
38
+				$retData += $data;
39
+			}
37 40
 		}
38 41
 
39
-		uksort($retData, function($a, $b) {
42
+		uksort($retData, function($a, $b)
43
+		{
40 44
 			static $prio = array(	// not explicitly mentioned get 0
41 45
 				'EGroupware\\Api\\Mail\\Smtp' => 9,
42 46
 				'EGroupware\\Api\\Mail\\Smtp\\Sql' => 8,
@@ -63,9 +67,13 @@  discard block
 block discarded – undo
63 67
 			'extended' => $extended,
64 68
 		), array('managementserver'), true) as $app => $data)
65 69
 		{
66
-			if ($data && $app != 'emailadmin') $retData += $data;
70
+			if ($data && $app != 'emailadmin')
71
+			{
72
+				$retData += $data;
73
+			}
67 74
 		}
68
-		uksort($retData, function($a, $b) {
75
+		uksort($retData, function($a, $b)
76
+		{
69 77
 			static $prio = array(	// not explicitly mentioned get 0
70 78
 				'EGroupware\\Api\\Mail\\Imap' => 9,
71 79
 				'managementserver_imap' => 8,
@@ -102,13 +110,19 @@  discard block
 block discarded – undo
102 110
 			{
103 111
 				continue;
104 112
 			}
105
-			if (!class_exists($class_name)) continue;
113
+			if (!class_exists($class_name))
114
+			{
115
+				continue;
116
+			}
106 117
 
107 118
 			$type = array(
108 119
 				'classname' => $class_name,
109 120
 				'description' => is_callable($function=$class_name.'::description') ? call_user_func($function) : $class_name,
110 121
 			);
111
-			if ($imap) $type['protocol'] = 'imap';
122
+			if ($imap)
123
+			{
124
+				$type['protocol'] = 'imap';
125
+			}
112 126
 
113 127
 			$types[$class_name] = $extended ? $type : $type['description'];
114 128
 		}
Please login to merge, or discard this patch.
api/src/Mail/Notifications.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 * @param boolean $return_empty_marker =false should we return null
53 53
 	 * @return array with values for "notify_folders", "notify_use_default"
54 54
 	 */
55
-	public static function read($acc_id, $account_id=null, $return_empty_marker=false)
55
+	public static function read($acc_id, $account_id = null, $return_empty_marker = false)
56 56
 	{
57 57
 		if (is_null($account_id))
58 58
 		{
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 			//error_log(__METHOD__."($acc_id, ".array2string($account_id).") nothing in cache");
72 72
 		}
73 73
 		$account_specific = 0;
74
-		foreach($rows as $row)
74
+		foreach ($rows as $row)
75 75
 		{
76 76
 			if ($row['account_id'])
77 77
 			{
@@ -109,19 +109,19 @@  discard block
 block discarded – undo
109 109
 	{
110 110
 		if (!is_numeric($account_id) || !($account_id >= 0))
111 111
 		{
112
-			return 0;	// nothing to save, happens eg. in setup
112
+			return 0; // nothing to save, happens eg. in setup
113 113
 		}
114 114
 
115 115
 		if ($account_id && !$folders && ($default = self::read($acc_id, 0)) && $default['notify_folders'])
116 116
 		{
117
-			$folders[] = null;	// we need to write a marker, that user wants no notifications!
117
+			$folders[] = null; // we need to write a marker, that user wants no notifications!
118 118
 		}
119
-		$old = self::read($acc_id, $account_id, true);	// true = return empty marker
120
-		if ($account_id && !$old['notify_account_id']) $old['notify_folders'] = array();	// ignore returned default
119
+		$old = self::read($acc_id, $account_id, true); // true = return empty marker
120
+		if ($account_id && !$old['notify_account_id']) $old['notify_folders'] = array(); // ignore returned default
121 121
 
122 122
 		$changed = 0;
123 123
 		// insert newly added ones
124
-		foreach(array_diff($folders, $old['notify_folders']) as $folder)
124
+		foreach (array_diff($folders, $old['notify_folders']) as $folder)
125 125
 		{
126 126
 			self::$db->insert(self::TABLE, array(
127 127
 				'acc_id' => $acc_id,
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 * @param int|array $account_id =null
157 157
 	 * @return int number of rows deleted
158 158
 	 */
159
-	public static function delete($acc_id, $account_id=null)
159
+	public static function delete($acc_id, $account_id = null)
160 160
 	{
161 161
 		if (!($acc_id > 0) && !isset($account_id))
162 162
 		{
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		self::$db->delete(self::TABLE, $where, __LINE__, __FILE__, self::APP);
170 170
 
171 171
 		// invalidate cache: we allways unset everything about an account to simplify cache handling
172
-		foreach($acc_id > 0 ? (array)$acc_id : array_keys(self::$cache) as $acc_id)
172
+		foreach ($acc_id > 0 ? (array)$acc_id : array_keys(self::$cache) as $acc_id)
173 173
 		{
174 174
 			unset(self::$cache[$acc_id]);
175 175
 		}
Please login to merge, or discard this patch.
Braces   +17 added lines, -4 removed lines patch added patch discarded remove patch
@@ -88,7 +88,10 @@  discard block
 block discarded – undo
88 88
 			}
89 89
 		}
90 90
 		$folders = (array)self::$cache[$acc_id][$account_specific];
91
-		if (!$return_empty_marker && $folders == array(null)) $folders = array();
91
+		if (!$return_empty_marker && $folders == array(null))
92
+		{
93
+			$folders = array();
94
+		}
92 95
 		$result = array(
93 96
 			'notify_folders' => $folders,
94 97
 			'notify_account_id' => $account_specific,
@@ -117,7 +120,11 @@  discard block
 block discarded – undo
117 120
 			$folders[] = null;	// we need to write a marker, that user wants no notifications!
118 121
 		}
119 122
 		$old = self::read($acc_id, $account_id, true);	// true = return empty marker
120
-		if ($account_id && !$old['notify_account_id']) $old['notify_folders'] = array();	// ignore returned default
123
+		if ($account_id && !$old['notify_account_id'])
124
+		{
125
+			$old['notify_folders'] = array();
126
+		}
127
+		// ignore returned default
121 128
 
122 129
 		$changed = 0;
123 130
 		// insert newly added ones
@@ -163,8 +170,14 @@  discard block
 block discarded – undo
163 170
 			throw new Api\Exception\WrongParameter(__METHOD__."() no acc_id AND no account_id parameter!");
164 171
 		}
165 172
 		$where = array();
166
-		if ($acc_id > 0) $where['acc_id'] = $acc_id;
167
-		if (isset($account_id)) $where['account_id'] = $account_id;
173
+		if ($acc_id > 0)
174
+		{
175
+			$where['acc_id'] = $acc_id;
176
+		}
177
+		if (isset($account_id))
178
+		{
179
+			$where['account_id'] = $account_id;
180
+		}
168 181
 
169 182
 		self::$db->delete(self::TABLE, $where, __LINE__, __FILE__, self::APP);
170 183
 
Please login to merge, or discard this patch.
api/src/Html.php 3 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -425,20 +425,20 @@  discard block
 block discarded – undo
425 425
 	}
426 426
 
427 427
 	/**
428
-	* this static function is a wrapper for fckEditor to create some reuseable layouts
429
-	*
430
-	* @param string $_name name and id of the input-field
431
-	* @param string $_content of the tinymce (will be run through htmlspecialchars !!!), default ''
432
-	* @param string $_mode display mode of the tinymce editor can be: simple, extended or advanced
433
-	* @param array  $_options (toolbar_expanded true/false)
434
-	* @param string $_height ='400px'
435
-	* @param string $_width ='100%'
436
-	* @param string $_start_path ='' if passed activates the browser for image at absolute path passed
437
-	* @param boolean $_purify =true run $_content through htmlpurifier before handing it to fckEditor
438
-	* @param mixed (boolean/string) $_focusToBody=false USED only for CKEDIOR true means yes, focus on top, you may specify TOP or BOTTOM (to focus on the end of the editor area)
439
-	* @param string $_executeJSAfterInit ='' Javascript to be executed after InstanceReady of CKEditor
440
-	* @return string the necessary html for the textarea
441
-	*/
428
+	 * this static function is a wrapper for fckEditor to create some reuseable layouts
429
+	 *
430
+	 * @param string $_name name and id of the input-field
431
+	 * @param string $_content of the tinymce (will be run through htmlspecialchars !!!), default ''
432
+	 * @param string $_mode display mode of the tinymce editor can be: simple, extended or advanced
433
+	 * @param array  $_options (toolbar_expanded true/false)
434
+	 * @param string $_height ='400px'
435
+	 * @param string $_width ='100%'
436
+	 * @param string $_start_path ='' if passed activates the browser for image at absolute path passed
437
+	 * @param boolean $_purify =true run $_content through htmlpurifier before handing it to fckEditor
438
+	 * @param mixed (boolean/string) $_focusToBody=false USED only for CKEDIOR true means yes, focus on top, you may specify TOP or BOTTOM (to focus on the end of the editor area)
439
+	 * @param string $_executeJSAfterInit ='' Javascript to be executed after InstanceReady of CKEditor
440
+	 * @return string the necessary html for the textarea
441
+	 */
442 442
 	static function fckEditor($_name, $_content, $_mode, $_options=array('toolbar_expanded' =>'true'),
443 443
 		$_height='400px', $_width='100%',$_start_path='',$_purify=true, $_focusToBody=false, $_executeJSAfterInit='')
444 444
 	{
@@ -509,21 +509,21 @@  discard block
 block discarded – undo
509 509
 	}
510 510
 
511 511
 	/**
512
-	* this static function is a wrapper for tinymce to create some reuseable layouts
513
-	*
514
-	* Please note: if you did not run init_tinymce already you this static function need to be called before the call to phpgw_header() !!!
515
-	*
516
-	* @param string $_name name and id of the input-field
517
-	* @param string $_mode display mode of the tinymce editor can be: simple, extended or advanced
518
-	* @param string $_content ='' of the tinymce (will be run through htmlspecialchars !!!), default ''
519
-	* @param string $_height ='400px'
520
-	* @param string $_width ='100%'
521
-	* @param boolean $_purify =true
522
-	* @param string $_border ='0px' NOT used for CKEditor
523
-	* @param mixed (boolean/string) $_focusToBody=false USED only for CKEDIOR true means yes, focus on top, you may specify TOP or BOTTOM (to focus on the end of the editor area)
524
-	* @param string $_executeJSAfterInit ='' Javascript to be executed after InstanceReady of CKEditor
525
-	* @return string the necessary html for the textarea
526
-	*/
512
+	 * this static function is a wrapper for tinymce to create some reuseable layouts
513
+	 *
514
+	 * Please note: if you did not run init_tinymce already you this static function need to be called before the call to phpgw_header() !!!
515
+	 *
516
+	 * @param string $_name name and id of the input-field
517
+	 * @param string $_mode display mode of the tinymce editor can be: simple, extended or advanced
518
+	 * @param string $_content ='' of the tinymce (will be run through htmlspecialchars !!!), default ''
519
+	 * @param string $_height ='400px'
520
+	 * @param string $_width ='100%'
521
+	 * @param boolean $_purify =true
522
+	 * @param string $_border ='0px' NOT used for CKEditor
523
+	 * @param mixed (boolean/string) $_focusToBody=false USED only for CKEDIOR true means yes, focus on top, you may specify TOP or BOTTOM (to focus on the end of the editor area)
524
+	 * @param string $_executeJSAfterInit ='' Javascript to be executed after InstanceReady of CKEditor
525
+	 * @return string the necessary html for the textarea
526
+	 */
527 527
 	static function fckEditorQuick($_name, $_mode, $_content='', $_height='400px', $_width='100%',$_purify=true, $_border='0px',$_focusToBody=false,$_executeJSAfterInit='')
528 528
 	{
529 529
 		if (!self::htmlarea_availible() || $_mode == 'ascii')
Please login to merge, or discard this patch.
Spacing   +173 added lines, -173 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
 	/**
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	 *
413 413
 	 * creates a textarea inputfield for the htmlarea js-widget (returns the necessary html and js)
414 414
 	 */
415
-	static function htmlarea($name,$content='',$style='',$base_href=''/*,$plugins='',$custom_toolbar='',$set_width_height_in_config=false*/)
415
+	static function htmlarea($name, $content = '', $style = '', $base_href = ''/*,$plugins='',$custom_toolbar='',$set_width_height_in_config=false*/)
416 416
 	{
417 417
 		/*if (!self::htmlarea_availible())
418 418
 		{
@@ -436,15 +436,15 @@  discard block
 block discarded – undo
436 436
 	* @param string $_executeJSAfterInit ='' Javascript to be executed after InstanceReady of CKEditor
437 437
 	* @return string the necessary html for the textarea
438 438
 	*/
439
-	static function fckEditor($_name, $_content, $_mode, $_options=array('toolbar_expanded' =>'true'),
440
-		$_height='400px', $_width='100%',$_start_path='',$_purify=true, $_focusToBody=false, $_executeJSAfterInit='')
439
+	static function fckEditor($_name, $_content, $_mode, $_options = array('toolbar_expanded' =>'true'),
440
+		$_height = '400px', $_width = '100%', $_start_path = '', $_purify = true, $_focusToBody = false, $_executeJSAfterInit = '')
441 441
 	{
442 442
 		//not used anymore but defined in function signature
443 443
 		unset ($_options);
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
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 		// we need to enable double encoding here, as ckEditor has to undo one level of encoding
465 465
 		// otherwise < and > chars eg. from html markup entered in regular (not source) input, will turn into html!
466 466
 		//error_log(__METHOD__.__LINE__.' '.Header\UserAgent::type().','.Header\UserAgent::version());
467
-		return self::textarea($_name,$_content,'id="'.htmlspecialchars($_name).'"',true).	// true = double encoding
467
+		return self::textarea($_name, $_content, 'id="'.htmlspecialchars($_name).'"', true).// true = double encoding
468 468
 '
469 469
 <script type="text/javascript">
470 470
 
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 					"Wingdings=wingdings,zapf dingbats",
571 571
 			fontsize_formats:font_size_formats["'. $font_size_unit.'"],
572 572
 		});
573
-		'.($_executeJSAfterInit?$_executeJSAfterInit:'').'
573
+		'.($_executeJSAfterInit ? $_executeJSAfterInit : '').'
574 574
 });
575 575
 </script>
576 576
 ';
@@ -592,16 +592,16 @@  discard block
 block discarded – undo
592 592
 	* @param string $_executeJSAfterInit ='' Javascript to be executed after InstanceReady of CKEditor
593 593
 	* @return string the necessary html for the textarea
594 594
 	*/
595
-	static function fckEditorQuick($_name, $_mode, $_content='', $_height='400px', $_width='100%',$_purify=true, $_border='0px',$_focusToBody=false,$_executeJSAfterInit='')
595
+	static function fckEditorQuick($_name, $_mode, $_content = '', $_height = '400px', $_width = '100%', $_purify = true, $_border = '0px', $_focusToBody = false, $_executeJSAfterInit = '')
596 596
 	{
597 597
 		if (!self::htmlarea_availible() || $_mode == 'ascii')
598 598
 		{
599 599
 			//TODO: use self::textarea
600
-			return "<textarea name=\"$_name\" style=\"".($_width?" width:".$_width.';':" width:100%;").($_height?" height:".$_height.';':" height:400px;").($_border?" border:".$_border.';':" border:0px;")."\">$_content</textarea>";
600
+			return "<textarea name=\"$_name\" style=\"".($_width ? " width:".$_width.';' : " width:100%;").($_height ? " height:".$_height.';' : " height:400px;").($_border ? " border:".$_border.';' : " border:0px;")."\">$_content</textarea>";
601 601
 		}
602 602
 		else
603 603
 		{
604
-			return self::fckEditor($_name, $_content, $_mode, array(), $_height, $_width,'',$_purify,$_focusToBody,$_executeJSAfterInit);
604
+			return self::fckEditor($_name, $_content, $_mode, array(), $_height, $_width, '', $_purify, $_focusToBody, $_executeJSAfterInit);
605 605
 		}
606 606
 	}
607 607
 
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 	 * @param string $type type, default ''=not specified = text
614 614
 	 * @param string $options attributes for the tag, default ''=none
615 615
 	 */
616
-	static function input($name,$value='',$type='',$options='' )
616
+	static function input($name, $value = '', $type = '', $options = '')
617 617
 	{
618 618
 		switch ((string)$type)
619 619
 		{
@@ -640,12 +640,12 @@  discard block
 block discarded – undo
640 640
 		'cancelled' => '/no(&|\]|$)/',
641 641
 		'ok'     => '/ok(&|\]|$)/',
642 642
 		'close'  => '/close(&|\]|$)/',
643
-		'add'    => '/(add(&|\]|$)|create)/',	// customfields use create*
643
+		'add'    => '/(add(&|\]|$)|create)/', // customfields use create*
644 644
 	);
645 645
 
646 646
 	static protected $default_classes = array(
647
-		'et2_button_cancel'   => '/cancel(&|\]|$)/',	// yellow
648
-		'et2_button_question' => '/(yes|no)(&|\]|$)/',	// yellow
647
+		'et2_button_cancel'   => '/cancel(&|\]|$)/', // yellow
648
+		'et2_button_question' => '/(yes|no)(&|\]|$)/', // yellow
649 649
 		'et2_button_delete'   => '/delete(&|\]|$)/'		// red
650 650
 	);
651 651
 
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 	 * @param string $buttontype which type of html button (button|submit), default ='submit'
663 663
 	 * @return string html
664 664
 	 */
665
-	static function submit_button($name,$label,$onClick='',$no_lang=false,$options='',$image='',$app='phpgwapi', $buttontype='submit')
665
+	static function submit_button($name, $label, $onClick = '', $no_lang = false, $options = '', $image = '', $app = 'phpgwapi', $buttontype = 'submit')
666 666
 	{
667 667
 		// workaround for idots and IE button problem (wrong cursor-image)
668 668
 		if (Header\UserAgent::type() == 'msie')
@@ -674,11 +674,11 @@  discard block
 block discarded – undo
674 674
 
675 675
 		if ($image != '')
676 676
 		{
677
-			$image = str_replace(array('.gif','.GIF','.png','.PNG'),'',$image);
677
+			$image = str_replace(array('.gif', '.GIF', '.png', '.PNG'), '', $image);
678 678
 
679 679
 			if (!($path = Image::find($app, $image)))
680 680
 			{
681
-				$path = $image;		// name may already contain absolut path
681
+				$path = $image; // name may already contain absolut path
682 682
 			}
683 683
 			$image = ' src="'.$path.'"';
684 684
 			$classes[] = 'image_button';
@@ -687,11 +687,11 @@  discard block
 block discarded – undo
687 687
 		{
688 688
 			$label = lang($label);
689 689
 		}
690
-		if (($accesskey = @strstr($label,'&')) && $accesskey[1] != ' ' &&
691
-			(($pos = strpos($accesskey,';')) === false || $pos > 5))
690
+		if (($accesskey = @strstr($label, '&')) && $accesskey[1] != ' ' &&
691
+			(($pos = strpos($accesskey, ';')) === false || $pos > 5))
692 692
 		{
693
-			$label_u = str_replace('&'.$accesskey[1],'<u>'.$accesskey[1].'</u>',$label);
694
-			$label = str_replace('&','',$label);
693
+			$label_u = str_replace('&'.$accesskey[1], '<u>'.$accesskey[1].'</u>', $label);
694
+			$label = str_replace('&', '', $label);
695 695
 			$options .= ' accesskey="'.$accesskey[1].'" '.$options;
696 696
 		}
697 697
 		else
@@ -699,10 +699,10 @@  discard block
 block discarded – undo
699 699
 			$accesskey = '';
700 700
 			$label_u = $label;
701 701
 		}
702
-		if ($onClick) $options .= ' onclick="'.str_replace('"','\\"',$onClick).'"';
702
+		if ($onClick) $options .= ' onclick="'.str_replace('"', '\\"', $onClick).'"';
703 703
 
704 704
 		// add default background-image to get et2 like buttons
705
-		foreach(self::$default_background_images as $img => $reg_exp)
705
+		foreach (self::$default_background_images as $img => $reg_exp)
706 706
 		{
707 707
 			if (preg_match($reg_exp, $name) && ($url = Image::find($GLOBALS['egw_info']['flags']['currentapp'], $img)))
708 708
 			{
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 			}
713 713
 		}
714 714
 		// add default class for cancel, delete or yes/no buttons
715
-		foreach(self::$default_classes as $class => $reg_exp)
715
+		foreach (self::$default_classes as $class => $reg_exp)
716 716
 		{
717 717
 			if (preg_match($reg_exp, $name))
718 718
 			{
@@ -746,19 +746,19 @@  discard block
 block discarded – undo
746 746
 	 * @param array|string $vars query or array ('name' => 'value', ...) with query
747 747
 	 * @return string absolut link already run through $phpgw->link
748 748
 	 */
749
-	static function link($_url,$vars='')
749
+	static function link($_url, $vars = '')
750 750
 	{
751 751
 		if (!is_array($vars))
752 752
 		{
753
-			parse_str($vars,$vars);
753
+			parse_str($vars, $vars);
754 754
 		}
755
-		list($url,$v) = explode('?', $_url);	// url may contain additional vars
755
+		list($url, $v) = explode('?', $_url); // url may contain additional vars
756 756
 		if ($v)
757 757
 		{
758
-			parse_str($v,$v);
758
+			parse_str($v, $v);
759 759
 			$vars += $v;
760 760
 		}
761
-		return Framework::link($url,$vars);
761
+		return Framework::link($url, $vars);
762 762
 	}
763 763
 
764 764
 	/**
@@ -770,9 +770,9 @@  discard block
 block discarded – undo
770 770
 	 * @param string $options attributes for the tag, default ''=none
771 771
 	 * @return string html
772 772
 	 */
773
-	static function checkbox($name,$checked=false,$value='True',$options='')
773
+	static function checkbox($name, $checked = false, $value = 'True', $options = '')
774 774
 	{
775
-		return '<input type="checkbox" name="'.$name.'" value="'.self::htmlspecialchars($value).'"' .($checked ? ' checked="1"' : '') . "$options />\n";
775
+		return '<input type="checkbox" name="'.$name.'" value="'.self::htmlspecialchars($value).'"'.($checked ? ' checked="1"' : '')."$options />\n";
776 776
 	}
777 777
 
778 778
 	/**
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 	 * @param string $method method of the form, default 'POST'
788 788
 	 * @return string html
789 789
 	 */
790
-	static function form($content,$hidden_vars,$_url,$url_vars='',$name='',$options='',$method='POST')
790
+	static function form($content, $hidden_vars, $_url, $url_vars = '', $name = '', $options = '', $method = 'POST')
791 791
 	{
792 792
 		$url = $_url ? self::link($_url, $url_vars) : $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
793 793
 		$html = "<form method=\"$method\" ".($name != '' ? "name=\"$name\" " : '')."action=\"$url\" $options>\n";
@@ -814,9 +814,9 @@  discard block
 block discarded – undo
814 814
 	 * @param string $method method of the form, default 'POST'
815 815
 	 * @return string html
816 816
 	 */
817
-	static function form_1button($name,$label,$hidden_vars,$url,$url_vars='',$form_name='',$method='POST')
817
+	static function form_1button($name, $label, $hidden_vars, $url, $url_vars = '', $form_name = '', $method = 'POST')
818 818
 	{
819
-		return self::form(self::submit_button($name,$label),$hidden_vars,$url,$url_vars,$form_name,' style="display: inline-block"',$method);
819
+		return self::form(self::submit_button($name, $label), $hidden_vars, $url, $url_vars, $form_name, ' style="display: inline-block"', $method);
820 820
 	}
821 821
 
822 822
 	const THEAD = 1;
@@ -849,34 +849,34 @@  discard block
 block discarded – undo
849 849
 	 * @param boolean $no_table_tr dont return the table- and outmost tr-tabs, default false=return table+tr
850 850
 	 * @return string with html-code of the table
851 851
 	 */
852
-	static function table($rows,$options = '',$no_table_tr=False)
852
+	static function table($rows, $options = '', $no_table_tr = False)
853 853
 	{
854 854
 		$html = $no_table_tr ? '' : "<table $options>\n";
855 855
 
856 856
 		$part = 0;
857
-		foreach($rows as $key => $row)
857
+		foreach ($rows as $key => $row)
858 858
 		{
859 859
 			if (!is_array($row))
860 860
 			{
861
-				continue;					// parameter
861
+				continue; // parameter
862 862
 			}
863 863
 			// get the current part from the optional 'h' or 'f' prefix of the key
864 864
 			$p = $key[0] == 'h' ? self::THEAD : ($key[0] == 'f' ? self::TFOOT : self::TBODY);
865 865
 			if ($part < $p && ($part || $p < self::TBODY))	// add only allowed and neccessary transitions
866 866
 			{
867 867
 				if ($part) $html .= '</'.self::$part2tag[$part].">\n";
868
-				$html .= '<'.self::$part2tag[$part=$p].">\n";
868
+				$html .= '<'.self::$part2tag[$part = $p].">\n";
869 869
 			}
870 870
 			$html .= $no_table_tr && $key == 1 ? '' : "\t<tr ".$rows['.'.$key].">\n";
871 871
 
872
-			foreach($row as $key => $cell)
872
+			foreach ($row as $key => $cell)
873 873
 			{
874 874
 				if ($key[0] == '.')
875 875
 				{
876
-					continue;				// parameter
876
+					continue; // parameter
877 877
 				}
878
-				$table_pos = strpos($cell,'<table');
879
-				$td_pos = strpos($cell,'<td');
878
+				$table_pos = strpos($cell, '<table');
879
+				$td_pos = strpos($cell, '<td');
880 880
 				if ($td_pos !== False && ($table_pos === False || $td_pos < $table_pos))
881 881
 				{
882 882
 					$html .= $cell;
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 
901 901
 		if ($no_table_tr)
902 902
 		{
903
-			$html = substr($html,0,-16);
903
+			$html = substr($html, 0, -16);
904 904
 		}
905 905
 		return $html;
906 906
 	}
@@ -912,12 +912,12 @@  discard block
 block discarded – undo
912 912
 	 * @param boolean $no_script if true generate a submit-button if javascript is off
913 913
 	 * @return string html
914 914
 	 */
915
-	static function sbox_submit( $sbox,$no_script=false )
915
+	static function sbox_submit($sbox, $no_script = false)
916 916
 	{
917
-		$html = str_replace('<select','<select onchange="this.form.submit()" ',$sbox);
917
+		$html = str_replace('<select', '<select onchange="this.form.submit()" ', $sbox);
918 918
 		if ($no_script)
919 919
 		{
920
-			$html .= '<noscript>'.self::submit_button('send','>').'</noscript>';
920
+			$html .= '<noscript>'.self::submit_button('send', '>').'</noscript>';
921 921
 		}
922 922
 		return $html;
923 923
 	}
@@ -933,17 +933,17 @@  discard block
 block discarded – undo
933 933
 	 * @param string $height height, default 5px
934 934
 	 * @return string html
935 935
 	 */
936
-	static function progressbar($_percent, $_title='',$options='',$width='',$color='',$height='' )
936
+	static function progressbar($_percent, $_title = '', $options = '', $width = '', $color = '', $height = '')
937 937
 	{
938 938
 		$percent = (int)$_percent;
939 939
 		if (!$width) $width = '30px';
940
-		if (!$height)$height= '5px';
940
+		if (!$height)$height = '5px';
941 941
 		if (!$color) $color = '#D00000';
942 942
 		$title = $_title ? self::htmlspecialchars($_title) : $percent.'%';
943 943
 
944 944
 		return '<div class="onlyPrint">'.$title.'</div><div class="noPrint" title="'.$title.'" '.$options.
945 945
 			' style="height: '.$height.'; width: '.$width.'; border: 1px solid black; padding: 1px; text-align: left;'.
946
-			(@stristr($options,'onclick="') ? ' cursor: pointer;' : '').'">'."\n\t".
946
+			(@stristr($options, 'onclick="') ? ' cursor: pointer;' : '').'">'."\n\t".
947 947
 			'<div style="height: '.$height.'; width: '.$percent.'%; background: '.$color.';"></div>'."\n</div>\n";
948 948
 	}
949 949
 
@@ -961,32 +961,32 @@  discard block
 block discarded – undo
961 961
 	 * @param string $options further options for the tag, default '' = none
962 962
 	 * @return string the html
963 963
 	 */
964
-	static function image( $app,$name,$title='',$options='' )
964
+	static function image($app, $name, $title = '', $options = '')
965 965
 	{
966 966
 		if (is_array($name))	// menuaction and other get-vars
967 967
 		{
968
-			$name = $GLOBALS['egw']->link('/index.php',$name);
968
+			$name = $GLOBALS['egw']->link('/index.php', $name);
969 969
 		}
970
-		if (substr($name,0,5) == 'vfs:/')	// vfs pseudo protocoll
970
+		if (substr($name, 0, 5) == 'vfs:/')	// vfs pseudo protocoll
971 971
 		{
972
-			$name = Framework::link(Vfs::download_url(substr($name,4)));
972
+			$name = Framework::link(Vfs::download_url(substr($name, 4)));
973 973
 		}
974
-		if ($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://' || stripos($name,'api/thumbnail.php') )
974
+		if ($name[0] == '/' || substr($name, 0, 7) == 'http://' || substr($name, 0, 8) == 'https://' || stripos($name, 'api/thumbnail.php'))
975 975
 		{
976
-			if (!($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://')) $name = '/'.$name;
976
+			if (!($name[0] == '/' || substr($name, 0, 7) == 'http://' || substr($name, 0, 8) == 'https://')) $name = '/'.$name;
977 977
 			$url = $name;
978 978
 		}
979 979
 		else	// no URL, so try searching the image
980 980
 		{
981
-			$name = str_replace(array('.gif','.GIF','.png','.PNG'),'',$name);
981
+			$name = str_replace(array('.gif', '.GIF', '.png', '.PNG'), '', $name);
982 982
 
983
-			if (!($url = Image::find($app,$name)))
983
+			if (!($url = Image::find($app, $name)))
984 984
 			{
985
-				$url = $name;		// name may already contain absolut path
985
+				$url = $name; // name may already contain absolut path
986 986
 			}
987
-			if($GLOBALS['egw_info']['server']['webserver_url'])
987
+			if ($GLOBALS['egw_info']['server']['webserver_url'])
988 988
 			{
989
-				list(,$path) = explode($GLOBALS['egw_info']['server']['webserver_url'],$url);
989
+				list(,$path) = explode($GLOBALS['egw_info']['server']['webserver_url'], $url);
990 990
 
991 991
 				if (!is_null($path)) $path = EGW_SERVER_ROOT.$path;
992 992
 			}
@@ -995,12 +995,12 @@  discard block
 block discarded – undo
995 995
 				$path = EGW_SERVER_ROOT.$url;
996 996
 			}
997 997
 
998
-			if (is_null($path) || (!@is_readable($path) && stripos($path,'webdav.php')===false))
998
+			if (is_null($path) || (!@is_readable($path) && stripos($path, 'webdav.php') === false))
999 999
 			{
1000 1000
 				// if the image-name is a percentage, use a progressbar
1001
-				if (substr($name,-1) == '%' && is_numeric($percent = substr($name,0,-1)))
1001
+				if (substr($name, -1) == '%' && is_numeric($percent = substr($name, 0, -1)))
1002 1002
 				{
1003
-					return self::progressbar($percent,$title);
1003
+					return self::progressbar($percent, $title);
1004 1004
 				}
1005 1005
 				return $title;
1006 1006
 			}
@@ -1011,12 +1011,12 @@  discard block
 block discarded – undo
1011 1011
 		}
1012 1012
 
1013 1013
 		// This block makes pngfix.js useless, adding a check on disable_pngfix to have pngfix.js do its thing
1014
-		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'])))
1014
+		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'])))
1015 1015
 		{
1016 1016
 			$extra_styles = "display: inline-block; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='$url',sizingMethod='image'); width: 1px; height: 1px;";
1017
-			if (false!==strpos($options,'style="'))
1017
+			if (false !== strpos($options, 'style="'))
1018 1018
 			{
1019
-				$options = str_replace('style="','style="'.$extra_styles, $options);
1019
+				$options = str_replace('style="', 'style="'.$extra_styles, $options);
1020 1020
 			}
1021 1021
 			else
1022 1022
 			{
@@ -1036,24 +1036,24 @@  discard block
 block discarded – undo
1036 1036
 	 * @param string $options attributes for the tag, default ''=none
1037 1037
 	 * @return string the html
1038 1038
 	 */
1039
-	static function a_href( $content,$url,$vars='',$options='')
1039
+	static function a_href($content, $url, $vars = '', $options = '')
1040 1040
 	{
1041 1041
 		if (is_array($url))
1042 1042
 		{
1043 1043
 			$vars = $url;
1044 1044
 			$url = '/index.php';
1045 1045
 		}
1046
-		elseif (strpos($url,'/')===false &&
1047
-			count(explode('.',$url)) >= 3 &&
1048
-			!(strpos($url,'mailto:')!==false ||
1049
-			strpos($url,'://')!==false ||
1050
-			strpos($url,'javascript:')!==false))
1046
+		elseif (strpos($url, '/') === false &&
1047
+			count(explode('.', $url)) >= 3 &&
1048
+			!(strpos($url, 'mailto:') !== false ||
1049
+			strpos($url, '://') !== false ||
1050
+			strpos($url, 'javascript:') !== false))
1051 1051
 		{
1052 1052
 			$url = "/index.php?menuaction=$url";
1053 1053
 		}
1054 1054
 		if ($url[0] == '/')		// link relative to eGW
1055 1055
 		{
1056
-			$url = self::link($url,$vars);
1056
+			$url = self::link($url, $vars);
1057 1057
 		}
1058 1058
 		//echo "<p>self::a_href('".self::htmlspecialchars($content)."','$url',".print_r($vars,True).") = ".self::link($url,$vars)."</p>";
1059 1059
 		return '<a href="'.self::htmlspecialchars($url).'" '.$options.'>'.$content.'</a>';
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
 	 */
1068 1068
 	static function bold($content)
1069 1069
 	{
1070
-		return '<b>'.($content?$content.'</b>':'');
1070
+		return '<b>'.($content ? $content.'</b>' : '');
1071 1071
 	}
1072 1072
 
1073 1073
 	/**
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 	 * @param string $options attributes for the tag, default ''=none
1078 1078
 	 * @return string the html
1079 1079
 	 */
1080
-	static function hr($width='',$options='')
1080
+	static function hr($width = '', $options = '')
1081 1081
 	{
1082 1082
 		if ($width) $options .= " width=\"$width\"";
1083 1083
 
@@ -1093,12 +1093,12 @@  discard block
 block discarded – undo
1093 1093
 	 * @param mixed $names String (or Array) with the option-names eg. 'WIDTH,HEIGHT,BORDER'
1094 1094
 	 * @return string with options/attributes
1095 1095
 	 */
1096
-	static function formatOptions($options,$names)
1096
+	static function formatOptions($options, $names)
1097 1097
 	{
1098
-		if (!is_array($options)) $options = explode(',',$options);
1099
-		if (!is_array($names))   $names   = explode(',',$names);
1098
+		if (!is_array($options)) $options = explode(',', $options);
1099
+		if (!is_array($names))   $names   = explode(',', $names);
1100 1100
 
1101
-		foreach($options as $n => $val)
1101
+		foreach ($options as $n => $val)
1102 1102
 		{
1103 1103
 			if ($val != '' && $names[$n] != '')
1104 1104
 			{
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 	 * @param string $options attributes for the tag, default ''=none
1129 1129
 	 * @return string the html
1130 1130
 	 */
1131
-	static function label($content,$id='',$accesskey='',$options='')
1131
+	static function label($content, $id = '', $accesskey = '', $options = '')
1132 1132
 	{
1133 1133
 		if ($id != '')
1134 1134
 		{
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
 	 * @param string $options attributes for the tag, default ''=none
1150 1150
 	 * @return string the html
1151 1151
 	 */
1152
-	static function fieldset($content,$legend='',$options='')
1152
+	static function fieldset($content, $legend = '', $options = '')
1153 1153
 	{
1154 1154
 		$html = "<fieldset $options>".($legend ? '<legend>'.self::htmlspecialchars($legend).'</legend>' : '')."\n";
1155 1155
 
@@ -1183,9 +1183,9 @@  discard block
 block discarded – undo
1183 1183
 	 *
1184 1184
 	 * @return string the html code, to be added into the template
1185 1185
 	 */
1186
-	static function tree($_folders,$_selected,$_topFolder=false,$_onNodeSelect="null",$tree='foldertree',$_divClass='',
1187
-		$_leafImage='',$_onCheckHandler=false,$delimiter='/',$folderImageDir=null,$autoLoading=null,$dataMode='JSON',
1188
-		$dragndrop=false)
1186
+	static function tree($_folders, $_selected, $_topFolder = false, $_onNodeSelect = "null", $tree = 'foldertree', $_divClass = '',
1187
+		$_leafImage = '', $_onCheckHandler = false, $delimiter = '/', $folderImageDir = null, $autoLoading = null, $dataMode = 'JSON',
1188
+		$dragndrop = false)
1189 1189
 	{
1190 1190
 		$webserver_url = $GLOBALS['egw_info']['server']['webserver_url'];
1191 1191
 		if (empty($folderImageDir))
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
 			//error_log(__METHOD__."() setting templated image-path: $folderImageDir");
1209 1209
 		}
1210 1210
 
1211
-		static $tree_initialised=false;
1211
+		static $tree_initialised = false;
1212 1212
 		if (!$tree_initialised)
1213 1213
 		{
1214 1214
 			Framework::includeCSS('/api/js/dhtmlxtree/codebase/dhtmlxtree.css');
@@ -1218,16 +1218,16 @@  discard block
 block discarded – undo
1218 1218
 			$tree_initialised = true;
1219 1219
 			if (!$_folders && !$autoLoading) return null;
1220 1220
 		}
1221
-		$html = self::div("\n",'id="'.$tree.'"',$_divClass).$html;
1221
+		$html = self::div("\n", 'id="'.$tree.'"', $_divClass).$html;
1222 1222
 		$html .= "<script type='text/javascript'>\n";
1223 1223
 		$html .= "var $tree;";
1224 1224
 		$html .= "egw_LAB.wait(function() {";
1225 1225
 		$html .= "$tree = new"." dhtmlXTreeObject('$tree','100%','100%',0);\n";
1226
-		$html .= "$tree.parentObject.style.overflow='auto';\n";	// dhtmlXTree constructor has hidden hardcoded
1226
+		$html .= "$tree.parentObject.style.overflow='auto';\n"; // dhtmlXTree constructor has hidden hardcoded
1227 1227
 		if (Translation::charset() == 'utf-8') $html .= "if ($tree.setEscapingMode) $tree.setEscapingMode('utf8');\n";
1228 1228
 		$html .= "$tree.setImagePath('$folderImageDir/dhtmlxtree/');\n";
1229 1229
 
1230
-		if($_onCheckHandler)
1230
+		if ($_onCheckHandler)
1231 1231
 		{
1232 1232
 			$html .= "$tree.enableCheckBoxes(1);\n";
1233 1233
 			$html .= "$tree.setOnCheckHandler('$_onCheckHandler');\n";
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
 		if ($autoLoading)
1239 1239
 		{
1240 1240
 			$autoLoading = is_array($autoLoading) ?
1241
-				Framework::link('/index.php',$autoLoading) : Framework::link($autoLoading);
1241
+				Framework::link('/index.php', $autoLoading) : Framework::link($autoLoading);
1242 1242
 			$html .= "$tree.setXMLAutoLoading('$autoLoading');\n";
1243 1243
 			if ($dataMode != 'XML') $html .= "$tree.setDataMode('$dataMode');\n";
1244 1244
 
@@ -1279,7 +1279,7 @@  discard block
 block discarded – undo
1279 1279
 		}
1280 1280
 		if (is_string($_folders))
1281 1281
 		{
1282
-			switch($dataMode)
1282
+			switch ($dataMode)
1283 1283
 			{
1284 1284
 				case 'JSON':
1285 1285
 					$html .= "$tree.loadJSONObject($_folders);\n"; break;
@@ -1290,10 +1290,10 @@  discard block
 block discarded – undo
1290 1290
 		else
1291 1291
 		{
1292 1292
 			// evtl. remove leading delimiter
1293
-			if ($_selected[0] == $delimiter) $_selected = substr($_selected,1);
1293
+			if ($_selected[0] == $delimiter) $_selected = substr($_selected, 1);
1294 1294
 
1295 1295
 			$n = 0;
1296
-			foreach($_folders as $path => $data)
1296
+			foreach ($_folders as $path => $data)
1297 1297
 			{
1298 1298
 				if (!is_array($data))
1299 1299
 				{
@@ -1305,10 +1305,10 @@  discard block
 block discarded – undo
1305 1305
 				if ($_leafImage)
1306 1306
 				{
1307 1307
 					$image1 = $image2 = $image3 = "'".$_leafImage."'";
1308
-					if (($next_item = array_slice($_folders, $n+1, 1, true)))
1308
+					if (($next_item = array_slice($_folders, $n + 1, 1, true)))
1309 1309
 					{
1310 1310
 						$next_path = key($next_item);
1311
-						if (substr($next_path,0,strlen($path)+1) == $path.'/')
1311
+						if (substr($next_path, 0, strlen($path) + 1) == $path.'/')
1312 1312
 						{
1313 1313
 							$image1 = $image2 = $image3 = '0';
1314 1314
 						}
@@ -1319,22 +1319,22 @@  discard block
 block discarded – undo
1319 1319
 					$image1 = $image2 = $image3 = "'".$data['image']."'";
1320 1320
 				}
1321 1321
 				// evtl. remove leading delimiter
1322
-				if ($path[0] == $delimiter) $path = substr($path,1);
1323
-				$folderParts = explode($delimiter,$path);
1322
+				if ($path[0] == $delimiter) $path = substr($path, 1);
1323
+				$folderParts = explode($delimiter, $path);
1324 1324
 
1325 1325
 				//get rightmost folderpart
1326 1326
 				$label = array_pop($folderParts);
1327 1327
 				if (isset($data['label'])) $label = $data['label'];
1328 1328
 
1329 1329
 				// the rest of the array is the name of the parent
1330
-				$parentName = implode((array)$folderParts,$delimiter);
1331
-				if(empty($parentName)) $parentName = $top;
1330
+				$parentName = implode((array)$folderParts, $delimiter);
1331
+				if (empty($parentName)) $parentName = $top;
1332 1332
 
1333 1333
 				$entryOptions = !isset($data['child']) || $data['child'] ? 'CHILD' : '';
1334 1334
 				if ($_onCheckHandler && $_selected)	// check selected items on multi selection
1335 1335
 				{
1336
-					if (!is_array($_selected)) $_selected = explode(',',$_selected);
1337
-					if (array_search("$path",$_selected)!==false) $entryOptions .= ',CHECKED';
1336
+					if (!is_array($_selected)) $_selected = explode(',', $_selected);
1337
+					if (array_search("$path", $_selected) !== false) $entryOptions .= ',CHECKED';
1338 1338
 					//echo "<p>path=$path, _selected=".print_r($_selected,true).": $entryOptions</p>\n";
1339 1339
 				}
1340 1340
 				// highlight current item
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
 		$html .= "$tree.closeAllItems(0);\n";
1355 1355
 		if ($_selected)
1356 1356
 		{
1357
-			foreach(is_array($_selected)?$_selected:array($_selected) as $path)
1357
+			foreach (is_array($_selected) ? $_selected : array($_selected) as $path)
1358 1358
 			{
1359 1359
 				$html .= "$tree.openItem('".addslashes($path)."');\n";
1360 1360
 			}
@@ -1379,7 +1379,7 @@  discard block
 block discarded – undo
1379 1379
 	 *		or to restrict the attribute's values
1380 1380
 	 * @param boolean $_force =null - force the config passed to be used without merging to the default
1381 1381
 	 */
1382
-	static function purify($html,$config=null,$spec=array(),$_force=false)
1382
+	static function purify($html, $config = null, $spec = array(), $_force = false)
1383 1383
 	{
1384 1384
 		return Html\HtmLawed::purify($html, $config, $spec, $_force);
1385 1385
 	}
Please login to merge, or discard this patch.
Braces   +179 added lines, -46 removed lines patch added patch discarded remove patch
@@ -34,7 +34,11 @@  discard block
 block discarded – undo
34 34
 	 */
35 35
 	static function activate_links($content)
36 36
 	{
37
-		if (!$content || strlen($content) < 20) return $content;	// performance
37
+		if (!$content || strlen($content) < 20)
38
+		{
39
+			return $content;
40
+		}
41
+		// performance
38 42
 
39 43
 		// Exclude everything which is already a link
40 44
 		$NotAnchor = '(?<!"|href=|href\s=\s|href=\s|href\s=)';
@@ -57,10 +61,14 @@  discard block
 block discarded – undo
57 61
 			return $match[1]."<a href=\"".($match[2]&&!$match[3]?$match[2]:'').($match[3]?$match[3]:'').$match[4].$match[5]."\" target=\"_blank\">".$match[4].$match[5]."</a>".$match[6];
58 62
 		}, $result);
59 63
 
60
-		if (true)	// hack to keep IDE from complaing about double assignments
64
+		if (true)
65
+		{
66
+			// hack to keep IDE from complaing about double assignments
61 67
 		{
62 68
 			//  First match things beginning with http:// (or other protocols)
63
-			$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))';	// only http:// gets removed, other protocolls are shown
69
+			$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))';
70
+		}
71
+		// only http:// gets removed, other protocolls are shown
64 72
 			$Domain = '([\w-]+\.[\w\-.]+)';
65 73
 			$Subdir = '([\w\-\.,@?^=%&;:\/~\+#]*[\w\-\@?^=%&\/~\+#])?';
66 74
 			$optStuff = '(&quot;|&quot|;)?';
@@ -98,7 +106,8 @@  discard block
 block discarded – undo
98 106
 			$Expr = '/' .$optBracket0. $NotAnchor . $NotHTTP . $Domain2 . $Subdir2 .$optBracket. '/i';
99 107
 			//$Expr = '/' . $NotAnchor . $NotHTTP . $Domain . $Subdir . $optBracket . '/i';
100 108
 			// use preg_replace_callback as we experienced problems with links such as <www.example.tld/pfad/zu/einer/pdf-Datei.pdf>
101
-			$result4 = preg_replace_callback( $Expr, function ($match) {
109
+			$result4 = preg_replace_callback( $Expr, function ($match)
110
+			{
102 111
 					//error_log(__METHOD__.__LINE__.array2string($match));
103 112
 					if ($match[4]==';' && (strlen($match[3])-4) >=0 && strpos($match[3],'&gt',strlen($match[3])-4)!==false)
104 113
 					{
@@ -148,7 +157,11 @@  discard block
 block discarded – undo
148 157
 	 */
149 158
 	static function select($name, $key, $arr=0,$no_lang=false,$options='',$multiple=0,$enhanced=null)
150 159
 	{
151
-		if(is_null($enhanced)) $enhanced = false;	//disabled by default (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
160
+		if(is_null($enhanced))
161
+		{
162
+			$enhanced = false;
163
+		}
164
+		//disabled by default (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
152 165
 
153 166
 		if (!is_array($arr))
154 167
 		{
@@ -211,7 +224,8 @@  discard block
 block discarded – undo
211 224
 		}
212 225
 		$out .= "</select>\n";
213 226
 
214
-		if($enhanced) {
227
+		if($enhanced)
228
+		{
215 229
 			Framework::includeJS('/api/js/jquery/chosen/chosen.jquery.js');
216 230
 			Framework::includeCSS('/api/js/jquery/chosen/chosen.css',null,false);
217 231
 			$out .= "<script>var lab = egw_LAB || \$LAB; lab.wait(function() {jQuery(function() {if(jQuery().chosen) jQuery('select[name=\"$name\"]').chosen({width: '100%'});});})</script>\n";
@@ -238,13 +252,19 @@  discard block
 block discarded – undo
238 252
 	static function checkbox_multiselect($name, $key, $arr=0,$no_lang=false,$options='',$multiple=3,$selected_first=true,$style='',$enhanced = null)
239 253
 	{
240 254
 		//echo "<p align=right>checkbox_multiselect('$name',".array2string($key).",".array2string($arr).",$no_lang,'$options',$multiple,$selected_first,'$style')</p>\n";
241
-		if(is_null($enhanced)) $enhanced = (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
255
+		if(is_null($enhanced))
256
+		{
257
+			$enhanced = (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
258
+		}
242 259
 
243 260
 		if (!is_array($arr))
244 261
 		{
245 262
 			$arr = array('no','yes');
246 263
 		}
247
-		if ((int)$multiple <= 0) $multiple = 1;
264
+		if ((int)$multiple <= 0)
265
+		{
266
+			$multiple = 1;
267
+		}
248 268
 
249 269
 		if (substr($name,-2) != '[]')
250 270
 		{
@@ -252,7 +272,10 @@  discard block
 block discarded – undo
252 272
 		}
253 273
 		$base_name = substr($name,0,-2);
254 274
 
255
-		if($enhanced) return self::select($name, $key, $arr,$no_lang,$options." style=\"$style\" ",$multiple,$enhanced);
275
+		if($enhanced)
276
+		{
277
+			return self::select($name, $key, $arr,$no_lang,$options." style=\"$style\" ",$multiple,$enhanced);
278
+		}
256 279
 
257 280
 		if (!is_array($key))
258 281
 		{
@@ -290,18 +313,36 @@  discard block
 block discarded – undo
290 313
 			{
291 314
 				$title = '';
292 315
 			}
293
-			if ($label && !$no_lang) $label = lang($label);
294
-			if ($title && !$no_lang) $title = lang($title);
316
+			if ($label && !$no_lang)
317
+			{
318
+				$label = lang($label);
319
+			}
320
+			if ($title && !$no_lang)
321
+			{
322
+				$title = lang($title);
323
+			}
295 324
 
296
-			if (strlen($label) > $max_len) $max_len = strlen($label);
325
+			if (strlen($label) > $max_len)
326
+			{
327
+				$max_len = strlen($label);
328
+			}
297 329
 
298 330
 			$html .= self::label(self::checkbox($name,in_array((string)$val,$key),$val,$options_no_id.
299 331
 				' id="'.$base_name.'['.$val.']'.'"').self::htmlspecialchars($label),
300 332
 				$base_name.'['.$val.']','',($title ? 'title="'.self::htmlspecialchars($title).'" ':''))."<br />\n";
301 333
 		}
302
-		if ($style && substr($style,-1) != ';') $style .= '; ';
303
-		if (strpos($style,'height')===false) $style .= 'height: '.(1.7*$multiple).'em; ';
304
-		if (strpos($style,'width')===false)  $style .= 'width: '.(4+$max_len*($max_len < 15 ? 0.65 : 0.6)).'em; ';
334
+		if ($style && substr($style,-1) != ';')
335
+		{
336
+			$style .= '; ';
337
+		}
338
+		if (strpos($style,'height')===false)
339
+		{
340
+			$style .= 'height: '.(1.7*$multiple).'em; ';
341
+		}
342
+		if (strpos($style,'width')===false)
343
+		{
344
+			$style .= 'width: '.(4+$max_len*($max_len < 15 ? 0.65 : 0.6)).'em; ';
345
+		}
305 346
 		$style .= 'background-color: white; overflow: auto; border: lightgray 2px inset; text-align: left;';
306 347
 
307 348
 		return self::div($html,$options,'',$style);
@@ -326,7 +367,10 @@  discard block
 block discarded – undo
326 367
 			$found = false;
327 368
 			foreach($selected as $sel)
328 369
 			{
329
-				if (($found = (((string) $value) === ((string) $selected[$key])))) break;
370
+				if (($found = (((string) $value) === ((string) $selected[$key]))))
371
+				{
372
+					break;
373
+				}
330 374
 			}
331 375
 			unset($sel);
332 376
 		}
@@ -347,8 +391,14 @@  discard block
 block discarded – undo
347 391
 	 */
348 392
 	static function div($content,$options='',$class='',$style='')
349 393
 	{
350
-		if ($class) $options .= ' class="'.$class.'"';
351
-		if ($style) $options .= ' style="'.$style.'"';
394
+		if ($class)
395
+		{
396
+			$options .= ' class="'.$class.'"';
397
+		}
398
+		if ($style)
399
+		{
400
+			$options .= ' style="'.$style.'"';
401
+		}
352 402
 
353 403
 		return "<div $options>\n".($content ? "$content</div>\n" : '');
354 404
 	}
@@ -373,10 +423,13 @@  discard block
 block discarded – undo
373 423
 			{
374 424
 				$value = json_encode($value);
375 425
 			}
376
-			if (!$ignore_empty || $value && !($name == 'filter' && $value == 'none'))	// dont need to send all the empty vars
426
+			if (!$ignore_empty || $value && !($name == 'filter' && $value == 'none'))
427
+			{
428
+				// dont need to send all the empty vars
377 429
 			{
378 430
 				$html .= "<input type=\"hidden\" name=\"$name\" value=\"".self::htmlspecialchars($value)."\" />\n";
379 431
 			}
432
+			}
380 433
 		}
381 434
 		return $html;
382 435
 	}
@@ -452,7 +505,9 @@  discard block
 block discarded – undo
452 505
 
453 506
 		// run content through htmlpurifier
454 507
 		if ($_purify && !empty($_content))
455
-			$_content = self::purify($_content);
508
+		{
509
+					$_content = self::purify($_content);
510
+		}
456 511
 
457 512
 		// User preferences
458 513
 		$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
@@ -699,7 +754,10 @@  discard block
 block discarded – undo
699 754
 			$accesskey = '';
700 755
 			$label_u = $label;
701 756
 		}
702
-		if ($onClick) $options .= ' onclick="'.str_replace('"','\\"',$onClick).'"';
757
+		if ($onClick)
758
+		{
759
+			$options .= ' onclick="'.str_replace('"','\\"',$onClick).'"';
760
+		}
703 761
 
704 762
 		// add default background-image to get et2 like buttons
705 763
 		foreach(self::$default_background_images as $img => $reg_exp)
@@ -862,9 +920,12 @@  discard block
 block discarded – undo
862 920
 			}
863 921
 			// get the current part from the optional 'h' or 'f' prefix of the key
864 922
 			$p = $key[0] == 'h' ? self::THEAD : ($key[0] == 'f' ? self::TFOOT : self::TBODY);
865
-			if ($part < $p && ($part || $p < self::TBODY))	// add only allowed and neccessary transitions
923
+			if ($part < $p && ($part || $p < self::TBODY))
924
+			{
925
+				// add only allowed and neccessary transitions
866 926
 			{
867 927
 				if ($part) $html .= '</'.self::$part2tag[$part].">\n";
928
+			}
868 929
 				$html .= '<'.self::$part2tag[$part=$p].">\n";
869 930
 			}
870 931
 			$html .= $no_table_tr && $key == 1 ? '' : "\t<tr ".$rows['.'.$key].">\n";
@@ -892,10 +953,13 @@  discard block
 block discarded – undo
892 953
 		{
893 954
 			echo "<p>".function_backtrace()."</p>\n";
894 955
 		}
895
-		if ($part)	// close current part
956
+		if ($part)
957
+		{
958
+			// close current part
896 959
 		{
897 960
 			$html .= "</".self::$part2tag[$part].">\n";
898 961
 		}
962
+		}
899 963
 		$html .= "</table>\n";
900 964
 
901 965
 		if ($no_table_tr)
@@ -936,9 +1000,18 @@  discard block
 block discarded – undo
936 1000
 	static function progressbar($_percent, $_title='',$options='',$width='',$color='',$height='' )
937 1001
 	{
938 1002
 		$percent = (int)$_percent;
939
-		if (!$width) $width = '30px';
940
-		if (!$height)$height= '5px';
941
-		if (!$color) $color = '#D00000';
1003
+		if (!$width)
1004
+		{
1005
+			$width = '30px';
1006
+		}
1007
+		if (!$height)
1008
+		{
1009
+			$height= '5px';
1010
+		}
1011
+		if (!$color)
1012
+		{
1013
+			$color = '#D00000';
1014
+		}
942 1015
 		$title = $_title ? self::htmlspecialchars($_title) : $percent.'%';
943 1016
 
944 1017
 		return '<div class="onlyPrint">'.$title.'</div><div class="noPrint" title="'.$title.'" '.$options.
@@ -963,17 +1036,26 @@  discard block
 block discarded – undo
963 1036
 	 */
964 1037
 	static function image( $app,$name,$title='',$options='' )
965 1038
 	{
966
-		if (is_array($name))	// menuaction and other get-vars
1039
+		if (is_array($name))
1040
+		{
1041
+			// menuaction and other get-vars
967 1042
 		{
968 1043
 			$name = $GLOBALS['egw']->link('/index.php',$name);
969 1044
 		}
970
-		if (substr($name,0,5) == 'vfs:/')	// vfs pseudo protocoll
1045
+		}
1046
+		if (substr($name,0,5) == 'vfs:/')
1047
+		{
1048
+			// vfs pseudo protocoll
971 1049
 		{
972 1050
 			$name = Framework::link(Vfs::download_url(substr($name,4)));
973 1051
 		}
1052
+		}
974 1053
 		if ($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://' || stripos($name,'api/thumbnail.php') )
975 1054
 		{
976
-			if (!($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://')) $name = '/'.$name;
1055
+			if (!($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://'))
1056
+			{
1057
+				$name = '/'.$name;
1058
+			}
977 1059
 			$url = $name;
978 1060
 		}
979 1061
 		else	// no URL, so try searching the image
@@ -988,7 +1070,10 @@  discard block
 block discarded – undo
988 1070
 			{
989 1071
 				list(,$path) = explode($GLOBALS['egw_info']['server']['webserver_url'],$url);
990 1072
 
991
-				if (!is_null($path)) $path = EGW_SERVER_ROOT.$path;
1073
+				if (!is_null($path))
1074
+				{
1075
+					$path = EGW_SERVER_ROOT.$path;
1076
+				}
992 1077
 			}
993 1078
 			else
994 1079
 			{
@@ -1051,10 +1136,13 @@  discard block
 block discarded – undo
1051 1136
 		{
1052 1137
 			$url = "/index.php?menuaction=$url";
1053 1138
 		}
1054
-		if ($url[0] == '/')		// link relative to eGW
1139
+		if ($url[0] == '/')
1140
+		{
1141
+			// link relative to eGW
1055 1142
 		{
1056 1143
 			$url = self::link($url,$vars);
1057 1144
 		}
1145
+		}
1058 1146
 		//echo "<p>self::a_href('".self::htmlspecialchars($content)."','$url',".print_r($vars,True).") = ".self::link($url,$vars)."</p>";
1059 1147
 		return '<a href="'.self::htmlspecialchars($url).'" '.$options.'>'.$content.'</a>';
1060 1148
 	}
@@ -1079,7 +1167,10 @@  discard block
 block discarded – undo
1079 1167
 	 */
1080 1168
 	static function hr($width='',$options='')
1081 1169
 	{
1082
-		if ($width) $options .= " width=\"$width\"";
1170
+		if ($width)
1171
+		{
1172
+			$options .= " width=\"$width\"";
1173
+		}
1083 1174
 
1084 1175
 		return "<hr $options />\n";
1085 1176
 	}
@@ -1095,8 +1186,14 @@  discard block
 block discarded – undo
1095 1186
 	 */
1096 1187
 	static function formatOptions($options,$names)
1097 1188
 	{
1098
-		if (!is_array($options)) $options = explode(',',$options);
1099
-		if (!is_array($names))   $names   = explode(',',$names);
1189
+		if (!is_array($options))
1190
+		{
1191
+			$options = explode(',',$options);
1192
+		}
1193
+		if (!is_array($names))
1194
+		{
1195
+			$names   = explode(',',$names);
1196
+		}
1100 1197
 
1101 1198
 		foreach($options as $n => $val)
1102 1199
 		{
@@ -1214,9 +1311,15 @@  discard block
 block discarded – undo
1214 1311
 			Framework::includeCSS('/api/js/dhtmlxtree/codebase/dhtmlxtree.css');
1215 1312
 			Framework::includeJS('/api/js/dhtmlxtree/codebase/dhtmlxcommon.js');
1216 1313
 			Framework::includeJS('/api/js/dhtmlxtree/sources/dhtmlxtree.js');
1217
-			if ($autoLoading && $dataMode != 'XML') Framework::includeJS('/api/js/dhtmlxtree/sources/ext/dhtmlxtree_json.js');
1314
+			if ($autoLoading && $dataMode != 'XML')
1315
+			{
1316
+				Framework::includeJS('/api/js/dhtmlxtree/sources/ext/dhtmlxtree_json.js');
1317
+			}
1218 1318
 			$tree_initialised = true;
1219
-			if (!$_folders && !$autoLoading) return null;
1319
+			if (!$_folders && !$autoLoading)
1320
+			{
1321
+				return null;
1322
+			}
1220 1323
 		}
1221 1324
 		$html = self::div("\n",'id="'.$tree.'"',$_divClass).$html;
1222 1325
 		$html .= "<script type='text/javascript'>\n";
@@ -1224,7 +1327,10 @@  discard block
 block discarded – undo
1224 1327
 		$html .= "egw_LAB.wait(function() {";
1225 1328
 		$html .= "$tree = new"." dhtmlXTreeObject('$tree','100%','100%',0);\n";
1226 1329
 		$html .= "$tree.parentObject.style.overflow='auto';\n";	// dhtmlXTree constructor has hidden hardcoded
1227
-		if (Translation::charset() == 'utf-8') $html .= "if ($tree.setEscapingMode) $tree.setEscapingMode('utf8');\n";
1330
+		if (Translation::charset() == 'utf-8')
1331
+		{
1332
+			$html .= "if ($tree.setEscapingMode) $tree.setEscapingMode('utf8');\n";
1333
+		}
1228 1334
 		$html .= "$tree.setImagePath('$folderImageDir/dhtmlxtree/');\n";
1229 1335
 
1230 1336
 		if($_onCheckHandler)
@@ -1233,19 +1339,28 @@  discard block
 block discarded – undo
1233 1339
 			$html .= "$tree.setOnCheckHandler('$_onCheckHandler');\n";
1234 1340
 		}
1235 1341
 
1236
-		if ($dragndrop) $html .= "$tree.enableDragAndDrop(true);\n";
1342
+		if ($dragndrop)
1343
+		{
1344
+			$html .= "$tree.enableDragAndDrop(true);\n";
1345
+		}
1237 1346
 
1238 1347
 		if ($autoLoading)
1239 1348
 		{
1240 1349
 			$autoLoading = is_array($autoLoading) ?
1241 1350
 				Framework::link('/index.php',$autoLoading) : Framework::link($autoLoading);
1242 1351
 			$html .= "$tree.setXMLAutoLoading('$autoLoading');\n";
1243
-			if ($dataMode != 'XML') $html .= "$tree.setDataMode('$dataMode');\n";
1352
+			if ($dataMode != 'XML')
1353
+			{
1354
+				$html .= "$tree.setDataMode('$dataMode');\n";
1355
+			}
1244 1356
 
1245 1357
 			// if no folders given, use xml url to load root, incl. setting of selected folder
1246 1358
 			if (!$_folders)
1247 1359
 			{
1248
-				if ($_selected) $autoLoading .= '&selected='.urlencode($_selected);
1360
+				if ($_selected)
1361
+				{
1362
+					$autoLoading .= '&selected='.urlencode($_selected);
1363
+				}
1249 1364
 				unset($_selected);
1250 1365
 				$html .= "$tree.loadXML('$autoLoading');\n";
1251 1366
 				$html .= "});";
@@ -1290,7 +1405,10 @@  discard block
 block discarded – undo
1290 1405
 		else
1291 1406
 		{
1292 1407
 			// evtl. remove leading delimiter
1293
-			if ($_selected[0] == $delimiter) $_selected = substr($_selected,1);
1408
+			if ($_selected[0] == $delimiter)
1409
+			{
1410
+				$_selected = substr($_selected,1);
1411
+			}
1294 1412
 
1295 1413
 			$n = 0;
1296 1414
 			foreach($_folders as $path => $data)
@@ -1319,22 +1437,37 @@  discard block
 block discarded – undo
1319 1437
 					$image1 = $image2 = $image3 = "'".$data['image']."'";
1320 1438
 				}
1321 1439
 				// evtl. remove leading delimiter
1322
-				if ($path[0] == $delimiter) $path = substr($path,1);
1440
+				if ($path[0] == $delimiter)
1441
+				{
1442
+					$path = substr($path,1);
1443
+				}
1323 1444
 				$folderParts = explode($delimiter,$path);
1324 1445
 
1325 1446
 				//get rightmost folderpart
1326 1447
 				$label = array_pop($folderParts);
1327
-				if (isset($data['label'])) $label = $data['label'];
1448
+				if (isset($data['label']))
1449
+				{
1450
+					$label = $data['label'];
1451
+				}
1328 1452
 
1329 1453
 				// the rest of the array is the name of the parent
1330 1454
 				$parentName = implode((array)$folderParts,$delimiter);
1331
-				if(empty($parentName)) $parentName = $top;
1455
+				if(empty($parentName))
1456
+				{
1457
+					$parentName = $top;
1458
+				}
1332 1459
 
1333 1460
 				$entryOptions = !isset($data['child']) || $data['child'] ? 'CHILD' : '';
1334
-				if ($_onCheckHandler && $_selected)	// check selected items on multi selection
1461
+				if ($_onCheckHandler && $_selected)
1462
+				{
1463
+					// check selected items on multi selection
1335 1464
 				{
1336 1465
 					if (!is_array($_selected)) $_selected = explode(',',$_selected);
1337
-					if (array_search("$path",$_selected)!==false) $entryOptions .= ',CHECKED';
1466
+				}
1467
+					if (array_search("$path",$_selected)!==false)
1468
+					{
1469
+						$entryOptions .= ',CHECKED';
1470
+					}
1338 1471
 					//echo "<p>path=$path, _selected=".print_r($_selected,true).": $entryOptions</p>\n";
1339 1472
 				}
1340 1473
 				// highlight current item
Please login to merge, or discard this patch.
api/src/Ldap.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,17 +31,17 @@
 block discarded – undo
31 31
 class Ldap
32 32
 {
33 33
 	/**
34
-	* Holds the LDAP link identifier
35
-	*
36
-	* @var resource $ds
37
-	*/
34
+	 * Holds the LDAP link identifier
35
+	 *
36
+	 * @var resource $ds
37
+	 */
38 38
 	var $ds;
39 39
 
40 40
 	/**
41
-	* Holds the detected information about the connected ldap server
42
-	*
43
-	* @var Ldap\ServerInfo $ldapserverinfo
44
-	*/
41
+	 * Holds the detected information about the connected ldap server
42
+	 *
43
+	 * @var Ldap\ServerInfo $ldapserverinfo
44
+	 */
45 45
 	var $ldapserverinfo;
46 46
 
47 47
 	/**
Please login to merge, or discard this patch.
Braces   +36 added lines, -9 removed lines patch added patch discarded remove patch
@@ -129,12 +129,18 @@  discard block
 block discarded – undo
129 129
 	 */
130 130
 	static function result2array($ldap)
131 131
 	{
132
-		if (!is_array($ldap)) return false;
132
+		if (!is_array($ldap))
133
+		{
134
+			return false;
135
+		}
133 136
 
134 137
 		$arr = array();
135 138
 		foreach($ldap as $var => $val)
136 139
 		{
137
-			if (is_int($var) || $var == 'count') continue;
140
+			if (is_int($var) || $var == 'count')
141
+			{
142
+				continue;
143
+			}
138 144
 
139 145
 			if (is_array($val) && $val['count'] == 1)
140 146
 			{
@@ -142,7 +148,10 @@  discard block
 block discarded – undo
142 148
 			}
143 149
 			else
144 150
 			{
145
-				if (is_array($val)) unset($val['count']);
151
+				if (is_array($val))
152
+				{
153
+					unset($val['count']);
154
+				}
146 155
 
147 156
 				$arr[$var] = $val;
148 157
 			}
@@ -168,7 +177,10 @@  discard block
 block discarded – undo
168 177
 	{
169 178
 		if(!function_exists('ldap_connect'))
170 179
 		{
171
-			if ($this->exception_on_error) throw new Exception\AssertionFailed('LDAP support unavailable!');
180
+			if ($this->exception_on_error)
181
+			{
182
+				throw new Exception\AssertionFailed('LDAP support unavailable!');
183
+			}
172 184
 
173 185
 			printf('<b>Error: LDAP support unavailable</b><br>',$host);
174 186
 			return False;
@@ -194,10 +206,13 @@  discard block
 block discarded – undo
194 206
 			{
195 207
 				if ($h !== $host)
196 208
 				{
197
-					if (isset($_SESSION))	// store working host as first choice in session
209
+					if (isset($_SESSION))
210
+					{
211
+						// store working host as first choice in session
198 212
 					{
199 213
 						$_SESSION['ldapConnect'][$host] = implode(' ',array_unique(array_merge(array($h),$hosts)));
200 214
 					}
215
+					}
201 216
 				}
202 217
 				return $this->ds;
203 218
 			}
@@ -206,7 +221,10 @@  discard block
 block discarded – undo
206 221
 				' '.function_backtrace());
207 222
 		}
208 223
 		// give visible error, only if we cant connect to any ldap server
209
-		if ($this->exception_on_error) throw new Exception\NoPermission("Can't connect/bind to LDAP server '$host' and dn='$dn'!");
224
+		if ($this->exception_on_error)
225
+		{
226
+			throw new Exception\NoPermission("Can't connect/bind to LDAP server '$host' and dn='$dn'!");
227
+		}
210 228
 
211 229
 		return false;
212 230
 	}
@@ -242,7 +260,10 @@  discard block
 block discarded – undo
242 260
 		{
243 261
 			$supportedLDAPVersion = 2;
244 262
 		}
245
-		if ($use_tls) ldap_start_tls($this->ds);
263
+		if ($use_tls)
264
+		{
265
+			ldap_start_tls($this->ds);
266
+		}
246 267
 
247 268
 		if (!isset($this->ldapserverinfo) ||
248 269
 			!is_a($this->ldapserverinfo,'EGroupware\Ldap\ServerInfo') ||
@@ -281,10 +302,13 @@  discard block
 block discarded – undo
281 302
 	 */
282 303
 	function restoreSessionData()
283 304
 	{
284
-		if (isset($GLOBALS['egw']->session))	// no availible in setup
305
+		if (isset($GLOBALS['egw']->session))
306
+		{
307
+			// no availible in setup
285 308
 		{
286 309
 			$this->ldapserverinfo = Cache::getSession(__CLASS__, 'ldapServerInfo');
287 310
 		}
311
+		}
288 312
 	}
289 313
 
290 314
 	/**
@@ -292,9 +316,12 @@  discard block
 block discarded – undo
292 316
 	 */
293 317
 	function saveSessionData()
294 318
 	{
295
-		if (isset($GLOBALS['egw']->session))	// no availible in setup
319
+		if (isset($GLOBALS['egw']->session))
320
+		{
321
+			// no availible in setup
296 322
 		{
297 323
 			Cache::setSession(__CLASS__, 'ldapServerInfo', $this->ldapserverinfo);
298 324
 		}
325
+		}
299 326
 	}
300 327
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -49,14 +49,14 @@  discard block
 block discarded – undo
49 49
 	 *
50 50
 	 * @var boolean $exception_on_error
51 51
 	 */
52
-	var $exception_on_error=false;
52
+	var $exception_on_error = false;
53 53
 
54 54
 	/**
55 55
 	 * Constructor
56 56
 	 *
57 57
 	 * @param boolean $exception_on_error =false true: throw Exceptions in ldapConnect instead of echoing error and returning false
58 58
 	 */
59
-	function __construct($exception_on_error=false)
59
+	function __construct($exception_on_error = false)
60 60
 	{
61 61
 		$this->exception_on_error = $exception_on_error;
62 62
 		$this->restoreSessionData();
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @throws Exception\AssertingFailed 'LDAP support unavailable!' (no ldap extension)
84 84
 	 * @throws Exception\NoPermission if bind fails
85 85
 	 */
86
-	public static function factory($ressource=true, $host='', $dn='', $passwd='')
86
+	public static function factory($ressource = true, $host = '', $dn = '', $passwd = '')
87 87
 	{
88 88
 		$key = md5($host.':'.$dn.':'.$passwd);
89 89
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	static function quote($string)
120 120
 	{
121
-		return str_replace(array('\\','*','(',')','\0',' '),array('\\\\','\*','\(','\)','\\0','\20'),$string);
121
+		return str_replace(array('\\', '*', '(', ')', '\0', ' '), array('\\\\', '\*', '\(', '\)', '\\0', '\20'), $string);
122 122
 	}
123 123
 
124 124
 	/**
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 		if (!is_array($ldap)) return false;
133 133
 
134 134
 		$arr = array();
135
-		foreach($ldap as $var => $val)
135
+		foreach ($ldap as $var => $val)
136 136
 		{
137 137
 			if (is_int($var) || $var == 'count') continue;
138 138
 
@@ -164,13 +164,13 @@  discard block
 block discarded – undo
164 164
 	 * @throws Exception\AssertingFailed 'LDAP support unavailable!' (no ldap extension)
165 165
 	 * @throws Exception\NoPermission if bind fails
166 166
 	 */
167
-	function ldapConnect($host='', $dn='', $passwd='')
167
+	function ldapConnect($host = '', $dn = '', $passwd = '')
168 168
 	{
169
-		if(!function_exists('ldap_connect'))
169
+		if (!function_exists('ldap_connect'))
170 170
 		{
171 171
 			if ($this->exception_on_error) throw new Exception\AssertionFailed('LDAP support unavailable!');
172 172
 
173
-			printf('<b>Error: LDAP support unavailable</b><br>',$host);
173
+			printf('<b>Error: LDAP support unavailable</b><br>', $host);
174 174
 			return False;
175 175
 		}
176 176
 		if (empty($host))
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		{
189 189
 			$host = $_SESSION['ldapConnect'][$host];
190 190
 		}
191
-		foreach($hosts=preg_split('/[ ,;]+/', $host) as $h)
191
+		foreach ($hosts = preg_split('/[ ,;]+/', $host) as $h)
192 192
 		{
193 193
 			if ($this->_connect($h, $dn, $passwd))
194 194
 			{
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 				{
197 197
 					if (isset($_SESSION))	// store working host as first choice in session
198 198
 					{
199
-						$_SESSION['ldapConnect'][$host] = implode(' ',array_unique(array_merge(array($h),$hosts)));
199
+						$_SESSION['ldapConnect'][$host] = implode(' ', array_unique(array_merge(array($h), $hosts)));
200 200
 					}
201 201
 				}
202 202
 				return $this->ds;
@@ -221,20 +221,20 @@  discard block
 block discarded – undo
221 221
 	 */
222 222
 	private function _connect($host, $dn, $passwd)
223 223
 	{
224
-		if (($use_tls = substr($host,0,6) == 'tls://'))
224
+		if (($use_tls = substr($host, 0, 6) == 'tls://'))
225 225
 		{
226
-			$port = parse_url($host,PHP_URL_PORT);
227
-			$host = parse_url($host,PHP_URL_HOST);
226
+			$port = parse_url($host, PHP_URL_PORT);
227
+			$host = parse_url($host, PHP_URL_HOST);
228 228
 		}
229 229
 		// connect to ldap server (never fails, as connection happens in bind!)
230
-		if(!$host || !($this->ds = !empty($port) ? ldap_connect($host, $port) : ldap_connect($host)))
230
+		if (!$host || !($this->ds = !empty($port) ? ldap_connect($host, $port) : ldap_connect($host)))
231 231
 		{
232 232
 			return False;
233 233
 		}
234 234
 		// set network timeout to not block for minutes
235 235
 		ldap_set_option($this->ds, LDAP_OPT_NETWORK_TIMEOUT, 5);
236 236
 
237
-		if(ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3))
237
+		if (ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3))
238 238
 		{
239 239
 			$supportedLDAPVersion = 3;
240 240
 		}
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 		if ($use_tls) ldap_start_tls($this->ds);
246 246
 
247 247
 		if (!isset($this->ldapserverinfo) ||
248
-			!is_a($this->ldapserverinfo,'EGroupware\Ldap\ServerInfo') ||
248
+			!is_a($this->ldapserverinfo, 'EGroupware\Ldap\ServerInfo') ||
249 249
 			$this->ldapserverinfo->host != $host)
250 250
 		{
251 251
 			//error_log("no ldap server info found");
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 			$this->saveSessionData();
256 256
 		}
257 257
 
258
-		if(!@ldap_bind($this->ds, $dn, $passwd))
258
+		if (!@ldap_bind($this->ds, $dn, $passwd))
259 259
 		{
260 260
 			return False;
261 261
 		}
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	 */
269 269
 	function ldapDisconnect()
270 270
 	{
271
-		if(is_resource($this->ds))
271
+		if (is_resource($this->ds))
272 272
 		{
273 273
 			ldap_unbind($this->ds);
274 274
 			unset($this->ds);
Please login to merge, or discard this patch.