Completed
Push — master ( aa44e9...fa84e5 )
by Ralf
90:14 queued 73:21
created
api/src/Etemplate/Widget/Date.php 4 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -101,7 +101,6 @@  discard block
 block discarded – undo
101 101
 	/**
102 102
 	 * Put date in the proper format for sending to client
103 103
 	 * @param string|int $value
104
-	 * @param string $format
105 104
 	 */
106 105
 	public function format_date($value)
107 106
 	{
@@ -139,7 +138,7 @@  discard block
 block discarded – undo
139 138
 	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
140 139
 	 * @param array $content
141 140
 	 * @param array &$validated=array() validated content
142
-	 * @return boolean true if no validation error, false otherwise
141
+	 * @return boolean|null true if no validation error, false otherwise
143 142
 	 */
144 143
 	public function validate($cname, array $expand, array $content, &$validated=array())
145 144
 	{
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -60,17 +60,17 @@  discard block
 block discarded – undo
60 60
 	 * @param string $cname
61 61
 	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
62 62
 	 */
63
-	public function beforeSendToClient($cname, array $expand=null)
63
+	public function beforeSendToClient($cname, array $expand = null)
64 64
 	{
65
-		if($this->type == 'date-houronly')
65
+		if ($this->type == 'date-houronly')
66 66
 		{
67 67
 			return parent::beforeSendToClient($cname, $expand);
68 68
 		}
69 69
 
70 70
 		$form_name = self::form_name($cname, $this->id, $expand);
71
-		$value =& self::get_array(self::$request->content, $form_name, false, true);
71
+		$value = & self::get_array(self::$request->content, $form_name, false, true);
72 72
 
73
-		if($this->type != 'date-duration' && $value)
73
+		if ($this->type != 'date-duration' && $value)
74 74
 		{
75 75
 			$value = $this->format_date($value);
76 76
 		}
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	public function set_row_value($cname, Array $expand, Array &$data)
92 92
 	{
93
-		if($this->type == 'date-duration') return;
93
+		if ($this->type == 'date-duration') return;
94 94
 
95 95
 		$form_name = self::form_name($cname, $this->id, $expand);
96
-		$value =& $this->get_array($data, $form_name, true);
96
+		$value = & $this->get_array($data, $form_name, true);
97 97
 
98 98
 		if (true) $value = $this->format_date($value);
99 99
 	}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	public function format_date($value)
107 107
 	{
108
-		if (!$value) return $value;	// otherwise we will get current date or 1970-01-01 instead of an empty value
108
+		if (!$value) return $value; // otherwise we will get current date or 1970-01-01 instead of an empty value
109 109
 
110 110
 		if ($this->attrs['dataformat'] && !is_numeric($value))
111 111
 		{
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
 		{
116 116
 			$date = new Api\DateTime($value);
117 117
 		}
118
-		if($this->type == 'date-timeonly')
118
+		if ($this->type == 'date-timeonly')
119 119
 		{
120 120
 			$date->setDate(1970, 1, 1);
121 121
 		}
122
-		if($date)
122
+		if ($date)
123 123
 		{
124 124
 			// postfix date-string with "Z" so javascript doesn't add/subtract anything
125 125
 			$value = $date->format('Y-m-d\TH:i:s\Z');
@@ -141,18 +141,18 @@  discard block
 block discarded – undo
141 141
 	 * @param array &$validated=array() validated content
142 142
 	 * @return boolean true if no validation error, false otherwise
143 143
 	 */
144
-	public function validate($cname, array $expand, array $content, &$validated=array())
144
+	public function validate($cname, array $expand, array $content, &$validated = array())
145 145
 	{
146 146
 		$form_name = self::form_name($cname, $this->id, $expand);
147 147
 
148 148
 		if (!$this->is_readonly($cname, $form_name) && $this->type != 'date-since')	// date-since is always readonly
149 149
 		{
150 150
 			$value = self::get_array($content, $form_name);
151
-			$valid =& self::get_array($validated, $form_name, true);
151
+			$valid = & self::get_array($validated, $form_name, true);
152 152
 
153 153
 			if ((string)$value === '' && $this->attrs['needed'])
154 154
 			{
155
-				self::set_validation_error($form_name,lang('Field must not be empty !!!'));
155
+				self::set_validation_error($form_name, lang('Field must not be empty !!!'));
156 156
 			}
157 157
 			elseif (is_null($value))
158 158
 			{
@@ -162,49 +162,49 @@  discard block
 block discarded – undo
162 162
 			{
163 163
 				$valid = (string)$value === '' ? '' : (int)$value;
164 164
 			}
165
-			if($value)
165
+			if ($value)
166 166
 			{
167 167
 				$date = new Api\DateTime($value);
168 168
 			}
169 169
 			if (!empty($this->attrs['min']))
170 170
 			{
171
-				if(is_numeric($this->attrs['min']))
171
+				if (is_numeric($this->attrs['min']))
172 172
 				{
173
-					$min = new Api\DateTime(strtotime( $this->attrs['min'] . 'days'));
173
+					$min = new Api\DateTime(strtotime($this->attrs['min'].'days'));
174 174
 				}
175 175
 				else
176 176
 				{
177 177
 					$min = new Api\DateTime(strtotime($this->attrs['min']));
178 178
 				}
179
-				if($value < $min)
179
+				if ($value < $min)
180 180
 				{
181
-					self::set_validation_error($form_name,lang(
181
+					self::set_validation_error($form_name, lang(
182 182
 						"Value has to be at least '%1' !!!",
183 183
 						$min->format($this->type != 'date')
184
-					),'');
184
+					), '');
185 185
 					$value = $min;
186 186
 				}
187 187
 			}
188 188
 			if (!empty($this->attrs['max']))
189 189
 			{
190
-				if(is_numeric($this->attrs['max']))
190
+				if (is_numeric($this->attrs['max']))
191 191
 				{
192
-					$max = new Api\DateTime(strtotime( $this->attrs['max'] . 'days'));
192
+					$max = new Api\DateTime(strtotime($this->attrs['max'].'days'));
193 193
 				}
194 194
 				else
195 195
 				{
196 196
 					$max = new Api\DateTime(strtotime($this->attrs['max']));
197 197
 				}
198
-				if($value < $max)
198
+				if ($value < $max)
199 199
 				{
200
-					self::set_validation_error($form_name,lang(
200
+					self::set_validation_error($form_name, lang(
201 201
 						"Value has to be at maximum '%1' !!!",
202 202
 						$max->format($this->type != 'date')
203
-					),'');
203
+					), '');
204 204
 					$value = $max;
205 205
 				}
206 206
 			}
207
-			if(!$value)
207
+			if (!$value)
208 208
 			{
209 209
 				// Not null, blank
210 210
 				$value = '';
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 			else
222 222
 			{
223 223
 				// this is not really a user error, but one of the clientside engine
224
-				self::set_validation_error($form_name,lang("'%1' is not a valid date !!!", $value).' '.$this->dataformat);
224
+				self::set_validation_error($form_name, lang("'%1' is not a valid date !!!", $value).' '.$this->dataformat);
225 225
 			}
226 226
 			//error_log("$this : ($valid)" . Api\DateTime::to($valid));
227 227
 		}
Please login to merge, or discard this patch.
Braces   +21 added lines, -5 removed lines patch added patch discarded remove patch
@@ -90,12 +90,18 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	public function set_row_value($cname, Array $expand, Array &$data)
92 92
 	{
93
-		if($this->type == 'date-duration') return;
93
+		if($this->type == 'date-duration')
94
+		{
95
+			return;
96
+		}
94 97
 
95 98
 		$form_name = self::form_name($cname, $this->id, $expand);
96 99
 		$value =& $this->get_array($data, $form_name, true);
97 100
 
98
-		if (true) $value = $this->format_date($value);
101
+		if (true)
102
+		{
103
+			$value = $this->format_date($value);
104
+		}
99 105
 	}
100 106
 
101 107
 	/**
@@ -105,7 +111,11 @@  discard block
 block discarded – undo
105 111
 	 */
106 112
 	public function format_date($value)
107 113
 	{
108
-		if (!$value) return $value;	// otherwise we will get current date or 1970-01-01 instead of an empty value
114
+		if (!$value)
115
+		{
116
+			return $value;
117
+		}
118
+		// otherwise we will get current date or 1970-01-01 instead of an empty value
109 119
 
110 120
 		if ($this->attrs['dataformat'] && !is_numeric($value))
111 121
 		{
@@ -145,9 +155,12 @@  discard block
 block discarded – undo
145 155
 	{
146 156
 		$form_name = self::form_name($cname, $this->id, $expand);
147 157
 
148
-		if (!$this->is_readonly($cname, $form_name) && $this->type != 'date-since')	// date-since is always readonly
158
+		if (!$this->is_readonly($cname, $form_name) && $this->type != 'date-since')
159
+		{
160
+			// date-since is always readonly
149 161
 		{
150 162
 			$value = self::get_array($content, $form_name);
163
+		}
151 164
 			$valid =& self::get_array($validated, $form_name, true);
152 165
 
153 166
 			if ((string)$value === '' && $this->attrs['needed'])
@@ -209,10 +222,13 @@  discard block
 block discarded – undo
209 222
 				// Not null, blank
210 223
 				$value = '';
211 224
 			}
212
-			elseif (empty($this->attrs['dataformat']))	// integer timestamp
225
+			elseif (empty($this->attrs['dataformat']))
226
+			{
227
+				// integer timestamp
213 228
 			{
214 229
 				$valid = $date->format('ts');
215 230
 			}
231
+			}
216 232
 			// string with formatting letters like for php's date() method
217 233
 			elseif ($date && ($valid = $date->format($this->attrs['dataformat'])))
218 234
 			{
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@
 block discarded – undo
88 88
 	 * @param array $data Row data
89 89
 	 * @return type
90 90
 	 */
91
-	public function set_row_value($cname, Array $expand, Array &$data)
91
+	public function set_row_value($cname, array $expand, array &$data)
92 92
 	{
93 93
 		if($this->type == 'date-duration') return;
94 94
 
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Textbox.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @param string|XMLReader $xml
57 57
 	 * @param boolean $cloned =true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object
58
-	 * @return Template current object or clone, if any attribute was set
58
+	 * @return Textbox current object or clone, if any attribute was set
59 59
 	 */
60 60
 	public function set_attrs($xml, $cloned=true)
61 61
 	{
@@ -110,7 +110,6 @@  discard block
 block discarded – undo
110 110
 	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
111 111
 	 * @param array $content
112 112
 	 * @param array &$validated=array() validated content
113
-	 * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont'
114 113
 	 */
115 114
 	public function validate($cname, array $expand, array $content, &$validated=array())
116 115
 	{
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 * @param boolean $cloned =true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object
58 58
 	 * @return Template current object or clone, if any attribute was set
59 59
 	 */
60
-	public function set_attrs($xml, $cloned=true)
60
+	public function set_attrs($xml, $cloned = true)
61 61
 	{
62 62
 		parent::set_attrs($xml, $cloned);
63 63
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 			$this->setElementAttribute($this->id, 'size', abs($this->attrs['size']));
70 70
 			self::$request->readonlys[$this->id] = false;
71 71
 			$this->setElementAttribute($this->id, 'readonly', true);
72
-			trigger_error("Using a negative size to set textbox readonly. " .$this, E_USER_DEPRECATED);
72
+			trigger_error("Using a negative size to set textbox readonly. ".$this, E_USER_DEPRECATED);
73 73
 		}
74 74
 		return $this;
75 75
 	}
@@ -80,16 +80,16 @@  discard block
 block discarded – undo
80 80
 	 * @param string $cname
81 81
 	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
82 82
 	 */
83
-	public function beforeSendToClient($cname, array $expand=null)
83
+	public function beforeSendToClient($cname, array $expand = null)
84 84
 	{
85 85
 		// to NOT transmit passwords back to client, we need to store (non-empty) value in preserv
86 86
 		if ($this->attrs['type'] == 'passwd' || $this->type == 'passwd')
87 87
 		{
88 88
 			$form_name = self::form_name($cname, $this->id, $expand);
89
-			$value =& self::get_array(self::$request->content, $form_name);
89
+			$value = & self::get_array(self::$request->content, $form_name);
90 90
 			if (!empty($value))
91 91
 			{
92
-				$preserv =& self::get_array(self::$request->preserv, $form_name, true);
92
+				$preserv = & self::get_array(self::$request->preserv, $form_name, true);
93 93
 				if (true) $preserv = (string)$value;
94 94
 				$value = str_repeat('*', strlen($preserv));
95 95
 			}
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 * @param array &$validated=array() validated content
113 113
 	 * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont'
114 114
 	 */
115
-	public function validate($cname, array $expand, array $content, &$validated=array())
115
+	public function validate($cname, array $expand, array $content, &$validated = array())
116 116
 	{
117 117
 		$form_name = self::form_name($cname, $this->id, $expand);
118 118
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		{
121 121
 			if (!isset($this->attrs['validator']))
122 122
 			{
123
-				switch($this->type)
123
+				switch ($this->type)
124 124
 				{
125 125
 					case 'int':
126 126
 					case 'integer':
@@ -150,24 +150,24 @@  discard block
 block discarded – undo
150 150
 
151 151
 			if ((string)$value === '' && $this->attrs['needed'])
152 152
 			{
153
-				self::set_validation_error($form_name,lang('Field must not be empty !!!'),'');
153
+				self::set_validation_error($form_name, lang('Field must not be empty !!!'), '');
154 154
 			}
155
-			if ((int) $this->attrs['maxlength'] > 0 && mb_strlen($value) > (int) $this->attrs['maxlength'])
155
+			if ((int)$this->attrs['maxlength'] > 0 && mb_strlen($value) > (int)$this->attrs['maxlength'])
156 156
 			{
157
-				$value = mb_substr($value,0,(int) $this->attrs['maxlength']);
157
+				$value = mb_substr($value, 0, (int)$this->attrs['maxlength']);
158 158
 			}
159
-			if ($this->attrs['validator'] && !preg_match($this->attrs['validator'],$value))
159
+			if ($this->attrs['validator'] && !preg_match($this->attrs['validator'], $value))
160 160
 			{
161
-				switch($this->type)
161
+				switch ($this->type)
162 162
 				{
163 163
 					case 'integer':
164
-						self::set_validation_error($form_name,lang("'%1' is not a valid integer !!!",$value),'');
164
+						self::set_validation_error($form_name, lang("'%1' is not a valid integer !!!", $value), '');
165 165
 						break;
166 166
 					case 'float':
167
-						self::set_validation_error($form_name,lang("'%1' is not a valid floatingpoint number !!!",$value),'');
167
+						self::set_validation_error($form_name, lang("'%1' is not a valid floatingpoint number !!!", $value), '');
168 168
 						break;
169 169
 					default:
170
-						self::set_validation_error($form_name,lang("'%1' has an invalid format !!!",$value)/*." !preg_match('$this->attrs[validator]', '$value')"*/,'');
170
+						self::set_validation_error($form_name, lang("'%1' has an invalid format !!!", $value)/*." !preg_match('$this->attrs[validator]', '$value')"*/, '');
171 171
 						break;
172 172
 				}
173 173
 			}
@@ -175,17 +175,17 @@  discard block
 block discarded – undo
175 175
 			{
176 176
 				if ((string)$value !== '' || $this->attrs['needed'])	// empty values are Ok if needed is not set
177 177
 				{
178
-					$value = $this->type == 'integer' ? (int) $value : (float) str_replace(',','.',$value);	// allow for german (and maybe other) format
178
+					$value = $this->type == 'integer' ? (int)$value : (float)str_replace(',', '.', $value); // allow for german (and maybe other) format
179 179
 
180 180
 					if (!empty($this->attrs['min']) && $value < $this->attrs['min'])
181 181
 					{
182
-						self::set_validation_error($form_name,lang("Value has to be at least '%1' !!!",$this->attrs['min']),'');
183
-						$value = $this->type == 'integer' ? (int) $this->attrs['min'] : (float) $this->attrs['min'];
182
+						self::set_validation_error($form_name, lang("Value has to be at least '%1' !!!", $this->attrs['min']), '');
183
+						$value = $this->type == 'integer' ? (int)$this->attrs['min'] : (float)$this->attrs['min'];
184 184
 					}
185 185
 					if (!empty($this->attrs['max']) && $value > $this->attrs['max'])
186 186
 					{
187
-						self::set_validation_error($form_name,lang("Value has to be at maximum '%1' !!!",$this->attrs['max']),'');
188
-						$value = $this->type == 'integer' ? (int) $this->attrs['max'] : (float) $this->attrs['max'];
187
+						self::set_validation_error($form_name, lang("Value has to be at maximum '%1' !!!", $this->attrs['max']), '');
188
+						$value = $this->type == 'integer' ? (int)$this->attrs['max'] : (float)$this->attrs['max'];
189 189
 					}
190 190
 				}
191 191
 			}
@@ -197,4 +197,4 @@  discard block
 block discarded – undo
197 197
 		}
198 198
 	}
199 199
 }
200
-Etemplate\Widget::registerWidget(__NAMESPACE__.'\\Textbox', array('textbox','text','int','integer','float','passwd','hidden','colorpicker','hidden'));
200
+Etemplate\Widget::registerWidget(__NAMESPACE__.'\\Textbox', array('textbox', 'text', 'int', 'integer', 'float', 'passwd', 'hidden', 'colorpicker', 'hidden'));
Please login to merge, or discard this patch.
Braces   +14 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,7 +41,10 @@  discard block
 block discarded – undo
41 41
 		// normalize types
42 42
 		if ($this->type !== 'textbox')
43 43
 		{
44
-			if ($this->type == 'int') $this->type = 'integer';
44
+			if ($this->type == 'int')
45
+			{
46
+				$this->type = 'integer';
47
+			}
45 48
 
46 49
 			$this->attrs['type'] = $this->type;
47 50
 			$this->type = 'textbox';
@@ -90,7 +93,10 @@  discard block
 block discarded – undo
90 93
 			if (!empty($value))
91 94
 			{
92 95
 				$preserv =& self::get_array(self::$request->preserv, $form_name, true);
93
-				if (true) $preserv = (string)$value;
96
+				if (true)
97
+				{
98
+					$preserv = (string)$value;
99
+				}
94 100
 				$value = str_repeat('*', strlen($preserv));
95 101
 			}
96 102
 		}
@@ -171,11 +177,15 @@  discard block
 block discarded – undo
171 177
 						break;
172 178
 				}
173 179
 			}
174
-			elseif ($this->type == 'integer' || $this->type == 'float')	// cast int and float and check range
180
+			elseif ($this->type == 'integer' || $this->type == 'float')
181
+			{
182
+				// cast int and float and check range
175 183
 			{
176 184
 				if ((string)$value !== '' || $this->attrs['needed'])	// empty values are Ok if needed is not set
177 185
 				{
178
-					$value = $this->type == 'integer' ? (int) $value : (float) str_replace(',','.',$value);	// allow for german (and maybe other) format
186
+					$value = $this->type == 'integer' ? (int) $value : (float) str_replace(',','.',$value);
187
+			}
188
+			// allow for german (and maybe other) format
179 189
 
180 190
 					if (!empty($this->attrs['min']) && $value < $this->attrs['min'])
181 191
 					{
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Tree.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -361,7 +361,6 @@  discard block
 block discarded – undo
361 361
 	 * Get options from $sel_options array for a given selectbox name
362 362
 	 *
363 363
 	 * @param string $name
364
-	 * @param boolean $no_lang=false value of no_lang attribute
365 364
 	 * @return array
366 365
 	 */
367 366
 	public static function selOptions($name)
@@ -400,7 +399,7 @@  discard block
 block discarded – undo
400 399
 	 *
401 400
 	 * @param string $widget_type
402 401
 	 * @param string $legacy_options options string of widget
403
-	 * @param boolean $no_lang=false initial value of no_lang attribute (some types set it to true)
402
+	 * @param boolean $no_lang initial value of no_lang attribute (some types set it to true)
404 403
 	 * @param boolean $readonly =false
405 404
 	 * @param mixed $value =null value for readonly
406 405
 	 * @return array with value => label pairs
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 * @param boolean $cloned =true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object
121 121
 	 * @return Etempalte\Widget current object or clone, if any attribute was set
122 122
 	 */
123
-	public function set_attrs($xml, $cloned=true)
123
+	public function set_attrs($xml, $cloned = true)
124 124
 	{
125 125
 		$this->attrs['type'] = $xml->localName;
126 126
 		parent::set_attrs($xml, $cloned);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
 		if (isset($item['item']) && is_array($item['item']))
166 166
 		{
167
-			foreach($item['item'] as &$child)
167
+			foreach ($item['item'] as &$child)
168 168
 			{
169 169
 				$child = self::htmlencode_node($child);
170 170
 			}
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 		{
186 186
 			return true;
187 187
 		}
188
-		foreach((array)$item['item'] as $child)
188
+		foreach ((array)$item['item'] as $child)
189 189
 		{
190 190
 			if (self::in_tree($id, $child)) return true;
191 191
 		}
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 * @param array $content
216 216
 	 * @param array &$validated=array() validated content
217 217
 	 */
218
-	public function validate($cname, array $expand, array $content, &$validated=array())
218
+	public function validate($cname, array $expand, array $content, &$validated = array())
219 219
 	{
220 220
 		$form_name = self::form_name($cname, $this->id, $expand);
221 221
 
@@ -229,13 +229,13 @@  discard block
 block discarded – undo
229 229
 			{
230 230
 				$allowed = $this->attrs['multiple'] ? array() : array('' => $this->attrs['options']);
231 231
 				$allowed += self::selOptions($form_name);
232
-				foreach((array) $value as $val)
232
+				foreach ((array)$value as $val)
233 233
 				{
234 234
 					if ($this->type == 'tree-cat' && !($this->attrs['multiple'] && !$val) && !self::in_cats($val, $allowed) ||
235 235
 						$this->type == 'tree' && !self::in_tree($val, $allowed))
236 236
 					{
237
-						self::set_validation_error($form_name,lang("'%1' is NOT allowed%2)!", $val,
238
-							$this->type == 'tree-cat' ? " ('".implode("','",array_keys($allowed)).')' : ''), '');
237
+						self::set_validation_error($form_name, lang("'%1' is NOT allowed%2)!", $val,
238
+							$this->type == 'tree-cat' ? " ('".implode("','", array_keys($allowed)).')' : ''), '');
239 239
 						$value = '';
240 240
 						break;
241 241
 					}
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
 			// return values for cat-tree as string, but not for regular tree as it can have id's with comma!
245 245
 			if (is_array($value) && $this->type == 'tree-cat')
246 246
 			{
247
-				$value = implode(',',$value);
247
+				$value = implode(',', $value);
248 248
 			}
249 249
 			if ($ok && $value === '' && $this->attrs['needed'])
250 250
 			{
251
-				self::set_validation_error($form_name,lang('Field must not be empty !!!',$value),'');
251
+				self::set_validation_error($form_name, lang('Field must not be empty !!!', $value), '');
252 252
 			}
253
-			$valid =& self::get_array($validated, $form_name, true);
253
+			$valid = & self::get_array($validated, $form_name, true);
254 254
 			if (true) $valid = $value;
255 255
 			//error_log(__METHOD__."() $form_name: ".array2string($value_in).' --> '.array2string($value).', allowed='.array2string($allowed));
256 256
 		}
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 		{
277 277
 			// += to keep further options set by app code
278 278
 			self::$request->sel_options[$form_name] += self::typeOptions($this->attrs['type'], $this->attrs['options'],
279
-				$no_lang=null, $this->attrs['readonly'], self::get_array(self::$request->content, $form_name));
279
+				$no_lang = null, $this->attrs['readonly'], self::get_array(self::$request->content, $form_name));
280 280
 
281 281
 			// if no_lang was modified, forward modification to the client
282 282
 			if ($no_lang != $this->attr['no_lang'])
@@ -286,15 +286,15 @@  discard block
 block discarded – undo
286 286
 		}
287 287
 
288 288
 		// Make sure &nbsp;s, etc.  are properly encoded when sent, and not double-encoded
289
-		foreach(self::$request->sel_options[$form_name] as &$label)
289
+		foreach (self::$request->sel_options[$form_name] as &$label)
290 290
 		{
291
-			if(!is_array($label))
291
+			if (!is_array($label))
292 292
 			{
293
-				$label = html_entity_decode($label, ENT_NOQUOTES,'utf-8');
293
+				$label = html_entity_decode($label, ENT_NOQUOTES, 'utf-8');
294 294
 			}
295
-			elseif($label['label'])
295
+			elseif ($label['label'])
296 296
 			{
297
-				$label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES,'utf-8');
297
+				$label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES, 'utf-8');
298 298
 			}
299 299
 		}
300 300
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	 * @param string $image_path =null default path to use, or empty to use default of /phpgwapi/templates/default/images/dhtmlxtree
307 307
 	 * @return string templated url if available, otherwise default path
308 308
 	 */
309
-	public static function templateImagePath($image_path=null)
309
+	public static function templateImagePath($image_path = null)
310 310
 	{
311 311
 		$webserver_url = $GLOBALS['egw_info']['server']['webserver_url'];
312 312
 		if (empty($image_path))
@@ -338,20 +338,20 @@  discard block
 block discarded – undo
338 338
 	 */
339 339
 	public static function imagePath($image)
340 340
 	{
341
-		static $image_path=null;
342
-		if (!isset($image_path)) $image_path = self::templateImagePath ();
341
+		static $image_path = null;
342
+		if (!isset($image_path)) $image_path = self::templateImagePath();
343 343
 
344 344
 		$parts = explode('/', $image_path);
345
-		$image_parts   = explode('/', $image);
345
+		$image_parts = explode('/', $image);
346 346
 
347 347
 		// remove common parts
348
-		while(isset($parts[0]) && $parts[0] === $image_parts[0])
348
+		while (isset($parts[0]) && $parts[0] === $image_parts[0])
349 349
 		{
350 350
 			array_shift($parts);
351 351
 			array_shift($image_parts);
352 352
 		}
353 353
 		// add .. for different parts, except last image part
354
-		$url = implode('/', array_merge(array_fill(0, count($parts)-1, '..'), $image_parts));
354
+		$url = implode('/', array_merge(array_fill(0, count($parts) - 1, '..'), $image_parts));
355 355
 
356 356
 		//error_log(__METHOD__."('$image') image_path=$image_path returning $url");
357 357
 		return $url;
@@ -373,10 +373,10 @@  discard block
 block discarded – undo
373 373
 		}
374 374
 		else
375 375
 		{
376
-			$name_parts = explode('[',str_replace(']','',$name));
376
+			$name_parts = explode('[', str_replace(']', '', $name));
377 377
 			if (count($name_parts))
378 378
 			{
379
-				$org_name = $name_parts[count($name_parts)-1];
379
+				$org_name = $name_parts[count($name_parts) - 1];
380 380
 				if (isset(self::$request->sel_options[$org_name]) && is_array(self::$request->sel_options[$org_name]))
381 381
 				{
382 382
 					$options += self::$request->sel_options[$org_name];
@@ -405,9 +405,9 @@  discard block
 block discarded – undo
405 405
 	 * @param mixed $value =null value for readonly
406 406
 	 * @return array with value => label pairs
407 407
 	 */
408
-	public static function typeOptions($widget_type, $legacy_options, &$no_lang=false, $readonly=false, $value=null)
408
+	public static function typeOptions($widget_type, $legacy_options, &$no_lang = false, $readonly = false, $value = null)
409 409
 	{
410
-		list($rows,$type,$type2,$type3) = explode(',',$legacy_options);
410
+		list($rows, $type, $type2, $type3) = explode(',', $legacy_options);
411 411
 
412 412
 		$no_lang = false;
413 413
 		$options = array();
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 				if ($readonly)  // for readonly we dont need to fetch all cat's, nor do we need to indent them by level
418 418
 				{
419 419
 					$cell['no_lang'] = True;
420
-					foreach(is_array($value) ? $value : (strpos($value,',') !== false ? explode(',',$value) : array($value)) as $id)
420
+					foreach (is_array($value) ? $value : (strpos($value, ',') !== false ? explode(',', $value) : array($value)) as $id)
421 421
 					{
422 422
 						if ($id) $cell['sel_options'][$id] = stripslashes($GLOBALS['egw']->categories->id2name($id));
423 423
 					}
@@ -425,14 +425,14 @@  discard block
 block discarded – undo
425 425
 				}
426 426
 				if (!$type3 || $type3 === $GLOBALS['egw']->categories->app_name)
427 427
 				{
428
-					$categories =& $GLOBALS['egw']->categories;
428
+					$categories = & $GLOBALS['egw']->categories;
429 429
 				}
430 430
 				else    // we need to instanciate a new cat object for the correct application
431 431
 				{
432
-					$categories = new Api\Categories('',$type3);
432
+					$categories = new Api\Categories('', $type3);
433 433
 				}
434
-				$cat2path=array();
435
-				foreach((array)$categories->return_sorted_array(0,False,'','','',!$type,0,true) as $cat)
434
+				$cat2path = array();
435
+				foreach ((array)$categories->return_sorted_array(0, False, '', '', '', !$type, 0, true) as $cat)
436 436
 				{
437 437
 					$s = stripslashes($cat['name']);
438 438
 
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 				if ($value)
464 464
 				{
465 465
 					$pathes = $extension_data['unavailable'] = array();
466
-					foreach(is_array($value) ? $value : explode(',',$value) as $cat)
466
+					foreach (is_array($value) ? $value : explode(',', $value) as $cat)
467 467
 					{
468 468
 						if (isset($cat2path[$cat]))
469 469
 						{
Please login to merge, or discard this patch.
Braces   +24 added lines, -6 removed lines patch added patch discarded remove patch
@@ -187,7 +187,10 @@  discard block
 block discarded – undo
187 187
 		}
188 188
 		foreach((array)$item['item'] as $child)
189 189
 		{
190
-			if (self::in_tree($id, $child)) return true;
190
+			if (self::in_tree($id, $child))
191
+			{
192
+				return true;
193
+			}
191 194
 		}
192 195
 		return false;
193 196
 	}
@@ -251,7 +254,10 @@  discard block
 block discarded – undo
251 254
 				self::set_validation_error($form_name,lang('Field must not be empty !!!',$value),'');
252 255
 			}
253 256
 			$valid =& self::get_array($validated, $form_name, true);
254
-			if (true) $valid = $value;
257
+			if (true)
258
+			{
259
+				$valid = $value;
260
+			}
255 261
 			//error_log(__METHOD__."() $form_name: ".array2string($value_in).' --> '.array2string($value).', allowed='.array2string($allowed));
256 262
 		}
257 263
 	}
@@ -271,7 +277,10 @@  discard block
 block discarded – undo
271 277
 			//error_log(__METHOD__."() setting templated image-path for $form_name: $templated_path");
272 278
 		}
273 279
 
274
-		if (!is_array(self::$request->sel_options[$form_name])) self::$request->sel_options[$form_name] = array();
280
+		if (!is_array(self::$request->sel_options[$form_name]))
281
+		{
282
+			self::$request->sel_options[$form_name] = array();
283
+		}
275 284
 		if ($this->attrs['type'])
276 285
 		{
277 286
 			// += to keep further options set by app code
@@ -339,7 +348,10 @@  discard block
 block discarded – undo
339 348
 	public static function imagePath($image)
340 349
 	{
341 350
 		static $image_path=null;
342
-		if (!isset($image_path)) $image_path = self::templateImagePath ();
351
+		if (!isset($image_path))
352
+		{
353
+			$image_path = self::templateImagePath ();
354
+		}
343 355
 
344 356
 		$parts = explode('/', $image_path);
345 357
 		$image_parts   = explode('/', $image);
@@ -414,12 +426,18 @@  discard block
 block discarded – undo
414 426
 		switch ($widget_type)
415 427
 		{
416 428
 			case 'tree-cat':	// !$type == globals cats too, $type2: extraStyleMultiselect, $type3: application, if not current-app, $type4: parent-id, $type5=owner (-1=global),$type6=show missing
417
-				if ($readonly)  // for readonly we dont need to fetch all cat's, nor do we need to indent them by level
429
+				if ($readonly)
430
+				{
431
+					// for readonly we dont need to fetch all cat's, nor do we need to indent them by level
418 432
 				{
419 433
 					$cell['no_lang'] = True;
434
+				}
420 435
 					foreach(is_array($value) ? $value : (strpos($value,',') !== false ? explode(',',$value) : array($value)) as $id)
421 436
 					{
422
-						if ($id) $cell['sel_options'][$id] = stripslashes($GLOBALS['egw']->categories->id2name($id));
437
+						if ($id)
438
+						{
439
+							$cell['sel_options'][$id] = stripslashes($GLOBALS['egw']->categories->id2name($id));
440
+						}
423 441
 					}
424 442
 					break;
425 443
 				}
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Url.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,6 @@
 block discarded – undo
52 52
 	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
53 53
 	 * @param array $content
54 54
 	 * @param array &$validated=array() validated content
55
-	 * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont'
56 55
 	 */
57 56
 	public function validate($cname, array $expand, array $content, &$validated=array())
58 57
 	{
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @param array &$validated=array() validated content
55 55
 	 * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont'
56 56
 	 */
57
-	public function validate($cname, array $expand, array $content, &$validated=array())
57
+	public function validate($cname, array $expand, array $content, &$validated = array())
58 58
 	{
59 59
 		$form_name = self::form_name($cname, $this->id, $expand);
60 60
 
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
 
65 65
 			if ((string)$value === '' && $this->attrs['needed'])
66 66
 			{
67
-				self::set_validation_error($form_name,lang('Field must not be empty !!!'),'');
67
+				self::set_validation_error($form_name, lang('Field must not be empty !!!'), '');
68 68
 				return;
69 69
 			}
70 70
 			elseif ((string)$value != '' && !isset($this->attrs['preg']))
71 71
 			{
72
-				switch($this->type)
72
+				switch ($this->type)
73 73
 				{
74 74
 					case 'url':
75 75
 						// if no protocol given eg. "www.egroupware.org" prepend "http://" for validation
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 						}
80 80
 						$url_valid = filter_var($value, FILTER_VALIDATE_URL) ||
81 81
 							// Remove intl chars & check again, but if it passes we'll keep the original
82
-							filter_var(preg_replace('/[^[:print:]]/','',$value), FILTER_VALIDATE_URL);
82
+							filter_var(preg_replace('/[^[:print:]]/', '', $value), FILTER_VALIDATE_URL);
83 83
 						//error_log(__METHOD__."() filter_var(value=".array2string($value).", FILTER_VALIDATE_URL)=".array2string(filter_var($value, FILTER_VALIDATE_URL))." --> url_valid=".array2string($url_valid));
84 84
 						// remove http:// validation prefix again
85 85
 						if ($missing_protocol)
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 						}
89 89
 						if (!$url_valid)
90 90
 						{
91
-							self::set_validation_error($form_name,lang("'%1' has an invalid format !!!",$value),'');
91
+							self::set_validation_error($form_name, lang("'%1' has an invalid format !!!", $value), '');
92 92
 							return;
93 93
 						}
94 94
 						break;
@@ -98,19 +98,19 @@  discard block
 block discarded – undo
98 98
 				}
99 99
 			}
100 100
 
101
-			$valid =& self::get_array($validated, $form_name, true);
101
+			$valid = & self::get_array($validated, $form_name, true);
102 102
 
103
-			if ((int) $this->attrs['maxlength'] > 0 && strlen($value) > (int) $this->attrs['maxlength'])
103
+			if ((int)$this->attrs['maxlength'] > 0 && strlen($value) > (int)$this->attrs['maxlength'])
104 104
 			{
105
-				$value = substr($value,0,(int) $this->attrs['maxlength']);
105
+				$value = substr($value, 0, (int)$this->attrs['maxlength']);
106 106
 			}
107
-			if ($this->attrs['preg'] && !preg_match($this->attrs['preg'],$value))
107
+			if ($this->attrs['preg'] && !preg_match($this->attrs['preg'], $value))
108 108
 			{
109
-				switch($this->type)
109
+				switch ($this->type)
110 110
 				{
111 111
 					default:
112 112
 						//error_log("preg_match('{$this->attrs['preg']}', '$value')=".array2string(preg_match($this->attrs['preg'], $value)));
113
-						self::set_validation_error($form_name,lang("'%1' has an invalid format !!!",$value)/*." !preg_match('$this->attrs[preg]', '$value')"*/,'');
113
+						self::set_validation_error($form_name, lang("'%1' has an invalid format !!!", $value)/*." !preg_match('$this->attrs[preg]', '$value')"*/, '');
114 114
 						break;
115 115
 				}
116 116
 			}
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,10 @@
 block discarded – undo
37 37
 		{
38 38
 			$value = self::get_array($content, $form_name);
39 39
 			$valid =& self::get_array($validated, $form_name, true);
40
-			if (true) $valid = $value;
40
+			if (true)
41
+			{
42
+				$valid = $value;
43
+			}
41 44
 		}
42 45
 	}
43 46
 }
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Vfs.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -230,6 +230,7 @@
 block discarded – undo
230 230
 	* If the entry is not yet created, the file information is stored into the widget's value.
231 231
 	* When the form is submitted, the information for all files uploaded is available in the returned
232 232
 	* $content array and the application should deal with the file.
233
+	* @return string
233 234
 	*/
234 235
 	public static function store_file($path, $file)
235 236
 	{
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -224,13 +224,13 @@
 block discarded – undo
224 224
 	}
225 225
 
226 226
 	/**
227
-	* Ajax callback to receive an incoming file
228
-	*
229
-	* The incoming file is automatically placed into the appropriate VFS location.
230
-	* If the entry is not yet created, the file information is stored into the widget's value.
231
-	* When the form is submitted, the information for all files uploaded is available in the returned
232
-	* $content array and the application should deal with the file.
233
-	*/
227
+	 * Ajax callback to receive an incoming file
228
+	 *
229
+	 * The incoming file is automatically placed into the appropriate VFS location.
230
+	 * If the entry is not yet created, the file information is stored into the widget's value.
231
+	 * When the form is submitted, the information for all files uploaded is available in the returned
232
+	 * $content array and the application should deal with the file.
233
+	 */
234 234
 	public static function store_file($path, $file)
235 235
 	{
236 236
 		$name = $_REQUEST['widget_id'];
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
 	// Legacy option for vfs-upload
26 26
 	protected $legacy_options = "mime";
27 27
 
28
-	public function __construct($xml='')
28
+	public function __construct($xml = '')
29 29
 	{
30
-		if($xml) parent::__construct($xml);
30
+		if ($xml) parent::__construct($xml);
31 31
 	}
32 32
 
33 33
 	/**
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 	 */
37 37
 	public function beforeSendToClient($cname, $expand = array())
38 38
 	{
39
-		if($this->type == 'vfs-upload' || $this->attrs['type'] == 'vfs-upload')
39
+		if ($this->type == 'vfs-upload' || $this->attrs['type'] == 'vfs-upload')
40 40
 		{
41 41
 			$form_name = self::form_name($cname, $this->id, $expand ? $expand : array('cont'=>self::$request->content));
42
-			if($this->attrs['path'])
42
+			if ($this->attrs['path'])
43 43
 			{
44 44
 				$path = $this->attrs['path'];
45 45
 			}
@@ -50,26 +50,26 @@  discard block
 block discarded – undo
50 50
 
51 51
 			$this->setElementAttribute($form_name, 'path', $path);
52 52
 			// ID maps to path - check there for any existing files
53
-			list($app,$id,$relpath) = explode(':',$path,3);
54
-			if($app && $id)
53
+			list($app, $id, $relpath) = explode(':', $path, 3);
54
+			if ($app && $id)
55 55
 			{
56
-				if(!is_numeric($id))
56
+				if (!is_numeric($id))
57 57
 				{
58
-					$_id = self::expand_name($id,0,0,0,0,self::$request->content);
59
-					if($_id != $id)
58
+					$_id = self::expand_name($id, 0, 0, 0, 0, self::$request->content);
59
+					if ($_id != $id)
60 60
 					{
61 61
 						$id = $_id;
62 62
 						$form_name = "$app:$id:$relpath";
63 63
 					}
64 64
 				}
65
-				$value =& self::get_array(self::$request->content, $form_name, true);
66
-				$path = Api\Link::vfs_path($app,$id,'',true);
65
+				$value = & self::get_array(self::$request->content, $form_name, true);
66
+				$path = Api\Link::vfs_path($app, $id, '', true);
67 67
 				if (!empty($relpath)) $path .= '/'.$relpath;
68 68
 
69 69
 				if (true) $value = array();
70 70
 
71 71
 				// Single file, already existing
72
-				if (substr($path,-1) != '/' && Api\Vfs::file_exists($path) && !Api\Vfs::is_dir($path))
72
+				if (substr($path, -1) != '/' && Api\Vfs::file_exists($path) && !Api\Vfs::is_dir($path))
73 73
 				{
74 74
 					$file = Api\Vfs::stat($path);
75 75
 					$file['path'] = $path;
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 					$value = array($file);
79 79
 				}
80 80
 				// Single file, missing extension in path
81
-				else if (substr($path, -1) != '/' && !Api\Vfs::file_exists($path) && $relpath && substr($relpath,-4,1) !== '.')
81
+				else if (substr($path, -1) != '/' && !Api\Vfs::file_exists($path) && $relpath && substr($relpath, -4, 1) !== '.')
82 82
 				{
83
-					$find = Api\Vfs::find(substr($path,0, - strlen($relpath)), array(
83
+					$find = Api\Vfs::find(substr($path, 0, - strlen($relpath)), array(
84 84
 						'type' => 'f',
85 85
 						'maxdepth' => 1,
86
-						'name' => $relpath . '*'
86
+						'name' => $relpath.'*'
87 87
 					));
88
-					foreach($find as $file)
88
+					foreach ($find as $file)
89 89
 					{
90 90
 						$file_info = Api\Vfs::stat($file);
91 91
 						$file_info['path'] = $file;
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 				else if (substr($path, -1) == '/' && Api\Vfs::is_dir($path))
98 98
 				{
99 99
 					$scan = Api\Vfs::scandir($path);
100
-					foreach($scan as $file)
100
+					foreach ($scan as $file)
101 101
 					{
102 102
 						$file_info = Api\Vfs::stat("$path$file");
103 103
 						$file_info['path'] = "$path$file";
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	public static function ajax_upload()
114 114
 	{
115 115
 		parent::ajax_upload();
116
-		foreach($_FILES as $file)
116
+		foreach ($_FILES as $file)
117 117
 		{
118 118
 			self::store_file($_REQUEST['path'] ? $_REQUEST['path'] : $_REQUEST['widget_id'], $file);
119 119
 		}
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	{
127 127
 		$request_id = urldecode($_REQUEST['request_id']);
128 128
 		$widget_id = $_REQUEST['widget_id'];
129
-		if(!self::$request = Etemplate\Request::read($request_id))
129
+		if (!self::$request = Etemplate\Request::read($request_id))
130 130
 		{
131 131
 			$error = lang("Could not read session");
132 132
 		}
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 	static function fix_html_dragins($app, $id, array $links, &$html)
187 187
 	{
188 188
 		$replace = $remove_dir = array();
189
-		foreach($links as $link)
189
+		foreach ($links as $link)
190 190
 		{
191 191
 			$matches = null;
192
-			if (is_array($link) && preg_match('|^'.preg_quote(Api\Vfs::PREFIX,'|').'('.preg_quote(self::get_temp_dir($app, ''), '|').'[^/]+)/|', $link['id']['tmp_name'], $matches))
192
+			if (is_array($link) && preg_match('|^'.preg_quote(Api\Vfs::PREFIX, '|').'('.preg_quote(self::get_temp_dir($app, ''), '|').'[^/]+)/|', $link['id']['tmp_name'], $matches))
193 193
 			{
194 194
 				$replace[substr($link['id']['tmp_name'], strlen(Api\Vfs::PREFIX))] =
195 195
 					Api\Link::vfs_path($app, $id, Api\Vfs::basename($link['id']['tmp_name']), true);
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 		{
202 202
 			$html = strtr($old = $html, $replace);
203 203
 			// remove all dirs
204
-			foreach($remove_dir as $dir)
204
+			foreach ($remove_dir as $dir)
205 205
 			{
206 206
 				Api\Vfs::remove($dir);
207 207
 			}
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * @param string $postfix =null default random id
217 217
 	 * @return string vfs path
218 218
 	 */
219
-	static function get_temp_dir($app, $postfix=null)
219
+	static function get_temp_dir($app, $postfix = null)
220 220
 	{
221 221
 		if (!isset($postfix)) $postfix = md5(time().session_id());
222 222
 
@@ -236,15 +236,15 @@  discard block
 block discarded – undo
236 236
 		$name = $_REQUEST['widget_id'];
237 237
 
238 238
 		// Find real path
239
-		if($path[0] != '/')
239
+		if ($path[0] != '/')
240 240
 		{
241 241
 			$path = self::get_vfs_path($path);
242 242
 		}
243 243
 		$filename = $file['name'];
244
-		if (substr($path,-1) != '/')
244
+		if (substr($path, -1) != '/')
245 245
 		{
246 246
 			// add extension to path
247
-			$parts = explode('.',$filename);
247
+			$parts = explode('.', $filename);
248 248
 			if (($extension = array_pop($parts)) && Api\MimeMagic::ext2mime($extension))       // really an extension --> add it to path
249 249
 			{
250 250
 				$path .= '.'.$extension;
@@ -254,14 +254,14 @@  discard block
 block discarded – undo
254 254
 		{
255 255
 			$path .= Api\Vfs::encodePathComponent($filename);
256 256
 		}
257
-		if (!Api\Vfs::file_exists($dir = Api\Vfs::dirname($path)) && !Api\Vfs::mkdir($dir,null,STREAM_MKDIR_RECURSIVE))
257
+		if (!Api\Vfs::file_exists($dir = Api\Vfs::dirname($path)) && !Api\Vfs::mkdir($dir, null, STREAM_MKDIR_RECURSIVE))
258 258
 		{
259
-			self::set_validation_error($name,lang('Error create parent directory %1!',Api\Vfs::decodePath($dir)));
259
+			self::set_validation_error($name, lang('Error create parent directory %1!', Api\Vfs::decodePath($dir)));
260 260
 			return false;
261 261
 		}
262
-		if (!copy($file['tmp_name'],Api\Vfs::PREFIX.$path))
262
+		if (!copy($file['tmp_name'], Api\Vfs::PREFIX.$path))
263 263
 		{
264
-			self::set_validation_error($name,lang('Error copying uploaded file to vfs!'));
264
+			self::set_validation_error($name, lang('Error copying uploaded file to vfs!'));
265 265
 			return false;
266 266
 		}
267 267
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	 * @param array $content
281 281
 	 * @param array &$validated=array() validated content
282 282
 	 */
283
-	public function validate($cname, array $expand, array $content, &$validated=array())
283
+	public function validate($cname, array $expand, array $content, &$validated = array())
284 284
 	{
285 285
 		// do not validate, as it would overwrite preserved values with null!
286 286
 		if (in_array($this->type, array('vfs-size', 'vfs-uid', 'vfs-gid', 'vfs', 'vfs-mime')))
@@ -289,12 +289,12 @@  discard block
 block discarded – undo
289 289
 		}
290 290
 		$form_name = self::form_name($cname, $this->id, $expand);
291 291
 		$value = $value_in = self::get_array($content, $form_name);
292
-		$valid =& self::get_array($validated, $form_name, true);
292
+		$valid = & self::get_array($validated, $form_name, true);
293 293
 
294
-		switch($this->type)
294
+		switch ($this->type)
295 295
 		{
296 296
 			case 'vfs-upload':
297
-				if(!is_array($value)) $value = array();
297
+				if (!is_array($value)) $value = array();
298 298
 				/* Check & skip files that made it asyncronously
299 299
 				list($app,$id,$relpath) = explode(':',$this->id,3);
300 300
 				//...
@@ -313,16 +313,16 @@  discard block
 block discarded – undo
313 313
 	 */
314 314
 	public static function get_vfs_path($path)
315 315
 	{
316
-		list($app,$id,$relpath) = explode(':',$path,3);
316
+		list($app, $id, $relpath) = explode(':', $path, 3);
317 317
 		if (empty($id) || $id == 'undefined')
318 318
 		{
319
-			static $tmppath = array();      // static var, so all vfs-uploads get created in the same temporary dir
320
-			if (!isset($tmppath[$app])) $tmppath[$app] = self::get_temp_dir ($app);
319
+			static $tmppath = array(); // static var, so all vfs-uploads get created in the same temporary dir
320
+			if (!isset($tmppath[$app])) $tmppath[$app] = self::get_temp_dir($app);
321 321
 			$path = $tmppath[$app];
322 322
 		}
323 323
 		else
324 324
 		{
325
-			$path = Api\Link::vfs_path($app,$id,'',true);
325
+			$path = Api\Link::vfs_path($app, $id, '', true);
326 326
 		}
327 327
 		if (!empty($relpath)) $path .= '/'.$relpath;
328 328
 		return $path;
Please login to merge, or discard this patch.
Braces   +40 added lines, -10 removed lines patch added patch discarded remove patch
@@ -27,7 +27,10 @@  discard block
 block discarded – undo
27 27
 
28 28
 	public function __construct($xml='')
29 29
 	{
30
-		if($xml) parent::__construct($xml);
30
+		if($xml)
31
+		{
32
+			parent::__construct($xml);
33
+		}
31 34
 	}
32 35
 
33 36
 	/**
@@ -64,9 +67,15 @@  discard block
 block discarded – undo
64 67
 				}
65 68
 				$value =& self::get_array(self::$request->content, $form_name, true);
66 69
 				$path = Api\Link::vfs_path($app,$id,'',true);
67
-				if (!empty($relpath)) $path .= '/'.$relpath;
70
+				if (!empty($relpath))
71
+				{
72
+					$path .= '/'.$relpath;
73
+				}
68 74
 
69
-				if (true) $value = array();
75
+				if (true)
76
+				{
77
+					$value = array();
78
+				}
70 79
 
71 80
 				// Single file, already existing
72 81
 				if (substr($path,-1) != '/' && Api\Vfs::file_exists($path) && !Api\Vfs::is_dir($path))
@@ -194,7 +203,10 @@  discard block
 block discarded – undo
194 203
 				$replace[substr($link['id']['tmp_name'], strlen(Api\Vfs::PREFIX))] =
195 204
 					Api\Link::vfs_path($app, $id, Api\Vfs::basename($link['id']['tmp_name']), true);
196 205
 
197
-				if (!in_array($matches[1], $remove_dir)) $remove_dir[] = $matches[1];
206
+				if (!in_array($matches[1], $remove_dir))
207
+				{
208
+					$remove_dir[] = $matches[1];
209
+				}
198 210
 			}
199 211
 		}
200 212
 		if ($replace)
@@ -218,7 +230,10 @@  discard block
 block discarded – undo
218 230
 	 */
219 231
 	static function get_temp_dir($app, $postfix=null)
220 232
 	{
221
-		if (!isset($postfix)) $postfix = md5(time().session_id());
233
+		if (!isset($postfix))
234
+		{
235
+			$postfix = md5(time().session_id());
236
+		}
222 237
 
223 238
 		return '/home/'.$GLOBALS['egw_info']['user']['account_lid'].'/.tmp/'.$app.'_'.$postfix;
224 239
 	}
@@ -245,10 +260,13 @@  discard block
 block discarded – undo
245 260
 		{
246 261
 			// add extension to path
247 262
 			$parts = explode('.',$filename);
248
-			if (($extension = array_pop($parts)) && Api\MimeMagic::ext2mime($extension))       // really an extension --> add it to path
263
+			if (($extension = array_pop($parts)) && Api\MimeMagic::ext2mime($extension))
264
+			{
265
+				// really an extension --> add it to path
249 266
 			{
250 267
 				$path .= '.'.$extension;
251 268
 			}
269
+			}
252 270
 		}
253 271
 		else    // multiple upload with dir given (trailing slash)
254 272
 		{
@@ -294,7 +312,10 @@  discard block
 block discarded – undo
294 312
 		switch($this->type)
295 313
 		{
296 314
 			case 'vfs-upload':
297
-				if(!is_array($value)) $value = array();
315
+				if(!is_array($value))
316
+				{
317
+					$value = array();
318
+				}
298 319
 				/* Check & skip files that made it asyncronously
299 320
 				list($app,$id,$relpath) = explode(':',$this->id,3);
300 321
 				//...
@@ -305,7 +326,10 @@  discard block
 block discarded – undo
305 326
 				parent::validate($cname, $content, $validated);
306 327
 				break;
307 328
 		}
308
-		if (true) $valid = $value;
329
+		if (true)
330
+		{
331
+			$valid = $value;
332
+		}
309 333
 	}
310 334
 
311 335
 	/**
@@ -317,14 +341,20 @@  discard block
 block discarded – undo
317 341
 		if (empty($id) || $id == 'undefined')
318 342
 		{
319 343
 			static $tmppath = array();      // static var, so all vfs-uploads get created in the same temporary dir
320
-			if (!isset($tmppath[$app])) $tmppath[$app] = self::get_temp_dir ($app);
344
+			if (!isset($tmppath[$app]))
345
+			{
346
+				$tmppath[$app] = self::get_temp_dir ($app);
347
+			}
321 348
 			$path = $tmppath[$app];
322 349
 		}
323 350
 		else
324 351
 		{
325 352
 			$path = Api\Link::vfs_path($app,$id,'',true);
326 353
 		}
327
-		if (!empty($relpath)) $path .= '/'.$relpath;
354
+		if (!empty($relpath))
355
+		{
356
+			$path .= '/'.$relpath;
357
+		}
328 358
 		return $path;
329 359
 	}
330 360
 }
Please login to merge, or discard this patch.
api/src/Exception/NoPermission/Admin.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -19,6 +19,9 @@
 block discarded – undo
19 19
  */
20 20
 class Admin extends App
21 21
 {
22
+	/**
23
+	 * @param string $msg
24
+	 */
22 25
 	function __construct($msg=null,$code=102)
23 26
 	{
24 27
 		if (is_null($msg)) $msg = 'admin';
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@
 block discarded – undo
19 19
  */
20 20
 class Admin extends App
21 21
 {
22
-	function __construct($msg=null,$code=102)
22
+	function __construct($msg = null, $code = 102)
23 23
 	{
24 24
 		if (is_null($msg)) $msg = 'admin';
25 25
 
26
-		parent::__construct($msg,$code);
26
+		parent::__construct($msg, $code);
27 27
 	}
28 28
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,10 @@
 block discarded – undo
21 21
 {
22 22
 	function __construct($msg=null,$code=102)
23 23
 	{
24
-		if (is_null($msg)) $msg = 'admin';
24
+		if (is_null($msg))
25
+		{
26
+			$msg = 'admin';
27
+		}
25 28
 
26 29
 		parent::__construct($msg,$code);
27 30
 	}
Please login to merge, or discard this patch.
api/src/Framework.php 5 patches
Doc Comments   +4 added lines, -10 removed lines patch added patch discarded remove patch
@@ -78,6 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * Constructor
79 79
 	 *
80 80
 	 * The constructor instanciates the class in $GLOBALS['egw']->framework, from where it should be used
81
+	 * @param string $template
81 82
 	 */
82 83
 	function __construct($template)
83 84
 	{
@@ -544,7 +545,7 @@  discard block
 block discarded – undo
544 545
 	/**
545 546
 	 * Returns Html with user and time
546 547
 	 *
547
-	 * @return void
548
+	 * @return string
548 549
 	 */
549 550
 	protected static function _user_time_info()
550 551
 	{
@@ -602,7 +603,7 @@  discard block
 block discarded – undo
602 603
 	 *
603 604
 	 * @param string $username =null username for regular basic Auth
604 605
 	 * @param string $password =null password --------- " ----------
605
-	 * @return resource|null context to use with file_get_context/fopen or null if no proxy configured
606
+	 * @return resource context to use with file_get_context/fopen or null if no proxy configured
606 607
 	 */
607 608
 	public static function proxy_context($username=null, $password=null)
608 609
 	{
@@ -970,7 +971,6 @@  discard block
 block discarded – undo
970 971
 	 *
971 972
 	 * Themes are css file in the template directory
972 973
 	 *
973
-	 * @param string $themes_dir ='css'
974 974
 	 */
975 975
 	function list_themes()
976 976
 	{
@@ -1156,11 +1156,6 @@  discard block
 block discarded – undo
1156 1156
 	/**
1157 1157
 	* Add menu items to the topmenu template class to be displayed
1158 1158
 	*
1159
-	* @param array $app application data
1160
-	* @param mixed $alt_label string with alternative menu item label default value = null
1161
-	* @param string $urlextra string with alternate additional code inside <a>-tag
1162
-	* @access protected
1163
-	* @return void
1164 1159
 	*/
1165 1160
 	abstract function _add_topmenu_item(array $app_data,$alt_label=null);
1166 1161
 
@@ -1253,7 +1248,6 @@  discard block
 block discarded – undo
1253 1248
 	* @param string $package package or complete path (relative to EGW_SERVER_ROOT) to be included
1254 1249
 	* @param string|array $file =null file to be included - no ".js" on the end or array with get params
1255 1250
 	* @param string $app ='phpgwapi' application directory to search - default = phpgwapi
1256
-	* @param boolean $append =true should the file be added
1257 1251
 	*/
1258 1252
 	static function includeJS($package, $file=null, $app='phpgwapi')
1259 1253
 	{
@@ -1414,7 +1408,7 @@  discard block
 block discarded – undo
1414 1408
 	 * @param string $action "add" or "delete"
1415 1409
 	 * @param boolean|int|string $group ID of the group to create the favorite for, or 'all' for all users
1416 1410
 	 * @param array $filters =array() key => value pairs for the filter
1417
-	 * @return boolean Success
1411
+	 * @return boolean|null Success
1418 1412
 	 */
1419 1413
 	public static function ajax_set_favorite($app, $name, $action, $group, $filters = array())
1420 1414
 	{
Please login to merge, or discard this patch.
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -62,16 +62,16 @@  discard block
 block discarded – undo
62 62
 	var $template_dirs = array();
63 63
 
64 64
 	/**
65
-	* true if $this->header() was called
66
-	*
67
-	* @var boolean
68
-	*/
65
+	 * true if $this->header() was called
66
+	 *
67
+	 * @var boolean
68
+	 */
69 69
 	static $header_done = false;
70 70
 	/**
71
-	* true if $this->navbar() was called
72
-	*
73
-	* @var boolean
74
-	*/
71
+	 * true if $this->navbar() was called
72
+	 *
73
+	 * @var boolean
74
+	 */
75 75
 	static $navbar_done = false;
76 76
 
77 77
 	/**
@@ -1044,13 +1044,13 @@  discard block
 block discarded – undo
1044 1044
 	}
1045 1045
 
1046 1046
 	/**
1047
-	* Compile entries for topmenu:
1048
-	* - regular items: links
1049
-	* - info items
1050
-	*
1051
-	* @param array $vars
1052
-	* @param array $apps
1053
-	*/
1047
+	 * Compile entries for topmenu:
1048
+	 * - regular items: links
1049
+	 * - info items
1050
+	 *
1051
+	 * @param array $vars
1052
+	 * @param array $apps
1053
+	 */
1054 1054
 	function topmenu(array $vars,array $apps)
1055 1055
 	{
1056 1056
 		if($GLOBALS['egw_info']['user']['apps']['home'] && isset($apps['home']))
@@ -1154,39 +1154,39 @@  discard block
 block discarded – undo
1154 1154
 	}
1155 1155
 
1156 1156
 	/**
1157
-	* Add menu items to the topmenu template class to be displayed
1158
-	*
1159
-	* @param array $app application data
1160
-	* @param mixed $alt_label string with alternative menu item label default value = null
1161
-	* @param string $urlextra string with alternate additional code inside <a>-tag
1162
-	* @access protected
1163
-	* @return void
1164
-	*/
1157
+	 * Add menu items to the topmenu template class to be displayed
1158
+	 *
1159
+	 * @param array $app application data
1160
+	 * @param mixed $alt_label string with alternative menu item label default value = null
1161
+	 * @param string $urlextra string with alternate additional code inside <a>-tag
1162
+	 * @access protected
1163
+	 * @return void
1164
+	 */
1165 1165
 	abstract function _add_topmenu_item(array $app_data,$alt_label=null);
1166 1166
 
1167 1167
 	/**
1168
-	* Add info items to the topmenu template class to be displayed
1169
-	*
1170
-	* @param string $content Html of item
1171
-	* @param string $id =null
1172
-	* @access protected
1173
-	* @return void
1174
-	*/
1168
+	 * Add info items to the topmenu template class to be displayed
1169
+	 *
1170
+	 * @param string $content Html of item
1171
+	 * @param string $id =null
1172
+	 * @access protected
1173
+	 * @return void
1174
+	 */
1175 1175
 	abstract function _add_topmenu_info_item($content, $id=null);
1176 1176
 
1177 1177
 	static $top_menu_extra = array();
1178 1178
 
1179 1179
 	/**
1180
-	* Called by hooks to add an entry in the topmenu location.
1181
-	* Extra entries will be added just before Logout.
1182
-	*
1183
-	* @param string $id unique element id
1184
-	* @param string $url Address for the entry to link to
1185
-	* @param string $title Text displayed for the entry
1186
-	* @param string $target Optional, so the entry can open in a new page or popup
1187
-	* @access public
1188
-	* @return void
1189
-	*/
1180
+	 * Called by hooks to add an entry in the topmenu location.
1181
+	 * Extra entries will be added just before Logout.
1182
+	 *
1183
+	 * @param string $id unique element id
1184
+	 * @param string $url Address for the entry to link to
1185
+	 * @param string $title Text displayed for the entry
1186
+	 * @param string $target Optional, so the entry can open in a new page or popup
1187
+	 * @access public
1188
+	 * @return void
1189
+	 */
1190 1190
 	public static function add_topmenu_item($id,$url,$title,$target = '')
1191 1191
 	{
1192 1192
 		$entry['name'] = $id;
@@ -1198,16 +1198,16 @@  discard block
 block discarded – undo
1198 1198
 	}
1199 1199
 
1200 1200
 	/**
1201
-	* called by hooks to add an icon in the topmenu info location
1202
-	*
1203
-	* @param string $id unique element id
1204
-	* @param string $icon_src src of the icon image. Make sure this nog height then 18pixels
1205
-	* @param string $iconlink where the icon links to
1206
-	* @param booleon $blink set true to make the icon blink
1207
-	* @param mixed $tooltip string containing the tooltip html, or null of no tooltip
1208
-	* @access public
1209
-	* @return void
1210
-	*/
1201
+	 * called by hooks to add an icon in the topmenu info location
1202
+	 *
1203
+	 * @param string $id unique element id
1204
+	 * @param string $icon_src src of the icon image. Make sure this nog height then 18pixels
1205
+	 * @param string $iconlink where the icon links to
1206
+	 * @param booleon $blink set true to make the icon blink
1207
+	 * @param mixed $tooltip string containing the tooltip html, or null of no tooltip
1208
+	 * @access public
1209
+	 * @return void
1210
+	 */
1211 1211
 	abstract function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null);
1212 1212
 
1213 1213
 	/**
@@ -1242,19 +1242,19 @@  discard block
 block discarded – undo
1242 1242
 	protected static $js_include_mgr;
1243 1243
 
1244 1244
 	/**
1245
-	* Checks to make sure a valid package and file name is provided
1246
-	*
1247
-	* Example call syntax:
1248
-	* a) Api\Framework::includeJS('jscalendar','calendar')
1249
-	*    --> /phpgwapi/js/jscalendar/calendar.js
1250
-	* b) Api\Framework::includeJS('/phpgwapi/inc/calendar-setup.js',array('lang'=>'de'))
1251
-	*    --> /phpgwapi/inc/calendar-setup.js?lang=de
1252
-	*
1253
-	* @param string $package package or complete path (relative to EGW_SERVER_ROOT) to be included
1254
-	* @param string|array $file =null file to be included - no ".js" on the end or array with get params
1255
-	* @param string $app ='phpgwapi' application directory to search - default = phpgwapi
1256
-	* @param boolean $append =true should the file be added
1257
-	*/
1245
+	 * Checks to make sure a valid package and file name is provided
1246
+	 *
1247
+	 * Example call syntax:
1248
+	 * a) Api\Framework::includeJS('jscalendar','calendar')
1249
+	 *    --> /phpgwapi/js/jscalendar/calendar.js
1250
+	 * b) Api\Framework::includeJS('/phpgwapi/inc/calendar-setup.js',array('lang'=>'de'))
1251
+	 *    --> /phpgwapi/inc/calendar-setup.js?lang=de
1252
+	 *
1253
+	 * @param string $package package or complete path (relative to EGW_SERVER_ROOT) to be included
1254
+	 * @param string|array $file =null file to be included - no ".js" on the end or array with get params
1255
+	 * @param string $app ='phpgwapi' application directory to search - default = phpgwapi
1256
+	 * @param boolean $append =true should the file be added
1257
+	 */
1258 1258
 	static function includeJS($package, $file=null, $app='phpgwapi')
1259 1259
 	{
1260 1260
 		self::$js_include_mgr->include_js_file($package, $file, $app);
Please login to merge, or discard this patch.
Spacing   +124 added lines, -126 removed lines patch added patch discarded remove patch
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
 			if (empty($GLOBALS['egw_info']['server']['template_set'])) $GLOBALS['egw_info']['server']['template_set'] = 'idots';
121 121
 			// setup the new eGW framework (template sets)
122 122
 			$class = $GLOBALS['egw_info']['server']['template_set'].'_framework';
123
-			if (!class_exists($class) &&	// first try to autoload the class
124
-				file_exists($file=EGW_INCLUDE_ROOT.'/phpgwapi/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/class.'.$class.'.inc.php'))
123
+			if (!class_exists($class) && // first try to autoload the class
124
+				file_exists($file = EGW_INCLUDE_ROOT.'/phpgwapi/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/class.'.$class.'.inc.php'))
125 125
 			{
126 126
 				require_once($file);
127
-				if (!in_array($file,(array)$_SESSION['egw_required_files']))
127
+				if (!in_array($file, (array)$_SESSION['egw_required_files']))
128 128
 				{
129
-					$_SESSION['egw_required_files'][] = $file;	// automatic load the used framework class, when the object get's restored
129
+					$_SESSION['egw_required_files'][] = $file; // automatic load the used framework class, when the object get's restored
130 130
 				}
131 131
 			}
132 132
 		}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		Header\ContentSecurityPolicy::send();
154 154
 
155 155
 		// allow client-side to detect first load aka just logged in
156
-		$reload_count =& Cache::getSession(__CLASS__, 'framework-reload');
156
+		$reload_count = & Cache::getSession(__CLASS__, 'framework-reload');
157 157
 		self::$extra['framework-reload'] = (int)(bool)$reload_count++;
158 158
 	}
159 159
 
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
 	 * @param string $link_app =null if appname or true, some templates generate a special link-handler url
183 183
 	 * @return string	The full url after processing
184 184
 	 */
185
-	static function link($url, $extravars = '', $link_app=null)
185
+	static function link($url, $extravars = '', $link_app = null)
186 186
 	{
187
-		unset($link_app);	// not used by required by function signature
187
+		unset($link_app); // not used by required by function signature
188 188
 		return $GLOBALS['egw']->session->link($url, $extravars);
189 189
 	}
190 190
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 * @param string $url url to redirect to
197 197
 	 * @param string $link_app =null appname to redirect for, default currentapp
198 198
 	 */
199
-	static function redirect($url, $link_app=null)
199
+	static function redirect($url, $link_app = null)
200 200
 	{
201 201
 		// Determines whether the current output buffer should be flushed
202 202
 		$do_flush = true;
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 		else
219 219
 		{
220 220
 			$file = $line = null;
221
-			if (headers_sent($file,$line))
221
+			if (headers_sent($file, $line))
222 222
 			{
223 223
 				throw new Exception\AssertionFailed(__METHOD__."('".htmlspecialchars($url)."') can NOT redirect, output already started at $file line $line!");
224 224
 			}
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	 * @param string $link_app =null if appname or true, some templates generate a special link-handler url
254 254
 	 * @return string	The full url after processing
255 255
 	 */
256
-	static function redirect_link($url, $extravars='', $link_app=null)
256
+	static function redirect_link($url, $extravars = '', $link_app = null)
257 257
 	{
258 258
 		self::redirect(self::link($url, $extravars), $link_app);
259 259
 	}
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	 * @param string $navbar =null show the navigation, default !$GLOBALS['egw_info']['flags']['nonavbar'], false gives a typical popu
269 269
 	 *
270 270
 	 */
271
-	function render($content,$app_header=null,$navbar=null)
271
+	function render($content, $app_header = null, $navbar = null)
272 272
 	{
273 273
 		if (!is_null($app_header)) $GLOBALS['egw_info']['flags']['app_header'] = $app_header;
274 274
 		if (!is_null($navbar)) $GLOBALS['egw_info']['flags']['nonavbar'] = !$navbar;
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 *
290 290
 	 * @return string with Html
291 291
 	 */
292
-	abstract function header(array $extra=array());
292
+	abstract function header(array $extra = array());
293 293
 
294 294
 	/**
295 295
 	 * Returns the Html from the body-tag til the main application area (incl. opening div tag)
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 * @return boolean $consider_navbar_not_yet_called_as_true=true
310 310
 	 * @return boolean
311 311
 	 */
312
-	abstract function isTop($consider_navbar_not_yet_called_as_true=true);
312
+	abstract function isTop($consider_navbar_not_yet_called_as_true = true);
313 313
 
314 314
 	/**
315 315
 	 * Returns the content of one sidebox
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 * @param array $file
320 320
 	 * @param string $type =null 'admin', 'preferences', 'favorites', ...
321 321
 	 */
322
-	abstract function sidebox($appname,$menu_title,$file,$type=null);
322
+	abstract function sidebox($appname, $menu_title, $file, $type = null);
323 323
 
324 324
 	/**
325 325
 	 * Returns the Html from the closing div of the main application area to the closing html-tag
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 	 * @param string $extra_vars for login url
335 335
 	 * @param string $change_passwd =null string with message to render input fields for password change
336 336
 	 */
337
-	function login_screen($extra_vars, $change_passwd=null)
337
+	function login_screen($extra_vars, $change_passwd = null)
338 338
 	{
339 339
 		(new Framework\Login($this))->screen($extra_vars, $change_passwd);
340 340
 	}
@@ -355,19 +355,19 @@  discard block
 block discarded – undo
355 355
 	public function _get_footer()
356 356
 	{
357 357
 		$var = Array(
358
-			'img_root'       => $GLOBALS['egw_info']['server']['webserver_url'] . $this->template_dir.'/images',
358
+			'img_root'       => $GLOBALS['egw_info']['server']['webserver_url'].$this->template_dir.'/images',
359 359
 			'version'        => $GLOBALS['egw_info']['server']['versions']['phpgwapi']
360 360
 		);
361 361
 		$var['page_generation_time'] = '';
362
-		if($GLOBALS['egw_info']['user']['preferences']['common']['show_generation_time'])
362
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['show_generation_time'])
363 363
 		{
364
-			$totaltime = sprintf('%4.2lf',microtime(true) - $GLOBALS['egw_info']['flags']['page_start_time']);
364
+			$totaltime = sprintf('%4.2lf', microtime(true) - $GLOBALS['egw_info']['flags']['page_start_time']);
365 365
 
366
-			$var['page_generation_time'] = '<div class="pageGenTime" id="divGenTime_'.$GLOBALS['egw_info']['flags']['currentapp'].'"><span>'.lang('Page was generated in %1 seconds',$totaltime);
366
+			$var['page_generation_time'] = '<div class="pageGenTime" id="divGenTime_'.$GLOBALS['egw_info']['flags']['currentapp'].'"><span>'.lang('Page was generated in %1 seconds', $totaltime);
367 367
 			if ($GLOBALS['egw_info']['flags']['session_restore_time'])
368 368
 			{
369 369
 				$var['page_generation_time'] .= ' '.lang('(session restored in %1 seconds)',
370
-					sprintf('%4.2lf',$GLOBALS['egw_info']['flags']['session_restore_time']));
370
+					sprintf('%4.2lf', $GLOBALS['egw_info']['flags']['session_restore_time']));
371 371
 			}
372 372
 			$var['page_generation_time'] .= '</span></div>';
373 373
 		}
@@ -397,16 +397,16 @@  discard block
 block discarded – undo
397 397
 	static public function _get_body_attribs()
398 398
 	{
399 399
 		$js = '';
400
-		foreach(self::$body_tags as $what => $data)
400
+		foreach (self::$body_tags as $what => $data)
401 401
 		{
402 402
 			if (!empty($data))
403 403
 			{
404
-				if($what == 'onLoad')
404
+				if ($what == 'onLoad')
405 405
 				{
406
-					$js .= 'onLoad="egw_LAB.wait(function() {'. htmlspecialchars($data).'})"';
406
+					$js .= 'onLoad="egw_LAB.wait(function() {'.htmlspecialchars($data).'})"';
407 407
 					continue;
408 408
 				}
409
-				$js .= ' '.$what.'="' . htmlspecialchars($data) . '"';
409
+				$js .= ' '.$what.'="'.htmlspecialchars($data).'"';
410 410
 			}
411 411
 		}
412 412
 		return $js;
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 	 * @param array $extra =array() extra attributes passed as data-attribute to egw.js
419 419
 	 * @return array
420 420
 	 */
421
-	protected function _get_header(array $extra=array())
421
+	protected function _get_header(array $extra = array())
422 422
 	{
423 423
 		// display password expires in N days message once per session
424 424
 		$message = null;
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		}
430 430
 
431 431
 		// get used language code (with a little xss check, if someone tries to sneak something in)
432
-		if (preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$GLOBALS['egw_info']['user']['preferences']['common']['lang']))
432
+		if (preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $GLOBALS['egw_info']['user']['preferences']['common']['lang']))
433 433
 		{
434 434
 			$lang_code = $GLOBALS['egw_info']['user']['preferences']['common']['lang'];
435 435
 		}
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
 		// send appheader to clientside
450 450
 		$extra['app-header'] = $app_header;
451 451
 
452
-		if($GLOBALS['egw_info']['flags']['currentapp'] != 'wiki') $robots ='<meta name="robots" content="none" />';
452
+		if ($GLOBALS['egw_info']['flags']['currentapp'] != 'wiki') $robots = '<meta name="robots" content="none" />';
453 453
 
454
-		if (substr($GLOBALS['egw_info']['server']['favicon_file'],0,4) == 'http')
454
+		if (substr($GLOBALS['egw_info']['server']['favicon_file'], 0, 4) == 'http')
455 455
 		{
456 456
 			$var['favicon_file'] = $GLOBALS['egw_info']['server']['favicon_file'];
457 457
 		}
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 			$include_wz_tooltip = '<script src="'.$GLOBALS['egw_info']['server']['webserver_url'].
468 468
 				$wz_tooltip.'?'.filemtime(EGW_SERVER_ROOT.$wz_tooltip).'" type="text/javascript"></script>';
469 469
 		}
470
-		return $this->_get_css()+array(
470
+		return $this->_get_css() + array(
471 471
 			'img_icon'			=> $var['favicon_file'],
472 472
 			'img_shortcut'		=> $var['favicon_file'],
473 473
 			'pngfix'        	=> $pngfix,
@@ -491,15 +491,15 @@  discard block
 block discarded – undo
491 491
 	 */
492 492
 	protected function _get_navbar($apps)
493 493
 	{
494
-		$var['img_root'] = $GLOBALS['egw_info']['server']['webserver_url'] . '/phpgwapi/templates/'.$this->template.'/images';
494
+		$var['img_root'] = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/templates/'.$this->template.'/images';
495 495
 
496
-		if(isset($GLOBALS['egw_info']['flags']['app_header']))
496
+		if (isset($GLOBALS['egw_info']['flags']['app_header']))
497 497
 		{
498 498
 			$var['current_app_title'] = $GLOBALS['egw_info']['flags']['app_header'];
499 499
 		}
500 500
 		else
501 501
 		{
502
-			$var['current_app_title']=$apps[$GLOBALS['egw_info']['flags']['currentapp']]['title'];
502
+			$var['current_app_title'] = $apps[$GLOBALS['egw_info']['flags']['currentapp']]['title'];
503 503
 		}
504 504
 		$var['currentapp'] = $GLOBALS['egw_info']['flags']['currentapp'];
505 505
 
@@ -511,32 +511,32 @@  discard block
 block discarded – undo
511 511
 
512 512
 		$var['user_info'] = $this->_user_time_info();
513 513
 
514
-		if($GLOBALS['egw_info']['user']['account_lastpwd_change'] == 0)
514
+		if ($GLOBALS['egw_info']['user']['account_lastpwd_change'] == 0)
515 515
 		{
516 516
 			$api_messages = lang('You are required to change your password during your first login').'<br />'.
517
-				lang('Click this image on the navbar: %1','<img src="'.Image::find('preferences','navbar.gif').'">');
517
+				lang('Click this image on the navbar: %1', '<img src="'.Image::find('preferences', 'navbar.gif').'">');
518 518
 		}
519
-		elseif($GLOBALS['egw_info']['server']['change_pwd_every_x_days'] && $GLOBALS['egw_info']['user']['account_lastpwd_change'] < time() - (86400*$GLOBALS['egw_info']['server']['change_pwd_every_x_days']))
519
+		elseif ($GLOBALS['egw_info']['server']['change_pwd_every_x_days'] && $GLOBALS['egw_info']['user']['account_lastpwd_change'] < time() - (86400 * $GLOBALS['egw_info']['server']['change_pwd_every_x_days']))
520 520
 		{
521
-			$api_messages = lang('it has been more then %1 days since you changed your password',$GLOBALS['egw_info']['server']['change_pwd_every_x_days']);
521
+			$api_messages = lang('it has been more then %1 days since you changed your password', $GLOBALS['egw_info']['server']['change_pwd_every_x_days']);
522 522
 		}
523 523
 
524
-		if (substr($GLOBALS['egw_info']['server']['login_logo_file'],0,4) == 'http' ||
524
+		if (substr($GLOBALS['egw_info']['server']['login_logo_file'], 0, 4) == 'http' ||
525 525
 			$GLOBALS['egw_info']['server']['login_logo_file'][0] == '/')
526 526
 		{
527 527
 			$var['logo_file'] = $GLOBALS['egw_info']['server']['login_logo_file'];
528 528
 		}
529 529
 		else
530 530
 		{
531
-			$var['logo_file'] = Image::find('phpgwapi',$GLOBALS['egw_info']['server']['login_logo_file']?$GLOBALS['egw_info']['server']['login_logo_file']:'logo', '', null);	// null=explicit allow svg
531
+			$var['logo_file'] = Image::find('phpgwapi', $GLOBALS['egw_info']['server']['login_logo_file'] ? $GLOBALS['egw_info']['server']['login_logo_file'] : 'logo', '', null); // null=explicit allow svg
532 532
 		}
533
-		$var['logo_url'] = $GLOBALS['egw_info']['server']['login_logo_url']?$GLOBALS['egw_info']['server']['login_logo_url']:'http://www.eGroupWare.org';
533
+		$var['logo_url'] = $GLOBALS['egw_info']['server']['login_logo_url'] ? $GLOBALS['egw_info']['server']['login_logo_url'] : 'http://www.eGroupWare.org';
534 534
 
535
-		if (substr($var['logo_url'],0,4) != 'http')
535
+		if (substr($var['logo_url'], 0, 4) != 'http')
536 536
 		{
537 537
 			$var['logo_url'] = 'http://'.$var['logo_url'];
538 538
 		}
539
-		$var['logo_title'] = $GLOBALS['egw_info']['server']['login_logo_title']?$GLOBALS['egw_info']['server']['login_logo_title']:'www.eGroupWare.org';
539
+		$var['logo_title'] = $GLOBALS['egw_info']['server']['login_logo_title'] ? $GLOBALS['egw_info']['server']['login_logo_title'] : 'www.eGroupWare.org';
540 540
 
541 541
 		return $var;
542 542
 	}
@@ -549,14 +549,14 @@  discard block
 block discarded – undo
549 549
 	protected static function _user_time_info()
550 550
 	{
551 551
 		$now = new DateTime();
552
-		$user_info = '<b>'.Accounts::format_username() .'</b>'. ' - ' . lang($now->format('l')) . ' ' . $now->format(true);
552
+		$user_info = '<b>'.Accounts::format_username().'</b>'.' - '.lang($now->format('l')).' '.$now->format(true);
553 553
 
554 554
 		$user_tzs = DateTime::getUserTimezones();
555 555
 		if (count($user_tzs) > 1)
556 556
 		{
557 557
 			$tz = $GLOBALS['egw_info']['user']['preferences']['common']['tz'];
558
-			$user_info .= Html::form(Html::select('tz',$tz,$user_tzs,true),array(),
559
-				'/index.php','','tz_selection',' style="display: inline;"','GET');
558
+			$user_info .= Html::form(Html::select('tz', $tz, $user_tzs, true), array(),
559
+				'/index.php', '', 'tz_selection', ' style="display: inline;"', 'GET');
560 560
 		}
561 561
 		return $user_info;
562 562
 	}
@@ -568,10 +568,10 @@  discard block
 block discarded – undo
568 568
 	 */
569 569
 	protected static function _current_users()
570 570
 	{
571
-	   if( $GLOBALS['egw_info']['user']['apps']['admin'] && $GLOBALS['egw_info']['user']['preferences']['common']['show_currentusers'])
571
+	   if ($GLOBALS['egw_info']['user']['apps']['admin'] && $GLOBALS['egw_info']['user']['preferences']['common']['show_currentusers'])
572 572
 	   {
573
-		  $current_users = '<a href="' . self::link('/index.php','menuaction=admin.admin_accesslog.sessions') . '">' .
574
-		  	lang('Current users') . ': <span id="currentusers">' . $GLOBALS['egw']->session->session_count() . '</span></a>';
573
+		  $current_users = '<a href="'.self::link('/index.php', 'menuaction=admin.admin_accesslog.sessions').'">'.
574
+		  	lang('Current users').': <span id="currentusers">'.$GLOBALS['egw']->session->session_count().'</span></a>';
575 575
 		  return $current_users;
576 576
 	   }
577 577
 	}
@@ -604,14 +604,14 @@  discard block
 block discarded – undo
604 604
 	 * @param string $password =null password --------- " ----------
605 605
 	 * @return resource|null context to use with file_get_context/fopen or null if no proxy configured
606 606
 	 */
607
-	public static function proxy_context($username=null, $password=null)
607
+	public static function proxy_context($username = null, $password = null)
608 608
 	{
609 609
 		$opts = array(
610 610
 			'method' => 'GET',
611 611
 		);
612 612
 		if (!empty($GLOBALS['egw_info']['server']['httpproxy_server']))
613 613
 		{
614
-			$opts += array (
614
+			$opts += array(
615 615
 				'proxy'  => 'tcp://'.$GLOBALS['egw_info']['server']['httpproxy_server'].':'.
616 616
 					($GLOBALS['egw_info']['server']['httpproxy_port'] ? $GLOBALS['egw_info']['server']['httpproxy_port'] : 8080),
617 617
 				'request_fulluri' => true,
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 	 * @param string &$changelog on return path to changelog
641 641
 	 * @return string
642 642
 	 */
643
-	public static function api_version(&$changelog=null)
643
+	public static function api_version(&$changelog = null)
644 644
 	{
645 645
 		return Framework\Updates::api_version($changelog);
646 646
 	}
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 	 */
654 654
 	public static function index($app)
655 655
 	{
656
-		$data =& $GLOBALS['egw_info']['user']['apps'][$app];
656
+		$data = & $GLOBALS['egw_info']['user']['apps'][$app];
657 657
 		if (!isset($data))
658 658
 		{
659 659
 			throw new Exception\WrongParameter("'$app' not a valid app for this user!");
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 				$index = '/index.php?menuaction='.$data['index'];
671 671
 			}
672 672
 		}
673
-		return self::link($index,$GLOBALS['egw_info']['flags']['params'][$app]);
673
+		return self::link($index, $GLOBALS['egw_info']['flags']['params'][$app]);
674 674
 	}
675 675
 
676 676
 	/**
@@ -711,15 +711,15 @@  discard block
 block discarded – undo
711 711
 	 *	true: always return svg, false: never return svg (current default), null: browser dependent, see svg_usable()
712 712
 	 * @return array
713 713
 	 */
714
-	protected static function _get_navbar_apps($svg=false)
714
+	protected static function _get_navbar_apps($svg = false)
715 715
 	{
716 716
 		list($first) = each($GLOBALS['egw_info']['user']['apps']);
717
-		if(is_array($GLOBALS['egw_info']['user']['apps']['admin']) && $first != 'admin')
717
+		if (is_array($GLOBALS['egw_info']['user']['apps']['admin']) && $first != 'admin')
718 718
 		{
719 719
 			$newarray['admin'] = $GLOBALS['egw_info']['user']['apps']['admin'];
720
-			foreach($GLOBALS['egw_info']['user']['apps'] as $index => $value)
720
+			foreach ($GLOBALS['egw_info']['user']['apps'] as $index => $value)
721 721
 			{
722
-				if($index != 'admin')
722
+				if ($index != 'admin')
723 723
 				{
724 724
 					$newarray[$index] = $value;
725 725
 				}
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 		unset($newarray);
733 733
 
734 734
 		$apps = array();
735
-		foreach($GLOBALS['egw_info']['user']['apps'] as $app => $data)
735
+		foreach ($GLOBALS['egw_info']['user']['apps'] as $app => $data)
736 736
 		{
737 737
 			if (is_long($app))
738 738
 			{
@@ -749,21 +749,21 @@  discard block
 block discarded – undo
749 749
 				if ($data['status'] == 4)
750 750
 				{
751 751
 					$apps[$app]['target'] = ' target="'.$app.'" onClick="'."if (this != '') { window.open(this+'".
752
-						(strpos($apps[$app]['url'],'?') !== false ? '&' : '?').
752
+						(strpos($apps[$app]['url'], '?') !== false ? '&' : '?').
753 753
 						"referer='+encodeURIComponent(location),this.target,'width=800,height=600,scrollbars=yes,resizable=yes'); return false; } else { return true; }".'"';
754 754
 				}
755
-				elseif(isset($GLOBALS['egw_info']['flags']['navbar_target']) && $GLOBALS['egw_info']['flags']['navbar_target'])
755
+				elseif (isset($GLOBALS['egw_info']['flags']['navbar_target']) && $GLOBALS['egw_info']['flags']['navbar_target'])
756 756
 				{
757
-					$apps[$app]['target'] = 'target="' . $GLOBALS['egw_info']['flags']['navbar_target'] . '"';
757
+					$apps[$app]['target'] = 'target="'.$GLOBALS['egw_info']['flags']['navbar_target'].'"';
758 758
 				}
759 759
 				else
760 760
 				{
761 761
 					$apps[$app]['target'] = '';
762 762
 				}
763 763
 
764
-				$icon = isset($data['icon']) ?  $data['icon'] : 'navbar';
764
+				$icon = isset($data['icon']) ? $data['icon'] : 'navbar';
765 765
 				$icon_app = isset($data['icon_app']) ? $data['icon_app'] : $app;
766
-				$apps[$app]['icon']  = $apps[$app]['icon_hover']  = Image::find($icon_app,Array($icon,'nonav'),'',$svg);
766
+				$apps[$app]['icon'] = $apps[$app]['icon_hover'] = Image::find($icon_app, Array($icon, 'nonav'), '', $svg);
767 767
 			}
768 768
 		}
769 769
 
@@ -796,13 +796,13 @@  discard block
 block discarded – undo
796 796
 		// We handle this here because its special
797 797
 		$apps['about']['title'] = 'EGroupware';
798 798
 		$apps['about']['url']   = self::link('/about.php');
799
-		$apps['about']['icon']  = $apps['about']['icon_hover'] = Image::find('api',Array('about','nonav'));
799
+		$apps['about']['icon']  = $apps['about']['icon_hover'] = Image::find('api', Array('about', 'nonav'));
800 800
 		$apps['about']['name']  = 'about';
801 801
 
802 802
 		$apps['logout']['title'] = lang('Logout');
803 803
 		$apps['logout']['name']  = 'logout';
804 804
 		$apps['logout']['url']   = self::link('/logout.php');
805
-		$apps['logout']['icon']  = $apps['logout']['icon_hover'] = Image::find('api',Array('logout','nonav'));
805
+		$apps['logout']['icon']  = $apps['logout']['icon_hover'] = Image::find('api', Array('logout', 'nonav'));
806 806
 
807 807
 		return $apps;
808 808
 	}
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 			}
837 837
 			$themes_to_check[] = $this->template_dir.'/css/'.$GLOBALS['egw_info']['user']['preferences']['common']['theme'].'.css';
838 838
 			$themes_to_check[] = $this->template_dir.'/css/'.$this->template.'.css';
839
-			foreach($themes_to_check as $theme_css)
839
+			foreach ($themes_to_check as $theme_css)
840 840
 			{
841 841
 				if (file_exists(EGW_SERVER_ROOT.$theme_css)) break;
842 842
 			}
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
 
868 868
 				// sending print css last, so it can overwrite anything
869 869
 				$print_css = $this->template_dir.'/print.css';
870
-				if(!file_exists(EGW_SERVER_ROOT.$print_css))
870
+				if (!file_exists(EGW_SERVER_ROOT.$print_css))
871 871
 				{
872 872
 					$print_css = '/api/templates/default/print.css';
873 873
 				}
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 	 * @param array $extra =array() extra data to pass to egw.js as data-parameter
894 894
 	 * @return string the javascript to be included
895 895
 	 */
896
-	public static function _get_js(array $extra=array())
896
+	public static function _get_js(array $extra = array())
897 897
 	{
898 898
 		$java_script = '';
899 899
 
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 		Think of conf vars etc...  ([email protected]) */
902 902
 		if (isset($GLOBALS['egw_info']['flags']['java_script_thirst']))
903 903
 		{
904
-			$java_script .= $GLOBALS['egw_info']['flags']['java_script_thirst'] . "\n";
904
+			$java_script .= $GLOBALS['egw_info']['flags']['java_script_thirst']."\n";
905 905
 		}
906 906
 		// add configuration, link-registry, images, user-data and -perferences for non-popup windows
907 907
 		// specifying etag in url to force reload, as we send expires header
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
 			self::includeJS('/api/images.php', array(
914 914
 				'template' => $GLOBALS['egw_info']['server']['template_set'],
915 915
 				'etag' => md5(json_encode(Image::map($GLOBALS['egw_info']['server']['template_set']))),
916
-				'svg' => Header\UserAgent::mobile(),	// always load non-svg image map, ATM we use svg icons only for mobile theme
916
+				'svg' => Header\UserAgent::mobile(), // always load non-svg image map, ATM we use svg icons only for mobile theme
917 917
 			));
918 918
 			self::includeJS('/api/user.php', array(
919 919
 				'user' => $GLOBALS['egw_info']['user']['account_lid'],
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
 		}
926 926
 
927 927
 		$extra['url'] = $GLOBALS['egw_info']['server']['webserver_url'];
928
-		$extra['include'] = array_map(function($str){return substr($str,1);}, self::get_script_links(true), array(1));
928
+		$extra['include'] = array_map(function($str) {return substr($str, 1); }, self::get_script_links(true), array(1));
929 929
 		$extra['app'] = $GLOBALS['egw_info']['flags']['currentapp'];
930 930
 
931 931
 		// Load LABjs ONCE here
@@ -935,18 +935,18 @@  discard block
 block discarded – undo
935 935
 				'/api/js/jsapi/egw.js?'.filemtime(EGW_SERVER_ROOT.'/api/js/jsapi/egw.js').'" id="egw_script_id"';
936 936
 
937 937
 		// add values of extra parameter and class var as data attributes to script tag of egw.js
938
-		foreach($extra+self::$extra as $name => $value)
938
+		foreach ($extra + self::$extra as $name => $value)
939 939
 		{
940 940
 			if (is_array($value)) $value = json_encode($value);
941 941
 			// we need to double encode (Html::htmlspecialchars( , TRUE)), as otherwise we get invalid json, eg. for quotes
942
-			$java_script .= ' data-'.$name."=\"". Html::htmlspecialchars($value, true)."\"";
942
+			$java_script .= ' data-'.$name."=\"".Html::htmlspecialchars($value, true)."\"";
943 943
 		}
944 944
 		$java_script .= "></script>\n";
945 945
 
946
-		if(@isset($_GET['menuaction']))
946
+		if (@isset($_GET['menuaction']))
947 947
 		{
948
-			list(, $class) = explode('.',$_GET['menuaction']);
949
-			if(is_array($GLOBALS[$class]->public_functions) &&
948
+			list(, $class) = explode('.', $_GET['menuaction']);
949
+			if (is_array($GLOBALS[$class]->public_functions) &&
950 950
 				$GLOBALS[$class]->public_functions['java_script'])
951 951
 			{
952 952
 				$java_script .= $GLOBALS[$class]->java_script();
@@ -955,10 +955,10 @@  discard block
 block discarded – undo
955 955
 		if (isset($GLOBALS['egw_info']['flags']['java_script']))
956 956
 		{
957 957
 			// Strip out any script tags, this needs to be executed as anonymous function
958
-			$GLOBALS['egw_info']['flags']['java_script'] = preg_replace(array('/(<script[^>]*>)([^<]*)/is','/<\/script>/'),array('$2',''),$GLOBALS['egw_info']['flags']['java_script']);
959
-			if(trim($GLOBALS['egw_info']['flags']['java_script']) != '')
958
+			$GLOBALS['egw_info']['flags']['java_script'] = preg_replace(array('/(<script[^>]*>)([^<]*)/is', '/<\/script>/'), array('$2', ''), $GLOBALS['egw_info']['flags']['java_script']);
959
+			if (trim($GLOBALS['egw_info']['flags']['java_script']) != '')
960 960
 			{
961
-				$java_script .= '<script type="text/javascript">window.egw_LAB.wait(function() {'.$GLOBALS['egw_info']['flags']['java_script'] . "});</script>\n";
961
+				$java_script .= '<script type="text/javascript">window.egw_LAB.wait(function() {'.$GLOBALS['egw_info']['flags']['java_script']."});</script>\n";
962 962
 			}
963 963
 		}
964 964
 
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 			{
982 982
 				if (preg_match('/'."\.css$".'/i', $file))
983 983
 				{
984
-					list($name) = explode('.',$file);
984
+					list($name) = explode('.', $file);
985 985
 					$list[$name] = $name;
986 986
 				}
987 987
 			}
@@ -996,21 +996,20 @@  discard block
 block discarded – undo
996 996
 	 * @param boolean $full_data =false true: value is array with values for keys 'name', 'title', ...
997 997
 	 * @returns array alphabetically sorted list of templates
998 998
 	 */
999
-	static function list_templates($full_data=false)
999
+	static function list_templates($full_data = false)
1000 1000
 	{
1001
-		$list = array('pixelegg'=>null,'jdots'=>null,'idots'=>null);
1001
+		$list = array('pixelegg'=>null, 'jdots'=>null, 'idots'=>null);
1002 1002
 		// templates packaged in old phpgwapi
1003
-		if (file_exists(EGW_SERVER_ROOT . '/phpgwapi') && ($d = dir(EGW_SERVER_ROOT . '/phpgwapi/templates')))
1003
+		if (file_exists(EGW_SERVER_ROOT.'/phpgwapi') && ($d = dir(EGW_SERVER_ROOT.'/phpgwapi/templates')))
1004 1004
 		{
1005
-			while (($entry=$d->read()))
1005
+			while (($entry = $d->read()))
1006 1006
 			{
1007
-				if ($entry != '..' && file_exists(EGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry .'/class.'.$entry.'_framework.inc.php'))
1007
+				if ($entry != '..' && file_exists(EGW_SERVER_ROOT.'/phpgwapi/templates/'.$entry.'/class.'.$entry.'_framework.inc.php'))
1008 1008
 				{
1009
-					if (file_exists ($f = EGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/setup/setup.inc.php'))
1009
+					if (file_exists($f = EGW_SERVER_ROOT.'/phpgwapi/templates/'.$entry.'/setup/setup.inc.php'))
1010 1010
 					{
1011 1011
 						include($f);
1012
-						$list[$entry] = $full_data ? $GLOBALS['egw_info']['template'][$entry] :
1013
-							$GLOBALS['egw_info']['template'][$entry]['title'];
1012
+						$list[$entry] = $full_data ? $GLOBALS['egw_info']['template'][$entry] : $GLOBALS['egw_info']['template'][$entry]['title'];
1014 1013
 					}
1015 1014
 					else
1016 1015
 					{
@@ -1025,16 +1024,15 @@  discard block
 block discarded – undo
1025 1024
 		}
1026 1025
 		// templates packaged like apps in own directories (containing as setup/setup.inc.php file!)
1027 1026
 		$dr = dir(EGW_SERVER_ROOT);
1028
-		while (($entry=$dr->read()))
1027
+		while (($entry = $dr->read()))
1029 1028
 		{
1030 1029
 			if ($entry != '..' && !isset($GLOBALS['egw_info']['apps'][$entry]) && is_dir(EGW_SERVER_ROOT.'/'.$entry) &&
1031
-				file_exists($f = EGW_SERVER_ROOT . '/' . $entry .'/setup/setup.inc.php'))
1030
+				file_exists($f = EGW_SERVER_ROOT.'/'.$entry.'/setup/setup.inc.php'))
1032 1031
 			{
1033 1032
 				include($f);
1034 1033
 				if (isset($GLOBALS['egw_info']['template'][$entry]))
1035 1034
 				{
1036
-					$list[$entry] = $full_data ? $GLOBALS['egw_info']['template'][$entry] :
1037
-						$GLOBALS['egw_info']['template'][$entry]['title'];
1035
+					$list[$entry] = $full_data ? $GLOBALS['egw_info']['template'][$entry] : $GLOBALS['egw_info']['template'][$entry]['title'];
1038 1036
 				}
1039 1037
 			}
1040 1038
 		}
@@ -1051,14 +1049,14 @@  discard block
 block discarded – undo
1051 1049
 	* @param array $vars
1052 1050
 	* @param array $apps
1053 1051
 	*/
1054
-	function topmenu(array $vars,array $apps)
1052
+	function topmenu(array $vars, array $apps)
1055 1053
 	{
1056
-		if($GLOBALS['egw_info']['user']['apps']['home'] && isset($apps['home']))
1054
+		if ($GLOBALS['egw_info']['user']['apps']['home'] && isset($apps['home']))
1057 1055
 		{
1058 1056
 			$this->_add_topmenu_item($apps['home']);
1059 1057
 		}
1060 1058
 
1061
-		if($GLOBALS['egw_info']['user']['apps']['preferences'])
1059
+		if ($GLOBALS['egw_info']['user']['apps']['preferences'])
1062 1060
 		{
1063 1061
 			$this->add_preferences_topmenu('prefs');
1064 1062
 			$this->add_preferences_topmenu('acl');
@@ -1083,9 +1081,9 @@  discard block
 block discarded – undo
1083 1081
 			$this->_add_topmenu_item(array_merge($apps['manual'],array('title' => lang('Help'))));
1084 1082
 		}*/
1085 1083
 
1086
-		Hooks::process('topmenu_info',array(),true);
1084
+		Hooks::process('topmenu_info', array(), true);
1087 1085
 		// Add extra items added by hooks
1088
-		foreach(self::$top_menu_extra as $extra_item) {
1086
+		foreach (self::$top_menu_extra as $extra_item) {
1089 1087
 			$this->_add_topmenu_item($extra_item);
1090 1088
 		}
1091 1089
 
@@ -1095,7 +1093,7 @@  discard block
 block discarded – undo
1095 1093
 		{
1096 1094
 			$this->_add_topmenu_info_item($update, 'update');
1097 1095
 		}
1098
-		if($GLOBALS['egw_info']['user']['apps']['notifications'])
1096
+		if ($GLOBALS['egw_info']['user']['apps']['notifications'])
1099 1097
 		{
1100 1098
 			$this->_add_topmenu_info_item(self::_get_notification_bell(), 'notifications');
1101 1099
 		}
@@ -1107,9 +1105,9 @@  discard block
 block discarded – undo
1107 1105
 	/**
1108 1106
 	 * Add Preferences link to topmenu using settings-hook to know if an app supports Preferences
1109 1107
 	 */
1110
-	protected function add_preferences_topmenu($type='prefs')
1108
+	protected function add_preferences_topmenu($type = 'prefs')
1111 1109
 	{
1112
-		static $memberships=null;
1110
+		static $memberships = null;
1113 1111
 		if (!isset($memberships)) $memberships = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true);
1114 1112
 		static $types = array(
1115 1113
 			'prefs' => array(
@@ -1123,20 +1121,20 @@  discard block
 block discarded – undo
1123 1121
 			'cats' => array(
1124 1122
 				'title' => 'Categories',
1125 1123
 				'hook' => 'categories',
1126
-				'run_hook' => true,	// acturally run hook, not just look it's implemented
1124
+				'run_hook' => true, // acturally run hook, not just look it's implemented
1127 1125
 			),
1128 1126
 		);
1129 1127
 		if (!$GLOBALS['egw_info']['user']['apps']['preferences'] || $GLOBALS['egw_info']['server']['deny_'.$type] &&
1130 1128
 			array_intersect($memberships, (array)$GLOBALS['egw_info']['server']['deny_'.$type]) &&
1131 1129
 			!$GLOBALS['egw_info']['user']['apps']['admin'])
1132 1130
 		{
1133
-			return;	// user has no access to Preferences app
1131
+			return; // user has no access to Preferences app
1134 1132
 		}
1135 1133
 		if (isset($types[$type]['run_hook']))
1136 1134
 		{
1137 1135
 			$apps = Hooks::process($types[$type]['hook']);
1138 1136
 			// as all apps answer, we need to remove none-true responses
1139
-			foreach($apps as $app => $val)
1137
+			foreach ($apps as $app => $val)
1140 1138
 			{
1141 1139
 				if (!$val) unset($apps[$app]);
1142 1140
 			}
@@ -1162,7 +1160,7 @@  discard block
 block discarded – undo
1162 1160
 	* @access protected
1163 1161
 	* @return void
1164 1162
 	*/
1165
-	abstract function _add_topmenu_item(array $app_data,$alt_label=null);
1163
+	abstract function _add_topmenu_item(array $app_data, $alt_label = null);
1166 1164
 
1167 1165
 	/**
1168 1166
 	* Add info items to the topmenu template class to be displayed
@@ -1172,7 +1170,7 @@  discard block
 block discarded – undo
1172 1170
 	* @access protected
1173 1171
 	* @return void
1174 1172
 	*/
1175
-	abstract function _add_topmenu_info_item($content, $id=null);
1173
+	abstract function _add_topmenu_info_item($content, $id = null);
1176 1174
 
1177 1175
 	static $top_menu_extra = array();
1178 1176
 
@@ -1187,7 +1185,7 @@  discard block
 block discarded – undo
1187 1185
 	* @access public
1188 1186
 	* @return void
1189 1187
 	*/
1190
-	public static function add_topmenu_item($id,$url,$title,$target = '')
1188
+	public static function add_topmenu_item($id, $url, $title, $target = '')
1191 1189
 	{
1192 1190
 		$entry['name'] = $id;
1193 1191
 		$entry['url'] = $url;
@@ -1208,7 +1206,7 @@  discard block
 block discarded – undo
1208 1206
 	* @access public
1209 1207
 	* @return void
1210 1208
 	*/
1211
-	abstract function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null);
1209
+	abstract function topmenu_info_icon($id, $icon_src, $iconlink, $blink = false, $tooltip = null);
1212 1210
 
1213 1211
 	/**
1214 1212
 	 * Call and return content of 'after_navbar' hook
@@ -1218,7 +1216,7 @@  discard block
 block discarded – undo
1218 1216
 	protected function _get_after_navbar()
1219 1217
 	{
1220 1218
 		ob_start();
1221
-		Hooks::process('after_navbar',null,true);
1219
+		Hooks::process('after_navbar', null, true);
1222 1220
 		$content = ob_get_contents();
1223 1221
 		ob_end_clean();
1224 1222
 
@@ -1255,7 +1253,7 @@  discard block
 block discarded – undo
1255 1253
 	* @param string $app ='phpgwapi' application directory to search - default = phpgwapi
1256 1254
 	* @param boolean $append =true should the file be added
1257 1255
 	*/
1258
-	static function includeJS($package, $file=null, $app='phpgwapi')
1256
+	static function includeJS($package, $file = null, $app = 'phpgwapi')
1259 1257
 	{
1260 1258
 		self::$js_include_mgr->include_js_file($package, $file, $app);
1261 1259
 	}
@@ -1267,7 +1265,7 @@  discard block
 block discarded – undo
1267 1265
 	 * @param boolean $clear_files =false true clear files after returning them
1268 1266
 	 * @return array with pathes relative to EGW_SERVER_ROOT
1269 1267
 	 */
1270
-	static function js_files(array $files=null, $clear_files=false)
1268
+	static function js_files(array $files = null, $clear_files = false)
1271 1269
 	{
1272 1270
 		if (isset($files) && is_array($files))
1273 1271
 		{
@@ -1286,7 +1284,7 @@  discard block
 block discarded – undo
1286 1284
 	 * @param boolean $clear_files =false true clear files after returning them
1287 1285
 	 * @return string|array see $return_pathes parameter
1288 1286
 	 */
1289
-	static public function get_script_links($return_pathes=false, $clear_files=false)
1287
+	static public function get_script_links($return_pathes = false, $clear_files = false)
1290 1288
 	{
1291 1289
 		$to_include = Framework\Bundle::js_includes(self::$js_include_mgr->get_included_files($clear_files));
1292 1290
 
@@ -1294,7 +1292,7 @@  discard block
 block discarded – undo
1294 1292
 		{
1295 1293
 			return $to_include;
1296 1294
 		}
1297
-		$start = '<script type="text/javascript" src="'. $GLOBALS['egw_info']['server']['webserver_url'];
1295
+		$start = '<script type="text/javascript" src="'.$GLOBALS['egw_info']['server']['webserver_url'];
1298 1296
 		$end = '">'."</script>\n";
1299 1297
 		return "\n".$start.implode($end.$start, $to_include).$end;
1300 1298
 	}
@@ -1314,7 +1312,7 @@  discard block
 block discarded – undo
1314 1312
 	 * @param boolean $no_default_css =false true do NOT load any default css, only what app explicitly includes
1315 1313
 	 * @return boolean false: css file not found, true: file found
1316 1314
 	 */
1317
-	public static function includeCSS($app, $name=null, $append=true, $no_default_css=false)
1315
+	public static function includeCSS($app, $name = null, $append = true, $no_default_css = false)
1318 1316
 	{
1319 1317
 		if ($no_default_css)
1320 1318
 		{
@@ -1334,16 +1332,16 @@  discard block
 block discarded – undo
1334 1332
 
1335 1333
 		// try to add app specific css file
1336 1334
 		self::includeCSS($app, 'app-'.$GLOBALS['egw_info']['user']['preferences']['common']['theme']) ||
1337
-			self::includeCSS($app,'app');
1335
+			self::includeCSS($app, 'app');
1338 1336
 
1339 1337
 		// add all css files from Framework::includeCSS()
1340 1338
 		$query = null;
1341 1339
 		//error_log(__METHOD__."() Framework\CssIncludes::get()=".array2string(Framework\CssIncludes::get()));
1342
-		foreach(Framework\CssIncludes::get() as $path)
1340
+		foreach (Framework\CssIncludes::get() as $path)
1343 1341
 		{
1344 1342
 			unset($query);
1345
-			list($path,$query) = explode('?',$path,2);
1346
-			$path .= '?'. ($query ? $query : filemtime(EGW_SERVER_ROOT.$path));
1343
+			list($path, $query) = explode('?', $path, 2);
1344
+			$path .= '?'.($query ? $query : filemtime(EGW_SERVER_ROOT.$path));
1347 1345
 			$response->includeCSS($GLOBALS['egw_info']['server']['webserver_url'].$path);
1348 1346
 		}
1349 1347
 
@@ -1352,7 +1350,7 @@  discard block
 block discarded – undo
1352 1350
 
1353 1351
 		// add all js files from Framework::includeJS()
1354 1352
 		$files = Framework\Bundle::js_includes(self::$js_include_mgr->get_included_files());
1355
-		foreach($files as $path)
1353
+		foreach ($files as $path)
1356 1354
 		{
1357 1355
 			$response->includeScript($GLOBALS['egw_info']['server']['webserver_url'].$path);
1358 1356
 		}
@@ -1428,17 +1426,17 @@  discard block
 block discarded – undo
1428 1426
 	 */
1429 1427
 	public static function ajax_user_list()
1430 1428
 	{
1431
-		$list = array('accounts' => array(),'groups' => array(), 'owngroups' => array());
1432
-		if($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] == 'primary_group')
1429
+		$list = array('accounts' => array(), 'groups' => array(), 'owngroups' => array());
1430
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] == 'primary_group')
1433 1431
 		{
1434 1432
 			$list['accounts']['filter']['group'] = $GLOBALS['egw_info']['user']['account_primary_group'];
1435 1433
 		}
1436
-		foreach($list as $type => &$accounts)
1434
+		foreach ($list as $type => &$accounts)
1437 1435
 		{
1438 1436
 			$options = array('account_type' => $type) + $accounts;
1439
-			$key_pair = Accounts::link_query('',$options);
1437
+			$key_pair = Accounts::link_query('', $options);
1440 1438
 			$accounts = array();
1441
-			foreach($key_pair as $account_id => $name)
1439
+			foreach ($key_pair as $account_id => $name)
1442 1440
 			{
1443 1441
 				$accounts[] = array('value' => $account_id, 'label' => $name);
1444 1442
 			}
@@ -1456,16 +1454,16 @@  discard block
 block discarded – undo
1456 1454
 	 * @param boolean $_resolve_groups =false true: return attribute for all members, false return attribute for group itself
1457 1455
 	 * @return array account_id => data pairs
1458 1456
 	 */
1459
-	public static function ajax_account_data($_account_ids, $_field, $_resolve_groups=false)
1457
+	public static function ajax_account_data($_account_ids, $_field, $_resolve_groups = false)
1460 1458
 	{
1461 1459
 		$list = array();
1462
-		foreach((array)$_account_ids as $account_id)
1460
+		foreach ((array)$_account_ids as $account_id)
1463 1461
 		{
1464
-			foreach($account_id < 0 && $_resolve_groups ?
1462
+			foreach ($account_id < 0 && $_resolve_groups ?
1465 1463
 				$GLOBALS['egw']->accounts->members($account_id, true) : array($account_id) as $account_id)
1466 1464
 			{
1467 1465
 				// Make sure name is formatted according to preference
1468
-				if($_field == 'account_fullname')
1466
+				if ($_field == 'account_fullname')
1469 1467
 				{
1470 1468
 					$list[$account_id] = Accounts::format_username(
1471 1469
 						$GLOBALS['egw']->accounts->id2name($account_id, 'account_lid'),
Please login to merge, or discard this patch.
Braces   +54 added lines, -15 removed lines patch added patch discarded remove patch
@@ -117,7 +117,10 @@  discard block
 block discarded – undo
117 117
 		if (file_exists(EGW_SERVER_ROOT.'/phpgwapi'))
118 118
 		{
119 119
 			// default to idots, if no template_set set, to eg. not stall installations if settings use self::link
120
-			if (empty($GLOBALS['egw_info']['server']['template_set'])) $GLOBALS['egw_info']['server']['template_set'] = 'idots';
120
+			if (empty($GLOBALS['egw_info']['server']['template_set']))
121
+			{
122
+				$GLOBALS['egw_info']['server']['template_set'] = 'idots';
123
+			}
121 124
 			// setup the new eGW framework (template sets)
122 125
 			$class = $GLOBALS['egw_info']['server']['template_set'].'_framework';
123 126
 			if (!class_exists($class) &&	// first try to autoload the class
@@ -240,7 +243,10 @@  discard block
 block discarded – undo
240 243
 		}
241 244
 
242 245
 		// commit session (if existing), to fix timing problems sometimes preventing session creation ("Your session can not be verified")
243
-		if (isset($GLOBALS['egw']->session)) $GLOBALS['egw']->session->commit_session();
246
+		if (isset($GLOBALS['egw']->session))
247
+		{
248
+			$GLOBALS['egw']->session->commit_session();
249
+		}
244 250
 
245 251
 		exit;
246 252
 	}
@@ -270,8 +276,14 @@  discard block
 block discarded – undo
270 276
 	 */
271 277
 	function render($content,$app_header=null,$navbar=null)
272 278
 	{
273
-		if (!is_null($app_header)) $GLOBALS['egw_info']['flags']['app_header'] = $app_header;
274
-		if (!is_null($navbar)) $GLOBALS['egw_info']['flags']['nonavbar'] = !$navbar;
279
+		if (!is_null($app_header))
280
+		{
281
+			$GLOBALS['egw_info']['flags']['app_header'] = $app_header;
282
+		}
283
+		if (!is_null($navbar))
284
+		{
285
+			$GLOBALS['egw_info']['flags']['nonavbar'] = !$navbar;
286
+		}
275 287
 
276 288
 		echo $this->header();
277 289
 
@@ -449,7 +461,10 @@  discard block
 block discarded – undo
449 461
 		// send appheader to clientside
450 462
 		$extra['app-header'] = $app_header;
451 463
 
452
-		if($GLOBALS['egw_info']['flags']['currentapp'] != 'wiki') $robots ='<meta name="robots" content="none" />';
464
+		if($GLOBALS['egw_info']['flags']['currentapp'] != 'wiki')
465
+		{
466
+			$robots ='<meta name="robots" content="none" />';
467
+		}
453 468
 
454 469
 		if (substr($GLOBALS['egw_info']['server']['favicon_file'],0,4) == 'http')
455 470
 		{
@@ -691,13 +706,19 @@  discard block
 block discarded – undo
691 706
 		$ind_b = isset($arr[$b['name']]) ? $arr[$b['name']] : null;
692 707
 
693 708
 		if ($ind_a == $ind_b)
694
-			return 0;
709
+		{
710
+					return 0;
711
+		}
695 712
 
696 713
 		if ($ind_a == null)
697
-			return -1;
714
+		{
715
+					return -1;
716
+		}
698 717
 
699 718
 		if ($ind_b == null)
700
-			return 1;
719
+		{
720
+					return 1;
721
+		}
701 722
 
702 723
 		return $ind_a > $ind_b ? 1 : -1;
703 724
 	}
@@ -786,9 +807,12 @@  discard block
 block discarded – undo
786 807
 			$app_title = $GLOBALS['egw_info']['apps'][$app]['title'];
787 808
 		}
788 809
 
789
-		if ($GLOBALS['egw_info']['user']['apps']['preferences'])	// Preferences last
810
+		if ($GLOBALS['egw_info']['user']['apps']['preferences'])
811
+		{
812
+			// Preferences last
790 813
 		{
791 814
 			$prefs = $apps['preferences'];
815
+		}
792 816
 			unset($apps['preferences']);
793 817
 			$apps['preferences'] = $prefs;
794 818
 		}
@@ -838,7 +862,10 @@  discard block
 block discarded – undo
838 862
 			$themes_to_check[] = $this->template_dir.'/css/'.$this->template.'.css';
839 863
 			foreach($themes_to_check as $theme_css)
840 864
 			{
841
-				if (file_exists(EGW_SERVER_ROOT.$theme_css)) break;
865
+				if (file_exists(EGW_SERVER_ROOT.$theme_css))
866
+				{
867
+					break;
868
+				}
842 869
 			}
843 870
 			$debug_minify = $GLOBALS['egw_info']['server']['debug_minify'] === 'True';
844 871
 			if (!$debug_minify && file_exists(EGW_SERVER_ROOT.($theme_min_css = str_replace('.css', '.min.css', $theme_css))))
@@ -925,7 +952,9 @@  discard block
 block discarded – undo
925 952
 		}
926 953
 
927 954
 		$extra['url'] = $GLOBALS['egw_info']['server']['webserver_url'];
928
-		$extra['include'] = array_map(function($str){return substr($str,1);}, self::get_script_links(true), array(1));
955
+		$extra['include'] = array_map(function($str)
956
+		{
957
+return substr($str,1);}, self::get_script_links(true), array(1));
929 958
 		$extra['app'] = $GLOBALS['egw_info']['flags']['currentapp'];
930 959
 
931 960
 		// Load LABjs ONCE here
@@ -937,7 +966,10 @@  discard block
 block discarded – undo
937 966
 		// add values of extra parameter and class var as data attributes to script tag of egw.js
938 967
 		foreach($extra+self::$extra as $name => $value)
939 968
 		{
940
-			if (is_array($value)) $value = json_encode($value);
969
+			if (is_array($value))
970
+			{
971
+				$value = json_encode($value);
972
+			}
941 973
 			// we need to double encode (Html::htmlspecialchars( , TRUE)), as otherwise we get invalid json, eg. for quotes
942 974
 			$java_script .= ' data-'.$name."=\"". Html::htmlspecialchars($value, true)."\"";
943 975
 		}
@@ -1085,7 +1117,8 @@  discard block
 block discarded – undo
1085 1117
 
1086 1118
 		Hooks::process('topmenu_info',array(),true);
1087 1119
 		// Add extra items added by hooks
1088
-		foreach(self::$top_menu_extra as $extra_item) {
1120
+		foreach(self::$top_menu_extra as $extra_item)
1121
+		{
1089 1122
 			$this->_add_topmenu_item($extra_item);
1090 1123
 		}
1091 1124
 
@@ -1110,7 +1143,10 @@  discard block
 block discarded – undo
1110 1143
 	protected function add_preferences_topmenu($type='prefs')
1111 1144
 	{
1112 1145
 		static $memberships=null;
1113
-		if (!isset($memberships)) $memberships = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true);
1146
+		if (!isset($memberships))
1147
+		{
1148
+			$memberships = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true);
1149
+		}
1114 1150
 		static $types = array(
1115 1151
 			'prefs' => array(
1116 1152
 				'title' => 'Preferences',
@@ -1138,7 +1174,10 @@  discard block
 block discarded – undo
1138 1174
 			// as all apps answer, we need to remove none-true responses
1139 1175
 			foreach($apps as $app => $val)
1140 1176
 			{
1141
-				if (!$val) unset($apps[$app]);
1177
+				if (!$val)
1178
+				{
1179
+					unset($apps[$app]);
1180
+				}
1142 1181
 			}
1143 1182
 		}
1144 1183
 		else
Please login to merge, or discard this patch.
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 	 */
355 355
 	public function _get_footer()
356 356
 	{
357
-		$var = Array(
357
+		$var = array(
358 358
 			'img_root'       => $GLOBALS['egw_info']['server']['webserver_url'] . $this->template_dir.'/images',
359 359
 			'version'        => $GLOBALS['egw_info']['server']['versions']['phpgwapi']
360 360
 		);
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
 
764 764
 				$icon = isset($data['icon']) ?  $data['icon'] : 'navbar';
765 765
 				$icon_app = isset($data['icon_app']) ? $data['icon_app'] : $app;
766
-				$apps[$app]['icon']  = $apps[$app]['icon_hover']  = Image::find($icon_app,Array($icon,'nonav'),'',$svg);
766
+				$apps[$app]['icon']  = $apps[$app]['icon_hover']  = Image::find($icon_app,array($icon,'nonav'),'',$svg);
767 767
 			}
768 768
 		}
769 769
 
@@ -796,13 +796,13 @@  discard block
 block discarded – undo
796 796
 		// We handle this here because its special
797 797
 		$apps['about']['title'] = 'EGroupware';
798 798
 		$apps['about']['url']   = self::link('/about.php');
799
-		$apps['about']['icon']  = $apps['about']['icon_hover'] = Image::find('api',Array('about','nonav'));
799
+		$apps['about']['icon']  = $apps['about']['icon_hover'] = Image::find('api',array('about','nonav'));
800 800
 		$apps['about']['name']  = 'about';
801 801
 
802 802
 		$apps['logout']['title'] = lang('Logout');
803 803
 		$apps['logout']['name']  = 'logout';
804 804
 		$apps['logout']['url']   = self::link('/logout.php');
805
-		$apps['logout']['icon']  = $apps['logout']['icon_hover'] = Image::find('api',Array('logout','nonav'));
805
+		$apps['logout']['icon']  = $apps['logout']['icon_hover'] = Image::find('api',array('logout','nonav'));
806 806
 
807 807
 		return $apps;
808 808
 	}
Please login to merge, or discard this patch.
api/src/Framework/CssIncludes.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@
 block discarded – undo
145 145
 	 * Parse beginning of given CSS file for /*@import url("...") statements
146 146
 	 *
147 147
 	 * @param string $path EGroupware relative path eg. /phpgwapi/templates/default/some.css
148
-	 * @return array parsed pathes (EGroupware relative) including $path itself
148
+	 * @return string[] parsed pathes (EGroupware relative) including $path itself
149 149
 	 */
150 150
 	protected static function resolve_css_includes($path, &$pathes=array())
151 151
 	{
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @param boolean $clear_includes =false true: clear all previous includes
35 35
 	 * @return boolean false: css file not found, true: file found
36 36
 	 */
37
-	public static function add($app, $name=null, $append=true, $clear_includes=false)
37
+	public static function add($app, $name = null, $append = true, $clear_includes = false)
38 38
 	{
39 39
 		if ($clear_includes)
40 40
 		{
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
 		if (!is_null($name))
45 45
 		{
46
-			foreach($GLOBALS['egw']->framework->template_dirs as $dir)
46
+			foreach ($GLOBALS['egw']->framework->template_dirs as $dir)
47 47
 			{
48 48
 				if (file_exists(EGW_SERVER_ROOT.($path = '/'.$app.'/templates/'.$dir.'/'.$name.'.css')))
49 49
 				{
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
 		{
56 56
 			$path = $app;
57 57
 		}
58
-		if (!file_exists(EGW_SERVER_ROOT.$path) && !file_exists(EGW_SERVER_ROOT . parse_url($path,PHP_URL_PATH)))
58
+		if (!file_exists(EGW_SERVER_ROOT.$path) && !file_exists(EGW_SERVER_ROOT.parse_url($path, PHP_URL_PATH)))
59 59
 		{
60 60
 			//error_log(__METHOD__."($app,$name) $path NOT found!");
61 61
 			return false;
62 62
 		}
63
-		if (!in_array($path,self::$files))
63
+		if (!in_array($path, self::$files))
64 64
 		{
65 65
 			if ($append)
66 66
 			{
@@ -79,16 +79,16 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @return string
81 81
 	 */
82
-	public static function get($resolve=false)
82
+	public static function get($resolve = false)
83 83
 	{
84 84
 		if (!$resolve)
85 85
 		{
86 86
 			return self::$files;
87 87
 		}
88 88
 		$files = array();
89
-		foreach(self::$files as $path)
89
+		foreach (self::$files as $path)
90 90
 		{
91
-			foreach(self::resolve_css_includes($path) as $path)
91
+			foreach (self::resolve_css_includes($path) as $path)
92 92
 			{
93 93
 				$files[] = $path;
94 94
 			}
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 		$base_path = $GLOBALS['egw_info']['server']['webserver_url'];
110 110
 		if ($base_path[0] != '/') $base_path = parse_url($base_path, PHP_URL_PATH);
111 111
 		$css_files = '';
112
-		foreach(self::$files as $path)
112
+		foreach (self::$files as $path)
113 113
 		{
114
-			foreach(self::resolve_css_includes($path) as $path)
114
+			foreach (self::resolve_css_includes($path) as $path)
115 115
 			{
116
-				list($file,$query) = explode('?',$path,2);
116
+				list($file, $query) = explode('?', $path, 2);
117 117
 				if (($mod = filemtime(EGW_SERVER_ROOT.$file)) > $max_modified) $max_modified = $mod;
118 118
 
119 119
 				// do NOT include app.css or categories.php, as it changes from app to app
@@ -147,20 +147,20 @@  discard block
 block discarded – undo
147 147
 	 * @param string $path EGroupware relative path eg. /phpgwapi/templates/default/some.css
148 148
 	 * @return array parsed pathes (EGroupware relative) including $path itself
149 149
 	 */
150
-	protected static function resolve_css_includes($path, &$pathes=array())
150
+	protected static function resolve_css_includes($path, &$pathes = array())
151 151
 	{
152 152
 		$matches = null;
153 153
 
154
-		list($file) = explode('?',$path,2);
155
-		if (($to_check = file_get_contents (EGW_SERVER_ROOT.$file, false, null, -1, 1024)) &&
154
+		list($file) = explode('?', $path, 2);
155
+		if (($to_check = file_get_contents(EGW_SERVER_ROOT.$file, false, null, -1, 1024)) &&
156 156
 			stripos($to_check, '/*@import') !== false && preg_match_all('|/\*@import url\("([^"]+)"|i', $to_check, $matches))
157 157
 		{
158
-			foreach($matches[1] as $import_path)
158
+			foreach ($matches[1] as $import_path)
159 159
 			{
160 160
 				if ($import_path[0] != '/')
161 161
 				{
162 162
 					$dir = dirname($path);
163
-					while(substr($import_path,0,3) == '../')
163
+					while (substr($import_path, 0, 3) == '../')
164 164
 					{
165 165
 						$dir = dirname($dir);
166 166
 						$import_path = substr($import_path, 3);
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -107,14 +107,20 @@
 block discarded – undo
107 107
 		$max_modified = 0;
108 108
 		//no more dynamic minifying: $debug_minify = $GLOBALS['egw_info']['server']['debug_minify'] === 'True';
109 109
 		$base_path = $GLOBALS['egw_info']['server']['webserver_url'];
110
-		if ($base_path[0] != '/') $base_path = parse_url($base_path, PHP_URL_PATH);
110
+		if ($base_path[0] != '/')
111
+		{
112
+			$base_path = parse_url($base_path, PHP_URL_PATH);
113
+		}
111 114
 		$css_files = '';
112 115
 		foreach(self::$files as $path)
113 116
 		{
114 117
 			foreach(self::resolve_css_includes($path) as $path)
115 118
 			{
116 119
 				list($file,$query) = explode('?',$path,2);
117
-				if (($mod = filemtime(EGW_SERVER_ROOT.$file)) > $max_modified) $max_modified = $mod;
120
+				if (($mod = filemtime(EGW_SERVER_ROOT.$file)) > $max_modified)
121
+				{
122
+					$max_modified = $mod;
123
+				}
118 124
 
119 125
 				// do NOT include app.css or categories.php, as it changes from app to app
120 126
 				//no more dynamic minifying: if ($debug_minify || substr($path, -8) == '/app.css' || substr($file,-14) == 'categories.php')
Please login to merge, or discard this patch.
api/src/Framework/Favorites.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -187,7 +187,7 @@
 block discarded – undo
187 187
 	 * @param string $action "add" or "delete"
188 188
 	 * @param boolean|int|String $group ID of the group to create the favorite for, or 'all' for all users
189 189
 	 * @param array $filters key => value pairs for the filter
190
-	 * @return boolean Success
190
+	 * @return boolean|null Success
191 191
 	 */
192 192
 	public static function set_favorite($app, $_name, $action, $group, $filters = array())
193 193
 	{
Please login to merge, or discard this patch.
Spacing   +22 added lines, -23 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @return array with a single sidebox menu item (array) containing html for favorites
44 44
 	 */
45
-	public static function list_favorites($app, $default=null)
45
+	public static function list_favorites($app, $default = null)
46 46
 	{
47 47
 		if (!$app)
48 48
 		{
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		$target = 'favorite_sidebox_'.$app;
59 59
 
60 60
 		/* @var $filters array an array of favorites*/
61
-		$filters =  self::get_favorites($app);
61
+		$filters = self::get_favorites($app);
62 62
 		$is_admin = $GLOBALS['egw_info']['user']['apps']['admin'];
63 63
 		$html = "<span id='$target' class='ui-helper-clearfix sidebox-favorites'><ul class='ui-menu ui-widget-content ui-corner-all favorites' role='listbox'>\n";
64 64
 
@@ -69,25 +69,24 @@  discard block
 block discarded – undo
69 69
 		}
70 70
 
71 71
 		// Get link for if there is no nextmatch - this is the fallback
72
-		$registry = Api\Link::get_registry($app,'list');
72
+		$registry = Api\Link::get_registry($app, 'list');
73 73
 		if (!$registry)
74 74
 		{
75 75
 			$registry = Api\Link::get_registry($app, 'index');
76 76
 		}
77
-		foreach($filters as $name => $filter)
77
+		foreach ($filters as $name => $filter)
78 78
 		{
79 79
 			//filter must not be empty if there's one, ignore it at the moment but it need to be checked how it got there in database
80 80
 			if (!$filter)
81 81
 			{
82
-				error_log(__METHOD__.'Favorite filter "'.$name.'" is not supposed to be empty, it should be an array.  Skipping, more investigation needed. filter = '. array2string($filters[$name]));
82
+				error_log(__METHOD__.'Favorite filter "'.$name.'" is not supposed to be empty, it should be an array.  Skipping, more investigation needed. filter = '.array2string($filters[$name]));
83 83
 				continue;
84 84
 			}
85 85
 			$li = "<li data-id='$name' data-group='{$filter['group']}' class='ui-menu-item' role='menuitem'>\n";
86 86
 			$li .= '<a href="#" class="ui-corner-all" tabindex="-1">';
87
-			$li .= "<div class='" . ((string)$name === (string)$default_filter ? 'ui-icon ui-icon-heart' : 'sideboxstar') . "'></div>".
87
+			$li .= "<div class='".((string)$name === (string)$default_filter ? 'ui-icon ui-icon-heart' : 'sideboxstar')."'></div>".
88 88
 				$filter['name'];
89
-			$li .= ($filter['group'] != false && !$is_admin || $name === 'blank' ? "" :
90
-				"<div class='ui-icon ui-icon-trash' title='" . lang('Delete') . "'></div>");
89
+			$li .= ($filter['group'] != false && !$is_admin || $name === 'blank' ? "" : "<div class='ui-icon ui-icon-trash' title='".lang('Delete')."'></div>");
91 90
 			$li .= "</a></li>\n";
92 91
 			//error_log(__METHOD__."() $name, filter=".array2string($filter)." --> ".$li);
93 92
 			$html .= $li;
@@ -95,7 +94,7 @@  discard block
 block discarded – undo
95 94
 
96 95
 		// If were're here, the app supports favorites, so add a 'Add' link too
97 96
 		$html .= "<li data-id='add' class='ui-menu-item' role='menuitem'><a href='javascript:app.$app.add_favorite()' class='ui-corner-all'>";
98
-		$html .= Api\Html::image($app, 'new') . lang('Add current'). '</a></li>';
97
+		$html .= Api\Html::image($app, 'new').lang('Add current').'</a></li>';
99 98
 
100 99
 		$html .= '</ul></span>';
101 100
 
@@ -117,7 +116,7 @@  discard block
 block discarded – undo
117 116
 	 * @return (array|boolean) An array of sorted favorites or False if there's no preferenced sorted list
118 117
 	 *
119 118
 	 */
120
-	public static function get_fav_sort_pref ($app)
119
+	public static function get_fav_sort_pref($app)
121 120
 	{
122 121
 		$fav_sorted_list = array();
123 122
 
@@ -157,13 +156,13 @@  discard block
 block discarded – undo
157 156
 		$fav_sort_pref = self::get_fav_sort_pref($app);
158 157
 
159 158
 		// Look through all preferences & pull out favorites
160
-		foreach((array)$GLOBALS['egw_info']['user']['preferences'][$app] as $pref_name => $pref)
159
+		foreach ((array)$GLOBALS['egw_info']['user']['preferences'][$app] as $pref_name => $pref)
161 160
 		{
162
-			if(strpos($pref_name, $pref_prefix) === 0)
161
+			if (strpos($pref_name, $pref_prefix) === 0)
163 162
 			{
164
-				if(!is_array($pref)) continue;	// old favorite
163
+				if (!is_array($pref)) continue; // old favorite
165 164
 
166
-				$favorites[(string)substr($pref_name,strlen($pref_prefix))] = $pref;
165
+				$favorites[(string)substr($pref_name, strlen($pref_prefix))] = $pref;
167 166
 			}
168 167
 		}
169 168
 		if (is_array($fav_sort_pref))
@@ -172,7 +171,7 @@  discard block
 block discarded – undo
172 171
 			{
173 172
 				$sorted_list[$key] = $favorites[$key];
174 173
 			}
175
-			$favorites = array_merge($sorted_list,$favorites);
174
+			$favorites = array_merge($sorted_list, $favorites);
176 175
 		}
177 176
 		return $favorites;
178 177
 	}
@@ -204,7 +203,7 @@  discard block
 block discarded – undo
204 203
 			}
205 204
 			else
206 205
 			{
207
-				foreach($GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $gid)
206
+				foreach ($GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $gid)
208 207
 				{
209 208
 					$prefs = new Api\Preferences($gid);
210 209
 					$prefs->read_repository();
@@ -216,7 +215,7 @@  discard block
 block discarded – undo
216 215
 				}
217 216
 			}
218 217
 		}
219
-		if($group && $GLOBALS['egw_info']['apps']['admin'] && $group !== 'all')
218
+		if ($group && $GLOBALS['egw_info']['apps']['admin'] && $group !== 'all')
220 219
 		{
221 220
 			$prefs = new Api\Preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']);
222 221
 		}
@@ -227,7 +226,7 @@  discard block
 block discarded – undo
227 226
 		$prefs->read_repository();
228 227
 		$type = $group === "all" ? "default" : "user";
229 228
 		//error_log(__METHOD__."('$app', '$name', '$action', ".array2string($group).", ...) pref_name=$pref_name, type=$type");
230
-		if($action == "add")
229
+		if ($action == "add")
231 230
 		{
232 231
 			$filters = array(
233 232
 				// This is the name as user entered it, minus tags
@@ -235,9 +234,9 @@  discard block
 block discarded – undo
235 234
 				'group' => $group ? $group : false,
236 235
 				'state' => $filters
237 236
 			);
238
-			$pref_name = "favorite_".preg_replace('/[^A-Za-z0-9-_]/','_',$name);
239
-			$result = $prefs->add($app,$pref_name,$filters,$type);
240
-			$pref = $prefs->save_repository(false,$type);
237
+			$pref_name = "favorite_".preg_replace('/[^A-Za-z0-9-_]/', '_', $name);
238
+			$result = $prefs->add($app, $pref_name, $filters, $type);
239
+			$pref = $prefs->save_repository(false, $type);
241 240
 
242 241
 			// Update preferences client side, or it could disappear
243 242
 			Api\Json\Response::get()->call('egw.set_preferences', (array)$pref[$app], $app);
@@ -247,8 +246,8 @@  discard block
 block discarded – undo
247 246
 		}
248 247
 		else if ($action == "delete")
249 248
 		{
250
-			$result = $prefs->delete($app,$pref_name, $type);
251
-			$pref = $prefs->save_repository(false,$type);
249
+			$result = $prefs->delete($app, $pref_name, $type);
250
+			$pref = $prefs->save_repository(false, $type);
252 251
 
253 252
 			// Update preferences client side, or it could come back
254 253
 			Api\Json\Response::get()->call('egw.set_preferences', (array)$pref[$app], $app);
Please login to merge, or discard this patch.
Braces   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -161,7 +161,11 @@
 block discarded – undo
161 161
 		{
162 162
 			if(strpos($pref_name, $pref_prefix) === 0)
163 163
 			{
164
-				if(!is_array($pref)) continue;	// old favorite
164
+				if(!is_array($pref))
165
+				{
166
+					continue;
167
+				}
168
+				// old favorite
165 169
 
166 170
 				$favorites[(string)substr($pref_name,strlen($pref_prefix))] = $pref;
167 171
 			}
Please login to merge, or discard this patch.